iii-sdk 0.8.2 → 0.9.0

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.
Files changed (48) hide show
  1. package/README.md +15 -11
  2. package/dist/index.cjs +234 -105
  3. package/dist/index.cjs.map +1 -1
  4. package/dist/index.d.cts +182 -3
  5. package/dist/index.d.cts.map +1 -1
  6. package/dist/index.d.mts +182 -3
  7. package/dist/index.d.mts.map +1 -1
  8. package/dist/index.mjs +234 -106
  9. package/dist/index.mjs.map +1 -1
  10. package/dist/state.cjs +1 -0
  11. package/dist/state.cjs.map +1 -1
  12. package/dist/state.d.cts +43 -1
  13. package/dist/state.d.cts.map +1 -1
  14. package/dist/state.d.mts +43 -1
  15. package/dist/state.d.mts.map +1 -1
  16. package/dist/state.mjs +1 -0
  17. package/dist/state.mjs.map +1 -1
  18. package/dist/stream-BAjVneSg.d.mts +176 -0
  19. package/dist/stream-BAjVneSg.d.mts.map +1 -0
  20. package/dist/stream-DUNsytJU.d.cts +176 -0
  21. package/dist/stream-DUNsytJU.d.cts.map +1 -0
  22. package/dist/stream.d.cts +1 -1
  23. package/dist/stream.d.mts +1 -1
  24. package/dist/telemetry.cjs +1 -1
  25. package/dist/telemetry.d.cts +10 -11
  26. package/dist/telemetry.d.cts.map +1 -1
  27. package/dist/telemetry.d.mts +10 -11
  28. package/dist/telemetry.d.mts.map +1 -1
  29. package/dist/telemetry.mjs +1 -1
  30. package/dist/{utils-coGqiBHT.mjs → utils-5jD8F3OE.mjs} +241 -212
  31. package/dist/utils-5jD8F3OE.mjs.map +1 -0
  32. package/dist/{utils-CMrMD5Ij.d.mts → utils-BRn3Iff5.d.mts} +586 -210
  33. package/dist/utils-BRn3Iff5.d.mts.map +1 -0
  34. package/dist/{utils-BaGgUfjl.d.cts → utils-D6RPYBhs.d.cts} +586 -210
  35. package/dist/utils-D6RPYBhs.d.cts.map +1 -0
  36. package/dist/{utils-BJTjoUdq.cjs → utils-bsZVduQi.cjs} +240 -211
  37. package/dist/utils-bsZVduQi.cjs.map +1 -0
  38. package/package.json +4 -2
  39. package/typedoc.json +8 -0
  40. package/vitest.config.ts +4 -4
  41. package/dist/stream-BEp3rjfm.d.cts +0 -97
  42. package/dist/stream-BEp3rjfm.d.cts.map +0 -1
  43. package/dist/stream-Bzpo5JNV.d.mts +0 -97
  44. package/dist/stream-Bzpo5JNV.d.mts.map +0 -1
  45. package/dist/utils-BJTjoUdq.cjs.map +0 -1
  46. package/dist/utils-BaGgUfjl.d.cts.map +0 -1
  47. package/dist/utils-CMrMD5Ij.d.mts.map +0 -1
  48. package/dist/utils-coGqiBHT.mjs.map +0 -1
package/README.md CHANGED
@@ -14,9 +14,9 @@ npm install iii-sdk
14
14
  ## Hello World
15
15
 
16
16
  ```javascript
17
- import { init } from 'iii-sdk'
17
+ import { registerWorker } from 'iii-sdk'
18
18
 
19
- const iii = init('ws://localhost:49134')
19
+ const iii = registerWorker('ws://localhost:49134')
20
20
 
21
21
  iii.registerFunction({ id: 'greet' }, async (input) => {
22
22
  return { message: `Hello, ${input.name}!` }
@@ -28,18 +28,18 @@ iii.registerTrigger({
28
28
  config: { api_path: '/greet', http_method: 'POST' },
29
29
  })
30
30
 
31
- const result = await iii.trigger('greet', { name: 'world' })
31
+ const result = await iii.trigger({ function_id: 'greet', payload: { name: 'world' } })
32
32
  ```
