@compassdigital/sdk.typescript 3.8.0 → 3.10.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.
Files changed (48) hide show
  1. package/README.md +1 -1
  2. package/bin/gen.js +5 -0
  3. package/gen.ts +5 -0
  4. package/lib/base.d.ts.map +1 -1
  5. package/lib/base.js +5 -2
  6. package/lib/base.js.map +1 -1
  7. package/lib/index.d.ts +2 -9
  8. package/lib/index.d.ts.map +1 -1
  9. package/lib/index.js +1 -10
  10. package/lib/index.js.map +1 -1
  11. package/lib/interface/location.d.ts +22 -4
  12. package/lib/interface/location.d.ts.map +1 -1
  13. package/lib/interface/menu.d.ts +5 -1
  14. package/lib/interface/menu.d.ts.map +1 -1
  15. package/lib/interface/message.d.ts +6 -2
  16. package/lib/interface/message.d.ts.map +1 -1
  17. package/lib/interface/order.d.ts +4 -1
  18. package/lib/interface/order.d.ts.map +1 -1
  19. package/lib/interface/partner.d.ts +10 -5
  20. package/lib/interface/partner.d.ts.map +1 -1
  21. package/lib/interface/payment.d.ts +4 -4
  22. package/lib/interface/payment.d.ts.map +1 -1
  23. package/lib/interface/permission.d.ts +6 -2
  24. package/lib/interface/permission.d.ts.map +1 -1
  25. package/lib/interface/shoppingcart.d.ts +0 -4
  26. package/lib/interface/shoppingcart.d.ts.map +1 -1
  27. package/lib/interface/task.d.ts +9 -22
  28. package/lib/interface/task.d.ts.map +1 -1
  29. package/lib/interface/vendor.d.ts +1 -0
  30. package/lib/interface/vendor.d.ts.map +1 -1
  31. package/lib/interface/vote.d.ts +6 -2
  32. package/lib/interface/vote.d.ts.map +1 -1
  33. package/package.json +1 -1
  34. package/src/base.ts +4 -2
  35. package/src/index.ts +1 -16
  36. package/src/interface/announcement.ts +1 -1
  37. package/src/interface/location.ts +25 -4
  38. package/src/interface/menu.ts +5 -1
  39. package/src/interface/message.ts +6 -2
  40. package/src/interface/order.ts +4 -1
  41. package/src/interface/partner.ts +11 -6
  42. package/src/interface/payment.ts +4 -4
  43. package/src/interface/permission.ts +6 -2
  44. package/src/interface/shoppingcart.ts +0 -5
  45. package/src/interface/task.ts +9 -28
  46. package/src/interface/vendor.ts +1 -0
  47. package/src/interface/vote.ts +6 -2
  48. package/test/client.test.ts +17 -6
