@chift/chift-nodejs 0.0.1
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/.eslintignore +1 -0
- package/.eslintrc.json +25 -0
- package/.github/workflows/ci.yml +73 -0
- package/.husky/pre-commit +4 -0
- package/.prettierignore +1 -0
- package/.prettierrc.json +7 -0
- package/CHANGELOG.md +4 -0
- package/LICENSE +201 -0
- package/README.md +48 -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/helpers/openapi.d.ts +3 -0
- package/dist/src/helpers/openapi.js +18 -0
- package/dist/src/helpers/settings.d.ts +4 -0
- package/dist/src/helpers/settings.js +5 -0
- package/dist/src/index.d.ts +1 -0
- package/dist/src/index.js +17 -0
- package/dist/src/modules/accounting.d.ts +48 -0
- package/dist/src/modules/accounting.js +255 -0
- package/dist/src/modules/api.d.ts +39333 -0
- package/dist/src/modules/api.js +36 -0
- package/dist/src/modules/consumer.d.ts +2588 -0
- package/dist/src/modules/consumer.js +118 -0
- package/dist/src/modules/consumers.d.ts +13034 -0
- package/dist/src/modules/consumers.js +51 -0
- package/dist/src/modules/custom.d.ts +8 -0
- package/dist/src/modules/custom.js +36 -0
- package/dist/src/modules/datastores.d.ts +18 -0
- package/dist/src/modules/datastores.js +23 -0
- package/dist/src/modules/ecommerce.d.ts +16 -0
- package/dist/src/modules/ecommerce.js +69 -0
- package/dist/src/modules/flow.d.ts +15 -0
- package/dist/src/modules/flow.js +156 -0
- package/dist/src/modules/integrations.d.ts +14 -0
- package/dist/src/modules/integrations.js +23 -0
- package/dist/src/modules/internalApi.d.ts +22 -0
- package/dist/src/modules/internalApi.js +160 -0
- package/dist/src/modules/invoicing.d.ts +18 -0
- package/dist/src/modules/invoicing.js +90 -0
- package/dist/src/modules/pos.d.ts +20 -0
- package/dist/src/modules/pos.js +80 -0
- package/dist/src/modules/sync.d.ts +10494 -0
- package/dist/src/modules/sync.js +75 -0
- package/dist/src/modules/syncs.d.ts +26200 -0
- package/dist/src/modules/syncs.js +29 -0
- package/dist/src/modules/webhooks.d.ts +55 -0
- package/dist/src/modules/webhooks.js +53 -0
- package/dist/src/types/api.d.ts +28 -0
- package/dist/src/types/api.js +2 -0
- package/dist/src/types/consumers.d.ts +8 -0
- package/dist/src/types/consumers.js +2 -0
- package/dist/src/types/public-api/mappings.d.ts +21 -0
- package/dist/src/types/public-api/mappings.js +2 -0
- package/dist/src/types/sync.d.ts +20 -0
- package/dist/src/types/sync.js +2 -0
- package/dist/test/modules/accounting.test.d.ts +1 -0
- package/dist/test/modules/accounting.test.js +453 -0
- package/dist/test/modules/consumer.test.d.ts +1 -0
- package/dist/test/modules/consumer.test.js +89 -0
- package/dist/test/modules/consumers.test.d.ts +1 -0
- package/dist/test/modules/consumers.test.js +109 -0
- package/dist/test/modules/ecommerce.test.d.ts +1 -0
- package/dist/test/modules/ecommerce.test.js +193 -0
- package/dist/test/modules/flow.test.d.ts +1 -0
- package/dist/test/modules/flow.test.js +69 -0
- package/dist/test/modules/integrations.test.d.ts +1 -0
- package/dist/test/modules/integrations.test.js +54 -0
- package/dist/test/modules/invoicing.test.d.ts +1 -0
- package/dist/test/modules/invoicing.test.js +108 -0
- package/dist/test/modules/pos.test.d.ts +1 -0
- package/dist/test/modules/pos.test.js +164 -0
- package/dist/test/modules/sync.test.d.ts +1 -0
- package/dist/test/modules/sync.test.js +81 -0
- package/dist/test/modules/syncs.test.d.ts +1 -0
- package/dist/test/modules/syncs.test.js +53 -0
- package/dist/test/modules/webhooks.test.d.ts +1 -0
- package/dist/test/modules/webhooks.test.js +120 -0
- package/jest.config.ts +195 -0
- package/package.json +47 -0
- package/src/helpers/openapi.ts +22 -0
- package/src/helpers/settings.ts +3 -0
- package/src/index.ts +1 -0
- package/src/modules/accounting.ts +357 -0
- package/src/modules/api.ts +35 -0
- package/src/modules/consumer.ts +177 -0
- package/src/modules/consumers.ts +82 -0
- package/src/modules/custom.ts +36 -0
- package/src/modules/datastores.ts +19 -0
- package/src/modules/ecommerce.ts +82 -0
- package/src/modules/flow.ts +168 -0
- package/src/modules/integrations.ts +22 -0
- package/src/modules/internalApi.ts +162 -0
- package/src/modules/invoicing.ts +106 -0
- package/src/modules/pos.ts +112 -0
- package/src/modules/sync.ts +77 -0
- package/src/modules/syncs.ts +28 -0
- package/src/modules/webhooks.ts +86 -0
- package/src/types/api.ts +35 -0
- package/src/types/consumers.ts +9 -0
- package/src/types/public-api/mappings.ts +21 -0
- package/src/types/public-api/schema.d.ts +9436 -0
- package/src/types/sync.ts +23 -0
- package/test/data/accounting_invoice.pdf +0 -0
- package/test/modules/accounting.test.ts +483 -0
- package/test/modules/consumer.test.ts +68 -0
- package/test/modules/consumers.test.ts +83 -0
- package/test/modules/ecommerce.test.ts +177 -0
- package/test/modules/integrations.test.ts +22 -0
- package/test/modules/invoicing.test.ts +88 -0
- package/test/modules/pos.test.ts +145 -0
- package/test/modules/sync.test.ts +60 -0
- package/test/modules/syncs.test.ts +23 -0
- package/test/modules/webhooks.test.ts +92 -0
- package/test/set_envs.sh +14 -0
- package/tsconfig.json +107 -0
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.Consumer = void 0;
|
|
13
|
+
const pos_1 = require("./pos");
|
|
14
|
+
const openapi_1 = require("../helpers/openapi");
|
|
15
|
+
const accounting_1 = require("./accounting");
|
|
16
|
+
const invoicing_1 = require("./invoicing");
|
|
17
|
+
const ecommerce_1 = require("./ecommerce");
|
|
18
|
+
const custom_1 = require("./custom");
|
|
19
|
+
const Consumer = (internalApi, body) => {
|
|
20
|
+
const _internalApi = internalApi;
|
|
21
|
+
const data = body;
|
|
22
|
+
const consumerId = data.consumerid;
|
|
23
|
+
const name = data.name;
|
|
24
|
+
const redirect_url = data.redirect_url;
|
|
25
|
+
const email = data.email;
|
|
26
|
+
const pos = (0, openapi_1.createApiFor)(pos_1.posFactory, _internalApi, data.name, consumerId);
|
|
27
|
+
const accounting = (0, openapi_1.createApiFor)(accounting_1.accountingFactory, _internalApi, data.name, consumerId);
|
|
28
|
+
const invoicing = (0, openapi_1.createApiFor)(invoicing_1.invoicingFactory, _internalApi, data.name, consumerId);
|
|
29
|
+
const ecommerce = (0, openapi_1.createApiFor)(ecommerce_1.ecommerceFactory, _internalApi, data.name, consumerId);
|
|
30
|
+
const custom = (0, openapi_1.createApiFor)(custom_1.customFactory, _internalApi, data.name, consumerId);
|
|
31
|
+
const getConnections = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
32
|
+
const { data, } = yield _internalApi.get(`/consumers/${consumerId}/connections`);
|
|
33
|
+
return data;
|
|
34
|
+
});
|
|
35
|
+
const createConnection = (body) => __awaiter(void 0, void 0, void 0, function* () {
|
|
36
|
+
const { data, } = yield _internalApi.post(`/consumers/${consumerId}/connections`, Object.assign({}, body));
|
|
37
|
+
return data;
|
|
38
|
+
});
|
|
39
|
+
const updateConnection = (connectionId, body) => __awaiter(void 0, void 0, void 0, function* () {
|
|
40
|
+
const { data, } = yield _internalApi.patch(`/consumers/${consumerId}/connections/${connectionId}`, Object.assign({}, body));
|
|
41
|
+
return data;
|
|
42
|
+
});
|
|
43
|
+
const deleteConnection = (connectionId) => __awaiter(void 0, void 0, void 0, function* () {
|
|
44
|
+
const { data, } = yield _internalApi.delete(`/consumers/${consumerId}/connections/${connectionId}`);
|
|
45
|
+
return data;
|
|
46
|
+
});
|
|
47
|
+
const getSyncUrl = (body) => __awaiter(void 0, void 0, void 0, function* () {
|
|
48
|
+
const { data } = yield _internalApi.post(`/consumers/${consumerId}/syncs`, body);
|
|
49
|
+
return data;
|
|
50
|
+
});
|
|
51
|
+
const getSyncData = (syncId) => __awaiter(void 0, void 0, void 0, function* () {
|
|
52
|
+
const { data } = yield _internalApi.get(`/consumers/${consumerId}/syncs/${syncId}`);
|
|
53
|
+
return data;
|
|
54
|
+
});
|
|
55
|
+
const getDataByDataStoreName = (dataStoreName, params) => __awaiter(void 0, void 0, void 0, function* () {
|
|
56
|
+
const { data } = yield _internalApi.get(`/datastores`);
|
|
57
|
+
for (let i = 0; i < data.length; i++) {
|
|
58
|
+
if (data[i].name == dataStoreName) {
|
|
59
|
+
return yield getDataByDataStoreId(data[i].id, params);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
throw Error('Datastore could not be found');
|
|
63
|
+
});
|
|
64
|
+
const getDataByDataStoreId = (dataStoreId, params) => __awaiter(void 0, void 0, void 0, function* () {
|
|
65
|
+
const { data } = yield _internalApi.get(`/consumers/${consumerId}/datastore/${dataStoreId}/data`, { params: params });
|
|
66
|
+
return data;
|
|
67
|
+
});
|
|
68
|
+
const addDataByDataStoreId = (dataStoreId, data) => __awaiter(void 0, void 0, void 0, function* () {
|
|
69
|
+
const { data: response } = yield _internalApi.post(`/consumers/${consumerId}/datastore/${dataStoreId}/data`, data);
|
|
70
|
+
return response;
|
|
71
|
+
});
|
|
72
|
+
const addDataByDataStoreName = (dataStoreName, data) => __awaiter(void 0, void 0, void 0, function* () {
|
|
73
|
+
const { data: datastores } = yield _internalApi.get(`/datastores`);
|
|
74
|
+
for (let i = 0; i < datastores.length; i++) {
|
|
75
|
+
if (datastores[i].name == dataStoreName) {
|
|
76
|
+
return yield addDataByDataStoreId(datastores[i].id, data);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
});
|
|
80
|
+
const updateDataStoreData = (dataStoreId, dataStoreDataId, data) => __awaiter(void 0, void 0, void 0, function* () {
|
|
81
|
+
const { data: response } = yield _internalApi.patch(`/consumers/${consumerId}/datastore/${dataStoreId}/data/${dataStoreDataId}`, data);
|
|
82
|
+
return response;
|
|
83
|
+
});
|
|
84
|
+
/**
|
|
85
|
+
* This function is used to add logs related to a chainexecution (passed in the header)
|
|
86
|
+
* INTERNAL USE only
|
|
87
|
+
* @param logs
|
|
88
|
+
* @returns
|
|
89
|
+
*/
|
|
90
|
+
const logData = (logs) => __awaiter(void 0, void 0, void 0, function* () {
|
|
91
|
+
const { data: response } = yield _internalApi.post(`/consumers/${consumerId}/logs`, logs);
|
|
92
|
+
return response;
|
|
93
|
+
});
|
|
94
|
+
return {
|
|
95
|
+
consumerId,
|
|
96
|
+
getConnections,
|
|
97
|
+
createConnection,
|
|
98
|
+
updateConnection,
|
|
99
|
+
deleteConnection,
|
|
100
|
+
getSyncUrl,
|
|
101
|
+
name,
|
|
102
|
+
redirect_url,
|
|
103
|
+
email,
|
|
104
|
+
pos,
|
|
105
|
+
accounting,
|
|
106
|
+
invoicing,
|
|
107
|
+
ecommerce,
|
|
108
|
+
custom,
|
|
109
|
+
getDataByDataStoreId,
|
|
110
|
+
addDataByDataStoreId,
|
|
111
|
+
getSyncData,
|
|
112
|
+
getDataByDataStoreName,
|
|
113
|
+
addDataByDataStoreName,
|
|
114
|
+
updateDataStoreData,
|
|
115
|
+
logData,
|
|
116
|
+
};
|
|
117
|
+
};
|
|
118
|
+
exports.Consumer = Consumer;
|