@drfed/models 0.2.0-dev.716 → 0.2.0-dev.718

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.
Files changed (36) hide show
  1. package/README.md +58 -4
  2. package/dist/activity-delivery.d.mts +1 -1
  3. package/dist/{db-CcbUSnp2.d.mts → db-Al_MT-L_.d.mts} +132 -3
  4. package/dist/{db-CcbUSnp2.d.mts.map → db-Al_MT-L_.d.mts.map} +1 -1
  5. package/dist/db.d.mts +1 -1
  6. package/dist/document.d.mts +14 -2
  7. package/dist/document.d.mts.map +1 -1
  8. package/dist/document.mjs +115 -26
  9. package/dist/document.mjs.map +1 -1
  10. package/dist/expansion-p4BoMDVd.d.mts +90 -0
  11. package/dist/expansion-p4BoMDVd.d.mts.map +1 -0
  12. package/dist/expansion.d.mts +2 -0
  13. package/dist/expansion.mjs +131 -0
  14. package/dist/expansion.mjs.map +1 -0
  15. package/dist/index.d.mts +3 -3
  16. package/dist/index.mjs +2 -2
  17. package/dist/instance.d.mts +1 -1
  18. package/dist/key.d.mts +1 -1
  19. package/dist/login.d.mts +1 -1
  20. package/dist/migrations-manifest.json +4 -0
  21. package/dist/relations.d.mts +1 -1
  22. package/dist/{resource-revision-rDmHhNCj.d.mts → resource-revision-BbXciRsu.d.mts} +117 -4
  23. package/dist/resource-revision-BbXciRsu.d.mts.map +1 -0
  24. package/dist/{resource-revision-bTQyJ7aw.mjs → resource-revision-DGsz8fnS.mjs} +338 -42
  25. package/dist/resource-revision-DGsz8fnS.mjs.map +1 -0
  26. package/dist/resource-revision.d.mts +2 -2
  27. package/dist/resource-revision.mjs +1 -1
  28. package/dist/resource.d.mts +1 -1
  29. package/dist/schema.d.mts +2 -2
  30. package/dist/schema.mjs +55 -1
  31. package/dist/schema.mjs.map +1 -1
  32. package/drizzle/20261125051505_revision_expansions/migration.sql +31 -0
  33. package/drizzle/20261125051505_revision_expansions/snapshot.json +4806 -0
  34. package/package.json +12 -7
  35. package/dist/resource-revision-bTQyJ7aw.mjs.map +0 -1
  36. package/dist/resource-revision-rDmHhNCj.d.mts.map +0 -1
