@tearleads/client-sdk 0.1.244 → 0.1.246

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (101) hide show
  1. package/data/persistence/container-contents/containerContentsPersistence.js +2 -0
  2. package/data/persistence/container-contents/containerContentsPersistence.js.map +1 -1
  3. package/data/persistence/container-contents/containerContentsPersistenceTypes.d.ts +2 -1
  4. package/data/persistence/container-contents/containerContentsPersistenceTypes.js.map +1 -1
  5. package/data/persistence/container-contents/containerMetadataRevalidations.d.ts +22 -0
  6. package/data/persistence/container-contents/containerMetadataRevalidations.js +52 -0
  7. package/data/persistence/container-contents/containerMetadataRevalidations.js.map +1 -0
  8. package/data/sqlite/schema/containerSchema.d.ts +173 -0
  9. package/data/sqlite/schema/containerSchema.js +18 -0
  10. package/data/sqlite/schema/containerSchema.js.map +1 -1
  11. package/data/sqlite/schema/index.d.ts +84 -1
  12. package/data/sqlite/schema/index.js +1 -1
  13. package/data/sqlite/schema/index.js.map +1 -1
  14. package/internal/api-client/ApiClient.d.ts +1 -8
  15. package/internal/api-client/client/apiClientContext.d.ts +1 -0
  16. package/internal/api-client/client/containerReads.d.ts +1 -0
  17. package/internal/crypto/keying/accessManifestVerificationTypes.d.ts +8 -2
  18. package/internal/crypto/keying/accessManifestVerificationTypes.js.map +1 -1
  19. package/internal/crypto/keying/containerAccess.js +1 -1
  20. package/internal/crypto/keying/containerAccess.js.map +1 -1
  21. package/internal/crypto/keying/documentAccess.js +1 -1
  22. package/internal/crypto/keying/documentAccess.js.map +1 -1
  23. package/internal/crypto/organizationReplacement.js +5 -6
  24. package/internal/crypto/organizationReplacement.js.map +1 -1
  25. package/internal/loro/document.d.ts +5 -0
  26. package/internal/loro/document.js +17 -0
  27. package/internal/loro/document.js.map +1 -1
  28. package/internal/loro/index.d.ts +1 -1
  29. package/internal/loro/index.js +1 -1
  30. package/internal/loro/index.js.map +1 -1
  31. package/internal/validators/operation/attachments.d.ts +0 -12
  32. package/internal/validators/operation/auth.d.ts +0 -76
  33. package/internal/validators/operation/containerMutations.d.ts +1 -49
  34. package/internal/validators/operation/containerMutations.js +1 -1
  35. package/internal/validators/operation/containerMutations.js.map +1 -1
  36. package/internal/validators/operation/containerReads.d.ts +2 -0
  37. package/internal/validators/operation/documentMutations.d.ts +0 -24
  38. package/internal/validators/operation/documentSync.d.ts +0 -4
  39. package/internal/validators/operation/organizations.d.ts +0 -88
  40. package/internal/validators/operation/principals.d.ts +0 -16
  41. package/internal/validators/request/blob.d.ts +0 -12
  42. package/internal/validators/request/container.d.ts +0 -16
  43. package/internal/validators/request/container.js +0 -2
  44. package/internal/validators/request/container.js.map +1 -1
  45. package/internal/validators/request/containerMetadata.d.ts +0 -20
  46. package/internal/validators/request/document.d.ts +0 -22
  47. package/internal/validators/request/document.js +0 -1
  48. package/internal/validators/request/document.js.map +1 -1
  49. package/internal/validators/request/documentSyncSchema.d.ts +0 -4
  50. package/internal/validators/request/documentSyncSchema.js +0 -1
  51. package/internal/validators/request/documentSyncSchema.js.map +1 -1
  52. package/internal/validators/request/organization.d.ts +0 -16
  53. package/internal/validators/request/organizationProvisioning.d.ts +0 -242
  54. package/internal/validators/request/principal.d.ts +0 -20
  55. package/internal/validators/request/registration.d.ts +0 -76
  56. package/internal/validators/response/container.d.ts +8 -0
  57. package/internal/validators/response/container.js +1 -0
  58. package/internal/validators/response/container.js.map +1 -1
  59. package/internal/validators/response/containerParentLanes.d.ts +2 -0
  60. package/package.json +1 -1
  61. package/stores/container-contents/containerContentsStore.js +2 -0
  62. package/stores/container-contents/containerContentsStore.js.map +1 -1
  63. package/stores/container-contents/hydration/startupHydration.js +6 -2
  64. package/stores/container-contents/hydration/startupHydration.js.map +1 -1
  65. package/stores/container-contents/state.js +5 -1
  66. package/stores/container-contents/state.js.map +1 -1
  67. package/stores/container-contents/syncAgent/metadataRevalidation.js +79 -0
  68. package/stores/container-contents/syncAgent/metadataRevalidation.js.map +1 -0
  69. package/stores/container-contents/syncAgent/syncAgentTypes.d.ts +6 -0
  70. package/stores/container-contents/syncAgent/syncAgentTypes.js.map +1 -1
  71. package/stores/container-contents/syncAgent/syncLaneIteration.js +110 -23
  72. package/stores/container-contents/syncAgent/syncLaneIteration.js.map +1 -1
  73. package/workflows/container-contents/container-state/move/acceptedMoveSettlement.js +3 -0
  74. package/workflows/container-contents/container-state/move/acceptedMoveSettlement.js.map +1 -1
  75. package/workflows/container-contents/container-state/remote.js +3 -0
  76. package/workflows/container-contents/container-state/remote.js.map +1 -1
  77. package/workflows/container-contents/containerPersistence.d.ts +1 -0
  78. package/workflows/container-contents/containerPersistence.js.map +1 -1
  79. package/workflows/container-contents/metadata/index.js +4 -1
  80. package/workflows/container-contents/metadata/index.js.map +1 -1
  81. package/workflows/container-contents/metadata/metadataSyncFollowup.js +9 -0
  82. package/workflows/container-contents/metadata/metadataSyncFollowup.js.map +1 -1
  83. package/workflows/container-contents/metadata/metadataTypes.d.ts +2 -0
  84. package/workflows/container-contents/metadata/metadataTypes.js.map +1 -1
  85. package/workflows/container-contents/remoteHydration/index.js +9 -0
  86. package/workflows/container-contents/remoteHydration/index.js.map +1 -1
  87. package/workflows/container-contents/remoteHydration/remoteContainers/remoteContainerState.js +31 -0
  88. package/workflows/container-contents/remoteHydration/remoteContainers/remoteContainerState.js.map +1 -1
  89. package/workflows/container-contents/remoteHydration/types.d.ts +9 -1
  90. package/workflows/container-contents/remoteHydration/types.js.map +1 -1
  91. package/workflows/containers/child/mutationRequestCore.js +1 -1
  92. package/workflows/containers/child/mutationRequestCore.js.map +1 -1
  93. package/workflows/containers/child/recitePlan.js +0 -1
  94. package/workflows/containers/child/recitePlan.js.map +1 -1
  95. package/workflows/containers/root/create.js +0 -1
  96. package/workflows/containers/root/create.js.map +1 -1
  97. package/workflows/documents/linkSet/index.js +0 -1
  98. package/workflows/documents/linkSet/index.js.map +1 -1
  99. package/workflows/organizations/principalPolicy/principalPolicyReceiptArtifacts.js +17 -10
  100. package/workflows/organizations/principalPolicy/principalPolicyReceiptArtifacts.js.map +1 -1
  101. package/workflows/registration/provisioningBootstrapBuilders.d.ts +0 -2
