@wener/common 2.0.2 → 2.0.5

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 (410) hide show
  1. package/lib/ai/qwen3vl/index.js +2 -0
  2. package/lib/ai/qwen3vl/index.js.map +1 -0
  3. package/lib/ai/qwen3vl/utils.js +31 -0
  4. package/lib/ai/qwen3vl/utils.js.map +1 -0
  5. package/lib/ai/vision/DocLayoutElementTypeSchema.js +28 -0
  6. package/lib/ai/vision/DocLayoutElementTypeSchema.js.map +1 -0
  7. package/lib/ai/vision/ImageAnnotationSchema.js +50 -0
  8. package/lib/ai/vision/ImageAnnotationSchema.js.map +1 -0
  9. package/lib/ai/vision/index.js +3 -0
  10. package/lib/ai/vision/index.js.map +1 -0
  11. package/lib/ai/vision/resolveImageAnnotation.js +105 -0
  12. package/lib/ai/vision/resolveImageAnnotation.js.map +1 -0
  13. package/lib/cn/ChineseResidentIdNo.js +22 -15
  14. package/lib/cn/ChineseResidentIdNo.js.map +1 -0
  15. package/lib/cn/ChineseResidentIdNo.test.js +1 -1
  16. package/lib/cn/DivisionCode.js +30 -25
  17. package/lib/cn/DivisionCode.js.map +1 -0
  18. package/lib/cn/DivisionCode.test.js +1 -1
  19. package/lib/cn/Mod11.js +38 -81
  20. package/lib/cn/Mod11.js.map +1 -0
  21. package/lib/cn/Mod31.js +41 -90
  22. package/lib/cn/Mod31.js.map +1 -0
  23. package/lib/cn/UnifiedSocialCreditCode.js +43 -34
  24. package/lib/cn/UnifiedSocialCreditCode.js.map +1 -0
  25. package/lib/cn/UnifiedSocialCreditCode.test.js +1 -1
  26. package/lib/cn/formatChineseAmount.js +77 -0
  27. package/lib/cn/formatChineseAmount.js.map +1 -0
  28. package/lib/cn/index.js +7 -1
  29. package/lib/cn/index.js.map +1 -0
  30. package/lib/cn/parseChineseNumber.js +94 -0
  31. package/lib/cn/parseChineseNumber.js.map +1 -0
  32. package/lib/cn/parseChineseNumber.test.js +278 -0
  33. package/lib/cn/pinyin/cartesianProduct.js +22 -0
  34. package/lib/cn/pinyin/cartesianProduct.js.map +1 -0
  35. package/lib/cn/pinyin/cartesianProduct.test.js +179 -0
  36. package/lib/cn/pinyin/data.json +23573 -0
  37. package/lib/cn/pinyin/loader.js +14 -0
  38. package/lib/cn/pinyin/loader.js.map +1 -0
  39. package/lib/cn/pinyin/preload.js +3 -0
  40. package/lib/cn/pinyin/preload.js.map +1 -0
  41. package/lib/cn/pinyin/toPinyin.test.js +167 -0
  42. package/lib/cn/pinyin/toPinyinPure.js +33 -0
  43. package/lib/cn/pinyin/toPinyinPure.js.map +1 -0
  44. package/lib/cn/pinyin/transform.js +14 -0
  45. package/lib/cn/pinyin/transform.js.map +1 -0
  46. package/lib/cn/types.d.js +2 -0
  47. package/lib/cn/types.d.js.map +1 -0
  48. package/lib/consola/createStandardConsolaReporter.js +6 -6
  49. package/lib/consola/createStandardConsolaReporter.js.map +1 -0
  50. package/lib/consola/formatLogObject.js +66 -146
  51. package/lib/consola/formatLogObject.js.map +1 -0
  52. package/lib/consola/formatLogObject.test.js +184 -0
  53. package/lib/consola/index.js +1 -0
  54. package/lib/consola/index.js.map +1 -0
  55. package/lib/data/formatSort.js +6 -5
  56. package/lib/data/formatSort.js.map +1 -0
  57. package/lib/data/index.js +1 -0
  58. package/lib/data/index.js.map +1 -0
  59. package/lib/data/maybeNumber.js +6 -8
  60. package/lib/data/maybeNumber.js.map +1 -0
  61. package/lib/data/parseSort.js +22 -28
  62. package/lib/data/parseSort.js.map +1 -0
  63. package/lib/data/resolvePagination.js +13 -17
  64. package/lib/data/resolvePagination.js.map +1 -0
  65. package/lib/data/types.d.js +2 -0
  66. package/lib/data/types.d.js.map +1 -0
  67. package/lib/dayjs/dayjs.js +21 -19
  68. package/lib/dayjs/dayjs.js.map +1 -0
  69. package/lib/dayjs/formatDuration.js +15 -14
  70. package/lib/dayjs/formatDuration.js.map +1 -0
  71. package/lib/dayjs/index.js +2 -0
  72. package/lib/dayjs/index.js.map +1 -0
  73. package/lib/dayjs/parseDuration.js +5 -8
  74. package/lib/dayjs/parseDuration.js.map +1 -0
  75. package/lib/dayjs/parseRelativeTime.js +90 -0
  76. package/lib/dayjs/parseRelativeTime.js.map +1 -0
  77. package/lib/dayjs/parseRelativeTime.test.js +247 -0
  78. package/lib/dayjs/resolveRelativeTime.js +87 -0
  79. package/lib/dayjs/resolveRelativeTime.js.map +1 -0
  80. package/lib/dayjs/resolveRelativeTime.test.js +310 -0
  81. package/lib/decimal/index.js +1 -0
  82. package/lib/decimal/index.js.map +1 -0
  83. package/lib/decimal/parseDecimal.js +3 -1
  84. package/lib/decimal/parseDecimal.js.map +1 -0
  85. package/lib/drain3/Drain.js +356 -0
  86. package/lib/drain3/Drain.js.map +1 -0
  87. package/lib/drain3/LogCluster.js +38 -0
  88. package/lib/drain3/LogCluster.js.map +1 -0
  89. package/lib/drain3/Node.js +39 -0
  90. package/lib/drain3/Node.js.map +1 -0
  91. package/lib/drain3/TemplateMiner.js +204 -0
  92. package/lib/drain3/TemplateMiner.js.map +1 -0
  93. package/lib/drain3/index.js +31 -0
  94. package/lib/drain3/index.js.map +1 -0
  95. package/lib/drain3/persistence/FilePersistence.js +24 -0
  96. package/lib/drain3/persistence/FilePersistence.js.map +1 -0
  97. package/lib/drain3/persistence/MemoryPersistence.js +18 -0
  98. package/lib/drain3/persistence/MemoryPersistence.js.map +1 -0
  99. package/lib/drain3/persistence/PersistenceHandler.js +5 -0
  100. package/lib/drain3/persistence/PersistenceHandler.js.map +1 -0
  101. package/lib/drain3/types.js +7 -0
  102. package/lib/drain3/types.js.map +1 -0
  103. package/lib/emittery/emitter.js +10 -0
  104. package/lib/emittery/emitter.js.map +1 -0
  105. package/lib/emittery/index.js +2 -0
  106. package/lib/emittery/index.js.map +1 -0
  107. package/lib/foundation/schema/SexType.js +5 -3
  108. package/lib/foundation/schema/SexType.js.map +1 -0
  109. package/lib/foundation/schema/index.js +1 -0
  110. package/lib/foundation/schema/index.js.map +1 -0
  111. package/lib/foundation/schema/parseSexType.js +1 -0
  112. package/lib/foundation/schema/parseSexType.js.map +1 -0
  113. package/lib/foundation/schema/types.js +4 -2
  114. package/lib/foundation/schema/types.js.map +1 -0
  115. package/lib/fs/FileSystemError.js +23 -0
  116. package/lib/fs/FileSystemError.js.map +1 -0
  117. package/lib/fs/IFileSystem.d.js +3 -0
  118. package/lib/fs/IFileSystem.d.js.map +1 -0
  119. package/lib/fs/MemoryFileSystem.test.js +188 -0
  120. package/lib/fs/createBrowserFileSystem.js +250 -0
  121. package/lib/fs/createBrowserFileSystem.js.map +1 -0
  122. package/lib/fs/createMemoryFileSystem.js +517 -0
  123. package/lib/fs/createMemoryFileSystem.js.map +1 -0
  124. package/lib/fs/createSandboxFileSystem.js +108 -0
  125. package/lib/fs/createSandboxFileSystem.js.map +1 -0
  126. package/lib/fs/createWebDavFileSystem.js +154 -0
  127. package/lib/fs/createWebDavFileSystem.js.map +1 -0
  128. package/lib/fs/createWebFileSystem.js +225 -0
  129. package/lib/fs/createWebFileSystem.js.map +1 -0
  130. package/lib/fs/findMimeType.js +17 -0
  131. package/lib/fs/findMimeType.js.map +1 -0
  132. package/lib/fs/index.js +8 -0
  133. package/lib/fs/index.js.map +1 -0
  134. package/lib/fs/minio/createMinioFileSystem.js +974 -0
  135. package/lib/fs/minio/createMinioFileSystem.js.map +1 -0
  136. package/lib/fs/minio/index.js +2 -0
  137. package/lib/fs/minio/index.js.map +1 -0
  138. package/lib/fs/orpc/FileSystemContract.js +93 -0
  139. package/lib/fs/orpc/FileSystemContract.js.map +1 -0
  140. package/lib/fs/orpc/createContractClientFileSystem.js +93 -0
  141. package/lib/fs/orpc/createContractClientFileSystem.js.map +1 -0
  142. package/lib/fs/orpc/index.js +3 -0
  143. package/lib/fs/orpc/index.js.map +1 -0
  144. package/lib/fs/orpc/server/createFileSystemContractImpl.js +63 -0
  145. package/lib/fs/orpc/server/createFileSystemContractImpl.js.map +1 -0
  146. package/lib/fs/orpc/server/index.js +2 -0
  147. package/lib/fs/orpc/server/index.js.map +1 -0
  148. package/lib/fs/s3/createS3MiniFileSystem.js +753 -0
  149. package/lib/fs/s3/createS3MiniFileSystem.js.map +1 -0
  150. package/lib/fs/s3/index.js +2 -0
  151. package/lib/fs/s3/index.js.map +1 -0
  152. package/lib/fs/s3/s3mini.test.js +584 -0
  153. package/lib/fs/scandir.js +59 -0
  154. package/lib/fs/scandir.js.map +1 -0
  155. package/lib/fs/server/createDatabaseFileSystem.js +750 -0
  156. package/lib/fs/server/createDatabaseFileSystem.js.map +1 -0
  157. package/lib/fs/server/createNodeFileSystem.js +426 -0
  158. package/lib/fs/server/createNodeFileSystem.js.map +1 -0
  159. package/lib/fs/server/dbfs.test.js +221 -0
  160. package/lib/fs/server/index.js +2 -0
  161. package/lib/fs/server/index.js.map +1 -0
  162. package/lib/fs/server/loadTestDatabase.js +127 -0
  163. package/lib/fs/server/loadTestDatabase.js.map +1 -0
  164. package/lib/fs/tests/runFileSystemTest.js +319 -0
  165. package/lib/fs/tests/runFileSystemTest.js.map +1 -0
  166. package/lib/fs/types.js +27 -0
  167. package/lib/fs/types.js.map +1 -0
  168. package/lib/fs/utils/getFileUrl.js +35 -0
  169. package/lib/fs/utils/getFileUrl.js.map +1 -0
  170. package/lib/fs/utils.js +22 -0
  171. package/lib/fs/utils.js.map +1 -0
  172. package/lib/fs/webdav/index.js +2 -0
  173. package/lib/fs/webdav/index.js.map +1 -0
  174. package/lib/index.js +1 -0
  175. package/lib/index.js.map +1 -0
  176. package/lib/jsonschema/JsonSchema.js +146 -172
  177. package/lib/jsonschema/JsonSchema.js.map +1 -0
  178. package/lib/jsonschema/forEachJsonSchema.js +44 -0
  179. package/lib/jsonschema/forEachJsonSchema.js.map +1 -0
  180. package/lib/jsonschema/index.js +2 -0
  181. package/lib/jsonschema/index.js.map +1 -0
  182. package/lib/jsonschema/types.d.js +2 -0
  183. package/lib/jsonschema/types.d.js.map +1 -0
  184. package/lib/meta/defineFileType.js +20 -103
  185. package/lib/meta/defineFileType.js.map +1 -0
  186. package/lib/meta/defineInit.js +31 -250
  187. package/lib/meta/defineInit.js.map +1 -0
  188. package/lib/meta/defineMetadata.js +24 -140
  189. package/lib/meta/defineMetadata.js.map +1 -0
  190. package/lib/meta/index.js +1 -0
  191. package/lib/meta/index.js.map +1 -0
  192. package/lib/orpc/createOpenApiContractClient.js +27 -0
  193. package/lib/orpc/createOpenApiContractClient.js.map +1 -0
  194. package/lib/orpc/createRpcContractClient.js +34 -0
  195. package/lib/orpc/createRpcContractClient.js.map +1 -0
  196. package/lib/orpc/index.js +3 -0
  197. package/lib/orpc/index.js.map +1 -0
  198. package/lib/orpc/resolveLinkPlugins.js +28 -0
  199. package/lib/orpc/resolveLinkPlugins.js.map +1 -0
  200. package/lib/password/PHC.js +63 -87
  201. package/lib/password/PHC.js.map +1 -0
  202. package/lib/password/PHC.test.js +11 -3
  203. package/lib/password/Password.js +29 -294
  204. package/lib/password/Password.js.map +1 -0
  205. package/lib/password/Password.test.js +35 -22
  206. package/lib/password/createArgon2PasswordAlgorithm.js +35 -191
  207. package/lib/password/createArgon2PasswordAlgorithm.js.map +1 -0
  208. package/lib/password/createBase64PasswordAlgorithm.js +8 -141
  209. package/lib/password/createBase64PasswordAlgorithm.js.map +1 -0
  210. package/lib/password/createBcryptPasswordAlgorithm.js +13 -168
  211. package/lib/password/createBcryptPasswordAlgorithm.js.map +1 -0
  212. package/lib/password/createPBKDF2PasswordAlgorithm.js +46 -228
  213. package/lib/password/createPBKDF2PasswordAlgorithm.js.map +1 -0
  214. package/lib/password/createScryptPasswordAlgorithm.js +55 -211
  215. package/lib/password/createScryptPasswordAlgorithm.js.map +1 -0
  216. package/lib/password/index.js +1 -0
  217. package/lib/password/index.js.map +1 -0
  218. package/lib/password/server/index.js +1 -0
  219. package/lib/password/server/index.js.map +1 -0
  220. package/lib/resource/Identifiable.js +2 -0
  221. package/lib/resource/Identifiable.js.map +1 -0
  222. package/lib/resource/ListQuery.js +21 -93
  223. package/lib/resource/ListQuery.js.map +1 -0
  224. package/lib/resource/getTitleOfResource.js +3 -5
  225. package/lib/resource/getTitleOfResource.js.map +1 -0
  226. package/lib/resource/index.js +1 -0
  227. package/lib/resource/index.js.map +1 -0
  228. package/lib/resource/schema/AnyResourceSchema.js +2 -1
  229. package/lib/resource/schema/AnyResourceSchema.js.map +1 -0
  230. package/lib/resource/schema/BaseResourceSchema.js +2 -1
  231. package/lib/resource/schema/BaseResourceSchema.js.map +1 -0
  232. package/lib/resource/schema/ResourceActionType.js +6 -4
  233. package/lib/resource/schema/ResourceActionType.js.map +1 -0
  234. package/lib/resource/schema/ResourceStatus.js +5 -3
  235. package/lib/resource/schema/ResourceStatus.js.map +1 -0
  236. package/lib/resource/schema/ResourceType.js +5 -3
  237. package/lib/resource/schema/ResourceType.js.map +1 -0
  238. package/lib/resource/schema/index.js +1 -0
  239. package/lib/resource/schema/index.js.map +1 -0
  240. package/lib/resource/schema/types.js +16 -20
  241. package/lib/resource/schema/types.js.map +1 -0
  242. package/lib/s3/formatS3Url.js +65 -0
  243. package/lib/s3/formatS3Url.js.map +1 -0
  244. package/lib/s3/formatS3Url.test.js +262 -0
  245. package/lib/s3/index.js +3 -0
  246. package/lib/s3/index.js.map +1 -0
  247. package/lib/s3/parseS3Url.js +65 -0
  248. package/lib/s3/parseS3Url.js.map +1 -0
  249. package/lib/s3/parseS3Url.test.js +270 -0
  250. package/lib/schema/SchemaRegistry.js +38 -38
  251. package/lib/schema/SchemaRegistry.js.map +1 -0
  252. package/lib/schema/TypeSchema.d.js +2 -0
  253. package/lib/schema/TypeSchema.d.js.map +1 -0
  254. package/lib/schema/createSchemaData.js +26 -125
  255. package/lib/schema/createSchemaData.js.map +1 -0
  256. package/lib/schema/findJsonSchemaByPath.js +13 -36
  257. package/lib/schema/findJsonSchemaByPath.js.map +1 -0
  258. package/lib/schema/formatZodError.js +138 -0
  259. package/lib/schema/formatZodError.js.map +1 -0
  260. package/lib/schema/formatZodError.test.js +196 -0
  261. package/lib/schema/getSchemaCache.js +5 -5
  262. package/lib/schema/getSchemaCache.js.map +1 -0
  263. package/lib/schema/getSchemaOptions.js +8 -11
  264. package/lib/schema/getSchemaOptions.js.map +1 -0
  265. package/lib/schema/index.js +2 -1
  266. package/lib/schema/index.js.map +1 -0
  267. package/lib/schema/toJsonSchema.js +50 -293
  268. package/lib/schema/toJsonSchema.js.map +1 -0
  269. package/lib/schema/validate.js +34 -46
  270. package/lib/schema/validate.js.map +1 -0
  271. package/lib/tools/generateSchema.js +39 -197
  272. package/lib/tools/generateSchema.js.map +1 -0
  273. package/lib/tools/renderJsonSchemaToMarkdownDoc.js +55 -143
  274. package/lib/tools/renderJsonSchemaToMarkdownDoc.js.map +1 -0
  275. package/lib/utils/buildBaseUrl.js +13 -0
  276. package/lib/utils/buildBaseUrl.js.map +1 -0
  277. package/lib/utils/buildRedactorFormSchema.js +59 -0
  278. package/lib/utils/buildRedactorFormSchema.js.map +1 -0
  279. package/lib/utils/getEstimateProcessTime.js +12 -11
  280. package/lib/utils/getEstimateProcessTime.js.map +1 -0
  281. package/lib/utils/index.js +3 -0
  282. package/lib/utils/index.js.map +1 -0
  283. package/lib/utils/resolveFeatureOptions.js +12 -0
  284. package/lib/utils/resolveFeatureOptions.js.map +1 -0
  285. package/package.json +80 -13
  286. package/src/ai/qwen3vl/index.ts +1 -0
  287. package/src/ai/qwen3vl/utils.ts +36 -0
  288. package/src/ai/vision/DocLayoutElementTypeSchema.ts +30 -0
  289. package/src/ai/vision/ImageAnnotationSchema.ts +60 -0
  290. package/src/ai/vision/index.ts +2 -0
  291. package/src/ai/vision/resolveImageAnnotation.ts +135 -0
  292. package/src/cn/ChineseResidentIdNo.test.ts +1 -1
  293. package/src/cn/ChineseResidentIdNo.ts +9 -1
  294. package/src/cn/DivisionCode.test.ts +1 -1
  295. package/src/cn/DivisionCode.ts +8 -0
  296. package/src/cn/Mod11.ts +1 -1
  297. package/src/cn/UnifiedSocialCreditCode.test.ts +1 -1
  298. package/src/cn/UnifiedSocialCreditCode.ts +15 -0
  299. package/src/cn/__snapshots__/ChineseResidentIdNo.test.ts.snap +1 -1
  300. package/src/cn/formatChineseAmount.ts +61 -0
  301. package/src/cn/index.ts +7 -1
  302. package/src/cn/parseChineseNumber.test.ts +159 -0
  303. package/src/cn/parseChineseNumber.ts +97 -0
  304. package/src/cn/pinyin/cartesianProduct.test.ts +64 -0
  305. package/src/cn/pinyin/cartesianProduct.ts +24 -0
  306. package/src/cn/pinyin/data.json +23573 -0
  307. package/src/cn/pinyin/loader.ts +12 -0
  308. package/src/cn/pinyin/preload.ts +3 -0
  309. package/src/cn/pinyin/toPinyin.test.ts +12 -0
  310. package/src/cn/pinyin/toPinyinPure.ts +43 -0
  311. package/src/cn/pinyin/transform.ts +12 -0
  312. package/src/consola/formatLogObject.test.ts +27 -0
  313. package/src/consola/formatLogObject.ts +40 -12
  314. package/src/data/maybeNumber.ts +1 -1
  315. package/src/data/parseSort.test.ts +0 -1
  316. package/src/data/types.d.ts +2 -2
  317. package/src/dayjs/dayjs.ts +18 -18
  318. package/src/dayjs/formatDuration.ts +2 -2
  319. package/src/dayjs/index.ts +3 -1
  320. package/src/dayjs/parseRelativeTime.test.ts +185 -0
  321. package/src/dayjs/parseRelativeTime.ts +115 -0
  322. package/src/dayjs/resolveRelativeTime.test.ts +357 -0
  323. package/src/dayjs/resolveRelativeTime.ts +164 -0
  324. package/src/drain3/Drain.test.ts +378 -0
  325. package/src/drain3/Drain.ts +394 -0
  326. package/src/drain3/LogCluster.ts +46 -0
  327. package/src/drain3/Node.ts +53 -0
  328. package/src/drain3/TemplateMiner.ts +246 -0
  329. package/src/drain3/index.ts +36 -0
  330. package/src/drain3/persistence/FilePersistence.ts +24 -0
  331. package/src/drain3/persistence/MemoryPersistence.ts +23 -0
  332. package/src/drain3/persistence/PersistenceHandler.ts +19 -0
  333. package/src/drain3/types.ts +75 -0
  334. package/src/emittery/emitter.ts +9 -0
  335. package/src/emittery/index.ts +1 -0
  336. package/src/fs/FileSystemError.ts +26 -0
  337. package/src/fs/IFileSystem.d.ts +101 -0
  338. package/src/fs/MemoryFileSystem.test.ts +37 -0
  339. package/src/fs/createBrowserFileSystem.ts +293 -0
  340. package/src/fs/createMemoryFileSystem.ts +600 -0
  341. package/src/fs/createSandboxFileSystem.ts +136 -0
  342. package/src/fs/createWebDavFileSystem.ts +190 -0
  343. package/src/fs/createWebFileSystem.ts +242 -0
  344. package/src/fs/findMimeType.ts +20 -0
  345. package/src/fs/index.ts +8 -0
  346. package/src/fs/minio/createMinioFileSystem.ts +1148 -0
  347. package/src/fs/minio/index.ts +1 -0
  348. package/src/fs/orpc/FileSystemContract.ts +92 -0
  349. package/src/fs/orpc/createContractClientFileSystem.ts +115 -0
  350. package/src/fs/orpc/index.ts +2 -0
  351. package/src/fs/orpc/server/createFileSystemContractImpl.ts +64 -0
  352. package/src/fs/orpc/server/index.ts +1 -0
  353. package/src/fs/s3/createS3MiniFileSystem.ts +871 -0
  354. package/src/fs/s3/index.ts +1 -0
  355. package/src/fs/s3/s3fs.test.ts +441 -0
  356. package/src/fs/s3/s3mini.test.ts +264 -0
  357. package/src/fs/scandir.ts +75 -0
  358. package/src/fs/server/createDatabaseFileSystem.ts +668 -0
  359. package/src/fs/server/createNodeFileSystem.ts +518 -0
  360. package/src/fs/server/dbfs.test.ts +48 -0
  361. package/src/fs/server/index.ts +1 -0
  362. package/src/fs/server/loadTestDatabase.ts +131 -0
  363. package/src/fs/tests/runFileSystemTest.ts +289 -0
  364. package/src/fs/types.ts +29 -0
  365. package/src/fs/utils/getFileUrl.ts +44 -0
  366. package/src/fs/utils.ts +23 -0
  367. package/src/fs/webdav/index.ts +1 -0
  368. package/src/jsonschema/JsonSchema.ts +118 -110
  369. package/src/jsonschema/forEachJsonSchema.ts +50 -0
  370. package/src/jsonschema/index.ts +1 -0
  371. package/src/jsonschema/types.d.ts +1 -1
  372. package/src/meta/defineMetadata.ts +1 -1
  373. package/src/orpc/createOpenApiContractClient.ts +52 -0
  374. package/src/orpc/createRpcContractClient.ts +50 -0
  375. package/src/orpc/index.ts +2 -0
  376. package/src/orpc/resolveLinkPlugins.ts +29 -0
  377. package/src/password/PHC.ts +6 -6
  378. package/src/password/Password.test.ts +1 -1
  379. package/src/password/createArgon2PasswordAlgorithm.ts +1 -1
  380. package/src/password/createBase64PasswordAlgorithm.ts +2 -2
  381. package/src/password/createBcryptPasswordAlgorithm.ts +4 -2
  382. package/src/password/createPBKDF2PasswordAlgorithm.ts +4 -4
  383. package/src/password/createScryptPasswordAlgorithm.ts +4 -4
  384. package/src/resource/ListQuery.ts +4 -1
  385. package/src/resource/index.ts +2 -2
  386. package/src/resource/schema/AnyResourceSchema.ts +16 -2
  387. package/src/s3/formatS3Url.test.ts +254 -0
  388. package/src/s3/formatS3Url.ts +84 -0
  389. package/src/s3/index.ts +2 -0
  390. package/src/s3/parseS3Url.test.ts +258 -0
  391. package/src/s3/parseS3Url.ts +88 -0
  392. package/src/schema/SchemaRegistry.ts +35 -33
  393. package/src/schema/TypeSchema.d.ts +6 -6
  394. package/src/schema/createSchemaData.ts +4 -4
  395. package/src/schema/findJsonSchemaByPath.ts +4 -4
  396. package/src/schema/formatZodError.test.ts +197 -0
  397. package/src/schema/formatZodError.ts +139 -0
  398. package/src/schema/getSchemaOptions.ts +2 -2
  399. package/src/schema/index.ts +1 -1
  400. package/src/schema/toJsonSchema.ts +6 -6
  401. package/src/schema/validate.ts +1 -1
  402. package/src/utils/buildBaseUrl.ts +12 -0
  403. package/src/utils/buildRedactorFormSchema.ts +85 -0
  404. package/src/utils/index.ts +4 -0
  405. package/src/utils/resolveFeatureOptions.ts +14 -0
  406. package/src/cn/ChineseResidentIdNo.mod.ts +0 -7
  407. package/src/cn/DivisionCode.mod.ts +0 -7
  408. package/src/cn/UnifiedSocialCreditCode.mod.ts +0 -7
  409. package/src/cn/mod.ts +0 -3
  410. package/src/schema/SchemaRegistry.mod.ts +0 -1
