@chift/chift-nodejs 1.0.3 → 1.0.5
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/CHANGELOG.md +9 -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 +5 -1
- package/dist/src/modules/accounting.js +12 -1
- package/dist/src/modules/api.d.ts +781 -226
- package/dist/src/modules/consumer.d.ts +52 -15
- package/dist/src/modules/consumers.d.ts +260 -75
- package/dist/src/modules/datastores.d.ts +1 -1
- package/dist/src/modules/internalApi.js +5 -1
- package/dist/src/modules/sync.d.ts +208 -60
- package/dist/src/modules/syncs.d.ts +520 -150
- package/dist/test/modules/accounting.test.js +23 -0
- package/dist/test/modules/flow.test.d.ts +1 -0
- package/dist/test/modules/flow.test.js +69 -0
- package/package.json +1 -1
- package/src/modules/accounting.ts +17 -3
- package/src/modules/internalApi.ts +19 -10
- package/src/types/public-api/schema.d.ts +343 -33
- package/test/modules/accounting.test.ts +27 -0
|
@@ -525,6 +525,29 @@ let miscOperations;
|
|
|
525
525
|
throw new Error('No journal with type "financial_operation" found to create financial entry');
|
|
526
526
|
}
|
|
527
527
|
const financialEntry = yield consumer.accounting.createFinancialEntry({
|
|
528
|
+
date: '2022-01-01',
|
|
529
|
+
journal_id: journal.id,
|
|
530
|
+
currency: 'EUR',
|
|
531
|
+
items: [
|
|
532
|
+
{
|
|
533
|
+
account_type: 'customer_account',
|
|
534
|
+
account: clients[0].id,
|
|
535
|
+
amount: 10,
|
|
536
|
+
},
|
|
537
|
+
],
|
|
538
|
+
});
|
|
539
|
+
(0, globals_1.expect)(financialEntry).toBeTruthy();
|
|
540
|
+
(0, globals_1.expect)(financialEntry).toHaveProperty('journal_id', journal.id);
|
|
541
|
+
}));
|
|
542
|
+
/**
|
|
543
|
+
* @deprecated replaced by createFinancialEntry
|
|
544
|
+
*/
|
|
545
|
+
(0, globals_1.test)('createFinancialEntryOld', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
546
|
+
const journal = journals.find((journal) => journal.journal_type === 'financial_operation');
|
|
547
|
+
if (!journal) {
|
|
548
|
+
throw new Error('No journal with type "financial_operation" found to create financial entry');
|
|
549
|
+
}
|
|
550
|
+
const financialEntry = yield consumer.accounting.createFinancialEntryOld({
|
|
528
551
|
date: '2022-01-01',
|
|
529
552
|
journal_id: journal.id,
|
|
530
553
|
currency: 'EUR',
|
|
@@ -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
|
+
}));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@chift/chift-nodejs",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.5",
|
|
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",
|
|
@@ -357,10 +357,13 @@ const accountingFactory = {
|
|
|
357
357
|
url: '/consumers/{consumer_id}/accounting/outstandings',
|
|
358
358
|
};
|
|
359
359
|
},
|
|
360
|
-
|
|
361
|
-
|
|
360
|
+
/**
|
|
361
|
+
* @deprecated replaced by createFinancialEntry
|
|
362
|
+
*/
|
|
363
|
+
createFinancialEntryOld(
|
|
364
|
+
financial_entry: components['schemas']['FinancialEntryItemInOld'],
|
|
362
365
|
params: operations['accounting_create_financial_entry']['parameters']['query']
|
|
363
|
-
): RequestData<components['schemas']['
|
|
366
|
+
): RequestData<components['schemas']['FinancialEntryItemOutOld']> {
|
|
364
367
|
return {
|
|
365
368
|
params,
|
|
366
369
|
method: 'post',
|
|
@@ -368,6 +371,17 @@ const accountingFactory = {
|
|
|
368
371
|
body: financial_entry,
|
|
369
372
|
};
|
|
370
373
|
},
|
|
374
|
+
createFinancialEntry(
|
|
375
|
+
financial_entry: components['schemas']['FinancialEntryItemIn'],
|
|
376
|
+
params: operations['accounting_create_financial_entries']['parameters']['query']
|
|
377
|
+
): RequestData<components['schemas']['FinancialEntryItemOut'][]> {
|
|
378
|
+
return {
|
|
379
|
+
params,
|
|
380
|
+
method: 'post',
|
|
381
|
+
url: '/consumers/{consumer_id}/accounting/financial-entries',
|
|
382
|
+
body: financial_entry,
|
|
383
|
+
};
|
|
384
|
+
},
|
|
371
385
|
createJournalEntry(
|
|
372
386
|
journal_entry: components['schemas']['JournalEntryIn']
|
|
373
387
|
): RequestData<components['schemas']['JournalEntryMultiAnalyticPlan']> {
|
|
@@ -26,27 +26,36 @@ class InternalAPI {
|
|
|
26
26
|
|
|
27
27
|
this.instance.interceptors.request.use(
|
|
28
28
|
(config) => {
|
|
29
|
-
return new Promise((resolve) => {
|
|
29
|
+
return new Promise((resolve, reject) => {
|
|
30
30
|
if (this.relatedChainExecutionId) {
|
|
31
31
|
config.headers['X-Chift-RelatedChainExecutionId'] =
|
|
32
32
|
this.relatedChainExecutionId;
|
|
33
33
|
}
|
|
34
34
|
if (this.token) {
|
|
35
35
|
if (this.token?.expires_on < new Date().getTime()) {
|
|
36
|
-
return this.getToken()
|
|
37
|
-
|
|
38
|
-
'
|
|
39
|
-
|
|
40
|
-
|
|
36
|
+
return this.getToken()
|
|
37
|
+
.then(() => {
|
|
38
|
+
config.headers['Authorization'] =
|
|
39
|
+
'Bearer ' + this.token?.access_token;
|
|
40
|
+
return resolve(config);
|
|
41
|
+
})
|
|
42
|
+
.catch((err) => {
|
|
43
|
+
return reject(err);
|
|
44
|
+
});
|
|
41
45
|
} else {
|
|
42
46
|
config.headers['Authorization'] = 'Bearer ' + this.token?.access_token;
|
|
43
47
|
return resolve(config);
|
|
44
48
|
}
|
|
45
49
|
} else {
|
|
46
|
-
return this.getToken()
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
+
return this.getToken()
|
|
51
|
+
.then(() => {
|
|
52
|
+
config.headers['Authorization'] =
|
|
53
|
+
'Bearer ' + this.token?.access_token;
|
|
54
|
+
return resolve(config);
|
|
55
|
+
})
|
|
56
|
+
.catch((err) => {
|
|
57
|
+
return reject(err);
|
|
58
|
+
});
|
|
50
59
|
}
|
|
51
60
|
});
|
|
52
61
|
},
|