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

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 (37) hide show
  1. package/dist/activity-delivery.d.mts +1 -1
  2. package/dist/{db-BBw4F4HU.d.mts → db-CcbUSnp2.d.mts} +84 -3
  3. package/dist/{db-BBw4F4HU.d.mts.map → db-CcbUSnp2.d.mts.map} +1 -1
  4. package/dist/db.d.mts +1 -1
  5. package/dist/document.d.mts +10 -0
  6. package/dist/document.d.mts.map +1 -1
  7. package/dist/document.mjs +6 -1
  8. package/dist/document.mjs.map +1 -1
  9. package/dist/index.d.mts +4 -4
  10. package/dist/index.mjs +3 -3
  11. package/dist/instance.d.mts +1 -1
  12. package/dist/key.d.mts +1 -1
  13. package/dist/login.d.mts +8 -2
  14. package/dist/login.d.mts.map +1 -1
  15. package/dist/login.mjs +8 -1
  16. package/dist/login.mjs.map +1 -1
  17. package/dist/migrations-manifest.json +8 -0
  18. package/dist/relations.d.mts +1 -1
  19. package/dist/relations.mjs +19 -2
  20. package/dist/relations.mjs.map +1 -1
  21. package/dist/{resource-revision-iQ8HZ699.mjs → resource-revision-bTQyJ7aw.mjs} +28 -3
  22. package/dist/resource-revision-bTQyJ7aw.mjs.map +1 -0
  23. package/dist/{resource-revision-BauDwFIn.d.mts → resource-revision-rDmHhNCj.d.mts} +19 -3
  24. package/dist/resource-revision-rDmHhNCj.d.mts.map +1 -0
  25. package/dist/resource-revision.d.mts +2 -2
  26. package/dist/resource-revision.mjs +1 -1
  27. package/dist/resource.d.mts +1 -1
  28. package/dist/schema.d.mts +2 -2
  29. package/dist/schema.mjs +27 -1
  30. package/dist/schema.mjs.map +1 -1
  31. package/drizzle/20261113080536_revision_embeddings/migration.sql +14 -0
  32. package/drizzle/20261113080536_revision_embeddings/snapshot.json +4634 -0
  33. package/drizzle/20261113080537_guard_revision_embeddings/migration.sql +42 -0
  34. package/drizzle/20261113080537_guard_revision_embeddings/snapshot.json +4634 -0
  35. package/package.json +6 -6
  36. package/dist/resource-revision-BauDwFIn.d.mts.map +0 -1
  37. package/dist/resource-revision-iQ8HZ699.mjs.map +0 -1
package/dist/index.d.mts CHANGED
@@ -1,8 +1,8 @@
1
- import { Gt as jwkThumbprint, Ht as schema_d_exports, Jt as toPublicJwk, Kt as observeKeyVersion, Wt as PublicJwk, i as relations, n as RelationsFilter, qt as thumbprintInput, r as Transaction, t as Database } from "./db-BBw4F4HU.mjs";
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";
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";
5
- import { LoginChallengeConsumptionError, LoginChallengeError, LoginChallengeNotFoundError, consumeLoginChallenge, findLoginChallenge } from "./login.mjs";
5
+ import { LoginChallengeConsumptionError, LoginChallengeError, LoginChallengeNotFoundError, consumeLoginChallenge, findLoginChallenge, generateLoginChallengeCode } from "./login.mjs";
6
6
  import { AddressingInput, AddressingOccurrence, PUBLIC_IRI, PUBLIC_RESOURCE_ID, ResourceKindConflictError, addActorCollectionItem, checkAddressingOccurrences, ensureResource, lockActorCollection, lockResources, promoteResource, replaceAddressing, storeAddressing, storeAddressingOccurrences } from "./resource.mjs";
7
7
  import { ensureRemoteInstance } from "./instance.mjs";
8
8
  import { storableText } from "./text.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 { a as StoredResourceRevision, c as appendResourceRevision, d as loadResourceRevision, f as writeTypedResourceRevision, g as RevisionConflictError, h as LegacyResourceRevisionError, i as RevisionRelationInput, l as listResourceRevisions, m as ResourceRevisionStateError, n as JsonObject, o as TypedObjectColumns, p as captureLegacyResourceRevision, r as JsonValue, s as TypedResourceRevisionInput, t as AppendResourceRevisionInput, u as loadCurrentResourceRevision } from "./resource-revision-BauDwFIn.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, RevisionRelationInput, StoredResourceRevision, Transaction, TypedObjectColumns, TypedResourceRevisionInput, addActorCollectionItem, appendResourceRevision, assertMigrationManifestPrefix, captureLegacyResourceRevision, checkAddressingOccurrences, classifyMigrationHistory, consumeLoginChallenge, ensureRemoteInstance, ensureResource, findLoginChallenge, 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 { _ 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 };
package/dist/index.mjs CHANGED
@@ -3,7 +3,7 @@ import { t as schema_exports } from "./schema.mjs";
3
3
  import relations from "./relations.mjs";
4
4
  import "./db.mjs";
5
5
  import { migrate } from "./migrate.mjs";
6
- import { LoginChallengeConsumptionError, LoginChallengeError, LoginChallengeNotFoundError, consumeLoginChallenge, findLoginChallenge } from "./login.mjs";
6
+ import { LoginChallengeConsumptionError, LoginChallengeError, LoginChallengeNotFoundError, consumeLoginChallenge, findLoginChallenge, generateLoginChallengeCode } from "./login.mjs";
7
7
  import { PUBLIC_IRI, PUBLIC_RESOURCE_ID, ResourceKindConflictError, addActorCollectionItem, checkAddressingOccurrences, ensureResource, lockActorCollection, lockResources, promoteResource, replaceAddressing, storeAddressing, storeAddressingOccurrences } from "./resource.mjs";
8
8
  import { jwkThumbprint, observeKeyVersion, thumbprintInput, toPublicJwk } from "./key.mjs";
9
9
  import { storableText } from "./text.mjs";
@@ -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-iQ8HZ699.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, 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 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 };
@@ -1,4 +1,4 @@
1
- import { r as Transaction, t as Database, x as Instance } from "./db-BBw4F4HU.mjs";
1
+ import { r as Transaction, t as Database, x as Instance } from "./db-CcbUSnp2.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 { Gt as jwkThumbprint, Jt as toPublicJwk, Kt as observeKeyVersion, Wt as PublicJwk, qt as thumbprintInput } from "./db-BBw4F4HU.mjs";
1
+ import { Jt as jwkThumbprint, Xt as thumbprintInput, Yt as observeKeyVersion, Zt as toPublicJwk, qt as PublicJwk } from "./db-CcbUSnp2.mjs";
2
2
  export { PublicJwk, jwkThumbprint, observeKeyVersion, thumbprintInput, toPublicJwk };
package/dist/login.d.mts CHANGED
@@ -1,7 +1,13 @@
1
- import { A as LoginChallenge, r as Transaction, t as Database } from "./db-BBw4F4HU.mjs";
1
+ import { A as LoginChallenge, r as Transaction, t as Database } from "./db-CcbUSnp2.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
5
+ /**
6
+ * Generates the plaintext code of a login challenge: lowercase base-36
7
+ * characters of {@link LOGIN_CHALLENGE_CODE_LENGTH}.
8
+ * @returns A random login challenge code.
9
+ */
10
+ declare const generateLoginChallengeCode: () => string;
5
11
  /**
6
12
  * An error that occurs when a login challenge operation fails.
7
13
  */