@@ -0,0 +1,204 @@
1
+ import { Drain } from "./Drain.js";
2
+ /**
3
+ * High-level API for log template mining with persistence support.
4
+ *
5
+ * TemplateMiner wraps the Drain algorithm and provides convenience methods
6
+ * for extracting parameters and managing persistence.
7
+ */ export class TemplateMiner {
8
+ drain;
9
+ persistence;
10
+ constructor(drain, persistence) {
11
+ this.drain = drain;
12
+ this.persistence = persistence;
13
+ }
14
+ /**
15
+ * Adds a log message and returns the update type, cluster, template, and cluster count.
16
+ *
17
+ * @param content The log message content
18
+ * @returns Object containing updateType, cluster, templateMined, and clusterCount
19
+ */ async addLogMessage(content) {
20
+ const { cluster, updateType } = this.drain.addLogMessage(content);
21
+ const templateMined = cluster.getTemplate();
22
+ const clusterCount = this.drain.getClusters().length;
23
+ if (updateType !== "none") {
24
+ await this.saveState();
25
+ }
26
+ return {
27
+ updateType,
28
+ cluster,
29
+ templateMined,
30
+ clusterCount
31
+ };
32
+ }
33
+ /**
34
+ * Matches a log message against an already existing cluster.
35
+ *
36
+ * @param content Log message to match
37
+ * @param strategy Search strategy
38
+ * @returns Matched cluster or null
39
+ */ match(content, strategy = "never") {
40
+ return this.drain.match(content, strategy);
41
+ }
42
+ /**
43
+ * Extracts parameters from a log message according to a provided template.
44
+ *
45
+ * @param logTemplate Template generated by AddLogMessage
46
+ * @param logMessage The log message to extract parameters from
47
+ * @returns Array of extracted parameters, or null if template doesn't match
48
+ */ extractParameters(logTemplate, logMessage) {
49
+ // Apply delimiters
50
+ let processedMessage = logMessage;
51
+ for (const delimiter of this.drain.extraDelimiters) {
52
+ // Escape delimiter for regex if it contains special characters
53
+ const escapedDelimiter = delimiter.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
54
+ processedMessage = processedMessage.replace(new RegExp(escapedDelimiter, "g"), " ");
55
+ }
56
+ const { templateRegex, paramGroupNameToMaskName } = this.getTemplateParameterExtractionRegex(logTemplate);
57
+ // Create regex from template
58
+ const regex = new RegExp(templateRegex);
59
+ // Match the log message against the template
60
+ const match = processedMessage.match(regex);
61
+ // Template doesn't match
62
+ if (match === null) {
63
+ return null;
64
+ }
65
+ // Extract named captures
66
+ const extractedParameters = [];
67
+ // Get all named groups from the match
68
+ if (match.groups) {
69
+ for (const [groupName, value] of Object.entries(match.groups)) {
70
+ if (value !== undefined) {
71
+ const maskName = paramGroupNameToMaskName.get(groupName);
72
+ if (maskName !== undefined) {
73
+ extractedParameters.push({
74
+ value,
75
+ maskName
76
+ });
77
+ }
78
+ }
79
+ }
80
+ }
81
+ // Also check by index if groups are not available (fallback)
82
+ // The regex exec method provides better named group support
83
+ const execResult = regex.exec(processedMessage);
84
+ if (execResult !== null && execResult.groups === undefined) {
85
+ // Fallback: extract by order (less reliable but works)
86
+ const indices = Array.from({
87
+ length: execResult.length - 1
88
+ }, (_, i) => i + 1);
89
+ let paramIndex = 0;
90
+ for (const index of indices) {
91
+ const value = execResult[index];
92
+ if (value !== undefined) {
93
+ // Find corresponding mask name by order
94
+ // This is a fallback - ideally we should use named groups
95
+ const maskName = paramGroupNameToMaskName.get(`p_${paramIndex}`);
96
+ if (maskName !== undefined) {
97
+ extractedParameters.push({
98
+ value,
99
+ maskName
100
+ });
101
+ }
102
+ paramIndex++;
103
+ }
104
+ }
105
+ }
106
+ return extractedParameters.length > 0 ? extractedParameters : null;
107
+ }
108
+ /**
109
+ * Gets the template parameter extraction regex and mapping.
110
+ *
111
+ * @param logTemplate The log template
112
+ * @returns Tuple of [templateRegex, paramGroupNameToMaskName]
113
+ */ getTemplateParameterExtractionRegex(logTemplate) {
114
+ const paramGroupNameToMaskName = new Map();
115
+ let paramNameCounter = 0;
116
+ const getNextParamName = () => {
117
+ const paramGroupName = `p_${paramNameCounter}`;
118
+ paramNameCounter++;
119
+ return paramGroupName;
120
+ };
121
+ // Create a named group with the respective patterns for the given mask-name
122
+ const createCaptureRegex = (maskName) => {
123
+ const allowedPatterns = [];
124
+ if (maskName === "*") {
125
+ allowedPatterns.push(".+?");
126
+ }
127
+ // Give each capture group a unique name to avoid conflict
128
+ const paramGroupName = getNextParamName();
129
+ paramGroupNameToMaskName.set(paramGroupName, maskName);
130
+ const joinedPatterns = allowedPatterns.join("|");
131
+ const captureRegex = `(?<${paramGroupName}>${joinedPatterns})`;
132
+ return captureRegex;
133
+ };
134
+ // For every mask in the template, replace it with a named group
135
+ const maskNames = new Set();
136
+ // The drain catch-all mask
137
+ maskNames.add("*");
138
+ // Escape the template for regex
139
+ let templateRegex = this.escapeRegex(logTemplate);
140
+ // Replace each mask name with a proper regex that captures it
141
+ for (const maskName of maskNames) {
142
+ const searchStr = `<${this.escapeRegex(maskName)}>`;
143
+ // Replace one-by-one to get a new param group name for each replacement
144
+ while (true) {
145
+ const repStr = createCaptureRegex(maskName);
146
+ const templateRegexNew = templateRegex.replace(searchStr, repStr);
147
+ // Break when all replaces for this mask are done
148
+ if (templateRegexNew === templateRegex) {
149
+ break;
150
+ }
151
+ templateRegex = templateRegexNew;
152
+ }
153
+ }
154
+ // Match also messages with multiple spaces or other whitespace chars between tokens
155
+ templateRegex = templateRegex.replace(/\\ /g, "\\s+");
156
+ templateRegex = `^${templateRegex}$`;
157
+ return {
158
+ templateRegex,
159
+ paramGroupNameToMaskName
160
+ };
161
+ }
162
+ /**
163
+ * Escapes special regex characters in a string.
164
+ */ escapeRegex(str) {
165
+ return str.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
166
+ }
167
+ /**
168
+ * Loads the Drain state from persistence.
169
+ *
170
+ * @throws Error if loading fails
171
+ */ async loadState() {
172
+ const state = await this.persistence.load();
173
+ if (state === null || typeof state === "string" && state.length === 0) {
174
+ throw new Error("saved state not found");
175
+ }
176
+ try {
177
+ const stateStr = typeof state === "string" ? state : new TextDecoder().decode(state);
178
+ const data = JSON.parse(stateStr);
179
+ this.drain = Drain.fromJSON(data);
180
+ }
181
+ catch (error) {
182
+ throw new Error(`failed to unmarshal state: ${error instanceof Error ? error.message : String(error)}`);
183
+ }
184
+ }
185
+ /**
186
+ * Saves the Drain state to persistence.
187
+ *
188
+ * @throws Error if saving fails
189
+ */ async saveState() {
190
+ try {
191
+ const state = JSON.stringify(this.drain.toJSON());
192
+ await this.persistence.save(state);
193
+ }
194
+ catch (error) {
195
+ throw new Error(`failed to save state: ${error instanceof Error ? error.message : String(error)}`);
196
+ }
197
+ }
198
+ /**
199
+ * Gets the underlying Drain instance.
200
+ */ getDrain() {
201
+ return this.drain;
202
+ }
203
+ }
204
+ //# sourceMappingURL=TemplateMiner.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/drain3/TemplateMiner.ts"],"sourcesContent":["import { Drain } from './Drain';\nimport type { LogCluster } from './LogCluster';\nimport type { PersistenceHandler } from './persistence/PersistenceHandler';\nimport type { ClusterUpdateType, ExtractedParameter, SearchStrategy } from './types';\n\n/**\n * High-level API for log template mining with persistence support.\n *\n * TemplateMiner wraps the Drain algorithm and provides convenience methods\n * for extracting parameters and managing persistence.\n */\nexport class TemplateMiner {\n\tconstructor(\n\t\tprivate drain: Drain,\n\t\tprivate readonly persistence: PersistenceHandler,\n\t) {}\n\n\t/**\n\t * Adds a log message and returns the update type, cluster, template, and cluster count.\n\t *\n\t * @param content The log message content\n\t * @returns Object containing updateType, cluster, templateMined, and clusterCount\n\t */\n\tasync addLogMessage(content: string): Promise<{\n\t\tupdateType: ClusterUpdateType;\n\t\tcluster: LogCluster;\n\t\ttemplateMined: string;\n\t\tclusterCount: number;\n\t}> {\n\t\tconst { cluster, updateType } = this.drain.addLogMessage(content);\n\n\t\tconst templateMined = cluster.getTemplate();\n\t\tconst clusterCount = this.drain.getClusters().length;\n\n\t\tif (updateType !== 'none') {\n\t\t\tawait this.saveState();\n\t\t}\n\n\t\treturn {\n\t\t\tupdateType,\n\t\t\tcluster,\n\t\t\ttemplateMined,\n\t\t\tclusterCount,\n\t\t};\n\t}\n\n\t/**\n\t * Matches a log message against an already existing cluster.\n\t *\n\t * @param content Log message to match\n\t * @param strategy Search strategy\n\t * @returns Matched cluster or null\n\t */\n\tmatch(content: string, strategy: SearchStrategy = 'never'): LogCluster | null {\n\t\treturn this.drain.match(content, strategy);\n\t}\n\n\t/**\n\t * Extracts parameters from a log message according to a provided template.\n\t *\n\t * @param logTemplate Template generated by AddLogMessage\n\t * @param logMessage The log message to extract parameters from\n\t * @returns Array of extracted parameters, or null if template doesn't match\n\t */\n\textractParameters(logTemplate: string, logMessage: string): ExtractedParameter[] | null {\n\t\t// Apply delimiters\n\t\tlet processedMessage = logMessage;\n\t\tfor (const delimiter of this.drain.extraDelimiters) {\n\t\t\t// Escape delimiter for regex if it contains special characters\n\t\t\tconst escapedDelimiter = delimiter.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&');\n\t\t\tprocessedMessage = processedMessage.replace(new RegExp(escapedDelimiter, 'g'), ' ');\n\t\t}\n\n\t\tconst { templateRegex, paramGroupNameToMaskName } = this.getTemplateParameterExtractionRegex(logTemplate);\n\n\t\t// Create regex from template\n\t\tconst regex = new RegExp(templateRegex);\n\n\t\t// Match the log message against the template\n\t\tconst match = processedMessage.match(regex);\n\n\t\t// Template doesn't match\n\t\tif (match === null) {\n\t\t\treturn null;\n\t\t}\n\n\t\t// Extract named captures\n\t\tconst extractedParameters: ExtractedParameter[] = [];\n\n\t\t// Get all named groups from the match\n\t\tif (match.groups) {\n\t\t\tfor (const [groupName, value] of Object.entries(match.groups)) {\n\t\t\t\tif (value !== undefined) {\n\t\t\t\t\tconst maskName = paramGroupNameToMaskName.get(groupName);\n\t\t\t\t\tif (maskName !== undefined) {\n\t\t\t\t\t\textractedParameters.push({\n\t\t\t\t\t\t\tvalue,\n\t\t\t\t\t\t\tmaskName,\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t// Also check by index if groups are not available (fallback)\n\t\t// The regex exec method provides better named group support\n\t\tconst execResult = regex.exec(processedMessage);\n\t\tif (execResult !== null && execResult.groups === undefined) {\n\t\t\t// Fallback: extract by order (less reliable but works)\n\t\t\tconst indices = Array.from({ length: execResult.length - 1 }, (_, i) => i + 1);\n\t\t\tlet paramIndex = 0;\n\t\t\tfor (const index of indices) {\n\t\t\t\tconst value = execResult[index];\n\t\t\t\tif (value !== undefined) {\n\t\t\t\t\t// Find corresponding mask name by order\n\t\t\t\t\t// This is a fallback - ideally we should use named groups\n\t\t\t\t\tconst maskName = paramGroupNameToMaskName.get(`p_${paramIndex}`);\n\t\t\t\t\tif (maskName !== undefined) {\n\t\t\t\t\t\textractedParameters.push({\n\t\t\t\t\t\t\tvalue,\n\t\t\t\t\t\t\tmaskName,\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\t\t\t\t\tparamIndex++;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn extractedParameters.length > 0 ? extractedParameters : null;\n\t}\n\n\t/**\n\t * Gets the template parameter extraction regex and mapping.\n\t *\n\t * @param logTemplate The log template\n\t * @returns Tuple of [templateRegex, paramGroupNameToMaskName]\n\t */\n\tprivate getTemplateParameterExtractionRegex(logTemplate: string): {\n\t\ttemplateRegex: string;\n\t\tparamGroupNameToMaskName: Map<string, string>;\n\t} {\n\t\tconst paramGroupNameToMaskName = new Map<string, string>();\n\t\tlet paramNameCounter = 0;\n\n\t\tconst getNextParamName = (): string => {\n\t\t\tconst paramGroupName = `p_${paramNameCounter}`;\n\t\t\tparamNameCounter++;\n\t\t\treturn paramGroupName;\n\t\t};\n\n\t\t// Create a named group with the respective patterns for the given mask-name\n\t\tconst createCaptureRegex = (maskName: string): string => {\n\t\t\tconst allowedPatterns: string[] = [];\n\n\t\t\tif (maskName === '*') {\n\t\t\t\tallowedPatterns.push('.+?');\n\t\t\t}\n\n\t\t\t// Give each capture group a unique name to avoid conflict\n\t\t\tconst paramGroupName = getNextParamName();\n\t\t\tparamGroupNameToMaskName.set(paramGroupName, maskName);\n\t\t\tconst joinedPatterns = allowedPatterns.join('|');\n\t\t\tconst captureRegex = `(?<${paramGroupName}>${joinedPatterns})`;\n\n\t\t\treturn captureRegex;\n\t\t};\n\n\t\t// For every mask in the template, replace it with a named group\n\t\tconst maskNames = new Set<string>();\n\t\t// The drain catch-all mask\n\t\tmaskNames.add('*');\n\n\t\t// Escape the template for regex\n\t\tlet templateRegex = this.escapeRegex(logTemplate);\n\n\t\t// Replace each mask name with a proper regex that captures it\n\t\tfor (const maskName of maskNames) {\n\t\t\tconst searchStr = `<${this.escapeRegex(maskName)}>`;\n\n\t\t\t// Replace one-by-one to get a new param group name for each replacement\n\t\t\twhile (true) {\n\t\t\t\tconst repStr = createCaptureRegex(maskName);\n\t\t\t\tconst templateRegexNew = templateRegex.replace(searchStr, repStr);\n\t\t\t\t// Break when all replaces for this mask are done\n\t\t\t\tif (templateRegexNew === templateRegex) {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\ttemplateRegex = templateRegexNew;\n\t\t\t}\n\t\t}\n\n\t\t// Match also messages with multiple spaces or other whitespace chars between tokens\n\t\ttemplateRegex = templateRegex.replace(/\\\\ /g, '\\\\s+');\n\t\ttemplateRegex = `^${templateRegex}$`;\n\n\t\treturn { templateRegex, paramGroupNameToMaskName };\n\t}\n\n\t/**\n\t * Escapes special regex characters in a string.\n\t */\n\tprivate escapeRegex(str: string): string {\n\t\treturn str.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&');\n\t}\n\n\t/**\n\t * Loads the Drain state from persistence.\n\t *\n\t * @throws Error if loading fails\n\t */\n\tasync loadState(): Promise<void> {\n\t\tconst state = await this.persistence.load();\n\t\tif (state === null || (typeof state === 'string' && state.length === 0)) {\n\t\t\tthrow new Error('saved state not found');\n\t\t}\n\n\t\ttry {\n\t\t\tconst stateStr = typeof state === 'string' ? state : new TextDecoder().decode(state);\n\t\t\tconst data = JSON.parse(stateStr);\n\t\t\tthis.drain = Drain.fromJSON(data);\n\t\t} catch (error) {\n\t\t\tthrow new Error(`failed to unmarshal state: ${error instanceof Error ? error.message : String(error)}`);\n\t\t}\n\t}\n\n\t/**\n\t * Saves the Drain state to persistence.\n\t *\n\t * @throws Error if saving fails\n\t */\n\tasync saveState(): Promise<void> {\n\t\ttry {\n\t\t\tconst state = JSON.stringify(this.drain.toJSON());\n\t\t\tawait this.persistence.save(state);\n\t\t} catch (error) {\n\t\t\tthrow new Error(`failed to save state: ${error instanceof Error ? error.message : String(error)}`);\n\t\t}\n\t}\n\n\t/**\n\t * Gets the underlying Drain instance.\n\t */\n\tgetDrain(): Drain {\n\t\treturn this.drain;\n\t}\n}\n"],"names":["Drain","TemplateMiner","drain","persistence","addLogMessage","content","cluster","updateType","templateMined","getTemplate","clusterCount","getClusters","length","saveState","match","strategy","extractParameters","logTemplate","logMessage","processedMessage","delimiter","extraDelimiters","escapedDelimiter","replace","RegExp","templateRegex","paramGroupNameToMaskName","getTemplateParameterExtractionRegex","regex","extractedParameters","groups","groupName","value","Object","entries","undefined","maskName","get","push","execResult","exec","indices","Array","from","_","i","paramIndex","index","Map","paramNameCounter","getNextParamName","paramGroupName","createCaptureRegex","allowedPatterns","set","joinedPatterns","join","captureRegex","maskNames","Set","add","escapeRegex","searchStr","repStr","templateRegexNew","str","loadState","state","load","Error","stateStr","TextDecoder","decode","data","JSON","parse","fromJSON","error","message","String","stringify","toJSON","save","getDrain"],"mappings":"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"}
@@ -0,0 +1,31 @@
1
+ /**
2
+ * Drain3 - A TypeScript implementation of the Drain log clustering algorithm.
3
+ *
4
+ * Drain is an online log parsing algorithm that groups log messages into clusters
5
+ * based on their structural similarity, extracting templates by parameterizing
6
+ * variable parts of the logs.
7
+ *
8
+ * @example
9
+ * ```typescript
10
+ * import { Drain, TemplateMiner, MemoryPersistence } from '@wener/common/drain3';
11
+ *
12
+ * // Basic usage
13
+ * const drain = new Drain({
14
+ * logClusterDepth: 4,
15
+ * simTh: 0.4,
16
+ * maxClusters: 1000
17
+ * });
18
+ *
19
+ * const result = drain.addLogMessage('[INFO] User 123 logged in');
20
+ * console.log(result.cluster.getTemplate()); // [INFO] User <*> logged in
21
+ *
22
+ * // Advanced usage with persistence
23
+ * const miner = new TemplateMiner(drain, new MemoryPersistence());
24
+ * await miner.addLogMessage('[INFO] User 123 logged in');
25
+ * ```
26
+ */ export { Drain } from "./Drain.js";
27
+ export { LogCluster } from "./LogCluster.js";
28
+ export { Node } from "./Node.js";
29
+ export { TemplateMiner } from "./TemplateMiner.js";
30
+ export { MemoryPersistence } from "./persistence/MemoryPersistence.js";
31
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/drain3/index.ts"],"sourcesContent":["/**\n * Drain3 - A TypeScript implementation of the Drain log clustering algorithm.\n *\n * Drain is an online log parsing algorithm that groups log messages into clusters\n * based on their structural similarity, extracting templates by parameterizing\n * variable parts of the logs.\n *\n * @example\n * ```typescript\n * import { Drain, TemplateMiner, MemoryPersistence } from '@wener/common/drain3';\n *\n * // Basic usage\n * const drain = new Drain({\n * logClusterDepth: 4,\n * simTh: 0.4,\n * maxClusters: 1000\n * });\n *\n * const result = drain.addLogMessage('[INFO] User 123 logged in');\n * console.log(result.cluster.getTemplate()); // [INFO] User <*> logged in\n *\n * // Advanced usage with persistence\n * const miner = new TemplateMiner(drain, new MemoryPersistence());\n * await miner.addLogMessage('[INFO] User 123 logged in');\n * ```\n */\n\nexport { Drain } from './Drain';\nexport { LogCluster } from './LogCluster';\nexport { Node } from './Node';\nexport { TemplateMiner } from './TemplateMiner';\n\nexport type { ClusterUpdateType, DrainOptions, ExtractedParameter, SearchStrategy } from './types';\n\nexport type { PersistenceHandler } from './persistence/PersistenceHandler';\nexport { MemoryPersistence } from './persistence/MemoryPersistence';\n"],"names":["Drain","LogCluster","Node","TemplateMiner","MemoryPersistence"],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;CAyBC,GAED,SAASA,KAAK,QAAQ,UAAU;AAChC,SAASC,UAAU,QAAQ,eAAe;AAC1C,SAASC,IAAI,QAAQ,SAAS;AAC9B,SAASC,aAAa,QAAQ,kBAAkB;AAKhD,SAASC,iBAAiB,QAAQ,kCAAkC"}
@@ -0,0 +1,24 @@
1
+ import { readFile, writeFile } from "node:fs/promises";
2
+ /**
3
+ * File-based persistence handler that saves and loads state from the filesystem.
4
+ */ export class FilePersistence {
5
+ filePath;
6
+ constructor(filePath){
7
+ this.filePath = filePath;
8
+ }
9
+ async save(state) {
10
+ await writeFile(this.filePath, state, 'utf8');
11
+ }
12
+ async load() {
13
+ try {
14
+ return await readFile(this.filePath, 'utf8');
15
+ } catch (error) {
16
+ if (error?.code === 'ENOENT') {
17
+ return null;
18
+ }
19
+ throw error;
20
+ }
21
+ }
22
+ }
23
+
24
+ //# sourceMappingURL=FilePersistence.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/drain3/persistence/FilePersistence.ts"],"sourcesContent":["import { readFile, writeFile } from 'node:fs/promises';\nimport type { PersistenceHandler } from './PersistenceHandler';\n\n/**\n * File-based persistence handler that saves and loads state from the filesystem.\n */\nexport class FilePersistence implements PersistenceHandler {\n\tconstructor(private readonly filePath: string) {}\n\n\tasync save(state: Uint8Array | string): Promise<void> {\n\t\tawait writeFile(this.filePath, state, 'utf8');\n\t}\n\n\tasync load(): Promise<string | null> {\n\t\ttry {\n\t\t\treturn await readFile(this.filePath, 'utf8');\n\t\t} catch (error) {\n\t\t\tif ((error as { code?: string })?.code === 'ENOENT') {\n\t\t\t\treturn null;\n\t\t\t}\n\t\t\tthrow error;\n\t\t}\n\t}\n}\n"],"names":["readFile","writeFile","FilePersistence","filePath","save","state","load","error","code"],"mappings":"AAAA,SAASA,QAAQ,EAAEC,SAAS,QAAQ,mBAAmB;AAGvD;;CAEC,GACD,OAAO,MAAMC;;IACZ,YAAY,AAAiBC,QAAgB,CAAE;aAAlBA,WAAAA;IAAmB;IAEhD,MAAMC,KAAKC,KAA0B,EAAiB;QACrD,MAAMJ,UAAU,IAAI,CAACE,QAAQ,EAAEE,OAAO;IACvC;IAEA,MAAMC,OAA+B;QACpC,IAAI;YACH,OAAO,MAAMN,SAAS,IAAI,CAACG,QAAQ,EAAE;QACtC,EAAE,OAAOI,OAAO;YACf,IAAI,AAACA,OAA6BC,SAAS,UAAU;gBACpD,OAAO;YACR;YACA,MAAMD;QACP;IACD;AACD"}
@@ -0,0 +1,18 @@
1
+ /**
2
+ * In-memory persistence handler that stores state in memory.
3
+ * Useful for testing or when persistence is not needed.
4
+ */ export class MemoryPersistence {
5
+ state = null;
6
+ /**
7
+ * Saves the state to memory.
8
+ */ async save(state) {
9
+ this.state = state;
10
+ }
11
+ /**
12
+ * Loads the state from memory.
13
+ */ async load() {
14
+ return this.state;
15
+ }
16
+ }
17
+
18
+ //# sourceMappingURL=MemoryPersistence.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/drain3/persistence/MemoryPersistence.ts"],"sourcesContent":["import type { PersistenceHandler } from './PersistenceHandler';\n\n/**\n * In-memory persistence handler that stores state in memory.\n * Useful for testing or when persistence is not needed.\n */\nexport class MemoryPersistence implements PersistenceHandler {\n\tprivate state: Uint8Array | string | null = null;\n\n\t/**\n\t * Saves the state to memory.\n\t */\n\tasync save(state: Uint8Array | string): Promise<void> {\n\t\tthis.state = state;\n\t}\n\n\t/**\n\t * Loads the state from memory.\n\t */\n\tasync load(): Promise<Uint8Array | string | null> {\n\t\treturn this.state;\n\t}\n}\n"],"names":["MemoryPersistence","state","save","load"],"mappings":"AAEA;;;CAGC,GACD,OAAO,MAAMA;IACJC,QAAoC,KAAK;IAEjD;;EAEC,GACD,MAAMC,KAAKD,KAA0B,EAAiB;QACrD,IAAI,CAACA,KAAK,GAAGA;IACd;IAEA;;EAEC,GACD,MAAME,OAA4C;QACjD,OAAO,IAAI,CAACF,KAAK;IAClB;AACD"}
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Interface for persistence handlers that can save and load Drain state.
3
+ */ export { };
4
+
5
+ //# sourceMappingURL=PersistenceHandler.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/drain3/persistence/PersistenceHandler.ts"],"sourcesContent":["/**\n * Interface for persistence handlers that can save and load Drain state.\n */\nexport interface PersistenceHandler {\n\t/**\n\t * Saves the Drain state.\n\t *\n\t * @param state Serialized state data\n\t * @returns Promise that resolves when save is complete\n\t */\n\tsave(state: Uint8Array | string): Promise<void>;\n\n\t/**\n\t * Loads the Drain state.\n\t *\n\t * @returns Promise that resolves with the loaded state, or null if no state exists\n\t */\n\tload(): Promise<Uint8Array | string | null>;\n}\n"],"names":[],"mappings":"AAAA;;CAEC,GACD,WAeC"}
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Cluster update type indicating what happened when a log message was processed.
3
+ */ /**
4
+ * Extracted parameter from a log message based on a template.
5
+ */ export { };
6
+
7
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/drain3/types.ts"],"sourcesContent":["/**\n * Cluster update type indicating what happened when a log message was processed.\n */\nexport type ClusterUpdateType = 'none' | 'created' | 'templateChanged';\n\n/**\n * Search strategy for matching log messages against existing clusters.\n *\n * - 'never': Fastest, always performs tree search [O(log(n))] but might produce false negatives\n * - 'fallback': Performs linear search [O(n)] only if tree search found no match, should not have false negatives\n * - 'always': Slowest, always evaluates all clusters and selects the best match with least wildcard parameters\n */\nexport type SearchStrategy = 'never' | 'fallback' | 'always';\n\n/**\n * Configuration options for Drain algorithm.\n */\nexport interface DrainOptions {\n\t/**\n\t * Depth of the prefix tree for log clustering. Must be at least 3.\n\t * @default 4\n\t */\n\tlogClusterDepth?: number;\n\n\t/**\n\t * Similarity threshold (0.0 to 1.0) for matching log messages to clusters.\n\t * @default 0.4\n\t */\n\tsimTh?: number;\n\n\t/**\n\t * Maximum number of children nodes in the prefix tree.\n\t * @default 100\n\t */\n\tmaxChildren?: number;\n\n\t/**\n\t * Maximum number of clusters to maintain in LRU cache.\n\t * @default 1000\n\t */\n\tmaxClusters?: number;\n\n\t/**\n\t * Additional delimiters to replace with spaces during tokenization.\n\t * @default []\n\t */\n\textraDelimiters?: string[];\n\n\t/**\n\t * String used to represent parameterized tokens in templates.\n\t * @default \"<*>\"\n\t */\n\tparamStr?: string;\n\n\t/**\n\t * Whether to automatically parameterize tokens containing numbers.\n\t * @default true\n\t */\n\tparametrizeNumericTokens?: boolean;\n}\n\n/**\n * Extracted parameter from a log message based on a template.\n */\nexport interface ExtractedParameter {\n\t/**\n\t * The extracted parameter value.\n\t */\n\tvalue: string;\n\n\t/**\n\t * The mask name (e.g., \"*\") that matched this parameter.\n\t */\n\tmaskName: string;\n}\n"],"names":[],"mappings":"AAAA;;CAEC,GA2DD;;CAEC,GACD,WAUC"}
@@ -0,0 +1,10 @@
1
+ import Emittery from "emittery";
2
+ export function createEmitter(name) {
3
+ return new Emittery({
4
+ debug: {
5
+ name
6
+ }
7
+ });
8
+ }
9
+
10
+ //# sourceMappingURL=emitter.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/emittery/emitter.ts"],"sourcesContent":["import Emittery, { type EventName } from 'emittery';\n\nexport function createEmitter<EventData = Record<EventName, any>>(name: string) {\n\treturn new Emittery<EventData>({\n\t\tdebug: {\n\t\t\tname,\n\t\t},\n\t});\n}\n"],"names":["Emittery","createEmitter","name","debug"],"mappings":"AAAA,OAAOA,cAAkC,WAAW;AAEpD,OAAO,SAASC,cAAkDC,IAAY;IAC7E,OAAO,IAAIF,SAAoB;QAC9BG,OAAO;YACND;QACD;IACD;AACD"}
@@ -0,0 +1,2 @@
1
+ export { createEmitter } from "./emitter.js";
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/emittery/index.ts"],"sourcesContent":["export { createEmitter } from './emitter';\n"],"names":["createEmitter"],"mappings":"AAAA,SAASA,aAAa,QAAQ,YAAY"}
@@ -1,14 +1,16 @@
1
- import { z } from 'zod/v4';
1
+ import { z } from "zod/v4";
2
2
  // Sex 指的是生理性别/生物性别,通常由出生时的生物特征决定
