@compassdigital/sdk.typescript 4.117.0 → 4.119.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@compassdigital/sdk.typescript",
3
- "version": "4.117.0",
3
+ "version": "4.119.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.39.0",
52
+ "@compassdigital/sdk.typescript.cli": "^4.40.1",
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
@@ -325,26 +325,33 @@ export abstract class BaseServiceClient {
325
325
  }
326
326
 
327
327
  /**
328
- * Combine the path and query parameters into a full url.
328
+ * Determine the base url to use.
329
329
  */
330
- private build_url(
331
- path: string,
332
- service: string,
333
- { base_url, stage }: RequestOptions,
334
- params: any,
335
- ): string {
336
- if (!stage) {
337
- throw new Error('stage not specified');
338
- }
339
- let url =
340
- stage === 'v1'
341
- ? `https://api.compassdigital.org${path}`
342
- : `https://${stage}.api.compassdigital.org${path}`;
330
+ private base_url(service: string, { base_url, stage }: RequestOptions): string {
343
331
  // use the base url if one was provided.
344
- if (base_url) {
345
- if (typeof base_url === 'object' && base_url[service]) base_url = base_url[service];
346
- if (typeof base_url === 'string') url = `${this.clean_url(base_url)}${path}`;
332
+ if (typeof base_url === 'string') {
333
+ return this.clean_url(base_url);
334
+ }
335
+ if (typeof base_url === 'object' && base_url[service]) {
336
+ return this.clean_url(base_url[service]);
347
337
  }
338
+ switch (stage) {
339
+ case 'dev':
340
+ case 'staging':
341
+ return `https://${stage}.api.compassdigital.org`;
342
+ case 'v1':
343
+ case 'prod':
344
+ return `https://api.compassdigital.org`;
345
+ default:
346
+ throw new Error(`ServiceClient was not provided a valid stage: '${stage}'`);
347
+ }
348
+ }
349
+
350
+ /**
351
+ * Combine the path and query parameters into a full url.
352
+ */
353
+ private build_url(path: string, service: string, options: RequestOptions, params: any): string {
354
+ let url = this.base_url(service, options) + path;
348
355
  // add query parameters.
349
356
  const query: string[] = [];
350
357
  for (const [name, values] of Object.entries(params)) {
package/src/index.ts CHANGED
@@ -931,8 +931,6 @@ import {
931
931
  PostMenuV4BrandCategoryDuplicateResponse,
932
932
  PostMenuV4BrandMenuDuplicateBody,
933
933
  PostMenuV4BrandMenuDuplicateResponse,
934
- PostMenuV4CategoryAttachmentQuery,
935
- PostMenuV4CategoryAttachmentResponse,
936
934
  PostMenuV4ItemAttachmentQuery,
937
935
  PostMenuV4ItemAttachmentResponse,
938
936
  PostMenuV4ItemBody,
@@ -948,6 +946,8 @@ import {
948
946
  PatchMenuV4ItemsBulkUpdateResponse,
949
947
  PostMenuV4ItemDuplicateBody,
950
948
  PostMenuV4ItemDuplicateResponse,
949
+ DeleteMenuV4ItemModifierGroupsDetachBody,
950
+ DeleteMenuV4ItemModifierGroupsDetachResponse,
951
951
  PostMenuV4ModifierBody,
952
952
  PostMenuV4ModifierResponse,
953
953
  GetMenuV4ModifierQuery,
@@ -973,6 +973,8 @@ import {
973
973
  PostMenuV4ModifierGroupDuplicateQuery,
974
974
  PostMenuV4ModifierGroupDuplicateBody,
975
975
  PostMenuV4ModifierGroupDuplicateResponse,
976
+ DeleteMenuV4ModifierGroupModifiersDetachBody,
977
+ DeleteMenuV4ModifierGroupModifiersDetachResponse,
976
978
  PatchMenuV4StockBusinessUnitBody,
977
979
  PatchMenuV4StockBusinessUnitResponse,
978
980
  PatchMenuV4StockBody,
@@ -991,6 +993,10 @@ import {
991
993
  PostMenuV4ScheduleMenuResponse,
992
994
  PostMenuV4UnscheduleMenuBody,
993
995
  PostMenuV4UnscheduleMenuResponse,
996
+ PostMenuV4CategoryAttachmentQuery,
997
+ PostMenuV4CategoryAttachmentResponse,
998
+ DeleteMenuV4CategoryDetachItemsBody,
999
+ DeleteMenuV4CategoryDetachItemsResponse,
994
1000
  } from './interface/menu';
995
1001
 
996
1002
  import {
@@ -10107,30 +10113,6 @@ export class ServiceClient extends BaseServiceClient {
10107
10113
  );
10108
10114
  }
10109
10115
 
10110
- /**
10111
- * POST /menu/v4/category/{id}/attachment/{name}
10112
- *
10113
- * @param id
10114
- * @param name
10115
- * @param options - additional request options
10116
- */
10117
- post_menu_v4_category_attachment(
10118
- id: string,
10119
- name: 'thumbnail',
10120
- options?: {
10121
- query?: PostMenuV4CategoryAttachmentQuery;
10122
- } & RequestOptions,
10123
- ): ResponsePromise<PostMenuV4CategoryAttachmentResponse> {
10124
- return this.request(
10125
- 'menu',
10126
- '/menu/v4/category/{id}/attachment/{name}',
10127
- 'post',
10128
- `/menu/v4/category/${id}/attachment/${name}`,
10129
- null,
10130
- options,
10131
- );
10132
- }
10133
-
10134
10116
  /**
10135
10117
  * POST /menu/v4/item/{id}/attachment/{name}
10136
10118
  *
@@ -10287,6 +10269,28 @@ export class ServiceClient extends BaseServiceClient {
10287
10269
  );
10288
10270
  }
10289
10271
 
10272
+ /**
10273
+ * DELETE /menu/v4/item/{id}/modifier-groups/detach
10274
+ *
10275
+ * @param id
10276
+ * @param body
10277
+ * @param options - additional request options
10278
+ */
10279
+ delete_menu_v4_item_modifier_groups_detach(
10280
+ id: string,
10281
+ body: DeleteMenuV4ItemModifierGroupsDetachBody,
10282
+ options?: RequestOptions,
10283
+ ): ResponsePromise<DeleteMenuV4ItemModifierGroupsDetachResponse> {
10284
+ return this.request(
10285
+ 'menu',
10286
+ '/menu/v4/item/{id}/modifier-groups/detach',
10287
+ 'delete',
10288
+ `/menu/v4/item/${id}/modifier-groups/detach`,
10289
+ body,
10290
+ options,
10291
+ );
10292
+ }
10293
+
10290
10294
  /**
10291
10295
  * POST /menu/v4/modifier
10292
10296
  *
@@ -10560,6 +10564,28 @@ export class ServiceClient extends BaseServiceClient {
10560
10564
  );
10561
10565
  }
10562
10566
 
10567
+ /**
10568
+ * DELETE /menu/v4/modifier-group/{id}/modifiers/detach
10569
+ *
10570
+ * @param id
10571
+ * @param body
10572
+ * @param options - additional request options
10573
+ */
10574
+ delete_menu_v4_modifier_group_modifiers_detach(
10575
+ id: string,
10576
+ body: DeleteMenuV4ModifierGroupModifiersDetachBody,
10577
+ options?: RequestOptions,
10578
+ ): ResponsePromise<DeleteMenuV4ModifierGroupModifiersDetachResponse> {
10579
+ return this.request(
10580
+ 'menu',
10581
+ '/menu/v4/modifier-group/{id}/modifiers/detach',
10582
+ 'delete',
10583
+ `/menu/v4/modifier-group/${id}/modifiers/detach`,
10584
+ body,
10585
+ options,
10586
+ );
10587
+ }
10588
+
10563
10589
  /**
10564
10590
  * PATCH /menu/v4/stock/business-unit
10565
10591
  *
@@ -10746,6 +10772,52 @@ export class ServiceClient extends BaseServiceClient {
10746
10772
  );
10747
10773
  }
10748
10774
 
10775
+ /**
10776
+ * POST /menu/v4/category/{id}/attachment/{name}
10777
+ *
10778
+ * @param id
10779
+ * @param name
10780
+ * @param options - additional request options
10781
+ */
10782
+ post_menu_v4_category_attachment(
10783
+ id: string,
10784
+ name: 'thumbnail',
10785
+ options?: {
10786
+ query?: PostMenuV4CategoryAttachmentQuery;
10787
+ } & RequestOptions,
10788
+ ): ResponsePromise<PostMenuV4CategoryAttachmentResponse> {
10789
+ return this.request(
10790
+ 'menu',
10791
+ '/menu/v4/category/{id}/attachment/{name}',
10792
+ 'post',
10793
+ `/menu/v4/category/${id}/attachment/${name}`,
10794
+ null,
10795
+ options,
10796
+ );
10797
+ }
10798
+
10799
+ /**
10800
+ * DELETE /menu/v4/category/{id}/detach-items
10801
+ *
10802
+ * @param id
10803
+ * @param body
10804
+ * @param options - additional request options
10805
+ */
10806
+ delete_menu_v4_category_detach_items(
10807
+ id: string,
10808
+ body: DeleteMenuV4CategoryDetachItemsBody,
10809
+ options?: RequestOptions,
10810
+ ): ResponsePromise<DeleteMenuV4CategoryDetachItemsResponse> {
10811
+ return this.request(
10812
+ 'menu',
10813
+ '/menu/v4/category/{id}/detach-items',
10814
+ 'delete',
10815
+ `/menu/v4/category/${id}/detach-items`,
10816
+ body,
10817
+ options,
10818
+ );
10819
+ }
10820
+
10749
10821
  /**
10750
10822
  * GET /notification - Get all notifications
10751
10823
  *
@@ -366,25 +366,9 @@ export interface PostMealplanInternalDebitBody {
366
366
  type?: string;
367
367
  conversion_amount?: number;
368
368
  terminal_id?: string;
369
- drain_order_type?: {
370
- taxable?: boolean;
371
- tax_exempt?: boolean;
372
- };
373
369
  }
374
370
 
375
- export interface PostMealplanInternalDebitResponse {
376
- id?: string;
377
- name?: string;
378
- balance?: number;
379
- is?: TenderIs;
380
- transaction_id?: string;
381
- type?: number;
382
- tender_id?: number;
383
- currency?: string;
384
- transaction_amount?: number;
385
- drained_tender_name?: string;
386
- drained_tender_breakdown?: DrainedTender[];
387
- }
371
+ export type PostMealplanInternalDebitResponse = Tender;
388
372
 
389
373
  export interface PostMealplanInternalDebitRequest
390
374
  extends BaseRequest,
@@ -8027,27 +8027,6 @@ export interface PostMenuV4BrandMenuDuplicateRequest
8027
8027
  body: PostMenuV4BrandMenuDuplicateBody;
8028
8028
  }
8029
8029
 
8030
- // POST /menu/v4/category/{id}/attachment/{name}
8031
-
8032
- export interface PostMenuV4CategoryAttachmentPath {
8033
- id: string;
8034
- name: 'thumbnail';
8035
- }
8036
-
8037
- export interface PostMenuV4CategoryAttachmentQuery {
8038
- 'body.data'?: string;
8039
- 'body.brand_id'?: string;
8040
- }
8041
-
8042
- export interface PostMenuV4CategoryAttachmentResponse {
8043
- status?: string;
8044
- }
8045
-
8046
- export interface PostMenuV4CategoryAttachmentRequest
8047
- extends BaseRequest,
8048
- RequestQuery<PostMenuV4CategoryAttachmentQuery>,
8049
- PostMenuV4CategoryAttachmentPath {}
8050
-
8051
8030
  // POST /menu/v4/item/{id}/attachment/{name}
8052
8031
 
8053
8032
  export interface PostMenuV4ItemAttachmentPath {
@@ -8610,6 +8589,45 @@ export interface PostMenuV4ItemDuplicateRequest extends BaseRequest, PostMenuV4I
8610
8589
  body: PostMenuV4ItemDuplicateBody;
8611
8590
  }
8612
8591
 
8592
+ // DELETE /menu/v4/item/{id}/modifier-groups/detach
8593
+
8594
+ export interface DeleteMenuV4ItemModifierGroupsDetachPath {
8595
+ id: string;
8596
+ }
8597
+
8598
+ export type DeleteMenuV4ItemModifierGroupsDetachBody = {
8599
+ parent?: DraftItemToModifierGroupRelationshipDTO;
8600
+ children?: DraftItemToModifierGroupRelationshipDTO[];
8601
+ id: string;
8602
+ created_at?: string;
8603
+ updated_at?: string;
8604
+ deleted_at?: string;
8605
+ parent_id?: string;
8606
+ modifier_group_id: string;
8607
+ item_id: string;
8608
+ brand_id: string;
8609
+ sequence?: number;
8610
+ applied_diff_snapshot?: Record<string, any>;
8611
+ version?: number;
8612
+ item?: DraftItemDTO;
8613
+ modifier_group?: DraftModifierGroupDTO;
8614
+ brand?: DraftBrandDTO;
8615
+ changes?: ItemToModifierGroupRelationshipChangeDTO[];
8616
+ vendor_metadata?: VendorMetadataDTO[];
8617
+ permissions?: Record<string, any>;
8618
+ [index: string]: any;
8619
+ }[];
8620
+
8621
+ export interface DeleteMenuV4ItemModifierGroupsDetachResponse {
8622
+ status?: string;
8623
+ }
8624
+
8625
+ export interface DeleteMenuV4ItemModifierGroupsDetachRequest
8626
+ extends BaseRequest,
8627
+ DeleteMenuV4ItemModifierGroupsDetachPath {
8628
+ body: DeleteMenuV4ItemModifierGroupsDetachBody;
8629
+ }
8630
+
8613
8631
  // POST /menu/v4/modifier
8614
8632
 
8615
8633
  export interface PostMenuV4ModifierBody {
@@ -9398,6 +9416,45 @@ export interface PostMenuV4ModifierGroupDuplicateRequest
9398
9416
  body: PostMenuV4ModifierGroupDuplicateBody;
9399
9417
  }
9400
9418
 
9419
+ // DELETE /menu/v4/modifier-group/{id}/modifiers/detach
9420
+
9421
+ export interface DeleteMenuV4ModifierGroupModifiersDetachPath {
9422
+ id: string;
9423
+ }
9424
+
9425
+ export type DeleteMenuV4ModifierGroupModifiersDetachBody = {
9426
+ parent?: DraftModifierGroupToModifierRelationshipDTO;
9427
+ children?: DraftModifierGroupToModifierRelationshipDTO[];
9428
+ id: string;
9429
+ created_at?: string;
9430
+ updated_at?: string;
9431
+ deleted_at?: string;
9432
+ parent_id?: string;
9433
+ modifier_id: string;
9434
+ modifier_group_id: string;
9435
+ brand_id: string;
9436
+ sequence?: number;
9437
+ applied_diff_snapshot?: Record<string, any>;
9438
+ version?: number;
9439
+ modifier?: DraftModifierDTO;
9440
+ modifier_group?: DraftModifierGroupDTO;
9441
+ brand?: DraftBrandDTO;
9442
+ changes?: ModifierGroupToModifierRelationshipChangeDTO[];
9443
+ vendor_metadata?: VendorMetadataDTO[];
9444
+ permissions?: Record<string, any>;
9445
+ [index: string]: any;
9446
+ }[];
9447
+
9448
+ export interface DeleteMenuV4ModifierGroupModifiersDetachResponse {
9449
+ status?: string;
9450
+ }
9451
+
9452
+ export interface DeleteMenuV4ModifierGroupModifiersDetachRequest
9453
+ extends BaseRequest,
9454
+ DeleteMenuV4ModifierGroupModifiersDetachPath {
9455
+ body: DeleteMenuV4ModifierGroupModifiersDetachBody;
9456
+ }
9457
+
9401
9458
  // PATCH /menu/v4/stock/business-unit
9402
9459
 
9403
9460
  export interface PatchMenuV4StockBusinessUnitBody {
@@ -9633,3 +9690,63 @@ export interface PostMenuV4UnscheduleMenuResponse {
9633
9690
  export interface PostMenuV4UnscheduleMenuRequest extends BaseRequest {
9634
9691
  body: PostMenuV4UnscheduleMenuBody;
9635
9692
  }
9693
+
9694
+ // POST /menu/v4/category/{id}/attachment/{name}
9695
+
9696
+ export interface PostMenuV4CategoryAttachmentPath {
9697
+ id: string;
9698
+ name: 'thumbnail';
9699
+ }
9700
+
9701
+ export interface PostMenuV4CategoryAttachmentQuery {
9702
+ 'body.data'?: string;
9703
+ 'body.brand_id'?: string;
9704
+ }
9705
+
9706
+ export interface PostMenuV4CategoryAttachmentResponse {
9707
+ status?: string;
9708
+ }
9709
+
9710
+ export interface PostMenuV4CategoryAttachmentRequest
9711
+ extends BaseRequest,
9712
+ RequestQuery<PostMenuV4CategoryAttachmentQuery>,
9713
+ PostMenuV4CategoryAttachmentPath {}
9714
+
9715
+ // DELETE /menu/v4/category/{id}/detach-items
9716
+
9717
+ export interface DeleteMenuV4CategoryDetachItemsPath {
9718
+ id: string;
9719
+ }
9720
+
9721
+ export type DeleteMenuV4CategoryDetachItemsBody = {
9722
+ parent?: DraftCategoryToItemRelationshipDTO;
9723
+ children?: DraftCategoryToItemRelationshipDTO[];
9724
+ id: string;
9725
+ created_at?: string;
9726
+ updated_at?: string;
9727
+ deleted_at?: string;
9728
+ parent_id?: string;
9729
+ item_id: string;
9730
+ category_id: string;
9731
+ brand_id: string;
9732
+ sequence?: number;
9733
+ applied_diff_snapshot?: Record<string, any>;
9734
+ version?: number;
9735
+ category?: DraftCategoryDTO;
9736
+ item?: DraftItemDTO;
9737
+ brand?: DraftBrandDTO;
9738
+ changes?: CategoryToItemRelationshipChangeDTO[];
9739
+ vendor_metadata?: VendorMetadataDTO[];
9740
+ permissions?: Record<string, any>;
9741
+ [index: string]: any;
9742
+ }[];
9743
+
9744
+ export interface DeleteMenuV4CategoryDetachItemsResponse {
9745
+ status?: string;
9746
+ }
9747
+
9748
+ export interface DeleteMenuV4CategoryDetachItemsRequest
9749
+ extends BaseRequest,
9750
+ DeleteMenuV4CategoryDetachItemsPath {
9751
+ body: DeleteMenuV4CategoryDetachItemsBody;
9752
+ }
@@ -49,7 +49,7 @@ describe('ServiceClient', () => {
49
49
  test('headers get merged', async () => {
50
50
  const intercept = jest.fn(interceptor(200));
51
51
  const api = new ServiceClient({
52
- stage: 'test',
52
+ stage: 'dev',
53
53
  intercept,
54
54
  headers: {
55
55
  a: 'a from constructor',
@@ -114,6 +114,11 @@ describe('ServiceClient', () => {
114
114
  expect(query).toEqual({ foo: 'test', things: ['1', '2', '3'] });
115
115
  });
116
116
 
117
+ test('client throws if invalid stage is passed', async () => {
118
+ const api = new ServiceClient({ stage: 'invalid', intercept: interceptor(500) });
119
+ await expect(api.get_task('')).rejects.toBeInstanceOf(Error);
120
+ });
121
+
117
122
  describe('ServiceError', () => {
118
123
  // see: https://github.com/microsoft/TypeScript/issues/13965
119
124
  test('is instance of itself', async () => {