@@ -16,7 +16,6 @@ export declare const documentCreateRequestShape: {
16
16
  expectedManifestHash: string;
17
17
  keyEpoch: Record<string, unknown>;
18
18
  keyring: Record<string, unknown> | null;
19
- manifest: Record<string, unknown>;
20
19
  predecessorBridge: Record<string, unknown> | null;
21
20
  principalPolicyRefs: {
22
21
  principalType: "group" | "organization";
@@ -57,7 +56,6 @@ export declare const documentCreateRequestShape: {
57
56
  expectedManifestHash: string;
58
57
  keyEpoch: Record<string, unknown>;
59
58
  keyring: Record<string, unknown> | null;
60
- manifest: Record<string, unknown>;
61
59
  predecessorBridge: Record<string, unknown> | null;
62
60
  principalPolicyRefs: {
63
61
  principalType: "group" | "organization";
@@ -182,7 +180,6 @@ export declare const DocumentCreateBaseRequestSchema: z.ZodType<{
182
180
  expectedManifestHash: string;
183
181
  keyEpoch: Record<string, unknown>;
184
182
  keyring: Record<string, unknown> | null;
185
- manifest: Record<string, unknown>;
186
183
  predecessorBridge: Record<string, unknown> | null;
187
184
  principalPolicyRefs: {
188
185
  principalType: "group" | "organization";
@@ -250,7 +247,6 @@ export declare const DocumentCreateBaseRequestSchema: z.ZodType<{
250
247
  expectedManifestHash: string;
251
248
  keyEpoch: Record<string, unknown>;
252
249
  keyring: Record<string, unknown> | null;
253
- manifest: Record<string, unknown>;
254
250
  predecessorBridge: Record<string, unknown> | null;
255
251
  principalPolicyRefs: {
256
252
  principalType: "group" | "organization";
@@ -318,7 +314,6 @@ export declare const DocumentCreateBaseRequestSchema: z.ZodType<{
318
314
  expectedManifestHash: string;
319
315
  keyEpoch: Record<string, unknown>;
320
316
  keyring: Record<string, unknown> | null;
321
- manifest: Record<string, unknown>;
322
317
  predecessorBridge: Record<string, unknown> | null;
323
318
  principalPolicyRefs: {
324
319
  principalType: "group" | "organization";
@@ -386,7 +381,6 @@ export declare const DocumentCreateBaseRequestSchema: z.ZodType<{
386
381
  expectedManifestHash: string;
387
382
  keyEpoch: Record<string, unknown>;
388
383
  keyring: Record<string, unknown> | null;
389
- manifest: Record<string, unknown>;
390
384
  predecessorBridge: Record<string, unknown> | null;
391
385
  principalPolicyRefs: {
392
386
  principalType: "group" | "organization";
@@ -477,7 +471,6 @@ export declare const DocumentCreateRequestSchema: z.ZodType<{
477
471
  expectedManifestHash: string;
478
472
  keyEpoch: Record<string, unknown>;
479
473
  keyring: Record<string, unknown> | null;
480
- manifest: Record<string, unknown>;
481
474
  predecessorBridge: Record<string, unknown> | null;
482
475
  principalPolicyRefs: {
483
476
  principalType: "group" | "organization";
@@ -541,7 +534,6 @@ export declare const DocumentCreateRequestSchema: z.ZodType<{
541
534
  expectedManifestHash: string;
542
535
  keyEpoch: Record<string, unknown>;
543
536
  keyring: Record<string, unknown> | null;
544
- manifest: Record<string, unknown>;
545
537
  predecessorBridge: Record<string, unknown> | null;
546
538
  principalPolicyRefs: {
547
539
  principalType: "group" | "organization";
@@ -626,7 +618,6 @@ export declare const DocumentCreateRequestSchema: z.ZodType<{
626
618
  expectedManifestHash: string;
627
619
  keyEpoch: Record<string, unknown>;
628
620
  keyring: Record<string, unknown> | null;
629
- manifest: Record<string, unknown>;
630
621
  predecessorBridge: Record<string, unknown> | null;
631
622
  principalPolicyRefs: {
632
623
  principalType: "group" | "organization";
@@ -690,7 +681,6 @@ export declare const DocumentCreateRequestSchema: z.ZodType<{
690
681
  expectedManifestHash: string;
691
682
  keyEpoch: Record<string, unknown>;
692
683
  keyring: Record<string, unknown> | null;
693
- manifest: Record<string, unknown>;
694
684
  predecessorBridge: Record<string, unknown> | null;
695
685
  principalPolicyRefs: {
696
686
  principalType: "group" | "organization";
@@ -775,7 +765,6 @@ export declare const DocumentCreateRequestSchema: z.ZodType<{
775
765
  expectedManifestHash: string;
776
766
  keyEpoch: Record<string, unknown>;
777
767
  keyring: Record<string, unknown> | null;
778
- manifest: Record<string, unknown>;
779
768
  predecessorBridge: Record<string, unknown> | null;
780
769
  principalPolicyRefs: {
781
770
  principalType: "group" | "organization";
@@ -839,7 +828,6 @@ export declare const DocumentCreateRequestSchema: z.ZodType<{
839
828
  expectedManifestHash: string;
840
829
  keyEpoch: Record<string, unknown>;
841
830
  keyring: Record<string, unknown> | null;
842
- manifest: Record<string, unknown>;
843
831
  predecessorBridge: Record<string, unknown> | null;
844
832
  principalPolicyRefs: {
845
833
  principalType: "group" | "organization";
@@ -924,7 +912,6 @@ export declare const DocumentCreateRequestSchema: z.ZodType<{
924
912
  expectedManifestHash: string;
925
913
  keyEpoch: Record<string, unknown>;
926
914
  keyring: Record<string, unknown> | null;
927
- manifest: Record<string, unknown>;
928
915
  predecessorBridge: Record<string, unknown> | null;
929
916
  principalPolicyRefs: {
930
917
  principalType: "group" | "organization";
@@ -988,7 +975,6 @@ export declare const DocumentCreateRequestSchema: z.ZodType<{
988
975
  expectedManifestHash: string;
989
976
  keyEpoch: Record<string, unknown>;
990
977
  keyring: Record<string, unknown> | null;
991
- manifest: Record<string, unknown>;
992
978
  predecessorBridge: Record<string, unknown> | null;
993
979
  principalPolicyRefs: {
994
980
  principalType: "group" | "organization";
@@ -1051,7 +1037,6 @@ export declare const DocumentLinkSetMutationRequestSchema: z.ZodType<{
1051
1037
  };
1052
1038
  event: Record<string, unknown>;
1053
1039
  expectedManifestHash: string;
1054
- manifest: Record<string, unknown>;
1055
1040
  targetContainerPathRefs: {
1056
1041
  containerId: string;
1057
1042
  manifestHash: string;
@@ -1062,7 +1047,6 @@ export declare const DocumentLinkSetMutationRequestSchema: z.ZodType<{
1062
1047
  expectedManifestHash: string;
1063
1048
  keyEpoch: Record<string, unknown>;
1064
1049
  keyring: Record<string, unknown> | null;
1065
- manifest: Record<string, unknown>;
1066
1050
  predecessorBridge: Record<string, unknown> | null;
1067
1051
  principalPolicyRefs: {
1068
1052
  principalType: "group" | "organization";
@@ -1130,7 +1114,6 @@ export declare const DocumentLinkSetMutationRequestSchema: z.ZodType<{
1130
1114
  };
1131
1115
  event: Record<string, unknown>;
1132
1116
  expectedManifestHash: string;
1133
- manifest: Record<string, unknown>;
1134
1117
  targetContainerPathRefs: {
1135
1118
  containerId: string;
1136
1119
  manifestHash: string;
@@ -1141,7 +1124,6 @@ export declare const DocumentLinkSetMutationRequestSchema: z.ZodType<{
1141
1124
  expectedManifestHash: string;
1142
1125
  keyEpoch: Record<string, unknown>;
1143
1126
  keyring: Record<string, unknown> | null;
1144
- manifest: Record<string, unknown>;
1145
1127
  predecessorBridge: Record<string, unknown> | null;
1146
1128
  principalPolicyRefs: {
1147
1129
  principalType: "group" | "organization";
@@ -1209,7 +1191,6 @@ export declare const DocumentLinkSetMutationRequestSchema: z.ZodType<{
1209
1191
  };
1210
1192
  event: Record<string, unknown>;
1211
1193
  expectedManifestHash: string;
1212
- manifest: Record<string, unknown>;
1213
1194
  targetContainerPathRefs: {
1214
1195
  containerId: string;
1215
1196
  manifestHash: string;
@@ -1220,7 +1201,6 @@ export declare const DocumentLinkSetMutationRequestSchema: z.ZodType<{
1220
1201
  expectedManifestHash: string;
1221
1202
  keyEpoch: Record<string, unknown>;
1222
1203
  keyring: Record<string, unknown> | null;
1223
- manifest: Record<string, unknown>;
1224
1204
  predecessorBridge: Record<string, unknown> | null;
1225
1205
  principalPolicyRefs: {
1226
1206
  principalType: "group" | "organization";
@@ -1288,7 +1268,6 @@ export declare const DocumentLinkSetMutationRequestSchema: z.ZodType<{
1288
1268
  };
1289
1269
  event: Record<string, unknown>;
1290
1270
  expectedManifestHash: string;
1291
- manifest: Record<string, unknown>;
1292
1271
  targetContainerPathRefs: {
1293
1272
  containerId: string;
1294
1273
  manifestHash: string;
@@ -1299,7 +1278,6 @@ export declare const DocumentLinkSetMutationRequestSchema: z.ZodType<{
1299
1278
  expectedManifestHash: string;
1300
1279
  keyEpoch: Record<string, unknown>;
1301
1280
  keyring: Record<string, unknown> | null;
1302
- manifest: Record<string, unknown>;
1303
1281
  predecessorBridge: Record<string, unknown> | null;
1304
1282
  principalPolicyRefs: {
1305
1283
  principalType: "group" | "organization";
@@ -44,7 +44,6 @@ export const DocumentLinkSetMutationRequestSchema = registerJsonSchemaRuntimeRef
44
44
  contentKeyBundle: DocumentContentKeyBundleRequestSchema,
45
45
  event: plainObjectSchema,
46
46
  expectedManifestHash: nonEmptyStringSchema,
47
- manifest: plainObjectSchema,
48
47
  rotationBaseline: DocumentOutgoingUpdateSchema.optional(),
49
48
  // A container path (root→leaf chain) must carry at least one manifest
50
49
  // reference; an empty path authorizes nothing and is never legitimately built.
@@ -1 +1 @@
1
- {"version":3,"file":"document.js","sourceRoot":"","sources":["document.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,4BAA4B,EAAE,MAAM,kCAAkC,CAAC;AAChF,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,gCAAgC,EAChC,sBAAsB,GACvB,MAAM,sBAAsB,CAAC;AAC9B,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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UAAU,gCAAgC,CAC9C,KAAc;IAEd,OAAO,oCAAoC,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,OAAO,CAAC;AACvE,CAAC;AAED,MAAM,UAAU,iCAAiC,CAC/C,KAAc;IAEd,OAAO,qCAAqC,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,OAAO,CAAC;AACxE,CAAC;AAED,MAAM,UAAU,uBAAuB,CACrC,KAAc;IAEd,OAAO,2BAA2B,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,OAAO,CAAC;AAC9D,CAAC;AAED,MAAM,UAAU,gCAAgC,CAC9C,KAAc;IAEd,OAAO,oCAAoC,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,OAAO,CAAC;AACvE,CAAC;AAED,MAAM,UAAU,sBAAsB,CACpC,KAAc;IAEd,OAAO,0BAA0B,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,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 { documentCreateSeedRefinement } from \"../documentCreateSeedRefinements\";\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 refineSeedWithinSyncRequestLimit,\n refineSingleUpdateSeed,\n} from \"./documentCreateSeed\";\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\n/** A document create with no seed: a container's metadata document. */\nexport const DocumentCreateBaseRequestSchema = loosePlainObject(\n documentCreateRequestShape,\n);\n\n/**\n * `POST /documents`. The optional seed is the create's first queued update,\n * committed in the create transaction under the same checks as a standalone\n * sync, so a new document needs no follow-up sync round trip.\n */\nexport const DocumentCreateRequestSchema = registerJsonSchemaRuntimeRefinements(\n loosePlainObject({\n ...documentCreateRequestShape,\n initialSync: DocumentSyncRequestSchema.optional(),\n }).superRefine((value, context) => {\n refineSingleUpdateSeed(value.initialSync, context, {\n message:\n \"document create seed requires one update and no container rekeys\",\n path: \"initialSync\",\n });\n refineSeedWithinSyncRequestLimit(value.initialSync, context, \"initialSync\");\n }),\n [documentCreateSeedRefinement],\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
+ {"version":3,"file":"document.js","sourceRoot":"","sources":["document.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,4BAA4B,EAAE,MAAM,kCAAkC,CAAC;AAChF,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,gCAAgC,EAChC,sBAAsB,GACvB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AC,QAAQ,CAAC;YACf,IAAI,EAAE,QAAQ;YACd,OAAO,EAAE,6BAA6B,CAAC,WAAW;YAClD,IAAI,EAAE,CAAC,8BAA8B,CAAC;SACvC,CAAC,CAAC;IACL,CAAC;AACH,CAAC,CAAC,EACF,CAAC,6BAA6B,CAAC,CAChC,CAAC;AAMJ,MAAM,CAAC,MAAM,0BAA0B,GAAG,gBAAgB,CAAC;IACzD,4BAA4B,EAAE,2BAA2B;IACzD,IAAI,EAAE,qBAAqB;IAC3B,KAAK,EAAE,iBAAiB;CACzB,CAAC,CAAC;AAIH,MAAM,UAAU,gCAAgC,CAC9C,KAAc;IAEd,OAAO,oCAAoC,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,OAAO,CAAC;AACvE,CAAC;AAED,MAAM,UAAU,iCAAiC,CAC/C,KAAc;IAEd,OAAO,qCAAqC,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,OAAO,CAAC;AACxE,CAAC;AAED,MAAM,UAAU,uBAAuB,CACrC,KAAc;IAEd,OAAO,2BAA2B,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,OAAO,CAAC;AAC9D,CAAC;AAED,MAAM,UAAU,gCAAgC,CAC9C,KAAc;IAEd,OAAO,oCAAoC,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,OAAO,CAAC;AACvE,CAAC;AAED,MAAM,UAAU,sBAAsB,CACpC,KAAc;IAEd,OAAO,0BAA0B,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,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 { documentCreateSeedRefinement } from \"../documentCreateSeedRefinements\";\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 refineSeedWithinSyncRequestLimit,\n refineSingleUpdateSeed,\n} from \"./documentCreateSeed\";\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\n/** A document create with no seed: a container's metadata document. */\nexport const DocumentCreateBaseRequestSchema = loosePlainObject(\n documentCreateRequestShape,\n);\n\n/**\n * `POST /documents`. The optional seed is the create's first queued update,\n * committed in the create transaction under the same checks as a standalone\n * sync, so a new document needs no follow-up sync round trip.\n */\nexport const DocumentCreateRequestSchema = registerJsonSchemaRuntimeRefinements(\n loosePlainObject({\n ...documentCreateRequestShape,\n initialSync: DocumentSyncRequestSchema.optional(),\n }).superRefine((value, context) => {\n refineSingleUpdateSeed(value.initialSync, context, {\n message:\n \"document create seed requires one update and no container rekeys\",\n path: \"initialSync\",\n });\n refineSeedWithinSyncRequestLimit(value.initialSync, context, \"initialSync\");\n }),\n [documentCreateSeedRefinement],\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 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"]}
@@ -157,7 +157,6 @@ export declare const DocumentSyncRequestSchema: z.ZodType<{
157
157
  expectedManifestHash: string;
158
158
  keyEpoch: Record<string, unknown>;
159
159
  keyring: Record<string, unknown> | null;
160
- manifest: Record<string, unknown>;
161
160
  predecessorBridge: Record<string, unknown> | null;
162
161
  principalPolicyRefs: {
163
162
  principalType: "group" | "organization";
@@ -237,7 +236,6 @@ export declare const DocumentSyncRequestSchema: z.ZodType<{
237
236
  expectedManifestHash: string;
238
237
  keyEpoch: Record<string, unknown>;
239
238
  keyring: Record<string, unknown> | null;
240
- manifest: Record<string, unknown>;
241
239
  predecessorBridge: Record<string, unknown> | null;
242
240
  principalPolicyRefs: {
243
241
  principalType: "group" | "organization";
@@ -317,7 +315,6 @@ export declare const DocumentSyncRequestSchema: z.ZodType<{
317
315
  expectedManifestHash: string;
318
316
  keyEpoch: Record<string, unknown>;
319
317
  keyring: Record<string, unknown> | null;
320
- manifest: Record<string, unknown>;
321
318
  predecessorBridge: Record<string, unknown> | null;
322
319
  principalPolicyRefs: {
323
320
  principalType: "group" | "organization";
@@ -397,7 +394,6 @@ export declare const DocumentSyncRequestSchema: z.ZodType<{
397
394
  expectedManifestHash: string;
398
395
  keyEpoch: Record<string, unknown>;
399
396
  keyring: Record<string, unknown> | null;
400
- manifest: Record<string, unknown>;
401
397
  predecessorBridge: Record<string, unknown> | null;
402
398
  principalPolicyRefs: {
403
399
  principalType: "group" | "organization";
@@ -74,7 +74,6 @@ const DocumentSyncContainerMutationRequestSchema = registerJsonSchemaView(z.cust
74
74
  expectedManifestHash: nonEmptyStringSchema,
75
75
  keyEpoch: plainObjectSchema,
76
76
  keyring: plainObjectSchema.nullable(),
77
- manifest: plainObjectSchema,
78
77
  parentContainerPathRefs: OptionalContainerManifestPathSchema.optional(),
79
78
  parentKekRef: ContainerKekParentRefSchema.nullable().optional(),
80
79
  predecessorBridge: plainObjectSchema.nullable(),
@@ -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,M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C7C,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 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 ContainerKekParentRefSchema,\n ContainerManifestPathSchema,\n type ContainerManifestRef,\n ContainerManifestRefListSchema,\n ContainerManifestRefSchema,\n OptionalContainerManifestPathSchema,\n} from \"./containerManifestRef\";\nimport {\n ContentKeyWrappedKeySchema,\n contentKeyWrappingMetadataSchema,\n} from \"./contentKeyEnvelopeSchema\";\nimport { PrincipalPolicyRefListSchema } from \"./principalPolicyRef\";\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 parentKekRef: ContainerKekParentRefSchema.nullable().optional(),\n predecessorBridge: plainObjectSchema.nullable(),\n previousContainerPathRefs: OptionalContainerManifestPathSchema.optional(),\n previousManifestRef: ContainerManifestRefSchema.nullable().optional(),\n principalPolicyRefs: PrincipalPolicyRefListSchema,\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\nfunction exceedsCrossFieldScanBounds(\n outgoingUpdateCount: number,\n authorizingContainerPathRefs: unknown,\n): boolean {\n if (outgoingUpdateCount > MAX_DOCUMENT_SYNC_OUTGOING_UPDATES) return true;\n return (\n Array.isArray(authorizingContainerPathRefs) &&\n authorizingContainerPathRefs.length > MAX_DOCUMENT_SYNC_AUTHORIZATION_PATHS\n );\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 (\n exceedsCrossFieldScanBounds(\n request.outgoingUpdates.length,\n request.authorizingContainerPathRefs,\n )\n ) {\n return;\n }\n\n const hasOutgoingUpdates = request.outgoingUpdates.length > 0;\n const hasContainerRekeys = (request.containerRekeys?.length ?? 0) > 0;\n const carriesWrite =\n hasOutgoingUpdates ||\n hasContainerRekeys ||\n request.contentKeyBundle !== undefined ||\n request.authorizingContainerPathRefs !== undefined;\n if (hasContainerRekeys !== (request.inlineRekeyCommitId !== undefined)) {\n context.addIssue({\n code: \"custom\",\n message: \"inline rekey commit id must accompany container rekeys\",\n path: [\"inlineRekeyCommitId\"],\n });\n }\n if (request.pullCursor !== undefined && carriesWrite) {\n context.addIssue({\n code: \"custom\",\n message: \"continued pulls must be read-only\",\n path: [\"pullCursor\"],\n });\n }\n if (request.historyMode === \"raw\" && carriesWrite) {\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,\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,4BAA4B,CAAC;AACpC,OAAO,EAAE,+BAA+B,EAAE,MAAM,4BAA4B,CAAC;AAC7E,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,EACL,0BAA0B,EAC1B,oCAAoC,EACpC,sBAAsB,GACvB,MAAM,eAAe,CAAC;AACvB,OAAO,EACL,WAAW,EACX,2BAA2B,EAC3B,mBAAmB,EACnB,gBAAgB,EAChB,oBAAoB,EACpB,iBAAiB,EACjB,qBAAqB,EACrB,qBAAqB,EACrB,qBAAqB,GACtB,MAAM,WAAW,CAAC;AACnB,OAAO,EAAE,2BAA2B,EAAE,MAAM,iCAAiC,CAAC;AAC9E,OAAO,EACL,qCAAqC,EACrC,qCAAqC,EACrC,kCAAkC,EAClC,oCAAoC,E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ACf,IAAI,EAAE,QAAQ;YACd,OAAO,EACL,+DAA+D;YACjE,IAAI,EAAE,CAAC,8BAA8B,CAAC;SACvC,CAAC,CAAC;IACL,CAAC;IAED,IAAI,WAAW,KAAK,8BAA8B,EAAE,CAAC;QACnD,OAAO,CAAC,QAAQ,CAAC;YACf,IAAI,EAAE,QAAQ;YACd,OAAO,EAAE,6CAA6C;YACtD,IAAI,EAAE,CAAC,iBAAiB,CAAC;SAC1B,CAAC,CAAC;IACL,CAAC;IAED,IACE,IAAI,GAAG,CACL,OAAO,CAAC,eAAe;SACpB,MAAM,CAAC,aAAa,CAAC;SACrB,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,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 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 ContainerKekParentRefSchema,\n ContainerManifestPathSchema,\n type ContainerManifestRef,\n ContainerManifestRefListSchema,\n ContainerManifestRefSchema,\n OptionalContainerManifestPathSchema,\n} from \"./containerManifestRef\";\nimport {\n ContentKeyWrappedKeySchema,\n contentKeyWrappingMetadataSchema,\n} from \"./contentKeyEnvelopeSchema\";\nimport { PrincipalPolicyRefListSchema } from \"./principalPolicyRef\";\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 parentContainerPathRefs: OptionalContainerManifestPathSchema.optional(),\n parentKekRef: ContainerKekParentRefSchema.nullable().optional(),\n predecessorBridge: plainObjectSchema.nullable(),\n previousContainerPathRefs: OptionalContainerManifestPathSchema.optional(),\n previousManifestRef: ContainerManifestRefSchema.nullable().optional(),\n principalPolicyRefs: PrincipalPolicyRefListSchema,\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\nfunction exceedsCrossFieldScanBounds(\n outgoingUpdateCount: number,\n authorizingContainerPathRefs: unknown,\n): boolean {\n if (outgoingUpdateCount > MAX_DOCUMENT_SYNC_OUTGOING_UPDATES) return true;\n return (\n Array.isArray(authorizingContainerPathRefs) &&\n authorizingContainerPathRefs.length > MAX_DOCUMENT_SYNC_AUTHORIZATION_PATHS\n );\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 (\n exceedsCrossFieldScanBounds(\n request.outgoingUpdates.length,\n request.authorizingContainerPathRefs,\n )\n ) {\n return;\n }\n\n const hasOutgoingUpdates = request.outgoingUpdates.length > 0;\n const hasContainerRekeys = (request.containerRekeys?.length ?? 0) > 0;\n const carriesWrite =\n hasOutgoingUpdates ||\n hasContainerRekeys ||\n request.contentKeyBundle !== undefined ||\n request.authorizingContainerPathRefs !== undefined;\n if (hasContainerRekeys !== (request.inlineRekeyCommitId !== undefined)) {\n context.addIssue({\n code: \"custom\",\n message: \"inline rekey commit id must accompany container rekeys\",\n path: [\"inlineRekeyCommitId\"],\n });\n }\n if (request.pullCursor !== undefined && carriesWrite) {\n context.addIssue({\n code: \"custom\",\n message: \"continued pulls must be read-only\",\n path: [\"pullCursor\"],\n });\n }\n if (request.historyMode === \"raw\" && carriesWrite) {\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,\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"]}
@@ -57,7 +57,6 @@ export declare const CreateOrganizationGroupRequestSchema: z.ZodObject<{
57
57
  expectedManifestHash: string;
58
58
  keyEpoch: Record<string, unknown>;
59
59
  keyring: Record<string, unknown> | null;
60
- manifest: Record<string, unknown>;
61
60
  predecessorBridge: Record<string, unknown> | null;
62
61
  principalPolicyRefs: {
63
62
  principalType: "group" | "organization";
@@ -149,7 +148,6 @@ export declare const CreateOrganizationGroupRequestSchema: z.ZodObject<{
149
148
  expectedManifestHash: string;
150
149
  keyEpoch: Record<string, unknown>;
151
150
  keyring: Record<string, unknown> | null;
152
- manifest: Record<string, unknown>;
153
151
  predecessorBridge: Record<string, unknown> | null;
154
152
  principalPolicyRefs: {
155
153
  principalType: "group" | "organization";
@@ -241,7 +239,6 @@ export declare const CreateOrganizationGroupRequestSchema: z.ZodObject<{
241
239
  expectedManifestHash: string;
242
240
  keyEpoch: Record<string, unknown>;
243
241
  keyring: Record<string, unknown> | null;
244
- manifest: Record<string, unknown>;
245
242
  predecessorBridge: Record<string, unknown> | null;
246
243
  principalPolicyRefs: {
247
244
  principalType: "group" | "organization";
@@ -333,7 +330,6 @@ export declare const CreateOrganizationGroupRequestSchema: z.ZodObject<{
333
330
  expectedManifestHash: string;
334
331
  keyEpoch: Record<string, unknown>;
335
332
  keyring: Record<string, unknown> | null;
336
- manifest: Record<string, unknown>;
337
333
  predecessorBridge: Record<string, unknown> | null;
338
334
  principalPolicyRefs: {
339
335
  principalType: "group" | "organization";
@@ -428,7 +424,6 @@ export declare const CreateOrganizationGroupWithPolicyRequestSchema: z.ZodObject
428
424
  expectedManifestHash: string;
429
425
  keyEpoch: Record<string, unknown>;
430
426
  keyring: Record<string, unknown> | null;
431
- manifest: Record<string, unknown>;
432
427
  predecessorBridge: Record<string, unknown> | null;
433
428
  principalPolicyRefs: {
434
429
  principalType: "group" | "organization";
@@ -520,7 +515,6 @@ export declare const CreateOrganizationGroupWithPolicyRequestSchema: z.ZodObject
520
515
  expectedManifestHash: string;
521
516
  keyEpoch: Record<string, unknown>;
522
517
  keyring: Record<string, unknown> | null;
523
- manifest: Record<string, unknown>;
524
518
  predecessorBridge: Record<string, unknown> | null;
525
519
  principalPolicyRefs: {
526
520
  principalType: "group" | "organization";
@@ -612,7 +606,6 @@ export declare const CreateOrganizationGroupWithPolicyRequestSchema: z.ZodObject
612
606
  expectedManifestHash: string;
613
607
  keyEpoch: Record<string, unknown>;
614
608
  keyring: Record<string, unknown> | null;
615
- manifest: Record<string, unknown>;
616
609
  predecessorBridge: Record<string, unknown> | null;
617
610
  principalPolicyRefs: {
618
611
  principalType: "group" | "organization";
@@ -704,7 +697,6 @@ export declare const CreateOrganizationGroupWithPolicyRequestSchema: z.ZodObject
704
697
  expectedManifestHash: string;
705
698
  keyEpoch: Record<string, unknown>;
706
699
  keyring: Record<string, unknown> | null;
707
- manifest: Record<string, unknown>;
708
700
  predecessorBridge: Record<string, unknown> | null;
709
701
  principalPolicyRefs: {
710
702
  principalType: "group" | "organization";
@@ -798,7 +790,6 @@ export declare const CreateOrganizationGroupWithPolicyRequestSchema: z.ZodObject
798
790
  expectedManifestHash: string;
799
791
  keyEpoch: Record<string, unknown>;
800
792
  keyring: Record<string, unknown> | null;
801
- manifest: Record<string, unknown>;
802
793
  predecessorBridge: Record<string, unknown> | null;
803
794
  principalPolicyRefs: {
804
795
  principalType: "group" | "organization";
@@ -890,7 +881,6 @@ export declare const CreateOrganizationGroupWithPolicyRequestSchema: z.ZodObject
890
881
  expectedManifestHash: string;
891
882
  keyEpoch: Record<string, unknown>;
892
883
  keyring: Record<string, unknown> | null;
893
- manifest: Record<string, unknown>;
894
884
  predecessorBridge: Record<string, unknown> | null;
895
885
  principalPolicyRefs: {
896
886
  principalType: "group" | "organization";
@@ -982,7 +972,6 @@ export declare const CreateOrganizationGroupWithPolicyRequestSchema: z.ZodObject
982
972
  expectedManifestHash: string;
983
973
  keyEpoch: Record<string, unknown>;
984
974
  keyring: Record<string, unknown> | null;
985
- manifest: Record<string, unknown>;
986
975
  predecessorBridge: Record<string, unknown> | null;
987
976
  principalPolicyRefs: {
988
977
  principalType: "group" | "organization";
@@ -1074,7 +1063,6 @@ export declare const CreateOrganizationGroupWithPolicyRequestSchema: z.ZodObject
1074
1063
  expectedManifestHash: string;
1075
1064
  keyEpoch: Record<string, unknown>;
1076
1065
  keyring: Record<string, unknown> | null;
1077
- manifest: Record<string, unknown>;
1078
1066
  predecessorBridge: Record<string, unknown> | null;
1079
1067
  principalPolicyRefs: {
1080
1068
  principalType: "group" | "organization";
@@ -1171,7 +1159,6 @@ export declare const DeleteOrganizationGroupRequestSchema: z.ZodType<{
1171
1159
  expectedManifestHash: string;
1172
1160
  keyEpoch: Record<string, unknown>;
1173
1161
  keyring: Record<string, unknown> | null;
1174
- manifest: Record<string, unknown>;
1175
1162
  predecessorBridge: Record<string, unknown> | null;
1176
1163
  principalPolicyRefs: {
1177
1164
  principalType: "group" | "organization";
@@ -1265,7 +1252,6 @@ export declare const DeleteOrganizationGroupRequestSchema: z.ZodType<{
1265
1252
  expectedManifestHash: string;
1266
1253
  keyEpoch: Record<string, unknown>;
1267
1254
  keyring: Record<string, unknown> | null;
1268
- manifest: Record<string, unknown>;
1269
1255
  predecessorBridge: Record<string, unknown> | null;
1270
1256
  principalPolicyRefs: {
1271
1257
  principalType: "group" | "organization";
@@ -1359,7 +1345,6 @@ export declare const DeleteOrganizationGroupRequestSchema: z.ZodType<{
1359
1345
  expectedManifestHash: string;
1360
1346
  keyEpoch: Record<string, unknown>;
1361
1347
  keyring: Record<string, unknown> | null;
1362
- manifest: Record<string, unknown>;
1363
1348
  predecessorBridge: Record<string, unknown> | null;
1364
1349
  principalPolicyRefs: {
1365
1350
  principalType: "group" | "organization";
@@ -1453,7 +1438,6 @@ export declare const DeleteOrganizationGroupRequestSchema: z.ZodType<{
1453
1438
  expectedManifestHash: string;
1454
1439
  keyEpoch: Record<string, unknown>;
1455
1440
  keyring: Record<string, unknown> | null;
1456
- manifest: Record<string, unknown>;
1457
1441
  predecessorBridge: Record<string, unknown> | null;
1458
1442
  principalPolicyRefs: {
1459
1443
  principalType: "group" | "organization";