@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.
Files changed (206) hide show
  1. package/lib/ai/qwen3vl/index.js +1 -1
  2. package/lib/ai/qwen3vl/utils.js +15 -15
  3. package/lib/ai/vision/DocLayoutElementTypeSchema.js +22 -22
  4. package/lib/ai/vision/ImageAnnotationSchema.js +63 -47
  5. package/lib/ai/vision/index.js +2 -2
  6. package/lib/ai/vision/resolveImageAnnotation.js +81 -95
  7. package/lib/cn/ChineseResidentIdNo.js +55 -41
  8. package/lib/cn/ChineseResidentIdNo.mod.js +6 -1
  9. package/lib/cn/ChineseResidentIdNo.test.js +22 -21
  10. package/lib/cn/DivisionCode.js +220 -235
  11. package/lib/cn/DivisionCode.mod.js +6 -1
  12. package/lib/cn/DivisionCode.test.js +92 -121
  13. package/lib/cn/Mod11.js +18 -37
  14. package/lib/cn/Mod31.js +23 -41
  15. package/lib/cn/UnifiedSocialCreditCode.js +143 -137
  16. package/lib/cn/UnifiedSocialCreditCode.mod.js +6 -1
  17. package/lib/cn/UnifiedSocialCreditCode.test.js +21 -15
  18. package/lib/cn/formatChineseAmount.js +46 -71
  19. package/lib/cn/index.js +6 -6
  20. package/lib/cn/mod.js +5 -3
  21. package/lib/cn/parseChineseNumber.js +81 -85
  22. package/lib/cn/parseChineseNumber.test.js +183 -261
  23. package/lib/cn/pinyin/cartesianProduct.js +19 -19
  24. package/lib/cn/pinyin/cartesianProduct.test.js +78 -178
  25. package/lib/cn/pinyin/loader.js +13 -11
  26. package/lib/cn/pinyin/preload.js +2 -1
  27. package/lib/cn/pinyin/toPinyin.test.js +149 -161
  28. package/lib/cn/pinyin/toPinyinPure.js +28 -23
  29. package/lib/cn/pinyin/transform.js +11 -11
  30. package/lib/cn/types.d.js +2 -2
  31. package/lib/consola/createStandardConsolaReporter.js +14 -15
  32. package/lib/consola/formatLogObject.js +149 -133
  33. package/lib/consola/formatLogObject.test.js +167 -178
  34. package/lib/consola/index.js +2 -2
  35. package/lib/data/formatSort.js +14 -12
  36. package/lib/data/formatSort.test.js +33 -33
  37. package/lib/data/index.js +3 -3
  38. package/lib/data/maybeNumber.js +23 -23
  39. package/lib/data/parseSort.js +75 -68
  40. package/lib/data/parseSort.test.js +196 -187
  41. package/lib/data/resolvePagination.js +38 -39
  42. package/lib/data/resolvePagination.test.js +228 -218
  43. package/lib/data/types.d.js +2 -2
  44. package/lib/dayjs/dayjs.js +20 -20
  45. package/lib/dayjs/formatDuration.js +56 -56
  46. package/lib/dayjs/formatDuration.test.js +63 -77
  47. package/lib/dayjs/index.js +4 -4
  48. package/lib/dayjs/parseDuration.js +21 -26
  49. package/lib/dayjs/parseRelativeTime.js +65 -66
  50. package/lib/dayjs/parseRelativeTime.test.js +227 -243
  51. package/lib/dayjs/resolveRelativeTime.js +73 -72
  52. package/lib/dayjs/resolveRelativeTime.test.js +296 -307
  53. package/lib/decimal/index.js +1 -1
  54. package/lib/decimal/parseDecimal.js +12 -12
  55. package/lib/drain3/Drain.js +303 -338
  56. package/lib/drain3/LogCluster.js +25 -25
  57. package/lib/drain3/Node.js +24 -24
  58. package/lib/drain3/TemplateMiner.js +197 -196
  59. package/lib/drain3/index.js +5 -5
  60. package/lib/drain3/persistence/FilePersistence.js +19 -19
  61. package/lib/drain3/persistence/MemoryPersistence.js +8 -8
  62. package/lib/drain3/persistence/PersistenceHandler.js +2 -2
  63. package/lib/drain3/types.js +2 -2
  64. package/lib/emittery/emitter.js +7 -7
  65. package/lib/emittery/index.js +1 -1
  66. package/lib/foundation/schema/SexType.js +15 -12
  67. package/lib/foundation/schema/index.js +1 -1
  68. package/lib/foundation/schema/parseSexType.js +15 -16
  69. package/lib/foundation/schema/types.js +8 -6
  70. package/lib/fs/FileSystemError.js +18 -18
  71. package/lib/fs/IFileSystem.d.js +2 -2
  72. package/lib/fs/MemoryFileSystem.test.js +172 -181
  73. package/lib/fs/createBrowserFileSystem.js +222 -235
  74. package/lib/fs/createMemoryFileSystem.js +472 -510
  75. package/lib/fs/createSandboxFileSystem.js +102 -101
  76. package/lib/fs/createWebDavFileSystem.js +162 -149
  77. package/lib/fs/createWebFileSystem.js +197 -220
  78. package/lib/fs/findMimeType.js +14 -14
  79. package/lib/fs/index.js +7 -7
  80. package/lib/fs/minio/createMinioFileSystem.js +959 -956
  81. package/lib/fs/minio/index.js +1 -1
  82. package/lib/fs/orpc/FileSystemContract.js +57 -57
  83. package/lib/fs/orpc/createContractClientFileSystem.js +88 -88
  84. package/lib/fs/orpc/index.js +2 -2
  85. package/lib/fs/orpc/server/createFileSystemContractImpl.js +62 -60
  86. package/lib/fs/orpc/server/index.js +1 -1
  87. package/lib/fs/s3/createS3MiniFileSystem.js +756 -737
  88. package/lib/fs/s3/index.js +1 -1
  89. package/lib/fs/s3/s3mini.test.js +524 -553
  90. package/lib/fs/scandir.js +56 -56
  91. package/lib/fs/server/createDatabaseFileSystem.js +834 -741
  92. package/lib/fs/server/createNodeFileSystem.js +407 -405
  93. package/lib/fs/server/dbfs.test.js +201 -214
  94. package/lib/fs/server/index.js +1 -1
  95. package/lib/fs/server/loadTestDatabase.js +40 -43
  96. package/lib/fs/tests/runFileSystemTest.js +352 -316
  97. package/lib/fs/types.js +17 -20
  98. package/lib/fs/utils/getFileUrl.js +24 -30
  99. package/lib/fs/utils.js +17 -17
  100. package/lib/fs/webdav/index.js +1 -1
  101. package/lib/index.js +2 -2
  102. package/lib/jsonschema/JsonSchema.js +216 -155
  103. package/lib/jsonschema/JsonSchema.test.js +123 -124
  104. package/lib/jsonschema/forEachJsonSchema.js +41 -41
  105. package/lib/jsonschema/index.js +2 -2
  106. package/lib/jsonschema/types.d.js +2 -2
  107. package/lib/meta/defineFileType.js +32 -38
  108. package/lib/meta/defineInit.js +39 -35
  109. package/lib/meta/defineMetadata.js +37 -34
  110. package/lib/meta/defineMetadata.test.js +13 -12
  111. package/lib/meta/index.js +3 -3
  112. package/lib/orpc/createOpenApiContractClient.js +26 -24
  113. package/lib/orpc/createRpcContractClient.js +37 -31
  114. package/lib/orpc/index.js +2 -2
  115. package/lib/orpc/resolveLinkPlugins.js +25 -25
  116. package/lib/password/PHC.js +187 -189
  117. package/lib/password/PHC.test.js +517 -535
  118. package/lib/password/Password.js +85 -80
  119. package/lib/password/Password.test.js +330 -364
  120. package/lib/password/createArgon2PasswordAlgorithm.js +50 -51
  121. package/lib/password/createBase64PasswordAlgorithm.js +11 -11
  122. package/lib/password/createBcryptPasswordAlgorithm.js +20 -18
  123. package/lib/password/createPBKDF2PasswordAlgorithm.js +65 -52
  124. package/lib/password/createScryptPasswordAlgorithm.js +74 -63
  125. package/lib/password/index.js +5 -5
  126. package/lib/password/server/index.js +1 -1
  127. package/lib/resource/Identifiable.js +2 -2
  128. package/lib/resource/ListQuery.js +42 -42
  129. package/lib/resource/getTitleOfResource.js +5 -5
  130. package/lib/resource/index.js +2 -2
  131. package/lib/resource/schema/AnyResourceSchema.js +91 -89
  132. package/lib/resource/schema/BaseResourceSchema.js +26 -26
  133. package/lib/resource/schema/ResourceActionType.js +117 -115
  134. package/lib/resource/schema/ResourceStatus.js +94 -92
  135. package/lib/resource/schema/ResourceType.js +25 -23
  136. package/lib/resource/schema/index.js +5 -5
  137. package/lib/resource/schema/types.js +86 -55
  138. package/lib/resource/schema/types.test.js +16 -13
  139. package/lib/s3/formatS3Url.js +60 -60
  140. package/lib/s3/formatS3Url.test.js +238 -261
  141. package/lib/s3/index.js +2 -2
  142. package/lib/s3/parseS3Url.js +61 -60
  143. package/lib/s3/parseS3Url.test.js +270 -269
  144. package/lib/schema/SchemaRegistry.js +41 -42
  145. package/lib/schema/SchemaRegistry.mod.js +1 -1
  146. package/lib/schema/TypeSchema.d.js +2 -2
  147. package/lib/schema/createSchemaData.js +113 -67
  148. package/lib/schema/findJsonSchemaByPath.js +28 -23
  149. package/lib/schema/formatZodError.js +112 -131
  150. package/lib/schema/formatZodError.test.js +192 -195
  151. package/lib/schema/getSchemaCache.js +7 -7
  152. package/lib/schema/getSchemaOptions.js +17 -16
  153. package/lib/schema/index.js +6 -6
  154. package/lib/schema/toJsonSchema.js +195 -189
  155. package/lib/schema/toJsonSchema.test.js +34 -26
  156. package/lib/schema/validate.js +105 -96
  157. package/lib/tools/generateSchema.js +40 -40
  158. package/lib/tools/renderJsonSchemaToMarkdownDoc.js +74 -74
  159. package/lib/utils/buildBaseUrl.js +8 -8
  160. package/lib/utils/buildRedactorFormSchema.js +54 -53
  161. package/lib/utils/getEstimateProcessTime.js +24 -19
  162. package/lib/utils/index.js +3 -3
  163. package/lib/utils/resolveFeatureOptions.js +9 -9
  164. package/package.json +14 -14
  165. package/src/ai/vision/index.ts +2 -2
  166. package/src/cn/index.ts +1 -2
  167. package/src/consola/index.ts +1 -1
  168. package/src/data/index.ts +3 -4
  169. package/src/data/resolvePagination.ts +2 -2
  170. package/src/dayjs/formatDuration.ts +8 -9
  171. package/src/dayjs/index.ts +1 -1
  172. package/src/dayjs/parseRelativeTime.ts +1 -1
  173. package/src/dayjs/resolveRelativeTime.ts +1 -1
  174. package/src/drain3/Drain.test.ts +2 -2
  175. package/src/drain3/index.ts +2 -4
  176. package/src/fs/createWebDavFileSystem.ts +2 -7
  177. package/src/fs/createWebFileSystem.ts +1 -1
  178. package/src/fs/index.ts +4 -4
  179. package/src/fs/minio/createMinioFileSystem.ts +2 -2
  180. package/src/fs/minio/index.ts +1 -1
  181. package/src/fs/s3/createS3MiniFileSystem.ts +1 -1
  182. package/src/fs/server/createDatabaseFileSystem.ts +84 -120
  183. package/src/fs/server/dbfs.test.ts +14 -10
  184. package/src/fs/server/index.ts +1 -0
  185. package/src/fs/server/loadTestDatabase.ts +8 -119
  186. package/src/jsonschema/index.ts +1 -1
  187. package/src/meta/index.ts +2 -3
  188. package/src/orm/createSqliteDialect.ts +17 -0
  189. package/src/orm/index.ts +1 -0
  190. package/src/orpc/createOpenApiContractClient.ts +1 -1
  191. package/src/orpc/index.ts +1 -1
  192. package/src/password/createArgon2PasswordAlgorithm.ts +1 -1
  193. package/src/password/index.ts +2 -2
  194. package/src/resource/index.ts +3 -3
  195. package/src/resource/schema/index.ts +4 -4
  196. package/src/s3/index.ts +1 -1
  197. package/src/schema/SchemaRegistry.ts +1 -1
  198. package/src/schema/createSchemaData.ts +1 -1
  199. package/src/schema/findJsonSchemaByPath.ts +1 -1
  200. package/src/schema/index.ts +5 -5
  201. package/src/schema/validate.ts +1 -1
  202. package/src/utils/buildRedactorFormSchema.ts +1 -1
  203. package/src/utils/formatNumber.ts +18 -0
  204. package/src/utils/formatPercent.ts +17 -0
  205. package/src/utils/index.ts +3 -3
  206. package/src/utils/resolveFeatureOptions.ts +1 -1
