@chift/chift-nodejs 1.0.22 → 1.0.24

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 (45) hide show
  1. package/README.md +37 -0
  2. package/dist/src/modules/accounting.d.ts +46 -42
  3. package/dist/src/modules/accounting.js +117 -42
  4. package/dist/src/modules/api.d.ts +13477 -11015
  5. package/dist/src/modules/banking.d.ts +13 -0
  6. package/dist/src/modules/banking.js +38 -0
  7. package/dist/src/modules/consumer.d.ts +2639 -2163
  8. package/dist/src/modules/consumer.js +3 -0
  9. package/dist/src/modules/consumers.d.ts +13432 -10982
  10. package/dist/src/modules/custom.d.ts +4 -4
  11. package/dist/src/modules/custom.js +6 -3
  12. package/dist/src/modules/datastores.d.ts +12 -6
  13. package/dist/src/modules/ecommerce.d.ts +18 -15
  14. package/dist/src/modules/ecommerce.js +32 -14
  15. package/dist/src/modules/flow.d.ts +2 -2
  16. package/dist/src/modules/integrations.d.ts +4 -2
  17. package/dist/src/modules/internalApi.js +8 -0
  18. package/dist/src/modules/invoicing.d.ts +16 -16
  19. package/dist/src/modules/invoicing.js +33 -18
  20. package/dist/src/modules/payment.d.ts +6 -6
  21. package/dist/src/modules/payment.js +10 -5
  22. package/dist/src/modules/pms.d.ts +8 -8
  23. package/dist/src/modules/pms.js +16 -8
  24. package/dist/src/modules/pos.d.ts +15 -15
  25. package/dist/src/modules/pos.js +29 -15
  26. package/dist/src/modules/sync.d.ts +10804 -8842
  27. package/dist/src/modules/webhooks.d.ts +12 -12
  28. package/dist/src/types/api.d.ts +8 -0
  29. package/dist/src/types/public-api/mappings.d.ts +128 -1
  30. package/dist/src/types/public-api/schema.d.ts +4575 -1985
  31. package/dist/test/modules/accounting.test.js +101 -28
  32. package/dist/test/modules/banking.test.d.ts +1 -0
  33. package/dist/test/modules/banking.test.js +94 -0
  34. package/dist/test/modules/client-request-id.test.d.ts +1 -0
  35. package/dist/test/modules/client-request-id.test.js +135 -0
  36. package/dist/test/modules/consumer.test.js +2 -2
  37. package/dist/test/modules/ecommerce.test.js +2 -1
  38. package/dist/test/modules/invoicing-pdf.test.d.ts +1 -0
  39. package/dist/test/modules/invoicing-pdf.test.js +34 -0
  40. package/dist/test/modules/invoicing.test.js +3 -1
  41. package/dist/test/modules/payment.test.js +5 -4
  42. package/dist/test/modules/raw-data.test.d.ts +1 -0
  43. package/dist/test/modules/raw-data.test.js +55 -0
  44. package/package.json +1 -1
  45. package/src/types/public-api/schema.d.ts +4575 -1985
@@ -0,0 +1,34 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const globals_1 = require("@jest/globals");
4
+ const invoicing_1 = require("../../src/modules/invoicing");
5
+ (0, globals_1.test)('getInvoiceById returns InvoiceItemOutSingle with pdf field support', () => {
6
+ // Test that getInvoiceById supports include_pdf parameter and returns correct type
7
+ const getInvoiceRequest = invoicing_1.invoicingFactory.getInvoiceById('test-invoice-id', {
8
+ include_pdf: 'true',
9
+ });
10
+ (0, globals_1.expect)(getInvoiceRequest).toHaveProperty('method', 'get');
11
+ (0, globals_1.expect)(getInvoiceRequest).toHaveProperty('url', '/consumers/{consumer_id}/invoicing/invoices/test-invoice-id');
12
+ (0, globals_1.expect)(getInvoiceRequest).toHaveProperty('params', { include_pdf: 'true' });
13
+ // The return type should be InvoiceItemOutSingle which includes the pdf field
14
+ // This is verified at compile time by TypeScript
15
+ // Test that the method works without params too
16
+ const getInvoiceRequestNoParams = invoicing_1.invoicingFactory.getInvoiceById('test-invoice-id');
17
+ (0, globals_1.expect)(getInvoiceRequestNoParams).toHaveProperty('method', 'get');
18
+ (0, globals_1.expect)(getInvoiceRequestNoParams).toHaveProperty('url', '/consumers/{consumer_id}/invoicing/invoices/test-invoice-id');
19
+ (0, globals_1.expect)(getInvoiceRequestNoParams.params).toBeUndefined();
20
+ });
21
+ (0, globals_1.test)('getInvoiceById parameter types allow include_pdf', () => {
22
+ // Test various parameter combinations that should be valid
23
+ const validParams = [
24
+ { include_pdf: 'true' },
25
+ { include_pdf: 'false' },
26
+ { include_pdf: null },
27
+ undefined,
28
+ ];
29
+ validParams.forEach((params, index) => {
30
+ const request = invoicing_1.invoicingFactory.getInvoiceById(`invoice-${index}`, params);
31
+ (0, globals_1.expect)(request).toHaveProperty('method', 'get');
32
+ (0, globals_1.expect)(request).toHaveProperty('params', params);
33
+ });
34
+ });
@@ -60,7 +60,9 @@ let invoices;
60
60
  if (!invoices.length) {
61
61
  throw new Error('No invoices found to test getInvoiceById');
62
62
  }
