@mionjs/core 0.8.0-alpha.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (136) hide show
  1. package/.dist/cjs/index.cjs +245 -0
  2. package/.dist/cjs/index.cjs.map +1 -0
  3. package/.dist/cjs/index.d.ts +21 -0
  4. package/.dist/cjs/package.json +1 -0
  5. package/.dist/cjs/src/binary/bodyDeserializer.cjs +54 -0
  6. package/.dist/cjs/src/binary/bodyDeserializer.cjs.map +1 -0
  7. package/.dist/cjs/src/binary/bodyDeserializer.d.ts +5 -0
  8. package/.dist/cjs/src/binary/bodySerializer.cjs +49 -0
  9. package/.dist/cjs/src/binary/bodySerializer.cjs.map +1 -0
  10. package/.dist/cjs/src/binary/bodySerializer.d.ts +6 -0
  11. package/.dist/cjs/src/binary/dataView.cjs +212 -0
  12. package/.dist/cjs/src/binary/dataView.cjs.map +1 -0
  13. package/.dist/cjs/src/binary/dataView.d.ts +16 -0
  14. package/.dist/cjs/src/constants.cjs +84 -0
  15. package/.dist/cjs/src/constants.cjs.map +1 -0
  16. package/.dist/cjs/src/constants.d.ts +50 -0
  17. package/.dist/cjs/src/errors.cjs +170 -0
  18. package/.dist/cjs/src/errors.cjs.map +1 -0
  19. package/.dist/cjs/src/errors.d.ts +24 -0
  20. package/.dist/cjs/src/friendlyErrors.cjs +235 -0
  21. package/.dist/cjs/src/friendlyErrors.cjs.map +1 -0
  22. package/.dist/cjs/src/friendlyErrors.d.ts +4 -0
  23. package/.dist/cjs/src/headers.cjs +11 -0
  24. package/.dist/cjs/src/headers.cjs.map +1 -0
  25. package/.dist/cjs/src/headers.d.ts +12 -0
  26. package/.dist/cjs/src/jit/jitUtils.cjs +173 -0
  27. package/.dist/cjs/src/jit/jitUtils.cjs.map +1 -0
  28. package/.dist/cjs/src/jit/jitUtils.d.ts +30 -0
  29. package/.dist/cjs/src/pureFns/pureFn.cjs +80 -0
  30. package/.dist/cjs/src/pureFns/pureFn.cjs.map +1 -0
  31. package/.dist/cjs/src/pureFns/pureFn.d.ts +2 -0
  32. package/.dist/cjs/src/pureFns/pureServerFn.cjs +20 -0
  33. package/.dist/cjs/src/pureFns/pureServerFn.cjs.map +1 -0
  34. package/.dist/cjs/src/pureFns/pureServerFn.d.ts +4 -0
  35. package/.dist/cjs/src/pureFns/quickHash.cjs +62 -0
  36. package/.dist/cjs/src/pureFns/quickHash.cjs.map +1 -0
  37. package/.dist/cjs/src/pureFns/quickHash.d.ts +7 -0
  38. package/.dist/cjs/src/pureFns/restoreJitFns.cjs +88 -0
  39. package/.dist/cjs/src/pureFns/restoreJitFns.cjs.map +1 -0
  40. package/.dist/cjs/src/pureFns/restoreJitFns.d.ts +3 -0
  41. package/.dist/cjs/src/routerUtils.cjs +209 -0
  42. package/.dist/cjs/src/routerUtils.cjs.map +1 -0
  43. package/.dist/cjs/src/routerUtils.d.ts +24 -0
  44. package/.dist/cjs/src/types/formats/formatBrands.types.cjs +45 -0
  45. package/.dist/cjs/src/types/formats/formatBrands.types.cjs.map +1 -0
  46. package/.dist/cjs/src/types/formats/formatBrands.types.d.ts +45 -0
  47. package/.dist/cjs/src/types/formats/formats.types.cjs +27 -0
  48. package/.dist/cjs/src/types/formats/formats.types.cjs.map +1 -0
  49. package/.dist/cjs/src/types/formats/formats.types.d.ts +37 -0
  50. package/.dist/cjs/src/types/formats/formatsParams.types.cjs +60 -0
  51. package/.dist/cjs/src/types/formats/formatsParams.types.cjs.map +1 -0
  52. package/.dist/cjs/src/types/formats/formatsParams.types.d.ts +234 -0
  53. package/.dist/cjs/src/types/formats/friendlyErrors.types.cjs +53 -0
  54. package/.dist/cjs/src/types/formats/friendlyErrors.types.cjs.map +1 -0
  55. package/.dist/cjs/src/types/formats/friendlyErrors.types.d.ts +71 -0
  56. package/.dist/cjs/src/types/general.types.cjs +145 -0
  57. package/.dist/cjs/src/types/general.types.cjs.map +1 -0
  58. package/.dist/cjs/src/types/general.types.d.ts +246 -0
  59. package/.dist/cjs/src/types/method.types.cjs +26 -0
  60. package/.dist/cjs/src/types/method.types.cjs.map +1 -0
  61. package/.dist/cjs/src/types/method.types.d.ts +60 -0
  62. package/.dist/cjs/src/types/pureFunctions.types.cjs +39 -0
  63. package/.dist/cjs/src/types/pureFunctions.types.cjs.map +1 -0
  64. package/.dist/cjs/src/types/pureFunctions.types.d.ts +75 -0
  65. package/.dist/cjs/src/utils.cjs +47 -0
  66. package/.dist/cjs/src/utils.cjs.map +1 -0
  67. package/.dist/cjs/src/utils.d.ts +9 -0
  68. package/.dist/esm/index.d.ts +21 -0
  69. package/.dist/esm/index.js +245 -0
  70. package/.dist/esm/index.js.map +1 -0
  71. package/.dist/esm/src/binary/bodyDeserializer.d.ts +5 -0
  72. package/.dist/esm/src/binary/bodyDeserializer.js +54 -0
  73. package/.dist/esm/src/binary/bodyDeserializer.js.map +1 -0
  74. package/.dist/esm/src/binary/bodySerializer.d.ts +6 -0
  75. package/.dist/esm/src/binary/bodySerializer.js +49 -0
  76. package/.dist/esm/src/binary/bodySerializer.js.map +1 -0
  77. package/.dist/esm/src/binary/dataView.d.ts +16 -0
  78. package/.dist/esm/src/binary/dataView.js +212 -0
  79. package/.dist/esm/src/binary/dataView.js.map +1 -0
  80. package/.dist/esm/src/constants.d.ts +50 -0
  81. package/.dist/esm/src/constants.js +84 -0
  82. package/.dist/esm/src/constants.js.map +1 -0
  83. package/.dist/esm/src/errors.d.ts +24 -0
  84. package/.dist/esm/src/errors.js +170 -0
  85. package/.dist/esm/src/errors.js.map +1 -0
  86. package/.dist/esm/src/friendlyErrors.d.ts +4 -0
  87. package/.dist/esm/src/friendlyErrors.js +235 -0
  88. package/.dist/esm/src/friendlyErrors.js.map +1 -0
  89. package/.dist/esm/src/headers.d.ts +12 -0
  90. package/.dist/esm/src/headers.js +11 -0
  91. package/.dist/esm/src/headers.js.map +1 -0
  92. package/.dist/esm/src/jit/jitUtils.d.ts +30 -0
  93. package/.dist/esm/src/jit/jitUtils.js +173 -0
  94. package/.dist/esm/src/jit/jitUtils.js.map +1 -0
  95. package/.dist/esm/src/pureFns/pureFn.d.ts +2 -0
  96. package/.dist/esm/src/pureFns/pureFn.js +80 -0
  97. package/.dist/esm/src/pureFns/pureFn.js.map +1 -0
  98. package/.dist/esm/src/pureFns/pureServerFn.d.ts +4 -0
  99. package/.dist/esm/src/pureFns/pureServerFn.js +20 -0
  100. package/.dist/esm/src/pureFns/pureServerFn.js.map +1 -0
  101. package/.dist/esm/src/pureFns/quickHash.d.ts +7 -0
  102. package/.dist/esm/src/pureFns/quickHash.js +62 -0
  103. package/.dist/esm/src/pureFns/quickHash.js.map +1 -0
  104. package/.dist/esm/src/pureFns/restoreJitFns.d.ts +3 -0
  105. package/.dist/esm/src/pureFns/restoreJitFns.js +88 -0
  106. package/.dist/esm/src/pureFns/restoreJitFns.js.map +1 -0
  107. package/.dist/esm/src/routerUtils.d.ts +24 -0
  108. package/.dist/esm/src/routerUtils.js +209 -0
  109. package/.dist/esm/src/routerUtils.js.map +1 -0
  110. package/.dist/esm/src/types/formats/formatBrands.types.d.ts +45 -0
  111. package/.dist/esm/src/types/formats/formatBrands.types.js +45 -0
  112. package/.dist/esm/src/types/formats/formatBrands.types.js.map +1 -0
  113. package/.dist/esm/src/types/formats/formats.types.d.ts +37 -0
  114. package/.dist/esm/src/types/formats/formats.types.js +27 -0
  115. package/.dist/esm/src/types/formats/formats.types.js.map +1 -0
  116. package/.dist/esm/src/types/formats/formatsParams.types.d.ts +234 -0
  117. package/.dist/esm/src/types/formats/formatsParams.types.js +60 -0
  118. package/.dist/esm/src/types/formats/formatsParams.types.js.map +1 -0
  119. package/.dist/esm/src/types/formats/friendlyErrors.types.d.ts +71 -0
  120. package/.dist/esm/src/types/formats/friendlyErrors.types.js +53 -0
  121. package/.dist/esm/src/types/formats/friendlyErrors.types.js.map +1 -0
  122. package/.dist/esm/src/types/general.types.d.ts +246 -0
  123. package/.dist/esm/src/types/general.types.js +145 -0
  124. package/.dist/esm/src/types/general.types.js.map +1 -0
  125. package/.dist/esm/src/types/method.types.d.ts +60 -0
  126. package/.dist/esm/src/types/method.types.js +26 -0
  127. package/.dist/esm/src/types/method.types.js.map +1 -0
  128. package/.dist/esm/src/types/pureFunctions.types.d.ts +75 -0
  129. package/.dist/esm/src/types/pureFunctions.types.js +39 -0
  130. package/.dist/esm/src/types/pureFunctions.types.js.map +1 -0
  131. package/.dist/esm/src/utils.d.ts +9 -0
  132. package/.dist/esm/src/utils.js +47 -0
  133. package/.dist/esm/src/utils.js.map +1 -0
  134. package/LICENSE +21 -0
  135. package/README.md +32 -0
  136. package/package.json +58 -0