33
33
 
34
34
  ## API
35
35
 
36
36
  | Operation | Signature | Description |
37
37
  | ------------------------ | ---------------------------------------------------- | ------------------------------------------------------------ |
38
- | Initialize | `init(url, options?)` | Create and connect to the engine. Returns an `ISdk` instance |
38
+ | Initialize | `registerWorker(url, options?)` | Create and connect to the engine. Returns an `ISdk` instance |
39
39
  | Register function | `iii.registerFunction({ id }, handler)` | Register a function that can be invoked by name |
40
40
  | Register trigger | `iii.registerTrigger({ type, function_id, config })` | Bind a trigger (HTTP, cron, queue, etc.) to a function |
41
- | Invoke (await) | `await iii.trigger(id, data, timeoutMs?)` | Invoke a function and wait for the result |
42
- | Invoke (fire-and-forget) | `iii.triggerVoid(id, data)` | Invoke a function without waiting (fire-and-forget) |
41
+ | Invoke (await) | `await iii.trigger({ function_id, payload })` | Invoke a function and wait for the result |
42
+ | Invoke (fire-and-forget) | `iii.trigger({ function_id, payload, action: TriggerAction.Void() })` | Invoke without waiting |
43
43
 
44
44
  ### Registering Functions
45
45
 
@@ -62,23 +62,27 @@ iii.registerTrigger({
62
62
  ### Invoking Functions
63
63
 
64
64
  ```javascript
65
- const result = await iii.trigger('orders.create', { item: 'widget' })
65
+ import { registerWorker, TriggerAction } from 'iii-sdk'
66
66
 
67
- iii.triggerVoid('analytics.track', { event: 'page_view' })
67
+ const iii = registerWorker('ws://localhost:49134')
68
+
69
+ const result = await iii.trigger({ function_id: 'orders.create', payload: { item: 'widget' } })
70
+
71
+ iii.trigger({ function_id: 'analytics.track', payload: { event: 'page_view' }, action: TriggerAction.Void() })
68
72
  ```
69
73
 
70
74
  ## Node Modules
71
75
 
72
76
  | Import | What it provides |
73
77
  | ------------------- | ------------------------------------- |
74
- | `iii-sdk` | Core SDK (`init`, types) |
78
+ | `iii-sdk` | Core SDK (`registerWorker`, types) |
75
79
  | `iii-sdk/stream` | Stream client for real-time state |
76
80
  | `iii-sdk/state` | State client for key-value operations |
77
81
  | `iii-sdk/telemetry` | OpenTelemetry integration |
78
82
 
79
- ## Deprecated
83
+ ## Removed methods
80
84
 
81
- `call()` and `callVoid()` are deprecated aliases for `trigger()` and `triggerVoid()`. They still work but will be removed in a future release.
85
+ `call`, `callVoid`, and `triggerVoid` have been removed. Use `trigger()` for all invocations. For fire-and-forget, use `trigger({ function_id, payload, action: TriggerAction.Void() })`.
82
86
 
83
87
  ## Resources
84
88
 
package/dist/index.cjs CHANGED
@@ -25,16 +25,33 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
25
25
  }) : target, mod));
26
26
 
27
27
  //#endregion
28
- const require_utils = require('./utils-BJTjoUdq.cjs');
28
+ const require_utils = require('./utils-bsZVduQi.cjs');
29
+ let node_stream = require("node:stream");
30
+ let ws = require("ws");
29
31
  let __opentelemetry_api = require("@opentelemetry/api");
30
32
  let node_module = require("node:module");
31
33
  let node_os = require("node:os");
32
34
  node_os = __toESM(node_os);
33
- let ws = require("ws");
34
- let node_stream = require("node:stream");
35
35
  let __opentelemetry_api_logs = require("@opentelemetry/api-logs");
36
36
 
37
37
  //#region src/channels.ts
