@wener/common 2.0.3 → 2.0.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (312) hide show
  1. package/lib/ai/qwen3vl/index.js +1 -1
  2. package/lib/ai/qwen3vl/utils.js +15 -15
  3. package/lib/ai/qwen3vl/utils.js.map +1 -1
  4. package/lib/ai/vision/DocLayoutElementTypeSchema.js +22 -22
  5. package/lib/ai/vision/ImageAnnotationSchema.js +63 -47
  6. package/lib/ai/vision/index.js +2 -2
  7. package/lib/ai/vision/resolveImageAnnotation.js +81 -95
  8. package/lib/cn/ChineseResidentIdNo.js +55 -41
  9. package/lib/cn/ChineseResidentIdNo.js.map +1 -1
  10. package/lib/cn/ChineseResidentIdNo.mod.js +6 -1
  11. package/lib/cn/ChineseResidentIdNo.test.js +22 -21
  12. package/lib/cn/DivisionCode.js +220 -235
  13. package/lib/cn/DivisionCode.mod.js +6 -1
  14. package/lib/cn/DivisionCode.test.js +92 -121
  15. package/lib/cn/Mod11.js +18 -37
  16. package/lib/cn/Mod11.js.map +1 -1
  17. package/lib/cn/Mod31.js +23 -41
  18. package/lib/cn/UnifiedSocialCreditCode.js +143 -137
  19. package/lib/cn/UnifiedSocialCreditCode.mod.js +6 -1
  20. package/lib/cn/UnifiedSocialCreditCode.test.js +21 -15
  21. package/lib/cn/formatChineseAmount.js +46 -71
  22. package/lib/cn/index.js +6 -6
  23. package/lib/cn/mod.js +5 -3
  24. package/lib/cn/parseChineseNumber.js +81 -85
  25. package/lib/cn/parseChineseNumber.test.js +183 -261
  26. package/lib/cn/pinyin/cartesianProduct.js +19 -19
  27. package/lib/cn/pinyin/cartesianProduct.test.js +78 -178
  28. package/lib/cn/pinyin/loader.js +13 -11
  29. package/lib/cn/pinyin/preload.js +2 -1
  30. package/lib/cn/pinyin/toPinyin.test.js +149 -161
  31. package/lib/cn/pinyin/toPinyinPure.js +28 -23
  32. package/lib/cn/pinyin/transform.js +11 -11
  33. package/lib/cn/types.d.js +2 -2
  34. package/lib/consola/createStandardConsolaReporter.js +14 -15
  35. package/lib/consola/formatLogObject.js +149 -133
  36. package/lib/consola/formatLogObject.js.map +1 -1
  37. package/lib/consola/formatLogObject.test.js +167 -178
  38. package/lib/consola/index.js +2 -2
  39. package/lib/data/formatSort.js +14 -12
  40. package/lib/data/formatSort.test.js +33 -33
  41. package/lib/data/index.js +3 -3
  42. package/lib/data/maybeNumber.js +23 -23
  43. package/lib/data/maybeNumber.js.map +1 -1
  44. package/lib/data/parseSort.js +75 -68
  45. package/lib/data/parseSort.test.js +196 -187
  46. package/lib/data/resolvePagination.js +38 -39
  47. package/lib/data/resolvePagination.test.js +228 -218
  48. package/lib/data/types.d.js +2 -2
  49. package/lib/data/types.d.js.map +1 -1
  50. package/lib/dayjs/dayjs.js +20 -20
  51. package/lib/dayjs/formatDuration.js +56 -56
  52. package/lib/dayjs/formatDuration.js.map +1 -1
  53. package/lib/dayjs/formatDuration.test.js +63 -77
  54. package/lib/dayjs/index.js +4 -4
  55. package/lib/dayjs/parseDuration.js +21 -26
  56. package/lib/dayjs/parseRelativeTime.js +65 -66
  57. package/lib/dayjs/parseRelativeTime.test.js +227 -243
  58. package/lib/dayjs/resolveRelativeTime.js +74 -144
  59. package/lib/dayjs/resolveRelativeTime.js.map +1 -1
  60. package/lib/dayjs/resolveRelativeTime.test.js +296 -307
  61. package/lib/decimal/index.js +1 -1
  62. package/lib/decimal/parseDecimal.js +12 -12
  63. package/lib/drain3/Drain.js +321 -0
  64. package/lib/drain3/Drain.js.map +1 -0
  65. package/lib/drain3/LogCluster.js +38 -0
  66. package/lib/drain3/LogCluster.js.map +1 -0
  67. package/lib/drain3/Node.js +39 -0
  68. package/lib/drain3/Node.js.map +1 -0
  69. package/lib/drain3/TemplateMiner.js +205 -0
  70. package/lib/drain3/TemplateMiner.js.map +1 -0
  71. package/lib/drain3/index.js +31 -0
  72. package/lib/drain3/index.js.map +1 -0
  73. package/lib/drain3/persistence/FilePersistence.js +24 -0
  74. package/lib/drain3/persistence/FilePersistence.js.map +1 -0
  75. package/lib/drain3/persistence/MemoryPersistence.js +18 -0
  76. package/lib/drain3/persistence/MemoryPersistence.js.map +1 -0
  77. package/lib/drain3/persistence/PersistenceHandler.js +5 -0
  78. package/lib/drain3/persistence/PersistenceHandler.js.map +1 -0
  79. package/lib/drain3/types.js +7 -0
  80. package/lib/drain3/types.js.map +1 -0
  81. package/lib/emittery/emitter.js +7 -7
  82. package/lib/emittery/index.js +1 -1
  83. package/lib/foundation/schema/SexType.js +15 -12
  84. package/lib/foundation/schema/index.js +1 -1
  85. package/lib/foundation/schema/parseSexType.js +15 -16
  86. package/lib/foundation/schema/types.js +8 -6
  87. package/lib/fs/FileSystemError.js +18 -18
  88. package/lib/fs/IFileSystem.d.js +2 -2
  89. package/lib/fs/IFileSystem.d.js.map +1 -1
  90. package/lib/fs/MemoryFileSystem.test.js +172 -181
  91. package/lib/fs/createBrowserFileSystem.js +222 -233
  92. package/lib/fs/createBrowserFileSystem.js.map +1 -1
  93. package/lib/fs/createMemoryFileSystem.js +473 -510
  94. package/lib/fs/createMemoryFileSystem.js.map +1 -1
  95. package/lib/fs/createSandboxFileSystem.js +102 -101
  96. package/lib/fs/createSandboxFileSystem.js.map +1 -1
  97. package/lib/fs/createWebDavFileSystem.js +162 -132
  98. package/lib/fs/createWebDavFileSystem.js.map +1 -1
  99. package/lib/fs/createWebFileSystem.js +202 -0
  100. package/lib/fs/createWebFileSystem.js.map +1 -0
  101. package/lib/fs/findMimeType.js +14 -14
  102. package/lib/fs/findMimeType.js.map +1 -1
  103. package/lib/fs/index.js +7 -7
  104. package/lib/fs/index.js.map +1 -1
  105. package/lib/fs/minio/createMinioFileSystem.js +977 -0
  106. package/lib/fs/minio/createMinioFileSystem.js.map +1 -0
  107. package/lib/fs/minio/index.js +2 -0
  108. package/lib/fs/minio/index.js.map +1 -0
  109. package/lib/fs/orpc/FileSystemContract.js +57 -57
  110. package/lib/fs/orpc/createContractClientFileSystem.js +88 -88
  111. package/lib/fs/orpc/createContractClientFileSystem.js.map +1 -1
  112. package/lib/fs/orpc/index.js +2 -2
  113. package/lib/fs/orpc/server/createFileSystemContractImpl.js +62 -60
  114. package/lib/fs/orpc/server/createFileSystemContractImpl.js.map +1 -1
  115. package/lib/fs/orpc/server/index.js +1 -1
  116. package/lib/fs/s3/createS3MiniFileSystem.js +756 -689
  117. package/lib/fs/s3/createS3MiniFileSystem.js.map +1 -1
  118. package/lib/fs/s3/index.js +1 -1
  119. package/lib/fs/s3/s3mini.test.js +524 -553
  120. package/lib/fs/scandir.js +56 -56
  121. package/lib/fs/server/createDatabaseFileSystem.js +834 -741
  122. package/lib/fs/server/createDatabaseFileSystem.js.map +1 -1
  123. package/lib/fs/server/createNodeFileSystem.js +407 -380
  124. package/lib/fs/server/createNodeFileSystem.js.map +1 -1
  125. package/lib/fs/server/dbfs.test.js +201 -214
  126. package/lib/fs/server/index.js +1 -1
  127. package/lib/fs/server/loadTestDatabase.js +40 -43
  128. package/lib/fs/tests/runFileSystemTest.js +352 -315
  129. package/lib/fs/tests/runFileSystemTest.js.map +1 -1
  130. package/lib/fs/types.js +17 -20
  131. package/lib/fs/utils/getFileUrl.js +24 -30
  132. package/lib/fs/utils.js +17 -17
  133. package/lib/fs/utils.js.map +1 -1
  134. package/lib/fs/webdav/index.js +2 -0
  135. package/lib/fs/webdav/index.js.map +1 -0
  136. package/lib/index.js +2 -2
  137. package/lib/jsonschema/JsonSchema.js +216 -155
  138. package/lib/jsonschema/JsonSchema.js.map +1 -1
  139. package/lib/jsonschema/JsonSchema.test.js +123 -124
  140. package/lib/jsonschema/forEachJsonSchema.js +41 -41
  141. package/lib/jsonschema/forEachJsonSchema.js.map +1 -1
  142. package/lib/jsonschema/index.js +2 -2
  143. package/lib/jsonschema/types.d.js +2 -2
  144. package/lib/jsonschema/types.d.js.map +1 -1
  145. package/lib/meta/defineFileType.js +32 -38
  146. package/lib/meta/defineInit.js +39 -35
  147. package/lib/meta/defineMetadata.js +37 -34
  148. package/lib/meta/defineMetadata.js.map +1 -1
  149. package/lib/meta/defineMetadata.test.js +13 -12
  150. package/lib/meta/index.js +3 -3
  151. package/lib/orpc/createOpenApiContractClient.js +26 -24
  152. package/lib/orpc/createOpenApiContractClient.js.map +1 -1
  153. package/lib/orpc/createRpcContractClient.js +37 -31
  154. package/lib/orpc/index.js +2 -2
  155. package/lib/orpc/resolveLinkPlugins.js +25 -25
  156. package/lib/password/PHC.js +187 -189
  157. package/lib/password/PHC.js.map +1 -1
  158. package/lib/password/PHC.test.js +517 -535
  159. package/lib/password/Password.js +85 -80
  160. package/lib/password/Password.test.js +330 -364
  161. package/lib/password/createArgon2PasswordAlgorithm.js +50 -51
  162. package/lib/password/createArgon2PasswordAlgorithm.js.map +1 -1
  163. package/lib/password/createBase64PasswordAlgorithm.js +11 -11
  164. package/lib/password/createBase64PasswordAlgorithm.js.map +1 -1
  165. package/lib/password/createBcryptPasswordAlgorithm.js +20 -18
  166. package/lib/password/createBcryptPasswordAlgorithm.js.map +1 -1
  167. package/lib/password/createPBKDF2PasswordAlgorithm.js +65 -52
  168. package/lib/password/createPBKDF2PasswordAlgorithm.js.map +1 -1
  169. package/lib/password/createScryptPasswordAlgorithm.js +74 -63
  170. package/lib/password/createScryptPasswordAlgorithm.js.map +1 -1
  171. package/lib/password/index.js +5 -5
  172. package/lib/password/server/index.js +1 -1
  173. package/lib/resource/Identifiable.js +2 -2
  174. package/lib/resource/ListQuery.js +42 -42
  175. package/lib/resource/ListQuery.js.map +1 -1
  176. package/lib/resource/getTitleOfResource.js +5 -5
  177. package/lib/resource/index.js +2 -2
  178. package/lib/resource/index.js.map +1 -1
  179. package/lib/resource/schema/AnyResourceSchema.js +91 -89
  180. package/lib/resource/schema/BaseResourceSchema.js +26 -26
  181. package/lib/resource/schema/ResourceActionType.js +117 -115
  182. package/lib/resource/schema/ResourceStatus.js +94 -92
  183. package/lib/resource/schema/ResourceType.js +25 -23
  184. package/lib/resource/schema/index.js +5 -5
  185. package/lib/resource/schema/types.js +86 -55
  186. package/lib/resource/schema/types.test.js +16 -13
  187. package/lib/s3/formatS3Url.js +60 -60
  188. package/lib/s3/formatS3Url.js.map +1 -1
  189. package/lib/s3/formatS3Url.test.js +238 -261
  190. package/lib/s3/index.js +2 -2
  191. package/lib/s3/parseS3Url.js +61 -60
  192. package/lib/s3/parseS3Url.js.map +1 -1
  193. package/lib/s3/parseS3Url.test.js +270 -269
  194. package/lib/schema/SchemaRegistry.js +41 -42
  195. package/lib/schema/SchemaRegistry.js.map +1 -1
  196. package/lib/schema/SchemaRegistry.mod.js +1 -1
  197. package/lib/schema/TypeSchema.d.js +2 -2
  198. package/lib/schema/TypeSchema.d.js.map +1 -1
  199. package/lib/schema/createSchemaData.js +113 -67
  200. package/lib/schema/createSchemaData.js.map +1 -1
  201. package/lib/schema/findJsonSchemaByPath.js +28 -23
  202. package/lib/schema/findJsonSchemaByPath.js.map +1 -1
  203. package/lib/schema/formatZodError.js +113 -134
  204. package/lib/schema/formatZodError.js.map +1 -1
  205. package/lib/schema/formatZodError.test.js +192 -195
  206. package/lib/schema/getSchemaCache.js +7 -7
  207. package/lib/schema/getSchemaOptions.js +17 -16
  208. package/lib/schema/index.js +6 -6
  209. package/lib/schema/toJsonSchema.js +196 -190
  210. package/lib/schema/toJsonSchema.js.map +1 -1
  211. package/lib/schema/toJsonSchema.test.js +34 -26
  212. package/lib/schema/validate.js +106 -97
  213. package/lib/schema/validate.js.map +1 -1
  214. package/lib/tools/generateSchema.js +40 -40
  215. package/lib/tools/renderJsonSchemaToMarkdownDoc.js +74 -74
  216. package/lib/utils/buildBaseUrl.js +8 -8
  217. package/lib/utils/buildRedactorFormSchema.js +55 -54
  218. package/lib/utils/buildRedactorFormSchema.js.map +1 -1
  219. package/lib/utils/getEstimateProcessTime.js +24 -19
  220. package/lib/utils/index.js +3 -3
  221. package/lib/utils/resolveFeatureOptions.js +9 -9
  222. package/package.json +37 -18
  223. package/src/ai/qwen3vl/utils.ts +1 -1
  224. package/src/ai/vision/index.ts +2 -2
  225. package/src/cn/ChineseResidentIdNo.ts +1 -1
  226. package/src/cn/Mod11.ts +1 -1
  227. package/src/cn/__snapshots__/ChineseResidentIdNo.test.ts.snap +1 -1
  228. package/src/cn/__snapshots__/UnifiedSocialCreditCode.test.ts.snap +0 -23
  229. package/src/cn/index.ts +1 -2
  230. package/src/cn/parseChineseNumber.test.ts +4 -4
  231. package/src/consola/formatLogObject.ts +6 -6
  232. package/src/consola/index.ts +1 -1
  233. package/src/data/index.ts +3 -4
  234. package/src/data/maybeNumber.ts +1 -1
  235. package/src/data/parseSort.test.ts +0 -1
  236. package/src/data/resolvePagination.ts +2 -2
  237. package/src/data/types.d.ts +2 -2
  238. package/src/dayjs/formatDuration.ts +10 -11
  239. package/src/dayjs/index.ts +1 -1
  240. package/src/dayjs/parseRelativeTime.ts +1 -1
  241. package/src/dayjs/resolveRelativeTime.ts +11 -14
  242. package/src/drain3/Drain.test.ts +378 -0
  243. package/src/drain3/Drain.ts +394 -0
  244. package/src/drain3/LogCluster.ts +46 -0
  245. package/src/drain3/Node.ts +53 -0
  246. package/src/drain3/TemplateMiner.ts +246 -0
  247. package/src/drain3/index.ts +34 -0
  248. package/src/drain3/persistence/FilePersistence.ts +24 -0
  249. package/src/drain3/persistence/MemoryPersistence.ts +23 -0
  250. package/src/drain3/persistence/PersistenceHandler.ts +19 -0
  251. package/src/drain3/types.ts +75 -0
  252. package/src/fs/IFileSystem.d.ts +1 -2
  253. package/src/fs/createBrowserFileSystem.ts +7 -5
  254. package/src/fs/createMemoryFileSystem.ts +9 -13
  255. package/src/fs/createSandboxFileSystem.ts +1 -1
  256. package/src/fs/createWebDavFileSystem.ts +30 -17
  257. package/src/fs/createWebFileSystem.ts +242 -0
  258. package/src/fs/findMimeType.ts +1 -4
  259. package/src/fs/index.ts +5 -5
  260. package/src/fs/minio/createMinioFileSystem.ts +1148 -0
  261. package/src/fs/minio/index.ts +1 -0
  262. package/src/fs/orpc/createContractClientFileSystem.ts +5 -5
  263. package/src/fs/orpc/server/createFileSystemContractImpl.ts +1 -1
  264. package/src/fs/s3/createS3MiniFileSystem.ts +120 -79
  265. package/src/fs/s3/s3fs.test.ts +441 -0
  266. package/src/fs/s3/s3mini.test.ts +2 -2
  267. package/src/fs/server/createDatabaseFileSystem.ts +78 -114
  268. package/src/fs/server/createNodeFileSystem.ts +32 -13
  269. package/src/fs/server/dbfs.test.ts +13 -8
  270. package/src/fs/server/index.ts +1 -0
  271. package/src/fs/server/loadTestDatabase.ts +8 -119
  272. package/src/fs/tests/runFileSystemTest.ts +29 -28
  273. package/src/fs/utils.ts +1 -1
  274. package/src/fs/webdav/index.ts +1 -0
  275. package/src/jsonschema/JsonSchema.ts +5 -5
  276. package/src/jsonschema/forEachJsonSchema.ts +1 -1
  277. package/src/jsonschema/index.ts +1 -1
  278. package/src/jsonschema/types.d.ts +1 -1
  279. package/src/meta/defineMetadata.ts +1 -1
  280. package/src/meta/index.ts +2 -3
  281. package/src/orm/createSqliteDialect.ts +17 -0
  282. package/src/orm/index.ts +1 -0
  283. package/src/orpc/createOpenApiContractClient.ts +3 -3
  284. package/src/orpc/index.ts +1 -1
  285. package/src/password/PHC.ts +3 -3
  286. package/src/password/createArgon2PasswordAlgorithm.ts +2 -2
  287. package/src/password/createBase64PasswordAlgorithm.ts +2 -2
  288. package/src/password/createBcryptPasswordAlgorithm.ts +4 -2
  289. package/src/password/createPBKDF2PasswordAlgorithm.ts +2 -2
  290. package/src/password/createScryptPasswordAlgorithm.ts +4 -4
  291. package/src/password/index.ts +2 -2
  292. package/src/resource/ListQuery.ts +4 -1
  293. package/src/resource/index.ts +3 -3
  294. package/src/resource/schema/index.ts +4 -4
  295. package/src/s3/formatS3Url.test.ts +1 -1
  296. package/src/s3/formatS3Url.ts +2 -2
  297. package/src/s3/index.ts +1 -1
  298. package/src/s3/parseS3Url.ts +1 -1
  299. package/src/schema/SchemaRegistry.ts +2 -2
  300. package/src/schema/TypeSchema.d.ts +6 -6
  301. package/src/schema/createSchemaData.ts +5 -5
  302. package/src/schema/findJsonSchemaByPath.ts +5 -5
  303. package/src/schema/formatZodError.test.ts +2 -1
  304. package/src/schema/formatZodError.ts +50 -62
  305. package/src/schema/index.ts +5 -5
  306. package/src/schema/toJsonSchema.ts +6 -6
  307. package/src/schema/validate.ts +2 -2
  308. package/src/utils/buildRedactorFormSchema.ts +4 -4
  309. package/src/utils/formatNumber.ts +18 -0
  310. package/src/utils/formatPercent.ts +17 -0
  311. package/src/utils/index.ts +3 -3
  312. package/src/utils/resolveFeatureOptions.ts +1 -1
