@wener/common 2.0.2 → 2.0.3

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 (351) 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 +21 -14
  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 +65 -145
  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 +5 -7
  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 +158 -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/emittery/emitter.js +10 -0
  86. package/lib/emittery/emitter.js.map +1 -0
  87. package/lib/emittery/index.js +2 -0
  88. package/lib/emittery/index.js.map +1 -0
  89. package/lib/foundation/schema/SexType.js +5 -3
  90. package/lib/foundation/schema/SexType.js.map +1 -0
  91. package/lib/foundation/schema/index.js +1 -0
  92. package/lib/foundation/schema/index.js.map +1 -0
  93. package/lib/foundation/schema/parseSexType.js +1 -0
  94. package/lib/foundation/schema/parseSexType.js.map +1 -0
  95. package/lib/foundation/schema/types.js +4 -2
  96. package/lib/foundation/schema/types.js.map +1 -0
  97. package/lib/fs/FileSystemError.js +23 -0
  98. package/lib/fs/FileSystemError.js.map +1 -0
  99. package/lib/fs/IFileSystem.d.js +3 -0
  100. package/lib/fs/IFileSystem.d.js.map +1 -0
  101. package/lib/fs/MemoryFileSystem.test.js +188 -0
  102. package/lib/fs/createBrowserFileSystem.js +248 -0
  103. package/lib/fs/createBrowserFileSystem.js.map +1 -0
  104. package/lib/fs/createMemoryFileSystem.js +516 -0
  105. package/lib/fs/createMemoryFileSystem.js.map +1 -0
  106. package/lib/fs/createSandboxFileSystem.js +108 -0
  107. package/lib/fs/createSandboxFileSystem.js.map +1 -0
  108. package/lib/fs/createWebDavFileSystem.js +137 -0
  109. package/lib/fs/createWebDavFileSystem.js.map +1 -0
  110. package/lib/fs/findMimeType.js +17 -0
  111. package/lib/fs/findMimeType.js.map +1 -0
  112. package/lib/fs/index.js +8 -0
  113. package/lib/fs/index.js.map +1 -0
  114. package/lib/fs/orpc/FileSystemContract.js +93 -0
  115. package/lib/fs/orpc/FileSystemContract.js.map +1 -0
  116. package/lib/fs/orpc/createContractClientFileSystem.js +93 -0
  117. package/lib/fs/orpc/createContractClientFileSystem.js.map +1 -0
  118. package/lib/fs/orpc/index.js +3 -0
  119. package/lib/fs/orpc/index.js.map +1 -0
  120. package/lib/fs/orpc/server/createFileSystemContractImpl.js +63 -0
  121. package/lib/fs/orpc/server/createFileSystemContractImpl.js.map +1 -0
  122. package/lib/fs/orpc/server/index.js +2 -0
  123. package/lib/fs/orpc/server/index.js.map +1 -0
  124. package/lib/fs/s3/createS3MiniFileSystem.js +705 -0
  125. package/lib/fs/s3/createS3MiniFileSystem.js.map +1 -0
  126. package/lib/fs/s3/index.js +2 -0
  127. package/lib/fs/s3/index.js.map +1 -0
  128. package/lib/fs/s3/s3mini.test.js +584 -0
  129. package/lib/fs/scandir.js +59 -0
  130. package/lib/fs/scandir.js.map +1 -0
  131. package/lib/fs/server/createDatabaseFileSystem.js +750 -0
  132. package/lib/fs/server/createDatabaseFileSystem.js.map +1 -0
  133. package/lib/fs/server/createNodeFileSystem.js +401 -0
  134. package/lib/fs/server/createNodeFileSystem.js.map +1 -0
  135. package/lib/fs/server/dbfs.test.js +221 -0
  136. package/lib/fs/server/index.js +2 -0
  137. package/lib/fs/server/index.js.map +1 -0
  138. package/lib/fs/server/loadTestDatabase.js +127 -0
  139. package/lib/fs/server/loadTestDatabase.js.map +1 -0
  140. package/lib/fs/tests/runFileSystemTest.js +318 -0
  141. package/lib/fs/tests/runFileSystemTest.js.map +1 -0
  142. package/lib/fs/types.js +27 -0
  143. package/lib/fs/types.js.map +1 -0
  144. package/lib/fs/utils/getFileUrl.js +35 -0
  145. package/lib/fs/utils/getFileUrl.js.map +1 -0
  146. package/lib/fs/utils.js +22 -0
  147. package/lib/fs/utils.js.map +1 -0
  148. package/lib/index.js +1 -0
  149. package/lib/index.js.map +1 -0
  150. package/lib/jsonschema/JsonSchema.js +146 -172
  151. package/lib/jsonschema/JsonSchema.js.map +1 -0
  152. package/lib/jsonschema/forEachJsonSchema.js +44 -0
  153. package/lib/jsonschema/forEachJsonSchema.js.map +1 -0
  154. package/lib/jsonschema/index.js +2 -0
  155. package/lib/jsonschema/index.js.map +1 -0
  156. package/lib/jsonschema/types.d.js +2 -0
  157. package/lib/jsonschema/types.d.js.map +1 -0
  158. package/lib/meta/defineFileType.js +20 -103
  159. package/lib/meta/defineFileType.js.map +1 -0
  160. package/lib/meta/defineInit.js +31 -250
  161. package/lib/meta/defineInit.js.map +1 -0
  162. package/lib/meta/defineMetadata.js +24 -140
  163. package/lib/meta/defineMetadata.js.map +1 -0
  164. package/lib/meta/index.js +1 -0
  165. package/lib/meta/index.js.map +1 -0
  166. package/lib/orpc/createOpenApiContractClient.js +27 -0
  167. package/lib/orpc/createOpenApiContractClient.js.map +1 -0
  168. package/lib/orpc/createRpcContractClient.js +34 -0
  169. package/lib/orpc/createRpcContractClient.js.map +1 -0
  170. package/lib/orpc/index.js +3 -0
  171. package/lib/orpc/index.js.map +1 -0
  172. package/lib/orpc/resolveLinkPlugins.js +28 -0
  173. package/lib/orpc/resolveLinkPlugins.js.map +1 -0
  174. package/lib/password/PHC.js +63 -87
  175. package/lib/password/PHC.js.map +1 -0
  176. package/lib/password/PHC.test.js +11 -3
  177. package/lib/password/Password.js +29 -294
  178. package/lib/password/Password.js.map +1 -0
  179. package/lib/password/Password.test.js +35 -22
  180. package/lib/password/createArgon2PasswordAlgorithm.js +35 -191
  181. package/lib/password/createArgon2PasswordAlgorithm.js.map +1 -0
  182. package/lib/password/createBase64PasswordAlgorithm.js +8 -141
  183. package/lib/password/createBase64PasswordAlgorithm.js.map +1 -0
  184. package/lib/password/createBcryptPasswordAlgorithm.js +13 -168
  185. package/lib/password/createBcryptPasswordAlgorithm.js.map +1 -0
  186. package/lib/password/createPBKDF2PasswordAlgorithm.js +46 -228
  187. package/lib/password/createPBKDF2PasswordAlgorithm.js.map +1 -0
  188. package/lib/password/createScryptPasswordAlgorithm.js +55 -211
  189. package/lib/password/createScryptPasswordAlgorithm.js.map +1 -0
  190. package/lib/password/index.js +1 -0
  191. package/lib/password/index.js.map +1 -0
  192. package/lib/password/server/index.js +1 -0
  193. package/lib/password/server/index.js.map +1 -0
  194. package/lib/resource/Identifiable.js +2 -0
  195. package/lib/resource/Identifiable.js.map +1 -0
  196. package/lib/resource/ListQuery.js +21 -93
  197. package/lib/resource/ListQuery.js.map +1 -0
  198. package/lib/resource/getTitleOfResource.js +3 -5
  199. package/lib/resource/getTitleOfResource.js.map +1 -0
  200. package/lib/resource/index.js +1 -0
  201. package/lib/resource/index.js.map +1 -0
  202. package/lib/resource/schema/AnyResourceSchema.js +2 -1
  203. package/lib/resource/schema/AnyResourceSchema.js.map +1 -0
  204. package/lib/resource/schema/BaseResourceSchema.js +2 -1
  205. package/lib/resource/schema/BaseResourceSchema.js.map +1 -0
  206. package/lib/resource/schema/ResourceActionType.js +6 -4
  207. package/lib/resource/schema/ResourceActionType.js.map +1 -0
  208. package/lib/resource/schema/ResourceStatus.js +5 -3
  209. package/lib/resource/schema/ResourceStatus.js.map +1 -0
  210. package/lib/resource/schema/ResourceType.js +5 -3
  211. package/lib/resource/schema/ResourceType.js.map +1 -0
  212. package/lib/resource/schema/index.js +1 -0
  213. package/lib/resource/schema/index.js.map +1 -0
  214. package/lib/resource/schema/types.js +16 -20
  215. package/lib/resource/schema/types.js.map +1 -0
  216. package/lib/s3/formatS3Url.js +65 -0
  217. package/lib/s3/formatS3Url.js.map +1 -0
  218. package/lib/s3/formatS3Url.test.js +262 -0
  219. package/lib/s3/index.js +3 -0
  220. package/lib/s3/index.js.map +1 -0
  221. package/lib/s3/parseS3Url.js +65 -0
  222. package/lib/s3/parseS3Url.js.map +1 -0
  223. package/lib/s3/parseS3Url.test.js +270 -0
  224. package/lib/schema/SchemaRegistry.js +38 -38
  225. package/lib/schema/SchemaRegistry.js.map +1 -0
  226. package/lib/schema/TypeSchema.d.js +2 -0
  227. package/lib/schema/TypeSchema.d.js.map +1 -0
  228. package/lib/schema/createSchemaData.js +26 -125
  229. package/lib/schema/createSchemaData.js.map +1 -0
  230. package/lib/schema/findJsonSchemaByPath.js +13 -36
  231. package/lib/schema/findJsonSchemaByPath.js.map +1 -0
  232. package/lib/schema/formatZodError.js +140 -0
  233. package/lib/schema/formatZodError.js.map +1 -0
  234. package/lib/schema/formatZodError.test.js +196 -0
  235. package/lib/schema/getSchemaCache.js +5 -5
  236. package/lib/schema/getSchemaCache.js.map +1 -0
  237. package/lib/schema/getSchemaOptions.js +8 -11
  238. package/lib/schema/getSchemaOptions.js.map +1 -0
  239. package/lib/schema/index.js +2 -1
  240. package/lib/schema/index.js.map +1 -0
  241. package/lib/schema/toJsonSchema.js +47 -290
  242. package/lib/schema/toJsonSchema.js.map +1 -0
  243. package/lib/schema/validate.js +33 -45
  244. package/lib/schema/validate.js.map +1 -0
  245. package/lib/tools/generateSchema.js +39 -197
  246. package/lib/tools/generateSchema.js.map +1 -0
  247. package/lib/tools/renderJsonSchemaToMarkdownDoc.js +55 -143
  248. package/lib/tools/renderJsonSchemaToMarkdownDoc.js.map +1 -0
  249. package/lib/utils/buildBaseUrl.js +13 -0
  250. package/lib/utils/buildBaseUrl.js.map +1 -0
  251. package/lib/utils/buildRedactorFormSchema.js +59 -0
  252. package/lib/utils/buildRedactorFormSchema.js.map +1 -0
  253. package/lib/utils/getEstimateProcessTime.js +12 -11
  254. package/lib/utils/getEstimateProcessTime.js.map +1 -0
  255. package/lib/utils/index.js +3 -0
  256. package/lib/utils/index.js.map +1 -0
  257. package/lib/utils/resolveFeatureOptions.js +12 -0
  258. package/lib/utils/resolveFeatureOptions.js.map +1 -0
  259. package/package.json +61 -13
  260. package/src/ai/qwen3vl/index.ts +1 -0
  261. package/src/ai/qwen3vl/utils.ts +36 -0
  262. package/src/ai/vision/DocLayoutElementTypeSchema.ts +30 -0
  263. package/src/ai/vision/ImageAnnotationSchema.ts +60 -0
  264. package/src/ai/vision/index.ts +2 -0
  265. package/src/ai/vision/resolveImageAnnotation.ts +135 -0
  266. package/src/cn/ChineseResidentIdNo.test.ts +1 -1
  267. package/src/cn/ChineseResidentIdNo.ts +8 -0
  268. package/src/cn/DivisionCode.test.ts +1 -1
  269. package/src/cn/DivisionCode.ts +8 -0
  270. package/src/cn/UnifiedSocialCreditCode.test.ts +1 -1
  271. package/src/cn/UnifiedSocialCreditCode.ts +15 -0
  272. package/src/cn/__snapshots__/UnifiedSocialCreditCode.test.ts.snap +23 -0
  273. package/src/cn/formatChineseAmount.ts +61 -0
  274. package/src/cn/index.ts +7 -1
  275. package/src/cn/parseChineseNumber.test.ts +159 -0
  276. package/src/cn/parseChineseNumber.ts +97 -0
  277. package/src/cn/pinyin/cartesianProduct.test.ts +64 -0
  278. package/src/cn/pinyin/cartesianProduct.ts +24 -0
  279. package/src/cn/pinyin/data.json +23573 -0
  280. package/src/cn/pinyin/loader.ts +12 -0
  281. package/src/cn/pinyin/preload.ts +3 -0
  282. package/src/cn/pinyin/toPinyin.test.ts +12 -0
  283. package/src/cn/pinyin/toPinyinPure.ts +43 -0
  284. package/src/cn/pinyin/transform.ts +12 -0
  285. package/src/consola/formatLogObject.test.ts +27 -0
  286. package/src/consola/formatLogObject.ts +34 -6
  287. package/src/dayjs/dayjs.ts +18 -18
  288. package/src/dayjs/index.ts +3 -1
  289. package/src/dayjs/parseRelativeTime.test.ts +185 -0
  290. package/src/dayjs/parseRelativeTime.ts +115 -0
  291. package/src/dayjs/resolveRelativeTime.test.ts +357 -0
  292. package/src/dayjs/resolveRelativeTime.ts +167 -0
  293. package/src/emittery/emitter.ts +9 -0
  294. package/src/emittery/index.ts +1 -0
  295. package/src/fs/FileSystemError.ts +26 -0
  296. package/src/fs/IFileSystem.d.ts +102 -0
  297. package/src/fs/MemoryFileSystem.test.ts +37 -0
  298. package/src/fs/createBrowserFileSystem.ts +291 -0
  299. package/src/fs/createMemoryFileSystem.ts +604 -0
  300. package/src/fs/createSandboxFileSystem.ts +136 -0
  301. package/src/fs/createWebDavFileSystem.ts +172 -0
  302. package/src/fs/findMimeType.ts +23 -0
  303. package/src/fs/index.ts +8 -0
  304. package/src/fs/orpc/FileSystemContract.ts +92 -0
  305. package/src/fs/orpc/createContractClientFileSystem.ts +115 -0
  306. package/src/fs/orpc/index.ts +2 -0
  307. package/src/fs/orpc/server/createFileSystemContractImpl.ts +64 -0
  308. package/src/fs/orpc/server/index.ts +1 -0
  309. package/src/fs/s3/createS3MiniFileSystem.ts +830 -0
  310. package/src/fs/s3/index.ts +1 -0
  311. package/src/fs/s3/s3mini.test.ts +264 -0
  312. package/src/fs/scandir.ts +75 -0
  313. package/src/fs/server/createDatabaseFileSystem.ts +668 -0
  314. package/src/fs/server/createNodeFileSystem.ts +499 -0
  315. package/src/fs/server/dbfs.test.ts +47 -0
  316. package/src/fs/server/index.ts +1 -0
  317. package/src/fs/server/loadTestDatabase.ts +131 -0
  318. package/src/fs/tests/runFileSystemTest.ts +288 -0
  319. package/src/fs/types.ts +29 -0
  320. package/src/fs/utils/getFileUrl.ts +44 -0
  321. package/src/fs/utils.ts +23 -0
  322. package/src/jsonschema/JsonSchema.ts +118 -110
  323. package/src/jsonschema/forEachJsonSchema.ts +50 -0
  324. package/src/jsonschema/index.ts +1 -0
  325. package/src/orpc/createOpenApiContractClient.ts +52 -0
  326. package/src/orpc/createRpcContractClient.ts +50 -0
  327. package/src/orpc/index.ts +2 -0
  328. package/src/orpc/resolveLinkPlugins.ts +29 -0
  329. package/src/password/PHC.ts +3 -3
  330. package/src/password/Password.test.ts +1 -1
  331. package/src/password/createPBKDF2PasswordAlgorithm.ts +2 -2
  332. package/src/resource/schema/AnyResourceSchema.ts +16 -2
  333. package/src/s3/formatS3Url.test.ts +254 -0
  334. package/src/s3/formatS3Url.ts +84 -0
  335. package/src/s3/index.ts +2 -0
  336. package/src/s3/parseS3Url.test.ts +258 -0
  337. package/src/s3/parseS3Url.ts +88 -0
  338. package/src/schema/SchemaRegistry.ts +35 -33
  339. package/src/schema/formatZodError.test.ts +196 -0
  340. package/src/schema/formatZodError.ts +151 -0
  341. package/src/schema/getSchemaOptions.ts +2 -2
  342. package/src/schema/index.ts +1 -1
  343. package/src/utils/buildBaseUrl.ts +12 -0
  344. package/src/utils/buildRedactorFormSchema.ts +85 -0
  345. package/src/utils/index.ts +4 -0
  346. package/src/utils/resolveFeatureOptions.ts +14 -0
  347. package/src/cn/ChineseResidentIdNo.mod.ts +0 -7
  348. package/src/cn/DivisionCode.mod.ts +0 -7
  349. package/src/cn/UnifiedSocialCreditCode.mod.ts +0 -7
  350. package/src/cn/mod.ts +0 -3
  351. package/src/schema/SchemaRegistry.mod.ts +0 -1
