@pristine-ts/common 2.0.3 → 2.0.5

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 (149) hide show
  1. package/dist/lib/cjs/contexts/event-context.js +5 -5
  2. package/dist/lib/cjs/contexts/event-context.js.map +1 -1
  3. package/dist/lib/cjs/decorators/decorators.js +1 -0
  4. package/dist/lib/cjs/decorators/decorators.js.map +1 -1
  5. package/dist/lib/cjs/decorators/traced.decorator.js +101 -0
  6. package/dist/lib/cjs/decorators/traced.decorator.js.map +1 -0
  7. package/dist/lib/cjs/enums/enums.js +1 -0
  8. package/dist/lib/cjs/enums/enums.js.map +1 -1
  9. package/dist/lib/cjs/enums/span-keyname.enum.js +34 -0
  10. package/dist/lib/cjs/enums/span-keyname.enum.js.map +1 -0
  11. package/dist/lib/cjs/errors/bad-request.error.js +15 -0
  12. package/dist/lib/cjs/errors/bad-request.error.js.map +1 -0
  13. package/dist/lib/cjs/errors/config.error.js +20 -0
  14. package/dist/lib/cjs/errors/config.error.js.map +1 -0
  15. package/dist/lib/cjs/errors/conflict.error.js +15 -0
  16. package/dist/lib/cjs/errors/conflict.error.js.map +1 -0
  17. package/dist/lib/cjs/errors/errors.js +14 -1
  18. package/dist/lib/cjs/errors/errors.js.map +1 -1
  19. package/dist/lib/cjs/errors/exit-code.enum.js +50 -0
  20. package/dist/lib/cjs/errors/exit-code.enum.js.map +1 -0
  21. package/dist/lib/cjs/errors/forbidden.error.js +15 -0
  22. package/dist/lib/cjs/errors/forbidden.error.js.map +1 -0
  23. package/dist/lib/cjs/errors/internal.error.js +19 -0
  24. package/dist/lib/cjs/errors/internal.error.js.map +1 -0
  25. package/dist/lib/cjs/errors/not-found.error.js +15 -0
  26. package/dist/lib/cjs/errors/not-found.error.js.map +1 -0
  27. package/dist/lib/cjs/errors/pristine-error-code.enum.js +37 -0
  28. package/dist/lib/cjs/errors/pristine-error-code.enum.js.map +1 -0
  29. package/dist/lib/cjs/errors/pristine-error-kind.enum.js +29 -0
  30. package/dist/lib/cjs/errors/pristine-error-kind.enum.js.map +1 -0
  31. package/dist/lib/cjs/errors/pristine-error-options.interface.js +3 -0
  32. package/dist/lib/cjs/errors/pristine-error-options.interface.js.map +1 -0
  33. package/dist/lib/cjs/errors/pristine.error.js +109 -0
  34. package/dist/lib/cjs/errors/pristine.error.js.map +1 -0
  35. package/dist/lib/cjs/errors/unauthorized.error.js +15 -0
  36. package/dist/lib/cjs/errors/unauthorized.error.js.map +1 -0
  37. package/dist/lib/cjs/errors/usage.error.js +18 -0
  38. package/dist/lib/cjs/errors/usage.error.js.map +1 -0
  39. package/dist/lib/cjs/errors/validation.error.js +15 -0
  40. package/dist/lib/cjs/errors/validation.error.js.map +1 -0
  41. package/dist/lib/cjs/interfaces/interfaces.js +1 -0
  42. package/dist/lib/cjs/interfaces/interfaces.js.map +1 -1
  43. package/dist/lib/cjs/interfaces/tracing-manager.interface.js +3 -0
  44. package/dist/lib/cjs/interfaces/tracing-manager.interface.js.map +1 -0
  45. package/dist/lib/cjs/managers/event-context.manager.js +9 -0
  46. package/dist/lib/cjs/managers/event-context.manager.js.map +1 -1
  47. package/dist/lib/cjs/models/models.js +4 -0
  48. package/dist/lib/cjs/models/models.js.map +1 -1
  49. package/dist/lib/cjs/models/span-event.model.js +28 -0
  50. package/dist/lib/cjs/models/span-event.model.js.map +1 -0
  51. package/dist/lib/cjs/models/span-lifecycle-owner.interface.js +3 -0
  52. package/dist/lib/cjs/models/span-lifecycle-owner.interface.js.map +1 -0
  53. package/dist/lib/cjs/models/span.model.js +79 -0
  54. package/dist/lib/cjs/models/span.model.js.map +1 -0
  55. package/dist/lib/cjs/models/trace.model.js +46 -0
  56. package/dist/lib/cjs/models/trace.model.js.map +1 -0
  57. package/dist/lib/cjs/tsconfig.cjs.tsbuildinfo +1 -1
  58. package/dist/lib/esm/contexts/event-context.js +5 -5
  59. package/dist/lib/esm/contexts/event-context.js.map +1 -1
  60. package/dist/lib/esm/decorators/decorators.js +1 -0
  61. package/dist/lib/esm/decorators/decorators.js.map +1 -1
  62. package/dist/lib/esm/decorators/traced.decorator.js +98 -0
  63. package/dist/lib/esm/decorators/traced.decorator.js.map +1 -0
  64. package/dist/lib/esm/enums/enums.js +1 -0
  65. package/dist/lib/esm/enums/enums.js.map +1 -1
  66. package/dist/lib/esm/enums/span-keyname.enum.js +31 -0
  67. package/dist/lib/esm/enums/span-keyname.enum.js.map +1 -0
  68. package/dist/lib/esm/errors/bad-request.error.js +11 -0
  69. package/dist/lib/esm/errors/bad-request.error.js.map +1 -0
  70. package/dist/lib/esm/errors/config.error.js +16 -0
  71. package/dist/lib/esm/errors/config.error.js.map +1 -0
  72. package/dist/lib/esm/errors/conflict.error.js +11 -0
  73. package/dist/lib/esm/errors/conflict.error.js.map +1 -0
  74. package/dist/lib/esm/errors/errors.js +14 -1
  75. package/dist/lib/esm/errors/errors.js.map +1 -1
  76. package/dist/lib/esm/errors/exit-code.enum.js +47 -0
  77. package/dist/lib/esm/errors/exit-code.enum.js.map +1 -0
  78. package/dist/lib/esm/errors/forbidden.error.js +11 -0
  79. package/dist/lib/esm/errors/forbidden.error.js.map +1 -0
  80. package/dist/lib/esm/errors/internal.error.js +15 -0
  81. package/dist/lib/esm/errors/internal.error.js.map +1 -0
  82. package/dist/lib/esm/errors/not-found.error.js +11 -0
  83. package/dist/lib/esm/errors/not-found.error.js.map +1 -0
  84. package/dist/lib/esm/errors/pristine-error-code.enum.js +34 -0
  85. package/dist/lib/esm/errors/pristine-error-code.enum.js.map +1 -0
  86. package/dist/lib/esm/errors/pristine-error-kind.enum.js +26 -0
  87. package/dist/lib/esm/errors/pristine-error-kind.enum.js.map +1 -0
  88. package/dist/lib/esm/errors/pristine-error-options.interface.js +2 -0
  89. package/dist/lib/esm/errors/pristine-error-options.interface.js.map +1 -0
  90. package/dist/lib/esm/errors/pristine.error.js +105 -0
  91. package/dist/lib/esm/errors/pristine.error.js.map +1 -0
  92. package/dist/lib/esm/errors/unauthorized.error.js +11 -0
  93. package/dist/lib/esm/errors/unauthorized.error.js.map +1 -0
  94. package/dist/lib/esm/errors/usage.error.js +14 -0
  95. package/dist/lib/esm/errors/usage.error.js.map +1 -0
  96. package/dist/lib/esm/errors/validation.error.js +11 -0
  97. package/dist/lib/esm/errors/validation.error.js.map +1 -0
  98. package/dist/lib/esm/interfaces/interfaces.js +1 -0
  99. package/dist/lib/esm/interfaces/interfaces.js.map +1 -1
  100. package/dist/lib/esm/interfaces/tracing-manager.interface.js +2 -0
  101. package/dist/lib/esm/interfaces/tracing-manager.interface.js.map +1 -0
  102. package/dist/lib/esm/managers/event-context.manager.js +9 -0
  103. package/dist/lib/esm/managers/event-context.manager.js.map +1 -1
  104. package/dist/lib/esm/models/models.js +4 -0
  105. package/dist/lib/esm/models/models.js.map +1 -1
  106. package/dist/lib/esm/models/span-event.model.js +24 -0
  107. package/dist/lib/esm/models/span-event.model.js.map +1 -0
  108. package/dist/lib/esm/models/span-lifecycle-owner.interface.js +2 -0
  109. package/dist/lib/esm/models/span-lifecycle-owner.interface.js.map +1 -0
  110. package/dist/lib/esm/models/span.model.js +75 -0
  111. package/dist/lib/esm/models/span.model.js.map +1 -0
  112. package/dist/lib/esm/models/trace.model.js +42 -0
  113. package/dist/lib/esm/models/trace.model.js.map +1 -0
  114. package/dist/lib/esm/tsconfig.tsbuildinfo +1 -1
  115. package/dist/types/contexts/event-context.d.ts +24 -9
  116. package/dist/types/decorators/decorators.d.ts +1 -0
  117. package/dist/types/decorators/traced.decorator.d.ts +40 -0
  118. package/dist/types/enums/enums.d.ts +1 -0
  119. package/dist/types/enums/span-keyname.enum.d.ts +29 -0
  120. package/dist/types/errors/bad-request.error.d.ts +8 -0
  121. package/dist/types/errors/config.error.d.ts +13 -0
  122. package/dist/types/errors/conflict.error.d.ts +8 -0
  123. package/dist/types/errors/errors.d.ts +14 -1
  124. package/dist/types/errors/exit-code.enum.d.ts +45 -0
  125. package/dist/types/errors/forbidden.error.d.ts +8 -0
  126. package/dist/types/errors/internal.error.d.ts +12 -0
  127. package/dist/types/errors/not-found.error.d.ts +8 -0
  128. package/dist/types/errors/pristine-error-code.enum.d.ts +32 -0
  129. package/dist/types/errors/pristine-error-kind.enum.d.ts +24 -0
  130. package/dist/types/errors/pristine-error-options.interface.d.ts +59 -0
  131. package/dist/types/errors/pristine.error.d.ts +78 -0
  132. package/dist/types/errors/unauthorized.error.d.ts +8 -0
  133. package/dist/types/errors/usage.error.d.ts +11 -0
  134. package/dist/types/errors/validation.error.d.ts +8 -0
  135. package/dist/types/interfaces/interfaces.d.ts +1 -0
  136. package/dist/types/interfaces/module.interface.d.ts +26 -0
  137. package/dist/types/interfaces/tracing-manager.interface.d.ts +78 -0
  138. package/dist/types/managers/event-context.manager.d.ts +4 -0
  139. package/dist/types/models/models.d.ts +4 -0
  140. package/dist/types/models/span-event.model.d.ts +30 -0
  141. package/dist/types/models/span-lifecycle-owner.interface.d.ts +11 -0
  142. package/dist/types/models/span.model.d.ts +82 -0
  143. package/dist/types/models/trace.model.d.ts +53 -0
  144. package/package.json +2 -2
  145. package/dist/lib/cjs/errors/loggable.error.js +0 -19
  146. package/dist/lib/cjs/errors/loggable.error.js.map +0 -1
  147. package/dist/lib/esm/errors/loggable.error.js +0 -15
  148. package/dist/lib/esm/errors/loggable.error.js.map +0 -1
  149. package/dist/types/errors/loggable.error.d.ts +0 -8
