This commit is contained in:
Michael Puckett 2022-10-14 17:15:27 -04:00
parent 3559951474
commit ffc0359085
21 changed files with 9114 additions and 21 deletions

View File

@ -0,0 +1,11 @@
# `activitypub-core-example-2`
> TODO: description
## Usage
```
const activitypubCoreExample2 = require('activitypub-core-example-2');
// TODO: DEMONSTRATE API
```

View File

@ -0,0 +1,7 @@
'use strict';
const activitypubCoreExample2 = require('..');
const assert = require('assert').strict;
assert.strictEqual(activitypubCoreExample2(), 'Hello from activitypubCoreExample2');
console.info("activitypubCoreExample2 tests passed");

View File

@ -0,0 +1,7 @@
'use strict';
module.exports = activitypubCoreExample2;
function activitypubCoreExample2() {
return "Hello from activitypubCoreExample2";
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,43 @@
{
"name": "activitypub-core-example-2",
"version": "0.0.54",
"description": "> TODO: description",
"author": "Michael Puckett <michaelcpuckett@gmail.com>",
"homepage": "https://github.com/michaelcpuckett/activitypub-core#readme",
"license": "MIT",
"main": "lib/activitypub-core-example-2.js",
"directories": {
"lib": "lib",
"test": "__tests__"
},
"files": [
"lib"
],
"repository": {
"type": "git",
"url": "git+https://github.com/michaelcpuckett/activitypub-core.git"
},
"bugs": {
"url": "https://github.com/michaelcpuckett/activitypub-core/issues"
},
"scripts": {
"tsc": "tsc --project tsconfig.json",
"dev": "ts-node ./src/index.tsx",
"server": "node ./lib/index.js"
},
"dependencies": {
"activitypub-core-delivery": "^0.0.54",
"activitypub-core-express-middleware": "^0.0.54",
"activitypub-core-jsx-components": "^0.0.54",
"activitypub-core-types": "^0.0.54",
"activitypub-core-utilities": "^0.0.54",
"firebase-admin": "^11.1.0",
"react": "^16.14.0",
"react-server": "^0.8.1"
},
"devDependencies": {
"@types/react": "^18.0.21",
"@types/react-dom": "^18.0.6",
"ts-node": "^10.9.1"
}
}

View File

@ -0,0 +1,18 @@
import { ServiceAccount } from 'firebase-admin';
const serviceAccount = {
type: 'service_account',
project_id: 'socialweb-id',
private_key_id: 'a80ec37ff2f96f01a5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ZrLt1WSQev1+LhiHueoz\nHZG3MMZKEhspZ0yQPIAyd49+DHSDd6yt63OMmCMO4yFm0vfMto30bt6/OxCMNwcm\nGFR0lIYGSwKBgQCQ/7s/np2+GSF4uiwtVESW4jop/HdJp+rZ1TU0wwTLQakBErLT\nrGYCIttjUyaQE9MoSzSfIGFVW4G0Mf6CZo3IJM7YxKXbSMnEbb9hjJJ540IkbJAW\nsut7YWJy6tb/UETPw/a4xhX1gsIfdrMp6NLU0zgXI5s2pao2BycsuqN9IQKBgCt1\nGPogZkt/yW7gN6mzZHzXP7PhOvTWTuTeF5PNak6HdXSK4sIuNEseDj+xmB9Rg+NJ\nmGXBohhJgqCprLW0MELZX2ujr8w0hnLrRFLXTRldMmSU6g+SCnDjUz+IkvKlR8+h\n3TPk/jKLHQCXTvIV1kfIepQOxlaW1AV7304fm6ZhAoGBAKIa5MUGzrK8SYGawwrV\nExDDr4oV/Fq9HZRMY0xWa2PshYEqGFB4FLc+rl6/SLTzxDehwYqXsqkLfqm2xjCf\nP1rFBnJsQhoxNQ1+b51sI+8dftrFJ7zEz7NAZ2YWtXqtu5gGyzf3qIeTkLxTpVTO\naqLRlxdKtEp0TMizftnlVl6R\n-----END PRIVATE KEY-----\n',
client_email: 'firebase-adminsdk-o0j5x@socialweb-id.iam.gserviceaccount.com',
client_id: '110281511136422720421',
auth_uri: 'https://accounts.google.com/o/oauth2/auth',
token_uri: 'https://oauth2.googleapis.com/token',
auth_provider_x509_cert_url: 'https://www.googleapis.com/oauth2/v1/certs',
client_x509_cert_url:
'https://www.googleapis.com/robot/v1/metadata/x509/firebase-adminsdk-o0j5x%40socialweb-id.iam.gserviceaccount.com',
};
export default serviceAccount as ServiceAccount;

View File

@ -0,0 +1 @@
// Required file.

View File

@ -0,0 +1,43 @@
import React from 'react';
import express from 'express';
import { activityPub } from 'activitypub-core-express-middleware';
import { IndexPage, EntityPage, HomePage } from 'activitypub-core-jsx-components';
import { renderToString } from 'react-dom/server';
import serviceAccount from './credentials';
import { MongoDatabaseService } from 'activitypub-core-mongodb';
import { DeliveryService } from 'activitypub-core-delivery';
(async () => {
const app = express();
const databaseService = await new MongoDatabaseService().connect();
const deliveryService = new DeliveryService(databaseService);
app.use(express.static('node_modules/activitypub-core-jsx-components/static'));
app.use(activityPub({
renderIndex: async () => {
return `
<!doctype html>
${renderToString(<IndexPage />)}`;
},
renderEntity: async ({ entity, actor }) => {
return `
<!doctype html>
${renderToString(<EntityPage entity={entity} actor={actor} />)}
`;
},
renderHome: async ({ actor }) => {
return `
<!doctype html>
${renderToString(<HomePage actor={actor} />)}
`;
},
}, {
databaseService,
deliveryService,
serviceAccount
}));
app.listen(process.env.PORT ?? 3001, () => {
console.log('Running...');
});
})();

View File

@ -0,0 +1,26 @@
{
"compilerOptions": {
"module": "commonjs",
"declaration": true,
"noImplicitAny": false,
"removeComments": true,
"noLib": false,
"esModuleInterop": true,
"target": "ESNext",
"jsx": "react",
"skipLibCheck": true,
"moduleResolution": "node",
"sourceMap": true,
"lib": [
"ESNext"
],
"outDir": "./lib"
},
"exclude": [
"./node_modules",
"../../node_modules"
],
"include": [
"src/index.tsx"
]
}

View File

@ -5,7 +5,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
Object.defineProperty(exports, "__esModule", { value: true });
exports.ActivityEntity = void 0;
const react_1 = __importDefault(require("react"));
const Note_1 = require("./Note");
const Object_1 = require("./Object");
function ActivityEntity({ activity, headingLevel }) {
const { actor, target } = activity;
let object = null;
@ -17,7 +17,7 @@ function ActivityEntity({ activity, headingLevel }) {
}
return (react_1.default.createElement("div", { className: "card" },
react_1.default.createElement("span", { role: "heading", "aria-level": headingLevel }, activity.type),
object && object.type === 'Note' ? react_1.default.createElement(Note_1.NoteEntity, { headingLevel: headingLevel + 1, note: object }) : null));
'object' in activity && activity.object ? react_1.default.createElement(Object_1.ObjectEntity, { object: activity.object, headingLevel: headingLevel + 1 }) : null));
}
exports.ActivityEntity = ActivityEntity;
//# sourceMappingURL=Activity.js.map

