@chift/chift-nodejs 1.0.0 → 1.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 (42) hide show
  1. package/.eslintcache +1 -0
  2. package/CHANGELOG.md +5 -1
  3. package/coverage/clover.xml +1645 -0
  4. package/coverage/coverage-final.json +19 -0
  5. package/coverage/lcov-report/base.css +224 -0
  6. package/coverage/lcov-report/block-navigation.js +87 -0
  7. package/coverage/lcov-report/favicon.png +0 -0
  8. package/coverage/lcov-report/index.html +146 -0
  9. package/coverage/lcov-report/prettify.css +1 -0
  10. package/coverage/lcov-report/prettify.js +2 -0
  11. package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
  12. package/coverage/lcov-report/sorter.js +196 -0
  13. package/coverage/lcov-report/src/helpers/index.html +131 -0
  14. package/coverage/lcov-report/src/helpers/openapi.ts.html +151 -0
  15. package/coverage/lcov-report/src/helpers/settings.ts.html +94 -0
  16. package/coverage/lcov-report/src/index.html +116 -0
  17. package/coverage/lcov-report/src/index.ts.html +88 -0
  18. package/coverage/lcov-report/src/modules/accounting.ts.html +1156 -0
  19. package/coverage/lcov-report/src/modules/api.ts.html +190 -0
  20. package/coverage/lcov-report/src/modules/consumer.ts.html +616 -0
  21. package/coverage/lcov-report/src/modules/consumers.ts.html +331 -0
  22. package/coverage/lcov-report/src/modules/custom.ts.html +193 -0
  23. package/coverage/lcov-report/src/modules/datastores.ts.html +142 -0
  24. package/coverage/lcov-report/src/modules/ecommerce.ts.html +331 -0
  25. package/coverage/lcov-report/src/modules/flow.ts.html +589 -0
  26. package/coverage/lcov-report/src/modules/index.html +326 -0
  27. package/coverage/lcov-report/src/modules/integrations.ts.html +151 -0
  28. package/coverage/lcov-report/src/modules/internalApi.ts.html +586 -0
  29. package/coverage/lcov-report/src/modules/invoicing.ts.html +391 -0
  30. package/coverage/lcov-report/src/modules/pos.ts.html +421 -0
  31. package/coverage/lcov-report/src/modules/sync.ts.html +316 -0
  32. package/coverage/lcov-report/src/modules/syncs.ts.html +169 -0
  33. package/coverage/lcov-report/src/modules/webhooks.ts.html +343 -0
  34. package/coverage/lcov.info +1976 -0
  35. package/dist/src/modules/sync.js +2 -0
  36. package/dist/test/modules/flow.test.d.ts +1 -0
  37. package/dist/test/modules/flow.test.js +69 -0
  38. package/dist/test/modules/pos.test.js +4 -4
  39. package/package.json +1 -1
  40. package/src/modules/accounting.ts +14 -0
  41. package/src/types/public-api/schema.d.ts +162 -3
  42. package/test/modules/accounting.test.ts +14 -0
@@ -22,7 +22,9 @@ const Sync = (internalApi, body) => {
22
22
  };
23
23
  const getFlowByName = (name) => {
24
24
  const flow = data.flows.find((flow) => flow.name.toLowerCase() === name.toLowerCase());
25
+ console.log('undefined ?');
25
26
  if (flow) {
27
+ console.log('on a le flux');
26
28
  return (0, flow_1.Flow)(_internalApi, flow, data.syncid, data.consumers);
27
29
  }
28
30
  return undefined;
@@ -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
+ }));
@@ -61,8 +61,8 @@ let lightspeedConsumer;
61
61
  let orders;
