@wener/common 2.0.5 → 2.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/ai/qwen3vl/index.js +1 -1
- package/lib/ai/qwen3vl/utils.js +15 -15
- package/lib/ai/vision/DocLayoutElementTypeSchema.js +22 -22
- package/lib/ai/vision/ImageAnnotationSchema.js +63 -47
- package/lib/ai/vision/index.js +2 -2
- package/lib/ai/vision/resolveImageAnnotation.js +81 -95
- package/lib/cn/ChineseResidentIdNo.js +55 -41
- package/lib/cn/ChineseResidentIdNo.mod.js +6 -1
- package/lib/cn/ChineseResidentIdNo.test.js +22 -21
- package/lib/cn/DivisionCode.js +220 -235
- package/lib/cn/DivisionCode.mod.js +6 -1
- package/lib/cn/DivisionCode.test.js +92 -121
- package/lib/cn/Mod11.js +18 -37
- package/lib/cn/Mod31.js +23 -41
- package/lib/cn/UnifiedSocialCreditCode.js +143 -137
- package/lib/cn/UnifiedSocialCreditCode.mod.js +6 -1
- package/lib/cn/UnifiedSocialCreditCode.test.js +21 -15
- package/lib/cn/formatChineseAmount.js +46 -71
- package/lib/cn/index.js +6 -6
- package/lib/cn/mod.js +5 -3
- package/lib/cn/parseChineseNumber.js +81 -85
- package/lib/cn/parseChineseNumber.test.js +183 -261
- package/lib/cn/pinyin/cartesianProduct.js +19 -19
- package/lib/cn/pinyin/cartesianProduct.test.js +78 -178
- package/lib/cn/pinyin/loader.js +13 -11
- package/lib/cn/pinyin/preload.js +2 -1
- package/lib/cn/pinyin/toPinyin.test.js +149 -161
- package/lib/cn/pinyin/toPinyinPure.js +28 -23
- package/lib/cn/pinyin/transform.js +11 -11
- package/lib/cn/types.d.js +2 -2
- package/lib/consola/createStandardConsolaReporter.js +14 -15
- package/lib/consola/formatLogObject.js +149 -133
- package/lib/consola/formatLogObject.test.js +167 -178
- package/lib/consola/index.js +2 -2
- package/lib/data/formatSort.js +14 -12
- package/lib/data/formatSort.test.js +33 -33
- package/lib/data/index.js +3 -3
- package/lib/data/maybeNumber.js +23 -23
- package/lib/data/parseSort.js +75 -68
- package/lib/data/parseSort.test.js +196 -187
- package/lib/data/resolvePagination.js +38 -39
- package/lib/data/resolvePagination.test.js +228 -218
- package/lib/data/types.d.js +2 -2
- package/lib/dayjs/dayjs.js +20 -20
- package/lib/dayjs/formatDuration.js +56 -56
- package/lib/dayjs/formatDuration.test.js +63 -77
- package/lib/dayjs/index.js +4 -4
- package/lib/dayjs/parseDuration.js +21 -26
- package/lib/dayjs/parseRelativeTime.js +65 -66
- package/lib/dayjs/parseRelativeTime.test.js +227 -243
- package/lib/dayjs/resolveRelativeTime.js +73 -72
- package/lib/dayjs/resolveRelativeTime.test.js +296 -307
- package/lib/decimal/index.js +1 -1
- package/lib/decimal/parseDecimal.js +12 -12
- package/lib/drain3/Drain.js +303 -338
- package/lib/drain3/LogCluster.js +25 -25
- package/lib/drain3/Node.js +24 -24
- package/lib/drain3/TemplateMiner.js +197 -196
- package/lib/drain3/index.js +5 -5
- package/lib/drain3/persistence/FilePersistence.js +19 -19
- package/lib/drain3/persistence/MemoryPersistence.js +8 -8
- package/lib/drain3/persistence/PersistenceHandler.js +2 -2
- package/lib/drain3/types.js +2 -2
- package/lib/emittery/emitter.js +7 -7
- package/lib/emittery/index.js +1 -1
- package/lib/foundation/schema/SexType.js +15 -12
- package/lib/foundation/schema/index.js +1 -1
- package/lib/foundation/schema/parseSexType.js +15 -16
- package/lib/foundation/schema/types.js +8 -6
- package/lib/fs/FileSystemError.js +18 -18
- package/lib/fs/IFileSystem.d.js +2 -2
- package/lib/fs/MemoryFileSystem.test.js +172 -181
- package/lib/fs/createBrowserFileSystem.js +222 -235
- package/lib/fs/createMemoryFileSystem.js +472 -510
- package/lib/fs/createSandboxFileSystem.js +102 -101
- package/lib/fs/createWebDavFileSystem.js +162 -149
- package/lib/fs/createWebFileSystem.js +197 -220
- package/lib/fs/findMimeType.js +14 -14
- package/lib/fs/index.js +7 -7
- package/lib/fs/minio/createMinioFileSystem.js +959 -956
- package/lib/fs/minio/index.js +1 -1
- package/lib/fs/orpc/FileSystemContract.js +57 -57
- package/lib/fs/orpc/createContractClientFileSystem.js +88 -88
- package/lib/fs/orpc/index.js +2 -2
- package/lib/fs/orpc/server/createFileSystemContractImpl.js +62 -60
- package/lib/fs/orpc/server/index.js +1 -1
- package/lib/fs/s3/createS3MiniFileSystem.js +756 -737
- package/lib/fs/s3/index.js +1 -1
- package/lib/fs/s3/s3mini.test.js +524 -553
- package/lib/fs/scandir.js +56 -56
- package/lib/fs/server/createDatabaseFileSystem.js +834 -741
- package/lib/fs/server/createNodeFileSystem.js +407 -405
- package/lib/fs/server/dbfs.test.js +201 -214
- package/lib/fs/server/index.js +1 -1
- package/lib/fs/server/loadTestDatabase.js +40 -43
- package/lib/fs/tests/runFileSystemTest.js +352 -316
- package/lib/fs/types.js +17 -20
- package/lib/fs/utils/getFileUrl.js +24 -30
- package/lib/fs/utils.js +17 -17
- package/lib/fs/webdav/index.js +1 -1
- package/lib/index.js +2 -2
- package/lib/jsonschema/JsonSchema.js +216 -155
- package/lib/jsonschema/JsonSchema.test.js +123 -124
- package/lib/jsonschema/forEachJsonSchema.js +41 -41
- package/lib/jsonschema/index.js +2 -2
- package/lib/jsonschema/types.d.js +2 -2
- package/lib/meta/defineFileType.js +32 -38
- package/lib/meta/defineInit.js +39 -35
- package/lib/meta/defineMetadata.js +37 -34
- package/lib/meta/defineMetadata.test.js +13 -12
- package/lib/meta/index.js +3 -3
- package/lib/orpc/createOpenApiContractClient.js +26 -24
- package/lib/orpc/createRpcContractClient.js +37 -31
- package/lib/orpc/index.js +2 -2
- package/lib/orpc/resolveLinkPlugins.js +25 -25
- package/lib/password/PHC.js +187 -189
- package/lib/password/PHC.test.js +517 -535
- package/lib/password/Password.js +85 -80
- package/lib/password/Password.test.js +330 -364
- package/lib/password/createArgon2PasswordAlgorithm.js +50 -51
- package/lib/password/createBase64PasswordAlgorithm.js +11 -11
- package/lib/password/createBcryptPasswordAlgorithm.js +20 -18
- package/lib/password/createPBKDF2PasswordAlgorithm.js +65 -52
- package/lib/password/createScryptPasswordAlgorithm.js +74 -63
- package/lib/password/index.js +5 -5
- package/lib/password/server/index.js +1 -1
- package/lib/resource/Identifiable.js +2 -2
- package/lib/resource/ListQuery.js +42 -42
- package/lib/resource/getTitleOfResource.js +5 -5
- package/lib/resource/index.js +2 -2
- package/lib/resource/schema/AnyResourceSchema.js +91 -89
- package/lib/resource/schema/BaseResourceSchema.js +26 -26
- package/lib/resource/schema/ResourceActionType.js +117 -115
- package/lib/resource/schema/ResourceStatus.js +94 -92
- package/lib/resource/schema/ResourceType.js +25 -23
- package/lib/resource/schema/index.js +5 -5
- package/lib/resource/schema/types.js +86 -55
- package/lib/resource/schema/types.test.js +16 -13
- package/lib/s3/formatS3Url.js +60 -60
- package/lib/s3/formatS3Url.test.js +238 -261
- package/lib/s3/index.js +2 -2
- package/lib/s3/parseS3Url.js +61 -60
- package/lib/s3/parseS3Url.test.js +270 -269
- package/lib/schema/SchemaRegistry.js +41 -42
- package/lib/schema/SchemaRegistry.mod.js +1 -1
- package/lib/schema/TypeSchema.d.js +2 -2
- package/lib/schema/createSchemaData.js +113 -67
- package/lib/schema/findJsonSchemaByPath.js +28 -23
- package/lib/schema/formatZodError.js +112 -131
- package/lib/schema/formatZodError.test.js +192 -195
- package/lib/schema/getSchemaCache.js +7 -7
- package/lib/schema/getSchemaOptions.js +17 -16
- package/lib/schema/index.js +6 -6
- package/lib/schema/toJsonSchema.js +195 -189
- package/lib/schema/toJsonSchema.test.js +34 -26
- package/lib/schema/validate.js +105 -96
- package/lib/tools/generateSchema.js +40 -40
- package/lib/tools/renderJsonSchemaToMarkdownDoc.js +74 -74
- package/lib/utils/buildBaseUrl.js +8 -8
- package/lib/utils/buildRedactorFormSchema.js +54 -53
- package/lib/utils/getEstimateProcessTime.js +24 -19
- package/lib/utils/index.js +3 -3
- package/lib/utils/resolveFeatureOptions.js +9 -9
- package/package.json +14 -14
- package/src/ai/vision/index.ts +2 -2
- package/src/cn/index.ts +1 -2
- package/src/consola/index.ts +1 -1
- package/src/data/index.ts +3 -4
- package/src/data/resolvePagination.ts +2 -2
- package/src/dayjs/formatDuration.ts +8 -9
- package/src/dayjs/index.ts +1 -1
- package/src/dayjs/parseRelativeTime.ts +1 -1
- package/src/dayjs/resolveRelativeTime.ts +1 -1
- package/src/drain3/Drain.test.ts +2 -2
- package/src/drain3/index.ts +2 -4
- package/src/fs/createWebDavFileSystem.ts +2 -7
- package/src/fs/createWebFileSystem.ts +1 -1
- package/src/fs/index.ts +4 -4
- package/src/fs/minio/createMinioFileSystem.ts +2 -2
- package/src/fs/minio/index.ts +1 -1
- package/src/fs/s3/createS3MiniFileSystem.ts +1 -1
- package/src/fs/server/createDatabaseFileSystem.ts +84 -120
- package/src/fs/server/dbfs.test.ts +14 -10
- package/src/fs/server/index.ts +1 -0
- package/src/fs/server/loadTestDatabase.ts +8 -119
- package/src/jsonschema/index.ts +1 -1
- package/src/meta/index.ts +2 -3
- package/src/orm/createSqliteDialect.ts +17 -0
- package/src/orm/index.ts +1 -0
- package/src/orpc/createOpenApiContractClient.ts +1 -1
- package/src/orpc/index.ts +1 -1
- package/src/password/createArgon2PasswordAlgorithm.ts +1 -1
- package/src/password/index.ts +2 -2
- package/src/resource/index.ts +3 -3
- package/src/resource/schema/index.ts +4 -4
- package/src/s3/index.ts +1 -1
- package/src/schema/SchemaRegistry.ts +1 -1
- package/src/schema/createSchemaData.ts +1 -1
- package/src/schema/findJsonSchemaByPath.ts +1 -1
- package/src/schema/index.ts +5 -5
- package/src/schema/validate.ts +1 -1
- package/src/utils/buildRedactorFormSchema.ts +1 -1
- package/src/utils/formatNumber.ts +18 -0
- package/src/utils/formatPercent.ts +17 -0
- package/src/utils/index.ts +3 -3
- package/src/utils/resolveFeatureOptions.ts +1 -1
package/lib/fs/minio/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { createMinioFileSystem } from
|
|
1
|
+
export { createMinioFileSystem } from './createMinioFileSystem.js';
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
|
@@ -1,93 +1,93 @@
|
|
|
1
|
-
import { oc } from
|
|
2
|
-
import { z } from
|
|
3
|
-
import { FileKindSchema } from
|
|
1
|
+
import { oc } from '@orpc/contract';
|
|
2
|
+
import { z } from 'zod/v4';
|
|
3
|
+
import { FileKindSchema } from '../types.js';
|
|
4
4
|
export const FileStatSchema = z.object({
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
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
12
|
});
|
|
13
13
|
export const ReaddirInputSchema = z.object({
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
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
21
|
});
|
|
22
22
|
const ReaddirOutputSchema = z.object({
|
|
23
|
-
|
|
23
|
+
data: FileStatSchema.array(),
|
|
24
24
|
});
|
|
25
25
|
const StatInputSchema = z.object({
|
|
26
|
-
|
|
26
|
+
path: z.string(),
|
|
27
27
|
});
|
|
28
28
|
const StatOutputSchema = z.object({
|
|
29
|
-
|
|
29
|
+
data: FileStatSchema,
|
|
30
30
|
});
|
|
31
31
|
const CreateDirectoryInputSchema = z.object({
|
|
32
|
-
|
|
33
|
-
|
|
32
|
+
path: z.string(),
|
|
33
|
+
recursive: z.boolean().nullish(),
|
|
34
34
|
});
|
|
35
35
|
const CreateDirectoryOutputSchema = z.object({}).default({});
|
|
36
36
|
const RenameInputSchema = z.object({
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
37
|
+
oldPath: z.string(),
|
|
38
|
+
newPath: z.string(),
|
|
39
|
+
overwrite: z.boolean().nullish(),
|
|
40
40
|
});
|
|
41
41
|
const RenameOutputSchema = z.object({}).default({});
|
|
42
42
|
const ExistsInputSchema = z.object({
|
|
43
|
-
|
|
43
|
+
path: z.string(),
|
|
44
44
|
});
|
|
45
45
|
const ExistsOutputSchema = z.object({
|
|
46
|
-
|
|
46
|
+
data: z.boolean(),
|
|
47
47
|
});
|
|
48
48
|
const CopyInputSchema = z.object({
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
49
|
+
src: z.string(),
|
|
50
|
+
dest: z.string(),
|
|
51
|
+
overwrite: z.boolean().nullish(),
|
|
52
|
+
shallow: z.boolean().nullish(),
|
|
53
53
|
});
|
|
54
54
|
const CopyOutputSchema = z.object({}).default({});
|
|
55
55
|
const ReadFileInputSchema = z.object({
|
|
56
|
-
|
|
56
|
+
path: z.string(),
|
|
57
57
|
});
|
|
58
58
|
const ReadFileOutputSchema = z.object({
|
|
59
|
-
|
|
59
|
+
base64: z.string(),
|
|
60
60
|
});
|
|
61
61
|
const WriteFileInputSchema = z.object({
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
62
|
+
path: z.string(),
|
|
63
|
+
base64: z.string(),
|
|
64
|
+
overwrite: z.boolean().optional(),
|
|
65
65
|
});
|
|
66
66
|
const WriteFileOutputSchema = z.object({});
|
|
67
67
|
const RemoveInputSchema = z.object({
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
68
|
+
path: z.string(),
|
|
69
|
+
recursive: z.boolean().nullish(),
|
|
70
|
+
force: z.boolean().nullish(),
|
|
71
71
|
});
|
|
72
72
|
const RemoveOutputSchema = z.object({}).default({});
|
|
73
73
|
export const FileSystemContract = {
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
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
92
|
};
|
|
93
93
|
//# sourceMappingURL=FileSystemContract.js.map
|
|
@@ -1,93 +1,93 @@
|
|
|
1
|
-
import { ArrayBuffers } from
|
|
2
|
-
import { resolveData } from
|
|
1
|
+
import { ArrayBuffers } from '@wener/utils';
|
|
2
|
+
import { resolveData } from '../utils';
|
|
3
3
|
export function createContractClientFileSystem(client) {
|
|
4
|
-
|
|
4
|
+
return new ContractFS(client);
|
|
5
5
|
}
|
|
6
6
|
let ContractFS = class ContractFS {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
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
91
|
};
|
|
92
92
|
|
|
93
|
-
//# sourceMappingURL=createContractClientFileSystem.js.map
|
|
93
|
+
//# sourceMappingURL=createContractClientFileSystem.js.map
|
package/lib/fs/orpc/index.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { createContractClientFileSystem } from
|
|
2
|
-
export { FileSystemContract } from
|
|
1
|
+
export { createContractClientFileSystem } from './createContractClientFileSystem.js';
|
|
2
|
+
export { FileSystemContract } from './FileSystemContract.js';
|
|
3
3
|
//# sourceMappingURL=index.js.map
|
|
@@ -1,63 +1,65 @@
|
|
|
1
|
-
import { implement } from
|
|
2
|
-
import { ArrayBuffers } from
|
|
3
|
-
import { FileSystemContract } from
|
|
1
|
+
import { implement } from '@orpc/server';
|
|
2
|
+
import { ArrayBuffers } from '@wener/utils';
|
|
3
|
+
import { FileSystemContract } from '../FileSystemContract.js';
|
|
4
4
|
export function createFileSystemContractImpl(ifs) {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
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(
|
|
44
|
+
await ifs.readFile(input.path, {
|
|
45
|
+
encoding: 'binary',
|
|
46
|
+
}),
|
|
47
|
+
),
|
|
48
|
+
};
|
|
49
|
+
}),
|
|
50
|
+
writeFile: os.writeFile.handler(async ({ input }) => {
|
|
51
|
+
await ifs.writeFile(input.path, Buffer.from(input.base64, 'base64'), {
|
|
52
|
+
overwrite: input.overwrite,
|
|
53
|
+
});
|
|
54
|
+
return {};
|
|
55
|
+
}),
|
|
56
|
+
rm: os.rm.handler(async ({ input }) => {
|
|
57
|
+
await ifs.rm(input.path, {
|
|
58
|
+
recursive: input.recursive ?? undefined,
|
|
59
|
+
force: input.force ?? undefined,
|
|
60
|
+
});
|
|
61
|
+
return {};
|
|
62
|
+
}),
|
|
63
|
+
};
|
|
62
64
|
}
|
|
63
65
|
//# sourceMappingURL=createFileSystemContractImpl.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { createFileSystemContractImpl } from
|
|
1
|
+
export { createFileSystemContractImpl } from './createFileSystemContractImpl.js';
|
|
2
2
|
//# sourceMappingURL=index.js.map
|