@@ -0,0 +1,108 @@
1
+ import { join, normalize, relative, sep } from "pathe";
2
+ import { getPath } from "./utils";
3
+ let SandboxSecurityError = class SandboxSecurityError extends Error {
4
+ constructor(message){
5
+ super(message);
6
+ this.name = 'SandboxSecurityError';
7
+ }
8
+ };
9
+ export function createSandboxFileSystem(fs, basePath) {
10
+ return new SandboxFS(fs, basePath);
11
+ }
12
+ let SandboxFS = class SandboxFS {
13
+ fs;
14
+ basePath;
15
+ constructor(fs, basePath){
16
+ this.fs = fs;
17
+ this.basePath = normalize(basePath);
18
+ }
19
+ _resolvePath(userPath) {
20
+ const fullPath = join(this.basePath, userPath);
21
+ const normalizedFullPath = normalize(fullPath);
22
+ const rel = relative(this.basePath, normalizedFullPath);
23
+ if (rel.startsWith('..') || rel === '..') {
24
+ throw new SandboxSecurityError(`Path traversal attempt detected: ${userPath}`);
25
+ }
26
+ return normalizedFullPath;
27
+ }
28
+ _stripPath(fullPath) {
29
+ const relPath = relative(this.basePath, fullPath);
30
+ // 保证返回的是一个以 '/' 开头的绝对路径(在沙箱内)
31
+ return sep + relPath.split(sep).join('/');
32
+ }
33
+ _processStat(stat) {
34
+ stat.path = this._stripPath(stat.path);
35
+ stat.directory = this._stripPath(stat.directory);
36
+ return stat;
37
+ }
38
+ async stat(path, options) {
39
+ const fullPath = this._resolvePath(path);
40
+ const result = await this.fs.stat(fullPath, options);
41
+ return this._processStat(result);
42
+ }
43
+ async readdir(dir, options) {
44
+ const fullPath = this._resolvePath(dir);
45
+ const results = await this.fs.readdir(fullPath, options);
46
+ return results.map((stat)=>this._processStat(stat));
47
+ }
48
+ async exists(path) {
49
+ try {
50
+ const fullPath = this._resolvePath(path);
51
+ return await this.fs.exists(fullPath);
52
+ } catch (e) {
53
+ if (e instanceof SandboxSecurityError) {
54
+ return false; // 越界访问视为不存在
55
+ }
56
+ throw e;
57
+ }
58
+ }
59
+ mkdir(path, options) {
60
+ const fullPath = this._resolvePath(path);
61
+ return this.fs.mkdir(fullPath, options);
62
+ }
63
+ readFile(path, options) {
64
+ const fullPath = this._resolvePath(path);
65
+ return this.fs.readFile(fullPath, options);
66
+ }
67
+ writeFile(path, data, options) {
68
+ const fullPath = this._resolvePath(path);
69
+ return this.fs.writeFile(fullPath, data, options);
70
+ }
71
+ rm(path, options) {
72
+ const fullPath = this._resolvePath(path);
73
+ return this.fs.rm(fullPath, options);
74
+ }
75
+ rename(oldPath, newPath, options) {
76
+ const fullOldPath = this._resolvePath(oldPath);
77
+ const fullNewPath = this._resolvePath(newPath);
78
+ return this.fs.rename(fullOldPath, fullNewPath, options);
79
+ }
80
+ copy(src, dest, options) {
81
+ const fullSrc = this._resolvePath(src);
82
+ const fullDest = this._resolvePath(dest);
83
+ return this.fs.copy(fullSrc, fullDest, options);
84
+ }
85
+ createReadStream(path, options) {
86
+ const fullPath = this._resolvePath(path);
87
+ if (!this.fs.createReadStream) {
88
+ throw new Error('Underlying filesystem does not support createReadStream');
89
+ }
90
+ return this.fs.createReadStream(fullPath, options);
91
+ }
92
+ createWriteStream(path, options) {
93
+ const fullPath = this._resolvePath(path);
94
+ if (!this.fs.createWriteStream) {
95
+ throw new Error('Underlying filesystem does not support createWriteStream');
96
+ }
97
+ return this.fs.createWriteStream(fullPath, options);
98
+ }
99
+ getUrl(file, options) {
100
+ let path = this._resolvePath(getPath(file.path));
101
+ if (this.fs.getUrl) {
102
+ return this.fs.getUrl(path, options);
103
+ }
104
+ return;
105
+ }
106
+ };
107
+
108
+ //# sourceMappingURL=createSandboxFileSystem.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/fs/createSandboxFileSystem.ts"],"sourcesContent":["import { join, normalize, relative, sep } from 'pathe';\nimport type { IFileStat, IFileSystem, IServerFileSystem, ReadFileOptions } from './IFileSystem';\nimport { getPath } from './utils';\n\nclass SandboxSecurityError extends Error {\n\tconstructor(message: string) {\n\t\tsuper(message);\n\t\tthis.name = 'SandboxSecurityError';\n\t}\n}\n\nexport function createSandboxFileSystem(\n\tfs: IServerFileSystem,\n\tbasePath: string,\n): IServerFileSystem & {\n\tfs: IServerFileSystem;\n\tbasePath: string;\n} {\n\treturn new SandboxFS(fs, basePath);\n}\n\nclass SandboxFS implements IServerFileSystem {\n\tfs: IServerFileSystem;\n\tbasePath: string;\n\n\tconstructor(fs: IServerFileSystem, basePath: string) {\n\t\tthis.fs = fs;\n\t\tthis.basePath = normalize(basePath);\n\t}\n\n\tprivate _resolvePath(userPath: string): string {\n\t\tconst fullPath = join(this.basePath, userPath);\n\n\t\tconst normalizedFullPath = normalize(fullPath);\n\n\t\tconst rel = relative(this.basePath, normalizedFullPath);\n\t\tif (rel.startsWith('..') || rel === '..') {\n\t\t\tthrow new SandboxSecurityError(`Path traversal attempt detected: ${userPath}`);\n\t\t}\n\t\treturn normalizedFullPath;\n\t}\n\n\tprivate _stripPath(fullPath: string): string {\n\t\tconst relPath = relative(this.basePath, fullPath);\n\t\t// 保证返回的是一个以 '/' 开头的绝对路径(在沙箱内)\n\t\treturn sep + relPath.split(sep).join('/');\n\t}\n\n\tprivate _processStat(stat: IFileStat): IFileStat {\n\t\tstat.path = this._stripPath(stat.path);\n\t\tstat.directory = this._stripPath(stat.directory);\n\t\treturn stat;\n\t}\n\n\tasync stat(path: string, options?: any): Promise<IFileStat> {\n\t\tconst fullPath = this._resolvePath(path);\n\t\tconst result = await this.fs.stat(fullPath, options);\n\t\treturn this._processStat(result);\n\t}\n\n\tasync readdir(dir: string, options?: any): Promise<IFileStat[]> {\n\t\tconst fullPath = this._resolvePath(dir);\n\t\tconst results = await this.fs.readdir(fullPath, options);\n\t\treturn results.map((stat) => this._processStat(stat));\n\t}\n\n\tasync exists(path: string): Promise<boolean> {\n\t\ttry {\n\t\t\tconst fullPath = this._resolvePath(path);\n\t\t\treturn await this.fs.exists(fullPath);\n\t\t} catch (e) {\n\t\t\tif (e instanceof SandboxSecurityError) {\n\t\t\t\treturn false; // 越界访问视为不存在\n\t\t\t}\n\t\t\tthrow e;\n\t\t}\n\t}\n\n\tmkdir(path: string, options?: any): Promise<void> {\n\t\tconst fullPath = this._resolvePath(path);\n\t\treturn this.fs.mkdir(fullPath, options);\n\t}\n\n\treadFile(path: string, options?: ReadFileOptions & { encoding: 'text' }): Promise<string>;\n\treadFile(path: string, options?: ReadFileOptions): Promise<Uint8Array>;\n\treadFile(path: string, options?: ReadFileOptions): Promise<string | Uint8Array> {\n\t\tconst fullPath = this._resolvePath(path);\n\t\treturn this.fs.readFile(fullPath, options);\n\t}\n\n\twriteFile(path: string, data: any, options?: any): Promise<void> {\n\t\tconst fullPath = this._resolvePath(path);\n\t\treturn this.fs.writeFile(fullPath, data, options);\n\t}\n\n\trm(path: string, options?: any): Promise<void> {\n\t\tconst fullPath = this._resolvePath(path);\n\t\treturn this.fs.rm(fullPath, options);\n\t}\n\n\trename(oldPath: string, newPath: string, options?: any): Promise<void> {\n\t\tconst fullOldPath = this._resolvePath(oldPath);\n\t\tconst fullNewPath = this._resolvePath(newPath);\n\t\treturn this.fs.rename(fullOldPath, fullNewPath, options);\n\t}\n\n\tcopy(src: string, dest: string, options?: any): Promise<void> {\n\t\tconst fullSrc = this._resolvePath(src);\n\t\tconst fullDest = this._resolvePath(dest);\n\t\treturn this.fs.copy(fullSrc, fullDest, options);\n\t}\n\n\tcreateReadStream(path: string, options?: any): any {\n\t\tconst fullPath = this._resolvePath(path);\n\t\tif (!this.fs.createReadStream) {\n\t\t\tthrow new Error('Underlying filesystem does not support createReadStream');\n\t\t}\n\t\treturn this.fs.createReadStream(fullPath, options);\n\t}\n\n\tcreateWriteStream(path: string, options?: any): any {\n\t\tconst fullPath = this._resolvePath(path);\n\t\tif (!this.fs.createWriteStream) {\n\t\t\tthrow new Error('Underlying filesystem does not support createWriteStream');\n\t\t}\n\t\treturn this.fs.createWriteStream(fullPath, options);\n\t}\n\n\tgetUrl(file: IFileStat, options?: any): string | undefined {\n\t\tlet path = this._resolvePath(getPath(file.path));\n\t\tif (this.fs.getUrl) {\n\t\t\treturn this.fs.getUrl(path, options);\n\t\t}\n\t\treturn;\n\t}\n}\n"],"names":["join","normalize","relative","sep","getPath","SandboxSecurityError","Error","message","name","createSandboxFileSystem","fs","basePath","SandboxFS","_resolvePath","userPath","fullPath","normalizedFullPath","rel","startsWith","_stripPath","relPath","split","_processStat","stat","path","directory","options","result","readdir","dir","results","map","exists","e","mkdir","readFile","writeFile","data","rm","rename","oldPath","newPath","fullOldPath","fullNewPath","copy","src","dest","fullSrc","fullDest","createReadStream","createWriteStream","getUrl","file"],"mappings":"AAAA,SAASA,IAAI,EAAEC,SAAS,EAAEC,QAAQ,EAAEC,GAAG,QAAQ,QAAQ;AAEvD,SAASC,OAAO,QAAQ,UAAU;AAElC,IAAA,AAAMC,uBAAN,MAAMA,6BAA6BC;IAClC,YAAYC,OAAe,CAAE;QAC5B,KAAK,CAACA;QACN,IAAI,CAACC,IAAI,GAAG;IACb;AACD;AAEA,OAAO,SAASC,wBACfC,EAAqB,EACrBC,QAAgB;IAKhB,OAAO,IAAIC,UAAUF,IAAIC;AAC1B;AAEA,IAAA,AAAMC,YAAN,MAAMA;IACLF,GAAsB;IAC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ACiC;QACnC,OAAO,IAAI,CAACpC,EAAE,CAACkC,IAAI,CAACG,SAASC,UAAUtB;IACxC;IAEAuB,iBAAiBzB,IAAY,EAAEE,OAAa,EAAO;QAClD,MAAMX,WAAW,IAAI,CAACF,YAAY,CAACW;QACnC,IAAI,CAAC,IAAI,CAACd,EAAE,CAACuC,gBAAgB,EAAE;YAC9B,MAAM,IAAI3C,MAAM;QACjB;QACA,OAAO,IAAI,CAACI,EAAE,CAACuC,gBAAgB,CAAClC,UAAUW;IAC3C;IAEAwB,kBAAkB1B,IAAY,EAAEE,OAAa,EAAO;QACnD,MAAMX,WAAW,IAAI,CAACF,YAAY,CAACW;QACnC,IAAI,CAAC,IAAI,CAACd,EAAE,CAACwC,iBAAiB,EAAE;YAC/B,MAAM,IAAI5C,MAAM;QACjB;QACA,OAAO,IAAI,CAACI,EAAE,CAACwC,iBAAiB,CAACnC,UAAUW;IAC5C;IAEAyB,OAAOC,IAAe,EAAE1B,OAAa,EAAsB;QAC1D,IAAIF,OAAO,IAAI,CAACX,YAAY,CAACT,QAAQgD,KAAK5B,IAAI;QAC9C,IAAI,IAAI,CAACd,EAAE,CAACyC,MAAM,EAAE;YACnB,OAAO,IAAI,CAACzC,EAAE,CAACyC,MAAM,CAAC3B,MAAME;QAC7B;QACA;IACD;AACD"}
@@ -0,0 +1,137 @@
1
+ import { maybeFunction } from "@wener/utils";
2
+ export function createWebDavFileSystem({ client }) {
3
+ let fs = new WebdavFS({
4
+ client
5
+ });
6
+ return fs;
7
+ }
8
+ let WebdavFS = class WebdavFS {
9
+ _client;
10
+ constructor({ client = ()=>{
11
+ throw new Error('WebdavFS client not initialized');
12
+ } }){
13
+ this._client = client;
14
+ }
15
+ set client(client) {
16
+ this._client = client;
17
+ }
18
+ get client() {
19
+ return maybeFunction(this._client);
20
+ }
21
+ toEntry(input) {
22
+ const { filename: path, basename, lastmod, type: kind, etag, size, mime } = input;
23
+ let meta = {};
24
+ if (etag) {
25
+ meta['etag'] = etag;
26
+ }
27
+ if (mime) {
28
+ meta['mime'] = mime;
29
+ }
30
+ return {
31
+ directory: path.substring(0, path.lastIndexOf('/')) || '/',
32
+ path,
33
+ name: basename,
34
+ mtime: +new Date(lastmod),
35
+ kind,
36
+ meta,
37
+ size
38
+ };
39
+ }
40
+ getData(input) {
41
+ if (input && typeof input === 'object' && 'data' in input && 'status' in input && typeof input.status === 'number') {
42
+ return input.data;
43
+ }
44
+ return input;
45
+ }
46
+ async readdir(path, { glob, recursive, depth, kind, hidden, signal } = {}) {
47
+ // webdav depth 只支持 0,1
48
+ let o = {};
49
+ if (recursive) {
50
+ o.deep = true;
51
+ }
52
+ let res = await this.client.getDirectoryContents(path, {
53
+ deep: recursive,
54
+ signal
55
+ });
56
+ let out = this.getData(res);
57
+ if (!recursive && typeof depth === 'number' && depth >= 2) {
58
+ let l = depth;
59
+ let cur = out;
60
+ while(l-- > 1){
61
+ let sub = (await Promise.all(cur.map(async (v)=>{
62
+ if (v.type === 'directory') {
63
+ return this.getData(await this.client.getDirectoryContents(v.filename, {
64
+ signal
65
+ }));
66
+ }
67
+ return [];
68
+ }))).flat();
69
+ out = out.concat(...sub);
70
+ cur = sub;
71
+ }
72
+ }
73
+ if (glob) {
74
+ const { default: def, matcher = def.matcher } = await import("micromatch");
75
+ const match = matcher(glob);
76
+ out = out.filter((v)=>match(v.filename));
77
+ }
78
+ if (kind) {
79
+ out = out.filter((v)=>v.type === kind);
80
+ }
81
+ if (!hidden) {
82
+ out = out.filter((v)=>!v.basename.startsWith('.'));
83
+ }
84
+ return out.map((stat)=>this.toEntry(stat));
85
+ }
86
+ async stat(path, { signal } = {}) {
87
+ const res = await this.client.stat(path, {
88
+ details: true,
89
+ signal
90
+ });
91
+ return this.toEntry(this.getData(res));
92
+ }
93
+ async mkdir(path, { recursive, signal } = {}) {
94
+ await this.client.createDirectory(path, {
95
+ recursive,
96
+ signal
97
+ });
98
+ }
99
+ async readFile(path, options = {}) {
100
+ const format = options.encoding === 'text' ? 'text' : 'binary';
101
+ const res = await this.client.getFileContents(path, {
102
+ format,
103
+ ...options
104
+ });
105
+ return this.getData(res);
106
+ }
107
+ async writeFile(path, data, options = {}) {
108
+ await this.client.putFileContents(path, data, options);
109
+ }
110
+ async rm(path, { signal, force, recursive } = {}) {
111
+ try {
112
+ await this.client.deleteFile(path);
113
+ } catch (e) {
114
+ if (force && e.status === 404) {
115
+ return;
116
+ }
117
+ throw e;
118
+ }
119
+ }
120
+ async rename(oldPath, newPath, options = {}) {
121
+ await this.client.moveFile(oldPath, newPath, options);
122
+ }
123
+ async exists(path) {
124
+ return await this.client.exists(path);
125
+ }
126
+ async copy(src, dest, options = {}) {
127
+ await this.client.copyFile(src, dest, options);
128
+ }
129
+ createReadStream(path, options = {}) {
130
+ return this.client.createReadStream(path, options);
131
+ }
132
+ createWriteStream(path, options = {}) {
133
+ return this.client.createWriteStream(path, options);
134
+ }
135
+ };
136
+
137
+ //# sourceMappingURL=createWebDavFileSystem.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/fs/createWebDavFileSystem.ts"],"sourcesContent":["import type { Readable, Writable } from 'node:stream';\nimport { maybeFunction, type MaybeFunction } from '@wener/utils';\nimport type { FileStat, GetDirectoryContentsOptions, ResponseDataDetailed, WebDAVClient } from 'webdav';\nimport type {\n\tIFileStat,\n\tIFileSystem,\n\tMkdirOptions,\n\tReaddirOptions,\n\tReadFileOptions,\n\tRmOptions,\n\tStatOptions,\n} from './IFileSystem';\n\nexport function createWebDavFileSystem({ client }: { client: MaybeFunction<WebDAVClient> }): IFileSystem {\n\tlet fs = new WebdavFS({ client });\n\treturn fs;\n}\n\nclass WebdavFS implements IFileSystem {\n\t_client: MaybeFunction<WebDAVClient>;\n\n\tconstructor({\n\t\tclient = () => {\n\t\t\tthrow new Error('WebdavFS client not initialized');\n\t\t},\n\t}: {\n\t\tclient?: MaybeFunction<WebDAVClient>;\n\t}) {\n\t\tthis._client = client;\n\t}\n\n\tset client(client: MaybeFunction<WebDAVClient>) {\n\t\tthis._client = client;\n\t}\n\n\tget client(): WebDAVClient {\n\t\treturn maybeFunction(this._client);\n\t}\n\n\tprivate toEntry(input: FileStat): IFileStat {\n\t\tconst { filename: path, basename, lastmod, type: kind, etag, size, mime } = input;\n\t\tlet meta: Record<string, any> = {};\n\t\tif (etag) {\n\t\t\tmeta['etag'] = etag;\n\t\t}\n\t\tif (mime) {\n\t\t\tmeta['mime'] = mime;\n\t\t}\n\t\treturn {\n\t\t\tdirectory: path.substring(0, path.lastIndexOf('/')) || '/',\n\t\t\tpath,\n\t\t\tname: basename,\n\t\t\tmtime: +new Date(lastmod),\n\t\t\tkind,\n\t\t\tmeta,\n\t\t\tsize,\n\t\t};\n\t}\n\n\tprivate getData<T>(input: ResponseDataDetailed<T> | T): T {\n\t\tif (\n\t\t\tinput\n\t\t\t&& typeof input === 'object'\n\t\t\t&& 'data' in input\n\t\t\t// 'headers' in input &&\n\t\t\t&& 'status' in input\n\t\t\t&& typeof input.status === 'number'\n\t\t) {\n\t\t\treturn input.data;\n\t\t}\n\t\treturn input as T;\n\t}\n\n\tasync readdir(\n\t\tpath: string,\n\t\t{ glob, recursive, depth, kind, hidden, signal }: ReaddirOptions = {},\n\t): Promise<IFileStat[]> {\n\t\t// webdav depth 只支持 0,1\n\t\tlet o: GetDirectoryContentsOptions = {};\n\t\tif (recursive) {\n\t\t\to.deep = true;\n\t\t}\n\t\tlet res = await this.client.getDirectoryContents(path, {\n\t\t\tdeep: recursive,\n\t\t\tsignal,\n\t\t});\n\n\t\tlet out: FileStat[] = this.getData(res);\n\n\t\tif (!recursive && typeof depth === 'number' && depth >= 2) {\n\t\t\tlet l = depth;\n\t\t\tlet cur = out;\n\t\t\twhile (l-- > 1) {\n\t\t\t\tlet sub = (\n\t\t\t\t\tawait Promise.all(\n\t\t\t\t\t\tcur.map(async (v) => {\n\t\t\t\t\t\t\tif (v.type === 'directory') {\n\t\t\t\t\t\t\t\treturn this.getData(await this.client.getDirectoryContents(v.filename, { signal }));\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\treturn [];\n\t\t\t\t\t\t}),\n\t\t\t\t\t)\n\t\t\t\t).flat();\n\t\t\t\tout = out.concat(...sub);\n\t\t\t\tcur = sub;\n\t\t\t}\n\t\t}\n\n\t\tif (glob) {\n\t\t\tconst { default: def, matcher = def.matcher } = await import('micromatch');\n\t\t\tconst match = matcher(glob);\n\t\t\tout = out.filter((v) => match(v.filename));\n\t\t}\n\t\tif (kind) {\n\t\t\tout = out.filter((v) => v.type === kind);\n\t\t}\n\t\tif (!hidden) {\n\t\t\tout = out.filter((v) => !v.basename.startsWith('.'));\n\t\t}\n\t\treturn out.map((stat) => this.toEntry(stat));\n\t}\n\n\tasync stat(path: string, { signal }: StatOptions = {}): Promise<IFileStat> {\n\t\tconst res = await this.client.stat(path, { details: true, signal });\n\t\treturn this.toEntry(this.getData(res));\n\t}\n\n\tasync mkdir(path: string, { recursive, signal }: MkdirOptions = {}): Promise<void> {\n\t\tawait this.client.createDirectory(path, { recursive, signal });\n\t}\n\n\tasync readFile(path: string, options: ReadFileOptions = {}): Promise<any> {\n\t\tconst format = options.encoding === 'text' ? 'text' : 'binary';\n\t\tconst res = await this.client.getFileContents(path, { format, ...options });\n\t\treturn this.getData(res);\n\t}\n\n\tasync writeFile(path: string, data: string | Buffer | ArrayBuffer | Readable, options = {}): Promise<void> {\n\t\tawait this.client.putFileContents(path, data, options);\n\t}\n\n\tasync rm(path: string, { signal, force, recursive }: RmOptions = {}): Promise<void> {\n\t\ttry {\n\t\t\tawait this.client.deleteFile(path);\n\t\t} catch (e: any) {\n\t\t\tif (force && e.status === 404) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tthrow e;\n\t\t}\n\t}\n\n\tasync rename(oldPath: string, newPath: string, options = {}): Promise<void> {\n\t\tawait this.client.moveFile(oldPath, newPath, options);\n\t}\n\n\tasync exists(path: string): Promise<boolean> {\n\t\treturn await this.client.exists(path);\n\t}\n\n\tasync copy(src: string, dest: string, options = {}): Promise<void> {\n\t\tawait this.client.copyFile(src, dest, options);\n\t}\n\n\tcreateReadStream(path: string, options = {}): Readable {\n\t\treturn this.client.createReadStream(path, options);\n\t}\n\n\tcreateWriteStream(path: string, options = {}): Writable {\n\t\treturn this.client.createWriteStream(path, options);\n\t}\n}\n"],"names":["maybeFunction","createWebDavFileSystem","client","fs","WebdavFS","_client","Error","toEntry","input","filename","path","basename","lastmod","type","kind","etag","size","mime","meta","directory","substring","lastIndexOf","name","mtime","Date","getData","status","data","readdir","glob","recursive","depth","hidden","signal","o","deep","res","getDirectoryContents","out","l","cur","sub","Promise","all","map","v","flat","concat","default","def","matcher","match","filter","startsWith","stat","details","mkdir","createDirectory","readFile","options","format","encoding","getFileContents","writeFile","putFileContents","rm","force","deleteFile","e","rename","oldPath","newPath","moveFile","exists","copy","src","dest","copyFile","createReadStream","createWriteStream"],"mappings":"AACA,SAASA,aAAa,QAA4B,eAAe;AAYjE,OAAO,SAASC,uBAAuB,EAAEC,MAAM,EAA2C;IACzF,IAAIC,KAAK,IAAIC,SAAS;QAAEF;IAAO;IAC/B,OAAOC;AACR;AAEA,IAAA,AAAMC,WAAN,MAAMA;IACLC,QAAqC;IAErC,YAAY,EACXH,SAAS;QACR,MAAM,IAAII,MAAM;IACjB,CAAC,EAGD,CAAE;QACF,IAAI,CAACD,OAAO,GAAGH;IAChB;IAEA,IAAIA,OAAOA,MAAmC,EAAE;QAC/C,IAAI,CAACG,OAAO,GAAGH;IAChB;IAEA,IAAIA,SAAuB;QAC1B,OAAOF,cAAc,IAAI,CAACK,OAAO;IAClC;IAEQE,QAAQC,KAAe,EAAa;QAC3C,MAAM,EAAEC,UAAUC,IAAI,EAAEC,QAAQ,EAAEC,OAAO,EAAEC,MAAMC,IAAI,EAAEC,IAAI,EAAEC,IAAI,EAAEC,IAAI,EAAE,GAAGT;QAC5E,IAAIU,OAA4B,CAAC;QACjC,IAAIH,MAAM;YACTG,IAAI,CAAC,OAAO,GAAGH;QAChB;QACA,IAA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B,UAAUrD,IAAY,EAAEiB,IAA8C,EAAEgC,UAAU,CAAC,CAAC,EAAiB;QAC1G,MAAM,IAAI,CAACzD,MAAM,CAAC8D,eAAe,CAACtD,MAAMiB,MAAMgC;IAC/C;IAEA,MAAMM,GAAGvD,IAAY,EAAE,EAAEuB,MAAM,EAAEiC,KAAK,EAAEpC,SAAS,EAAa,GAAG,CAAC,CAAC,EAAiB;QACnF,IAAI;YACH,MAAM,IAAI,CAAC5B,MAAM,CAACiE,UAAU,CAACzD;QAC9B,EAAE,OAAO0D,GAAQ;YAChB,IAAIF,SAASE,EAAE1C,MAAM,KAAK,KAAK;gBAC9B;YACD;YACA,MAAM0C;QACP;IACD;IAEA,MAAMC,OAAOC,OAAe,EAAEC,OAAe,EAAEZ,UAAU,CAAC,CAAC,EAAiB;QAC3E,MAAM,IAAI,CAACzD,MAAM,CAACsE,QAAQ,CAACF,SAASC,SAASZ;IAC9C;IAEA,MAAMc,OAAO/D,IAAY,EAAoB;QAC5C,OAAO,MAAM,IAAI,CAACR,MAAM,CAACuE,MAAM,CAAC/D;IACjC;IAEA,MAAMgE,KAAKC,GAAW,EAAEC,IAAY,EAAEjB,UAAU,CAAC,CAAC,EAAiB;QAClE,MAAM,IAAI,CAACzD,MAAM,CAAC2E,QAAQ,CAACF,KAAKC,MAAMjB;IACvC;IAEAmB,iBAAiBpE,IAAY,EAAEiD,UAAU,CAAC,CAAC,EAAY;QACtD,OAAO,IAAI,CAACzD,MAAM,CAAC4E,gBAAgB,CAACpE,MAAMiD;IAC3C;IAEAoB,kBAAkBrE,IAAY,EAAEiD,UAAU,CAAC,CAAC,EAAY;QACvD,OAAO,IAAI,CAACzD,MAAM,CAAC6E,iBAAiB,CAACrE,MAAMiD;IAC5C;AACD"}
@@ -0,0 +1,17 @@
1
+ import { types } from "mime-types";
2
+ import pathe from "pathe";
3
+ export function findMimeType(path) {
4
+ // fix extname error
5
+ // https://github.com/jshttp/mime-types/issues/111
6
+ if (!path || typeof path !== 'string') {
7
+ return false;
8
+ }
9
+ // get the extension ("ext" or ".ext" or full path)
10
+ const extension = pathe.extname('x.' + path).toLowerCase().slice(1);
11
+ if (!extension) {
12
+ return false;
13
+ }
14
+ return types[extension] || false;
15
+ }
16
+
17
+ //# sourceMappingURL=findMimeType.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/fs/findMimeType.ts"],"sourcesContent":["import { types } from 'mime-types';\nimport pathe from 'pathe';\n\nexport function findMimeType(path: string | undefined | null) {\n\t// fix extname error\n\t// https://github.com/jshttp/mime-types/issues/111\n\n\tif (!path || typeof path !== 'string') {\n\t\treturn false;\n\t}\n\n\t// get the extension (\"ext\" or \".ext\" or full path)\n\tconst extension = pathe\n\t\t.extname('x.' + path)\n\t\t.toLowerCase()\n\t\t.slice(1);\n\n\tif (!extension) {\n\t\treturn false;\n\t}\n\n\treturn types[extension] || false;\n}\n"],"names":["types","pathe","findMimeType","path","extension","extname","toLowerCase","slice"],"mappings":"AAAA,SAASA,KAAK,QAAQ,aAAa;AACnC,OAAOC,WAAW,QAAQ;AAE1B,OAAO,SAASC,aAAaC,IAA+B;IAC3D,oBAAoB;IACpB,kDAAkD;IAElD,IAAI,CAACA,QAAQ,OAAOA,SAAS,UAAU;QACtC,OAAO;IACR;IAEA,mDAAmD;IACnD,MAAMC,YAAYH,MAChBI,OAAO,CAAC,OAAOF,MACfG,WAAW,GACXC,KAAK,CAAC;IAER,IAAI,CAACH,WAAW;QACf,OAAO;IACR;IAEA,OAAOJ,KAAK,CAACI,UAAU,IAAI;AAC5B"}
@@ -0,0 +1,8 @@
1
+ export { createSandboxFileSystem } from "./createSandboxFileSystem.js";
2
+ export { createMemoryFileSystem } from "./createMemoryFileSystem.js";
3
+ export { createWebDavFileSystem } from "./createWebDavFileSystem.js";
4
+ export { createBrowserFileSystem } from "./createBrowserFileSystem.js";
5
+ export { findMimeType } from "./findMimeType.js";
6
+ export { FileUrlOptionsSchema } from "./types.js";
7
+ export { FileSystemError, FileSystemErrorCode } from "./FileSystemError.js";
8
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/fs/index.ts"],"sourcesContent":["export type * from './IFileSystem';\nexport { createSandboxFileSystem } from './createSandboxFileSystem';\nexport { createMemoryFileSystem } from './createMemoryFileSystem';\nexport { createWebDavFileSystem } from './createWebDavFileSystem';\nexport { createBrowserFileSystem } from './createBrowserFileSystem';\nexport { findMimeType } from './findMimeType';\nexport { type FileUrlOptions, FileUrlOptionsSchema } from './types';\nexport { FileSystemError, FileSystemErrorCode } from './FileSystemError';\n"],"names":["createSandboxFileSystem","createMemoryFileSystem","createWebDavFileSystem","createBrowserFileSystem","findMimeType","FileUrlOptionsSchema","FileSystemError","FileSystemErrorCode"],"mappings":"AACA,SAASA,uBAAuB,QAAQ,4BAA4B;AACpE,SAASC,sBAAsB,QAAQ,2BAA2B;AAClE,SAASC,sBAAsB,QAAQ,2BAA2B;AAClE,SAASC,uBAAuB,QAAQ,4BAA4B;AACpE,SAASC,YAAY,QAAQ,iBAAiB;AAC9C,SAA8BC,oBAAoB,QAAQ,UAAU;AACpE,SAASC,eAAe,EAAEC,mBAAmB,QAAQ,oBAAoB"}
@@ -0,0 +1,93 @@
1
+ import { oc } from "@orpc/contract";
2
+ import { z } from "zod/v4";
3
+ import { FileKindSchema } from "../types.js";
4
+ export const FileStatSchema = z.object({
5
+ directory: z.string(),
6
+ path: z.string(),
7
+ name: z.string(),
8
+ kind: FileKindSchema,
9
+ mtime: z.coerce.date(),
10
+ size: z.coerce.number().nonnegative().default(0),
11
+ meta: z.record(z.string(), z.any())
12
+ });
13
+ export const ReaddirInputSchema = z.object({
14
+ dir: z.string().nonempty(),
15
+ glob: z.string().optional(),
16
+ recursive: z.boolean().default(false),
17
+ depth: z.number().min(0).optional(),
18
+ kind: FileKindSchema.optional(),
19
+ cursor: z.string().optional(),
20
+ hidden: z.boolean().default(false)
21
+ });
22
+ const ReaddirOutputSchema = z.object({
23
+ data: FileStatSchema.array()
24
+ });
25
+ const StatInputSchema = z.object({
26
+ path: z.string()
27
+ });
28
+ const StatOutputSchema = z.object({
29
+ data: FileStatSchema
30
+ });
31
+ const CreateDirectoryInputSchema = z.object({
32
+ path: z.string(),
33
+ recursive: z.boolean().nullish()
34
+ });
35
+ const CreateDirectoryOutputSchema = z.object({}).default({});
36
+ const RenameInputSchema = z.object({
37
+ oldPath: z.string(),
38
+ newPath: z.string(),
39
+ overwrite: z.boolean().nullish()
40
+ });
41
+ const RenameOutputSchema = z.object({}).default({});
42
+ const ExistsInputSchema = z.object({
43
+ path: z.string()
44
+ });
45
+ const ExistsOutputSchema = z.object({
46
+ data: z.boolean()
47
+ });
48
+ const CopyInputSchema = z.object({
49
+ src: z.string(),
50
+ dest: z.string(),
51
+ overwrite: z.boolean().nullish(),
52
+ shallow: z.boolean().nullish()
53
+ });
54
+ const CopyOutputSchema = z.object({}).default({});
55
+ const ReadFileInputSchema = z.object({
56
+ path: z.string()
57
+ });
58
+ const ReadFileOutputSchema = z.object({
59
+ base64: z.string()
60
+ });
61
+ const WriteFileInputSchema = z.object({
62
+ path: z.string(),
63
+ base64: z.string(),
64
+ overwrite: z.boolean().optional()
65
+ });
66
+ const WriteFileOutputSchema = z.object({});
67
+ const RemoveInputSchema = z.object({
68
+ path: z.string(),
69
+ recursive: z.boolean().nullish(),
70
+ force: z.boolean().nullish()
71
+ });
72
+ const RemoveOutputSchema = z.object({}).default({});
73
+ export const FileSystemContract = {
74
+ readdir: oc.input(ReaddirInputSchema).output(ReaddirOutputSchema).route({
75
+ description: "List directory contents"
76
+ }),
77
+ stat: oc.input(StatInputSchema).output(StatOutputSchema).route({
78
+ method: "GET",
79
+ description: "Get file or directory status"
80
+ }),
81
+ mkdir: oc.input(CreateDirectoryInputSchema).output(CreateDirectoryOutputSchema).route({
82
+ description: "Create a directory"
83
+ }),
84
+ readFile: oc.input(ReadFileInputSchema).output(ReadFileOutputSchema).route({
85
+ description: "Read file"
86
+ }),
87
+ writeFile: oc.input(WriteFileInputSchema).output(WriteFileOutputSchema),
88
+ rename: oc.input(RenameInputSchema).output(RenameOutputSchema),
89
+ exists: oc.input(ExistsInputSchema).output(ExistsOutputSchema),
90
+ copy: oc.input(CopyInputSchema).output(CopyOutputSchema),
91
+ rm: oc.input(RemoveInputSchema).output(RemoveOutputSchema)
92
+ };
93
+ //# sourceMappingURL=FileSystemContract.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/fs/orpc/FileSystemContract.ts"],"sourcesContent":["import { oc } from '@orpc/contract';\nimport { z } from 'zod/v4';\nimport { FileKindSchema } from '../types';\n\nexport type FileStat = z.infer<typeof FileStatSchema>;\nexport const FileStatSchema = z.object({\n\tdirectory: z.string(),\n\tpath: z.string(),\n\tname: z.string(),\n\tkind: FileKindSchema,\n\tmtime: z.coerce.date(),\n\tsize: z.coerce.number().nonnegative().default(0),\n\tmeta: z.record(z.string(), z.any()),\n});\nexport type ReaddirInput = z.infer<typeof ReaddirInputSchema>;\nexport const ReaddirInputSchema = z.object({\n\tdir: z.string().nonempty(),\n\tglob: z.string().optional(),\n\trecursive: z.boolean().default(false),\n\tdepth: z.number().min(0).optional(),\n\tkind: FileKindSchema.optional(),\n\tcursor: z.string().optional(),\n\thidden: z.boolean().default(false),\n});\nconst ReaddirOutputSchema = z.object({\n\tdata: FileStatSchema.array(),\n});\nconst StatInputSchema = z.object({\n\tpath: z.string(),\n});\nconst StatOutputSchema = z.object({\n\tdata: FileStatSchema,\n});\nconst CreateDirectoryInputSchema = z.object({\n\tpath: z.string(),\n\trecursive: z.boolean().nullish(),\n});\nconst CreateDirectoryOutputSchema = z.object({}).default({});\nconst RenameInputSchema = z.object({\n\toldPath: z.string(),\n\tnewPath: z.string(),\n\toverwrite: z.boolean().nullish(),\n});\nconst RenameOutputSchema = z.object({}).default({});\nconst ExistsInputSchema = z.object({\n\tpath: z.string(),\n});\nconst ExistsOutputSchema = z.object({\n\tdata: z.boolean(),\n});\nconst CopyInputSchema = z.object({\n\tsrc: z.string(),\n\tdest: z.string(),\n\toverwrite: z.boolean().nullish(),\n\tshallow: z.boolean().nullish(),\n});\nconst CopyOutputSchema = z.object({}).default({});\nconst ReadFileInputSchema = z.object({\n\tpath: z.string(),\n});\nconst ReadFileOutputSchema = z.object({\n\tbase64: z.string(),\n});\nconst WriteFileInputSchema = z.object({\n\tpath: z.string(),\n\tbase64: z.string(),\n\toverwrite: z.boolean().optional(),\n});\nconst WriteFileOutputSchema = z.object({});\nconst RemoveInputSchema = z.object({\n\tpath: z.string(),\n\trecursive: z.boolean().nullish(),\n\tforce: z.boolean().nullish(),\n});\nconst RemoveOutputSchema = z.object({}).default({});\nexport const FileSystemContract = {\n\treaddir: oc.input(ReaddirInputSchema).output(ReaddirOutputSchema).route({ description: 'List directory contents' }),\n\tstat: oc.input(StatInputSchema).output(StatOutputSchema).route({\n\t\tmethod: 'GET',\n\t\tdescription: 'Get file or directory status',\n\t}),\n\tmkdir: oc\n\t\t.input(CreateDirectoryInputSchema)\n\t\t.output(CreateDirectoryOutputSchema)\n\t\t.route({ description: 'Create a directory' }),\n\treadFile: oc.input(ReadFileInputSchema).output(ReadFileOutputSchema).route({ description: 'Read file' }),\n\twriteFile: oc.input(WriteFileInputSchema).output(WriteFileOutputSchema),\n\trename: oc.input(RenameInputSchema).output(RenameOutputSchema),\n\texists: oc.input(ExistsInputSchema).output(ExistsOutputSchema),\n\tcopy: oc.input(CopyInputSchema).output(CopyOutputSchema),\n\trm: oc.input(RemoveInputSchema).output(RemoveOutputSchema),\n};\n"],"names":["oc","z","FileKindSchema","FileStatSchema","object","directory","string","path","name","kind","mtime","coerce","date","size","number","nonnegative","default","meta","record","any","ReaddirInputSchema","dir","nonempty","glob","optional","recursive","boolean","depth","min","cursor","hidden","ReaddirOutputSchema","data","array","StatInputSchema","StatOutputSchema","CreateDirectoryInputSchema","nullish","CreateDirectoryOutputSchema","RenameInputSchema","oldPath","newPath","overwrite","RenameOutputSchema","ExistsInputSchema","ExistsOutputSchema","CopyInputSchema","src","dest","shallow","CopyOutputSchema","ReadFileInputSchema","ReadFileOutputSchema","base64","WriteFileInputSchema","WriteFileOutputSchema","RemoveInputSchema","force","RemoveOutputSchema","FileSystemContract","readdir","input","output","route","description","stat","method","mkdir","readFile","writeFile","rename","exists","copy","rm"],"mappings":"AAAA,SAASA,EAAE,QAAQ,iBAAiB;AACpC,SAASC,CAAC,QAAQ,SAAS;AAC3B,SAASC,cAAc,QAAQ,WAAW;AAG1C,OAAO,MAAMC,iBAAiBF,EAAEG,MAAM,CAAC;IACtCC,WAAWJ,EAAEK,MAAM;IACnBC,MAAMN,EAAEK,MAAM;IACdE,MAAMP,EAAEK,MAAM;IACdG,MAAMP;IACNQ,OAAOT,EAAEU,MAAM,CAACC,IAAI;IACpBC,MAAMZ,EAAEU,MAAM,CAACG,MAAM,GAAGC,WAAW,GAAGC,OAAO,CAAC;IAC9CC,MAAMhB,EAAEiB,MAAM,CAACjB,EAAEK,MAAM,IAAIL,EAAEkB,GAAG;AACjC,GAAG;AAEH,OAAO,MAAMC,qBAAqBnB,EAAEG,MAAM,CAAC;IAC1CiB,KAAKpB,EAAEK,MAAM,GAAGgB,QAAQ;IACxBC,MAAMtB,EAAEK,MAAM,GAAGkB,QAAQ;IACzBC,WAAWxB,EAAEyB,OAAO,GAAGV,OAAO,CAAC;IAC/BW,OAAO1B,EAAEa,MAAM,GAAGc,GAAG,CAAC,GAAGJ,QAAQ;IACjCf,MAAMP,eAAesB,QAAQ;IAC7BK,QAAQ5B,EAAEK,MAAM,GAAGkB,QAAQ;IAC3BM,QAAQ7B,EAAEyB,OAAO,GAAGV,OAAO,CAAC;AAC7B,GAAG;AACH,MAAMe,sBAAsB9B,EAAEG,MAAM,CAAC;IACpC4B,MAAM7B,eAAe8B,KAAK;AAC3B;AACA,MAAMC,kBAAkBjC,EAAEG,MAAM,CAAC;IAChCG,MAAMN,EAAEK,MAAM;AACf;AACA,MAAM6B,mBAAmBlC,EAAEG,MAAM,CAAC;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AACxC,MAAMoD,oBAAoBvD,EAAEG,MAAM,CAAC;IAClCG,MAAMN,EAAEK,MAAM;IACdmB,WAAWxB,EAAEyB,OAAO,GAAGW,OAAO;IAC9BoB,OAAOxD,EAAEyB,OAAO,GAAGW,OAAO;AAC3B;AACA,MAAMqB,qBAAqBzD,EAAEG,MAAM,CAAC,CAAC,GAAGY,OAAO,CAAC,CAAC;AACjD,OAAO,MAAM2C,qBAAqB;IACjCC,SAAS5D,GAAG6D,KAAK,CAACzC,oBAAoB0C,MAAM,CAAC/B,qBAAqBgC,KAAK,CAAC;QAAEC,aAAa;IAA0B;IACjHC,MAAMjE,GAAG6D,KAAK,CAAC3B,iBAAiB4B,MAAM,CAAC3B,kBAAkB4B,KAAK,CAAC;QAC9DG,QAAQ;QACRF,aAAa;IACd;IACAG,OAAOnE,GACL6D,KAAK,CAACzB,4BACN0B,MAAM,CAACxB,6BACPyB,KAAK,CAAC;QAAEC,aAAa;IAAqB;IAC5CI,UAAUpE,GAAG6D,KAAK,CAACV,qBAAqBW,MAAM,CAACV,sBAAsBW,KAAK,CAAC;QAAEC,aAAa;IAAY;IACtGK,WAAWrE,GAAG6D,KAAK,CAACP,sBAAsBQ,MAAM,CAACP;IACjDe,QAAQtE,GAAG6D,KAAK,CAACtB,mBAAmBuB,MAAM,CAACnB;IAC3C4B,QAAQvE,GAAG6D,KAAK,CAACjB,mBAAmBkB,MAAM,CAACjB;IAC3C2B,MAAMxE,GAAG6D,KAAK,CAACf,iBAAiBgB,MAAM,CAACZ;IACvCuB,IAAIzE,GAAG6D,KAAK,CAACL,mBAAmBM,MAAM,CAACJ;AACxC,EAAE"}
@@ -0,0 +1,93 @@
1
+ import { ArrayBuffers } from "@wener/utils";
2
+ import { resolveData } from "../utils";
3
+ export function createContractClientFileSystem(client) {
4
+ return new ContractFS(client);
5
+ }
6
+ let ContractFS = class ContractFS {
7
+ client;
8
+ constructor(client){
9
+ this.client = client;
10
+ }
11
+ async readdir(dir, options = {}) {
12
+ const { data } = await this.client.readdir({
13
+ dir,
14
+ ...options
15
+ });
16
+ return data.map((stat)=>({
17
+ ...stat,
18
+ mtime: stat.mtime.getTime()
19
+ }));
20
+ }
21
+ async stat(entry, options) {
22
+ const { data } = await this.client.stat({
23
+ path: entry
24
+ });
25
+ return {
26
+ ...data,
27
+ mtime: data.mtime.getTime()
28
+ };
29
+ }
30
+ async mkdir(path, options) {
31
+ await this.client.mkdir({
32
+ path,
33
+ recursive: options?.recursive
34
+ });
35
+ }
36
+ async readFile(path, options) {
37
+ // Note: The contract doesn't currently support encoding options.
38
+ const { base64 } = await this.client.readFile({
39
+ path
40
+ });
41
+ let enc = options?.encoding || 'binary';
42
+ let buf = ArrayBuffers.fromBase64(base64);
43
+ switch(enc){
44
+ case 'text':
45
+ return ArrayBuffers.toString(buf);
46
+ }
47
+ return buf;
48
+ }
49
+ async writeFile(path, data, options) {
50
+ let buf = resolveData(data);
51
+ await this.client.writeFile({
52
+ path,
53
+ base64: ArrayBuffers.toBase64(buf),
54
+ ...options
55
+ });
56
+ }
57
+ async rename(oldPath, newPath, options) {
58
+ await this.client.rename({
59
+ oldPath,
60
+ newPath,
61
+ overwrite: options?.overwrite
62
+ });
63
+ }
64
+ async exists(path) {
65
+ const { data } = await this.client.exists({
66
+ path
67
+ });
68
+ return data;
69
+ }
70
+ async copy(src, dest, options) {
71
+ await this.client.copy({
72
+ src,
73
+ dest,
74
+ overwrite: options?.overwrite,
75
+ shallow: options?.shallow
76
+ });
77
+ }
78
+ async rm(path, options) {
79
+ await this.client.rm({
80
+ path,
81
+ recursive: options?.recursive,
82
+ force: options?.force
83
+ });
84
+ }
85
+ createReadStream(path, options) {
86
+ throw new Error('createReadStream is not implemented in ContractFS');
87
+ }
88
+ createWriteStream(path, options) {
89
+ throw new Error('createWriteStream is not implemented in ContractFS');
90
+ }
91
+ };
92
+
93
+ //# sourceMappingURL=createContractClientFileSystem.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/fs/orpc/createContractClientFileSystem.ts"],"sourcesContent":["import type { Readable, Writable } from 'node:stream';\nimport type { ContractRouterClient } from '@orpc/contract';\nimport { ArrayBuffers } from '@wener/utils';\nimport type {\n\tCopyOptions,\n\tCreateReadStreamOptions,\n\tCreateWriteStreamOptions,\n\tIFileSystem,\n\tMkdirOptions,\n\tReaddirOptions,\n\tReadFileOptions,\n\tRenameOptions,\n\tRmOptions,\n\tStatOptions,\n\tWritableData,\n\tWriteFileOptions,\n} from '../IFileSystem';\nimport { resolveData } from '../utils';\nimport { FileSystemContract } from './FileSystemContract';\n\ntype FileSystemContractClient = ContractRouterClient<typeof FileSystemContract>;\n\nexport function createContractClientFileSystem(client: FileSystemContractClient): IFileSystem & {\n\tclient: FileSystemContractClient;\n} {\n\treturn new ContractFS(client);\n}\n\nclass ContractFS implements IFileSystem {\n\tclient: FileSystemContractClient;\n\n\tconstructor(client: FileSystemContractClient) {\n\t\tthis.client = client;\n\t}\n\n\tasync readdir(dir: string, options: ReaddirOptions = {}) {\n\t\tconst { data } = await this.client.readdir({ dir, ...options });\n\t\treturn data.map((stat) => ({\n\t\t\t...stat,\n\t\t\tmtime: stat.mtime.getTime(),\n\t\t}));\n\t}\n\n\tasync stat(entry: string, options?: StatOptions) {\n\t\tconst { data } = await this.client.stat({ path: entry });\n\t\treturn {\n\t\t\t...data,\n\t\t\tmtime: data.mtime.getTime(),\n\t\t};\n\t}\n\n\tasync mkdir(path: string, options?: MkdirOptions) {\n\t\tawait this.client.mkdir({\n\t\t\tpath,\n\t\t\trecursive: options?.recursive,\n\t\t});\n\t}\n\n\treadFile(path: string, options?: ReadFileOptions & { encoding: 'text' }): Promise<string>;\n\treadFile(path: string, options?: ReadFileOptions): Promise<Uint8Array>;\n\tasync readFile(path: string, options?: ReadFileOptions): Promise<string | Uint8Array> {\n\t\t// Note: The contract doesn't currently support encoding options.\n\t\tconst { base64 } = await this.client.readFile({ path });\n\t\tlet enc = options?.encoding || 'binary';\n\t\tlet buf = ArrayBuffers.fromBase64(base64);\n\t\tswitch (enc) {\n\t\t\tcase 'text':\n\t\t\t\treturn ArrayBuffers.toString(buf);\n\t\t}\n\t\treturn buf;\n\t}\n\n\tasync writeFile(path: string, data: WritableData, options?: WriteFileOptions) {\n\t\tlet buf = resolveData(data);\n\t\tawait this.client.writeFile({ path, base64: ArrayBuffers.toBase64(buf), ...options });\n\t}\n\n\tasync rename(oldPath: string, newPath: string, options?: RenameOptions) {\n\t\tawait this.client.rename({\n\t\t\toldPath,\n\t\t\tnewPath,\n\t\t\toverwrite: options?.overwrite,\n\t\t});\n\t}\n\n\tasync exists(path: string) {\n\t\tconst { data } = await this.client.exists({ path });\n\t\treturn data;\n\t}\n\n\tasync copy(src: string, dest: string, options?: CopyOptions) {\n\t\tawait this.client.copy({\n\t\t\tsrc,\n\t\t\tdest,\n\t\t\toverwrite: options?.overwrite,\n\t\t\tshallow: options?.shallow,\n\t\t});\n\t}\n\n\tasync rm(path: string, options?: RmOptions) {\n\t\tawait this.client.rm({\n\t\t\tpath,\n\t\t\trecursive: options?.recursive,\n\t\t\tforce: options?.force,\n\t\t});\n\t}\n\n\tcreateReadStream(path: string, options?: CreateReadStreamOptions): Readable {\n\t\tthrow new Error('createReadStream is not implemented in ContractFS');\n\t}\n\n\tcreateWriteStream(path: string, options?: CreateWriteStreamOptions): Writable {\n\t\tthrow new Error('createWriteStream is not implemented in ContractFS');\n\t}\n}\n"],"names":["ArrayBuffers","resolveData","createContractClientFileSystem","client","ContractFS","readdir","dir","options","data","map","stat","mtime","getTime","entry","path","mkdir","recursive","readFile","base64","enc","encoding","buf","fromBase64","toString","writeFile","toBase64","rename","oldPath","newPath","overwrite","exists","copy","src","dest","shallow","rm","force","createReadStream","Error","createWriteStream"],"mappings":"AAEA,SAASA,YAAY,QAAQ,eAAe;AAe5C,SAASC,WAAW,QAAQ,WAAW;AAKvC,OAAO,SAASC,+BAA+BC,MAAgC;IAG9E,OAAO,IAAIC,WAAWD;AACvB;AAEA,IAAA,AAAMC,aAA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ayB,QAAQ,CAACJ;YAAM,GAAGd,OAAO;QAAC;IACpF;IAEA,MAAMmB,OAAOC,OAAe,EAAEC,OAAe,EAAErB,OAAuB,EAAE;QACvE,MAAM,IAAI,CAACJ,MAAM,CAACuB,MAAM,CAAC;YACxBC;YACAC;YACAC,WAAWtB,SAASsB;QACrB;IACD;IAEA,MAAMC,OAAOhB,IAAY,EAAE;QAC1B,MAAM,EAAEN,IAAI,EAAE,GAAG,MAAM,IAAI,CAACL,MAAM,CAAC2B,MAAM,CAAC;YAAEhB;QAAK;QACjD,OAAON;IACR;IAEA,MAAMuB,KAAKC,GAAW,EAAEC,IAAY,EAAE1B,OAAqB,EAAE;QAC5D,MAAM,IAAI,CAACJ,MAAM,CAAC4B,IAAI,CAAC;YACtBC;YACAC;YACAJ,WAAWtB,SAASsB;YACpBK,SAAS3B,SAAS2B;QACnB;IACD;IAEA,MAAMC,GAAGrB,IAAY,EAAEP,OAAmB,EAAE;QAC3C,MAAM,IAAI,CAACJ,MAAM,CAACgC,EAAE,CAAC;YACpBrB;YACAE,WAAWT,SAASS;YACpBoB,OAAO7B,SAAS6B;QACjB;IACD;IAEAC,iBAAiBvB,IAAY,EAAEP,OAAiC,EAAY;QAC3E,MAAM,IAAI+B,MAAM;IACjB;IAEAC,kBAAkBzB,IAAY,EAAEP,OAAkC,EAAY;QAC7E,MAAM,IAAI+B,MAAM;IACjB;AACD"}
@@ -0,0 +1,3 @@
1
+ export { createContractClientFileSystem } from "./createContractClientFileSystem.js";
2
+ export { FileSystemContract } from "./FileSystemContract.js";
3
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/fs/orpc/index.ts"],"sourcesContent":["export { createContractClientFileSystem } from './createContractClientFileSystem';\nexport { FileSystemContract } from './FileSystemContract';\n"],"names":["createContractClientFileSystem","FileSystemContract"],"mappings":"AAAA,SAASA,8BAA8B,QAAQ,mCAAmC;AAClF,SAASC,kBAAkB,QAAQ,uBAAuB"}
@@ -0,0 +1,63 @@
1
+ import { implement } from "@orpc/server";
2
+ import { ArrayBuffers } from "@wener/utils";
3
+ import { FileSystemContract } from "../FileSystemContract.js";
4
+ export function createFileSystemContractImpl(ifs) {
5
+ const os = implement(FileSystemContract);
6
+ return {
7
+ readdir: os.readdir.handler(async ({ input }) => {
8
+ return {
9
+ data: await ifs.readdir(input.dir)
10
+ };
11
+ }),
12
+ stat: os.stat.handler(async ({ input }) => {
13
+ return {
14
+ data: await ifs.stat(input.path)
15
+ };
16
+ }),
17
+ mkdir: os.mkdir.handler(async ({ input }) => {
18
+ await ifs.mkdir(input.path, {
19
+ recursive: input.recursive ?? false
20
+ });
21
+ return {};
22
+ }),
23
+ rename: os.rename.handler(async ({ input }) => {
24
+ await ifs.rename(input.oldPath, input.newPath, {
25
+ overwrite: input.overwrite ?? false
26
+ });
27
+ return {};
28
+ }),
29
+ exists: os.exists.handler(async ({ input }) => {
30
+ return {
31
+ data: await ifs.exists(input.path)
32
+ };
33
+ }),
34
+ copy: os.copy.handler(async ({ input }) => {
35
+ await ifs.copy(input.src, input.dest, {
36
+ overwrite: input.overwrite ?? false,
37
+ shallow: input.shallow ?? false
38
+ });
39
+ return {};
40
+ }),
41
+ readFile: os.readFile.handler(async ({ input }) => {
42
+ return {
43
+ base64: ArrayBuffers.toBase64(await ifs.readFile(input.path, {
44
+ encoding: "binary"
45
+ }))
46
+ };
47
+ }),
48
+ writeFile: os.writeFile.handler(async ({ input }) => {
49
+ await ifs.writeFile(input.path, Buffer.from(input.base64, "base64"), {
50
+ overwrite: input.overwrite
51
+ });
52
+ return {};
53
+ }),
54
+ rm: os.rm.handler(async ({ input }) => {
55
+ await ifs.rm(input.path, {
56
+ recursive: input.recursive ?? undefined,
57
+ force: input.force ?? undefined
58
+ });
59
+ return {};
60
+ })
61
+ };
62
+ }
63
+ //# sourceMappingURL=createFileSystemContractImpl.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../src/fs/orpc/server/createFileSystemContractImpl.ts"],"sourcesContent":["import { implement } from '@orpc/server';\nimport { ArrayBuffers } from '@wener/utils';\nimport type { IFileSystem } from '../../IFileSystem';\nimport { FileSystemContract } from '../FileSystemContract';\n\nexport function createFileSystemContractImpl(ifs: IFileSystem) {\n\tconst os = implement(FileSystemContract);\n\n\treturn {\n\t\treaddir: os.readdir.handler(async ({ input }) => {\n\t\t\treturn {\n\t\t\t\tdata: await ifs.readdir(input.dir),\n\t\t\t};\n\t\t}),\n\t\tstat: os.stat.handler(async ({ input }) => {\n\t\t\treturn {\n\t\t\t\tdata: await ifs.stat(input.path),\n\t\t\t};\n\t\t}),\n\t\tmkdir: os.mkdir.handler(async ({ input }) => {\n\t\t\tawait ifs.mkdir(input.path, {\n\t\t\t\trecursive: input.recursive ?? false,\n\t\t\t});\n\t\t\treturn {};\n\t\t}),\n\t\trename: os.rename.handler(async ({ input }) => {\n\t\t\tawait ifs.rename(input.oldPath, input.newPath, {\n\t\t\t\toverwrite: input.overwrite ?? false,\n\t\t\t});\n\t\t\treturn {};\n\t\t}),\n\t\texists: os.exists.handler(async ({ input }) => {\n\t\t\treturn {\n\t\t\t\tdata: await ifs.exists(input.path),\n\t\t\t};\n\t\t}),\n\t\tcopy: os.copy.handler(async ({ input }) => {\n\t\t\tawait ifs.copy(input.src, input.dest, {\n\t\t\t\toverwrite: input.overwrite ?? false,\n\t\t\t\tshallow: input.shallow ?? false,\n\t\t\t});\n\t\t\treturn {};\n\t\t}),\n\t\treadFile: os.readFile.handler(async ({ input }) => {\n\t\t\treturn {\n\t\t\t\tbase64: ArrayBuffers.toBase64(await ifs.readFile(input.path, { encoding: 'binary' })),\n\t\t\t};\n\t\t}),\n\t\twriteFile: os.writeFile.handler(async ({ input }) => {\n\t\t\tawait ifs.writeFile(input.path, Buffer.from(input.base64, 'base64'), {\n\t\t\t\toverwrite: input.overwrite,\n\t\t\t});\n\t\t\treturn {};\n\t\t}),\n\n\t\trm: os.rm.handler(async ({ input }) => {\n\t\t\tawait ifs.rm(input.path, {\n\t\t\t\trecursive: input.recursive ?? undefined,\n\t\t\t\tforce: input.force ?? undefined,\n\t\t\t});\n\t\t\treturn {};\n\t\t}),\n\t};\n}\n"],"names":["implement","ArrayBuffers","FileSystemContract","createFileSystemContractImpl","ifs","os","readdir","handler","input","data","dir","stat","path","mkdir","recursive","rename","oldPath","newPath","overwrite","exists","copy","src","dest","shallow","readFile","base64","toBase64","encoding","writeFile","Buffer","from","rm","undefined","force"],"mappings":"AAAA,SAASA,SAAS,QAAQ,eAAe;AACzC,SAASC,YAAY,QAAQ,eAAe;AAE5C,SAASC,kBAAkB,QAAQ,wBAAwB;AAE3D,OAAO,SAASC,6BAA6BC,GAAgB;IAC5D,MAAMC,KAAKL,UAAUE;IAErB,OAAO;QACNI,SAASD,GAAGC,OAAO,CAACC,OAAO,CAAC,OAAO,EAAEC,KAAK,EAAE;YAC3C,OAAO;gBACNC,MAAM,MAAML,IAAIE,OAAO,CAACE,MAAME,GAAG;YAClC;QACD;QACAC,MAAMN,GAAGM,IAAI,CAACJ,OAAO,CAAC,OAAO,EAAEC,KAAK,EAAE;YACrC,OAAO;gBACNC,MAAM,MAAML,IAAIO,IAAI,CAACH,MAAMI,IAAI;YAChC;QACD;QACAC,OAAOR,GAAGQ,KAAK,CAACN,OAAO,CAAC,OAAO,EAAEC,KAAK,EAAE;YACvC,MAAMJ,IAAIS,KAAK,CAACL,MAAMI,IAAI,EAAE;gBAC3BE,WAAWN,MAAMM,SAAS,IAAI;YAC/B;YACA,OAAO,CAAC;QACT;QACAC,QAAQV,GAAGU,MAAM,CAACR,OAAO,CAAC,OAAO,EAAEC,KAAK,EAAE;YACzC,MAAMJ,IAAIW,MAAM,CAACP,MAAMQ,OAAO,EAAER,MAAMS,OAAO,EAAE;gBAC9CC,WAAWV,MAAMU,SAAS,IAAI;YAC/B;YACA,OAAO,CAAC;QACT;QACAC,QAAQd,GAAGc,MAAM,CAACZ,OAAO,CAAC,OAAO,EAAEC,KAAK,EAAE;YACzC,OAAO;gBACNC,MAAM,MAAML,IAAIe,MAAM,CAACX,MAAMI,IAAI;YAClC;QACD;QACAQ,MAAMf,GAAGe,IAAI,CAACb,OAAO,CAAC,OAAO,EAAEC,KAAK,EAAE;YACrC,MAAMJ,IAAIgB,IAAI,CAACZ,MAAMa,GAAG,EAAEb,MAAMc,IAAI,EAAE;gBACrCJ,WAAWV,MAAMU,SAAS,IAAI;gBAC9BK,SAASf,MAAMe,OAAO,IAAI;YAC3B;YACA,OAAO,CAAC;QACT;QACAC,UAAUnB,GAAGmB,QAAQ,CAACjB,OAAO,CAAC,OAAO,EAAEC,KAAK,EAAE;YAC7C,OAAO;gBACNiB,QAAQxB,aAAayB,QAAQ,CAAC,MAAMtB,IAAIoB,QAAQ,CAAChB,MAAMI,IAAI,EAAE;oBAAEe,UAAU;gBAAS;YACnF;QACD;QACAC,WAAWvB,GAAGuB,SAAS,CAACrB,OAAO,CAAC,OAAO,EAAEC,KAAK,EAAE;YAC/C,MAAMJ,IAAIwB,SAAS,CAACpB,MAAMI,IAAI,EAAEiB,OAAOC,IAAI,CAACtB,MAAMiB,MAAM,EAAE,WAAW;gBACpEP,WAAWV,MAAMU,SAAS;YAC3B;YACA,OAAO,CAAC;QACT;QAEAa,IAAI1B,GAAG0B,EAAE,CAACxB,OAAO,CAAC,OAAO,EAAEC,KAAK,EAAE;YACjC,MAAMJ,IAAI2B,EAAE,CAACvB,MAAMI,IAAI,EAAE;gBACxBE,WAAWN,MAAMM,SAAS,IAAIkB;gBAC9BC,OAAOzB,MAAMyB,KAAK,IAAID;YACvB;YACA,OAAO,CAAC;QACT;IACD;AACD"}
@@ -0,0 +1,2 @@
1
+ export { createFileSystemContractImpl } from "./createFileSystemContractImpl.js";
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../src/fs/orpc/server/index.ts"],"sourcesContent":["export { createFileSystemContractImpl } from './createFileSystemContractImpl';\n"],"names":["createFileSystemContractImpl"],"mappings":"AAAA,SAASA,4BAA4B,QAAQ,iCAAiC"}