@@ -1,137 +1,136 @@
1
1
  function _array_like_to_array(arr, len) {
2
- if (len == null || len > arr.length)
3
- len = arr.length;
4
- for (var i = 0, arr2 = new Array(len); i < len; i++)
5
- arr2[i] = arr[i];
6
- return arr2;
2
+ if (len == null || len > arr.length) len = arr.length;
3
+ for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
4
+ return arr2;
7
5
  }
8
6
  function _array_with_holes(arr) {
9
- if (Array.isArray(arr))
10
- return arr;
7
+ if (Array.isArray(arr)) return arr;
11
8
  }
12
9
  function _iterable_to_array_limit(arr, i) {
13
- var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
14
- if (_i == null)
15
- return;
16
- var _arr = [];
17
- var _n = true;
18
- var _d = false;
19
- var _s, _e;
20
- try {
21
- for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) {
22
- _arr.push(_s.value);
23
- if (i && _arr.length === i)
24
- break;
25
- }
26
- }
27
- catch (err) {
28
- _d = true;
29
- _e = err;
30
- }
31
- finally {
32
- try {
33
- if (!_n && _i["return"] != null)
34
- _i["return"]();
35
- }
36
- finally {
37
- if (_d)
38
- throw _e;
39
- }
40
- }
41
- return _arr;
10
+ var _i = arr == null ? null : (typeof Symbol !== 'undefined' && arr[Symbol.iterator]) || arr['@@iterator'];
11
+ if (_i == null) return;
12
+ var _arr = [];
13
+ var _n = true;
14
+ var _d = false;
15
+ var _s, _e;
16
+ try {
17
+ for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) {
18
+ _arr.push(_s.value);
19
+ if (i && _arr.length === i) break;
20
+ }
21
+ } catch (err) {
22
+ _d = true;
23
+ _e = err;
24
+ } finally {
25
+ try {
26
+ if (!_n && _i['return'] != null) _i['return']();
27
+ } finally {
28
+ if (_d) throw _e;
29
+ }
30
+ }
31
+ return _arr;
42
32
  }
