@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 @@
1
+ {"version":3,"file":"resource-revision-DGsz8fnS.mjs","names":["addressingTable"],"sources":["../src/json-text.ts","../src/legacy-resource-revision-error.ts","../src/resource-revision-state-error.ts","../src/revision-conflict-error.ts","../src/revision-expansion.ts","../src/legacy-resource-revision.ts","../src/resource-revision.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/>.\nfunction jsonKeys(value: object): string[] {\n const prototype: unknown = Object.getPrototypeOf(value);\n if (\n Array.isArray(value)\n ? prototype !== Array.prototype\n : prototype !== Object.prototype && prototype !== null\n ) {\n throw new TypeError(\"JSON objects must be plain records.\");\n }\n const result: string[] = [];\n for (const key of Reflect.ownKeys(value)) {\n const descriptor = Object.getOwnPropertyDescriptor(value, key);\n if (\n typeof key !== \"string\" ||\n descriptor === undefined ||\n !(\"value\" in descriptor)\n ) {\n throw new TypeError(\n \"JSON values cannot contain symbol keys or accessors.\",\n );\n }\n if (Array.isArray(value) && key === \"length\") continue;\n if (!descriptor.enumerable) {\n throw new TypeError(\"JSON members must be enumerable.\");\n }\n if (\n Array.isArray(value) &&\n (!/^(?:0|[1-9][0-9]*)$/u.test(key) || Number(key) >= value.length)\n ) {\n throw new TypeError(\"JSON arrays cannot contain named properties.\");\n }\n result.push(key);\n }\n return result;\n}\n\n/**\n * Serializes a JSON value without coercion, keeping negative zero and\n * escaped Unicode, for storage in `json` columns.\n * @param value The value to serialize.\n * @param ancestors Objects being serialized, to reject cycles.\n * @returns The JSON text.\n */\nexport function json(value: unknown, ancestors = new Set<object>()): string {\n if (value === null) return \"null\";\n if (typeof value === \"string\" || typeof value === \"boolean\") {\n return JSON.stringify(value);\n }\n if (typeof value === \"number\") {\n if (!Number.isFinite(value)) {\n throw new TypeError(\"JSON numbers must be finite.\");\n }\n return Object.is(value, -0) ? \"-0\" : JSON.stringify(value);\n }\n if (typeof value !== \"object\" || ancestors.has(value)) {\n throw new TypeError(\"Expected an acyclic JSON value without coercion.\");\n }\n const keys = jsonKeys(value);\n ancestors.add(value);\n try {\n if (Array.isArray(value)) {\n return `[${Array.from(value, (entry: unknown) => json(entry, ancestors)).join(\",\")}]`;\n }\n return `{${keys.map((key) => `${JSON.stringify(key)}:${json(Object.getOwnPropertyDescriptor(value, key)!.value, ancestors)}`).join(\",\")}}`;\n } finally {\n ancestors.delete(value);\n }\n}\n","// 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/>.\n\nimport type { Uuid } from \"./uuid.ts\";\n\n/** Legacy typed rows require the coordinated application adapter in #152. */\nexport class LegacyResourceRevisionError extends Error {\n constructor(readonly resourceId: Uuid) {\n super(\n \"Legacy typed state requires coordinated capture and must agree with retained history.\",\n );\n this.name = \"LegacyResourceRevisionError\";\n }\n}\n","// 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/>.\n\n/** A requested state transition would change a saved activity or revive a deletion. */\nexport class ResourceRevisionStateError extends Error {\n constructor(\n readonly code: \"activity-immutable\" | \"deleted\" | \"initial-whiteout\",\n ) {\n super(`Unsupported resource revision transition: ${code}.`);\n this.name = \"ResourceRevisionStateError\";\n }\n}\n","// 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/>.\n\nimport type { Uuid } from \"./uuid.ts\";\n\n/** The caller's expected current revision no longer matches the database. */\nexport class RevisionConflictError extends Error {\n constructor(\n readonly resourceId: Uuid,\n readonly expectedRevisionId: Uuid | null,\n readonly actualRevisionId: Uuid | null,\n ) {\n super(\"The resource's current revision has changed.\");\n this.name = \"RevisionConflictError\";\n }\n}\n","// 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 { type SQL, and, asc, eq, gt, isNull, sql } from \"drizzle-orm\";\nimport type { PgInsertValue } from \"drizzle-orm/pg-core\";\n\nimport type { Database, Transaction } from \"./db.ts\";\nimport { type DocumentExpansion, expandDocument } from \"./expansion.ts\";\nimport { json } from \"./json-text.ts\";\nimport {\n type ResourceRevision,\n type RevisionExpansion,\n objects,\n resourceRevisions,\n resources,\n revisionExpansions,\n} from \"./schema.ts\";\nimport { storableText } from \"./text.ts\";\nimport { type Uuid, validateUuid } from \"./uuid.ts\";\n\ntype ExpansionRow = PgInsertValue<typeof revisionExpansions>;\n\n/**\n * The expansion of a new snapshot revision's document, computed by the caller\n * before the transaction that stores it.\n */\nexport type RevisionExpansionInput = Exclude<\n DocumentExpansion,\n { readonly outcome: \"no_document\" }\n> & {\n /**\n * The revision whose expanded document this one was taken from, for an\n * object embedded in a received activity.\n */\n readonly sourceRevisionId?: Uuid;\n};\n\nfunction terms(value: unknown): value is readonly string[] {\n return (\n Array.isArray(value) && value.every((term) => typeof term === \"string\")\n );\n}\n\n/**\n * Checks the shape of a caller's expansion.\n * @param input The expansion.\n * @throws {TypeError} If it is not an expanded or failed outcome.\n */\nexport function checkRevisionExpansion(\n input: unknown,\n): asserts input is RevisionExpansionInput {\n if (input === null || typeof input !== \"object\") {\n throw new TypeError(\"Expected a document expansion.\");\n }\n const expansion = input as Partial<Record<string, unknown>>;\n if (\n expansion.sourceRevisionId !== undefined &&\n (typeof expansion.sourceRevisionId !== \"string\" ||\n !validateUuid(expansion.sourceRevisionId))\n ) {\n throw new TypeError(\"Expected a canonical source revision UUID.\");\n }\n if (expansion.outcome === \"expanded\") {\n if (\n !Array.isArray(expansion.document) ||\n !terms(expansion.droppedTerms) ||\n !terms(expansion.undefinedTerms)\n ) {\n throw new TypeError(\"Expected an expanded document and its terms.\");\n }\n return;\n }\n if (expansion.outcome === \"failed\") {\n if (typeof expansion.failure !== \"string\") {\n throw new TypeError(\"Expected the reason of a failed expansion.\");\n }\n return;\n }\n throw new TypeError(\"Expected an expanded or failed outcome.\");\n}\n\n// `text` and `jsonb` refuse U+0000 and unpaired surrogates; error messages\n// and expanded documents may contain both.\nfunction storableString(value: string): string {\n if (storableText(value)) return value;\n return value.replaceAll(\"\\0\", \"\\uFFFD\").toWellFormed();\n}\n\n/**\n * Normalizes an expanded document for `jsonb`, replacing in every string and\n * key what it refuses with U+FFFD. The stored document keeps the exact\n * values, so the expansion need not.\n * @param value Part of an expanded document.\n * @returns The value with storable strings and keys.\n */\nfunction storableJson(value: unknown): unknown {\n if (typeof value === \"string\") return storableString(value);\n if (Array.isArray(value)) return value.map(storableJson);\n if (value === null || typeof value !== \"object\") return value;\n return Object.fromEntries(\n Object.entries(value).map(([key, entry]) => [\n storableString(key),\n storableJson(entry),\n ]),\n );\n}\n\n/**\n * Checks that an embedded snapshot's expansion names the revision it was\n * taken from, since an embedded document cannot be expanded on its own.\n * @param capture How the snapshot was captured.\n * @param expansion Its expansion.\n * @throws {TypeError} If an embedded expansion has no source.\n */\nexport function checkExpansionSource(\n capture: ResourceRevision[\"capture\"] | undefined,\n expansion: RevisionExpansionInput | null | undefined,\n): void {\n if (\n capture === \"embedded\" &&\n expansion?.outcome === \"expanded\" &&\n expansion.sourceRevisionId === undefined\n ) {\n throw new TypeError(\n \"An embedded snapshot's expansion names the revision it was taken from.\",\n );\n }\n}\n\n/**\n * An expansion serialized for storage, so that it is fixed when the revision\n * is prepared rather than when the row is inserted.\n */\nexport interface SerializedExpansion {\n readonly outcome: ResourceRevisionExpansionOutcome;\n /** The expanded document as JSON text, for a `jsonb` column. */\n readonly document: string | null;\n readonly droppedTerms: readonly string[] | null;\n readonly undefinedTerms: readonly string[] | null;\n readonly failure: string | null;\n readonly sourceRevisionId: Uuid | null;\n}\n\ntype ResourceRevisionExpansionOutcome = ExpansionRow[\"outcome\"];\n\n/**\n * Serializes an expansion for storage. An expanded document that JSON cannot\n * represent, such as one keeping a number beyond the double range, is\n * recorded as a failure instead of failing the write. Strings are normalized\n * for `jsonb` and `text`, and `jsonb` stores negative zero as zero.\n * @param expansion The expansion, or null for a revision without a document.\n * @returns The serialized expansion.\n */\nexport function serializeExpansion(\n expansion: RevisionExpansionInput | null,\n): SerializedExpansion {\n const none = {\n document: null,\n droppedTerms: null,\n undefinedTerms: null,\n failure: null,\n };\n if (expansion === null) {\n return { ...none, outcome: \"no_document\", sourceRevisionId: null };\n }\n const sourceRevisionId = expansion.sourceRevisionId ?? null;\n if (expansion.outcome === \"expanded\") {\n try {\n return {\n outcome: \"expanded\",\n document: json(storableJson(expansion.document)),\n droppedTerms: expansion.droppedTerms.map(storableString),\n undefinedTerms: expansion.undefinedTerms.map(storableString),\n failure: null,\n sourceRevisionId,\n };\n } catch (error) {\n if (!(error instanceof TypeError)) throw error;\n return {\n ...none,\n outcome: \"failed\",\n failure: `The expanded document cannot be stored as JSON: ${error.message}`,\n sourceRevisionId,\n };\n }\n }\n return {\n ...none,\n outcome: \"failed\",\n failure: storableString(expansion.failure),\n sourceRevisionId,\n };\n}\n\n/**\n * Builds the row recording a revision's expansion.\n * @param revisionId The revision.\n * @param serialized The serialized expansion.\n * @returns The row to insert.\n */\nexport function expansionRow(\n revisionId: Uuid,\n serialized: SerializedExpansion,\n): ExpansionRow {\n return {\n revisionId,\n outcome: serialized.outcome,\n document:\n serialized.document === null ? null : sql`${serialized.document}::jsonb`,\n droppedTerms:\n serialized.droppedTerms === null ? null : [...serialized.droppedTerms],\n undefinedTerms:\n serialized.undefinedTerms === null\n ? null\n : [...serialized.undefinedTerms],\n failure: serialized.failure,\n sourceRevisionId: serialized.sourceRevisionId,\n };\n}\n\n/**\n * Records the expansions of a resource's revisions that have none, after a\n * legacy capture. Revisions the capture created have none; a revision it\n * reused has none only if it predates expansions, and the capture has then\n * verified that its document equals the typed one. `expansion` is of that\n * document, so it is recorded only for the snapshot the capture returned;\n * other snapshots without one are handled as if none were given.\n * @param tx The capturing transaction.\n * @param resourceId The captured resource.\n * @param capturedId The revision the capture returned.\n * @param expansion The expansion of the typed document, if the caller computed\n * it; otherwise the document is expanded offline here, from\n * preloaded contexts only, when it was written locally. A\n * received, embedded, or fetched snapshot may need remote\n * contexts or the context it inherits, so without one it is\n * left without a row for the backfill, which loads them;\n * a failure recorded offline would keep the backfill away.\n */\nexport async function recordMissingExpansions(\n tx: Transaction,\n resourceId: Uuid,\n capturedId: Uuid,\n expansion?: RevisionExpansionInput,\n): Promise<void> {\n const missing = await tx\n .select({\n id: resourceRevisions.id,\n kind: resourceRevisions.kind,\n capture: resourceRevisions.capture,\n document: resourceRevisions.document,\n })\n .from(resourceRevisions)\n .leftJoin(\n revisionExpansions,\n eq(revisionExpansions.revisionId, resourceRevisions.id),\n )\n .where(\n and(\n eq(resourceRevisions.resourceId, resourceId),\n isNull(revisionExpansions.revisionId),\n ),\n )\n .orderBy(asc(resourceRevisions.sequence));\n const rows: ExpansionRow[] = [];\n const given =\n expansion === undefined ? undefined : serializeExpansion(expansion);\n for (const revision of missing) {\n if (revision.kind !== \"snapshot\") {\n // A revision without a document records why, when the capture says.\n const failed =\n revision.id === capturedId &&\n revision.kind === \"unavailable\" &&\n given?.outcome === \"failed\";\n if (revision.id === capturedId && given !== undefined && !failed) {\n throw new TypeError(\n `A revision of kind ${revision.kind} has no document to expand.`,\n );\n }\n rows.push(\n expansionRow(revision.id, failed ? given : serializeExpansion(null)),\n );\n continue;\n }\n if (given === undefined || revision.id !== capturedId) {\n if (revision.capture !== \"local\") continue;\n // oxlint-disable-next-line no-await-in-loop\n const own = await expandDocument(revision.document);\n if (own.outcome === \"no_document\") {\n throw new TypeError(\"A snapshot revision has a document.\");\n }\n rows.push(expansionRow(revision.id, serializeExpansion(own)));\n continue;\n }\n checkExpansionSource(revision.capture, expansion);\n rows.push(expansionRow(revision.id, given));\n }\n if (rows.length > 0) {\n await tx.insert(revisionExpansions).values(rows).onConflictDoNothing();\n }\n}\n\n/** A revision the backfill has not reached, as {@link listUnexpandedRevisions} lists it. */\nexport interface UnexpandedRevision {\n readonly id: Uuid;\n readonly resourceId: Uuid;\n /** The IRI of the revision's resource. */\n readonly resourceIri: string;\n readonly kind: ResourceRevision[\"kind\"];\n readonly capture: ResourceRevision[\"capture\"];\n readonly document: unknown;\n}\n\n/**\n * Lists revisions without an expansion, in ID order.\n * @param db The database.\n * @param options Where to continue from, and how many to list.\n * @returns Up to `limit` revisions after `after`.\n */\nexport async function listUnexpandedRevisions(\n db: Database | Transaction,\n options: { readonly after?: Uuid; readonly limit: number },\n): Promise<UnexpandedRevision[]> {\n return await listRevisions(\n db,\n isNull(revisionExpansions.revisionId),\n options,\n );\n}\n\n/**\n * Lists snapshot revisions whose expansion failed, in ID order, so that a\n * failure such as a context that could not be loaded can be retried.\n * @param db The database.\n * @param options Where to continue from, and how many to list.\n * @returns Up to `limit` revisions after `after`.\n */\nexport async function listFailedRevisions(\n db: Database | Transaction,\n options: { readonly after?: Uuid; readonly limit: number },\n): Promise<UnexpandedRevision[]> {\n return await listRevisions(\n db,\n and(\n eq(revisionExpansions.outcome, \"failed\"),\n eq(resourceRevisions.kind, \"snapshot\"),\n ),\n options,\n );\n}\n\nasync function listRevisions(\n db: Database | Transaction,\n condition: SQL | undefined,\n options: { readonly after?: Uuid; readonly limit: number },\n): Promise<UnexpandedRevision[]> {\n return await db\n .select({\n id: resourceRevisions.id,\n resourceId: resourceRevisions.resourceId,\n resourceIri: resources.iri,\n kind: resourceRevisions.kind,\n capture: resourceRevisions.capture,\n document: resourceRevisions.document,\n })\n .from(resourceRevisions)\n .innerJoin(resources, eq(resources.id, resourceRevisions.resourceId))\n .leftJoin(\n revisionExpansions,\n eq(revisionExpansions.revisionId, resourceRevisions.id),\n )\n .where(\n and(\n condition,\n options.after === undefined\n ? undefined\n : gt(resourceRevisions.id, options.after),\n ),\n )\n .orderBy(asc(resourceRevisions.id))\n .limit(options.limit);\n}\n\n/**\n * Finds the revision of the activity that first carried an embedded object,\n * the one its typed row names, which an embedded revision's expansion is\n * taken from.\n * @param db The database.\n * @param objectId The embedded object's resource.\n * @returns The activity's first revision, or null if there is none.\n */\nexport async function findCarryingActivityRevision(\n db: Database | Transaction,\n objectId: Uuid,\n): Promise<{ readonly id: Uuid; readonly document: unknown } | null> {\n const [row] = await db\n .select({\n id: resourceRevisions.id,\n document: resourceRevisions.document,\n })\n .from(objects)\n .innerJoin(\n resourceRevisions,\n and(\n eq(resourceRevisions.resourceId, objects.activityId),\n eq(resourceRevisions.sequence, 1),\n eq(resourceRevisions.kind, \"snapshot\"),\n ),\n )\n .where(eq(objects.id, objectId))\n .limit(1);\n return row ?? null;\n}\n\n/**\n * Records the expansion of a revision that has none. An existing row is kept,\n * so that the backfill can run again or alongside new writes.\n * @param db The database.\n * @param revisionId The revision.\n * @param expansion Its expansion, or null for a revision without a document,\n * which must be `unavailable` or a `whiteout`.\n * @returns The outcome of the row inserted, which is `failed` for an\n * expansion JSON cannot hold, or null if the revision already had\n * one.\n * @throws {TypeError} If the revision does not exist, or the expansion does\n * not suit its kind.\n */\nexport async function recordRevisionExpansion(\n db: Database | Transaction,\n revisionId: Uuid,\n expansion: RevisionExpansionInput | null,\n): Promise<RevisionExpansion[\"outcome\"] | null> {\n const serialized = await checkedExpansion(db, revisionId, expansion);\n const inserted = await db\n .insert(revisionExpansions)\n .values(expansionRow(revisionId, serialized))\n .onConflictDoNothing()\n .returning({ outcome: revisionExpansions.outcome });\n return inserted[0]?.outcome ?? null;\n}\n\n/**\n * Replaces a failed expansion of a revision, as when a context that could not\n * be loaded before now loads. A row that is no longer failed, because\n * another writer replaced it first, is kept.\n * @param db The database.\n * @param revisionId The revision.\n * @param expansion Its new expansion.\n * @returns The outcome of the row replaced, or null if it was not failed.\n * @throws {TypeError} If the revision does not exist, or the expansion does\n * not suit its kind.\n */\nexport async function retryRevisionExpansion(\n db: Database | Transaction,\n revisionId: Uuid,\n expansion: RevisionExpansionInput | null,\n): Promise<RevisionExpansion[\"outcome\"] | null> {\n const serialized = await checkedExpansion(db, revisionId, expansion);\n const { revisionId: _revisionId, ...columns } = expansionRow(\n revisionId,\n serialized,\n );\n const updated = await db\n .update(revisionExpansions)\n .set(columns)\n .where(\n and(\n eq(revisionExpansions.revisionId, revisionId),\n eq(revisionExpansions.outcome, \"failed\"),\n ),\n )\n .returning({ outcome: revisionExpansions.outcome });\n return updated[0]?.outcome ?? null;\n}\n\n// Checks an expansion against the revision it is recorded for.\nasync function checkedExpansion(\n db: Database | Transaction,\n revisionId: Uuid,\n expansion: RevisionExpansionInput | null,\n): Promise<SerializedExpansion> {\n if (expansion !== null) checkRevisionExpansion(expansion);\n const serialized = serializeExpansion(expansion);\n const [revision] = await db\n .select({\n kind: resourceRevisions.kind,\n capture: resourceRevisions.capture,\n })\n .from(resourceRevisions)\n .where(eq(resourceRevisions.id, revisionId))\n .limit(1);\n if (revision === undefined) {\n throw new TypeError(\"The revision does not exist.\");\n }\n // A revision's kind never changes, so checking it first is enough.\n // A snapshot is expanded or fails; an unavailable revision may record why\n // its document is missing; a whiteout has nothing to expand.\n const fits =\n revision.kind === \"snapshot\"\n ? expansion !== null\n : expansion === null ||\n (revision.kind === \"unavailable\" && expansion.outcome === \"failed\");\n if (!fits) {\n throw new TypeError(\n revision.kind === \"snapshot\"\n ? \"A snapshot has a document to expand.\"\n : `A revision of kind ${revision.kind} has no document to expand.`,\n );\n }\n checkExpansionSource(revision.capture, expansion);\n return serialized;\n}\n","// 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/>.\n\nimport { sql } from \"drizzle-orm\";\n\nimport type { Transaction } from \"./db.ts\";\nimport { LegacyResourceRevisionError } from \"./legacy-resource-revision-error.ts\";\nimport {\n type RevisionExpansionInput,\n checkRevisionExpansion,\n recordMissingExpansions,\n} from \"./revision-expansion.ts\";\nimport type { Uuid } from \"./uuid.ts\";\n\n/** Options for {@link captureLegacyResourceRevision}. */\nexport interface CaptureLegacyResourceRevisionOptions {\n /**\n * The expansion of the typed row's document, computed before the\n * transaction. When omitted, a captured snapshot is expanded offline within\n * the transaction.\n */\n readonly expansion?: RevisionExpansionInput;\n}\n\n/**\n * Captures fully written legacy typed state within its creating transaction.\n * This trusted compatibility operation performs no authorization or fetching.\n * Repeated calls return the original revision only when the typed state agrees.\n * Revisions of the resource without an expansion get one, so that a capture\n * reusing a revision made before expansions were stored records it too.\n * @returns The first retained revision ID, including an unavailable snapshot.\n * @throws {LegacyResourceRevisionError} When typed state cannot be captured.\n */\nexport async function captureLegacyResourceRevision(\n tx: Transaction,\n resourceId: Uuid,\n options: CaptureLegacyResourceRevisionOptions = {},\n): Promise<Uuid> {\n if (options.expansion !== undefined) {\n checkRevisionExpansion(options.expansion);\n }\n const id = await capture(tx, resourceId);\n await recordMissingExpansions(tx, resourceId, id, options.expansion);\n return id;\n}\n\nasync function capture(tx: Transaction, resourceId: Uuid): Promise<Uuid> {\n try {\n const [row] = await tx\n .select({\n id: sql<Uuid>`drfed_capture_legacy_resource(${resourceId}::uuid, false)`,\n })\n .from(sql`(VALUES (1)) AS capture_input(value)`);\n if (row === undefined) {\n throw new Error(\"Legacy capture returned no revision.\");\n }\n return row.id;\n } catch (error) {\n let detail: unknown = error;\n while (detail instanceof Error) {\n if (\n (\"constraint\" in detail &&\n detail.constraint === \"resource_revisions_legacy_guard\") ||\n (\"constraint_name\" in detail &&\n detail.constraint_name === \"resource_revisions_legacy_guard\")\n ) {\n throw new LegacyResourceRevisionError(resourceId);\n }\n detail = detail.cause;\n }\n throw error;\n }\n}\n","// 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/>.\n\nimport { and, desc, eq, inArray, isNull, lt, sql } from \"drizzle-orm\";\n\nimport type { Database, Transaction } from \"./db.ts\";\nimport { expandDocument } from \"./expansion.ts\";\nimport { json } from \"./json-text.ts\";\nimport { LegacyResourceRevisionError } from \"./legacy-resource-revision-error.ts\";\nimport { ResourceRevisionStateError } from \"./resource-revision-state-error.ts\";\nimport {\n type AddressingInput,\n type AddressingOccurrence,\n ResourceKindConflictError,\n checkAddressingOccurrences,\n replaceAddressing,\n} from \"./resource.ts\";\nimport { RevisionConflictError } from \"./revision-conflict-error.ts\";\nimport {\n type RevisionExpansionInput,\n type SerializedExpansion,\n checkExpansionSource,\n checkRevisionExpansion,\n expansionRow,\n serializeExpansion,\n} from \"./revision-expansion.ts\";\nimport {\n type NewActivityPubObject,\n type ResourceRevision,\n type RevisionAddressing,\n type RevisionEmbedding,\n type RevisionExpansion,\n type RevisionRelation,\n activities,\n addressingPropertyEnum,\n addressing as addressingTable,\n objects,\n resourceHeads,\n resourceRevisionCaptureEnum,\n resourceRevisionProjectionEnum,\n resourceRevisions,\n resources,\n revisionAddressing,\n revisionEmbeddingRelationEnum,\n revisionEmbeddings,\n revisionExpansions,\n revisionRelations,\n} from \"./schema.ts\";\nimport { storableText } from \"./text.ts\";\nimport { type Uuid, areUuidsEqual, uuidV7, validateUuid } from \"./uuid.ts\";\n\n/** A value representable by JSON, without implicit coercion. */\nexport type JsonValue =\n | string\n | number\n | boolean\n | null\n | readonly JsonValue[]\n | {\n readonly [property: string]: JsonValue;\n };\nexport type JsonObject = { readonly [property: string]: JsonValue };\n\n/** A semantic adapter's relation projection; no JSON-LD interpretation occurs here. */\nexport interface RevisionRelationInput {\n readonly property: string;\n readonly path?: readonly (string | number)[] | null;\n readonly representation: RevisionRelation[\"representation\"];\n readonly targetIri?: string | null;\n}\n\n/**\n * Where an embedded document of a new snapshot came from, as\n * `revisionEmbeddings` records it. The caller decides the relation by\n * comparing the documents; nothing is compared here.\n */\nexport interface RevisionEmbeddingInput {\n /** The embedded document's source path from the root; never `[]`. */\n readonly path: readonly (string | number)[];\n /** A snapshot of another resource, stored before this revision. */\n readonly sourceRevisionId: Uuid;\n readonly relation: RevisionEmbedding[\"relation\"];\n}\n\ninterface AppendBase {\n readonly resourceId: Uuid;\n readonly resourceKind: \"object\" | \"activity\";\n /** Null requires that the resource has no current revision. */\n readonly expectedRevisionId: Uuid | null;\n}\nexport type AppendResourceRevisionInput = AppendBase &\n (\n | {\n readonly kind: \"snapshot\";\n readonly document: JsonObject;\n readonly capture: ResourceRevision[\"capture\"];\n readonly addressing?: AddressingInput;\n /**\n * Explicit occurrences at their source positions, instead of\n * `addressing`; positions of unindexed values stay unused.\n */\n readonly addressingOccurrences?: readonly AddressingOccurrence[];\n readonly relations?: readonly RevisionRelationInput[];\n /** Embedded documents whose source is known, each path once. */\n readonly embeddings?: readonly RevisionEmbeddingInput[];\n readonly projection?: ResourceRevision[\"projection\"];\n /**\n * The document's expansion. When omitted, the document is expanded\n * offline, from preloaded contexts only, before this function opens\n * its transaction, or within the caller's. A document that needs\n * remote contexts must be expanded before the caller's transaction\n * and passed here, since none is fetched within it.\n */\n readonly expansion?: RevisionExpansionInput;\n }\n | {\n readonly kind: \"whiteout\";\n readonly deleted: Temporal.Instant;\n readonly formerTypes: readonly string[];\n }\n );\n\nexport {\n type RevisionExpansionInput,\n type UnexpandedRevision,\n findCarryingActivityRevision,\n listFailedRevisions,\n listUnexpandedRevisions,\n recordRevisionExpansion,\n retryRevisionExpansion,\n} from \"./revision-expansion.ts\";\n\n/** Protected local JSON and projections, not an authorized or wire representation. */\nexport interface StoredResourceRevision extends ResourceRevision {\n readonly addressing: readonly RevisionAddressing[];\n readonly relations: readonly RevisionRelation[];\n}\n\nexport { RevisionConflictError } from \"./revision-conflict-error.ts\";\nexport { LegacyResourceRevisionError } from \"./legacy-resource-revision-error.ts\";\nexport { ResourceRevisionStateError } from \"./resource-revision-state-error.ts\";\n\nfunction text(value: unknown): asserts value is string {\n if (typeof value !== \"string\" || !storableText(value)) {\n throw new TypeError(\"A projection must contain losslessly storable text.\");\n }\n}\n\nfunction projectionRows(\n input: AddressingInput = {},\n): Omit<RevisionAddressing, \"revisionId\">[] {\n const rows: Omit<RevisionAddressing, \"revisionId\">[] = [];\n for (const property of Object.keys(input)) {\n if (\n !addressingPropertyEnum.enumValues.includes(\n property as RevisionAddressing[\"property\"],\n )\n ) {\n throw new TypeError(\"Unknown addressing projection property.\");\n }\n }\n for (const property of addressingPropertyEnum.enumValues) {\n const values = input[property];\n if (values === undefined) continue;\n if (!Array.isArray(values)) {\n throw new TypeError(\"Addressing projections must be arrays.\");\n }\n for (const [position, iri] of values.entries()) {\n text(iri);\n rows.push({ property, position, iri });\n }\n }\n return rows;\n}\n\nfunction relationRows(\n input: readonly RevisionRelationInput[] = [],\n): Omit<RevisionRelation, \"revisionId\">[] {\n if (!Array.isArray(input)) {\n throw new TypeError(\"Relation projections must be arrays.\");\n }\n return input.map((relation, occurrence) => {\n text(relation.property);\n const targetIri = relation.targetIri ?? null;\n if (targetIri !== null) text(targetIri);\n if (\n ![\"reference\", \"embedded\", \"link\"].includes(relation.representation) ||\n (relation.representation === \"reference\" && targetIri === null)\n ) {\n throw new TypeError(\"Invalid relation representation.\");\n }\n const path = relation.path ?? null;\n if (\n path !== null &&\n (!Array.isArray(path) ||\n Array.from(path).some(\n (part) =>\n typeof part !== \"string\" &&\n !(Number.isSafeInteger(part) && part >= 0),\n ))\n ) {\n throw new TypeError(\n \"A relation path must contain field names and nonnegative indexes.\",\n );\n }\n return {\n occurrence,\n property: relation.property,\n representation: relation.representation,\n targetIri,\n path: path === null ? null : [...path],\n };\n });\n}\n\nfunction embeddingRows(\n input: readonly RevisionEmbeddingInput[] = [],\n): Omit<RevisionEmbedding, \"revisionId\">[] {\n if (!Array.isArray(input)) {\n throw new TypeError(\"Embedding projections must be arrays.\");\n }\n const paths = new Set<string>();\n return input.map(({ path, sourceRevisionId, relation }) => {\n if (\n !Array.isArray(path) ||\n path.length < 1 ||\n Array.from(path).some(\n (part) =>\n typeof part !== \"string\" &&\n !(Number.isSafeInteger(part) && part >= 0),\n )\n ) {\n throw new TypeError(\n \"An embedding path must name a nonempty list of field names and \" +\n \"nonnegative indexes.\",\n );\n }\n for (const part of path) if (typeof part === \"string\") text(part);\n const key = JSON.stringify(path);\n if (paths.has(key)) {\n throw new TypeError(\"Each embedding path must be given once.\");\n }\n paths.add(key);\n if (!validateUuid(sourceRevisionId)) {\n throw new TypeError(\"Expected a source revision UUID.\");\n }\n if (!revisionEmbeddingRelationEnum.enumValues.includes(relation)) {\n throw new TypeError(\"Invalid embedding relation.\");\n }\n return { path: [...path], sourceRevisionId, relation };\n });\n}\n\nasync function current(\n db: Database | Transaction,\n resourceId: Uuid,\n): Promise<ResourceRevision | null> {\n const [row] = await db\n .select({ revision: resourceRevisions })\n .from(resourceHeads)\n .innerJoin(\n resourceRevisions,\n and(\n eq(resourceHeads.resourceId, resourceRevisions.resourceId),\n eq(resourceHeads.revisionId, resourceRevisions.id),\n ),\n )\n .where(eq(resourceHeads.resourceId, resourceId))\n .limit(1);\n return row?.revision ?? null;\n}\n\nasync function hydrate(\n db: Database | Transaction,\n revision: ResourceRevision,\n): Promise<StoredResourceRevision> {\n const [addressing, relations] = await Promise.all([\n db\n .select()\n .from(revisionAddressing)\n .where(eq(revisionAddressing.revisionId, revision.id))\n .orderBy(revisionAddressing.property, revisionAddressing.position),\n db\n .select()\n .from(revisionRelations)\n .where(eq(revisionRelations.revisionId, revision.id))\n .orderBy(revisionRelations.occurrence),\n ]);\n return { ...revision, addressing, relations };\n}\n\ninterface PreparedRevision extends AppendBase {\n readonly kind: \"snapshot\" | \"whiteout\";\n readonly serialized: string | null;\n readonly capture: ResourceRevision[\"capture\"] | undefined;\n readonly projection: ResourceRevision[\"projection\"] | undefined;\n readonly addressing: Omit<RevisionAddressing, \"revisionId\">[];\n readonly relations: Omit<RevisionRelation, \"revisionId\">[];\n readonly embeddings: Omit<RevisionEmbedding, \"revisionId\">[];\n readonly deleted: Temporal.Instant | null;\n readonly formerTypes: string[] | null;\n /**\n * Serialized when the revision is prepared, so that a caller changing its\n * expansion afterwards cannot change what is stored; undefined until the\n * snapshot is expanded.\n */\n readonly expansion: SerializedExpansion | undefined;\n /** The snapshot document, kept to expand it before the transaction. */\n readonly source: JsonObject | null;\n}\n\ntype PreparedValue = Omit<PreparedRevision, keyof AppendBase>;\nfunction prepareSnapshot(\n input: Extract<AppendResourceRevisionInput, { kind: \"snapshot\" }>,\n): PreparedValue {\n if (\n input.document === null ||\n typeof input.document !== \"object\" ||\n Array.isArray(input.document)\n ) {\n throw new TypeError(\"A new resource document must be a JSON object.\");\n }\n const projection = input.projection ?? \"partial\";\n if (\n !resourceRevisionCaptureEnum.enumValues.includes(input.capture) ||\n !resourceRevisionProjectionEnum.enumValues.includes(projection)\n ) {\n throw new TypeError(\"Invalid capture or projection category.\");\n }\n let addressing: Omit<RevisionAddressing, \"revisionId\">[];\n if (input.addressingOccurrences === undefined) {\n addressing = projectionRows(input.addressing);\n } else {\n if (input.addressing !== undefined) {\n throw new TypeError(\"Pass addressing or its occurrences, not both.\");\n }\n checkAddressingOccurrences(input.addressingOccurrences);\n addressing = input.addressingOccurrences.map(\n ({ property, position, iri }) => {\n text(iri);\n return { property, position, iri };\n },\n );\n }\n if (input.expansion !== undefined) {\n checkRevisionExpansion(input.expansion);\n checkExpansionSource(input.capture, input.expansion);\n }\n return {\n kind: \"snapshot\",\n serialized: json(input.document),\n capture: input.capture,\n projection,\n addressing,\n relations: relationRows(input.relations),\n embeddings: embeddingRows(input.embeddings),\n deleted: null,\n formerTypes: null,\n expansion:\n input.expansion === undefined\n ? undefined\n : serializeExpansion(input.expansion),\n source: input.document,\n };\n}\n\nfunction prepareWhiteout(\n input: Extract<AppendResourceRevisionInput, { kind: \"whiteout\" }>,\n): PreparedValue {\n if (\n !(input.deleted instanceof Temporal.Instant) ||\n !Array.isArray(input.formerTypes)\n ) {\n throw new TypeError(\"Expected a deletion instant and former type array.\");\n }\n const formerTypes = [...input.formerTypes];\n for (const type of formerTypes) text(type);\n return {\n kind: \"whiteout\",\n serialized: null,\n capture: undefined,\n projection: undefined,\n addressing: [],\n relations: [],\n embeddings: [],\n deleted: input.deleted,\n formerTypes,\n expansion: serializeExpansion(null),\n source: null,\n };\n}\n\nfunction prepareRevision(input: AppendResourceRevisionInput): PreparedRevision {\n const { resourceId, resourceKind, expectedRevisionId } = input;\n if (\n !validateUuid(resourceId) ||\n (expectedRevisionId !== null && !validateUuid(expectedRevisionId))\n ) {\n throw new TypeError(\"Expected canonical resource and revision UUIDs.\");\n }\n if (resourceKind !== \"object\" && resourceKind !== \"activity\") {\n throw new TypeError(\"Unsupported resource kind.\");\n }\n if (input.kind === \"snapshot\") {\n return {\n resourceId,\n resourceKind,\n expectedRevisionId,\n ...prepareSnapshot(input),\n };\n }\n if (input.kind === \"whiteout\") {\n return {\n resourceId,\n resourceKind,\n expectedRevisionId,\n ...prepareWhiteout(input),\n };\n }\n throw new TypeError(\"Unsupported revision kind.\");\n}\n\nasync function lockRevisionTarget(\n tx: Transaction,\n input: PreparedRevision,\n typed = false,\n): Promise<ResourceRevision | null> {\n const { resourceId, resourceKind, expectedRevisionId, kind } = input;\n const [resource] = await tx\n .select()\n .from(resources)\n .where(eq(resources.id, resourceId))\n .for(\"no key update\");\n if (resource === undefined) {\n throw new Error(\"The canonical resource is not registered.\");\n }\n // Read the head separately after the resource lock, including after a wait.\n const previous = await current(tx, resourceId);\n const matches =\n previous === null\n ? expectedRevisionId === null\n : expectedRevisionId !== null &&\n areUuidsEqual(previous.id, expectedRevisionId);\n if (!matches) {\n throw new RevisionConflictError(\n resourceId,\n expectedRevisionId,\n previous?.id ?? null,\n );\n }\n const [legacyObject, legacyActivity] = await Promise.all([\n tx\n .select({ id: objects.id })\n .from(objects)\n .where(eq(objects.id, resourceId))\n .limit(1),\n tx\n .select({ id: activities.id })\n .from(activities)\n .where(eq(activities.id, resourceId))\n .limit(1),\n ]);\n // A typed append has verified and changes the typed row itself.\n if (!typed && (legacyObject.length > 0 || legacyActivity.length > 0)) {\n throw new LegacyResourceRevisionError(resourceId);\n }\n if (resource.kind !== \"unknown\" && resource.kind !== resourceKind) {\n throw new ResourceKindConflictError(\n resource.iri,\n resource.kind,\n resourceKind,\n );\n }\n if (previous !== null && resourceKind === \"activity\") {\n throw new ResourceRevisionStateError(\"activity-immutable\");\n }\n if (previous?.kind === \"whiteout\") {\n throw new ResourceRevisionStateError(\"deleted\");\n }\n if (kind === \"whiteout\" && previous === null) {\n throw new ResourceRevisionStateError(\"initial-whiteout\");\n }\n if (resource.kind === \"unknown\") {\n await tx\n .update(resources)\n .set({ kind: resourceKind })\n .where(eq(resources.id, resourceId));\n }\n return previous;\n}\n\nasync function appendPrepared(\n tx: Transaction,\n input: PreparedRevision,\n typed = false,\n): Promise<StoredResourceRevision> {\n const previous = await lockRevisionTarget(tx, input, typed);\n const {\n resourceId,\n kind,\n serialized,\n capture,\n projection,\n deleted,\n formerTypes,\n addressing,\n relations,\n embeddings,\n } = input;\n const id = uuidV7();\n const [revision] = await tx\n .insert(resourceRevisions)\n .values({\n id,\n resourceId,\n sequence: (previous?.sequence ?? 0) + 1,\n kind,\n capture: capture ?? previous!.capture,\n projection: projection ?? previous!.projection,\n document: serialized === null ? null : sql`${serialized}::json`,\n deleted,\n formerTypes,\n })\n .returning();\n if (revision === undefined) {\n throw new Error(\"Revision insertion returned no row.\");\n }\n if (kind === \"whiteout\") {\n const inherited = await hydrate(tx, previous!);\n addressing.push(\n ...inherited.addressing.map(({ revisionId: _revisionId, ...row }) => row),\n );\n relations.push(\n ...inherited.relations.map(({ revisionId: _revisionId, ...row }) => row),\n );\n }\n if (addressing.length > 0) {\n await tx\n .insert(revisionAddressing)\n .values(addressing.map((row) => ({ ...row, revisionId: id })));\n }\n if (relations.length > 0) {\n await tx\n .insert(revisionRelations)\n .values(relations.map((row) => ({ ...row, revisionId: id })));\n }\n if (embeddings.length > 0) {\n await tx\n .insert(revisionEmbeddings)\n .values(embeddings.map((row) => ({ ...row, revisionId: id })));\n }\n if (input.expansion === undefined) {\n throw new TypeError(\"A snapshot must be expanded before its transaction.\");\n }\n await tx.insert(revisionExpansions).values(expansionRow(id, input.expansion));\n if (previous === null) {\n await tx.insert(resourceHeads).values({ resourceId, revisionId: id });\n } else {\n await tx\n .update(resourceHeads)\n .set({ revisionId: id })\n .where(eq(resourceHeads.resourceId, resourceId));\n }\n return await hydrate(tx, revision);\n}\n\n// Expand outside the transaction the caller is about to open.\nasync function expanded(prepared: PreparedRevision): Promise<PreparedRevision> {\n if (prepared.expansion !== undefined || prepared.source === null) {\n return prepared;\n }\n // Without the context it inherits, an embedded document would expand to\n // something else; it is expanded from the activity that carried it.\n if (prepared.capture === \"embedded\") {\n throw new TypeError(\"An embedded snapshot needs its given expansion.\");\n }\n const expansion = await expandDocument(prepared.source);\n if (expansion.outcome === \"no_document\") {\n throw new TypeError(\"A snapshot revision has a document.\");\n }\n return { ...prepared, expansion: serializeExpansion(expansion) };\n}\n\n/**\n * Appends one current object version or saved activity, atomically with projections.\n * The caller must validate the document and authorize the write. Lock multiple\n * canonical IRIs in sorted order before composing several appends in one transaction.\n * This does not publish, change collection membership, or reserve delivery.\n * The revision's expansion is stored with it; see the `expansion` input.\n * @returns The stored revision, including protected blind addressing.\n */\nexport async function appendResourceRevision(\n db: Database | Transaction,\n input: AppendResourceRevisionInput,\n): Promise<StoredResourceRevision> {\n const prepared = await expanded(prepareRevision(input));\n return await db.transaction((tx) => appendPrepared(tx, prepared));\n}\n\n/**\n * Loads the recorded expansion of a revision's document.\n * @returns The expansion, or null if the revision has not been expanded.\n */\nexport async function loadRevisionExpansion(\n db: Database | Transaction,\n revisionId: Uuid,\n): Promise<RevisionExpansion | null> {\n const [row] = await db\n .select()\n .from(revisionExpansions)\n .where(eq(revisionExpansions.revisionId, revisionId))\n .limit(1);\n return row ?? null;\n}\n\n/**\n * Loads protected local JSON without applying authorization or stripping bto/bcc.\n * @returns The immutable revision and projections, or null if not found.\n */\nexport async function loadResourceRevision(\n db: Database | Transaction,\n revisionId: Uuid,\n): Promise<StoredResourceRevision | null> {\n const [revision] = await db\n .select()\n .from(resourceRevisions)\n .where(eq(resourceRevisions.id, revisionId))\n .limit(1);\n return revision === undefined ? null : await hydrate(db, revision);\n}\n\n/**\n * Loads current protected local state without dereferencing any document target.\n * @returns A snapshot, unavailable record or whiteout, or null when unversioned.\n */\nexport async function loadCurrentResourceRevision(\n db: Database | Transaction,\n resourceId: Uuid,\n): Promise<StoredResourceRevision | null> {\n const revision = await current(db, resourceId);\n return revision === null ? null : await hydrate(db, revision);\n}\n\nconst MAX_HISTORY_LIMIT = 100;\nconst DEFAULT_HISTORY_LIMIT = 20;\n/**\n * Lists protected history in descending sequence order; authorization belongs to callers.\n * @returns Up to limit revisions strictly before beforeSequence, when supplied.\n */\nexport async function listResourceRevisions(\n db: Database | Transaction,\n resourceId: Uuid,\n options: { readonly beforeSequence?: number; readonly limit?: number } = {},\n): Promise<StoredResourceRevision[]> {\n const { beforeSequence, limit = DEFAULT_HISTORY_LIMIT } = options;\n if (\n !Number.isInteger(limit) ||\n limit < 1 ||\n limit > MAX_HISTORY_LIMIT ||\n (beforeSequence !== undefined &&\n (!Number.isSafeInteger(beforeSequence) || beforeSequence < 1))\n ) {\n throw new RangeError(\"Invalid history bounds.\");\n }\n const revisions = await db\n .select()\n .from(resourceRevisions)\n .where(\n and(\n eq(resourceRevisions.resourceId, resourceId),\n beforeSequence === undefined\n ? undefined\n : lt(resourceRevisions.sequence, beforeSequence),\n ),\n )\n .orderBy(desc(resourceRevisions.sequence))\n .limit(limit);\n if (revisions.length === 0) return [];\n const revisionIds = revisions.map(({ id }) => id);\n const [addressing, relations] = await Promise.all([\n db\n .select()\n .from(revisionAddressing)\n .where(inArray(revisionAddressing.revisionId, revisionIds))\n .orderBy(revisionAddressing.property, revisionAddressing.position),\n db\n .select()\n .from(revisionRelations)\n .where(inArray(revisionRelations.revisionId, revisionIds))\n .orderBy(revisionRelations.occurrence),\n ]);\n const addressingByRevision = new Map<Uuid, RevisionAddressing[]>();\n for (const row of addressing) {\n const rows = addressingByRevision.get(row.revisionId) ?? [];\n rows.push(row);\n addressingByRevision.set(row.revisionId, rows);\n }\n const relationsByRevision = new Map<Uuid, RevisionRelation[]>();\n for (const row of relations) {\n const rows = relationsByRevision.get(row.revisionId) ?? [];\n rows.push(row);\n relationsByRevision.set(row.revisionId, rows);\n }\n return revisions.map((revision) => ({\n ...revision,\n addressing: addressingByRevision.get(revision.id) ?? [],\n relations: relationsByRevision.get(revision.id) ?? [],\n }));\n}\n\n/** Typed object columns a coordinated edit may set, besides its document. */\nexport type TypedObjectColumns = Pick<\n NewActivityPubObject,\n | \"type\"\n | \"url\"\n | \"name\"\n | \"summary\"\n | \"contentHtml\"\n | \"language\"\n | \"sensitive\"\n | \"published\"\n | \"updated\"\n>;\n\ninterface TypedRevisionBase {\n readonly resourceId: Uuid;\n /** The current revision; a typed object always has one. */\n readonly expectedRevisionId: Uuid;\n}\nexport type TypedResourceRevisionInput = TypedRevisionBase &\n (\n | {\n readonly kind: \"snapshot\";\n readonly document: JsonObject;\n /** Every column the typed row serves; `updated` is not implied. */\n readonly columns: Required<Omit<TypedObjectColumns, \"type\">> &\n Partial<Pick<TypedObjectColumns, \"type\">>;\n readonly addressingOccurrences: readonly AddressingOccurrence[];\n readonly relations?: readonly RevisionRelationInput[];\n /** Embedded documents whose source is known, each path once. */\n readonly embeddings?: readonly RevisionEmbeddingInput[];\n readonly projection?: ResourceRevision[\"projection\"];\n /** As for {@link appendResourceRevision}. */\n readonly expansion?: RevisionExpansionInput;\n }\n | {\n readonly kind: \"whiteout\";\n readonly deleted: Temporal.Instant;\n readonly formerTypes: readonly string[];\n }\n );\n\nasync function sameTypedState(\n tx: Transaction,\n resourceId: Uuid,\n head: ResourceRevision,\n): Promise<boolean> {\n // Compare JSON text, as legacy capture does, rather than parsed values.\n const [row] = await tx\n .select({\n same: sql<boolean>`${objects.document}::text IS NOT DISTINCT FROM ${resourceRevisions.document}::text\n AND NOT EXISTS (\n (SELECT saved.property, saved.position, saved.iri\n FROM ${revisionAddressing} AS saved\n WHERE saved.revision_id = ${head.id})\n EXCEPT ALL\n (SELECT declared.property, declared.position, target.iri\n FROM ${addressingTable} AS declared\n JOIN ${resources} AS target ON target.id = declared.target_id\n WHERE declared.source_id = ${resourceId})\n )\n AND NOT EXISTS (\n (SELECT declared.property, declared.position, target.iri\n FROM ${addressingTable} AS declared\n JOIN ${resources} AS target ON target.id = declared.target_id\n WHERE declared.source_id = ${resourceId})\n EXCEPT ALL\n (SELECT saved.property, saved.position, saved.iri\n FROM ${revisionAddressing} AS saved\n WHERE saved.revision_id = ${head.id})\n )`,\n })\n .from(objects)\n .innerJoin(resourceRevisions, eq(resourceRevisions.id, head.id))\n .where(and(eq(objects.id, resourceId), isNull(objects.deleted)));\n return row?.same === true;\n}\n\n/**\n * Edits or deletes an object that has a legacy typed row, keeping the typed\n * row, its current addressing, and the revision history in step. Under the\n * canonical lock, the current revision must be the expected snapshot, and the\n * typed row's document and addressing must still equal it; otherwise nothing\n * changes. A snapshot sets the typed columns, the typed document to the same\n * JSON as the new revision, and the current addressing to the occurrences. A\n * whiteout soft-deletes the typed row and keeps its addressing, which\n * continues to describe the last content. The caller must validate and\n * authorize the change and check any served column against the old head.\n * The whole write runs in a savepoint, so a caught error leaves no part of it.\n * @returns The appended revision, including protected blind addressing.\n * @throws {RevisionConflictError} If the current revision is not the expected.\n * @throws {LegacyResourceRevisionError} If the resource has no live typed\n * object or the typed state differs from its current revision.\n * @throws {ResourceRevisionStateError} If the object is already deleted.\n */\nexport async function writeTypedResourceRevision(\n db: Database | Transaction,\n input: TypedResourceRevisionInput,\n): Promise<StoredResourceRevision> {\n const prepared = await expanded(\n prepareRevision(\n input.kind === \"snapshot\"\n ? {\n resourceId: input.resourceId,\n resourceKind: \"object\",\n expectedRevisionId: input.expectedRevisionId,\n kind: \"snapshot\",\n document: input.document,\n capture: \"local\",\n addressingOccurrences: input.addressingOccurrences,\n ...(input.relations === undefined\n ? {}\n : { relations: input.relations }),\n ...(input.embeddings === undefined\n ? {}\n : { embeddings: input.embeddings }),\n ...(input.projection === undefined\n ? {}\n : { projection: input.projection }),\n ...(input.expansion === undefined\n ? {}\n : { expansion: input.expansion }),\n }\n : {\n resourceId: input.resourceId,\n resourceKind: \"object\",\n expectedRevisionId: input.expectedRevisionId,\n kind: \"whiteout\",\n deleted: input.deleted,\n formerTypes: input.formerTypes,\n },\n ),\n );\n if (prepared.expectedRevisionId === null) {\n throw new TypeError(\"A typed object always has a current revision.\");\n }\n return await db.transaction(async (tx) => {\n const [resource] = await tx\n .select({ kind: resources.kind })\n .from(resources)\n .where(eq(resources.id, prepared.resourceId))\n .for(\"no key update\");\n const [typed] = await tx\n .select({ id: objects.id })\n .from(objects)\n .where(eq(objects.id, prepared.resourceId))\n .for(\"update\");\n if (resource?.kind !== \"object\" || typed === undefined) {\n throw new LegacyResourceRevisionError(prepared.resourceId);\n }\n const head = await current(tx, prepared.resourceId);\n if (\n head === null ||\n !areUuidsEqual(head.id, prepared.expectedRevisionId!)\n ) {\n throw new RevisionConflictError(\n prepared.resourceId,\n prepared.expectedRevisionId,\n head?.id ?? null,\n );\n }\n if (head.kind === \"whiteout\") {\n throw new ResourceRevisionStateError(\"deleted\");\n }\n if (\n head.kind !== \"snapshot\" ||\n !(await sameTypedState(tx, prepared.resourceId, head))\n ) {\n throw new LegacyResourceRevisionError(prepared.resourceId);\n }\n if (input.kind === \"snapshot\") {\n await tx\n .update(objects)\n .set({\n ...input.columns,\n // The edited document is local, not a copy fetched from its IRI.\n fetched: false,\n document: sql`${prepared.serialized}::json`,\n })\n .where(eq(objects.id, prepared.resourceId));\n await replaceAddressing(\n tx,\n prepared.resourceId,\n input.addressingOccurrences,\n );\n } else {\n // Keep the update hook from moving `updated` past the deletion.\n const [row] = await tx\n .select({ updated: objects.updated })\n .from(objects)\n .where(eq(objects.id, prepared.resourceId));\n await tx\n .update(objects)\n .set({ deleted: input.deleted, updated: row!.updated })\n .where(eq(objects.id, prepared.resourceId));\n }\n return await appendPrepared(tx, prepared, true);\n });\n}\n\nexport {\n type CaptureLegacyResourceRevisionOptions,\n captureLegacyResourceRevision,\n} from \"./legacy-resource-revision.ts\";\n"],"mappings":";;;;;;;AAeA,SAAS,SAAS,OAAyB;CACzC,MAAM,YAAqB,OAAO,eAAe,KAAK;CACtD,IACE,MAAM,QAAQ,KAAK,IACf,cAAc,MAAM,YACpB,cAAc,OAAO,aAAa,cAAc,MAEpD,MAAM,IAAI,UAAU,qCAAqC;CAE3D,MAAM,SAAmB,CAAC;CAC1B,KAAK,MAAM,OAAO,QAAQ,QAAQ,KAAK,GAAG;EACxC,MAAM,aAAa,OAAO,yBAAyB,OAAO,GAAG;EAC7D,IACE,OAAO,QAAQ,YACf,eAAe,KAAA,KACf,EAAE,WAAW,aAEb,MAAM,IAAI,UACR,sDACF;EAEF,IAAI,MAAM,QAAQ,KAAK,KAAK,QAAQ,UAAU;EAC9C,IAAI,CAAC,WAAW,YACd,MAAM,IAAI,UAAU,kCAAkC;EAExD,IACE,MAAM,QAAQ,KAAK,MAClB,CAAC,uBAAuB,KAAK,GAAG,KAAK,OAAO,GAAG,KAAK,MAAM,SAE3D,MAAM,I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3C,MAAM,IAAI,4BAA4B,SAAS,UAAU;EAE3D,MAAM,OAAO,MAAM,QAAQ,IAAI,SAAS,UAAU;EAClD,IACE,SAAS,QACT,CAAC,cAAc,KAAK,IAAI,SAAS,kBAAmB,GAEpD,MAAM,IAAI,sBACR,SAAS,YACT,SAAS,oBACT,MAAM,MAAM,IACd;EAEF,IAAI,KAAK,SAAS,YAChB,MAAM,IAAI,2BAA2B,SAAS;EAEhD,IACE,KAAK,SAAS,cACd,CAAE,MAAM,eAAe,IAAI,SAAS,YAAY,IAAI,GAEpD,MAAM,IAAI,4BAA4B,SAAS,UAAU;EAE3D,IAAI,MAAM,SAAS,YAAY;GAC7B,MAAM,GACH,OAAO,OAAO,CAAC,CACf,IAAI;IACH,GAAG,MAAM;IAET,SAAS;IACT,UAAU,GAAG,GAAG,SAAS,WAAW;GACtC,CAAC,CAAC,CACD,MAAM,GAAG,QAAQ,IAAI,SAAS,UAAU,CAAC;GAC5C,MAAM,kBACJ,IACA,SAAS,YACT,MAAM,qBACR;EACF,OAAO;GAEL,MAAM,CAAC,OAAO,MAAM,GACjB,OAAO,EAAE,SAAS,QAAQ,QAAQ,CAAC,CAAC,CACpC,KAAK,OAAO,CAAC,CACb,MAAM,GAAG,QAAQ,IAAI,SAAS,UAAU,CAAC;GAC5C,MAAM,GACH,OAAO,OAAO,CAAC,CACf,IAAI;IAAE,SAAS,MAAM;IAAS,SAAS,IAAK;GAAQ,CAAC,CAAC,CACtD,MAAM,GAAG,QAAQ,IAAI,SAAS,UAAU,CAAC;EAC9C;EACA,OAAO,MAAM,eAAe,IAAI,UAAU,IAAI;CAChD,CAAC;AACH"}
@@ -1,2 +1,2 @@
1
- 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";
2
- export { AppendResourceRevisionInput, JsonObject, JsonValue, LegacyResourceRevisionError, ResourceRevisionStateError, RevisionConflictError, RevisionEmbeddingInput, RevisionRelationInput, StoredResourceRevision, TypedObjectColumns, TypedResourceRevisionInput, appendResourceRevision, captureLegacyResourceRevision, listResourceRevisions, loadCurrentResourceRevision, loadResourceRevision, writeTypedResourceRevision };
1
+ 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";
2
+ export { AppendResourceRevisionInput, type CaptureLegacyResourceRevisionOptions, JsonObject, JsonValue, LegacyResourceRevisionError, ResourceRevisionStateError, RevisionConflictError, RevisionEmbeddingInput, type RevisionExpansionInput, RevisionRelationInput, StoredResourceRevision, TypedObjectColumns, TypedResourceRevisionInput, type UnexpandedRevision, appendResourceRevision, captureLegacyResourceRevision, findCarryingActivityRevision, listFailedRevisions, listResourceRevisions, listUnexpandedRevisions, loadCurrentResourceRevision, loadResourceRevision, loadRevisionExpansion, recordRevisionExpansion, retryRevisionExpansion, writeTypedResourceRevision };
@@ -1,3 +1,3 @@
1
1
  import "./resource.mjs";
