@chift/chift-nodejs 1.0.10 → 1.0.13

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.
@@ -1,37 +1,27 @@
1
1
  import { operations, components } from '../types/public-api/schema';
2
- import { RequestData } from '../types/api';
2
+ import { AutoPaginatedParams, RequestData } from '../types/api';
3
3
 
4
- type getPaymentsParams = Omit<
5
- operations['pos_get_payments']['parameters']['query'],
6
- 'page' | 'size'
7
- >;
4
+ type GetPaymentsParams = AutoPaginatedParams<operations['pos_get_payments']['parameters']['query']>;
8
5
 
9
- type getPaymentMethodsParams = Omit<
10
- operations['pos_get_payments_methods']['parameters']['query'],
11
- 'page' | 'size'
6
+ type GetPaymentMethodsParams = AutoPaginatedParams<
7
+ operations['pos_get_payments_methods']['parameters']['query']
12
8
  >;
13
9
 
14
- type getProductCategoriesParams = Omit<
15
- operations['pos_get_product_categories']['parameters']['query'],
16
- 'page' | 'size'
10
+ type GetProductCategoriesParams = AutoPaginatedParams<
11
+ operations['pos_get_product_categories']['parameters']['query']
17
12
  >;
18
13
 
19
- type getProductsParams = Omit<
20
- operations['pos_get_products']['parameters']['query'],
21
- 'page' | 'size'
22
- >;
14
+ type GetProductsParams = AutoPaginatedParams<operations['pos_get_products']['parameters']['query']>;
23
15
 
24
- type getCustomersParams = Omit<
25
- operations['pos_get_customers']['parameters']['query'],
26
- 'page' | 'size'
16
+ type GetCustomersParams = AutoPaginatedParams<
17
+ operations['pos_get_customers']['parameters']['query']
27
18
  >;
28
19
 
29
- type getAccountingCategoriesParams = Omit<
30
- operations['pos_get_accounting_categories']['parameters']['query'],
31
- 'page' | 'size'
20
+ type GetAccountingCategoriesParams = AutoPaginatedParams<
21
+ operations['pos_get_accounting_categories']['parameters']['query']
32
22
  >;
33
23
 
34
- type getOrdersParams = Omit<operations['pos_get_orders']['parameters']['query'], 'page' | 'size'>;
24
+ type GetOrdersParams = AutoPaginatedParams<operations['pos_get_orders']['parameters']['query']>;
35
25
 
