randmar-api-client 1.55.0 → 1.56.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.
@@ -339,6 +339,22 @@ const enhancedApi = randmarApi.enhanceEndpoints({
339
339
  method: 'GET',
340
340
  responseHandler: (response) => response.blob(),
341
341
  }),
342
+ transformResponse: (response, meta, arg) => {
343
+ // Extract filename from content-disposition header
344
+ const contentDisposition = meta?.response?.headers.get('content-disposition');
345
+ let filename = `${arg.documentNumber}.pdf`; // Default filename
346
+ if (contentDisposition) {
347
+ const filenameMatch = /filename[^;=\n]*=((['"]).*?\2|[^;\n]*)/.exec(contentDisposition);
348
+ if (filenameMatch?.[1]) {
349
+ filename = filenameMatch[1].replace(/['"]/g, '');
350
+ }
351
+ }
352
+ // Create a serializable object with the blob's URL and the filename
353
+ return {
354
+ url: window.URL.createObjectURL(response),
355
+ filename: filename,
356
+ };
357
+ },
342
358
  }
343
359
  }
344
360
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "randmar-api-client",
3
- "version": "1.55.0",
3
+ "version": "1.56.0",
4
4
  "type": "module",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.js",