@develit-services/bank 0.0.31 → 0.0.32

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.
@@ -1,6 +1,6 @@
1
1
  import { Environment } from '@develit-io/backend-sdk';
2
2
  import { CURRENCY_CODES, BANK_CODES, CODES } from '@develit-io/general-codes';
3
- import { a as PaymentInsertType, t as tables } from './bank.Nf6oaNfB.cjs';
3
+ import { a as PaymentInsertType, t as tables } from './bank.e_XSg9KV.cjs';
4
4
  import { DrizzleD1Database } from 'drizzle-orm/d1';
5
5
  import { z } from 'zod';
6
6
  import * as drizzle_zod from 'drizzle-zod';
@@ -34,7 +34,7 @@ declare const COUNTRY_CODES: ["AF" | "AL" | "DZ" | "AS" | "AD" | "AO" | "AG" | "
34
34
  type CountryCode = (typeof COUNTRY_CODES)[number];
35
35
 
36
36
  interface BankAccountWithLastSync extends ConnectedAccount {
37
- lastSyncAt: SyncLog;
37
+ lastSyncedAt: Date;
38
38
  }
39
39
  declare const CONNECTOR_KEYS: readonly ["ERSTE", "FINBRICKS", "MOCK", "CREDITAS", "MOCK_COBS", "FIO", "MONETA"];
40
40
  type ConnectorKey = (typeof CONNECTOR_KEYS)[number];
@@ -46,10 +46,6 @@ interface ConfigEnvironmentBank {
46
46
  allowedProviders: ConnectorKey[];
47
47
  }
48
48
 
49
- interface SyncLog {
50
- lastSyncedAt: Date;
51
- }
52
-
53
49
  type WithStatus<T extends {
54
50
  status: PaymentStatus;
55
51
  }, S extends PaymentStatus> = Omit<T, 'status'> & {
@@ -106,9 +102,8 @@ declare abstract class IBankConnector {
106
102
  }): Promise<InitiatedBatch>;
107
103
  abstract initiateSEPAPayment(payment: IncomingPaymentMessage): Promise<InitiatedPayment>;
108
104
  abstract initiateSinglePayment(payment: PaymentPreparedInsertType): Promise<InitiatedPayment>;
109
- abstract getAllAccountPayments({ account, lastSync, db, env, }: {
110
- account: ConnectedAccount;
111
- lastSync: SyncLog;
105
+ abstract getAllAccountPayments({ account, db, env, }: {
106
+ account: AccountSelectType;
112
107
  db: DrizzleD1Database<typeof tables>;
113
108
  env: Environment;
114
109
  }): Promise<PaymentInsertType[]>;
@@ -166,6 +161,25 @@ declare const accountInsertSchema: drizzle_zod.BuildSchema<"insert", {
166
161
  length: number | undefined;
167
162
  $type: "AUTHORIZED" | "DISABLED" | "EXPIRED";
168
163
  }>;
164
+ bankRefId: drizzle_orm_sqlite_core.SQLiteColumn<{
165
+ name: "bank_ref_id";
166
+ tableName: "account";
167
+ dataType: "string";
168
+ columnType: "SQLiteText";
169
+ data: string;
170
+ driverParam: string;
171
+ notNull: true;
172
+ hasDefault: false;
173
+ isPrimaryKey: false;
174
+ isAutoincrement: false;
175
+ hasRuntimeDefault: false;
176
+ enumValues: [string, ...string[]];
177
+ baseColumn: never;
178
+ identity: undefined;
179
+ generated: undefined;
180
+ }, {}, {
181
+ length: number | undefined;
182
+ }>;
169
183
  sync: drizzle_orm_sqlite_core.SQLiteColumn<{
170
184
  name: "sync";
171
185
  tableName: "account";
@@ -500,6 +514,25 @@ declare const accountUpdateSchema: drizzle_zod.BuildSchema<"update", {
500
514
  length: number | undefined;
501
515
  $type: "AUTHORIZED" | "DISABLED" | "EXPIRED";
502
516
  }>;
517
+ bankRefId: drizzle_orm_sqlite_core.SQLiteColumn<{
518
+ name: "bank_ref_id";
519
+ tableName: "account";
520
+ dataType: "string";
521
+ columnType: "SQLiteText";
522
+ data: string;
523
+ driverParam: string;
524
+ notNull: true;
525
+ hasDefault: false;
526
+ isPrimaryKey: false;
527
+ isAutoincrement: false;
528
+ hasRuntimeDefault: false;
529
+ enumValues: [string, ...string[]];
530
+ baseColumn: never;
531
+ identity: undefined;
532
+ generated: undefined;
533
+ }, {}, {
534
+ length: number | undefined;
535
+ }>;
503
536
  sync: drizzle_orm_sqlite_core.SQLiteColumn<{
504
537
  name: "sync";
505
538
  tableName: "account";
@@ -834,6 +867,25 @@ declare const accountSelectSchema: drizzle_zod.BuildSchema<"select", {
834
867
  length: number | undefined;
835
868
  $type: "AUTHORIZED" | "DISABLED" | "EXPIRED";
836
869
  }>;
870
+ bankRefId: drizzle_orm_sqlite_core.SQLiteColumn<{
871
+ name: "bank_ref_id";
872
+ tableName: "account";
873
+ dataType: "string";
874
+ columnType: "SQLiteText";
875
+ data: string;
876
+ driverParam: string;
877
+ notNull: true;
878
+ hasDefault: false;
879
+ isPrimaryKey: false;
880
+ isAutoincrement: false;
881
+ hasRuntimeDefault: false;
882
+ enumValues: [string, ...string[]];
883
+ baseColumn: never;
884
+ identity: undefined;
885
+ generated: undefined;
886
+ }, {}, {
887
+ length: number | undefined;
888
+ }>;
837
889
  sync: drizzle_orm_sqlite_core.SQLiteColumn<{
838
890
  name: "sync";
839
891
  tableName: "account";
@@ -1644,5 +1696,5 @@ type AccountCredentialsUpdateType = z.infer<typeof accountCredentialsInsertSchem
1644
1696
  type AccountCredentialsPatchType = z.infer<typeof accountCredentialsUpdateSchema>;
1645
1697
  type AccountCredentialsSelectType = z.infer<typeof accountCredentialsSelectSchema>;
1646
1698
 
1647
- export { CONNECTOR_KEYS as D, CREDENTIALS_TYPES as E, accountInsertSchema as H, IBankConnector as I, accountUpdateSchema as J, accountSelectSchema as K, accountCredentialsInsertSchema as N, accountCredentialsUpdateSchema as Q, accountCredentialsSelectSchema as R, TOKEN_TYPES as T, BATCH_STATUSES as r, PAYMENT_TYPES as s, PAYMENT_STATUSES as u, PAYMENT_DIRECTIONS as v, ACCOUNT_STATUSES as x, COUNTRY_CODES as z };
1648
- export type { AccountSelectType as A, BankAccountWithLastSync as B, ConfigEnvironmentBank as C, CredentialsType as F, TokenType as G, AccountUpdateType as L, AccountPatchType as M, OutgoingPaymentMessage as O, PaymentPreparedInsertType as P, SyncLog as S, AccountCredentialsUpdateType as U, AccountCredentialsPatchType as V, AccountCredentialsSelectType as W, ConnectorKey as a, CurrencyCode as b, BankCode as c, CountryCode as d, ConnectedAccount as e, AccountCredentialsInsertType as f, AccountInsertType as g, AuthInput as h, IncomingPaymentMessage as i, InitiatedBatch as j, InitiatedPayment as k, PaymentStatus as l, BatchStatus as m, BatchMetadata as n, Currency as o, PaymentFailedInsertType as p, paymentInitializedInsertType as q, PaymentType as t, PaymentDirection as w, AccountStatus as y };
1699
+ export { CONNECTOR_KEYS as D, CREDENTIALS_TYPES as E, accountInsertSchema as H, IBankConnector as I, accountUpdateSchema as J, accountSelectSchema as K, accountCredentialsInsertSchema as N, accountCredentialsUpdateSchema as Q, accountCredentialsSelectSchema as R, TOKEN_TYPES as T, BATCH_STATUSES as q, PAYMENT_TYPES as r, PAYMENT_STATUSES as t, PAYMENT_DIRECTIONS as u, ACCOUNT_STATUSES as w, COUNTRY_CODES as y };
1700
+ export type { AccountSelectType as A, BatchMetadata as B, ConfigEnvironmentBank as C, CredentialsType as F, TokenType as G, AccountUpdateType as L, AccountPatchType as M, OutgoingPaymentMessage as O, PaymentPreparedInsertType as P, AccountCredentialsUpdateType as S, AccountCredentialsPatchType as U, AccountCredentialsSelectType as V, ConnectorKey as a, IncomingPaymentMessage as b, InitiatedPayment as c, ConnectedAccount as d, AccountCredentialsInsertType as e, AccountInsertType as f, InitiatedBatch as g, PaymentStatus as h, BatchStatus as i, CurrencyCode as j, BankCode as k, CountryCode as l, AuthInput as m, Currency as n, PaymentFailedInsertType as o, paymentInitializedInsertType as p, PaymentType as s, PaymentDirection as v, AccountStatus as x, BankAccountWithLastSync as z };
@@ -82,10 +82,10 @@ declare const paymentInsertTypeZod: z.ZodObject<{
82
82
  }>;
83
83
  status: z.ZodEnum<{
84
84
  PREPARED: "PREPARED";
85
- INITIALIZED: "INITIALIZED";
85
+ COMPLETED: "COMPLETED";
86
86
  FAILED: "FAILED";
87
+ INITIALIZED: "INITIALIZED";
87
88
  PENDING: "PENDING";
88
- COMPLETED: "COMPLETED";
89
89
  CREATED: "CREATED";
90
90
  }>;
91
91
  batchId: z.ZodString;
@@ -165,7 +165,7 @@ declare const batch: drizzle_orm_sqlite_core.SQLiteTableWithColumns<{
165
165
  tableName: "batch";
166
166
  dataType: "string";
167
167
  columnType: "SQLiteText";
168
- data: "PREPARED" | "FAILED" | "COMPLETED" | "OPEN" | "PROCESSING" | "READY_TO_SIGN" | "WAITING_FOR_PROCESSING";
168
+ data: "OPEN" | "PROCESSING" | "READY_TO_SIGN" | "WAITING_FOR_PROCESSING" | "PREPARED" | "COMPLETED" | "FAILED";
169
169
  driverParam: string;
170
170
  notNull: false;
171
171
  hasDefault: false;
@@ -178,7 +178,7 @@ declare const batch: drizzle_orm_sqlite_core.SQLiteTableWithColumns<{
178
178
  generated: undefined;
179
179
  }, {}, {
180
180
  length: number | undefined;
181
- $type: "PREPARED" | "FAILED" | "COMPLETED" | "OPEN" | "PROCESSING" | "READY_TO_SIGN" | "WAITING_FOR_PROCESSING";
181
+ $type: "OPEN" | "PROCESSING" | "READY_TO_SIGN" | "WAITING_FOR_PROCESSING" | "PREPARED" | "COMPLETED" | "FAILED";
182
182
  }>;
183
183
  payments: drizzle_orm_sqlite_core.SQLiteColumn<{
184
184
  name: "payments";
@@ -455,7 +455,7 @@ declare const payment: drizzle_orm_sqlite_core.SQLiteTableWithColumns<{
455
455
  tableName: "payment";
456
456
  dataType: "string";
457
457
  columnType: "SQLiteText";
458
- data: "PREPARED" | "INITIALIZED" | "FAILED" | "PENDING" | "COMPLETED" | "CREATED";
458
+ data: "PREPARED" | "COMPLETED" | "FAILED" | "INITIALIZED" | "PENDING" | "CREATED";
459
459
  driverParam: string;
460
460
  notNull: true;
461
461
  hasDefault: false;
@@ -468,7 +468,7 @@ declare const payment: drizzle_orm_sqlite_core.SQLiteTableWithColumns<{
468
468
  generated: undefined;
469
469
  }, {}, {
470
470
  length: number | undefined;
471
- $type: "PREPARED" | "INITIALIZED" | "FAILED" | "PENDING" | "COMPLETED" | "CREATED";
471
+ $type: "PREPARED" | "COMPLETED" | "FAILED" | "INITIALIZED" | "PENDING" | "CREATED";
472
472
  }>;
473
473
  statusReason: drizzle_orm_sqlite_core.SQLiteColumn<{
474
474
  name: "status_reason";
@@ -1006,6 +1006,25 @@ declare const account: drizzle_orm_sqlite_core.SQLiteTableWithColumns<{
1006
1006
  length: number | undefined;
1007
1007
  $type: "AUTHORIZED" | "DISABLED" | "EXPIRED";
1008
1008
  }>;
1009
+ bankRefId: drizzle_orm_sqlite_core.SQLiteColumn<{
1010
+ name: "bank_ref_id";
1011
+ tableName: "account";
1012
+ dataType: "string";
1013
+ columnType: "SQLiteText";
1014
+ data: string;
1015
+ driverParam: string;
1016
+ notNull: true;
1017
+ hasDefault: false;
1018
+ isPrimaryKey: false;
1019
+ isAutoincrement: false;
1020
+ hasRuntimeDefault: false;
1021
+ enumValues: [string, ...string[]];
1022
+ baseColumn: never;
1023
+ identity: undefined;
1024
+ generated: undefined;
1025
+ }, {}, {
1026
+ length: number | undefined;
1027
+ }>;
1009
1028
  sync: drizzle_orm_sqlite_core.SQLiteColumn<{
1010
1029
  name: "sync";
1011
1030
  tableName: "account";
@@ -82,10 +82,10 @@ declare const paymentInsertTypeZod: z.ZodObject<{
82
82
  }>;
83
83
  status: z.ZodEnum<{
84
84
  PREPARED: "PREPARED";
85
- INITIALIZED: "INITIALIZED";
85
+ COMPLETED: "COMPLETED";
86
86
  FAILED: "FAILED";
87
+ INITIALIZED: "INITIALIZED";
87
88
  PENDING: "PENDING";
88
- COMPLETED: "COMPLETED";
89
89
  CREATED: "CREATED";
90
90
  }>;
91
91
  batchId: z.ZodString;
@@ -165,7 +165,7 @@ declare const batch: drizzle_orm_sqlite_core.SQLiteTableWithColumns<{
165
165
  tableName: "batch";
166
166
  dataType: "string";
167
167
  columnType: "SQLiteText";
168
- data: "PREPARED" | "FAILED" | "COMPLETED" | "OPEN" | "PROCESSING" | "READY_TO_SIGN" | "WAITING_FOR_PROCESSING";
168
+ data: "OPEN" | "PROCESSING" | "READY_TO_SIGN" | "WAITING_FOR_PROCESSING" | "PREPARED" | "COMPLETED" | "FAILED";
169
169
  driverParam: string;
170
170
  notNull: false;
171
171
  hasDefault: false;
@@ -178,7 +178,7 @@ declare const batch: drizzle_orm_sqlite_core.SQLiteTableWithColumns<{
178
178
  generated: undefined;
179
179
  }, {}, {
180
180
  length: number | undefined;
181
- $type: "PREPARED" | "FAILED" | "COMPLETED" | "OPEN" | "PROCESSING" | "READY_TO_SIGN" | "WAITING_FOR_PROCESSING";
181
+ $type: "OPEN" | "PROCESSING" | "READY_TO_SIGN" | "WAITING_FOR_PROCESSING" | "PREPARED" | "COMPLETED" | "FAILED";
182
182
  }>;
183
183
  payments: drizzle_orm_sqlite_core.SQLiteColumn<{
184
184
  name: "payments";
@@ -455,7 +455,7 @@ declare const payment: drizzle_orm_sqlite_core.SQLiteTableWithColumns<{
455
455
  tableName: "payment";
456
456
  dataType: "string";
457
457
  columnType: "SQLiteText";
458
- data: "PREPARED" | "INITIALIZED" | "FAILED" | "PENDING" | "COMPLETED" | "CREATED";
458
+ data: "PREPARED" | "COMPLETED" | "FAILED" | "INITIALIZED" | "PENDING" | "CREATED";
459
459
  driverParam: string;
460
460
  notNull: true;
461
461
  hasDefault: false;
@@ -468,7 +468,7 @@ declare const payment: drizzle_orm_sqlite_core.SQLiteTableWithColumns<{
468
468
  generated: undefined;
469
469
  }, {}, {
470
470
  length: number | undefined;
471
- $type: "PREPARED" | "INITIALIZED" | "FAILED" | "PENDING" | "COMPLETED" | "CREATED";
471
+ $type: "PREPARED" | "COMPLETED" | "FAILED" | "INITIALIZED" | "PENDING" | "CREATED";
472
472
  }>;
473
473
  statusReason: drizzle_orm_sqlite_core.SQLiteColumn<{
474
474
  name: "status_reason";
@@ -1006,6 +1006,25 @@ declare const account: drizzle_orm_sqlite_core.SQLiteTableWithColumns<{
1006
1006
  length: number | undefined;
1007
1007
  $type: "AUTHORIZED" | "DISABLED" | "EXPIRED";
1008
1008
  }>;
1009
+ bankRefId: drizzle_orm_sqlite_core.SQLiteColumn<{
1010
+ name: "bank_ref_id";
1011
+ tableName: "account";
1012
+ dataType: "string";
1013
+ columnType: "SQLiteText";
1014
+ data: string;
1015
+ driverParam: string;
1016
+ notNull: true;
1017
+ hasDefault: false;
1018
+ isPrimaryKey: false;
1019
+ isAutoincrement: false;
1020
+ hasRuntimeDefault: false;
1021
+ enumValues: [string, ...string[]];
1022
+ baseColumn: never;
1023
+ identity: undefined;
1024
+ generated: undefined;
1025
+ }, {}, {
1026
+ length: number | undefined;
1027
+ }>;
1009
1028
  sync: drizzle_orm_sqlite_core.SQLiteColumn<{
1010
1029
  name: "sync";
1011
1030
  tableName: "account";
@@ -82,10 +82,10 @@ declare const paymentInsertTypeZod: z.ZodObject<{
82
82
  }>;
83
83
  status: z.ZodEnum<{
84
84
  PREPARED: "PREPARED";
85
- INITIALIZED: "INITIALIZED";
85
+ COMPLETED: "COMPLETED";
86
86
  FAILED: "FAILED";
87
+ INITIALIZED: "INITIALIZED";
87
88
  PENDING: "PENDING";
88
- COMPLETED: "COMPLETED";
89
89
  CREATED: "CREATED";
90
90
  }>;
91
91
  batchId: z.ZodString;
@@ -165,7 +165,7 @@ declare const batch: drizzle_orm_sqlite_core.SQLiteTableWithColumns<{
165
165
  tableName: "batch";
166
166
  dataType: "string";
167
167
  columnType: "SQLiteText";
168
- data: "PREPARED" | "FAILED" | "COMPLETED" | "OPEN" | "PROCESSING" | "READY_TO_SIGN" | "WAITING_FOR_PROCESSING";
168
+ data: "OPEN" | "PROCESSING" | "READY_TO_SIGN" | "WAITING_FOR_PROCESSING" | "PREPARED" | "COMPLETED" | "FAILED";
169
169
  driverParam: string;
170
170
  notNull: false;
171
171
  hasDefault: false;
@@ -178,7 +178,7 @@ declare const batch: drizzle_orm_sqlite_core.SQLiteTableWithColumns<{
178
178
  generated: undefined;
179
179
  }, {}, {
180
180
  length: number | undefined;
181
- $type: "PREPARED" | "FAILED" | "COMPLETED" | "OPEN" | "PROCESSING" | "READY_TO_SIGN" | "WAITING_FOR_PROCESSING";
181
+ $type: "OPEN" | "PROCESSING" | "READY_TO_SIGN" | "WAITING_FOR_PROCESSING" | "PREPARED" | "COMPLETED" | "FAILED";
182
182
  }>;
183
183
  payments: drizzle_orm_sqlite_core.SQLiteColumn<{
184
184
  name: "payments";
@@ -455,7 +455,7 @@ declare const payment: drizzle_orm_sqlite_core.SQLiteTableWithColumns<{
455
455
  tableName: "payment";
456
456
  dataType: "string";
457
457
  columnType: "SQLiteText";
458
- data: "PREPARED" | "INITIALIZED" | "FAILED" | "PENDING" | "COMPLETED" | "CREATED";
458
+ data: "PREPARED" | "COMPLETED" | "FAILED" | "INITIALIZED" | "PENDING" | "CREATED";
459
459
  driverParam: string;
460
460
  notNull: true;
461
461
  hasDefault: false;
@@ -468,7 +468,7 @@ declare const payment: drizzle_orm_sqlite_core.SQLiteTableWithColumns<{
468
468
  generated: undefined;
469
469
  }, {}, {
470
470
  length: number | undefined;
471
- $type: "PREPARED" | "INITIALIZED" | "FAILED" | "PENDING" | "COMPLETED" | "CREATED";
471
+ $type: "PREPARED" | "COMPLETED" | "FAILED" | "INITIALIZED" | "PENDING" | "CREATED";
472
472
  }>;
473
473
  statusReason: drizzle_orm_sqlite_core.SQLiteColumn<{
474
474
  name: "status_reason";
@@ -1006,6 +1006,25 @@ declare const account: drizzle_orm_sqlite_core.SQLiteTableWithColumns<{
1006
1006
  length: number | undefined;
1007
1007
  $type: "AUTHORIZED" | "DISABLED" | "EXPIRED";
1008
1008
  }>;
1009
+ bankRefId: drizzle_orm_sqlite_core.SQLiteColumn<{
1010
+ name: "bank_ref_id";
1011
+ tableName: "account";
1012
+ dataType: "string";
1013
+ columnType: "SQLiteText";
1014
+ data: string;
1015
+ driverParam: string;
1016
+ notNull: true;
1017
+ hasDefault: false;
1018
+ isPrimaryKey: false;
1019
+ isAutoincrement: false;
1020
+ hasRuntimeDefault: false;
1021
+ enumValues: [string, ...string[]];
1022
+ baseColumn: never;
1023
+ identity: undefined;
1024
+ generated: undefined;
1025
+ }, {}, {
1026
+ length: number | undefined;
1027
+ }>;
1009
1028
  sync: drizzle_orm_sqlite_core.SQLiteColumn<{
1010
1029
  name: "sync";
1011
1030
  tableName: "account";
@@ -7,7 +7,6 @@ import { createInsertSchema, createUpdateSchema, createSelectSchema } from 'driz
7
7
  import { sqliteTable, integer, text, unique, real } from 'drizzle-orm/sqlite-core';
8
8
  import { format, parseISO } from 'date-fns';
9
9
  import { relations } from 'drizzle-orm/relations';
10
- import 'superjson';
11
10
 
12
11
  class IBankConnector {
13
12
  }
@@ -182,6 +181,7 @@ const mapFinbricksTransactionToPayment = (tx, account) => {
182
181
  const base = {
183
182
  id: uuidv4(),
184
183
  connectorKey: account.connectorKey,
184
+ accountId: account.id,
185
185
  bankRefId: tx.entryReference || tx.fbxReference,
186
186
  amount: tx.amount?.value || 0,
187
187
  currency: tx.amount?.currency || "CZK",
@@ -209,6 +209,7 @@ const mapFinbricksAccountInsert = ({
209
209
  status
210
210
  }) => ({
211
211
  id: account.id,
212
+ bankRefId: account.bankRefId,
212
213
  connectorKey,
213
214
  status,
214
215
  sync: false,
@@ -283,14 +284,20 @@ class FinbricksConnector extends IBankConnector {
283
284
  status: 401
284
285
  });
285
286
  }
286
- const accounts = await this.getAccountsForClient({ clientId });
287
+ const accounts = (await this.getAccountsForClient({ clientId })).map(
288
+ (acc) => ({
289
+ ...acc,
290
+ bankRefId: acc.id,
291
+ id: uuidv4()
292
+ })
293
+ );
287
294
  console.log(accounts, "accs finbricks");
288
295
  const credentials = accounts.map((acc) => ({
289
- accountId: acc.id,
290
296
  connectorKey: this.PROVIDER,
291
297
  expiresAt: new Date(Date.now() + 36e5),
292
298
  type: "CLIENT_ID",
293
- value: clientId
299
+ value: clientId,
300
+ accountId: acc.id
294
301
  }));
295
302
  this.connectedAccounts.push(
296
303
  ...accounts.map((acc) => ({
@@ -392,6 +399,7 @@ class FinbricksConnector extends IBankConnector {
392
399
  );
393
400
  return uniqueAccounts.map((acc) => ({
394
401
  connectorKey: this.connectorKey,
402
+ bankRefId: acc.id,
395
403
  currency: acc.currency,
396
404
  sync: false,
397
405
  status: "AUTHORIZED",
@@ -529,11 +537,10 @@ class FinbricksConnector extends IBankConnector {
529
537
  };
530
538
  }
531
539
  async getAllAccountPayments({
532
- account,
533
- lastSync
540
+ account
534
541
  }) {
535
542
  const dateFormat = "yyyy-MM-dd";
536
- const dateFrom = format(lastSync.lastSyncedAt, dateFormat);
543
+ const dateFrom = format(account.lastSyncedAt, dateFormat);
537
544
  const dateTo = format(/* @__PURE__ */ new Date(), dateFormat);
538
545
  let cursor = null;
539
546
  const allPayments = [];
@@ -836,12 +843,11 @@ class ErsteConnector extends IBankConnector {
836
843
  return (await data.json()).signingUrl;
837
844
  }
838
845
  async getAllAccountPayments({
839
- account,
840
- lastSync
846
+ account
841
847
  }) {
842
848
  const erstePayments = [];
843
849
  const dateFormat = "yyyy-MM-dd";
844
- const fromDate = format(lastSync.lastSyncedAt, dateFormat);
850
+ const fromDate = format(account.lastSyncedAt, dateFormat);
845
851
  const toDate = format(/* @__PURE__ */ new Date(), dateFormat);
846
852
  let page = 0;
847
853
  const pageSize = 200;
@@ -866,6 +872,7 @@ class ErsteConnector extends IBankConnector {
866
872
  const paymentInsert = {
867
873
  id: uuidv4(),
868
874
  connectorKey: "ERSTE",
875
+ accountId: account.id,
869
876
  bankRefId: payment.entryReference,
870
877
  amount: payment.amount.value,
871
878
  currency: payment.amount.currency.code,
@@ -1052,6 +1059,7 @@ const account = sqliteTable(
1052
1059
  enum: CONNECTOR_KEYS
1053
1060
  }).$type().notNull(),
1054
1061
  status: text("status", { enum: ACCOUNT_STATUSES }).$type().notNull(),
1062
+ bankRefId: text("bank_ref_id").notNull(),
1055
1063
  sync: integer("sync", { mode: "boolean" }).default(false).notNull(),
1056
1064
  syncPeriod: integer("sync_period"),
1057
1065
  lastSyncedAt: integer("last_synced_at", { mode: "timestamp_ms" })
package/dist/types.cjs CHANGED
@@ -1,7 +1,7 @@
1
1
  'use strict';
2
2
 
3
- const database_schema = require('./shared/bank.BMRBXGF1.cjs');
4
- const mockCobs_connector = require('./shared/bank.DuY4d2y_.cjs');
3
+ const database_schema = require('./shared/bank.Dx7kRjFL.cjs');
4
+ const mockCobs_connector = require('./shared/bank.BiZtZWed.cjs');
5
5
  const generalCodes = require('@develit-io/general-codes');
6
6
  require('@develit-io/backend-sdk');
7
7
  require('drizzle-orm');
@@ -11,7 +11,6 @@ require('drizzle-zod');
11
11
  require('drizzle-orm/sqlite-core');
12
12
  require('date-fns');
13
13
  require('drizzle-orm/relations');
14
- require('superjson');
15
14
 
16
15
 
17
16
 
package/dist/types.d.cts CHANGED
@@ -1,7 +1,7 @@
1
- import { b as CurrencyCode, c as BankCode, d as CountryCode, e as ConnectedAccount, I as IBankConnector, a as ConnectorKey, f as AccountCredentialsInsertType, g as AccountInsertType, h as AuthInput, i as IncomingPaymentMessage, P as PaymentPreparedInsertType, j as InitiatedBatch, k as InitiatedPayment, S as SyncLog, l as PaymentStatus, m as BatchStatus, n as BatchMetadata, o as Currency } from './shared/bank.DUalSuEK.cjs';
2
- export { x as ACCOUNT_STATUSES, V as AccountCredentialsPatchType, W as AccountCredentialsSelectType, U as AccountCredentialsUpdateType, M as AccountPatchType, A as AccountSelectType, y as AccountStatus, L as AccountUpdateType, r as BATCH_STATUES, r as BATCH_STATUSES, B as BankAccountWithLastSync, D as CONNECTOR_KEYS, z as COUNTRY_CODES, E as CREDENTIALS_TYPES, C as ConfigEnvironmentBank, F as CredentialsType, O as OutgoingPaymentMessage, v as PAYMENT_DIRECTIONS, u as PAYMENT_STATUSES, s as PAYMENT_TYPES, w as PaymentDirection, p as PaymentFailedInsertType, t as PaymentType, T as TOKEN_TYPES, G as TokenType, N as accountCredentialsInsertSchema, R as accountCredentialsSelectSchema, Q as accountCredentialsUpdateSchema, H as accountInsertSchema, K as accountSelectSchema, J as accountUpdateSchema, q as paymentInitializedInsertType } from './shared/bank.DUalSuEK.cjs';
3
- import { t as tables, a as PaymentInsertType, P as PaymentSelectType } from './shared/bank.Nf6oaNfB.cjs';
4
- export { b as BatchInsertType, B as BatchSelectType, p as paymentInsertTypeZod } from './shared/bank.Nf6oaNfB.cjs';
1
+ import { I as IBankConnector, b as IncomingPaymentMessage, c as InitiatedPayment, a as ConnectorKey, d as ConnectedAccount, e as AccountCredentialsInsertType, f as AccountInsertType, P as PaymentPreparedInsertType, g as InitiatedBatch, B as BatchMetadata, A as AccountSelectType, h as PaymentStatus, i as BatchStatus, j as CurrencyCode, k as BankCode, l as CountryCode, m as AuthInput, n as Currency } from './shared/bank._5C74-4K.cjs';
2
+ export { w as ACCOUNT_STATUSES, U as AccountCredentialsPatchType, V as AccountCredentialsSelectType, S as AccountCredentialsUpdateType, M as AccountPatchType, x as AccountStatus, L as AccountUpdateType, q as BATCH_STATUES, q as BATCH_STATUSES, z as BankAccountWithLastSync, D as CONNECTOR_KEYS, y as COUNTRY_CODES, E as CREDENTIALS_TYPES, C as ConfigEnvironmentBank, F as CredentialsType, O as OutgoingPaymentMessage, u as PAYMENT_DIRECTIONS, t as PAYMENT_STATUSES, r as PAYMENT_TYPES, v as PaymentDirection, o as PaymentFailedInsertType, s as PaymentType, T as TOKEN_TYPES, G as TokenType, N as accountCredentialsInsertSchema, R as accountCredentialsSelectSchema, Q as accountCredentialsUpdateSchema, H as accountInsertSchema, K as accountSelectSchema, J as accountUpdateSchema, p as paymentInitializedInsertType } from './shared/bank._5C74-4K.cjs';
3
+ import { a as PaymentInsertType, t as tables, P as PaymentSelectType } from './shared/bank.e_XSg9KV.cjs';
4
+ export { b as BatchInsertType, B as BatchSelectType, p as paymentInsertTypeZod } from './shared/bank.e_XSg9KV.cjs';
5
5
  import { Environment, BaseEvent } from '@develit-io/backend-sdk';
6
6
  import { DrizzleD1Database } from 'drizzle-orm/d1';
7
7
  export { b as BankServiceEnv, a as BankServiceEnvironmentConfig, B as BankServiceWranglerConfig } from './shared/bank.BchnXQDL.cjs';
@@ -11,6 +11,65 @@ import { z } from 'zod';
11
11
  export { BANK_CODES, CURRENCY_CODES } from '@develit-io/general-codes';
12
12
  import 'drizzle-orm';
13
13
 
14
+ interface ErsteConnectorConfig {
15
+ API_KEY: string;
16
+ CLIENT_ID: string;
17
+ CLIENT_SECRET: string;
18
+ REDIRECT_URI: string;
19
+ AUTH_URI: string;
20
+ PAYMENTS_URI: string;
21
+ ACCOUNTS_URI: string;
22
+ connectedAccounts: ConnectedAccount[];
23
+ }
24
+ declare class ErsteConnector extends IBankConnector {
25
+ initiateSEPAPayment(payment: IncomingPaymentMessage): Promise<InitiatedPayment>;
26
+ static readonly FETCH_INTERVAL: number;
27
+ private readonly API_KEY;
28
+ private readonly CLIENT_ID;
29
+ private readonly CLIENT_SECRET;
30
+ private readonly AUTH_URI;
31
+ private readonly PAYMENTS_URI;
32
+ private readonly REDIRECT_URI;
33
+ private readonly ACCOUNTS_URI;
34
+ connectorKey: ConnectorKey;
35
+ connectedAccounts: ConnectedAccount[];
36
+ private accessToken;
37
+ constructor(config: ErsteConnectorConfig);
38
+ getAuthUri({ ott }: {
39
+ ott: string;
40
+ }): Promise<string>;
41
+ authorizeAccount({ urlParams }: {
42
+ urlParams: string;
43
+ }): Promise<{
44
+ credentials: AccountCredentialsInsertType[];
45
+ accounts: AccountInsertType[];
46
+ }>;
47
+ authenticate(tokens?: {
48
+ refreshToken?: string;
49
+ token?: string;
50
+ }): Promise<string>;
51
+ listAccounts(): Promise<[]>;
52
+ preparePayment(payment: IncomingPaymentMessage): Promise<PaymentPreparedInsertType>;
53
+ initiateBatchFromPayments({ payments, }: {
54
+ payments: PaymentPreparedInsertType[];
55
+ }): Promise<InitiatedBatch>;
56
+ initiateSinglePayment(): Promise<InitiatedPayment>;
57
+ sendBatchPaymentForAuthorization(paymentIds: string[]): Promise<BatchMetadata>;
58
+ getBatchAuthorizationURI({ signId, signHash, }: {
59
+ signId: string;
60
+ signHash: string;
61
+ }): Promise<string>;
62
+ getAllAccountPayments({ account, }: {
63
+ account: AccountSelectType;
64
+ }): Promise<PaymentInsertType[]>;
65
+ getPaymentStatus(_: {
66
+ paymentId: string;
67
+ }): Promise<PaymentStatus>;
68
+ getBatchStatus(_: {
69
+ batchId: string;
70
+ }): Promise<BatchStatus>;
71
+ }
72
+
14
73
  type FinbricksProvider = 'KB' | 'ERSTE' | 'CSOB' | 'MOCK_COBS' | 'CREDITAS' | 'FIO' | 'MONETA';
15
74
  declare const FINBRICKS_TRANSACTION_STATUSES: readonly ["OPENED", "AUTHORIZED", "COMPLETED", "BOOKED", "SETTLED", "REJECTED", "CLOSED"];
16
75
  type FinbricksTransactionStatus = (typeof FINBRICKS_TRANSACTION_STATUSES)[number];
@@ -355,9 +414,8 @@ declare abstract class FinbricksConnector extends IBankConnector {
355
414
  }): Promise<InitiatedBatch>;
356
415
  initiateSEPAPayment(payment: IncomingPaymentMessage): Promise<InitiatedPayment>;
357
416
  initiateSinglePayment(payment: PaymentPreparedInsertType): Promise<InitiatedPayment>;
358
- getAllAccountPayments({ account, lastSync, }: {
359
- account: ConnectedAccount;
360
- lastSync: SyncLog;
417
+ getAllAccountPayments({ account, }: {
418
+ account: AccountSelectType;
361
419
  db: DrizzleD1Database<typeof tables>;
362
420
  env: Environment;
363
421
  }): Promise<PaymentInsertType[]>;
@@ -369,66 +427,6 @@ declare abstract class FinbricksConnector extends IBankConnector {
369
427
  }): Promise<BatchStatus>;
370
428
  }
371
429
 
372
- interface ErsteConnectorConfig {
373
- API_KEY: string;
374
- CLIENT_ID: string;
375
- CLIENT_SECRET: string;
376
- REDIRECT_URI: string;
377
- AUTH_URI: string;
378
- PAYMENTS_URI: string;
379
- ACCOUNTS_URI: string;
380
- connectedAccounts: ConnectedAccount[];
381
- }
382
- declare class ErsteConnector extends IBankConnector {
383
- initiateSEPAPayment(payment: IncomingPaymentMessage): Promise<InitiatedPayment>;
384
- static readonly FETCH_INTERVAL: number;
385
- private readonly API_KEY;
386
- private readonly CLIENT_ID;
387
- private readonly CLIENT_SECRET;
388
- private readonly AUTH_URI;
389
- private readonly PAYMENTS_URI;
390
- private readonly REDIRECT_URI;
391
- private readonly ACCOUNTS_URI;
392
- connectorKey: ConnectorKey;
393
- connectedAccounts: ConnectedAccount[];
394
- private accessToken;
395
- constructor(config: ErsteConnectorConfig);
396
- getAuthUri({ ott }: {
397
- ott: string;
398
- }): Promise<string>;
399
- authorizeAccount({ urlParams }: {
400
- urlParams: string;
401
- }): Promise<{
402
- credentials: AccountCredentialsInsertType[];
403
- accounts: AccountInsertType[];
404
- }>;
405
- authenticate(tokens?: {
406
- refreshToken?: string;
407
- token?: string;
408
- }): Promise<string>;
409
- listAccounts(): Promise<[]>;
410
- preparePayment(payment: IncomingPaymentMessage): Promise<PaymentPreparedInsertType>;
411
- initiateBatchFromPayments({ payments, }: {
412
- payments: PaymentPreparedInsertType[];
413
- }): Promise<InitiatedBatch>;
414
- initiateSinglePayment(): Promise<InitiatedPayment>;
415
- sendBatchPaymentForAuthorization(paymentIds: string[]): Promise<BatchMetadata>;
416
- getBatchAuthorizationURI({ signId, signHash, }: {
417
- signId: string;
418
- signHash: string;
419
- }): Promise<string>;
420
- getAllAccountPayments({ account, lastSync, }: {
421
- account: ConnectedAccount;
422
- lastSync: SyncLog;
423
- }): Promise<PaymentInsertType[]>;
424
- getPaymentStatus(_: {
425
- paymentId: string;
426
- }): Promise<PaymentStatus>;
427
- getBatchStatus(_: {
428
- batchId: string;
429
- }): Promise<BatchStatus>;
430
- }
431
-
432
430
  declare class MockConnector extends IBankConnector {
433
431
  initiateSEPAPayment(payment: IncomingPaymentMessage): Promise<InitiatedPayment>;
434
432
  connectedAccounts: ConnectedAccount[];
@@ -1054,5 +1052,5 @@ type OneTimeTokenUpdateType = z.infer<typeof ottInsertSchema>;
1054
1052
  type OneTimeTokenPatchType = z.infer<typeof ottUpdateSchema>;
1055
1053
  type OneTimeTokenSelectType = z.infer<typeof ottSelectSchema>;
1056
1054
 
1057
- export { AccountCredentialsInsertType, AccountInsertType, AuthInput, BankCode, BatchMetadata, BatchStatus, ConnectedAccount, ConnectorKey, CountryCode, Currency, CurrencyCode, ErsteConnector, FINBRICKS_ENDPOINTS, FinbricksClient, FinbricksConnector, IBankConnector, IncomingPaymentMessage, InitiatedBatch, InitiatedPayment, MockCobsConnector, MockConnector, PaymentInsertType, PaymentPreparedInsertType, PaymentSelectType, PaymentStatus, ottInsertSchema, ottSelectSchema, ottUpdateSchema, signFinbricksJws, useFinbricksFetch };
1055
+ export { AccountCredentialsInsertType, AccountInsertType, AccountSelectType, AuthInput, BankCode, BatchMetadata, BatchStatus, ConnectedAccount, ConnectorKey, CountryCode, Currency, CurrencyCode, ErsteConnector, FINBRICKS_ENDPOINTS, FinbricksClient, FinbricksConnector, IBankConnector, IncomingPaymentMessage, InitiatedBatch, InitiatedPayment, MockCobsConnector, MockConnector, PaymentInsertType, PaymentPreparedInsertType, PaymentSelectType, PaymentStatus, ottInsertSchema, ottSelectSchema, ottUpdateSchema, signFinbricksJws, useFinbricksFetch };
1058
1056
  export type { BankPaymentEvent, ErsteAuthenticationResponse, ErsteBatchPaymentInitiationResponse, ErsteIncomingPaymentResponse, ErsteObtainAuthorizationURLResponse, ErstePaymentInitiationResponse, FinbricksAccount, FinbricksAccountTransactionsResponse, FinbricksAccountsListResponse, FinbricksAuthTokenResponse, FinbricksBatchBody, FinbricksBatchResponse, FinbricksBatchStatus, FinbricksConnectAccountBody, FinbricksConnectAccountResponse, FinbricksConnectorConfig, FinbricksEndpoint, FinbricksEndpointPath, FinbricksFetchConfig, FinbricksGetBatchStatusBody, FinbricksGetBatchStatusResponse, FinbricksGetTransactionStatusResponse, FinbricksJWSData, FinbricksPaymentBody, FinbricksPaymentResponse, FinbricksProvider, FinbricksRequestInit, FinbricksTransactionStatus, OneTimeTokenInsertType, OneTimeTokenPatchType, OneTimeTokenSelectType, OneTimeTokenUpdateType };