@develit-services/bank 0.7.8 → 0.7.10
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 +2 -2
- package/dist/database/schema.d.cts +2 -2
- package/dist/database/schema.d.mts +2 -2
- package/dist/database/schema.d.ts +2 -2
- package/dist/database/schema.mjs +2 -2
- package/dist/export/worker.cjs +15 -40
- package/dist/export/worker.d.cts +12 -10
- package/dist/export/worker.d.mts +12 -10
- package/dist/export/worker.d.ts +12 -10
- package/dist/export/worker.mjs +15 -40
- package/dist/export/workflows.cjs +13 -47
- package/dist/export/workflows.mjs +13 -47
- package/dist/shared/{bank.Vm9IO_UH.d.cts → bank.0qpz9IIt.d.cts} +273 -267
- package/dist/shared/{bank.Vm9IO_UH.d.mts → bank.0qpz9IIt.d.mts} +273 -267
- package/dist/shared/{bank.Vm9IO_UH.d.ts → bank.0qpz9IIt.d.ts} +273 -267
- package/dist/shared/{bank.PB07ttj3.mjs → bank.993UA65l.mjs} +3 -2
- package/dist/shared/{bank.AEdMloQz.cjs → bank.Bs7mkXbR.cjs} +13 -4
- package/dist/shared/{bank.BVRO97AQ.mjs → bank.CGIeLo8U.mjs} +13 -4
- package/dist/shared/{bank.kYaMR0UG.cjs → bank.Ce-NBBw1.cjs} +140 -92
- package/dist/shared/{bank.CCQB8FnG.mjs → bank.CeRbuycV.mjs} +141 -94
- package/dist/shared/{bank.Bz8-M6O4.cjs → bank.Cp0yvOdq.cjs} +1 -1
- package/dist/shared/{bank.DgGri2Wr.cjs → bank.IVhZ_RlH.cjs} +3 -2
- package/dist/shared/{bank.I0pR4Me2.mjs → bank.fIGTiPnp.mjs} +1 -1
- package/dist/types.cjs +3 -2
- package/dist/types.d.cts +158 -150
- package/dist/types.d.mts +158 -150
- package/dist/types.d.ts +158 -150
- package/dist/types.mjs +2 -2
- package/package.json +1 -1
|
@@ -1,22 +1,22 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
const backendSdk = require('@develit-io/backend-sdk');
|
|
4
|
-
const drizzle = require('../shared/bank.
|
|
4
|
+
const drizzle = require('../shared/bank.Bs7mkXbR.cjs');
|
|
5
5
|
const batchLifecycle = require('../shared/bank.Bg3Pdwm4.cjs');
|
|
6
|
-
const mock_connector = require('../shared/bank.
|
|
6
|
+
const mock_connector = require('../shared/bank.Ce-NBBw1.cjs');
|
|
7
7
|
const drizzleOrm = require('drizzle-orm');
|
|
8
8
|
const cloudflare_workers = require('cloudflare:workers');
|
|
9
9
|
const cloudflare_workflows = require('cloudflare:workflows');
|
|
10
10
|
const d1 = require('drizzle-orm/d1');
|
|
11
|
-
require('
|
|
12
|
-
require('../shared/bank.
|
|
11
|
+
require('node:crypto');
|
|
12
|
+
require('../shared/bank.IVhZ_RlH.cjs');
|
|
13
13
|
require('drizzle-orm/relations');
|
|
14
14
|
require('drizzle-orm/sqlite-core');
|
|
15
15
|
require('date-fns');
|
|
16
|
-
require('@develit-io/general-codes');
|
|
17
16
|
require('jose');
|
|
18
|
-
require('
|
|
17
|
+
require('@develit-io/general-codes');
|
|
19
18
|
require('drizzle-zod');
|
|
19
|
+
require('../shared/bank.Cp0yvOdq.cjs');
|
|
20
20
|
|
|
21
21
|
const updateAccountLastSyncCommand = (db, {
|
|
22
22
|
lastSyncAt,
|
|
@@ -98,32 +98,15 @@ class BankProcessBatch extends cloudflare_workers.WorkflowEntrypoint {
|
|
|
98
98
|
if (!account) {
|
|
99
99
|
throw new cloudflare_workflows.NonRetryableError(`Account not found: ${batch.accountId}`);
|
|
100
100
|
}
|
|
101
|
-
const
|
|
102
|
-
(await this.env.SECRETS_STORE.get({
|
|
103
|
-
secretName: "BANK_SERVICE_ENCRYPTION_KEY"
|
|
104
|
-
})).data?.secretValue || ""
|
|
105
|
-
);
|
|
106
|
-
const credentials = await drizzle.getCredentialsByAccountId(db, encryptionKey, {
|
|
107
|
-
accountId: account.id
|
|
108
|
-
});
|
|
109
|
-
if (!credentials) {
|
|
110
|
-
throw new cloudflare_workflows.NonRetryableError(
|
|
111
|
-
`No credentials found for account: ${account.id}`
|
|
112
|
-
);
|
|
113
|
-
}
|
|
114
|
-
if (credentials.expiresAt < /* @__PURE__ */ new Date()) {
|
|
115
|
-
throw new cloudflare_workflows.NonRetryableError(
|
|
116
|
-
`Credentials have expired for account: ${account.id}`
|
|
117
|
-
);
|
|
118
|
-
}
|
|
101
|
+
const resolveCredentials = await drizzle.createCredentialsResolver(db, this.env);
|
|
119
102
|
const connector = await mock_connector.initiateConnector({
|
|
120
103
|
env: this.env,
|
|
121
104
|
bank: account.connectorKey,
|
|
105
|
+
resolveCredentials,
|
|
122
106
|
connectedAccounts: [
|
|
123
107
|
{
|
|
124
108
|
...account,
|
|
125
|
-
iban: account.iban
|
|
126
|
-
token: credentials.value
|
|
109
|
+
iban: account.iban
|
|
127
110
|
}
|
|
128
111
|
]
|
|
129
112
|
});
|
|
@@ -283,7 +266,6 @@ class BankSyncAccountPayments extends cloudflare_workers.WorkflowEntrypoint {
|
|
|
283
266
|
if (!account.lastSyncAt) {
|
|
284
267
|
throw new Error(`lastSyncedAt is not set for account: ${accountId}`);
|
|
285
268
|
}
|
|
286
|
-
//! ### This step is currently inside the fetch payments step with retries due to cf workflows output logs (until they allow hiding sensitive data) <-----
|
|
287
269
|
const payments = await step.do(
|
|
288
270
|
"fetch bank payments",
|
|
289
271
|
{
|
|
@@ -291,34 +273,18 @@ class BankSyncAccountPayments extends cloudflare_workers.WorkflowEntrypoint {
|
|
|
291
273
|
timeout: "30 seconds"
|
|
292
274
|
},
|
|
293
275
|
async () => {
|
|
294
|
-
const
|
|
295
|
-
(await this.env.SECRETS_STORE.get({
|
|
296
|
-
secretName: "BANK_SERVICE_ENCRYPTION_KEY"
|
|
297
|
-
})).data?.secretValue || ""
|
|
298
|
-
);
|
|
299
|
-
const credentials = await drizzle.getCredentialsByAccountId(
|
|
276
|
+
const resolveCredentials = await drizzle.createCredentialsResolver(
|
|
300
277
|
db,
|
|
301
|
-
|
|
302
|
-
{ accountId }
|
|
278
|
+
this.env
|
|
303
279
|
);
|
|
304
|
-
if (!credentials) {
|
|
305
|
-
throw new cloudflare_workflows.NonRetryableError(
|
|
306
|
-
`No credentials found for account: ${accountId}`
|
|
307
|
-
);
|
|
308
|
-
}
|
|
309
|
-
if (credentials.expiresAt < /* @__PURE__ */ new Date()) {
|
|
310
|
-
throw new cloudflare_workflows.NonRetryableError(
|
|
311
|
-
`Credentials have expired for account: ${accountId}`
|
|
312
|
-
);
|
|
313
|
-
}
|
|
314
280
|
const connector = await mock_connector.initiateConnector({
|
|
315
281
|
env: this.env,
|
|
316
282
|
bank: account.connectorKey,
|
|
283
|
+
resolveCredentials,
|
|
317
284
|
connectedAccounts: [
|
|
318
285
|
{
|
|
319
286
|
...account,
|
|
320
|
-
iban: account.iban
|
|
321
|
-
token: credentials.value
|
|
287
|
+
iban: account.iban
|
|
322
288
|
}
|
|
323
289
|
]
|
|
324
290
|
});
|
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
import { first, uuidv4, asNonEmpty } from '@develit-io/backend-sdk';
|
|
2
|
-
import { t as tables, g as getBatchByIdQuery, c as checksum, u as upsertBatchCommand, a as getAccountByIdQuery,
|
|
2
|
+
import { t as tables, g as getBatchByIdQuery, c as checksum, u as upsertBatchCommand, a as getAccountByIdQuery, b as createCredentialsResolver, d as createPaymentCommand } from '../shared/bank.CGIeLo8U.mjs';
|
|
3
3
|
import { f as isBatchSigned, a as isBatchFailed, c as isBatchOpen, g as isPaymentCompleted } from '../shared/bank.CbAwwIhZ.mjs';
|
|
4
|
-
import { h as toPreparedPayment, i as initiateConnector, f as toCompletedPayment } from '../shared/bank.
|
|
4
|
+
import { h as toPreparedPayment, i as initiateConnector, f as toCompletedPayment } from '../shared/bank.CeRbuycV.mjs';
|
|
5
5
|
import { eq } from 'drizzle-orm';
|
|
6
6
|
import { WorkflowEntrypoint } from 'cloudflare:workers';
|
|
7
7
|
import { NonRetryableError } from 'cloudflare:workflows';
|
|
8
8
|
import { drizzle } from 'drizzle-orm/d1';
|
|
9
|
-
import '
|
|
10
|
-
import '../shared/bank.
|
|
9
|
+
import 'node:crypto';
|
|
10
|
+
import '../shared/bank.993UA65l.mjs';
|
|
11
11
|
import 'drizzle-orm/relations';
|
|
12
12
|
import 'drizzle-orm/sqlite-core';
|
|
13
13
|
import 'date-fns';
|
|
14
|
-
import '@develit-io/general-codes';
|
|
15
14
|
import 'jose';
|
|
16
|
-
import '
|
|
15
|
+
import '@develit-io/general-codes';
|
|
17
16
|
import 'drizzle-zod';
|
|
17
|
+
import '../shared/bank.fIGTiPnp.mjs';
|
|
18
18
|
|
|
19
19
|
const updateAccountLastSyncCommand = (db, {
|
|
20
20
|
lastSyncAt,
|
|
@@ -96,32 +96,15 @@ class BankProcessBatch extends WorkflowEntrypoint {
|
|
|
96
96
|
if (!account) {
|
|
97
97
|
throw new NonRetryableError(`Account not found: ${batch.accountId}`);
|
|
98
98
|
}
|
|
99
|
-
const
|
|
100
|
-
(await this.env.SECRETS_STORE.get({
|
|
101
|
-
secretName: "BANK_SERVICE_ENCRYPTION_KEY"
|
|
102
|
-
})).data?.secretValue || ""
|
|
103
|
-
);
|
|
104
|
-
const credentials = await getCredentialsByAccountId(db, encryptionKey, {
|
|
105
|
-
accountId: account.id
|
|
106
|
-
});
|
|
107
|
-
if (!credentials) {
|
|
108
|
-
throw new NonRetryableError(
|
|
109
|
-
`No credentials found for account: ${account.id}`
|
|
110
|
-
);
|
|
111
|
-
}
|
|
112
|
-
if (credentials.expiresAt < /* @__PURE__ */ new Date()) {
|
|
113
|
-
throw new NonRetryableError(
|
|
114
|
-
`Credentials have expired for account: ${account.id}`
|
|
115
|
-
);
|
|
116
|
-
}
|
|
99
|
+
const resolveCredentials = await createCredentialsResolver(db, this.env);
|
|
117
100
|
const connector = await initiateConnector({
|
|
118
101
|
env: this.env,
|
|
119
102
|
bank: account.connectorKey,
|
|
103
|
+
resolveCredentials,
|
|
120
104
|
connectedAccounts: [
|
|
121
105
|
{
|
|
122
106
|
...account,
|
|
123
|
-
iban: account.iban
|
|
124
|
-
token: credentials.value
|
|
107
|
+
iban: account.iban
|
|
125
108
|
}
|
|
126
109
|
]
|
|
127
110
|
});
|
|
@@ -281,7 +264,6 @@ class BankSyncAccountPayments extends WorkflowEntrypoint {
|
|
|
281
264
|
if (!account.lastSyncAt) {
|
|
282
265
|
throw new Error(`lastSyncedAt is not set for account: ${accountId}`);
|
|
283
266
|
}
|
|
284
|
-
//! ### This step is currently inside the fetch payments step with retries due to cf workflows output logs (until they allow hiding sensitive data) <-----
|
|
285
267
|
const payments = await step.do(
|
|
286
268
|
"fetch bank payments",
|
|
287
269
|
{
|
|
@@ -289,34 +271,18 @@ class BankSyncAccountPayments extends WorkflowEntrypoint {
|
|
|
289
271
|
timeout: "30 seconds"
|
|
290
272
|
},
|
|
291
273
|
async () => {
|
|
292
|
-
const
|
|
293
|
-
(await this.env.SECRETS_STORE.get({
|
|
294
|
-
secretName: "BANK_SERVICE_ENCRYPTION_KEY"
|
|
295
|
-
})).data?.secretValue || ""
|
|
296
|
-
);
|
|
297
|
-
const credentials = await getCredentialsByAccountId(
|
|
274
|
+
const resolveCredentials = await createCredentialsResolver(
|
|
298
275
|
db,
|
|
299
|
-
|
|
300
|
-
{ accountId }
|
|
276
|
+
this.env
|
|
301
277
|
);
|
|
302
|
-
if (!credentials) {
|
|
303
|
-
throw new NonRetryableError(
|
|
304
|
-
`No credentials found for account: ${accountId}`
|
|
305
|
-
);
|
|
306
|
-
}
|
|
307
|
-
if (credentials.expiresAt < /* @__PURE__ */ new Date()) {
|
|
308
|
-
throw new NonRetryableError(
|
|
309
|
-
`Credentials have expired for account: ${accountId}`
|
|
310
|
-
);
|
|
311
|
-
}
|
|
312
278
|
const connector = await initiateConnector({
|
|
313
279
|
env: this.env,
|
|
314
280
|
bank: account.connectorKey,
|
|
281
|
+
resolveCredentials,
|
|
315
282
|
connectedAccounts: [
|
|
316
283
|
{
|
|
317
284
|
...account,
|
|
318
|
-
iban: account.iban
|
|
319
|
-
token: credentials.value
|
|
285
|
+
iban: account.iban
|
|
320
286
|
}
|
|
321
287
|
]
|
|
322
288
|
});
|