@openshift-migration-advisor/agent-sdk 0.25.0 → 0.27.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.
@@ -1 +1 @@
1
- 7.26.0-SNAPSHOT
1
+ 7.27.0-SNAPSHOT
package/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # @openshift-migration-advisor/agent-sdk@0.25.0
1
+ # @openshift-migration-advisor/agent-sdk@0.27.0
2
2
 
3
3
  A TypeScript SDK client for the raw.githubusercontent.com API.
4
4
 
@@ -200,8 +200,8 @@ and is automatically generated by the
200
200
  [OpenAPI Generator](https://openapi-generator.tech) project:
201
201
 
202
202
  - API version: `v2`
203
- - Package version: `0.25.0`
204
- - Generator version: `7.26.0-SNAPSHOT`
203
+ - Package version: `0.27.0`
204
+ - Generator version: `7.27.0-SNAPSHOT`
205
205
  - Build package: `org.openapitools.codegen.languages.TypeScriptFetchClientCodegen`
206
206
 
207
207
  The generated npm module supports the following:
@@ -153,11 +153,11 @@ export interface CollectionsApiInterface {
153
153
  * @throws {RequiredError}
154
154
  * @memberof CollectionsApiInterface
155
155
  */
156
- exportCollectionRaw(requestParameters: ExportCollectionRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<Blob>>;
156
+ exportCollectionRaw(requestParameters: ExportCollectionRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<runtime.HttpFile>>;
157
157
  /**
158
158
  * Export collection data as CSV ZIP archive or Excel workbook
159
159
  */
160
- exportCollection(requestParameters: ExportCollectionRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<Blob>;
160
+ exportCollection(requestParameters: ExportCollectionRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.HttpFile>;
161
161
  /**
162
162
  * Creates request options for listCollections without sending the request
163
163
  * @throws {RequiredError}
@@ -224,11 +224,11 @@ export declare class CollectionsApi extends runtime.BaseAPI implements Collectio
224
224
  /**
225
225
  * Export collection data as CSV ZIP archive or Excel workbook
226
226
  */
227
- exportCollectionRaw(requestParameters: ExportCollectionRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<Blob>>;
227
+ exportCollectionRaw(requestParameters: ExportCollectionRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<runtime.HttpFile>>;
228
228
  /**
229
229
  * Export collection data as CSV ZIP archive or Excel workbook
230
230
  */
231
- exportCollection(requestParameters: ExportCollectionRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<Blob>;
231
+ exportCollection(requestParameters: ExportCollectionRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.HttpFile>;
232
232
  /**
233
233
  * Creates request options for listCollections without sending the request
234
234
  */
@@ -153,11 +153,11 @@ export interface CollectionsApiInterface {
153
153
  * @throws {RequiredError}
154
154
  * @memberof CollectionsApiInterface
155
155
  */
156
- exportCollectionRaw(requestParameters: ExportCollectionRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<Blob>>;
156
+ exportCollectionRaw(requestParameters: ExportCollectionRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<runtime.HttpFile>>;
157
157
  /**
158
158
  * Export collection data as CSV ZIP archive or Excel workbook
159
159
  */
160
- exportCollection(requestParameters: ExportCollectionRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<Blob>;
160
+ exportCollection(requestParameters: ExportCollectionRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.HttpFile>;
161
161
  /**
162
162
  * Creates request options for listCollections without sending the request
163
163
  * @throws {RequiredError}
@@ -224,11 +224,11 @@ export declare class CollectionsApi extends runtime.BaseAPI implements Collectio
224
224
  /**
225
225
  * Export collection data as CSV ZIP archive or Excel workbook
226
226
  */
227
- exportCollectionRaw(requestParameters: ExportCollectionRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<Blob>>;
227
+ exportCollectionRaw(requestParameters: ExportCollectionRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<runtime.HttpFile>>;
228
228
  /**
229
229
  * Export collection data as CSV ZIP archive or Excel workbook
230
230
  */
231
- exportCollection(requestParameters: ExportCollectionRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<Blob>;
231
+ exportCollection(requestParameters: ExportCollectionRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.HttpFile>;
232
232
  /**
233
233
  * Creates request options for listCollections without sending the request
234
234
  */
@@ -184,23 +184,30 @@ export declare class VoidApiResponse {
184
184
  constructor(raw: Response);
185
185
  value(): Promise<void>;
186
186
  }
187
+ /**
188
+ * A Blob carrying the file name the server advertised, empty when it did not send one. It is a File
189
+ * wherever one can be built, and the bare Blob given a name otherwise. Same name and shape as the
190
+ * `typescript` generator's browser HttpFile.
191
+ */
192
+ export type HttpFile = Blob & {
193
+ readonly name: string;
194
+ };
187
195
  export declare class BlobApiResponse {
188
196
  raw: Response;
189
197
  constructor(raw: Response);
190
198
  /**
191
- * The body as a File named after the Content-Disposition header, so that a download keeps the
192
- * name the server gave it. A File is a Blob: callers reading a Blob are unaffected, and the name
193
- * is empty when the server did not send one. Runtimes without a global File (Node.js before 20)
194
- * keep receiving the bare Blob.
199
+ * The body named after the Content-Disposition header, so that a download keeps the name the
200
+ * server gave it. A File is built from a native Blob; the Blob itself is named where there is no
201
+ * global File (Node.js before 20), where File cannot be constructed, or where the Blob is not the
202
+ * native one, as returned by an injected fetch implementation such as node-fetch, which a File
203
+ * would stringify instead of wrapping.
195
204
  */
196
- value(): Promise<File>;
205
+ value(): Promise<HttpFile>;
197
206
  }
198
207
  /**
199
208
  * The file name advertised by a Content-Disposition header (RFC 6266): the RFC 5987 encoded
200
- * `filename*` parameter first, then the plain `filename` as a quoted-string or a token. Parameters
201
- * are split on `;` outside quoted-strings and matched by name case-insensitively. Any directory
202
- * part is dropped so that the name is safe to write to disk as is; undefined when no usable name
203
- * is advertised.
209
+ * `filename*` parameter first, falling back to the plain `filename` when it is malformed, not UTF-8
210
+ * or has no usable name. Any directory part is dropped; undefined when no usable name is advertised.
204
211
  */
205
212
  export declare function parseContentDispositionFilename(headers: Headers): string | undefined;
206
213
  export declare class TextApiResponse {
@@ -381,90 +381,71 @@ export class BlobApiResponse {
381
381
  this.raw = raw;
382
382
  }
383
383
  /**
384
- * The body as a File named after the Content-Disposition header, so that a download keeps the
385
- * name the server gave it. A File is a Blob: callers reading a Blob are unaffected, and the name
386
- * is empty when the server did not send one. Runtimes without a global File (Node.js before 20)
387
- * keep receiving the bare Blob.
384
+ * The body named after the Content-Disposition header, so that a download keeps the name the
385
+ * server gave it. A File is built from a native Blob; the Blob itself is named where there is no
386
+ * global File (Node.js before 20), where File cannot be constructed, or where the Blob is not the
387
+ * native one, as returned by an injected fetch implementation such as node-fetch, which a File
388
+ * would stringify instead of wrapping.
388
389
  */
389
390
  value() {
390
391
  return __awaiter(this, void 0, void 0, function* () {
391
392
  var _a;
392
393
  const blob = yield this.raw.blob();
393
- if (typeof File === 'undefined') {
394
- return blob;
394
+ const name = (_a = parseContentDispositionFilename(this.raw.headers)) !== null && _a !== void 0 ? _a : '';
395
+ if (typeof File !== 'undefined' && blob instanceof Blob) {
396
+ try {
397
+ return new File([blob], name, { type: blob.type });
398
+ }
399
+ catch (_b) {
400
+ // File cannot be constructed: name the Blob itself
401
+ }
395
402
  }
396
- return new File([blob], (_a = parseContentDispositionFilename(this.raw.headers)) !== null && _a !== void 0 ? _a : '', { type: blob.type });
403
+ return Object.assign(blob, { name });
397
404
  });
398
405
  }
399
406
  ;
400
407
  }
401
408
  /**
402
409
  * The file name advertised by a Content-Disposition header (RFC 6266): the RFC 5987 encoded
403
- * `filename*` parameter first, then the plain `filename` as a quoted-string or a token. Parameters
404
- * are split on `;` outside quoted-strings and matched by name case-insensitively. Any directory
405
- * part is dropped so that the name is safe to write to disk as is; undefined when no usable name
406
- * is advertised.
410
+ * `filename*` parameter first, falling back to the plain `filename` when it is malformed, not UTF-8
411
+ * or has no usable name. Any directory part is dropped; undefined when no usable name is advertised.
407
412
  */
408
413
  export function parseContentDispositionFilename(headers) {
409
- const value = headers.get('Content-Disposition');
410
- if (!value) {
411
- return undefined;
414
+ var _a, _b;
415
+ const params = parseHeaderParameters((_a = headers.get('Content-Disposition')) !== null && _a !== void 0 ? _a : '');
416
+ return (_b = basename(decodeExtValue(params.get('filename*')))) !== null && _b !== void 0 ? _b : basename(params.get('filename'));
417
+ }
418
+ /** The decoded RFC 5987 ext-value, or undefined when it is not UTF-8 or its percent-encoding is malformed. */
419
+ function decodeExtValue(value) {
420
+ const match = value === undefined ? null : /^utf-8'[^']*'(.*)$/i.exec(value);
421
+ try {
422
+ return match ? decodeURIComponent(match[1]) : undefined;
412
423
  }
413
- const params = parseHeaderParameters(value);
414
- const encoded = params.get('filename*');
415
- if (encoded !== undefined) {
416
- const extValue = /^utf-8'[^']*'(.*)$/i.exec(encoded);
417
- if (extValue) {
418
- try {
419
- return basename(decodeURIComponent(extValue[1]));
420
- }
421
- catch (_a) {
422
- // malformed percent-encoding: fall through to the plain form
423
- }
424
- }
424
+ catch (_a) {
425
+ return undefined;
425
426
  }
426
- const plain = params.get('filename');
427
- return plain === undefined ? undefined : basename(plain);
428
427
  }
429
428
  /**
430
- * The `name=value` parameters of a header value, split on `;` outside quoted-strings. Names are
431
- * lower-cased, quoted-string values are unquoted with their backslash escapes resolved, and the
432
- * first occurrence of a name wins.
429
+ * The `name=value` parameters of a header value, consumed one at a time so that a quoted-string is
430
+ * taken whole, `;` included. Names are lower-cased, quoted-string values are unquoted with their
431
+ * backslash escapes resolved, and the first occurrence of a name wins.
433
432
  */
434
433
  function parseHeaderParameters(value) {
435
434
  const params = new Map();
436
- let start = 0;
437
- let quoted = false;
438
- for (let i = 0; i <= value.length; i++) {
439
- const c = value[i];
440
- if (i === value.length || (c === ';' && !quoted)) {
441
- const part = value.slice(start, i);
442
- const eq = part.indexOf('=');
443
- if (eq !== -1) {
444
- const name = part.slice(0, eq).trim().toLowerCase();
445
- let raw = part.slice(eq + 1).trim();
446
- if (raw.startsWith('"')) {
447
- raw = raw.slice(1, raw.length > 1 && raw.endsWith('"') ? -1 : undefined).replace(/\\(.)/g, '$1');
448
- }
449
- if (name && !params.has(name)) {
450
- params.set(name, raw);
451
- }
452
- }
453
- start = i + 1;
454
- }
455
- else if (c === '"') {
456
- quoted = !quoted;
457
- }
458
- else if (c === '\\' && quoted) {
459
- i++;
435
+ const parameter = /(?:^|;)\s*([^=;]+?)\s*=\s*(?:"((?:[^"\\]|\\.)*)"?|([^;]*))/g;
436
+ let match;
437
+ while ((match = parameter.exec(value)) !== null) {
438
+ const name = match[1].toLowerCase();
439
+ if (!params.has(name)) {
440
+ params.set(name, match[2] !== undefined ? match[2].replace(/\\(.)/g, '$1') : match[3].trim());
460
441
  }
461
442
  }
462
443
  return params;
463
444
  }
464
- /** The last path segment of a file name, or undefined when nothing usable is left. */
445
+ /** The last `/` or `\` separated segment of a file name, or undefined when it is not a file name. */
465
446
  function basename(name) {
466
- const base = name.slice(Math.max(name.lastIndexOf('/'), name.lastIndexOf('\\')) + 1).trim();
467
- return base === '' || base === '.' || base === '..' ? undefined : base;
447
+ const base = name === null || name === void 0 ? void 0 : name.split(/[\\/]/).pop();
448
+ return !base || base === '.' || base === '..' ? undefined : base;
468
449
  }
469
450
  export class TextApiResponse {
470
451
  constructor(raw) {
package/dist/runtime.d.ts CHANGED
@@ -184,23 +184,30 @@ export declare class VoidApiResponse {
184
184
  constructor(raw: Response);
185
185
  value(): Promise<void>;
186
186
  }
187
+ /**
188
+ * A Blob carrying the file name the server advertised, empty when it did not send one. It is a File
189
+ * wherever one can be built, and the bare Blob given a name otherwise. Same name and shape as the
190
+ * `typescript` generator's browser HttpFile.
191
+ */
192
+ export type HttpFile = Blob & {
193
+ readonly name: string;
194
+ };
187
195
  export declare class BlobApiResponse {
188
196
  raw: Response;
189
197
  constructor(raw: Response);
190
198
  /**
191
- * The body as a File named after the Content-Disposition header, so that a download keeps the
192
- * name the server gave it. A File is a Blob: callers reading a Blob are unaffected, and the name
193
- * is empty when the server did not send one. Runtimes without a global File (Node.js before 20)
194
- * keep receiving the bare Blob.
199
+ * The body named after the Content-Disposition header, so that a download keeps the name the
200
+ * server gave it. A File is built from a native Blob; the Blob itself is named where there is no
201
+ * global File (Node.js before 20), where File cannot be constructed, or where the Blob is not the
202
+ * native one, as returned by an injected fetch implementation such as node-fetch, which a File
203
+ * would stringify instead of wrapping.
195
204
  */
196
- value(): Promise<File>;
205
+ value(): Promise<HttpFile>;
197
206
  }
198
207
  /**
199
208
  * The file name advertised by a Content-Disposition header (RFC 6266): the RFC 5987 encoded
200
- * `filename*` parameter first, then the plain `filename` as a quoted-string or a token. Parameters
201
- * are split on `;` outside quoted-strings and matched by name case-insensitively. Any directory
202
- * part is dropped so that the name is safe to write to disk as is; undefined when no usable name
203
- * is advertised.
209
+ * `filename*` parameter first, falling back to the plain `filename` when it is malformed, not UTF-8
210
+ * or has no usable name. Any directory part is dropped; undefined when no usable name is advertised.
204
211
  */
205
212
  export declare function parseContentDispositionFilename(headers: Headers): string | undefined;
206
213
  export declare class TextApiResponse {
package/dist/runtime.js CHANGED
@@ -401,19 +401,26 @@ class BlobApiResponse {
401
401
  this.raw = raw;
402
402
  }
403
403
  /**
404
- * The body as a File named after the Content-Disposition header, so that a download keeps the
405
- * name the server gave it. A File is a Blob: callers reading a Blob are unaffected, and the name
406
- * is empty when the server did not send one. Runtimes without a global File (Node.js before 20)
407
- * keep receiving the bare Blob.
404
+ * The body named after the Content-Disposition header, so that a download keeps the name the
405
+ * server gave it. A File is built from a native Blob; the Blob itself is named where there is no
406
+ * global File (Node.js before 20), where File cannot be constructed, or where the Blob is not the
407
+ * native one, as returned by an injected fetch implementation such as node-fetch, which a File
408
+ * would stringify instead of wrapping.
408
409
  */
409
410
  value() {
410
411
  return __awaiter(this, void 0, void 0, function* () {
411
412
  var _a;
412
413
  const blob = yield this.raw.blob();
413
- if (typeof File === 'undefined') {
414
- return blob;
414
+ const name = (_a = parseContentDispositionFilename(this.raw.headers)) !== null && _a !== void 0 ? _a : '';
415
+ if (typeof File !== 'undefined' && blob instanceof Blob) {
416
+ try {
417
+ return new File([blob], name, { type: blob.type });
418
+ }
419
+ catch (_b) {
420
+ // File cannot be constructed: name the Blob itself
421
+ }
415
422
  }
416
- return new File([blob], (_a = parseContentDispositionFilename(this.raw.headers)) !== null && _a !== void 0 ? _a : '', { type: blob.type });
423
+ return Object.assign(blob, { name });
417
424
  });
418
425
  }
419
426
  ;
@@ -421,71 +428,45 @@ class BlobApiResponse {
421
428
  exports.BlobApiResponse = BlobApiResponse;
422
429
  /**
423
430
  * The file name advertised by a Content-Disposition header (RFC 6266): the RFC 5987 encoded
424
- * `filename*` parameter first, then the plain `filename` as a quoted-string or a token. Parameters
425
- * are split on `;` outside quoted-strings and matched by name case-insensitively. Any directory
426
- * part is dropped so that the name is safe to write to disk as is; undefined when no usable name
427
- * is advertised.
431
+ * `filename*` parameter first, falling back to the plain `filename` when it is malformed, not UTF-8
432
+ * or has no usable name. Any directory part is dropped; undefined when no usable name is advertised.
428
433
  */
429
434
  function parseContentDispositionFilename(headers) {
430
- const value = headers.get('Content-Disposition');
431
- if (!value) {
432
- return undefined;
435
+ var _a, _b;
436
+ const params = parseHeaderParameters((_a = headers.get('Content-Disposition')) !== null && _a !== void 0 ? _a : '');
437
+ return (_b = basename(decodeExtValue(params.get('filename*')))) !== null && _b !== void 0 ? _b : basename(params.get('filename'));
438
+ }
439
+ /** The decoded RFC 5987 ext-value, or undefined when it is not UTF-8 or its percent-encoding is malformed. */
440
+ function decodeExtValue(value) {
441
+ const match = value === undefined ? null : /^utf-8'[^']*'(.*)$/i.exec(value);
442
+ try {
443
+ return match ? decodeURIComponent(match[1]) : undefined;
433
444
  }
434
- const params = parseHeaderParameters(value);
435
- const encoded = params.get('filename*');
436
- if (encoded !== undefined) {
437
- const extValue = /^utf-8'[^']*'(.*)$/i.exec(encoded);
438
- if (extValue) {
439
- try {
440
- return basename(decodeURIComponent(extValue[1]));
441
- }
442
- catch (_a) {
443
- // malformed percent-encoding: fall through to the plain form
444
- }
445
- }
445
+ catch (_a) {
446
+ return undefined;
446
447
  }
447
- const plain = params.get('filename');
448
- return plain === undefined ? undefined : basename(plain);
449
448
  }
450
449
  /**
451
- * The `name=value` parameters of a header value, split on `;` outside quoted-strings. Names are
452
- * lower-cased, quoted-string values are unquoted with their backslash escapes resolved, and the
453
- * first occurrence of a name wins.
450
+ * The `name=value` parameters of a header value, consumed one at a time so that a quoted-string is
451
+ * taken whole, `;` included. Names are lower-cased, quoted-string values are unquoted with their
452
+ * backslash escapes resolved, and the first occurrence of a name wins.
454
453
  */
455
454
  function parseHeaderParameters(value) {
456
455
  const params = new Map();
457
- let start = 0;
458
- let quoted = false;
459
- for (let i = 0; i <= value.length; i++) {
460
- const c = value[i];
461
- if (i === value.length || (c === ';' && !quoted)) {
462
- const part = value.slice(start, i);
463
- const eq = part.indexOf('=');
464
- if (eq !== -1) {
465
- const name = part.slice(0, eq).trim().toLowerCase();
466
- let raw = part.slice(eq + 1).trim();
467
- if (raw.startsWith('"')) {
468
- raw = raw.slice(1, raw.length > 1 && raw.endsWith('"') ? -1 : undefined).replace(/\\(.)/g, '$1');
469
- }
470
- if (name && !params.has(name)) {
471
- params.set(name, raw);
472
- }
473
- }
474
- start = i + 1;
475
- }
476
- else if (c === '"') {
477
- quoted = !quoted;
478
- }
479
- else if (c === '\\' && quoted) {
480
- i++;
456
+ const parameter = /(?:^|;)\s*([^=;]+?)\s*=\s*(?:"((?:[^"\\]|\\.)*)"?|([^;]*))/g;
457
+ let match;
458
+ while ((match = parameter.exec(value)) !== null) {
459
+ const name = match[1].toLowerCase();
460
+ if (!params.has(name)) {
461
+ params.set(name, match[2] !== undefined ? match[2].replace(/\\(.)/g, '$1') : match[3].trim());
481
462
  }
482
463
  }
483
464
  return params;
484
465
  }
485
- /** The last path segment of a file name, or undefined when nothing usable is left. */
466
+ /** The last `/` or `\` separated segment of a file name, or undefined when it is not a file name. */
486
467
  function basename(name) {
487
- const base = name.slice(Math.max(name.lastIndexOf('/'), name.lastIndexOf('\\')) + 1).trim();
488
- return base === '' || base === '.' || base === '..' ? undefined : base;
468
+ const base = name === null || name === void 0 ? void 0 : name.split(/[\\/]/).pop();
469
+ return !base || base === '.' || base === '..' ? undefined : base;
489
470
  }
490
471
  class TextApiResponse {
491
472
  constructor(raw) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openshift-migration-advisor/agent-sdk",
3
- "version": "0.25.0",
3
+ "version": "0.27.0",
4
4
  "description": "OpenAPI client for @openshift-migration-advisor/agent-sdk",
5
5
  "author": "OpenAPI-Generator",
6
6
  "repository": {
@@ -182,12 +182,12 @@ export interface CollectionsApiInterface {
182
182
  * @throws {RequiredError}
183
183
  * @memberof CollectionsApiInterface
184
184
  */
185
- exportCollectionRaw(requestParameters: ExportCollectionRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<Blob>>;
185
+ exportCollectionRaw(requestParameters: ExportCollectionRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<runtime.HttpFile>>;
186
186
 
187
187
  /**
188
188
  * Export collection data as CSV ZIP archive or Excel workbook
189
189
  */
190
- exportCollection(requestParameters: ExportCollectionRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<Blob>;
190
+ exportCollection(requestParameters: ExportCollectionRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.HttpFile>;
191
191
 
192
192
  /**
193
193
  * Creates request options for listCollections without sending the request
@@ -413,7 +413,7 @@ export class CollectionsApi extends runtime.BaseAPI implements CollectionsApiInt
413
413
  /**
414
414
  * Export collection data as CSV ZIP archive or Excel workbook
415
415
  */
416
- async exportCollectionRaw(requestParameters: ExportCollectionRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<Blob>> {
416
+ async exportCollectionRaw(requestParameters: ExportCollectionRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<runtime.HttpFile>> {
417
417
  const requestOptions = await this.exportCollectionRequestOpts(requestParameters);
418
418
  const response = await this.request(requestOptions, initOverrides);
419
419
 
@@ -423,7 +423,7 @@ export class CollectionsApi extends runtime.BaseAPI implements CollectionsApiInt
423
423
  /**
424
424
  * Export collection data as CSV ZIP archive or Excel workbook
425
425
  */
426
- async exportCollection(requestParameters: ExportCollectionRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<Blob> {
426
+ async exportCollection(requestParameters: ExportCollectionRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.HttpFile> {
427
427
  const response = await this.exportCollectionRaw(requestParameters, initOverrides);
428
428
  return await response.value();
429
429
  }
package/src/runtime.ts CHANGED
@@ -488,90 +488,79 @@ export class VoidApiResponse {
488
488
  }
489
489
  }
490
490
 
491
+ /**
492
+ * A Blob carrying the file name the server advertised, empty when it did not send one. It is a File
493
+ * wherever one can be built, and the bare Blob given a name otherwise. Same name and shape as the
494
+ * `typescript` generator's browser HttpFile.
495
+ */
496
+ export type HttpFile = Blob & { readonly name: string };
497
+
491
498
  export class BlobApiResponse {
492
499
  constructor(public raw: Response) {}
493
500
 
494
501
  /**
495
- * The body as a File named after the Content-Disposition header, so that a download keeps the
496
- * name the server gave it. A File is a Blob: callers reading a Blob are unaffected, and the name
497
- * is empty when the server did not send one. Runtimes without a global File (Node.js before 20)
498
- * keep receiving the bare Blob.
502
+ * The body named after the Content-Disposition header, so that a download keeps the name the
503
+ * server gave it. A File is built from a native Blob; the Blob itself is named where there is no
504
+ * global File (Node.js before 20), where File cannot be constructed, or where the Blob is not the
505
+ * native one, as returned by an injected fetch implementation such as node-fetch, which a File
506
+ * would stringify instead of wrapping.
499
507
  */
500
- async value(): Promise<File> {
508
+ async value(): Promise<HttpFile> {
501
509
  const blob = await this.raw.blob();
502
- if (typeof File === 'undefined') {
503
- return blob as File;
510
+ const name = parseContentDispositionFilename(this.raw.headers) ?? '';
511
+ if (typeof File !== 'undefined' && blob instanceof Blob) {
512
+ try {
513
+ return new File([blob], name, { type: blob.type });
514
+ } catch {
515
+ // File cannot be constructed: name the Blob itself
516
+ }
504
517
  }
505
- return new File([blob], parseContentDispositionFilename(this.raw.headers) ?? '', { type: blob.type });
518
+ return Object.assign(blob, { name });
506
519
  };
507
520
  }
508
521
 
509
522
  /**
510
523
  * The file name advertised by a Content-Disposition header (RFC 6266): the RFC 5987 encoded
511
- * `filename*` parameter first, then the plain `filename` as a quoted-string or a token. Parameters
512
- * are split on `;` outside quoted-strings and matched by name case-insensitively. Any directory
513
- * part is dropped so that the name is safe to write to disk as is; undefined when no usable name
514
- * is advertised.
524
+ * `filename*` parameter first, falling back to the plain `filename` when it is malformed, not UTF-8
525
+ * or has no usable name. Any directory part is dropped; undefined when no usable name is advertised.
515
526
  */
516
527
  export function parseContentDispositionFilename(headers: Headers): string | undefined {
517
- const value = headers.get('Content-Disposition');
518
- if (!value) {
528
+ const params = parseHeaderParameters(headers.get('Content-Disposition') ?? '');
529
+ return basename(decodeExtValue(params.get('filename*'))) ?? basename(params.get('filename'));
530
+ }
531
+
532
+ /** The decoded RFC 5987 ext-value, or undefined when it is not UTF-8 or its percent-encoding is malformed. */
533
+ function decodeExtValue(value: string | undefined): string | undefined {
534
+ const match = value === undefined ? null : /^utf-8'[^']*'(.*)$/i.exec(value);
535
+ try {
536
+ return match ? decodeURIComponent(match[1]) : undefined;
537
+ } catch {
519
538
  return undefined;
520
539
  }
521
- const params = parseHeaderParameters(value);
522
- const encoded = params.get('filename*');
523
- if (encoded !== undefined) {
524
- const extValue = /^utf-8'[^']*'(.*)$/i.exec(encoded);
525
- if (extValue) {
526
- try {
527
- return basename(decodeURIComponent(extValue[1]));
528
- } catch {
529
- // malformed percent-encoding: fall through to the plain form
530
- }
531
- }
532
- }
533
- const plain = params.get('filename');
534
- return plain === undefined ? undefined : basename(plain);
535
540
  }
536
541
 
537
542
  /**
538
- * The `name=value` parameters of a header value, split on `;` outside quoted-strings. Names are
539
- * lower-cased, quoted-string values are unquoted with their backslash escapes resolved, and the
540
- * first occurrence of a name wins.
543
+ * The `name=value` parameters of a header value, consumed one at a time so that a quoted-string is
544
+ * taken whole, `;` included. Names are lower-cased, quoted-string values are unquoted with their
545
+ * backslash escapes resolved, and the first occurrence of a name wins.
541
546
  */
542
547
  function parseHeaderParameters(value: string): Map<string, string> {
543
548
  const params = new Map<string, string>();
544
- let start = 0;
545
- let quoted = false;
546
- for (let i = 0; i <= value.length; i++) {
547
- const c = value[i];
548
- if (i === value.length || (c === ';' && !quoted)) {
549
- const part = value.slice(start, i);
550
- const eq = part.indexOf('=');
551
- if (eq !== -1) {
552
- const name = part.slice(0, eq).trim().toLowerCase();
553
- let raw = part.slice(eq + 1).trim();
554
- if (raw.startsWith('"')) {
555
- raw = raw.slice(1, raw.length > 1 && raw.endsWith('"') ? -1 : undefined).replace(/\\(.)/g, '$1');
556
- }
557
- if (name && !params.has(name)) {
558
- params.set(name, raw);
559
- }
560
- }
561
- start = i + 1;
562
- } else if (c === '"') {
563
- quoted = !quoted;
564
- } else if (c === '\\' && quoted) {
565
- i++;
549
+ const parameter = /(?:^|;)\s*([^=;]+?)\s*=\s*(?:"((?:[^"\\]|\\.)*)"?|([^;]*))/g;
550
+ let match: RegExpExecArray | null;
551
+ while ((match = parameter.exec(value)) !== null) {
552
+ const name = match[1].toLowerCase();
553
+ if (!params.has(name)) {
554
+ params.set(name, match[2] !== undefined ? match[2].replace(/\\(.)/g, '$1') : match[3].trim());
566
555
  }
567
556
  }
568
557
  return params;
569
558
  }
570
559
 
571
- /** The last path segment of a file name, or undefined when nothing usable is left. */
572
- function basename(name: string): string | undefined {
573
- const base = name.slice(Math.max(name.lastIndexOf('/'), name.lastIndexOf('\\')) + 1).trim();
574
- return base === '' || base === '.' || base === '..' ? undefined : base;
560
+ /** The last `/` or `\` separated segment of a file name, or undefined when it is not a file name. */
561
+ function basename(name: string | undefined): string | undefined {
562
+ const base = name?.split(/[\\/]/).pop();
563
+ return !base || base === '.' || base === '..' ? undefined : base;
575
564
  }
576
565
 
577
566
  export class TextApiResponse {