@chift/chift-nodejs 1.0.23 → 1.0.25
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/README.md +37 -0
- package/dist/src/modules/accounting.d.ts +45 -43
- package/dist/src/modules/accounting.js +102 -42
- package/dist/src/modules/api.d.ts +13247 -11010
- package/dist/src/modules/banking.d.ts +13 -0
- package/dist/src/modules/banking.js +38 -0
- package/dist/src/modules/consumer.d.ts +2594 -2163
- package/dist/src/modules/consumer.js +3 -0
- package/dist/src/modules/consumers.d.ts +13205 -10980
- package/dist/src/modules/custom.d.ts +4 -4
- package/dist/src/modules/custom.js +6 -3
- package/dist/src/modules/datastores.d.ts +12 -6
- package/dist/src/modules/ecommerce.d.ts +18 -15
- package/dist/src/modules/ecommerce.js +32 -14
- package/dist/src/modules/flow.d.ts +2 -2
- package/dist/src/modules/integrations.d.ts +4 -2
- package/dist/src/modules/internalApi.js +11 -0
- package/dist/src/modules/invoicing.d.ts +16 -16
- package/dist/src/modules/invoicing.js +33 -18
- package/dist/src/modules/payment.d.ts +6 -6
- package/dist/src/modules/payment.js +10 -5
- package/dist/src/modules/pms.d.ts +8 -8
- package/dist/src/modules/pms.js +16 -8
- package/dist/src/modules/pos.d.ts +15 -15
- package/dist/src/modules/pos.js +29 -15
- package/dist/src/modules/sync.d.ts +10553 -8771
- package/dist/src/modules/webhooks.d.ts +12 -12
- package/dist/src/types/api.d.ts +9 -0
- package/dist/src/types/public-api/mappings.d.ts +128 -1
- package/dist/src/types/public-api/schema.d.ts +3856 -2132
- package/dist/src/types/public-api/schema.js +6 -0
- package/dist/test/modules/banking.test.d.ts +1 -0
- package/dist/test/modules/banking.test.js +94 -0
- package/dist/test/modules/client-request-id.test.d.ts +1 -0
- package/dist/test/modules/client-request-id.test.js +135 -0
- package/dist/test/modules/ecommerce.test.js +2 -1
- package/dist/test/modules/invoicing-pdf.test.d.ts +1 -0
- package/dist/test/modules/invoicing-pdf.test.js +34 -0
- package/dist/test/modules/raw-data.test.d.ts +1 -0
- package/dist/test/modules/raw-data.test.js +55 -0
- package/package.json +1 -1
- package/src/types/public-api/schema.d.ts +3856 -2132
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,94 @@
|
|
|
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_BACKBONE_API,
|
|
41
|
+
clientId: process.env.CHIFT_TESTING_CLIENTID,
|
|
42
|
+
clientSecret: process.env.CHIFT_TESTING_CLIENTSECRET,
|
|
43
|
+
accountId: process.env.CHIFT_TESTING_ACCOUNTID,
|
|
44
|
+
});
|
|
45
|
+
const consumerId = process.env.CHIFT_BANKING_CONSUMER_ID;
|
|
46
|
+
let consumer;
|
|
47
|
+
(0, globals_1.beforeAll)(() => __awaiter(void 0, void 0, void 0, function* () {
|
|
48
|
+
consumer = yield client.Consumers.getConsumerById(consumerId);
|
|
49
|
+
}));
|
|
50
|
+
let financialInstitutions;
|
|
51
|
+
(0, globals_1.test)('getFinancialInstitutions', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
52
|
+
financialInstitutions = yield consumer.banking.getFinancialInstitutions();
|
|
53
|
+
(0, globals_1.expect)(financialInstitutions).toBeInstanceOf(Array);
|
|
54
|
+
(0, globals_1.expect)(financialInstitutions.length).toBeGreaterThan(0);
|
|
55
|
+
(0, globals_1.expect)(financialInstitutions[0]).toHaveProperty('id', globals_1.expect.any(String));
|
|
56
|
+
(0, globals_1.expect)(financialInstitutions[0]).toHaveProperty('name', globals_1.expect.any(String));
|
|
57
|
+
(0, globals_1.expect)(financialInstitutions[0]).toHaveProperty('country');
|
|
58
|
+
(0, globals_1.expect)(financialInstitutions[0]).toHaveProperty('bic');
|
|
59
|
+
}));
|
|
60
|
+
let accounts;
|
|
61
|
+
(0, globals_1.test)('getAccounts', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
62
|
+
accounts = yield consumer.banking.getAccounts();
|
|
63
|
+
(0, globals_1.expect)(accounts).toBeInstanceOf(Array);
|
|
64
|
+
(0, globals_1.expect)(accounts.length).toBeGreaterThan(0);
|
|
65
|
+
(0, globals_1.expect)(accounts[0]).toHaveProperty('id', globals_1.expect.any(String));
|
|
66
|
+
(0, globals_1.expect)(accounts[0]).toHaveProperty('currency', globals_1.expect.any(String));
|
|
67
|
+
(0, globals_1.expect)(accounts[0]).toHaveProperty('current_balance', globals_1.expect.any(Number));
|
|
68
|
+
(0, globals_1.expect)(accounts[0]).toHaveProperty('available_balance', globals_1.expect.any(Number));
|
|
69
|
+
(0, globals_1.expect)(accounts[0]).toHaveProperty('description', globals_1.expect.any(String));
|
|
70
|
+
(0, globals_1.expect)(accounts[0]).toHaveProperty('reference', globals_1.expect.any(String));
|
|
71
|
+
}));
|
|
72
|
+
let transactions;
|
|
73
|
+
(0, globals_1.test)('getAccountTransactions', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
74
|
+
if (!accounts.length) {
|
|
75
|
+
throw new Error('No accounts found to test getAccountTransactions');
|
|
76
|
+
}
|
|
77
|
+
transactions = yield consumer.banking.getAccountTransactions(accounts[0].id);
|
|
78
|
+
(0, globals_1.expect)(transactions).toBeInstanceOf(Array);
|
|
79
|
+
if (transactions.length > 0) {
|
|
80
|
+
(0, globals_1.expect)(transactions[0]).toHaveProperty('id', globals_1.expect.any(String));
|
|
81
|
+
(0, globals_1.expect)(transactions[0]).toHaveProperty('amount', globals_1.expect.any(Number));
|
|
82
|
+
(0, globals_1.expect)(transactions[0]).toHaveProperty('currency', globals_1.expect.any(String));
|
|
83
|
+
(0, globals_1.expect)(transactions[0]).toHaveProperty('creation_date', globals_1.expect.any(String));
|
|
84
|
+
}
|
|
85
|
+
}));
|
|
86
|
+
let counterparts;
|
|
87
|
+
(0, globals_1.test)('getAccountCounterparts', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
88
|
+
counterparts = yield consumer.banking.getAccountCounterparts();
|
|
89
|
+
(0, globals_1.expect)(counterparts).toBeInstanceOf(Array);
|
|
90
|
+
if (counterparts.length > 0) {
|
|
91
|
+
(0, globals_1.expect)(counterparts[0]).toHaveProperty('name');
|
|
92
|
+
(0, globals_1.expect)(counterparts[0]).toHaveProperty('reference');
|
|
93
|
+
}
|
|
94
|
+
}));
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,135 @@
|
|
|
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 invoicing_1 = require("../../src/modules/invoicing");
|
|
7
|
+
const pos_1 = require("../../src/modules/pos");
|
|
8
|
+
const custom_1 = require("../../src/modules/custom");
|
|
9
|
+
(0, globals_1.test)('accounting factory methods support clientRequestId parameter for create operations', () => {
|
|
10
|
+
// Test that createClient supports clientRequestId parameter
|
|
11
|
+
const createClientRequest = accounting_1.accountingFactory.createClient({ name: 'Test Client' }, undefined, { clientRequestId: 'test-request-id-123' });
|
|
12
|
+
(0, globals_1.expect)(createClientRequest).toHaveProperty('clientRequestId', 'test-request-id-123');
|
|
13
|
+
(0, globals_1.expect)(createClientRequest).toHaveProperty('method', 'post');
|
|
14
|
+
(0, globals_1.expect)(createClientRequest).toHaveProperty('url', '/consumers/{consumer_id}/accounting/clients');
|
|
15
|
+
(0, globals_1.expect)(createClientRequest).toHaveProperty('body', { name: 'Test Client' });
|
|
16
|
+
// Test that createInvoice supports clientRequestId parameter
|
|
17
|
+
const createInvoiceRequest = accounting_1.accountingFactory.createInvoice({ number: 'INV-001' }, undefined, { clientRequestId: 'test-invoice-request-id-789' });
|
|
18
|
+
(0, globals_1.expect)(createInvoiceRequest).toHaveProperty('clientRequestId', 'test-invoice-request-id-789');
|
|
19
|
+
(0, globals_1.expect)(createInvoiceRequest).toHaveProperty('method', 'post');
|
|
20
|
+
(0, globals_1.expect)(createInvoiceRequest).toHaveProperty('url', '/consumers/{consumer_id}/accounting/invoices');
|
|
21
|
+
// Test that createSupplier supports clientRequestId parameter
|
|
22
|
+
const createSupplierRequest = accounting_1.accountingFactory.createSupplier({ name: 'Test Supplier' }, undefined, { clientRequestId: 'test-supplier-request-id-456' });
|
|
23
|
+
(0, globals_1.expect)(createSupplierRequest).toHaveProperty('clientRequestId', 'test-supplier-request-id-456');
|
|
24
|
+
(0, globals_1.expect)(createSupplierRequest).toHaveProperty('method', 'post');
|
|
25
|
+
(0, globals_1.expect)(createSupplierRequest).toHaveProperty('url', '/consumers/{consumer_id}/accounting/suppliers');
|
|
26
|
+
});
|
|
27
|
+
(0, globals_1.test)('accounting factory methods support clientRequestId parameter for update operations', () => {
|
|
28
|
+
// Test that updateClient supports clientRequestId parameter
|
|
29
|
+
const updateClientRequest = accounting_1.accountingFactory.updateClient('client-123', { name: 'Updated Client' }, undefined, { clientRequestId: 'test-update-request-id-456' });
|
|
30
|
+
(0, globals_1.expect)(updateClientRequest).toHaveProperty('clientRequestId', 'test-update-request-id-456');
|
|
31
|
+
(0, globals_1.expect)(updateClientRequest).toHaveProperty('method', 'patch');
|
|
32
|
+
(0, globals_1.expect)(updateClientRequest).toHaveProperty('url', '/consumers/{consumer_id}/accounting/clients/client-123');
|
|
33
|
+
(0, globals_1.expect)(updateClientRequest).toHaveProperty('body', { name: 'Updated Client' });
|
|
34
|
+
});
|
|
35
|
+
(0, globals_1.test)('ecommerce factory methods support clientRequestId parameter', () => {
|
|
36
|
+
// Test that createOrder supports clientRequestId parameter
|
|
37
|
+
const createOrderRequest = ecommerce_1.ecommerceFactory.createOrder({ customer_id: 'cust-123' }, {
|
|
38
|
+
clientRequestId: 'test-ecommerce-order-id-123',
|
|
39
|
+
});
|
|
40
|
+
(0, globals_1.expect)(createOrderRequest).toHaveProperty('clientRequestId', 'test-ecommerce-order-id-123');
|
|
41
|
+
(0, globals_1.expect)(createOrderRequest).toHaveProperty('method', 'post');
|
|
42
|
+
(0, globals_1.expect)(createOrderRequest).toHaveProperty('url', '/consumers/{consumer_id}/commerce/orders');
|
|
43
|
+
(0, globals_1.expect)(createOrderRequest).toHaveProperty('body', { customer_id: 'cust-123' });
|
|
44
|
+
// Test that updateAvailableQuantity supports clientRequestId parameter
|
|
45
|
+
const updateQuantityRequest = ecommerce_1.ecommerceFactory.updateAvailableQuantity('variant-123', { quantity: 10 }, { clientRequestId: 'test-quantity-update-id-456' });
|
|
46
|
+
(0, globals_1.expect)(updateQuantityRequest).toHaveProperty('clientRequestId', 'test-quantity-update-id-456');
|
|
47
|
+
(0, globals_1.expect)(updateQuantityRequest).toHaveProperty('method', 'post');
|
|
48
|
+
(0, globals_1.expect)(updateQuantityRequest).toHaveProperty('url', '/consumers/{consumer_id}/commerce/variants/set_quantity/variant-123');
|
|
49
|
+
(0, globals_1.expect)(updateQuantityRequest).toHaveProperty('body', { quantity: 10 });
|
|
50
|
+
});
|
|
51
|
+
(0, globals_1.test)('invoicing factory methods support clientRequestId parameter', () => {
|
|
52
|
+
// Test that createInvoice supports clientRequestId parameter
|
|
53
|
+
const createInvoiceRequest = invoicing_1.invoicingFactory.createInvoice({ number: 'INV-001' }, {
|
|
54
|
+
clientRequestId: 'test-invoicing-invoice-id-123',
|
|
55
|
+
});
|
|
56
|
+
(0, globals_1.expect)(createInvoiceRequest).toHaveProperty('clientRequestId', 'test-invoicing-invoice-id-123');
|
|
57
|
+
(0, globals_1.expect)(createInvoiceRequest).toHaveProperty('method', 'post');
|
|
58
|
+
(0, globals_1.expect)(createInvoiceRequest).toHaveProperty('url', '/consumers/{consumer_id}/invoicing/invoices');
|
|
59
|
+
(0, globals_1.expect)(createInvoiceRequest).toHaveProperty('body', { number: 'INV-001' });
|
|
60
|
+
// Test that createProduct supports clientRequestId parameter
|
|
61
|
+
const createProductRequest = invoicing_1.invoicingFactory.createProduct({ name: 'Test Product' }, {
|
|
62
|
+
clientRequestId: 'test-invoicing-product-id-456',
|
|
63
|
+
});
|
|
64
|
+
(0, globals_1.expect)(createProductRequest).toHaveProperty('clientRequestId', 'test-invoicing-product-id-456');
|
|
65
|
+
(0, globals_1.expect)(createProductRequest).toHaveProperty('method', 'post');
|
|
66
|
+
(0, globals_1.expect)(createProductRequest).toHaveProperty('url', '/consumers/{consumer_id}/invoicing/products');
|
|
67
|
+
(0, globals_1.expect)(createProductRequest).toHaveProperty('body', { name: 'Test Product' });
|
|
68
|
+
// Test that createContact supports clientRequestId parameter
|
|
69
|
+
const createContactRequest = invoicing_1.invoicingFactory.createContact({ name: 'Test Contact' }, {
|
|
70
|
+
clientRequestId: 'test-invoicing-contact-id-789',
|
|
71
|
+
});
|
|
72
|
+
(0, globals_1.expect)(createContactRequest).toHaveProperty('clientRequestId', 'test-invoicing-contact-id-789');
|
|
73
|
+
(0, globals_1.expect)(createContactRequest).toHaveProperty('method', 'post');
|
|
74
|
+
(0, globals_1.expect)(createContactRequest).toHaveProperty('url', '/consumers/{consumer_id}/invoicing/contacts');
|
|
75
|
+
(0, globals_1.expect)(createContactRequest).toHaveProperty('body', { name: 'Test Contact' });
|
|
76
|
+
});
|
|
77
|
+
(0, globals_1.test)('pos factory methods support clientRequestId parameter', () => {
|
|
78
|
+
// Test that createCustomer supports clientRequestId parameter
|
|
79
|
+
const createCustomerRequest = pos_1.posFactory.createCustomer({ name: 'Test Customer' }, {
|
|
80
|
+
clientRequestId: 'test-pos-customer-id-123',
|
|
81
|
+
});
|
|
82
|
+
(0, globals_1.expect)(createCustomerRequest).toHaveProperty('clientRequestId', 'test-pos-customer-id-123');
|
|
83
|
+
(0, globals_1.expect)(createCustomerRequest).toHaveProperty('method', 'post');
|
|
84
|
+
(0, globals_1.expect)(createCustomerRequest).toHaveProperty('url', '/consumers/{consumer_id}/pos/customers');
|
|
85
|
+
(0, globals_1.expect)(createCustomerRequest).toHaveProperty('body', { name: 'Test Customer' });
|
|
86
|
+
// Test that updateOrder supports clientRequestId parameter
|
|
87
|
+
const updateOrderRequest = pos_1.posFactory.updateOrder('order-123', { status: 'completed' }, {
|
|
88
|
+
clientRequestId: 'test-pos-order-update-id-456',
|
|
89
|
+
});
|
|
90
|
+
(0, globals_1.expect)(updateOrderRequest).toHaveProperty('clientRequestId', 'test-pos-order-update-id-456');
|
|
91
|
+
(0, globals_1.expect)(updateOrderRequest).toHaveProperty('method', 'patch');
|
|
92
|
+
(0, globals_1.expect)(updateOrderRequest).toHaveProperty('url', '/consumers/{consumer_id}/pos/orders/order-123');
|
|
93
|
+
(0, globals_1.expect)(updateOrderRequest).toHaveProperty('body', { status: 'completed' });
|
|
94
|
+
});
|
|
95
|
+
(0, globals_1.test)('custom factory methods support clientRequestId parameter', () => {
|
|
96
|
+
// Test that post supports clientRequestId parameter
|
|
97
|
+
const postRequest = custom_1.customFactory.post('test-integration', 'test-resource', { data: 'test' }, undefined, { clientRequestId: 'test-custom-post-id-123' });
|
|
98
|
+
(0, globals_1.expect)(postRequest).toHaveProperty('clientRequestId', 'test-custom-post-id-123');
|
|
99
|
+
(0, globals_1.expect)(postRequest).toHaveProperty('method', 'post');
|
|
100
|
+
(0, globals_1.expect)(postRequest).toHaveProperty('url', '/consumers/{consumer_id}/custom/test-integration/test-resource');
|
|
101
|
+
(0, globals_1.expect)(postRequest).toHaveProperty('body', { data: 'test' });
|
|
102
|
+
// Test that patch supports clientRequestId parameter
|
|
103
|
+
const patchRequest = custom_1.customFactory.patch('test-integration', 'test-resource', { data: 'updated' }, undefined, { clientRequestId: 'test-custom-patch-id-456' });
|
|
104
|
+
(0, globals_1.expect)(patchRequest).toHaveProperty('clientRequestId', 'test-custom-patch-id-456');
|
|
105
|
+
(0, globals_1.expect)(patchRequest).toHaveProperty('method', 'patch');
|
|
106
|
+
(0, globals_1.expect)(patchRequest).toHaveProperty('url', '/consumers/{consumer_id}/custom/test-integration/test-resource');
|
|
107
|
+
(0, globals_1.expect)(patchRequest).toHaveProperty('body', { data: 'updated' });
|
|
108
|
+
});
|
|
109
|
+
(0, globals_1.test)('additional accounting factory methods support clientRequestId parameter', () => {
|
|
110
|
+
// Test that createJournal supports clientRequestId parameter
|
|
111
|
+
const createJournalRequest = accounting_1.accountingFactory.createJournal({ name: 'Test Journal' }, undefined, { clientRequestId: 'test-journal-request-id-111' });
|
|
112
|
+
(0, globals_1.expect)(createJournalRequest).toHaveProperty('clientRequestId', 'test-journal-request-id-111');
|
|
113
|
+
(0, globals_1.expect)(createJournalRequest).toHaveProperty('method', 'post');
|
|
114
|
+
// Test that createBankAccount supports clientRequestId parameter
|
|
115
|
+
const createBankAccountRequest = accounting_1.accountingFactory.createBankAccount({ name: 'Test Bank Account' }, undefined, { clientRequestId: 'test-bank-account-request-id-222' });
|
|
116
|
+
(0, globals_1.expect)(createBankAccountRequest).toHaveProperty('clientRequestId', 'test-bank-account-request-id-222');
|
|
117
|
+
(0, globals_1.expect)(createBankAccountRequest).toHaveProperty('method', 'post');
|
|
118
|
+
// Test that updateSupplier supports clientRequestId parameter
|
|
119
|
+
const updateSupplierRequest = accounting_1.accountingFactory.updateSupplier('supplier-123', { name: 'Updated Supplier' }, undefined, { clientRequestId: 'test-update-supplier-id-333' });
|
|
120
|
+
(0, globals_1.expect)(updateSupplierRequest).toHaveProperty('clientRequestId', 'test-update-supplier-id-333');
|
|
121
|
+
(0, globals_1.expect)(updateSupplierRequest).toHaveProperty('method', 'patch');
|
|
122
|
+
});
|
|
123
|
+
(0, globals_1.test)('clientRequestId parameter defaults to undefined when not specified', () => {
|
|
124
|
+
// Test that clientRequestId is undefined when not specified
|
|
125
|
+
const createClientRequest = accounting_1.accountingFactory.createClient({ name: 'Test Client' });
|
|
126
|
+
(0, globals_1.expect)(createClientRequest.clientRequestId).toBeUndefined();
|
|
127
|
+
const createOrderRequest = ecommerce_1.ecommerceFactory.createOrder({ customer_id: 'cust-123' });
|
|
128
|
+
(0, globals_1.expect)(createOrderRequest.clientRequestId).toBeUndefined();
|
|
129
|
+
const createInvoiceRequest = invoicing_1.invoicingFactory.createInvoice({ number: 'INV-001' });
|
|
130
|
+
(0, globals_1.expect)(createInvoiceRequest.clientRequestId).toBeUndefined();
|
|
131
|
+
const createCustomerRequest = pos_1.posFactory.createCustomer({ name: 'Test Customer' });
|
|
132
|
+
(0, globals_1.expect)(createCustomerRequest.clientRequestId).toBeUndefined();
|
|
133
|
+
const customPostRequest = custom_1.customFactory.post('test', 'resource', { data: 'test' });
|
|
134
|
+
(0, globals_1.expect)(customPostRequest.clientRequestId).toBeUndefined();
|
|
135
|
+
});
|
|
@@ -91,10 +91,11 @@ let products;
|
|
|
91
91
|
}));
|
|
92
92
|
let productVariant;
|
|
93
93
|
globals_1.test.skip('getProductVariantById', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
94
|
+
var _a;
|
|
94
95
|
if (!(products === null || products === void 0 ? void 0 : products.length)) {
|
|
95
96
|
throw new Error('No product to test');
|
|
96
97
|
}
|
|
97
|
-
if (!products[0].variants.length) {
|
|
98
|
+
if (!((_a = products[0].variants) === null || _a === void 0 ? void 0 : _a.length)) {
|
|
98
99
|
throw new Error('No product variant to test');
|
|
99
100
|
}
|
|
100
101
|
productVariant = yield consumer.ecommerce.getProductVariantById(products[0].variants[0].id);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -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
|
+
});
|
|
@@ -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.
|
|
3
|
+
"version": "1.0.25",
|
|
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",
|