@compassdigital/sdk.typescript 4.119.0 → 4.120.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/lib/base.d.ts.map +1 -1
- package/lib/base.js +4 -1
- package/lib/base.js.map +1 -1
- package/lib/index.d.ts +19 -2
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +19 -0
- package/lib/index.js.map +1 -1
- package/lib/interface/auth.d.ts +8 -0
- package/lib/interface/auth.d.ts.map +1 -1
- package/lib/interface/menu.d.ts +26 -0
- package/lib/interface/menu.d.ts.map +1 -1
- package/package.json +2 -2
- package/src/base.ts +3 -1
- package/src/index.ts +48 -0
- package/src/interface/auth.ts +14 -0
- package/src/interface/menu.ts +34 -0
- package/test/client.test.ts +14 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@compassdigital/sdk.typescript",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.120.0",
|
|
4
4
|
"description": "Compass Digital Labs TypeScript SDK",
|
|
5
5
|
"type": "commonjs",
|
|
6
6
|
"main": "./lib/index.js",
|
|
@@ -49,7 +49,7 @@
|
|
|
49
49
|
},
|
|
50
50
|
"devDependencies": {
|
|
51
51
|
"@compassdigital/review": "^7.3.0",
|
|
52
|
-
"@compassdigital/sdk.typescript.cli": "^4.
|
|
52
|
+
"@compassdigital/sdk.typescript.cli": "^4.41.0",
|
|
53
53
|
"@swc/core": "^1.4.1",
|
|
54
54
|
"@swc/jest": "^0.2.36",
|
|
55
55
|
"@types/jest": "^29.2.4",
|
package/src/base.ts
CHANGED
|
@@ -490,9 +490,11 @@ export abstract class BaseServiceClient {
|
|
|
490
490
|
if (url.startsWith('https://')) options.agent ??= this.agent();
|
|
491
491
|
const headers: Record<string, string> = {
|
|
492
492
|
'User-Agent': 'CDL/ServiceClient',
|
|
493
|
-
'Content-Type': 'application/json',
|
|
494
493
|
...options.headers,
|
|
495
494
|
};
|
|
495
|
+
if (body) {
|
|
496
|
+
headers['Content-Type'] = 'application/json';
|
|
497
|
+
}
|
|
496
498
|
if (options.internal) {
|
|
497
499
|
headers['X-Request-Type'] = 'internal';
|
|
498
500
|
}
|
package/src/index.ts
CHANGED
|
@@ -948,6 +948,8 @@ import {
|
|
|
948
948
|
PostMenuV4ItemDuplicateResponse,
|
|
949
949
|
DeleteMenuV4ItemModifierGroupsDetachBody,
|
|
950
950
|
DeleteMenuV4ItemModifierGroupsDetachResponse,
|
|
951
|
+
PostMenuV4ItemAttachModifierGroupsBody,
|
|
952
|
+
PostMenuV4ItemAttachModifierGroupsResponse,
|
|
951
953
|
PostMenuV4ModifierBody,
|
|
952
954
|
PostMenuV4ModifierResponse,
|
|
953
955
|
GetMenuV4ModifierQuery,
|
|
@@ -1187,6 +1189,8 @@ import {
|
|
|
1187
1189
|
import {
|
|
1188
1190
|
PostAuthFlowBody,
|
|
1189
1191
|
PostAuthFlowResponse,
|
|
1192
|
+
GetAuthSsoConfigQuery,
|
|
1193
|
+
GetAuthSsoConfigResponse,
|
|
1190
1194
|
GetAuthSsoConfigsQuery,
|
|
1191
1195
|
GetAuthSsoConfigsResponse,
|
|
1192
1196
|
PostAuthSsoConfigBody,
|
|
@@ -10291,6 +10295,28 @@ export class ServiceClient extends BaseServiceClient {
|
|
|
10291
10295
|
);
|
|
10292
10296
|
}
|
|
10293
10297
|
|
|
10298
|
+
/**
|
|
10299
|
+
* POST /menu/v4/item/{id}/attach-modifier-groups
|
|
10300
|
+
*
|
|
10301
|
+
* @param id
|
|
10302
|
+
* @param body
|
|
10303
|
+
* @param options - additional request options
|
|
10304
|
+
*/
|
|
10305
|
+
post_menu_v4_item_attach_modifier_groups(
|
|
10306
|
+
id: string,
|
|
10307
|
+
body: PostMenuV4ItemAttachModifierGroupsBody,
|
|
10308
|
+
options?: RequestOptions,
|
|
10309
|
+
): ResponsePromise<PostMenuV4ItemAttachModifierGroupsResponse> {
|
|
10310
|
+
return this.request(
|
|
10311
|
+
'menu',
|
|
10312
|
+
'/menu/v4/item/{id}/attach-modifier-groups',
|
|
10313
|
+
'post',
|
|
10314
|
+
`/menu/v4/item/${id}/attach-modifier-groups`,
|
|
10315
|
+
body,
|
|
10316
|
+
options,
|
|
10317
|
+
);
|
|
10318
|
+
}
|
|
10319
|
+
|
|
10294
10320
|
/**
|
|
10295
10321
|
* POST /menu/v4/modifier
|
|
10296
10322
|
*
|
|
@@ -12449,6 +12475,28 @@ export class ServiceClient extends BaseServiceClient {
|
|
|
12449
12475
|
return this.request('auth', '/auth/flow', 'post', `/auth/flow`, body, options);
|
|
12450
12476
|
}
|
|
12451
12477
|
|
|
12478
|
+
/**
|
|
12479
|
+
* GET /auth/sso-config/{name} - Return sso client-id based on lookup values
|
|
12480
|
+
*
|
|
12481
|
+
* @param name
|
|
12482
|
+
* @param options - additional request options
|
|
12483
|
+
*/
|
|
12484
|
+
get_auth_sso_config(
|
|
12485
|
+
name: string,
|
|
12486
|
+
options: {
|
|
12487
|
+
query: GetAuthSsoConfigQuery;
|
|
12488
|
+
} & RequestOptions,
|
|
12489
|
+
): ResponsePromise<GetAuthSsoConfigResponse> {
|
|
12490
|
+
return this.request(
|
|
12491
|
+
'auth',
|
|
12492
|
+
'/auth/sso-config/{name}',
|
|
12493
|
+
'get',
|
|
12494
|
+
`/auth/sso-config/${name}`,
|
|
12495
|
+
null,
|
|
12496
|
+
options,
|
|
12497
|
+
);
|
|
12498
|
+
}
|
|
12499
|
+
|
|
12452
12500
|
/**
|
|
12453
12501
|
* GET /auth/sso-configs - Returns all available SSO configurations
|
|
12454
12502
|
*
|
package/src/interface/auth.ts
CHANGED
|
@@ -126,6 +126,20 @@ export type PostAuthFlowBody = SSOFlowRequestDTO;
|
|
|
126
126
|
|
|
127
127
|
export type PostAuthFlowResponse = SSOFlowResponseDTO;
|
|
128
128
|
|
|
129
|
+
// GET /auth/sso-config/{name} - Return sso client-id based on lookup values
|
|
130
|
+
|
|
131
|
+
export interface GetAuthSsoConfigPath {
|
|
132
|
+
name: string;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
export interface GetAuthSsoConfigQuery {
|
|
136
|
+
realm: string;
|
|
137
|
+
// Graphql query string
|
|
138
|
+
_query?: string;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
export type GetAuthSsoConfigResponse = string;
|
|
142
|
+
|
|
129
143
|
// GET /auth/sso-configs - Returns all available SSO configurations
|
|
130
144
|
|
|
131
145
|
export interface GetAuthSsoConfigsQuery {
|
package/src/interface/menu.ts
CHANGED
|
@@ -8628,6 +8628,40 @@ export interface DeleteMenuV4ItemModifierGroupsDetachRequest
|
|
|
8628
8628
|
body: DeleteMenuV4ItemModifierGroupsDetachBody;
|
|
8629
8629
|
}
|
|
8630
8630
|
|
|
8631
|
+
// POST /menu/v4/item/{id}/attach-modifier-groups
|
|
8632
|
+
|
|
8633
|
+
export interface PostMenuV4ItemAttachModifierGroupsPath {
|
|
8634
|
+
id: string;
|
|
8635
|
+
}
|
|
8636
|
+
|
|
8637
|
+
export type PostMenuV4ItemAttachModifierGroupsBody = {
|
|
8638
|
+
parent?: DraftItemToModifierGroupRelationshipDTO;
|
|
8639
|
+
children?: DraftItemToModifierGroupRelationshipDTO[];
|
|
8640
|
+
parent_id?: string;
|
|
8641
|
+
modifier_group_id: string;
|
|
8642
|
+
item_id: string;
|
|
8643
|
+
brand_id: string;
|
|
8644
|
+
sequence?: number;
|
|
8645
|
+
applied_diff_snapshot?: Record<string, any>;
|
|
8646
|
+
item?: DraftItemDTO;
|
|
8647
|
+
modifier_group?: DraftModifierGroupDTO;
|
|
8648
|
+
brand?: DraftBrandDTO;
|
|
8649
|
+
changes?: ItemToModifierGroupRelationshipChangeDTO[];
|
|
8650
|
+
vendor_metadata?: VendorMetadataDTO[];
|
|
8651
|
+
permissions?: Record<string, any>;
|
|
8652
|
+
[index: string]: any;
|
|
8653
|
+
}[];
|
|
8654
|
+
|
|
8655
|
+
export interface PostMenuV4ItemAttachModifierGroupsResponse {
|
|
8656
|
+
status?: string;
|
|
8657
|
+
}
|
|
8658
|
+
|
|
8659
|
+
export interface PostMenuV4ItemAttachModifierGroupsRequest
|
|
8660
|
+
extends BaseRequest,
|
|
8661
|
+
PostMenuV4ItemAttachModifierGroupsPath {
|
|
8662
|
+
body: PostMenuV4ItemAttachModifierGroupsBody;
|
|
8663
|
+
}
|
|
8664
|
+
|
|
8631
8665
|
// POST /menu/v4/modifier
|
|
8632
8666
|
|
|
8633
8667
|
export interface PostMenuV4ModifierBody {
|
package/test/client.test.ts
CHANGED
|
@@ -32,7 +32,6 @@ describe('ServiceClient', () => {
|
|
|
32
32
|
method: 'get',
|
|
33
33
|
headers: {
|
|
34
34
|
'User-Agent': 'CDL/ServiceClient',
|
|
35
|
-
'Content-Type': 'application/json',
|
|
36
35
|
},
|
|
37
36
|
});
|
|
38
37
|
});
|
|
@@ -65,13 +64,26 @@ describe('ServiceClient', () => {
|
|
|
65
64
|
const req = intercept.mock.calls[0][0];
|
|
66
65
|
expect(req.headers).toEqual({
|
|
67
66
|
'User-Agent': 'CDL/ServiceClient',
|
|
68
|
-
'Content-Type': 'application/json',
|
|
69
67
|
a: 'a from constructor',
|
|
70
68
|
b: 'b from method',
|
|
71
69
|
c: 'c from method',
|
|
72
70
|
});
|
|
73
71
|
});
|
|
74
72
|
|
|
73
|
+
test('Content-Type header is added to headers if body exists', async () => {
|
|
74
|
+
const intercept = jest.fn(interceptor(200));
|
|
75
|
+
const api = new ServiceClient({
|
|
76
|
+
stage: 'dev',
|
|
77
|
+
intercept,
|
|
78
|
+
});
|
|
79
|
+
await api.post_discount({ name: 'test', createdBy: 'test' }, {});
|
|
80
|
+
const req = intercept.mock.calls[0][0];
|
|
81
|
+
expect(req.headers).toEqual({
|
|
82
|
+
'User-Agent': 'CDL/ServiceClient',
|
|
83
|
+
'Content-Type': 'application/json',
|
|
84
|
+
});
|
|
85
|
+
});
|
|
86
|
+
|
|
75
87
|
test('client retries on bad status codes', async () => {
|
|
76
88
|
const intercept = jest.fn(async () => {
|
|
77
89
|
if (intercept.mock.calls.length === 3) {
|