ts-typed-api 0.1.2 → 0.1.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/dist/definition.d.ts +5 -5
- package/dist/definition.js +8 -1
- package/package.json +1 -1
- package/src/definition.ts +8 -1
package/dist/definition.d.ts
CHANGED
|
@@ -148,7 +148,7 @@ export declare const fileSchema: z.ZodObject<{
|
|
|
148
148
|
encoding: z.ZodString;
|
|
149
149
|
mimetype: z.ZodString;
|
|
150
150
|
size: z.ZodNumber;
|
|
151
|
-
buffer: z.ZodType<Buffer<ArrayBufferLike>, z.ZodTypeDef, Buffer<ArrayBufferLike>>;
|
|
151
|
+
buffer: z.ZodOptional<z.ZodUnion<[z.ZodType<Buffer<ArrayBufferLike>, z.ZodTypeDef, Buffer<ArrayBufferLike>>, z.ZodType<import("buffer").File, z.ZodTypeDef, import("buffer").File>, z.ZodType<import("buffer").Blob, z.ZodTypeDef, import("buffer").Blob>]>>;
|
|
152
152
|
destination: z.ZodOptional<z.ZodString>;
|
|
153
153
|
filename: z.ZodOptional<z.ZodString>;
|
|
154
154
|
path: z.ZodOptional<z.ZodString>;
|
|
@@ -159,22 +159,22 @@ export declare const fileSchema: z.ZodObject<{
|
|
|
159
159
|
encoding: string;
|
|
160
160
|
mimetype: string;
|
|
161
161
|
size: number;
|
|
162
|
-
buffer: Buffer<ArrayBufferLike>;
|
|
163
162
|
path?: string | undefined;
|
|
163
|
+
stream?: any;
|
|
164
|
+
buffer?: Buffer<ArrayBufferLike> | import("buffer").File | import("buffer").Blob | undefined;
|
|
164
165
|
destination?: string | undefined;
|
|
165
166
|
filename?: string | undefined;
|
|
166
|
-
stream?: any;
|
|
167
167
|
}, {
|
|
168
168
|
fieldname: string;
|
|
169
169
|
originalname: string;
|
|
170
170
|
encoding: string;
|
|
171
171
|
mimetype: string;
|
|
172
172
|
size: number;
|
|
173
|
-
buffer: Buffer<ArrayBufferLike>;
|
|
174
173
|
path?: string | undefined;
|
|
174
|
+
stream?: any;
|
|
175
|
+
buffer?: Buffer<ArrayBufferLike> | import("buffer").File | import("buffer").Blob | undefined;
|
|
175
176
|
destination?: string | undefined;
|
|
176
177
|
filename?: string | undefined;
|
|
177
|
-
stream?: any;
|
|
178
178
|
}>;
|
|
179
179
|
export type FileType = z.infer<typeof fileSchema>;
|
|
180
180
|
export declare function createFileValidationSchema(options?: {
|
package/dist/definition.js
CHANGED
|
@@ -84,13 +84,20 @@ function CreateApiDefinition(definition) {
|
|
|
84
84
|
}
|
|
85
85
|
// --- File Upload Validation Schemas ---
|
|
86
86
|
// Schema for validating uploaded files
|
|
87
|
+
// Compatible with both Node.js (Buffer) and browser (File/Blob) environments
|
|
87
88
|
exports.fileSchema = zod_1.z.object({
|
|
88
89
|
fieldname: zod_1.z.string(),
|
|
89
90
|
originalname: zod_1.z.string(),
|
|
90
91
|
encoding: zod_1.z.string(),
|
|
91
92
|
mimetype: zod_1.z.string(),
|
|
92
93
|
size: zod_1.z.number(),
|
|
93
|
-
buffer: zod_1.z.
|
|
94
|
+
buffer: zod_1.z.union([
|
|
95
|
+
// Node.js environment
|
|
96
|
+
typeof Buffer !== 'undefined' ? zod_1.z.instanceof(Buffer) : zod_1.z.never(),
|
|
97
|
+
// Browser environment
|
|
98
|
+
typeof File !== 'undefined' ? zod_1.z.instanceof(File) : zod_1.z.never(),
|
|
99
|
+
typeof Blob !== 'undefined' ? zod_1.z.instanceof(Blob) : zod_1.z.never(),
|
|
100
|
+
]).optional(), // Make optional since not all environments will have all types
|
|
94
101
|
destination: zod_1.z.string().optional(),
|
|
95
102
|
filename: zod_1.z.string().optional(),
|
|
96
103
|
path: zod_1.z.string().optional(),
|
package/package.json
CHANGED
package/src/definition.ts
CHANGED
|
@@ -265,13 +265,20 @@ export type ApiClientQuery<
|
|
|
265
265
|
// --- File Upload Validation Schemas ---
|
|
266
266
|
|
|
267
267
|
// Schema for validating uploaded files
|
|
268
|
+
// Compatible with both Node.js (Buffer) and browser (File/Blob) environments
|
|
268
269
|
export const fileSchema = z.object({
|
|
269
270
|
fieldname: z.string(),
|
|
270
271
|
originalname: z.string(),
|
|
271
272
|
encoding: z.string(),
|
|
272
273
|
mimetype: z.string(),
|
|
273
274
|
size: z.number(),
|
|
274
|
-
buffer: z.
|
|
275
|
+
buffer: z.union([
|
|
276
|
+
// Node.js environment
|
|
277
|
+
typeof Buffer !== 'undefined' ? z.instanceof(Buffer) : z.never(),
|
|
278
|
+
// Browser environment
|
|
279
|
+
typeof File !== 'undefined' ? z.instanceof(File) : z.never(),
|
|
280
|
+
typeof Blob !== 'undefined' ? z.instanceof(Blob) : z.never(),
|
|
281
|
+
]).optional(), // Make optional since not all environments will have all types
|
|
275
282
|
destination: z.string().optional(),
|
|
276
283
|
filename: z.string().optional(),
|
|
277
284
|
path: z.string().optional(),
|