@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.
Files changed (146) hide show
  1. package/.eslintcache +1 -0
  2. package/.eslintignore +1 -0
  3. package/.eslintrc.json +25 -0
  4. package/.github/workflows/ci.yml +73 -0
  5. package/.husky/pre-commit +4 -0
  6. package/.prettierignore +1 -0
  7. package/.prettierrc.json +7 -0
  8. package/CHANGELOG.md +4 -0
  9. package/LICENSE +201 -0
  10. package/README.md +48 -0
  11. package/coverage/clover.xml +1645 -0
  12. package/coverage/coverage-final.json +19 -0
  13. package/coverage/lcov-report/base.css +224 -0
  14. package/coverage/lcov-report/block-navigation.js +87 -0
  15. package/coverage/lcov-report/favicon.png +0 -0
  16. package/coverage/lcov-report/index.html +146 -0
  17. package/coverage/lcov-report/prettify.css +1 -0
  18. package/coverage/lcov-report/prettify.js +2 -0
  19. package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
  20. package/coverage/lcov-report/sorter.js +196 -0
  21. package/coverage/lcov-report/src/helpers/index.html +131 -0
  22. package/coverage/lcov-report/src/helpers/openapi.ts.html +151 -0
  23. package/coverage/lcov-report/src/helpers/settings.ts.html +94 -0
  24. package/coverage/lcov-report/src/index.html +116 -0
  25. package/coverage/lcov-report/src/index.ts.html +88 -0
  26. package/coverage/lcov-report/src/modules/accounting.ts.html +1156 -0
  27. package/coverage/lcov-report/src/modules/api.ts.html +190 -0
  28. package/coverage/lcov-report/src/modules/consumer.ts.html +616 -0
  29. package/coverage/lcov-report/src/modules/consumers.ts.html +331 -0
  30. package/coverage/lcov-report/src/modules/custom.ts.html +193 -0
  31. package/coverage/lcov-report/src/modules/datastores.ts.html +142 -0
  32. package/coverage/lcov-report/src/modules/ecommerce.ts.html +331 -0
  33. package/coverage/lcov-report/src/modules/flow.ts.html +589 -0
  34. package/coverage/lcov-report/src/modules/index.html +326 -0
  35. package/coverage/lcov-report/src/modules/integrations.ts.html +151 -0
  36. package/coverage/lcov-report/src/modules/internalApi.ts.html +586 -0
  37. package/coverage/lcov-report/src/modules/invoicing.ts.html +391 -0
  38. package/coverage/lcov-report/src/modules/pos.ts.html +421 -0
  39. package/coverage/lcov-report/src/modules/sync.ts.html +316 -0
  40. package/coverage/lcov-report/src/modules/syncs.ts.html +169 -0
  41. package/coverage/lcov-report/src/modules/webhooks.ts.html +343 -0
  42. package/coverage/lcov.info +1976 -0
  43. package/dist/src/helpers/openapi.d.ts +3 -0
  44. package/dist/src/helpers/openapi.js +18 -0
  45. package/dist/src/helpers/settings.d.ts +4 -0
  46. package/dist/src/helpers/settings.js +5 -0
  47. package/dist/src/index.d.ts +1 -0
  48. package/dist/src/index.js +17 -0
  49. package/dist/src/modules/accounting.d.ts +48 -0
  50. package/dist/src/modules/accounting.js +255 -0
  51. package/dist/src/modules/api.d.ts +39333 -0
  52. package/dist/src/modules/api.js +36 -0
  53. package/dist/src/modules/consumer.d.ts +2588 -0
  54. package/dist/src/modules/consumer.js +118 -0
  55. package/dist/src/modules/consumers.d.ts +13034 -0
  56. package/dist/src/modules/consumers.js +51 -0
  57. package/dist/src/modules/custom.d.ts +8 -0
  58. package/dist/src/modules/custom.js +36 -0
  59. package/dist/src/modules/datastores.d.ts +18 -0
  60. package/dist/src/modules/datastores.js +23 -0
  61. package/dist/src/modules/ecommerce.d.ts +16 -0
  62. package/dist/src/modules/ecommerce.js +69 -0
  63. package/dist/src/modules/flow.d.ts +15 -0
  64. package/dist/src/modules/flow.js +156 -0
  65. package/dist/src/modules/integrations.d.ts +14 -0
  66. package/dist/src/modules/integrations.js +23 -0
  67. package/dist/src/modules/internalApi.d.ts +22 -0
  68. package/dist/src/modules/internalApi.js +160 -0
  69. package/dist/src/modules/invoicing.d.ts +18 -0
  70. package/dist/src/modules/invoicing.js +90 -0
  71. package/dist/src/modules/pos.d.ts +20 -0
  72. package/dist/src/modules/pos.js +80 -0
  73. package/dist/src/modules/sync.d.ts +10494 -0
  74. package/dist/src/modules/sync.js +75 -0
  75. package/dist/src/modules/syncs.d.ts +26200 -0
  76. package/dist/src/modules/syncs.js +29 -0
  77. package/dist/src/modules/webhooks.d.ts +55 -0
  78. package/dist/src/modules/webhooks.js +53 -0
  79. package/dist/src/types/api.d.ts +28 -0
  80. package/dist/src/types/api.js +2 -0
  81. package/dist/src/types/consumers.d.ts +8 -0
  82. package/dist/src/types/consumers.js +2 -0
  83. package/dist/src/types/public-api/mappings.d.ts +21 -0
  84. package/dist/src/types/public-api/mappings.js +2 -0
  85. package/dist/src/types/sync.d.ts +20 -0
  86. package/dist/src/types/sync.js +2 -0
  87. package/dist/test/modules/accounting.test.d.ts +1 -0
  88. package/dist/test/modules/accounting.test.js +453 -0
  89. package/dist/test/modules/consumer.test.d.ts +1 -0
  90. package/dist/test/modules/consumer.test.js +89 -0
  91. package/dist/test/modules/consumers.test.d.ts +1 -0
  92. package/dist/test/modules/consumers.test.js +109 -0
  93. package/dist/test/modules/ecommerce.test.d.ts +1 -0
  94. package/dist/test/modules/ecommerce.test.js +193 -0
  95. package/dist/test/modules/flow.test.d.ts +1 -0
  96. package/dist/test/modules/flow.test.js +69 -0
  97. package/dist/test/modules/integrations.test.d.ts +1 -0
  98. package/dist/test/modules/integrations.test.js +54 -0
  99. package/dist/test/modules/invoicing.test.d.ts +1 -0
  100. package/dist/test/modules/invoicing.test.js +108 -0
  101. package/dist/test/modules/pos.test.d.ts +1 -0
  102. package/dist/test/modules/pos.test.js +164 -0
  103. package/dist/test/modules/sync.test.d.ts +1 -0
  104. package/dist/test/modules/sync.test.js +81 -0
  105. package/dist/test/modules/syncs.test.d.ts +1 -0
  106. package/dist/test/modules/syncs.test.js +53 -0
  107. package/dist/test/modules/webhooks.test.d.ts +1 -0
  108. package/dist/test/modules/webhooks.test.js +120 -0
  109. package/jest.config.ts +195 -0
  110. package/package.json +47 -0
  111. package/src/helpers/openapi.ts +22 -0
  112. package/src/helpers/settings.ts +3 -0
  113. package/src/index.ts +1 -0
  114. package/src/modules/accounting.ts +357 -0
  115. package/src/modules/api.ts +35 -0
  116. package/src/modules/consumer.ts +177 -0
  117. package/src/modules/consumers.ts +82 -0
  118. package/src/modules/custom.ts +36 -0
  119. package/src/modules/datastores.ts +19 -0
  120. package/src/modules/ecommerce.ts +82 -0
  121. package/src/modules/flow.ts +168 -0
  122. package/src/modules/integrations.ts +22 -0
  123. package/src/modules/internalApi.ts +162 -0
  124. package/src/modules/invoicing.ts +106 -0
  125. package/src/modules/pos.ts +112 -0
  126. package/src/modules/sync.ts +77 -0
  127. package/src/modules/syncs.ts +28 -0
  128. package/src/modules/webhooks.ts +86 -0
  129. package/src/types/api.ts +35 -0
  130. package/src/types/consumers.ts +9 -0
  131. package/src/types/public-api/mappings.ts +21 -0
  132. package/src/types/public-api/schema.d.ts +9436 -0
  133. package/src/types/sync.ts +23 -0
  134. package/test/data/accounting_invoice.pdf +0 -0
  135. package/test/modules/accounting.test.ts +483 -0
  136. package/test/modules/consumer.test.ts +68 -0
  137. package/test/modules/consumers.test.ts +83 -0
  138. package/test/modules/ecommerce.test.ts +177 -0
  139. package/test/modules/integrations.test.ts +22 -0
  140. package/test/modules/invoicing.test.ts +88 -0
  141. package/test/modules/pos.test.ts +145 -0
  142. package/test/modules/sync.test.ts +60 -0
  143. package/test/modules/syncs.test.ts +23 -0
  144. package/test/modules/webhooks.test.ts +92 -0
  145. package/test/set_envs.sh +14 -0
  146. package/tsconfig.json +107 -0
