@chift/chift-nodejs 1.0.16 → 1.0.18

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.
Files changed (145) hide show
  1. package/README.md +3 -3
  2. package/package.json +5 -2
  3. package/src/types/public-api/schema.d.ts +4071 -850
  4. package/src/types/sync.ts +20 -5
  5. package/.eslintcache +0 -1
  6. package/.eslintignore +0 -1
  7. package/.eslintrc.json +0 -25
  8. package/.github/workflows/ci.yml +0 -75
  9. package/.husky/pre-commit +0 -4
  10. package/.prettierignore +0 -1
  11. package/.prettierrc.json +0 -7
  12. package/CHANGELOG.md +0 -98
  13. package/coverage/clover.xml +0 -1645
  14. package/coverage/coverage-final.json +0 -19
  15. package/coverage/lcov-report/base.css +0 -224
  16. package/coverage/lcov-report/block-navigation.js +0 -87
  17. package/coverage/lcov-report/favicon.png +0 -0
  18. package/coverage/lcov-report/index.html +0 -146
  19. package/coverage/lcov-report/prettify.css +0 -1
  20. package/coverage/lcov-report/prettify.js +0 -2
  21. package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
  22. package/coverage/lcov-report/sorter.js +0 -196
  23. package/coverage/lcov-report/src/helpers/index.html +0 -131
  24. package/coverage/lcov-report/src/helpers/openapi.ts.html +0 -151
  25. package/coverage/lcov-report/src/helpers/settings.ts.html +0 -94
  26. package/coverage/lcov-report/src/index.html +0 -116
  27. package/coverage/lcov-report/src/index.ts.html +0 -88
  28. package/coverage/lcov-report/src/modules/accounting.ts.html +0 -1156
  29. package/coverage/lcov-report/src/modules/api.ts.html +0 -190
  30. package/coverage/lcov-report/src/modules/consumer.ts.html +0 -616
  31. package/coverage/lcov-report/src/modules/consumers.ts.html +0 -331
  32. package/coverage/lcov-report/src/modules/custom.ts.html +0 -193
  33. package/coverage/lcov-report/src/modules/datastores.ts.html +0 -142
  34. package/coverage/lcov-report/src/modules/ecommerce.ts.html +0 -331
  35. package/coverage/lcov-report/src/modules/flow.ts.html +0 -589
  36. package/coverage/lcov-report/src/modules/index.html +0 -326
  37. package/coverage/lcov-report/src/modules/integrations.ts.html +0 -151
  38. package/coverage/lcov-report/src/modules/internalApi.ts.html +0 -586
  39. package/coverage/lcov-report/src/modules/invoicing.ts.html +0 -391
  40. package/coverage/lcov-report/src/modules/pos.ts.html +0 -421
  41. package/coverage/lcov-report/src/modules/sync.ts.html +0 -316
  42. package/coverage/lcov-report/src/modules/syncs.ts.html +0 -169
  43. package/coverage/lcov-report/src/modules/webhooks.ts.html +0 -343
  44. package/coverage/lcov.info +0 -1976
  45. package/dist/src/helpers/openapi.d.ts +0 -3
  46. package/dist/src/helpers/openapi.js +0 -18
  47. package/dist/src/helpers/settings.d.ts +0 -4
  48. package/dist/src/helpers/settings.js +0 -5
  49. package/dist/src/index.d.ts +0 -1
  50. package/dist/src/modules/accounting.d.ts +0 -68
  51. package/dist/src/modules/accounting.js +0 -326
  52. package/dist/src/modules/api.d.ts +0 -16795
  53. package/dist/src/modules/api.js +0 -36
  54. package/dist/src/modules/consumer.d.ts +0 -3313
  55. package/dist/src/modules/consumer.js +0 -139
  56. package/dist/src/modules/consumers.d.ts +0 -16684
  57. package/dist/src/modules/consumers.js +0 -51
  58. package/dist/src/modules/custom.d.ts +0 -8
  59. package/dist/src/modules/custom.js +0 -36
  60. package/dist/src/modules/datastores.d.ts +0 -18
  61. package/dist/src/modules/datastores.js +0 -23
  62. package/dist/src/modules/ecommerce.d.ts +0 -24
  63. package/dist/src/modules/ecommerce.js +0 -97
  64. package/dist/src/modules/flow.d.ts +0 -15
  65. package/dist/src/modules/flow.js +0 -156
  66. package/dist/src/modules/integrations.d.ts +0 -23
  67. package/dist/src/modules/integrations.js +0 -23
  68. package/dist/src/modules/internalApi.d.ts +0 -24
  69. package/dist/src/modules/internalApi.js +0 -175
  70. package/dist/src/modules/invoicing.d.ts +0 -20
  71. package/dist/src/modules/invoicing.js +0 -90
  72. package/dist/src/modules/pms.d.ts +0 -15
  73. package/dist/src/modules/pms.js +0 -47
  74. package/dist/src/modules/pos.d.ts +0 -26
  75. package/dist/src/modules/pos.js +0 -101
  76. package/dist/src/modules/sync.d.ts +0 -13414
  77. package/dist/src/modules/sync.js +0 -73
  78. package/dist/src/modules/syncs.d.ts +0 -11
  79. package/dist/src/modules/syncs.js +0 -39
  80. package/dist/src/modules/webhooks.d.ts +0 -55
  81. package/dist/src/modules/webhooks.js +0 -53
  82. package/dist/src/types/api.d.ts +0 -29
  83. package/dist/src/types/api.js +0 -2
  84. package/dist/src/types/consumers.d.ts +0 -8
  85. package/dist/src/types/consumers.js +0 -2
  86. package/dist/src/types/public-api/mappings.d.ts +0 -21
  87. package/dist/src/types/public-api/mappings.js +0 -2
  88. package/dist/src/types/public-api/schema.d.ts +0 -12003
  89. package/dist/src/types/public-api/schema.js +0 -6
  90. package/dist/src/types/sync.d.ts +0 -20
  91. package/dist/src/types/sync.js +0 -2
  92. package/dist/test/modules/accounting.test.d.ts +0 -1
  93. package/dist/test/modules/accounting.test.js +0 -582
  94. package/dist/test/modules/consumer.test.d.ts +0 -1
  95. package/dist/test/modules/consumer.test.js +0 -89
  96. package/dist/test/modules/consumers.test.d.ts +0 -1
  97. package/dist/test/modules/consumers.test.js +0 -109
  98. package/dist/test/modules/ecommerce.test.d.ts +0 -1
  99. package/dist/test/modules/ecommerce.test.js +0 -220
  100. package/dist/test/modules/integrations.test.d.ts +0 -1
  101. package/dist/test/modules/integrations.test.js +0 -54
  102. package/dist/test/modules/invoicing.test.d.ts +0 -1
  103. package/dist/test/modules/invoicing.test.js +0 -108
  104. package/dist/test/modules/pos.test.d.ts +0 -1
  105. package/dist/test/modules/pos.test.js +0 -182
  106. package/dist/test/modules/sync.test.d.ts +0 -1
  107. package/dist/test/modules/sync.test.js +0 -81
  108. package/dist/test/modules/syncs.test.d.ts +0 -1
  109. package/dist/test/modules/syncs.test.js +0 -53
  110. package/dist/test/modules/webhooks.test.d.ts +0 -1
  111. package/dist/test/modules/webhooks.test.js +0 -120
  112. package/jest.config.ts +0 -195
  113. package/src/helpers/openapi.ts +0 -22
  114. package/src/helpers/settings.ts +0 -3
  115. package/src/index.ts +0 -1
  116. package/src/modules/accounting.ts +0 -510
  117. package/src/modules/api.ts +0 -35
  118. package/src/modules/consumer.ts +0 -213
  119. package/src/modules/consumers.ts +0 -82
  120. package/src/modules/custom.ts +0 -36
  121. package/src/modules/datastores.ts +0 -19
  122. package/src/modules/ecommerce.ts +0 -127
  123. package/src/modules/flow.ts +0 -168
  124. package/src/modules/integrations.ts +0 -24
  125. package/src/modules/internalApi.ts +0 -182
  126. package/src/modules/invoicing.ts +0 -114
  127. package/src/modules/pms.ts +0 -67
  128. package/src/modules/pos.ts +0 -144
  129. package/src/modules/sync.ts +0 -77
  130. package/src/modules/syncs.ts +0 -59
  131. package/src/modules/webhooks.ts +0 -86
  132. package/src/types/public-api/schema.ts +0 -12073
  133. package/test/data/accounting_invoice.pdf +0 -0
  134. package/test/modules/accounting.test.ts +0 -628
  135. package/test/modules/consumer.test.ts +0 -68
  136. package/test/modules/consumers.test.ts +0 -85
  137. package/test/modules/ecommerce.test.ts +0 -208
  138. package/test/modules/integrations.test.ts +0 -22
  139. package/test/modules/invoicing.test.ts +0 -88
  140. package/test/modules/pos.test.ts +0 -166
  141. package/test/modules/sync.test.ts +0 -60
  142. package/test/modules/syncs.test.ts +0 -23
  143. package/test/modules/webhooks.test.ts +0 -92
  144. package/test/set_envs.sh +0 -14
  145. package/tsconfig.json +0 -107
