@appport/sdk 1.0.1
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/LICENSE +126 -0
- package/README.md +39 -0
- package/dist/index.d.ts +14 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +14 -0
- package/dist/index.js.map +1 -0
- package/dist/node.d.ts +3 -0
- package/dist/node.d.ts.map +1 -0
- package/dist/node.js +3 -0
- package/dist/node.js.map +1 -0
- package/node_modules/@appport/authorization/README.md +28 -0
- package/node_modules/@appport/authorization/dist/index.d.ts +94 -0
- package/node_modules/@appport/authorization/dist/index.d.ts.map +1 -0
- package/node_modules/@appport/authorization/dist/index.js +131 -0
- package/node_modules/@appport/authorization/dist/index.js.map +1 -0
- package/node_modules/@appport/authorization/package.json +28 -0
- package/node_modules/@appport/client/README.md +35 -0
- package/node_modules/@appport/client/dist/channel.d.ts +14 -0
- package/node_modules/@appport/client/dist/channel.d.ts.map +1 -0
- package/node_modules/@appport/client/dist/channel.js +58 -0
- package/node_modules/@appport/client/dist/channel.js.map +1 -0
- package/node_modules/@appport/client/dist/client.d.ts +61 -0
- package/node_modules/@appport/client/dist/client.d.ts.map +1 -0
- package/node_modules/@appport/client/dist/client.js +214 -0
- package/node_modules/@appport/client/dist/client.js.map +1 -0
- package/node_modules/@appport/client/dist/contract.d.ts +55 -0
- package/node_modules/@appport/client/dist/contract.d.ts.map +1 -0
- package/node_modules/@appport/client/dist/contract.js +12 -0
- package/node_modules/@appport/client/dist/contract.js.map +1 -0
- package/node_modules/@appport/client/dist/discovery.d.ts +17 -0
- package/node_modules/@appport/client/dist/discovery.d.ts.map +1 -0
- package/node_modules/@appport/client/dist/discovery.js +56 -0
- package/node_modules/@appport/client/dist/discovery.js.map +1 -0
- package/node_modules/@appport/client/dist/duplex.d.ts +25 -0
- package/node_modules/@appport/client/dist/duplex.d.ts.map +1 -0
- package/node_modules/@appport/client/dist/duplex.js +194 -0
- package/node_modules/@appport/client/dist/duplex.js.map +1 -0
- package/node_modules/@appport/client/dist/index.d.ts +13 -0
- package/node_modules/@appport/client/dist/index.d.ts.map +1 -0
- package/node_modules/@appport/client/dist/index.js +13 -0
- package/node_modules/@appport/client/dist/index.js.map +1 -0
- package/node_modules/@appport/client/dist/transport.d.ts +42 -0
- package/node_modules/@appport/client/dist/transport.d.ts.map +1 -0
- package/node_modules/@appport/client/dist/transport.js +2 -0
- package/node_modules/@appport/client/dist/transport.js.map +1 -0
- package/node_modules/@appport/client/package.json +32 -0
- package/node_modules/@appport/core/README.md +91 -0
- package/node_modules/@appport/core/dist/appboundry-contract.d.ts +80 -0
- package/node_modules/@appport/core/dist/appboundry-contract.d.ts.map +1 -0
- package/node_modules/@appport/core/dist/appboundry-contract.js +160 -0
- package/node_modules/@appport/core/dist/appboundry-contract.js.map +1 -0
- package/node_modules/@appport/core/dist/application-implementation.d.ts +125 -0
- package/node_modules/@appport/core/dist/application-implementation.d.ts.map +1 -0
- package/node_modules/@appport/core/dist/application-implementation.js +220 -0
- package/node_modules/@appport/core/dist/application-implementation.js.map +1 -0
- package/node_modules/@appport/core/dist/application-lifecycle.d.ts +150 -0
- package/node_modules/@appport/core/dist/application-lifecycle.d.ts.map +1 -0
- package/node_modules/@appport/core/dist/application-lifecycle.js +70 -0
- package/node_modules/@appport/core/dist/application-lifecycle.js.map +1 -0
- package/node_modules/@appport/core/dist/application-source.d.ts +109 -0
- package/node_modules/@appport/core/dist/application-source.d.ts.map +1 -0
- package/node_modules/@appport/core/dist/application-source.js +186 -0
- package/node_modules/@appport/core/dist/application-source.js.map +1 -0
- package/node_modules/@appport/core/dist/application.d.ts +122 -0
- package/node_modules/@appport/core/dist/application.d.ts.map +1 -0
- package/node_modules/@appport/core/dist/application.js +515 -0
- package/node_modules/@appport/core/dist/application.js.map +1 -0
- package/node_modules/@appport/core/dist/artifact.d.ts +395 -0
- package/node_modules/@appport/core/dist/artifact.d.ts.map +1 -0
- package/node_modules/@appport/core/dist/artifact.js +392 -0
- package/node_modules/@appport/core/dist/artifact.js.map +1 -0
- package/node_modules/@appport/core/dist/assembly.d.ts +237 -0
- package/node_modules/@appport/core/dist/assembly.d.ts.map +1 -0
- package/node_modules/@appport/core/dist/assembly.js +458 -0
- package/node_modules/@appport/core/dist/assembly.js.map +1 -0
- package/node_modules/@appport/core/dist/authority-attestation.d.ts +34 -0
- package/node_modules/@appport/core/dist/authority-attestation.d.ts.map +1 -0
- package/node_modules/@appport/core/dist/authority-attestation.js +72 -0
- package/node_modules/@appport/core/dist/authority-attestation.js.map +1 -0
- package/node_modules/@appport/core/dist/authorization-grant.d.ts +107 -0
- package/node_modules/@appport/core/dist/authorization-grant.d.ts.map +1 -0
- package/node_modules/@appport/core/dist/authorization-grant.js +131 -0
- package/node_modules/@appport/core/dist/authorization-grant.js.map +1 -0
- package/node_modules/@appport/core/dist/binding.d.ts +294 -0
- package/node_modules/@appport/core/dist/binding.d.ts.map +1 -0
- package/node_modules/@appport/core/dist/binding.js +263 -0
- package/node_modules/@appport/core/dist/binding.js.map +1 -0
- package/node_modules/@appport/core/dist/builtins.d.ts +18 -0
- package/node_modules/@appport/core/dist/builtins.d.ts.map +1 -0
- package/node_modules/@appport/core/dist/builtins.js +38 -0
- package/node_modules/@appport/core/dist/builtins.js.map +1 -0
- package/node_modules/@appport/core/dist/capability.d.ts +94 -0
- package/node_modules/@appport/core/dist/capability.d.ts.map +1 -0
- package/node_modules/@appport/core/dist/capability.js +85 -0
- package/node_modules/@appport/core/dist/capability.js.map +1 -0
- package/node_modules/@appport/core/dist/concurrency.d.ts +16 -0
- package/node_modules/@appport/core/dist/concurrency.d.ts.map +1 -0
- package/node_modules/@appport/core/dist/concurrency.js +46 -0
- package/node_modules/@appport/core/dist/concurrency.js.map +1 -0
- package/node_modules/@appport/core/dist/context.d.ts +59 -0
- package/node_modules/@appport/core/dist/context.d.ts.map +1 -0
- package/node_modules/@appport/core/dist/context.js +14 -0
- package/node_modules/@appport/core/dist/context.js.map +1 -0
- package/node_modules/@appport/core/dist/contract-artifact.d.ts +15 -0
- package/node_modules/@appport/core/dist/contract-artifact.d.ts.map +1 -0
- package/node_modules/@appport/core/dist/contract-artifact.js +152 -0
- package/node_modules/@appport/core/dist/contract-artifact.js.map +1 -0
- package/node_modules/@appport/core/dist/contract-attestation.d.ts +68 -0
- package/node_modules/@appport/core/dist/contract-attestation.d.ts.map +1 -0
- package/node_modules/@appport/core/dist/contract-attestation.js +76 -0
- package/node_modules/@appport/core/dist/contract-attestation.js.map +1 -0
- package/node_modules/@appport/core/dist/crash-injection.d.ts +3 -0
- package/node_modules/@appport/core/dist/crash-injection.d.ts.map +1 -0
- package/node_modules/@appport/core/dist/crash-injection.js +8 -0
- package/node_modules/@appport/core/dist/crash-injection.js.map +1 -0
- package/node_modules/@appport/core/dist/events.d.ts +33 -0
- package/node_modules/@appport/core/dist/events.d.ts.map +1 -0
- package/node_modules/@appport/core/dist/events.js +79 -0
- package/node_modules/@appport/core/dist/events.js.map +1 -0
- package/node_modules/@appport/core/dist/execution-barrier.d.ts +13 -0
- package/node_modules/@appport/core/dist/execution-barrier.d.ts.map +1 -0
- package/node_modules/@appport/core/dist/execution-barrier.js +33 -0
- package/node_modules/@appport/core/dist/execution-barrier.js.map +1 -0
- package/node_modules/@appport/core/dist/execution-ledger.d.ts +81 -0
- package/node_modules/@appport/core/dist/execution-ledger.d.ts.map +1 -0
- package/node_modules/@appport/core/dist/execution-ledger.js +173 -0
- package/node_modules/@appport/core/dist/execution-ledger.js.map +1 -0
- package/node_modules/@appport/core/dist/execution.d.ts +387 -0
- package/node_modules/@appport/core/dist/execution.d.ts.map +1 -0
- package/node_modules/@appport/core/dist/execution.js +165 -0
- package/node_modules/@appport/core/dist/execution.js.map +1 -0
- package/node_modules/@appport/core/dist/idempotency.d.ts +36 -0
- package/node_modules/@appport/core/dist/idempotency.d.ts.map +1 -0
- package/node_modules/@appport/core/dist/idempotency.js +36 -0
- package/node_modules/@appport/core/dist/idempotency.js.map +1 -0
- package/node_modules/@appport/core/dist/implementation.d.ts +110 -0
- package/node_modules/@appport/core/dist/implementation.d.ts.map +1 -0
- package/node_modules/@appport/core/dist/implementation.js +65 -0
- package/node_modules/@appport/core/dist/implementation.js.map +1 -0
- package/node_modules/@appport/core/dist/index.d.ts +44 -0
- package/node_modules/@appport/core/dist/index.d.ts.map +1 -0
- package/node_modules/@appport/core/dist/index.js +44 -0
- package/node_modules/@appport/core/dist/index.js.map +1 -0
- package/node_modules/@appport/core/dist/invocation.d.ts +253 -0
- package/node_modules/@appport/core/dist/invocation.d.ts.map +1 -0
- package/node_modules/@appport/core/dist/invocation.js +258 -0
- package/node_modules/@appport/core/dist/invocation.js.map +1 -0
- package/node_modules/@appport/core/dist/manifest.d.ts +157 -0
- package/node_modules/@appport/core/dist/manifest.d.ts.map +1 -0
- package/node_modules/@appport/core/dist/manifest.js +255 -0
- package/node_modules/@appport/core/dist/manifest.js.map +1 -0
- package/node_modules/@appport/core/dist/memory-application-data-store.d.ts +19 -0
- package/node_modules/@appport/core/dist/memory-application-data-store.d.ts.map +1 -0
- package/node_modules/@appport/core/dist/memory-application-data-store.js +161 -0
- package/node_modules/@appport/core/dist/memory-application-data-store.js.map +1 -0
- package/node_modules/@appport/core/dist/operations.d.ts +61 -0
- package/node_modules/@appport/core/dist/operations.d.ts.map +1 -0
- package/node_modules/@appport/core/dist/operations.js +210 -0
- package/node_modules/@appport/core/dist/operations.js.map +1 -0
- package/node_modules/@appport/core/dist/public.d.ts +19 -0
- package/node_modules/@appport/core/dist/public.d.ts.map +1 -0
- package/node_modules/@appport/core/dist/public.js +18 -0
- package/node_modules/@appport/core/dist/public.js.map +1 -0
- package/node_modules/@appport/core/dist/registration.d.ts +165 -0
- package/node_modules/@appport/core/dist/registration.d.ts.map +1 -0
- package/node_modules/@appport/core/dist/registration.js +253 -0
- package/node_modules/@appport/core/dist/registration.js.map +1 -0
- package/node_modules/@appport/core/dist/registry.d.ts +29 -0
- package/node_modules/@appport/core/dist/registry.d.ts.map +1 -0
- package/node_modules/@appport/core/dist/registry.js +148 -0
- package/node_modules/@appport/core/dist/registry.js.map +1 -0
- package/node_modules/@appport/core/dist/repository-connection.d.ts +100 -0
- package/node_modules/@appport/core/dist/repository-connection.d.ts.map +1 -0
- package/node_modules/@appport/core/dist/repository-connection.js +57 -0
- package/node_modules/@appport/core/dist/repository-connection.js.map +1 -0
- package/node_modules/@appport/core/dist/resolver.d.ts +130 -0
- package/node_modules/@appport/core/dist/resolver.d.ts.map +1 -0
- package/node_modules/@appport/core/dist/resolver.js +252 -0
- package/node_modules/@appport/core/dist/resolver.js.map +1 -0
- package/node_modules/@appport/core/dist/runtime-manifest.d.ts +68 -0
- package/node_modules/@appport/core/dist/runtime-manifest.d.ts.map +1 -0
- package/node_modules/@appport/core/dist/runtime-manifest.js +84 -0
- package/node_modules/@appport/core/dist/runtime-manifest.js.map +1 -0
- package/node_modules/@appport/core/dist/sanitize.d.ts +14 -0
- package/node_modules/@appport/core/dist/sanitize.d.ts.map +1 -0
- package/node_modules/@appport/core/dist/sanitize.js +49 -0
- package/node_modules/@appport/core/dist/sanitize.js.map +1 -0
- package/node_modules/@appport/core/dist/server-internal.d.ts +5 -0
- package/node_modules/@appport/core/dist/server-internal.d.ts.map +1 -0
- package/node_modules/@appport/core/dist/server-internal.js +4 -0
- package/node_modules/@appport/core/dist/server-internal.js.map +1 -0
- package/node_modules/@appport/core/dist/sessions.d.ts +29 -0
- package/node_modules/@appport/core/dist/sessions.d.ts.map +1 -0
- package/node_modules/@appport/core/dist/sessions.js +39 -0
- package/node_modules/@appport/core/dist/sessions.js.map +1 -0
- package/node_modules/@appport/core/dist/sha256.d.ts +3 -0
- package/node_modules/@appport/core/dist/sha256.d.ts.map +1 -0
- package/node_modules/@appport/core/dist/sha256.js +46 -0
- package/node_modules/@appport/core/dist/sha256.js.map +1 -0
- package/node_modules/@appport/core/dist/source-verification.d.ts +53 -0
- package/node_modules/@appport/core/dist/source-verification.d.ts.map +1 -0
- package/node_modules/@appport/core/dist/source-verification.js +92 -0
- package/node_modules/@appport/core/dist/source-verification.js.map +1 -0
- package/node_modules/@appport/core/dist/state-context.d.ts +312 -0
- package/node_modules/@appport/core/dist/state-context.d.ts.map +1 -0
- package/node_modules/@appport/core/dist/state-context.js +100 -0
- package/node_modules/@appport/core/dist/state-context.js.map +1 -0
- package/node_modules/@appport/core/dist/state.d.ts +96 -0
- package/node_modules/@appport/core/dist/state.d.ts.map +1 -0
- package/node_modules/@appport/core/dist/state.js +89 -0
- package/node_modules/@appport/core/dist/state.js.map +1 -0
- package/node_modules/@appport/core/dist/streams.d.ts +38 -0
- package/node_modules/@appport/core/dist/streams.d.ts.map +1 -0
- package/node_modules/@appport/core/dist/streams.js +123 -0
- package/node_modules/@appport/core/dist/streams.js.map +1 -0
- package/node_modules/@appport/core/dist/telemetry.d.ts +42 -0
- package/node_modules/@appport/core/dist/telemetry.d.ts.map +1 -0
- package/node_modules/@appport/core/dist/telemetry.js +32 -0
- package/node_modules/@appport/core/dist/telemetry.js.map +1 -0
- package/node_modules/@appport/core/dist/wasm-engine.d.ts +22 -0
- package/node_modules/@appport/core/dist/wasm-engine.d.ts.map +1 -0
- package/node_modules/@appport/core/dist/wasm-engine.js +367 -0
- package/node_modules/@appport/core/dist/wasm-engine.js.map +1 -0
- package/node_modules/@appport/core/package.json +58 -0
- package/node_modules/@appport/mobile/README.md +10 -0
- package/node_modules/@appport/mobile/dist/index.d.ts +66 -0
- package/node_modules/@appport/mobile/dist/index.d.ts.map +1 -0
- package/node_modules/@appport/mobile/dist/index.js +182 -0
- package/node_modules/@appport/mobile/dist/index.js.map +1 -0
- package/node_modules/@appport/mobile/package.json +33 -0
- package/node_modules/@appport/protocol/README.md +41 -0
- package/node_modules/@appport/protocol/dist/blob.d.ts +46 -0
- package/node_modules/@appport/protocol/dist/blob.d.ts.map +1 -0
- package/node_modules/@appport/protocol/dist/blob.js +23 -0
- package/node_modules/@appport/protocol/dist/blob.js.map +1 -0
- package/node_modules/@appport/protocol/dist/compatibility.d.ts +25 -0
- package/node_modules/@appport/protocol/dist/compatibility.d.ts.map +1 -0
- package/node_modules/@appport/protocol/dist/compatibility.js +189 -0
- package/node_modules/@appport/protocol/dist/compatibility.js.map +1 -0
- package/node_modules/@appport/protocol/dist/envelopes.d.ts +175 -0
- package/node_modules/@appport/protocol/dist/envelopes.d.ts.map +1 -0
- package/node_modules/@appport/protocol/dist/envelopes.js +97 -0
- package/node_modules/@appport/protocol/dist/envelopes.js.map +1 -0
- package/node_modules/@appport/protocol/dist/errors.d.ts +74 -0
- package/node_modules/@appport/protocol/dist/errors.d.ts.map +1 -0
- package/node_modules/@appport/protocol/dist/errors.js +91 -0
- package/node_modules/@appport/protocol/dist/errors.js.map +1 -0
- package/node_modules/@appport/protocol/dist/ids.d.ts +12 -0
- package/node_modules/@appport/protocol/dist/ids.d.ts.map +1 -0
- package/node_modules/@appport/protocol/dist/ids.js +50 -0
- package/node_modules/@appport/protocol/dist/ids.js.map +1 -0
- package/node_modules/@appport/protocol/dist/index.d.ts +20 -0
- package/node_modules/@appport/protocol/dist/index.d.ts.map +1 -0
- package/node_modules/@appport/protocol/dist/index.js +20 -0
- package/node_modules/@appport/protocol/dist/index.js.map +1 -0
- package/node_modules/@appport/protocol/dist/jsonschema.d.ts +50 -0
- package/node_modules/@appport/protocol/dist/jsonschema.d.ts.map +1 -0
- package/node_modules/@appport/protocol/dist/jsonschema.js +6 -0
- package/node_modules/@appport/protocol/dist/jsonschema.js.map +1 -0
- package/node_modules/@appport/protocol/dist/manifest.d.ts +131 -0
- package/node_modules/@appport/protocol/dist/manifest.d.ts.map +1 -0
- package/node_modules/@appport/protocol/dist/manifest.js +20 -0
- package/node_modules/@appport/protocol/dist/manifest.js.map +1 -0
- package/node_modules/@appport/protocol/dist/names.d.ts +26 -0
- package/node_modules/@appport/protocol/dist/names.d.ts.map +1 -0
- package/node_modules/@appport/protocol/dist/names.js +85 -0
- package/node_modules/@appport/protocol/dist/names.js.map +1 -0
- package/node_modules/@appport/protocol/dist/operations.d.ts +34 -0
- package/node_modules/@appport/protocol/dist/operations.d.ts.map +1 -0
- package/node_modules/@appport/protocol/dist/operations.js +9 -0
- package/node_modules/@appport/protocol/dist/operations.js.map +1 -0
- package/node_modules/@appport/protocol/dist/session.d.ts +27 -0
- package/node_modules/@appport/protocol/dist/session.d.ts.map +1 -0
- package/node_modules/@appport/protocol/dist/session.js +7 -0
- package/node_modules/@appport/protocol/dist/session.js.map +1 -0
- package/node_modules/@appport/protocol/dist/validate.d.ts +37 -0
- package/node_modules/@appport/protocol/dist/validate.d.ts.map +1 -0
- package/node_modules/@appport/protocol/dist/validate.js +321 -0
- package/node_modules/@appport/protocol/dist/validate.js.map +1 -0
- package/node_modules/@appport/protocol/dist/version.d.ts +27 -0
- package/node_modules/@appport/protocol/dist/version.d.ts.map +1 -0
- package/node_modules/@appport/protocol/dist/version.js +26 -0
- package/node_modules/@appport/protocol/dist/version.js.map +1 -0
- package/node_modules/@appport/protocol/package.json +25 -0
- package/node_modules/@appport/schema/README.md +32 -0
- package/node_modules/@appport/schema/dist/builder.d.ts +85 -0
- package/node_modules/@appport/schema/dist/builder.d.ts.map +1 -0
- package/node_modules/@appport/schema/dist/builder.js +278 -0
- package/node_modules/@appport/schema/dist/builder.js.map +1 -0
- package/node_modules/@appport/schema/dist/from-json-schema.d.ts +12 -0
- package/node_modules/@appport/schema/dist/from-json-schema.d.ts.map +1 -0
- package/node_modules/@appport/schema/dist/from-json-schema.js +186 -0
- package/node_modules/@appport/schema/dist/from-json-schema.js.map +1 -0
- package/node_modules/@appport/schema/dist/index.d.ts +23 -0
- package/node_modules/@appport/schema/dist/index.d.ts.map +1 -0
- package/node_modules/@appport/schema/dist/index.js +22 -0
- package/node_modules/@appport/schema/dist/index.js.map +1 -0
- package/node_modules/@appport/schema/dist/standard.d.ts +46 -0
- package/node_modules/@appport/schema/dist/standard.d.ts.map +1 -0
- package/node_modules/@appport/schema/dist/standard.js +42 -0
- package/node_modules/@appport/schema/dist/standard.js.map +1 -0
- package/node_modules/@appport/schema/dist/types.d.ts +40 -0
- package/node_modules/@appport/schema/dist/types.d.ts.map +1 -0
- package/node_modules/@appport/schema/dist/types.js +19 -0
- package/node_modules/@appport/schema/dist/types.js.map +1 -0
- package/node_modules/@appport/schema/package.json +28 -0
- package/node_modules/@appport/server/README.md +39 -0
- package/node_modules/@appport/server/dist/connection.d.ts +45 -0
- package/node_modules/@appport/server/dist/connection.d.ts.map +1 -0
- package/node_modules/@appport/server/dist/connection.js +217 -0
- package/node_modules/@appport/server/dist/connection.js.map +1 -0
- package/node_modules/@appport/server/dist/fetch.d.ts +10 -0
- package/node_modules/@appport/server/dist/fetch.d.ts.map +1 -0
- package/node_modules/@appport/server/dist/fetch.js +50 -0
- package/node_modules/@appport/server/dist/fetch.js.map +1 -0
- package/node_modules/@appport/server/dist/http.d.ts +80 -0
- package/node_modules/@appport/server/dist/http.d.ts.map +1 -0
- package/node_modules/@appport/server/dist/http.js +306 -0
- package/node_modules/@appport/server/dist/http.js.map +1 -0
- package/node_modules/@appport/server/dist/index.d.ts +11 -0
- package/node_modules/@appport/server/dist/index.d.ts.map +1 -0
- package/node_modules/@appport/server/dist/index.js +11 -0
- package/node_modules/@appport/server/dist/index.js.map +1 -0
- package/node_modules/@appport/server/dist/node-entry.d.ts +4 -0
- package/node_modules/@appport/server/dist/node-entry.d.ts.map +1 -0
- package/node_modules/@appport/server/dist/node-entry.js +4 -0
- package/node_modules/@appport/server/dist/node-entry.js.map +1 -0
- package/node_modules/@appport/server/dist/node.d.ts +45 -0
- package/node_modules/@appport/server/dist/node.d.ts.map +1 -0
- package/node_modules/@appport/server/dist/node.js +190 -0
- package/node_modules/@appport/server/dist/node.js.map +1 -0
- package/node_modules/@appport/server/dist/server.d.ts +83 -0
- package/node_modules/@appport/server/dist/server.d.ts.map +1 -0
- package/node_modules/@appport/server/dist/server.js +114 -0
- package/node_modules/@appport/server/dist/server.js.map +1 -0
- package/node_modules/@appport/server/dist/websocket.d.ts +25 -0
- package/node_modules/@appport/server/dist/websocket.d.ts.map +1 -0
- package/node_modules/@appport/server/dist/websocket.js +221 -0
- package/node_modules/@appport/server/dist/websocket.js.map +1 -0
- package/node_modules/@appport/server/package.json +34 -0
- package/node_modules/@appport/transport-electron/README.md +56 -0
- package/node_modules/@appport/transport-electron/dist/index.d.ts +11 -0
- package/node_modules/@appport/transport-electron/dist/index.d.ts.map +1 -0
- package/node_modules/@appport/transport-electron/dist/index.js +11 -0
- package/node_modules/@appport/transport-electron/dist/index.js.map +1 -0
- package/node_modules/@appport/transport-electron/dist/main.d.ts +31 -0
- package/node_modules/@appport/transport-electron/dist/main.d.ts.map +1 -0
- package/node_modules/@appport/transport-electron/dist/main.js +61 -0
- package/node_modules/@appport/transport-electron/dist/main.js.map +1 -0
- package/node_modules/@appport/transport-electron/dist/preload.d.ts +22 -0
- package/node_modules/@appport/transport-electron/dist/preload.d.ts.map +1 -0
- package/node_modules/@appport/transport-electron/dist/preload.js +29 -0
- package/node_modules/@appport/transport-electron/dist/preload.js.map +1 -0
- package/node_modules/@appport/transport-electron/dist/renderer.d.ts +16 -0
- package/node_modules/@appport/transport-electron/dist/renderer.d.ts.map +1 -0
- package/node_modules/@appport/transport-electron/dist/renderer.js +36 -0
- package/node_modules/@appport/transport-electron/dist/renderer.js.map +1 -0
- package/node_modules/@appport/transport-electron/dist/types.d.ts +49 -0
- package/node_modules/@appport/transport-electron/dist/types.d.ts.map +1 -0
- package/node_modules/@appport/transport-electron/dist/types.js +5 -0
- package/node_modules/@appport/transport-electron/dist/types.js.map +1 -0
- package/node_modules/@appport/transport-electron/package.json +46 -0
- package/node_modules/@appport/transport-http/README.md +24 -0
- package/node_modules/@appport/transport-http/dist/index.d.ts +18 -0
- package/node_modules/@appport/transport-http/dist/index.d.ts.map +1 -0
- package/node_modules/@appport/transport-http/dist/index.js +223 -0
- package/node_modules/@appport/transport-http/dist/index.js.map +1 -0
- package/node_modules/@appport/transport-http/package.json +29 -0
- package/node_modules/@appport/transport-inprocess/README.md +24 -0
- package/node_modules/@appport/transport-inprocess/dist/index.d.ts +16 -0
- package/node_modules/@appport/transport-inprocess/dist/index.d.ts.map +1 -0
- package/node_modules/@appport/transport-inprocess/dist/index.js +30 -0
- package/node_modules/@appport/transport-inprocess/dist/index.js.map +1 -0
- package/node_modules/@appport/transport-inprocess/package.json +30 -0
- package/node_modules/@appport/transport-tauri/README.md +45 -0
- package/node_modules/@appport/transport-tauri/dist/index.d.ts +23 -0
- package/node_modules/@appport/transport-tauri/dist/index.d.ts.map +1 -0
- package/node_modules/@appport/transport-tauri/dist/index.js +44 -0
- package/node_modules/@appport/transport-tauri/dist/index.js.map +1 -0
- package/node_modules/@appport/transport-tauri/package.json +29 -0
- package/node_modules/@appport/transport-websocket/README.md +22 -0
- package/node_modules/@appport/transport-websocket/dist/index.d.ts +26 -0
- package/node_modules/@appport/transport-websocket/dist/index.d.ts.map +1 -0
- package/node_modules/@appport/transport-websocket/dist/index.js +72 -0
- package/node_modules/@appport/transport-websocket/dist/index.js.map +1 -0
- package/node_modules/@appport/transport-websocket/package.json +29 -0
- package/package.json +79 -0
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import { type AppEventEnvelope, type AppPortManifest, type AppRequest, type AppResponse, type AppStreamRequest, type ApplicationDescriptor, type Principal, type Session, type TransportDescriptor } from "@appport/protocol";
|
|
2
|
+
import { type Authorizer } from "@appport/authorization";
|
|
3
|
+
import type { AnyCapability, AnyEvent, CapabilityDefinition, EventDefinition } from "./capability.js";
|
|
4
|
+
import { CapabilityRegistry } from "./registry.js";
|
|
5
|
+
import { EventBus, type EventFilter, type EventListener, type Unsubscribe } from "./events.js";
|
|
6
|
+
import { type EmitEventInput, type Logger } from "./context.js";
|
|
7
|
+
import { type SessionStore } from "./sessions.js";
|
|
8
|
+
import { type IdempotencyStore } from "./idempotency.js";
|
|
9
|
+
import { type TelemetrySink } from "./telemetry.js";
|
|
10
|
+
import { type RuntimeMode } from "./sanitize.js";
|
|
11
|
+
import type { VerificationResult } from "./assembly.js";
|
|
12
|
+
export declare const DEFAULT_TIMEOUT_MS = 30000;
|
|
13
|
+
export declare const DEFAULT_MAX_TIMEOUT_MS = 120000;
|
|
14
|
+
export interface ApplicationOptions {
|
|
15
|
+
application: ApplicationDescriptor;
|
|
16
|
+
capabilities?: ReadonlyArray<AnyCapability>;
|
|
17
|
+
events?: ReadonlyArray<AnyEvent>;
|
|
18
|
+
/** Defaults to allow-all, which is only appropriate locally (§37, §38). */
|
|
19
|
+
authorizer?: Authorizer;
|
|
20
|
+
sessions?: SessionStore;
|
|
21
|
+
idempotency?: IdempotencyStore;
|
|
22
|
+
telemetry?: TelemetrySink;
|
|
23
|
+
logger?: Logger;
|
|
24
|
+
/** Controls error sanitization and output validation (§16, §49). */
|
|
25
|
+
mode?: RuntimeMode;
|
|
26
|
+
defaultTimeoutMs?: number;
|
|
27
|
+
maxTimeoutMs?: number;
|
|
28
|
+
/** Validate handler output. Defaults to true in development, true in production too. */
|
|
29
|
+
validateOutput?: boolean;
|
|
30
|
+
/** Application services made available on the handler context. */
|
|
31
|
+
services?: Record<string, unknown>;
|
|
32
|
+
/** Optional storage handle surfaced as `context.db` (§10, §66). */
|
|
33
|
+
db?: unknown;
|
|
34
|
+
/** Transports advertised in the manifest (§40). */
|
|
35
|
+
transports?: TransportDescriptor[];
|
|
36
|
+
extensions?: string[];
|
|
37
|
+
/**
|
|
38
|
+
* Registers the reserved `appport.manifest` and `appport.ping` capabilities so
|
|
39
|
+
* discovery works on transports without URLs. Defaults to true.
|
|
40
|
+
*/
|
|
41
|
+
builtins?: boolean;
|
|
42
|
+
}
|
|
43
|
+
/** Per-request inputs supplied by the transport layer. */
|
|
44
|
+
export interface DispatchOptions {
|
|
45
|
+
session?: Session;
|
|
46
|
+
principal?: Principal;
|
|
47
|
+
/** Transport kind, recorded for telemetry only — never for trust (§52). */
|
|
48
|
+
transport?: string;
|
|
49
|
+
/** External abort (connection closed, client cancelled). */
|
|
50
|
+
signal?: AbortSignal;
|
|
51
|
+
}
|
|
52
|
+
/** A running stream capability invocation. */
|
|
53
|
+
export interface StreamExecution {
|
|
54
|
+
readonly streamId: string;
|
|
55
|
+
readonly requestId: string;
|
|
56
|
+
/** Validated chunks. Throws {@link AppPortError} on failure. */
|
|
57
|
+
readonly chunks: AsyncIterable<unknown>;
|
|
58
|
+
/** Requests best-effort termination of the underlying operation (§21). */
|
|
59
|
+
cancel(reason?: string): void;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* The AppPort capability runtime.
|
|
63
|
+
*
|
|
64
|
+
* It owns the dispatch pipeline described in §48 — receive, validate,
|
|
65
|
+
* authorize, execute, serialize, respond — and knows nothing about transports.
|
|
66
|
+
* Servers and transports feed it envelopes and carry the results.
|
|
67
|
+
*/
|
|
68
|
+
export declare class AppPortApplication {
|
|
69
|
+
#private;
|
|
70
|
+
readonly registry: CapabilityRegistry;
|
|
71
|
+
readonly bus: EventBus;
|
|
72
|
+
readonly descriptor: ApplicationDescriptor;
|
|
73
|
+
readonly sessions: SessionStore;
|
|
74
|
+
readonly logger: Logger;
|
|
75
|
+
readonly mode: RuntimeMode;
|
|
76
|
+
constructor(options: ApplicationOptions);
|
|
77
|
+
/** Registers a capability after construction. */
|
|
78
|
+
capability<Input, Output>(definition: CapabilityDefinition<Input, Output>): this;
|
|
79
|
+
/** Registers an event definition after construction. */
|
|
80
|
+
event<Payload>(definition: EventDefinition<Payload>): this;
|
|
81
|
+
/** Advertises an additional transport in the manifest (§40). */
|
|
82
|
+
advertiseTransport(descriptor: TransportDescriptor): this;
|
|
83
|
+
manifest(): AppPortManifest;
|
|
84
|
+
/**
|
|
85
|
+
* Verifies the application assembly for coherence and completeness (PR18).
|
|
86
|
+
*
|
|
87
|
+
* Checks:
|
|
88
|
+
* - All capabilities in the registry are structurally valid
|
|
89
|
+
* - All capabilities have implementations (explicit, definition-bound, or handler)
|
|
90
|
+
* - No orphan or duplicate implementations
|
|
91
|
+
*
|
|
92
|
+
* Returns a VerificationResult with ready state and detailed issues.
|
|
93
|
+
*
|
|
94
|
+
* NOTE: This runtime verification accepts both explicit implementations
|
|
95
|
+
* and legacy handlers (PR17) for backward compatibility.
|
|
96
|
+
*
|
|
97
|
+
* CRITICAL: Verification never executes business logic. It is purely structural.
|
|
98
|
+
*/
|
|
99
|
+
verify(): VerificationResult;
|
|
100
|
+
/** Subscribes to application events (§18). */
|
|
101
|
+
subscribe(filter: EventFilter | string, listener: EventListener, subscriptionId?: string): Unsubscribe;
|
|
102
|
+
/** Publishes an application event outside of a capability handler. */
|
|
103
|
+
emit(input: EmitEventInput, options?: {
|
|
104
|
+
traceId?: string;
|
|
105
|
+
}): Promise<AppEventEnvelope>;
|
|
106
|
+
/**
|
|
107
|
+
* Executes a request capability and produces a response envelope.
|
|
108
|
+
* Never throws for application-level failures: every outcome is an envelope.
|
|
109
|
+
*/
|
|
110
|
+
handleRequest(request: AppRequest, options?: DispatchOptions): Promise<AppResponse>;
|
|
111
|
+
/**
|
|
112
|
+
* Starts a stream capability. Protocol errors that occur before the first
|
|
113
|
+
* chunk are thrown so the transport can answer with an error response rather
|
|
114
|
+
* than an empty stream.
|
|
115
|
+
*/
|
|
116
|
+
handleStreamRequest(request: AppStreamRequest, options?: DispatchOptions): Promise<StreamExecution>;
|
|
117
|
+
/** Releases every stream and subscription. */
|
|
118
|
+
close(): Promise<void>;
|
|
119
|
+
}
|
|
120
|
+
/** Creates an {@link AppPortApplication}. */
|
|
121
|
+
export declare function createApplication(options: ApplicationOptions): AppPortApplication;
|
|
122
|
+
//# sourceMappingURL=application.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"application.d.ts","sourceRoot":"","sources":["../src/application.ts"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1,515 @@
|
|
|
1
|
+
import { AppPortError, createErrorResponse, createEvent, createSuccessResponse, errors, isValidName, newEventId, newStreamId, newTraceId } from "@appport/protocol";
|
|
2
|
+
import { allowAllAuthorizer, createAuthorizationContext, decisionToError } from "@appport/authorization";
|
|
3
|
+
import { formatIssues, issuesToDetails } from "@appport/schema";
|
|
4
|
+
import { CapabilityRegistry } from "./registry.js";
|
|
5
|
+
import { EventBus } from "./events.js";
|
|
6
|
+
import { consoleLogger, silentLogger } from "./context.js";
|
|
7
|
+
import { createStreamContext, toAsyncIterable } from "./streams.js";
|
|
8
|
+
import { MemorySessionStore } from "./sessions.js";
|
|
9
|
+
import { DEFAULT_IDEMPOTENCY_TTL_MS, idempotencyStorageKey, MemoryIdempotencyStore } from "./idempotency.js";
|
|
10
|
+
import { ConcurrencyGate } from "./concurrency.js";
|
|
11
|
+
import { createBuiltinCapabilities } from "./builtins.js";
|
|
12
|
+
import { noopTelemetry } from "./telemetry.js";
|
|
13
|
+
import { toWireError } from "./sanitize.js";
|
|
14
|
+
import { verifyApplication, verifyApplicationWithHandlers } from "./assembly.js";
|
|
15
|
+
export const DEFAULT_TIMEOUT_MS = 30_000;
|
|
16
|
+
export const DEFAULT_MAX_TIMEOUT_MS = 120_000;
|
|
17
|
+
/**
|
|
18
|
+
* The AppPort capability runtime.
|
|
19
|
+
*
|
|
20
|
+
* It owns the dispatch pipeline described in §48 — receive, validate,
|
|
21
|
+
* authorize, execute, serialize, respond — and knows nothing about transports.
|
|
22
|
+
* Servers and transports feed it envelopes and carry the results.
|
|
23
|
+
*/
|
|
24
|
+
export class AppPortApplication {
|
|
25
|
+
registry;
|
|
26
|
+
bus;
|
|
27
|
+
descriptor;
|
|
28
|
+
sessions;
|
|
29
|
+
logger;
|
|
30
|
+
mode;
|
|
31
|
+
#authorizer;
|
|
32
|
+
#idempotency;
|
|
33
|
+
#telemetry;
|
|
34
|
+
#concurrency = new ConcurrencyGate();
|
|
35
|
+
#inflightIdempotent = new Map();
|
|
36
|
+
#defaultTimeoutMs;
|
|
37
|
+
#maxTimeoutMs;
|
|
38
|
+
#validateOutput;
|
|
39
|
+
#services;
|
|
40
|
+
#db;
|
|
41
|
+
#transports;
|
|
42
|
+
#extensions;
|
|
43
|
+
#openStreams = new Set();
|
|
44
|
+
#closed = false;
|
|
45
|
+
constructor(options) {
|
|
46
|
+
this.descriptor = options.application;
|
|
47
|
+
this.mode = options.mode ?? (process.env["NODE_ENV"] === "production" ? "production" : "development");
|
|
48
|
+
this.logger = options.logger ?? (this.mode === "development" ? consoleLogger() : silentLogger);
|
|
49
|
+
this.registry = new CapabilityRegistry();
|
|
50
|
+
this.bus = new EventBus(this.logger);
|
|
51
|
+
this.sessions = options.sessions ?? new MemorySessionStore();
|
|
52
|
+
this.#authorizer = options.authorizer ?? allowAllAuthorizer();
|
|
53
|
+
this.#idempotency = options.idempotency ?? new MemoryIdempotencyStore();
|
|
54
|
+
this.#telemetry = options.telemetry ?? noopTelemetry;
|
|
55
|
+
this.#defaultTimeoutMs = options.defaultTimeoutMs ?? DEFAULT_TIMEOUT_MS;
|
|
56
|
+
this.#maxTimeoutMs = options.maxTimeoutMs ?? DEFAULT_MAX_TIMEOUT_MS;
|
|
57
|
+
this.#validateOutput = options.validateOutput ?? true;
|
|
58
|
+
this.#services = options.services ?? {};
|
|
59
|
+
this.#db = options.db;
|
|
60
|
+
this.#transports = options.transports ?? [];
|
|
61
|
+
this.#extensions = options.extensions ?? [];
|
|
62
|
+
for (const capability of options.capabilities ?? [])
|
|
63
|
+
this.registry.register(capability);
|
|
64
|
+
for (const event of options.events ?? [])
|
|
65
|
+
this.registry.registerEvent(event);
|
|
66
|
+
if (options.builtins !== false) {
|
|
67
|
+
for (const capability of createBuiltinCapabilities({ manifest: () => this.manifest() })) {
|
|
68
|
+
this.registry.register(capability);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
/** Registers a capability after construction. */
|
|
73
|
+
capability(definition) {
|
|
74
|
+
this.registry.register(definition);
|
|
75
|
+
return this;
|
|
76
|
+
}
|
|
77
|
+
/** Registers an event definition after construction. */
|
|
78
|
+
event(definition) {
|
|
79
|
+
this.registry.registerEvent(definition);
|
|
80
|
+
return this;
|
|
81
|
+
}
|
|
82
|
+
/** Advertises an additional transport in the manifest (§40). */
|
|
83
|
+
advertiseTransport(descriptor) {
|
|
84
|
+
const existing = this.#transports.findIndex((entry) => entry.kind === descriptor.kind && entry.endpoint === descriptor.endpoint);
|
|
85
|
+
if (existing === -1)
|
|
86
|
+
this.#transports.push(descriptor);
|
|
87
|
+
else
|
|
88
|
+
this.#transports[existing] = descriptor;
|
|
89
|
+
return this;
|
|
90
|
+
}
|
|
91
|
+
manifest() {
|
|
92
|
+
return this.registry.manifest({
|
|
93
|
+
application: this.descriptor,
|
|
94
|
+
transports: [...this.#transports],
|
|
95
|
+
extensions: [...this.#extensions]
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Verifies the application assembly for coherence and completeness (PR18).
|
|
100
|
+
*
|
|
101
|
+
* Checks:
|
|
102
|
+
* - All capabilities in the registry are structurally valid
|
|
103
|
+
* - All capabilities have implementations (explicit, definition-bound, or handler)
|
|
104
|
+
* - No orphan or duplicate implementations
|
|
105
|
+
*
|
|
106
|
+
* Returns a VerificationResult with ready state and detailed issues.
|
|
107
|
+
*
|
|
108
|
+
* NOTE: This runtime verification accepts both explicit implementations
|
|
109
|
+
* and legacy handlers (PR17) for backward compatibility.
|
|
110
|
+
*
|
|
111
|
+
* CRITICAL: Verification never executes business logic. It is purely structural.
|
|
112
|
+
*/
|
|
113
|
+
verify() {
|
|
114
|
+
// Build an ApplicationAssembly from the current registry state
|
|
115
|
+
const capabilities = this.registry.capabilities();
|
|
116
|
+
const implementations = new Map();
|
|
117
|
+
// Collect all explicit implementations from the registry
|
|
118
|
+
// Note: We don't collect implementations from capability definitions here;
|
|
119
|
+
// the verifyApplicationWithHandlers function will check capability.implementation
|
|
120
|
+
for (const capability of capabilities) {
|
|
121
|
+
if (capability.implementation) {
|
|
122
|
+
implementations.set(`${capability.name}@${capability.version}`, capability.implementation);
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
const assembly = {
|
|
126
|
+
identity: {
|
|
127
|
+
id: this.descriptor.id,
|
|
128
|
+
name: this.descriptor.name,
|
|
129
|
+
version: this.descriptor.version
|
|
130
|
+
},
|
|
131
|
+
provides: capabilities,
|
|
132
|
+
requires: [],
|
|
133
|
+
implementations
|
|
134
|
+
};
|
|
135
|
+
// Use the handler-aware verification for runtime
|
|
136
|
+
return verifyApplicationWithHandlers(assembly);
|
|
137
|
+
}
|
|
138
|
+
/** Subscribes to application events (§18). */
|
|
139
|
+
subscribe(filter, listener, subscriptionId) {
|
|
140
|
+
return this.bus.subscribe(filter, listener, subscriptionId);
|
|
141
|
+
}
|
|
142
|
+
/** Publishes an application event outside of a capability handler. */
|
|
143
|
+
async emit(input, options = {}) {
|
|
144
|
+
return this.#emit(input, options.traceId);
|
|
145
|
+
}
|
|
146
|
+
async #emit(input, traceId) {
|
|
147
|
+
if (!isValidName(input.name)) {
|
|
148
|
+
throw errors.internal(`Invalid event name: ${input.name}`);
|
|
149
|
+
}
|
|
150
|
+
const definition = this.registry.getEvent(input.name, input.version);
|
|
151
|
+
if (!definition) {
|
|
152
|
+
if (this.registry.getEvent(input.name)) {
|
|
153
|
+
throw errors.internal(`Event ${input.name}@${input.version ?? "?"} is not registered`);
|
|
154
|
+
}
|
|
155
|
+
this.logger.warn("emitting an event that is not declared in the manifest", { event: input.name });
|
|
156
|
+
}
|
|
157
|
+
else {
|
|
158
|
+
const result = definition.payload.validate(input.payload);
|
|
159
|
+
if (!result.ok) {
|
|
160
|
+
throw new AppPortError("INTERNAL_ERROR", "Event payload failed validation", {
|
|
161
|
+
internal: `${input.name}: ${formatIssues(result.issues)}`
|
|
162
|
+
});
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
const envelope = createEvent({
|
|
166
|
+
name: input.name,
|
|
167
|
+
version: input.version ?? definition?.version ?? 1,
|
|
168
|
+
eventId: newEventId(),
|
|
169
|
+
payload: input.payload,
|
|
170
|
+
...(traceId ? { traceId } : {})
|
|
171
|
+
});
|
|
172
|
+
await this.bus.publish(envelope);
|
|
173
|
+
return envelope;
|
|
174
|
+
}
|
|
175
|
+
/**
|
|
176
|
+
* Executes a request capability and produces a response envelope.
|
|
177
|
+
* Never throws for application-level failures: every outcome is an envelope.
|
|
178
|
+
*/
|
|
179
|
+
async handleRequest(request, options = {}) {
|
|
180
|
+
const started = Date.now();
|
|
181
|
+
const traceId = request.traceId ?? newTraceId();
|
|
182
|
+
let capabilityRef = request.capability;
|
|
183
|
+
let outcome;
|
|
184
|
+
let idempotentReplay = false;
|
|
185
|
+
try {
|
|
186
|
+
const definition = this.registry.resolve(request.capability.name, request.capability.version);
|
|
187
|
+
capabilityRef = { name: definition.name, version: definition.version };
|
|
188
|
+
if (definition.kind === "stream") {
|
|
189
|
+
throw errors.invalidRequest(`Capability ${definition.name}@${definition.version} is a stream capability; use a stream request`);
|
|
190
|
+
}
|
|
191
|
+
const input = this.#validateInput(definition, request.input);
|
|
192
|
+
const authorization = await this.#authorize(definition, input, options);
|
|
193
|
+
const replayKey = definition.idempotency === "supported" && request.idempotencyKey
|
|
194
|
+
? idempotencyStorageKey({
|
|
195
|
+
key: request.idempotencyKey,
|
|
196
|
+
capability: definition.name,
|
|
197
|
+
version: definition.version,
|
|
198
|
+
sessionId: options.session?.id
|
|
199
|
+
})
|
|
200
|
+
: undefined;
|
|
201
|
+
if (replayKey) {
|
|
202
|
+
const stored = await this.#idempotency.get(replayKey);
|
|
203
|
+
if (stored) {
|
|
204
|
+
idempotentReplay = true;
|
|
205
|
+
outcome = { response: replayResponse(stored.response, request.requestId, traceId) };
|
|
206
|
+
this.#recordTelemetry(request, capabilityRef, "request", options, started, outcome, {
|
|
207
|
+
traceId,
|
|
208
|
+
idempotentReplay
|
|
209
|
+
});
|
|
210
|
+
return outcome.response;
|
|
211
|
+
}
|
|
212
|
+
const inflight = this.#inflightIdempotent.get(replayKey);
|
|
213
|
+
if (inflight) {
|
|
214
|
+
const response = replayResponse(await inflight, request.requestId, traceId);
|
|
215
|
+
this.#recordTelemetry(request, capabilityRef, "request", options, started, { response }, { traceId, idempotentReplay: true });
|
|
216
|
+
return response;
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
const execute = async () => {
|
|
220
|
+
const output = await this.#execute(definition, input, request, options, authorization, traceId);
|
|
221
|
+
return createSuccessResponse(request.requestId, output, { traceId });
|
|
222
|
+
};
|
|
223
|
+
let responsePromise;
|
|
224
|
+
if (replayKey) {
|
|
225
|
+
responsePromise = execute();
|
|
226
|
+
this.#inflightIdempotent.set(replayKey, responsePromise);
|
|
227
|
+
responsePromise.catch(() => undefined).finally(() => this.#inflightIdempotent.delete(replayKey));
|
|
228
|
+
}
|
|
229
|
+
else {
|
|
230
|
+
responsePromise = execute();
|
|
231
|
+
}
|
|
232
|
+
const response = await responsePromise;
|
|
233
|
+
if (replayKey) {
|
|
234
|
+
const now = Date.now();
|
|
235
|
+
await this.#idempotency.set({
|
|
236
|
+
key: replayKey,
|
|
237
|
+
capability: definition.name,
|
|
238
|
+
version: definition.version,
|
|
239
|
+
requestId: request.requestId,
|
|
240
|
+
response,
|
|
241
|
+
storedAt: now,
|
|
242
|
+
expiresAt: now + DEFAULT_IDEMPOTENCY_TTL_MS
|
|
243
|
+
});
|
|
244
|
+
}
|
|
245
|
+
outcome = { response };
|
|
246
|
+
}
|
|
247
|
+
catch (error) {
|
|
248
|
+
const wire = toWireError(error, this.mode);
|
|
249
|
+
outcome = { response: createErrorResponse(request.requestId, wire, { traceId }), errorCode: wire.code };
|
|
250
|
+
if (!AppPortError.is(error)) {
|
|
251
|
+
this.logger.error("capability handler threw a non-protocol error", {
|
|
252
|
+
capability: capabilityRef.name,
|
|
253
|
+
requestId: request.requestId
|
|
254
|
+
});
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
this.#recordTelemetry(request, capabilityRef, "request", options, started, outcome, {
|
|
258
|
+
traceId,
|
|
259
|
+
idempotentReplay
|
|
260
|
+
});
|
|
261
|
+
return outcome.response;
|
|
262
|
+
}
|
|
263
|
+
/**
|
|
264
|
+
* Starts a stream capability. Protocol errors that occur before the first
|
|
265
|
+
* chunk are thrown so the transport can answer with an error response rather
|
|
266
|
+
* than an empty stream.
|
|
267
|
+
*/
|
|
268
|
+
async handleStreamRequest(request, options = {}) {
|
|
269
|
+
const started = Date.now();
|
|
270
|
+
const traceId = request.traceId ?? newTraceId();
|
|
271
|
+
const definition = this.registry.resolve(request.capability.name, request.capability.version);
|
|
272
|
+
if (definition.kind !== "stream") {
|
|
273
|
+
throw errors.invalidRequest(`Capability ${definition.name}@${definition.version} is not a stream capability`);
|
|
274
|
+
}
|
|
275
|
+
const input = this.#validateInput(definition, request.input);
|
|
276
|
+
const authorization = await this.#authorize(definition, input, options);
|
|
277
|
+
const controller = new AbortController();
|
|
278
|
+
const timeoutMs = this.#resolveTimeout(definition.timeoutMs, request.timeoutMs);
|
|
279
|
+
const timer = setTimeout(() => controller.abort(errors.timeout()), timeoutMs);
|
|
280
|
+
if (timer.unref)
|
|
281
|
+
timer.unref();
|
|
282
|
+
const abortParent = () => controller.abort(errors.cancelled());
|
|
283
|
+
options.signal?.addEventListener("abort", abortParent, { once: true });
|
|
284
|
+
if (options.signal?.aborted)
|
|
285
|
+
controller.abort(errors.cancelled());
|
|
286
|
+
const release = () => {
|
|
287
|
+
clearTimeout(timer);
|
|
288
|
+
options.signal?.removeEventListener("abort", abortParent);
|
|
289
|
+
this.#openStreams.delete(release);
|
|
290
|
+
};
|
|
291
|
+
this.#openStreams.add(release);
|
|
292
|
+
const context = this.#createContext({
|
|
293
|
+
request,
|
|
294
|
+
definition,
|
|
295
|
+
options,
|
|
296
|
+
authorization,
|
|
297
|
+
traceId,
|
|
298
|
+
signal: controller.signal,
|
|
299
|
+
deadline: started + timeoutMs
|
|
300
|
+
});
|
|
301
|
+
const self = this;
|
|
302
|
+
let chunkCount = 0;
|
|
303
|
+
async function* iterate() {
|
|
304
|
+
let failure;
|
|
305
|
+
try {
|
|
306
|
+
// If an implementation is bound, execute it; otherwise use the handler directly.
|
|
307
|
+
// This supports PR17: Capability Implementation Binding & Runtime Enforcement
|
|
308
|
+
const source = definition.implementation
|
|
309
|
+
? await definition.implementation.execute(input, context)
|
|
310
|
+
: await definition.handler(input, context);
|
|
311
|
+
for await (const chunk of toAsyncIterable(source)) {
|
|
312
|
+
if (controller.signal.aborted) {
|
|
313
|
+
throw controller.signal.reason instanceof AppPortError ? controller.signal.reason : errors.cancelled();
|
|
314
|
+
}
|
|
315
|
+
chunkCount += 1;
|
|
316
|
+
yield self.#validateChunk(definition, chunk);
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
catch (error) {
|
|
320
|
+
failure = error;
|
|
321
|
+
throw error;
|
|
322
|
+
}
|
|
323
|
+
finally {
|
|
324
|
+
release();
|
|
325
|
+
// Telemetry reports what actually happened to the stream, including a
|
|
326
|
+
// cancellation or a failed chunk (§20).
|
|
327
|
+
const outcome = failure === undefined
|
|
328
|
+
? { response: createSuccessResponse(request.requestId, null, { traceId }) }
|
|
329
|
+
: {
|
|
330
|
+
response: createErrorResponse(request.requestId, toWireError(failure, self.mode), { traceId })
|
|
331
|
+
};
|
|
332
|
+
self.#recordTelemetry(request, { name: definition.name, version: definition.version }, "stream", options, started, outcome, { traceId, chunks: chunkCount });
|
|
333
|
+
}
|
|
334
|
+
}
|
|
335
|
+
return {
|
|
336
|
+
streamId: newStreamId(),
|
|
337
|
+
requestId: request.requestId,
|
|
338
|
+
chunks: iterate(),
|
|
339
|
+
cancel: (reason) => controller.abort(errors.cancelled(reason ?? "Cancelled by client"))
|
|
340
|
+
};
|
|
341
|
+
}
|
|
342
|
+
/** Releases every stream and subscription. */
|
|
343
|
+
async close() {
|
|
344
|
+
if (this.#closed)
|
|
345
|
+
return;
|
|
346
|
+
this.#closed = true;
|
|
347
|
+
for (const release of [...this.#openStreams])
|
|
348
|
+
release();
|
|
349
|
+
this.bus.clear();
|
|
350
|
+
}
|
|
351
|
+
// -------------------------------------------------------------------------
|
|
352
|
+
// Pipeline steps
|
|
353
|
+
// -------------------------------------------------------------------------
|
|
354
|
+
#validateInput(definition, raw) {
|
|
355
|
+
const result = definition.input.validate(raw);
|
|
356
|
+
if (!result.ok) {
|
|
357
|
+
throw errors.invalidInput(`Input for ${definition.name}@${definition.version} is invalid: ${formatIssues(result.issues)}`, issuesToDetails(result.issues));
|
|
358
|
+
}
|
|
359
|
+
return result.value;
|
|
360
|
+
}
|
|
361
|
+
#validateChunk(definition, chunk) {
|
|
362
|
+
if (!this.#validateOutput)
|
|
363
|
+
return chunk;
|
|
364
|
+
const result = definition.output.validate(chunk);
|
|
365
|
+
if (!result.ok) {
|
|
366
|
+
throw new AppPortError("STREAM_ERROR", "Stream chunk failed output validation", {
|
|
367
|
+
internal: `${definition.name}: ${formatIssues(result.issues)}`
|
|
368
|
+
});
|
|
369
|
+
}
|
|
370
|
+
return result.value;
|
|
371
|
+
}
|
|
372
|
+
async #authorize(definition, input, options) {
|
|
373
|
+
const decision = await this.#authorizer.authorize({
|
|
374
|
+
capability: { name: definition.name, version: definition.version },
|
|
375
|
+
required: definition.authorization,
|
|
376
|
+
...(options.session ? { session: options.session } : {}),
|
|
377
|
+
...(options.principal ?? options.session?.principal
|
|
378
|
+
? { principal: (options.principal ?? options.session?.principal) }
|
|
379
|
+
: {}),
|
|
380
|
+
input,
|
|
381
|
+
...(options.transport ? { transport: options.transport } : {})
|
|
382
|
+
});
|
|
383
|
+
if (!decision.allowed)
|
|
384
|
+
throw decisionToError(decision);
|
|
385
|
+
return decision.permissions ?? options.session?.permissions ?? [];
|
|
386
|
+
}
|
|
387
|
+
#resolveTimeout(capabilityTimeout, requested) {
|
|
388
|
+
const base = capabilityTimeout ?? this.#defaultTimeoutMs;
|
|
389
|
+
const desired = requested ?? base;
|
|
390
|
+
return Math.min(desired, capabilityTimeout ?? this.#maxTimeoutMs, this.#maxTimeoutMs);
|
|
391
|
+
}
|
|
392
|
+
async #execute(definition, input, request, options, authorization, traceId) {
|
|
393
|
+
const controller = new AbortController();
|
|
394
|
+
const timeoutMs = this.#resolveTimeout(definition.timeoutMs, request.timeoutMs);
|
|
395
|
+
const deadline = Date.now() + timeoutMs;
|
|
396
|
+
const abortParent = () => controller.abort(errors.cancelled());
|
|
397
|
+
if (options.signal?.aborted)
|
|
398
|
+
controller.abort(errors.cancelled());
|
|
399
|
+
else
|
|
400
|
+
options.signal?.addEventListener("abort", abortParent, { once: true });
|
|
401
|
+
const context = this.#createContext({
|
|
402
|
+
request,
|
|
403
|
+
definition,
|
|
404
|
+
options,
|
|
405
|
+
authorization,
|
|
406
|
+
traceId,
|
|
407
|
+
signal: controller.signal,
|
|
408
|
+
deadline
|
|
409
|
+
});
|
|
410
|
+
let timer;
|
|
411
|
+
const timeout = new Promise((_, reject) => {
|
|
412
|
+
timer = setTimeout(() => {
|
|
413
|
+
const error = errors.timeout(`Capability ${definition.name}@${definition.version} exceeded ${timeoutMs}ms`);
|
|
414
|
+
controller.abort(error);
|
|
415
|
+
reject(error);
|
|
416
|
+
}, timeoutMs);
|
|
417
|
+
if (timer.unref)
|
|
418
|
+
timer.unref();
|
|
419
|
+
});
|
|
420
|
+
try {
|
|
421
|
+
const work = this.#concurrency.run(definition.concurrency, `${definition.name}@${definition.version}`, input, async () => {
|
|
422
|
+
// If an implementation is bound, execute it; otherwise use the handler directly.
|
|
423
|
+
// This supports PR17: Capability Implementation Binding & Runtime Enforcement
|
|
424
|
+
if (definition.implementation) {
|
|
425
|
+
return await definition.implementation.execute(input, context);
|
|
426
|
+
}
|
|
427
|
+
return definition.handler(input, context);
|
|
428
|
+
});
|
|
429
|
+
const output = await Promise.race([work, timeout]);
|
|
430
|
+
if (!this.#validateOutput)
|
|
431
|
+
return output;
|
|
432
|
+
const result = definition.output.validate(output);
|
|
433
|
+
if (!result.ok) {
|
|
434
|
+
throw new AppPortError("INTERNAL_ERROR", "Capability produced an invalid response", {
|
|
435
|
+
internal: `${definition.name}: ${formatIssues(result.issues)}`
|
|
436
|
+
});
|
|
437
|
+
}
|
|
438
|
+
return result.value;
|
|
439
|
+
}
|
|
440
|
+
finally {
|
|
441
|
+
if (timer)
|
|
442
|
+
clearTimeout(timer);
|
|
443
|
+
options.signal?.removeEventListener("abort", abortParent);
|
|
444
|
+
}
|
|
445
|
+
}
|
|
446
|
+
#createContext(args) {
|
|
447
|
+
const { request, definition, options, authorization, traceId, signal, deadline } = args;
|
|
448
|
+
const metadata = {
|
|
449
|
+
...(request.metadata ?? {}),
|
|
450
|
+
...(options.transport ? { transport: options.transport } : {}),
|
|
451
|
+
receivedAt: request.metadata?.receivedAt ?? new Date().toISOString()
|
|
452
|
+
};
|
|
453
|
+
const principal = options.principal ?? options.session?.principal;
|
|
454
|
+
return {
|
|
455
|
+
requestId: request.requestId,
|
|
456
|
+
traceId,
|
|
457
|
+
capability: { name: definition.name, version: definition.version },
|
|
458
|
+
...(options.session ? { session: options.session } : {}),
|
|
459
|
+
...(principal ? { principal } : {}),
|
|
460
|
+
authorization: createAuthorizationContext({
|
|
461
|
+
...(options.session ? { session: options.session } : {}),
|
|
462
|
+
...(principal ? { principal } : {}),
|
|
463
|
+
permissions: authorization
|
|
464
|
+
}),
|
|
465
|
+
metadata,
|
|
466
|
+
signal,
|
|
467
|
+
deadline,
|
|
468
|
+
...(request.idempotencyKey ? { idempotencyKey: request.idempotencyKey } : {}),
|
|
469
|
+
logger: this.logger,
|
|
470
|
+
extensions: request.extensions ?? {},
|
|
471
|
+
emit: async (event) => {
|
|
472
|
+
await this.#emit(event, traceId);
|
|
473
|
+
},
|
|
474
|
+
createStream: (highWaterMark) => createStreamContext(signal, highWaterMark),
|
|
475
|
+
...(this.#db !== undefined ? { db: this.#db } : {}),
|
|
476
|
+
services: this.#services
|
|
477
|
+
};
|
|
478
|
+
}
|
|
479
|
+
#recordTelemetry(request, capability, kind, options, started, outcome, extra) {
|
|
480
|
+
const principal = options.principal ?? options.session?.principal;
|
|
481
|
+
const record = {
|
|
482
|
+
requestId: request.requestId,
|
|
483
|
+
traceId: extra.traceId,
|
|
484
|
+
applicationId: this.descriptor.id,
|
|
485
|
+
capability: capability.name,
|
|
486
|
+
version: capability.version,
|
|
487
|
+
kind,
|
|
488
|
+
transport: options.transport ?? "unknown",
|
|
489
|
+
...(principal ? { principal: principal.id } : {}),
|
|
490
|
+
...(options.session ? { sessionId: options.session.id } : {}),
|
|
491
|
+
startTime: started,
|
|
492
|
+
durationMs: Date.now() - started,
|
|
493
|
+
success: outcome.response.ok,
|
|
494
|
+
...(outcome.response.ok ? {} : { errorCode: outcome.response.error.code }),
|
|
495
|
+
...(extra.chunks !== undefined ? { chunks: extra.chunks } : {}),
|
|
496
|
+
...(extra.idempotentReplay ? { idempotentReplay: true } : {})
|
|
497
|
+
};
|
|
498
|
+
try {
|
|
499
|
+
this.#telemetry.record(record);
|
|
500
|
+
}
|
|
501
|
+
catch {
|
|
502
|
+
// Telemetry must never break a request.
|
|
503
|
+
}
|
|
504
|
+
}
|
|
505
|
+
}
|
|
506
|
+
function replayResponse(stored, requestId, traceId) {
|
|
507
|
+
return stored.ok
|
|
508
|
+
? createSuccessResponse(requestId, stored.output, { traceId })
|
|
509
|
+
: createErrorResponse(requestId, stored.error, { traceId });
|
|
510
|
+
}
|
|
511
|
+
/** Creates an {@link AppPortApplication}. */
|
|
512
|
+
export function createApplication(options) {
|
|
513
|
+
return new AppPortApplication(options);
|
|
514
|
+
}
|
|
515
|
+
//# sourceMappingURL=application.js.map
|