View File

@ -1 +1 @@
{"version":3,"file":"Activity.js","sourceRoot":"","sources":["../../../src/pages/EntityPage/Activity.tsx"],"names":[],"mappings":";;;;;;AACA,kDAA0B;AAC1B,iCAAoC;AAEpC,SAAgB,cAAc,CAAC,EAAE,QAAQ,EAAE,YAAY,EAAmD;IACxG,MAAM,EACJ,KAAK,EACL,MAAM,EACP,GAAG,QAAQ,CAAC;IAEb,IAAI,MAAM,GAAG,IAAI,CAAC;IAElB,IAAI,QAAQ,IAAI,QAAQ,EAAE;QACxB,MAAM,GAAG,QAAQ,CAAC,MAAM,CAAC;KAC1B;IAED,IAAI,CAAC,KAAK,EAAE;QACV,OAAO,2EAAe,CAAC;KACxB;IAED,OAAO,CACL,uCAAK,SAAS,EAAC,MAAM;QACnB,wCAAM,IAAI,EAAC,SAAS,gBAAa,YAAY,IAC1C,QAAQ,CAAC,IAAI,CACT;QACN,MAAM,IAAI,MAAM,CAAC,IAAI,KAAK,MAAM,CAAC,CAAC,CAAC,8BAAC,iBAAU,IAAC,YAAY,EAAE,YAAY,GAAG,CAAC,EAAE,IAAI,EAAE,MAAM,GAAI,CAAC,CAAC,CAAC,IAAI,CACnG,CACP,CAAC;AACJ,CAAC;AAxBD,wCAwBC"}
{"version":3,"file":"Activity.js","sourceRoot":"","sources":["../../../src/pages/EntityPage/Activity.tsx"],"names":[],"mappings":";;;;;;AACA,kDAA0B;AAC1B,qCAAwC;AAExC,SAAgB,cAAc,CAAC,EAAE,QAAQ,EAAE,YAAY,EAAmD;IACxG,MAAM,EACJ,KAAK,EACL,MAAM,EACP,GAAG,QAAQ,CAAC;IAEb,IAAI,MAAM,GAAG,IAAI,CAAC;IAElB,IAAI,QAAQ,IAAI,QAAQ,EAAE;QACxB,MAAM,GAAG,QAAQ,CAAC,MAAM,CAAC;KAC1B;IAED,IAAI,CAAC,KAAK,EAAE;QACV,OAAO,2EAAe,CAAC;KACxB;IAED,OAAO,CACL,uCAAK,SAAS,EAAC,MAAM;QACnB,wCAAM,IAAI,EAAC,SAAS,gBAAa,YAAY,IAC1C,QAAQ,CAAC,IAAI,CACT;QACN,QAAQ,IAAI,QAAQ,IAAI,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,8BAAC,qBAAY,IAAC,MAAM,EAAE,QAAQ,CAAC,MAA2B,EAAE,YAAY,EAAE,YAAY,GAAG,CAAC,GAAI,CAAC,CAAC,CAAC,IAAI,CAC5I,CACP,CAAC;AACJ,CAAC;AAxBD,wCAwBC"}

