@develit-services/bank 0.1.9 → 0.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.
- package/dist/database/schema.cjs +1 -1
- package/dist/database/schema.d.cts +1 -1
- package/dist/database/schema.d.mts +1 -1
- package/dist/database/schema.d.ts +1 -1
- package/dist/database/schema.mjs +1 -1
- package/dist/export/worker.cjs +7 -123
- package/dist/export/worker.d.cts +14 -17
- package/dist/export/worker.d.mts +14 -17
- package/dist/export/worker.d.ts +14 -17
- package/dist/export/worker.mjs +7 -123
- package/dist/export/workflows.cjs +27 -20
- package/dist/export/workflows.mjs +27 -20
- package/dist/shared/{bank.DouutABZ.d.mts → bank.2BgwPCw_.d.ts} +2 -2
- package/dist/shared/{bank.-FurAs09.cjs → bank.B5dSMikM.cjs} +2 -7
- package/dist/shared/{bank.CsvBtQib.d.cts → bank.BGZYksmV.d.cts} +12 -8
- package/dist/shared/{bank.CsvBtQib.d.mts → bank.BGZYksmV.d.mts} +12 -8
- package/dist/shared/{bank.CsvBtQib.d.ts → bank.BGZYksmV.d.ts} +12 -8
- package/dist/shared/{bank.CRVH1wUH.d.cts → bank.BOe_Qmuw.d.mts} +2 -2
- package/dist/shared/{bank.BvXwHpBp.mjs → bank.BcDo3cbz.mjs} +1 -1
- package/dist/shared/{bank.DTdKHhGd.mjs → bank.CpoWaBu0.mjs} +4 -8
- package/dist/shared/{bank.W4h6Dlzi.mjs → bank.DdvSjgls.mjs} +17 -8
- package/dist/shared/{bank.z4VxSea3.cjs → bank.DhuHP2ky.cjs} +1 -1
- package/dist/shared/{bank.tLe0jhjo.cjs → bank.NAgd77sr.cjs} +17 -8
- package/dist/shared/{bank.Ckn_klvT.d.ts → bank.RD4xwHFf.d.cts} +2 -2
- package/dist/types.cjs +2 -2
- package/dist/types.d.cts +11 -9
- package/dist/types.d.mts +11 -9
- package/dist/types.d.ts +11 -9
- package/dist/types.mjs +2 -2
- package/package.json +1 -1
|
@@ -3,9 +3,9 @@
|
|
|
3
3
|
const cloudflare_workers = require('cloudflare:workers');
|
|
4
4
|
const cloudflare_workflows = require('cloudflare:workflows');
|
|
5
5
|
const d1 = require('drizzle-orm/d1');
|
|
6
|
-
const database_schema = require('../shared/bank.
|
|
6
|
+
const database_schema = require('../shared/bank.NAgd77sr.cjs');
|
|
7
7
|
const backendSdk = require('@develit-io/backend-sdk');
|
|
8
|
-
const bank = require('../shared/bank
|
|
8
|
+
const bank = require('../shared/bank.B5dSMikM.cjs');
|
|
9
9
|
const drizzleOrm = require('drizzle-orm');
|
|
10
10
|
require('drizzle-orm/sqlite-core');
|
|
11
11
|
require('date-fns');
|
|
@@ -14,12 +14,16 @@ require('zod');
|
|
|
14
14
|
require('jose');
|
|
15
15
|
require('drizzle-zod');
|
|
16
16
|
require('drizzle-orm/relations');
|
|
17
|
-
require('../shared/bank.
|
|
17
|
+
require('../shared/bank.DhuHP2ky.cjs');
|
|
18
18
|
|
|
19
19
|
const getAccountByIdQuery = async (db, { accountId }) => {
|
|
20
20
|
return await db.select().from(database_schema.tables.account).where(drizzleOrm.eq(database_schema.tables.account.id, accountId)).get();
|
|
21
21
|
};
|
|
22
22
|
|
|
23
|
+
const getPaymentsByBankRefIdsQuery = async (db, { ids }) => {
|
|
24
|
+
return await db.select().from(database_schema.tables.payment).where(drizzleOrm.inArray(database_schema.tables.payment.bankRefId, ids));
|
|
25
|
+
};
|
|
26
|
+
|
|
23
27
|
function pushToQueue(queue, message) {
|
|
24
28
|
if (!Array.isArray(message)) return queue.send(message, { contentType: "v8" });
|
|
25
29
|
return queue.sendBatch(
|
|
@@ -82,62 +86,65 @@ class SyncAccountPaymentsWorkflow extends cloudflare_workers.WorkflowEntrypoint
|
|
|
82
86
|
});
|
|
83
87
|
return fetched.map((p) => ({
|
|
84
88
|
...p,
|
|
85
|
-
|
|
89
|
+
parsed: {
|
|
90
|
+
...p.parsed,
|
|
91
|
+
direction: database_schema.getPaymentDirection(p.parsed, account.iban)
|
|
92
|
+
}
|
|
86
93
|
}));
|
|
87
94
|
}
|
|
88
95
|
);
|
|
89
96
|
if (payments.length) {
|
|
90
|
-
const bankRefIds = payments.map((payment) => payment.bankRefId).filter(Boolean);
|
|
97
|
+
const bankRefIds = payments.map((payment) => payment.parsed.bankRefId).filter(Boolean);
|
|
91
98
|
const existing = await step.do("load existing payments", async () => {
|
|
92
|
-
return await
|
|
99
|
+
return await getPaymentsByBankRefIdsQuery(db, {
|
|
93
100
|
ids: bankRefIds
|
|
94
101
|
});
|
|
95
102
|
});
|
|
96
103
|
const paymentsToUpdate = payments.filter(
|
|
97
|
-
(p) => existing.some((e) => e.bankRefId === p.bankRefId)
|
|
104
|
+
(p) => existing.some((e) => e.bankRefId === p.parsed.bankRefId)
|
|
98
105
|
);
|
|
99
106
|
const paymentsToCreate = payments.filter(
|
|
100
|
-
(p) => !existing.some((e) => e.bankRefId === p.bankRefId)
|
|
107
|
+
(p) => !existing.some((e) => e.bankRefId === p.parsed.bankRefId)
|
|
101
108
|
);
|
|
102
109
|
await step.do("process payments and update lastSyncAt", async () => {
|
|
103
110
|
const eventsToEmit = [];
|
|
104
111
|
const updateCommands = paymentsToUpdate.map(
|
|
105
|
-
(p) => bank.updatePaymentCommand(db, { payment: p }).command
|
|
112
|
+
(p) => bank.updatePaymentCommand(db, { payment: p.parsed }).command
|
|
106
113
|
);
|
|
107
114
|
eventsToEmit.push(
|
|
108
115
|
...paymentsToUpdate.map((p) => ({
|
|
109
116
|
eventType: "BANK_PAYMENT",
|
|
110
117
|
eventSignal: "paymentUpdated",
|
|
111
|
-
bankPayment: p,
|
|
118
|
+
bankPayment: p.parsed,
|
|
112
119
|
metadata: {
|
|
113
|
-
correlationId: p.correlationId,
|
|
114
|
-
entityId: p.id,
|
|
115
|
-
idempotencySuffix: p.status,
|
|
120
|
+
correlationId: p.parsed.correlationId,
|
|
121
|
+
entityId: p.parsed.id,
|
|
122
|
+
idempotencySuffix: p.parsed.status,
|
|
116
123
|
timestamp: (/* @__PURE__ */ new Date()).toDateString()
|
|
117
124
|
}
|
|
118
125
|
}))
|
|
119
126
|
);
|
|
120
127
|
const createCommands = paymentsToCreate.map(
|
|
121
|
-
(p) => bank.createPaymentCommand(db, { payment: p }).command
|
|
128
|
+
(p) => bank.createPaymentCommand(db, { payment: p.parsed }).command
|
|
122
129
|
);
|
|
123
130
|
eventsToEmit.push(
|
|
124
131
|
...paymentsToCreate.map((p) => ({
|
|
125
132
|
eventType: "BANK_PAYMENT",
|
|
126
133
|
eventSignal: "paymentCreated",
|
|
127
|
-
bankPayment: p,
|
|
134
|
+
bankPayment: p.parsed,
|
|
128
135
|
metadata: {
|
|
129
|
-
correlationId: p.correlationId,
|
|
130
|
-
entityId: p.id,
|
|
136
|
+
correlationId: p.parsed.correlationId,
|
|
137
|
+
entityId: p.parsed.id,
|
|
131
138
|
timestamp: (/* @__PURE__ */ new Date()).toDateString()
|
|
132
139
|
}
|
|
133
140
|
}))
|
|
134
141
|
);
|
|
135
142
|
const latest = payments.reduce((current, p) => {
|
|
136
|
-
return new Date(p.processedAt).getTime() > new Date(current.processedAt).getTime() ? p : current;
|
|
143
|
+
return new Date(p.parsed.processedAt).getTime() > new Date(current.parsed.processedAt).getTime() ? p : current;
|
|
137
144
|
}, payments[0]);
|
|
138
145
|
const updateLastSyncCommand = bank.updateAccountLastSyncCommand(db, {
|
|
139
146
|
accountId: account.id,
|
|
140
|
-
lastSyncedAt: latest.processedAt
|
|
147
|
+
lastSyncedAt: latest.parsed.processedAt
|
|
141
148
|
}).command;
|
|
142
149
|
if (eventsToEmit.length) {
|
|
143
150
|
await db.batch(
|
|
@@ -157,7 +164,7 @@ class SyncAccountPaymentsWorkflow extends cloudflare_workers.WorkflowEntrypoint
|
|
|
157
164
|
updated: paymentsToUpdate.length,
|
|
158
165
|
created: paymentsToCreate.length,
|
|
159
166
|
eventsEmitted: eventsToEmit.length,
|
|
160
|
-
lastSyncedAt: latest?.createdAt
|
|
167
|
+
lastSyncedAt: latest?.parsed?.createdAt
|
|
161
168
|
};
|
|
162
169
|
});
|
|
163
170
|
}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { WorkflowEntrypoint } from 'cloudflare:workers';
|
|
2
2
|
import { NonRetryableError } from 'cloudflare:workflows';
|
|
3
3
|
import { drizzle } from 'drizzle-orm/d1';
|
|
4
|
-
import { t as tables, v as getPaymentDirection } from '../shared/bank.
|
|
4
|
+
import { t as tables, v as getPaymentDirection } from '../shared/bank.DdvSjgls.mjs';
|
|
5
5
|
import { asNonEmpty } from '@develit-io/backend-sdk';
|
|
6
|
-
import { g as getCredentialsByAccountId, i as initiateConnector,
|
|
7
|
-
import { eq } from 'drizzle-orm';
|
|
6
|
+
import { g as getCredentialsByAccountId, i as initiateConnector, u as updatePaymentCommand, c as createPaymentCommand, a as updateAccountLastSyncCommand } from '../shared/bank.CpoWaBu0.mjs';
|
|
7
|
+
import { eq, inArray } from 'drizzle-orm';
|
|
8
8
|
import 'drizzle-orm/sqlite-core';
|
|
9
9
|
import 'date-fns';
|
|
10
10
|
import '@develit-io/general-codes';
|
|
@@ -12,12 +12,16 @@ import 'zod';
|
|
|
12
12
|
import 'jose';
|
|
13
13
|
import 'drizzle-zod';
|
|
14
14
|
import 'drizzle-orm/relations';
|
|
15
|
-
import '../shared/bank.
|
|
15
|
+
import '../shared/bank.BcDo3cbz.mjs';
|
|
16
16
|
|
|
17
17
|
const getAccountByIdQuery = async (db, { accountId }) => {
|
|
18
18
|
return await db.select().from(tables.account).where(eq(tables.account.id, accountId)).get();
|
|
19
19
|
};
|
|
20
20
|
|
|
21
|
+
const getPaymentsByBankRefIdsQuery = async (db, { ids }) => {
|
|
22
|
+
return await db.select().from(tables.payment).where(inArray(tables.payment.bankRefId, ids));
|
|
23
|
+
};
|
|
24
|
+
|
|
21
25
|
function pushToQueue(queue, message) {
|
|
22
26
|
if (!Array.isArray(message)) return queue.send(message, { contentType: "v8" });
|
|
23
27
|
return queue.sendBatch(
|
|
@@ -80,62 +84,65 @@ class SyncAccountPaymentsWorkflow extends WorkflowEntrypoint {
|
|
|
80
84
|
});
|
|
81
85
|
return fetched.map((p) => ({
|
|
82
86
|
...p,
|
|
83
|
-
|
|
87
|
+
parsed: {
|
|
88
|
+
...p.parsed,
|
|
89
|
+
direction: getPaymentDirection(p.parsed, account.iban)
|
|
90
|
+
}
|
|
84
91
|
}));
|
|
85
92
|
}
|
|
86
93
|
);
|
|
87
94
|
if (payments.length) {
|
|
88
|
-
const bankRefIds = payments.map((payment) => payment.bankRefId).filter(Boolean);
|
|
95
|
+
const bankRefIds = payments.map((payment) => payment.parsed.bankRefId).filter(Boolean);
|
|
89
96
|
const existing = await step.do("load existing payments", async () => {
|
|
90
97
|
return await getPaymentsByBankRefIdsQuery(db, {
|
|
91
98
|
ids: bankRefIds
|
|
92
99
|
});
|
|
93
100
|
});
|
|
94
101
|
const paymentsToUpdate = payments.filter(
|
|
95
|
-
(p) => existing.some((e) => e.bankRefId === p.bankRefId)
|
|
102
|
+
(p) => existing.some((e) => e.bankRefId === p.parsed.bankRefId)
|
|
96
103
|
);
|
|
97
104
|
const paymentsToCreate = payments.filter(
|
|
98
|
-
(p) => !existing.some((e) => e.bankRefId === p.bankRefId)
|
|
105
|
+
(p) => !existing.some((e) => e.bankRefId === p.parsed.bankRefId)
|
|
99
106
|
);
|
|
100
107
|
await step.do("process payments and update lastSyncAt", async () => {
|
|
101
108
|
const eventsToEmit = [];
|
|
102
109
|
const updateCommands = paymentsToUpdate.map(
|
|
103
|
-
(p) => updatePaymentCommand(db, { payment: p }).command
|
|
110
|
+
(p) => updatePaymentCommand(db, { payment: p.parsed }).command
|
|
104
111
|
);
|
|
105
112
|
eventsToEmit.push(
|
|
106
113
|
...paymentsToUpdate.map((p) => ({
|
|
107
114
|
eventType: "BANK_PAYMENT",
|
|
108
115
|
eventSignal: "paymentUpdated",
|
|
109
|
-
bankPayment: p,
|
|
116
|
+
bankPayment: p.parsed,
|
|
110
117
|
metadata: {
|
|
111
|
-
correlationId: p.correlationId,
|
|
112
|
-
entityId: p.id,
|
|
113
|
-
idempotencySuffix: p.status,
|
|
118
|
+
correlationId: p.parsed.correlationId,
|
|
119
|
+
entityId: p.parsed.id,
|
|
120
|
+
idempotencySuffix: p.parsed.status,
|
|
114
121
|
timestamp: (/* @__PURE__ */ new Date()).toDateString()
|
|
115
122
|
}
|
|
116
123
|
}))
|
|
117
124
|
);
|
|
118
125
|
const createCommands = paymentsToCreate.map(
|
|
119
|
-
(p) => createPaymentCommand(db, { payment: p }).command
|
|
126
|
+
(p) => createPaymentCommand(db, { payment: p.parsed }).command
|
|
120
127
|
);
|
|
121
128
|
eventsToEmit.push(
|
|
122
129
|
...paymentsToCreate.map((p) => ({
|
|
123
130
|
eventType: "BANK_PAYMENT",
|
|
124
131
|
eventSignal: "paymentCreated",
|
|
125
|
-
bankPayment: p,
|
|
132
|
+
bankPayment: p.parsed,
|
|
126
133
|
metadata: {
|
|
127
|
-
correlationId: p.correlationId,
|
|
128
|
-
entityId: p.id,
|
|
134
|
+
correlationId: p.parsed.correlationId,
|
|
135
|
+
entityId: p.parsed.id,
|
|
129
136
|
timestamp: (/* @__PURE__ */ new Date()).toDateString()
|
|
130
137
|
}
|
|
131
138
|
}))
|
|
132
139
|
);
|
|
133
140
|
const latest = payments.reduce((current, p) => {
|
|
134
|
-
return new Date(p.processedAt).getTime() > new Date(current.processedAt).getTime() ? p : current;
|
|
141
|
+
return new Date(p.parsed.processedAt).getTime() > new Date(current.parsed.processedAt).getTime() ? p : current;
|
|
135
142
|
}, payments[0]);
|
|
136
143
|
const updateLastSyncCommand = updateAccountLastSyncCommand(db, {
|
|
137
144
|
accountId: account.id,
|
|
138
|
-
lastSyncedAt: latest.processedAt
|
|
145
|
+
lastSyncedAt: latest.parsed.processedAt
|
|
139
146
|
}).command;
|
|
140
147
|
if (eventsToEmit.length) {
|
|
141
148
|
await db.batch(
|
|
@@ -155,7 +162,7 @@ class SyncAccountPaymentsWorkflow extends WorkflowEntrypoint {
|
|
|
155
162
|
updated: paymentsToUpdate.length,
|
|
156
163
|
created: paymentsToCreate.length,
|
|
157
164
|
eventsEmitted: eventsToEmit.length,
|
|
158
|
-
lastSyncedAt: latest?.createdAt
|
|
165
|
+
lastSyncedAt: latest?.parsed?.createdAt
|
|
159
166
|
};
|
|
160
167
|
});
|
|
161
168
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Environment } from '@develit-io/backend-sdk';
|
|
2
2
|
import { DrizzleD1Database } from 'drizzle-orm/d1';
|
|
3
|
-
import { a as PaymentInsertType, t as tables } from './bank.
|
|
3
|
+
import { a as PaymentInsertType, t as tables, b as ParsedBankPayment } from './bank.BGZYksmV.js';
|
|
4
4
|
import { CURRENCY_CODES, BANK_CODES, CODES } from '@develit-io/general-codes';
|
|
5
5
|
import { z } from 'zod';
|
|
6
6
|
import * as drizzle_zod from 'drizzle-zod';
|
|
@@ -114,7 +114,7 @@ declare abstract class IBankConnector {
|
|
|
114
114
|
dateFrom: Date;
|
|
115
115
|
dateTo?: Date;
|
|
116
116
|
};
|
|
117
|
-
}): Promise<
|
|
117
|
+
}): Promise<ParsedBankPayment[]>;
|
|
118
118
|
abstract getPaymentStatus({ paymentId, }: {
|
|
119
119
|
paymentId: string;
|
|
120
120
|
}): Promise<PaymentStatus>;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
const database_schema = require('./bank.
|
|
3
|
+
const database_schema = require('./bank.NAgd77sr.cjs');
|
|
4
4
|
const drizzleOrm = require('drizzle-orm');
|
|
5
|
-
const mockCobs_connector = require('./bank.
|
|
5
|
+
const mockCobs_connector = require('./bank.DhuHP2ky.cjs');
|
|
6
6
|
require('jose');
|
|
7
7
|
require('@develit-io/general-codes');
|
|
8
8
|
|
|
@@ -36,10 +36,6 @@ const getCredentialsByAccountId = async (db, { accountId }) => {
|
|
|
36
36
|
return cred;
|
|
37
37
|
};
|
|
38
38
|
|
|
39
|
-
const getPaymentsByBankRefIdsQuery = async (db, { ids }) => {
|
|
40
|
-
return await db.select().from(database_schema.tables.payment).where(drizzleOrm.inArray(database_schema.tables.payment.bankRefId, ids));
|
|
41
|
-
};
|
|
42
|
-
|
|
43
39
|
class CreditasConnector extends database_schema.FinbricksConnector {
|
|
44
40
|
constructor(config) {
|
|
45
41
|
super("CREDITAS", config);
|
|
@@ -114,7 +110,6 @@ const initiateConnector = ({
|
|
|
114
110
|
|
|
115
111
|
exports.createPaymentCommand = createPaymentCommand;
|
|
116
112
|
exports.getCredentialsByAccountId = getCredentialsByAccountId;
|
|
117
|
-
exports.getPaymentsByBankRefIdsQuery = getPaymentsByBankRefIdsQuery;
|
|
118
113
|
exports.initiateConnector = initiateConnector;
|
|
119
114
|
exports.updateAccountLastSyncCommand = updateAccountLastSyncCommand;
|
|
120
115
|
exports.updatePaymentCommand = updatePaymentCommand;
|
|
@@ -12,6 +12,10 @@ interface BatchSelectType extends InferSelectModel<typeof tables.batch> {
|
|
|
12
12
|
}
|
|
13
13
|
interface BatchInsertType extends InferInsertModel<typeof tables.batch> {
|
|
14
14
|
}
|
|
15
|
+
type ParsedBankPayment = {
|
|
16
|
+
raw: object;
|
|
17
|
+
parsed: PaymentInsertType;
|
|
18
|
+
};
|
|
15
19
|
declare const paymentInsertTypeZod: z.ZodObject<{
|
|
16
20
|
refId: z.ZodString;
|
|
17
21
|
bankRefId: z.ZodString;
|
|
@@ -83,10 +87,10 @@ declare const paymentInsertTypeZod: z.ZodObject<{
|
|
|
83
87
|
}>;
|
|
84
88
|
status: z.ZodEnum<{
|
|
85
89
|
PREPARED: "PREPARED";
|
|
86
|
-
|
|
90
|
+
COMPLETED: "COMPLETED";
|
|
87
91
|
FAILED: "FAILED";
|
|
92
|
+
INITIALIZED: "INITIALIZED";
|
|
88
93
|
PENDING: "PENDING";
|
|
89
|
-
COMPLETED: "COMPLETED";
|
|
90
94
|
CREATED: "CREATED";
|
|
91
95
|
}>;
|
|
92
96
|
batchId: z.ZodString;
|
|
@@ -166,7 +170,7 @@ declare const batch: drizzle_orm_sqlite_core.SQLiteTableWithColumns<{
|
|
|
166
170
|
tableName: "batch";
|
|
167
171
|
dataType: "string";
|
|
168
172
|
columnType: "SQLiteText";
|
|
169
|
-
data: "
|
|
173
|
+
data: "OPEN" | "PROCESSING" | "READY_TO_SIGN" | "WAITING_FOR_PROCESSING" | "PREPARED" | "COMPLETED" | "FAILED";
|
|
170
174
|
driverParam: string;
|
|
171
175
|
notNull: false;
|
|
172
176
|
hasDefault: false;
|
|
@@ -179,7 +183,7 @@ declare const batch: drizzle_orm_sqlite_core.SQLiteTableWithColumns<{
|
|
|
179
183
|
generated: undefined;
|
|
180
184
|
}, {}, {
|
|
181
185
|
length: number | undefined;
|
|
182
|
-
$type: "
|
|
186
|
+
$type: "OPEN" | "PROCESSING" | "READY_TO_SIGN" | "WAITING_FOR_PROCESSING" | "PREPARED" | "COMPLETED" | "FAILED";
|
|
183
187
|
}>;
|
|
184
188
|
payments: drizzle_orm_sqlite_core.SQLiteColumn<{
|
|
185
189
|
name: "payments";
|
|
@@ -475,7 +479,7 @@ declare const payment: drizzle_orm_sqlite_core.SQLiteTableWithColumns<{
|
|
|
475
479
|
tableName: "payment";
|
|
476
480
|
dataType: "string";
|
|
477
481
|
columnType: "SQLiteText";
|
|
478
|
-
data: "PREPARED" | "
|
|
482
|
+
data: "PREPARED" | "COMPLETED" | "FAILED" | "INITIALIZED" | "PENDING" | "CREATED";
|
|
479
483
|
driverParam: string;
|
|
480
484
|
notNull: true;
|
|
481
485
|
hasDefault: false;
|
|
@@ -488,7 +492,7 @@ declare const payment: drizzle_orm_sqlite_core.SQLiteTableWithColumns<{
|
|
|
488
492
|
generated: undefined;
|
|
489
493
|
}, {}, {
|
|
490
494
|
length: number | undefined;
|
|
491
|
-
$type: "PREPARED" | "
|
|
495
|
+
$type: "PREPARED" | "COMPLETED" | "FAILED" | "INITIALIZED" | "PENDING" | "CREATED";
|
|
492
496
|
}>;
|
|
493
497
|
statusReason: drizzle_orm_sqlite_core.SQLiteColumn<{
|
|
494
498
|
name: "status_reason";
|
|
@@ -1590,5 +1594,5 @@ declare namespace schema {
|
|
|
1590
1594
|
|
|
1591
1595
|
declare const tables: typeof schema;
|
|
1592
1596
|
|
|
1593
|
-
export { batch as
|
|
1594
|
-
export type { BatchSelectType as B, PaymentSelectType as P, PaymentInsertType as a,
|
|
1597
|
+
export { batch as d, payment as e, paymentRelations as f, account as g, accountCredentials as h, ott as o, paymentInsertTypeZod as p, tables as t };
|
|
1598
|
+
export type { BatchSelectType as B, PaymentSelectType as P, PaymentInsertType as a, ParsedBankPayment as b, BatchInsertType as c };
|
|
@@ -12,6 +12,10 @@ interface BatchSelectType extends InferSelectModel<typeof tables.batch> {
|
|
|
12
12
|
}
|
|
13
13
|
interface BatchInsertType extends InferInsertModel<typeof tables.batch> {
|
|
14
14
|
}
|
|
15
|
+
type ParsedBankPayment = {
|
|
16
|
+
raw: object;
|
|
17
|
+
parsed: PaymentInsertType;
|
|
18
|
+
};
|
|
15
19
|
declare const paymentInsertTypeZod: z.ZodObject<{
|
|
16
20
|
refId: z.ZodString;
|
|
17
21
|
bankRefId: z.ZodString;
|
|
@@ -83,10 +87,10 @@ declare const paymentInsertTypeZod: z.ZodObject<{
|
|
|
83
87
|
}>;
|
|
84
88
|
status: z.ZodEnum<{
|
|
85
89
|
PREPARED: "PREPARED";
|
|
86
|
-
|
|
90
|
+
COMPLETED: "COMPLETED";
|
|
87
91
|
FAILED: "FAILED";
|
|
92
|
+
INITIALIZED: "INITIALIZED";
|
|
88
93
|
PENDING: "PENDING";
|
|
89
|
-
COMPLETED: "COMPLETED";
|
|
90
94
|
CREATED: "CREATED";
|
|
91
95
|
}>;
|
|
92
96
|
batchId: z.ZodString;
|
|
@@ -166,7 +170,7 @@ declare const batch: drizzle_orm_sqlite_core.SQLiteTableWithColumns<{
|
|
|
166
170
|
tableName: "batch";
|
|
167
171
|
dataType: "string";
|
|
168
172
|
columnType: "SQLiteText";
|
|
169
|
-
data: "
|
|
173
|
+
data: "OPEN" | "PROCESSING" | "READY_TO_SIGN" | "WAITING_FOR_PROCESSING" | "PREPARED" | "COMPLETED" | "FAILED";
|
|
170
174
|
driverParam: string;
|
|
171
175
|
notNull: false;
|
|
172
176
|
hasDefault: false;
|
|
@@ -179,7 +183,7 @@ declare const batch: drizzle_orm_sqlite_core.SQLiteTableWithColumns<{
|
|
|
179
183
|
generated: undefined;
|
|
180
184
|
}, {}, {
|
|
181
185
|
length: number | undefined;
|
|
182
|
-
$type: "
|
|
186
|
+
$type: "OPEN" | "PROCESSING" | "READY_TO_SIGN" | "WAITING_FOR_PROCESSING" | "PREPARED" | "COMPLETED" | "FAILED";
|
|
183
187
|
}>;
|
|
184
188
|
payments: drizzle_orm_sqlite_core.SQLiteColumn<{
|
|
185
189
|
name: "payments";
|
|
@@ -475,7 +479,7 @@ declare const payment: drizzle_orm_sqlite_core.SQLiteTableWithColumns<{
|
|
|
475
479
|
tableName: "payment";
|
|
476
480
|
dataType: "string";
|
|
477
481
|
columnType: "SQLiteText";
|
|
478
|
-
data: "PREPARED" | "
|
|
482
|
+
data: "PREPARED" | "COMPLETED" | "FAILED" | "INITIALIZED" | "PENDING" | "CREATED";
|
|
479
483
|
driverParam: string;
|
|
480
484
|
notNull: true;
|
|
481
485
|
hasDefault: false;
|
|
@@ -488,7 +492,7 @@ declare const payment: drizzle_orm_sqlite_core.SQLiteTableWithColumns<{
|
|
|
488
492
|
generated: undefined;
|
|
489
493
|
}, {}, {
|
|
490
494
|
length: number | undefined;
|
|
491
|
-
$type: "PREPARED" | "
|
|
495
|
+
$type: "PREPARED" | "COMPLETED" | "FAILED" | "INITIALIZED" | "PENDING" | "CREATED";
|
|
492
496
|
}>;
|
|
493
497
|
statusReason: drizzle_orm_sqlite_core.SQLiteColumn<{
|
|
494
498
|
name: "status_reason";
|
|
@@ -1590,5 +1594,5 @@ declare namespace schema {
|
|
|
1590
1594
|
|
|
1591
1595
|
declare const tables: typeof schema;
|
|
1592
1596
|
|
|
1593
|
-
export { batch as
|
|
1594
|
-
export type { BatchSelectType as B, PaymentSelectType as P, PaymentInsertType as a,
|
|
1597
|
+
export { batch as d, payment as e, paymentRelations as f, account as g, accountCredentials as h, ott as o, paymentInsertTypeZod as p, tables as t };
|
|
1598
|
+
export type { BatchSelectType as B, PaymentSelectType as P, PaymentInsertType as a, ParsedBankPayment as b, BatchInsertType as c };
|
|
@@ -12,6 +12,10 @@ interface BatchSelectType extends InferSelectModel<typeof tables.batch> {
|
|
|
12
12
|
}
|
|
13
13
|
interface BatchInsertType extends InferInsertModel<typeof tables.batch> {
|
|
14
14
|
}
|
|
15
|
+
type ParsedBankPayment = {
|
|
16
|
+
raw: object;
|
|
17
|
+
parsed: PaymentInsertType;
|
|
18
|
+
};
|
|
15
19
|
declare const paymentInsertTypeZod: z.ZodObject<{
|
|
16
20
|
refId: z.ZodString;
|
|
17
21
|
bankRefId: z.ZodString;
|
|
@@ -83,10 +87,10 @@ declare const paymentInsertTypeZod: z.ZodObject<{
|
|
|
83
87
|
}>;
|
|
84
88
|
status: z.ZodEnum<{
|
|
85
89
|
PREPARED: "PREPARED";
|
|
86
|
-
|
|
90
|
+
COMPLETED: "COMPLETED";
|
|
87
91
|
FAILED: "FAILED";
|
|
92
|
+
INITIALIZED: "INITIALIZED";
|
|
88
93
|
PENDING: "PENDING";
|
|
89
|
-
COMPLETED: "COMPLETED";
|
|
90
94
|
CREATED: "CREATED";
|
|
91
95
|
}>;
|
|
92
96
|
batchId: z.ZodString;
|
|
@@ -166,7 +170,7 @@ declare const batch: drizzle_orm_sqlite_core.SQLiteTableWithColumns<{
|
|
|
166
170
|
tableName: "batch";
|
|
167
171
|
dataType: "string";
|
|
168
172
|
columnType: "SQLiteText";
|
|
169
|
-
data: "
|
|
173
|
+
data: "OPEN" | "PROCESSING" | "READY_TO_SIGN" | "WAITING_FOR_PROCESSING" | "PREPARED" | "COMPLETED" | "FAILED";
|
|
170
174
|
driverParam: string;
|
|
171
175
|
notNull: false;
|
|
172
176
|
hasDefault: false;
|
|
@@ -179,7 +183,7 @@ declare const batch: drizzle_orm_sqlite_core.SQLiteTableWithColumns<{
|
|
|
179
183
|
generated: undefined;
|
|
180
184
|
}, {}, {
|
|
181
185
|
length: number | undefined;
|
|
182
|
-
$type: "
|
|
186
|
+
$type: "OPEN" | "PROCESSING" | "READY_TO_SIGN" | "WAITING_FOR_PROCESSING" | "PREPARED" | "COMPLETED" | "FAILED";
|
|
183
187
|
}>;
|
|
184
188
|
payments: drizzle_orm_sqlite_core.SQLiteColumn<{
|
|
185
189
|
name: "payments";
|
|
@@ -475,7 +479,7 @@ declare const payment: drizzle_orm_sqlite_core.SQLiteTableWithColumns<{
|
|
|
475
479
|
tableName: "payment";
|
|
476
480
|
dataType: "string";
|
|
477
481
|
columnType: "SQLiteText";
|
|
478
|
-
data: "PREPARED" | "
|
|
482
|
+
data: "PREPARED" | "COMPLETED" | "FAILED" | "INITIALIZED" | "PENDING" | "CREATED";
|
|
479
483
|
driverParam: string;
|
|
480
484
|
notNull: true;
|
|
481
485
|
hasDefault: false;
|
|
@@ -488,7 +492,7 @@ declare const payment: drizzle_orm_sqlite_core.SQLiteTableWithColumns<{
|
|
|
488
492
|
generated: undefined;
|
|
489
493
|
}, {}, {
|
|
490
494
|
length: number | undefined;
|
|
491
|
-
$type: "PREPARED" | "
|
|
495
|
+
$type: "PREPARED" | "COMPLETED" | "FAILED" | "INITIALIZED" | "PENDING" | "CREATED";
|
|
492
496
|
}>;
|
|
493
497
|
statusReason: drizzle_orm_sqlite_core.SQLiteColumn<{
|
|
494
498
|
name: "status_reason";
|
|
@@ -1590,5 +1594,5 @@ declare namespace schema {
|
|
|
1590
1594
|
|
|
1591
1595
|
declare const tables: typeof schema;
|
|
1592
1596
|
|
|
1593
|
-
export { batch as
|
|
1594
|
-
export type { BatchSelectType as B, PaymentSelectType as P, PaymentInsertType as a,
|
|
1597
|
+
export { batch as d, payment as e, paymentRelations as f, account as g, accountCredentials as h, ott as o, paymentInsertTypeZod as p, tables as t };
|
|
1598
|
+
export type { BatchSelectType as B, PaymentSelectType as P, PaymentInsertType as a, ParsedBankPayment as b, BatchInsertType as c };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Environment } from '@develit-io/backend-sdk';
|
|
2
2
|
import { DrizzleD1Database } from 'drizzle-orm/d1';
|
|
3
|
-
import { a as PaymentInsertType, t as tables } from './bank.
|
|
3
|
+
import { a as PaymentInsertType, t as tables, b as ParsedBankPayment } from './bank.BGZYksmV.mjs';
|
|
4
4
|
import { CURRENCY_CODES, BANK_CODES, CODES } from '@develit-io/general-codes';
|
|
5
5
|
import { z } from 'zod';
|
|
6
6
|
import * as drizzle_zod from 'drizzle-zod';
|
|
@@ -114,7 +114,7 @@ declare abstract class IBankConnector {
|
|
|
114
114
|
dateFrom: Date;
|
|
115
115
|
dateTo?: Date;
|
|
116
116
|
};
|
|
117
|
-
}): Promise<
|
|
117
|
+
}): Promise<ParsedBankPayment[]>;
|
|
118
118
|
abstract getPaymentStatus({ paymentId, }: {
|
|
119
119
|
paymentId: string;
|
|
120
120
|
}): Promise<PaymentStatus>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { t as tables, F as FinbricksConnector, M as MockConnector, E as ErsteConnector } from './bank.
|
|
2
|
-
import { eq
|
|
3
|
-
import { M as MockCobsConnector } from './bank.
|
|
1
|
+
import { t as tables, F as FinbricksConnector, M as MockConnector, E as ErsteConnector } from './bank.DdvSjgls.mjs';
|
|
2
|
+
import { eq } from 'drizzle-orm';
|
|
3
|
+
import { M as MockCobsConnector } from './bank.BcDo3cbz.mjs';
|
|
4
4
|
import 'jose';
|
|
5
5
|
import '@develit-io/general-codes';
|
|
6
6
|
|
|
@@ -34,10 +34,6 @@ const getCredentialsByAccountId = async (db, { accountId }) => {
|
|
|
34
34
|
return cred;
|
|
35
35
|
};
|
|
36
36
|
|
|
37
|
-
const getPaymentsByBankRefIdsQuery = async (db, { ids }) => {
|
|
38
|
-
return await db.select().from(tables.payment).where(inArray(tables.payment.bankRefId, ids));
|
|
39
|
-
};
|
|
40
|
-
|
|
41
37
|
class CreditasConnector extends FinbricksConnector {
|
|
42
38
|
constructor(config) {
|
|
43
39
|
super("CREDITAS", config);
|
|
@@ -110,4 +106,4 @@ const initiateConnector = ({
|
|
|
110
106
|
}
|
|
111
107
|
};
|
|
112
108
|
|
|
113
|
-
export {
|
|
109
|
+
export { updateAccountLastSyncCommand as a, createPaymentCommand as c, getCredentialsByAccountId as g, initiateConnector as i, updatePaymentCommand as u };
|
|
@@ -196,7 +196,7 @@ const mapFinbricksAccountInsert = ({
|
|
|
196
196
|
});
|
|
197
197
|
|
|
198
198
|
const mapFinbricksTransactionToPayment = (tx, account) => {
|
|
199
|
-
const isIncoming = tx.creditDebitIndicator
|
|
199
|
+
const isIncoming = tx.creditDebitIndicator !== "DBIT";
|
|
200
200
|
const related = tx.entryDetails?.transactionDetails?.relatedParties;
|
|
201
201
|
const base = {
|
|
202
202
|
id: uuidv4(),
|
|
@@ -215,7 +215,7 @@ const mapFinbricksTransactionToPayment = (tx, account) => {
|
|
|
215
215
|
tx.entryDetails.transactionDetails?.remittanceInformation?.structured?.creditorReferenceInformation?.reference || tx.entryDetails.transactionDetails?.references?.endToEndIdentification
|
|
216
216
|
),
|
|
217
217
|
creditor: {
|
|
218
|
-
holderName: related?.creditor?.name || "Unknown",
|
|
218
|
+
holderName: related?.creditorAccount?.name || related?.creditor?.name || "Unknown",
|
|
219
219
|
iban: isIncoming ? account.iban || void 0 : related.creditorAccount?.identification?.iban || account.iban || void 0,
|
|
220
220
|
number: isIncoming ? account.number || void 0 : related.creditorAccount?.identification?.other?.identification ? related.creditorAccount.identification.other.identification.split(
|
|
221
221
|
"/"
|
|
@@ -225,7 +225,7 @@ const mapFinbricksTransactionToPayment = (tx, account) => {
|
|
|
225
225
|
)[1] : account.bankCode || void 0
|
|
226
226
|
},
|
|
227
227
|
debtor: {
|
|
228
|
-
holderName: related?.debtor?.name || "Unknown",
|
|
228
|
+
holderName: related?.debtorAccount?.name || related?.debtor?.name || "Unknown",
|
|
229
229
|
iban: isIncoming ? related.debtorAccount?.identification?.iban || account.iban || void 0 : account.iban ?? void 0,
|
|
230
230
|
number: isIncoming ? related.debtorAccount?.identification?.other?.identification ? related.debtorAccount.identification.other.identification.split(
|
|
231
231
|
"/"
|
|
@@ -662,7 +662,10 @@ class FinbricksConnector extends IBankConnector {
|
|
|
662
662
|
cursor = links?.[0]?.value || null;
|
|
663
663
|
if (transactions) {
|
|
664
664
|
for (const tx of transactions) {
|
|
665
|
-
allPayments.push(
|
|
665
|
+
allPayments.push({
|
|
666
|
+
raw: tx,
|
|
667
|
+
parsed: mapFinbricksTransactionToPayment(tx, account)
|
|
668
|
+
});
|
|
666
669
|
}
|
|
667
670
|
}
|
|
668
671
|
} while (cursor != null);
|
|
@@ -998,8 +1001,11 @@ class ErsteConnector extends IBankConnector {
|
|
|
998
1001
|
status: "COMPLETED"
|
|
999
1002
|
};
|
|
1000
1003
|
return {
|
|
1001
|
-
|
|
1002
|
-
|
|
1004
|
+
raw: payment,
|
|
1005
|
+
parsed: {
|
|
1006
|
+
...paymentInsert,
|
|
1007
|
+
direction: account.iban ? getPaymentDirection(paymentInsert, account.iban) : "INCOMING"
|
|
1008
|
+
}
|
|
1003
1009
|
};
|
|
1004
1010
|
});
|
|
1005
1011
|
return payments;
|
|
@@ -1090,8 +1096,11 @@ class MockConnector extends IBankConnector {
|
|
|
1090
1096
|
)
|
|
1091
1097
|
);
|
|
1092
1098
|
return payments.map((payment) => ({
|
|
1093
|
-
|
|
1094
|
-
|
|
1099
|
+
raw: payment,
|
|
1100
|
+
parsed: {
|
|
1101
|
+
...payment,
|
|
1102
|
+
status: "COMPLETED"
|
|
1103
|
+
}
|
|
1095
1104
|
}));
|
|
1096
1105
|
}
|
|
1097
1106
|
getPaymentStatus(_) {
|