62
62
  (0, globals_1.test)('getOrders', () => __awaiter(void 0, void 0, void 0, function* () {
63
63
  orders = yield lightspeedConsumer.pos.getOrders({
64
- date_from: '2023-01-11',
65
- date_to: '2023-02-28',
64
+ date_from: '2022-08-11',
65
+ date_to: '2022-08-12',
66
66
  });
67
67
  (0, globals_1.expect)(orders).toBeInstanceOf(Array);
68
68
  (0, globals_1.expect)(orders.length).toBeGreaterThan(0);
@@ -142,8 +142,8 @@ globals_1.test.skip('getCustomer', () => __awaiter(void 0, void 0, void 0, funct
142
142
  }));
143
143
  (0, globals_1.test)('getPayments', () => __awaiter(void 0, void 0, void 0, function* () {
144
144
  const payments = yield lightspeedConsumer.pos.getPayments({
145
- date_from: '2023-01-11',
146
- date_to: '2023-02-28',
145
+ date_from: '2022-08-11',
146
+ date_to: '2022-08-12',
147
147
  });
148
148
  (0, globals_1.expect)(payments).toBeInstanceOf(Array);
149
149
  (0, globals_1.expect)(payments.length).toBeGreaterThan(0);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@chift/chift-nodejs",
3
- "version": "1.0.0",
3
+ "version": "1.0.1",
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",
@@ -31,6 +31,11 @@ type getInvoicesByTypeParams = Omit<
31
31
  'page' | 'size'
32
32
  >;
33
33
 
34
+ type getOutstandingsParams = Omit<
35
+ operations['accounting_get_outstandings']['parameters']['query'],
36
+ 'page' | 'size'
37
+ >;
38
+
34
39
  const accountingFactory = {
35
40
  getAnalyticPlans(): RequestData<components['schemas']['AnalyticPlanItem'][]> {
36
41
  return {
@@ -343,6 +348,15 @@ const accountingFactory = {
343
348
  url: '/consumers/{consumer_id}/accounting/employees',
344
349
  };
345
350
  },
351
+ getOutstandings(
352
+ params: getOutstandingsParams
353
+ ): RequestData<components['schemas']['OutstandingItem'][]> {
354
+ return {
355
+ params,
356
+ method: 'get',
357
+ url: '/consumers/{consumer_id}/accounting/outstandings',
358
+ };
359
+ },
346
360
  createFinancialEntry(
347
361
  financial_entry: components['schemas']['FinancialEntryItemIn']
348
362
  ): RequestData<components['schemas']['FinancialEntryItemOut']> {
@@ -128,6 +128,13 @@ export interface paths {
128
128
  */
129
129
  post: operations['syncs_send_custom_event'];
130
130
  };
131
+ '/consumers/{consumerid}/syncs/{syncid}/flows/{flowid}/executions': {
132
+ /**
133
+ * Get executions information for one consumer/flow/sync
134
+ * @description Returns executions information for one consumer/flow/sync
135
+ */
136
+ get: operations['syncs_get_consumer_executions'];
137
+ };
131
138
  '/syncs/{syncid}/flows/{flowid}/executions/{executionid}': {
132
139
  /**
133
140
  * Get execution start/end timestamp
@@ -431,6 +438,13 @@ export interface paths {
431
438
  */
432
439
  post: operations['accounting_create_financial_entry'];
433
440
  };
441
+ '/consumers/{consumer_id}/accounting/outstandings': {
442
+ /**
443
+ * Get clients/suppliers outstandings
444
+ * @description Returns a list of all clients/suppliers outstanding's informations
445
+ */
446
+ get: operations['accounting_get_outstandings'];
447
+ };
434
448
  '/consumers/{consumer_id}/pos/orders': {
435
449
  /**
436
450
  * Get orders
@@ -1284,6 +1298,8 @@ export interface components {
1284
1298
  addresses?: components['schemas']['models__common__AddressItemOut'][];
1285
1299
  /** Account Number */
1286
1300
  account_number?: string;
1301
+ /** Company Number */
1302
+ company_number?: string;
1287
1303
  /** Id */
1288
1304
  id?: string;
1289
1305
  };
@@ -3087,7 +3103,8 @@ export interface components {
3087
3103
  | 'supplier_invoice'
3088
3104
  | 'supplier_refund'
3089
3105
  | 'financial_operation'
3090
- | 'miscellaneous_operation';
3106
+ | 'miscellaneous_operation'
3107
+ | 'unknown';
3091
3108
  /** LinkItem */
3092
3109
  LinkItem: {
3093
3110
  /** Url */
@@ -3629,6 +3646,48 @@ export interface components {
3629
3646
  * @enum {string}
3630
3647
  */
3631
3648
  OrderStatus: 'cancelled' | 'draft' | 'confirmed';
3649
+ /** OutstandingItem */
3650
+ OutstandingItem: {
3651
+ /** Id */
3652
+ id: string;
3653
+ /** Number */
3654
+ number?: string;
3655
+ /** Journal Id */
3656
+ journal_id: string;
3657
+ journal_type: components['schemas']['JournalType'];
3658
+ /**
3659
+ * Date
3660
+ * Format: date
3661
+ */
3662
+ date: string;
3663
+ /**
3664
+ * Due Date
3665
+ * Format: date
3666
+ */
3667
+ due_date?: string;
3668
+ /** Currency */
3669
+ currency: string;
3670
+ /** Currency Exchange Rate */
3671
+ currency_exchange_rate: number;
3672
+ /** Amount */
3673
+ amount: number;
3674
+ /** Open Amount */
3675
+ open_amount: number;
3676
+ /** Partner Id */
3677
+ partner_id: string;
3678
+ /** Account Number */
3679
+ account_number: string;
3680
+ /** Reference */
3681
+ reference?: string;
3682
+ /** Posted */
3683
+ posted: boolean;
3684
+ };
3685
+ /**
3686
+ * OutstandingType
3687
+ * @description An enumeration.
3688
+ * @enum {string}
3689
+ */
3690
+ OutstandingType: 'client' | 'supplier';
3632
3691
  /** POSCreateCustomerItem */
3633
3692
  POSCreateCustomerItem: {
3634
3693
  /** First Name */
@@ -3942,6 +4001,17 @@ export interface components {
3942
4001
  /** Size */
3943
4002
  size: number;
3944
4003
  };
4004
+ /** Page[OutstandingItem] */
4005
+ Page_OutstandingItem_: {
4006
+ /** Items */
4007
+ items: components['schemas']['OutstandingItem'][];
4008
+ /** Total */
4009
+ total: number;
4010
+ /** Page */
4011
+ page: number;
4012
+ /** Size */
4013
+ size: number;
4014
+ };
3945
4015
  /** Page[POSCustomerItem] */
3946
4016
  Page_POSCustomerItem_: {
3947
4017
  /** Items */
@@ -4564,6 +4634,8 @@ export interface components {
4564
4634
  addresses?: components['schemas']['models__common__AddressItemOut'][];
4565
4635
  /** Account Number */
4566
4636
  account_number?: string;
4637
+ /** Company Number */
4638
+ company_number?: string;
4567
4639
  /** Id */
4568
4640
  id?: string;
4569
4641
  };
@@ -4735,7 +4807,15 @@ export interface components {
4735
4807
  * @description An enumeration.
4736
4808
  * @enum {string}
4737
4809
  */
4738
- TransactionAccountingCategory: 'all' | 'unknown' | 'test';
4810
+ TransactionAccountingCategory:
4811
+ | 'all'
4812
+ | 'unknown'
4813
+ | 'payout'
4814
+ | 'payout_cancel'
4815
+ | 'payment'
4816
+ | 'payment_cancel'
4817
+ | 'fee'
4818
+ | 'fee_cancel';
4739
4819
  /**
4740
4820
  * TransactionFilterDateType
4741
4821
  * @description An enumeration.
@@ -6022,12 +6102,52 @@ export interface operations {
6022
6102
  };
6023
6103
  };
6024
6104
  };
6105
+ /**
6106
+ * Get executions information for one consumer/flow/sync
6107
+ * @description Returns executions information for one consumer/flow/sync
6108
+ */
6109
+ syncs_get_consumer_executions: {
6110
+ parameters: {
6111
+ query?: {
6112
+ date_to?: string;
6113
+ date_from?: string;
6114
+ };
6115
+ path: {
6116
+ consumerid: string;
6117
+ syncid: string;
6118
+ flowid: string;
6119
+ };
6120
+ };
6121
+ responses: {
6122
+ /** @description Successful Response */
6123
+ 200: {
6124
+ content: {
6125
+ 'application/json': components['schemas']['ChainExecutionItem'][];
6126
+ };
6127
+ };
6128
+ /** @description Not Found */
6129
+ 404: {
6130
+ content: {
6131
+ 'application/json': components['schemas']['ChiftError'];
6132
+ };
6133
+ };
6134
+ /** @description Validation Error */
6135
+ 422: {
6136
+ content: {
6137
+ 'application/json': components['schemas']['HTTPValidationError'];
6138
+ };
6139
+ };
6140
+ };
6141
+ };
6025
6142
  /**
6026
6143
  * Get execution start/end timestamp
6027
6144
  * @description Get execution start/end timestamp
6028
6145
  */
6029
6146
  syncs_get_execution: {
6030
6147
  parameters: {
6148
+ query?: {
6149
+ consumerid?: string;
6150
+ };
6031
6151
  path: {
6032
6152
  syncid: string;
6033
6153
  flowid: string;
@@ -6161,6 +6281,8 @@ export interface operations {
6161
6281
  datastores_get_consumer_and_datastoredata: {
6162
6282
  parameters: {
6163
6283
  query?: {
6284
+ date_to?: string;
6285
+ date_from?: string;
6164
6286
  executionid?: string;
6165
6287
  };
6166
6288
  path: {
@@ -7858,6 +7980,43 @@ export interface operations {
7858
7980
  };
7859
7981
  };
7860
7982
  };
7983
+ /**
7984
+ * Get clients/suppliers outstandings
7985
+ * @description Returns a list of all clients/suppliers outstanding's informations
7986
+ */
7987
+ accounting_get_outstandings: {
7988
+ parameters: {
7989
+ query: {
7990
+ type: components['schemas']['OutstandingType'];
7991
+ unposted_allowed: components['schemas']['BoolParam'];
7992
+ page?: number;
7993
+ size?: number;
7994
+ };
7995
+ path: {
7996
+ consumer_id: string;
7997
+ };
7998
+ };
7999
+ responses: {
8000
+ /** @description Successful Response */
8001
+ 200: {
8002
+ content: {
8003
+ 'application/json': components['schemas']['Page_OutstandingItem_'];
8004
+ };
8005
+ };
8006
+ /** @description Bad Request */
8007
+ 400: {
8008
+ content: {
8009
+ 'application/json': components['schemas']['ChiftError'];
8010
+ };
8011
+ };
8012
+ /** @description Validation Error */
8013
+ 422: {
8014
+ content: {
8015
+ 'application/json': components['schemas']['HTTPValidationError'];
8016
+ };
8017
+ };
8018
+ };
8019
+ };
7861
8020
  /**
7862
8021
  * Get orders
7863
8022
  * @description Returns a list of the orders
@@ -8669,7 +8828,7 @@ export interface operations {
8669
8828
  date_from?: string;
8670
8829
  /** @description Filter orders created at or before this date (e.g. 2023-01-31) */
8671
8830
  date_to?: string;
8672
- /** @description Filter orders last updated at or after this date (e.g. 2023-01-31T15:00:00 for 31 of January 2023 at 3PM UTC) */
8831
+ /** @description Filter orders last updated at or after this date (e.g. 2023-01-31T15:00:00 for 31 of January 2023 at 3PM UTC). UTC is the only format that is supported on all connectors. */
8673
8832
  updated_after?: string;
8674
8833
  /** @description Include detailed information concerning refunds */
8675
8834
  include_detailed_refunds?: components['schemas']['BoolParam'];
@@ -481,3 +481,17 @@ test('getBalanceOfAccounts', async () => {
481
481
  expect(balanceOfAccounts).toHaveProperty('items');
482
482
  expect(balanceOfAccounts.items).toBeInstanceOf(Array);
483
483
  });
484
+
485
+ test('getEmployees', async () => {
486
+ const employees = await consumer.accounting.getEmployees();
487
+ expect(employees).toBeTruthy();
488
+ expect(employees.items).toBeInstanceOf(Array);
489
+ });
490
+
491
+ test('getOutstandings', async () => {
492
+ const outstandings = await consumer.accounting.getOutstandings({
493
+ type: 'client',
494
+ });
495
+ expect(outstandings).toBeTruthy();
496
+ expect(outstandings.items).toBeInstanceOf(Array);
497
+ });