43
33
  function _non_iterable_rest() {
44
- throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
34
+ throw new TypeError(
35
+ 'Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.',
36
+ );
45
37
  }
46
38
  function _sliced_to_array(arr, i) {
47
- return _array_with_holes(arr) || _iterable_to_array_limit(arr, i) || _unsupported_iterable_to_array(arr, i) || _non_iterable_rest();
39
+ return (
40
+ _array_with_holes(arr) ||
41
+ _iterable_to_array_limit(arr, i) ||
42
+ _unsupported_iterable_to_array(arr, i) ||
43
+ _non_iterable_rest()
44
+ );
48
45
  }
49
46
  function _unsupported_iterable_to_array(o, minLen) {
50
- if (!o)
51
- return;
52
- if (typeof o === "string")
53
- return _array_like_to_array(o, minLen);
54
- var n = Object.prototype.toString.call(o).slice(8, -1);
55
- if (n === "Object" && o.constructor)
56
- n = o.constructor.name;
57
- if (n === "Map" || n === "Set")
58
- return Array.from(n);
59
- if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))
60
- return _array_like_to_array(o, minLen);
47
+ if (!o) return;
48
+ if (typeof o === 'string') return _array_like_to_array(o, minLen);
49
+ var n = Object.prototype.toString.call(o).slice(8, -1);
50
+ if (n === 'Object' && o.constructor) n = o.constructor.name;
51
+ if (n === 'Map' || n === 'Set') return Array.from(n);
52
+ if (n === 'Arguments' || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
61
53
  }
