@tearleads/client-sdk 0.1.43 → 0.1.45
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/client/containerDocumentDiscovery.js +71 -29
- package/client/containerDocumentDiscovery.js.map +1 -1
- package/client/deviceFirst.js +4 -5
- package/client/deviceFirst.js.map +1 -1
- package/data/persistence/container-contents/containerContentsPersistence.js +2 -3
- package/data/persistence/container-contents/containerContentsPersistence.js.map +1 -1
- package/data/persistence/container-contents/containerCreateIntentSettlement.js +16 -16
- package/data/persistence/container-contents/containerCreateIntentSettlement.js.map +1 -1
- package/data/persistence/container-contents/containerDeletionPersistence.js +5 -11
- package/data/persistence/container-contents/containerDeletionPersistence.js.map +1 -1
- package/data/persistence/container-contents/containerDocumentReassignment.js +13 -13
- package/data/persistence/container-contents/containerDocumentReassignment.js.map +1 -1
- package/data/persistence/container-contents/containerHydrationPersistence.js +7 -4
- package/data/persistence/container-contents/containerHydrationPersistence.js.map +1 -1
- package/data/persistence/container-contents/containerIntentPersistence.js +43 -42
- package/data/persistence/container-contents/containerIntentPersistence.js.map +1 -1
- package/data/persistence/container-contents/containerMetadataMutationPersistence.js +15 -20
- package/data/persistence/container-contents/containerMetadataMutationPersistence.js.map +1 -1
- package/data/persistence/container-contents/containerMoveAbandonPersistence.js +1 -6
- package/data/persistence/container-contents/containerMoveAbandonPersistence.js.map +1 -1
- package/data/persistence/container-contents/containerMoveIntentRows.js +9 -8
- package/data/persistence/container-contents/containerMoveIntentRows.js.map +1 -1
- package/data/persistence/container-contents/containerReconcilePersistence.js +4 -8
- package/data/persistence/container-contents/containerReconcilePersistence.js.map +1 -1
- package/data/persistence/container-contents/containerRecoveryPersistence.js +20 -19
- package/data/persistence/container-contents/containerRecoveryPersistence.js.map +1 -1
- package/data/persistence/container-contents/containerRemovalWork.js +10 -10
- package/data/persistence/container-contents/containerRemovalWork.js.map +1 -1
- package/data/persistence/container-contents/containerStructuralRepair.js +21 -44
- package/data/persistence/container-contents/containerStructuralRepair.js.map +1 -1
- package/data/persistence/container-contents/documentLinkRemovalRepair.js +12 -11
- package/data/persistence/container-contents/documentLinkRemovalRepair.js.map +1 -1
- package/data/persistence/container-contents/documentMoveIntentPersistence.js +53 -28
- package/data/persistence/container-contents/documentMoveIntentPersistence.js.map +1 -1
- package/data/persistence/container-contents/documentPlacementIntentEnqueue.js +9 -8
- package/data/persistence/container-contents/documentPlacementIntentEnqueue.js.map +1 -1
- package/data/persistence/container-contents/documentPurgePlacement.js +6 -6
- package/data/persistence/container-contents/documentPurgePlacement.js.map +1 -1
- package/data/persistence/container-contents/dormantContainerMetadata.js +1 -5
- package/data/persistence/container-contents/dormantContainerMetadata.js.map +1 -1
- package/data/persistence/container-contents/pendingContainerCreate.js +5 -5
- package/data/persistence/container-contents/pendingContainerCreate.js.map +1 -1
- package/data/persistence/containers/containerPersistence.js +10 -27
- package/data/persistence/containers/containerPersistence.js.map +1 -1
- package/data/persistence/containers/containerSyncWatermarkPersistence.d.ts +11 -3
- package/data/persistence/containers/containerSyncWatermarkPersistence.js +46 -58
- package/data/persistence/containers/containerSyncWatermarkPersistence.js.map +1 -1
- package/data/persistence/containers/documentContainerProjectionPersistence.js +2 -2
- package/data/persistence/containers/documentContainerProjectionPersistence.js.map +1 -1
- package/data/persistence/containers/documentPlacement.js +10 -10
- package/data/persistence/containers/documentPlacement.js.map +1 -1
- package/data/persistence/documents/internal/discardDocument.js +5 -5
- package/data/persistence/documents/internal/discardDocument.js.map +1 -1
- package/data/persistence/documents/internal/documentDeletionPersistence.js +7 -9
- package/data/persistence/documents/internal/documentDeletionPersistence.js.map +1 -1
- package/data/persistence/documents/internal/documentMutationPersistence.js +6 -8
- package/data/persistence/documents/internal/documentMutationPersistence.js.map +1 -1
- package/data/persistence/documents/internal/ensureDocumentsSchema.js +2 -2
- package/data/persistence/documents/internal/ensureDocumentsSchema.js.map +1 -1
- package/data/persistence/documents/internal/orphanSideRows.js +3 -22
- package/data/persistence/documents/internal/orphanSideRows.js.map +1 -1
- package/data/persistence/organizations/organizationDataUsagePersistence.js +31 -64
- package/data/persistence/organizations/organizationDataUsagePersistence.js.map +1 -1
- package/data/persistence/organizations/organizationReadModelPurge.js +1 -5
- package/data/persistence/organizations/organizationReadModelPurge.js.map +1 -1
- package/data/persistence/principalCurrentAcknowledgementPersistence.js +24 -17
- package/data/persistence/principalCurrentAcknowledgementPersistence.js.map +1 -1
- package/data/persistence/principalHistoryIncompleteRetention.js +3 -9
- package/data/persistence/principalHistoryIncompleteRetention.js.map +1 -1
- package/data/persistence/principalHistoryStagePersistence.d.ts +3 -9
- package/data/persistence/principalHistoryStagePersistence.js +15 -25
- package/data/persistence/principalHistoryStagePersistence.js.map +1 -1
- package/data/persistence/principalHistoryStageRetention.js +16 -15
- package/data/persistence/principalHistoryStageRetention.js.map +1 -1
- package/data/persistence/principalHistoryUnpublishedRetention.js +6 -13
- package/data/persistence/principalHistoryUnpublishedRetention.js.map +1 -1
- package/data/sqlite/containerSchema.d.ts +84 -180
- package/data/sqlite/containerSchema.js +14 -23
- package/data/sqlite/containerSchema.js.map +1 -1
- package/data/sqlite/documentPlacementIntentSchema.js +3 -50
- package/data/sqlite/documentPlacementIntentSchema.js.map +1 -1
- package/data/sqlite/documentSyncFailurePersistence.d.ts +16 -6
- package/data/sqlite/documentSyncFailurePersistence.js +44 -54
- package/data/sqlite/documentSyncFailurePersistence.js.map +1 -1
- package/data/sqlite/{documentPlacementIntentSchema.d.ts → localIntentSchema.d.ts} +162 -88
- package/data/sqlite/localIntentSchema.js +90 -0
- package/data/sqlite/localIntentSchema.js.map +1 -0
- package/data/sqlite/organizationDataUsageSchema.js +11 -17
- package/data/sqlite/organizationDataUsageSchema.js.map +1 -1
- package/data/sqlite/principalHistoryRetentionSchema.js +0 -15
- package/data/sqlite/principalHistoryRetentionSchema.js.map +1 -1
- package/data/sqlite/principalHistoryStageSchema.d.ts +44 -2
- package/data/sqlite/principalHistoryStageSchema.js +14 -2
- package/data/sqlite/principalHistoryStageSchema.js.map +1 -1
- package/data/sqlite/schema.d.ts +1019 -2284
- package/data/sqlite/schema.js +48 -169
- package/data/sqlite/schema.js.map +1 -1
- package/internal/api-client/ApiClient.d.ts +6 -34
- package/internal/api-client/ApiClient.js +8 -10
- package/internal/api-client/ApiClient.js.map +1 -1
- package/internal/api-client/apiRequestRuntime.d.ts +2 -0
- package/internal/api-client/apiRequestRuntime.js +4 -0
- package/internal/api-client/apiRequestRuntime.js.map +1 -1
- package/internal/api-client/requestInternals.js +7 -7
- package/internal/api-client/requestInternals.js.map +1 -1
- package/internal/api-client/routes/containers/reads.d.ts +13 -7
- package/internal/api-client/routes/containers/reads.js +36 -15
- package/internal/api-client/routes/containers/reads.js.map +1 -1
- package/internal/api-client/types.d.ts +1 -5
- package/internal/api-client/types.js.map +1 -1
- package/internal/validators/containerReadRefinements.js +15 -5
- package/internal/validators/containerReadRefinements.js.map +1 -1
- package/internal/validators/containerReadSchemas.d.ts +36 -0
- package/internal/validators/containerReadSchemas.js +64 -1
- package/internal/validators/containerReadSchemas.js.map +1 -1
- package/internal/validators/operation/containerReads.d.ts +118 -182
- package/internal/validators/operation/containerReads.js +20 -54
- package/internal/validators/operation/containerReads.js.map +1 -1
- package/internal/validators/operation/index.d.ts +1 -1
- package/internal/validators/operation/index.js +1 -1
- package/internal/validators/operation/index.js.map +1 -1
- package/internal/validators/operation/registry.d.ts +2 -2
- package/internal/validators/operation/registry.js +2 -2
- package/internal/validators/operation/registry.js.map +1 -1
- package/internal/validators/request/containerDocumentLanes.d.ts +23 -0
- package/internal/validators/request/containerDocumentLanes.js +23 -0
- package/internal/validators/request/containerDocumentLanes.js.map +1 -0
- package/internal/validators/request/containerParentLanes.js +5 -35
- package/internal/validators/request/containerParentLanes.js.map +1 -1
- package/internal/validators/request/index.d.ts +1 -0
- package/internal/validators/request/index.js +1 -0
- package/internal/validators/request/index.js.map +1 -1
- package/internal/validators/response/containerDocumentLanes.d.ts +82 -0
- package/internal/validators/response/containerDocumentLanes.js +35 -0
- package/internal/validators/response/containerDocumentLanes.js.map +1 -0
- package/internal/validators/response/containerParentLanes.js +3 -15
- package/internal/validators/response/containerParentLanes.js.map +1 -1
- package/internal/validators/response/index.d.ts +2 -1
- package/internal/validators/response/index.js +1 -1
- package/internal/validators/response/index.js.map +1 -1
- package/package.json +1 -1
- package/sync/reconciliation/knownContainerSweep.js +57 -54
- package/sync/reconciliation/knownContainerSweep.js.map +1 -1
- package/sync/reconciliation/reconcileContainer.js +49 -17
- package/sync/reconciliation/reconcileContainer.js.map +1 -1
- package/sync/reconciliation/service.js +44 -16
- package/sync/reconciliation/service.js.map +1 -1
- package/sync/reconciliation/serviceTypes.d.ts +23 -2
- package/sync/reconciliation/serviceTypes.js.map +1 -1
- package/workflows/container-contents/containerDocumentListing.js +92 -38
- package/workflows/container-contents/containerDocumentListing.js.map +1 -1
- package/workflows/container-contents/containerPersistence.d.ts +8 -2
- package/workflows/container-contents/containerPersistence.js +6 -7
- package/workflows/container-contents/containerPersistence.js.map +1 -1
- package/workflows/container-contents/documentDiscovery.d.ts +3 -3
- package/workflows/container-contents/documentDiscovery.js +24 -96
- package/workflows/container-contents/documentDiscovery.js.map +1 -1
- package/workflows/container-contents/documentDiscoveryApply.js +65 -0
- package/workflows/container-contents/documentDiscoveryApply.js.map +1 -0
- package/workflows/container-contents/documentDiscoveryLanes.js +53 -0
- package/workflows/container-contents/documentDiscoveryLanes.js.map +1 -0
- package/workflows/container-contents/documentDiscoveryTypes.d.ts +25 -19
- package/workflows/container-contents/documentDiscoveryTypes.js.map +1 -1
- package/workflows/container-contents/documentPriming.js +6 -10
- package/workflows/container-contents/documentPriming.js.map +1 -1
- package/workflows/container-contents/documentQueries/sql.js +11 -10
- package/workflows/container-contents/documentQueries/sql.js.map +1 -1
- package/workflows/container-contents/documentQueries.js +2 -2
- package/workflows/container-contents/documentQueries.js.map +1 -1
- package/workflows/container-contents/pendingDownloads.js +2 -5
- package/workflows/container-contents/pendingDownloads.js.map +1 -1
- package/workflows/container-contents/pendingWrites/deferredTails.js +3 -11
- package/workflows/container-contents/pendingWrites/deferredTails.js.map +1 -1
- package/workflows/container-contents/pendingWrites/sources.js +56 -80
- package/workflows/container-contents/pendingWrites/sources.js.map +1 -1
- package/workflows/container-contents/pendingWrites.js +6 -4
- package/workflows/container-contents/pendingWrites.js.map +1 -1
- package/workflows/container-contents/remoteContainerState.js +2 -1
- package/workflows/container-contents/remoteContainerState.js.map +1 -1
- package/workflows/container-contents/remoteHydration/laneFetchMarkers.js +11 -17
- package/workflows/container-contents/remoteHydration/laneFetchMarkers.js.map +1 -1
- package/workflows/sync/remoteReset.js +16 -23
- package/workflows/sync/remoteReset.js.map +1 -1
- package/workflows/sync/remoteResetCursorScope.js +10 -18
- package/workflows/sync/remoteResetCursorScope.js.map +1 -1
- package/workflows/sync/remoteResetPrincipalScope.js +1 -2
- package/workflows/sync/remoteResetPrincipalScope.js.map +1 -1
- package/workflows/sync/remoteResetScope.js +18 -18
- package/workflows/sync/remoteResetScope.js.map +1 -1
package/data/sqlite/schema.js
CHANGED
|
@@ -5,7 +5,8 @@ import { containerSQLiteSchema, containerTableSchemas, } from "./containerSchema
|
|
|
5
5
|
import { documentAttachmentBlobProjection, documentPendingAttachments, } from "./documentAttachmentSchema.js";
|
|
6
6
|
import { documentDiscoveryHeads, documentDiscoverySequence, pendingDocumentDiscoveries, } from "./documentDiscoveryEvidenceSchema.js";
|
|
7
7
|
import { documentOrphanBlobReclaims, documentOrphanBlobReclaimTable, } from "./documentOrphanBlobReclaims.js";
|
|
8
|
-
import { documentIntentLinkTargets
|
|
8
|
+
import { documentIntentLinkTargets } from "./documentPlacementIntentSchema.js";
|
|
9
|
+
import { localIntents } from "./localIntentSchema.js";
|
|
9
10
|
import * as organizationDataUsage from "./organizationDataUsageSchema.js";
|
|
10
11
|
import { organizationFounders } from "./organizationFounderSchema.js";
|
|
11
12
|
import * as provisioningAttempt from "./organizationProvisioningAttemptSchema.js";
|
|
@@ -13,16 +14,16 @@ import { organizationReadModelSQLiteSchema, organizationReadModelTables, } from
|
|
|
13
14
|
import { principalGrantRetirements } from "./principalGrantRetirementSchema.js";
|
|
14
15
|
import { principalHistoryEntries, principalHistoryEvidenceTables, principalHistoryNodes, principalHistoryPrefixes, } from "./principalHistoryEvidenceSchema.js";
|
|
15
16
|
import { principalHistoryNodeReferences, principalHistoryRootOwners, } from "./principalHistoryNodeRetentionSchema.js";
|
|
16
|
-
import {
|
|
17
|
+
import { principalKeyEnvelopeArchive } from "./principalHistoryRetentionSchema.js";
|
|
17
18
|
import { principalHistoryStages, principalHistoryStageTables, } from "./principalHistoryStageSchema.js";
|
|
18
19
|
import { principalMutationJournal, principalMutationJournalTables, } from "./principalMutationJournalSchema.js";
|
|
19
20
|
import { principalPolicies, principalPolicyBundleHistory, principalPolicyBundleReferences, principalPolicyCheckpoints, principalPolicyOrganizations, } from "./principalPolicySchema.js";
|
|
20
21
|
import { securityIncidents, securityIncidentTable, } from "./securityIncidentSchema.js";
|
|
21
22
|
import { defineSqlTableSchema } from "./sqlTableSchema.js";
|
|
22
23
|
import { verifiedAccessManifestBundles, verifiedManifestBundleTables, } from "./verifiedManifestBundleSchema.js";
|
|
23
|
-
export { containerHydrationTombstones,
|
|
24
|
+
export { containerHydrationTombstones, containers, dormantContainerMetadata, dormantMetadataSweepRequests, supersededContainerBindings, } from "./containerSchema.js";
|
|
24
25
|
export { documentAttachmentBlobProjection, documentPendingAttachments, } from "./documentAttachmentSchema.js";
|
|
25
|
-
export {
|
|
26
|
+
export { inContainerIntentLanes, inLocalIntentLane, LOCAL_INTENT_LANES, LOCAL_INTENT_SUBJECT, localIntents, } from "./localIntentSchema.js";
|
|
26
27
|
export { principalPolicies, principalPolicyBundleHistory, principalPolicyBundleReferences, principalPolicyCheckpoints, principalPolicyOrganizations, } from "./principalPolicySchema.js";
|
|
27
28
|
export { securityIncidents } from "./securityIncidentSchema.js";
|
|
28
29
|
export { containerDocumentTombstoneHolds, organizationReadModelTables };
|
|
@@ -64,6 +65,14 @@ const accessLevelColumn = "effective_access_level";
|
|
|
64
65
|
* - `recoveryGeneration`: Atomic raw-history recovery writer fence.
|
|
65
66
|
* - `recoveryDocumentId`: Former server id for cross-client post-purge recreation.
|
|
66
67
|
* - `pullContinuation`: Durable progress for the next bounded remote pull.
|
|
68
|
+
* - `syncFailureStatus`, `syncFailureMessage`, `syncFailureAttemptedAt`: The
|
|
69
|
+
* last terminal sync failure or quarantined incoming update for this scope.
|
|
70
|
+
* The durable write queue (queued rows of `documentHistoryUpdates`) has no
|
|
71
|
+
* status columns, so these let the write-queue view and footer explain why
|
|
72
|
+
* the document is blocked. `syncFailureMessage` is non-null exactly when a
|
|
73
|
+
* failure is recorded; a newer failure replaces the old, and a later fully
|
|
74
|
+
* validated sync pass, a remote reset, or the scope's teardown clears all
|
|
75
|
+
* three.
|
|
67
76
|
* - `updatedAt`: Local timestamp for the last persisted runtime-state update.
|
|
68
77
|
*
|
|
69
78
|
* Indexes:
|
|
@@ -87,6 +96,9 @@ export const documents = sqliteTable("documents", {
|
|
|
87
96
|
recoveryGeneration: integer("recovery_generation").notNull().default(0),
|
|
88
97
|
recoveryDocumentId: text("recovery_document_id"),
|
|
89
98
|
snapshotEndVersion: text("snapshot_end_version").notNull().default(""),
|
|
99
|
+
syncFailureStatus: integer("sync_failure_status"),
|
|
100
|
+
syncFailureMessage: text("sync_failure_message"),
|
|
101
|
+
syncFailureAttemptedAt: text("sync_failure_attempted_at"),
|
|
90
102
|
updatedAt: text("updated_at").notNull(),
|
|
91
103
|
}, (table) => [
|
|
92
104
|
primaryKey({ columns: [table.appKind, table.localId] }),
|
|
@@ -94,33 +106,6 @@ export const documents = sqliteTable("documents", {
|
|
|
94
106
|
.on(table.appKind, table.documentId)
|
|
95
107
|
.where(sql `${table.documentId} IS NOT NULL`),
|
|
96
108
|
]);
|
|
97
|
-
/**
|
|
98
|
-
* Last terminal sync failure or quarantined incoming update per document scope.
|
|
99
|
-
*
|
|
100
|
-
* The durable write queue (queued rows of `documentHistoryUpdates`) has no
|
|
101
|
-
* status columns — a row is either queued or settled. Terminal submissions and
|
|
102
|
-
* incoming updates that cannot be decrypted or imported are recorded here so
|
|
103
|
-
* the write-queue view and footer can surface why the document is blocked.
|
|
104
|
-
* Rows are upserted per scope and deleted only after a later fully validated
|
|
105
|
-
* sync pass succeeds or the scope's local state is torn down.
|
|
106
|
-
*
|
|
107
|
-
* Columns:
|
|
108
|
-
* - `appKind`: Local document namespace matching `documents.appKind`.
|
|
109
|
-
* - `localId`: Local document id matching `documents.localId`.
|
|
110
|
-
* - `status`: HTTP status of the failed submission when known.
|
|
111
|
-
* - `message`: Human-readable failure description for queue display.
|
|
112
|
-
* - `attemptedAt`: Timestamp of the failed attempt.
|
|
113
|
-
*
|
|
114
|
-
* Indexes:
|
|
115
|
-
* - `(appKind, localId)` is the primary key and keeps one failure per scope.
|
|
116
|
-
*/
|
|
117
|
-
export const documentSyncFailures = sqliteTable("document_sync_failures", {
|
|
118
|
-
appKind: text("app_kind").notNull(),
|
|
119
|
-
localId: text("local_id").notNull(),
|
|
120
|
-
status: integer("status"),
|
|
121
|
-
message: text("message").notNull(),
|
|
122
|
-
attemptedAt: text("attempted_at").notNull(),
|
|
123
|
-
}, (table) => [primaryKey({ columns: [table.appKind, table.localId] })]);
|
|
124
109
|
/**
|
|
125
110
|
* Full-history persistence for local documents (checkpoint + tail) — the ONLY
|
|
126
111
|
* durable content source. Record rows in `documents` carry runtime metadata
|
|
@@ -366,139 +351,39 @@ export const documentProjectionText = sqliteTable("document_projection_text", {
|
|
|
366
351
|
text: text("text").notNull(),
|
|
367
352
|
}, (table) => [primaryKey({ columns: [table.localId] })]);
|
|
368
353
|
/**
|
|
369
|
-
*
|
|
370
|
-
*
|
|
371
|
-
* A user can create a local container before the API has assigned all remote
|
|
372
|
-
* state for the container and its metadata document. This table keeps the sync
|
|
373
|
-
* intent until container-create sync either records the remote ids or stores an
|
|
374
|
-
* error for retry.
|
|
375
|
-
*
|
|
376
|
-
* Columns:
|
|
377
|
-
* - `id`: Client-generated intent id.
|
|
378
|
-
* - `containerId`: Local container id created optimistically.
|
|
379
|
-
* - `parentContainerId`: Parent container id used when the intent is sent.
|
|
380
|
-
* - `intentType`: Intent discriminator, currently `container.create`.
|
|
381
|
-
* - `syncStatus`: Current sync state, currently `pending` or `synced`.
|
|
382
|
-
* - `remoteContainerId`: Remote container id recorded after successful sync.
|
|
383
|
-
* - `remoteMetadataDocumentId`: Remote metadata document id recorded after
|
|
384
|
-
* successful sync.
|
|
385
|
-
* - `remoteMetadataAccessStateHash`: Access state hash for the synced metadata
|
|
386
|
-
* document.
|
|
387
|
-
* - `lastError`: Last sync error message for retry/debug display.
|
|
388
|
-
* - `createdAt`: Intent creation timestamp used for FIFO sync.
|
|
389
|
-
* - `updatedAt`: Local timestamp for the latest status/error change.
|
|
390
|
-
*
|
|
391
|
-
* Indexes:
|
|
392
|
-
* - `id` is the primary key.
|
|
393
|
-
* - `containerId` is unique so each local container has one create intent.
|
|
394
|
-
* - `(syncStatus, createdAt)` supports listing pending intents in creation
|
|
395
|
-
* order.
|
|
396
|
-
*/
|
|
397
|
-
export const containerCreateIntents = sqliteTable("container_create_intents", {
|
|
398
|
-
id: text("id"),
|
|
399
|
-
containerId: text("container_id").notNull().unique(),
|
|
400
|
-
parentContainerId: text("parent_container_id").notNull(),
|
|
401
|
-
intentType: text("intent_type").notNull(),
|
|
402
|
-
syncStatus: text("sync_status").notNull(),
|
|
403
|
-
remoteContainerId: text("remote_container_id"),
|
|
404
|
-
remoteMetadataDocumentId: text("remote_metadata_document_id"),
|
|
405
|
-
remoteMetadataAccessStateHash: text("remote_metadata_access_state_hash"),
|
|
406
|
-
lastError: text("last_error"),
|
|
407
|
-
lastAttemptedAt: text("last_attempted_at"),
|
|
408
|
-
createdAt: text("created_at").notNull(),
|
|
409
|
-
updatedAt: text("updated_at").notNull(),
|
|
410
|
-
}, (table) => [
|
|
411
|
-
primaryKey({ columns: [table.id] }),
|
|
412
|
-
index("container_create_intents_status_created_idx").on(table.syncStatus, table.createdAt),
|
|
413
|
-
]);
|
|
414
|
-
/**
|
|
415
|
-
* Offline move queue for synced containers.
|
|
416
|
-
*
|
|
417
|
-
* A user can move a container whose server identity is already known while the
|
|
418
|
-
* API or writer context is unavailable. This table stores only the desired
|
|
419
|
-
* final parent and replay diagnostics; the signed move request is rebuilt from
|
|
420
|
-
* current writer projections when sync resumes.
|
|
421
|
-
*
|
|
422
|
-
* Columns:
|
|
423
|
-
* - `id`: Client-generated intent id.
|
|
424
|
-
* - `containerId`: Synced container moved optimistically in the local tree.
|
|
425
|
-
* - `parentContainerId`: Desired final parent container id.
|
|
426
|
-
* - `previousParentContainerId`: Parent observed when the move was queued.
|
|
427
|
-
* - `intentType`: Intent discriminator, currently `container.move`.
|
|
428
|
-
* - `syncStatus`: Current sync state, currently `pending` or `blocked`.
|
|
429
|
-
* - `lastError`: Last sync error message for retry/debug display.
|
|
430
|
-
* - `lastAttemptedAt`: Timestamp of the last replay attempt.
|
|
431
|
-
* - `createdAt`: Intent creation timestamp used for FIFO sync.
|
|
432
|
-
* - `updatedAt`: Local timestamp for the latest target/status/error change.
|
|
433
|
-
*
|
|
434
|
-
* Indexes:
|
|
435
|
-
* - `id` is the primary key.
|
|
436
|
-
* - `containerId` is unique so same-container moves coalesce to one intent.
|
|
437
|
-
* - `(syncStatus, createdAt)` supports listing pending intents in queue order.
|
|
438
|
-
*/
|
|
439
|
-
export const containerMoveIntents = sqliteTable("container_move_intents", {
|
|
440
|
-
id: text("id"),
|
|
441
|
-
containerId: text("container_id").notNull().unique(),
|
|
442
|
-
parentContainerId: text("parent_container_id").notNull(),
|
|
443
|
-
previousParentContainerId: text("previous_parent_container_id"),
|
|
444
|
-
intentType: text("intent_type").notNull(),
|
|
445
|
-
syncStatus: text("sync_status").notNull(),
|
|
446
|
-
lastError: text("last_error"),
|
|
447
|
-
lastAttemptedAt: text("last_attempted_at"),
|
|
448
|
-
createdAt: text("created_at").notNull(),
|
|
449
|
-
updatedAt: text("updated_at").notNull(),
|
|
450
|
-
}, (table) => [
|
|
451
|
-
primaryKey({ columns: [table.id] }),
|
|
452
|
-
index("container_move_intents_status_created_idx").on(table.syncStatus, table.createdAt),
|
|
453
|
-
]);
|
|
454
|
-
/**
|
|
455
|
-
* Per-lane sync cursors for container data.
|
|
354
|
+
* Per-lane sync state for container data: the server cursor and the local
|
|
355
|
+
* freshness marker share one row per lane.
|
|
456
356
|
*
|
|
457
357
|
* Container sync is split into lanes, such as a parent-container child lane or
|
|
458
|
-
* a container-document membership lane.
|
|
459
|
-
*
|
|
460
|
-
*
|
|
358
|
+
* a container-document membership lane. The cursor lets the next request
|
|
359
|
+
* resume without replaying the entire tree. The freshness marker records the
|
|
360
|
+
* last fully drained check independently of the cursor: empty server
|
|
361
|
+
* responses do not always carry a new watermark, but startup still needs to
|
|
362
|
+
* know that it recently checked the lane before polling again.
|
|
461
363
|
*
|
|
462
364
|
* Columns:
|
|
463
365
|
* - `laneKind`: Sync lane category, such as `container_parent` or
|
|
464
366
|
* `container_documents`.
|
|
465
367
|
* - `laneId`: Lane identity. Root parent sync uses `root`, child sync uses a
|
|
466
368
|
* parent-prefixed container id, and document lanes use the container id.
|
|
467
|
-
* - `watermarkUpdatedAt`: Server `updatedAt` value for the stored watermark
|
|
468
|
-
*
|
|
369
|
+
* - `watermarkUpdatedAt`: Server `updatedAt` value for the stored watermark;
|
|
370
|
+
* null until a watermark is saved.
|
|
371
|
+
* - `watermarkId`: Server id tie-breaker for the stored watermark; null
|
|
372
|
+
* exactly when `watermarkUpdatedAt` is.
|
|
469
373
|
* - `updatedAt`: Local timestamp for when the cursor was saved.
|
|
374
|
+
* - `checkedAt`: Local timestamp for the most recent fully drained lane check;
|
|
375
|
+
* null until one completes.
|
|
470
376
|
*
|
|
471
377
|
* Indexes:
|
|
472
|
-
* - `(laneKind, laneId)` is the primary key and stores one
|
|
378
|
+
* - `(laneKind, laneId)` is the primary key and stores one row per lane.
|
|
473
379
|
*/
|
|
474
380
|
export const containerSyncWatermarks = sqliteTable("container_sync_watermarks", {
|
|
475
381
|
laneKind: text("lane_kind").notNull(),
|
|
476
382
|
laneId: text("lane_id").notNull(),
|
|
477
|
-
watermarkUpdatedAt: text("watermark_updated_at")
|
|
478
|
-
watermarkId: text("watermark_id")
|
|
479
|
-
updatedAt: text("updated_at")
|
|
480
|
-
|
|
481
|
-
/**
|
|
482
|
-
* Local freshness markers for container sync lanes.
|
|
483
|
-
*
|
|
484
|
-
* These rows track the last successful API check for a lane independently from
|
|
485
|
-
* server watermarks. Empty server responses do not always include a new
|
|
486
|
-
* watermark, but the client still needs to remember that it recently checked
|
|
487
|
-
* the lane so startup can use cached container state without polling every
|
|
488
|
-
* time a container tree opens.
|
|
489
|
-
*
|
|
490
|
-
* Columns:
|
|
491
|
-
* - `laneKind`: Sync lane category matching `containerSyncWatermarks`.
|
|
492
|
-
* - `laneId`: Lane identity matching `containerSyncWatermarks`.
|
|
493
|
-
* - `checkedAt`: Local timestamp for the most recent successful lane check.
|
|
494
|
-
*
|
|
495
|
-
* Indexes:
|
|
496
|
-
* - `(laneKind, laneId)` is the primary key and stores one marker per lane.
|
|
497
|
-
*/
|
|
498
|
-
export const containerSyncLaneChecks = sqliteTable("container_sync_lane_checks", {
|
|
499
|
-
laneKind: text("lane_kind").notNull(),
|
|
500
|
-
laneId: text("lane_id").notNull(),
|
|
501
|
-
checkedAt: text("checked_at").notNull(),
|
|
383
|
+
watermarkUpdatedAt: text("watermark_updated_at"),
|
|
384
|
+
watermarkId: text("watermark_id"),
|
|
385
|
+
updatedAt: text("updated_at"),
|
|
386
|
+
checkedAt: text("checked_at"),
|
|
502
387
|
}, (table) => [primaryKey({ columns: [table.laneKind, table.laneId] })]);
|
|
503
388
|
export const documentTables = [
|
|
504
389
|
{
|
|
@@ -507,9 +392,11 @@ export const documentTables = [
|
|
|
507
392
|
"pull_continuation",
|
|
508
393
|
"recovery_generation",
|
|
509
394
|
"recovery_document_id",
|
|
395
|
+
"sync_failure_status",
|
|
396
|
+
"sync_failure_message",
|
|
397
|
+
"sync_failure_attempted_at",
|
|
510
398
|
],
|
|
511
399
|
},
|
|
512
|
-
defineSqlTableSchema(documentSyncFailures),
|
|
513
400
|
defineSqlTableSchema(documentHistoryCheckpoints),
|
|
514
401
|
{
|
|
515
402
|
...defineSqlTableSchema(documentHistoryUpdates),
|
|
@@ -557,8 +444,11 @@ export const documentContainerProjectionTables = [
|
|
|
557
444
|
},
|
|
558
445
|
defineSqlTableSchema(documentDiscoverySequence),
|
|
559
446
|
];
|
|
560
|
-
export const
|
|
561
|
-
defineSqlTableSchema(
|
|
447
|
+
export const localIntentTables = [
|
|
448
|
+
defineSqlTableSchema(localIntents),
|
|
449
|
+
];
|
|
450
|
+
export const documentPlacementIntentTables = [
|
|
451
|
+
...localIntentTables,
|
|
562
452
|
defineSqlTableSchema(documentIntentLinkTargets),
|
|
563
453
|
];
|
|
564
454
|
export const documentProjectionTables = [
|
|
@@ -574,15 +464,11 @@ export const documentProjectionTables = [
|
|
|
574
464
|
},
|
|
575
465
|
documentOrphanBlobReclaimTable,
|
|
576
466
|
];
|
|
577
|
-
export const containerCreateIntentTables = [
|
|
578
|
-
defineSqlTableSchema(containerCreateIntents),
|
|
579
|
-
];
|
|
580
|
-
export const containerMoveIntentTables = [
|
|
581
|
-
defineSqlTableSchema(containerMoveIntents),
|
|
582
|
-
];
|
|
583
467
|
export const containerSyncWatermarkTables = [
|
|
584
|
-
|
|
585
|
-
|
|
468
|
+
{
|
|
469
|
+
...defineSqlTableSchema(containerSyncWatermarks),
|
|
470
|
+
requiredColumns: ["checked_at"],
|
|
471
|
+
},
|
|
586
472
|
];
|
|
587
473
|
export const clientSqlTables = [
|
|
588
474
|
...principalMutationJournalTables,
|
|
@@ -594,10 +480,8 @@ export const clientSqlTables = [
|
|
|
594
480
|
...securityIncidentTables,
|
|
595
481
|
...containerTables,
|
|
596
482
|
...documentContainerProjectionTables,
|
|
597
|
-
...
|
|
483
|
+
...documentPlacementIntentTables,
|
|
598
484
|
...documentProjectionTables,
|
|
599
|
-
...containerCreateIntentTables,
|
|
600
|
-
...containerMoveIntentTables,
|
|
601
485
|
...containerSyncWatermarkTables,
|
|
602
486
|
...organizationReadModelTables,
|
|
603
487
|
...organizationDataUsage.organizationDataUsageTables,
|
|
@@ -606,7 +490,6 @@ export const clientSqlTables = [
|
|
|
606
490
|
export const clientSQLiteSchema = {
|
|
607
491
|
principalHistoryNodeReferences,
|
|
608
492
|
principalHistoryRootOwners,
|
|
609
|
-
principalHistoryStageScopes,
|
|
610
493
|
principalKeyEnvelopeArchive,
|
|
611
494
|
principalMutationJournal,
|
|
612
495
|
principalHistoryEntries,
|
|
@@ -616,7 +499,6 @@ export const clientSQLiteSchema = {
|
|
|
616
499
|
organizationFounders,
|
|
617
500
|
principalGrantRetirements,
|
|
618
501
|
documents,
|
|
619
|
-
documentSyncFailures,
|
|
620
502
|
principalPolicies,
|
|
621
503
|
principalPolicyBundleHistory,
|
|
622
504
|
principalPolicyBundleReferences,
|
|
@@ -629,15 +511,12 @@ export const clientSQLiteSchema = {
|
|
|
629
511
|
securityIncidents,
|
|
630
512
|
...containerSQLiteSchema,
|
|
631
513
|
documentContainerProjection,
|
|
632
|
-
|
|
514
|
+
localIntents,
|
|
633
515
|
documentIntentLinkTargets,
|
|
634
516
|
documentProjection,
|
|
635
517
|
documentPendingAttachments,
|
|
636
518
|
documentAttachmentBlobProjection,
|
|
637
519
|
documentOrphanBlobReclaims: documentOrphanBlobReclaims,
|
|
638
|
-
containerCreateIntents,
|
|
639
|
-
containerMoveIntents,
|
|
640
|
-
containerSyncLaneChecks,
|
|
641
520
|
containerSyncWatermarks,
|
|
642
521
|
...organizationReadModelSQLiteSchema,
|
|
643
522
|
...organizationDataUsage.organizationDataUsageSQLiteSchema,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schema.js","sourceRoot":"","sources":["schema.ts"],"names":[],"mappings":"AAAA,OAAO,E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AAG,qBAAqB;IACxB,GAAG,sBAAsB;IACzB,GAAG,4BAA4B;IAC/B,GAAG,4BAA4B;IAC/B,GAAG,sBAAsB;IACzB,GAAG,eAAe;IAClB,GAAG,iCAAiC;IACpC,GAAG,wBAAwB;IAC3B,GAAG,wBAAwB;IAC3B,GAAG,2BAA2B;IAC9B,GAAG,yBAAyB;IAC5B,GAAG,4BAA4B;IAC/B,GAAG,2BAA2B;IAC9B,GAAG,qBAAqB,CAAC,2BAA2B;IACpD,GAAG,mBAAmB,CAAC,qCAAqC;CAC7D,CAAC;AAEF,MAAM,CAAC,MAAM,kBAAkB,GAAG;IAChC,8BAA8B;IAC9B,0BAA0B;IAC1B,2BAA2B;IAC3B,2BAA2B;IAC3B,wBAAwB;IACxB,uBAAuB;IACvB,qBAAqB;IACrB,wBAAwB;IACxB,sBAAsB;IACtB,oBAAoB;IACpB,yBAAyB;IACzB,SAAS;IACT,oBAAoB;IACpB,iBAAiB;IACjB,4BAA4B;IAC5B,+BAA+B;IAC/B,4BAA4B;IAC5B,yBAAyB;IACzB,wBAAwB;IACxB,0BAA0B;IAC1B,6BAA6B;IAC7B,uBAAuB;IACvB,iBAAiB;IACjB,GAAG,qBAAqB;IACxB,2BAA2B;IAC3B,mBAAmB;IACnB,yBAAyB;IACzB,kBAAkB;IAClB,0BAA0B;IAC1B,gCAAgC;IAChC,0BAA0B,EAAE,0BAA0B;IACtD,sBAAsB;IACtB,oBAAoB;IACpB,uBAAuB;IACvB,uBAAuB;IACvB,GAAG,iCAAiC;IACpC,GAAG,qBAAqB,CAAC,iCAAiC;IAC1D,GAAG,mBAAmB,CAAC,2CAA2C;CACnE,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 { containerDocumentTombstoneHolds } from \"./containerDocumentTombstoneHoldSchema\";\nimport {\n containerSQLiteSchema,\n containerTableSchemas,\n} from \"./containerSchema\";\nimport {\n documentAttachmentBlobProjection,\n documentPendingAttachments,\n} from \"./documentAttachmentSchema\";\nimport {\n documentDiscoveryHeads,\n documentDiscoverySequence,\n pendingDocumentDiscoveries,\n} from \"./documentDiscoveryEvidenceSchema\";\nimport {\n documentOrphanBlobReclaims,\n documentOrphanBlobReclaimTable,\n} from \"./documentOrphanBlobReclaims\";\nimport {\n documentIntentLinkTargets,\n documentMoveIntents,\n} from \"./documentPlacementIntentSchema\";\nimport * as organizationDataUsage from \"./organizationDataUsageSchema\";\nimport { organizationFounders } from \"./organizationFounderSchema\";\nimport * as provisioningAttempt from \"./organizationProvisioningAttemptSchema\";\nimport {\n organizationReadModelSQLiteSchema,\n organizationReadModelTables,\n} from \"./organizationReadModelTableRegistry\";\nimport { principalGrantRetirements } from \"./principalGrantRetirementSchema\";\nimport {\n principalHistoryEntries,\n principalHistoryEvidenceTables,\n principalHistoryNodes,\n principalHistoryPrefixes,\n} from \"./principalHistoryEvidenceSchema\";\nimport {\n principalHistoryNodeReferences,\n principalHistoryRootOwners,\n} from \"./principalHistoryNodeRetentionSchema\";\nimport {\n principalHistoryStageScopes,\n principalKeyEnvelopeArchive,\n} from \"./principalHistoryRetentionSchema\";\nimport {\n principalHistoryStages,\n principalHistoryStageTables,\n} from \"./principalHistoryStageSchema\";\nimport {\n principalMutationJournal,\n principalMutationJournalTables,\n} from \"./principalMutationJournalSchema\";\nimport {\n principalPolicies,\n principalPolicyBundleHistory,\n principalPolicyBundleReferences,\n principalPolicyCheckpoints,\n principalPolicyOrganizations,\n} from \"./principalPolicySchema\";\nimport {\n securityIncidents,\n securityIncidentTable,\n} from \"./securityIncidentSchema\";\nimport { defineSqlTableSchema, type SqlTableSchema } from \"./sqlTableSchema\";\nimport {\n verifiedAccessManifestBundles,\n verifiedManifestBundleTables,\n} from \"./verifiedManifestBundleSchema\";\n\nexport {\n containerHydrationTombstones,\n containerProjection,\n containers,\n dormantContainerMetadata,\n dormantMetadataSweepRequests,\n supersededContainerBindings,\n} from \"./containerSchema\";\nexport {\n documentAttachmentBlobProjection,\n documentPendingAttachments,\n} from \"./documentAttachmentSchema\";\nexport { documentMoveIntents } from \"./documentPlacementIntentSchema\";\nexport {\n principalPolicies,\n principalPolicyBundleHistory,\n principalPolicyBundleReferences,\n principalPolicyCheckpoints,\n principalPolicyOrganizations,\n} from \"./principalPolicySchema\";\nexport { securityIncidents } from \"./securityIncidentSchema\";\nexport { containerDocumentTombstoneHolds, organizationReadModelTables };\n\nconst accessLevelColumn = \"effective_access_level\";\n\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 * - `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 */\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 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 ],\n);\n\n/**\n * Last terminal sync failure or quarantined incoming update per document scope.\n *\n * The durable write queue (queued rows of `documentHistoryUpdates`) has no\n * status columns — a row is either queued or settled. Terminal submissions and\n * incoming updates that cannot be decrypted or imported are recorded here so\n * the write-queue view and footer can surface why the document is blocked.\n * Rows are upserted per scope and deleted only after a later fully validated\n * sync pass succeeds or the scope's local state is torn down.\n *\n * Columns:\n * - `appKind`: Local document namespace matching `documents.appKind`.\n * - `localId`: Local document id matching `documents.localId`.\n * - `status`: HTTP status of the failed submission when known.\n * - `message`: Human-readable failure description for queue display.\n * - `attemptedAt`: Timestamp of the failed attempt.\n *\n * Indexes:\n * - `(appKind, localId)` is the primary key and keeps one failure per scope.\n */\nexport const documentSyncFailures = sqliteTable(\n \"document_sync_failures\",\n {\n appKind: text(\"app_kind\").notNull(),\n localId: text(\"local_id\").notNull(),\n status: integer(\"status\"),\n message: text(\"message\").notNull(),\n attemptedAt: text(\"attempted_at\").notNull(),\n },\n (table) => [primaryKey({ columns: [table.appKind, table.localId] })],\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.\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.\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.\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 ],\n);\n\n/**\n * Anti-rollback pin for verified access manifests.\n *\n * Records the highest access-manifest epoch this client has verified for each\n * object, so a later projection that serves an older epoch (rollback) or a\n * conflicting manifest at the same epoch (equivocation) is detected before any\n * key is unwrapped. Updated monotonically after a projection verifies cleanly.\n *\n * Columns:\n * - `objectKind`: Access object kind (`container`, `document`, ...).\n * - `organizationId`: Organization boundary that owns the object.\n * - `objectId`: Stable object id.\n * - `epoch`: Highest verified manifest epoch.\n * - `manifestHash`: Manifest hash pinned at that epoch.\n * - `updatedAt`: Local timestamp for the pin.\n *\n * Indexes:\n * - `(objectKind, organizationId, objectId)` is the primary key and gives one\n * pin per object.\n */\nexport const accessManifestCheckpoints = sqliteTable(\n \"access_manifest_checkpoints\",\n {\n objectKind: text(\"object_kind\").notNull(),\n organizationId: text(\"organization_id\").notNull(),\n objectId: text(\"object_id\").notNull(),\n epoch: integer(\"epoch\").notNull(),\n manifestHash: text(\"manifest_hash\").notNull(),\n updatedAt: text(\"updated_at\").notNull(),\n },\n (table) => [\n primaryKey({\n columns: [table.objectKind, table.organizationId, table.objectId],\n }),\n ],\n);\n\n/**\n * Durable terminal pins for documents whose signed purge proof was verified.\n * These survive remote-state resets so a dishonest API cannot later replay the\n * pre-purge writer projection and resurrect locally deleted content.\n */\nexport const documentPurgeCheckpoints = sqliteTable(\n \"document_purge_checkpoints\",\n {\n documentId: text(\"document_id\").primaryKey(),\n organizationId: text(\"organization_id\").notNull(),\n documentManifestHash: text(\"document_manifest_hash\").notNull(),\n purgeEventHash: text(\"purge_event_hash\").notNull(),\n updatedAt: text(\"updated_at\").notNull(),\n },\n);\n\n/**\n * Durable trust-on-first-use pins for remote user identity bundles.\n *\n * The first validated identity observed for a user in a configured API trust\n * domain is inserted once. Later observations must match every suite, public\n * key, and fingerprint exactly; the persistence adapter never updates these\n * rows. `firstSeenAt` records when the local trust decision was made and is\n * likewise immutable.\n *\n * Indexes:\n * - `(identityTrustDomain, userId)` is the primary key and scopes a user pin to\n * the host-configured API authority that supplied it.\n * - `(identityTrustDomain, signingKeyFingerprint)` binds the reverse identity\n * mapping durably, including across session recreation. There is no\n * migration for a table that already violates it. Earlier builds pinned a\n * registration's user id before the server confirmed it, so a device that\n * ran one may hold two users on one key; deployments are greenfield, and\n * such a device clears its local data, which recreates this table empty. A\n * device that used an environment before a reset does the same (see\n * docs/developer/greenfield-reset.md).\n */\nexport const trustedUserIdentityPins = sqliteTable(\n \"trusted_user_identity_pins\",\n {\n identityTrustDomain: text(\"identity_trust_domain\").notNull(),\n userId: text(\"user_id\").notNull(),\n formatVersion: integer(\"format_version\").notNull(),\n signingSuite: text(\"signing_suite\").notNull(),\n signingPublicKey: text(\"signing_public_key\").notNull(),\n signingKeyFingerprint: text(\"signing_key_fingerprint\").notNull(),\n encapsulationSuite: text(\"encapsulation_suite\").notNull(),\n encapsulationPublicKey: text(\"encapsulation_public_key\").notNull(),\n encapsulationKeyFingerprint: text(\n \"encapsulation_key_fingerprint\",\n ).notNull(),\n firstSeenAt: text(\"first_seen_at\").notNull(),\n },\n (table) => [\n primaryKey({\n columns: [table.identityTrustDomain, table.userId],\n }),\n uniqueIndex(\"trusted_user_identity_pins_domain_signing_fingerprint_idx\").on(\n table.identityTrustDomain,\n table.signingKeyFingerprint,\n ),\n ],\n);\n\n/**\n * Local many-to-many projection between documents and containers.\n *\n * The document summary row stores one selected `containerId` for primary list\n * placement, while this table keeps the full set of linked containers returned\n * by container/document sync. Removing a container deletes its links and may\n * repair affected document summary rows to point at another remaining link.\n *\n * Columns:\n * - `documentId`: Server document id whose container links are projected.\n * - `containerId`: Linked container id.\n * - `updatedAt`: Local timestamp for the last replacement of the link set.\n *\n * Indexes:\n * - `(documentId, containerId)` is the primary key and prevents duplicate\n * links for the same document/container pair.\n */\nexport const documentContainerProjection = sqliteTable(\n \"document_container_projection\",\n {\n documentId: text(\"document_id\").notNull(),\n containerId: text(\"container_id\").notNull(),\n updatedAt: text(\"updated_at\").notNull(),\n },\n (table) => [primaryKey({ columns: [table.documentId, table.containerId] })],\n);\n\n/**\n * Queryable document summary and detail projection.\n *\n * The durable Loro state lives in `documents`. This table stores the fields the\n * app needs for document lists, summaries, and fast detail hydration without\n * opening the full Loro snapshot on every read.\n *\n * Columns:\n * - `localId`: Stable local document id. This joins to `documents.localId` for\n * rows where `documents.appKind = documents`.\n * - `documentId`: Server document id when known.\n * - `containerId`: Selected container for primary document placement, or\n * `null` if the document is not currently linked to a visible container.\n * - `organizationId`: Last-known owning organization. Stamped from the\n * container row when the document is detached because its container was\n * removed locally (e.g. access to a shared org was revoked and the container\n * tombstoned), so pending writes keep their org attribution after the\n * `containers` join source disappears. Read as a fallback only — a live\n * container join always wins.\n * - `documentKind`: Stored document kind. Defaults to `note`.\n * - `title`: Plain projected title. Defaults to the note fallback title.\n * - `updatedAt`: Timestamp used for document list ordering.\n *\n * The projected full text lives in `documentProjectionText`, keyed by the same\n * `localId`. Keeping it out of this row keeps list/window scans narrow: the\n * sidebar and summary queries read titles and placement from rows whose size\n * does not grow with document content.\n *\n * Indexes:\n * - `localId` is the primary key for document projection lookups.\n * - `(containerId) where containerId is not null` serves container-scoped\n * window/count scans without walking the whole table.\n * - `(organizationId) where containerId is null` serves the orphan-recovery\n * existence and window scans.\n * - `(documentId) where documentId is not null` serves the linked-placement\n * join from `documentContainerProjection` and server-id lookups.\n */\nexport const documentProjection = sqliteTable(\n \"document_projection\",\n {\n localId: text(\"local_id\"),\n documentId: text(\"document_id\"),\n containerId: text(\"container_id\"),\n organizationId: text(\"organization_id\"),\n documentKind: text(\"document_kind\").notNull().default(\"note\"),\n title: text(\"title\").notNull().default(\"Untitled note\"),\n updatedAt: text(\"updated_at\").notNull(),\n },\n (table) => [\n primaryKey({ columns: [table.localId] }),\n index(\"document_projection_container_idx\")\n .on(table.containerId)\n .where(sql`${table.containerId} IS NOT NULL`),\n index(\"document_projection_orphan_organization_idx\")\n .on(table.organizationId)\n .where(sql`${table.containerId} IS NULL`),\n index(\"document_projection_document_idx\")\n .on(table.documentId)\n .where(sql`${table.documentId} IS NOT NULL`),\n ],\n);\n\n/**\n * Projected document text, split from `documentProjection` so content size\n * never bloats the rows that list/window queries scan. Loaded only by detail\n * reads (`loadDocument`) and the save-timestamp change check.\n *\n * Columns:\n * - `localId`: Stable local document id, matching `documentProjection.localId`.\n * - `text`: Plain projected text used to rebuild summaries/details.\n */\nexport const documentProjectionText = sqliteTable(\n \"document_projection_text\",\n {\n localId: text(\"local_id\"),\n text: text(\"text\").notNull(),\n },\n (table) => [primaryKey({ columns: [table.localId] })],\n);\n\n/**\n * Offline create queue for containers.\n *\n * A user can create a local container before the API has assigned all remote\n * state for the container and its metadata document. This table keeps the sync\n * intent until container-create sync either records the remote ids or stores an\n * error for retry.\n *\n * Columns:\n * - `id`: Client-generated intent id.\n * - `containerId`: Local container id created optimistically.\n * - `parentContainerId`: Parent container id used when the intent is sent.\n * - `intentType`: Intent discriminator, currently `container.create`.\n * - `syncStatus`: Current sync state, currently `pending` or `synced`.\n * - `remoteContainerId`: Remote container id recorded after successful sync.\n * - `remoteMetadataDocumentId`: Remote metadata document id recorded after\n * successful sync.\n * - `remoteMetadataAccessStateHash`: Access state hash for the synced metadata\n * document.\n * - `lastError`: Last sync error message for retry/debug display.\n * - `createdAt`: Intent creation timestamp used for FIFO sync.\n * - `updatedAt`: Local timestamp for the latest status/error change.\n *\n * Indexes:\n * - `id` is the primary key.\n * - `containerId` is unique so each local container has one create intent.\n * - `(syncStatus, createdAt)` supports listing pending intents in creation\n * order.\n */\nexport const containerCreateIntents = sqliteTable(\n \"container_create_intents\",\n {\n id: text(\"id\"),\n containerId: text(\"container_id\").notNull().unique(),\n parentContainerId: text(\"parent_container_id\").notNull(),\n intentType: text(\"intent_type\").notNull(),\n syncStatus: text(\"sync_status\").notNull(),\n remoteContainerId: text(\"remote_container_id\"),\n remoteMetadataDocumentId: text(\"remote_metadata_document_id\"),\n remoteMetadataAccessStateHash: text(\"remote_metadata_access_state_hash\"),\n lastError: text(\"last_error\"),\n lastAttemptedAt: text(\"last_attempted_at\"),\n createdAt: text(\"created_at\").notNull(),\n updatedAt: text(\"updated_at\").notNull(),\n },\n (table) => [\n primaryKey({ columns: [table.id] }),\n index(\"container_create_intents_status_created_idx\").on(\n table.syncStatus,\n table.createdAt,\n ),\n ],\n);\n\n/**\n * Offline move queue for synced containers.\n *\n * A user can move a container whose server identity is already known while the\n * API or writer context is unavailable. This table stores only the desired\n * final parent and replay diagnostics; the signed move request is rebuilt from\n * current writer projections when sync resumes.\n *\n * Columns:\n * - `id`: Client-generated intent id.\n * - `containerId`: Synced container moved optimistically in the local tree.\n * - `parentContainerId`: Desired final parent container id.\n * - `previousParentContainerId`: Parent observed when the move was queued.\n * - `intentType`: Intent discriminator, currently `container.move`.\n * - `syncStatus`: Current sync state, currently `pending` or `blocked`.\n * - `lastError`: Last sync error message for retry/debug display.\n * - `lastAttemptedAt`: Timestamp of the last replay attempt.\n * - `createdAt`: Intent creation timestamp used for FIFO sync.\n * - `updatedAt`: Local timestamp for the latest target/status/error change.\n *\n * Indexes:\n * - `id` is the primary key.\n * - `containerId` is unique so same-container moves coalesce to one intent.\n * - `(syncStatus, createdAt)` supports listing pending intents in queue order.\n */\nexport const containerMoveIntents = sqliteTable(\n \"container_move_intents\",\n {\n id: text(\"id\"),\n containerId: text(\"container_id\").notNull().unique(),\n parentContainerId: text(\"parent_container_id\").notNull(),\n previousParentContainerId: text(\"previous_parent_container_id\"),\n intentType: text(\"intent_type\").notNull(),\n syncStatus: text(\"sync_status\").notNull(),\n lastError: text(\"last_error\"),\n lastAttemptedAt: text(\"last_attempted_at\"),\n createdAt: text(\"created_at\").notNull(),\n updatedAt: text(\"updated_at\").notNull(),\n },\n (table) => [\n primaryKey({ columns: [table.id] }),\n index(\"container_move_intents_status_created_idx\").on(\n table.syncStatus,\n table.createdAt,\n ),\n ],\n);\n\n/**\n * Per-lane sync cursors for container data.\n *\n * Container sync is split into lanes, such as a parent-container child lane or\n * a container-document membership lane. This table stores the last accepted\n * server watermark for each lane so the next sync request can resume without\n * replaying the entire tree.\n *\n * Columns:\n * - `laneKind`: Sync lane category, such as `container_parent` or\n * `container_documents`.\n * - `laneId`: Lane identity. Root parent sync uses `root`, child sync uses a\n * parent-prefixed container id, and document lanes use the container id.\n * - `watermarkUpdatedAt`: Server `updatedAt` value for the stored watermark.\n * - `watermarkId`: Server id tie-breaker for the stored watermark.\n * - `updatedAt`: Local timestamp for when the cursor was saved.\n *\n * Indexes:\n * - `(laneKind, laneId)` is the primary key and stores one cursor per lane.\n */\nexport const containerSyncWatermarks = sqliteTable(\n \"container_sync_watermarks\",\n {\n laneKind: text(\"lane_kind\").notNull(),\n laneId: text(\"lane_id\").notNull(),\n watermarkUpdatedAt: text(\"watermark_updated_at\").notNull(),\n watermarkId: text(\"watermark_id\").notNull(),\n updatedAt: text(\"updated_at\").notNull(),\n },\n (table) => [primaryKey({ columns: [table.laneKind, table.laneId] })],\n);\n\n/**\n * Local freshness markers for container sync lanes.\n *\n * These rows track the last successful API check for a lane independently from\n * server watermarks. Empty server responses do not always include a new\n * watermark, but the client still needs to remember that it recently checked\n * the lane so startup can use cached container state without polling every\n * time a container tree opens.\n *\n * Columns:\n * - `laneKind`: Sync lane category matching `containerSyncWatermarks`.\n * - `laneId`: Lane identity matching `containerSyncWatermarks`.\n * - `checkedAt`: Local timestamp for the most recent successful lane check.\n *\n * Indexes:\n * - `(laneKind, laneId)` is the primary key and stores one marker per lane.\n */\nexport const containerSyncLaneChecks = sqliteTable(\n \"container_sync_lane_checks\",\n {\n laneKind: text(\"lane_kind\").notNull(),\n laneId: text(\"lane_id\").notNull(),\n checkedAt: text(\"checked_at\").notNull(),\n },\n (table) => [primaryKey({ columns: [table.laneKind, table.laneId] })],\n);\n\nexport const documentTables: ReadonlyArray<SqlTableSchema> = [\n {\n ...defineSqlTableSchema(documents),\n requiredColumns: [\n \"pull_continuation\",\n \"recovery_generation\",\n \"recovery_document_id\",\n ],\n },\n defineSqlTableSchema(documentSyncFailures),\n defineSqlTableSchema(documentHistoryCheckpoints),\n {\n ...defineSqlTableSchema(documentHistoryUpdates),\n requiredColumns: [\"update_id\"],\n },\n];\n\nexport const principalPolicyTables: ReadonlyArray<SqlTableSchema> = [\n {\n ...defineSqlTableSchema(principalPolicies),\n requiredColumns: [\"current_grants_json\"],\n },\n {\n ...defineSqlTableSchema(principalPolicyBundleHistory),\n requiredColumns: [\"current_grants_json\"],\n },\n defineSqlTableSchema(principalPolicyBundleReferences),\n defineSqlTableSchema(principalPolicyOrganizations),\n ...principalHistoryStageTables,\n ...principalHistoryEvidenceTables,\n];\n\nexport const keyingCheckpointTables: ReadonlyArray<SqlTableSchema> = [\n defineSqlTableSchema(organizationFounders),\n defineSqlTableSchema(accessManifestCheckpoints),\n defineSqlTableSchema(principalGrantRetirements),\n defineSqlTableSchema(documentPurgeCheckpoints),\n defineSqlTableSchema(principalPolicyCheckpoints),\n];\n\nexport const trustedUserIdentityPinTables: ReadonlyArray<SqlTableSchema> = [\n defineSqlTableSchema(trustedUserIdentityPins),\n];\n\nconst securityIncidentTables: ReadonlyArray<SqlTableSchema> = [\n securityIncidentTable,\n];\n\nexport const containerTables = containerTableSchemas;\n\nexport const documentContainerProjectionTables: ReadonlyArray<SqlTableSchema> =\n [\n defineSqlTableSchema(documentContainerProjection),\n {\n ...defineSqlTableSchema(containerDocumentTombstoneHolds),\n requiredColumns: [\"hidden\"],\n },\n defineSqlTableSchema(pendingDocumentDiscoveries),\n {\n ...defineSqlTableSchema(documentDiscoveryHeads),\n requiredColumns: [\"organization_id\"],\n },\n defineSqlTableSchema(documentDiscoverySequence),\n ];\n\nexport const documentMoveIntentTables: ReadonlyArray<SqlTableSchema> = [\n defineSqlTableSchema(documentMoveIntents),\n defineSqlTableSchema(documentIntentLinkTargets),\n];\n\nexport const documentProjectionTables: ReadonlyArray<SqlTableSchema> = [\n defineSqlTableSchema(documentProjection),\n defineSqlTableSchema(documentProjectionText),\n {\n ...defineSqlTableSchema(documentPendingAttachments),\n requiredColumns: [\"content_sha256\"],\n },\n {\n ...defineSqlTableSchema(documentAttachmentBlobProjection),\n requiredColumns: [\"content_sha256\"],\n },\n documentOrphanBlobReclaimTable,\n];\n\nexport const containerCreateIntentTables: ReadonlyArray<SqlTableSchema> = [\n defineSqlTableSchema(containerCreateIntents),\n];\n\nexport const containerMoveIntentTables: ReadonlyArray<SqlTableSchema> = [\n defineSqlTableSchema(containerMoveIntents),\n];\n\nexport const containerSyncWatermarkTables: ReadonlyArray<SqlTableSchema> = [\n defineSqlTableSchema(containerSyncWatermarks),\n defineSqlTableSchema(containerSyncLaneChecks),\n];\n\nexport const clientSqlTables: ReadonlyArray<SqlTableSchema> = [\n ...principalMutationJournalTables,\n ...documentTables,\n ...principalPolicyTables,\n ...keyingCheckpointTables,\n ...verifiedManifestBundleTables,\n ...trustedUserIdentityPinTables,\n ...securityIncidentTables,\n ...containerTables,\n ...documentContainerProjectionTables,\n ...documentMoveIntentTables,\n ...documentProjectionTables,\n ...containerCreateIntentTables,\n ...containerMoveIntentTables,\n ...containerSyncWatermarkTables,\n ...organizationReadModelTables,\n ...organizationDataUsage.organizationDataUsageTables,\n ...provisioningAttempt.organizationProvisioningAttemptTables,\n];\n\nexport const clientSQLiteSchema = {\n principalHistoryNodeReferences,\n principalHistoryRootOwners,\n principalHistoryStageScopes,\n principalKeyEnvelopeArchive,\n principalMutationJournal,\n principalHistoryEntries,\n principalHistoryNodes,\n principalHistoryPrefixes,\n principalHistoryStages,\n organizationFounders,\n principalGrantRetirements,\n documents,\n documentSyncFailures,\n principalPolicies,\n principalPolicyBundleHistory,\n principalPolicyBundleReferences,\n principalPolicyOrganizations,\n accessManifestCheckpoints,\n documentPurgeCheckpoints,\n principalPolicyCheckpoints,\n verifiedAccessManifestBundles,\n trustedUserIdentityPins,\n securityIncidents,\n ...containerSQLiteSchema,\n documentContainerProjection,\n documentMoveIntents,\n documentIntentLinkTargets,\n documentProjection,\n documentPendingAttachments,\n documentAttachmentBlobProjection,\n documentOrphanBlobReclaims: documentOrphanBlobReclaims,\n containerCreateIntents,\n containerMoveIntents,\n containerSyncLaneChecks,\n containerSyncWatermarks,\n ...organizationReadModelSQLiteSchema,\n ...organizationDataUsage.organizationDataUsageSQLiteSchema,\n ...provisioningAttempt.organizationProvisioningAttemptSQLiteSchema,\n};\n"]}
|
|
1
|
+
{"version":3,"file":"schema.js","sourceRoot":"","sources":["schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,aAAa,CAAC;AAClC,OAAO,EACL,KAAK,EACL,OAAO,EACP,UAAU,EACV,WAAW,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BAA2B;IAC3B,wBAAwB;IACxB,uBAAuB;IACvB,qBAAqB;IACrB,wBAAwB;IACxB,sBAAsB;IACtB,oBAAoB;IACpB,yBAAyB;IACzB,SAAS;IACT,iBAAiB;IACjB,4BAA4B;IAC5B,+BAA+B;IAC/B,4BAA4B;IAC5B,yBAAyB;IACzB,wBAAwB;IACxB,0BAA0B;IAC1B,6BAA6B;IAC7B,uBAAuB;IACvB,iBAAiB;IACjB,GAAG,qBAAqB;IACxB,2BAA2B;IAC3B,YAAY;IACZ,yBAAyB;IACzB,kBAAkB;IAClB,0BAA0B;IAC1B,gCAAgC;IAChC,0BAA0B,EAAE,0BAA0B;IACtD,uBAAuB;IACvB,GAAG,iCAAiC;IACpC,GAAG,qBAAqB,CAAC,iCAAiC;IAC1D,GAAG,mBAAmB,CAAC,2CAA2C;CACnE,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 { containerDocumentTombstoneHolds } from \"./containerDocumentTombstoneHoldSchema\";\nimport {\n containerSQLiteSchema,\n containerTableSchemas,\n} from \"./containerSchema\";\nimport {\n documentAttachmentBlobProjection,\n documentPendingAttachments,\n} from \"./documentAttachmentSchema\";\nimport {\n documentDiscoveryHeads,\n documentDiscoverySequence,\n pendingDocumentDiscoveries,\n} from \"./documentDiscoveryEvidenceSchema\";\nimport {\n documentOrphanBlobReclaims,\n documentOrphanBlobReclaimTable,\n} from \"./documentOrphanBlobReclaims\";\nimport { documentIntentLinkTargets } from \"./documentPlacementIntentSchema\";\nimport { localIntents } from \"./localIntentSchema\";\nimport * as organizationDataUsage from \"./organizationDataUsageSchema\";\nimport { organizationFounders } from \"./organizationFounderSchema\";\nimport * as provisioningAttempt from \"./organizationProvisioningAttemptSchema\";\nimport {\n organizationReadModelSQLiteSchema,\n organizationReadModelTables,\n} from \"./organizationReadModelTableRegistry\";\nimport { principalGrantRetirements } from \"./principalGrantRetirementSchema\";\nimport {\n principalHistoryEntries,\n principalHistoryEvidenceTables,\n principalHistoryNodes,\n principalHistoryPrefixes,\n} from \"./principalHistoryEvidenceSchema\";\nimport {\n principalHistoryNodeReferences,\n principalHistoryRootOwners,\n} from \"./principalHistoryNodeRetentionSchema\";\nimport { principalKeyEnvelopeArchive } from \"./principalHistoryRetentionSchema\";\nimport {\n principalHistoryStages,\n principalHistoryStageTables,\n} from \"./principalHistoryStageSchema\";\nimport {\n principalMutationJournal,\n principalMutationJournalTables,\n} from \"./principalMutationJournalSchema\";\nimport {\n principalPolicies,\n principalPolicyBundleHistory,\n principalPolicyBundleReferences,\n principalPolicyCheckpoints,\n principalPolicyOrganizations,\n} from \"./principalPolicySchema\";\nimport {\n securityIncidents,\n securityIncidentTable,\n} from \"./securityIncidentSchema\";\nimport { defineSqlTableSchema, type SqlTableSchema } from \"./sqlTableSchema\";\nimport {\n verifiedAccessManifestBundles,\n verifiedManifestBundleTables,\n} from \"./verifiedManifestBundleSchema\";\n\nexport {\n containerHydrationTombstones,\n containers,\n dormantContainerMetadata,\n dormantMetadataSweepRequests,\n supersededContainerBindings,\n} from \"./containerSchema\";\nexport {\n documentAttachmentBlobProjection,\n documentPendingAttachments,\n} from \"./documentAttachmentSchema\";\nexport {\n inContainerIntentLanes,\n inLocalIntentLane,\n LOCAL_INTENT_LANES,\n LOCAL_INTENT_SUBJECT,\n localIntents,\n} from \"./localIntentSchema\";\nexport {\n principalPolicies,\n principalPolicyBundleHistory,\n principalPolicyBundleReferences,\n principalPolicyCheckpoints,\n principalPolicyOrganizations,\n} from \"./principalPolicySchema\";\nexport { securityIncidents } from \"./securityIncidentSchema\";\nexport { containerDocumentTombstoneHolds, organizationReadModelTables };\n\nconst accessLevelColumn = \"effective_access_level\";\n\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 */\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 ],\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.\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.\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.\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 ],\n);\n\n/**\n * Anti-rollback pin for verified access manifests.\n *\n * Records the highest access-manifest epoch this client has verified for each\n * object, so a later projection that serves an older epoch (rollback) or a\n * conflicting manifest at the same epoch (equivocation) is detected before any\n * key is unwrapped. Updated monotonically after a projection verifies cleanly.\n *\n * Columns:\n * - `objectKind`: Access object kind (`container`, `document`, ...).\n * - `organizationId`: Organization boundary that owns the object.\n * - `objectId`: Stable object id.\n * - `epoch`: Highest verified manifest epoch.\n * - `manifestHash`: Manifest hash pinned at that epoch.\n * - `updatedAt`: Local timestamp for the pin.\n *\n * Indexes:\n * - `(objectKind, organizationId, objectId)` is the primary key and gives one\n * pin per object.\n */\nexport const accessManifestCheckpoints = sqliteTable(\n \"access_manifest_checkpoints\",\n {\n objectKind: text(\"object_kind\").notNull(),\n organizationId: text(\"organization_id\").notNull(),\n objectId: text(\"object_id\").notNull(),\n epoch: integer(\"epoch\").notNull(),\n manifestHash: text(\"manifest_hash\").notNull(),\n updatedAt: text(\"updated_at\").notNull(),\n },\n (table) => [\n primaryKey({\n columns: [table.objectKind, table.organizationId, table.objectId],\n }),\n ],\n);\n\n/**\n * Durable terminal pins for documents whose signed purge proof was verified.\n * These survive remote-state resets so a dishonest API cannot later replay the\n * pre-purge writer projection and resurrect locally deleted content.\n */\nexport const documentPurgeCheckpoints = sqliteTable(\n \"document_purge_checkpoints\",\n {\n documentId: text(\"document_id\").primaryKey(),\n organizationId: text(\"organization_id\").notNull(),\n documentManifestHash: text(\"document_manifest_hash\").notNull(),\n purgeEventHash: text(\"purge_event_hash\").notNull(),\n updatedAt: text(\"updated_at\").notNull(),\n },\n);\n\n/**\n * Durable trust-on-first-use pins for remote user identity bundles.\n *\n * The first validated identity observed for a user in a configured API trust\n * domain is inserted once. Later observations must match every suite, public\n * key, and fingerprint exactly; the persistence adapter never updates these\n * rows. `firstSeenAt` records when the local trust decision was made and is\n * likewise immutable.\n *\n * Indexes:\n * - `(identityTrustDomain, userId)` is the primary key and scopes a user pin to\n * the host-configured API authority that supplied it.\n * - `(identityTrustDomain, signingKeyFingerprint)` binds the reverse identity\n * mapping durably, including across session recreation. There is no\n * migration for a table that already violates it. Earlier builds pinned a\n * registration's user id before the server confirmed it, so a device that\n * ran one may hold two users on one key; deployments are greenfield, and\n * such a device clears its local data, which recreates this table empty. A\n * device that used an environment before a reset does the same (see\n * docs/developer/greenfield-reset.md).\n */\nexport const trustedUserIdentityPins = sqliteTable(\n \"trusted_user_identity_pins\",\n {\n identityTrustDomain: text(\"identity_trust_domain\").notNull(),\n userId: text(\"user_id\").notNull(),\n formatVersion: integer(\"format_version\").notNull(),\n signingSuite: text(\"signing_suite\").notNull(),\n signingPublicKey: text(\"signing_public_key\").notNull(),\n signingKeyFingerprint: text(\"signing_key_fingerprint\").notNull(),\n encapsulationSuite: text(\"encapsulation_suite\").notNull(),\n encapsulationPublicKey: text(\"encapsulation_public_key\").notNull(),\n encapsulationKeyFingerprint: text(\n \"encapsulation_key_fingerprint\",\n ).notNull(),\n firstSeenAt: text(\"first_seen_at\").notNull(),\n },\n (table) => [\n primaryKey({\n columns: [table.identityTrustDomain, table.userId],\n }),\n uniqueIndex(\"trusted_user_identity_pins_domain_signing_fingerprint_idx\").on(\n table.identityTrustDomain,\n table.signingKeyFingerprint,\n ),\n ],\n);\n\n/**\n * Local many-to-many projection between documents and containers.\n *\n * The document summary row stores one selected `containerId` for primary list\n * placement, while this table keeps the full set of linked containers returned\n * by container/document sync. Removing a container deletes its links and may\n * repair affected document summary rows to point at another remaining link.\n *\n * Columns:\n * - `documentId`: Server document id whose container links are projected.\n * - `containerId`: Linked container id.\n * - `updatedAt`: Local timestamp for the last replacement of the link set.\n *\n * Indexes:\n * - `(documentId, containerId)` is the primary key and prevents duplicate\n * links for the same document/container pair.\n */\nexport const documentContainerProjection = sqliteTable(\n \"document_container_projection\",\n {\n documentId: text(\"document_id\").notNull(),\n containerId: text(\"container_id\").notNull(),\n updatedAt: text(\"updated_at\").notNull(),\n },\n (table) => [primaryKey({ columns: [table.documentId, table.containerId] })],\n);\n\n/**\n * Queryable document summary and detail projection.\n *\n * The durable Loro state lives in `documents`. This table stores the fields the\n * app needs for document lists, summaries, and fast detail hydration without\n * opening the full Loro snapshot on every read.\n *\n * Columns:\n * - `localId`: Stable local document id. This joins to `documents.localId` for\n * rows where `documents.appKind = documents`.\n * - `documentId`: Server document id when known.\n * - `containerId`: Selected container for primary document placement, or\n * `null` if the document is not currently linked to a visible container.\n * - `organizationId`: Last-known owning organization. Stamped from the\n * container row when the document is detached because its container was\n * removed locally (e.g. access to a shared org was revoked and the container\n * tombstoned), so pending writes keep their org attribution after the\n * `containers` join source disappears. Read as a fallback only — a live\n * container join always wins.\n * - `documentKind`: Stored document kind. Defaults to `note`.\n * - `title`: Plain projected title. Defaults to the note fallback title.\n * - `updatedAt`: Timestamp used for document list ordering.\n *\n * The projected full text lives in `documentProjectionText`, keyed by the same\n * `localId`. Keeping it out of this row keeps list/window scans narrow: the\n * sidebar and summary queries read titles and placement from rows whose size\n * does not grow with document content.\n *\n * Indexes:\n * - `localId` is the primary key for document projection lookups.\n * - `(containerId) where containerId is not null` serves container-scoped\n * window/count scans without walking the whole table.\n * - `(organizationId) where containerId is null` serves the orphan-recovery\n * existence and window scans.\n * - `(documentId) where documentId is not null` serves the linked-placement\n * join from `documentContainerProjection` and server-id lookups.\n */\nexport const documentProjection = sqliteTable(\n \"document_projection\",\n {\n localId: text(\"local_id\"),\n documentId: text(\"document_id\"),\n containerId: text(\"container_id\"),\n organizationId: text(\"organization_id\"),\n documentKind: text(\"document_kind\").notNull().default(\"note\"),\n title: text(\"title\").notNull().default(\"Untitled note\"),\n updatedAt: text(\"updated_at\").notNull(),\n },\n (table) => [\n primaryKey({ columns: [table.localId] }),\n index(\"document_projection_container_idx\")\n .on(table.containerId)\n .where(sql`${table.containerId} IS NOT NULL`),\n index(\"document_projection_orphan_organization_idx\")\n .on(table.organizationId)\n .where(sql`${table.containerId} IS NULL`),\n index(\"document_projection_document_idx\")\n .on(table.documentId)\n .where(sql`${table.documentId} IS NOT NULL`),\n ],\n);\n\n/**\n * Projected document text, split from `documentProjection` so content size\n * never bloats the rows that list/window queries scan. Loaded only by detail\n * reads (`loadDocument`) and the save-timestamp change check.\n *\n * Columns:\n * - `localId`: Stable local document id, matching `documentProjection.localId`.\n * - `text`: Plain projected text used to rebuild summaries/details.\n */\nexport const documentProjectionText = sqliteTable(\n \"document_projection_text\",\n {\n localId: text(\"local_id\"),\n text: text(\"text\").notNull(),\n },\n (table) => [primaryKey({ columns: [table.localId] })],\n);\n\n/**\n * Per-lane sync state for container data: the server cursor and the local\n * freshness marker share one row per lane.\n *\n * Container sync is split into lanes, such as a parent-container child lane or\n * a container-document membership lane. The cursor lets the next request\n * resume without replaying the entire tree. The freshness marker records the\n * last fully drained check independently of the cursor: empty server\n * responses do not always carry a new watermark, but startup still needs to\n * know that it recently checked the lane before polling again.\n *\n * Columns:\n * - `laneKind`: Sync lane category, such as `container_parent` or\n * `container_documents`.\n * - `laneId`: Lane identity. Root parent sync uses `root`, child sync uses a\n * parent-prefixed container id, and document lanes use the container id.\n * - `watermarkUpdatedAt`: Server `updatedAt` value for the stored watermark;\n * null until a watermark is saved.\n * - `watermarkId`: Server id tie-breaker for the stored watermark; null\n * exactly when `watermarkUpdatedAt` is.\n * - `updatedAt`: Local timestamp for when the cursor was saved.\n * - `checkedAt`: Local timestamp for the most recent fully drained lane check;\n * null until one completes.\n *\n * Indexes:\n * - `(laneKind, laneId)` is the primary key and stores one row per lane.\n */\nexport const containerSyncWatermarks = sqliteTable(\n \"container_sync_watermarks\",\n {\n laneKind: text(\"lane_kind\").notNull(),\n laneId: text(\"lane_id\").notNull(),\n watermarkUpdatedAt: text(\"watermark_updated_at\"),\n watermarkId: text(\"watermark_id\"),\n updatedAt: text(\"updated_at\"),\n checkedAt: text(\"checked_at\"),\n },\n (table) => [primaryKey({ columns: [table.laneKind, table.laneId] })],\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\nexport const principalPolicyTables: ReadonlyArray<SqlTableSchema> = [\n {\n ...defineSqlTableSchema(principalPolicies),\n requiredColumns: [\"current_grants_json\"],\n },\n {\n ...defineSqlTableSchema(principalPolicyBundleHistory),\n requiredColumns: [\"current_grants_json\"],\n },\n defineSqlTableSchema(principalPolicyBundleReferences),\n defineSqlTableSchema(principalPolicyOrganizations),\n ...principalHistoryStageTables,\n ...principalHistoryEvidenceTables,\n];\n\nexport const keyingCheckpointTables: ReadonlyArray<SqlTableSchema> = [\n defineSqlTableSchema(organizationFounders),\n defineSqlTableSchema(accessManifestCheckpoints),\n defineSqlTableSchema(principalGrantRetirements),\n defineSqlTableSchema(documentPurgeCheckpoints),\n defineSqlTableSchema(principalPolicyCheckpoints),\n];\n\nexport const trustedUserIdentityPinTables: ReadonlyArray<SqlTableSchema> = [\n defineSqlTableSchema(trustedUserIdentityPins),\n];\n\nconst securityIncidentTables: ReadonlyArray<SqlTableSchema> = [\n securityIncidentTable,\n];\n\nexport const containerTables = containerTableSchemas;\n\nexport const documentContainerProjectionTables: ReadonlyArray<SqlTableSchema> =\n [\n defineSqlTableSchema(documentContainerProjection),\n {\n ...defineSqlTableSchema(containerDocumentTombstoneHolds),\n requiredColumns: [\"hidden\"],\n },\n defineSqlTableSchema(pendingDocumentDiscoveries),\n {\n ...defineSqlTableSchema(documentDiscoveryHeads),\n requiredColumns: [\"organization_id\"],\n },\n defineSqlTableSchema(documentDiscoverySequence),\n ];\n\nexport const localIntentTables: ReadonlyArray<SqlTableSchema> = [\n defineSqlTableSchema(localIntents),\n];\n\nexport const documentPlacementIntentTables: ReadonlyArray<SqlTableSchema> = [\n ...localIntentTables,\n defineSqlTableSchema(documentIntentLinkTargets),\n];\n\nexport const documentProjectionTables: ReadonlyArray<SqlTableSchema> = [\n defineSqlTableSchema(documentProjection),\n defineSqlTableSchema(documentProjectionText),\n {\n ...defineSqlTableSchema(documentPendingAttachments),\n requiredColumns: [\"content_sha256\"],\n },\n {\n ...defineSqlTableSchema(documentAttachmentBlobProjection),\n requiredColumns: [\"content_sha256\"],\n },\n documentOrphanBlobReclaimTable,\n];\n\nexport const containerSyncWatermarkTables: ReadonlyArray<SqlTableSchema> = [\n {\n ...defineSqlTableSchema(containerSyncWatermarks),\n requiredColumns: [\"checked_at\"],\n },\n];\n\nexport const clientSqlTables: ReadonlyArray<SqlTableSchema> = [\n ...principalMutationJournalTables,\n ...documentTables,\n ...principalPolicyTables,\n ...keyingCheckpointTables,\n ...verifiedManifestBundleTables,\n ...trustedUserIdentityPinTables,\n ...securityIncidentTables,\n ...containerTables,\n ...documentContainerProjectionTables,\n ...documentPlacementIntentTables,\n ...documentProjectionTables,\n ...containerSyncWatermarkTables,\n ...organizationReadModelTables,\n ...organizationDataUsage.organizationDataUsageTables,\n ...provisioningAttempt.organizationProvisioningAttemptTables,\n];\n\nexport const clientSQLiteSchema = {\n principalHistoryNodeReferences,\n principalHistoryRootOwners,\n principalKeyEnvelopeArchive,\n principalMutationJournal,\n principalHistoryEntries,\n principalHistoryNodes,\n principalHistoryPrefixes,\n principalHistoryStages,\n organizationFounders,\n principalGrantRetirements,\n documents,\n principalPolicies,\n principalPolicyBundleHistory,\n principalPolicyBundleReferences,\n principalPolicyOrganizations,\n accessManifestCheckpoints,\n documentPurgeCheckpoints,\n principalPolicyCheckpoints,\n verifiedAccessManifestBundles,\n trustedUserIdentityPins,\n securityIncidents,\n ...containerSQLiteSchema,\n documentContainerProjection,\n localIntents,\n documentIntentLinkTargets,\n documentProjection,\n documentPendingAttachments,\n documentAttachmentBlobProjection,\n documentOrphanBlobReclaims: documentOrphanBlobReclaims,\n containerSyncWatermarks,\n ...organizationReadModelSQLiteSchema,\n ...organizationDataUsage.organizationDataUsageSQLiteSchema,\n ...provisioningAttempt.organizationProvisioningAttemptSQLiteSchema,\n};\n"]}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { NativeSubscriptionStore } from "../validators/billing.js";
|
|
2
2
|
import { type RootIdentitiesQuery, type RootOrganizationPageQuery, type RootOrganizationsQuery } from "../validators/operation/index.js";
|
|
3
|
-
import type { BlobAttachmentBindRequest, BlobAttachmentDetachRequest, CommitOrganizationGroupPolicyRequest, ContainerCreateWithMetadataDocumentRequest, ContainerMutationRequest, ContainerReciteRequest, ContainerRotationRequest, CreateOrganizationRequest, DocumentCreateRequest, DocumentLinkSetMutationRequest, DocumentPurgeRequest, DocumentSyncRequest, InitiateMultipartBlobStageRequest, ListContainerParentLanesRequest, RegistrationRequest, UpdateOrganizationProfileRequest, UpdateOrganizationRosterEntryRequest } from "../validators/request/index.js";
|
|
4
|
-
import type { CommitOrganizationGroupPolicyResponse, ContainerCreateWithMetadataDocumentResponse, ContainerDeleteResponse, ContainerMutationResponse, ContainerRotationResponse, ContainerWriterProjectionResponse, DocumentCreateResponse, DocumentSyncResponse, DocumentWriterProjectionResponse,
|
|
3
|
+
import type { BlobAttachmentBindRequest, BlobAttachmentDetachRequest, CommitOrganizationGroupPolicyRequest, ContainerCreateWithMetadataDocumentRequest, ContainerMutationRequest, ContainerReciteRequest, ContainerRotationRequest, CreateOrganizationRequest, DocumentCreateRequest, DocumentLinkSetMutationRequest, DocumentPurgeRequest, DocumentSyncRequest, InitiateMultipartBlobStageRequest, ListContainerDocumentLanesRequest, ListContainerParentLanesRequest, RegistrationRequest, UpdateOrganizationProfileRequest, UpdateOrganizationRosterEntryRequest } from "../validators/request/index.js";
|
|
4
|
+
import type { CommitOrganizationGroupPolicyResponse, ContainerCreateWithMetadataDocumentResponse, ContainerDeleteResponse, ContainerMutationResponse, ContainerRotationResponse, ContainerWriterProjectionResponse, DocumentCreateResponse, DocumentSyncResponse, DocumentWriterProjectionResponse, ListContainerDocumentLanesResponse, OrganizationDataUsageResponse, OrganizationPolicyHistoryResponse, OrganizationReadModelResponse, RootDataUsageReportResponse, RootIdentitiesResponse, RootIdentityDetailResponse, RootIdentityOrganizationsResponse, RootOrganizationDetailResponse, RootOrganizationIdentitiesResponse, RootOrganizationsResponse } from "../validators/response/index.js";
|
|
5
5
|
import type { ApiRequestInstrumentation } from "./apiRequestMetrics.js";
|
|
6
6
|
import { getOrganizationPolicyHistoryResult as organizationHistory } from "./organizationPolicyHistory.js";
|
|
7
7
|
import type { PrincipalPolicyPageReadOptions } from "./principalPolicyPages.js";
|
|
@@ -9,14 +9,14 @@ import { PrincipalPolicyRequests } from "./principalPolicyRequests.js";
|
|
|
9
9
|
import { type UploadMultipartBlobPartBytesRequest } from "./routes/blobs/get.js";
|
|
10
10
|
import { type ContainerKekLogOptions } from "./routes/containers/reads.js";
|
|
11
11
|
import { type DocumentPurgeProofOptions } from "./routes/documents/mutations.js";
|
|
12
|
-
import type { HttpMethod,
|
|
12
|
+
import type { HttpMethod, ListDocumentEditAttributionRangesOptions, RequestResult, RequestResultOptions } from "./types.js";
|
|
13
13
|
import type { VerifiedManifestCitations } from "./verifiedManifestCitations.js";
|
|
14
14
|
type ExpiredHandler = () => boolean | Promise<boolean>;
|
|
15
15
|
type PaymentRequiredHandler = (organizationId: string | null) => void;
|
|
16
16
|
export declare class ApiClient {
|
|
17
17
|
private readonly requestRuntime;
|
|
18
18
|
private verifiedManifestCitations;
|
|
19
|
-
private readonly
|
|
19
|
+
private readonly containerDocumentLaneRequestsByKey;
|
|
20
20
|
private readonly containerParentLaneRequestsByKey;
|
|
21
21
|
private readonly containerWriterProjectionRequestsByContainerId;
|
|
22
22
|
private readonly documentWriterProjectionRequestsByDocumentId;
|
|
@@ -3571,36 +3571,8 @@ export declare class ApiClient {
|
|
|
3571
3571
|
};
|
|
3572
3572
|
}[];
|
|
3573
3573
|
} | null>;
|
|
3574
|
-
|
|
3575
|
-
|
|
3576
|
-
items: {
|
|
3577
|
-
createdAt: string;
|
|
3578
|
-
currentAccessEpoch: number;
|
|
3579
|
-
currentAccessStateHash: string;
|
|
3580
|
-
effectiveAccessLevel: "admin" | "read" | "write";
|
|
3581
|
-
id: string;
|
|
3582
|
-
linkedContainerIds: string[];
|
|
3583
|
-
referencedPrincipals: {
|
|
3584
|
-
keyEpoch: number;
|
|
3585
|
-
keyFingerprint: string;
|
|
3586
|
-
principalId: string;
|
|
3587
|
-
principalType: "group" | "organization";
|
|
3588
|
-
stateHash: string;
|
|
3589
|
-
version: number;
|
|
3590
|
-
}[];
|
|
3591
|
-
updatedAt: string;
|
|
3592
|
-
}[];
|
|
3593
|
-
nextWatermark: {
|
|
3594
|
-
id: string;
|
|
3595
|
-
updatedAt: string;
|
|
3596
|
-
} | null;
|
|
3597
|
-
tombstones: {
|
|
3598
|
-
containerId: string;
|
|
3599
|
-
documentId: string;
|
|
3600
|
-
updatedAt: string;
|
|
3601
|
-
}[];
|
|
3602
|
-
} | null>;
|
|
3603
|
-
listContainerDocumentsResult(containerId: string, options?: ListContainerDocumentsOptions, requestOptions?: RequestResultOptions): Promise<RequestResult<ListContainerDocumentsResponse>>;
|
|
3574
|
+
/** Batched document listing; see `containerDocumentLanes.settle`. */
|
|
3575
|
+
listContainerDocumentLanes(input: ListContainerDocumentLanesRequest, options?: Pick<RequestResultOptions, "reportErrors">): Promise<ListContainerDocumentLanesResponse | null>;
|
|
3604
3576
|
unlinkDocument(documentId: string, input: DocumentLinkSetMutationRequest, options?: RequestResultOptions): Promise<{
|
|
3605
3577
|
accessManifest: {
|
|
3606
3578
|
event: {
|