@kalutskii/foundation 0.4.4 → 0.4.5
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/dist/index.d.ts +10 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -80,6 +80,15 @@ declare const honoLoggingHandler: MiddlewareHandler;
|
|
|
80
80
|
type SerializeDates<T> = T extends Date ? string : T extends (infer U)[] ? SerializeDates<U>[] : T extends readonly (infer U)[] ? readonly SerializeDates<U>[] : T extends object ? {
|
|
81
81
|
[K in keyof T]: SerializeDates<T[K]>;
|
|
82
82
|
} : T;
|
|
83
|
+
type QueryPrimitive = string | number | boolean | bigint | Date | null | undefined;
|
|
84
|
+
/**
|
|
85
|
+
* Type utility that recursively transforms all fields to string, as well as handling arrays and objects.
|
|
86
|
+
* This is useful for serializing complex data structures into query parameters, which must be strings.
|
|
87
|
+
* Example usage: `AsQuery<{ id: number; name: string; tags: string[] }>` = `{ id: string; name: string; tags: string[] }`
|
|
88
|
+
*/
|
|
89
|
+
type AsQuery<T> = T extends QueryPrimitive ? string : T extends readonly (infer Item)[] ? AsQuery<Item>[] : T extends object ? {
|
|
90
|
+
[Key in keyof T]: AsQuery<T[Key]>;
|
|
91
|
+
} : string;
|
|
83
92
|
/**
|
|
84
93
|
* Transforms a string to a number (when passing query parameters).
|
|
85
94
|
* Example usage: `asQueryNumber(z.number())('123') = 123`
|
|
@@ -243,4 +252,4 @@ declare class ZodJWTService<TPayloadOrSchema> {
|
|
|
243
252
|
verifyOrThrow(token: string, secret: string): Promise<Payload<TPayloadOrSchema>>;
|
|
244
253
|
}
|
|
245
254
|
|
|
246
|
-
export { type APIContractData, type APIContractError, type APIContractResult, type APIError, type APISuccess, EXCEPTION_STATUS_CODES, type ExceptionStatusCode, type FetchResult, type JWTServiceOptions, type JWTSignOptions, type MeasuredExecution, type Payload, type PayloadSchema, SUCCESS_STATUS_CODES, type SerializeDates, type SuccessStatusCode, type XOR, ZodJWTService, asQueryBoolean, asQueryNumber, failure, fetchAndThrow, fetchSafely, formatTime, generateRandomString, getColoredHTTPStatus, getFormattedDate, getFormattedTime, getUTCOffset, getZonedTime, honoLoggingHandler, log, measureExecutionTime, onHandlerError, respond, safeExecute, success };
|
|
255
|
+
export { type APIContractData, type APIContractError, type APIContractResult, type APIError, type APISuccess, type AsQuery, EXCEPTION_STATUS_CODES, type ExceptionStatusCode, type FetchResult, type JWTServiceOptions, type JWTSignOptions, type MeasuredExecution, type Payload, type PayloadSchema, SUCCESS_STATUS_CODES, type SerializeDates, type SuccessStatusCode, type XOR, ZodJWTService, asQueryBoolean, asQueryNumber, failure, fetchAndThrow, fetchSafely, formatTime, generateRandomString, getColoredHTTPStatus, getFormattedDate, getFormattedTime, getUTCOffset, getZonedTime, honoLoggingHandler, log, measureExecutionTime, onHandlerError, respond, safeExecute, success };
|