wildberries-sdk 0.1.159 → 0.1.160

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.
Files changed (91) hide show
  1. package/README.md +3 -0
  2. package/dist/analytics/runtime.d.ts +15 -1
  3. package/dist/analytics/runtime.js +85 -3
  4. package/dist/communications/runtime.d.ts +15 -1
  5. package/dist/communications/runtime.js +85 -3
  6. package/dist/dbs/runtime.d.ts +15 -1
  7. package/dist/dbs/runtime.js +85 -3
  8. package/dist/finances/runtime.d.ts +15 -1
  9. package/dist/finances/runtime.js +85 -3
  10. package/dist/general/runtime.d.ts +15 -1
  11. package/dist/general/runtime.js +85 -3
  12. package/dist/in_store_pickup/runtime.d.ts +15 -1
  13. package/dist/in_store_pickup/runtime.js +85 -3
  14. package/dist/items/models/GetV2BufferGoodsTask200Response.d.ts +1 -1
  15. package/dist/items/models/GetV2BufferTasks200Response.d.ts +1 -1
  16. package/dist/items/models/GetV2DirectoryTnved200Response.d.ts +1 -1
  17. package/dist/items/models/GetV2DirectoryVat200Response.d.ts +1 -1
  18. package/dist/items/models/GetV2HistoryTasks200Response.d.ts +1 -1
  19. package/dist/items/models/GetV2ListGoodsFilter200Response.d.ts +1 -1
  20. package/dist/items/models/GetV2ListGoodsSizeNm200Response.d.ts +1 -1
  21. package/dist/items/models/GetV2ObjectAll200Response.d.ts +1 -1
  22. package/dist/items/models/GetV2ObjectCharcsSubjectId200Response.d.ts +1 -1
  23. package/dist/items/models/GetV2QuarantineGoods200Response.d.ts +1 -1
  24. package/dist/items/models/GoodBufferHistory.d.ts +1 -1
  25. package/dist/items/models/GoodHistory.d.ts +1 -1
  26. package/dist/items/models/MediaErrors.d.ts +1 -1
  27. package/dist/items/models/RequestAlreadyExistsError.d.ts +1 -1
  28. package/dist/items/models/ResponseBodyContentError400.d.ts +1 -1
  29. package/dist/items/models/ResponseBodyContentError403.d.ts +1 -1
  30. package/dist/items/models/ResponseContentError.d.ts +1 -1
  31. package/dist/items/models/ResponseError.d.ts +1 -1
  32. package/dist/items/models/TaskCreated.d.ts +1 -1
  33. package/dist/items/runtime.d.ts +15 -1
  34. package/dist/items/runtime.js +85 -3
  35. package/dist/orders_dbw/runtime.d.ts +15 -1
  36. package/dist/orders_dbw/runtime.js +85 -3
  37. package/dist/orders_fbs/apis/FBSApi.d.ts +10 -9
  38. package/dist/orders_fbs/apis/FBSApi.js +8 -7
  39. package/dist/orders_fbs/models/{ReplyBatchError.d.ts → UpdateSuppliesShippingMethodResponse.d.ts} +11 -15
  40. package/dist/orders_fbs/models/UpdateSuppliesShippingMethodResponse.js +52 -0
  41. package/dist/orders_fbs/models/{UpdateSuppliesResponse.d.ts → UpdateSuppliesWaybillResponse.d.ts} +10 -10
  42. package/dist/orders_fbs/models/{UpdateSuppliesResponse.js → UpdateSuppliesWaybillResponse.js} +16 -16
  43. package/dist/orders_fbs/models/UpdatedSuppliesShippingMethod.d.ts +39 -0
  44. package/dist/orders_fbs/models/UpdatedSuppliesShippingMethod.js +56 -0
  45. package/dist/orders_fbs/models/UpdatedSuppliesShippingMethodError.d.ts +46 -0
  46. package/dist/orders_fbs/models/UpdatedSuppliesShippingMethodError.js +55 -0
  47. package/dist/orders_fbs/models/{UpdatedSupplies.d.ts → UpdatedSuppliesWaybill.d.ts} +10 -10
  48. package/dist/orders_fbs/models/{UpdatedSupplies.js → UpdatedSuppliesWaybill.js} +16 -16
  49. package/dist/orders_fbs/models/UpdatedSuppliesWaybillError.d.ts +44 -0
  50. package/dist/orders_fbs/models/{ReplyBatchError.js → UpdatedSuppliesWaybillError.js} +13 -13
  51. package/dist/orders_fbs/models/index.d.ts +6 -3
  52. package/dist/orders_fbs/models/index.js +6 -3
  53. package/dist/orders_fbs/runtime.d.ts +15 -1
  54. package/dist/orders_fbs/runtime.js +85 -3
  55. package/dist/orders_fbw/apis/DefaultApi.d.ts +2 -2
  56. package/dist/orders_fbw/apis/DefaultApi.js +2 -2
  57. package/dist/orders_fbw/runtime.d.ts +15 -1
  58. package/dist/orders_fbw/runtime.js +85 -3
  59. package/dist/promotion/apis/DefaultApi.d.ts +43 -0
  60. package/dist/promotion/apis/DefaultApi.js +150 -0
  61. package/dist/promotion/models/V0DailyLimitAdvert.d.ts +68 -0
  62. package/dist/promotion/models/V0DailyLimitAdvert.js +79 -0
  63. package/dist/promotion/models/V0GetDailyLimitsResponse.d.ts +31 -0
  64. package/dist/promotion/models/V0GetDailyLimitsResponse.js +52 -0
  65. package/dist/promotion/models/V0PutDailyLimitsAdvertResult.d.ts +43 -0
  66. package/dist/promotion/models/V0PutDailyLimitsAdvertResult.js +59 -0
  67. package/dist/promotion/models/V0PutDailyLimitsRequest.d.ts +52 -0
  68. package/dist/promotion/models/V0PutDailyLimitsRequest.js +59 -0
  69. package/dist/promotion/models/V0PutDailyLimitsResponse.d.ts +31 -0
  70. package/dist/promotion/models/V0PutDailyLimitsResponse.js +52 -0
  71. package/dist/promotion/models/V2GetConfigResponse.d.ts +5 -0
  72. package/dist/promotion/models/V2GetConfigResponse.js +4 -0
  73. package/dist/promotion/models/index.d.ts +5 -0
  74. package/dist/promotion/models/index.js +5 -0
  75. package/dist/promotion/runtime.d.ts +15 -1
  76. package/dist/promotion/runtime.js +85 -3
  77. package/dist/rates/runtime.d.ts +15 -1
  78. package/dist/rates/runtime.js +85 -3
  79. package/dist/reports/apis/DefaultApi.d.ts +53 -2
  80. package/dist/reports/apis/DefaultApi.js +121 -3
  81. package/dist/reports/models/GoodsReturn200Response.d.ts +35 -0
  82. package/dist/reports/models/GoodsReturn200Response.js +56 -0
  83. package/dist/reports/models/GoodsReturn200ResponseReportInner.d.ts +102 -0
  84. package/dist/reports/models/GoodsReturn200ResponseReportInner.js +122 -0
  85. package/dist/reports/models/{Model4xxResponse.d.ts → Model4XXResponse.d.ts} +8 -8
  86. package/dist/reports/models/{Model4xxResponse.js → Model4XXResponse.js} +13 -13
  87. package/dist/reports/models/index.d.ts +3 -1
  88. package/dist/reports/models/index.js +3 -1
  89. package/dist/reports/runtime.d.ts +15 -1
  90. package/dist/reports/runtime.js +85 -3
  91. package/package.json +1 -1
