@develit-services/bank 0.0.2 → 0.0.4

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.
@@ -0,0 +1,243 @@
1
+ import * as _develit_io_backend_sdk from '@develit-io/backend-sdk';
2
+ import { IRPCResponse } from '@develit-io/backend-sdk';
3
+ import { P as PaymentSelectType, B as BatchSelectType, t as tables, a as PaymentInsertType } from '../shared/bank.CBNQZ5Pd.cjs';
4
+ import { WorkerEntrypoint } from 'cloudflare:workers';
5
+ import { DrizzleD1Database } from 'drizzle-orm/d1';
6
+ import { z } from 'zod';
7
+ import { I as IBankConnector, C as ConfigBankAccount, a as ConnectorKey, B as BankAccountWithLastSync } from '../shared/bank.C28GtA5s.cjs';
8
+ import 'drizzle-orm/sqlite-core';
9
+ import 'drizzle-orm';
10
+ import '@develit-io/general-codes';
11
+
12
+ declare const sendPaymentInputSchema: z.ZodObject<{
13
+ refId: z.ZodString;
14
+ amount: z.ZodNumber;
15
+ paymentType: z.ZodEnum<{
16
+ SEPA: "SEPA";
17
+ SWIFT: "SWIFT";
18
+ IFSC: "IFSC";
19
+ DOMESTIC: "DOMESTIC";
20
+ }>;
21
+ currency: z.ZodEnum<{
22
+ CZK: "CZK";
23
+ EUR: "EUR";
24
+ USD: "USD";
25
+ PLN: "PLN";
26
+ RON: "RON";
27
+ GBP: "GBP";
28
+ RUB: "RUB";
29
+ HUF: "HUF";
30
+ CHF: "CHF";
31
+ DKK: "DKK";
32
+ SEK: "SEK";
33
+ HRK: "HRK";
34
+ NOK: "NOK";
35
+ BGN: "BGN";
36
+ TRY: "TRY";
37
+ AUD: "AUD";
38
+ CAD: "CAD";
39
+ JPY: "JPY";
40
+ CNY: "CNY";
41
+ INR: "INR";
42
+ BRL: "BRL";
43
+ MXN: "MXN";
44
+ ZAR: "ZAR";
45
+ SGD: "SGD";
46
+ HKD: "HKD";
47
+ KRW: "KRW";
48
+ MYR: "MYR";
49
+ THB: "THB";
50
+ IDR: "IDR";
51
+ PHP: "PHP";
52
+ AED: "AED";
53
+ SAR: "SAR";
54
+ ILS: "ILS";
55
+ EGP: "EGP";
56
+ NGN: "NGN";
57
+ PKR: "PKR";
58
+ COP: "COP";
59
+ CLP: "CLP";
60
+ PEN: "PEN";
61
+ VND: "VND";
62
+ KZT: "KZT";
63
+ UAH: "UAH";
64
+ BTC: "BTC";
65
+ ETH: "ETH";
66
+ ADA: "ADA";
67
+ DOT: "DOT";
68
+ ATOM: "ATOM";
69
+ XRP: "XRP";
70
+ LTC: "LTC";
71
+ SOL: "SOL";
72
+ DOGE: "DOGE";
73
+ MATIC: "MATIC";
74
+ AVAX: "AVAX";
75
+ }>;
76
+ vs: z.ZodOptional<z.ZodNullable<z.ZodString>>;
77
+ ss: z.ZodOptional<z.ZodNullable<z.ZodString>>;
78
+ ks: z.ZodOptional<z.ZodNullable<z.ZodString>>;
79
+ message: z.ZodOptional<z.ZodNullable<z.ZodString>>;
80
+ creditorHolderName: z.ZodString;
81
+ creditorAccountNumberWithBankCode: z.ZodString;
82
+ creditorIban: z.ZodString;
83
+ debtorHolderName: z.ZodString;
84
+ debtorAccountNumberWithBankCode: z.ZodString;
85
+ debtorIban: z.ZodString;
86
+ }, z.core.$strip>;
87
+ interface SendPaymentInput extends z.infer<typeof sendPaymentInputSchema> {
88
+ }
89
+ type SendPaymentOutput = void;
90
+
91
+ interface GetErsteCodeURIOutput {
92
+ uri: string;
93
+ }
94
+
95
+ declare const saveErsteCodeInputSchema: z.ZodObject<{
96
+ code: z.ZodString;
97
+ }, z.core.$strip>;
98
+ interface SaveErsteCodeInput extends z.infer<typeof saveErsteCodeInputSchema> {
99
+ }
100
+ type SaveErsteCodeOutput = void;
101
+
102
+ declare const simulateDepositInputSchema: z.ZodObject<{
103
+ amount: z.ZodNumber;
104
+ currency: z.ZodEnum<{
105
+ CZK: "CZK";
106
+ EUR: "EUR";
107
+ USD: "USD";
108
+ PLN: "PLN";
109
+ RON: "RON";
110
+ GBP: "GBP";
111
+ RUB: "RUB";
112
+ HUF: "HUF";
113
+ CHF: "CHF";
114
+ DKK: "DKK";
115
+ SEK: "SEK";
116
+ HRK: "HRK";
117
+ NOK: "NOK";
118
+ BGN: "BGN";
119
+ TRY: "TRY";
120
+ AUD: "AUD";
121
+ CAD: "CAD";
122
+ JPY: "JPY";
123
+ CNY: "CNY";
124
+ INR: "INR";
125
+ BRL: "BRL";
126
+ MXN: "MXN";
127
+ ZAR: "ZAR";
128
+ SGD: "SGD";
129
+ HKD: "HKD";
130
+ KRW: "KRW";
131
+ MYR: "MYR";
132
+ THB: "THB";
133
+ IDR: "IDR";
134
+ PHP: "PHP";
135
+ AED: "AED";
136
+ SAR: "SAR";
137
+ ILS: "ILS";
138
+ EGP: "EGP";
139
+ NGN: "NGN";
140
+ PKR: "PKR";
141
+ COP: "COP";
142
+ CLP: "CLP";
143
+ PEN: "PEN";
144
+ VND: "VND";
145
+ KZT: "KZT";
146
+ UAH: "UAH";
147
+ BTC: "BTC";
148
+ ETH: "ETH";
149
+ ADA: "ADA";
150
+ DOT: "DOT";
151
+ ATOM: "ATOM";
152
+ XRP: "XRP";
153
+ LTC: "LTC";
154
+ SOL: "SOL";
155
+ DOGE: "DOGE";
156
+ MATIC: "MATIC";
157
+ AVAX: "AVAX";
158
+ }>;
159
+ bankingVs: z.ZodString;
160
+ message: z.ZodString;
161
+ creditorIban: z.ZodString;
162
+ creditorHolderName: z.ZodString;
163
+ debtorIban: z.ZodString;
164
+ debtorHolderName: z.ZodString;
165
+ }, z.core.$strip>;
166
+ interface SimulateDepositInput extends z.infer<typeof simulateDepositInputSchema> {
167
+ }
168
+ interface SimulateDepositOutput extends PaymentSelectType {
169
+ }
170
+
171
+ declare const setLastSyncAtInputSchema: z.ZodObject<{
172
+ iban: z.ZodString;
173
+ lastSyncedAt: z.ZodCoercedDate<unknown>;
174
+ }, z.core.$strip>;
175
+ interface SetLastSyncAtInput extends z.infer<typeof setLastSyncAtInputSchema> {
176
+ }
177
+ type SetLastSyncAtOutput = {};
178
+
179
+ declare const initiateConnectorInputSchema: z.ZodObject<{
180
+ connectorKey: z.ZodString;
181
+ }, z.core.$strip>;
182
+ interface initiateConnectorInput extends z.input<typeof initiateConnectorInputSchema> {
183
+ }
184
+ interface initiateConnectorOutput {
185
+ }
186
+
187
+ declare const getBatchesInputSchema: z.ZodObject<{
188
+ limit: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
189
+ offset: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
190
+ }, z.core.$strip>;
191
+ interface GetBatchesInput extends z.infer<typeof getBatchesInputSchema> {
192
+ }
193
+ interface GetBatchesOutput {
194
+ batches: BatchSelectType[];
195
+ totalCount: number;
196
+ }
197
+
198
+ declare const BankServiceBase_base: (abstract new (ctx: ExecutionContext, env: BankEnv) => WorkerEntrypoint<BankEnv, {}>) & (abstract new (...args: any[]) => _develit_io_backend_sdk.DevelitWorkerMethods);
199
+ declare class BankServiceBase extends BankServiceBase_base {
200
+ readonly name: string;
201
+ readonly db: DrizzleD1Database<typeof tables>;
202
+ protected bankConnector: IBankConnector;
203
+ constructor(ctx: ExecutionContext, env: BankEnv);
204
+ protected get accounts(): ConfigBankAccount[];
205
+ accountFetchInterval(connectorKey: ConnectorKey): number;
206
+ syncAccounts(): Promise<IRPCResponse<void>>;
207
+ scheduled(controller: ScheduledController): Promise<void>;
208
+ initiateBankConnector(input: initiateConnectorInput): Promise<initiateConnectorOutput>;
209
+ addPaymentsToBatch({ paymentsToBatch, }: {
210
+ paymentsToBatch: SendPaymentInput[];
211
+ }): Promise<IRPCResponse<{
212
+ batchPaymentInitiatedAt: Date | null;
213
+ authorizationUrls: string | string[] | null;
214
+ accountId: string | null;
215
+ status: "OPEN" | "WAITING_FOR_PROCESSING" | "PROCESSING" | "READY_TO_SIGN" | "PREPARED" | "COMPLETED" | "FAILED" | null;
216
+ payments: PaymentInsertType[];
217
+ metadata: object | null;
218
+ id: string;
219
+ createdAt: Date | null;
220
+ updatedAt: Date | null;
221
+ deletedAt: Date | null;
222
+ }[] | undefined>>;
223
+ processBatch({ batch, connectorKey, }: {
224
+ batch: BatchSelectType;
225
+ connectorKey: ConnectorKey;
226
+ }): Promise<IRPCResponse<void>>;
227
+ queue(b: MessageBatch<SendPaymentInput>): Promise<void>;
228
+ getErsteCodeURI(): Promise<IRPCResponse<GetErsteCodeURIOutput>>;
229
+ saveErsteCode(input: SaveErsteCodeInput): Promise<IRPCResponse<SaveErsteCodeOutput>>;
230
+ saveOrUpdatePayments(accounts: BankAccountWithLastSync[]): Promise<IRPCResponse<void>>;
231
+ simulateDeposit(input: SimulateDepositInput): Promise<IRPCResponse<SimulateDepositOutput>>;
232
+ setLastSyncAt(input: SetLastSyncAtInput): Promise<IRPCResponse<SetLastSyncAtOutput>>;
233
+ sendPayment(input: SendPaymentInput): Promise<IRPCResponse<SendPaymentOutput>>;
234
+ getBankAccounts(): Promise<IRPCResponse<ConfigBankAccount[]>>;
235
+ getBatches(input: GetBatchesInput): Promise<IRPCResponse<GetBatchesOutput>>;
236
+ }
237
+ declare function defineBankService(): new (ctx: ExecutionContext, env: BankEnv) => BankServiceBase;
238
+
239
+ declare const _default: new (ctx: ExecutionContext, env: BankEnv) => WorkerEntrypoint<BankEnv>;
240
+
241
+ // @ts-ignore
242
+ export = _default;
243
+ export { defineBankService };
@@ -4,9 +4,10 @@ import { P as PaymentSelectType, B as BatchSelectType, t as tables, a as Payment
4
4
  import { WorkerEntrypoint } from 'cloudflare:workers';
5
5
  import { DrizzleD1Database } from 'drizzle-orm/d1';
6
6
  import { z } from 'zod';
7
- import { I as IBankConnector, C as ConfigBankAccount, a as ConnectorKey, B as BankAccountWithLastSync } from '../shared/bank.DdbWdNgy.mjs';
7
+ import { I as IBankConnector, C as ConfigBankAccount, a as ConnectorKey, B as BankAccountWithLastSync } from '../shared/bank.LCrZu9Ic.mjs';
8
8
  import 'drizzle-orm/sqlite-core';
9
9
  import 'drizzle-orm';
10
+ import '@develit-io/general-codes';
10
11
 
11
12
  declare const sendPaymentInputSchema: z.ZodObject<{
12
13
  refId: z.ZodString;
@@ -4,9 +4,10 @@ import { P as PaymentSelectType, B as BatchSelectType, t as tables, a as Payment
4
4
  import { WorkerEntrypoint } from 'cloudflare:workers';
5
5
  import { DrizzleD1Database } from 'drizzle-orm/d1';
6
6
  import { z } from 'zod';
7
- import { I as IBankConnector, C as ConfigBankAccount, a as ConnectorKey, B as BankAccountWithLastSync } from '../shared/bank.D-DeJSGN.js';
7
+ import { I as IBankConnector, C as ConfigBankAccount, a as ConnectorKey, B as BankAccountWithLastSync } from '../shared/bank.atHmEWmc.js';
8
8
  import 'drizzle-orm/sqlite-core';
9
9
  import 'drizzle-orm';
10
+ import '@develit-io/general-codes';
10
11
 
11
12
  declare const sendPaymentInputSchema: z.ZodObject<{
12
13
  refId: z.ZodString;
@@ -237,4 +238,6 @@ declare function defineBankService(): new (ctx: ExecutionContext, env: BankEnv)
237
238
 
238
239
  declare const _default: new (ctx: ExecutionContext, env: BankEnv) => WorkerEntrypoint<BankEnv>;
239
240
 
240
- export { _default as default, defineBankService };
241
+ // @ts-ignore
242
+ export = _default;
243
+ export { defineBankService };
@@ -1,8 +1,9 @@
1
1
  import { uuidv4, useResult, createInternalError, develitWorker, first, RPCResponse, action } from '@develit-io/backend-sdk';
2
- import { C as CURRENCY_CODES, P as PAYMENT_TYPES, t as tables, F as FinbricksConnector, M as MockConnector, a as MockCobsConnector, E as ErsteConnector, g as getPaymentDirection } from '../shared/bank._EHVypLw.mjs';
2
+ import { P as PAYMENT_TYPES, t as tables, F as FinbricksConnector, M as MockConnector, a as MockCobsConnector, E as ErsteConnector, g as getPaymentDirection } from '../shared/bank.TOYdvcg7.mjs';
3
3
  import { WorkerEntrypoint } from 'cloudflare:workers';
4
4
  import { drizzle } from 'drizzle-orm/d1';
5
5
  import { z } from 'zod';
6
+ import { CURRENCY_CODES } from '@develit-io/general-codes';
6
7
  import { eq, and, inArray, desc, sql } from 'drizzle-orm';
7
8
  import superjson from 'superjson';
8
9
  import '../shared/bank.BeH-ZCJJ.mjs';
@@ -0,0 +1,131 @@
1
+ 'use strict';
2
+
3
+ function defineBankServiceWrangler(config) {
4
+ const { project, name, envs } = config;
5
+ const base = {
6
+ name,
7
+ main: "./src/index.ts",
8
+ compatibility_date: "2025-06-04",
9
+ compatibility_flags: ["nodejs_compat"],
10
+ observability: {
11
+ enabled: true,
12
+ head_sampling_rate: 1,
13
+ logs: {
14
+ invocation_logs: false
15
+ }
16
+ },
17
+ preview_urls: false,
18
+ workers_dev: false,
19
+ vars: {
20
+ // Secrets
21
+ FINBRICKS_PRIVATE_KEY_PEM: "[SECRET]",
22
+ ERSTE_API_KEY: "[SECRET]",
23
+ ERSTE_CLIENT_SECRET: "[SECRET]",
24
+ ERSTE_CLIENT_ID: "[SECRET]",
25
+ // Variables
26
+ ...envs.local.vars,
27
+ ENVIRONMENT: "localhost",
28
+ ERSTE_REDIRECT_URI: "http://localhost:8080/api/v1/bank/erste/auth-complete",
29
+ ERSTE_AUTH_URI: "https://webapi.developers.erstegroup.com/api/csas/sandbox/v1/sandbox-idp",
30
+ ERSTE_PAYMENTS_URI: "https://webapi.developers.erstegroup.com/api/csas/public/sandbox/v1/payments",
31
+ ERSTE_ACCOUNTS_URI: "https://webapi.developers.erstegroup.com/api/csas/public/sandbox/v3/accounts",
32
+ ERSTE_FETCH_INTERVAL: 300,
33
+ FINBRICKS_BASE_URI: "https://api.sandbox.finbricks.com",
34
+ FINBRICKS_MERCHANT_ID: "10435c82-84b4-4efa-b5bf-ae6cd723e653",
35
+ CRON_BATCHES_PROCESSING: "* * * * *",
36
+ CRON_PAYMENTS_PROCESSING: "* * * * *"
37
+ },
38
+ triggers: envs.local.triggers,
39
+ kv_namespaces: [
40
+ {
41
+ binding: "BANK_KV",
42
+ id: envs.local.kv.id
43
+ }
44
+ ],
45
+ d1_databases: [
46
+ {
47
+ binding: "BANK_D1",
48
+ database_name: name,
49
+ database_id: envs.local.d1.id,
50
+ migrations_dir: "./src/database/migrations"
51
+ }
52
+ ],
53
+ queues: {
54
+ producers: [
55
+ {
56
+ binding: "PAYMENTS_READY_TO_BATCH_QUEUE",
57
+ queue: `${project}-payments-ready-to-batch`
58
+ },
59
+ {
60
+ binding: "QUEUE_BUS_QUEUE",
61
+ queue: `${project}-queue-bus`
62
+ },
63
+ {
64
+ binding: "NOTIFICATIONS_QUEUE",
65
+ queue: `${project}-notifications`
66
+ }
67
+ ],
68
+ consumers: [
69
+ {
70
+ queue: `${project}-payments-ready-to-batch`,
71
+ max_batch_size: 1,
72
+ max_batch_timeout: 5,
73
+ dead_letter_queue: `${project}-payments-ready-to-batch-dlq`
74
+ }
75
+ ]
76
+ },
77
+ env: {}
78
+ };
79
+ for (const [envName, envCfg] of Object.entries(envs).filter(
80
+ ([key]) => key !== "local"
81
+ )) {
82
+ base.env[envName] = {
83
+ vars: {
84
+ ...envCfg.vars,
85
+ ENVIRONMENT: envName
86
+ },
87
+ triggers: envs.local.triggers,
88
+ kv_namespaces: [
89
+ {
90
+ binding: "BANK_KV",
91
+ id: envCfg.kv.id
92
+ }
93
+ ],
94
+ d1_databases: [
95
+ {
96
+ binding: "NOTIFICATION_D1",
97
+ database_name: `${name}-${envName}`,
98
+ database_id: envCfg.d1.id,
99
+ migrations_dir: "./src/database/migrations"
100
+ }
101
+ ],
102
+ queues: {
103
+ producers: [
104
+ {
105
+ binding: "PAYMENTS_READY_TO_BATCH_QUEUE",
106
+ queue: `${project}-payments-ready-to-batch-${envName}`
107
+ },
108
+ {
109
+ binding: "QUEUE_BUS_QUEUE",
110
+ queue: `${project}-queue-bus-${envName}`
111
+ },
112
+ {
113
+ binding: "NOTIFICATIONS_QUEUE",
114
+ queue: `${project}-notifications-${envName}`
115
+ }
116
+ ],
117
+ consumers: [
118
+ {
119
+ queue: `${project}-payments-ready-to-batch-${envName}`,
120
+ max_batch_size: envCfg.queue?.max_batch_size ?? 1,
121
+ max_batch_timeout: envCfg.queue?.max_batch_timeout ?? 5,
122
+ dead_letter_queue: `${project}-payments-ready-to-batch-dlq`
123
+ }
124
+ ]
125
+ }
126
+ };
127
+ }
128
+ return base;
129
+ }
130
+
131
+ exports.defineBankServiceWrangler = defineBankServiceWrangler;
@@ -0,0 +1,59 @@
1
+ import { B as BankServiceWranglerConfig } from '../shared/bank.DxGqqFhD.cjs';
2
+
3
+ declare function defineBankServiceWrangler(config: BankServiceWranglerConfig): {
4
+ name: string;
5
+ main: string;
6
+ compatibility_date: string;
7
+ compatibility_flags: string[];
8
+ observability: {
9
+ enabled: boolean;
10
+ head_sampling_rate: number;
11
+ logs: {
12
+ invocation_logs: boolean;
13
+ };
14
+ };
15
+ preview_urls: boolean;
16
+ workers_dev: boolean;
17
+ vars: {
18
+ ENVIRONMENT: string;
19
+ ERSTE_REDIRECT_URI: string;
20
+ ERSTE_AUTH_URI: string;
21
+ ERSTE_PAYMENTS_URI: string;
22
+ ERSTE_ACCOUNTS_URI: string;
23
+ ERSTE_FETCH_INTERVAL: number;
24
+ FINBRICKS_BASE_URI: string;
25
+ FINBRICKS_MERCHANT_ID: string;
26
+ CRON_BATCHES_PROCESSING: string;
27
+ CRON_PAYMENTS_PROCESSING: string;
28
+ FINBRICKS_PRIVATE_KEY_PEM: string;
29
+ ERSTE_API_KEY: string;
30
+ ERSTE_CLIENT_SECRET: string;
31
+ ERSTE_CLIENT_ID: string;
32
+ };
33
+ triggers: string[];
34
+ kv_namespaces: {
35
+ binding: string;
36
+ id: string;
37
+ }[];
38
+ d1_databases: {
39
+ binding: string;
40
+ database_name: string;
41
+ database_id: string;
42
+ migrations_dir: string;
43
+ }[];
44
+ queues: {
45
+ producers: {
46
+ binding: string;
47
+ queue: string;
48
+ }[];
49
+ consumers: {
50
+ queue: string;
51
+ max_batch_size: number;
52
+ max_batch_timeout: number;
53
+ dead_letter_queue: string;
54
+ }[];
55
+ };
56
+ env: Record<string, unknown>;
57
+ };
58
+
59
+ export { defineBankServiceWrangler };