2
2
  import "./text.mjs";
3
- export { l as LegacyResourceRevisionError, c as ResourceRevisionStateError, s as RevisionConflictError, t as appendResourceRevision, o as captureLegacyResourceRevision, n as listResourceRevisions, r as loadCurrentResourceRevision, i as loadResourceRevision, a as writeTypedResourceRevision } from "./resource-revision-bTQyJ7aw.mjs";
3
+ export { h as LegacyResourceRevisionError, m as ResourceRevisionStateError, p as RevisionConflictError, t as appendResourceRevision, s as captureLegacyResourceRevision, c as findCarryingActivityRevision, l as listFailedRevisions, n as listResourceRevisions, u as listUnexpandedRevisions, r as loadCurrentResourceRevision, i as loadResourceRevision, a as loadRevisionExpansion, d as recordRevisionExpansion, f as retryRevisionExpansion, o as writeTypedResourceRevision } from "./resource-revision-DGsz8fnS.mjs";
@@ -1,4 +1,4 @@
1
- import { G as Resource, b as CollectionRole, r as Transaction, t as Database, v as AddressingProperty } from "./db-CcbUSnp2.mjs";
1
+ import { K as Resource, b as CollectionRole, r as Transaction, t as Database, v as AddressingProperty } from "./db-Al_MT-L_.mjs";
2
2
  import { t as Uuid } from "./uuid-CKMzlIND.mjs";