package/README.md CHANGED
@@ -252,6 +252,7 @@ main().catch(console.error);
252
252
  ### promotion (`promotion`)
253
253
  - `promotion.DefaultApi.deleteV0NormqueryBids` — Удалить ставки поисковых кластеров
254
254
  - `promotion.DefaultApi.getV0BidsRecommendations` — Рекомендуемые ставки для карточек товаров и поисковых кластеров
255
+ - `promotion.DefaultApi.getV0DailyLimits` — Получить настройки дневных лимитов кампаний
255
256
  - `promotion.DefaultApi.getV0Delete` — Удаление кампании
256
257
  - `promotion.DefaultApi.getV0Pause` — Пауза кампании
257
258
  - `promotion.DefaultApi.getV0Start` — Запуск кампании
@@ -290,6 +291,7 @@ main().catch(console.error);
290
291
  - `promotion.DefaultApi.postV2SeacatSaveAd` — Создать кампанию
291
292
  - `promotion.DefaultApi.postV2SupplierNms` — Карточки товаров для кампаний
292
293
  - `promotion.DefaultApi.putV0AuctionPlacements` — Изменение мест размещения в кампаниях с ручной ставкой
294
+ - `promotion.DefaultApi.putV0DailyLimits` — Настройка дневных лимитов кампаний
293
295
 
