@wandelbots/nova-js 4.4.0 → 4.5.0-pr.321.4edffe1

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.
@@ -1,4 +1,5 @@
1
1
  import { t as Nova } from "../../Nova-DdbUm145.mjs";
2
+ import { JsMsg } from "@nats-io/jetstream";
2
3
  import { ConnectionOptions, Msg, NatsConnection } from "@nats-io/nats-core";
3
4
  //#region src/lib/experimental/nats/buildNatsServerUrl.d.ts
4
5
  /**
@@ -2858,6 +2859,23 @@ interface NatsSubscribePayloads {
2858
2859
  "nova.v2.events.cells.{cell}.controllers.{controller}.deleted": RobotControllerDeletedEvent;
2859
2860
  }
2860
2861
  type NatsSubscribeSubject = keyof NatsSubscribePayloads;
2862
+ /**
2863
+ * The JetStream stream backing each subject that retains only its latest
2864
+ * message (`max_msgs_per_subject: 1` in src/asyncapi.yaml), so that
2865
+ * message is the subject's current state.
2866
+ */
2867
+ declare const natsStreamBySubject: {
2868
+ readonly "nova.v2.cells.{cell}": "system-state";
2869
+ readonly "nova.v2.cells.{cell}.apps.{app}": "system-state";
2870
+ readonly "nova.v2.cells.{cell}.controllers.{controller}": "system-state";
2871
+ readonly "nova.v2.cells.{cell}.status": "system-state";
2872
+ readonly "nova.v2.system.status": "system-state";
2873
+ readonly "nova.v2.cells.{cell}.collision.setups.{setup}": "system-state";
2874
+ readonly "nova.v2.cells.{cell}.bus-ios.status": "system-state";
2875
+ readonly "nova.v2.cells.{cell}.controllers.{controller}.motion-groups.{motion-group}.description": "system-state";
2876
+ };
2877
+ /** Subjects whose current value can be replayed via `{ replayLast: true }`. */
2878
+ type NatsPersistedSubject = keyof typeof natsStreamBySubject;
2861
2879
  /** Request payload types for subjects the client sends requests to. */
