@singi-labs/sifa-sdk 0.19.50 → 0.19.52
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +1 -1
- package/dist/index.js +1 -1
- package/dist/jsonld/index.cjs +28 -13
- package/dist/jsonld/index.cjs.map +1 -1
- package/dist/jsonld/works-graph.js +29 -14
- package/dist/jsonld/works-graph.js.map +1 -1
- package/dist/{network-map-B0bp4-ex.d.cts → network-map-C-p-k3gB.d.cts} +1 -0
- package/dist/{network-map-C-y5XxLI.d.ts → network-map-CnVlBE0G.d.ts} +1 -0
- package/dist/query/fetchers/index.cjs +2 -0
- package/dist/query/fetchers/index.cjs.map +1 -1
- package/dist/query/fetchers/index.d.cts +1 -1
- package/dist/query/fetchers/index.d.ts +1 -1
- package/dist/query/fetchers/rpg.js +2 -0
- package/dist/query/fetchers/rpg.js.map +1 -1
- package/dist/query/index.cjs +2 -0
- package/dist/query/index.cjs.map +1 -1
- package/dist/query/index.d.cts +2 -2
- package/dist/query/index.d.ts +2 -2
- package/dist/rpg/catalog.js +1 -1
- package/dist/rpg/catalog.js.map +1 -1
- package/dist/rpg/index.cjs +1 -1
- package/dist/rpg/index.cjs.map +1 -1
- package/package.json +1 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// src/jsonld/works-graph.ts
|
|
2
2
|
import { filterHidden } from "../profile/section-model.js";
|
|
3
|
-
import { normaliseBaseUrl } from "./url.js";
|
|
3
|
+
import { normaliseBaseUrl, profileUrl } from "./url.js";
|
|
4
4
|
import {
|
|
5
5
|
buildCourseJsonLd,
|
|
6
6
|
buildPresentationJsonLd,
|
|
@@ -16,21 +16,36 @@ function buildProfileWorksJsonLd(profile, author, options = {}) {
|
|
|
16
16
|
const { "@context": _context, ...rest } = node;
|
|
17
17
|
return rest;
|
|
18
18
|
};
|
|
19
|
-
const
|
|
19
|
+
const ownerUrl = profileUrl(normaliseBaseUrl(options.baseUrl), author.handle);
|
|
20
|
+
const refOwner = (nodes) => {
|
|
21
|
+
let seenOwner = false;
|
|
22
|
+
const out = [];
|
|
23
|
+
for (const node of nodes) {
|
|
24
|
+
const isOwner = typeof node === "object" && node !== null && node["@type"] === "Person" && node.url === ownerUrl;
|
|
25
|
+
if (isOwner) {
|
|
26
|
+
if (seenOwner) continue;
|
|
27
|
+
seenOwner = true;
|
|
28
|
+
out.push({ "@id": personId });
|
|
29
|
+
} else {
|
|
30
|
+
out.push(node);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
return out;
|
|
34
|
+
};
|
|
20
35
|
const graph = [
|
|
21
|
-
...visible(profile.publications).map((p) =>
|
|
22
|
-
|
|
23
|
-
author:
|
|
24
|
-
})
|
|
25
|
-
...visible(profile.presentations).map((p) =>
|
|
26
|
-
|
|
27
|
-
author:
|
|
28
|
-
})
|
|
36
|
+
...visible(profile.publications).map((p) => {
|
|
37
|
+
const node = strip(buildPublicationJsonLd(p, author, options));
|
|
38
|
+
return { ...node, author: refOwner(node.author) };
|
|
39
|
+
}),
|
|
40
|
+
...visible(profile.presentations).map((p) => {
|
|
41
|
+
const node = strip(buildPresentationJsonLd(p, author, options));
|
|
42
|
+
return { ...node, author: refOwner([node.author]) };
|
|
43
|
+
}),
|
|
29
44
|
...visible(profile.courses).map((c) => strip(buildCourseJsonLd(c, options))),
|
|
30
|
-
...visible(profile.projects).map((p) =>
|
|
31
|
-
|
|
32
|
-
member:
|
|
33
|
-
})
|
|
45
|
+
...visible(profile.projects).map((p) => {
|
|
46
|
+
const node = strip(buildProjectJsonLd(p, author, options));
|
|
47
|
+
return { ...node, member: refOwner(node.member) };
|
|
48
|
+
})
|
|
34
49
|
];
|
|
35
50
|
if (graph.length === 0) return null;
|
|
36
51
|
return { "@context": "https://schema.org", "@graph": graph };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/jsonld/works-graph.ts"],"sourcesContent":["/**\n * The works on a profile as one JSON-LD `@graph`.\n *\n * A profile page already emits a `ProfilePage` whose `mainEntity` is the\n * Person. Publications, talks, courses and projects are separate entities\n * rather than properties of that Person, so they go in their own block and\n * point back at the Person by `@id` instead of repeating the whole node.\n */\n\nimport { filterHidden } from '../profile/section-model.js';\nimport type { JsonLdOptions } from './profile.js';\nimport { normaliseBaseUrl } from './url.js';\nimport {\n buildCourseJsonLd,\n buildPresentationJsonLd,\n buildProjectJsonLd,\n buildPublicationJsonLd,\n type CourseInput,\n type PresentationInput,\n type ProjectInput,\n type PublicationInput,\n type WorkAuthor,\n} from './works.js';\n\nexport interface ProfileWorksInput {\n readonly handle: string;\n readonly publications?: readonly PublicationInput[];\n readonly presentations?: readonly PresentationInput[];\n readonly courses?: readonly CourseInput[];\n readonly projects?: readonly ProjectInput[];\n}\n\n/** `filterHidden` takes a mutable array; inputs here are readonly. */\nfunction visible<T extends { hidden?: boolean }>(items: readonly T[] | undefined): T[] {\n return filterHidden(items ? [...items] : undefined);\n}\n\n/**\n * Returns null when there is nothing to say, so a caller can skip the script\n * block entirely rather than emitting an empty graph.\n */\nexport function buildProfileWorksJsonLd(\n profile: ProfileWorksInput,\n author: WorkAuthor,\n options: JsonLdOptions = {},\n) {\n const personId =\n options.canonicalUrl ?? `${normaliseBaseUrl(options.baseUrl)}/p/${profile.handle}`;\n\n // Each work is built by its own emitter, then its `@context` is dropped: the\n // graph carries one context for every node in it.\n const strip = <T extends { '@context': string }>(node: T) => {\n const { '@context': _context, ...rest } = node;\n return rest;\n };\n\n // The Person is emitted in full by the ProfilePage block. Referencing
|
|
1
|
+
{"version":3,"sources":["../../src/jsonld/works-graph.ts"],"sourcesContent":["/**\n * The works on a profile as one JSON-LD `@graph`.\n *\n * A profile page already emits a `ProfilePage` whose `mainEntity` is the\n * Person. Publications, talks, courses and projects are separate entities\n * rather than properties of that Person, so they go in their own block and\n * point back at the Person by `@id` instead of repeating the whole node.\n */\n\nimport { filterHidden } from '../profile/section-model.js';\nimport type { JsonLdOptions } from './profile.js';\nimport { normaliseBaseUrl, profileUrl } from './url.js';\nimport {\n buildCourseJsonLd,\n buildPresentationJsonLd,\n buildProjectJsonLd,\n buildPublicationJsonLd,\n type CourseInput,\n type PresentationInput,\n type ProjectInput,\n type PublicationInput,\n type WorkAuthor,\n} from './works.js';\n\nexport interface ProfileWorksInput {\n readonly handle: string;\n readonly publications?: readonly PublicationInput[];\n readonly presentations?: readonly PresentationInput[];\n readonly courses?: readonly CourseInput[];\n readonly projects?: readonly ProjectInput[];\n}\n\n/** `filterHidden` takes a mutable array; inputs here are readonly. */\nfunction visible<T extends { hidden?: boolean }>(items: readonly T[] | undefined): T[] {\n return filterHidden(items ? [...items] : undefined);\n}\n\n/**\n * Returns null when there is nothing to say, so a caller can skip the script\n * block entirely rather than emitting an empty graph.\n */\nexport function buildProfileWorksJsonLd(\n profile: ProfileWorksInput,\n author: WorkAuthor,\n options: JsonLdOptions = {},\n) {\n const personId =\n options.canonicalUrl ?? `${normaliseBaseUrl(options.baseUrl)}/p/${profile.handle}`;\n\n // Each work is built by its own emitter, then its `@context` is dropped: the\n // graph carries one context for every node in it.\n const strip = <T extends { '@context': string }>(node: T) => {\n const { '@context': _context, ...rest } = node;\n return rest;\n };\n\n // The Person is emitted in full by the ProfilePage block. Referencing the\n // owner by `@id` keeps one Person in the graph rather than several partial\n // copies. But only the OWNER is de-duplicated this way: co-authors and\n // co-members (which the per-work builders emit as full Person nodes) must be\n // preserved, not overwritten. The owner is matched by its profile URL.\n const ownerUrl = profileUrl(normaliseBaseUrl(options.baseUrl), author.handle);\n const refOwner = (nodes: readonly unknown[]): unknown[] => {\n let seenOwner = false;\n const out: unknown[] = [];\n for (const node of nodes) {\n const isOwner =\n typeof node === 'object' &&\n node !== null &&\n (node as Record<string, unknown>)['@type'] === 'Person' &&\n (node as Record<string, unknown>).url === ownerUrl;\n if (isOwner) {\n if (seenOwner) continue; // collapse a repeated owner into one @id ref\n seenOwner = true;\n out.push({ '@id': personId });\n } else {\n out.push(node);\n }\n }\n return out;\n };\n\n const graph: Record<string, unknown>[] = [\n ...visible(profile.publications).map((p) => {\n const node = strip(buildPublicationJsonLd(p, author, options));\n return { ...node, author: refOwner(node.author) };\n }),\n ...visible(profile.presentations).map((p) => {\n const node = strip(buildPresentationJsonLd(p, author, options));\n return { ...node, author: refOwner([node.author]) };\n }),\n ...visible(profile.courses).map((c) => strip(buildCourseJsonLd(c, options))),\n ...visible(profile.projects).map((p) => {\n const node = strip(buildProjectJsonLd(p, author, options));\n return { ...node, member: refOwner(node.member) };\n }),\n ];\n\n if (graph.length === 0) return null;\n\n return { '@context': 'https://schema.org', '@graph': graph };\n}\n"],"mappings":";AASA,SAAS,oBAAoB;AAE7B,SAAS,kBAAkB,kBAAkB;AAC7C;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OAMK;AAWP,SAAS,QAAwC,OAAsC;AACrF,SAAO,aAAa,QAAQ,CAAC,GAAG,KAAK,IAAI,MAAS;AACpD;AAMO,SAAS,wBACd,SACA,QACA,UAAyB,CAAC,GAC1B;AACA,QAAM,WACJ,QAAQ,gBAAgB,GAAG,iBAAiB,QAAQ,OAAO,CAAC,MAAM,QAAQ,MAAM;AAIlF,QAAM,QAAQ,CAAmC,SAAY;AAC3D,UAAM,EAAE,YAAY,UAAU,GAAG,KAAK,IAAI;AAC1C,WAAO;AAAA,EACT;AAOA,QAAM,WAAW,WAAW,iBAAiB,QAAQ,OAAO,GAAG,OAAO,MAAM;AAC5E,QAAM,WAAW,CAAC,UAAyC;AACzD,QAAI,YAAY;AAChB,UAAM,MAAiB,CAAC;AACxB,eAAW,QAAQ,OAAO;AACxB,YAAM,UACJ,OAAO,SAAS,YAChB,SAAS,QACR,KAAiC,OAAO,MAAM,YAC9C,KAAiC,QAAQ;AAC5C,UAAI,SAAS;AACX,YAAI,UAAW;AACf,oBAAY;AACZ,YAAI,KAAK,EAAE,OAAO,SAAS,CAAC;AAAA,MAC9B,OAAO;AACL,YAAI,KAAK,IAAI;AAAA,MACf;AAAA,IACF;AACA,WAAO;AAAA,EACT;AAEA,QAAM,QAAmC;AAAA,IACvC,GAAG,QAAQ,QAAQ,YAAY,EAAE,IAAI,CAAC,MAAM;AAC1C,YAAM,OAAO,MAAM,uBAAuB,GAAG,QAAQ,OAAO,CAAC;AAC7D,aAAO,EAAE,GAAG,MAAM,QAAQ,SAAS,KAAK,MAAM,EAAE;AAAA,IAClD,CAAC;AAAA,IACD,GAAG,QAAQ,QAAQ,aAAa,EAAE,IAAI,CAAC,MAAM;AAC3C,YAAM,OAAO,MAAM,wBAAwB,GAAG,QAAQ,OAAO,CAAC;AAC9D,aAAO,EAAE,GAAG,MAAM,QAAQ,SAAS,CAAC,KAAK,MAAM,CAAC,EAAE;AAAA,IACpD,CAAC;AAAA,IACD,GAAG,QAAQ,QAAQ,OAAO,EAAE,IAAI,CAAC,MAAM,MAAM,kBAAkB,GAAG,OAAO,CAAC,CAAC;AAAA,IAC3E,GAAG,QAAQ,QAAQ,QAAQ,EAAE,IAAI,CAAC,MAAM;AACtC,YAAM,OAAO,MAAM,mBAAmB,GAAG,QAAQ,OAAO,CAAC;AACzD,aAAO,EAAE,GAAG,MAAM,QAAQ,SAAS,KAAK,MAAM,EAAE;AAAA,IAClD,CAAC;AAAA,EACH;AAEA,MAAI,MAAM,WAAW,EAAG,QAAO;AAE/B,SAAO,EAAE,YAAY,sBAAsB,UAAU,MAAM;AAC7D;","names":[]}
|
|
@@ -408,6 +408,7 @@ type RpgItemStatus = z.infer<typeof RpgItemStatusSchema>;
|
|
|
408
408
|
declare const RpgStatusResponseSchema: z.ZodObject<{
|
|
409
409
|
hasCharacter: z.ZodBoolean;
|
|
410
410
|
canWriteItems: z.ZodBoolean;
|
|
411
|
+
canCollect: z.ZodDefault<z.ZodBoolean>;
|
|
411
412
|
items: z.ZodArray<z.ZodObject<{
|
|
412
413
|
id: z.ZodString;
|
|
413
414
|
title: z.ZodString;
|
|
@@ -408,6 +408,7 @@ type RpgItemStatus = z.infer<typeof RpgItemStatusSchema>;
|
|
|
408
408
|
declare const RpgStatusResponseSchema: z.ZodObject<{
|
|
409
409
|
hasCharacter: z.ZodBoolean;
|
|
410
410
|
canWriteItems: z.ZodBoolean;
|
|
411
|
+
canCollect: z.ZodDefault<z.ZodBoolean>;
|
|
411
412
|
items: z.ZodArray<z.ZodObject<{
|
|
412
413
|
id: z.ZodString;
|
|
413
414
|
title: z.ZodString;
|
|
@@ -1301,6 +1301,8 @@ var RpgStatusResponseSchema = zod.z.object({
|
|
|
1301
1301
|
hasCharacter: zod.z.boolean(),
|
|
1302
1302
|
/** True when the user granted the `repo:equipment.rpg.item` OAuth scope. */
|
|
1303
1303
|
canWriteItems: zod.z.boolean(),
|
|
1304
|
+
/** True when collecting (Sifa writing the gift) is switched on for this user. */
|
|
1305
|
+
canCollect: zod.z.boolean().default(false),
|
|
1304
1306
|
items: zod.z.array(RpgItemStatusSchema)
|
|
1305
1307
|
});
|
|
1306
1308
|
async function fetchRpgStatus(config, options = {}) {
|