@abloatai/transaction 0.37.0
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/CONVENTIONS.md +83 -0
- package/README.md +48 -0
- package/dist/ablo.d.ts +90 -0
- package/dist/ablo.d.ts.map +1 -0
- package/dist/ablo.js +34 -0
- package/dist/ablo.js.map +1 -0
- package/dist/ai-sdk/coordinatedTool.d.ts +123 -0
- package/dist/ai-sdk/coordinatedTool.d.ts.map +1 -0
- package/dist/ai-sdk/coordinatedTool.js +135 -0
- package/dist/ai-sdk/coordinatedTool.js.map +1 -0
- package/dist/ai-sdk/index.d.ts +2 -0
- package/dist/ai-sdk/index.d.ts.map +1 -0
- package/dist/ai-sdk/index.js +2 -0
- package/dist/ai-sdk/index.js.map +1 -0
- package/dist/auth/apiKey.d.ts +154 -0
- package/dist/auth/apiKey.d.ts.map +1 -0
- package/dist/auth/apiKey.js +408 -0
- package/dist/auth/apiKey.js.map +1 -0
- package/dist/auth/bootstrapScope.d.ts +16 -0
- package/dist/auth/bootstrapScope.d.ts.map +1 -0
- package/dist/auth/bootstrapScope.js +2 -0
- package/dist/auth/bootstrapScope.js.map +1 -0
- package/dist/auth/browserCredentialSafety.d.ts +7 -0
- package/dist/auth/browserCredentialSafety.d.ts.map +1 -0
- package/dist/auth/browserCredentialSafety.js +29 -0
- package/dist/auth/browserCredentialSafety.js.map +1 -0
- package/dist/auth/capability.d.ts +241 -0
- package/dist/auth/capability.d.ts.map +1 -0
- package/dist/auth/capability.js +253 -0
- package/dist/auth/capability.js.map +1 -0
- package/dist/auth/capabilityLifecycle.d.ts +47 -0
- package/dist/auth/capabilityLifecycle.d.ts.map +1 -0
- package/dist/auth/capabilityLifecycle.js +108 -0
- package/dist/auth/capabilityLifecycle.js.map +1 -0
- package/dist/auth/credentialEndpoint.d.ts +10 -0
- package/dist/auth/credentialEndpoint.d.ts.map +1 -0
- package/dist/auth/credentialEndpoint.js +58 -0
- package/dist/auth/credentialEndpoint.js.map +1 -0
- package/dist/auth/credentialEndpointProtocol.d.ts +24 -0
- package/dist/auth/credentialEndpointProtocol.d.ts.map +1 -0
- package/dist/auth/credentialEndpointProtocol.js +34 -0
- package/dist/auth/credentialEndpointProtocol.js.map +1 -0
- package/dist/auth/credentialKind.d.ts +4 -0
- package/dist/auth/credentialKind.d.ts.map +1 -0
- package/dist/auth/credentialKind.js +15 -0
- package/dist/auth/credentialKind.js.map +1 -0
- package/dist/auth/credentialPolicy.d.ts +141 -0
- package/dist/auth/credentialPolicy.d.ts.map +1 -0
- package/dist/auth/credentialPolicy.js +113 -0
- package/dist/auth/credentialPolicy.js.map +1 -0
- package/dist/auth/credentialResult.d.ts +7 -0
- package/dist/auth/credentialResult.d.ts.map +1 -0
- package/dist/auth/credentialResult.js +9 -0
- package/dist/auth/credentialResult.js.map +1 -0
- package/dist/auth/credentialSource.d.ts +31 -0
- package/dist/auth/credentialSource.d.ts.map +1 -0
- package/dist/auth/credentialSource.js +56 -0
- package/dist/auth/credentialSource.js.map +1 -0
- package/dist/auth/hostedEndpoints.d.ts +22 -0
- package/dist/auth/hostedEndpoints.d.ts.map +1 -0
- package/dist/auth/hostedEndpoints.js +22 -0
- package/dist/auth/hostedEndpoints.js.map +1 -0
- package/dist/auth/identity.d.ts +62 -0
- package/dist/auth/identity.d.ts.map +1 -0
- package/dist/auth/identity.js +224 -0
- package/dist/auth/identity.js.map +1 -0
- package/dist/auth/index.d.ts +189 -0
- package/dist/auth/index.d.ts.map +1 -0
- package/dist/auth/index.js +312 -0
- package/dist/auth/index.js.map +1 -0
- package/dist/auth/schemas.d.ts +41 -0
- package/dist/auth/schemas.d.ts.map +1 -0
- package/dist/auth/schemas.js +69 -0
- package/dist/auth/schemas.js.map +1 -0
- package/dist/auth/sessionMint.d.ts +29 -0
- package/dist/auth/sessionMint.d.ts.map +1 -0
- package/dist/auth/sessionMint.js +92 -0
- package/dist/auth/sessionMint.js.map +1 -0
- package/dist/auth/token.d.ts +4 -0
- package/dist/auth/token.d.ts.map +1 -0
- package/dist/auth/token.js +4 -0
- package/dist/auth/token.js.map +1 -0
- package/dist/batching/index.d.ts +56 -0
- package/dist/batching/index.d.ts.map +1 -0
- package/dist/batching/index.js +148 -0
- package/dist/batching/index.js.map +1 -0
- package/dist/coordination/awaitClaimGrant.d.ts +57 -0
- package/dist/coordination/awaitClaimGrant.d.ts.map +1 -0
- package/dist/coordination/awaitClaimGrant.js +138 -0
- package/dist/coordination/awaitClaimGrant.js.map +1 -0
- package/dist/coordination/claimHeartbeatLoop.d.ts +85 -0
- package/dist/coordination/claimHeartbeatLoop.d.ts.map +1 -0
- package/dist/coordination/claimHeartbeatLoop.js +109 -0
- package/dist/coordination/claimHeartbeatLoop.js.map +1 -0
- package/dist/coordination/claimMeta.d.ts +50 -0
- package/dist/coordination/claimMeta.d.ts.map +1 -0
- package/dist/coordination/claimMeta.js +53 -0
- package/dist/coordination/claimMeta.js.map +1 -0
- package/dist/coordination/events.d.ts +75 -0
- package/dist/coordination/events.d.ts.map +1 -0
- package/dist/coordination/events.js +8 -0
- package/dist/coordination/events.js.map +1 -0
- package/dist/coordination/index.d.ts +20 -0
- package/dist/coordination/index.d.ts.map +1 -0
- package/dist/coordination/index.js +46 -0
- package/dist/coordination/index.js.map +1 -0
- package/dist/coordination/locator.d.ts +106 -0
- package/dist/coordination/locator.d.ts.map +1 -0
- package/dist/coordination/locator.js +110 -0
- package/dist/coordination/locator.js.map +1 -0
- package/dist/coordination/schema.d.ts +1332 -0
- package/dist/coordination/schema.d.ts.map +1 -0
- package/dist/coordination/schema.js +1137 -0
- package/dist/coordination/schema.js.map +1 -0
- package/dist/coordination/targetConflict.d.ts +3 -0
- package/dist/coordination/targetConflict.d.ts.map +1 -0
- package/dist/coordination/targetConflict.js +74 -0
- package/dist/coordination/targetConflict.js.map +1 -0
- package/dist/coordination/trace.d.ts +79 -0
- package/dist/coordination/trace.d.ts.map +1 -0
- package/dist/coordination/trace.js +139 -0
- package/dist/coordination/trace.js.map +1 -0
- package/dist/docs/catalog.d.ts +73 -0
- package/dist/docs/catalog.d.ts.map +1 -0
- package/dist/docs/catalog.js +231 -0
- package/dist/docs/catalog.js.map +1 -0
- package/dist/docs/index.d.ts +11 -0
- package/dist/docs/index.d.ts.map +1 -0
- package/dist/docs/index.js +11 -0
- package/dist/docs/index.js.map +1 -0
- package/dist/durableWrites.d.ts +63 -0
- package/dist/durableWrites.d.ts.map +1 -0
- package/dist/durableWrites.js +72 -0
- package/dist/durableWrites.js.map +1 -0
- package/dist/environment.d.ts +106 -0
- package/dist/environment.d.ts.map +1 -0
- package/dist/environment.js +109 -0
- package/dist/environment.js.map +1 -0
- package/dist/errorCodes.d.ts +411 -0
- package/dist/errorCodes.d.ts.map +1 -0
- package/dist/errorCodes.js +500 -0
- package/dist/errorCodes.js.map +1 -0
- package/dist/errors.d.ts +429 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +687 -0
- package/dist/errors.js.map +1 -0
- package/dist/footprint.d.ts +112 -0
- package/dist/footprint.d.ts.map +1 -0
- package/dist/footprint.js +0 -0
- package/dist/footprint.js.map +1 -0
- package/dist/headlessClient.d.ts +10 -0
- package/dist/headlessClient.d.ts.map +1 -0
- package/dist/headlessClient.js +114 -0
- package/dist/headlessClient.js.map +1 -0
- package/dist/index.d.ts +21 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +21 -0
- package/dist/index.js.map +1 -0
- package/dist/keys/index.d.ts +88 -0
- package/dist/keys/index.d.ts.map +1 -0
- package/dist/keys/index.js +208 -0
- package/dist/keys/index.js.map +1 -0
- package/dist/log/syncDeltaRow.d.ts +159 -0
- package/dist/log/syncDeltaRow.d.ts.map +1 -0
- package/dist/log/syncDeltaRow.js +96 -0
- package/dist/log/syncDeltaRow.js.map +1 -0
- package/dist/logger.d.ts +17 -0
- package/dist/logger.d.ts.map +1 -0
- package/dist/logger.js +8 -0
- package/dist/logger.js.map +1 -0
- package/dist/observability.d.ts +54 -0
- package/dist/observability.d.ts.map +1 -0
- package/dist/observability.js +20 -0
- package/dist/observability.js.map +1 -0
- package/dist/policy/types.d.ts +218 -0
- package/dist/policy/types.d.ts.map +1 -0
- package/dist/policy/types.js +127 -0
- package/dist/policy/types.js.map +1 -0
- package/dist/resources/functionalUpdate.d.ts +80 -0
- package/dist/resources/functionalUpdate.d.ts.map +1 -0
- package/dist/resources/functionalUpdate.js +88 -0
- package/dist/resources/functionalUpdate.js.map +1 -0
- package/dist/resources/httpResources.d.ts +449 -0
- package/dist/resources/httpResources.d.ts.map +1 -0
- package/dist/resources/httpResources.js +8 -0
- package/dist/resources/httpResources.js.map +1 -0
- package/dist/resources/modelOperations.d.ts +380 -0
- package/dist/resources/modelOperations.d.ts.map +1 -0
- package/dist/resources/modelOperations.js +13 -0
- package/dist/resources/modelOperations.js.map +1 -0
- package/dist/resources/mutationOptions.d.ts +67 -0
- package/dist/resources/mutationOptions.d.ts.map +1 -0
- package/dist/resources/mutationOptions.js +10 -0
- package/dist/resources/mutationOptions.js.map +1 -0
- package/dist/resources/where.d.ts +102 -0
- package/dist/resources/where.d.ts.map +1 -0
- package/dist/resources/where.js +116 -0
- package/dist/resources/where.js.map +1 -0
- package/dist/resources/writeOptionsSchema.d.ts +48 -0
- package/dist/resources/writeOptionsSchema.d.ts.map +1 -0
- package/dist/resources/writeOptionsSchema.js +74 -0
- package/dist/resources/writeOptionsSchema.js.map +1 -0
- package/dist/schema/coordination.d.ts +113 -0
- package/dist/schema/coordination.d.ts.map +1 -0
- package/dist/schema/coordination.js +134 -0
- package/dist/schema/coordination.js.map +1 -0
- package/dist/schema/ddl.d.ts +98 -0
- package/dist/schema/ddl.d.ts.map +1 -0
- package/dist/schema/ddl.js +492 -0
- package/dist/schema/ddl.js.map +1 -0
- package/dist/schema/ddlLock.d.ts +36 -0
- package/dist/schema/ddlLock.d.ts.map +1 -0
- package/dist/schema/ddlLock.js +47 -0
- package/dist/schema/ddlLock.js.map +1 -0
- package/dist/schema/diff.d.ts +226 -0
- package/dist/schema/diff.d.ts.map +1 -0
- package/dist/schema/diff.js +290 -0
- package/dist/schema/diff.js.map +1 -0
- package/dist/schema/field.d.ts +121 -0
- package/dist/schema/field.d.ts.map +1 -0
- package/dist/schema/field.js +266 -0
- package/dist/schema/field.js.map +1 -0
- package/dist/schema/fieldRef.d.ts +58 -0
- package/dist/schema/fieldRef.d.ts.map +1 -0
- package/dist/schema/fieldRef.js +26 -0
- package/dist/schema/fieldRef.js.map +1 -0
- package/dist/schema/generate.d.ts +20 -0
- package/dist/schema/generate.d.ts.map +1 -0
- package/dist/schema/generate.js +87 -0
- package/dist/schema/generate.js.map +1 -0
- package/dist/schema/index.d.ts +43 -0
- package/dist/schema/index.d.ts.map +1 -0
- package/dist/schema/index.js +81 -0
- package/dist/schema/index.js.map +1 -0
- package/dist/schema/loadStrategy.d.ts +46 -0
- package/dist/schema/loadStrategy.d.ts.map +1 -0
- package/dist/schema/loadStrategy.js +47 -0
- package/dist/schema/loadStrategy.js.map +1 -0
- package/dist/schema/model.d.ts +380 -0
- package/dist/schema/model.d.ts.map +1 -0
- package/dist/schema/model.js +124 -0
- package/dist/schema/model.js.map +1 -0
- package/dist/schema/openapi.d.ts +59 -0
- package/dist/schema/openapi.d.ts.map +1 -0
- package/dist/schema/openapi.js +508 -0
- package/dist/schema/openapi.js.map +1 -0
- package/dist/schema/queries.d.ts +202 -0
- package/dist/schema/queries.d.ts.map +1 -0
- package/dist/schema/queries.js +144 -0
- package/dist/schema/queries.js.map +1 -0
- package/dist/schema/relation.d.ts +205 -0
- package/dist/schema/relation.d.ts.map +1 -0
- package/dist/schema/relation.js +105 -0
- package/dist/schema/relation.js.map +1 -0
- package/dist/schema/residency.d.ts +30 -0
- package/dist/schema/residency.d.ts.map +1 -0
- package/dist/schema/residency.js +26 -0
- package/dist/schema/residency.js.map +1 -0
- package/dist/schema/roles.d.ts +250 -0
- package/dist/schema/roles.d.ts.map +1 -0
- package/dist/schema/roles.js +231 -0
- package/dist/schema/roles.js.map +1 -0
- package/dist/schema/schema.d.ts +352 -0
- package/dist/schema/schema.d.ts.map +1 -0
- package/dist/schema/schema.js +326 -0
- package/dist/schema/schema.js.map +1 -0
- package/dist/schema/select.d.ts +41 -0
- package/dist/schema/select.d.ts.map +1 -0
- package/dist/schema/select.js +91 -0
- package/dist/schema/select.js.map +1 -0
- package/dist/schema/serialize.d.ts +116 -0
- package/dist/schema/serialize.d.ts.map +1 -0
- package/dist/schema/serialize.js +278 -0
- package/dist/schema/serialize.js.map +1 -0
- package/dist/schema/sugar.d.ts +110 -0
- package/dist/schema/sugar.d.ts.map +1 -0
- package/dist/schema/sugar.js +84 -0
- package/dist/schema/sugar.js.map +1 -0
- package/dist/schema/tenancy.d.ts +140 -0
- package/dist/schema/tenancy.d.ts.map +1 -0
- package/dist/schema/tenancy.js +191 -0
- package/dist/schema/tenancy.js.map +1 -0
- package/dist/server/adapter.d.ts +174 -0
- package/dist/server/adapter.d.ts.map +1 -0
- package/dist/server/adapter.js +19 -0
- package/dist/server/adapter.js.map +1 -0
- package/dist/server/commit.d.ts +108 -0
- package/dist/server/commit.d.ts.map +1 -0
- package/dist/server/commit.js +2 -0
- package/dist/server/commit.js.map +1 -0
- package/dist/server/index.d.ts +15 -0
- package/dist/server/index.d.ts.map +1 -0
- package/dist/server/index.js +3 -0
- package/dist/server/index.js.map +1 -0
- package/dist/server/readConfig.d.ts +81 -0
- package/dist/server/readConfig.d.ts.map +1 -0
- package/dist/server/readConfig.js +9 -0
- package/dist/server/readConfig.js.map +1 -0
- package/dist/server/storageMode.d.ts +24 -0
- package/dist/server/storageMode.d.ts.map +1 -0
- package/dist/server/storageMode.js +18 -0
- package/dist/server/storageMode.js.map +1 -0
- package/dist/source/adapter.d.ts +84 -0
- package/dist/source/adapter.d.ts.map +1 -0
- package/dist/source/adapter.js +25 -0
- package/dist/source/adapter.js.map +1 -0
- package/dist/source/adapters/drizzle.d.ts +49 -0
- package/dist/source/adapters/drizzle.d.ts.map +1 -0
- package/dist/source/adapters/drizzle.js +220 -0
- package/dist/source/adapters/drizzle.js.map +1 -0
- package/dist/source/adapters/kysely.d.ts +43 -0
- package/dist/source/adapters/kysely.d.ts.map +1 -0
- package/dist/source/adapters/kysely.js +206 -0
- package/dist/source/adapters/kysely.js.map +1 -0
- package/dist/source/adapters/kyselyMutationCore.d.ts +77 -0
- package/dist/source/adapters/kyselyMutationCore.d.ts.map +1 -0
- package/dist/source/adapters/kyselyMutationCore.js +126 -0
- package/dist/source/adapters/kyselyMutationCore.js.map +1 -0
- package/dist/source/adapters/memory.d.ts +14 -0
- package/dist/source/adapters/memory.d.ts.map +1 -0
- package/dist/source/adapters/memory.js +131 -0
- package/dist/source/adapters/memory.js.map +1 -0
- package/dist/source/adapters/prisma.d.ts +64 -0
- package/dist/source/adapters/prisma.d.ts.map +1 -0
- package/dist/source/adapters/prisma.js +203 -0
- package/dist/source/adapters/prisma.js.map +1 -0
- package/dist/source/conformance.d.ts +38 -0
- package/dist/source/conformance.d.ts.map +1 -0
- package/dist/source/conformance.js +216 -0
- package/dist/source/conformance.js.map +1 -0
- package/dist/source/connector.d.ts +96 -0
- package/dist/source/connector.d.ts.map +1 -0
- package/dist/source/connector.js +267 -0
- package/dist/source/connector.js.map +1 -0
- package/dist/source/connectorProtocol.d.ts +155 -0
- package/dist/source/connectorProtocol.d.ts.map +1 -0
- package/dist/source/connectorProtocol.js +164 -0
- package/dist/source/connectorProtocol.js.map +1 -0
- package/dist/source/contract.d.ts +196 -0
- package/dist/source/contract.d.ts.map +1 -0
- package/dist/source/contract.js +165 -0
- package/dist/source/contract.js.map +1 -0
- package/dist/source/drizzle.d.ts +2 -0
- package/dist/source/drizzle.d.ts.map +1 -0
- package/dist/source/drizzle.js +2 -0
- package/dist/source/drizzle.js.map +1 -0
- package/dist/source/factory.d.ts +93 -0
- package/dist/source/factory.d.ts.map +1 -0
- package/dist/source/factory.js +287 -0
- package/dist/source/factory.js.map +1 -0
- package/dist/source/idempotency.d.ts +62 -0
- package/dist/source/idempotency.d.ts.map +1 -0
- package/dist/source/idempotency.js +145 -0
- package/dist/source/idempotency.js.map +1 -0
- package/dist/source/index.d.ts +24 -0
- package/dist/source/index.d.ts.map +1 -0
- package/dist/source/index.js +29 -0
- package/dist/source/index.js.map +1 -0
- package/dist/source/kysely.d.ts +3 -0
- package/dist/source/kysely.d.ts.map +1 -0
- package/dist/source/kysely.js +3 -0
- package/dist/source/kysely.js.map +1 -0
- package/dist/source/migrations.d.ts +22 -0
- package/dist/source/migrations.d.ts.map +1 -0
- package/dist/source/migrations.js +104 -0
- package/dist/source/migrations.js.map +1 -0
- package/dist/source/next.d.ts +33 -0
- package/dist/source/next.d.ts.map +1 -0
- package/dist/source/next.js +26 -0
- package/dist/source/next.js.map +1 -0
- package/dist/source/pushQueue.d.ts +135 -0
- package/dist/source/pushQueue.d.ts.map +1 -0
- package/dist/source/pushQueue.js +257 -0
- package/dist/source/pushQueue.js.map +1 -0
- package/dist/source/signing.d.ts +93 -0
- package/dist/source/signing.d.ts.map +1 -0
- package/dist/source/signing.js +163 -0
- package/dist/source/signing.js.map +1 -0
- package/dist/source/types.d.ts +402 -0
- package/dist/source/types.d.ts.map +1 -0
- package/dist/source/types.js +60 -0
- package/dist/source/types.js.map +1 -0
- package/dist/syncLog/contract.d.ts +21 -0
- package/dist/syncLog/contract.d.ts.map +1 -0
- package/dist/syncLog/contract.js +20 -0
- package/dist/syncLog/contract.js.map +1 -0
- package/dist/syncLog/index.d.ts +2 -0
- package/dist/syncLog/index.d.ts.map +1 -0
- package/dist/syncLog/index.js +2 -0
- package/dist/syncLog/index.js.map +1 -0
- package/dist/testing/fixtures/httpResponses.d.ts +74 -0
- package/dist/testing/fixtures/httpResponses.d.ts.map +1 -0
- package/dist/testing/fixtures/httpResponses.js +102 -0
- package/dist/testing/fixtures/httpResponses.js.map +1 -0
- package/dist/transactionLayer.d.ts +110 -0
- package/dist/transactionLayer.d.ts.map +1 -0
- package/dist/transactionLayer.js +25 -0
- package/dist/transactionLayer.js.map +1 -0
- package/dist/transactions/settlement/commitEnvelope.d.ts +144 -0
- package/dist/transactions/settlement/commitEnvelope.d.ts.map +1 -0
- package/dist/transactions/settlement/commitEnvelope.js +162 -0
- package/dist/transactions/settlement/commitEnvelope.js.map +1 -0
- package/dist/transactions/settlement/httpCommitEnvelope.d.ts +54 -0
- package/dist/transactions/settlement/httpCommitEnvelope.d.ts.map +1 -0
- package/dist/transactions/settlement/httpCommitEnvelope.js +208 -0
- package/dist/transactions/settlement/httpCommitEnvelope.js.map +1 -0
- package/dist/transactions/settlement/idempotencyKey.d.ts +11 -0
- package/dist/transactions/settlement/idempotencyKey.d.ts.map +1 -0
- package/dist/transactions/settlement/idempotencyKey.js +10 -0
- package/dist/transactions/settlement/idempotencyKey.js.map +1 -0
- package/dist/transactions/settlement/pendingWrite.d.ts +113 -0
- package/dist/transactions/settlement/pendingWrite.d.ts.map +1 -0
- package/dist/transactions/settlement/pendingWrite.js +21 -0
- package/dist/transactions/settlement/pendingWrite.js.map +1 -0
- package/dist/transport/commitFrames.d.ts +91 -0
- package/dist/transport/commitFrames.d.ts.map +1 -0
- package/dist/transport/commitFrames.js +135 -0
- package/dist/transport/commitFrames.js.map +1 -0
- package/dist/transport/connectionManager.d.ts +216 -0
- package/dist/transport/connectionManager.d.ts.map +1 -0
- package/dist/transport/connectionManager.js +674 -0
- package/dist/transport/connectionManager.js.map +1 -0
- package/dist/transport/credentialLifecycle.d.ts +178 -0
- package/dist/transport/credentialLifecycle.d.ts.map +1 -0
- package/dist/transport/credentialLifecycle.js +324 -0
- package/dist/transport/credentialLifecycle.js.map +1 -0
- package/dist/transport/heartbeat.d.ts +66 -0
- package/dist/transport/heartbeat.d.ts.map +1 -0
- package/dist/transport/heartbeat.js +94 -0
- package/dist/transport/heartbeat.js.map +1 -0
- package/dist/transport/httpClient.d.ts +143 -0
- package/dist/transport/httpClient.d.ts.map +1 -0
- package/dist/transport/httpClient.js +150 -0
- package/dist/transport/httpClient.js.map +1 -0
- package/dist/transport/httpFeed.d.ts +4 -0
- package/dist/transport/httpFeed.d.ts.map +1 -0
- package/dist/transport/httpFeed.js +94 -0
- package/dist/transport/httpFeed.js.map +1 -0
- package/dist/transport/httpOptions.d.ts +34 -0
- package/dist/transport/httpOptions.d.ts.map +1 -0
- package/dist/transport/httpOptions.js +13 -0
- package/dist/transport/httpOptions.js.map +1 -0
- package/dist/transport/httpTransport.d.ts +68 -0
- package/dist/transport/httpTransport.d.ts.map +1 -0
- package/dist/transport/httpTransport.js +1433 -0
- package/dist/transport/httpTransport.js.map +1 -0
- package/dist/transport/networkProbe.d.ts +85 -0
- package/dist/transport/networkProbe.d.ts.map +1 -0
- package/dist/transport/networkProbe.js +208 -0
- package/dist/transport/networkProbe.js.map +1 -0
- package/dist/transport/wsFrameHandlers.d.ts +129 -0
- package/dist/transport/wsFrameHandlers.d.ts.map +1 -0
- package/dist/transport/wsFrameHandlers.js +429 -0
- package/dist/transport/wsFrameHandlers.js.map +1 -0
- package/dist/transport/wsTransport.d.ts +575 -0
- package/dist/transport/wsTransport.d.ts.map +1 -0
- package/dist/transport/wsTransport.js +1024 -0
- package/dist/transport/wsTransport.js.map +1 -0
- package/dist/types/assertExact.d.ts +18 -0
- package/dist/types/assertExact.d.ts.map +1 -0
- package/dist/types/assertExact.js +2 -0
- package/dist/types/assertExact.js.map +1 -0
- package/dist/types/global.d.ts +108 -0
- package/dist/types/global.d.ts.map +1 -0
- package/dist/types/global.js +41 -0
- package/dist/types/global.js.map +1 -0
- package/dist/types/index.d.ts +206 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +57 -0
- package/dist/types/index.js.map +1 -0
- package/dist/types/modelData.d.ts +11 -0
- package/dist/types/modelData.d.ts.map +1 -0
- package/dist/types/modelData.js +10 -0
- package/dist/types/modelData.js.map +1 -0
- package/dist/types/participant.d.ts +21 -0
- package/dist/types/participant.d.ts.map +1 -0
- package/dist/types/participant.js +11 -0
- package/dist/types/participant.js.map +1 -0
- package/dist/types/streams.d.ts +545 -0
- package/dist/types/streams.d.ts.map +1 -0
- package/dist/types/streams.js +12 -0
- package/dist/types/streams.js.map +1 -0
- package/dist/utils/asyncIterator.d.ts +35 -0
- package/dist/utils/asyncIterator.d.ts.map +1 -0
- package/dist/utils/asyncIterator.js +136 -0
- package/dist/utils/asyncIterator.js.map +1 -0
- package/dist/utils/duration.d.ts +51 -0
- package/dist/utils/duration.d.ts.map +1 -0
- package/dist/utils/duration.js +78 -0
- package/dist/utils/duration.js.map +1 -0
- package/dist/utils/json.d.ts +58 -0
- package/dist/utils/json.d.ts.map +1 -0
- package/dist/utils/json.js +277 -0
- package/dist/utils/json.js.map +1 -0
- package/dist/webhooks/events.d.ts +44 -0
- package/dist/webhooks/events.d.ts.map +1 -0
- package/dist/webhooks/events.js +43 -0
- package/dist/webhooks/events.js.map +1 -0
- package/dist/webhooks/index.d.ts +9 -0
- package/dist/webhooks/index.d.ts.map +1 -0
- package/dist/webhooks/index.js +9 -0
- package/dist/webhooks/index.js.map +1 -0
- package/dist/wire/accountResponses.d.ts +463 -0
- package/dist/wire/accountResponses.d.ts.map +1 -0
- package/dist/wire/accountResponses.js +294 -0
- package/dist/wire/accountResponses.js.map +1 -0
- package/dist/wire/auth.d.ts +57 -0
- package/dist/wire/auth.d.ts.map +1 -0
- package/dist/wire/auth.js +71 -0
- package/dist/wire/auth.js.map +1 -0
- package/dist/wire/bootstrapReason.d.ts +10 -0
- package/dist/wire/bootstrapReason.d.ts.map +1 -0
- package/dist/wire/bootstrapReason.js +9 -0
- package/dist/wire/bootstrapReason.js.map +1 -0
- package/dist/wire/claimEvent.d.ts +70 -0
- package/dist/wire/claimEvent.d.ts.map +1 -0
- package/dist/wire/claimEvent.js +74 -0
- package/dist/wire/claimEvent.js.map +1 -0
- package/dist/wire/claims.d.ts +475 -0
- package/dist/wire/claims.d.ts.map +1 -0
- package/dist/wire/claims.js +326 -0
- package/dist/wire/claims.js.map +1 -0
- package/dist/wire/commit.d.ts +604 -0
- package/dist/wire/commit.d.ts.map +1 -0
- package/dist/wire/commit.js +322 -0
- package/dist/wire/commit.js.map +1 -0
- package/dist/wire/delta.d.ts +251 -0
- package/dist/wire/delta.d.ts.map +1 -0
- package/dist/wire/delta.js +148 -0
- package/dist/wire/delta.js.map +1 -0
- package/dist/wire/errorEnvelope.d.ts +73 -0
- package/dist/wire/errorEnvelope.d.ts.map +1 -0
- package/dist/wire/errorEnvelope.js +124 -0
- package/dist/wire/errorEnvelope.js.map +1 -0
- package/dist/wire/feedCursor.d.ts +61 -0
- package/dist/wire/feedCursor.d.ts.map +1 -0
- package/dist/wire/feedCursor.js +83 -0
- package/dist/wire/feedCursor.js.map +1 -0
- package/dist/wire/feedEvent.d.ts +264 -0
- package/dist/wire/feedEvent.d.ts.map +1 -0
- package/dist/wire/feedEvent.js +66 -0
- package/dist/wire/feedEvent.js.map +1 -0
- package/dist/wire/frames.d.ts +195 -0
- package/dist/wire/frames.d.ts.map +1 -0
- package/dist/wire/frames.js +51 -0
- package/dist/wire/frames.js.map +1 -0
- package/dist/wire/inboundFrames.d.ts +490 -0
- package/dist/wire/inboundFrames.d.ts.map +1 -0
- package/dist/wire/inboundFrames.js +117 -0
- package/dist/wire/inboundFrames.js.map +1 -0
- package/dist/wire/index.d.ts +55 -0
- package/dist/wire/index.d.ts.map +1 -0
- package/dist/wire/index.js +84 -0
- package/dist/wire/index.js.map +1 -0
- package/dist/wire/listEnvelope.d.ts +38 -0
- package/dist/wire/listEnvelope.d.ts.map +1 -0
- package/dist/wire/listEnvelope.js +43 -0
- package/dist/wire/listEnvelope.js.map +1 -0
- package/dist/wire/modelMutations.d.ts +32 -0
- package/dist/wire/modelMutations.d.ts.map +1 -0
- package/dist/wire/modelMutations.js +53 -0
- package/dist/wire/modelMutations.js.map +1 -0
- package/dist/wire/modelResponses.d.ts +79 -0
- package/dist/wire/modelResponses.d.ts.map +1 -0
- package/dist/wire/modelResponses.js +44 -0
- package/dist/wire/modelResponses.js.map +1 -0
- package/dist/wire/modelShape.d.ts +79 -0
- package/dist/wire/modelShape.d.ts.map +1 -0
- package/dist/wire/modelShape.js +75 -0
- package/dist/wire/modelShape.js.map +1 -0
- package/dist/wire/protocol.d.ts +39 -0
- package/dist/wire/protocol.d.ts.map +1 -0
- package/dist/wire/protocol.js +39 -0
- package/dist/wire/protocol.js.map +1 -0
- package/dist/wire/protocolVersion.d.ts +74 -0
- package/dist/wire/protocolVersion.d.ts.map +1 -0
- package/dist/wire/protocolVersion.js +84 -0
- package/dist/wire/protocolVersion.js.map +1 -0
- package/package.json +187 -0
- package/src/ablo.ts +139 -0
- package/src/ai-sdk/coordinatedTool.ts +214 -0
- package/src/ai-sdk/index.ts +7 -0
- package/src/auth/apiKey.ts +540 -0
- package/src/auth/bootstrapScope.ts +15 -0
- package/src/auth/browserCredentialSafety.ts +48 -0
- package/src/auth/capability.ts +326 -0
- package/src/auth/capabilityLifecycle.ts +174 -0
- package/src/auth/credentialEndpoint.ts +79 -0
- package/src/auth/credentialEndpointProtocol.ts +51 -0
- package/src/auth/credentialKind.ts +20 -0
- package/src/auth/credentialPolicy.ts +244 -0
- package/src/auth/credentialResult.ts +23 -0
- package/src/auth/credentialSource.ts +99 -0
- package/src/auth/hostedEndpoints.ts +24 -0
- package/src/auth/identity.ts +330 -0
- package/src/auth/index.ts +592 -0
- package/src/auth/schemas.ts +94 -0
- package/src/auth/sessionMint.ts +126 -0
- package/src/auth/token.ts +4 -0
- package/src/batching/index.ts +200 -0
- package/src/coordination/awaitClaimGrant.ts +243 -0
- package/src/coordination/claimHeartbeatLoop.ts +165 -0
- package/src/coordination/claimMeta.ts +56 -0
- package/src/coordination/events.ts +86 -0
- package/src/coordination/index.ts +181 -0
- package/src/coordination/locator.ts +200 -0
- package/src/coordination/schema.ts +1346 -0
- package/src/coordination/targetConflict.ts +85 -0
- package/src/coordination/trace.ts +173 -0
- package/src/docs/catalog.ts +274 -0
- package/src/docs/index.ts +18 -0
- package/src/durableWrites.ts +134 -0
- package/src/environment.ts +132 -0
- package/src/errorCodes.ts +1591 -0
- package/src/errors.ts +918 -0
- package/src/footprint.ts +0 -0
- package/src/headlessClient.ts +161 -0
- package/src/index.ts +52 -0
- package/src/keys/index.ts +254 -0
- package/src/log/syncDeltaRow.ts +119 -0
- package/src/logger.ts +22 -0
- package/src/observability.ts +85 -0
- package/src/policy/types.ts +292 -0
- package/src/resources/functionalUpdate.ts +151 -0
- package/src/resources/httpResources.ts +520 -0
- package/src/resources/modelOperations.ts +444 -0
- package/src/resources/mutationOptions.ts +66 -0
- package/src/resources/where.ts +160 -0
- package/src/resources/writeOptionsSchema.ts +91 -0
- package/src/schema/coordination.ts +161 -0
- package/src/schema/ddl.ts +593 -0
- package/src/schema/ddlLock.ts +53 -0
- package/src/schema/diff.ts +489 -0
- package/src/schema/field.ts +321 -0
- package/src/schema/fieldRef.ts +88 -0
- package/src/schema/generate.ts +95 -0
- package/src/schema/index.ts +278 -0
- package/src/schema/loadStrategy.ts +52 -0
- package/src/schema/model.ts +476 -0
- package/src/schema/openapi.ts +658 -0
- package/src/schema/queries.ts +273 -0
- package/src/schema/relation.ts +291 -0
- package/src/schema/residency.ts +30 -0
- package/src/schema/roles.ts +325 -0
- package/src/schema/schema.ts +825 -0
- package/src/schema/select.ts +115 -0
- package/src/schema/serialize.ts +373 -0
- package/src/schema/sugar.ts +194 -0
- package/src/schema/tenancy.ts +221 -0
- package/src/server/adapter.ts +203 -0
- package/src/server/commit.ts +109 -0
- package/src/server/index.ts +26 -0
- package/src/server/readConfig.ts +82 -0
- package/src/server/storageMode.ts +20 -0
- package/src/source/adapter.ts +85 -0
- package/src/source/adapters/drizzle.ts +291 -0
- package/src/source/adapters/kysely.ts +346 -0
- package/src/source/adapters/kyselyMutationCore.ts +220 -0
- package/src/source/adapters/memory.ts +154 -0
- package/src/source/adapters/prisma.ts +282 -0
- package/src/source/conformance.ts +287 -0
- package/src/source/connector.ts +394 -0
- package/src/source/connectorProtocol.ts +189 -0
- package/src/source/contract.ts +221 -0
- package/src/source/drizzle.ts +1 -0
- package/src/source/factory.ts +444 -0
- package/src/source/idempotency.ts +189 -0
- package/src/source/index.ts +182 -0
- package/src/source/kysely.ts +2 -0
- package/src/source/migrations.ts +109 -0
- package/src/source/next.ts +38 -0
- package/src/source/pushQueue.ts +368 -0
- package/src/source/signing.ts +279 -0
- package/src/source/types.ts +502 -0
- package/src/syncLog/contract.ts +32 -0
- package/src/syncLog/index.ts +1 -0
- package/src/testing/fixtures/httpResponses.ts +155 -0
- package/src/transactionLayer.ts +122 -0
- package/src/transactions/settlement/commitEnvelope.ts +192 -0
- package/src/transactions/settlement/httpCommitEnvelope.ts +250 -0
- package/src/transactions/settlement/idempotencyKey.ts +11 -0
- package/src/transactions/settlement/pendingWrite.ts +24 -0
- package/src/transport/commitFrames.ts +225 -0
- package/src/transport/connectionManager.ts +856 -0
- package/src/transport/credentialLifecycle.ts +389 -0
- package/src/transport/heartbeat.ts +118 -0
- package/src/transport/httpClient.ts +354 -0
- package/src/transport/httpFeed.ts +111 -0
- package/src/transport/httpOptions.ts +41 -0
- package/src/transport/httpTransport.ts +1976 -0
- package/src/transport/networkProbe.ts +249 -0
- package/src/transport/wsFrameHandlers.ts +619 -0
- package/src/transport/wsTransport.ts +1491 -0
- package/src/types/assertExact.ts +17 -0
- package/src/types/global.ts +123 -0
- package/src/types/index.ts +270 -0
- package/src/types/modelData.ts +11 -0
- package/src/types/participant.ts +22 -0
- package/src/types/streams.ts +702 -0
- package/src/utils/asyncIterator.ts +141 -0
- package/src/utils/duration.ts +88 -0
- package/src/utils/json.ts +281 -0
- package/src/webhooks/events.ts +96 -0
- package/src/webhooks/index.ts +12 -0
- package/src/wire/accountResponses.ts +328 -0
- package/src/wire/auth.ts +86 -0
- package/src/wire/bootstrapReason.ts +10 -0
- package/src/wire/claimEvent.ts +85 -0
- package/src/wire/claims.ts +370 -0
- package/src/wire/commit.ts +379 -0
- package/src/wire/delta.ts +173 -0
- package/src/wire/errorEnvelope.ts +133 -0
- package/src/wire/feedCursor.ts +91 -0
- package/src/wire/feedEvent.ts +74 -0
- package/src/wire/frames.ts +77 -0
- package/src/wire/inboundFrames.ts +182 -0
- package/src/wire/index.ts +328 -0
- package/src/wire/listEnvelope.ts +51 -0
- package/src/wire/modelMutations.ts +55 -0
- package/src/wire/modelResponses.ts +48 -0
- package/src/wire/modelShape.ts +83 -0
- package/src/wire/protocol.ts +39 -0
- package/src/wire/protocolVersion.ts +97 -0
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Runtime contracts for retry-safe commits.
|
|
3
|
+
*
|
|
4
|
+
* `commitEnvelopeMemberSchema` is the compact pointer stored on an in-memory
|
|
5
|
+
* transaction. `durableCommitEnvelopeSchema` is the actual outbox record: one
|
|
6
|
+
* atomic IndexedDB value containing the stable request key, exact ordered wire
|
|
7
|
+
* operations, and the source mutations it supersedes.
|
|
8
|
+
*/
|
|
9
|
+
import { z } from 'zod';
|
|
10
|
+
import { readDependencySchema, trackDependencySchema } from '../../coordination/schema.js';
|
|
11
|
+
import { wireCommitOperationSchema } from '../../wire/frames.js';
|
|
12
|
+
import { correlationIdSchema } from '../../wire/commit.js';
|
|
13
|
+
import { idempotencyKeySchema } from './idempotencyKey.js';
|
|
14
|
+
import { snapshotJsonValue } from '../../utils/json.js';
|
|
15
|
+
export const COMMIT_ENVELOPE_VERSION = 1;
|
|
16
|
+
export const COMMIT_ENVELOPE_RECORD_PREFIX = 'commit-envelope:';
|
|
17
|
+
/** One transaction's position in a commit; this is not the envelope itself. */
|
|
18
|
+
export const commitEnvelopeMemberSchema = z
|
|
19
|
+
.strictObject({
|
|
20
|
+
idempotencyKey: idempotencyKeySchema,
|
|
21
|
+
operationIndex: z.number().int().nonnegative(),
|
|
22
|
+
operationCount: z.number().int().positive(),
|
|
23
|
+
sealedAt: z.number().int().nonnegative().optional(),
|
|
24
|
+
sequence: z.number().int().nonnegative().optional(),
|
|
25
|
+
})
|
|
26
|
+
.refine(({ operationIndex, operationCount }) => operationIndex < operationCount, { message: 'operationIndex must be smaller than operationCount' });
|
|
27
|
+
/** One operation stored exactly as the current commit transport sends it. */
|
|
28
|
+
export const durableCommitOperationSchema = wireCommitOperationSchema
|
|
29
|
+
.pick({
|
|
30
|
+
type: true,
|
|
31
|
+
model: true,
|
|
32
|
+
id: true,
|
|
33
|
+
input: true,
|
|
34
|
+
transactionId: true,
|
|
35
|
+
readAt: true,
|
|
36
|
+
onStale: true,
|
|
37
|
+
fenceToken: true,
|
|
38
|
+
})
|
|
39
|
+
.extend({
|
|
40
|
+
model: z.string().min(1),
|
|
41
|
+
id: z.string().min(1),
|
|
42
|
+
input: z.record(z.string(), z.unknown()).optional(),
|
|
43
|
+
transactionId: z.string().min(1).optional(),
|
|
44
|
+
options: z
|
|
45
|
+
.strictObject({
|
|
46
|
+
idempotencyKey: z.string().min(1).max(255).nullable().optional(),
|
|
47
|
+
label: z.string().min(1).max(255).optional(),
|
|
48
|
+
})
|
|
49
|
+
.optional(),
|
|
50
|
+
});
|
|
51
|
+
const durableCommitOptionsSchema = z.strictObject({
|
|
52
|
+
reads: z.array(readDependencySchema).nullable().optional(),
|
|
53
|
+
track: z.array(trackDependencySchema).nullable().optional(),
|
|
54
|
+
});
|
|
55
|
+
export const commitOutboxScopeSchema = z.strictObject({
|
|
56
|
+
organizationId: z.string().min(1),
|
|
57
|
+
participantId: z.string().min(1),
|
|
58
|
+
namespace: z.string().min(1),
|
|
59
|
+
});
|
|
60
|
+
/**
|
|
61
|
+
* One crash-durable logical commit. Keeping every operation in one record makes
|
|
62
|
+
* membership and order atomic: recovery can observe the old record or the new
|
|
63
|
+
* record, never half an envelope.
|
|
64
|
+
*/
|
|
65
|
+
export const durableCommitEnvelopeSchema = z
|
|
66
|
+
.strictObject({
|
|
67
|
+
id: z.string().startsWith(COMMIT_ENVELOPE_RECORD_PREFIX),
|
|
68
|
+
type: z.literal('commit_envelope'),
|
|
69
|
+
storageVersion: z.literal(COMMIT_ENVELOPE_VERSION),
|
|
70
|
+
origin: z.enum(['model_batch', 'atomic_commit']),
|
|
71
|
+
idempotencyKey: idempotencyKeySchema,
|
|
72
|
+
operations: z.array(durableCommitOperationSchema).min(1).max(500),
|
|
73
|
+
// Bookkeeping cardinality is independent of the 500 wire-operation cap:
|
|
74
|
+
// hundreds of same-row offline patches may coalesce into one operation.
|
|
75
|
+
sourceMutationIds: z.array(z.string().min(1)).default([]),
|
|
76
|
+
commitOptions: durableCommitOptionsSchema.default({}),
|
|
77
|
+
scope: commitOutboxScopeSchema.optional(),
|
|
78
|
+
createdAt: z.number().int().nonnegative(),
|
|
79
|
+
sealedAt: z.number().int().nonnegative(),
|
|
80
|
+
/**
|
|
81
|
+
* Monotonic evidence that a connected source accepted this exact request.
|
|
82
|
+
* Its server and customer idempotency keys are permanent, so an accepted
|
|
83
|
+
* envelope remains replayable until the WAL echo confirms it.
|
|
84
|
+
*/
|
|
85
|
+
acceptedAt: z.number().int().nonnegative().optional(),
|
|
86
|
+
/** Opaque server-derived source-batch identity paired with `acceptedAt`. */
|
|
87
|
+
correlationId: correlationIdSchema.optional(),
|
|
88
|
+
/** Monotonic within one client; disambiguates writes sealed in the same ms. */
|
|
89
|
+
sequence: z.number().int().nonnegative().optional(),
|
|
90
|
+
timestamp: z.number().int().nonnegative(),
|
|
91
|
+
})
|
|
92
|
+
.superRefine((envelope, context) => {
|
|
93
|
+
if (envelope.id !== commitEnvelopeRecordId(envelope.idempotencyKey)) {
|
|
94
|
+
context.addIssue({
|
|
95
|
+
code: 'custom',
|
|
96
|
+
path: ['id'],
|
|
97
|
+
message: 'Envelope record id must be derived from its idempotency key',
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
if (new Set(envelope.sourceMutationIds).size !== envelope.sourceMutationIds.length) {
|
|
101
|
+
context.addIssue({
|
|
102
|
+
code: 'custom',
|
|
103
|
+
path: ['sourceMutationIds'],
|
|
104
|
+
message: 'Source mutation ids must be unique',
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
if ((envelope.acceptedAt === undefined) !== (envelope.correlationId === undefined)) {
|
|
108
|
+
context.addIssue({
|
|
109
|
+
code: 'custom',
|
|
110
|
+
path: ['acceptedAt'],
|
|
111
|
+
message: 'Accepted commit envelopes require both acceptedAt and correlationId',
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
if (envelope.acceptedAt !== undefined &&
|
|
115
|
+
envelope.acceptedAt < envelope.sealedAt) {
|
|
116
|
+
context.addIssue({
|
|
117
|
+
code: 'custom',
|
|
118
|
+
path: ['acceptedAt'],
|
|
119
|
+
message: 'Commit envelope cannot be accepted before it is sealed',
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
if (envelope.origin === 'model_batch') {
|
|
123
|
+
const transactionIds = envelope.operations.map((operation) => operation.transactionId);
|
|
124
|
+
if (transactionIds.some((id) => typeof id !== 'string' || id.length === 0)) {
|
|
125
|
+
context.addIssue({
|
|
126
|
+
code: 'custom',
|
|
127
|
+
path: ['operations'],
|
|
128
|
+
message: 'Every model-batch operation must carry a transactionId',
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
else if (new Set(transactionIds).size !== transactionIds.length) {
|
|
132
|
+
context.addIssue({
|
|
133
|
+
code: 'custom',
|
|
134
|
+
path: ['operations'],
|
|
135
|
+
message: 'Model-batch transactionIds must be unique',
|
|
136
|
+
});
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
});
|
|
140
|
+
export function commitEnvelopeRecordId(idempotencyKey) {
|
|
141
|
+
return `${COMMIT_ENVELOPE_RECORD_PREFIX}${idempotencyKey}`;
|
|
142
|
+
}
|
|
143
|
+
/** Constructs validated member metadata when an in-memory batch is formed. */
|
|
144
|
+
export function createCommitEnvelopeMember(value) {
|
|
145
|
+
return commitEnvelopeMemberSchema.parse(value);
|
|
146
|
+
}
|
|
147
|
+
/**
|
|
148
|
+
* Freezes the exact JSON request that will be persisted and sent. The shared
|
|
149
|
+
* snapshot contract makes framework proxies plain and rejects values that
|
|
150
|
+
* would be lost or corrupted by JSON serialization.
|
|
151
|
+
*/
|
|
152
|
+
export function createDurableCommitEnvelope(value) {
|
|
153
|
+
const candidate = {
|
|
154
|
+
...value,
|
|
155
|
+
id: commitEnvelopeRecordId(value.idempotencyKey),
|
|
156
|
+
type: 'commit_envelope',
|
|
157
|
+
storageVersion: COMMIT_ENVELOPE_VERSION,
|
|
158
|
+
timestamp: value.sealedAt,
|
|
159
|
+
};
|
|
160
|
+
return durableCommitEnvelopeSchema.parse(snapshotJsonValue(candidate, '$.commitEnvelope'));
|
|
161
|
+
}
|
|
162
|
+
//# sourceMappingURL=commitEnvelope.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"commitEnvelope.js","sourceRoot":"","sources":["../../../src/transactions/settlement/commitEnvelope.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,oBAAoB,EAAE,qBAAqB,EAAE,MAAM,8BAA8B,CAAC;AAC3F,OAAO,EAAE,yBAAyB,EAAE,MAAM,sBAAsB,CAAC;AACjE,OAAO,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAC3D,OAAO,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAC3D,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAExD,MAAM,CAAC,MAAM,uBAAuB,GAAG,CAAU,CAAC;AAClD,MAAM,CAAC,MAAM,6BAA6B,GAAG,kBAAkB,CAAC;AAEhE,+EAA+E;AAC/E,MAAM,CAAC,MAAM,0BAA0B,GAAG,CAAC;KACxC,YAAY,CAAC;IACZ,cAAc,EAAE,oBAAoB;IACpC,cAAc,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,WAAW,EAAE;IAC9C,cAAc,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,QAAQ,E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CAAC;gBACpB,OAAO,EAAE,2CAA2C;aACrD,CAAC,CAAC;QACL,CAAC;IACH,CAAC;AACH,CAAC,CAAC,CAAC;AAIL,MAAM,UAAU,sBAAsB,CAAC,cAAsB;IAC3D,OAAO,GAAG,6BAA6B,GAAG,cAAc,EAAE,CAAC;AAC7D,CAAC;AAED,8EAA8E;AAC9E,MAAM,UAAU,0BAA0B,CACxC,KAAiD;IAEjD,OAAO,0BAA0B,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;AACjD,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,2BAA2B,CACzC,KAGC;IAED,MAAM,SAAS,GAAG;QAChB,GAAG,KAAK;QACR,EAAE,EAAE,sBAAsB,CAAC,KAAK,CAAC,cAAc,CAAC;QAChD,IAAI,EAAE,iBAA0B;QAChC,cAAc,EAAE,uBAAuB;QACvC,SAAS,EAAE,KAAK,CAAC,QAAQ;KAC1B,CAAC;IACF,OAAO,2BAA2B,CAAC,KAAK,CACtC,iBAAiB,CAAC,SAAS,EAAE,kBAAkB,CAAC,CACjD,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/** Crash-durable exact HTTP request used by the stateless agent client. */
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
export declare const HTTP_COMMIT_ENVELOPE_VERSION: 1;
|
|
4
|
+
export declare const HTTP_COMMIT_ENVELOPE_PREFIX = "http-commit-envelope:";
|
|
5
|
+
/** Stay one hour inside the server's 24-hour idempotency retention window. */
|
|
6
|
+
export declare const HTTP_COMMIT_REPLAY_WINDOW_MS: number;
|
|
7
|
+
/** Snapshot the JSON contract once, then make object-key order canonical. */
|
|
8
|
+
export declare function canonicalHttpCommitBody(value: unknown): string;
|
|
9
|
+
export declare const durableHttpCommitEnvelopeSchema: z.ZodObject<{
|
|
10
|
+
id: z.ZodString;
|
|
11
|
+
type: z.ZodLiteral<"http_commit_envelope">;
|
|
12
|
+
storageVersion: z.ZodLiteral<1>;
|
|
13
|
+
idempotencyKey: z.core.$ZodBranded<z.ZodString, "IdempotencyKey", "out">;
|
|
14
|
+
protocolVersion: z.ZodDefault<z.ZodNumber>;
|
|
15
|
+
request: z.ZodObject<{
|
|
16
|
+
method: z.ZodEnum<{
|
|
17
|
+
DELETE: "DELETE";
|
|
18
|
+
POST: "POST";
|
|
19
|
+
PATCH: "PATCH";
|
|
20
|
+
}>;
|
|
21
|
+
path: z.ZodString;
|
|
22
|
+
body: z.ZodString;
|
|
23
|
+
}, z.core.$strict>;
|
|
24
|
+
scopeNamespace: z.ZodString;
|
|
25
|
+
createdAt: z.ZodNumber;
|
|
26
|
+
sealedAt: z.ZodNumber;
|
|
27
|
+
acceptedAt: z.ZodOptional<z.ZodNumber>;
|
|
28
|
+
correlationId: z.ZodOptional<z.ZodString>;
|
|
29
|
+
sequence: z.ZodOptional<z.ZodNumber>;
|
|
30
|
+
timestamp: z.ZodNumber;
|
|
31
|
+
}, z.core.$strict>;
|
|
32
|
+
export type DurableHttpCommitEnvelope = z.infer<typeof durableHttpCommitEnvelopeSchema>;
|
|
33
|
+
/**
|
|
34
|
+
* The HTTP verbs a durable commit envelope can carry, projected out of the
|
|
35
|
+
* persisted schema above. Callers that build, seal, or dispatch an envelope
|
|
36
|
+
* take this rather than restating the verbs: the envelope is a stored contract,
|
|
37
|
+
* so a verb the schema does not accept must not be constructible.
|
|
38
|
+
*/
|
|
39
|
+
export type DurableHttpCommitMethod = DurableHttpCommitEnvelope['request']['method'];
|
|
40
|
+
export declare function httpCommitEnvelopeRecordId(idempotencyKey: string, scopeNamespace?: string): string;
|
|
41
|
+
export declare function createDurableHttpCommitEnvelope(input: {
|
|
42
|
+
idempotencyKey: string;
|
|
43
|
+
request: {
|
|
44
|
+
method: DurableHttpCommitMethod;
|
|
45
|
+
path: string;
|
|
46
|
+
body: unknown;
|
|
47
|
+
};
|
|
48
|
+
scopeNamespace: string;
|
|
49
|
+
createdAt?: number;
|
|
50
|
+
sealedAt?: number;
|
|
51
|
+
sequence?: number;
|
|
52
|
+
}): DurableHttpCommitEnvelope;
|
|
53
|
+
export declare function isHttpCommitReplayExpired(envelope: Pick<DurableHttpCommitEnvelope, 'sealedAt' | 'acceptedAt'>, now?: number): boolean;
|
|
54
|
+
//# sourceMappingURL=httpCommitEnvelope.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"httpCommitEnvelope.d.ts","sourceRoot":"","sources":["../../../src/transactions/settlement/httpCommitEnvelope.ts"],"names":[],"mappings":"AAAA,2EAA2E;AAE3E,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAOxB,eAAO,MAAM,4BAA4B,EAAG,CAAU,CAAC;AACvD,eAAO,MAAM,2BAA2B,0BAA0B,CAAC;AACnE,8EAA8E;AAC9E,eAAO,MAAM,4BAA4B,QAAsB,CAAC;AA4BhE,6EAA6E;AAC7E,wBAAgB,uBAAuB,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAE9D;AAED,eAAO,MAAM,+BAA+B;;;;;;;;;;;;;;;;;;;;;;kBAuIxC,CAAC;AAEL,MAAM,MAAM,yBAAyB,GAAG,CAAC,CAAC,KAAK,CAC7C,OAAO,+BAA+B,CACvC,CAAC;AAEF;;;;;GAKG;AACH,MAAM,MAAM,uBAAuB,GAAG,yBAAyB,CAAC,SAAS,CAAC,CAAC,QAAQ,CAAC,CAAC;AAErF,wBAAgB,0BAA0B,CACxC,cAAc,EAAE,MAAM,EACtB,cAAc,CAAC,EAAE,MAAM,GACtB,MAAM,CAMR;AAED,wBAAgB,+BAA+B,CAAC,KAAK,EAAE;IACrD,cAAc,EAAE,MAAM,CAAC;IACvB,OAAO,EAAE;QACP,MAAM,EAAE,uBAAuB,CAAC;QAChC,IAAI,EAAE,MAAM,CAAC;QACb,IAAI,EAAE,OAAO,CAAC;KACf,CAAC;IACF,cAAc,EAAE,MAAM,CAAC;IACvB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB,GAAG,yBAAyB,CAsB5B;AAED,wBAAgB,yBAAyB,CACvC,QAAQ,EAAE,IAAI,CAAC,yBAAyB,EAAE,UAAU,GAAG,YAAY,CAAC,EACpE,GAAG,SAAa,GACf,OAAO,CAMT"}
|
|
@@ -0,0 +1,208 @@
|
|
|
1
|
+
/** Crash-durable exact HTTP request used by the stateless agent client. */
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
import { v5 as uuidv5 } from 'uuid';
|
|
4
|
+
import { snapshotJsonValue, stableStringify } from '../../utils/json.js';
|
|
5
|
+
import { correlationIdSchema } from '../../wire/commit.js';
|
|
6
|
+
import { PROTOCOL_VERSION } from '../../wire/protocolVersion.js';
|
|
7
|
+
import { idempotencyKeySchema } from './idempotencyKey.js';
|
|
8
|
+
export const HTTP_COMMIT_ENVELOPE_VERSION = 1;
|
|
9
|
+
export const HTTP_COMMIT_ENVELOPE_PREFIX = 'http-commit-envelope:';
|
|
10
|
+
/** Stay one hour inside the server's 24-hour idempotency retention window. */
|
|
11
|
+
export const HTTP_COMMIT_REPLAY_WINDOW_MS = 23 * 60 * 60 * 1000;
|
|
12
|
+
const HTTP_COMMIT_SCOPE_ID_NAMESPACE = '043e8f73-86fc-5f62-af46-935d68fca729';
|
|
13
|
+
const commitPathSchema = z.literal('/v1/commits');
|
|
14
|
+
const modelCollectionPathSchema = z.string().regex(/^\/v1\/models\/[^/]+$/);
|
|
15
|
+
const modelEntityPathSchema = z.string().regex(/^\/v1\/models\/[^/]+\/[^/]+$/);
|
|
16
|
+
function hasSafeModelPathSegments(path) {
|
|
17
|
+
if (!path.startsWith('/v1/models/'))
|
|
18
|
+
return true;
|
|
19
|
+
try {
|
|
20
|
+
return path
|
|
21
|
+
.slice('/v1/models/'.length)
|
|
22
|
+
.split('/')
|
|
23
|
+
.every((segment) => {
|
|
24
|
+
const decoded = decodeURIComponent(segment);
|
|
25
|
+
return (decoded.length > 0 &&
|
|
26
|
+
decoded !== '.' &&
|
|
27
|
+
decoded !== '..' &&
|
|
28
|
+
!decoded.includes('/') &&
|
|
29
|
+
!decoded.includes('\\'));
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
catch {
|
|
33
|
+
return false;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
/** Snapshot the JSON contract once, then make object-key order canonical. */
|
|
37
|
+
export function canonicalHttpCommitBody(value) {
|
|
38
|
+
return stableStringify(snapshotJsonValue(value, '$.body'));
|
|
39
|
+
}
|
|
40
|
+
export const durableHttpCommitEnvelopeSchema = z
|
|
41
|
+
.strictObject({
|
|
42
|
+
id: z.string().startsWith(HTTP_COMMIT_ENVELOPE_PREFIX),
|
|
43
|
+
type: z.literal('http_commit_envelope'),
|
|
44
|
+
storageVersion: z.literal(HTTP_COMMIT_ENVELOPE_VERSION),
|
|
45
|
+
idempotencyKey: idempotencyKeySchema,
|
|
46
|
+
/**
|
|
47
|
+
* The wire contract used when this exact request was sealed. Entries from
|
|
48
|
+
* before protocol versioning omitted the field and are v1 by definition.
|
|
49
|
+
*/
|
|
50
|
+
protocolVersion: z.number().int().positive().default(1),
|
|
51
|
+
request: z.strictObject({
|
|
52
|
+
method: z.enum(['POST', 'PATCH', 'DELETE']),
|
|
53
|
+
path: z.string().startsWith('/'),
|
|
54
|
+
body: z.string().refine((body) => {
|
|
55
|
+
try {
|
|
56
|
+
JSON.parse(body);
|
|
57
|
+
return true;
|
|
58
|
+
}
|
|
59
|
+
catch {
|
|
60
|
+
return false;
|
|
61
|
+
}
|
|
62
|
+
}, 'HTTP commit body must be valid JSON'),
|
|
63
|
+
}),
|
|
64
|
+
scopeNamespace: z.string().min(1),
|
|
65
|
+
createdAt: z.number().int().nonnegative(),
|
|
66
|
+
sealedAt: z.number().int().nonnegative(),
|
|
67
|
+
/**
|
|
68
|
+
* Monotonic evidence that the server accepted this exact request for a
|
|
69
|
+
* connected source. Such server keys are permanent, so this envelope must
|
|
70
|
+
* remain replayable past the ordinary hosted 24-hour window until its WAL
|
|
71
|
+
* echo confirms.
|
|
72
|
+
*/
|
|
73
|
+
acceptedAt: z.number().int().nonnegative().optional(),
|
|
74
|
+
/** Opaque server-derived source-batch identity paired with `acceptedAt`. */
|
|
75
|
+
correlationId: correlationIdSchema.optional(),
|
|
76
|
+
/** Monotonic within one client; disambiguates writes sealed in the same ms. */
|
|
77
|
+
sequence: z.number().int().nonnegative().optional(),
|
|
78
|
+
timestamp: z.number().int().nonnegative(),
|
|
79
|
+
})
|
|
80
|
+
.superRefine((envelope, context) => {
|
|
81
|
+
const legacyId = httpCommitEnvelopeRecordId(envelope.idempotencyKey);
|
|
82
|
+
const scopedId = httpCommitEnvelopeRecordId(envelope.idempotencyKey, envelope.scopeNamespace);
|
|
83
|
+
if (envelope.id !== legacyId && envelope.id !== scopedId) {
|
|
84
|
+
context.addIssue({
|
|
85
|
+
code: 'custom',
|
|
86
|
+
path: ['id'],
|
|
87
|
+
message: 'HTTP envelope id must be derived from its idempotency key',
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
if (envelope.sealedAt < envelope.createdAt) {
|
|
91
|
+
context.addIssue({
|
|
92
|
+
code: 'custom',
|
|
93
|
+
path: ['sealedAt'],
|
|
94
|
+
message: 'HTTP envelope cannot be sealed before it is created',
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
if ((envelope.acceptedAt === undefined) !== (envelope.correlationId === undefined)) {
|
|
98
|
+
context.addIssue({
|
|
99
|
+
code: 'custom',
|
|
100
|
+
path: ['acceptedAt'],
|
|
101
|
+
message: 'Accepted HTTP envelopes require both acceptedAt and correlationId',
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
if (envelope.acceptedAt !== undefined &&
|
|
105
|
+
envelope.acceptedAt < envelope.sealedAt) {
|
|
106
|
+
context.addIssue({
|
|
107
|
+
code: 'custom',
|
|
108
|
+
path: ['acceptedAt'],
|
|
109
|
+
message: 'HTTP envelope cannot be accepted before it is sealed',
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
const { method, path } = envelope.request;
|
|
113
|
+
const allowedPath = method === 'POST'
|
|
114
|
+
? commitPathSchema.safeParse(path).success ||
|
|
115
|
+
modelCollectionPathSchema.safeParse(path).success
|
|
116
|
+
: modelEntityPathSchema.safeParse(path).success;
|
|
117
|
+
if (!allowedPath || !hasSafeModelPathSegments(path)) {
|
|
118
|
+
context.addIssue({
|
|
119
|
+
code: 'custom',
|
|
120
|
+
path: ['request', 'path'],
|
|
121
|
+
message: 'HTTP outbox records may target only commit or model-mutation routes',
|
|
122
|
+
});
|
|
123
|
+
return;
|
|
124
|
+
}
|
|
125
|
+
let body;
|
|
126
|
+
try {
|
|
127
|
+
body = JSON.parse(envelope.request.body);
|
|
128
|
+
}
|
|
129
|
+
catch {
|
|
130
|
+
return; // The field-level JSON refinement reports this.
|
|
131
|
+
}
|
|
132
|
+
if (typeof body !== 'object' || body === null || Array.isArray(body)) {
|
|
133
|
+
context.addIssue({
|
|
134
|
+
code: 'custom',
|
|
135
|
+
path: ['request', 'body'],
|
|
136
|
+
message: 'HTTP commit body must be a JSON object',
|
|
137
|
+
});
|
|
138
|
+
return;
|
|
139
|
+
}
|
|
140
|
+
const record = body;
|
|
141
|
+
// `envelope.idempotencyKey` is replayed as the `Idempotency-Key` header.
|
|
142
|
+
// Older sealed bodies may also carry `idempotencyKey`/`clientTxId`; accept
|
|
143
|
+
// and replay them byte-for-byte, but current requests do not duplicate the
|
|
144
|
+
// key in JSON.
|
|
145
|
+
if (path === '/v1/commits') {
|
|
146
|
+
if (!Array.isArray(record.operations) || record.operations.length === 0) {
|
|
147
|
+
context.addIssue({
|
|
148
|
+
code: 'custom',
|
|
149
|
+
path: ['request', 'body'],
|
|
150
|
+
message: 'Commit-route body must carry operations',
|
|
151
|
+
});
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
else if (method === 'POST' && typeof record.id !== 'string') {
|
|
155
|
+
context.addIssue({
|
|
156
|
+
code: 'custom',
|
|
157
|
+
path: ['request', 'body', 'id'],
|
|
158
|
+
message: 'Model-create body must carry its entity id',
|
|
159
|
+
});
|
|
160
|
+
}
|
|
161
|
+
else if (method === 'PATCH' &&
|
|
162
|
+
(typeof record.data !== 'object' || record.data === null || Array.isArray(record.data))) {
|
|
163
|
+
context.addIssue({
|
|
164
|
+
code: 'custom',
|
|
165
|
+
path: ['request', 'body', 'data'],
|
|
166
|
+
message: 'Model-update body must carry a JSON object patch',
|
|
167
|
+
});
|
|
168
|
+
}
|
|
169
|
+
});
|
|
170
|
+
export function httpCommitEnvelopeRecordId(idempotencyKey, scopeNamespace) {
|
|
171
|
+
if (!scopeNamespace) {
|
|
172
|
+
return `${HTTP_COMMIT_ENVELOPE_PREFIX}${idempotencyKey}`;
|
|
173
|
+
}
|
|
174
|
+
const scopeId = uuidv5(scopeNamespace, HTTP_COMMIT_SCOPE_ID_NAMESPACE);
|
|
175
|
+
return `${HTTP_COMMIT_ENVELOPE_PREFIX}${scopeId}:${idempotencyKey}`;
|
|
176
|
+
}
|
|
177
|
+
export function createDurableHttpCommitEnvelope(input) {
|
|
178
|
+
const now = Date.now();
|
|
179
|
+
const createdAt = input.createdAt ?? now;
|
|
180
|
+
const sealedAt = input.sealedAt ?? now;
|
|
181
|
+
const body = canonicalHttpCommitBody(input.request.body);
|
|
182
|
+
return durableHttpCommitEnvelopeSchema.parse({
|
|
183
|
+
id: httpCommitEnvelopeRecordId(input.idempotencyKey, input.scopeNamespace),
|
|
184
|
+
type: 'http_commit_envelope',
|
|
185
|
+
storageVersion: HTTP_COMMIT_ENVELOPE_VERSION,
|
|
186
|
+
idempotencyKey: input.idempotencyKey,
|
|
187
|
+
protocolVersion: PROTOCOL_VERSION,
|
|
188
|
+
request: {
|
|
189
|
+
method: input.request.method,
|
|
190
|
+
path: input.request.path,
|
|
191
|
+
body,
|
|
192
|
+
},
|
|
193
|
+
scopeNamespace: input.scopeNamespace,
|
|
194
|
+
createdAt,
|
|
195
|
+
sealedAt,
|
|
196
|
+
...(input.sequence !== undefined ? { sequence: input.sequence } : {}),
|
|
197
|
+
timestamp: sealedAt,
|
|
198
|
+
});
|
|
199
|
+
}
|
|
200
|
+
export function isHttpCommitReplayExpired(envelope, now = Date.now()) {
|
|
201
|
+
// Connected-source mutation-log and customer idempotency keys are
|
|
202
|
+
// permanent. Once acceptance is durable, age can no longer make replay
|
|
203
|
+
// ambiguous; only the matching WAL echo may settle the envelope.
|
|
204
|
+
if (envelope.acceptedAt !== undefined)
|
|
205
|
+
return false;
|
|
206
|
+
return now - envelope.sealedAt >= HTTP_COMMIT_REPLAY_WINDOW_MS;
|
|
207
|
+
}
|
|
208
|
+
//# sourceMappingURL=httpCommitEnvelope.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"httpCommitEnvelope.js","sourceRoot":"","sources":["../../../src/transactions/settlement/httpCommitEnvelope.ts"],"names":[],"mappings":"AAAA,2EAA2E;AAE3E,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,EAAE,IAAI,MAAM,EAAE,MAAM,MAAM,CAAC;AACpC,OAAO,EAAE,iBAAiB,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AACzE,OAAO,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAC3D,OAAO,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AACjE,OAAO,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAE3D,MAAM,CAAC,MAAM,4BAA4B,GAAG,CAAU,CAAC;AACvD,MAAM,CAAC,MAAM,2BAA2B,GAAG,uBAAuB,CAAC;AACnE,8EAA8E;AAC9E,MAAM,CAAC,MAAM,4BAA4B,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC;AAChE,MAAM,8BAA8B,GAAG,sCAAsC,CAAC;AAE9E,MAAM,gBAAgB,GAAG,CAAC,CAAC,OAAO,C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same logical write. This is a persistence invariant, not a second commit
|
|
6
|
+
* protocol.
|
|
7
|
+
*/
|
|
8
|
+
import { z } from 'zod';
|
|
9
|
+
export declare const idempotencyKeySchema: z.core.$ZodBranded<z.ZodString, "IdempotencyKey", "out">;
|
|
10
|
+
export type IdempotencyKey = z.output<typeof idempotencyKeySchema>;
|
|
11
|
+
//# sourceMappingURL=idempotencyKey.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"idempotencyKey.d.ts","sourceRoot":"","sources":["../../../src/transactions/settlement/idempotencyKey.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,eAAO,MAAM,oBAAoB,0DAAuD,CAAC;AACzF,MAAM,MAAM,cAAc,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,oBAAoB,CAAC,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Identity shared by the durable write records.
|
|
3
|
+
*
|
|
4
|
+
* A retry must reuse the same non-empty key so the server can recognize the
|
|
5
|
+
* same logical write. This is a persistence invariant, not a second commit
|
|
6
|
+
* protocol.
|
|
7
|
+
*/
|
|
8
|
+
import { z } from 'zod';
|
|
9
|
+
export const idempotencyKeySchema = z.string().min(1).max(255).brand();
|
|
10
|
+
//# sourceMappingURL=idempotencyKey.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"idempotencyKey.js","sourceRoot":"","sources":["../../../src/transactions/settlement/idempotencyKey.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,KAAK,EAAoB,CAAC"}
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The persisted shape of a write awaiting a definitive outcome.
|
|
3
|
+
*
|
|
4
|
+
* Owns one authoritative union over the two durable commit envelopes — the
|
|
5
|
+
* WebSocket envelope and its HTTP counterpart — so an injected store and the
|
|
6
|
+
* engine that reads back from it agree on exactly one set of records. The
|
|
7
|
+
* envelope schemas in this directory remain authoritative for their own fields;
|
|
8
|
+
* this module only unions them.
|
|
9
|
+
*
|
|
10
|
+
* The port that persists these records is a behavior contract, not a persisted
|
|
11
|
+
* shape, so it lives outside this directory in `src/durableWrites.ts`.
|
|
12
|
+
*/
|
|
13
|
+
import { z } from 'zod';
|
|
14
|
+
/** Every write shape that Ablo may ask an injected store to persist. */
|
|
15
|
+
export declare const pendingWriteSchema: z.ZodUnion<readonly [z.ZodObject<{
|
|
16
|
+
id: z.ZodString;
|
|
17
|
+
type: z.ZodLiteral<"commit_envelope">;
|
|
18
|
+
storageVersion: z.ZodLiteral<1>;
|
|
19
|
+
origin: z.ZodEnum<{
|
|
20
|
+
model_batch: "model_batch";
|
|
21
|
+
atomic_commit: "atomic_commit";
|
|
22
|
+
}>;
|
|
23
|
+
idempotencyKey: z.core.$ZodBranded<z.ZodString, "IdempotencyKey", "out">;
|
|
24
|
+
operations: z.ZodArray<z.ZodObject<{
|
|
25
|
+
type: z.ZodEnum<{
|
|
26
|
+
CREATE: "CREATE";
|
|
27
|
+
UPDATE: "UPDATE";
|
|
28
|
+
DELETE: "DELETE";
|
|
29
|
+
ARCHIVE: "ARCHIVE";
|
|
30
|
+
UNARCHIVE: "UNARCHIVE";
|
|
31
|
+
}>;
|
|
32
|
+
readAt: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
33
|
+
onStale: z.ZodOptional<z.ZodNullable<z.ZodEnum<{
|
|
34
|
+
reject: "reject";
|
|
35
|
+
overwrite: "overwrite";
|
|
36
|
+
notify: "notify";
|
|
37
|
+
}>>>;
|
|
38
|
+
fenceToken: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
39
|
+
model: z.ZodString;
|
|
40
|
+
id: z.ZodString;
|
|
41
|
+
input: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
42
|
+
transactionId: z.ZodOptional<z.ZodString>;
|
|
43
|
+
options: z.ZodOptional<z.ZodObject<{
|
|
44
|
+
idempotencyKey: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
45
|
+
label: z.ZodOptional<z.ZodString>;
|
|
46
|
+
}, z.core.$strict>>;
|
|
47
|
+
}, z.core.$strip>>;
|
|
48
|
+
sourceMutationIds: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
49
|
+
commitOptions: z.ZodDefault<z.ZodObject<{
|
|
50
|
+
reads: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodUnion<readonly [z.ZodObject<{
|
|
51
|
+
model: z.ZodString;
|
|
52
|
+
id: z.ZodString;
|
|
53
|
+
readAt: z.ZodNumber;
|
|
54
|
+
fields: z.ZodOptional<z.ZodReadonly<z.ZodArray<z.ZodString>>>;
|
|
55
|
+
onStale: z.ZodOptional<z.ZodEnum<{
|
|
56
|
+
reject: "reject";
|
|
57
|
+
overwrite: "overwrite";
|
|
58
|
+
notify: "notify";
|
|
59
|
+
}>>;
|
|
60
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
61
|
+
group: z.ZodString;
|
|
62
|
+
readAt: z.ZodNumber;
|
|
63
|
+
onStale: z.ZodOptional<z.ZodEnum<{
|
|
64
|
+
reject: "reject";
|
|
65
|
+
overwrite: "overwrite";
|
|
66
|
+
notify: "notify";
|
|
67
|
+
}>>;
|
|
68
|
+
}, z.core.$strip>]>>>>;
|
|
69
|
+
track: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodUnion<readonly [z.ZodObject<{
|
|
70
|
+
id: z.ZodString;
|
|
71
|
+
model: z.ZodString;
|
|
72
|
+
readAt: z.ZodOptional<z.ZodNumber>;
|
|
73
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
74
|
+
group: z.ZodString;
|
|
75
|
+
readAt: z.ZodOptional<z.ZodNumber>;
|
|
76
|
+
}, z.core.$strip>]>>>>;
|
|
77
|
+
}, z.core.$strict>>;
|
|
78
|
+
scope: z.ZodOptional<z.ZodObject<{
|
|
79
|
+
organizationId: z.ZodString;
|
|
80
|
+
participantId: z.ZodString;
|
|
81
|
+
namespace: z.ZodString;
|
|
82
|
+
}, z.core.$strict>>;
|
|
83
|
+
createdAt: z.ZodNumber;
|
|
84
|
+
sealedAt: z.ZodNumber;
|
|
85
|
+
acceptedAt: z.ZodOptional<z.ZodNumber>;
|
|
86
|
+
correlationId: z.ZodOptional<z.ZodString>;
|
|
87
|
+
sequence: z.ZodOptional<z.ZodNumber>;
|
|
88
|
+
timestamp: z.ZodNumber;
|
|
89
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
90
|
+
id: z.ZodString;
|
|
91
|
+
type: z.ZodLiteral<"http_commit_envelope">;
|
|
92
|
+
storageVersion: z.ZodLiteral<1>;
|
|
93
|
+
idempotencyKey: z.core.$ZodBranded<z.ZodString, "IdempotencyKey", "out">;
|
|
94
|
+
protocolVersion: z.ZodDefault<z.ZodNumber>;
|
|
95
|
+
request: z.ZodObject<{
|
|
96
|
+
method: z.ZodEnum<{
|
|
97
|
+
DELETE: "DELETE";
|
|
98
|
+
POST: "POST";
|
|
99
|
+
PATCH: "PATCH";
|
|
100
|
+
}>;
|
|
101
|
+
path: z.ZodString;
|
|
102
|
+
body: z.ZodString;
|
|
103
|
+
}, z.core.$strict>;
|
|
104
|
+
scopeNamespace: z.ZodString;
|
|
105
|
+
createdAt: z.ZodNumber;
|
|
106
|
+
sealedAt: z.ZodNumber;
|
|
107
|
+
acceptedAt: z.ZodOptional<z.ZodNumber>;
|
|
108
|
+
correlationId: z.ZodOptional<z.ZodString>;
|
|
109
|
+
sequence: z.ZodOptional<z.ZodNumber>;
|
|
110
|
+
timestamp: z.ZodNumber;
|
|
111
|
+
}, z.core.$strict>]>;
|
|
112
|
+
export type PendingWrite = z.infer<typeof pendingWriteSchema>;
|
|
113
|
+
//# sourceMappingURL=pendingWrite.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pendingWrite.d.ts","sourceRoot":"","sources":["../../../src/transactions/settlement/pendingWrite.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAIxB,wEAAwE;AACxE,eAAO,MAAM,kBAAkB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;oBAG7B,CAAC;AAEH,MAAM,MAAM,YAAY,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,kBAAkB,CAAC,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The persisted shape of a write awaiting a definitive outcome.
|
|
3
|
+
*
|
|
4
|
+
* Owns one authoritative union over the two durable commit envelopes — the
|
|
5
|
+
* WebSocket envelope and its HTTP counterpart — so an injected store and the
|
|
6
|
+
* engine that reads back from it agree on exactly one set of records. The
|
|
7
|
+
* envelope schemas in this directory remain authoritative for their own fields;
|
|
8
|
+
* this module only unions them.
|
|
9
|
+
*
|
|
10
|
+
* The port that persists these records is a behavior contract, not a persisted
|
|
11
|
+
* shape, so it lives outside this directory in `src/durableWrites.ts`.
|
|
12
|
+
*/
|
|
13
|
+
import { z } from 'zod';
|
|
14
|
+
import { durableCommitEnvelopeSchema } from './commitEnvelope.js';
|
|
15
|
+
import { durableHttpCommitEnvelopeSchema } from './httpCommitEnvelope.js';
|
|
16
|
+
/** Every write shape that Ablo may ask an injected store to persist. */
|
|
17
|
+
export const pendingWriteSchema = z.union([
|
|
18
|
+
durableCommitEnvelopeSchema,
|
|
19
|
+
durableHttpCommitEnvelopeSchema,
|
|
20
|
+
]);
|
|
21
|
+
//# sourceMappingURL=pendingWrite.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pendingWrite.js","sourceRoot":"","sources":["../../../src/transactions/settlement/pendingWrite.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,2BAA2B,EAAE,MAAM,qBAAqB,CAAC;AAClE,OAAO,EAAE,+BAA+B,EAAE,MAAM,yBAAyB,CAAC;AAE1E,wEAAwE;AACxE,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,CAAC,KAAK,CAAC;IACxC,2BAA2B;IAC3B,+BAA+B;CAChC,CAAC,CAAC"}
|