@@ -0,0 +1,90 @@
1
+ //#region src/expansion.d.ts
2
+ /**
3
+ * How the JSON-LD expansion of a revision's document turned out.
4
+ *
5
+ * - `expanded`: the document was expanded. `droppedTerms` lists the terms
6
+ * the expansion discarded because no context defined them;
7
+ * `undefinedTerms` lists the terms a vocabulary such as ActivityStreams,
8
+ * whose context maps undefined terms with `"@vocab": "_:"`, kept as
9
+ * blank node identifiers instead.
10
+ * - `failed`: the document could not be expanded, for example because a
11
+ * context could not be loaded.
12
+ * - `no_document`: the revision has no document to expand.
13
+ */
14
+ type DocumentExpansion = {
15
+ readonly outcome: "expanded";
16
+ readonly document: readonly unknown[];
17
+ readonly droppedTerms: readonly string[];
18
+ readonly undefinedTerms: readonly string[];
19
+ } | {
20
+ readonly outcome: "failed";
21
+ readonly failure: string;
22
+ } | {
23
+ readonly outcome: "no_document";
24
+ };
25
+ /** Options for {@link expandDocument}. */
26
+ interface ExpandDocumentOptions {
27
+ /**
28
+ * Remote contexts gathered beforehand, by URL, besides the contexts
29
+ * preloaded by `@fedify/vocab-runtime`. Expansion never accesses the
30
+ * network, so it may run inside a transaction; a context found in neither
31
+ * fails the expansion.
32
+ */
33
+ readonly contexts?: ReadonlyMap<string, GatheredContext>;
34
+ /**
35
+ * Called for each occurrence of a dropped term, before duplicates are
36
+ * removed from `droppedTerms`.
37
+ */
38
+ readonly onDroppedTerm?: (term: string) => void;
39
+ }
40
+ /** A remote context gathered before an expansion, keyed by requested URL. */
41
+ interface GatheredContext {
42
+ /** The URL the context was finally loaded from, after redirects. */
43
+ readonly documentUrl: string;
44
+ /**
45
+ * The context a response linked to, such as with an HTTP `Link` header,
46
+ * which the processor applies with the loaded one.
47
+ */
48
+ readonly contextUrl?: string | null;
49
+ readonly document: unknown;
50
+ }
51
+ /**
52
+ * Options the JSON-LD processor is given, as Fedify gives them when it reads
53
+ * a document, so that a node with only an `@id` is kept.
54
+ */
55
+ declare const EXPAND_OPTIONS: {
56
+ readonly keepFreeFloatingNodes: true;
57
+ };
58
+ /**
59
+ * Why a stored value cannot be expanded, if it cannot: the processor reads a
60
+ * string as the URL of a document to load, which a stored value is not.
61
+ * @param document The stored value.
62
+ * @returns The failure reason, or undefined for an object or array.
63
+ */
64
+ declare function unexpandableValue(document: unknown): string | undefined;
65
+ /**
66
+ * Expands a document with the JSON-LD processor Fedify uses, reading
67
+ * contexts only from those preloaded and those given. Expansion failures are
68
+ * returned as a `failed` outcome rather than thrown.
69
+ * @param document The document as stored.
70
+ * @param options Options, including gathered contexts.
71
+ * @returns The outcome of the expansion.
72
+ */
73
+ declare function expandDocument(document: unknown, options?: ExpandDocumentOptions): Promise<DocumentExpansion>;
74
+ /**
75
+ * Describes why an expansion failed, followed by its causes, since the
76
+ * JSON-LD processor wraps the error a context loader threw.
77
+ * @param error The thrown error.
78
+ * @returns The reason recorded for a `failed` outcome.
79
+ */
80
+ declare function expansionFailure(error: unknown): string;
81
+ /**
82
+ * Lists the terms an expanded document keeps as blank node identifiers, in
83
+ * property names and `@type` values, without their `_:` prefix.
84
+ * @param expanded An expanded document.
85
+ * @returns The terms, sorted and without duplicates.
86
+ */
87
+ declare function undefinedTermsOf(expanded: readonly unknown[]): string[];
88
+ //#endregion
89
+ export { expandDocument as a, unexpandableValue as c, GatheredContext as i, EXPAND_OPTIONS as n, expansionFailure as o, ExpandDocumentOptions as r, undefinedTermsOf as s, DocumentExpansion as t };
90
+ //# sourceMappingURL=expansion-p4BoMDVd.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"expansion-p4BoMDVd.d.mts","names":[],"sources":["../src/expansion.ts"],"mappings":";;;;;;;;;;;;;KAkCY;WAEG;WACA;WACA;WACA;;WAEA;WAA4B;;WAC5B;;;UAGE;;;;;;;WAON,WAAW,oBAAoB;;;;;WAK/B,iBAAiB;;;UAIX;;WAEN;;;;;WAKA;WACA;;;;;;cA4BE;WAAmB;;;;;;;;iBAQhB,kBAAkB;;;;;;;;;iBAuBZ,eACpB,mBACA,UAAS,wBACR,QAAQ;;;;;;;iBAkEK,iBAAiB;;;;;;;iBAwBjB,iBAAiB"}
@@ -0,0 +1,2 @@
1
+ import { a as expandDocument, c as unexpandableValue, i as GatheredContext, n as EXPAND_OPTIONS, o as expansionFailure, r as ExpandDocumentOptions, s as undefinedTermsOf, t as DocumentExpansion } from "./expansion-p4BoMDVd.mjs";
2
+ export { DocumentExpansion, EXPAND_OPTIONS, ExpandDocumentOptions, GatheredContext, expandDocument, expansionFailure, undefinedTermsOf, unexpandableValue };
@@ -0,0 +1,131 @@
1
+ import { preloadedContexts } from "@fedify/vocab-runtime";
2
+ import jsonld from "@fedify/vocab-runtime/jsonld";
3
+ //#region src/expansion.ts
4
+ function contextReader(contexts = /* @__PURE__ */ new Map()) {
5
+ return (url) => {
6
+ const gathered = Object.hasOwn(preloadedContexts, url) ? {
7
+ documentUrl: url,
8
+ document: preloadedContexts[url]
9
+ } : contexts.get(url);
10
+ if (gathered === void 0) return Promise.reject(/* @__PURE__ */ new Error(`The context ${JSON.stringify(url)} was not gathered.`));
11
+ const remote = {
12
+ contextUrl: gathered.contextUrl ?? null,
13
+ documentUrl: gathered.documentUrl,
14
+ document: gathered.document
15
+ };
16
+ return Promise.resolve(remote);
17
+ };
18
+ }
19
+ /**
20
+ * Options the JSON-LD processor is given, as Fedify gives them when it reads
21
+ * a document, so that a node with only an `@id` is kept.
22
+ */
23
+ const EXPAND_OPTIONS = { keepFreeFloatingNodes: true };
24
+ /**
25
+ * Why a stored value cannot be expanded, if it cannot: the processor reads a
26
+ * string as the URL of a document to load, which a stored value is not.
27
+ * @param document The stored value.
28
+ * @returns The failure reason, or undefined for an object or array.
29
+ */
30
+ function unexpandableValue(document) {
31
+ if (document !== null && typeof document === "object") return void 0;
32
+ return `A JSON-LD document must be an object or array, not ${document === null ? "null" : typeof document}.`;
33
+ }
34
+ const DROPPED_TERM_EVENTS = /* @__PURE__ */ new Set(["invalid property", "invalid reverse property"]);
35
+ /**
36
+ * Expands a document with the JSON-LD processor Fedify uses, reading
37
+ * contexts only from those preloaded and those given. Expansion failures are
38
+ * returned as a `failed` outcome rather than thrown.
39
+ * @param document The document as stored.
40
+ * @param options Options, including gathered contexts.
41
+ * @returns The outcome of the expansion.
42
+ */
43
+ async function expandDocument(document, options = {}) {
44
+ const unexpandable = unexpandableValue(document);
45
+ if (unexpandable !== void 0) return {
46
+ outcome: "failed",
47
+ failure: unexpandable
48
+ };
49
+ const dropped = [];
50
+ let expanded;
51
+ try {
52
+ expanded = await jsonld.expand(document, {
53
+ ...EXPAND_OPTIONS,
54
+ documentLoader: contextReader(options.contexts),
55
+ eventHandler: ({ event }) => {
56
+ const property = event.details?.property;
57
+ if (DROPPED_TERM_EVENTS.has(event.code) && typeof property === "string") {
58
+ dropped.push(property);
59
+ options.onDroppedTerm?.(property);
60
+ }
61
+ }
62
+ });
63
+ } catch (error) {
64
+ return {
65
+ outcome: "failed",
66
+ failure: expansionFailure(error)
67
+ };
68
+ }
69
+ const nodes = Array.isArray(expanded) ? expanded : [expanded];
70
+ return {
71
+ outcome: "expanded",
72
+ document: nodes,
73
+ droppedTerms: distinct(dropped),
74
+ undefinedTerms: undefinedTermsOf(nodes)
75
+ };
76
+ }
77
+ function describeError(error) {
78
+ if (error instanceof Error) return error.message === "" ? error.name : `${error.name}: ${error.message}`;
79
+ return String(error);
80
+ }
81
+ function causeOf(error) {
82
+ if (error === null || typeof error !== "object") return void 0;
83
+ const { details, cause } = error;
84
+ return details?.cause ?? cause;
85
+ }
86
+ /**
87
+ * Describes why an expansion failed, followed by its causes, since the
88
+ * JSON-LD processor wraps the error a context loader threw.
89
+ * @param error The thrown error.
90
+ * @returns The reason recorded for a `failed` outcome.
91
+ */
92
+ function expansionFailure(error) {
93
+ const reasons = [describeError(error)];
94
+ const seen = /* @__PURE__ */ new Set([error]);
95
+ for (let cause = causeOf(error); cause !== void 0 && cause !== null && !seen.has(cause); cause = causeOf(cause)) {
96
+ seen.add(cause);
97
+ reasons.push(describeError(cause));
98
+ }
99
+ return reasons.join(" Caused by ");
100
+ }
101
+ function distinct(values) {
102
+ return [...new Set(values)].sort();
103
+ }
104
+ /**
105
+ * Lists the terms an expanded document keeps as blank node identifiers, in
106
+ * property names and `@type` values, without their `_:` prefix.
107
+ * @param expanded An expanded document.
108
+ * @returns The terms, sorted and without duplicates.
109
+ */
110
+ function undefinedTermsOf(expanded) {
111
+ const terms = [];
112
+ const visit = (value) => {
113
+ if (Array.isArray(value)) {
114
+ for (const entry of value) visit(entry);
115
+ return;
116
+ }
117
+ if (value === null || typeof value !== "object") return;
118
+ for (const [key, entry] of Object.entries(value)) {
119
+ if (key.startsWith("_:")) terms.push(key.slice(2));
120
+ if (key === "@type") {
121
+ for (const type of Array.isArray(entry) ? entry : [entry]) if (typeof type === "string" && type.startsWith("_:")) terms.push(type.slice(2));
122
+ } else if (key !== "@value") visit(entry);
123
+ }
124
+ };
125
+ visit(expanded);
126
+ return distinct(terms);
127
+ }
128
+ //#endregion
129
+ export { EXPAND_OPTIONS, expandDocument, expansionFailure, undefinedTermsOf, unexpandableValue };
130
+
131
+ //# sourceMappingURL=expansion.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"expansion.mjs","names":[],"sources":["../src/expansion.ts"],"sourcesContent":["// DrFed: A web-based platform for developing and debugging ActivityPub apps\n// Copyright (C) 2026 DrFed team\n//\n// This program is free software: you can redistribute it and/or modify\n// it under the terms of the GNU Affero General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// This program is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU Affero General Public License for more details.\n//\n// You should have received a copy of the GNU Affero General Public License\n// along with this program. If not, see <https://www.gnu.org/licenses/>.\nimport {\n type DocumentLoader,\n type RemoteDocument,\n preloadedContexts,\n} from \"@fedify/vocab-runtime\";\nimport jsonld from \"@fedify/vocab-runtime/jsonld\";\n\n/**\n * How the JSON-LD expansion of a revision's document turned out.\n *\n * - `expanded`: the document was expanded. `droppedTerms` lists the terms\n * the expansion discarded because no context defined them;\n * `undefinedTerms` lists the terms a vocabulary such as ActivityStreams,\n * whose context maps undefined terms with `\"@vocab\": \"_:\"`, kept as\n * blank node identifiers instead.\n * - `failed`: the document could not be expanded, for example because a\n * context could not be loaded.\n * - `no_document`: the revision has no document to expand.\n */\nexport type DocumentExpansion =\n | {\n readonly outcome: \"expanded\";\n readonly document: readonly unknown[];\n readonly droppedTerms: readonly string[];\n readonly undefinedTerms: readonly string[];\n }\n | { readonly outcome: \"failed\"; readonly failure: string }\n | { readonly outcome: \"no_document\" };\n\n/** Options for {@link expandDocument}. */\nexport interface ExpandDocumentOptions {\n /**\n * Remote contexts gathered beforehand, by URL, besides the contexts\n * preloaded by `@fedify/vocab-runtime`. Expansion never accesses the\n * network, so it may run inside a transaction; a context found in neither\n * fails the expansion.\n */\n readonly contexts?: ReadonlyMap<string, GatheredContext>;\n /**\n * Called for each occurrence of a dropped term, before duplicates are\n * removed from `droppedTerms`.\n */\n readonly onDroppedTerm?: (term: string) => void;\n}\n\n/** A remote context gathered before an expansion, keyed by requested URL. */\nexport interface GatheredContext {\n /** The URL the context was finally loaded from, after redirects. */\n readonly documentUrl: string;\n /**\n * The context a response linked to, such as with an HTTP `Link` header,\n * which the processor applies with the loaded one.\n */\n readonly contextUrl?: string | null;\n readonly document: unknown;\n}\n\nfunction contextReader(\n contexts: ReadonlyMap<string, GatheredContext> = new Map(),\n): DocumentLoader {\n return (url) => {\n const gathered = Object.hasOwn(preloadedContexts, url)\n ? { documentUrl: url, document: preloadedContexts[url] }\n : contexts.get(url);\n if (gathered === undefined) {\n return Promise.reject(\n new Error(`The context ${JSON.stringify(url)} was not gathered.`),\n );\n }\n const remote: RemoteDocument = {\n contextUrl: gathered.contextUrl ?? null,\n documentUrl: gathered.documentUrl,\n document: gathered.document,\n };\n return Promise.resolve(remote);\n };\n}\n\n/**\n * Options the JSON-LD processor is given, as Fedify gives them when it reads\n * a document, so that a node with only an `@id` is kept.\n */\nexport const EXPAND_OPTIONS = { keepFreeFloatingNodes: true } as const;\n\n/**\n * Why a stored value cannot be expanded, if it cannot: the processor reads a\n * string as the URL of a document to load, which a stored value is not.\n * @param document The stored value.\n * @returns The failure reason, or undefined for an object or array.\n */\nexport function unexpandableValue(document: unknown): string | undefined {\n if (document !== null && typeof document === \"object\") return undefined;\n return `A JSON-LD document must be an object or array, not ${\n document === null ? \"null\" : typeof document\n }.`;\n}\n\nconst DROPPED_TERM_EVENTS: ReadonlySet<string> = new Set([\n \"invalid property\",\n \"invalid reverse property\",\n]);\n\ntype ExpandInput = Parameters<typeof jsonld.expand>[0];\ntype ExpandOptions = NonNullable<Parameters<typeof jsonld.expand>[1]>;\n\n/**\n * Expands a document with the JSON-LD processor Fedify uses, reading\n * contexts only from those preloaded and those given. Expansion failures are\n * returned as a `failed` outcome rather than thrown.\n * @param document The document as stored.\n * @param options Options, including gathered contexts.\n * @returns The outcome of the expansion.\n */\nexport async function expandDocument(\n document: unknown,\n options: ExpandDocumentOptions = {},\n): Promise<DocumentExpansion> {\n const unexpandable = unexpandableValue(document);\n if (unexpandable !== undefined) {\n return { outcome: \"failed\", failure: unexpandable };\n }\n const dropped: string[] = [];\n let expanded: unknown;\n try {\n expanded = await jsonld.expand(\n document as ExpandInput,\n {\n ...EXPAND_OPTIONS,\n documentLoader: contextReader(options.contexts),\n eventHandler: ({ event }: { event: JsonLdEvent }) => {\n const property = event.details?.property;\n if (\n DROPPED_TERM_EVENTS.has(event.code) &&\n typeof property === \"string\"\n ) {\n dropped.push(property);\n options.onDroppedTerm?.(property);\n }\n },\n } as ExpandOptions,\n );\n } catch (error) {\n return { outcome: \"failed\", failure: expansionFailure(error) };\n }\n const nodes = Array.isArray(expanded) ? (expanded as unknown[]) : [expanded];\n return {\n outcome: \"expanded\",\n document: nodes,\n droppedTerms: distinct(dropped),\n undefinedTerms: undefinedTermsOf(nodes),\n };\n}\n\ninterface JsonLdEvent {\n readonly code: string;\n readonly details?: { readonly property?: unknown };\n}\n\nfunction describeError(error: unknown): string {\n if (error instanceof Error) {\n return error.message === \"\"\n ? error.name\n : `${error.name}: ${error.message}`;\n }\n return String(error);\n}\n\nfunction causeOf(error: unknown): unknown {\n if (error === null || typeof error !== \"object\") return undefined;\n const { details, cause } = error as {\n readonly details?: { readonly cause?: unknown };\n readonly cause?: unknown;\n };\n return details?.cause ?? cause;\n}\n\n/**\n * Describes why an expansion failed, followed by its causes, since the\n * JSON-LD processor wraps the error a context loader threw.\n * @param error The thrown error.\n * @returns The reason recorded for a `failed` outcome.\n */\nexport function expansionFailure(error: unknown): string {\n const reasons = [describeError(error)];\n const seen = new Set<unknown>([error]);\n for (\n let cause = causeOf(error);\n cause !== undefined && cause !== null && !seen.has(cause);\n cause = causeOf(cause)\n ) {\n seen.add(cause);\n reasons.push(describeError(cause));\n }\n return reasons.join(\" Caused by \");\n}\n\nfunction distinct(values: readonly string[]): string[] {\n return [...new Set(values)].sort();\n}\n\n/**\n * Lists the terms an expanded document keeps as blank node identifiers, in\n * property names and `@type` values, without their `_:` prefix.\n * @param expanded An expanded document.\n * @returns The terms, sorted and without duplicates.\n */\nexport function undefinedTermsOf(expanded: readonly unknown[]): string[] {\n const terms: string[] = [];\n const visit = (value: unknown): void => {\n if (Array.isArray(value)) {\n for (const entry of value) visit(entry);\n return;\n }\n if (value === null || typeof value !== \"object\") return;\n for (const [key, entry] of Object.entries(value)) {\n if (key.startsWith(\"_:\")) terms.push(key.slice(2));\n if (key === \"@type\") {\n for (const type of Array.isArray(entry) ? entry : [entry]) {\n if (typeof type === \"string\" && type.startsWith(\"_:\")) {\n terms.push(type.slice(2));\n }\n }\n } else if (key !== \"@value\") {\n visit(entry);\n }\n }\n };\n visit(expanded);\n return distinct(terms);\n}\n"],"mappings":";;;AAwEA,SAAS,cACP,2BAAiD,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D,IAAI,QAAQ,SACL;SAAA,MAAM,QAAQ,MAAM,QAAQ,KAAK,IAAI,QAAQ,CAAC,KAAK,GACtD,IAAI,OAAO,SAAS,YAAY,KAAK,WAAW,IAAI,GAClD,MAAM,KAAK,KAAK,MAAM,CAAC,CAAC;GAAA,OAGvB,IAAI,QAAQ,UACjB,MAAM,KAAK;EAEf;CACF;CACA,MAAM,QAAQ;CACd,OAAO,SAAS,KAAK;AACvB"}
package/dist/index.d.mts CHANGED
@@ -1,4 +1,4 @@
1
- import { Gt as schema_d_exports, Jt as jwkThumbprint, Xt as thumbprintInput, Yt as observeKeyVersion, Zt as toPublicJwk, i as relations, n as RelationsFilter, qt as PublicJwk, r as Transaction, t as Database } from "./db-CcbUSnp2.mjs";
1
+ import { $t as observeKeyVersion, Qt as jwkThumbprint, Yt as schema_d_exports, Zt as PublicJwk, en as thumbprintInput, i as relations, n as RelationsFilter, r as Transaction, t as Database, tn as toPublicJwk } from "./db-Al_MT-L_.mjs";
2
2
  import { AddressedActor, InboundDeliveryEntry, OutboundDeliveryEntry, OutboundSettlement, inboundActorRows, linkInboundActivity, receiveInbound, recordFetchedObject, recordInbound, recordOutbound, settleOutbound } from "./activity-delivery.mjs";
