@pristine-ts/common 2.0.4 → 2.0.6
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/dist/lib/cjs/contexts/event-context.js.map +1 -1
- package/dist/lib/cjs/decorators/traced.decorator.js +38 -2
- package/dist/lib/cjs/decorators/traced.decorator.js.map +1 -1
- package/dist/lib/cjs/errors/bad-request.error.js +15 -0
- package/dist/lib/cjs/errors/bad-request.error.js.map +1 -0
- package/dist/lib/cjs/errors/config.error.js +20 -0
- package/dist/lib/cjs/errors/config.error.js.map +1 -0
- package/dist/lib/cjs/errors/conflict.error.js +15 -0
- package/dist/lib/cjs/errors/conflict.error.js.map +1 -0
- package/dist/lib/cjs/errors/errors.js +14 -1
- package/dist/lib/cjs/errors/errors.js.map +1 -1
- package/dist/lib/cjs/errors/exit-code.enum.js +50 -0
- package/dist/lib/cjs/errors/exit-code.enum.js.map +1 -0
- package/dist/lib/cjs/errors/forbidden.error.js +15 -0
- package/dist/lib/cjs/errors/forbidden.error.js.map +1 -0
- package/dist/lib/cjs/errors/internal.error.js +19 -0
- package/dist/lib/cjs/errors/internal.error.js.map +1 -0
- package/dist/lib/cjs/errors/not-found.error.js +15 -0
- package/dist/lib/cjs/errors/not-found.error.js.map +1 -0
- package/dist/lib/cjs/errors/pristine-error-code.enum.js +37 -0
- package/dist/lib/cjs/errors/pristine-error-code.enum.js.map +1 -0
- package/dist/lib/cjs/errors/pristine-error-kind.enum.js +29 -0
- package/dist/lib/cjs/errors/pristine-error-kind.enum.js.map +1 -0
- package/dist/lib/cjs/errors/pristine-error-options.interface.js +3 -0
- package/dist/lib/cjs/errors/pristine-error-options.interface.js.map +1 -0
- package/dist/lib/cjs/errors/pristine.error.js +109 -0
- package/dist/lib/cjs/errors/pristine.error.js.map +1 -0
- package/dist/lib/cjs/errors/unauthorized.error.js +15 -0
- package/dist/lib/cjs/errors/unauthorized.error.js.map +1 -0
- package/dist/lib/cjs/errors/usage.error.js +18 -0
- package/dist/lib/cjs/errors/usage.error.js.map +1 -0
- package/dist/lib/cjs/errors/validation.error.js +15 -0
- package/dist/lib/cjs/errors/validation.error.js.map +1 -0
- package/dist/lib/cjs/managers/event-context.manager.js +9 -0
- package/dist/lib/cjs/managers/event-context.manager.js.map +1 -1
- package/dist/lib/cjs/models/models.js +2 -1
- package/dist/lib/cjs/models/models.js.map +1 -1
- package/dist/lib/cjs/models/span-lifecycle-owner.interface.js +3 -0
- package/dist/lib/cjs/models/span-lifecycle-owner.interface.js.map +1 -0
- package/dist/lib/cjs/models/span-marker.model.js +34 -0
- package/dist/lib/cjs/models/span-marker.model.js.map +1 -0
- package/dist/lib/cjs/models/span.model.js +5 -2
- package/dist/lib/cjs/models/span.model.js.map +1 -1
- package/dist/lib/cjs/tsconfig.cjs.tsbuildinfo +1 -1
- package/dist/lib/cjs/utils/utils.js +0 -1
- package/dist/lib/cjs/utils/utils.js.map +1 -1
- package/dist/lib/esm/contexts/event-context.js.map +1 -1
- package/dist/lib/esm/decorators/traced.decorator.js +38 -2
- package/dist/lib/esm/decorators/traced.decorator.js.map +1 -1
- package/dist/lib/esm/errors/bad-request.error.js +11 -0
- package/dist/lib/esm/errors/bad-request.error.js.map +1 -0
- package/dist/lib/esm/errors/config.error.js +16 -0
- package/dist/lib/esm/errors/config.error.js.map +1 -0
- package/dist/lib/esm/errors/conflict.error.js +11 -0
- package/dist/lib/esm/errors/conflict.error.js.map +1 -0
- package/dist/lib/esm/errors/errors.js +14 -1
- package/dist/lib/esm/errors/errors.js.map +1 -1
- package/dist/lib/esm/errors/exit-code.enum.js +47 -0
- package/dist/lib/esm/errors/exit-code.enum.js.map +1 -0
- package/dist/lib/esm/errors/forbidden.error.js +11 -0
- package/dist/lib/esm/errors/forbidden.error.js.map +1 -0
- package/dist/lib/esm/errors/internal.error.js +15 -0
- package/dist/lib/esm/errors/internal.error.js.map +1 -0
- package/dist/lib/esm/errors/not-found.error.js +11 -0
- package/dist/lib/esm/errors/not-found.error.js.map +1 -0
- package/dist/lib/esm/errors/pristine-error-code.enum.js +34 -0
- package/dist/lib/esm/errors/pristine-error-code.enum.js.map +1 -0
- package/dist/lib/esm/errors/pristine-error-kind.enum.js +26 -0
- package/dist/lib/esm/errors/pristine-error-kind.enum.js.map +1 -0
- package/dist/lib/esm/errors/pristine-error-options.interface.js +2 -0
- package/dist/lib/esm/errors/pristine-error-options.interface.js.map +1 -0
- package/dist/lib/esm/errors/pristine.error.js +105 -0
- package/dist/lib/esm/errors/pristine.error.js.map +1 -0
- package/dist/lib/esm/errors/unauthorized.error.js +11 -0
- package/dist/lib/esm/errors/unauthorized.error.js.map +1 -0
- package/dist/lib/esm/errors/usage.error.js +14 -0
- package/dist/lib/esm/errors/usage.error.js.map +1 -0
- package/dist/lib/esm/errors/validation.error.js +11 -0
- package/dist/lib/esm/errors/validation.error.js.map +1 -0
- package/dist/lib/esm/managers/event-context.manager.js +9 -0
- package/dist/lib/esm/managers/event-context.manager.js.map +1 -1
- package/dist/lib/esm/models/models.js +2 -1
- package/dist/lib/esm/models/models.js.map +1 -1
- package/dist/lib/esm/models/span-lifecycle-owner.interface.js +2 -0
- package/dist/lib/esm/models/span-lifecycle-owner.interface.js.map +1 -0
- package/dist/lib/esm/models/span-marker.model.js +30 -0
- package/dist/lib/esm/models/span-marker.model.js.map +1 -0
- package/dist/lib/esm/models/span.model.js +5 -2
- package/dist/lib/esm/models/span.model.js.map +1 -1
- package/dist/lib/esm/tsconfig.tsbuildinfo +1 -1
- package/dist/lib/esm/utils/utils.js +0 -1
- package/dist/lib/esm/utils/utils.js.map +1 -1
- package/dist/types/contexts/event-context.d.ts +12 -4
- package/dist/types/errors/bad-request.error.d.ts +8 -0
- package/dist/types/errors/config.error.d.ts +13 -0
- package/dist/types/errors/conflict.error.d.ts +8 -0
- package/dist/types/errors/errors.d.ts +14 -1
- package/dist/types/errors/exit-code.enum.d.ts +45 -0
- package/dist/types/errors/forbidden.error.d.ts +8 -0
- package/dist/types/errors/internal.error.d.ts +12 -0
- package/dist/types/errors/not-found.error.d.ts +8 -0
- package/dist/types/errors/pristine-error-code.enum.d.ts +32 -0
- package/dist/types/errors/pristine-error-kind.enum.d.ts +24 -0
- package/dist/types/errors/pristine-error-options.interface.d.ts +59 -0
- package/dist/types/errors/pristine.error.d.ts +78 -0
- package/dist/types/errors/unauthorized.error.d.ts +8 -0
- package/dist/types/errors/usage.error.d.ts +11 -0
- package/dist/types/errors/validation.error.d.ts +8 -0
- package/dist/types/interfaces/module.interface.d.ts +26 -0
- package/dist/types/interfaces/tracing-manager.interface.d.ts +7 -7
- package/dist/types/managers/event-context.manager.d.ts +4 -0
- package/dist/types/models/models.d.ts +2 -1
- package/dist/types/models/span-lifecycle-owner.interface.d.ts +11 -0
- package/dist/types/models/span-marker.model.d.ts +36 -0
- package/dist/types/models/span.model.d.ts +7 -12
- package/dist/types/utils/utils.d.ts +0 -1
- package/package.json +2 -2
- package/dist/lib/cjs/errors/loggable.error.js +0 -19
- package/dist/lib/cjs/errors/loggable.error.js.map +0 -1
- package/dist/lib/cjs/models/span-event.model.js +0 -28
- package/dist/lib/cjs/models/span-event.model.js.map +0 -1
- package/dist/lib/cjs/utils/span-runner.js +0 -117
- package/dist/lib/cjs/utils/span-runner.js.map +0 -1
- package/dist/lib/esm/errors/loggable.error.js +0 -15
- package/dist/lib/esm/errors/loggable.error.js.map +0 -1
- package/dist/lib/esm/models/span-event.model.js +0 -24
- package/dist/lib/esm/models/span-event.model.js.map +0 -1
- package/dist/lib/esm/utils/span-runner.js +0 -113
- package/dist/lib/esm/utils/span-runner.js.map +0 -1
- package/dist/types/errors/loggable.error.d.ts +0 -8
- package/dist/types/models/span-event.model.d.ts +0 -30
- package/dist/types/utils/span-runner.d.ts +0 -55
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"traced.decorator.js","sourceRoot":"","sources":["../../../../src/decorators/traced.decorator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,
|
|
1
|
+
{"version":3,"file":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,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"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { ExitCode } from "./exit-code.enum";
|
|
2
|
+
import { PristineError } from "./pristine.error";
|
|
3
|
+
import { PristineErrorCode } from "./pristine-error-code.enum";
|
|
4
|
+
import { PristineErrorKind } from "./pristine-error-kind.enum";
|
|
5
|
+
/** 400. Caller sent malformed/invalid input. CLI exit `ExitCode.DataError` (65). */
|
|
6
|
+
export class BadRequestError extends PristineError {
|
|
7
|
+
constructor(message, options = {}) {
|
|
8
|
+
super(message, Object.assign({ code: PristineErrorCode.BadRequest, httpStatus: 400, exitCode: ExitCode.DataError, kind: PristineErrorKind.UserError }, options));
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
//# 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,OAAO,EAAC,QAAQ,EAAC,MAAM,kBAAkB,CAAC;AAC1C,OAAO,EAAC,aAAa,EAAC,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAC,iBAAiB,EAAC,MAAM,4BAA4B,CAAC;AAC7D,OAAO,EAAC,iBAAiB,EAAC,MAAM,4BAA4B,CAAC;AAK7D,oFAAoF;AACpF,MAAM,OAAO,eAAgB,SAAQ,aAAa;IAChD,YAAY,OAAe,EAAE,UAA2B,EAAE;QACxD,KAAK,CAAC,OAAO,kBACX,IAAI,EAAE,iBAAiB,CAAC,UAAU,EAAE,UAAU,EAAE,GAAG,EAAE,QAAQ,EAAE,QAAQ,CAAC,SAAS,EACjF,IAAI,EAAE,iBAAiB,CAAC,SAAS,IAC9B,OAAO,EACV,CAAC;IACL,CAAC;CACF"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { ExitCode } from "./exit-code.enum";
|
|
2
|
+
import { PristineError } from "./pristine.error";
|
|
3
|
+
import { PristineErrorCode } from "./pristine-error-code.enum";
|
|
4
|
+
import { PristineErrorKind } from "./pristine-error-kind.enum";
|
|
5
|
+
/**
|
|
6
|
+
* Configuration loading / parsing / validation failure. No `httpStatus` — config errors
|
|
7
|
+
* shouldn't be exposed to HTTP callers, so the responder will treat them as 500 with
|
|
8
|
+
* sanitized message. CLI exit `ExitCode.Configuration` (78). Marked `SystemError` so the
|
|
9
|
+
* message isn't surfaced verbatim in production HTTP responses.
|
|
10
|
+
*/
|
|
11
|
+
export class ConfigError extends PristineError {
|
|
12
|
+
constructor(message, options = {}) {
|
|
13
|
+
super(message, Object.assign({ code: PristineErrorCode.ConfigError, exitCode: ExitCode.Configuration, kind: PristineErrorKind.SystemError }, options));
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
//# 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,OAAO,EAAC,QAAQ,EAAC,MAAM,kBAAkB,CAAC;AAC1C,OAAO,EAAC,aAAa,EAAC,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAC,iBAAiB,EAAC,MAAM,4BAA4B,CAAC;AAC7D,OAAO,EAAC,iBAAiB,EAAC,MAAM,4BAA4B,CAAC;AAK7D;;;;;GAKG;AACH,MAAM,OAAO,WAAY,SAAQ,aAAa;IAC5C,YAAY,OAAe,EAAE,UAA2B,EAAE;QACxD,KAAK,CAAC,OAAO,kBACX,IAAI,EAAE,iBAAiB,CAAC,WAAW,EAAE,QAAQ,EAAE,QAAQ,CAAC,aAAa,EACrE,IAAI,EAAE,iBAAiB,CAAC,WAAW,IAChC,OAAO,EACV,CAAC;IACL,CAAC;CACF"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { ExitCode } from "./exit-code.enum";
|
|
2
|
+
import { PristineError } from "./pristine.error";
|
|
3
|
+
import { PristineErrorCode } from "./pristine-error-code.enum";
|
|
4
|
+
import { PristineErrorKind } from "./pristine-error-kind.enum";
|
|
5
|
+
/** 409. Operation conflicts with existing state (duplicate, version mismatch, etc.). */
|
|
6
|
+
export class ConflictError extends PristineError {
|
|
7
|
+
constructor(message, options = {}) {
|
|
8
|
+
super(message, Object.assign({ code: PristineErrorCode.Conflict, httpStatus: 409, exitCode: ExitCode.Error, kind: PristineErrorKind.UserError }, options));
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
//# 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,OAAO,EAAC,QAAQ,EAAC,MAAM,kBAAkB,CAAC;AAC1C,OAAO,EAAC,aAAa,EAAC,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAC,iBAAiB,EAAC,MAAM,4BAA4B,CAAC;AAC7D,OAAO,EAAC,iBAAiB,EAAC,MAAM,4BAA4B,CAAC;AAK7D,wFAAwF;AACxF,MAAM,OAAO,aAAc,SAAQ,aAAa;IAC9C,YAAY,OAAe,EAAE,UAA2B,EAAE;QACxD,KAAK,CAAC,OAAO,kBACX,IAAI,EAAE,iBAAiB,CAAC,QAAQ,EAAE,UAAU,EAAE,GAAG,EAAE,QAAQ,EAAE,QAAQ,CAAC,KAAK,EAC3E,IAAI,EAAE,iBAAiB,CAAC,SAAS,IAC9B,OAAO,EACV,CAAC;IACL,CAAC;CACF"}
|
|
@@ -1,2 +1,15 @@
|
|
|
1
|
-
export * from "./
|
|
1
|
+
export * from "./bad-request.error";
|
|
2
|
+
export * from "./config.error";
|
|
3
|
+
export * from "./conflict.error";
|
|
4
|
+
export * from "./exit-code.enum";
|
|
5
|
+
export * from "./forbidden.error";
|
|
6
|
+
export * from "./internal.error";
|
|
7
|
+
export * from "./not-found.error";
|
|
8
|
+
export * from "./pristine-error-code.enum";
|
|
9
|
+
export * from "./pristine-error-kind.enum";
|
|
10
|
+
export * from "./pristine-error-options.interface";
|
|
11
|
+
export * from "./pristine.error";
|
|
12
|
+
export * from "./unauthorized.error";
|
|
13
|
+
export * from "./usage.error";
|
|
14
|
+
export * from "./validation.error";
|
|
2
15
|
//# sourceMappingURL=errors.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../../../../src/errors/errors.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAC"}
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../../../../src/errors/errors.ts"],"names":[],"mappings":"AAAA,cAAc,qBAAqB,CAAC;AACpC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,kBAAkB,CAAC;AACjC,cAAc,kBAAkB,CAAC;AACjC,cAAc,mBAAmB,CAAC;AAClC,cAAc,kBAAkB,CAAC;AACjC,cAAc,mBAAmB,CAAC;AAClC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,4BAA4B,CAAC;AAC3C,cAAc,oCAAoC,CAAC;AACnD,cAAc,kBAAkB,CAAC;AACjC,cAAc,sBAAsB,CAAC;AACrC,cAAc,eAAe,CAAC;AAC9B,cAAc,oBAAoB,CAAC"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Standard process exit codes, drawn from BSD's `sysexits.h` conventions. Surfaced by
|
|
3
|
+
* `CliErrorReporter` and `PristineError.options.exitCode` so shell pipelines can branch on
|
|
4
|
+
* meaningful failure categories rather than the binary "0 or non-zero" distinction.
|
|
5
|
+
*
|
|
6
|
+
* **Use the enum for framework-standard codes.** Consumers can pass raw numbers for any
|
|
7
|
+
* custom exit code — `PristineErrorOptions.exitCode` is typed `ExitCode | number`.
|
|
8
|
+
*
|
|
9
|
+
* Note that exit codes ≥ 64 (`Usage` and above) follow the `sysexits.h` registered
|
|
10
|
+
* meanings; lower codes (1, etc.) are conventional but not standardized.
|
|
11
|
+
*
|
|
12
|
+
* ```ts
|
|
13
|
+
* throw new ConfigError("Missing DATABASE_URL", {
|
|
14
|
+
* exitCode: ExitCode.Configuration, // 78 — picked up by shells aware of sysexits.h
|
|
15
|
+
* });
|
|
16
|
+
*
|
|
17
|
+
* throw new UsageError("Unknown flag --foo", {
|
|
18
|
+
* exitCode: ExitCode.Usage, // 64
|
|
19
|
+
* });
|
|
20
|
+
* ```
|
|
21
|
+
*/
|
|
22
|
+
export var ExitCode;
|
|
23
|
+
(function (ExitCode) {
|
|
24
|
+
/** Successful termination. */
|
|
25
|
+
ExitCode[ExitCode["Success"] = 0] = "Success";
|
|
26
|
+
/** Generic error. Default fallback for user-facing errors that don't specify a code. */
|
|
27
|
+
ExitCode[ExitCode["Error"] = 1] = "Error";
|
|
28
|
+
/** Command-line usage error (`EX_USAGE`). Bad flags, missing required args, unknown commands. */
|
|
29
|
+
ExitCode[ExitCode["Usage"] = 64] = "Usage";
|
|
30
|
+
/** Input data malformed (`EX_DATAERR`). Validation failed, body unparseable. */
|
|
31
|
+
ExitCode[ExitCode["DataError"] = 65] = "DataError";
|
|
32
|
+
/** Internal software error (`EX_SOFTWARE`). Default fallback for system errors. */
|
|
33
|
+
ExitCode[ExitCode["Software"] = 70] = "Software";
|
|
34
|
+
/** Can't create user output file (`EX_CANTCREAT`). */
|
|
35
|
+
ExitCode[ExitCode["Cantcreat"] = 73] = "Cantcreat";
|
|
36
|
+
/** Input/output error (`EX_IOERR`). */
|
|
37
|
+
ExitCode[ExitCode["IoError"] = 74] = "IoError";
|
|
38
|
+
/** Temporary failure, retry might succeed (`EX_TEMPFAIL`). */
|
|
39
|
+
ExitCode[ExitCode["Temporary"] = 75] = "Temporary";
|
|
40
|
+
/** Remote error in protocol (`EX_PROTOCOL`). */
|
|
41
|
+
ExitCode[ExitCode["Protocol"] = 76] = "Protocol";
|
|
42
|
+
/** Permission denied (`EX_NOPERM`). Authentication / authorization failures. */
|
|
43
|
+
ExitCode[ExitCode["NoPermission"] = 77] = "NoPermission";
|
|
44
|
+
/** Configuration error (`EX_CONFIG`). Missing or invalid config. */
|
|
45
|
+
ExitCode[ExitCode["Configuration"] = 78] = "Configuration";
|
|
46
|
+
})(ExitCode || (ExitCode = {}));
|
|
47
|
+
//# 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,MAAM,CAAN,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,KAAR,QAAQ,QAiCnB"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { ExitCode } from "./exit-code.enum";
|
|
2
|
+
import { PristineError } from "./pristine.error";
|
|
3
|
+
import { PristineErrorCode } from "./pristine-error-code.enum";
|
|
4
|
+
import { PristineErrorKind } from "./pristine-error-kind.enum";
|
|
5
|
+
/** 403. Caller is authenticated but lacks permission. CLI exit `ExitCode.NoPermission` (77). */
|
|
6
|
+
export class ForbiddenError extends PristineError {
|
|
7
|
+
constructor(message = "Forbidden", options = {}) {
|
|
8
|
+
super(message, Object.assign({ code: PristineErrorCode.Forbidden, httpStatus: 403, exitCode: ExitCode.NoPermission, kind: PristineErrorKind.UserError }, options));
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
//# 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,OAAO,EAAC,QAAQ,EAAC,MAAM,kBAAkB,CAAC;AAC1C,OAAO,EAAC,aAAa,EAAC,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAC,iBAAiB,EAAC,MAAM,4BAA4B,CAAC;AAC7D,OAAO,EAAC,iBAAiB,EAAC,MAAM,4BAA4B,CAAC;AAK7D,gGAAgG;AAChG,MAAM,OAAO,cAAe,SAAQ,aAAa;IAC/C,YAAY,UAAkB,WAAW,EAAE,UAA2B,EAAE;QACtE,KAAK,CAAC,OAAO,kBACX,IAAI,EAAE,iBAAiB,CAAC,SAAS,EAAE,UAAU,EAAE,GAAG,EAAE,QAAQ,EAAE,QAAQ,CAAC,YAAY,EACnF,IAAI,EAAE,iBAAiB,CAAC,SAAS,IAC9B,OAAO,EACV,CAAC;IACL,CAAC;CACF"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { ExitCode } from "./exit-code.enum";
|
|
2
|
+
import { PristineError } from "./pristine.error";
|
|
3
|
+
import { PristineErrorCode } from "./pristine-error-code.enum";
|
|
4
|
+
import { PristineErrorKind } from "./pristine-error-kind.enum";
|
|
5
|
+
/**
|
|
6
|
+
* Catch-all for framework/system bugs that shouldn't be exposed verbatim. 500.
|
|
7
|
+
* CLI exit `ExitCode.Software` (70). `SystemError` triggers message sanitization in
|
|
8
|
+
* production mode.
|
|
9
|
+
*/
|
|
10
|
+
export class InternalError extends PristineError {
|
|
11
|
+
constructor(message = "Internal error", options = {}) {
|
|
12
|
+
super(message, Object.assign({ code: PristineErrorCode.InternalError, httpStatus: 500, exitCode: ExitCode.Software, kind: PristineErrorKind.SystemError }, options));
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
//# 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,OAAO,EAAC,QAAQ,EAAC,MAAM,kBAAkB,CAAC;AAC1C,OAAO,EAAC,aAAa,EAAC,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAC,iBAAiB,EAAC,MAAM,4BAA4B,CAAC;AAC7D,OAAO,EAAC,iBAAiB,EAAC,MAAM,4BAA4B,CAAC;AAK7D;;;;GAIG;AACH,MAAM,OAAO,aAAc,SAAQ,aAAa;IAC9C,YAAY,UAAkB,gBAAgB,EAAE,UAA2B,EAAE;QAC3E,KAAK,CAAC,OAAO,kBACX,IAAI,EAAE,iBAAiB,CAAC,aAAa,EAAE,UAAU,EAAE,GAAG,EAAE,QAAQ,EAAE,QAAQ,CAAC,QAAQ,EACnF,IAAI,EAAE,iBAAiB,CAAC,WAAW,IAChC,OAAO,EACV,CAAC;IACL,CAAC;CACF"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { ExitCode } from "./exit-code.enum";
|
|
2
|
+
import { PristineError } from "./pristine.error";
|
|
3
|
+
import { PristineErrorCode } from "./pristine-error-code.enum";
|
|
4
|
+
import { PristineErrorKind } from "./pristine-error-kind.enum";
|
|
5
|
+
/** 404. Resource doesn't exist. CLI exit `ExitCode.Error` (1). */
|
|
6
|
+
export class NotFoundError extends PristineError {
|
|
7
|
+
constructor(message, options = {}) {
|
|
8
|
+
super(message, Object.assign({ code: PristineErrorCode.NotFound, httpStatus: 404, exitCode: ExitCode.Error, kind: PristineErrorKind.UserError }, options));
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
//# 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,OAAO,EAAC,QAAQ,EAAC,MAAM,kBAAkB,CAAC;AAC1C,OAAO,EAAC,aAAa,EAAC,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAC,iBAAiB,EAAC,MAAM,4BAA4B,CAAC;AAC7D,OAAO,EAAC,iBAAiB,EAAC,MAAM,4BAA4B,CAAC;AAK7D,kEAAkE;AAClE,MAAM,OAAO,aAAc,SAAQ,aAAa;IAC9C,YAAY,OAAe,EAAE,UAA2B,EAAE;QACxD,KAAK,CAAC,OAAO,kBACX,IAAI,EAAE,iBAAiB,CAAC,QAAQ,EAAE,UAAU,EAAE,GAAG,EAAE,QAAQ,EAAE,QAAQ,CAAC,KAAK,EAC3E,IAAI,EAAE,iBAAiB,CAAC,SAAS,IAC9B,OAAO,EACV,CAAC;IACL,CAAC;CACF"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Standard error-code catalog used across the framework. Each value is a `SCREAMING_SNAKE_CASE`
|
|
3
|
+
* slug surfaced in the HTTP response body (`{"code": ...}`) and on CLI stderr (`✗ CODE: ...`).
|
|
4
|
+
*
|
|
5
|
+
* **Use the enum members for framework-standard cases.** Consumers can add their own
|
|
6
|
+
* domain-specific codes by passing a plain string — `PristineErrorOptions.code` is typed
|
|
7
|
+
* `PristineErrorCode | string` so both the enum and free-form strings get autocomplete-
|
|
8
|
+
* friendly type checking.
|
|
9
|
+
*
|
|
10
|
+
* ```ts
|
|
11
|
+
* throw new PristineError("Token expired", {
|
|
12
|
+
* code: "TOKEN_EXPIRED", // consumer-defined code
|
|
13
|
+
* httpStatus: 401,
|
|
14
|
+
* });
|
|
15
|
+
*
|
|
16
|
+
* throw new PristineError("Item missing", {
|
|
17
|
+
* code: PristineErrorCode.NotFound, // framework-standard code
|
|
18
|
+
* httpStatus: 404,
|
|
19
|
+
* });
|
|
20
|
+
* ```
|
|
21
|
+
*/
|
|
22
|
+
export var PristineErrorCode;
|
|
23
|
+
(function (PristineErrorCode) {
|
|
24
|
+
PristineErrorCode["BadRequest"] = "BAD_REQUEST";
|
|
25
|
+
PristineErrorCode["Unauthorized"] = "UNAUTHORIZED";
|
|
26
|
+
PristineErrorCode["Forbidden"] = "FORBIDDEN";
|
|
27
|
+
PristineErrorCode["NotFound"] = "NOT_FOUND";
|
|
28
|
+
PristineErrorCode["Conflict"] = "CONFLICT";
|
|
29
|
+
PristineErrorCode["ValidationFailed"] = "VALIDATION_FAILED";
|
|
30
|
+
PristineErrorCode["ConfigError"] = "CONFIG_ERROR";
|
|
31
|
+
PristineErrorCode["UsageError"] = "USAGE_ERROR";
|
|
32
|
+
PristineErrorCode["InternalError"] = "INTERNAL_ERROR";
|
|
33
|
+
})(PristineErrorCode || (PristineErrorCode = {}));
|
|
34
|
+
//# 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,MAAM,CAAN,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,KAAjB,iBAAiB,QAU5B"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Categorizes a `PristineError` by who caused it. Replaces the older `expected: boolean`
|
|
3
|
+
* field, whose meaning ("expected by whom?") wasn't self-explanatory.
|
|
4
|
+
*
|
|
5
|
+
* The kind drives how the channel reporters render the error in production mode:
|
|
6
|
+
*
|
|
7
|
+
* - `UserError`: caller did something wrong. Message is safe to expose verbatim;
|
|
8
|
+
* structured details surface as-is. HTTP responses use the carried `httpStatus`
|
|
9
|
+
* (typically 4xx). CLI stderr shows the message and details.
|
|
10
|
+
*
|
|
11
|
+
* - `SystemError`: framework or downstream bug — not the caller's fault. In production
|
|
12
|
+
* mode the message is replaced with a generic "Internal Server Error" / "Internal Error"
|
|
13
|
+
* so internal details never leak to clients. Stack and cause chain are still logged
|
|
14
|
+
* internally via the LogHandler for operators. In development mode (`PRISTINE_ENV=dev`)
|
|
15
|
+
* the full message surfaces.
|
|
16
|
+
*
|
|
17
|
+
* Default is `UserError` — most thrown errors in framework and application code are caller-
|
|
18
|
+
* induced. `PristineError.from(unknown)` marks raw `Error` and non-Error throws as
|
|
19
|
+
* `SystemError` since they didn't opt into the typed contract.
|
|
20
|
+
*/
|
|
21
|
+
export var PristineErrorKind;
|
|
22
|
+
(function (PristineErrorKind) {
|
|
23
|
+
PristineErrorKind["UserError"] = "user-error";
|
|
24
|
+
PristineErrorKind["SystemError"] = "system-error";
|
|
25
|
+
})(PristineErrorKind || (PristineErrorKind = {}));
|
|
26
|
+
//# 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,MAAM,CAAN,IAAY,iBAGX;AAHD,WAAY,iBAAiB;IAC3B,6CAA0B,CAAA;IAC1B,iDAA4B,CAAA;AAC9B,CAAC,EAHW,iBAAiB,KAAjB,iBAAiB,QAG5B"}
|
|
@@ -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,105 @@
|
|
|
1
|
+
import { PristineErrorKind } from "./pristine-error-kind.enum";
|
|
2
|
+
/**
|
|
3
|
+
* Single error base for the entire framework. Replaces the old `LoggableError` +
|
|
4
|
+
* `HttpError` + ad-hoc subclass hierarchy.
|
|
5
|
+
*
|
|
6
|
+
* **What it gives you**:
|
|
7
|
+
* - A structured `options` bag (`code`, `httpStatus`, `exitCode`, `details`, `cause`,
|
|
8
|
+
* `kind`) read by both the HTTP and CLI channel reporters.
|
|
9
|
+
* - Automatic `error.name = ClassName` for subclasses.
|
|
10
|
+
* - Automatic prototype-chain fix via `new.target.prototype` — subclasses never need to
|
|
11
|
+
* repeat the `Object.setPrototypeOf(this, FooError.prototype)` incantation, AND
|
|
12
|
+
* `instanceof` works correctly for direct/standard-library/custom subclasses at any
|
|
13
|
+
* depth (verified by spec).
|
|
14
|
+
* - Standard `Error.cause` propagation (Node 16.9+ native).
|
|
15
|
+
*
|
|
16
|
+
* **Subclass form** when a named class makes `instanceof` checks read better:
|
|
17
|
+
*
|
|
18
|
+
* ```ts
|
|
19
|
+
* export class TokenExpiredError extends UnauthorizedError {
|
|
20
|
+
* constructor(tokenId: string) {
|
|
21
|
+
* super("The token has expired", {
|
|
22
|
+
* code: "TOKEN_EXPIRED",
|
|
23
|
+
* details: { tokenId },
|
|
24
|
+
* });
|
|
25
|
+
* }
|
|
26
|
+
* }
|
|
27
|
+
* // ...
|
|
28
|
+
* try { ... }
|
|
29
|
+
* catch (e) { if (e instanceof TokenExpiredError) ... } // works.
|
|
30
|
+
* ```
|
|
31
|
+
*
|
|
32
|
+
* **Direct form** when the call site self-documents:
|
|
33
|
+
*
|
|
34
|
+
* ```ts
|
|
35
|
+
* throw new PristineError(`User '${id}' not found`, {
|
|
36
|
+
* code: PristineErrorCode.NotFound,
|
|
37
|
+
* httpStatus: 404,
|
|
38
|
+
* details: { resource: "User", id },
|
|
39
|
+
* });
|
|
40
|
+
* ```
|
|
41
|
+
*
|
|
42
|
+
* **Re-throw with enrichment** when catching, adding context, and re-throwing. Use the
|
|
43
|
+
* standard `cause` chain rather than mutating the original — this preserves the original
|
|
44
|
+
* error's identity for tooling that walks `error.cause`:
|
|
45
|
+
*
|
|
46
|
+
* ```ts
|
|
47
|
+
* try { await dispatcher.dispatch(event); }
|
|
48
|
+
* catch (cause) {
|
|
49
|
+
* throw new PristineError("Event dispatch failed", {
|
|
50
|
+
* code: "EVENT_DISPATCH_FAILED",
|
|
51
|
+
* kind: PristineErrorKind.SystemError,
|
|
52
|
+
* cause,
|
|
53
|
+
* details: { eventId: event.id },
|
|
54
|
+
* });
|
|
55
|
+
* }
|
|
56
|
+
* ```
|
|
57
|
+
*/
|
|
58
|
+
export class PristineError extends Error {
|
|
59
|
+
constructor(message, options = {}) {
|
|
60
|
+
// Use the standard Error.cause slot so any tooling that knows the standard chain
|
|
61
|
+
// (debuggers, V8's default Error formatting, OpenTelemetry's exception recording)
|
|
62
|
+
// picks it up automatically. We don't need a custom `originalError` slot.
|
|
63
|
+
super(message, { cause: options.cause });
|
|
64
|
+
// `new.target` is the actual class being constructed (subclass or PristineError
|
|
65
|
+
// itself). Using it for both `name` and `setPrototypeOf` means subclasses never need
|
|
66
|
+
// to repeat the boilerplate, and `instanceof` works correctly at every depth.
|
|
67
|
+
this.name = new.target.name;
|
|
68
|
+
Object.setPrototypeOf(this, new.target.prototype);
|
|
69
|
+
// `kind: UserError` is the default — most thrown errors are caller-induced. System
|
|
70
|
+
// errors get marked explicitly via `kind: PristineErrorKind.SystemError` (or by
|
|
71
|
+
// `PristineError.from` for unknown throws).
|
|
72
|
+
this.options = Object.assign({ kind: PristineErrorKind.UserError }, options);
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Normalizes any thrown value into a `PristineError`. The chokepoint that every channel
|
|
76
|
+
* reporter funnels through before rendering, so the reporters never need to handle
|
|
77
|
+
* unknown shapes.
|
|
78
|
+
*
|
|
79
|
+
* - `PristineError` instances pass through unchanged.
|
|
80
|
+
* - `Error` instances are wrapped with `kind: SystemError` and propagated as `cause` —
|
|
81
|
+
* the wrapper preserves the original message and stack for `mode === Development`
|
|
82
|
+
* rendering.
|
|
83
|
+
* - Anything else (strings, numbers, `throw {someObject}`) is coerced via `String(...)`
|
|
84
|
+
* into a message with `kind: SystemError`.
|
|
85
|
+
*
|
|
86
|
+
* The standard `Error.cause` chain is preserved: if the input has a `cause`, it stays
|
|
87
|
+
* on the wrapper (which itself has the input as its cause), so a debugger walking
|
|
88
|
+
* `error.cause.cause.cause` sees the full history.
|
|
89
|
+
*/
|
|
90
|
+
static from(error) {
|
|
91
|
+
if (error instanceof PristineError) {
|
|
92
|
+
return error;
|
|
93
|
+
}
|
|
94
|
+
if (error instanceof Error) {
|
|
95
|
+
return new PristineError(error.message, {
|
|
96
|
+
cause: error,
|
|
97
|
+
kind: PristineErrorKind.SystemError,
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
return new PristineError(String(error), {
|
|
101
|
+
kind: PristineErrorKind.SystemError,
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
//# sourceMappingURL=pristine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AC,CAAC;IACL,CAAC;CACF"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { ExitCode } from "./exit-code.enum";
|
|
2
|
+
import { PristineError } from "./pristine.error";
|
|
3
|
+
import { PristineErrorCode } from "./pristine-error-code.enum";
|
|
4
|
+
import { PristineErrorKind } from "./pristine-error-kind.enum";
|
|
5
|
+
/** 401. Caller is not authenticated. CLI exit `ExitCode.NoPermission` (77). */
|
|
6
|
+
export class UnauthorizedError extends PristineError {
|
|
7
|
+
constructor(message = "Unauthorized", options = {}) {
|
|
8
|
+
super(message, Object.assign({ code: PristineErrorCode.Unauthorized, httpStatus: 401, exitCode: ExitCode.NoPermission, kind: PristineErrorKind.UserError }, options));
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
//# sourceMappingURL=unauthorized.error.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"unauthorized.error.js","sourceRoot":"","sources":["../../../../src/errors/unauthorized.error.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,QAAQ,EAAC,MAAM,kBAAkB,CAAC;AAC1C,OAAO,EAAC,aAAa,EAAC,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAC,iBAAiB,EAAC,MAAM,4BAA4B,CAAC;AAC7D,OAAO,EAAC,iBAAiB,EAAC,MAAM,4BAA4B,CAAC;AAK7D,+EAA+E;AAC/E,MAAM,OAAO,iBAAkB,SAAQ,aAAa;IAClD,YAAY,UAAkB,cAAc,EAAE,UAA2B,EAAE;QACzE,KAAK,CAAC,OAAO,kBACX,IAAI,EAAE,iBAAiB,CAAC,YAAY,EAAE,UAAU,EAAE,GAAG,EAAE,QAAQ,EAAE,QAAQ,CAAC,YAAY,EACtF,IAAI,EAAE,iBAAiB,CAAC,SAAS,IAC9B,OAAO,EACV,CAAC;IACL,CAAC;CACF"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { ExitCode } from "./exit-code.enum";
|
|
2
|
+
import { PristineError } from "./pristine.error";
|
|
3
|
+
import { PristineErrorCode } from "./pristine-error-code.enum";
|
|
4
|
+
import { PristineErrorKind } from "./pristine-error-kind.enum";
|
|
5
|
+
/**
|
|
6
|
+
* CLI-only — bad command-line usage (wrong flag, missing required arg, unknown command).
|
|
7
|
+
* No `httpStatus`. CLI exit `ExitCode.Usage` (64).
|
|
8
|
+
*/
|
|
9
|
+
export class UsageError extends PristineError {
|
|
10
|
+
constructor(message, options = {}) {
|
|
11
|
+
super(message, Object.assign({ code: PristineErrorCode.UsageError, exitCode: ExitCode.Usage, kind: PristineErrorKind.UserError }, options));
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=usage.error.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"usage.error.js","sourceRoot":"","sources":["../../../../src/errors/usage.error.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,QAAQ,EAAC,MAAM,kBAAkB,CAAC;AAC1C,OAAO,EAAC,aAAa,EAAC,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAC,iBAAiB,EAAC,MAAM,4BAA4B,CAAC;AAC7D,OAAO,EAAC,iBAAiB,EAAC,MAAM,4BAA4B,CAAC;AAK7D;;;GAGG;AACH,MAAM,OAAO,UAAW,SAAQ,aAAa;IAC3C,YAAY,OAAe,EAAE,UAA2B,EAAE;QACxD,KAAK,CAAC,OAAO,kBACX,IAAI,EAAE,iBAAiB,CAAC,UAAU,EAAE,QAAQ,EAAE,QAAQ,CAAC,KAAK,EAC5D,IAAI,EAAE,iBAAiB,CAAC,SAAS,IAC9B,OAAO,EACV,CAAC;IACL,CAAC;CACF"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { ExitCode } from "./exit-code.enum";
|
|
2
|
+
import { PristineError } from "./pristine.error";
|
|
3
|
+
import { PristineErrorCode } from "./pristine-error-code.enum";
|
|
4
|
+
import { PristineErrorKind } from "./pristine-error-kind.enum";
|
|
5
|
+
/** 422. Input parsed but failed semantic validation. CLI exit `ExitCode.DataError` (65). */
|
|
6
|
+
export class ValidationError extends PristineError {
|
|
7
|
+
constructor(message, options = {}) {
|
|
8
|
+
super(message, Object.assign({ code: PristineErrorCode.ValidationFailed, httpStatus: 422, exitCode: ExitCode.DataError, kind: PristineErrorKind.UserError }, options));
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
//# sourceMappingURL=validation.error.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validation.error.js","sourceRoot":"","sources":["../../../../src/errors/validation.error.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,QAAQ,EAAC,MAAM,kBAAkB,CAAC;AAC1C,OAAO,EAAC,aAAa,EAAC,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAC,iBAAiB,EAAC,MAAM,4BAA4B,CAAC;AAC7D,OAAO,EAAC,iBAAiB,EAAC,MAAM,4BAA4B,CAAC;AAK7D,4FAA4F;AAC5F,MAAM,OAAO,eAAgB,SAAQ,aAAa;IAChD,YAAY,OAAe,EAAE,UAA2B,EAAE;QACxD,KAAK,CAAC,OAAO,kBACX,IAAI,EAAE,iBAAiB,CAAC,gBAAgB,EAAE,UAAU,EAAE,GAAG,EAAE,QAAQ,EAAE,QAAQ,CAAC,SAAS,EACvF,IAAI,EAAE,iBAAiB,CAAC,SAAS,IAC9B,OAAO,EACV,CAAC;IACL,CAAC;CACF"}
|
|
@@ -53,6 +53,11 @@ let EventContextManager = EventContextManager_1 = class EventContextManager {
|
|
|
53
53
|
var _a;
|
|
54
54
|
return (_a = this.current()) === null || _a === void 0 ? void 0 : _a.container;
|
|
55
55
|
}
|
|
56
|
+
/** Convenience: the `TracingManager` that owns this event's trace, or `undefined`. */
|
|
57
|
+
tracingManager() {
|
|
58
|
+
var _a;
|
|
59
|
+
return (_a = this.current()) === null || _a === void 0 ? void 0 : _a.tracingManager;
|
|
60
|
+
}
|
|
56
61
|
/**
|
|
57
62
|
* Returns a wrapped version of `fn` that restores the current context on call. Use
|
|
58
63
|
* when you need to spawn work that escapes the natural async chain (e.g. a callback
|
|
@@ -88,6 +93,10 @@ let EventContextManager = EventContextManager_1 = class EventContextManager {
|
|
|
88
93
|
var _a;
|
|
89
94
|
return (_a = EventContextManager_1.current()) === null || _a === void 0 ? void 0 : _a.container;
|
|
90
95
|
}
|
|
96
|
+
static tracingManager() {
|
|
97
|
+
var _a;
|
|
98
|
+
return (_a = EventContextManager_1.current()) === null || _a === void 0 ? void 0 : _a.tracingManager;
|
|
99
|
+
}
|
|
91
100
|
static bind(fn) {
|
|
92
101
|
const ctx = EventContextManager_1.current();
|
|
93
102
|
if (ctx === undefined)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"event-context.manager.js","sourceRoot":"","sources":["../../../../src/managers/event-context.manager.ts"],"names":[],"mappings":";;;;;;;AAAA,OAAO,EAAC,iBAAiB,EAAC,MAAM,aAAa,CAAC;AAC9C,OAAO,EAAsB,UAAU,EAAC,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"event-context.manager.js","sourceRoot":"","sources":["../../../../src/managers/event-context.manager.ts"],"names":[],"mappings":";;;;;;;AAAA,OAAO,EAAC,iBAAiB,EAAC,MAAM,aAAa,CAAC;AAC9C,OAAO,EAAsB,UAAU,EAAC,MAAM,UAAU,CAAC;AAIzD;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEI,IAAM,mBAAmB,2BAAzB,MAAM,mBAAmB;IAU9B,GAAG,CAAI,GAAiB,EAAE,EAAwB;QAChD,OAAO,qBAAmB,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC;IAC9C,CAAC;IAED;iDAC6C;IAC7C,OAAO;QACL,OAAO,qBAAmB,CAAC,GAAG,CAAC,QAAQ,EAAE,CAAC;IAC5C,CAAC;IAED,wEAAwE;IACxE,OAAO;;QACL,OAAO,MAAA,IAAI,CAAC,OAAO,EAAE,0CAAE,OAAO,CAAC;IACjC,C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,MAAM,CAAC,IAAI,CAAoC,EAAK;QAClD,MAAM,GAAG,GAAG,qBAAmB,CAAC,OAAO,EAAE,CAAC;QAC1C,IAAI,GAAG,KAAK,SAAS;YAAE,OAAO,EAAE,CAAC;QACjC,MAAM,GAAG,GAAG,qBAAmB,CAAC,GAAG,CAAC;QACpC,OAAO,CAAC,CAAC,GAAG,IAAW,EAAE,EAAE,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,EAAE,GAAG,EAAE,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,CAAC,CAAM,CAAC;IACpE,CAAC;;AArFuB,uBAAG,GAAG,IAAI,iBAAiB,EAAgB,AAAxC,CAAyC;AADzD,mBAAmB;IAD/B,UAAU,EAAE;GACA,mBAAmB,CAuF/B"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export * from "./request";
|
|
2
2
|
export * from "./response";
|
|
3
|
-
export * from "./span-
|
|
3
|
+
export * from "./span-lifecycle-owner.interface";
|
|
4
|
+
export * from "./span-marker.model";
|
|
4
5
|
export * from "./span.model";
|
|
5
6
|
export * from "./trace.model";
|
|
6
7
|
//# sourceMappingURL=models.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"models.js","sourceRoot":"","sources":["../../../../src/models/models.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAC;AAC1B,cAAc,YAAY,CAAC;AAC3B,cAAc,
|
|
1
|
+
{"version":3,"file":"models.js","sourceRoot":"","sources":["../../../../src/models/models.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAC;AAC1B,cAAc,YAAY,CAAC;AAC3B,cAAc,kCAAkC,CAAC;AACjD,cAAc,qBAAqB,CAAC;AACpC,cAAc,cAAc,CAAC;AAC7B,cAAc,eAAe,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"span-lifecycle-owner.interface.js","sourceRoot":"","sources":["../../../../src/models/span-lifecycle-owner.interface.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A named, timestamped marker attached to a `Span`. Represents a noteworthy moment
|
|
3
|
+
* inside the span's lifetime that doesn't warrant a child span of its own — e.g.
|
|
4
|
+
* "validation passed", "rate limit check ok", "found 50 rows in DB".
|
|
5
|
+
*
|
|
6
|
+
* **Markers are instants, not durations.** They carry a single timestamp; they have no
|
|
7
|
+
* children and no end date. If you need hierarchical timing, spawn a child `Span`
|
|
8
|
+
* instead — that gives you start/end semantics and its own marker list.
|
|
9
|
+
*
|
|
10
|
+
* Modeled after OpenTelemetry's "span events" concept (we renamed `event` → `marker`
|
|
11
|
+
* here because `Event` is heavily overloaded in Pristine's dispatched-event domain —
|
|
12
|
+
* `Event<T>`, `EventHandler`, `EventPipeline`, `EventDispatcher`, etc.). A `Span` carries
|
|
13
|
+
* `markers: SpanMarker[]` alongside its `children: Span[]`. Renderers interleave markers
|
|
14
|
+
* with child spans by timestamp to produce a chronological trail of what happened.
|
|
15
|
+
*
|
|
16
|
+
* Use `TracingManager.addMarkerToCurrentSpan(message, attributes?)` to add one — it
|
|
17
|
+
* finds the most-recently-started in-progress span and attaches the marker there.
|
|
18
|
+
*/
|
|
19
|
+
export class SpanMarker {
|
|
20
|
+
constructor(message, attributes) {
|
|
21
|
+
this.message = message;
|
|
22
|
+
/**
|
|
23
|
+
* The timestamp in milliseconds at which the marker was created. Used to interleave
|
|
24
|
+
* markers with sibling spans when rendering a sorted trail.
|
|
25
|
+
*/
|
|
26
|
+
this.timestamp = Date.now();
|
|
27
|
+
this.attributes = attributes;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
//# sourceMappingURL=span-marker.model.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"span-marker.model.js","sourceRoot":"","sources":["../../../../src/models/span-marker.model.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,OAAO,UAAU;IAarB,YAA4B,OAAe,EAAE,UAAsC;QAAvD,YAAO,GAAP,OAAO,CAAQ;QAZ3C;;;WAGG;QACa,cAAS,GAAW,IAAI,CAAC,GAAG,EAAE,CAAC;QAS7C,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;IAC/B,CAAC;CACF"}
|
|
@@ -23,9 +23,12 @@ export class Span {
|
|
|
23
23
|
* Named, timestamped markers attached to this span. Use these for noteworthy moments
|
|
24
24
|
* inside the span's lifetime that don't warrant their own child span — e.g.
|
|
25
25
|
* "validation passed", "found 50 rows in DB". Empty by default; populated by
|
|
26
|
-
* `TracingManager.
|
|
26
|
+
* `TracingManager.addMarkerToCurrentSpan(...)`.
|
|
27
|
+
*
|
|
28
|
+
* Markers are flat by design (instants, not durations). For hierarchical timing, use
|
|
29
|
+
* child spans.
|
|
27
30
|
*/
|
|
28
|
-
this.
|
|
31
|
+
this.markers = [];
|
|
29
32
|
/**
|
|
30
33
|
* The context associated with the span.
|
|
31
34
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"span.model.js","sourceRoot":"","sources":["../../../../src/models/span.model.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,UAAU,EAAC,MAAM,QAAQ,CAAC;
|
|
1
|
+
{"version":3,"file":"span.model.js","sourceRoot":"","sources":["../../../../src/models/span.model.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,UAAU,EAAC,MAAM,QAAQ,CAAC;AAKlC;;GAEG;AACH,MAAM,OAAO,IAAI;IA0Df;;;;;OAKG;IACH,YAA0B,OAAe,EAAE,EAAW,EAAE,OAAmC;QAAjE,YAAO,GAAP,OAAO,CAAQ;QA/CzC;;WAEG;QACI,cAAS,GAAW,IAAI,CAAC,GAAG,EAAE,CAAC;QAYtC;;WAEG;QACI,aAAQ,GAAW,EAAE,CAAC;QAE7B;;;;;;;;WAQG;QACI,YAAO,GAAiB,EAAE,CAAC;QAElC;;WAEG;QACI,YAAO,GAA8B,EAAE,CAAC;QAE/C;;WAEG;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