@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,209 @@
1
+ import { JIT_FUNCTION_IDS, EMPTY_HASH, ROUTE_PATH_ROOT, PATH_SEPARATOR, ROUTER_ITEM_SEPARATOR_CHAR } from "./constants.js";
2
+ import { getJitUtils } from "./jit/jitUtils.js";
3
+ const methodsCache = {};
4
+ const methodsOptionsCache = {};
5
+ const jitFunctionsCache = /* @__PURE__ */ new Map();
6
+ const headerJitFunctionsCache = /* @__PURE__ */ new Map();
7
+ const routesCache = {
8
+ /**
9
+ * Get method metadata from the router cache by id.
10
+ * @param id - The method id
11
+ * @returns The method metadata or undefined if not found
12
+ */
13
+ getMetadata(id) {
14
+ return methodsCache[id];
15
+ },
16
+ /**
17
+ * Set method metadata in the router cache
18
+ * @param id - The method id
19
+ * @param methodData - The method metadata
20
+ */
21
+ setMetadata(id, methodData) {
22
+ methodsCache[id] = methodData;
23
+ },
24
+ /**
25
+ * Check if the router cache contains a method by id.
26
+ * @param id - The method id
27
+ * @returns True if the method exists in the cache
28
+ */
29
+ hasMetadata(id) {
30
+ return id in methodsCache;
31
+ },
32
+ /**
33
+ * Get the raw router cache object.
34
+ * Use with caution - prefer using get/set/has methods.
35
+ * @returns The router cache object
36
+ */
37
+ getCache() {
38
+ return methodsCache;
39
+ },
40
+ /**
41
+ * Get method metadata with JIT functions restored from the router cache by id.
42
+ * This augments the MethodWithOptions with paramsJitFns and returnJitFns.
43
+ * JIT functions are cached in the entry after first access for performance.
44
+ * @param id - The method id
45
+ * @returns The method metadata with JIT functions or undefined if not found
46
+ */
47
+ getMethodJitFns(id) {
48
+ if (id in methodsCache) {
49
+ const cached = methodsCache[id];
50
+ if (cached.paramsJitFns && cached.returnJitFns) {
51
+ return cached;
52
+ }
53
+ }
54
+ const metadata = this.getMetadata(id);
55
+ if (!metadata) return void 0;
56
+ const paramsJitFns = getJitFunctionsFromHash(metadata.paramsJitHash);
57
+ const returnJitFns = getJitFunctionsFromHash(metadata.returnJitHash);
58
+ const headersParam = metadata.headersParam ? { ...metadata.headersParam, jitFns: getHeaderJitFunctionsFromHash(metadata.headersParam.jitHash) } : void 0;
59
+ const headersReturn = metadata.headersReturn ? { ...metadata.headersReturn, jitFns: getHeaderJitFunctionsFromHash(metadata.headersReturn.jitHash) } : void 0;
60
+ const result = {
61
+ ...metadata,
62
+ paramsJitFns,
63
+ returnJitFns,
64
+ headersParam,
65
+ headersReturn
66
+ };
67
+ methodsCache[id] = result;
68
+ return result;
69
+ },
70
+ /**
71
+ * Get method metadata with JIT functions restored from the router cache by id.
72
+ * @param id
73
+ * @returns
74
+ */
75
+ useMethodJitFns(id) {
76
+ const MethodWithOptsAndJitFns = this.getMethodJitFns(id);
77
+ if (!MethodWithOptsAndJitFns) throw new Error(`Metadata for remote method ${id} not found`);
78
+ return MethodWithOptsAndJitFns;
79
+ },
80
+ /**
81
+ * Set method metadata with JIT functions in the router cache.
82
+ * This stores the complete MethodWithOptsAndJitFns object directly.
83
+ * @param id - The method id
84
+ * @param MethodWithOptsAndJitFns - The method metadata with JIT functions
85
+ */
86
+ setMethodJitFns(id, MethodWithOptsAndJitFns) {
87
+ methodsCache[id] = MethodWithOptsAndJitFns;
88
+ }
89
+ };
90
+ const methodOptsCache = {
91
+ getMethodOptions(id) {
92
+ return methodsOptionsCache[id];
93
+ },
94
+ setMethodOptions(id, options) {
95
+ methodsOptionsCache[id] = options;
96
+ }
97
+ };
98
+ function addRoutesToCache(newCache) {
99
+ for (const key in newCache) {
100
+ if (!(key in methodsCache)) {
101
+ methodsCache[key] = { ...newCache[key] };
102
+ }
103
+ }
104
+ }
105
+ function getJitFnHashes(jitHash) {
106
+ return {
107
+ isType: `${JIT_FUNCTION_IDS.isType}_${jitHash}`,
108
+ typeErrors: `${JIT_FUNCTION_IDS.typeErrors}_${jitHash}`,
109
+ prepareForJson: `${JIT_FUNCTION_IDS.prepareForJson}_${jitHash}`,
110
+ restoreFromJson: `${JIT_FUNCTION_IDS.restoreFromJson}_${jitHash}`,
111
+ stringifyJson: `${JIT_FUNCTION_IDS.stringifyJson}_${jitHash}`,
112
+ toBinary: `${JIT_FUNCTION_IDS.toBinary}_${jitHash}`,
113
+ fromBinary: `${JIT_FUNCTION_IDS.fromBinary}_${jitHash}`
114
+ };
115
+ }
116
+ function getJitFunctionsFromHash(jitHash) {
117
+ if (jitHash === EMPTY_HASH) return noopJitFns;
118
+ const cached = jitFunctionsCache.get(jitHash);
119
+ if (cached) return cached;
120
+ const hashes = getJitFnHashes(jitHash);
121
+ const jUtils = getJitUtils();
122
+ const jitFns = {
123
+ isType: jUtils.getJIT(hashes.isType),
124
+ typeErrors: jUtils.getJIT(hashes.typeErrors),
125
+ prepareForJson: jUtils.getJIT(hashes.prepareForJson),
126
+ restoreFromJson: jUtils.getJIT(hashes.restoreFromJson),
127
+ stringifyJson: jUtils.getJIT(hashes.stringifyJson),
128
+ toBinary: jUtils.getJIT(hashes.toBinary),
129
+ fromBinary: jUtils.getJIT(hashes.fromBinary)
130
+ };
131
+ for (const key in jitFns) {
132
+ if (!jitFns[key]) throw new Error(`Jit function ${key} not found for jitHash ${jitHash}`);
133
+ }
134
+ jitFunctionsCache.set(jitHash, jitFns);
135
+ return jitFns;
136
+ }
137
+ function getHeaderJitFunctionsFromHash(jitHash) {
138
+ const cached = headerJitFunctionsCache.get(jitHash);
139
+ if (cached) return cached;
140
+ const hashes = getJitFnHashes(jitHash);
141
+ const jUtils = getJitUtils();
142
+ const jitFns = {
143
+ isType: jUtils.getJIT(hashes.isType),
144
+ typeErrors: jUtils.getJIT(hashes.typeErrors)
145
+ };
146
+ headerJitFunctionsCache.set(jitHash, jitFns);
147
+ return jitFns;
148
+ }
149
+ function getRouterItemId(itemPointer) {
150
+ return itemPointer.join(ROUTER_ITEM_SEPARATOR_CHAR);
151
+ }
152
+ function getRoutePath(pathPointer, routerOptions) {
153
+ const pathId = getRouterItemId(pathPointer);
154
+ const basePath = routerOptions.basePath.startsWith(ROUTE_PATH_ROOT) ? routerOptions.basePath : `${ROUTE_PATH_ROOT}${routerOptions.basePath}`;
155
+ const routePath = basePath.endsWith(PATH_SEPARATOR) ? `${basePath}${pathId}` : `${basePath}${PATH_SEPARATOR}${pathId}`;
156
+ return routerOptions.suffix ? routePath + routerOptions.suffix : routePath;
157
+ }
158
+ function resetRoutesCache() {
159
+ for (const k in methodsCache) delete methodsCache[k];
160
+ }
161
+ function resetJitFunctionsCache() {
162
+ jitFunctionsCache.clear();
163
+ headerJitFunctionsCache.clear();
164
+ }
165
+ const noopJitFns = {
166
+ isType: fakeJitFn(JIT_FUNCTION_IDS.isType),
167
+ typeErrors: fakeJitFn(JIT_FUNCTION_IDS.typeErrors),
168
+ prepareForJson: fakeJitFn(JIT_FUNCTION_IDS.prepareForJson),
169
+ restoreFromJson: fakeJitFn(JIT_FUNCTION_IDS.restoreFromJson),
170
+ stringifyJson: fakeJitFn(JIT_FUNCTION_IDS.stringifyJson),
171
+ toBinary: fakeJitFn(JIT_FUNCTION_IDS.toBinary),
172
+ fromBinary: fakeJitFn(JIT_FUNCTION_IDS.fromBinary)
173
+ };
174
+ function fakeJitFn(fnID) {
175
+ return {
176
+ typeName: "mionNoopJit",
177
+ fnID,
178
+ jitFnHash: EMPTY_HASH,
179
+ args: { vλl: "v" },
180
+ defaultParamValues: { vλl: "v" },
181
+ isNoop: true,
182
+ code: "",
183
+ jitDependencies: [],
184
+ pureFnDependencies: [],
185
+ createJitFn: () => {
186
+ throw new Error("isNoop JIT functions should not be called, this is a function when jit is never used");
187
+ },
188
+ fn: () => {
189
+ throw new Error("isNoop JIT functions should not be called, this is a function when jit is never used");
190
+ }
191
+ };
192
+ }
193
+ function getNoopJitFns() {
194
+ return noopJitFns;
195
+ }
196
+ export {
197
+ addRoutesToCache,
198
+ getHeaderJitFunctionsFromHash,
199
+ getJitFnHashes,
200
+ getJitFunctionsFromHash,
201
+ getNoopJitFns,
202
+ getRoutePath,
203
+ getRouterItemId,
204
+ methodOptsCache,
205
+ resetJitFunctionsCache,
206
+ resetRoutesCache,
207
+ routesCache
208
+ };
209
+ //# sourceMappingURL=routerUtils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"routerUtils.js","sources":["../../../src/routerUtils.ts"],"sourcesContent":["/* ########\n * 2023 mion\n * Author: Ma-jerez\n * License: MIT\n * The software is provided \"as is\", without warranty of any kind.\n * ######## */\n\nimport {JIT_FUNCTION_IDS, PATH_SEPARATOR, ROUTER_ITEM_SEPARATOR_CHAR, ROUTE_PATH_ROOT, EMPTY_HASH} from './constants.ts';\nimport type {RemoteMethodOpts, MethodWithOptions, MethodsCache, MethodWithOptsAndJitFns} from './types/method.types.ts';\nimport type {CoreRouterOptions, JitCompiledFn, JitCompiledFunctions, JitFunctionsHashes} from './types/general.types.ts';\nimport {getJitUtils} from './jit/jitUtils.ts';\n\nconst methodsCache: MethodsCache = {};\nconst methodsOptionsCache: Record<string, RemoteMethodOpts> = {};\n\n// Cache for JitCompiledFunctions objects keyed by jitHash\nconst jitFunctionsCache = new Map<string, JitCompiledFunctions>();\nconst headerJitFunctionsCache = new Map<string, Pick<JitCompiledFunctions, 'isType' | 'typeErrors'>>();\n\n/**\n * Utilities for accessing and modifying the router cache.\n * The router cache stores method metadata for routes registered via addRoutesToCache() or virtual modules.\n */\nexport const routesCache = {\n /**\n * Get method metadata from the router cache by id.\n * @param id - The method id\n * @returns The method metadata or undefined if not found\n */\n getMetadata(id: string): MethodWithOptions | undefined {\n return methodsCache[id] as MethodWithOptions | undefined;\n },\n\n /**\n * Set method metadata in the router cache\n * @param id - The method id\n * @param methodData - The method metadata\n */\n setMetadata(id: string, methodData: MethodWithOptions): void {\n methodsCache[id] = methodData as any;\n },\n\n /**\n * Check if the router cache contains a method by id.\n * @param id - The method id\n * @returns True if the method exists in the cache\n */\n hasMetadata(id: string): boolean {\n return id in methodsCache;\n },\n\n /**\n * Get the raw router cache object.\n * Use with caution - prefer using get/set/has methods.\n * @returns The router cache object\n */\n getCache(): MethodsCache {\n return methodsCache;\n },\n\n /**\n * Get method metadata with JIT functions restored from the router cache by id.\n * This augments the MethodWithOptions with paramsJitFns and returnJitFns.\n * JIT functions are cached in the entry after first access for performance.\n * @param id - The method id\n * @returns The method metadata with JIT functions or undefined if not found\n */\n getMethodJitFns(id: string): MethodWithOptsAndJitFns | undefined {\n if (id in methodsCache) {\n const cached = methodsCache[id] as any;\n if (cached.paramsJitFns && cached.returnJitFns) {\n return cached as MethodWithOptsAndJitFns;\n }\n }\n\n const metadata = this.getMetadata(id);\n if (!metadata) return undefined;\n\n const paramsJitFns = getJitFunctionsFromHash(metadata.paramsJitHash);\n const returnJitFns = getJitFunctionsFromHash(metadata.returnJitHash);\n const headersParam = metadata.headersParam\n ? {...metadata.headersParam, jitFns: getHeaderJitFunctionsFromHash(metadata.headersParam.jitHash)}\n : undefined;\n const headersReturn = metadata.headersReturn\n ? {...metadata.headersReturn, jitFns: getHeaderJitFunctionsFromHash(metadata.headersReturn.jitHash)}\n : undefined;\n\n const result: MethodWithOptsAndJitFns = {\n ...metadata,\n paramsJitFns,\n returnJitFns,\n headersParam,\n headersReturn,\n };\n\n methodsCache[id] = result;\n return result as MethodWithOptsAndJitFns;\n },\n\n /**\n * Get method metadata with JIT functions restored from the router cache by id.\n * @param id\n * @returns\n */\n useMethodJitFns(id: string): MethodWithOptsAndJitFns {\n const MethodWithOptsAndJitFns = this.getMethodJitFns(id);\n if (!MethodWithOptsAndJitFns) throw new Error(`Metadata for remote method ${id} not found`);\n return MethodWithOptsAndJitFns;\n },\n\n /**\n * Set method metadata with JIT functions in the router cache.\n * This stores the complete MethodWithOptsAndJitFns object directly.\n * @param id - The method id\n * @param MethodWithOptsAndJitFns - The method metadata with JIT functions\n */\n setMethodJitFns(id: string, MethodWithOptsAndJitFns: MethodWithOptsAndJitFns): void {\n methodsCache[id] = MethodWithOptsAndJitFns as any;\n },\n};\n\nexport const methodOptsCache = {\n getMethodOptions(id: string): RemoteMethodOpts | undefined {\n return methodsOptionsCache[id];\n },\n setMethodOptions(id: string, options: RemoteMethodOpts): void {\n methodsOptionsCache[id] = options;\n },\n};\n\n/**\n * Adds new routes to the router cache.\n * This is the public API for registering routes - called by virtual modules or directly.\n * @param newCache\n */\nexport function addRoutesToCache(newCache: MethodsCache) {\n for (const key in newCache) {\n if (!(key in methodsCache)) {\n // Clone the cache entry to avoid mutating the original\n methodsCache[key] = {...newCache[key]} as MethodWithOptions;\n }\n }\n}\n\nexport function getJitFnHashes(jitHash: string): JitFunctionsHashes {\n return {\n isType: `${JIT_FUNCTION_IDS.isType}_${jitHash}`,\n typeErrors: `${JIT_FUNCTION_IDS.typeErrors}_${jitHash}`,\n prepareForJson: `${JIT_FUNCTION_IDS.prepareForJson}_${jitHash}`,\n restoreFromJson: `${JIT_FUNCTION_IDS.restoreFromJson}_${jitHash}`,\n stringifyJson: `${JIT_FUNCTION_IDS.stringifyJson}_${jitHash}`,\n toBinary: `${JIT_FUNCTION_IDS.toBinary}_${jitHash}`,\n fromBinary: `${JIT_FUNCTION_IDS.fromBinary}_${jitHash}`,\n };\n}\n\n/**\n * Helper function to get JIT functions from a JIT hash\n * Returns nullJitFns for empty hash (handlers with no params or void return)\n * Results are cached to avoid creating duplicate objects.\n */\nexport function getJitFunctionsFromHash(jitHash: string): JitCompiledFunctions {\n // Empty hash means no JIT functions were generated (optimization for no params or void return)\n if (jitHash === EMPTY_HASH) return noopJitFns;\n\n // Check cache first\n const cached = jitFunctionsCache.get(jitHash);\n if (cached) return cached;\n\n const hashes = getJitFnHashes(jitHash);\n const jUtils = getJitUtils();\n const jitFns = {\n isType: jUtils.getJIT(hashes.isType),\n typeErrors: jUtils.getJIT(hashes.typeErrors),\n prepareForJson: jUtils.getJIT(hashes.prepareForJson),\n restoreFromJson: jUtils.getJIT(hashes.restoreFromJson),\n stringifyJson: jUtils.getJIT(hashes.stringifyJson),\n toBinary: jUtils.getJIT(hashes.toBinary),\n fromBinary: jUtils.getJIT(hashes.fromBinary),\n } as JitCompiledFunctions;\n for (const key in jitFns) {\n if (!jitFns[key]) throw new Error(`Jit function ${key} not found for jitHash ${jitHash}`);\n }\n\n // Cache for future calls\n jitFunctionsCache.set(jitHash, jitFns);\n return jitFns;\n}\n\n/**\n * Helper function to get header JIT functions from a JIT hash\n * Results are cached to avoid creating duplicate objects.\n */\nexport function getHeaderJitFunctionsFromHash(jitHash: string): Pick<JitCompiledFunctions, 'isType' | 'typeErrors'> {\n // Check cache first\n const cached = headerJitFunctionsCache.get(jitHash);\n if (cached) return cached;\n\n const hashes = getJitFnHashes(jitHash);\n const jUtils = getJitUtils();\n const jitFns = {\n isType: jUtils.getJIT(hashes.isType),\n typeErrors: jUtils.getJIT(hashes.typeErrors),\n } as Pick<JitCompiledFunctions, 'isType' | 'typeErrors'>;\n\n // Cache for future calls\n headerJitFunctionsCache.set(jitHash, jitFns);\n return jitFns;\n}\n\n/**\n * Get the router id for Routes or MiddleFns\n * @param itemPointer - The pointer to the item within the Routes object\n * i.e:\n * const routes = {\n * auth: () => {},\n * users: {\n * getUser: () => {}\n * }\n * login: () => {}\n * }\n *\n * then the pointer for getUser is => ['users', 'getUser']\n */\nexport function getRouterItemId(itemPointer: string[]) {\n return itemPointer.join(ROUTER_ITEM_SEPARATOR_CHAR);\n}\n\n/** Gets a route path from a route pointer */\nexport function getRoutePath(pathPointer: string[], routerOptions: CoreRouterOptions) {\n const pathId = getRouterItemId(pathPointer);\n const basePath = routerOptions.basePath.startsWith(ROUTE_PATH_ROOT)\n ? routerOptions.basePath\n : `${ROUTE_PATH_ROOT}${routerOptions.basePath}`;\n const routePath = basePath.endsWith(PATH_SEPARATOR) ? `${basePath}${pathId}` : `${basePath}${PATH_SEPARATOR}${pathId}`;\n return routerOptions.suffix ? routePath + routerOptions.suffix : routePath;\n}\n\nexport function resetRoutesCache() {\n for (const k in methodsCache) delete methodsCache[k];\n}\n\n/** Resets the JIT functions cache. Useful for testing purposes only. */\nexport function resetJitFunctionsCache(): void {\n jitFunctionsCache.clear();\n headerJitFunctionsCache.clear();\n}\n\n// Noop JIT functions used for handlers with no params or void return\n// prettier-ignore\nconst noopJitFns: JitCompiledFunctions = {\n isType: fakeJitFn(JIT_FUNCTION_IDS.isType),\n typeErrors: fakeJitFn(JIT_FUNCTION_IDS.typeErrors),\n prepareForJson: fakeJitFn(JIT_FUNCTION_IDS.prepareForJson),\n restoreFromJson: fakeJitFn(JIT_FUNCTION_IDS.restoreFromJson),\n stringifyJson: fakeJitFn(JIT_FUNCTION_IDS.stringifyJson),\n toBinary: fakeJitFn(JIT_FUNCTION_IDS.toBinary),\n fromBinary: fakeJitFn(JIT_FUNCTION_IDS.fromBinary),\n} as any;\n\n/** Creates a fake JIT function with isNoop=true for handlers with no params or void return */\nfunction fakeJitFn(fnID: string): JitCompiledFn<any> {\n return {\n typeName: 'mionNoopJit',\n fnID,\n jitFnHash: EMPTY_HASH,\n args: {vλl: 'v'},\n defaultParamValues: {vλl: 'v'},\n isNoop: true,\n code: '',\n jitDependencies: [],\n pureFnDependencies: [],\n createJitFn: () => {\n throw new Error('isNoop JIT functions should not be called, this is a function when jit is never used');\n },\n fn: () => {\n throw new Error('isNoop JIT functions should not be called, this is a function when jit is never used');\n },\n };\n}\n\nexport function getNoopJitFns(): JitCompiledFunctions {\n return noopJitFns;\n}\n"],"names":[],"mappings":";;AAYA,MAAM,eAA6B,CAAA;AACnC,MAAM,sBAAwD,CAAA;AAG9D,MAAM,wCAAwB,IAAA;AAC9B,MAAM,8CAA8B,IA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AA,EACzC,YAAY,UAAU,iBAAiB,UAAU;AAAA,EACjD,gBAAgB,UAAU,iBAAiB,cAAc;AAAA,EACzD,iBAAiB,UAAU,iBAAiB,eAAe;AAAA,EAC3D,eAAe,UAAU,iBAAiB,aAAa;AAAA,EACvD,UAAU,UAAU,iBAAiB,QAAQ;AAAA,EAC7C,YAAY,UAAU,iBAAiB,UAAU;AACrD;AAGA,SAAS,UAAU,MAAkC;AACjD,SAAO;AAAA,IACH,UAAU;AAAA,IACV;AAAA,IACA,WAAW;AAAA,IACX,MAAM,EAAC,KAAK,IAAA;AAAA,IACZ,oBAAoB,EAAC,KAAK,IAAA;AAAA,IAC1B,QAAQ;AAAA,IACR,MAAM;AAAA,IACN,iBAAiB,CAAA;AAAA,IACjB,oBAAoB,CAAA;AAAA,IACpB,aAAa,MAAM;AACf,YAAM,IAAI,MAAM,sFAAsF;AAAA,IAC1G;AAAA,IACA,IAAI,MAAM;AACN,YAAM,IAAI,MAAM,sFAAsF;AAAA,IAC1G;AAAA,EAAA;AAER;AAEO,SAAS,gBAAsC;AAClD,SAAO;AACX;"}
@@ -0,0 +1,45 @@
1
+ import { TypeFormatPrimitives } from './formats.types.ts';
2
+ export type Brand<BaseType extends TypeFormatPrimitives, Name extends string> = BaseType & {
3
+ brand: Name;
4
+ };
5
+ export type BrandEmail = Brand<string, 'email'>;
6
+ export type BrandUUID = Brand<string, 'uuid'>;
7
+ export type BrandUrl = Brand<string, 'url'>;
8
+ export type BrandDomain = Brand<string, 'domain'>;
9
+ export type BrandIP = Brand<string, 'ip'>;
10
+ export type BrandDate = Brand<string, 'date'>;
11
+ export type BrandTime = Brand<string, 'time'>;
12
+ export type BrandDateTime = Brand<string, 'dateTime'>;
13
+ export type BrandInteger = Brand<number, 'integer'>;
14
+ export type BrandFloat = Brand<number, 'float'>;
15
+ export type BrandPositive = Brand<number, 'positive'>;
16
+ export type BrandNegative = Brand<number, 'negative'>;
17
+ export type BrandPositiveInt = Brand<number, 'positiveInt'>;
18
+ export type BrandNegativeInt = Brand<number, 'negativeInt'>;
19
+ export type BrandInt8 = Brand<number, 'int8'>;
20
+ export type BrandInt16 = Brand<number, 'int16'>;
21
+ export type BrandInt32 = Brand<number, 'int32'>;
22
+ export type BrandUInt8 = Brand<number, 'uint8'>;
23
+ export type BrandUInt16 = Brand<number, 'uint16'>;
24
+ export type BrandUInt32 = Brand<number, 'uint32'>;
25
+ export declare type __ΩBrand = any[];
26
+ export declare type __ΩBrandEmail = any[];
27
+ export declare type __ΩBrandUUID = any[];
28
+ export declare type __ΩBrandUrl = any[];
29
+ export declare type __ΩBrandDomain = any[];
30
+ export declare type __ΩBrandIP = any[];
31
+ export declare type __ΩBrandDate = any[];
32
+ export declare type __ΩBrandTime = any[];
33
+ export declare type __ΩBrandDateTime = any[];
34
+ export declare type __ΩBrandInteger = any[];
35
+ export declare type __ΩBrandFloat = any[];
36
+ export declare type __ΩBrandPositive = any[];
37
+ export declare type __ΩBrandNegative = any[];
38
+ export declare type __ΩBrandPositiveInt = any[];
39
+ export declare type __ΩBrandNegativeInt = any[];
40
+ export declare type __ΩBrandInt8 = any[];
41
+ export declare type __ΩBrandInt16 = any[];
42
+ export declare type __ΩBrandInt32 = any[];
43
+ export declare type __ΩBrandUInt8 = any[];
44
+ export declare type __ΩBrandUInt16 = any[];
45
+ export declare type __ΩBrandUInt32 = any[];
@@ -0,0 +1,45 @@
1
+ const __ΩBrand = ["BaseType", "Name", "brand", "Brand", 'b!b"Pe"!Pe#"4#MKw$y'];
2
+ const __ΩBrandEmail = [() => __ΩBrand, "email", "BrandEmail", '&."o!#w#y'];
3
+ const __ΩBrandUUID = [() => __ΩBrand, "uuid", "BrandUUID", '&."o!#w#y'];
4
+ const __ΩBrandUrl = [() => __ΩBrand, "url", "BrandUrl", '&."o!#w#y'];
5
+ const __ΩBrandDomain = [() => __ΩBrand, "domain", "BrandDomain", '&."o!#w#y'];
6
+ const __ΩBrandIP = [() => __ΩBrand, "ip", "BrandIP", '&."o!#w#y'];
7
+ const __ΩBrandDate = [() => __ΩBrand, "date", "BrandDate", '&."o!#w#y'];
8
+ const __ΩBrandTime = [() => __ΩBrand, "time", "BrandTime", '&."o!#w#y'];
9
+ const __ΩBrandDateTime = [() => __ΩBrand, "dateTime", "BrandDateTime", '&."o!#w#y'];
10
+ const __ΩBrandInteger = [() => __ΩBrand, "integer", "BrandInteger", `'."o!#w#y`];
11
+ const __ΩBrandFloat = [() => __ΩBrand, "float", "BrandFloat", `'."o!#w#y`];
12
+ const __ΩBrandPositive = [() => __ΩBrand, "positive", "BrandPositive", `'."o!#w#y`];
13
+ const __ΩBrandNegative = [() => __ΩBrand, "negative", "BrandNegative", `'."o!#w#y`];
14
+ const __ΩBrandPositiveInt = [() => __ΩBrand, "positiveInt", "BrandPositiveInt", `'."o!#w#y`];
15
+ const __ΩBrandNegativeInt = [() => __ΩBrand, "negativeInt", "BrandNegativeInt", `'."o!#w#y`];
16
+ const __ΩBrandInt8 = [() => __ΩBrand, "int8", "BrandInt8", `'."o!#w#y`];
17
+ const __ΩBrandInt16 = [() => __ΩBrand, "int16", "BrandInt16", `'."o!#w#y`];
18
+ const __ΩBrandInt32 = [() => __ΩBrand, "int32", "BrandInt32", `'."o!#w#y`];
19
+ const __ΩBrandUInt8 = [() => __ΩBrand, "uint8", "BrandUInt8", `'."o!#w#y`];
20
+ const __ΩBrandUInt16 = [() => __ΩBrand, "uint16", "BrandUInt16", `'."o!#w#y`];
21
+ const __ΩBrandUInt32 = [() => __ΩBrand, "uint32", "BrandUInt32", `'."o!#w#y`];
22
+ export {
23
+ __ΩBrand,
24
+ __ΩBrandDate,
25
+ __ΩBrandDateTime,
26
+ __ΩBrandDomain,
27
+ __ΩBrandEmail,
28
+ __ΩBrandFloat,
29
+ __ΩBrandIP,
30
+ __ΩBrandInt16,
31
+ __ΩBrandInt32,
32
+ __ΩBrandInt8,
33
+ __ΩBrandInteger,
34
+ __ΩBrandNegative,
35
+ __ΩBrandNegativeInt,
36
+ __ΩBrandPositive,
37
+ __ΩBrandPositiveInt,
38
+ __ΩBrandTime,
39
+ __ΩBrandUInt16,
40
+ __ΩBrandUInt32,
41
+ __ΩBrandUInt8,
42
+ __ΩBrandUUID,
43
+ __ΩBrandUrl
44
+ };
45
+ //# sourceMappingURL=formatBrands.types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"formatBrands.types.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;"}
@@ -0,0 +1,37 @@
1
+ type StrNumber = string | number;
2
+ export type TypeFormatPrimitives = string | number | bigint | Date;
3
+ export type FormatParamLiteral = string | number | boolean | RegExp | bigint;
4
+ export type TypeFormatValue = FormatParamLiteral | readonly TypeFormatValue[] | {
5
+ [key: string]: TypeFormatValue | undefined | never;
6
+ };
7
+ export type FormatParamMeta<L extends TypeFormatValue = TypeFormatValue> = {
8
+ val: L;
9
+ errorMessage: string;
10
+ desc?: string;
11
+ };
12
+ export type FormatParam<L extends TypeFormatValue> = L | FormatParamMeta<L>;
13
+ export type TypeFormatParams = Record<string, TypeFormatValue | undefined | never>;
14
+ export type TypeFormatParsedParams = {
15
+ __jitId: string;
16
+ [key: string]: TypeFormatValue;
17
+ };
18
+ export type AliasTypeAnnotation<Name extends string, Options = never> = unknown;
19
+ export type AliasTypeFormat<BaseType extends string | number | bigint, Name extends string, P extends TypeFormatParams> = BaseType & AliasTypeAnnotation<Name, P>;
20
+ export type ExtractFormatParams<T> = T extends AliasTypeFormat<infer Base, infer Name, infer P> ? P : undefined;
21
+ export type TypeFormatError = {
22
+ name: string;
23
+ val: StrNumber | boolean | bigint | (StrNumber | boolean | bigint)[];
24
+ formatPath: StrNumber[];
25
+ };
26
+ export {};
27
+ export declare type __ΩTypeFormatPrimitives = any[];
28
+ export declare type __ΩFormatParamLiteral = any[];
29
+ export declare type __ΩTypeFormatValue = any[];
30
+ export declare type __ΩFormatParamMeta = any[];
31
+ export declare type __ΩFormatParam = any[];
32
+ export declare type __ΩTypeFormatParams = any[];
33
+ export declare type __ΩTypeFormatParsedParams = any[];
34
+ export declare type __ΩAliasTypeAnnotation = any[];
35
+ export declare type __ΩAliasTypeFormat = any[];
36
+ export declare type __ΩExtractFormatParams = any[];
37
+ export declare type __ΩTypeFormatError = any[];
@@ -0,0 +1,27 @@
1
+ const __ΩRecord = ["K", "T", "Record", `l'e#"Rb!b"Pde"!N#!w#y`];
2
+ const __ΩStrNumber = ["StrNumber", "P&'Jw!y"];
3
+ const __ΩTypeFormatPrimitives = ["TypeFormatPrimitives", "P&'*TJw!y"];
4
+ const __ΩFormatParamLiteral = ["FormatParamLiteral", "P&')A*Jw!y"];
5
+ const __ΩTypeFormatValue = [() => __ΩFormatParamLiteral, 0, 0, "TypeFormatValue", 'Pn!n"F9P&Pn#-!JLMJw$y'];
6
+ const __ΩFormatParamMeta = [() => __ΩTypeFormatValue, "L", "val", "errorMessage", "desc", "FormatParamMeta", 'n!c"Pe"!4#&4$&4%8Mw&y'];
7
+ const __ΩFormatParam = ["L", () => __ΩFormatParamMeta, "FormatParam", 'b!Pe"!e"!o""Jw#y'];
8
+ const __ΩTypeFormatParams = [() => __ΩRecord, () => __ΩTypeFormatValue, "TypeFormatParams", '&Pn"-!Jo!#w#y'];
9
+ const __ΩTypeFormatParsedParams = ["__jitId", () => __ΩTypeFormatValue, "TypeFormatParsedParams", 'P&4!&n"LMw#y'];
10
+ const __ΩAliasTypeAnnotation = ["Name", "Options", "AliasTypeAnnotation", 'b!!c"#w#y'];
11
+ const __ΩAliasTypeFormat = ["BaseType", "Name", "P", () => __ΩAliasTypeAnnotation, "AliasTypeFormat", 'b!b"b#Pe"!e""e"#o$#Kw%y'];
12
+ const __ΩExtractFormatParams = ["T", () => __ΩAliasTypeFormat, "ExtractFormatParams", `lBe"#R-RPddde#!h!!h!"h!#o"$qk#'QRb!Pde"!p)w#y`];
13
+ const __ΩTypeFormatError = ["name", () => __ΩStrNumber, () => __ΩStrNumber, "val", () => __ΩStrNumber, "formatPath", "TypeFormatError", `P&4!Pn")*Pn#)*JFJ4$n%F4&Mw'y`];
14
+ export {
15
+ __ΩAliasTypeAnnotation,
16
+ __ΩAliasTypeFormat,
17
+ __ΩExtractFormatParams,
18
+ __ΩFormatParam,
19
+ __ΩFormatParamLiteral,
20
+ __ΩFormatParamMeta,
21
+ __ΩTypeFormatError,
22
+ __ΩTypeFormatParams,
23
+ __ΩTypeFormatParsedParams,
24
+ __ΩTypeFormatPrimitives,
25
+ __ΩTypeFormatValue
26
+ };
27
+ //# sourceMappingURL=formats.types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"formats.types.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;"}
@@ -0,0 +1,234 @@
1
+ import { FormatParam } from './formats.types.ts';
2
+ export type Samples = string | readonly string[];
3
+ export type StringValidators = {
4
+ maxLength?: number | {
5
+ val: number;
6
+ errorMessage: string;
7
+ desc?: string;
8
+ };
9
+ minLength?: number | {
10
+ val: number;
11
+ errorMessage: string;
12
+ desc?: string;
13
+ };
14
+ length?: number | {
15
+ val: number;
16
+ errorMessage: string;
17
+ desc?: string;
18
+ };
19
+ disallowedChars?: {
20
+ val: string;
21
+ errorMessage: string;
22
+ desc?: string;
23
+ ignoreCase?: boolean;
24
+ mockSamples: string;
25
+ };
26
+ disallowedValues?: {
27
+ val: readonly string[];
28
+ errorMessage: string;
29
+ desc?: string;
30
+ ignoreCase?: boolean;
31
+ mockSamples: Samples;
32
+ };
33
+ pattern?: {
34
+ val: RegExp;
35
+ errorMessage: string;
36
+ desc?: string;
37
+ ignoreCase?: boolean;
38
+ mockSamples: Samples;
39
+ };
40
+ allowedChars?: {
41
+ val: string;
42
+ errorMessage: string;
43
+ desc?: string;
44
+ ignoreCase?: boolean;
45
+ mockSamples?: Samples;
46
+ };
47
+ allowedValues?: {
48
+ val: readonly string[];
49
+ errorMessage: string;
50
+ desc?: string;
51
+ ignoreCase?: boolean;
52
+ mockSamples?: Samples;
53
+ };
54
+ };
55
+ export type StringTransformers = {
56
+ lowercase?: boolean;
57
+ uppercase?: boolean;
58
+ capitalize?: boolean;
59
+ trim?: boolean;
60
+ replace?: {
61
+ searchValue: string;
62
+ replaceValue: string;
63
+ };
64
+ replaceAll?: {
65
+ searchValue: string;
66
+ replaceValue: string;
67
+ };
68
+ };
69
+ export type StringParams = StringValidators & StringTransformers;
70
+ export type DateFmt = 'ISO' | 'YYYY-MM-DD' | 'DD-MM-YYYY' | 'MM-DD-YYYY' | 'MM-DD' | 'DD-MM' | 'YYYY-MM';
71
+ export type FormatParams_Date = {
72
+ format: FormatParam<DateFmt>;
73
+ };
74
+ export type TimeFmt = 'ISO' | 'HH:mm:ss[.mmm]TZ' | 'HH:mm:ss[.mmm]' | 'HH:mm:ss' | 'HH:mm' | 'mm:ss' | 'HH' | 'mm' | 'ss';
75
+ export type FormatParams_Time = {
76
+ format: FormatParam<TimeFmt>;
77
+ };
78
+ export type FormatParams_DateTime = {
79
+ date: FormatParams_Date;
80
+ time: FormatParams_Time;
81
+ splitChar: FormatParam<string>;
82
+ };
83
+ export type FormatParams_EmailPattern = Omit<StringValidators, 'length' | 'allowedChars' | 'disallowedChars' | 'allowedValues'>;
84
+ export type FormatParams_Email = FormatParams_EmailPattern & {
85
+ localPart?: StringValidators;
86
+ domain?: FormatParams_Domain;
87
+ };
88
+ export type FormatParams_UrlPattern = Omit<StringParams, 'allowedChars' | 'disallowedChars' | 'allowedValues' | 'disallowedValues'>;
89
+ export type FormatParams_Url = FormatParams_UrlPattern & {
90
+ ip?: FormatParams_IP;
91
+ domain?: FormatParams_Domain;
92
+ };
93
+ export type FormatParams_DomainName = Omit<StringValidators, 'length' | 'allowedChars' | 'disallowedChars'>;
94
+ export type FormatParams_Tld = Omit<StringValidators, 'length' | 'allowedChars' | 'disallowedChars'>;
95
+ export type FormatParam_Pattern = StringValidators['pattern'];
96
+ export type FormatParams_DomainCore = {
97
+ names?: never;
98
+ tld?: never;
99
+ pattern: FormatParam_Pattern;
100
+ } | {
101
+ names: FormatParams_DomainName;
102
+ tld: FormatParams_Tld;
103
+ pattern?: never;
104
+ };
105
+ export type FormatParams_Domain = {
106
+ maxLength?: FormatParam<number>;
107
+ minLength?: FormatParam<number>;
108
+ maxParts?: FormatParam<number>;
109
+ minParts?: FormatParam<number>;
110
+ } & FormatParams_DomainCore;
111
+ export type FormatParams_IP = {
112
+ version: FormatParam<4 | 6 | 'any'>;
113
+ allowLocalHost?: FormatParam<boolean>;
114
+ allowPort?: FormatParam<boolean>;
115
+ };
116
+ export type FormatParams_UUID = {
117
+ version: FormatParam<'4' | '7'>;
118
+ };
119
+ type NumberMax = {
120
+ max?: number | {
121
+ val: number;
122
+ errorMessage: string;
123
+ desc?: string;
124
+ };
125
+ gt?: never;
126
+ } | {
127
+ max?: never;
128
+ gt?: number | {
129
+ val: number;
130
+ errorMessage: string;
131
+ desc?: string;
132
+ };
133
+ };
134
+ type NumberMin = {
135
+ min?: number | {
136
+ val: number;
137
+ errorMessage: string;
138
+ desc?: string;
139
+ };
140
+ lt?: never;
141
+ } | {
142
+ min?: never;
143
+ lt?: number | {
144
+ val: number;
145
+ errorMessage: string;
146
+ desc?: string;
147
+ };
148
+ };
149
+ type NumberType = {
150
+ integer?: boolean | {
151
+ val: boolean;
152
+ errorMessage: string;
153
+ desc?: string;
154
+ };
155
+ float?: never;
156
+ } | {
157
+ integer?: never;
158
+ float?: boolean | {
159
+ val: boolean;
160
+ errorMessage: string;
161
+ desc?: string;
162
+ };
163
+ };
164
+ export type FormatParams_Number = NumberMax & NumberMin & NumberType & {
165
+ multipleOf?: number | {
166
+ val: number;
167
+ errorMessage: string;
168
+ desc?: string;
169
+ };
170
+ };
171
+ type BigIntMax = {
172
+ max?: bigint | {
173
+ val: bigint;
174
+ errorMessage: string;
175
+ desc?: string;
176
+ };
177
+ gt?: never;
178
+ } | {
179
+ max?: never;
180
+ gt?: bigint | {
181
+ val: bigint;
182
+ errorMessage: string;
183
+ desc?: string;
184
+ };
185
+ };
186
+ type BigIntMin = {
187
+ min?: bigint | {
188
+ val: bigint;
189
+ errorMessage: string;
190
+ desc?: string;
191
+ };
192
+ lt?: never;
193
+ } | {
194
+ min?: never;
195
+ lt?: bigint | {
196
+ val: bigint;
197
+ errorMessage: string;
198
+ desc?: string;
199
+ };
200
+ };
201
+ export type FormatParams_BigInt = BigIntMax & BigIntMin & {
202
+ multipleOf?: bigint | {
203
+ val: bigint;
204
+ errorMessage: string;
205
+ desc?: string;
206
+ };
207
+ };
208
+ export type AnyStringFormatParam = StringParams | FormatParams_Email | FormatParams_Url | FormatParams_Domain | FormatParams_IP | FormatParams_UUID | FormatParams_DateTime | FormatParams_Date | FormatParams_Time;
209
+ export type AnyFormatParams = AnyStringFormatParam | FormatParams_Number | FormatParams_BigInt;
210
+ export {};
211
+ export declare type __ΩSamples = any[];
212
+ export declare type __ΩStringValidators = any[];
213
+ export declare type __ΩStringTransformers = any[];
214
+ export declare type __ΩStringParams = any[];
215
+ export declare type __ΩDateFmt = any[];
216
+ export declare type __ΩFormatParams_Date = any[];
217
+ export declare type __ΩTimeFmt = any[];
218
+ export declare type __ΩFormatParams_Time = any[];
219
+ export declare type __ΩFormatParams_DateTime = any[];
220
+ export declare type __ΩFormatParams_EmailPattern = any[];
221
+ export declare type __ΩFormatParams_Email = any[];
222
+ export declare type __ΩFormatParams_UrlPattern = any[];
223
+ export declare type __ΩFormatParams_Url = any[];
224
+ export declare type __ΩFormatParams_DomainName = any[];
225
+ export declare type __ΩFormatParams_Tld = any[];
226
+ export declare type __ΩFormatParam_Pattern = any[];
227
+ export declare type __ΩFormatParams_DomainCore = any[];
228
+ export declare type __ΩFormatParams_Domain = any[];
229
+ export declare type __ΩFormatParams_IP = any[];
230
+ export declare type __ΩFormatParams_UUID = any[];
231
+ export declare type __ΩFormatParams_Number = any[];
232
+ export declare type __ΩFormatParams_BigInt = any[];
233
+ export declare type __ΩAnyStringFormatParam = any[];
234
+ export declare type __ΩAnyFormatParams = any[];