View File

@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
exports.ActorEntity = void 0;
const react_1 = __importDefault(require("react"));
function ActorEntity({ actor, headingLevel }) {
return (react_1.default.createElement("div", null,
return (react_1.default.createElement("div", { className: "card" },
react_1.default.createElement("span", { role: "heading", "aria-level": headingLevel },
"@",
actor.preferredUsername ?? actor.name)));

View File

@ -1 +1 @@
{"version":3,"file":"Actor.js","sourceRoot":"","sources":["../../../src/pages/EntityPage/Actor.tsx"],"names":[],"mappings":";;;;;;AACA,kDAA0B;AAE1B,SAAgB,WAAW,CAAC,EAAE,KAAK,EAAE,YAAY,EAA8C;IAC7F,OAAO,CACL;QACE,wCAAM,IAAI,EAAC,SAAS,gBAAa,YAAY;;YACzC,KAAK,CAAC,iBAAiB,IAAI,KAAK,CAAC,IAAI,CAClC,CACH,CACP,CAAC;AACJ,CAAC;AARD,kCAQC"}
{"version":3,"file":"Actor.js","sourceRoot":"","sources":["../../../src/pages/EntityPage/Actor.tsx"],"names":[],"mappings":";;;;;;AACA,kDAA0B;AAE1B,SAAgB,WAAW,CAAC,EAAE,KAAK,EAAE,YAAY,EAA8C;IAC7F,OAAO,CACL,uCAAK,SAAS,EAAC,MAAM;QACnB,wCAAM,IAAI,EAAC,SAAS,gBAAa,YAAY;;YACzC,KAAK,CAAC,iBAAiB,IAAI,KAAK,CAAC,IAAI,CAClC,CACH,CACP,CAAC;AACJ,CAAC;AARD,kCAQC"}

View File

@ -8,12 +8,15 @@ const activitypub_core_types_1 = require("activitypub-core-types");
const activitypub_core_utilities_1 = require("activitypub-core-utilities");
const react_1 = __importDefault(require("react"));
const Activity_1 = require("./Activity");
const Actor_1 = require("./Actor");
const Link_1 = require("./Link");
const Object_1 = require("./Object");
function CollectionEntity({ collection, actor, headingLevel }) {
const { items } = collection;
if (!Array.isArray(items)) {
return react_1.default.createElement(react_1.default.Fragment, null);
}
return (react_1.default.createElement("div", null,
return (react_1.default.createElement("div", { className: "card" },
react_1.default.createElement("span", { role: "heading", "aria-level": headingLevel }, collection.name),
actor && collection.name === 'Following' ? react_1.default.createElement(FollowForm, { headingLevel: headingLevel + 1, actor: actor }) : null,
Array.isArray(collection.items) ? collection.items.map(item => {
@ -21,10 +24,25 @@ function CollectionEntity({ collection, actor, headingLevel }) {
return react_1.default.createElement(react_1.default.Fragment, null);
}
for (const type of Object.values(activitypub_core_types_1.AP.ActivityTypes)) {
if (type === item.type) {
if (item.type === type) {
return react_1.default.createElement(Activity_1.ActivityEntity, { headingLevel: headingLevel + 1, activity: item });
}
}
for (const type of Object.values(activitypub_core_types_1.AP.ActorTypes)) {
if (item.type === type) {
return react_1.default.createElement(Actor_1.ActorEntity, { headingLevel: headingLevel + 1, actor: item });
}
}
for (const type of Object.values(activitypub_core_types_1.AP.ExtendedObjectTypes)) {
if (item.type === type) {
return react_1.default.createElement(Object_1.ObjectEntity, { headingLevel: headingLevel + 1, object: item });
}
}
for (const type of Object.values(activitypub_core_types_1.AP.LinkTypes)) {
if (item.type === type) {
return react_1.default.createElement(Link_1.LinkEntity, { link: item });
}
}
return react_1.default.createElement("li", { key: item.id.toString() }, item.type);
}) : null));
}

View File

@ -1 +1 @@
{"version":3,"file":"Collection.js","sourceRoot":"","sources":["../../../src/pages/EntityPage/Collection.tsx"],"names":[],"mappings":";;;;;;AAAA,mEAA4C;AAC5C,2EAAmD;AACnD,kDAA0B;AAC1B,yCAA4C;AAG5C,SAAgB,gBAAgB,CAAC,EAAE,UAAU,EAAE,KAAK,EAAE,YAAY,EAAyE;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,EAAE,YAAY,EAA8C;IACrF,OAAO,uCAAK,SAAS,EAAC,MAAM;QAC1B,wCAAM,IAAI,EAAC,SAAS,gBAAa,YAAY,sBAEtC;QACP,wCAAM,EAAE,EAAC,YAAY,EAAC,UAAU,QAAC,MAAM,EAAE,IAAA,kCAAK,EAAC,KAAK,CAAC,MAAM,CAAC,CAAC,QAAQ,EAAE;YACrE,yCAAO,IAAI,EAAC,QAAQ,EAAC,IAAI,EAAC,OAAO,EAAC,KAAK,EAAE,IAAA,kCAAK,EAAC,KAAK,CAAC,CAAC,QAAQ,EAAE,GAAI;YACpE;gBACE,yCAAO,IAAI,EAAC,MAAM,EAAC,IAAI,EAAC,QAAQ,GAAG,CAC7B;YACR,0CAAQ,IAAI,EAAC,QAAQ,aAEZ,CACJ;QACP,0CAAQ,IAAI,EAAC,QAAQ,EAAC,GAAG,EAAC,gBAAgB,GAAU,CAChD,CAAA;AACR,CAAC"}

View File

@ -7,22 +7,40 @@ exports.OrderedCollectionEntity = void 0;
const activitypub_core_types_1 = require("activitypub-core-types");
const react_1 = __importDefault(require("react"));
const Activity_1 = require("./Activity");
const Actor_1 = require("./Actor");
const Link_1 = require("./Link");
const Object_1 = require("./Object");
function OrderedCollectionEntity({ collection, headingLevel }) {
const { orderedItems: items } = collection;
if (!Array.isArray(items)) {
return react_1.default.createElement(react_1.default.Fragment, null);
}
return (react_1.default.createElement("div", null,
return (react_1.default.createElement("div", { className: "card" },
react_1.default.createElement("span", { role: "heading", "aria-level": headingLevel }, collection.name),
Array.isArray(collection.orderedItems) ? collection.orderedItems.map(item => {
if (item instanceof URL) {
return react_1.default.createElement(react_1.default.Fragment, null);
}
for (const type of Object.values(activitypub_core_types_1.AP.ActivityTypes)) {
if (type === item.type) {
if (item.type === type) {
return react_1.default.createElement(Activity_1.ActivityEntity, { headingLevel: headingLevel + 1, activity: item });
}
}
for (const type of Object.values(activitypub_core_types_1.AP.ActorTypes)) {
if (item.type === type) {
return react_1.default.createElement(Actor_1.ActorEntity, { headingLevel: headingLevel + 1, actor: item });
}
}
for (const type of Object.values(activitypub_core_types_1.AP.ExtendedObjectTypes)) {
if (item.type === type) {
return react_1.default.createElement(Object_1.ObjectEntity, { headingLevel: headingLevel + 1, object: item });
}
}
for (const type of Object.values(activitypub_core_types_1.AP.LinkTypes)) {
if (item.type === type) {
return react_1.default.createElement(Link_1.LinkEntity, { link: item });
}
}
return react_1.default.createElement("li", { key: item.id.toString() }, item.type);
}) : null));
}

View File

@ -1 +1 @@
{"version":3,"file":"OrderedCollection.js","sourceRoot":"","sources":["../../../src/pages/EntityPage/OrderedCollection.tsx"],"names":[],"mappings":";;;;;;AAAA,mEAA4C;AAC5C,kDAA0B;AAC1B,yCAA4C;AAE5C,SAAgB,uBAAuB,CAAC,EAAE,UAAU,EAAE,YAAY,EAA+D;IAC/H,MAAM,EACJ,YAAY,EAAE,KAAK,EACpB,GAAG,UAAU,CAAC;IAEf,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE;QACzB,OAAO,6DAAK,CAAA;KACb;IAED,OAAO,CACL;QACE,wCAAM,IAAI,EAAC,SAAS,gBAAa,YAAY,IAC1C,UAAU,CAAC,IAAI,CACX;QACN,KAAK,CAAC,OAAO,CAAC,UAAU,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,YAAY,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE;YAC3E,IAAI,IAAI,YAAY,GAAG,EAAE;gBACvB,OAAO,6DAAK,CAAA;aACb;YACD,KAAK,MAAM,IAAI,IAAI,MAAM,CAAC,MAAM,CAAC,2BAAE,CAAC,aAAa,CAAC,EAAE;gBAClD,IAAI,IAAI,KAAK,IAAI,CAAC,IAAI,EAAE;oBACtB,OAAO,8BAAC,yBAAc,IAAC,YAAY,EAAE,YAAY,GAAG,CAAC,EAAE,QAAQ,EAAE,IAAI,GAAI,CAAA;iBAC1E;aACF;YACD,OAAO,sCAAI,GAAG,EAAE,IAAI,CAAC,EA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BACtB,OAAO,8BAAC,mBAAW,IAAC,YAAY,EAAE,YAAY,GAAG,CAAC,EAAE,KAAK,EAAE,IAAgB,GAAgB,CAAA;iBAC5F;aACF;YAED,KAAK,MAAM,IAAI,IAAI,MAAM,CAAC,MAAM,CAAC,2BAAE,CAAC,mBAAmB,CAAC,EAAE;gBACxD,IAAI,IAAI,CAAC,IAAI,KAAK,IAAI,EAAE;oBACtB,OAAO,8BAAC,qBAAY,IAAC,YAAY,EAAE,YAAY,GAAG,CAAC,EAAE,MAAM,EAAE,IAAyB,GAAiB,CAAA;iBACxG;aACF;YAED,KAAK,MAAM,IAAI,IAAI,MAAM,CAAC,MAAM,CAAC,2BAAE,CAAC,SAAS,CAAC,EAAE;gBAC9C,IAAI,IAAI,CAAC,IAAI,KAAK,IAAI,EAAE;oBACtB,OAAO,8BAAC,iBAAU,IAAC,IAAI,EAAE,IAAe,GAAe,CAAA;iBACxD;aACF;YAED,OAAO,sCAAI,GAAG,EAAE,IAAI,CAAC,EAAE,CAAC,QAAQ,EAAE,IAC/B,IAAI,CAAC,IAAI,CACP,CAAA;QACP,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CACL,CACP,CAAC;AACJ,CAAC;AAhDD,0DAgDC"}

View File

@ -1,6 +1,6 @@
import { AP } from 'activitypub-core-types';
import React from 'react';
import { NoteEntity } from './Note';
import { ObjectEntity } from './Object';
export function ActivityEntity({ activity, headingLevel }: { activity: AP.Activity, headingLevel: number }) {
const {
@ -23,7 +23,7 @@ export function ActivityEntity({ activity, headingLevel }: { activity: AP.Activi
<span role="heading" aria-level={headingLevel}>
{activity.type}
</span>
{object && object.type === 'Note' ? <NoteEntity headingLevel={headingLevel + 1} note={object} /> : null}
{'object' in activity && activity.object ? <ObjectEntity object={activity.object as AP.ExtendedObject} headingLevel={headingLevel + 1} /> : null}
</div>
);
}
}

View File

@ -3,7 +3,7 @@ import React from 'react';
export function ActorEntity({ actor, headingLevel }: { actor: AP.Actor; headingLevel: number; }) {
return (
<div>
<div className="card">
<span role="heading" aria-level={headingLevel}>
@{actor.preferredUsername ?? actor.name}
</span>

View File

@ -2,6 +2,9 @@ import { AP } from 'activitypub-core-types';
import { getId } from 'activitypub-core-utilities';
import React from 'react';
import { ActivityEntity } from './Activity';
import { ActorEntity } from './Actor';
import { LinkEntity } from './Link';
import { ObjectEntity } from './Object';
export function CollectionEntity({ collection, actor, headingLevel }: { collection: AP.Collection; actor: AP.Actor; headingLevel: number; }) {
@ -14,7 +17,7 @@ export function CollectionEntity({ collection, actor, headingLevel }: { collecti
}
return (
<div>
<div className="card">
<span role="heading" aria-level={headingLevel}>
{collection.name}
</span>
@ -25,11 +28,31 @@ export function CollectionEntity({ collection, actor, headingLevel }: { collecti
if (item instanceof URL) {
return <></>
}
for (const type of Object.values(AP.ActivityTypes)) {
if (type === item.type) {
return <ActivityEntity headingLevel={headingLevel + 1} activity={item} />
if (item.type === type) {
return <ActivityEntity headingLevel={headingLevel + 1} activity={item as AP.Activity}></ActivityEntity>;
}
}
for (const type of Object.values(AP.ActorTypes)) {
if (item.type === type) {
return <ActorEntity headingLevel={headingLevel + 1} actor={item as AP.Actor}></ActorEntity>
}
}
for (const type of Object.values(AP.ExtendedObjectTypes)) {
if (item.type === type) {
return <ObjectEntity headingLevel={headingLevel + 1} object={item as AP.ExtendedObject}></ObjectEntity>
}
}
for (const type of Object.values(AP.LinkTypes)) {
if (item.type === type) {
return <LinkEntity link={item as AP.Link}></LinkEntity>
}
}
return <li key={item.id.toString()}>
{item.type}
</li>

View File

@ -1,6 +1,9 @@
import { AP } from 'activitypub-core-types';
import React from 'react';
import { ActivityEntity } from './Activity';
import { ActorEntity } from './Actor';
import { LinkEntity } from './Link';
import { ObjectEntity } from './Object';
export function OrderedCollectionEntity({ collection, headingLevel }: { collection: AP.OrderedCollection; headingLevel: number; }) {
const {
@ -12,7 +15,7 @@ export function OrderedCollectionEntity({ collection, headingLevel }: { collecti
}
return (
<div>
<div className="card">
<span role="heading" aria-level={headingLevel}>
{collection.name}
</span>
@ -21,10 +24,29 @@ export function OrderedCollectionEntity({ collection, headingLevel }: { collecti
return <></>
}
for (const type of Object.values(AP.ActivityTypes)) {
if (type === item.type) {
return <ActivityEntity headingLevel={headingLevel + 1} activity={item} />
if (item.type === type) {
return <ActivityEntity headingLevel={headingLevel + 1} activity={item as AP.Activity}></ActivityEntity>;
}
}
for (const type of Object.values(AP.ActorTypes)) {
if (item.type === type) {
return <ActorEntity headingLevel={headingLevel + 1} actor={item as AP.Actor}></ActorEntity>
}
}
for (const type of Object.values(AP.ExtendedObjectTypes)) {
if (item.type === type) {
return <ObjectEntity headingLevel={headingLevel + 1} object={item as AP.ExtendedObject}></ObjectEntity>
}
}
for (const type of Object.values(AP.LinkTypes)) {
if (item.type === type) {
return <LinkEntity link={item as AP.Link}></LinkEntity>
}
}
return <li key={item.id.toString()}>
{item.type}
</li>