@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 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/session/index.ts","../src/errors.ts","../src/session/rateGate.ts","../src/topics/resources.ts","../src/types/constants.ts","../src/topics/topics.ts","../src/types/common.ts","../src/schema/validators.ts","../src/schema/iso21423.schema.json","../src/schema/normalize.ts","../src/session/session.ts","../src/session/mqttTransport.ts"],"sourcesContent":["/**\n * Copyright 2026 InOrbit, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nexport * from './transport.js';\nexport * from './session.js';\nexport { RateGate } from './rateGate.js';\nexport * from './mqttTransport.js';\n","/**\n * Copyright 2026 InOrbit, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/** Base class for all errors this SDK throws; `name` is set to the concrete subclass name so it survives serialization. */\nexport class Iso21423Error extends Error {\n constructor(message: string) {\n super(message);\n this.name = new.target.name;\n }\n}\n\n/** Thrown when a payload fails ISO 21423 JSON Schema validation; `errors` holds the raw Ajv error list. */\nexport class ValidationError extends Iso21423Error {\n constructor(message: string, public readonly errors: unknown[]) {\n super(message);\n }\n}\n\n/** Thrown when a request/detail reaches a terminal failure state; `finalStatus` carries the last status received. */\nexport class RequestFailed extends Iso21423Error {\n constructor(message: string, public readonly finalStatus: unknown) {\n super(message);\n }\n}\n\nexport class RequestTimeout extends Iso21423Error {}\nexport class BrokerUnavailable extends Iso21423Error {}\n\n/** Thrown when a broker/ACL rejects a publish or subscribe; `topic` names the topic that was denied. */\nexport class AuthorizationDenied extends Iso21423Error {\n constructor(message: string, public readonly topic: string) {\n super(message);\n }\n}\n\nexport class NotCapableError extends Iso21423Error {}\n/** Thrown by {@link Lifecycle.transition} when the requested state change isn't allowed from the current state. */\nexport class IllegalTransition extends Iso21423Error {}\n","/**\n * Copyright 2026 InOrbit, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { Iso21423Error } from '../errors.js';\n\n/**\n * Latest-wins rate limiter for streaming telemetry (Table B.1 bounds).\n * Emits immediately when the minimum interval has elapsed; otherwise keeps\n * only the newest value and flushes it when the interval expires.\n */\nexport class RateGate {\n private readonly intervalMs: number;\n private lastEmit = -Infinity;\n private pending?: { value: unknown; emit: (v: never) => void };\n private timer?: ReturnType<typeof setTimeout>;\n\n constructor(maxHz: number) {\n if (!(maxHz > 0) || !Number.isFinite(maxHz)) {\n throw new Iso21423Error(`RateGate requires a finite maxHz > 0, got ${maxHz}`);\n }\n this.intervalMs = 1000 / maxHz;\n }\n\n /** Offers a value for emission; emits now if the interval has elapsed, else schedules a trailing emit and discards any previously-pending value. */\n offer<T>(value: T, emit: (v: T) => void): void {\n const now = Date.now();\n if (now - this.lastEmit >= this.intervalMs) {\n this.lastEmit = now;\n emit(value);\n return;\n }\n this.pending = { value, emit: emit as (v: never) => void };\n if (this.timer === undefined) {\n const wait = this.intervalMs - (now - this.lastEmit);\n this.timer = setTimeout(() => {\n this.timer = undefined;\n const p = this.pending;\n this.pending = undefined;\n if (p) {\n this.lastEmit = Date.now();\n (p.emit as (v: unknown) => void)(p.value);\n }\n }, wait);\n }\n }\n\n /** Cancels any pending trailing emit. The pending value is dropped, not flushed. */\n dispose(): void {\n if (this.timer !== undefined) clearTimeout(this.timer);\n this.timer = undefined;\n this.pending = undefined;\n }\n}\n","/**\n * Copyright 2026 InOrbit, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { Iso21423Error } from '../errors.js';\n\n/** Normative publish settings for a resource; `minHz`/`maxHz` bound the allowed publish rate where the spec constrains it. */\nexport interface ResourceConfig { qos: 0 | 1 | 2; retain: boolean; minHz?: number; maxHz?: number }\n\n/** Table B.1 — resources and their normative QoS / retain / rate configuration. */\nexport const RESOURCE_CONFIG: Record<string, ResourceConfig> = {\n identity: { qos: 1, retain: true },\n status: { qos: 1, retain: true },\n batteryStatus: { qos: 0, retain: true },\n footprint: { qos: 1, retain: true },\n odometry: { qos: 0, retain: false, minHz: 0.5, maxHz: 30 },\n localTrajectory: { qos: 0, retain: false, minHz: 1, maxHz: 10 },\n globalPath: { qos: 1, retain: true },\n globalPlan: { qos: 1, retain: true },\n request: { qos: 2, retain: true },\n requestStatus: { qos: 2, retain: true },\n activeRequestsStatus: { qos: 1, retain: true },\n disconnection: { qos: 1, retain: true }, // B.4 LWT parameters\n};\n\nconst STANDARD_RESOURCES: ReadonlySet<string> = new Set(Object.keys(RESOURCE_CONFIG));\n\n/** True for the resources Table B.1 defines; false for deployment-defined extension resources. */\nexport function isStandardResource(name: string): boolean {\n return STANDARD_RESOURCES.has(name);\n}\n\n/**\n * Registers a deployment-defined resource (ISO 21423 leaves the resource catalog open — see the\n * standard's extension clause) so entities can publish it via `EntityHandle.publishExtension` and\n * clients can `subscribeResource` to it. Extension resources carry no schema: subscribers receive\n * the raw payload text, exactly like `footprint`.\n *\n * Process-wide (the resource table is a module singleton): both ends of a deployment must\n * register the same name with the same config. Re-registering with an identical config is a\n * no-op; a different config throws, as does a name that collides with a standard resource.\n */\nexport function registerExtensionResource(name: string, config: ResourceConfig): void {\n if (!/^[A-Za-z][A-Za-z0-9_-]*$/.test(name)) {\n throw new Iso21423Error(`invalid extension resource name \"${name}\"`);\n }\n if (STANDARD_RESOURCES.has(name)) {\n throw new Iso21423Error(`\"${name}\" is a standard ISO 21423 resource and cannot be redefined`);\n }\n const existing = RESOURCE_CONFIG[name];\n if (existing && (existing.qos !== config.qos || existing.retain !== config.retain\n || existing.minHz !== config.minHz || existing.maxHz !== config.maxHz)) {\n throw new Iso21423Error(`extension resource \"${name}\" is already registered with a different config`);\n }\n RESOURCE_CONFIG[name] = { ...config };\n}\n","/**\n * Copyright 2026 InOrbit, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nexport const ROOT_NAMESPACE = '/ISO_21423/v1';\nexport const PROTOCOL_VERSION = '1.0';\n\nexport const ENTITY_TYPES = ['IMR', 'IMRFM'] as const;\nexport type KnownEntityType = (typeof ENTITY_TYPES)[number];\n/** Widened to allow vendor-defined entity types beyond the two the spec names, while still autocompleting the known ones. */\nexport type EntityType = KnownEntityType | (string & {});\n\n/** All operating states the spec defines: stop categories, motion states, and MODE_* (mutually-exclusive mode markers) mixed together. */\nexport const KNOWN_OPERATING_STATES = [\n 'STOP_CATEGORY_0', 'STOP_CATEGORY_1', 'STOP_CATEGORY_2',\n 'PAUSED', 'WAIT_FOR_RESET', 'MAPPING', 'LOST',\n 'WAIT_FOR_ATTACHMENT', 'WAIT_FOR_EVENT', 'BLOCKED', 'ATTACHMENT_ACTIVE',\n 'STOPPED', 'DOCKING', 'SLOWING', 'ACCELERATING',\n 'LEFT_TURN', 'RIGHT_TURN', 'REVERSE', 'FORWARD', 'LINE_FOLLOWING',\n 'CHARGING', 'LOW_BATTERY', 'IDLE', 'PARKED', 'OFFLINE',\n 'READY', 'NOT_READY',\n 'MODE_AUTO', 'MODE_SEMIAUTO', 'MODE_TELEOP', 'MODE_MANUAL', 'MODE_MAINTENANCE',\n] as const;\nexport type KnownOperatingState = (typeof KNOWN_OPERATING_STATES)[number];\nexport type OperatingState = KnownOperatingState | (string & {});\n\n/** Subset of {@link KNOWN_OPERATING_STATES} that are the mutually-exclusive MODE_* markers. */\nexport const OPERATING_MODES = [\n 'MODE_AUTO', 'MODE_SEMIAUTO', 'MODE_TELEOP', 'MODE_MANUAL', 'MODE_MAINTENANCE',\n] as const;\n\n/** LWT state published by the broker on ungraceful disconnect (B.4). */\nexport const LOST_CONNECTION_STATE = 'LOST_CONNECTION';\n\n/** Overall lifecycle states for a whole {@link Request} (its `RECOVERY` state has no per-detail equivalent — see {@link DetailState}). */\nexport const REQUEST_STATES = [\n 'RECEIVED', 'ACCEPTED', 'EXECUTING', 'CANCELED', 'SUCCEEDED', 'ABORTED', 'RECOVERY',\n] as const;\nexport type RequestState = (typeof REQUEST_STATES)[number];\n\n/** Lifecycle states for a single detail/action within a request. */\nexport const DETAIL_STATES = [\n 'RECEIVED', 'ACCEPTED', 'EXECUTING', 'CANCELED', 'SUCCEEDED', 'ABORTED',\n] as const;\nexport type DetailState = (typeof DETAIL_STATES)[number];\n\nexport const KNOWN_REASON_CODES = [\n 'OK', 'GENERAL_FAILURE', 'TIMEOUT', 'VERSION_NOT_SUPPORTED', 'FORMAT_NOT_SUPPORTED',\n 'ACTION_NOT_IMPLEMENTED', 'REJECTED', 'MALFORMED_REQUEST', 'INVALID_IMR_STATE_FOR_ACTION',\n] as const;\nexport type ReasonCode = (typeof KNOWN_REASON_CODES)[number] | (string & {});\n\nexport const BATTERY_HEALTH = [\n 'UNKNOWN', 'HEALTHY', 'OVERHEAT', 'DEAD', 'OVERVOLTAGE', 'FAILURE', 'COLD',\n] as const;\nexport type BatteryHealth = (typeof BATTERY_HEALTH)[number] | (string & {});\n\n/** Charging state as distinct from {@link BatteryHealth} — this is about current/direction of charge flow, not battery condition. */\nexport const CHARGING_STATES = [\n 'UNKNOWN', 'CHARGING', 'DISCHARGING', 'NOT_CHARGING', 'FULL',\n] as const;\nexport type ChargingState = (typeof CHARGING_STATES)[number] | (string & {});\n\nexport const DOCK_ACTIONS = ['CHARGE', 'DUMP', 'FILL', 'LOAD', 'UNLOAD', 'PICK', 'DROP'] as const;\nexport type DockAction = (typeof DOCK_ACTIONS)[number] | (string & {});\n","/**\n * Copyright 2026 InOrbit, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { ROOT_NAMESPACE } from '../types/constants.js';\n\n/** Identifies an entity for topic-building purposes: its ISO type (\"IMR\"/\"IMRFM\") and its uuid. */\nexport interface EntityRef { entityType: string; entityUuid: string }\n\n/** Decomposed form of an ISO 21423 topic string, as produced by {@link parseTopic}. */\nexport interface ParsedTopic {\n entityType: string;\n entityUuid: string;\n resource: string;\n requestUuid?: string;\n isRequestStatus: boolean;\n}\n\nexport function topicFor(ref: EntityRef, resource: string): string {\n return `${ROOT_NAMESPACE}/${ref.entityType}/${ref.entityUuid}/${resource}`;\n}\n\nexport function requestTopic(ref: EntityRef, requestUuid: string): string {\n return `${topicFor(ref, 'request')}/${requestUuid}`;\n}\n\nexport function requestStatusTopic(ref: EntityRef, requestUuid: string): string {\n return `${requestTopic(ref, requestUuid)}/status`;\n}\n\nexport function disconnectionTopic(ref: EntityRef): string {\n return topicFor(ref, 'disconnection');\n}\n\n/** MQTT wildcard subscription matching every entity's identity topic, used to build the fleet-wide entity cache. */\nexport function identityWildcard(): string {\n return `${ROOT_NAMESPACE}/+/+/identity`;\n}\n\n/**\n * Splits a concrete topic string into its parts, or returns `null` if it doesn't\n * live under {@link ROOT_NAMESPACE} or has an unrecognized shape (e.g. extra path segments).\n */\nexport function parseTopic(topic: string): ParsedTopic | null {\n if (!topic.startsWith(`${ROOT_NAMESPACE}/`)) return null;\n const rest = topic.slice(ROOT_NAMESPACE.length + 1).split('/');\n const [entityType, entityUuid, resource, ...tail] = rest;\n if (!entityType || !entityUuid || !resource) return null;\n if (resource === 'request' && tail.length >= 1) {\n const [requestUuid, maybeStatus] = tail;\n if (!requestUuid || (maybeStatus !== undefined && maybeStatus !== 'status') || tail.length > 2) return null;\n return { entityType, entityUuid, resource, requestUuid, isRequestStatus: maybeStatus === 'status' };\n }\n if (tail.length > 0) return null;\n return { entityType, entityUuid, resource, isRequestStatus: false };\n}\n\n/** MQTT 3.1.1 topic filter matching (+ single level, # multi level). */\nexport function topicFilterMatches(filter: string, topic: string): boolean {\n const f = filter.split('/');\n const t = topic.split('/');\n for (let i = 0; i < f.length; i++) {\n const seg = f[i];\n if (seg === '#') return true;\n if (i >= t.length) return false;\n if (seg !== '+' && seg !== t[i]) return false;\n }\n return f.length === t.length;\n}\n","/**\n * Copyright 2026 InOrbit, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nexport type Uuid = string;\n/** ISO 8601-1 timestamp string, dot-decimal milliseconds, UTC. */\nexport type IsoTimestamp = string;\n\nexport function nowTimestamp(date: Date = new Date()): IsoTimestamp {\n return date.toISOString();\n}\n\n/** Accepts both dot and comma decimal separators (spec §3.1). */\nexport function parseTimestamp(ts: string): Date {\n return new Date(ts.replace(',', '.'));\n}\n","/**\n * Copyright 2026 InOrbit, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { Ajv2020 } from 'ajv/dist/2020.js';\nimport addFormats from 'ajv-formats';\nimport schema from './iso21423.schema.json' with { type: 'json' };\nimport { KNOWN_OPERATING_STATES } from '../types/constants.js';\nimport { ValidationError } from '../errors.js';\nimport { normalizeInbound } from './normalize.js';\n\nexport type MessageKind =\n | 'entityIdentity' | 'entityStatus' | 'batteryStatus' | 'odometry'\n | 'localTrajectory' | 'globalPath' | 'globalPlan'\n | 'request' | 'requestStatus' | 'requestStatusArray';\n\n/** Result of {@link validateMessage}: `value` is the normalized payload (present whether or not it validated). */\nexport interface ValidationResult {\n ok: boolean;\n value?: unknown;\n warnings: string[];\n errors?: unknown[];\n}\n\nconst ajv = new Ajv2020({ allErrors: true, strict: false });\n(addFormats as unknown as (ajv: Ajv2020) => void)(ajv);\najv.addSchema(schema);\n\nconst KNOWN_STATES = new Set<string>(KNOWN_OPERATING_STATES);\n\n/** Appends a warning (mutating `warnings`) for each `entityStatus.states` entry not in {@link KNOWN_OPERATING_STATES} — schema-valid but possibly a deployment-specific extension. */\nfunction collectWarnings(kind: MessageKind, value: unknown, warnings: string[]): void {\n if (kind !== 'entityStatus') return;\n const states = (value as { states?: unknown })?.states;\n if (!Array.isArray(states)) return;\n for (const s of states) {\n if (typeof s === 'string' && !KNOWN_STATES.has(s)) {\n warnings.push(`entityStatus: unknown operating state \"${s}\" (deployment extension?)`);\n }\n }\n}\n\n/** Normalizes then validates a raw wire payload against the ISO 21423 JSON Schema for `kind`. Throws if `kind` has no registered schema. */\nexport function validateMessage(kind: MessageKind, raw: unknown): ValidationResult {\n const { value, warnings } = normalizeInbound(kind, raw);\n const validate = ajv.getSchema(`https://openrobops.org/schemas/iso21423/v1.json#/$defs/${kind}`);\n if (!validate) throw new Error(`No schema for message kind: ${kind}`);\n const ok = validate(value) as boolean;\n collectWarnings(kind, value, warnings);\n return ok\n ? { ok: true, value, warnings }\n : { ok: false, value, warnings, errors: validate.errors ?? [] };\n}\n\n/** Egress guard: throws on non-conformant outbound payloads. */\nexport function assertValid(kind: MessageKind, value: unknown): void {\n const r = validateMessage(kind, value);\n if (!r.ok) {\n throw new ValidationError(`outbound ${kind} message is not ISO 21423 conformant`, r.errors ?? []);\n }\n}\n","{\n \"$schema\": \"https://json-schema.org/draft/2020-12/schema\",\n \"$id\": \"https://openrobops.org/schemas/iso21423/v1.json\",\n \"$defs\": {\n \"uuid\": { \"type\": \"string\", \"pattern\": \"^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-5][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}$\" },\n \"timestamp\": { \"type\": \"string\", \"format\": \"date-time\" },\n \"point\": {\n \"type\": \"object\", \"required\": [\"x\", \"y\"],\n \"properties\": { \"x\": { \"type\": \"number\" }, \"y\": { \"type\": \"number\" } }\n },\n \"locationPoint\": {\n \"type\": \"object\", \"required\": [\"ccsId\", \"x\", \"y\", \"z\"],\n \"properties\": {\n \"ccsId\": { \"$ref\": \"#/$defs/uuid\" },\n \"x\": { \"type\": \"number\" }, \"y\": { \"type\": \"number\" }, \"z\": { \"type\": \"number\" }\n }\n },\n \"orientation\": {\n \"type\": \"object\", \"required\": [\"yaw\", \"pitch\", \"roll\"],\n \"properties\": { \"yaw\": { \"type\": \"number\" }, \"pitch\": { \"type\": \"number\" }, \"roll\": { \"type\": \"number\" } }\n },\n \"capabilities\": {\n \"type\": \"object\", \"required\": [\"provides\", \"accepts\"],\n \"properties\": {\n \"provides\": { \"type\": \"array\", \"items\": { \"type\": \"string\" } },\n \"accepts\": {\n \"type\": \"object\", \"required\": [\"requests\"],\n \"properties\": { \"requests\": { \"type\": \"array\", \"items\": { \"type\": \"string\" } } }\n },\n \"manages\": { \"type\": \"array\", \"items\": { \"$ref\": \"#/$defs/uuid\" } },\n \"managedBy\": { \"$ref\": \"#/$defs/uuid\" }\n }\n },\n \"softwareVersion\": {\n \"type\": \"object\", \"required\": [\"moduleName\", \"moduleVersion\"],\n \"properties\": { \"moduleName\": { \"type\": \"string\" }, \"moduleVersion\": { \"type\": \"string\" } }\n },\n \"locationPointStamped\": {\n \"type\": \"object\", \"required\": [\"timestamp\", \"locationPoint\"],\n \"properties\": {\n \"timestamp\": { \"$ref\": \"#/$defs/timestamp\" },\n \"locationPoint\": { \"$ref\": \"#/$defs/locationPoint\" }\n }\n },\n \"requestDetail\": {\n \"type\": \"object\", \"required\": [\"type\", \"version\"],\n \"properties\": {\n \"type\": { \"type\": \"string\" },\n \"version\": { \"type\": \"string\" },\n \"format\": { \"type\": \"string\" },\n \"blocking\": { \"type\": \"boolean\" },\n \"atomic\": { \"type\": \"boolean\" },\n \"properties\": { \"type\": \"object\" }\n }\n },\n \"requestDetailStatus\": {\n \"type\": \"object\", \"required\": [\"type\", \"version\", \"status\"],\n \"properties\": {\n \"type\": { \"type\": \"string\" },\n \"version\": { \"type\": \"string\" },\n \"blocking\": { \"type\": \"boolean\" },\n \"status\": {\n \"type\": \"object\", \"required\": [\"code\"],\n \"properties\": {\n \"code\": { \"enum\": [\"RECEIVED\", \"ACCEPTED\", \"EXECUTING\", \"CANCELED\", \"SUCCEEDED\", \"ABORTED\"] },\n \"reason\": { \"type\": \"string\" },\n \"message\": { \"type\": \"string\" }\n }\n },\n \"properties\": { \"type\": \"object\" }\n }\n },\n \"entityIdentity\": {\n \"type\": \"object\",\n \"required\": [\"id\", \"timestamp\", \"entityType\", \"manufacturerName\", \"capabilities\", \"details\"],\n \"properties\": {\n \"id\": { \"$ref\": \"#/$defs/uuid\" },\n \"timestamp\": { \"$ref\": \"#/$defs/timestamp\" },\n \"entityType\": { \"type\": \"string\" },\n \"manufacturerName\": { \"type\": \"string\" },\n \"iso21423Version\": { \"type\": \"string\" },\n \"capabilities\": { \"$ref\": \"#/$defs/capabilities\" },\n \"details\": { \"type\": \"object\" }\n }\n },\n \"entityStatus\": {\n \"type\": \"object\", \"required\": [\"entityId\", \"timestamp\", \"states\"],\n \"properties\": {\n \"entityId\": { \"$ref\": \"#/$defs/uuid\" },\n \"timestamp\": { \"$ref\": \"#/$defs/timestamp\" },\n \"states\": { \"type\": \"array\", \"items\": { \"type\": \"string\", \"pattern\": \"^[A-Z0-9_]+$\" } },\n \"disabledCapabilities\": { \"$ref\": \"#/$defs/capabilities\" }\n }\n },\n \"batteryStatus\": {\n \"type\": \"object\", \"required\": [\"timestamp\", \"batterySoc\"],\n \"properties\": {\n \"timestamp\": { \"$ref\": \"#/$defs/timestamp\" },\n \"batterySoc\": { \"type\": \"number\", \"minimum\": 0, \"maximum\": 1 },\n \"batteryHealth\": { \"type\": \"string\" },\n \"batteryTemperature\": { \"type\": \"number\" },\n \"batteryVoltage\": { \"type\": \"number\" },\n \"batteryCurrent\": { \"type\": \"number\" },\n \"batteryChargingState\": { \"type\": \"string\" }\n }\n },\n \"odometry\": {\n \"type\": \"object\", \"required\": [\"timestamp\", \"pose\", \"velocity\"],\n \"properties\": {\n \"timestamp\": { \"$ref\": \"#/$defs/timestamp\" },\n \"pose\": {\n \"type\": \"object\", \"required\": [\"locationPoint\", \"orientation\"],\n \"properties\": {\n \"locationPoint\": { \"$ref\": \"#/$defs/locationPoint\" },\n \"orientation\": { \"$ref\": \"#/$defs/orientation\" }\n }\n },\n \"velocity\": {\n \"type\": \"object\", \"required\": [\"linear\", \"angular\"],\n \"properties\": { \"linear\": { \"type\": \"number\" }, \"angular\": { \"type\": \"number\" } }\n }\n }\n },\n \"localTrajectory\": {\n \"type\": \"object\", \"required\": [\"timestamp\", \"localTrajectory\"],\n \"properties\": {\n \"timestamp\": { \"$ref\": \"#/$defs/timestamp\" },\n \"localTrajectory\": { \"type\": \"array\", \"items\": { \"$ref\": \"#/$defs/locationPointStamped\" } }\n }\n },\n \"globalPath\": {\n \"type\": \"object\", \"required\": [\"timestamp\", \"globalPath\"],\n \"properties\": {\n \"timestamp\": { \"$ref\": \"#/$defs/timestamp\" },\n \"globalPath\": {\n \"type\": \"object\", \"required\": [\"degree\", \"controlPoints\", \"knots\"],\n \"properties\": {\n \"degree\": { \"type\": \"integer\", \"minimum\": 1 },\n \"controlPoints\": {\n \"type\": \"array\",\n \"items\": {\n \"type\": \"object\", \"required\": [\"locationPoint\"],\n \"properties\": {\n \"locationPoint\": { \"$ref\": \"#/$defs/locationPoint\" },\n \"weight\": { \"type\": \"number\" }\n }\n }\n },\n \"knots\": { \"type\": \"array\", \"items\": { \"type\": \"number\" }, \"minItems\": 4 }\n }\n }\n }\n },\n \"globalPlan\": {\n \"type\": \"object\", \"required\": [\"timestamp\", \"globalPlan\"],\n \"properties\": {\n \"timestamp\": { \"$ref\": \"#/$defs/timestamp\" },\n \"globalPlan\": { \"type\": \"array\", \"items\": { \"$ref\": \"#/$defs/locationPointStamped\" } }\n }\n },\n \"request\": {\n \"type\": \"object\",\n \"required\": [\"destination\", \"source\", \"sequenceId\", \"timestamp\", \"details\"],\n \"properties\": {\n \"destination\": { \"anyOf\": [{ \"$ref\": \"#/$defs/uuid\" }, { \"const\": \"\" }] },\n \"source\": { \"$ref\": \"#/$defs/uuid\" },\n \"sequenceId\": { \"type\": \"integer\", \"minimum\": 0 },\n \"timestamp\": { \"$ref\": \"#/$defs/timestamp\" },\n \"priority\": { \"type\": \"integer\", \"minimum\": 0, \"maximum\": 255 },\n \"atomic\": { \"type\": \"boolean\" },\n \"details\": { \"type\": \"array\", \"minItems\": 1, \"items\": { \"$ref\": \"#/$defs/requestDetail\" } },\n \"recoveries\": { \"type\": \"array\", \"items\": { \"$ref\": \"#/$defs/requestDetail\" } }\n }\n },\n \"requestStatus\": {\n \"type\": \"object\",\n \"required\": [\"source\", \"destination\", \"sequenceId\", \"requestSequenceId\", \"timestamp\", \"status\", \"detailStatuses\"],\n \"properties\": {\n \"source\": { \"$ref\": \"#/$defs/uuid\" },\n \"destination\": { \"$ref\": \"#/$defs/uuid\" },\n \"sequenceId\": { \"type\": \"integer\", \"minimum\": 0 },\n \"requestSequenceId\": { \"type\": \"integer\", \"minimum\": 0 },\n \"timestamp\": { \"$ref\": \"#/$defs/timestamp\" },\n \"status\": { \"enum\": [\"RECEIVED\", \"ACCEPTED\", \"EXECUTING\", \"CANCELED\", \"SUCCEEDED\", \"ABORTED\", \"RECOVERY\"] },\n \"detailStatuses\": { \"type\": \"array\", \"items\": { \"$ref\": \"#/$defs/requestDetailStatus\" } },\n \"recoveryStatuses\": { \"type\": \"array\", \"items\": { \"$ref\": \"#/$defs/requestDetailStatus\" } }\n }\n },\n \"requestStatusArray\": { \"type\": \"array\", \"items\": { \"$ref\": \"#/$defs/requestStatus\" } }\n }\n}\n","/**\n * Copyright 2026 InOrbit, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nconst TIMESTAMP_KEYS = new Set(['timestamp', 'arrivalTime']);\nconst COMMA_TS = /^(\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}),(\\d+)(Z|[+-]\\d{2}:?\\d{2})$/;\n\n/** Recursively rewrites comma-decimal timestamps (e.g. \"12:00:00,500Z\") to dot-decimal form, recording a warning per fix. */\nfunction fixTimestamps(value: unknown, warnings: string[], path: string): unknown {\n if (Array.isArray(value)) return value.map((v, i) => fixTimestamps(v, warnings, `${path}[${i}]`));\n if (value === null || typeof value !== 'object') return value;\n const out: Record<string, unknown> = {};\n for (const [k, v] of Object.entries(value as Record<string, unknown>)) {\n if (TIMESTAMP_KEYS.has(k) && typeof v === 'string' && COMMA_TS.test(v)) {\n out[k] = v.replace(COMMA_TS, '$1.$2$3');\n warnings.push(`${path}.${k}: comma-decimal timestamp normalized to dot form`);\n } else {\n out[k] = fixTimestamps(v, warnings, `${path}.${k}`);\n }\n }\n return out;\n}\n\n/**\n * Best-effort cleanup of inbound wire payloads before schema validation: fixes comma-decimal\n * timestamps and, for `entityStatus`, renames the legacy `id` field to `entityId` (spec §3.1).\n * Never throws; returns the corrected value plus human-readable warnings for anything it touched.\n */\nexport function normalizeInbound(kind: string, value: unknown): { value: unknown; warnings: string[] } {\n const warnings: string[] = [];\n let v = fixTimestamps(value, warnings, kind);\n if (kind === 'entityStatus' && v !== null && typeof v === 'object' && !Array.isArray(v)) {\n const o = v as Record<string, unknown>;\n if (o.entityId === undefined && typeof o.id === 'string') {\n const { id, ...rest } = o;\n v = { ...rest, entityId: id };\n warnings.push('entityStatus: legacy field \"id\" renamed to \"entityId\" (spec §3.1)');\n }\n }\n return { value: v, warnings };\n}\n","/**\n * Copyright 2026 InOrbit, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { MqttTransport, ConnectionState } from './transport.js';\nimport { RateGate } from './rateGate.js';\nimport { RESOURCE_CONFIG } from '../topics/resources.js';\nimport {\n topicFor, disconnectionTopic, parseTopic, topicFilterMatches, type EntityRef,\n} from '../topics/topics.js';\nimport { ROOT_NAMESPACE, LOST_CONNECTION_STATE } from '../types/constants.js';\nimport { nowTimestamp } from '../types/common.js';\nimport { validateMessage, assertValid, type MessageKind } from '../schema/validators.js';\nimport { AuthorizationDenied, Iso21423Error } from '../errors.js';\n\n/** Options for {@link Iso21423Session.connect}. */\nexport interface SessionOptions {\n transport: MqttTransport;\n entity: EntityRef;\n credentials?: { username?: string; password?: string };\n validateOutbound?: boolean;\n /** Arm the B.4 Last Will at connect time. Default true; false for identity-less sessions (R1). */\n armWill?: boolean;\n}\n\n/** Returned by `subscribeTopic` / `subscribeResource`: stop receiving on that filter. */\nexport interface SessionSubscription {\n unsubscribe(): Promise<void>;\n}\n\n/** Topic-derived metadata handed to subscription handlers alongside the parsed payload. */\nexport interface TopicMeta {\n topic: string;\n entityType: string;\n entityUuid: string;\n resource: string;\n requestUuid?: string;\n isRequestStatus: boolean;\n}\n\n/** Emitted on the `'validation-warning'` event when an inbound message fails schema validation or JSON parsing. */\nexport interface ValidationWarningEvent {\n topic: string;\n payload: string;\n errors: unknown[];\n}\n\ntype SessionEvents = {\n connection: (s: ConnectionState) => void;\n 'validation-warning': (w: ValidationWarningEvent) => void;\n error: (err: unknown) => void;\n};\n\ninterface TopicSub {\n filter: string;\n kind: MessageKind | null;\n handler: (msg: unknown, meta: TopicMeta) => void;\n}\n\n/**\n * Owns one MQTT connection for a single entity: topic-scoped subscribe/publish, retained-resource\n * dedup and republish-on-reconnect, streaming-resource rate gating, LWT arming, and inbound schema\n * validation. This is the layer `/core` builds its request/response semantics on top of.\n */\nexport class Iso21423Session {\n private retainedOwned = new Map<string, { payload: string; qos: 0 | 1 | 2 }>();\n private rateGates = new Map<string, RateGate>();\n private topicSubs: TopicSub[] = [];\n private listeners: { [K in keyof SessionEvents]: Array<SessionEvents[K]> } = {\n connection: [], 'validation-warning': [], error: [],\n };\n private wasConnected = false;\n private state: ConnectionState = 'closed';\n\n private constructor(\n private readonly transport: MqttTransport,\n readonly entity: EntityRef,\n private readonly validateOutbound: boolean,\n private readonly armWill: boolean,\n ) {}\n\n /**\n * Connects the transport and, unless `armWill` is false, arms the B.4 Last Will and clears any\n * stale retained LOST_CONNECTION left over from a prior ungraceful disconnect (spec §4).\n */\n static async connect(opts: SessionOptions): Promise<Iso21423Session> {\n const armWill = opts.armWill ?? true;\n const session = new Iso21423Session(opts.transport, opts.entity, opts.validateOutbound ?? true, armWill);\n opts.transport.onMessage((m) => session.dispatch(m.topic, m.payload));\n opts.transport.onConnectionState((s) => session.handleConnectionState(s));\n await opts.transport.connect({\n clientId: `iso21423-${opts.entity.entityType}-${opts.entity.entityUuid}`,\n cleanSession: false,\n keepalive: 60,\n username: opts.credentials?.username,\n password: opts.credentials?.password,\n will: armWill ? {\n topic: disconnectionTopic(opts.entity),\n payload: JSON.stringify({ states: [LOST_CONNECTION_STATE] }),\n qos: 1,\n retain: true,\n } : undefined,\n });\n // Clear stale retained LOST_CONNECTION from a prior crash (spec §4). Skipped when no will was\n // armed: an identity-less session never owns a disconnection topic, so there is nothing stale\n // to clear (R1 — implementer's choice).\n if (armWill) await session.clearRetained(disconnectionTopic(opts.entity));\n return session;\n }\n\n /** Passthrough so `/core` never rebuilds topics itself (Task 3 implementer note). */\n topicFor(ref: EntityRef, resource: string): string {\n return topicFor(ref, resource);\n }\n\n on<K extends keyof SessionEvents>(event: K, cb: SessionEvents[K]): void {\n this.listeners[event].push(cb);\n }\n\n /**\n * Publishes a known resource (looked up in {@link RESOURCE_CONFIG} for its QoS/retain/rate).\n * Retained resources are deduped on-change (a re-publish with identical body is a no-op) and\n * rolled back from the dedup cache if the publish itself fails. Rate-limited (streaming)\n * resources go through a per-topic {@link RateGate} and are fire-and-forget: publish failures\n * there are reported via the `error` event, not thrown.\n */\n async publishResource(ref: EntityRef, resource: string, kind: MessageKind | null, payload: unknown): Promise<void> {\n const config = RESOURCE_CONFIG[resource];\n if (!config) throw new Iso21423Error(`unknown resource \"${resource}\"`);\n if (kind && this.validateOutbound) assertValid(kind, payload);\n const topic = topicFor(ref, resource);\n const body = JSON.stringify(payload);\n\n if (config.retain) {\n if (this.retainedOwned.get(topic)?.payload === body) return; // on-change rule\n this.retainedOwned.set(topic, { payload: body, qos: config.qos });\n try {\n await this.transport.publish(topic, body, { qos: config.qos, retain: true });\n } catch (err) {\n this.retainedOwned.delete(topic);\n throw err;\n }\n return;\n }\n if (config.maxHz !== undefined) {\n let gate = this.rateGates.get(topic);\n if (!gate) {\n gate = new RateGate(config.maxHz);\n this.rateGates.set(topic, gate);\n }\n gate.offer(body, (b) => {\n this.transport.publish(topic, b, { qos: config.qos, retain: false })\n .catch((err) => this.emitError(err));\n });\n return;\n }\n await this.transport.publish(topic, body, { qos: config.qos, retain: false });\n }\n\n /** Last non-wildcard resource segment → Table B.1 QoS, defaulting to QoS 1 when unknown. */\n private qosForFilter(filter: string): 0 | 1 | 2 {\n const parsed = parseTopic(filter);\n if (!parsed) return 1;\n const key = parsed.isRequestStatus ? 'requestStatus' : parsed.resource;\n return RESOURCE_CONFIG[key]?.qos ?? 1;\n }\n\n /**\n * Always issues a broker SUBSCRIBE (a real broker redelivers retained messages on every\n * SUBSCRIBE, so a late second handler must see the current retained value); the broker-side\n * unsubscribe still only fires once the last local listener on the filter leaves (ND-17).\n */\n async subscribeTopic(\n topicFilter: string,\n kind: MessageKind | null,\n handler: (msg: unknown, meta: TopicMeta) => void,\n opts: { qos?: 0 | 1 | 2 } = {},\n ): Promise<SessionSubscription> {\n const qos = opts.qos ?? this.qosForFilter(topicFilter);\n const { granted } = await this.transport.subscribe(topicFilter, { qos });\n if (!granted) {\n throw new AuthorizationDenied(`subscription denied by broker: ${topicFilter}`, topicFilter);\n }\n const sub: TopicSub = { filter: topicFilter, kind, handler };\n this.topicSubs.push(sub);\n return {\n unsubscribe: async () => {\n this.topicSubs = this.topicSubs.filter((s) => s !== sub);\n if (!this.topicSubs.some((s) => s.filter === topicFilter)) {\n await this.transport.unsubscribe(topicFilter);\n }\n },\n };\n }\n\n /** Publish to an exact topic (request / requestStatus topics are not plain resources). */\n async publishTopic(\n topic: string,\n kind: MessageKind | null,\n payload: unknown,\n opts: { qos: 0 | 1 | 2; retain: boolean },\n ): Promise<void> {\n if (kind && this.validateOutbound) assertValid(kind, payload);\n await this.transport.publish(topic, JSON.stringify(payload), opts);\n }\n\n get connectionState(): ConnectionState {\n return this.state;\n }\n\n /**\n * Subscribe to a resource topic with optional validation.\n * When kind is null, handler receives raw payload text without parsing or validation.\n */\n async subscribeResource(\n filter: { entityType?: string; entityUuid?: string },\n resource: string,\n kind: MessageKind | null,\n handler: (msg: unknown, meta: TopicMeta) => void,\n ): Promise<SessionSubscription & { [Symbol.asyncDispose](): Promise<void> }> {\n const config = RESOURCE_CONFIG[resource];\n if (!config) throw new Iso21423Error(`unknown resource \"${resource}\"`);\n const topicFilter = `${ROOT_NAMESPACE}/${filter.entityType ?? '+'}/${filter.entityUuid ?? '+'}/${resource}`;\n const sub = await this.subscribeTopic(topicFilter, kind, handler, { qos: config.qos });\n return { unsubscribe: sub.unsubscribe, [Symbol.asyncDispose]: sub.unsubscribe };\n }\n\n /** For subscribers that opt out of schema routing (kind: null) but still want to surface a\n * malformed payload as the usual 'validation-warning' event (D-13's RequestServer). */\n reportValidationWarning(w: ValidationWarningEvent): void {\n this.emitWarning(w);\n }\n\n async publishRaw(topic: string, payload: string, opts: { qos: 0 | 1 | 2; retain: boolean }): Promise<void> {\n await this.transport.publish(topic, payload, opts);\n }\n\n /** Clears a retained topic by publishing an empty retained payload, and drops it from the owned-retained dedup cache. */\n async clearRetained(topic: string): Promise<void> {\n this.retainedOwned.delete(topic);\n await this.transport.publish(topic, '', { qos: 1, retain: true });\n }\n\n /** Optionally publishes a final status, disposes all rate gates, then ends the transport. */\n async close(finalStates?: string[]): Promise<void> {\n if (finalStates) {\n await this.publishResource(this.entity, 'status', 'entityStatus', {\n entityId: this.entity.entityUuid,\n timestamp: nowTimestamp(),\n states: finalStates,\n });\n }\n for (const gate of this.rateGates.values()) gate.dispose();\n await this.transport.end();\n }\n\n /**\n * Routes an inbound message to every registered {@link TopicSub} whose filter matches the\n * topic. `kind: null` subscribers get the raw text with no parsing; typed subscribers get an\n * empty payload treated as a retained-clear (skipped silently) and malformed/non-conformant\n * payloads reported via `emitWarning` rather than delivered to the handler.\n */\n private dispatch(topic: string, payload: Buffer): void {\n const parsed = parseTopic(topic);\n if (!parsed) return;\n const text = payload.toString();\n const meta: TopicMeta = {\n topic,\n entityType: parsed.entityType,\n entityUuid: parsed.entityUuid,\n resource: parsed.resource,\n requestUuid: parsed.requestUuid,\n isRequestStatus: parsed.isRequestStatus,\n };\n for (const sub of this.topicSubs) {\n if (!topicFilterMatches(sub.filter, topic)) continue;\n if (!sub.kind) {\n sub.handler(text, meta);\n continue;\n }\n // An empty payload on a validated subscription is a retained-clear, not malformed input.\n if (text === '') continue;\n let value: unknown;\n try {\n value = JSON.parse(text);\n } catch {\n this.emitWarning({ topic, payload: text, errors: ['invalid JSON'] });\n continue;\n }\n const result = validateMessage(sub.kind, value);\n if (!result.ok) {\n this.emitWarning({ topic, payload: text, errors: result.errors ?? [] });\n continue;\n }\n sub.handler(result.value, meta);\n }\n }\n\n private handleConnectionState(s: ConnectionState): void {\n this.state = s;\n for (const cb of this.listeners.connection) cb(s);\n if (s === 'connected' && this.wasConnected) {\n // Reconnect: republish owned retained resources (broker may have lost them).\n for (const [topic, { payload, qos }] of this.retainedOwned) {\n this.transport.publish(topic, payload, { qos, retain: true })\n .catch((err) => this.emitError(err));\n }\n // The LWT we armed at connect time has now fired (stale): clear it, same as the\n // stale-crash clear at initial connect (spec §4).\n if (this.armWill) {\n this.clearRetained(disconnectionTopic(this.entity)).catch((err) => this.emitError(err));\n }\n }\n if (s === 'connected') this.wasConnected = true;\n }\n\n private emitWarning(w: ValidationWarningEvent): void {\n for (const cb of this.listeners['validation-warning']) cb(w);\n }\n\n private emitError(err: unknown): void {\n const errorListeners = this.listeners.error;\n if (errorListeners.length > 0) {\n for (const cb of errorListeners) cb(err);\n } else {\n console.error('[Iso21423Session] async publish failed:', err);\n }\n }\n}\n","/**\n * Copyright 2026 InOrbit, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type {\n ConnectionState, MqttTransport, TransportConnectOptions, TransportMessage,\n} from './transport.js';\nimport { BrokerUnavailable, Iso21423Error } from '../errors.js';\n\n/** The minimal mqtt@5 surface the adapter uses — keeps `mqtt` out of the public types. */\nexport interface MqttClientLike {\n options?: { will?: { topic?: string }; clean?: boolean };\n connected: boolean;\n on(event: string, cb: (...args: never[]) => void): void;\n publishAsync(\n topic: string, payload: string | Buffer, opts: { qos: 0 | 1 | 2; retain: boolean },\n ): Promise<unknown>;\n subscribeAsync(filter: string, opts: { qos: 0 | 1 | 2 }): Promise<Array<{ topic: string; qos: number }>>;\n unsubscribeAsync(filter: string): Promise<unknown>;\n endAsync(force?: boolean): Promise<void>;\n}\n\n/** Options for {@link createMqttTransport}. */\nexport interface MqttTransportOptions {\n username?: string;\n password?: string;\n /** TLS / socket options passed straight through to mqtt.connect (ND-15). */\n tls?: Record<string, unknown>;\n reconnectPeriod?: number;\n}\n\n/** {@link MqttTransport} implementation over mqtt@5, either owning its own client ({@link createMqttTransport}) or wrapping a caller-supplied one ({@link wrapMqttClient}). */\nclass MqttAdapter implements MqttTransport {\n private client?: MqttClientLike;\n private ended = false;\n private wired = false;\n private readonly messageCbs: Array<(m: TransportMessage) => void> = [];\n private readonly stateCbs: Array<(s: ConnectionState) => void> = [];\n\n constructor(\n private readonly acquire: (opts: TransportConnectOptions) => Promise<MqttClientLike>,\n private readonly checkWill: boolean,\n private readonly ownsClient: boolean,\n ) {}\n\n /**\n * Acquires the underlying mqtt client (via the constructor-supplied `acquire`) and wires\n * message/connection-state listeners exactly once per adapter instance, so repeated `connect()`\n * calls (e.g. reconnect flows) don't accumulate duplicate listeners. For a caller-constructed\n * client whose will doesn't match `opts.will`, throws (P-4) rather than silently diverging.\n */\n async connect(opts: TransportConnectOptions): Promise<void> {\n const client = await this.acquire(opts);\n if (this.checkWill && opts.will && client.options?.will?.topic !== opts.will.topic) {\n throw new Iso21423Error(\n `caller-constructed mqtt client must be created with will { topic: \"${opts.will.topic}\", ` +\n `payload: '${opts.will.payload}', qos: ${opts.will.qos}, retain: ${opts.will.retain} } (P-4)`,\n );\n }\n\n // Wire message/state listeners only once per adapter\n if (!this.wired) {\n this.wired = true;\n client.on('message', ((topic: string, payload: Buffer, packet: { qos?: 0 | 1 | 2; retain?: boolean }) => {\n const msg: TransportMessage = {\n topic, payload, qos: packet?.qos ?? 0, retain: packet?.retain ?? false,\n };\n for (const cb of this.messageCbs) cb(msg);\n }) as never);\n client.on('reconnect', (() => this.emitState('reconnecting')) as never);\n client.on('offline', (() => this.emitState('offline')) as never);\n client.on('close', (() => this.emitState('closed')) as never);\n // Persistent 'connect' listener: mqtt.js re-emits 'connect' after every auto-reconnect, not\n // just the initial handshake. This is the ONLY place that emits 'connected' — the initial\n // connect's own onConnect (below) fires after this one (registered later, same event) and\n // only settles the promise/records `this.client`, so each 'connect' event still produces\n // exactly one 'connected' state, initial or reconnect alike.\n client.on('connect', (() => this.emitState('connected')) as never);\n }\n\n if (client.connected) {\n // Already connected (e.g. a caller-constructed client via wrapMqttClient): no 'connect'\n // event will fire for this state, so emit it directly — the persistent listener above only\n // covers events, not the already-there case.\n this.client = client;\n this.emitState('connected');\n return;\n }\n\n // Local settled flag ensures onConnect/onError fires at most once per promise\n let settled = false;\n const resolveReject = { resolve: null as unknown as (v: void) => void, reject: null as unknown as (r: unknown) => void };\n\n const onConnect = (() => {\n if (settled) return;\n settled = true;\n // 'connected' itself is emitted by the persistent listener registered above (same event) —\n // this only needs to record the live client and settle the connect() promise.\n this.client = client;\n resolveReject.resolve();\n }) as (...args: never[]) => void;\n\n const onError = ((err: Error) => {\n if (settled) return;\n settled = true;\n // Clean up owned clients (createMqttTransport path)\n if (this.ownsClient) {\n client.endAsync(true).catch(() => {}); // fire-and-forget\n }\n resolveReject.reject(new BrokerUnavailable(`mqtt connect failed: ${err.message}`));\n }) as (...args: never[]) => void;\n\n try {\n await new Promise<void>((resolve, reject) => {\n resolveReject.resolve = resolve;\n resolveReject.reject = reject;\n client.on('connect', onConnect);\n client.on('error', onError);\n });\n } finally {\n // Clean up settled listeners to prevent accumulation on retry\n try {\n const clientWithRemoval = client as { off?: (ev: string, cb: unknown) => void; removeListener?: (ev: string, cb: unknown) => void };\n (clientWithRemoval.off ?? clientWithRemoval.removeListener)?.('connect', onConnect);\n (clientWithRemoval.off ?? clientWithRemoval.removeListener)?.('error', onError);\n } catch {\n // Ignore cleanup errors (client might be disconnected/destroyed)\n }\n }\n }\n\n async publish(\n topic: string, payload: string | Buffer, opts: { qos: 0 | 1 | 2; retain: boolean },\n ): Promise<void> {\n await this.live().publishAsync(topic, payload, opts);\n }\n\n /** Subscribes and reports whether the broker granted it — false if any SUBACK return code was a refusal (>= 0x80, ND-15) or no grants came back. */\n async subscribe(filter: string, opts: { qos: 0 | 1 | 2 }): Promise<{ granted: boolean }> {\n const grants = await this.live().subscribeAsync(filter, opts);\n // MQTT 3.1.1 SUBACK: return code >= 0x80 means the broker refused the filter (ND-15).\n const granted = grants.length > 0 && grants.every((g) => g.qos < 128);\n return { granted };\n }\n\n async unsubscribe(filter: string): Promise<void> {\n await this.live().unsubscribeAsync(filter);\n }\n\n onMessage(cb: (m: TransportMessage) => void): void {\n this.messageCbs.push(cb);\n }\n\n onConnectionState(cb: (s: ConnectionState) => void): void {\n this.stateCbs.push(cb);\n }\n\n async end(): Promise<void> {\n this.ended = true;\n if (this.client) await this.client.endAsync();\n this.emitState('closed');\n }\n\n /** Returns the connected client or throws {@link BrokerUnavailable} if `end()` was called or `connect()` hasn't completed. */\n private live(): MqttClientLike {\n if (this.ended || !this.client) throw new BrokerUnavailable('mqtt transport is not connected');\n return this.client;\n }\n\n private emitState(s: ConnectionState): void {\n for (const cb of this.stateCbs) cb(s);\n }\n}\n\n/** Adapt a caller-constructed mqtt client (D-07). Its will must match the SDK's (P-4). */\nexport function wrapMqttClient(client: MqttClientLike): MqttTransport {\n return new MqttAdapter(async () => client, true, false);\n}\n\n/**\n * Default adapter. `mqtt` is a peer dependency and is imported lazily inside connect(),\n * so importing this module never pulls mqtt into the graph (no top-level await, ND-19).\n */\nexport function createMqttTransport(url: string, opts: MqttTransportOptions = {}): MqttTransport {\n return new MqttAdapter(async (connectOpts) => {\n let mod: { connect: (url: string, o: Record<string, unknown>) => MqttClientLike };\n try {\n mod = (await import('mqtt')) as never;\n } catch (err) {\n throw new BrokerUnavailable(\n `the \"mqtt\" peer dependency is not installed: ${(err as Error).message}`,\n );\n }\n return mod.connect(url, {\n ...opts.tls,\n clientId: connectOpts.clientId,\n clean: connectOpts.cleanSession,\n keepalive: connectOpts.keepalive,\n username: connectOpts.username ?? opts.username,\n password: connectOpts.password ?? opts.password,\n reconnectPeriod: opts.reconnectPeriod,\n will: connectOpts.will,\n });\n }, false, true);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACiBO,IAAM,gBAAN,cAA4B,MAAM;AAAA,EACvC,YAAY,SAAiB;AAC3B,UAAM,OAAO;AACb,SAAK,OAAO,WAAW;AAAA,EACzB;AACF;AAGO,IAAM,kBAAN,cAA8B,cAAc;AAAA,EACjD,YAAY,SAAiC,QAAmB;AAC9D,UAAM,OAAO;AAD8B;AAAA,EAE7C;AAAA,EAF6C;AAG/C;AAUO,IAAM,oBAAN,cAAgC,cAAc;AAAC;AAG/C,IAAM,sBAAN,cAAkC,cAAc;AAAA,EACrD,YAAY,SAAiC,OAAe;AAC1D,UAAM,OAAO;AAD8B;AAAA,EAE7C;AAAA,EAF6C;AAG/C;;;ACvBO,IAAM,WAAN,MAAe;AAAA,EACH;AAAA,EACT,WAAW;AAAA,EACX;AAAA,EACA;AAAA,EAER,YAAY,OAAe;AACzB,QAAI,EAAE,QAAQ,MAAM,CAAC,OAAO,SAAS,KAAK,GAAG;AAC3C,YAAM,IAAI,cAAc,6CAA6C,KAAK,EAAE;AAAA,IAC9E;AACA,SAAK,aAAa,MAAO;AAAA,EAC3B;AAAA;AAAA,EAGA,MAAS,OAAU,MAA4B;AAC7C,UAAM,MAAM,KAAK,IAAI;AACrB,QAAI,MAAM,KAAK,YAAY,KAAK,YAAY;AAC1C,WAAK,WAAW;AAChB,WAAK,KAAK;AACV;AAAA,IACF;AACA,SAAK,UAAU,EAAE,OAAO,KAAiC;AACzD,QAAI,KAAK,UAAU,QAAW;AAC5B,YAAM,OAAO,KAAK,cAAc,MAAM,KAAK;AAC3C,WAAK,QAAQ,WAAW,MAAM;AA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,SAAO,IAAI,YAAY,OAAO,gBAAgB;AAC5C,QAAI;AACJ,QAAI;AACF,YAAO,MAAM,OAAO,MAAM;AAAA,IAC5B,SAAS,KAAK;AACZ,YAAM,IAAI;AAAA,QACR,gDAAiD,IAAc,OAAO;AAAA,MACxE;AAAA,IACF;AACA,WAAO,IAAI,QAAQ,KAAK;AAAA,MACtB,GAAG,KAAK;AAAA,MACR,UAAU,YAAY;AAAA,MACtB,OAAO,YAAY;AAAA,MACnB,WAAW,YAAY;AAAA,MACvB,UAAU,YAAY,YAAY,KAAK;AAAA,MACvC,UAAU,YAAY,YAAY,KAAK;AAAA,MACvC,iBAAiB,KAAK;AAAA,MACtB,MAAM,YAAY;AAAA,IACpB,CAAC;AAAA,EACH,GAAG,OAAO,IAAI;AAChB;","names":["addFormats"]}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import { M as MqttTransport } from './transport-BT4AjTn9.cjs';
|
|
2
|
+
export { C as ConnectionState, T as TransportConnectOptions, a as TransportMessage, W as WillOptions } from './transport-BT4AjTn9.cjs';
|
|
3
|
+
export { I as Iso21423Session, S as SessionOptions, a as SessionSubscription, T as TopicMeta, V as ValidationWarningEvent } from './session-RV32MFpV.cjs';
|
|
4
|
+
import './topics-BiVeZyTW.cjs';
|
|
5
|
+
import './validators-Be0ce1b8.cjs';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Copyright 2026 InOrbit, Inc.
|
|
9
|
+
*
|
|
10
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
11
|
+
* you may not use this file except in compliance with the License.
|
|
12
|
+
* You may obtain a copy of the License at
|
|
13
|
+
*
|
|
14
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
15
|
+
*
|
|
16
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
17
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
18
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
19
|
+
* See the License for the specific language governing permissions and
|
|
20
|
+
* limitations under the License.
|
|
21
|
+
*/
|
|
22
|
+
/**
|
|
23
|
+
* Latest-wins rate limiter for streaming telemetry (Table B.1 bounds).
|
|
24
|
+
* Emits immediately when the minimum interval has elapsed; otherwise keeps
|
|
25
|
+
* only the newest value and flushes it when the interval expires.
|
|
26
|
+
*/
|
|
27
|
+
declare class RateGate {
|
|
28
|
+
private readonly intervalMs;
|
|
29
|
+
private lastEmit;
|
|
30
|
+
private pending?;
|
|
31
|
+
private timer?;
|
|
32
|
+
constructor(maxHz: number);
|
|
33
|
+
/** Offers a value for emission; emits now if the interval has elapsed, else schedules a trailing emit and discards any previously-pending value. */
|
|
34
|
+
offer<T>(value: T, emit: (v: T) => void): void;
|
|
35
|
+
/** Cancels any pending trailing emit. The pending value is dropped, not flushed. */
|
|
36
|
+
dispose(): void;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Copyright 2026 InOrbit, Inc.
|
|
41
|
+
*
|
|
42
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
43
|
+
* you may not use this file except in compliance with the License.
|
|
44
|
+
* You may obtain a copy of the License at
|
|
45
|
+
*
|
|
46
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
47
|
+
*
|
|
48
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
49
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
50
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
51
|
+
* See the License for the specific language governing permissions and
|
|
52
|
+
* limitations under the License.
|
|
53
|
+
*/
|
|
54
|
+
|
|
55
|
+
/** The minimal mqtt@5 surface the adapter uses — keeps `mqtt` out of the public types. */
|
|
56
|
+
interface MqttClientLike {
|
|
57
|
+
options?: {
|
|
58
|
+
will?: {
|
|
59
|
+
topic?: string;
|
|
60
|
+
};
|
|
61
|
+
clean?: boolean;
|
|
62
|
+
};
|
|
63
|
+
connected: boolean;
|
|
64
|
+
on(event: string, cb: (...args: never[]) => void): void;
|
|
65
|
+
publishAsync(topic: string, payload: string | Buffer, opts: {
|
|
66
|
+
qos: 0 | 1 | 2;
|
|
67
|
+
retain: boolean;
|
|
68
|
+
}): Promise<unknown>;
|
|
69
|
+
subscribeAsync(filter: string, opts: {
|
|
70
|
+
qos: 0 | 1 | 2;
|
|
71
|
+
}): Promise<Array<{
|
|
72
|
+
topic: string;
|
|
73
|
+
qos: number;
|
|
74
|
+
}>>;
|
|
75
|
+
unsubscribeAsync(filter: string): Promise<unknown>;
|
|
76
|
+
endAsync(force?: boolean): Promise<void>;
|
|
77
|
+
}
|
|
78
|
+
/** Options for {@link createMqttTransport}. */
|
|
79
|
+
interface MqttTransportOptions {
|
|
80
|
+
username?: string;
|
|
81
|
+
password?: string;
|
|
82
|
+
/** TLS / socket options passed straight through to mqtt.connect (ND-15). */
|
|
83
|
+
tls?: Record<string, unknown>;
|
|
84
|
+
reconnectPeriod?: number;
|
|
85
|
+
}
|
|
86
|
+
/** Adapt a caller-constructed mqtt client (D-07). Its will must match the SDK's (P-4). */
|
|
87
|
+
declare function wrapMqttClient(client: MqttClientLike): MqttTransport;
|
|
88
|
+
/**
|
|
89
|
+
* Default adapter. `mqtt` is a peer dependency and is imported lazily inside connect(),
|
|
90
|
+
* so importing this module never pulls mqtt into the graph (no top-level await, ND-19).
|
|
91
|
+
*/
|
|
92
|
+
declare function createMqttTransport(url: string, opts?: MqttTransportOptions): MqttTransport;
|
|
93
|
+
|
|
94
|
+
export { type MqttClientLike, MqttTransport, type MqttTransportOptions, RateGate, createMqttTransport, wrapMqttClient };
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import { M as MqttTransport } from './transport-BT4AjTn9.js';
|
|
2
|
+
export { C as ConnectionState, T as TransportConnectOptions, a as TransportMessage, W as WillOptions } from './transport-BT4AjTn9.js';
|
|
3
|
+
export { I as Iso21423Session, S as SessionOptions, a as SessionSubscription, T as TopicMeta, V as ValidationWarningEvent } from './session-ueiESY7Y.js';
|
|
4
|
+
import './topics-BiVeZyTW.js';
|
|
5
|
+
import './validators-Be0ce1b8.js';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Copyright 2026 InOrbit, Inc.
|
|
9
|
+
*
|
|
10
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
11
|
+
* you may not use this file except in compliance with the License.
|
|
12
|
+
* You may obtain a copy of the License at
|
|
13
|
+
*
|
|
14
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
15
|
+
*
|
|
16
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
17
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
18
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
19
|
+
* See the License for the specific language governing permissions and
|
|
20
|
+
* limitations under the License.
|
|
21
|
+
*/
|
|
22
|
+
/**
|
|
23
|
+
* Latest-wins rate limiter for streaming telemetry (Table B.1 bounds).
|
|
24
|
+
* Emits immediately when the minimum interval has elapsed; otherwise keeps
|
|
25
|
+
* only the newest value and flushes it when the interval expires.
|
|
26
|
+
*/
|
|
27
|
+
declare class RateGate {
|
|
28
|
+
private readonly intervalMs;
|
|
29
|
+
private lastEmit;
|
|
30
|
+
private pending?;
|
|
31
|
+
private timer?;
|
|
32
|
+
constructor(maxHz: number);
|
|
33
|
+
/** Offers a value for emission; emits now if the interval has elapsed, else schedules a trailing emit and discards any previously-pending value. */
|
|
34
|
+
offer<T>(value: T, emit: (v: T) => void): void;
|
|
35
|
+
/** Cancels any pending trailing emit. The pending value is dropped, not flushed. */
|
|
36
|
+
dispose(): void;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Copyright 2026 InOrbit, Inc.
|
|
41
|
+
*
|
|
42
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
43
|
+
* you may not use this file except in compliance with the License.
|
|
44
|
+
* You may obtain a copy of the License at
|
|
45
|
+
*
|
|
46
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
47
|
+
*
|
|
48
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
49
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
50
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
51
|
+
* See the License for the specific language governing permissions and
|
|
52
|
+
* limitations under the License.
|
|
53
|
+
*/
|
|
54
|
+
|
|
55
|
+
/** The minimal mqtt@5 surface the adapter uses — keeps `mqtt` out of the public types. */
|
|
56
|
+
interface MqttClientLike {
|
|
57
|
+
options?: {
|
|
58
|
+
will?: {
|
|
59
|
+
topic?: string;
|
|
60
|
+
};
|
|
61
|
+
clean?: boolean;
|
|
62
|
+
};
|
|
63
|
+
connected: boolean;
|
|
64
|
+
on(event: string, cb: (...args: never[]) => void): void;
|
|
65
|
+
publishAsync(topic: string, payload: string | Buffer, opts: {
|
|
66
|
+
qos: 0 | 1 | 2;
|
|
67
|
+
retain: boolean;
|
|
68
|
+
}): Promise<unknown>;
|
|
69
|
+
subscribeAsync(filter: string, opts: {
|
|
70
|
+
qos: 0 | 1 | 2;
|
|
71
|
+
}): Promise<Array<{
|
|
72
|
+
topic: string;
|
|
73
|
+
qos: number;
|
|
74
|
+
}>>;
|
|
75
|
+
unsubscribeAsync(filter: string): Promise<unknown>;
|
|
76
|
+
endAsync(force?: boolean): Promise<void>;
|
|
77
|
+
}
|
|
78
|
+
/** Options for {@link createMqttTransport}. */
|
|
79
|
+
interface MqttTransportOptions {
|
|
80
|
+
username?: string;
|
|
81
|
+
password?: string;
|
|
82
|
+
/** TLS / socket options passed straight through to mqtt.connect (ND-15). */
|
|
83
|
+
tls?: Record<string, unknown>;
|
|
84
|
+
reconnectPeriod?: number;
|
|
85
|
+
}
|
|
86
|
+
/** Adapt a caller-constructed mqtt client (D-07). Its will must match the SDK's (P-4). */
|
|
87
|
+
declare function wrapMqttClient(client: MqttClientLike): MqttTransport;
|
|
88
|
+
/**
|
|
89
|
+
* Default adapter. `mqtt` is a peer dependency and is imported lazily inside connect(),
|
|
90
|
+
* so importing this module never pulls mqtt into the graph (no top-level await, ND-19).
|
|
91
|
+
*/
|
|
92
|
+
declare function createMqttTransport(url: string, opts?: MqttTransportOptions): MqttTransport;
|
|
93
|
+
|
|
94
|
+
export { type MqttClientLike, MqttTransport, type MqttTransportOptions, RateGate, createMqttTransport, wrapMqttClient };
|
package/dist/session.js
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import "./chunk-JQAMNFAF.js";
|
|
2
|
+
import {
|
|
3
|
+
Iso21423Session,
|
|
4
|
+
RateGate,
|
|
5
|
+
createMqttTransport,
|
|
6
|
+
wrapMqttClient
|
|
7
|
+
} from "./chunk-DMJ6T3RX.js";
|
|
8
|
+
import "./chunk-UJC46NTA.js";
|
|
9
|
+
import "./chunk-UW6WTEPT.js";
|
|
10
|
+
import "./chunk-LTPOAVGF.js";
|
|
11
|
+
import "./chunk-5ZIUSUHF.js";
|
|
12
|
+
import "./chunk-RD7PYTIT.js";
|
|
13
|
+
import "./chunk-JLUENXGS.js";
|
|
14
|
+
export {
|
|
15
|
+
Iso21423Session,
|
|
16
|
+
RateGate,
|
|
17
|
+
createMqttTransport,
|
|
18
|
+
wrapMqttClient
|
|
19
|
+
};
|
|
20
|
+
//# sourceMappingURL=session.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
package/dist/testing.cjs
ADDED
|
@@ -0,0 +1,205 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/testing/index.ts
|
|
21
|
+
var testing_exports = {};
|
|
22
|
+
__export(testing_exports, {
|
|
23
|
+
MemoryBroker: () => MemoryBroker,
|
|
24
|
+
MemoryTransport: () => MemoryTransport
|
|
25
|
+
});
|
|
26
|
+
module.exports = __toCommonJS(testing_exports);
|
|
27
|
+
|
|
28
|
+
// src/topics/topics.ts
|
|
29
|
+
function topicFilterMatches(filter, topic) {
|
|
30
|
+
const f = filter.split("/");
|
|
31
|
+
const t = topic.split("/");
|
|
32
|
+
for (let i = 0; i < f.length; i++) {
|
|
33
|
+
const seg = f[i];
|
|
34
|
+
if (seg === "#") return true;
|
|
35
|
+
if (i >= t.length) return false;
|
|
36
|
+
if (seg !== "+" && seg !== t[i]) return false;
|
|
37
|
+
}
|
|
38
|
+
return f.length === t.length;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
// src/testing/memoryTransport.ts
|
|
42
|
+
var MemoryBroker = class {
|
|
43
|
+
clients = /* @__PURE__ */ new Set();
|
|
44
|
+
retained = /* @__PURE__ */ new Map();
|
|
45
|
+
deniedFilters = [];
|
|
46
|
+
log = [];
|
|
47
|
+
createTransport() {
|
|
48
|
+
const t = new MemoryTransport(this);
|
|
49
|
+
this.clients.add(t);
|
|
50
|
+
return t;
|
|
51
|
+
}
|
|
52
|
+
/** Makes future `subscribe()` calls for exactly this filter string report `granted: false`, for testing subscription-denied paths. */
|
|
53
|
+
denySubscribe(filterPattern) {
|
|
54
|
+
this.deniedFilters.push(filterPattern);
|
|
55
|
+
}
|
|
56
|
+
isDenied(filter) {
|
|
57
|
+
return this.deniedFilters.includes(filter);
|
|
58
|
+
}
|
|
59
|
+
/** Current retained payload for `topic`, if any — mirrors what a newly-subscribing client would receive. */
|
|
60
|
+
retainedOn(topic) {
|
|
61
|
+
return this.retained.get(topic)?.payload;
|
|
62
|
+
}
|
|
63
|
+
/** All messages ever routed to exactly `topic`, in publish order (test assertion helper). */
|
|
64
|
+
messagesOn(topic) {
|
|
65
|
+
return this.log.filter((m) => m.topic === topic);
|
|
66
|
+
}
|
|
67
|
+
/** Every logged message whose topic starts with `prefix` (test convenience). */
|
|
68
|
+
messagesUnder(prefix) {
|
|
69
|
+
return this.log.filter((m) => m.topic.startsWith(prefix));
|
|
70
|
+
}
|
|
71
|
+
/** Logs `msg`, updates the retained-message store (empty payload clears it), and delivers it to every connected client. */
|
|
72
|
+
route(msg) {
|
|
73
|
+
this.log.push(msg);
|
|
74
|
+
if (msg.retain) {
|
|
75
|
+
if (msg.payload.length === 0) this.retained.delete(msg.topic);
|
|
76
|
+
else this.retained.set(msg.topic, msg);
|
|
77
|
+
}
|
|
78
|
+
for (const c of this.clients) {
|
|
79
|
+
c.deliver(msg);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
/** Asynchronously (next tick) delivers every retained message matching `filter` to `to`, mimicking a real broker's SUBSCRIBE-time redelivery. */
|
|
83
|
+
deliverRetained(to, filter) {
|
|
84
|
+
for (const msg of this.retained.values()) {
|
|
85
|
+
if (topicFilterMatches(filter, msg.topic)) {
|
|
86
|
+
setImmediate(() => to.deliver(msg, filter));
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
/** Routes a client's LWT if the disconnect was ungraceful and a will was armed; a graceful `end()` never fires the will. */
|
|
91
|
+
disconnected(t, ungraceful) {
|
|
92
|
+
if (ungraceful && t.will) {
|
|
93
|
+
this.route({
|
|
94
|
+
topic: t.will.topic,
|
|
95
|
+
payload: Buffer.from(t.will.payload),
|
|
96
|
+
qos: t.will.qos,
|
|
97
|
+
retain: t.will.retain
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
/** Every live subscription across all clients — for lazy-subscribe and QoS assertions. */
|
|
102
|
+
subscriptions() {
|
|
103
|
+
return [...this.clients].flatMap((c) => c.subscriptions().map((s) => ({ clientId: c.clientId, ...s })));
|
|
104
|
+
}
|
|
105
|
+
};
|
|
106
|
+
var MemoryTransport = class {
|
|
107
|
+
constructor(broker) {
|
|
108
|
+
this.broker = broker;
|
|
109
|
+
}
|
|
110
|
+
broker;
|
|
111
|
+
will;
|
|
112
|
+
clientId = "";
|
|
113
|
+
subs = [];
|
|
114
|
+
messageCbs = [];
|
|
115
|
+
stateCbs = [];
|
|
116
|
+
connected = false;
|
|
117
|
+
reconnectTimer = null;
|
|
118
|
+
async connect(opts) {
|
|
119
|
+
this.will = opts.will;
|
|
120
|
+
this.clientId = opts.clientId;
|
|
121
|
+
this.connected = true;
|
|
122
|
+
this.emitState("connected");
|
|
123
|
+
}
|
|
124
|
+
async publish(topic, payload, opts) {
|
|
125
|
+
this.broker.route({
|
|
126
|
+
topic,
|
|
127
|
+
payload: Buffer.isBuffer(payload) ? payload : Buffer.from(payload),
|
|
128
|
+
qos: opts.qos,
|
|
129
|
+
retain: opts.retain
|
|
130
|
+
});
|
|
131
|
+
}
|
|
132
|
+
/** Subscribes (unless the broker has denied this filter) and triggers retained-message redelivery for it. */
|
|
133
|
+
async subscribe(filter, opts) {
|
|
134
|
+
if (this.broker.isDenied(filter)) return { granted: false };
|
|
135
|
+
if (!this.subs.some((s) => s.filter === filter && s.qos === opts.qos)) {
|
|
136
|
+
this.subs.push({ filter, qos: opts.qos });
|
|
137
|
+
}
|
|
138
|
+
this.broker.deliverRetained(this, filter);
|
|
139
|
+
return { granted: true };
|
|
140
|
+
}
|
|
141
|
+
async unsubscribe(filter) {
|
|
142
|
+
this.subs = this.subs.filter((s) => s.filter !== filter);
|
|
143
|
+
}
|
|
144
|
+
subscriptions() {
|
|
145
|
+
return [...this.subs];
|
|
146
|
+
}
|
|
147
|
+
onMessage(cb) {
|
|
148
|
+
this.messageCbs.push(cb);
|
|
149
|
+
}
|
|
150
|
+
onConnectionState(cb) {
|
|
151
|
+
this.stateCbs.push(cb);
|
|
152
|
+
}
|
|
153
|
+
/**
|
|
154
|
+
* Delivers `msg` to this client's message callbacks if it's currently connected and either
|
|
155
|
+
* `viaFilter` is given (a targeted retained redelivery, always delivered) or the topic matches
|
|
156
|
+
* one of this client's live subscriptions. Isolates each callback's exceptions so one bad
|
|
157
|
+
* handler can't break delivery to the others.
|
|
158
|
+
*/
|
|
159
|
+
deliver(msg, viaFilter) {
|
|
160
|
+
if (!this.connected) return;
|
|
161
|
+
const matched = viaFilter !== void 0 || this.subs.some((s) => topicFilterMatches(s.filter, msg.topic));
|
|
162
|
+
if (matched) {
|
|
163
|
+
for (const cb of this.messageCbs) {
|
|
164
|
+
try {
|
|
165
|
+
cb(msg);
|
|
166
|
+
} catch (err) {
|
|
167
|
+
console.error("[MemoryTransport] subscriber callback threw:", err);
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
/** Simulate ungraceful TCP loss: will fires, then auto-reconnect. */
|
|
173
|
+
dropConnection() {
|
|
174
|
+
this.connected = false;
|
|
175
|
+
if (this.reconnectTimer) clearImmediate(this.reconnectTimer);
|
|
176
|
+
this.emitState("reconnecting");
|
|
177
|
+
this.broker.disconnected(this, true);
|
|
178
|
+
this.reconnectTimer = setImmediate(() => {
|
|
179
|
+
this.reconnectTimer = null;
|
|
180
|
+
this.connected = true;
|
|
181
|
+
this.emitState("connected");
|
|
182
|
+
});
|
|
183
|
+
}
|
|
184
|
+
async end() {
|
|
185
|
+
if (this.reconnectTimer) clearImmediate(this.reconnectTimer);
|
|
186
|
+
this.connected = false;
|
|
187
|
+
this.broker.disconnected(this, false);
|
|
188
|
+
this.emitState("closed");
|
|
189
|
+
}
|
|
190
|
+
emitState(s) {
|
|
191
|
+
for (const cb of this.stateCbs) {
|
|
192
|
+
try {
|
|
193
|
+
cb(s);
|
|
194
|
+
} catch (err) {
|
|
195
|
+
console.error("[MemoryTransport] subscriber callback threw:", err);
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
};
|
|
200
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
201
|
+
0 && (module.exports = {
|
|
202
|
+
MemoryBroker,
|
|
203
|
+
MemoryTransport
|
|
204
|
+
});
|
|
205
|
+
//# sourceMappingURL=testing.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/testing/index.ts","../src/topics/topics.ts","../src/testing/memoryTransport.ts"],"sourcesContent":["/**\n * Copyright 2026 InOrbit, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nexport { MemoryBroker, MemoryTransport } from './memoryTransport.js';\n","/**\n * Copyright 2026 InOrbit, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { ROOT_NAMESPACE } from '../types/constants.js';\n\n/** Identifies an entity for topic-building purposes: its ISO type (\"IMR\"/\"IMRFM\") and its uuid. */\nexport interface EntityRef { entityType: string; entityUuid: string }\n\n/** Decomposed form of an ISO 21423 topic string, as produced by {@link parseTopic}. */\nexport interface ParsedTopic {\n entityType: string;\n entityUuid: string;\n resource: string;\n requestUuid?: string;\n isRequestStatus: boolean;\n}\n\nexport function topicFor(ref: EntityRef, resource: string): string {\n return `${ROOT_NAMESPACE}/${ref.entityType}/${ref.entityUuid}/${resource}`;\n}\n\nexport function requestTopic(ref: EntityRef, requestUuid: string): string {\n return `${topicFor(ref, 'request')}/${requestUuid}`;\n}\n\nexport function requestStatusTopic(ref: EntityRef, requestUuid: string): string {\n return `${requestTopic(ref, requestUuid)}/status`;\n}\n\nexport function disconnectionTopic(ref: EntityRef): string {\n return topicFor(ref, 'disconnection');\n}\n\n/** MQTT wildcard subscription matching every entity's identity topic, used to build the fleet-wide entity cache. */\nexport function identityWildcard(): string {\n return `${ROOT_NAMESPACE}/+/+/identity`;\n}\n\n/**\n * Splits a concrete topic string into its parts, or returns `null` if it doesn't\n * live under {@link ROOT_NAMESPACE} or has an unrecognized shape (e.g. extra path segments).\n */\nexport function parseTopic(topic: string): ParsedTopic | null {\n if (!topic.startsWith(`${ROOT_NAMESPACE}/`)) return null;\n const rest = topic.slice(ROOT_NAMESPACE.length + 1).split('/');\n const [entityType, entityUuid, resource, ...tail] = rest;\n if (!entityType || !entityUuid || !resource) return null;\n if (resource === 'request' && tail.length >= 1) {\n const [requestUuid, maybeStatus] = tail;\n if (!requestUuid || (maybeStatus !== undefined && maybeStatus !== 'status') || tail.length > 2) return null;\n return { entityType, entityUuid, resource, requestUuid, isRequestStatus: maybeStatus === 'status' };\n }\n if (tail.length > 0) return null;\n return { entityType, entityUuid, resource, isRequestStatus: false };\n}\n\n/** MQTT 3.1.1 topic filter matching (+ single level, # multi level). */\nexport function topicFilterMatches(filter: string, topic: string): boolean {\n const f = filter.split('/');\n const t = topic.split('/');\n for (let i = 0; i < f.length; i++) {\n const seg = f[i];\n if (seg === '#') return true;\n if (i >= t.length) return false;\n if (seg !== '+' && seg !== t[i]) return false;\n }\n return f.length === t.length;\n}\n","/**\n * Copyright 2026 InOrbit, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type {\n MqttTransport, TransportConnectOptions, TransportMessage, ConnectionState,\n} from '../session/transport.js';\nimport { topicFilterMatches } from '../topics/topics.js';\n\ninterface Sub { filter: string; qos: 0 | 1 | 2 }\n\n/**\n * In-process stand-in for an MQTT broker: routes published messages to matching subscribers,\n * stores retained messages, and can simulate a denied subscription or a dropped connection.\n * Pairs with {@link MemoryTransport} to test the SDK without a real broker.\n */\nexport class MemoryBroker {\n private clients = new Set<MemoryTransport>();\n private retained = new Map<string, TransportMessage>();\n private deniedFilters: string[] = [];\n private log: TransportMessage[] = [];\n\n createTransport(): MemoryTransport {\n const t = new MemoryTransport(this);\n this.clients.add(t);\n return t;\n }\n\n /** Makes future `subscribe()` calls for exactly this filter string report `granted: false`, for testing subscription-denied paths. */\n denySubscribe(filterPattern: string): void {\n this.deniedFilters.push(filterPattern);\n }\n\n isDenied(filter: string): boolean {\n // ponytail: exact-filter match only; make wildcard-aware if a test ever needs prefix denial\n return this.deniedFilters.includes(filter);\n }\n\n /** Current retained payload for `topic`, if any — mirrors what a newly-subscribing client would receive. */\n retainedOn(topic: string): Buffer | undefined {\n return this.retained.get(topic)?.payload;\n }\n\n /** All messages ever routed to exactly `topic`, in publish order (test assertion helper). */\n messagesOn(topic: string): TransportMessage[] {\n return this.log.filter((m) => m.topic === topic);\n }\n\n /** Every logged message whose topic starts with `prefix` (test convenience). */\n messagesUnder(prefix: string): TransportMessage[] {\n return this.log.filter((m) => m.topic.startsWith(prefix));\n }\n\n /** Logs `msg`, updates the retained-message store (empty payload clears it), and delivers it to every connected client. */\n route(msg: TransportMessage): void {\n this.log.push(msg);\n if (msg.retain) {\n if (msg.payload.length === 0) this.retained.delete(msg.topic);\n else this.retained.set(msg.topic, msg);\n }\n for (const c of this.clients) {\n c.deliver(msg); // deliver() isolates callback exceptions internally, never throws\n }\n }\n\n /** Asynchronously (next tick) delivers every retained message matching `filter` to `to`, mimicking a real broker's SUBSCRIBE-time redelivery. */\n deliverRetained(to: MemoryTransport, filter: string): void {\n for (const msg of this.retained.values()) {\n if (topicFilterMatches(filter, msg.topic)) {\n setImmediate(() => to.deliver(msg, filter));\n }\n }\n }\n\n /** Routes a client's LWT if the disconnect was ungraceful and a will was armed; a graceful `end()` never fires the will. */\n disconnected(t: MemoryTransport, ungraceful: boolean): void {\n if (ungraceful && t.will) {\n this.route({\n topic: t.will.topic,\n payload: Buffer.from(t.will.payload),\n qos: t.will.qos,\n retain: t.will.retain,\n });\n }\n }\n\n /** Every live subscription across all clients — for lazy-subscribe and QoS assertions. */\n subscriptions(): Array<{ clientId: string; filter: string; qos: 0 | 1 | 2 }> {\n return [...this.clients].flatMap((c) =>\n c.subscriptions().map((s) => ({ clientId: c.clientId, ...s })));\n }\n}\n\n/** {@link MqttTransport} implementation backed by a {@link MemoryBroker}, for broker-free tests. */\nexport class MemoryTransport implements MqttTransport {\n will: TransportConnectOptions['will'];\n clientId = '';\n private subs: Sub[] = [];\n private messageCbs: Array<(m: TransportMessage) => void> = [];\n private stateCbs: Array<(s: ConnectionState) => void> = [];\n private connected = false;\n private reconnectTimer: NodeJS.Immediate | null = null;\n\n constructor(private readonly broker: MemoryBroker) {}\n\n async connect(opts: TransportConnectOptions): Promise<void> {\n this.will = opts.will;\n this.clientId = opts.clientId;\n this.connected = true;\n this.emitState('connected');\n }\n\n async publish(topic: string, payload: string | Buffer, opts: { qos: 0 | 1 | 2; retain: boolean }): Promise<void> {\n this.broker.route({\n topic,\n payload: Buffer.isBuffer(payload) ? payload : Buffer.from(payload),\n qos: opts.qos,\n retain: opts.retain,\n });\n }\n\n /** Subscribes (unless the broker has denied this filter) and triggers retained-message redelivery for it. */\n async subscribe(filter: string, opts: { qos: 0 | 1 | 2 }): Promise<{ granted: boolean }> {\n if (this.broker.isDenied(filter)) return { granted: false };\n // Re-subscribing the same (filter, qos) pair replaces the entry, as on a real broker.\n if (!this.subs.some((s) => s.filter === filter && s.qos === opts.qos)) {\n this.subs.push({ filter, qos: opts.qos });\n }\n this.broker.deliverRetained(this, filter);\n return { granted: true };\n }\n\n async unsubscribe(filter: string): Promise<void> {\n this.subs = this.subs.filter((s) => s.filter !== filter);\n }\n\n subscriptions(): ReadonlyArray<{ filter: string; qos: 0 | 1 | 2 }> {\n return [...this.subs];\n }\n\n onMessage(cb: (m: TransportMessage) => void): void {\n this.messageCbs.push(cb);\n }\n\n onConnectionState(cb: (s: ConnectionState) => void): void {\n this.stateCbs.push(cb);\n }\n\n /**\n * Delivers `msg` to this client's message callbacks if it's currently connected and either\n * `viaFilter` is given (a targeted retained redelivery, always delivered) or the topic matches\n * one of this client's live subscriptions. Isolates each callback's exceptions so one bad\n * handler can't break delivery to the others.\n */\n deliver(msg: TransportMessage, viaFilter?: string): void {\n if (!this.connected) return;\n const matched = viaFilter !== undefined\n || this.subs.some((s) => topicFilterMatches(s.filter, msg.topic));\n if (matched) {\n for (const cb of this.messageCbs) {\n try {\n cb(msg);\n } catch (err) {\n console.error('[MemoryTransport] subscriber callback threw:', err);\n }\n }\n }\n }\n\n /** Simulate ungraceful TCP loss: will fires, then auto-reconnect. */\n dropConnection(): void {\n this.connected = false;\n if (this.reconnectTimer) clearImmediate(this.reconnectTimer);\n this.emitState('reconnecting');\n this.broker.disconnected(this, true);\n this.reconnectTimer = setImmediate(() => {\n this.reconnectTimer = null;\n this.connected = true;\n this.emitState('connected');\n });\n }\n\n async end(): Promise<void> {\n if (this.reconnectTimer) clearImmediate(this.reconnectTimer);\n this.connected = false;\n this.broker.disconnected(this, false);\n this.emitState('closed');\n }\n\n private emitState(s: ConnectionState): void {\n for (const cb of this.stateCbs) {\n try {\n cb(s);\n } catch (err) {\n console.error('[MemoryTransport] subscriber callback threw:', err);\n }\n }\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACsEO,SAAS,mBAAmB,QAAgB,OAAwB;AACzE,QAAM,IAAI,OAAO,MAAM,GAAG;AAC1B,QAAM,IAAI,MAAM,MAAM,GAAG;AACzB,WAAS,IAAI,GAAG,IAAI,EAAE,QAAQ,KAAK;AACjC,UAAM,MAAM,EAAE,CAAC;AACf,QAAI,QAAQ,IAAK,QAAO;AACxB,QAAI,KAAK,EAAE,OAAQ,QAAO;AAC1B,QAAI,QAAQ,OAAO,QAAQ,EAAE,CAAC,EAAG,QAAO;AAAA,EAC1C;AACA,SAAO,EAAE,WAAW,EAAE;AACxB;;;ACpDO,IAAM,eAAN,MAAmB;AAAA,EAChB,UAAU,oBAAI,IAAqB;AAAA,EACnC,WAAW,oBAAI,IAA8B;AAAA,EAC7C,gBAA0B,CAAC;AAAA,EAC3B,MAA0B,CAAC;AAAA,EAEnC,kBAAmC;AACjC,UAAM,IAAI,IAAI,gBAAgB,IAAI;AAClC,SAAK,QAAQ,IAAI,CAAC;AAClB,WAAO;AAAA,EACT;AAAA;AAAA,EAGA,cAAc,eAA6B;AACzC,SAAK,cAAc,KAAK,aAAa;AAAA,EACvC;AAAA,EAEA,SAAS,QAAyB;AAEhC,WAAO,KAAK,cAAc,SAAS,MAAM;AAAA,EAC3C;AAAA;AAAA,EAGA,WAAW,OAAmC;AAC5C,WAAO,KAAK,SAAS,IAAI,KAAK,GAAG;AAAA,EACnC;AAAA;AAAA,EAGA,WAAW,OAAmC;AAC5C,WAAO,KAAK,IAAI,OAAO,CAAC,MAAM,EAAE,UAAU,KAAK;AA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