@@ -0,0 +1,81 @@
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
+ const flowName = 'Je suis un flux de test';
46
+ let sync;
47
+ let flow;
48
+ (0, globals_1.beforeAll)(() => __awaiter(void 0, void 0, void 0, function* () {
49
+ const syncId = process.env.CHIFT_TEST_SYNC_ID;
50
+ sync = yield client.Syncs.getSyncById(syncId);
51
+ }));
52
+ (0, globals_1.test)('createFlow', () => __awaiter(void 0, void 0, void 0, function* () {
53
+ flow = yield sync.createFlow({
54
+ name: flowName,
55
+ description: 'Flux de test',
56
+ execution: {
57
+ type: 'code',
58
+ },
59
+ trigger: {
60
+ type: 'event',
61
+ },
62
+ config: {},
63
+ }, (consumer, flowContext) => __awaiter(void 0, void 0, void 0, function* () {
64
+ console.log(`Mon flow_id : ${flowContext.flow_id}`);
65
+ console.log(`Bonjour, ceci est un test, on exécute le flux pour consumer: ${consumer}`);
66
+ }));
67
+ (0, globals_1.expect)(flow).toHaveProperty('flowId');
68
+ (0, globals_1.expect)(flow).toHaveProperty('name', flowName);
69
+ }));
70
+ (0, globals_1.test)('getFlows', () => __awaiter(void 0, void 0, void 0, function* () {
71
+ const flows = yield sync.getFlows();
72
+ (0, globals_1.expect)(flows).toBeInstanceOf(Array);
73
+ }));
74
+ (0, globals_1.test)('getFlowByName', () => __awaiter(void 0, void 0, void 0, function* () {
75
+ const flowWithName = yield sync.getFlowByName(flow.name);
76
+ (0, globals_1.expect)(flowWithName).toHaveProperty('name', flow.name);
77
+ }));
78
+ (0, globals_1.test)('getFlowById', () => __awaiter(void 0, void 0, void 0, function* () {
79
+ const flowWithId = yield sync.getFlowById(flow.flowId);
80
+ (0, globals_1.expect)(flowWithId).toHaveProperty('flowId', flow.flowId);
81
+ }));
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,53 @@
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
+ (0, globals_1.test)('getSyncs', () => __awaiter(void 0, void 0, void 0, function* () {
46
+ const syncs = yield client.Syncs.getSyncs();
47
+ (0, globals_1.expect)(syncs).toBeInstanceOf(Array);
48
+ }));
49
+ (0, globals_1.test)('getSyncById', () => __awaiter(void 0, void 0, void 0, function* () {
50
+ const syncId = process.env.CHIFT_TEST_SYNC_ID;
51
+ const sync = yield client.Syncs.getSyncById(syncId);
52
+ (0, globals_1.expect)(sync).toHaveProperty('syncid', syncId);
53
+ }));
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,120 @@
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
+ var __importDefault = (this && this.__importDefault) || function (mod) {
35
+ return (mod && mod.__esModule) ? mod : { "default": mod };
36
+ };
37
+ Object.defineProperty(exports, "__esModule", { value: true });
38
+ const globals_1 = require("@jest/globals");
39
+ const chift = __importStar(require("../../src/index"));
40
+ const dotenv = __importStar(require("dotenv"));
41
+ const axios_1 = __importDefault(require("axios"));
42
+ dotenv.config();
43
+ const client = new chift.API({
44
+ baseUrl: process.env.CHIFT_BASE_URL,
45
+ clientId: process.env.CHIFT_CLIENT_ID,
46
+ clientSecret: process.env.CHIFT_CLIENT_SECRET,
47
+ accountId: process.env.CHIFT_ACCOUNT_ID,
48
+ });
49
+ let webhook;
50
+ (0, globals_1.beforeAll)(() => __awaiter(void 0, void 0, void 0, function* () {
51
+ webhook = yield client.Webhooks.registerWebhook({
52
+ event: 'account.connection.created',
53
+ url: 'https://test',
54
+ signingsecret: 'secret',
55
+ });
56
+ (0, globals_1.expect)(webhook).toHaveProperty('status', 'active');
57
+ (0, globals_1.expect)(webhook).toHaveProperty('webhookid', globals_1.expect.any(String));
58
+ (0, globals_1.expect)(webhook).toHaveProperty('accountid', globals_1.expect.any(String));
59
+ (0, globals_1.expect)(webhook).toHaveProperty('createdby');
60
+ (0, globals_1.expect)(webhook).toHaveProperty('createdon');
61
+ (0, globals_1.expect)(webhook).toHaveProperty('event', 'account.connection.created');
62
+ (0, globals_1.expect)(webhook).toHaveProperty('url', 'https://test');
63
+ (0, globals_1.expect)(webhook).toHaveProperty('status', 'active');
64
+ (0, globals_1.expect)(webhook).toHaveProperty('integrationid');
65
+ }));
66
+ (0, globals_1.test)('getWebhookTypes', () => __awaiter(void 0, void 0, void 0, function* () {
67
+ const webhookTypes = yield client.Webhooks.getWebhookTypes();
68
+ (0, globals_1.expect)(webhookTypes).toBeInstanceOf(Array);
69
+ (0, globals_1.expect)(webhookTypes.length).toBeGreaterThan(0);
70
+ (0, globals_1.expect)(webhookTypes[0]).toHaveProperty('event', globals_1.expect.any(String));
71
+ (0, globals_1.expect)(webhookTypes[0]).toHaveProperty('api');
72
+ }));
73
+ (0, globals_1.test)('getWebhooks', () => __awaiter(void 0, void 0, void 0, function* () {
74
+ const webhooks = yield client.Webhooks.getWebhooks();
75
+ (0, globals_1.expect)(webhooks).toBeInstanceOf(Array);
76
+ (0, globals_1.expect)(webhooks.length).toBeGreaterThan(0);
77
+ (0, globals_1.expect)(webhooks[0]).toHaveProperty('webhookid', globals_1.expect.any(String));
78
+ }));
79
+ (0, globals_1.test)('getWebhookById', () => __awaiter(void 0, void 0, void 0, function* () {
80
+ const webhookWithId = yield client.Webhooks.getWebhookById(webhook.webhookid);
81
+ (0, globals_1.expect)(webhookWithId).toHaveProperty('webhookid', webhook.webhookid);
82
+ (0, globals_1.expect)(webhookWithId).toHaveProperty('accountid', globals_1.expect.any(String));
83
+ (0, globals_1.expect)(webhookWithId).toHaveProperty('createdby');
84
+ (0, globals_1.expect)(webhookWithId).toHaveProperty('createdon');
85
+ (0, globals_1.expect)(webhookWithId).toHaveProperty('event', globals_1.expect.any(String));
86
+ (0, globals_1.expect)(webhookWithId).toHaveProperty('url', globals_1.expect.any(String));
87
+ (0, globals_1.expect)(webhookWithId).toHaveProperty('status', globals_1.expect.any(String));
88
+ (0, globals_1.expect)(webhookWithId).toHaveProperty('integrationid');
89
+ }));
90
+ (0, globals_1.test)('updateWebhookById', () => __awaiter(void 0, void 0, void 0, function* () {
91
+ const updatedWebhook = yield client.Webhooks.updateWebhookById(webhook.webhookid, {
92
+ status: 'inactive',
93
+ });
94
+ (0, globals_1.expect)(updatedWebhook).toHaveProperty('webhookid', globals_1.expect.any(String));
95
+ (0, globals_1.expect)(updatedWebhook).toHaveProperty('accountid', globals_1.expect.any(String));
96
+ (0, globals_1.expect)(updatedWebhook).toHaveProperty('createdby');
97
+ (0, globals_1.expect)(updatedWebhook).toHaveProperty('createdon');
98
+ (0, globals_1.expect)(updatedWebhook).toHaveProperty('event', 'account.connection.created');
99
+ (0, globals_1.expect)(updatedWebhook).toHaveProperty('url', 'https://test');
100
+ (0, globals_1.expect)(updatedWebhook).toHaveProperty('status', 'inactive');
101
+ (0, globals_1.expect)(updatedWebhook).toHaveProperty('integrationid');
102
+ }));
103
+ (0, globals_1.test)('getWebhookLogsByWebhookId', () => __awaiter(void 0, void 0, void 0, function* () {
104
+ const webhookLogs = yield client.Webhooks.getWebhookLogsByWebhookId(webhook.webhookid);
105
+ (0, globals_1.expect)(webhookLogs).toBeInstanceOf(Array);
106
+ }));
107
+ (0, globals_1.afterAll)(() => __awaiter(void 0, void 0, void 0, function* () {
108
+ globals_1.expect.assertions(1);
109
+ try {
110
+ yield client.Webhooks.unRegisterWebhook(webhook.webhookid);
111
+ yield client.Webhooks.getWebhookById(webhook.webhookid);
112
+ }
113
+ catch (e) {
114
+ if (axios_1.default.isAxiosError(e)) {
115
+ (0, globals_1.expect)(e.message).toMatch('Request failed with status code 404');
116
+ return;
117
+ }
118
+ throw e;
119
+ }
120
+ }));
package/jest.config.ts ADDED
@@ -0,0 +1,195 @@
1
+ /*
2
+ * For a detailed explanation regarding each configuration property and type check, visit:
3
+ * https://jestjs.io/docs/configuration
4
+ */
5
+
6
+ export default {
7
+ // All imported modules in your tests should be mocked automatically
8
+ // automock: false,
9
+
10
+ // Stop running tests after `n` failures
11
+ // bail: 0,
12
+
13
+ // The directory where Jest should store its cached dependency information
14
+ // cacheDirectory: "/private/var/folders/z7/d2q2nkfs49x74tqyg3t_7zt40000gn/T/jest_dx",
15
+
16
+ // Automatically clear mock calls, instances, contexts and results before every test
17
+ clearMocks: true,
18
+
19
+ // Indicates whether the coverage information should be collected while executing the test
20
+ collectCoverage: true,
21
+
22
+ // An array of glob patterns indicating a set of files for which coverage information should be collected
23
+ // collectCoverageFrom: undefined,
24
+
25
+ // The directory where Jest should output its coverage files
26
+ coverageDirectory: 'coverage',
27
+
28
+ // An array of regexp pattern strings used to skip coverage collection
29
+ // coveragePathIgnorePatterns: [
30
+ // "/node_modules/"
31
+ // ],
32
+
33
+ // Indicates which provider should be used to instrument code for coverage
34
+ coverageProvider: 'v8',
35
+
36
+ // A list of reporter names that Jest uses when writing coverage reports
37
+ // coverageReporters: [
38
+ // "json",
39
+ // "text",
40
+ // "lcov",
41
+ // "clover"
42
+ // ],
43
+
44
+ // An object that configures minimum threshold enforcement for coverage results
45
+ // coverageThreshold: undefined,
46
+
47
+ // A path to a custom dependency extractor
48
+ // dependencyExtractor: undefined,
49
+
50
+ // Make calling deprecated APIs throw helpful error messages
51
+ // errorOnDeprecated: false,
52
+
53
+ // The default configuration for fake timers
54
+ // fakeTimers: {
55
+ // "enableGlobally": false
56
+ // },
57
+
58
+ // Force coverage collection from ignored files using an array of glob patterns
59
+ // forceCoverageMatch: [],
60
+
61
+ // A path to a module which exports an async function that is triggered once before all test suites
62
+ // globalSetup: undefined,
63
+
64
+ // A path to a module which exports an async function that is triggered once after all test suites
65
+ // globalTeardown: undefined,
66
+
67
+ // A set of global variables that need to be available in all test environments
68
+ // globals: {},
69
+
70
+ // The maximum amount of workers used to run your tests. Can be specified as % or a number. E.g. maxWorkers: 10% will use 10% of your CPU amount + 1 as the maximum worker number. maxWorkers: 2 will use a maximum of 2 workers.
71
+ // maxWorkers: "50%",
72
+
73
+ // An array of directory names to be searched recursively up from the requiring module's location
74
+ moduleDirectories: ['node_modules', 'src'],
75
+
76
+ // An array of file extensions your modules use
77
+ // moduleFileExtensions: [
78
+ // "js",
79
+ // "mjs",
80
+ // "cjs",
81
+ // "jsx",
82
+ // "ts",
83
+ // "tsx",
84
+ // "json",
85
+ // "node"
86
+ // ],
87
+
88
+ // A map from regular expressions to module names or to arrays of module names that allow to stub out resources with a single module
89
+ // moduleNameMapper: {},
90
+
91
+ // An array of regexp pattern strings, matched against all module paths before considered 'visible' to the module loader
92
+ // modulePathIgnorePatterns: [],
93
+
94
+ // Activates notifications for test results
95
+ // notify: false,
96
+
97
+ // An enum that specifies notification mode. Requires { notify: true }
98
+ // notifyMode: "failure-change",
99
+
100
+ // A preset that is used as a base for Jest's configuration
101
+ preset: 'ts-jest',
102
+
103
+ // Run tests from one or more projects
104
+ // projects: undefined,
105
+
106
+ // Use this configuration option to add custom reporters to Jest
107
+ // reporters: undefined,
108
+
109
+ // Automatically reset mock state before every test
110
+ // resetMocks: false,
111
+
112
+ // Reset the module registry before running each individual test
113
+ // resetModules: false,
114
+
115
+ // A path to a custom resolver
116
+ // resolver: undefined,
117
+
118
+ // Automatically restore mock state and implementation before every test
119
+ // restoreMocks: false,
120
+
121
+ // The root directory that Jest should scan for tests and modules within
122
+ // rootDir: undefined,
123
+
124
+ // A list of paths to directories that Jest should use to search for files in
125
+ // roots: [
126
+ // "<rootDir>"
127
+ // ],
128
+
129
+ // Allows you to use a custom runner instead of Jest's default test runner
130
+ // runner: "jest-runner",
131
+
132
+ // The paths to modules that run some code to configure or set up the testing environment before each test
133
+ // setupFiles: [],
134
+
135
+ // A list of paths to modules that run some code to configure or set up the testing framework before each test
136
+ // setupFilesAfterEnv: [],
137
+
138
+ // The number of seconds after which a test is considered as slow and reported as such in the results.
139
+ // slowTestThreshold: 5,
140
+
141
+ // A list of paths to snapshot serializer modules Jest should use for snapshot testing
142
+ // snapshotSerializers: [],
143
+
144
+ // The test environment that will be used for testing
145
+ testEnvironment: 'node',
146
+
147
+ // Options that will be passed to the testEnvironment
148
+ // testEnvironmentOptions: {},
149
+
150
+ // Adds a location field to test results
151
+ // testLocationInResults: false,
152
+
153
+ // The glob patterns Jest uses to detect test files
154
+ // testMatch: [
155
+ // "**/__tests__/**/*.[jt]s?(x)",
156
+ // "**/?(*.)+(spec|test).[tj]s?(x)"
157
+ // ],
158
+
159
+ // An array of regexp pattern strings that are matched against all test paths, matched tests are skipped
160
+ // testPathIgnorePatterns: [
161
+ // "/node_modules/"
162
+ // ],
163
+
164
+ // The regexp pattern or array of patterns that Jest uses to detect test files
165
+ // testRegex: [],
166
+
167
+ // This option allows the use of a custom results processor
168
+ // testResultsProcessor: undefined,
169
+
170
+ // This option allows use of a custom test runner
171
+ // testRunner: "jest-circus/runner",
172
+
173
+ // A map from regular expressions to paths to transformers
174
+ //transform: undefined,
175
+
176
+ // An array of regexp pattern strings that are matched against all source file paths, matched files will skip transformation
177
+ // transformIgnorePatterns: [
178
+ // "/node_modules/",
179
+ // "\\.pnp\\.[^\\/]+$"
180
+ // ],
181
+
182
+ // An array of regexp pattern strings that are matched against all modules before the module loader will automatically return a mock for them
183
+ // unmockedModulePathPatterns: undefined,
184
+
185
+ // Indicates whether each individual test should be reported during the run
186
+ // verbose: undefined,
187
+
188
+ // An array of regexp patterns that are matched against all source file paths before re-running tests in watch mode
189
+ // watchPathIgnorePatterns: [],
190
+
191
+ // Whether to use watchman for file crawling
192
+ // watchman: true,
193
+
194
+ testTimeout: 30000,
195
+ };
package/package.json ADDED
@@ -0,0 +1,47 @@
1
+ {
2
+ "name": "@chift/chift-nodejs",
3
+ "version": "0.0.1",
4
+ "description": "The Chift NodeJS library provides convenient access to the Chift API from applications written in the NodeJS language (Javascript/Typescript).",
5
+ "main": "dist/src/index.js",
6
+ "types": "dist/src/index.d.ts",
7
+ "scripts": {
8
+ "dev": "chokidar src --command 'npm run build' --debounce=5000",
9
+ "prepare": "husky install",
10
+ "build": "tsc",
11
+ "test": "jest"
12
+ },
13
+ "keywords": [],
14
+ "author": "Chift",
15
+ "license": "Apache License 2.0",
16
+ "devDependencies": {
17
+ "@jest/globals": "^29.5.0",
18
+ "@types/node": "^18.15.11",
19
+ "@typescript-eslint/eslint-plugin": "^5.53.0",
20
+ "chokidar-cli": "^3.0.0",
21
+ "eslint": "^8.34.0",
22
+ "eslint-config-prettier": "^8.6.0",
23
+ "eslint-config-standard-with-typescript": "^34.0.0",
24
+ "eslint-plugin-import": "^2.27.5",
25
+ "eslint-plugin-n": "^15.6.1",
26
+ "eslint-plugin-prettier": "^4.2.1",
27
+ "eslint-plugin-promise": "^6.1.1",
28
+ "husky": "^8.0.3",
29
+ "jest": "^29.7.0",
30
+ "lint-staged": "^13.2.0",
31
+ "prettier": "^2.8.4",
32
+ "ts-jest": "^29.1.1",
33
+ "ts-node": "^10.9.1",
34
+ "typescript": "^4.9.5"
35
+ },
36
+ "dependencies": {
37
+ "axios": "^1.5.0",
38
+ "dotenv": "^16.0.3"
39
+ },
40
+ "lint-staged": {
41
+ "**/*.{js,ts,json}": [
42
+ "npx prettier --write",
43
+ "npx eslint --cache --fix"
44
+ ]
45
+ },
46
+ "homepage": "https://github.com/chift-oneapi/chift-nodejs-sdk"
47
+ }
@@ -0,0 +1,22 @@
1
+ import { InternalAPI } from '../modules/internalApi';
2
+ import { RequestFactory, ApiFor } from '../types/api';
3
+
4
+ export function createApiFor<TFactory extends RequestFactory>(
5
+ factory: TFactory,
6
+ internalApi: InternalAPI,
7
+ consumerName: string,
8
+ consumerId: string
9
+ ) {
10
+ return new Proxy(factory, {
11
+ get(target: any, property) {
12
+ return (...args: any[]) => {
13
+ const requestData = target[property](...args);
14
+ requestData.property = property;
15
+ requestData.consumerName = consumerName;
16
+ requestData.consumerId = consumerId;
17
+ requestData.url = requestData.url.replace('{consumer_id}', consumerId);
18
+ return internalApi.makeRequest(requestData);
19
+ };
20
+ },
21
+ }) as unknown as ApiFor<TFactory>;
22
+ }
@@ -0,0 +1,3 @@
1
+ export default {
2
+ BASE_URL: 'https://api.chift.eu',
3
+ };
package/src/index.ts ADDED
@@ -0,0 +1 @@
1
+ export * from './modules/api';