@@ -3,16 +3,16 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.EventContext = void 0;
4
4
  /**
5
5
  * Per-event runtime state — the framework's correlation primitives plus a handle to
6
- * the per-event DI child container. Propagated implicitly via `AsyncLocalStorage`
7
- * (managed by `EventContextManager`) so downstream code doesn't have to thread these
8
- * fields through every method signature.
6
+ * the per-event DI child container and the active trace. Propagated implicitly via
7
+ * `AsyncLocalStorage` (managed by `EventContextManager`) so downstream code doesn't
8
+ * have to thread these fields through every method signature.
9
9
  *
10
10
  * **Not to be confused with `ExecutionContextInterface` (in `@pristine-ts/core`):**
11
11
  * - `ExecutionContext` describes *where* the framework is running (AWS Lambda, CLI,
12
12
  * Express, etc.) — set once per `kernel.handle()` call, immutable, host-shaped.
13
13
  * - `EventContext` describes *which specific event* is being handled — set per event
14
- * in the pipeline, mutable (`traceId` fills in once tracing starts), correlation-
15
- * shaped.
14
+ * in the pipeline, mutable (`traceId` / `trace` fill in once tracing starts),
15
+ * correlation-shaped.
16
16
  *
17
17
  * One `kernel.handle()` call can produce multiple events (each event mapper can return
18
18
  * a list); each event gets its own `EventContext` instance.
@@ -1 +1 @@
1
- {"version":3,"file":"event-context.js","sourceRoot":"","sources":["../../../../src/contexts/event-context.ts"],"names":[],"mappings":";;;AAEA;;;;;;;;;;;;;;;GAeG;AACH,MAAa,YAAY;CAYxB;AAZD,oCAYC"}
1
+ {"version":3,"file":"event-context.js","sourceRoot":"","sources":["../../../../src/contexts/event-context.ts"],"names":[],"mappings":";;;AAIA;;;;;;;;;;;;;;;GAeG;AACH,MAAa,YAAY;CA2BxB;AA3BD,oCA2BC"}
@@ -17,4 +17,5 @@ Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./inject-config.decorator"), exports);
18
18
  __exportStar(require("./module-scoped.decorator"), exports);
19
19
  __exportStar(require("./tag.decorator"), exports);
20
+ __exportStar(require("./traced.decorator"), exports);
20
21
  //# sourceMappingURL=decorators.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"decorators.js","sourceRoot":"","sources":["../../../../src/decorators/decorators.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,4DAA0C;AAC1C,4DAA0C;AAC1C,kDAAgC"}
1
+ {"version":3,"file":"decorators.js","sourceRoot":"","sources":["../../../../src/decorators/decorators.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,4DAA0C;AAC1C,4DAA0C;AAC1C,kDAAgC;AAChC,qDAAmC"}
@@ -0,0 +1,101 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.traced = traced;
13
+ const event_context_manager_1 = require("../managers/event-context.manager");
14
+ /**
15
+ * Method decorator that wraps the decorated method in a span. The span is automatically
16
+ * ended when the method returns or throws, and the `TracingManager` is auto-resolved
17
+ * from the active `EventContext` — no need to inject it manually.
18
+ *
19
+ * ```ts
20
+ * class PaymentService {
21
+ * @traced() // span name = "PaymentService.charge"
22
+ * async charge(amount: number) { ... }
23
+ *
24
+ * @traced("payment.refund.action") // explicit name
25
+ * async refund(chargeId: string) { ... }
26
+ * }
27
+ * ```
28
+ *
29
+ * **Behavior outside an event context.** When the decorated method runs without an
30
+ * active `EventContext` (e.g. a unit test calling the method directly, or background
31
+ * work that escaped the event lifecycle), the decorator is a no-op — the original
32
+ * method runs unchanged. Tracing must never throw or alter semantics.
33
+ *
34
+ * **Sync methods become async.** The decorator awaits the wrapped method internally,
35
+ * so any decorated method returns a `Promise`. Decorating a sync method changes its
36
+ * signature visible to callers — apply `@traced` to methods you'd already be awaiting
37
+ * (DB calls, HTTP, expensive computations), not to tight sync helpers.
38
+ *
39
+ * **Type-level caveat.** TypeScript's parameter and method decorator types don't carry
40
+ * enough information for the compiler to verify that the wrapped method's return type
41
+ * is compatible with `Promise<T>`. The wrapper is type-safe at runtime; the call site's
42
+ * static types are unchanged. Pair with explicit `: Promise<T>` annotations on the
43
+ * method when you want the static type to match what's actually returned.
44
+ *
45
+ * **Lives in `@pristine-ts/common`** so any package can use it without taking a direct
46
+ * dep on `@pristine-ts/telemetry`. The actual `TracingManager` implementation still
47
+ * lives in telemetry; this decorator only reads the active manager from the
48
+ * EventContext when one is present.
49
+ *
50
+ * @param spanName Optional explicit name for the span. Defaults to
51
+ * `${ClassName}.${methodName}`.
52
+ */
53
+ function traced(spanName) {
54
+ return (target, propertyKey, descriptor) => {
55
+ var _a, _b, _c;
56
+ const original = descriptor.value;
57
+ if (typeof original !== "function") {
58
+ // Decorator was applied to something other than a method (a getter, a property
59
+ // with no initial value, etc.). Leave it alone — silently no-op rather than
60
+ // throw at decoration time.
61
+ return descriptor;
62
+ }
63
+ // Resolve a stable default name at decoration time. `target.constructor.name` is
64
+ // the class name for instance methods; for static methods, `target.name` is the
65
+ // class. We cover both via the fallback chain.
66
+ const className = (_c = (_b = (_a = target === null || target === void 0 ? void 0 : target.constructor) === null || _a === void 0 ? void 0 : _a.name) !== null && _b !== void 0 ? _b : target === null || target === void 0 ? void 0 : target.name) !== null && _c !== void 0 ? _c : "anonymous";
67
+ const resolvedName = spanName !== null && spanName !== void 0 ? spanName : `${className}.${String(propertyKey)}`;
68
+ descriptor.value = function (...args) {
69
+ return __awaiter(this, void 0, void 0, function* () {
70
+ const tracingManager = event_context_manager_1.EventContextManager.tracingManager();
71
+ if (tracingManager === undefined) {
72
+ // No active EventContext (unit test, background work, kernel boot before the
73
+ // pipeline runs). Run the original unchanged — tracing must never throw or
74
+ // alter semantics.
75
+ return yield original.apply(this, args);
76
+ }
77
+ const span = tracingManager.startSpan(resolvedName);
78
+ try {
79
+ return yield original.apply(this, args);
80
+ }
81
+ catch (error) {
82
+ // Annotate the span with error info so it surfaces in the rendered tree
83
+ // without forcing the caller to remember to add it themselves. `span.context`
84
+ // is string-typed by design (cheap to serialize), so we coerce.
85
+ if (error instanceof Error) {
86
+ span.context = Object.assign(Object.assign({}, span.context), { error: "true", errorName: error.name, errorMessage: error.message });
87
+ }
88
+ else {
89
+ span.context = Object.assign(Object.assign({}, span.context), { error: "true", errorName: "non-error-throw", errorMessage: String(error) });
90
+ }
91
+ throw error;
92
+ }
93
+ finally {
94
+ span.end();
95
+ }
96
+ });
97
+ };
98
+ return descriptor;
99
+ };
100
+ }
101
+ //# sourceMappingURL=traced.decorator.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"traced.decorator.js","sourceRoot":"","sources":["../../../../src/decorators/traced.decorator.ts"],"names":[],"mappings":";;;;;;;;;;;AAyCA,wBAuDC;AAhGD,6EAAsE;AAEtE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsCG;AACH,SAAgB,MAAM,CAAC,QAAiB;IACtC,OAAO,CAAC,MAAW,EAAE,WAA4B,EAAE,UAA8B,EAAE,EAAE;;QACnF,MAAM,QAAQ,GAAG,UAAU,CAAC,KAAK,CAAC;QAClC,IAAI,OAAO,QAAQ,KAAK,UAAU,EAAE,CAAC;YACnC,+EAA+E;YAC/E,4EAA4E;YAC5E,4BAA4B;YAC5B,OAAO,UAAU,CAAC;QACpB,CAAC;QAED,iFAAiF;QACjF,gFAAgF;QAChF,+CAA+C;QAC/C,MAAM,SAAS,GAAW,MAAA,MAAA,MAAA,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,WAAW,0CAAE,IAAI,mCAAI,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,IAAI,mCAAI,WAAW,CAAC;QACnF,MAAM,YAAY,GAAG,QAAQ,aAAR,QAAQ,cAAR,QAAQ,GAAI,GAAG,SAAS,IAAI,MAAM,CAAC,WAAW,CAAC,EAAE,CAAC;QAEvE,UAAU,CAAC,KAAK,GAAG,UAA+B,GAAG,IAAW;;gBAC9D,MAAM,cAAc,GAAG,2CAAmB,CAAC,cAAc,EAAE,CAAC;gBAC5D,IAAI,cAAc,KAAK,SAAS,EAAE,CAAC;oBACjC,6EAA6E;oBAC7E,2EAA2E;oBAC3E,mBAAmB;oBACnB,OAAO,MAAM,QAAQ,CAAC,KAAK,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;gBAC1C,CAAC;gBAED,MAAM,IAAI,GAAG,cAAc,CAAC,SAAS,CAAC,YAAY,CAAC,CAAC;gBACpD,IAAI,CAAC;oBACH,OAAO,MAAM,QAAQ,CAAC,KAAK,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;gBAC1C,CAAC;gBAAC,OAAO,KAAK,EAAE,CAAC;oBACf,wEAAwE;oBACxE,8EAA8E;oBAC9E,gEAAgE;oBAChE,IAAI,KAAK,YAAY,KAAK,EAAE,CAAC;wBAC3B,IAAI,CAAC,OAAO,mCACP,IAAI,CAAC,OAAO,KACf,KAAK,EAAE,MAAM,EACb,SAAS,EAAE,KAAK,CAAC,IAAI,EACrB,YAAY,EAAE,KAAK,CAAC,OAAO,GAC5B,CAAC;oBACJ,CAAC;yBAAM,CAAC;wBACN,IAAI,CAAC,OAAO,mCACP,IAAI,CAAC,OAAO,KACf,KAAK,EAAE,MAAM,EACb,SAAS,EAAE,iBAAiB,EAC5B,YAAY,EAAE,MAAM,CAAC,KAAK,CAAC,GAC5B,CAAC;oBACJ,CAAC;oBACD,MAAM,KAAK,CAAC;gBACd,CAAC;wBAAS,CAAC;oBACT,IAAI,CAAC,GAAG,EAAE,CAAC;gBACb,CAAC;YACH,CAAC;SAAA,CAAC;QAEF,OAAO,UAAU,CAAC;IACpB,CAAC,CAAC;AACJ,CAAC"}
@@ -18,4 +18,5 @@ __exportStar(require("./http-method.enum"), exports);
18
18
  __exportStar(require("./internal-container-parameter.enum"), exports);
