@zlink-systems/framework 0.29.1 → 0.30.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 +150 -68
- package/dist/.tsbuildinfo +1 -1
- package/dist/contracts/Actors/ZLinkActorClient.d.ts +2 -1
- package/dist/contracts/Channels/Calls.d.ts +2 -1
- package/dist/contracts/Common/ZLinkMessageMetadata.js +11 -5
- package/dist/contracts/Configuration/Builders.d.ts +1 -2
- package/dist/contracts/Configuration/Configs.d.ts +0 -5
- package/dist/contracts/Configuration/RegistrationBuilders.js +6 -4
- package/dist/contracts/Configuration/RegistrationTypes.d.ts +1 -6
- package/dist/contracts/Configuration/RegistrationValidators.js +4 -4
- package/dist/contracts/Configuration/index.d.ts +1 -1
- package/dist/contracts/Handlers/Attributes.d.ts +5 -13
- package/dist/contracts/Handlers/Attributes.js +7 -11
- package/dist/contracts/Handlers/JsonContract.d.ts +2 -46
- package/dist/contracts/Handlers/JsonContract.js +4 -153
- package/dist/contracts/Spots/Contracts.d.ts +2 -1
- package/dist/internal.d.ts +1 -0
- package/dist/internal.js +3 -1
- package/dist/nest-integration.d.ts +1 -1
- package/dist/nest-integration.js +2 -1
- package/dist/runtime/actors/actor-client.d.ts +1 -1
- package/dist/runtime/actors/actor-client.js +14 -12
- package/dist/runtime/actors/actor-handoff.d.ts +3 -2
- package/dist/runtime/actors/actor-handoff.js +15 -7
- package/dist/runtime/actors/actor-join-relocation.d.ts +1 -0
- package/dist/runtime/actors/actor-local-native-join.js +9 -12
- package/dist/runtime/actors/actor-remote-wire.js +15 -0
- package/dist/runtime/actors/actor-routed-join-transport.d.ts +6 -2
- package/dist/runtime/actors/actor-routed-json-request.d.ts +2 -0
- package/dist/runtime/actors/index.d.ts +2 -1
- package/dist/runtime/actors/index.js +18 -6
- package/dist/runtime/actors/spot-actor-dispatch.js +2 -2
- package/dist/runtime/admission.d.ts +1 -1
- package/dist/runtime/admission.js +15 -5
- package/dist/runtime/application-jobs/application-ingress-record-owner.d.ts +9 -9
- package/dist/runtime/application-jobs/application-ingress-record-owner.js +45 -23
- package/dist/runtime/application-jobs/application-job-queue-scope.d.ts +5 -2
- package/dist/runtime/application-jobs/application-job-queue-scope.js +41 -21
- package/dist/runtime/application-jobs/contracts.d.ts +15 -2
- package/dist/runtime/backend/contracts/index.d.ts +27 -27
- package/dist/runtime/backend/mesh-completion-table.d.ts +15 -5
- package/dist/runtime/backend/mesh-completion-table.js +160 -50
- package/dist/runtime/backend/mesh-dispatch-pump.d.ts +3 -0
- package/dist/runtime/backend/mesh-dispatch-pump.js +53 -36
- package/dist/runtime/backend/node/node-backend-adapter-factory.js +6 -1
- package/dist/runtime/backend/node/node-backend-adapter-support.d.ts +3 -3
- package/dist/runtime/backend/node/node-backend-adapter-support.js +33 -31
- package/dist/runtime/backend/node/node-dealer-channel-client-transport.d.ts +1 -1
- package/dist/runtime/backend/node/node-dealer-channel-client-transport.js +5 -2
- package/dist/runtime/backend/node/node-mesh-backend-adapter.d.ts +1 -9
- package/dist/runtime/backend/node/node-mesh-backend-adapter.js +1 -1
- package/dist/runtime/backend/node/node-raw-binding-port.js +50 -25
- package/dist/runtime/backend/node/node-raw-mesh-backend.d.ts +22 -16
- package/dist/runtime/backend/node/node-raw-mesh-backend.js +133 -149
- package/dist/runtime/backend/node/node-socket-backend-adapter.js +15 -10
- package/dist/runtime/backend/raw-binding-port.d.ts +10 -3
- package/dist/runtime/backend/runtime-message.d.ts +1 -0
- package/dist/runtime/backend/runtime-message.js +5 -0
- package/dist/runtime/backend/runtime-values.d.ts +1 -0
- package/dist/runtime/backend/runtime-values.js +2 -1
- package/dist/runtime/channels/channel-clients.d.ts +1 -0
- package/dist/runtime/channels/channel-clients.js +58 -21
- package/dist/runtime/channels/channel-dispatch-pipeline.d.ts +3 -2
- package/dist/runtime/channels/channel-dispatch-pipeline.js +20 -11
- package/dist/runtime/channels/channel-dispatch-services.d.ts +1 -0
- package/dist/runtime/channels/channel-dispatch-services.js +45 -0
- package/dist/runtime/channels/channel-dispatchers.d.ts +1 -1
- package/dist/runtime/channels/channel-dispatchers.js +27 -26
- package/dist/runtime/channels/channel-envelope-inspection.d.ts +1 -2
- package/dist/runtime/channels/channel-envelope-inspection.js +1 -16
- package/dist/runtime/channels/channel-envelope.d.ts +1 -0
- package/dist/runtime/channels/channel-envelope.js +83 -8
- package/dist/runtime/channels/channel-outbound-operations.d.ts +2 -2
- package/dist/runtime/channels/channel-outbound-operations.js +8 -8
- package/dist/runtime/channels/channel-receive-loops.js +3 -3
- package/dist/runtime/channels/channel-runtime-lifecycle.js +2 -1
- package/dist/runtime/channels/channel-runtime-manager.d.ts +6 -6
- package/dist/runtime/channels/channel-runtime-manager.js +12 -12
- package/dist/runtime/channels/channel-socket-registry.d.ts +10 -3
- package/dist/runtime/channels/channel-socket-registry.js +59 -82
- package/dist/runtime/channels/channel-transports.d.ts +18 -15
- package/dist/runtime/channels/channel-transports.js +48 -31
- package/dist/runtime/channels/local-spot-route-transport.d.ts +1 -1
- package/dist/runtime/channels/local-spot-route-transport.js +2 -1
- package/dist/runtime/channels/router-socket-spot-route-transport.d.ts +2 -2
- package/dist/runtime/channels/router-socket-spot-route-transport.js +4 -4
- package/dist/runtime/channels/source-spot-router.d.ts +2 -2
- package/dist/runtime/channels/source-spot-router.js +4 -4
- package/dist/runtime/channels/spot-node-route-transport.d.ts +2 -2
- package/dist/runtime/channels/spot-node-route-transport.js +4 -4
- package/dist/runtime/channels/spot-route-bridge-transport.d.ts +2 -2
- package/dist/runtime/channels/spot-route-bridge-transport.js +4 -4
- package/dist/runtime/channels/spot-route-dispatch-strategy.d.ts +5 -4
- package/dist/runtime/channels/spot-route-dispatch-strategy.js +18 -18
- package/dist/runtime/diagnostics/message-flow.d.ts +1 -0
- package/dist/runtime/diagnostics/message-flow.js +3 -3
- package/dist/runtime/execution/serial-execution-queue.d.ts +1 -0
- package/dist/runtime/execution/serial-execution-queue.js +1 -0
- package/dist/runtime/foundation/actor-join-recovery-codec.js +2 -2
- package/dist/runtime/foundation/durable-service-request.d.ts +14 -0
- package/dist/runtime/foundation/durable-service-request.js +98 -0
- package/dist/runtime/foundation/operation-identity.d.ts +1 -0
- package/dist/runtime/foundation/operation-identity.js +5 -1
- package/dist/runtime/foundation/raw-service-mesh-runtime.d.ts +37 -6
- package/dist/runtime/foundation/raw-service-mesh-runtime.js +473 -220
- package/dist/runtime/foundation/service-liveness-registry.d.ts +20 -8
- package/dist/runtime/foundation/service-liveness-registry.js +57 -44
- package/dist/runtime/foundation/service-mailbox.d.ts +3 -0
- package/dist/runtime/foundation/service-mailbox.js +2 -1
- package/dist/runtime/foundation/service-relocation-object-owner.d.ts +1 -0
- package/dist/runtime/foundation/service-relocation-object-owner.js +1 -0
- package/dist/runtime/foundation/service-relocation-runtime.d.ts +2 -0
- package/dist/runtime/foundation/service-relocation-runtime.js +13 -1
- package/dist/runtime/foundation/service-runtime-contracts.d.ts +2 -0
- package/dist/runtime/foundation/service-stateful-runtime.d.ts +10 -9
- package/dist/runtime/foundation/service-stateful-runtime.js +78 -126
- package/dist/runtime/foundation/service-stateful-wire-codec.d.ts +5 -7
- package/dist/runtime/foundation/service-stateful-wire-codec.js +43 -61
- package/dist/runtime/foundation/service-topology-registry.d.ts +16 -4
- package/dist/runtime/foundation/service-topology-registry.js +69 -30
- package/dist/runtime/foundation/service-wire-m6a-codec.d.ts +3 -3
- package/dist/runtime/foundation/service-wire-m6a-codec.js +36 -38
- package/dist/runtime/handlers/handler-instance-scope.d.ts +8 -0
- package/dist/runtime/handlers/handler-instance-scope.js +54 -11
- package/dist/runtime/host/actor-packet-relay.js +7 -7
- package/dist/runtime/host/actor-runtime-options-factory.js +2 -2
- package/dist/runtime/host/application-job-queue.d.ts +28 -9
- package/dist/runtime/host/application-job-queue.js +214 -50
- package/dist/runtime/host/entry-actor-runtime.d.ts +1 -0
- package/dist/runtime/host/entry-actor-runtime.js +4 -1
- package/dist/runtime/host/index.d.ts +7 -1
- package/dist/runtime/host/index.js +154 -126
- package/dist/runtime/host/instance-activation-authority.d.ts +2 -1
- package/dist/runtime/host/instance-activation-authority.js +89 -25
- package/dist/runtime/host/remote-bound-session-relay.js +2 -18
- package/dist/runtime/host/route-mesh-runtime.js +1 -1
- package/dist/runtime/host/service-relocation-control.d.ts +1 -0
- package/dist/runtime/host/service-relocation-control.js +10 -4
- package/dist/runtime/host/service-relocation-host-runtime.d.ts +6 -8
- package/dist/runtime/host/service-relocation-host-runtime.js +215 -243
- package/dist/runtime/host/spot-address-transport.d.ts +1 -0
- package/dist/runtime/host/spot-address-transport.js +28 -14
- package/dist/runtime/host/spot-runtime-options-factory.js +3 -2
- package/dist/runtime/host/user-spot-creation-coordinator.d.ts +1 -0
- package/dist/runtime/host/user-spot-creation-coordinator.js +1 -0
- package/dist/runtime/locations/actor-location-claims.d.ts +2 -2
- package/dist/runtime/locations/actor-location-claims.js +34 -19
- package/dist/runtime/locations/domain-store-contract.d.ts +2 -2
- package/dist/runtime/locations/in-memory-authority-store.d.ts +4 -2
- package/dist/runtime/locations/in-memory-authority-store.js +80 -8
- package/dist/runtime/locations/in-memory-location-store.d.ts +2 -2
- package/dist/runtime/locations/in-memory-location-store.js +19 -3
- package/dist/runtime/locations/internal-location-contracts.d.ts +3 -0
- package/dist/runtime/locations/lifecycle.d.ts +1 -2
- package/dist/runtime/locations/lifecycle.js +2 -5
- package/dist/runtime/locations/location-store-repository.d.ts +3 -2
- package/dist/runtime/locations/location-store-repository.js +165 -22
- package/dist/runtime/locations/resolvers.d.ts +2 -1
- package/dist/runtime/locations/resolvers.js +10 -1
- package/dist/runtime/locations/runtime.d.ts +1 -1
- package/dist/runtime/locations/runtime.js +24 -23
- package/dist/runtime/messaging/framework-json-v1.d.ts +4 -6
- package/dist/runtime/messaging/framework-json-v1.js +38 -294
- package/dist/runtime/messaging/packet-name.d.ts +1 -1
- package/dist/runtime/messaging/packet-name.js +8 -24
- package/dist/runtime/messaging/request-result.d.ts +2 -0
- package/dist/runtime/messaging/request-result.js +54 -0
- package/dist/runtime/messaging/submission-result.d.ts +2 -1
- package/dist/runtime/messaging/submission-result.js +7 -4
- package/dist/runtime/protocol/service_wire_codec.generated.d.ts +15 -0
- package/dist/runtime/protocol/service_wire_codec.generated.js +144 -0
- package/dist/runtime/protocol/service_wire_pilot_codec.generated.d.ts +9 -0
- package/dist/runtime/protocol/service_wire_pilot_codec.generated.js +14 -1
- package/dist/runtime/spots/formal-remote-actor-admission-registry.d.ts +9 -2
- package/dist/runtime/spots/formal-remote-actor-admission-registry.js +33 -19
- package/dist/runtime/spots/index.d.ts +7 -3
- package/dist/runtime/spots/index.js +23 -16
- package/dist/runtime/spots/spot-activation.d.ts +3 -1
- package/dist/runtime/spots/spot-activation.js +21 -12
- package/dist/runtime/spots/spot-actor-admission-coordinator.d.ts +2 -1
- package/dist/runtime/spots/spot-actor-admission-coordinator.js +11 -10
- package/dist/runtime/spots/spot-actor-packet-dispatch.d.ts +4 -1
- package/dist/runtime/spots/spot-actor-packet-dispatch.js +7 -5
- package/dist/runtime/spots/spot-actor-packet-drain.js +2 -0
- package/dist/runtime/spots/spot-actor-packet-relay-dispatch.js +1 -0
- package/dist/runtime/spots/spot-entry-activation.js +9 -3
- package/dist/runtime/spots/spot-handler-registry.d.ts +3 -1
- package/dist/runtime/spots/spot-handler-registry.js +18 -8
- package/dist/runtime/spots/spot-node-autoconnect.js +4 -3
- package/dist/runtime/spots/spot-node-runtime-manager.d.ts +2 -1
- package/dist/runtime/spots/spot-node-runtime-manager.js +4 -11
- package/dist/runtime/spots/spot-outbound.d.ts +3 -0
- package/dist/runtime/spots/spot-outbound.js +24 -15
- package/dist/runtime/spots/spot-routed-spot-packet-dispatch.d.ts +1 -0
- package/dist/runtime/spots/spot-routed-spot-packet-dispatch.js +1 -1
- package/dist/runtime/spots/spot-routing-internal.d.ts +6 -0
- package/dist/runtime/spots/spot-runtime-ports.d.ts +3 -1
- package/dist/runtime/spots/spot-subscription-dispatch.js +0 -3
- package/dist/runtime/spots/spot-timer.js +1 -0
- package/dist/runtime/streams/stream-session-runtime.d.ts +1 -1
- package/dist/runtime/streams/stream-session-runtime.js +14 -28
- package/package.json +3 -3
- package/src/contracts/Actors/ZLinkActorClient.ts +2 -1
- package/src/contracts/Channels/Calls.ts +2 -1
- package/src/contracts/Common/ZLinkMessageMetadata.ts +13 -8
- package/src/contracts/Configuration/Builders.ts +1 -2
- package/src/contracts/Configuration/Configs.ts +0 -6
- package/src/contracts/Configuration/RegistrationBuilders.ts +8 -12
- package/src/contracts/Configuration/RegistrationTypes.ts +1 -6
- package/src/contracts/Configuration/RegistrationValidators.ts +9 -10
- package/src/contracts/Configuration/index.ts +1 -6
- package/src/contracts/Handlers/Attributes.ts +14 -21
- package/src/contracts/Handlers/JsonContract.ts +8 -216
- package/src/contracts/Spots/Contracts.ts +2 -1
- package/src/internal.ts +1 -0
- package/src/nest-integration.ts +1 -0
- package/src/runtime/actors/actor-client.ts +40 -16
- package/src/runtime/actors/actor-handoff.ts +22 -8
- package/src/runtime/actors/actor-join-relocation.ts +1 -0
- package/src/runtime/actors/actor-local-native-join.ts +17 -26
- package/src/runtime/actors/actor-remote-wire.ts +17 -0
- package/src/runtime/actors/actor-routed-join-transport.ts +14 -4
- package/src/runtime/actors/actor-routed-json-request.ts +10 -2
- package/src/runtime/actors/index.ts +19 -5
- package/src/runtime/actors/spot-actor-dispatch.ts +4 -2
- package/src/runtime/admission.ts +18 -5
- package/src/runtime/application-jobs/application-ingress-record-owner.ts +53 -27
- package/src/runtime/application-jobs/application-job-queue-scope.ts +56 -22
- package/src/runtime/application-jobs/contracts.ts +28 -2
- package/src/runtime/backend/contracts/index.ts +63 -32
- package/src/runtime/backend/mesh-completion-table.ts +175 -59
- package/src/runtime/backend/mesh-dispatch-pump.ts +59 -32
- package/src/runtime/backend/node/node-backend-adapter-factory.ts +12 -5
- package/src/runtime/backend/node/node-backend-adapter-support.ts +42 -31
- package/src/runtime/backend/node/node-dealer-channel-client-transport.ts +12 -2
- package/src/runtime/backend/node/node-mesh-backend-adapter.ts +3 -10
- package/src/runtime/backend/node/node-raw-binding-port.ts +73 -37
- package/src/runtime/backend/node/node-raw-mesh-backend.ts +209 -176
- package/src/runtime/backend/node/node-socket-backend-adapter.ts +32 -13
- package/src/runtime/backend/raw-binding-port.ts +18 -3
- package/src/runtime/backend/runtime-message.ts +6 -0
- package/src/runtime/backend/runtime-values.ts +1 -0
- package/src/runtime/channels/channel-clients.ts +90 -41
- package/src/runtime/channels/channel-dispatch-pipeline.ts +69 -34
- package/src/runtime/channels/channel-dispatch-services.ts +69 -1
- package/src/runtime/channels/channel-dispatchers.ts +29 -27
- package/src/runtime/channels/channel-envelope-inspection.ts +2 -16
- package/src/runtime/channels/channel-envelope.ts +133 -8
- package/src/runtime/channels/channel-outbound-operations.ts +22 -8
- package/src/runtime/channels/channel-receive-loops.ts +3 -3
- package/src/runtime/channels/channel-runtime-lifecycle.ts +7 -1
- package/src/runtime/channels/channel-runtime-manager.ts +29 -12
- package/src/runtime/channels/channel-socket-registry.ts +84 -130
- package/src/runtime/channels/channel-transports.ts +128 -60
- package/src/runtime/channels/local-spot-route-transport.ts +3 -1
- package/src/runtime/channels/router-socket-spot-route-transport.ts +13 -4
- package/src/runtime/channels/source-spot-router.ts +8 -4
- package/src/runtime/channels/spot-node-route-transport.ts +8 -4
- package/src/runtime/channels/spot-route-bridge-transport.ts +6 -4
- package/src/runtime/channels/spot-route-dispatch-strategy.ts +47 -18
- package/src/runtime/diagnostics/message-flow.ts +1 -1
- package/src/runtime/execution/serial-execution-queue.ts +2 -0
- package/src/runtime/foundation/actor-join-recovery-codec.ts +2 -2
- package/src/runtime/foundation/durable-service-request.ts +137 -0
- package/src/runtime/foundation/operation-identity.ts +5 -1
- package/src/runtime/foundation/raw-service-mesh-runtime.ts +642 -253
- package/src/runtime/foundation/service-liveness-registry.ts +68 -59
- package/src/runtime/foundation/service-mailbox.ts +7 -1
- package/src/runtime/foundation/service-relocation-object-owner.ts +2 -0
- package/src/runtime/foundation/service-relocation-runtime.ts +18 -1
- package/src/runtime/foundation/service-runtime-contracts.ts +7 -1
- package/src/runtime/foundation/service-stateful-runtime.ts +128 -160
- package/src/runtime/foundation/service-stateful-wire-codec.ts +55 -84
- package/src/runtime/foundation/service-topology-registry.ts +103 -42
- package/src/runtime/foundation/service-wire-m6a-codec.ts +57 -38
- package/src/runtime/handlers/handler-instance-scope.ts +67 -16
- package/src/runtime/host/actor-packet-relay.ts +7 -0
- package/src/runtime/host/actor-runtime-options-factory.ts +14 -2
- package/src/runtime/host/application-job-queue.ts +249 -48
- package/src/runtime/host/entry-actor-runtime.ts +5 -0
- package/src/runtime/host/index.ts +224 -160
- package/src/runtime/host/instance-activation-authority.ts +132 -27
- package/src/runtime/host/remote-bound-session-relay.ts +2 -23
- package/src/runtime/host/route-mesh-runtime.ts +1 -1
- package/src/runtime/host/service-relocation-control.ts +11 -5
- package/src/runtime/host/service-relocation-host-runtime.ts +317 -291
- package/src/runtime/host/spot-address-transport.ts +49 -24
- package/src/runtime/host/spot-runtime-options-factory.ts +4 -0
- package/src/runtime/host/user-spot-creation-coordinator.ts +8 -0
- package/src/runtime/locations/actor-location-claims.ts +52 -30
- package/src/runtime/locations/domain-store-contract.ts +6 -2
- package/src/runtime/locations/in-memory-authority-store.ts +113 -9
- package/src/runtime/locations/in-memory-location-store.ts +25 -3
- package/src/runtime/locations/internal-location-contracts.ts +4 -0
- package/src/runtime/locations/lifecycle.ts +8 -26
- package/src/runtime/locations/location-store-repository.ts +220 -15
- package/src/runtime/locations/resolvers.ts +25 -2
- package/src/runtime/locations/runtime.ts +28 -24
- package/src/runtime/messaging/framework-json-v1.ts +5 -325
- package/src/runtime/messaging/packet-name.ts +5 -25
- package/src/runtime/messaging/request-result.ts +58 -0
- package/src/runtime/messaging/submission-result.ts +7 -3
- package/src/runtime/protocol/service_wire_codec.generated.ts +131 -1
- package/src/runtime/protocol/service_wire_pilot_codec.generated.ts +4 -4
- package/src/runtime/spots/formal-remote-actor-admission-registry.ts +45 -23
- package/src/runtime/spots/index.ts +30 -2
- package/src/runtime/spots/spot-activation.ts +33 -10
- package/src/runtime/spots/spot-actor-admission-coordinator.ts +13 -0
- package/src/runtime/spots/spot-actor-packet-dispatch.ts +10 -0
- package/src/runtime/spots/spot-actor-packet-drain.ts +2 -0
- package/src/runtime/spots/spot-actor-packet-relay-dispatch.ts +1 -0
- package/src/runtime/spots/spot-entry-activation.ts +12 -2
- package/src/runtime/spots/spot-handler-registry.ts +41 -8
- package/src/runtime/spots/spot-node-autoconnect.ts +6 -2
- package/src/runtime/spots/spot-node-runtime-manager.ts +7 -12
- package/src/runtime/spots/spot-outbound.ts +36 -16
- package/src/runtime/spots/spot-routed-spot-packet-dispatch.ts +2 -1
- package/src/runtime/spots/spot-routing-internal.ts +14 -0
- package/src/runtime/spots/spot-runtime-ports.ts +3 -0
- package/src/runtime/spots/spot-subscription-dispatch.ts +0 -3
- package/src/runtime/spots/spot-timer.ts +5 -1
- package/src/runtime/streams/stream-session-runtime.ts +13 -30
|
@@ -1,326 +1,6 @@
|
|
|
1
|
-
import
|
|
1
|
+
import * as profile from '@zlink-systems/stream-wire/internal/json';
|
|
2
2
|
|
|
3
|
-
export const FRAMEWORK_JSON_V1_PROFILE =
|
|
4
|
-
|
|
5
|
-
const
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
export interface FrameworkJsonParseOptions {
|
|
9
|
-
readonly rejectPropertyName?: (name: string) => boolean;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
export function stringifyFrameworkJsonV1(value: unknown, schema?: ZLinkJsonSchema): string {
|
|
13
|
-
if (value === undefined || typeof value === 'function' || typeof value === 'symbol') {
|
|
14
|
-
throw new TypeError('framework-json-v1 payload is not a JSON value.');
|
|
15
|
-
}
|
|
16
|
-
const encoded = JSON.stringify(value, frameworkJsonV1Replacer);
|
|
17
|
-
if (schema !== undefined) {
|
|
18
|
-
validateFrameworkJsonV1Value(JSON.parse(encoded), schema, '$', false);
|
|
19
|
-
}
|
|
20
|
-
return encoded;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
// Module-level so JSON.stringify does not allocate a fresh closure per
|
|
24
|
-
// encoded message. On the root call `this` is the {'': value} wrapper, so
|
|
25
|
-
// this[key] resolves the raw (pre-toJSON) source for every key including ''.
|
|
26
|
-
function frameworkJsonV1Replacer(
|
|
27
|
-
this: Record<string, unknown>,
|
|
28
|
-
key: string,
|
|
29
|
-
item: unknown
|
|
30
|
-
): unknown {
|
|
31
|
-
const source = this[key];
|
|
32
|
-
if (typeof source === 'number' && !Number.isFinite(source)) {
|
|
33
|
-
throw new TypeError('framework-json-v1 only accepts finite JSON numbers.');
|
|
34
|
-
}
|
|
35
|
-
if (typeof source === 'bigint') {
|
|
36
|
-
if (source < SIGNED_64_MIN || source > UNSIGNED_64_MAX) {
|
|
37
|
-
throw new RangeError('framework-json-v1 64-bit integer is outside the supported range.');
|
|
38
|
-
}
|
|
39
|
-
return source.toString(10);
|
|
40
|
-
}
|
|
41
|
-
if (source instanceof Uint8Array) {
|
|
42
|
-
return Buffer.from(source.buffer, source.byteOffset, source.byteLength).toString('base64');
|
|
43
|
-
}
|
|
44
|
-
if (source instanceof Date) {
|
|
45
|
-
throw new TypeError('framework-json-v1 does not implicitly encode Date values.');
|
|
46
|
-
}
|
|
47
|
-
if (
|
|
48
|
-
typeof source === 'object' &&
|
|
49
|
-
source !== null &&
|
|
50
|
-
typeof (source as { readonly toJSON?: unknown }).toJSON === 'function'
|
|
51
|
-
) {
|
|
52
|
-
throw new TypeError('framework-json-v1 does not implicitly invoke custom toJSON methods.');
|
|
53
|
-
}
|
|
54
|
-
return item;
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
export function parseFrameworkJsonV1(
|
|
58
|
-
text: string,
|
|
59
|
-
options: FrameworkJsonParseOptions = {},
|
|
60
|
-
schema?: ZLinkJsonSchema
|
|
61
|
-
): unknown {
|
|
62
|
-
if (text.charCodeAt(0) === 0xfeff) {
|
|
63
|
-
throw new SyntaxError('framework-json-v1 does not allow a UTF-8 BOM.');
|
|
64
|
-
}
|
|
65
|
-
new JsonPropertyScanner(text, options).scan();
|
|
66
|
-
const parsed = JSON.parse(text);
|
|
67
|
-
return schema === undefined ? parsed : validateFrameworkJsonV1Value(parsed, schema, '$', true);
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
// Sticky pattern shared across scans; matching happens synchronously so the
|
|
71
|
-
// mutable lastIndex never crosses calls.
|
|
72
|
-
const NUMBER_TOKEN_PATTERN = /-?(?:0|[1-9][0-9]*)(?:\.[0-9]+)?(?:[eE][+-]?[0-9]+)?/uy;
|
|
73
|
-
|
|
74
|
-
const BASE64_PATTERN = /^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/u;
|
|
75
|
-
const INT32_MIN = -2_147_483_648;
|
|
76
|
-
const INT32_MAX = 2_147_483_647;
|
|
77
|
-
const UINT32_MAX = 4_294_967_295;
|
|
78
|
-
|
|
79
|
-
function validateFrameworkJsonV1Value(
|
|
80
|
-
value: unknown,
|
|
81
|
-
schema: ZLinkJsonSchema,
|
|
82
|
-
path: string,
|
|
83
|
-
decode: boolean
|
|
84
|
-
): unknown {
|
|
85
|
-
switch (schema.type) {
|
|
86
|
-
case 'boolean':
|
|
87
|
-
if (typeof value !== 'boolean') schemaFailure(path, 'a boolean');
|
|
88
|
-
return value;
|
|
89
|
-
case 'string':
|
|
90
|
-
if (typeof value !== 'string') schemaFailure(path, 'a string');
|
|
91
|
-
return value;
|
|
92
|
-
case 'number':
|
|
93
|
-
if (typeof value !== 'number' || !Number.isFinite(value))
|
|
94
|
-
schemaFailure(path, 'a finite number');
|
|
95
|
-
return value;
|
|
96
|
-
case 'int32':
|
|
97
|
-
if (
|
|
98
|
-
!Number.isInteger(value) ||
|
|
99
|
-
(value as number) < INT32_MIN ||
|
|
100
|
-
(value as number) > INT32_MAX
|
|
101
|
-
) {
|
|
102
|
-
schemaFailure(path, 'an int32 JSON number');
|
|
103
|
-
}
|
|
104
|
-
return value;
|
|
105
|
-
case 'uint32':
|
|
106
|
-
if (!Number.isInteger(value) || (value as number) < 0 || (value as number) > UINT32_MAX) {
|
|
107
|
-
schemaFailure(path, 'a uint32 JSON number');
|
|
108
|
-
}
|
|
109
|
-
return value;
|
|
110
|
-
case 'int64':
|
|
111
|
-
return validateDecimalInteger(value, path, true, decode);
|
|
112
|
-
case 'uint64':
|
|
113
|
-
return validateDecimalInteger(value, path, false, decode);
|
|
114
|
-
case 'bytes': {
|
|
115
|
-
if (typeof value !== 'string' || !BASE64_PATTERN.test(value)) {
|
|
116
|
-
schemaFailure(path, 'padded RFC 4648 base64');
|
|
117
|
-
}
|
|
118
|
-
const bytes = Buffer.from(value as string, 'base64');
|
|
119
|
-
if (bytes.toString('base64') !== value)
|
|
120
|
-
schemaFailure(path, 'canonical padded RFC 4648 base64');
|
|
121
|
-
return decode ? Uint8Array.from(bytes) : value;
|
|
122
|
-
}
|
|
123
|
-
case 'enum':
|
|
124
|
-
if (typeof value !== 'string' || !schema.names.includes(value)) {
|
|
125
|
-
schemaFailure(path, `one of ${schema.names.join(', ')}`);
|
|
126
|
-
}
|
|
127
|
-
return value;
|
|
128
|
-
case 'nullable':
|
|
129
|
-
return value === null
|
|
130
|
-
? null
|
|
131
|
-
: validateFrameworkJsonV1Value(value, schema.value, path, decode);
|
|
132
|
-
case 'array':
|
|
133
|
-
if (!Array.isArray(value)) schemaFailure(path, 'an array');
|
|
134
|
-
return (value as unknown[]).map((item, index) =>
|
|
135
|
-
validateFrameworkJsonV1Value(item, schema.items, `${path}[${index}]`, decode)
|
|
136
|
-
);
|
|
137
|
-
case 'record': {
|
|
138
|
-
if (!isJsonObject(value)) schemaFailure(path, 'an object');
|
|
139
|
-
const result: Record<string, unknown> = {};
|
|
140
|
-
for (const [name, item] of Object.entries(value as Record<string, unknown>)) {
|
|
141
|
-
result[name] = validateFrameworkJsonV1Value(item, schema.values, `${path}.${name}`, decode);
|
|
142
|
-
}
|
|
143
|
-
return decode ? result : value;
|
|
144
|
-
}
|
|
145
|
-
case 'object': {
|
|
146
|
-
if (!isJsonObject(value)) schemaFailure(path, 'an object');
|
|
147
|
-
const input = value as Record<string, unknown>;
|
|
148
|
-
for (const name of schema.required) {
|
|
149
|
-
if (!Object.prototype.hasOwnProperty.call(input, name)) {
|
|
150
|
-
throw new TypeError(`framework-json-v1 required property '${path}.${name}' is missing.`);
|
|
151
|
-
}
|
|
152
|
-
}
|
|
153
|
-
const result: Record<string, unknown> = {};
|
|
154
|
-
for (const [name, item] of Object.entries(input)) {
|
|
155
|
-
const propertySchema: unknown = schema.properties[name];
|
|
156
|
-
if (propertySchema === undefined) {
|
|
157
|
-
if (schema.additionalProperties === false) {
|
|
158
|
-
throw new TypeError(`framework-json-v1 property '${path}.${name}' is not allowed.`);
|
|
159
|
-
}
|
|
160
|
-
continue;
|
|
161
|
-
}
|
|
162
|
-
result[name] = validateFrameworkJsonV1Value(
|
|
163
|
-
item,
|
|
164
|
-
propertySchema as ZLinkJsonSchema,
|
|
165
|
-
`${path}.${name}`,
|
|
166
|
-
decode
|
|
167
|
-
);
|
|
168
|
-
}
|
|
169
|
-
return decode ? result : value;
|
|
170
|
-
}
|
|
171
|
-
}
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
function validateDecimalInteger(
|
|
175
|
-
value: unknown,
|
|
176
|
-
path: string,
|
|
177
|
-
signed: boolean,
|
|
178
|
-
decode: boolean
|
|
179
|
-
): unknown {
|
|
180
|
-
if (typeof value !== 'string' || !/^(?:0|[1-9][0-9]*|-[1-9][0-9]*)$/u.test(value)) {
|
|
181
|
-
schemaFailure(
|
|
182
|
-
path,
|
|
183
|
-
signed ? 'a canonical int64 decimal string' : 'a canonical uint64 decimal string'
|
|
184
|
-
);
|
|
185
|
-
}
|
|
186
|
-
const parsed = BigInt(value as string);
|
|
187
|
-
const minimum = signed ? SIGNED_64_MIN : 0n;
|
|
188
|
-
const maximum = signed ? (1n << 63n) - 1n : UNSIGNED_64_MAX;
|
|
189
|
-
if (parsed < minimum || parsed > maximum)
|
|
190
|
-
schemaFailure(path, signed ? 'an int64 value' : 'a uint64 value');
|
|
191
|
-
return decode ? parsed : value;
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
function isJsonObject(value: unknown): value is Record<string, unknown> {
|
|
195
|
-
return typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
196
|
-
}
|
|
197
|
-
|
|
198
|
-
function schemaFailure(path: string, expected: string): never {
|
|
199
|
-
throw new TypeError(`framework-json-v1 value '${path}' must be ${expected}.`);
|
|
200
|
-
}
|
|
201
|
-
|
|
202
|
-
class JsonPropertyScanner {
|
|
203
|
-
private index = 0;
|
|
204
|
-
|
|
205
|
-
constructor(
|
|
206
|
-
private readonly text: string,
|
|
207
|
-
private readonly options: FrameworkJsonParseOptions
|
|
208
|
-
) {}
|
|
209
|
-
|
|
210
|
-
scan(): void {
|
|
211
|
-
this.skipWhitespace();
|
|
212
|
-
this.scanValue();
|
|
213
|
-
this.skipWhitespace();
|
|
214
|
-
if (this.index !== this.text.length) this.fail('trailing data');
|
|
215
|
-
}
|
|
216
|
-
|
|
217
|
-
private scanValue(): void {
|
|
218
|
-
this.skipWhitespace();
|
|
219
|
-
const token = this.text[this.index];
|
|
220
|
-
if (token === '{') return this.scanObject();
|
|
221
|
-
if (token === '[') return this.scanArray();
|
|
222
|
-
if (token === '"') {
|
|
223
|
-
this.scanString();
|
|
224
|
-
return;
|
|
225
|
-
}
|
|
226
|
-
if (token === 't') return this.scanLiteral('true');
|
|
227
|
-
if (token === 'f') return this.scanLiteral('false');
|
|
228
|
-
if (token === 'n') return this.scanLiteral('null');
|
|
229
|
-
this.scanNumber();
|
|
230
|
-
}
|
|
231
|
-
|
|
232
|
-
private scanObject(): void {
|
|
233
|
-
this.index++;
|
|
234
|
-
this.skipWhitespace();
|
|
235
|
-
if (this.text[this.index] === '}') {
|
|
236
|
-
this.index++;
|
|
237
|
-
return;
|
|
238
|
-
}
|
|
239
|
-
const properties = new Set<string>();
|
|
240
|
-
for (;;) {
|
|
241
|
-
this.skipWhitespace();
|
|
242
|
-
if (this.text[this.index] !== '"') this.fail('object property name');
|
|
243
|
-
const property = this.scanString();
|
|
244
|
-
if (properties.has(property)) {
|
|
245
|
-
throw new SyntaxError(`framework-json-v1 duplicate property '${property}'.`);
|
|
246
|
-
}
|
|
247
|
-
properties.add(property);
|
|
248
|
-
if (this.options.rejectPropertyName?.(property) === true) {
|
|
249
|
-
throw new SyntaxError(`framework-json-v1 property '${property}' is not allowed.`);
|
|
250
|
-
}
|
|
251
|
-
this.skipWhitespace();
|
|
252
|
-
if (this.text[this.index] !== ':') this.fail("':' after object property");
|
|
253
|
-
this.index++;
|
|
254
|
-
this.scanValue();
|
|
255
|
-
this.skipWhitespace();
|
|
256
|
-
const delimiter = this.text[this.index++];
|
|
257
|
-
if (delimiter === '}') return;
|
|
258
|
-
if (delimiter !== ',') this.fail("',' or '}' after object property");
|
|
259
|
-
}
|
|
260
|
-
}
|
|
261
|
-
|
|
262
|
-
private scanArray(): void {
|
|
263
|
-
this.index++;
|
|
264
|
-
this.skipWhitespace();
|
|
265
|
-
if (this.text[this.index] === ']') {
|
|
266
|
-
this.index++;
|
|
267
|
-
return;
|
|
268
|
-
}
|
|
269
|
-
for (;;) {
|
|
270
|
-
this.scanValue();
|
|
271
|
-
this.skipWhitespace();
|
|
272
|
-
const delimiter = this.text[this.index++];
|
|
273
|
-
if (delimiter === ']') return;
|
|
274
|
-
if (delimiter !== ',') this.fail("',' or ']' after array item");
|
|
275
|
-
}
|
|
276
|
-
}
|
|
277
|
-
|
|
278
|
-
private scanString(): string {
|
|
279
|
-
const start = this.index++;
|
|
280
|
-
let sawEscape = false;
|
|
281
|
-
for (;;) {
|
|
282
|
-
if (this.index >= this.text.length) this.fail('unterminated string');
|
|
283
|
-
const character = this.text[this.index++]!;
|
|
284
|
-
if (character === '"') {
|
|
285
|
-
// Without escapes the token content is verbatim; the outer
|
|
286
|
-
// JSON.parse pass still rejects any raw control characters.
|
|
287
|
-
return sawEscape
|
|
288
|
-
? (JSON.parse(this.text.slice(start, this.index)) as string)
|
|
289
|
-
: this.text.slice(start + 1, this.index - 1);
|
|
290
|
-
}
|
|
291
|
-
if (character === '\\') {
|
|
292
|
-
sawEscape = true;
|
|
293
|
-
if (this.index >= this.text.length) this.fail('unterminated escape');
|
|
294
|
-
const escaped = this.text[this.index++]!;
|
|
295
|
-
if (escaped === 'u') this.index += 4;
|
|
296
|
-
}
|
|
297
|
-
}
|
|
298
|
-
}
|
|
299
|
-
|
|
300
|
-
private scanLiteral(value: 'true' | 'false' | 'null'): void {
|
|
301
|
-
if (!this.text.startsWith(value, this.index)) this.fail(value);
|
|
302
|
-
this.index += value.length;
|
|
303
|
-
}
|
|
304
|
-
|
|
305
|
-
private scanNumber(): void {
|
|
306
|
-
NUMBER_TOKEN_PATTERN.lastIndex = this.index;
|
|
307
|
-
const match = NUMBER_TOKEN_PATTERN.exec(this.text);
|
|
308
|
-
if (match === null) this.fail('JSON value');
|
|
309
|
-
this.index += match[0].length;
|
|
310
|
-
}
|
|
311
|
-
|
|
312
|
-
private skipWhitespace(): void {
|
|
313
|
-
for (;;) {
|
|
314
|
-
const code = this.text.charCodeAt(this.index);
|
|
315
|
-
if (code === 0x20 || code === 0x09 || code === 0x0a || code === 0x0d) {
|
|
316
|
-
this.index += 1;
|
|
317
|
-
continue;
|
|
318
|
-
}
|
|
319
|
-
return;
|
|
320
|
-
}
|
|
321
|
-
}
|
|
322
|
-
|
|
323
|
-
private fail(expected: string): never {
|
|
324
|
-
throw new SyntaxError(`framework-json-v1 expected ${expected} at offset ${this.index}.`);
|
|
325
|
-
}
|
|
326
|
-
}
|
|
3
|
+
export const FRAMEWORK_JSON_V1_PROFILE = profile.FRAMEWORK_JSON_V1_PROFILE;
|
|
4
|
+
export const stringifyFrameworkJsonV1 = profile.stringifyFrameworkJsonV1;
|
|
5
|
+
export const parseFrameworkJsonV1 = profile.parseFrameworkJsonV1;
|
|
6
|
+
export type { FrameworkJsonParseOptions } from '@zlink-systems/stream-wire/internal/json';
|
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
import {
|
|
2
|
+
readFrameworkPacketJsonContract,
|
|
3
|
+
normalizePacketName
|
|
4
|
+
} from '@zlink-systems/stream-wire/internal/json';
|
|
1
5
|
import { readZLinkDecoratorMetadata } from '../../contracts/Handlers/Attributes';
|
|
2
6
|
import type { ZLinkPacketJsonContract } from '../../contracts/Handlers/JsonContract';
|
|
3
7
|
import { ZLinkConfigurationException } from '../configuration';
|
|
@@ -42,23 +46,7 @@ export function resolveFrameworkPacketJsonContract(
|
|
|
42
46
|
return readFrameworkPacketJsonContract(constructor, explicitPacketName);
|
|
43
47
|
}
|
|
44
48
|
|
|
45
|
-
export
|
|
46
|
-
type: object,
|
|
47
|
-
explicitPacketName?: string
|
|
48
|
-
): ZLinkPacketJsonContract | undefined {
|
|
49
|
-
const expectedPacketName = normalizePacketName(explicitPacketName);
|
|
50
|
-
for (const metadata of readZLinkDecoratorMetadata(type)) {
|
|
51
|
-
if (
|
|
52
|
-
metadata.kind === 'packet' &&
|
|
53
|
-
metadata.jsonContract !== undefined &&
|
|
54
|
-
(expectedPacketName === undefined ||
|
|
55
|
-
normalizePacketName(metadata.packetName) === expectedPacketName)
|
|
56
|
-
) {
|
|
57
|
-
return metadata.jsonContract;
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
return undefined;
|
|
61
|
-
}
|
|
49
|
+
export { readFrameworkPacketJsonContract } from '@zlink-systems/stream-wire/internal/json';
|
|
62
50
|
|
|
63
51
|
function tryDecoratorPacketName(payload: unknown): string | undefined {
|
|
64
52
|
if (typeof payload !== 'object' || payload === null) {
|
|
@@ -86,11 +74,3 @@ function tryConstructorPacketName(payload: unknown): string | undefined {
|
|
|
86
74
|
}
|
|
87
75
|
return normalizePacketName(name);
|
|
88
76
|
}
|
|
89
|
-
|
|
90
|
-
function normalizePacketName(value: unknown): string | undefined {
|
|
91
|
-
if (typeof value !== 'string') {
|
|
92
|
-
return undefined;
|
|
93
|
-
}
|
|
94
|
-
const trimmed = value.trim();
|
|
95
|
-
return trimmed.length > 0 ? trimmed : undefined;
|
|
96
|
-
}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import type { ZLinkRequest } from '../../contracts/Handlers/Attributes';
|
|
2
|
+
|
|
3
|
+
const completedAdmission = Promise.resolve();
|
|
4
|
+
const ignoreAdmissionFailure = (): void => {};
|
|
5
|
+
|
|
6
|
+
export function createZLinkRequest<TReply>(
|
|
7
|
+
start: (onAdmitted: () => void) => Promise<TReply>,
|
|
8
|
+
deliverReply?: (reply: Promise<TReply>) => Promise<TReply>
|
|
9
|
+
): ZLinkRequest<TReply> {
|
|
10
|
+
let admitted: Promise<void> | undefined;
|
|
11
|
+
let resolveAdmission: (() => void) | undefined;
|
|
12
|
+
let rejectAdmission: ((error: unknown) => void) | undefined;
|
|
13
|
+
const confirmAdmission = (): void => {
|
|
14
|
+
admitted ??= completedAdmission;
|
|
15
|
+
resolveAdmission?.();
|
|
16
|
+
};
|
|
17
|
+
const failAdmission = (error: unknown): void => {
|
|
18
|
+
if (admitted === undefined) {
|
|
19
|
+
admitted = Promise.reject(error);
|
|
20
|
+
// Existing callers may observe only the reply Promise. Observing the
|
|
21
|
+
// rejection here leaves the public admission Promise rejected.
|
|
22
|
+
void admitted.catch(ignoreAdmissionFailure);
|
|
23
|
+
} else {
|
|
24
|
+
rejectAdmission?.(error);
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
const observeAdmission = (): Promise<void> => {
|
|
28
|
+
if (admitted === undefined) {
|
|
29
|
+
admitted = new Promise<void>((resolve, reject) => {
|
|
30
|
+
resolveAdmission = resolve;
|
|
31
|
+
rejectAdmission = reject;
|
|
32
|
+
});
|
|
33
|
+
void admitted.catch(ignoreAdmissionFailure);
|
|
34
|
+
}
|
|
35
|
+
return admitted;
|
|
36
|
+
};
|
|
37
|
+
let pending: Promise<TReply>;
|
|
38
|
+
try {
|
|
39
|
+
pending = start(confirmAdmission);
|
|
40
|
+
} catch (error) {
|
|
41
|
+
pending = Promise.reject(error);
|
|
42
|
+
}
|
|
43
|
+
const observed = pending.then(
|
|
44
|
+
(value) => {
|
|
45
|
+
// A successful reply proves admission even without an observation callback.
|
|
46
|
+
confirmAdmission();
|
|
47
|
+
return value;
|
|
48
|
+
},
|
|
49
|
+
(error: unknown) => {
|
|
50
|
+
failAdmission(error);
|
|
51
|
+
throw error;
|
|
52
|
+
}
|
|
53
|
+
);
|
|
54
|
+
const reply = deliverReply?.(observed) ?? observed;
|
|
55
|
+
return Object.defineProperty(reply, 'admitted', {
|
|
56
|
+
get: observeAdmission
|
|
57
|
+
}) as ZLinkRequest<TReply>;
|
|
58
|
+
}
|
|
@@ -18,13 +18,17 @@ export interface ZLinkSubmitResult {
|
|
|
18
18
|
readonly status: ZLinkSubmitStatus;
|
|
19
19
|
}
|
|
20
20
|
|
|
21
|
-
|
|
21
|
+
export const submittedResult: ZLinkSubmitResult = Object.freeze({
|
|
22
|
+
status: ZLinkSubmitStatus.Submitted
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
/** Projects typed submit failure; capacity refusal has no admission wait token. */
|
|
22
26
|
export function submitToRequestResult(result: number, phase: 'submit' | 'completion'): number {
|
|
23
27
|
switch (result) {
|
|
24
28
|
case SubmitResult.Ok:
|
|
25
29
|
return RequestResult.Ok;
|
|
26
30
|
case SubmitResult.Backpressured:
|
|
27
|
-
return
|
|
31
|
+
return RequestResult.NotConnected;
|
|
28
32
|
case SubmitResult.NotConnected:
|
|
29
33
|
return RequestResult.NotConnected;
|
|
30
34
|
case SubmitResult.NotFound:
|
|
@@ -54,7 +58,7 @@ export function classifySubmitResult(
|
|
|
54
58
|
const terminal = submitToRequestResult(result, phase);
|
|
55
59
|
switch (terminal) {
|
|
56
60
|
case RequestResult.Ok:
|
|
57
|
-
return
|
|
61
|
+
return submittedResult;
|
|
58
62
|
case RequestResult.TimedOut:
|
|
59
63
|
return { status: ZLinkSubmitStatus.TimedOut };
|
|
60
64
|
case RequestResult.NotFound:
|
|
@@ -7584,7 +7584,127 @@ function writeRelocationPendingTimerTickVector(input: RelocationPendingTimerTick
|
|
|
7584
7584
|
export function decodeRelocationPendingTimerTickVector(bytes: Uint8Array, context: ServiceWireDecoderContext): RelocationPendingTimerTickVector { const reader = new Reader(bytes); const value = readRelocationPendingTimerTickVector(reader, context, {}, 0); reader.done("relocation-pending-timer-tick-vector"); return value; }
|
|
7585
7585
|
export function encodeRelocationPendingTimerTickVector(value: RelocationPendingTimerTickVector, context: ServiceWireDecoderContext): Uint8Array { const writer = new Writer(); writeRelocationPendingTimerTickVector(value, writer, context, {}, 0); return writer.result(); }
|
|
7586
7586
|
|
|
7587
|
-
export type
|
|
7587
|
+
export type RelocationSessionBinding = { readonly participantId: NonzeroU64; readonly sessionOwnerNodeRid: Rid; readonly sessionOwnerNodeGeneration: NonzeroU64; readonly sessionOwnerId: Text8; readonly sessionOwnerLeaseGeneration: NonzeroU64; readonly sessionRid: Rid; readonly bindingGeneration: NonzeroU64 };
|
|
7588
|
+
|
|
7589
|
+
function readRelocationSessionBinding(reader: Reader, context: ServiceWireDecoderContext, enclosing: any, flags: number): RelocationSessionBinding {
|
|
7590
|
+
void context; void enclosing; void flags;
|
|
7591
|
+
const value: any = {};
|
|
7592
|
+
value["participantId"] = readNonzeroU64(reader, context, value, flags);
|
|
7593
|
+
|
|
7594
|
+
|
|
7595
|
+
value["sessionOwnerNodeRid"] = readRid(reader, context, value, flags);
|
|
7596
|
+
|
|
7597
|
+
|
|
7598
|
+
value["sessionOwnerNodeGeneration"] = readNonzeroU64(reader, context, value, flags);
|
|
7599
|
+
|
|
7600
|
+
|
|
7601
|
+
value["sessionOwnerId"] = readText8(reader, context, value, flags);
|
|
7602
|
+
|
|
7603
|
+
|
|
7604
|
+
value["sessionOwnerLeaseGeneration"] = readNonzeroU64(reader, context, value, flags);
|
|
7605
|
+
|
|
7606
|
+
|
|
7607
|
+
value["sessionRid"] = readRid(reader, context, value, flags);
|
|
7608
|
+
|
|
7609
|
+
|
|
7610
|
+
value["bindingGeneration"] = readNonzeroU64(reader, context, value, flags);
|
|
7611
|
+
|
|
7612
|
+
|
|
7613
|
+
|
|
7614
|
+
|
|
7615
|
+
return value;
|
|
7616
|
+
}
|
|
7617
|
+
function* readIncrementalRelocationSessionBinding(reader: IncrementalInput, context: ServiceWireDecoderContext, enclosing: any, flags: number): Generator<void, RelocationSessionBinding, void> {
|
|
7618
|
+
void context; void enclosing; void flags;
|
|
7619
|
+
const value: any = {};
|
|
7620
|
+
value["participantId"] = yield* readIncrementalNonzeroU64(reader, context, value, flags);
|
|
7621
|
+
|
|
7622
|
+
|
|
7623
|
+
value["sessionOwnerNodeRid"] = yield* readIncrementalRid(reader, context, value, flags);
|
|
7624
|
+
|
|
7625
|
+
|
|
7626
|
+
value["sessionOwnerNodeGeneration"] = yield* readIncrementalNonzeroU64(reader, context, value, flags);
|
|
7627
|
+
|
|
7628
|
+
|
|
7629
|
+
value["sessionOwnerId"] = yield* readIncrementalText8(reader, context, value, flags);
|
|
7630
|
+
|
|
7631
|
+
|
|
7632
|
+
value["sessionOwnerLeaseGeneration"] = yield* readIncrementalNonzeroU64(reader, context, value, flags);
|
|
7633
|
+
|
|
7634
|
+
|
|
7635
|
+
value["sessionRid"] = yield* readIncrementalRid(reader, context, value, flags);
|
|
7636
|
+
|
|
7637
|
+
|
|
7638
|
+
value["bindingGeneration"] = yield* readIncrementalNonzeroU64(reader, context, value, flags);
|
|
7639
|
+
|
|
7640
|
+
|
|
7641
|
+
|
|
7642
|
+
|
|
7643
|
+
return value;
|
|
7644
|
+
}
|
|
7645
|
+
function writeRelocationSessionBinding(input: RelocationSessionBinding, writer: Writer, context: ServiceWireDecoderContext, enclosing: any, flags: number): void {
|
|
7646
|
+
void context; void enclosing; void flags; const value: any = input;
|
|
7647
|
+
|
|
7648
|
+
|
|
7649
|
+
if (value["participantId"] === undefined) fail("participantId required");
|
|
7650
|
+
|
|
7651
|
+
|
|
7652
|
+
writeNonzeroU64(numeric(value["participantId"]), writer, context, value, flags);
|
|
7653
|
+
if (value["sessionOwnerNodeRid"] === undefined) fail("sessionOwnerNodeRid required");
|
|
7654
|
+
|
|
7655
|
+
|
|
7656
|
+
writeRid(value["sessionOwnerNodeRid"], writer, context, value, flags);
|
|
7657
|
+
if (value["sessionOwnerNodeGeneration"] === undefined) fail("sessionOwnerNodeGeneration required");
|
|
7658
|
+
|
|
7659
|
+
|
|
7660
|
+
writeNonzeroU64(numeric(value["sessionOwnerNodeGeneration"]), writer, context, value, flags);
|
|
7661
|
+
if (value["sessionOwnerId"] === undefined) fail("sessionOwnerId required");
|
|
7662
|
+
|
|
7663
|
+
|
|
7664
|
+
writeText8(value["sessionOwnerId"], writer, context, value, flags);
|
|
7665
|
+
if (value["sessionOwnerLeaseGeneration"] === undefined) fail("sessionOwnerLeaseGeneration required");
|
|
7666
|
+
|
|
7667
|
+
|
|
7668
|
+
writeNonzeroU64(numeric(value["sessionOwnerLeaseGeneration"]), writer, context, value, flags);
|
|
7669
|
+
if (value["sessionRid"] === undefined) fail("sessionRid required");
|
|
7670
|
+
|
|
7671
|
+
|
|
7672
|
+
writeRid(value["sessionRid"], writer, context, value, flags);
|
|
7673
|
+
if (value["bindingGeneration"] === undefined) fail("bindingGeneration required");
|
|
7674
|
+
|
|
7675
|
+
|
|
7676
|
+
writeNonzeroU64(numeric(value["bindingGeneration"]), writer, context, value, flags);
|
|
7677
|
+
}
|
|
7678
|
+
export function decodeRelocationSessionBinding(bytes: Uint8Array, context: ServiceWireDecoderContext): RelocationSessionBinding { const reader = new Reader(bytes); const value = readRelocationSessionBinding(reader, context, {}, 0); reader.done("relocation-session-binding"); return value; }
|
|
7679
|
+
export function encodeRelocationSessionBinding(value: RelocationSessionBinding, context: ServiceWireDecoderContext): Uint8Array { const writer = new Writer(); writeRelocationSessionBinding(value, writer, context, {}, 0); return writer.result(); }
|
|
7680
|
+
|
|
7681
|
+
export type RelocationSessionBindingVector = readonly RelocationSessionBinding[];
|
|
7682
|
+
|
|
7683
|
+
function readRelocationSessionBindingVector(reader: Reader, context: ServiceWireDecoderContext, enclosing: any, flags: number): RelocationSessionBindingVector {
|
|
7684
|
+
void context; void enclosing; void flags;
|
|
7685
|
+
const count = Number(readU32(reader, context, enclosing, flags)); if (count > 1024) fail("relocation-session-binding-vector count"); const value: any = Array.from({ length: count }, () => readRelocationSessionBinding(reader, context, enclosing, flags));
|
|
7686
|
+
try { for (let index = 1; index < value.length; ++index) if (compareResults([compareBigint(numeric(value[index - 1]["participantId"]), numeric(value[index]["participantId"]))]) >= 0) fail("relocation-session-binding-vector sorted"); } catch (error) { if (error instanceof ServiceWireProtocolError || error instanceof ServiceWireCapacityError) throw error; if (error instanceof RangeError) capacityFail("relocation-session-binding-vector constraint capacity"); throw error; }
|
|
7687
|
+
|
|
7688
|
+
return value;
|
|
7689
|
+
}
|
|
7690
|
+
function* readIncrementalRelocationSessionBindingVector(reader: IncrementalInput, context: ServiceWireDecoderContext, enclosing: any, flags: number): Generator<void, RelocationSessionBindingVector, void> {
|
|
7691
|
+
void context; void enclosing; void flags;
|
|
7692
|
+
const count = Number(yield* readIncrementalU32(reader, context, enclosing, flags)); if (count > 1024) fail("relocation-session-binding-vector count"); const value: any[] = []; for (let index = 0; index < count; ++index) { const item = yield* readIncrementalRelocationSessionBinding(reader, context, enclosing, flags); try { value.push(item); } catch { capacityFail("relocation-session-binding-vector capacity"); } }
|
|
7693
|
+
try { for (let index = 1; index < value.length; ++index) if (compareResults([compareBigint(numeric(value[index - 1]["participantId"]), numeric(value[index]["participantId"]))]) >= 0) fail("relocation-session-binding-vector sorted"); } catch (error) { if (error instanceof ServiceWireProtocolError || error instanceof ServiceWireCapacityError) throw error; if (error instanceof RangeError) capacityFail("relocation-session-binding-vector constraint capacity"); throw error; }
|
|
7694
|
+
|
|
7695
|
+
return value;
|
|
7696
|
+
}
|
|
7697
|
+
function writeRelocationSessionBindingVector(input: RelocationSessionBindingVector, writer: Writer, context: ServiceWireDecoderContext, enclosing: any, flags: number): void {
|
|
7698
|
+
void context; void enclosing; void flags; const value: any = input;
|
|
7699
|
+
if (!Array.isArray(value) || value.length > 1024) fail("relocation-session-binding-vector count");
|
|
7700
|
+
try { for (let index = 1; index < value.length; ++index) if (compareResults([compareBigint(numeric(value[index - 1]["participantId"]), numeric(value[index]["participantId"]))]) >= 0) fail("relocation-session-binding-vector sorted"); } catch (error) { if (error instanceof ServiceWireProtocolError || error instanceof ServiceWireCapacityError) throw error; if (error instanceof RangeError) capacityFail("relocation-session-binding-vector constraint capacity"); throw error; }
|
|
7701
|
+
|
|
7702
|
+
writeU32(value.length, writer, context, enclosing, flags); for (const item of value) writeRelocationSessionBinding(item, writer, context, enclosing, flags);
|
|
7703
|
+
}
|
|
7704
|
+
export function decodeRelocationSessionBindingVector(bytes: Uint8Array, context: ServiceWireDecoderContext): RelocationSessionBindingVector { const reader = new Reader(bytes); const value = readRelocationSessionBindingVector(reader, context, {}, 0); reader.done("relocation-session-binding-vector"); return value; }
|
|
7705
|
+
export function encodeRelocationSessionBindingVector(value: RelocationSessionBindingVector, context: ServiceWireDecoderContext): Uint8Array { const writer = new Writer(); writeRelocationSessionBindingVector(value, writer, context, {}, 0); return writer.result(); }
|
|
7706
|
+
|
|
7707
|
+
export type RelocationEnvelopeV1 = { readonly relocation: RelocationId; readonly object: RelocationObjectIdentity; readonly applicationVersion: ApplicationVersion; readonly applicationStates: RelocationParticipantApplicationStateVector; readonly savedWork: SavedWorkVector; readonly timerRegistrations: RelocationTimerRegistrationVector; readonly pendingTimerTicks: RelocationPendingTimerTickVector; readonly sessionBindings: RelocationSessionBindingVector };
|
|
7588
7708
|
|
|
7589
7709
|
function readRelocationEnvelopeV1(reader: Reader, context: ServiceWireDecoderContext, enclosing: any, flags: number): RelocationEnvelopeV1 {
|
|
7590
7710
|
void context; void enclosing; void flags;
|
|
@@ -7610,6 +7730,9 @@ function readRelocationEnvelopeV1(reader: Reader, context: ServiceWireDecoderCon
|
|
|
7610
7730
|
value["pendingTimerTicks"] = readRelocationPendingTimerTickVector(reader, context, value, flags);
|
|
7611
7731
|
|
|
7612
7732
|
|
|
7733
|
+
value["sessionBindings"] = readRelocationSessionBindingVector(reader, context, value, flags);
|
|
7734
|
+
|
|
7735
|
+
|
|
7613
7736
|
|
|
7614
7737
|
|
|
7615
7738
|
return value;
|
|
@@ -7638,6 +7761,9 @@ function* readIncrementalRelocationEnvelopeV1(reader: IncrementalInput, context:
|
|
|
7638
7761
|
value["pendingTimerTicks"] = yield* readIncrementalRelocationPendingTimerTickVector(reader, context, value, flags);
|
|
7639
7762
|
|
|
7640
7763
|
|
|
7764
|
+
value["sessionBindings"] = yield* readIncrementalRelocationSessionBindingVector(reader, context, value, flags);
|
|
7765
|
+
|
|
7766
|
+
|
|
7641
7767
|
|
|
7642
7768
|
|
|
7643
7769
|
return value;
|
|
@@ -7674,6 +7800,10 @@ function writeRelocationEnvelopeV1(input: RelocationEnvelopeV1, writer: Writer,
|
|
|
7674
7800
|
|
|
7675
7801
|
|
|
7676
7802
|
writeRelocationPendingTimerTickVector(value["pendingTimerTicks"], writer, context, value, flags);
|
|
7803
|
+
if (value["sessionBindings"] === undefined) fail("sessionBindings required");
|
|
7804
|
+
|
|
7805
|
+
|
|
7806
|
+
writeRelocationSessionBindingVector(value["sessionBindings"], writer, context, value, flags);
|
|
7677
7807
|
}
|
|
7678
7808
|
export function decodeRelocationEnvelopeV1(bytes: Uint8Array, context: ServiceWireDecoderContext): RelocationEnvelopeV1 { const reader = new Reader(bytes); const value = readRelocationEnvelopeV1(reader, context, {}, 0); reader.done("relocation-envelope-v1"); return value; }
|
|
7679
7809
|
export function encodeRelocationEnvelopeV1(value: RelocationEnvelopeV1, context: ServiceWireDecoderContext): Uint8Array { const writer = new Writer(); writeRelocationEnvelopeV1(value, writer, context, {}, 0); return writer.result(); }
|