@qlever-llc/trellis 0.5.1

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 (118) hide show
  1. package/README.md +9 -0
  2. package/esm/_dnt.polyfills.d.ts +7 -0
  3. package/esm/_dnt.polyfills.d.ts.map +1 -0
  4. package/esm/_dnt.polyfills.js +1 -0
  5. package/esm/package.json +3 -0
  6. package/esm/trellis/browser.d.ts +11 -0
  7. package/esm/trellis/browser.d.ts.map +1 -0
  8. package/esm/trellis/browser.js +10 -0
  9. package/esm/trellis/client.d.ts +31 -0
  10. package/esm/trellis/client.d.ts.map +1 -0
  11. package/esm/trellis/client.js +13 -0
  12. package/esm/trellis/codec.d.ts +12 -0
  13. package/esm/trellis/codec.d.ts.map +1 -0
  14. package/esm/trellis/codec.js +60 -0
  15. package/esm/trellis/env.d.ts +2 -0
  16. package/esm/trellis/env.d.ts.map +1 -0
  17. package/esm/trellis/env.js +1 -0
  18. package/esm/trellis/errors/AuthError.d.ts +30 -0
  19. package/esm/trellis/errors/AuthError.d.ts.map +1 -0
  20. package/esm/trellis/errors/AuthError.js +65 -0
  21. package/esm/trellis/errors/KVError.d.ts +31 -0
  22. package/esm/trellis/errors/KVError.d.ts.map +1 -0
  23. package/esm/trellis/errors/KVError.js +46 -0
  24. package/esm/trellis/errors/RemoteError.d.ts +47 -0
  25. package/esm/trellis/errors/RemoteError.d.ts.map +1 -0
  26. package/esm/trellis/errors/RemoteError.js +80 -0
  27. package/esm/trellis/errors/TrellisError.d.ts +16 -0
  28. package/esm/trellis/errors/TrellisError.d.ts.map +1 -0
  29. package/esm/trellis/errors/TrellisError.js +15 -0
  30. package/esm/trellis/errors/ValidationError.d.ts +51 -0
  31. package/esm/trellis/errors/ValidationError.d.ts.map +1 -0
  32. package/esm/trellis/errors/ValidationError.js +77 -0
  33. package/esm/trellis/errors/index.d.ts +38 -0
  34. package/esm/trellis/errors/index.d.ts.map +1 -0
  35. package/esm/trellis/errors/index.js +26 -0
  36. package/esm/trellis/globals.d.ts +2 -0
  37. package/esm/trellis/globals.d.ts.map +1 -0
  38. package/esm/trellis/globals.js +8 -0
  39. package/esm/trellis/helpers.d.ts +12 -0
  40. package/esm/trellis/helpers.d.ts.map +1 -0
  41. package/esm/trellis/helpers.js +47 -0
  42. package/esm/trellis/index.d.ts +11 -0
  43. package/esm/trellis/index.d.ts.map +1 -0
  44. package/esm/trellis/index.js +6 -0
  45. package/esm/trellis/kv.d.ts +67 -0
  46. package/esm/trellis/kv.d.ts.map +1 -0
  47. package/esm/trellis/kv.js +326 -0
  48. package/esm/trellis/models/trellis/TrellisError.d.ts +43 -0
  49. package/esm/trellis/models/trellis/TrellisError.d.ts.map +1 -0
  50. package/esm/trellis/models/trellis/TrellisError.js +16 -0
  51. package/esm/trellis/tasks.d.ts +11 -0
  52. package/esm/trellis/tasks.d.ts.map +1 -0
  53. package/esm/trellis/tasks.js +41 -0
  54. package/esm/trellis/tracing.d.ts +5 -0
  55. package/esm/trellis/tracing.d.ts.map +1 -0
  56. package/esm/trellis/tracing.js +7 -0
  57. package/esm/trellis/trellis.d.ts +117 -0
  58. package/esm/trellis/trellis.d.ts.map +1 -0
  59. package/esm/trellis/trellis.js +710 -0
  60. package/package.json +49 -0
  61. package/script/_dnt.polyfills.d.ts +7 -0
  62. package/script/_dnt.polyfills.d.ts.map +1 -0
  63. package/script/_dnt.polyfills.js +2 -0
  64. package/script/package.json +3 -0
  65. package/script/trellis/browser.d.ts +11 -0
  66. package/script/trellis/browser.d.ts.map +1 -0
  67. package/script/trellis/browser.js +21 -0
  68. package/script/trellis/client.d.ts +31 -0
  69. package/script/trellis/client.d.ts.map +1 -0
  70. package/script/trellis/client.js +16 -0
  71. package/script/trellis/codec.d.ts +12 -0
  72. package/script/trellis/codec.d.ts.map +1 -0
  73. package/script/trellis/codec.js +66 -0
  74. package/script/trellis/env.d.ts +2 -0
  75. package/script/trellis/env.d.ts.map +1 -0
  76. package/script/trellis/env.js +5 -0
  77. package/script/trellis/errors/AuthError.d.ts +30 -0
  78. package/script/trellis/errors/AuthError.d.ts.map +1 -0
  79. package/script/trellis/errors/AuthError.js +72 -0
  80. package/script/trellis/errors/KVError.d.ts +31 -0
  81. package/script/trellis/errors/KVError.d.ts.map +1 -0
  82. package/script/trellis/errors/KVError.js +53 -0
  83. package/script/trellis/errors/RemoteError.d.ts +47 -0
  84. package/script/trellis/errors/RemoteError.d.ts.map +1 -0
  85. package/script/trellis/errors/RemoteError.js +87 -0
  86. package/script/trellis/errors/TrellisError.d.ts +16 -0
  87. package/script/trellis/errors/TrellisError.d.ts.map +1 -0
  88. package/script/trellis/errors/TrellisError.js +19 -0
  89. package/script/trellis/errors/ValidationError.d.ts +51 -0
  90. package/script/trellis/errors/ValidationError.d.ts.map +1 -0
  91. package/script/trellis/errors/ValidationError.js +84 -0
  92. package/script/trellis/errors/index.d.ts +38 -0
  93. package/script/trellis/errors/index.d.ts.map +1 -0
  94. package/script/trellis/errors/index.js +40 -0
  95. package/script/trellis/globals.d.ts +2 -0
  96. package/script/trellis/globals.d.ts.map +1 -0
  97. package/script/trellis/globals.js +11 -0
  98. package/script/trellis/helpers.d.ts +12 -0
  99. package/script/trellis/helpers.d.ts.map +1 -0
  100. package/script/trellis/helpers.js +54 -0
  101. package/script/trellis/index.d.ts +11 -0
  102. package/script/trellis/index.d.ts.map +1 -0
  103. package/script/trellis/index.js +24 -0
  104. package/script/trellis/kv.d.ts +67 -0
  105. package/script/trellis/kv.d.ts.map +1 -0
  106. package/script/trellis/kv.js +354 -0
  107. package/script/trellis/models/trellis/TrellisError.d.ts +43 -0
  108. package/script/trellis/models/trellis/TrellisError.d.ts.map +1 -0
  109. package/script/trellis/models/trellis/TrellisError.js +22 -0
  110. package/script/trellis/tasks.d.ts +11 -0
  111. package/script/trellis/tasks.d.ts.map +1 -0
  112. package/script/trellis/tasks.js +45 -0
  113. package/script/trellis/tracing.d.ts +5 -0
  114. package/script/trellis/tracing.d.ts.map +1 -0
  115. package/script/trellis/tracing.js +49 -0
  116. package/script/trellis/trellis.d.ts +117 -0
  117. package/script/trellis/trellis.d.ts.map +1 -0
  118. package/script/trellis/trellis.js +715 -0