@@ -0,0 +1,50 @@
1
+ import { CoreRouterOptions } from './types/general.types.ts';
2
+ export declare const DEFAULT_CORE_OPTIONS: CoreRouterOptions;
3
+ export declare const PATH_SEPARATOR = "/";
4
+ export declare const ROUTE_PATH_ROOT = "/";
5
+ export declare const ROUTER_ITEM_SEPARATOR_CHAR = "/";
6
+ export declare const MAX_UNKNOWN_KEYS = 10;
7
+ export declare const MAX_STACK_DEPTH = 50;
8
+ export declare const MION_ROUTES: {
9
+ readonly methodsMetadataById: "mion@methodsMetadataById";
10
+ readonly methodsMetadataByPath: "mion@methodsMetadataByPath";
11
+ readonly platformError: "mion@platformError";
12
+ readonly notFound: "mion@notFound";
13
+ readonly thrownErrors: "@thrownErrors";
14
+ };
15
+ export declare const MIME_TYPES: {
16
+ readonly json: "application/json";
17
+ readonly octetStream: "application/octet-stream";
18
+ };
19
+ export declare const StatusCodes: {
20
+ readonly SERVER_ERROR: 500;
21
+ readonly APPLICATION_ERROR: 400;
22
+ readonly UNEXPECTED_ERROR: 422;
23
+ readonly NOT_FOUND: 404;
24
+ readonly OK: 200;
25
+ };
26
+ export declare const HandlerType: {
27
+ readonly route: 1;
28
+ readonly middleFn: 2;
29
+ readonly headersMiddleFn: 3;
30
+ readonly rawMiddleFn: 4;
31
+ };
32
+ export declare const JIT_FUNCTION_IDS: {
33
+ readonly isType: "is";
34
+ readonly typeErrors: "te";
35
+ readonly prepareForJson: "tj";
36
+ readonly restoreFromJson: "fj";
37
+ readonly stringifyJson: "sj";
38
+ readonly toJSCode: "tc";
39
+ readonly toBinary: "tBi";
40
+ readonly fromBinary: "fBi";
41
+ readonly format: "fmt";
42
+ readonly unknownKeyErrors: "uk";
43
+ readonly hasUnknownKeys: "hk";
44
+ readonly stripUnknownKeys: "sk";
45
+ readonly unknownKeysToUndefined: "ku";
46
+ readonly aux: "aux";
47
+ readonly mock: "mock";
48
+ readonly pureFunction: "pf";
49
+ };
50
+ export declare const EMPTY_HASH = "";
@@ -0,0 +1,84 @@
1
+ const DEFAULT_CORE_OPTIONS = {
2
+ /** automatically generate and uuid */
3
+ autoGenerateErrorId: false
4
+ };
5
+ const PATH_SEPARATOR = "/";
6
+ const ROUTE_PATH_ROOT = PATH_SEPARATOR;
7
+ const ROUTER_ITEM_SEPARATOR_CHAR = "/";
8
+ const MAX_UNKNOWN_KEYS = 10;
9
+ const MAX_STACK_DEPTH = 50;
10
+ const MION_ROUTES = {
11
+ /** get remote methods metadata by method id */
12
+ methodsMetadataById: "mion@methodsMetadataById",
13
+ /** get remote methods metadata by route path, this include all middleFns in the ExecutionChain of the route. */
14
+ methodsMetadataByPath: "mion@methodsMetadataByPath",
15
+ /** Platform or adapters errors that occur before reaching the router or outside the router and are platform/adapter related */
16
+ platformError: "mion@platformError",
17
+ /** not-found route. This route is called when a requested route doesn't exist */
18
+ notFound: "mion@notFound",
19
+ /**
20
+ * !IMPORTANT!!
21
+ * This is technically not a route, but a special key used to store unexpected errors in the response body.
22
+ * is declared as a route to reuse existing router serialization/deserialization logic.
23
+ * Errors thrown by routes/middleFns, these are not strongly typed
24
+ * */
25
+ thrownErrors: "@thrownErrors"
26
+ };
27
+ const MIME_TYPES = {
28
+ json: "application/json",
29
+ octetStream: "application/octet-stream"
30
+ };
31
+ const StatusCodes = {
32
+ /** Any error in the server that is not related to the application, ie: server not ready, etc... */
33
+ SERVER_ERROR: 500,
34
+ /** Any expected and strongly typed error returned by a route/middleFn. ie: entity not found, etc. */
35
+ APPLICATION_ERROR: 400,
36
+ /** Any thrown or unexpected error in the application, ie: validation error, not found, etc, database error, serialization error, etc...
37
+ * These are are typically irrecoverable and can be handled globally, ie redirect to login page if auth fails
38
+ */
39
+ UNEXPECTED_ERROR: 422,
40
+ /** Not found error */
41
+ NOT_FOUND: 404,
42
+ /** Standard success code */
43
+ OK: 200
44
+ };
45
+ const HandlerType = {
46
+ route: 1,
47
+ middleFn: 2,
48
+ headersMiddleFn: 3,
49
+ rawMiddleFn: 4
50
+ };
51
+ const JIT_FUNCTION_IDS = {
52
+ isType: "is",
53
+ typeErrors: "te",
54
+ prepareForJson: "tj",
55
+ restoreFromJson: "fj",
56
+ stringifyJson: "sj",
57
+ toJSCode: "tc",
58
+ toBinary: "tBi",
59
+ fromBinary: "fBi",
60
+ format: "fmt",
61
+ unknownKeyErrors: "uk",
62
+ hasUnknownKeys: "hk",
63
+ stripUnknownKeys: "sk",
64
+ unknownKeysToUndefined: "ku",
65
+ aux: "aux",
66
+ mock: "mock",
67
+ pureFunction: "pf"
68
+ };
69
+ const EMPTY_HASH = "";
70
+ export {
71
+ DEFAULT_CORE_OPTIONS,
72
+ EMPTY_HASH,
73
+ HandlerType,
74
+ JIT_FUNCTION_IDS,
75
+ MAX_STACK_DEPTH,
76
+ MAX_UNKNOWN_KEYS,
77
+ MIME_TYPES,
78
+ MION_ROUTES,
79
+ PATH_SEPARATOR,
80
+ ROUTER_ITEM_SEPARATOR_CHAR,
81
+ ROUTE_PATH_ROOT,
82
+ StatusCodes
83
+ };
84
+ //# sourceMappingURL=constants.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -0,0 +1,24 @@
1
+ import { CoreRouterOptions, AnyErrorParams, TypedErrorParams, RpcErrorParams, RunTypeError } from './types/general.types.ts';
2
+ export interface ValidationErrorData {
3
+ typeErrors: RunTypeError[];
4
+ }
5
+ export type ValidationError = RpcError<'validation-error', ValidationErrorData>;
6
+ export declare function setErrorOptions(opts: CoreRouterOptions): void;
7
+ export declare class TypedError<ErrType extends string> extends Error {
8
+ readonly 'mion@isΣrrθr': true;
9
+ readonly type: ErrType;
10
+ constructor({ message, originalError, type }: TypedErrorParams<ErrType>);
11
+ }
12
+ export declare class RpcError<ErrType extends string, ErrData = any> extends TypedError<ErrType> implements RpcErrorParams<ErrType, ErrData> {
13
+ readonly id?: number | string;
14
+ readonly publicMessage: string;
15
+ readonly errorData?: Readonly<ErrData>;
16
+ statusCode?: number;
17
+ constructor({ message, publicMessage, originalError, errorData, type, id, statusCode }: AnyErrorParams<ErrType, ErrData>);
18
+ }
19
+ export declare function isTypedError(error: any): error is TypedError<any>;
20
+ export declare function isRpcError(error: any): error is RpcError<string>;
21
+ export declare function isAnyError(error: any): error is TypedError<any> | RpcError<string> | Error;
22
+ export declare function registerErrorDeserializers(): void;
23
+ export declare type __ΩValidationErrorData = any[];
24
+ export declare type __ΩValidationError = any[];
@@ -0,0 +1,170 @@
1
+ import { DEFAULT_CORE_OPTIONS } from "./constants.js";
2
+ import { randomUUID_V7 } from "./utils.js";
3
+ import { getJitUtils } from "./jit/jitUtils.js";
4
+ const __ΩReadonly = ["T", "Readonly", 'l+e#!e"!fRb!Pde"!gN#%w"y'];
5
+ const __ΩRecord = ["K", "T", "Record", `l'e#"Rb!b"Pde"!N#!w#y`];
6
+ function __assignType(fn, args) {
7
+ fn.__type = args;
8
+ return fn;
9
+ }
10
+ const __ΩValidationErrorData = ["RunTypeError", "typeErrors", "ValidationErrorData", 'P"w!F4"Mw#y'];
11
+ const __ΩValidationError = ["validation-error", () => __ΩValidationErrorData, () => RpcError, "ValidationError", 'P.!n"7#w$y'];
12
+ let options = { ...DEFAULT_CORE_OPTIONS };
13
+ function setErrorOptions(opts) {
14
+ options = opts;
15
+ }
16
+ setErrorOptions.__type = ["CoreRouterOptions", "opts", "setErrorOptions", 'P"w!2""/#'];
17
+ class TypedError extends Error {
18
+ /**
19
+ * Unique error identifier,
20
+ * Ideally this should be a symbol but we need to be able to serialize it so a namespaced prop is used instead
21
+ */
22
+ // eslint-disable-next-line @typescript-eslint/prefer-as-const
23
+ "mion@isΣrrθr" = true;
24
+ /** Error type, can be used as discriminator in union types*/
25
+ type;
26
+ // Note: message and name are NOT declared as properties here
27
+ // They are inherited from Error class and assigned in constructor
28
+ // This prevents them from being included in type reflection for JIT validation
29
+ constructor({ message, originalError, type }) {
30
+ const errorMessage = message || originalError?.message || "";
31
+ super(errorMessage);
32
+ this.type = type;
33
+ Object.defineProperty(this, "message", {
34
+ value: errorMessage,
35
+ writable: true,
36
+ enumerable: false,
37
+ configurable: true
38
+ });
39
+ Object.defineProperty(this, "name", {
40
+ value: "TypedError",
41
+ writable: true,
42
+ enumerable: false,
43
+ configurable: true
44
+ });
45
+ if (originalError?.stack) {
46
+ try {
47
+ this.stack = originalError.stack;
48
+ } catch {
49
+ try {
50
+ Object.defineProperty(this, "stack", {
51
+ value: originalError.stack,
52
+ writable: true,
53
+ configurable: true
54
+ });
55
+ } catch {
56
+ }
57
+ }
58
+ }
59
+ Object.setPrototypeOf(this, TypedError.prototype);
60
+ }
61
+ static __type = ["ErrType", () => Error, true, "mion@isΣrrθr", function() {
62
+ return true;
63
+ }, "type", "TypedErrorParams", "param0", "constructor", "TypedError", `b!P7".#3$9>%e!!3&9P"w'2("0)5w*`];
64
+ }
65
+ class RpcError extends TypedError {
66
+ // Note: name is NOT declared as a property here
67
+ // It is inherited from Error class and assigned in constructor
68
+ // This prevents it from being included in type reflection for JIT validation
69
+ /**
70
+ * id of the error, ideally each error should unique identifiable
71
+ * * if RouterOptions.autoGenerateErrorId is set to true and id with timestamp+uuid will be generated
72
+ * */
73
+ id;
74
+ /** the message that will be returned in the response */
75
+ publicMessage;
76
+ /** options data related to the error, ie validation data, must be json serializable */
77
+ errorData;
78
+ /** optional http status code */
79
+ statusCode;
80
+ constructor({ message, publicMessage, originalError, errorData, type, id, statusCode }) {
81
+ const originalMessage = message || originalError?.message || publicMessage || "";
82
+ super({
83
+ message: originalMessage,
84
+ originalError,
85
+ type
86
+ });
87
+ const { autoGenerateErrorId } = options;
88
+ this.id = id ?? (autoGenerateErrorId ? randomUUID_V7() : void 0);
89
+ this.publicMessage = publicMessage || "";
90
+ this.errorData = errorData;
91
+ this.statusCode = statusCode;
92
+ Object.defineProperty(this, "name", {
93
+ value: "RpcError",
94
+ writable: true,
95
+ enumerable: false,
96
+ configurable: true
97
+ });
98
+ Object.setPrototypeOf(this, RpcError.prototype);
99
+ }
100
+ static __type = ["ErrType", "ErrData", () => TypedError, "id", "publicMessage", () => __ΩReadonly, "errorData", "statusCode", "AnyErrorParams", "param0", "constructor", "RpcErrorParams", "RpcError", `b!"c"Pe"!7#P'&J3$89&3%9e!"o&"3'89'3(8P"w)2*"0+5e!!6""w,x"w-`];
101
+ }
102
+ function hasUnknownKeys(obj, keys) {
103
+ for (const prop in obj) {
104
+ let found = false;
105
+ for (let j = 0; j < keys.length; j++) {
106
+ if (keys[j] === prop) {
107
+ found = true;
108
+ break;
109
+ }
110
+ }
111
+ if (!found)
112
+ return true;
113
+ }
114
+ return false;
115
+ }
116
+ hasUnknownKeys.__type = [() => __ΩRecord, "StrNumber", "obj", "keys", "hasUnknownKeys", 'P"w""o!#2#"w"F2$)/%'];
117
+ function isTypedError(error) {
118
+ if (!error)
119
+ return false;
120
+ if (error instanceof TypedError)
121
+ return true;
122
+ return error && error["mion@isΣrrθr"] === true && (typeof error.type === "string" || typeof error.type === "number") && !hasUnknownKeys(error, ["mion@isΣrrθr", "type", "message"]);
123
+ }
124
+ isTypedError.__type = ["error", "isTypedError", 'P"2!!/"'];
125
+ function isRpcError(error) {
126
+ if (!error)
127
+ return false;
128
+ if (error instanceof RpcError)
129
+ return true;
130
+ return error && error["mion@isΣrrθr"] === true && (typeof error.type === "string" || typeof error.type === "number") && (error.id === void 0 || typeof error.id === "string" || typeof error.id === "number") && !hasUnknownKeys(error, ["mion@isΣrrθr", "id", "message", "publicMessage", "errorData", "type", "statusCode"]);
131
+ }
132
+ isRpcError.__type = ["error", "isRpcError", 'P"2!!/"'];
133
+ function isAnyError(error) {
134
+ if (!error)
135
+ return false;
136
+ const tErr = error;
137
+ if (tErr["mion@isΣrrθr"] === true)
138
+ return true;
139
+ if (typeof Error.isError === "function")
140
+ return Error.isError(error);
141
+ return error instanceof Error;
142
+ }
143
+ isAnyError.__type = ["error", "isAnyError", 'P"2!!/"'];
144
+ let errorDeserializersRegistered = false;
145
+ function registerErrorDeserializers() {
146
+ if (errorDeserializersRegistered)
147
+ return;
148
+ if (!TypedError || !RpcError)
149
+ return;
150
+ errorDeserializersRegistered = true;
151
+ getJitUtils().setDeserializeFn(TypedError, __assignType((data) => {
152
+ return new TypedError(data);
153
+ }, ["DataOnly", "data", "", 'P"w!2""/#']));
154
+ getJitUtils().setDeserializeFn(RpcError, __assignType((data) => {
155
+ return new RpcError(data);
156
+ }, ["DataOnly", "data", "", 'P"w!2""/#']));
157
+ }
158
+ registerErrorDeserializers.__type = ["registerErrorDeserializers", 'P"/!'];
159
+ export {
160
+ RpcError,
161
+ TypedError,
162
+ __ΩValidationError,
163
+ __ΩValidationErrorData,
164
+ isAnyError,
165
+ isRpcError,
166
+ isTypedError,
167
+ registerErrorDeserializers,
168
+ setErrorOptions
169
+ };
170
+ //# sourceMappingURL=errors.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -0,0 +1,4 @@
1
+ import { RunTypeError } from './types/general.types.ts';
2
+ import { FriendlyErrors, FriendlyErrorsResult } from './types/formats/friendlyErrors.types.ts';
3
+ export declare function defaultErrorPrinter(error: RunTypeError): string;
4
+ export declare function getFriendlyErrors<T>(errors: RunTypeError[], errorsMap?: FriendlyErrors<T>): FriendlyErrorsResult<T>;
@@ -0,0 +1,235 @@
1
+ import { isTestEnv } from "./utils.js";
2
+ function isMapKeyPath(segment) {
3
+ return typeof segment === "object" && segment !== null && "failed" in segment && segment.failed === "mapKey";
4
+ }
5
+ function isMapValuePath(segment) {
6
+ return typeof segment === "object" && segment !== null && "failed" in segment && segment.failed === "mapVal";
7
+ }
8
+ function isSetItemPath(segment) {
9
+ return typeof segment === "object" && segment !== null && "key" in segment && "index" in segment && !("failed" in segment);
10
+ }
11
+ function defaultErrorPrinter(error) {
12
+ const lastSegment = error.path.length > 0 ? error.path[error.path.length - 1] : "value";
13
+ let prop;
14
+ if (isMapKeyPath(lastSegment)) {
15
+ prop = `mapKey[${lastSegment.index}]`;
16
+ } else if (isMapValuePath(lastSegment)) {
17
+ prop = `mapValue[${lastSegment.index}]`;
18
+ } else if (isSetItemPath(lastSegment)) {
19
+ prop = `setItem[${lastSegment.index}]`;
20
+ } else {
21
+ prop = lastSegment;
22
+ }
23
+ if (error.format) {
24
+ const param = error.format.formatPath[0];
25
+ return `${prop}: ${param} validation failed (expected ${error.format.val})`;
26
+ }
27
+ return `${prop}: expected ${error.expected}`;
28
+ }
29
+ function mergeErrorIntoParams(params, error) {
30
+ params.rtErrors.push(error);
31
+ params.rtError = error;
32
+ if (error.format) {
33
+ const paramKey = error.format.formatPath[0];
34
+ params[paramKey] = error.format;
35
+ }
36
+ }
37
+ function createAggregatedParams(error) {
38
+ const lastSegment = error.path[error.path.length - 1];
39
+ let propName;
40
+ let index;
41
+ let mapErrorType;
42
+ if (isMapKeyPath(lastSegment)) {
43
+ propName = lastSegment.index;
44
+ index = lastSegment.index;
45
+ mapErrorType = "key";
46
+ } else if (isMapValuePath(lastSegment)) {
47
+ propName = lastSegment.index;
48
+ index = lastSegment.index;
49
+ mapErrorType = "value";
50
+ } else if (isSetItemPath(lastSegment)) {
51
+ propName = lastSegment.index;
52
+ index = lastSegment.index;
53
+ } else {
54
+ propName = lastSegment;
55
+ index = typeof propName === "number" ? propName : void 0;
56
+ }
57
+ const params = {
58
+ rtError: error,
59
+ rtErrors: [error],
60
+ propName,
61
+ index,
62
+ mapErrorType
63
+ };
64
+ if (error.format) {
65
+ const paramKey = error.format.formatPath[0];
66
+ params[paramKey] = error.format;
67
+ }
68
+ return params;
69
+ }
70
+ function pathToKey(path) {
71
+ return path.map((segment) => {
72
+ if (isMapKeyPath(segment)) {
73
+ return `$mapKey[${segment.index}]`;
74
+ } else if (isMapValuePath(segment)) {
75
+ return `$mapVal[${segment.index}]`;
76
+ } else if (isSetItemPath(segment)) {
77
+ return `$setItem[${segment.index}]`;
78
+ }
79
+ return String(segment);
80
+ }).join(".");
81
+ }
82
+ function getOrCreatePath(obj, path) {
83
+ if (path.length === 0) return null;
84
+ let current = obj;
85
+ for (let i = 0; i < path.length - 1; i++) {
86
+ const segment = path[i];
87
+ let key;
88
+ if (isMapKeyPath(segment)) {
89
+ if (current["$keys"] === void 0) {
90
+ current["$keys"] = {};
91
+ }
92
+ current = current["$keys"];
93
+ key = segment.index;
94
+ } else if (isMapValuePath(segment)) {
95
+ if (current["$values"] === void 0) {
96
+ current["$values"] = {};
97
+ }
98
+ current = current["$values"];
99
+ key = segment.index;
100
+ } else if (isSetItemPath(segment)) {
101
+ key = segment.index;
102
+ } else {
103
+ key = segment;
104
+ }
105
+ if (current[key] === void 0) {
106
+ current[key] = {};
107
+ }
108
+ current = current[key];
109
+ }
110
+ const lastSegment = path[path.length - 1];
111
+ let finalKey;
112
+ if (isMapKeyPath(lastSegment)) {
113
+ if (current["$keys"] === void 0) {
114
+ current["$keys"] = {};
115
+ }
116
+ return { target: current["$keys"], key: lastSegment.index };
117
+ } else if (isMapValuePath(lastSegment)) {
118
+ if (current["$values"] === void 0) {
119
+ current["$values"] = {};
120
+ }
121
+ return { target: current["$values"], key: lastSegment.index };
122
+ } else if (isSetItemPath(lastSegment)) {
123
+ finalKey = lastSegment.index;
124
+ } else {
125
+ finalKey = lastSegment;
126
+ }
127
+ return { target: current, key: finalKey };
128
+ }
129
+ function getHandler(errorsMap, path) {
130
+ if (!errorsMap) return null;
131
+ if (typeof errorsMap === "function") {
132
+ return errorsMap;
133
+ }
134
+ let current = errorsMap;
135
+ for (let i = 0; i < path.length; i++) {
136
+ const segment = path[i];
137
+ if (current === void 0 || current === null) return null;
138
+ if (isMapKeyPath(segment)) {
139
+ if (typeof current === "object" && current !== null && "$key" in current) {
140
+ const keyHandler = current["$key"];
141
+ if (typeof keyHandler === "function") {
142
+ return keyHandler;
143
+ }
144
+ }
145
+ if (typeof current === "function") {
146
+ return current;
147
+ }
148
+ return null;
149
+ }
150
+ if (isMapValuePath(segment)) {
151
+ if (typeof current === "object" && current !== null && "$value" in current) {
152
+ const valueHandler = current["$value"];
153
+ if (typeof valueHandler === "function") {
154
+ return valueHandler;
155
+ }
156
+ current = valueHandler;
157
+ continue;
158
+ }
159
+ if (typeof current === "function") {
160
+ return current;
161
+ }
162
+ return null;
163
+ }
164
+ if (isSetItemPath(segment)) {
165
+ if (typeof current === "object" && current !== null && "$item" in current) {
166
+ const itemHandler = current["$item"];
167
+ if (typeof itemHandler === "function") {
168
+ return itemHandler;
169
+ }
170
+ current = itemHandler;
171
+ continue;
172
+ }
173
+ if (typeof current === "function") {
174
+ return current;
175
+ }
176
+ return null;
177
+ }
178
+ if (typeof segment === "number") {
179
+ if (typeof current === "function") {
180
+ return current;
181
+ }
182
+ continue;
183
+ }
184
+ if (typeof current === "function") return null;
185
+ current = current[segment];
186
+ }
187
+ if (typeof current === "function") {
188
+ return current;
189
+ }
190
+ return null;
191
+ }
192
+ function getFriendlyErrors(errors, errorsMap) {
193
+ const result = {};
194
+ const aggregatedByPath = /* @__PURE__ */ new Map();
195
+ for (const error of errors) {
196
+ const pathKey = pathToKey(error.path);
197
+ const existing = aggregatedByPath.get(pathKey);
198
+ if (existing) {
199
+ mergeErrorIntoParams(existing, error);
200
+ } else {
201
+ aggregatedByPath.set(pathKey, createAggregatedParams(error));
202
+ }
203
+ }
204
+ for (const [pathKey, aggregatedParams] of aggregatedByPath) {
205
+ const path = aggregatedParams.rtErrors[0].path;
206
+ const handler = getHandler(errorsMap, path);
207
+ let message;
208
+ if (handler) {
209
+ message = handler(aggregatedParams);
210
+ } else {
211
+ if (!isTestEnv()) {
212
+ console.warn(
213
+ `[mion] Using defaultErrorPrinter for "${pathKey || "$root"}". Consider providing a custom error handler for better user-facing messages.`
214
+ );
215
+ }
216
+ const messages = aggregatedParams.rtErrors.map((err) => defaultErrorPrinter(err));
217
+ message = [...new Set(messages)].join("; ");
218
+ }
219
+ if (path.length === 0) {
220
+ result["$root"] = message;
221
+ } else {
222
+ const pathInfo = getOrCreatePath(result, path);
223
+ if (pathInfo) {
224
+ const { target, key } = pathInfo;
225
+ target[key] = message;
226
+ }
227
+ }
228
+ }
229
+ return result;
230
+ }
231
+ export {
232
+ defaultErrorPrinter,
233
+ getFriendlyErrors
234
+ };
235
+ //# sourceMappingURL=friendlyErrors.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"friendlyErrors.js","sources":["../../../src/friendlyErrors.ts"],"sourcesContent":["/* ########\n * 2025 mion\n * Author: Ma-jerez\n * License: MIT\n * The software is provided \"as is\", without warranty of any kind.\n * ######## */\n\nimport type {\n RunTypeError,\n StrNumber,\n PathSegment,\n MapKeyPathSegment,\n MapValuePathSegment,\n SetItemPathSegment,\n} from './types/general.types.ts';\nimport type {\n FriendlyErrors,\n FriendlyErrorsResult,\n AnyFriendlyErrorParams,\n TypeErrorParam,\n} from './types/formats/friendlyErrors.types.ts';\nimport {isTestEnv} from './utils.ts';\n\n// ============================================================================\n// Map/Set Path Type Guards\n// ============================================================================\n\n/** Check if a path segment is a Map key error */\nfunction isMapKeyPath(segment: unknown): segment is MapKeyPathSegment {\n return (\n typeof segment === 'object' &&\n segment !== null &&\n 'failed' in segment &&\n (segment as MapKeyPathSegment).failed === 'mapKey'\n );\n}\n\n/** Check if a path segment is a Map value error */\nfunction isMapValuePath(segment: unknown): segment is MapValuePathSegment {\n return (\n typeof segment === 'object' &&\n segment !== null &&\n 'failed' in segment &&\n (segment as MapValuePathSegment).failed === 'mapVal'\n );\n}\n\n/** Check if a path segment is a Set item error (has key and index but no failed property) */\nfunction isSetItemPath(segment: unknown): segment is SetItemPathSegment {\n return typeof segment === 'object' && segment !== null && 'key' in segment && 'index' in segment && !('failed' in segment);\n}\n\n// ============================================================================\n// Default Error Printer\n// ============================================================================\n\n/**\n * Default error message generator used when no handler is provided.\n * Generates a human-readable message from the RunTypeError.\n * Uses only the last item in the path (the property that failed).\n */\nexport function defaultErrorPrinter(error: RunTypeError): string {\n const lastSegment = error.path.length > 0 ? error.path[error.path.length - 1] : 'value';\n\n // Handle Map/Set path segments\n let prop: StrNumber;\n if (isMapKeyPath(lastSegment)) {\n prop = `mapKey[${lastSegment.index}]`;\n } else if (isMapValuePath(lastSegment)) {\n prop = `mapValue[${lastSegment.index}]`;\n } else if (isSetItemPath(lastSegment)) {\n prop = `setItem[${lastSegment.index}]`;\n } else {\n prop = lastSegment as StrNumber;\n }\n\n if (error.format) {\n const param = error.format.formatPath[0];\n return `${prop}: ${param} validation failed (expected ${error.format.val})`;\n }\n return `${prop}: expected ${error.expected}`;\n}\n\n// ============================================================================\n// Aggregated Error Params\n// ============================================================================\n\n/**\n * Aggregated error params for a single field.\n * Contains all format errors merged together plus the base TypeErrorParam fields.\n */\ntype AggregatedErrorParams = TypeErrorParam & {\n /** All RunTypeErrors for this field */\n rtErrors: RunTypeError[];\n /** For Map errors: whether this is a key or value error */\n mapErrorType?: 'key' | 'value';\n};\n\n/**\n * Merges a RunTypeError into an existing aggregated params object.\n * If error has format, adds the format param key to the object.\n */\nfunction mergeErrorIntoParams(params: AggregatedErrorParams, error: RunTypeError): void {\n params.rtErrors.push(error);\n // Update rtError to the latest error (for backward compatibility)\n params.rtError = error;\n if (error.format) {\n const paramKey = error.format.formatPath[0];\n (params as Record<string, unknown>)[paramKey] = error.format;\n }\n}\n\n/**\n * Creates initial aggregated error params from a RunTypeError.\n */\nfunction createAggregatedParams(error: RunTypeError): AggregatedErrorParams {\n const lastSegment = error.path[error.path.length - 1];\n\n let propName: string | number;\n let index: number | undefined;\n let mapErrorType: 'key' | 'value' | undefined;\n\n if (isMapKeyPath(lastSegment)) {\n propName = lastSegment.index;\n index = lastSegment.index;\n mapErrorType = 'key';\n } else if (isMapValuePath(lastSegment)) {\n propName = lastSegment.index;\n index = lastSegment.index;\n mapErrorType = 'value';\n } else if (isSetItemPath(lastSegment)) {\n propName = lastSegment.index;\n index = lastSegment.index;\n } else {\n propName = lastSegment as StrNumber;\n index = typeof propName === 'number' ? propName : undefined;\n }\n\n const params: AggregatedErrorParams = {\n rtError: error,\n rtErrors: [error],\n propName,\n index,\n mapErrorType,\n };\n\n if (error.format) {\n const paramKey = error.format.formatPath[0];\n (params as Record<string, unknown>)[paramKey] = error.format;\n }\n\n return params;\n}\n\n// ============================================================================\n// Path Utilities\n// ============================================================================\n\n/**\n * Converts a path array to a string key for grouping errors.\n * Handles Map/Set path segments by converting them to a string representation.\n */\nfunction pathToKey(path: PathSegment[]): string {\n return path\n .map((segment) => {\n if (isMapKeyPath(segment)) {\n return `$mapKey[${segment.index}]`;\n } else if (isMapValuePath(segment)) {\n return `$mapVal[${segment.index}]`;\n } else if (isSetItemPath(segment)) {\n return `$setItem[${segment.index}]`;\n }\n return String(segment);\n })\n .join('.');\n}\n\n/**\n * Gets or creates a nested object at the given path.\n * Returns the target object and the final key.\n * Handles Map/Set path segments by creating appropriate result structure.\n */\nfunction getOrCreatePath(\n obj: Record<StrNumber, unknown>,\n path: PathSegment[]\n): {target: Record<StrNumber, unknown>; key: StrNumber} | null {\n if (path.length === 0) return null;\n\n let current = obj;\n for (let i = 0; i < path.length - 1; i++) {\n const segment = path[i];\n\n let key: StrNumber;\n if (isMapKeyPath(segment)) {\n // For Map key errors, create $keys container\n if (current['$keys'] === undefined) {\n current['$keys'] = {};\n }\n current = current['$keys'] as Record<StrNumber, unknown>;\n key = segment.index;\n } else if (isMapValuePath(segment)) {\n // For Map value errors, create $values container\n if (current['$values'] === undefined) {\n current['$values'] = {};\n }\n current = current['$values'] as Record<StrNumber, unknown>;\n key = segment.index;\n } else if (isSetItemPath(segment)) {\n // For Set item errors, use index directly\n key = segment.index;\n } else {\n key = segment as StrNumber;\n }\n\n if (current[key] === undefined) {\n current[key] = {};\n }\n current = current[key] as Record<StrNumber, unknown>;\n }\n\n // Handle the final segment\n const lastSegment = path[path.length - 1];\n let finalKey: StrNumber;\n\n if (isMapKeyPath(lastSegment)) {\n // For Map key errors at the end, create $keys container\n if (current['$keys'] === undefined) {\n current['$keys'] = {};\n }\n return {target: current['$keys'] as Record<StrNumber, unknown>, key: lastSegment.index};\n } else if (isMapValuePath(lastSegment)) {\n // For Map value errors at the end, create $values container\n if (current['$values'] === undefined) {\n current['$values'] = {};\n }\n return {target: current['$values'] as Record<StrNumber, unknown>, key: lastSegment.index};\n } else if (isSetItemPath(lastSegment)) {\n // For Set item errors, use index directly\n finalKey = lastSegment.index;\n } else {\n finalKey = lastSegment as StrNumber;\n }\n\n return {target: current, key: finalKey};\n}\n\n// ============================================================================\n// Handler Lookup\n// ============================================================================\n\n/** Runtime type for error params - union of all possible error param types */\ntype RuntimeErrorParams = AnyFriendlyErrorParams | TypeErrorParam;\n\n/**\n * Gets the handler for a given path from the errors map.\n * Returns null if no handler is found.\n * For arrays, the handler at the array property level applies to all indices.\n * For Maps, looks for $key or $value handlers.\n * For Sets, looks for $item handler.\n */\nfunction getHandler<T>(\n errorsMap: FriendlyErrors<T> | undefined,\n path: PathSegment[]\n): ((errors: RuntimeErrorParams) => string) | null {\n if (!errorsMap) return null;\n\n // Handle top-level array/Map/Set (errorsMap is a function)\n if (typeof errorsMap === 'function') {\n return errorsMap as (errors: RuntimeErrorParams) => string;\n }\n\n let current: unknown = errorsMap;\n\n for (let i = 0; i < path.length; i++) {\n const segment = path[i];\n if (current === undefined || current === null) return null;\n\n // Handle Map path segments\n if (isMapKeyPath(segment)) {\n // Look for $key handler\n if (typeof current === 'object' && current !== null && '$key' in current) {\n const keyHandler = (current as Record<string, unknown>)['$key'];\n if (typeof keyHandler === 'function') {\n return keyHandler as (errors: RuntimeErrorParams) => string;\n }\n }\n // If current is a function, it's a handler for the whole Map\n if (typeof current === 'function') {\n return current as (errors: RuntimeErrorParams) => string;\n }\n return null;\n }\n\n if (isMapValuePath(segment)) {\n // Look for $value handler\n if (typeof current === 'object' && current !== null && '$value' in current) {\n const valueHandler = (current as Record<string, unknown>)['$value'];\n if (typeof valueHandler === 'function') {\n return valueHandler as (errors: RuntimeErrorParams) => string;\n }\n // $value could be a nested FriendlyErrors object\n current = valueHandler;\n continue;\n }\n // If current is a function, it's a handler for the whole Map\n if (typeof current === 'function') {\n return current as (errors: RuntimeErrorParams) => string;\n }\n return null;\n }\n\n if (isSetItemPath(segment)) {\n // Look for $item handler\n if (typeof current === 'object' && current !== null && '$item' in current) {\n const itemHandler = (current as Record<string, unknown>)['$item'];\n if (typeof itemHandler === 'function') {\n return itemHandler as (errors: RuntimeErrorParams) => string;\n }\n // $item could be a nested FriendlyErrors object\n current = itemHandler;\n continue;\n }\n // If current is a function, it's a handler for the whole Set\n if (typeof current === 'function') {\n return current as (errors: RuntimeErrorParams) => string;\n }\n return null;\n }\n\n // Skip numeric segments (array indices) - handlers apply to all indices\n // But if current is already a function, return it (handler for array elements)\n if (typeof segment === 'number') {\n if (typeof current === 'function') {\n return current as (errors: RuntimeErrorParams) => string;\n }\n continue;\n }\n\n // If current is a function but we have more non-numeric path segments, no handler found\n if (typeof current === 'function') return null;\n\n current = (current as Record<string, unknown>)[segment];\n }\n\n if (typeof current === 'function') {\n return current as (errors: RuntimeErrorParams) => string;\n }\n return null;\n}\n\n// ============================================================================\n// Main Function\n// ============================================================================\n\n/**\n * Converts RunTypeError[] to friendly error messages using the provided error map.\n * Aggregates all validation errors per field before calling the error printer function once.\n * For properties without a handler, default error messages are generated and joined.\n *\n * Supports:\n * - Objects with nested properties\n * - Arrays (top-level and nested)\n * - Maps with separate $key and $value handlers\n * - Sets with $item handler\n *\n * @param errors - Array of validation errors from createTypeErrorsFn\n * @param errorsMap - Object mapping properties to error printer functions (optional)\n * @returns Object with same shape as T containing only properties with errors (single string per field)\n */\nexport function getFriendlyErrors<T>(errors: RunTypeError[], errorsMap?: FriendlyErrors<T>): FriendlyErrorsResult<T> {\n const result: Record<StrNumber, unknown> = {};\n\n // Step 1: Group errors by path and aggregate params\n const aggregatedByPath = new Map<string, AggregatedErrorParams>();\n\n for (const error of errors) {\n const pathKey = pathToKey(error.path as PathSegment[]);\n const existing = aggregatedByPath.get(pathKey);\n\n if (existing) {\n // Merge this error into existing aggregated params\n mergeErrorIntoParams(existing, error);\n } else {\n // Create new aggregated params for this path\n aggregatedByPath.set(pathKey, createAggregatedParams(error));\n }\n }\n\n // Step 2: Process each aggregated field and call handlers once per field\n for (const [pathKey, aggregatedParams] of aggregatedByPath) {\n const path = aggregatedParams.rtErrors[0].path as PathSegment[];\n const handler = getHandler(errorsMap, path);\n let message: string;\n\n if (handler) {\n // Call handler once with all aggregated params for this field\n message = handler(aggregatedParams);\n } else {\n // No handler: use defaultErrorPrinter for each error and join messages\n if (!isTestEnv()) {\n console.warn(\n `[mion] Using defaultErrorPrinter for \"${pathKey || '$root'}\". ` +\n `Consider providing a custom error handler for better user-facing messages.`\n );\n }\n // Generate default messages for all errors at this path and join them\n const messages = aggregatedParams.rtErrors.map((err) => defaultErrorPrinter(err));\n // Remove duplicates and join into single string\n message = [...new Set(messages)].join('; ');\n }\n\n // Store the single message\n if (path.length === 0) {\n // Root level error\n result['$root'] = message;\n } else {\n const pathInfo = getOrCreatePath(result, path);\n if (pathInfo) {\n const {target, key}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,iBAAiB,IAAI,OAAO;AAE7C,QAAI,UAAU;AAEV,2BAAqB,UAAU,KAAK;AAAA,IACxC,OAAO;AAEH,uBAAiB,IAAI,SAAS,uBAAuB,KAAK,CAAC;AAAA,IAC/D;AAAA,EACJ;AAGA,aAAW,CAAC,SAAS,gBAAgB,KAAK,kBAAkB;AACxD,UAAM,OAAO,iBAAiB,SAAS,CAAC,EAAE;AAC1C,UAAM,UAAU,WAAW,WAAW,IAAI;AAC1C,QAAI;AAEJ,QAAI,SAAS;AAET,gBAAU,QAAQ,gBAAgB;AAAA,IACtC,OAAO;AAEH,UAAI,CAAC,aAAa;AACd,gBAAQ;AAAA,UACJ,yCAAyC,WAAW,OAAO;AAAA,QAAA;AAAA,MAGnE;AAEA,YAAM,WAAW,iBAAiB,SAAS,IAAI,CAAC,QAAQ,oBAAoB,GAAG,CAAC;AAEhF,gBAAU,CAAC,GAAG,IAAI,IAAI,QAAQ,CAAC,EAAE,KAAK,IAAI;AAAA,IAC9C;AAGA,QAAI,KAAK,WAAW,GAAG;AAEnB,aAAO,OAAO,IAAI;AAAA,IACtB,OAAO;AACH,YAAM,WAAW,gBAAgB,QAAQ,IAAI;AAC7C,UAAI,UAAU;AACV,cAAM,EAAC,QAAQ,IAAA,IAAO;AACtB,eAAO,GAAG,IAAI;AAAA,MAClB;AAAA,IACJ;AAAA,EACJ;AAEA,SAAO;AACX;"}
@@ -0,0 +1,12 @@
1
+ export declare class HeadersSubset<Required extends string, Optional extends string = never> {
2
+ readonly headers: {
3
+ [K in Required]: string;
4
+ } & {
5
+ [K in Optional]?: string;
6
+ };
7
+ constructor(headers: {
8
+ [K in Required]: string;
9
+ } & {
10
+ [K in Optional]?: string;
11
+ });
12
+ }
@@ -0,0 +1,11 @@
1
+ class HeadersSubset {
2
+ headers;
3
+ constructor(headers) {
4
+ this.headers = headers;
5
+ }
6
+ static __type = ["Required", "Optional", "headers", "constructor", "HeadersSubset", `l+&R&R&R&Rb!!c"PPde#!N#!Pde#"N%"K3#9PPPde$!N'!Pde$"N)"K2#"0$5w%`];
7
+ }
8
+ export {
9
+ HeadersSubset
10
+ };
11
+ //# sourceMappingURL=headers.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"headers.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;"}