@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.
- package/lib/ai/qwen3vl/index.js +2 -0
- package/lib/ai/qwen3vl/index.js.map +1 -0
- package/lib/ai/qwen3vl/utils.js +31 -0
- package/lib/ai/qwen3vl/utils.js.map +1 -0
- package/lib/ai/vision/DocLayoutElementTypeSchema.js +28 -0
- package/lib/ai/vision/DocLayoutElementTypeSchema.js.map +1 -0
- package/lib/ai/vision/ImageAnnotationSchema.js +50 -0
- package/lib/ai/vision/ImageAnnotationSchema.js.map +1 -0
- package/lib/ai/vision/index.js +3 -0
- package/lib/ai/vision/index.js.map +1 -0
- package/lib/ai/vision/resolveImageAnnotation.js +105 -0
- package/lib/ai/vision/resolveImageAnnotation.js.map +1 -0
- package/lib/cn/ChineseResidentIdNo.js +21 -14
- package/lib/cn/ChineseResidentIdNo.js.map +1 -0
- package/lib/cn/ChineseResidentIdNo.test.js +1 -1
- package/lib/cn/DivisionCode.js +30 -25
- package/lib/cn/DivisionCode.js.map +1 -0
- package/lib/cn/DivisionCode.test.js +1 -1
- package/lib/cn/Mod11.js +38 -81
- package/lib/cn/Mod11.js.map +1 -0
- package/lib/cn/Mod31.js +41 -90
- package/lib/cn/Mod31.js.map +1 -0
- package/lib/cn/UnifiedSocialCreditCode.js +43 -34
- package/lib/cn/UnifiedSocialCreditCode.js.map +1 -0
- package/lib/cn/UnifiedSocialCreditCode.test.js +1 -1
- package/lib/cn/formatChineseAmount.js +77 -0
- package/lib/cn/formatChineseAmount.js.map +1 -0
- package/lib/cn/index.js +7 -1
- package/lib/cn/index.js.map +1 -0
- package/lib/cn/parseChineseNumber.js +94 -0
- package/lib/cn/parseChineseNumber.js.map +1 -0
- package/lib/cn/parseChineseNumber.test.js +278 -0
- package/lib/cn/pinyin/cartesianProduct.js +22 -0
- package/lib/cn/pinyin/cartesianProduct.js.map +1 -0
- package/lib/cn/pinyin/cartesianProduct.test.js +179 -0
- package/lib/cn/pinyin/data.json +23573 -0
- package/lib/cn/pinyin/loader.js +14 -0
- package/lib/cn/pinyin/loader.js.map +1 -0
- package/lib/cn/pinyin/preload.js +3 -0
- package/lib/cn/pinyin/preload.js.map +1 -0
- package/lib/cn/pinyin/toPinyin.test.js +167 -0
- package/lib/cn/pinyin/toPinyinPure.js +33 -0
- package/lib/cn/pinyin/toPinyinPure.js.map +1 -0
- package/lib/cn/pinyin/transform.js +14 -0
- package/lib/cn/pinyin/transform.js.map +1 -0
- package/lib/cn/types.d.js +2 -0
- package/lib/cn/types.d.js.map +1 -0
- package/lib/consola/createStandardConsolaReporter.js +6 -6
- package/lib/consola/createStandardConsolaReporter.js.map +1 -0
- package/lib/consola/formatLogObject.js +65 -145
- package/lib/consola/formatLogObject.js.map +1 -0
- package/lib/consola/formatLogObject.test.js +184 -0
- package/lib/consola/index.js +1 -0
- package/lib/consola/index.js.map +1 -0
- package/lib/data/formatSort.js +6 -5
- package/lib/data/formatSort.js.map +1 -0
- package/lib/data/index.js +1 -0
- package/lib/data/index.js.map +1 -0
- package/lib/data/maybeNumber.js +5 -7
- package/lib/data/maybeNumber.js.map +1 -0
- package/lib/data/parseSort.js +22 -28
- package/lib/data/parseSort.js.map +1 -0
- package/lib/data/resolvePagination.js +13 -17
- package/lib/data/resolvePagination.js.map +1 -0
- package/lib/data/types.d.js +2 -0
- package/lib/data/types.d.js.map +1 -0
- package/lib/dayjs/dayjs.js +21 -19
- package/lib/dayjs/dayjs.js.map +1 -0
- package/lib/dayjs/formatDuration.js +15 -14
- package/lib/dayjs/formatDuration.js.map +1 -0
- package/lib/dayjs/index.js +2 -0
- package/lib/dayjs/index.js.map +1 -0
- package/lib/dayjs/parseDuration.js +5 -8
- package/lib/dayjs/parseDuration.js.map +1 -0
- package/lib/dayjs/parseRelativeTime.js +90 -0
- package/lib/dayjs/parseRelativeTime.js.map +1 -0
- package/lib/dayjs/parseRelativeTime.test.js +247 -0
- package/lib/dayjs/resolveRelativeTime.js +158 -0
- package/lib/dayjs/resolveRelativeTime.js.map +1 -0
- package/lib/dayjs/resolveRelativeTime.test.js +310 -0
- package/lib/decimal/index.js +1 -0
- package/lib/decimal/index.js.map +1 -0
- package/lib/decimal/parseDecimal.js +3 -1
- package/lib/decimal/parseDecimal.js.map +1 -0
- package/lib/emittery/emitter.js +10 -0
- package/lib/emittery/emitter.js.map +1 -0
- package/lib/emittery/index.js +2 -0
- package/lib/emittery/index.js.map +1 -0
- package/lib/foundation/schema/SexType.js +5 -3
- package/lib/foundation/schema/SexType.js.map +1 -0
- package/lib/foundation/schema/index.js +1 -0
- package/lib/foundation/schema/index.js.map +1 -0
- package/lib/foundation/schema/parseSexType.js +1 -0
- package/lib/foundation/schema/parseSexType.js.map +1 -0
- package/lib/foundation/schema/types.js +4 -2
- package/lib/foundation/schema/types.js.map +1 -0
- package/lib/fs/FileSystemError.js +23 -0
- package/lib/fs/FileSystemError.js.map +1 -0
- package/lib/fs/IFileSystem.d.js +3 -0
- package/lib/fs/IFileSystem.d.js.map +1 -0
- package/lib/fs/MemoryFileSystem.test.js +188 -0
- package/lib/fs/createBrowserFileSystem.js +248 -0
- package/lib/fs/createBrowserFileSystem.js.map +1 -0
- package/lib/fs/createMemoryFileSystem.js +516 -0
- package/lib/fs/createMemoryFileSystem.js.map +1 -0
- package/lib/fs/createSandboxFileSystem.js +108 -0
- package/lib/fs/createSandboxFileSystem.js.map +1 -0
- package/lib/fs/createWebDavFileSystem.js +137 -0
- package/lib/fs/createWebDavFileSystem.js.map +1 -0
- package/lib/fs/findMimeType.js +17 -0
- package/lib/fs/findMimeType.js.map +1 -0
- package/lib/fs/index.js +8 -0
- package/lib/fs/index.js.map +1 -0
- package/lib/fs/orpc/FileSystemContract.js +93 -0
- package/lib/fs/orpc/FileSystemContract.js.map +1 -0
- package/lib/fs/orpc/createContractClientFileSystem.js +93 -0
- package/lib/fs/orpc/createContractClientFileSystem.js.map +1 -0
- package/lib/fs/orpc/index.js +3 -0
- package/lib/fs/orpc/index.js.map +1 -0
- package/lib/fs/orpc/server/createFileSystemContractImpl.js +63 -0
- package/lib/fs/orpc/server/createFileSystemContractImpl.js.map +1 -0
- package/lib/fs/orpc/server/index.js +2 -0
- package/lib/fs/orpc/server/index.js.map +1 -0
- package/lib/fs/s3/createS3MiniFileSystem.js +705 -0
- package/lib/fs/s3/createS3MiniFileSystem.js.map +1 -0
- package/lib/fs/s3/index.js +2 -0
- package/lib/fs/s3/index.js.map +1 -0
- package/lib/fs/s3/s3mini.test.js +584 -0
- package/lib/fs/scandir.js +59 -0
- package/lib/fs/scandir.js.map +1 -0
- package/lib/fs/server/createDatabaseFileSystem.js +750 -0
- package/lib/fs/server/createDatabaseFileSystem.js.map +1 -0
- package/lib/fs/server/createNodeFileSystem.js +401 -0
- package/lib/fs/server/createNodeFileSystem.js.map +1 -0
- package/lib/fs/server/dbfs.test.js +221 -0
- package/lib/fs/server/index.js +2 -0
- package/lib/fs/server/index.js.map +1 -0
- package/lib/fs/server/loadTestDatabase.js +127 -0
- package/lib/fs/server/loadTestDatabase.js.map +1 -0
- package/lib/fs/tests/runFileSystemTest.js +318 -0
- package/lib/fs/tests/runFileSystemTest.js.map +1 -0
- package/lib/fs/types.js +27 -0
- package/lib/fs/types.js.map +1 -0
- package/lib/fs/utils/getFileUrl.js +35 -0
- package/lib/fs/utils/getFileUrl.js.map +1 -0
- package/lib/fs/utils.js +22 -0
- package/lib/fs/utils.js.map +1 -0
- package/lib/index.js +1 -0
- package/lib/index.js.map +1 -0
- package/lib/jsonschema/JsonSchema.js +146 -172
- package/lib/jsonschema/JsonSchema.js.map +1 -0
- package/lib/jsonschema/forEachJsonSchema.js +44 -0
- package/lib/jsonschema/forEachJsonSchema.js.map +1 -0
- package/lib/jsonschema/index.js +2 -0
- package/lib/jsonschema/index.js.map +1 -0
- package/lib/jsonschema/types.d.js +2 -0
- package/lib/jsonschema/types.d.js.map +1 -0
- package/lib/meta/defineFileType.js +20 -103
- package/lib/meta/defineFileType.js.map +1 -0
- package/lib/meta/defineInit.js +31 -250
- package/lib/meta/defineInit.js.map +1 -0
- package/lib/meta/defineMetadata.js +24 -140
- package/lib/meta/defineMetadata.js.map +1 -0
- package/lib/meta/index.js +1 -0
- package/lib/meta/index.js.map +1 -0
- package/lib/orpc/createOpenApiContractClient.js +27 -0
- package/lib/orpc/createOpenApiContractClient.js.map +1 -0
- package/lib/orpc/createRpcContractClient.js +34 -0
- package/lib/orpc/createRpcContractClient.js.map +1 -0
- package/lib/orpc/index.js +3 -0
- package/lib/orpc/index.js.map +1 -0
- package/lib/orpc/resolveLinkPlugins.js +28 -0
- package/lib/orpc/resolveLinkPlugins.js.map +1 -0
- package/lib/password/PHC.js +63 -87
- package/lib/password/PHC.js.map +1 -0
- package/lib/password/PHC.test.js +11 -3
- package/lib/password/Password.js +29 -294
- package/lib/password/Password.js.map +1 -0
- package/lib/password/Password.test.js +35 -22
- package/lib/password/createArgon2PasswordAlgorithm.js +35 -191
- package/lib/password/createArgon2PasswordAlgorithm.js.map +1 -0
- package/lib/password/createBase64PasswordAlgorithm.js +8 -141
- package/lib/password/createBase64PasswordAlgorithm.js.map +1 -0
- package/lib/password/createBcryptPasswordAlgorithm.js +13 -168
- package/lib/password/createBcryptPasswordAlgorithm.js.map +1 -0
- package/lib/password/createPBKDF2PasswordAlgorithm.js +46 -228
- package/lib/password/createPBKDF2PasswordAlgorithm.js.map +1 -0
- package/lib/password/createScryptPasswordAlgorithm.js +55 -211
- package/lib/password/createScryptPasswordAlgorithm.js.map +1 -0
- package/lib/password/index.js +1 -0
- package/lib/password/index.js.map +1 -0
- package/lib/password/server/index.js +1 -0
- package/lib/password/server/index.js.map +1 -0
- package/lib/resource/Identifiable.js +2 -0
- package/lib/resource/Identifiable.js.map +1 -0
- package/lib/resource/ListQuery.js +21 -93
- package/lib/resource/ListQuery.js.map +1 -0
- package/lib/resource/getTitleOfResource.js +3 -5
- package/lib/resource/getTitleOfResource.js.map +1 -0
- package/lib/resource/index.js +1 -0
- package/lib/resource/index.js.map +1 -0
- package/lib/resource/schema/AnyResourceSchema.js +2 -1
- package/lib/resource/schema/AnyResourceSchema.js.map +1 -0
- package/lib/resource/schema/BaseResourceSchema.js +2 -1
- package/lib/resource/schema/BaseResourceSchema.js.map +1 -0
- package/lib/resource/schema/ResourceActionType.js +6 -4
- package/lib/resource/schema/ResourceActionType.js.map +1 -0
- package/lib/resource/schema/ResourceStatus.js +5 -3
- package/lib/resource/schema/ResourceStatus.js.map +1 -0
- package/lib/resource/schema/ResourceType.js +5 -3
- package/lib/resource/schema/ResourceType.js.map +1 -0
- package/lib/resource/schema/index.js +1 -0
- package/lib/resource/schema/index.js.map +1 -0
- package/lib/resource/schema/types.js +16 -20
- package/lib/resource/schema/types.js.map +1 -0
- package/lib/s3/formatS3Url.js +65 -0
- package/lib/s3/formatS3Url.js.map +1 -0
- package/lib/s3/formatS3Url.test.js +262 -0
- package/lib/s3/index.js +3 -0
- package/lib/s3/index.js.map +1 -0
- package/lib/s3/parseS3Url.js +65 -0
- package/lib/s3/parseS3Url.js.map +1 -0
- package/lib/s3/parseS3Url.test.js +270 -0
- package/lib/schema/SchemaRegistry.js +38 -38
- package/lib/schema/SchemaRegistry.js.map +1 -0
- package/lib/schema/TypeSchema.d.js +2 -0
- package/lib/schema/TypeSchema.d.js.map +1 -0
- package/lib/schema/createSchemaData.js +26 -125
- package/lib/schema/createSchemaData.js.map +1 -0
- package/lib/schema/findJsonSchemaByPath.js +13 -36
- package/lib/schema/findJsonSchemaByPath.js.map +1 -0
- package/lib/schema/formatZodError.js +140 -0
- package/lib/schema/formatZodError.js.map +1 -0
- package/lib/schema/formatZodError.test.js +196 -0
- package/lib/schema/getSchemaCache.js +5 -5
- package/lib/schema/getSchemaCache.js.map +1 -0
- package/lib/schema/getSchemaOptions.js +8 -11
- package/lib/schema/getSchemaOptions.js.map +1 -0
- package/lib/schema/index.js +2 -1
- package/lib/schema/index.js.map +1 -0
- package/lib/schema/toJsonSchema.js +47 -290
- package/lib/schema/toJsonSchema.js.map +1 -0
- package/lib/schema/validate.js +33 -45
- package/lib/schema/validate.js.map +1 -0
- package/lib/tools/generateSchema.js +39 -197
- package/lib/tools/generateSchema.js.map +1 -0
- package/lib/tools/renderJsonSchemaToMarkdownDoc.js +55 -143
- package/lib/tools/renderJsonSchemaToMarkdownDoc.js.map +1 -0
- package/lib/utils/buildBaseUrl.js +13 -0
- package/lib/utils/buildBaseUrl.js.map +1 -0
- package/lib/utils/buildRedactorFormSchema.js +59 -0
- package/lib/utils/buildRedactorFormSchema.js.map +1 -0
- package/lib/utils/getEstimateProcessTime.js +12 -11
- package/lib/utils/getEstimateProcessTime.js.map +1 -0
- package/lib/utils/index.js +3 -0
- package/lib/utils/index.js.map +1 -0
- package/lib/utils/resolveFeatureOptions.js +12 -0
- package/lib/utils/resolveFeatureOptions.js.map +1 -0
- package/package.json +61 -13
- package/src/ai/qwen3vl/index.ts +1 -0
- package/src/ai/qwen3vl/utils.ts +36 -0
- package/src/ai/vision/DocLayoutElementTypeSchema.ts +30 -0
- package/src/ai/vision/ImageAnnotationSchema.ts +60 -0
- package/src/ai/vision/index.ts +2 -0
- package/src/ai/vision/resolveImageAnnotation.ts +135 -0
- package/src/cn/ChineseResidentIdNo.test.ts +1 -1
- package/src/cn/ChineseResidentIdNo.ts +8 -0
- package/src/cn/DivisionCode.test.ts +1 -1
- package/src/cn/DivisionCode.ts +8 -0
- package/src/cn/UnifiedSocialCreditCode.test.ts +1 -1
- package/src/cn/UnifiedSocialCreditCode.ts +15 -0
- package/src/cn/__snapshots__/UnifiedSocialCreditCode.test.ts.snap +23 -0
- package/src/cn/formatChineseAmount.ts +61 -0
- package/src/cn/index.ts +7 -1
- package/src/cn/parseChineseNumber.test.ts +159 -0
- package/src/cn/parseChineseNumber.ts +97 -0
- package/src/cn/pinyin/cartesianProduct.test.ts +64 -0
- package/src/cn/pinyin/cartesianProduct.ts +24 -0
- package/src/cn/pinyin/data.json +23573 -0
- package/src/cn/pinyin/loader.ts +12 -0
- package/src/cn/pinyin/preload.ts +3 -0
- package/src/cn/pinyin/toPinyin.test.ts +12 -0
- package/src/cn/pinyin/toPinyinPure.ts +43 -0
- package/src/cn/pinyin/transform.ts +12 -0
- package/src/consola/formatLogObject.test.ts +27 -0
- package/src/consola/formatLogObject.ts +34 -6
- package/src/dayjs/dayjs.ts +18 -18
- package/src/dayjs/index.ts +3 -1
- package/src/dayjs/parseRelativeTime.test.ts +185 -0
- package/src/dayjs/parseRelativeTime.ts +115 -0
- package/src/dayjs/resolveRelativeTime.test.ts +357 -0
- package/src/dayjs/resolveRelativeTime.ts +167 -0
- package/src/emittery/emitter.ts +9 -0
- package/src/emittery/index.ts +1 -0
- package/src/fs/FileSystemError.ts +26 -0
- package/src/fs/IFileSystem.d.ts +102 -0
- package/src/fs/MemoryFileSystem.test.ts +37 -0
- package/src/fs/createBrowserFileSystem.ts +291 -0
- package/src/fs/createMemoryFileSystem.ts +604 -0
- package/src/fs/createSandboxFileSystem.ts +136 -0
- package/src/fs/createWebDavFileSystem.ts +172 -0
- package/src/fs/findMimeType.ts +23 -0
- package/src/fs/index.ts +8 -0
- package/src/fs/orpc/FileSystemContract.ts +92 -0
- package/src/fs/orpc/createContractClientFileSystem.ts +115 -0
- package/src/fs/orpc/index.ts +2 -0
- package/src/fs/orpc/server/createFileSystemContractImpl.ts +64 -0
- package/src/fs/orpc/server/index.ts +1 -0
- package/src/fs/s3/createS3MiniFileSystem.ts +830 -0
- package/src/fs/s3/index.ts +1 -0
- package/src/fs/s3/s3mini.test.ts +264 -0
- package/src/fs/scandir.ts +75 -0
- package/src/fs/server/createDatabaseFileSystem.ts +668 -0
- package/src/fs/server/createNodeFileSystem.ts +499 -0
- package/src/fs/server/dbfs.test.ts +47 -0
- package/src/fs/server/index.ts +1 -0
- package/src/fs/server/loadTestDatabase.ts +131 -0
- package/src/fs/tests/runFileSystemTest.ts +288 -0
- package/src/fs/types.ts +29 -0
- package/src/fs/utils/getFileUrl.ts +44 -0
- package/src/fs/utils.ts +23 -0
- package/src/jsonschema/JsonSchema.ts +118 -110
- package/src/jsonschema/forEachJsonSchema.ts +50 -0
- package/src/jsonschema/index.ts +1 -0
- package/src/orpc/createOpenApiContractClient.ts +52 -0
- package/src/orpc/createRpcContractClient.ts +50 -0
- package/src/orpc/index.ts +2 -0
- package/src/orpc/resolveLinkPlugins.ts +29 -0
- package/src/password/PHC.ts +3 -3
- package/src/password/Password.test.ts +1 -1
- package/src/password/createPBKDF2PasswordAlgorithm.ts +2 -2
- package/src/resource/schema/AnyResourceSchema.ts +16 -2
- package/src/s3/formatS3Url.test.ts +254 -0
- package/src/s3/formatS3Url.ts +84 -0
- package/src/s3/index.ts +2 -0
- package/src/s3/parseS3Url.test.ts +258 -0
- package/src/s3/parseS3Url.ts +88 -0
- package/src/schema/SchemaRegistry.ts +35 -33
- package/src/schema/formatZodError.test.ts +196 -0
- package/src/schema/formatZodError.ts +151 -0
- package/src/schema/getSchemaOptions.ts +2 -2
- package/src/schema/index.ts +1 -1
- package/src/utils/buildBaseUrl.ts +12 -0
- package/src/utils/buildRedactorFormSchema.ts +85 -0
- package/src/utils/index.ts +4 -0
- package/src/utils/resolveFeatureOptions.ts +14 -0
- package/src/cn/ChineseResidentIdNo.mod.ts +0 -7
- package/src/cn/DivisionCode.mod.ts +0 -7
- package/src/cn/UnifiedSocialCreditCode.mod.ts +0 -7
- package/src/cn/mod.ts +0 -3
- package/src/schema/SchemaRegistry.mod.ts +0 -1
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
|
|
2
|
+
try {
|
|
3
|
+
var info = gen[key](arg);
|
|
4
|
+
var value = info.value;
|
|
5
|
+
}
|
|
6
|
+
catch (error) {
|
|
7
|
+
reject(error);
|
|
8
|
+
return;
|
|
9
|
+
}
|
|
10
|
+
if (info.done) {
|
|
11
|
+
resolve(value);
|
|
12
|
+
}
|
|
13
|
+
else {
|
|
14
|
+
Promise.resolve(value).then(_next, _throw);
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
function _async_to_generator(fn) {
|
|
18
|
+
return function () {
|
|
19
|
+
var self = this, args = arguments;
|
|
20
|
+
return new Promise(function (resolve, reject) {
|
|
21
|
+
var gen = fn.apply(self, args);
|
|
22
|
+
function _next(value) {
|
|
23
|
+
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
|
|
24
|
+
}
|
|
25
|
+
function _throw(err) {
|
|
26
|
+
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
|
|
27
|
+
}
|
|
28
|
+
_next(undefined);
|
|
29
|
+
});
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
function _ts_generator(thisArg, body) {
|
|
33
|
+
var f, y, t, _ = {
|
|
34
|
+
label: 0,
|
|
35
|
+
sent: function () {
|
|
36
|
+
if (t[0] & 1)
|
|
37
|
+
throw t[1];
|
|
38
|
+
return t[1];
|
|
39
|
+
},
|
|
40
|
+
trys: [],
|
|
41
|
+
ops: []
|
|
42
|
+
}, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype), d = Object.defineProperty;
|
|
43
|
+
return d(g, "next", {
|
|
44
|
+
value: verb(0)
|
|
45
|
+
}), d(g, "throw", {
|
|
46
|
+
value: verb(1)
|
|
47
|
+
}), d(g, "return", {
|
|
48
|
+
value: verb(2)
|
|
49
|
+
}), typeof Symbol === "function" && d(g, Symbol.iterator, {
|
|
50
|
+
value: function () {
|
|
51
|
+
return this;
|
|
52
|
+
}
|
|
53
|
+
}), g;
|
|
54
|
+
function verb(n) {
|
|
55
|
+
return function (v) {
|
|
56
|
+
return step([
|
|
57
|
+
n,
|
|
58
|
+
v
|
|
59
|
+
]);
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
function step(op) {
|
|
63
|
+
if (f)
|
|
64
|
+
throw new TypeError("Generator is already executing.");
|
|
65
|
+
while (g && (g = 0, op[0] && (_ = 0)), _)
|
|
66
|
+
try {
|
|
67
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done)
|
|
68
|
+
return t;
|
|
69
|
+
if (y = 0, t)
|
|
70
|
+
op = [
|
|
71
|
+
op[0] & 2,
|
|
72
|
+
t.value
|
|
73
|
+
];
|
|
74
|
+
switch (op[0]) {
|
|
75
|
+
case 0:
|
|
76
|
+
case 1:
|
|
77
|
+
t = op;
|
|
78
|
+
break;
|
|
79
|
+
case 4:
|
|
80
|
+
_.label++;
|
|
81
|
+
return {
|
|
82
|
+
value: op[1],
|
|
83
|
+
done: false
|
|
84
|
+
};
|
|
85
|
+
case 5:
|
|
86
|
+
_.label++;
|
|
87
|
+
y = op[1];
|
|
88
|
+
op = [
|
|
89
|
+
0
|
|
90
|
+
];
|
|
91
|
+
continue;
|
|
92
|
+
case 7:
|
|
93
|
+
op = _.ops.pop();
|
|
94
|
+
_.trys.pop();
|
|
95
|
+
continue;
|
|
96
|
+
default:
|
|
97
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
|
|
98
|
+
_ = 0;
|
|
99
|
+
continue;
|
|
100
|
+
}
|
|
101
|
+
if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
|
|
102
|
+
_.label = op[1];
|
|
103
|
+
break;
|
|
104
|
+
}
|
|
105
|
+
if (op[0] === 6 && _.label < t[1]) {
|
|
106
|
+
_.label = t[1];
|
|
107
|
+
t = op;
|
|
108
|
+
break;
|
|
109
|
+
}
|
|
110
|
+
if (t && _.label < t[2]) {
|
|
111
|
+
_.label = t[2];
|
|
112
|
+
_.ops.push(op);
|
|
113
|
+
break;
|
|
114
|
+
}
|
|
115
|
+
if (t[2])
|
|
116
|
+
_.ops.pop();
|
|
117
|
+
_.trys.pop();
|
|
118
|
+
continue;
|
|
119
|
+
}
|
|
120
|
+
op = body.call(thisArg, _);
|
|
121
|
+
}
|
|
122
|
+
catch (e) {
|
|
123
|
+
op = [
|
|
124
|
+
6,
|
|
125
|
+
e
|
|
126
|
+
];
|
|
127
|
+
y = 0;
|
|
128
|
+
}
|
|
129
|
+
finally {
|
|
130
|
+
f = t = 0;
|
|
131
|
+
}
|
|
132
|
+
if (op[0] & 5)
|
|
133
|
+
throw op[1];
|
|
134
|
+
return {
|
|
135
|
+
value: op[0] ? op[1] : void 0,
|
|
136
|
+
done: true
|
|
137
|
+
};
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
import consola from "consola";
|
|
141
|
+
import { Consola } from "consola/core";
|
|
142
|
+
import { test } from "vitest";
|
|
143
|
+
import { createStandardConsolaReporter } from "./createStandardConsolaReporter.js";
|
|
144
|
+
test("formatLogObject", function () {
|
|
145
|
+
return _async_to_generator(function () {
|
|
146
|
+
var log;
|
|
147
|
+
return _ts_generator(this, function (_state) {
|
|
148
|
+
log = new Consola({
|
|
149
|
+
reporters: [
|
|
150
|
+
createStandardConsolaReporter({})
|
|
151
|
+
]
|
|
152
|
+
}).create({
|
|
153
|
+
formatOptions: {
|
|
154
|
+
colors: true
|
|
155
|
+
}
|
|
156
|
+
});
|
|
157
|
+
consola.warn({
|
|
158
|
+
name: "wener"
|
|
159
|
+
});
|
|
160
|
+
log.info({
|
|
161
|
+
name: "wener"
|
|
162
|
+
});
|
|
163
|
+
log.info("message", {
|
|
164
|
+
name: "wener"
|
|
165
|
+
});
|
|
166
|
+
log.info("complex object", {
|
|
167
|
+
name: "wener",
|
|
168
|
+
age: 30,
|
|
169
|
+
active: true,
|
|
170
|
+
tags: [
|
|
171
|
+
"developer",
|
|
172
|
+
"typescript"
|
|
173
|
+
],
|
|
174
|
+
meta: {
|
|
175
|
+
level: "senior",
|
|
176
|
+
remote: true
|
|
177
|
+
}
|
|
178
|
+
});
|
|
179
|
+
return [
|
|
180
|
+
2
|
|
181
|
+
];
|
|
182
|
+
});
|
|
183
|
+
})();
|
|
184
|
+
});
|
package/lib/consola/index.js
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/consola/index.ts"],"sourcesContent":["export { formatLogObject } from './formatLogObject';\nexport { createStandardConsolaReporter } from './createStandardConsolaReporter';\n"],"names":["formatLogObject","createStandardConsolaReporter"],"mappings":"AAAA,SAASA,eAAe,QAAQ,oBAAoB;AACpD,SAASC,6BAA6B,QAAQ,kCAAkC"}
|
package/lib/data/formatSort.js
CHANGED
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
export function formatSort(s) {
|
|
2
|
-
return s.map(
|
|
3
|
-
var field = param.field, order = param.order, nulls = param.nulls;
|
|
2
|
+
return s.map(({ field, order, nulls })=>{
|
|
4
3
|
if (!field) return '';
|
|
5
|
-
|
|
4
|
+
let r = field;
|
|
6
5
|
if (order) {
|
|
7
|
-
r +=
|
|
6
|
+
r += ` ${order}`;
|
|
8
7
|
}
|
|
9
8
|
if (nulls) {
|
|
10
|
-
r +=
|
|
9
|
+
r += ` nulls ${nulls}`;
|
|
11
10
|
}
|
|
12
11
|
return r;
|
|
13
12
|
}).filter(Boolean);
|
|
14
13
|
}
|
|
14
|
+
|
|
15
|
+
//# sourceMappingURL=formatSort.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/data/formatSort.ts"],"sourcesContent":["import type { SortRule } from './parseSort';\n\nexport function formatSort(s: SortRule[]): string[] {\n\treturn s\n\t\t.map(({ field, order, nulls }) => {\n\t\t\tif (!field) return '';\n\n\t\t\tlet r = field;\n\t\t\tif (order) {\n\t\t\t\tr += ` ${order}`;\n\t\t\t}\n\t\t\tif (nulls) {\n\t\t\t\tr += ` nulls ${nulls}`;\n\t\t\t}\n\t\t\treturn r;\n\t\t})\n\t\t.filter(Boolean);\n}\n"],"names":["formatSort","s","map","field","order","nulls","r","filter","Boolean"],"mappings":"AAEA,OAAO,SAASA,WAAWC,CAAa;IACvC,OAAOA,EACLC,GAAG,CAAC,CAAC,EAAEC,KAAK,EAAEC,KAAK,EAAEC,KAAK,EAAE;QAC5B,IAAI,CAACF,OAAO,OAAO;QAEnB,IAAIG,IAAIH;QACR,IAAIC,OAAO;YACVE,KAAK,CAAC,CAAC,EAAEF,OAAO;QACjB;QACA,IAAIC,OAAO;YACVC,KAAK,CAAC,OAAO,EAAED,OAAO;QACvB;QACA,OAAOC;IACR,GACCC,MAAM,CAACC;AACV"}
|
package/lib/data/index.js
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/data/index.ts"],"sourcesContent":["export type * from './types';\n\nexport { resolvePagination, type PaginationInput, type ResolvedPagination } from './resolvePagination';\nexport { parseSort, type SortRule } from './parseSort';\nexport { formatSort } from './formatSort';\n"],"names":["resolvePagination","parseSort","formatSort"],"mappings":"AAEA,SAASA,iBAAiB,QAAuD,sBAAsB;AACvG,SAASC,SAAS,QAAuB,cAAc;AACvD,SAASC,UAAU,QAAQ,eAAe"}
|
package/lib/data/maybeNumber.js
CHANGED
|
@@ -1,17 +1,13 @@
|
|
|
1
|
-
function _type_of(obj) {
|
|
2
|
-
"@swc/helpers - typeof";
|
|
3
|
-
return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
|
|
4
|
-
}
|
|
5
1
|
export function maybeNumber(v) {
|
|
6
2
|
if (v === null || v === undefined) {
|
|
7
3
|
return undefined;
|
|
8
4
|
}
|
|
9
|
-
switch(typeof v
|
|
5
|
+
switch(typeof v){
|
|
10
6
|
case 'number':
|
|
11
7
|
return v;
|
|
12
8
|
case 'bigint':
|
|
13
9
|
if (v > BigInt(Number.MAX_SAFE_INTEGER) || v < BigInt(Number.MIN_SAFE_INTEGER)) {
|
|
14
|
-
throw new Error(
|
|
10
|
+
throw new Error(`bigint out of range`);
|
|
15
11
|
}
|
|
16
12
|
return Number(v);
|
|
17
13
|
case 'string':
|
|
@@ -20,9 +16,11 @@ export function maybeNumber(v) {
|
|
|
20
16
|
return undefined;
|
|
21
17
|
}
|
|
22
18
|
}
|
|
23
|
-
|
|
19
|
+
const n = Number(v);
|
|
24
20
|
if (isNaN(n)) {
|
|
25
21
|
return undefined;
|
|
26
22
|
}
|
|
27
23
|
return n;
|
|
28
24
|
}
|
|
25
|
+
|
|
26
|
+
//# sourceMappingURL=maybeNumber.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/data/maybeNumber.ts"],"sourcesContent":["export type MaybeNumber = number | null | string | undefined | bigint;\n\nexport function maybeNumber(v: MaybeNumber) {\n\tif (v === null || v === undefined) {\n\t\treturn undefined;\n\t}\n\n\tswitch (typeof v) {\n\t\tcase 'number':\n\t\t\treturn v;\n\t\tcase 'bigint':\n\t\t\tif (v > BigInt(Number.MAX_SAFE_INTEGER) || v < BigInt(Number.MIN_SAFE_INTEGER)) {\n\t\t\t\tthrow new Error(`bigint out of range`);\n\t\t\t}\n\t\t\treturn Number(v);\n\t\tcase 'string':\n\t\t\tv = v.trim();\n\t\t\tif (!v) {\n\t\t\t\treturn undefined;\n\t\t\t}\n\t}\n\tconst n = Number(v);\n\tif (isNaN(n)) {\n\t\treturn undefined;\n\t}\n\treturn n;\n}\n"],"names":["maybeNumber","v","undefined","BigInt","Number","MAX_SAFE_INTEGER","MIN_SAFE_INTEGER","Error","trim","n","isNaN"],"mappings":"AAEA,OAAO,SAASA,YAAYC,CAAc;IACzC,IAAIA,MAAM,QAAQA,MAAMC,WAAW;QAClC,OAAOA;IACR;IAEA,OAAQ,OAAOD;QACd,KAAK;YACJ,OAAOA;QACR,KAAK;YACJ,IAAIA,IAAIE,OAAOC,OAAOC,gBAAgB,KAAKJ,IAAIE,OAAOC,OAAOE,gBAAgB,GAAG;gBAC/E,MAAM,IAAIC,MAAM,CAAC,mBAAmB,CAAC;YACtC;YACA,OAAOH,OAAOH;QACf,KAAK;YACJA,IAAIA,EAAEO,IAAI;YACV,IAAI,CAACP,GAAG;gBACP,OAAOC;YACR;IACF;IACA,MAAMO,IAAIL,OAAOH;IACjB,IAAIS,MAAMD,IAAI;QACb,OAAOP;IACR;IACA,OAAOO;AACR"}
|
package/lib/data/parseSort.js
CHANGED
|
@@ -1,8 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
"@swc/helpers - typeof";
|
|
3
|
-
return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
|
|
4
|
-
}
|
|
5
|
-
import { arrayOfMaybeArray } from '@wener/utils';
|
|
1
|
+
import { arrayOfMaybeArray } from "@wener/utils";
|
|
6
2
|
/**
|
|
7
3
|
* Parses various format of sort specifications into standardized SortRule objects
|
|
8
4
|
*
|
|
@@ -21,13 +17,13 @@ import { arrayOfMaybeArray } from '@wener/utils';
|
|
|
21
17
|
if (!order) {
|
|
22
18
|
return [];
|
|
23
19
|
}
|
|
24
|
-
return arrayOfMaybeArray(order).flatMap(
|
|
20
|
+
return arrayOfMaybeArray(order).flatMap((v)=>{
|
|
25
21
|
if (!v) return [];
|
|
26
|
-
if (
|
|
22
|
+
if (typeof v === 'object') {
|
|
27
23
|
if (!v.field) {
|
|
28
24
|
return [];
|
|
29
25
|
}
|
|
30
|
-
|
|
26
|
+
const rule = {
|
|
31
27
|
field: v.field,
|
|
32
28
|
order: normalizeOrder(v.order)
|
|
33
29
|
};
|
|
@@ -36,28 +32,26 @@ import { arrayOfMaybeArray } from '@wener/utils';
|
|
|
36
32
|
}
|
|
37
33
|
return rule;
|
|
38
34
|
}
|
|
39
|
-
return v.split(',').map(
|
|
40
|
-
return v.trim();
|
|
41
|
-
}).filter(Boolean).map(_parse);
|
|
35
|
+
return v.split(',').map((v)=>v.trim()).filter(Boolean).map(_parse);
|
|
42
36
|
});
|
|
43
37
|
}
|
|
44
38
|
/**
|
|
45
39
|
* Normalizes order values to 'asc' or 'desc'
|
|
46
40
|
*/ function normalizeOrder(order) {
|
|
47
|
-
return
|
|
41
|
+
return order?.toLowerCase() === 'asc' ? 'asc' : 'desc';
|
|
48
42
|
}
|
|
49
43
|
/**
|
|
50
44
|
* Normalizes nulls values to 'last' or 'first'
|
|
51
45
|
*/ function normalizeNulls(nulls) {
|
|
52
|
-
return
|
|
46
|
+
return nulls?.toLowerCase() === 'last' ? 'last' : 'first';
|
|
53
47
|
}
|
|
54
48
|
function _parse(v) {
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
49
|
+
const sp = v.split(/\s+/);
|
|
50
|
+
let field = '';
|
|
51
|
+
let order;
|
|
52
|
+
let nulls;
|
|
59
53
|
// Handle first token which should be the field name (possibly with +/- prefix)
|
|
60
|
-
|
|
54
|
+
const f = sp.shift();
|
|
61
55
|
if (!f) return {
|
|
62
56
|
field: '',
|
|
63
57
|
order: 'asc'
|
|
@@ -70,8 +64,7 @@ function _parse(v) {
|
|
|
70
64
|
}
|
|
71
65
|
// Process remaining tokens
|
|
72
66
|
while(sp.length > 0){
|
|
73
|
-
|
|
74
|
-
var token = (_sp_shift = sp.shift()) === null || _sp_shift === void 0 ? void 0 : (_sp_shift_trim = _sp_shift.trim()) === null || _sp_shift_trim === void 0 ? void 0 : _sp_shift_trim.toLowerCase();
|
|
67
|
+
const token = sp.shift()?.trim()?.toLowerCase();
|
|
75
68
|
if (!token) continue;
|
|
76
69
|
switch(token){
|
|
77
70
|
case 'asc':
|
|
@@ -79,8 +72,7 @@ function _parse(v) {
|
|
|
79
72
|
order = token;
|
|
80
73
|
break;
|
|
81
74
|
case 'nulls':
|
|
82
|
-
|
|
83
|
-
nulls = ((_sp_shift1 = sp.shift()) === null || _sp_shift1 === void 0 ? void 0 : (_sp_shift_trim1 = _sp_shift1.trim()) === null || _sp_shift_trim1 === void 0 ? void 0 : _sp_shift_trim1.toLowerCase()) === 'last' ? 'last' : 'first';
|
|
75
|
+
nulls = sp.shift()?.trim()?.toLowerCase() === 'last' ? 'last' : 'first';
|
|
84
76
|
break;
|
|
85
77
|
case 'last':
|
|
86
78
|
case 'first':
|
|
@@ -88,14 +80,16 @@ function _parse(v) {
|
|
|
88
80
|
break;
|
|
89
81
|
}
|
|
90
82
|
}
|
|
91
|
-
order
|
|
83
|
+
order ||= 'asc';
|
|
92
84
|
// Only include nulls if specified
|
|
93
85
|
return nulls ? {
|
|
94
|
-
field
|
|
95
|
-
order
|
|
96
|
-
nulls
|
|
86
|
+
field,
|
|
87
|
+
order,
|
|
88
|
+
nulls
|
|
97
89
|
} : {
|
|
98
|
-
field
|
|
99
|
-
order
|
|
90
|
+
field,
|
|
91
|
+
order
|
|
100
92
|
};
|
|
101
93
|
}
|
|
94
|
+
|
|
95
|
+
//# sourceMappingURL=parseSort.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/data/parseSort.ts"],"sourcesContent":["import { arrayOfMaybeArray, type MaybeArray } from '@wener/utils';\n\nexport type SortRule = { field: string; order: 'asc' | 'desc'; nulls?: 'last' | 'first' };\n\n/**\n * Parses various format of sort specifications into standardized SortRule objects\n *\n * Supported formats:\n * - \"field asc|desc\"\n * - \"field asc|desc nulls first|last\"\n * - \"+field\" for ascending, \"-field\" for descending\n * - Object notation: { field: string, order?: string, nulls?: string }\n *\n * @example\n * parseSort('name desc') // [{ field: 'name', order: 'desc' }]\n * parseSort('+name,-age') // [{ field: 'name', order: 'asc' }, { field: 'age', order: 'desc' }]\n * parseSort('name asc nulls last') // [{ field: 'name', order: 'asc', nulls: 'last' }]\n * parseSort([{ field: 'name' }]) // [{ field: 'name', order: 'asc' }]\n */\nexport function parseSort(\n\torder: MaybeArray<{ field?: string; order?: string; nulls?: string } | string> | undefined | null,\n): SortRule[] {\n\tif (!order) {\n\t\treturn [];\n\t}\n\n\treturn arrayOfMaybeArray(order).flatMap((v): MaybeArray<SortRule> => {\n\t\tif (!v) return [];\n\t\tif (typeof v === 'object') {\n\t\t\tif (!v.field) {\n\t\t\t\treturn [];\n\t\t\t}\n\t\t\tconst rule: SortRule = {\n\t\t\t\tfield: v.field,\n\t\t\t\torder: normalizeOrder(v.order),\n\t\t\t};\n\n\t\t\tif (v.nulls) {\n\t\t\t\trule.nulls = normalizeNulls(v.nulls);\n\t\t\t}\n\t\t\treturn rule;\n\t\t}\n\t\treturn v\n\t\t\t.split(',')\n\t\t\t.map((v) => v.trim())\n\t\t\t.filter(Boolean)\n\t\t\t.map(_parse);\n\t});\n}\n\n/**\n * Normalizes order values to 'asc' or 'desc'\n */\nfunction normalizeOrder(order?: string): SortRule['order'] {\n\treturn order?.toLowerCase() === 'asc' ? 'asc' : 'desc';\n}\n\n/**\n * Normalizes nulls values to 'last' or 'first'\n */\nfunction normalizeNulls(nulls?: string): SortRule['nulls'] {\n\treturn nulls?.toLowerCase() === 'last' ? 'last' : 'first';\n}\n\nfunction _parse(v: string): SortRule {\n\tconst sp = v.split(/\\s+/);\n\tlet field = '';\n\tlet order: SortRule['order'];\n\tlet nulls: SortRule['nulls'];\n\n\t// Handle first token which should be the field name (possibly with +/- prefix)\n\tconst f = sp.shift();\n\tif (!f) return { field: '', order: 'asc' }; // Defensive programming\n\n\tif (f.startsWith('-') || f.startsWith('+')) {\n\t\tfield = f.slice(1).trim();\n\t\torder = f.startsWith('-') ? 'desc' : 'asc';\n\t} else {\n\t\tfield = f.trim();\n\t}\n\n\t// Process remaining tokens\n\twhile (sp.length > 0) {\n\t\tconst token = sp.shift()?.trim()?.toLowerCase();\n\t\tif (!token) continue;\n\n\t\tswitch (token) {\n\t\t\tcase 'asc':\n\t\t\tcase 'desc':\n\t\t\t\torder = token;\n\t\t\t\tbreak;\n\n\t\t\tcase 'nulls':\n\t\t\t\tnulls = sp.shift()?.trim()?.toLowerCase() === 'last' ? 'last' : 'first';\n\t\t\t\tbreak;\n\n\t\t\tcase 'last':\n\t\t\tcase 'first':\n\t\t\t\tnulls = token;\n\t\t\t\tbreak;\n\t\t}\n\t}\n\n\torder ||= 'asc';\n\n\t// Only include nulls if specified\n\treturn nulls ? { field, order, nulls } : { field, order };\n}\n"],"names":["arrayOfMaybeArray","parseSort","order","flatMap","v","field","rule","normalizeOrder","nulls","normalizeNulls","split","map","trim","filter","Boolean","_parse","toLowerCase","sp","f","shift","startsWith","slice","length","token"],"mappings":"AAAA,SAASA,iBAAiB,QAAyB,eAAe;AAIlE;;;;;;;;;;;;;;CAcC,GACD,OAAO,SAASC,UACfC,KAAiG;IAEjG,IAAI,CAACA,OAAO;QACX,OAAO,EAAE;IACV;IAEA,OAAOF,kBAAkBE,OAAOC,OAAO,CAAC,CAACC;QACxC,IAAI,CAACA,GAAG,OAAO,EAAE;QACjB,IAAI,OAAOA,MAAM,UAAU;YAC1B,IAAI,CAACA,EAAEC,KAAK,EAAE;gBACb,OAAO,EAAE;YACV;YACA,MAAMC,OAAiB;gBACtBD,OAAOD,EAAEC,KAAK;gBACdH,OAAOK,eAAeH,EAAEF,KAAK;YAC9B;YAEA,IAAIE,EAAEI,KAAK,EAAE;gBACZF,KAAKE,KAAK,GAAGC,eAAeL,EAAEI,KAAK;YACpC;YACA,OAAOF;QACR;QACA,OAAOF,EACLM,KAAK,CAAC,KACNC,GAAG,CAAC,CAACP,IAAMA,EAAEQ,IAAI,IACjBC,MAAM,CAACC,SACPH,GAAG,CAACI;IACP;AACD;AAEA;;CAEC,GACD,SAASR,eAAeL,KAAc;IACrC,OAAOA,OAAOc,kBAAkB,QAAQ,QAAQ;AACjD;AAEA;;CAEC,GACD,SAASP,eAAeD,KAAc;IACrC,OAAOA,OAAOQ,kBAAkB,SAAS,SAAS;AACnD;AAEA,SAASD,OAAOX,CAAS;IACxB,MAAMa,KAAKb,EAAEM,KAAK,CAAC;IACnB,IAAIL,QAAQ;IACZ,IAAIH;IACJ,IAAIM;IAEJ,+EAA+E;IAC/E,MAAMU,IAAID,GAAGE,KAAK;IAClB,IAAI,CAACD,GAAG,OAAO;QAAEb,OAAO;QAAIH,OAAO;IAAM,GAAG,wBAAwB;IAEpE,IAAIgB,EAAEE,UAAU,CAAC,QAAQF,EAAEE,UAAU,CAAC,MAAM;QAC3Cf,QAAQa,EAAEG,KAAK,CAAC,GAAGT,IAAI;QACvBV,QAAQgB,EAAEE,UAAU,CAAC,OAAO,SAAS;IACtC,OAAO;QACNf,QAAQa,EAAEN,IAAI;IACf;IAEA,2BAA2B;IAC3B,MAAOK,GAAGK,MAAM,GAAG,EAAG;QACrB,MAAMC,QAAQN,GAAGE,KAAK,IAAIP,QAAQI;QAClC,IAAI,CAACO,OAAO;QAEZ,OAAQA;YACP,KAAK;YACL,KAAK;gBACJrB,QAAQqB;gBACR;YAED,KAAK;gBACJf,QAAQS,GAAGE,KAAK,IAAIP,QAAQI,kBAAkB,SAAS,SAAS;gBAChE;YAED,KAAK;YACL,KAAK;gBACJR,QAAQe;gBACR;QACF;IACD;IAEArB,UAAU;IAEV,kCAAkC;IAClC,OAAOM,QAAQ;QAAEH;QAAOH;QAAOM;IAAM,IAAI;QAAEH;QAAOH;IAAM;AACzD"}
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import { maybeFunction } from "@wener/utils";
|
|
2
2
|
import { mapValues, omitBy, pick } from "es-toolkit";
|
|
3
3
|
import { maybeNumber } from "./maybeNumber.js";
|
|
4
|
-
export function resolvePagination(page) {
|
|
5
|
-
|
|
6
|
-
var out = omitBy(mapValues(//
|
|
4
|
+
export function resolvePagination(page, options = {}) {
|
|
5
|
+
let out = omitBy(mapValues(//
|
|
7
6
|
pick(page, [
|
|
8
7
|
"limit",
|
|
9
8
|
"offset",
|
|
@@ -11,21 +10,17 @@ export function resolvePagination(page) {
|
|
|
11
10
|
"pageNumber",
|
|
12
11
|
"pageIndex"
|
|
13
12
|
]), // to Number
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
}), function (v) {
|
|
17
|
-
return v === undefined || v === null;
|
|
18
|
-
});
|
|
19
|
-
var pageSize = out.pageSize;
|
|
13
|
+
(v) => maybeNumber(v)), (v) => v === undefined || v === null);
|
|
14
|
+
let { pageSize } = out;
|
|
20
15
|
if (options.pageSize) {
|
|
21
16
|
pageSize = maybeFunction(options.pageSize, pageSize);
|
|
22
17
|
}
|
|
23
|
-
pageSize
|
|
24
|
-
|
|
18
|
+
pageSize ??= resolvePagination.pageSize;
|
|
19
|
+
let { pageNumber = 1, pageIndex } = out;
|
|
25
20
|
// page index over page number
|
|
26
21
|
pageNumber = Math.max(pageNumber, 1);
|
|
27
|
-
pageIndex = Math.max(pageIndex
|
|
28
|
-
|
|
22
|
+
pageIndex = Math.max(pageIndex ?? pageNumber - 1, 0);
|
|
23
|
+
let { limit = pageSize, offset = pageSize * pageIndex } = out;
|
|
29
24
|
limit = Math.max(1, limit);
|
|
30
25
|
offset = Math.max(0, offset);
|
|
31
26
|
if (options.maxLimit) {
|
|
@@ -37,11 +32,12 @@ export function resolvePagination(page) {
|
|
|
37
32
|
pageSize = limit;
|
|
38
33
|
pageIndex = Math.floor(offset / pageSize);
|
|
39
34
|
return {
|
|
40
|
-
limit
|
|
41
|
-
offset
|
|
42
|
-
pageSize
|
|
35
|
+
limit,
|
|
36
|
+
offset,
|
|
37
|
+
pageSize,
|
|
43
38
|
pageNumber: pageIndex + 1,
|
|
44
|
-
pageIndex
|
|
39
|
+
pageIndex
|
|
45
40
|
};
|
|
46
41
|
}
|
|
47
42
|
resolvePagination.pageSize = 20;
|
|
43
|
+
//# sourceMappingURL=resolvePagination.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/data/resolvePagination.ts"],"sourcesContent":["import { maybeFunction, type MaybeFunction } from '@wener/utils';\nimport { mapValues, omitBy, pick } from 'es-toolkit';\nimport { maybeNumber, type MaybeNumber } from './maybeNumber';\n\nexport type PaginationInput = {\n\tlimit?: MaybeNumber;\n\toffset?: MaybeNumber;\n\tpageSize?: MaybeNumber;\n\tpageNumber?: MaybeNumber;\n\tpageIndex?: MaybeNumber;\n};\n\nexport type ResolvedPagination = {\n\tlimit: number;\n\toffset: number;\n\tpageSize: number;\n\tpageNumber: number;\n\tpageIndex: number;\n};\n\nexport function resolvePagination(\n\tpage: PaginationInput,\n\toptions: {\n\t\tpageSize?: MaybeFunction<number, [number | undefined]>;\n\t\tmaxLimit?: number;\n\t\tmaxOffset?: number;\n\t} = {},\n): ResolvedPagination {\n\tlet out = omitBy(\n\t\tmapValues(\n\t\t\t//\n\t\t\tpick(page, ['limit', 'offset', 'pageSize', 'pageNumber', 'pageIndex']),\n\t\t\t// to Number\n\t\t\t(v) => maybeNumber(v),\n\t\t),\n\t\t(v) => v === undefined || v === null,\n\t);\n\tlet { pageSize } = out;\n\tif (options.pageSize) {\n\t\tpageSize = maybeFunction(options.pageSize, pageSize);\n\t}\n\tpageSize ??= resolvePagination.pageSize;\n\n\tlet { pageNumber = 1, pageIndex } = out;\n\t// page index over page number\n\tpageNumber = Math.max(pageNumber, 1);\n\tpageIndex = Math.max(pageIndex ?? pageNumber - 1, 0);\n\n\tlet { limit = pageSize, offset = pageSize * pageIndex } = out;\n\tlimit = Math.max(1, limit);\n\toffset = Math.max(0, offset);\n\n\tif (options.maxLimit) {\n\t\tlimit = Math.min(limit, options.maxLimit);\n\t}\n\tif (options.maxOffset) {\n\t\toffset = Math.min(offset, options.maxOffset);\n\t}\n\n\tpageSize = limit;\n\tpageIndex = Math.floor(offset / pageSize);\n\treturn {\n\t\tlimit,\n\t\toffset,\n\t\tpageSize,\n\t\tpageNumber: pageIndex + 1,\n\t\tpageIndex,\n\t};\n}\n\nresolvePagination.pageSize = 20;\n"],"names":["maybeFunction","mapValues","omitBy","pick","maybeNumber","resolvePagination","page","options","out","v","undefined","pageSize","pageNumber","pageIndex","Math","max","limit","offset","maxLimit","min","maxOffset","floor"],"mappings":"AAAA,SAASA,aAAa,QAA4B,eAAe;AACjE,SAASC,SAAS,EAAEC,MAAM,EAAEC,IAAI,QAAQ,aAAa;AACrD,SAASC,WAAW,QAA0B,gBAAgB;AAkB9D,OAAO,SAASC,kBACfC,IAAqB,EACrBC,UAII,CAAC,CAAC;IAEN,IAAIC,MAAMN,OACTD,UACC,EAAE;IACFE,KAAKG,MAAM;QAAC;QAAS;QAAU;QAAY;QAAc;KAAY,GACrE,YAAY;IACZ,CAACG,IAAML,YAAYK,KAEpB,CAACA,IAAMA,MAAMC,aAAaD,MAAM;IAEjC,IAAI,EAAEE,QAAQ,EAAE,GAAGH;IACnB,IAAID,QAAQI,QAAQ,EAAE;QACrBA,WAAWX,cAAcO,QAAQI,QAAQ,EAAEA;IAC5C;IACAA,aAAaN,kBAAkBM,QAAQ;IAEvC,IAAI,EAAEC,aAAa,CAAC,EAAEC,SAAS,EAAE,GAAGL;IACpC,8BAA8B;IAC9BI,aAAaE,KAAKC,GAAG,CAACH,YAAY;IAClCC,YAAYC,KAAKC,GAAG,CAACF,aAAaD,aAAa,GAAG;IAElD,IAAI,EAAEI,QAAQL,QAAQ,EAAEM,SAASN,WAAWE,SAAS,EAAE,GAAGL;IAC1DQ,QAAQF,KAAKC,GAAG,CAAC,GAAGC;IACpBC,SAASH,KAAKC,GAAG,CAAC,GAAGE;IAErB,IAAIV,QAAQW,QAAQ,EAAE;QACrBF,QAAQF,KAAKK,GAAG,CAACH,OAAOT,QAAQW,QAAQ;IACzC;IACA,IAAIX,QAAQa,SAAS,EAAE;QACtBH,SAASH,KAAKK,GAAG,CAACF,QAAQV,QAAQa,SAAS;IAC5C;IAEAT,WAAWK;IACXH,YAAYC,KAAKO,KAAK,CAACJ,SAASN;IAChC,OAAO;QACNK;QACAC;QACAN;QACAC,YAAYC,YAAY;QACxBA;IACD;AACD;AAEAR,kBAAkBM,QAAQ,GAAG"}
|
package/lib/data/types.d.js
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/data/types.d.ts"],"sourcesContent":["export type ListQueryInput = {\n\t/** Filter string */\n\tfilter?: string;\n\t/** Filter array */\n\tfilters?: string[];\n\t/** Filter by IDs */\n\tids?: string[];\n\t/** Search query */\n\tsearch?: string;\n\t/** Items per page */\n\tlimit?: number;\n\t/** Offset for pagination */\n\toffset?: number;\n\t/** Ordering criteria */\n\torder?: string[];\n\t/** Page index (0-based) */\n\tpageIndex?: number;\n\t/** Page number (1-based) */\n\tpageNumber?: number;\n\t/** Items per page */\n\tpageSize?: number;\n\t/** Cursor for pagination */\n\tcursor?: string;\n\t/** Whether to include deleted items */\n\tdeleted?: boolean;\n};\n\ntype ListResult<T = any> = {\n\t/** List of items */\n\tdata: T[];\n\t/** Total number of items */\n\ttotal: number;\n};\n\ntype PageInfo = {\n\t/** Whether there are more items */\n\thasNextPage: boolean;\n\t/** Whether there are previous items */\n\thasPreviousPage: boolean;\n\n\t// /** Start cursor */\n\t// startCursor?: string;\n\t// /** End cursor */\n\t// endCursor?: string;\n};\n"],"names":[],"mappings":"AAAA,WAyBE"}
|
package/lib/dayjs/dayjs.js
CHANGED
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
import dayjs from
|
|
2
|
-
import advancedFormat from
|
|
3
|
-
import dayOfYear from
|
|
4
|
-
import duration from
|
|
5
|
-
import isBetween from
|
|
6
|
-
import isSameOrAfter from
|
|
7
|
-
import isSameOrBefore from
|
|
8
|
-
import isToday from
|
|
9
|
-
import isTomorrow from
|
|
10
|
-
import isYesterday from
|
|
11
|
-
import localeData from
|
|
12
|
-
import objectSupport from
|
|
13
|
-
import quarterOfYear from
|
|
14
|
-
import relativeTime from
|
|
15
|
-
import timezone from
|
|
16
|
-
import toObject from
|
|
17
|
-
import utc from
|
|
18
|
-
import
|
|
19
|
-
import
|
|
1
|
+
import dayjs from "dayjs";
|
|
2
|
+
import advancedFormat from "dayjs/plugin/advancedFormat.js";
|
|
3
|
+
import dayOfYear from "dayjs/plugin/dayOfYear.js";
|
|
4
|
+
import duration from "dayjs/plugin/duration.js";
|
|
5
|
+
import isBetween from "dayjs/plugin/isBetween.js";
|
|
6
|
+
import isSameOrAfter from "dayjs/plugin/isSameOrAfter.js";
|
|
7
|
+
import isSameOrBefore from "dayjs/plugin/isSameOrBefore.js";
|
|
8
|
+
import isToday from "dayjs/plugin/isToday.js";
|
|
9
|
+
import isTomorrow from "dayjs/plugin/isTomorrow.js";
|
|
10
|
+
import isYesterday from "dayjs/plugin/isYesterday.js";
|
|
11
|
+
import localeData from "dayjs/plugin/localeData.js";
|
|
12
|
+
import objectSupport from "dayjs/plugin/objectSupport.js";
|
|
13
|
+
import quarterOfYear from "dayjs/plugin/quarterOfYear.js";
|
|
14
|
+
import relativeTime from "dayjs/plugin/relativeTime.js";
|
|
15
|
+
import timezone from "dayjs/plugin/timezone.js";
|
|
16
|
+
import toObject from "dayjs/plugin/toObject.js";
|
|
17
|
+
import utc from "dayjs/plugin/utc.js";
|
|
18
|
+
import "dayjs/locale/zh-cn.js";
|
|
19
|
+
import "dayjs/locale/zh.js";
|
|
20
20
|
dayjs.extend(advancedFormat);
|
|
21
21
|
dayjs.extend(dayOfYear);
|
|
22
22
|
dayjs.extend(duration);
|
|
@@ -36,3 +36,5 @@ dayjs.extend(utc);
|
|
|
36
36
|
dayjs.locale('zh-cn');
|
|
37
37
|
dayjs.tz.setDefault('Asia/Shanghai');
|
|
38
38
|
export { dayjs };
|
|
39
|
+
|
|
40
|
+
//# sourceMappingURL=dayjs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/dayjs/dayjs.ts"],"sourcesContent":["import dayjs from 'dayjs';\nimport advancedFormat from 'dayjs/plugin/advancedFormat.js';\nimport dayOfYear from 'dayjs/plugin/dayOfYear.js';\nimport duration from 'dayjs/plugin/duration.js';\nimport isBetween from 'dayjs/plugin/isBetween.js';\nimport isSameOrAfter from 'dayjs/plugin/isSameOrAfter.js';\nimport isSameOrBefore from 'dayjs/plugin/isSameOrBefore.js';\nimport isToday from 'dayjs/plugin/isToday.js';\nimport isTomorrow from 'dayjs/plugin/isTomorrow.js';\nimport isYesterday from 'dayjs/plugin/isYesterday.js';\nimport localeData from 'dayjs/plugin/localeData.js';\nimport objectSupport from 'dayjs/plugin/objectSupport.js';\nimport quarterOfYear from 'dayjs/plugin/quarterOfYear.js';\nimport relativeTime from 'dayjs/plugin/relativeTime.js';\nimport timezone from 'dayjs/plugin/timezone.js';\nimport toObject from 'dayjs/plugin/toObject.js';\nimport utc from 'dayjs/plugin/utc.js';\nimport 'dayjs/locale/zh-cn.js';\nimport 'dayjs/locale/zh.js';\n\ndayjs.extend(advancedFormat);\ndayjs.extend(dayOfYear);\ndayjs.extend(duration);\ndayjs.extend(isBetween);\ndayjs.extend(isSameOrAfter);\ndayjs.extend(isSameOrBefore);\ndayjs.extend(isToday);\ndayjs.extend(isTomorrow);\ndayjs.extend(isYesterday);\ndayjs.extend(localeData);\ndayjs.extend(objectSupport);\ndayjs.extend(quarterOfYear);\ndayjs.extend(relativeTime);\ndayjs.extend(timezone);\ndayjs.extend(toObject);\ndayjs.extend(utc);\ndayjs.locale('zh-cn');\ndayjs.tz.setDefault('Asia/Shanghai');\n\nexport { dayjs };\n"],"names":["dayjs","advancedFormat","dayOfYear","duration","isBetween","isSameOrAfter","isSameOrBefore","isToday","isTomorrow","isYesterday","localeData","objectSupport","quarterOfYear","relativeTime","timezone","toObject","utc","extend","locale","tz","setDefault"],"mappings":"AAAA,OAAOA,WAAW,QAAQ;AAC1B,OAAOC,oBAAoB,iCAAiC;AAC5D,OAAOC,eAAe,4BAA4B;AAClD,OAAOC,cAAc,2BAA2B;AAChD,OAAOC,eAAe,4BAA4B;AAClD,OAAOC,mBAAmB,gCAAgC;AAC1D,OAAOC,oBAAoB,iCAAiC;AAC5D,OAAOC,aAAa,0BAA0B;AAC9C,OAAOC,gBAAgB,6BAA6B;AACpD,OAAOC,iBAAiB,8BAA8B;AACtD,OAAOC,gBAAgB,6BAA6B;AACpD,OAAOC,mBAAmB,gCAAgC;AAC1D,OAAOC,mBAAmB,gCAAgC;AAC1D,OAAOC,kBAAkB,+BAA+B;AACxD,OAAOC,cAAc,2BAA2B;AAChD,OAAOC,cAAc,2BAA2B;AAChD,OAAOC,SAAS,sBAAsB;AACtC,OAAO,wBAAwB;AAC/B,OAAO,qBAAqB;AAE5BhB,MAAMiB,MAAM,CAAChB;AACbD,MAAMiB,MAAM,CAACf;AACbF,MAAMiB,MAAM,CAACd;AACbH,MAAMiB,MAAM,CAACb;AACbJ,MAAMiB,MAAM,CAACZ;AACbL,MAAMiB,MAAM,CAACX;AACbN,MAAMiB,MAAM,CAACV;AACbP,MAAMiB,MAAM,CAACT;AACbR,MAAMiB,MAAM,CAACR;AACbT,MAAMiB,MAAM,CAACP;AACbV,MAAMiB,MAAM,CAACN;AACbX,MAAMiB,MAAM,CAACL;AACbZ,MAAMiB,MAAM,CAACJ;AACbb,MAAMiB,MAAM,CAACH;AACbd,MAAMiB,MAAM,CAACF;AACbf,MAAMiB,MAAM,CAACD;AACbhB,MAAMkB,MAAM,CAAC;AACblB,MAAMmB,EAAE,CAACC,UAAU,CAAC;AAEpB,SAASpB,KAAK,GAAG"}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { parseDuration } from "./parseDuration.js";
|
|
2
2
|
export function formatDuration(value, o) {
|
|
3
|
-
|
|
3
|
+
const v = parseDuration(value);
|
|
4
4
|
if (v === undefined || v === null) {
|
|
5
5
|
return;
|
|
6
6
|
}
|
|
7
|
-
|
|
7
|
+
let { format, humanize, iso } = o || {};
|
|
8
8
|
// Use local variables instead of modifying o directly
|
|
9
9
|
switch (format) {
|
|
10
10
|
case "human":
|
|
@@ -32,27 +32,28 @@ export function formatDuration(value, o) {
|
|
|
32
32
|
// auto format
|
|
33
33
|
// 1h2m3s
|
|
34
34
|
if (v.asDays() > 1) {
|
|
35
|
-
|
|
35
|
+
let s = v.toISOString();
|
|
36
36
|
return s.replace("P", "").replace("T", "").toLowerCase();
|
|
37
37
|
}
|
|
38
38
|
{
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
39
|
+
let parts = [];
|
|
40
|
+
let h = v.hours();
|
|
41
|
+
let m = v.minutes();
|
|
42
|
+
let s = v.seconds();
|
|
43
|
+
let ms = v.milliseconds();
|
|
44
44
|
if (h > 0) {
|
|
45
|
-
parts.push(
|
|
45
|
+
parts.push(`${h}h`);
|
|
46
46
|
}
|
|
47
47
|
if (m > 0) {
|
|
48
|
-
parts.push(
|
|
48
|
+
parts.push(`${m}m`);
|
|
49
49
|
}
|
|
50
|
-
if (
|
|
51
|
-
parts.push(
|
|
50
|
+
if (s > 0) {
|
|
51
|
+
parts.push(`${s}s`);
|
|
52
52
|
}
|
|
53
|
-
if (ms > 0 || h === 0 && m === 0 &&
|
|
54
|
-
parts.push(
|
|
53
|
+
if (ms > 0 || h === 0 && m === 0 && s === 0) {
|
|
54
|
+
parts.push(`${ms}ms`);
|
|
55
55
|
}
|
|
56
56
|
return parts.join("");
|
|
57
57
|
}
|
|
58
58
|
}
|
|
59
|
+
//# sourceMappingURL=formatDuration.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/dayjs/formatDuration.ts"],"sourcesContent":["import { type OpUnitType, type UnitTypeLongPlural } from 'dayjs';\nimport { type Duration } from 'dayjs/plugin/duration';\nimport { parseDuration } from './parseDuration';\n\ntype FormatDurationOptions = {\n\thumanize?: boolean;\n\tformat?: string | 'human' | 'humanize' | 'iso' | 'auto';\n\tiso?: boolean;\n};\n\nexport type MaybeDuration =\n\t| number\n\t| string\n\t| Duration\n\t| Partial<{\n\t\t\t[unit in Exclude<UnitTypeLongPlural, 'dates'> | 'weeks']: number;\n\t }>\n\t| {\n\t\t\tvalue: number;\n\t\t\tunit?: Exclude<OpUnitType, 'date' | 'dates'>;\n\t }\n\t| undefined\n\t| null;\n\nexport function formatDuration(value: MaybeDuration, o?: FormatDurationOptions): string | undefined {\n\tconst v = parseDuration(value);\n\tif (v === undefined || v === null) {\n\t\treturn;\n\t}\n\n\tlet { format, humanize, iso } = o || {};\n\t// Use local variables instead of modifying o directly\n\tswitch (format) {\n\t\tcase 'human':\n\t\tcase 'humanize':\n\t\t\thumanize = true;\n\t\t\tformat = undefined;\n\t\t\tbreak;\n\t\tcase 'iso':\n\t\t\tiso = true;\n\t\t\tformat = undefined;\n\t\t\tbreak;\n\t\tcase 'auto':\n\t\t\tformat = undefined;\n\t\t\tbreak;\n\t}\n\n\tif (humanize) {\n\t\treturn v.humanize();\n\t}\n\tif (iso) {\n\t\treturn v.toISOString();\n\t}\n\tif (format) {\n\t\treturn v.format(format);\n\t}\n\n\t// auto format\n\t// 1h2m3s\n\tif (v.asDays() > 1) {\n\t\tlet s = v.toISOString();\n\t\treturn s.replace('P', '').replace('T', '').toLowerCase();\n\t}\n\n\t{\n\t\tlet parts: string[] = [];\n\t\tlet h = v.hours();\n\t\tlet m = v.minutes();\n\t\tlet s = v.seconds();\n\t\tlet ms = v.milliseconds();\n\n\t\tif (h > 0) {\n\t\t\tparts.push(`${h}h`);\n\t\t}\n\t\tif (m > 0) {\n\t\t\tparts.push(`${m}m`);\n\t\t}\n\t\tif (s > 0) {\n\t\t\tparts.push(`${s}s`);\n\t\t}\n\t\tif (ms > 0 || (h === 0 && m === 0 && s === 0)) {\n\t\t\tparts.push(`${ms}ms`);\n\t\t}\n\t\treturn parts.join('');\n\t}\n}\n"],"names":["parseDuration","formatDuration","value","o","v","undefined","format","humanize","iso","toISOString","asDays","s","replace","toLowerCase","parts","h","hours","m","minutes","seconds","ms","milliseconds","push","join"],"mappings":"AAEA,SAASA,aAAa,QAAQ,kBAAkB;AAsBhD,OAAO,SAASC,eAAeC,KAAoB,EAAEC,CAAyB;IAC7E,MAAMC,IAAIJ,cAAcE;IACxB,IAAIE,MAAMC,aAAaD,MAAM,MAAM;QAClC;IACD;IAEA,IAAI,EAAEE,MAAM,EAAEC,QAAQ,EAAEC,GAAG,EAAE,GAAGL,KAAK,CAAC;IACtC,sDAAsD;IACtD,OAAQG;QACP,KAAK;QACL,KAAK;YACJC,WAAW;YACXD,SAASD;YACT;QACD,KAAK;YACJG,MAAM;YACNF,SAASD;YACT;QACD,KAAK;YACJC,SAASD;YACT;IACF;IAEA,IAAIE,UAAU;QACb,OAAOH,EAAEG,QAAQ;IAClB;IACA,IAAIC,KAAK;QACR,OAAOJ,EAAEK,WAAW;IACrB;IACA,IAAIH,QAAQ;QACX,OAAOF,EAAEE,MAAM,CAACA;IACjB;IAEA,cAAc;IACd,SAAS;IACT,IAAIF,EAAEM,MAAM,KAAK,GAAG;QACnB,IAAIC,IAAIP,EAAEK,WAAW;QACrB,OAAOE,EAAEC,OAAO,CAAC,KAAK,IAAIA,OAAO,CAAC,KAAK,IAAIC,WAAW;IACvD;IAEA;QACC,IAAIC,QAAkB,EAAE;QACxB,IAAIC,IAAIX,EAAEY,KAAK;QACf,IAAIC,IAAIb,EAAEc,OAAO;QACjB,IAAIP,IAAIP,EAAEe,OAAO;QACjB,IAAIC,KAAKhB,EAAEiB,YAAY;QAEvB,IAAIN,IAAI,GAAG;YACVD,MAAMQ,IAAI,CAAC,GAAGP,EAAE,CAAC,CAAC;QACnB;QACA,IAAIE,IAAI,GAAG;YACVH,MAAMQ,IAAI,CAAC,GAAGL,EAAE,CAAC,CAAC;QACnB;QACA,IAAIN,IAAI,GAAG;YACVG,MAAMQ,IAAI,CAAC,GAAGX,EAAE,CAAC,CAAC;QACnB;QACA,IAAIS,KAAK,KAAML,MAAM,KAAKE,MAAM,KAAKN,MAAM,GAAI;YAC9CG,MAAMQ,IAAI,CAAC,GAAGF,GAAG,EAAE,CAAC;QACrB;QACA,OAAON,MAAMS,IAAI,CAAC;IACnB;AACD"}
|
package/lib/dayjs/index.js
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/dayjs/index.ts"],"sourcesContent":["export { dayjs } from './dayjs';\nexport { parseDuration, type MaybeDuration } from './parseDuration';\nexport { formatDuration } from './formatDuration';\n\nexport { resolveRelativeTime } from './resolveRelativeTime';\n"],"names":["dayjs","parseDuration","formatDuration","resolveRelativeTime"],"mappings":"AAAA,SAASA,KAAK,QAAQ,UAAU;AAChC,SAASC,aAAa,QAA4B,kBAAkB;AACpE,SAASC,cAAc,QAAQ,mBAAmB;AAElD,SAASC,mBAAmB,QAAQ,wBAAwB"}
|
|
@@ -1,13 +1,9 @@
|
|
|
1
|
-
function _type_of(obj) {
|
|
2
|
-
"@swc/helpers - typeof";
|
|
3
|
-
return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
|
|
4
|
-
}
|
|
5
1
|
import { dayjs } from "./dayjs.js";
|
|
6
2
|
export function parseDuration(value) {
|
|
7
3
|
if (!value && value !== 0) {
|
|
8
4
|
return;
|
|
9
5
|
}
|
|
10
|
-
|
|
6
|
+
let duration;
|
|
11
7
|
if (typeof value === "number") {
|
|
12
8
|
duration = dayjs.duration(value);
|
|
13
9
|
}
|
|
@@ -15,18 +11,19 @@ export function parseDuration(value) {
|
|
|
15
11
|
// PT0S
|
|
16
12
|
duration = dayjs.duration(value);
|
|
17
13
|
}
|
|
18
|
-
else if (
|
|
14
|
+
else if (typeof value === "object" && "value" in value) {
|
|
19
15
|
duration = dayjs.duration(value.value, value.unit);
|
|
20
16
|
}
|
|
21
17
|
else if (dayjs.isDuration(value)) {
|
|
22
18
|
duration = value;
|
|
23
19
|
}
|
|
24
|
-
else if (
|
|
20
|
+
else if (typeof value === "object") {
|
|
25
21
|
duration = dayjs.duration(value);
|
|
26
22
|
}
|
|
27
23
|
else {
|
|
28
|
-
console.warn(
|
|
24
|
+
console.warn(`Invalid duration value:`, value);
|
|
29
25
|
return;
|
|
30
26
|
}
|
|
31
27
|
return duration;
|
|
32
28
|
}
|
|
29
|
+
//# sourceMappingURL=parseDuration.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/dayjs/parseDuration.ts"],"sourcesContent":["import type { OpUnitType, UnitTypeLongPlural } from 'dayjs';\nimport type { Duration } from 'dayjs/plugin/duration';\nimport { dayjs } from './dayjs';\n\nexport type MaybeDuration =\n\t| number\n\t| string\n\t| Duration\n\t| Partial<{\n\t\t\t[unit in Exclude<UnitTypeLongPlural, 'dates'> | 'weeks']: number;\n\t }>\n\t| {\n\t\t\tvalue: number;\n\t\t\tunit?: Exclude<OpUnitType, 'date' | 'dates'>;\n\t }\n\t| undefined\n\t| null;\n\nexport function parseDuration(value: MaybeDuration): Duration | undefined {\n\tif (!value && value !== 0) {\n\t\treturn;\n\t}\n\tlet duration: Duration;\n\tif (typeof value === 'number') {\n\t\tduration = dayjs.duration(value);\n\t} else if (typeof value === 'string' && value.startsWith('P')) {\n\t\t// PT0S\n\t\tduration = dayjs.duration(value);\n\t} else if (typeof value === 'object' && 'value' in value) {\n\t\tduration = dayjs.duration(value.value, value.unit);\n\t} else if (dayjs.isDuration(value)) {\n\t\tduration = value;\n\t} else if (typeof value === 'object') {\n\t\tduration = dayjs.duration(value);\n\t} else {\n\t\tconsole.warn(`Invalid duration value:`, value);\n\t\treturn;\n\t}\n\treturn duration;\n}\n"],"names":["dayjs","parseDuration","value","duration","startsWith","unit","isDuration","console","warn"],"mappings":"AAEA,SAASA,KAAK,QAAQ,UAAU;AAgBhC,OAAO,SAASC,cAAcC,KAAoB;IACjD,IAAI,CAACA,SAASA,UAAU,GAAG;QAC1B;IACD;IACA,IAAIC;IACJ,IAAI,OAAOD,UAAU,UAAU;QAC9BC,WAAWH,MAAMG,QAAQ,CAACD;IAC3B,OAAO,IAAI,OAAOA,UAAU,YAAYA,MAAME,UAAU,CAAC,MAAM;QAC9D,OAAO;QACPD,WAAWH,MAAMG,QAAQ,CAACD;IAC3B,OAAO,IAAI,OAAOA,UAAU,YAAY,WAAWA,OAAO;QACzDC,WAAWH,MAAMG,QAAQ,CAACD,MAAMA,KAAK,EAAEA,MAAMG,IAAI;IAClD,OAAO,IAAIL,MAAMM,UAAU,CAACJ,QAAQ;QACnCC,WAAWD;IACZ,OAAO,IAAI,OAAOA,UAAU,UAAU;QACrCC,WAAWH,MAAMG,QAAQ,CAACD;IAC3B,OAAO;QACNK,QAAQC,IAAI,CAAC,CAAC,uBAAuB,CAAC,EAAEN;QACxC;IACD;IACA,OAAOC;AACR"}
|