@@ -45,5 +51,5 @@ declare class LoginChallengeConsumptionError extends LoginChallengeError {
45
51
  */
46
52
  declare function consumeLoginChallenge(db: Database | Transaction, id: Uuid, now?: Temporal.Instant | SQL): Promise<void>;
47
53
  //#endregion
48
- export { LoginChallengeConsumptionError, LoginChallengeError, LoginChallengeNotFoundError, consumeLoginChallenge, findLoginChallenge };
54
+ export { LoginChallengeConsumptionError, LoginChallengeError, LoginChallengeNotFoundError, consumeLoginChallenge, findLoginChallenge, generateLoginChallengeCode };
49
55
  //# sourceMappingURL=login.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"login.d.mts","names":[],"sources":["../src/login.ts"],"mappings":";;;;;;;cA0Ba,4BAA4B;EACvC,YAAY;;;;;cASD,oCAAoC;EAC/C,YAAY;;;;;;;;;;;;;;;iBAmBQ,mBACpB,IAAI,WAAW,aACf,IAAI,MACJ,MAAM,SAAS,UAAU,MACxB,QAAQ;;;;cAqBE,uCAAuC;EAClD,YAAY;;;;;;;;;;;iBAeQ,sBACpB,IAAI,WAAW,aACf,IAAI,MACJ,MAAM,SAAS,UAAU,MACxB"}
1
+ {"version":3,"file":"login.d.mts","names":[],"sources":["../src/login.ts"],"mappings":";;;;;;;;;cAkCa;;;;cAaA,4BAA4B;EACvC,YAAY;;;;;cASD,oCAAoC;EAC/C,YAAY;;;;;;;;;;;;;;;iBAmBQ,mBACpB,IAAI,WAAW,aACf,IAAI,MACJ,MAAM,SAAS,UAAU,MACxB,QAAQ;;;;cAqBE,uCAAuC;EAClD,YAAY;;;;;;;;;;;iBAeQ,sBACpB,IAAI,WAAW,aACf,IAAI,MACJ,MAAM,SAAS,UAAU,MACxB"}
package/dist/login.mjs CHANGED
@@ -1,6 +1,13 @@
1
1
  import { loginChallenges } from "./schema.mjs";
2
2
  import { and, eq, gt, isNull, sql } from "drizzle-orm/sql";
3
3
  //#region src/login.ts
4
+ const LOGIN_CHALLENGE_CODE_ALPHABET = "0123456789abcdefghijklmnopqrstuvwxyz";
5
+ /**
6
+ * Generates the plaintext code of a login challenge: lowercase base-36
7
+ * characters of {@link LOGIN_CHALLENGE_CODE_LENGTH}.
8
+ * @returns A random login challenge code.
9
+ */
10
+ const generateLoginChallengeCode = () => Array.from(crypto.getRandomValues(/* @__PURE__ */ new Uint16Array(6)), (num) => LOGIN_CHALLENGE_CODE_ALPHABET[num % 36]).join("");
4
11
  /**
5
12
  * An error that occurs when a login challenge operation fails.
6
13
  */
@@ -66,6 +73,6 @@ async function consumeLoginChallenge(db, id, now) {
66
73
  if (result.length < 1 || result[0]?.consumed == null) throw new LoginChallengeConsumptionError("Login challenge not found or already consumed.");
67
74
  }
68
75
  //#endregion
69
- export { LoginChallengeConsumptionError, LoginChallengeError, LoginChallengeNotFoundError, consumeLoginChallenge, findLoginChallenge };
76
+ export { LoginChallengeConsumptionError, LoginChallengeError, LoginChallengeNotFoundError, consumeLoginChallenge, findLoginChallenge, generateLoginChallengeCode };
70
77
 
71
78
  //# sourceMappingURL=login.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"login.mjs","names":[],"sources":["../src/login.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/>.\n// oxlint-disable max-classes-per-file -- Keep the related challenge errors together.\n\nimport { type SQL, and, eq, gt, isNull, sql } from \"drizzle-orm/sql\";\n\nimport type { Database, Transaction } from \"./db.ts\";\nimport { type LoginChallenge, loginChallenges } from \"./schema.ts\";\nimport type { Uuid } from \"./uuid.ts\";\n\n/**\n * An error that occurs when a login challenge operation fails.\n */\nexport class LoginChallengeError extends Error {\n constructor(message: string) {\n super(message);\n this.name = \"LoginChallengeError\";\n }\n}\n\n/**\n * An error that occurs when a login challenge is not found.\n */\nexport class LoginChallengeNotFoundError extends LoginChallengeError {\n constructor(message: string) {\n super(message);\n this.name = \"LoginChallengeNotFoundError\";\n }\n}\n\n/**\n * Finds a login challenge by its ID, ensuring that it has not been consumed\n * and has not expired. If the login challenge is not found, it throws a\n * {@link LoginChallengeNotFoundError}.\n * @param db The {@link Database} instance to use for the operation.\n * It can be a {@link Transaction} as well.\n * @param id The UUID of the login challenge to find.\n * @param now An optional timestamp to use for checking expiration.\n * If not provided, the current timestamp will be used.\n * @returns A promise that resolves to the found {@link LoginChallenge}.\n * @throws {LoginChallengeNotFoundError} if the login challenge is not found\n * or has been consumed or expired.\n */\nexport async function findLoginChallenge(\n db: Database | Transaction,\n id: Uuid,\n now?: Temporal.Instant | SQL,\n): Promise<LoginChallenge> {\n // oxlint-disable-next-line no-param-reassign\n now ??= sql`CURRENT_TIMESTAMP`;\n const result = await db.query.loginChallenges.findFirst({\n where: {\n id,\n consumed: { isNull: true },\n ...(now instanceof Temporal.Instant\n ? { expires: { gt: now } }\n : { RAW: (t) => sql`${t.expires} > ${now}` }),\n },\n });\n if (result == null) {\n throw new LoginChallengeNotFoundError(\"Login challenge not found.\");\n }\n return result;\n}\n\n/**\n * An error that occurs when consuming a login challenge fails.\n */\nexport class LoginChallengeConsumptionError extends LoginChallengeError {\n constructor(message: string) {\n super(message);\n this.name = \"LoginChallengeConsumptionError\";\n }\n}\n\n/**\n * Consumes a login challenge by setting its `consumed` timestamp to\n * the current time.\n * @param db The {@link Database} instance to use for the operation.\n * It can be a {@link Transaction} as well.\n * @param id The UUID of the login challenge to consume.\n * @param now An optional timestamp to set as the `consumed` time.\n * If not provided, the current timestamp will be used.\n */\nexport async function consumeLoginChallenge(\n db: Database | Transaction,\n id: Uuid,\n now?: Temporal.Instant | SQL,\n): Promise<void> {\n // oxlint-disable-next-line no-param-reassign\n now ??= sql`CURRENT_TIMESTAMP`;\n const result = await db\n .update(loginChallenges)\n .set({ consumed: now })\n .where(\n and(\n eq(loginChallenges.id, id),\n isNull(loginChallenges.consumed),\n gt(loginChallenges.expires, now),\n ),\n )\n .returning({ consumed: loginChallenges.consumed });\n if (result.length < 1 || result[0]?.consumed == null) {\n throw new LoginChallengeConsumptionError(\n \"Login challenge not found or already consumed.\",\n );\n }\n}\n"],"mappings":";;;;;;AA0BA,IAAa,sBAAb,cAAyC,MAAM;CAC7C,YAAY,SAAiB;EAC3B,MAAM,OAAO;EACb,KAAK,OAAO;CACd;AACF;;;;AAKA,IAAa,8BAAb,cAAiD,oBAAoB;CACnE,YAAY,SAAiB;EAC3B,MAAM,OAAO;EACb,KAAK,OAAO;CACd;AACF;;;;;;;;;;;;;;AAeA,eAAsB,mBACpB,IACA,IACA,KACyB;CAEzB,QAAQ,GAAG;CACX,MAAM,SAAS,MAAM,GAAG,MAAM,gBAAgB,UAAU,EACtD,OAAO;EACL;EACA,UAAU,EAAE,QAAQ,KAAK;EACzB,GAAI,eAAe,SAAS,UACxB,EAAE,SAAS,EAAE,IAAI,IAAI,EAAE,IACvB,EAAE,MAAM,MAAM,GAAG,GAAG,EAAE,QAAQ,KAAK,MAAM;CAC/C,EACF,CAAC;CACD,IAAI,UAAU,MACZ,MAAM,IAAI,4BAA4B,4BAA4B;CAEpE,OAAO;AACT;;;;AAKA,IAAa,iCAAb,cAAoD,oBAAoB;CACtE,YAAY,SAAiB;EAC3B,MAAM,OAAO;EACb,KAAK,OAAO;CACd;AACF;;;;;;;;;;AAWA,eAAsB,sBACpB,IACA,IACA,KACe;CAEf,QAAQ,GAAG;CACX,MAAM,SAAS,MAAM,GAClB,OAAO,eAAe,CAAC,CACvB,IAAI,EAAE,UAAU,IAAI,CAAC,CAAC,CACtB,MACC,IACE,GAAG,gBAAgB,IAAI,EAAE,GACzB,OAAO,gBAAgB,QAAQ,GAC/B,GAAG,gBAAgB,SAAS,GAAG,CACjC,CACF,CAAC,CACA,UAAU,EAAE,UAAU,gBAAgB,SAAS,CAAC;CACnD,IAAI,OAAO,SAAS,KAAK,OAAO,EAAE,EAAE,YAAY,MAC9C,MAAM,IAAI,+BACR,gDACF;AAEJ"}
1
+ {"version":3,"file":"login.mjs","names":[],"sources":["../src/login.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/>.\n// oxlint-disable max-classes-per-file -- Keep the related challenge errors together.\n\nimport { type SQL, and, eq, gt, isNull, sql } from \"drizzle-orm/sql\";\n\nimport type { Database, Transaction } from \"./db.ts\";\nimport {\n LOGIN_CHALLENGE_CODE_LENGTH,\n type LoginChallenge,\n loginChallenges,\n} from \"./schema.ts\";\nimport type { Uuid } from \"./uuid.ts\";\n\nconst LOGIN_CHALLENGE_CODE_ALPHABET = \"0123456789abcdefghijklmnopqrstuvwxyz\";\n\n/**\n * Generates the plaintext code of a login challenge: lowercase base-36\n * characters of {@link LOGIN_CHALLENGE_CODE_LENGTH}.\n * @returns A random login challenge code.\n */\nexport const generateLoginChallengeCode = (): string =>\n Array.from(\n // `Uint16Array` keeps the modulo bias small, since `2 ** 16 % 36 = 16`\n // while `2 ** 8 % 36 = 2 ** 32 % 36 = 4`. It is not strictly uniform,\n // but the bias is negligible.\n crypto.getRandomValues(new Uint16Array(LOGIN_CHALLENGE_CODE_LENGTH)),\n (num) =>\n LOGIN_CHALLENGE_CODE_ALPHABET[num % LOGIN_CHALLENGE_CODE_ALPHABET.length],\n ).join(\"\");\n\n/**\n * An error that occurs when a login challenge operation fails.\n */\nexport class LoginChallengeError extends Error {\n constructor(message: string) {\n super(message);\n this.name = \"LoginChallengeError\";\n }\n}\n\n/**\n * An error that occurs when a login challenge is not found.\n */\nexport class LoginChallengeNotFoundError extends LoginChallengeError {\n constructor(message: string) {\n super(message);\n this.name = \"LoginChallengeNotFoundError\";\n }\n}\n\n/**\n * Finds a login challenge by its ID, ensuring that it has not been consumed\n * and has not expired. If the login challenge is not found, it throws a\n * {@link LoginChallengeNotFoundError}.\n * @param db The {@link Database} instance to use for the operation.\n * It can be a {@link Transaction} as well.\n * @param id The UUID of the login challenge to find.\n * @param now An optional timestamp to use for checking expiration.\n * If not provided, the current timestamp will be used.\n * @returns A promise that resolves to the found {@link LoginChallenge}.\n * @throws {LoginChallengeNotFoundError} if the login challenge is not found\n * or has been consumed or expired.\n */\nexport async function findLoginChallenge(\n db: Database | Transaction,\n id: Uuid,\n now?: Temporal.Instant | SQL,\n): Promise<LoginChallenge> {\n // oxlint-disable-next-line no-param-reassign\n now ??= sql`CURRENT_TIMESTAMP`;\n const result = await db.query.loginChallenges.findFirst({\n where: {\n id,\n consumed: { isNull: true },\n ...(now instanceof Temporal.Instant\n ? { expires: { gt: now } }\n : { RAW: (t) => sql`${t.expires} > ${now}` }),\n },\n });\n if (result == null) {\n throw new LoginChallengeNotFoundError(\"Login challenge not found.\");\n }\n return result;\n}\n\n/**\n * An error that occurs when consuming a login challenge fails.\n */\nexport class LoginChallengeConsumptionError extends LoginChallengeError {\n constructor(message: string) {\n super(message);\n this.name = \"LoginChallengeConsumptionError\";\n }\n}\n\n/**\n * Consumes a login challenge by setting its `consumed` timestamp to\n * the current time.\n * @param db The {@link Database} instance to use for the operation.\n * It can be a {@link Transaction} as well.\n * @param id The UUID of the login challenge to consume.\n * @param now An optional timestamp to set as the `consumed` time.\n * If not provided, the current timestamp will be used.\n */\nexport async function consumeLoginChallenge(\n db: Database | Transaction,\n id: Uuid,\n now?: Temporal.Instant | SQL,\n): Promise<void> {\n // oxlint-disable-next-line no-param-reassign\n now ??= sql`CURRENT_TIMESTAMP`;\n const result = await db\n .update(loginChallenges)\n .set({ consumed: now })\n .where(\n and(\n eq(loginChallenges.id, id),\n isNull(loginChallenges.consumed),\n gt(loginChallenges.expires, now),\n ),\n )\n .returning({ consumed: loginChallenges.consumed });\n if (result.length < 1 || result[0]?.consumed == null) {\n throw new LoginChallengeConsumptionError(\n \"Login challenge not found or already consumed.\",\n );\n }\n}\n"],"mappings":";;;AA2BA,MAAM,gCAAgC;;;;;;AAOtC,MAAa,mCACX,MAAM,KAIJ,OAAO,gCAAgB,IAAI,YAAA,CAAuC,CAAC,IAClE,QACC,8BAA8B,MAAM,GACxC,CAAC,CAAC,KAAK,EAAE;;;;AAKX,IAAa,sBAAb,cAAyC,MAAM;CAC7C,YAAY,SAAiB;EAC3B,MAAM,OAAO;EACb,KAAK,OAAO;CACd;AACF;;;;AAKA,IAAa,8BAAb,cAAiD,oBAAoB;CACnE,YAAY,SAAiB;EAC3B,MAAM,OAAO;EACb,KAAK,OAAO;CACd;AACF;;;;;;;;;;;;;;AAeA,eAAsB,mBACpB,IACA,IACA,KACyB;CAEzB,QAAQ,GAAG;CACX,MAAM,SAAS,MAAM,GAAG,MAAM,gBAAgB,UAAU,EACtD,OAAO;EACL;EACA,UAAU,EAAE,QAAQ,KAAK;EACzB,GAAI,eAAe,SAAS,UACxB,EAAE,SAAS,EAAE,IAAI,IAAI,EAAE,IACvB,EAAE,MAAM,MAAM,GAAG,GAAG,EAAE,QAAQ,KAAK,MAAM;CAC/C,EACF,CAAC;CACD,IAAI,UAAU,MACZ,MAAM,IAAI,4BAA4B,4BAA4B;CAEpE,OAAO;AACT;;;;AAKA,IAAa,iCAAb,cAAoD,oBAAoB;CACtE,YAAY,SAAiB;EAC3B,MAAM,OAAO;EACb,KAAK,OAAO;CACd;AACF;;;;;;;;;;AAWA,eAAsB,sBACpB,IACA,IACA,KACe;CAEf,QAAQ,GAAG;CACX,MAAM,SAAS,MAAM,GAClB,OAAO,eAAe,CAAC,CACvB,IAAI,EAAE,UAAU,IAAI,CAAC,CAAC,CACtB,MACC,IACE,GAAG,gBAAgB,IAAI,EAAE,GACzB,OAAO,gBAAgB,QAAQ,GAC/B,GAAG,gBAAgB,SAAS,GAAG,CACjC,CACF,CAAC,CACA,UAAU,EAAE,UAAU,gBAAgB,SAAS,CAAC;CACnD,IAAI,OAAO,SAAS,KAAK,OAAO,EAAE,EAAE,YAAY,MAC9C,MAAM,IAAI,+BACR,gDACF;AAEJ"}
@@ -116,6 +116,14 @@
116
116
  {
117
117
  "name": "20261026192411_capture_legacy_resource_revisions",
118
118
  "sha256": "25deff8bc6684620fb679c1d339c8803cdcb1b5a8c5f9a9771c95411a185eee3"
119
+ },
120
+ {
121
+ "name": "20261113080536_revision_embeddings",
122
+ "sha256": "52427c6e8a430652bbca4aa351bcb35d0933ac372b221e9dd13cd2a537c68084"
123
+ },
124
+ {
125
+ "name": "20261113080537_guard_revision_embeddings",
126
+ "sha256": "565918b747d0a6d092cdb1d68cf709a729b705c17489b2e333aca294c692b8f5"
119
127
  }
120
128
  ]