38
+ /**
39
+ * Write end of a streaming channel. Provides both a Node.js `Writable` stream
40
+ * and a `sendMessage` method for sending structured text messages.
41
+ *
42
+ * @example
43
+ * ```typescript
44
+ * const channel = await iii.createChannel()
45
+ *
46
+ * // Stream binary data
47
+ * channel.writer.stream.write(Buffer.from('hello'))
48
+ * channel.writer.stream.end()
49
+ *
50
+ * // Or send text messages
51
+ * channel.writer.sendMessage(JSON.stringify({ type: 'event', data: 'test' }))
52
+ * channel.writer.close()
53
+ * ```
54
+ */
38
55
  var ChannelWriter = class ChannelWriter {
39
56
  static {
40
57
  this.FRAME_SIZE = 64 * 1024;
@@ -79,12 +96,14 @@ var ChannelWriter = class ChannelWriter {
79
96
  if (!this.stream.destroyed) this.stream.destroy();
80
97
  });
81
98
  }
99
+ /** Send a text message through the channel. */
82
100
  sendMessage(msg) {
83
101
  this.ensureConnected();
84
102
  this.sendRaw(msg, (err) => {
85
103
  if (err) this.stream.destroy(err);
86
104
  });
87
105
  }
106
+ /** Close the channel writer. */
88
107
  close() {
89
108
  if (!this.ws) return;
90
109
  if (this.wsReady) this.ws.close(1e3, "channel_close");
@@ -117,6 +136,21 @@ var ChannelWriter = class ChannelWriter {
117
136
  });
118
137
  }
119
138
  };
139
+ /**
140
+ * Read end of a streaming channel. Provides both a Node.js `Readable` stream
141
+ * for binary data and an `onMessage` callback for structured text messages.
142
+ *
143
+ * @example
144
+ * ```typescript
145
+ * const channel = await iii.createChannel()
146
+ *
147
+ * // Stream binary data
148
+ * channel.reader.stream.on('data', (chunk) => console.log(chunk))
149
+ *
150
+ * // Or receive text messages
151
+ * channel.reader.onMessage((msg) => console.log('Got:', msg))
152
+ * ```
153
+ */
120
154
  var ChannelReader = class {
121
155
  constructor(engineWsBase, ref) {
122
156
  this.ws = null;
@@ -159,9 +193,19 @@ var ChannelReader = class {
159
193
  this.stream.destroy(err);
160
194
  });
161
195
  }
196
+ /** Register a callback to receive text messages from the channel. */
162
197
  onMessage(callback) {
163
198
  this.messageCallbacks.push(callback);
164
199
  }
200
+ async readAll() {
201
+ this.ensureConnected();
202
+ const chunks = [];
203
+ for await (const chunk of this.stream) chunks.push(Buffer.isBuffer(chunk) ? chunk : Buffer.from(chunk));
204
+ return Buffer.concat(chunks);
205
+ }
206
+ close() {
207
+ if (this.ws && this.ws.readyState !== ws.WebSocket.CLOSED) this.ws.close(1e3, "channel_close");
208
+ }
165
209
  };
