@tearleads/client-sdk 0.1.261 → 0.1.263
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/README.md +1 -1
- package/client/documents/index.d.ts +11 -0
- package/client/documents/index.js +7 -1
- package/client/documents/index.js.map +1 -1
- package/client/index.d.ts +1 -1
- package/client/index.js.map +1 -1
- package/index.d.ts +1 -1
- package/index.js.map +1 -1
- package/internal/sqlite-worker/crossTabConnectionMachine.js +67 -0
- package/internal/sqlite-worker/crossTabConnectionMachine.js.map +1 -0
- package/internal/sqlite-worker/crossTabLocalClient.js +76 -14
- package/internal/sqlite-worker/crossTabLocalClient.js.map +1 -1
- package/internal/sqlite-worker/crossTabProtocol.js +17 -0
- package/internal/sqlite-worker/crossTabProtocol.js.map +1 -1
- package/internal/sqlite-worker/crossTabRuntime.js +20 -18
- package/internal/sqlite-worker/crossTabRuntime.js.map +1 -1
- package/internal/sqlite-worker/runtime.d.ts +1 -1
- package/internal/sqlite-worker/runtime.js +1 -0
- package/internal/sqlite-worker/runtime.js.map +1 -1
- package/internal/sqlite-worker/types.d.ts +7 -0
- package/internal/sqlite-worker/types.js +12 -0
- package/internal/sqlite-worker/types.js.map +1 -1
- package/internal/sqlite-worker/workerCrash.d.ts +23 -0
- package/internal/sqlite-worker/workerCrash.js +17 -0
- package/internal/sqlite-worker/workerCrash.js.map +1 -1
- package/package.json +1 -1
- package/sqlite/index.d.ts +1 -1
- package/sqlite/index.js +1 -1
- package/sqlite/index.js.map +1 -1
- package/sqlite/worker.js +4 -4
- package/stores/documents/downloadRetry.d.ts +16 -0
- package/stores/documents/downloadRetry.js +28 -0
- package/stores/documents/downloadRetry.js.map +1 -0
- package/stores/documents/index.d.ts +1 -0
- package/stores/documents/index.js +1 -0
- package/stores/documents/index.js.map +1 -1
- package/workflows/container-contents/documentQueries/pendingDownloads.d.ts +23 -2
- package/workflows/container-contents/documentQueries/pendingDownloads.js +63 -1
- package/workflows/container-contents/documentQueries/pendingDownloads.js.map +1 -1
package/README.md
CHANGED
|
@@ -9,7 +9,7 @@ behavior into the SDK rather than duplicate its setup.
|
|
|
9
9
|
| Entry point | Use for |
|
|
10
10
|
| --- | --- |
|
|
11
11
|
| `@tearleads/client-sdk` | `Tearleads`, SDK service types, local keyring helpers, document contracts, sync diagnostics, stores, purchase capabilities, and public workflow symbols |
|
|
12
|
-
| `@tearleads/client-sdk/sqlite` | SQLite worker runtime factory, executor contracts, and adapter helpers |
|
|
12
|
+
| `@tearleads/client-sdk/sqlite` | SQLite worker runtime factory, executor contracts, the lost-connection error (`DatabaseConnectionLostError`, `isDatabaseConnectionLostError`), and adapter helpers |
|
|
13
13
|
| `@tearleads/client-sdk/sqlite/worker.js` | The SQLite worker module to serve |
|
|
14
14
|
| `@tearleads/client-sdk/sqlite/sqlite3.wasm` | The SQLite WebAssembly to serve beside `worker.js` |
|
|
15
15
|
| `@tearleads/client-sdk/sqlite/sqlite3-licenses.md` | The licenses that ship with the two SQLite files |
|
|
@@ -28,6 +28,10 @@ export interface OpenDocumentOptions {
|
|
|
28
28
|
readonly remoteSyncMode?: "on-demand" | "startup" | undefined;
|
|
29
29
|
readonly workflowRuntime?: DocumentsRuntime | undefined;
|
|
30
30
|
}
|
|
31
|
+
export interface RetryDocumentDownloadInput {
|
|
32
|
+
readonly documentId: string;
|
|
33
|
+
readonly localId: string;
|
|
34
|
+
}
|
|
31
35
|
export interface DocumentSubscriptionOptions {
|
|
32
36
|
readonly containerId?: string | null | undefined;
|
|
33
37
|
}
|
|
@@ -43,6 +47,13 @@ export interface Documents {
|
|
|
43
47
|
* The caller must `close()` the result.
|
|
44
48
|
*/
|
|
45
49
|
openHistory(localId: string): Promise<DocumentHistory | null>;
|
|
50
|
+
/**
|
|
51
|
+
* Pull a synced document again and re-list its attachment bindings, e.g.
|
|
52
|
+
* to retry a pending first download. Resolves false, without syncing, when
|
|
53
|
+
* the database is not ready or the local record no longer carries
|
|
54
|
+
* `documentId`; an already-open store keeps its runtime and draft.
|
|
55
|
+
*/
|
|
56
|
+
retryDownload(input: RetryDocumentDownloadInput): Promise<boolean>;
|
|
46
57
|
subscribe(listener: PersistedDocumentListener, options?: DocumentSubscriptionOptions | undefined): () => void;
|
|
47
58
|
workflowRuntime(containerId?: string | null | undefined): DocumentsRuntime;
|
|
48
59
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { DEFAULT_DOCUMENT_KIND } from "../../data/documents/documentConstants.js";
|
|
2
|
-
import { createSeededDocument, DEFAULT_DOCUMENT_ID as DEFAULT_LOCAL_DOCUMENT_ID, openDocumentStore, subscribeToPersistedDocuments, } from "../../stores/documents/index.js";
|
|
2
|
+
import { createSeededDocument, DEFAULT_DOCUMENT_ID as DEFAULT_LOCAL_DOCUMENT_ID, openDocumentStore, retryDocumentDownload, subscribeToPersistedDocuments, } from "../../stores/documents/index.js";
|
|
3
3
|
import { emitPersistedDocumentDeletion } from "../../stores/documents/registry.js";
|
|
4
4
|
import { createDocumentsWorkflowRuntimeFromSnapshot, defaultDocumentsPersistence, deletePersistedDocument, openDocumentHistory, reclaimDocumentOrphanBlobs, } from "../../workflows/documents/index.js";
|
|
5
5
|
export { DEFAULT_LOCAL_DOCUMENT_ID as DEFAULT_DOCUMENT_ID };
|
|
@@ -80,6 +80,12 @@ class DocumentsService {
|
|
|
80
80
|
persistence: defaultDocumentsPersistence,
|
|
81
81
|
});
|
|
82
82
|
}
|
|
83
|
+
retryDownload(input) {
|
|
84
|
+
return retryDocumentDownload({
|
|
85
|
+
...input,
|
|
86
|
+
workflowRuntime: (containerId) => this.workflowRuntime(containerId),
|
|
87
|
+
});
|
|
88
|
+
}
|
|
83
89
|
subscribe(listener, options = {}) {
|
|
84
90
|
return subscribeToPersistedDocuments(this.dependencies.runtime.workflowInput(options.containerId).state
|
|
85
91
|
.domainScope, listener);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":"A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zC,OAAO,6BAA6B,CAClC,IAAI,CAAC,YAAY,CAAC,OAAO,CAAC,aAAa,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC,KAAK;aAC/D,WAAW,EACd,QAAQ,CACT,CAAC;IACJ,CAAC;IAEO,YAAY,CAAC,OAAgB;QACnC,MAAM,QAAQ,GAAG,IAAI,CAAC,sBAAsB,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;QAC1D,IAAI,QAAQ,EAAE,CAAC;YACb,OAAO,QAAQ,CAAC;QAClB,CAAC;QAED,MAAM,MAAM,GAAG,2BAA2B;aACvC,YAAY,CAAC,OAAO,CAAC;aACrB,KAAK,CAAC,CAAC,KAAc,EAAE,EAAE;YACxB,IAAI,CAAC,sBAAsB,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;YAC5C,MAAM,KAAK,CAAC;QACd,CAAC,CAAC,CAAC;QACL,IAAI,CAAC,sBAAsB,CAAC,GAAG,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;QACjD,OAAO,MAAM,CAAC;IAChB,CAAC;CACF","sourcesContent":["import { DEFAULT_DOCUMENT_KIND } from \"../../data/documents/documentConstants\";\nimport type { StoredDocumentKind } from \"../../data/documents/documentKinds\";\nimport type { DiscoveredDocumentInput } from \"../../data/documents/documentSummary\";\nimport type {\n DocumentSummaryList,\n DocumentSummarySort,\n DocumentSummarySortDirection,\n DocumentSummarySortKey,\n ListDocumentSummariesInput,\n} from \"../../data/persistence/documents/types\";\nimport type { ExecSql } from \"../../data/sqlite/sqlSchema\";\nimport {\n createSeededDocument,\n DEFAULT_DOCUMENT_ID as DEFAULT_LOCAL_DOCUMENT_ID,\n type DocumentStore,\n type DocumentStoreOpenOptions,\n type DocumentsRuntime,\n openDocumentStore,\n type PersistedDocumentListener,\n type SeededDocumentInput,\n subscribeToPersistedDocuments,\n} from \"../../stores/documents\";\nimport { emitPersistedDocumentDeletion } from \"../../stores/documents/registry\";\nimport {\n createDocumentsWorkflowRuntimeFromSnapshot,\n type DocumentHistory,\n defaultDocumentsPersistence,\n deletePersistedDocument,\n openDocumentHistory,\n reclaimDocumentOrphanBlobs,\n} from \"../../workflows/documents\";\nimport type { InternalRuntime } from \"../runtime/workflowRuntime\";\n\nexport type {\n DocumentAttachmentStatus,\n DocumentAttachmentUpload,\n DocumentContextValue,\n DocumentStore,\n DocumentsRuntime,\n PersistedDocumentListener,\n} from \"../../stores/documents\";\n\nexport type {\n DocumentHistory,\n DocumentHistoryChange,\n DocumentHistoryRowChange,\n DocumentHistoryStop,\n DocumentHistoryTextChange,\n DocumentHistoryVersion,\n DocumentHistoryVersionEntry,\n DocumentHistoryView,\n} from \"../../workflows/documents\";\n\nexport type DocumentSortDirection = DocumentSummarySortDirection;\nexport type DocumentSortKey = DocumentSummarySortKey;\n\nexport type DocumentSort = DocumentSummarySort;\n\nexport interface ListDocumentsInput extends ListDocumentSummariesInput {}\n\nexport type DocumentList = DocumentSummaryList;\n\nexport type { SeededDocumentInput } from \"../../stores/documents\";\nexport interface OpenDocumentInput {\n readonly containerId?: string | null | undefined;\n readonly documentId?: string | null | undefined;\n readonly initialDocumentKind?: StoredDocumentKind | undefined;\n /** Birth content of a created record; see `DocumentStoreOpenOptions`. */\n readonly initialRows?: DocumentStoreOpenOptions[\"initialRows\"];\n readonly initialStructuredFields?: DocumentStoreOpenOptions[\"initialStructuredFields\"];\n readonly initialText?: string | undefined;\n readonly localId?: string | undefined;\n}\nexport { DEFAULT_LOCAL_DOCUMENT_ID as DEFAULT_DOCUMENT_ID };\n\nexport interface OpenDocumentOptions {\n readonly remoteSyncMode?: \"on-demand\" | \"startup\" | undefined;\n readonly workflowRuntime?: DocumentsRuntime | undefined;\n}\n\nexport interface DocumentSubscriptionOptions {\n readonly containerId?: string | null | undefined;\n}\n\nexport interface Documents {\n createSeeded(\n input: SeededDocumentInput,\n ): Promise<DiscoveredDocumentInput | \"purged\">;\n delete(localId: string): Promise<boolean>;\n findLocalIdByDocumentId(documentId: string): Promise<string | null>;\n list(input?: ListDocumentsInput | undefined): Promise<DocumentList | null>;\n open(\n input?: OpenDocumentInput | undefined,\n options?: OpenDocumentOptions | undefined,\n ): DocumentStore;\n /**\n * Open a read-only replay of a document's durable local history. Resolves to\n * null while the database is not ready or the document has no history yet.\n * The caller must `close()` the result.\n */\n openHistory(localId: string): Promise<DocumentHistory | null>;\n subscribe(\n listener: PersistedDocumentListener,\n options?: DocumentSubscriptionOptions | undefined,\n ): () => void;\n workflowRuntime(containerId?: string | null | undefined): DocumentsRuntime;\n}\n\ninterface DocumentsDependencies {\n getDefaultContainerId: () => string | null;\n runtime: InternalRuntime;\n}\n\nexport function createDocuments(\n dependencies: DocumentsDependencies,\n): Documents {\n return new DocumentsService(dependencies);\n}\n\nclass DocumentsService implements Documents {\n private readonly schemaEnsuresByExecSql = new WeakMap<\n ExecSql,\n Promise<void>\n >();\n\n constructor(private readonly dependencies: DocumentsDependencies) {}\n\n createSeeded(input: SeededDocumentInput) {\n const { runtime } = this.dependencies;\n const generation = runtime.scopeGeneration;\n return createSeededDocument(\n this.workflowRuntime(input.containerId),\n input,\n () => runtime.scopeGeneration === generation,\n );\n }\n\n async delete(localId: string): Promise<boolean> {\n const runtime = this.workflowRuntime();\n if (runtime.infra.dbStatus !== \"ready\") {\n return false;\n }\n\n const deleted = await deletePersistedDocument({\n deleteDocumentPlacements: runtime.deleteDocumentPlacements,\n documentProjectors: runtime.infra.documentProjectors,\n execSql: runtime.infra.execSql,\n localId,\n persistence: defaultDocumentsPersistence,\n });\n if (!deleted) return false;\n void reclaimDocumentOrphanBlobs(runtime);\n emitPersistedDocumentDeletion(runtime.state.domainScope, localId);\n return true;\n }\n\n async findLocalIdByDocumentId(documentId: string): Promise<string | null> {\n const runtime = this.dependencies.runtime.workflowInput();\n if (runtime.infra.dbStatus !== \"ready\") {\n return null;\n }\n\n await this.ensureSchema(runtime.infra.execSql);\n return defaultDocumentsPersistence.findLocalIdByDocumentId(\n runtime.infra.execSql,\n documentId,\n );\n }\n\n async list(input: ListDocumentsInput = {}): Promise<DocumentList | null> {\n const runtime = this.dependencies.runtime.workflowInput();\n if (runtime.infra.dbStatus !== \"ready\") {\n return null;\n }\n\n await this.ensureSchema(runtime.infra.execSql);\n return defaultDocumentsPersistence.listDocumentSummaries(\n runtime.infra.execSql,\n input,\n );\n }\n\n workflowRuntime(\n containerId = this.dependencies.getDefaultContainerId(),\n ): DocumentsRuntime {\n const { runtime } = this.dependencies;\n return createDocumentsWorkflowRuntimeFromSnapshot({\n ...runtime.workflowInput(containerId),\n deleteDocumentPlacements: runtime.deleteDocumentPlacements,\n });\n }\n\n open(\n input: OpenDocumentInput = {},\n options: OpenDocumentOptions = {},\n ): DocumentStore {\n const {\n containerId,\n documentId = null,\n initialDocumentKind = DEFAULT_DOCUMENT_KIND,\n initialRows,\n initialStructuredFields,\n initialText = \"\",\n localId = DEFAULT_LOCAL_DOCUMENT_ID,\n } = input;\n const runtime =\n options.workflowRuntime ?? this.workflowRuntime(containerId);\n return openDocumentStore(\n runtime.state.domainScope,\n localId,\n runtime,\n documentId,\n initialText,\n initialDocumentKind,\n {\n initialRows,\n initialStructuredFields,\n remoteSyncMode: options.remoteSyncMode,\n },\n );\n }\n\n async openHistory(localId: string): Promise<DocumentHistory | null> {\n const runtime = this.workflowRuntime();\n if (runtime.infra.dbStatus !== \"ready\") {\n return null;\n }\n\n await this.ensureSchema(runtime.infra.execSql);\n return openDocumentHistory({\n documentProjectors: runtime.infra.documentProjectors,\n execSql: runtime.infra.execSql,\n localId,\n persistence: defaultDocumentsPersistence,\n });\n }\n\n subscribe(\n listener: PersistedDocumentListener,\n options: DocumentSubscriptionOptions = {},\n ): () => void {\n return subscribeToPersistedDocuments(\n this.dependencies.runtime.workflowInput(options.containerId).state\n .domainScope,\n listener,\n );\n }\n\n private ensureSchema(execSql: ExecSql): Promise<void> {\n const existing = this.schemaEnsuresByExecSql.get(execSql);\n if (existing) {\n return existing;\n }\n\n const ensure = defaultDocumentsPersistence\n .ensureSchema(execSql)\n .catch((error: unknown) => {\n this.schemaEnsuresByExecSql.delete(execSql);\n throw error;\n });\n this.schemaEnsuresByExecSql.set(execSql, ensure);\n return ensure;\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,wCAAwC,CAAC;AAW/E,OAAO,EACL,oBAAoB,EACpB,mBAAmB,IAAI,yBAAyB,EAIhD,iBAAiB,EAEjB,qBAAqB,EAErB,6BAA6B,GAC9B,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,6BAA6B,EAAE,MAAM,iCAAiC,CAAC;AAChF,OAAO,EACL,0CAA0C,EAE1C,2BAA2B,EAC3B,uBAAuB,EACvB,mBAAmB,EACnB,0BAA0B,GAC3B,MAAM,2BAA2B,CAAC;AA2CnC,OAAO,EAAE,yBAAyB,IAAI,mBAAmB,EAAE,CAAC;AAoD5D,MAAM,UAAU,eAAe,CAC7B,YAAmC;IAEnC,OAAO,IAAI,gBAAgB,CAAC,YAAY,CAAC,CAAC;AAC5C,CAAC;AAED,MAAM,gBAAgB;IAMS;IALZ,sBAAsB,GAAG,IAAI,OAAO,EAGlD,CAAC;IAEJ,YAA6B,YAAmC;QAAnC,iBAAY,GAAZ,YAAY,CAAuB;IAAG,CAAC;IAEpE,YAAY,CAAC,KAA0B;QACrC,MAAM,EAAE,OAAO,EAAE,GAAG,IAAI,CAAC,YAAY,CAAC;QACtC,MAAM,UAAU,GAAG,OAAO,CAAC,eAAe,CAAC;QAC3C,OAAO,oBAAoB,CACzB,IAAI,CAAC,eAAe,CAAC,KAAK,CAAC,WAAW,CAAC,EACvC,KAAK,EACL,GAAG,EAAE,CAAC,OAAO,CAAC,eAAe,KAAK,UAAU,CAC7C,CAAC;IACJ,CAAC;IAED,KAAK,CAAC,MAAM,CAAC,OAAe;QAC1B,MAAM,OAAO,GAAG,IAAI,CAAC,eAAe,EAAE,CAAC;QACvC,IAAI,OAA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AAO,CAAC,KAAK,CAAC,kBAAkB;YACpD,OAAO,EAAE,OAAO,CAAC,KAAK,CAAC,OAAO;YAC9B,OAAO;YACP,WAAW,EAAE,2BAA2B;SACzC,CAAC,CAAC;IACL,CAAC;IAED,aAAa,CAAC,KAAiC;QAC7C,OAAO,qBAAqB,CAAC;YAC3B,GAAG,KAAK;YACR,eAAe,EAAE,CAAC,WAAW,EAAE,EAAE,CAAC,IAAI,CAAC,eAAe,CAAC,WAAW,CAAC;SACpE,CAAC,CAAC;IACL,CAAC;IAED,SAAS,CACP,QAAmC,EACnC,UAAuC,EAAE;QAEzC,OAAO,6BAA6B,CAClC,IAAI,CAAC,YAAY,CAAC,OAAO,CAAC,aAAa,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC,KAAK;aAC/D,WAAW,EACd,QAAQ,CACT,CAAC;IACJ,CAAC;IAEO,YAAY,CAAC,OAAgB;QACnC,MAAM,QAAQ,GAAG,IAAI,CAAC,sBAAsB,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;QAC1D,IAAI,QAAQ,EAAE,CAAC;YACb,OAAO,QAAQ,CAAC;QAClB,CAAC;QAED,MAAM,MAAM,GAAG,2BAA2B;aACvC,YAAY,CAAC,OAAO,CAAC;aACrB,KAAK,CAAC,CAAC,KAAc,EAAE,EAAE;YACxB,IAAI,CAAC,sBAAsB,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;YAC5C,MAAM,KAAK,CAAC;QACd,CAAC,CAAC,CAAC;QACL,IAAI,CAAC,sBAAsB,CAAC,GAAG,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;QACjD,OAAO,MAAM,CAAC;IAChB,CAAC;CACF","sourcesContent":["import { DEFAULT_DOCUMENT_KIND } from \"../../data/documents/documentConstants\";\nimport type { StoredDocumentKind } from \"../../data/documents/documentKinds\";\nimport type { DiscoveredDocumentInput } from \"../../data/documents/documentSummary\";\nimport type {\n DocumentSummaryList,\n DocumentSummarySort,\n DocumentSummarySortDirection,\n DocumentSummarySortKey,\n ListDocumentSummariesInput,\n} from \"../../data/persistence/documents/types\";\nimport type { ExecSql } from \"../../data/sqlite/sqlSchema\";\nimport {\n createSeededDocument,\n DEFAULT_DOCUMENT_ID as DEFAULT_LOCAL_DOCUMENT_ID,\n type DocumentStore,\n type DocumentStoreOpenOptions,\n type DocumentsRuntime,\n openDocumentStore,\n type PersistedDocumentListener,\n retryDocumentDownload,\n type SeededDocumentInput,\n subscribeToPersistedDocuments,\n} from \"../../stores/documents\";\nimport { emitPersistedDocumentDeletion } from \"../../stores/documents/registry\";\nimport {\n createDocumentsWorkflowRuntimeFromSnapshot,\n type DocumentHistory,\n defaultDocumentsPersistence,\n deletePersistedDocument,\n openDocumentHistory,\n reclaimDocumentOrphanBlobs,\n} from \"../../workflows/documents\";\nimport type { InternalRuntime } from \"../runtime/workflowRuntime\";\n\nexport type {\n DocumentAttachmentStatus,\n DocumentAttachmentUpload,\n DocumentContextValue,\n DocumentStore,\n DocumentsRuntime,\n PersistedDocumentListener,\n} from \"../../stores/documents\";\n\nexport type {\n DocumentHistory,\n DocumentHistoryChange,\n DocumentHistoryRowChange,\n DocumentHistoryStop,\n DocumentHistoryTextChange,\n DocumentHistoryVersion,\n DocumentHistoryVersionEntry,\n DocumentHistoryView,\n} from \"../../workflows/documents\";\n\nexport type DocumentSortDirection = DocumentSummarySortDirection;\nexport type DocumentSortKey = DocumentSummarySortKey;\n\nexport type DocumentSort = DocumentSummarySort;\n\nexport interface ListDocumentsInput extends ListDocumentSummariesInput {}\n\nexport type DocumentList = DocumentSummaryList;\n\nexport type { SeededDocumentInput } from \"../../stores/documents\";\nexport interface OpenDocumentInput {\n readonly containerId?: string | null | undefined;\n readonly documentId?: string | null | undefined;\n readonly initialDocumentKind?: StoredDocumentKind | undefined;\n /** Birth content of a created record; see `DocumentStoreOpenOptions`. */\n readonly initialRows?: DocumentStoreOpenOptions[\"initialRows\"];\n readonly initialStructuredFields?: DocumentStoreOpenOptions[\"initialStructuredFields\"];\n readonly initialText?: string | undefined;\n readonly localId?: string | undefined;\n}\nexport { DEFAULT_LOCAL_DOCUMENT_ID as DEFAULT_DOCUMENT_ID };\n\nexport interface OpenDocumentOptions {\n readonly remoteSyncMode?: \"on-demand\" | \"startup\" | undefined;\n readonly workflowRuntime?: DocumentsRuntime | undefined;\n}\n\nexport interface RetryDocumentDownloadInput {\n readonly documentId: string;\n readonly localId: string;\n}\n\nexport interface DocumentSubscriptionOptions {\n readonly containerId?: string | null | undefined;\n}\n\nexport interface Documents {\n createSeeded(\n input: SeededDocumentInput,\n ): Promise<DiscoveredDocumentInput | \"purged\">;\n delete(localId: string): Promise<boolean>;\n findLocalIdByDocumentId(documentId: string): Promise<string | null>;\n list(input?: ListDocumentsInput | undefined): Promise<DocumentList | null>;\n open(\n input?: OpenDocumentInput | undefined,\n options?: OpenDocumentOptions | undefined,\n ): DocumentStore;\n /**\n * Open a read-only replay of a document's durable local history. Resolves to\n * null while the database is not ready or the document has no history yet.\n * The caller must `close()` the result.\n */\n openHistory(localId: string): Promise<DocumentHistory | null>;\n /**\n * Pull a synced document again and re-list its attachment bindings, e.g.\n * to retry a pending first download. Resolves false, without syncing, when\n * the database is not ready or the local record no longer carries\n * `documentId`; an already-open store keeps its runtime and draft.\n */\n retryDownload(input: RetryDocumentDownloadInput): Promise<boolean>;\n subscribe(\n listener: PersistedDocumentListener,\n options?: DocumentSubscriptionOptions | undefined,\n ): () => void;\n workflowRuntime(containerId?: string | null | undefined): DocumentsRuntime;\n}\n\ninterface DocumentsDependencies {\n getDefaultContainerId: () => string | null;\n runtime: InternalRuntime;\n}\n\nexport function createDocuments(\n dependencies: DocumentsDependencies,\n): Documents {\n return new DocumentsService(dependencies);\n}\n\nclass DocumentsService implements Documents {\n private readonly schemaEnsuresByExecSql = new WeakMap<\n ExecSql,\n Promise<void>\n >();\n\n constructor(private readonly dependencies: DocumentsDependencies) {}\n\n createSeeded(input: SeededDocumentInput) {\n const { runtime } = this.dependencies;\n const generation = runtime.scopeGeneration;\n return createSeededDocument(\n this.workflowRuntime(input.containerId),\n input,\n () => runtime.scopeGeneration === generation,\n );\n }\n\n async delete(localId: string): Promise<boolean> {\n const runtime = this.workflowRuntime();\n if (runtime.infra.dbStatus !== \"ready\") {\n return false;\n }\n\n const deleted = await deletePersistedDocument({\n deleteDocumentPlacements: runtime.deleteDocumentPlacements,\n documentProjectors: runtime.infra.documentProjectors,\n execSql: runtime.infra.execSql,\n localId,\n persistence: defaultDocumentsPersistence,\n });\n if (!deleted) return false;\n void reclaimDocumentOrphanBlobs(runtime);\n emitPersistedDocumentDeletion(runtime.state.domainScope, localId);\n return true;\n }\n\n async findLocalIdByDocumentId(documentId: string): Promise<string | null> {\n const runtime = this.dependencies.runtime.workflowInput();\n if (runtime.infra.dbStatus !== \"ready\") {\n return null;\n }\n\n await this.ensureSchema(runtime.infra.execSql);\n return defaultDocumentsPersistence.findLocalIdByDocumentId(\n runtime.infra.execSql,\n documentId,\n );\n }\n\n async list(input: ListDocumentsInput = {}): Promise<DocumentList | null> {\n const runtime = this.dependencies.runtime.workflowInput();\n if (runtime.infra.dbStatus !== \"ready\") {\n return null;\n }\n\n await this.ensureSchema(runtime.infra.execSql);\n return defaultDocumentsPersistence.listDocumentSummaries(\n runtime.infra.execSql,\n input,\n );\n }\n\n workflowRuntime(\n containerId = this.dependencies.getDefaultContainerId(),\n ): DocumentsRuntime {\n const { runtime } = this.dependencies;\n return createDocumentsWorkflowRuntimeFromSnapshot({\n ...runtime.workflowInput(containerId),\n deleteDocumentPlacements: runtime.deleteDocumentPlacements,\n });\n }\n\n open(\n input: OpenDocumentInput = {},\n options: OpenDocumentOptions = {},\n ): DocumentStore {\n const {\n containerId,\n documentId = null,\n initialDocumentKind = DEFAULT_DOCUMENT_KIND,\n initialRows,\n initialStructuredFields,\n initialText = \"\",\n localId = DEFAULT_LOCAL_DOCUMENT_ID,\n } = input;\n const runtime =\n options.workflowRuntime ?? this.workflowRuntime(containerId);\n return openDocumentStore(\n runtime.state.domainScope,\n localId,\n runtime,\n documentId,\n initialText,\n initialDocumentKind,\n {\n initialRows,\n initialStructuredFields,\n remoteSyncMode: options.remoteSyncMode,\n },\n );\n }\n\n async openHistory(localId: string): Promise<DocumentHistory | null> {\n const runtime = this.workflowRuntime();\n if (runtime.infra.dbStatus !== \"ready\") {\n return null;\n }\n\n await this.ensureSchema(runtime.infra.execSql);\n return openDocumentHistory({\n documentProjectors: runtime.infra.documentProjectors,\n execSql: runtime.infra.execSql,\n localId,\n persistence: defaultDocumentsPersistence,\n });\n }\n\n retryDownload(input: RetryDocumentDownloadInput): Promise<boolean> {\n return retryDocumentDownload({\n ...input,\n workflowRuntime: (containerId) => this.workflowRuntime(containerId),\n });\n }\n\n subscribe(\n listener: PersistedDocumentListener,\n options: DocumentSubscriptionOptions = {},\n ): () => void {\n return subscribeToPersistedDocuments(\n this.dependencies.runtime.workflowInput(options.containerId).state\n .domainScope,\n listener,\n );\n }\n\n private ensureSchema(execSql: ExecSql): Promise<void> {\n const existing = this.schemaEnsuresByExecSql.get(execSql);\n if (existing) {\n return existing;\n }\n\n const ensure = defaultDocumentsPersistence\n .ensureSchema(execSql)\n .catch((error: unknown) => {\n this.schemaEnsuresByExecSql.delete(execSql);\n throw error;\n });\n this.schemaEnsuresByExecSql.set(execSql, ensure);\n return ensure;\n }\n}\n"]}
|
package/client/index.d.ts
CHANGED
|
@@ -7,7 +7,7 @@ export { type BlobStoreFactory, Blobs } from "./blobs/index.js";
|
|
|
7
7
|
export type { BlobInfo, BlobInfoAttachmentKind, BlobInfoDocumentReference, BlobInfoInput, BlobInfoList, BlobInfoSort, BlobInfoSortDirection, BlobInfoSortKey, ContainerContents, ContainerContentsContextValue, ContainerContentsStore, ContainerContentsStoreOptions, ContainerDocumentLinkInput, ContainerDocumentLinks, ContainerDocumentObjectSyncState, ContainerDocumentObjectSyncStatus, ContainerDocumentQueries, ContainerDocumentSidebarRow, ContainerInfo, ContainerInfoInput, ContainerItemRow, ContainerItemSort, ContainerItemSortDirection, ContainerItemSortKey, ContainerNode, ContainerShareAccessLevel, DocumentAttributionRangesInput, DocumentAttributionRangesPage, DocumentInfo, DocumentInfoInput, LinkDocumentToContainerInput, MergeDocumentSummary, MoveDocumentToContainerInput, OpenContainerDocumentInput, PendingWriteQueueItem, PendingWriteQueueItemStatus, PendingWriteQueueObjectKind, PendingWriteQueueOperation, PendingWriteQueueOperationKind, PendingWriteQueueOperationStatus, PurgeDocumentInput, PurgeDocumentResult, SetActiveDocumentContainerInput, SetLinkedContainerIdsForDocument, UnlinkDocumentFromContainerInput, } from "./containerContents/index.js";
|
|
8
8
|
export { createContainerDocumentObjectSyncState } from "./containerContents/index.js";
|
|
9
9
|
export type { DeviceFirst, DeviceFirstContainerContents, LocalProjectionView, } from "./deviceFirst/index.js";
|
|
10
|
-
export type { DocumentAttachmentStatus, DocumentAttachmentUpload, DocumentContextValue, DocumentHistory, DocumentHistoryChange, DocumentHistoryRowChange, DocumentHistoryStop, DocumentHistoryTextChange, DocumentHistoryVersion, DocumentHistoryVersionEntry, DocumentHistoryView, DocumentList, DocumentSort, DocumentSortDirection, DocumentSortKey, DocumentStore, DocumentSubscriptionOptions, Documents, DocumentsRuntime, ListDocumentsInput, OpenDocumentInput, OpenDocumentOptions, PersistedDocumentListener, SeededDocumentInput, } from "./documents/index.js";
|
|
10
|
+
export type { DocumentAttachmentStatus, DocumentAttachmentUpload, DocumentContextValue, DocumentHistory, DocumentHistoryChange, DocumentHistoryRowChange, DocumentHistoryStop, DocumentHistoryTextChange, DocumentHistoryVersion, DocumentHistoryVersionEntry, DocumentHistoryView, DocumentList, DocumentSort, DocumentSortDirection, DocumentSortKey, DocumentStore, DocumentSubscriptionOptions, Documents, DocumentsRuntime, ListDocumentsInput, OpenDocumentInput, OpenDocumentOptions, PersistedDocumentListener, RetryDocumentDownloadInput, SeededDocumentInput, } from "./documents/index.js";
|
|
11
11
|
export { DEFAULT_DOCUMENT_ID } from "./documents/index.js";
|
|
12
12
|
export type { FileSaver, SaveFileRequest } from "./host/fileSaver.js";
|
|
13
13
|
export type { Logger } from "./host/logger.js";
|
package/client/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,iBAAiB,GAElB,MAAM,4BAA4B,CAAC;AAKpC,OAAO,EACL,8BAA8B,GAE/B,MAAM,wBAAwB,CAAC;AAChC,OAAO,EACL,+BAA+B,EAK/B,8BAA8B,GAC/B,MAAM,0BAA0B,CAAC;AAClC,OAAO,EACL,yBAAyB,EACzB,0BAA0B,EAC1B,oBAAoB,EACpB,yBAAyB,EACzB,sBAAsB,EACtB,4BAA4B,EAC5B,4BAA4B,EAE5B,yBAAyB,GAO1B,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAyB,KAAK,EAAE,MAAM,SAAS,CAAC;AAgDvD,OAAO,EAAE,sCAAsC,EAAE,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,iBAAiB,GAElB,MAAM,4BAA4B,CAAC;AAKpC,OAAO,EACL,8BAA8B,GAE/B,MAAM,wBAAwB,CAAC;AAChC,OAAO,EACL,+BAA+B,EAK/B,8BAA8B,GAC/B,MAAM,0BAA0B,CAAC;AAClC,OAAO,EACL,yBAAyB,EACzB,0BAA0B,EAC1B,oBAAoB,EACpB,yBAAyB,EACzB,sBAAsB,EACtB,4BAA4B,EAC5B,4BAA4B,EAE5B,yBAAyB,GAO1B,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAyB,KAAK,EAAE,MAAM,SAAS,CAAC;AAgDvD,OAAO,EAAE,sCAAsC,EAAE,MAAM,qBAAqB,CAAC;AAiC7E,OAAO,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAUlD,OAAO,EACL,2BAA2B,GAE5B,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAEL,2BAA2B,GAE5B,MAAM,2BAA2B,CAAC;AAyBnC,OAAO,EACL,yBAAyB,EACzB,sCAAsC,EACtC,wCAAwC,EACxC,kCAAkC,EAClC,kBAAkB,EAClB,2CAA2C,EAC3C,qCAAqC,EACrC,+BAA+B,EAC/B,yBAAyB,EACzB,2BAA2B,EAC3B,2BAA2B,EAC3B,6BAA6B,EAC7B,oBAAoB,EACpB,0BAA0B,EAC1B,yBAAyB,EACzB,6BAA6B,EAC7B,2BAA2B,GAC5B,MAAM,gBAAgB,CAAC;AAMxB,OAAO,EACL,gCAAgC,EAChC,gCAAgC,EAChC,mCAAmC,GACpC,MAAM,oCAAoC,CAAC;AA0C5C,OAAO,EACL,2CAA2C,EAC3C,sCAAsC,GACvC,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EACL,QAAQ,GAKT,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EACL,8BAA8B,GAE/B,MAAM,4BAA4B,CAAC;AACpC,OAAO,EACL,MAAM,GAGP,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EACL,gCAAgC,EAChC,OAAO,GAIR,MAAM,mBAAmB,CAAC;AAK3B,OAAO,EACL,eAAe,GAEhB,MAAM,2BAA2B,CAAC;AAOnC,OAAO,EAAE,8CAA8C,EAAE,MAAM,iCAAiC,CAAC","sourcesContent":["export {\n createDomainScope,\n type DomainScope,\n} from \"../data/shared/domainScope\";\nexport type {\n LocalProjectionReconciledDelta,\n LocalProjectionSnapshot,\n} from \"../stores/local-projection\";\nexport {\n enqueueReconciliationForEvents,\n type ReconciliationService,\n} from \"../sync/reconciliation\";\nexport {\n createUnavailableDirectCheckout,\n type DirectCheckoutAppearance,\n type DirectCheckoutCapability,\n type DirectCheckoutConfirmation,\n type DirectCheckoutSession,\n DirectCheckoutUnavailableError,\n} from \"./billing/directCheckout\";\nexport {\n createRevenueCatPurchases,\n createUnavailablePurchases,\n PurchaseAbortedError,\n PurchaseAlreadyOwnedError,\n PurchaseCancelledError,\n PurchaseIdentityPendingError,\n PurchaseProviderStalledError,\n type PurchasesCapability,\n PurchasesUnavailableError,\n type RevenueCatBackend,\n type RevenueCatCustomerInfo,\n type RevenueCatPackage,\n type RevenueCatPurchasesConfig,\n type SyncPurchaseResult,\n type SyncSubscriptionOption,\n} from \"./billing/purchases\";\nexport { type BlobStoreFactory, Blobs } from \"./blobs\";\nexport type {\n BlobInfo,\n BlobInfoAttachmentKind,\n BlobInfoDocumentReference,\n BlobInfoInput,\n BlobInfoList,\n BlobInfoSort,\n BlobInfoSortDirection,\n BlobInfoSortKey,\n ContainerContents,\n ContainerContentsContextValue,\n ContainerContentsStore,\n ContainerContentsStoreOptions,\n ContainerDocumentLinkInput,\n ContainerDocumentLinks,\n ContainerDocumentObjectSyncState,\n ContainerDocumentObjectSyncStatus,\n ContainerDocumentQueries,\n ContainerDocumentSidebarRow,\n ContainerInfo,\n ContainerInfoInput,\n ContainerItemRow,\n ContainerItemSort,\n ContainerItemSortDirection,\n ContainerItemSortKey,\n ContainerNode,\n ContainerShareAccessLevel,\n DocumentAttributionRangesInput,\n DocumentAttributionRangesPage,\n DocumentInfo,\n DocumentInfoInput,\n LinkDocumentToContainerInput,\n MergeDocumentSummary,\n MoveDocumentToContainerInput,\n OpenContainerDocumentInput,\n PendingWriteQueueItem,\n PendingWriteQueueItemStatus,\n PendingWriteQueueObjectKind,\n PendingWriteQueueOperation,\n PendingWriteQueueOperationKind,\n PendingWriteQueueOperationStatus,\n PurgeDocumentInput,\n PurgeDocumentResult,\n SetActiveDocumentContainerInput,\n SetLinkedContainerIdsForDocument,\n UnlinkDocumentFromContainerInput,\n} from \"./containerContents\";\nexport { createContainerDocumentObjectSyncState } from \"./containerContents\";\nexport type {\n DeviceFirst,\n DeviceFirstContainerContents,\n LocalProjectionView,\n} from \"./deviceFirst\";\nexport type {\n DocumentAttachmentStatus,\n DocumentAttachmentUpload,\n DocumentContextValue,\n DocumentHistory,\n DocumentHistoryChange,\n DocumentHistoryRowChange,\n DocumentHistoryStop,\n DocumentHistoryTextChange,\n DocumentHistoryVersion,\n DocumentHistoryVersionEntry,\n DocumentHistoryView,\n DocumentList,\n DocumentSort,\n DocumentSortDirection,\n DocumentSortKey,\n DocumentStore,\n DocumentSubscriptionOptions,\n Documents,\n DocumentsRuntime,\n ListDocumentsInput,\n OpenDocumentInput,\n OpenDocumentOptions,\n PersistedDocumentListener,\n RetryDocumentDownloadInput,\n SeededDocumentInput,\n} from \"./documents\";\nexport { DEFAULT_DOCUMENT_ID } from \"./documents\";\nexport type { FileSaver, SaveFileRequest } from \"./host/fileSaver\";\nexport type { Logger } from \"./host/logger\";\nexport type {\n Identity,\n IdentityGenerationResult,\n IdentityListener,\n IdentityOptions,\n IdentitySnapshot,\n} from \"./identity\";\nexport {\n IDENTITY_KEY_PACKAGE_FORMAT,\n type IdentityKeyPackage,\n} from \"./identity/keyPackage\";\nexport {\n type ResolvedUserIdentity,\n UnverifiedUserIdentityError,\n type UserIdentities,\n} from \"./identity/userIdentities\";\nexport type {\n BrowserLocalKeyringOptions,\n IndexedDbLocalKeyringManifestStoreOptions,\n IndexedDbWrappingKeyKeystoreOptions,\n LocalKeyPurpose,\n LocalKeyring,\n LocalKeyringManifest,\n LocalKeyringManifestFormat,\n LocalKeyringManifestStorage,\n LocalKeyringManifestStore,\n LocalKeyringOptions,\n LocalKeyringScope,\n LocalKeyringSession,\n LocalSecretContext,\n LocalStorageLocalKeyringManifestStoreOptions,\n NormalizedLocalKeyringScope,\n UnwrapLocalSecretInput,\n WrapLocalSecretInput,\n WrappedLocalSecretEnvelope,\n WrappedLocalSecretFormat,\n WrappingKeyHandle,\n WrappingKeyKeystore,\n WrappingKeyMaterialStorage,\n} from \"./localKeyring\";\nexport {\n createBrowserLocalKeyring,\n createBrowserLocalKeyringManifestStore,\n createIndexedDbLocalKeyringManifestStore,\n createIndexedDbWrappingKeyKeystore,\n createLocalKeyring,\n createLocalStorageLocalKeyringManifestStore,\n createMemoryLocalKeyringManifestStore,\n createMemoryWrappingKeyKeystore,\n createWebViewLocalKeyring,\n decodeLocalKeyringSqliteKey,\n encodeLocalKeyringSqliteKey,\n LOCAL_KEYRING_MANIFEST_FORMAT,\n localKeyringScopeKey,\n normalizeLocalKeyringScope,\n parseLocalKeyringManifest,\n serializeLocalKeyringManifest,\n WRAPPED_LOCAL_SECRET_FORMAT,\n} from \"./localKeyring\";\nexport type {\n LocalKeyringPinCode,\n PinCodeBrowserLocalKeyringOptions,\n PinCodeWrappingKeyKeystoreOptions,\n} from \"./localKeyring/localKeyringPinCode\";\nexport {\n createPinCodeBrowserLocalKeyring,\n createPinCodeWrappingKeyKeystore,\n isPinCodeWrappedLocalSecretEnvelope,\n} from \"./localKeyring/localKeyringPinCode\";\nexport type {\n AbandonOrganizationPolicyMutationInput,\n AddOrganizationGroupUserInput,\n DiscardUnreadableOrganizationPolicyMutationInput,\n LocalOrganizationSummary,\n OrganizationBilling,\n OrganizationBillingHistory,\n OrganizationBillingHistoryEntry,\n OrganizationBillingManagementUrl,\n OrganizationBillingView,\n OrganizationContainerGrant,\n OrganizationContainerGrants,\n OrganizationDataUsage,\n OrganizationDeviceDataUsage,\n OrganizationDeviceDocumentUsageCategoryBreakdown,\n OrganizationDirectory,\n OrganizationDirectoryAndGroups,\n OrganizationDirectoryUser,\n OrganizationGrantRef,\n OrganizationGroupContainer,\n OrganizationGroupContainers,\n OrganizationGroupDetails,\n OrganizationGroupMember,\n OrganizationGroupMembers,\n OrganizationGroupMutationReceipt,\n OrganizationGroupMutationResult,\n OrganizationGroupPolicyHistory,\n OrganizationGroupSummary,\n OrganizationLeaveRequestResult,\n OrganizationMembership,\n OrganizationMemberships,\n OrganizationPolicyGrantChange,\n OrganizationPolicyGroupChange,\n OrganizationPolicyHistory,\n OrganizationPolicyHistoryEntry,\n OrganizationProfile,\n OrganizationSyncPauseResult,\n Organizations,\n OrganizationUserDetail,\n RemoveOrganizationGroupUserInput,\n} from \"./organizations\";\nexport {\n createContainerContentsStoreWorkflowRuntime,\n createContainerContentsWorkflowRuntime,\n} from \"./runtime/containerContentsRuntime\";\nexport {\n Database,\n type DatabaseListener,\n type DatabaseOptions,\n type DatabaseSnapshot,\n type DatabaseStatus,\n} from \"./runtime/database\";\nexport {\n createDocumentsWorkflowRuntime,\n type DocumentsWorkflowRuntimeInput,\n} from \"./runtime/documentsRuntime\";\nexport {\n Events,\n type EventsListener,\n type EventsSnapshot,\n} from \"./runtime/events\";\nexport {\n createBrowserNetworkStatusSource,\n Network,\n type NetworkListener,\n type NetworkMode,\n type NetworkStatusSource,\n} from \"./runtime/network\";\nexport type {\n PrincipalHistoryKeyProvider,\n PrincipalHistoryKeyScope,\n} from \"./runtime/principalHistoryProtection\";\nexport {\n SyncBillingGate,\n type SyncBillingGateListener,\n} from \"./runtime/syncBillingGate\";\nexport type {\n SecurityIncident,\n SecurityIncidentListener,\n SecurityIncidentObjectKind,\n SecurityIncidents,\n} from \"./securityIncidents\";\nexport { PurgedOrganizationRecoveryBillingRequiredError } from \"./session/sessionRecoveryErrors\";\nexport type {\n CreateOrganizationOptions,\n Session,\n SessionContext,\n SessionCreateOrganizationResult,\n SessionListener,\n SessionRecoverOrganizationResult,\n SessionRegistrationRefusal,\n SessionRegistrationResult,\n SessionSnapshot,\n UserSession,\n} from \"./session/sessionTypes\";\n"]}
|
package/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export { type ApiRequestCounts, type ApiRequestEndpointCounts, ApiRequestMetrics, type ApiRequestMetricsSnapshot, } from "./internal/api-client/index.js";
|
|
2
2
|
export type { AbandonOrganizationPolicyMutationInput, AddOrganizationGroupUserInput, BlobInfo, BlobInfoAttachmentKind, BlobInfoDocumentReference, BlobInfoInput, BlobInfoList, BlobInfoSort, BlobInfoSortDirection, BlobInfoSortKey, BrowserLocalKeyringOptions, ContainerContents, ContainerContentsContextValue, ContainerContentsStore, ContainerContentsStoreOptions, ContainerDocumentLinkInput, ContainerDocumentLinks, ContainerDocumentObjectSyncState, ContainerDocumentObjectSyncStatus, ContainerDocumentQueries, ContainerDocumentSidebarRow, ContainerInfo, ContainerInfoInput, ContainerItemRow, ContainerItemSort, ContainerItemSortDirection, ContainerItemSortKey, ContainerNode, ContainerShareAccessLevel, CreateOrganizationOptions, DatabaseListener, DatabaseOptions, DatabaseSnapshot, DatabaseStatus, DeviceFirst, DeviceFirstContainerContents, DiscardUnreadableOrganizationPolicyMutationInput, DocumentAttachmentStatus, DocumentAttachmentUpload, DocumentAttributionRangesInput, DocumentAttributionRangesPage, DocumentContextValue, DocumentHistory, DocumentHistoryChange, DocumentHistoryRowChange, DocumentHistoryStop, DocumentHistoryTextChange, DocumentHistoryVersion, DocumentHistoryVersionEntry, DocumentHistoryView, DocumentInfo, DocumentInfoInput, DocumentList, DocumentSort, DocumentSortDirection, DocumentSortKey, DocumentStore, DocumentSubscriptionOptions, Documents, DocumentsRuntime, DocumentsWorkflowRuntimeInput, DomainScope, FileSaver, Identity, IdentityGenerationResult, IdentityKeyPackage, IdentityListener, IdentityOptions, IdentitySnapshot, IndexedDbLocalKeyringManifestStoreOptions, IndexedDbWrappingKeyKeystoreOptions, LinkDocumentToContainerInput, ListDocumentsInput, LocalKeyPurpose, LocalKeyring, LocalKeyringManifest, LocalKeyringManifestFormat, LocalKeyringManifestStorage, LocalKeyringManifestStore, LocalKeyringOptions, LocalKeyringPinCode, LocalKeyringScope, LocalKeyringSession, LocalOrganizationSummary, LocalProjectionReconciledDelta, LocalProjectionSnapshot, LocalProjectionView, LocalSecretContext, LocalStorageLocalKeyringManifestStoreOptions, Logger, MergeDocumentSummary, MoveDocumentToContainerInput, NetworkListener, NetworkMode, NetworkStatusSource, NormalizedLocalKeyringScope, OpenContainerDocumentInput, OpenDocumentInput, OpenDocumentOptions, OrganizationBilling, OrganizationBillingHistory, OrganizationBillingHistoryEntry, OrganizationBillingManagementUrl, OrganizationBillingView, OrganizationContainerGrant, OrganizationContainerGrants, OrganizationDataUsage, OrganizationDeviceDataUsage, OrganizationDeviceDocumentUsageCategoryBreakdown, OrganizationDirectory, OrganizationDirectoryAndGroups, OrganizationDirectoryUser, OrganizationGrantRef, OrganizationGroupContainer, OrganizationGroupContainers, OrganizationGroupDetails, OrganizationGroupMember, OrganizationGroupMembers, OrganizationGroupMutationReceipt, OrganizationGroupMutationResult, OrganizationGroupPolicyHistory, OrganizationGroupSummary, OrganizationLeaveRequestResult, OrganizationMembership, OrganizationMemberships, OrganizationPolicyGrantChange, OrganizationPolicyGroupChange,
|
|
3
3
|
/** Verified organization display page with an optional older-page cursor. */
|
|
4
|
-
OrganizationPolicyHistory, OrganizationPolicyHistoryEntry, OrganizationProfile, OrganizationSyncPauseResult, Organizations, OrganizationUserDetail, PendingWriteQueueItem, PendingWriteQueueItemStatus, PendingWriteQueueObjectKind, PendingWriteQueueOperation, PendingWriteQueueOperationKind, PendingWriteQueueOperationStatus, PersistedDocumentListener, PinCodeBrowserLocalKeyringOptions, PinCodeWrappingKeyKeystoreOptions, PurgeDocumentInput, PurgeDocumentResult, ReconciliationService, RemoveOrganizationGroupUserInput, ResolvedUserIdentity, SaveFileRequest, SecurityIncident, SecurityIncidentListener, SecurityIncidentObjectKind, SecurityIncidents, SeededDocumentInput, Session, SessionContext, SessionCreateOrganizationResult, SessionListener, SessionRecoverOrganizationResult, SessionRegistrationRefusal, SessionRegistrationResult, SessionSnapshot, SetActiveDocumentContainerInput, SetLinkedContainerIdsForDocument, UnlinkDocumentFromContainerInput, UnwrapLocalSecretInput, UserIdentities, UserSession, WrapLocalSecretInput, WrappedLocalSecretEnvelope, WrappedLocalSecretFormat, WrappingKeyHandle, WrappingKeyKeystore, WrappingKeyMaterialStorage, } from "./client/index.js";
|
|
4
|
+
OrganizationPolicyHistory, OrganizationPolicyHistoryEntry, OrganizationProfile, OrganizationSyncPauseResult, Organizations, OrganizationUserDetail, PendingWriteQueueItem, PendingWriteQueueItemStatus, PendingWriteQueueObjectKind, PendingWriteQueueOperation, PendingWriteQueueOperationKind, PendingWriteQueueOperationStatus, PersistedDocumentListener, PinCodeBrowserLocalKeyringOptions, PinCodeWrappingKeyKeystoreOptions, PurgeDocumentInput, PurgeDocumentResult, ReconciliationService, RemoveOrganizationGroupUserInput, ResolvedUserIdentity, RetryDocumentDownloadInput, SaveFileRequest, SecurityIncident, SecurityIncidentListener, SecurityIncidentObjectKind, SecurityIncidents, SeededDocumentInput, Session, SessionContext, SessionCreateOrganizationResult, SessionListener, SessionRecoverOrganizationResult, SessionRegistrationRefusal, SessionRegistrationResult, SessionSnapshot, SetActiveDocumentContainerInput, SetLinkedContainerIdsForDocument, UnlinkDocumentFromContainerInput, UnwrapLocalSecretInput, UserIdentities, UserSession, WrapLocalSecretInput, WrappedLocalSecretEnvelope, WrappedLocalSecretFormat, WrappingKeyHandle, WrappingKeyKeystore, WrappingKeyMaterialStorage, } from "./client/index.js";
|
|
5
5
|
export { type BlobStoreFactory, Blobs, createBrowserLocalKeyring, createBrowserLocalKeyringManifestStore, createBrowserNetworkStatusSource, createContainerContentsStoreWorkflowRuntime, createContainerContentsWorkflowRuntime, createContainerDocumentObjectSyncState, createDocumentsWorkflowRuntime, createDomainScope, createIndexedDbLocalKeyringManifestStore, createIndexedDbWrappingKeyKeystore, createLocalKeyring, createLocalStorageLocalKeyringManifestStore, createMemoryLocalKeyringManifestStore, createMemoryWrappingKeyKeystore, createPinCodeBrowserLocalKeyring, createPinCodeWrappingKeyKeystore, createRevenueCatPurchases, createUnavailableDirectCheckout, createUnavailablePurchases, createWebViewLocalKeyring, Database, DEFAULT_DOCUMENT_ID, type DirectCheckoutAppearance, type DirectCheckoutCapability, type DirectCheckoutConfirmation, type DirectCheckoutSession, DirectCheckoutUnavailableError, decodeLocalKeyringSqliteKey, Events, type EventsListener, type EventsSnapshot, encodeLocalKeyringSqliteKey, enqueueReconciliationForEvents, IDENTITY_KEY_PACKAGE_FORMAT, isPinCodeWrappedLocalSecretEnvelope, LOCAL_KEYRING_MANIFEST_FORMAT, localKeyringScopeKey, Network, normalizeLocalKeyringScope, type PrincipalHistoryKeyProvider, type PrincipalHistoryKeyScope, PurchaseAbortedError, PurchaseAlreadyOwnedError, PurchaseCancelledError, PurchaseIdentityPendingError, PurchaseProviderStalledError, type PurchasesCapability, PurchasesUnavailableError, PurgedOrganizationRecoveryBillingRequiredError, parseLocalKeyringManifest, type RevenueCatBackend, type RevenueCatCustomerInfo, type RevenueCatPackage, type RevenueCatPurchasesConfig, SyncBillingGate, type SyncBillingGateListener, type SyncPurchaseResult, type SyncSubscriptionOption, serializeLocalKeyringManifest, UnverifiedUserIdentityError, WRAPPED_LOCAL_SECRET_FORMAT, } from "./client/index.js";
|
|
6
6
|
export type { DiscoveredDocumentInput, DocumentAttachment, DocumentClientProjectionDefinition, DocumentClientProjectionDeleteInput, DocumentClientProjectionSaveInput, DocumentFieldValidationIssue, DocumentProjection, DocumentProjectorDefinition, DocumentProjectorInput, DocumentProjectorRegistry, DocumentProjectorRegistryInput, DocumentRestoreContent, DocumentRow, DocumentRowSummary, DocumentSummary, EnvFileVariable, StoredDocumentKind, StoredDocumentState, StructuredDocumentMap, StructuredDocumentShape, StructuredDocumentText, ValidatedDocumentFields, } from "./data/documents/index.js";
|
|
7
7
|
export { addDocumentAttachments, createDocumentProjectorRegistry, createDocumentSignerDeviceId, DEFAULT_DOCUMENT_ACCESS_EPOCH, DEFAULT_DOCUMENT_KIND, defaultDocumentProjectorRegistry, deriveStoredDocumentTitle, ENV_FILE_DOCUMENT_KIND, ENV_FILE_NAME_FIELD, ENV_FILE_VARIABLE_KEY_FIELD, ENV_FILE_VARIABLE_NAME_PATTERN, ENV_FILE_VARIABLE_VALUE_FIELD, ensureDocumentAttachmentStructure, getDocumentAttachments, getDocumentClientProjectionTables, getStoredDocumentTypeLabel, getUntitledDocumentTitle, initializeStoredDocumentKind, isValidEnvFileVariableName, parseEnvFileText, projectStoredDocumentState, readStoredDocumentState, readStringDocumentField, resolveOpIdAttribution, sameDocumentAttachments, summarizeDocumentContributors, writerByPeerId, writeStoredDocumentFields, } from "./data/documents/index.js";
|
package/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":"AAAA,iEAAiE;AACjE,yEAAyE;AACzE,gEAAgE;AAChE,OAAO,EAGL,iBAAiB,GAElB,MAAM,uBAAuB,CAAC;AAkL/B,OAAO,EAEL,KAAK,EACL,yBAAyB,EACzB,sCAAsC,EACtC,gCAAgC,EAChC,2CAA2C,EAC3C,sCAAsC,EACtC,sCAAsC,EACtC,8BAA8B,EAC9B,iBAAiB,EACjB,wCAAwC,EACxC,kCAAkC,EAClC,kBAAkB,EAClB,2CAA2C,EAC3C,qCAAqC,EACrC,+BAA+B,EAC/B,gCAAgC,EAChC,gCAAgC,EAChC,yBAAyB,EACzB,+BAA+B,EAC/B,0BAA0B,EAC1B,yBAAyB,EACzB,QAAQ,EACR,mBAAmB,EAKnB,8BAA8B,EAC9B,2BAA2B,EAC3B,MAAM,EAGN,2BAA2B,EAC3B,8BAA8B,EAC9B,2BAA2B,EAC3B,mCAAmC,EACnC,6BAA6B,EAC7B,oBAAoB,EACpB,OAAO,EACP,0BAA0B,EAG1B,oBAAoB,EACpB,yBAAyB,EACzB,sBAAsB,EACtB,4BAA4B,EAC5B,4BAA4B,EAE5B,yBAAyB,EACzB,8CAA8C,EAC9C,yBAAyB,EAKzB,eAAe,EAIf,6BAA6B,EAC7B,2BAA2B,EAC3B,2BAA2B,GAC5B,MAAM,UAAU,CAAC;AAyBlB,OAAO,EACL,sBAAsB,EACtB,+BAA+B,EAC/B,4BAA4B,EAC5B,6BAA6B,EAC7B,qBAAqB,EACrB,gCAAgC,EAChC,yBAAyB,EACzB,sBAAsB,EACtB,mBAAmB,EACnB,2BAA2B,EAC3B,8BAA8B,EAC9B,6BAA6B,EAC7B,iCAAiC,EACjC,sBAAsB,EACtB,iCAAiC,EACjC,0BAA0B,EAC1B,wBAAwB,EACxB,4BAA4B,EAC5B,0BAA0B,EAC1B,gBAA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AClC,gCAAgC,EAChC,4BAA4B,EAC5B,gBAAgB,GACjB,MAAM,0BAA0B,CAAC;AAelC,OAAO,EACL,0BAA0B,EAC1B,mBAAmB,EACnB,uBAAuB,EACvB,kBAAkB,EAClB,6BAA6B,EAC7B,8BAA8B,EAC9B,oCAAoC,EACpC,qBAAqB,EACrB,8BAA8B,EAC9B,gBAAgB,EAChB,uBAAuB,EACvB,oBAAoB,EACpB,6BAA6B,EAyB7B,mBAAmB,GACpB,MAAM,kBAAkB,CAAC;AAe1B,OAAO,EACL,oBAAoB,EACpB,gCAAgC,EAChC,gCAAgC,EAChC,mCAAmC,EACnC,yBAAyB,EACzB,gCAAgC,EAChC,oCAAoC,GACrC,MAAM,kBAAkB,CAAC","sourcesContent":["// SDK: full-bundle identity trust and bounded Members admission.\n// Exact-head authority; canonical writer domains; restart-safe journals.\n// No pin promotion or legacy adapters. See workflows/README.md.\nexport {\n type ApiRequestCounts,\n type ApiRequestEndpointCounts,\n ApiRequestMetrics,\n type ApiRequestMetricsSnapshot,\n} from \"@tearleads/api-client\";\nexport type {\n AbandonOrganizationPolicyMutationInput,\n AddOrganizationGroupUserInput,\n BlobInfo,\n BlobInfoAttachmentKind,\n BlobInfoDocumentReference,\n BlobInfoInput,\n BlobInfoList,\n BlobInfoSort,\n BlobInfoSortDirection,\n BlobInfoSortKey,\n BrowserLocalKeyringOptions,\n ContainerContents,\n ContainerContentsContextValue,\n ContainerContentsStore,\n ContainerContentsStoreOptions,\n ContainerDocumentLinkInput,\n ContainerDocumentLinks,\n ContainerDocumentObjectSyncState,\n ContainerDocumentObjectSyncStatus,\n ContainerDocumentQueries,\n ContainerDocumentSidebarRow,\n ContainerInfo,\n ContainerInfoInput,\n ContainerItemRow,\n ContainerItemSort,\n ContainerItemSortDirection,\n ContainerItemSortKey,\n ContainerNode,\n ContainerShareAccessLevel,\n CreateOrganizationOptions,\n DatabaseListener,\n DatabaseOptions,\n DatabaseSnapshot,\n DatabaseStatus,\n DeviceFirst,\n DeviceFirstContainerContents,\n DiscardUnreadableOrganizationPolicyMutationInput,\n DocumentAttachmentStatus,\n DocumentAttachmentUpload,\n DocumentAttributionRangesInput,\n DocumentAttributionRangesPage,\n DocumentContextValue,\n DocumentHistory,\n DocumentHistoryChange,\n DocumentHistoryRowChange,\n DocumentHistoryStop,\n DocumentHistoryTextChange,\n DocumentHistoryVersion,\n DocumentHistoryVersionEntry,\n DocumentHistoryView,\n DocumentInfo,\n DocumentInfoInput,\n DocumentList,\n DocumentSort,\n DocumentSortDirection,\n DocumentSortKey,\n DocumentStore,\n DocumentSubscriptionOptions,\n Documents,\n DocumentsRuntime,\n DocumentsWorkflowRuntimeInput,\n DomainScope,\n FileSaver,\n Identity,\n IdentityGenerationResult,\n IdentityKeyPackage,\n IdentityListener,\n IdentityOptions,\n IdentitySnapshot,\n IndexedDbLocalKeyringManifestStoreOptions,\n IndexedDbWrappingKeyKeystoreOptions,\n LinkDocumentToContainerInput,\n ListDocumentsInput,\n LocalKeyPurpose,\n LocalKeyring,\n LocalKeyringManifest,\n LocalKeyringManifestFormat,\n LocalKeyringManifestStorage,\n LocalKeyringManifestStore,\n LocalKeyringOptions,\n LocalKeyringPinCode,\n LocalKeyringScope,\n LocalKeyringSession,\n LocalOrganizationSummary,\n LocalProjectionReconciledDelta,\n LocalProjectionSnapshot,\n LocalProjectionView,\n LocalSecretContext,\n LocalStorageLocalKeyringManifestStoreOptions,\n Logger,\n MergeDocumentSummary,\n MoveDocumentToContainerInput,\n NetworkListener,\n NetworkMode,\n NetworkStatusSource,\n NormalizedLocalKeyringScope,\n OpenContainerDocumentInput,\n OpenDocumentInput,\n OpenDocumentOptions,\n OrganizationBilling,\n OrganizationBillingHistory,\n OrganizationBillingHistoryEntry,\n OrganizationBillingManagementUrl,\n OrganizationBillingView,\n OrganizationContainerGrant,\n OrganizationContainerGrants,\n OrganizationDataUsage,\n OrganizationDeviceDataUsage,\n OrganizationDeviceDocumentUsageCategoryBreakdown,\n OrganizationDirectory,\n OrganizationDirectoryAndGroups,\n OrganizationDirectoryUser,\n OrganizationGrantRef,\n OrganizationGroupContainer,\n OrganizationGroupContainers,\n OrganizationGroupDetails,\n OrganizationGroupMember,\n OrganizationGroupMembers,\n OrganizationGroupMutationReceipt,\n OrganizationGroupMutationResult,\n OrganizationGroupPolicyHistory,\n OrganizationGroupSummary,\n OrganizationLeaveRequestResult,\n OrganizationMembership,\n OrganizationMemberships,\n OrganizationPolicyGrantChange,\n OrganizationPolicyGroupChange,\n /** Verified organization display page with an optional older-page cursor. */\n OrganizationPolicyHistory,\n OrganizationPolicyHistoryEntry,\n OrganizationProfile,\n OrganizationSyncPauseResult,\n Organizations,\n OrganizationUserDetail,\n PendingWriteQueueItem,\n PendingWriteQueueItemStatus,\n PendingWriteQueueObjectKind,\n PendingWriteQueueOperation,\n PendingWriteQueueOperationKind,\n PendingWriteQueueOperationStatus,\n // Persistence notifications distinguish placement changes from content saves.\n PersistedDocumentListener,\n PinCodeBrowserLocalKeyringOptions,\n PinCodeWrappingKeyKeystoreOptions,\n PurgeDocumentInput,\n PurgeDocumentResult,\n ReconciliationService,\n RemoveOrganizationGroupUserInput,\n ResolvedUserIdentity,\n SaveFileRequest,\n SecurityIncident,\n SecurityIncidentListener,\n SecurityIncidentObjectKind,\n SecurityIncidents,\n SeededDocumentInput,\n Session,\n SessionContext,\n SessionCreateOrganizationResult,\n SessionListener,\n SessionRecoverOrganizationResult,\n SessionRegistrationRefusal,\n SessionRegistrationResult,\n SessionSnapshot,\n SetActiveDocumentContainerInput,\n SetLinkedContainerIdsForDocument,\n UnlinkDocumentFromContainerInput,\n UnwrapLocalSecretInput,\n UserIdentities,\n UserSession,\n WrapLocalSecretInput,\n WrappedLocalSecretEnvelope,\n WrappedLocalSecretFormat,\n WrappingKeyHandle,\n WrappingKeyKeystore,\n WrappingKeyMaterialStorage,\n} from \"./client\";\nexport {\n type BlobStoreFactory,\n Blobs,\n createBrowserLocalKeyring,\n createBrowserLocalKeyringManifestStore,\n createBrowserNetworkStatusSource,\n createContainerContentsStoreWorkflowRuntime,\n createContainerContentsWorkflowRuntime,\n createContainerDocumentObjectSyncState,\n createDocumentsWorkflowRuntime,\n createDomainScope,\n createIndexedDbLocalKeyringManifestStore,\n createIndexedDbWrappingKeyKeystore,\n createLocalKeyring,\n createLocalStorageLocalKeyringManifestStore,\n createMemoryLocalKeyringManifestStore,\n createMemoryWrappingKeyKeystore,\n createPinCodeBrowserLocalKeyring,\n createPinCodeWrappingKeyKeystore,\n createRevenueCatPurchases,\n createUnavailableDirectCheckout,\n createUnavailablePurchases,\n createWebViewLocalKeyring,\n Database,\n DEFAULT_DOCUMENT_ID,\n type DirectCheckoutAppearance,\n type DirectCheckoutCapability,\n type DirectCheckoutConfirmation,\n type DirectCheckoutSession,\n DirectCheckoutUnavailableError,\n decodeLocalKeyringSqliteKey,\n Events,\n type EventsListener,\n type EventsSnapshot,\n encodeLocalKeyringSqliteKey,\n enqueueReconciliationForEvents,\n IDENTITY_KEY_PACKAGE_FORMAT,\n isPinCodeWrappedLocalSecretEnvelope,\n LOCAL_KEYRING_MANIFEST_FORMAT,\n localKeyringScopeKey,\n Network,\n normalizeLocalKeyringScope,\n type PrincipalHistoryKeyProvider,\n type PrincipalHistoryKeyScope,\n PurchaseAbortedError,\n PurchaseAlreadyOwnedError,\n PurchaseCancelledError,\n PurchaseIdentityPendingError,\n PurchaseProviderStalledError,\n type PurchasesCapability,\n PurchasesUnavailableError,\n PurgedOrganizationRecoveryBillingRequiredError,\n parseLocalKeyringManifest,\n type RevenueCatBackend,\n type RevenueCatCustomerInfo,\n type RevenueCatPackage,\n type RevenueCatPurchasesConfig,\n SyncBillingGate,\n type SyncBillingGateListener,\n type SyncPurchaseResult,\n type SyncSubscriptionOption,\n serializeLocalKeyringManifest,\n UnverifiedUserIdentityError,\n WRAPPED_LOCAL_SECRET_FORMAT,\n} from \"./client\";\nexport type {\n DiscoveredDocumentInput,\n DocumentAttachment,\n DocumentClientProjectionDefinition,\n DocumentClientProjectionDeleteInput,\n DocumentClientProjectionSaveInput,\n DocumentFieldValidationIssue,\n DocumentProjection,\n DocumentProjectorDefinition,\n DocumentProjectorInput,\n DocumentProjectorRegistry,\n DocumentProjectorRegistryInput,\n DocumentRestoreContent,\n DocumentRow,\n DocumentRowSummary,\n DocumentSummary,\n EnvFileVariable,\n StoredDocumentKind,\n StoredDocumentState,\n StructuredDocumentMap,\n StructuredDocumentShape,\n StructuredDocumentText,\n ValidatedDocumentFields,\n} from \"./data/documents\";\nexport {\n addDocumentAttachments,\n createDocumentProjectorRegistry,\n createDocumentSignerDeviceId,\n DEFAULT_DOCUMENT_ACCESS_EPOCH,\n DEFAULT_DOCUMENT_KIND,\n defaultDocumentProjectorRegistry,\n deriveStoredDocumentTitle,\n ENV_FILE_DOCUMENT_KIND,\n ENV_FILE_NAME_FIELD,\n ENV_FILE_VARIABLE_KEY_FIELD,\n ENV_FILE_VARIABLE_NAME_PATTERN,\n ENV_FILE_VARIABLE_VALUE_FIELD,\n ensureDocumentAttachmentStructure,\n getDocumentAttachments,\n getDocumentClientProjectionTables,\n getStoredDocumentTypeLabel,\n getUntitledDocumentTitle,\n initializeStoredDocumentKind,\n isValidEnvFileVariableName,\n parseEnvFileText,\n projectStoredDocumentState,\n readStoredDocumentState,\n readStringDocumentField,\n resolveOpIdAttribution,\n sameDocumentAttachments,\n summarizeDocumentContributors,\n writerByPeerId,\n writeStoredDocumentFields,\n} from \"./data/documents\";\nexport type {\n ContainerContentsSnapshot,\n ContainerContentsStoreRuntime,\n ContainerContentsStoreState,\n ContainerContentsStoreSyncAgent,\n ContainerContentsStoreSyncState,\n ContainerState,\n PurgeMoveSettlement,\n PurgeOptions,\n PurgeProgress,\n} from \"./stores/container-contents\";\nexport {\n createContainerContentsStore,\n createContainerContentsStoreState,\n createContainerContentsStoreSyncAgent,\n getOrCreateContainerContentsStore,\n isSystemContainerNode,\n requestContainerContentsDocumentPriming,\n subscribeToContainerContentsStore,\n updateContainerContentsSnapshot,\n updateContainerContentsStoreRuntime,\n} from \"./stores/container-contents\";\nexport type {\n DocumentMutationGuard,\n DocumentMutationOptions,\n DocumentSnapshot,\n DocumentStoreFacade,\n DocumentStoreOpenOptions,\n DocumentStoreRelinkInput,\n DocumentStructuredFieldPatch,\n} from \"./stores/documents\";\nexport {\n createDocumentStore,\n discardRegisteredDocumentLocalState,\n getOrCreateDocumentStore,\n hasPendingLocalDocumentWrites,\n openDocumentStore,\n requestDomainDocumentSync,\n subscribeToPersistedDocuments,\n} from \"./stores/documents\";\nexport { Tearleads } from \"./Tearleads\";\nexport type {\n TearleadsDatabaseOptions,\n TearleadsOptions,\n} from \"./TearleadsOptions\";\nexport type {\n BlobAttachmentCollaborators,\n BlobAttachmentServiceApi,\n BlobByteSource,\n BlobByteSourceInput,\n BlobBytes,\n BlobStore,\n DecryptDocumentAttachmentBlobRequest,\n DetachDocumentAttachmentRequest,\n DetachDocumentAttachmentResult,\n EncryptedBlobStoreCipher,\n EncryptedBlobStoreKey,\n EncryptedBlobStoreOptions,\n HydrateDocumentAttachmentBlobsRequest,\n HydratedDocumentAttachmentBlob,\n UploadDocumentAttachmentRequest,\n UploadDocumentAttachmentResult,\n WrapEncryptedBlobStoreOptions,\n} from \"./workflows/blobs\";\nexport {\n BlobAttachmentService,\n blobByteSourceInputLength,\n createBlobByteSource,\n createBlobStore,\n createEncryptedBlobStore,\n createLazyEncryptedBlobStore,\n createMemoryBlobStore,\n purgeOpfsBlobStore,\n readBlobByteSource,\n wrapEncryptedBlobStore,\n} from \"./workflows/blobs\";\nexport type {\n ContainerContentsRootAdopter,\n ContainerContentsRootAdoptionInput,\n ContainerContentsStoreWorkflowRuntime,\n ContainerContentsWorkflowRuntime,\n // Distinct from the canonical `ContainerDocumentLinkInput` (./client); the\n // documentQueries variant has a different shape, so it keeps a disambiguating\n // alias on the public surface.\n ContainerDocumentLinkInput as ContainerDocumentQueriesLinkInput,\n ContainerSystemSlotDefinition,\n PendingDownloadQueueItem,\n RecoveryFolder,\n} from \"./workflows/container-contents\";\nexport {\n ContainerSyncWatermarkRepository,\n createContainerContentsDocumentsRuntime,\n createContainerContentsProjectionUserKeyResolver,\n createContainerContentsSyncLane,\n createContainerParentSyncLane,\n createDocumentHeadLinkSetLoader,\n createInitializedContainerMetadataDocument,\n DocumentContainerProjectionRepository,\n defaultContainerContentsPersistence,\n deriveContainerSystemSlot,\n listBlobInfo,\n loadContainerInfo,\n loadDocumentAttributionRanges,\n loadDocumentInfo,\n syncedContainerDocumentObjectSyncState,\n} from \"./workflows/container-contents\";\nexport type {\n AggregatedContainerKekLog,\n ContainerMutationAuthor,\n ContainerMutationCollaborators,\n ContainerReciteApi,\n ContainerWriteRefusal,\n KeyringRebuildResult,\n MaterializedContainerRekeyPlan,\n} from \"./workflows/containers\";\nexport {\n buildMaterializedContainerRekeyPlan,\n buildRootContainerCreatePlan,\n ContainerAuthorAccessError,\n ContainerKekRepairInaccessibleError,\n ContainerKekRepairRequiredError,\n ContainerKeyringOverrideStaleError,\n ContainerMutationService,\n ContainerPathTooDeepError,\n classifyContainerWriteRefusal,\n containerWriterProjectionFromRekeyPlan,\n fetchContainerKekLog,\n HistoricalWrapUnavailableError,\n type HistoricalWrapUnavailableReason,\n isProjectionVerificationCancelledError,\n rebuildKeyringEntriesFromLog,\n recoverKeyringEntryFromWraps,\n rootContainerWriterProjectionFromCreatePlan,\n} from \"./workflows/containers\";\nexport type {\n CreateRemoteDocumentRequest,\n CreateRemoteDocumentResult,\n DocumentBirthResult,\n DocumentRecord,\n DocumentSyncContainerRekeyBuilder,\n DocumentSyncPullContinuation,\n DocumentSyncUpdateIsolationError,\n DocumentsPersistence,\n DocumentsWorkflowRuntime,\n IncomingDocumentSyncUpdateValidator,\n LocalAttachmentRecord,\n PendingAttachmentRecord,\n PendingUpdateInsert,\n PendingUpdateRecord,\n QueuedPendingUpdateRecord,\n RemoteDocumentServiceApi,\n SyncRemoteDocumentRequest,\n SyncRemoteDocumentResult,\n} from \"./workflows/documents\";\nexport {\n buildMaterializedDocumentCreatePlan,\n createDocumentProjectionUserKeyResolver,\n DOCUMENT_SYNC_TRACE_FRAGMENT,\n DOCUMENT_SYNC_TRACE_PATTERN,\n DOCUMENTS_APP_KIND,\n DocumentRawHistoryUnavailableError,\n defaultDocumentsPersistence,\n deletePersistedDocument,\n deriveStableDocumentId,\n isDatabaseUnavailableError,\n isDocumentSyncUpdateIsolationError,\n isEmptyDocumentHistoryChange,\n persistedDocumentCreateStateFromResponse,\n RemoteDocumentService,\n readPullContinuation,\n resolveDocumentCreateAuthor,\n unwrapContainerKekPath,\n unwrapDocumentContentKeyTarget,\n validateDocumentSyncUpdateImports,\n} from \"./workflows/documents\";\n// Nominal identity constructors are available only through the testing subpath\n// for low-level runtime tests.\nexport type {\n AcknowledgedPrincipalCurrentInput,\n AcknowledgedPrincipalCurrentRetirement,\n AuthoredPrincipalMutation,\n OrganizationDocumentUsageCategory,\n OrganizationGroupPolicyHistoryEntry,\n OrganizationNativePurchaseEligibility,\n OrganizationPrincipalMemberChange,\n OrganizationPrincipalMemberChangeType,\n OrganizationPrincipalPolicyHistory,\n OrganizationPrincipalPolicyHistoryEntry,\n PrincipalMutationJournalContext,\n PrincipalMutationJournalScope,\n PrincipalMutationResponse,\n ReconcileOrganizationDataUsageInput,\n} from \"./workflows/organizations\";\nexport {\n abandonJournaledPrincipalMutation,\n addOrganizationGroupUser,\n buildInitialGroupPolicyRequest,\n buildInitialMemberGroupPolicyRequest,\n buildOrganizationGroupPolicyHistory,\n buildOrganizationProfileDocumentPatch,\n buildRosterProfileDocumentPatch,\n checkNativePurchaseEligibility,\n createInitializedRosterProfileDocument,\n createOrganizationGroup,\n DEFAULT_PERSONAL_ORGANIZATION_PROFILE_NAME,\n deriveOrganizationMetadataContainerSystemSlot,\n deriveOrganizationRosterProfileContainerSystemSlot,\n discardUnreadableJournaledPrincipalMutation,\n GroupMembershipNameMismatchError,\n GroupShareNameMismatchError,\n getOrganizationProfileDocumentLocalId,\n getRosterProfileDocumentLocalId,\n loadLocalOrganizationDataUsage,\n loadLocalOrganizationDirectoryAndGroups,\n loadOrganizationBilling,\n loadOrganizationBillingHistory,\n loadOrganizationBillingManagementUrl,\n ORGANIZATION_DOCUMENT_USAGE_CATEGORIES,\n ORGANIZATION_METADATA_CONTAINER_NAME,\n ORGANIZATION_PROFILE_DOCUMENT_KIND,\n ORGANIZATION_ROSTER_PROFILE_CONTAINER_NAME,\n PendingPrincipalMutationError,\n PrincipalMutationOutcomeUnknownError,\n ROSTER_PROFILE_DOCUMENT_KIND,\n readJournaledPrincipalMutation,\n readOrganizationProfileName,\n reconcileOrganizationDataUsage,\n reconcileOrganizationDirectoryAndGroups,\n recoverJournaledPrincipalMutation,\n removeOrganizationGroupUser,\n resolveOrganizationBillingView,\n retainAcknowledgedPrincipalCurrents,\n revokeOrganizationContainerGrant,\n shareRemoteContainerWithGroup,\n startOrganizationTrial,\n submitJournaledPrincipalMutation,\n subscribeOrganizationReadModelInvalidation,\n UnreadablePrincipalMutationError,\n updateOrganizationProfile,\n updateOrganizationRosterEntry,\n} from \"./workflows/organizations\";\nexport type {\n AcknowledgedPrincipalPredecessor,\n CacheReferencedPrincipalPoliciesOptions,\n PrincipalHistoryProtectionLease,\n PrincipalPolicyService,\n ProjectionPolicyHistoryRecoveryOptions,\n RecoveredPrincipalPolicyHistory,\n RecoveredScopedPrincipalPolicyHistory,\n RecoverPrincipalPolicyHistoryOptions,\n RecoverScopedPrincipalPolicyHistoryOptions,\n} from \"./workflows/principals\";\nexport {\n cacheReferencedPrincipalPolicies,\n captureAcknowledgedPrincipalPredecessor,\n PrincipalPolicyHistoryReadError,\n recoverPrincipalPolicyHistory,\n recoverProjectionPolicyHistory,\n recoverScopedPrincipalPolicyHistory,\n} from \"./workflows/principals\";\nexport type {\n InitialRootMetadataBootstrap,\n ProvisionedSystemContainerSpec,\n RegisterIdentityInput,\n RegistrationApi,\n} from \"./workflows/registration\";\nexport {\n bootstrapRootContainer,\n buildInitialOrganizationPolicyRequest,\n createInitialRootMetadataBootstrap,\n deriveRegistrationOrganizationId,\n persistRegistrationBootstrap,\n registerIdentity,\n} from \"./workflows/registration\";\nexport type {\n PendingBlobDeletion,\n PendingBlobDeletionsPage,\n PendingBlobDeletionsQueryInput,\n RootIdentitiesApi,\n RootIdentitiesPage,\n RootIdentitiesQueryInput,\n RootIdentity,\n RootIdentityDetail,\n RootIdentityOrganization,\n RootIdentitySession,\n RootPendingBlobDeletionsQueryInput,\n RootRequestOutcome,\n} from \"./workflows/root\";\nexport {\n liftRootIdentitySuspension,\n listRootAuditEvents,\n listRootDataUsageReport,\n listRootIdentities,\n listRootIdentityOrganizations,\n listRootOrganizationIdentities,\n listRootOrganizationRevenuecatEvents,\n listRootOrganizations,\n listRootRevenuecatEventsReport,\n loadRootIdentity,\n loadRootOpsHealthReport,\n loadRootOrganization,\n loadRootOrganizationDataUsage,\n type RootAuditApi,\n type RootAuditEvent,\n type RootAuditEventsPage,\n type RootAuditEventsQueryInput,\n type RootDataUsageApi,\n type RootDataUsageReportPage,\n type RootOpsHealthApi,\n type RootOpsHealthReport,\n type RootOrganization,\n type RootOrganizationDetail,\n type RootOrganizationIdentitiesPage,\n type RootOrganizationIdentity,\n type RootOrganizationPageQueryInput,\n type RootOrganizationRevenuecatEvent,\n type RootOrganizationRevenuecatEventsPage,\n type RootOrganizationsApi,\n type RootOrganizationsPage,\n type RootOrganizationsQueryInput,\n type RootRevenuecatApi,\n type RootRevenuecatEvent,\n type RootRevenuecatEventsQueryInput,\n type RootRevenuecatEventsReportPage,\n type RootRevenuecatEventsReportQueryInput,\n type RootSuspensionApi,\n suspendRootIdentity,\n} from \"./workflows/root\";\nexport type {\n ClearRemoteSyncStateResult,\n DomainSyncCoordinator,\n DomainSyncSnapshot,\n RemoteResetInput,\n RemoteResetReplacement,\n SyncIdleOptions,\n SyncLane,\n SyncLaneConfig,\n SyncLaneLastAction,\n SyncLanePhase,\n SyncLaneSnapshot,\n SyncLaneStatus,\n} from \"./workflows/sync\";\nexport {\n clearRemoteSyncState,\n getDomainSyncCoordinatorSnapshot,\n getOrCreateDomainSyncCoordinator,\n hasDomainSyncCoordinatorPendingWork,\n requestAllDomainSyncLanes,\n subscribeToDomainSyncCoordinator,\n waitForDomainSyncCoordinatorToSettle,\n} from \"./workflows/sync\";\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":"AAAA,iEAAiE;AACjE,yEAAyE;AACzE,gEAAgE;AAChE,OAAO,EAGL,iBAAiB,GAElB,MAAM,uBAAuB,CAAC;AAmL/B,OAAO,EAEL,KAAK,EACL,yBAAyB,EACzB,sCAAsC,EACtC,gCAAgC,EAChC,2CAA2C,EAC3C,sCAAsC,EACtC,sCAAsC,EACtC,8BAA8B,EAC9B,iBAAiB,EACjB,wCAAwC,EACxC,kCAAkC,EAClC,kBAAkB,EAClB,2CAA2C,EAC3C,qCAAqC,EACrC,+BAA+B,EAC/B,gCAAgC,EAChC,gCAAgC,EAChC,yBAAyB,EACzB,+BAA+B,EAC/B,0BAA0B,EAC1B,yBAAyB,EACzB,QAAQ,EACR,mBAAmB,EAKnB,8BAA8B,EAC9B,2BAA2B,EAC3B,MAAM,EAGN,2BAA2B,EAC3B,8BAA8B,EAC9B,2BAA2B,EAC3B,mCAAmC,EACnC,6BAA6B,EAC7B,oBAAoB,EACpB,OAAO,EACP,0BAA0B,EAG1B,oBAAoB,EACpB,yBAAyB,EACzB,sBAAsB,EACtB,4BAA4B,EAC5B,4BAA4B,EAE5B,yBAAyB,EACzB,8CAA8C,EAC9C,yBAAyB,EAKzB,eAAe,EAIf,6BAA6B,EAC7B,2BAA2B,EAC3B,2BAA2B,GAC5B,MAAM,UAAU,CAAC;AAyBlB,OAAO,EACL,sBAAsB,EACtB,+BAA+B,EAC/B,4BAA4B,EAC5B,6BAA6B,EAC7B,qBAAqB,EACrB,gCAAgC,EAChC,yBAAyB,EACzB,sBAAsB,EACtB,mBAAmB,EACnB,2BAA2B,EAC3B,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C,+BAA+B,EAC/B,6BAA6B,EAC7B,8BAA8B,EAC9B,mCAAmC,GACpC,MAAM,wBAAwB,CAAC;AAOhC,OAAO,EACL,sBAAsB,EACtB,qCAAqC,EACrC,kCAAkC,EAClC,gCAAgC,EAChC,4BAA4B,EAC5B,gBAAgB,GACjB,MAAM,0BAA0B,CAAC;AAelC,OAAO,EACL,0BAA0B,EAC1B,mBAAmB,EACnB,uBAAuB,EACvB,kBAAkB,EAClB,6BAA6B,EAC7B,8BAA8B,EAC9B,oCAAoC,EACpC,qBAAqB,EACrB,8BAA8B,EAC9B,gBAAgB,EAChB,uBAAuB,EACvB,oBAAoB,EACpB,6BAA6B,EAyB7B,mBAAmB,GACpB,MAAM,kBAAkB,CAAC;AAe1B,OAAO,EACL,oBAAoB,EACpB,gCAAgC,EAChC,gCAAgC,EAChC,mCAAmC,EACnC,yBAAyB,EACzB,gCAAgC,EAChC,oCAAoC,GACrC,MAAM,kBAAkB,CAAC","sourcesContent":["// SDK: full-bundle identity trust and bounded Members admission.\n// Exact-head authority; canonical writer domains; restart-safe journals.\n// No pin promotion or legacy adapters. See workflows/README.md.\nexport {\n type ApiRequestCounts,\n type ApiRequestEndpointCounts,\n ApiRequestMetrics,\n type ApiRequestMetricsSnapshot,\n} from \"@tearleads/api-client\";\nexport type {\n AbandonOrganizationPolicyMutationInput,\n AddOrganizationGroupUserInput,\n BlobInfo,\n BlobInfoAttachmentKind,\n BlobInfoDocumentReference,\n BlobInfoInput,\n BlobInfoList,\n BlobInfoSort,\n BlobInfoSortDirection,\n BlobInfoSortKey,\n BrowserLocalKeyringOptions,\n ContainerContents,\n ContainerContentsContextValue,\n ContainerContentsStore,\n ContainerContentsStoreOptions,\n ContainerDocumentLinkInput,\n ContainerDocumentLinks,\n ContainerDocumentObjectSyncState,\n ContainerDocumentObjectSyncStatus,\n ContainerDocumentQueries,\n ContainerDocumentSidebarRow,\n ContainerInfo,\n ContainerInfoInput,\n ContainerItemRow,\n ContainerItemSort,\n ContainerItemSortDirection,\n ContainerItemSortKey,\n ContainerNode,\n ContainerShareAccessLevel,\n CreateOrganizationOptions,\n DatabaseListener,\n DatabaseOptions,\n DatabaseSnapshot,\n DatabaseStatus,\n DeviceFirst,\n DeviceFirstContainerContents,\n DiscardUnreadableOrganizationPolicyMutationInput,\n DocumentAttachmentStatus,\n DocumentAttachmentUpload,\n DocumentAttributionRangesInput,\n DocumentAttributionRangesPage,\n DocumentContextValue,\n DocumentHistory,\n DocumentHistoryChange,\n DocumentHistoryRowChange,\n DocumentHistoryStop,\n DocumentHistoryTextChange,\n DocumentHistoryVersion,\n DocumentHistoryVersionEntry,\n DocumentHistoryView,\n DocumentInfo,\n DocumentInfoInput,\n DocumentList,\n DocumentSort,\n DocumentSortDirection,\n DocumentSortKey,\n DocumentStore,\n DocumentSubscriptionOptions,\n Documents,\n DocumentsRuntime,\n DocumentsWorkflowRuntimeInput,\n DomainScope,\n FileSaver,\n Identity,\n IdentityGenerationResult,\n IdentityKeyPackage,\n IdentityListener,\n IdentityOptions,\n IdentitySnapshot,\n IndexedDbLocalKeyringManifestStoreOptions,\n IndexedDbWrappingKeyKeystoreOptions,\n LinkDocumentToContainerInput,\n ListDocumentsInput,\n LocalKeyPurpose,\n LocalKeyring,\n LocalKeyringManifest,\n LocalKeyringManifestFormat,\n LocalKeyringManifestStorage,\n LocalKeyringManifestStore,\n LocalKeyringOptions,\n LocalKeyringPinCode,\n LocalKeyringScope,\n LocalKeyringSession,\n LocalOrganizationSummary,\n LocalProjectionReconciledDelta,\n LocalProjectionSnapshot,\n LocalProjectionView,\n LocalSecretContext,\n LocalStorageLocalKeyringManifestStoreOptions,\n Logger,\n MergeDocumentSummary,\n MoveDocumentToContainerInput,\n NetworkListener,\n NetworkMode,\n NetworkStatusSource,\n NormalizedLocalKeyringScope,\n OpenContainerDocumentInput,\n OpenDocumentInput,\n OpenDocumentOptions,\n OrganizationBilling,\n OrganizationBillingHistory,\n OrganizationBillingHistoryEntry,\n OrganizationBillingManagementUrl,\n OrganizationBillingView,\n OrganizationContainerGrant,\n OrganizationContainerGrants,\n OrganizationDataUsage,\n OrganizationDeviceDataUsage,\n OrganizationDeviceDocumentUsageCategoryBreakdown,\n OrganizationDirectory,\n OrganizationDirectoryAndGroups,\n OrganizationDirectoryUser,\n OrganizationGrantRef,\n OrganizationGroupContainer,\n OrganizationGroupContainers,\n OrganizationGroupDetails,\n OrganizationGroupMember,\n OrganizationGroupMembers,\n OrganizationGroupMutationReceipt,\n OrganizationGroupMutationResult,\n OrganizationGroupPolicyHistory,\n OrganizationGroupSummary,\n OrganizationLeaveRequestResult,\n OrganizationMembership,\n OrganizationMemberships,\n OrganizationPolicyGrantChange,\n OrganizationPolicyGroupChange,\n /** Verified organization display page with an optional older-page cursor. */\n OrganizationPolicyHistory,\n OrganizationPolicyHistoryEntry,\n OrganizationProfile,\n OrganizationSyncPauseResult,\n Organizations,\n OrganizationUserDetail,\n PendingWriteQueueItem,\n PendingWriteQueueItemStatus,\n PendingWriteQueueObjectKind,\n PendingWriteQueueOperation,\n PendingWriteQueueOperationKind,\n PendingWriteQueueOperationStatus,\n // Persistence notifications distinguish placement changes from content saves.\n PersistedDocumentListener,\n PinCodeBrowserLocalKeyringOptions,\n PinCodeWrappingKeyKeystoreOptions,\n PurgeDocumentInput,\n PurgeDocumentResult,\n ReconciliationService,\n RemoveOrganizationGroupUserInput,\n ResolvedUserIdentity,\n RetryDocumentDownloadInput,\n SaveFileRequest,\n SecurityIncident,\n SecurityIncidentListener,\n SecurityIncidentObjectKind,\n SecurityIncidents,\n SeededDocumentInput,\n Session,\n SessionContext,\n SessionCreateOrganizationResult,\n SessionListener,\n SessionRecoverOrganizationResult,\n SessionRegistrationRefusal,\n SessionRegistrationResult,\n SessionSnapshot,\n SetActiveDocumentContainerInput,\n SetLinkedContainerIdsForDocument,\n UnlinkDocumentFromContainerInput,\n UnwrapLocalSecretInput,\n UserIdentities,\n UserSession,\n WrapLocalSecretInput,\n WrappedLocalSecretEnvelope,\n WrappedLocalSecretFormat,\n WrappingKeyHandle,\n WrappingKeyKeystore,\n WrappingKeyMaterialStorage,\n} from \"./client\";\nexport {\n type BlobStoreFactory,\n Blobs,\n createBrowserLocalKeyring,\n createBrowserLocalKeyringManifestStore,\n createBrowserNetworkStatusSource,\n createContainerContentsStoreWorkflowRuntime,\n createContainerContentsWorkflowRuntime,\n createContainerDocumentObjectSyncState,\n createDocumentsWorkflowRuntime,\n createDomainScope,\n createIndexedDbLocalKeyringManifestStore,\n createIndexedDbWrappingKeyKeystore,\n createLocalKeyring,\n createLocalStorageLocalKeyringManifestStore,\n createMemoryLocalKeyringManifestStore,\n createMemoryWrappingKeyKeystore,\n createPinCodeBrowserLocalKeyring,\n createPinCodeWrappingKeyKeystore,\n createRevenueCatPurchases,\n createUnavailableDirectCheckout,\n createUnavailablePurchases,\n createWebViewLocalKeyring,\n Database,\n DEFAULT_DOCUMENT_ID,\n type DirectCheckoutAppearance,\n type DirectCheckoutCapability,\n type DirectCheckoutConfirmation,\n type DirectCheckoutSession,\n DirectCheckoutUnavailableError,\n decodeLocalKeyringSqliteKey,\n Events,\n type EventsListener,\n type EventsSnapshot,\n encodeLocalKeyringSqliteKey,\n enqueueReconciliationForEvents,\n IDENTITY_KEY_PACKAGE_FORMAT,\n isPinCodeWrappedLocalSecretEnvelope,\n LOCAL_KEYRING_MANIFEST_FORMAT,\n localKeyringScopeKey,\n Network,\n normalizeLocalKeyringScope,\n type PrincipalHistoryKeyProvider,\n type PrincipalHistoryKeyScope,\n PurchaseAbortedError,\n PurchaseAlreadyOwnedError,\n PurchaseCancelledError,\n PurchaseIdentityPendingError,\n PurchaseProviderStalledError,\n type PurchasesCapability,\n PurchasesUnavailableError,\n PurgedOrganizationRecoveryBillingRequiredError,\n parseLocalKeyringManifest,\n type RevenueCatBackend,\n type RevenueCatCustomerInfo,\n type RevenueCatPackage,\n type RevenueCatPurchasesConfig,\n SyncBillingGate,\n type SyncBillingGateListener,\n type SyncPurchaseResult,\n type SyncSubscriptionOption,\n serializeLocalKeyringManifest,\n UnverifiedUserIdentityError,\n WRAPPED_LOCAL_SECRET_FORMAT,\n} from \"./client\";\nexport type {\n DiscoveredDocumentInput,\n DocumentAttachment,\n DocumentClientProjectionDefinition,\n DocumentClientProjectionDeleteInput,\n DocumentClientProjectionSaveInput,\n DocumentFieldValidationIssue,\n DocumentProjection,\n DocumentProjectorDefinition,\n DocumentProjectorInput,\n DocumentProjectorRegistry,\n DocumentProjectorRegistryInput,\n DocumentRestoreContent,\n DocumentRow,\n DocumentRowSummary,\n DocumentSummary,\n EnvFileVariable,\n StoredDocumentKind,\n StoredDocumentState,\n StructuredDocumentMap,\n StructuredDocumentShape,\n StructuredDocumentText,\n ValidatedDocumentFields,\n} from \"./data/documents\";\nexport {\n addDocumentAttachments,\n createDocumentProjectorRegistry,\n createDocumentSignerDeviceId,\n DEFAULT_DOCUMENT_ACCESS_EPOCH,\n DEFAULT_DOCUMENT_KIND,\n defaultDocumentProjectorRegistry,\n deriveStoredDocumentTitle,\n ENV_FILE_DOCUMENT_KIND,\n ENV_FILE_NAME_FIELD,\n ENV_FILE_VARIABLE_KEY_FIELD,\n ENV_FILE_VARIABLE_NAME_PATTERN,\n ENV_FILE_VARIABLE_VALUE_FIELD,\n ensureDocumentAttachmentStructure,\n getDocumentAttachments,\n getDocumentClientProjectionTables,\n getStoredDocumentTypeLabel,\n getUntitledDocumentTitle,\n initializeStoredDocumentKind,\n isValidEnvFileVariableName,\n parseEnvFileText,\n projectStoredDocumentState,\n readStoredDocumentState,\n readStringDocumentField,\n resolveOpIdAttribution,\n sameDocumentAttachments,\n summarizeDocumentContributors,\n writerByPeerId,\n writeStoredDocumentFields,\n} from \"./data/documents\";\nexport type {\n ContainerContentsSnapshot,\n ContainerContentsStoreRuntime,\n ContainerContentsStoreState,\n ContainerContentsStoreSyncAgent,\n ContainerContentsStoreSyncState,\n ContainerState,\n PurgeMoveSettlement,\n PurgeOptions,\n PurgeProgress,\n} from \"./stores/container-contents\";\nexport {\n createContainerContentsStore,\n createContainerContentsStoreState,\n createContainerContentsStoreSyncAgent,\n getOrCreateContainerContentsStore,\n isSystemContainerNode,\n requestContainerContentsDocumentPriming,\n subscribeToContainerContentsStore,\n updateContainerContentsSnapshot,\n updateContainerContentsStoreRuntime,\n} from \"./stores/container-contents\";\nexport type {\n DocumentMutationGuard,\n DocumentMutationOptions,\n DocumentSnapshot,\n DocumentStoreFacade,\n DocumentStoreOpenOptions,\n DocumentStoreRelinkInput,\n DocumentStructuredFieldPatch,\n} from \"./stores/documents\";\nexport {\n createDocumentStore,\n discardRegisteredDocumentLocalState,\n getOrCreateDocumentStore,\n hasPendingLocalDocumentWrites,\n openDocumentStore,\n requestDomainDocumentSync,\n subscribeToPersistedDocuments,\n} from \"./stores/documents\";\nexport { Tearleads } from \"./Tearleads\";\nexport type {\n TearleadsDatabaseOptions,\n TearleadsOptions,\n} from \"./TearleadsOptions\";\nexport type {\n BlobAttachmentCollaborators,\n BlobAttachmentServiceApi,\n BlobByteSource,\n BlobByteSourceInput,\n BlobBytes,\n BlobStore,\n DecryptDocumentAttachmentBlobRequest,\n DetachDocumentAttachmentRequest,\n DetachDocumentAttachmentResult,\n EncryptedBlobStoreCipher,\n EncryptedBlobStoreKey,\n EncryptedBlobStoreOptions,\n HydrateDocumentAttachmentBlobsRequest,\n HydratedDocumentAttachmentBlob,\n UploadDocumentAttachmentRequest,\n UploadDocumentAttachmentResult,\n WrapEncryptedBlobStoreOptions,\n} from \"./workflows/blobs\";\nexport {\n BlobAttachmentService,\n blobByteSourceInputLength,\n createBlobByteSource,\n createBlobStore,\n createEncryptedBlobStore,\n createLazyEncryptedBlobStore,\n createMemoryBlobStore,\n purgeOpfsBlobStore,\n readBlobByteSource,\n wrapEncryptedBlobStore,\n} from \"./workflows/blobs\";\nexport type {\n ContainerContentsRootAdopter,\n ContainerContentsRootAdoptionInput,\n ContainerContentsStoreWorkflowRuntime,\n ContainerContentsWorkflowRuntime,\n // Distinct from the canonical `ContainerDocumentLinkInput` (./client); the\n // documentQueries variant has a different shape, so it keeps a disambiguating\n // alias on the public surface.\n ContainerDocumentLinkInput as ContainerDocumentQueriesLinkInput,\n ContainerSystemSlotDefinition,\n PendingDownloadQueueItem,\n RecoveryFolder,\n} from \"./workflows/container-contents\";\nexport {\n ContainerSyncWatermarkRepository,\n createContainerContentsDocumentsRuntime,\n createContainerContentsProjectionUserKeyResolver,\n createContainerContentsSyncLane,\n createContainerParentSyncLane,\n createDocumentHeadLinkSetLoader,\n createInitializedContainerMetadataDocument,\n DocumentContainerProjectionRepository,\n defaultContainerContentsPersistence,\n deriveContainerSystemSlot,\n listBlobInfo,\n loadContainerInfo,\n loadDocumentAttributionRanges,\n loadDocumentInfo,\n syncedContainerDocumentObjectSyncState,\n} from \"./workflows/container-contents\";\nexport type {\n AggregatedContainerKekLog,\n ContainerMutationAuthor,\n ContainerMutationCollaborators,\n ContainerReciteApi,\n ContainerWriteRefusal,\n KeyringRebuildResult,\n MaterializedContainerRekeyPlan,\n} from \"./workflows/containers\";\nexport {\n buildMaterializedContainerRekeyPlan,\n buildRootContainerCreatePlan,\n ContainerAuthorAccessError,\n ContainerKekRepairInaccessibleError,\n ContainerKekRepairRequiredError,\n ContainerKeyringOverrideStaleError,\n ContainerMutationService,\n ContainerPathTooDeepError,\n classifyContainerWriteRefusal,\n containerWriterProjectionFromRekeyPlan,\n fetchContainerKekLog,\n HistoricalWrapUnavailableError,\n type HistoricalWrapUnavailableReason,\n isProjectionVerificationCancelledError,\n rebuildKeyringEntriesFromLog,\n recoverKeyringEntryFromWraps,\n rootContainerWriterProjectionFromCreatePlan,\n} from \"./workflows/containers\";\nexport type {\n CreateRemoteDocumentRequest,\n CreateRemoteDocumentResult,\n DocumentBirthResult,\n DocumentRecord,\n DocumentSyncContainerRekeyBuilder,\n DocumentSyncPullContinuation,\n DocumentSyncUpdateIsolationError,\n DocumentsPersistence,\n DocumentsWorkflowRuntime,\n IncomingDocumentSyncUpdateValidator,\n LocalAttachmentRecord,\n PendingAttachmentRecord,\n PendingUpdateInsert,\n PendingUpdateRecord,\n QueuedPendingUpdateRecord,\n RemoteDocumentServiceApi,\n SyncRemoteDocumentRequest,\n SyncRemoteDocumentResult,\n} from \"./workflows/documents\";\nexport {\n buildMaterializedDocumentCreatePlan,\n createDocumentProjectionUserKeyResolver,\n DOCUMENT_SYNC_TRACE_FRAGMENT,\n DOCUMENT_SYNC_TRACE_PATTERN,\n DOCUMENTS_APP_KIND,\n DocumentRawHistoryUnavailableError,\n defaultDocumentsPersistence,\n deletePersistedDocument,\n deriveStableDocumentId,\n isDatabaseUnavailableError,\n isDocumentSyncUpdateIsolationError,\n isEmptyDocumentHistoryChange,\n persistedDocumentCreateStateFromResponse,\n RemoteDocumentService,\n readPullContinuation,\n resolveDocumentCreateAuthor,\n unwrapContainerKekPath,\n unwrapDocumentContentKeyTarget,\n validateDocumentSyncUpdateImports,\n} from \"./workflows/documents\";\n// Nominal identity constructors are available only through the testing subpath\n// for low-level runtime tests.\nexport type {\n AcknowledgedPrincipalCurrentInput,\n AcknowledgedPrincipalCurrentRetirement,\n AuthoredPrincipalMutation,\n OrganizationDocumentUsageCategory,\n OrganizationGroupPolicyHistoryEntry,\n OrganizationNativePurchaseEligibility,\n OrganizationPrincipalMemberChange,\n OrganizationPrincipalMemberChangeType,\n OrganizationPrincipalPolicyHistory,\n OrganizationPrincipalPolicyHistoryEntry,\n PrincipalMutationJournalContext,\n PrincipalMutationJournalScope,\n PrincipalMutationResponse,\n ReconcileOrganizationDataUsageInput,\n} from \"./workflows/organizations\";\nexport {\n abandonJournaledPrincipalMutation,\n addOrganizationGroupUser,\n buildInitialGroupPolicyRequest,\n buildInitialMemberGroupPolicyRequest,\n buildOrganizationGroupPolicyHistory,\n buildOrganizationProfileDocumentPatch,\n buildRosterProfileDocumentPatch,\n checkNativePurchaseEligibility,\n createInitializedRosterProfileDocument,\n createOrganizationGroup,\n DEFAULT_PERSONAL_ORGANIZATION_PROFILE_NAME,\n deriveOrganizationMetadataContainerSystemSlot,\n deriveOrganizationRosterProfileContainerSystemSlot,\n discardUnreadableJournaledPrincipalMutation,\n GroupMembershipNameMismatchError,\n GroupShareNameMismatchError,\n getOrganizationProfileDocumentLocalId,\n getRosterProfileDocumentLocalId,\n loadLocalOrganizationDataUsage,\n loadLocalOrganizationDirectoryAndGroups,\n loadOrganizationBilling,\n loadOrganizationBillingHistory,\n loadOrganizationBillingManagementUrl,\n ORGANIZATION_DOCUMENT_USAGE_CATEGORIES,\n ORGANIZATION_METADATA_CONTAINER_NAME,\n ORGANIZATION_PROFILE_DOCUMENT_KIND,\n ORGANIZATION_ROSTER_PROFILE_CONTAINER_NAME,\n PendingPrincipalMutationError,\n PrincipalMutationOutcomeUnknownError,\n ROSTER_PROFILE_DOCUMENT_KIND,\n readJournaledPrincipalMutation,\n readOrganizationProfileName,\n reconcileOrganizationDataUsage,\n reconcileOrganizationDirectoryAndGroups,\n recoverJournaledPrincipalMutation,\n removeOrganizationGroupUser,\n resolveOrganizationBillingView,\n retainAcknowledgedPrincipalCurrents,\n revokeOrganizationContainerGrant,\n shareRemoteContainerWithGroup,\n startOrganizationTrial,\n submitJournaledPrincipalMutation,\n subscribeOrganizationReadModelInvalidation,\n UnreadablePrincipalMutationError,\n updateOrganizationProfile,\n updateOrganizationRosterEntry,\n} from \"./workflows/organizations\";\nexport type {\n AcknowledgedPrincipalPredecessor,\n CacheReferencedPrincipalPoliciesOptions,\n PrincipalHistoryProtectionLease,\n PrincipalPolicyService,\n ProjectionPolicyHistoryRecoveryOptions,\n RecoveredPrincipalPolicyHistory,\n RecoveredScopedPrincipalPolicyHistory,\n RecoverPrincipalPolicyHistoryOptions,\n RecoverScopedPrincipalPolicyHistoryOptions,\n} from \"./workflows/principals\";\nexport {\n cacheReferencedPrincipalPolicies,\n captureAcknowledgedPrincipalPredecessor,\n PrincipalPolicyHistoryReadError,\n recoverPrincipalPolicyHistory,\n recoverProjectionPolicyHistory,\n recoverScopedPrincipalPolicyHistory,\n} from \"./workflows/principals\";\nexport type {\n InitialRootMetadataBootstrap,\n ProvisionedSystemContainerSpec,\n RegisterIdentityInput,\n RegistrationApi,\n} from \"./workflows/registration\";\nexport {\n bootstrapRootContainer,\n buildInitialOrganizationPolicyRequest,\n createInitialRootMetadataBootstrap,\n deriveRegistrationOrganizationId,\n persistRegistrationBootstrap,\n registerIdentity,\n} from \"./workflows/registration\";\nexport type {\n PendingBlobDeletion,\n PendingBlobDeletionsPage,\n PendingBlobDeletionsQueryInput,\n RootIdentitiesApi,\n RootIdentitiesPage,\n RootIdentitiesQueryInput,\n RootIdentity,\n RootIdentityDetail,\n RootIdentityOrganization,\n RootIdentitySession,\n RootPendingBlobDeletionsQueryInput,\n RootRequestOutcome,\n} from \"./workflows/root\";\nexport {\n liftRootIdentitySuspension,\n listRootAuditEvents,\n listRootDataUsageReport,\n listRootIdentities,\n listRootIdentityOrganizations,\n listRootOrganizationIdentities,\n listRootOrganizationRevenuecatEvents,\n listRootOrganizations,\n listRootRevenuecatEventsReport,\n loadRootIdentity,\n loadRootOpsHealthReport,\n loadRootOrganization,\n loadRootOrganizationDataUsage,\n type RootAuditApi,\n type RootAuditEvent,\n type RootAuditEventsPage,\n type RootAuditEventsQueryInput,\n type RootDataUsageApi,\n type RootDataUsageReportPage,\n type RootOpsHealthApi,\n type RootOpsHealthReport,\n type RootOrganization,\n type RootOrganizationDetail,\n type RootOrganizationIdentitiesPage,\n type RootOrganizationIdentity,\n type RootOrganizationPageQueryInput,\n type RootOrganizationRevenuecatEvent,\n type RootOrganizationRevenuecatEventsPage,\n type RootOrganizationsApi,\n type RootOrganizationsPage,\n type RootOrganizationsQueryInput,\n type RootRevenuecatApi,\n type RootRevenuecatEvent,\n type RootRevenuecatEventsQueryInput,\n type RootRevenuecatEventsReportPage,\n type RootRevenuecatEventsReportQueryInput,\n type RootSuspensionApi,\n suspendRootIdentity,\n} from \"./workflows/root\";\nexport type {\n ClearRemoteSyncStateResult,\n DomainSyncCoordinator,\n DomainSyncSnapshot,\n RemoteResetInput,\n RemoteResetReplacement,\n SyncIdleOptions,\n SyncLane,\n SyncLaneConfig,\n SyncLaneLastAction,\n SyncLanePhase,\n SyncLaneSnapshot,\n SyncLaneStatus,\n} from \"./workflows/sync\";\nexport {\n clearRemoteSyncState,\n getDomainSyncCoordinatorSnapshot,\n getOrCreateDomainSyncCoordinator,\n hasDomainSyncCoordinatorPendingWork,\n requestAllDomainSyncLanes,\n subscribeToDomainSyncCoordinator,\n waitForDomainSyncCoordinatorToSettle,\n} from \"./workflows/sync\";\n"]}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { isDatabaseDeletedNotice, responseOutcome } from "./crossTabProtocol.js";
|
|
2
|
+
import { DATABASE_DELETED_MESSAGE, DATABASE_NOT_INITIALIZED_MESSAGE, } from "./types.js";
|
|
3
|
+
export const UNBOUND_CONNECTION = {
|
|
4
|
+
status: "unbound",
|
|
5
|
+
};
|
|
6
|
+
const BOUND_CONNECTION = { status: "bound" };
|
|
7
|
+
const CLOSING_CONNECTION = { status: "closing" };
|
|
8
|
+
const LOST_CONNECTION = { status: "lost" };
|
|
9
|
+
function transitionOpenConnection(state, event) {
|
|
10
|
+
switch (event.type) {
|
|
11
|
+
case "opened":
|
|
12
|
+
return BOUND_CONNECTION;
|
|
13
|
+
case "closeRequested":
|
|
14
|
+
return CLOSING_CONNECTION;
|
|
15
|
+
case "databaseDeleted":
|
|
16
|
+
return UNBOUND_CONNECTION;
|
|
17
|
+
case "databaseMissing":
|
|
18
|
+
case "ownerGone":
|
|
19
|
+
return state.status === "bound" ? LOST_CONNECTION : state;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
export function transitionCrossTabConnection(state, event) {
|
|
23
|
+
switch (state.status) {
|
|
24
|
+
case "lost":
|
|
25
|
+
return state;
|
|
26
|
+
case "closing":
|
|
27
|
+
// Its requests to a vanished owner can never be answered; fail them as
|
|
28
|
+
// lost so the teardown does not wait on them, or retry them elsewhere.
|
|
29
|
+
return event.type === "ownerGone" ? LOST_CONNECTION : state;
|
|
30
|
+
case "unbound":
|
|
31
|
+
case "bound":
|
|
32
|
+
return transitionOpenConnection(state, event);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
/** Whether the client still needs an owner to serve it. */
|
|
36
|
+
export function isOpenCrossTabConnection(state) {
|
|
37
|
+
return state.status === "unbound" || state.status === "bound";
|
|
38
|
+
}
|
|
39
|
+
/** The event a request implies for the client sending it, if any. */
|
|
40
|
+
export function connectionEventForRequest(method) {
|
|
41
|
+
return method === "close" || method === "delete"
|
|
42
|
+
? { type: "closeRequested" }
|
|
43
|
+
: null;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* The event a worker message implies for the client: a response to its
|
|
47
|
+
* `method` request, or an unprompted notice.
|
|
48
|
+
*/
|
|
49
|
+
export function connectionEventForResponse(method, response) {
|
|
50
|
+
if (isDatabaseDeletedNotice(response)) {
|
|
51
|
+
return { type: "databaseDeleted" };
|
|
52
|
+
}
|
|
53
|
+
const outcome = responseOutcome(response);
|
|
54
|
+
if (!outcome) {
|
|
55
|
+
return null;
|
|
56
|
+
}
|
|
57
|
+
if (outcome.ok) {
|
|
58
|
+
return method === "init" ? { type: "opened" } : null;
|
|
59
|
+
}
|
|
60
|
+
if (outcome.message === DATABASE_DELETED_MESSAGE) {
|
|
61
|
+
return { type: "databaseDeleted" };
|
|
62
|
+
}
|
|
63
|
+
return outcome.message === DATABASE_NOT_INITIALIZED_MESSAGE
|
|
64
|
+
? { type: "databaseMissing" }
|
|
65
|
+
: null;
|
|
66
|
+
}
|
|
67
|
+
//# sourceMappingURL=crossTabConnectionMachine.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"crossTabConnectionMachine.js","sourceRoot":"","sources":["crossTabConnectionMachine.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,uBAAuB,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAC9E,OAAO,EACL,wBAA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,KAAK,OAAO,CAAC;AAChE,CAAC;AAED,qEAAqE;AACrE,MAAM,UAAU,yBAAyB,CACvC,MAAqB;IAErB,OAAO,MAAM,KAAK,OAAO,IAAI,MAAM,KAAK,QAAQ;QAC9C,CAAC,CAAC,EAAE,IAAI,EAAE,gBAAgB,EAAE;QAC5B,CAAC,CAAC,IAAI,CAAC;AACX,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,0BAA0B,CACxC,MAAqB,EACrB,QAAiB;IAEjB,IAAI,uBAAuB,CAAC,QAAQ,CAAC,EAAE,CAAC;QACtC,OAAO,EAAE,IAAI,EAAE,iBAAiB,EAAE,CAAC;IACrC,CAAC;IAED,MAAM,OAAO,GAAG,eAAe,CAAC,QAAQ,CAAC,CAAC;IAC1C,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,OAAO,IAAI,CAAC;IACd,CAAC;IAED,IAAI,OAAO,CAAC,EAAE,EAAE,CAAC;QACf,OAAO,MAAM,KAAK,MAAM,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC;IACvD,CAAC;IAED,IAAI,OAAO,CAAC,OAAO,KAAK,wBAAwB,EAAE,CAAC;QACjD,OAAO,EAAE,IAAI,EAAE,iBAAiB,EAAE,CAAC;IACrC,CAAC;IACD,OAAO,OAAO,CAAC,OAAO,KAAK,gCAAgC;QACzD,CAAC,CAAC,EAAE,IAAI,EAAE,iBAAiB,EAAE;QAC7B,CAAC,CAAC,IAAI,CAAC;AACX,CAAC","sourcesContent":["import { isDatabaseDeletedNotice, responseOutcome } from \"./crossTabProtocol\";\nimport {\n DATABASE_DELETED_MESSAGE,\n DATABASE_NOT_INITIALIZED_MESSAGE,\n} from \"./types\";\n\n/**\n * Where one tab-local client's open database lives, as its coordinator sees it.\n *\n * The SQLite worker keeps a client's open database on that client's own\n * connection, so the database exists only in the owner worker that answered\n * the client's `init`. When ownership moves to another tab's worker, the\n * client's later statements reach a connection with no database, and the\n * worker answers every one with \"Database has not been initialized.\" while the\n * host still believes it is ready. This machine lets the coordinator notice\n * that and retire the client instead.\n *\n * - `unbound`: no database is open for the client: before its `init`, or\n * after another connection deliberately deleted it.\n * - `bound`: an `init` succeeded, and the owner worker that answered it holds\n * the client's open database.\n * - `closing`: the client sent `close` or `delete`, so it is being retired.\n * A missing database is the expected end of its last statements racing the\n * teardown, and the client no longer needs an owner.\n * - `lost`: the client's database went away with the owner that held it.\n * Terminal: the host must open a new client. The coordinator answers this\n * one's requests itself, so they never reach an owner that did not open its\n * database.\n *\n * A database another connection deleted is not lost: the worker tells every\n * other connection at once, and answers their later statements that it was\n * deleted. Either unbinds the client, so a later owner change does not turn a\n * deliberate delete (logout, destroying an identity) into a loss the host\n * would reopen behind the tab that made it.\n */\nexport type CrossTabConnectionState =\n | { readonly status: \"unbound\" }\n | { readonly status: \"bound\" }\n | { readonly status: \"closing\" }\n | { readonly status: \"lost\" };\n\nexport type CrossTabConnectionEvent =\n // An `init` succeeded.\n | { readonly type: \"opened\" }\n // The client sent a `close` or `delete`.\n | { readonly type: \"closeRequested\" }\n // A worker answered that the client's connection has no open database.\n | { readonly type: \"databaseMissing\" }\n // A worker said another connection deleted the client's database.\n | { readonly type: \"databaseDeleted\" }\n // The owner worker that served this tab is gone: this tab took the owner\n // lock from it, or the owner worker crashed.\n | { readonly type: \"ownerGone\" };\n\nexport const UNBOUND_CONNECTION: CrossTabConnectionState = {\n status: \"unbound\",\n};\nconst BOUND_CONNECTION: CrossTabConnectionState = { status: \"bound\" };\nconst CLOSING_CONNECTION: CrossTabConnectionState = { status: \"closing\" };\nconst LOST_CONNECTION: CrossTabConnectionState = { status: \"lost\" };\n\nfunction transitionOpenConnection(\n state: CrossTabConnectionState,\n event: CrossTabConnectionEvent,\n): CrossTabConnectionState {\n switch (event.type) {\n case \"opened\":\n return BOUND_CONNECTION;\n case \"closeRequested\":\n return CLOSING_CONNECTION;\n case \"databaseDeleted\":\n return UNBOUND_CONNECTION;\n case \"databaseMissing\":\n case \"ownerGone\":\n return state.status === \"bound\" ? LOST_CONNECTION : state;\n }\n}\n\nexport function transitionCrossTabConnection(\n state: CrossTabConnectionState,\n event: CrossTabConnectionEvent,\n): CrossTabConnectionState {\n switch (state.status) {\n case \"lost\":\n return state;\n case \"closing\":\n // Its requests to a vanished owner can never be answered; fail them as\n // lost so the teardown does not wait on them, or retry them elsewhere.\n return event.type === \"ownerGone\" ? LOST_CONNECTION : state;\n case \"unbound\":\n case \"bound\":\n return transitionOpenConnection(state, event);\n }\n}\n\n/** Whether the client still needs an owner to serve it. */\nexport function isOpenCrossTabConnection(\n state: CrossTabConnectionState,\n): boolean {\n return state.status === \"unbound\" || state.status === \"bound\";\n}\n\n/** The event a request implies for the client sending it, if any. */\nexport function connectionEventForRequest(\n method: string | null,\n): CrossTabConnectionEvent | null {\n return method === \"close\" || method === \"delete\"\n ? { type: \"closeRequested\" }\n : null;\n}\n\n/**\n * The event a worker message implies for the client: a response to its\n * `method` request, or an unprompted notice.\n */\nexport function connectionEventForResponse(\n method: string | null,\n response: unknown,\n): CrossTabConnectionEvent | null {\n if (isDatabaseDeletedNotice(response)) {\n return { type: \"databaseDeleted\" };\n }\n\n const outcome = responseOutcome(response);\n if (!outcome) {\n return null;\n }\n\n if (outcome.ok) {\n return method === \"init\" ? { type: \"opened\" } : null;\n }\n\n if (outcome.message === DATABASE_DELETED_MESSAGE) {\n return { type: \"databaseDeleted\" };\n }\n return outcome.message === DATABASE_NOT_INITIALIZED_MESSAGE\n ? { type: \"databaseMissing\" }\n : null;\n}\n"]}
|
|
@@ -1,8 +1,10 @@
|
|
|
1
|
+
import { connectionEventForRequest, connectionEventForResponse, isOpenCrossTabConnection, transitionCrossTabConnection, UNBOUND_CONNECTION, } from "./crossTabConnectionMachine.js";
|
|
1
2
|
import { createClientLivenessLock, } from "./crossTabLocks.js";
|
|
2
|
-
import { errorResponse, responseId } from "./crossTabProtocol.js";
|
|
3
|
+
import { errorResponse, requestId, requestMethod, responseId, } from "./crossTabProtocol.js";
|
|
4
|
+
import { DatabaseConnectionLostError, } from "./workerCrash.js";
|
|
3
5
|
export function createLocalClient(clientId, events) {
|
|
4
6
|
return {
|
|
5
|
-
|
|
7
|
+
connection: UNBOUND_CONNECTION,
|
|
6
8
|
dispatch: (response) => {
|
|
7
9
|
events.dispatchEvent(new MessageEvent("message", { data: response }));
|
|
8
10
|
},
|
|
@@ -12,12 +14,61 @@ export function createLocalClient(clientId, events) {
|
|
|
12
14
|
events.dispatchEvent(new ErrorEvent("error", { error, message: error.message }));
|
|
13
15
|
},
|
|
14
16
|
liveness: createClientLivenessLock(clientId),
|
|
17
|
+
methodsByRequestId: new Map(),
|
|
15
18
|
timeoutsByRequestId: new Map(),
|
|
16
19
|
pendingRemoteRequestIds: new Set(),
|
|
17
20
|
};
|
|
18
21
|
}
|
|
22
|
+
// Apply an event; true when it just made the client lost.
|
|
23
|
+
function applyConnectionEvent(localClient, event) {
|
|
24
|
+
if (!event) {
|
|
25
|
+
return false;
|
|
26
|
+
}
|
|
27
|
+
const previous = localClient.connection;
|
|
28
|
+
localClient.connection = transitionCrossTabConnection(previous, event);
|
|
29
|
+
return previous.status !== "lost" && localClient.connection.status === "lost";
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Note what a request will do to the client before it is routed. A lost
|
|
33
|
+
* client needs no owner, so its requests fail here instead of waiting for one.
|
|
34
|
+
*/
|
|
35
|
+
export function admitLocalClientRequest(localClient, request) {
|
|
36
|
+
assertLocalClientConnected(localClient);
|
|
37
|
+
const id = requestId(request);
|
|
38
|
+
const method = requestMethod(request);
|
|
39
|
+
applyConnectionEvent(localClient, connectionEventForRequest(method));
|
|
40
|
+
if (id !== null && method !== null) {
|
|
41
|
+
localClient.methodsByRequestId.set(id, method);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* No owner holds a lost client's database, so its requests fail here rather
|
|
46
|
+
* than reach one that would answer as if the database had never been opened.
|
|
47
|
+
*/
|
|
48
|
+
export function assertLocalClientConnected(localClient) {
|
|
49
|
+
if (localClient.connection.status === "lost") {
|
|
50
|
+
throw new DatabaseConnectionLostError();
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
/** Whether the client still needs an owner to serve it. */
|
|
54
|
+
export function isOpenLocalClient(localClient) {
|
|
55
|
+
return isOpenCrossTabConnection(localClient.connection);
|
|
56
|
+
}
|
|
57
|
+
// Every request this client has outstanding — routed locally or posted to a
|
|
58
|
+
// remote owner — is lost with the crashed worker, so drop their timeouts too:
|
|
59
|
+
// the client rejects them all at once and would only ignore the late errors.
|
|
60
|
+
function crashLocalClient(localClient, error) {
|
|
61
|
+
for (const timeoutId of localClient.timeoutsByRequestId.values()) {
|
|
62
|
+
clearTimeout(timeoutId);
|
|
63
|
+
}
|
|
64
|
+
localClient.timeoutsByRequestId.clear();
|
|
65
|
+
localClient.pendingRemoteRequestIds.clear();
|
|
66
|
+
localClient.methodsByRequestId.clear();
|
|
67
|
+
localClient.dispatchError(error);
|
|
68
|
+
}
|
|
19
69
|
export function dispatchResponseToLocalClient(localClient, response) {
|
|
20
70
|
const id = responseId(response);
|
|
71
|
+
let method = null;
|
|
21
72
|
if (id !== null) {
|
|
22
73
|
const timeoutId = localClient.timeoutsByRequestId.get(id);
|
|
23
74
|
if (timeoutId !== undefined) {
|
|
@@ -25,26 +76,37 @@ export function dispatchResponseToLocalClient(localClient, response) {
|
|
|
25
76
|
localClient.timeoutsByRequestId.delete(id);
|
|
26
77
|
}
|
|
27
78
|
localClient.pendingRemoteRequestIds.delete(id);
|
|
79
|
+
method = localClient.methodsByRequestId.get(id) ?? null;
|
|
80
|
+
localClient.methodsByRequestId.delete(id);
|
|
81
|
+
}
|
|
82
|
+
const event = connectionEventForResponse(method, response);
|
|
83
|
+
if (applyConnectionEvent(localClient, event)) {
|
|
84
|
+
// This answer and every other outstanding request fail as one loss.
|
|
85
|
+
crashLocalClient(localClient, new DatabaseConnectionLostError());
|
|
86
|
+
return;
|
|
28
87
|
}
|
|
29
88
|
localClient.dispatch(response);
|
|
30
89
|
}
|
|
31
|
-
//
|
|
32
|
-
//
|
|
33
|
-
// the client rejects them all at once and would only ignore the late errors.
|
|
90
|
+
// The worker serving this client died, so a database it had open died with
|
|
91
|
+
// it. A client already lost was told so when it was lost.
|
|
34
92
|
export function dispatchCrashToLocalClient(localClient, error) {
|
|
35
|
-
|
|
36
|
-
|
|
93
|
+
if (localClient.connection.status === "lost") {
|
|
94
|
+
return;
|
|
37
95
|
}
|
|
38
|
-
localClient
|
|
39
|
-
localClient
|
|
40
|
-
localClient.dispatchError(error);
|
|
96
|
+
applyConnectionEvent(localClient, { type: "ownerGone" });
|
|
97
|
+
crashLocalClient(localClient, error);
|
|
41
98
|
}
|
|
42
99
|
/**
|
|
43
|
-
*
|
|
44
|
-
*
|
|
45
|
-
*
|
|
100
|
+
* This tab just took the owner lock, so the owner it had been routing to is
|
|
101
|
+
* gone. A client with a database open there, or retiring from it, has lost it;
|
|
102
|
+
* any other client only loses the requests it had posted there, which fail
|
|
103
|
+
* with a retryable error rather than waiting out the timeout.
|
|
46
104
|
*/
|
|
47
|
-
export function
|
|
105
|
+
export function releaseLocalClientFromPreviousOwner(localClient) {
|
|
106
|
+
if (applyConnectionEvent(localClient, { type: "ownerGone" })) {
|
|
107
|
+
crashLocalClient(localClient, new DatabaseConnectionLostError());
|
|
108
|
+
return;
|
|
109
|
+
}
|
|
48
110
|
for (const id of [...localClient.pendingRemoteRequestIds]) {
|
|
49
111
|
dispatchResponseToLocalClient(localClient, errorResponse(id, "The database owner tab changed; retry the request."));
|
|
50
112
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"crossTabLocalClient.js","sourceRoot":"","sources":["crossTabLocalClient.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,wBAAwB,GACzB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;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ACxB,KAA+B;IAE/B,KAAK,MAAM,SAAS,IAAI,WAAW,CAAC,mBAAmB,CAAC,MAAM,EAAE,EAAE,CAAC;QACjE,YAAY,CAAC,SAAS,CAAC,CAAC;IAC1B,CAAC;IACD,WAAW,CAAC,mBAAmB,CAAC,KAAK,EAAE,CAAC;IACxC,WAAW,CAAC,uBAAuB,CAAC,KAAK,EAAE,CAAC;IAC5C,WAAW,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;AACnC,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,yBAAyB,CAAC,WAAwB;IAChE,KAAK,MAAM,EAAE,IAAI,CAAC,GAAG,WAAW,CAAC,uBAAuB,CAAC,EAAE,CAAC;QAC1D,6BAA6B,CAC3B,WAAW,EACX,aAAa,CAAC,EAAE,EAAE,oDAAoD,CAAC,CACxE,CAAC;IACJ,CAAC;AACH,CAAC;AAED,MAAM,UAAU,kBAAkB,CAAC,WAAwB;IACzD,KAAK,MAAM,SAAS,IAAI,WAAW,CAAC,mBAAmB,CAAC,MAAM,EAAE,EAAE,CAAC;QACjE,YAAY,CAAC,SAAS,CAAC,CAAC;IAC1B,CAAC;IACD,WAAW,CAAC,QAAQ,CAAC,OAAO,EAAE,CAAC;AACjC,CAAC","sourcesContent":["import {\n type ClientLivenessLock,\n createClientLivenessLock,\n} from \"./crossTabLocks\";\nimport { errorResponse, responseId } from \"./crossTabProtocol\";\nimport type { DatabaseWorkerCrashError } from \"./workerCrash\";\n\n/**\n * One logical client of this tab's coordinator: the synthetic worker handed to a\n * runtime, its liveness lock, and the bookkeeping for requests it has posted to\n * a remote owner tab.\n */\nexport interface LocalClient {\n closing: boolean;\n readonly dispatch: (response: unknown) => void;\n readonly dispatchError: (error: DatabaseWorkerCrashError) => void;\n readonly liveness: ClientLivenessLock;\n readonly timeoutsByRequestId: Map<number, ReturnType<typeof setTimeout>>;\n // Request ids this client posted over BroadcastChannel that have not yet been\n // answered by the owner tab. Used to fail them fast (rather than wait out the\n // timeout) when this tab is promoted to owner after the previous owner died.\n readonly pendingRemoteRequestIds: Set<number>;\n}\n\nexport function createLocalClient(\n clientId: string,\n events: EventTarget,\n): LocalClient {\n return {\n closing: false,\n dispatch: (response) => {\n events.dispatchEvent(new MessageEvent(\"message\", { data: response }));\n },\n // Carries the instance so the client's error handler rejects with the\n // stack minted where the crash was observed, not one rooted here.\n dispatchError: (error) => {\n events.dispatchEvent(\n new ErrorEvent(\"error\", { error, message: error.message }),\n );\n },\n liveness: createClientLivenessLock(clientId),\n timeoutsByRequestId: new Map(),\n pendingRemoteRequestIds: new Set(),\n };\n}\n\nexport function dispatchResponseToLocalClient(\n localClient: LocalClient,\n response: unknown,\n): void {\n const id = responseId(response);\n if (id !== null) {\n const timeoutId = localClient.timeoutsByRequestId.get(id);\n if (timeoutId !== undefined) {\n clearTimeout(timeoutId);\n localClient.timeoutsByRequestId.delete(id);\n }\n localClient.pendingRemoteRequestIds.delete(id);\n }\n\n localClient.dispatch(response);\n}\n\n// Every request this client has outstanding — routed locally or posted to a\n// remote owner — is lost with the crashed worker, so drop their timeouts too:\n// the client rejects them all at once and would only ignore the late errors.\nexport function dispatchCrashToLocalClient(\n localClient: LocalClient,\n error: DatabaseWorkerCrashError,\n): void {\n for (const timeoutId of localClient.timeoutsByRequestId.values()) {\n clearTimeout(timeoutId);\n }\n localClient.timeoutsByRequestId.clear();\n localClient.pendingRemoteRequestIds.clear();\n localClient.dispatchError(error);\n}\n\n/**\n * Fail every still-outstanding remote request of this client with a retryable\n * error. Called when this tab is promoted to owner, because the owner it had\n * posted those requests to is now gone.\n */\nexport function failPendingRemoteRequests(localClient: LocalClient): void {\n for (const id of [...localClient.pendingRemoteRequestIds]) {\n dispatchResponseToLocalClient(\n localClient,\n errorResponse(id, \"The database owner tab changed; retry the request.\"),\n );\n }\n}\n\nexport function releaseLocalClient(localClient: LocalClient): void {\n for (const timeoutId of localClient.timeoutsByRequestId.values()) {\n clearTimeout(timeoutId);\n }\n localClient.liveness.release();\n}\n"]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AE,CAAC;QAC7C,OAAO;IACT,CAAC;IAED,oBAAoB,CAAC,WAAW,EAAE,EAAE,IAAI,EAAE,WAAW,EAAE,CAAC,CAAC;IACzD,gBAAgB,CAAC,WAAW,EAAE,KAAK,CAAC,CAAC;AACvC,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,mCAAmC,CACjD,WAAwB;IAExB,IAAI,oBAAoB,CAAC,WAAW,EAAE,EAAE,IAAI,EAAE,WAAW,EAAE,CAAC,EAAE,CAAC;QAC7D,gBAAgB,CAAC,WAAW,EAAE,IAAI,2BAA2B,EAAE,CAAC,CAAC;QACjE,OAAO;IACT,CAAC;IAED,KAAK,MAAM,EAAE,IAAI,CAAC,GAAG,WAAW,CAAC,uBAAuB,CAAC,EAAE,CAAC;QAC1D,6BAA6B,CAC3B,WAAW,EACX,aAAa,CAAC,EAAE,EAAE,oDAAoD,CAAC,CACxE,CAAC;IACJ,CAAC;AACH,CAAC;AAED,MAAM,UAAU,kBAAkB,CAAC,WAAwB;IACzD,KAAK,MAAM,SAAS,IAAI,WAAW,CAAC,mBAAmB,CAAC,MAAM,EAAE,EAAE,CAAC;QACjE,YAAY,CAAC,SAAS,CAAC,CAAC;IAC1B,CAAC;IACD,WAAW,CAAC,QAAQ,CAAC,OAAO,EAAE,CAAC;AACjC,CAAC","sourcesContent":["import {\n type CrossTabConnectionEvent,\n type CrossTabConnectionState,\n connectionEventForRequest,\n connectionEventForResponse,\n isOpenCrossTabConnection,\n transitionCrossTabConnection,\n UNBOUND_CONNECTION,\n} from \"./crossTabConnectionMachine\";\nimport {\n type ClientLivenessLock,\n createClientLivenessLock,\n} from \"./crossTabLocks\";\nimport {\n errorResponse,\n requestId,\n requestMethod,\n responseId,\n} from \"./crossTabProtocol\";\nimport {\n DatabaseConnectionLostError,\n type DatabaseWorkerCrashError,\n} from \"./workerCrash\";\n\n/**\n * One logical client of this tab's coordinator: the synthetic worker handed to a\n * runtime, its liveness lock, the bookkeeping for requests it has posted to\n * a remote owner tab, and where its open database lives.\n */\nexport interface LocalClient {\n connection: CrossTabConnectionState;\n readonly dispatch: (response: unknown) => void;\n readonly dispatchError: (error: DatabaseWorkerCrashError) => void;\n readonly liveness: ClientLivenessLock;\n // The method of every request still awaiting its response, so a response\n // can say whether it opened the client's database.\n readonly methodsByRequestId: Map<number, string>;\n readonly timeoutsByRequestId: Map<number, ReturnType<typeof setTimeout>>;\n // Request ids this client posted over BroadcastChannel that have not yet been\n // answered by the owner tab. Used to fail them fast (rather than wait out the\n // timeout) when this tab is promoted to owner after the previous owner died.\n readonly pendingRemoteRequestIds: Set<number>;\n}\n\nexport function createLocalClient(\n clientId: string,\n events: EventTarget,\n): LocalClient {\n return {\n connection: UNBOUND_CONNECTION,\n dispatch: (response) => {\n events.dispatchEvent(new MessageEvent(\"message\", { data: response }));\n },\n // Carries the instance so the client's error handler rejects with the\n // stack minted where the crash was observed, not one rooted here.\n dispatchError: (error) => {\n events.dispatchEvent(\n new ErrorEvent(\"error\", { error, message: error.message }),\n );\n },\n liveness: createClientLivenessLock(clientId),\n methodsByRequestId: new Map(),\n timeoutsByRequestId: new Map(),\n pendingRemoteRequestIds: new Set(),\n };\n}\n\n// Apply an event; true when it just made the client lost.\nfunction applyConnectionEvent(\n localClient: LocalClient,\n event: CrossTabConnectionEvent | null,\n): boolean {\n if (!event) {\n return false;\n }\n\n const previous = localClient.connection;\n localClient.connection = transitionCrossTabConnection(previous, event);\n return previous.status !== \"lost\" && localClient.connection.status === \"lost\";\n}\n\n/**\n * Note what a request will do to the client before it is routed. A lost\n * client needs no owner, so its requests fail here instead of waiting for one.\n */\nexport function admitLocalClientRequest(\n localClient: LocalClient,\n request: unknown,\n): void {\n assertLocalClientConnected(localClient);\n const id = requestId(request);\n const method = requestMethod(request);\n applyConnectionEvent(localClient, connectionEventForRequest(method));\n if (id !== null && method !== null) {\n localClient.methodsByRequestId.set(id, method);\n }\n}\n\n/**\n * No owner holds a lost client's database, so its requests fail here rather\n * than reach one that would answer as if the database had never been opened.\n */\nexport function assertLocalClientConnected(localClient: LocalClient): void {\n if (localClient.connection.status === \"lost\") {\n throw new DatabaseConnectionLostError();\n }\n}\n\n/** Whether the client still needs an owner to serve it. */\nexport function isOpenLocalClient(localClient: LocalClient): boolean {\n return isOpenCrossTabConnection(localClient.connection);\n}\n\n// Every request this client has outstanding — routed locally or posted to a\n// remote owner — is lost with the crashed worker, so drop their timeouts too:\n// the client rejects them all at once and would only ignore the late errors.\nfunction crashLocalClient(\n localClient: LocalClient,\n error: DatabaseWorkerCrashError,\n): void {\n for (const timeoutId of localClient.timeoutsByRequestId.values()) {\n clearTimeout(timeoutId);\n }\n localClient.timeoutsByRequestId.clear();\n localClient.pendingRemoteRequestIds.clear();\n localClient.methodsByRequestId.clear();\n localClient.dispatchError(error);\n}\n\nexport function dispatchResponseToLocalClient(\n localClient: LocalClient,\n response: unknown,\n): void {\n const id = responseId(response);\n let method: string | null = null;\n if (id !== null) {\n const timeoutId = localClient.timeoutsByRequestId.get(id);\n if (timeoutId !== undefined) {\n clearTimeout(timeoutId);\n localClient.timeoutsByRequestId.delete(id);\n }\n localClient.pendingRemoteRequestIds.delete(id);\n method = localClient.methodsByRequestId.get(id) ?? null;\n localClient.methodsByRequestId.delete(id);\n }\n\n const event = connectionEventForResponse(method, response);\n if (applyConnectionEvent(localClient, event)) {\n // This answer and every other outstanding request fail as one loss.\n crashLocalClient(localClient, new DatabaseConnectionLostError());\n return;\n }\n\n localClient.dispatch(response);\n}\n\n// The worker serving this client died, so a database it had open died with\n// it. A client already lost was told so when it was lost.\nexport function dispatchCrashToLocalClient(\n localClient: LocalClient,\n error: DatabaseWorkerCrashError,\n): void {\n if (localClient.connection.status === \"lost\") {\n return;\n }\n\n applyConnectionEvent(localClient, { type: \"ownerGone\" });\n crashLocalClient(localClient, error);\n}\n\n/**\n * This tab just took the owner lock, so the owner it had been routing to is\n * gone. A client with a database open there, or retiring from it, has lost it;\n * any other client only loses the requests it had posted there, which fail\n * with a retryable error rather than waiting out the timeout.\n */\nexport function releaseLocalClientFromPreviousOwner(\n localClient: LocalClient,\n): void {\n if (applyConnectionEvent(localClient, { type: \"ownerGone\" })) {\n crashLocalClient(localClient, new DatabaseConnectionLostError());\n return;\n }\n\n for (const id of [...localClient.pendingRemoteRequestIds]) {\n dispatchResponseToLocalClient(\n localClient,\n errorResponse(id, \"The database owner tab changed; retry the request.\"),\n );\n }\n}\n\nexport function releaseLocalClient(localClient: LocalClient): void {\n for (const timeoutId of localClient.timeoutsByRequestId.values()) {\n clearTimeout(timeoutId);\n }\n localClient.liveness.release();\n}\n"]}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { WORKER_DATABASE_DELETED_MESSAGE_TYPE, } from "./types.js";
|
|
1
2
|
function isObject(value) {
|
|
2
3
|
return typeof value === "object" && value !== null;
|
|
3
4
|
}
|
|
@@ -24,6 +25,22 @@ export function requestMethod(request) {
|
|
|
24
25
|
export function responseId(response) {
|
|
25
26
|
return getNumber(response, "id");
|
|
26
27
|
}
|
|
28
|
+
// The worker's unprompted notice that another connection deleted the database.
|
|
29
|
+
export function isDatabaseDeletedNotice(message) {
|
|
30
|
+
return getString(message, "type") === WORKER_DATABASE_DELETED_MESSAGE_TYPE;
|
|
31
|
+
}
|
|
32
|
+
// The outcome a worker response reports, or null for anything that is not one.
|
|
33
|
+
export function responseOutcome(response) {
|
|
34
|
+
if (!isObject(response)) {
|
|
35
|
+
return null;
|
|
36
|
+
}
|
|
37
|
+
const result = Reflect.get(response, "result");
|
|
38
|
+
const ok = isObject(result) ? Reflect.get(result, "ok") : undefined;
|
|
39
|
+
if (typeof ok !== "boolean") {
|
|
40
|
+
return null;
|
|
41
|
+
}
|
|
42
|
+
return { ok, message: getString(result, "message") };
|
|
43
|
+
}
|
|
27
44
|
export function errorResponse(id, message) {
|
|
28
45
|
return {
|
|
29
46
|
id,
|