@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,231 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The catalog of documentation this package ships.
|
|
3
|
+
*
|
|
4
|
+
* One definition of *which docs exist*, read from the files themselves. Every
|
|
5
|
+
* reader — `ablo docs`, the public `/api/docs/*` routes, the MCP docs tools —
|
|
6
|
+
* resolves through here rather than keeping its own list, because a
|
|
7
|
+
* hand-maintained index of a directory is a copy that drifts the moment a page
|
|
8
|
+
* is added and nothing fails when it does. Before this module the public web
|
|
9
|
+
* allowlist had fallen 21 pages behind the corpus, including `coordination`.
|
|
10
|
+
*
|
|
11
|
+
* Title and description are DERIVED from each file's own convention: an H1,
|
|
12
|
+
* then a one-paragraph blockquote stating what the page is for. That blockquote
|
|
13
|
+
* is the description everywhere it is needed — the site frontmatter lifts the
|
|
14
|
+
* same line — so a page states its own promise exactly once, in the source that
|
|
15
|
+
* ships in the npm tarball and still reads correctly as plain markdown.
|
|
16
|
+
*
|
|
17
|
+
* The published set mirrors the tarball's `files` globs (`docs/*.md`,
|
|
18
|
+
* `docs/examples/*.md`, plus the three root files). Anything else under `docs/`
|
|
19
|
+
* — `docs/internal/**` above all — is neither shipped nor catalogued, and that
|
|
20
|
+
* exclusion is the only thing keeping internal notes off the public routes now
|
|
21
|
+
* that they read from here.
|
|
22
|
+
*/
|
|
23
|
+
import { readdir, readFile } from 'node:fs/promises';
|
|
24
|
+
import { basename, join } from 'node:path';
|
|
25
|
+
const MARKDOWN_MIME = 'text/markdown; charset=utf-8';
|
|
26
|
+
const TEXT_MIME = 'text/plain; charset=utf-8';
|
|
27
|
+
/**
|
|
28
|
+
* The three files that document the package itself rather than a topic. They
|
|
29
|
+
* live at the package root, not under `docs/`, and none follows the H1 +
|
|
30
|
+
* blockquote convention — `llms.txt` opens with a prose paragraph and
|
|
31
|
+
* `README.md` with a banner — so their titles and descriptions are curated
|
|
32
|
+
* here, the one place that knows they are a different kind of artifact.
|
|
33
|
+
*
|
|
34
|
+
* Their slug is their filename, because the filename IS how these are referred
|
|
35
|
+
* to everywhere (`AGENTS.md` is an ecosystem convention, not a topic name) and
|
|
36
|
+
* because a bare word would collide: `docs/agents.md` is a published guide that
|
|
37
|
+
* the docs index cross-links as `agents`, and whichever of the two won that
|
|
38
|
+
* name would silently shadow the other. Friendlier spellings are aliases below.
|
|
39
|
+
*/
|
|
40
|
+
const PACKAGE_FILES = [
|
|
41
|
+
{
|
|
42
|
+
filename: 'AGENTS.md',
|
|
43
|
+
title: 'AGENTS.md',
|
|
44
|
+
description: 'The playbook a coding agent follows to install and drive Ablo without hanging on a prompt.',
|
|
45
|
+
mime: MARKDOWN_MIME,
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
filename: 'README.md',
|
|
49
|
+
title: 'README',
|
|
50
|
+
description: 'Package overview — what Ablo is and the shape of the API.',
|
|
51
|
+
mime: MARKDOWN_MIME,
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
filename: 'llms.txt',
|
|
55
|
+
title: 'llms.txt',
|
|
56
|
+
description: 'The curated single-file index of the whole API, for machine readers.',
|
|
57
|
+
mime: TEXT_MIME,
|
|
58
|
+
},
|
|
59
|
+
];
|
|
60
|
+
/**
|
|
61
|
+
* Curated redirects for references that are not a slug: the friendly spellings
|
|
62
|
+
* of the root files, plus the renames the public URLs carried before this
|
|
63
|
+
* module existed, kept so old links and any agent working from a cached page
|
|
64
|
+
* still resolve. Identity mappings are NOT listed — a slug resolves to itself
|
|
65
|
+
* by derivation, and restating the other 30 here would rebuild the
|
|
66
|
+
* hand-maintained list this module exists to delete.
|
|
67
|
+
*/
|
|
68
|
+
const SLUG_ALIASES = {
|
|
69
|
+
readme: 'README.md',
|
|
70
|
+
overview: 'README.md',
|
|
71
|
+
llms: 'llms.txt',
|
|
72
|
+
storage: 'data-sources',
|
|
73
|
+
'docs/storage.md': 'data-sources',
|
|
74
|
+
};
|
|
75
|
+
/**
|
|
76
|
+
* Read the catalog from a package root — the directory holding `docs/` and the
|
|
77
|
+
* three root files.
|
|
78
|
+
*
|
|
79
|
+
* The root is a parameter rather than resolved here because each reader knows
|
|
80
|
+
* it differently and they are genuinely different facts: the CLI resolves it
|
|
81
|
+
* against its own bundle inside `node_modules`, while the web app resolves it
|
|
82
|
+
* against the monorepo checkout. Nothing is cached; callers that serve many
|
|
83
|
+
* requests should memoize the returned array.
|
|
84
|
+
*/
|
|
85
|
+
export async function readDocsCatalog(packageRoot) {
|
|
86
|
+
const docsDir = join(packageRoot, 'docs');
|
|
87
|
+
const entries = [];
|
|
88
|
+
entries.push(...(await readDocsDirectory(docsDir, 'guide')));
|
|
89
|
+
entries.push(...(await readDocsDirectory(join(docsDir, 'examples'), 'example')));
|
|
90
|
+
for (const file of PACKAGE_FILES) {
|
|
91
|
+
const path = join(packageRoot, file.filename);
|
|
92
|
+
const body = await readFileOrNull(path);
|
|
93
|
+
if (body === null)
|
|
94
|
+
continue;
|
|
95
|
+
entries.push({
|
|
96
|
+
slug: file.filename,
|
|
97
|
+
title: file.title,
|
|
98
|
+
description: file.description,
|
|
99
|
+
kind: 'package',
|
|
100
|
+
path,
|
|
101
|
+
mime: file.mime,
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
return entries.sort((a, b) => a.slug.localeCompare(b.slug));
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Read one flat directory of markdown. Deliberately non-recursive: the shipped
|
|
108
|
+
* set is `docs/*.md` plus `docs/examples/*.md`, so descending would catalogue
|
|
109
|
+
* `docs/internal/**` — notes that are not in the tarball and must not reach a
|
|
110
|
+
* public route.
|
|
111
|
+
*/
|
|
112
|
+
async function readDocsDirectory(dir, kind) {
|
|
113
|
+
let names;
|
|
114
|
+
try {
|
|
115
|
+
const found = await readdir(dir, { withFileTypes: true });
|
|
116
|
+
names = found.filter((e) => e.isFile() && e.name.endsWith('.md')).map((e) => e.name);
|
|
117
|
+
}
|
|
118
|
+
catch {
|
|
119
|
+
return [];
|
|
120
|
+
}
|
|
121
|
+
const entries = [];
|
|
122
|
+
for (const name of names) {
|
|
123
|
+
const path = join(dir, name);
|
|
124
|
+
const body = await readFileOrNull(path);
|
|
125
|
+
if (body === null)
|
|
126
|
+
continue;
|
|
127
|
+
const stem = basename(name, '.md');
|
|
128
|
+
const { title, description } = parseDocHeader(body);
|
|
129
|
+
entries.push({
|
|
130
|
+
slug: kind === 'example' ? `examples/${stem}` : stem,
|
|
131
|
+
title: title ?? stem,
|
|
132
|
+
description,
|
|
133
|
+
kind,
|
|
134
|
+
path,
|
|
135
|
+
mime: MARKDOWN_MIME,
|
|
136
|
+
});
|
|
137
|
+
}
|
|
138
|
+
return entries;
|
|
139
|
+
}
|
|
140
|
+
/** The H1 a page opens with, and the blockquote paragraph that follows it. */
|
|
141
|
+
const H1_LINE = /^#[ \t]+(.+?)[ \t]*$/m;
|
|
142
|
+
const PROMISE_BLOCKQUOTE = /^\s*\n((?:>.*\n)+)/;
|
|
143
|
+
/**
|
|
144
|
+
* Pull a page's title and promise line out of its markdown.
|
|
145
|
+
*
|
|
146
|
+
* The convention every page follows: an H1, then a blockquote paragraph saying
|
|
147
|
+
* what the page is for. A page missing either simply reports what it has — the
|
|
148
|
+
* catalog never invents prose.
|
|
149
|
+
*/
|
|
150
|
+
export function parseDocHeader(body) {
|
|
151
|
+
const heading = H1_LINE.exec(body);
|
|
152
|
+
const title = heading?.[1] ?? null;
|
|
153
|
+
const afterHeading = heading === null ? body : body.slice(heading.index + heading[0].length);
|
|
154
|
+
const promise = PROMISE_BLOCKQUOTE.exec(afterHeading);
|
|
155
|
+
const description = promise?.[1]
|
|
156
|
+
?.split('\n')
|
|
157
|
+
.filter(Boolean)
|
|
158
|
+
.map((line) => line.replace(/^>\s?/, ''))
|
|
159
|
+
.join(' ')
|
|
160
|
+
.trim() ?? '';
|
|
161
|
+
return { title, description };
|
|
162
|
+
}
|
|
163
|
+
/**
|
|
164
|
+
* Resolve a reference to a page. Accepts the slug (`coordination`), a curated
|
|
165
|
+
* alias (`storage`), or a repo-relative path (`docs/coordination.md`,
|
|
166
|
+
* `AGENTS.md`) — the three forms readers actually arrive with. Returns null
|
|
167
|
+
* rather than throwing so a caller can render its own not-found.
|
|
168
|
+
*/
|
|
169
|
+
export function findDoc(catalog, reference) {
|
|
170
|
+
const trimmed = reference.trim();
|
|
171
|
+
if (trimmed === '')
|
|
172
|
+
return null;
|
|
173
|
+
const direct = matchSlug(catalog, trimmed);
|
|
174
|
+
if (direct)
|
|
175
|
+
return direct;
|
|
176
|
+
const aliased = SLUG_ALIASES[trimmed.toLowerCase()];
|
|
177
|
+
if (aliased) {
|
|
178
|
+
const target = matchSlug(catalog, aliased);
|
|
179
|
+
if (target)
|
|
180
|
+
return target;
|
|
181
|
+
}
|
|
182
|
+
// Path form: `docs/coordination.md`, `docs/examples/nextjs.md`, `llms.txt`.
|
|
183
|
+
const asSlug = trimmed
|
|
184
|
+
.replace(/^\.?\//, '')
|
|
185
|
+
.replace(/^docs\//, '')
|
|
186
|
+
.replace(/\.(md|txt)$/i, '');
|
|
187
|
+
return matchSlug(catalog, asSlug);
|
|
188
|
+
}
|
|
189
|
+
function matchSlug(catalog, slug) {
|
|
190
|
+
const needle = slug.toLowerCase();
|
|
191
|
+
return catalog.find((entry) => entry.slug.toLowerCase() === needle) ?? null;
|
|
192
|
+
}
|
|
193
|
+
/**
|
|
194
|
+
* Slugs closest to a miss, for a "did you mean" line. Ranks by shared prefix,
|
|
195
|
+
* then substring containment — enough to catch a typo or a half-remembered
|
|
196
|
+
* name without pulling in a distance library.
|
|
197
|
+
*/
|
|
198
|
+
export function suggestSlugs(catalog, reference, limit = 3) {
|
|
199
|
+
const needle = reference.trim().toLowerCase();
|
|
200
|
+
if (needle === '')
|
|
201
|
+
return [];
|
|
202
|
+
return catalog
|
|
203
|
+
.map((entry) => {
|
|
204
|
+
const slug = entry.slug.toLowerCase();
|
|
205
|
+
let score = 0;
|
|
206
|
+
if (slug.includes(needle) || needle.includes(slug))
|
|
207
|
+
score += 10;
|
|
208
|
+
score += sharedPrefixLength(slug, needle);
|
|
209
|
+
return { slug: entry.slug, score };
|
|
210
|
+
})
|
|
211
|
+
.filter(({ score }) => score > 2)
|
|
212
|
+
.sort((a, b) => b.score - a.score)
|
|
213
|
+
.slice(0, limit)
|
|
214
|
+
.map(({ slug }) => slug);
|
|
215
|
+
}
|
|
216
|
+
function sharedPrefixLength(a, b) {
|
|
217
|
+
const max = Math.min(a.length, b.length);
|
|
218
|
+
let i = 0;
|
|
219
|
+
while (i < max && a[i] === b[i])
|
|
220
|
+
i += 1;
|
|
221
|
+
return i;
|
|
222
|
+
}
|
|
223
|
+
async function readFileOrNull(path) {
|
|
224
|
+
try {
|
|
225
|
+
return await readFile(path, 'utf8');
|
|
226
|
+
}
|
|
227
|
+
catch {
|
|
228
|
+
return null;
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
//# sourceMappingURL=catalog.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"catalog.js","sourceRoot":"","sources":["../../src/docs/catalog.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAmB3C,MAAM,aAAa,GAAG,8BAA8B,CAAC;AACrD,MAAM,SAAS,GAAG,2BAA2B,CAAC;AAE9C;;;;;;;;;;;;GAYG;AACH,MAAM,aAAa,GAKb;IACJ;QACE,QAAQ,EA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1
|
+
/**
|
|
2
|
+
* Programmatic access to the documentation this package ships.
|
|
3
|
+
*
|
|
4
|
+
* The docs travel in the npm tarball beside the code they describe, so a reader
|
|
5
|
+
* that resolves them through here is reading the pages for the version actually
|
|
6
|
+
* installed — not whatever the website is serving today. That is the whole
|
|
7
|
+
* point of the subpath: a published version is frozen, its docs are frozen with
|
|
8
|
+
* it, and the canonical `get` contract cannot drift behind a pinned dependency.
|
|
9
|
+
*/
|
|
10
|
+
export { readDocsCatalog, findDoc, parseDocHeader, suggestSlugs, type DocEntry, type DocKind, } from './catalog.js';
|
|
11
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/docs/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EACL,eAAe,EACf,OAAO,EACP,cAAc,EACd,YAAY,EACZ,KAAK,QAAQ,EACb,KAAK,OAAO,GACb,MAAM,cAAc,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Programmatic access to the documentation this package ships.
|
|
3
|
+
*
|
|
4
|
+
* The docs travel in the npm tarball beside the code they describe, so a reader
|
|
5
|
+
* that resolves them through here is reading the pages for the version actually
|
|
6
|
+
* installed — not whatever the website is serving today. That is the whole
|
|
7
|
+
* point of the subpath: a published version is frozen, its docs are frozen with
|
|
8
|
+
* it, and the canonical `get` contract cannot drift behind a pinned dependency.
|
|
9
|
+
*/
|
|
10
|
+
export { readDocsCatalog, findDoc, parseDocHeader, suggestSlugs, } from './catalog.js';
|
|
11
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/docs/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EACL,eAAe,EACf,OAAO,EACP,cAAc,EACd,YAAY,GAGb,MAAM,cAAc,CAAC"}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The durable-write port and the option that installs it.
|
|
3
|
+
*
|
|
4
|
+
* Owns the persistence contract behind `Ablo({ durableWrites })` — a behavior
|
|
5
|
+
* contract of methods, not a serialized shape, which is why it lives here
|
|
6
|
+
* rather than in `transactions/settlement/`. The records that cross this port
|
|
7
|
+
* are owned by `pendingWriteSchema` there; this module never redescribes them.
|
|
8
|
+
*
|
|
9
|
+
* The engine consumes the port through `commitOutboxStore`, and the HTTP client
|
|
10
|
+
* accepts the same option through `transport/httpOptions`.
|
|
11
|
+
*/
|
|
12
|
+
import { z } from 'zod';
|
|
13
|
+
import type { CommitOutboxScope } from './transactions/settlement/commitEnvelope.js';
|
|
14
|
+
import type { PendingWrite } from './transactions/settlement/pendingWrite.js';
|
|
15
|
+
/**
|
|
16
|
+
* Persistence port used by `Ablo({ durableWrites })`.
|
|
17
|
+
*
|
|
18
|
+
* `seal` is the durability boundary: it must atomically persist the exact write
|
|
19
|
+
* and consume the staged records that write supersedes. Resolving this promise
|
|
20
|
+
* authorizes Ablo to dispatch the request, so adapters must never report success
|
|
21
|
+
* before the data is durable.
|
|
22
|
+
*/
|
|
23
|
+
export interface DurableWriteStore {
|
|
24
|
+
/**
|
|
25
|
+
* Atomically reserve a pending write and consume the staged records it owns.
|
|
26
|
+
* The same id + same request is idempotent; the same id + a different request
|
|
27
|
+
* must be rejected. For a source-accepted envelope, a re-seal may add the
|
|
28
|
+
* monotonic `acceptedAt`/`correlationId` evidence and the store must preserve
|
|
29
|
+
* that upgrade atomically rather than ignoring it.
|
|
30
|
+
*/
|
|
31
|
+
seal(write: PendingWrite, consumedRecordIds: readonly string[]): Promise<void>;
|
|
32
|
+
/** Load all unacknowledged writes. Stored data is treated as untrusted. */
|
|
33
|
+
list(): Promise<readonly unknown[]>;
|
|
34
|
+
/** Remove one write only after its outcome is definitive. */
|
|
35
|
+
remove(writeId: string): Promise<void>;
|
|
36
|
+
}
|
|
37
|
+
/** Runtime validation for injected adapters, including JavaScript consumers. */
|
|
38
|
+
export declare const durableWriteStoreSchema: z.ZodCustom<DurableWriteStore, DurableWriteStore>;
|
|
39
|
+
/** Options for crash-durable `create`, `update`, and `delete` calls. */
|
|
40
|
+
export declare const durableWritesConfigSchema: z.ZodObject<{
|
|
41
|
+
store: z.ZodCustom<DurableWriteStore, DurableWriteStore>;
|
|
42
|
+
namespace: z.ZodOptional<z.ZodString>;
|
|
43
|
+
}, z.core.$strict>;
|
|
44
|
+
export type DurableWritesConfig = z.infer<typeof durableWritesConfigSchema>;
|
|
45
|
+
interface DurableWriteOptionInput {
|
|
46
|
+
readonly durableWrites?: DurableWritesConfig;
|
|
47
|
+
/** Compatibility input for pre-`durableWrites` clients. */
|
|
48
|
+
readonly commitOutbox?: DurableWriteStore;
|
|
49
|
+
/** Compatibility input and internal child-client identity seam. */
|
|
50
|
+
readonly commitOutboxScope?: CommitOutboxScope;
|
|
51
|
+
}
|
|
52
|
+
export interface ResolvedDurableWrites {
|
|
53
|
+
readonly store?: DurableWriteStore;
|
|
54
|
+
readonly namespace?: string;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Resolves one canonical store configuration for both HTTP and WebSocket
|
|
58
|
+
* clients. Mixed old/new configuration fails loudly so Ablo never persists to
|
|
59
|
+
* one adapter while the caller believes another adapter is authoritative.
|
|
60
|
+
*/
|
|
61
|
+
export declare function resolveDurableWrites(options: DurableWriteOptionInput): ResolvedDurableWrites;
|
|
62
|
+
export {};
|
|
63
|
+
//# sourceMappingURL=durableWrites.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"durableWrites.d.ts","sourceRoot":"","sources":["../src/durableWrites.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,6CAA6C,CAAC;AACrF,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,2CAA2C,CAAC;AAE9E;;;;;;;GAOG;AACH,MAAM,WAAW,iBAAiB;IAChC;;;;;;OAMG;IACH,IAAI,CACF,KAAK,EAAE,YAAY,EACnB,iBAAiB,EAAE,SAAS,MAAM,EAAE,GACnC,OAAO,CAAC,IAAI,CAAC,CAAC;IACjB,2EAA2E;IAC3E,IAAI,IAAI,OAAO,CAAC,SAAS,OAAO,EAAE,CAAC,CAAC;IACpC,6DAA6D;IAC7D,MAAM,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CACxC;AAED,gFAAgF;AAChF,eAAO,MAAM,uBAAuB,mDAWnC,CAAC;AAEF,wEAAwE;AACxE,eAAO,MAAM,yBAAyB;;;kBAIpC,CAAC;AAEH,MAAM,MAAM,mBAAmB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,yBAAyB,CAAC,CAAC;AAE5E,UAAU,uBAAuB;IAC/B,QAAQ,CAAC,aAAa,CAAC,EAAE,mBAAmB,CAAC;IAC7C,2DAA2D;IAC3D,QAAQ,CAAC,YAAY,CAAC,EAAE,iBAAiB,CAAC;IAC1C,mEAAmE;IACnE,QAAQ,CAAC,iBAAiB,CAAC,EAAE,iBAAiB,CAAC;CAChD;AAED,MAAM,WAAW,qBAAqB;IACpC,QAAQ,CAAC,KAAK,CAAC,EAAE,iBAAiB,CAAC;IACnC,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;CAC7B;AASD;;;;GAIG;AACH,wBAAgB,oBAAoB,CAClC,OAAO,EAAE,uBAAuB,GAC/B,qBAAqB,CAwCvB"}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The durable-write port and the option that installs it.
|
|
3
|
+
*
|
|
4
|
+
* Owns the persistence contract behind `Ablo({ durableWrites })` — a behavior
|
|
5
|
+
* contract of methods, not a serialized shape, which is why it lives here
|
|
6
|
+
* rather than in `transactions/settlement/`. The records that cross this port
|
|
7
|
+
* are owned by `pendingWriteSchema` there; this module never redescribes them.
|
|
8
|
+
*
|
|
9
|
+
* The engine consumes the port through `commitOutboxStore`, and the HTTP client
|
|
10
|
+
* accepts the same option through `transport/httpOptions`.
|
|
11
|
+
*/
|
|
12
|
+
import { z } from 'zod';
|
|
13
|
+
import { AbloValidationError } from './errors.js';
|
|
14
|
+
/** Runtime validation for injected adapters, including JavaScript consumers. */
|
|
15
|
+
export const durableWriteStoreSchema = z.custom((value) => {
|
|
16
|
+
if (typeof value !== 'object' || value === null)
|
|
17
|
+
return false;
|
|
18
|
+
const candidate = value;
|
|
19
|
+
return (typeof candidate.seal === 'function' &&
|
|
20
|
+
typeof candidate.list === 'function' &&
|
|
21
|
+
typeof candidate.remove === 'function');
|
|
22
|
+
}, { message: 'store must implement seal(), list(), and remove()' });
|
|
23
|
+
/** Options for crash-durable `create`, `update`, and `delete` calls. */
|
|
24
|
+
export const durableWritesConfigSchema = z.strictObject({
|
|
25
|
+
store: durableWriteStoreSchema,
|
|
26
|
+
/** Separates deployments or workflow lanes that share an authenticated actor. */
|
|
27
|
+
namespace: z.string().trim().min(1).optional(),
|
|
28
|
+
});
|
|
29
|
+
function invalidDurableWrites(message) {
|
|
30
|
+
return new AbloValidationError(`Ablo: invalid \`durableWrites\` option — ${message}.`, {
|
|
31
|
+
code: 'invalid_options',
|
|
32
|
+
param: 'durableWrites',
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Resolves one canonical store configuration for both HTTP and WebSocket
|
|
37
|
+
* clients. Mixed old/new configuration fails loudly so Ablo never persists to
|
|
38
|
+
* one adapter while the caller believes another adapter is authoritative.
|
|
39
|
+
*/
|
|
40
|
+
export function resolveDurableWrites(options) {
|
|
41
|
+
if (options.durableWrites !== undefined && options.commitOutbox !== undefined) {
|
|
42
|
+
throw invalidDurableWrites('pass `durableWrites` or the deprecated `commitOutbox`, not both');
|
|
43
|
+
}
|
|
44
|
+
if (options.durableWrites !== undefined) {
|
|
45
|
+
const parsed = durableWritesConfigSchema.safeParse(options.durableWrites);
|
|
46
|
+
if (!parsed.success) {
|
|
47
|
+
throw invalidDurableWrites(parsed.error.issues.map((issue) => issue.message).join('; '));
|
|
48
|
+
}
|
|
49
|
+
return {
|
|
50
|
+
store: parsed.data.store,
|
|
51
|
+
...(parsed.data.namespace !== undefined
|
|
52
|
+
? { namespace: parsed.data.namespace }
|
|
53
|
+
: options.commitOutboxScope?.namespace !== undefined
|
|
54
|
+
? { namespace: options.commitOutboxScope.namespace }
|
|
55
|
+
: {}),
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
if (options.commitOutbox !== undefined) {
|
|
59
|
+
const parsed = durableWriteStoreSchema.safeParse(options.commitOutbox);
|
|
60
|
+
if (!parsed.success) {
|
|
61
|
+
throw invalidDurableWrites(parsed.error.issues.map((issue) => issue.message).join('; '));
|
|
62
|
+
}
|
|
63
|
+
return {
|
|
64
|
+
store: parsed.data,
|
|
65
|
+
...(options.commitOutboxScope?.namespace !== undefined
|
|
66
|
+
? { namespace: options.commitOutboxScope.namespace }
|
|
67
|
+
: {}),
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
return {};
|
|
71
|
+
}
|
|
72
|
+
//# sourceMappingURL=durableWrites.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"durableWrites.js","sourceRoot":"","sources":["../src/durableWrites.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AA8BlD,gFAAgF;AAChF,MAAM,CAAC,MAAM,uBAAuB,GAAG,CAAC,CAAC,MAAM,CAC7C,CAAC,KAAK,EAAE,EAAE;IACR,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI;QAAE,OAAO,KAAK,CAAC;IAC9D,MAA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ACD,OAAO;YACL,KAAK,EAAE,MAAM,CAAC,IAAI,CAAC,KAAK;YACxB,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,SAAS,KAAK,SAAS;gBACrC,CAAC,CAAC,EAAE,SAAS,EAAE,MAAM,CAAC,IAAI,CAAC,SAAS,EAAE;gBACtC,CAAC,CAAC,OAAO,CAAC,iBAAiB,EAAE,SAAS,KAAK,SAAS;oBAClD,CAAC,CAAC,EAAE,SAAS,EAAE,OAAO,CAAC,iBAAiB,CAAC,SAAS,EAAE;oBACpD,CAAC,CAAC,EAAE,CAAC;SACV,CAAC;IACJ,CAAC;IAED,IAAI,OAAO,CAAC,YAAY,KAAK,SAAS,EAAE,CAAC;QACvC,MAAM,MAAM,GAAG,uBAAuB,CAAC,SAAS,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC;QACvE,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;YACpB,MAAM,oBAAoB,CACxB,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAC7D,CAAC;QACJ,CAAC;QACD,OAAO;YACL,KAAK,EAAE,MAAM,CAAC,IAAI;YAClB,GAAG,CAAC,OAAO,CAAC,iBAAiB,EAAE,SAAS,KAAK,SAAS;gBACpD,CAAC,CAAC,EAAE,SAAS,EAAE,OAAO,CAAC,iBAAiB,CAAC,SAAS,EAAE;gBACpD,CAAC,CAAC,EAAE,CAAC;SACR,CAAC;IACJ,CAAC;IAED,OAAO,EAAE,CAAC;AACZ,CAAC"}
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
/**
|
|
3
|
+
* Two axes live in this module, and they are NOT the same axis. They stay
|
|
4
|
+
* together because they convert into each other; they stay distinct because
|
|
5
|
+
* conflating them is how credentials acquire a mode nobody chose.
|
|
6
|
+
*
|
|
7
|
+
* - The PLANE axis ({@link Environment}) — which isolated plane a row, schema
|
|
8
|
+
* artifact, or data source belongs to. Open-ended: `production` is the root
|
|
9
|
+
* plane and any number of others may exist beside it.
|
|
10
|
+
* - The CREDENTIAL axis ({@link KeyEnvironment}) — the mode a key was minted
|
|
11
|
+
* in. Binary, and fixed by the key format: a prefix spells exactly one of
|
|
12
|
+
* `live` or `test`, so a third value is not representable in a key at all.
|
|
13
|
+
*
|
|
14
|
+
* These were one type until this split, which is the shape behind two
|
|
15
|
+
* incidents: an `sk_test_` exchange that minted an `ek_live_` and landed
|
|
16
|
+
* sandbox commits in another tenant's tables, and a rotation that handed back
|
|
17
|
+
* an `rk_live_` in place of an `rk_test_`. Widening the plane axis while the
|
|
18
|
+
* credential axis aliased it would reopen that door one plane name wider, so
|
|
19
|
+
* the split comes first and the conversions below are deliberately narrow.
|
|
20
|
+
*/
|
|
21
|
+
/**
|
|
22
|
+
* The plane names every deployment has: the root, plus the plane every project
|
|
23
|
+
* starts with beside it. This is the well-known set, not the permitted set —
|
|
24
|
+
* {@link environmentSchema} decides what is valid.
|
|
25
|
+
*/
|
|
26
|
+
export declare const ENVIRONMENTS: readonly ["production", "sandbox"];
|
|
27
|
+
/** The root plane — the one every other plane is defined relative to. */
|
|
28
|
+
export declare const ROOT_ENVIRONMENT = "production";
|
|
29
|
+
/**
|
|
30
|
+
* The modes a credential can be minted in. Deliberately its own list rather
|
|
31
|
+
* than a view of {@link ENVIRONMENTS}: this one is fixed by the key format,
|
|
32
|
+
* which has exactly two prefix spellings, and must not grow when planes do.
|
|
33
|
+
*/
|
|
34
|
+
export declare const KEY_ENVIRONMENTS: readonly ["production", "sandbox"];
|
|
35
|
+
/**
|
|
36
|
+
* How a credential's mode is spelled inside an API-key prefix: a `live` key
|
|
37
|
+
* acts on production and a `test` key acts on the sandbox. Convert between this
|
|
38
|
+
* spelling and {@link KeyEnvironment} with {@link environmentFromKeyPrefix} and
|
|
39
|
+
* {@link environmentToKeyPrefix}.
|
|
40
|
+
*/
|
|
41
|
+
export declare const KEY_PREFIX_ENVIRONMENTS: readonly ["live", "test"];
|
|
42
|
+
export type KeyPrefixEnvironment = (typeof KEY_PREFIX_ENVIRONMENTS)[number];
|
|
43
|
+
/**
|
|
44
|
+
* Validates a value as a plane name — a lowercase slug that may not lead or
|
|
45
|
+
* trail with a hyphen.
|
|
46
|
+
*
|
|
47
|
+
* The character set is load-bearing rather than cosmetic. A plane name is
|
|
48
|
+
* interpolated into two delimited identifiers: the sync-group prefix
|
|
49
|
+
* (`sandbox:<org>:<slug>`, colon separated) and the tenant secret scope
|
|
50
|
+
* (`<org>/<env>/<project>/<sandbox>`, slash separated). Admitting `:` or `/`
|
|
51
|
+
* would let one plane's name parse as two segments and so collide with a
|
|
52
|
+
* different plane's identity, which is why the pattern excludes every delimiter
|
|
53
|
+
* either format relies on.
|
|
54
|
+
*/
|
|
55
|
+
export declare const environmentSchema: z.ZodString;
|
|
56
|
+
/** A plane name. `production` is the root; any other slug is a plane beside it. */
|
|
57
|
+
export type Environment = z.infer<typeof environmentSchema>;
|
|
58
|
+
/** Validates a value as one of the {@link KEY_ENVIRONMENTS}. */
|
|
59
|
+
export declare const keyEnvironmentSchema: z.ZodEnum<{
|
|
60
|
+
production: "production";
|
|
61
|
+
sandbox: "sandbox";
|
|
62
|
+
}>;
|
|
63
|
+
/**
|
|
64
|
+
* The mode a credential was minted in — `'production'` or `'sandbox'`, never
|
|
65
|
+
* anything else. Not an alias of {@link Environment}: a key's mode is a trust
|
|
66
|
+
* boundary, and a plane name must never be able to answer it.
|
|
67
|
+
*/
|
|
68
|
+
export type KeyEnvironment = z.infer<typeof keyEnvironmentSchema>;
|
|
69
|
+
/**
|
|
70
|
+
* Coerces an untrusted value into a valid {@link Environment}, returning
|
|
71
|
+
* `fallback` (which defaults to the root plane) when the value is not a
|
|
72
|
+
* well-formed plane name. Use it when reading a plane from configuration or off
|
|
73
|
+
* the wire.
|
|
74
|
+
*/
|
|
75
|
+
export declare function normalizeEnvironment(value: unknown, fallback?: Environment): Environment;
|
|
76
|
+
/** True when the given plane is the root plane. */
|
|
77
|
+
export declare function isRootEnvironment(value: Environment): boolean;
|
|
78
|
+
/**
|
|
79
|
+
* The mode a credential acting on the given plane must be minted in.
|
|
80
|
+
*
|
|
81
|
+
* This is the ONE narrowing from the open plane axis to the binary credential
|
|
82
|
+
* axis, and it is deliberately asymmetric: only the root plane yields a
|
|
83
|
+
* production-mode key, and every other plane — named, numbered, or newly forked
|
|
84
|
+
* — yields a sandbox-mode one. A plane cannot acquire live authority by being
|
|
85
|
+
* spelled a particular way, which is the property that keeps adding planes from
|
|
86
|
+
* widening what any credential is allowed to touch.
|
|
87
|
+
*/
|
|
88
|
+
export declare function keyEnvironmentForPlane(value: Environment): KeyEnvironment;
|
|
89
|
+
/**
|
|
90
|
+
* Maps an API-key prefix spelling to the mode it denotes: a `'test'` key was
|
|
91
|
+
* minted in the sandbox, and anything else in production.
|
|
92
|
+
*/
|
|
93
|
+
export declare function environmentFromKeyPrefix(value: KeyPrefixEnvironment): KeyEnvironment;
|
|
94
|
+
/**
|
|
95
|
+
* Maps a credential's mode to the spelling used in its key prefix.
|
|
96
|
+
*
|
|
97
|
+
* Takes a {@link KeyEnvironment} rather than an {@link Environment} on purpose.
|
|
98
|
+
* Planes outside the well-known two have no prefix spelling, and a signature
|
|
99
|
+
* that accepted one would silently answer `'live'` for them — minting a
|
|
100
|
+
* production-mode credential for a plane that is not production. That is the
|
|
101
|
+
* 2026-06-10 incident with a new cause, so the type refuses the input instead.
|
|
102
|
+
*/
|
|
103
|
+
export declare function environmentToKeyPrefix(value: KeyEnvironment): KeyPrefixEnvironment;
|
|
104
|
+
/** Returns true when the given environment is the sandbox. */
|
|
105
|
+
export declare function isSandboxEnvironment(value: Environment): boolean;
|
|
106
|
+
//# sourceMappingURL=environment.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"environment.d.ts","sourceRoot":"","sources":["../src/environment.ts"],"names":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
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
/**
|
|
3
|
+
* Two axes live in this module, and they are NOT the same axis. They stay
|
|
4
|
+
* together because they convert into each other; they stay distinct because
|
|
5
|
+
* conflating them is how credentials acquire a mode nobody chose.
|
|
6
|
+
*
|
|
7
|
+
* - The PLANE axis ({@link Environment}) — which isolated plane a row, schema
|
|
8
|
+
* artifact, or data source belongs to. Open-ended: `production` is the root
|
|
9
|
+
* plane and any number of others may exist beside it.
|
|
10
|
+
* - The CREDENTIAL axis ({@link KeyEnvironment}) — the mode a key was minted
|
|
11
|
+
* in. Binary, and fixed by the key format: a prefix spells exactly one of
|
|
12
|
+
* `live` or `test`, so a third value is not representable in a key at all.
|
|
13
|
+
*
|
|
14
|
+
* These were one type until this split, which is the shape behind two
|
|
15
|
+
* incidents: an `sk_test_` exchange that minted an `ek_live_` and landed
|
|
16
|
+
* sandbox commits in another tenant's tables, and a rotation that handed back
|
|
17
|
+
* an `rk_live_` in place of an `rk_test_`. Widening the plane axis while the
|
|
18
|
+
* credential axis aliased it would reopen that door one plane name wider, so
|
|
19
|
+
* the split comes first and the conversions below are deliberately narrow.
|
|
20
|
+
*/
|
|
21
|
+
/**
|
|
22
|
+
* The plane names every deployment has: the root, plus the plane every project
|
|
23
|
+
* starts with beside it. This is the well-known set, not the permitted set —
|
|
24
|
+
* {@link environmentSchema} decides what is valid.
|
|
25
|
+
*/
|
|
26
|
+
export const ENVIRONMENTS = ['production', 'sandbox'];
|
|
27
|
+
/** The root plane — the one every other plane is defined relative to. */
|
|
28
|
+
export const ROOT_ENVIRONMENT = 'production';
|
|
29
|
+
/**
|
|
30
|
+
* The modes a credential can be minted in. Deliberately its own list rather
|
|
31
|
+
* than a view of {@link ENVIRONMENTS}: this one is fixed by the key format,
|
|
32
|
+
* which has exactly two prefix spellings, and must not grow when planes do.
|
|
33
|
+
*/
|
|
34
|
+
export const KEY_ENVIRONMENTS = ['production', 'sandbox'];
|
|
35
|
+
/**
|
|
36
|
+
* How a credential's mode is spelled inside an API-key prefix: a `live` key
|
|
37
|
+
* acts on production and a `test` key acts on the sandbox. Convert between this
|
|
38
|
+
* spelling and {@link KeyEnvironment} with {@link environmentFromKeyPrefix} and
|
|
39
|
+
* {@link environmentToKeyPrefix}.
|
|
40
|
+
*/
|
|
41
|
+
export const KEY_PREFIX_ENVIRONMENTS = ['live', 'test'];
|
|
42
|
+
/**
|
|
43
|
+
* Validates a value as a plane name — a lowercase slug that may not lead or
|
|
44
|
+
* trail with a hyphen.
|
|
45
|
+
*
|
|
46
|
+
* The character set is load-bearing rather than cosmetic. A plane name is
|
|
47
|
+
* interpolated into two delimited identifiers: the sync-group prefix
|
|
48
|
+
* (`sandbox:<org>:<slug>`, colon separated) and the tenant secret scope
|
|
49
|
+
* (`<org>/<env>/<project>/<sandbox>`, slash separated). Admitting `:` or `/`
|
|
50
|
+
* would let one plane's name parse as two segments and so collide with a
|
|
51
|
+
* different plane's identity, which is why the pattern excludes every delimiter
|
|
52
|
+
* either format relies on.
|
|
53
|
+
*/
|
|
54
|
+
export const environmentSchema = z
|
|
55
|
+
.string()
|
|
56
|
+
.regex(/^[a-z0-9](?:[a-z0-9-]{0,38}[a-z0-9])?$/, 'must be a lowercase slug');
|
|
57
|
+
/** Validates a value as one of the {@link KEY_ENVIRONMENTS}. */
|
|
58
|
+
export const keyEnvironmentSchema = z.enum(KEY_ENVIRONMENTS);
|
|
59
|
+
/**
|
|
60
|
+
* Coerces an untrusted value into a valid {@link Environment}, returning
|
|
61
|
+
* `fallback` (which defaults to the root plane) when the value is not a
|
|
62
|
+
* well-formed plane name. Use it when reading a plane from configuration or off
|
|
63
|
+
* the wire.
|
|
64
|
+
*/
|
|
65
|
+
export function normalizeEnvironment(value, fallback = ROOT_ENVIRONMENT) {
|
|
66
|
+
const parsed = environmentSchema.safeParse(value);
|
|
67
|
+
return parsed.success ? parsed.data : fallback;
|
|
68
|
+
}
|
|
69
|
+
/** True when the given plane is the root plane. */
|
|
70
|
+
export function isRootEnvironment(value) {
|
|
71
|
+
return value === ROOT_ENVIRONMENT;
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* The mode a credential acting on the given plane must be minted in.
|
|
75
|
+
*
|
|
76
|
+
* This is the ONE narrowing from the open plane axis to the binary credential
|
|
77
|
+
* axis, and it is deliberately asymmetric: only the root plane yields a
|
|
78
|
+
* production-mode key, and every other plane — named, numbered, or newly forked
|
|
79
|
+
* — yields a sandbox-mode one. A plane cannot acquire live authority by being
|
|
80
|
+
* spelled a particular way, which is the property that keeps adding planes from
|
|
81
|
+
* widening what any credential is allowed to touch.
|
|
82
|
+
*/
|
|
83
|
+
export function keyEnvironmentForPlane(value) {
|
|
84
|
+
return isRootEnvironment(value) ? 'production' : 'sandbox';
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Maps an API-key prefix spelling to the mode it denotes: a `'test'` key was
|
|
88
|
+
* minted in the sandbox, and anything else in production.
|
|
89
|
+
*/
|
|
90
|
+
export function environmentFromKeyPrefix(value) {
|
|
91
|
+
return value === 'test' ? 'sandbox' : 'production';
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Maps a credential's mode to the spelling used in its key prefix.
|
|
95
|
+
*
|
|
96
|
+
* Takes a {@link KeyEnvironment} rather than an {@link Environment} on purpose.
|
|
97
|
+
* Planes outside the well-known two have no prefix spelling, and a signature
|
|
98
|
+
* that accepted one would silently answer `'live'` for them — minting a
|
|
99
|
+
* production-mode credential for a plane that is not production. That is the
|
|
100
|
+
* 2026-06-10 incident with a new cause, so the type refuses the input instead.
|
|
101
|
+
*/
|
|
102
|
+
export function environmentToKeyPrefix(value) {
|
|
103
|
+
return value === 'sandbox' ? 'test' : 'live';
|
|
104
|
+
}
|
|
105
|
+
/** Returns true when the given environment is the sandbox. */
|
|
106
|
+
export function isSandboxEnvironment(value) {
|
|
107
|
+
return value === 'sandbox';
|
|
108
|
+
}
|
|
109
|
+
//# sourceMapp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