3
3
  //#region src/resource.d.ts
4
4
  declare const PUBLIC_IRI = "https://www.w3.org/ns/activitystreams#Public";
package/dist/schema.d.mts CHANGED
@@ -1,2 +1,2 @@
1
- import { $ as StoredActivity, A as LoginChallenge, At as objects, B as NewLocalInstance, Bt as revisionEmbeddings, C as Key, Ct as keys, D as LocalActorKey, Dt as localInstances, E as LocalActor, Et as localActors, F as NewActor, Ft as resourceRevisionProjectionEnum, G as Resource, H as NewResourceRevision, Ht as revisionReceipts, I as NewInstance, It as resourceRevisions, J as RevisionAddressing, K as ResourceHead, Kt as sessions, L as NewInstanceMember, Lt as resources, M as NewActivityDelivery, Mt as resourceKindEnum, N as NewActivityDeliveryActor, Nt as resourceRevisionCaptureEnum, O as LocalActorKeyType, Ot as loginChallenges, P as NewActivityPubObject, Pt as resourceRevisionKindEnum, Q as Session, R as NewLocalActor, Rt as revisionAddressing, S as InstanceMember, St as keyVersions, T as LOGIN_CHALLENGE_CODE_LENGTH, Tt as localActorKeys, U as NewSession, Ut as revisionRelationRepresentationEnum, V as NewLoginChallenge, Vt as revisionReceiptRoleEnum, W as ObjectType, Wt as revisionRelations, X as RevisionReceipt, Y as RevisionEmbedding, Z as RevisionRelation, _ as Addressing, _t as collectionRoleEnum, a as Account, at as activityDeliveryAttempts, b as CollectionRole, bt as instanceMembers, c as ActivityDeliveryActorCollection, ct as activityDeliveryVerificationMechanismEnum, d as ActivityDeliveryStatus, dt as actorCollectionReferences, et as accounts, f as ActivityDeliveryVerificationMechanism, ft as actorTypeEnum, g as ActorType, gt as collectionItems, h as Actor, ht as addressingPropertyEnum, it as activityDeliveryActors, j as NewAccount, jt as resourceHeads, k as LocalInstance, kt as objectTypeEnum, l as ActivityDeliveryAttempt, lt as activityDeliveryVerificationResultEnum, m as ActivityPubObject, mt as addressing, nt as activityDeliveries, o as ActivityDelivery, ot as activityDeliveryDirectionEnum, p as ActivityDeliveryVerificationResult, pt as actors, q as ResourceRevision, rt as activityDeliveryActorCollections, s as ActivityDeliveryActor, st as activityDeliveryStatusEnum, tt as activities, u as ActivityDeliveryDirection, ut as activityTypeEnum, v as AddressingProperty, vt as collectionTypeEnum, w as KeyVersion, wt as localActorKeyTypeEnum, x as Instance, xt as instances, y as Collection, yt as collections, z as NewLocalActorKey, zt as revisionEmbeddingRelationEnum } from "./db-CcbUSnp2.mjs";
2
- export { Account, ActivityDelivery, ActivityDeliveryActor, ActivityDeliveryActorCollection, ActivityDeliveryAttempt, ActivityDeliveryDirection, ActivityDeliveryStatus, ActivityDeliveryVerificationMechanism, ActivityDeliveryVerificationResult, ActivityPubObject, Actor, ActorType, Addressing, AddressingProperty, Collection, CollectionRole, Instance, InstanceMember, Key, KeyVersion, LOGIN_CHALLENGE_CODE_LENGTH, LocalActor, LocalActorKey, LocalActorKeyType, LocalInstance, LoginChallenge, NewAccount, NewActivityDelivery, NewActivityDeliveryActor, NewActivityPubObject, NewActor, NewInstance, NewInstanceMember, NewLocalActor, NewLocalActorKey, NewLocalInstance, NewLoginChallenge, NewResourceRevision, NewSession, ObjectType, Resource, ResourceHead, ResourceRevision, RevisionAddressing, RevisionEmbedding, RevisionReceipt, RevisionRelation, Session, StoredActivity, accounts, activities, activityDeliveries, activityDeliveryActorCollections, activityDeliveryActors, activityDeliveryAttempts, activityDeliveryDirectionEnum, activityDeliveryStatusEnum, activityDeliveryVerificationMechanismEnum, activityDeliveryVerificationResultEnum, activityTypeEnum, actorCollectionReferences, actorTypeEnum, actors, addressing, addressingPropertyEnum, collectionItems, collectionRoleEnum, collectionTypeEnum, collections, instanceMembers, instances, keyVersions, keys, localActorKeyTypeEnum, localActorKeys, localActors, localInstances, loginChallenges, objectTypeEnum, objects, resourceHeads, resourceKindEnum, resourceRevisionCaptureEnum, resourceRevisionKindEnum, resourceRevisionProjectionEnum, resourceRevisions, resources, revisionAddressing, revisionEmbeddingRelationEnum, revisionEmbeddings, revisionReceiptRoleEnum, revisionReceipts, revisionRelationRepresentationEnum, revisionRelations, sessions };
1
+ import { $ as RevisionRelation, A as LoginChallenge, At as loginChallenges, B as NewLocalInstance, Bt as revisionAddressing, C as Key, Ct as instances, D as LocalActorKey, Dt as localActorKeys, E as LocalActor, Et as localActorKeyTypeEnum, F as NewActor, Ft as resourceRevisionCaptureEnum, G as ObjectType, Gt as revisionReceiptRoleEnum, H as NewResourceRevision, Ht as revisionEmbeddings, I as NewInstance, It as resourceRevisionKindEnum, J as ResourceRevision, Jt as revisionRelations, K as Resource, Kt as revisionReceipts, L as NewInstanceMember, Lt as resourceRevisionProjectionEnum, M as NewActivityDelivery, Mt as objects, N as NewActivityDeliveryActor, Nt as resourceHeads, O as LocalActorKeyType, Ot as localActors, P as NewActivityPubObject, Pt as resourceKindEnum, Q as RevisionReceipt, R as NewLocalActor, Rt as resourceRevisions, S as InstanceMember, St as instanceMembers, T as LOGIN_CHALLENGE_CODE_LENGTH, Tt as keys, U as NewRevisionExpansion, Ut as revisionExpansionOutcomeEnum, V as NewLoginChallenge, Vt as revisionEmbeddingRelationEnum, W as NewSession, Wt as revisionExpansions, X as RevisionEmbedding, Xt as sessions, Y as RevisionAddressing, Z as RevisionExpansion, _ as Addressing, _t as addressingPropertyEnum, a as Account, at as activityDeliveryActorCollections, b as CollectionRole, bt as collectionTypeEnum, c as ActivityDeliveryActorCollection, ct as activityDeliveryDirectionEnum, d as ActivityDeliveryStatus, dt as activityDeliveryVerificationResultEnum, et as Session, f as ActivityDeliveryVerificationMechanism, ft as activityTypeEnum, g as ActorType, gt as addressing, h as Actor, ht as actors, it as activityDeliveries, j as NewAccount, jt as objectTypeEnum, k as LocalInstance, kt as localInstances, l as ActivityDeliveryAttempt, lt as activityDeliveryStatusEnum, m as ActivityPubObject, mt as actorTypeEnum, nt as accounts, o as ActivityDelivery, ot as activityDeliveryActors, p as ActivityDeliveryVerificationResult, pt as actorCollectionReferences, q as ResourceHead, qt as revisionRelationRepresentationEnum, rt as activities, s as ActivityDeliveryActor, st as activityDeliveryAttempts, tt as StoredActivity, u as ActivityDeliveryDirection, ut as activityDeliveryVerificationMechanismEnum, v as AddressingProperty, vt as collectionItems, w as KeyVersion, wt as keyVersions, x as Instance, xt as collections, y as Collection, yt as collectionRoleEnum, z as NewLocalActorKey, zt as resources } from "./db-Al_MT-L_.mjs";
2
+ export { Account, ActivityDelivery, ActivityDeliveryActor, ActivityDeliveryActorCollection, ActivityDeliveryAttempt, ActivityDeliveryDirection, ActivityDeliveryStatus, ActivityDeliveryVerificationMechanism, ActivityDeliveryVerificationResult, ActivityPubObject, Actor, ActorType, Addressing, AddressingProperty, Collection, CollectionRole, Instance, InstanceMember, Key, KeyVersion, LOGIN_CHALLENGE_CODE_LENGTH, LocalActor, LocalActorKey, LocalActorKeyType, LocalInstance, LoginChallenge, NewAccount, NewActivityDelivery, NewActivityDeliveryActor, NewActivityPubObject, NewActor, NewInstance, NewInstanceMember, NewLocalActor, NewLocalActorKey, NewLocalInstance, NewLoginChallenge, NewResourceRevision, NewRevisionExpansion, NewSession, ObjectType, Resource, ResourceHead, ResourceRevision, RevisionAddressing, RevisionEmbedding, RevisionExpansion, RevisionReceipt, RevisionRelation, Session, StoredActivity, accounts, activities, activityDeliveries, activityDeliveryActorCollections, activityDeliveryActors, activityDeliveryAttempts, activityDeliveryDirectionEnum, activityDeliveryStatusEnum, activityDeliveryVerificationMechanismEnum, activityDeliveryVerificationResultEnum, activityTypeEnum, actorCollectionReferences, actorTypeEnum, actors, addressing, addressingPropertyEnum, collectionItems, collectionRoleEnum, collectionTypeEnum, collections, instanceMembers, instances, keyVersions, keys, localActorKeyTypeEnum, localActorKeys, localActors, localInstances, loginChallenges, objectTypeEnum, objects, resourceHeads, resourceKindEnum, resourceRevisionCaptureEnum, resourceRevisionKindEnum, resourceRevisionProjectionEnum, resourceRevisions, resources, revisionAddressing, revisionEmbeddingRelationEnum, revisionEmbeddings, revisionExpansionOutcomeEnum, revisionExpansions, revisionReceiptRoleEnum, revisionReceipts, revisionRelationRepresentationEnum, revisionRelations, sessions };
package/dist/schema.mjs CHANGED
@@ -45,6 +45,8 @@ var schema_exports = /* @__PURE__ */ __exportAll({
45
45
  revisionAddressing: () => revisionAddressing,
46
46
  revisionEmbeddingRelationEnum: () => revisionEmbeddingRelationEnum,
47
47
  revisionEmbeddings: () => revisionEmbeddings,
48
+ revisionExpansionOutcomeEnum: () => revisionExpansionOutcomeEnum,
49
+ revisionExpansions: () => revisionExpansions,
48
50
  revisionReceiptRoleEnum: () => revisionReceiptRoleEnum,
49
51
  revisionReceipts: () => revisionReceipts,
50
52
  revisionRelationRepresentationEnum: () => revisionRelationRepresentationEnum,
@@ -603,6 +605,58 @@ const revisionEmbeddings = pgTable("revision_embeddings", {
603
605
  check("revision_embeddings_source_check", sql`${t.sourceRevisionId} <> ${t.revisionId}`),
604
606
  index("revision_embeddings_source_index").on(t.sourceRevisionId)
605
607
  ]);
608
+ const revisionExpansionOutcomeEnum = pgEnum("revision_expansion_outcome", [
609
+ "expanded",
610
+ "failed",
611
+ "no_document"
612
+ ]);
613
+ /**
614
+ * The JSON-LD expanded form of a revision's document, written with the
615
+ * revision. Unlike the other revision projections, rows are derived data: an
616
+ * incorrect expansion is a bug, fixed by recomputing the rows of the affected
617
+ * revisions, so the table has no immutability guard. A revision without a row
618
+ * has not been expanded yet. An object embedded in a received activity is
619
+ * expanded from that activity's document, recorded as `sourceRevisionId`.
620
+ *
621
+ * Unlike revision documents, expanded documents are `jsonb` so that they can
622
+ * be indexed and queried with containment. Being derived, they are stored
623
+ * normalized: U+0000 and unpaired surrogates in strings and keys become
624
+ * U+FFFD, and negative zero becomes zero. The stored document holds the exact
625
+ * values.
626
+ */
627
+ const revisionExpansions = pgTable("revision_expansions", {
628
+ revisionId: uuid("revision_id").$type().primaryKey().references(() => resourceRevisions.id, { onDelete: "restrict" }),
629
+ outcome: revisionExpansionOutcomeEnum().notNull(),
630
+ document: jsonb().$type(),
631
+ droppedTerms: text("dropped_terms").array(),
632
+ undefinedTerms: text("undefined_terms").array(),
633
+ failure: text(),
634
+ sourceRevisionId: uuid("source_revision_id").$type()
635
+ }, (t) => [
636
+ foreignKey({
637
+ name: "revision_expansions_source_revision_fkey",
638
+ columns: [t.sourceRevisionId],
639
+ foreignColumns: [resourceRevisions.id]
640
+ }).onDelete("restrict"),
641
+ check("revision_expansions_outcome_check", sql`(${t.outcome} = 'expanded'
642
+ AND ${t.document} IS NOT NULL
643
+ AND ${t.droppedTerms} IS NOT NULL
644
+ AND ${t.undefinedTerms} IS NOT NULL
645
+ AND ${t.failure} IS NULL)
646
+ OR (${t.outcome} = 'failed'
647
+ AND ${t.document} IS NULL
648
+ AND ${t.droppedTerms} IS NULL
649
+ AND ${t.undefinedTerms} IS NULL
650
+ AND ${t.failure} IS NOT NULL)
651
+ OR (${t.outcome} = 'no_document'
652
+ AND ${t.document} IS NULL
653
+ AND ${t.droppedTerms} IS NULL
654
+ AND ${t.undefinedTerms} IS NULL
655
+ AND ${t.failure} IS NULL
656
+ AND ${t.sourceRevisionId} IS NULL)`),
657
+ check("revision_expansions_source_check", sql`${t.sourceRevisionId} <> ${t.revisionId}`),
658
+ index("revision_expansions_source_index").on(t.sourceRevisionId)
659
+ ]);
606
660
  const revisionReceiptRoleEnum = pgEnum("revision_receipt_role", ["activity", "object"]);
607
661
  /** Mutable index of delivery evidence, not part of immutable document history. */
608
662
  const revisionReceipts = pgTable("revision_receipts", {
@@ -615,6 +669,6 @@ const revisionReceipts = pgTable("revision_receipts", {
615
669
  t.role
616
670
  ] }), index("revision_receipts_revision_index").on(t.revisionId)]);
617
671
  //#endregion
618
- export { LOGIN_CHALLENGE_CODE_LENGTH, accounts, activities, activityDeliveries, activityDeliveryActorCollections, activityDeliveryActors, activityDeliveryAttempts, activityDeliveryDirectionEnum, activityDeliveryStatusEnum, activityDeliveryVerificationMechanismEnum, activityDeliveryVerificationResultEnum, activityTypeEnum, actorCollectionReferences, actorTypeEnum, actors, addressing, addressingPropertyEnum, collectionItems, collectionRoleEnum, collectionTypeEnum, collections, instanceMembers, instances, keyVersions, keys, localActorKeyTypeEnum, localActorKeys, localActors, localInstances, loginChallenges, objectTypeEnum, objects, resourceHeads, resourceKindEnum, resourceRevisionCaptureEnum, resourceRevisionKindEnum, resourceRevisionProjectionEnum, resourceRevisions, resources, revisionAddressing, revisionEmbeddingRelationEnum, revisionEmbeddings, revisionReceiptRoleEnum, revisionReceipts, revisionRelationRepresentationEnum, revisionRelations, sessions, schema_exports as t };
672
+ export { LOGIN_CHALLENGE_CODE_LENGTH, accounts, activities, activityDeliveries, activityDeliveryActorCollections, activityDeliveryActors, activityDeliveryAttempts, activityDeliveryDirectionEnum, activityDeliveryStatusEnum, activityDeliveryVerificationMechanismEnum, activityDeliveryVerificationResultEnum, activityTypeEnum, actorCollectionReferences, actorTypeEnum, actors, addressing, addressingPropertyEnum, collectionItems, collectionRoleEnum, collectionTypeEnum, collections, instanceMembers, instances, keyVersions, keys, localActorKeyTypeEnum, localActorKeys, localActors, localInstances, loginChallenges, objectTypeEnum, objects, resourceHeads, resourceKindEnum, resourceRevisionCaptureEnum, resourceRevisionKindEnum, resourceRevisionProjectionEnum, resourceRevisions, resources, revisionAddressing, revisionEmbeddingRelationEnum, revisionEmbeddings, revisionExpansionOutcomeEnum, revisionExpansions, revisionReceiptRoleEnum, revisionReceipts, revisionRelationRepresentationEnum, revisionRelations, sessions, schema_exports as t };
619
673
 
620
674
  //# sourceMappingURL=schema.mjs.map