@deboxsoft/module-core
Advanced tools
Comparing version 2.6.2 to 2.6.3
@@ -154,13 +154,7 @@ import { z, ZodType } from 'zod'; | ||
declare const RangeDateSchema: ZodType<RangeDate>; | ||
declare const makeSchemaResponse: <T>(schema: z.ZodType<T, z.ZodTypeDef, T>) => z.ZodObject<{ | ||
data: z.ZodType<T, z.ZodTypeDef, T>; | ||
}, "strip", z.ZodTypeAny, z.objectUtil.addQuestionMarks<{ | ||
declare const makeSchemaResponse: <T>(schema: z.ZodType<T, z.ZodTypeDef, T>) => z.ZodType<{ | ||
data: T; | ||
}> extends infer T_1 ? { [k_1 in keyof T_1]: z.objectUtil.addQuestionMarks<{ | ||
}, z.ZodTypeDef, { | ||
data: T; | ||
}>[k_1]; } : never, z.objectUtil.addQuestionMarks<{ | ||
data: T; | ||
}> extends infer T_2 ? { [k_3 in keyof T_2]: z.objectUtil.addQuestionMarks<{ | ||
data: T; | ||
}>[k_3]; } : never>; | ||
}>; | ||
declare const IdParams: z.ZodObject<{ | ||
@@ -174,48 +168,52 @@ id: z.ZodString; | ||
declare type IdParams = z.TypeOf<typeof IdParams>; | ||
declare const BooleanResponse: z.ZodObject<{ | ||
data: z.ZodType<boolean, z.ZodTypeDef, boolean>; | ||
}, "strip", z.ZodTypeAny, { | ||
declare type MakeSchema<T> = z.TypeOf<ReturnType<typeof makeSchemaResponse<T>>>; | ||
declare const BooleanResponse: z.ZodType<{ | ||
data: boolean; | ||
}, { | ||
}, z.ZodTypeDef, { | ||
data: boolean; | ||
}>; | ||
declare type BooleanResponse = z.TypeOf<typeof BooleanResponse>; | ||
declare const StringResponse: z.ZodObject<{ | ||
data: z.ZodType<string, z.ZodTypeDef, string>; | ||
}, "strip", z.ZodTypeAny, { | ||
declare type BooleanResponse = MakeSchema<boolean>; | ||
declare const StringResponse: z.ZodType<{ | ||
data: string; | ||
}, { | ||
}, z.ZodTypeDef, { | ||
data: string; | ||
}>; | ||
declare type StringResponse = z.TypeOf<typeof StringResponse>; | ||
declare const NumberResponse: z.ZodObject<{ | ||
data: z.ZodType<number, z.ZodTypeDef, number>; | ||
}, "strip", z.ZodTypeAny, { | ||
declare type StringResponse = MakeSchema<string>; | ||
declare const NumberResponse: z.ZodType<{ | ||
data: number; | ||
}, { | ||
}, z.ZodTypeDef, { | ||
data: number; | ||
}>; | ||
declare type NumberResponse = z.TypeOf<typeof NumberResponse>; | ||
declare type NumberResponse = MakeSchema<number>; | ||
declare const transformDefaultPageInfo: z.ZodEffects<z.ZodObject<z.extendShape<{ | ||
current: z.ZodDefault<z.ZodNumber>; | ||
declare const PaginationType: z.ZodDefault<z.ZodEnum<["cursor", "default"]>>; | ||
declare const PageParams: z.ZodObject<{ | ||
size: z.ZodDefault<z.ZodNumber>; | ||
}, "strip", z.ZodTypeAny, { | ||
size: number; | ||
}, { | ||
size?: number | undefined; | ||
}>; | ||
declare const transformDefaultPageInfo: z.ZodEffects<z.ZodObject<z.extendShape<z.extendShape<{ | ||
size: z.ZodDefault<z.ZodNumber>; | ||
}, { | ||
current: z.ZodDefault<z.ZodNumber>; | ||
}>, { | ||
total: z.ZodNumber; | ||
}>, "strip", z.ZodTypeAny, { | ||
size: number; | ||
current: number; | ||
size: number; | ||
total: number; | ||
}, { | ||
size?: number | undefined; | ||
current?: number | undefined; | ||
size?: number | undefined; | ||
total: number; | ||
}>, { | ||
size: number; | ||
current: number; | ||
size: number; | ||
total: number; | ||
last: number; | ||
}, { | ||
size?: number | undefined; | ||
current?: number | undefined; | ||
size?: number | undefined; | ||
total: number; | ||
@@ -225,12 +223,15 @@ }>; | ||
type: z.ZodOptional<z.ZodDefault<z.ZodEnum<["cursor", "default"]>>>; | ||
params: z.ZodUnion<[z.ZodObject<{ | ||
params: z.ZodOptional<z.ZodUnion<[z.ZodObject<z.extendShape<{ | ||
size: z.ZodDefault<z.ZodNumber>; | ||
}, { | ||
current: z.ZodDefault<z.ZodNumber>; | ||
size: z.ZodDefault<z.ZodNumber>; | ||
}, "strip", z.ZodTypeAny, { | ||
}>, "strip", z.ZodTypeAny, { | ||
size: number; | ||
current: number; | ||
size: number; | ||
}, { | ||
size?: number | undefined; | ||
current?: number | undefined; | ||
size?: number | undefined; | ||
}>, z.ZodObject<{ | ||
}>, z.ZodObject<z.extendShape<{ | ||
size: z.ZodDefault<z.ZodNumber>; | ||
}, { | ||
previous: z.ZodOptional<z.ZodAny>; | ||
@@ -241,3 +242,3 @@ before: z.ZodOptional<z.ZodAny>; | ||
hint: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodRecord<z.ZodString, z.ZodString>]>>; | ||
}, "strip", z.ZodTypeAny, { | ||
}>, "strip", z.ZodTypeAny, { | ||
previous?: any; | ||
@@ -248,3 +249,5 @@ before?: any; | ||
hint?: string | Record<string, string> | undefined; | ||
size: number; | ||
}, { | ||
size?: number | undefined; | ||
previous?: any; | ||
@@ -255,5 +258,5 @@ before?: any; | ||
hint?: string | Record<string, string> | undefined; | ||
}>]>; | ||
}>]>>; | ||
sortField: z.ZodOptional<z.ZodString>; | ||
sortAsc: z.ZodOptional<z.ZodDefault<z.ZodBoolean>>; | ||
sortAsc: z.ZodOptional<z.ZodBoolean>; | ||
sort: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<[z.ZodLiteral<1>, z.ZodLiteral<-1>]>>>; | ||
@@ -264,6 +267,3 @@ filter: z.ZodOptional<z.ZodAny>; | ||
filter?: any; | ||
type?: "cursor" | "default" | undefined; | ||
sortField?: string | undefined; | ||
sortAsc?: boolean | undefined; | ||
params: { | ||
params?: { | ||
previous?: any; | ||
@@ -274,13 +274,15 @@ before?: any; | ||
hint?: string | Record<string, string> | undefined; | ||
size: number; | ||
} | { | ||
size: number; | ||
current: number; | ||
size: number; | ||
}; | ||
} | undefined; | ||
type?: "cursor" | "default" | undefined; | ||
sortField?: string | undefined; | ||
sortAsc?: boolean | undefined; | ||
}, { | ||
sort?: Record<string, 1 | -1> | undefined; | ||
filter?: any; | ||
type?: "cursor" | "default" | undefined; | ||
sortField?: string | undefined; | ||
sortAsc?: boolean | undefined; | ||
params: { | ||
params?: { | ||
size?: number | undefined; | ||
previous?: any; | ||
@@ -292,20 +294,27 @@ before?: any; | ||
} | { | ||
size?: number | undefined; | ||
current?: number | undefined; | ||
size?: number | undefined; | ||
}; | ||
} | undefined; | ||
type?: "cursor" | "default" | undefined; | ||
sortField?: string | undefined; | ||
sortAsc?: boolean | undefined; | ||
}>; | ||
declare type PaginationOptions<F = any> = z.TypeOf<typeof PaginationOptions> & { | ||
declare type PaginationOptions<F = any> = z.input<typeof PaginationOptions> & { | ||
filter?: F; | ||
}; | ||
declare type PaginationOptionsOutput<F = any> = z.output<typeof PaginationOptions> & { | ||
filter?: F; | ||
}; | ||
declare const PageInfo: z.ZodObject<{ | ||
total: z.ZodNumber; | ||
total: z.ZodOptional<z.ZodNumber>; | ||
}, "strip", z.ZodTypeAny, { | ||
total: number; | ||
total?: number | undefined; | ||
}, { | ||
total: number; | ||
total?: number | undefined; | ||
}>; | ||
declare type PageInfo = z.TypeOf<typeof PageInfo>; | ||
declare type PageInfo = z.output<typeof PageInfo>; | ||
declare const PageDefaultInfo: z.ZodObject<z.extendShape<{ | ||
total: z.ZodOptional<z.ZodNumber>; | ||
}, { | ||
total: z.ZodNumber; | ||
}, { | ||
size: z.ZodNumber; | ||
@@ -315,15 +324,15 @@ current: z.ZodNumber; | ||
}>, "strip", z.ZodTypeAny, { | ||
size: number; | ||
current: number; | ||
size: number; | ||
total: number; | ||
last: number; | ||
}, { | ||
size: number; | ||
current: number; | ||
size: number; | ||
total: number; | ||
last: number; | ||
}>; | ||
declare type PageDefaultInfo = z.TypeOf<typeof PageDefaultInfo>; | ||
declare type PageDefaultInfo = z.output<typeof PageDefaultInfo>; | ||
declare const PageCursorInfo: z.ZodObject<z.extendShape<{ | ||
total: z.ZodNumber; | ||
total: z.ZodOptional<z.ZodNumber>; | ||
}, { | ||
@@ -337,18 +346,19 @@ next: z.ZodOptional<z.ZodString>; | ||
next?: string | undefined; | ||
total?: number | undefined; | ||
hasNext?: boolean | undefined; | ||
hasPrevious?: boolean | undefined; | ||
total: number; | ||
}, { | ||
previous?: string | undefined; | ||
next?: string | undefined; | ||
total?: number | undefined; | ||
hasNext?: boolean | undefined; | ||
hasPrevious?: boolean | undefined; | ||
total: number; | ||
}>; | ||
declare type PageCursorInfo = z.TypeOf<typeof PageCursorInfo>; | ||
declare type PageCursorInfo = z.output<typeof PageCursorInfo>; | ||
declare const Pagination: z.ZodObject<{ | ||
data: z.ZodArray<z.ZodAny, "many">; | ||
pageInfo: z.ZodUnion<[z.ZodObject<z.extendShape<{ | ||
total: z.ZodOptional<z.ZodNumber>; | ||
}, { | ||
total: z.ZodNumber; | ||
}, { | ||
size: z.ZodNumber; | ||
@@ -358,13 +368,13 @@ current: z.ZodNumber; | ||
}>, "strip", z.ZodTypeAny, { | ||
size: number; | ||
current: number; | ||
size: number; | ||
total: number; | ||
last: number; | ||
}, { | ||
size: number; | ||
current: number; | ||
size: number; | ||
total: number; | ||
last: number; | ||
}>, z.ZodObject<z.extendShape<{ | ||
total: z.ZodNumber; | ||
total: z.ZodOptional<z.ZodNumber>; | ||
}, { | ||
@@ -378,11 +388,11 @@ next: z.ZodOptional<z.ZodString>; | ||
next?: string | undefined; | ||
total?: number | undefined; | ||
hasNext?: boolean | undefined; | ||
hasPrevious?: boolean | undefined; | ||
total: number; | ||
}, { | ||
previous?: string | undefined; | ||
next?: string | undefined; | ||
total?: number | undefined; | ||
hasNext?: boolean | undefined; | ||
hasPrevious?: boolean | undefined; | ||
total: number; | ||
}>]>; | ||
@@ -394,8 +404,8 @@ }, "strip", z.ZodTypeAny, { | ||
next?: string | undefined; | ||
total?: number | undefined; | ||
hasNext?: boolean | undefined; | ||
hasPrevious?: boolean | undefined; | ||
total: number; | ||
} | { | ||
size: number; | ||
current: number; | ||
size: number; | ||
total: number; | ||
@@ -409,8 +419,8 @@ last: number; | ||
next?: string | undefined; | ||
total?: number | undefined; | ||
hasNext?: boolean | undefined; | ||
hasPrevious?: boolean | undefined; | ||
total: number; | ||
} | { | ||
size: number; | ||
current: number; | ||
size: number; | ||
total: number; | ||
@@ -420,6 +430,8 @@ last: number; | ||
}>; | ||
declare type Pagination<D = any> = z.TypeOf<typeof Pagination> & { | ||
declare type Pagination<D = any> = z.output<typeof Pagination> & { | ||
data: D[]; | ||
}; | ||
declare const PageCursorParams: z.ZodObject<{ | ||
declare const PageCursorParams: z.ZodObject<z.extendShape<{ | ||
size: z.ZodDefault<z.ZodNumber>; | ||
}, { | ||
previous: z.ZodOptional<z.ZodAny>; | ||
@@ -430,3 +442,3 @@ before: z.ZodOptional<z.ZodAny>; | ||
hint: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodRecord<z.ZodString, z.ZodString>]>>; | ||
}, "strip", z.ZodTypeAny, { | ||
}>, "strip", z.ZodTypeAny, { | ||
previous?: any; | ||
@@ -437,3 +449,5 @@ before?: any; | ||
hint?: string | Record<string, string> | undefined; | ||
size: number; | ||
}, { | ||
size?: number | undefined; | ||
previous?: any; | ||
@@ -445,14 +459,17 @@ before?: any; | ||
}>; | ||
declare type PageCursorParams = z.TypeOf<typeof PageCursorParams>; | ||
declare const PageDefaultParams: z.ZodObject<{ | ||
declare type PageCursorParams = z.input<typeof PageCursorParams>; | ||
declare type PageCursorParamsOutput = z.output<typeof PageCursorParams>; | ||
declare const PageDefaultParams: z.ZodObject<z.extendShape<{ | ||
size: z.ZodDefault<z.ZodNumber>; | ||
}, { | ||
current: z.ZodDefault<z.ZodNumber>; | ||
size: z.ZodDefault<z.ZodNumber>; | ||
}, "strip", z.ZodTypeAny, { | ||
}>, "strip", z.ZodTypeAny, { | ||
size: number; | ||
current: number; | ||
size: number; | ||
}, { | ||
size?: number | undefined; | ||
current?: number | undefined; | ||
size?: number | undefined; | ||
}>; | ||
declare type PageDefaultParams = z.TypeOf<typeof PageDefaultParams>; | ||
declare type PageDefaultParams = z.input<typeof PageDefaultParams>; | ||
declare type PageDefaultParamsOutput = z.output<typeof PageDefaultParams>; | ||
@@ -605,2 +622,2 @@ interface AppConfig { | ||
export { AppConfig, BooleanResponse, CONFIG_KEY, Config, Container, DateSchema, DbxError, DbxErrorOptions, IdParams, IdSchema, LOGGER_KEY, Logger, ModuleConfig, NotificationType, NumberResponse, PageCursorInfo, PageCursorParams, PageDefaultInfo, PageDefaultParams, PageInfo, Pagination, PaginationOptions, RangeDate, RangeDateSchema, StringResponse, TimeStampSchema, clamp, cloneDeep, createLoggerConsole, dayTimeZone, debounce, getAppConfig, getConfig, getLogger, getRangeDate, isEmpty, isObject, isPlainObject, isString, isStringAndNotBlank, isStringBlank, kindOf, makeSchemaResponse, omit, pickBy, pull, throttle, transformDefaultPageInfo }; | ||
export { AppConfig, BooleanResponse, CONFIG_KEY, Config, Container, DateSchema, DbxError, DbxErrorOptions, IdParams, IdSchema, LOGGER_KEY, Logger, MakeSchema, ModuleConfig, NotificationType, NumberResponse, PageCursorInfo, PageCursorParams, PageCursorParamsOutput, PageDefaultInfo, PageDefaultParams, PageDefaultParamsOutput, PageInfo, PageParams, Pagination, PaginationOptions, PaginationOptionsOutput, PaginationType, RangeDate, RangeDateSchema, StringResponse, TimeStampSchema, clamp, cloneDeep, createLoggerConsole, dayTimeZone, debounce, getAppConfig, getConfig, getLogger, getRangeDate, isEmpty, isObject, isPlainObject, isString, isStringAndNotBlank, isStringBlank, kindOf, makeSchemaResponse, omit, pickBy, pull, throttle, transformDefaultPageInfo }; |
@@ -32,4 +32,11 @@ var __defProp = Object.defineProperty; | ||
NumberResponse: () => NumberResponse, | ||
PageCursorInfo: () => PageCursorInfo, | ||
PageCursorParams: () => PageCursorParams, | ||
PageDefaultInfo: () => PageDefaultInfo, | ||
PageDefaultParams: () => PageDefaultParams, | ||
PageInfo: () => PageInfo, | ||
PageParams: () => PageParams, | ||
Pagination: () => Pagination, | ||
PaginationOptions: () => PaginationOptions, | ||
PaginationType: () => PaginationType, | ||
RangeDateSchema: () => RangeDateSchema, | ||
@@ -90,3 +97,3 @@ StringResponse: () => StringResponse, | ||
// src/zod/schema.ts | ||
import { z } from "zod"; | ||
import { z, ZodFirstPartyTypeKind } from "zod"; | ||
var IdSchema = z.string().min(1); | ||
@@ -113,5 +120,11 @@ var DateSchema = z.preprocess((_) => { | ||
var makeSchemaResponse = (schema) => { | ||
return z.object({ | ||
data: schema | ||
const result = new z.ZodObject({ | ||
typeName: ZodFirstPartyTypeKind.ZodObject, | ||
shape: () => ({ | ||
data: schema | ||
}), | ||
unknownKeys: "strip", | ||
catchall: z.any() | ||
}); | ||
return result; | ||
}; | ||
@@ -127,3 +140,6 @@ var BooleanResponse = makeSchemaResponse(z.boolean()); | ||
var PaginationType = z2.enum(["cursor", "default"]).default("default"); | ||
var PageCursorParams = z2.object({ | ||
var PageParams = z2.object({ | ||
size: z2.number().default(30) | ||
}); | ||
var PageCursorParams = PageParams.extend({ | ||
previous: z2.any().optional(), | ||
@@ -135,8 +151,7 @@ before: z2.any().optional(), | ||
}); | ||
var PageDefaultParams = z2.object({ | ||
current: z2.number().default(1), | ||
size: z2.number().default(30) | ||
var PageDefaultParams = PageParams.extend({ | ||
current: z2.number().default(1) | ||
}); | ||
var PageInfo = z2.object({ | ||
total: z2.number() | ||
total: z2.number().optional() | ||
}); | ||
@@ -150,2 +165,3 @@ var PageCursorInfo = PageInfo.extend({ | ||
var PageDefaultInfo = PageInfo.extend({ | ||
total: z2.number(), | ||
size: z2.number(), | ||
@@ -157,5 +173,5 @@ current: z2.number(), | ||
type: PaginationType.optional(), | ||
params: z2.union([PageDefaultParams, PageCursorParams]), | ||
params: z2.union([PageDefaultParams, PageCursorParams]).optional(), | ||
sortField: z2.string().optional(), | ||
sortAsc: z2.boolean().default(true).optional(), | ||
sortAsc: z2.boolean().optional(), | ||
sort: z2.record(z2.string(), z2.union([z2.literal(1), z2.literal(-1)])).optional(), | ||
@@ -742,4 +758,11 @@ filter: z2.any().optional() | ||
NumberResponse, | ||
PageCursorInfo, | ||
PageCursorParams, | ||
PageDefaultInfo, | ||
PageDefaultParams, | ||
PageInfo, | ||
PageParams, | ||
Pagination, | ||
PaginationOptions, | ||
PaginationType, | ||
RangeDateSchema, | ||
@@ -746,0 +769,0 @@ StringResponse, |
{ | ||
"name": "@deboxsoft/module-core", | ||
"version": "2.6.2", | ||
"version": "2.6.3", | ||
"license": "SEE LICENSE IN LICENSE", | ||
@@ -33,11 +33,11 @@ "maintainers": [ | ||
"dependencies": { | ||
"zod": "^3.17.10", | ||
"dayjs": "^1.11.4", | ||
"change-case": "^4.1.2", | ||
"clone-deep": "^4.0.1", | ||
"dayjs": "^1.11.4", | ||
"is-plain-object": "^5.0.0", | ||
"js-base64": "^3.7.2", | ||
"kind-of": "^6.0.3", | ||
"mustache": "^4.2.0", | ||
"shallow-clone": "^3.0.1", | ||
"js-base64": "^3.7.2", | ||
"mustache": "^4.2.0" | ||
"zod": "^3.18.0" | ||
}, | ||
@@ -44,0 +44,0 @@ "devDependencies": { |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
69873
2132
Updatedzod@^3.18.0