@drttix/drt-sdk 0.6.5 → 0.7.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.
- package/azure-pipelines.yml +15 -6
- package/demo/default.html +2 -1
- package/demo/test.html +529 -102
- package/demo/with-base.html +10 -8
- package/dist/bundle/drt-sdk.js +1 -0
- package/dist/cjs/index.d.ts +5 -0
- package/dist/cjs/index.js +5 -0
- package/dist/cjs/src/generated/portal/core/OpenAPI.js +1 -1
- package/dist/cjs/src/generated/portal/core/request.js +3 -1
- package/dist/cjs/src/generated/portal/services/AccountService.d.ts +12 -2
- package/dist/cjs/src/generated/portal/services/AccountService.js +26 -2
- package/dist/cjs/src/generated/portal/services/AuthService.d.ts +2 -1
- package/dist/cjs/src/generated/portal/services/AuthService.js +5 -1
- package/dist/cjs/src/generated/portal/services/FeaturesBlockedSeatsService.d.ts +10 -7
- package/dist/cjs/src/generated/portal/services/FeaturesBlockedSeatsService.js +19 -7
- package/dist/cjs/src/generated/portal/services/OrderLookupService.d.ts +4 -3
- package/dist/cjs/src/generated/portal/services/OrderLookupService.js +7 -3
- package/dist/cjs/src/generated/scanner/core/request.d.ts +7 -10
- package/dist/cjs/src/generated/scanner/core/request.js +56 -37
- package/dist/cjs/src/generated/shopper/core/request.js +3 -1
- package/dist/cjs/src/scripts/build-all.js +9 -1
- package/dist/esm/index.d.ts +5 -0
- package/dist/esm/index.js +5 -0
- package/dist/esm/src/generated/portal/core/OpenAPI.js +1 -1
- package/dist/esm/src/generated/portal/core/request.js +3 -1
- package/dist/esm/src/generated/portal/services/AccountService.d.ts +12 -2
- package/dist/esm/src/generated/portal/services/AccountService.js +26 -2
- package/dist/esm/src/generated/portal/services/AuthService.d.ts +2 -1
- package/dist/esm/src/generated/portal/services/AuthService.js +5 -1
- package/dist/esm/src/generated/portal/services/FeaturesBlockedSeatsService.d.ts +10 -7
- package/dist/esm/src/generated/portal/services/FeaturesBlockedSeatsService.js +19 -7
- package/dist/esm/src/generated/portal/services/OrderLookupService.d.ts +4 -3
- package/dist/esm/src/generated/portal/services/OrderLookupService.js +7 -3
- package/dist/esm/src/generated/scanner/core/request.d.ts +7 -10
- package/dist/esm/src/generated/scanner/core/request.js +58 -39
- package/dist/esm/src/generated/shopper/core/request.js +3 -1
- package/dist/esm/src/scripts/build-all.js +9 -1
- package/index.ts +5 -0
- package/package.json +3 -1
- package/src/custom/custom-request.txt +7 -2
- package/src/generated/portal/core/OpenAPI.ts +1 -1
- package/src/generated/portal/core/request.ts +7 -2
- package/src/generated/portal/services/AccountService.ts +30 -1
- package/src/generated/portal/services/AuthService.ts +7 -1
- package/src/generated/portal/services/FeaturesBlockedSeatsService.ts +23 -6
- package/src/generated/portal/services/OrderLookupService.ts +7 -2
- package/src/generated/scanner/core/request.ts +331 -266
- package/src/generated/shopper/core/request.ts +7 -2
- package/src/scripts/build-all.ts +14 -1
|
@@ -76,24 +76,28 @@ export class FeaturesBlockedSeatsService {
|
|
|
76
76
|
/**
|
|
77
77
|
* Fetch the selected seats
|
|
78
78
|
* Fetch the selected seats
|
|
79
|
+
* @param xStudioId
|
|
79
80
|
* @returns BlockedSeatDetailResponseDto Selected seats fetched successfully
|
|
80
81
|
* @throws ApiError
|
|
81
82
|
*/
|
|
82
|
-
static getSelectedSeats() {
|
|
83
|
+
static getSelectedSeats(xStudioId) {
|
|
83
84
|
return __request(OpenAPI, {
|
|
84
85
|
method: 'GET',
|
|
85
86
|
url: '/features/blocked-seats/selected-seats',
|
|
87
|
+
headers: {
|
|
88
|
+
'x-studio-id': xStudioId,
|
|
89
|
+
},
|
|
86
90
|
});
|
|
87
91
|
}
|
|
88
92
|
/**
|
|
89
93
|
* Initialize the seat engine for a show
|
|
90
94
|
* Initialize the seat engine for a show
|
|
91
|
-
* @param showId The ID of the show
|
|
92
95
|
* @param xStudioId The ID of the studio
|
|
96
|
+
* @param showId The ID of the show
|
|
93
97
|
* @returns SuccessResponse Show initialized successfully
|
|
94
98
|
* @throws ApiError
|
|
95
99
|
*/
|
|
96
|
-
static initializeSeatEngine(
|
|
100
|
+
static initializeSeatEngine(xStudioId, showId) {
|
|
97
101
|
return __request(OpenAPI, {
|
|
98
102
|
method: 'GET',
|
|
99
103
|
url: '/features/blocked-seats/{showId}/initialize-seat-engine',
|
|
@@ -108,12 +112,12 @@ export class FeaturesBlockedSeatsService {
|
|
|
108
112
|
/**
|
|
109
113
|
* Fetch the seat engine occupancy for a show
|
|
110
114
|
* Fetch the seat engine occupancy for a show
|
|
111
|
-
* @param showId The ID of the show
|
|
112
115
|
* @param xStudioId The ID of the studio
|
|
116
|
+
* @param showId The ID of the show
|
|
113
117
|
* @returns any Show occupancy fetched successfully
|
|
114
118
|
* @throws ApiError
|
|
115
119
|
*/
|
|
116
|
-
static getSeatEngineOccupancy(
|
|
120
|
+
static getSeatEngineOccupancy(xStudioId, showId) {
|
|
117
121
|
return __request(OpenAPI, {
|
|
118
122
|
method: 'GET',
|
|
119
123
|
url: '/features/blocked-seats/{showId}/occupancy',
|
|
@@ -409,24 +413,29 @@ export class FeaturesBlockedSeatsService {
|
|
|
409
413
|
/**
|
|
410
414
|
* Release all seats
|
|
411
415
|
* Release all seats
|
|
416
|
+
* @param xStudioId
|
|
412
417
|
* @returns SuccessResponse Seats released successfully
|
|
413
418
|
* @throws ApiError
|
|
414
419
|
*/
|
|
415
|
-
static releaseAllSeats() {
|
|
420
|
+
static releaseAllSeats(xStudioId) {
|
|
416
421
|
return __request(OpenAPI, {
|
|
417
422
|
method: 'PUT',
|
|
418
423
|
url: '/features/blocked-seats/release-all-seats',
|
|
424
|
+
headers: {
|
|
425
|
+
'x-studio-id': xStudioId,
|
|
426
|
+
},
|
|
419
427
|
});
|
|
420
428
|
}
|
|
421
429
|
/**
|
|
422
430
|
* Toggle the seat in cart ticket
|
|
423
431
|
* Toggle the seat in cart ticket
|
|
432
|
+
* @param xStudioId
|
|
424
433
|
* @param showId The ID of the show
|
|
425
434
|
* @param seatId The ID of the seat
|
|
426
435
|
* @returns CartToggleTickerResponseDto Seat toggled successfully
|
|
427
436
|
* @throws ApiError
|
|
428
437
|
*/
|
|
429
|
-
static toggleSeatInCartTicket(showId, seatId) {
|
|
438
|
+
static toggleSeatInCartTicket(xStudioId, showId, seatId) {
|
|
430
439
|
return __request(OpenAPI, {
|
|
431
440
|
method: 'PUT',
|
|
432
441
|
url: '/features/blocked-seats/{showId}/{seatId}/toggle-cart-ticket',
|
|
@@ -434,6 +443,9 @@ export class FeaturesBlockedSeatsService {
|
|
|
434
443
|
'showId': showId,
|
|
435
444
|
'seatId': seatId,
|
|
436
445
|
},
|
|
446
|
+
headers: {
|
|
447
|
+
'x-studio-id': xStudioId,
|
|
448
|
+
},
|
|
437
449
|
});
|
|
438
450
|
}
|
|
439
451
|
}
|
|
@@ -140,11 +140,12 @@ export declare class OrderLookupService {
|
|
|
140
140
|
/**
|
|
141
141
|
* Change the type of the tier
|
|
142
142
|
* Toggle tier to another available type for the same seats
|
|
143
|
+
* @param xStudioId
|
|
143
144
|
* @param requestBody
|
|
144
145
|
* @returns ToggleTierResponseDto Tier type changed successfully
|
|
145
146
|
* @throws ApiError
|
|
146
147
|
*/
|
|
147
|
-
static toggleTier(requestBody: ToggleTierRequestDto): CancelablePromise<ToggleTierResponseDto>;
|
|
148
|
+
static toggleTier(xStudioId: string, requestBody: ToggleTierRequestDto): CancelablePromise<ToggleTierResponseDto>;
|
|
148
149
|
/**
|
|
149
150
|
* Get details of show and tier
|
|
150
151
|
* Fetch details of the show with tier details
|
|
@@ -240,13 +241,13 @@ export declare class OrderLookupService {
|
|
|
240
241
|
/**
|
|
241
242
|
* Toggle modify tier status for the order
|
|
242
243
|
* To toggle the modify tier status for the order
|
|
243
|
-
* @param orderId The ID of the order
|
|
244
244
|
* @param xStudioId The ID of the studio
|
|
245
|
+
* @param orderId The ID of the order
|
|
245
246
|
* @param requestBody Modify tier status details
|
|
246
247
|
* @returns ToggleModifyTierResponseDto Modify tier status toggled successfully
|
|
247
248
|
* @throws ApiError
|
|
248
249
|
*/
|
|
249
|
-
static toggleModifyTierStatus(
|
|
250
|
+
static toggleModifyTierStatus(xStudioId: string, orderId: string, requestBody: ToggleModifyTierRequestDto): CancelablePromise<ToggleModifyTierResponseDto>;
|
|
250
251
|
/**
|
|
251
252
|
* Add seats to session
|
|
252
253
|
* To add seats to the session for the order
|
|
@@ -242,14 +242,18 @@ export class OrderLookupService {
|
|
|
242
242
|
/**
|
|
243
243
|
* Change the type of the tier
|
|
244
244
|
* Toggle tier to another available type for the same seats
|
|
245
|
+
* @param xStudioId
|
|
245
246
|
* @param requestBody
|
|
246
247
|
* @returns ToggleTierResponseDto Tier type changed successfully
|
|
247
248
|
* @throws ApiError
|
|
248
249
|
*/
|
|
249
|
-
static toggleTier(requestBody) {
|
|
250
|
+
static toggleTier(xStudioId, requestBody) {
|
|
250
251
|
return __request(OpenAPI, {
|
|
251
252
|
method: 'POST',
|
|
252
253
|
url: '/order-lookup/toggle-tier',
|
|
254
|
+
headers: {
|
|
255
|
+
'x-studio-id': xStudioId,
|
|
256
|
+
},
|
|
253
257
|
body: requestBody,
|
|
254
258
|
mediaType: 'application/json',
|
|
255
259
|
});
|
|
@@ -457,13 +461,13 @@ export class OrderLookupService {
|
|
|
457
461
|
/**
|
|
458
462
|
* Toggle modify tier status for the order
|
|
459
463
|
* To toggle the modify tier status for the order
|
|
460
|
-
* @param orderId The ID of the order
|
|
461
464
|
* @param xStudioId The ID of the studio
|
|
465
|
+
* @param orderId The ID of the order
|
|
462
466
|
* @param requestBody Modify tier status details
|
|
463
467
|
* @returns ToggleModifyTierResponseDto Modify tier status toggled successfully
|
|
464
468
|
* @throws ApiError
|
|
465
469
|
*/
|
|
466
|
-
static toggleModifyTierStatus(
|
|
470
|
+
static toggleModifyTierStatus(xStudioId, orderId, requestBody) {
|
|
467
471
|
return __request(OpenAPI, {
|
|
468
472
|
method: 'PUT',
|
|
469
473
|
url: '/order-lookup/{orderId}/toggle-modify-tier',
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import type { ApiRequestOptions } from
|
|
2
|
-
import type { ApiResult } from
|
|
3
|
-
import { CancelablePromise } from
|
|
4
|
-
import type { OnCancel } from
|
|
5
|
-
import type { OpenAPIConfig } from
|
|
1
|
+
import type { ApiRequestOptions } from "./ApiRequestOptions";
|
|
2
|
+
import type { ApiResult } from "./ApiResult";
|
|
3
|
+
import { CancelablePromise } from "./CancelablePromise";
|
|
4
|
+
import type { OnCancel } from "./CancelablePromise";
|
|
5
|
+
import type { OpenAPIConfig } from "./OpenAPI";
|
|
6
6
|
export declare const isDefined: <T>(value: T | null | undefined) => value is Exclude<T, null | undefined>;
|
|
7
7
|
export declare const isString: (value: any) => value is string;
|
|
8
8
|
export declare const isStringWithValue: (value: any) => value is string;
|
|
@@ -20,11 +20,8 @@ export declare const getResponseHeader: (response: Response, responseHeader?: st
|
|
|
20
20
|
export declare const getResponseBody: (response: Response) => Promise<any>;
|
|
21
21
|
export declare const catchErrorCodes: (options: ApiRequestOptions, result: ApiResult) => void;
|
|
22
22
|
/**
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
-
* @param options The request options from the service
|
|
26
|
-
* @returns CancelablePromise<T>
|
|
27
|
-
* @throws ApiError
|
|
23
|
+
* Wraps sendRequest to capture cookies on login
|
|
24
|
+
* and attach cookies on other requests
|
|
28
25
|
*/
|
|
29
26
|
export declare const request: <T>(config: OpenAPIConfig, options: ApiRequestOptions) => CancelablePromise<T>;
|
|
30
27
|
export {};
|
|
@@ -2,24 +2,24 @@
|
|
|
2
2
|
/* istanbul ignore file */
|
|
3
3
|
/* tslint:disable */
|
|
4
4
|
/* eslint-disable */
|
|
5
|
-
import { ApiError } from
|
|
6
|
-
import { CancelablePromise } from
|
|
5
|
+
import { ApiError } from "./ApiError.js";
|
|
6
|
+
import { CancelablePromise } from "./CancelablePromise.js";
|
|
7
7
|
export const isDefined = (value) => {
|
|
8
8
|
return value !== undefined && value !== null;
|
|
9
9
|
};
|
|
10
10
|
export const isString = (value) => {
|
|
11
|
-
return typeof value ===
|
|
11
|
+
return typeof value === "string";
|
|
12
12
|
};
|
|
13
13
|
export const isStringWithValue = (value) => {
|
|
14
|
-
return isString(value) && value !==
|
|
14
|
+
return isString(value) && value !== "";
|
|
15
15
|
};
|
|
16
16
|
export const isBlob = (value) => {
|
|
17
|
-
return (typeof value ===
|
|
18
|
-
typeof value.type ===
|
|
19
|
-
typeof value.stream ===
|
|
20
|
-
typeof value.arrayBuffer ===
|
|
21
|
-
typeof value.constructor ===
|
|
22
|
-
typeof value.constructor.name ===
|
|
17
|
+
return (typeof value === "object" &&
|
|
18
|
+
typeof value.type === "string" &&
|
|
19
|
+
typeof value.stream === "function" &&
|
|
20
|
+
typeof value.arrayBuffer === "function" &&
|
|
21
|
+
typeof value.constructor === "function" &&
|
|
22
|
+
typeof value.constructor.name === "string" &&
|
|
23
23
|
/^(Blob|File)$/.test(value.constructor.name) &&
|
|
24
24
|
/^(Blob|File)$/.test(value[Symbol.toStringTag]));
|
|
25
25
|
};
|
|
@@ -32,7 +32,7 @@ export const base64 = (str) => {
|
|
|
32
32
|
}
|
|
33
33
|
catch (err) {
|
|
34
34
|
// @ts-ignore
|
|
35
|
-
return Buffer.from(str).toString(
|
|
35
|
+
return Buffer.from(str).toString("base64");
|
|
36
36
|
}
|
|
37
37
|
};
|
|
38
38
|
export const getQueryString = (params) => {
|
|
@@ -43,11 +43,11 @@ export const getQueryString = (params) => {
|
|
|
43
43
|
const process = (key, value) => {
|
|
44
44
|
if (isDefined(value)) {
|
|
45
45
|
if (Array.isArray(value)) {
|
|
46
|
-
value.forEach(v => {
|
|
46
|
+
value.forEach((v) => {
|
|
47
47
|
process(key, v);
|
|
48
48
|
});
|
|
49
49
|
}
|
|
50
|
-
else if (typeof value ===
|
|
50
|
+
else if (typeof value === "object") {
|
|
51
51
|
Object.entries(value).forEach(([k, v]) => {
|
|
52
52
|
process(`${key}[${k}]`, v);
|
|
53
53
|
});
|
|
@@ -61,14 +61,14 @@ export const getQueryString = (params) => {
|
|
|
61
61
|
process(key, value);
|
|
62
62
|
});
|
|
63
63
|
if (qs.length > 0) {
|
|
64
|
-
return `?${qs.join(
|
|
64
|
+
return `?${qs.join("&")}`;
|
|
65
65
|
}
|
|
66
|
-
return
|
|
66
|
+
return "";
|
|
67
67
|
};
|
|
68
68
|
const getUrl = (config, options) => {
|
|
69
69
|
const encoder = config.ENCODE_PATH || encodeURI;
|
|
70
70
|
const path = options.url
|
|
71
|
-
.replace(
|
|
71
|
+
.replace("{api-version}", config.VERSION)
|
|
72
72
|
.replace(/{(.*?)}/g, (substring, group) => {
|
|
73
73
|
var _a;
|
|
74
74
|
if ((_a = options.path) === null || _a === void 0 ? void 0 : _a.hasOwnProperty(group)) {
|
|
@@ -97,7 +97,7 @@ export const getFormData = (options) => {
|
|
|
97
97
|
.filter(([_, value]) => isDefined(value))
|
|
98
98
|
.forEach(([key, value]) => {
|
|
99
99
|
if (Array.isArray(value)) {
|
|
100
|
-
value.forEach(v => process(key, v));
|
|
100
|
+
value.forEach((v) => process(key, v));
|
|
101
101
|
}
|
|
102
102
|
else {
|
|
103
103
|
process(key, value);
|
|
@@ -108,7 +108,7 @@ export const getFormData = (options) => {
|
|
|
108
108
|
return undefined;
|
|
109
109
|
};
|
|
110
110
|
export const resolve = async (options, resolver) => {
|
|
111
|
-
if (typeof resolver ===
|
|
111
|
+
if (typeof resolver === "function") {
|
|
112
112
|
return resolver(options);
|
|
113
113
|
}
|
|
114
114
|
return resolver;
|
|
@@ -120,28 +120,30 @@ export const getHeaders = async (config, options) => {
|
|
|
120
120
|
resolve(options, config.PASSWORD),
|
|
121
121
|
resolve(options, config.HEADERS),
|
|
122
122
|
]);
|
|
123
|
-
|
|
123
|
+
// Filter out undefined/null values from options.headers first
|
|
124
|
+
const optionsHeaders = Object.fromEntries(Object.entries(options.headers || {}).filter(([_, value]) => isDefined(value)));
|
|
125
|
+
const headers = Object.entries(Object.assign(Object.assign({ Accept: "application/json" }, optionsHeaders), additionalHeaders))
|
|
124
126
|
.filter(([_, value]) => isDefined(value))
|
|
125
127
|
.reduce((headers, [key, value]) => (Object.assign(Object.assign({}, headers), { [key]: String(value) })), {});
|
|
126
128
|
if (isStringWithValue(token)) {
|
|
127
|
-
headers[
|
|
129
|
+
headers["Authorization"] = `Bearer ${token}`;
|
|
128
130
|
}
|
|
129
131
|
if (isStringWithValue(username) && isStringWithValue(password)) {
|
|
130
132
|
const credentials = base64(`${username}:${password}`);
|
|
131
|
-
headers[
|
|
133
|
+
headers["Authorization"] = `Basic ${credentials}`;
|
|
132
134
|
}
|
|
133
135
|
if (options.body !== undefined) {
|
|
134
136
|
if (options.mediaType) {
|
|
135
|
-
headers[
|
|
137
|
+
headers["Content-Type"] = options.mediaType;
|
|
136
138
|
}
|
|
137
139
|
else if (isBlob(options.body)) {
|
|
138
|
-
headers[
|
|
140
|
+
headers["Content-Type"] = options.body.type || "application/octet-stream";
|
|
139
141
|
}
|
|
140
142
|
else if (isString(options.body)) {
|
|
141
|
-
headers[
|
|
143
|
+
headers["Content-Type"] = "text/plain";
|
|
142
144
|
}
|
|
143
145
|
else if (!isFormData(options.body)) {
|
|
144
|
-
headers[
|
|
146
|
+
headers["Content-Type"] = "application/json";
|
|
145
147
|
}
|
|
146
148
|
}
|
|
147
149
|
return new Headers(headers);
|
|
@@ -149,10 +151,12 @@ export const getHeaders = async (config, options) => {
|
|
|
149
151
|
export const getRequestBody = (options) => {
|
|
150
152
|
var _a;
|
|
151
153
|
if (options.body !== undefined) {
|
|
152
|
-
if ((_a = options.mediaType) === null || _a === void 0 ? void 0 : _a.includes(
|
|
154
|
+
if ((_a = options.mediaType) === null || _a === void 0 ? void 0 : _a.includes("/json")) {
|
|
153
155
|
return JSON.stringify(options.body);
|
|
154
156
|
}
|
|
155
|
-
else if (isString(options.body) ||
|
|
157
|
+
else if (isString(options.body) ||
|
|
158
|
+
isBlob(options.body) ||
|
|
159
|
+
isFormData(options.body)) {
|
|
156
160
|
return options.body;
|
|
157
161
|
}
|
|
158
162
|
else {
|
|
@@ -187,10 +191,10 @@ export const getResponseHeader = (response, responseHeader) => {
|
|
|
187
191
|
export const getResponseBody = async (response) => {
|
|
188
192
|
if (response.status !== 204) {
|
|
189
193
|
try {
|
|
190
|
-
const contentType = response.headers.get(
|
|
194
|
+
const contentType = response.headers.get("Content-Type");
|
|
191
195
|
if (contentType) {
|
|
192
|
-
const jsonTypes = [
|
|
193
|
-
const isJSON = jsonTypes.some(type => contentType.toLowerCase().startsWith(type));
|
|
196
|
+
const jsonTypes = ["application/json", "application/problem+json"];
|
|
197
|
+
const isJSON = jsonTypes.some((type) => contentType.toLowerCase().startsWith(type));
|
|
194
198
|
if (isJSON) {
|
|
195
199
|
return await response.json();
|
|
196
200
|
}
|
|
@@ -207,14 +211,14 @@ export const getResponseBody = async (response) => {
|
|
|
207
211
|
};
|
|
208
212
|
export const catchErrorCodes = (options, result) => {
|
|
209
213
|
var _a, _b;
|
|
210
|
-
const errors = Object.assign({ 400:
|
|
214
|
+
const errors = Object.assign({ 400: "Bad Request", 401: "Unauthorized", 403: "Forbidden", 404: "Not Found", 500: "Internal Server Error", 502: "Bad Gateway", 503: "Service Unavailable" }, options.errors);
|
|
211
215
|
const error = errors[result.status];
|
|
212
216
|
if (error) {
|
|
213
217
|
throw new ApiError(options, result, error);
|
|
214
218
|
}
|
|
215
219
|
if (!result.ok) {
|
|
216
|
-
const errorStatus = (_a = result.status) !== null && _a !== void 0 ? _a :
|
|
217
|
-
const errorStatusText = (_b = result.statusText) !== null && _b !== void 0 ? _b :
|
|
220
|
+
const errorStatus = (_a = result.status) !== null && _a !== void 0 ? _a : "unknown";
|
|
221
|
+
const errorStatusText = (_b = result.statusText) !== null && _b !== void 0 ? _b : "unknown";
|
|
218
222
|
const errorBody = (() => {
|
|
219
223
|
try {
|
|
220
224
|
return JSON.stringify(result.body, null, 2);
|
|
@@ -226,12 +230,10 @@ export const catchErrorCodes = (options, result) => {
|
|
|
226
230
|
throw new ApiError(options, result, `Generic Error: status: ${errorStatus}; status text: ${errorStatusText}; body: ${errorBody}`);
|
|
227
231
|
}
|
|
228
232
|
};
|
|
233
|
+
let globalCookieHeader;
|
|
229
234
|
/**
|
|
230
|
-
*
|
|
231
|
-
*
|
|
232
|
-
* @param options The request options from the service
|
|
233
|
-
* @returns CancelablePromise<T>
|
|
234
|
-
* @throws ApiError
|
|
235
|
+
* Wraps sendRequest to capture cookies on login
|
|
236
|
+
* and attach cookies on other requests
|
|
235
237
|
*/
|
|
236
238
|
export const request = (config, options) => {
|
|
237
239
|
return new CancelablePromise(async (resolve, reject, onCancel) => {
|
|
@@ -239,9 +241,26 @@ export const request = (config, options) => {
|
|
|
239
241
|
const url = getUrl(config, options);
|
|
240
242
|
const formData = getFormData(options);
|
|
241
243
|
const body = getRequestBody(options);
|
|
242
|
-
|
|
244
|
+
// Before making headers, possibly attach cookie if we have it
|
|
245
|
+
const baseHeaders = await getHeaders(config, options);
|
|
246
|
+
// We will build combined headers
|
|
247
|
+
const headerObj = {};
|
|
248
|
+
baseHeaders.forEach((value, key) => {
|
|
249
|
+
headerObj[key] = value;
|
|
250
|
+
});
|
|
251
|
+
if (globalCookieHeader) {
|
|
252
|
+
// Attach stored cookie
|
|
253
|
+
headerObj["Cookie"] = globalCookieHeader;
|
|
254
|
+
}
|
|
255
|
+
const headers = new Headers(headerObj);
|
|
243
256
|
if (!onCancel.isCancelled) {
|
|
244
257
|
const response = await sendRequest(config, options, url, body, formData, headers, onCancel);
|
|
258
|
+
// Capture Set-Cookie if present
|
|
259
|
+
const setCookie = response.headers.get("set-cookie");
|
|
260
|
+
if (setCookie) {
|
|
261
|
+
// Overwrite or append as needed
|
|
262
|
+
globalCookieHeader = setCookie;
|
|
263
|
+
}
|
|
245
264
|
const responseBody = await getResponseBody(response);
|
|
246
265
|
const responseHeader = getResponseHeader(response, options.responseHeader);
|
|
247
266
|
const result = {
|
|
@@ -120,7 +120,9 @@ export const getHeaders = async (config, options) => {
|
|
|
120
120
|
resolve(options, config.PASSWORD),
|
|
121
121
|
resolve(options, config.HEADERS),
|
|
122
122
|
]);
|
|
123
|
-
|
|
123
|
+
// Filter out undefined/null values from options.headers first
|
|
124
|
+
const optionsHeaders = Object.fromEntries(Object.entries(options.headers || {}).filter(([_, value]) => isDefined(value)));
|
|
125
|
+
const headers = Object.entries(Object.assign(Object.assign({ Accept: "application/json" }, optionsHeaders), additionalHeaders))
|
|
124
126
|
.filter(([_, value]) => isDefined(value))
|
|
125
127
|
.reduce((headers, [key, value]) => (Object.assign(Object.assign({}, headers), { [key]: String(value) })), {});
|
|
126
128
|
if (isStringWithValue(token)) {
|
|
@@ -46,15 +46,18 @@ for (const spec of specs) {
|
|
|
46
46
|
shell: true,
|
|
47
47
|
});
|
|
48
48
|
}
|
|
49
|
-
// After generating all clients and definitions, replace request.ts for
|
|
49
|
+
// After generating all clients and definitions, replace request.ts for all services
|
|
50
50
|
const customRequestPath = path.resolve('src/custom/custom-request.txt');
|
|
51
51
|
const shopperRequestPath = path.resolve('src/generated/shopper/core/request.ts');
|
|
52
52
|
const portalRequestPath = path.resolve('src/generated/portal/core/request.ts');
|
|
53
|
+
const scannerRequestPath = path.resolve('src/generated/scanner/core/request.ts');
|
|
53
54
|
const customRequestContent = fs.readFileSync(customRequestPath, 'utf-8');
|
|
54
55
|
fs.writeFileSync(shopperRequestPath, customRequestContent);
|
|
55
56
|
console.log('✅ Replaced shopper/core/request.ts with custom-request.txt');
|
|
56
57
|
fs.writeFileSync(portalRequestPath, customRequestContent);
|
|
57
58
|
console.log('✅ Replaced portal/core/request.ts with custom-request.txt');
|
|
59
|
+
fs.writeFileSync(scannerRequestPath, customRequestContent);
|
|
60
|
+
console.log('✅ Replaced scanner/core/request.ts with custom-request.txt');
|
|
58
61
|
// --- Generate index.ts
|
|
59
62
|
console.log(`🧩 Generating DRT index...`);
|
|
60
63
|
const lines = [];
|
|
@@ -65,6 +68,7 @@ for (const spec of specs) {
|
|
|
65
68
|
lines.push(`import { ${name} } from "./src/definitions/${name}.js";`);
|
|
66
69
|
}
|
|
67
70
|
lines.push(`import { setBaseUrlsOnce } from "./src/functions/setBaseURL.js";`);
|
|
71
|
+
lines.push(`import { init, isReady, getConfig, reset } from "./src/functions/sdkConfig.js";`);
|
|
68
72
|
lines.push('');
|
|
69
73
|
// Re-export type namespaces for easy access
|
|
70
74
|
for (const spec of specs) {
|
|
@@ -77,6 +81,10 @@ lines.push('export const DRT = {');
|
|
|
77
81
|
for (const spec of specs) {
|
|
78
82
|
lines.push(` ${spec.name.toLowerCase()},`);
|
|
79
83
|
}
|
|
84
|
+
lines.push(' init,');
|
|
85
|
+
lines.push(' isReady,');
|
|
86
|
+
lines.push(' getConfig,');
|
|
87
|
+
lines.push(' reset,');
|
|
80
88
|
lines.push('};');
|
|
81
89
|
lines.push('');
|
|
82
90
|
lines.push('setBaseUrlsOnce();');
|
package/index.ts
CHANGED
|
@@ -4,6 +4,7 @@ import { shopper } from "./src/definitions/shopper";
|
|
|
4
4
|
import { scanner } from "./src/definitions/scanner";
|
|
5
5
|
import { portal } from "./src/definitions/portal";
|
|
6
6
|
import { setBaseUrlsOnce } from "./src/functions/setBaseURL";
|
|
7
|
+
import { init, isReady, getConfig, reset } from "./src/functions/sdkConfig";
|
|
7
8
|
|
|
8
9
|
export { ShopperTypes } from "./src/definitions/shopper";
|
|
9
10
|
export { ScannerTypes } from "./src/definitions/scanner";
|
|
@@ -13,6 +14,10 @@ export const DRT = {
|
|
|
13
14
|
shopper,
|
|
14
15
|
scanner,
|
|
15
16
|
portal,
|
|
17
|
+
init,
|
|
18
|
+
isReady,
|
|
19
|
+
getConfig,
|
|
20
|
+
reset,
|
|
16
21
|
};
|
|
17
22
|
|
|
18
23
|
setBaseUrlsOnce();
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@drttix/drt-sdk",
|
|
3
3
|
"description": "DRT SDK",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.7.0",
|
|
5
5
|
"main": "dist/cjs/index.js",
|
|
6
6
|
"module": "dist/esm/index.js",
|
|
7
7
|
"types": "dist/esm/index.d.ts",
|
|
@@ -17,11 +17,13 @@
|
|
|
17
17
|
},
|
|
18
18
|
"scripts": {
|
|
19
19
|
"build": "npx tsc --project tsconfig.esm.json && npx tsc --project tsconfig.cjs.json && node scripts/fix-import-extensions.mjs",
|
|
20
|
+
"build:bundle": "npm run build && npx esbuild dist/esm/index.js --bundle --format=esm --outfile=dist/bundle/drt-sdk.js --minify",
|
|
20
21
|
"generate": "npx tsx src/scripts/build-all.ts",
|
|
21
22
|
"prepublishOnly": "npx tsx src/scripts/check-version-not-published.ts && npm run build"
|
|
22
23
|
},
|
|
23
24
|
"devDependencies": {
|
|
24
25
|
"@types/node": "^24.0.4",
|
|
26
|
+
"esbuild": "^0.20.0",
|
|
25
27
|
"typescript": "^5.8.3"
|
|
26
28
|
},
|
|
27
29
|
"dependencies": {
|
|
@@ -154,10 +154,15 @@ export const getHeaders = async (
|
|
|
154
154
|
resolve(options, config.HEADERS),
|
|
155
155
|
]);
|
|
156
156
|
|
|
157
|
+
// Filter out undefined/null values from options.headers first
|
|
158
|
+
const optionsHeaders = Object.fromEntries(
|
|
159
|
+
Object.entries(options.headers || {}).filter(([_, value]) => isDefined(value))
|
|
160
|
+
);
|
|
161
|
+
|
|
157
162
|
const headers = Object.entries({
|
|
158
163
|
Accept: "application/json",
|
|
159
|
-
...
|
|
160
|
-
...
|
|
164
|
+
...optionsHeaders,
|
|
165
|
+
...additionalHeaders, // config.HEADERS takes precedence when set (for DRT.init())
|
|
161
166
|
})
|
|
162
167
|
.filter(([_, value]) => isDefined(value))
|
|
163
168
|
.reduce(
|
|
@@ -154,10 +154,15 @@ export const getHeaders = async (
|
|
|
154
154
|
resolve(options, config.HEADERS),
|
|
155
155
|
]);
|
|
156
156
|
|
|
157
|
+
// Filter out undefined/null values from options.headers first
|
|
158
|
+
const optionsHeaders = Object.fromEntries(
|
|
159
|
+
Object.entries(options.headers || {}).filter(([_, value]) => isDefined(value))
|
|
160
|
+
);
|
|
161
|
+
|
|
157
162
|
const headers = Object.entries({
|
|
158
163
|
Accept: "application/json",
|
|
159
|
-
...
|
|
160
|
-
...
|
|
164
|
+
...optionsHeaders,
|
|
165
|
+
...additionalHeaders, // config.HEADERS takes precedence when set (for DRT.init())
|
|
161
166
|
})
|
|
162
167
|
.filter(([_, value]) => isDefined(value))
|
|
163
168
|
.reduce(
|
|
@@ -14,13 +14,19 @@ export class AccountService {
|
|
|
14
14
|
/**
|
|
15
15
|
* Fetch the portal object details
|
|
16
16
|
* To fetch the portal object details
|
|
17
|
+
* @param xStudioId
|
|
17
18
|
* @returns MappedPortalObjectPermission Account created successfully
|
|
18
19
|
* @throws ApiError
|
|
19
20
|
*/
|
|
20
|
-
public static getPortalObject(
|
|
21
|
+
public static getPortalObject(
|
|
22
|
+
xStudioId: string,
|
|
23
|
+
): CancelablePromise<Array<MappedPortalObjectPermission>> {
|
|
21
24
|
return __request(OpenAPI, {
|
|
22
25
|
method: 'GET',
|
|
23
26
|
url: '/account/permission',
|
|
27
|
+
headers: {
|
|
28
|
+
'x-studio-id': xStudioId,
|
|
29
|
+
},
|
|
24
30
|
});
|
|
25
31
|
}
|
|
26
32
|
/**
|
|
@@ -48,12 +54,14 @@ export class AccountService {
|
|
|
48
54
|
/**
|
|
49
55
|
* Permissions to be updated
|
|
50
56
|
* To update the permissions of the user
|
|
57
|
+
* @param xStudioId
|
|
51
58
|
* @param id The ID of the user
|
|
52
59
|
* @param requestBody Permissions to be updated
|
|
53
60
|
* @returns SuccessResponse Permission updated successfully
|
|
54
61
|
* @throws ApiError
|
|
55
62
|
*/
|
|
56
63
|
public static updatePermission(
|
|
64
|
+
xStudioId: string,
|
|
57
65
|
id: string,
|
|
58
66
|
requestBody: Array<PortalObjectRequestDto>,
|
|
59
67
|
): CancelablePromise<SuccessResponse> {
|
|
@@ -63,6 +71,9 @@ export class AccountService {
|
|
|
63
71
|
path: {
|
|
64
72
|
'id': id,
|
|
65
73
|
},
|
|
74
|
+
headers: {
|
|
75
|
+
'x-studio-id': xStudioId,
|
|
76
|
+
},
|
|
66
77
|
body: requestBody,
|
|
67
78
|
mediaType: 'application/json',
|
|
68
79
|
});
|
|
@@ -108,4 +119,22 @@ export class AccountService {
|
|
|
108
119
|
},
|
|
109
120
|
});
|
|
110
121
|
}
|
|
122
|
+
/**
|
|
123
|
+
* Clear user permissions cache
|
|
124
|
+
* To clear the cached permissions for a specific studio login
|
|
125
|
+
* @param studioLoginId The studio login ID to clear cache for
|
|
126
|
+
* @returns SuccessResponse Cache cleared successfully
|
|
127
|
+
* @throws ApiError
|
|
128
|
+
*/
|
|
129
|
+
public static clearPermissionsCache(
|
|
130
|
+
studioLoginId: string,
|
|
131
|
+
): CancelablePromise<SuccessResponse> {
|
|
132
|
+
return __request(OpenAPI, {
|
|
133
|
+
method: 'POST',
|
|
134
|
+
url: '/account/cache',
|
|
135
|
+
query: {
|
|
136
|
+
'studio_login_id': studioLoginId,
|
|
137
|
+
},
|
|
138
|
+
});
|
|
139
|
+
}
|
|
111
140
|
}
|
|
@@ -82,13 +82,19 @@ export class AuthService {
|
|
|
82
82
|
/**
|
|
83
83
|
* Logging out the user
|
|
84
84
|
* Logging out the user
|
|
85
|
+
* @param xStudioId
|
|
85
86
|
* @returns SuccessResponse Logout successful
|
|
86
87
|
* @throws ApiError
|
|
87
88
|
*/
|
|
88
|
-
public static logout(
|
|
89
|
+
public static logout(
|
|
90
|
+
xStudioId: string,
|
|
91
|
+
): CancelablePromise<SuccessResponse> {
|
|
89
92
|
return __request(OpenAPI, {
|
|
90
93
|
method: 'POST',
|
|
91
94
|
url: '/auth/logout',
|
|
95
|
+
headers: {
|
|
96
|
+
'x-studio-id': xStudioId,
|
|
97
|
+
},
|
|
92
98
|
});
|
|
93
99
|
}
|
|
94
100
|
/**
|