@intrig/core 0.0.15-4 → 0.0.15-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/main.js +12 -18
- package/package.json +1 -1
package/main.js
CHANGED
|
@@ -8097,6 +8097,15 @@ async function reactDownloadHookTemplate({ source, data: { paths, operationId, r
|
|
|
8097
8097
|
"...params"
|
|
8098
8098
|
].join(",");
|
|
8099
8099
|
const finalRequestBodyBlock = requestBody ? `,data: encode(data, "${contentType}", requestBodySchema)` : '';
|
|
8100
|
+
function responseTypePart() {
|
|
8101
|
+
switch(responseType){
|
|
8102
|
+
case "application/octet-stream":
|
|
8103
|
+
return `responseType: 'blob', adapter: 'fetch',`;
|
|
8104
|
+
case "text/event-stream":
|
|
8105
|
+
return `responseType: 'stream', adapter: 'fetch',`;
|
|
8106
|
+
}
|
|
8107
|
+
return '';
|
|
8108
|
+
}
|
|
8100
8109
|
return ts`
|
|
8101
8110
|
${[
|
|
8102
8111
|
...imports
|
|
@@ -8175,7 +8184,7 @@ async function reactDownloadHookTemplate({ source, data: { paths, operationId, r
|
|
|
8175
8184
|
key: \`${"${source}: ${operation}"}\`,
|
|
8176
8185
|
source: '${source}'
|
|
8177
8186
|
${requestBody ? finalRequestBodyBlock : ''},
|
|
8178
|
-
${
|
|
8187
|
+
${responseTypePart()}
|
|
8179
8188
|
})
|
|
8180
8189
|
return successfulDispatch();
|
|
8181
8190
|
}, [dispatch])
|
|
@@ -9316,23 +9325,8 @@ function typeUtilsTemplate(_path) {
|
|
|
9316
9325
|
const ts = typescript(external_path_default().resolve(_path, 'src', 'type-utils.ts'));
|
|
9317
9326
|
return ts`import { z } from 'zod';
|
|
9318
9327
|
|
|
9319
|
-
export type BinaryData = Blob
|
|
9320
|
-
|
|
9321
|
-
export const BinaryDataSchema = z.union([
|
|
9322
|
-
// Blob in browsers
|
|
9323
|
-
z.instanceof(Blob).optional(), // optional here so union below still validates if Blob is absent in Node
|
|
9324
|
-
// Raw buffers
|
|
9325
|
-
z.instanceof(ArrayBuffer),
|
|
9326
|
-
z.custom<Uint8Array>((v) => v instanceof Uint8Array, { message: 'Expected Uint8Array' }),
|
|
9327
|
-
]).transform((v) => {
|
|
9328
|
-
// Normalize to Blob if possible (nice for downloads in browser)
|
|
9329
|
-
if (typeof Blob !== 'undefined') {
|
|
9330
|
-
if (v instanceof Blob) return v;
|
|
9331
|
-
if (v instanceof ArrayBuffer) return new Blob([v]);
|
|
9332
|
-
if (v instanceof Uint8Array) return new Blob([v.buffer]);
|
|
9333
|
-
}
|
|
9334
|
-
return v;
|
|
9335
|
-
});
|
|
9328
|
+
export type BinaryData = Blob;
|
|
9329
|
+
export const BinaryDataSchema: z.ZodType<BinaryData> = z.instanceof(Blob);
|
|
9336
9330
|
|
|
9337
9331
|
// Base64 helpers (browser + Node compatible; no Buffer required)
|
|
9338
9332
|
export function base64ToUint8Array(b64: string): Uint8Array {
|