62
- import { describe, expect, it } from "vitest";
63
- import { JsonSchema } from "./JsonSchema.js";
64
- describe("jsonschema", function () {
65
- it("should create from schema", function () {
66
- for (var _i = 0, _iter = [
67
- [
68
- {
69
- type: "string"
70
- },
71
- ""
72
- ],
73
- [
74
- {
75
- type: "number"
76
- },
77
- 0
78
- ],
79
- [
80
- {
81
- type: "number",
82
- default: 1
83
- },
84
- 1
85
- ],
86
- [
87
- {
88
- type: "integer"
89
- },
90
- 0
91
- ],
92
- [
93
- {
94
- type: "array"
95
- },
96
- []
97
- ],
98
- [
99
- {
100
- type: "object"
101
- },
102
- {}
103
- ],
104
- [
105
- {
106
- type: "object",
107
- properties: {
108
- a: {
109
- type: "string"
110
- }
111
- },
112
- required: [
113
- "a"
114
- ]
115
- },
116
- {
117
- a: ""
118
- }
119
- ]
120
- ]; _i < _iter.length; _i++) {
121
- var _iter__i = _sliced_to_array(_iter[_i], 2), a = _iter__i[0], b = _iter__i[1];
122
- expect(JsonSchema.create(a)).toEqual(b);
123
- }
124
- });
125
- it("should match typebox types", function () {
126
- var a;
127
- var b;
128
- a = b;
129
- });
130
- it("should match ajv types", function () {
131
- var a;
132
- var b;
133
- var c;
134
- a = b;
135
- // a = c;
136
- });
54
+
55
+ import { describe, expect, it } from 'vitest';
56
+ import { JsonSchema } from './JsonSchema.js';
57
+
58
+ describe('jsonschema', () => {
59
+ it('should create from schema', () => {
60
+ for (
61
+ var _i = 0,
62
+ _iter = [
63
+ [
64
+ {
65
+ type: 'string',
66
+ },
67
+ '',
68
+ ],
69
+ [
70
+ {
71
+ type: 'number',
72
+ },
73
+ 0,
74
+ ],
75
+ [
76
+ {
77
+ type: 'number',
78
+ default: 1,
79
+ },
80
+ 1,
81
+ ],
82
+ [
83
+ {
84
+ type: 'integer',
85
+ },
86
+ 0,
87
+ ],
88
+ [
89
+ {
90
+ type: 'array',
91
+ },
92
+ [],
93
+ ],
94
+ [
95
+ {
96
+ type: 'object',
97
+ },
98
+ {},
99
+ ],
100
+ [
101
+ {
102
+ type: 'object',
103
+ properties: {
104
+ a: {
105
+ type: 'string',
106
+ },
107
+ },
108
+ required: ['a'],
109
+ },
110
+ {
111
+ a: '',
112
+ },
113
+ ],
114
+ ];
115
+ _i < _iter.length;
116
+ _i++
117
+ ) {
118
+ var _iter__i = _sliced_to_array(_iter[_i], 2),
119
+ a = _iter__i[0],
120
+ b = _iter__i[1];
121
+ expect(JsonSchema.create(a)).toEqual(b);
122
+ }
123
+ });
124
+ it('should match typebox types', () => {
125
+ var a;
126
+ var b;
127
+ a = b;
128
+ });
129
+ it('should match ajv types', () => {
130
+ var a;
131
+ var b;
132
+ var c;
133
+ a = b;
134
+ // a = c;
135
+ });
137
136
  });
@@ -1,44 +1,44 @@
1
1
  export function forEachJsonSchema(js, cb) {
2
- const ctx = {
3
- path: []
4
- };
5
- const _visit = (js, _f, parent, path, k)=>{
6
- if (!js) {
7
- return;
8
- }
9
- ctx.path = path;
10
- ctx.parent = parent;
11
- _f(js, ctx);
12
- if (js.properties) {
13
- for (const [k, v] of Object.entries(js.properties)){
14
- if (v) {
15
- _visit(v, _f, js, path.concat(k), 'properties');
16
- }
17
- }
18
- } else if (js.items) {
19
- // array should be `key[].subkey` or `key.*.subkey`?
20
- if (Array.isArray(js.items)) {
21
- for (const v of js.items){
22
- _visit(v, _f, js, path, 'items');
23
- }
24
- } else {
25
- _visit(js.items, _f, js, path, 'items');
26
- }
27
- } else if (js.anyOf) {
28
- for (const v of js.anyOf){
29
- _visit(v, _f, js, path, 'anyOf');
30
- }
31
- } else if (js.oneOf) {
32
- for (const v of js.oneOf){
33
- _visit(v, _f, js, path, 'oneOf');
34
- }
35
- } else if (js.allOf) {
36
- for (const v of js.allOf){
37
- _visit(v, _f, js, path, 'allOf');
38
- }
39
- }
40
- };
41
- _visit(js, cb, undefined, []);
2
+ const ctx = {
3
+ path: [],
4
+ };
5
+ const _visit = (js, _f, parent, path, _k) => {
6
+ if (!js) {
7
+ return;
8
+ }
9
+ ctx.path = path;
10
+ ctx.parent = parent;
11
+ _f(js, ctx);
12
+ if (js.properties) {
13
+ for (const [k, v] of Object.entries(js.properties)) {
14
+ if (v) {
15
+ _visit(v, _f, js, path.concat(k), 'properties');
16
+ }
17
+ }
18
+ } else if (js.items) {
19
+ // array should be `key[].subkey` or `key.*.subkey`?
20
+ if (Array.isArray(js.items)) {
21
+ for (const v of js.items) {
22
+ _visit(v, _f, js, path, 'items');
23
+ }
24
+ } else {
25
+ _visit(js.items, _f, js, path, 'items');
26
+ }
27
+ } else if (js.anyOf) {
28
+ for (const v of js.anyOf) {
29
+ _visit(v, _f, js, path, 'anyOf');
30
+ }
31
+ } else if (js.oneOf) {
32
+ for (const v of js.oneOf) {
33
+ _visit(v, _f, js, path, 'oneOf');
34
+ }
35
+ } else if (js.allOf) {
36
+ for (const v of js.allOf) {
37
+ _visit(v, _f, js, path, 'allOf');
38
+ }
39
+ }
40
+ };
41
+ _visit(js, cb, undefined, []);
42
42
  }
43
43
 
44
- //# sourceMappingURL=forEachJsonSchema.js.map
44
+ //# sourceMappingURL=forEachJsonSchema.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/jsonschema/forEachJsonSchema.ts"],"sourcesContent":["import type { JsonSchemaDef } from './types';\n\nexport type VisitJsonSchemaContext = { path: string[]; parent?: JsonSchemaDef };\n\nexport function forEachJsonSchema(js: JsonSchemaDef, cb: (js: JsonSchemaDef, ctx: VisitJsonSchemaContext) => void) {\n\tconst ctx: VisitJsonSchemaContext = { path: [] };\n\tconst _visit = (\n\t\tjs: JsonSchemaDef,\n\t\t_f: (js: JsonSchemaDef, ctx: VisitJsonSchemaContext) => void,\n\t\tparent: JsonSchemaDef | undefined,\n\t\tpath: string[],\n\t\tk?: string,\n\t) => {\n\t\tif (!js) {\n\t\t\treturn;\n\t\t}\n\t\tctx.path = path;\n\t\tctx.parent = parent;\n\t\t_f(js, ctx);\n\t\tif (js.properties) {\n\t\t\tfor (const [k, v] of Object.entries(js.properties)) {\n\t\t\t\tif (v) {\n\t\t\t\t\t_visit(v, _f, js, path.concat(k), 'properties');\n\t\t\t\t}\n\t\t\t}\n\t\t} else if (js.items) {\n\t\t\t// array should be `key[].subkey` or `key.*.subkey`?\n\t\t\tif (Array.isArray(js.items)) {\n\t\t\t\tfor (const v of js.items) {\n\t\t\t\t\t_visit(v, _f, js, path, 'items');\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\t_visit(js.items, _f, js, path, 'items');\n\t\t\t}\n\t\t} else if (js.anyOf) {\n\t\t\tfor (const v of js.anyOf) {\n\t\t\t\t_visit(v, _f, js, path, 'anyOf');\n\t\t\t}\n\t\t} else if (js.oneOf) {\n\t\t\tfor (const v of js.oneOf) {\n\t\t\t\t_visit(v, _f, js, path, 'oneOf');\n\t\t\t}\n\t\t} else if (js.allOf) {\n\t\t\tfor (const v of js.allOf) {\n\t\t\t\t_visit(v, _f, js, path, 'allOf');\n\t\t\t}\n\t\t}\n\t};\n\t_visit(js, cb, undefined, []);\n}\n"],"names":["forEachJsonSchema","js","cb","ctx","path","_visit","_f","parent","k","properties","v","Object","entries","concat","items","Array","isArray","anyOf","oneOf","allOf","undefined"],"mappings":"AAIA,OAAO,SAASA,kBAAkBC,EAAiB,EAAEC,EAA4D;IAChH,MAAMC,MAA8B;QAAEC,MAAM,EAAE;IAAC;IAC/C,MAAMC,SAAS,CACdJ,IACAK,IACAC,QACAH,MACAI;QAEA,IAAI,CAACP,IAAI;YACR;QACD;QACAE,IAAIC,IAAI,GAAGA;QACXD,IAAII,MAAM,GAAGA;QACbD,GAAGL,IAAIE;QACP,IAAIF,GAAGQ,UAAU,EAAE;YAClB,KAAK,MAAM,CAACD,GAAGE,EAAE,IAAIC,OAAOC,OAAO,CAACX,GAAGQ,UAAU,EAAG;gBACnD,IAAIC,GAAG;oBACNL,OAAOK,GAAGJ,IAAIL,IAAIG,KAAKS,MAAM,CAACL,IAAI;gBACnC;YACD;QACD,OAAO,IAAIP,GAAGa,KAAK,EAAE;YACpB,oDAAoD;YACpD,IAAIC,MAAMC,OAAO,CAACf,GAAGa,KAAK,GAAG;gBAC5B,KAAK,MAAMJ,KAAKT,GAAGa,KAAK,CAAE;oBACzBT,OAAOK,GAAGJ,IAAIL,IAAIG,MAAM;gBACzB;YACD,OAAO;gBACNC,OAAOJ,GAAGa,KAAK,EAAER,IAAIL,IAAIG,MAAM;YAChC;QACD,OAAO,IAAIH,GAAGgB,KAAK,EAAE;YACpB,KAAK,MAAMP,KAAKT,GAAGgB,KAAK,CAAE;gBACzBZ,OAAOK,GAAGJ,IAAIL,IAAIG,MAAM;YACzB;QACD,OAAO,IAAIH,GAAGiB,KAAK,EAAE;YACpB,KAAK,MAAMR,KAAKT,GAAGiB,KAAK,CAAE;gBACzBb,OAAOK,GAAGJ,IAAIL,IAAIG,MAAM;YACzB;QACD,OAAO,IAAIH,GAAGkB,KAAK,EAAE;YACpB,KAAK,MAAMT,KAAKT,GAAGkB,KAAK,CAAE;gBACzBd,OAAOK,GAAGJ,IAAIL,IAAIG,MAAM;YACzB;QACD;IACD;IACAC,OAAOJ,IAAIC,IAAIkB,WAAW,EAAE;AAC7B"}
1
+ {"version":3,"sources":["../../src/jsonschema/forEachJsonSchema.ts"],"sourcesContent":["import type { JsonSchemaDef } from './types';\n\nexport type VisitJsonSchemaContext = { path: string[]; parent?: JsonSchemaDef };\n\nexport function forEachJsonSchema(js: JsonSchemaDef, cb: (js: JsonSchemaDef, ctx: VisitJsonSchemaContext) => void) {\n\tconst ctx: VisitJsonSchemaContext = { path: [] };\n\tconst _visit = (\n\t\tjs: JsonSchemaDef,\n\t\t_f: (js: JsonSchemaDef, ctx: VisitJsonSchemaContext) => void,\n\t\tparent: JsonSchemaDef | undefined,\n\t\tpath: string[],\n\t\t_k?: string,\n\t) => {\n\t\tif (!js) {\n\t\t\treturn;\n\t\t}\n\t\tctx.path = path;\n\t\tctx.parent = parent;\n\t\t_f(js, ctx);\n\t\tif (js.properties) {\n\t\t\tfor (const [k, v] of Object.entries(js.properties)) {\n\t\t\t\tif (v) {\n\t\t\t\t\t_visit(v, _f, js, path.concat(k), 'properties');\n\t\t\t\t}\n\t\t\t}\n\t\t} else if (js.items) {\n\t\t\t// array should be `key[].subkey` or `key.*.subkey`?\n\t\t\tif (Array.isArray(js.items)) {\n\t\t\t\tfor (const v of js.items) {\n\t\t\t\t\t_visit(v, _f, js, path, 'items');\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\t_visit(js.items, _f, js, path, 'items');\n\t\t\t}\n\t\t} else if (js.anyOf) {\n\t\t\tfor (const v of js.anyOf) {\n\t\t\t\t_visit(v, _f, js, path, 'anyOf');\n\t\t\t}\n\t\t} else if (js.oneOf) {\n\t\t\tfor (const v of js.oneOf) {\n\t\t\t\t_visit(v, _f, js, path, 'oneOf');\n\t\t\t}\n\t\t} else if (js.allOf) {\n\t\t\tfor (const v of js.allOf) {\n\t\t\t\t_visit(v, _f, js, path, 'allOf');\n\t\t\t}\n\t\t}\n\t};\n\t_visit(js, cb, undefined, []);\n}\n"],"names":["forEachJsonSchema","js","cb","ctx","path","_visit","_f","parent","_k","properties","k","v","Object","entries","concat","items","Array","isArray","anyOf","oneOf","allOf","undefined"],"mappings":"AAIA,OAAO,SAASA,kBAAkBC,EAAiB,EAAEC,EAA4D;IAChH,MAAMC,MAA8B;QAAEC,MAAM,EAAE;IAAC;IAC/C,MAAMC,SAAS,CACdJ,IACAK,IACAC,QACAH,MACAI;QAEA,IAAI,CAACP,IAAI;YACR;QACD;QACAE,IAAIC,IAAI,GAAGA;QACXD,IAAII,MAAM,GAAGA;QACbD,GAAGL,IAAIE;QACP,IAAIF,GAAGQ,UAAU,EAAE;YAClB,KAAK,MAAM,CAACC,GAAGC,EAAE,IAAIC,OAAOC,OAAO,CAACZ,GAAGQ,UAAU,EAAG;gBACnD,IAAIE,GAAG;oBACNN,OAAOM,GAAGL,IAAIL,IAAIG,KAAKU,MAAM,CAACJ,IAAI;gBACnC;YACD;QACD,OAAO,IAAIT,GAAGc,KAAK,EAAE;YACpB,oDAAoD;YACpD,IAAIC,MAAMC,OAAO,CAAChB,GAAGc,KAAK,GAAG;gBAC5B,KAAK,MAAMJ,KAAKV,GAAGc,KAAK,CAAE;oBACzBV,OAAOM,GAAGL,IAAIL,IAAIG,MAAM;gBACzB;YACD,OAAO;gBACNC,OAAOJ,GAAGc,KAAK,EAAET,IAAIL,IAAIG,MAAM;YAChC;QACD,OAAO,IAAIH,GAAGiB,KAAK,EAAE;YACpB,KAAK,MAAMP,KAAKV,GAAGiB,KAAK,CAAE;gBACzBb,OAAOM,GAAGL,IAAIL,IAAIG,MAAM;YACzB;QACD,OAAO,IAAIH,GAAGkB,KAAK,EAAE;YACpB,KAAK,MAAMR,KAAKV,GAAGkB,KAAK,CAAE;gBACzBd,OAAOM,GAAGL,IAAIL,IAAIG,MAAM;YACzB;QACD,OAAO,IAAIH,GAAGmB,KAAK,EAAE;YACpB,KAAK,MAAMT,KAAKV,GAAGmB,KAAK,CAAE;gBACzBf,OAAOM,GAAGL,IAAIL,IAAIG,MAAM;YACzB;QACD;IACD;IACAC,OAAOJ,IAAIC,IAAImB,WAAW,EAAE;AAC7B"}
@@ -1,3 +1,3 @@
1
- export { JsonSchema } from "./JsonSchema.js";
2
- export { forEachJsonSchema } from "./forEachJsonSchema.js";
1
+ export { forEachJsonSchema } from './forEachJsonSchema.js';
2
+ export { JsonSchema } from './JsonSchema.js';
3
3
  //# sourceMappingURL=index.js.map
@@ -2,6 +2,6 @@
2
2
  * JSON Schema Definition
3
3
  *
4
4
  * @see https://json-schema.org/specification-links.html
5
- */ export { };
5
+ */ export {};
6
6
 
7
- //# sourceMappingURL=types.d.js.map
7
+ //# sourceMappingURL=types.d.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/jsonschema/types.d.ts"],"sourcesContent":["type JsonSchemaTypeName =\n\t| 'string' //\n\t| 'number'\n\t| 'integer'\n\t| 'boolean'\n\t| 'object'\n\t| 'array'\n\t| 'null'\n\t| undefined;\n\ntype JsonValue =\n\t| string //\n\t| number\n\t| boolean\n\t| { [key: string]: JsonValue }\n\t| JsonValue[]\n\t| null\n\t| undefined; //\n\ntype JsonSchemaVersion =\n\t| 'http://json-schema.org/schema' // latest\n\t//\n\t| 'https://json-schema.org/draft/2020-12/schema'\n\t| 'https://json-schema.org/draft/2019-09/schema'\n\t// draft-07\n\t| 'https://json-schema.org/draft-07/schema'\n\t| 'http://json-schema.org/draft-07/schema'\n\t| 'https://json-schema.org/draft-07/hyper-schema'\n\t| 'http://json-schema.org/draft-07/hyper-schema'\n\t//\n\t| 'https://json-schema.org/draft-04/schema';\ntype JsonSchemaFormatName =\n\t//\n\t| 'date-time'\n\t| 'date'\n\t| 'time'\n\t| 'duration'\n\t//\n\t| 'email'\n\t| 'idn-email'\n\t//\n\t| 'hostname'\n\t| 'idn-hostname'\n\t| 'ipv4'\n\t| 'ipv6'\n\t//\n\t| 'uri'\n\t| 'uri-reference'\n\t| 'iri'\n\t| 'iri-reference'\n\t| 'uuid'\n\t| 'uri-template'\n\t| 'regex'\n\t| 'json-pointer'\n\t| 'relative-json-pointer';\n\n/**\n * JSON Schema Definition\n *\n * @see https://json-schema.org/specification-links.html\n */\nexport type JsonSchemaDef<I = any, O = I> = {\n\t$id?: string;\n\t$ref?: string;\n\t/**\n\t * Meta schema\n\t *\n\t * Recommended values:\n\t * - 'http://json-schema.org/schema#'\n\t * - 'http://json-schema.org/hyper-schema#'\n\t * - 'http://json-schema.org/draft-07/schema#'\n\t * - 'http://json-schema.org/draft-07/hyper-schema#'\n\t *\n\t * @see https://tools.ietf.org/html/draft-handrews-json-schema-validation-01#section-5\n\t */\n\t$schema?: JsonSchemaVersion | string;\n\t$comment?: string;\n\n\t$defs?: { [key: string]: JsonSchemaDef };\n\n\ttype?: JsonSchemaTypeName | JsonSchemaTypeName[];\n\tenum?: JsonValue;\n\tconst?: JsonValue;\n\n\t//region Numeric Validation\n\n\tmultipleOf?: number;\n\tmaximum?: number;\n\texclusiveMaximum?: number;\n\tminimum?: number;\n\texclusiveMinimum?: number;\n\n\t//endregion\n\n\t//region String Validation\n\n\tmaxLength?: number;\n\tminLength?: number;\n\tpattern?: string;\n\n\t//endregion\n\n\t//region Array Validation\n\n\t/**\n\t * schema for array items\n\t * @see https://json-schema.org/understanding-json-schema/reference/array.html#items\n\t */\n\titems?: JsonSchemaDef | JsonSchemaDef[];\n\tadditionalItems?: JsonSchemaDef | boolean;\n\tmaxItems?: number;\n\tminItems?: number;\n\tuniqueItems?: boolean;\n\tcontains?: JsonSchemaDef;\n\n\t//region Draft 2022-12\n\tminContains?: number;\n\tmaxContains?: number;\n\tprefixItems?: JsonSchemaDef[];\n\t//endregion\n\n\t//endregion\n\n\t//region Object Validation\n\n\tmaxProperties?: number;\n\tminProperties?: number;\n\trequired?: string[];\n\tproperties?: { [key: string]: JsonSchemaDef };\n\tpatternProperties?: { [key: string]: JsonSchemaDef };\n\t/**\n\t * Replaced by {@link unevaluatedProperties} in Draft 2019-09+\n\t */\n\tadditionalProperties?: JsonSchemaDef | boolean; // true = {}\n\t/**\n\t * Superseded by {@link dependentSchemas}, {@link dependentRequired} in Draft 2019-09+\n\t */\n\tdependencies?: { [key: string]: undefined | JsonSchemaDef | string[] };\n\tpropertyNames?: JsonSchemaDef;\n\n\t//region Draft 2019-09+\n\n\tdependentSchemas?: { [key: string]: JsonSchemaDef };\n\tdependentRequired?: { [key: string]: string[] };\n\tunevaluatedProperties?: JsonSchemaDef | boolean;\n\tunevaluatedItems?: JsonSchemaDef | boolean;\n\n\t//endregion\n\n\t//endregion\n\n\t//region Conditional\n\n\tif?: JsonSchemaDef;\n\tthen?: JsonSchemaDef;\n\telse?: JsonSchemaDef;\n\n\t//endregion\n\n\t//region Boolean Logic\n\n\tallOf?: JsonSchemaDef[]; // extends, merge\n\tanyOf?: JsonSchemaDef[];\n\toneOf?: JsonSchemaDef[]; // polymorphism, enum\n\tnot?: JsonSchemaDef;\n\t//endregion\n\n\t//region Semantic\n\n\tformat?: JsonSchemaFormatName | string;\n\n\t//endregion\n\n\t//region String-Encoding Non-JSON Data\n\n\tcontentMediaType?: string;\n\tcontentEncoding?: string;\n\tcontentSchema?: JsonSchemaDef;\n\t//endregion\n\n\t/**\n\t * use {@link $defs} instead\n\t */\n\tdefinitions?: Record<string, JsonSchemaDef>;\n\n\t//region Meta-Data Annotations\n\t/**\n\t * @see https://tools.ietf.org/html/draft-handrews-json-schema-validation-01#section-10\n\t */\n\n\ttitle?: string;\n\tdescription?: string;\n\tdefault?: JsonValue;\n\treadOnly?: boolean;\n\twriteOnly?: boolean;\n\texamples?: JsonValue;\n\tdeprecated?: boolean;\n\n\t//endregion\n\n\t//region OpenAPI Spec\n\n\tnullable?: boolean;\n\n\tdiscriminator?: {\n\t\tpropertyName: string;\n\t\tmapping?: { [key: string]: string };\n\t};\n\n\t//endregion\n\n\t// [key: `x-${string}`]: JsonValue;\n\t[key: string]: JsonValue;\n};\n"],"names":[],"mappings":"AAwDA;;;;CAIC,GACD,WAwJE"}
1
+ {"version":3,"sources":["../../src/jsonschema/types.d.ts"],"sourcesContent":["type JsonSchemaTypeName =\n\t| 'string' //\n\t| 'number'\n\t| 'integer'\n\t| 'boolean'\n\t| 'object'\n\t| 'array'\n\t| 'null'\n\t| undefined;\n\ntype JsonValue =\n\t| string //\n\t| number\n\t| boolean\n\t| { [key: string]: JsonValue }\n\t| JsonValue[]\n\t| null\n\t| undefined; //\n\ntype JsonSchemaVersion =\n\t| 'http://json-schema.org/schema' // latest\n\t//\n\t| 'https://json-schema.org/draft/2020-12/schema'\n\t| 'https://json-schema.org/draft/2019-09/schema'\n\t// draft-07\n\t| 'https://json-schema.org/draft-07/schema'\n\t| 'http://json-schema.org/draft-07/schema'\n\t| 'https://json-schema.org/draft-07/hyper-schema'\n\t| 'http://json-schema.org/draft-07/hyper-schema'\n\t//\n\t| 'https://json-schema.org/draft-04/schema';\ntype JsonSchemaFormatName =\n\t//\n\t| 'date-time'\n\t| 'date'\n\t| 'time'\n\t| 'duration'\n\t//\n\t| 'email'\n\t| 'idn-email'\n\t//\n\t| 'hostname'\n\t| 'idn-hostname'\n\t| 'ipv4'\n\t| 'ipv6'\n\t//\n\t| 'uri'\n\t| 'uri-reference'\n\t| 'iri'\n\t| 'iri-reference'\n\t| 'uuid'\n\t| 'uri-template'\n\t| 'regex'\n\t| 'json-pointer'\n\t| 'relative-json-pointer';\n\n/**\n * JSON Schema Definition\n *\n * @see https://json-schema.org/specification-links.html\n */\nexport type JsonSchemaDef<I = any, _O = I> = {\n\t$id?: string;\n\t$ref?: string;\n\t/**\n\t * Meta schema\n\t *\n\t * Recommended values:\n\t * - 'http://json-schema.org/schema#'\n\t * - 'http://json-schema.org/hyper-schema#'\n\t * - 'http://json-schema.org/draft-07/schema#'\n\t * - 'http://json-schema.org/draft-07/hyper-schema#'\n\t *\n\t * @see https://tools.ietf.org/html/draft-handrews-json-schema-validation-01#section-5\n\t */\n\t$schema?: JsonSchemaVersion | string;\n\t$comment?: string;\n\n\t$defs?: { [key: string]: JsonSchemaDef };\n\n\ttype?: JsonSchemaTypeName | JsonSchemaTypeName[];\n\tenum?: JsonValue;\n\tconst?: JsonValue;\n\n\t//region Numeric Validation\n\n\tmultipleOf?: number;\n\tmaximum?: number;\n\texclusiveMaximum?: number;\n\tminimum?: number;\n\texclusiveMinimum?: number;\n\n\t//endregion\n\n\t//region String Validation\n\n\tmaxLength?: number;\n\tminLength?: number;\n\tpattern?: string;\n\n\t//endregion\n\n\t//region Array Validation\n\n\t/**\n\t * schema for array items\n\t * @see https://json-schema.org/understanding-json-schema/reference/array.html#items\n\t */\n\titems?: JsonSchemaDef | JsonSchemaDef[];\n\tadditionalItems?: JsonSchemaDef | boolean;\n\tmaxItems?: number;\n\tminItems?: number;\n\tuniqueItems?: boolean;\n\tcontains?: JsonSchemaDef;\n\n\t//region Draft 2022-12\n\tminContains?: number;\n\tmaxContains?: number;\n\tprefixItems?: JsonSchemaDef[];\n\t//endregion\n\n\t//endregion\n\n\t//region Object Validation\n\n\tmaxProperties?: number;\n\tminProperties?: number;\n\trequired?: string[];\n\tproperties?: { [key: string]: JsonSchemaDef };\n\tpatternProperties?: { [key: string]: JsonSchemaDef };\n\t/**\n\t * Replaced by {@link unevaluatedProperties} in Draft 2019-09+\n\t */\n\tadditionalProperties?: JsonSchemaDef | boolean; // true = {}\n\t/**\n\t * Superseded by {@link dependentSchemas}, {@link dependentRequired} in Draft 2019-09+\n\t */\n\tdependencies?: { [key: string]: undefined | JsonSchemaDef | string[] };\n\tpropertyNames?: JsonSchemaDef;\n\n\t//region Draft 2019-09+\n\n\tdependentSchemas?: { [key: string]: JsonSchemaDef };\n\tdependentRequired?: { [key: string]: string[] };\n\tunevaluatedProperties?: JsonSchemaDef | boolean;\n\tunevaluatedItems?: JsonSchemaDef | boolean;\n\n\t//endregion\n\n\t//endregion\n\n\t//region Conditional\n\n\tif?: JsonSchemaDef;\n\tthen?: JsonSchemaDef;\n\telse?: JsonSchemaDef;\n\n\t//endregion\n\n\t//region Boolean Logic\n\n\tallOf?: JsonSchemaDef[]; // extends, merge\n\tanyOf?: JsonSchemaDef[];\n\toneOf?: JsonSchemaDef[]; // polymorphism, enum\n\tnot?: JsonSchemaDef;\n\t//endregion\n\n\t//region Semantic\n\n\tformat?: JsonSchemaFormatName | string;\n\n\t//endregion\n\n\t//region String-Encoding Non-JSON Data\n\n\tcontentMediaType?: string;\n\tcontentEncoding?: string;\n\tcontentSchema?: JsonSchemaDef;\n\t//endregion\n\n\t/**\n\t * use {@link $defs} instead\n\t */\n\tdefinitions?: Record<string, JsonSchemaDef>;\n\n\t//region Meta-Data Annotations\n\t/**\n\t * @see https://tools.ietf.org/html/draft-handrews-json-schema-validation-01#section-10\n\t */\n\n\ttitle?: string;\n\tdescription?: string;\n\tdefault?: JsonValue;\n\treadOnly?: boolean;\n\twriteOnly?: boolean;\n\texamples?: JsonValue;\n\tdeprecated?: boolean;\n\n\t//endregion\n\n\t//region OpenAPI Spec\n\n\tnullable?: boolean;\n\n\tdiscriminator?: {\n\t\tpropertyName: string;\n\t\tmapping?: { [key: string]: string };\n\t};\n\n\t//endregion\n\n\t// [key: `x-${string}`]: JsonValue;\n\t[key: string]: JsonValue;\n};\n"],"names":[],"mappings":"AAwDA;;;;CAIC,GACD,WAwJE"}
@@ -1,44 +1,38 @@
1
1
  let _all = [];
2
2
  export function defineFileType({ type = '', types = [], extension = '', extensions = [], ...opts }) {
3
- if (!type) {
4
- type = types[0] || '';
5
- }
6
- if (!extension) {
7
- extension = extensions[0] || '';
8
- }
9
- if (!types.includes(type)) {
10
- types = [
11
- type,
12
- ...types
13
- ];
14
- }
15
- if (!extensions.includes(extension)) {
16
- extensions = [
17
- extension,
18
- ...extensions
19
- ];
20
- }
21
- const def = {
22
- title: opts.title || opts.name,
23
- type,
24
- extension,
25
- types,
26
- extensions,
27
- tags: [],
28
- metadata: {},
29
- ...opts
30
- };
31
- let idx = _all.findIndex((v)=>v.name === def.name);
32
- if (idx >= 0) {
33
- _all[idx] = def;
34
- console.warn(`File type ${def.name} is redefined`);
35
- } else {
36
- _all.push(def);
37
- }
38
- return def;
3
+ if (!type) {
4
+ type = types[0] || '';
5
+ }
6
+ if (!extension) {
7
+ extension = extensions[0] || '';
8
+ }
9
+ if (!types.includes(type)) {
10
+ types = [type, ...types];
11
+ }
12
+ if (!extensions.includes(extension)) {
13
+ extensions = [extension, ...extensions];
14
+ }
15
+ const def = {
16
+ title: opts.title || opts.name,
17
+ type,
18
+ extension,
19
+ types,
20
+ extensions,
21
+ tags: [],
22
+ metadata: {},
23
+ ...opts,
24
+ };
25
+ let idx = _all.findIndex((v) => v.name === def.name);
26
+ if (idx >= 0) {
27
+ _all[idx] = def;
28
+ console.warn(`File type ${def.name} is redefined`);
29
+ } else {
30
+ _all.push(def);
31
+ }
32
+ return def;
39
33
  }
40
34
  export function getFileType() {
41
- return _all;
35
+ return _all;
42
36
  }
43
37
 
44
- //# sourceMappingURL=defineFileType.js.map
38
+ //# sourceMappingURL=defineFileType.js.map
@@ -1,42 +1,46 @@
1
- import { startCase } from "es-toolkit";
1
+ import { startCase } from 'es-toolkit';
2
+
2
3
  let _all = [];
3
4
  export function defineInit(o) {
4
- const def = {
5
- title: startCase(o.name),
6
- metadata: {},
7
- ...o
8
- };
9
- let idx = _all.findIndex((v)=>v.name === def.name);
10
- if (idx >= 0) {
11
- console.warn(`skip redefined init: ${def.name}`);
12
- } else {
13
- _all.push(def);
14
- }
15
- return def;
5
+ const def = {
6
+ title: startCase(o.name),
7
+ metadata: {},
8
+ ...o,
9
+ };
10
+ let idx = _all.findIndex((v) => v.name === def.name);
11
+ if (idx >= 0) {
12
+ console.warn(`skip redefined init: ${def.name}`);
13
+ } else {
14
+ _all.push(def);
15
+ }
16
+ return def;
16
17
  }
17
18
  let result = new Map();
18
19
  export async function runInit(inits = _all) {
19
- for (let init of inits){
20
- if (result.get(init)) {
21
- return;
22
- }
23
- result.set(init, Promise.resolve().then(async ()=>{
24
- let out = {
25
- name: init.name,
26
- success: true
27
- };
28
- try {
29
- await init.onInit?.();
30
- } catch (e) {
31
- console.error(`Failed to init ${init.name}`, e);
32
- out.success = false;
33
- out.error = e;
34
- }
35
- result.set(init, out);
36
- return out;
37
- }));
38
- }
39
- return Promise.all(result.values());
20
+ for (let init of inits) {
21
+ if (result.get(init)) {
22
+ return;
23
+ }
24
+ result.set(
25
+ init,
26
+ Promise.resolve().then(async () => {
27
+ let out = {
28
+ name: init.name,
29
+ success: true,
30
+ };
31
+ try {
32
+ await init.onInit?.();
33
+ } catch (e) {
34
+ console.error(`Failed to init ${init.name}`, e);
35
+ out.success = false;
36
+ out.error = e;
37
+ }
38
+ result.set(init, out);
39
+ return out;
40
+ }),
41
+ );
42
+ }
43
+ return Promise.all(result.values());
40
44
  }
41
45
 
42
- //# sourceMappingURL=defineInit.js.map
46
+ //# sourceMappingURL=defineInit.js.map
@@ -1,41 +1,44 @@
1
- import { startCase } from "es-toolkit";
2
- import { get, set } from "es-toolkit/compat";
1
+ import { startCase } from 'es-toolkit';
2
+ import { get, set } from 'es-toolkit/compat';
3
3
  export function createMetadataKey(a, b) {
4
- const opts = typeof a === 'string' ? {
5
- key: a,
6
- ...b
7
- } : a;
8
- const { key } = opts;
9
- opts.title ||= startCase(key);
10
- const k = {
11
- ...opts,
12
- type: null
13
- };
14
- if ('toStringTag' in Symbol && typeof Symbol.toStringTag === 'symbol') {
15
- Object.defineProperty(k, Symbol.toStringTag, {
16
- value: key
17
- });
18
- }
19
- return k;
4
+ const opts =
5
+ typeof a === 'string'
6
+ ? {
7
+ key: a,
8
+ ...b,
9
+ }
10
+ : a;
11
+ const { key } = opts;
12
+ opts.title ||= startCase(key);
13
+ const k = {
14
+ ...opts,
15
+ type: null,
16
+ };
17
+ if ('toStringTag' in Symbol && typeof Symbol.toStringTag === 'symbol') {
18
+ Object.defineProperty(k, Symbol.toStringTag, {
19
+ value: key,
20
+ });
21
+ }
22
+ return k;
20
23
  }
21
24
  export function defineMetadata(a, b, c) {
22
- if (Array.isArray(b)) {
23
- const key = a;
24
- const items = b;
25
- for (const [res, opts] of items){
26
- defineMetadata(res, key, opts);
27
- }
28
- } else {
29
- const res = a;
30
- const key = b;
31
- const opts = c;
32
- res.metadata = res.metadata || {};
33
- set(res.metadata, key.key, opts);
34
- }
25
+ if (Array.isArray(b)) {
26
+ const key = a;
27
+ const items = b;
28
+ for (const [res, opts] of items) {
29
+ defineMetadata(res, key, opts);
30
+ }
31
+ } else {
32
+ const res = a;
33
+ const key = b;
34
+ const opts = c;
35
+ res.metadata = res.metadata || {};
36
+ set(res.metadata, key.key, opts);
37
+ }
35
38
  }
36
39
  export function getMetadata(res, key) {
37
- if (!res?.metadata) return undefined;
38
- return get(res.metadata, key.key);
40
+ if (!res?.metadata) return undefined;
41
+ return get(res.metadata, key.key);
39
42
  }
40
43
 
41
- //# sourceMappingURL=defineMetadata.js.map
44
+ //# sourceMappingURL=defineMetadata.js.map