3
- export var SexType = Object.freeze({
3
+ export const SexType = Object.freeze({
4
4
  __proto__: null,
5
5
  Male: 'Male',
6
6
  Female: 'Female'
7
7
  });
8
- export var SexTypeSchema = z.union([
8
+ export const SexTypeSchema = z.union([
9
9
  //
10
10
  z.literal(SexType.Male).describe('男'),
11
11
  z.literal(SexType.Female).describe('女')
12
12
  ]).describe('性别').meta({
13
13
  title: 'SexType'
14
14
  });
15
+
16
+ //# sourceMappingURL=SexType.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/foundation/schema/SexType.ts"],"sourcesContent":["import { z } from 'zod/v4';\nimport type { EnumValues } from '../../resource/schema';\n\n// Sex 指的是生理性别/生物性别,通常由出生时的生物特征决定\nexport const SexType = Object.freeze({\n\t__proto__: null,\n\tMale: 'Male',\n\tFemale: 'Female',\n});\nexport type SexType = EnumValues<typeof SexType>;\n\nexport const SexTypeSchema = z\n\t.union([\n\t\t//\n\t\tz.literal(SexType.Male).describe('男'),\n\t\tz.literal(SexType.Female).describe('女'),\n\t])\n\t.describe('性别')\n\t.meta({\n\t\ttitle: 'SexType',\n\t});\n"],"names":["z","SexType","Object","freeze","__proto__","Male","Female","SexTypeSchema","union","literal","describe","meta","title"],"mappings":"AAAA,SAASA,CAAC,QAAQ,SAAS;AAG3B,iCAAiC;AACjC,OAAO,MAAMC,UAAUC,OAAOC,MAAM,CAAC;IACpCC,WAAW;IACXC,MAAM;IACNC,QAAQ;AACT,GAAG;AAGH,OAAO,MAAMC,gBAAgBP,EAC3BQ,KAAK,CAAC;IACN,EAAE;IACFR,EAAES,OAAO,CAACR,QAAQI,IAAI,EAAEK,QAAQ,CAAC;IACjCV,EAAES,OAAO,CAACR,QAAQK,MAAM,EAAEI,QAAQ,CAAC;CACnC,EACAA,QAAQ,CAAC,MACTC,IAAI,CAAC;IACLC,OAAO;AACR,GAAG"}
@@ -1 +1,2 @@
1
1
  export { SexType, SexTypeSchema } from "./SexType.js";
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/foundation/schema/index.ts"],"sourcesContent":["export { SexType, SexTypeSchema } from './SexType';\n"],"names":["SexType","SexTypeSchema"],"mappings":"AAAA,SAASA,OAAO,EAAEC,aAAa,QAAQ,YAAY"}
@@ -16,3 +16,4 @@ export function parseSexType(s) {
16
16
  }
17
17
  return undefined;
18
18
  }
19
+ //# sourceMappingURL=parseSexType.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/foundation/schema/parseSexType.ts"],"sourcesContent":["import { SexType } from './SexType';\n\nexport function parseSexType(s: string | null | undefined): undefined | SexType {\n\tif (!s) return undefined;\n\n\tswitch (s.toLowerCase()) {\n\t\tcase '♂':\n\t\tcase '男':\n\t\tcase 'male':\n\t\tcase 'man':\n\t\t\treturn SexType.Male;\n\t\tcase '♀':\n\t\tcase '女':\n\t\tcase 'female':\n\t\tcase 'woman':\n\t\t\treturn SexType.Female;\n\t}\n\treturn undefined;\n}\n"],"names":["SexType","parseSexType","s","undefined","toLowerCase","Male","Female"],"mappings":"AAAA,SAASA,OAAO,QAAQ,YAAY;AAEpC,OAAO,SAASC,aAAaC,CAA4B;IACxD,IAAI,CAACA,GAAG,OAAOC;IAEf,OAAQD,EAAEE,WAAW;QACpB,KAAK;QACL,KAAK;QACL,KAAK;QACL,KAAK;YACJ,OAAOJ,QAAQK,IAAI;QACpB,KAAK;QACL,KAAK;QACL,KAAK;QACL,KAAK;YACJ,OAAOL,QAAQM,MAAM;IACvB;IACA,OAAOH;AACR"}
@@ -1,5 +1,7 @@
1
- import z from 'zod/v4';
2
- export var CoordinatesSchema = z.object({
1
+ import z from "zod/v4";
2
+ export const CoordinatesSchema = z.object({
3
3
  latitude: z.number().min(-90).max(90).describe('纬度'),
4
4
  longitude: z.number().min(-180).max(180).describe('经度')
5
5
  }).describe('坐标信息');
6
+
7
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/foundation/schema/types.ts"],"sourcesContent":["import z from 'zod/v4';\n\nexport const CoordinatesSchema = z\n\t.object({\n\t\tlatitude: z.number().min(-90).max(90).describe('纬度'),\n\t\tlongitude: z.number().min(-180).max(180).describe('经度'),\n\t})\n\t.describe('坐标信息');\n"],"names":["z","CoordinatesSchema","object","latitude","number","min","max","describe","longitude"],"mappings":"AAAA,OAAOA,OAAO,SAAS;AAEvB,OAAO,MAAMC,oBAAoBD,EAC/BE,MAAM,CAAC;IACPC,UAAUH,EAAEI,MAAM,GAAGC,GAAG,CAAC,CAAC,IAAIC,GAAG,CAAC,IAAIC,QAAQ,CAAC;IAC/CC,WAAWR,EAAEI,MAAM,GAAGC,GAAG,CAAC,CAAC,KAAKC,GAAG,CAAC,KAAKC,QAAQ,CAAC;AACnD,GACCA,QAAQ,CAAC,QAAQ"}
@@ -0,0 +1,23 @@
1
+ export const FileSystemErrorCode = {
2
+ ENOENT: 'ENOENT',
3
+ ENOTDIR: 'ENOTDIR',
4
+ EEXIST: 'EEXIST',
5
+ EISDIR: 'EISDIR',
6
+ ENOTEMPTY: 'ENOTEMPTY',
7
+ EACCES: 'EACCES',
8
+ EPERM: 'EPERM',
9
+ EINVAL: 'EINVAL'
10
+ };
11
+ export class FileSystemError extends Error {
12
+ code;
13
+ constructor(message, code){
14
+ super(message), this.code = code;
15
+ this.name = 'FileSystemError';
16
+ // Maintains proper stack trace for where our error was thrown (only available on V8)
17
+ if (Error.captureStackTrace) {
18
+ Error.captureStackTrace(this, FileSystemError);
19
+ }
20
+ }
21
+ }
22
+
23
+ //# sourceMappingURL=FileSystemError.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/fs/FileSystemError.ts"],"sourcesContent":["export const FileSystemErrorCode = {\n\tENOENT: 'ENOENT',\n\tENOTDIR: 'ENOTDIR',\n\tEEXIST: 'EEXIST',\n\tEISDIR: 'EISDIR',\n\tENOTEMPTY: 'ENOTEMPTY',\n\tEACCES: 'EACCES',\n\tEPERM: 'EPERM',\n\tEINVAL: 'EINVAL',\n} as const;\n\nexport type FileSystemErrorCode = (typeof FileSystemErrorCode)[keyof typeof FileSystemErrorCode];\n\nexport class FileSystemError extends Error {\n\tconstructor(\n\t\tmessage: string,\n\t\tpublic readonly code: FileSystemErrorCode | string,\n\t) {\n\t\tsuper(message);\n\t\tthis.name = 'FileSystemError';\n\t\t// Maintains proper stack trace for where our error was thrown (only available on V8)\n\t\tif (Error.captureStackTrace) {\n\t\t\tError.captureStackTrace(this, FileSystemError);\n\t\t}\n\t}\n}\n"],"names":["FileSystemErrorCode","ENOENT","ENOTDIR","EEXIST","EISDIR","ENOTEMPTY","EACCES","EPERM","EINVAL","FileSystemError","Error","message","code","name","captureStackTrace"],"mappings":"AAAA,OAAO,MAAMA,sBAAsB;IAClCC,QAAQ;IACRC,SAAS;IACTC,QAAQ;IACRC,QAAQ;IACRC,WAAW;IACXC,QAAQ;IACRC,OAAO;IACPC,QAAQ;AACT,EAAW;AAIX,OAAO,MAAMC,wBAAwBC;;IACpC,YACCC,OAAe,EACf,AAAgBC,IAAkC,CACjD;QACD,KAAK,CAACD,eAFUC,OAAAA;QAGhB,IAAI,CAACC,IAAI,GAAG;QACZ,qFAAqF;QACrF,IAAIH,MAAMI,iBAAiB,EAAE;YAC5BJ,MAAMI,iBAAiB,CAAC,IAAI,EAAEL;QAC/B;IACD;AACD"}
@@ -0,0 +1,3 @@
1
+ export { };
2
+
3
+ //# sourceMappingURL=IFileSystem.d.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/fs/IFileSystem.d.ts"],"sourcesContent":["import type { FileKind, FileUrlOptions } from './types';\n\n// Base operation options\ntype OperationOptions = {\n\tsignal?: AbortSignal;\n};\n\n// Directory operations\nexport type ReaddirOptions = OperationOptions & {\n\tglob?: string;\n\trecursive?: boolean;\n\tdepth?: number;\n\tkind?: FileKind;\n\thidden?: boolean;\n};\nexport type MkdirOptions = OperationOptions & {\n\trecursive?: boolean;\n};\n// File operations\nexport type ReadFileOptions = OperationOptions & {\n\tencoding?: 'text' | 'binary';\n\tonDownloadProgress?: (e: { loaded: number; total: number }) => void;\n};\nexport type WriteFileOptions = OperationOptions & {\n\toverwrite?: boolean;\n\tonUploadProgress?: (e: { loaded: number; total: number }) => void;\n};\nexport type RenameOptions = OperationOptions & {\n\toverwrite?: boolean;\n};\nexport type RmOptions = OperationOptions & {\n\trecursive?: boolean;\n\tforce?: boolean;\n};\nexport type CopyOptions = OperationOptions & {\n\toverwrite?: boolean;\n\tshallow?: boolean;\n};\nexport type CreateReadStreamOptions = OperationOptions & {\n\trange?: { start: number; end?: number };\n\tsignal?: AbortSignal;\n};\nexport type CreateWriteStreamOptions = OperationOptions & {\n\toverwrite?: boolean;\n};\nexport type StatOptions = OperationOptions & {};\n\ntype WritableData = string | ArrayBuffer | ArrayBufferView<ArrayBufferLike> | ReadableStream;\n\n/**\n * Universal file system interface (browser & server compatible)\n */\nexport type IFileSystem = {\n\treaddir(dir: string, options?: ReaddirOptions): Promise<IFileStat[]>;\n\tstat(entry: string, options?: StatOptions): Promise<IFileStat>;\n\tmkdir(path: string, options?: MkdirOptions): Promise<void>;\n\treadFile(path: string, options?: ReadFileOptions & { encoding: 'text' }): Promise<string>;\n\treadFile(path: string, options?: ReadFileOptions): Promise<Uint8Array>;\n\twriteFile(path: string, data: WritableData, options?: WriteFileOptions): Promise<void>;\n\trm(path: string, options?: RmOptions): Promise<void>;\n\trename(oldPath: string, newPath: string, options?: RenameOptions): Promise<void>;\n\texists(path: string): Promise<boolean>;\n\tcopy(src: string, dest: string, options?: CopyOptions): Promise<void>;\n\n\tgetUrl?(path: IFileStat | string, options?: FileUrlOptions): string | undefined;\n\n\tcreateReadableStream?(path: string, options?: CreateReadStreamOptions): ReadableStream;\n\tcreateWritableStream?(path: string, options?: CreateWriteStreamOptions): WritableStream;\n};\n\n/**\n * Server/Node.js specific file system interface with stream support\n */\nexport type IServerFileSystem = IFileSystem & {\n\tcreateReadStream(path: string, options?: CreateReadStreamOptions): import('node:stream').Readable;\n\tcreateWriteStream(path: string, options?: CreateWriteStreamOptions): import('node:stream').Writable;\n\twriteFile(\n\t\tpath: string,\n\t\tdata: WritableData | Buffer | import('node:stream').Readable,\n\t\toptions?: WriteFileOptions,\n\t): Promise<void>;\n};\n\nexport type IFileStat = {\n\t/**\n\t * parent path\n\t */\n\tdirectory: string;\n\t/**\n\t * full path\n\t */\n\tpath: string;\n\t/**\n\t * basename\n\t */\n\tname: string;\n\tkind: 'directory' | 'file';\n\tmtime: number;\n\tmeta: Record<string, any>;\n\tsize: number;\n};\n"],"names":[],"mappings":"AAmFA,WAiBE"}