@@ -1,73 +0,0 @@
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
- trigger: context.trigger,
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;
@@ -1,11 +0,0 @@
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 };
@@ -1,39 +0,0 @@
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;
@@ -1,55 +0,0 @@
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
- content: never;
33
- }>;
34
- getWebhookLogsByWebhookId: (webhookId: string) => Promise<{
35
- webhooklogid: string;
36
- webhookid: string;
37
- event: string;
38
- url: string;
39
- accountid: string;
40
- createdon: string;
41
- httpstatus: number;
42
- integrationid?: number | undefined;
43
- }[]>;
44
- getWebhooks: () => Promise<{
45
- webhookid: string;
46
- accountid: string;
47
- createdby?: string | undefined;
48
- createdon: string;
49
- event: string;
50
- url: string;
51
- status: "active" | "inactive";
52
- integrationid?: number | undefined;
53
- }[]>;
54
- };
55
- export { Webhooks };
@@ -1,53 +0,0 @@
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;
@@ -1,29 +0,0 @@
1
- export interface AuthType {
2
- clientId: string;
3
- clientSecret: string;
4
- accountId: string;
5
- envId?: string;
6
- baseUrl?: string;
7
- }
8
- export interface TokenType {
9
- access_token: string;
10
- token_type: string;
11
- expires_in: number;
12
- expires_on: number;
13
- }
14
- export type RequestData<TResponse> = {
15
- method: string;
16
- property?: string;
17
- consumerName?: string;
18
- consumerId?: string;
19
- url: string;
20
- params?: unknown;
21
- body?: unknown;
22
- };
23
- export type RequestFactory = {
24
- [key: string]: (...args: any) => RequestData<any>;
25
- };
26
- export type ApiFor<TFactory extends RequestFactory> = {
27
- [key in keyof TFactory]: TFactory[key] extends (...args: infer TArgs) => RequestData<infer TResponse> ? (...args: TArgs) => Promise<TResponse> : never;
28
- };
29
- export type AutoPaginatedParams<T> = Omit<Exclude<T, undefined>, 'page' | 'size'>;
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,8 +0,0 @@
1
- export interface Consumers {
2
- method: void;
3
- }
4
- export interface ConsumerLog {
5
- type: string;
6
- message: string;
7
- context: any;
8
- }
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,21 +0,0 @@
1
- export type chiftOperations = {
2
- getConsumers: 'consumers_get_consumers';
3
- createConsumer: 'consumers_create_consumer';
4
- getConsumerById: 'consumers_get_consumer';
5
- updateConsumer: 'consumers_update_consumer';
6
- deleteConsumerById: 'consumers_delete_consumer';
7
- getConnectionsByConsumerId: 'connections_get_connections';
8
- createConnection: 'connections_create_connection';
9
- deleteConnectionById: 'connections_delete_connection';
10
- updateConnection: 'connections_update_connection';
11
- getSyncs: 'syncs_get_syncs';
12
- getIntegrations: 'integrations_get_integrations';
13
- getWebhookTypes: 'webhooks_get_webhook_types';
14
- getWebhooks: 'webhooks_get_webhooks';
15
- registerWebhook: 'webhooks_create_webhook';
16
- unRegisterWebhook: 'webhooks_delete_webhook';
17
- getWebhookById: 'webhooks_get_webhook';
18
- updateWebhookById: 'webhooks_update_webhook';
19
- getWebhookLogsByWebhookId: 'webhooks_get_webhook_logs';
20
- getSync: 'syncs_get_sync';
21
- };
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });