@abloatai/transaction 0.56.0 → 0.58.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 +54 -10
- package/README.md +3 -1
- package/dist/ai-sdk/modelTools.d.ts +3 -3
- package/dist/ai-sdk/modelTools.d.ts.map +1 -1
- package/dist/ai-sdk/modelTools.js +1 -1
- package/dist/ai-sdk/modelTools.js.map +1 -1
- package/dist/ai-sdk/updateTool.d.ts +5 -7
- package/dist/ai-sdk/updateTool.d.ts.map +1 -1
- package/dist/ai-sdk/updateTool.js +3 -5
- package/dist/ai-sdk/updateTool.js.map +1 -1
- package/dist/auth/capability.d.ts +5 -0
- package/dist/auth/capability.d.ts.map +1 -1
- package/dist/auth/capability.js +5 -0
- package/dist/auth/capability.js.map +1 -1
- package/dist/auth/capabilityLifecycle.d.ts +1 -1
- package/dist/auth/capabilityLifecycle.d.ts.map +1 -1
- package/dist/auth/credentialPolicy.d.ts +1 -1
- package/dist/auth/credentialPolicy.d.ts.map +1 -1
- package/dist/auth/identity.d.ts +3 -3
- package/dist/auth/identity.d.ts.map +1 -1
- package/dist/auth/identity.js +5 -5
- package/dist/auth/identity.js.map +1 -1
- package/dist/auth/index.d.ts +4 -208
- package/dist/auth/index.d.ts.map +1 -1
- package/dist/auth/index.js +4 -330
- package/dist/auth/index.js.map +1 -1
- package/dist/auth/runtime.d.ts +218 -0
- package/dist/auth/runtime.d.ts.map +1 -0
- package/dist/auth/runtime.js +336 -0
- package/dist/auth/runtime.js.map +1 -0
- package/dist/auth/sessionMint.d.ts +1 -1
- package/dist/auth/sessionMint.d.ts.map +1 -1
- package/dist/auth/sessionMint.js +2 -1
- package/dist/auth/sessionMint.js.map +1 -1
- package/dist/branches.d.ts +25 -21
- package/dist/branches.d.ts.map +1 -1
- package/dist/branches.js +3 -0
- package/dist/branches.js.map +1 -1
- package/dist/{coordination/awaitClaimGrant.d.ts → claims/awaitGrant.d.ts} +1 -1
- package/dist/claims/awaitGrant.d.ts.map +1 -0
- package/dist/{coordination/awaitClaimGrant.js → claims/awaitGrant.js} +4 -4
- package/dist/claims/awaitGrant.js.map +1 -0
- package/dist/{wire/claims.d.ts → claims/contract.d.ts} +1 -1
- package/dist/claims/contract.d.ts.map +1 -0
- package/dist/{wire/claims.js → claims/contract.js} +2 -2
- package/dist/claims/contract.js.map +1 -0
- package/dist/{wire/claimEvent.d.ts → claims/eventContract.d.ts} +1 -1
- package/dist/claims/eventContract.d.ts.map +1 -0
- package/dist/{wire/claimEvent.js → claims/eventContract.js} +1 -1
- package/dist/claims/eventContract.js.map +1 -0
- package/dist/{coordination → claims}/events.d.ts +7 -11
- package/dist/claims/events.d.ts.map +1 -0
- package/dist/claims/events.js +8 -0
- package/dist/claims/events.js.map +1 -0
- package/dist/{coordination/claimHeartbeatLoop.d.ts → claims/heartbeat.d.ts} +1 -1
- package/dist/claims/heartbeat.d.ts.map +1 -0
- package/dist/{coordination/claimHeartbeatLoop.js → claims/heartbeat.js} +1 -1
- package/dist/claims/heartbeat.js.map +1 -0
- package/dist/claims/index.d.ts +17 -0
- package/dist/claims/index.d.ts.map +1 -0
- package/dist/claims/index.js +16 -0
- package/dist/claims/index.js.map +1 -0
- package/dist/claims/lifetime.d.ts +26 -0
- package/dist/claims/lifetime.d.ts.map +1 -0
- package/dist/claims/lifetime.js +62 -0
- package/dist/claims/lifetime.js.map +1 -0
- package/dist/{coordination → claims}/locator.d.ts +1 -1
- package/dist/claims/locator.d.ts.map +1 -0
- package/dist/{coordination → claims}/locator.js +2 -2
- package/dist/claims/locator.js.map +1 -0
- package/dist/{coordination/claimMeta.d.ts → claims/meta.d.ts} +1 -1
- package/dist/claims/meta.d.ts.map +1 -0
- package/dist/{coordination/claimMeta.js → claims/meta.js} +1 -1
- package/dist/claims/meta.js.map +1 -0
- package/dist/claims/routes.d.ts +59 -0
- package/dist/claims/routes.d.ts.map +1 -0
- package/dist/claims/routes.js +69 -0
- package/dist/claims/routes.js.map +1 -0
- package/dist/claims/targetConflict.d.ts.map +1 -0
- package/dist/claims/targetConflict.js.map +1 -0
- package/dist/{coordination → claims}/trace.d.ts +2 -2
- package/dist/claims/trace.d.ts.map +1 -0
- package/dist/{coordination → claims}/trace.js +5 -5
- package/dist/claims/trace.js.map +1 -0
- package/dist/{ablo.d.ts → client/ablo.d.ts} +6 -15
- package/dist/client/ablo.d.ts.map +1 -0
- package/dist/{ablo.js → client/ablo.js} +2 -2
- package/dist/client/ablo.js.map +1 -0
- package/dist/{transactionLayer.d.ts → client/contract.d.ts} +12 -14
- package/dist/client/contract.d.ts.map +1 -0
- package/dist/{transactionLayer.js → client/contract.js} +4 -5
- package/dist/client/contract.js.map +1 -0
- package/dist/{headlessClient.d.ts → client/headless.d.ts} +4 -4
- package/dist/client/headless.d.ts.map +1 -0
- package/dist/{headlessClient.js → client/headless.js} +8 -10
- package/dist/{headlessClient.js.map → client/headless.js.map} +1 -1
- package/dist/client/index.d.ts +11 -0
- package/dist/client/index.d.ts.map +1 -0
- package/dist/client/index.js +11 -0
- package/dist/client/index.js.map +1 -0
- package/dist/{resources → client/resources}/functionalUpdate.d.ts +4 -4
- package/dist/client/resources/functionalUpdate.d.ts.map +1 -0
- package/dist/{resources → client/resources}/functionalUpdate.js +3 -3
- package/dist/client/resources/functionalUpdate.js.map +1 -0
- package/dist/{resources → client/resources}/httpResources.d.ts +92 -77
- package/dist/client/resources/httpResources.d.ts.map +1 -0
- package/dist/client/resources/httpResources.js +94 -0
- package/dist/client/resources/httpResources.js.map +1 -0
- package/dist/client/resources/modelCreate.d.ts +21 -0
- package/dist/client/resources/modelCreate.d.ts.map +1 -0
- package/dist/client/resources/modelCreate.js +49 -0
- package/dist/client/resources/modelCreate.js.map +1 -0
- package/dist/{resources → client/resources}/modelOperations.d.ts +57 -51
- package/dist/client/resources/modelOperations.d.ts.map +1 -0
- package/dist/{resources → client/resources}/modelOperations.js +1 -1
- package/dist/client/resources/modelOperations.js.map +1 -0
- package/dist/{resources → client/resources}/mutationOptions.d.ts +4 -17
- package/dist/client/resources/mutationOptions.d.ts.map +1 -0
- package/dist/client/resources/mutationOptions.js.map +1 -0
- package/dist/client/resources/where.d.ts.map +1 -0
- package/dist/{resources → client/resources}/where.js +1 -1
- package/dist/client/resources/where.js.map +1 -0
- package/dist/{resources → client/resources}/writeOptionsSchema.d.ts +16 -35
- package/dist/client/resources/writeOptionsSchema.d.ts.map +1 -0
- package/dist/{resources → client/resources}/writeOptionsSchema.js +25 -18
- package/dist/client/resources/writeOptionsSchema.js.map +1 -0
- package/dist/{transactions → commit}/confirmation/commitEnvelope.d.ts +1 -37
- package/dist/commit/confirmation/commitEnvelope.d.ts.map +1 -0
- package/dist/{transactions → commit}/confirmation/commitEnvelope.js +2 -7
- package/dist/commit/confirmation/commitEnvelope.js.map +1 -0
- package/dist/commit/confirmation/httpCommitEnvelope.d.ts.map +1 -0
- package/dist/{transactions → commit}/confirmation/httpCommitEnvelope.js +1 -1
- package/dist/commit/confirmation/httpCommitEnvelope.js.map +1 -0
- package/dist/commit/confirmation/idempotencyKey.d.ts.map +1 -0
- package/dist/commit/confirmation/idempotencyKey.js.map +1 -0
- package/dist/{transactions → commit}/confirmation/pendingWrite.d.ts +2 -33
- package/dist/commit/confirmation/pendingWrite.d.ts.map +1 -0
- package/dist/{transactions → commit}/confirmation/pendingWrite.js +1 -1
- package/dist/commit/confirmation/pendingWrite.js.map +1 -0
- package/dist/commit/contract.d.ts +1404 -0
- package/dist/commit/contract.d.ts.map +1 -0
- package/dist/{wire/commit.js → commit/contract.js} +26 -21
- package/dist/commit/contract.js.map +1 -0
- package/dist/{durableWrites.d.ts → commit/durableWrites.d.ts} +6 -6
- package/dist/commit/durableWrites.d.ts.map +1 -0
- package/dist/{durableWrites.js → commit/durableWrites.js} +5 -5
- package/dist/commit/durableWrites.js.map +1 -0
- package/dist/commit/httpRequest.d.ts +45 -0
- package/dist/commit/httpRequest.d.ts.map +1 -0
- package/dist/commit/httpRequest.js +66 -0
- package/dist/commit/httpRequest.js.map +1 -0
- package/dist/commit/index.d.ts +17 -0
- package/dist/commit/index.d.ts.map +1 -0
- package/dist/commit/index.js +17 -0
- package/dist/commit/index.js.map +1 -0
- package/dist/{readSetContext.d.ts → commit/readSetContext.d.ts} +7 -15
- package/dist/commit/readSetContext.d.ts.map +1 -0
- package/dist/{readSetContext.js → commit/readSetContext.js} +18 -28
- package/dist/commit/readSetContext.js.map +1 -0
- package/dist/{commitRecordRuntime.d.ts → commit/recordRuntime.d.ts} +3 -5
- package/dist/commit/recordRuntime.d.ts.map +1 -0
- package/dist/{commitRecordRuntime.js → commit/recordRuntime.js} +13 -54
- package/dist/commit/recordRuntime.js.map +1 -0
- package/dist/coordination/index.d.ts +6 -8
- package/dist/coordination/index.d.ts.map +1 -1
- package/dist/coordination/index.js +3 -9
- package/dist/coordination/index.js.map +1 -1
- package/dist/coordination/schema.d.ts +11 -466
- package/dist/coordination/schema.d.ts.map +1 -1
- package/dist/coordination/schema.js +13 -265
- package/dist/coordination/schema.js.map +1 -1
- package/dist/errorCodes.d.ts +16 -9
- package/dist/errorCodes.d.ts.map +1 -1
- package/dist/errorCodes.js +14 -6
- package/dist/errorCodes.js.map +1 -1
- package/dist/errorObservation.d.ts +2 -2
- package/dist/errors.d.ts +3 -2
- package/dist/errors.d.ts.map +1 -1
- package/dist/errors.js +27 -11
- package/dist/errors.js.map +1 -1
- package/dist/index.d.ts +7 -7
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -3
- package/dist/index.js.map +1 -1
- package/dist/internal/read-set.d.ts +3 -3
- package/dist/internal/read-set.d.ts.map +1 -1
- package/dist/internal/read-set.js +2 -2
- package/dist/internal/read-set.js.map +1 -1
- package/dist/observability.d.ts +4 -4
- package/dist/observability.d.ts.map +1 -1
- package/dist/observability.js +2 -2
- package/dist/{wire/delta.d.ts → observation/contract.d.ts} +8 -8
- package/dist/observation/contract.d.ts.map +1 -0
- package/dist/{wire/delta.js → observation/contract.js} +3 -3
- package/dist/observation/contract.js.map +1 -0
- package/dist/{wire/feedCursor.d.ts → observation/cursor.d.ts} +1 -1
- package/dist/observation/cursor.d.ts.map +1 -0
- package/dist/{wire/feedCursor.js → observation/cursor.js} +1 -1
- package/dist/observation/cursor.js.map +1 -0
- package/dist/{wire/deltaDelivery.d.ts → observation/deliveryContract.d.ts} +1 -1
- package/dist/observation/deliveryContract.d.ts.map +1 -0
- package/dist/{wire/deltaDelivery.js → observation/deliveryContract.js} +1 -1
- package/dist/observation/deliveryContract.js.map +1 -0
- package/dist/{wire/feedEvent.d.ts → observation/feedContract.d.ts} +10 -10
- package/dist/observation/feedContract.d.ts.map +1 -0
- package/dist/{wire/feedEvent.js → observation/feedContract.js} +4 -4
- package/dist/observation/feedContract.js.map +1 -0
- package/dist/observation/httpFeed.d.ts +4 -0
- package/dist/observation/httpFeed.d.ts.map +1 -0
- package/dist/{transport → observation}/httpFeed.js +1 -1
- package/dist/{transport → observation}/httpFeed.js.map +1 -1
- package/dist/observation/index.d.ts +13 -0
- package/dist/observation/index.d.ts.map +1 -0
- package/dist/observation/index.js +13 -0
- package/dist/observation/index.js.map +1 -0
- package/dist/{log → observation/persistence}/syncDeltaRow.d.ts +8 -8
- package/dist/observation/persistence/syncDeltaRow.d.ts.map +1 -0
- package/dist/{log → observation/persistence}/syncDeltaRow.js +4 -4
- package/dist/observation/persistence/syncDeltaRow.js.map +1 -0
- package/dist/pricing.d.ts +20 -12
- package/dist/pricing.d.ts.map +1 -1
- package/dist/pricing.js +46 -26
- package/dist/pricing.js.map +1 -1
- package/dist/schema/audit.d.ts +15 -0
- package/dist/schema/audit.d.ts.map +1 -0
- package/dist/schema/audit.js +90 -0
- package/dist/schema/audit.js.map +1 -0
- package/dist/schema/ddl.d.ts.map +1 -1
- package/dist/schema/ddl.js +68 -1
- package/dist/schema/ddl.js.map +1 -1
- package/dist/schema/index.d.ts +7 -6
- package/dist/schema/index.d.ts.map +1 -1
- package/dist/schema/index.js +6 -7
- package/dist/schema/index.js.map +1 -1
- package/dist/schema/model.d.ts +14 -27
- package/dist/schema/model.d.ts.map +1 -1
- package/dist/schema/model.js +2 -2
- package/dist/schema/model.js.map +1 -1
- package/dist/schema/openapi.d.ts.map +1 -1
- package/dist/schema/openapi.js +149 -8
- package/dist/schema/openapi.js.map +1 -1
- package/dist/schema/roles.d.ts +27 -0
- package/dist/schema/roles.d.ts.map +1 -1
- package/dist/schema/roles.js +40 -0
- package/dist/schema/roles.js.map +1 -1
- package/dist/schema/schema.d.ts +34 -7
- package/dist/schema/schema.d.ts.map +1 -1
- package/dist/schema/schema.js +39 -3
- package/dist/schema/schema.js.map +1 -1
- package/dist/schema/serialize.d.ts +5 -5
- package/dist/schema/serialize.d.ts.map +1 -1
- package/dist/schema/serialize.js +5 -5
- package/dist/schema/serialize.js.map +1 -1
- package/dist/schema/subject.d.ts +18 -0
- package/dist/schema/subject.d.ts.map +1 -0
- package/dist/schema/subject.js +27 -0
- package/dist/schema/subject.js.map +1 -0
- package/dist/schema/tenancy.d.ts +1 -1
- package/dist/server/adapter.d.ts +3 -1
- package/dist/server/adapter.d.ts.map +1 -1
- package/dist/server/commit.d.ts +6 -14
- package/dist/server/commit.d.ts.map +1 -1
- package/dist/server/index.d.ts +1 -1
- package/dist/server/index.d.ts.map +1 -1
- package/dist/server/index.js +1 -1
- package/dist/server/index.js.map +1 -1
- package/dist/server/readConfig.d.ts +3 -0
- package/dist/server/readConfig.d.ts.map +1 -1
- package/dist/server/readConfig.js +0 -21
- package/dist/server/readConfig.js.map +1 -1
- package/dist/server/storageMode.d.ts +1 -1
- package/dist/source/{adapter.d.ts → adapters/adapter.d.ts} +10 -4
- package/dist/source/adapters/adapter.d.ts.map +1 -0
- package/dist/source/adapters/adapter.js.map +1 -0
- package/dist/source/adapters/adapterFactory.d.ts.map +1 -0
- package/dist/source/{adapterFactory.js → adapters/adapterFactory.js} +1 -1
- package/dist/source/adapters/adapterFactory.js.map +1 -0
- package/dist/source/adapters/adapterProfile.d.ts.map +1 -0
- package/dist/source/adapters/adapterProfile.js.map +1 -0
- package/dist/source/{conformance.d.ts → adapters/conformance.d.ts} +1 -1
- package/dist/source/adapters/conformance.d.ts.map +1 -0
- package/dist/source/{conformance.js → adapters/conformance.js} +1 -1
- package/dist/source/adapters/conformance.js.map +1 -0
- package/dist/source/{contract.d.ts → adapters/contract.d.ts} +20 -75
- package/dist/source/adapters/contract.d.ts.map +1 -0
- package/dist/source/{contract.js → adapters/contract.js} +20 -55
- package/dist/source/adapters/contract.js.map +1 -0
- package/dist/source/adapters/drizzle.d.ts +1 -1
- package/dist/source/adapters/drizzle.d.ts.map +1 -1
- package/dist/source/adapters/drizzle.js +54 -25
- package/dist/source/adapters/drizzle.js.map +1 -1
- package/dist/source/adapters/idempotency.d.ts.map +1 -0
- package/dist/source/{idempotency.js → adapters/idempotency.js} +2 -2
- package/dist/source/adapters/idempotency.js.map +1 -0
- package/dist/source/adapters/index.d.ts +21 -0
- package/dist/source/adapters/index.d.ts.map +1 -0
- package/dist/source/adapters/index.js +21 -0
- package/dist/source/adapters/index.js.map +1 -0
- package/dist/source/adapters/kysely.d.ts +3 -1
- package/dist/source/adapters/kysely.d.ts.map +1 -1
- package/dist/source/adapters/kysely.js +49 -23
- package/dist/source/adapters/kysely.js.map +1 -1
- package/dist/source/adapters/kyselyMutationCore.d.ts +6 -3
- package/dist/source/adapters/kyselyMutationCore.d.ts.map +1 -1
- package/dist/source/adapters/kyselyMutationCore.js +17 -8
- package/dist/source/adapters/kyselyMutationCore.js.map +1 -1
- package/dist/source/adapters/memory.d.ts +3 -3
- package/dist/source/adapters/memory.d.ts.map +1 -1
- package/dist/source/adapters/memory.js +20 -7
- package/dist/source/adapters/memory.js.map +1 -1
- package/dist/source/adapters/migration.d.ts +8 -0
- package/dist/source/adapters/migration.d.ts.map +1 -0
- package/dist/source/adapters/migration.js +9 -0
- package/dist/source/adapters/migration.js.map +1 -0
- package/dist/source/{migrations.d.ts → adapters/migrations.d.ts} +3 -4
- package/dist/source/adapters/migrations.d.ts.map +1 -0
- package/dist/source/{migrations.js → adapters/migrations.js} +4 -31
- package/dist/source/adapters/migrations.js.map +1 -0
- package/dist/source/adapters/prisma.d.ts +1 -1
- package/dist/source/adapters/prisma.d.ts.map +1 -1
- package/dist/source/adapters/prisma.js +75 -30
- package/dist/source/adapters/prisma.js.map +1 -1
- package/dist/source/adapters/subjectAuthorization.d.ts +16 -0
- package/dist/source/adapters/subjectAuthorization.d.ts.map +1 -0
- package/dist/source/adapters/subjectAuthorization.js +126 -0
- package/dist/source/adapters/subjectAuthorization.js.map +1 -0
- package/dist/source/{connector.d.ts → connector/client.d.ts} +6 -1
- package/dist/source/connector/client.d.ts.map +1 -0
- package/dist/source/{connector.js → connector/client.js} +28 -11
- package/dist/source/connector/client.js.map +1 -0
- package/dist/source/connector/index.d.ts +4 -0
- package/dist/source/connector/index.d.ts.map +1 -0
- package/dist/source/connector/index.js +4 -0
- package/dist/source/connector/index.js.map +1 -0
- package/dist/source/{connectorProtocol.d.ts → connector/protocol.d.ts} +8 -1
- package/dist/source/connector/protocol.d.ts.map +1 -0
- package/dist/source/{connectorProtocol.js → connector/protocol.js} +10 -3
- package/dist/source/connector/protocol.js.map +1 -0
- package/dist/source/delivery/index.d.ts +3 -0
- package/dist/source/delivery/index.d.ts.map +1 -0
- package/dist/source/delivery/index.js +3 -0
- package/dist/source/delivery/index.js.map +1 -0
- package/dist/source/{pushQueue.d.ts → delivery/pushQueue.d.ts} +1 -1
- package/dist/source/delivery/pushQueue.d.ts.map +1 -0
- package/dist/source/{pushQueue.js → delivery/pushQueue.js} +1 -1
- package/dist/source/delivery/pushQueue.js.map +1 -0
- package/dist/source/{factory.d.ts → endpoint/factory.d.ts} +9 -3
- package/dist/source/endpoint/factory.d.ts.map +1 -0
- package/dist/source/{factory.js → endpoint/factory.js} +122 -6
- package/dist/source/endpoint/factory.js.map +1 -0
- package/dist/source/endpoint/index.d.ts +5 -0
- package/dist/source/endpoint/index.d.ts.map +1 -0
- package/dist/source/endpoint/index.js +5 -0
- package/dist/source/endpoint/index.js.map +1 -0
- package/dist/source/{next.d.ts → endpoint/next.d.ts} +2 -2
- package/dist/source/endpoint/next.d.ts.map +1 -0
- package/dist/source/{next.js → endpoint/next.js} +1 -1
- package/dist/source/endpoint/next.js.map +1 -0
- package/dist/source/{signing.d.ts → endpoint/signing.d.ts} +1 -1
- package/dist/source/endpoint/signing.d.ts.map +1 -0
- package/dist/source/{signing.js → endpoint/signing.js} +1 -1
- package/dist/source/endpoint/signing.js.map +1 -0
- package/dist/source/index.d.ts +15 -12
- package/dist/source/index.d.ts.map +1 -1
- package/dist/source/index.js +13 -10
- package/dist/source/index.js.map +1 -1
- package/dist/source/outbox/contract.d.ts +50 -0
- package/dist/source/outbox/contract.d.ts.map +1 -0
- package/dist/source/outbox/contract.js +50 -0
- package/dist/source/outbox/contract.js.map +1 -0
- package/dist/source/outbox/envelope.d.ts +9 -0
- package/dist/source/outbox/envelope.d.ts.map +1 -0
- package/dist/source/outbox/envelope.js +36 -0
- package/dist/source/outbox/envelope.js.map +1 -0
- package/dist/source/outbox/index.d.ts +11 -0
- package/dist/source/outbox/index.d.ts.map +1 -0
- package/dist/source/outbox/index.js +11 -0
- package/dist/source/outbox/index.js.map +1 -0
- package/dist/source/outbox/migrations.d.ts +4 -0
- package/dist/source/outbox/migrations.d.ts.map +1 -0
- package/dist/source/outbox/migrations.js +67 -0
- package/dist/source/outbox/migrations.js.map +1 -0
- package/dist/source/outbox/retention.d.ts +3 -0
- package/dist/source/outbox/retention.d.ts.map +1 -0
- package/dist/source/outbox/retention.js +3 -0
- package/dist/source/outbox/retention.js.map +1 -0
- package/dist/source/types.d.ts +59 -10
- package/dist/source/types.d.ts.map +1 -1
- package/dist/source/types.js +2 -0
- package/dist/source/types.js.map +1 -1
- package/dist/syncLog/contract.d.ts +19 -8
- package/dist/syncLog/contract.d.ts.map +1 -1
- package/dist/syncLog/contract.js +19 -6
- package/dist/syncLog/contract.js.map +1 -1
- package/dist/testing/fixtures/httpResponses.d.ts +6 -0
- package/dist/testing/fixtures/httpResponses.d.ts.map +1 -1
- package/dist/testing/fixtures/httpResponses.js +1 -0
- package/dist/testing/fixtures/httpResponses.js.map +1 -1
- package/dist/transport/{credentialLifecycle.d.ts → connection/credentialLifecycle.d.ts} +3 -3
- package/dist/transport/connection/credentialLifecycle.d.ts.map +1 -0
- package/dist/transport/{credentialLifecycle.js → connection/credentialLifecycle.js} +2 -2
- package/dist/transport/connection/credentialLifecycle.js.map +1 -0
- package/dist/transport/connection/index.d.ts +5 -0
- package/dist/transport/connection/index.d.ts.map +1 -0
- package/dist/transport/connection/index.js +5 -0
- package/dist/transport/connection/index.js.map +1 -0
- package/dist/transport/{connectionManager.d.ts → connection/manager.d.ts} +13 -5
- package/dist/transport/connection/manager.d.ts.map +1 -0
- package/dist/transport/{connectionManager.js → connection/manager.js} +6 -4
- package/dist/transport/connection/manager.js.map +1 -0
- package/dist/transport/{networkProbe.d.ts → connection/networkProbe.d.ts} +2 -2
- package/dist/transport/connection/networkProbe.d.ts.map +1 -0
- package/dist/transport/{networkProbe.js → connection/networkProbe.js} +4 -4
- package/dist/transport/connection/networkProbe.js.map +1 -0
- package/dist/transport/{httpClient.d.ts → http/client.d.ts} +32 -44
- package/dist/transport/http/client.d.ts.map +1 -0
- package/dist/transport/{httpClient.js → http/client.js} +96 -105
- package/dist/transport/http/client.js.map +1 -0
- package/dist/transport/http/helpers.d.ts +10 -0
- package/dist/transport/http/helpers.d.ts.map +1 -0
- package/dist/transport/http/helpers.js +46 -0
- package/dist/transport/http/helpers.js.map +1 -0
- package/dist/transport/http/index.d.ts +6 -0
- package/dist/transport/http/index.d.ts.map +1 -0
- package/dist/transport/http/index.js +6 -0
- package/dist/transport/http/index.js.map +1 -0
- package/dist/transport/{httpOptions.d.ts → http/options.d.ts} +7 -7
- package/dist/transport/{httpOptions.d.ts.map → http/options.d.ts.map} +1 -1
- package/dist/transport/{httpOptions.js → http/options.js} +1 -1
- package/dist/transport/http/options.js.map +1 -0
- package/dist/transport/http/subscription.d.ts +16 -0
- package/dist/transport/http/subscription.d.ts.map +1 -0
- package/dist/transport/http/subscription.js +146 -0
- package/dist/transport/http/subscription.js.map +1 -0
- package/dist/transport/{httpTransport.d.ts → http/transport.d.ts} +9 -6
- package/dist/transport/http/transport.d.ts.map +1 -0
- package/dist/transport/{httpTransport.js → http/transport.js} +153 -188
- package/dist/transport/http/transport.js.map +1 -0
- package/dist/transport/index.d.ts +8 -0
- package/dist/transport/index.d.ts.map +1 -0
- package/dist/transport/index.js +8 -0
- package/dist/transport/index.js.map +1 -0
- package/dist/transport/{commitFrames.d.ts → websocket/commitFrames.d.ts} +8 -20
- package/dist/transport/websocket/commitFrames.d.ts.map +1 -0
- package/dist/transport/{commitFrames.js → websocket/commitFrames.js} +6 -25
- package/dist/transport/websocket/commitFrames.js.map +1 -0
- package/dist/transport/{wsFrameHandlers.d.ts → websocket/frameHandlers.d.ts} +5 -5
- package/dist/transport/websocket/frameHandlers.d.ts.map +1 -0
- package/dist/transport/{wsFrameHandlers.js → websocket/frameHandlers.js} +10 -51
- package/dist/transport/websocket/frameHandlers.js.map +1 -0
- package/dist/transport/{heartbeat.d.ts → websocket/heartbeat.d.ts} +1 -1
- package/dist/transport/websocket/heartbeat.d.ts.map +1 -0
- package/dist/transport/{heartbeat.js → websocket/heartbeat.js} +2 -2
- package/dist/transport/websocket/heartbeat.js.map +1 -0
- package/dist/transport/websocket/index.d.ts +6 -0
- package/dist/transport/websocket/index.d.ts.map +1 -0
- package/dist/transport/websocket/index.js +6 -0
- package/dist/transport/websocket/index.js.map +1 -0
- package/dist/transport/{wsTransport.d.ts → websocket/transport.d.ts} +13 -25
- package/dist/transport/websocket/transport.d.ts.map +1 -0
- package/dist/transport/{wsTransport.js → websocket/transport.js} +14 -14
- package/dist/transport/websocket/transport.js.map +1 -0
- package/dist/types/index.d.ts +1 -1
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/streams.d.ts +8 -48
- package/dist/types/streams.d.ts.map +1 -1
- package/dist/types/streams.js +2 -2
- package/dist/wire/accountResponses.d.ts +4 -72
- package/dist/wire/accountResponses.d.ts.map +1 -1
- package/dist/wire/accountResponses.js +2 -10
- package/dist/wire/accountResponses.js.map +1 -1
- package/dist/wire/apiLifecycle.d.ts +63 -0
- package/dist/wire/apiLifecycle.d.ts.map +1 -0
- package/dist/wire/apiLifecycle.js +89 -0
- package/dist/wire/apiLifecycle.js.map +1 -0
- package/dist/wire/frames.d.ts +6 -83
- package/dist/wire/frames.d.ts.map +1 -1
- package/dist/wire/frames.js +4 -11
- package/dist/wire/frames.js.map +1 -1
- package/dist/wire/inboundFrames.d.ts +6 -131
- package/dist/wire/inboundFrames.d.ts.map +1 -1
- package/dist/wire/inboundFrames.js +3 -3
- package/dist/wire/inboundFrames.js.map +1 -1
- package/dist/wire/index.d.ts +20 -15
- package/dist/wire/index.d.ts.map +1 -1
- package/dist/wire/index.js +22 -8
- package/dist/wire/index.js.map +1 -1
- package/dist/wire/modelMutations.d.ts +1 -32
- package/dist/wire/modelMutations.d.ts.map +1 -1
- package/dist/wire/modelMutations.js +1 -8
- package/dist/wire/modelMutations.js.map +1 -1
- package/dist/wire/rateLimit.d.ts +82 -0
- package/dist/wire/rateLimit.d.ts.map +1 -0
- package/dist/wire/rateLimit.js +142 -0
- package/dist/wire/rateLimit.js.map +1 -0
- package/package.json +130 -10
- package/src/ai-sdk/modelTools.ts +5 -5
- package/src/ai-sdk/updateTool.ts +5 -7
- package/src/auth/capability.ts +5 -0
- package/src/auth/capabilityLifecycle.ts +1 -1
- package/src/auth/credentialPolicy.ts +1 -1
- package/src/auth/identity.ts +7 -7
- package/src/auth/index.ts +4 -663
- package/src/auth/runtime.ts +669 -0
- package/src/auth/sessionMint.ts +3 -2
- package/src/branches.ts +3 -0
- package/src/{coordination/awaitClaimGrant.ts → claims/awaitGrant.ts} +4 -4
- package/src/{wire/claims.ts → claims/contract.ts} +1 -1
- package/src/{coordination → claims}/events.ts +7 -11
- package/src/claims/index.ts +21 -0
- package/src/claims/lifetime.ts +78 -0
- package/src/{coordination → claims}/locator.ts +3 -3
- package/src/claims/routes.ts +81 -0
- package/src/{coordination → claims}/trace.ts +5 -5
- package/src/{ablo.ts → client/ablo.ts} +8 -20
- package/src/{transactionLayer.ts → client/contract.ts} +11 -13
- package/src/{headlessClient.ts → client/headless.ts} +13 -15
- package/src/client/index.ts +10 -0
- package/src/{resources → client/resources}/functionalUpdate.ts +4 -4
- package/src/{resources → client/resources}/httpResources.ts +163 -92
- package/src/client/resources/modelCreate.ts +73 -0
- package/src/{resources → client/resources}/modelOperations.ts +73 -55
- package/src/{resources → client/resources}/mutationOptions.ts +4 -17
- package/src/{resources → client/resources}/where.ts +1 -1
- package/src/{resources → client/resources}/writeOptionsSchema.ts +35 -27
- package/src/{transactions → commit}/confirmation/commitEnvelope.ts +2 -12
- package/src/{transactions → commit}/confirmation/httpCommitEnvelope.ts +1 -1
- package/src/{transactions → commit}/confirmation/pendingWrite.ts +1 -1
- package/src/{wire/commit.ts → commit/contract.ts} +27 -26
- package/src/{durableWrites.ts → commit/durableWrites.ts} +7 -7
- package/src/commit/httpRequest.ts +103 -0
- package/src/commit/index.ts +16 -0
- package/src/{readSetContext.ts → commit/readSetContext.ts} +24 -43
- package/src/{commitRecordRuntime.ts → commit/recordRuntime.ts} +12 -67
- package/src/coordination/index.ts +4 -54
- package/src/coordination/schema.ts +15 -309
- package/src/errorCodes.ts +62 -10
- package/src/errors.ts +32 -10
- package/src/index.ts +8 -8
- package/src/internal/read-set.ts +3 -6
- package/src/observability.ts +4 -4
- package/src/{wire/delta.ts → observation/contract.ts} +2 -2
- package/src/{wire/feedEvent.ts → observation/feedContract.ts} +3 -4
- package/src/{transport → observation}/httpFeed.ts +3 -3
- package/src/observation/index.ts +12 -0
- package/src/{log → observation/persistence}/syncDeltaRow.ts +6 -7
- package/src/pricing.ts +46 -25
- package/src/schema/audit.ts +121 -0
- package/src/schema/ddl.ts +71 -1
- package/src/schema/index.ts +20 -20
- package/src/schema/model.ts +17 -33
- package/src/schema/openapi.ts +170 -9
- package/src/schema/roles.ts +53 -0
- package/src/schema/schema.ts +91 -6
- package/src/schema/serialize.ts +8 -9
- package/src/schema/subject.ts +43 -0
- package/src/server/adapter.ts +3 -1
- package/src/server/commit.ts +6 -14
- package/src/server/index.ts +1 -1
- package/src/server/readConfig.ts +4 -0
- package/src/source/{adapter.ts → adapters/adapter.ts} +9 -5
- package/src/source/{adapterFactory.ts → adapters/adapterFactory.ts} +1 -1
- package/src/source/{conformance.ts → adapters/conformance.ts} +1 -1
- package/src/source/{contract.ts → adapters/contract.ts} +24 -61
- package/src/source/adapters/drizzle.ts +75 -29
- package/src/source/{idempotency.ts → adapters/idempotency.ts} +2 -2
- package/src/source/adapters/index.ts +20 -0
- package/src/source/adapters/kysely.ts +77 -27
- package/src/source/adapters/kyselyMutationCore.ts +23 -11
- package/src/source/adapters/memory.ts +26 -9
- package/src/source/adapters/migration.ts +11 -0
- package/src/source/{migrations.ts → adapters/migrations.ts} +6 -33
- package/src/source/adapters/prisma.ts +98 -34
- package/src/source/adapters/subjectAuthorization.ts +182 -0
- package/src/source/{connector.ts → connector/client.ts} +35 -12
- package/src/source/connector/index.ts +3 -0
- package/src/source/{connectorProtocol.ts → connector/protocol.ts} +10 -2
- package/src/source/delivery/index.ts +2 -0
- package/src/source/{pushQueue.ts → delivery/pushQueue.ts} +2 -2
- package/src/source/{factory.ts → endpoint/factory.ts} +150 -9
- package/src/source/endpoint/index.ts +4 -0
- package/src/source/{next.ts → endpoint/next.ts} +2 -2
- package/src/source/{signing.ts → endpoint/signing.ts} +1 -1
- package/src/source/index.ts +27 -18
- package/src/source/outbox/contract.ts +56 -0
- package/src/source/outbox/envelope.ts +47 -0
- package/src/source/outbox/index.ts +15 -0
- package/src/source/outbox/migrations.ts +71 -0
- package/src/source/outbox/retention.ts +2 -0
- package/src/source/types.ts +64 -10
- package/src/syncLog/contract.ts +19 -9
- package/src/testing/fixtures/httpResponses.ts +7 -0
- package/src/transport/{credentialLifecycle.ts → connection/credentialLifecycle.ts} +3 -3
- package/src/transport/connection/index.ts +4 -0
- package/src/transport/{connectionManager.ts → connection/manager.ts} +13 -4
- package/src/transport/{networkProbe.ts → connection/networkProbe.ts} +4 -4
- package/src/transport/{httpClient.ts → http/client.ts} +165 -184
- package/src/transport/http/helpers.ts +63 -0
- package/src/transport/http/index.ts +5 -0
- package/src/transport/{httpOptions.ts → http/options.ts} +6 -6
- package/src/transport/http/subscription.ts +174 -0
- package/src/transport/{httpTransport.ts → http/transport.ts} +210 -246
- package/src/transport/index.ts +7 -0
- package/src/transport/{commitFrames.ts → websocket/commitFrames.ts} +14 -46
- package/src/transport/{wsFrameHandlers.ts → websocket/frameHandlers.ts} +11 -54
- package/src/transport/{heartbeat.ts → websocket/heartbeat.ts} +2 -2
- package/src/transport/websocket/index.ts +5 -0
- package/src/transport/{wsTransport.ts → websocket/transport.ts} +16 -30
- package/src/types/index.ts +2 -6
- package/src/types/streams.ts +7 -61
- package/src/webhooks/events.ts +1 -1
- package/src/wire/accountResponses.ts +3 -12
- package/src/wire/apiLifecycle.ts +94 -0
- package/src/wire/frames.ts +5 -15
- package/src/wire/inboundFrames.ts +3 -3
- package/src/wire/index.ts +50 -15
- package/src/wire/modelMutations.ts +1 -14
- package/src/wire/rateLimit.ts +155 -0
- package/dist/ablo.d.ts.map +0 -1
- package/dist/ablo.js.map +0 -1
- package/dist/commitRecordRuntime.d.ts.map +0 -1
- package/dist/commitRecordRuntime.js.map +0 -1
- package/dist/coordination/awaitClaimGrant.d.ts.map +0 -1
- package/dist/coordination/awaitClaimGrant.js.map +0 -1
- package/dist/coordination/claimHeartbeatLoop.d.ts.map +0 -1
- package/dist/coordination/claimHeartbeatLoop.js.map +0 -1
- package/dist/coordination/claimMeta.d.ts.map +0 -1
- package/dist/coordination/claimMeta.js.map +0 -1
- package/dist/coordination/events.d.ts.map +0 -1
- package/dist/coordination/events.js +0 -8
- package/dist/coordination/events.js.map +0 -1
- package/dist/coordination/locator.d.ts.map +0 -1
- package/dist/coordination/locator.js.map +0 -1
- package/dist/coordination/targetConflict.d.ts.map +0 -1
- package/dist/coordination/targetConflict.js.map +0 -1
- package/dist/coordination/trace.d.ts.map +0 -1
- package/dist/coordination/trace.js.map +0 -1
- package/dist/durableWrites.d.ts.map +0 -1
- package/dist/durableWrites.js.map +0 -1
- package/dist/headlessClient.d.ts.map +0 -1
- package/dist/log/syncDeltaRow.d.ts.map +0 -1
- package/dist/log/syncDeltaRow.js.map +0 -1
- package/dist/policy/types.d.ts +0 -226
- package/dist/policy/types.d.ts.map +0 -1
- package/dist/policy/types.js +0 -127
- package/dist/policy/types.js.map +0 -1
- package/dist/readSetContext.d.ts.map +0 -1
- package/dist/readSetContext.js.map +0 -1
- package/dist/resources/functionalUpdate.d.ts.map +0 -1
- package/dist/resources/functionalUpdate.js.map +0 -1
- package/dist/resources/httpResources.d.ts.map +0 -1
- package/dist/resources/httpResources.js +0 -17
- package/dist/resources/httpResources.js.map +0 -1
- package/dist/resources/modelOperations.d.ts.map +0 -1
- package/dist/resources/modelOperations.js.map +0 -1
- package/dist/resources/mutationOptions.d.ts.map +0 -1
- package/dist/resources/mutationOptions.js.map +0 -1
- package/dist/resources/where.d.ts.map +0 -1
- package/dist/resources/where.js.map +0 -1
- package/dist/resources/writeOptionsSchema.d.ts.map +0 -1
- package/dist/resources/writeOptionsSchema.js.map +0 -1
- package/dist/schema/coordination.d.ts +0 -113
- package/dist/schema/coordination.d.ts.map +0 -1
- package/dist/schema/coordination.js +0 -134
- package/dist/schema/coordination.js.map +0 -1
- package/dist/source/adapter.d.ts.map +0 -1
- package/dist/source/adapter.js.map +0 -1
- package/dist/source/adapterFactory.d.ts.map +0 -1
- package/dist/source/adapterFactory.js.map +0 -1
- package/dist/source/adapterProfile.d.ts.map +0 -1
- package/dist/source/adapterProfile.js.map +0 -1
- package/dist/source/conformance.d.ts.map +0 -1
- package/dist/source/conformance.js.map +0 -1
- package/dist/source/connector.d.ts.map +0 -1
- package/dist/source/connector.js.map +0 -1
- package/dist/source/connectorProtocol.d.ts.map +0 -1
- package/dist/source/connectorProtocol.js.map +0 -1
- package/dist/source/contract.d.ts.map +0 -1
- package/dist/source/contract.js.map +0 -1
- package/dist/source/drizzle.d.ts +0 -2
- package/dist/source/drizzle.d.ts.map +0 -1
- package/dist/source/drizzle.js +0 -2
- package/dist/source/drizzle.js.map +0 -1
- package/dist/source/factory.d.ts.map +0 -1
- package/dist/source/factory.js.map +0 -1
- package/dist/source/idempotency.d.ts.map +0 -1
- package/dist/source/idempotency.js.map +0 -1
- package/dist/source/kysely.d.ts +0 -3
- package/dist/source/kysely.d.ts.map +0 -1
- package/dist/source/kysely.js +0 -3
- package/dist/source/kysely.js.map +0 -1
- package/dist/source/migrations.d.ts.map +0 -1
- package/dist/source/migrations.js.map +0 -1
- package/dist/source/next.d.ts.map +0 -1
- package/dist/source/next.js.map +0 -1
- package/dist/source/pushQueue.d.ts.map +0 -1
- package/dist/source/pushQueue.js.map +0 -1
- package/dist/source/signing.d.ts.map +0 -1
- package/dist/source/signing.js.map +0 -1
- package/dist/transactionLayer.d.ts.map +0 -1
- package/dist/transactionLayer.js.map +0 -1
- package/dist/transactions/confirmation/commitEnvelope.d.ts.map +0 -1
- package/dist/transactions/confirmation/commitEnvelope.js.map +0 -1
- package/dist/transactions/confirmation/httpCommitEnvelope.d.ts.map +0 -1
- package/dist/transactions/confirmation/httpCommitEnvelope.js.map +0 -1
- package/dist/transactions/confirmation/idempotencyKey.d.ts.map +0 -1
- package/dist/transactions/confirmation/idempotencyKey.js.map +0 -1
- package/dist/transactions/confirmation/pendingWrite.d.ts.map +0 -1
- package/dist/transactions/confirmation/pendingWrite.js.map +0 -1
- package/dist/transport/commitFrames.d.ts.map +0 -1
- package/dist/transport/commitFrames.js.map +0 -1
- package/dist/transport/connectionManager.d.ts.map +0 -1
- package/dist/transport/connectionManager.js.map +0 -1
- package/dist/transport/credentialLifecycle.d.ts.map +0 -1
- package/dist/transport/credentialLifecycle.js.map +0 -1
- package/dist/transport/heartbeat.d.ts.map +0 -1
- package/dist/transport/heartbeat.js.map +0 -1
- package/dist/transport/httpClient.d.ts.map +0 -1
- package/dist/transport/httpClient.js.map +0 -1
- package/dist/transport/httpFeed.d.ts +0 -4
- package/dist/transport/httpFeed.d.ts.map +0 -1
- package/dist/transport/httpOptions.js.map +0 -1
- package/dist/transport/httpTransport.d.ts.map +0 -1
- package/dist/transport/httpTransport.js.map +0 -1
- package/dist/transport/networkProbe.d.ts.map +0 -1
- package/dist/transport/networkProbe.js.map +0 -1
- package/dist/transport/wsFrameHandlers.d.ts.map +0 -1
- package/dist/transport/wsFrameHandlers.js.map +0 -1
- package/dist/transport/wsTransport.d.ts.map +0 -1
- package/dist/transport/wsTransport.js.map +0 -1
- package/dist/wire/claimEvent.d.ts.map +0 -1
- package/dist/wire/claimEvent.js.map +0 -1
- package/dist/wire/claims.d.ts.map +0 -1
- package/dist/wire/claims.js.map +0 -1
- package/dist/wire/commit.d.ts +0 -2801
- package/dist/wire/commit.d.ts.map +0 -1
- package/dist/wire/commit.js.map +0 -1
- package/dist/wire/delta.d.ts.map +0 -1
- package/dist/wire/delta.js.map +0 -1
- package/dist/wire/deltaDelivery.d.ts.map +0 -1
- package/dist/wire/deltaDelivery.js.map +0 -1
- package/dist/wire/feedCursor.d.ts.map +0 -1
- package/dist/wire/feedCursor.js.map +0 -1
- package/dist/wire/feedEvent.d.ts.map +0 -1
- package/dist/wire/feedEvent.js.map +0 -1
- package/src/policy/types.ts +0 -300
- package/src/schema/coordination.ts +0 -161
- package/src/source/drizzle.ts +0 -1
- package/src/source/kysely.ts +0 -2
- /package/dist/{coordination → claims}/targetConflict.d.ts +0 -0
- /package/dist/{coordination → claims}/targetConflict.js +0 -0
- /package/dist/{resources → client/resources}/mutationOptions.js +0 -0
- /package/dist/{resources → client/resources}/where.d.ts +0 -0
- /package/dist/{transactions → commit}/confirmation/httpCommitEnvelope.d.ts +0 -0
- /package/dist/{transactions → commit}/confirmation/idempotencyKey.d.ts +0 -0
- /package/dist/{transactions → commit}/confirmation/idempotencyKey.js +0 -0
- /package/dist/source/{adapter.js → adapters/adapter.js} +0 -0
- /package/dist/source/{adapterFactory.d.ts → adapters/adapterFactory.d.ts} +0 -0
- /package/dist/source/{adapterProfile.d.ts → adapters/adapterProfile.d.ts} +0 -0
- /package/dist/source/{adapterProfile.js → adapters/adapterProfile.js} +0 -0
- /package/dist/source/{idempotency.d.ts → adapters/idempotency.d.ts} +0 -0
- /package/src/{wire/claimEvent.ts → claims/eventContract.ts} +0 -0
- /package/src/{coordination/claimHeartbeatLoop.ts → claims/heartbeat.ts} +0 -0
- /package/src/{coordination/claimMeta.ts → claims/meta.ts} +0 -0
- /package/src/{coordination → claims}/targetConflict.ts +0 -0
- /package/src/{transactions → commit}/confirmation/idempotencyKey.ts +0 -0
- /package/src/{wire/feedCursor.ts → observation/cursor.ts} +0 -0
- /package/src/{wire/deltaDelivery.ts → observation/deliveryContract.ts} +0 -0
- /package/src/source/{adapterProfile.ts → adapters/adapterProfile.ts} +0 -0
|
@@ -16,14 +16,13 @@ import {
|
|
|
16
16
|
AbloNotFoundError,
|
|
17
17
|
claimedError,
|
|
18
18
|
translateHttpError,
|
|
19
|
-
} from '
|
|
20
|
-
import { v5 as uuidv5 } from 'uuid';
|
|
19
|
+
} from '../../errors.js';
|
|
21
20
|
import { z } from 'zod';
|
|
22
21
|
import {
|
|
23
22
|
reconcileFunctionalUpdate,
|
|
24
23
|
type ModelUpdater,
|
|
25
24
|
type FunctionalUpdateOptions,
|
|
26
|
-
} from '
|
|
25
|
+
} from '../../client/resources/functionalUpdate.js';
|
|
27
26
|
import {
|
|
28
27
|
assertBrowserSafety,
|
|
29
28
|
readProcessEnv,
|
|
@@ -34,42 +33,42 @@ import {
|
|
|
34
33
|
resolveBootstrapBaseUrl,
|
|
35
34
|
rejectRemovedDatabaseUrlOption,
|
|
36
35
|
warnIfCliKeyMismatch,
|
|
37
|
-
} from '
|
|
38
|
-
import { PROTOCOL_VERSION, PROTOCOL_VERSION_HEADER } from '
|
|
36
|
+
} from '../../auth/apiKey.js';
|
|
37
|
+
import { PROTOCOL_VERSION, PROTOCOL_VERSION_HEADER } from '../../wire/protocolVersion.js';
|
|
39
38
|
import {
|
|
40
|
-
commitReceiptSchema,
|
|
41
39
|
commitRecordSchema,
|
|
42
40
|
commitRecordListSchema,
|
|
43
41
|
commitRecordListOptionsSchema,
|
|
44
42
|
commitRecordWhereSchema,
|
|
45
43
|
type CommitReceiptWire,
|
|
46
|
-
} from '
|
|
47
|
-
import { logListResponseSchema } from '
|
|
44
|
+
} from '../../commit/contract.js';
|
|
45
|
+
import { logListResponseSchema } from '../../observation/feedContract.js';
|
|
48
46
|
import {
|
|
49
47
|
claimAcquireResponseSchema,
|
|
50
48
|
claimHeartbeatBatchReplySchema,
|
|
51
49
|
claimHeartbeatReplySchema,
|
|
52
50
|
claimListResponseSchema,
|
|
53
51
|
claimStateSchema,
|
|
52
|
+
DEFAULT_CLAIM_TTL_MS,
|
|
54
53
|
type ClaimHeartbeatReply,
|
|
55
54
|
type ClaimListResponse,
|
|
56
55
|
type ClaimQueuedResponse,
|
|
57
56
|
type ClaimRequest,
|
|
58
57
|
type ClaimState,
|
|
59
58
|
type ClaimTargetBody,
|
|
60
|
-
} from '
|
|
59
|
+
} from '../../claims/contract.js';
|
|
61
60
|
import {
|
|
62
61
|
modelListResponseSchema,
|
|
63
62
|
modelReadResponseSchema,
|
|
64
|
-
} from '
|
|
65
|
-
import { toMs } from '
|
|
63
|
+
} from '../../wire/modelResponses.js';
|
|
64
|
+
import { toMs } from '../../utils/duration.js';
|
|
66
65
|
import {
|
|
67
66
|
heartbeatCadenceMs,
|
|
68
67
|
resolveHeartbeatOptions,
|
|
69
68
|
resolveHeartbeatPlan,
|
|
70
69
|
startClaimHeartbeatLoop,
|
|
71
|
-
} from '
|
|
72
|
-
import type { HttpClientConfig } from './
|
|
70
|
+
} from '../../claims/heartbeat.js';
|
|
71
|
+
import type { HttpClientConfig } from './options.js';
|
|
73
72
|
import type {
|
|
74
73
|
ClaimedOptions,
|
|
75
74
|
CommitCreateOptions,
|
|
@@ -81,7 +80,7 @@ import type {
|
|
|
81
80
|
HttpClaimsResource,
|
|
82
81
|
HttpTransportModel,
|
|
83
82
|
ModelClaim,
|
|
84
|
-
ModelMutationOptions,
|
|
83
|
+
InternalModelMutationOptions as ModelMutationOptions,
|
|
85
84
|
ModelReadOptions,
|
|
86
85
|
HttpTransportRead,
|
|
87
86
|
HttpTransportList,
|
|
@@ -90,69 +89,68 @@ import type {
|
|
|
90
89
|
CreateSessionParams,
|
|
91
90
|
AbloSession,
|
|
92
91
|
SessionResource,
|
|
93
|
-
} from '
|
|
94
|
-
import { mintSession } from '
|
|
92
|
+
} from '../../client/resources/httpResources.js';
|
|
93
|
+
import { mintSession } from '../../auth/sessionMint.js';
|
|
95
94
|
import {
|
|
96
95
|
revokeCapability,
|
|
97
96
|
rotateCapability,
|
|
98
|
-
} from '
|
|
99
|
-
import { parseIdentityResolveResponse } from '
|
|
100
|
-
import type { EffectiveAuthority } from '
|
|
97
|
+
} from '../../auth/capabilityLifecycle.js';
|
|
98
|
+
import { parseIdentityResolveResponse } from '../../auth/schemas.js';
|
|
99
|
+
import type { EffectiveAuthority } from '../../auth/capability.js';
|
|
101
100
|
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
*/
|
|
109
|
-
function heldHeartbeatReply(reply: ClaimHeartbeatReply, label: string): ClaimHeartbeat {
|
|
110
|
-
if (reply.status === 'held' && typeof reply.expiresAt === 'number') {
|
|
111
|
-
return {
|
|
112
|
-
expiresAt: reply.expiresAt,
|
|
113
|
-
...(reply.queueDepth !== undefined ? { queueDepth: reply.queueDepth } : {}),
|
|
114
|
-
};
|
|
115
|
-
}
|
|
116
|
-
throw new AbloClaimedError(
|
|
117
|
-
`The lease behind ${label} is no longer held — it expired or was granted onward. Re-acquire the claim and retry; a write attempted under the old lease is rejected by its \`readAt\` guard.`,
|
|
118
|
-
{ code: 'claim_lost' }
|
|
119
|
-
);
|
|
120
|
-
}
|
|
121
|
-
import type { SchemaRecord } from '../schema/schema.js';
|
|
101
|
+
import {
|
|
102
|
+
claimFromModelClaim,
|
|
103
|
+
heldHeartbeatReply,
|
|
104
|
+
parseSuccessfulCommitResponse,
|
|
105
|
+
} from './helpers.js';
|
|
106
|
+
import type { SchemaRecord } from '../../schema/schema.js';
|
|
122
107
|
import type {
|
|
123
108
|
ClaimLookupParams,
|
|
124
109
|
ClaimOptions,
|
|
125
110
|
ClaimParams,
|
|
126
111
|
ClaimSkipParams,
|
|
112
|
+
ClaimSkipOptions,
|
|
127
113
|
ClaimReorderParams,
|
|
128
|
-
|
|
129
|
-
ModelTrackResult,
|
|
114
|
+
ModelCreateManyParams,
|
|
130
115
|
ServerReadOptions,
|
|
131
116
|
ResolvedClaimContentionOptions,
|
|
132
117
|
ClaimQueueView,
|
|
133
|
-
} from '
|
|
118
|
+
} from '../../client/resources/modelOperations.js';
|
|
134
119
|
import {
|
|
135
120
|
claimAttemptFailure,
|
|
136
121
|
claimQueueView,
|
|
137
122
|
emitClaimStatus,
|
|
138
123
|
resolveClaimContentionOptions,
|
|
139
|
-
} from '
|
|
140
|
-
import type { Duration } from '
|
|
141
|
-
import
|
|
142
|
-
import {
|
|
143
|
-
import type { BatchFence } from '../coordination/locator.js';
|
|
124
|
+
} from '../../client/resources/modelOperations.js';
|
|
125
|
+
import type { Duration } from '../../utils/duration.js';
|
|
126
|
+
import { claimDescription, partName } from '../../coordination/schema.js';
|
|
127
|
+
import type { BatchFence } from '../../claims/locator.js';
|
|
144
128
|
import {
|
|
145
129
|
subTarget,
|
|
146
130
|
streamTarget,
|
|
147
131
|
batchFence,
|
|
148
132
|
claimIdFor,
|
|
149
133
|
fenceTokenFor,
|
|
150
|
-
} from '
|
|
151
|
-
import { declaredMeta, wireMeta } from '
|
|
152
|
-
import type {
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
134
|
+
} from '../../claims/locator.js';
|
|
135
|
+
import { declaredMeta, wireMeta } from '../../claims/meta.js';
|
|
136
|
+
import type {
|
|
137
|
+
Claim,
|
|
138
|
+
ClaimHeartbeat,
|
|
139
|
+
ClaimHeartbeatOptions,
|
|
140
|
+
HeldClaim,
|
|
141
|
+
HeldLease,
|
|
142
|
+
} from '../../types/streams.js';
|
|
143
|
+
import type { CoordinationObservability } from '../../observability.js';
|
|
144
|
+
import {
|
|
145
|
+
assertWriteOptions,
|
|
146
|
+
assertWriteTarget,
|
|
147
|
+
} from '../../client/resources/writeOptionsSchema.js';
|
|
148
|
+
import {
|
|
149
|
+
createModelId,
|
|
150
|
+
resolveCreatedRows,
|
|
151
|
+
resolveCreateId,
|
|
152
|
+
} from '../../client/resources/modelCreate.js';
|
|
153
|
+
import { normalizeWhere } from '../../client/resources/where.js';
|
|
156
154
|
import {
|
|
157
155
|
createDurableHttpCommitEnvelope,
|
|
158
156
|
canonicalHttpCommitBody,
|
|
@@ -161,9 +159,16 @@ import {
|
|
|
161
159
|
isHttpCommitReplayExpired,
|
|
162
160
|
type DurableHttpCommitEnvelope,
|
|
163
161
|
type DurableHttpCommitMethod,
|
|
164
|
-
} from '
|
|
165
|
-
import type { CommitOutboxScope } from '
|
|
166
|
-
import {
|
|
162
|
+
} from '../../commit/confirmation/httpCommitEnvelope.js';
|
|
163
|
+
import type { CommitOutboxScope } from '../../commit/confirmation/commitEnvelope.js';
|
|
164
|
+
import {
|
|
165
|
+
createClientTxId,
|
|
166
|
+
normalizeCommitOperations,
|
|
167
|
+
replicationLagTimeout,
|
|
168
|
+
type ExactHttpCommitRequest,
|
|
169
|
+
} from '../../commit/httpRequest.js';
|
|
170
|
+
import { resolveDurableWrites } from '../../commit/durableWrites.js';
|
|
171
|
+
import { createHttpReadOnChange, type HttpReadOnChange } from './subscription.js';
|
|
167
172
|
|
|
168
173
|
/** @internal Private options for the schema-agnostic HTTP protocol transport. */
|
|
169
174
|
export type HttpTransportOptions = Omit<HttpClientConfig, 'schema'> & {
|
|
@@ -191,12 +196,6 @@ export type HttpTransportOptions = Omit<HttpClientConfig, 'schema'> & {
|
|
|
191
196
|
/** @internal Default per-request deadline for the private HTTP transport. */
|
|
192
197
|
export const DEFAULT_REQUEST_TIMEOUT_MS = 30_000;
|
|
193
198
|
const HTTP_CONFIRMATION_POLL_INTERVAL_MS = 250;
|
|
194
|
-
/**
|
|
195
|
-
* The server's acquire window, mirrored here as the client-side default for a
|
|
196
|
-
* claim that names no `ttl` — it sets the auto-heartbeat cadence.
|
|
197
|
-
*/
|
|
198
|
-
const DEFAULT_CLAIM_TTL_MS = 60_000;
|
|
199
|
-
|
|
200
199
|
// NOTE: end-user / agent session minting is `ablo.sessions.create(...)` (typed
|
|
201
200
|
// against the schema, see Ablo.ts `CreateSessionParams`). There is no separate
|
|
202
201
|
// `ephemeralKeys` resource — `sessions` is the one front door for both.
|
|
@@ -208,6 +207,8 @@ export interface HttpTransport {
|
|
|
208
207
|
/** Drains scheduled commits and active requests. */
|
|
209
208
|
dispose(): Promise<void>;
|
|
210
209
|
purge(): Promise<void>;
|
|
210
|
+
/** @internal Live check used only by `context().onChange`. */
|
|
211
|
+
readonly onChange: HttpReadOnChange;
|
|
211
212
|
readonly commits: CommitResource;
|
|
212
213
|
/**
|
|
213
214
|
* Claim-ticket operations keyed by `claimId` — the id a queued acquire
|
|
@@ -239,46 +240,6 @@ export interface HttpTransport {
|
|
|
239
240
|
|
|
240
241
|
type CommitResponse = CommitReceiptWire;
|
|
241
242
|
|
|
242
|
-
function parseSuccessfulCommitResponse(value: unknown, idempotencyKey: string): CommitResponse {
|
|
243
|
-
const parsed = commitReceiptSchema.safeParse(value);
|
|
244
|
-
if (!parsed.success || parsed.data.clientTxId !== idempotencyKey) {
|
|
245
|
-
throw new AbloConnectionError(
|
|
246
|
-
'The commit endpoint returned an invalid success receipt; its outcome remains pending and is safe to retry.',
|
|
247
|
-
{
|
|
248
|
-
code: 'commit_no_result',
|
|
249
|
-
cause: parsed.success
|
|
250
|
-
? new Error('Commit receipt clientTxId did not match its idempotency key')
|
|
251
|
-
: parsed.error,
|
|
252
|
-
}
|
|
253
|
-
);
|
|
254
|
-
}
|
|
255
|
-
return parsed.data;
|
|
256
|
-
}
|
|
257
|
-
|
|
258
|
-
/** Decode the HTTP claim DTO into the one public Claim shape. */
|
|
259
|
-
function claimFromModelClaim(claim: ModelClaim): Claim {
|
|
260
|
-
// The handle a caller reads back is a public claim, so its `meta` is the
|
|
261
|
-
// declared shape; the rest of the sub-entity locator crosses whole rather
|
|
262
|
-
// than member by member, which is how `fields` used to die on this hop.
|
|
263
|
-
const { meta, ...details } = subTarget(claim.target);
|
|
264
|
-
return {
|
|
265
|
-
object: 'claim',
|
|
266
|
-
id: claim.id,
|
|
267
|
-
...(claim.status ? { status: claim.status } : {}),
|
|
268
|
-
// The server always stamps a description; default only for total safety.
|
|
269
|
-
description: claim.description ?? 'editing',
|
|
270
|
-
heldBy: claim.actor,
|
|
271
|
-
participantKind: claim.participantKind,
|
|
272
|
-
expiresAt: claim.expiresAt,
|
|
273
|
-
...(claim.position !== undefined ? { position: claim.position } : {}),
|
|
274
|
-
target: {
|
|
275
|
-
...streamTarget(claim.target),
|
|
276
|
-
...details,
|
|
277
|
-
...(meta !== undefined ? { meta: declaredMeta(meta) } : {}),
|
|
278
|
-
},
|
|
279
|
-
};
|
|
280
|
-
}
|
|
281
|
-
|
|
282
243
|
/** @internal Constructed only by the typed HTTP facade. */
|
|
283
244
|
export function createHttpTransport(options: HttpTransportOptions): HttpTransport {
|
|
284
245
|
const env = readProcessEnv();
|
|
@@ -320,8 +281,7 @@ export function createHttpTransport(options: HttpTransportOptions): HttpTranspor
|
|
|
320
281
|
const isConflict =
|
|
321
282
|
code === 'stale_context' ||
|
|
322
283
|
code === 'claim_conflict' ||
|
|
323
|
-
code === 'entity_claimed'
|
|
324
|
-
(typeof code === 'string' && code.startsWith('policy:'));
|
|
284
|
+
code === 'entity_claimed';
|
|
325
285
|
if (!isConflict) return;
|
|
326
286
|
const rawConflicts = errorRecord?.conflicts;
|
|
327
287
|
const rows =
|
|
@@ -367,6 +327,7 @@ export function createHttpTransport(options: HttpTransportOptions): HttpTranspor
|
|
|
367
327
|
let activeRequests = 0;
|
|
368
328
|
let requestIdleWaiters: Array<() => void> = [];
|
|
369
329
|
let disposePromise: Promise<void> | null = null;
|
|
330
|
+
const readChangeControllers = new Set<AbortController>();
|
|
370
331
|
|
|
371
332
|
function requestStarted(): void {
|
|
372
333
|
activeRequests += 1;
|
|
@@ -488,7 +449,24 @@ export function createHttpTransport(options: HttpTransportOptions): HttpTranspor
|
|
|
488
449
|
return target.toString();
|
|
489
450
|
}
|
|
490
451
|
|
|
452
|
+
function subscriptionEndpoint(): string {
|
|
453
|
+
const target = new URL(endpoint('/v1/subscriptions'));
|
|
454
|
+
const partition = effectiveAuthority?.deliveryPartition;
|
|
455
|
+
if (partition) {
|
|
456
|
+
target.searchParams.set('deliveryPartition', `${partition.index}-${partition.count}`);
|
|
457
|
+
}
|
|
458
|
+
return target.toString();
|
|
459
|
+
}
|
|
460
|
+
|
|
491
461
|
const requestTimeoutMs = options.timeoutMs ?? DEFAULT_REQUEST_TIMEOUT_MS;
|
|
462
|
+
const onChange = createHttpReadOnChange({
|
|
463
|
+
fetch: fetchImpl,
|
|
464
|
+
endpoint: subscriptionEndpoint,
|
|
465
|
+
authHeaders,
|
|
466
|
+
prepare: ready,
|
|
467
|
+
register: (controller) => readChangeControllers.add(controller),
|
|
468
|
+
unregister: (controller) => readChangeControllers.delete(controller),
|
|
469
|
+
});
|
|
492
470
|
|
|
493
471
|
/**
|
|
494
472
|
* Issues one request and returns its decoded body without a contract.
|
|
@@ -703,14 +681,6 @@ export function createHttpTransport(options: HttpTransportOptions): HttpTranspor
|
|
|
703
681
|
readonly response: CommitResponse;
|
|
704
682
|
}
|
|
705
683
|
|
|
706
|
-
interface ExactHttpCommitRequest {
|
|
707
|
-
readonly idempotencyKey: string;
|
|
708
|
-
readonly method: DurableHttpCommitMethod;
|
|
709
|
-
readonly path: string;
|
|
710
|
-
readonly body: string;
|
|
711
|
-
readonly sealedProtocolVersion?: number;
|
|
712
|
-
}
|
|
713
|
-
|
|
714
684
|
function observeCommitReceipt(
|
|
715
685
|
request: ExactHttpCommitRequest,
|
|
716
686
|
receipt: CommitResponse,
|
|
@@ -738,25 +708,6 @@ export function createHttpTransport(options: HttpTransportOptions): HttpTranspor
|
|
|
738
708
|
}
|
|
739
709
|
}
|
|
740
710
|
|
|
741
|
-
function replicationLagTimeout(
|
|
742
|
-
request: ExactHttpCommitRequest,
|
|
743
|
-
response: CommitResponse
|
|
744
|
-
): AbloConnectionError {
|
|
745
|
-
return new AbloConnectionError(
|
|
746
|
-
`The source accepted commit ${request.idempotencyKey}, but its replication echo did not arrive within ${requestTimeoutMs}ms.`,
|
|
747
|
-
{
|
|
748
|
-
code: 'replication_lag_timeout',
|
|
749
|
-
httpStatus: 504,
|
|
750
|
-
details: {
|
|
751
|
-
clientTxId: request.idempotencyKey,
|
|
752
|
-
...(response.correlationId ? { correlationId: response.correlationId } : {}),
|
|
753
|
-
timeoutMs: requestTimeoutMs,
|
|
754
|
-
accepted: true,
|
|
755
|
-
},
|
|
756
|
-
}
|
|
757
|
-
);
|
|
758
|
-
}
|
|
759
|
-
|
|
760
711
|
/**
|
|
761
712
|
* Replays one byte-identical, idempotent HTTP commit until mutation-log
|
|
762
713
|
* replay reports the source echo as confirmed. `queued` is acceptance only:
|
|
@@ -779,7 +730,7 @@ export function createHttpTransport(options: HttpTransportOptions): HttpTranspor
|
|
|
779
730
|
while (current.status === 'queued') {
|
|
780
731
|
const remaining = deadlineAt === null ? null : deadlineAt - Date.now();
|
|
781
732
|
if (remaining !== null && remaining <= 0) {
|
|
782
|
-
throw replicationLagTimeout(request, current);
|
|
733
|
+
throw replicationLagTimeout(request, current, requestTimeoutMs);
|
|
783
734
|
}
|
|
784
735
|
|
|
785
736
|
const confirmationController = new AbortController();
|
|
@@ -817,7 +768,7 @@ export function createHttpTransport(options: HttpTransportOptions): HttpTranspor
|
|
|
817
768
|
confirmationController.signal.aborted ||
|
|
818
769
|
(deadlineAt !== null && Date.now() >= deadlineAt)
|
|
819
770
|
) {
|
|
820
|
-
throw replicationLagTimeout(request, current);
|
|
771
|
+
throw replicationLagTimeout(request, current, requestTimeoutMs);
|
|
821
772
|
}
|
|
822
773
|
throw error;
|
|
823
774
|
} finally {
|
|
@@ -1128,57 +1079,6 @@ export function createHttpTransport(options: HttpTransportOptions): HttpTranspor
|
|
|
1128
1079
|
});
|
|
1129
1080
|
}
|
|
1130
1081
|
|
|
1131
|
-
function createClientTxId(idempotencyKey?: string | null): string {
|
|
1132
|
-
if (idempotencyKey && idempotencyKey.length > 0) return idempotencyKey;
|
|
1133
|
-
return typeof crypto !== 'undefined' && typeof crypto.randomUUID === 'function'
|
|
1134
|
-
? crypto.randomUUID()
|
|
1135
|
-
: `tx_${Date.now()}_${Math.random().toString(36).slice(2, 10)}`;
|
|
1136
|
-
}
|
|
1137
|
-
|
|
1138
|
-
function createModelId(modelName: string, idempotencyKey?: string | null): string {
|
|
1139
|
-
if (idempotencyKey) {
|
|
1140
|
-
return uuidv5(`${modelName}:${idempotencyKey}`, 'aa4ba6d4-bf0b-5b38-9c45-116f79a6e548');
|
|
1141
|
-
}
|
|
1142
|
-
return typeof crypto !== 'undefined' && typeof crypto.randomUUID === 'function'
|
|
1143
|
-
? crypto.randomUUID()
|
|
1144
|
-
: `id_${Date.now()}_${Math.random().toString(36).slice(2, 10)}`;
|
|
1145
|
-
}
|
|
1146
|
-
|
|
1147
|
-
function normalizeCommitOperation(
|
|
1148
|
-
op: CommitOperationInput,
|
|
1149
|
-
defaults: Pick<CommitCreateOptions, 'readAt' | 'onStale'>,
|
|
1150
|
-
fence: BatchFence | null,
|
|
1151
|
-
claim: Claim | null,
|
|
1152
|
-
): CommitOperationInput {
|
|
1153
|
-
return {
|
|
1154
|
-
action: op.action,
|
|
1155
|
-
model: op.model,
|
|
1156
|
-
id: op.id ?? null,
|
|
1157
|
-
data: op.data ?? null,
|
|
1158
|
-
where: op.where ?? null,
|
|
1159
|
-
transactionId: op.transactionId ?? null,
|
|
1160
|
-
claimId:
|
|
1161
|
-
op.claimId ?? claimIdFor(claim?.target, claim?.id, op.model, op.id ?? null),
|
|
1162
|
-
readAt: op.readAt ?? defaults.readAt ?? null,
|
|
1163
|
-
onStale: op.onStale ?? defaults.onStale ?? null,
|
|
1164
|
-
fenceToken: op.fenceToken ?? fenceTokenFor(fence, op.model, op.id ?? null),
|
|
1165
|
-
};
|
|
1166
|
-
}
|
|
1167
|
-
|
|
1168
|
-
function normalizeCommitOperations(
|
|
1169
|
-
commitOptions: CommitCreateOptions,
|
|
1170
|
-
fence: BatchFence | null
|
|
1171
|
-
): readonly CommitOperationInput[] {
|
|
1172
|
-
if (commitOptions.operations.length === 0) {
|
|
1173
|
-
throw new AbloValidationError('Commit requires a non-empty `operations` array.', {
|
|
1174
|
-
code: 'commit_operation_required',
|
|
1175
|
-
});
|
|
1176
|
-
}
|
|
1177
|
-
return commitOptions.operations.map((op) =>
|
|
1178
|
-
normalizeCommitOperation(op, commitOptions, fence, commitOptions.claim ?? null)
|
|
1179
|
-
);
|
|
1180
|
-
}
|
|
1181
|
-
|
|
1182
1082
|
async function listClaimState(
|
|
1183
1083
|
target?: Partial<ModelTarget>
|
|
1184
1084
|
): Promise<{ active: readonly ModelClaim[]; queue: readonly ModelClaim[] }> {
|
|
@@ -1374,11 +1274,9 @@ export function createHttpTransport(options: HttpTransportOptions): HttpTranspor
|
|
|
1374
1274
|
{
|
|
1375
1275
|
idempotencyKey: commitOptions.idempotencyKey,
|
|
1376
1276
|
readAt: commitOptions.readAt,
|
|
1377
|
-
onStale: commitOptions.onStale,
|
|
1378
1277
|
wait: commitOptions.wait,
|
|
1379
1278
|
claim: commitOptions.claim,
|
|
1380
1279
|
reads: commitOptions.reads,
|
|
1381
|
-
track: commitOptions.track,
|
|
1382
1280
|
},
|
|
1383
1281
|
'commits.create'
|
|
1384
1282
|
);
|
|
@@ -1390,14 +1288,12 @@ export function createHttpTransport(options: HttpTransportOptions): HttpTranspor
|
|
|
1390
1288
|
{
|
|
1391
1289
|
...commitOptions,
|
|
1392
1290
|
readAt: commitOptions.readAt ?? claim?.readAt ?? null,
|
|
1393
|
-
onStale: commitOptions.onStale ?? (claim?.readAt !== undefined ? 'reject' : null),
|
|
1394
1291
|
},
|
|
1395
1292
|
batchFence(claim?.target, claim?.fenceToken)
|
|
1396
1293
|
);
|
|
1397
1294
|
const requestBody = {
|
|
1398
1295
|
operations,
|
|
1399
1296
|
reads: commitOptions.reads,
|
|
1400
|
-
track: commitOptions.track,
|
|
1401
1297
|
};
|
|
1402
1298
|
const wait = commitOptions.wait ?? 'confirmed';
|
|
1403
1299
|
let body: CommitResponse;
|
|
@@ -1433,9 +1329,6 @@ export function createHttpTransport(options: HttpTransportOptions): HttpTranspor
|
|
|
1433
1329
|
id: body.id ?? body.clientTxId,
|
|
1434
1330
|
status: body.status,
|
|
1435
1331
|
lastSyncId: body.lastSyncId,
|
|
1436
|
-
...(body.notifications && body.notifications.length > 0
|
|
1437
|
-
? { notifications: body.notifications }
|
|
1438
|
-
: {}),
|
|
1439
1332
|
...(body.missingIds && body.missingIds.length > 0 ? { missingIds: body.missingIds } : {}),
|
|
1440
1333
|
...(body.operationResults && body.operationResults.length > 0
|
|
1441
1334
|
? { operationResults: body.operationResults }
|
|
@@ -1549,7 +1442,7 @@ export function createHttpTransport(options: HttpTransportOptions): HttpTranspor
|
|
|
1549
1442
|
};
|
|
1550
1443
|
}
|
|
1551
1444
|
|
|
1552
|
-
async function
|
|
1445
|
+
async function readModel<T>(
|
|
1553
1446
|
modelName: string,
|
|
1554
1447
|
params: ModelReadOptions & { readonly id: string }
|
|
1555
1448
|
): Promise<HttpTransportRead<T>> {
|
|
@@ -1562,7 +1455,7 @@ export function createHttpTransport(options: HttpTransportOptions): HttpTranspor
|
|
|
1562
1455
|
);
|
|
1563
1456
|
|
|
1564
1457
|
// A miss is `data: undefined`, not a thrown error. The WebSocket client's
|
|
1565
|
-
// `
|
|
1458
|
+
// `read` returns `T | undefined` for a missing row; throwing only here
|
|
1566
1459
|
// made the obvious read ("does this row exist?") a hard edge that an agent
|
|
1567
1460
|
// had to wrap in try/catch. Both transports agree: an absent row means absent
|
|
1568
1461
|
// data. Callers branch on `.data` (the documented `.data?.x` usage).
|
|
@@ -1598,15 +1491,14 @@ export function createHttpTransport(options: HttpTransportOptions): HttpTranspor
|
|
|
1598
1491
|
options && {
|
|
1599
1492
|
idempotencyKey: options.idempotencyKey,
|
|
1600
1493
|
readAt: options.readAt,
|
|
1601
|
-
onStale: options.onStale,
|
|
1602
1494
|
claim: options.claim,
|
|
1603
1495
|
claimRef: options.claimRef,
|
|
1604
1496
|
fenceToken: options.fenceToken,
|
|
1605
1497
|
reads: options.reads,
|
|
1606
|
-
track: options.track,
|
|
1607
1498
|
},
|
|
1608
1499
|
`${modelName} ${action}`
|
|
1609
1500
|
);
|
|
1501
|
+
if (action !== 'create') assertWriteTarget(action, modelName, id);
|
|
1610
1502
|
const clientTxId = createClientTxId(options?.idempotencyKey);
|
|
1611
1503
|
const encModel = encodeURIComponent(modelName);
|
|
1612
1504
|
const path =
|
|
@@ -1628,10 +1520,8 @@ export function createHttpTransport(options: HttpTransportOptions): HttpTranspor
|
|
|
1628
1520
|
const readAt = options?.readAt ?? claimHandle?.readAt;
|
|
1629
1521
|
const requestBody: Record<string, unknown> = {
|
|
1630
1522
|
claim: normalizeClaimId(options?.claimRef) ?? claimHandle?.id,
|
|
1631
|
-
onStale: options?.onStale ?? (claimHandle?.readAt !== undefined ? 'reject' : undefined),
|
|
1632
1523
|
readAt,
|
|
1633
1524
|
reads: options?.reads,
|
|
1634
|
-
track: options?.track,
|
|
1635
1525
|
// The claim's fencing token (Option B), so the per-model HTTP write door
|
|
1636
1526
|
// fences the same as the WS proxy and `commits.create`.
|
|
1637
1527
|
fenceToken: options?.fenceToken ?? claimHandle?.fenceToken,
|
|
@@ -1798,9 +1688,23 @@ export function createHttpTransport(options: HttpTransportOptions): HttpTranspor
|
|
|
1798
1688
|
params: ClaimSkipParams<Fields>
|
|
1799
1689
|
): Promise<HeldClaim<T> | null>;
|
|
1800
1690
|
function claimImpl(params: ClaimParams<Fields>): Promise<HeldClaim<T>>;
|
|
1691
|
+
function claimImpl(
|
|
1692
|
+
id: string,
|
|
1693
|
+
opts: ClaimSkipOptions<Fields>
|
|
1694
|
+
): Promise<HeldLease | null>;
|
|
1695
|
+
function claimImpl(id: string, opts?: ClaimOptions<Fields>): Promise<HeldLease>;
|
|
1801
1696
|
async function claimImpl(
|
|
1802
|
-
|
|
1803
|
-
|
|
1697
|
+
idOrParams: string | ClaimParams<Fields>,
|
|
1698
|
+
opts?: ClaimOptions<Fields>,
|
|
1699
|
+
): Promise<HeldClaim<T> | HeldLease | null> {
|
|
1700
|
+
// The row-free form names a key by id alone. Ablo has never held that
|
|
1701
|
+
// row, so there is no snapshot to take after the grant and no `data` on
|
|
1702
|
+
// the handle: the lease is the whole answer. The object form re-reads
|
|
1703
|
+
// the row under the lease and hands back a `HeldClaim`.
|
|
1704
|
+
const rowFree = typeof idOrParams === 'string';
|
|
1705
|
+
const params: ClaimParams<Fields> = rowFree
|
|
1706
|
+
? { ...(opts ?? {}), id: idOrParams }
|
|
1707
|
+
: idOrParams;
|
|
1804
1708
|
let acquired: { id: string; fenceToken?: number };
|
|
1805
1709
|
try {
|
|
1806
1710
|
acquired = await acquireClaim(params);
|
|
@@ -1827,16 +1731,6 @@ export function createHttpTransport(options: HttpTransportOptions): HttpTranspor
|
|
|
1827
1731
|
id: params.id,
|
|
1828
1732
|
description: claimDescription(params),
|
|
1829
1733
|
});
|
|
1830
|
-
const { data, stamp } = await retrieveModel<T>(name, { id: params.id });
|
|
1831
|
-
// A held claim hands back a snapshot; the typed `HeldClaim.data` is `T`.
|
|
1832
|
-
// `retrieve` now reports a miss as `undefined` rather than throwing, but a
|
|
1833
|
-
// claim on a row that doesn't exist has nothing to hold — surface it.
|
|
1834
|
-
if (data === undefined) {
|
|
1835
|
-
throw new AbloNotFoundError(
|
|
1836
|
-
`Cannot claim ${name}/${params.id}: it does not exist (or is outside this credential's scope).`,
|
|
1837
|
-
[params.id]
|
|
1838
|
-
);
|
|
1839
|
-
}
|
|
1840
1734
|
// One reading of the heartbeat options — cadence and callbacks from
|
|
1841
1735
|
// whichever spelling the caller used (plan object, shorthand, or the
|
|
1842
1736
|
// deprecated flat callbacks).
|
|
@@ -1876,10 +1770,9 @@ export function createHttpTransport(options: HttpTransportOptions): HttpTranspor
|
|
|
1876
1770
|
// way. `subTarget` is wire-shaped by contract, including here, where the
|
|
1877
1771
|
// value happens to have started out declared.
|
|
1878
1772
|
const { meta, ...narrowed } = subTarget(params, name);
|
|
1879
|
-
|
|
1773
|
+
const lease: HeldLease = {
|
|
1880
1774
|
object: 'claim',
|
|
1881
1775
|
id: claimId,
|
|
1882
|
-
readAt: stamp,
|
|
1883
1776
|
...(fenceToken !== undefined ? { fenceToken } : {}),
|
|
1884
1777
|
target: {
|
|
1885
1778
|
...streamTarget({ model: name, id: params.id }),
|
|
@@ -1887,7 +1780,6 @@ export function createHttpTransport(options: HttpTransportOptions): HttpTranspor
|
|
|
1887
1780
|
...(meta !== undefined ? { meta: declaredMeta(meta) } : {}),
|
|
1888
1781
|
},
|
|
1889
1782
|
description: claimDescription(params),
|
|
1890
|
-
data,
|
|
1891
1783
|
release,
|
|
1892
1784
|
revoke: () => {
|
|
1893
1785
|
void release().catch(() => {});
|
|
@@ -1895,6 +1787,24 @@ export function createHttpTransport(options: HttpTransportOptions): HttpTranspor
|
|
|
1895
1787
|
heartbeat,
|
|
1896
1788
|
[Symbol.asyncDispose]: release,
|
|
1897
1789
|
};
|
|
1790
|
+
if (rowFree) return lease;
|
|
1791
|
+
|
|
1792
|
+
const { data, stamp } = await readModel<T>(name, { id: params.id });
|
|
1793
|
+
// A held claim hands back a snapshot; the typed `HeldClaim.data` is `T`.
|
|
1794
|
+
// `retrieve` reports a miss as `undefined`, and a claim on a row that does
|
|
1795
|
+
// not exist has nothing to hold. The grant came BEFORE this read, so the
|
|
1796
|
+
// miss must give the lease back first: otherwise the key stays held under
|
|
1797
|
+
// this credential until the TTL lapses, behind no handle anyone can
|
|
1798
|
+
// release, and every other participant is refused for the duration.
|
|
1799
|
+
if (data === undefined) {
|
|
1800
|
+
await release().catch(() => undefined);
|
|
1801
|
+
throw new AbloNotFoundError(
|
|
1802
|
+
`Cannot claim ${name}/${params.id}: it does not exist (or is outside this credential's scope). ` +
|
|
1803
|
+
`To hold a key before its row exists, claim it by id alone: claim('${params.id}') returns a lease without a snapshot.`,
|
|
1804
|
+
[params.id]
|
|
1805
|
+
);
|
|
1806
|
+
}
|
|
1807
|
+
return { ...lease, readAt: stamp, data };
|
|
1898
1808
|
}
|
|
1899
1809
|
const claimsForEntity = (
|
|
1900
1810
|
params: ClaimLookupParams<T>
|
|
@@ -1906,7 +1816,7 @@ export function createHttpTransport(options: HttpTransportOptions): HttpTranspor
|
|
|
1906
1816
|
{ method: 'GET' },
|
|
1907
1817
|
claimListResponseSchema
|
|
1908
1818
|
);
|
|
1909
|
-
const claim = Object.assign(claimImpl, {
|
|
1819
|
+
const claim: HttpClaimApi<T, Fields> = Object.assign(claimImpl, {
|
|
1910
1820
|
release: releaseClaim,
|
|
1911
1821
|
state: async (params: ClaimLookupParams<T>): Promise<Claim | null> => {
|
|
1912
1822
|
const res = await claimsForEntity(params);
|
|
@@ -1914,6 +1824,19 @@ export function createHttpTransport(options: HttpTransportOptions): HttpTranspor
|
|
|
1914
1824
|
const first = res.data.find((row) => row.status !== 'queued');
|
|
1915
1825
|
return first ? claimFromModelClaim(first) : null;
|
|
1916
1826
|
},
|
|
1827
|
+
// Every holder, from the same one read `state` takes its first entry
|
|
1828
|
+
// from: the server lists holders before waiters, and the caller's own
|
|
1829
|
+
// lease before its peers'. (This member was missing for as long as the
|
|
1830
|
+
// namespace was cast to its type instead of typed as it.)
|
|
1831
|
+
list: async (params: ClaimLookupParams<T>) => {
|
|
1832
|
+
const res = await claimsForEntity(params);
|
|
1833
|
+
return {
|
|
1834
|
+
object: 'list' as const,
|
|
1835
|
+
data: res.data
|
|
1836
|
+
.filter((row) => row.status !== 'queued')
|
|
1837
|
+
.map(claimFromModelClaim),
|
|
1838
|
+
};
|
|
1839
|
+
},
|
|
1917
1840
|
queue: async (
|
|
1918
1841
|
params: ClaimLookupParams<T>
|
|
1919
1842
|
): Promise<ClaimQueueView> => {
|
|
@@ -1934,7 +1857,7 @@ export function createHttpTransport(options: HttpTransportOptions): HttpTranspor
|
|
|
1934
1857
|
}),
|
|
1935
1858
|
});
|
|
1936
1859
|
},
|
|
1937
|
-
})
|
|
1860
|
+
});
|
|
1938
1861
|
|
|
1939
1862
|
const withMutationClaim = async <R>(
|
|
1940
1863
|
id: string,
|
|
@@ -1945,12 +1868,23 @@ export function createHttpTransport(options: HttpTransportOptions): HttpTranspor
|
|
|
1945
1868
|
if (!claimInput) return run(input);
|
|
1946
1869
|
|
|
1947
1870
|
if (isClaimHandle(claimInput)) {
|
|
1871
|
+
// The lease's watermark travels with it. Unwrapping the handle to a
|
|
1872
|
+
// `claimRef` is what put this here: `mutateModel` reads `readAt` off a
|
|
1873
|
+
// handle on `claim`, and this sets `claim: undefined` before it looks,
|
|
1874
|
+
// so the stale guard was silently dropped on every write that named a
|
|
1875
|
+
// handle. The result was mutual exclusion without lost-update
|
|
1876
|
+
// detection, on the transport agents run, under code that reads as
|
|
1877
|
+
// though it had both. The reactive client binds the same three values
|
|
1878
|
+
// from the claim it holds; a caller's own `readAt` wins.
|
|
1948
1879
|
return run({
|
|
1949
1880
|
...input,
|
|
1950
1881
|
claimRef: { id: claimInput.id },
|
|
1951
1882
|
...(claimInput.fenceToken !== undefined
|
|
1952
1883
|
? { fenceToken: claimInput.fenceToken }
|
|
1953
1884
|
: {}),
|
|
1885
|
+
...(input?.readAt === undefined && claimInput.readAt !== undefined
|
|
1886
|
+
? { readAt: claimInput.readAt }
|
|
1887
|
+
: {}),
|
|
1954
1888
|
claim: undefined,
|
|
1955
1889
|
});
|
|
1956
1890
|
}
|
|
@@ -1996,7 +1930,7 @@ export function createHttpTransport(options: HttpTransportOptions): HttpTranspor
|
|
|
1996
1930
|
): Promise<CommitReceipt | undefined> {
|
|
1997
1931
|
// Functional form: update(id, current => next). The SDK owns the
|
|
1998
1932
|
// read-fresh → compute → compare-and-swap → reconcile loop; correctness
|
|
1999
|
-
// rides on the row's watermark (readAt
|
|
1933
|
+
// rides on the row's watermark (`readAt`), so no claim
|
|
2000
1934
|
// or per-participant identity is needed and contention never clobbers.
|
|
2001
1935
|
if (typeof arg === 'string') {
|
|
2002
1936
|
const id = arg;
|
|
@@ -2011,13 +1945,12 @@ export function createHttpTransport(options: HttpTransportOptions): HttpTranspor
|
|
|
2011
1945
|
model: name,
|
|
2012
1946
|
id,
|
|
2013
1947
|
readFresh: async () => {
|
|
2014
|
-
const read = await
|
|
1948
|
+
const read = await readModel<T>(name, { id });
|
|
2015
1949
|
return { data: read.data, stamp: read.stamp };
|
|
2016
1950
|
},
|
|
2017
1951
|
writeNext: (patch, readAt) =>
|
|
2018
1952
|
mutateModel('update', name, id, patch, {
|
|
2019
1953
|
readAt,
|
|
2020
|
-
onStale: 'reject',
|
|
2021
1954
|
}),
|
|
2022
1955
|
});
|
|
2023
1956
|
}
|
|
@@ -2030,11 +1963,8 @@ export function createHttpTransport(options: HttpTransportOptions): HttpTranspor
|
|
|
2030
1963
|
|
|
2031
1964
|
return {
|
|
2032
1965
|
claim,
|
|
2033
|
-
|
|
2034
|
-
return
|
|
2035
|
-
},
|
|
2036
|
-
retrieve(params: ModelReadOptions & { readonly id: string }): Promise<HttpTransportRead<T>> {
|
|
2037
|
-
return retrieveModel<T>(name, params);
|
|
1966
|
+
read(params: ModelReadOptions & { readonly id: string }): Promise<HttpTransportRead<T>> {
|
|
1967
|
+
return readModel<T>(name, params);
|
|
2038
1968
|
},
|
|
2039
1969
|
list(options?: ServerReadOptions<T>): ReturnType<typeof listModel<T>> {
|
|
2040
1970
|
return listModel<T>(name, options);
|
|
@@ -2061,7 +1991,7 @@ export function createHttpTransport(options: HttpTransportOptions): HttpTranspor
|
|
|
2061
1991
|
params.data,
|
|
2062
1992
|
options,
|
|
2063
1993
|
async () => {
|
|
2064
|
-
const read = await
|
|
1994
|
+
const read = await readModel<T>(name, { id });
|
|
2065
1995
|
if (read.data === undefined) {
|
|
2066
1996
|
throw new AbloNotFoundError(
|
|
2067
1997
|
`create ${name}/${id} did not yield a readable row (the write did not confirm).`,
|
|
@@ -2079,6 +2009,60 @@ export function createHttpTransport(options: HttpTransportOptions): HttpTranspor
|
|
|
2079
2009
|
return created;
|
|
2080
2010
|
});
|
|
2081
2011
|
},
|
|
2012
|
+
/**
|
|
2013
|
+
* Creates many rows as ONE commit, and returns them.
|
|
2014
|
+
*
|
|
2015
|
+
* Atomic on purpose: a batch that half-lands leaves the caller to work
|
|
2016
|
+
* out which half, and every other write door here declines whole. One
|
|
2017
|
+
* rejected row declines the batch.
|
|
2018
|
+
*
|
|
2019
|
+
* A fresh receipt returns the authoritative rows directly from the
|
|
2020
|
+
* writing transaction. A durable idempotency replay deliberately redacts
|
|
2021
|
+
* those rows, so that path verifies every deterministic id with a point
|
|
2022
|
+
* read and fails loudly if policy prevents a complete answer. Neither
|
|
2023
|
+
* path can report a partial collection as success.
|
|
2024
|
+
*
|
|
2025
|
+
* Ids are resolved here rather than left to the server, so the results
|
|
2026
|
+
* can be returned in the caller's own order rather than the order the
|
|
2027
|
+
* transaction happened to settle them.
|
|
2028
|
+
*/
|
|
2029
|
+
async createMany(
|
|
2030
|
+
params: ModelCreateManyParams<Record<string, unknown>>
|
|
2031
|
+
): Promise<T[]> {
|
|
2032
|
+
if (params.data.length === 0) return [];
|
|
2033
|
+
|
|
2034
|
+
// A claim/stale guard addresses one existing row, so the canonical
|
|
2035
|
+
// batch-create options do not admit those fields at all.
|
|
2036
|
+
const { data, ...options } = params;
|
|
2037
|
+
const ids = data.map(
|
|
2038
|
+
(row, index) =>
|
|
2039
|
+
resolveCreateId(undefined, row) ??
|
|
2040
|
+
createModelId(
|
|
2041
|
+
name,
|
|
2042
|
+
params.idempotencyKey ? `${params.idempotencyKey}:${index}` : null
|
|
2043
|
+
)
|
|
2044
|
+
);
|
|
2045
|
+
const receipt = await commits.create({
|
|
2046
|
+
...options,
|
|
2047
|
+
operations: data.map((row, index) => ({
|
|
2048
|
+
action: 'create' as const,
|
|
2049
|
+
model: name,
|
|
2050
|
+
id: ids[index] ?? null,
|
|
2051
|
+
data: row,
|
|
2052
|
+
})),
|
|
2053
|
+
wait: 'confirmed',
|
|
2054
|
+
});
|
|
2055
|
+
|
|
2056
|
+
return resolveCreatedRows<T>({
|
|
2057
|
+
modelName: name,
|
|
2058
|
+
ids,
|
|
2059
|
+
operationResults: receipt.operationResults,
|
|
2060
|
+
readRow: async (id) => {
|
|
2061
|
+
const read = await readModel<T>(name, { id });
|
|
2062
|
+
return read.data;
|
|
2063
|
+
},
|
|
2064
|
+
});
|
|
2065
|
+
},
|
|
2082
2066
|
update: updateModel,
|
|
2083
2067
|
async delete(params: ModelMutationOptions & { readonly id: string }): Promise<CommitReceipt> {
|
|
2084
2068
|
return withMutationClaim(params.id, params, async (options) => {
|
|
@@ -2086,29 +2070,6 @@ export function createHttpTransport(options: HttpTransportOptions): HttpTranspor
|
|
|
2086
2070
|
return mutateModel('delete', name, params.id, undefined, options);
|
|
2087
2071
|
});
|
|
2088
2072
|
},
|
|
2089
|
-
async track(params: ModelTrackParams): Promise<ModelTrackResult> {
|
|
2090
|
-
const dependency: TrackDependency = {
|
|
2091
|
-
model: name.toLowerCase(),
|
|
2092
|
-
id: params.id,
|
|
2093
|
-
...(params.readAt !== undefined ? { readAt: params.readAt } : {}),
|
|
2094
|
-
};
|
|
2095
|
-
// A track carries no write, so it rides the commit lane as a
|
|
2096
|
-
// zero-operation body — the shape `/v1/commits` accepts for registering
|
|
2097
|
-
// a premise without one. Going through the same durable lane as every
|
|
2098
|
-
// other commit means a disconnect replays the registration rather than
|
|
2099
|
-
// dropping it, and a notification that had already fired is not lost to
|
|
2100
|
-
// a retry.
|
|
2101
|
-
const body = await dispatchHttpCommit({
|
|
2102
|
-
path: '/v1/commits',
|
|
2103
|
-
method: 'POST',
|
|
2104
|
-
idempotencyKey: createClientTxId(),
|
|
2105
|
-
body: { track: [dependency] },
|
|
2106
|
-
wait: 'confirmed',
|
|
2107
|
-
});
|
|
2108
|
-
return body.notifications && body.notifications.length > 0
|
|
2109
|
-
? { notifications: body.notifications }
|
|
2110
|
-
: {};
|
|
2111
|
-
},
|
|
2112
2073
|
};
|
|
2113
2074
|
}
|
|
2114
2075
|
|
|
@@ -2123,6 +2084,8 @@ export function createHttpTransport(options: HttpTransportOptions): HttpTranspor
|
|
|
2123
2084
|
}),
|
|
2124
2085
|
dispose() {
|
|
2125
2086
|
if (!disposePromise) {
|
|
2087
|
+
for (const controller of readChangeControllers) controller.abort();
|
|
2088
|
+
readChangeControllers.clear();
|
|
2126
2089
|
const scheduledCommits = httpCommitLane;
|
|
2127
2090
|
disposePromise = (async () => {
|
|
2128
2091
|
await scheduledCommits;
|
|
@@ -2132,6 +2095,7 @@ export function createHttpTransport(options: HttpTransportOptions): HttpTranspor
|
|
|
2132
2095
|
return disposePromise;
|
|
2133
2096
|
},
|
|
2134
2097
|
async purge() {},
|
|
2098
|
+
onChange,
|
|
2135
2099
|
commits,
|
|
2136
2100
|
claims,
|
|
2137
2101
|
logs,
|