package/package.json ADDED
@@ -0,0 +1,49 @@
1
+ {
2
+ "name": "@qlever-llc/trellis",
3
+ "version": "0.5.1",
4
+ "description": "Client-side Trellis runtime, models, and contract helpers for TypeScript applications.",
5
+ "homepage": "https://github.com/Qlever-LLC/trellis#readme",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "https://github.com/Qlever-LLC/trellis"
9
+ },
10
+ "license": "Apache-2.0",
11
+ "bugs": {
12
+ "url": "https://github.com/Qlever-LLC/trellis/issues"
13
+ },
14
+ "main": "./script/trellis/index.js",
15
+ "module": "./esm/trellis/index.js",
16
+ "exports": {
17
+ ".": {
18
+ "import": "./esm/trellis/index.js",
19
+ "require": "./script/trellis/index.js"
20
+ },
21
+ "./browser": {
22
+ "import": "./esm/trellis/browser.js",
23
+ "require": "./script/trellis/browser.js"
24
+ },
25
+ "./tracing": {
26
+ "import": "./esm/trellis/tracing.js",
27
+ "require": "./script/trellis/tracing.js"
28
+ }
29
+ },
30
+ "publishConfig": {
31
+ "access": "public"
32
+ },
33
+ "dependencies": {
34
+ "@nats-io/jetstream": "^3.3.0",
35
+ "@nats-io/kv": "^3.2.0",
36
+ "@nats-io/nats-core": "^3.3.1",
37
+ "pino": "^9.11.0",
38
+ "ts-deepmerge": "^7.0.3",
39
+ "typebox": "^1.0.15",
40
+ "ulid": "^3.0.1",
41
+ "@qlever-llc/trellis-contracts": "^0.5.1",
42
+ "@qlever-llc/trellis-result": "^0.5.1",
43
+ "@qlever-llc/trellis-telemetry": "^0.5.1"
44
+ },
45
+ "devDependencies": {
46
+ "@types/node": "^20.9.0"
47
+ },
48
+ "_generatedBy": "dnt@dev"
49
+ }
@@ -0,0 +1,7 @@
1
+ declare global {
2
+ interface Error {
3
+ cause?: unknown;
4
+ }
5
+ }
6
+ export {};
7
+ //# sourceMappingURL=_dnt.polyfills.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"_dnt.polyfills.d.ts","sourceRoot":"","sources":["../src/_dnt.polyfills.ts"],"names":[],"mappings":"AAAA,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,KAAK;QACb,KAAK,CAAC,EAAE,OAAO,CAAC;KACjB;CACF;AAED,OAAO,EAAE,CAAC"}
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,3 @@
1
+ {
2
+ "type": "commonjs"
3
+ }
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Browser-safe exports for @qlever-llc/trellis
3
+ */
4
+ import "../_dnt.polyfills.js";
5
+ export { Trellis } from "./trellis.js";
6
+ export type { TrellisAuth } from "./trellis.js";
7
+ export { TypedKV, TypedKVEntry } from "./kv.js";
8
+ export type { WatchEvent, WatchOptions } from "./kv.js";
9
+ export { AuthError, KVError, RemoteError, UnexpectedError, ValidationError, } from "./errors/index.js";
10
+ export type { TrellisErrorInstance } from "./errors/index.js";
11
+ //# sourceMappingURL=browser.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"browser.d.ts","sourceRoot":"","sources":["../../src/trellis/browser.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,OAAO,sBAAsB,CAAC;AAE9B,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,YAAY,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAGhD,OAAO,EAAE,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAChD,YAAY,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAGxD,OAAO,EACL,SAAS,EACT,OAAO,EACP,WAAW,EACX,eAAe,EACf,eAAe,GAChB,MAAM,mBAAmB,CAAC;AAC3B,YAAY,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAC"}
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ /**
3
+ * Browser-safe exports for @qlever-llc/trellis
4
+ */
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.ValidationError = exports.UnexpectedError = exports.RemoteError = exports.KVError = exports.AuthError = exports.TypedKVEntry = exports.TypedKV = exports.Trellis = void 0;
7
+ // Core Trellis client class (browser-safe)
8
+ require("../_dnt.polyfills.js");
9
+ var trellis_js_1 = require("./trellis.js");
10
+ Object.defineProperty(exports, "Trellis", { enumerable: true, get: function () { return trellis_js_1.Trellis; } });
11
+ // KV utilities (browser-safe)
12
+ var kv_js_1 = require("./kv.js");
13
+ Object.defineProperty(exports, "TypedKV", { enumerable: true, get: function () { return kv_js_1.TypedKV; } });
14
+ Object.defineProperty(exports, "TypedKVEntry", { enumerable: true, get: function () { return kv_js_1.TypedKVEntry; } });
15
+ // Error types (browser-safe)
16
+ var index_js_1 = require("./errors/index.js");
17
+ Object.defineProperty(exports, "AuthError", { enumerable: true, get: function () { return index_js_1.AuthError; } });
18
+ Object.defineProperty(exports, "KVError", { enumerable: true, get: function () { return index_js_1.KVError; } });
19
+ Object.defineProperty(exports, "RemoteError", { enumerable: true, get: function () { return index_js_1.RemoteError; } });
20
+ Object.defineProperty(exports, "UnexpectedError", { enumerable: true, get: function () { return index_js_1.UnexpectedError; } });
21
+ Object.defineProperty(exports, "ValidationError", { enumerable: true, get: function () { return index_js_1.ValidationError; } });
@@ -0,0 +1,31 @@
1
+ import type { NatsConnection } from "@nats-io/nats-core";
2
+ import type { TrellisAPI } from "@qlever-llc/trellis-contracts";
3
+ import type { Logger } from "pino";
4
+ import type { TrellisAuth } from "./trellis.js";
5
+ import { Trellis } from "./trellis.js";
6
+ type NoResponderRetryOpts = {
7
+ maxAttempts?: number;
8
+ baseDelayMs?: number;
9
+ };
10
+ export type ClientOpts = {
11
+ /**
12
+ * Logical name for this client instance (used for logs and consumer names).
13
+ * Defaults to "client".
14
+ */
15
+ name?: string;
16
+ log?: Logger;
17
+ timeout?: number;
18
+ stream?: string;
19
+ noResponderRetry?: NoResponderRetryOpts;
20
+ };
21
+ type ClientContract<TApi> = {
22
+ API: {
23
+ trellis: TApi;
24
+ };
25
+ };
26
+ /**
27
+ * Create a Trellis client typed from a contract module's derived outbound surface.
28
+ */
29
+ export declare function createClient<TApi extends TrellisAPI>(contract: ClientContract<TApi>, nats: NatsConnection, auth: TrellisAuth, opts?: ClientOpts): Trellis<TApi>;
30
+ export {};
31
+ //# sourceMappingURL=client.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/trellis/client.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACzD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAChE,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AAEnC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAChD,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAEvC,KAAK,oBAAoB,GAAG;IAC1B,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB,CAAC;AAEF,MAAM,MAAM,UAAU,GAAG;IACvB;;;OAGG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,gBAAgB,CAAC,EAAE,oBAAoB,CAAC;CACzC,CAAC;AAEF,KAAK,cAAc,CAAC,IAAI,IAAI;IAC1B,GAAG,EAAE;QACH,OAAO,EAAE,IAAI,CAAC;KACf,CAAC;CACH,CAAC;AAEF;;GAEG;AACH,wBAAgB,YAAY,CAAC,IAAI,SAAS,UAAU,EAClD,QAAQ,EAAE,cAAc,CAAC,IAAI,CAAC,EAC9B,IAAI,EAAE,cAAc,EACpB,IAAI,EAAE,WAAW,EACjB,IAAI,CAAC,EAAE,UAAU,GAChB,OAAO,CAAC,IAAI,CAAC,CAaf"}
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createClient = createClient;
4
+ const trellis_js_1 = require("./trellis.js");
5
+ /**
6
+ * Create a Trellis client typed from a contract module's derived outbound surface.
7
+ */
8
+ function createClient(contract, nats, auth, opts) {
9
+ return new trellis_js_1.Trellis(opts?.name ?? "client", nats, auth, {
10
+ log: opts?.log,
11
+ timeout: opts?.timeout,
12
+ stream: opts?.stream,
13
+ noResponderRetry: opts?.noResponderRetry,
14
+ api: contract.API.trellis,
15
+ });
16
+ }
@@ -0,0 +1,12 @@
1
+ import { type InferSchemaType, type SchemaLike } from "@qlever-llc/trellis-contracts";
2
+ import { Result } from "@qlever-llc/trellis-result";
3
+ import type { StaticDecode, TSchema } from "typebox";
4
+ import { UnexpectedError, ValidationError } from "./errors/index.js";
5
+ export type JsonValue = string | number | boolean | null | JsonValue[] | {
6
+ [key: string]: JsonValue;
7
+ };
8
+ export declare function parse<T extends TSchema>(schema: T, data: JsonValue): Result<StaticDecode<T>, ValidationError | UnexpectedError>;
9
+ export declare function parseSchema<S extends SchemaLike>(schema: S, data: JsonValue): Result<InferSchemaType<S>, ValidationError | UnexpectedError>;
10
+ export declare function encode<T extends TSchema>(schema: T, data: unknown): Result<string, ValidationError | UnexpectedError>;
11
+ export declare function encodeSchema<S extends SchemaLike>(schema: S, data: unknown): Result<string, ValidationError | UnexpectedError>;
12
+ //# sourceMappingURL=codec.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"codec.d.ts","sourceRoot":"","sources":["../../src/trellis/codec.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,eAAe,EACpB,KAAK,UAAU,EAEhB,MAAM,+BAA+B,CAAC;AACvC,OAAO,EAAE,MAAM,EAAE,MAAM,4BAA4B,CAAC;AACpD,OAAO,KAAK,EAAE,YAAY,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAErD,OAAO,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAErE,MAAM,MAAM,SAAS,GACjB,MAAM,GACN,MAAM,GACN,OAAO,GACP,IAAI,GACJ,SAAS,EAAE,GACX;IACA,CAAC,GAAG,EAAE,MAAM,GAAG,SAAS,CAAC;CAC1B,CAAC;AAUJ,wBAAgB,KAAK,CAAC,CAAC,SAAS,OAAO,EACrC,MAAM,EAAE,CAAC,EACT,IAAI,EAAE,SAAS,GACd,MAAM,CAAC,YAAY,CAAC,CAAC,CAAC,EAAE,eAAe,GAAG,eAAe,CAAC,CAU5D;AAED,wBAAgB,WAAW,CAAC,CAAC,SAAS,UAAU,EAC9C,MAAM,EAAE,CAAC,EACT,IAAI,EAAE,SAAS,GACd,MAAM,CAAC,eAAe,CAAC,CAAC,CAAC,EAAE,eAAe,GAAG,eAAe,CAAC,CAW/D;AAED,wBAAgB,MAAM,CAAC,CAAC,SAAS,OAAO,EACtC,MAAM,EAAE,CAAC,EACT,IAAI,EAAE,OAAO,GACZ,MAAM,CAAC,MAAM,EAAE,eAAe,GAAG,eAAe,CAAC,CAUnD;AAED,wBAAgB,YAAY,CAAC,CAAC,SAAS,UAAU,EAC/C,MAAM,EAAE,CAAC,EACT,IAAI,EAAE,OAAO,GACZ,MAAM,CAAC,MAAM,EAAE,eAAe,GAAG,eAAe,CAAC,CAWnD"}
@@ -0,0 +1,66 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.parse = parse;
4
+ exports.parseSchema = parseSchema;
5
+ exports.encode = encode;
6
+ exports.encodeSchema = encodeSchema;
7
+ const trellis_contracts_1 = require("@qlever-llc/trellis-contracts");
8
+ const trellis_result_1 = require("@qlever-llc/trellis-result");
9
+ const value_1 = require("typebox/value");
10
+ const index_js_1 = require("./errors/index.js");
11
+ function parseWithSchema(schema, data) {
12
+ return value_1.Value.Parse(schema, data);
13
+ }
14
+ function encodeWithSchema(schema, data) {
15
+ return JSON.stringify(value_1.Value.Encode(schema, data));
16
+ }
17
+ function parse(schema, data) {
18
+ try {
19
+ return trellis_result_1.Result.ok(parseWithSchema(schema, data));
20
+ }
21
+ catch (cause) {
22
+ if (cause instanceof value_1.ParseError) {
23
+ const errors = value_1.Value.Errors(schema, data);
24
+ return trellis_result_1.Result.err(new index_js_1.ValidationError({ errors, cause }));
25
+ }
26
+ return trellis_result_1.Result.err(new index_js_1.UnexpectedError({ cause }));
27
+ }
28
+ }
29
+ function parseSchema(schema, data) {
30
+ const raw = (0, trellis_contracts_1.unwrapSchema)(schema);
31
+ try {
32
+ return trellis_result_1.Result.ok(parseWithSchema(raw, data));
33
+ }
34
+ catch (cause) {
35
+ if (cause instanceof value_1.ParseError) {
36
+ const errors = value_1.Value.Errors(raw, data);
37
+ return trellis_result_1.Result.err(new index_js_1.ValidationError({ errors, cause }));
38
+ }
39
+ return trellis_result_1.Result.err(new index_js_1.UnexpectedError({ cause }));
40
+ }
41
+ }
42
+ function encode(schema, data) {
43
+ try {
44
+ return trellis_result_1.Result.ok(encodeWithSchema(schema, data));
45
+ }
46
+ catch (cause) {
47
+ if (cause instanceof value_1.EncodeError) {
48
+ const errors = value_1.Value.Errors(schema, data);
49
+ return trellis_result_1.Result.err(new index_js_1.ValidationError({ errors, cause }));
50
+ }
51
+ return trellis_result_1.Result.err(new index_js_1.UnexpectedError({ cause }));
52
+ }
53
+ }
54
+ function encodeSchema(schema, data) {
55
+ const raw = (0, trellis_contracts_1.unwrapSchema)(schema);
56
+ try {
57
+ return trellis_result_1.Result.ok(encodeWithSchema(raw, data));
58
+ }
59
+ catch (cause) {
60
+ if (cause instanceof value_1.EncodeError) {
61
+ const errors = value_1.Value.Errors(raw, data);
62
+ return trellis_result_1.Result.err(new index_js_1.ValidationError({ errors, cause }));
63
+ }
64
+ return trellis_result_1.Result.err(new index_js_1.UnexpectedError({ cause }));
65
+ }
66
+ }
@@ -0,0 +1,2 @@
1
+ export { getEnv } from "@qlever-llc/trellis-telemetry";
2
+ //# sourceMappingURL=env.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"env.d.ts","sourceRoot":"","sources":["../../src/trellis/env.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,+BAA+B,CAAC"}
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getEnv = void 0;
4
+ var trellis_telemetry_1 = require("@qlever-llc/trellis-telemetry");
5
+ Object.defineProperty(exports, "getEnv", { enumerable: true, get: function () { return trellis_telemetry_1.getEnv; } });
@@ -0,0 +1,30 @@
1
+ import Type, { type Static } from "typebox";
2
+ import { TrellisError } from "./TrellisError.js";
3
+ export declare const AuthErrorDataSchema: Type.TObject<{
4
+ id: Type.TString;
5
+ type: Type.TLiteral<"AuthError">;
6
+ message: Type.TString;
7
+ reason: Type.TUnion<[Type.TLiteral<"invalid_request">, Type.TLiteral<"missing_session_key">, Type.TLiteral<"missing_proof">, Type.TLiteral<"session_not_found">, Type.TLiteral<"session_expired">, Type.TLiteral<"invalid_signature">, Type.TLiteral<"user_not_found">, Type.TLiteral<"user_inactive">, Type.TLiteral<"unknown_service">, Type.TLiteral<"service_disabled">, Type.TLiteral<"iat_out_of_range">, Type.TLiteral<"invalid_binding_token">, Type.TLiteral<"session_corrupted">, Type.TLiteral<"session_already_bound">, Type.TLiteral<"authtoken_already_used">, Type.TLiteral<"oauth_session_key_mismatch">, Type.TLiteral<"service_role_on_user">, Type.TLiteral<"reply_subject_mismatch">, Type.TLiteral<"insufficient_permissions">, Type.TLiteral<"forbidden">]>;
8
+ context: Type.TOptional<Type.TRecord<"^.*$", Type.TUnknown>>;
9
+ traceId: Type.TOptional<Type.TString>;
10
+ }>;
11
+ export type AuthErrorData = Static<typeof AuthErrorDataSchema>;
12
+ /**
13
+ * Error for authentication and authorization failures.
14
+ */
15
+ export declare class AuthError extends TrellisError<AuthErrorData> {
16
+ readonly name: "AuthError";
17
+ readonly reason: AuthErrorData["reason"];
18
+ constructor(options: ErrorOptions & {
19
+ reason: AuthErrorData["reason"];
20
+ context?: Record<string, unknown>;
21
+ id?: string;
22
+ });
23
+ /**
24
+ * Serializes error to a plain object.
25
+ *
26
+ * @returns Plain object representation of the error
27
+ */
28
+ toSerializable(): AuthErrorData;
29
+ }
30
+ //# sourceMappingURL=AuthError.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AuthError.d.ts","sourceRoot":"","sources":["../../../src/trellis/errors/AuthError.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,EAAE,EAAE,KAAK,MAAM,EAAE,MAAM,SAAS,CAAC;AAC5C,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAEjD,eAAO,MAAM,mBAAmB;;;;;;;EA4B9B,CAAC;AACH,MAAM,MAAM,aAAa,GAAG,MAAM,CAAC,OAAO,mBAAmB,CAAC,CAAC;AAE/D;;GAEG;AACH,qBAAa,SAAU,SAAQ,YAAY,CAAC,aAAa,CAAC;IACxD,SAAkB,IAAI,cAAwB;IAC9C,QAAQ,CAAC,MAAM,EAAE,aAAa,CAAC,QAAQ,CAAC,CAAC;gBAGvC,OAAO,EAAE,YAAY,GAAG;QACtB,MAAM,EAAE,aAAa,CAAC,QAAQ,CAAC,CAAC;QAChC,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;QAClC,EAAE,CAAC,EAAE,MAAM,CAAC;KACb;IAOH;;;;OAIG;IACM,cAAc,IAAI,aAAa;CAOzC"}
@@ -0,0 +1,72 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.AuthError = exports.AuthErrorDataSchema = void 0;
7
+ const typebox_1 = __importDefault(require("typebox"));
8
+ const TrellisError_js_1 = require("./TrellisError.js");
9
+ exports.AuthErrorDataSchema = typebox_1.default.Object({
10
+ id: typebox_1.default.String(),
11
+ type: typebox_1.default.Literal("AuthError"),
12
+ message: typebox_1.default.String(),
13
+ reason: typebox_1.default.Union([
14
+ typebox_1.default.Literal("invalid_request"),
15
+ typebox_1.default.Literal("missing_session_key"),
16
+ typebox_1.default.Literal("missing_proof"),
17
+ typebox_1.default.Literal("session_not_found"),
18
+ typebox_1.default.Literal("session_expired"),
19
+ typebox_1.default.Literal("invalid_signature"),
20
+ typebox_1.default.Literal("user_not_found"),
21
+ typebox_1.default.Literal("user_inactive"),
22
+ typebox_1.default.Literal("unknown_service"),
23
+ typebox_1.default.Literal("service_disabled"),
24
+ typebox_1.default.Literal("iat_out_of_range"),
25
+ typebox_1.default.Literal("invalid_binding_token"),
26
+ typebox_1.default.Literal("session_corrupted"),
27
+ typebox_1.default.Literal("session_already_bound"),
28
+ typebox_1.default.Literal("authtoken_already_used"),
29
+ typebox_1.default.Literal("oauth_session_key_mismatch"),
30
+ typebox_1.default.Literal("service_role_on_user"),
31
+ typebox_1.default.Literal("reply_subject_mismatch"),
32
+ typebox_1.default.Literal("insufficient_permissions"),
33
+ typebox_1.default.Literal("forbidden"),
34
+ ]),
35
+ context: typebox_1.default.Optional(typebox_1.default.Record(typebox_1.default.String(), typebox_1.default.Unknown())),
36
+ traceId: typebox_1.default.Optional(typebox_1.default.String()),
37
+ });
38
+ /**
39
+ * Error for authentication and authorization failures.
40
+ */
41
+ class AuthError extends TrellisError_js_1.TrellisError {
42
+ constructor(options) {
43
+ const { reason, ...baseOptions } = options;
44
+ super(`Auth failed: ${reason}`, baseOptions);
45
+ Object.defineProperty(this, "name", {
46
+ enumerable: true,
47
+ configurable: true,
48
+ writable: true,
49
+ value: "AuthError"
50
+ });
51
+ Object.defineProperty(this, "reason", {
52
+ enumerable: true,
53
+ configurable: true,
54
+ writable: true,
55
+ value: void 0
56
+ });
57
+ this.reason = reason;
58
+ }
59
+ /**
60
+ * Serializes error to a plain object.
61
+ *
62
+ * @returns Plain object representation of the error
63
+ */
64
+ toSerializable() {
65
+ return {
66
+ ...this.baseSerializable(),
67
+ type: this.name,
68
+ reason: this.reason,
69
+ };
70
+ }
71
+ }
72
+ exports.AuthError = AuthError;
@@ -0,0 +1,31 @@
1
+ import Type, { type Static } from "typebox";
2
+ import { TrellisError } from "./TrellisError.js";
3
+ export declare const KVErrorDataSchema: Type.TObject<{
4
+ id: Type.TString;
5
+ type: Type.TLiteral<"KVError">;
6
+ message: Type.TString;
7
+ operation: Type.TOptional<Type.TString>;
8
+ context: Type.TOptional<Type.TRecord<"^.*$", Type.TUnknown>>;
9
+ traceId: Type.TOptional<Type.TString>;
10
+ }>;
11
+ export type KVErrorData = Static<typeof KVErrorDataSchema>;
12
+ /**
13
+ * Error for KV storage operations.
14
+ * Used when key-value store operations fail.
15
+ */
16
+ export declare class KVError extends TrellisError<KVErrorData> {
17
+ readonly name: "KVError";
18
+ readonly operation?: string;
19
+ constructor(options: ErrorOptions & {
20
+ operation?: string;
21
+ context?: Record<string, unknown>;
22
+ id?: string;
23
+ });
24
+ /**
25
+ * Serializes error to a plain object.
26
+ *
27
+ * @returns Plain object representation of the error
28
+ */
29
+ toSerializable(): KVErrorData;
30
+ }
31
+ //# sourceMappingURL=KVError.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"KVError.d.ts","sourceRoot":"","sources":["../../../src/trellis/errors/KVError.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,EAAE,EAAE,KAAK,MAAM,EAAE,MAAM,SAAS,CAAC;AAC5C,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAEjD,eAAO,MAAM,iBAAiB;;;;;;;EAO5B,CAAC;AACH,MAAM,MAAM,WAAW,GAAG,MAAM,CAAC,OAAO,iBAAiB,CAAC,CAAC;AAE3D;;;GAGG;AACH,qBAAa,OAAQ,SAAQ,YAAY,CAAC,WAAW,CAAC;IACpD,SAAkB,IAAI,YAAsB;IAC5C,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;gBAG1B,OAAO,EAAE,YAAY,GAAG;QACtB,SAAS,CAAC,EAAE,MAAM,CAAC;QACnB,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;QAClC,EAAE,CAAC,EAAE,MAAM,CAAC;KACb;IAQH;;;;OAIG;IACM,cAAc,IAAI,WAAW;CAOvC"}
@@ -0,0 +1,53 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.KVError = exports.KVErrorDataSchema = void 0;
7
+ const typebox_1 = __importDefault(require("typebox"));
8
+ const TrellisError_js_1 = require("./TrellisError.js");
9
+ exports.KVErrorDataSchema = typebox_1.default.Object({
10
+ id: typebox_1.default.String(),
11
+ type: typebox_1.default.Literal("KVError"),
12
+ message: typebox_1.default.String(),
13
+ operation: typebox_1.default.Optional(typebox_1.default.String()),
14
+ context: typebox_1.default.Optional(typebox_1.default.Record(typebox_1.default.String(), typebox_1.default.Unknown())),
15
+ traceId: typebox_1.default.Optional(typebox_1.default.String()),
16
+ });
17
+ /**
18
+ * Error for KV storage operations.
19
+ * Used when key-value store operations fail.
20
+ */
21
+ class KVError extends TrellisError_js_1.TrellisError {
22
+ constructor(options) {
23
+ const { operation, ...baseOptions } = options;
24
+ const msg = `KV ${operation || ""} failed`;
25
+ super(msg, baseOptions);
26
+ Object.defineProperty(this, "name", {
27
+ enumerable: true,
28
+ configurable: true,
29
+ writable: true,
30
+ value: "KVError"
31
+ });
32
+ Object.defineProperty(this, "operation", {
33
+ enumerable: true,
34
+ configurable: true,
35
+ writable: true,
36
+ value: void 0
37
+ });
38
+ this.operation = operation;
39
+ }
40
+ /**
41
+ * Serializes error to a plain object.
42
+ *
43
+ * @returns Plain object representation of the error
44
+ */
45
+ toSerializable() {
46
+ return {
47
+ ...this.baseSerializable(),
48
+ type: this.name,
49
+ operation: this.operation,
50
+ };
51
+ }
52
+ }
53
+ exports.KVError = KVError;
@@ -0,0 +1,47 @@
1
+ import { Result, UnexpectedError } from "@qlever-llc/trellis-result";
2
+ import Type, { type Static } from "typebox";
3
+ import { ValidationError } from "./ValidationError.js";
4
+ import { TrellisError } from "./TrellisError.js";
5
+ import type { TrellisErrorData } from "../models/trellis/TrellisError.js";
6
+ export declare const RemoteErrorDataSchema: Type.TObject<{
7
+ id: Type.TString;
8
+ type: Type.TLiteral<"RemoteError">;
9
+ message: Type.TString;
10
+ remoteError: Type.TAny;
11
+ context: Type.TOptional<Type.TRecord<"^.*$", Type.TUnknown>>;
12
+ traceId: Type.TOptional<Type.TString>;
13
+ }>;
14
+ export type RemoteErrorData = Static<typeof RemoteErrorDataSchema>;
15
+ /**
16
+ * Error for wrapping errors received from remote Trellis services.
17
+ * This is the only error type with parseJSON/parseObject methods for deserializing remote errors.
18
+ */
19
+ export declare class RemoteError extends TrellisError<RemoteErrorData> {
20
+ readonly name: "RemoteError";
21
+ readonly remoteError: TrellisErrorData;
22
+ constructor(options: ErrorOptions & {
23
+ error: TrellisErrorData;
24
+ context?: Record<string, unknown>;
25
+ id?: string;
26
+ });
27
+ /**
28
+ * Serializes error to a plain object.
29
+ *
30
+ * @returns Plain object representation of the error
31
+ */
32
+ toSerializable(): RemoteErrorData;
33
+ /**
34
+ * Parses and validates a plain object as TrellisErrorData.
35
+ * Use this to deserialize errors received from remote services.
36
+ *
37
+ * @param obj - Plain object to validate
38
+ * @returns Result containing validated TrellisError or a ValidationError or UnexpectedError
39
+ */
40
+ static parse(data: unknown): Result<TrellisErrorData, ValidationError | UnexpectedError>;
41
+ /**
42
+ * Alias for parse() - parses JSON string or object as TrellisErrorData.
43
+ * @see parse
44
+ */
45
+ static parseJSON: typeof RemoteError.parse;
46
+ }
47
+ //# sourceMappingURL=RemoteError.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"RemoteError.d.ts","sourceRoot":"","sources":["../../../src/trellis/errors/RemoteError.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AACrE,OAAO,IAAI,EAAE,EAAE,KAAK,MAAM,EAAE,MAAM,SAAS,CAAC;AAE5C,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,mCAAmC,CAAC;AAG1E,eAAO,MAAM,qBAAqB;;;;;;;EAOhC,CAAC;AACH,MAAM,MAAM,eAAe,GAAG,MAAM,CAAC,OAAO,qBAAqB,CAAC,CAAC;AAEnE;;;GAGG;AACH,qBAAa,WAAY,SAAQ,YAAY,CAAC,eAAe,CAAC;IAC5D,SAAkB,IAAI,gBAA0B;IAChD,QAAQ,CAAC,WAAW,EAAE,gBAAgB,CAAC;gBAGrC,OAAO,EAAE,YAAY,GAAG;QACtB,KAAK,EAAE,gBAAgB,CAAC;QACxB,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;QAClC,EAAE,CAAC,EAAE,MAAM,CAAC;KACb;IAOH;;;;OAIG;IACM,cAAc,IAAI,eAAe;IAQ1C;;;;;;OAMG;IACH,MAAM,CAAC,KAAK,CACV,IAAI,EAAE,OAAO,GACZ,MAAM,CAAC,gBAAgB,EAAE,eAAe,GAAG,eAAe,CAAC;IAqB9D;;;OAGG;IACH,MAAM,CAAC,SAAS,2BAAqB;CACtC"}
@@ -0,0 +1,87 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.RemoteError = exports.RemoteErrorDataSchema = void 0;
7
+ const trellis_result_1 = require("@qlever-llc/trellis-result");
8
+ const typebox_1 = __importDefault(require("typebox"));
9
+ const value_1 = require("typebox/value");
10
+ const ValidationError_js_1 = require("./ValidationError.js");
11
+ const TrellisError_js_1 = require("./TrellisError.js");
12
+ const TrellisError_js_2 = require("../models/trellis/TrellisError.js");
13
+ exports.RemoteErrorDataSchema = typebox_1.default.Object({
14
+ id: typebox_1.default.String(),
15
+ type: typebox_1.default.Literal("RemoteError"),
16
+ message: typebox_1.default.String(),
17
+ remoteError: typebox_1.default.Any(),
18
+ context: typebox_1.default.Optional(typebox_1.default.Record(typebox_1.default.String(), typebox_1.default.Unknown())),
19
+ traceId: typebox_1.default.Optional(typebox_1.default.String()),
20
+ });
21
+ /**
22
+ * Error for wrapping errors received from remote Trellis services.
23
+ * This is the only error type with parseJSON/parseObject methods for deserializing remote errors.
24
+ */
25
+ class RemoteError extends TrellisError_js_1.TrellisError {
26
+ constructor(options) {
27
+ const { error, ...baseOptions } = options;
28
+ super(`Remote error: ${error.message}`, baseOptions);
29
+ Object.defineProperty(this, "name", {
30
+ enumerable: true,
31
+ configurable: true,
32
+ writable: true,
33
+ value: "RemoteError"
34
+ });
35
+ Object.defineProperty(this, "remoteError", {
36
+ enumerable: true,
37
+ configurable: true,
38
+ writable: true,
39
+ value: void 0
40
+ });
41
+ this.remoteError = error;
42
+ }
43
+ /**
44
+ * Serializes error to a plain object.
45
+ *
46
+ * @returns Plain object representation of the error
47
+ */
48
+ toSerializable() {
49
+ return {
50
+ ...this.baseSerializable(),
51
+ type: this.name,
52
+ remoteError: this.remoteError,
53
+ };
54
+ }
55
+ /**
56
+ * Parses and validates a plain object as TrellisErrorData.
57
+ * Use this to deserialize errors received from remote services.
58
+ *
59
+ * @param obj - Plain object to validate
60
+ * @returns Result containing validated TrellisError or a ValidationError or UnexpectedError
61
+ */
62
+ static parse(data) {
63
+ return trellis_result_1.Result.try(() => typeof data === "string" ? JSON.parse(data) : data).andThen((obj) => {
64
+ const parseResult = trellis_result_1.Result.try(() => value_1.Value.Parse(TrellisError_js_2.TrellisErrorDataSchema, obj));
65
+ if (parseResult.isErr()) {
66
+ const cause = parseResult.error.cause;
67
+ if (cause instanceof value_1.ParseError) {
68
+ const errors = value_1.Value.Errors(TrellisError_js_2.TrellisErrorDataSchema, obj);
69
+ return trellis_result_1.Result.err(new ValidationError_js_1.ValidationError({ errors, cause }));
70
+ }
71
+ return trellis_result_1.Result.err(parseResult.error);
72
+ }
73
+ return trellis_result_1.Result.ok(parseResult.take());
74
+ });
75
+ }
76
+ }
77
+ exports.RemoteError = RemoteError;
78
+ /**
79
+ * Alias for parse() - parses JSON string or object as TrellisErrorData.
80
+ * @see parse
81
+ */
82
+ Object.defineProperty(RemoteError, "parseJSON", {
83
+ enumerable: true,
84
+ configurable: true,
85
+ writable: true,
86
+ value: RemoteError.parse
87
+ });
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Base class for all Trellis-specific errors.
3
+ * Extends BaseError and relies on the traceId getter being configured via initTracing.
4
+ */
5
+ import { BaseError, type BaseErrorSchema } from "@qlever-llc/trellis-result";
6
+ /**
7
+ * Abstract base class for Trellis errors.
8
+ * Trellis errors automatically include traceId when initTracing() has been called
9
+ * and a span is active in the current context.
10
+ *
11
+ * The traceId integration is configured by the tracing module's initTracing() function,
12
+ * which sets up BaseError.traceIdGetter to retrieve the traceId from the active span.
13
+ */
14
+ export declare abstract class TrellisError<TData extends BaseErrorSchema = BaseErrorSchema> extends BaseError<TData> {
15
+ }
16
+ //# sourceMappingURL=TrellisError.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TrellisError.d.ts","sourceRoot":"","sources":["../../../src/trellis/errors/TrellisError.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAE,SAAS,EAAE,KAAK,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAEtE;;;;;;;GAOG;AACH,8BAAsB,YAAY,CAChC,KAAK,SAAS,eAAe,GAAG,eAAe,CAC/C,SAAQ,SAAS,CAAC,KAAK,CAAC;CAGzB"}
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.TrellisError = void 0;
4
+ /**
5
+ * Base class for all Trellis-specific errors.
6
+ * Extends BaseError and relies on the traceId getter being configured via initTracing.
7
+ */
8
+ const mod_js_1 = require("@qlever-llc/trellis-result");
9
+ /**
10
+ * Abstract base class for Trellis errors.
11
+ * Trellis errors automatically include traceId when initTracing() has been called
12
+ * and a span is active in the current context.
13
+ *
14
+ * The traceId integration is configured by the tracing module's initTracing() function,
15
+ * which sets up BaseError.traceIdGetter to retrieve the traceId from the active span.
16
+ */
17
+ class TrellisError extends mod_js_1.BaseError {
18
+ }
19
+ exports.TrellisError = TrellisError;