@chift/chift-nodejs 1.0.15 → 1.0.17
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/.github/workflows/ci.yml +10 -10
- package/CHANGELOG.md +15 -2
- package/README.md +3 -3
- package/dist/src/modules/accounting.d.ts +3 -3
- package/dist/src/modules/api.d.ts +4374 -2758
- package/dist/src/modules/consumer.d.ts +829 -509
- package/dist/src/modules/consumer.js +3 -0
- package/dist/src/modules/consumers.d.ts +4395 -2787
- package/dist/src/modules/datastores.d.ts +2 -2
- package/dist/src/modules/ecommerce.d.ts +2 -2
- package/dist/src/modules/integrations.d.ts +9 -4
- package/dist/src/modules/invoicing.d.ts +3 -3
- package/dist/src/modules/payment.d.ts +14 -0
- package/dist/src/modules/payment.js +41 -0
- package/dist/src/modules/sync.d.ts +3507 -2223
- package/dist/src/modules/sync.js +1 -1
- package/dist/src/modules/webhooks.d.ts +4 -1
- package/dist/src/types/sync.d.ts +22 -5
- package/dist/test/modules/accounting.test.js +58 -50
- package/dist/test/modules/consumer.test.js +4 -4
- package/dist/test/modules/consumers.test.js +4 -4
- package/dist/test/modules/ecommerce.test.js +23 -19
- package/dist/test/modules/integrations.test.js +4 -4
- package/dist/test/modules/invoicing.test.js +16 -9
- package/dist/test/modules/payment.test.d.ts +1 -0
- package/dist/test/modules/payment.test.js +88 -0
- package/dist/test/modules/pms.test.d.ts +1 -0
- package/dist/test/modules/pms.test.js +90 -0
- package/dist/test/modules/pos.test.js +31 -34
- package/dist/test/modules/sync.test.js +31 -19
- package/dist/test/modules/syncs.test.js +4 -4
- package/dist/test/modules/webhooks.test.js +4 -4
- package/package.json +1 -1
- package/src/modules/accounting.ts +3 -3
- package/src/modules/consumer.ts +6 -1
- package/src/modules/ecommerce.ts +4 -2
- package/src/modules/invoicing.ts +7 -3
- package/src/modules/payment.ts +59 -0
- package/src/modules/sync.ts +1 -1
- package/src/types/public-api/schema.d.ts +4165 -900
- package/src/types/sync.ts +20 -5
- package/test/modules/accounting.test.ts +69 -50
- package/test/modules/consumer.test.ts +5 -5
- package/test/modules/consumers.test.ts +4 -4
- package/test/modules/ecommerce.test.ts +25 -20
- package/test/modules/integrations.test.ts +4 -4
- package/test/modules/invoicing.test.ts +20 -10
- package/test/modules/payment.test.ts +65 -0
- package/test/modules/pms.test.ts +69 -0
- package/test/modules/pos.test.ts +32 -34
- package/test/modules/sync.test.ts +33 -19
- package/test/modules/syncs.test.ts +4 -4
- package/test/modules/webhooks.test.ts +4 -4
- package/.eslintcache +0 -1
- package/coverage/clover.xml +0 -1645
- package/coverage/coverage-final.json +0 -19
- package/coverage/lcov-report/base.css +0 -224
- package/coverage/lcov-report/block-navigation.js +0 -87
- package/coverage/lcov-report/favicon.png +0 -0
- package/coverage/lcov-report/index.html +0 -146
- package/coverage/lcov-report/prettify.css +0 -1
- package/coverage/lcov-report/prettify.js +0 -2
- package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
- package/coverage/lcov-report/sorter.js +0 -196
- package/coverage/lcov-report/src/helpers/index.html +0 -131
- package/coverage/lcov-report/src/helpers/openapi.ts.html +0 -151
- package/coverage/lcov-report/src/helpers/settings.ts.html +0 -94
- package/coverage/lcov-report/src/index.html +0 -116
- package/coverage/lcov-report/src/index.ts.html +0 -88
- package/coverage/lcov-report/src/modules/accounting.ts.html +0 -1156
- package/coverage/lcov-report/src/modules/api.ts.html +0 -190
- package/coverage/lcov-report/src/modules/consumer.ts.html +0 -616
- package/coverage/lcov-report/src/modules/consumers.ts.html +0 -331
- package/coverage/lcov-report/src/modules/custom.ts.html +0 -193
- package/coverage/lcov-report/src/modules/datastores.ts.html +0 -142
- package/coverage/lcov-report/src/modules/ecommerce.ts.html +0 -331
- package/coverage/lcov-report/src/modules/flow.ts.html +0 -589
- package/coverage/lcov-report/src/modules/index.html +0 -326
- package/coverage/lcov-report/src/modules/integrations.ts.html +0 -151
- package/coverage/lcov-report/src/modules/internalApi.ts.html +0 -586
- package/coverage/lcov-report/src/modules/invoicing.ts.html +0 -391
- package/coverage/lcov-report/src/modules/pos.ts.html +0 -421
- package/coverage/lcov-report/src/modules/sync.ts.html +0 -316
- package/coverage/lcov-report/src/modules/syncs.ts.html +0 -169
- package/coverage/lcov-report/src/modules/webhooks.ts.html +0 -343
- package/coverage/lcov.info +0 -1976
- package/dist/src/types/public-api/schema.d.ts +0 -11959
- package/dist/src/types/public-api/schema.js +0 -6
- package/src/types/public-api/schema.ts +0 -12029
- package/test/set_envs.sh +0 -14
|
@@ -0,0 +1,90 @@
|
|
|
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_BACKBONE_API,
|
|
41
|
+
clientId: process.env.CHIFT_TESTING_CLIENTID,
|
|
42
|
+
clientSecret: process.env.CHIFT_TESTING_CLIENTSECRET,
|
|
43
|
+
accountId: process.env.CHIFT_TESTING_ACCOUNTID,
|
|
44
|
+
});
|
|
45
|
+
// TODO: Setup PMS test data
|
|
46
|
+
const consumerId = process.env.CHIFT_PMS_CONSUMER_ID;
|
|
47
|
+
let consumer;
|
|
48
|
+
(0, globals_1.beforeAll)(() => __awaiter(void 0, void 0, void 0, function* () {
|
|
49
|
+
consumer = yield client.Consumers.getConsumerById(consumerId);
|
|
50
|
+
}));
|
|
51
|
+
globals_1.test.skip('getLocations', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
52
|
+
const locations = yield consumer.pms.getLocations();
|
|
53
|
+
(0, globals_1.expect)(locations).toBeInstanceOf(Array);
|
|
54
|
+
(0, globals_1.expect)(locations.length).toBeGreaterThan(0);
|
|
55
|
+
(0, globals_1.expect)(locations[0]).toHaveProperty('id', globals_1.expect.any(String));
|
|
56
|
+
}));
|
|
57
|
+
globals_1.test.skip('getOrders', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
58
|
+
const orders = yield consumer.pms.getOrders({
|
|
59
|
+
date_from: '2023-01-01',
|
|
60
|
+
date_to: '2023-01-31',
|
|
61
|
+
});
|
|
62
|
+
(0, globals_1.expect)(orders).toBeInstanceOf(Array);
|
|
63
|
+
(0, globals_1.expect)(orders.length).toBeGreaterThan(0);
|
|
64
|
+
(0, globals_1.expect)(orders[0]).toHaveProperty('id', globals_1.expect.any(String));
|
|
65
|
+
}));
|
|
66
|
+
globals_1.test.skip('getPaymentMethods', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
67
|
+
const paymentMethods = yield consumer.pms.getPaymentMethods();
|
|
68
|
+
(0, globals_1.expect)(paymentMethods).toBeInstanceOf(Array);
|
|
69
|
+
(0, globals_1.expect)(paymentMethods.length).toBeGreaterThan(0);
|
|
70
|
+
(0, globals_1.expect)(paymentMethods[0]).toHaveProperty('id', globals_1.expect.any(String));
|
|
71
|
+
}));
|
|
72
|
+
globals_1.test.skip('getClosure', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
73
|
+
const closure = yield consumer.pms.getClosure('2023-01-01');
|
|
74
|
+
(0, globals_1.expect)(closure).toHaveProperty('id', globals_1.expect.any(String));
|
|
75
|
+
}));
|
|
76
|
+
globals_1.test.skip('getPayments', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
77
|
+
const payments = yield consumer.pms.getPayments({
|
|
78
|
+
date_from: '2023-01-01',
|
|
79
|
+
date_to: '2023-01-31',
|
|
80
|
+
});
|
|
81
|
+
(0, globals_1.expect)(payments).toBeInstanceOf(Array);
|
|
82
|
+
(0, globals_1.expect)(payments.length).toBeGreaterThan(0);
|
|
83
|
+
(0, globals_1.expect)(payments[0]).toHaveProperty('id', globals_1.expect.any(String));
|
|
84
|
+
}));
|
|
85
|
+
globals_1.test.skip('getAccountingCategories', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
86
|
+
const accountingCategories = yield consumer.pms.getAccountingCategories();
|
|
87
|
+
(0, globals_1.expect)(accountingCategories).toBeInstanceOf(Array);
|
|
88
|
+
(0, globals_1.expect)(accountingCategories.length).toBeGreaterThan(0);
|
|
89
|
+
(0, globals_1.expect)(accountingCategories[0]).toHaveProperty('id', globals_1.expect.any(String));
|
|
90
|
+
}));
|
|
@@ -37,35 +37,29 @@ const chift = __importStar(require("../../src/index"));
|
|
|
37
37
|
const dotenv = __importStar(require("dotenv"));
|
|
38
38
|
dotenv.config();
|
|
39
39
|
const client = new chift.API({
|
|
40
|
-
baseUrl: process.env.
|
|
41
|
-
clientId: process.env.
|
|
42
|
-
clientSecret: process.env.
|
|
43
|
-
accountId: process.env.
|
|
40
|
+
baseUrl: process.env.CHIFT_BACKBONE_API,
|
|
41
|
+
clientId: process.env.CHIFT_TESTING_CLIENTID,
|
|
42
|
+
clientSecret: process.env.CHIFT_TESTING_CLIENTSECRET,
|
|
43
|
+
accountId: process.env.CHIFT_TESTING_ACCOUNTID,
|
|
44
44
|
});
|
|
45
45
|
// Split testing between two APIs to support all endpoints
|
|
46
|
-
const
|
|
47
|
-
|
|
48
|
-
const popinaConsumerId = process.env.CHIFT_POPINA_CONSUMER_ID;
|
|
49
|
-
let cashpadConsumer;
|
|
50
|
-
let lightspeedConsumer;
|
|
51
|
-
let popinaConsumer;
|
|
46
|
+
const consumerId = process.env.CHIFT_POS_CONSUMER_ID;
|
|
47
|
+
let consumer;
|
|
52
48
|
(0, globals_1.beforeAll)(() => __awaiter(void 0, void 0, void 0, function* () {
|
|
53
|
-
|
|
54
|
-
lightspeedConsumer = yield client.Consumers.getConsumerById(lightspeedConsumerId);
|
|
55
|
-
popinaConsumer = yield client.Consumers.getConsumerById(popinaConsumerId);
|
|
49
|
+
consumer = yield client.Consumers.getConsumerById(consumerId);
|
|
56
50
|
}));
|
|
57
51
|
(0, globals_1.test)('getLocations', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
58
|
-
const locations = yield
|
|
52
|
+
const locations = yield consumer.pos.getLocations();
|
|
59
53
|
(0, globals_1.expect)(locations).toBeInstanceOf(Array);
|
|
60
54
|
(0, globals_1.expect)(locations.length).toBeGreaterThan(0);
|
|
61
55
|
(0, globals_1.expect)(locations[0]).toHaveProperty('id', globals_1.expect.any(String));
|
|
62
56
|
(0, globals_1.expect)(locations[0]).toHaveProperty('name', globals_1.expect.any(String));
|
|
63
57
|
}));
|
|
64
58
|
let orders;
|
|
65
|
-
|
|
66
|
-
orders = yield
|
|
67
|
-
date_from: '2023-01-
|
|
68
|
-
date_to: '2023-
|
|
59
|
+
globals_1.test.skip('getOrders', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
60
|
+
orders = yield consumer.pos.getOrders({
|
|
61
|
+
date_from: '2023-01-08',
|
|
62
|
+
date_to: '2023-01-01',
|
|
69
63
|
});
|
|
70
64
|
(0, globals_1.expect)(orders).toBeInstanceOf(Array);
|
|
71
65
|
(0, globals_1.expect)(orders.length).toBeGreaterThan(0);
|
|
@@ -78,7 +72,7 @@ globals_1.test.skip('createCustomer', () => __awaiter(void 0, void 0, void 0, fu
|
|
|
78
72
|
last_name: 'Doe',
|
|
79
73
|
email: 'test@test.com',
|
|
80
74
|
};
|
|
81
|
-
const customer = yield
|
|
75
|
+
const customer = yield consumer.pos.createCustomer(body);
|
|
82
76
|
(0, globals_1.expect)(customer).toBeTruthy();
|
|
83
77
|
(0, globals_1.expect)(customer).toHaveProperty('id', globals_1.expect.any(String));
|
|
84
78
|
(0, globals_1.expect)(customer).toHaveProperty('name');
|
|
@@ -86,14 +80,17 @@ globals_1.test.skip('createCustomer', () => __awaiter(void 0, void 0, void 0, fu
|
|
|
86
80
|
// TODO: Fix timeout error
|
|
87
81
|
let customers = [];
|
|
88
82
|
globals_1.test.skip('getCustomers', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
89
|
-
customers = yield
|
|
83
|
+
customers = yield consumer.pos.getCustomers();
|
|
90
84
|
(0, globals_1.expect)(customers).toBeInstanceOf(Array);
|
|
91
85
|
(0, globals_1.expect)(customers.length).toBeGreaterThan(0);
|
|
92
86
|
(0, globals_1.expect)(customers[0]).toHaveProperty('id', globals_1.expect.any(String));
|
|
93
87
|
}));
|
|
94
88
|
// TODO: Fix The day parameter is missing error
|
|
95
89
|
globals_1.test.skip('getOrder', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
96
|
-
|
|
90
|
+
if (!orders.length) {
|
|
91
|
+
throw new Error('No orders found to test getOrder');
|
|
92
|
+
}
|
|
93
|
+
const order = yield consumer.pos.getOrder(orders[0].id);
|
|
97
94
|
(0, globals_1.expect)(order).toBeTruthy();
|
|
98
95
|
(0, globals_1.expect)(order).toHaveProperty('id', globals_1.expect.any(String));
|
|
99
96
|
(0, globals_1.expect)(order).toHaveProperty('order_number');
|
|
@@ -116,13 +113,13 @@ globals_1.test.skip('getOrder', () => __awaiter(void 0, void 0, void 0, function
|
|
|
116
113
|
}));
|
|
117
114
|
// TODO: Fix getCustomers first
|
|
118
115
|
globals_1.test.skip('getCustomer', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
119
|
-
const customer = yield
|
|
116
|
+
const customer = yield consumer.pos.getCustomer(customers[0].id);
|
|
120
117
|
(0, globals_1.expect)(customer).toBeTruthy();
|
|
121
118
|
(0, globals_1.expect)(customer).toHaveProperty('id', globals_1.expect.any(String));
|
|
122
119
|
(0, globals_1.expect)(customer).toHaveProperty('name');
|
|
123
120
|
}));
|
|
124
121
|
(0, globals_1.test)('getPaymentMethods', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
125
|
-
const paymentMethods = yield
|
|
122
|
+
const paymentMethods = yield consumer.pos.getPaymentMethods();
|
|
126
123
|
(0, globals_1.expect)(paymentMethods).toBeInstanceOf(Array);
|
|
127
124
|
(0, globals_1.expect)(paymentMethods.length).toBeGreaterThan(0);
|
|
128
125
|
(0, globals_1.expect)(paymentMethods[0]).toHaveProperty('id', globals_1.expect.any(String));
|
|
@@ -130,7 +127,7 @@ globals_1.test.skip('getCustomer', () => __awaiter(void 0, void 0, void 0, funct
|
|
|
130
127
|
(0, globals_1.expect)(paymentMethods[0]).toHaveProperty('extra');
|
|
131
128
|
}));
|
|
132
129
|
(0, globals_1.test)('getSales', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
133
|
-
const sales = yield
|
|
130
|
+
const sales = yield consumer.pos.getSales({
|
|
134
131
|
date_from: '2022-08-11',
|
|
135
132
|
date_to: '2022-08-12',
|
|
136
133
|
});
|
|
@@ -139,14 +136,14 @@ globals_1.test.skip('getCustomer', () => __awaiter(void 0, void 0, void 0, funct
|
|
|
139
136
|
(0, globals_1.expect)(sales).toHaveProperty('taxes', globals_1.expect.any(Array));
|
|
140
137
|
}));
|
|
141
138
|
(0, globals_1.test)('getClosure', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
142
|
-
const closure = yield
|
|
139
|
+
const closure = yield consumer.pos.getClosure('2022-08-11');
|
|
143
140
|
(0, globals_1.expect)(closure).toHaveProperty('date', globals_1.expect.any(String));
|
|
144
141
|
(0, globals_1.expect)(closure).toHaveProperty('status');
|
|
145
142
|
}));
|
|
146
|
-
|
|
147
|
-
const payments = yield
|
|
148
|
-
date_from: '2023-01-
|
|
149
|
-
date_to: '2023-
|
|
143
|
+
globals_1.test.skip('getPayments', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
144
|
+
const payments = yield consumer.pos.getPayments({
|
|
145
|
+
date_from: '2023-01-08',
|
|
146
|
+
date_to: '2023-01-01',
|
|
150
147
|
});
|
|
151
148
|
(0, globals_1.expect)(payments).toBeInstanceOf(Array);
|
|
152
149
|
(0, globals_1.expect)(payments.length).toBeGreaterThan(0);
|
|
@@ -161,22 +158,22 @@ globals_1.test.skip('getCustomer', () => __awaiter(void 0, void 0, void 0, funct
|
|
|
161
158
|
}));
|
|
162
159
|
// TODO: Fix API Resource does not exist
|
|
163
160
|
globals_1.test.skip('updateOrder', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
164
|
-
const order = yield
|
|
161
|
+
const order = yield consumer.pos.updateOrder(orders[0].id, {});
|
|
165
162
|
(0, globals_1.expect)(order).toBeTruthy();
|
|
166
163
|
(0, globals_1.expect)(order).toHaveProperty('id', globals_1.expect.any(String));
|
|
167
164
|
}));
|
|
168
|
-
|
|
169
|
-
const products = yield
|
|
165
|
+
globals_1.test.skip('getProducts', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
166
|
+
const products = yield consumer.pos.getProducts();
|
|
170
167
|
(0, globals_1.expect)(products).toBeInstanceOf(Array);
|
|
171
168
|
(0, globals_1.expect)(products.length).toBeGreaterThan(0);
|
|
172
169
|
}));
|
|
173
170
|
(0, globals_1.test)('getProductCategories', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
174
|
-
const productCategories = yield
|
|
171
|
+
const productCategories = yield consumer.pos.getProductCategories();
|
|
175
172
|
(0, globals_1.expect)(productCategories).toBeInstanceOf(Array);
|
|
176
173
|
(0, globals_1.expect)(productCategories.length).toBeGreaterThan(0);
|
|
177
174
|
}));
|
|
178
175
|
(0, globals_1.test)('getAccountingCategories', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
179
|
-
const accountingCategories = yield
|
|
176
|
+
const accountingCategories = yield consumer.pos.getAccountingCategories();
|
|
180
177
|
(0, globals_1.expect)(accountingCategories).toBeInstanceOf(Array);
|
|
181
178
|
(0, globals_1.expect)(accountingCategories.length).toBeGreaterThan(0);
|
|
182
179
|
}));
|
|
@@ -37,45 +37,57 @@ const chift = __importStar(require("../../src/index"));
|
|
|
37
37
|
const dotenv = __importStar(require("dotenv"));
|
|
38
38
|
dotenv.config();
|
|
39
39
|
const client = new chift.API({
|
|
40
|
-
baseUrl: process.env.
|
|
41
|
-
clientId: process.env.
|
|
42
|
-
clientSecret: process.env.
|
|
43
|
-
accountId: process.env.
|
|
40
|
+
baseUrl: process.env.CHIFT_BACKBONE_API,
|
|
41
|
+
clientId: process.env.CHIFT_TESTING_CLIENTID,
|
|
42
|
+
clientSecret: process.env.CHIFT_TESTING_CLIENTSECRET,
|
|
43
|
+
accountId: process.env.CHIFT_TESTING_ACCOUNTID,
|
|
44
44
|
});
|
|
45
|
-
const flowName = '
|
|
45
|
+
const flowName = 'CI GENERATED';
|
|
46
46
|
let sync;
|
|
47
|
-
let flow;
|
|
48
47
|
(0, globals_1.beforeAll)(() => __awaiter(void 0, void 0, void 0, function* () {
|
|
49
48
|
const syncId = process.env.CHIFT_TEST_SYNC_ID;
|
|
50
49
|
sync = yield client.Syncs.getSyncById(syncId);
|
|
51
50
|
}));
|
|
52
51
|
(0, globals_1.test)('createFlow', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
53
|
-
flow = yield sync.createFlow({
|
|
52
|
+
const flow = yield sync.createFlow({
|
|
54
53
|
name: flowName,
|
|
55
|
-
description: '
|
|
54
|
+
description: 'Generated by Chift Node.js sdk',
|
|
56
55
|
execution: {
|
|
57
|
-
type: '
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
56
|
+
type: 'module',
|
|
57
|
+
data: {
|
|
58
|
+
name: 'POS to accounting',
|
|
59
|
+
},
|
|
61
60
|
},
|
|
61
|
+
triggers: [
|
|
62
|
+
{
|
|
63
|
+
id: 'trigger1',
|
|
64
|
+
type: 'event',
|
|
65
|
+
},
|
|
66
|
+
],
|
|
62
67
|
config: {},
|
|
63
68
|
}, (consumer, flowContext) => __awaiter(void 0, void 0, void 0, function* () {
|
|
64
|
-
console.log(`
|
|
65
|
-
console.log(`
|
|
69
|
+
console.log(`consumer: ${consumer}`);
|
|
70
|
+
console.log(`flow_id : ${flowContext.flow_id}`);
|
|
66
71
|
}));
|
|
67
72
|
(0, globals_1.expect)(flow).toHaveProperty('flowId');
|
|
68
73
|
(0, globals_1.expect)(flow).toHaveProperty('name', flowName);
|
|
69
74
|
}));
|
|
75
|
+
let flows = [];
|
|
70
76
|
(0, globals_1.test)('getFlows', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
71
|
-
|
|
77
|
+
flows = yield sync.getFlows();
|
|
72
78
|
(0, globals_1.expect)(flows).toBeInstanceOf(Array);
|
|
73
79
|
}));
|
|
74
80
|
(0, globals_1.test)('getFlowByName', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
75
|
-
|
|
76
|
-
|
|
81
|
+
if (!flows.length) {
|
|
82
|
+
throw new Error('No flows found to test getFlowByName');
|
|
83
|
+
}
|
|
84
|
+
const flowWithName = yield sync.getFlowByName(flows[0].name);
|
|
85
|
+
(0, globals_1.expect)(flowWithName).toHaveProperty('name', flows[0].name);
|
|
77
86
|
}));
|
|
78
87
|
(0, globals_1.test)('getFlowById', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
79
|
-
|
|
80
|
-
|
|
88
|
+
if (!flows.length) {
|
|
89
|
+
throw new Error('No flows found to test getFlowById');
|
|
90
|
+
}
|
|
91
|
+
const flowWithId = yield sync.getFlowById(flows[0].flowId);
|
|
92
|
+
(0, globals_1.expect)(flowWithId).toHaveProperty('flowId', flows[0].flowId);
|
|
81
93
|
}));
|
|
@@ -37,10 +37,10 @@ const chift = __importStar(require("../../src/index"));
|
|
|
37
37
|
const dotenv = __importStar(require("dotenv"));
|
|
38
38
|
dotenv.config();
|
|
39
39
|
const client = new chift.API({
|
|
40
|
-
baseUrl: process.env.
|
|
41
|
-
clientId: process.env.
|
|
42
|
-
clientSecret: process.env.
|
|
43
|
-
accountId: process.env.
|
|
40
|
+
baseUrl: process.env.CHIFT_BACKBONE_API,
|
|
41
|
+
clientId: process.env.CHIFT_TESTING_CLIENTID,
|
|
42
|
+
clientSecret: process.env.CHIFT_TESTING_CLIENTSECRET,
|
|
43
|
+
accountId: process.env.CHIFT_TESTING_ACCOUNTID,
|
|
44
44
|
});
|
|
45
45
|
(0, globals_1.test)('getSyncs', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
46
46
|
const syncs = yield client.Syncs.getSyncs();
|
|
@@ -41,10 +41,10 @@ const dotenv = __importStar(require("dotenv"));
|
|
|
41
41
|
const axios_1 = __importDefault(require("axios"));
|
|
42
42
|
dotenv.config();
|
|
43
43
|
const client = new chift.API({
|
|
44
|
-
baseUrl: process.env.
|
|
45
|
-
clientId: process.env.
|
|
46
|
-
clientSecret: process.env.
|
|
47
|
-
accountId: process.env.
|
|
44
|
+
baseUrl: process.env.CHIFT_BACKBONE_API,
|
|
45
|
+
clientId: process.env.CHIFT_TESTING_CLIENTID,
|
|
46
|
+
clientSecret: process.env.CHIFT_TESTING_CLIENTSECRET,
|
|
47
|
+
accountId: process.env.CHIFT_TESTING_ACCOUNTID,
|
|
48
48
|
});
|
|
49
49
|
let webhook;
|
|
50
50
|
(0, globals_1.beforeAll)(() => __awaiter(void 0, void 0, void 0, function* () {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@chift/chift-nodejs",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.17",
|
|
4
4
|
"description": "The Chift NodeJS library provides convenient access to the Chift API from applications written in the NodeJS language (Javascript/Typescript).",
|
|
5
5
|
"main": "dist/src/index.js",
|
|
6
6
|
"types": "dist/src/index.d.ts",
|
|
@@ -184,7 +184,7 @@ const accountingFactory = {
|
|
|
184
184
|
};
|
|
185
185
|
},
|
|
186
186
|
getInvoicesByType(
|
|
187
|
-
invoice_type: components['schemas']['
|
|
187
|
+
invoice_type: components['schemas']['backbone_api__app__routers__accounting__InvoiceType'],
|
|
188
188
|
params?: GetInvoicesByTypeParams
|
|
189
189
|
): RequestData<components['schemas']['InvoiceItemOutMonoAnalyticPlan'][]> {
|
|
190
190
|
return {
|
|
@@ -214,7 +214,7 @@ const accountingFactory = {
|
|
|
214
214
|
};
|
|
215
215
|
},
|
|
216
216
|
getInvoicesByTypeWithMultiplePlans(
|
|
217
|
-
invoice_type: components['schemas']['
|
|
217
|
+
invoice_type: components['schemas']['backbone_api__app__routers__accounting__InvoiceType'],
|
|
218
218
|
params?: GetInvoicesByTypeWithMultiplePlansParams
|
|
219
219
|
): RequestData<components['schemas']['InvoiceItemOutMultiAnalyticPlans'][]> {
|
|
220
220
|
return {
|
|
@@ -347,7 +347,7 @@ const accountingFactory = {
|
|
|
347
347
|
},
|
|
348
348
|
getVatCodes(
|
|
349
349
|
params?: GetVatCodesParams
|
|
350
|
-
): RequestData<components['schemas']['
|
|
350
|
+
): RequestData<components['schemas']['backbone_api__app__routers__accounting__VatCode'][]> {
|
|
351
351
|
return {
|
|
352
352
|
params,
|
|
353
353
|
method: 'get',
|
package/src/modules/consumer.ts
CHANGED
|
@@ -3,6 +3,7 @@ import { InternalAPI } from './internalApi';
|
|
|
3
3
|
import { chiftOperations } from '../types/public-api/mappings';
|
|
4
4
|
import { posFactory } from './pos';
|
|
5
5
|
import { pmsFactory } from './pms';
|
|
6
|
+
import { paymentFactory } from './payment';
|
|
6
7
|
import { createApiFor } from '../helpers/openapi';
|
|
7
8
|
import { accountingFactory } from './accounting';
|
|
8
9
|
import { invoicingFactory } from './invoicing';
|
|
@@ -23,6 +24,7 @@ const Consumer = (
|
|
|
23
24
|
const email = data.email;
|
|
24
25
|
const pos = createApiFor(posFactory, _internalApi, data.name, consumerId);
|
|
25
26
|
const pms = createApiFor(pmsFactory, _internalApi, data.name, consumerId);
|
|
27
|
+
const payment = createApiFor(paymentFactory, _internalApi, data.name, consumerId);
|
|
26
28
|
const accounting = createApiFor(accountingFactory, _internalApi, data.name, consumerId);
|
|
27
29
|
const invoicing = createApiFor(invoicingFactory, _internalApi, data.name, consumerId);
|
|
28
30
|
const ecommerce = createApiFor(ecommerceFactory, _internalApi, data.name, consumerId);
|
|
@@ -45,7 +47,9 @@ const Consumer = (
|
|
|
45
47
|
return data;
|
|
46
48
|
};
|
|
47
49
|
|
|
48
|
-
const createConnection = async (
|
|
50
|
+
const createConnection = async (
|
|
51
|
+
body?: components['schemas']['backbone_api__app__routers__connections__PostConnectionItem']
|
|
52
|
+
) => {
|
|
49
53
|
const {
|
|
50
54
|
data,
|
|
51
55
|
}: {
|
|
@@ -191,6 +195,7 @@ const Consumer = (
|
|
|
191
195
|
email,
|
|
192
196
|
pos,
|
|
193
197
|
pms,
|
|
198
|
+
payment,
|
|
194
199
|
accounting,
|
|
195
200
|
invoicing,
|
|
196
201
|
ecommerce,
|
package/src/modules/ecommerce.ts
CHANGED
|
@@ -26,7 +26,9 @@ const ecommerceFactory = {
|
|
|
26
26
|
url: '/consumers/{consumer_id}/commerce/customers',
|
|
27
27
|
};
|
|
28
28
|
},
|
|
29
|
-
getProducts(): RequestData<
|
|
29
|
+
getProducts(): RequestData<
|
|
30
|
+
components['schemas']['backbone_api__app__routers__commerce__ProductItem'][]
|
|
31
|
+
> {
|
|
30
32
|
return {
|
|
31
33
|
method: 'get',
|
|
32
34
|
url: '/consumers/{consumer_id}/commerce/products',
|
|
@@ -40,7 +42,7 @@ const ecommerceFactory = {
|
|
|
40
42
|
},
|
|
41
43
|
getProduct(
|
|
42
44
|
productId: string
|
|
43
|
-
): RequestData<components['schemas']['
|
|
45
|
+
): RequestData<components['schemas']['backbone_api__app__routers__commerce__ProductItem']> {
|
|
44
46
|
return {
|
|
45
47
|
method: 'get',
|
|
46
48
|
url: `/consumers/{consumer_id}/commerce/products/${productId}`,
|
package/src/modules/invoicing.ts
CHANGED
|
@@ -51,7 +51,7 @@ const invoicingFactory = {
|
|
|
51
51
|
};
|
|
52
52
|
},
|
|
53
53
|
createProduct(
|
|
54
|
-
product: components['schemas']['
|
|
54
|
+
product: components['schemas']['backbone_common__models__invoicing__ProductItem']
|
|
55
55
|
): RequestData<components['schemas']['ProductItemOut']> {
|
|
56
56
|
return {
|
|
57
57
|
method: 'create',
|
|
@@ -59,13 +59,17 @@ const invoicingFactory = {
|
|
|
59
59
|
body: product,
|
|
60
60
|
};
|
|
61
61
|
},
|
|
62
|
-
getTaxes(): RequestData<
|
|
62
|
+
getTaxes(): RequestData<
|
|
63
|
+
components['schemas']['backbone_common__models__invoicing__VatCode'][]
|
|
64
|
+
> {
|
|
63
65
|
return {
|
|
64
66
|
method: 'get',
|
|
65
67
|
url: `/consumers/{consumer_id}/invoicing/taxes`,
|
|
66
68
|
};
|
|
67
69
|
},
|
|
68
|
-
getTaxById(
|
|
70
|
+
getTaxById(
|
|
71
|
+
taxId: string
|
|
72
|
+
): RequestData<components['schemas']['backbone_common__models__invoicing__VatCode']> {
|
|
69
73
|
return {
|
|
70
74
|
method: 'get',
|
|
71
75
|
url: `/consumers/{consumer_id}/invoicing/taxes/${taxId}`,
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { operations, components } from '../types/public-api/schema';
|
|
2
|
+
import { AutoPaginatedParams, RequestData } from '../types/api';
|
|
3
|
+
|
|
4
|
+
type GetBalancesParams = AutoPaginatedParams<
|
|
5
|
+
operations['payment_get_balances']['parameters']['query']
|
|
6
|
+
>;
|
|
7
|
+
type GetPaymentsParams = AutoPaginatedParams<
|
|
8
|
+
operations['payment_get_payments']['parameters']['query']
|
|
9
|
+
>;
|
|
10
|
+
type GetTransactionsParams = AutoPaginatedParams<
|
|
11
|
+
operations['payment_get_transaction']['parameters']['query']
|
|
12
|
+
>;
|
|
13
|
+
type GetRefundsParams = AutoPaginatedParams<
|
|
14
|
+
operations['payment_get_refunds']['parameters']['query']
|
|
15
|
+
>;
|
|
16
|
+
|
|
17
|
+
const paymentFactory = {
|
|
18
|
+
getPayments(params: GetPaymentsParams): RequestData<components['schemas']['PaymentItemOut'][]> {
|
|
19
|
+
return {
|
|
20
|
+
params,
|
|
21
|
+
method: 'get',
|
|
22
|
+
url: `/consumers/{consumer_id}/payment/payments`,
|
|
23
|
+
};
|
|
24
|
+
},
|
|
25
|
+
getBalances(params: GetBalancesParams): RequestData<components['schemas']['BalanceItemOut'][]> {
|
|
26
|
+
return {
|
|
27
|
+
params,
|
|
28
|
+
method: 'get',
|
|
29
|
+
url: `/consumers/{consumer_id}/payment/balances`,
|
|
30
|
+
};
|
|
31
|
+
},
|
|
32
|
+
getTransactions(
|
|
33
|
+
params: GetTransactionsParams
|
|
34
|
+
): RequestData<components['schemas']['TransactionItemOut'][]> {
|
|
35
|
+
return {
|
|
36
|
+
params,
|
|
37
|
+
method: 'get',
|
|
38
|
+
url: `/consumers/{consumer_id}/payment/transactions`,
|
|
39
|
+
};
|
|
40
|
+
},
|
|
41
|
+
getPayment(
|
|
42
|
+
params: operations['payment_get_payment']['parameters']['path']
|
|
43
|
+
): RequestData<components['schemas']['PaymentItemOut']> {
|
|
44
|
+
return {
|
|
45
|
+
params,
|
|
46
|
+
method: 'get',
|
|
47
|
+
url: `/consumers/{consumer_id}/payment/payments/{payment_id}`,
|
|
48
|
+
};
|
|
49
|
+
},
|
|
50
|
+
getRefunds(params: GetRefundsParams): RequestData<components['schemas']['RefundItemOut'][]> {
|
|
51
|
+
return {
|
|
52
|
+
params,
|
|
53
|
+
method: 'get',
|
|
54
|
+
url: `/consumers/{consumer_id}/payment/refunds`,
|
|
55
|
+
};
|
|
56
|
+
},
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
export { paymentFactory };
|
package/src/modules/sync.ts
CHANGED
|
@@ -56,7 +56,7 @@ const Sync = (internalApi: InternalAPI, body: components['schemas']['ReadSyncIte
|
|
|
56
56
|
type: context.execution.type,
|
|
57
57
|
data: executionData,
|
|
58
58
|
},
|
|
59
|
-
|
|
59
|
+
triggers: context.triggers,
|
|
60
60
|
config: context.config,
|
|
61
61
|
});
|
|
62
62
|
const myflow = Flow(_internalApi, createFlowData, data.syncid, data.consumers, process);
|