@openrobops/iso21423 0.0.0-stage → 0.1.3
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/README.md +358 -2
- package/dist/ccs-CU8XD5sl.d.cts +69 -0
- package/dist/ccs-CU8XD5sl.d.ts +69 -0
- package/dist/chunk-3JNSIJSX.js +31 -0
- package/dist/chunk-3JNSIJSX.js.map +1 -0
- package/dist/chunk-5ZIUSUHF.js +55 -0
- package/dist/chunk-5ZIUSUHF.js.map +1 -0
- package/dist/chunk-DMJ6T3RX.js +445 -0
- package/dist/chunk-DMJ6T3RX.js.map +1 -0
- package/dist/chunk-GPNR37CI.js +1915 -0
- package/dist/chunk-GPNR37CI.js.map +1 -0
- package/dist/chunk-JDO725KR.js +210 -0
- package/dist/chunk-JDO725KR.js.map +1 -0
- package/dist/chunk-JIYCTQXR.js +1 -0
- package/dist/chunk-JIYCTQXR.js.map +1 -0
- package/dist/chunk-JLUENXGS.js +48 -0
- package/dist/chunk-JLUENXGS.js.map +1 -0
- package/dist/chunk-JQAMNFAF.js +1 -0
- package/dist/chunk-JQAMNFAF.js.map +1 -0
- package/dist/chunk-LTPOAVGF.js +44 -0
- package/dist/chunk-LTPOAVGF.js.map +1 -0
- package/dist/chunk-ODBIFZN3.js +65 -0
- package/dist/chunk-ODBIFZN3.js.map +1 -0
- package/dist/chunk-OH2DOPKJ.js +107 -0
- package/dist/chunk-OH2DOPKJ.js.map +1 -0
- package/dist/chunk-QAA44UNO.js +1 -0
- package/dist/chunk-QAA44UNO.js.map +1 -0
- package/dist/chunk-RD7PYTIT.js +107 -0
- package/dist/chunk-RD7PYTIT.js.map +1 -0
- package/dist/chunk-UJC46NTA.js +13 -0
- package/dist/chunk-UJC46NTA.js.map +1 -0
- package/dist/chunk-UW6WTEPT.js +293 -0
- package/dist/chunk-UW6WTEPT.js.map +1 -0
- package/dist/chunk-W7DIDPTG.js +1 -0
- package/dist/chunk-W7DIDPTG.js.map +1 -0
- package/dist/core.cjs +2874 -0
- package/dist/core.cjs.map +1 -0
- package/dist/core.d.cts +996 -0
- package/dist/core.d.ts +996 -0
- package/dist/core.js +59 -0
- package/dist/core.js.map +1 -0
- package/dist/gateway.cjs +2937 -0
- package/dist/gateway.cjs.map +1 -0
- package/dist/gateway.d.cts +165 -0
- package/dist/gateway.d.ts +165 -0
- package/dist/gateway.js +21 -0
- package/dist/gateway.js.map +1 -0
- package/dist/geometry.cjs +98 -0
- package/dist/geometry.cjs.map +1 -0
- package/dist/geometry.d.cts +38 -0
- package/dist/geometry.d.ts +38 -0
- package/dist/geometry.js +14 -0
- package/dist/geometry.js.map +1 -0
- package/dist/identity-BGr2FJmC.d.cts +258 -0
- package/dist/identity-Bw8Dik5S.d.ts +258 -0
- package/dist/index.cjs +3327 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +118 -0
- package/dist/index.d.ts +118 -0
- package/dist/index.js +193 -0
- package/dist/index.js.map +1 -0
- package/dist/schema.cjs +375 -0
- package/dist/schema.cjs.map +1 -0
- package/dist/schema.d.cts +28 -0
- package/dist/schema.d.ts +28 -0
- package/dist/schema.js +14 -0
- package/dist/schema.js.map +1 -0
- package/dist/session-RV32MFpV.d.cts +139 -0
- package/dist/session-ueiESY7Y.d.ts +139 -0
- package/dist/session.cjs +855 -0
- package/dist/session.cjs.map +1 -0
- package/dist/session.d.cts +94 -0
- package/dist/session.d.ts +94 -0
- package/dist/session.js +20 -0
- package/dist/session.js.map +1 -0
- package/dist/testing.cjs +205 -0
- package/dist/testing.cjs.map +1 -0
- package/dist/testing.d.cts +94 -0
- package/dist/testing.d.ts +94 -0
- package/dist/testing.js +169 -0
- package/dist/testing.js.map +1 -0
- package/dist/topics-BiVeZyTW.d.cts +43 -0
- package/dist/topics-BiVeZyTW.d.ts +43 -0
- package/dist/topics.cjs +134 -0
- package/dist/topics.cjs.map +1 -0
- package/dist/topics.d.cts +41 -0
- package/dist/topics.d.ts +41 -0
- package/dist/topics.js +30 -0
- package/dist/topics.js.map +1 -0
- package/dist/transport-BT4AjTn9.d.cts +61 -0
- package/dist/transport-BT4AjTn9.d.ts +61 -0
- package/dist/types.cjs +186 -0
- package/dist/types.cjs.map +1 -0
- package/dist/types.d.cts +83 -0
- package/dist/types.d.ts +83 -0
- package/dist/types.js +50 -0
- package/dist/types.js.map +1 -0
- package/dist/validators-Be0ce1b8.d.cts +29 -0
- package/dist/validators-Be0ce1b8.d.ts +29 -0
- package/package.json +48 -4
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
import { M as MqttTransport, C as ConnectionState } from './transport-BT4AjTn9.cjs';
|
|
2
|
+
import { E as EntityRef } from './topics-BiVeZyTW.cjs';
|
|
3
|
+
import { M as MessageKind } from './validators-Be0ce1b8.cjs';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Copyright 2026 InOrbit, Inc.
|
|
7
|
+
*
|
|
8
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
9
|
+
* you may not use this file except in compliance with the License.
|
|
10
|
+
* You may obtain a copy of the License at
|
|
11
|
+
*
|
|
12
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
13
|
+
*
|
|
14
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
15
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
16
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
17
|
+
* See the License for the specific language governing permissions and
|
|
18
|
+
* limitations under the License.
|
|
19
|
+
*/
|
|
20
|
+
|
|
21
|
+
/** Options for {@link Iso21423Session.connect}. */
|
|
22
|
+
interface SessionOptions {
|
|
23
|
+
transport: MqttTransport;
|
|
24
|
+
entity: EntityRef;
|
|
25
|
+
credentials?: {
|
|
26
|
+
username?: string;
|
|
27
|
+
password?: string;
|
|
28
|
+
};
|
|
29
|
+
validateOutbound?: boolean;
|
|
30
|
+
/** Arm the B.4 Last Will at connect time. Default true; false for identity-less sessions (R1). */
|
|
31
|
+
armWill?: boolean;
|
|
32
|
+
}
|
|
33
|
+
/** Returned by `subscribeTopic` / `subscribeResource`: stop receiving on that filter. */
|
|
34
|
+
interface SessionSubscription {
|
|
35
|
+
unsubscribe(): Promise<void>;
|
|
36
|
+
}
|
|
37
|
+
/** Topic-derived metadata handed to subscription handlers alongside the parsed payload. */
|
|
38
|
+
interface TopicMeta {
|
|
39
|
+
topic: string;
|
|
40
|
+
entityType: string;
|
|
41
|
+
entityUuid: string;
|
|
42
|
+
resource: string;
|
|
43
|
+
requestUuid?: string;
|
|
44
|
+
isRequestStatus: boolean;
|
|
45
|
+
}
|
|
46
|
+
/** Emitted on the `'validation-warning'` event when an inbound message fails schema validation or JSON parsing. */
|
|
47
|
+
interface ValidationWarningEvent {
|
|
48
|
+
topic: string;
|
|
49
|
+
payload: string;
|
|
50
|
+
errors: unknown[];
|
|
51
|
+
}
|
|
52
|
+
type SessionEvents = {
|
|
53
|
+
connection: (s: ConnectionState) => void;
|
|
54
|
+
'validation-warning': (w: ValidationWarningEvent) => void;
|
|
55
|
+
error: (err: unknown) => void;
|
|
56
|
+
};
|
|
57
|
+
/**
|
|
58
|
+
* Owns one MQTT connection for a single entity: topic-scoped subscribe/publish, retained-resource
|
|
59
|
+
* dedup and republish-on-reconnect, streaming-resource rate gating, LWT arming, and inbound schema
|
|
60
|
+
* validation. This is the layer `/core` builds its request/response semantics on top of.
|
|
61
|
+
*/
|
|
62
|
+
declare class Iso21423Session {
|
|
63
|
+
private readonly transport;
|
|
64
|
+
readonly entity: EntityRef;
|
|
65
|
+
private readonly validateOutbound;
|
|
66
|
+
private readonly armWill;
|
|
67
|
+
private retainedOwned;
|
|
68
|
+
private rateGates;
|
|
69
|
+
private topicSubs;
|
|
70
|
+
private listeners;
|
|
71
|
+
private wasConnected;
|
|
72
|
+
private state;
|
|
73
|
+
private constructor();
|
|
74
|
+
/**
|
|
75
|
+
* Connects the transport and, unless `armWill` is false, arms the B.4 Last Will and clears any
|
|
76
|
+
* stale retained LOST_CONNECTION left over from a prior ungraceful disconnect (spec §4).
|
|
77
|
+
*/
|
|
78
|
+
static connect(opts: SessionOptions): Promise<Iso21423Session>;
|
|
79
|
+
/** Passthrough so `/core` never rebuilds topics itself (Task 3 implementer note). */
|
|
80
|
+
topicFor(ref: EntityRef, resource: string): string;
|
|
81
|
+
on<K extends keyof SessionEvents>(event: K, cb: SessionEvents[K]): void;
|
|
82
|
+
/**
|
|
83
|
+
* Publishes a known resource (looked up in {@link RESOURCE_CONFIG} for its QoS/retain/rate).
|
|
84
|
+
* Retained resources are deduped on-change (a re-publish with identical body is a no-op) and
|
|
85
|
+
* rolled back from the dedup cache if the publish itself fails. Rate-limited (streaming)
|
|
86
|
+
* resources go through a per-topic {@link RateGate} and are fire-and-forget: publish failures
|
|
87
|
+
* there are reported via the `error` event, not thrown.
|
|
88
|
+
*/
|
|
89
|
+
publishResource(ref: EntityRef, resource: string, kind: MessageKind | null, payload: unknown): Promise<void>;
|
|
90
|
+
/** Last non-wildcard resource segment → Table B.1 QoS, defaulting to QoS 1 when unknown. */
|
|
91
|
+
private qosForFilter;
|
|
92
|
+
/**
|
|
93
|
+
* Always issues a broker SUBSCRIBE (a real broker redelivers retained messages on every
|
|
94
|
+
* SUBSCRIBE, so a late second handler must see the current retained value); the broker-side
|
|
95
|
+
* unsubscribe still only fires once the last local listener on the filter leaves (ND-17).
|
|
96
|
+
*/
|
|
97
|
+
subscribeTopic(topicFilter: string, kind: MessageKind | null, handler: (msg: unknown, meta: TopicMeta) => void, opts?: {
|
|
98
|
+
qos?: 0 | 1 | 2;
|
|
99
|
+
}): Promise<SessionSubscription>;
|
|
100
|
+
/** Publish to an exact topic (request / requestStatus topics are not plain resources). */
|
|
101
|
+
publishTopic(topic: string, kind: MessageKind | null, payload: unknown, opts: {
|
|
102
|
+
qos: 0 | 1 | 2;
|
|
103
|
+
retain: boolean;
|
|
104
|
+
}): Promise<void>;
|
|
105
|
+
get connectionState(): ConnectionState;
|
|
106
|
+
/**
|
|
107
|
+
* Subscribe to a resource topic with optional validation.
|
|
108
|
+
* When kind is null, handler receives raw payload text without parsing or validation.
|
|
109
|
+
*/
|
|
110
|
+
subscribeResource(filter: {
|
|
111
|
+
entityType?: string;
|
|
112
|
+
entityUuid?: string;
|
|
113
|
+
}, resource: string, kind: MessageKind | null, handler: (msg: unknown, meta: TopicMeta) => void): Promise<SessionSubscription & {
|
|
114
|
+
[Symbol.asyncDispose](): Promise<void>;
|
|
115
|
+
}>;
|
|
116
|
+
/** For subscribers that opt out of schema routing (kind: null) but still want to surface a
|
|
117
|
+
* malformed payload as the usual 'validation-warning' event (D-13's RequestServer). */
|
|
118
|
+
reportValidationWarning(w: ValidationWarningEvent): void;
|
|
119
|
+
publishRaw(topic: string, payload: string, opts: {
|
|
120
|
+
qos: 0 | 1 | 2;
|
|
121
|
+
retain: boolean;
|
|
122
|
+
}): Promise<void>;
|
|
123
|
+
/** Clears a retained topic by publishing an empty retained payload, and drops it from the owned-retained dedup cache. */
|
|
124
|
+
clearRetained(topic: string): Promise<void>;
|
|
125
|
+
/** Optionally publishes a final status, disposes all rate gates, then ends the transport. */
|
|
126
|
+
close(finalStates?: string[]): Promise<void>;
|
|
127
|
+
/**
|
|
128
|
+
* Routes an inbound message to every registered {@link TopicSub} whose filter matches the
|
|
129
|
+
* topic. `kind: null` subscribers get the raw text with no parsing; typed subscribers get an
|
|
130
|
+
* empty payload treated as a retained-clear (skipped silently) and malformed/non-conformant
|
|
131
|
+
* payloads reported via `emitWarning` rather than delivered to the handler.
|
|
132
|
+
*/
|
|
133
|
+
private dispatch;
|
|
134
|
+
private handleConnectionState;
|
|
135
|
+
private emitWarning;
|
|
136
|
+
private emitError;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
export { Iso21423Session as I, type SessionOptions as S, type TopicMeta as T, type ValidationWarningEvent as V, type SessionSubscription as a };
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
import { M as MqttTransport, C as ConnectionState } from './transport-BT4AjTn9.js';
|
|
2
|
+
import { E as EntityRef } from './topics-BiVeZyTW.js';
|
|
3
|
+
import { M as MessageKind } from './validators-Be0ce1b8.js';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Copyright 2026 InOrbit, Inc.
|
|
7
|
+
*
|
|
8
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
9
|
+
* you may not use this file except in compliance with the License.
|
|
10
|
+
* You may obtain a copy of the License at
|
|
11
|
+
*
|
|
12
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
13
|
+
*
|
|
14
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
15
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
16
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
17
|
+
* See the License for the specific language governing permissions and
|
|
18
|
+
* limitations under the License.
|
|
19
|
+
*/
|
|
20
|
+
|
|
21
|
+
/** Options for {@link Iso21423Session.connect}. */
|
|
22
|
+
interface SessionOptions {
|
|
23
|
+
transport: MqttTransport;
|
|
24
|
+
entity: EntityRef;
|
|
25
|
+
credentials?: {
|
|
26
|
+
username?: string;
|
|
27
|
+
password?: string;
|
|
28
|
+
};
|
|
29
|
+
validateOutbound?: boolean;
|
|
30
|
+
/** Arm the B.4 Last Will at connect time. Default true; false for identity-less sessions (R1). */
|
|
31
|
+
armWill?: boolean;
|
|
32
|
+
}
|
|
33
|
+
/** Returned by `subscribeTopic` / `subscribeResource`: stop receiving on that filter. */
|
|
34
|
+
interface SessionSubscription {
|
|
35
|
+
unsubscribe(): Promise<void>;
|
|
36
|
+
}
|
|
37
|
+
/** Topic-derived metadata handed to subscription handlers alongside the parsed payload. */
|
|
38
|
+
interface TopicMeta {
|
|
39
|
+
topic: string;
|
|
40
|
+
entityType: string;
|
|
41
|
+
entityUuid: string;
|
|
42
|
+
resource: string;
|
|
43
|
+
requestUuid?: string;
|
|
44
|
+
isRequestStatus: boolean;
|
|
45
|
+
}
|
|
46
|
+
/** Emitted on the `'validation-warning'` event when an inbound message fails schema validation or JSON parsing. */
|
|
47
|
+
interface ValidationWarningEvent {
|
|
48
|
+
topic: string;
|
|
49
|
+
payload: string;
|
|
50
|
+
errors: unknown[];
|
|
51
|
+
}
|
|
52
|
+
type SessionEvents = {
|
|
53
|
+
connection: (s: ConnectionState) => void;
|
|
54
|
+
'validation-warning': (w: ValidationWarningEvent) => void;
|
|
55
|
+
error: (err: unknown) => void;
|
|
56
|
+
};
|
|
57
|
+
/**
|
|
58
|
+
* Owns one MQTT connection for a single entity: topic-scoped subscribe/publish, retained-resource
|
|
59
|
+
* dedup and republish-on-reconnect, streaming-resource rate gating, LWT arming, and inbound schema
|
|
60
|
+
* validation. This is the layer `/core` builds its request/response semantics on top of.
|
|
61
|
+
*/
|
|
62
|
+
declare class Iso21423Session {
|
|
63
|
+
private readonly transport;
|
|
64
|
+
readonly entity: EntityRef;
|
|
65
|
+
private readonly validateOutbound;
|
|
66
|
+
private readonly armWill;
|
|
67
|
+
private retainedOwned;
|
|
68
|
+
private rateGates;
|
|
69
|
+
private topicSubs;
|
|
70
|
+
private listeners;
|
|
71
|
+
private wasConnected;
|
|
72
|
+
private state;
|
|
73
|
+
private constructor();
|
|
74
|
+
/**
|
|
75
|
+
* Connects the transport and, unless `armWill` is false, arms the B.4 Last Will and clears any
|
|
76
|
+
* stale retained LOST_CONNECTION left over from a prior ungraceful disconnect (spec §4).
|
|
77
|
+
*/
|
|
78
|
+
static connect(opts: SessionOptions): Promise<Iso21423Session>;
|
|
79
|
+
/** Passthrough so `/core` never rebuilds topics itself (Task 3 implementer note). */
|
|
80
|
+
topicFor(ref: EntityRef, resource: string): string;
|
|
81
|
+
on<K extends keyof SessionEvents>(event: K, cb: SessionEvents[K]): void;
|
|
82
|
+
/**
|
|
83
|
+
* Publishes a known resource (looked up in {@link RESOURCE_CONFIG} for its QoS/retain/rate).
|
|
84
|
+
* Retained resources are deduped on-change (a re-publish with identical body is a no-op) and
|
|
85
|
+
* rolled back from the dedup cache if the publish itself fails. Rate-limited (streaming)
|
|
86
|
+
* resources go through a per-topic {@link RateGate} and are fire-and-forget: publish failures
|
|
87
|
+
* there are reported via the `error` event, not thrown.
|
|
88
|
+
*/
|
|
89
|
+
publishResource(ref: EntityRef, resource: string, kind: MessageKind | null, payload: unknown): Promise<void>;
|
|
90
|
+
/** Last non-wildcard resource segment → Table B.1 QoS, defaulting to QoS 1 when unknown. */
|
|
91
|
+
private qosForFilter;
|
|
92
|
+
/**
|
|
93
|
+
* Always issues a broker SUBSCRIBE (a real broker redelivers retained messages on every
|
|
94
|
+
* SUBSCRIBE, so a late second handler must see the current retained value); the broker-side
|
|
95
|
+
* unsubscribe still only fires once the last local listener on the filter leaves (ND-17).
|
|
96
|
+
*/
|
|
97
|
+
subscribeTopic(topicFilter: string, kind: MessageKind | null, handler: (msg: unknown, meta: TopicMeta) => void, opts?: {
|
|
98
|
+
qos?: 0 | 1 | 2;
|
|
99
|
+
}): Promise<SessionSubscription>;
|
|
100
|
+
/** Publish to an exact topic (request / requestStatus topics are not plain resources). */
|
|
101
|
+
publishTopic(topic: string, kind: MessageKind | null, payload: unknown, opts: {
|
|
102
|
+
qos: 0 | 1 | 2;
|
|
103
|
+
retain: boolean;
|
|
104
|
+
}): Promise<void>;
|
|
105
|
+
get connectionState(): ConnectionState;
|
|
106
|
+
/**
|
|
107
|
+
* Subscribe to a resource topic with optional validation.
|
|
108
|
+
* When kind is null, handler receives raw payload text without parsing or validation.
|
|
109
|
+
*/
|
|
110
|
+
subscribeResource(filter: {
|
|
111
|
+
entityType?: string;
|
|
112
|
+
entityUuid?: string;
|
|
113
|
+
}, resource: string, kind: MessageKind | null, handler: (msg: unknown, meta: TopicMeta) => void): Promise<SessionSubscription & {
|
|
114
|
+
[Symbol.asyncDispose](): Promise<void>;
|
|
115
|
+
}>;
|
|
116
|
+
/** For subscribers that opt out of schema routing (kind: null) but still want to surface a
|
|
117
|
+
* malformed payload as the usual 'validation-warning' event (D-13's RequestServer). */
|
|
118
|
+
reportValidationWarning(w: ValidationWarningEvent): void;
|
|
119
|
+
publishRaw(topic: string, payload: string, opts: {
|
|
120
|
+
qos: 0 | 1 | 2;
|
|
121
|
+
retain: boolean;
|
|
122
|
+
}): Promise<void>;
|
|
123
|
+
/** Clears a retained topic by publishing an empty retained payload, and drops it from the owned-retained dedup cache. */
|
|
124
|
+
clearRetained(topic: string): Promise<void>;
|
|
125
|
+
/** Optionally publishes a final status, disposes all rate gates, then ends the transport. */
|
|
126
|
+
close(finalStates?: string[]): Promise<void>;
|
|
127
|
+
/**
|
|
128
|
+
* Routes an inbound message to every registered {@link TopicSub} whose filter matches the
|
|
129
|
+
* topic. `kind: null` subscribers get the raw text with no parsing; typed subscribers get an
|
|
130
|
+
* empty payload treated as a retained-clear (skipped silently) and malformed/non-conformant
|
|
131
|
+
* payloads reported via `emitWarning` rather than delivered to the handler.
|
|
132
|
+
*/
|
|
133
|
+
private dispatch;
|
|
134
|
+
private handleConnectionState;
|
|
135
|
+
private emitWarning;
|
|
136
|
+
private emitError;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
export { Iso21423Session as I, type SessionOptions as S, type TopicMeta as T, type ValidationWarningEvent as V, type SessionSubscription as a };
|