@develit-services/bank 0.3.0 → 0.3.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.
@@ -422,7 +422,9 @@ let BankServiceBase = class extends backendSdk.develitWorker(cloudflare_workers.
422
422
  }) {
423
423
  if (!this.allowedProviders.includes(connectorKey)) {
424
424
  throw backendSdk.createInternalError(null, {
425
- message: `Invalid connector key: ${connectorKey}`
425
+ message: `Invalid connector key: ${connectorKey}`,
426
+ code: "VALID-B-001",
427
+ status: 400
426
428
  });
427
429
  }
428
430
  const accounts = await this._getAccounts();
@@ -441,7 +443,9 @@ let BankServiceBase = class extends backendSdk.develitWorker(cloudflare_workers.
441
443
  );
442
444
  if (!credentials) {
443
445
  throw backendSdk.createInternalError(null, {
444
- message: `No credentials found for account ${acc.id}`
446
+ message: `No credentials found for account ${acc.id}`,
447
+ code: "DB-B-001",
448
+ status: 404
445
449
  });
446
450
  }
447
451
  return {
@@ -546,7 +550,9 @@ let BankServiceBase = class extends backendSdk.develitWorker(cloudflare_workers.
546
550
  { successMessage: "Accounts synchronized successfully" },
547
551
  async () => {
548
552
  throw backendSdk.createInternalError(null, {
549
- message: "Not implemented yet"
553
+ message: "Not implemented yet",
554
+ code: "SYS-B-001",
555
+ status: 501
550
556
  });
551
557
  }
552
558
  );
@@ -820,14 +826,14 @@ let BankServiceBase = class extends backendSdk.develitWorker(cloudflare_workers.
820
826
  if (!ottRow) {
821
827
  throw backendSdk.createInternalError(null, {
822
828
  message: "One-time token not found",
823
- code: "NOT_FOUND",
829
+ code: "DB-B-002",
824
830
  status: 404
825
831
  });
826
832
  }
827
833
  if (ottRow.expiresAt.getTime() < Date.now()) {
828
834
  throw backendSdk.createInternalError(null, {
829
835
  message: "One time token has expired",
830
- code: "INVALID_GRANT",
836
+ code: "VALID-B-002",
831
837
  status: 400
832
838
  });
833
839
  }
@@ -872,7 +878,7 @@ let BankServiceBase = class extends backendSdk.develitWorker(cloudflare_workers.
872
878
  if (!fetchedAccounts)
873
879
  throw backendSdk.createInternalError(null, {
874
880
  message: "Account not found",
875
- code: "NOT_FOUND",
881
+ code: "DB-B-003",
876
882
  status: 404
877
883
  });
878
884
  return {
@@ -902,7 +908,7 @@ let BankServiceBase = class extends backendSdk.develitWorker(cloudflare_workers.
902
908
  if (!account)
903
909
  throw backendSdk.createInternalError(null, {
904
910
  message: "Unsupported account",
905
- code: "UNSUPPORTED_ACCOUNT",
911
+ code: "VALID-B-003",
906
912
  status: 422
907
913
  });
908
914
  const payment = {
@@ -1002,7 +1008,7 @@ let BankServiceBase = class extends backendSdk.develitWorker(cloudflare_workers.
1002
1008
  if (!updatedAccount) {
1003
1009
  throw backendSdk.createInternalError(null, {
1004
1010
  message: "Account not found",
1005
- code: "ACCOUNT_NOT_FOUND",
1011
+ code: "DB-B-004",
1006
1012
  status: 404
1007
1013
  });
1008
1014
  }
@@ -1019,7 +1025,7 @@ let BankServiceBase = class extends backendSdk.develitWorker(cloudflare_workers.
1019
1025
  if (!account) {
1020
1026
  throw backendSdk.createInternalError(null, {
1021
1027
  message: "Account not found",
1022
- code: "ACCOUNT_NOT_FOUND",
1028
+ code: "DB-B-005",
1023
1029
  status: 404
1024
1030
  });
1025
1031
  }
@@ -1060,8 +1066,8 @@ let BankServiceBase = class extends backendSdk.develitWorker(cloudflare_workers.
1060
1066
  if (!updatedAccount) {
1061
1067
  throw backendSdk.createInternalError(null, {
1062
1068
  message: "Account not updated",
1063
- code: "DB-B-0?",
1064
- status: 404
1069
+ code: "DB-B-006",
1070
+ status: 500
1065
1071
  });
1066
1072
  }
1067
1073
  return updatedAccount;
@@ -1518,9 +1518,9 @@ declare const getBatchesInputSchema: z.ZodObject<{
1518
1518
  limit: z.ZodNumber;
1519
1519
  sort: z.ZodObject<{
1520
1520
  column: z.ZodEnum<{
1521
- batchPaymentInitiatedAt: "batchPaymentInitiatedAt";
1522
1521
  createdAt: "createdAt";
1523
1522
  updatedAt: "updatedAt";
1523
+ batchPaymentInitiatedAt: "batchPaymentInitiatedAt";
1524
1524
  }>;
1525
1525
  direction: z.ZodEnum<{
1526
1526
  asc: "asc";
@@ -2444,14 +2444,14 @@ declare class BankServiceBase extends BankServiceBase_base {
2444
2444
  addPaymentsToBatch({ paymentsToBatch, }: {
2445
2445
  paymentsToBatch: SendPaymentInput[];
2446
2446
  }): Promise<IRPCResponse<{
2447
- batchPaymentInitiatedAt: Date | null;
2448
- authorizationUrls: string[] | null;
2449
2447
  status: "OPEN" | "FULL" | "PROCESSING" | "READY_TO_SIGN" | "SIGNED" | "SIGNATURE_FAILED" | "FAILED" | null;
2450
2448
  id: string;
2451
2449
  createdAt: Date | null;
2452
2450
  updatedAt: Date | null;
2453
2451
  deletedAt: Date | null;
2454
2452
  accountId: string | null;
2453
+ batchPaymentInitiatedAt: Date | null;
2454
+ authorizationUrls: string[] | null;
2455
2455
  payments: PaymentInsertType[];
2456
2456
  metadata: BatchMetadata | null;
2457
2457
  paymentsChecksum: string | null;
@@ -1518,9 +1518,9 @@ declare const getBatchesInputSchema: z.ZodObject<{
1518
1518
  limit: z.ZodNumber;
1519
1519
  sort: z.ZodObject<{
1520
1520
  column: z.ZodEnum<{
1521
- batchPaymentInitiatedAt: "batchPaymentInitiatedAt";
1522
1521
  createdAt: "createdAt";
1523
1522
  updatedAt: "updatedAt";
1523
+ batchPaymentInitiatedAt: "batchPaymentInitiatedAt";
1524
1524
  }>;
1525
1525
  direction: z.ZodEnum<{
1526
1526
  asc: "asc";
@@ -2444,14 +2444,14 @@ declare class BankServiceBase extends BankServiceBase_base {
2444
2444
  addPaymentsToBatch({ paymentsToBatch, }: {
2445
2445
  paymentsToBatch: SendPaymentInput[];
2446
2446
  }): Promise<IRPCResponse<{
2447
- batchPaymentInitiatedAt: Date | null;
2448
- authorizationUrls: string[] | null;
2449
2447
  status: "OPEN" | "FULL" | "PROCESSING" | "READY_TO_SIGN" | "SIGNED" | "SIGNATURE_FAILED" | "FAILED" | null;
2450
2448
  id: string;
2451
2449
  createdAt: Date | null;
2452
2450
  updatedAt: Date | null;
2453
2451
  deletedAt: Date | null;
2454
2452
  accountId: string | null;
2453
+ batchPaymentInitiatedAt: Date | null;
2454
+ authorizationUrls: string[] | null;
2455
2455
  payments: PaymentInsertType[];
2456
2456
  metadata: BatchMetadata | null;
2457
2457
  paymentsChecksum: string | null;
@@ -1518,9 +1518,9 @@ declare const getBatchesInputSchema: z.ZodObject<{
1518
1518
  limit: z.ZodNumber;
1519
1519
  sort: z.ZodObject<{
1520
1520
  column: z.ZodEnum<{
1521
- batchPaymentInitiatedAt: "batchPaymentInitiatedAt";
1522
1521
  createdAt: "createdAt";
1523
1522
  updatedAt: "updatedAt";
1523
+ batchPaymentInitiatedAt: "batchPaymentInitiatedAt";
1524
1524
  }>;
1525
1525
  direction: z.ZodEnum<{
1526
1526
  asc: "asc";
@@ -2444,14 +2444,14 @@ declare class BankServiceBase extends BankServiceBase_base {
2444
2444
  addPaymentsToBatch({ paymentsToBatch, }: {
2445
2445
  paymentsToBatch: SendPaymentInput[];
2446
2446
  }): Promise<IRPCResponse<{
2447
- batchPaymentInitiatedAt: Date | null;
2448
- authorizationUrls: string[] | null;
2449
2447
  status: "OPEN" | "FULL" | "PROCESSING" | "READY_TO_SIGN" | "SIGNED" | "SIGNATURE_FAILED" | "FAILED" | null;
2450
2448
  id: string;
2451
2449
  createdAt: Date | null;
2452
2450
  updatedAt: Date | null;
2453
2451
  deletedAt: Date | null;
2454
2452
  accountId: string | null;
2453
+ batchPaymentInitiatedAt: Date | null;
2454
+ authorizationUrls: string[] | null;
2455
2455
  payments: PaymentInsertType[];
2456
2456
  metadata: BatchMetadata | null;
2457
2457
  paymentsChecksum: string | null;
@@ -420,7 +420,9 @@ let BankServiceBase = class extends develitWorker(WorkerEntrypoint) {
420
420
  }) {
421
421
  if (!this.allowedProviders.includes(connectorKey)) {
422
422
  throw createInternalError(null, {
423
- message: `Invalid connector key: ${connectorKey}`
423
+ message: `Invalid connector key: ${connectorKey}`,
424
+ code: "VALID-B-001",
425
+ status: 400
424
426
  });
425
427
  }
426
428
  const accounts = await this._getAccounts();
@@ -439,7 +441,9 @@ let BankServiceBase = class extends develitWorker(WorkerEntrypoint) {
439
441
  );
440
442
  if (!credentials) {
441
443
  throw createInternalError(null, {
442
- message: `No credentials found for account ${acc.id}`
444
+ message: `No credentials found for account ${acc.id}`,
445
+ code: "DB-B-001",
446
+ status: 404
443
447
  });
444
448
  }
445
449
  return {
@@ -544,7 +548,9 @@ let BankServiceBase = class extends develitWorker(WorkerEntrypoint) {
544
548
  { successMessage: "Accounts synchronized successfully" },
545
549
  async () => {
546
550
  throw createInternalError(null, {
547
- message: "Not implemented yet"
551
+ message: "Not implemented yet",
552
+ code: "SYS-B-001",
553
+ status: 501
548
554
  });
549
555
  }
550
556
  );
@@ -818,14 +824,14 @@ let BankServiceBase = class extends develitWorker(WorkerEntrypoint) {
818
824
  if (!ottRow) {
819
825
  throw createInternalError(null, {
820
826
  message: "One-time token not found",
821
- code: "NOT_FOUND",
827
+ code: "DB-B-002",
822
828
  status: 404
823
829
  });
824
830
  }
825
831
  if (ottRow.expiresAt.getTime() < Date.now()) {
826
832
  throw createInternalError(null, {
827
833
  message: "One time token has expired",
828
- code: "INVALID_GRANT",
834
+ code: "VALID-B-002",
829
835
  status: 400
830
836
  });
831
837
  }
@@ -870,7 +876,7 @@ let BankServiceBase = class extends develitWorker(WorkerEntrypoint) {
870
876
  if (!fetchedAccounts)
871
877
  throw createInternalError(null, {
872
878
  message: "Account not found",
873
- code: "NOT_FOUND",
879
+ code: "DB-B-003",
874
880
  status: 404
875
881
  });
876
882
  return {
@@ -900,7 +906,7 @@ let BankServiceBase = class extends develitWorker(WorkerEntrypoint) {
900
906
  if (!account)
901
907
  throw createInternalError(null, {
902
908
  message: "Unsupported account",
903
- code: "UNSUPPORTED_ACCOUNT",
909
+ code: "VALID-B-003",
904
910
  status: 422
905
911
  });
906
912
  const payment = {
@@ -1000,7 +1006,7 @@ let BankServiceBase = class extends develitWorker(WorkerEntrypoint) {
1000
1006
  if (!updatedAccount) {
1001
1007
  throw createInternalError(null, {
1002
1008
  message: "Account not found",
1003
- code: "ACCOUNT_NOT_FOUND",
1009
+ code: "DB-B-004",
1004
1010
  status: 404
1005
1011
  });
1006
1012
  }
@@ -1017,7 +1023,7 @@ let BankServiceBase = class extends develitWorker(WorkerEntrypoint) {
1017
1023
  if (!account) {
1018
1024
  throw createInternalError(null, {
1019
1025
  message: "Account not found",
1020
- code: "ACCOUNT_NOT_FOUND",
1026
+ code: "DB-B-005",
1021
1027
  status: 404
1022
1028
  });
1023
1029
  }
@@ -1058,8 +1064,8 @@ let BankServiceBase = class extends develitWorker(WorkerEntrypoint) {
1058
1064
  if (!updatedAccount) {
1059
1065
  throw createInternalError(null, {
1060
1066
  message: "Account not updated",
1061
- code: "DB-B-0?",
1062
- status: 404
1067
+ code: "DB-B-006",
1068
+ status: 500
1063
1069
  });
1064
1070
  }
1065
1071
  return updatedAccount;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@develit-services/bank",
3
- "version": "0.3.0",
3
+ "version": "0.3.1",
4
4
  "author": "Develit.io s.r.o.",
5
5
  "type": "module",
6
6
  "exports": {