@develit-services/bank 5.1.0 → 5.2.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.
@@ -1283,80 +1283,119 @@ class DbuConnector extends IBankConnector {
1283
1283
  }
1284
1284
  async makeRequest(endpoint, requestId, options = {}) {
1285
1285
  const { method = "GET", headers = {}, query = {}, body } = options;
1286
- if (method === "POST" && !this.allowedPostEndpoints.includes(endpoint)) {
1287
- throw createInternalError(null, {
1288
- message: `DBU API endpoint ${endpoint} does not support POST method`,
1289
- code: "DBU_INVALID_METHOD"
1286
+ let url;
1287
+ let response;
1288
+ try {
1289
+ if (method === "POST" && !this.allowedPostEndpoints.includes(endpoint)) {
1290
+ throw createInternalError(null, {
1291
+ message: `DBU API endpoint ${endpoint} does not support POST method`,
1292
+ code: "DBU_INVALID_METHOD"
1293
+ });
1294
+ }
1295
+ const defaultHeaders = {
1296
+ "x-dcs-username": this.username,
1297
+ "x-dcs-session-id": `session-${this.sessionId}`,
1298
+ "x-dcs-request-id": `request-${requestId}`,
1299
+ "Content-Type": "application/json",
1300
+ ...headers
1301
+ };
1302
+ const baseUrl = this.baseUrl.endsWith("/") ? this.baseUrl.slice(0, -1) : this.baseUrl;
1303
+ const cleanEndpoint = endpoint.startsWith("/") ? endpoint.slice(1) : endpoint;
1304
+ url = new URL(`${baseUrl}/${cleanEndpoint}`);
1305
+ Object.entries(query).forEach(([key, value]) => {
1306
+ if (value !== void 0 && value !== null) {
1307
+ url.searchParams.append(key, value);
1308
+ }
1290
1309
  });
1291
- }
1292
- const defaultHeaders = {
1293
- "x-dcs-username": this.username,
1294
- "x-dcs-session-id": `session-${this.sessionId}`,
1295
- "x-dcs-request-id": `request-${requestId}`,
1296
- "Content-Type": "application/json",
1297
- ...headers
1298
- };
1299
- const baseUrl = this.baseUrl.endsWith("/") ? this.baseUrl.slice(0, -1) : this.baseUrl;
1300
- const cleanEndpoint = endpoint.startsWith("/") ? endpoint.slice(1) : endpoint;
1301
- const url = new URL(`${baseUrl}/${cleanEndpoint}`);
1302
- Object.entries(query).forEach(([key, value]) => {
1303
- if (value !== void 0 && value !== null) {
1304
- url.searchParams.append(key, value);
1310
+ const fetchOptions = {
1311
+ method,
1312
+ headers: defaultHeaders
1313
+ };
1314
+ if (body && method !== "GET") {
1315
+ fetchOptions.body = JSON.stringify(body);
1305
1316
  }
1306
- });
1307
- const fetchOptions = {
1308
- method,
1309
- headers: defaultHeaders
1310
- };
1311
- if (body && method !== "GET") {
1312
- fetchOptions.body = JSON.stringify(body);
1313
- }
1314
- console.log(
1315
- "[DBU] request",
1316
- JSON.stringify(
1317
- {
1318
- method,
1317
+ console.log(
1318
+ "[DBU] request",
1319
+ JSON.stringify(
1320
+ {
1321
+ method,
1322
+ url: url.toString(),
1323
+ requestId,
1324
+ headers: defaultHeaders,
1325
+ body: body ?? null
1326
+ },
1327
+ null,
1328
+ 2
1329
+ )
1330
+ );
1331
+ response = await this.api.fetch(url.toString(), fetchOptions);
1332
+ const responseText = await response.text().catch(() => "unable to read response");
1333
+ if (!response.ok) {
1334
+ let parsedBody = responseText;
1335
+ try {
1336
+ parsedBody = JSON.parse(responseText);
1337
+ } catch {
1338
+ }
1339
+ console.error("[DBU] error response", {
1340
+ status: response.status,
1341
+ statusText: response.statusText,
1319
1342
  url: url.toString(),
1320
1343
  requestId,
1321
- headers: defaultHeaders,
1322
- body: body ?? null
1323
- },
1324
- null,
1325
- 2
1326
- )
1327
- );
1328
- const response = await this.api.fetch(url.toString(), fetchOptions);
1329
- if (!response.ok) {
1330
- const errorBody = await response.text().catch(() => "unable to read body");
1331
- console.error("[DBU] error response", {
1332
- status: response.status,
1333
- statusText: response.statusText,
1334
- url: url.toString(),
1344
+ body: parsedBody
1345
+ });
1346
+ const errorMessage = typeof parsedBody === "string" ? parsedBody : JSON.stringify(parsedBody);
1347
+ throw createInternalError(
1348
+ new Error(`DBU API error: ${response.status}`),
1349
+ {
1350
+ message: `DBU request failed [${response.status}]: ${errorMessage}`
1351
+ }
1352
+ );
1353
+ }
1354
+ let data;
1355
+ try {
1356
+ data = JSON.parse(responseText);
1357
+ } catch (parseError) {
1358
+ console.error("[DBU] JSON parse error", {
1359
+ url: url.toString(),
1360
+ requestId,
1361
+ status: response.status,
1362
+ responseTextPreview: responseText.substring(0, 500),
1363
+ parseError: parseError instanceof Error ? parseError.message : String(parseError)
1364
+ });
1365
+ throw createInternalError(parseError, {
1366
+ message: "Failed to parse DBU response as JSON"
1367
+ });
1368
+ }
1369
+ console.log(
1370
+ "[DBU] response",
1371
+ JSON.stringify(
1372
+ {
1373
+ status: response.status,
1374
+ url: url.toString(),
1375
+ requestId,
1376
+ body: data
1377
+ },
1378
+ null,
1379
+ 2
1380
+ )
1381
+ );
1382
+ return data;
1383
+ } catch (error) {
1384
+ console.error("[DBU] makeRequest failed", {
1385
+ endpoint,
1335
1386
  requestId,
1336
- body: errorBody
1337
- });
1338
- throw createInternalError(
1339
- new Error(`DBU API error: ${response.status}`),
1340
- {
1341
- message: `DBU request failed [${response.status}]: ${errorBody}`
1387
+ method,
1388
+ url: url?.toString(),
1389
+ responseStatus: response?.status,
1390
+ responseStatusText: response?.statusText,
1391
+ error: {
1392
+ message: error instanceof Error ? error.message : String(error),
1393
+ name: error instanceof Error ? error.name : "Unknown",
1394
+ stack: error instanceof Error ? error.stack : void 0
1342
1395
  }
1343
- );
1396
+ });
1397
+ throw error;
1344
1398
  }
1345
- const data = await response.json();
1346
- console.log(
1347
- "[DBU] response",
1348
- JSON.stringify(
1349
- {
1350
- status: response.status,
1351
- url: url.toString(),
1352
- requestId,
1353
- body: data
1354
- },
1355
- null,
1356
- 2
1357
- )
1358
- );
1359
- return data;
1360
1399
  }
1361
1400
  mapDbuCurrencyCode(dbuCurrency) {
1362
1401
  const currency = dbuCurrency.toUpperCase();
@@ -2250,13 +2289,19 @@ class MockConnector extends IBankConnector {
2250
2289
  }
2251
2290
 
2252
2291
  const accountInsertSchema = createInsertSchema(account, {
2253
- address: () => structuredAddressSchema.optional()
2292
+ address: () => structuredAddressSchema.optional(),
2293
+ lastSyncMetadata: () => z.custom().optional(),
2294
+ connectorConfig: () => z.custom().optional()
2254
2295
  });
2255
2296
  const accountUpdateSchema = createUpdateSchema(account, {
2256
- address: () => structuredAddressSchema.optional()
2297
+ address: () => structuredAddressSchema.optional(),
2298
+ lastSyncMetadata: () => z.custom().optional(),
2299
+ connectorConfig: () => z.custom().optional()
2257
2300
  });
2258
2301
  const accountSelectSchema = createSelectSchema(account, {
2259
- address: () => structuredAddressSchema.nullable()
2302
+ address: () => structuredAddressSchema.nullable(),
2303
+ lastSyncMetadata: () => z.custom().nullable(),
2304
+ connectorConfig: () => z.custom().nullable()
2260
2305
  });
2261
2306
 
2262
2307
  const accountCredentialsInsertSchema = createInsertSchema(accountCredentials);
@@ -1,4 +1,4 @@
1
- import { e as CurrencyCode, R as BankCode, a1 as CountryCode, P as PaymentRequestSelectType } from './bank.Do1KUeDr.js';
1
+ import { e as CurrencyCode, R as BankCode, a1 as CountryCode, P as PaymentRequestSelectType } from './bank.CdkOsZE8.cjs';
2
2
  import { z } from 'zod';
3
3
 
4
4
  type ReferenceType = `${'VS' | 'SS' | 'KS'}:${number}`;
@@ -444,6 +444,7 @@ declare const sendPaymentInputSchema: z.ZodObject<{
444
444
  GW: "GW";
445
445
  GY: "GY";
446
446
  HT: "HT";
447
+ HK: "HK";
447
448
  HN: "HN";
448
449
  HU: "HU";
449
450
  IS: "IS";
@@ -715,6 +716,7 @@ declare const sendPaymentInputSchema: z.ZodObject<{
715
716
  GW: "GW";
716
717
  GY: "GY";
717
718
  HT: "HT";
719
+ HK: "HK";
718
720
  HN: "HN";
719
721
  HU: "HU";
720
722
  IS: "IS";
@@ -1007,6 +1009,7 @@ declare const sendPaymentInputSchema: z.ZodObject<{
1007
1009
  GW: "GW";
1008
1010
  GY: "GY";
1009
1011
  HT: "HT";
1012
+ HK: "HK";
1010
1013
  HN: "HN";
1011
1014
  HU: "HU";
1012
1015
  IS: "IS";
@@ -1278,6 +1281,7 @@ declare const sendPaymentInputSchema: z.ZodObject<{
1278
1281
  GW: "GW";
1279
1282
  GY: "GY";
1280
1283
  HT: "HT";
1284
+ HK: "HK";
1281
1285
  HN: "HN";
1282
1286
  HU: "HU";
1283
1287
  IS: "IS";
@@ -1658,6 +1662,7 @@ declare const sendPaymentSyncInputSchema: z.ZodObject<{
1658
1662
  GW: "GW";
1659
1663
  GY: "GY";
1660
1664
  HT: "HT";
1665
+ HK: "HK";
1661
1666
  HN: "HN";
1662
1667
  HU: "HU";
1663
1668
  IS: "IS";
@@ -1929,6 +1934,7 @@ declare const sendPaymentSyncInputSchema: z.ZodObject<{
1929
1934
  GW: "GW";
1930
1935
  GY: "GY";
1931
1936
  HT: "HT";
1937
+ HK: "HK";
1932
1938
  HN: "HN";
1933
1939
  HU: "HU";
1934
1940
  IS: "IS";
@@ -2221,6 +2227,7 @@ declare const sendPaymentSyncInputSchema: z.ZodObject<{
2221
2227
  GW: "GW";
2222
2228
  GY: "GY";
2223
2229
  HT: "HT";
2230
+ HK: "HK";
2224
2231
  HN: "HN";
2225
2232
  HU: "HU";
2226
2233
  IS: "IS";
@@ -2492,6 +2499,7 @@ declare const sendPaymentSyncInputSchema: z.ZodObject<{
2492
2499
  GW: "GW";
2493
2500
  GY: "GY";
2494
2501
  HT: "HT";
2502
+ HK: "HK";
2495
2503
  HN: "HN";
2496
2504
  HU: "HU";
2497
2505
  IS: "IS";
@@ -1,4 +1,4 @@
1
- import { e as CurrencyCode, R as BankCode, a1 as CountryCode, P as PaymentRequestSelectType } from './bank.Do1KUeDr.cjs';
1
+ import { e as CurrencyCode, R as BankCode, a1 as CountryCode, P as PaymentRequestSelectType } from './bank.CdkOsZE8.js';
2
2
  import { z } from 'zod';
3
3
 
4
4
  type ReferenceType = `${'VS' | 'SS' | 'KS'}:${number}`;
@@ -444,6 +444,7 @@ declare const sendPaymentInputSchema: z.ZodObject<{
444
444
  GW: "GW";
445
445
  GY: "GY";
446
446
  HT: "HT";
447
+ HK: "HK";
447
448
  HN: "HN";
448
449
  HU: "HU";
449
450
  IS: "IS";
@@ -715,6 +716,7 @@ declare const sendPaymentInputSchema: z.ZodObject<{
715
716
  GW: "GW";
716
717
  GY: "GY";
717
718
  HT: "HT";
719
+ HK: "HK";
718
720
  HN: "HN";
719
721
  HU: "HU";
720
722
  IS: "IS";
@@ -1007,6 +1009,7 @@ declare const sendPaymentInputSchema: z.ZodObject<{
1007
1009
  GW: "GW";
1008
1010
  GY: "GY";
1009
1011
  HT: "HT";
1012
+ HK: "HK";
1010
1013
  HN: "HN";
1011
1014
  HU: "HU";
1012
1015
  IS: "IS";
@@ -1278,6 +1281,7 @@ declare const sendPaymentInputSchema: z.ZodObject<{
1278
1281
  GW: "GW";
1279
1282
  GY: "GY";
1280
1283
  HT: "HT";
1284
+ HK: "HK";
1281
1285
  HN: "HN";
1282
1286
  HU: "HU";
1283
1287
  IS: "IS";
@@ -1658,6 +1662,7 @@ declare const sendPaymentSyncInputSchema: z.ZodObject<{
1658
1662
  GW: "GW";
1659
1663
  GY: "GY";
1660
1664
  HT: "HT";
1665
+ HK: "HK";
1661
1666
  HN: "HN";
1662
1667
  HU: "HU";
1663
1668
  IS: "IS";
@@ -1929,6 +1934,7 @@ declare const sendPaymentSyncInputSchema: z.ZodObject<{
1929
1934
  GW: "GW";
1930
1935
  GY: "GY";
1931
1936
  HT: "HT";
1937
+ HK: "HK";
1932
1938
  HN: "HN";
1933
1939
  HU: "HU";
1934
1940
  IS: "IS";
@@ -2221,6 +2227,7 @@ declare const sendPaymentSyncInputSchema: z.ZodObject<{
2221
2227
  GW: "GW";
2222
2228
  GY: "GY";
2223
2229
  HT: "HT";
2230
+ HK: "HK";
2224
2231
  HN: "HN";
2225
2232
  HU: "HU";
2226
2233
  IS: "IS";
@@ -2492,6 +2499,7 @@ declare const sendPaymentSyncInputSchema: z.ZodObject<{
2492
2499
  GW: "GW";
2493
2500
  GY: "GY";
2494
2501
  HT: "HT";
2502
+ HK: "HK";
2495
2503
  HN: "HN";
2496
2504
  HU: "HU";
2497
2505
  IS: "IS";
@@ -1285,80 +1285,119 @@ class DbuConnector extends IBankConnector {
1285
1285
  }
1286
1286
  async makeRequest(endpoint, requestId, options = {}) {
1287
1287
  const { method = "GET", headers = {}, query = {}, body } = options;
1288
- if (method === "POST" && !this.allowedPostEndpoints.includes(endpoint)) {
1289
- throw backendSdk.createInternalError(null, {
1290
- message: `DBU API endpoint ${endpoint} does not support POST method`,
1291
- code: "DBU_INVALID_METHOD"
1288
+ let url;
1289
+ let response;
1290
+ try {
1291
+ if (method === "POST" && !this.allowedPostEndpoints.includes(endpoint)) {
1292
+ throw backendSdk.createInternalError(null, {
1293
+ message: `DBU API endpoint ${endpoint} does not support POST method`,
1294
+ code: "DBU_INVALID_METHOD"
1295
+ });
1296
+ }
1297
+ const defaultHeaders = {
1298
+ "x-dcs-username": this.username,
1299
+ "x-dcs-session-id": `session-${this.sessionId}`,
1300
+ "x-dcs-request-id": `request-${requestId}`,
1301
+ "Content-Type": "application/json",
1302
+ ...headers
1303
+ };
1304
+ const baseUrl = this.baseUrl.endsWith("/") ? this.baseUrl.slice(0, -1) : this.baseUrl;
1305
+ const cleanEndpoint = endpoint.startsWith("/") ? endpoint.slice(1) : endpoint;
1306
+ url = new URL(`${baseUrl}/${cleanEndpoint}`);
1307
+ Object.entries(query).forEach(([key, value]) => {
1308
+ if (value !== void 0 && value !== null) {
1309
+ url.searchParams.append(key, value);
1310
+ }
1292
1311
  });
1293
- }
1294
- const defaultHeaders = {
1295
- "x-dcs-username": this.username,
1296
- "x-dcs-session-id": `session-${this.sessionId}`,
1297
- "x-dcs-request-id": `request-${requestId}`,
1298
- "Content-Type": "application/json",
1299
- ...headers
1300
- };
1301
- const baseUrl = this.baseUrl.endsWith("/") ? this.baseUrl.slice(0, -1) : this.baseUrl;
1302
- const cleanEndpoint = endpoint.startsWith("/") ? endpoint.slice(1) : endpoint;
1303
- const url = new URL(`${baseUrl}/${cleanEndpoint}`);
1304
- Object.entries(query).forEach(([key, value]) => {
1305
- if (value !== void 0 && value !== null) {
1306
- url.searchParams.append(key, value);
1312
+ const fetchOptions = {
1313
+ method,
1314
+ headers: defaultHeaders
1315
+ };
1316
+ if (body && method !== "GET") {
1317
+ fetchOptions.body = JSON.stringify(body);
1307
1318
  }
1308
- });
1309
- const fetchOptions = {
1310
- method,
1311
- headers: defaultHeaders
1312
- };
1313
- if (body && method !== "GET") {
1314
- fetchOptions.body = JSON.stringify(body);
1315
- }
1316
- console.log(
1317
- "[DBU] request",
1318
- JSON.stringify(
1319
- {
1320
- method,
1319
+ console.log(
1320
+ "[DBU] request",
1321
+ JSON.stringify(
1322
+ {
1323
+ method,
1324
+ url: url.toString(),
1325
+ requestId,
1326
+ headers: defaultHeaders,
1327
+ body: body ?? null
1328
+ },
1329
+ null,
1330
+ 2
1331
+ )
1332
+ );
1333
+ response = await this.api.fetch(url.toString(), fetchOptions);
1334
+ const responseText = await response.text().catch(() => "unable to read response");
1335
+ if (!response.ok) {
1336
+ let parsedBody = responseText;
1337
+ try {
1338
+ parsedBody = JSON.parse(responseText);
1339
+ } catch {
1340
+ }
1341
+ console.error("[DBU] error response", {
1342
+ status: response.status,
1343
+ statusText: response.statusText,
1321
1344
  url: url.toString(),
1322
1345
  requestId,
1323
- headers: defaultHeaders,
1324
- body: body ?? null
1325
- },
1326
- null,
1327
- 2
1328
- )
1329
- );
1330
- const response = await this.api.fetch(url.toString(), fetchOptions);
1331
- if (!response.ok) {
1332
- const errorBody = await response.text().catch(() => "unable to read body");
1333
- console.error("[DBU] error response", {
1334
- status: response.status,
1335
- statusText: response.statusText,
1336
- url: url.toString(),
1346
+ body: parsedBody
1347
+ });
1348
+ const errorMessage = typeof parsedBody === "string" ? parsedBody : JSON.stringify(parsedBody);
1349
+ throw backendSdk.createInternalError(
1350
+ new Error(`DBU API error: ${response.status}`),
1351
+ {
1352
+ message: `DBU request failed [${response.status}]: ${errorMessage}`
1353
+ }
1354
+ );
1355
+ }
1356
+ let data;
1357
+ try {
1358
+ data = JSON.parse(responseText);
1359
+ } catch (parseError) {
1360
+ console.error("[DBU] JSON parse error", {
1361
+ url: url.toString(),
1362
+ requestId,
1363
+ status: response.status,
1364
+ responseTextPreview: responseText.substring(0, 500),
1365
+ parseError: parseError instanceof Error ? parseError.message : String(parseError)
1366
+ });
1367
+ throw backendSdk.createInternalError(parseError, {
1368
+ message: "Failed to parse DBU response as JSON"
1369
+ });
1370
+ }
1371
+ console.log(
1372
+ "[DBU] response",
1373
+ JSON.stringify(
1374
+ {
1375
+ status: response.status,
1376
+ url: url.toString(),
1377
+ requestId,
1378
+ body: data
1379
+ },
1380
+ null,
1381
+ 2
1382
+ )
1383
+ );
1384
+ return data;
1385
+ } catch (error) {
1386
+ console.error("[DBU] makeRequest failed", {
1387
+ endpoint,
1337
1388
  requestId,
1338
- body: errorBody
1339
- });
1340
- throw backendSdk.createInternalError(
1341
- new Error(`DBU API error: ${response.status}`),
1342
- {
1343
- message: `DBU request failed [${response.status}]: ${errorBody}`
1389
+ method,
1390
+ url: url?.toString(),
1391
+ responseStatus: response?.status,
1392
+ responseStatusText: response?.statusText,
1393
+ error: {
1394
+ message: error instanceof Error ? error.message : String(error),
1395
+ name: error instanceof Error ? error.name : "Unknown",
1396
+ stack: error instanceof Error ? error.stack : void 0
1344
1397
  }
1345
- );
1398
+ });
1399
+ throw error;
1346
1400
  }
1347
- const data = await response.json();
1348
- console.log(
1349
- "[DBU] response",
1350
- JSON.stringify(
1351
- {
1352
- status: response.status,
1353
- url: url.toString(),
1354
- requestId,
1355
- body: data
1356
- },
1357
- null,
1358
- 2
1359
- )
1360
- );
1361
- return data;
1362
1401
  }
1363
1402
  mapDbuCurrencyCode(dbuCurrency) {
1364
1403
  const currency = dbuCurrency.toUpperCase();
@@ -2252,13 +2291,19 @@ class MockConnector extends IBankConnector {
2252
2291
  }
2253
2292
 
2254
2293
  const accountInsertSchema = zod$1.createInsertSchema(database_schema.account, {
2255
- address: () => backendSdk.structuredAddressSchema.optional()
2294
+ address: () => backendSdk.structuredAddressSchema.optional(),
2295
+ lastSyncMetadata: () => zod.z.custom().optional(),
2296
+ connectorConfig: () => zod.z.custom().optional()
2256
2297
  });
2257
2298
  const accountUpdateSchema = zod$1.createUpdateSchema(database_schema.account, {
2258
- address: () => backendSdk.structuredAddressSchema.optional()
2299
+ address: () => backendSdk.structuredAddressSchema.optional(),
2300
+ lastSyncMetadata: () => zod.z.custom().optional(),
2301
+ connectorConfig: () => zod.z.custom().optional()
2259
2302
  });
2260
2303
  const accountSelectSchema = zod$1.createSelectSchema(database_schema.account, {
2261
- address: () => backendSdk.structuredAddressSchema.nullable()
2304
+ address: () => backendSdk.structuredAddressSchema.nullable(),
2305
+ lastSyncMetadata: () => zod.z.custom().nullable(),
2306
+ connectorConfig: () => zod.z.custom().nullable()
2262
2307
  });
2263
2308
 
2264
2309
  const accountCredentialsInsertSchema = zod$1.createInsertSchema(database_schema.accountCredentials);
@@ -1,7 +1,7 @@
1
1
  'use strict';
2
2
 
3
3
  const drizzleOrm = require('drizzle-orm');
4
- const bank = require('./bank.CjEKRnVl.cjs');
4
+ const bank = require('./bank.R64Uwo7k.cjs');
5
5
  const backendSdk = require('@develit-io/backend-sdk');
6
6
  require('./bank.9Yw4KHyl.cjs');
7
7
  require('date-fns');
package/dist/types.cjs CHANGED
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- const bank = require('./shared/bank.CjEKRnVl.cjs');
3
+ const bank = require('./shared/bank.R64Uwo7k.cjs');
4
4
  const database_schema = require('./shared/bank.9Yw4KHyl.cjs');
5
5
  const batchLifecycle = require('./shared/bank.NF8bZBy0.cjs');
6
6
  const generalCodes = require('@develit-io/general-codes');