63
- const invoice = yield consumer.invoicing.getInvoiceById(invoices[0].id, { include_pdf: false });
63
+ const invoice = yield consumer.invoicing.getInvoiceById(invoices[0].id, {
64
+ include_pdf: 'false',
65
+ });
64
66
  (0, globals_1.expect)(invoice).toHaveProperty('id', globals_1.expect.any(String));
65
67
  }));
66
68
  let products;
@@ -50,28 +50,29 @@ let consumer;
50
50
  }));
51
51
  let payments;
52
52
  (0, globals_1.test)('getPayments', () => __awaiter(void 0, void 0, void 0, function* () {
53
- payments = yield consumer.payment.getPayments();
53
+ payments = yield consumer.payment.getPayments({});
54
54
  (0, globals_1.expect)(payments).toBeInstanceOf(Array);
55
55
  (0, globals_1.expect)(payments.length).toBeGreaterThan(0);
56
56
  (0, globals_1.expect)(payments[0]).toHaveProperty('id', globals_1.expect.any(String));
57
57
  }));
58
58
  (0, globals_1.test)('getBalances', () => __awaiter(void 0, void 0, void 0, function* () {
59
- const balances = yield consumer.payment.getBalances();
59
+ const balances = yield consumer.payment.getBalances({});
60
60
  (0, globals_1.expect)(balances).toBeInstanceOf(Array);
61
61
  (0, globals_1.expect)(balances.length).toBeGreaterThan(0);
62
62
  (0, globals_1.expect)(balances[0]).toHaveProperty('id', globals_1.expect.any(String));
63
63
  }));
64
64
  globals_1.test.skip('getTransactions', () => __awaiter(void 0, void 0, void 0, function* () {
65
- const transactions = yield consumer.payment.getTransactions();
65
+ const transactions = yield consumer.payment.getTransactions({});
66
66
  (0, globals_1.expect)(transactions).toBeInstanceOf(Array);
67
67
  (0, globals_1.expect)(transactions.length).toBeGreaterThan(0);
68
68
  (0, globals_1.expect)(transactions[0]).toHaveProperty('id', globals_1.expect.any(String));
69
69
  }));