@@ -22,6 +22,7 @@ export interface CreateOrder {
22
22
  meta?: {
23
23
  // which ui the order was placed on
24
24
  source?: string;
25
+ [index: string]: any;
25
26
  };
26
27
  pickup?: string;
27
28
  pickup_name?: string;
@@ -226,7 +227,9 @@ export interface OrderedItem {
226
227
  _loyalty?: {
227
228
  amount?: number;
228
229
  };
229
- meta?: any;
230
+ meta?: {
231
+ [index: string]: any;
232
+ };
230
233
  options?: {
231
234
  label?: {
232
235
  en?: string;
@@ -163,11 +163,6 @@ export interface ShoppingCart {
163
163
  // If an order should be paid with meal exchange. If true, this will calculate meals total.
164
164
  mx_cart?: boolean;
165
165
  };
166
- meta?: {
167
- // Raw request from any vendor integrated with CDL
168
- vendor?: any;
169
- [index: string]: any;
170
- };
171
166
  }
172
167
 
173
168
  export type Item = any;
@@ -383,6 +378,12 @@ export interface LocationGroup {
383
378
  logo?: string;
384
379
  is?: {
385
380
  pickup_supported?: boolean;
381
+ delivery_supported?: boolean;
382
+ };
383
+ delivery_details?: {
384
+ show_single_timeslot?: boolean;
385
+ show_instructions?: boolean;
386
+ runner_app_enabled?: boolean;
386
387
  };
387
388
  pickup_instruction?: {
388
389
  en?: string;
@@ -399,7 +400,9 @@ export interface LocationGroup {
399
400
  [index: string]: any;
400
401
  }[];
401
402
  address?: Brand["address"];
402
- meta?: any;
403
+ meta?: {
404
+ [index: string]: any;
405
+ };
403
406
  style?: any;
404
407
  [index: string]: any;
405
408
  }
@@ -689,6 +692,8 @@ export interface PostPartnerStandardcognitionShoppingcartBody {
689
692
  location_brand: string;
690
693
  // CDL shoppingcart id. If provided, items will be added to this shoppingcart
691
694
  shoppingcart: string;
695
+ // Meta data from Standard Cognition shoppingcart
696
+ meta?: any;
692
697
  }
693
698
 
694
699
  export type PostPartnerStandardcognitionShoppingcartResponse = ShoppingCart;
@@ -311,7 +311,7 @@ export interface PostPaymentTokenBody {
311
311
  // Name on credit card
312
312
  nameOnCard: string;
313
313
  // FP StoreId
314
- storeId: string;
314
+ storeId: any[];
315
315
  // FP TerminalId
316
316
  terminalId: string;
317
317
  }
@@ -328,7 +328,7 @@ export interface PutPaymentTokenBody {
328
328
  // Token information to be saved
329
329
  updatedTokenInfo: UpdateTokenInformation;
330
330
  // FP StoreId
331
- storeId: string;
331
+ storeId: any[];
332
332
  // FP TerminalId
333
333
  terminalId: string;
334
334
  }
@@ -345,7 +345,7 @@ export interface DeletePaymentTokenBody {
345
345
  // Token string to be deleted
346
346
  token: string;
347
347
  // FP StoreId
348
- storeId: string;
348
+ storeId: any[];
349
349
  // FP TerminalId
350
350
  terminalId: string;
351
351
  }
@@ -360,7 +360,7 @@ export interface DeletePaymentTokenRequest {
360
360
 
361
361
  export interface GetPaymentMethodsQuery {
362
362
  // FP StoreId
363
- storeId: string;
363
+ storeId: any[];
364
364
  // FP TerminalId
365
365
  terminalId: string;
366
366
  }
@@ -86,7 +86,9 @@ export interface RoleAssignmentBody {
86
86
  // role
87
87
  role_id: string;
88
88
  recipient_id: string;
89
- meta?: any;
89
+ meta?: {
90
+ [index: string]: any;
91
+ };
90
92
  }
91
93
 
92
94
  export interface RoleAssignment {
@@ -95,7 +97,9 @@ export interface RoleAssignment {
95
97
  // role
96
98
  role_id: string;
97
99
  recipient_id: string;
98
- meta?: any;
100
+ meta?: {
101
+ [index: string]: any;
102
+ };
99
103
  last_updated_by?: string;
100
104
  date_created?: string;
101
105
  date_modified?: string;
@@ -221,11 +221,6 @@ export interface ShoppingCart {
221
221
  // If an order should be paid with meal exchange. If true, this will calculate meals total.
222
222
  mx_cart?: boolean;
223
223
  };
224
- meta?: {
225
- // Raw request from any vendor integrated with CDL
226
- vendor?: any;
227
- [index: string]: any;
228
- };
229
224
  }
230
225
 
231
226
  // POST /shoppingcart/ - Create a new ShoppingCart
@@ -45,7 +45,9 @@ export interface Task {
45
45
  // Task Status
46
46
  status?: string;
47
47
  // Any related metadata information about this Task
48
- meta?: any;
48
+ meta?: {
49
+ [index: string]: any;
50
+ };
49
51
  // Date when Task was created
50
52
  created?: string;
51
53
  // Date when task was last modified
@@ -89,7 +91,9 @@ export interface TaskCreate {
89
91
  // Task Status
90
92
  status: string;
91
93
  // Any related metadata information about this Task
92
- meta?: any;
94
+ meta?: {
95
+ [index: string]: any;
96
+ };
93
97
  // Task Type
94
98
  type: string;
95
99
  }
@@ -114,7 +118,9 @@ export interface TaskUpdate {
114
118
  // Task Status
115
119
  status?: string;
116
120
  // Any related metadata information about this Task
117
- meta?: any;
121
+ meta?: {
122
+ [index: string]: any;
123
+ };
118
124
  }
119
125
 
120
126
  export interface OrderUpdate {
@@ -126,21 +132,6 @@ export interface ActionResponse {
126
132
  success?: boolean;
127
133
  }
128
134
 
129
- export interface SNSMessage {
130
- Type: string;
131
- MessageId: string;
132
- Token?: string;
133
- TopicArn: string;
134
- Message: string;
135
- SubscribeURL?: string;
136
- Timestamp: string;
137
- SignatureVersion: string;
138
- Signature: string;
139
- SigningCertURL: string;
140
- Subject?: string;
141
- UnsubscribeURL?: string;
142
- }
143
-
144
135
  // POST /task/ - Create new Task
145
136
 
146
137
  export type PostTaskBody = TaskCreate;
@@ -308,13 +299,3 @@ export type GetTaskLocationGroupResponse = Tasks;
308
299
  export interface GetTaskLocationGroupRequest
309
300
  extends GetTaskLocationGroupQuery,
310
301
  GetTaskLocationGroupPath {}
311
-
312
- // POST /task/apex/sns - Update apex integrated task
313
-
314
- export type PostTaskApexSnsBody = SNSMessage;
315
-
316
- export type PostTaskApexSnsResponse = ActionResponse;
317
-
318
- export interface PostTaskApexSnsRequest {
319
- body: PostTaskApexSnsBody;
320
- }
@@ -19,6 +19,7 @@ export interface Vendor {
19
19
  staging?: string;
20
20
  v1?: string;
21
21
  };
22
+ [index: string]: any;
22
23
  };
23
24
  domain?: string;
24
25
  }
@@ -16,7 +16,9 @@ export interface CreateVote {
16
16
  skip?: boolean;
17
17
  idfa?: string;
18
18
  session_start_time?: number;
19
- meta?: any;
19
+ meta?: {
20
+ [index: string]: any;
21
+ };
20
22
  }
21
23
 
22
24
  export interface Vote {
@@ -32,7 +34,9 @@ export interface Vote {
32
34
  skip?: boolean;
33
35
  idfa?: string;
34
36
  session_start_time?: string;
35
- meta?: any;
37
+ meta?: {
38
+ [index: string]: any;
39
+ };
36
40
  timestamp?: string;
37
41
  }
38
42
 
@@ -1,5 +1,6 @@
1
1
 
2
- import { ServiceClient, ResponseData, ServiceError, RequestData, InterceptFn } from "../src";
2
+ import { parse as parseURL } from "url";
3
+ import { ServiceClient, ResponseData, ServiceError, InterceptFn } from "../src";
3
4
  import { Task } from "../src/interface/task";
4
5
 
5
6
  describe("ServiceClient", () => {
@@ -16,7 +17,7 @@ describe("ServiceClient", () => {
16
17
  }
17
18
 
18
19
  function interceptor(status: number, body?: any, err?: any): InterceptFn {
19
- return (req: RequestData) => Promise.resolve(response(status, body, err));
20
+ return () => Promise.resolve(response(status, body, err));
20
21
  }
21
22
 
22
23
  test("makes basic request", async () => {
@@ -71,26 +72,26 @@ describe("ServiceClient", () => {
71
72
  });
72
73
 
73
74
  test("client retries on bad status codes", async () => {
74
- const intercept = jest.fn(async (req: RequestData) => {
75
+ const intercept = jest.fn(async () => {
75
76
  if (intercept.mock.calls.length === 3) {
76
77
  return response(200, "{}");
77
78
  }
78
79
  return response(500, "something went wrong");
79
80
  });
80
81
  const api = new ServiceClient({ intercept });
81
- const task = await api.get_task("", { retry: 2 });
82
+ await api.get_task("", { retry: 2 });
82
83
  expect(intercept.mock.calls.length).toBe(3);
83
84
  });
84
85
 
85
86
  test("client retries on network error", async () => {
86
- const intercept = jest.fn(async (req: RequestData) => {
87
+ const intercept = jest.fn(async () => {
87
88
  if (intercept.mock.calls.length === 3) {
88
89
  return response(200, "{}");
89
90
  }
90
91
  return response(0, "", new Error("network error"));
91
92
  });
92
93
  const api = new ServiceClient({ intercept });
93
- const task = await api.get_task("", { retry: 2 });
94
+ await api.get_task("", { retry: 2 });
94
95
  expect(intercept.mock.calls.length).toBe(3);
95
96
  });
96
97
 
@@ -102,6 +103,16 @@ describe("ServiceClient", () => {
102
103
  expect(intercept.mock.calls.length).toEqual(6);
103
104
  });
104
105
 
106
+ test("array query parameters are passed correctly", async () => {
107
+ const intercept = jest.fn(interceptor(200, {}));
108
+ const api = new ServiceClient({ intercept });
109
+ await api.get_menus({ query: { foo: "test", things: [1, 2, 3] }} as any);
110
+ expect(intercept.mock.calls.length).toBe(1);
111
+ const req = intercept.mock.calls[0][0];
112
+ const { query } = parseURL(req.url, true);
113
+ expect(query).toEqual({ foo: "test", things: ["1","2","3"] });
114
+ });
115
+
105
116
  describe("ServiceError", () => {
106
117
 
107
118
  // see: https://github.com/microsoft/TypeScript/issues/13965