@tearleads/client-sdk 0.1.42 → 0.1.44
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/client/containerDocumentDiscovery.js +71 -29
- package/client/containerDocumentDiscovery.js.map +1 -1
- package/client/deviceFirst.js +4 -5
- package/client/deviceFirst.js.map +1 -1
- package/data/blobs/transferPool.js +35 -8
- package/data/blobs/transferPool.js.map +1 -1
- package/data/containers/shared/projection.js +12 -0
- package/data/containers/shared/projection.js.map +1 -1
- package/data/documents/blob/shared/types.d.ts +2 -3
- package/data/documents/blob/shared/types.js.map +1 -1
- package/data/documents/shared/events.js +0 -1
- package/data/documents/shared/events.js.map +1 -1
- package/data/persistence/container-contents/containerContentsPersistence.js +6 -22
- package/data/persistence/container-contents/containerContentsPersistence.js.map +1 -1
- package/data/persistence/container-contents/containerMetadataMutationPersistence.js +5 -15
- package/data/persistence/container-contents/containerMetadataMutationPersistence.js.map +1 -1
- package/data/persistence/container-contents/containerPendingUpdatePersistence.js +6 -15
- package/data/persistence/container-contents/containerPendingUpdatePersistence.js.map +1 -1
- package/data/persistence/container-contents/containerRecoveryPersistence.js +3 -4
- package/data/persistence/container-contents/containerRecoveryPersistence.js.map +1 -1
- package/data/persistence/container-contents/containerRemovalWork.js +3 -5
- package/data/persistence/container-contents/containerRemovalWork.js.map +1 -1
- package/data/persistence/container-contents/dormantContainerMetadata.js +1 -5
- package/data/persistence/container-contents/dormantContainerMetadata.js.map +1 -1
- package/data/persistence/containers/containerSyncWatermarkPersistence.d.ts +11 -3
- package/data/persistence/containers/containerSyncWatermarkPersistence.js +46 -58
- package/data/persistence/containers/containerSyncWatermarkPersistence.js.map +1 -1
- package/data/persistence/documents/documentsPersistence.js +4 -9
- package/data/persistence/documents/documentsPersistence.js.map +1 -1
- package/data/persistence/documents/internal/discardDocument.js +1 -2
- package/data/persistence/documents/internal/discardDocument.js.map +1 -1
- package/data/persistence/documents/internal/documentDeletionPersistence.js +1 -2
- package/data/persistence/documents/internal/documentDeletionPersistence.js.map +1 -1
- package/data/persistence/documents/internal/documentMutationPersistence.js +17 -25
- package/data/persistence/documents/internal/documentMutationPersistence.js.map +1 -1
- package/data/persistence/documents/internal/orphanSideRows.js +2 -14
- package/data/persistence/documents/internal/orphanSideRows.js.map +1 -1
- package/data/persistence/documents/internal/syncQueuePersistence.js +3 -3
- package/data/persistence/documents/internal/syncQueuePersistence.js.map +1 -1
- package/data/sqlite/documentHistoryPersistence.d.ts +9 -3
- package/data/sqlite/documentHistoryPersistence.js +31 -8
- package/data/sqlite/documentHistoryPersistence.js.map +1 -1
- package/data/sqlite/documentPendingUpdatePersistence.d.ts +58 -11
- package/data/sqlite/documentPendingUpdatePersistence.js +137 -63
- package/data/sqlite/documentPendingUpdatePersistence.js.map +1 -1
- package/data/sqlite/documentPersistence.d.ts +1 -1
- package/data/sqlite/documentPersistence.js +1 -1
- package/data/sqlite/documentPersistence.js.map +1 -1
- package/data/sqlite/documentPersistenceTypes.d.ts +2 -2
- package/data/sqlite/documentPersistenceTypes.js.map +1 -1
- package/data/sqlite/documentRecordPersistence.js +5 -4
- package/data/sqlite/documentRecordPersistence.js.map +1 -1
- package/data/sqlite/schema.d.ts +167 -517
- package/data/sqlite/schema.js +68 -82
- package/data/sqlite/schema.js.map +1 -1
- package/internal/api-client/ApiClient.d.ts +18 -41
- package/internal/api-client/ApiClient.js +9 -14
- package/internal/api-client/ApiClient.js.map +1 -1
- package/internal/api-client/apiRequestRuntime.d.ts +2 -0
- package/internal/api-client/apiRequestRuntime.js +4 -0
- package/internal/api-client/apiRequestRuntime.js.map +1 -1
- package/internal/api-client/binaryRequestOperationTransport.d.ts +18 -0
- package/internal/api-client/index.d.ts +1 -0
- package/internal/api-client/index.js +1 -0
- package/internal/api-client/index.js.map +1 -1
- package/internal/api-client/operationTransportFactory.d.ts +6 -0
- package/internal/api-client/requestInternals.js +7 -7
- package/internal/api-client/requestInternals.js.map +1 -1
- package/internal/api-client/routes/blobs/get.d.ts +7 -0
- package/internal/api-client/routes/blobs/get.js.map +1 -1
- package/internal/api-client/routes/blobs/multipart.js +1 -11
- package/internal/api-client/routes/blobs/multipart.js.map +1 -1
- package/internal/api-client/routes/blobs/multipartUpload.d.ts +14 -0
- package/internal/api-client/routes/blobs/multipartUpload.js +94 -43
- package/internal/api-client/routes/blobs/multipartUpload.js.map +1 -1
- package/internal/api-client/routes/containers/reads.d.ts +13 -7
- package/internal/api-client/routes/containers/reads.js +36 -15
- package/internal/api-client/routes/containers/reads.js.map +1 -1
- package/internal/api-client/types.d.ts +1 -5
- package/internal/api-client/types.js.map +1 -1
- package/internal/validators/containerReadRefinements.js +15 -5
- package/internal/validators/containerReadRefinements.js.map +1 -1
- package/internal/validators/containerReadSchemas.d.ts +36 -0
- package/internal/validators/containerReadSchemas.js +64 -1
- package/internal/validators/containerReadSchemas.js.map +1 -1
- package/internal/validators/operation/attachments.d.ts +80 -160
- package/internal/validators/operation/auth.d.ts +760 -1664
- package/internal/validators/operation/blobDownloads.js +1 -1
- package/internal/validators/operation/blobDownloads.js.map +1 -1
- package/internal/validators/operation/containerMutations.d.ts +416 -856
- package/internal/validators/operation/containerReads.d.ts +118 -182
- package/internal/validators/operation/containerReads.js +20 -54
- package/internal/validators/operation/containerReads.js.map +1 -1
- package/internal/validators/operation/documentMutations.d.ts +120 -264
- package/internal/validators/operation/documentSync.d.ts +40 -80
- package/internal/validators/operation/index.d.ts +2 -2
- package/internal/validators/operation/index.js +2 -2
- package/internal/validators/operation/index.js.map +1 -1
- package/internal/validators/operation/multipartBlobs.d.ts +70 -190
- package/internal/validators/operation/multipartBlobs.js +2 -24
- package/internal/validators/operation/multipartBlobs.js.map +1 -1
- package/internal/validators/operation/multipartPartUploads.d.ts +5 -5
- package/internal/validators/operation/multipartPartUploads.js +6 -20
- package/internal/validators/operation/multipartPartUploads.js.map +1 -1
- package/internal/validators/operation/organizations.d.ts +882 -1906
- package/internal/validators/operation/principals.d.ts +120 -240
- package/internal/validators/operation/registry.d.ts +3 -4
- package/internal/validators/operation/registry.js +3 -4
- package/internal/validators/operation/registry.js.map +1 -1
- package/internal/validators/request/blob.d.ts +100 -201
- package/internal/validators/request/blob.js +6 -13
- package/internal/validators/request/blob.js.map +1 -1
- package/internal/validators/request/container.d.ts +136 -272
- package/internal/validators/request/container.js +16 -10
- package/internal/validators/request/container.js.map +1 -1
- package/internal/validators/request/containerDocumentLanes.d.ts +23 -0
- package/internal/validators/request/containerDocumentLanes.js +23 -0
- package/internal/validators/request/containerDocumentLanes.js.map +1 -0
- package/internal/validators/request/containerManifestRef.d.ts +54 -0
- package/internal/validators/request/containerManifestRef.js +28 -0
- package/internal/validators/request/containerManifestRef.js.map +1 -0
- package/internal/validators/request/containerMetadata.d.ts +160 -368
- package/internal/validators/request/containerParentLanes.js +5 -35
- package/internal/validators/request/containerParentLanes.js.map +1 -1
- package/internal/validators/request/document.d.ts +100 -245
- package/internal/validators/request/document.js +1 -2
- package/internal/validators/request/document.js.map +1 -1
- package/internal/validators/request/documentSyncSchema.d.ts +42 -109
- package/internal/validators/request/documentSyncSchema.js +8 -25
- package/internal/validators/request/documentSyncSchema.js.map +1 -1
- package/internal/validators/request/index.d.ts +2 -1
- package/internal/validators/request/index.js +2 -1
- package/internal/validators/request/index.js.map +1 -1
- package/internal/validators/request/organization.d.ts +160 -320
- package/internal/validators/request/organizationProvisioning.d.ts +2424 -5312
- package/internal/validators/request/principal.d.ts +160 -320
- package/internal/validators/request/registration.d.ts +760 -1664
- package/internal/validators/response/blob.d.ts +48 -27
- package/internal/validators/response/blob.js +3 -10
- package/internal/validators/response/blob.js.map +1 -1
- package/internal/validators/response/containerDocumentLanes.d.ts +82 -0
- package/internal/validators/response/containerDocumentLanes.js +35 -0
- package/internal/validators/response/containerDocumentLanes.js.map +1 -0
- package/internal/validators/response/containerParentLanes.js +3 -15
- package/internal/validators/response/containerParentLanes.js.map +1 -1
- package/internal/validators/response/index.d.ts +3 -2
- package/internal/validators/response/index.js +2 -2
- package/internal/validators/response/index.js.map +1 -1
- package/internal/validators/util/blob.d.ts +7 -0
- package/internal/validators/util/blob.js +7 -0
- package/internal/validators/util/blob.js.map +1 -1
- package/internal/validators/util/blobTransferSchemas.d.ts +41 -0
- package/internal/validators/util/blobTransferSchemas.js +39 -0
- package/internal/validators/util/blobTransferSchemas.js.map +1 -0
- package/internal/validators/util/containerLimits.d.ts +7 -0
- package/internal/validators/util/containerLimits.js +7 -0
- package/internal/validators/util/containerLimits.js.map +1 -1
- package/internal/validators/util/index.d.ts +2 -1
- package/internal/validators/util/index.js +2 -1
- package/internal/validators/util/index.js.map +1 -1
- package/package.json +1 -1
- package/sync/reconciliation/knownContainerSweep.js +57 -54
- package/sync/reconciliation/knownContainerSweep.js.map +1 -1
- package/sync/reconciliation/reconcileContainer.js +49 -17
- package/sync/reconciliation/reconcileContainer.js.map +1 -1
- package/sync/reconciliation/service.js +44 -16
- package/sync/reconciliation/service.js.map +1 -1
- package/sync/reconciliation/serviceTypes.d.ts +23 -2
- package/sync/reconciliation/serviceTypes.js.map +1 -1
- package/workflows/blobs/multipartFirstParts.js +82 -0
- package/workflows/blobs/multipartFirstParts.js.map +1 -0
- package/workflows/blobs/multipartStageResolution.js +83 -0
- package/workflows/blobs/multipartStageResolution.js.map +1 -0
- package/workflows/blobs/multipartUpload.js +45 -89
- package/workflows/blobs/multipartUpload.js.map +1 -1
- package/workflows/container-contents/containerDocumentListing.js +92 -38
- package/workflows/container-contents/containerDocumentListing.js.map +1 -1
- package/workflows/container-contents/containerPersistence.d.ts +8 -2
- package/workflows/container-contents/containerPersistence.js +6 -7
- package/workflows/container-contents/containerPersistence.js.map +1 -1
- package/workflows/container-contents/documentDiscovery.d.ts +3 -3
- package/workflows/container-contents/documentDiscovery.js +24 -96
- package/workflows/container-contents/documentDiscovery.js.map +1 -1
- package/workflows/container-contents/documentDiscoveryApply.js +65 -0
- package/workflows/container-contents/documentDiscoveryApply.js.map +1 -0
- package/workflows/container-contents/documentDiscoveryLanes.js +53 -0
- package/workflows/container-contents/documentDiscoveryLanes.js.map +1 -0
- package/workflows/container-contents/documentDiscoveryTypes.d.ts +25 -19
- package/workflows/container-contents/documentDiscoveryTypes.js.map +1 -1
- package/workflows/container-contents/documentPriming.js +2 -1
- package/workflows/container-contents/documentPriming.js.map +1 -1
- package/workflows/container-contents/documentQueries/sql.js +4 -4
- package/workflows/container-contents/documentQueries/sql.js.map +1 -1
- package/workflows/container-contents/pendingWrites/deferredTails.js +6 -3
- package/workflows/container-contents/pendingWrites/deferredTails.js.map +1 -1
- package/workflows/container-contents/pendingWrites/sources.js +2 -1
- package/workflows/container-contents/pendingWrites/sources.js.map +1 -1
- package/workflows/container-contents/pendingWrites.js +2 -1
- package/workflows/container-contents/pendingWrites.js.map +1 -1
- package/workflows/container-contents/remoteHydration/laneFetchMarkers.js +11 -17
- package/workflows/container-contents/remoteHydration/laneFetchMarkers.js.map +1 -1
- package/workflows/containers/child/create.js +3 -3
- package/workflows/containers/child/create.js.map +1 -1
- package/workflows/containers/child/move.js +2 -2
- package/workflows/containers/child/move.js.map +1 -1
- package/workflows/containers/child/mutationRequestCore.js +5 -4
- package/workflows/containers/child/mutationRequestCore.js.map +1 -1
- package/workflows/containers/child/recitePlan.js +3 -2
- package/workflows/containers/child/recitePlan.js.map +1 -1
- package/workflows/containers/child/sharePlanCore.js +2 -2
- package/workflows/containers/child/sharePlanCore.js.map +1 -1
- package/workflows/containers/root/create.js +2 -2
- package/workflows/containers/root/create.js.map +1 -1
- package/workflows/registration/provisioningBootstrapBuilders.d.ts +20 -46
- package/workflows/sync/remoteReset.js +9 -9
- package/workflows/sync/remoteReset.js.map +1 -1
- package/workflows/sync/remoteResetCursorScope.js +10 -18
- package/workflows/sync/remoteResetCursorScope.js.map +1 -1
- package/workflows/sync/remoteResetPlans.js +6 -3
- package/workflows/sync/remoteResetPlans.js.map +1 -1
- package/workflows/sync/remoteResetScope.js +4 -11
- package/workflows/sync/remoteResetScope.js.map +1 -1
- package/internal/validators/operation/blobTransferSchemas.js +0 -11
- package/internal/validators/operation/blobTransferSchemas.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"document.js","sourceRoot":"","sources":["document.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,6BAA6B,EAAE,MAAM,4BAA4B,CAAC;AAC3E,OAAO,EAAE,oCAAoC,EAAE,MAAM,eAAe,CAAC;AACrE,OAAO,EACL,WAAW,EACX,gBAAgB,EAChB,oBAAoB,EACpB,iBAAiB,EACjB,qBAAqB,GACtB,MAAM,WAAW,CAAC;AACnB,OAAO,EACL,
|
|
1
|
+
{"version":3,"file":"document.js","sourceRoot":"","sources":["document.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,6BAA6B,EAAE,MAAM,4BAA4B,CAAC;AAC3E,OAAO,EAAE,oCAAoC,EAAE,MAAM,eAAe,CAAC;AACrE,OAAO,EACL,WAAW,EACX,gBAAgB,EAChB,oBAAoB,EACpB,iBAAiB,EACjB,qBAAqB,GACtB,MAAM,WAAW,CAAC;AACnB,OAAO,EACL,yBAAyB,EACzB,yCAAyC,EACzC,qCAAqC,EACrC,2BAA2B,GAC5B,MAAM,SAAS,CAAC;AACjB,OAAO,EAAE,8BAA8B,EAAE,MAAM,aAAa,CAAC;AAC7D,OAAO,EACL,2BAA2B,EAE3B,oCAAoC,EAEpC,qCAAqC,EACrC,4BAA4B,EAE5B,yBAAyB,GAC1B,MAAM,sBAAsB,CAAC;AAE9B,OAAO,EAEL,oCAAoC,EACpC,0BAA0B,EAE1B,qCAAqC,EAErC,sCAAsC,EAEtC,4BAA4B,EAE5B,yBAAyB,GAC1B,MAAM,sBAAsB,CAAC;AAE9B,MAAM,CAAC,MAAM,0BAA0B,GAAG;IACxC,4BAA4B,EAAE,oCAAoC,CAAC,QAAQ,EAAE;IAC7E,IAAI,EAAE,qBAAqB;IAC3B,eAAe,EAAE,WAAW,CAC1B,8BAA8B,EAC9B,2BAA2B,CAC5B,CAAC,QAAQ,EAAE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AC,OAAO,CAAC;AAC7D,CAAC;AAED,MAAM,UAAU,qBAAqB,CACnC,KAAc;IAEd,OAAO,yBAAyB,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,OAAO,CAAC;AAC5D,CAAC","sourcesContent":["import type { z } from \"zod\";\nimport { documentLinkSetPathRefinement } from \"../documentSyncRefinements\";\nimport { registerJsonSchemaRuntimeRefinements } from \"../jsonSchema\";\nimport {\n arraySchema,\n loosePlainObject,\n nonEmptyStringSchema,\n plainObjectSchema,\n requiredUnknownSchema,\n} from \"../schema\";\nimport {\n MAX_CONTAINER_PATH_LENGTH,\n MAX_DOCUMENT_SYNC_AUTHORIZATION_PATH_REFS,\n MAX_DOCUMENT_SYNC_AUTHORIZATION_PATHS,\n MAX_INLINE_CONTAINER_REKEYS,\n} from \"../util\";\nimport { ContainerMutationRequestSchema } from \"./container\";\nimport {\n ContainerManifestPathSchema,\n type ContainerManifestRef,\n ContainerManifestRefArrayArraySchema,\n type DocumentContentKeyBundleRequest,\n DocumentContentKeyBundleRequestSchema,\n DocumentOutgoingUpdateSchema,\n type DocumentSyncRequest,\n DocumentSyncRequestSchema,\n} from \"./documentSyncSchema\";\n\nexport {\n type ContainerManifestRef,\n ContainerManifestRefArrayArraySchema,\n ContainerManifestRefSchema,\n type DocumentContentKeyBundleRequest,\n DocumentContentKeyBundleRequestSchema,\n type DocumentContentKeyTargetEnvelope,\n DocumentContentKeyTargetEnvelopeSchema,\n type DocumentOutgoingUpdate,\n DocumentOutgoingUpdateSchema,\n type DocumentSyncRequest,\n DocumentSyncRequestSchema,\n} from \"./documentSyncSchema\";\n\nexport const documentCreateRequestShape = {\n authorizingContainerPathRefs: ContainerManifestRefArrayArraySchema.optional(),\n body: requiredUnknownSchema,\n containerRekeys: arraySchema(\n ContainerMutationRequestSchema,\n MAX_INLINE_CONTAINER_REKEYS,\n ).optional(),\n contentKeyBundle: DocumentContentKeyBundleRequestSchema,\n event: plainObjectSchema,\n expectedManifestHash: nonEmptyStringSchema,\n manifest: plainObjectSchema,\n targetContainerPathRefs: ContainerManifestPathSchema.optional(),\n} satisfies z.ZodRawShape;\n\nexport const DocumentCreateRequestSchema = loosePlainObject(\n documentCreateRequestShape,\n);\n\nexport type DocumentCreateRequest = z.infer<typeof DocumentCreateRequestSchema>;\n\n// The prior link-set manifest is the document's current head. The server\n// resolves it from its own store, while the signed event's previous manifest\n// hash pins freshness, so the writer does not echo the bundle back.\nexport const DocumentLinkSetMutationRequestSchema =\n registerJsonSchemaRuntimeRefinements(\n loosePlainObject({\n authorizingContainerPathRefs: ContainerManifestRefArrayArraySchema,\n body: requiredUnknownSchema,\n containerRekeys: arraySchema(\n ContainerMutationRequestSchema,\n MAX_INLINE_CONTAINER_REKEYS,\n ).optional(),\n contentKeyBundle: DocumentContentKeyBundleRequestSchema,\n event: plainObjectSchema,\n expectedManifestHash: nonEmptyStringSchema,\n manifest: plainObjectSchema,\n rotationBaseline: DocumentOutgoingUpdateSchema.optional(),\n // A container path (root→leaf chain) must carry at least one manifest\n // reference; an empty path authorizes nothing and is never legitimately built.\n targetContainerPathRefs: ContainerManifestPathSchema,\n }).superRefine((request, context) => {\n if (\n !Array.isArray(request.authorizingContainerPathRefs) ||\n !Array.isArray(request.targetContainerPathRefs)\n ) {\n return;\n }\n // The nested schemas have already reported their shape/cardinality\n // errors. Keep this aggregate refinement bounded and never dereference a\n // malformed path after those continuable issues have been replayed.\n if (\n request.authorizingContainerPathRefs.length >\n MAX_DOCUMENT_SYNC_AUTHORIZATION_PATHS ||\n request.targetContainerPathRefs.length > MAX_CONTAINER_PATH_LENGTH ||\n request.authorizingContainerPathRefs.some(\n (path) =>\n !Array.isArray(path) || path.length > MAX_CONTAINER_PATH_LENGTH,\n )\n ) {\n return;\n }\n const totalReferences = request.authorizingContainerPathRefs.reduce(\n (total, path) => total + path.length,\n request.targetContainerPathRefs.length,\n );\n if (totalReferences > MAX_DOCUMENT_SYNC_AUTHORIZATION_PATH_REFS) {\n context.addIssue({\n code: \"custom\",\n message: documentLinkSetPathRefinement.description,\n path: [\"authorizingContainerPathRefs\"],\n });\n }\n }),\n [documentLinkSetPathRefinement],\n );\n\nexport type DocumentLinkSetMutationRequest = z.infer<\n typeof DocumentLinkSetMutationRequestSchema\n>;\n\nexport const DocumentPurgeRequestSchema = loosePlainObject({\n authorizingContainerPathRefs: ContainerManifestPathSchema,\n body: requiredUnknownSchema,\n event: plainObjectSchema,\n});\n\nexport type DocumentPurgeRequest = z.infer<typeof DocumentPurgeRequestSchema>;\n\nexport function isContainerManifestRefArrayArray(\n value: unknown,\n): value is ContainerManifestRef[][] {\n return ContainerManifestRefArrayArraySchema.safeParse(value).success;\n}\n\nexport function isDocumentContentKeyBundleRequest(\n value: unknown,\n): value is DocumentContentKeyBundleRequest {\n return DocumentContentKeyBundleRequestSchema.safeParse(value).success;\n}\n\nexport function isDocumentCreateRequest(\n value: unknown,\n): value is DocumentCreateRequest {\n return DocumentCreateRequestSchema.safeParse(value).success;\n}\n\nexport function isDocumentLinkSetMutationRequest(\n value: unknown,\n): value is DocumentLinkSetMutationRequest {\n return DocumentLinkSetMutationRequestSchema.safeParse(value).success;\n}\n\nexport function isDocumentPurgeRequest(\n value: unknown,\n): value is DocumentPurgeRequest {\n return DocumentPurgeRequestSchema.safeParse(value).success;\n}\n\nexport function isDocumentSyncRequest(\n value: unknown,\n): value is DocumentSyncRequest {\n return DocumentSyncRequestSchema.safeParse(value).success;\n}\n"]}
|
|
@@ -1,33 +1,6 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
* of re-embedding the full signed manifest bundle. The server resolves the full
|
|
5
|
-
* manifest from its own store by `manifestHash` and pins it to the container's
|
|
6
|
-
* current head, so the reference carries the same authority as the full bundle
|
|
7
|
-
* without the multi-KB signature. `containerId` is advisory: the server keys the
|
|
8
|
-
* head lookup off the resolved bundle's own containerId and rejects a mismatch.
|
|
9
|
-
*/
|
|
10
|
-
export declare const ContainerManifestRefSchema: z.ZodType<{
|
|
11
|
-
containerId: string;
|
|
12
|
-
manifestHash: string;
|
|
13
|
-
}, {
|
|
14
|
-
containerId: string;
|
|
15
|
-
manifestHash: string;
|
|
16
|
-
}, z.core.$ZodTypeInternals<{
|
|
17
|
-
containerId: string;
|
|
18
|
-
manifestHash: string;
|
|
19
|
-
}, {
|
|
20
|
-
containerId: string;
|
|
21
|
-
manifestHash: string;
|
|
22
|
-
}>>;
|
|
23
|
-
export type ContainerManifestRef = z.infer<typeof ContainerManifestRefSchema>;
|
|
24
|
-
export declare const ContainerManifestPathSchema: z.ZodCustom<{
|
|
25
|
-
containerId: string;
|
|
26
|
-
manifestHash: string;
|
|
27
|
-
}[], {
|
|
28
|
-
containerId: string;
|
|
29
|
-
manifestHash: string;
|
|
30
|
-
}[]>;
|
|
2
|
+
import { ContainerManifestPathSchema, type ContainerManifestRef, ContainerManifestRefSchema } from "./containerManifestRef.js";
|
|
3
|
+
export { ContainerManifestPathSchema, type ContainerManifestRef, ContainerManifestRefSchema, };
|
|
31
4
|
export declare const ContainerManifestRefArrayArraySchema: z.ZodCustom<{
|
|
32
5
|
containerId: string;
|
|
33
6
|
manifestHash: string;
|
|
@@ -188,36 +161,26 @@ export declare const DocumentSyncRequestSchema: z.ZodType<{
|
|
|
188
161
|
predecessorBridge: Record<string, unknown> | null;
|
|
189
162
|
principalPolicies: Record<string, unknown>[];
|
|
190
163
|
wraps: Record<string, unknown>[];
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
manifest: Record<string, unknown>;
|
|
164
|
+
containerManifestHistoryRefs?: {
|
|
165
|
+
containerId: string;
|
|
194
166
|
manifestHash: string;
|
|
195
|
-
state: Record<string, unknown>;
|
|
196
167
|
}[] | undefined;
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
manifest: Record<string, unknown>;
|
|
168
|
+
destinationParentContainerPathRefs?: {
|
|
169
|
+
containerId: string;
|
|
200
170
|
manifestHash: string;
|
|
201
|
-
state: Record<string, unknown>;
|
|
202
171
|
}[] | undefined;
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
manifest: Record<string, unknown>;
|
|
172
|
+
parentContainerPathRefs?: {
|
|
173
|
+
containerId: string;
|
|
206
174
|
manifestHash: string;
|
|
207
|
-
state: Record<string, unknown>;
|
|
208
175
|
}[] | undefined;
|
|
209
176
|
parentKekState?: Record<string, unknown> | null | undefined;
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
manifest: Record<string, unknown>;
|
|
177
|
+
previousContainerPathRefs?: {
|
|
178
|
+
containerId: string;
|
|
213
179
|
manifestHash: string;
|
|
214
|
-
state: Record<string, unknown>;
|
|
215
180
|
}[] | undefined;
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
manifest: Record<string, unknown>;
|
|
181
|
+
previousManifestRef?: {
|
|
182
|
+
containerId: string;
|
|
219
183
|
manifestHash: string;
|
|
220
|
-
state: Record<string, unknown>;
|
|
221
184
|
} | null | undefined;
|
|
222
185
|
userRecipientKeys?: Record<string, unknown>[] | undefined;
|
|
223
186
|
}[] | undefined;
|
|
@@ -269,36 +232,26 @@ export declare const DocumentSyncRequestSchema: z.ZodType<{
|
|
|
269
232
|
predecessorBridge: Record<string, unknown> | null;
|
|
270
233
|
principalPolicies: Record<string, unknown>[];
|
|
271
234
|
wraps: Record<string, unknown>[];
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
manifest: Record<string, unknown>;
|
|
235
|
+
containerManifestHistoryRefs?: {
|
|
236
|
+
containerId: string;
|
|
275
237
|
manifestHash: string;
|
|
276
|
-
state: Record<string, unknown>;
|
|
277
238
|
}[] | undefined;
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
manifest: Record<string, unknown>;
|
|
239
|
+
destinationParentContainerPathRefs?: {
|
|
240
|
+
containerId: string;
|
|
281
241
|
manifestHash: string;
|
|
282
|
-
state: Record<string, unknown>;
|
|
283
242
|
}[] | undefined;
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
manifest: Record<string, unknown>;
|
|
243
|
+
parentContainerPathRefs?: {
|
|
244
|
+
containerId: string;
|
|
287
245
|
manifestHash: string;
|
|
288
|
-
state: Record<string, unknown>;
|
|
289
246
|
}[] | undefined;
|
|
290
247
|
parentKekState?: Record<string, unknown> | null | undefined;
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
manifest: Record<string, unknown>;
|
|
248
|
+
previousContainerPathRefs?: {
|
|
249
|
+
containerId: string;
|
|
294
250
|
manifestHash: string;
|
|
295
|
-
state: Record<string, unknown>;
|
|
296
251
|
}[] | undefined;
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
manifest: Record<string, unknown>;
|
|
252
|
+
previousManifestRef?: {
|
|
253
|
+
containerId: string;
|
|
300
254
|
manifestHash: string;
|
|
301
|
-
state: Record<string, unknown>;
|
|
302
255
|
} | null | undefined;
|
|
303
256
|
userRecipientKeys?: Record<string, unknown>[] | undefined;
|
|
304
257
|
}[] | undefined;
|
|
@@ -350,36 +303,26 @@ export declare const DocumentSyncRequestSchema: z.ZodType<{
|
|
|
350
303
|
predecessorBridge: Record<string, unknown> | null;
|
|
351
304
|
principalPolicies: Record<string, unknown>[];
|
|
352
305
|
wraps: Record<string, unknown>[];
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
manifest: Record<string, unknown>;
|
|
306
|
+
containerManifestHistoryRefs?: {
|
|
307
|
+
containerId: string;
|
|
356
308
|
manifestHash: string;
|
|
357
|
-
state: Record<string, unknown>;
|
|
358
309
|
}[] | undefined;
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
manifest: Record<string, unknown>;
|
|
310
|
+
destinationParentContainerPathRefs?: {
|
|
311
|
+
containerId: string;
|
|
362
312
|
manifestHash: string;
|
|
363
|
-
state: Record<string, unknown>;
|
|
364
313
|
}[] | undefined;
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
manifest: Record<string, unknown>;
|
|
314
|
+
parentContainerPathRefs?: {
|
|
315
|
+
containerId: string;
|
|
368
316
|
manifestHash: string;
|
|
369
|
-
state: Record<string, unknown>;
|
|
370
317
|
}[] | undefined;
|
|
371
318
|
parentKekState?: Record<string, unknown> | null | undefined;
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
manifest: Record<string, unknown>;
|
|
319
|
+
previousContainerPathRefs?: {
|
|
320
|
+
containerId: string;
|
|
375
321
|
manifestHash: string;
|
|
376
|
-
state: Record<string, unknown>;
|
|
377
322
|
}[] | undefined;
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
manifest: Record<string, unknown>;
|
|
323
|
+
previousManifestRef?: {
|
|
324
|
+
containerId: string;
|
|
381
325
|
manifestHash: string;
|
|
382
|
-
state: Record<string, unknown>;
|
|
383
326
|
} | null | undefined;
|
|
384
327
|
userRecipientKeys?: Record<string, unknown>[] | undefined;
|
|
385
328
|
}[] | undefined;
|
|
@@ -431,36 +374,26 @@ export declare const DocumentSyncRequestSchema: z.ZodType<{
|
|
|
431
374
|
predecessorBridge: Record<string, unknown> | null;
|
|
432
375
|
principalPolicies: Record<string, unknown>[];
|
|
433
376
|
wraps: Record<string, unknown>[];
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
manifest: Record<string, unknown>;
|
|
377
|
+
containerManifestHistoryRefs?: {
|
|
378
|
+
containerId: string;
|
|
437
379
|
manifestHash: string;
|
|
438
|
-
state: Record<string, unknown>;
|
|
439
380
|
}[] | undefined;
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
manifest: Record<string, unknown>;
|
|
381
|
+
destinationParentContainerPathRefs?: {
|
|
382
|
+
containerId: string;
|
|
443
383
|
manifestHash: string;
|
|
444
|
-
state: Record<string, unknown>;
|
|
445
384
|
}[] | undefined;
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
manifest: Record<string, unknown>;
|
|
385
|
+
parentContainerPathRefs?: {
|
|
386
|
+
containerId: string;
|
|
449
387
|
manifestHash: string;
|
|
450
|
-
state: Record<string, unknown>;
|
|
451
388
|
}[] | undefined;
|
|
452
389
|
parentKekState?: Record<string, unknown> | null | undefined;
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
manifest: Record<string, unknown>;
|
|
390
|
+
previousContainerPathRefs?: {
|
|
391
|
+
containerId: string;
|
|
456
392
|
manifestHash: string;
|
|
457
|
-
state: Record<string, unknown>;
|
|
458
393
|
}[] | undefined;
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
manifest: Record<string, unknown>;
|
|
394
|
+
previousManifestRef?: {
|
|
395
|
+
containerId: string;
|
|
462
396
|
manifestHash: string;
|
|
463
|
-
state: Record<string, unknown>;
|
|
464
397
|
} | null | undefined;
|
|
465
398
|
userRecipientKeys?: Record<string, unknown>[] | undefined;
|
|
466
399
|
}[] | undefined;
|
|
@@ -4,28 +4,15 @@ import { documentSyncRequestEnvelopeRefinements, documentSyncRequestPullRefineme
|
|
|
4
4
|
import { classifyDocumentSyncRequestMode } from "../documentSyncRequestMode.js";
|
|
5
5
|
import { isPlainObject } from "../isPlainObject.js";
|
|
6
6
|
import { registerJsonSchemaFragment, registerJsonSchemaRuntimeRefinements, registerJsonSchemaView, } from "../jsonSchema.js";
|
|
7
|
-
import { arraySchema,
|
|
8
|
-
import { AccessManifestBundleWireSchema } from "../util/accessManifestBundle.js";
|
|
7
|
+
import { arraySchema, boundedNonEmptyStringSchema, boundedStringSchema, loosePlainObject, nonEmptyStringSchema, plainObjectSchema, positiveIntegerSchema, requiredUnknownSchema, sha256HexStringSchema, } from "../schema.js";
|
|
9
8
|
import { MAX_INLINE_CONTAINER_REKEYS } from "../util/containerKekKeyringWire.js";
|
|
10
|
-
import { MAX_CONTAINER_PATH_LENGTH } from "../util/containerLimits.js";
|
|
11
9
|
import { MAX_DOCUMENT_SYNC_AUTHORIZATION_PATHS, MAX_DOCUMENT_SYNC_CONTENT_KEY_TARGETS, MAX_DOCUMENT_SYNC_OUTGOING_UPDATES, MAX_DOCUMENT_SYNC_PULL_CURSOR_LENGTH, MAX_DOCUMENT_SYNC_REQUEST_BYTES, } from "../util/documentSyncLimits.js";
|
|
12
10
|
import { isUuidV4String, UUID_V4_PATTERN } from "../util/uuid.js";
|
|
13
11
|
import { isWalLsnString, WAL_LSN_PATTERN } from "../util/walLsn.js";
|
|
14
12
|
import { ContainerMutationRequestSchema, } from "./container.js";
|
|
13
|
+
import { ContainerManifestPathSchema, ContainerManifestRefListSchema, ContainerManifestRefSchema, OptionalContainerManifestPathSchema, } from "./containerManifestRef.js";
|
|
15
14
|
import { ContentKeyWrappedKeySchema, contentKeyWrappingMetadataSchema, } from "./contentKeyEnvelopeSchema.js";
|
|
16
|
-
|
|
17
|
-
* A reference to a container access manifest the server already stores, in lieu
|
|
18
|
-
* of re-embedding the full signed manifest bundle. The server resolves the full
|
|
19
|
-
* manifest from its own store by `manifestHash` and pins it to the container's
|
|
20
|
-
* current head, so the reference carries the same authority as the full bundle
|
|
21
|
-
* without the multi-KB signature. `containerId` is advisory: the server keys the
|
|
22
|
-
* head lookup off the resolved bundle's own containerId and rejects a mismatch.
|
|
23
|
-
*/
|
|
24
|
-
export const ContainerManifestRefSchema = loosePlainObject({
|
|
25
|
-
containerId: nonEmptyStringSchema,
|
|
26
|
-
manifestHash: nonEmptyStringSchema,
|
|
27
|
-
});
|
|
28
|
-
export const ContainerManifestPathSchema = boundedNonEmptyArraySchema(ContainerManifestRefSchema, MAX_CONTAINER_PATH_LENGTH);
|
|
15
|
+
export { ContainerManifestPathSchema, ContainerManifestRefSchema, };
|
|
29
16
|
export const ContainerManifestRefArrayArraySchema = arraySchema(ContainerManifestPathSchema, MAX_DOCUMENT_SYNC_AUTHORIZATION_PATHS);
|
|
30
17
|
export const DocumentContentKeyTargetEnvelopeSchema = loosePlainObject({
|
|
31
18
|
containerId: nonEmptyStringSchema,
|
|
@@ -80,22 +67,18 @@ const DocumentSyncOutgoingUpdateSchema = createDocumentOutgoingUpdateSchema(boun
|
|
|
80
67
|
// schema used by newer operations.
|
|
81
68
|
const DocumentSyncContainerMutationRequestSchema = registerJsonSchemaView(z.custom((value) => ContainerMutationRequestSchema.safeParse(value).success), z.looseObject({
|
|
82
69
|
body: requiredUnknownSchema,
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
.optional(),
|
|
86
|
-
destinationParentContainerPath: z
|
|
87
|
-
.array(AccessManifestBundleWireSchema)
|
|
88
|
-
.optional(),
|
|
70
|
+
containerManifestHistoryRefs: ContainerManifestRefListSchema.optional(),
|
|
71
|
+
destinationParentContainerPathRefs: OptionalContainerManifestPathSchema.optional(),
|
|
89
72
|
event: plainObjectSchema,
|
|
90
73
|
expectedManifestHash: nonEmptyStringSchema,
|
|
91
74
|
keyEpoch: plainObjectSchema,
|
|
92
75
|
keyring: plainObjectSchema.nullable(),
|
|
93
76
|
manifest: plainObjectSchema,
|
|
94
|
-
|
|
77
|
+
parentContainerPathRefs: OptionalContainerManifestPathSchema.optional(),
|
|
95
78
|
parentKekState: plainObjectSchema.nullable().optional(),
|
|
96
79
|
predecessorBridge: plainObjectSchema.nullable(),
|
|
97
|
-
|
|
98
|
-
|
|
80
|
+
previousContainerPathRefs: OptionalContainerManifestPathSchema.optional(),
|
|
81
|
+
previousManifestRef: ContainerManifestRefSchema.nullable().optional(),
|
|
99
82
|
principalPolicies: z.array(plainObjectSchema),
|
|
100
83
|
userRecipientKeys: z.array(plainObjectSchema).optional(),
|
|
101
84
|
wraps: z.array(plainObjectSchema),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"documentSyncSchema.js","sourceRoot":"","sources":["documentSyncSchema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EACL,oCAAoC,EACpC,gDAAgD,EAChD,sCAAsC,EACtC,8CAA8C,GAC/C,MAAM,2BAA2B,CAAC;AACnC,OAAO,EACL,sCAAsC,EACtC,kCAAkC,EAClC,qCAAqC,GACtC,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAE,+BAA+B,EAAE,MAAM,4BAA4B,CAAC;AAC7E,OAAO,EAAE,aAAa,EAA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AAE,CAAC,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC,CAC9C,CAAC,IAAI,KAAK,OAAO,CAAC,eAAe,CAAC,MAAM,EACzC,CAAC;QACD,OAAO,CAAC,QAAQ,CAAC;YACf,IAAI,EAAE,QAAQ;YACd,OAAO,EAAE,oCAAoC;YAC7C,IAAI,EAAE,CAAC,iBAAiB,CAAC;SAC1B,CAAC,CAAC;IACL,CAAC;AACH,CAAC,CAAC,EACF;IACE,GAAG,sCAAsC;IACzC,GAAG,kCAAkC;CACtC,CACF,CAAC","sourcesContent":["import { z } from \"zod\";\nimport {\n classifyDocumentSyncCheckpointFields,\n DOCUMENT_SYNC_CHECKPOINT_FIELD_SET_ISSUE_MESSAGE,\n DOCUMENT_SYNC_ROTATION_CHECKPOINT_KIND,\n DOCUMENT_SYNC_ROTATION_CHECKPOINT_PAYLOAD_KIND,\n} from \"../documentSyncCheckpoint\";\nimport {\n documentSyncRequestEnvelopeRefinements,\n documentSyncRequestPullRefinements,\n documentSyncRequestRotationRefinement,\n} from \"../documentSyncRefinements\";\nimport { classifyDocumentSyncRequestMode } from \"../documentSyncRequestMode\";\nimport { isPlainObject } from \"../isPlainObject\";\nimport {\n registerJsonSchemaFragment,\n registerJsonSchemaRuntimeRefinements,\n registerJsonSchemaView,\n} from \"../jsonSchema\";\nimport {\n arraySchema,\n boundedNonEmptyArraySchema,\n boundedNonEmptyStringSchema,\n boundedStringSchema,\n loosePlainObject,\n nonEmptyStringSchema,\n plainObjectSchema,\n positiveIntegerSchema,\n requiredUnknownSchema,\n sha256HexStringSchema,\n} from \"../schema\";\nimport { AccessManifestBundleWireSchema } from \"../util/accessManifestBundle\";\nimport { MAX_INLINE_CONTAINER_REKEYS } from \"../util/containerKekKeyringWire\";\nimport { MAX_CONTAINER_PATH_LENGTH } from \"../util/containerLimits\";\nimport {\n MAX_DOCUMENT_SYNC_AUTHORIZATION_PATHS,\n MAX_DOCUMENT_SYNC_CONTENT_KEY_TARGETS,\n MAX_DOCUMENT_SYNC_OUTGOING_UPDATES,\n MAX_DOCUMENT_SYNC_PULL_CURSOR_LENGTH,\n MAX_DOCUMENT_SYNC_REQUEST_BYTES,\n} from \"../util/documentSyncLimits\";\nimport { isUuidV4String, UUID_V4_PATTERN } from \"../util/uuid\";\nimport { isWalLsnString, WAL_LSN_PATTERN } from \"../util/walLsn\";\nimport {\n type ContainerMutationRequest,\n ContainerMutationRequestSchema,\n} from \"./container\";\nimport {\n ContentKeyWrappedKeySchema,\n contentKeyWrappingMetadataSchema,\n} from \"./contentKeyEnvelopeSchema\";\n\n/**\n * A reference to a container access manifest the server already stores, in lieu\n * of re-embedding the full signed manifest bundle. The server resolves the full\n * manifest from its own store by `manifestHash` and pins it to the container's\n * current head, so the reference carries the same authority as the full bundle\n * without the multi-KB signature. `containerId` is advisory: the server keys the\n * head lookup off the resolved bundle's own containerId and rejects a mismatch.\n */\nexport const ContainerManifestRefSchema = loosePlainObject({\n containerId: nonEmptyStringSchema,\n manifestHash: nonEmptyStringSchema,\n});\n\nexport type ContainerManifestRef = z.infer<typeof ContainerManifestRefSchema>;\n\nexport const ContainerManifestPathSchema = boundedNonEmptyArraySchema(\n ContainerManifestRefSchema,\n MAX_CONTAINER_PATH_LENGTH,\n);\n\nexport const ContainerManifestRefArrayArraySchema = arraySchema(\n ContainerManifestPathSchema,\n MAX_DOCUMENT_SYNC_AUTHORIZATION_PATHS,\n);\n\nexport const DocumentContentKeyTargetEnvelopeSchema = loosePlainObject({\n containerId: nonEmptyStringSchema,\n containerKeyEpoch: positiveIntegerSchema,\n containerKeyEpochId: nonEmptyStringSchema,\n containerManifestHash: nonEmptyStringSchema,\n wrappedKey: ContentKeyWrappedKeySchema,\n wrappingMetadata: contentKeyWrappingMetadataSchema(\"document\"),\n});\n\nexport type DocumentContentKeyTargetEnvelope = z.infer<\n typeof DocumentContentKeyTargetEnvelopeSchema\n>;\n\nexport const DocumentContentKeyBundleRequestSchema = loosePlainObject({\n contentKeyEpoch: positiveIntegerSchema,\n linkSetManifestHash: nonEmptyStringSchema,\n targetHash: nonEmptyStringSchema,\n targets: arraySchema(\n DocumentContentKeyTargetEnvelopeSchema,\n MAX_DOCUMENT_SYNC_CONTENT_KEY_TARGETS,\n ),\n});\n\nexport type DocumentContentKeyBundleRequest = z.infer<\n typeof DocumentContentKeyBundleRequestSchema\n>;\n\nfunction createDocumentOutgoingUpdateSchema(\n encryptedDataSchema: z.ZodType<string>,\n versionVectorSchema: z.ZodType<string>,\n) {\n return registerJsonSchemaRuntimeRefinements(\n loosePlainObject({\n checkpointKind: z\n .literal(DOCUMENT_SYNC_ROTATION_CHECKPOINT_KIND)\n .optional(),\n checkpointPayloadKind: z\n .literal(DOCUMENT_SYNC_ROTATION_CHECKPOINT_PAYLOAD_KIND)\n .optional(),\n encryptedData: encryptedDataSchema,\n id: registerJsonSchemaFragment(z.string().refine(isUuidV4String), {\n pattern: UUID_V4_PATTERN.source,\n type: \"string\",\n }),\n partialEndVersionVector: versionVectorSchema,\n partialStartVersionVector: versionVectorSchema,\n plaintextHash: nonEmptyStringSchema,\n sourceVersionVector: versionVectorSchema.optional(),\n writeHeader: plainObjectSchema,\n }).superRefine((update, context) => {\n if (classifyDocumentSyncCheckpointFields(update) === \"invalid\") {\n context.addIssue({\n code: \"custom\",\n message: DOCUMENT_SYNC_CHECKPOINT_FIELD_SET_ISSUE_MESSAGE,\n });\n }\n }),\n [documentSyncRequestRotationRefinement],\n );\n}\n\n// Link-set rotations may carry a full-history baseline that is larger than a\n// single sync request. Their route has its own ingress policy, so keep the\n// shared update contract unbounded and apply the sync-specific ceiling only\n// where an update is embedded in DocumentSyncRequest.\nexport const DocumentOutgoingUpdateSchema = createDocumentOutgoingUpdateSchema(\n nonEmptyStringSchema,\n nonEmptyStringSchema,\n);\n\nconst DocumentSyncOutgoingUpdateSchema = createDocumentOutgoingUpdateSchema(\n boundedNonEmptyStringSchema(MAX_DOCUMENT_SYNC_REQUEST_BYTES),\n boundedNonEmptyStringSchema(MAX_DOCUMENT_SYNC_REQUEST_BYTES),\n);\n\nexport type DocumentOutgoingUpdate = z.infer<\n typeof DocumentOutgoingUpdateSchema\n>;\n\n// Document sync published container keyrings as opaque records before the\n// canonical container-mutation schema described their fields. Keep that one\n// existing OpenAPI view stable while runtime validation delegates to the shared\n// schema used by newer operations.\nconst DocumentSyncContainerMutationRequestSchema = registerJsonSchemaView(\n z.custom<ContainerMutationRequest>(\n (value) => ContainerMutationRequestSchema.safeParse(value).success,\n ),\n z.looseObject({\n body: requiredUnknownSchema,\n containerManifestHistory: z\n .array(AccessManifestBundleWireSchema)\n .optional(),\n destinationParentContainerPath: z\n .array(AccessManifestBundleWireSchema)\n .optional(),\n event: plainObjectSchema,\n expectedManifestHash: nonEmptyStringSchema,\n keyEpoch: plainObjectSchema,\n keyring: plainObjectSchema.nullable(),\n manifest: plainObjectSchema,\n parentContainerPath: z.array(AccessManifestBundleWireSchema).optional(),\n parentKekState: plainObjectSchema.nullable().optional(),\n predecessorBridge: plainObjectSchema.nullable(),\n previousContainerPath: z.array(AccessManifestBundleWireSchema).optional(),\n previousManifest: AccessManifestBundleWireSchema.nullable().optional(),\n principalPolicies: z.array(plainObjectSchema),\n userRecipientKeys: z.array(plainObjectSchema).optional(),\n wraps: z.array(plainObjectSchema),\n }),\n);\n\nconst WalLsnSchema = registerJsonSchemaFragment(\n z.string().refine(isWalLsnString),\n { pattern: WAL_LSN_PATTERN.source, type: \"string\" },\n);\n\nexport const DocumentSyncRequestSchema = registerJsonSchemaRuntimeRefinements(\n loosePlainObject({\n authorizingContainerPathRefs:\n ContainerManifestRefArrayArraySchema.optional(),\n // Each rotation carries a keyring sized by its epoch, so the batch is\n // bounded here as well as in the runtime guard.\n containerRekeys: arraySchema(\n DocumentSyncContainerMutationRequestSchema,\n MAX_INLINE_CONTAINER_REKEYS,\n ).optional(),\n contentKeyBundle: DocumentContentKeyBundleRequestSchema.optional(),\n contentKeyEpoch: positiveIntegerSchema,\n expectedLinkSetManifestHash: nonEmptyStringSchema,\n expectedTargetHash: nonEmptyStringSchema,\n historyMode: z\n .literal(\"raw\")\n .describe(\n \"Explicit read-only recovery mode that bypasses rotation-baseline redirection and returns retained missing history\",\n )\n .optional(),\n inlineRekeyCommitId: sha256HexStringSchema.optional(),\n localVersionVector: boundedStringSchema(\n MAX_DOCUMENT_SYNC_REQUEST_BYTES,\n ).nullable(),\n minLsn: WalLsnSchema.optional(),\n outgoingUpdates: arraySchema(\n DocumentSyncOutgoingUpdateSchema,\n MAX_DOCUMENT_SYNC_OUTGOING_UPDATES,\n ),\n pullCursor: boundedNonEmptyStringSchema(\n MAX_DOCUMENT_SYNC_PULL_CURSOR_LENGTH,\n ).optional(),\n supportsPullPagination: z.literal(true),\n }).superRefine((request, context) => {\n if (!Array.isArray(request.outgoingUpdates)) {\n return;\n }\n // The field schemas have already recorded their cardinality errors. Do\n // not let the cross-field checks below rescan attacker-sized arrays after\n // those bounded schemas deliberately stopped before item validation.\n if (request.outgoingUpdates.length > MAX_DOCUMENT_SYNC_OUTGOING_UPDATES) {\n return;\n }\n if (\n Array.isArray(request.authorizingContainerPathRefs) &&\n request.authorizingContainerPathRefs.length >\n MAX_DOCUMENT_SYNC_AUTHORIZATION_PATHS\n ) {\n return;\n }\n\n const hasOutgoingUpdates = request.outgoingUpdates.length > 0;\n if (\n (request.containerRekeys?.length ?? 0) > 0 !==\n (request.inlineRekeyCommitId !== undefined)\n ) {\n context.addIssue({\n code: \"custom\",\n message: \"inline rekey commit id must accompany container rekeys\",\n path: [\"inlineRekeyCommitId\"],\n });\n }\n if (\n request.pullCursor !== undefined &&\n (hasOutgoingUpdates ||\n (request.containerRekeys?.length ?? 0) > 0 ||\n request.contentKeyBundle !== undefined ||\n request.authorizingContainerPathRefs !== undefined)\n ) {\n context.addIssue({\n code: \"custom\",\n message: \"continued pulls must be read-only\",\n path: [\"pullCursor\"],\n });\n }\n if (\n request.historyMode === \"raw\" &&\n (hasOutgoingUpdates ||\n (request.containerRekeys?.length ?? 0) > 0 ||\n request.contentKeyBundle !== undefined ||\n request.authorizingContainerPathRefs !== undefined)\n ) {\n context.addIssue({\n code: \"custom\",\n message: \"raw-history pulls must be read-only\",\n path: [\"historyMode\"],\n });\n }\n if (request.historyMode === \"raw\" && request.localVersionVector !== null) {\n context.addIssue({\n code: \"custom\",\n message: \"raw-history pulls must start from a null version vector\",\n path: [\"localVersionVector\"],\n });\n }\n const requestMode = classifyDocumentSyncRequestMode({\n authorizingContainerPathRefsPresent:\n request.authorizingContainerPathRefs !== undefined,\n hasContainerRekeys: (request.containerRekeys?.length ?? 0) > 0,\n hasOutgoingUpdates,\n });\n\n if (requestMode === \"invalid-authorizing-path-refs-absent\") {\n context.addIssue({\n code: \"custom\",\n message:\n \"authorizing container paths are required for outgoing updates\",\n path: [\"authorizingContainerPathRefs\"],\n });\n }\n\n if (requestMode === \"invalid-rekeys-without-write\") {\n context.addIssue({\n code: \"custom\",\n message: \"container rekeys require an outgoing update\",\n path: [\"containerRekeys\"],\n });\n }\n\n if (\n new Set(\n request.outgoingUpdates\n .filter(isPlainObject)\n .map((update) => Reflect.get(update, \"id\")),\n ).size !== request.outgoingUpdates.length\n ) {\n context.addIssue({\n code: \"custom\",\n message: \"outgoing update ids must be unique\",\n path: [\"outgoingUpdates\"],\n });\n }\n }),\n [\n ...documentSyncRequestEnvelopeRefinements,\n ...documentSyncRequestPullRefinements,\n ],\n);\n\nexport type DocumentSyncRequest = z.infer<typeof DocumentSyncRequestSchema>;\n"]}
|
|
1
|
+
{"version":3,"file":"documentSyncSchema.js","sourceRoot":"","sources":["documentSyncSchema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EACL,oCAAoC,EACpC,gDAAgD,EAChD,sCAAsC,EACtC,8CAA8C,GAC/C,MAAM,2BAA2B,CAAC;AACnC,OAAO,EACL,sCAAsC,EACtC,kCAAkC,EAClC,qCAAqC,GACtC,MAAM,4BAA4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CAAC,iBAAiB,CAAC;SAC1B,CAAC,CAAC;IACL,CAAC;AACH,CAAC,CAAC,EACF;IACE,GAAG,sCAAsC;IACzC,GAAG,kCAAkC;CACtC,CACF,CAAC","sourcesContent":["import { z } from \"zod\";\nimport {\n classifyDocumentSyncCheckpointFields,\n DOCUMENT_SYNC_CHECKPOINT_FIELD_SET_ISSUE_MESSAGE,\n DOCUMENT_SYNC_ROTATION_CHECKPOINT_KIND,\n DOCUMENT_SYNC_ROTATION_CHECKPOINT_PAYLOAD_KIND,\n} from \"../documentSyncCheckpoint\";\nimport {\n documentSyncRequestEnvelopeRefinements,\n documentSyncRequestPullRefinements,\n documentSyncRequestRotationRefinement,\n} from \"../documentSyncRefinements\";\nimport { classifyDocumentSyncRequestMode } from \"../documentSyncRequestMode\";\nimport { isPlainObject } from \"../isPlainObject\";\nimport {\n registerJsonSchemaFragment,\n registerJsonSchemaRuntimeRefinements,\n registerJsonSchemaView,\n} from \"../jsonSchema\";\nimport {\n arraySchema,\n boundedNonEmptyStringSchema,\n boundedStringSchema,\n loosePlainObject,\n nonEmptyStringSchema,\n plainObjectSchema,\n positiveIntegerSchema,\n requiredUnknownSchema,\n sha256HexStringSchema,\n} from \"../schema\";\nimport { MAX_INLINE_CONTAINER_REKEYS } from \"../util/containerKekKeyringWire\";\nimport {\n MAX_DOCUMENT_SYNC_AUTHORIZATION_PATHS,\n MAX_DOCUMENT_SYNC_CONTENT_KEY_TARGETS,\n MAX_DOCUMENT_SYNC_OUTGOING_UPDATES,\n MAX_DOCUMENT_SYNC_PULL_CURSOR_LENGTH,\n MAX_DOCUMENT_SYNC_REQUEST_BYTES,\n} from \"../util/documentSyncLimits\";\nimport { isUuidV4String, UUID_V4_PATTERN } from \"../util/uuid\";\nimport { isWalLsnString, WAL_LSN_PATTERN } from \"../util/walLsn\";\nimport {\n type ContainerMutationRequest,\n ContainerMutationRequestSchema,\n} from \"./container\";\nimport {\n ContainerManifestPathSchema,\n type ContainerManifestRef,\n ContainerManifestRefListSchema,\n ContainerManifestRefSchema,\n OptionalContainerManifestPathSchema,\n} from \"./containerManifestRef\";\nimport {\n ContentKeyWrappedKeySchema,\n contentKeyWrappingMetadataSchema,\n} from \"./contentKeyEnvelopeSchema\";\n\nexport {\n ContainerManifestPathSchema,\n type ContainerManifestRef,\n ContainerManifestRefSchema,\n};\n\nexport const ContainerManifestRefArrayArraySchema = arraySchema(\n ContainerManifestPathSchema,\n MAX_DOCUMENT_SYNC_AUTHORIZATION_PATHS,\n);\n\nexport const DocumentContentKeyTargetEnvelopeSchema = loosePlainObject({\n containerId: nonEmptyStringSchema,\n containerKeyEpoch: positiveIntegerSchema,\n containerKeyEpochId: nonEmptyStringSchema,\n containerManifestHash: nonEmptyStringSchema,\n wrappedKey: ContentKeyWrappedKeySchema,\n wrappingMetadata: contentKeyWrappingMetadataSchema(\"document\"),\n});\n\nexport type DocumentContentKeyTargetEnvelope = z.infer<\n typeof DocumentContentKeyTargetEnvelopeSchema\n>;\n\nexport const DocumentContentKeyBundleRequestSchema = loosePlainObject({\n contentKeyEpoch: positiveIntegerSchema,\n linkSetManifestHash: nonEmptyStringSchema,\n targetHash: nonEmptyStringSchema,\n targets: arraySchema(\n DocumentContentKeyTargetEnvelopeSchema,\n MAX_DOCUMENT_SYNC_CONTENT_KEY_TARGETS,\n ),\n});\n\nexport type DocumentContentKeyBundleRequest = z.infer<\n typeof DocumentContentKeyBundleRequestSchema\n>;\n\nfunction createDocumentOutgoingUpdateSchema(\n encryptedDataSchema: z.ZodType<string>,\n versionVectorSchema: z.ZodType<string>,\n) {\n return registerJsonSchemaRuntimeRefinements(\n loosePlainObject({\n checkpointKind: z\n .literal(DOCUMENT_SYNC_ROTATION_CHECKPOINT_KIND)\n .optional(),\n checkpointPayloadKind: z\n .literal(DOCUMENT_SYNC_ROTATION_CHECKPOINT_PAYLOAD_KIND)\n .optional(),\n encryptedData: encryptedDataSchema,\n id: registerJsonSchemaFragment(z.string().refine(isUuidV4String), {\n pattern: UUID_V4_PATTERN.source,\n type: \"string\",\n }),\n partialEndVersionVector: versionVectorSchema,\n partialStartVersionVector: versionVectorSchema,\n plaintextHash: nonEmptyStringSchema,\n sourceVersionVector: versionVectorSchema.optional(),\n writeHeader: plainObjectSchema,\n }).superRefine((update, context) => {\n if (classifyDocumentSyncCheckpointFields(update) === \"invalid\") {\n context.addIssue({\n code: \"custom\",\n message: DOCUMENT_SYNC_CHECKPOINT_FIELD_SET_ISSUE_MESSAGE,\n });\n }\n }),\n [documentSyncRequestRotationRefinement],\n );\n}\n\n// Link-set rotations may carry a full-history baseline that is larger than a\n// single sync request. Their route has its own ingress policy, so keep the\n// shared update contract unbounded and apply the sync-specific ceiling only\n// where an update is embedded in DocumentSyncRequest.\nexport const DocumentOutgoingUpdateSchema = createDocumentOutgoingUpdateSchema(\n nonEmptyStringSchema,\n nonEmptyStringSchema,\n);\n\nconst DocumentSyncOutgoingUpdateSchema = createDocumentOutgoingUpdateSchema(\n boundedNonEmptyStringSchema(MAX_DOCUMENT_SYNC_REQUEST_BYTES),\n boundedNonEmptyStringSchema(MAX_DOCUMENT_SYNC_REQUEST_BYTES),\n);\n\nexport type DocumentOutgoingUpdate = z.infer<\n typeof DocumentOutgoingUpdateSchema\n>;\n\n// Document sync published container keyrings as opaque records before the\n// canonical container-mutation schema described their fields. Keep that one\n// existing OpenAPI view stable while runtime validation delegates to the shared\n// schema used by newer operations.\nconst DocumentSyncContainerMutationRequestSchema = registerJsonSchemaView(\n z.custom<ContainerMutationRequest>(\n (value) => ContainerMutationRequestSchema.safeParse(value).success,\n ),\n z.looseObject({\n body: requiredUnknownSchema,\n containerManifestHistoryRefs: ContainerManifestRefListSchema.optional(),\n destinationParentContainerPathRefs:\n OptionalContainerManifestPathSchema.optional(),\n event: plainObjectSchema,\n expectedManifestHash: nonEmptyStringSchema,\n keyEpoch: plainObjectSchema,\n keyring: plainObjectSchema.nullable(),\n manifest: plainObjectSchema,\n parentContainerPathRefs: OptionalContainerManifestPathSchema.optional(),\n parentKekState: plainObjectSchema.nullable().optional(),\n predecessorBridge: plainObjectSchema.nullable(),\n previousContainerPathRefs: OptionalContainerManifestPathSchema.optional(),\n previousManifestRef: ContainerManifestRefSchema.nullable().optional(),\n principalPolicies: z.array(plainObjectSchema),\n userRecipientKeys: z.array(plainObjectSchema).optional(),\n wraps: z.array(plainObjectSchema),\n }),\n);\n\nconst WalLsnSchema = registerJsonSchemaFragment(\n z.string().refine(isWalLsnString),\n { pattern: WAL_LSN_PATTERN.source, type: \"string\" },\n);\n\nexport const DocumentSyncRequestSchema = registerJsonSchemaRuntimeRefinements(\n loosePlainObject({\n authorizingContainerPathRefs:\n ContainerManifestRefArrayArraySchema.optional(),\n // Each rotation carries a keyring sized by its epoch, so the batch is\n // bounded here as well as in the runtime guard.\n containerRekeys: arraySchema(\n DocumentSyncContainerMutationRequestSchema,\n MAX_INLINE_CONTAINER_REKEYS,\n ).optional(),\n contentKeyBundle: DocumentContentKeyBundleRequestSchema.optional(),\n contentKeyEpoch: positiveIntegerSchema,\n expectedLinkSetManifestHash: nonEmptyStringSchema,\n expectedTargetHash: nonEmptyStringSchema,\n historyMode: z\n .literal(\"raw\")\n .describe(\n \"Explicit read-only recovery mode that bypasses rotation-baseline redirection and returns retained missing history\",\n )\n .optional(),\n inlineRekeyCommitId: sha256HexStringSchema.optional(),\n localVersionVector: boundedStringSchema(\n MAX_DOCUMENT_SYNC_REQUEST_BYTES,\n ).nullable(),\n minLsn: WalLsnSchema.optional(),\n outgoingUpdates: arraySchema(\n DocumentSyncOutgoingUpdateSchema,\n MAX_DOCUMENT_SYNC_OUTGOING_UPDATES,\n ),\n pullCursor: boundedNonEmptyStringSchema(\n MAX_DOCUMENT_SYNC_PULL_CURSOR_LENGTH,\n ).optional(),\n supportsPullPagination: z.literal(true),\n }).superRefine((request, context) => {\n if (!Array.isArray(request.outgoingUpdates)) {\n return;\n }\n // The field schemas have already recorded their cardinality errors. Do\n // not let the cross-field checks below rescan attacker-sized arrays after\n // those bounded schemas deliberately stopped before item validation.\n if (request.outgoingUpdates.length > MAX_DOCUMENT_SYNC_OUTGOING_UPDATES) {\n return;\n }\n if (\n Array.isArray(request.authorizingContainerPathRefs) &&\n request.authorizingContainerPathRefs.length >\n MAX_DOCUMENT_SYNC_AUTHORIZATION_PATHS\n ) {\n return;\n }\n\n const hasOutgoingUpdates = request.outgoingUpdates.length > 0;\n if (\n (request.containerRekeys?.length ?? 0) > 0 !==\n (request.inlineRekeyCommitId !== undefined)\n ) {\n context.addIssue({\n code: \"custom\",\n message: \"inline rekey commit id must accompany container rekeys\",\n path: [\"inlineRekeyCommitId\"],\n });\n }\n if (\n request.pullCursor !== undefined &&\n (hasOutgoingUpdates ||\n (request.containerRekeys?.length ?? 0) > 0 ||\n request.contentKeyBundle !== undefined ||\n request.authorizingContainerPathRefs !== undefined)\n ) {\n context.addIssue({\n code: \"custom\",\n message: \"continued pulls must be read-only\",\n path: [\"pullCursor\"],\n });\n }\n if (\n request.historyMode === \"raw\" &&\n (hasOutgoingUpdates ||\n (request.containerRekeys?.length ?? 0) > 0 ||\n request.contentKeyBundle !== undefined ||\n request.authorizingContainerPathRefs !== undefined)\n ) {\n context.addIssue({\n code: \"custom\",\n message: \"raw-history pulls must be read-only\",\n path: [\"historyMode\"],\n });\n }\n if (request.historyMode === \"raw\" && request.localVersionVector !== null) {\n context.addIssue({\n code: \"custom\",\n message: \"raw-history pulls must start from a null version vector\",\n path: [\"localVersionVector\"],\n });\n }\n const requestMode = classifyDocumentSyncRequestMode({\n authorizingContainerPathRefsPresent:\n request.authorizingContainerPathRefs !== undefined,\n hasContainerRekeys: (request.containerRekeys?.length ?? 0) > 0,\n hasOutgoingUpdates,\n });\n\n if (requestMode === \"invalid-authorizing-path-refs-absent\") {\n context.addIssue({\n code: \"custom\",\n message:\n \"authorizing container paths are required for outgoing updates\",\n path: [\"authorizingContainerPathRefs\"],\n });\n }\n\n if (requestMode === \"invalid-rekeys-without-write\") {\n context.addIssue({\n code: \"custom\",\n message: \"container rekeys require an outgoing update\",\n path: [\"containerRekeys\"],\n });\n }\n\n if (\n new Set(\n request.outgoingUpdates\n .filter(isPlainObject)\n .map((update) => Reflect.get(update, \"id\")),\n ).size !== request.outgoingUpdates.length\n ) {\n context.addIssue({\n code: \"custom\",\n message: \"outgoing update ids must be unique\",\n path: [\"outgoingUpdates\"],\n });\n }\n }),\n [\n ...documentSyncRequestEnvelopeRefinements,\n ...documentSyncRequestPullRefinements,\n ],\n);\n\nexport type DocumentSyncRequest = z.infer<typeof DocumentSyncRequestSchema>;\n"]}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
export type { AccessManifestBundleWire } from "../util/accessManifestBundle.js";
|
|
2
2
|
export { type ChallengeRequest, ChallengeRequestSchema, isChallengeRequest, isVerifyRequest, type VerifyRequest, VerifyRequestSchema, } from "./auth/index.js";
|
|
3
|
-
export { type BlobAttachmentBindRequest, BlobAttachmentBindRequestSchema, type BlobAttachmentDetachRequest, BlobAttachmentDetachRequestSchema, type BlobContentKeyBundleRequest, BlobContentKeyBundleRequestSchema, type BlobContentKeyTargetEnvelopeRequest, BlobContentKeyTargetEnvelopeRequestSchema, type BlobStagedBlobRequest, BlobStagedBlobRequestSchema, type
|
|
3
|
+
export { type BlobAttachmentBindRequest, BlobAttachmentBindRequestSchema, type BlobAttachmentDetachRequest, BlobAttachmentDetachRequestSchema, type BlobContentKeyBundleRequest, BlobContentKeyBundleRequestSchema, type BlobContentKeyTargetEnvelopeRequest, BlobContentKeyTargetEnvelopeRequestSchema, type BlobStagedBlobRequest, BlobStagedBlobRequestSchema, type InitiateMultipartBlobStageRequest, InitiateMultipartBlobStageRequestSchema, isBlobAttachmentBindRequest, isBlobAttachmentDetachRequest, isInitiateMultipartBlobStageRequest, } from "./blob.js";
|
|
4
4
|
export { type ContainerMutationRequest, ContainerMutationRequestSchema, type ContainerReciteRequest, ContainerReciteRequestSchema, type ContainerRotationRequest, ContainerRotationRequestSchema, isContainerMutationRequest, isContainerReciteRequest, isContainerRotationRequest, } from "./container.js";
|
|
5
|
+
export { DEFAULT_CONTAINER_DOCUMENT_LANE_PAGE_LIMIT, isListContainerDocumentLanesRequest, type ListContainerDocumentLanesRequest, ListContainerDocumentLanesRequestSchema, MAX_CONTAINER_DOCUMENT_LANE_PAGE_TOTAL, MAX_CONTAINER_DOCUMENT_LANES, } from "./containerDocumentLanes.js";
|
|
5
6
|
export { type ContainerCreateWithMetadataDocumentRequest, ContainerCreateWithMetadataDocumentRequestSchema, isContainerCreateWithMetadataDocumentRequest, } from "./containerMetadata.js";
|
|
6
7
|
export { isListContainerParentLanesRequest, type ListContainerParentLanesRequest, ListContainerParentLanesRequestSchema, } from "./containerParentLanes.js";
|
|
7
8
|
export { type ContainerManifestRef, ContainerManifestRefArrayArraySchema, ContainerManifestRefSchema, type DocumentContentKeyBundleRequest, DocumentContentKeyBundleRequestSchema, type DocumentContentKeyTargetEnvelope, DocumentContentKeyTargetEnvelopeSchema, type DocumentCreateRequest, DocumentCreateRequestSchema, type DocumentLinkSetMutationRequest, DocumentLinkSetMutationRequestSchema, type DocumentOutgoingUpdate, DocumentOutgoingUpdateSchema, type DocumentPurgeRequest, DocumentPurgeRequestSchema, type DocumentSyncRequest, DocumentSyncRequestSchema, isContainerManifestRefArrayArray, isDocumentContentKeyBundleRequest, isDocumentCreateRequest, isDocumentLinkSetMutationRequest, isDocumentPurgeRequest, isDocumentSyncRequest, } from "./document.js";
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export { ChallengeRequestSchema, isChallengeRequest, isVerifyRequest, VerifyRequestSchema, } from "./auth/index.js";
|
|
2
|
-
export { BlobAttachmentBindRequestSchema, BlobAttachmentDetachRequestSchema, BlobContentKeyBundleRequestSchema, BlobContentKeyTargetEnvelopeRequestSchema, BlobStagedBlobRequestSchema,
|
|
2
|
+
export { BlobAttachmentBindRequestSchema, BlobAttachmentDetachRequestSchema, BlobContentKeyBundleRequestSchema, BlobContentKeyTargetEnvelopeRequestSchema, BlobStagedBlobRequestSchema, InitiateMultipartBlobStageRequestSchema, isBlobAttachmentBindRequest, isBlobAttachmentDetachRequest, isInitiateMultipartBlobStageRequest, } from "./blob.js";
|
|
3
3
|
export { ContainerMutationRequestSchema, ContainerReciteRequestSchema, ContainerRotationRequestSchema, isContainerMutationRequest, isContainerReciteRequest, isContainerRotationRequest, } from "./container.js";
|
|
4
|
+
export { DEFAULT_CONTAINER_DOCUMENT_LANE_PAGE_LIMIT, isListContainerDocumentLanesRequest, ListContainerDocumentLanesRequestSchema, MAX_CONTAINER_DOCUMENT_LANE_PAGE_TOTAL, MAX_CONTAINER_DOCUMENT_LANES, } from "./containerDocumentLanes.js";
|
|
4
5
|
export { ContainerCreateWithMetadataDocumentRequestSchema, isContainerCreateWithMetadataDocumentRequest, } from "./containerMetadata.js";
|
|
5
6
|
export { isListContainerParentLanesRequest, ListContainerParentLanesRequestSchema, } from "./containerParentLanes.js";
|
|
6
7
|
export { ContainerManifestRefArrayArraySchema, ContainerManifestRefSchema, DocumentContentKeyBundleRequestSchema, DocumentContentKeyTargetEnvelopeSchema, DocumentCreateRequestSchema, DocumentLinkSetMutationRequestSchema, DocumentOutgoingUpdateSchema, DocumentPurgeRequestSchema, DocumentSyncRequestSchema, isContainerManifestRefArrayArray, isDocumentContentKeyBundleRequest, isDocumentCreateRequest, isDocumentLinkSetMutationRequest, isDocumentPurgeRequest, isDocumentSyncRequest, } from "./document.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":"AACA,OAAO,EAEL,sBAAsB,EACtB,kBAAkB,EAClB,eAAe,EAEf,mBAAmB,GACpB,MAAM,QAAQ,CAAC;AAChB,OAAO,EAEL,+BAA+B,EAE/B,iCAAiC,EAEjC,iCAAiC,EAEjC,yCAAyC,EAEzC,2BAA2B,EAE3B,uCAAuC,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":"AACA,OAA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AuC,GACxC,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAEL,0CAA0C,EAC1C,sCAAsC,EACtC,oCAAoC,EACpC,2BAA2B,EAE3B,wCAAwC,EAExC,oCAAoC,EAMpC,+BAA+B,GAChC,MAAM,aAAa,CAAC;AACrB,OAAO,EACL,qBAAqB,EAErB,yBAAyB,GAC1B,MAAM,gBAAgB,CAAC;AACxB,OAAO,EACL,gCAAgC,EAChC,0BAA0B,EAE1B,oCAAoC,EAEpC,mCAAmC,EAEnC,oCAAoC,EAEpC,4BAA4B,EAE5B,8BAA8B,GAC/B,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EACL,wBAAwB,EAExB,4BAA4B,GAC7B,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EACL,sBAAsB,EAEtB,0BAA0B,GAC3B,MAAM,iBAAiB,CAAC","sourcesContent":["export type { AccessManifestBundleWire } from \"../util/accessManifestBundle\";\nexport {\n type ChallengeRequest,\n ChallengeRequestSchema,\n isChallengeRequest,\n isVerifyRequest,\n type VerifyRequest,\n VerifyRequestSchema,\n} from \"./auth\";\nexport {\n type BlobAttachmentBindRequest,\n BlobAttachmentBindRequestSchema,\n type BlobAttachmentDetachRequest,\n BlobAttachmentDetachRequestSchema,\n type BlobContentKeyBundleRequest,\n BlobContentKeyBundleRequestSchema,\n type BlobContentKeyTargetEnvelopeRequest,\n BlobContentKeyTargetEnvelopeRequestSchema,\n type BlobStagedBlobRequest,\n BlobStagedBlobRequestSchema,\n type InitiateMultipartBlobStageRequest,\n InitiateMultipartBlobStageRequestSchema,\n isBlobAttachmentBindRequest,\n isBlobAttachmentDetachRequest,\n isInitiateMultipartBlobStageRequest,\n} from \"./blob\";\nexport {\n type ContainerMutationRequest,\n ContainerMutationRequestSchema,\n type ContainerReciteRequest,\n ContainerReciteRequestSchema,\n type ContainerRotationRequest,\n ContainerRotationRequestSchema,\n isContainerMutationRequest,\n isContainerReciteRequest,\n isContainerRotationRequest,\n} from \"./container\";\nexport {\n DEFAULT_CONTAINER_DOCUMENT_LANE_PAGE_LIMIT,\n isListContainerDocumentLanesRequest,\n type ListContainerDocumentLanesRequest,\n ListContainerDocumentLanesRequestSchema,\n MAX_CONTAINER_DOCUMENT_LANE_PAGE_TOTAL,\n MAX_CONTAINER_DOCUMENT_LANES,\n} from \"./containerDocumentLanes\";\nexport {\n type ContainerCreateWithMetadataDocumentRequest,\n ContainerCreateWithMetadataDocumentRequestSchema,\n isContainerCreateWithMetadataDocumentRequest,\n} from \"./containerMetadata\";\nexport {\n isListContainerParentLanesRequest,\n type ListContainerParentLanesRequest,\n ListContainerParentLanesRequestSchema,\n} from \"./containerParentLanes\";\nexport {\n type ContainerManifestRef,\n ContainerManifestRefArrayArraySchema,\n ContainerManifestRefSchema,\n type DocumentContentKeyBundleRequest,\n DocumentContentKeyBundleRequestSchema,\n type DocumentContentKeyTargetEnvelope,\n DocumentContentKeyTargetEnvelopeSchema,\n type DocumentCreateRequest,\n DocumentCreateRequestSchema,\n type DocumentLinkSetMutationRequest,\n DocumentLinkSetMutationRequestSchema,\n type DocumentOutgoingUpdate,\n DocumentOutgoingUpdateSchema,\n type DocumentPurgeRequest,\n DocumentPurgeRequestSchema,\n type DocumentSyncRequest,\n DocumentSyncRequestSchema,\n isContainerManifestRefArrayArray,\n isDocumentContentKeyBundleRequest,\n isDocumentCreateRequest,\n isDocumentLinkSetMutationRequest,\n isDocumentPurgeRequest,\n isDocumentSyncRequest,\n} from \"./document\";\nexport {\n type CreateOrganizationGroupRequest,\n CreateOrganizationGroupRequestSchema,\n type CreateOrganizationGroupWithPolicyRequest,\n CreateOrganizationGroupWithPolicyRequestSchema,\n type DeleteOrganizationGroupRequest,\n DeleteOrganizationGroupRequestSchema,\n isCreateOrganizationGroupRequest,\n isCreateOrganizationGroupWithPolicyRequest,\n isDeleteOrganizationGroupRequest,\n isUpdateOrganizationProfileRequest,\n isUpdateOrganizationRosterEntryRequest,\n type OrganizationReadModelQuery,\n OrganizationReadModelQuerySchema,\n type UpdateOrganizationProfileRequest,\n UpdateOrganizationProfileRequestSchema,\n type UpdateOrganizationRosterEntryRequest,\n UpdateOrganizationRosterEntryRequestSchema,\n} from \"./organization\";\nexport {\n type CreateOrganizationRequest,\n CreateOrganizationRequestSchema,\n isCreateOrganizationRequest,\n isOrganizationProvisioningRequest,\n isProvisionedDocumentRequest,\n isProvisionedSystemContainerRequest,\n type OrganizationProvisioningRequest,\n OrganizationProvisioningRequestSchema,\n type ProvisionedDocumentRequest,\n ProvisionedDocumentRequestSchema,\n type ProvisionedSystemContainerRequest,\n ProvisionedSystemContainerRequestSchema,\n} from \"./organizationProvisioning\";\nexport {\n type CommitOrganizationGroupPolicyRequest,\n CommitOrganizationGroupPolicyRequestSchema,\n isCommitOrganizationGroupPolicyRequest,\n isOrganizationPrincipalPolicyRequest,\n isPutPrincipalPolicyRequest,\n type OrganizationPrincipalPolicyRequest,\n OrganizationPrincipalPolicyRequestSchema,\n type PrincipalContainerGrantRequest,\n PrincipalContainerGrantRequestSchema,\n type PrincipalMemberEnvelopeRequest,\n type PrincipalProjectionMemberRequest,\n type PrincipalStateEncryptedPayloadRequest,\n type PrincipalStateRequest,\n type PutPrincipalPolicyRequest,\n PutPrincipalPolicyRequestSchema,\n} from \"./principal\";\nexport {\n isRegistrationRequest,\n type RegistrationRequest,\n RegistrationRequestSchema,\n} from \"./registration\";\nexport {\n isRevenueCatTransferWebhookEvent,\n isRevenueCatWebhookRequest,\n type RevenueCatIncomingWebhookEvent,\n RevenueCatIncomingWebhookEventSchema,\n type RevenueCatSubscriberAttribute,\n RevenueCatSubscriberAttributeSchema,\n type RevenueCatTransferWebhookEvent,\n RevenueCatTransferWebhookEventSchema,\n type RevenueCatWebhookEvent,\n RevenueCatWebhookEventSchema,\n type RevenueCatWebhookRequest,\n RevenueCatWebhookRequestSchema,\n} from \"./revenuecatWebhook\";\nexport {\n isStripeReturnUrlRequest,\n type StripeReturnUrlRequest,\n StripeReturnUrlRequestSchema,\n} from \"./stripeCheckout\";\nexport {\n isStripeWebhookRequest,\n type StripeWebhookRequest,\n StripeWebhookRequestSchema,\n} from \"./stripeWebhook\";\n"]}
|