36
26
  const posFactory = {
37
27
  getLocations(): RequestData<components['schemas']['POSLocationItem'][]> {
@@ -40,7 +30,7 @@ const posFactory = {
40
30
  url: '/consumers/{consumer_id}/pos/locations',
41
31
  };
42
32
  },
43
- getOrders(params: getOrdersParams): RequestData<components['schemas']['OrderItem'][]> {
33
+ getOrders(params: GetOrdersParams): RequestData<components['schemas']['OrderItem'][]> {
44
34
  return {
45
35
  params,
46
36
  method: 'get',
@@ -48,7 +38,7 @@ const posFactory = {
48
38
  };
49
39
  },
50
40
  getCustomers(
51
- params: getCustomersParams
41
+ params?: GetCustomersParams
52
42
  ): RequestData<components['schemas']['POSCustomerItem'][]> {
53
43
  return {
54
44
  params,
@@ -78,7 +68,7 @@ const posFactory = {
78
68
  };
79
69
  },
80
70
  getPaymentMethods(
81
- params: getPaymentMethodsParams
71
+ params?: GetPaymentMethodsParams
82
72
  ): RequestData<components['schemas']['PaymentMethods'][]> {
83
73
  return {
84
74
  params,
@@ -87,7 +77,7 @@ const posFactory = {
87
77
  };
88
78
  },
89
79
  getProductCategories(
90
- params: getProductCategoriesParams
80
+ params?: GetProductCategoriesParams
91
81
  ): RequestData<components['schemas']['CategoryItem'][]> {
92
82
  return {
93
83
  params,
@@ -95,7 +85,9 @@ const posFactory = {
95
85
  url: `/consumers/{consumer_id}/pos/product-categories`,
96
86
  };
97
87
  },
98
- getProducts(params: getProductsParams): RequestData<components['schemas']['POSProductItem'][]> {
88
+ getProducts(
89
+ params?: GetProductsParams
90
+ ): RequestData<components['schemas']['POSProductItem'][]> {
99
91
  return {
100
92
  params,
101
93
  method: 'get',
@@ -113,7 +105,7 @@ const posFactory = {
113
105
  },
114
106
  getClosure(
115
107
  date: string,
116
- params: operations['pos_get_closure']['parameters']['query']
108
+ params?: operations['pos_get_closure']['parameters']['query']
117
109
  ): RequestData<components['schemas']['ClosureItem']> {
118
110
  return {
119
111
  params,
@@ -121,7 +113,7 @@ const posFactory = {
121
113
  url: `/consumers/{consumer_id}/pos/closures/${date}`,
122
114
  };
123
115
  },
124
- getPayments(params: getPaymentsParams): RequestData<components['schemas']['PaymentItem'][]> {
116
+ getPayments(params: GetPaymentsParams): RequestData<components['schemas']['PaymentItem'][]> {
125
117
  return {
126
118
  params,
127
119
  method: 'get',
@@ -139,7 +131,7 @@ const posFactory = {
139
131
  };
140
132
  },
141
133
  getAccountingCategories(
142
- params: getAccountingCategoriesParams
134
+ params?: GetAccountingCategoriesParams
143
135
  ): RequestData<components['schemas']['AccountingCategoryItem'][]> {
144
136
  return {
145
137
  params,
package/src/types/api.ts CHANGED
@@ -33,3 +33,5 @@ export type ApiFor<TFactory extends RequestFactory> = {
33
33
  ? (...args: TArgs) => Promise<TResponse>
34
34
  : never;
35
35
  };
36
+
37
+ export type AutoPaginatedParams<T> = Omit<Exclude<T, undefined>, 'page' | 'size'>;
@@ -819,6 +819,8 @@ export interface components {
819
819
  AccountBalance: {
820
820
  /** Account Number */
821
821
  account_number: string;
822
+ /** Account Name */
823
+ account_name?: string;
822
824
  /** Debit */
823
825
  debit: number;
824
826
  /** Credit */
@@ -835,12 +837,12 @@ export interface components {
835
837
  accounts: string[];
836
838
  /**
837
839
  * Start
838
- * @description Start month (included, e.g. 022023 for february 2023)
840
+ * @description Start month (included, e.g. 202302 for february 2023)
839
841
  */
840
- start: string;
842
+ start?: string;
841
843
  /**
842
844
  * End
843
- * @description End month (included, e.g. 122023 for december 2023)
845
+ * @description End month (included, e.g. 202312 for december 2023)
844
846
  */
845
847
  end: string;
846
848
  };
@@ -2544,6 +2546,16 @@ export interface components {
2544
2546
  ExecutionType: 'code' | 'module';
2545
2547
  /** FeesItem */
2546
2548
  FeesItem: {
2549
+ /**
2550
+ * Id
2551
+ * @description Technical id in Chift
2552
+ */
2553
+ id: string;
2554
+ /**
2555
+ * Source Ref
2556
+ * @description Technical id in the target software
2557
+ */
2558
+ source_ref: components['schemas']['Ref'];
2547
2559
  /**
2548
2560
  * Created On
2549
2561
  * Format: date-time
@@ -5341,6 +5353,16 @@ export interface components {
5341
5353
  };
5342
5354
  /** ShippingRefund */
5343
5355
  ShippingRefund: {
5356
+ /**
5357
+ * Id
5358
+ * @description Technical id in Chift
5359
+ */
5360
+ id: string;
5361
+ /**
5362
+ * Source Ref
5363
+ * @description Technical id in the target software
5364
+ */
5365
+ source_ref: components['schemas']['Ref'];
5344
5366
  /**
5345
5367
  * Untaxed Amount
5346
5368
  * @description Untaxed amount refunded (after discount).
@@ -1 +0,0 @@
1
- export {};
@@ -1,69 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
26
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
27
- return new (P || (P = Promise))(function (resolve, reject) {
28
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
29
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
30
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
31
- step((generator = generator.apply(thisArg, _arguments || [])).next());
32
- });
33
- };
34
- Object.defineProperty(exports, "__esModule", { value: true });
35
- const globals_1 = require("@jest/globals");
36
- const chift = __importStar(require("../../src/index"));
37
- const dotenv = __importStar(require("dotenv"));
38
- dotenv.config();
39
- const client = new chift.API({
40
- baseUrl: process.env.CHIFT_BASE_URL,
41
- clientId: process.env.CHIFT_CLIENT_ID,
42
- clientSecret: process.env.CHIFT_CLIENT_SECRET,
43
- accountId: process.env.CHIFT_ACCOUNT_ID,
44
- });
45
- let flow;
46
- (0, globals_1.beforeAll)(() => __awaiter(void 0, void 0, void 0, function* () {
47
- const syncId = process.env.CHIFT_TEST_SYNC_ID;
48
- const sync = yield client.Syncs.getSyncById(syncId);
49
- flow = yield sync.createFlow({
50
- name: 'Je suis un flux de test',
51
- description: 'Flux de test',
52
- execution: {
53
- type: 'code',
54
- },
55
- trigger: {
56
- type: 'event',
57
- },
58
- config: {},
59
- }, (consumer, flowContext) => __awaiter(void 0, void 0, void 0, function* () {
60
- console.log(`Mon flow_id : ${flowContext.flow_id}`);
61
- console.log(`Bonjour, ceci est un test, on exécute le flux pour consumer: ${consumer}`);
62
- }));
63
- }));
64
- (0, globals_1.test)('executeLocal', () => __awaiter(void 0, void 0, void 0, function* () {
65
- flow.execute({ context: { logs: true, local: true } });
66
- }));
67
- (0, globals_1.test)('execute', () => __awaiter(void 0, void 0, void 0, function* () {
68
- flow.execute({ context: { logs: true, local: false } });
69
- }));