294
296
  ### communications (`communications`)
295
297
  - `communications.DefaultApi.deleteFeedbacksV1Pins` — Открепить отзывы
@@ -349,6 +351,7 @@ main().catch(console.error);
349
351
 
350
352
  ### reports (`reports`)
351
353
  - `reports.CApi.postV1AnalyticsExciseReport` — Получить отчёт
354
+ - `reports.DefaultApi.getAnalyticsV1GoodsReturn` — Получить отчёт
352
355
  - `reports.DefaultApi.getV1AcceptanceReport` — Создать отчёт
353
356
  - `reports.DefaultApi.getV1AcceptanceReportTasksTaskIdDownload` — Получить отчёт
354
357
  - `reports.DefaultApi.getV1AcceptanceReportTasksTaskIdStatus` — Проверить статус
@@ -187,8 +187,22 @@ export declare class VoidApiResponse {
187
187
  export declare class BlobApiResponse {
188
188
  raw: Response;
189
189
  constructor(raw: Response);
190
- value(): Promise<Blob>;
190
+ /**
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.
195
+ */
196
+ value(): Promise<File>;
191
197
  }
198
+ /**
199
+ * 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.
204
+ */
205
+ export declare function parseContentDispositionFilename(headers: Headers): string | undefined;
192
206
  export declare class TextApiResponse {
193
207
  raw: Response;
194
208
  constructor(raw: Response);
@@ -85,6 +85,7 @@ exports.parseDateTime = parseDateTime;
85
85
  exports.mapValues = mapValues;
86
86
  exports.anyToJSON = anyToJSON;
87
87
  exports.canConsumeForm = canConsumeForm;
88
+ exports.parseContentDispositionFilename = parseContentDispositionFilename;
88
89
  exports.BASE_PATH = "http://localhost".replace(/\/+$/, "");
89
90
  var Configuration = /** @class */ (function () {
90
91
  function Configuration(configuration) {
@@ -604,12 +605,25 @@ var BlobApiResponse = /** @class */ (function () {
604
605
  function BlobApiResponse(raw) {
605
606
  this.raw = raw;
606
607
  }
608
+ /**
609
+ * The body as a File named after the Content-Disposition header, so that a download keeps the
610
+ * name the server gave it. A File is a Blob: callers reading a Blob are unaffected, and the name
611
+ * is empty when the server did not send one. Runtimes without a global File (Node.js before 20)
612
+ * keep receiving the bare Blob.
613
+ */
607
614
  BlobApiResponse.prototype.value = function () {
608
615
  return __awaiter(this, void 0, void 0, function () {
609
- return __generator(this, function (_a) {
610
- switch (_a.label) {
616
+ var blob;
617
+ var _a;
618
+ return __generator(this, function (_b) {
619
+ switch (_b.label) {
611
620
  case 0: return [4 /*yield*/, this.raw.blob()];
612
- case 1: return [2 /*return*/, _a.sent()];
621
+ case 1:
622
+ blob = _b.sent();
623
+ if (typeof File === 'undefined') {
624
+ return [2 /*return*/, blob];
625
+ }
626
+ return [2 /*return*/, new File([blob], (_a = parseContentDispositionFilename(this.raw.headers)) !== null && _a !== void 0 ? _a : '', { type: blob.type })];
613
627
  }
614
628
  });
615
629
  });
@@ -618,6 +632,74 @@ var BlobApiResponse = /** @class */ (function () {
618
632
  return BlobApiResponse;
619
633
  }());
620
634
  exports.BlobApiResponse = BlobApiResponse;
635
+ /**
636
+ * The file name advertised by a Content-Disposition header (RFC 6266): the RFC 5987 encoded
637
+ * `filename*` parameter first, then the plain `filename` as a quoted-string or a token. Parameters
638
+ * are split on `;` outside quoted-strings and matched by name case-insensitively. Any directory
639
+ * part is dropped so that the name is safe to write to disk as is; undefined when no usable name
640
+ * is advertised.
641
+ */
642
+ function parseContentDispositionFilename(headers) {
643
+ var value = headers.get('Content-Disposition');
644
+ if (!value) {
645
+ return undefined;
646
+ }
647
+ var params = parseHeaderParameters(value);
648
+ var encoded = params.get('filename*');
649
+ if (encoded !== undefined) {
650
+ var extValue = /^utf-8'[^']*'(.*)$/i.exec(encoded);
651
+ if (extValue) {
652
+ try {
653
+ return basename(decodeURIComponent(extValue[1]));
654
+ }
655
+ catch (_a) {
656
+ // malformed percent-encoding: fall through to the plain form
657
+ }
658
+ }
659
+ }
660
+ var plain = params.get('filename');
661
+ return plain === undefined ? undefined : basename(plain);
662
+ }
663
+ /**
664
+ * The `name=value` parameters of a header value, split on `;` outside quoted-strings. Names are
665
+ * lower-cased, quoted-string values are unquoted with their backslash escapes resolved, and the
666
+ * first occurrence of a name wins.
667
+ */
668
+ function parseHeaderParameters(value) {
669
+ var params = new Map();
670
+ var start = 0;
671
+ var quoted = false;
672
+ for (var i = 0; i <= value.length; i++) {
673
+ var c = value[i];
674
+ if (i === value.length || (c === ';' && !quoted)) {
675
+ var part = value.slice(start, i);
676
+ var eq = part.indexOf('=');
677
+ if (eq !== -1) {
678
+ var name_1 = part.slice(0, eq).trim().toLowerCase();
679
+ var raw = part.slice(eq + 1).trim();
680
+ if (raw.startsWith('"')) {
681
+ raw = raw.slice(1, raw.length > 1 && raw.endsWith('"') ? -1 : undefined).replace(/\\(.)/g, '$1');
682
+ }
683
+ if (name_1 && !params.has(name_1)) {
684
+ params.set(name_1, raw);
685
+ }
686
+ }
687
+ start = i + 1;
688
+ }
689
+ else if (c === '"') {
690
+ quoted = !quoted;
691
+ }
692
+ else if (c === '\\' && quoted) {
693
+ i++;
694
+ }
695
+ }
696
+ return params;
697
+ }
698
+ /** The last path segment of a file name, or undefined when nothing usable is left. */
699
+ function basename(name) {
700
+ var base = name.slice(Math.max(name.lastIndexOf('/'), name.lastIndexOf('\\')) + 1).trim();
701
+ return base === '' || base === '.' || base === '..' ? undefined : base;
702
+ }
621
703
  var TextApiResponse = /** @class */ (function () {
622
704
  function TextApiResponse(raw) {
623
705
  this.raw = raw;
@@ -187,8 +187,22 @@ export declare class VoidApiResponse {
187
187
  export declare class BlobApiResponse {
188
188
  raw: Response;
189
189
  constructor(raw: Response);
190
- value(): Promise<Blob>;
190
+ /**
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.
195
+ */
196
+ value(): Promise<File>;
191
197
  }
198
+ /**
199
+ * 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.
204
+ */
205
+ export declare function parseContentDispositionFilename(headers: Headers): string | undefined;
192
206
  export declare class TextApiResponse {
193
207
  raw: Response;
194
208
  constructor(raw: Response);
@@ -85,6 +85,7 @@ exports.parseDateTime = parseDateTime;
85
85
  exports.mapValues = mapValues;
86
86
  exports.anyToJSON = anyToJSON;
87
87
  exports.canConsumeForm = canConsumeForm;
88
+ exports.parseContentDispositionFilename = parseContentDispositionFilename;
88
89
  exports.BASE_PATH = "http://localhost".replace(/\/+$/, "");
89
90
  var Configuration = /** @class */ (function () {
90
91
  function Configuration(configuration) {
@@ -604,12 +605,25 @@ var BlobApiResponse = /** @class */ (function () {
604
605
  function BlobApiResponse(raw) {
605
606
  this.raw = raw;
606
607
  }
608
+ /**
609
+ * The body as a File named after the Content-Disposition header, so that a download keeps the
610
+ * name the server gave it. A File is a Blob: callers reading a Blob are unaffected, and the name
611
+ * is empty when the server did not send one. Runtimes without a global File (Node.js before 20)
612
+ * keep receiving the bare Blob.
613
+ */
607
614
  BlobApiResponse.prototype.value = function () {
608
615
  return __awaiter(this, void 0, void 0, function () {
609
- return __generator(this, function (_a) {
610
- switch (_a.label) {
616
+ var blob;
617
+ var _a;
618
+ return __generator(this, function (_b) {
619
+ switch (_b.label) {
611
620
  case 0: return [4 /*yield*/, this.raw.blob()];
612
- case 1: return [2 /*return*/, _a.sent()];
621
+ case 1:
622
+ blob = _b.sent();
623
+ if (typeof File === 'undefined') {
624
+ return [2 /*return*/, blob];
625
+ }
626
+ return [2 /*return*/, new File([blob], (_a = parseContentDispositionFilename(this.raw.headers)) !== null && _a !== void 0 ? _a : '', { type: blob.type })];
613
627
  }
614
628
  });
615
629
  });
@@ -618,6 +632,74 @@ var BlobApiResponse = /** @class */ (function () {
618
632
  return BlobApiResponse;
619
633
  }());
620
634
  exports.BlobApiResponse = BlobApiResponse;
635
+ /**
636
+ * The file name advertised by a Content-Disposition header (RFC 6266): the RFC 5987 encoded
637
+ * `filename*` parameter first, then the plain `filename` as a quoted-string or a token. Parameters
638
+ * are split on `;` outside quoted-strings and matched by name case-insensitively. Any directory
639
+ * part is dropped so that the name is safe to write to disk as is; undefined when no usable name
640
+ * is advertised.
641
+ */
642
+ function parseContentDispositionFilename(headers) {
643
+ var value = headers.get('Content-Disposition');
644
+ if (!value) {
645
+ return undefined;
646
+ }
647
+ var params = parseHeaderParameters(value);
648
+ var encoded = params.get('filename*');
649
+ if (encoded !== undefined) {
650
+ var extValue = /^utf-8'[^']*'(.*)$/i.exec(encoded);
651
+ if (extValue) {
652
+ try {
653
+ return basename(decodeURIComponent(extValue[1]));
654
+ }
655
+ catch (_a) {
656
+ // malformed percent-encoding: fall through to the plain form
657
+ }
658
+ }
659
+ }
660
+ var plain = params.get('filename');
661
+ return plain === undefined ? undefined : basename(plain);
662
+ }
663
+ /**
664
+ * The `name=value` parameters of a header value, split on `;` outside quoted-strings. Names are
665
+ * lower-cased, quoted-string values are unquoted with their backslash escapes resolved, and the
666
+ * first occurrence of a name wins.
667
+ */
668
+ function parseHeaderParameters(value) {
669
+ var params = new Map();
670
+ var start = 0;
671
+ var quoted = false;
672
+ for (var i = 0; i <= value.length; i++) {
673
+ var c = value[i];
674
+ if (i === value.length || (c === ';' && !quoted)) {
675
+ var part = value.slice(start, i);
676
+ var eq = part.indexOf('=');
677
+ if (eq !== -1) {
678
+ var name_1 = part.slice(0, eq).trim().toLowerCase();
679
+ var raw = part.slice(eq + 1).trim();
680
+ if (raw.startsWith('"')) {
681
+ raw = raw.slice(1, raw.length > 1 && raw.endsWith('"') ? -1 : undefined).replace(/\\(.)/g, '$1');
682
+ }
683
+ if (name_1 && !params.has(name_1)) {
684
+ params.set(name_1, raw);
685
+ }
686
+ }
687
+ start = i + 1;
688
+ }
689
+ else if (c === '"') {
690
+ quoted = !quoted;
691
+ }
692
+ else if (c === '\\' && quoted) {
693
+ i++;
694
+ }
695
+ }
696
+ return params;
697
+ }
698
+ /** The last path segment of a file name, or undefined when nothing usable is left. */
699
+ function basename(name) {
700
+ var base = name.slice(Math.max(name.lastIndexOf('/'), name.lastIndexOf('\\')) + 1).trim();
701
+ return base === '' || base === '.' || base === '..' ? undefined : base;
702
+ }
621
703
  var TextApiResponse = /** @class */ (function () {
622
704
  function TextApiResponse(raw) {
623
705
  this.raw = raw;
@@ -187,8 +187,22 @@ export declare class VoidApiResponse {
187
187
  export declare class BlobApiResponse {
188
188
  raw: Response;
189
189
  constructor(raw: Response);
190
- value(): Promise<Blob>;
190
+ /**
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.
195
+ */
196
+ value(): Promise<File>;
191
197
  }
198
+ /**
199
+ * 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.
204
+ */
205
+ export declare function parseContentDispositionFilename(headers: Headers): string | undefined;
192
206
  export declare class TextApiResponse {
193
207
  raw: Response;
194
208
  constructor(raw: Response);
@@ -85,6 +85,7 @@ exports.parseDateTime = parseDateTime;
85
85
  exports.mapValues = mapValues;
86
86
  exports.anyToJSON = anyToJSON;
87
87
  exports.canConsumeForm = canConsumeForm;
88
+ exports.parseContentDispositionFilename = parseContentDispositionFilename;
88
89
  exports.BASE_PATH = "http://localhost".replace(/\/+$/, "");
89
90
  var Configuration = /** @class */ (function () {
90
91
  function Configuration(configuration) {
@@ -604,12 +605,25 @@ var BlobApiResponse = /** @class */ (function () {
604
605
  function BlobApiResponse(raw) {
605
606
  this.raw = raw;
606
607
  }
608
+ /**
609
+ * The body as a File named after the Content-Disposition header, so that a download keeps the
610
+ * name the server gave it. A File is a Blob: callers reading a Blob are unaffected, and the name
611
+ * is empty when the server did not send one. Runtimes without a global File (Node.js before 20)
612
+ * keep receiving the bare Blob.
613
+ */
607
614
  BlobApiResponse.prototype.value = function () {
608
615
  return __awaiter(this, void 0, void 0, function () {
609
- return __generator(this, function (_a) {
610
- switch (_a.label) {
616
+ var blob;
617
+ var _a;
618
+ return __generator(this, function (_b) {
619
+ switch (_b.label) {
611
620
  case 0: return [4 /*yield*/, this.raw.blob()];
612
- case 1: return [2 /*return*/, _a.sent()];
621
+ case 1:
622
+ blob = _b.sent();
623
+ if (typeof File === 'undefined') {
624
+ return [2 /*return*/, blob];
625
+ }
626
+ return [2 /*return*/, new File([blob], (_a = parseContentDispositionFilename(this.raw.headers)) !== null && _a !== void 0 ? _a : '', { type: blob.type })];
613
627
  }
614
628
  });
615
629
  });
@@ -618,6 +632,74 @@ var BlobApiResponse = /** @class */ (function () {
618
632
  return BlobApiResponse;
619
633
  }());
620
634
  exports.BlobApiResponse = BlobApiResponse;
635
+ /**
636
+ * The file name advertised by a Content-Disposition header (RFC 6266): the RFC 5987 encoded
637
+ * `filename*` parameter first, then the plain `filename` as a quoted-string or a token. Parameters
638
+ * are split on `;` outside quoted-strings and matched by name case-insensitively. Any directory
639
+ * part is dropped so that the name is safe to write to disk as is; undefined when no usable name
640
+ * is advertised.
641
+ */
642
+ function parseContentDispositionFilename(headers) {
643
+ var value = headers.get('Content-Disposition');
644
+ if (!value) {
645
+ return undefined;
646
+ }
647
+ var params = parseHeaderParameters(value);
648
+ var encoded = params.get('filename*');
649
+ if (encoded !== undefined) {
650
+ var extValue = /^utf-8'[^']*'(.*)$/i.exec(encoded);
651
+ if (extValue) {
652
+ try {
653
+ return basename(decodeURIComponent(extValue[1]));
654
+ }
655
+ catch (_a) {
656
+ // malformed percent-encoding: fall through to the plain form
657
+ }
658
+ }
659
+ }
660
+ var plain = params.get('filename');
661
+ return plain === undefined ? undefined : basename(plain);
662
+ }
663
+ /**
664
+ * The `name=value` parameters of a header value, split on `;` outside quoted-strings. Names are
665
+ * lower-cased, quoted-string values are unquoted with their backslash escapes resolved, and the
666
+ * first occurrence of a name wins.
667
+ */
668
+ function parseHeaderParameters(value) {
669
+ var params = new Map();
670
+ var start = 0;
671
+ var quoted = false;
672
+ for (var i = 0; i <= value.length; i++) {
673
+ var c = value[i];
674
+ if (i === value.length || (c === ';' && !quoted)) {
675
+ var part = value.slice(start, i);
676
+ var eq = part.indexOf('=');
677
+ if (eq !== -1) {
678
+ var name_1 = part.slice(0, eq).trim().toLowerCase();
679
+ var raw = part.slice(eq + 1).trim();
680
+ if (raw.startsWith('"')) {
681
+ raw = raw.slice(1, raw.length > 1 && raw.endsWith('"') ? -1 : undefined).replace(/\\(.)/g, '$1');
682
+ }
683
+ if (name_1 && !params.has(name_1)) {
684
+ params.set(name_1, raw);
685
+ }
686
+ }
687
+ start = i + 1;
688
+ }
689
+ else if (c === '"') {
690
+ quoted = !quoted;
691
+ }
692
+ else if (c === '\\' && quoted) {
693
+ i++;
694
+ }
695
+ }
696
+ return params;
697
+ }
698
+ /** The last path segment of a file name, or undefined when nothing usable is left. */
699
+ function basename(name) {
700
+ var base = name.slice(Math.max(name.lastIndexOf('/'), name.lastIndexOf('\\')) + 1).trim();
701
+ return base === '' || base === '.' || base === '..' ? undefined : base;
702
+ }
621
703
  var TextApiResponse = /** @class */ (function () {
622
704
  function TextApiResponse(raw) {
623
705
  this.raw = raw;
@@ -187,8 +187,22 @@ export declare class VoidApiResponse {
187
187
  export declare class BlobApiResponse {
188
188
  raw: Response;
189
189
  constructor(raw: Response);
190
- value(): Promise<Blob>;
190
+ /**
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.
195
+ */
196
+ value(): Promise<File>;
191
197
  }
198
+ /**
199
+ * 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.
204
+ */
205
+ export declare function parseContentDispositionFilename(headers: Headers): string | undefined;
192
206
  export declare class TextApiResponse {
193
207
  raw: Response;
194
208
  constructor(raw: Response);
@@ -85,6 +85,7 @@ exports.parseDateTime = parseDateTime;
85
85
  exports.mapValues = mapValues;
86
86
  exports.anyToJSON = anyToJSON;
87
87
  exports.canConsumeForm = canConsumeForm;
88
+ exports.parseContentDispositionFilename = parseContentDispositionFilename;
88
89
  exports.BASE_PATH = "http://localhost".replace(/\/+$/, "");
89
90
  var Configuration = /** @class */ (function () {
90
91
  function Configuration(configuration) {
@@ -604,12 +605,25 @@ var BlobApiResponse = /** @class */ (function () {
604
605
  function BlobApiResponse(raw) {
605
606
  this.raw = raw;
606
607
  }
608
+ /**
609
+ * The body as a File named after the Content-Disposition header, so that a download keeps the
610
+ * name the server gave it. A File is a Blob: callers reading a Blob are unaffected, and the name
611
+ * is empty when the server did not send one. Runtimes without a global File (Node.js before 20)
612
+ * keep receiving the bare Blob.
613
+ */
607
614
  BlobApiResponse.prototype.value = function () {
608
615
  return __awaiter(this, void 0, void 0, function () {
609
- return __generator(this, function (_a) {
610
- switch (_a.label) {
616
+ var blob;
617
+ var _a;
618
+ return __generator(this, function (_b) {
619
+ switch (_b.label) {
611
620
  case 0: return [4 /*yield*/, this.raw.blob()];
612
- case 1: return [2 /*return*/, _a.sent()];
621
+ case 1:
622
+ blob = _b.sent();
623
+ if (typeof File === 'undefined') {
624
+ return [2 /*return*/, blob];
625
+ }
626
+ return [2 /*return*/, new File([blob], (_a = parseContentDispositionFilename(this.raw.headers)) !== null && _a !== void 0 ? _a : '', { type: blob.type })];
613
627
  }
614
628
  });
615
629
  });
@@ -618,6 +632,74 @@ var BlobApiResponse = /** @class */ (function () {
618
632
  return BlobApiResponse;
619
633
  }());
620
634
  exports.BlobApiResponse = BlobApiResponse;
635
+ /**
636
+ * The file name advertised by a Content-Disposition header (RFC 6266): the RFC 5987 encoded
637
+ * `filename*` parameter first, then the plain `filename` as a quoted-string or a token. Parameters
638
+ * are split on `;` outside quoted-strings and matched by name case-insensitively. Any directory
639
+ * part is dropped so that the name is safe to write to disk as is; undefined when no usable name
640
+ * is advertised.
641
+ */
642
+ function parseContentDispositionFilename(headers) {
643
+ var value = headers.get('Content-Disposition');
644
+ if (!value) {
645
+ return undefined;
646
+ }
647
+ var params = parseHeaderParameters(value);
648
+ var encoded = params.get('filename*');
649
+ if (encoded !== undefined) {
650
+ var extValue = /^utf-8'[^']*'(.*)$/i.exec(encoded);
651
+ if (extValue) {
652
+ try {
653
+ return basename(decodeURIComponent(extValue[1]));
654
+ }
655
+ catch (_a) {
656
+ // malformed percent-encoding: fall through to the plain form
657
+ }
658
+ }
659
+ }
660
+ var plain = params.get('filename');
661
+ return plain === undefined ? undefined : basename(plain);
662
+ }
663
+ /**
664
+ * The `name=value` parameters of a header value, split on `;` outside quoted-strings. Names are
665
+ * lower-cased, quoted-string values are unquoted with their backslash escapes resolved, and the
666
+ * first occurrence of a name wins.
667
+ */
668
+ function parseHeaderParameters(value) {
669
+ var params = new Map();
670
+ var start = 0;
671
+ var quoted = false;
672
+ for (var i = 0; i <= value.length; i++) {
673
+ var c = value[i];
674
+ if (i === value.length || (c === ';' && !quoted)) {
675
+ var part = value.slice(start, i);
676
+ var eq = part.indexOf('=');
677
+ if (eq !== -1) {
678
+ var name_1 = part.slice(0, eq).trim().toLowerCase();
679
+ var raw = part.slice(eq + 1).trim();
680
+ if (raw.startsWith('"')) {
681
+ raw = raw.slice(1, raw.length > 1 && raw.endsWith('"') ? -1 : undefined).replace(/\\(.)/g, '$1');
682
+ }
683
+ if (name_1 && !params.has(name_1)) {
684
+ params.set(name_1, raw);
685
+ }
686
+ }
687
+ start = i + 1;
688
+ }
689
+ else if (c === '"') {
690
+ quoted = !quoted;
691
+ }
692
+ else if (c === '\\' && quoted) {
693
+ i++;
694
+ }
695
+ }
696
+ return params;
697
+ }
698
+ /** The last path segment of a file name, or undefined when nothing usable is left. */
699
+ function basename(name) {
700
+ var base = name.slice(Math.max(name.lastIndexOf('/'), name.lastIndexOf('\\')) + 1).trim();
701
+ return base === '' || base === '.' || base === '..' ? undefined : base;
702
+ }
621
703
  var TextApiResponse = /** @class */ (function () {
622
704
  function TextApiResponse(raw) {
623
705
  this.raw = raw;
@@ -187,8 +187,22 @@ export declare class VoidApiResponse {
187
187
  export declare class BlobApiResponse {
188
188
  raw: Response;
189
189
  constructor(raw: Response);
190
- value(): Promise<Blob>;
190
+ /**
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.
195
+ */
196
+ value(): Promise<File>;
191
197
  }
198
+ /**
199
+ * 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.
204
+ */
205
+ export declare function parseContentDispositionFilename(headers: Headers): string | undefined;
192
206
  export declare class TextApiResponse {
193
207
  raw: Response;
194
208
  constructor(raw: Response);