70
70
  globals_1.test.skip('getPayment', () => __awaiter(void 0, void 0, void 0, function* () {
71
- if (!payments.length) {
71
+ if (!(payments === null || payments === void 0 ? void 0 : payments[0].id)) {
72
72
  throw new Error('No payments found to test getPayment');
73
73
  }
74
74
  const payment = yield consumer.payment.getPayment({
75
+ consumer_id: consumerId,
75
76
  payment_id: payments[0].id,
76
77
  });
77
78
  (0, globals_1.expect)(payment).toHaveProperty('id', payments[0].id);
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,55 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const globals_1 = require("@jest/globals");
4
+ const accounting_1 = require("../../src/modules/accounting");
5
+ const ecommerce_1 = require("../../src/modules/ecommerce");
6
+ const banking_1 = require("../../src/modules/banking");
7
+ (0, globals_1.test)('accounting factory methods support rawData parameter', () => {
8
+ // Test that getInvoicesByType supports rawData parameter
9
+ const getInvoicesRequest = accounting_1.accountingFactory.getInvoicesByType('customer_invoice', {}, { rawData: true });
10
+ (0, globals_1.expect)(getInvoicesRequest).toHaveProperty('rawData', true);
11
+ (0, globals_1.expect)(getInvoicesRequest).toHaveProperty('method', 'get');
12
+ (0, globals_1.expect)(getInvoicesRequest).toHaveProperty('url', '/consumers/{consumer_id}/accounting/invoices/type/customer_invoice');
13
+ // Test that getInvoice supports rawData parameter
14
+ const getInvoiceRequest = accounting_1.accountingFactory.getInvoice('test-invoice-id', {}, { rawData: true });
15
+ (0, globals_1.expect)(getInvoiceRequest).toHaveProperty('rawData', true);
16
+ (0, globals_1.expect)(getInvoiceRequest).toHaveProperty('method', 'get');
17
+ (0, globals_1.expect)(getInvoiceRequest).toHaveProperty('url', '/consumers/{consumer_id}/accounting/invoices/test-invoice-id');
18
+ });
19
+ (0, globals_1.test)('ecommerce factory methods support rawData parameter', () => {
20
+ // Test that getOrders supports rawData parameter
21
+ const getOrdersRequest = ecommerce_1.ecommerceFactory.getOrders({}, { rawData: true });
22
+ (0, globals_1.expect)(getOrdersRequest).toHaveProperty('rawData', true);
23
+ (0, globals_1.expect)(getOrdersRequest).toHaveProperty('method', 'get');
24
+ (0, globals_1.expect)(getOrdersRequest).toHaveProperty('url', '/consumers/{consumer_id}/commerce/orders');
25
+ // Test that getOrder supports rawData parameter
26
+ const getOrderRequest = ecommerce_1.ecommerceFactory.getOrder('test-order-id', {}, { rawData: true });
27
+ (0, globals_1.expect)(getOrderRequest).toHaveProperty('rawData', true);
28
+ (0, globals_1.expect)(getOrderRequest).toHaveProperty('method', 'get');
29
+ (0, globals_1.expect)(getOrderRequest).toHaveProperty('url', '/consumers/{consumer_id}/commerce/orders/test-order-id');
30
+ });
31
+ (0, globals_1.test)('banking factory methods support rawData parameter', () => {
32
+ // Test that getAccountTransactions supports rawData parameter
33
+ const getTransactionsRequest = banking_1.bankingFactory.getAccountTransactions('test-account-id', {}, { rawData: true });
34
+ (0, globals_1.expect)(getTransactionsRequest).toHaveProperty('rawData', true);
35
+ (0, globals_1.expect)(getTransactionsRequest).toHaveProperty('method', 'get');
36
+ (0, globals_1.expect)(getTransactionsRequest).toHaveProperty('url', '/consumers/{consumer_id}/banking/test-account-id/transactions');
37
+ });
38
+ (0, globals_1.test)('rawData parameter defaults to undefined when not specified', () => {
39
+ // Test that rawData is undefined when not specified
40
+ const getInvoicesRequest = accounting_1.accountingFactory.getInvoicesByType('customer_invoice');
41
+ (0, globals_1.expect)(getInvoicesRequest.rawData).toBeUndefined();
42
+ const getOrdersRequest = ecommerce_1.ecommerceFactory.getOrders();
43
+ (0, globals_1.expect)(getOrdersRequest.rawData).toBeUndefined();
44
+ const getTransactionsRequest = banking_1.bankingFactory.getAccountTransactions('test-account-id');
45
+ (0, globals_1.expect)(getTransactionsRequest.rawData).toBeUndefined();
46
+ });
47
+ (0, globals_1.test)('rawData parameter can be explicitly set to false', () => {
48
+ // Test that rawData can be explicitly set to false
49
+ const getInvoicesRequest = accounting_1.accountingFactory.getInvoicesByType('customer_invoice', {}, { rawData: false });
50
+ (0, globals_1.expect)(getInvoicesRequest).toHaveProperty('rawData', false);
51
+ const getOrdersRequest = ecommerce_1.ecommerceFactory.getOrders({}, { rawData: false });
52
+ (0, globals_1.expect)(getOrdersRequest).toHaveProperty('rawData', false);
53
+ const getTransactionsRequest = banking_1.bankingFactory.getAccountTransactions('test-account-id', {}, { rawData: false });
54
+ (0, globals_1.expect)(getTransactionsRequest).toHaveProperty('rawData', false);
55
+ });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@chift/chift-nodejs",
3
- "version": "1.0.22",
3
+ "version": "1.0.24",
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",