@okcy/core 1.0.0

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/README.md ADDED
@@ -0,0 +1,41 @@
1
+ # @okcy/core
2
+
3
+ Vue 3 工具库,聚合常用工具函数与 composable。
4
+
5
+ ## 安装
6
+
7
+ ```bash
8
+ pnpm add @okcy/core
9
+ ```
10
+
11
+ ## 入口
12
+
13
+ | 子路径 | 说明 |
14
+ |--------|------|
15
+ | `.` / `./index` | 空入口(仅类型导出) |
16
+ | `./utils` | 通用工具:`@vueuse/core` 重导出、字符串/数组/Oss 工具、Vue composable、Zod、断言等 |
17
+ | `./toolkit` | es-toolkit 兼容层 + `isNotNil` / `isJSON` / `pascalCase` / `isBlank` / `isPositive` |
18
+ | `./crypto` | `crypto.js` 重导出 |
19
+ | `./dayjs` | dayjs + 中文语言包 + `DatePattern`(`ll`/`lll`/`LL`/`LLL`)+ 无效日期 fallback `--` |
20
+ | `./emittery` | emittery 重导出 |
21
+
22
+ ## 用法示例
23
+
24
+ ```ts
25
+ import { dayjs, DatePattern, localeZhCn } from "@okcy/core/dayjs";
26
+ localeZhCn();
27
+ dayjs("2024-01-01").format(DatePattern.ll); // "2024-01-01"
28
+
29
+ import { isNotNil, pascalCase } from "@okcy/core/toolkit";
30
+ pascalCase("hello-world"); // "HelloWorld"
31
+
32
+ import { AliOssAbstract } from "@okcy/core/utils";
33
+ class MyOss extends AliOssAbstract {
34
+ baseUrl = "https://my-bucket.oss-cn-hangzhou.aliyuncs.com";
35
+ }
36
+ ```
37
+
38
+ ## 依赖
39
+
40
+ - Vue 3、`@vueuse/core`
41
+ - dayjs、crypto.js、emittery、es-toolkit、zod
@@ -0,0 +1 @@
1
+ export * from "crypto.js";
@@ -0,0 +1,2 @@
1
+ export * from "crypto.js";
2
+ export {};
@@ -0,0 +1,12 @@
1
+ import "dayjs/locale/zh-cn.js";
2
+ import dayjs from "dayjs/esm/index.js";
3
+ //#region src/dayjs.d.ts
4
+ export declare const DatePattern: {
5
+ ll: string;
6
+ lll: string;
7
+ LL: string;
8
+ LLL: string;
9
+ };
10
+ export declare const localeZhCn: () => void;
11
+ //#endregion
12
+ export { dayjs };
package/dist/dayjs.mjs ADDED
@@ -0,0 +1,21 @@
1
+ import "dayjs/locale/zh-cn.js";
2
+ import dayjs from "dayjs/esm/index.js";
3
+ //#region src/dayjs.ts
4
+ const DatePattern = {
5
+ ll: "YYYY-MM-DD",
6
+ lll: "YYYY-MM-DD HH:mm",
7
+ LL: "YYYY年MM月DD日",
8
+ LLL: "YYYY年MM月DD日 HH:mm"
9
+ };
10
+ const localeZhCn = () => {
11
+ dayjs.locale("zh-cn");
12
+ dayjs.extend(function(dayjsClass, Ctor, dayjs) {
13
+ const _format = Ctor.prototype.format;
14
+ Ctor.prototype.format = function(format) {
15
+ const fun = _format.bind(this);
16
+ return this.isValid() ? fun(format) : "--";
17
+ };
18
+ });
19
+ };
20
+ //#endregion
21
+ export { DatePattern, dayjs, localeZhCn };
@@ -0,0 +1,2 @@
1
+ import Emitter from "emittery";
2
+ export { Emitter, Emitter as Emittery, Emitter as default };
@@ -0,0 +1,5 @@
1
+ import Emitter from "emittery";
2
+ //#region src/emittery.ts
3
+ var emittery_default = Emitter;
4
+ //#endregion
5
+ export { Emitter, Emitter as Emittery, emittery_default as default };
@@ -0,0 +1 @@
1
+ export {}
package/dist/index.mjs ADDED
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,14 @@
1
+ import { isJSON, isNotNil } from "es-toolkit";
2
+ export * from "es-toolkit/compat";
3
+ //#region src/es-toolkit/my.d.ts
4
+ export declare const isPositive: (n: any) => boolean;
5
+ /**
6
+ * 将字符串转换为 PascalCase
7
+ * 支持 kebab-case, snake_case, camelCase, 空格分隔等格式
8
+ * @param {string} str - 输入字符串
9
+ * @returns {string} PascalCase 格式的字符串
10
+ */
11
+ export declare const pascalCase: (str: string) => string;
12
+ export declare const isBlank: (value: unknown) => boolean;
13
+ //#endregion
14
+ export { isJSON, isNotNil };
@@ -0,0 +1,21 @@
1
+ import { isJSON, isNil, isNotNil, isString } from "es-toolkit";
2
+ export * from "es-toolkit/compat";
3
+ //#region src/es-toolkit/my.ts
4
+ const isPositive = (n) => typeof n === "number" && !isNaN(n) && n > 0;
5
+ /**
6
+ * 将字符串转换为 PascalCase
7
+ * 支持 kebab-case, snake_case, camelCase, 空格分隔等格式
8
+ * @param {string} str - 输入字符串
9
+ * @returns {string} PascalCase 格式的字符串
10
+ */
11
+ const pascalCase = (str) => {
12
+ if (typeof str !== "string") return "";
13
+ return str.replace(/([a-z])([A-Z])/g, "$1 $2").replace(/[-_\s]+/g, " ").trim().split(/\s+/).filter(Boolean).map((word) => word.charAt(0).toUpperCase() + word.slice(1).toLowerCase()).join("");
14
+ };
15
+ const isBlank = (value) => {
16
+ if (isNil(value)) return true;
17
+ if (isString(value)) return value.trim() === "";
18
+ return true;
19
+ };
20
+ //#endregion
21
+ export { isBlank, isJSON, isNotNil, isPositive, pascalCase };
@@ -0,0 +1,536 @@
1
+ import { ComponentInternalInstance, DefineSetupFnComponent, InjectionKey, Ref, VNode } from "vue";
2
+ import * as z from "zod";
3
+ import { ZodType } from "zod";
4
+ export * from "@vueuse/core";
5
+ //#region src/utils/strUtil.d.ts
6
+ export declare const replaceImgSrc: (html: string, func: (src: string) => string) => string;
7
+ export declare const fixHtml: (html: string, func: (src: string) => string) => string;
8
+ /**
9
+ * 文字
10
+ * @param name
11
+ * @returns
12
+ */
13
+ export declare const nameGradient: (name: string) => string;
14
+ //#endregion
15
+ //#region src/utils/array.d.ts
16
+ /**
17
+ * 转树结构
18
+ * @param array
19
+ * @param pid
20
+ * @param childrenKey
21
+ */
22
+ export declare const arrayToArrayTree: <T>(array: T[], pid?: string, childrenKey?: string) => T[];
23
+ //#endregion
24
+ //#region src/utils/util.d.ts
25
+ /**
26
+ * 生成uuid
27
+ * @param size 大小
28
+ * @returns uuid
29
+ */
30
+ export declare const generateUUID: (size?: number) => string;
31
+ /**
32
+ * 数字穿插函数
33
+ * @param arr 数组
34
+ * @param separator 分隔符
35
+ * @param arr 数组
36
+ */
37
+ export declare const intersperse: <T>(arr: T[], separator: T) => T[];
38
+ /**
39
+ * 数字穿插函数 [1,2,3]=>[1,0,2,0,3]
40
+ * @param arr 数组
41
+ * @param fun 函数
42
+ * @param arr 数组
43
+ */
44
+ export declare const intersperseFun: <T>(arr: T[], fun: (index: number) => T) => T[];
45
+ //#endregion
46
+ //#region src/utils/ossUtil.d.ts
47
+ interface StrCndImg {
48
+ /**
49
+ * lfit:等比缩放,缩放图限制为指定w与h的矩形内的最大图片。
50
+ * mfit:等比缩放,缩放图为延伸出指定w与h的矩形框外的最小图片。
51
+ * fill(默认值):将原图等比缩放为延伸出指定w与h的矩形框外的最小图片,之后将超出的部分进行居中裁剪。
52
+ * pad:将原图缩放为指定w与h的矩形内的最大图片,之后使用指定颜色居中填充空白部分。
53
+ * fixed:固定宽高,强制缩放。
54
+ */
55
+ m: "lfit" | "mfit" | "fill" | "pad" | "fixed";
56
+ w: number;
57
+ h: number;
58
+ /**
59
+ * 背景颜色
60
+ */
61
+ c: string;
62
+ /**
63
+ * 指定目标缩放图的最长边。
64
+ */
65
+ l: number;
66
+ /**
67
+ * 指定目标缩放图的最短边。
68
+ */
69
+ s: number;
70
+ }
71
+ export interface OSS {
72
+ baseUrl: string;
73
+ /**
74
+ * 生成ossurl
75
+ * @param src 图片url
76
+ * @param origin 是否包含域名
77
+ * @param search 是否包含查询参数
78
+ * @returns url
79
+ */
80
+ cdnUrl(src: string, origin?: boolean, search?: boolean): string;
81
+ /**
82
+ * 生成oss图片url
83
+ * @param src 图片url
84
+ * @param options 图片参数
85
+ * @returns 图片url
86
+ */
87
+ cdnImg(src: string, options: Partial<StrCndImg>): string;
88
+ }
89
+ /**
90
+ * 阿里云 oss
91
+ */
92
+ export declare abstract class AliOssAbstract implements OSS {
93
+ abstract baseUrl: string;
94
+ cdnImg: (src?: string, options?: Partial<StrCndImg>) => string;
95
+ cdnUrl: (src?: string, origin?: boolean, search?: boolean) => string;
96
+ }
97
+ /**
98
+ * 七牛
99
+ */
100
+ export declare abstract class QiniuAbstract implements OSS {
101
+ abstract baseUrl: string;
102
+ cdnImg: (src: string, options: Partial<StrCndImg>) => string;
103
+ cdnUrl: (src: string, origin?: boolean, search?: boolean) => string;
104
+ }
105
+ /**
106
+ * 天翼云
107
+ */
108
+ export declare abstract class CtOssAbstract implements OSS {
109
+ abstract baseUrl: string;
110
+ cdnImg: (src: string, options: Partial<StrCndImg>) => string;
111
+ cdnUrl: (src: string, origin?: boolean, search?: boolean) => string;
112
+ }
113
+ //#endregion
114
+ //#region src/utils/hook.d.ts
115
+ export declare const useNodeJSX: (name: string, def?: () => any) => import("vue").ComputedRef<(() => any) | ((params?: any) => import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
116
+ [key: string]: any;
117
+ }>[]) | undefined>;
118
+ /**
119
+ * 获取上级prop没有就获取注入
120
+ * @param name
121
+ * @param defaultValue
122
+ */
123
+ export declare const useInjectProp: <T>(name: string | symbol, defaultValue?: T) => Ref<T>;
124
+ type ActionType<E = any> = {
125
+ emit?: Record<string, (...args: any) => E>;
126
+ };
127
+ type ResultAction<E extends ActionType, T> = { [K in keyof E["emit"]]: E["emit"][K] extends ((...args: infer Args) => any) ? (callback: (...args: Args) => void) => ResultAction<E, T> : never; } & T;
128
+ export declare const defineAction: <T extends Record<string, any>, Args extends any[] = [], E extends ActionType = {}>(setup: (ctx: E["emit"], ...args: Args) => T, options?: E) => (...args: Args) => ResultAction<E, T>;
129
+ //#endregion
130
+ //#region src/utils/components/createTemplate.d.ts
131
+ export type CreateTemplate = DefineSetupFnComponent<any, any, any> & {
132
+ jsx: (jsx: VNode) => void;
133
+ remove: () => void;
134
+ loadingTemplate: () => DefineSetupFnComponent<any, any, any>;
135
+ };
136
+ export declare const LOADING_KEY: unique symbol;
137
+ interface LoadingHandler {
138
+ start: () => void;
139
+ end: () => void;
140
+ }
141
+ export declare const getLoadingHandler: (instance: ComponentInternalInstance) => LoadingHandler | undefined;
142
+ /**
143
+ * 创建模板
144
+ */
145
+ export declare const useCreateTemplate: () => CreateTemplate;
146
+ /**
147
+ * 创建加载模板
148
+ */
149
+ export declare const useCreateLoading: () => {
150
+ onSuccess: (callback: (val: boolean) => void) => /*elided*/ any & {
151
+ loading: import("vue").ComputedRef<boolean>;
152
+ Template: DefineSetupFnComponent<Record<string, any>, {}, {}, Record<string, any> & {}, import("vue").PublicProps>;
153
+ };
154
+ } & {
155
+ loading: import("vue").ComputedRef<boolean>;
156
+ Template: DefineSetupFnComponent<Record<string, any>, {}, {}, Record<string, any> & {}, import("vue").PublicProps>;
157
+ };
158
+ //#endregion
159
+ //#region src/utils/vue.d.ts
160
+ /**
161
+ * 外部获取provide
162
+ * @param key
163
+ * @param instance
164
+ */
165
+ export declare const injectExternal: <T>(key: InjectionKey<T> | string, instance?: ComponentInternalInstance) => any;
166
+ //#endregion
167
+ //#region src/utils/assert.d.ts
168
+ /**
169
+ * 断言工具类
170
+ */
171
+ export declare abstract class AssertAbstract {
172
+ /**
173
+ * 统一的错误抛出方法(私有)
174
+ * @private
175
+ * @param {string} methodName - 调用断言的方法名(用于错误前缀)
176
+ * @param {string} message - 错误信息
177
+ * @throws {Error}
178
+ */
179
+ abstract throwError(methodName: string, message: string): void;
180
+ /**
181
+ * 断言条件为真,否则抛出错误
182
+ * @param {boolean} condition - 要断言的条件
183
+ * @param {string} [message='Assertion failed'] - 错误信息
184
+ */
185
+ isTrue(condition: boolean, message?: string): void;
186
+ /**
187
+ * 断言条件为假,否则抛出错误
188
+ * @param {boolean} condition - 要断言的条件
189
+ * @param {string} [message='Assertion failed'] - 错误信息
190
+ */
191
+ isFalse(condition: boolean, message?: string): void;
192
+ /**
193
+ * 断言值不为 null 或 undefined
194
+ * @param {*} value - 要检查的值
195
+ * @param {string} [message='Value must not be null or undefined'] - 错误信息
196
+ */
197
+ notNull(value: any, message?: string): void;
198
+ /**
199
+ * 断言值为非空白字符串(即:是字符串,且去除两端空白后非空)
200
+ * @param {any} value - 要检查的值
201
+ * @param {string} [message='must not be blank'] - 错误信息
202
+ */
203
+ notBlank(value: any, message?: string): void;
204
+ /**
205
+ * 断言值为指定类型
206
+ * @param {*} value - 要检查的值
207
+ * @param {string} expectedType - 期望的类型(如 'string', 'number', 'object' 等)
208
+ * @param {string} [message] - 错误信息
209
+ */
210
+ isType(value: any, expectedType: string, message?: string): void;
211
+ /**
212
+ * 断言值为非空
213
+ * @param {any} value - 要检查的字符串
214
+ * @param {string} [message='must not be empty'] - 错误信息
215
+ */
216
+ notEmpty(value: any, message?: string): void;
217
+ /**
218
+ * 断言值为整数
219
+ * @param {number} value - 要检查的数值
220
+ * @param {string} [message='Value must be an integer'] - 错误信息
221
+ */
222
+ isInteger(value: number, message?: string): void;
223
+ /**
224
+ * 断言两个值相等(使用严格相等 ===)
225
+ * @param {*} actual - 实际值
226
+ * @param {*} expected - 期望值
227
+ * @param {string} [message] - 错误信息
228
+ */
229
+ equals(actual: any, expected: any, message?: string): void;
230
+ /**
231
+ * 断言数值在指定范围内(包含边界)
232
+ * @param {number} value - 要检查的数值
233
+ * @param {number} min - 最小值(含)
234
+ * @param {number} max - 最大值(含)
235
+ * @param {string} [message] - 错误信息
236
+ */
237
+ inRange(value: number, min: number, max: number, message?: string): void;
238
+ }
239
+ //#endregion
240
+ //#region src/utils/zod.d.ts
241
+ declare const zod: {
242
+ ZodError: z.core.$constructor<z.ZodError<unknown>, z.core.$ZodIssue[]>;
243
+ ZodRealError: z.core.$constructor<z.ZodError>;
244
+ parse: <T extends z.core.$ZodType>(schema: T, value: unknown, _ctx?: z.core.ParseContext<z.core.$ZodIssue>, _params?: {
245
+ callee?: z.util.AnyFunc;
246
+ Err?: z.core.$ZodErrorClass;
247
+ }) => z.TypeOf<T>;
248
+ parseAsync: <T extends z.core.$ZodType>(schema: T, value: unknown, _ctx?: z.core.ParseContext<z.core.$ZodIssue>, _params?: {
249
+ callee?: z.util.AnyFunc;
250
+ Err?: z.core.$ZodErrorClass;
251
+ }) => Promise<z.TypeOf<T>>;
252
+ safeParse: <T extends z.core.$ZodType>(schema: T, value: unknown, _ctx?: z.core.ParseContext<z.core.$ZodIssue>) => z.ZodSafeParseResult<z.TypeOf<T>>;
253
+ safeParseAsync: <T extends z.core.$ZodType>(schema: T, value: unknown, _ctx?: z.core.ParseContext<z.core.$ZodIssue>) => Promise<z.ZodSafeParseResult<z.TypeOf<T>>>;
254
+ encode: <T extends z.core.$ZodType>(schema: T, value: z.TypeOf<T>, _ctx?: z.core.ParseContext<z.core.$ZodIssue>) => z.input<T>;
255
+ decode: <T extends z.core.$ZodType>(schema: T, value: z.input<T>, _ctx?: z.core.ParseContext<z.core.$ZodIssue>) => z.TypeOf<T>;
256
+ encodeAsync: <T extends z.core.$ZodType>(schema: T, value: z.TypeOf<T>, _ctx?: z.core.ParseContext<z.core.$ZodIssue>) => Promise<z.input<T>>;
257
+ decodeAsync: <T extends z.core.$ZodType>(schema: T, value: z.input<T>, _ctx?: z.core.ParseContext<z.core.$ZodIssue>) => Promise<z.TypeOf<T>>;
258
+ safeEncode: <T extends z.core.$ZodType>(schema: T, value: z.TypeOf<T>, _ctx?: z.core.ParseContext<z.core.$ZodIssue>) => z.ZodSafeParseResult<z.input<T>>;
259
+ safeDecode: <T extends z.core.$ZodType>(schema: T, value: z.input<T>, _ctx?: z.core.ParseContext<z.core.$ZodIssue>) => z.ZodSafeParseResult<z.TypeOf<T>>;
260
+ safeEncodeAsync: <T extends z.core.$ZodType>(schema: T, value: z.TypeOf<T>, _ctx?: z.core.ParseContext<z.core.$ZodIssue>) => Promise<z.ZodSafeParseResult<z.input<T>>>;
261
+ safeDecodeAsync: <T extends z.core.$ZodType>(schema: T, value: z.input<T>, _ctx?: z.core.ParseContext<z.core.$ZodIssue>) => Promise<z.ZodSafeParseResult<z.TypeOf<T>>>;
262
+ ZodType: z.core.$constructor<ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>, z.core.$ZodTypeDef>;
263
+ _ZodString: z.core.$constructor<z._ZodString<z.core.$ZodStringInternals<unknown>>, z.core.$ZodStringDef>;
264
+ ZodString: z.core.$constructor<z.ZodString, z.core.$ZodStringDef>;
265
+ string(params?: string | z.core.$ZodStringParams): z.ZodString;
266
+ string<T extends string>(params?: string | z.core.$ZodStringParams): z.core.$ZodType<T, T>;
267
+ ZodStringFormat: z.core.$constructor<z.ZodStringFormat<string>, z.core.$ZodStringFormatDef<string>>;
268
+ ZodEmail: z.core.$constructor<z.ZodEmail, z.core.$ZodStringFormatDef<"email">>;
269
+ email(params?: string | z.core.$ZodEmailParams): z.ZodEmail;
270
+ ZodGUID: z.core.$constructor<z.ZodGUID, z.core.$ZodStringFormatDef<"guid">>;
271
+ guid(params?: string | z.core.$ZodGUIDParams): z.ZodGUID;
272
+ ZodUUID: z.core.$constructor<z.ZodUUID, z.core.$ZodUUIDDef>;
273
+ uuid(params?: string | z.core.$ZodUUIDParams): z.ZodUUID;
274
+ uuidv4(params?: string | z.core.$ZodUUIDv4Params): z.ZodUUID;
275
+ uuidv6(params?: string | z.core.$ZodUUIDv6Params): z.ZodUUID;
276
+ uuidv7(params?: string | z.core.$ZodUUIDv7Params): z.ZodUUID;
277
+ ZodURL: z.core.$constructor<z.ZodURL, z.core.$ZodURLDef>;
278
+ url(params?: string | z.core.$ZodURLParams): z.ZodURL;
279
+ httpUrl(params?: string | Omit<z.core.$ZodURLParams, "protocol" | "hostname">): z.ZodURL;
280
+ ZodEmoji: z.core.$constructor<z.ZodEmoji, z.core.$ZodStringFormatDef<"emoji">>;
281
+ emoji(params?: string | z.core.$ZodEmojiParams): z.ZodEmoji;
282
+ ZodNanoID: z.core.$constructor<z.ZodNanoID, z.core.$ZodStringFormatDef<"nanoid">>;
283
+ nanoid(params?: string | z.core.$ZodNanoIDParams): z.ZodNanoID;
284
+ ZodCUID: z.core.$constructor<z.ZodCUID, z.core.$ZodStringFormatDef<"cuid">>;
285
+ cuid(params?: string | z.core.$ZodCUIDParams): z.ZodCUID;
286
+ ZodCUID2: z.core.$constructor<z.ZodCUID2, z.core.$ZodStringFormatDef<"cuid2">>;
287
+ cuid2(params?: string | z.core.$ZodCUID2Params): z.ZodCUID2;
288
+ ZodULID: z.core.$constructor<z.ZodULID, z.core.$ZodStringFormatDef<"ulid">>;
289
+ ulid(params?: string | z.core.$ZodULIDParams): z.ZodULID;
290
+ ZodXID: z.core.$constructor<z.ZodXID, z.core.$ZodStringFormatDef<"xid">>;
291
+ xid(params?: string | z.core.$ZodXIDParams): z.ZodXID;
292
+ ZodKSUID: z.core.$constructor<z.ZodKSUID, z.core.$ZodStringFormatDef<"ksuid">>;
293
+ ksuid(params?: string | z.core.$ZodKSUIDParams): z.ZodKSUID;
294
+ ZodIPv4: z.core.$constructor<z.ZodIPv4, z.core.$ZodIPv4Def>;
295
+ ipv4(params?: string | z.core.$ZodIPv4Params): z.ZodIPv4;
296
+ ZodMAC: z.core.$constructor<z.ZodMAC, z.core.$ZodMACDef>;
297
+ mac(params?: string | z.core.$ZodMACParams): z.ZodMAC;
298
+ ZodIPv6: z.core.$constructor<z.ZodIPv6, z.core.$ZodIPv6Def>;
299
+ ipv6(params?: string | z.core.$ZodIPv6Params): z.ZodIPv6;
300
+ ZodCIDRv4: z.core.$constructor<z.ZodCIDRv4, z.core.$ZodCIDRv4Def>;
301
+ cidrv4(params?: string | z.core.$ZodCIDRv4Params): z.ZodCIDRv4;
302
+ ZodCIDRv6: z.core.$constructor<z.ZodCIDRv6, z.core.$ZodCIDRv6Def>;
303
+ cidrv6(params?: string | z.core.$ZodCIDRv6Params): z.ZodCIDRv6;
304
+ ZodBase64: z.core.$constructor<z.ZodBase64, z.core.$ZodStringFormatDef<"base64">>;
305
+ base64(params?: string | z.core.$ZodBase64Params): z.ZodBase64;
306
+ ZodBase64URL: z.core.$constructor<z.ZodBase64URL, z.core.$ZodStringFormatDef<"base64url">>;
307
+ base64url(params?: string | z.core.$ZodBase64URLParams): z.ZodBase64URL;
308
+ ZodE164: z.core.$constructor<z.ZodE164, z.core.$ZodStringFormatDef<"e164">>;
309
+ e164(params?: string | z.core.$ZodE164Params): z.ZodE164;
310
+ ZodJWT: z.core.$constructor<z.ZodJWT, z.core.$ZodJWTDef>;
311
+ jwt(params?: string | z.core.$ZodJWTParams): z.ZodJWT;
312
+ ZodCustomStringFormat: z.core.$constructor<z.ZodCustomStringFormat<string>, z.core.$ZodCustomStringFormatDef<string>>;
313
+ stringFormat<Format extends string>(format: Format, fnOrRegex: ((arg: string) => z.util.MaybeAsync<unknown>) | RegExp, _params?: string | z.core.$ZodStringFormatParams): z.ZodCustomStringFormat<Format>;
314
+ hostname(_params?: string | z.core.$ZodStringFormatParams): z.ZodCustomStringFormat<"hostname">;
315
+ hex(_params?: string | z.core.$ZodStringFormatParams): z.ZodCustomStringFormat<"hex">;
316
+ hash<Alg extends z.util.HashAlgorithm, Enc extends z.util.HashEncoding = "hex">(alg: Alg, params?: {
317
+ enc?: Enc;
318
+ } & z.core.$ZodStringFormatParams): z.ZodCustomStringFormat<`${Alg}_${Enc}`>;
319
+ ZodNumber: z.core.$constructor<z.ZodNumber, z.core.$ZodNumberDef>;
320
+ number(params?: string | z.core.$ZodNumberParams): z.ZodNumber;
321
+ ZodNumberFormat: z.core.$constructor<z.ZodNumberFormat, z.core.$ZodNumberFormatDef>;
322
+ int(params?: string | z.core.$ZodCheckNumberFormatParams): z.ZodInt;
323
+ float32(params?: string | z.core.$ZodCheckNumberFormatParams): z.ZodFloat32;
324
+ float64(params?: string | z.core.$ZodCheckNumberFormatParams): z.ZodFloat64;
325
+ int32(params?: string | z.core.$ZodCheckNumberFormatParams): z.ZodInt32;
326
+ uint32(params?: string | z.core.$ZodCheckNumberFormatParams): z.ZodUInt32;
327
+ ZodBoolean: z.core.$constructor<z.ZodBoolean, z.core.$ZodBooleanDef>;
328
+ boolean(params?: string | z.core.$ZodBooleanParams): z.ZodBoolean;
329
+ ZodBigInt: z.core.$constructor<z.ZodBigInt, z.core.$ZodBigIntDef>;
330
+ bigint(params?: string | z.core.$ZodBigIntParams): z.ZodBigInt;
331
+ ZodBigIntFormat: z.core.$constructor<z.ZodBigIntFormat, z.core.$ZodBigIntFormatDef>;
332
+ int64(params?: string | z.core.$ZodBigIntFormatParams): z.ZodBigIntFormat;
333
+ uint64(params?: string | z.core.$ZodBigIntFormatParams): z.ZodBigIntFormat;
334
+ ZodSymbol: z.core.$constructor<z.ZodSymbol, z.core.$ZodSymbolDef>;
335
+ symbol(params?: string | z.core.$ZodSymbolParams): z.ZodSymbol;
336
+ ZodUndefined: z.core.$constructor<z.ZodUndefined, z.core.$ZodUndefinedDef>;
337
+ undefined: typeof z.undefined;
338
+ ZodNull: z.core.$constructor<z.ZodNull, z.core.$ZodNullDef>;
339
+ null: typeof z.null;
340
+ ZodAny: z.core.$constructor<z.ZodAny, z.core.$ZodAnyDef>;
341
+ any(): z.ZodAny;
342
+ ZodUnknown: z.core.$constructor<z.ZodUnknown, z.core.$ZodUnknownDef>;
343
+ unknown(): z.ZodUnknown;
344
+ ZodNever: z.core.$constructor<z.ZodNever, z.core.$ZodNeverDef>;
345
+ never(params?: string | z.core.$ZodNeverParams): z.ZodNever;
346
+ ZodVoid: z.core.$constructor<z.ZodVoid, z.core.$ZodVoidDef>;
347
+ void: typeof z.void;
348
+ ZodDate: z.core.$constructor<z.ZodDate, z.core.$ZodDateDef>;
349
+ date(params?: string | z.core.$ZodDateParams): z.ZodDate;
350
+ ZodArray: z.core.$constructor<z.ZodArray<z.core.$ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>>, z.core.$ZodArrayDef<z.core.$ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>>>;
351
+ array<T extends z.core.SomeType>(element: T, params?: string | z.core.$ZodArrayParams): z.ZodArray<T>;
352
+ keyof<T extends z.ZodObject>(schema: T): z.ZodEnum<z.util.KeysEnum<T["_zod"]["output"]>>;
353
+ ZodObject: z.core.$constructor<z.ZodObject<z.core.$ZodLooseShape, z.core.$strip>, z.core.$ZodObjectDef<z.core.$ZodLooseShape>>;
354
+ object<T extends z.core.$ZodLooseShape = Partial<Record<never, z.core.SomeType>>>(shape?: T, params?: string | z.core.$ZodObjectParams): z.ZodObject<z.util.Writeable<T>, z.core.$strip>;
355
+ strictObject<T extends z.core.$ZodLooseShape>(shape: T, params?: string | z.core.$ZodObjectParams): z.ZodObject<T, z.core.$strict>;
356
+ looseObject<T extends z.core.$ZodLooseShape>(shape: T, params?: string | z.core.$ZodObjectParams): z.ZodObject<T, z.core.$loose>;
357
+ ZodUnion: z.core.$constructor<z.ZodUnion<readonly z.core.$ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>[]>, z.core.$ZodUnionDef<readonly z.core.$ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>[]>>;
358
+ union<const T extends readonly z.core.SomeType[]>(options: T, params?: string | z.core.$ZodUnionParams): z.ZodUnion<T>;
359
+ ZodXor: z.core.$constructor<z.ZodXor<readonly z.core.$ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>[]>, z.core.$ZodUnionDef<readonly z.core.$ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>[]>>;
360
+ xor<const T extends readonly z.core.SomeType[]>(options: T, params?: string | z.core.$ZodXorParams): z.ZodXor<T>;
361
+ ZodDiscriminatedUnion: z.core.$constructor<z.ZodDiscriminatedUnion<readonly z.core.$ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>[], string>, z.core.$ZodDiscriminatedUnionDef<readonly z.core.$ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>[], string>>;
362
+ discriminatedUnion<Types extends readonly [z.core.$ZodTypeDiscriminable, ...z.core.$ZodTypeDiscriminable[]], Disc extends string>(discriminator: Disc, options: Types, params?: string | z.core.$ZodDiscriminatedUnionParams): z.ZodDiscriminatedUnion<Types, Disc>;
363
+ ZodIntersection: z.core.$constructor<z.ZodIntersection<z.core.$ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>, z.core.$ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>>, z.core.$ZodIntersectionDef<z.core.$ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>, z.core.$ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>>>;
364
+ intersection<T extends z.core.SomeType, U extends z.core.SomeType>(left: T, right: U): z.ZodIntersection<T, U>;
365
+ ZodTuple: z.core.$constructor<z.ZodTuple<readonly z.core.$ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>[], z.core.$ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>> | null>, z.core.$ZodTupleDef<readonly z.core.$ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>[], z.core.$ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>> | null>>;
366
+ tuple<T extends readonly [z.core.SomeType, ...z.core.SomeType[]]>(items: T, params?: string | z.core.$ZodTupleParams): z.ZodTuple<T, null>;
367
+ tuple<T extends readonly [z.core.SomeType, ...z.core.SomeType[]], Rest extends z.core.SomeType>(items: T, rest: Rest, params?: string | z.core.$ZodTupleParams): z.ZodTuple<T, Rest>;
368
+ tuple(items: [], params?: string | z.core.$ZodTupleParams): z.ZodTuple<[], null>;
369
+ ZodRecord: z.core.$constructor<z.ZodRecord<z.core.$ZodRecordKey, z.core.$ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>>, z.core.$ZodRecordDef<z.core.$ZodRecordKey, z.core.$ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>>>;
370
+ record<Key extends z.core.$ZodRecordKey, Value extends z.core.SomeType>(keyType: Key, valueType: Value, params?: string | z.core.$ZodRecordParams): z.ZodRecord<Key, Value>;
371
+ partialRecord<Key extends z.core.$ZodRecordKey, Value extends z.core.SomeType>(keyType: Key, valueType: Value, params?: string | z.core.$ZodRecordParams): z.ZodRecord<Key & z.core.$partial, Value>;
372
+ looseRecord<Key extends z.core.$ZodRecordKey, Value extends z.core.SomeType>(keyType: Key, valueType: Value, params?: string | z.core.$ZodRecordParams): z.ZodRecord<Key, Value>;
373
+ ZodMap: z.core.$constructor<z.ZodMap<z.core.$ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>, z.core.$ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>>, z.core.$ZodMapDef<z.core.$ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>, z.core.$ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>>>;
374
+ map<Key extends z.core.SomeType, Value extends z.core.SomeType>(keyType: Key, valueType: Value, params?: string | z.core.$ZodMapParams): z.ZodMap<Key, Value>;
375
+ ZodSet: z.core.$constructor<z.ZodSet<z.core.$ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>>, z.core.$ZodSetDef<z.core.$ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>>>;
376
+ set<Value extends z.core.SomeType>(valueType: Value, params?: string | z.core.$ZodSetParams): z.ZodSet<Value>;
377
+ ZodEnum: z.core.$constructor<z.ZodEnum<Readonly<Record<string, z.util.EnumValue>>>, z.core.$ZodEnumDef<Readonly<Record<string, z.util.EnumValue>>>>;
378
+ enum: typeof z.enum;
379
+ nativeEnum<T extends z.util.EnumLike>(entries: T, params?: string | z.core.$ZodEnumParams): z.ZodEnum<T>;
380
+ ZodLiteral: z.core.$constructor<z.ZodLiteral<z.util.Literal>, z.core.$ZodLiteralDef<z.util.Literal>>;
381
+ literal<const T extends ReadonlyArray<z.util.Literal>>(value: T, params?: string | z.core.$ZodLiteralParams): z.ZodLiteral<T[number]>;
382
+ literal<const T extends z.util.Literal>(value: T, params?: string | z.core.$ZodLiteralParams): z.ZodLiteral<T>;
383
+ ZodFile: z.core.$constructor<z.ZodFile, z.core.$ZodFileDef>;
384
+ file(params?: string | z.core.$ZodFileParams): z.ZodFile;
385
+ ZodTransform: z.core.$constructor<z.ZodTransform<unknown, unknown>, z.core.$ZodTransformDef>;
386
+ transform<I = unknown, O = I>(fn: (input: I, ctx: z.core.ParsePayload) => O): z.ZodTransform<Awaited<O>, I>;
387
+ ZodOptional: z.core.$constructor<z.ZodOptional<z.core.$ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>>, z.core.$ZodOptionalDef<z.core.$ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>>>;
388
+ optional<T extends z.core.SomeType>(innerType: T): z.ZodOptional<T>;
389
+ ZodExactOptional: z.core.$constructor<z.ZodExactOptional<z.core.$ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>>, z.core.$ZodExactOptionalDef<z.core.$ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>>>;
390
+ exactOptional<T extends z.core.SomeType>(innerType: T): z.ZodExactOptional<T>;
391
+ ZodNullable: z.core.$constructor<z.ZodNullable<z.core.$ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>>, z.core.$ZodNullableDef<z.core.$ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>>>;
392
+ nullable<T extends z.core.SomeType>(innerType: T): z.ZodNullable<T>;
393
+ nullish<T extends z.core.SomeType>(innerType: T): z.ZodOptional<z.ZodNullable<T>>;
394
+ ZodDefault: z.core.$constructor<z.ZodDefault<z.core.$ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>>, z.core.$ZodDefaultDef<z.core.$ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>>>;
395
+ _default<T extends z.core.SomeType>(innerType: T, defaultValue: z.util.NoUndefined<z.TypeOf<T>> | (() => z.util.NoUndefined<z.TypeOf<T>>)): z.ZodDefault<T>;
396
+ ZodPrefault: z.core.$constructor<z.ZodPrefault<z.core.$ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>>, z.core.$ZodPrefaultDef<z.core.$ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>>>;
397
+ prefault<T extends z.core.SomeType>(innerType: T, defaultValue: z.input<T> | (() => z.input<T>)): z.ZodPrefault<T>;
398
+ ZodNonOptional: z.core.$constructor<z.ZodNonOptional<z.core.$ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>>, z.core.$ZodNonOptionalDef<z.core.$ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>>>;
399
+ nonoptional<T extends z.core.SomeType>(innerType: T, params?: string | z.core.$ZodNonOptionalParams): z.ZodNonOptional<T>;
400
+ ZodSuccess: z.core.$constructor<z.ZodSuccess<z.core.$ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>>, z.core.$ZodSuccessDef<z.core.$ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>>>;
401
+ success<T extends z.core.SomeType>(innerType: T): z.ZodSuccess<T>;
402
+ ZodCatch: z.core.$constructor<z.ZodCatch<z.core.$ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>>, z.core.$ZodCatchDef<z.core.$ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>>>;
403
+ catch: typeof z.catch;
404
+ ZodNaN: z.core.$constructor<z.ZodNaN, z.core.$ZodNaNDef>;
405
+ nan(params?: string | z.core.$ZodNaNParams): z.ZodNaN;
406
+ ZodPipe: z.core.$constructor<z.ZodPipe<z.core.$ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>, z.core.$ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>>, z.core.$ZodPipeDef<z.core.$ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>, z.core.$ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>>>;
407
+ pipe<const A extends z.core.SomeType, B extends z.core.$ZodType<unknown, z.TypeOf<A>> = z.core.$ZodType<unknown, z.TypeOf<A>, z.core.$ZodTypeInternals<unknown, z.TypeOf<A>>>>(in_: A, out: B | z.core.$ZodType<unknown, z.TypeOf<A>>): z.ZodPipe<A, B>;
408
+ ZodCodec: z.core.$constructor<z.ZodCodec<z.core.$ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>, z.core.$ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>>, z.core.$ZodCodecDef<z.core.$ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>, z.core.$ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>>>;
409
+ codec<const A extends z.core.SomeType, B extends z.core.SomeType = z.core.$ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>>(in_: A, out: B, params: {
410
+ decode: (value: z.TypeOf<A>, payload: z.core.ParsePayload<z.TypeOf<A>>) => z.util.MaybeAsync<z.input<B>>;
411
+ encode: (value: z.input<B>, payload: z.core.ParsePayload<z.input<B>>) => z.util.MaybeAsync<z.TypeOf<A>>;
412
+ }): z.ZodCodec<A, B>;
413
+ ZodReadonly: z.core.$constructor<z.ZodReadonly<z.core.$ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>>, z.core.$ZodReadonlyDef<z.core.$ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>>>;
414
+ readonly<T extends z.core.SomeType>(innerType: T): z.ZodReadonly<T>;
415
+ ZodTemplateLiteral: z.core.$constructor<z.ZodTemplateLiteral<string>, z.core.$ZodTemplateLiteralDef>;
416
+ templateLiteral<const Parts extends z.core.$ZodTemplateLiteralPart[]>(parts: Parts, params?: string | z.core.$ZodTemplateLiteralParams): z.ZodTemplateLiteral<z.core.$PartsToTemplateLiteral<Parts>>;
417
+ ZodLazy: z.core.$constructor<z.ZodLazy<z.core.$ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>>, z.core.$ZodLazyDef<z.core.$ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>>>;
418
+ lazy<T extends z.core.SomeType>(getter: () => T): z.ZodLazy<T>;
419
+ ZodPromise: z.core.$constructor<z.ZodPromise<z.core.$ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>>, z.core.$ZodPromiseDef<z.core.$ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>>>;
420
+ promise<T extends z.core.SomeType>(innerType: T): z.ZodPromise<T>;
421
+ ZodFunction: z.core.$constructor<z.ZodFunction<z.core.$ZodFunctionArgs, z.core.$ZodFunctionOut>, z.core.$ZodFunctionDef<z.core.$ZodFunctionArgs, z.core.$ZodFunctionOut>>;
422
+ _function(): z.ZodFunction;
423
+ _function<const In extends ReadonlyArray<z.core.$ZodType>>(params: {
424
+ input: In;
425
+ }): z.ZodFunction<z.ZodTuple<In, null>, z.core.$ZodFunctionOut>;
426
+ _function<const In extends ReadonlyArray<z.core.$ZodType>, const Out extends z.core.$ZodFunctionOut = z.core.$ZodFunctionOut>(params: {
427
+ input: In;
428
+ output: Out;
429
+ }): z.ZodFunction<z.ZodTuple<In, null>, Out>;
430
+ _function<const In extends z.core.$ZodFunctionIn = z.core.$ZodFunctionArgs>(params: {
431
+ input: In;
432
+ }): z.ZodFunction<In, z.core.$ZodFunctionOut>;
433
+ _function<const Out extends z.core.$ZodFunctionOut = z.core.$ZodFunctionOut>(params: {
434
+ output: Out;
435
+ }): z.ZodFunction<z.core.$ZodFunctionIn, Out>;
436
+ _function<In extends z.core.$ZodFunctionIn = z.core.$ZodFunctionArgs, Out extends z.core.$ZodType = z.core.$ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>>(params?: {
437
+ input: In;
438
+ output: Out;
439
+ }): z.ZodFunction<In, Out>;
440
+ function: typeof z._function;
441
+ ZodCustom: z.core.$constructor<z.ZodCustom<unknown, unknown>, z.core.$ZodCustomDef<unknown>>;
442
+ check<O = unknown>(fn: z.core.CheckFn<O>): z.core.$ZodCheck<O>;
443
+ custom<O>(fn?: (data: unknown) => unknown, _params?: string | z.core.$ZodCustomParams | undefined): z.ZodCustom<O, O>;
444
+ refine<T>(fn: (arg: NoInfer<T>) => z.util.MaybeAsync<unknown>, _params?: string | z.core.$ZodCustomParams): z.core.$ZodCheck<T>;
445
+ superRefine<T>(fn: (arg: T, payload: z.RefinementCtx<T>) => void | Promise<void>): z.core.$ZodCheck<T>;
446
+ describe: typeof z.core.describe;
447
+ meta: typeof z.core.meta;
448
+ instanceof: typeof z.instanceof;
449
+ stringbool: (_params?: string | z.core.$ZodStringBoolParams) => z.ZodCodec<z.ZodString, z.ZodBoolean>;
450
+ json(params?: string | z.core.$ZodCustomParams): z.ZodJSONSchema;
451
+ preprocess<A, U extends z.core.SomeType, B = unknown>(fn: (arg: B, ctx: z.RefinementCtx) => A, schema: U): z.ZodPipe<z.ZodTransform<A, B>, U>;
452
+ lt: typeof z.lt;
453
+ lte: typeof z.lte;
454
+ gt: typeof z.gt;
455
+ gte: typeof z.gte;
456
+ positive: typeof z.positive;
457
+ negative: typeof z.negative;
458
+ nonpositive: typeof z.nonpositive;
459
+ nonnegative: typeof z.nonnegative;
460
+ multipleOf: typeof z.multipleOf;
461
+ maxSize: typeof z.maxSize;
462
+ minSize: typeof z.minSize;
463
+ size: typeof z.size;
464
+ maxLength: typeof z.maxLength;
465
+ minLength: typeof z.minLength;
466
+ length: typeof z.length;
467
+ regex: typeof z.regex;
468
+ lowercase: typeof z.lowercase;
469
+ uppercase: typeof z.uppercase;
470
+ includes: typeof z.includes;
471
+ startsWith: typeof z.startsWith;
472
+ endsWith: typeof z.endsWith;
473
+ property: typeof z.property;
474
+ mime: typeof z.mime;
475
+ overwrite: typeof z.overwrite;
476
+ normalize: typeof z.normalize;
477
+ trim: typeof z.trim;
478
+ toLowerCase: typeof z.toLowerCase;
479
+ toUpperCase: typeof z.toUpperCase;
480
+ slugify: typeof z.slugify;
481
+ ZodIssueCode: {
482
+ readonly invalid_type: "invalid_type";
483
+ readonly too_big: "too_big";
484
+ readonly too_small: "too_small";
485
+ readonly invalid_format: "invalid_format";
486
+ readonly not_multiple_of: "not_multiple_of";
487
+ readonly unrecognized_keys: "unrecognized_keys";
488
+ readonly invalid_union: "invalid_union";
489
+ readonly invalid_key: "invalid_key";
490
+ readonly invalid_element: "invalid_element";
491
+ readonly invalid_value: "invalid_value";
492
+ readonly custom: "custom";
493
+ };
494
+ setErrorMap(map: z.ZodErrorMap): void;
495
+ getErrorMap(): z.ZodErrorMap<z.core.$ZodIssue> | undefined;
496
+ ZodFirstPartyTypeKind: typeof z.ZodFirstPartyTypeKind;
497
+ core: typeof z.core;
498
+ globalRegistry: z.core.$ZodRegistry<z.GlobalMeta, z.core.$ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>>;
499
+ registry: typeof z.registry;
500
+ config: typeof z.config;
501
+ $output: typeof z.$output;
502
+ $input: typeof z.$input;
503
+ $brand: typeof z.$brand;
504
+ clone: typeof z.clone;
505
+ regexes: typeof z.regexes;
506
+ treeifyError: typeof z.treeifyError;
507
+ prettifyError: typeof z.prettifyError;
508
+ formatError: typeof z.formatError;
509
+ flattenError: typeof z.flattenError;
510
+ TimePrecision: {
511
+ readonly Any: null;
512
+ readonly Minute: -1;
513
+ readonly Second: 0;
514
+ readonly Millisecond: 3;
515
+ readonly Microsecond: 6;
516
+ };
517
+ util: typeof z.util;
518
+ NEVER: never;
519
+ toJSONSchema: typeof z.toJSONSchema;
520
+ fromJSONSchema: typeof z.fromJSONSchema;
521
+ locales: typeof z.locales;
522
+ ZodISODateTime: z.core.$constructor<z.ZodISODateTime, z.core.$ZodISODateTimeDef>;
523
+ ZodISODate: z.core.$constructor<z.ZodISODate, z.core.$ZodStringFormatDef<"date">>;
524
+ ZodISOTime: z.core.$constructor<z.ZodISOTime, z.core.$ZodISOTimeDef>;
525
+ ZodISODuration: z.core.$constructor<z.ZodISODuration, z.core.$ZodStringFormatDef<"duration">>;
526
+ iso: typeof z.iso;
527
+ coerce: typeof z.coerce;
528
+ z: typeof z.z;
529
+ default: typeof z.z;
530
+ stringNonEmpty: (message?: string) => z.ZodString;
531
+ notBlank: (message?: string) => z.ZodCustom<unknown, unknown>;
532
+ notEmpty: (message?: string) => z.ZodCustom<unknown, unknown>;
533
+ isTrue: (message?: string) => z.ZodCustom<unknown, unknown>;
534
+ };
535
+ //#endregion
536
+ export { ZodType, zod };
package/dist/utils.mjs ADDED
@@ -0,0 +1,361 @@
1
+ import { isBlank } from "./toolkit.mjs";
2
+ import { useVModel } from "@vueuse/core";
3
+ import Emitter from "emittery";
4
+ import { computed, defineComponent, getCurrentInstance, inject, onMounted, onUnmounted, ref, useSlots } from "vue";
5
+ import { isNotNil } from "es-toolkit";
6
+ import { isEmpty } from "es-toolkit/compat";
7
+ import * as z from "zod";
8
+ import { ZodType } from "zod";
9
+ export * from "@vueuse/core";
10
+ //#region src/utils/strUtil.ts
11
+ const replaceImgSrc = (html, func) => {
12
+ return html?.replace(/(<img[^>]*?src=)(["']?)(.*?)\2([^>]*?>)/gi, (match, prefix, quote, src, suffix) => {
13
+ return `${prefix}${quote}${func(src)}${quote}${suffix}`;
14
+ });
15
+ };
16
+ const fixHtml = (html, func) => {
17
+ return replaceImgSrc(html, func);
18
+ };
19
+ /**
20
+ * 文字
21
+ * @param name
22
+ * @returns
23
+ */
24
+ const nameGradient = (name) => {
25
+ let hash = 0;
26
+ for (let i = 0; i < name.length; i++) hash = name.charCodeAt(i) + ((hash << 5) - hash);
27
+ const hue = (hash % 360 + 360) % 360;
28
+ return `linear-gradient(135deg,hsl(${hue}, 55%, 50%),hsl(${(hue + 35) % 360}, 58%, 62%))`;
29
+ };
30
+ //#endregion
31
+ //#region src/utils/array.ts
32
+ /**
33
+ * 转树结构
34
+ * @param array
35
+ * @param pid
36
+ * @param childrenKey
37
+ */
38
+ const arrayToArrayTree = (array, pid = "0", childrenKey) => {
39
+ const tree = [];
40
+ array.forEach((item) => {
41
+ if (item["pid"] === pid) {
42
+ const children = arrayToArrayTree(array, item["id"], childrenKey);
43
+ if (children.length) item[childrenKey || "children"] = children;
44
+ tree.push(item);
45
+ }
46
+ });
47
+ return tree;
48
+ };
49
+ //#endregion
50
+ //#region src/utils/util.ts
51
+ /**
52
+ * 生成uuid
53
+ * @param size 大小
54
+ * @returns uuid
55
+ */
56
+ const generateUUID = (size = 21) => {
57
+ const chars = "ModuleSymbhasOwnPr-0123456789ABCDEFGHNRVfgctiUvz_KqYTJkLxpZXIjQW";
58
+ let id = "";
59
+ for (let i = 0; i < size; i++) id += chars.charAt(Math.floor(Math.random() * 64));
60
+ return id;
61
+ };
62
+ /**
63
+ * 数字穿插函数
64
+ * @param arr 数组
65
+ * @param separator 分隔符
66
+ * @param arr 数组
67
+ */
68
+ const intersperse = (arr, separator) => {
69
+ if (arr.length === 0) return [];
70
+ return arr.slice(0, -1).flatMap((x) => [x, separator]).concat(arr.at(-1));
71
+ };
72
+ /**
73
+ * 数字穿插函数 [1,2,3]=>[1,0,2,0,3]
74
+ * @param arr 数组
75
+ * @param fun 函数
76
+ * @param arr 数组
77
+ */
78
+ const intersperseFun = (arr, fun) => {
79
+ if (arr.length === 0) return [];
80
+ return arr.slice(0, -1).flatMap((x, index) => [x, fun(index)]).concat(arr.at(-1));
81
+ };
82
+ //#endregion
83
+ //#region src/utils/ossUtil.ts
84
+ /**
85
+ * 阿里云 oss
86
+ */
87
+ var AliOssAbstract = class {
88
+ cdnImg = (src, options) => {
89
+ if (!src) return "";
90
+ let u = new URL(src, this.baseUrl);
91
+ if (options) {
92
+ if (!options.m) options.m = "fill";
93
+ const str = `image/resize,${Object.keys(options).map((key) => `${key}_${options[key]}`).join(",")},limit_0/auto-orient,1/quality,q_100`;
94
+ u.searchParams.append("x-oss-process", str);
95
+ }
96
+ return u.href;
97
+ };
98
+ cdnUrl = (src, origin = true, search = true) => {
99
+ if (!src) return "";
100
+ let u = new URL(src, this.baseUrl);
101
+ if (!search) u.searchParams.forEach((value, key) => u.searchParams.delete(key));
102
+ return origin ? u.href : u.pathname + u.search;
103
+ };
104
+ };
105
+ /**
106
+ * 七牛
107
+ */
108
+ var QiniuAbstract = class {
109
+ cdnImg = (src, options) => {
110
+ if (!src) return src;
111
+ let u = new URL(src, this.baseUrl);
112
+ if (options) {
113
+ if (!options.m) options.m = "fill";
114
+ const str = `imageView2/0/${Object.keys(options).map((key) => `${key}_${options[key]}`).join("/")}/format/jpg/q/75`;
115
+ u.pathname += `?` + str;
116
+ }
117
+ return u.href;
118
+ };
119
+ cdnUrl = (src, origin = true, search = true) => {
120
+ if (!src) return src;
121
+ let u = new URL(src, this.baseUrl);
122
+ if (!search) u.searchParams.forEach((value, key) => u.searchParams.delete(key));
123
+ return origin ? u.href : u.pathname + u.search;
124
+ };
125
+ };
126
+ /**
127
+ * 天翼云
128
+ */
129
+ var CtOssAbstract = class {
130
+ cdnImg = (src, options) => {
131
+ if (!src) return src;
132
+ let u = new URL(src, this.baseUrl);
133
+ if (options) {
134
+ if (!options.m) options.m = "mfit";
135
+ const str = `image/resize,${Object.keys(options).map((key) => `${key}_${options[key]}`).join(",")},limit_1/format,jpg/bright,0/contrast,0`;
136
+ u.searchParams.append("x-image-process", str);
137
+ }
138
+ return u.href;
139
+ };
140
+ cdnUrl = (src, origin = true, search = true) => {
141
+ if (!src) return src;
142
+ let u = new URL(src, this.baseUrl);
143
+ if (!search) u.searchParams.forEach((value, key) => u.searchParams.delete(key));
144
+ return origin ? u.href : u.pathname + u.search;
145
+ };
146
+ };
147
+ //#endregion
148
+ //#region src/utils/hook.ts
149
+ const useNodeJSX = (name, def) => {
150
+ const instance = getCurrentInstance();
151
+ return computed(() => {
152
+ if (!instance) return def;
153
+ const slots = useSlots();
154
+ if (slots[name]) return (params) => slots[name](params);
155
+ if (instance.props[name]) return () => instance.props[name];
156
+ return def;
157
+ });
158
+ };
159
+ /**
160
+ * 获取上级prop没有就获取注入
161
+ * @param name
162
+ * @param defaultValue
163
+ */
164
+ const useInjectProp = (name, defaultValue) => {
165
+ const instance = getCurrentInstance();
166
+ const injectValue = inject(name, defaultValue);
167
+ const key = typeof name === "symbol" ? name.description : name;
168
+ return useVModel(instance.props, key, null, {
169
+ passive: true,
170
+ defaultValue: injectValue
171
+ });
172
+ };
173
+ const defineAction = (setup, options) => {
174
+ return (...args) => {
175
+ const emitter = new Emitter();
176
+ const ctx = {};
177
+ if (options?.emit) for (const [methodName, callbackDef] of Object.entries(options.emit)) ctx[methodName] = (...args) => {
178
+ emitter.emit(methodName, args);
179
+ };
180
+ const json = setup(ctx, ...args);
181
+ if (json) {
182
+ for (const key in json) if (typeof json[key] === "function") json[key] = json[key].bind(json);
183
+ }
184
+ for (const key of Object.keys(ctx)) json[key] = (callback) => {
185
+ emitter.on(key, ({ data }) => callback(...data));
186
+ return json;
187
+ };
188
+ return json;
189
+ };
190
+ };
191
+ //#endregion
192
+ //#region src/utils/components/createTemplate.ts
193
+ const LOADING_KEY = Symbol("LOADING_KEY");
194
+ const loadingRegistry = /* @__PURE__ */ new WeakMap();
195
+ const getLoadingHandler = (instance) => {
196
+ return loadingRegistry.get(instance);
197
+ };
198
+ /**
199
+ * 创建模板
200
+ */
201
+ const useCreateTemplate = () => {
202
+ const template = ref();
203
+ const component = defineComponent(() => {
204
+ return () => template.value;
205
+ });
206
+ component.jsx = (jsx) => {
207
+ template.value = jsx;
208
+ };
209
+ component.remove = () => {
210
+ template.value = void 0;
211
+ };
212
+ return component;
213
+ };
214
+ /**
215
+ * 创建加载模板
216
+ */
217
+ const useCreateLoading = defineAction((ctx) => {
218
+ const loadingCount = ref(0);
219
+ const loading = computed(() => loadingCount.value > 0);
220
+ const handler = {
221
+ start() {
222
+ loadingCount.value++;
223
+ },
224
+ end() {
225
+ loadingCount.value = Math.max(0, loadingCount.value - 1);
226
+ if (loadingCount.value === 0) ctx.onSuccess(false);
227
+ }
228
+ };
229
+ const instance = getCurrentInstance();
230
+ onMounted(() => {
231
+ if (instance) loadingRegistry.set(instance, handler);
232
+ });
233
+ onUnmounted(() => {
234
+ if (instance) loadingRegistry.delete(instance);
235
+ });
236
+ return {
237
+ loading,
238
+ Template: defineComponent(() => {
239
+ const slots = useSlots();
240
+ return () => slots.default?.();
241
+ })
242
+ };
243
+ }, { emit: { onSuccess: (val) => void 0 } });
244
+ //#endregion
245
+ //#region src/utils/vue.ts
246
+ /**
247
+ * 外部获取provide
248
+ * @param key
249
+ * @param instance
250
+ */
251
+ const injectExternal = (key, instance) => {
252
+ if (!instance) return;
253
+ return instance?.provides[key] || injectExternal(key, instance.parent);
254
+ };
255
+ //#endregion
256
+ //#region src/utils/assert.ts
257
+ /**
258
+ * 断言工具类
259
+ */
260
+ var AssertAbstract = class {
261
+ /**
262
+ * 断言条件为真,否则抛出错误
263
+ * @param {boolean} condition - 要断言的条件
264
+ * @param {string} [message='Assertion failed'] - 错误信息
265
+ */
266
+ isTrue(condition, message = "Assertion failed") {
267
+ if (!condition) this.throwError("isTrue", message);
268
+ }
269
+ /**
270
+ * 断言条件为假,否则抛出错误
271
+ * @param {boolean} condition - 要断言的条件
272
+ * @param {string} [message='Assertion failed'] - 错误信息
273
+ */
274
+ isFalse(condition, message = "Assertion failed") {
275
+ if (condition) this.throwError("isFalse", message);
276
+ }
277
+ /**
278
+ * 断言值不为 null 或 undefined
279
+ * @param {*} value - 要检查的值
280
+ * @param {string} [message='Value must not be null or undefined'] - 错误信息
281
+ */
282
+ notNull(value, message = "Value must not be null or undefined") {
283
+ if (!isNotNil(value)) this.throwError("notNull", message);
284
+ }
285
+ /**
286
+ * 断言值为非空白字符串(即:是字符串,且去除两端空白后非空)
287
+ * @param {any} value - 要检查的值
288
+ * @param {string} [message='must not be blank'] - 错误信息
289
+ */
290
+ notBlank(value, message = "must not be blank") {
291
+ if (typeof value !== "string") this.throwError("notBlank", message);
292
+ if (value.trim().length === 0) this.throwError("notBlank", message);
293
+ }
294
+ /**
295
+ * 断言值为指定类型
296
+ * @param {*} value - 要检查的值
297
+ * @param {string} expectedType - 期望的类型(如 'string', 'number', 'object' 等)
298
+ * @param {string} [message] - 错误信息
299
+ */
300
+ isType(value, expectedType, message) {
301
+ const actualType = typeof value;
302
+ if (actualType !== expectedType) {
303
+ const msg = message || `Expected type "${expectedType}", but got "${actualType}"`;
304
+ this.throwError("isType", msg);
305
+ }
306
+ }
307
+ /**
308
+ * 断言值为非空
309
+ * @param {any} value - 要检查的字符串
310
+ * @param {string} [message='must not be empty'] - 错误信息
311
+ */
312
+ notEmpty(value, message = "must not be empty") {
313
+ if (isEmpty(value)) this.throwError("notEmpty", message);
314
+ }
315
+ /**
316
+ * 断言值为整数
317
+ * @param {number} value - 要检查的数值
318
+ * @param {string} [message='Value must be an integer'] - 错误信息
319
+ */
320
+ isInteger(value, message = "Value must be an integer") {
321
+ this.isType(value, "number", "Value must be a number for isInteger check");
322
+ if (!Number.isInteger(value)) this.throwError("isInteger", message);
323
+ }
324
+ /**
325
+ * 断言两个值相等(使用严格相等 ===)
326
+ * @param {*} actual - 实际值
327
+ * @param {*} expected - 期望值
328
+ * @param {string} [message] - 错误信息
329
+ */
330
+ equals(actual, expected, message) {
331
+ if (actual !== expected) {
332
+ const msg = message || `Expected ${JSON.stringify(expected)}, but got ${JSON.stringify(actual)}`;
333
+ this.throwError("equals", msg);
334
+ }
335
+ }
336
+ /**
337
+ * 断言数值在指定范围内(包含边界)
338
+ * @param {number} value - 要检查的数值
339
+ * @param {number} min - 最小值(含)
340
+ * @param {number} max - 最大值(含)
341
+ * @param {string} [message] - 错误信息
342
+ */
343
+ inRange(value, min, max, message) {
344
+ this.isType(value, "number", "Value must be a number for inRange check");
345
+ if (value < min || value > max) {
346
+ const msg = message || `Value ${value} is not in range [${min}, ${max}]`;
347
+ this.throwError("inRange", msg);
348
+ }
349
+ }
350
+ };
351
+ //#endregion
352
+ //#region src/utils/zod.ts
353
+ const zod = {
354
+ ...z,
355
+ stringNonEmpty: (message = "该字段不能为空") => z.string(message).trim().min(1, message),
356
+ notBlank: (message = "该字段不能为空") => z.custom((val) => isNotNil(val) && !isBlank(val), { error: message }),
357
+ notEmpty: (message = "该字段不能为空") => z.custom((val) => !isEmpty(val), { error: message }),
358
+ isTrue: (message = "该字段不能为空") => z.custom((val) => val === true, { error: message })
359
+ };
360
+ //#endregion
361
+ export { AliOssAbstract, AssertAbstract, CtOssAbstract, LOADING_KEY, QiniuAbstract, ZodType, arrayToArrayTree, defineAction, fixHtml, generateUUID, getLoadingHandler, injectExternal, intersperse, intersperseFun, nameGradient, replaceImgSrc, useCreateLoading, useCreateTemplate, useInjectProp, useNodeJSX, zod };
package/package.json ADDED
@@ -0,0 +1,38 @@
1
+ {
2
+ "name": "@okcy/core",
3
+ "version": "1.0.0",
4
+ "files": [
5
+ "dist"
6
+ ],
7
+ "type": "module",
8
+ "types": "./dist/index.d.ts",
9
+ "exports": {
10
+ ".": "./dist/index.mjs",
11
+ "./crypto": "./dist/crypto.mjs",
12
+ "./dayjs": "./dist/dayjs.mjs",
13
+ "./emittery": "./dist/emittery.mjs",
14
+ "./toolkit": "./dist/toolkit.mjs",
15
+ "./utils": "./dist/utils.mjs",
16
+ "./package.json": "./package.json"
17
+ },
18
+ "publishConfig": {
19
+ "access": "public",
20
+ "registry": "https://registry.npmjs.org/"
21
+ },
22
+ "dependencies": {
23
+ "@vueuse/core": "14.1.0",
24
+ "crypto.js": "^3.3.4",
25
+ "dayjs": "^1.11.18",
26
+ "emittery": "^2.0.0",
27
+ "es-toolkit": "^1.44.0",
28
+ "vue": "3.5.24",
29
+ "zod": "4.3.6"
30
+ },
31
+ "devDependencies": {
32
+ "vite-plus": "0.3.1"
33
+ },
34
+ "scripts": {
35
+ "dev": "vp pack --watch",
36
+ "build": "vp pack"
37
+ }
38
+ }