@tearleads/client-sdk 0.1.237 → 0.1.239

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 (31) hide show
  1. package/data/persistence/documents/records/documentSyncFailurePersistence.d.ts +0 -2
  2. package/data/persistence/documents/records/documentSyncFailurePersistence.js +0 -2
  3. package/data/persistence/documents/records/documentSyncFailurePersistence.js.map +1 -1
  4. package/data/persistence/organizations/organizationReadModelDirectoryPersistence.js +88 -0
  5. package/data/persistence/organizations/organizationReadModelDirectoryPersistence.js.map +1 -0
  6. package/data/persistence/organizations/organizationReadModelPersistence.js +8 -46
  7. package/data/persistence/organizations/organizationReadModelPersistence.js.map +1 -1
  8. package/data/persistence/organizations/organizationReadModelProjection.js +0 -4
  9. package/data/persistence/organizations/organizationReadModelProjection.js.map +1 -1
  10. package/data/sqlite/migrations/localSchemaMigrations.js +30 -1
  11. package/data/sqlite/migrations/localSchemaMigrations.js.map +1 -1
  12. package/data/sqlite/schema/documentRecordSchema.js +4 -6
  13. package/data/sqlite/schema/documentRecordSchema.js.map +1 -1
  14. package/data/sqlite/schema/index.d.ts +0 -55
  15. package/data/sqlite/schema/organizationReadModelSchema.js +4 -3
  16. package/data/sqlite/schema/organizationReadModelSchema.js.map +1 -1
  17. package/data/sqlite/schema/organizationReadModelTableRegistry.d.ts +0 -38
  18. package/internal/api-client/ApiClient.d.ts +0 -6
  19. package/internal/api-client/client/organizations.d.ts +0 -6
  20. package/internal/validators/operation/organizations.d.ts +0 -32
  21. package/internal/validators/response/organization.d.ts +5 -63
  22. package/internal/validators/response/organization.js +5 -7
  23. package/internal/validators/response/organization.js.map +1 -1
  24. package/internal/validators/response/organizationReadModel.d.ts +3 -23
  25. package/internal/validators/response/organizationReadModel.js +4 -7
  26. package/internal/validators/response/organizationReadModel.js.map +1 -1
  27. package/package.json +1 -1
  28. package/stores/documents/documentStore/sync/attachmentUploadFailure.js +0 -1
  29. package/stores/documents/documentStore/sync/attachmentUploadFailure.js.map +1 -1
  30. package/stores/documents/documentStore/sync/syncShared.js +0 -1
  31. package/stores/documents/documentStore/sync/syncShared.js.map +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"documentRecordSchema.js","sourceRoot":"","sources":["documentRecordSchema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,aAAa,CAAC;AAClC,OAAO,EACL,KAAK,EACL,OAAO,EACP,UAAU,EACV,WAAW,EACX,IAAI,EACJ,WAAW,GACZ,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,oBAAoB,EAAuB,MAAM,mBAAmB,CAAC;AAE9E,MAAM,iBAAiB,GAAG,wBAAwB,CAAC;AACnD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuDG;AACH,MAAM,CAAC,MAAM,SAAS,GAAG,WAAW,CAClC,WAAW,EACX;IACE,OAAO,EAAE,IAAI,CAAC,UAAU,CAAC,CAAC,OAAO,EAAE;IACnC,OAAO,EAAE,IAAI,CAAC,UAAU,CAAC,CAAC,OAAO,EAAE;IACnC,UAAU,EAAE,IAAI,CAAC,aAAa,CAAC;IAC/B,WAAW,EAAE,OAAO,CAAC,cAAc,CAAC,CAAC,OAAO,EAAE,CAAC,OAAO,CAAC,CAAC,CAAC;IACzD,eAAe,EAAE,IAAI,CAAC,mBAAmB,CAAC;IAC1C,oBAAoB,EAAE,IAAI,CAAC,iBAAiB,CAAC,CAAC,OAAO,EAAE,CAAC,OAAO,CAAC,MAAM,CAAC;IACvE,aAAa,EAAE,IAAI,CAAC,iBAAiB,CAAC;IACtC,sBAAsB,EAAE,IAAI,CAAC,0BAA0B,CAAC;IACxD,gBAAgB,EAAE,IAAI,CAAC,oBAAoB,CAAC;IAC5C,kBAAkB,EAAE,IAAI,CAAC,sBAAsB,CAAC;IAChD,kBAAkB,EAAE,IAAI,CAAC,sBAAsB,CAAC;IAChD,gBAAgB,EAAE,IAAI,CAAC,mBA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E,CAAC;IACnC,KAAK,CAAC,4CAA4C,CAAC,CAAC,EAAE,CACpD,KAAK,CAAC,OAAO,EACb,KAAK,CAAC,OAAO,EACb,KAAK,CAAC,SAAS,CAChB;IACD,WAAW,CAAC,wCAAwC,CAAC;SAClD,EAAE,CAAC,KAAK,CAAC,QAAQ,CAAC;SAClB,KAAK,CAAC,GAAG,CAAA,GAAG,KAAK,CAAC,QAAQ,cAAc,CAAC;IAC5C,2EAA2E;IAC3E,KAAK,CAAC,2CAA2C,CAAC;SAC/C,EAAE,CAAC,KAAK,CAAC,OAAO,EAAE,KAAK,CAAC,OAAO,EAAE,KAAK,CAAC,SAAS,CAAC;SACjD,KAAK,CAAC,GAAG,CAAA,GAAG,KAAK,CAAC,QAAQ,cAAc,CAAC;CAC7C,CACF,CAAC;AAEF,MAAM,CAAC,MAAM,cAAc,GAAkC;IAC3D;QACE,GAAG,oBAAoB,CAAC,SAAS,CAAC;QAClC,eAAe,EAAE;YACf,mBAAmB;YACnB,qBAAqB;YACrB,sBAAsB;YACtB,qBAAqB;YACrB,sBAAsB;YACtB,2BAA2B;SAC5B;KACF;IACD,oBAAoB,CAAC,0BAA0B,CAAC;IAChD;QACE,GAAG,oBAAoB,CAAC,sBAAsB,CAAC;QAC/C,eAAe,EAAE,CAAC,WAAW,CAAC;KAC/B;CACF,CAAC","sourcesContent":["import { sql } from \"drizzle-orm\";\nimport {\n index,\n integer,\n primaryKey,\n sqliteTable,\n text,\n uniqueIndex,\n} from \"drizzle-orm/sqlite-core\";\nimport { defineSqlTableSchema, type SqlTableSchema } from \"../sqlTableSchema\";\n\nconst accessLevelColumn = \"effective_access_level\";\n/**\n * Durable Loro-backed document records shared by app features.\n *\n * This table stores encrypted document runtime state for multiple app domains.\n * `appKind` namespaces records for documents and container metadata. User-facing\n * list data is projected into feature-specific read models.\n *\n * Columns:\n * - `appKind`: Local domain namespace for the row, such as `documents` or\n * `container-metadata`.\n * - `localId`: Stable local id inside `appKind`. It may be created before a\n * server `documentId` exists.\n * - `documentId`: Server document id once the record is known remotely, or\n * `null` while the document is local-only.\n * - `accessEpoch`: Latest access epoch persisted for the document. Defaults to\n * the initial epoch.\n * - `accessStateHash`: Current document access/manifest state hash returned by\n * sync, when known.\n * - `lastCommitLsn`: Last remote commit cursor applied to this local document.\n * - `documentManifestBundle`: Serialized document manifest bundle used for\n * encrypted document sync.\n * - `contentKeyBundle`: Serialized content-key material needed to open the\n * local document.\n * - `documentKekTargets`: Serialized KEK target state for document key wraps.\n * - `pendingBaseVersion`: Encoded oplog version through which every persisted\n * op is already enqueued or synced. Persisted so a restart restores the\n * outgoing-delta marker instead of re-seeding it past a device-first\n * `deferRemoteSync` write's un-advanced op. `null` when unset.\n * - `snapshotEndVersion`: Encoded end version vector of the persisted content\n * (which lives in the durable-history tables, never on this row), written on\n * every content persist. Lets the pending-write queue's deferred-tail scan\n * compare version coverage without loading content. Empty string when the\n * document has never hydrated content, which readers treat as \"no deferred\n * tail claimable\".\n * - `recoveryGeneration`: Atomic raw-history recovery writer fence.\n * - `recoveryDocumentId`: Former server id for cross-client post-purge recreation.\n * - `pullContinuation`: Durable progress for the next bounded remote pull.\n * - `syncFailureStatus`, `syncFailureMessage`, `syncFailureAttemptedAt`: The\n * last terminal sync failure or quarantined incoming update for this scope.\n * The durable write queue (queued rows of `documentHistoryUpdates`) has no\n * status columns, so these let the write-queue view and footer explain why\n * the document is blocked. `syncFailureMessage` is non-null exactly when a\n * failure is recorded; a newer failure replaces the old, and a later fully\n * validated sync pass, a remote reset, or the scope's teardown clears all\n * three.\n * - `updatedAt`: Local timestamp for the last persisted runtime-state update.\n *\n * Indexes:\n * - `(appKind, localId)` is the primary key and scopes local document lookups.\n * - `(appKind, documentId) where documentId is not null` supports resolving a\n * server document id back to the local row during discovery and relinking.\n * - `(appKind, localId)` over records whose `pendingBaseVersion` differs from\n * a non-empty `snapshotEndVersion` serves the pending-write queue's\n * deferred-tail scan, which repeats that condition, so it reads only\n * unsettled records instead of every synced one.\n */\nexport const documents = sqliteTable(\n \"documents\",\n {\n appKind: text(\"app_kind\").notNull(),\n localId: text(\"local_id\").notNull(),\n documentId: text(\"document_id\"),\n accessEpoch: integer(\"access_epoch\").notNull().default(1),\n accessStateHash: text(\"access_state_hash\"),\n effectiveAccessLevel: text(accessLevelColumn).notNull().default(\"read\"),\n lastCommitLsn: text(\"last_commit_lsn\"),\n documentManifestBundle: text(\"document_manifest_bundle\"),\n contentKeyBundle: text(\"content_key_bundle\"),\n documentKekTargets: text(\"document_kek_targets\"),\n pendingBaseVersion: text(\"pending_base_version\"),\n pullContinuation: text(\"pull_continuation\"),\n recoveryGeneration: integer(\"recovery_generation\").notNull().default(0),\n recoveryDocumentId: text(\"recovery_document_id\"),\n snapshotEndVersion: text(\"snapshot_end_version\").notNull().default(\"\"),\n syncFailureStatus: integer(\"sync_failure_status\"),\n syncFailureMessage: text(\"sync_failure_message\"),\n syncFailureAttemptedAt: text(\"sync_failure_attempted_at\"),\n updatedAt: text(\"updated_at\").notNull(),\n },\n (table) => [\n primaryKey({ columns: [table.appKind, table.localId] }),\n index(\"documents_app_document_idx\")\n .on(table.appKind, table.documentId)\n .where(sql`${table.documentId} IS NOT NULL`),\n index(\"documents_deferred_tail_idx\")\n .on(table.appKind, table.localId)\n .where(\n sql`${table.snapshotEndVersion} <> '' AND ${table.pendingBaseVersion} IS NOT ${table.snapshotEndVersion}`,\n ),\n ],\n);\n\n/**\n * Full-history persistence for local documents (checkpoint + tail) — the ONLY\n * durable content source. Record rows in `documents` carry runtime metadata\n * and the content frontier (`snapshotEndVersion`), never content. The\n * checkpoint holds a full-history snapshot refreshed only at compaction, and\n * the tail appends every update (local deltas and decrypted remote updates)\n * written since. Restore = import checkpoint + replay tail; compaction =\n * export full history from the live doc, replace the checkpoint, clear the\n * tail — all bounded and amortized. Container metadata stores its content (an\n * exported-updates blob) as its checkpoint row, with no tail.\n */\nexport const documentHistoryCheckpoints = sqliteTable(\n \"document_history_checkpoints\",\n {\n appKind: text(\"app_kind\").notNull(),\n localId: text(\"local_id\").notNull(),\n snapshot: text(\"snapshot\").notNull(),\n endVersionVector: text(\"end_version_vector\").notNull(),\n revision: text(\"revision\").notNull(),\n updatedAt: text(\"updated_at\").notNull(),\n },\n (table) => [primaryKey({ columns: [table.appKind, table.localId] })],\n);\n\n/**\n * The local update log: one row per Loro update, serving as both the history\n * tail (restore = checkpoint + tail) and the outbound write queue.\n *\n * Every locally authored update is stored once. While it waits for sync it\n * carries an `updateId` (the id submitted to the server) and the version-vector\n * metadata the submission needs; settlement clears them, leaving the row as\n * ordinary tail history until compaction folds it into a checkpoint. Before a\n * send, a contiguous run of queued local rows may be replaced by one merged\n * row holding exactly their operations: the first row is updated in place\n * (same `id`, `createdAt` and `rowid`, so the same queue and replay position)\n * under a fresh `updateId`, and the other rows are deleted.\n *\n * Columns:\n * - `id`: Row id; tail compaction deletes by it.\n * - `appKind`, `localId`: Document scope matching `documents`.\n * - `updateData`: Serialized Loro update payload.\n * - `origin`: \"local\" (authored on this device) or \"remote\" (decrypted\n * pulled update) for tail rows. Restores use it to advance the\n * outgoing-delta marker across remote rows — their ops are already\n * server-side — while a local row left behind by a crash stays below the\n * marker so the next edit re-derives and sends it. \"outbox\" marks a queued\n * update with no tail role (container metadata, whose content is its\n * checkpoint, and full-state re-uploads after a remote reset); restores and\n * compaction never see it and settlement deletes it.\n * - `createdAt`: Insertion timestamp; with `rowid`, deterministic replay order.\n * - `updateId`: Present exactly while the row is queued for sync; rekeyed\n * after a lost acknowledgement poisons the submitted id, and replaced by a\n * fresh id when queued rows merge. An id never names two payloads.\n * - `partialStartVersionVector` / `partialEndVersionVector`: Version vectors\n * around a queued partial update.\n * - `sourceVersionVector`: Present on a queued rotation baseline checkpoint.\n * - `rekeyCount`: Durable bound on rekeys of a queued row; a merged row takes\n * the largest count among the rows it replaces.\n *\n * Invariant: compaction never deletes a queued row, so a checkpoint can cover\n * a queued update's operations without removing it from the queue.\n */\nexport const documentHistoryUpdates = sqliteTable(\n \"document_history_updates\",\n {\n id: text(\"id\"),\n appKind: text(\"app_kind\").notNull(),\n localId: text(\"local_id\").notNull(),\n updateData: text(\"update_data\").notNull(),\n origin: text(\"origin\").notNull(),\n createdAt: text(\"created_at\").notNull(),\n updateId: text(\"update_id\"),\n partialStartVersionVector: text(\"partial_start_version_vector\"),\n partialEndVersionVector: text(\"partial_end_version_vector\"),\n sourceVersionVector: text(\"source_version_vector\"),\n rekeyCount: integer(\"rekey_count\").notNull().default(0),\n },\n (table) => [\n primaryKey({ columns: [table.id] }),\n index(\"document_history_updates_scope_created_idx\").on(\n table.appKind,\n table.localId,\n table.createdAt,\n ),\n uniqueIndex(\"document_history_updates_update_id_idx\")\n .on(table.updateId)\n .where(sql`${table.updateId} IS NOT NULL`),\n // Queued rows only: pending counts and pending loads skip settled history.\n index(\"document_history_updates_queued_scope_idx\")\n .on(table.appKind, table.localId, table.createdAt)\n .where(sql`${table.updateId} IS NOT NULL`),\n ],\n);\n\nexport const documentTables: ReadonlyArray<SqlTableSchema> = [\n {\n ...defineSqlTableSchema(documents),\n requiredColumns: [\n \"pull_continuation\",\n \"recovery_generation\",\n \"recovery_document_id\",\n \"sync_failure_status\",\n \"sync_failure_message\",\n \"sync_failure_attempted_at\",\n ],\n },\n defineSqlTableSchema(documentHistoryCheckpoints),\n {\n ...defineSqlTableSchema(documentHistoryUpdates),\n requiredColumns: [\"update_id\"],\n },\n];\n"]}