19
19
  __exportStar(require("./metadata.enum"), exports);
20
20
  __exportStar(require("./service-definition-tag.enum"), exports);
21
+ __exportStar(require("./span-keyname.enum"), exports);
21
22
  //# sourceMappingURL=enums.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"enums.js","sourceRoot":"","sources":["../../../../src/enums/enums.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,qDAAmC;AACnC,sEAAoD;AACpD,kDAAgC;AAChC,gEAA8C"}
1
+ {"version":3,"file":"enums.js","sourceRoot":"","sources":["../../../../src/enums/enums.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,qDAAmC;AACnC,sEAAoD;AACpD,kDAAgC;AAChC,gEAA8C;AAC9C,sDAAoC"}
@@ -0,0 +1,34 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SpanKeynameEnum = void 0;
4
+ /**
5
+ * This enum is for the different span names that are integrated in Pristine.
6
+ */
7
+ var SpanKeynameEnum;
8
+ (function (SpanKeynameEnum) {
9
+ SpanKeynameEnum["ChildContainerCreation"] = "child.container.creation";
10
+ SpanKeynameEnum["ChildContainerRegistration"] = "child.container.registration";
11
+ SpanKeynameEnum["ConfigurationInitialization"] = "configuration.initialization";
12
+ SpanKeynameEnum["ErrorResponseInterceptors"] = "error.response.interceptors";
13
+ SpanKeynameEnum["EventDispatcherResolver"] = "event.dispatcher.resolver";
14
+ SpanKeynameEnum["EventExecution"] = "event.execution";
15
+ SpanKeynameEnum["EventInitialization"] = "event.initialization";
16
+ SpanKeynameEnum["EventPreMappingInterception"] = "event.pre-mapping.interception";
17
+ SpanKeynameEnum["EventPostMappingInterception"] = "event.post-mapping.interception";
18
+ SpanKeynameEnum["EventPreResponseMappingInterception"] = "event.pre-response-mapping.interception";
19
+ SpanKeynameEnum["EventPostResponseMappingInterception"] = "event.post-response-mapping.interception";
20
+ SpanKeynameEnum["EventMapping"] = "event.mapping";
21
+ SpanKeynameEnum["KernelInitialization"] = "kernel.initialization";
22
+ SpanKeynameEnum["ModuleInitialization"] = "module.initialization";
23
+ SpanKeynameEnum["ModuleInitializationImportModules"] = "module.initialization.import.modules";
24
+ SpanKeynameEnum["RequestExecution"] = "request.execution";
25
+ SpanKeynameEnum["RequestInterceptors"] = "request.interceptors";
26
+ SpanKeynameEnum["ResponseInterceptors"] = "response.interceptors";
27
+ SpanKeynameEnum["RootExecution"] = "root.execution";
28
+ SpanKeynameEnum["RouterControllerResolver"] = "router.controller.resolver";
29
+ SpanKeynameEnum["RouterFindMethodRouterNode"] = "router.find.method.router.node";
30
+ SpanKeynameEnum["RouterRequestAuthentication"] = "router.request.authentication";
31
+ SpanKeynameEnum["RouterRequestExecution"] = "router.request.execution";
32
+ SpanKeynameEnum["RouterSetup"] = "router.setup";
33
+ })(SpanKeynameEnum || (exports.SpanKeynameEnum = SpanKeynameEnum = {}));
34
+ //# sourceMappingURL=span-keyname.enum.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"span-keyname.enum.js","sourceRoot":"","sources":["../../../../src/enums/span-keyname.enum.ts"],"names":[],"mappings":";;;AAAA;;GAEG;AACH,IAAY,eAyBX;AAzBD,WAAY,eAAe;IACzB,sEAAmD,CAAA;IACnD,8EAA2D,CAAA;IAC3D,+EAA4D,CAAA;IAC5D,4EAAyD,CAAA;IACzD,wEAAqD,CAAA;IACrD,qDAAkC,CAAA;IAClC,+DAA4C,CAAA;IAC5C,iFAA8D,CAAA;IAC9D,mFAAgE,CAAA;IAChE,kGAA+E,CAAA;IAC/E,oGAAiF,CAAA;IACjF,iDAA8B,CAAA;IAC9B,iEAA8C,CAAA;IAC9C,iEAA8C,CAAA;IAC9C,6FAA0E,CAAA;IAC1E,yDAAsC,CAAA;IACtC,+DAA4C,CAAA;IAC5C,iEAA8C,CAAA;IAC9C,mDAAgC,CAAA;IAChC,0EAAuD,CAAA;IACvD,gFAA6D,CAAA;IAC7D,gFAA6D,CAAA;IAC7D,sEAAmD,CAAA;IACnD,+CAA4B,CAAA;AAC9B,CAAC,EAzBW,eAAe,+BAAf,eAAe,QAyB1B"}
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.BadRequestError = void 0;
4
+ const exit_code_enum_1 = require("./exit-code.enum");
5
+ const pristine_error_1 = require("./pristine.error");
6
+ const pristine_error_code_enum_1 = require("./pristine-error-code.enum");
7
+ const pristine_error_kind_enum_1 = require("./pristine-error-kind.enum");
8
+ /** 400. Caller sent malformed/invalid input. CLI exit `ExitCode.DataError` (65). */
9
+ class BadRequestError extends pristine_error_1.PristineError {
10
+ constructor(message, options = {}) {
11
+ super(message, Object.assign({ code: pristine_error_code_enum_1.PristineErrorCode.BadRequest, httpStatus: 400, exitCode: exit_code_enum_1.ExitCode.DataError, kind: pristine_error_kind_enum_1.PristineErrorKind.UserError }, options));
12
+ }
13
+ }
14
+ exports.BadRequestError = BadRequestError;
15
+ //# sourceMappingURL=bad-request.error.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bad-request.error.js","sourceRoot":"","sources":["../../../../src/errors/bad-request.error.ts"],"names":[],"mappings":";;;AAAA,qDAA0C;AAC1C,qDAA+C;AAC/C,yEAA6D;AAC7D,yEAA6D;AAK7D,oFAAoF;AACpF,MAAa,eAAgB,SAAQ,8BAAa;IAChD,YAAY,OAAe,EAAE,UAA2B,EAAE;QACxD,KAAK,CAAC,OAAO,kBACX,IAAI,EAAE,4CAAiB,CAAC,UAAU,EAAE,UAAU,EAAE,GAAG,EAAE,QAAQ,EAAE,yBAAQ,CAAC,SAAS,EACjF,IAAI,EAAE,4CAAiB,CAAC,SAAS,IAC9B,OAAO,EACV,CAAC;IACL,CAAC;CACF;AARD,0CAQC"}
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ConfigError = void 0;
4
+ const exit_code_enum_1 = require("./exit-code.enum");
5
+ const pristine_error_1 = require("./pristine.error");
6
+ const pristine_error_code_enum_1 = require("./pristine-error-code.enum");
7
+ const pristine_error_kind_enum_1 = require("./pristine-error-kind.enum");
8
+ /**
9
+ * Configuration loading / parsing / validation failure. No `httpStatus` — config errors
10
+ * shouldn't be exposed to HTTP callers, so the responder will treat them as 500 with
11
+ * sanitized message. CLI exit `ExitCode.Configuration` (78). Marked `SystemError` so the
12
+ * message isn't surfaced verbatim in production HTTP responses.
13
+ */
14
+ class ConfigError extends pristine_error_1.PristineError {
15
+ constructor(message, options = {}) {
16
+ super(message, Object.assign({ code: pristine_error_code_enum_1.PristineErrorCode.ConfigError, exitCode: exit_code_enum_1.ExitCode.Configuration, kind: pristine_error_kind_enum_1.PristineErrorKind.SystemError }, options));
17
+ }
18
+ }
19
+ exports.ConfigError = ConfigError;
20
+ //# sourceMappingURL=config.error.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.error.js","sourceRoot":"","sources":["../../../../src/errors/config.error.ts"],"names":[],"mappings":";;;AAAA,qDAA0C;AAC1C,qDAA+C;AAC/C,yEAA6D;AAC7D,yEAA6D;AAK7D;;;;;GAKG;AACH,MAAa,WAAY,SAAQ,8BAAa;IAC5C,YAAY,OAAe,EAAE,UAA2B,EAAE;QACxD,KAAK,CAAC,OAAO,kBACX,IAAI,EAAE,4CAAiB,CAAC,WAAW,EAAE,QAAQ,EAAE,yBAAQ,CAAC,aAAa,EACrE,IAAI,EAAE,4CAAiB,CAAC,WAAW,IAChC,OAAO,EACV,CAAC;IACL,CAAC;CACF;AARD,kCAQC"}
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ConflictError = void 0;
4
+ const exit_code_enum_1 = require("./exit-code.enum");
5
+ const pristine_error_1 = require("./pristine.error");
6
+ const pristine_error_code_enum_1 = require("./pristine-error-code.enum");
7
+ const pristine_error_kind_enum_1 = require("./pristine-error-kind.enum");
8
+ /** 409. Operation conflicts with existing state (duplicate, version mismatch, etc.). */
9
+ class ConflictError extends pristine_error_1.PristineError {
10
+ constructor(message, options = {}) {
11
+ super(message, Object.assign({ code: pristine_error_code_enum_1.PristineErrorCode.Conflict, httpStatus: 409, exitCode: exit_code_enum_1.ExitCode.Error, kind: pristine_error_kind_enum_1.PristineErrorKind.UserError }, options));
12
+ }
13
+ }
14
+ exports.ConflictError = ConflictError;
15
+ //# sourceMappingURL=conflict.error.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"conflict.error.js","sourceRoot":"","sources":["../../../../src/errors/conflict.error.ts"],"names":[],"mappings":";;;AAAA,qDAA0C;AAC1C,qDAA+C;AAC/C,yEAA6D;AAC7D,yEAA6D;AAK7D,wFAAwF;AACxF,MAAa,aAAc,SAAQ,8BAAa;IAC9C,YAAY,OAAe,EAAE,UAA2B,EAAE;QACxD,KAAK,CAAC,OAAO,kBACX,IAAI,EAAE,4CAAiB,CAAC,QAAQ,EAAE,UAAU,EAAE,GAAG,EAAE,QAAQ,EAAE,yBAAQ,CAAC,KAAK,EAC3E,IAAI,EAAE,4CAAiB,CAAC,SAAS,IAC9B,OAAO,EACV,CAAC;IACL,CAAC;CACF;AARD,sCAQC"}
@@ -14,5 +14,18 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./loggable.error"), exports);
17
+ __exportStar(require("./bad-request.error"), exports);
18
+ __exportStar(require("./config.error"), exports);
19
+ __exportStar(require("./conflict.error"), exports);
20
+ __exportStar(require("./exit-code.enum"), exports);
21
+ __exportStar(require("./forbidden.error"), exports);
22
+ __exportStar(require("./internal.error"), exports);
23
+ __exportStar(require("./not-found.error"), exports);
24
+ __exportStar(require("./pristine-error-code.enum"), exports);
25
+ __exportStar(require("./pristine-error-kind.enum"), exports);
26
+ __exportStar(require("./pristine-error-options.interface"), exports);
27
+ __exportStar(require("./pristine.error"), exports);
28
+ __exportStar(require("./unauthorized.error"), exports);
29
+ __exportStar(require("./usage.error"), exports);
30
+ __exportStar(require("./validation.error"), exports);
18
31
  //# sourceMappingURL=errors.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"errors.js","sourceRoot":"","sources":["../../../../src/errors/errors.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,mDAAiC"}
1
+ {"version":3,"file":"errors.js","sourceRoot":"","sources":["../../../../src/errors/errors.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,sDAAoC;AACpC,iDAA+B;AAC/B,mDAAiC;AACjC,mDAAiC;AACjC,oDAAkC;AAClC,mDAAiC;AACjC,oDAAkC;AAClC,6DAA2C;AAC3C,6DAA2C;AAC3C,qEAAmD;AACnD,mDAAiC;AACjC,uDAAqC;AACrC,gDAA8B;AAC9B,qDAAmC"}
@@ -0,0 +1,50 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ExitCode = void 0;
4
+ /**
5
+ * Standard process exit codes, drawn from BSD's `sysexits.h` conventions. Surfaced by
6
+ * `CliErrorReporter` and `PristineError.options.exitCode` so shell pipelines can branch on
7
+ * meaningful failure categories rather than the binary "0 or non-zero" distinction.
8
+ *
9
+ * **Use the enum for framework-standard codes.** Consumers can pass raw numbers for any
10
+ * custom exit code — `PristineErrorOptions.exitCode` is typed `ExitCode | number`.
11
+ *
12
+ * Note that exit codes ≥ 64 (`Usage` and above) follow the `sysexits.h` registered
13
+ * meanings; lower codes (1, etc.) are conventional but not standardized.
14
+ *
15
+ * ```ts
16
+ * throw new ConfigError("Missing DATABASE_URL", {
17
+ * exitCode: ExitCode.Configuration, // 78 — picked up by shells aware of sysexits.h
18
+ * });
19
+ *
20
+ * throw new UsageError("Unknown flag --foo", {
21
+ * exitCode: ExitCode.Usage, // 64
22
+ * });
23
+ * ```
24
+ */
25
+ var ExitCode;
26
+ (function (ExitCode) {
27
+ /** Successful termination. */
28
+ ExitCode[ExitCode["Success"] = 0] = "Success";
29
+ /** Generic error. Default fallback for user-facing errors that don't specify a code. */
30
+ ExitCode[ExitCode["Error"] = 1] = "Error";
31
+ /** Command-line usage error (`EX_USAGE`). Bad flags, missing required args, unknown commands. */
32
+ ExitCode[ExitCode["Usage"] = 64] = "Usage";
33
+ /** Input data malformed (`EX_DATAERR`). Validation failed, body unparseable. */
34
+ ExitCode[ExitCode["DataError"] = 65] = "DataError";
35
+ /** Internal software error (`EX_SOFTWARE`). Default fallback for system errors. */
36
+ ExitCode[ExitCode["Software"] = 70] = "Software";
37
+ /** Can't create user output file (`EX_CANTCREAT`). */
38
+ ExitCode[ExitCode["Cantcreat"] = 73] = "Cantcreat";
39
+ /** Input/output error (`EX_IOERR`). */
40
+ ExitCode[ExitCode["IoError"] = 74] = "IoError";
41
+ /** Temporary failure, retry might succeed (`EX_TEMPFAIL`). */
42
+ ExitCode[ExitCode["Temporary"] = 75] = "Temporary";
43
+ /** Remote error in protocol (`EX_PROTOCOL`). */
44
+ ExitCode[ExitCode["Protocol"] = 76] = "Protocol";
45
+ /** Permission denied (`EX_NOPERM`). Authentication / authorization failures. */
46
+ ExitCode[ExitCode["NoPermission"] = 77] = "NoPermission";
47
+ /** Configuration error (`EX_CONFIG`). Missing or invalid config. */
48
+ ExitCode[ExitCode["Configuration"] = 78] = "Configuration";
49
+ })(ExitCode || (exports.ExitCode = ExitCode = {}));
50
+ //# sourceMappingURL=exit-code.enum.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"exit-code.enum.js","sourceRoot":"","sources":["../../../../src/errors/exit-code.enum.ts"],"names":[],"mappings":";;;AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,IAAY,QAiCX;AAjCD,WAAY,QAAQ;IAClB,8BAA8B;IAC9B,6CAAmB,CAAA;IAEnB,wFAAwF;IACxF,yCAAmB,CAAA;IAEnB,iGAAiG;IACjG,0CAAoB,CAAA;IAEpB,gFAAgF;IAChF,kDAAoB,CAAA;IAEpB,mFAAmF;IACnF,gDAAoB,CAAA;IAEpB,sDAAsD;IACtD,kDAAoB,CAAA;IAEpB,uCAAuC;IACvC,8CAAoB,CAAA;IAEpB,8DAA8D;IAC9D,kDAAoB,CAAA;IAEpB,gDAAgD;IAChD,gDAAoB,CAAA;IAEpB,gFAAgF;IAChF,wDAAoB,CAAA;IAEpB,oEAAoE;IACpE,0DAAoB,CAAA;AACtB,CAAC,EAjCW,QAAQ,wBAAR,QAAQ,QAiCnB"}
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ForbiddenError = void 0;
4
+ const exit_code_enum_1 = require("./exit-code.enum");
5
+ const pristine_error_1 = require("./pristine.error");
6
+ const pristine_error_code_enum_1 = require("./pristine-error-code.enum");
7
+ const pristine_error_kind_enum_1 = require("./pristine-error-kind.enum");
8
+ /** 403. Caller is authenticated but lacks permission. CLI exit `ExitCode.NoPermission` (77). */
9
+ class ForbiddenError extends pristine_error_1.PristineError {
10
+ constructor(message = "Forbidden", options = {}) {
11
+ super(message, Object.assign({ code: pristine_error_code_enum_1.PristineErrorCode.Forbidden, httpStatus: 403, exitCode: exit_code_enum_1.ExitCode.NoPermission, kind: pristine_error_kind_enum_1.PristineErrorKind.UserError }, options));
12
+ }
13
+ }
14
+ exports.ForbiddenError = ForbiddenError;
15
+ //# sourceMappingURL=forbidden.error.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"forbidden.error.js","sourceRoot":"","sources":["../../../../src/errors/forbidden.error.ts"],"names":[],"mappings":";;;AAAA,qDAA0C;AAC1C,qDAA+C;AAC/C,yEAA6D;AAC7D,yEAA6D;AAK7D,gGAAgG;AAChG,MAAa,cAAe,SAAQ,8BAAa;IAC/C,YAAY,UAAkB,WAAW,EAAE,UAA2B,EAAE;QACtE,KAAK,CAAC,OAAO,kBACX,IAAI,EAAE,4CAAiB,CAAC,SAAS,EAAE,UAAU,EAAE,GAAG,EAAE,QAAQ,EAAE,yBAAQ,CAAC,YAAY,EACnF,IAAI,EAAE,4CAAiB,CAAC,SAAS,IAC9B,OAAO,EACV,CAAC;IACL,CAAC;CACF;AARD,wCAQC"}
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.InternalError = void 0;
4
+ const exit_code_enum_1 = require("./exit-code.enum");
5
+ const pristine_error_1 = require("./pristine.error");
6
+ const pristine_error_code_enum_1 = require("./pristine-error-code.enum");
7
+ const pristine_error_kind_enum_1 = require("./pristine-error-kind.enum");
8
+ /**
9
+ * Catch-all for framework/system bugs that shouldn't be exposed verbatim. 500.
10
+ * CLI exit `ExitCode.Software` (70). `SystemError` triggers message sanitization in
11
+ * production mode.
12
+ */
13
+ class InternalError extends pristine_error_1.PristineError {
14
+ constructor(message = "Internal error", options = {}) {
15
+ super(message, Object.assign({ code: pristine_error_code_enum_1.PristineErrorCode.InternalError, httpStatus: 500, exitCode: exit_code_enum_1.ExitCode.Software, kind: pristine_error_kind_enum_1.PristineErrorKind.SystemError }, options));
16
+ }
17
+ }
18
+ exports.InternalError = InternalError;
19
+ //# sourceMappingURL=internal.error.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"internal.error.js","sourceRoot":"","sources":["../../../../src/errors/internal.error.ts"],"names":[],"mappings":";;;AAAA,qDAA0C;AAC1C,qDAA+C;AAC/C,yEAA6D;AAC7D,yEAA6D;AAK7D;;;;GAIG;AACH,MAAa,aAAc,SAAQ,8BAAa;IAC9C,YAAY,UAAkB,gBAAgB,EAAE,UAA2B,EAAE;QAC3E,KAAK,CAAC,OAAO,kBACX,IAAI,EAAE,4CAAiB,CAAC,aAAa,EAAE,UAAU,EAAE,GAAG,EAAE,QAAQ,EAAE,yBAAQ,CAAC,QAAQ,EACnF,IAAI,EAAE,4CAAiB,CAAC,WAAW,IAChC,OAAO,EACV,CAAC;IACL,CAAC;CACF;AARD,sCAQC"}
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.NotFoundError = void 0;
4
+ const exit_code_enum_1 = require("./exit-code.enum");
5
+ const pristine_error_1 = require("./pristine.error");
6
+ const pristine_error_code_enum_1 = require("./pristine-error-code.enum");
7
+ const pristine_error_kind_enum_1 = require("./pristine-error-kind.enum");
8
+ /** 404. Resource doesn't exist. CLI exit `ExitCode.Error` (1). */
9
+ class NotFoundError extends pristine_error_1.PristineError {
10
+ constructor(message, options = {}) {
11
+ super(message, Object.assign({ code: pristine_error_code_enum_1.PristineErrorCode.NotFound, httpStatus: 404, exitCode: exit_code_enum_1.ExitCode.Error, kind: pristine_error_kind_enum_1.PristineErrorKind.UserError }, options));
12
+ }
13
+ }
14
+ exports.NotFoundError = NotFoundError;
15
+ //# sourceMappingURL=not-found.error.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"not-found.error.js","sourceRoot":"","sources":["../../../../src/errors/not-found.error.ts"],"names":[],"mappings":";;;AAAA,qDAA0C;AAC1C,qDAA+C;AAC/C,yEAA6D;AAC7D,yEAA6D;AAK7D,kEAAkE;AAClE,MAAa,aAAc,SAAQ,8BAAa;IAC9C,YAAY,OAAe,EAAE,UAA2B,EAAE;QACxD,KAAK,CAAC,OAAO,kBACX,IAAI,EAAE,4CAAiB,CAAC,QAAQ,EAAE,UAAU,EAAE,GAAG,EAAE,QAAQ,EAAE,yBAAQ,CAAC,KAAK,EAC3E,IAAI,EAAE,4CAAiB,CAAC,SAAS,IAC9B,OAAO,EACV,CAAC;IACL,CAAC;CACF;AARD,sCAQC"}
@@ -0,0 +1,37 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.PristineErrorCode = void 0;
4
+ /**
5
+ * Standard error-code catalog used across the framework. Each value is a `SCREAMING_SNAKE_CASE`
6
+ * slug surfaced in the HTTP response body (`{"code": ...}`) and on CLI stderr (`✗ CODE: ...`).
7
+ *
8
+ * **Use the enum members for framework-standard cases.** Consumers can add their own
9
+ * domain-specific codes by passing a plain string — `PristineErrorOptions.code` is typed
10
+ * `PristineErrorCode | string` so both the enum and free-form strings get autocomplete-
11
+ * friendly type checking.
12
+ *
13
+ * ```ts
14
+ * throw new PristineError("Token expired", {
15
+ * code: "TOKEN_EXPIRED", // consumer-defined code
16
+ * httpStatus: 401,
17
+ * });
18
+ *
19
+ * throw new PristineError("Item missing", {
20
+ * code: PristineErrorCode.NotFound, // framework-standard code
21
+ * httpStatus: 404,
22
+ * });
23
+ * ```
24
+ */
25
+ var PristineErrorCode;
26
+ (function (PristineErrorCode) {
27
+ PristineErrorCode["BadRequest"] = "BAD_REQUEST";
28
+ PristineErrorCode["Unauthorized"] = "UNAUTHORIZED";
29
+ PristineErrorCode["Forbidden"] = "FORBIDDEN";
30
+ PristineErrorCode["NotFound"] = "NOT_FOUND";
31
+ PristineErrorCode["Conflict"] = "CONFLICT";
32
+ PristineErrorCode["ValidationFailed"] = "VALIDATION_FAILED";
33
+ PristineErrorCode["ConfigError"] = "CONFIG_ERROR";
34
+ PristineErrorCode["UsageError"] = "USAGE_ERROR";
35
+ PristineErrorCode["InternalError"] = "INTERNAL_ERROR";
36
+ })(PristineErrorCode || (exports.PristineErrorCode = PristineErrorCode = {}));
37
+ //# sourceMappingURL=pristine-error-code.enum.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pristine-error-code.enum.js","sourceRoot":"","sources":["../../../../src/errors/pristine-error-code.enum.ts"],"names":[],"mappings":";;;AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,IAAY,iBAUX;AAVD,WAAY,iBAAiB;IAC3B,+CAAiC,CAAA;IACjC,kDAAkC,CAAA;IAClC,4CAA+B,CAAA;IAC/B,2CAA+B,CAAA;IAC/B,0CAA8B,CAAA;IAC9B,2DAAuC,CAAA;IACvC,iDAAkC,CAAA;IAClC,+CAAiC,CAAA;IACjC,qDAAoC,CAAA;AACtC,CAAC,EAVW,iBAAiB,iCAAjB,iBAAiB,QAU5B"}
@@ -0,0 +1,29 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.PristineErrorKind = void 0;
4
+ /**
5
+ * Categorizes a `PristineError` by who caused it. Replaces the older `expected: boolean`
6
+ * field, whose meaning ("expected by whom?") wasn't self-explanatory.
7
+ *
8
+ * The kind drives how the channel reporters render the error in production mode:
9
+ *
10
+ * - `UserError`: caller did something wrong. Message is safe to expose verbatim;
11
+ * structured details surface as-is. HTTP responses use the carried `httpStatus`
12
+ * (typically 4xx). CLI stderr shows the message and details.
13
+ *
14
+ * - `SystemError`: framework or downstream bug — not the caller's fault. In production
15
+ * mode the message is replaced with a generic "Internal Server Error" / "Internal Error"
16
+ * so internal details never leak to clients. Stack and cause chain are still logged
17
+ * internally via the LogHandler for operators. In development mode (`PRISTINE_ENV=dev`)
18
+ * the full message surfaces.
19
+ *
20
+ * Default is `UserError` — most thrown errors in framework and application code are caller-
21
+ * induced. `PristineError.from(unknown)` marks raw `Error` and non-Error throws as
22
+ * `SystemError` since they didn't opt into the typed contract.
23
+ */
24
+ var PristineErrorKind;
25
+ (function (PristineErrorKind) {
26
+ PristineErrorKind["UserError"] = "user-error";
27
+ PristineErrorKind["SystemError"] = "system-error";
28
+ })(PristineErrorKind || (exports.PristineErrorKind = PristineErrorKind = {}));
29
+ //# sourceMappingURL=pristine-error-kind.enum.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pristine-error-kind.enum.js","sourceRoot":"","sources":["../../../../src/errors/pristine-error-kind.enum.ts"],"names":[],"mappings":";;;AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AACH,IAAY,iBAGX;AAHD,WAAY,iBAAiB;IAC3B,6CAA0B,CAAA;IAC1B,iDAA4B,CAAA;AAC9B,CAAC,EAHW,iBAAiB,iCAAjB,iBAAiB,QAG5B"}
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=pristine-error-options.interface.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pristine-error-options.interface.js","sourceRoot":"","sources":["../../../../src/errors/pristine-error-options.interface.ts"],"names":[],"mappings":""}
@@ -0,0 +1,109 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.PristineError = void 0;
4
+ const pristine_error_kind_enum_1 = require("./pristine-error-kind.enum");
5
+ /**
6
+ * Single error base for the entire framework. Replaces the old `LoggableError` +
7
+ * `HttpError` + ad-hoc subclass hierarchy.
8
+ *
9
+ * **What it gives you**:
10
+ * - A structured `options` bag (`code`, `httpStatus`, `exitCode`, `details`, `cause`,
11
+ * `kind`) read by both the HTTP and CLI channel reporters.
12
+ * - Automatic `error.name = ClassName` for subclasses.
13
+ * - Automatic prototype-chain fix via `new.target.prototype` — subclasses never need to
14
+ * repeat the `Object.setPrototypeOf(this, FooError.prototype)` incantation, AND
15
+ * `instanceof` works correctly for direct/standard-library/custom subclasses at any
16
+ * depth (verified by spec).
17
+ * - Standard `Error.cause` propagation (Node 16.9+ native).
18
+ *
19
+ * **Subclass form** when a named class makes `instanceof` checks read better:
20
+ *
21
+ * ```ts
22
+ * export class TokenExpiredError extends UnauthorizedError {
23
+ * constructor(tokenId: string) {
24
+ * super("The token has expired", {
25
+ * code: "TOKEN_EXPIRED",
26
+ * details: { tokenId },
27
+ * });
28
+ * }
29
+ * }
30
+ * // ...
31
+ * try { ... }
32
+ * catch (e) { if (e instanceof TokenExpiredError) ... } // works.
33
+ * ```
34
+ *
35
+ * **Direct form** when the call site self-documents:
36
+ *
37
+ * ```ts
38
+ * throw new PristineError(`User '${id}' not found`, {
39
+ * code: PristineErrorCode.NotFound,
40
+ * httpStatus: 404,
41
+ * details: { resource: "User", id },
42
+ * });
43
+ * ```
44
+ *
45
+ * **Re-throw with enrichment** when catching, adding context, and re-throwing. Use the
46
+ * standard `cause` chain rather than mutating the original — this preserves the original
47
+ * error's identity for tooling that walks `error.cause`:
48
+ *
49
+ * ```ts
50
+ * try { await dispatcher.dispatch(event); }
51
+ * catch (cause) {
52
+ * throw new PristineError("Event dispatch failed", {
53
+ * code: "EVENT_DISPATCH_FAILED",
54
+ * kind: PristineErrorKind.SystemError,
55
+ * cause,
56
+ * details: { eventId: event.id },
57
+ * });
58
+ * }
59
+ * ```
60
+ */
61
+ class PristineError extends Error {
62
+ constructor(message, options = {}) {
63
+ // Use the standard Error.cause slot so any tooling that knows the standard chain
64
+ // (debuggers, V8's default Error formatting, OpenTelemetry's exception recording)
65
+ // picks it up automatically. We don't need a custom `originalError` slot.
66
+ super(message, { cause: options.cause });
67
+ // `new.target` is the actual class being constructed (subclass or PristineError
68
+ // itself). Using it for both `name` and `setPrototypeOf` means subclasses never need
69
+ // to repeat the boilerplate, and `instanceof` works correctly at every depth.
70
+ this.name = new.target.name;
71
+ Object.setPrototypeOf(this, new.target.prototype);
72
+ // `kind: UserError` is the default — most thrown errors are caller-induced. System
73
+ // errors get marked explicitly via `kind: PristineErrorKind.SystemError` (or by
74
+ // `PristineError.from` for unknown throws).
75
+ this.options = Object.assign({ kind: pristine_error_kind_enum_1.PristineErrorKind.UserError }, options);
76
+ }
77
+ /**
78
+ * Normalizes any thrown value into a `PristineError`. The chokepoint that every channel
79
+ * reporter funnels through before rendering, so the reporters never need to handle
80
+ * unknown shapes.
81
+ *
82
+ * - `PristineError` instances pass through unchanged.
83
+ * - `Error` instances are wrapped with `kind: SystemError` and propagated as `cause` —
84
+ * the wrapper preserves the original message and stack for `mode === Development`
85
+ * rendering.
86
+ * - Anything else (strings, numbers, `throw {someObject}`) is coerced via `String(...)`
87
+ * into a message with `kind: SystemError`.
88
+ *
89
+ * The standard `Error.cause` chain is preserved: if the input has a `cause`, it stays
90
+ * on the wrapper (which itself has the input as its cause), so a debugger walking
91
+ * `error.cause.cause.cause` sees the full history.
92
+ */
93
+ static from(error) {
94
+ if (error instanceof PristineError) {
95
+ return error;
96
+ }
97
+ if (error instanceof Error) {
98
+ return new PristineError(error.message, {
99
+ cause: error,
100
+ kind: pristine_error_kind_enum_1.PristineErrorKind.SystemError,
101
+ });
102
+ }
103
+ return new PristineError(String(error), {
104
+ kind: pristine_error_kind_enum_1.PristineErrorKind.SystemError,
105
+ });
106
+ }
107
+ }
108
+ exports.PristineError = PristineError;
109
+ //# sourceMappingURL=pristine.error.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pristine.error.js","sourceRoot":"","sources":["../../../../src/errors/pristine.error.ts"],"names":[],"mappings":";;;AAAA,yEAA6D;AAG7D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuDG;AACH,MAAa,aAAc,SAAQ,KAAK;IAGtC,YAAY,OAAe,EAAE,UAAgC,EAAE;QAC7D,iFAAiF;QACjF,kFAAkF;QAClF,0EAA0E;QAC1E,KAAK,CAAC,OAAO,EAAE,EAAE,KAAK,EAAE,OAAO,CAAC,KAAK,EAAE,CAAC,CAAC;QAEzC,gFAAgF;QAChF,qFAAqF;QACrF,8EAA8E;QAC9E,IAAI,CAAC,IAAI,GAAG,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC;QAC5B,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,GAAG,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;QAElD,mFAAmF;QACnF,gFAAgF;QAChF,4CAA4C;QAC5C,IAAI,CAAC,OAAO,mBAAK,IAAI,EAAE,4CAAiB,CAAC,SAAS,IAAK,OAAO,CAAE,CAAC;IACnE,CAAC;IAED;;;;;;;;;;;;;;;OAeG;IACH,MAAM,CAAC,IAAI,CAAC,KAAc;QACxB,IAAI,KAAK,YAAY,aAAa,EAAE,CAAC;YACnC,OAAO,KAAK,CAAC;QACf,CAAC;QACD,IAAI,KAAK,YAAY,KAAK,EAAE,CAAC;YAC3B,OAAO,IAAI,aAAa,CAAC,KAAK,CAAC,OAAO,EAAE;gBACtC,KAAK,EAAE,KAAK;gBACZ,IAAI,EAAE,4CAAiB,CAAC,WAAW;aACpC,CAAC,CAAC;QACL,CAAC;QACD,OAAO,IAAI,aAAa,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE;YACtC,IAAI,EAAE,4CAAiB,CAAC,WAAW;SACpC,CAAC,CAAC;IACL,CAAC;CACF;AAnDD,sCAmDC"}