@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
|
@@ -1,95 +1,97 @@
|
|
|
1
|
-
import { z } from
|
|
1
|
+
import { z } from 'zod/v4';
|
|
2
2
|
export const ResourceStatus = Object.freeze({
|
|
3
|
-
|
|
4
|
-
|
|
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
|
-
export const ResourceStatusSchema = z.union([
|
|
48
|
-
z.literal(ResourceStatus.Active).describe('活跃'),
|
|
49
|
-
z.literal(ResourceStatus.Approved).describe('已通过'),
|
|
50
|
-
z.literal(ResourceStatus.Cancelled).describe('已取消'),
|
|
51
|
-
z.literal(ResourceStatus.Closed).describe('已关闭'),
|
|
52
|
-
z.literal(ResourceStatus.Completed).describe('已完成'),
|
|
53
|
-
z.literal(ResourceStatus.Confirmed).describe('已确认'),
|
|
54
|
-
z.literal(ResourceStatus.Contacted).describe('已联系'),
|
|
55
|
-
z.literal(ResourceStatus.Contacting).describe('联系中'),
|
|
56
|
-
z.literal(ResourceStatus.Deleted).describe('已删除'),
|
|
57
|
-
z.literal(ResourceStatus.Denied).describe('已拒绝'),
|
|
58
|
-
z.literal(ResourceStatus.Disabled).describe('已禁用'),
|
|
59
|
-
z.literal(ResourceStatus.Disqualified).describe('不合格'),
|
|
60
|
-
z.literal(ResourceStatus.Draft).describe('草稿'),
|
|
61
|
-
z.literal(ResourceStatus.Enabled).describe('已启用'),
|
|
62
|
-
z.literal(ResourceStatus.Expired).describe('已过期'),
|
|
63
|
-
z.literal(ResourceStatus.InProgress).describe('进行中'),
|
|
64
|
-
z.literal(ResourceStatus.Inactive).describe('停用'),
|
|
65
|
-
z.literal(ResourceStatus.Initial).describe('初始'),
|
|
66
|
-
z.literal(ResourceStatus.Lost).describe('已失去'),
|
|
67
|
-
z.literal(ResourceStatus.New).describe('新建'),
|
|
68
|
-
z.literal(ResourceStatus.Nurturing).describe('培育中'),
|
|
69
|
-
z.literal(ResourceStatus.OnHold).describe('搁置'),
|
|
70
|
-
z.literal(ResourceStatus.Open).describe('开放'),
|
|
71
|
-
z.literal(ResourceStatus.Overdue).describe('逾期'),
|
|
72
|
-
z.literal(ResourceStatus.Paid).describe('已支付'),
|
|
73
|
-
z.literal(ResourceStatus.PartiallyPaid).describe('部分支付'),
|
|
74
|
-
z.literal(ResourceStatus.Pending).describe('待审核'),
|
|
75
|
-
z.literal(ResourceStatus.PendingAcceptance).describe('待接受'),
|
|
76
|
-
z.literal(ResourceStatus.PendingApproval).describe('待批准'),
|
|
77
|
-
z.literal(ResourceStatus.PendingConfirmation).describe('待确认'),
|
|
78
|
-
z.literal(ResourceStatus.PendingResubmission).describe('待重新提交'),
|
|
79
|
-
z.literal(ResourceStatus.Posted).describe('已过账'),
|
|
80
|
-
z.literal(ResourceStatus.Published).describe('已发布'),
|
|
81
|
-
z.literal(ResourceStatus.Qualified).describe('已合格'),
|
|
82
|
-
z.literal(ResourceStatus.Rejected).describe('已驳回'),
|
|
83
|
-
z.literal(ResourceStatus.Submitted).describe('已提交'),
|
|
84
|
-
z.literal(ResourceStatus.Suspended).describe('暂停'),
|
|
85
|
-
z.literal(ResourceStatus.Terminated).describe('终止'),
|
|
86
|
-
z.literal(ResourceStatus.Unqualified).describe('未达标'),
|
|
87
|
-
z.literal(ResourceStatus.Void).describe('作废'),
|
|
88
|
-
z.literal(ResourceStatus.Won).describe('已赢得')
|
|
89
|
-
]).meta({
|
|
90
|
-
title: 'ResourceStatus',
|
|
91
|
-
description: '资源状态',
|
|
92
|
-
type: 'string'
|
|
3
|
+
__proto__: null,
|
|
4
|
+
Active: 'Active',
|
|
5
|
+
Approved: 'Approved',
|
|
6
|
+
Cancelled: 'Cancelled',
|
|
7
|
+
Closed: 'Closed',
|
|
8
|
+
Completed: 'Completed',
|
|
9
|
+
Confirmed: 'Confirmed',
|
|
10
|
+
Contacted: 'Contacted',
|
|
11
|
+
Contacting: 'Contacting',
|
|
12
|
+
Deleted: 'Deleted',
|
|
13
|
+
Denied: 'Denied',
|
|
14
|
+
Disabled: 'Disabled',
|
|
15
|
+
Disqualified: 'Disqualified',
|
|
16
|
+
Draft: 'Draft',
|
|
17
|
+
Enabled: 'Enabled',
|
|
18
|
+
Expired: 'Expired',
|
|
19
|
+
Failed: 'Failed',
|
|
20
|
+
InProgress: 'InProgress',
|
|
21
|
+
Inactive: 'Inactive',
|
|
22
|
+
Initial: 'Initial',
|
|
23
|
+
Lost: 'Lost',
|
|
24
|
+
New: 'New',
|
|
25
|
+
Nurturing: 'Nurturing',
|
|
26
|
+
OnHold: 'OnHold',
|
|
27
|
+
Open: 'Open',
|
|
28
|
+
Overdue: 'Overdue',
|
|
29
|
+
Paid: 'Paid',
|
|
30
|
+
PartiallyPaid: 'PartiallyPaid',
|
|
31
|
+
Pending: 'Pending',
|
|
32
|
+
PendingAcceptance: 'PendingAcceptance',
|
|
33
|
+
PendingApproval: 'PendingApproval',
|
|
34
|
+
PendingConfirmation: 'PendingConfirmation',
|
|
35
|
+
PendingResubmission: 'PendingResubmission',
|
|
36
|
+
Posted: 'Posted',
|
|
37
|
+
Published: 'Published',
|
|
38
|
+
Qualified: 'Qualified',
|
|
39
|
+
Rejected: 'Rejected',
|
|
40
|
+
Submitted: 'Submitted',
|
|
41
|
+
Suspended: 'Suspended',
|
|
42
|
+
Terminated: 'Terminated',
|
|
43
|
+
Unqualified: 'Unqualified',
|
|
44
|
+
Void: 'Void',
|
|
45
|
+
Won: 'Won',
|
|
93
46
|
});
|
|
47
|
+
export const ResourceStatusSchema = z
|
|
48
|
+
.union([
|
|
49
|
+
z.literal(ResourceStatus.Active).describe('活跃'),
|
|
50
|
+
z.literal(ResourceStatus.Approved).describe('已通过'),
|
|
51
|
+
z.literal(ResourceStatus.Cancelled).describe('已取消'),
|
|
52
|
+
z.literal(ResourceStatus.Closed).describe('已关闭'),
|
|
53
|
+
z.literal(ResourceStatus.Completed).describe('已完成'),
|
|
54
|
+
z.literal(ResourceStatus.Confirmed).describe('已确认'),
|
|
55
|
+
z.literal(ResourceStatus.Contacted).describe('已联系'),
|
|
56
|
+
z.literal(ResourceStatus.Contacting).describe('联系中'),
|
|
57
|
+
z.literal(ResourceStatus.Deleted).describe('已删除'),
|
|
58
|
+
z.literal(ResourceStatus.Denied).describe('已拒绝'),
|
|
59
|
+
z.literal(ResourceStatus.Disabled).describe('已禁用'),
|
|
60
|
+
z.literal(ResourceStatus.Disqualified).describe('不合格'),
|
|
61
|
+
z.literal(ResourceStatus.Draft).describe('草稿'),
|
|
62
|
+
z.literal(ResourceStatus.Enabled).describe('已启用'),
|
|
63
|
+
z.literal(ResourceStatus.Expired).describe('已过期'),
|
|
64
|
+
z.literal(ResourceStatus.InProgress).describe('进行中'),
|
|
65
|
+
z.literal(ResourceStatus.Inactive).describe('停用'),
|
|
66
|
+
z.literal(ResourceStatus.Initial).describe('初始'),
|
|
67
|
+
z.literal(ResourceStatus.Lost).describe('已失去'),
|
|
68
|
+
z.literal(ResourceStatus.New).describe('新建'),
|
|
69
|
+
z.literal(ResourceStatus.Nurturing).describe('培育中'),
|
|
70
|
+
z.literal(ResourceStatus.OnHold).describe('搁置'),
|
|
71
|
+
z.literal(ResourceStatus.Open).describe('开放'),
|
|
72
|
+
z.literal(ResourceStatus.Overdue).describe('逾期'),
|
|
73
|
+
z.literal(ResourceStatus.Paid).describe('已支付'),
|
|
74
|
+
z.literal(ResourceStatus.PartiallyPaid).describe('部分支付'),
|
|
75
|
+
z.literal(ResourceStatus.Pending).describe('待审核'),
|
|
76
|
+
z.literal(ResourceStatus.PendingAcceptance).describe('待接受'),
|
|
77
|
+
z.literal(ResourceStatus.PendingApproval).describe('待批准'),
|
|
78
|
+
z.literal(ResourceStatus.PendingConfirmation).describe('待确认'),
|
|
79
|
+
z.literal(ResourceStatus.PendingResubmission).describe('待重新提交'),
|
|
80
|
+
z.literal(ResourceStatus.Posted).describe('已过账'),
|
|
81
|
+
z.literal(ResourceStatus.Published).describe('已发布'),
|
|
82
|
+
z.literal(ResourceStatus.Qualified).describe('已合格'),
|
|
83
|
+
z.literal(ResourceStatus.Rejected).describe('已驳回'),
|
|
84
|
+
z.literal(ResourceStatus.Submitted).describe('已提交'),
|
|
85
|
+
z.literal(ResourceStatus.Suspended).describe('暂停'),
|
|
86
|
+
z.literal(ResourceStatus.Terminated).describe('终止'),
|
|
87
|
+
z.literal(ResourceStatus.Unqualified).describe('未达标'),
|
|
88
|
+
z.literal(ResourceStatus.Void).describe('作废'),
|
|
89
|
+
z.literal(ResourceStatus.Won).describe('已赢得'),
|
|
90
|
+
])
|
|
91
|
+
.meta({
|
|
92
|
+
title: 'ResourceStatus',
|
|
93
|
+
description: '资源状态',
|
|
94
|
+
type: 'string',
|
|
95
|
+
});
|
|
94
96
|
|
|
95
|
-
//# sourceMappingURL=ResourceStatus.js.map
|
|
97
|
+
//# sourceMappingURL=ResourceStatus.js.map
|
|
@@ -1,26 +1,28 @@
|
|
|
1
|
-
import { z } from
|
|
1
|
+
import { z } from 'zod/v4';
|
|
2
2
|
export const ResourceType = Object.freeze({
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
});
|
|
12
|
-
export const ResourceTypeSchema = z.union([
|
|
13
|
-
z.literal(ResourceType.User).describe('用户'),
|
|
14
|
-
z.literal(ResourceType.Customer).describe('客户'),
|
|
15
|
-
z.literal(ResourceType.Contact).describe('联系人'),
|
|
16
|
-
z.literal(ResourceType.Account).describe('账户'),
|
|
17
|
-
z.literal(ResourceType.Order).describe('订单'),
|
|
18
|
-
z.literal(ResourceType.Lead).describe('线索'),
|
|
19
|
-
z.literal(ResourceType.Opportunity).describe('商机')
|
|
20
|
-
]).meta({
|
|
21
|
-
title: 'ResourceType',
|
|
22
|
-
description: '资源类型',
|
|
23
|
-
type: 'string'
|
|
3
|
+
__proto__: null,
|
|
4
|
+
User: 'User',
|
|
5
|
+
Customer: 'Customer',
|
|
6
|
+
Contact: 'Contact',
|
|
7
|
+
Account: 'Account',
|
|
8
|
+
Order: 'Order',
|
|
9
|
+
Lead: 'Lead',
|
|
10
|
+
Opportunity: 'Opportunity',
|
|
24
11
|
});
|
|
12
|
+
export const ResourceTypeSchema = z
|
|
13
|
+
.union([
|
|
14
|
+
z.literal(ResourceType.User).describe('用户'),
|
|
15
|
+
z.literal(ResourceType.Customer).describe('客户'),
|
|
16
|
+
z.literal(ResourceType.Contact).describe('联系人'),
|
|
17
|
+
z.literal(ResourceType.Account).describe('账户'),
|
|
18
|
+
z.literal(ResourceType.Order).describe('订单'),
|
|
19
|
+
z.literal(ResourceType.Lead).describe('线索'),
|
|
20
|
+
z.literal(ResourceType.Opportunity).describe('商机'),
|
|
21
|
+
])
|
|
22
|
+
.meta({
|
|
23
|
+
title: 'ResourceType',
|
|
24
|
+
description: '资源类型',
|
|
25
|
+
type: 'string',
|
|
26
|
+
});
|
|
25
27
|
|
|
26
|
-
//# sourceMappingURL=ResourceType.js.map
|
|
28
|
+
//# sourceMappingURL=ResourceType.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export {
|
|
2
|
-
export {
|
|
3
|
-
export {
|
|
4
|
-
export {
|
|
5
|
-
export {
|
|
1
|
+
export { AnyResourceSchema } from './AnyResourceSchema.js';
|
|
2
|
+
export { BaseResourceSchema } from './BaseResourceSchema.js';
|
|
3
|
+
export { ResourceActionDataSchema, ResourceActionType, ResourceActionTypeSchema } from './ResourceActionType.js';
|
|
4
|
+
export { ResourceStatus, ResourceStatusSchema } from './ResourceStatus.js';
|
|
5
|
+
export { rz } from './types.js';
|
|
6
6
|
//# sourceMappingURL=index.js.map
|
|
@@ -1,9 +1,13 @@
|
|
|
1
|
-
import { isValid } from
|
|
2
|
-
import dayjs from
|
|
3
|
-
import { z } from
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
import { isValid } from 'date-fns';
|
|
2
|
+
import dayjs from 'dayjs';
|
|
3
|
+
import { z } from 'zod/v4';
|
|
4
|
+
|
|
5
|
+
const TypeIdSchema = z
|
|
6
|
+
.string()
|
|
7
|
+
.regex(/^[a-zA-Z0-9]+_[a-zA-Z0-9]+$/, {
|
|
8
|
+
error: 'ID格式错误',
|
|
9
|
+
})
|
|
10
|
+
.describe('ID');
|
|
7
11
|
/*
|
|
8
12
|
XXX-XXX-XXXX
|
|
9
13
|
National: (XXX) XXX-XXXX
|
|
@@ -25,61 +29,88 @@ XXXXXXXXXXX
|
|
|
25
29
|
|
|
26
30
|
https://uibakery.io/regex-library/phone-number
|
|
27
31
|
https://fakerjs.dev/api/phone
|
|
28
|
-
*/ const PhoneNumberSchema = z
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
32
|
+
*/ const PhoneNumberSchema = z
|
|
33
|
+
.string()
|
|
34
|
+
.trim()
|
|
35
|
+
.max(20)
|
|
36
|
+
.regex(/(^$)|(^[0-9]*$)/, {
|
|
37
|
+
error: '电话号码只能包含数字',
|
|
38
|
+
})
|
|
39
|
+
.meta({
|
|
40
|
+
format: 'phone',
|
|
41
|
+
});
|
|
33
42
|
function resourceIdOf(entity) {
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
43
|
+
return rz.resourceId.meta({
|
|
44
|
+
'x-ref-entity': entity,
|
|
45
|
+
});
|
|
37
46
|
}
|
|
38
47
|
// allow empty string
|
|
39
|
-
const JsonDateSchema = z.coerce
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
})
|
|
48
|
+
const JsonDateSchema = z.coerce
|
|
49
|
+
.string()
|
|
50
|
+
.trim()
|
|
51
|
+
.overwrite((v) => {
|
|
52
|
+
if (v && !/^\d{4}-\d{2}-\d{2}$/.test(v)) {
|
|
53
|
+
let val = dayjs(v);
|
|
54
|
+
if (val.isValid()) {
|
|
55
|
+
return val.format('YYYY-MM-DD');
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
return v;
|
|
59
|
+
})
|
|
60
|
+
.regex(/(^$)|(^\d{4}-\d{2}-\d{2}$)/, {
|
|
61
|
+
error: '错误的日期格式',
|
|
62
|
+
})
|
|
63
|
+
.refine((value) => !value || isValid(new Date(value)), {
|
|
64
|
+
error: '错误的日期',
|
|
65
|
+
})
|
|
66
|
+
.nullish()
|
|
67
|
+
.overwrite((v) => v || undefined)
|
|
68
|
+
.meta({
|
|
69
|
+
format: 'date',
|
|
70
|
+
});
|
|
54
71
|
const JsonDateTimeSchema = z.coerce.date().meta({
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
});
|
|
58
|
-
const LoginNameSchema = z.string().trim().regex(/^[a-z0-9]{3,16}$/, {
|
|
59
|
-
error: '登录名只能包含小写字母和数字,长度为3-16位'
|
|
72
|
+
format: 'date-time',
|
|
73
|
+
type: 'string',
|
|
60
74
|
});
|
|
75
|
+
const LoginNameSchema = z
|
|
76
|
+
.string()
|
|
77
|
+
.trim()
|
|
78
|
+
.regex(/^[a-z0-9]{3,16}$/, {
|
|
79
|
+
error: '登录名只能包含小写字母和数字,长度为3-16位',
|
|
80
|
+
});
|
|
61
81
|
// maybe check valid cjk
|
|
62
|
-
const FriendlyNameSchema = z
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
82
|
+
const FriendlyNameSchema = z
|
|
83
|
+
.string()
|
|
84
|
+
.trim()
|
|
85
|
+
.max(50)
|
|
86
|
+
.refine((v) => !/\p{C}/u.test(v), {
|
|
87
|
+
message: '包含无效字符',
|
|
88
|
+
})
|
|
89
|
+
.describe('名称');
|
|
90
|
+
const PasswordSchema = z
|
|
91
|
+
.string()
|
|
92
|
+
.min(6, {
|
|
93
|
+
error: '密码长度至少 6 位',
|
|
94
|
+
})
|
|
95
|
+
.max(36, {
|
|
96
|
+
error: '密码长度最多 36 位',
|
|
97
|
+
})
|
|
98
|
+
.regex(/^\S*$/, {
|
|
99
|
+
error: '密码不能包含空格',
|
|
100
|
+
})
|
|
101
|
+
.describe('密码')
|
|
102
|
+
.meta({
|
|
103
|
+
sensitive: true,
|
|
104
|
+
});
|
|
74
105
|
export const rz = {
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
106
|
+
resourceIdOf: resourceIdOf,
|
|
107
|
+
date: JsonDateSchema,
|
|
108
|
+
dateTime: JsonDateTimeSchema,
|
|
109
|
+
resourceId: TypeIdSchema,
|
|
110
|
+
phoneNumber: PhoneNumberSchema,
|
|
111
|
+
loginName: LoginNameSchema,
|
|
112
|
+
password: PasswordSchema,
|
|
113
|
+
friendlyName: FriendlyNameSchema,
|
|
83
114
|
};
|
|
84
115
|
|
|
85
|
-
//# sourceMappingURL=types.js.map
|
|
116
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -1,14 +1,17 @@
|
|
|
1
|
-
import { describe, it } from
|
|
2
|
-
import { createSchemaData, toJsonSchema } from
|
|
3
|
-
import { renderJsonSchemaToMarkdownDoc } from
|
|
4
|
-
import { AnyResourceSchema } from
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
1
|
+
import { describe, it } from 'vitest';
|
|
2
|
+
import { createSchemaData, toJsonSchema } from '../../schema/index.js';
|
|
3
|
+
import { renderJsonSchemaToMarkdownDoc } from '../../tools/renderJsonSchemaToMarkdownDoc.js';
|
|
4
|
+
import { AnyResourceSchema } from './AnyResourceSchema.js';
|
|
5
|
+
|
|
6
|
+
describe('schema', () => {
|
|
7
|
+
it('should be convert to jsonschema', () => {
|
|
8
|
+
console.log(renderJsonSchemaToMarkdownDoc(toJsonSchema(AnyResourceSchema)));
|
|
9
|
+
});
|
|
10
|
+
it('should create from schema', () => {
|
|
11
|
+
console.log(
|
|
12
|
+
createSchemaData(AnyResourceSchema, {
|
|
13
|
+
all: true,
|
|
14
|
+
}),
|
|
15
|
+
);
|
|
16
|
+
});
|
|
14
17
|
});
|
package/lib/s3/formatS3Url.js
CHANGED
|
@@ -1,65 +1,65 @@
|
|
|
1
1
|
function isValidBucketName(bucket) {
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
const bucketRegex = /^[a-z0-9][a-z0-9.-]{1,61}[a-z0-9]$/;
|
|
3
|
+
return bucketRegex.test(bucket) && !bucket.includes('..') && !bucket.includes('.-') && !bucket.includes('-.');
|
|
4
4
|
}
|
|
5
5
|
export function formatS3Url(o, { credentials, useParams } = {}) {
|
|
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
|
-
|
|
62
|
-
|
|
6
|
+
if (!o || typeof o !== 'object') {
|
|
7
|
+
throw new Error('S3 options must be an object');
|
|
8
|
+
}
|
|
9
|
+
if (!o.endpoint) {
|
|
10
|
+
throw new Error('Endpoint is required');
|
|
11
|
+
}
|
|
12
|
+
let url;
|
|
13
|
+
let ep = o.endpoint || 's3.amazonaws.com';
|
|
14
|
+
try {
|
|
15
|
+
if (URL.canParse(ep)) {
|
|
16
|
+
url = new URL(ep);
|
|
17
|
+
} else {
|
|
18
|
+
url = new URL(`https://${ep}`);
|
|
19
|
+
}
|
|
20
|
+
} catch (_error) {
|
|
21
|
+
throw new Error(`Invalid endpoint: ${ep}`);
|
|
22
|
+
}
|
|
23
|
+
const { useSsl = true, region, pathStyle, port, accessKeyId, secretAccessKey, bucket } = o;
|
|
24
|
+
url.protocol = useSsl ? 'https:' : 'http:';
|
|
25
|
+
if (credentials) {
|
|
26
|
+
if (accessKeyId && secretAccessKey) {
|
|
27
|
+
url.username = encodeURIComponent(accessKeyId);
|
|
28
|
+
url.password = encodeURIComponent(secretAccessKey);
|
|
29
|
+
} else {
|
|
30
|
+
throw new Error('Access Key ID and Secret Access Key are required for credentials');
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
if (useParams) {
|
|
34
|
+
if (region) {
|
|
35
|
+
url.searchParams.set('region', region);
|
|
36
|
+
}
|
|
37
|
+
if (pathStyle !== undefined) {
|
|
38
|
+
url.searchParams.set('pathStyle', String(pathStyle));
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
if (port) {
|
|
42
|
+
const portNum = Number(port);
|
|
43
|
+
if (Number.isNaN(portNum) || portNum < 1 || portNum > 65535) {
|
|
44
|
+
throw new Error('Port must be a valid number between 1 and 65535');
|
|
45
|
+
}
|
|
46
|
+
url.port = String(portNum);
|
|
47
|
+
}
|
|
48
|
+
if (bucket) {
|
|
49
|
+
if (!isValidBucketName(bucket)) {
|
|
50
|
+
throw new Error(`Invalid bucket name: ${bucket}`);
|
|
51
|
+
}
|
|
52
|
+
if (pathStyle) {
|
|
53
|
+
url.pathname = `/${bucket}${url.pathname}`;
|
|
54
|
+
} else {
|
|
55
|
+
// Check if bucket is already in hostname (virtual-hosted style)
|
|
56
|
+
const bucketPattern = new RegExp(`^${bucket.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')}\\.`);
|
|
57
|
+
if (!bucketPattern.test(url.hostname)) {
|
|
58
|
+
url.hostname = `${bucket}.${url.hostname}`;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
return url.toString();
|
|
63
63
|
}
|
|
64
64
|
|
|
65
|
-
//# sourceMappingURL=formatS3Url.js.map
|
|
65
|
+
//# sourceMappingURL=formatS3Url.js.map
|