1
+ {"version":3,"file":"documentRecordSchema.js","sourceRoot":"","sources":["documentRecordSchema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,aAAa,CAAC;AAClC,OAAO,EACL,KAAK,EACL,OAAO,EACP,UAAU,EACV,WAAW,EACX,IAAI,EACJ,WAAW,GACZ,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,oBAAoB,EAAuB,MAAM,mBAAmB,CAAC;AAE9E,MAAM,iBAAiB,GAAG,wBAAwB,CAAC;AACnD;;;;;;;;;;;;;;;;;;;;;;;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C,MAAM,cAAc,GAAkC;IAC3D;QACE,GAAG,oBAAoB,CAAC,SAAS,CAAC;QAClC,eAAe,EAAE;YACf,mBAAmB;YACnB,qBAAqB;YACrB,sBAAsB;YACtB,sBAAsB;YACtB,2BAA2B;SAC5B;KACF;IACD,oBAAoB,CAAC,0BAA0B,CAAC;IAChD;QACE,GAAG,oBAAoB,CAAC,sBAAsB,CAAC;QAC/C,eAAe,EAAE,CAAC,WAAW,CAAC;KAC/B;CACF,CAAC","sourcesContent":["import { sql } from \"drizzle-orm\";\nimport {\n index,\n integer,\n primaryKey,\n sqliteTable,\n text,\n uniqueIndex,\n} from \"drizzle-orm/sqlite-core\";\nimport { defineSqlTableSchema, type SqlTableSchema } from \"../sqlTableSchema\";\n\nconst accessLevelColumn = \"effective_access_level\";\n/**\n * Durable Loro-backed document records shared by app features.\n *\n * This table stores encrypted document runtime state for multiple app domains.\n * `appKind` namespaces records for documents and container metadata. User-facing\n * list data is projected into feature-specific read models.\n *\n * Columns:\n * - `appKind`: Local domain namespace for the row, such as `documents` or\n * `container-metadata`.\n * - `localId`: Stable local id inside `appKind`. It may be created before a\n * server `documentId` exists.\n * - `documentId`: Server document id once the record is known remotely, or\n * `null` while the document is local-only.\n * - `accessEpoch`: Latest access epoch persisted for the document. Defaults to\n * the initial epoch.\n * - `accessStateHash`: Current document access/manifest state hash returned by\n * sync, when known.\n * - `lastCommitLsn`: Last remote commit cursor applied to this local document.\n * - `documentManifestBundle`: Serialized document manifest bundle used for\n * encrypted document sync.\n * - `contentKeyBundle`: Serialized content-key material needed to open the\n * local document.\n * - `documentKekTargets`: Serialized KEK target state for document key wraps.\n * - `pendingBaseVersion`: Encoded oplog version through which every persisted\n * op is already enqueued or synced. Persisted so a restart restores the\n * outgoing-delta marker instead of re-seeding it past a device-first\n * `deferRemoteSync` write's un-advanced op. `null` when unset.\n * - `snapshotEndVersion`: Encoded end version vector of the persisted content\n * (which lives in the durable-history tables, never on this row), written on\n * every content persist. Lets the pending-write queue's deferred-tail scan\n * compare version coverage without loading content. Empty string when the\n * document has never hydrated content, which readers treat as \"no deferred\n * tail claimable\".\n * - `recoveryGeneration`: Atomic raw-history recovery writer fence.\n * - `recoveryDocumentId`: Former server id for cross-client post-purge recreation.\n * - `pullContinuation`: Durable progress for the next bounded remote pull.\n * - `syncFailureMessage`, `syncFailureAttemptedAt`: The last terminal sync\n * failure or quarantined incoming update for this scope.\n * The durable write queue (queued rows of `documentHistoryUpdates`) has no\n * status columns, so these let the write-queue view and footer explain why\n * the document is blocked. `syncFailureMessage` is non-null exactly when a\n * failure is recorded; a newer failure replaces the old, and a later fully\n * validated sync pass, a remote reset, or the scope's teardown clears\n * both.\n * - `updatedAt`: Local timestamp for the last persisted runtime-state update.\n *\n * Indexes:\n * - `(appKind, localId)` is the primary key and scopes local document lookups.\n * - `(appKind, documentId) where documentId is not null` supports resolving a\n * server document id back to the local row during discovery and relinking.\n * - `(appKind, localId)` over records whose `pendingBaseVersion` differs from\n * a non-empty `snapshotEndVersion` serves the pending-write queue's\n * deferred-tail scan, which repeats that condition, so it reads only\n * unsettled records instead of every synced one.\n */\nexport const documents = sqliteTable(\n \"documents\",\n {\n appKind: text(\"app_kind\").notNull(),\n localId: text(\"local_id\").notNull(),\n documentId: text(\"document_id\"),\n accessEpoch: integer(\"access_epoch\").notNull().default(1),\n accessStateHash: text(\"access_state_hash\"),\n effectiveAccessLevel: text(accessLevelColumn).notNull().default(\"read\"),\n lastCommitLsn: text(\"last_commit_lsn\"),\n documentManifestBundle: text(\"document_manifest_bundle\"),\n contentKeyBundle: text(\"content_key_bundle\"),\n documentKekTargets: text(\"document_kek_targets\"),\n pendingBaseVersion: text(\"pending_base_version\"),\n pullContinuation: text(\"pull_continuation\"),\n recoveryGeneration: integer(\"recovery_generation\").notNull().default(0),\n recoveryDocumentId: text(\"recovery_document_id\"),\n snapshotEndVersion: text(\"snapshot_end_version\").notNull().default(\"\"),\n syncFailureMessage: text(\"sync_failure_message\"),\n syncFailureAttemptedAt: text(\"sync_failure_attempted_at\"),\n updatedAt: text(\"updated_at\").notNull(),\n },\n (table) => [\n primaryKey({ columns: [table.appKind, table.localId] }),\n index(\"documents_app_document_idx\")\n .on(table.appKind, table.documentId)\n .where(sql`${table.documentId} IS NOT NULL`),\n index(\"documents_deferred_tail_idx\")\n .on(table.appKind, table.localId)\n .where(\n sql`${table.snapshotEndVersion} <> '' AND ${table.pendingBaseVersion} IS NOT ${table.snapshotEndVersion}`,\n ),\n ],\n);\n\n/**\n * Full-history persistence for local documents (checkpoint + tail) — the ONLY\n * durable content source. Record rows in `documents` carry runtime metadata\n * and the content frontier (`snapshotEndVersion`), never content. The\n * checkpoint holds a full-history snapshot refreshed only at compaction, and\n * the tail appends every update (local deltas and decrypted remote updates)\n * written since. Restore = import checkpoint + replay tail; compaction =\n * export full history from the live doc, replace the checkpoint, clear the\n * tail — all bounded and amortized. Container metadata stores its content (an\n * exported-updates blob) as its checkpoint row, with no tail.\n */\nexport const documentHistoryCheckpoints = sqliteTable(\n \"document_history_checkpoints\",\n {\n appKind: text(\"app_kind\").notNull(),\n localId: text(\"local_id\").notNull(),\n snapshot: text(\"snapshot\").notNull(),\n endVersionVector: text(\"end_version_vector\").notNull(),\n revision: text(\"revision\").notNull(),\n updatedAt: text(\"updated_at\").notNull(),\n },\n (table) => [primaryKey({ columns: [table.appKind, table.localId] })],\n);\n\n/**\n * The local update log: one row per Loro update, serving as both the history\n * tail (restore = checkpoint + tail) and the outbound write queue.\n *\n * Every locally authored update is stored once. While it waits for sync it\n * carries an `updateId` (the id submitted to the server) and the version-vector\n * metadata the submission needs; settlement clears them, leaving the row as\n * ordinary tail history until compaction folds it into a checkpoint. Before a\n * send, a contiguous run of queued local rows may be replaced by one merged\n * row holding exactly their operations: the first row is updated in place\n * (same `id`, `createdAt` and `rowid`, so the same queue and replay position)\n * under a fresh `updateId`, and the other rows are deleted.\n *\n * Columns:\n * - `id`: Row id; tail compaction deletes by it.\n * - `appKind`, `localId`: Document scope matching `documents`.\n * - `updateData`: Serialized Loro update payload.\n * - `origin`: \"local\" (authored on this device) or \"remote\" (decrypted\n * pulled update) for tail rows. Restores use it to advance the\n * outgoing-delta marker across remote rows — their ops are already\n * server-side — while a local row left behind by a crash stays below the\n * marker so the next edit re-derives and sends it. \"outbox\" marks a queued\n * update with no tail role (container metadata, whose content is its\n * checkpoint, and full-state re-uploads after a remote reset); restores and\n * compaction never see it and settlement deletes it.\n * - `createdAt`: Insertion timestamp; with `rowid`, deterministic replay order.\n * - `updateId`: Present exactly while the row is queued for sync; rekeyed\n * after a lost acknowledgement poisons the submitted id, and replaced by a\n * fresh id when queued rows merge. An id never names two payloads.\n * - `partialStartVersionVector` / `partialEndVersionVector`: Version vectors\n * around a queued partial update.\n * - `sourceVersionVector`: Present on a queued rotation baseline checkpoint.\n * - `rekeyCount`: Durable bound on rekeys of a queued row; a merged row takes\n * the largest count among the rows it replaces.\n *\n * Invariant: compaction never deletes a queued row, so a checkpoint can cover\n * a queued update's operations without removing it from the queue.\n */\nexport const documentHistoryUpdates = sqliteTable(\n \"document_history_updates\",\n {\n id: text(\"id\"),\n appKind: text(\"app_kind\").notNull(),\n localId: text(\"local_id\").notNull(),\n updateData: text(\"update_data\").notNull(),\n origin: text(\"origin\").notNull(),\n createdAt: text(\"created_at\").notNull(),\n updateId: text(\"update_id\"),\n partialStartVersionVector: text(\"partial_start_version_vector\"),\n partialEndVersionVector: text(\"partial_end_version_vector\"),\n sourceVersionVector: text(\"source_version_vector\"),\n rekeyCount: integer(\"rekey_count\").notNull().default(0),\n },\n (table) => [\n primaryKey({ columns: [table.id] }),\n index(\"document_history_updates_scope_created_idx\").on(\n table.appKind,\n table.localId,\n table.createdAt,\n ),\n uniqueIndex(\"document_history_updates_update_id_idx\")\n .on(table.updateId)\n .where(sql`${table.updateId} IS NOT NULL`),\n // Queued rows only: pending counts and pending loads skip settled history.\n index(\"document_history_updates_queued_scope_idx\")\n .on(table.appKind, table.localId, table.createdAt)\n .where(sql`${table.updateId} IS NOT NULL`),\n ],\n);\n\nexport const documentTables: ReadonlyArray<SqlTableSchema> = [\n {\n ...defineSqlTableSchema(documents),\n requiredColumns: [\n \"pull_continuation\",\n \"recovery_generation\",\n \"recovery_document_id\",\n \"sync_failure_message\",\n \"sync_failure_attempted_at\",\n ],\n },\n defineSqlTableSchema(documentHistoryCheckpoints),\n {\n ...defineSqlTableSchema(documentHistoryUpdates),\n requiredColumns: [\"update_id\"],\n },\n];\n"]}
@@ -785,44 +785,6 @@ export declare const clientSQLiteSchema: {
785
785
  }, {}, {
786
786
  length: number | undefined;
787
787
  }>;
788
- signingPublicKey: import("drizzle-orm/sqlite-core").SQLiteColumn<{
789
- name: "signing_public_key";
790
- tableName: "organization_read_model_directory_users";
791
- dataType: "string";
792
- columnType: "SQLiteText";
793
- data: string;
794
- driverParam: string;
795
- notNull: true;
796
- hasDefault: false;
797
- isPrimaryKey: false;
798
- isAutoincrement: false;
799
- hasRuntimeDefault: false;
800
- enumValues: [string, ...string[]];
801
- baseColumn: never;
802
- identity: undefined;
803
- generated: undefined;
804
- }, {}, {
805
- length: number | undefined;
806
- }>;
807
- encapsulationPublicKey: import("drizzle-orm/sqlite-core").SQLiteColumn<{
808
- name: "encapsulation_public_key";
809
- tableName: "organization_read_model_directory_users";
810
- dataType: "string";
811
- columnType: "SQLiteText";
812
- data: string;
813
- driverParam: string;
814
- notNull: true;
815
- hasDefault: false;
816
- isPrimaryKey: false;
817
- isAutoincrement: false;
818
- hasRuntimeDefault: false;
819
- enumValues: [string, ...string[]];
820
- baseColumn: never;
821
- identity: undefined;
822
- generated: undefined;
823
- }, {}, {
824
- length: number | undefined;
825
- }>;
826
788
  encapsulationKeyFingerprint: import("drizzle-orm/sqlite-core").SQLiteColumn<{
827
789
  name: "encapsulation_key_fingerprint";
828
790
  tableName: "organization_read_model_directory_users";
@@ -4777,23 +4739,6 @@ export declare const clientSQLiteSchema: {
4777
4739
  }, {}, {
4778
4740
  length: number | undefined;
4779
4741
  }>;
4780
- syncFailureStatus: import("drizzle-orm/sqlite-core").SQLiteColumn<{
4781
- name: "sync_failure_status";
4782
- tableName: "documents";
4783
- dataType: "number";
4784
- columnType: "SQLiteInteger";
4785
- data: number;
4786
- driverParam: number;
4787
- notNull: false;
4788
- hasDefault: false;
4789
- isPrimaryKey: false;
4790
- isAutoincrement: false;
4791
- hasRuntimeDefault: false;
4792
- enumValues: undefined;
4793
- baseColumn: never;
4794
- identity: undefined;
4795
- generated: undefined;
4796
- }, {}, {}>;
4797
4742
  syncFailureMessage: import("drizzle-orm/sqlite-core").SQLiteColumn<{
4798
4743
  name: "sync_failure_message";
4799
4744
  tableName: "documents";
@@ -27,14 +27,15 @@ export const organizationReadModelRequesters = sqliteTable("organization_read_mo
27
27
  appliedCursor: text("applied_cursor").notNull(),
28
28
  updatedAt: text("updated_at").notNull(),
29
29
  }, (table) => [primaryKey({ columns: [table.organizationId, table.userId] })]);
30
- /** Normalized organization directory rows. `isSelf` is derived at read time. */
30
+ /**
31
+ * Normalized organization directory rows. `isSelf` is derived at read time.
32
+ * Rows keep key fingerprints only; keys come from the trusted identity store.
33
+ */
31
34
  export const organizationReadModelDirectoryUsers = sqliteTable("organization_read_model_directory_users", {
32
35
  organizationId: text("organization_id").notNull(),
33
36
  userId: text("user_id").notNull(),
34
37
  sortOrder: integer("sort_order").notNull(),
35
38
  signingKeyFingerprint: text("signing_key_fingerprint").notNull(),
36
- signingPublicKey: text("signing_public_key").notNull(),
37
- encapsulationPublicKey: text("encapsulation_public_key").notNull(),
38
39
  encapsulationKeyFingerprint: text("encapsulation_key_fingerprint").notNull(),
39
40
  isPersonalOrganizationOwner: integer("is_personal_organization_owner", {
40
41
  mode: "boolean",
@@ -1 +1 @@
1
- {"version":3,"file":"organizationReadModelSchema.js","sourceRoot":"","sources":["organizationReadModelSchema.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,OAAO,EACP,UAAU,EACV,WAAW,EACX,IAAI,GACL,MAAM,yBAAyB,CAAC;AAEjC;;;;G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ally projected organization: the\n * exact organization policy head, and the state hash of the reserved Members\n * group's membership head, which the group catalog does not list.\n */\nexport const organizationReadModelState = sqliteTable(\n \"organization_read_model_state\",\n {\n organizationId: text(\"organization_id\").notNull(),\n cursor: text(\"cursor\").notNull(),\n profileDocumentId: text(\"profile_document_id\"),\n memberGroupId: text(\"member_group_id\").notNull(),\n memberGroupStateHash: text(\"member_group_state_hash\").notNull(),\n organizationStateHash: text(\"organization_state_hash\").notNull(),\n organizationStateVersion: integer(\"organization_state_version\").notNull(),\n organizationKeyEpoch: integer(\"organization_key_epoch\").notNull(),\n organizationKeyFingerprint: text(\"organization_key_fingerprint\").notNull(),\n organizationMemberCount: integer(\"organization_member_count\").notNull(),\n updatedAt: text(\"updated_at\").notNull(),\n },\n (table) => [primaryKey({ columns: [table.organizationId] })],\n);\n\n/** Requester-scoped fields that must not become organization-global state. */\nexport const organizationReadModelRequesters = sqliteTable(\n \"organization_read_model_requesters\",\n {\n organizationId: text(\"organization_id\").notNull(),\n userId: text(\"user_id\").notNull(),\n isOrgAdmin: integer(\"is_org_admin\", { mode: \"boolean\" }).notNull(),\n // The response cursor this requester last applied. The organization row's\n // cursor proves only that some requester applied shared lanes.\n appliedCursor: text(\"applied_cursor\").notNull(),\n updatedAt: text(\"updated_at\").notNull(),\n },\n (table) => [primaryKey({ columns: [table.organizationId, table.userId] })],\n);\n\n/** Normalized organization directory rows. `isSelf` is derived at read time. */\nexport const organizationReadModelDirectoryUsers = sqliteTable(\n \"organization_read_model_directory_users\",\n {\n organizationId: text(\"organization_id\").notNull(),\n userId: text(\"user_id\").notNull(),\n sortOrder: integer(\"sort_order\").notNull(),\n signingKeyFingerprint: text(\"signing_key_fingerprint\").notNull(),\n signingPublicKey: text(\"signing_public_key\").notNull(),\n encapsulationPublicKey: text(\"encapsulation_public_key\").notNull(),\n encapsulationKeyFingerprint: text(\n \"encapsulation_key_fingerprint\",\n ).notNull(),\n isPersonalOrganizationOwner: integer(\"is_personal_organization_owner\", {\n mode: \"boolean\",\n }).notNull(),\n createdAt: text(\"created_at\").notNull(),\n status: text(\"status\").notNull(),\n profileDocumentId: text(\"profile_document_id\"),\n joinedAt: text(\"joined_at\").notNull(),\n updatedAt: text(\"updated_at\").notNull(),\n disabledAt: text(\"disabled_at\"),\n disabledByUserId: text(\"disabled_by_user_id\"),\n /** A pending leave request, as JSON, kept only once its signature verified. */\n leaveRequest: text(\"leave_request\"),\n },\n (table) => [primaryKey({ columns: [table.organizationId, table.userId] })],\n);\n\n/**\n * Normalized visible organization group summaries. The state columns are the\n * group's exact policy head, all null for a stateless group.\n * `members_state_hash` is the state hash of the membership head delivered for\n * the group, null until the groupMemberships lane covers it.\n */\nexport const organizationReadModelGroups = sqliteTable(\n \"organization_read_model_groups\",\n {\n organizationId: text(\"organization_id\").notNull(),\n groupId: text(\"group_id\").notNull(),\n sortOrder: integer(\"sort_order\").notNull(),\n name: text(\"name\").notNull(),\n createdAt: text(\"created_at\").notNull(),\n isBuiltin: integer(\"is_builtin\", { mode: \"boolean\" }).notNull(),\n stateHash: text(\"state_hash\"),\n stateVersion: integer(\"state_version\"),\n keyEpoch: integer(\"key_epoch\"),\n keyFingerprint: text(\"key_fingerprint\"),\n memberCount: integer(\"member_count\"),\n membersStateHash: text(\"members_state_hash\"),\n },\n (table) => [primaryKey({ columns: [table.organizationId, table.groupId] })],\n);\n\n/**\n * Direct users bound to the exact state of their group's membership head.\n * Public keys are not repeated here; the directory lane holds them per user.\n */\nexport const organizationReadModelGroupMembers = sqliteTable(\n \"organization_read_model_group_members\",\n {\n organizationId: text(\"organization_id\").notNull(),\n groupId: text(\"group_id\").notNull(),\n userId: text(\"user_id\").notNull(),\n sortOrder: integer(\"sort_order\").notNull(),\n stateHash: text(\"state_hash\").notNull(),\n role: text(\"role\").notNull(),\n },\n (table) => [\n primaryKey({\n columns: [table.organizationId, table.groupId, table.userId],\n }),\n ],\n);\n\n/**\n * Durable record of a server 403/404 for one requester's presentation\n * projection. Written before the revoked rows are purged so a purge failure\n * followed by an offline restart cannot serve the revoked projection; cleared\n * only by a successful authoritative reconcile for the same scope.\n */\nexport const organizationPresentationDenials = sqliteTable(\n \"organization_presentation_denials\",\n {\n organizationId: text(\"organization_id\").notNull(),\n requesterUserId: text(\"requester_user_id\").notNull(),\n projection: text(\"projection\").notNull(),\n deniedAt: text(\"denied_at\").notNull(),\n },\n (table) => [\n primaryKey({\n columns: [table.organizationId, table.requesterUserId, table.projection],\n }),\n ],\n);\n\n/** Whole-lane container grants used only by organization presentation reads. */\nexport const organizationReadModelContainerGrants = sqliteTable(\n \"organization_read_model_container_grants\",\n {\n organizationId: text(\"organization_id\").notNull(),\n containerId: text(\"container_id\").notNull(),\n subjectType: text(\"subject_type\").notNull(),\n subjectId: text(\"subject_id\").notNull(),\n sortOrder: integer(\"sort_order\").notNull(),\n accessLevel: text(\"access_level\").notNull(),\n createdAt: text(\"created_at\").notNull(),\n depth: integer(\"depth\").notNull(),\n isBuiltin: integer(\"is_builtin\", { mode: \"boolean\" }).notNull(),\n metadataAccessEpoch: integer(\"metadata_access_epoch\").notNull(),\n metadataAccessStateHash: text(\"metadata_access_state_hash\").notNull(),\n metadataDocumentId: text(\"metadata_document_id\"),\n parentId: text(\"parent_id\"),\n updatedAt: text(\"updated_at\").notNull(),\n userId: text(\"user_id\"),\n signingKeyFingerprint: text(\"signing_key_fingerprint\"),\n groupId: text(\"group_id\"),\n },\n (table) => [\n primaryKey({\n columns: [\n table.organizationId,\n table.containerId,\n table.subjectType,\n table.subjectId,\n ],\n }),\n ],\n);\n"]}
1
+ {"version":3,"file":"organizationReadModelSchema.js","sourceRoot":"","sources":["organizationReadModelSchema.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,OAAO,EACP,UAAU,EACV,WAAW,EACX,IAAI,GACL,MAAM,yBAAyB,CAAC;AAEjC;;;;GAIG;AACH,MAAM,CAAC,MAAM,0BAA0B,GAAG,WAAW,CACnD,+BAA+B,EAC/B;IACE,cAAc,EAAE,IAAI,CAAC,iBA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AE;IAC1C,WAAW,EAAE,IAAI,CAAC,cAAc,CAAC,CAAC,OAAO,EAAE;IAC3C,SAAS,EAAE,IAAI,CAAC,YAAY,CAAC,CAAC,OAAO,EAAE;IACvC,KAAK,EAAE,OAAO,CAAC,OAAO,CAAC,CAAC,OAAO,EAAE;IACjC,SAAS,EAAE,OAAO,CAAC,YAAY,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC,CAAC,OAAO,EAAE;IAC/D,mBAAmB,EAAE,OAAO,CAAC,uBAAuB,CAAC,CAAC,OAAO,EAAE;IAC/D,uBAAuB,EAAE,IAAI,CAAC,4BAA4B,CAAC,CAAC,OAAO,EAAE;IACrE,kBAAkB,EAAE,IAAI,CAAC,sBAAsB,CAAC;IAChD,QAAQ,EAAE,IAAI,CAAC,WAAW,CAAC;IAC3B,SAAS,EAAE,IAAI,CAAC,YAAY,CAAC,CAAC,OAAO,EAAE;IACvC,MAAM,EAAE,IAAI,CAAC,SAAS,CAAC;IACvB,qBAAqB,EAAE,IAAI,CAAC,yBAAyB,CAAC;IACtD,OAAO,EAAE,IAAI,CAAC,UAAU,CAAC;CAC1B,EACD,CAAC,KAAK,EAAE,EAAE,CAAC;IACT,UAAU,CAAC;QACT,OAAO,EAAE;YACP,KAAK,CAAC,cAAc;YACpB,KAAK,CAAC,WAAW;YACjB,KAAK,CAAC,WAAW;YACjB,KAAK,CAAC,SAAS;SAChB;KACF,CAAC;CACH,CACF,CAAC","sourcesContent":["import {\n integer,\n primaryKey,\n sqliteTable,\n text,\n} from \"drizzle-orm/sqlite-core\";\n\n/**\n * Cursor and lane-level fields for one locally projected organization: the\n * exact organization policy head, and the state hash of the reserved Members\n * group's membership head, which the group catalog does not list.\n */\nexport const organizationReadModelState = sqliteTable(\n \"organization_read_model_state\",\n {\n organizationId: text(\"organization_id\").notNull(),\n cursor: text(\"cursor\").notNull(),\n profileDocumentId: text(\"profile_document_id\"),\n memberGroupId: text(\"member_group_id\").notNull(),\n memberGroupStateHash: text(\"member_group_state_hash\").notNull(),\n organizationStateHash: text(\"organization_state_hash\").notNull(),\n organizationStateVersion: integer(\"organization_state_version\").notNull(),\n organizationKeyEpoch: integer(\"organization_key_epoch\").notNull(),\n organizationKeyFingerprint: text(\"organization_key_fingerprint\").notNull(),\n organizationMemberCount: integer(\"organization_member_count\").notNull(),\n updatedAt: text(\"updated_at\").notNull(),\n },\n (table) => [primaryKey({ columns: [table.organizationId] })],\n);\n\n/** Requester-scoped fields that must not become organization-global state. */\nexport const organizationReadModelRequesters = sqliteTable(\n \"organization_read_model_requesters\",\n {\n organizationId: text(\"organization_id\").notNull(),\n userId: text(\"user_id\").notNull(),\n isOrgAdmin: integer(\"is_org_admin\", { mode: \"boolean\" }).notNull(),\n // The response cursor this requester last applied. The organization row's\n // cursor proves only that some requester applied shared lanes.\n appliedCursor: text(\"applied_cursor\").notNull(),\n updatedAt: text(\"updated_at\").notNull(),\n },\n (table) => [primaryKey({ columns: [table.organizationId, table.userId] })],\n);\n\n/**\n * Normalized organization directory rows. `isSelf` is derived at read time.\n * Rows keep key fingerprints only; keys come from the trusted identity store.\n */\nexport const organizationReadModelDirectoryUsers = sqliteTable(\n \"organization_read_model_directory_users\",\n {\n organizationId: text(\"organization_id\").notNull(),\n userId: text(\"user_id\").notNull(),\n sortOrder: integer(\"sort_order\").notNull(),\n signingKeyFingerprint: text(\"signing_key_fingerprint\").notNull(),\n encapsulationKeyFingerprint: text(\n \"encapsulation_key_fingerprint\",\n ).notNull(),\n isPersonalOrganizationOwner: integer(\"is_personal_organization_owner\", {\n mode: \"boolean\",\n }).notNull(),\n createdAt: text(\"created_at\").notNull(),\n status: text(\"status\").notNull(),\n profileDocumentId: text(\"profile_document_id\"),\n joinedAt: text(\"joined_at\").notNull(),\n updatedAt: text(\"updated_at\").notNull(),\n disabledAt: text(\"disabled_at\"),\n disabledByUserId: text(\"disabled_by_user_id\"),\n /** A pending leave request, as JSON, kept only once its signature verified. */\n leaveRequest: text(\"leave_request\"),\n },\n (table) => [primaryKey({ columns: [table.organizationId, table.userId] })],\n);\n\n/**\n * Normalized visible organization group summaries. The state columns are the\n * group's exact policy head, all null for a stateless group.\n * `members_state_hash` is the state hash of the membership head delivered for\n * the group, null until the groupMemberships lane covers it.\n */\nexport const organizationReadModelGroups = sqliteTable(\n \"organization_read_model_groups\",\n {\n organizationId: text(\"organization_id\").notNull(),\n groupId: text(\"group_id\").notNull(),\n sortOrder: integer(\"sort_order\").notNull(),\n name: text(\"name\").notNull(),\n createdAt: text(\"created_at\").notNull(),\n isBuiltin: integer(\"is_builtin\", { mode: \"boolean\" }).notNull(),\n stateHash: text(\"state_hash\"),\n stateVersion: integer(\"state_version\"),\n keyEpoch: integer(\"key_epoch\"),\n keyFingerprint: text(\"key_fingerprint\"),\n memberCount: integer(\"member_count\"),\n membersStateHash: text(\"members_state_hash\"),\n },\n (table) => [primaryKey({ columns: [table.organizationId, table.groupId] })],\n);\n\n/**\n * Direct users bound to the exact state of their group's membership head.\n * Public keys are not repeated here; the directory lane holds them per user.\n */\nexport const organizationReadModelGroupMembers = sqliteTable(\n \"organization_read_model_group_members\",\n {\n organizationId: text(\"organization_id\").notNull(),\n groupId: text(\"group_id\").notNull(),\n userId: text(\"user_id\").notNull(),\n sortOrder: integer(\"sort_order\").notNull(),\n stateHash: text(\"state_hash\").notNull(),\n role: text(\"role\").notNull(),\n },\n (table) => [\n primaryKey({\n columns: [table.organizationId, table.groupId, table.userId],\n }),\n ],\n);\n\n/**\n * Durable record of a server 403/404 for one requester's presentation\n * projection. Written before the revoked rows are purged so a purge failure\n * followed by an offline restart cannot serve the revoked projection; cleared\n * only by a successful authoritative reconcile for the same scope.\n */\nexport const organizationPresentationDenials = sqliteTable(\n \"organization_presentation_denials\",\n {\n organizationId: text(\"organization_id\").notNull(),\n requesterUserId: text(\"requester_user_id\").notNull(),\n projection: text(\"projection\").notNull(),\n deniedAt: text(\"denied_at\").notNull(),\n },\n (table) => [\n primaryKey({\n columns: [table.organizationId, table.requesterUserId, table.projection],\n }),\n ],\n);\n\n/** Whole-lane container grants used only by organization presentation reads. */\nexport const organizationReadModelContainerGrants = sqliteTable(\n \"organization_read_model_container_grants\",\n {\n organizationId: text(\"organization_id\").notNull(),\n containerId: text(\"container_id\").notNull(),\n subjectType: text(\"subject_type\").notNull(),\n subjectId: text(\"subject_id\").notNull(),\n sortOrder: integer(\"sort_order\").notNull(),\n accessLevel: text(\"access_level\").notNull(),\n createdAt: text(\"created_at\").notNull(),\n depth: integer(\"depth\").notNull(),\n isBuiltin: integer(\"is_builtin\", { mode: \"boolean\" }).notNull(),\n metadataAccessEpoch: integer(\"metadata_access_epoch\").notNull(),\n metadataAccessStateHash: text(\"metadata_access_state_hash\").notNull(),\n metadataDocumentId: text(\"metadata_document_id\"),\n parentId: text(\"parent_id\"),\n updatedAt: text(\"updated_at\").notNull(),\n userId: text(\"user_id\"),\n signingKeyFingerprint: text(\"signing_key_fingerprint\"),\n groupId: text(\"group_id\"),\n },\n (table) => [\n primaryKey({\n columns: [\n table.organizationId,\n table.containerId,\n table.subjectType,\n table.subjectId,\n ],\n }),\n ],\n);\n"]}
@@ -389,44 +389,6 @@ export declare const organizationReadModelSQLiteSchema: {
389
389
  }, {}, {
390
390
  length: number | undefined;
391
391
  }>;
392
- signingPublicKey: import("drizzle-orm/sqlite-core").SQLiteColumn<{
393
- name: "signing_public_key";
394
- tableName: "organization_read_model_directory_users";
395
- dataType: "string";
396
- columnType: "SQLiteText";
397
- data: string;
398
- driverParam: string;
399
- notNull: true;
400
- hasDefault: false;
401
- isPrimaryKey: false;
402
- isAutoincrement: false;
403
- hasRuntimeDefault: false;
404
- enumValues: [string, ...string[]];
405
- baseColumn: never;
406
- identity: undefined;
407
- generated: undefined;
408
- }, {}, {
409
- length: number | undefined;
410
- }>;
411
- encapsulationPublicKey: import("drizzle-orm/sqlite-core").SQLiteColumn<{
412
- name: "encapsulation_public_key";
413
- tableName: "organization_read_model_directory_users";
414
- dataType: "string";
415
- columnType: "SQLiteText";
416
- data: string;
417
- driverParam: string;
418
- notNull: true;
419
- hasDefault: false;
420
- isPrimaryKey: false;
421
- isAutoincrement: false;
422
- hasRuntimeDefault: false;
423
- enumValues: [string, ...string[]];
424
- baseColumn: never;
425
- identity: undefined;
426
- generated: undefined;
427
- }, {}, {
428
- length: number | undefined;
429
- }>;
430
392
  encapsulationKeyFingerprint: import("drizzle-orm/sqlite-core").SQLiteColumn<{
431
393
  name: "encapsulation_key_fingerprint";
432
394
  tableName: "organization_read_model_directory_users";
@@ -2007,7 +2007,6 @@ export declare class ApiClient extends ApiClientAreas {
2007
2007
  disabledAt: string | null;
2008
2008
  disabledByUserId: string | null;
2009
2009
  encapsulationKeyFingerprint: string;
2010
- encapsulationPublicKey: string;
2011
2010
  isPersonalOrganizationOwner: boolean;
2012
2011
  isSelf: boolean;
2013
2012
  joinedAt: string;
@@ -2026,7 +2025,6 @@ export declare class ApiClient extends ApiClientAreas {
2026
2025
  } | null;
2027
2026
  profileDocumentId: string | null;
2028
2027
  signingKeyFingerprint: string;
2029
- signingPublicKey: string;
2030
2028
  status: "active" | "disabled";
2031
2029
  updatedAt: string;
2032
2030
  userId: string;
@@ -2048,11 +2046,7 @@ export declare class ApiClient extends ApiClientAreas {
2048
2046
  listOrganizationGroupMembers: (organizationId: string, groupId: string) => Promise<{
2049
2047
  groupId: string;
2050
2048
  members: {
2051
- encapsulationKeyFingerprint: string | null;
2052
- encapsulationPublicKey: string | null;
2053
2049
  role: "member" | "admin";
2054
- signingKeyFingerprint: string | null;
2055
- signingPublicKey: string | null;
2056
2050
  userId: string;
2057
2051
  }[];
2058
2052
  organizationId: string;
@@ -366,7 +366,6 @@ export declare class OrganizationArea {
366
366
  disabledAt: string | null;
367
367
  disabledByUserId: string | null;
368
368
  encapsulationKeyFingerprint: string;
369
- encapsulationPublicKey: string;
370
369
  isPersonalOrganizationOwner: boolean;
371
370
  isSelf: boolean;
372
371
  joinedAt: string;
@@ -385,7 +384,6 @@ export declare class OrganizationArea {
385
384
  } | null;
386
385
  profileDocumentId: string | null;
387
386
  signingKeyFingerprint: string;
388
- signingPublicKey: string;
389
387
  status: "active" | "disabled";
390
388
  updatedAt: string;
391
389
  userId: string;
@@ -409,11 +407,7 @@ export declare class OrganizationArea {
409
407
  listOrganizationGroupMembers(organizationId: string, groupId: string): Promise<{
410
408
  groupId: string;
411
409
  members: {
412
- encapsulationKeyFingerprint: string | null;
413
- encapsulationPublicKey: string | null;
414
410
  role: "member" | "admin";
415
- signingKeyFingerprint: string | null;
416
- signingPublicKey: string | null;
417
411
  userId: string;
418
412
  }[];
419
413
  organizationId: string;
@@ -6640,7 +6640,6 @@ export declare const getOrganizationReadModelOperation: Omit<{
6640
6640
  disabledAt: string | null;
6641
6641
  disabledByUserId: string | null;
6642
6642
  encapsulationKeyFingerprint: string;
6643
- encapsulationPublicKey: string;
6644
6643
  isPersonalOrganizationOwner: boolean;
6645
6644
  isSelf: boolean;
6646
6645
  joinedAt: string;
@@ -6659,7 +6658,6 @@ export declare const getOrganizationReadModelOperation: Omit<{
6659
6658
  } | null;
6660
6659
  profileDocumentId: string | null;
6661
6660
  signingKeyFingerprint: string;
6662
- signingPublicKey: string;
6663
6661
  status: "active" | "disabled";
6664
6662
  updatedAt: string;
6665
6663
  userId: string;
@@ -6668,7 +6666,6 @@ export declare const getOrganizationReadModelOperation: Omit<{
6668
6666
  disabledAt: string | null;
6669
6667
  disabledByUserId: string | null;
6670
6668
  encapsulationKeyFingerprint: string;
6671
- encapsulationPublicKey: string;
6672
6669
  isPersonalOrganizationOwner: boolean;
6673
6670
  isSelf: boolean;
6674
6671
  joinedAt: string;
@@ -6687,7 +6684,6 @@ export declare const getOrganizationReadModelOperation: Omit<{
6687
6684
  } | null;
6688
6685
  profileDocumentId: string | null;
6689
6686
  signingKeyFingerprint: string;
6690
- signingPublicKey: string;
6691
6687
  status: "active" | "disabled";
6692
6688
  updatedAt: string;
6693
6689
  userId: string;
@@ -6807,7 +6803,6 @@ export declare const getOrganizationReadModelOperation: Omit<{
6807
6803
  disabledAt: string | null;
6808
6804
  disabledByUserId: string | null;
6809
6805
  encapsulationKeyFingerprint: string;
6810
- encapsulationPublicKey: string;
6811
6806
  isPersonalOrganizationOwner: boolean;
6812
6807
  isSelf: boolean;
6813
6808
  joinedAt: string;
@@ -6826,7 +6821,6 @@ export declare const getOrganizationReadModelOperation: Omit<{
6826
6821
  } | null;
6827
6822
  profileDocumentId: string | null;
6828
6823
  signingKeyFingerprint: string;
6829
- signingPublicKey: string;
6830
6824
  status: "active" | "disabled";
6831
6825
  updatedAt: string;
6832
6826
  userId: string;
@@ -6835,7 +6829,6 @@ export declare const getOrganizationReadModelOperation: Omit<{
6835
6829
  disabledAt: string | null;
6836
6830
  disabledByUserId: string | null;
6837
6831
  encapsulationKeyFingerprint: string;
6838
- encapsulationPublicKey: string;
6839
6832
  isPersonalOrganizationOwner: boolean;
6840
6833
  isSelf: boolean;
6841
6834
  joinedAt: string;
@@ -6854,7 +6847,6 @@ export declare const getOrganizationReadModelOperation: Omit<{
6854
6847
  } | null;
6855
6848
  profileDocumentId: string | null;
6856
6849
  signingKeyFingerprint: string;
6857
- signingPublicKey: string;
6858
6850
  status: "active" | "disabled";
6859
6851
  updatedAt: string;
6860
6852
  userId: string;
@@ -8967,44 +8959,28 @@ export declare const listOrganizationGroupMembersOperation: Omit<{
8967
8959
  readonly 200: z.ZodType<{
8968
8960
  groupId: string;
8969
8961
  members: {
8970
- encapsulationKeyFingerprint: string | null;
8971
- encapsulationPublicKey: string | null;
8972
8962
  role: "member" | "admin";
8973
- signingKeyFingerprint: string | null;
8974
- signingPublicKey: string | null;
8975
8963
  userId: string;
8976
8964
  }[];
8977
8965
  organizationId: string;
8978
8966
  }, {
8979
8967
  groupId: string;
8980
8968
  members: {
8981
- encapsulationKeyFingerprint: string | null;
8982
- encapsulationPublicKey: string | null;
8983
8969
  role: "member" | "admin";
8984
- signingKeyFingerprint: string | null;
8985
- signingPublicKey: string | null;
8986
8970
  userId: string;
8987
8971
  }[];
8988
8972
  organizationId: string;
8989
8973
  }, z.core.$ZodTypeInternals<{
8990
8974
  groupId: string;
8991
8975
  members: {
8992
- encapsulationKeyFingerprint: string | null;
8993
- encapsulationPublicKey: string | null;
8994
8976
  role: "member" | "admin";
8995
- signingKeyFingerprint: string | null;
8996
- signingPublicKey: string | null;
8997
8977
  userId: string;
8998
8978
  }[];
8999
8979
  organizationId: string;
9000
8980
  }, {
9001
8981
  groupId: string;
9002
8982
  members: {
9003
- encapsulationKeyFingerprint: string | null;
9004
- encapsulationPublicKey: string | null;
9005
8983
  role: "member" | "admin";
9006
- signingKeyFingerprint: string | null;
9007
- signingPublicKey: string | null;
9008
8984
  userId: string;
9009
8985
  }[];
9010
8986
  organizationId: string;
@@ -9337,7 +9313,6 @@ export declare const updateOrganizationRosterEntryOperation: Omit<{
9337
9313
  disabledAt: string | null;
9338
9314
  disabledByUserId: string | null;
9339
9315
  encapsulationKeyFingerprint: string;
9340
- encapsulationPublicKey: string;
9341
9316
  isPersonalOrganizationOwner: boolean;
9342
9317
  isSelf: boolean;
9343
9318
  joinedAt: string;
@@ -9356,7 +9331,6 @@ export declare const updateOrganizationRosterEntryOperation: Omit<{
9356
9331
  } | null;
9357
9332
  profileDocumentId: string | null;
9358
9333
  signingKeyFingerprint: string;
9359
- signingPublicKey: string;
9360
9334
  status: "active" | "disabled";
9361
9335
  updatedAt: string;
9362
9336
  userId: string;
@@ -9365,7 +9339,6 @@ export declare const updateOrganizationRosterEntryOperation: Omit<{
9365
9339
  disabledAt: string | null;
9366
9340
  disabledByUserId: string | null;
9367
9341
  encapsulationKeyFingerprint: string;
9368
- encapsulationPublicKey: string;
9369
9342
  isPersonalOrganizationOwner: boolean;
9370
9343
  isSelf: boolean;
9371
9344
  joinedAt: string;
@@ -9384,7 +9357,6 @@ export declare const updateOrganizationRosterEntryOperation: Omit<{
9384
9357
  } | null;
9385
9358
  profileDocumentId: string | null;
9386
9359
  signingKeyFingerprint: string;
9387
- signingPublicKey: string;
9388
9360
  status: "active" | "disabled";
9389
9361
  updatedAt: string;
9390
9362
  userId: string;
@@ -9393,7 +9365,6 @@ export declare const updateOrganizationRosterEntryOperation: Omit<{
9393
9365
  disabledAt: string | null;
9394
9366
  disabledByUserId: string | null;
9395
9367
  encapsulationKeyFingerprint: string;
9396
- encapsulationPublicKey: string;
9397
9368
  isPersonalOrganizationOwner: boolean;
9398
9369
  isSelf: boolean;
9399
9370
  joinedAt: string;
@@ -9412,7 +9383,6 @@ export declare const updateOrganizationRosterEntryOperation: Omit<{
9412
9383
  } | null;
9413
9384
  profileDocumentId: string | null;
9414
9385
  signingKeyFingerprint: string;
9415
- signingPublicKey: string;
9416
9386
  status: "active" | "disabled";
9417
9387
  updatedAt: string;
9418
9388
  userId: string;
@@ -9421,7 +9391,6 @@ export declare const updateOrganizationRosterEntryOperation: Omit<{
9421
9391
  disabledAt: string | null;
9422
9392
  disabledByUserId: string | null;
9423
9393
  encapsulationKeyFingerprint: string;
9424
- encapsulationPublicKey: string;
9425
9394
  isPersonalOrganizationOwner: boolean;
9426
9395
  isSelf: boolean;
9427
9396
  joinedAt: string;
@@ -9440,7 +9409,6 @@ export declare const updateOrganizationRosterEntryOperation: Omit<{
9440
9409
  } | null;
9441
9410
  profileDocumentId: string | null;
9442
9411
  signingKeyFingerprint: string;
9443
- signingPublicKey: string;
9444
9412
  status: "active" | "disabled";
9445
9413
  updatedAt: string;
9446
9414
  userId: string;