@develit-services/bank 0.0.2

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,59 @@
1
+ import { B as BankServiceWranglerConfig } from '../shared/bank.DxGqqFhD.mjs';
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 };
@@ -0,0 +1,59 @@
1
+ import { B as BankServiceWranglerConfig } from '../shared/bank.DxGqqFhD.js';
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 };
@@ -0,0 +1,129 @@
1
+ function defineBankServiceWrangler(config) {
2
+ const { project, name, envs } = config;
3
+ const base = {
4
+ name,
5
+ main: "./src/index.ts",
6
+ compatibility_date: "2025-06-04",
7
+ compatibility_flags: ["nodejs_compat"],
8
+ observability: {
9
+ enabled: true,
10
+ head_sampling_rate: 1,
11
+ logs: {
12
+ invocation_logs: false
13
+ }
14
+ },
15
+ preview_urls: false,
16
+ workers_dev: false,
17
+ vars: {
18
+ // Secrets
19
+ FINBRICKS_PRIVATE_KEY_PEM: "[SECRET]",
20
+ ERSTE_API_KEY: "[SECRET]",
21
+ ERSTE_CLIENT_SECRET: "[SECRET]",
22
+ ERSTE_CLIENT_ID: "[SECRET]",
23
+ // Variables
24
+ ...envs.local.vars,
25
+ ENVIRONMENT: "localhost",
26
+ ERSTE_REDIRECT_URI: "http://localhost:8080/api/v1/bank/erste/auth-complete",
27
+ ERSTE_AUTH_URI: "https://webapi.developers.erstegroup.com/api/csas/sandbox/v1/sandbox-idp",
28
+ ERSTE_PAYMENTS_URI: "https://webapi.developers.erstegroup.com/api/csas/public/sandbox/v1/payments",
29
+ ERSTE_ACCOUNTS_URI: "https://webapi.developers.erstegroup.com/api/csas/public/sandbox/v3/accounts",
30
+ ERSTE_FETCH_INTERVAL: 300,
31
+ FINBRICKS_BASE_URI: "https://api.sandbox.finbricks.com",
32
+ FINBRICKS_MERCHANT_ID: "10435c82-84b4-4efa-b5bf-ae6cd723e653",
33
+ CRON_BATCHES_PROCESSING: "* * * * *",
34
+ CRON_PAYMENTS_PROCESSING: "* * * * *"
35
+ },
36
+ triggers: envs.local.triggers,
37
+ kv_namespaces: [
38
+ {
39
+ binding: "BANK_KV",
40
+ id: envs.local.kv.id
41
+ }
42
+ ],
43
+ d1_databases: [
44
+ {
45
+ binding: "BANK_D1",
46
+ database_name: name,
47
+ database_id: envs.local.d1.id,
48
+ migrations_dir: "./src/database/migrations"
49
+ }
50
+ ],
51
+ queues: {
52
+ producers: [
53
+ {
54
+ binding: "PAYMENTS_READY_TO_BATCH_QUEUE",
55
+ queue: `${project}-payments-ready-to-batch`
56
+ },
57
+ {
58
+ binding: "QUEUE_BUS_QUEUE",
59
+ queue: `${project}-queue-bus`
60
+ },
61
+ {
62
+ binding: "NOTIFICATIONS_QUEUE",
63
+ queue: `${project}-notifications`
64
+ }
65
+ ],
66
+ consumers: [
67
+ {
68
+ queue: `${project}-payments-ready-to-batch`,
69
+ max_batch_size: 1,
70
+ max_batch_timeout: 5,
71
+ dead_letter_queue: `${project}-payments-ready-to-batch-dlq`
72
+ }
73
+ ]
74
+ },
75
+ env: {}
76
+ };
77
+ for (const [envName, envCfg] of Object.entries(envs).filter(
78
+ ([key]) => key !== "local"
79
+ )) {
80
+ base.env[envName] = {
81
+ vars: {
82
+ ...envCfg.vars,
83
+ ENVIRONMENT: envName
84
+ },
85
+ triggers: envs.local.triggers,
86
+ kv_namespaces: [
87
+ {
88
+ binding: "BANK_KV",
89
+ id: envCfg.kv.id
90
+ }
91
+ ],
92
+ d1_databases: [
93
+ {
94
+ binding: "NOTIFICATION_D1",
95
+ database_name: `${name}-${envName}`,
96
+ database_id: envCfg.d1.id,
97
+ migrations_dir: "./src/database/migrations"
98
+ }
99
+ ],
100
+ queues: {
101
+ producers: [
102
+ {
103
+ binding: "PAYMENTS_READY_TO_BATCH_QUEUE",
104
+ queue: `${project}-payments-ready-to-batch-${envName}`
105
+ },
106
+ {
107
+ binding: "QUEUE_BUS_QUEUE",
108
+ queue: `${project}-queue-bus-${envName}`
109
+ },
110
+ {
111
+ binding: "NOTIFICATIONS_QUEUE",
112
+ queue: `${project}-notifications-${envName}`
113
+ }
114
+ ],
115
+ consumers: [
116
+ {
117
+ queue: `${project}-payments-ready-to-batch-${envName}`,
118
+ max_batch_size: envCfg.queue?.max_batch_size ?? 1,
119
+ max_batch_timeout: envCfg.queue?.max_batch_timeout ?? 5,
120
+ dead_letter_queue: `${project}-payments-ready-to-batch-dlq`
121
+ }
122
+ ]
123
+ }
124
+ };
125
+ }
126
+ return base;
127
+ }
128
+
129
+ export { defineBankServiceWrangler };
@@ -0,0 +1,67 @@
1
+ import { base } from '@develit-io/backend-sdk';
2
+ import { sqliteTable, text, integer, real } from 'drizzle-orm/sqlite-core';
3
+ import { relations } from 'drizzle-orm/relations';
4
+
5
+ const BATCH_STATUSES = [
6
+ "OPEN",
7
+ "WAITING_FOR_PROCESSING",
8
+ "PROCESSING",
9
+ "READY_TO_SIGN",
10
+ "PREPARED",
11
+ "COMPLETED",
12
+ "FAILED"
13
+ ];
14
+ const batch = sqliteTable("batch", {
15
+ ...base,
16
+ batchPaymentInitiatedAt: integer("batch_payment_initiated_at", {
17
+ mode: "timestamp_ms"
18
+ }),
19
+ authorizationUrls: text("authorization_urls", { mode: "json" }).$type(),
20
+ accountId: text("account_id"),
21
+ status: text("status", { enum: BATCH_STATUSES }).$type(),
22
+ payments: text("payments", { mode: "json" }).$type().notNull(),
23
+ metadata: text("metadata", { mode: "json" }).$type()
24
+ });
25
+
26
+ const payment = sqliteTable("payment", {
27
+ ...base,
28
+ refId: text("ref_id"),
29
+ bankRefId: text("bank_ref_id"),
30
+ amount: real("amount").notNull(),
31
+ direction: text("direction").$type().notNull(),
32
+ paymentType: text("payment_type").$type(),
33
+ currency: text("currency").$type().notNull(),
34
+ status: text("status").$type().notNull(),
35
+ statusReason: text("status_reason"),
36
+ batchId: text("bank_execution_batch_id"),
37
+ initiatedAt: integer("initiated_at", {
38
+ mode: "timestamp_ms"
39
+ }),
40
+ vs: text("vs"),
41
+ ss: text("ss"),
42
+ ks: text("ks"),
43
+ message: text("message"),
44
+ processedAt: integer("processed_at", {
45
+ mode: "timestamp_ms"
46
+ }),
47
+ creditorHolderName: text("creditor_holder_name").notNull(),
48
+ creditorAccountNumberWithBankCode: text(
49
+ "creditor_account_number_with_bank_code"
50
+ ),
51
+ creditorIban: text("creditor_iban"),
52
+ debtorIban: text("debtor_iban"),
53
+ debtorHolderName: text("debtor_holder_name"),
54
+ debtorAccountNumberWithBankCode: text("debtor_account_number_with_bank_code")
55
+ });
56
+ const paymentRelations = relations(payment, ({ one }) => ({
57
+ batch: one(batch, { fields: [payment.batchId], references: [batch.id] })
58
+ }));
59
+
60
+ const schema = {
61
+ __proto__: null,
62
+ batch: batch,
63
+ payment: payment,
64
+ paymentRelations: paymentRelations
65
+ };
66
+
67
+ export { paymentRelations as a, batch as b, payment as p, schema as s };