3
3
  import { normalizeEmail } from "./email.mjs";
4
4
  import { MigrateCredentials, MigrateOptions, PGliteMigrateCredentials, PostgresMigrateCredentials, migrate } from "./migrate.mjs";
@@ -11,5 +11,5 @@ import { InspectMigrationStateOptions, MigrationHistoryFormat, MigrationQueryCli
11
11
  import { a as preparePostgresDatabase, i as migrationLockKey, n as PostgresPreparationCredentials, o as MigrationPreparationCode, r as PreparePostgresOptions, s as MigrationPreparationError, t as MigrationClientFactory } from "./migration-session-B4xHeU_a.mjs";
12
12
  import { PersistentPgliteStore, PgliteStoreCode, PgliteStoreError, openPersistentPglite } from "./pglite-store.mjs";
13
13
  import { PreparePgliteOptions, preparePgliteDatabase } from "./pglite-preparation.mjs";
14
- import { _ as RevisionConflictError, a as RevisionRelationInput, c as TypedResourceRevisionInput, d as loadCurrentResourceRevision, f as loadResourceRevision, g as LegacyResourceRevisionError, h as ResourceRevisionStateError, i as RevisionEmbeddingInput, l as appendResourceRevision, m as captureLegacyResourceRevision, n as JsonObject, o as StoredResourceRevision, p as writeTypedResourceRevision, r as JsonValue, s as TypedObjectColumns, t as AppendResourceRevisionInput, u as listResourceRevisions } from "./resource-revision-rDmHhNCj.mjs";
15
- export { AddressedActor, AddressingInput, AddressingOccurrence, AppendResourceRevisionInput, Database, InboundDeliveryEntry, InspectMigrationStateOptions, JsonObject, JsonValue, LegacyResourceRevisionError, LoginChallengeConsumptionError, LoginChallengeError, LoginChallengeNotFoundError, MigrateCredentials, MigrateOptions, MigrationClientFactory, MigrationHistoryFormat, MigrationIdentity, MigrationManifest, MigrationManifestPaths, type MigrationPreparationCode, MigrationPreparationError, MigrationQueryClient, MigrationState, MigrationStatus, OutboundDeliveryEntry, OutboundSettlement, PGliteMigrateCredentials, PUBLIC_IRI, PUBLIC_RESOURCE_ID, PersistentPgliteStore, PgliteStoreCode, PgliteStoreError, PostgresMigrateCredentials, PostgresPreparationCredentials, PreparePgliteOptions, PreparePostgresOptions, PublicJwk, RelationsFilter, ResourceKindConflictError, ResourceRevisionStateError, RevisionConflictError, RevisionEmbeddingInput, RevisionRelationInput, StoredResourceRevision, Transaction, TypedObjectColumns, TypedResourceRevisionInput, addActorCollectionItem, appendResourceRevision, assertMigrationManifestPrefix, captureLegacyResourceRevision, checkAddressingOccurrences, classifyMigrationHistory, consumeLoginChallenge, ensureRemoteInstance, ensureResource, findLoginChallenge, generateLoginChallengeCode, inboundActorRows, inspectMigrationState, jwkThumbprint, linkInboundActivity, listResourceRevisions, loadCurrentResourceRevision, loadResourceRevision, lockActorCollection, lockResources, migrate, migrationLockKey, migrationTimestamp, normalizeEmail, observeKeyVersion, openPersistentPglite, parseMigrationManifest, preparePgliteDatabase, preparePostgresDatabase, promoteResource, receiveInbound, recordFetchedObject, recordInbound, recordOutbound, relations, replaceAddressing, schema_d_exports as schema, settleOutbound, storableText, storeAddressing, storeAddressingOccurrences, thumbprintInput, toPublicJwk, verifyMigrationManifest, writeTypedResourceRevision };
14
+ import { C as listFailedRevisions, E as retryRevisionExpansion, S as findCarryingActivityRevision, T as recordRevisionExpansion, _ as ResourceRevisionStateError, a as RevisionRelationInput, b as RevisionExpansionInput, c as TypedResourceRevisionInput, d as loadCurrentResourceRevision, f as loadResourceRevision, g as captureLegacyResourceRevision, h as CaptureLegacyResourceRevisionOptions, i as RevisionEmbeddingInput, l as appendResourceRevision, m as writeTypedResourceRevision, n as JsonObject, o as StoredResourceRevision, p as loadRevisionExpansion, r as JsonValue, s as TypedObjectColumns, t as AppendResourceRevisionInput, u as listResourceRevisions, v as LegacyResourceRevisionError, w as listUnexpandedRevisions, x as UnexpandedRevision, y as RevisionConflictError } from "./resource-revision-BbXciRsu.mjs";
15
+ export { AddressedActor, AddressingInput, AddressingOccurrence, AppendResourceRevisionInput, type CaptureLegacyResourceRevisionOptions, Database, InboundDeliveryEntry, InspectMigrationStateOptions, JsonObject, JsonValue, LegacyResourceRevisionError, LoginChallengeConsumptionError, LoginChallengeError, LoginChallengeNotFoundError, MigrateCredentials, MigrateOptions, MigrationClientFactory, MigrationHistoryFormat, MigrationIdentity, MigrationManifest, MigrationManifestPaths, type MigrationPreparationCode, MigrationPreparationError, MigrationQueryClient, MigrationState, MigrationStatus, OutboundDeliveryEntry, OutboundSettlement, PGliteMigrateCredentials, PUBLIC_IRI, PUBLIC_RESOURCE_ID, PersistentPgliteStore, PgliteStoreCode, PgliteStoreError, PostgresMigrateCredentials, PostgresPreparationCredentials, PreparePgliteOptions, PreparePostgresOptions, PublicJwk, RelationsFilter, ResourceKindConflictError, ResourceRevisionStateError, RevisionConflictError, RevisionEmbeddingInput, type RevisionExpansionInput, RevisionRelationInput, StoredResourceRevision, Transaction, TypedObjectColumns, TypedResourceRevisionInput, type UnexpandedRevision, addActorCollectionItem, appendResourceRevision, assertMigrationManifestPrefix, captureLegacyResourceRevision, checkAddressingOccurrences, classifyMigrationHistory, consumeLoginChallenge, ensureRemoteInstance, ensureResource, findCarryingActivityRevision, findLoginChallenge, generateLoginChallengeCode, inboundActorRows, inspectMigrationState, jwkThumbprint, linkInboundActivity, listFailedRevisions, listResourceRevisions, listUnexpandedRevisions, loadCurrentResourceRevision, loadResourceRevision, loadRevisionExpansion, lockActorCollection, lockResources, migrate, migrationLockKey, migrationTimestamp, normalizeEmail, observeKeyVersion, openPersistentPglite, parseMigrationManifest, preparePgliteDatabase, preparePostgresDatabase, promoteResource, receiveInbound, recordFetchedObject, recordInbound, recordOutbound, recordRevisionExpansion, relations, replaceAddressing, retryRevisionExpansion, schema_d_exports as schema, settleOutbound, storableText, storeAddressing, storeAddressingOccurrences, thumbprintInput, toPublicJwk, verifyMigrationManifest, writeTypedResourceRevision };
package/dist/index.mjs CHANGED
@@ -15,5 +15,5 @@ import { n as MigrationPreparationError } from "./migration-snapshot-OM5jQN1-.mj
15
15
  import { migrationLockKey, preparePostgresDatabase } from "./migration-session.mjs";
16
16
  import { PgliteStoreError, openPersistentPglite } from "./pglite-store.mjs";
17
17
  import { preparePgliteDatabase } from "./pglite-preparation.mjs";
18
- import { a as writeTypedResourceRevision, c as ResourceRevisionStateError, i as loadResourceRevision, l as LegacyResourceRevisionError, n as listResourceRevisions, o as captureLegacyResourceRevision, r as loadCurrentResourceRevision, s as RevisionConflictError, t as appendResourceRevision } from "./resource-revision-bTQyJ7aw.mjs";
19
- export { LegacyResourceRevisionError, LoginChallengeConsumptionError, LoginChallengeError, LoginChallengeNotFoundError, MigrationPreparationError, PUBLIC_IRI, PUBLIC_RESOURCE_ID, PgliteStoreError, ResourceKindConflictError, ResourceRevisionStateError, RevisionConflictError, addActorCollectionItem, appendResourceRevision, assertMigrationManifestPrefix, captureLegacyResourceRevision, checkAddressingOccurrences, classifyMigrationHistory, consumeLoginChallenge, ensureRemoteInstance, ensureResource, findLoginChallenge, generateLoginChallengeCode, inboundActorRows, inspectMigrationState, jwkThumbprint, linkInboundActivity, listResourceRevisions, loadCurrentResourceRevision, loadResourceRevision, lockActorCollection, lockResources, migrate, migrationLockKey, migrationTimestamp, normalizeEmail, observeKeyVersion, openPersistentPglite, parseMigrationManifest, preparePgliteDatabase, preparePostgresDatabase, promoteResource, receiveInbound, recordFetchedObject, recordInbound, recordOutbound, relations, replaceAddressing, schema_exports as schema, settleOutbound, storableText, storeAddressing, storeAddressingOccurrences, thumbprintInput, toPublicJwk, verifyMigrationManifest, writeTypedResourceRevision };
18
+ import { a as loadRevisionExpansion, c as findCarryingActivityRevision, d as recordRevisionExpansion, f as retryRevisionExpansion, h as LegacyResourceRevisionError, i as loadResourceRevision, l as listFailedRevisions, m as ResourceRevisionStateError, n as listResourceRevisions, o as writeTypedResourceRevision, p as RevisionConflictError, r as loadCurrentResourceRevision, s as captureLegacyResourceRevision, t as appendResourceRevision, u as listUnexpandedRevisions } from "./resource-revision-DGsz8fnS.mjs";
19
+ export { LegacyResourceRevisionError, LoginChallengeConsumptionError, LoginChallengeError, LoginChallengeNotFoundError, MigrationPreparationError, PUBLIC_IRI, PUBLIC_RESOURCE_ID, PgliteStoreError, ResourceKindConflictError, ResourceRevisionStateError, RevisionConflictError, addActorCollectionItem, appendResourceRevision, assertMigrationManifestPrefix, captureLegacyResourceRevision, checkAddressingOccurrences, classifyMigrationHistory, consumeLoginChallenge, ensureRemoteInstance, ensureResource, findCarryingActivityRevision, findLoginChallenge, generateLoginChallengeCode, inboundActorRows, inspectMigrationState, jwkThumbprint, linkInboundActivity, listFailedRevisions, listResourceRevisions, listUnexpandedRevisions, loadCurrentResourceRevision, loadResourceRevision, loadRevisionExpansion, lockActorCollection, lockResources, migrate, migrationLockKey, migrationTimestamp, normalizeEmail, observeKeyVersion, openPersistentPglite, parseMigrationManifest, preparePgliteDatabase, preparePostgresDatabase, promoteResource, receiveInbound, recordFetchedObject, recordInbound, recordOutbound, recordRevisionExpansion, relations, replaceAddressing, retryRevisionExpansion, schema_exports as schema, settleOutbound, storableText, storeAddressing, storeAddressingOccurrences, thumbprintInput, toPublicJwk, verifyMigrationManifest, writeTypedResourceRevision };
@@ -1,4 +1,4 @@
1
- import { r as Transaction, t as Database, x as Instance } from "./db-CcbUSnp2.mjs";
1
+ import { r as Transaction, t as Database, x as Instance } from "./db-Al_MT-L_.mjs";
2
2
  //#region src/instance.d.ts
3
3
  /**
4
4
  * Returns the remote instance of a host, registering it if it is new. The
package/dist/key.d.mts CHANGED
@@ -1,2 +1,2 @@
1
- import { Jt as jwkThumbprint, Xt as thumbprintInput, Yt as observeKeyVersion, Zt as toPublicJwk, qt as PublicJwk } from "./db-CcbUSnp2.mjs";
1
+ import { $t as observeKeyVersion, Qt as jwkThumbprint, Zt as PublicJwk, en as thumbprintInput, tn as toPublicJwk } from "./db-Al_MT-L_.mjs";
2
2
  export { PublicJwk, jwkThumbprint, observeKeyVersion, thumbprintInput, toPublicJwk };
package/dist/login.d.mts CHANGED
@@ -1,4 +1,4 @@
1
- import { A as LoginChallenge, r as Transaction, t as Database } from "./db-CcbUSnp2.mjs";
1
+ import { A as LoginChallenge, r as Transaction, t as Database } from "./db-Al_MT-L_.mjs";
2
2
  import { t as Uuid } from "./uuid-CKMzlIND.mjs";
3
3
  import { SQL } from "drizzle-orm/sql";
4
4
  //#region src/login.d.ts
@@ -124,6 +124,10 @@
124
124
  {
125
125
  "name": "20261113080537_guard_revision_embeddings",
126
126
  "sha256": "565918b747d0a6d092cdb1d68cf709a729b705c17489b2e333aca294c692b8f5"
127
+ },
128
+ {
129
+ "name": "20261125051505_revision_expansions",
130
+ "sha256": "15d30fdb8b3d0db2d5ee3a37d93ddeb17350a48d433948d09522538d6ee369b8"
127
131
  }
128
132
  ]
129
133
  }
@@ -1,2 +1,2 @@
1
- import { i as relations } from "./db-CcbUSnp2.mjs";
1
+ import { i as relations } from "./db-Al_MT-L_.mjs";
2
2
  export { relations as default, relations };
@@ -1,6 +1,92 @@
1
- import { J as RevisionAddressing, P as NewActivityPubObject, Y as RevisionEmbedding, Z as RevisionRelation, q as ResourceRevision, r as Transaction, t as Database } from "./db-CcbUSnp2.mjs";
1
+ import { $ as RevisionRelation, J as ResourceRevision, P as NewActivityPubObject, X as RevisionEmbedding, Y as RevisionAddressing, Z as RevisionExpansion, r as Transaction, t as Database } from "./db-Al_MT-L_.mjs";
2
2
  import { t as Uuid } from "./uuid-CKMzlIND.mjs";
3
+ import { t as DocumentExpansion } from "./expansion-p4BoMDVd.mjs";
3
4
  import { AddressingInput, AddressingOccurrence } from "./resource.mjs";
5
+ import "drizzle-orm/pg-core";
6
+ //#region src/revision-expansion.d.ts
7
+ /**
8
+ * The expansion of a new snapshot revision's document, computed by the caller
9
+ * before the transaction that stores it.
10
+ */
11
+ type RevisionExpansionInput = Exclude<DocumentExpansion, {
12
+ readonly outcome: "no_document";
13
+ }> & {
14
+ /**
15
+ * The revision whose expanded document this one was taken from, for an
16
+ * object embedded in a received activity.
17
+ */
18
+ readonly sourceRevisionId?: Uuid;
19
+ };
20
+ /** A revision the backfill has not reached, as {@link listUnexpandedRevisions} lists it. */
21
+ interface UnexpandedRevision {
22
+ readonly id: Uuid;
23
+ readonly resourceId: Uuid;
24
+ /** The IRI of the revision's resource. */
25
+ readonly resourceIri: string;
26
+ readonly kind: ResourceRevision["kind"];
27
+ readonly capture: ResourceRevision["capture"];
28
+ readonly document: unknown;
29
+ }
30
+ /**
31
+ * Lists revisions without an expansion, in ID order.
32
+ * @param db The database.
33
+ * @param options Where to continue from, and how many to list.
34
+ * @returns Up to `limit` revisions after `after`.
35
+ */
36
+ declare function listUnexpandedRevisions(db: Database | Transaction, options: {
37
+ readonly after?: Uuid;
38
+ readonly limit: number;
39
+ }): Promise<UnexpandedRevision[]>;
40
+ /**
41
+ * Lists snapshot revisions whose expansion failed, in ID order, so that a
42
+ * failure such as a context that could not be loaded can be retried.
43
+ * @param db The database.
44
+ * @param options Where to continue from, and how many to list.
45
+ * @returns Up to `limit` revisions after `after`.
46
+ */
47
+ declare function listFailedRevisions(db: Database | Transaction, options: {
48
+ readonly after?: Uuid;
49
+ readonly limit: number;
50
+ }): Promise<UnexpandedRevision[]>;
51
+ /**
52
+ * Finds the revision of the activity that first carried an embedded object,
53
+ * the one its typed row names, which an embedded revision's expansion is
54
+ * taken from.
55
+ * @param db The database.
56
+ * @param objectId The embedded object's resource.
57
+ * @returns The activity's first revision, or null if there is none.
58
+ */
59
+ declare function findCarryingActivityRevision(db: Database | Transaction, objectId: Uuid): Promise<{
60
+ readonly id: Uuid;
61
+ readonly document: unknown;
62
+ } | null>;
63
+ /**
64
+ * Records the expansion of a revision that has none. An existing row is kept,
65
+ * so that the backfill can run again or alongside new writes.
66
+ * @param db The database.
67
+ * @param revisionId The revision.
68
+ * @param expansion Its expansion, or null for a revision without a document,
69
+ * which must be `unavailable` or a `whiteout`.
70
+ * @returns The outcome of the row inserted, which is `failed` for an
71
+ * expansion JSON cannot hold, or null if the revision already had
72
+ * one.
73
+ * @throws {TypeError} If the revision does not exist, or the expansion does
74
+ * not suit its kind.
75
+ */
76
+ declare function recordRevisionExpansion(db: Database | Transaction, revisionId: Uuid, expansion: RevisionExpansionInput | null): Promise<RevisionExpansion["outcome"] | null>;
77
+ /**
78
+ * Replaces a failed expansion of a revision, as when a context that could not
79
+ * be loaded before now loads. A row that is no longer failed, because
80
+ * another writer replaced it first, is kept.
81
+ * @param db The database.
82
+ * @param revisionId The revision.
83
+ * @param expansion Its new expansion.
84
+ * @returns The outcome of the row replaced, or null if it was not failed.
85
+ * @throws {TypeError} If the revision does not exist, or the expansion does
86
+ * not suit its kind.
87
+ */
88
+ declare function retryRevisionExpansion(db: Database | Transaction, revisionId: Uuid, expansion: RevisionExpansionInput | null): Promise<RevisionExpansion["outcome"] | null>;
89
+ //#endregion
4
90
  //#region src/revision-conflict-error.d.ts
5
91
  /** The caller's expected current revision no longer matches the database. */
6
92
  declare class RevisionConflictError extends Error {
@@ -25,14 +111,25 @@ declare class ResourceRevisionStateError extends Error {
25
111
  }
26
112
  //#endregion
27
113
  //#region src/legacy-resource-revision.d.ts
114
+ /** Options for {@link captureLegacyResourceRevision}. */
115
+ interface CaptureLegacyResourceRevisionOptions {
116
+ /**
117
+ * The expansion of the typed row's document, computed before the
118
+ * transaction. When omitted, a captured snapshot is expanded offline within
119
+ * the transaction.
120
+ */
121
+ readonly expansion?: RevisionExpansionInput;
122
+ }
28
123
  /**
29
124
  * Captures fully written legacy typed state within its creating transaction.
30
125
  * This trusted compatibility operation performs no authorization or fetching.
31
126
  * Repeated calls return the original revision only when the typed state agrees.
127
+ * Revisions of the resource without an expansion get one, so that a capture
128
+ * reusing a revision made before expansions were stored records it too.
32
129
  * @returns The first retained revision ID, including an unavailable snapshot.
33
130
  * @throws {LegacyResourceRevisionError} When typed state cannot be captured.
34
131
  */
35
- declare function captureLegacyResourceRevision(tx: Transaction, resourceId: Uuid): Promise<Uuid>;
132
+ declare function captureLegacyResourceRevision(tx: Transaction, resourceId: Uuid, options?: CaptureLegacyResourceRevisionOptions): Promise<Uuid>;
36
133
  //#endregion
37
134
  //#region src/resource-revision.d.ts
38
135
  /** A value representable by JSON, without implicit coercion. */
@@ -81,6 +178,14 @@ type AppendResourceRevisionInput = AppendBase & ({
81
178
  /** Embedded documents whose source is known, each path once. */
82
179
  readonly embeddings?: readonly RevisionEmbeddingInput[];
83
180
  readonly projection?: ResourceRevision["projection"];
181
+ /**
182
+ * The document's expansion. When omitted, the document is expanded
183
+ * offline, from preloaded contexts only, before this function opens
184
+ * its transaction, or within the caller's. A document that needs
185
+ * remote contexts must be expanded before the caller's transaction
186
+ * and passed here, since none is fetched within it.
187
+ */
188
+ readonly expansion?: RevisionExpansionInput;
84
189
  } | {
85
190
  readonly kind: "whiteout";
86
191
  readonly deleted: Temporal.Instant;
@@ -96,9 +201,15 @@ interface StoredResourceRevision extends ResourceRevision {
96
201
  * The caller must validate the document and authorize the write. Lock multiple
97
202
  * canonical IRIs in sorted order before composing several appends in one transaction.
98
203
  * This does not publish, change collection membership, or reserve delivery.
204
+ * The revision's expansion is stored with it; see the `expansion` input.
99
205
  * @returns The stored revision, including protected blind addressing.
100
206
  */
101
207
  declare function appendResourceRevision(db: Database | Transaction, input: AppendResourceRevisionInput): Promise<StoredResourceRevision>;
208
+ /**
209
+ * Loads the recorded expansion of a revision's document.
210
+ * @returns The expansion, or null if the revision has not been expanded.
211
+ */
212
+ declare function loadRevisionExpansion(db: Database | Transaction, revisionId: Uuid): Promise<RevisionExpansion | null>;
102
213
  /**
103
214
  * Loads protected local JSON without applying authorization or stripping bto/bcc.
104
215
  * @returns The immutable revision and projections, or null if not found.
@@ -134,6 +245,8 @@ type TypedResourceRevisionInput = TypedRevisionBase & ({
134
245
  /** Embedded documents whose source is known, each path once. */
135
246
  readonly embeddings?: readonly RevisionEmbeddingInput[];
136
247
  readonly projection?: ResourceRevision["projection"];
248
+ /** As for {@link appendResourceRevision}. */
249
+ readonly expansion?: RevisionExpansionInput;
137
250
  } | {
138
251
  readonly kind: "whiteout";
139
252
  readonly deleted: Temporal.Instant;
@@ -158,5 +271,5 @@ type TypedResourceRevisionInput = TypedRevisionBase & ({
158
271
  */
159
272
  declare function writeTypedResourceRevision(db: Database | Transaction, input: TypedResourceRevisionInput): Promise<StoredResourceRevision>;
160
273
  //#endregion
161
- export { RevisionConflictError as _, RevisionRelationInput as a, TypedResourceRevisionInput as c, loadCurrentResourceRevision as d, loadResourceRevision as f, LegacyResourceRevisionError as g, ResourceRevisionStateError as h, RevisionEmbeddingInput as i, appendResourceRevision as l, captureLegacyResourceRevision as m, JsonObject as n, StoredResourceRevision as o, writeTypedResourceRevision as p, JsonValue as r, TypedObjectColumns as s, AppendResourceRevisionInput as t, listResourceRevisions as u };
162
- //# sourceMappingURL=resource-revision-rDmHhNCj.d.mts.map
274
+ export { listFailedRevisions as C, retryRevisionExpansion as E, findCarryingActivityRevision as S, recordRevisionExpansion as T, ResourceRevisionStateError as _, RevisionRelationInput as a, RevisionExpansionInput as b, TypedResourceRevisionInput as c, loadCurrentResourceRevision as d, loadResourceRevision as f, captureLegacyResourceRevision as g, CaptureLegacyResourceRevisionOptions as h, RevisionEmbeddingInput as i, appendResourceRevision as l, writeTypedResourceRevision as m, JsonObject as n, StoredResourceRevision as o, loadRevisionExpansion as p, JsonValue as r, TypedObjectColumns as s, AppendResourceRevisionInput as t, listResourceRevisions as u, LegacyResourceRevisionError as v, listUnexpandedRevisions as w, UnexpandedRevision as x, RevisionConflictError as y };
275
+ //# sourceMappingURL=resource-revision-BbXciRsu.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resource-revision-BbXciRsu.d.mts","names":[],"sources":["../src/revision-expansion.ts","../src/revision-conflict-error.ts","../src/legacy-resource-revision-error.ts","../src/resource-revision-state-error.ts","../src/legacy-resource-revision.ts","../src/resource-revision.ts"],"mappings":";;;;;;;;;;KAsCY,yBAAyB,QACnC;WACW;;;;;;WAMF,mBAAmB;;;UA4Qb;WACN,IAAI;WACJ,YAAY;;WAEZ;WACA,MAAM;WACN,SAAS;WACT;;;;;;;;iBASW,wBACpB,IAAI,WAAW,aACf;WAAoB,QAAQ;WAAe;IAC1C,QAAQ;;;;;;;;iBAeW,oBACpB,IAAI,WAAW,aACf;WAAoB,QAAQ;WAAe;IAC1C,QAAQ;;;;;;;;;iBAmDW,6BACpB,IAAI,WAAW,aACf,UAAU,OACT;WAAmB,IAAI;WAAe;;;;;;;;;;;;;;;iBAiCnB,wBACpB,IAAI,WAAW,aACf,YAAY,MACZ,WAAW,gCACV,QAAQ;;;;;;;;;;;;iBAqBW,uBACpB,IAAI,WAAW,aACf,YAAY,MACZ,WAAW,gCACV,QAAQ;;;;cChcE,8BAA8B;WAE9B,YAAY;WACZ,oBAAoB;WACpB,kBAAkB;EAH7B,YACW,YAAY,MACZ,oBAAoB,aACpB,kBAAkB;;;;;cCJlB,oCAAoC;WAC1B,YAAY;EAAjC,YAAqB,YAAY;;;;;cCHtB,mCAAmC;WAEnC;EADX,YACW;;;;;UCSI;;;;;;WAMN,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