@chift/chift-nodejs 1.0.8 → 1.0.9
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/.eslintcache +1 -0
- package/.github/workflows/ci.yml +2 -1
- package/CHANGELOG.md +4 -0
- package/coverage/clover.xml +1645 -0
- package/coverage/coverage-final.json +19 -0
- package/coverage/lcov-report/base.css +224 -0
- package/coverage/lcov-report/block-navigation.js +87 -0
- package/coverage/lcov-report/favicon.png +0 -0
- package/coverage/lcov-report/index.html +146 -0
- package/coverage/lcov-report/prettify.css +1 -0
- package/coverage/lcov-report/prettify.js +2 -0
- package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
- package/coverage/lcov-report/sorter.js +196 -0
- package/coverage/lcov-report/src/helpers/index.html +131 -0
- package/coverage/lcov-report/src/helpers/openapi.ts.html +151 -0
- package/coverage/lcov-report/src/helpers/settings.ts.html +94 -0
- package/coverage/lcov-report/src/index.html +116 -0
- package/coverage/lcov-report/src/index.ts.html +88 -0
- package/coverage/lcov-report/src/modules/accounting.ts.html +1156 -0
- package/coverage/lcov-report/src/modules/api.ts.html +190 -0
- package/coverage/lcov-report/src/modules/consumer.ts.html +616 -0
- package/coverage/lcov-report/src/modules/consumers.ts.html +331 -0
- package/coverage/lcov-report/src/modules/custom.ts.html +193 -0
- package/coverage/lcov-report/src/modules/datastores.ts.html +142 -0
- package/coverage/lcov-report/src/modules/ecommerce.ts.html +331 -0
- package/coverage/lcov-report/src/modules/flow.ts.html +589 -0
- package/coverage/lcov-report/src/modules/index.html +326 -0
- package/coverage/lcov-report/src/modules/integrations.ts.html +151 -0
- package/coverage/lcov-report/src/modules/internalApi.ts.html +586 -0
- package/coverage/lcov-report/src/modules/invoicing.ts.html +391 -0
- package/coverage/lcov-report/src/modules/pos.ts.html +421 -0
- package/coverage/lcov-report/src/modules/sync.ts.html +316 -0
- package/coverage/lcov-report/src/modules/syncs.ts.html +169 -0
- package/coverage/lcov-report/src/modules/webhooks.ts.html +343 -0
- package/coverage/lcov.info +1976 -0
- package/dist/src/modules/accounting.d.ts +24 -27
- package/dist/src/modules/accounting.js +31 -76
- package/dist/src/modules/api.d.ts +28022 -2110
- package/dist/src/modules/consumer.d.ts +64 -413
- package/dist/src/modules/consumer.js +0 -10
- package/dist/src/modules/consumers.d.ts +332 -2097
- package/dist/src/modules/ecommerce.d.ts +0 -8
- package/dist/src/modules/ecommerce.js +0 -28
- package/dist/src/modules/flow.js +1 -1
- package/dist/src/modules/pos.d.ts +1 -3
- package/dist/src/modules/pos.js +0 -7
- package/dist/src/modules/sync.d.ts +268 -1680
- package/dist/src/modules/syncs.d.ts +27677 -8
- package/dist/src/modules/syncs.js +0 -10
- package/dist/test/modules/accounting.test.js +11 -28
- package/dist/test/modules/ecommerce.test.js +7 -34
- package/dist/test/modules/flow.test.d.ts +1 -0
- package/dist/test/modules/flow.test.js +69 -0
- package/dist/test/modules/pos.test.js +5 -10
- package/package.json +1 -1
- package/src/modules/integrations.ts +4 -2
|
@@ -21,19 +21,9 @@ const Syncs = (internalApi) => {
|
|
|
21
21
|
const { data } = yield _internalApi.get(`/syncs/${syncid}`);
|
|
22
22
|
return (0, sync_1.Sync)(_internalApi, data);
|
|
23
23
|
});
|
|
24
|
-
const createSync = (body) => __awaiter(void 0, void 0, void 0, function* () {
|
|
25
|
-
const { data, } = yield _internalApi.post('/syncs', body);
|
|
26
|
-
return (0, sync_1.Sync)(_internalApi, data);
|
|
27
|
-
});
|
|
28
|
-
const updateSync = (body) => __awaiter(void 0, void 0, void 0, function* () {
|
|
29
|
-
const { data, } = yield _internalApi.patch('/syncs', body);
|
|
30
|
-
return (0, sync_1.Sync)(_internalApi, data);
|
|
31
|
-
});
|
|
32
24
|
return {
|
|
33
|
-
createSync,
|
|
34
25
|
getSyncs,
|
|
35
26
|
getSyncById,
|
|
36
|
-
updateSync,
|
|
37
27
|
};
|
|
38
28
|
};
|
|
39
29
|
exports.Syncs = Syncs;
|
|
@@ -377,6 +377,17 @@ let analyticAccounts;
|
|
|
377
377
|
const analyticAccountsWithMultiplePlans = yield consumer.accounting.getAnalyticAccountsWithMultiplePlans();
|
|
378
378
|
(0, globals_1.expect)(analyticAccountsWithMultiplePlans).toBeInstanceOf(Array);
|
|
379
379
|
}));
|
|
380
|
+
(0, globals_1.test)('getAnalyticLinesOfAccount', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
381
|
+
const analyticLinesOfAccount = yield consumer.accounting.getAnalyticLinesOfAccount(analyticAccounts[0].id);
|
|
382
|
+
(0, globals_1.expect)(analyticLinesOfAccount).toBeInstanceOf(Array);
|
|
383
|
+
if (analyticLinesOfAccount.length > 0) {
|
|
384
|
+
(0, globals_1.expect)(analyticLinesOfAccount[0]).toHaveProperty('account_id', analyticAccounts[0].id);
|
|
385
|
+
(0, globals_1.expect)(analyticLinesOfAccount[0]).toHaveProperty('description', globals_1.expect.any(String));
|
|
386
|
+
(0, globals_1.expect)(analyticLinesOfAccount[0]).toHaveProperty('amount', globals_1.expect.any(Number));
|
|
387
|
+
(0, globals_1.expect)(analyticLinesOfAccount[0]).toHaveProperty('date', globals_1.expect.any(String));
|
|
388
|
+
(0, globals_1.expect)(analyticLinesOfAccount[0]).toHaveProperty('id', globals_1.expect.any(String));
|
|
389
|
+
}
|
|
390
|
+
}));
|
|
380
391
|
(0, globals_1.test)('createJournalEntry', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
381
392
|
const journal = journals.find((journal) => journal.journal_type === 'customer_invoice');
|
|
382
393
|
if (!journal) {
|
|
@@ -552,31 +563,3 @@ let miscOperations;
|
|
|
552
563
|
(0, globals_1.expect)(financialEntry).toBeTruthy();
|
|
553
564
|
(0, globals_1.expect)(financialEntry).toHaveProperty('journal_id', journal.id);
|
|
554
565
|
}));
|
|
555
|
-
let folders = [];
|
|
556
|
-
(0, globals_1.test)('getFolders', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
557
|
-
folders = yield consumer.accounting.getFolders();
|
|
558
|
-
(0, globals_1.expect)(folders).toBeInstanceOf(Array);
|
|
559
|
-
(0, globals_1.expect)(folders.length).toBeGreaterThan(0);
|
|
560
|
-
(0, globals_1.expect)(folders[0]).toHaveProperty('id', globals_1.expect.any(String));
|
|
561
|
-
(0, globals_1.expect)(folders[0]).toHaveProperty('name', globals_1.expect.any(String));
|
|
562
|
-
}));
|
|
563
|
-
globals_1.test.skip('getAttachments', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
564
|
-
const attachments = yield consumer.accounting.getAttachments({
|
|
565
|
-
// TODO: Add documentId from test account
|
|
566
|
-
documentId: '',
|
|
567
|
-
type: 'invoice',
|
|
568
|
-
});
|
|
569
|
-
(0, globals_1.expect)(attachments).toBeInstanceOf(Array);
|
|
570
|
-
(0, globals_1.expect)(attachments.length).toBeGreaterThan(0);
|
|
571
|
-
(0, globals_1.expect)(attachments[0]).toHaveProperty('id', globals_1.expect.any(String));
|
|
572
|
-
(0, globals_1.expect)(attachments[0]).toHaveProperty('base64_string', globals_1.expect.any(String));
|
|
573
|
-
}));
|
|
574
|
-
globals_1.test.skip('matchEntries', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
575
|
-
const match = yield consumer.accounting.matchEntries({
|
|
576
|
-
// TODO: Change params with test account values
|
|
577
|
-
entries: [],
|
|
578
|
-
partner_id: '',
|
|
579
|
-
});
|
|
580
|
-
(0, globals_1.expect)(match).toHaveProperty('matching_number', globals_1.expect.any(String));
|
|
581
|
-
(0, globals_1.expect)(match).toHaveProperty('balance', globals_1.expect.any(Number));
|
|
582
|
-
}));
|
|
@@ -122,9 +122,9 @@ let locations;
|
|
|
122
122
|
(0, globals_1.expect)(product).toBeTruthy();
|
|
123
123
|
(0, globals_1.expect)(product).toHaveProperty('available_quantity', globals_1.expect.any(Number));
|
|
124
124
|
}));
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
const order =
|
|
125
|
+
/*
|
|
126
|
+
test('createOrder', async () => {
|
|
127
|
+
const order = await consumer.ecommerce.createOrder({
|
|
128
128
|
customer: {
|
|
129
129
|
email: 'test@test.com',
|
|
130
130
|
},
|
|
@@ -155,9 +155,10 @@ globals_1.test.skip('createOrder', () => __awaiter(void 0, void 0, void 0, funct
|
|
|
155
155
|
],
|
|
156
156
|
payment_method: 'bank-transfer',
|
|
157
157
|
});
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
})
|
|
158
|
+
expect(order).toBeTruthy();
|
|
159
|
+
expect(order).toHaveProperty('id', expect.any(String));
|
|
160
|
+
});
|
|
161
|
+
*/
|
|
161
162
|
let orders;
|
|
162
163
|
(0, globals_1.test)('getOrders', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
163
164
|
orders = yield consumer.ecommerce.getOrders({
|
|
@@ -190,31 +191,3 @@ let orders;
|
|
|
190
191
|
(0, globals_1.expect)(order).toHaveProperty('lines', globals_1.expect.any(Array));
|
|
191
192
|
(0, globals_1.expect)(order).toHaveProperty('other_fees');
|
|
192
193
|
}));
|
|
193
|
-
(0, globals_1.test)('getPaymentMethods', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
194
|
-
const paymentMethods = yield consumer.ecommerce.getPaymentMethods();
|
|
195
|
-
(0, globals_1.expect)(paymentMethods).toBeInstanceOf(Array);
|
|
196
|
-
(0, globals_1.expect)(paymentMethods.length).toBeGreaterThan(0);
|
|
197
|
-
(0, globals_1.expect)(paymentMethods[0]).toHaveProperty('id', globals_1.expect.any(String));
|
|
198
|
-
(0, globals_1.expect)(paymentMethods[0]).toHaveProperty('name', globals_1.expect.any(String));
|
|
199
|
-
}));
|
|
200
|
-
(0, globals_1.test)('getProductCategories', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
201
|
-
const productCategories = yield consumer.ecommerce.getProductCategories();
|
|
202
|
-
(0, globals_1.expect)(productCategories).toBeInstanceOf(Array);
|
|
203
|
-
(0, globals_1.expect)(productCategories.length).toBeGreaterThan(0);
|
|
204
|
-
(0, globals_1.expect)(productCategories[0]).toHaveProperty('id', globals_1.expect.any(String));
|
|
205
|
-
(0, globals_1.expect)(productCategories[0]).toHaveProperty('name', globals_1.expect.any(String));
|
|
206
|
-
}));
|
|
207
|
-
(0, globals_1.test)('getCountries', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
208
|
-
const countries = yield consumer.ecommerce.getCountries();
|
|
209
|
-
(0, globals_1.expect)(countries).toBeInstanceOf(Array);
|
|
210
|
-
(0, globals_1.expect)(countries.length).toBeGreaterThan(0);
|
|
211
|
-
(0, globals_1.expect)(countries[0]).toHaveProperty('code', globals_1.expect.any(String));
|
|
212
|
-
(0, globals_1.expect)(countries[0]).toHaveProperty('name', globals_1.expect.any(String));
|
|
213
|
-
}));
|
|
214
|
-
(0, globals_1.test)('getTaxes', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
215
|
-
const taxes = yield consumer.ecommerce.getTaxes();
|
|
216
|
-
(0, globals_1.expect)(taxes).toBeInstanceOf(Array);
|
|
217
|
-
(0, globals_1.expect)(taxes.length).toBeGreaterThan(0);
|
|
218
|
-
(0, globals_1.expect)(taxes[0]).toHaveProperty('id', globals_1.expect.any(String));
|
|
219
|
-
(0, globals_1.expect)(taxes[0]).toHaveProperty('rate', globals_1.expect.any(Number));
|
|
220
|
-
}));
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,69 @@
|
|
|
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
|
+
}));
|
|
@@ -45,14 +45,14 @@ const client = new chift.API({
|
|
|
45
45
|
// Split testing between two APIs to support all endpoints
|
|
46
46
|
const cashpadConsumerId = process.env.CHIFT_CASHPAD_CONSUMER_ID;
|
|
47
47
|
const lightspeedConsumerId = process.env.CHIFT_LIGHTSPEED_CONSUMER_ID;
|
|
48
|
-
const
|
|
48
|
+
const zeltyConsumerId = process.env.CHIFT_ZELTY_CONSUMER_ID;
|
|
49
49
|
let cashpadConsumer;
|
|
50
50
|
let lightspeedConsumer;
|
|
51
|
-
let
|
|
51
|
+
let zeltyConsumer;
|
|
52
52
|
(0, globals_1.beforeAll)(() => __awaiter(void 0, void 0, void 0, function* () {
|
|
53
53
|
cashpadConsumer = yield client.Consumers.getConsumerById(cashpadConsumerId);
|
|
54
54
|
lightspeedConsumer = yield client.Consumers.getConsumerById(lightspeedConsumerId);
|
|
55
|
-
|
|
55
|
+
zeltyConsumer = yield client.Consumers.getConsumerById(zeltyConsumerId);
|
|
56
56
|
}));
|
|
57
57
|
(0, globals_1.test)('getLocations', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
58
58
|
const locations = yield lightspeedConsumer.pos.getLocations();
|
|
@@ -166,17 +166,12 @@ globals_1.test.skip('updateOrder', () => __awaiter(void 0, void 0, void 0, funct
|
|
|
166
166
|
(0, globals_1.expect)(order).toHaveProperty('id', globals_1.expect.any(String));
|
|
167
167
|
}));
|
|
168
168
|
(0, globals_1.test)('getProducts', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
169
|
-
const products = yield
|
|
169
|
+
const products = yield zeltyConsumer.pos.getProducts();
|
|
170
170
|
(0, globals_1.expect)(products).toBeInstanceOf(Array);
|
|
171
171
|
(0, globals_1.expect)(products.length).toBeGreaterThan(0);
|
|
172
172
|
}));
|
|
173
173
|
(0, globals_1.test)('getProductCategories', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
174
|
-
const productCategories = yield
|
|
174
|
+
const productCategories = yield zeltyConsumer.pos.getProductCategories();
|
|
175
175
|
(0, globals_1.expect)(productCategories).toBeInstanceOf(Array);
|
|
176
176
|
(0, globals_1.expect)(productCategories.length).toBeGreaterThan(0);
|
|
177
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
|
-
}));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@chift/chift-nodejs",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.9",
|
|
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",
|
|
@@ -5,12 +5,14 @@ import { chiftOperations } from '../types/public-api/mappings';
|
|
|
5
5
|
const Integrations = (internalApi: InternalAPI) => {
|
|
6
6
|
const _internalApi: InternalAPI = internalApi;
|
|
7
7
|
|
|
8
|
-
const getIntegrations = async (
|
|
8
|
+
const getIntegrations = async (
|
|
9
|
+
params: operations[chiftOperations['getIntegrations']]['parameters']['query'] = {}
|
|
10
|
+
) => {
|
|
9
11
|
const {
|
|
10
12
|
data,
|
|
11
13
|
}: {
|
|
12
14
|
data: operations[chiftOperations['getIntegrations']]['responses'][200]['content']['application/json'];
|
|
13
|
-
} = await _internalApi.get('/integrations');
|
|
15
|
+
} = await _internalApi.get('/integrations', { params });
|
|
14
16
|
return data;
|
|
15
17
|
};
|
|
16
18
|
|