121
129
  }
@@ -1,2 +1,2 @@
1
- import { i as relations } from "./db-BBw4F4HU.mjs";
1
+ import { i as relations } from "./db-CcbUSnp2.mjs";
2
2
  export { relations as default, relations };
@@ -19,6 +19,11 @@ const relations = defineRelations(schema_exports, (r) => ({
19
19
  receipts: r.many.revisionReceipts({
20
20
  from: r.resourceRevisions.id,
21
21
  to: r.revisionReceipts.revisionId
22
+ }),
23
+ embeddings: r.many.revisionEmbeddings({
24
+ from: r.resourceRevisions.id,
25
+ to: r.revisionEmbeddings.revisionId,
26
+ alias: "embeddings"
22
27
  })
23
28
  },
24
29
  resourceHeads: {
@@ -43,6 +48,19 @@ const relations = defineRelations(schema_exports, (r) => ({
43
48
  to: r.resourceRevisions.id,
44
49
  optional: false
45
50
  }) },
51
+ revisionEmbeddings: {
52
+ revision: r.one.resourceRevisions({
53
+ from: r.revisionEmbeddings.revisionId,
54
+ to: r.resourceRevisions.id,
55
+ optional: false,
56
+ alias: "embeddings"
57
+ }),
58
+ source: r.one.resourceRevisions({
59
+ from: r.revisionEmbeddings.sourceRevisionId,
60
+ to: r.resourceRevisions.id,
61
+ optional: false
62
+ })
63
+ },
46
64
  revisionReceipts: {
47
65
  revision: r.one.resourceRevisions({
48
66
  from: r.revisionReceipts.revisionId,
@@ -348,8 +366,7 @@ const relations = defineRelations(schema_exports, (r) => ({
348
366
  }),
349
367
  objects: r.many.objects({
350
368
  from: r.actors.id,
351
- to: r.objects.actorId,
352
- where: { deleted: { isNull: true } }
369
+ to: r.objects.actorId
353
370
  }),
354
371
  instance: r.one.instances({
355
372
  from: r.actors.instanceId,
@@ -1 +1 @@
1
- {"version":3,"file":"relations.mjs","names":["schema"],"sources":["../src/relations.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/>.\n\nimport { defineRelations } from \"drizzle-orm\";\n\nimport * as schema from \"./schema.ts\";\n\nexport const relations = defineRelations(schema, (r) => ({\n resourceRevisions: {\n resource: r.one.resources({\n from: r.resourceRevisions.resourceId,\n to: r.resources.id,\n optional: false,\n }),\n addressing: r.many.revisionAddressing({\n from: r.resourceRevisions.id,\n to: r.revisionAddressing.revisionId,\n }),\n relations: r.many.revisionRelations({\n from: r.resourceRevisions.id,\n to: r.revisionRelations.revisionId,\n }),\n receipts: r.many.revisionReceipts({\n from: r.resourceRevisions.id,\n to: r.revisionReceipts.revisionId,\n }),\n },\n resourceHeads: {\n resource: r.one.resources({\n from: r.resourceHeads.resourceId,\n to: r.resources.id,\n optional: false,\n }),\n revision: r.one.resourceRevisions({\n from: [r.resourceHeads.resourceId, r.resourceHeads.revisionId],\n to: [r.resourceRevisions.resourceId, r.resourceRevisions.id],\n optional: false,\n }),\n },\n revisionAddressing: {\n revision: r.one.resourceRevisions({\n from: r.revisionAddressing.revisionId,\n to: r.resourceRevisions.id,\n optional: false,\n }),\n },\n revisionRelations: {\n revision: r.one.resourceRevisions({\n from: r.revisionRelations.revisionId,\n to: r.resourceRevisions.id,\n optional: false,\n }),\n },\n revisionReceipts: {\n revision: r.one.resourceRevisions({\n from: r.revisionReceipts.revisionId,\n to: r.resourceRevisions.id,\n optional: false,\n }),\n delivery: r.one.activityDeliveries({\n from: r.revisionReceipts.deliveryId,\n to: r.activityDeliveries.id,\n optional: false,\n }),\n },\n keys: {\n versions: r.many.keyVersions({ from: r.keys.id, to: r.keyVersions.keyId }),\n },\n keyVersions: {\n key: r.one.keys({\n from: r.keyVersions.keyId,\n to: r.keys.id,\n optional: false,\n }),\n activityDeliveries: r.many.activityDeliveries({\n from: r.keyVersions.id,\n to: r.activityDeliveries.verificationKeyId,\n }),\n },\n activityDeliveries: {\n revisionReceipts: r.many.revisionReceipts({\n from: r.activityDeliveries.id,\n to: r.revisionReceipts.deliveryId,\n }),\n instance: r.one.instances({\n from: r.activityDeliveries.instanceId,\n to: r.instances.id,\n optional: false,\n }),\n actor: r.one.actors({\n from: r.activityDeliveries.actorId,\n to: r.actors.id,\n where: { deleted: { isNull: true } },\n }),\n actorLinks: r.many.activityDeliveryActors({\n from: r.activityDeliveries.id,\n to: r.activityDeliveryActors.deliveryId,\n }),\n verificationKey: r.one.keyVersions({\n from: r.activityDeliveries.verificationKeyId,\n to: r.keyVersions.id,\n }),\n attempts: r.many.activityDeliveryAttempts({\n from: r.activityDeliveries.id,\n to: r.activityDeliveryAttempts.deliveryId,\n }),\n activity: r.one.activities({\n from: r.activityDeliveries.activityId,\n to: r.activities.id,\n }),\n },\n activityDeliveryAttempts: {\n delivery: r.one.activityDeliveries({\n from: r.activityDeliveryAttempts.deliveryId,\n to: r.activityDeliveries.id,\n optional: false,\n }),\n },\n activityDeliveryActors: {\n delivery: r.one.activityDeliveries({\n from: r.activityDeliveryActors.deliveryId,\n to: r.activityDeliveries.id,\n optional: false,\n }),\n actor: r.one.actors({\n from: r.activityDeliveryActors.actorId,\n to: r.actors.id,\n optional: false,\n }),\n collections: r.many.activityDeliveryActorCollections({\n from: [\n r.activityDeliveryActors.deliveryId,\n r.activityDeliveryActors.actorId,\n ],\n to: [\n r.activityDeliveryActorCollections.deliveryId,\n r.activityDeliveryActorCollections.actorId,\n ],\n }),\n },\n activityDeliveryActorCollections: {\n actorLink: r.one.activityDeliveryActors({\n from: [\n r.activityDeliveryActorCollections.deliveryId,\n r.activityDeliveryActorCollections.actorId,\n ],\n to: [\n r.activityDeliveryActors.deliveryId,\n r.activityDeliveryActors.actorId,\n ],\n optional: false,\n }),\n },\n accounts: {\n instances: r.many.instances({\n from: r.accounts.id.through(r.instanceMembers.accountId),\n to: r.instances.id.through(r.instanceMembers.instanceId),\n // Drizzle ORM currently does not support many-to-many relationships with\n // additional filters on the junction table. So we need to specify\n // filter `accepted IS NOT NULL` everywhere we query for instances of\n // an account (sigh). See also the below issue:\n // https://github.com/drizzle-team/drizzle-orm/issues/5343\n }),\n instanceMembers: r.many.instanceMembers({\n from: r.accounts.id,\n to: r.instanceMembers.accountId,\n where: {\n accepted: { isNotNull: true },\n },\n }),\n sessions: r.many.sessions({\n from: r.accounts.id,\n to: r.sessions.accountId,\n }),\n loginChallenges: r.many.loginChallenges({\n from: r.accounts.id,\n to: r.loginChallenges.accountId,\n }),\n },\n instanceMembers: {\n account: r.one.accounts({\n from: r.instanceMembers.accountId,\n to: r.accounts.id,\n }),\n instance: r.one.instances({\n from: r.instanceMembers.instanceId,\n to: r.instances.id,\n }),\n },\n instances: {\n activityDeliveries: r.many.activityDeliveries({\n from: r.instances.id,\n to: r.activityDeliveries.instanceId,\n }),\n members: r.many.accounts({\n from: r.instances.id.through(r.instanceMembers.instanceId),\n to: r.accounts.id.through(r.instanceMembers.accountId),\n // Drizzle ORM currently does not support many-to-many relationships with\n // additional filters on the junction table. So we need to specify\n // filter `accepted IS NOT NULL` everywhere we query for members of\n // an instance (sigh). See also the below issue:\n // https://github.com/drizzle-team/drizzle-orm/issues/5343\n }),\n instanceMembers: r.many.instanceMembers({\n from: r.instances.id,\n to: r.instanceMembers.instanceId,\n where: {\n accepted: { isNotNull: true },\n },\n }),\n actors: r.many.actors({\n from: r.instances.id,\n to: r.actors.instanceId,\n where: { deleted: { isNull: true } },\n }),\n localInstance: r.one.localInstances({\n from: r.instances.localId,\n to: r.localInstances.id,\n }),\n },\n localInstances: {\n instance: r.one.instances({\n from: r.localInstances.id,\n to: r.instances.localId,\n }),\n },\n sessions: {\n account: r.one.accounts({\n from: r.sessions.accountId,\n to: r.accounts.id,\n optional: false,\n }),\n },\n loginChallenges: {\n account: r.one.accounts({\n from: r.loginChallenges.accountId,\n to: r.accounts.id,\n optional: false,\n }),\n },\n resources: {\n revisions: r.many.resourceRevisions({\n from: r.resources.id,\n to: r.resourceRevisions.resourceId,\n }),\n head: r.one.resourceHeads({\n from: r.resources.id,\n to: r.resourceHeads.resourceId,\n }),\n actor: r.one.actors({\n from: r.resources.id,\n to: r.actors.id,\n optional: true,\n }),\n object: r.one.objects({\n from: r.resources.id,\n to: r.objects.id,\n optional: true,\n }),\n activity: r.one.activities({\n from: r.resources.id,\n to: r.activities.id,\n optional: true,\n }),\n collection: r.one.collections({\n from: r.resources.id,\n to: r.collections.id,\n optional: true,\n }),\n addressedBy: r.many.addressing({\n from: r.resources.id,\n to: r.addressing.targetId,\n }),\n },\n addressing: {\n source: r.one.resources({\n from: r.addressing.sourceId,\n to: r.resources.id,\n optional: false,\n }),\n targetResource: r.one.resources({\n from: r.addressing.targetId,\n to: r.resources.id,\n optional: false,\n }),\n },\n actorCollectionReferences: {\n actor: r.one.actors({\n from: r.actorCollectionReferences.actorId,\n to: r.actors.id,\n optional: false,\n }),\n collection: r.one.collections({\n from: r.actorCollectionReferences.collectionId,\n to: r.collections.id,\n optional: false,\n }),\n },\n collections: {\n resource: r.one.resources({\n from: r.collections.id,\n to: r.resources.id,\n optional: false,\n }),\n ownerActor: r.one.actors({\n from: r.collections.ownerActorId,\n to: r.actors.id,\n }),\n items: r.many.collectionItems({\n from: r.collections.id,\n to: r.collectionItems.collectionId,\n }),\n },\n collectionItems: {\n collection: r.one.collections({\n from: r.collectionItems.collectionId,\n to: r.collections.id,\n optional: false,\n }),\n item: r.one.resources({\n from: r.collectionItems.itemId,\n to: r.resources.id,\n optional: false,\n }),\n },\n activities: {\n resource: r.one.resources({\n from: r.activities.id,\n to: r.resources.id,\n optional: false,\n }),\n actor: r.one.actors({\n from: r.activities.actorId,\n to: r.actors.id,\n optional: false,\n }),\n object: r.one.resources({\n from: r.activities.objectId,\n to: r.resources.id,\n }),\n addressing: r.many.addressing({\n from: r.activities.id,\n to: r.addressing.sourceId,\n }),\n deliveries: r.many.activityDeliveries({\n from: r.activities.id,\n to: r.activityDeliveries.activityId,\n }),\n },\n objects: {\n resource: r.one.resources({\n from: r.objects.id,\n to: r.resources.id,\n optional: false,\n }),\n addressing: r.many.addressing({\n from: r.objects.id,\n to: r.addressing.sourceId,\n }),\n activities: r.many.activities({\n from: r.objects.id,\n to: r.activities.objectId,\n }),\n actor: r.one.actors({\n from: r.objects.actorId,\n to: r.actors.id,\n optional: false,\n }),\n },\n actors: {\n activityDeliveryLinks: r.many.activityDeliveryActors({\n from: r.actors.id,\n to: r.activityDeliveryActors.actorId,\n }),\n collectionReferences: r.many.actorCollectionReferences({\n from: r.actors.id,\n to: r.actorCollectionReferences.actorId,\n }),\n resource: r.one.resources({\n from: r.actors.id,\n to: r.resources.id,\n optional: false,\n }),\n collections: r.many.collections({\n from: r.actors.id,\n to: r.collections.ownerActorId,\n }),\n activities: r.many.activities({\n from: r.actors.id,\n to: r.activities.actorId,\n }),\n objects: r.many.objects({\n from: r.actors.id,\n to: r.objects.actorId,\n where: { deleted: { isNull: true } },\n }),\n instance: r.one.instances({\n from: r.actors.instanceId,\n to: r.instances.id,\n optional: false,\n }),\n localActor: r.one.localActors({\n from: r.actors.localId,\n to: r.localActors.id,\n }),\n },\n localActors: {\n actor: r.one.actors({ from: r.localActors.id, to: r.actors.localId }),\n },\n}));\n\nexport default relations;\n"],"mappings":";;;AAoBA,MAAa,YAAY,gBAAgBA,iBAAS,OAAO;CACvD,mBAAmB;EACjB,UAAU,EAAE,IAAI,UAAU;GACxB,MAAM,EAAE,kBAAkB;GAC1B,IAAI,EAAE,UAAU;GAChB,UAAU;EACZ,CAAC;EACD,YAAY,EAAE,KAAK,mBAAmB;GACpC,MAAM,EAAE,kBAAkB;GAC1B,IAAI,EAAE,mBAAmB;EAC3B,CAAC;EACD,WAAW,EAAE,KAAK,kBAAkB;GAClC,MAAM,EAAE,kBAAkB;GAC1B,IAAI,EAAE,kBAAkB;EAC1B,CAAC;EACD,UAAU,EAAE,KAAK,iBAAiB;GAChC,MAAM,EAAE,kBAAkB;GAC1B,IAAI,EAAE,iBAAiB;EACzB,CAAC;CACH;CACA,eAAe;EACb,UAAU,EAAE,IAAI,UAAU;GACxB,MAAM,EAAE,cAAc;GACtB,IAAI,EAAE,UAAU;GAChB,UAAU;EACZ,CAAC;EACD,UAAU,EAAE,IAAI,kBAAkB;GAChC,MAAM,CAAC,EAAE,cAAc,YAAY,EAAE,cAAc,UAAU;GAC7D,IAAI,CAAC,EAAE,kBAAkB,YAAY,EAAE,kBAAkB,EAAE;GAC3D,UAAU;EACZ,CAAC;CACH;CACA,oBAAoB,EAClB,UAAU,EAAE,IAAI,kBA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,CAAC,EACtE;AACF,EAAE"}
1
+ {"version":3,"file":"relations.mjs","names":["schema"],"sources":["../src/relations.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/>.\n\nimport { defineRelations } from \"drizzle-orm\";\n\nimport * as schema from \"./schema.ts\";\n\nexport const relations = defineRelations(schema, (r) => ({\n resourceRevisions: {\n resource: r.one.resources({\n from: r.resourceRevisions.resourceId,\n to: r.resources.id,\n optional: false,\n }),\n addressing: r.many.revisionAddressing({\n from: r.resourceRevisions.id,\n to: r.revisionAddressing.revisionId,\n }),\n relations: r.many.revisionRelations({\n from: r.resourceRevisions.id,\n to: r.revisionRelations.revisionId,\n }),\n receipts: r.many.revisionReceipts({\n from: r.resourceRevisions.id,\n to: r.revisionReceipts.revisionId,\n }),\n embeddings: r.many.revisionEmbeddings({\n from: r.resourceRevisions.id,\n to: r.revisionEmbeddings.revisionId,\n alias: \"embeddings\",\n }),\n },\n resourceHeads: {\n resource: r.one.resources({\n from: r.resourceHeads.resourceId,\n to: r.resources.id,\n optional: false,\n }),\n revision: r.one.resourceRevisions({\n from: [r.resourceHeads.resourceId, r.resourceHeads.revisionId],\n to: [r.resourceRevisions.resourceId, r.resourceRevisions.id],\n optional: false,\n }),\n },\n revisionAddressing: {\n revision: r.one.resourceRevisions({\n from: r.revisionAddressing.revisionId,\n to: r.resourceRevisions.id,\n optional: false,\n }),\n },\n revisionRelations: {\n revision: r.one.resourceRevisions({\n from: r.revisionRelations.revisionId,\n to: r.resourceRevisions.id,\n optional: false,\n }),\n },\n revisionEmbeddings: {\n revision: r.one.resourceRevisions({\n from: r.revisionEmbeddings.revisionId,\n to: r.resourceRevisions.id,\n optional: false,\n alias: \"embeddings\",\n }),\n source: r.one.resourceRevisions({\n from: r.revisionEmbeddings.sourceRevisionId,\n to: r.resourceRevisions.id,\n optional: false,\n }),\n },\n revisionReceipts: {\n revision: r.one.resourceRevisions({\n from: r.revisionReceipts.revisionId,\n to: r.resourceRevisions.id,\n optional: false,\n }),\n delivery: r.one.activityDeliveries({\n from: r.revisionReceipts.deliveryId,\n to: r.activityDeliveries.id,\n optional: false,\n }),\n },\n keys: {\n versions: r.many.keyVersions({ from: r.keys.id, to: r.keyVersions.keyId }),\n },\n keyVersions: {\n key: r.one.keys({\n from: r.keyVersions.keyId,\n to: r.keys.id,\n optional: false,\n }),\n activityDeliveries: r.many.activityDeliveries({\n from: r.keyVersions.id,\n to: r.activityDeliveries.verificationKeyId,\n }),\n },\n activityDeliveries: {\n revisionReceipts: r.many.revisionReceipts({\n from: r.activityDeliveries.id,\n to: r.revisionReceipts.deliveryId,\n }),\n instance: r.one.instances({\n from: r.activityDeliveries.instanceId,\n to: r.instances.id,\n optional: false,\n }),\n actor: r.one.actors({\n from: r.activityDeliveries.actorId,\n to: r.actors.id,\n where: { deleted: { isNull: true } },\n }),\n actorLinks: r.many.activityDeliveryActors({\n from: r.activityDeliveries.id,\n to: r.activityDeliveryActors.deliveryId,\n }),\n verificationKey: r.one.keyVersions({\n from: r.activityDeliveries.verificationKeyId,\n to: r.keyVersions.id,\n }),\n attempts: r.many.activityDeliveryAttempts({\n from: r.activityDeliveries.id,\n to: r.activityDeliveryAttempts.deliveryId,\n }),\n activity: r.one.activities({\n from: r.activityDeliveries.activityId,\n to: r.activities.id,\n }),\n },\n activityDeliveryAttempts: {\n delivery: r.one.activityDeliveries({\n from: r.activityDeliveryAttempts.deliveryId,\n to: r.activityDeliveries.id,\n optional: false,\n }),\n },\n activityDeliveryActors: {\n delivery: r.one.activityDeliveries({\n from: r.activityDeliveryActors.deliveryId,\n to: r.activityDeliveries.id,\n optional: false,\n }),\n actor: r.one.actors({\n from: r.activityDeliveryActors.actorId,\n to: r.actors.id,\n optional: false,\n }),\n collections: r.many.activityDeliveryActorCollections({\n from: [\n r.activityDeliveryActors.deliveryId,\n r.activityDeliveryActors.actorId,\n ],\n to: [\n r.activityDeliveryActorCollections.deliveryId,\n r.activityDeliveryActorCollections.actorId,\n ],\n }),\n },\n activityDeliveryActorCollections: {\n actorLink: r.one.activityDeliveryActors({\n from: [\n r.activityDeliveryActorCollections.deliveryId,\n r.activityDeliveryActorCollections.actorId,\n ],\n to: [\n r.activityDeliveryActors.deliveryId,\n r.activityDeliveryActors.actorId,\n ],\n optional: false,\n }),\n },\n accounts: {\n instances: r.many.instances({\n from: r.accounts.id.through(r.instanceMembers.accountId),\n to: r.instances.id.through(r.instanceMembers.instanceId),\n // Drizzle ORM currently does not support many-to-many relationships with\n // additional filters on the junction table. So we need to specify\n // filter `accepted IS NOT NULL` everywhere we query for instances of\n // an account (sigh). See also the below issue:\n // https://github.com/drizzle-team/drizzle-orm/issues/5343\n }),\n instanceMembers: r.many.instanceMembers({\n from: r.accounts.id,\n to: r.instanceMembers.accountId,\n where: {\n accepted: { isNotNull: true },\n },\n }),\n sessions: r.many.sessions({\n from: r.accounts.id,\n to: r.sessions.accountId,\n }),\n loginChallenges: r.many.loginChallenges({\n from: r.accounts.id,\n to: r.loginChallenges.accountId,\n }),\n },\n instanceMembers: {\n account: r.one.accounts({\n from: r.instanceMembers.accountId,\n to: r.accounts.id,\n }),\n instance: r.one.instances({\n from: r.instanceMembers.instanceId,\n to: r.instances.id,\n }),\n },\n instances: {\n activityDeliveries: r.many.activityDeliveries({\n from: r.instances.id,\n to: r.activityDeliveries.instanceId,\n }),\n members: r.many.accounts({\n from: r.instances.id.through(r.instanceMembers.instanceId),\n to: r.accounts.id.through(r.instanceMembers.accountId),\n // Drizzle ORM currently does not support many-to-many relationships with\n // additional filters on the junction table. So we need to specify\n // filter `accepted IS NOT NULL` everywhere we query for members of\n // an instance (sigh). See also the below issue:\n // https://github.com/drizzle-team/drizzle-orm/issues/5343\n }),\n instanceMembers: r.many.instanceMembers({\n from: r.instances.id,\n to: r.instanceMembers.instanceId,\n where: {\n accepted: { isNotNull: true },\n },\n }),\n actors: r.many.actors({\n from: r.instances.id,\n to: r.actors.instanceId,\n where: { deleted: { isNull: true } },\n }),\n localInstance: r.one.localInstances({\n from: r.instances.localId,\n to: r.localInstances.id,\n }),\n },\n localInstances: {\n instance: r.one.instances({\n from: r.localInstances.id,\n to: r.instances.localId,\n }),\n },\n sessions: {\n account: r.one.accounts({\n from: r.sessions.accountId,\n to: r.accounts.id,\n optional: false,\n }),\n },\n loginChallenges: {\n account: r.one.accounts({\n from: r.loginChallenges.accountId,\n to: r.accounts.id,\n optional: false,\n }),\n },\n resources: {\n revisions: r.many.resourceRevisions({\n from: r.resources.id,\n to: r.resourceRevisions.resourceId,\n }),\n head: r.one.resourceHeads({\n from: r.resources.id,\n to: r.resourceHeads.resourceId,\n }),\n actor: r.one.actors({\n from: r.resources.id,\n to: r.actors.id,\n optional: true,\n }),\n object: r.one.objects({\n from: r.resources.id,\n to: r.objects.id,\n optional: true,\n }),\n activity: r.one.activities({\n from: r.resources.id,\n to: r.activities.id,\n optional: true,\n }),\n collection: r.one.collections({\n from: r.resources.id,\n to: r.collections.id,\n optional: true,\n }),\n addressedBy: r.many.addressing({\n from: r.resources.id,\n to: r.addressing.targetId,\n }),\n },\n addressing: {\n source: r.one.resources({\n from: r.addressing.sourceId,\n to: r.resources.id,\n optional: false,\n }),\n targetResource: r.one.resources({\n from: r.addressing.targetId,\n to: r.resources.id,\n optional: false,\n }),\n },\n actorCollectionReferences: {\n actor: r.one.actors({\n from: r.actorCollectionReferences.actorId,\n to: r.actors.id,\n optional: false,\n }),\n collection: r.one.collections({\n from: r.actorCollectionReferences.collectionId,\n to: r.collections.id,\n optional: false,\n }),\n },\n collections: {\n resource: r.one.resources({\n from: r.collections.id,\n to: r.resources.id,\n optional: false,\n }),\n ownerActor: r.one.actors({\n from: r.collections.ownerActorId,\n to: r.actors.id,\n }),\n items: r.many.collectionItems({\n from: r.collections.id,\n to: r.collectionItems.collectionId,\n }),\n },\n collectionItems: {\n collection: r.one.collections({\n from: r.collectionItems.collectionId,\n to: r.collections.id,\n optional: false,\n }),\n item: r.one.resources({\n from: r.collectionItems.itemId,\n to: r.resources.id,\n optional: false,\n }),\n },\n activities: {\n resource: r.one.resources({\n from: r.activities.id,\n to: r.resources.id,\n optional: false,\n }),\n actor: r.one.actors({\n from: r.activities.actorId,\n to: r.actors.id,\n optional: false,\n }),\n object: r.one.resources({\n from: r.activities.objectId,\n to: r.resources.id,\n }),\n addressing: r.many.addressing({\n from: r.activities.id,\n to: r.addressing.sourceId,\n }),\n deliveries: r.many.activityDeliveries({\n from: r.activities.id,\n to: r.activityDeliveries.activityId,\n }),\n },\n objects: {\n resource: r.one.resources({\n from: r.objects.id,\n to: r.resources.id,\n optional: false,\n }),\n addressing: r.many.addressing({\n from: r.objects.id,\n to: r.addressing.sourceId,\n }),\n activities: r.many.activities({\n from: r.objects.id,\n to: r.activities.objectId,\n }),\n actor: r.one.actors({\n from: r.objects.actorId,\n to: r.actors.id,\n optional: false,\n }),\n },\n actors: {\n activityDeliveryLinks: r.many.activityDeliveryActors({\n from: r.actors.id,\n to: r.activityDeliveryActors.actorId,\n }),\n collectionReferences: r.many.actorCollectionReferences({\n from: r.actors.id,\n to: r.actorCollectionReferences.actorId,\n }),\n resource: r.one.resources({\n from: r.actors.id,\n to: r.resources.id,\n optional: false,\n }),\n collections: r.many.collections({\n from: r.actors.id,\n to: r.collections.ownerActorId,\n }),\n activities: r.many.activities({\n from: r.actors.id,\n to: r.activities.actorId,\n }),\n objects: r.many.objects({\n from: r.actors.id,\n to: r.objects.actorId,\n }),\n instance: r.one.instances({\n from: r.actors.instanceId,\n to: r.instances.id,\n optional: false,\n }),\n localActor: r.one.localActors({\n from: r.actors.localId,\n to: r.localActors.id,\n }),\n },\n localActors: {\n actor: r.one.actors({ from: r.localActors.id, to: r.actors.localId }),\n },\n}));\n\nexport default relations;\n"],"mappings":";;;AAoBA,MAAa,YAAY,gBAAgBA,iBAAS,OAAO;CACvD,mBAAmB;EACjB,UAAU,EAAE,IAAI,UAAU;GACxB,MAAM,EAAE,kBAAkB;GAC1B,IAAI,EAAE,UAAU;GAChB,UAAU;EACZ,CAAC;EACD,YAAY,EAAE,KAAK,mBAAmB;GACpC,MAAM,EAAE,kBAAkB;GAC1B,IAAI,EAAE,mBAAmB;EAC3B,CAAC;EACD,WAAW,EAAE,KAAK,kBAAkB;GAClC,MAAM,EAAE,kBAAkB;GAC1B,IAAI,EAAE,kBAAkB;EAC1B,CAAC;EACD,UAAU,EAAE,KAAK,iBAAiB;GAChC,MAAM,EAAE,kBAAkB;GAC1B,IAAI,EAAE,iBAAiB;EACzB,CAAC;EACD,YAAY,EAAE,KAAK,mBAAmB;GACpC,MAAM,EAAE,kBAAkB;GAC1B,IAAI,EAAE,mBAAmB;GACzB,OAAO;EACT,CAAC;CACH;CACA,eAAe;EACb,UAAU,EAAE,IAAI,UAAU;GACxB,MAAM,EAAE,cAAc;GACtB,IAAI,EAAE,UAAU;GAChB,UAAU;EACZ,CAAC;EACD,UAAU,EAAE,IAAI,kBAAkB;GAChC,MAAM,CAAC,EAAE,cAAc,YAAY,EAAE,cAAc,UAAU;GAC7D,IAAI,CAAC,EAAE,kBAAkB,YAAY,EAAE,kBAAkB,EAAE;GAC3D,UAAU;EACZ,CAAC;CACH;CACA,oBAAoB,EAClB,UAAU,EAAE,IAAI,kBAAkB;EAChC,MAAM,EAAE,mBAAmB;EAC3B,IAAI,EAAE,kBAAkB;EACxB,UAAU;CACZ,CAAC,EACH;CACA,mBAAmB,EACjB,UAAU,EAAE,IAAI,kBAAkB;EAChC,MAAM,EAAE,kBAAkB;EAC1B,IAAI,EAAE,kBAAkB;E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,OAAO;CAAQ,CAAC,EACtE;AACF,EAAE"}
@@ -1,4 +1,4 @@
1
- import { activities, addressing, addressingPropertyEnum, objects, resourceHeads, resourceRevisionCaptureEnum, resourceRevisionProjectionEnum, resourceRevisions, resources, revisionAddressing, revisionRelations } from "./schema.mjs";
1
+ import { activities, addressing, addressingPropertyEnum, objects, resourceHeads, resourceRevisionCaptureEnum, resourceRevisionProjectionEnum, resourceRevisions, resources, revisionAddressing, revisionEmbeddingRelationEnum, revisionEmbeddings, revisionRelations } from "./schema.mjs";
2
2
  import { areUuidsEqual, uuidV7, validateUuid } from "./uuid.mjs";
3
3
  import { ResourceKindConflictError, checkAddressingOccurrences, replaceAddressing } from "./resource.mjs";
4
4
  import { storableText } from "./text.mjs";
@@ -138,6 +138,24 @@ function relationRows(input = []) {
138
138
  };
139
139
  });
140
140
  }
141
+ function embeddingRows(input = []) {
142
+ if (!Array.isArray(input)) throw new TypeError("Embedding projections must be arrays.");
143
+ const paths = /* @__PURE__ */ new Set();
144
+ return input.map(({ path, sourceRevisionId, relation }) => {
145
+ if (!Array.isArray(path) || path.length < 1 || Array.from(path).some((part) => typeof part !== "string" && !(Number.isSafeInteger(part) && part >= 0))) throw new TypeError("An embedding path must name a nonempty list of field names and nonnegative indexes.");
146
+ for (const part of path) if (typeof part === "string") text(part);
147
+ const key = JSON.stringify(path);
148
+ if (paths.has(key)) throw new TypeError("Each embedding path must be given once.");
149
+ paths.add(key);
150
+ if (!validateUuid(sourceRevisionId)) throw new TypeError("Expected a source revision UUID.");
151
+ if (!revisionEmbeddingRelationEnum.enumValues.includes(relation)) throw new TypeError("Invalid embedding relation.");
152
+ return {
153
+ path: [...path],
154
+ sourceRevisionId,
155
+ relation
156
+ };
157
+ });
158
+ }
141
159
  async function current(db, resourceId) {
142
160
  const [row] = await db.select({ revision: resourceRevisions }).from(resourceHeads).innerJoin(resourceRevisions, and(eq(resourceHeads.resourceId, resourceRevisions.resourceId), eq(resourceHeads.revisionId, resourceRevisions.id))).where(eq(resourceHeads.resourceId, resourceId)).limit(1);
143
161
  return row?.revision ?? null;
@@ -175,6 +193,7 @@ function prepareSnapshot(input) {
175
193
  projection,
176
194
  addressing,
177
195
  relations: relationRows(input.relations),
196
+ embeddings: embeddingRows(input.embeddings),
178
197
  deleted: null,
179
198
  formerTypes: null
180
199
  };
@@ -190,6 +209,7 @@ function prepareWhiteout(input) {
190
209
  projection: void 0,
191
210
  addressing: [],
192
211
  relations: [],
212
+ embeddings: [],
193
213
  deleted: input.deleted,
194
214
  formerTypes
195
215
  };
@@ -229,7 +249,7 @@ async function lockRevisionTarget(tx, input, typed = false) {
229
249
  }
230
250
  async function appendPrepared(tx, input, typed = false) {
231
251
  const previous = await lockRevisionTarget(tx, input, typed);
232
- const { resourceId, kind, serialized, capture, projection, deleted, formerTypes, addressing, relations } = input;
252
+ const { resourceId, kind, serialized, capture, projection, deleted, formerTypes, addressing, relations, embeddings } = input;
233
253
  const id = uuidV7();
234
254
  const [revision] = await tx.insert(resourceRevisions).values({
235
255
  id,
@@ -256,6 +276,10 @@ async function appendPrepared(tx, input, typed = false) {
256
276
  ...row,
257
277
  revisionId: id
258
278
  })));
279
+ if (embeddings.length > 0) await tx.insert(revisionEmbeddings).values(embeddings.map((row) => ({
280
+ ...row,
281
+ revisionId: id
282
+ })));
259
283
  if (previous === null) await tx.insert(resourceHeads).values({
260
284
  resourceId,
261
285
  revisionId: id
@@ -372,6 +396,7 @@ async function writeTypedResourceRevision(db, input) {
372
396
  capture: "local",
373
397
  addressingOccurrences: input.addressingOccurrences,
374
398
  ...input.relations === void 0 ? {} : { relations: input.relations },
399
+ ...input.embeddings === void 0 ? {} : { embeddings: input.embeddings },
375
400
  ...input.projection === void 0 ? {} : { projection: input.projection }
376
401
  } : {
377
402
  resourceId: input.resourceId,
@@ -410,4 +435,4 @@ async function writeTypedResourceRevision(db, input) {
410
435
  //#endregion
411
436
  export { writeTypedResourceRevision as a, ResourceRevisionStateError as c, loadResourceRevision as i, LegacyResourceRevisionError as l, listResourceRevisions as n, captureLegacyResourceRevision as o, loadCurrentResourceRevision as r, RevisionConflictError as s, appendResourceRevision as t };
412
437
 
413
- //# sourceMappingURL=resource-revision-iQ8HZ699.mjs.map
438
+ //# sourceMappingURL=resource-revision-bTQyJ7aw.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resource-revision-bTQyJ7aw.mjs","names":["addressingTable"],"sources":["../src/legacy-resource-revision-error.ts","../src/resource-revision-state-error.ts","../src/revision-conflict-error.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/>.\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/>.\n\nimport { sql } from \"drizzle-orm\";\n\nimport type { Transaction } from \"./db.ts\";\nimport { LegacyResourceRevisionError } from \"./legacy-resource-revision-error.ts\";\nimport type { Uuid } from \"./uuid.ts\";\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 * @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): 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 { 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 NewActivityPubObject,\n type ResourceRevision,\n type RevisionAddressing,\n type RevisionEmbedding,\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 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 | {\n readonly kind: \"whiteout\";\n readonly deleted: Temporal.Instant;\n readonly formerTypes: readonly string[];\n }\n );\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 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// Produce JSON directly so negative zero and escaped Unicode are retained.\nfunction 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\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\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 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 };\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 };\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 (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/**\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 * @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 = prepareRevision(input);\n return await db.transaction((tx) => appendPrepared(tx, prepared));\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 }\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 = 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 }\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 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 { captureLegacyResourceRevision } from \"./legacy-resource-revision.ts\";\n"],"mappings":";;;;;;;AAmBA,IAAa,8BAAb,cAAiD,MAAM;CAChC;CAArB,YAAY,YAA2B;EACrC,MACE,uFACF;EAHmB,KAAA,aAAA;EAInB,KAAK,OAAO;CACd;AACF;;;;ACTA,IAAa,6BAAb,cAAgD,MAAM;CAEzC;CADX,YACE,MACA;EACA,MAAM,6CAA6C,KAAK,EAAE;EAFjD,KAAA,OAAA;EAGT,KAAK,OAAO;CACd;AACF;;;;ACLA,IAAa,wBAAb,cAA2C,MAAM;CAEpC;CACA;CACA;CAHX,YACE,YACA,oBACA,kBACA;EACA,MAAM,8CAA8C;EAJ3C,KAAA,aAAA;EACA,KAAA,qBAAA;EACA,KAAA,mBAAA;EAGT,KAAK,OAAO;CACd;AACF;;;;;;;;;;ACCA,eAAsB,8BACpB,IACA,YACe;CACf,IAAI;EACF,MAAM,CAAC,OAAO,MAAM,GACjB,OAAO,EACN,IAAI,GAAS,iCA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U,CAAC;EAC9C;EACA,OAAO,MAAM,eAAe,IAAI,UAAU,IAAI;CAChD,CAAC;AACH"}
@@ -1,4 +1,4 @@
1
- import { J as RevisionAddressing, P as NewActivityPubObject, X as RevisionRelation, q as ResourceRevision, r as Transaction, t as Database } from "./db-BBw4F4HU.mjs";
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";
2
2
  import { t as Uuid } from "./uuid-CKMzlIND.mjs";
3
3
  import { AddressingInput, AddressingOccurrence } from "./resource.mjs";
4
4
  //#region src/revision-conflict-error.d.ts
@@ -49,6 +49,18 @@ interface RevisionRelationInput {
49
49
  readonly representation: RevisionRelation["representation"];
50
50
  readonly targetIri?: string | null;
51
51
  }
52
+ /**
53
+ * Where an embedded document of a new snapshot came from, as
54
+ * `revisionEmbeddings` records it. The caller decides the relation by
55
+ * comparing the documents; nothing is compared here.
56
+ */
57
+ interface RevisionEmbeddingInput {
58
+ /** The embedded document's source path from the root; never `[]`. */
59
+ readonly path: readonly (string | number)[];
60
+ /** A snapshot of another resource, stored before this revision. */
61
+ readonly sourceRevisionId: Uuid;
62
+ readonly relation: RevisionEmbedding["relation"];
63
+ }
52
64
  interface AppendBase {
53
65
  readonly resourceId: Uuid;
54
66
  readonly resourceKind: "object" | "activity";
@@ -66,6 +78,8 @@ type AppendResourceRevisionInput = AppendBase & ({
66
78
  */
67
79
  readonly addressingOccurrences?: readonly AddressingOccurrence[];
68
80
  readonly relations?: readonly RevisionRelationInput[];
81
+ /** Embedded documents whose source is known, each path once. */
82
+ readonly embeddings?: readonly RevisionEmbeddingInput[];
69
83
  readonly projection?: ResourceRevision["projection"];
70
84
  } | {
71
85
  readonly kind: "whiteout";
@@ -117,6 +131,8 @@ type TypedResourceRevisionInput = TypedRevisionBase & ({
117
131
  readonly columns: Required<Omit<TypedObjectColumns, "type">> & Partial<Pick<TypedObjectColumns, "type">>;
118
132
  readonly addressingOccurrences: readonly AddressingOccurrence[];
119
133
  readonly relations?: readonly RevisionRelationInput[];
134
+ /** Embedded documents whose source is known, each path once. */
135
+ readonly embeddings?: readonly RevisionEmbeddingInput[];
120
136
  readonly projection?: ResourceRevision["projection"];
121
137
  } | {
122
138
  readonly kind: "whiteout";
@@ -142,5 +158,5 @@ type TypedResourceRevisionInput = TypedRevisionBase & ({
142
158
  */
143
159
  declare function writeTypedResourceRevision(db: Database | Transaction, input: TypedResourceRevisionInput): Promise<StoredResourceRevision>;
144
160
  //#endregion
145
- export { StoredResourceRevision as a, appendResourceRevision as c, loadResourceRevision as d, writeTypedResourceRevision as f, RevisionConflictError as g, LegacyResourceRevisionError as h, RevisionRelationInput as i, listResourceRevisions as l, ResourceRevisionStateError as m, JsonObject as n, TypedObjectColumns as o, captureLegacyResourceRevision as p, JsonValue as r, TypedResourceRevisionInput as s, AppendResourceRevisionInput as t, loadCurrentResourceRevision as u };
146
- //# sourceMappingURL=resource-revision-BauDwFIn.d.mts.map
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
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resource-revision-rDmHhNCj.d.mts","names":[],"sources":["../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":";;;;;cAmBa,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;;;;;;;;;;;iBCUS,8BACpB,IAAI,aACJ,YAAY,OACX,QAAQ;;;;KCqBC,wDAKC;YAEG,mBAAmB;;KAEvB;YAAyB,mBAAmB;;;UAGvC;WACN;WACA;WACA,gBAAgB;WAChB;;;;;;;UAQM;;WAEN;;WAEA,kBAAkB;WAClB,UAAU;;UAGX;WACC,YAAY;WACZ;;WAEA,oBAAoB;;KAEnB,8BAA8B;WAGzB;WACA,UAAU;WACV,SAAS;WACT,aAAa;;;;;WAKb,iCAAiC;WACjC,qBAAqB;;WAErB,sBAAsB;WACtB,aAAa;;WAGb;WACA,SAAS,SAAS;WAClB;;;UAKA,+BAA+B;WACrC,qBAAqB;WACrB,oBAAoB;;;;;;;;;iBA8dT,uBACpB,IAAI,WAAW,aACf,OAAO,8BACN,QAAQ;;;;;iBASW,qBACpB,IAAI,WAAW,aACf,YAAY,OACX,QAAQ;;;;;iBAaW,4BACpB,IAAI,WAAW,aACf,YAAY,OACX,QAAQ;;;;;iBAWW,sBACpB,IAAI,WAAW,aACf,YAAY,MACZ;WAAoB;WAAkC;IACrD,QAAQ;;KA0DC,qBAAqB,KAC/B;UAYQ;WACC,YAAY;;WAEZ,oBAAoB;;KAEnB,6BAA6B;WAGxB;WACA,UAAU;;WAEV,SAAS,SAAS,KAAK,+BAC9B,QAAQ,KAAK;WACN,gCAAgC;WAChC,qBAAqB;;WAErB,sBAAsB;WACtB,aAAa;;WAGb;WACA,SAAS,SAAS;WAClB;;;;;;;;;;;;;;;;;;;iBAyDK,2BACpB,IAAI,WAAW,aACf,OAAO,6BACN,QAAQ"}
@@ -1,2 +1,2 @@
1
- import { a as StoredResourceRevision, c as appendResourceRevision, d as loadResourceRevision, f as writeTypedResourceRevision, g as RevisionConflictError, h as LegacyResourceRevisionError, i as RevisionRelationInput, l as listResourceRevisions, m as ResourceRevisionStateError, n as JsonObject, o as TypedObjectColumns, p as captureLegacyResourceRevision, r as JsonValue, s as TypedResourceRevisionInput, t as AppendResourceRevisionInput, u as loadCurrentResourceRevision } from "./resource-revision-BauDwFIn.mjs";
2
- export { AppendResourceRevisionInput, JsonObject, JsonValue, LegacyResourceRevisionError, ResourceRevisionStateError, RevisionConflictError, RevisionRelationInput, StoredResourceRevision, TypedObjectColumns, TypedResourceRevisionInput, appendResourceRevision, captureLegacyResourceRevision, listResourceRevisions, loadCurrentResourceRevision, loadResourceRevision, writeTypedResourceRevision };
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,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-iQ8HZ699.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";
@@ -1,4 +1,4 @@
1
- import { G as Resource, b as CollectionRole, r as Transaction, t as Database, v as AddressingProperty } from "./db-BBw4F4HU.mjs";
1
+ import { G as Resource, b as CollectionRole, r as Transaction, t as Database, v as AddressingProperty } from "./db-CcbUSnp2.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";