@nice-code/action 0.2.6 → 0.2.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/build/index.js CHANGED
@@ -1,35 +1,3 @@
1
- var __create = Object.create;
2
- var __getProtoOf = Object.getPrototypeOf;
3
- var __defProp = Object.defineProperty;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- function __accessProp(key) {
7
- return this[key];
8
- }
9
- var __toESMCache_node;
10
- var __toESMCache_esm;
11
- var __toESM = (mod, isNodeMode, target) => {
12
- var canCache = mod != null && typeof mod === "object";
13
- if (canCache) {
14
- var cache = isNodeMode ? __toESMCache_node ??= new WeakMap : __toESMCache_esm ??= new WeakMap;
15
- var cached = cache.get(mod);
16
- if (cached)
17
- return cached;
18
- }
19
- target = mod != null ? __create(__getProtoOf(mod)) : {};
20
- const to = isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target;
21
- for (let key of __getOwnPropNames(mod))
22
- if (!__hasOwnProp.call(to, key))
23
- __defProp(to, key, {
24
- get: __accessProp.bind(mod, key),
25
- enumerable: true
26
- });
27
- if (canCache)
28
- cache.set(mod, to);
29
- return to;
30
- };
31
- var __commonJS = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
32
-
33
1
  // ../../node_modules/.bun/nanoid@5.1.9/node_modules/nanoid/url-alphabet/index.js
34
2
  var urlAlphabet = "useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";
35
3
 
@@ -3514,7 +3482,10 @@ class ActionRouter {
3514
3482
  specifiedClient: this._context.runtime.coordinate
3515
3483
  });
3516
3484
  }
3517
- throw new Error(`No route function found for action with domain "${action.domain}" and id "${action.id}".`);
3485
+ throw err_nice_action.fromId("no_action_execution_handler" /* no_action_execution_handler */, {
3486
+ domain: action.domain,
3487
+ actionId: action.id
3488
+ });
3518
3489
  }
3519
3490
  getRouteDataEntriesForActionOrThrow(action, context) {
3520
3491
  const entries = this.getRouteDataEntriesForAction(action);
@@ -3637,7 +3608,9 @@ class ActionRuntime {
3637
3608
  }
3638
3609
  updateRuntimeCoordinate(newCoordinate) {
3639
3610
  if (this._coordinate.envId !== newCoordinate.envId) {
3640
- throw new Error(`Can't update Runtime Coordinate with different "envId" properties (static environment id). "${this.coordinate.envId}" (current) !== ${newCoordinate.envId}`);
3611
+ throw err_nice_action.fromId("not_implemented" /* not_implemented */, {
3612
+ label: `updating RuntimeCoordinate with a different "envId" ("${this._coordinate.envId}" → "${newCoordinate.envId}")`
3613
+ });
3641
3614
  }
3642
3615
  this._coordinate = newCoordinate;
3643
3616
  this.apply();
@@ -7214,7 +7187,14 @@ class TransportHttp extends Transport {
7214
7187
  if (timedOut) {
7215
7188
  throw err_nice_transport.fromId("timeout" /* timeout */, { timeout });
7216
7189
  }
7217
- throw err3;
7190
+ if (err3 instanceof NiceError) {
7191
+ throw err3;
7192
+ }
7193
+ throw err_nice_transport.fromId("send_failed" /* send_failed */, {
7194
+ actionState: action.type,
7195
+ actionId: action.id,
7196
+ message: err3 instanceof Error ? err3.message : String(err3)
7197
+ }).withOriginError(err3 instanceof Error ? err3 : undefined);
7218
7198
  } finally {
7219
7199
  clearTimeout(timeoutId);
7220
7200
  unsubscribe();
@@ -7421,7 +7401,9 @@ class ActionExternalClientHandler extends ActionHandler {
7421
7401
  } else if (def.type === "custom" /* custom */) {
7422
7402
  this.transportManager.addTransport(new TransportCustom(def));
7423
7403
  } else {
7424
- throw new Error(`Unsupported transport type: ${def.type}`);
7404
+ throw err_nice_action.fromId("not_implemented" /* not_implemented */, {
7405
+ label: `transport type "${def.type}"`
7406
+ });
7425
7407
  }
7426
7408
  }
7427
7409
  }