|
1 | | -import urlJoin from "url-join"; |
2 | 1 | import * as Webflow from "../api"; |
3 | 2 | import { Items } from "../api/resources/collections/resources/items/client/Client"; |
4 | 3 | import * as core from "../core"; |
5 | 4 | import * as environments from "../environments"; |
6 | 5 | import * as errors from "../errors"; |
7 | 6 | import * as serializers from "../serialization"; |
8 | | -import { mergeHeaders, mergeOnlyDefinedHeaders } from "../core/headers.js"; |
| 7 | +import { mergeHeaders, mergeOnlyDefinedHeaders } from "../core/headers"; |
9 | 8 | import * as SchemaOverrides from "./schemas"; |
10 | 9 |
|
11 | 10 | declare module "../api/resources/collections/resources/items/client/Client" { |
@@ -82,32 +81,33 @@ export class Client extends Items { |
82 | 81 | const { skipInvalidFiles, ..._body } = request; |
83 | 82 | const _queryParams: Record<string, string | string[] | object | object[] | null> = {}; |
84 | 83 | if (skipInvalidFiles != null) { |
85 | | - _queryParams["skipInvalidFiles"] = skipInvalidFiles.toString(); |
| 84 | + _queryParams.skipInvalidFiles = skipInvalidFiles.toString(); |
86 | 85 | } |
87 | 86 |
|
| 87 | + const _headers: core.Fetcher.Args["headers"] = mergeHeaders( |
| 88 | + this._options?.headers, |
| 89 | + mergeOnlyDefinedHeaders({ Authorization: await this._getAuthorizationHeader() }), |
| 90 | + requestOptions?.headers, |
| 91 | + ); |
88 | 92 | const _response = await core.fetcher({ |
89 | | - url: urlJoin( |
| 93 | + url: core.url.join( |
90 | 94 | (await core.Supplier.get(this._options.baseUrl)) ?? |
91 | 95 | ((await core.Supplier.get(this._options.environment)) ?? environments.WebflowEnvironment.DataApi) |
92 | 96 | .base, |
93 | | - `collections/${encodeURIComponent(collectionId)}/items`, |
| 97 | + `collections/${core.url.encodePathParam(collectionId)}/items`, |
94 | 98 | ), |
95 | 99 | method: "POST", |
96 | | - headers: mergeHeaders( |
97 | | - this._options?.headers, |
98 | | - mergeOnlyDefinedHeaders({ Authorization: await this._getAuthorizationHeader() }), |
99 | | - requestOptions?.headers, |
100 | | - ), |
| 100 | + headers: _headers, |
101 | 101 | contentType: "application/json", |
102 | | - queryParameters: _queryParams, |
| 102 | + queryParameters: { ..._queryParams, ...requestOptions?.queryParams }, |
103 | 103 | requestType: "json", |
104 | 104 | body: serializers.collections.ItemsCreateItemRequestBody.jsonOrThrow(_body, { |
105 | 105 | unrecognizedObjectKeys: "passthrough", |
106 | 106 | allowUnrecognizedUnionMembers: true, |
107 | 107 | allowUnrecognizedEnumValues: true, |
108 | 108 | }), |
109 | | - timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, |
110 | | - maxRetries: requestOptions?.maxRetries, |
| 109 | + timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1000, |
| 110 | + maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, |
111 | 111 | abortSignal: requestOptions?.abortSignal, |
112 | 112 | }); |
113 | 113 | if (_response.ok) { |
@@ -245,32 +245,33 @@ export class Client extends Items { |
245 | 245 | const { skipInvalidFiles, ..._body } = request; |
246 | 246 | const _queryParams: Record<string, string | string[] | object | object[] | null> = {}; |
247 | 247 | if (skipInvalidFiles != null) { |
248 | | - _queryParams["skipInvalidFiles"] = skipInvalidFiles.toString(); |
| 248 | + _queryParams.skipInvalidFiles = skipInvalidFiles.toString(); |
249 | 249 | } |
250 | 250 |
|
| 251 | + const _headers: core.Fetcher.Args["headers"] = mergeHeaders( |
| 252 | + this._options?.headers, |
| 253 | + mergeOnlyDefinedHeaders({ Authorization: await this._getAuthorizationHeader() }), |
| 254 | + requestOptions?.headers, |
| 255 | + ); |
251 | 256 | const _response = await core.fetcher({ |
252 | | - url: urlJoin( |
| 257 | + url: core.url.join( |
253 | 258 | (await core.Supplier.get(this._options.baseUrl)) ?? |
254 | 259 | ((await core.Supplier.get(this._options.environment)) ?? environments.WebflowEnvironment.DataApi) |
255 | 260 | .base, |
256 | | - `collections/${encodeURIComponent(collectionId)}/items/${encodeURIComponent(itemId)}`, |
| 261 | + `collections/${core.url.encodePathParam(collectionId)}/items/${core.url.encodePathParam(itemId)}`, |
257 | 262 | ), |
258 | 263 | method: "PATCH", |
259 | | - headers: mergeHeaders( |
260 | | - this._options?.headers, |
261 | | - mergeOnlyDefinedHeaders({ Authorization: await this._getAuthorizationHeader() }), |
262 | | - requestOptions?.headers, |
263 | | - ), |
| 264 | + headers: _headers, |
264 | 265 | contentType: "application/json", |
265 | | - queryParameters: _queryParams, |
| 266 | + queryParameters: { ..._queryParams, ...requestOptions?.queryParams }, |
266 | 267 | requestType: "json", |
267 | 268 | body: serializers.CollectionItemPatchSingle.jsonOrThrow(_body, { |
268 | 269 | unrecognizedObjectKeys: "passthrough", |
269 | 270 | allowUnrecognizedUnionMembers: true, |
270 | 271 | allowUnrecognizedEnumValues: true, |
271 | 272 | }), |
272 | | - timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, |
273 | | - maxRetries: requestOptions?.maxRetries, |
| 273 | + timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1000, |
| 274 | + maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, |
274 | 275 | abortSignal: requestOptions?.abortSignal, |
275 | 276 | }); |
276 | 277 | if (_response.ok) { |
@@ -428,32 +429,33 @@ export class Client extends Items { |
428 | 429 | const { skipInvalidFiles, ..._body } = request; |
429 | 430 | const _queryParams: Record<string, string | string[] | object | object[] | null> = {}; |
430 | 431 | if (skipInvalidFiles != null) { |
431 | | - _queryParams["skipInvalidFiles"] = skipInvalidFiles.toString(); |
| 432 | + _queryParams.skipInvalidFiles = skipInvalidFiles.toString(); |
432 | 433 | } |
433 | 434 |
|
| 435 | + const _headers: core.Fetcher.Args["headers"] = mergeHeaders( |
| 436 | + this._options?.headers, |
| 437 | + mergeOnlyDefinedHeaders({ Authorization: await this._getAuthorizationHeader() }), |
| 438 | + requestOptions?.headers, |
| 439 | + ); |
434 | 440 | const _response = await core.fetcher({ |
435 | | - url: urlJoin( |
| 441 | + url: core.url.join( |
436 | 442 | (await core.Supplier.get(this._options.baseUrl)) ?? |
437 | 443 | ((await core.Supplier.get(this._options.environment)) ?? environments.WebflowEnvironment.DataApi) |
438 | 444 | .base, |
439 | | - `collections/${encodeURIComponent(collectionId)}/items/live`, |
| 445 | + `collections/${core.url.encodePathParam(collectionId)}/items/live`, |
440 | 446 | ), |
441 | 447 | method: "POST", |
442 | | - headers: mergeHeaders( |
443 | | - this._options?.headers, |
444 | | - mergeOnlyDefinedHeaders({ Authorization: await this._getAuthorizationHeader() }), |
445 | | - requestOptions?.headers, |
446 | | - ), |
| 448 | + headers: _headers, |
447 | 449 | contentType: "application/json", |
448 | | - queryParameters: _queryParams, |
| 450 | + queryParameters: { ..._queryParams, ...requestOptions?.queryParams }, |
449 | 451 | requestType: "json", |
450 | 452 | body: serializers.collections.ItemsCreateItemLiveRequestBody.jsonOrThrow(_body, { |
451 | 453 | unrecognizedObjectKeys: "passthrough", |
452 | 454 | allowUnrecognizedUnionMembers: true, |
453 | 455 | allowUnrecognizedEnumValues: true, |
454 | 456 | }), |
455 | | - timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, |
456 | | - maxRetries: requestOptions?.maxRetries, |
| 457 | + timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1000, |
| 458 | + maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, |
457 | 459 | abortSignal: requestOptions?.abortSignal, |
458 | 460 | }); |
459 | 461 | if (_response.ok) { |
@@ -592,32 +594,33 @@ export class Client extends Items { |
592 | 594 | const { skipInvalidFiles, ..._body } = request; |
593 | 595 | const _queryParams: Record<string, string | string[] | object | object[] | null> = {}; |
594 | 596 | if (skipInvalidFiles != null) { |
595 | | - _queryParams["skipInvalidFiles"] = skipInvalidFiles.toString(); |
| 597 | + _queryParams.skipInvalidFiles = skipInvalidFiles.toString(); |
596 | 598 | } |
597 | 599 |
|
| 600 | + const _headers: core.Fetcher.Args["headers"] = mergeHeaders( |
| 601 | + this._options?.headers, |
| 602 | + mergeOnlyDefinedHeaders({ Authorization: await this._getAuthorizationHeader() }), |
| 603 | + requestOptions?.headers, |
| 604 | + ); |
598 | 605 | const _response = await core.fetcher({ |
599 | | - url: urlJoin( |
| 606 | + url: core.url.join( |
600 | 607 | (await core.Supplier.get(this._options.baseUrl)) ?? |
601 | 608 | ((await core.Supplier.get(this._options.environment)) ?? environments.WebflowEnvironment.DataApi) |
602 | 609 | .base, |
603 | | - `collections/${encodeURIComponent(collectionId)}/items/${encodeURIComponent(itemId)}/live`, |
| 610 | + `collections/${core.url.encodePathParam(collectionId)}/items/${core.url.encodePathParam(itemId)}/live`, |
604 | 611 | ), |
605 | 612 | method: "PATCH", |
606 | | - headers: mergeHeaders( |
607 | | - this._options?.headers, |
608 | | - mergeOnlyDefinedHeaders({ Authorization: await this._getAuthorizationHeader() }), |
609 | | - requestOptions?.headers, |
610 | | - ), |
| 613 | + headers: _headers, |
611 | 614 | contentType: "application/json", |
612 | | - queryParameters: _queryParams, |
| 615 | + queryParameters: { ..._queryParams, ...requestOptions?.queryParams }, |
613 | 616 | requestType: "json", |
614 | 617 | body: serializers.CollectionItemPatchSingle.jsonOrThrow(_body, { |
615 | 618 | unrecognizedObjectKeys: "passthrough", |
616 | 619 | allowUnrecognizedUnionMembers: true, |
617 | 620 | allowUnrecognizedEnumValues: true, |
618 | 621 | }), |
619 | | - timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, |
620 | | - maxRetries: requestOptions?.maxRetries, |
| 622 | + timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1000, |
| 623 | + maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, |
621 | 624 | abortSignal: requestOptions?.abortSignal, |
622 | 625 | }); |
623 | 626 | if (_response.ok) { |
|
0 commit comments