@chift/chift-nodejs 1.0.16 → 1.0.18

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 (145) hide show
  1. package/README.md +3 -3
  2. package/package.json +5 -2
  3. package/src/types/public-api/schema.d.ts +4071 -850
  4. package/src/types/sync.ts +20 -5
  5. package/.eslintcache +0 -1
  6. package/.eslintignore +0 -1
  7. package/.eslintrc.json +0 -25
  8. package/.github/workflows/ci.yml +0 -75
  9. package/.husky/pre-commit +0 -4
  10. package/.prettierignore +0 -1
  11. package/.prettierrc.json +0 -7
  12. package/CHANGELOG.md +0 -98
  13. package/coverage/clover.xml +0 -1645
  14. package/coverage/coverage-final.json +0 -19
  15. package/coverage/lcov-report/base.css +0 -224
  16. package/coverage/lcov-report/block-navigation.js +0 -87
  17. package/coverage/lcov-report/favicon.png +0 -0
  18. package/coverage/lcov-report/index.html +0 -146
  19. package/coverage/lcov-report/prettify.css +0 -1
  20. package/coverage/lcov-report/prettify.js +0 -2
  21. package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
  22. package/coverage/lcov-report/sorter.js +0 -196
  23. package/coverage/lcov-report/src/helpers/index.html +0 -131
  24. package/coverage/lcov-report/src/helpers/openapi.ts.html +0 -151
  25. package/coverage/lcov-report/src/helpers/settings.ts.html +0 -94
  26. package/coverage/lcov-report/src/index.html +0 -116
  27. package/coverage/lcov-report/src/index.ts.html +0 -88
  28. package/coverage/lcov-report/src/modules/accounting.ts.html +0 -1156
  29. package/coverage/lcov-report/src/modules/api.ts.html +0 -190
  30. package/coverage/lcov-report/src/modules/consumer.ts.html +0 -616
  31. package/coverage/lcov-report/src/modules/consumers.ts.html +0 -331
  32. package/coverage/lcov-report/src/modules/custom.ts.html +0 -193
  33. package/coverage/lcov-report/src/modules/datastores.ts.html +0 -142
  34. package/coverage/lcov-report/src/modules/ecommerce.ts.html +0 -331
  35. package/coverage/lcov-report/src/modules/flow.ts.html +0 -589
  36. package/coverage/lcov-report/src/modules/index.html +0 -326
  37. package/coverage/lcov-report/src/modules/integrations.ts.html +0 -151
  38. package/coverage/lcov-report/src/modules/internalApi.ts.html +0 -586
  39. package/coverage/lcov-report/src/modules/invoicing.ts.html +0 -391
  40. package/coverage/lcov-report/src/modules/pos.ts.html +0 -421
  41. package/coverage/lcov-report/src/modules/sync.ts.html +0 -316
  42. package/coverage/lcov-report/src/modules/syncs.ts.html +0 -169
  43. package/coverage/lcov-report/src/modules/webhooks.ts.html +0 -343
  44. package/coverage/lcov.info +0 -1976
  45. package/dist/src/helpers/openapi.d.ts +0 -3
  46. package/dist/src/helpers/openapi.js +0 -18
  47. package/dist/src/helpers/settings.d.ts +0 -4
  48. package/dist/src/helpers/settings.js +0 -5
  49. package/dist/src/index.d.ts +0 -1
  50. package/dist/src/modules/accounting.d.ts +0 -68
  51. package/dist/src/modules/accounting.js +0 -326
  52. package/dist/src/modules/api.d.ts +0 -16795
  53. package/dist/src/modules/api.js +0 -36
  54. package/dist/src/modules/consumer.d.ts +0 -3313
  55. package/dist/src/modules/consumer.js +0 -139
  56. package/dist/src/modules/consumers.d.ts +0 -16684
  57. package/dist/src/modules/consumers.js +0 -51
  58. package/dist/src/modules/custom.d.ts +0 -8
  59. package/dist/src/modules/custom.js +0 -36
  60. package/dist/src/modules/datastores.d.ts +0 -18
  61. package/dist/src/modules/datastores.js +0 -23
  62. package/dist/src/modules/ecommerce.d.ts +0 -24
  63. package/dist/src/modules/ecommerce.js +0 -97
  64. package/dist/src/modules/flow.d.ts +0 -15
  65. package/dist/src/modules/flow.js +0 -156
  66. package/dist/src/modules/integrations.d.ts +0 -23
  67. package/dist/src/modules/integrations.js +0 -23
  68. package/dist/src/modules/internalApi.d.ts +0 -24
  69. package/dist/src/modules/internalApi.js +0 -175
  70. package/dist/src/modules/invoicing.d.ts +0 -20
  71. package/dist/src/modules/invoicing.js +0 -90
  72. package/dist/src/modules/pms.d.ts +0 -15
  73. package/dist/src/modules/pms.js +0 -47
  74. package/dist/src/modules/pos.d.ts +0 -26
  75. package/dist/src/modules/pos.js +0 -101
  76. package/dist/src/modules/sync.d.ts +0 -13414
  77. package/dist/src/modules/sync.js +0 -73
  78. package/dist/src/modules/syncs.d.ts +0 -11
  79. package/dist/src/modules/syncs.js +0 -39
  80. package/dist/src/modules/webhooks.d.ts +0 -55
  81. package/dist/src/modules/webhooks.js +0 -53
  82. package/dist/src/types/api.d.ts +0 -29
  83. package/dist/src/types/api.js +0 -2
  84. package/dist/src/types/consumers.d.ts +0 -8
  85. package/dist/src/types/consumers.js +0 -2
  86. package/dist/src/types/public-api/mappings.d.ts +0 -21
  87. package/dist/src/types/public-api/mappings.js +0 -2
  88. package/dist/src/types/public-api/schema.d.ts +0 -12003
  89. package/dist/src/types/public-api/schema.js +0 -6
  90. package/dist/src/types/sync.d.ts +0 -20
  91. package/dist/src/types/sync.js +0 -2
  92. package/dist/test/modules/accounting.test.d.ts +0 -1
  93. package/dist/test/modules/accounting.test.js +0 -582
  94. package/dist/test/modules/consumer.test.d.ts +0 -1
  95. package/dist/test/modules/consumer.test.js +0 -89
  96. package/dist/test/modules/consumers.test.d.ts +0 -1
  97. package/dist/test/modules/consumers.test.js +0 -109
  98. package/dist/test/modules/ecommerce.test.d.ts +0 -1
  99. package/dist/test/modules/ecommerce.test.js +0 -220
  100. package/dist/test/modules/integrations.test.d.ts +0 -1
  101. package/dist/test/modules/integrations.test.js +0 -54
  102. package/dist/test/modules/invoicing.test.d.ts +0 -1
  103. package/dist/test/modules/invoicing.test.js +0 -108
  104. package/dist/test/modules/pos.test.d.ts +0 -1
  105. package/dist/test/modules/pos.test.js +0 -182
  106. package/dist/test/modules/sync.test.d.ts +0 -1
  107. package/dist/test/modules/sync.test.js +0 -81
  108. package/dist/test/modules/syncs.test.d.ts +0 -1
  109. package/dist/test/modules/syncs.test.js +0 -53
  110. package/dist/test/modules/webhooks.test.d.ts +0 -1
  111. package/dist/test/modules/webhooks.test.js +0 -120
  112. package/jest.config.ts +0 -195
  113. package/src/helpers/openapi.ts +0 -22
  114. package/src/helpers/settings.ts +0 -3
  115. package/src/index.ts +0 -1
  116. package/src/modules/accounting.ts +0 -510
  117. package/src/modules/api.ts +0 -35
  118. package/src/modules/consumer.ts +0 -213
  119. package/src/modules/consumers.ts +0 -82
  120. package/src/modules/custom.ts +0 -36
  121. package/src/modules/datastores.ts +0 -19
  122. package/src/modules/ecommerce.ts +0 -127
  123. package/src/modules/flow.ts +0 -168
  124. package/src/modules/integrations.ts +0 -24
  125. package/src/modules/internalApi.ts +0 -182
  126. package/src/modules/invoicing.ts +0 -114
  127. package/src/modules/pms.ts +0 -67
  128. package/src/modules/pos.ts +0 -144
  129. package/src/modules/sync.ts +0 -77
  130. package/src/modules/syncs.ts +0 -59
  131. package/src/modules/webhooks.ts +0 -86
  132. package/src/types/public-api/schema.ts +0 -12073
  133. package/test/data/accounting_invoice.pdf +0 -0
  134. package/test/modules/accounting.test.ts +0 -628
  135. package/test/modules/consumer.test.ts +0 -68
  136. package/test/modules/consumers.test.ts +0 -85
  137. package/test/modules/ecommerce.test.ts +0 -208
  138. package/test/modules/integrations.test.ts +0 -22
  139. package/test/modules/invoicing.test.ts +0 -88
  140. package/test/modules/pos.test.ts +0 -166
  141. package/test/modules/sync.test.ts +0 -60
  142. package/test/modules/syncs.test.ts +0 -23
  143. package/test/modules/webhooks.test.ts +0 -92
  144. package/test/set_envs.sh +0 -14
  145. package/tsconfig.json +0 -107