@@ -1,270 +1,271 @@
1
- import { beforeEach, describe, expect, it, vi } from "vitest";
2
- import { parseS3Url } from "./parseS3Url.js";
3
- describe("parseS3Url", function () {
4
- beforeEach(function () {
5
- vi.restoreAllMocks();
6
- });
7
- it("should return undefined for empty URL", function () {
8
- var result = parseS3Url({
9
- url: ""
10
- });
11
- expect(result).toBeUndefined();
12
- });
13
- it("should return undefined for undefined URL", function () {
14
- var result = parseS3Url({
15
- url: undefined
16
- });
17
- expect(result).toBeUndefined();
18
- });
19
- it("should parse basic HTTPS URL", function () {
20
- var result = parseS3Url({
21
- url: "https://s3.amazonaws.com/bucket-name"
22
- });
23
- expect(result).toEqual({
24
- accessKeyId: undefined,
25
- secretAccessKey: undefined,
26
- endpoint: "s3.amazonaws.com",
27
- port: 443,
28
- useSsl: true,
29
- region: undefined,
30
- pathStyle: true,
31
- bucket: "bucket-name"
32
- });
33
- });
34
- it("should parse basic HTTP URL", function () {
35
- var result = parseS3Url({
36
- url: "http://s3.amazonaws.com/bucket-name"
37
- });
38
- expect(result).toEqual({
39
- accessKeyId: undefined,
40
- secretAccessKey: undefined,
41
- endpoint: "s3.amazonaws.com",
42
- port: 80,
43
- useSsl: false,
44
- region: undefined,
45
- pathStyle: true,
46
- bucket: "bucket-name"
47
- });
48
- });
49
- it("should parse S3 protocol URL", function () {
50
- var result = parseS3Url({
51
- url: "s3://s3.amazonaws.com/bucket-name"
52
- });
53
- expect(result).toEqual({
54
- accessKeyId: undefined,
55
- secretAccessKey: undefined,
56
- endpoint: "s3.amazonaws.com",
57
- port: 443,
58
- useSsl: true,
59
- region: undefined,
60
- pathStyle: true,
61
- bucket: "bucket-name"
62
- });
63
- });
64
- it("should parse URL with credentials", function () {
65
- var result = parseS3Url({
66
- url: "https://user:pass@s3.amazonaws.com/bucket-name"
67
- });
68
- expect(result).toEqual({
69
- accessKeyId: "user",
70
- secretAccessKey: "pass",
71
- endpoint: "s3.amazonaws.com",
72
- port: 443,
73
- useSsl: true,
74
- region: undefined,
75
- pathStyle: true,
76
- bucket: "bucket-name"
77
- });
78
- });
79
- it("should parse URL with port", function () {
80
- var result = parseS3Url({
81
- url: "https://s3.amazonaws.com:9000/bucket-name"
82
- });
83
- expect(result).toEqual({
84
- accessKeyId: undefined,
85
- secretAccessKey: undefined,
86
- endpoint: "s3.amazonaws.com",
87
- port: 9000,
88
- useSsl: true,
89
- region: undefined,
90
- pathStyle: true,
91
- bucket: "bucket-name"
92
- });
93
- });
94
- it("should parse URL with region query parameter", function () {
95
- var result = parseS3Url({
96
- url: "https://s3.amazonaws.com/bucket-name?region=us-east-1"
97
- });
98
- expect(result).toEqual({
99
- accessKeyId: undefined,
100
- secretAccessKey: undefined,
101
- endpoint: "s3.amazonaws.com",
102
- port: 443,
103
- useSsl: true,
104
- region: "us-east-1",
105
- pathStyle: true,
106
- bucket: "bucket-name"
107
- });
108
- });
109
- it("should parse URL with pathStyle parameter", function () {
110
- var result = parseS3Url({
111
- url: "https://s3.amazonaws.com/bucket-name?pathStyle=true"
112
- });
113
- expect(result).toEqual({
114
- accessKeyId: undefined,
115
- secretAccessKey: undefined,
116
- endpoint: "s3.amazonaws.com",
117
- port: 443,
118
- useSsl: true,
119
- region: undefined,
120
- pathStyle: true,
121
- bucket: "bucket-name"
122
- });
123
- });
124
- it("should parse URL with pathStyle=false parameter", function () {
125
- var result = parseS3Url({
126
- url: "https://s3.amazonaws.com/bucket-name?pathStyle=false"
127
- });
128
- expect(result).toEqual({
129
- accessKeyId: undefined,
130
- secretAccessKey: undefined,
131
- endpoint: "s3.amazonaws.com",
132
- port: 443,
133
- useSsl: true,
134
- region: undefined,
135
- pathStyle: false,
136
- bucket: "bucket-name"
137
- });
138
- });
139
- it("should detect path style for IP addresses", function () {
140
- var result = parseS3Url({
141
- url: "https://192.168.1.1/bucket-name"
142
- });
143
- expect(result).toEqual({
144
- accessKeyId: undefined,
145
- secretAccessKey: undefined,
146
- endpoint: "192.168.1.1",
147
- port: 443,
148
- useSsl: true,
149
- region: undefined,
150
- pathStyle: true,
151
- bucket: "bucket-name"
152
- });
153
- });
154
- it("should detect path style for IPv6 addresses", function () {
155
- var result = parseS3Url({
156
- url: "https://[2001:db8::1]/bucket-name"
157
- });
158
- expect(result).toEqual({
159
- accessKeyId: undefined,
160
- secretAccessKey: undefined,
161
- endpoint: "[2001:db8::1]",
162
- port: 443,
163
- useSsl: true,
164
- region: undefined,
165
- pathStyle: true,
166
- bucket: "bucket-name"
167
- });
168
- });
169
- it("should parse AWS virtual hosted style URL", function () {
170
- var result = parseS3Url({
171
- url: "https://my-bucket.s3.us-east-1.amazonaws.com"
172
- });
173
- expect(result).toEqual({
174
- accessKeyId: undefined,
175
- secretAccessKey: undefined,
176
- endpoint: "my-bucket.s3.us-east-1.amazonaws.com",
177
- port: 443,
178
- useSsl: true,
179
- region: "us-east-1",
180
- pathStyle: false,
181
- bucket: "my-bucket"
182
- });
183
- });
184
- it("should parse AWS virtual hosted style URL with custom endpoint", function () {
185
- var result = parseS3Url({
186
- url: "https://my-bucket.s3.amazonaws.com"
187
- });
188
- expect(result).toEqual({
189
- accessKeyId: undefined,
190
- secretAccessKey: undefined,
191
- endpoint: "my-bucket.s3.amazonaws.com",
192
- port: 443,
193
- useSsl: true,
194
- region: undefined,
195
- pathStyle: false,
196
- bucket: "my-bucket"
197
- });
198
- });
199
- it("should override parameters with provided options", function () {
200
- var result = parseS3Url({
201
- url: "https://s3.amazonaws.com/bucket-name",
202
- region: "us-west-2",
203
- pathStyle: false
204
- });
205
- expect(result).toEqual({
206
- accessKeyId: undefined,
207
- secretAccessKey: undefined,
208
- endpoint: "s3.amazonaws.com",
209
- port: 443,
210
- useSsl: true,
211
- region: "us-west-2",
212
- pathStyle: false,
213
- bucket: "bucket-name"
214
- });
215
- });
216
- it("should use S3_URL environment variable by default", function () {
217
- vi.stubEnv("S3_URL", "https://env-bucket.s3.amazonaws.com");
218
- var result = parseS3Url();
219
- expect(result).toEqual({
220
- accessKeyId: undefined,
221
- secretAccessKey: undefined,
222
- endpoint: "env-bucket.s3.amazonaws.com",
223
- port: 443,
224
- useSsl: true,
225
- region: undefined,
226
- pathStyle: false,
227
- bucket: "env-bucket"
228
- });
229
- });
230
- it("should throw error for invalid URL", function () {
231
- expect(function () {
232
- return parseS3Url({
233
- url: "invalid-url"
234
- });
235
- }).toThrow("Invalid S3 URL: invalid-url");
236
- });
237
- it("should handle complex URL with multiple parameters", function () {
238
- var result = parseS3Url({
239
- url: "https://user:pass@custom-s3.com:9000/my-bucket?region=us-east-1&pathStyle=true"
240
- });
241
- expect(result).toEqual({
242
- accessKeyId: "user",
243
- secretAccessKey: "pass",
244
- endpoint: "custom-s3.com",
245
- port: 9000,
246
- useSsl: true,
247
- region: "us-east-1",
248
- pathStyle: true,
249
- bucket: "my-bucket"
250
- });
251
- });
252
- it("should ignore undefined and null values in rest parameters", function () {
253
- var result = parseS3Url({
254
- url: "https://s3.amazonaws.com/bucket-name",
255
- region: "us-west-2",
256
- port: undefined,
257
- useSsl: null
258
- });
259
- expect(result).toEqual({
260
- accessKeyId: undefined,
261
- secretAccessKey: undefined,
262
- endpoint: "s3.amazonaws.com",
263
- port: 443,
264
- useSsl: true,
265
- region: "us-west-2",
266
- pathStyle: true,
267
- bucket: "bucket-name"
268
- });
269
- });
1
+ import { beforeEach, describe, expect, it, vi } from 'vitest';
2
+ import { parseS3Url } from './parseS3Url.js';
3
+
4
+ describe('parseS3Url', () => {
5
+ beforeEach(() => {
6
+ vi.restoreAllMocks();
7
+ });
8
+ it('should return undefined for empty URL', () => {
9
+ var result = parseS3Url({
10
+ url: '',
11
+ });
12
+ expect(result).toBeUndefined();
13
+ });
14
+ it('should return undefined for undefined URL', () => {
15
+ var result = parseS3Url({
16
+ url: undefined,
17
+ });
18
+ expect(result).toBeUndefined();
19
+ });
20
+ it('should parse basic HTTPS URL', () => {
21
+ var result = parseS3Url({
22
+ url: 'https://s3.amazonaws.com/bucket-name',
23
+ });
24
+ expect(result).toEqual({
25
+ accessKeyId: undefined,
26
+ secretAccessKey: undefined,
27
+ endpoint: 's3.amazonaws.com',
28
+ port: 443,
29
+ useSsl: true,
30
+ region: undefined,
31
+ pathStyle: true,
32
+ bucket: 'bucket-name',
33
+ });
34
+ });
35
+ it('should parse basic HTTP URL', () => {
36
+ var result = parseS3Url({
37
+ url: 'http://s3.amazonaws.com/bucket-name',
38
+ });
39
+ expect(result).toEqual({
40
+ accessKeyId: undefined,
41
+ secretAccessKey: undefined,
42
+ endpoint: 's3.amazonaws.com',
43
+ port: 80,
44
+ useSsl: false,
45
+ region: undefined,
46
+ pathStyle: true,
47
+ bucket: 'bucket-name',
48
+ });
49
+ });
50
+ it('should parse S3 protocol URL', () => {
51
+ var result = parseS3Url({
52
+ url: 's3://s3.amazonaws.com/bucket-name',
53
+ });
54
+ expect(result).toEqual({
55
+ accessKeyId: undefined,
56
+ secretAccessKey: undefined,
57
+ endpoint: 's3.amazonaws.com',
58
+ port: 443,
59
+ useSsl: true,
60
+ region: undefined,
61
+ pathStyle: true,
62
+ bucket: 'bucket-name',
63
+ });
64
+ });
65
+ it('should parse URL with credentials', () => {
66
+ var result = parseS3Url({
67
+ url: 'https://user:pass@s3.amazonaws.com/bucket-name',
68
+ });
69
+ expect(result).toEqual({
70
+ accessKeyId: 'user',
71
+ secretAccessKey: 'pass',
72
+ endpoint: 's3.amazonaws.com',
73
+ port: 443,
74
+ useSsl: true,
75
+ region: undefined,
76
+ pathStyle: true,
77
+ bucket: 'bucket-name',
78
+ });
79
+ });
80
+ it('should parse URL with port', () => {
81
+ var result = parseS3Url({
82
+ url: 'https://s3.amazonaws.com:9000/bucket-name',
83
+ });
84
+ expect(result).toEqual({
85
+ accessKeyId: undefined,
86
+ secretAccessKey: undefined,
87
+ endpoint: 's3.amazonaws.com',
88
+ port: 9000,
89
+ useSsl: true,
90
+ region: undefined,
91
+ pathStyle: true,
92
+ bucket: 'bucket-name',
93
+ });
94
+ });
95
+ it('should parse URL with region query parameter', () => {
96
+ var result = parseS3Url({
97
+ url: 'https://s3.amazonaws.com/bucket-name?region=us-east-1',
98
+ });
99
+ expect(result).toEqual({
100
+ accessKeyId: undefined,
101
+ secretAccessKey: undefined,
102
+ endpoint: 's3.amazonaws.com',
103
+ port: 443,
104
+ useSsl: true,
105
+ region: 'us-east-1',
106
+ pathStyle: true,
107
+ bucket: 'bucket-name',
108
+ });
109
+ });
110
+ it('should parse URL with pathStyle parameter', () => {
111
+ var result = parseS3Url({
112
+ url: 'https://s3.amazonaws.com/bucket-name?pathStyle=true',
113
+ });
114
+ expect(result).toEqual({
115
+ accessKeyId: undefined,
116
+ secretAccessKey: undefined,
117
+ endpoint: 's3.amazonaws.com',
118
+ port: 443,
119
+ useSsl: true,
120
+ region: undefined,
121
+ pathStyle: true,
122
+ bucket: 'bucket-name',
123
+ });
124
+ });
125
+ it('should parse URL with pathStyle=false parameter', () => {
126
+ var result = parseS3Url({
127
+ url: 'https://s3.amazonaws.com/bucket-name?pathStyle=false',
128
+ });
129
+ expect(result).toEqual({
130
+ accessKeyId: undefined,
131
+ secretAccessKey: undefined,
132
+ endpoint: 's3.amazonaws.com',
133
+ port: 443,
134
+ useSsl: true,
135
+ region: undefined,
136
+ pathStyle: false,
137
+ bucket: 'bucket-name',
138
+ });
139
+ });
140
+ it('should detect path style for IP addresses', () => {
141
+ var result = parseS3Url({
142
+ url: 'https://192.168.1.1/bucket-name',
143
+ });
144
+ expect(result).toEqual({
145
+ accessKeyId: undefined,
146
+ secretAccessKey: undefined,
147
+ endpoint: '192.168.1.1',
148
+ port: 443,
149
+ useSsl: true,
150
+ region: undefined,
151
+ pathStyle: true,
152
+ bucket: 'bucket-name',
153
+ });
154
+ });
155
+ it('should detect path style for IPv6 addresses', () => {
156
+ var result = parseS3Url({
157
+ url: 'https://[2001:db8::1]/bucket-name',
158
+ });
159
+ expect(result).toEqual({
160
+ accessKeyId: undefined,
161
+ secretAccessKey: undefined,
162
+ endpoint: '[2001:db8::1]',
163
+ port: 443,
164
+ useSsl: true,
165
+ region: undefined,
166
+ pathStyle: true,
167
+ bucket: 'bucket-name',
168
+ });
169
+ });
170
+ it('should parse AWS virtual hosted style URL', () => {
171
+ var result = parseS3Url({
172
+ url: 'https://my-bucket.s3.us-east-1.amazonaws.com',
173
+ });
174
+ expect(result).toEqual({
175
+ accessKeyId: undefined,
176
+ secretAccessKey: undefined,
177
+ endpoint: 'my-bucket.s3.us-east-1.amazonaws.com',
178
+ port: 443,
179
+ useSsl: true,
180
+ region: 'us-east-1',
181
+ pathStyle: false,
182
+ bucket: 'my-bucket',
183
+ });
184
+ });
185
+ it('should parse AWS virtual hosted style URL with custom endpoint', () => {
186
+ var result = parseS3Url({
187
+ url: 'https://my-bucket.s3.amazonaws.com',
188
+ });
189
+ expect(result).toEqual({
190
+ accessKeyId: undefined,
191
+ secretAccessKey: undefined,
192
+ endpoint: 'my-bucket.s3.amazonaws.com',
193
+ port: 443,
194
+ useSsl: true,
195
+ region: undefined,
196
+ pathStyle: false,
197
+ bucket: 'my-bucket',
198
+ });
199
+ });
200
+ it('should override parameters with provided options', () => {
201
+ var result = parseS3Url({
202
+ url: 'https://s3.amazonaws.com/bucket-name',
203
+ region: 'us-west-2',
204
+ pathStyle: false,
205
+ });
206
+ expect(result).toEqual({
207
+ accessKeyId: undefined,
208
+ secretAccessKey: undefined,
209
+ endpoint: 's3.amazonaws.com',
210
+ port: 443,
211
+ useSsl: true,
212
+ region: 'us-west-2',
213
+ pathStyle: false,
214
+ bucket: 'bucket-name',
215
+ });
216
+ });
217
+ it('should use S3_URL environment variable by default', () => {
218
+ vi.stubEnv('S3_URL', 'https://env-bucket.s3.amazonaws.com');
219
+ var result = parseS3Url();
220
+ expect(result).toEqual({
221
+ accessKeyId: undefined,
222
+ secretAccessKey: undefined,
223
+ endpoint: 'env-bucket.s3.amazonaws.com',
224
+ port: 443,
225
+ useSsl: true,
226
+ region: undefined,
227
+ pathStyle: false,
228
+ bucket: 'env-bucket',
229
+ });
230
+ });
231
+ it('should throw error for invalid URL', () => {
232
+ expect(() =>
233
+ parseS3Url({
234
+ url: 'invalid-url',
235
+ }),
236
+ ).toThrow('Invalid S3 URL: invalid-url');
237
+ });
238
+ it('should handle complex URL with multiple parameters', () => {
239
+ var result = parseS3Url({
240
+ url: 'https://user:pass@custom-s3.com:9000/my-bucket?region=us-east-1&pathStyle=true',
241
+ });
242
+ expect(result).toEqual({
243
+ accessKeyId: 'user',
244
+ secretAccessKey: 'pass',
245
+ endpoint: 'custom-s3.com',
246
+ port: 9000,
247
+ useSsl: true,
248
+ region: 'us-east-1',
249
+ pathStyle: true,
250
+ bucket: 'my-bucket',
251
+ });
252
+ });
253
+ it('should ignore undefined and null values in rest parameters', () => {
254
+ var result = parseS3Url({
255
+ url: 'https://s3.amazonaws.com/bucket-name',
256
+ region: 'us-west-2',
257
+ port: undefined,
258
+ useSsl: null,
259
+ });
260
+ expect(result).toEqual({
261
+ accessKeyId: undefined,
262
+ secretAccessKey: undefined,
263
+ endpoint: 's3.amazonaws.com',
264
+ port: 443,
265
+ useSsl: true,
266
+ region: 'us-west-2',
267
+ pathStyle: true,
268
+ bucket: 'bucket-name',
269
+ });
270
+ });
270
271
  });
@@ -1,45 +1,44 @@
1
- import { getGlobalStates } from "@wener/utils";
2
- import { toJsonSchema } from "./index.js";
3
- (function (SchemaRegistry) {
4
- const types = getGlobalStates("@wener/common/resource/schema/SchemaRegistry", () => new Map());
5
- function get(needle) {
6
- let key = getKey(needle);
7
- let found = types.get(key);
8
- if (found) {
9
- return found;
10
- }
11
- else {
12
- if (needle && typeof needle !== "string") {
13
- return toJsonSchema(needle);
14
- }
15
- }
16
- throw new Error(`Schema not found: ${key}`);
17
- }
18
- SchemaRegistry.get = get;
19
- function getKey(s) {
20
- let key;
21
- if (typeof s === "string") {
22
- key = s;
23
- }
24
- else {
25
- let js = toJsonSchema(s);
26
- key = js.$id || js.title;
27
- }
28
- if (!key) {
29
- throw new Error(`Schema must have $id or title`);
30
- }
31
- return key;
32
- }
33
- function set(key, def) {
34
- if (!def) {
35
- def = key;
36
- if (!def || typeof def !== "object") {
37
- throw new Error(`Invalid schema definition for: ${getKey(key)}`);
38
- }
39
- }
40
- types.set(getKey(key), toJsonSchema(def));
41
- }
42
- SchemaRegistry.set = set;
1
+ import { getGlobalStates } from '@wener/utils';
2
+ import { toJsonSchema } from './index.js';
3
+
4
+ ((SchemaRegistry) => {
5
+ const types = getGlobalStates('@wener/common/resource/schema/SchemaRegistry', () => new Map());
6
+ function get(needle) {
7
+ let key = getKey(needle);
8
+ let found = types.get(key);
9
+ if (found) {
10
+ return found;
11
+ } else {
12
+ if (needle && typeof needle !== 'string') {
13
+ return toJsonSchema(needle);
14
+ }
15
+ }
16
+ throw new Error(`Schema not found: ${key}`);
17
+ }
18
+ SchemaRegistry.get = get;
19
+ function getKey(s) {
20
+ let key;
21
+ if (typeof s === 'string') {
22
+ key = s;
23
+ } else {
24
+ let js = toJsonSchema(s);
25
+ key = js.$id || js.title;
26
+ }
27
+ if (!key) {
28
+ throw new Error(`Schema must have $id or title`);
29
+ }
30
+ return key;
31
+ }
32
+ function set(key, def) {
33
+ if (!def) {
34
+ def = key;
35
+ if (!def || typeof def !== 'object') {
36
+ throw new Error(`Invalid schema definition for: ${getKey(key)}`);
37
+ }
38
+ }
39
+ types.set(getKey(key), toJsonSchema(def));
40
+ }
41
+ SchemaRegistry.set = set;
43
42
  })(SchemaRegistry || (SchemaRegistry = {}));
44
43
  export var SchemaRegistry;
45
44
  //# sourceMappingURL=SchemaRegistry.js.map
@@ -1,2 +1,2 @@
1
- import * as _SchemaRegistry from "./SchemaRegistry.js";
1
+ import * as _SchemaRegistry from './SchemaRegistry.js';
2
2
  export { _SchemaRegistry as SchemaRegistry };
@@ -1,3 +1,3 @@
1
- export { };
1
+ export {};
2
2
 
3
- //# sourceMappingURL=TypeSchema.d.js.map
3
+ //# sourceMappingURL=TypeSchema.d.js.map