@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,164 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The wire protocol for the Data Source reverse channel — the frames that travel
|
|
3
|
+
* over the WebSocket a connector opens to Ablo.
|
|
4
|
+
*
|
|
5
|
+
* The load, list, and commit leg of a Data Source normally arrives as an inbound
|
|
6
|
+
* webhook that Ablo posts to your HTTPS endpoint. That needs a public URL, so it
|
|
7
|
+
* cannot reach a handler running on localhost or inside a private network with no
|
|
8
|
+
* inbound path. The reverse channel flips the direction: the connector dials out
|
|
9
|
+
* to Ablo over a WebSocket and serves those same requests back over the open
|
|
10
|
+
* socket. This module defines the frames exchanged on that socket.
|
|
11
|
+
*
|
|
12
|
+
* The trust model does not change. A `request` frame carries the same signature
|
|
13
|
+
* headers (`webhook-id`, `webhook-timestamp`, `webhook-signature`) and the same
|
|
14
|
+
* raw body Ablo would have posted, so the connector verifies it through
|
|
15
|
+
* `verifyAbloSourceRequest` exactly as it would a webhook. Only the transport
|
|
16
|
+
* differs.
|
|
17
|
+
*
|
|
18
|
+
* Frames are validated with Zod as they arrive, the same discipline `contract.ts`
|
|
19
|
+
* applies to change sets: a malformed frame is rejected at the boundary, and both
|
|
20
|
+
* sides infer every wire type from one schema so they cannot silently drift.
|
|
21
|
+
*/
|
|
22
|
+
import { z } from 'zod';
|
|
23
|
+
import { environmentSchema } from '../environment.js';
|
|
24
|
+
import { WS_BEARER_SUBPROTOCOL_PREFIX } from '../auth/credentialSource.js';
|
|
25
|
+
/**
|
|
26
|
+
* The wire-protocol version. It increases on any breaking change to a frame's
|
|
27
|
+
* shape, so a connector and server on mismatched versions fail fast during
|
|
28
|
+
* `register` rather than misparsing a frame later in the stream.
|
|
29
|
+
*/
|
|
30
|
+
export const SOURCE_CONNECTOR_PROTOCOL_VERSION = 1;
|
|
31
|
+
/** The WebSocket path the connector dials, appended to its configured base URL. */
|
|
32
|
+
export const SOURCE_CONNECTOR_WS_PATH = '/v1/source/listen';
|
|
33
|
+
/**
|
|
34
|
+
* The WebSocket subprotocol that identifies a reverse-channel source connector,
|
|
35
|
+
* as opposed to the SDK's sync client, which uses `ablo.sync.v1`. During the
|
|
36
|
+
* handshake the server echoes back only this value and never the subprotocol that
|
|
37
|
+
* carries the credential, keeping the API key out of proxy and load-balancer logs.
|
|
38
|
+
*/
|
|
39
|
+
export const WS_SOURCE_SUBPROTOCOL = 'ablo.source.v1';
|
|
40
|
+
/**
|
|
41
|
+
* Builds the `Sec-WebSocket-Protocol` list a connector offers during the
|
|
42
|
+
* handshake: the source subprotocol followed by the bearer credential, encoded as
|
|
43
|
+
* `ablo.bearer.<apiKey>`. A WebSocket handshake cannot carry an `Authorization`
|
|
44
|
+
* header, so the API key rides as a subprotocol instead — the same mechanism the
|
|
45
|
+
* SDK's sync client uses, which the server reads back with `extractBearer`.
|
|
46
|
+
*/
|
|
47
|
+
export function sourceConnectorSubprotocols(apiKey) {
|
|
48
|
+
return [WS_SOURCE_SUBPROTOCOL, `${WS_BEARER_SUBPROTOCOL_PREFIX}${apiKey}`];
|
|
49
|
+
}
|
|
50
|
+
const headerRecord = z.record(z.string(), z.string());
|
|
51
|
+
/**
|
|
52
|
+
* The first frame the connector sends, right after the socket opens. The server
|
|
53
|
+
* has already authenticated the connection and resolved which source it serves
|
|
54
|
+
* from the API key in the handshake, so this frame only negotiates the protocol
|
|
55
|
+
* version and carries advisory metadata.
|
|
56
|
+
*/
|
|
57
|
+
export const registerFrameSchema = z.object({
|
|
58
|
+
type: z.literal('register'),
|
|
59
|
+
protocolVersion: z.number().int(),
|
|
60
|
+
/**
|
|
61
|
+
* An optional client identifier, such as `@abloatai/ablo@0.12.0`, recorded in
|
|
62
|
+
* the server's logs. It is advisory only and never affects a decision.
|
|
63
|
+
*/
|
|
64
|
+
client: z.string().optional(),
|
|
65
|
+
});
|
|
66
|
+
/**
|
|
67
|
+
* The server's acknowledgement of a successful `register`. It echoes the resolved
|
|
68
|
+
* source identity so the connector can confirm and log which source it is serving.
|
|
69
|
+
*/
|
|
70
|
+
export const readyFrameSchema = z.object({
|
|
71
|
+
type: z.literal('ready'),
|
|
72
|
+
protocolVersion: z.number().int(),
|
|
73
|
+
sourceId: z.string().optional(),
|
|
74
|
+
organizationId: z.string().optional(),
|
|
75
|
+
environment: environmentSchema.optional(),
|
|
76
|
+
});
|
|
77
|
+
/**
|
|
78
|
+
* A single load, list, or commit request the server forwards to the connector.
|
|
79
|
+
* Its `headers` and `body` are byte-for-byte what the inbound webhook path would
|
|
80
|
+
* have sent, so the connector can replay them into a `Request` and let the same
|
|
81
|
+
* handler verify the signature exactly as it would for a webhook.
|
|
82
|
+
*/
|
|
83
|
+
export const requestFrameSchema = z.object({
|
|
84
|
+
type: z.literal('request'),
|
|
85
|
+
/** Correlation id; the matching `response` frame carries the same value. */
|
|
86
|
+
id: z.string().min(1),
|
|
87
|
+
method: z.literal('POST'),
|
|
88
|
+
/** Synthetic absolute URL used only to construct the `Request` object. */
|
|
89
|
+
url: z.string().min(1),
|
|
90
|
+
/** The signed webhook signature headers, plus `Content-Type`. */
|
|
91
|
+
headers: headerRecord,
|
|
92
|
+
/** Raw JSON request body — exactly the bytes that were signed. */
|
|
93
|
+
body: z.string(),
|
|
94
|
+
});
|
|
95
|
+
/**
|
|
96
|
+
* The handler's response to one `request` frame, sent back by the connector. The
|
|
97
|
+
* server matches it to the pending request by `id` and treats its `status` and
|
|
98
|
+
* `body` as though an HTTP response had returned.
|
|
99
|
+
*/
|
|
100
|
+
export const responseFrameSchema = z.object({
|
|
101
|
+
type: z.literal('response'),
|
|
102
|
+
id: z.string().min(1),
|
|
103
|
+
status: z.number().int(),
|
|
104
|
+
headers: headerRecord.optional(),
|
|
105
|
+
/** Raw JSON response body. */
|
|
106
|
+
body: z.string(),
|
|
107
|
+
});
|
|
108
|
+
/**
|
|
109
|
+
* An error either side can send for a failure that is not a normal request
|
|
110
|
+
* result, such as a rejected credential, an unsupported protocol version, or a
|
|
111
|
+
* malformed frame. When `id` is set the error belongs to that pending request and
|
|
112
|
+
* fails it; without an `id` it is a connection-level error.
|
|
113
|
+
*/
|
|
114
|
+
export const errorFrameSchema = z.object({
|
|
115
|
+
type: z.literal('error'),
|
|
116
|
+
id: z.string().min(1).optional(),
|
|
117
|
+
code: z.string().min(1),
|
|
118
|
+
message: z.string(),
|
|
119
|
+
});
|
|
120
|
+
export const connectorFrameSchema = z.discriminatedUnion('type', [
|
|
121
|
+
registerFrameSchema,
|
|
122
|
+
readyFrameSchema,
|
|
123
|
+
requestFrameSchema,
|
|
124
|
+
responseFrameSchema,
|
|
125
|
+
errorFrameSchema,
|
|
126
|
+
]);
|
|
127
|
+
/** Thrown when an incoming frame fails to parse or validate. */
|
|
128
|
+
export class ConnectorProtocolError extends Error {
|
|
129
|
+
code = 'source_connector_protocol_error';
|
|
130
|
+
constructor(message) {
|
|
131
|
+
super(message);
|
|
132
|
+
this.name = 'ConnectorProtocolError';
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
/** Serialize a frame for transmission. */
|
|
136
|
+
export function encodeFrame(frame) {
|
|
137
|
+
return JSON.stringify(frame);
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* Parses and validates one incoming frame. It accepts either the string or the
|
|
141
|
+
* binary payloads a WebSocket `message` event can deliver, and throws
|
|
142
|
+
* {@link ConnectorProtocolError} on any malformed or unrecognized frame so the
|
|
143
|
+
* caller can reject the connection instead of acting on bad data.
|
|
144
|
+
*/
|
|
145
|
+
export function decodeFrame(raw) {
|
|
146
|
+
const text = typeof raw === 'string' ? raw : decodeBinary(raw);
|
|
147
|
+
let parsed;
|
|
148
|
+
try {
|
|
149
|
+
parsed = JSON.parse(text);
|
|
150
|
+
}
|
|
151
|
+
catch {
|
|
152
|
+
throw new ConnectorProtocolError('Frame is not valid JSON');
|
|
153
|
+
}
|
|
154
|
+
const result = connectorFrameSchema.safeParse(parsed);
|
|
155
|
+
if (!result.success) {
|
|
156
|
+
throw new ConnectorProtocolError(`Invalid connector frame: ${result.error.message}`);
|
|
157
|
+
}
|
|
158
|
+
return result.data;
|
|
159
|
+
}
|
|
160
|
+
function decodeBinary(raw) {
|
|
161
|
+
const bytes = raw instanceof Uint8Array ? raw : new Uint8Array(raw);
|
|
162
|
+
return new TextDecoder().decode(bytes);
|
|
163
|
+
}
|
|
164
|
+
//# sourceMappingURL=connectorProtocol.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"connectorProtocol.js","sourceRoot":"","sources":["../../src/source/connectorProtocol.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AACtD,OAAO,EAAE,4BAA4B,EAAE,MAAM,6BAA6B,CAAC;AAE3E;;;;GAIG;AACH,MAAM,CAAC,MAAM,iCAAiC,GAAG,CAAC,CAAC;AAEnD,mFAAmF;AACnF,MAAM,CAAC,MAAM,wBAAwB,GAAG,mBAAmB,CAAC;AAE5D;;;;;GAKG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAG,gBAAgB,CAAC;AAEtD;;;;;;GAMG;AACH,MAAM,UAAU,2BAA2B,CAAC,MAAc;IACxD,OAAO,CAAC,qBAAqB,EAAE,GAAG,4BAA4B,GAAG,MAAM,EAAE,CAAC,CAAC;AAC7E,CAAC;AAED,MAAM,YAAY,GAAG,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,MAAM,EAAE,CAA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AAO,GAAG,KAAK,QAAQ,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,YAAY,CAAC,GAAG,CAAC,CAAC;IAC/D,IAAI,MAAe,CAAC;IACpB,IAAI,CAAC;QACH,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IAC5B,CAAC;IAAC,MAAM,CAAC;QACP,MAAM,IAAI,sBAAsB,CAAC,yBAAyB,CAAC,CAAC;IAC9D,CAAC;IACD,MAAM,MAAM,GAAG,oBAAoB,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;IACtD,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;QACpB,MAAM,IAAI,sBAAsB,CAC9B,4BAA4B,MAAM,CAAC,KAAK,CAAC,OAAO,EAAE,CACnD,CAAC;IACJ,CAAC;IACD,OAAO,MAAM,CAAC,IAAI,CAAC;AACrB,CAAC;AAED,SAAS,YAAY,CAAC,GAA6B;IACjD,MAAM,KAAK,GAAG,GAAG,YAAY,UAAU,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,UAAU,CAAC,GAAG,CAAC,CAAC;IACpE,OAAO,IAAI,WAAW,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;AACzC,CAAC"}
|
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Defines the data an ORM adapter exchanges with Ablo, expressed as Zod schemas
|
|
3
|
+
* rather than plain interfaces so every value is validated where it crosses the
|
|
4
|
+
* boundary. A malformed operation or outbox row is rejected at the edge instead of
|
|
5
|
+
* failing deep inside a transaction, and each TypeScript type is inferred from the
|
|
6
|
+
* one schema that validates it.
|
|
7
|
+
*
|
|
8
|
+
* These schemas describe the adapter's own contract: the change set it commits,
|
|
9
|
+
* the outbox row it stores, and the table migrations it ships. The operation
|
|
10
|
+
* vocabulary is not restated here — `operationSchema` is projected from the
|
|
11
|
+
* core's `commitOperationSchema`, so an action or field added to the commit
|
|
12
|
+
* contract reaches a data source by construction. The assertion at the end of
|
|
13
|
+
* this file then pins the published `SourceOperation` interface to that
|
|
14
|
+
* projection, which is what keeps the interface tied to the core rather than
|
|
15
|
+
* merely tied to a second local copy of it.
|
|
16
|
+
*/
|
|
17
|
+
import { z } from 'zod';
|
|
18
|
+
/**
|
|
19
|
+
* Served, not mirrored. The commit vocabulary is declared once in the core; a
|
|
20
|
+
* data source speaks the same five actions, so it re-exports them rather than
|
|
21
|
+
* listing them again under a second name.
|
|
22
|
+
*/
|
|
23
|
+
export declare const operationTypeSchema: z.ZodEnum<{
|
|
24
|
+
CREATE: "CREATE";
|
|
25
|
+
UPDATE: "UPDATE";
|
|
26
|
+
DELETE: "DELETE";
|
|
27
|
+
ARCHIVE: "ARCHIVE";
|
|
28
|
+
UNARCHIVE: "UNARCHIVE";
|
|
29
|
+
}>;
|
|
30
|
+
export type OperationType = z.infer<typeof operationTypeSchema>;
|
|
31
|
+
/**
|
|
32
|
+
* A single operation within a change set, and the runtime validator for it.
|
|
33
|
+
*
|
|
34
|
+
* The field set is projected from `commitOperationSchema` — an operation
|
|
35
|
+
* reaching a data source is a commit operation minus the two fields the core
|
|
36
|
+
* settles internally (`bypass`, `fenceToken`). The two `min(1)` overrides are
|
|
37
|
+
* deliberate and local: this is a customer-implemented boundary, so an empty
|
|
38
|
+
* model name or row id is rejected here rather than forwarded. Stating them as
|
|
39
|
+
* an extension keeps the tightening visible as a choice instead of hiding it
|
|
40
|
+
* inside a second copy of the shape.
|
|
41
|
+
*/
|
|
42
|
+
export declare const operationSchema: z.ZodObject<{
|
|
43
|
+
type: z.ZodEnum<{
|
|
44
|
+
CREATE: "CREATE";
|
|
45
|
+
UPDATE: "UPDATE";
|
|
46
|
+
DELETE: "DELETE";
|
|
47
|
+
ARCHIVE: "ARCHIVE";
|
|
48
|
+
UNARCHIVE: "UNARCHIVE";
|
|
49
|
+
}>;
|
|
50
|
+
readAt: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
51
|
+
onStale: z.ZodOptional<z.ZodNullable<z.ZodEnum<{
|
|
52
|
+
reject: "reject";
|
|
53
|
+
overwrite: "overwrite";
|
|
54
|
+
notify: "notify";
|
|
55
|
+
}>>>;
|
|
56
|
+
transactionId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
57
|
+
model: z.ZodString;
|
|
58
|
+
id: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
59
|
+
input: z.ZodOptional<z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
|
|
60
|
+
}, z.core.$strip>;
|
|
61
|
+
export type Operation = z.infer<typeof operationSchema>;
|
|
62
|
+
/** The supported customer-transaction echo mechanism. */
|
|
63
|
+
export declare const sourceCommitEchoSchema: z.ZodObject<{
|
|
64
|
+
kind: z.ZodLiteral<"postgres-wal">;
|
|
65
|
+
payload: z.ZodString;
|
|
66
|
+
}, z.core.$strip>;
|
|
67
|
+
export declare const sourceCommitEchoOperationSchema: z.ZodObject<{
|
|
68
|
+
model: z.ZodString;
|
|
69
|
+
id: z.ZodString;
|
|
70
|
+
action: z.ZodEnum<{
|
|
71
|
+
I: "I";
|
|
72
|
+
U: "U";
|
|
73
|
+
D: "D";
|
|
74
|
+
}>;
|
|
75
|
+
transactionId: z.ZodString;
|
|
76
|
+
}, z.core.$strict>;
|
|
77
|
+
export declare const sourceCommitEchoMarkerSchema: z.ZodObject<{
|
|
78
|
+
version: z.ZodLiteral<1>;
|
|
79
|
+
correlationId: z.ZodString;
|
|
80
|
+
operations: z.ZodReadonly<z.ZodArray<z.ZodObject<{
|
|
81
|
+
model: z.ZodString;
|
|
82
|
+
id: z.ZodString;
|
|
83
|
+
action: z.ZodEnum<{
|
|
84
|
+
I: "I";
|
|
85
|
+
U: "U";
|
|
86
|
+
D: "D";
|
|
87
|
+
}>;
|
|
88
|
+
transactionId: z.ZodString;
|
|
89
|
+
}, z.core.$strict>>>;
|
|
90
|
+
}, z.core.$strict>;
|
|
91
|
+
export type SourceCommitEchoMarkerWire = z.infer<typeof sourceCommitEchoMarkerSchema>;
|
|
92
|
+
/**
|
|
93
|
+
* The unit a mutation wrapper commits atomically. `correlationId` is derived by
|
|
94
|
+
* Ablo from the authenticated plane, participant, and public idempotency key; it
|
|
95
|
+
* is the customer-ledger identity. It is intentionally not a raw caller-authored
|
|
96
|
+
* `clientTxId` or an operation transaction id.
|
|
97
|
+
*/
|
|
98
|
+
export declare const changeSetSchema: z.ZodObject<{
|
|
99
|
+
operations: z.ZodArray<z.ZodObject<{
|
|
100
|
+
type: z.ZodEnum<{
|
|
101
|
+
CREATE: "CREATE";
|
|
102
|
+
UPDATE: "UPDATE";
|
|
103
|
+
DELETE: "DELETE";
|
|
104
|
+
ARCHIVE: "ARCHIVE";
|
|
105
|
+
UNARCHIVE: "UNARCHIVE";
|
|
106
|
+
}>;
|
|
107
|
+
readAt: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
108
|
+
onStale: z.ZodOptional<z.ZodNullable<z.ZodEnum<{
|
|
109
|
+
reject: "reject";
|
|
110
|
+
overwrite: "overwrite";
|
|
111
|
+
notify: "notify";
|
|
112
|
+
}>>>;
|
|
113
|
+
transactionId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
114
|
+
model: z.ZodString;
|
|
115
|
+
id: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
116
|
+
input: z.ZodOptional<z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
|
|
117
|
+
}, z.core.$strip>>;
|
|
118
|
+
correlationId: z.ZodString;
|
|
119
|
+
intentHash: z.ZodOptional<z.ZodString>;
|
|
120
|
+
echo: z.ZodOptional<z.ZodObject<{
|
|
121
|
+
kind: z.ZodLiteral<"postgres-wal">;
|
|
122
|
+
payload: z.ZodString;
|
|
123
|
+
}, z.core.$strip>>;
|
|
124
|
+
}, z.core.$strip>;
|
|
125
|
+
export type ChangeSet = z.infer<typeof changeSetSchema>;
|
|
126
|
+
/**
|
|
127
|
+
* A row in the adapter's `ablo_outbox` table. The adapter writes it in the same
|
|
128
|
+
* transaction as the underlying row change — the transactional-outbox pattern — so
|
|
129
|
+
* a change and its event commit together or not at all. The `events()` feed later
|
|
130
|
+
* reads these rows back and hands them to Ablo, and `cursor` is the monotonic
|
|
131
|
+
* ordering key Ablo round-trips to resume where it left off.
|
|
132
|
+
*/
|
|
133
|
+
export declare const outboxEventSchema: z.ZodObject<{
|
|
134
|
+
id: z.ZodString;
|
|
135
|
+
model: z.ZodString;
|
|
136
|
+
entityId: z.ZodString;
|
|
137
|
+
type: z.ZodEnum<{
|
|
138
|
+
CREATE: "CREATE";
|
|
139
|
+
UPDATE: "UPDATE";
|
|
140
|
+
DELETE: "DELETE";
|
|
141
|
+
ARCHIVE: "ARCHIVE";
|
|
142
|
+
UNARCHIVE: "UNARCHIVE";
|
|
143
|
+
}>;
|
|
144
|
+
data: z.ZodOptional<z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
|
|
145
|
+
organizationId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
146
|
+
clientTxId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
147
|
+
correlationId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
148
|
+
transactionId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
149
|
+
occurredAt: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
150
|
+
cursor: z.ZodString;
|
|
151
|
+
}, z.core.$strip>;
|
|
152
|
+
export type OutboxEvent = z.infer<typeof outboxEventSchema>;
|
|
153
|
+
/** A page of outbox events returned by `events()`. */
|
|
154
|
+
export declare const eventsPageSchema: z.ZodObject<{
|
|
155
|
+
events: z.ZodArray<z.ZodObject<{
|
|
156
|
+
id: z.ZodString;
|
|
157
|
+
model: z.ZodString;
|
|
158
|
+
entityId: z.ZodString;
|
|
159
|
+
type: z.ZodEnum<{
|
|
160
|
+
CREATE: "CREATE";
|
|
161
|
+
UPDATE: "UPDATE";
|
|
162
|
+
DELETE: "DELETE";
|
|
163
|
+
ARCHIVE: "ARCHIVE";
|
|
164
|
+
UNARCHIVE: "UNARCHIVE";
|
|
165
|
+
}>;
|
|
166
|
+
data: z.ZodOptional<z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
|
|
167
|
+
organizationId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
168
|
+
clientTxId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
169
|
+
correlationId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
170
|
+
transactionId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
171
|
+
occurredAt: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
172
|
+
cursor: z.ZodString;
|
|
173
|
+
}, z.core.$strip>>;
|
|
174
|
+
nextCursor: z.ZodNullable<z.ZodString>;
|
|
175
|
+
}, z.core.$strip>;
|
|
176
|
+
export type EventsPage = z.infer<typeof eventsPageSchema>;
|
|
177
|
+
/**
|
|
178
|
+
* A table-creation migration an adapter ships, so you never hand-write the
|
|
179
|
+
* `ablo_idempotency` and `ablo_outbox` tables yourself. An adapter returns these
|
|
180
|
+
* from its `migrations()` method.
|
|
181
|
+
*/
|
|
182
|
+
export declare const migrationSchema: z.ZodObject<{
|
|
183
|
+
name: z.ZodString;
|
|
184
|
+
up: z.ZodString;
|
|
185
|
+
}, z.core.$strip>;
|
|
186
|
+
export type Migration = z.infer<typeof migrationSchema>;
|
|
187
|
+
/** Describes what an adapter's backend supports, so callers check a capability rather than infer it from behavior. */
|
|
188
|
+
export declare const adapterCapabilitiesSchema: z.ZodObject<{
|
|
189
|
+
transactions: z.ZodBoolean;
|
|
190
|
+
propose: z.ZodBoolean;
|
|
191
|
+
schemaIntrospection: z.ZodBoolean;
|
|
192
|
+
postgresWalEcho: z.ZodOptional<z.ZodBoolean>;
|
|
193
|
+
outboxEvents: z.ZodBoolean;
|
|
194
|
+
}, z.core.$strip>;
|
|
195
|
+
export type AdapterCapabilities = z.infer<typeof adapterCapabilitiesSchema>;
|
|
196
|
+
//# sourceMappingURL=contract.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"contract.d.ts","sourceRoot":"","sources":["../../src/source/contract.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAiBxB;;;;GAIG;AACH,eAAO,MAAM,mBAAmB;;;;;;EAA4B,CAAC;AAC7D,MAAM,MAAM,aAAa,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,mBAAmB,CAAC,CAAC;AAEhE;;;;;;;;;;GAUG;AACH,eAAO,MAAM,eAAe;;;;;;;;;;;;;;;;;;iBAMxB,CAAC;AACL,MAAM,MAAM,SAAS,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,eAAe,CAAC,CAAC;AAExD,yDAAyD;AACzD,eAAO,MAAM,sBAAsB;;;iBASjC,CAAC;AAEH,eAAO,MAAM,+BAA+B;;;;;;;;;kBAK1C,CAAC;AAEH,eAAO,MAAM,4BAA4B;;;;;;;;;;;;;kBAsBrC,CAAC;AACL,MAAM,MAAM,0BAA0B,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,4BAA4B,CAAC,CAAC;AAEtF;;;;;GAKG;AACH,eAAO,MAAM,eAAe;;;;;;;;;;;;;;;;;;;;;;;;;;iBAK1B,CAAC;AACH,MAAM,MAAM,SAAS,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,eAAe,CAAC,CAAC;AAExD;;;;;;GAMG;AACH,eAAO,MAAM,iBAAiB;;;;;;;;;;;;;;;;;;iBAqB5B,CAAC;AACH,MAAM,MAAM,WAAW,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,iBAAiB,CAAC,CAAC;AAE5D,sDAAsD;AACtD,eAAO,MAAM,gBAAgB;;;;;;;;;;;;;;;;;;;;;iBAG3B,CAAC;AACH,MAAM,MAAM,UAAU,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,gBAAgB,CAAC,CAAC;AAE1D;;;;GAIG;AACH,eAAO,MAAM,eAAe;;;iBAK1B,CAAC;AACH,MAAM,MAAM,SAAS,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,eAAe,CAAC,CAAC;AAExD,sHAAsH;AACtH,eAAO,MAAM,yBAAyB;;;;;;iBAWpC,CAAC;AACH,MAAM,MAAM,mBAAmB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,yBAAyB,CAAC,CAAC"}
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Defines the data an ORM adapter exchanges with Ablo, expressed as Zod schemas
|
|
3
|
+
* rather than plain interfaces so every value is validated where it crosses the
|
|
4
|
+
* boundary. A malformed operation or outbox row is rejected at the edge instead of
|
|
5
|
+
* failing deep inside a transaction, and each TypeScript type is inferred from the
|
|
6
|
+
* one schema that validates it.
|
|
7
|
+
*
|
|
8
|
+
* These schemas describe the adapter's own contract: the change set it commits,
|
|
9
|
+
* the outbox row it stores, and the table migrations it ships. The operation
|
|
10
|
+
* vocabulary is not restated here — `operationSchema` is projected from the
|
|
11
|
+
* core's `commitOperationSchema`, so an action or field added to the commit
|
|
12
|
+
* contract reaches a data source by construction. The assertion at the end of
|
|
13
|
+
* this file then pins the published `SourceOperation` interface to that
|
|
14
|
+
* projection, which is what keeps the interface tied to the core rather than
|
|
15
|
+
* merely tied to a second local copy of it.
|
|
16
|
+
*/
|
|
17
|
+
import { z } from 'zod';
|
|
18
|
+
import { correlationIdSchema } from '../wire/commit.js';
|
|
19
|
+
import { commitOperationSchema, commitOperationTypeSchema, } from '../coordination/schema.js';
|
|
20
|
+
import { ABLO_SOURCE_CLIENT_TX_ID_MAX_LENGTH, ABLO_SOURCE_ECHO_MAX_OPERATIONS, ABLO_SOURCE_ECHO_MAX_PAYLOAD_BYTES, } from './types.js';
|
|
21
|
+
const jsonObject = z.record(z.string(), z.unknown());
|
|
22
|
+
/**
|
|
23
|
+
* Served, not mirrored. The commit vocabulary is declared once in the core; a
|
|
24
|
+
* data source speaks the same five actions, so it re-exports them rather than
|
|
25
|
+
* listing them again under a second name.
|
|
26
|
+
*/
|
|
27
|
+
export const operationTypeSchema = commitOperationTypeSchema;
|
|
28
|
+
/**
|
|
29
|
+
* A single operation within a change set, and the runtime validator for it.
|
|
30
|
+
*
|
|
31
|
+
* The field set is projected from `commitOperationSchema` — an operation
|
|
32
|
+
* reaching a data source is a commit operation minus the two fields the core
|
|
33
|
+
* settles internally (`bypass`, `fenceToken`). The two `min(1)` overrides are
|
|
34
|
+
* deliberate and local: this is a customer-implemented boundary, so an empty
|
|
35
|
+
* model name or row id is rejected here rather than forwarded. Stating them as
|
|
36
|
+
* an extension keeps the tightening visible as a choice instead of hiding it
|
|
37
|
+
* inside a second copy of the shape.
|
|
38
|
+
*/
|
|
39
|
+
export const operationSchema = commitOperationSchema
|
|
40
|
+
.omit({ bypass: true, fenceToken: true })
|
|
41
|
+
.extend({
|
|
42
|
+
model: z.string().min(1),
|
|
43
|
+
id: z.string().min(1).nullish(),
|
|
44
|
+
input: jsonObject.nullish(),
|
|
45
|
+
});
|
|
46
|
+
/** The supported customer-transaction echo mechanism. */
|
|
47
|
+
export const sourceCommitEchoSchema = z.object({
|
|
48
|
+
kind: z.literal('postgres-wal'),
|
|
49
|
+
payload: z
|
|
50
|
+
.string()
|
|
51
|
+
.min(1)
|
|
52
|
+
.refine((value) => new TextEncoder().encode(value).byteLength <= ABLO_SOURCE_ECHO_MAX_PAYLOAD_BYTES, `WAL echo payload exceeds ${ABLO_SOURCE_ECHO_MAX_PAYLOAD_BYTES} UTF-8 bytes`),
|
|
53
|
+
});
|
|
54
|
+
export const sourceCommitEchoOperationSchema = z.strictObject({
|
|
55
|
+
model: z.string().min(1),
|
|
56
|
+
id: z.string().min(1),
|
|
57
|
+
action: z.enum(['I', 'U', 'D']),
|
|
58
|
+
transactionId: z.string().min(1).max(ABLO_SOURCE_CLIENT_TX_ID_MAX_LENGTH),
|
|
59
|
+
});
|
|
60
|
+
export const sourceCommitEchoMarkerSchema = z
|
|
61
|
+
.strictObject({
|
|
62
|
+
version: z.literal(1),
|
|
63
|
+
correlationId: correlationIdSchema,
|
|
64
|
+
operations: z
|
|
65
|
+
.array(sourceCommitEchoOperationSchema)
|
|
66
|
+
.min(1)
|
|
67
|
+
.max(ABLO_SOURCE_ECHO_MAX_OPERATIONS)
|
|
68
|
+
.readonly(),
|
|
69
|
+
})
|
|
70
|
+
.superRefine(({ operations }, ctx) => {
|
|
71
|
+
const seen = new Set();
|
|
72
|
+
for (const [index, operation] of operations.entries()) {
|
|
73
|
+
if (seen.has(operation.transactionId)) {
|
|
74
|
+
ctx.addIssue({
|
|
75
|
+
code: 'custom',
|
|
76
|
+
path: ['operations', index, 'transactionId'],
|
|
77
|
+
message: 'WAL echo operation transactionIds must be unique',
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
seen.add(operation.transactionId);
|
|
81
|
+
}
|
|
82
|
+
});
|
|
83
|
+
/**
|
|
84
|
+
* The unit a mutation wrapper commits atomically. `correlationId` is derived by
|
|
85
|
+
* Ablo from the authenticated plane, participant, and public idempotency key; it
|
|
86
|
+
* is the customer-ledger identity. It is intentionally not a raw caller-authored
|
|
87
|
+
* `clientTxId` or an operation transaction id.
|
|
88
|
+
*/
|
|
89
|
+
export const changeSetSchema = z.object({
|
|
90
|
+
operations: z.array(operationSchema).min(1),
|
|
91
|
+
correlationId: correlationIdSchema,
|
|
92
|
+
intentHash: z.string().regex(/^[a-f0-9]{64}$/).optional(),
|
|
93
|
+
echo: sourceCommitEchoSchema.optional(),
|
|
94
|
+
});
|
|
95
|
+
/**
|
|
96
|
+
* A row in the adapter's `ablo_outbox` table. The adapter writes it in the same
|
|
97
|
+
* transaction as the underlying row change — the transactional-outbox pattern — so
|
|
98
|
+
* a change and its event commit together or not at all. The `events()` feed later
|
|
99
|
+
* reads these rows back and hands them to Ablo, and `cursor` is the monotonic
|
|
100
|
+
* ordering key Ablo round-trips to resume where it left off.
|
|
101
|
+
*/
|
|
102
|
+
export const outboxEventSchema = z.object({
|
|
103
|
+
/** Stable, globally-unique id — Ablo's replay-protection key. */
|
|
104
|
+
id: z.string().min(1),
|
|
105
|
+
model: z.string().min(1),
|
|
106
|
+
entityId: z.string().min(1),
|
|
107
|
+
type: operationTypeSchema,
|
|
108
|
+
data: jsonObject.nullish(),
|
|
109
|
+
organizationId: z.string().nullish(),
|
|
110
|
+
/** Legacy source transaction id. Never use this field to settle a queued commit. */
|
|
111
|
+
clientTxId: z.string().nullish(),
|
|
112
|
+
/** Scoped server-authored identity that correlates this event to a queued commit. */
|
|
113
|
+
correlationId: correlationIdSchema.nullish(),
|
|
114
|
+
/** Stable identity of this operation within the correlated source commit. */
|
|
115
|
+
transactionId: z
|
|
116
|
+
.string()
|
|
117
|
+
.min(1)
|
|
118
|
+
.max(ABLO_SOURCE_CLIENT_TX_ID_MAX_LENGTH)
|
|
119
|
+
.nullish(),
|
|
120
|
+
occurredAt: z.number().nullish(),
|
|
121
|
+
/** Monotonic ordering key (bigint as string). `events()` pages by `cursor > ?`. */
|
|
122
|
+
cursor: z.string().min(1),
|
|
123
|
+
});
|
|
124
|
+
/** A page of outbox events returned by `events()`. */
|
|
125
|
+
export const eventsPageSchema = z.object({
|
|
126
|
+
events: z.array(outboxEventSchema),
|
|
127
|
+
nextCursor: z.string().nullable(),
|
|
128
|
+
});
|
|
129
|
+
/**
|
|
130
|
+
* A table-creation migration an adapter ships, so you never hand-write the
|
|
131
|
+
* `ablo_idempotency` and `ablo_outbox` tables yourself. An adapter returns these
|
|
132
|
+
* from its `migrations()` method.
|
|
133
|
+
*/
|
|
134
|
+
export const migrationSchema = z.object({
|
|
135
|
+
/** Stable name, used as the migration filename + applied-ledger key. */
|
|
136
|
+
name: z.string().min(1),
|
|
137
|
+
/** The forward SQL. */
|
|
138
|
+
up: z.string().min(1),
|
|
139
|
+
});
|
|
140
|
+
/** Describes what an adapter's backend supports, so callers check a capability rather than infer it from behavior. */
|
|
141
|
+
export const adapterCapabilitiesSchema = z.object({
|
|
142
|
+
/** `commit` is atomic across all operations in the change set. */
|
|
143
|
+
transactions: z.boolean(),
|
|
144
|
+
/** A dry-run `propose` is available; when false, proposing a change happens before the adapter is called. */
|
|
145
|
+
propose: z.boolean(),
|
|
146
|
+
/** The backend can be introspected for its schema. */
|
|
147
|
+
schemaIntrospection: z.boolean(),
|
|
148
|
+
/** The adapter can atomically emit the requested Postgres WAL marker. */
|
|
149
|
+
postgresWalEcho: z.boolean().optional(),
|
|
150
|
+
/** The wrapper atomically writes and serves an endpoint transactional outbox. */
|
|
151
|
+
outboxEvents: z.boolean(),
|
|
152
|
+
});
|
|
153
|
+
const _operationContractInSync = [
|
|
154
|
+
true,
|
|
155
|
+
true,
|
|
156
|
+
];
|
|
157
|
+
void _operationContractInSync;
|
|
158
|
+
const _echoContractInSync = [
|
|
159
|
+
true,
|
|
160
|
+
true,
|
|
161
|
+
];
|
|
162
|
+
void _echoContractInSync;
|
|
163
|
+
const _echoMarkerContractInSync = [true, true];
|
|
164
|
+
void _echoMarkerContractInSync;
|
|
165
|
+
//# sourceMappingURL=contract.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"contract.js","sourceRoot":"","sources":["../../src/source/contract.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AACxD,OAAO,EACL,qBAAqB,EACrB,yBAAyB,GAC1B,MAAM,2BAA2B,CAAC;AACnC,OAAO,EACL,mCAAmC,EACnC,+BAA+B,EAC/B,kCAAkC,GAInC,MAAM,YAAY,CAAC;AAEpB,MAAM,UAAU,GAAG,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,OAAO,EAA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AAC,CAAC;IACvB,uBAAuB;IACvB,EAAE,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;CACtB,CAAC,CAAC;AAGH,sHAAsH;AACtH,MAAM,CAAC,MAAM,yBAAyB,GAAG,CAAC,CAAC,MAAM,CAAC;IAChD,kEAAkE;IAClE,YAAY,EAAE,CAAC,CAAC,OAAO,EAAE;IACzB,6GAA6G;IAC7G,OAAO,EAAE,CAAC,CAAC,OAAO,EAAE;IACpB,sDAAsD;IACtD,mBAAmB,EAAE,CAAC,CAAC,OAAO,EAAE;IAChC,yEAAyE;IACzE,eAAe,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,QAAQ,EAAE;IACvC,iFAAiF;IACjF,YAAY,EAAE,CAAC,CAAC,OAAO,EAAE;CAC1B,CAAC,CAAC;AASH,MAAM,wBAAwB,GAA+D;IAC3F,IAAI;IACJ,IAAI;CACL,CAAC;AACF,KAAK,wBAAwB,CAAC;AAQ9B,MAAM,mBAAmB,GAAqD;IAC5E,IAAI;IACJ,IAAI;CACL,CAAC;AACF,KAAK,mBAAmB,CAAC;AAQzB,MAAM,yBAAyB,GAG3B,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;AACjB,KAAK,yBAAyB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"drizzle.d.ts","sourceRoot":"","sources":["../../src/source/drizzle.ts"],"names":[],"mappings":"AAAA,cAAc,uBAAuB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"drizzle.js","sourceRoot":"","sources":["../../src/source/drizzle.ts"],"names":[],"mappings":"AAAA,cAAc,uBAAuB,CAAC"}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Builds the request handler returned by `dataSource()`. Given your options —
|
|
3
|
+
* the schema, the API key, and either
|
|
4
|
+
* per-model handlers or an ORM adapter — the handler verifies each signed request,
|
|
5
|
+
* enforces the per-key scopes, and routes the four wire operations (`load`,
|
|
6
|
+
* `list`, `commit`, and `events`) to whichever handlers you configured.
|
|
7
|
+
*/
|
|
8
|
+
import type { Schema, SchemaRecord, InferCreate } from '../schema/schema.js';
|
|
9
|
+
import type { DataSourceAdapter } from './adapter.js';
|
|
10
|
+
import type { SourceApiKey, SourceAuthorizeContext, SourceCommitHandler, SourceEventsHandler, SourceModelHandlers, SourceRequest, SourceScope } from './types.js';
|
|
11
|
+
type SourceModels<S extends SchemaRecord, TAuth> = Partial<{
|
|
12
|
+
readonly [K in keyof S & string]: SourceModelHandlers<InferCreate<Schema<S>, K> & {
|
|
13
|
+
readonly id: string;
|
|
14
|
+
} & Record<string, unknown>, InferCreate<Schema<S>, K>, TAuth>;
|
|
15
|
+
}>;
|
|
16
|
+
export type DataSourceOptions<S extends SchemaRecord, TAuth = unknown> = {
|
|
17
|
+
readonly schema: Schema<S>;
|
|
18
|
+
/**
|
|
19
|
+
* Your Ablo project credential. Ablo signs each Data Source call with the same
|
|
20
|
+
* project API key your server-side SDK already uses, so your environment holds a
|
|
21
|
+
* single Ablo credential and every request is signature-verified before any
|
|
22
|
+
* handler runs.
|
|
23
|
+
*/
|
|
24
|
+
readonly apiKey: SourceApiKey;
|
|
25
|
+
/**
|
|
26
|
+
* How much clock skew to tolerate when verifying a request's signed timestamp.
|
|
27
|
+
* Defaults to five minutes.
|
|
28
|
+
*/
|
|
29
|
+
readonly signatureToleranceMs?: number;
|
|
30
|
+
/**
|
|
31
|
+
* Attaches your own context to a verified request and returns it — for example a
|
|
32
|
+
* database handle, an account scope, or the current actor. Keep database
|
|
33
|
+
* credentials inside this function's environment and never send them to Ablo. The
|
|
34
|
+
* signature has already been checked against `apiKey` by the time this runs, so
|
|
35
|
+
* `authorize` only needs to supply business context, not re-verify the caller.
|
|
36
|
+
*/
|
|
37
|
+
readonly authorize?: (context: SourceAuthorizeContext) => Promise<TAuth> | TAuth;
|
|
38
|
+
/**
|
|
39
|
+
* Resolves the set of operations a request's key may perform. When you provide
|
|
40
|
+
* it, the handler checks the operation the request is asking for (`load`, `list`,
|
|
41
|
+
* `commit`, or `events`) against the returned set and responds 403
|
|
42
|
+
* `source_forbidden` if it is not allowed, before any model handler runs. A
|
|
43
|
+
* typical implementation reads a key id from the request — a `webhook-id` prefix,
|
|
44
|
+
* a custom header, or the API key itself — and looks that key's scopes up in your
|
|
45
|
+
* store. Omit it to allow every operation; return an empty set to deny them all.
|
|
46
|
+
*/
|
|
47
|
+
readonly resolveScopes?: (params: {
|
|
48
|
+
readonly auth: TAuth;
|
|
49
|
+
readonly request: Request;
|
|
50
|
+
readonly body: SourceRequest;
|
|
51
|
+
}) => Promise<ReadonlySet<SourceScope> | readonly SourceScope[]> | ReadonlySet<SourceScope> | readonly SourceScope[];
|
|
52
|
+
/**
|
|
53
|
+
* Handles a commit atomically across every model it touches. Prefer this in real
|
|
54
|
+
* applications: a single user action can change several models at once and should
|
|
55
|
+
* run inside one transaction you control.
|
|
56
|
+
*/
|
|
57
|
+
readonly commit?: SourceCommitHandler<TAuth>;
|
|
58
|
+
/**
|
|
59
|
+
* Reports changes that happened outside the SDK — cron jobs, dashboard edits,
|
|
60
|
+
* batch imports — which Ablo polls for. Each event you return becomes a delta and
|
|
61
|
+
* fans out to connected clients. You can return your outbox rows directly: Ablo
|
|
62
|
+
* dedupes on stable `event.id`, appends the authoritative event, and uses a
|
|
63
|
+
* server-authored `correlationId` plus per-operation `transactionId` to settle
|
|
64
|
+
* the matching queued write. Store both fields for mediated endpoint commits.
|
|
65
|
+
*/
|
|
66
|
+
readonly events?: SourceEventsHandler<TAuth>;
|
|
67
|
+
/**
|
|
68
|
+
* Groups per-model handlers under a `models` key. The spread form below is
|
|
69
|
+
* usually shorter — `dataSource({ schema, files: { load, list, commit } })` —
|
|
70
|
+
* but this explicit form is available when you prefer it.
|
|
71
|
+
*/
|
|
72
|
+
readonly models?: SourceModels<S, TAuth>;
|
|
73
|
+
/**
|
|
74
|
+
* An ORM adapter, such as `prismaDataSource(prisma, schema)`. When set, it serves
|
|
75
|
+
* all four operations on its own — reads for `load` and `list`, an idempotent
|
|
76
|
+
* `commit` backed by the outbox, and `events` — so you write no handlers by hand.
|
|
77
|
+
* Because rows travel as JSON, the adapter is applied at a single generic
|
|
78
|
+
* dispatch point and needs no per-model types. Use either an adapter or
|
|
79
|
+
* hand-written handlers, not both.
|
|
80
|
+
*/
|
|
81
|
+
readonly adapter?: DataSourceAdapter;
|
|
82
|
+
} & SourceModels<S, TAuth>;
|
|
83
|
+
/**
|
|
84
|
+
* Creates a Data Source endpoint you host in front of your own database.
|
|
85
|
+
*
|
|
86
|
+
* Your application code still reads and writes through Ablo, as in
|
|
87
|
+
* `ablo.files.load`, `.list`, and `.update`. This helper is for keeping the
|
|
88
|
+
* canonical rows in your database: Ablo calls a narrow, signed endpoint you
|
|
89
|
+
* control rather than holding your database credentials.
|
|
90
|
+
*/
|
|
91
|
+
export declare function dataSource<const S extends SchemaRecord, TAuth = unknown>(options: DataSourceOptions<S, TAuth>): (request: Request) => Promise<Response>;
|
|
92
|
+
export {};
|
|
93
|
+
//# sourceMappingURL=factory.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"factory.d.ts","sourceRoot":"","sources":["../../src/source/factory.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EACV,MAAM,EACN,YAAY,EACZ,WAAW,EACZ,MAAM,qBAAqB,CAAC;AAC7B,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAOtD,OAAO,KAAK,EACV,YAAY,EACZ,sBAAsB,EACtB,mBAAmB,EACnB,mBAAmB,EAInB,mBAAmB,EAEnB,aAAa,EAEb,WAAW,EACZ,MAAM,YAAY,CAAC;AAEpB,KAAK,YAAY,CAAC,CAAC,SAAS,YAAY,EAAE,KAAK,IAAI,OAAO,CAAC;IACzD,QAAQ,EAAE,CAAC,IAAI,MAAM,CAAC,GAAG,MAAM,GA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