@chift/chift-nodejs 1.0.18 → 1.0.19
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/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/modules/accounting.d.ts +68 -0
- package/dist/src/modules/accounting.js +326 -0
- package/dist/src/modules/api.d.ts +18351 -0
- package/dist/src/modules/api.js +36 -0
- package/dist/src/modules/consumer.d.ts +3622 -0
- package/dist/src/modules/consumer.js +142 -0
- package/dist/src/modules/consumers.d.ts +18237 -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 +24 -0
- package/dist/src/modules/ecommerce.js +97 -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 +23 -0
- package/dist/src/modules/integrations.js +23 -0
- package/dist/src/modules/internalApi.d.ts +24 -0
- package/dist/src/modules/internalApi.js +175 -0
- package/dist/src/modules/invoicing.d.ts +20 -0
- package/dist/src/modules/invoicing.js +90 -0
- package/dist/src/modules/payment.d.ts +14 -0
- package/dist/src/modules/payment.js +41 -0
- package/dist/src/modules/pms.d.ts +15 -0
- package/dist/src/modules/pms.js +47 -0
- package/dist/src/modules/pos.d.ts +26 -0
- package/dist/src/modules/pos.js +101 -0
- package/dist/src/modules/sync.d.ts +14654 -0
- package/dist/src/modules/sync.js +73 -0
- package/dist/src/modules/syncs.d.ts +11 -0
- package/dist/src/modules/syncs.js +39 -0
- package/dist/src/modules/webhooks.d.ts +58 -0
- package/dist/src/modules/webhooks.js +53 -0
- package/{src/types/api.ts → dist/src/types/api.d.ts} +4 -12
- package/dist/src/types/api.js +2 -0
- package/{src/types/consumers.ts → dist/src/types/consumers.d.ts} +0 -1
- package/dist/src/types/consumers.js +2 -0
- package/dist/src/types/public-api/mappings.js +2 -0
- package/dist/src/types/public-api/schema.d.ts +15294 -0
- package/{src/types/sync.ts → dist/src/types/sync.d.ts} +5 -6
- 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 +590 -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 +224 -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 +115 -0
- 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.d.ts +1 -0
- package/dist/test/modules/pos.test.js +179 -0
- package/dist/test/modules/sync.test.d.ts +1 -0
- package/dist/test/modules/sync.test.js +93 -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/package.json +3 -2
- /package/{src/types/public-api/mappings.ts → dist/src/types/public-api/mappings.d.ts} +0 -0
|
@@ -0,0 +1,73 @@
|
|
|
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.Sync = void 0;
|
|
13
|
+
const flow_1 = require("./flow");
|
|
14
|
+
const Sync = (internalApi, body) => {
|
|
15
|
+
const _internalApi = internalApi;
|
|
16
|
+
const data = body;
|
|
17
|
+
const name = data.name;
|
|
18
|
+
const consumers = data.consumers;
|
|
19
|
+
const syncid = data.syncid;
|
|
20
|
+
const getFlows = () => {
|
|
21
|
+
return data.flows.map((flow) => (0, flow_1.Flow)(_internalApi, flow, data.syncid, data.consumers));
|
|
22
|
+
};
|
|
23
|
+
const getFlowByName = (name) => {
|
|
24
|
+
const flow = data.flows.find((flow) => flow.name.toLowerCase() === name.toLowerCase());
|
|
25
|
+
if (flow) {
|
|
26
|
+
return (0, flow_1.Flow)(_internalApi, flow, data.syncid, data.consumers);
|
|
27
|
+
}
|
|
28
|
+
return undefined;
|
|
29
|
+
};
|
|
30
|
+
const getFlowById = (id) => {
|
|
31
|
+
const flow = data.flows.find((flow) => flow.id === id);
|
|
32
|
+
if (flow) {
|
|
33
|
+
return (0, flow_1.Flow)(_internalApi, flow, data.syncid, data.consumers);
|
|
34
|
+
}
|
|
35
|
+
return undefined;
|
|
36
|
+
};
|
|
37
|
+
/**
|
|
38
|
+
* Internal use: Used to create flow based on code and triggers.
|
|
39
|
+
* @param context
|
|
40
|
+
* @param process
|
|
41
|
+
* @returns flow
|
|
42
|
+
*/
|
|
43
|
+
const createFlow = (context, process) => __awaiter(void 0, void 0, void 0, function* () {
|
|
44
|
+
const executionData = context.execution.data || {};
|
|
45
|
+
if (context.execution.type === 'code') {
|
|
46
|
+
const fullFunc = process === null || process === void 0 ? void 0 : process.toString();
|
|
47
|
+
const bodyFunc = fullFunc === null || fullFunc === void 0 ? void 0 : fullFunc.slice(fullFunc.indexOf('{') + 1, fullFunc.lastIndexOf('}'));
|
|
48
|
+
executionData['code'] = bodyFunc;
|
|
49
|
+
}
|
|
50
|
+
const { data: createFlowData } = yield _internalApi.post(`/syncs/${data.syncid}/flows`, {
|
|
51
|
+
name: context.name,
|
|
52
|
+
description: context.description,
|
|
53
|
+
execution: {
|
|
54
|
+
type: context.execution.type,
|
|
55
|
+
data: executionData,
|
|
56
|
+
},
|
|
57
|
+
triggers: context.triggers,
|
|
58
|
+
config: context.config,
|
|
59
|
+
});
|
|
60
|
+
const myflow = (0, flow_1.Flow)(_internalApi, createFlowData, data.syncid, data.consumers, process);
|
|
61
|
+
return myflow;
|
|
62
|
+
});
|
|
63
|
+
return {
|
|
64
|
+
createFlow,
|
|
65
|
+
getFlows,
|
|
66
|
+
getFlowByName,
|
|
67
|
+
getFlowById,
|
|
68
|
+
name,
|
|
69
|
+
consumers,
|
|
70
|
+
syncid,
|
|
71
|
+
};
|
|
72
|
+
};
|
|
73
|
+
exports.Sync = Sync;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { components } from '../types/public-api/schema';
|
|
2
|
+
import { InternalAPI } from './internalApi';
|
|
3
|
+
import { Sync } from './sync';
|
|
4
|
+
export type SyncsAPI = {
|
|
5
|
+
createSync: (body?: components['schemas']['CreateSyncItem']) => Promise<ReturnType<typeof Sync>>;
|
|
6
|
+
getSyncs: () => Promise<ReturnType<typeof Sync>[]>;
|
|
7
|
+
getSyncById: (syncid: string) => Promise<ReturnType<typeof Sync>>;
|
|
8
|
+
updateSync: (body?: components['schemas']['CreateSyncItem']) => Promise<ReturnType<typeof Sync>>;
|
|
9
|
+
};
|
|
10
|
+
declare const Syncs: (internalApi: InternalAPI) => SyncsAPI;
|
|
11
|
+
export { Syncs };
|
|
@@ -0,0 +1,39 @@
|
|
|
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.Syncs = void 0;
|
|
13
|
+
const sync_1 = require("./sync");
|
|
14
|
+
const Syncs = (internalApi) => {
|
|
15
|
+
const _internalApi = internalApi;
|
|
16
|
+
const getSyncs = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
17
|
+
const { data } = yield _internalApi.get('/syncs');
|
|
18
|
+
return data.map((sync) => (0, sync_1.Sync)(_internalApi, sync));
|
|
19
|
+
});
|
|
20
|
+
const getSyncById = (syncid) => __awaiter(void 0, void 0, void 0, function* () {
|
|
21
|
+
const { data } = yield _internalApi.get(`/syncs/${syncid}`);
|
|
22
|
+
return (0, sync_1.Sync)(_internalApi, data);
|
|
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
|
+
return {
|
|
33
|
+
createSync,
|
|
34
|
+
getSyncs,
|
|
35
|
+
getSyncById,
|
|
36
|
+
updateSync,
|
|
37
|
+
};
|
|
38
|
+
};
|
|
39
|
+
exports.Syncs = Syncs;
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { operations } from '../types/public-api/schema';
|
|
2
|
+
import { InternalAPI } from './internalApi';
|
|
3
|
+
import { chiftOperations } from '../types/public-api/mappings';
|
|
4
|
+
declare const Webhooks: (internalApi: InternalAPI) => {
|
|
5
|
+
getWebhookTypes: () => Promise<{
|
|
6
|
+
event: string;
|
|
7
|
+
api?: string | undefined;
|
|
8
|
+
}[]>;
|
|
9
|
+
registerWebhook: (body: operations[chiftOperations['registerWebhook']]['requestBody']['content']['application/json']) => Promise<{
|
|
10
|
+
consumerid: string;
|
|
11
|
+
name: string;
|
|
12
|
+
email?: string | undefined;
|
|
13
|
+
redirect_url?: string | undefined;
|
|
14
|
+
}>;
|
|
15
|
+
getWebhookById: (webhookId: string) => Promise<{
|
|
16
|
+
webhookid: string;
|
|
17
|
+
accountid: string;
|
|
18
|
+
createdby?: string | undefined;
|
|
19
|
+
createdon: string;
|
|
20
|
+
event: string;
|
|
21
|
+
url: string;
|
|
22
|
+
status: "active" | "inactive";
|
|
23
|
+
integrationid?: number | undefined;
|
|
24
|
+
}>;
|
|
25
|
+
updateWebhookById: (webhookId: string, body: operations[chiftOperations['updateWebhookById']]['requestBody']['content']['application/json']) => Promise<{
|
|
26
|
+
consumerid: string;
|
|
27
|
+
name: string;
|
|
28
|
+
email?: string | undefined;
|
|
29
|
+
redirect_url?: string | undefined;
|
|
30
|
+
}>;
|
|
31
|
+
unRegisterWebhook: (webhookId: string) => Promise<{
|
|
32
|
+
headers: {
|
|
33
|
+
[name: string]: unknown;
|
|
34
|
+
};
|
|
35
|
+
content?: undefined;
|
|
36
|
+
}>;
|
|
37
|
+
getWebhookLogsByWebhookId: (webhookId: string) => Promise<{
|
|
38
|
+
webhooklogid: string;
|
|
39
|
+
webhookid: string;
|
|
40
|
+
event: string;
|
|
41
|
+
url: string;
|
|
42
|
+
accountid: string;
|
|
43
|
+
createdon: string;
|
|
44
|
+
httpstatus: number;
|
|
45
|
+
integrationid?: number | undefined;
|
|
46
|
+
}[]>;
|
|
47
|
+
getWebhooks: () => Promise<{
|
|
48
|
+
webhookid: string;
|
|
49
|
+
accountid: string;
|
|
50
|
+
createdby?: string | undefined;
|
|
51
|
+
createdon: string;
|
|
52
|
+
event: string;
|
|
53
|
+
url: string;
|
|
54
|
+
status: "active" | "inactive";
|
|
55
|
+
integrationid?: number | undefined;
|
|
56
|
+
}[]>;
|
|
57
|
+
};
|
|
58
|
+
export { Webhooks };
|
|
@@ -0,0 +1,53 @@
|
|
|
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.Webhooks = void 0;
|
|
13
|
+
const Webhooks = (internalApi) => {
|
|
14
|
+
const _internalApi = internalApi;
|
|
15
|
+
const getWebhookTypes = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
16
|
+
const { data, } = yield _internalApi.get('/webhooks/list');
|
|
17
|
+
return data;
|
|
18
|
+
});
|
|
19
|
+
const getWebhooks = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
20
|
+
const { data, } = yield _internalApi.get('/webhooks');
|
|
21
|
+
return data;
|
|
22
|
+
});
|
|
23
|
+
const registerWebhook = (body) => __awaiter(void 0, void 0, void 0, function* () {
|
|
24
|
+
const { data, } = yield _internalApi.post('/webhooks', body);
|
|
25
|
+
return data;
|
|
26
|
+
});
|
|
27
|
+
const getWebhookById = (webhookId) => __awaiter(void 0, void 0, void 0, function* () {
|
|
28
|
+
const { data, } = yield _internalApi.get(`/webhooks/${webhookId}`);
|
|
29
|
+
return data;
|
|
30
|
+
});
|
|
31
|
+
const updateWebhookById = (webhookId, body) => __awaiter(void 0, void 0, void 0, function* () {
|
|
32
|
+
const { data, } = yield _internalApi.patch(`/webhooks/${webhookId}`, body);
|
|
33
|
+
return data;
|
|
34
|
+
});
|
|
35
|
+
const unRegisterWebhook = (webhookId) => __awaiter(void 0, void 0, void 0, function* () {
|
|
36
|
+
const { data, } = yield _internalApi.delete(`/webhooks/${webhookId}`);
|
|
37
|
+
return data;
|
|
38
|
+
});
|
|
39
|
+
const getWebhookLogsByWebhookId = (webhookId) => __awaiter(void 0, void 0, void 0, function* () {
|
|
40
|
+
const { data, } = yield _internalApi.get(`/webhooks/${webhookId}/logs`);
|
|
41
|
+
return data;
|
|
42
|
+
});
|
|
43
|
+
return {
|
|
44
|
+
getWebhookTypes,
|
|
45
|
+
registerWebhook,
|
|
46
|
+
getWebhookById,
|
|
47
|
+
updateWebhookById,
|
|
48
|
+
unRegisterWebhook,
|
|
49
|
+
getWebhookLogsByWebhookId,
|
|
50
|
+
getWebhooks,
|
|
51
|
+
};
|
|
52
|
+
};
|
|
53
|
+
exports.Webhooks = Webhooks;
|
|
@@ -5,15 +5,12 @@ export interface AuthType {
|
|
|
5
5
|
envId?: string;
|
|
6
6
|
baseUrl?: string;
|
|
7
7
|
}
|
|
8
|
-
|
|
9
8
|
export interface TokenType {
|
|
10
9
|
access_token: string;
|
|
11
10
|
token_type: string;
|
|
12
11
|
expires_in: number;
|
|
13
12
|
expires_on: number;
|
|
14
13
|
}
|
|
15
|
-
|
|
16
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
17
14
|
export type RequestData<TResponse> = {
|
|
18
15
|
method: string;
|
|
19
16
|
property?: string;
|
|
@@ -23,15 +20,10 @@ export type RequestData<TResponse> = {
|
|
|
23
20
|
params?: unknown;
|
|
24
21
|
body?: unknown;
|
|
25
22
|
};
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
23
|
+
export type RequestFactory = {
|
|
24
|
+
[key: string]: (...args: any) => RequestData<any>;
|
|
25
|
+
};
|
|
29
26
|
export type ApiFor<TFactory extends RequestFactory> = {
|
|
30
|
-
[key in keyof TFactory]: TFactory[key] extends (
|
|
31
|
-
...args: infer TArgs
|
|
32
|
-
) => RequestData<infer TResponse>
|
|
33
|
-
? (...args: TArgs) => Promise<TResponse>
|
|
34
|
-
: never;
|
|
27
|
+
[key in keyof TFactory]: TFactory[key] extends (...args: infer TArgs) => RequestData<infer TResponse> ? (...args: TArgs) => Promise<TResponse> : never;
|
|
35
28
|
};
|
|
36
|
-
|
|
37
29
|
export type AutoPaginatedParams<T> = Omit<Exclude<T, undefined>, 'page' | 'size'>;
|