@@ -1,182 +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
- // Split testing between two APIs to support all endpoints
46
- const cashpadConsumerId = process.env.CHIFT_CASHPAD_CONSUMER_ID;
47
- const lightspeedConsumerId = process.env.CHIFT_LIGHTSPEED_CONSUMER_ID;
48
- const popinaConsumerId = process.env.CHIFT_POPINA_CONSUMER_ID;
49
- let cashpadConsumer;
50
- let lightspeedConsumer;
51
- let popinaConsumer;
52
- (0, globals_1.beforeAll)(() => __awaiter(void 0, void 0, void 0, function* () {
53
- cashpadConsumer = yield client.Consumers.getConsumerById(cashpadConsumerId);
54
- lightspeedConsumer = yield client.Consumers.getConsumerById(lightspeedConsumerId);
55
- popinaConsumer = yield client.Consumers.getConsumerById(popinaConsumerId);
56
- }));
57
- (0, globals_1.test)('getLocations', () => __awaiter(void 0, void 0, void 0, function* () {
58
- const locations = yield lightspeedConsumer.pos.getLocations();
59
- (0, globals_1.expect)(locations).toBeInstanceOf(Array);
60
- (0, globals_1.expect)(locations.length).toBeGreaterThan(0);
61
- (0, globals_1.expect)(locations[0]).toHaveProperty('id', globals_1.expect.any(String));
62
- (0, globals_1.expect)(locations[0]).toHaveProperty('name', globals_1.expect.any(String));
63
- }));
64
- let orders;
65
- (0, globals_1.test)('getOrders', () => __awaiter(void 0, void 0, void 0, function* () {
66
- orders = yield lightspeedConsumer.pos.getOrders({
67
- date_from: '2023-01-11',
68
- date_to: '2023-02-28',
69
- });
70
- (0, globals_1.expect)(orders).toBeInstanceOf(Array);
71
- (0, globals_1.expect)(orders.length).toBeGreaterThan(0);
72
- (0, globals_1.expect)(orders[0]).toHaveProperty('id', globals_1.expect.any(String));
73
- }));
74
- // TODO: Fix Method Not Allowed error
75
- globals_1.test.skip('createCustomer', () => __awaiter(void 0, void 0, void 0, function* () {
76
- const body = {
77
- first_name: 'John',
78
- last_name: 'Doe',
79
- email: 'test@test.com',
80
- };
81
- const customer = yield cashpadConsumer.pos.createCustomer(body);
82
- (0, globals_1.expect)(customer).toBeTruthy();
83
- (0, globals_1.expect)(customer).toHaveProperty('id', globals_1.expect.any(String));
84
- (0, globals_1.expect)(customer).toHaveProperty('name');
85
- }));
86
- // TODO: Fix timeout error
87
- let customers = [];
88
- globals_1.test.skip('getCustomers', () => __awaiter(void 0, void 0, void 0, function* () {
89
- customers = yield cashpadConsumer.pos.getCustomers();
90
- (0, globals_1.expect)(customers).toBeInstanceOf(Array);
91
- (0, globals_1.expect)(customers.length).toBeGreaterThan(0);
92
- (0, globals_1.expect)(customers[0]).toHaveProperty('id', globals_1.expect.any(String));
93
- }));
94
- // TODO: Fix The day parameter is missing error
95
- globals_1.test.skip('getOrder', () => __awaiter(void 0, void 0, void 0, function* () {
96
- const order = yield lightspeedConsumer.pos.getOrder(orders[0].id);
97
- (0, globals_1.expect)(order).toBeTruthy();
98
- (0, globals_1.expect)(order).toHaveProperty('id', globals_1.expect.any(String));
99
- (0, globals_1.expect)(order).toHaveProperty('order_number');
100
- (0, globals_1.expect)(order).toHaveProperty('creation_date', globals_1.expect.any(String));
101
- (0, globals_1.expect)(order).toHaveProperty('closing_date');
102
- (0, globals_1.expect)(order).toHaveProperty('service_date');
103
- (0, globals_1.expect)(order).toHaveProperty('total', globals_1.expect.any(Number));
104
- (0, globals_1.expect)(order).toHaveProperty('tax_amount', globals_1.expect.any(Number));
105
- (0, globals_1.expect)(order).toHaveProperty('total_discount');
106
- (0, globals_1.expect)(order).toHaveProperty('total_refund');
107
- (0, globals_1.expect)(order).toHaveProperty('total_tip', globals_1.expect.any(Number));
108
- (0, globals_1.expect)(order).toHaveProperty('items', globals_1.expect.any(Array));
109
- (0, globals_1.expect)(order).toHaveProperty('payments', globals_1.expect.any(Array));
110
- (0, globals_1.expect)(order).toHaveProperty('currency');
111
- (0, globals_1.expect)(order).toHaveProperty('country');
112
- (0, globals_1.expect)(order).toHaveProperty('loyalty');
113
- (0, globals_1.expect)(order).toHaveProperty('customer_id');
114
- (0, globals_1.expect)(order).toHaveProperty('location_id');
115
- (0, globals_1.expect)(order).toHaveProperty('taxes');
116
- }));
117
- // TODO: Fix getCustomers first
118
- globals_1.test.skip('getCustomer', () => __awaiter(void 0, void 0, void 0, function* () {
119
- const customer = yield cashpadConsumer.pos.getCustomer(customers[0].id);
120
- (0, globals_1.expect)(customer).toBeTruthy();
121
- (0, globals_1.expect)(customer).toHaveProperty('id', globals_1.expect.any(String));
122
- (0, globals_1.expect)(customer).toHaveProperty('name');
123
- }));
124
- (0, globals_1.test)('getPaymentMethods', () => __awaiter(void 0, void 0, void 0, function* () {
125
- const paymentMethods = yield lightspeedConsumer.pos.getPaymentMethods();
126
- (0, globals_1.expect)(paymentMethods).toBeInstanceOf(Array);
127
- (0, globals_1.expect)(paymentMethods.length).toBeGreaterThan(0);
128
- (0, globals_1.expect)(paymentMethods[0]).toHaveProperty('id', globals_1.expect.any(String));
129
- (0, globals_1.expect)(paymentMethods[0]).toHaveProperty('name', globals_1.expect.any(String));
130
- (0, globals_1.expect)(paymentMethods[0]).toHaveProperty('extra');
131
- }));
132
- (0, globals_1.test)('getSales', () => __awaiter(void 0, void 0, void 0, function* () {
133
- const sales = yield lightspeedConsumer.pos.getSales({
134
- date_from: '2022-08-11',
135
- date_to: '2022-08-12',
136
- });
137
- (0, globals_1.expect)(sales).toHaveProperty('total', globals_1.expect.any(Number));
138
- (0, globals_1.expect)(sales).toHaveProperty('tax_amount', globals_1.expect.any(Number));
139
- (0, globals_1.expect)(sales).toHaveProperty('taxes', globals_1.expect.any(Array));
140
- }));
141
- (0, globals_1.test)('getClosure', () => __awaiter(void 0, void 0, void 0, function* () {
142
- const closure = yield lightspeedConsumer.pos.getClosure('2022-08-11');
143
- (0, globals_1.expect)(closure).toHaveProperty('date', globals_1.expect.any(String));
144
- (0, globals_1.expect)(closure).toHaveProperty('status');
145
- }));
146
- (0, globals_1.test)('getPayments', () => __awaiter(void 0, void 0, void 0, function* () {
147
- const payments = yield lightspeedConsumer.pos.getPayments({
148
- date_from: '2023-01-11',
149
- date_to: '2023-02-28',
150
- });
151
- (0, globals_1.expect)(payments).toBeInstanceOf(Array);
152
- (0, globals_1.expect)(payments.length).toBeGreaterThan(0);
153
- (0, globals_1.expect)(payments[0]).toHaveProperty('id');
154
- (0, globals_1.expect)(payments[0]).toHaveProperty('payment_method_id');
155
- (0, globals_1.expect)(payments[0]).toHaveProperty('payment_method_name');
156
- (0, globals_1.expect)(payments[0]).toHaveProperty('total', globals_1.expect.any(Number));
157
- (0, globals_1.expect)(payments[0]).toHaveProperty('tip', globals_1.expect.any(Number));
158
- (0, globals_1.expect)(payments[0]).toHaveProperty('status');
159
- (0, globals_1.expect)(payments[0]).toHaveProperty('currency');
160
- (0, globals_1.expect)(payments[0]).toHaveProperty('date');
161
- }));
162
- // TODO: Fix API Resource does not exist
163
- globals_1.test.skip('updateOrder', () => __awaiter(void 0, void 0, void 0, function* () {
164
- const order = yield lightspeedConsumer.pos.updateOrder(orders[0].id, {});
165
- (0, globals_1.expect)(order).toBeTruthy();
166
- (0, globals_1.expect)(order).toHaveProperty('id', globals_1.expect.any(String));
167
- }));
168
- (0, globals_1.test)('getProducts', () => __awaiter(void 0, void 0, void 0, function* () {
169
- const products = yield popinaConsumer.pos.getProducts();
170
- (0, globals_1.expect)(products).toBeInstanceOf(Array);
171
- (0, globals_1.expect)(products.length).toBeGreaterThan(0);
172
- }));
173
- (0, globals_1.test)('getProductCategories', () => __awaiter(void 0, void 0, void 0, function* () {
174
- const productCategories = yield popinaConsumer.pos.getProductCategories();
175
- (0, globals_1.expect)(productCategories).toBeInstanceOf(Array);
176
- (0, globals_1.expect)(productCategories.length).toBeGreaterThan(0);
177
- }));
178
- (0, globals_1.test)('getAccountingCategories', () => __awaiter(void 0, void 0, void 0, function* () {
179
- const accountingCategories = yield popinaConsumer.pos.getAccountingCategories();
180
- (0, globals_1.expect)(accountingCategories).toBeInstanceOf(Array);
181
- (0, globals_1.expect)(accountingCategories.length).toBeGreaterThan(0);
182
- }));
@@ -1 +0,0 @@
1
- export {};
@@ -1,81 +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
- const flowName = 'Je suis un flux de test';
46
- let sync;
47
- let flow;
48
- (0, globals_1.beforeAll)(() => __awaiter(void 0, void 0, void 0, function* () {
49
- const syncId = process.env.CHIFT_TEST_SYNC_ID;
50
- sync = yield client.Syncs.getSyncById(syncId);
51
- }));
52
- (0, globals_1.test)('createFlow', () => __awaiter(void 0, void 0, void 0, function* () {
53
- flow = yield sync.createFlow({
54
- name: flowName,
55
- description: 'Flux de test',
56
- execution: {
57
- type: 'code',
58
- },
59
- trigger: {
60
- type: 'event',
61
- },
62
- config: {},
63
- }, (consumer, flowContext) => __awaiter(void 0, void 0, void 0, function* () {
64
- console.log(`Mon flow_id : ${flowContext.flow_id}`);
65
- console.log(`Bonjour, ceci est un test, on exécute le flux pour consumer: ${consumer}`);
66
- }));
67
- (0, globals_1.expect)(flow).toHaveProperty('flowId');
68
- (0, globals_1.expect)(flow).toHaveProperty('name', flowName);
69
- }));
70
- (0, globals_1.test)('getFlows', () => __awaiter(void 0, void 0, void 0, function* () {
71
- const flows = yield sync.getFlows();
72
- (0, globals_1.expect)(flows).toBeInstanceOf(Array);
73
- }));
74
- (0, globals_1.test)('getFlowByName', () => __awaiter(void 0, void 0, void 0, function* () {
75
- const flowWithName = yield sync.getFlowByName(flow.name);
76
- (0, globals_1.expect)(flowWithName).toHaveProperty('name', flow.name);
77
- }));
78
- (0, globals_1.test)('getFlowById', () => __awaiter(void 0, void 0, void 0, function* () {
79
- const flowWithId = yield sync.getFlowById(flow.flowId);
80
- (0, globals_1.expect)(flowWithId).toHaveProperty('flowId', flow.flowId);
81
- }));
@@ -1 +0,0 @@
1
- export {};
@@ -1,53 +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
- (0, globals_1.test)('getSyncs', () => __awaiter(void 0, void 0, void 0, function* () {
46
- const syncs = yield client.Syncs.getSyncs();
47
- (0, globals_1.expect)(syncs).toBeInstanceOf(Array);
48
- }));
49
- (0, globals_1.test)('getSyncById', () => __awaiter(void 0, void 0, void 0, function* () {
50
- const syncId = process.env.CHIFT_TEST_SYNC_ID;
51
- const sync = yield client.Syncs.getSyncById(syncId);
52
- (0, globals_1.expect)(sync).toHaveProperty('syncid', syncId);
53
- }));
@@ -1 +0,0 @@
1
- export {};
@@ -1,120 +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
- var __importDefault = (this && this.__importDefault) || function (mod) {
35
- return (mod && mod.__esModule) ? mod : { "default": mod };
36
- };
37
- Object.defineProperty(exports, "__esModule", { value: true });
38
- const globals_1 = require("@jest/globals");
39
- const chift = __importStar(require("../../src/index"));
40
- const dotenv = __importStar(require("dotenv"));
41
- const axios_1 = __importDefault(require("axios"));
42
- dotenv.config();
43
- const client = new chift.API({
44
- baseUrl: process.env.CHIFT_BASE_URL,
45
- clientId: process.env.CHIFT_CLIENT_ID,
46
- clientSecret: process.env.CHIFT_CLIENT_SECRET,
47
- accountId: process.env.CHIFT_ACCOUNT_ID,
48
- });
49
- let webhook;
50
- (0, globals_1.beforeAll)(() => __awaiter(void 0, void 0, void 0, function* () {
51
- webhook = yield client.Webhooks.registerWebhook({
52
- event: 'account.connection.created',
53
- url: 'https://test',
54
- signingsecret: 'secret',
55
- });
56
- (0, globals_1.expect)(webhook).toHaveProperty('status', 'active');
57
- (0, globals_1.expect)(webhook).toHaveProperty('webhookid', globals_1.expect.any(String));
58
- (0, globals_1.expect)(webhook).toHaveProperty('accountid', globals_1.expect.any(String));
59
- (0, globals_1.expect)(webhook).toHaveProperty('createdby');
60
- (0, globals_1.expect)(webhook).toHaveProperty('createdon');
61
- (0, globals_1.expect)(webhook).toHaveProperty('event', 'account.connection.created');
62
- (0, globals_1.expect)(webhook).toHaveProperty('url', 'https://test');
63
- (0, globals_1.expect)(webhook).toHaveProperty('status', 'active');
64
- (0, globals_1.expect)(webhook).toHaveProperty('integrationid');
65
- }));
66
- (0, globals_1.test)('getWebhookTypes', () => __awaiter(void 0, void 0, void 0, function* () {
67
- const webhookTypes = yield client.Webhooks.getWebhookTypes();
68
- (0, globals_1.expect)(webhookTypes).toBeInstanceOf(Array);
69
- (0, globals_1.expect)(webhookTypes.length).toBeGreaterThan(0);
70
- (0, globals_1.expect)(webhookTypes[0]).toHaveProperty('event', globals_1.expect.any(String));
71
- (0, globals_1.expect)(webhookTypes[0]).toHaveProperty('api');
72
- }));
73
- (0, globals_1.test)('getWebhooks', () => __awaiter(void 0, void 0, void 0, function* () {
74
- const webhooks = yield client.Webhooks.getWebhooks();
75
- (0, globals_1.expect)(webhooks).toBeInstanceOf(Array);
76
- (0, globals_1.expect)(webhooks.length).toBeGreaterThan(0);
77
- (0, globals_1.expect)(webhooks[0]).toHaveProperty('webhookid', globals_1.expect.any(String));
78
- }));
79
- (0, globals_1.test)('getWebhookById', () => __awaiter(void 0, void 0, void 0, function* () {
80
- const webhookWithId = yield client.Webhooks.getWebhookById(webhook.webhookid);
81
- (0, globals_1.expect)(webhookWithId).toHaveProperty('webhookid', webhook.webhookid);
82
- (0, globals_1.expect)(webhookWithId).toHaveProperty('accountid', globals_1.expect.any(String));
83
- (0, globals_1.expect)(webhookWithId).toHaveProperty('createdby');
84
- (0, globals_1.expect)(webhookWithId).toHaveProperty('createdon');
85
- (0, globals_1.expect)(webhookWithId).toHaveProperty('event', globals_1.expect.any(String));
86
- (0, globals_1.expect)(webhookWithId).toHaveProperty('url', globals_1.expect.any(String));
87
- (0, globals_1.expect)(webhookWithId).toHaveProperty('status', globals_1.expect.any(String));
88
- (0, globals_1.expect)(webhookWithId).toHaveProperty('integrationid');
89
- }));
90
- (0, globals_1.test)('updateWebhookById', () => __awaiter(void 0, void 0, void 0, function* () {
91
- const updatedWebhook = yield client.Webhooks.updateWebhookById(webhook.webhookid, {
92
- status: 'inactive',
93
- });
94
- (0, globals_1.expect)(updatedWebhook).toHaveProperty('webhookid', globals_1.expect.any(String));
95
- (0, globals_1.expect)(updatedWebhook).toHaveProperty('accountid', globals_1.expect.any(String));
96
- (0, globals_1.expect)(updatedWebhook).toHaveProperty('createdby');
97
- (0, globals_1.expect)(updatedWebhook).toHaveProperty('createdon');
98
- (0, globals_1.expect)(updatedWebhook).toHaveProperty('event', 'account.connection.created');
99
- (0, globals_1.expect)(updatedWebhook).toHaveProperty('url', 'https://test');
100
- (0, globals_1.expect)(updatedWebhook).toHaveProperty('status', 'inactive');
101
- (0, globals_1.expect)(updatedWebhook).toHaveProperty('integrationid');
102
- }));
103
- (0, globals_1.test)('getWebhookLogsByWebhookId', () => __awaiter(void 0, void 0, void 0, function* () {
104
- const webhookLogs = yield client.Webhooks.getWebhookLogsByWebhookId(webhook.webhookid);
105
- (0, globals_1.expect)(webhookLogs).toBeInstanceOf(Array);
106
- }));
107
- (0, globals_1.afterAll)(() => __awaiter(void 0, void 0, void 0, function* () {
108
- globals_1.expect.assertions(1);
109
- try {
110
- yield client.Webhooks.unRegisterWebhook(webhook.webhookid);
111
- yield client.Webhooks.getWebhookById(webhook.webhookid);
112
- }
113
- catch (e) {
114
- if (axios_1.default.isAxiosError(e)) {
115
- (0, globals_1.expect)(e.message).toMatch('Request failed with status code 404');
116
- return;
117
- }
118
- throw e;
119
- }
120
- }));
package/jest.config.ts DELETED
@@ -1,195 +0,0 @@
1
- /*
2
- * For a detailed explanation regarding each configuration property and type check, visit:
3
- * https://jestjs.io/docs/configuration
4
- */
5
-
6
- export default {
7
- // All imported modules in your tests should be mocked automatically
8
- // automock: false,
9
-
10
- // Stop running tests after `n` failures
11
- // bail: 0,
12
-
13
- // The directory where Jest should store its cached dependency information
14
- // cacheDirectory: "/private/var/folders/z7/d2q2nkfs49x74tqyg3t_7zt40000gn/T/jest_dx",
15
-
16
- // Automatically clear mock calls, instances, contexts and results before every test
17
- clearMocks: true,
18
-
19
- // Indicates whether the coverage information should be collected while executing the test
20
- collectCoverage: true,
21
-
22
- // An array of glob patterns indicating a set of files for which coverage information should be collected
23
- // collectCoverageFrom: undefined,
24
-
25
- // The directory where Jest should output its coverage files
26
- coverageDirectory: 'coverage',
27
-
28
- // An array of regexp pattern strings used to skip coverage collection
29
- // coveragePathIgnorePatterns: [
30
- // "/node_modules/"
31
- // ],
32
-
33
- // Indicates which provider should be used to instrument code for coverage
34
- coverageProvider: 'v8',
35
-
36
- // A list of reporter names that Jest uses when writing coverage reports
37
- // coverageReporters: [
38
- // "json",
39
- // "text",
40
- // "lcov",
41
- // "clover"
42
- // ],
43
-
44
- // An object that configures minimum threshold enforcement for coverage results
45
- // coverageThreshold: undefined,
46
-
47
- // A path to a custom dependency extractor
48
- // dependencyExtractor: undefined,
49
-
50
- // Make calling deprecated APIs throw helpful error messages
51
- // errorOnDeprecated: false,
52
-
53
- // The default configuration for fake timers
54
- // fakeTimers: {
55
- // "enableGlobally": false
56
- // },
57
-
58
- // Force coverage collection from ignored files using an array of glob patterns
59
- // forceCoverageMatch: [],
60
-
61
- // A path to a module which exports an async function that is triggered once before all test suites
62
- // globalSetup: undefined,
63
-
64
- // A path to a module which exports an async function that is triggered once after all test suites
65
- // globalTeardown: undefined,
66
-
67
- // A set of global variables that need to be available in all test environments
68
- // globals: {},
69
-
70
- // The maximum amount of workers used to run your tests. Can be specified as % or a number. E.g. maxWorkers: 10% will use 10% of your CPU amount + 1 as the maximum worker number. maxWorkers: 2 will use a maximum of 2 workers.
71
- // maxWorkers: "50%",
72
-
73
- // An array of directory names to be searched recursively up from the requiring module's location
74
- moduleDirectories: ['node_modules', 'src'],
75
-
76
- // An array of file extensions your modules use
77
- // moduleFileExtensions: [
78
- // "js",
79
- // "mjs",
80
- // "cjs",
81
- // "jsx",
82
- // "ts",
83
- // "tsx",
84
- // "json",
85
- // "node"
86
- // ],
87
-
88
- // A map from regular expressions to module names or to arrays of module names that allow to stub out resources with a single module
89
- // moduleNameMapper: {},
90
-
91
- // An array of regexp pattern strings, matched against all module paths before considered 'visible' to the module loader
92
- // modulePathIgnorePatterns: [],
93
-
94
- // Activates notifications for test results
95
- // notify: false,
96
-
97
- // An enum that specifies notification mode. Requires { notify: true }
98
- // notifyMode: "failure-change",
99
-
100
- // A preset that is used as a base for Jest's configuration
101
- preset: 'ts-jest',
102
-
103
- // Run tests from one or more projects
104
- // projects: undefined,
105
-
106
- // Use this configuration option to add custom reporters to Jest
107
- // reporters: undefined,
108
-
109
- // Automatically reset mock state before every test
110
- // resetMocks: false,
111
-
112
- // Reset the module registry before running each individual test
113
- // resetModules: false,
114
-
115
- // A path to a custom resolver
116
- // resolver: undefined,
117
-
118
- // Automatically restore mock state and implementation before every test
119
- // restoreMocks: false,
120
-
121
- // The root directory that Jest should scan for tests and modules within
122
- // rootDir: undefined,
123
-
124
- // A list of paths to directories that Jest should use to search for files in
125
- // roots: [
126
- // "<rootDir>"
127
- // ],
128
-
129
- // Allows you to use a custom runner instead of Jest's default test runner
130
- // runner: "jest-runner",
131
-
132
- // The paths to modules that run some code to configure or set up the testing environment before each test
133
- // setupFiles: [],
134
-
135
- // A list of paths to modules that run some code to configure or set up the testing framework before each test
136
- // setupFilesAfterEnv: [],
137
-
138
- // The number of seconds after which a test is considered as slow and reported as such in the results.
139
- // slowTestThreshold: 5,
140
-
141
- // A list of paths to snapshot serializer modules Jest should use for snapshot testing
142
- // snapshotSerializers: [],
143
-
144
- // The test environment that will be used for testing
145
- testEnvironment: 'node',
146
-
147
- // Options that will be passed to the testEnvironment
148
- // testEnvironmentOptions: {},
149
-
150
- // Adds a location field to test results
151
- // testLocationInResults: false,
152
-
153
- // The glob patterns Jest uses to detect test files
154
- // testMatch: [
155
- // "**/__tests__/**/*.[jt]s?(x)",
156
- // "**/?(*.)+(spec|test).[tj]s?(x)"
157
- // ],
158
-
159
- // An array of regexp pattern strings that are matched against all test paths, matched tests are skipped
160
- // testPathIgnorePatterns: [
161
- // "/node_modules/"
162
- // ],
163
-
164
- // The regexp pattern or array of patterns that Jest uses to detect test files
165
- // testRegex: [],
166
-
167
- // This option allows the use of a custom results processor
168
- // testResultsProcessor: undefined,
169
-
170
- // This option allows use of a custom test runner
171
- // testRunner: "jest-circus/runner",
172
-
173
- // A map from regular expressions to paths to transformers
174
- //transform: undefined,
175
-
176
- // An array of regexp pattern strings that are matched against all source file paths, matched files will skip transformation
177
- // transformIgnorePatterns: [
178
- // "/node_modules/",
179
- // "\\.pnp\\.[^\\/]+$"
180
- // ],
181
-
182
- // An array of regexp pattern strings that are matched against all modules before the module loader will automatically return a mock for them
183
- // unmockedModulePathPatterns: undefined,
184
-
185
- // Indicates whether each individual test should be reported during the run
186
- // verbose: undefined,
187
-
188
- // An array of regexp patterns that are matched against all source file paths before re-running tests in watch mode
189
- // watchPathIgnorePatterns: [],
190
-
191
- // Whether to use watchman for file crawling
192
- // watchman: true,
193
-
194
- testTimeout: 60000,
195
- };
@@ -1,22 +0,0 @@
1
- import { InternalAPI } from '../modules/internalApi';
2
- import { RequestFactory, ApiFor } from '../types/api';
3
-
4
- export function createApiFor<TFactory extends RequestFactory>(
5
- factory: TFactory,
6
- internalApi: InternalAPI,
7
- consumerName: string,
8
- consumerId: string
9
- ) {
10
- return new Proxy(factory, {
11
- get(target: any, property) {
12
- return (...args: any[]) => {
13
- const requestData = target[property](...args);
14
- requestData.property = property;
15
- requestData.consumerName = consumerName;
16
- requestData.consumerId = consumerId;
17
- requestData.url = requestData.url.replace('{consumer_id}', consumerId);
18
- return internalApi.makeRequest(requestData);
19
- };
20
- },
21
- }) as unknown as ApiFor<TFactory>;
22
- }
@@ -1,3 +0,0 @@
1
- export default {
2
- BASE_URL: 'https://api.chift.eu',
3
- };