2862
2880
  interface NatsRequestPayloads {
2863
2881
  /**
@@ -3180,11 +3198,27 @@ type NovaNatsClientConfig = ConnectionOptions;
3180
3198
  * a handler knows which entity a message belongs to. Typed per subject via
3181
3199
  * the generated `NatsOperationParams`.
3182
3200
  */
3183
- type NatsSubscribeMsg<K extends NatsSubscribeSubject> = Msg & {
3201
+ type NatsSubscribeMsg<K extends NatsSubscribeSubject> = (Msg | JsMsg) & {
3184
3202
  subjectParams: NatsOperationParams[K];
3185
3203
  };
3186
3204
  type NatsMessageHandler<K extends NatsSubscribeSubject> = (payload: NatsSubscribePayloads[K], msg: NatsSubscribeMsg<K>) => void | Promise<void>;
3187
- type SubscribeArgs<K extends NatsSubscribeSubject> = keyof NatsOperationParams[K] extends never ? [handler: NatsMessageHandler<K>] : [params: NatsOperationParams[K], handler: NatsMessageHandler<K>];
3205
+ /**
3206
+ * Extra options for {@link NovaNatsClient.subscribe}. `replayLast` is only
3207
+ * offered on subjects the spec marks as retaining their latest message, so
3208
+ * asking for a replay that could never arrive is a compile error.
3209
+ */
3210
+ type NatsSubscribeOptions<K extends NatsSubscribeSubject> = K extends NatsPersistedSubject ? {
3211
+ /**
3212
+ * Deliver the subject's current value immediately on subscribe,
3213
+ * before any subsequent updates. With a wildcard subscription (e.g.
3214
+ * `{ cell: "*" }`) the current value of every matching subject is
3215
+ * delivered, not just one.
3216
+ */
3217
+ replayLast?: boolean;
3218
+ } : {
3219
+ replayLast?: never;
3220
+ };
3221
+ type SubscribeArgs<K extends NatsSubscribeSubject> = keyof NatsOperationParams[K] extends never ? [handler: NatsMessageHandler<K>, opts?: NatsSubscribeOptions<K>] : [params: NatsOperationParams[K], handler: NatsMessageHandler<K>, opts?: NatsSubscribeOptions<K>];
3188
3222
  /**
3189
3223
  * Typed NATS client for the Wandelbots NOVA messaging API, generated from
3190
3224
  * src/asyncapi.yaml (see scripts/generate-nats-client.ts).
@@ -3222,6 +3256,12 @@ declare class NovaNatsClient {
3222
3256
  * nats.subscribe("nova.v2.cells.{cell}.status", { cell: "*" },
3223
3257
  * (services, msg) => console.log(msg.subjectParams.cell, services))
3224
3258
  *
3259
+ * On subjects that retain their latest message, pass `{ replayLast: true }`
3260
+ * to receive the current value immediately instead of waiting for the next
3261
+ * update — useful for a subscriber that starts after the last change:
3262
+ *
3263
+ * nats.subscribe("nova.v2.system.status", onStatus, { replayLast: true })
3264
+ *
3225
3265
  * Returns a function that unsubscribes when called.
3226
3266
  */
3227
3267
  subscribe<K extends NatsSubscribeSubject>(subject: K, ...args: SubscribeArgs<K>): Promise<() => void>;
@@ -3247,5 +3287,5 @@ declare class NovaNatsClient {
3247
3287
  publish<K extends NatsPublishSubject>(subject: K, params: NatsOperationParams[K], payload: NatsPublishPayloads[K]): Promise<void>;
3248
3288
  }
3249
3289
  //#endregion
3250
- export { type AbbController, type AddVirtualControllerMotionGroupRequest, type App, type AppCreatedEvent, type AppDeletedEvent, type AppEventData, type AppUpdatedEvent, type Box, type BusIOsState, type BusIOsStateEnum, type Capacity, type Capsule, type CartesianLimits, type Cell, type CellCreatedEvent, type CellCycleEvent, type CellDeletedEvent, type CellDescription, type CellEventData, type CellName, type CellUpdatedEvent, type CloudEvent, type Collider, type ColliderDictionary, type ColliderDictionary1, type ColliderDictionary2, type CollisionMotionGroupLink, type CollisionMotionGroupTool, type CollisionMotionGroupTool1, type CollisionSetup, type ContainerEnvironment, type ContainerImage, type ContainerResources, type ContainerStorage, type ControllerNetworkInterface, type ConvexHull, type Cylinder, type DHParameter, type Execute, type Execute1, type FanucController, type IOBooleanValue, type IOFloatValue, type IOIntegerValue, type IOValue, type ImageCredentials, type JoggingDetails, type JoggingPausedByUser, type JoggingPausedNearCollision, type JoggingPausedNearJointLimit, type JoggingPausedNearSingularity, type JoggingPausedOnIO, type JoggingRunning, type JointLimits, type JointTypeEnum, type Joints, type Joints1, type Joints2, type Joints3, type KukaController, type LimitRange, type LimitSet, type LinkChain, type LinkChain1, type ListIOValuesResponse, type Location, type Manufacturer, type MotionGroupDescription, type MotionGroupFromJSON, type MotionGroupFromModel, type MotionGroupModel, type MotionGroupState, type MotionGroupState1, type MotionGroupState_JointLimitReached, type MotionGroupState_JointLimitReached1, type NatsErrorPayload, type NatsOperationParams, type NatsPublishPayloads, type NatsPublishSubject, type NatsReplyPayloads, type NatsRequestPayloads, type NatsRequestSubject, type NatsSubscribeMsg, type NatsSubscribePayloads, type NatsSubscribeSubject, type NetworkState, type NetworkStatusChangedEvent, NovaNatsClient, type NovaNatsClientConfig, type OperatingState, type OperationLimits, type OperationMode, type Payload, type PayloadDictionary, type Plane, type Pose, type Pose1, type Pose2, type Pose3, type Pose4, type Pose5, type ProgramRunState, type ProgramRunState1, type ProgramStatus, type Rectangle, type RectangularCapsule, type RobotController, type RobotControllerCreatedEvent, type RobotControllerDeletedEvent, type RobotControllerEventData, type RobotControllerState, type RobotControllerUpdatedEvent, type RobotSystemMode, type RotationVector, type SafetyStateType, type SafetyToolColliders, type SelectIOs, type ServiceGroup, type ServiceStatus, type ServiceStatusList, type ServiceStatusPhase, type ServiceStatusSeverity, type Sphere, type StreamIOValuesResponse, type SystemUpdateCompletedEvent, type SystemUpdateStartedEvent, type TcpOffset, type TcpOffsetDictionary, type TrajectoryDetails, type TrajectoryEnded, type TrajectoryPausedByUser, type TrajectoryPausedOnIO, type TrajectoryRunning, type TrajectoryWaitForIO, type UniversalrobotsController, type Vector3D, type Vector3D1, type Vector3D2, type VirtualController, type YaskawaController, buildNatsServerUrl };
3290
+ export { type AbbController, type AddVirtualControllerMotionGroupRequest, type App, type AppCreatedEvent, type AppDeletedEvent, type AppEventData, type AppUpdatedEvent, type Box, type BusIOsState, type BusIOsStateEnum, type Capacity, type Capsule, type CartesianLimits, type Cell, type CellCreatedEvent, type CellCycleEvent, type CellDeletedEvent, type CellDescription, type CellEventData, type CellName, type CellUpdatedEvent, type CloudEvent, type Collider, type ColliderDictionary, type ColliderDictionary1, type ColliderDictionary2, type CollisionMotionGroupLink, type CollisionMotionGroupTool, type CollisionMotionGroupTool1, type CollisionSetup, type ContainerEnvironment, type ContainerImage, type ContainerResources, type ContainerStorage, type ControllerNetworkInterface, type ConvexHull, type Cylinder, type DHParameter, type Execute, type Execute1, type FanucController, type IOBooleanValue, type IOFloatValue, type IOIntegerValue, type IOValue, type ImageCredentials, type JoggingDetails, type JoggingPausedByUser, type JoggingPausedNearCollision, type JoggingPausedNearJointLimit, type JoggingPausedNearSingularity, type JoggingPausedOnIO, type JoggingRunning, type JointLimits, type JointTypeEnum, type Joints, type Joints1, type Joints2, type Joints3, type KukaController, type LimitRange, type LimitSet, type LinkChain, type LinkChain1, type ListIOValuesResponse, type Location, type Manufacturer, type MotionGroupDescription, type MotionGroupFromJSON, type MotionGroupFromModel, type MotionGroupModel, type MotionGroupState, type MotionGroupState1, type MotionGroupState_JointLimitReached, type MotionGroupState_JointLimitReached1, type NatsErrorPayload, type NatsOperationParams, type NatsPersistedSubject, type NatsPublishPayloads, type NatsPublishSubject, type NatsReplyPayloads, type NatsRequestPayloads, type NatsRequestSubject, type NatsSubscribeMsg, type NatsSubscribeOptions, type NatsSubscribePayloads, type NatsSubscribeSubject, type NetworkState, type NetworkStatusChangedEvent, NovaNatsClient, type NovaNatsClientConfig, type OperatingState, type OperationLimits, type OperationMode, type Payload, type PayloadDictionary, type Plane, type Pose, type Pose1, type Pose2, type Pose3, type Pose4, type Pose5, type ProgramRunState, type ProgramRunState1, type ProgramStatus, type Rectangle, type RectangularCapsule, type RobotController, type RobotControllerCreatedEvent, type RobotControllerDeletedEvent, type RobotControllerEventData, type RobotControllerState, type RobotControllerUpdatedEvent, type RobotSystemMode, type RotationVector, type SafetyStateType, type SafetyToolColliders, type SelectIOs, type ServiceGroup, type ServiceStatus, type ServiceStatusList, type ServiceStatusPhase, type ServiceStatusSeverity, type Sphere, type StreamIOValuesResponse, type SystemUpdateCompletedEvent, type SystemUpdateStartedEvent, type TcpOffset, type TcpOffsetDictionary, type TrajectoryDetails, type TrajectoryEnded, type TrajectoryPausedByUser, type TrajectoryPausedOnIO, type TrajectoryRunning, type TrajectoryWaitForIO, type UniversalrobotsController, type Vector3D, type Vector3D1, type Vector3D2, type VirtualController, type YaskawaController, buildNatsServerUrl, natsStreamBySubject };
3251
3291
  //# sourceMappingURL=index.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.mts","names":[],"sources":["../../../src/lib/experimental/nats/buildNatsServerUrl.ts","../../../src/lib/experimental/nats/generated/types.ts","../../../src/lib/experimental/nats/generated/operations.ts","../../../src/lib/experimental/nats/NovaNatsClient.ts"],"mappings":";;;;;;;;;;;iBAUgB,mBAAmB;;;;;;;;;;;;;;;;KCIvB;;;;;;;;KAQA;;;;;KAKA;;;;;;;;;KAeA;;;;;;;;;;;KAWA,yCACR,uBACA;;;;;;;;;KASQ;EACV;EACA;;;;;;;;KAQU;;;;;;;KAOA;;;;KASA;;;;;KAUA;;;;;KASA;;;;;KAKA;;;;;KAmBA,oBAAoB;;;;;;;;;;;KAWpB;;;;;;;;;;;;;;KAcA;;;;;;;;;;;;;;;;;;;KAmBA,YAAY;;;;;;;KAOZ,aAAa;;;;;;;;KAQb;;;;;KASA,UAAU,iBAAiB,iBAAiB;;;;;;;KAO5C,uBAAuB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KA4CvB;;;;;;;;;;;;;;KAmBA;;;;;;;;;;;;KAsBA;;;;;;;;;;KA0BA;;;;;;;;;;;;KAYA;;;;;;KAMA;;;;;;KAMA;;;;;;KAMA;;;;;;;KAOA,oBAAoB;;;;;;;;KAQpB;;;;;;;;KAQA;;;;;KAKA;;;;;KAKA,2BAA2B;EACrC;EACA;;;;EAIA;KACG;;;;;EAKH;KACG;;;;;EAKH;;;;IAIE;;;;IAIA;;;;;;;KAOQ,6BAA6B;EACvC;EACA;;;;EAIA;KACG;;;;;EAKH;KACG;;;;;EAKH;;;;IAIE;;;;IAIA;;;;;;;;;KASQ;;;;;KAKA;EACV;EACA;;;;EAIA;KACG;;;;;EAKH;KACG;;EAEH,MAAM;IACJ;;;;;KAKQ;EACV;EACA;;;;EAIA;KACG;;;;;EAKH;KACG;;EAEH,MAAM;IACJ;;;;;KAKQ;EACV;EACA;;;;EAIA;KACG;;;;;EAKH;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;EAUhE,gEAAgE;;;;;;;;;;EAUhE,gEAAgE;;KAGtD,2BAA2B;;;KCrgC3B,uBAAuB;;;;;;;;KASvB,iBAAiB,UAAU,wBAAwB;EAC7D,eAAe,oBAAoB;;KAGhC,mBAAmB,UAAU,yBAChC,SAAS,sBAAsB,IAC/B,KAAK,iBAAiB,cACZ;KAEP,cAAc,UAAU,8BACrB,oBAAoB,oBACrB,SAAS,mBAAmB,OAC5B,QAAQ,oBAAoB,IAAI,SAAS,mBAAmB;;;;;;;cAQtD;WACF,QAAQ;UACT;EAEI,YAAA,MAAM,MAAM,SAAQ;;;;;;EAgBhC,WAAW,QAAQ;;EAYb,SAAS;;;;;;;;;;;;;;;;;;;;;;EAiCT,UAAU,UAAU,sBACxB,SAAS,MACN,MAAM,cAAc,KACtB;;;;;;;;;EA8DG,QAAQ,UAAU,oBACtB,SAAS,GACT,QAAQ,oBAAoB,IAC5B,SAAS,oBAAoB,IAC7B;IAAQ;MACP,QAAQ,kBAAkB;;;;;;;;;EAiBvB,QAAQ,UAAU,oBACtB,SAAS,GACT,QAAQ,oBAAoB,IAC5B,SAAS,oBAAoB,KAC5B"}
1
+ {"version":3,"file":"index.d.mts","names":[],"sources":["../../../src/lib/experimental/nats/buildNatsServerUrl.ts","../../../src/lib/experimental/nats/generated/types.ts","../../../src/lib/experimental/nats/generated/operations.ts","../../../src/lib/experimental/nats/NovaNatsClient.ts"],"mappings":";;;;;;;;;;;;iBAUgB,mBAAmB;;;;;;;;;;;;;;;;KCIvB;;;;;;;;KAQA;;;;;KAKA;;;;;;;;;KAeA;;;;;;;;;;;KAWA,yCACR,uBACA;;;;;;;;;KASQ;EACV;EACA;;;;;;;;KAQU;;;;;;;KAOA;;;;KASA;;;;;KAUA;;;;;KASA;;;;;KAKA;;;;;KAmBA,oBAAoB;;;;;;;;;;;KAWpB;;;;;;;;;;;;;;KAcA;;;;;;;;;;;;;;;;;;;KAmBA,YAAY;;;;;;;KAOZ,aAAa;;;;;;;;KAQb;;;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Yb,SAAS;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAuCT,UAAU,UAAU,sBACxB,SAAS,MACN,MAAM,cAAc,KACtB;;;;;;;;;EA8FG,QAAQ,UAAU,oBACtB,SAAS,GACT,QAAQ,oBAAoB,IAC5B,SAAS,oBAAoB,IAC7B;IAAQ;MACP,QAAQ,kBAAkB;;;;;;;;;EAiBvB,QAAQ,UAAU,oBACtB,SAAS,GACT,QAAQ,oBAAoB,IAC5B,SAAS,oBAAoB,KAC5B"}
@@ -1,4 +1,5 @@
1
1
  import { a as parseNovaInstanceUrl } from "../../converters-DnG1fX23.mjs";
2
+ import { DeliverPolicy, jetstream } from "@nats-io/jetstream";
2
3
  import { wsconnect } from "@nats-io/nats-core";
3
4
  //#region src/lib/experimental/nats/buildNatsServerUrl.ts
4
5
  /**
@@ -14,6 +15,23 @@ function buildNatsServerUrl(instanceUrl) {
14
15
  return `${url.protocol === "https:" ? "wss:" : "ws:"}//${url.host}/api/nats`;
15
16
  }
16
17
  //#endregion
18
+ //#region src/lib/experimental/nats/generated/operations.ts
19
+ /**
20
+ * The JetStream stream backing each subject that retains only its latest
21
+ * message (`max_msgs_per_subject: 1` in src/asyncapi.yaml), so that
22
+ * message is the subject's current state.
23
+ */
24
+ const natsStreamBySubject = {
25
+ "nova.v2.cells.{cell}": "system-state",
26
+ "nova.v2.cells.{cell}.apps.{app}": "system-state",
27
+ "nova.v2.cells.{cell}.controllers.{controller}": "system-state",
28
+ "nova.v2.cells.{cell}.status": "system-state",
29
+ "nova.v2.system.status": "system-state",
30
+ "nova.v2.cells.{cell}.collision.setups.{setup}": "system-state",
31
+ "nova.v2.cells.{cell}.bus-ios.status": "system-state",
32
+ "nova.v2.cells.{cell}.controllers.{controller}.motion-groups.{motion-group}.description": "system-state"
33
+ };
34
+ //#endregion
17
35
  //#region src/lib/experimental/nats/buildSubject.ts
18
36
  /**
19
37
  * Builds a NATS subject from an AsyncAPI-style channel address template
@@ -112,26 +130,51 @@ var NovaNatsClient = class {
112
130
  * nats.subscribe("nova.v2.cells.{cell}.status", { cell: "*" },
113
131
  * (services, msg) => console.log(msg.subjectParams.cell, services))
114
132
  *
133
+ * On subjects that retain their latest message, pass `{ replayLast: true }`
134
+ * to receive the current value immediately instead of waiting for the next
135
+ * update — useful for a subscriber that starts after the last change:
136
+ *
137
+ * nats.subscribe("nova.v2.system.status", onStatus, { replayLast: true })
138
+ *
115
139
  * Returns a function that unsubscribes when called.
116
140
  */
117
141
  async subscribe(subject, ...args) {
118
- const [params, handler] = args.length === 1 ? [{}, args[0]] : [args[0], args[1]];
142
+ const hasParams = typeof args[0] !== "function";
143
+ const params = hasParams ? args[0] : {};
144
+ const handler = hasParams ? args[1] : args[0];
145
+ const opts = hasParams ? args[2] : args[1];
119
146
  const nc = await this.connect();
120
147
  const resolvedSubject = buildSubject(subject, params);
121
- const sub = nc.subscribe(resolvedSubject);
122
148
  const paramPositions = [];
123
149
  for (const [index, token] of subject.split(".").entries()) if (token.startsWith("{") && token.endsWith("}")) paramPositions.push([token.slice(1, -1), index]);
124
- (async () => {
125
- for await (const msg of sub) try {
150
+ const deliver = async (msg) => {
151
+ try {
126
152
  const subjectTokens = msg.subject.split(".");
127
153
  const subjectParams = Object.fromEntries(paramPositions.map(([name, index]) => [name, subjectTokens[index] ?? ""]));
128
154
  await handler(msg.json(), Object.assign(msg, { subjectParams }));
129
155
  } catch (err) {
130
156
  console.error(`Error handling NATS message on subject "${resolvedSubject}"`, err);
131
157
  }
132
- })().catch((err) => {
133
- console.error(`NATS subscription iterator failed for "${resolvedSubject}"`, err);
134
- });
158
+ };
159
+ const deliverAll = (messages) => {
160
+ (async () => {
161
+ for await (const msg of messages) await deliver(msg);
162
+ })().catch((err) => {
163
+ console.error(`NATS subscription iterator failed for "${resolvedSubject}"`, err);
164
+ });
165
+ };
166
+ if (opts?.replayLast) {
167
+ const messages = await (await jetstream(nc).consumers.get(natsStreamBySubject[subject], {
168
+ filter_subjects: [resolvedSubject],
169
+ deliver_policy: DeliverPolicy.LastPerSubject
170
+ })).consume();
171
+ deliverAll(messages);
172
+ return () => {
173
+ messages.stop();
174
+ };
175
+ }
176
+ const sub = nc.subscribe(resolvedSubject);
177
+ deliverAll(sub);
135
178
  return () => sub.unsubscribe();
136
179
  }
137
180
  /**
@@ -162,6 +205,6 @@ var NovaNatsClient = class {
162
205
  }
163
206
  };
164
207
  //#endregion
165
- export { NovaNatsClient, buildNatsServerUrl };
208
+ export { NovaNatsClient, buildNatsServerUrl, natsStreamBySubject };
166
209
 
167
210
  //# sourceMappingURL=index.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","names":[],"sources":["../../../src/lib/experimental/nats/buildNatsServerUrl.ts","../../../src/lib/experimental/nats/buildSubject.ts","../../../src/lib/experimental/nats/NovaNatsClient.ts"],"sourcesContent":["import { parseNovaInstanceUrl } from \"../../converters.ts\"\n\n/**\n * Builds the WebSocket URL for a NOVA instance's NATS gateway from its\n * instance URL, e.g. `https://foo.instance.wandelbots.io` becomes\n * `wss://foo.instance.wandelbots.io/api/nats`.\n *\n * Pass the result as `servers` in the `NovaNatsClientConfig` passed to\n * `NovaNatsClient`.\n */\nexport function buildNatsServerUrl(instanceUrl: string): string {\n const url = parseNovaInstanceUrl(instanceUrl)\n const protocol = url.protocol === \"https:\" ? \"wss:\" : \"ws:\"\n return `${protocol}//${url.host}/api/nats`\n}\n","/**\n * Builds a NATS subject from an AsyncAPI-style channel address template\n * (e.g. `\"{instance}.v2.cells.{cell}\"`) by substituting each `{param}`\n * placeholder with the corresponding value from `params`.\n */\n\nfunction isValidSubjectChar(char: string): boolean {\n const code = char.charCodeAt(0)\n return (\n (code >= 48 && code <= 57) || // 0-9\n (code >= 65 && code <= 90) || // A-Z\n (code >= 97 && code <= 122) || // a-z\n char === \"-\" ||\n char === \"_\"\n )\n}\n\nfunction isValidSubjectValue(value: string): boolean {\n // A bare \"*\" is the NATS single-token wildcard, allowed on its own (e.g.\n // subscribing to all cells with `{ cell: \"*\" }\") but not as part of a\n // larger value, since it wouldn't act as a wildcard there anyway.\n if (value === \"*\") return true\n if (value.length === 0) return false\n for (const char of value) {\n if (!isValidSubjectChar(char)) return false\n }\n return true\n}\n\nexport function buildSubject(\n template: string,\n params: Record<string, string>,\n): string {\n // Scanned manually (rather than with a regex like /\\{([^}]+)\\}/g) to avoid\n // a polynomial-time backtracking blowup on pathological input, e.g. a\n // template consisting of many \"{\" characters with no closing \"}\".\n let result = \"\"\n let cursor = 0\n\n while (cursor < template.length) {\n const openIndex = template.indexOf(\"{\", cursor)\n if (openIndex === -1) {\n result += template.slice(cursor)\n break\n }\n\n const closeIndex = template.indexOf(\"}\", openIndex + 1)\n if (closeIndex === -1) {\n result += template.slice(cursor)\n break\n }\n\n result += template.slice(cursor, openIndex)\n const paramName = template.slice(openIndex + 1, closeIndex)\n const value = params[paramName]\n if (value === undefined) {\n throw new Error(\n `Missing value for subject parameter \"${paramName}\" in template \"${template}\"`,\n )\n }\n if (!isValidSubjectValue(value)) {\n throw new Error(\n `Invalid value for subject parameter \"${paramName}\": \"${value}\" (must be non-empty and contain only letters, digits, \"-\", and \"_\")`,\n )\n }\n result += value\n\n cursor = closeIndex + 1\n }\n\n return result\n}\n","import {\n type ConnectionOptions,\n type Msg,\n type NatsConnection,\n wsconnect,\n} from \"@nats-io/nats-core\"\nimport type { Nova } from \"../../Nova.ts\"\nimport { buildNatsServerUrl } from \"./buildNatsServerUrl.ts\"\nimport { buildSubject } from \"./buildSubject.ts\"\nimport type {\n NatsOperationParams,\n NatsPublishPayloads,\n NatsPublishSubject,\n NatsReplyPayloads,\n NatsRequestPayloads,\n NatsRequestSubject,\n NatsSubscribePayloads,\n NatsSubscribeSubject,\n} from \"./generated/operations.ts\"\n\nexport type NovaNatsClientConfig = ConnectionOptions\n\n/**\n * A received message, annotated with the values of the subject template's\n * `{param}` placeholders as extracted from the message's concrete subject.\n * With a wildcard subscription (e.g. `{ cell: \"*\" }`), `subjectParams` is how\n * a handler knows which entity a message belongs to. Typed per subject via\n * the generated `NatsOperationParams`.\n */\nexport type NatsSubscribeMsg<K extends NatsSubscribeSubject> = Msg & {\n subjectParams: NatsOperationParams[K]\n}\n\ntype NatsMessageHandler<K extends NatsSubscribeSubject> = (\n payload: NatsSubscribePayloads[K],\n msg: NatsSubscribeMsg<K>,\n) => void | Promise<void>\n\ntype SubscribeArgs<K extends NatsSubscribeSubject> =\n keyof NatsOperationParams[K] extends never\n ? [handler: NatsMessageHandler<K>]\n : [params: NatsOperationParams[K], handler: NatsMessageHandler<K>]\n\n/**\n * Typed NATS client for the Wandelbots NOVA messaging API, generated from\n * src/asyncapi.yaml (see scripts/generate-nats-client.ts).\n *\n * Connects over WebSocket via `@nats-io/nats-core`'s `wsconnect`.\n */\nexport class NovaNatsClient {\n readonly config: NovaNatsClientConfig\n private connectionPromise: Promise<NatsConnection> | null = null\n\n constructor(nova: Nova, config: NovaNatsClientConfig = {}) {\n this.config = {\n servers: buildNatsServerUrl(nova.instanceUrl.href),\n // Reuse the Nova instance's access token for NATS auth, if it has one\n // (e.g. from login or a passed-in config.accessToken). Explicit auth\n // options in `config` (token/user/pass/authenticator) still win.\n ...(nova.accessToken ? { token: nova.accessToken } : {}),\n ...config,\n }\n }\n\n /**\n * Connects to NATS if not already connected or connecting, and returns the\n * connection. Safe to call concurrently: all callers share the same\n * in-flight connection attempt instead of each starting their own.\n */\n connect(): Promise<NatsConnection> {\n if (!this.connectionPromise) {\n this.connectionPromise = wsconnect(this.config).catch((err: unknown) => {\n // Allow a subsequent connect() call to retry after a failed attempt.\n this.connectionPromise = null\n throw err\n })\n }\n return this.connectionPromise\n }\n\n /** Closes the underlying NATS connection, if open or connecting. */\n async close(): Promise<void> {\n const connectionPromise = this.connectionPromise\n this.connectionPromise = null\n if (!connectionPromise) return\n try {\n const nc = await connectionPromise\n await nc.close()\n } catch {\n // Connection never succeeded; nothing to close.\n }\n }\n\n /**\n * Subscribes to a NATS subject published by the server, invoking `handler`\n * with the JSON-decoded payload of every message received.\n *\n * `subject` is the subject template as it appears on the wire, e.g.\n * `\"nova.v2.cells.{cell}\"`, with `{param}` placeholders filled in from\n * `params`.\n *\n * Errors decoding a message or thrown/rejected by `handler` are caught and\n * logged per-message, so one bad message doesn't stop later messages on\n * the same subscription from being handled.\n *\n * Each message is annotated with `msg.subjectParams` — the template's\n * `{param}` values extracted from the message's concrete subject — so a\n * wildcard subscriber knows which entity a message belongs to:\n *\n * nats.subscribe(\"nova.v2.cells.{cell}.status\", { cell: \"*\" },\n * (services, msg) => console.log(msg.subjectParams.cell, services))\n *\n * Returns a function that unsubscribes when called.\n */\n async subscribe<K extends NatsSubscribeSubject>(\n subject: K,\n ...args: SubscribeArgs<K>\n ): Promise<() => void> {\n const [params, handler] =\n args.length === 1\n ? ([{}, args[0]] as const)\n : ([args[0], args[1]] as const)\n\n const nc = await this.connect()\n const resolvedSubject = buildSubject(subject, params)\n const sub = nc.subscribe(resolvedSubject)\n\n // The token positions of the template's {param} placeholders, computed\n // once here so each message's subjectParams is a plain index pick: a\n // delivered message always matches the subscribed pattern token for\n // token, so its params sit at the same positions as in the template.\n const paramPositions: [name: string, index: number][] = []\n for (const [index, token] of subject.split(\".\").entries()) {\n if (token.startsWith(\"{\") && token.endsWith(\"}\")) {\n paramPositions.push([token.slice(1, -1), index])\n }\n }\n\n ;(async () => {\n for await (const msg of sub) {\n // Handled per-message: a bad payload or a throwing/rejecting handler\n // should not stop the subscription from processing later messages.\n try {\n const subjectTokens = msg.subject.split(\".\")\n const subjectParams = Object.fromEntries(\n paramPositions.map(([name, index]) => [\n name,\n subjectTokens[index] ?? \"\",\n ]),\n ) as NatsOperationParams[K]\n await handler(\n msg.json<NatsSubscribePayloads[K]>(),\n Object.assign(msg, { subjectParams }),\n )\n } catch (err) {\n console.error(\n `Error handling NATS message on subject \"${resolvedSubject}\"`,\n err,\n )\n }\n }\n })().catch((err: unknown) => {\n console.error(\n `NATS subscription iterator failed for \"${resolvedSubject}\"`,\n err,\n )\n })\n\n return () => sub.unsubscribe()\n }\n\n /**\n * Sends a request payload for a NATS subject the server receives, and\n * waits for the JSON-decoded reply.\n *\n * `subject` is the subject template as it appears on the wire, e.g.\n * `\"nova.v2.cells.{cell}.bus-ios.ios.set\"`, with `{param}` placeholders\n * filled in from `params`.\n */\n async request<K extends NatsRequestSubject>(\n subject: K,\n params: NatsOperationParams[K],\n payload: NatsRequestPayloads[K],\n opts: { timeout?: number } = {},\n ): Promise<NatsReplyPayloads[K]> {\n const nc = await this.connect()\n const resolvedSubject = buildSubject(subject, params)\n const msg = await nc.request(resolvedSubject, JSON.stringify(payload), {\n timeout: opts.timeout ?? 5000,\n })\n return msg.json<NatsReplyPayloads[K]>()\n }\n\n /**\n * Publishes a JSON payload to any NATS subject defined in the spec,\n * without waiting for a reply.\n *\n * `subject` is the subject template as it appears on the wire, e.g.\n * `\"nova.v2.cells.{cell}.bus-ios.ios.set\"`, with `{param}` placeholders\n * filled in from `params`.\n */\n async publish<K extends NatsPublishSubject>(\n subject: K,\n params: NatsOperationParams[K],\n payload: NatsPublishPayloads[K],\n ): Promise<void> {\n const nc = await this.connect()\n const resolvedSubject = buildSubject(subject, params)\n nc.publish(resolvedSubject, JSON.stringify(payload))\n }\n}\n"],"mappings":";;;;;;;;;;;AAUA,SAAgB,mBAAmB,aAA6B;CAC9D,MAAM,MAAM,qBAAqB,WAAW;CAE5C,OAAO,GADU,IAAI,aAAa,WAAW,SAAS,MACnC,IAAI,IAAI,KAAK;AAClC;;;;;;;;ACRA,SAAS,mBAAmB,MAAuB;CACjD,MAAM,OAAO,KAAK,WAAW,CAAC;CAC9B,OACG,QAAQ,MAAM,QAAQ,MACtB,QAAQ,MAAM,QAAQ,MACtB,QAAQ,MAAM,QAAQ,OACvB,SAAS,OACT,SAAS;AAEb;AAEA,SAAS,oBAAoB,OAAwB;CAInD,IAAI,UAAU,KAAK,OAAO;CAC1B,IAAI,MAAM,WAAW,GAAG,OAAO;CAC/B,KAAK,MAAM,QAAQ,OACjB,IAAI,C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KAAK,UAAU,OAAO,GAAG,EACrE,SAAS,KAAK,WAAW,IAC3B,CAAC,EAAA,CACU,KAA2B;CACxC;;;;;;;;;CAUA,MAAM,QACJ,SACA,QACA,SACe;EACf,MAAM,KAAK,MAAM,KAAK,QAAQ;EAC9B,MAAM,kBAAkB,aAAa,SAAS,MAAM;EACpD,GAAG,QAAQ,iBAAiB,KAAK,UAAU,OAAO,CAAC;CACrD;AACF"}
1
+ {"version":3,"file":"index.mjs","names":[],"sources":["../../../src/lib/experimental/nats/buildNatsServerUrl.ts","../../../src/lib/experimental/nats/generated/operations.ts","../../../src/lib/experimental/nats/buildSubject.ts","../../../src/lib/experimental/nats/NovaNatsClient.ts"],"sourcesContent":["import { parseNovaInstanceUrl } from \"../../converters.ts\"\n\n/**\n * Builds the WebSocket URL for a NOVA instance's NATS gateway from its\n * instance URL, e.g. `https://foo.instance.wandelbots.io` becomes\n * `wss://foo.instance.wandelbots.io/api/nats`.\n *\n * Pass the result as `servers` in the `NovaNatsClientConfig` passed to\n * `NovaNatsClient`.\n */\nexport function buildNatsServerUrl(instanceUrl: string): string {\n const url = parseNovaInstanceUrl(instanceUrl)\n const protocol = url.protocol === \"https:\" ? \"wss:\" : \"ws:\"\n return `${protocol}//${url.host}/api/nats`\n}\n","/**\n * AUTO-GENERATED FILE - DO NOT EDIT.\n * Generated from src/asyncapi.yaml by scripts/generate-nats-client.ts.\n * Run `pnpm generate:nats` to regenerate.\n */\n\nimport type {\n App,\n AppCreatedEvent,\n AppDeletedEvent,\n AppUpdatedEvent,\n BusIOsState,\n Cell,\n CellCreatedEvent,\n CellCycleEvent,\n CellDeletedEvent,\n CellUpdatedEvent,\n CollisionSetup,\n ListIOValuesResponse,\n MotionGroupDescription,\n NatsErrorPayload,\n NetworkStatusChangedEvent,\n ProgramStatus,\n RobotController,\n RobotControllerCreatedEvent,\n RobotControllerDeletedEvent,\n RobotControllerState,\n RobotControllerUpdatedEvent,\n SelectIOs,\n ServiceStatusList,\n StreamIOValuesResponse,\n SystemUpdateCompletedEvent,\n SystemUpdateStartedEvent,\n} from \"./types.ts\"\n\n/** Subject parameters required by each NATS subject, e.g. \"nova.v2.cells.{cell}\". */\nexport interface NatsOperationParams {\n /**\n * Cell Configuration\n *\n * Publishes the configuration for a cell.\n *\n * The latest status message is persisted NATS JetStream, documented in `x-nats-jetstream-stream`\n *\n * @operationId publishCell\n */\n \"nova.v2.cells.{cell}\": {\n /**\n * Unique identifier addressing a cell in all API calls.\n */\n cell: string\n }\n /**\n * App Configuration\n *\n * Publishes the configuration for a GUI application in the cell.\n *\n * The latest status message is persisted NATS JetStream, documented in `x-nats-jetstream-stream`\n *\n * @operationId publishApp\n */\n \"nova.v2.cells.{cell}.apps.{app}\": {\n /**\n * Unique identifier addressing a cell in all API calls.\n */\n cell: string\n /**\n * Name of the provided application.\n * Must be unique within the cell and is used as an identifier for addressing the application in all API calls, e.g., when updating the application.\n */\n app: string\n }\n /**\n * Program Status\n *\n * Publishes status messages for programs running in an app within a cell.\n * The status messages provide information about the current state of a program run.\n *\n * @operationId publishProgramStatus\n */\n \"nova.v2.cells.{cell}.programs\": {\n /**\n * Unique identifier addressing a cell in all API calls.\n */\n cell: string\n }\n /**\n * Robot Controller Configuration\n *\n * Publishes the configuration of a robot controller.\n *\n * @operationId publishRobotController\n */\n \"nova.v2.cells.{cell}.controllers.{controller}\": {\n /**\n * Unique identifier addressing a cell in all API calls.\n */\n cell: string\n /**\n * Unique identifier to address a controller in the cell.\n */\n controller: string\n }\n /**\n * Service Status\n *\n * Publishes the status of all cell resources.\n *\n * The latest status message is persisted NATS JetStream, documented in `x-nats-jetstream-stream`\n *\n * @operationId publishCellStatus\n */\n \"nova.v2.cells.{cell}.status\": {\n /**\n * Unique identifier addressing a cell in all API calls.\n */\n cell: string\n }\n /**\n * Cell Cycle Event\n *\n * Publishes the cycle events for a cell.\n *\n * @operationId publishCellCycle\n */\n \"nova.v2.cells.{cell}.cycle\": {\n /**\n * Unique identifier addressing a cell in all API calls.\n */\n cell: string\n }\n /**\n * Wandelbots NOVA status\n *\n * Publishes the status of all system services.\n *\n * The latest status message is persisted NATS JetStream, documented in `x-nats-jetstream-stream`\n *\n * @operationId publishSystemStatus\n */\n \"nova.v2.system.status\": Record<never, never>\n /**\n * Collision Setup\n *\n * Publishes the stored collision setup.\n *\n * The latest status message is persisted NATS JetStream, documented in `x-nats-jetstream-stream`\n *\n * @operationId publishCollisionSetup\n */\n \"nova.v2.cells.{cell}.collision.setups.{setup}\": {\n /**\n * Unique identifier addressing a cell in all API calls.\n */\n cell: string\n /**\n * Unique identifier addressing a collision setup.\n */\n setup: string\n }\n /**\n * BUS Inputs/Outputs Service Status\n *\n * Publishes the status of BUS inputs/outputs service.\n *\n * The latest status message is persisted NATS JetStream, documented in `x-nats-jetstream-stream`.\n *\n * @operationId publishBUSIOStatus\n */\n \"nova.v2.cells.{cell}.bus-ios.status\": {\n /**\n * Unique identifier addressing a cell in all API calls.\n */\n cell: string\n }\n /**\n * BUS Input/Output Values\n *\n * Publishes updates of BUS input/output values.\n *\n * @operationId publishBUSIOsIOs\n */\n \"nova.v2.cells.{cell}.bus-ios.ios\": {\n /**\n * Unique identifier addressing a cell in all API calls.\n */\n cell: string\n }\n /**\n * Set Output Values\n *\n * Set output values published with the BUS inputs/outputs service.\n * If you're using a virtual service, you can set inputs as well.\n *\n * @operationId setBUSIOsIOs\n */\n \"nova.v2.cells.{cell}.bus-ios.ios.set\": {\n /**\n * Unique identifier addressing a cell in all API calls.\n */\n cell: string\n }\n /**\n * Select Input/Output Values\n *\n * Select input/output values published by the controller.\n *\n * @operationId selectRobotControllerIOs\n */\n \"nova.v2.cells.{cell}.controllers.{controller}.ios.select\": {\n /**\n * Unique identifier addressing a cell in all API calls.\n */\n cell: string\n /**\n * Unique identifier to address a controller in a cell.\n */\n controller: string\n }\n /**\n * Input/Output Values\n *\n * Publishes updates of input/output values.\n *\n * @operationId publishRobotControllerIOs\n */\n \"nova.v2.cells.{cell}.controllers.{controller}.ios\": {\n /**\n * Unique identifier addressing a cell in all API calls.\n */\n cell: string\n /**\n * Unique identifier to address a controller in the cell.\n */\n controller: string\n }\n /**\n * State of Robot Controller\n *\n * Publishes the current state of a robot controller.\n *\n * @operationId publishRobotControllersState\n */\n \"nova.v2.cells.{cell}.controllers.{controller}.state\": {\n /**\n * Unique identifier addressing a cell in all API calls.\n */\n cell: string\n /**\n * Unique identifier to address a controller in the cell.\n */\n controller: string\n }\n /**\n * Description of Motion Group\n *\n * Publishes the description of a motion group, including TCPs, mounting, safety zones, limits, etc.\n *\n * @operationId publishMotionGroupDescription\n */\n \"nova.v2.cells.{cell}.controllers.{controller}.motion-groups.{motion-group}.description\": {\n /**\n * Unique identifier addressing a cell in all API calls.\n */\n cell: string\n /**\n * Unique identifier addressing a controller in the cell.\n */\n controller: string\n /**\n * Motion group identifier.\n */\n \"motion-group\": string\n }\n /**\n * System Update Started\n *\n * Publishes an event when a system update process is initiated.\n *\n * This event is triggered once the service-manager begins a system update process,\n * providing details about the update metadata, trigger information, and pre-update checks.\n *\n * The event follows CloudEvents v1.0 specification and is persisted in NATS JetStream\n * for reliable delivery and event replay capabilities.\n *\n * @operationId eventSystemUpdateStarted\n */\n \"nova.v2.events.system.update.started\": Record<never, never>\n /**\n * System Update Completed\n *\n * Publishes an event when a system update process is completed.\n *\n * This event is triggered once the service-manager completes a system update process,\n * providing comprehensive results including success status, component outcomes,\n * error details, and post-update validation results.\n *\n * The event follows CloudEvents v1.0 specification and is persisted in NATS JetStream\n * for reliable delivery and event replay capabilities.\n *\n * @operationId eventSystemUpdateCompleted\n */\n \"nova.v2.events.system.update.completed\": Record<never, never>\n /**\n * System Network Status Changed\n *\n * Publishes an event when a system network status changes.\n *\n * This event is triggered once system-info service detects a change in the system network status,\n * providing details about the new network state and related information.\n *\n * The event follows CloudEvents v1.0 specification and is persisted in NATS JetStream\n * for reliable delivery and event replay capabilities.\n *\n * @operationId eventSystemNetworkStatusChanged\n */\n \"nova.v2.events.system.network.status.changed\": Record<never, never>\n /**\n * Cell Created\n *\n * Publishes an event when a cell foundation release is created.\n *\n * The event follows CloudEvents v1.0 and is persisted in NATS JetStream for reliable delivery and replay capabilities.\n *\n * @operationId eventCellCreated\n */\n \"nova.v2.events.cells.{cell}.created\": {\n /**\n * Unique identifier addressing a cell in all API calls.\n */\n cell: string\n }\n /**\n * Cell Updated\n *\n * Publishes an event when a cell foundation release is updated.\n *\n * The event follows CloudEvents v1.0 and is persisted in NATS JetStream for reliable delivery and replay capabilities.\n *\n * @operationId eventCellUpdated\n */\n \"nova.v2.events.cells.{cell}.updated\": {\n /**\n * Unique identifier addressing a cell in all API calls.\n */\n cell: string\n }\n /**\n * Cell Deleted\n *\n * Publishes an event when a cell foundation release is deleted.\n *\n * The event follows CloudEvents v1.0 and is persisted in NATS JetStream for reliable delivery and replay capabilities.\n *\n * @operationId eventCellDeleted\n */\n \"nova.v2.events.cells.{cell}.deleted\": {\n /**\n * Unique identifier addressing a cell in all API calls.\n */\n cell: string\n }\n /**\n * App Created\n *\n * Publishes an event when an app release is created in a cell.\n *\n * The event follows CloudEvents v1.0 and is persisted in NATS JetStream for reliable delivery and replay capabilities.\n *\n * @operationId eventAppCreated\n */\n \"nova.v2.events.cells.{cell}.apps.{app}.created\": {\n /**\n * Unique identifier addressing a cell in all API calls.\n */\n cell: string\n /**\n * Unique identifier addressing an app in the cell.\n */\n app: string\n }\n /**\n * App Updated\n *\n * Publishes an event when an app release is updated in a cell.\n *\n * The event follows CloudEvents v1.0 and is persisted in NATS JetStream for reliable delivery and replay capabilities.\n *\n * @operationId eventAppUpdated\n */\n \"nova.v2.events.cells.{cell}.apps.{app}.updated\": {\n /**\n * Unique identifier addressing a cell in all API calls.\n */\n cell: string\n /**\n * Unique identifier addressing an app in the cell.\n */\n app: string\n }\n /**\n * App Deleted\n *\n * Publishes an event when an app release is deleted from a cell.\n *\n * The event follows CloudEvents v1.0 and is persisted in NATS JetStream for reliable delivery and replay capabilities.\n *\n * @operationId eventAppDeleted\n */\n \"nova.v2.events.cells.{cell}.apps.{app}.deleted\": {\n /**\n * Unique identifier addressing a cell in all API calls.\n */\n cell: string\n /**\n * Unique identifier addressing an app in the cell.\n */\n app: string\n }\n /**\n * Robot Controller Created\n *\n * Publishes an event when a robot controller release is created in a cell.\n *\n * The event follows CloudEvents v1.0 and is persisted in NATS JetStream for reliable delivery and replay capabilities.\n *\n * @operationId eventRobotControllerCreated\n */\n \"nova.v2.events.cells.{cell}.controllers.{controller}.created\": {\n /**\n * Unique identifier addressing a cell in all API calls.\n */\n cell: string\n /**\n * Unique identifier to address a controller in the cell.\n */\n controller: string\n }\n /**\n * Robot Controller Updated\n *\n * Publishes an event when a robot controller release is updated in a cell.\n *\n * The event follows CloudEvents v1.0 and is persisted in NATS JetStream for reliable delivery and replay capabilities.\n *\n * @operationId eventRobotControllerUpdated\n */\n \"nova.v2.events.cells.{cell}.controllers.{controller}.updated\": {\n /**\n * Unique identifier addressing a cell in all API calls.\n */\n cell: string\n /**\n * Unique identifier to address a controller in the cell.\n */\n controller: string\n }\n /**\n * Robot Controller Deleted\n *\n * Publishes an event when a robot controller release is deleted from a cell.\n *\n * The event follows CloudEvents v1.0 and is persisted in NATS JetStream for reliable delivery and replay capabilities.\n *\n * @operationId eventRobotControllerDeleted\n */\n \"nova.v2.events.cells.{cell}.controllers.{controller}.deleted\": {\n /**\n * Unique identifier addressing a cell in all API calls.\n */\n cell: string\n /**\n * Unique identifier to address a controller in the cell.\n */\n controller: string\n }\n}\n\n/** Payload types for subjects the server publishes and the client subscribes to. */\nexport interface NatsSubscribePayloads {\n /**\n * Cell Configuration\n *\n * Publishes the configuration for a cell.\n *\n * The latest status message is persisted NATS JetStream, documented in `x-nats-jetstream-stream`\n *\n * @operationId publishCell\n */\n \"nova.v2.cells.{cell}\": Cell\n /**\n * App Configuration\n *\n * Publishes the configuration for a GUI application in the cell.\n *\n * The latest status message is persisted NATS JetStream, documented in `x-nats-jetstream-stream`\n *\n * @operationId publishApp\n */\n \"nova.v2.cells.{cell}.apps.{app}\": App\n /**\n * Program Status\n *\n * Publishes status messages for programs running in an app within a cell.\n * The status messages provide information about the current state of a program run.\n *\n * @operationId publishProgramStatus\n */\n \"nova.v2.cells.{cell}.programs\": ProgramStatus\n /**\n * Robot Controller Configuration\n *\n * Publishes the configuration of a robot controller.\n *\n * @operationId publishRobotController\n */\n \"nova.v2.cells.{cell}.controllers.{controller}\": RobotController\n /**\n * Service Status\n *\n * Publishes the status of all cell resources.\n *\n * The latest status message is persisted NATS JetStream, documented in `x-nats-jetstream-stream`\n *\n * @operationId publishCellStatus\n */\n \"nova.v2.cells.{cell}.status\": ServiceStatusList\n /**\n * Cell Cycle Event\n *\n * Publishes the cycle events for a cell.\n *\n * @operationId publishCellCycle\n */\n \"nova.v2.cells.{cell}.cycle\": CellCycleEvent\n /**\n * Wandelbots NOVA status\n *\n * Publishes the status of all system services.\n *\n * The latest status message is persisted NATS JetStream, documented in `x-nats-jetstream-stream`\n *\n * @operationId publishSystemStatus\n */\n \"nova.v2.system.status\": ServiceStatusList\n /**\n * Collision Setup\n *\n * Publishes the stored collision setup.\n *\n * The latest status message is persisted NATS JetStream, documented in `x-nats-jetstream-stream`\n *\n * @operationId publishCollisionSetup\n */\n \"nova.v2.cells.{cell}.collision.setups.{setup}\": CollisionSetup\n /**\n * BUS Inputs/Outputs Service Status\n *\n * Publishes the status of BUS inputs/outputs service.\n *\n * The latest status message is persisted NATS JetStream, documented in `x-nats-jetstream-stream`.\n *\n * @operationId publishBUSIOStatus\n */\n \"nova.v2.cells.{cell}.bus-ios.status\": BusIOsState\n /**\n * BUS Input/Output Values\n *\n * Publishes updates of BUS input/output values.\n *\n * @operationId publishBUSIOsIOs\n */\n \"nova.v2.cells.{cell}.bus-ios.ios\": ListIOValuesResponse\n /**\n * Input/Output Values\n *\n * Publishes updates of input/output values.\n *\n * @operationId publishRobotControllerIOs\n */\n \"nova.v2.cells.{cell}.controllers.{controller}.ios\": StreamIOValuesResponse\n /**\n * State of Robot Controller\n *\n * Publishes the current state of a robot controller.\n *\n * @operationId publishRobotControllersState\n */\n \"nova.v2.cells.{cell}.controllers.{controller}.state\": RobotControllerState\n /**\n * Description of Motion Group\n *\n * Publishes the description of a motion group, including TCPs, mounting, safety zones, limits, etc.\n *\n * @operationId publishMotionGroupDescription\n */\n \"nova.v2.cells.{cell}.controllers.{controller}.motion-groups.{motion-group}.description\": MotionGroupDescription\n /**\n * System Update Started\n *\n * Publishes an event when a system update process is initiated.\n *\n * This event is triggered once the service-manager begins a system update process,\n * providing details about the update metadata, trigger information, and pre-update checks.\n *\n * The event follows CloudEvents v1.0 specification and is persisted in NATS JetStream\n * for reliable delivery and event replay capabilities.\n *\n * @operationId eventSystemUpdateStarted\n */\n \"nova.v2.events.system.update.started\": SystemUpdateStartedEvent\n /**\n * System Update Completed\n *\n * Publishes an event when a system update process is completed.\n *\n * This event is triggered once the service-manager completes a system update process,\n * providing comprehensive results including success status, component outcomes,\n * error details, and post-update validation results.\n *\n * The event follows CloudEvents v1.0 specification and is persisted in NATS JetStream\n * for reliable delivery and event replay capabilities.\n *\n * @operationId eventSystemUpdateCompleted\n */\n \"nova.v2.events.system.update.completed\": SystemUpdateCompletedEvent\n /**\n * System Network Status Changed\n *\n * Publishes an event when a system network status changes.\n *\n * This event is triggered once system-info service detects a change in the system network status,\n * providing details about the new network state and related information.\n *\n * The event follows CloudEvents v1.0 specification and is persisted in NATS JetStream\n * for reliable delivery and event replay capabilities.\n *\n * @operationId eventSystemNetworkStatusChanged\n */\n \"nova.v2.events.system.network.status.changed\": NetworkStatusChangedEvent\n /**\n * Cell Created\n *\n * Publishes an event when a cell foundation release is created.\n *\n * The event follows CloudEvents v1.0 and is persisted in NATS JetStream for reliable delivery and replay capabilities.\n *\n * @operationId eventCellCreated\n */\n \"nova.v2.events.cells.{cell}.created\": CellCreatedEvent\n /**\n * Cell Updated\n *\n * Publishes an event when a cell foundation release is updated.\n *\n * The event follows CloudEvents v1.0 and is persisted in NATS JetStream for reliable delivery and replay capabilities.\n *\n * @operationId eventCellUpdated\n */\n \"nova.v2.events.cells.{cell}.updated\": CellUpdatedEvent\n /**\n * Cell Deleted\n *\n * Publishes an event when a cell foundation release is deleted.\n *\n * The event follows CloudEvents v1.0 and is persisted in NATS JetStream for reliable delivery and replay capabilities.\n *\n * @operationId eventCellDeleted\n */\n \"nova.v2.events.cells.{cell}.deleted\": CellDeletedEvent\n /**\n * App Created\n *\n * Publishes an event when an app release is created in a cell.\n *\n * The event follows CloudEvents v1.0 and is persisted in NATS JetStream for reliable delivery and replay capabilities.\n *\n * @operationId eventAppCreated\n */\n \"nova.v2.events.cells.{cell}.apps.{app}.created\": AppCreatedEvent\n /**\n * App Updated\n *\n * Publishes an event when an app release is updated in a cell.\n *\n * The event follows CloudEvents v1.0 and is persisted in NATS JetStream for reliable delivery and replay capabilities.\n *\n * @operationId eventAppUpdated\n */\n \"nova.v2.events.cells.{cell}.apps.{app}.updated\": AppUpdatedEvent\n /**\n * App Deleted\n *\n * Publishes an event when an app release is deleted from a cell.\n *\n * The event follows CloudEvents v1.0 and is persisted in NATS JetStream for reliable delivery and replay capabilities.\n *\n * @operationId eventAppDeleted\n */\n \"nova.v2.events.cells.{cell}.apps.{app}.deleted\": AppDeletedEvent\n /**\n * Robot Controller Created\n *\n * Publishes an event when a robot controller release is created in a cell.\n *\n * The event follows CloudEvents v1.0 and is persisted in NATS JetStream for reliable delivery and replay capabilities.\n *\n * @operationId eventRobotControllerCreated\n */\n \"nova.v2.events.cells.{cell}.controllers.{controller}.created\": RobotControllerCreatedEvent\n /**\n * Robot Controller Updated\n *\n * Publishes an event when a robot controller release is updated in a cell.\n *\n * The event follows CloudEvents v1.0 and is persisted in NATS JetStream for reliable delivery and replay capabilities.\n *\n * @operationId eventRobotControllerUpdated\n */\n \"nova.v2.events.cells.{cell}.controllers.{controller}.updated\": RobotControllerUpdatedEvent\n /**\n * Robot Controller Deleted\n *\n * Publishes an event when a robot controller release is deleted from a cell.\n *\n * The event follows CloudEvents v1.0 and is persisted in NATS JetStream for reliable delivery and replay capabilities.\n *\n * @operationId eventRobotControllerDeleted\n */\n \"nova.v2.events.cells.{cell}.controllers.{controller}.deleted\": RobotControllerDeletedEvent\n}\n\nexport type NatsSubscribeSubject = keyof NatsSubscribePayloads\n\n/**\n * The JetStream stream backing each subject that retains only its latest\n * message (`max_msgs_per_subject: 1` in src/asyncapi.yaml), so that\n * message is the subject's current state.\n */\nexport const natsStreamBySubject = {\n \"nova.v2.cells.{cell}\": \"system-state\",\n \"nova.v2.cells.{cell}.apps.{app}\": \"system-state\",\n \"nova.v2.cells.{cell}.controllers.{controller}\": \"system-state\",\n \"nova.v2.cells.{cell}.status\": \"system-state\",\n \"nova.v2.system.status\": \"system-state\",\n \"nova.v2.cells.{cell}.collision.setups.{setup}\": \"system-state\",\n \"nova.v2.cells.{cell}.bus-ios.status\": \"system-state\",\n \"nova.v2.cells.{cell}.controllers.{controller}.motion-groups.{motion-group}.description\":\n \"system-state\",\n} as const\n\n/** Subjects whose current value can be replayed via `{ replayLast: true }`. */\nexport type NatsPersistedSubject = keyof typeof natsStreamBySubject\n\n/** Request payload types for subjects the client sends requests to. */\nexport interface NatsRequestPayloads {\n /**\n * Set Output Values\n *\n * Set output values published with the BUS inputs/outputs service.\n * If you're using a virtual service, you can set inputs as well.\n *\n * @operationId setBUSIOsIOs\n */\n \"nova.v2.cells.{cell}.bus-ios.ios.set\": ListIOValuesResponse\n /**\n * Select Input/Output Values\n *\n * Select input/output values published by the controller.\n *\n * @operationId selectRobotControllerIOs\n */\n \"nova.v2.cells.{cell}.controllers.{controller}.ios.select\": SelectIOs\n}\n\n/** Reply payload types for request/reply subjects. */\nexport interface NatsReplyPayloads {\n /**\n * Set Output Values\n *\n * Set output values published with the BUS inputs/outputs service.\n * If you're using a virtual service, you can set inputs as well.\n *\n * @operationId setBUSIOsIOs\n */\n \"nova.v2.cells.{cell}.bus-ios.ios.set\": NatsErrorPayload\n /**\n * Select Input/Output Values\n *\n * Select input/output values published by the controller.\n *\n * @operationId selectRobotControllerIOs\n */\n \"nova.v2.cells.{cell}.controllers.{controller}.ios.select\": NatsErrorPayload\n}\n\nexport type NatsRequestSubject = keyof NatsRequestPayloads\n\n/** Payload types for every subject defined in the spec, publishable via NovaNatsClient#publish. */\nexport interface NatsPublishPayloads {\n /**\n * Cell Configuration\n *\n * Publishes the configuration for a cell.\n *\n * The latest status message is persisted NATS JetStream, documented in `x-nats-jetstream-stream`\n *\n * @operationId publishCell\n */\n \"nova.v2.cells.{cell}\": Cell\n /**\n * App Configuration\n *\n * Publishes the configuration for a GUI application in the cell.\n *\n * The latest status message is persisted NATS JetStream, documented in `x-nats-jetstream-stream`\n *\n * @operationId publishApp\n */\n \"nova.v2.cells.{cell}.apps.{app}\": App\n /**\n * Program Status\n *\n * Publishes status messages for programs running in an app within a cell.\n * The status messages provide information about the current state of a program run.\n *\n * @operationId publishProgramStatus\n */\n \"nova.v2.cells.{cell}.programs\": ProgramStatus\n /**\n * Robot Controller Configuration\n *\n * Publishes the configuration of a robot controller.\n *\n * @operationId publishRobotController\n */\n \"nova.v2.cells.{cell}.controllers.{controller}\": RobotController\n /**\n * Service Status\n *\n * Publishes the status of all cell resources.\n *\n * The latest status message is persisted NATS JetStream, documented in `x-nats-jetstream-stream`\n *\n * @operationId publishCellStatus\n */\n \"nova.v2.cells.{cell}.status\": ServiceStatusList\n /**\n * Cell Cycle Event\n *\n * Publishes the cycle events for a cell.\n *\n * @operationId publishCellCycle\n */\n \"nova.v2.cells.{cell}.cycle\": CellCycleEvent\n /**\n * Wandelbots NOVA status\n *\n * Publishes the status of all system services.\n *\n * The latest status message is persisted NATS JetStream, documented in `x-nats-jetstream-stream`\n *\n * @operationId publishSystemStatus\n */\n \"nova.v2.system.status\": ServiceStatusList\n /**\n * Collision Setup\n *\n * Publishes the stored collision setup.\n *\n * The latest status message is persisted NATS JetStream, documented in `x-nats-jetstream-stream`\n *\n * @operationId publishCollisionSetup\n */\n \"nova.v2.cells.{cell}.collision.setups.{setup}\": CollisionSetup\n /**\n * BUS Inputs/Outputs Service Status\n *\n * Publishes the status of BUS inputs/outputs service.\n *\n * The latest status message is persisted NATS JetStream, documented in `x-nats-jetstream-stream`.\n *\n * @operationId publishBUSIOStatus\n */\n \"nova.v2.cells.{cell}.bus-ios.status\": BusIOsState\n /**\n * BUS Input/Output Values\n *\n * Publishes updates of BUS input/output values.\n *\n * @operationId publishBUSIOsIOs\n */\n \"nova.v2.cells.{cell}.bus-ios.ios\": ListIOValuesResponse\n /**\n * Set Output Values\n *\n * Set output values published with the BUS inputs/outputs service.\n * If you're using a virtual service, you can set inputs as well.\n *\n * @operationId setBUSIOsIOs\n */\n \"nova.v2.cells.{cell}.bus-ios.ios.set\": ListIOValuesResponse\n /**\n * Select Input/Output Values\n *\n * Select input/output values published by the controller.\n *\n * @operationId selectRobotControllerIOs\n */\n \"nova.v2.cells.{cell}.controllers.{controller}.ios.select\": SelectIOs\n /**\n * Input/Output Values\n *\n * Publishes updates of input/output values.\n *\n * @operationId publishRobotControllerIOs\n */\n \"nova.v2.cells.{cell}.controllers.{controller}.ios\": StreamIOValuesResponse\n /**\n * State of Robot Controller\n *\n * Publishes the current state of a robot controller.\n *\n * @operationId publishRobotControllersState\n */\n \"nova.v2.cells.{cell}.controllers.{controller}.state\": RobotControllerState\n /**\n * Description of Motion Group\n *\n * Publishes the description of a motion group, including TCPs, mounting, safety zones, limits, etc.\n *\n * @operationId publishMotionGroupDescription\n */\n \"nova.v2.cells.{cell}.controllers.{controller}.motion-groups.{motion-group}.description\": MotionGroupDescription\n /**\n * System Update Started\n *\n * Publishes an event when a system update process is initiated.\n *\n * This event is triggered once the service-manager begins a system update process,\n * providing details about the update metadata, trigger information, and pre-update checks.\n *\n * The event follows CloudEvents v1.0 specification and is persisted in NATS JetStream\n * for reliable delivery and event replay capabilities.\n *\n * @operationId eventSystemUpdateStarted\n */\n \"nova.v2.events.system.update.started\": SystemUpdateStartedEvent\n /**\n * System Update Completed\n *\n * Publishes an event when a system update process is completed.\n *\n * This event is triggered once the service-manager completes a system update process,\n * providing comprehensive results including success status, component outcomes,\n * error details, and post-update validation results.\n *\n * The event follows CloudEvents v1.0 specification and is persisted in NATS JetStream\n * for reliable delivery and event replay capabilities.\n *\n * @operationId eventSystemUpdateCompleted\n */\n \"nova.v2.events.system.update.completed\": SystemUpdateCompletedEvent\n /**\n * System Network Status Changed\n *\n * Publishes an event when a system network status changes.\n *\n * This event is triggered once system-info service detects a change in the system network status,\n * providing details about the new network state and related information.\n *\n * The event follows CloudEvents v1.0 specification and is persisted in NATS JetStream\n * for reliable delivery and event replay capabilities.\n *\n * @operationId eventSystemNetworkStatusChanged\n */\n \"nova.v2.events.system.network.status.changed\": NetworkStatusChangedEvent\n /**\n * Cell Created\n *\n * Publishes an event when a cell foundation release is created.\n *\n * The event follows CloudEvents v1.0 and is persisted in NATS JetStream for reliable delivery and replay capabilities.\n *\n * @operationId eventCellCreated\n */\n \"nova.v2.events.cells.{cell}.created\": CellCreatedEvent\n /**\n * Cell Updated\n *\n * Publishes an event when a cell foundation release is updated.\n *\n * The event follows CloudEvents v1.0 and is persisted in NATS JetStream for reliable delivery and replay capabilities.\n *\n * @operationId eventCellUpdated\n */\n \"nova.v2.events.cells.{cell}.updated\": CellUpdatedEvent\n /**\n * Cell Deleted\n *\n * Publishes an event when a cell foundation release is deleted.\n *\n * The event follows CloudEvents v1.0 and is persisted in NATS JetStream for reliable delivery and replay capabilities.\n *\n * @operationId eventCellDeleted\n */\n \"nova.v2.events.cells.{cell}.deleted\": CellDeletedEvent\n /**\n * App Created\n *\n * Publishes an event when an app release is created in a cell.\n *\n * The event follows CloudEvents v1.0 and is persisted in NATS JetStream for reliable delivery and replay capabilities.\n *\n * @operationId eventAppCreated\n */\n \"nova.v2.events.cells.{cell}.apps.{app}.created\": AppCreatedEvent\n /**\n * App Updated\n *\n * Publishes an event when an app release is updated in a cell.\n *\n * The event follows CloudEvents v1.0 and is persisted in NATS JetStream for reliable delivery and replay capabilities.\n *\n * @operationId eventAppUpdated\n */\n \"nova.v2.events.cells.{cell}.apps.{app}.updated\": AppUpdatedEvent\n /**\n * App Deleted\n *\n * Publishes an event when an app release is deleted from a cell.\n *\n * The event follows CloudEvents v1.0 and is persisted in NATS JetStream for reliable delivery and replay capabilities.\n *\n * @operationId eventAppDeleted\n */\n \"nova.v2.events.cells.{cell}.apps.{app}.deleted\": AppDeletedEvent\n /**\n * Robot Controller Created\n *\n * Publishes an event when a robot controller release is created in a cell.\n *\n * The event follows CloudEvents v1.0 and is persisted in NATS JetStream for reliable delivery and replay capabilities.\n *\n * @operationId eventRobotControllerCreated\n */\n \"nova.v2.events.cells.{cell}.controllers.{controller}.created\": RobotControllerCreatedEvent\n /**\n * Robot Controller Updated\n *\n * Publishes an event when a robot controller release is updated in a cell.\n *\n * The event follows CloudEvents v1.0 and is persisted in NATS JetStream for reliable delivery and replay capabilities.\n *\n * @operationId eventRobotControllerUpdated\n */\n \"nova.v2.events.cells.{cell}.controllers.{controller}.updated\": RobotControllerUpdatedEvent\n /**\n * Robot Controller Deleted\n *\n * Publishes an event when a robot controller release is deleted from a cell.\n *\n * The event follows CloudEvents v1.0 and is persisted in NATS JetStream for reliable delivery and replay capabilities.\n *\n * @operationId eventRobotControllerDeleted\n */\n \"nova.v2.events.cells.{cell}.controllers.{controller}.deleted\": RobotControllerDeletedEvent\n}\n\nexport type NatsPublishSubject = keyof NatsPublishPayloads\n","/**\n * Builds a NATS subject from an AsyncAPI-style channel address template\n * (e.g. `\"{instance}.v2.cells.{cell}\"`) by substituting each `{param}`\n * placeholder with the corresponding value from `params`.\n */\n\nfunction isValidSubjectChar(char: string): boolean {\n const code = char.charCodeAt(0)\n return (\n (code >= 48 && code <= 57) || // 0-9\n (code >= 65 && code <= 90) || // A-Z\n (code >= 97 && code <= 122) || // a-z\n char === \"-\" ||\n char === \"_\"\n )\n}\n\nfunction isValidSubjectValue(value: string): boolean {\n // A bare \"*\" is the NATS single-token wildcard, allowed on its own (e.g.\n // subscribing to all cells with `{ cell: \"*\" }\") but not as part of a\n // larger value, since it wouldn't act as a wildcard there anyway.\n if (value === \"*\") return true\n if (value.length === 0) return false\n for (const char of value) {\n if (!isValidSubjectChar(char)) return false\n }\n return true\n}\n\nexport function buildSubject(\n template: string,\n params: Record<string, string>,\n): string {\n // Scanned manually (rather than with a regex like /\\{([^}]+)\\}/g) to avoid\n // a polynomial-time backtracking blowup on pathological input, e.g. a\n // template consisting of many \"{\" characters with no closing \"}\".\n let result = \"\"\n let cursor = 0\n\n while (cursor < template.length) {\n const openIndex = template.indexOf(\"{\", cursor)\n if (openIndex === -1) {\n result += template.slice(cursor)\n break\n }\n\n const closeIndex = template.indexOf(\"}\", openIndex + 1)\n if (closeIndex === -1) {\n result += template.slice(cursor)\n break\n }\n\n result += template.slice(cursor, openIndex)\n const paramName = template.slice(openIndex + 1, closeIndex)\n const value = params[paramName]\n if (value === undefined) {\n throw new Error(\n `Missing value for subject parameter \"${paramName}\" in template \"${template}\"`,\n )\n }\n if (!isValidSubjectValue(value)) {\n throw new Error(\n `Invalid value for subject parameter \"${paramName}\": \"${value}\" (must be non-empty and contain only letters, digits, \"-\", and \"_\")`,\n )\n }\n result += value\n\n cursor = closeIndex + 1\n }\n\n return result\n}\n","import { DeliverPolicy, jetstream, type JsMsg } from \"@nats-io/jetstream\"\nimport {\n type ConnectionOptions,\n type Msg,\n type NatsConnection,\n wsconnect,\n} from \"@nats-io/nats-core\"\nimport type { Nova } from \"../../Nova.ts\"\nimport { buildNatsServerUrl } from \"./buildNatsServerUrl.ts\"\nimport { buildSubject } from \"./buildSubject.ts\"\nimport {\n type NatsOperationParams,\n type NatsPersistedSubject,\n type NatsPublishPayloads,\n type NatsPublishSubject,\n type NatsReplyPayloads,\n type NatsRequestPayloads,\n type NatsRequestSubject,\n natsStreamBySubject,\n type NatsSubscribePayloads,\n type NatsSubscribeSubject,\n} from \"./generated/operations.ts\"\n\nexport type NovaNatsClientConfig = ConnectionOptions\n\n/**\n * A received message, annotated with the values of the subject template's\n * `{param}` placeholders as extracted from the message's concrete subject.\n * With a wildcard subscription (e.g. `{ cell: \"*\" }`), `subjectParams` is how\n * a handler knows which entity a message belongs to. Typed per subject via\n * the generated `NatsOperationParams`.\n */\nexport type NatsSubscribeMsg<K extends NatsSubscribeSubject> = (Msg | JsMsg) & {\n subjectParams: NatsOperationParams[K]\n}\n\ntype NatsMessageHandler<K extends NatsSubscribeSubject> = (\n payload: NatsSubscribePayloads[K],\n msg: NatsSubscribeMsg<K>,\n) => void | Promise<void>\n\n/**\n * Extra options for {@link NovaNatsClient.subscribe}. `replayLast` is only\n * offered on subjects the spec marks as retaining their latest message, so\n * asking for a replay that could never arrive is a compile error.\n */\nexport type NatsSubscribeOptions<K extends NatsSubscribeSubject> =\n K extends NatsPersistedSubject\n ? {\n /**\n * Deliver the subject's current value immediately on subscribe,\n * before any subsequent updates. With a wildcard subscription (e.g.\n * `{ cell: \"*\" }`) the current value of every matching subject is\n * delivered, not just one.\n */\n replayLast?: boolean\n }\n : // Not `Record<never, never>`: that behaves like `{}` and so accepts any\n // object, letting `replayLast` through unchecked. Typing the property as\n // `never` is what makes passing it an error.\n { replayLast?: never }\n\ntype SubscribeArgs<K extends NatsSubscribeSubject> =\n keyof NatsOperationParams[K] extends never\n ? [handler: NatsMessageHandler<K>, opts?: NatsSubscribeOptions<K>]\n : [\n params: NatsOperationParams[K],\n handler: NatsMessageHandler<K>,\n opts?: NatsSubscribeOptions<K>,\n ]\n\n/**\n * Typed NATS client for the Wandelbots NOVA messaging API, generated from\n * src/asyncapi.yaml (see scripts/generate-nats-client.ts).\n *\n * Connects over WebSocket via `@nats-io/nats-core`'s `wsconnect`.\n */\nexport class NovaNatsClient {\n readonly config: NovaNatsClientConfig\n private connectionPromise: Promise<NatsConnection> | null = null\n\n constructor(nova: Nova, config: NovaNatsClientConfig = {}) {\n this.config = {\n servers: buildNatsServerUrl(nova.instanceUrl.href),\n // Reuse the Nova instance's access token for NATS auth, if it has one\n // (e.g. from login or a passed-in config.accessToken). Explicit auth\n // options in `config` (token/user/pass/authenticator) still win.\n ...(nova.accessToken ? { token: nova.accessToken } : {}),\n ...config,\n }\n }\n\n /**\n * Connects to NATS if not already connected or connecting, and returns the\n * connection. Safe to call concurrently: all callers share the same\n * in-flight connection attempt instead of each starting their own.\n */\n connect(): Promise<NatsConnection> {\n if (!this.connectionPromise) {\n this.connectionPromise = wsconnect(this.config).catch((err: unknown) => {\n // Allow a subsequent connect() call to retry after a failed attempt.\n this.connectionPromise = null\n throw err\n })\n }\n return this.connectionPromise\n }\n\n /** Closes the underlying NATS connection, if open or connecting. */\n async close(): Promise<void> {\n const connectionPromise = this.connectionPromise\n this.connectionPromise = null\n if (!connectionPromise) return\n try {\n const nc = await connectionPromise\n await nc.close()\n } catch {\n // Connection never succeeded; nothing to close.\n }\n }\n\n /**\n * Subscribes to a NATS subject published by the server, invoking `handler`\n * with the JSON-decoded payload of every message received.\n *\n * `subject` is the subject template as it appears on the wire, e.g.\n * `\"nova.v2.cells.{cell}\"`, with `{param}` placeholders filled in from\n * `params`.\n *\n * Errors decoding a message or thrown/rejected by `handler` are caught and\n * logged per-message, so one bad message doesn't stop later messages on\n * the same subscription from being handled.\n *\n * Each message is annotated with `msg.subjectParams` — the template's\n * `{param}` values extracted from the message's concrete subject — so a\n * wildcard subscriber knows which entity a message belongs to:\n *\n * nats.subscribe(\"nova.v2.cells.{cell}.status\", { cell: \"*\" },\n * (services, msg) => console.log(msg.subjectParams.cell, services))\n *\n * On subjects that retain their latest message, pass `{ replayLast: true }`\n * to receive the current value immediately instead of waiting for the next\n * update — useful for a subscriber that starts after the last change:\n *\n * nats.subscribe(\"nova.v2.system.status\", onStatus, { replayLast: true })\n *\n * Returns a function that unsubscribes when called.\n */\n async subscribe<K extends NatsSubscribeSubject>(\n subject: K,\n ...args: SubscribeArgs<K>\n ): Promise<() => void> {\n // `params` is omitted for subjects with no {param} placeholders, so the\n // handler is the first argument in that case.\n const hasParams = typeof args[0] !== \"function\"\n const params = (hasParams ? args[0] : {}) as NatsOperationParams[K]\n const handler = (hasParams ? args[1] : args[0]) as NatsMessageHandler<K>\n const opts = (hasParams ? args[2] : args[1]) as\n | { replayLast?: boolean }\n | undefined\n\n const nc = await this.connect()\n const resolvedSubject = buildSubject(subject, params)\n\n // The token positions of the template's {param} placeholders, computed\n // once here so each message's subjectParams is a plain index pick: a\n // delivered message always matches the subscribed pattern token for\n // token, so its params sit at the same positions as in the template.\n const paramPositions: [name: string, index: number][] = []\n for (const [index, token] of subject.split(\".\").entries()) {\n if (token.startsWith(\"{\") && token.endsWith(\"}\")) {\n paramPositions.push([token.slice(1, -1), index])\n }\n }\n\n const deliver = async (msg: Msg | JsMsg) => {\n // Handled per-message: a bad payload or a throwing/rejecting handler\n // should not stop the subscription from processing later messages.\n try {\n const subjectTokens = msg.subject.split(\".\")\n const subjectParams = Object.fromEntries(\n paramPositions.map(([name, index]) => [\n name,\n subjectTokens[index] ?? \"\",\n ]),\n ) as NatsOperationParams[K]\n await handler(\n msg.json<NatsSubscribePayloads[K]>(),\n Object.assign(msg, { subjectParams }),\n )\n } catch (err) {\n console.error(\n `Error handling NATS message on subject \"${resolvedSubject}\"`,\n err,\n )\n }\n }\n\n const deliverAll = (messages: AsyncIterable<Msg | JsMsg>) => {\n ;(async () => {\n for await (const msg of messages) {\n await deliver(msg)\n }\n })().catch((err: unknown) => {\n console.error(\n `NATS subscription iterator failed for \"${resolvedSubject}\"`,\n err,\n )\n })\n }\n\n if (opts?.replayLast) {\n // Delivered by JetStream rather than core NATS: an ordered consumer\n // starting at `last_per_subject` yields each matching subject's retained\n // message and then continues with live ones on the same iterator, so\n // there is no gap — and no possible duplicate — between the replayed\n // value and the updates that follow it. Ordered consumers are ephemeral\n // and need no acking, so stopping the iterator is the whole teardown.\n const consumer = await jetstream(nc).consumers.get(\n natsStreamBySubject[subject as NatsPersistedSubject],\n {\n filter_subjects: [resolvedSubject],\n deliver_policy: DeliverPolicy.LastPerSubject,\n },\n )\n const messages = await consumer.consume()\n deliverAll(messages)\n return () => {\n messages.stop()\n }\n }\n\n const sub = nc.subscribe(resolvedSubject)\n deliverAll(sub)\n return () => sub.unsubscribe()\n }\n\n /**\n * Sends a request payload for a NATS subject the server receives, and\n * waits for the JSON-decoded reply.\n *\n * `subject` is the subject template as it appears on the wire, e.g.\n * `\"nova.v2.cells.{cell}.bus-ios.ios.set\"`, with `{param}` placeholders\n * filled in from `params`.\n */\n async request<K extends NatsRequestSubject>(\n subject: K,\n params: NatsOperationParams[K],\n payload: NatsRequestPayloads[K],\n opts: { timeout?: number } = {},\n ): Promise<NatsReplyPayloads[K]> {\n const nc = await this.connect()\n const resolvedSubject = buildSubject(subject, params)\n const msg = await nc.request(resolvedSubject, JSON.stringify(payload), {\n timeout: opts.timeout ?? 5000,\n })\n return msg.json<NatsReplyPayloads[K]>()\n }\n\n /**\n * Publishes a JSON payload to any NATS subject defined in the spec,\n * without waiting for a reply.\n *\n * `subject` is the subject template as it appears on the wire, e.g.\n * `\"nova.v2.cells.{cell}.bus-ios.ios.set\"`, with `{param}` placeholders\n * filled in from `params`.\n */\n async publish<K extends NatsPublishSubject>(\n subject: K,\n params: NatsOperationParams[K],\n payload: NatsPublishPayloads[K],\n ): Promise<void> {\n const nc = await this.connect()\n const resolvedSubject = buildSubject(subject, params)\n nc.publish(resolvedSubject, JSON.stringify(payload))\n }\n}\n"],"mappings":";;;;;;;;;;;;AAUA,SAAgB,mBAAmB,aAA6B;CAC9D,MAAM,MAAM,qBAAqB,WAAW;CAE5C,OAAO,GADU,IAAI,aAAa,WAAW,SAAS,MACnC,IAAI,IAAI,KAAK;AAClC;;;;;;;;ACqtBA,MAAa,sBAAsB;CACjC,wBAAwB;CACxB,mCAAmC;CACnC,iDAAiD;CACjD,+BAA+B;CAC/B,yBAAyB;CACzB,iDAAiD;CACjD,uCAAuC;CACvC,0FACE;AACJ;;;;;;;;ACvuBA,SAAS,mBAAmB,MAAuB;CACjD,MAAM,OA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GAC1D,CAAC,YAAY;IACZ,WAAW,MAAM,OAAO,UACtB,MAAM,QAAQ,GAAG;GAErB,EAAA,CAAG,CAAC,CAAC,OAAO,QAAiB;IAC3B,QAAQ,MACN,0CAA0C,gBAAgB,IAC1D,GACF;GACF,CAAC;EACH;EAEA,IAAI,MAAM,YAAY;GAcpB,MAAM,WAAW,OAAM,MAPA,UAAU,EAAE,CAAC,CAAC,UAAU,IAC7C,oBAAoB,UACpB;IACE,iBAAiB,CAAC,eAAe;IACjC,gBAAgB,cAAc;GAChC,CACF,EAAA,CACgC,QAAQ;GACxC,WAAW,QAAQ;GACnB,aAAa;IACX,SAAS,KAAK;GAChB;EACF;EAEA,MAAM,MAAM,GAAG,UAAU,eAAe;EACxC,WAAW,GAAG;EACd,aAAa,IAAI,YAAY;CAC/B;;;;;;;;;CAUA,MAAM,QACJ,SACA,QACA,SACA,OAA6B,CAAC,GACC;EAC/B,MAAM,KAAK,MAAM,KAAK,QAAQ;EAC9B,MAAM,kBAAkB,aAAa,SAAS,MAAM;EAIpD,QAAO,MAHW,GAAG,QAAQ,iBAAiB,KAAK,UAAU,OAAO,GAAG,EACrE,SAAS,KAAK,WAAW,IAC3B,CAAC,EAAA,CACU,KAA2B;CACxC;;;;;;;;;CAUA,MAAM,QACJ,SACA,QACA,SACe;EACf,MAAM,KAAK,MAAM,KAAK,QAAQ;EAC9B,MAAM,kBAAkB,aAAa,SAAS,MAAM;EACpD,GAAG,QAAQ,iBAAiB,KAAK,UAAU,OAAO,CAAC;CACrD;AACF"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@wandelbots/nova-js",
3
3
  "type": "module",
4
- "version": "4.4.0",
4
+ "version": "4.5.0-pr.321.4edffe1",
5
5
  "description": "Official JS client for the Wandelbots API",
6
6
  "sideEffects": false,
7
7
  "packageManager": "pnpm@11.9.0+sha512.bd682d5d03fe525ef7c9fd6780c6884d1e756ac4c9c9fe00c538782824310dcf90e3ddc4f53835f06dfaebd5085e41855e0bcbb3b60de2ac5bbab89e5036f03b",
@@ -80,6 +80,7 @@
80
80
  },
81
81
  "dependencies": {
82
82
  "@auth0/auth0-spa-js": "^2.24.1",
83
+ "@nats-io/jetstream": "^3.4.0",
83
84
  "@nats-io/nats-core": "^3.4.0",
84
85
  "axios": "^1.19.0",
85
86
  "path-to-regexp": "^8.4.2",
@@ -5,15 +5,17 @@
5
5
  * This API is experimental and may change without a major version bump.
6
6
  */
7
7
  export { buildNatsServerUrl } from "../../lib/experimental/nats/buildNatsServerUrl.ts"
8
- export type {
9
- NatsOperationParams,
10
- NatsPublishPayloads,
11
- NatsPublishSubject,
12
- NatsReplyPayloads,
13
- NatsRequestPayloads,
14
- NatsRequestSubject,
15
- NatsSubscribePayloads,
16
- NatsSubscribeSubject,
8
+ export {
9
+ type NatsOperationParams,
10
+ type NatsPersistedSubject,
11
+ type NatsPublishPayloads,
12
+ type NatsPublishSubject,
13
+ type NatsReplyPayloads,
14
+ type NatsRequestPayloads,
15
+ type NatsRequestSubject,
16
+ natsStreamBySubject,
17
+ type NatsSubscribePayloads,
18
+ type NatsSubscribeSubject,
17
19
  } from "../../lib/experimental/nats/generated/operations.ts"
18
20
  // Message payload types for every schema in src/asyncapi.yaml, e.g. `Cell`,
19
21
  // `App`, `ProgramStatus` (see NatsSubscribePayloads/NatsRequestPayloads for
@@ -22,5 +24,6 @@ export type * from "../../lib/experimental/nats/generated/types.ts"
22
24
  export { NovaNatsClient } from "../../lib/experimental/nats/NovaNatsClient.ts"
23
25
  export type {
24
26
  NatsSubscribeMsg,
27
+ NatsSubscribeOptions,
25
28
  NovaNatsClientConfig,
26
29
  } from "../../lib/experimental/nats/NovaNatsClient.ts"
@@ -1,3 +1,4 @@
1
+ import { DeliverPolicy, jetstream, type JsMsg } from "@nats-io/jetstream"
1
2
  import {
2
3
  type ConnectionOptions,
3
4
  type Msg,
@@ -7,15 +8,17 @@ import {
7
8
  import type { Nova } from "../../Nova.ts"
8
9
  import { buildNatsServerUrl } from "./buildNatsServerUrl.ts"
9
10
  import { buildSubject } from "./buildSubject.ts"
10
- import type {
11
- NatsOperationParams,
12
- NatsPublishPayloads,
13
- NatsPublishSubject,
14
- NatsReplyPayloads,
15
- NatsRequestPayloads,
16
- NatsRequestSubject,
17
- NatsSubscribePayloads,
18
- NatsSubscribeSubject,
11
+ import {
12
+ type NatsOperationParams,
13
+ type NatsPersistedSubject,
14
+ type NatsPublishPayloads,
15
+ type NatsPublishSubject,
16
+ type NatsReplyPayloads,
17
+ type NatsRequestPayloads,
18
+ type NatsRequestSubject,
19
+ natsStreamBySubject,
20
+ type NatsSubscribePayloads,
21
+ type NatsSubscribeSubject,
19
22
  } from "./generated/operations.ts"
20
23
 
21
24
  export type NovaNatsClientConfig = ConnectionOptions
@@ -27,7 +30,7 @@ export type NovaNatsClientConfig = ConnectionOptions
27
30
  * a handler knows which entity a message belongs to. Typed per subject via
28
31
  * the generated `NatsOperationParams`.
29
32
  */
30
- export type NatsSubscribeMsg<K extends NatsSubscribeSubject> = Msg & {
33
+ export type NatsSubscribeMsg<K extends NatsSubscribeSubject> = (Msg | JsMsg) & {
31
34
  subjectParams: NatsOperationParams[K]
32
35
  }
33
36
 
@@ -36,10 +39,35 @@ type NatsMessageHandler<K extends NatsSubscribeSubject> = (
36
39
  msg: NatsSubscribeMsg<K>,
37
40
  ) => void | Promise<void>
38
41
 
42
+ /**
43
+ * Extra options for {@link NovaNatsClient.subscribe}. `replayLast` is only
44
+ * offered on subjects the spec marks as retaining their latest message, so
45
+ * asking for a replay that could never arrive is a compile error.
46
+ */
47
+ export type NatsSubscribeOptions<K extends NatsSubscribeSubject> =
48
+ K extends NatsPersistedSubject
49
+ ? {
50
+ /**
51
+ * Deliver the subject's current value immediately on subscribe,
52
+ * before any subsequent updates. With a wildcard subscription (e.g.
53
+ * `{ cell: "*" }`) the current value of every matching subject is
54
+ * delivered, not just one.
55
+ */
56
+ replayLast?: boolean
57
+ }
58
+ : // Not `Record<never, never>`: that behaves like `{}` and so accepts any
59
+ // object, letting `replayLast` through unchecked. Typing the property as
60
+ // `never` is what makes passing it an error.
61
+ { replayLast?: never }
62
+
39
63
  type SubscribeArgs<K extends NatsSubscribeSubject> =
40
64
  keyof NatsOperationParams[K] extends never
41
- ? [handler: NatsMessageHandler<K>]
42
- : [params: NatsOperationParams[K], handler: NatsMessageHandler<K>]
65
+ ? [handler: NatsMessageHandler<K>, opts?: NatsSubscribeOptions<K>]
66
+ : [
67
+ params: NatsOperationParams[K],
68
+ handler: NatsMessageHandler<K>,
69
+ opts?: NatsSubscribeOptions<K>,
70
+ ]
43
71
 
44
72
  /**
45
73
  * Typed NATS client for the Wandelbots NOVA messaging API, generated from
@@ -110,20 +138,29 @@ export class NovaNatsClient {
110
138
  * nats.subscribe("nova.v2.cells.{cell}.status", { cell: "*" },
111
139
  * (services, msg) => console.log(msg.subjectParams.cell, services))
112
140
  *
141
+ * On subjects that retain their latest message, pass `{ replayLast: true }`
142
+ * to receive the current value immediately instead of waiting for the next
143
+ * update — useful for a subscriber that starts after the last change:
144
+ *
145
+ * nats.subscribe("nova.v2.system.status", onStatus, { replayLast: true })
146
+ *
113
147
  * Returns a function that unsubscribes when called.
114
148
  */
115
149
  async subscribe<K extends NatsSubscribeSubject>(
116
150
  subject: K,
117
151
  ...args: SubscribeArgs<K>
118
152
  ): Promise<() => void> {
119
- const [params, handler] =
120
- args.length === 1
121
- ? ([{}, args[0]] as const)
122
- : ([args[0], args[1]] as const)
153
+ // `params` is omitted for subjects with no {param} placeholders, so the
154
+ // handler is the first argument in that case.
155
+ const hasParams = typeof args[0] !== "function"
156
+ const params = (hasParams ? args[0] : {}) as NatsOperationParams[K]
157
+ const handler = (hasParams ? args[1] : args[0]) as NatsMessageHandler<K>
158
+ const opts = (hasParams ? args[2] : args[1]) as
159
+ | { replayLast?: boolean }
160
+ | undefined
123
161
 
124
162
  const nc = await this.connect()
125
163
  const resolvedSubject = buildSubject(subject, params)
126
- const sub = nc.subscribe(resolvedSubject)
127
164
 
128
165
  // The token positions of the template's {param} placeholders, computed
129
166
  // once here so each message's subjectParams is a plain index pick: a
@@ -136,36 +173,65 @@ export class NovaNatsClient {
136
173
  }
137
174
  }
138
175
 
139
- ;(async () => {
140
- for await (const msg of sub) {
141
- // Handled per-message: a bad payload or a throwing/rejecting handler
142
- // should not stop the subscription from processing later messages.
143
- try {
144
- const subjectTokens = msg.subject.split(".")
145
- const subjectParams = Object.fromEntries(
146
- paramPositions.map(([name, index]) => [
147
- name,
148
- subjectTokens[index] ?? "",
149
- ]),
150
- ) as NatsOperationParams[K]
151
- await handler(
152
- msg.json<NatsSubscribePayloads[K]>(),
153
- Object.assign(msg, { subjectParams }),
154
- )
155
- } catch (err) {
156
- console.error(
157
- `Error handling NATS message on subject "${resolvedSubject}"`,
158
- err,
159
- )
160
- }
176
+ const deliver = async (msg: Msg | JsMsg) => {
177
+ // Handled per-message: a bad payload or a throwing/rejecting handler
178
+ // should not stop the subscription from processing later messages.
179
+ try {
180
+ const subjectTokens = msg.subject.split(".")
181
+ const subjectParams = Object.fromEntries(
182
+ paramPositions.map(([name, index]) => [
183
+ name,
184
+ subjectTokens[index] ?? "",
185
+ ]),
186
+ ) as NatsOperationParams[K]
187
+ await handler(
188
+ msg.json<NatsSubscribePayloads[K]>(),
189
+ Object.assign(msg, { subjectParams }),
190
+ )
191
+ } catch (err) {
192
+ console.error(
193
+ `Error handling NATS message on subject "${resolvedSubject}"`,
194
+ err,
195
+ )
161
196
  }
162
- })().catch((err: unknown) => {
163
- console.error(
164
- `NATS subscription iterator failed for "${resolvedSubject}"`,
165
- err,
197
+ }
198
+
199
+ const deliverAll = (messages: AsyncIterable<Msg | JsMsg>) => {
200
+ ;(async () => {
201
+ for await (const msg of messages) {
202
+ await deliver(msg)
203
+ }
204
+ })().catch((err: unknown) => {
205
+ console.error(
206
+ `NATS subscription iterator failed for "${resolvedSubject}"`,
207
+ err,
208
+ )
209
+ })
210
+ }
211
+
212
+ if (opts?.replayLast) {
213
+ // Delivered by JetStream rather than core NATS: an ordered consumer
214
+ // starting at `last_per_subject` yields each matching subject's retained
215
+ // message and then continues with live ones on the same iterator, so
216
+ // there is no gap — and no possible duplicate — between the replayed
217
+ // value and the updates that follow it. Ordered consumers are ephemeral
218
+ // and need no acking, so stopping the iterator is the whole teardown.
219
+ const consumer = await jetstream(nc).consumers.get(
220
+ natsStreamBySubject[subject as NatsPersistedSubject],
221
+ {
222
+ filter_subjects: [resolvedSubject],
223
+ deliver_policy: DeliverPolicy.LastPerSubject,
224
+ },
166
225
  )
167
- })
226
+ const messages = await consumer.consume()
227
+ deliverAll(messages)
228
+ return () => {
229
+ messages.stop()
230
+ }
231
+ }
168
232
 
233
+ const sub = nc.subscribe(resolvedSubject)
234
+ deliverAll(sub)
169
235
  return () => sub.unsubscribe()
170
236
  }
171
237
 
@@ -732,6 +732,26 @@ export interface NatsSubscribePayloads {
732
732
 
733
733
  export type NatsSubscribeSubject = keyof NatsSubscribePayloads
734
734
 
735
+ /**
736
+ * The JetStream stream backing each subject that retains only its latest
737
+ * message (`max_msgs_per_subject: 1` in src/asyncapi.yaml), so that
738
+ * message is the subject's current state.
739
+ */
740
+ export const natsStreamBySubject = {
741
+ "nova.v2.cells.{cell}": "system-state",
742
+ "nova.v2.cells.{cell}.apps.{app}": "system-state",
743
+ "nova.v2.cells.{cell}.controllers.{controller}": "system-state",
744
+ "nova.v2.cells.{cell}.status": "system-state",
745
+ "nova.v2.system.status": "system-state",
746
+ "nova.v2.cells.{cell}.collision.setups.{setup}": "system-state",
747
+ "nova.v2.cells.{cell}.bus-ios.status": "system-state",
748
+ "nova.v2.cells.{cell}.controllers.{controller}.motion-groups.{motion-group}.description":
749
+ "system-state",
750
+ } as const
751
+
752
+ /** Subjects whose current value can be replayed via `{ replayLast: true }`. */
753
+ export type NatsPersistedSubject = keyof typeof natsStreamBySubject
754
+
735
755
  /** Request payload types for subjects the client sends requests to. */
736
756
  export interface NatsRequestPayloads {
737
757
  /**