166
210
  function buildChannelUrl(engineWsBase, channelId, accessKey, direction) {
167
211
  return `${engineWsBase.replace(/\/$/, "")}/ws/channels/${channelId}?key=${encodeURIComponent(accessKey)}&dir=${direction}`;
@@ -203,11 +247,9 @@ var Sdk = class {
203
247
  this.triggers = /* @__PURE__ */ new Map();
204
248
  this.triggerTypes = /* @__PURE__ */ new Map();
205
249
  this.functionsAvailableCallbacks = /* @__PURE__ */ new Set();
206
- this.logCallbacks = /* @__PURE__ */ new Map();
207
250
  this.messagesToSend = [];
208
251
  this.reconnectAttempt = 0;
209
252
  this.connectionState = "disconnected";
210
- this.stateCallbacks = /* @__PURE__ */ new Set();
211
253
  this.isShuttingDown = false;
212
254
  this.registerTriggerType = (triggerType, handler) => {
213
255
  this.sendMessage(MessageType.RegisterTriggerType, triggerType, true);
@@ -219,9 +261,6 @@ var Sdk = class {
219
261
  handler
220
262
  });
221
263
  };
222
- this.on = (event, callback) => {
223
- this.ws?.on(event, callback);
224
- };
225
264
  this.unregisterTriggerType = (triggerType) => {
226
265
  this.sendMessage(MessageType.UnregisterTriggerType, triggerType, true);
227
266
  this.triggerTypes.delete(triggerType.id);
@@ -292,14 +331,21 @@ var Sdk = class {
292
331
  };
293
332
  };
294
333
  this.registerService = (message) => {
295
- this.sendMessage(MessageType.RegisterService, message, true);
296
- this.services.set(message.id, {
334
+ const msg = {
297
335
  ...message,
336
+ name: message.name ?? message.id
337
+ };
338
+ this.sendMessage(MessageType.RegisterService, msg, true);
339
+ this.services.set(message.id, {
340
+ ...msg,
298
341
  message_type: MessageType.RegisterService
299
342
  });
300
343
  };
301
344
  this.createChannel = async (bufferSize) => {
302
- const result = await this.call("engine::channels::create", { buffer_size: bufferSize });
345
+ const result = await this.trigger({
346
+ function_id: "engine::channels::create",
347
+ payload: { buffer_size: bufferSize }
348
+ });
303
349
  return {
304
350
  writer: new ChannelWriter(this.address, result.writer),
305
351
  reader: new ChannelReader(this.address, result.reader),
@@ -307,11 +353,24 @@ var Sdk = class {
307
353
  readerRef: result.reader
308
354
  };
309
355
  };
310
- this.trigger = async (function_id, data, timeoutMs) => {
356
+ this.trigger = async (request) => {
357
+ const { function_id, payload, action, timeoutMs } = request;
358
+ const effectiveTimeout = timeoutMs ?? this.invocationTimeoutMs;
359
+ if (action?.type === "void") {
360
+ const traceparent$1 = require_utils.injectTraceparent();
361
+ const baggage$1 = require_utils.injectBaggage();
362
+ this.sendMessage(MessageType.InvokeFunction, {
363
+ function_id,
364
+ data: payload,
365
+ traceparent: traceparent$1,
366
+ baggage: baggage$1,
367
+ action
368
+ });
369
+ return;
370
+ }
311
371
  const invocation_id = crypto.randomUUID();
312
372
  const traceparent = require_utils.injectTraceparent();
313
373
  const baggage = require_utils.injectBaggage();
314
- const effectiveTimeout = timeoutMs ?? this.invocationTimeoutMs;
315
374
  return new Promise((resolve, reject) => {
316
375
  const timeout = setTimeout(() => {
317
376
  if (this.invocations.get(invocation_id)) {
@@ -333,29 +392,30 @@ var Sdk = class {
333
392
  this.sendMessage(MessageType.InvokeFunction, {
334
393
  invocation_id,
335
394
  function_id,
336
- data,
395
+ data: payload,
337
396
  traceparent,
338
- baggage
397
+ baggage,
398
+ action
339
399
  });
340
400
  });
341
401
  };
342
- this.triggerVoid = (function_id, data) => {
343
- const traceparent = require_utils.injectTraceparent();
344
- const baggage = require_utils.injectBaggage();
345
- this.sendMessage(MessageType.InvokeFunction, {
346
- function_id,
347
- data,
348
- traceparent,
349
- baggage
350
- });
351
- };
352
- this.call = async (function_id, data, timeoutMs) => this.trigger(function_id, data, timeoutMs);
353
- this.callVoid = (function_id, data) => this.triggerVoid(function_id, data);
354
402
  this.listFunctions = async () => {
355
- return (await this.trigger(require_utils.EngineFunctions.LIST_FUNCTIONS, {})).functions;
403
+ return (await this.trigger({
404
+ function_id: require_utils.EngineFunctions.LIST_FUNCTIONS,
405
+ payload: {}
406
+ })).functions;
356
407
  };
357
408
  this.listWorkers = async () => {
358
- return (await this.trigger(require_utils.EngineFunctions.LIST_WORKERS, {})).workers;
409
+ return (await this.trigger({
410
+ function_id: require_utils.EngineFunctions.LIST_WORKERS,
411
+ payload: {}
412
+ })).workers;
413
+ };
414
+ this.listTriggers = async (includeInternal = false) => {
415
+ return (await this.trigger({
416
+ function_id: require_utils.EngineFunctions.LIST_TRIGGERS,
417
+ payload: { include_internal: includeInternal }
418
+ })).triggers;
359
419
  };
360
420
  this.createStream = (streamName, stream) => {
361
421
  this.registerFunction({ id: `stream::get(${streamName})` }, stream.get.bind(stream));
@@ -389,48 +449,6 @@ var Sdk = class {
389
449
  }
390
450
  };
391
451
  };
392
- this.onLog = (callback, config) => {
393
- const effectiveConfig = config ?? { level: "all" };
394
- this.logCallbacks.set(callback, effectiveConfig);
395
- if (!this.logTrigger) {
396
- if (!this.logFunctionPath) this.logFunctionPath = `engine.on_log.${crypto.randomUUID()}`;
397
- const function_id = this.logFunctionPath;
398
- if (!this.functions.has(function_id)) this.registerFunction({ id: function_id }, async (log) => {
399
- this.logCallbacks.forEach((cfg, handler) => {
400
- try {
401
- const minSeverity = this.severityTextToNumber(cfg.level ?? "all");
402
- if (cfg.level === "all" || log.severity_number >= minSeverity) handler(log);
403
- } catch (error) {
404
- this.logError("Log callback handler threw an exception", error);
405
- }
406
- });
407
- return null;
408
- });
409
- this.logTrigger = this.registerTrigger({
410
- type: require_utils.EngineTriggers.LOG,
411
- function_id,
412
- config: {
413
- level: "all",
414
- severity_min: 0
415
- }
416
- });
417
- }
418
- return () => {
419
- this.logCallbacks.delete(callback);
420
- if (this.logCallbacks.size === 0 && this.logTrigger) {
421
- this.logTrigger.unregister();
422
- this.logTrigger = void 0;
423
- }
424
- };
425
- };
426
- this.getConnectionState = () => {
427
- return this.connectionState;
428
- };
429
- this.onConnectionStateChange = (callback) => {
430
- this.stateCallbacks.add(callback);
431
- callback(this.connectionState);
432
- return () => this.stateCallbacks.delete(callback);
433
- };
434
452
  this.shutdown = async () => {
435
453
  this.isShuttingDown = true;
436
454
  this.stopMetricsReporting();
@@ -446,7 +464,6 @@ var Sdk = class {
446
464
  this.ws.close();
447
465
  this.ws = void 0;
448
466
  }
449
- this.stateCallbacks.clear();
450
467
  this.setConnectionState("disconnected");
451
468
  };
452
469
  this.workerName = options?.workerName ?? getDefaultWorkerName();
@@ -465,29 +482,26 @@ var Sdk = class {
465
482
  registerWorkerMetadata() {
466
483
  const telemetryOpts = this.options?.telemetry;
467
484
  const language = telemetryOpts?.language ?? Intl.DateTimeFormat().resolvedOptions().locale ?? process.env.LANG?.split(".")[0];
468
- this.triggerVoid(require_utils.EngineFunctions.REGISTER_WORKER, {
469
- runtime: "node",
470
- version: SDK_VERSION,
471
- name: this.workerName,
472
- os: getOsInfo(),
473
- pid: process.pid,
474
- telemetry: {
475
- language,
476
- project_name: telemetryOpts?.project_name,
477
- framework: telemetryOpts?.framework,
478
- amplitude_api_key: telemetryOpts?.amplitude_api_key
479
- }
485
+ this.trigger({
486
+ function_id: require_utils.EngineFunctions.REGISTER_WORKER,
487
+ payload: {
488
+ runtime: "node",
489
+ version: SDK_VERSION,
490
+ name: this.workerName,
491
+ os: getOsInfo(),
492
+ pid: process.pid,
493
+ telemetry: {
494
+ language,
495
+ project_name: telemetryOpts?.project_name,
496
+ framework: telemetryOpts?.framework,
497
+ amplitude_api_key: telemetryOpts?.amplitude_api_key
498
+ }
499
+ },
500
+ action: { type: "void" }
480
501
  });
481
502
  }
482
503
  setConnectionState(state) {
483
- if (this.connectionState !== state) {
484
- this.connectionState = state;
485
- for (const callback of this.stateCallbacks) try {
486
- callback(state);
487
- } catch (error) {
488
- this.logError("Error in connection state callback", error);
489
- }
490
- }
504
+ if (this.connectionState !== state) this.connectionState = state;
491
505
  }
492
506
  connect() {
493
507
  if (this.isShuttingDown) return;
@@ -632,18 +646,6 @@ var Sdk = class {
632
646
  });
633
647
  else console.error(`[iii] ${message}`, error ?? "");
634
648
  }
635
- severityTextToNumber(level) {
636
- switch (level) {
637
- case "trace": return 1;
638
- case "debug": return 5;
639
- case "info": return 9;
640
- case "warn": return 13;
641
- case "error": return 17;
642
- case "fatal": return 21;
643
- case "all": return 0;
644
- default: return 0;
645
- }
646
- }
647
649
  onInvocationResult(invocation_id, result, error) {
648
650
  const invocation = this.invocations.get(invocation_id);
649
651
  if (invocation) {
@@ -686,12 +688,14 @@ var Sdk = class {
686
688
  baggage: getResponseBaggage()
687
689
  });
688
690
  } catch (error) {
691
+ const isError = error instanceof Error;
689
692
  this.sendMessage(MessageType.InvocationResult, {
690
693
  invocation_id,
691
694
  function_id,
692
695
  error: {
693
696
  code: "invocation_failed",
694
- message: error.message
697
+ message: isError ? error.message : String(error),
698
+ stacktrace: isError ? error.stack : void 0
695
699
  },
696
700
  traceparent: getResponseTraceparent(),
697
701
  baggage: getResponseBaggage()
@@ -777,10 +781,82 @@ var Sdk = class {
777
781
  }
778
782
  }
779
783
  };
784
+ /**
785
+ * Factory object that constructs routing actions for {@link ISdk.trigger}.
786
+ *
787
+ * @example
788
+ * ```typescript
789
+ * import { TriggerAction } from 'iii-sdk'
790
+ *
791
+ * // Enqueue to a named queue
792
+ * iii.trigger({
793
+ * function_id: 'process',
794
+ * payload: { data: 'hello' },
795
+ * action: TriggerAction.Enqueue({ queue: 'jobs' }),
796
+ * })
797
+ *
798
+ * // Fire-and-forget
799
+ * iii.trigger({
800
+ * function_id: 'notify',
801
+ * payload: {},
802
+ * action: TriggerAction.Void(),
803
+ * })
804
+ * ```
805
+ */
806
+ const TriggerAction = {
807
+ Enqueue: (opts) => ({
808
+ type: "enqueue",
809
+ ...opts
810
+ }),
811
+ Void: () => ({ type: "void" })
812
+ };
813
+ /**
814
+ * Creates and returns a connected SDK instance. The WebSocket connection is
815
+ * established automatically -- there is no separate `connect()` call.
816
+ *
817
+ * @param address - WebSocket URL of the III engine (e.g. `ws://localhost:49134`).
818
+ * @param options - Optional {@link InitOptions} for worker name, timeouts, reconnection, and OTel.
819
+ * @returns A connected {@link ISdk} instance.
820
+ *
821
+ * @example
822
+ * ```typescript
823
+ * import { registerWorker } from 'iii-sdk'
824
+ *
825
+ * const iii = registerWorker(process.env.III_URL ?? 'ws://localhost:49134', {
826
+ * workerName: 'my-worker',
827
+ * })
828
+ * ```
829
+ */
780
830
  const registerWorker = (address, options) => new Sdk(address, options);
781
831
 
782
832
  //#endregion
783
833
  //#region src/logger.ts
834
+ /**
835
+ * Structured logger that emits logs as OpenTelemetry LogRecords.
836
+ *
837
+ * Every log call automatically captures the active trace and span context,
838
+ * correlating your logs with distributed traces without any manual wiring.
839
+ * When OTel is not initialized, Logger gracefully falls back to `console.*`.
840
+ *
841
+ * Pass structured data as the second argument to any log method. Using an
842
+ * object of key-value pairs (instead of string interpolation) lets you
843
+ * filter, aggregate, and build dashboards in your observability backend.
844
+ *
845
+ * @example
846
+ * ```typescript
847
+ * import { Logger } from 'iii-sdk'
848
+ *
849
+ * const logger = new Logger()
850
+ *
851
+ * // Basic logging — trace context is injected automatically
852
+ * logger.info('Worker connected')
853
+ *
854
+ * // Structured context for dashboards and alerting
855
+ * logger.info('Order processed', { orderId: 'ord_123', amount: 49.99, currency: 'USD' })
856
+ * logger.warn('Retry attempt', { attempt: 3, maxRetries: 5, endpoint: '/api/charge' })
857
+ * logger.error('Payment failed', { orderId: 'ord_123', gateway: 'stripe', errorCode: 'card_declined' })
858
+ * ```
859
+ */
784
860
  var Logger = class {
785
861
  get otelLogger() {
786
862
  if (!this._otelLogger) this._otelLogger = require_utils.getLogger();
@@ -821,15 +897,67 @@ var Logger = class {
821
897
  default: console.log(message, data);
822
898
  }
823
899
  }
900
+ /**
901
+ * Log an info-level message.
902
+ *
903
+ * @param message - Human-readable log message.
904
+ * @param data - Structured context attached as OTel log attributes.
905
+ * Use key-value objects to enable filtering and aggregation in your
906
+ * observability backend (e.g. Grafana, Datadog, New Relic).
907
+ *
908
+ * @example
909
+ * ```typescript
910
+ * logger.info('Order processed', { orderId: 'ord_123', status: 'completed' })
911
+ * ```
912
+ */
824
913
  info(message, data) {
825
914
  this.emit(message, __opentelemetry_api_logs.SeverityNumber.INFO, data);
826
915
  }
916
+ /**
917
+ * Log a warning-level message.
918
+ *
919
+ * @param message - Human-readable log message.
920
+ * @param data - Structured context attached as OTel log attributes.
921
+ * Use key-value objects to enable filtering and aggregation in your
922
+ * observability backend (e.g. Grafana, Datadog, New Relic).
923
+ *
924
+ * @example
925
+ * ```typescript
926
+ * logger.warn('Retry attempt', { attempt: 3, maxRetries: 5, endpoint: '/api/charge' })
927
+ * ```
928
+ */
827
929
  warn(message, data) {
828
930
  this.emit(message, __opentelemetry_api_logs.SeverityNumber.WARN, data);
829
931
  }
932
+ /**
933
+ * Log an error-level message.
934
+ *
935
+ * @param message - Human-readable log message.
936
+ * @param data - Structured context attached as OTel log attributes.
937
+ * Use key-value objects to enable filtering and aggregation in your
938
+ * observability backend (e.g. Grafana, Datadog, New Relic).
939
+ *
940
+ * @example
941
+ * ```typescript
942
+ * logger.error('Payment failed', { orderId: 'ord_123', gateway: 'stripe', errorCode: 'card_declined' })
943
+ * ```
944
+ */
830
945
  error(message, data) {
831
946
  this.emit(message, __opentelemetry_api_logs.SeverityNumber.ERROR, data);
832
947
  }
948
+ /**
949
+ * Log a debug-level message.
950
+ *
951
+ * @param message - Human-readable log message.
952
+ * @param data - Structured context attached as OTel log attributes.
953
+ * Use key-value objects to enable filtering and aggregation in your
954
+ * observability backend (e.g. Grafana, Datadog, New Relic).
955
+ *
956
+ * @example
957
+ * ```typescript
958
+ * logger.debug('Cache lookup', { key: 'user:42', hit: false })
959
+ * ```
960
+ */
833
961
  debug(message, data) {
834
962
  this.emit(message, __opentelemetry_api_logs.SeverityNumber.DEBUG, data);
835
963
  }
@@ -839,6 +967,7 @@ var Logger = class {
839
967
  exports.ChannelReader = ChannelReader;
840
968
  exports.ChannelWriter = ChannelWriter;
841
969
  exports.Logger = Logger;
970
+ exports.TriggerAction = TriggerAction;
842
971
  exports.__toESM = __toESM;
843
972
  exports.http = require_utils.http;
844
973
  exports.registerWorker = registerWorker;