@develit-services/bank 0.1.7 → 0.1.9
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 +13 -15
- package/dist/export/worker.d.cts +16 -17
- package/dist/export/worker.d.mts +16 -17
- package/dist/export/worker.d.ts +16 -17
- package/dist/export/worker.mjs +3 -5
- package/dist/export/workflows.cjs +160 -9
- package/dist/export/workflows.d.cts +10 -2
- package/dist/export/workflows.d.mts +10 -2
- package/dist/export/workflows.d.ts +10 -2
- package/dist/export/workflows.mjs +163 -8
- package/dist/shared/bank.-FurAs09.cjs +120 -0
- package/dist/shared/{bank.D2ZeOkyc.mjs → bank.BvXwHpBp.mjs} +1 -1
- package/dist/shared/{bank.DCTBX1dp.d.ts → bank.CRVH1wUH.d.cts} +7 -7
- package/dist/shared/{bank.CrRs_x0N.d.mts → bank.Ckn_klvT.d.ts} +7 -7
- package/dist/shared/{bank.BFGDv0oC.d.cts → bank.CsvBtQib.d.cts} +8 -8
- package/dist/shared/{bank.BFGDv0oC.d.mts → bank.CsvBtQib.d.mts} +8 -8
- package/dist/shared/{bank.BFGDv0oC.d.ts → bank.CsvBtQib.d.ts} +8 -8
- package/dist/shared/bank.DTdKHhGd.mjs +113 -0
- package/dist/shared/{bank.DSVzOCrh.d.cts → bank.DouutABZ.d.mts} +7 -7
- package/dist/shared/{bank.xIMAnZ4v.mjs → bank.W4h6Dlzi.mjs} +62 -2
- package/dist/shared/{bank.PDmcU0T-.cjs → bank.tLe0jhjo.cjs} +61 -1
- package/dist/shared/{bank.BcCfzRPi.cjs → bank.z4VxSea3.cjs} +1 -1
- package/dist/types.cjs +2 -2
- package/dist/types.d.cts +69 -5
- package/dist/types.d.mts +69 -5
- package/dist/types.d.ts +69 -5
- package/dist/types.mjs +2 -2
- package/package.json +1 -1
- package/dist/shared/bank.B3isylGM.cjs +0 -284
- package/dist/shared/bank.ChAGzUFo.d.cts +0 -18
- package/dist/shared/bank.ChAGzUFo.d.mts +0 -18
- package/dist/shared/bank.ChAGzUFo.d.ts +0 -18
- package/dist/shared/bank.JtGSu6eH.mjs +0 -275
package/dist/types.d.cts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
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.
|
|
2
|
-
export { D as ACCOUNT_STATUSES, Y as AccountCredentialsPatchType, Z as AccountCredentialsSelectType, X as AccountCredentialsUpdateType, S as AccountPatchType, E as AccountStatus, R as AccountUpdateType, q as BATCH_STATUES, q as BATCH_STATUSES, G as BankAccountWithLastSync, t as CHARGE_BEARERS, H as CONNECTOR_KEYS, F as COUNTRY_CODES, J as CREDENTIALS_TYPES, u as ChargeBearer, C as ConfigEnvironmentBank, K as CredentialsType, v as INSTRUCTION_PRIORITIES, w as InstructionPriority, O as OutgoingPaymentMessage, y as PAYMENT_DIRECTIONS, x as PAYMENT_STATUSES, r as PAYMENT_TYPES, z as PaymentDirection, o as PaymentFailedInsertType, s as PaymentType, T as TOKEN_TYPES, L as TokenType, U as accountCredentialsInsertSchema, W as accountCredentialsSelectSchema, V as accountCredentialsUpdateSchema, M as accountInsertSchema, Q as accountSelectSchema, N as accountUpdateSchema, p as paymentInitializedInsertType } from './shared/bank.
|
|
3
|
-
import { a as PaymentInsertType, t as tables, P as PaymentSelectType } from './shared/bank.
|
|
4
|
-
export { b as BatchInsertType, B as BatchSelectType, p as paymentInsertTypeZod } from './shared/bank.
|
|
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.CRVH1wUH.cjs';
|
|
2
|
+
export { D as ACCOUNT_STATUSES, Y as AccountCredentialsPatchType, Z as AccountCredentialsSelectType, X as AccountCredentialsUpdateType, S as AccountPatchType, E as AccountStatus, R as AccountUpdateType, q as BATCH_STATUES, q as BATCH_STATUSES, G as BankAccountWithLastSync, t as CHARGE_BEARERS, H as CONNECTOR_KEYS, F as COUNTRY_CODES, J as CREDENTIALS_TYPES, u as ChargeBearer, C as ConfigEnvironmentBank, K as CredentialsType, v as INSTRUCTION_PRIORITIES, w as InstructionPriority, O as OutgoingPaymentMessage, y as PAYMENT_DIRECTIONS, x as PAYMENT_STATUSES, r as PAYMENT_TYPES, z as PaymentDirection, o as PaymentFailedInsertType, s as PaymentType, T as TOKEN_TYPES, L as TokenType, U as accountCredentialsInsertSchema, W as accountCredentialsSelectSchema, V as accountCredentialsUpdateSchema, M as accountInsertSchema, Q as accountSelectSchema, N as accountUpdateSchema, p as paymentInitializedInsertType } from './shared/bank.CRVH1wUH.cjs';
|
|
3
|
+
import { a as PaymentInsertType, t as tables, P as PaymentSelectType } from './shared/bank.CsvBtQib.cjs';
|
|
4
|
+
export { b as BatchInsertType, B as BatchSelectType, p as paymentInsertTypeZod } from './shared/bank.CsvBtQib.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';
|
|
@@ -157,6 +157,68 @@ type FinbricksGetBatchStatusBody = {
|
|
|
157
157
|
merchantTransactionId?: string;
|
|
158
158
|
finalBankStatus?: boolean;
|
|
159
159
|
};
|
|
160
|
+
type FinbricksForeignPaymentBody = {
|
|
161
|
+
merchantIdentification: {
|
|
162
|
+
merchantId: string;
|
|
163
|
+
clientId: string;
|
|
164
|
+
initiatorName?: string;
|
|
165
|
+
};
|
|
166
|
+
paymentIdentification: {
|
|
167
|
+
merchantTransactionId: string;
|
|
168
|
+
};
|
|
169
|
+
amount: {
|
|
170
|
+
value: number;
|
|
171
|
+
currency: string;
|
|
172
|
+
};
|
|
173
|
+
chargeBearer: 'SHA' | 'OUR' | 'BEN';
|
|
174
|
+
debtor: {
|
|
175
|
+
accountIdentification: {
|
|
176
|
+
value: string;
|
|
177
|
+
type: 'BBAN' | 'IBAN' | 'PHONE' | 'EMAIL' | 'TAXID';
|
|
178
|
+
currency?: string;
|
|
179
|
+
};
|
|
180
|
+
debtorName?: string;
|
|
181
|
+
psuId?: string;
|
|
182
|
+
segmentContextType?: 'RETAIL' | 'CORPORATE';
|
|
183
|
+
paymentProvider: string;
|
|
184
|
+
};
|
|
185
|
+
creditor: {
|
|
186
|
+
accountIdentification: {
|
|
187
|
+
value: string;
|
|
188
|
+
type: 'BBAN' | 'IBAN' | 'PHONE' | 'EMAIL' | 'TAXID';
|
|
189
|
+
currency?: string;
|
|
190
|
+
};
|
|
191
|
+
creditorName: string;
|
|
192
|
+
postalAddress?: {
|
|
193
|
+
addressLine?: string;
|
|
194
|
+
town?: string;
|
|
195
|
+
country?: string;
|
|
196
|
+
};
|
|
197
|
+
};
|
|
198
|
+
creditorAgent?: {
|
|
199
|
+
financialInstitutionIdentification: {
|
|
200
|
+
bic?: string;
|
|
201
|
+
name?: string;
|
|
202
|
+
postalAddress?: {
|
|
203
|
+
addressLine?: string;
|
|
204
|
+
town?: string;
|
|
205
|
+
country?: string;
|
|
206
|
+
};
|
|
207
|
+
};
|
|
208
|
+
};
|
|
209
|
+
remittanceInformation?: {
|
|
210
|
+
unstructured?: string;
|
|
211
|
+
structured?: {
|
|
212
|
+
reference?: string;
|
|
213
|
+
};
|
|
214
|
+
};
|
|
215
|
+
instructionPriority?: 'NORM';
|
|
216
|
+
callbackUrl?: string;
|
|
217
|
+
confirmationPageUrl?: string;
|
|
218
|
+
transactionConfirmation?: {
|
|
219
|
+
email: string;
|
|
220
|
+
};
|
|
221
|
+
};
|
|
160
222
|
|
|
161
223
|
type ReferenceType = `${'VS' | 'SS' | 'KS'}:${number}`;
|
|
162
224
|
|
|
@@ -365,6 +427,7 @@ declare const FINBRICKS_ENDPOINTS: {
|
|
|
365
427
|
readonly TRANSACTION_INIT: "/transaction/platform/init";
|
|
366
428
|
readonly TRANSACTION_STATUS: "/transaction/platform/status";
|
|
367
429
|
readonly TRANSACTION_SEPA_INIT: "/transaction/platform/sepa/init";
|
|
430
|
+
readonly TRANSACTION_FOREIGN_INIT: "/transaction/platform/foreign/init";
|
|
368
431
|
readonly TRANSACTION_BATCH_INIT: "/transaction/platform/batchPayment/init";
|
|
369
432
|
readonly BATCH_STATUS: "/transaction/platform/batchPayment/status";
|
|
370
433
|
};
|
|
@@ -417,6 +480,7 @@ declare abstract class FinbricksConnector extends IBankConnector {
|
|
|
417
480
|
initiateBatchFromPayments({ payments, }: {
|
|
418
481
|
payments: PaymentPreparedInsertType[];
|
|
419
482
|
}): Promise<InitiatedBatch>;
|
|
483
|
+
initiateForeignPayment(payment: IncomingPaymentMessage): Promise<InitiatedPayment>;
|
|
420
484
|
initiateSEPAPayment(payment: IncomingPaymentMessage): Promise<InitiatedPayment>;
|
|
421
485
|
initiateSinglePayment(payment: PaymentPreparedInsertType): Promise<InitiatedPayment>;
|
|
422
486
|
getAllAccountPayments({ account, filter, }: {
|
|
@@ -1062,4 +1126,4 @@ type OneTimeTokenPatchType = z.infer<typeof ottUpdateSchema>;
|
|
|
1062
1126
|
type OneTimeTokenSelectType = z.infer<typeof ottSelectSchema>;
|
|
1063
1127
|
|
|
1064
1128
|
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 };
|
|
1065
|
-
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 };
|
|
1129
|
+
export type { BankPaymentEvent, ErsteAuthenticationResponse, ErsteBatchPaymentInitiationResponse, ErsteIncomingPaymentResponse, ErsteObtainAuthorizationURLResponse, ErstePaymentInitiationResponse, FinbricksAccount, FinbricksAccountTransactionsResponse, FinbricksAccountsListResponse, FinbricksAuthTokenResponse, FinbricksBatchBody, FinbricksBatchResponse, FinbricksBatchStatus, FinbricksConnectAccountBody, FinbricksConnectAccountResponse, FinbricksConnectorConfig, FinbricksEndpoint, FinbricksEndpointPath, FinbricksFetchConfig, FinbricksForeignPaymentBody, FinbricksGetBatchStatusBody, FinbricksGetBatchStatusResponse, FinbricksGetTransactionStatusResponse, FinbricksJWSData, FinbricksPaymentBody, FinbricksPaymentResponse, FinbricksProvider, FinbricksRequestInit, FinbricksTransactionStatus, OneTimeTokenInsertType, OneTimeTokenPatchType, OneTimeTokenSelectType, OneTimeTokenUpdateType };
|
package/dist/types.d.mts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
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.
|
|
2
|
-
export { D as ACCOUNT_STATUSES, Y as AccountCredentialsPatchType, Z as AccountCredentialsSelectType, X as AccountCredentialsUpdateType, S as AccountPatchType, E as AccountStatus, R as AccountUpdateType, q as BATCH_STATUES, q as BATCH_STATUSES, G as BankAccountWithLastSync, t as CHARGE_BEARERS, H as CONNECTOR_KEYS, F as COUNTRY_CODES, J as CREDENTIALS_TYPES, u as ChargeBearer, C as ConfigEnvironmentBank, K as CredentialsType, v as INSTRUCTION_PRIORITIES, w as InstructionPriority, O as OutgoingPaymentMessage, y as PAYMENT_DIRECTIONS, x as PAYMENT_STATUSES, r as PAYMENT_TYPES, z as PaymentDirection, o as PaymentFailedInsertType, s as PaymentType, T as TOKEN_TYPES, L as TokenType, U as accountCredentialsInsertSchema, W as accountCredentialsSelectSchema, V as accountCredentialsUpdateSchema, M as accountInsertSchema, Q as accountSelectSchema, N as accountUpdateSchema, p as paymentInitializedInsertType } from './shared/bank.
|
|
3
|
-
import { a as PaymentInsertType, t as tables, P as PaymentSelectType } from './shared/bank.
|
|
4
|
-
export { b as BatchInsertType, B as BatchSelectType, p as paymentInsertTypeZod } from './shared/bank.
|
|
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.DouutABZ.mjs';
|
|
2
|
+
export { D as ACCOUNT_STATUSES, Y as AccountCredentialsPatchType, Z as AccountCredentialsSelectType, X as AccountCredentialsUpdateType, S as AccountPatchType, E as AccountStatus, R as AccountUpdateType, q as BATCH_STATUES, q as BATCH_STATUSES, G as BankAccountWithLastSync, t as CHARGE_BEARERS, H as CONNECTOR_KEYS, F as COUNTRY_CODES, J as CREDENTIALS_TYPES, u as ChargeBearer, C as ConfigEnvironmentBank, K as CredentialsType, v as INSTRUCTION_PRIORITIES, w as InstructionPriority, O as OutgoingPaymentMessage, y as PAYMENT_DIRECTIONS, x as PAYMENT_STATUSES, r as PAYMENT_TYPES, z as PaymentDirection, o as PaymentFailedInsertType, s as PaymentType, T as TOKEN_TYPES, L as TokenType, U as accountCredentialsInsertSchema, W as accountCredentialsSelectSchema, V as accountCredentialsUpdateSchema, M as accountInsertSchema, Q as accountSelectSchema, N as accountUpdateSchema, p as paymentInitializedInsertType } from './shared/bank.DouutABZ.mjs';
|
|
3
|
+
import { a as PaymentInsertType, t as tables, P as PaymentSelectType } from './shared/bank.CsvBtQib.mjs';
|
|
4
|
+
export { b as BatchInsertType, B as BatchSelectType, p as paymentInsertTypeZod } from './shared/bank.CsvBtQib.mjs';
|
|
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.mjs';
|
|
@@ -157,6 +157,68 @@ type FinbricksGetBatchStatusBody = {
|
|
|
157
157
|
merchantTransactionId?: string;
|
|
158
158
|
finalBankStatus?: boolean;
|
|
159
159
|
};
|
|
160
|
+
type FinbricksForeignPaymentBody = {
|
|
161
|
+
merchantIdentification: {
|
|
162
|
+
merchantId: string;
|
|
163
|
+
clientId: string;
|
|
164
|
+
initiatorName?: string;
|
|
165
|
+
};
|
|
166
|
+
paymentIdentification: {
|
|
167
|
+
merchantTransactionId: string;
|
|
168
|
+
};
|
|
169
|
+
amount: {
|
|
170
|
+
value: number;
|
|
171
|
+
currency: string;
|
|
172
|
+
};
|
|
173
|
+
chargeBearer: 'SHA' | 'OUR' | 'BEN';
|
|
174
|
+
debtor: {
|
|
175
|
+
accountIdentification: {
|
|
176
|
+
value: string;
|
|
177
|
+
type: 'BBAN' | 'IBAN' | 'PHONE' | 'EMAIL' | 'TAXID';
|
|
178
|
+
currency?: string;
|
|
179
|
+
};
|
|
180
|
+
debtorName?: string;
|
|
181
|
+
psuId?: string;
|
|
182
|
+
segmentContextType?: 'RETAIL' | 'CORPORATE';
|
|
183
|
+
paymentProvider: string;
|
|
184
|
+
};
|
|
185
|
+
creditor: {
|
|
186
|
+
accountIdentification: {
|
|
187
|
+
value: string;
|
|
188
|
+
type: 'BBAN' | 'IBAN' | 'PHONE' | 'EMAIL' | 'TAXID';
|
|
189
|
+
currency?: string;
|
|
190
|
+
};
|
|
191
|
+
creditorName: string;
|
|
192
|
+
postalAddress?: {
|
|
193
|
+
addressLine?: string;
|
|
194
|
+
town?: string;
|
|
195
|
+
country?: string;
|
|
196
|
+
};
|
|
197
|
+
};
|
|
198
|
+
creditorAgent?: {
|
|
199
|
+
financialInstitutionIdentification: {
|
|
200
|
+
bic?: string;
|
|
201
|
+
name?: string;
|
|
202
|
+
postalAddress?: {
|
|
203
|
+
addressLine?: string;
|
|
204
|
+
town?: string;
|
|
205
|
+
country?: string;
|
|
206
|
+
};
|
|
207
|
+
};
|
|
208
|
+
};
|
|
209
|
+
remittanceInformation?: {
|
|
210
|
+
unstructured?: string;
|
|
211
|
+
structured?: {
|
|
212
|
+
reference?: string;
|
|
213
|
+
};
|
|
214
|
+
};
|
|
215
|
+
instructionPriority?: 'NORM';
|
|
216
|
+
callbackUrl?: string;
|
|
217
|
+
confirmationPageUrl?: string;
|
|
218
|
+
transactionConfirmation?: {
|
|
219
|
+
email: string;
|
|
220
|
+
};
|
|
221
|
+
};
|
|
160
222
|
|
|
161
223
|
type ReferenceType = `${'VS' | 'SS' | 'KS'}:${number}`;
|
|
162
224
|
|
|
@@ -365,6 +427,7 @@ declare const FINBRICKS_ENDPOINTS: {
|
|
|
365
427
|
readonly TRANSACTION_INIT: "/transaction/platform/init";
|
|
366
428
|
readonly TRANSACTION_STATUS: "/transaction/platform/status";
|
|
367
429
|
readonly TRANSACTION_SEPA_INIT: "/transaction/platform/sepa/init";
|
|
430
|
+
readonly TRANSACTION_FOREIGN_INIT: "/transaction/platform/foreign/init";
|
|
368
431
|
readonly TRANSACTION_BATCH_INIT: "/transaction/platform/batchPayment/init";
|
|
369
432
|
readonly BATCH_STATUS: "/transaction/platform/batchPayment/status";
|
|
370
433
|
};
|
|
@@ -417,6 +480,7 @@ declare abstract class FinbricksConnector extends IBankConnector {
|
|
|
417
480
|
initiateBatchFromPayments({ payments, }: {
|
|
418
481
|
payments: PaymentPreparedInsertType[];
|
|
419
482
|
}): Promise<InitiatedBatch>;
|
|
483
|
+
initiateForeignPayment(payment: IncomingPaymentMessage): Promise<InitiatedPayment>;
|
|
420
484
|
initiateSEPAPayment(payment: IncomingPaymentMessage): Promise<InitiatedPayment>;
|
|
421
485
|
initiateSinglePayment(payment: PaymentPreparedInsertType): Promise<InitiatedPayment>;
|
|
422
486
|
getAllAccountPayments({ account, filter, }: {
|
|
@@ -1062,4 +1126,4 @@ type OneTimeTokenPatchType = z.infer<typeof ottUpdateSchema>;
|
|
|
1062
1126
|
type OneTimeTokenSelectType = z.infer<typeof ottSelectSchema>;
|
|
1063
1127
|
|
|
1064
1128
|
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 };
|
|
1065
|
-
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 };
|
|
1129
|
+
export type { BankPaymentEvent, ErsteAuthenticationResponse, ErsteBatchPaymentInitiationResponse, ErsteIncomingPaymentResponse, ErsteObtainAuthorizationURLResponse, ErstePaymentInitiationResponse, FinbricksAccount, FinbricksAccountTransactionsResponse, FinbricksAccountsListResponse, FinbricksAuthTokenResponse, FinbricksBatchBody, FinbricksBatchResponse, FinbricksBatchStatus, FinbricksConnectAccountBody, FinbricksConnectAccountResponse, FinbricksConnectorConfig, FinbricksEndpoint, FinbricksEndpointPath, FinbricksFetchConfig, FinbricksForeignPaymentBody, FinbricksGetBatchStatusBody, FinbricksGetBatchStatusResponse, FinbricksGetTransactionStatusResponse, FinbricksJWSData, FinbricksPaymentBody, FinbricksPaymentResponse, FinbricksProvider, FinbricksRequestInit, FinbricksTransactionStatus, OneTimeTokenInsertType, OneTimeTokenPatchType, OneTimeTokenSelectType, OneTimeTokenUpdateType };
|
package/dist/types.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
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.
|
|
2
|
-
export { D as ACCOUNT_STATUSES, Y as AccountCredentialsPatchType, Z as AccountCredentialsSelectType, X as AccountCredentialsUpdateType, S as AccountPatchType, E as AccountStatus, R as AccountUpdateType, q as BATCH_STATUES, q as BATCH_STATUSES, G as BankAccountWithLastSync, t as CHARGE_BEARERS, H as CONNECTOR_KEYS, F as COUNTRY_CODES, J as CREDENTIALS_TYPES, u as ChargeBearer, C as ConfigEnvironmentBank, K as CredentialsType, v as INSTRUCTION_PRIORITIES, w as InstructionPriority, O as OutgoingPaymentMessage, y as PAYMENT_DIRECTIONS, x as PAYMENT_STATUSES, r as PAYMENT_TYPES, z as PaymentDirection, o as PaymentFailedInsertType, s as PaymentType, T as TOKEN_TYPES, L as TokenType, U as accountCredentialsInsertSchema, W as accountCredentialsSelectSchema, V as accountCredentialsUpdateSchema, M as accountInsertSchema, Q as accountSelectSchema, N as accountUpdateSchema, p as paymentInitializedInsertType } from './shared/bank.
|
|
3
|
-
import { a as PaymentInsertType, t as tables, P as PaymentSelectType } from './shared/bank.
|
|
4
|
-
export { b as BatchInsertType, B as BatchSelectType, p as paymentInsertTypeZod } from './shared/bank.
|
|
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.Ckn_klvT.js';
|
|
2
|
+
export { D as ACCOUNT_STATUSES, Y as AccountCredentialsPatchType, Z as AccountCredentialsSelectType, X as AccountCredentialsUpdateType, S as AccountPatchType, E as AccountStatus, R as AccountUpdateType, q as BATCH_STATUES, q as BATCH_STATUSES, G as BankAccountWithLastSync, t as CHARGE_BEARERS, H as CONNECTOR_KEYS, F as COUNTRY_CODES, J as CREDENTIALS_TYPES, u as ChargeBearer, C as ConfigEnvironmentBank, K as CredentialsType, v as INSTRUCTION_PRIORITIES, w as InstructionPriority, O as OutgoingPaymentMessage, y as PAYMENT_DIRECTIONS, x as PAYMENT_STATUSES, r as PAYMENT_TYPES, z as PaymentDirection, o as PaymentFailedInsertType, s as PaymentType, T as TOKEN_TYPES, L as TokenType, U as accountCredentialsInsertSchema, W as accountCredentialsSelectSchema, V as accountCredentialsUpdateSchema, M as accountInsertSchema, Q as accountSelectSchema, N as accountUpdateSchema, p as paymentInitializedInsertType } from './shared/bank.Ckn_klvT.js';
|
|
3
|
+
import { a as PaymentInsertType, t as tables, P as PaymentSelectType } from './shared/bank.CsvBtQib.js';
|
|
4
|
+
export { b as BatchInsertType, B as BatchSelectType, p as paymentInsertTypeZod } from './shared/bank.CsvBtQib.js';
|
|
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.js';
|
|
@@ -157,6 +157,68 @@ type FinbricksGetBatchStatusBody = {
|
|
|
157
157
|
merchantTransactionId?: string;
|
|
158
158
|
finalBankStatus?: boolean;
|
|
159
159
|
};
|
|
160
|
+
type FinbricksForeignPaymentBody = {
|
|
161
|
+
merchantIdentification: {
|
|
162
|
+
merchantId: string;
|
|
163
|
+
clientId: string;
|
|
164
|
+
initiatorName?: string;
|
|
165
|
+
};
|
|
166
|
+
paymentIdentification: {
|
|
167
|
+
merchantTransactionId: string;
|
|
168
|
+
};
|
|
169
|
+
amount: {
|
|
170
|
+
value: number;
|
|
171
|
+
currency: string;
|
|
172
|
+
};
|
|
173
|
+
chargeBearer: 'SHA' | 'OUR' | 'BEN';
|
|
174
|
+
debtor: {
|
|
175
|
+
accountIdentification: {
|
|
176
|
+
value: string;
|
|
177
|
+
type: 'BBAN' | 'IBAN' | 'PHONE' | 'EMAIL' | 'TAXID';
|
|
178
|
+
currency?: string;
|
|
179
|
+
};
|
|
180
|
+
debtorName?: string;
|
|
181
|
+
psuId?: string;
|
|
182
|
+
segmentContextType?: 'RETAIL' | 'CORPORATE';
|
|
183
|
+
paymentProvider: string;
|
|
184
|
+
};
|
|
185
|
+
creditor: {
|
|
186
|
+
accountIdentification: {
|
|
187
|
+
value: string;
|
|
188
|
+
type: 'BBAN' | 'IBAN' | 'PHONE' | 'EMAIL' | 'TAXID';
|
|
189
|
+
currency?: string;
|
|
190
|
+
};
|
|
191
|
+
creditorName: string;
|
|
192
|
+
postalAddress?: {
|
|
193
|
+
addressLine?: string;
|
|
194
|
+
town?: string;
|
|
195
|
+
country?: string;
|
|
196
|
+
};
|
|
197
|
+
};
|
|
198
|
+
creditorAgent?: {
|
|
199
|
+
financialInstitutionIdentification: {
|
|
200
|
+
bic?: string;
|
|
201
|
+
name?: string;
|
|
202
|
+
postalAddress?: {
|
|
203
|
+
addressLine?: string;
|
|
204
|
+
town?: string;
|
|
205
|
+
country?: string;
|
|
206
|
+
};
|
|
207
|
+
};
|
|
208
|
+
};
|
|
209
|
+
remittanceInformation?: {
|
|
210
|
+
unstructured?: string;
|
|
211
|
+
structured?: {
|
|
212
|
+
reference?: string;
|
|
213
|
+
};
|
|
214
|
+
};
|
|
215
|
+
instructionPriority?: 'NORM';
|
|
216
|
+
callbackUrl?: string;
|
|
217
|
+
confirmationPageUrl?: string;
|
|
218
|
+
transactionConfirmation?: {
|
|
219
|
+
email: string;
|
|
220
|
+
};
|
|
221
|
+
};
|
|
160
222
|
|
|
161
223
|
type ReferenceType = `${'VS' | 'SS' | 'KS'}:${number}`;
|
|
162
224
|
|
|
@@ -365,6 +427,7 @@ declare const FINBRICKS_ENDPOINTS: {
|
|
|
365
427
|
readonly TRANSACTION_INIT: "/transaction/platform/init";
|
|
366
428
|
readonly TRANSACTION_STATUS: "/transaction/platform/status";
|
|
367
429
|
readonly TRANSACTION_SEPA_INIT: "/transaction/platform/sepa/init";
|
|
430
|
+
readonly TRANSACTION_FOREIGN_INIT: "/transaction/platform/foreign/init";
|
|
368
431
|
readonly TRANSACTION_BATCH_INIT: "/transaction/platform/batchPayment/init";
|
|
369
432
|
readonly BATCH_STATUS: "/transaction/platform/batchPayment/status";
|
|
370
433
|
};
|
|
@@ -417,6 +480,7 @@ declare abstract class FinbricksConnector extends IBankConnector {
|
|
|
417
480
|
initiateBatchFromPayments({ payments, }: {
|
|
418
481
|
payments: PaymentPreparedInsertType[];
|
|
419
482
|
}): Promise<InitiatedBatch>;
|
|
483
|
+
initiateForeignPayment(payment: IncomingPaymentMessage): Promise<InitiatedPayment>;
|
|
420
484
|
initiateSEPAPayment(payment: IncomingPaymentMessage): Promise<InitiatedPayment>;
|
|
421
485
|
initiateSinglePayment(payment: PaymentPreparedInsertType): Promise<InitiatedPayment>;
|
|
422
486
|
getAllAccountPayments({ account, filter, }: {
|
|
@@ -1062,4 +1126,4 @@ type OneTimeTokenPatchType = z.infer<typeof ottUpdateSchema>;
|
|
|
1062
1126
|
type OneTimeTokenSelectType = z.infer<typeof ottSelectSchema>;
|
|
1063
1127
|
|
|
1064
1128
|
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 };
|
|
1065
|
-
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 };
|
|
1129
|
+
export type { BankPaymentEvent, ErsteAuthenticationResponse, ErsteBatchPaymentInitiationResponse, ErsteIncomingPaymentResponse, ErsteObtainAuthorizationURLResponse, ErstePaymentInitiationResponse, FinbricksAccount, FinbricksAccountTransactionsResponse, FinbricksAccountsListResponse, FinbricksAuthTokenResponse, FinbricksBatchBody, FinbricksBatchResponse, FinbricksBatchStatus, FinbricksConnectAccountBody, FinbricksConnectAccountResponse, FinbricksConnectorConfig, FinbricksEndpoint, FinbricksEndpointPath, FinbricksFetchConfig, FinbricksForeignPaymentBody, FinbricksGetBatchStatusBody, FinbricksGetBatchStatusResponse, FinbricksGetTransactionStatusResponse, FinbricksJWSData, FinbricksPaymentBody, FinbricksPaymentResponse, FinbricksProvider, FinbricksRequestInit, FinbricksTransactionStatus, OneTimeTokenInsertType, OneTimeTokenPatchType, OneTimeTokenSelectType, OneTimeTokenUpdateType };
|
package/dist/types.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export { A as ACCOUNT_STATUSES, B as BATCH_STATUES, B as BATCH_STATUSES, C as CHARGE_BEARERS, g as CONNECTOR_KEYS, f as COUNTRY_CODES, h as CREDENTIALS_TYPES, E as ErsteConnector, b as FINBRICKS_ENDPOINTS, a as FinbricksClient, F as FinbricksConnector, I as IBankConnector, c as INSTRUCTION_PRIORITIES, M as MockConnector, e as PAYMENT_DIRECTIONS, d as PAYMENT_STATUSES, P as PAYMENT_TYPES, T as TOKEN_TYPES, l as accountCredentialsInsertSchema, n as accountCredentialsSelectSchema, m as accountCredentialsUpdateSchema, i as accountInsertSchema, k as accountSelectSchema, j as accountUpdateSchema, o as ottInsertSchema, r as ottSelectSchema, q as ottUpdateSchema, p as paymentInsertTypeZod, s as signFinbricksJws, u as useFinbricksFetch } from './shared/bank.
|
|
2
|
-
export { M as MockCobsConnector } from './shared/bank.
|
|
1
|
+
export { A as ACCOUNT_STATUSES, B as BATCH_STATUES, B as BATCH_STATUSES, C as CHARGE_BEARERS, g as CONNECTOR_KEYS, f as COUNTRY_CODES, h as CREDENTIALS_TYPES, E as ErsteConnector, b as FINBRICKS_ENDPOINTS, a as FinbricksClient, F as FinbricksConnector, I as IBankConnector, c as INSTRUCTION_PRIORITIES, M as MockConnector, e as PAYMENT_DIRECTIONS, d as PAYMENT_STATUSES, P as PAYMENT_TYPES, T as TOKEN_TYPES, l as accountCredentialsInsertSchema, n as accountCredentialsSelectSchema, m as accountCredentialsUpdateSchema, i as accountInsertSchema, k as accountSelectSchema, j as accountUpdateSchema, o as ottInsertSchema, r as ottSelectSchema, q as ottUpdateSchema, p as paymentInsertTypeZod, s as signFinbricksJws, u as useFinbricksFetch } from './shared/bank.W4h6Dlzi.mjs';
|
|
2
|
+
export { M as MockCobsConnector } from './shared/bank.BvXwHpBp.mjs';
|
|
3
3
|
export { BANK_CODES, CURRENCY_CODES } from '@develit-io/general-codes';
|
|
4
4
|
import '@develit-io/backend-sdk';
|
|
5
5
|
import 'drizzle-orm/sqlite-core';
|
package/package.json
CHANGED
|
@@ -1,284 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
const cloudflare_workers = require('cloudflare:workers');
|
|
4
|
-
const cloudflare_workflows = require('cloudflare:workflows');
|
|
5
|
-
const d1 = require('drizzle-orm/d1');
|
|
6
|
-
const database_schema = require('./bank.PDmcU0T-.cjs');
|
|
7
|
-
const backendSdk = require('@develit-io/backend-sdk');
|
|
8
|
-
const drizzleOrm = require('drizzle-orm');
|
|
9
|
-
const mockCobs_connector = require('./bank.BcCfzRPi.cjs');
|
|
10
|
-
require('jose');
|
|
11
|
-
require('@develit-io/general-codes');
|
|
12
|
-
|
|
13
|
-
const createPaymentCommand = (db, { payment }) => {
|
|
14
|
-
return {
|
|
15
|
-
command: db.insert(database_schema.tables.payment).values({
|
|
16
|
-
...payment,
|
|
17
|
-
creditorIban: payment.creditor.iban,
|
|
18
|
-
debtorIban: payment.debtor.iban
|
|
19
|
-
}).returning()
|
|
20
|
-
};
|
|
21
|
-
};
|
|
22
|
-
|
|
23
|
-
const updatePaymentCommand = (db, { payment }) => {
|
|
24
|
-
return {
|
|
25
|
-
command: db.update(database_schema.tables.payment).set(payment).where(drizzleOrm.eq(database_schema.tables.payment.id, payment.id)).returning()
|
|
26
|
-
};
|
|
27
|
-
};
|
|
28
|
-
|
|
29
|
-
const updateAccountLastSyncCommand = (db, { lastSyncedAt, accountId }) => {
|
|
30
|
-
const command = db.update(database_schema.tables.account).set({
|
|
31
|
-
lastSyncedAt
|
|
32
|
-
}).where(drizzleOrm.eq(database_schema.tables.account.id, accountId)).returning();
|
|
33
|
-
return {
|
|
34
|
-
command
|
|
35
|
-
};
|
|
36
|
-
};
|
|
37
|
-
|
|
38
|
-
const getAccountByIdQuery = async (db, { accountId }) => {
|
|
39
|
-
return await db.select().from(database_schema.tables.account).where(drizzleOrm.eq(database_schema.tables.account.id, accountId)).get();
|
|
40
|
-
};
|
|
41
|
-
|
|
42
|
-
const getCredentialsByAccountId = async (db, { accountId }) => {
|
|
43
|
-
const cred = await db.select().from(database_schema.tables.accountCredentials).where(drizzleOrm.eq(database_schema.tables.accountCredentials.accountId, accountId)).get();
|
|
44
|
-
return cred;
|
|
45
|
-
};
|
|
46
|
-
|
|
47
|
-
const getPaymentsByBankRefIdsQuery = async (db, { ids }) => {
|
|
48
|
-
return await db.select().from(database_schema.tables.payment).where(drizzleOrm.inArray(database_schema.tables.payment.bankRefId, ids));
|
|
49
|
-
};
|
|
50
|
-
|
|
51
|
-
class CreditasConnector extends database_schema.FinbricksConnector {
|
|
52
|
-
constructor(config) {
|
|
53
|
-
super("CREDITAS", config);
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
class FioConnector extends database_schema.FinbricksConnector {
|
|
58
|
-
constructor(config) {
|
|
59
|
-
super("FIO", config);
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
class MonetaConnector extends database_schema.FinbricksConnector {
|
|
64
|
-
constructor(config) {
|
|
65
|
-
super("MONETA", config);
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
const initiateConnector = ({
|
|
70
|
-
bank,
|
|
71
|
-
env,
|
|
72
|
-
connectedAccounts
|
|
73
|
-
}) => {
|
|
74
|
-
switch (bank) {
|
|
75
|
-
case "ERSTE":
|
|
76
|
-
return new database_schema.ErsteConnector({
|
|
77
|
-
API_KEY: env.ERSTE_API_KEY,
|
|
78
|
-
CLIENT_ID: env.ERSTE_CLIENT_ID,
|
|
79
|
-
CLIENT_SECRET: env.ERSTE_CLIENT_SECRET,
|
|
80
|
-
REDIRECT_URI: env.REDIRECT_URI,
|
|
81
|
-
AUTH_URI: env.ERSTE_AUTH_URI,
|
|
82
|
-
PAYMENTS_URI: env.ERSTE_PAYMENTS_URI,
|
|
83
|
-
ACCOUNTS_URI: env.ERSTE_ACCOUNTS_URI,
|
|
84
|
-
connectedAccounts
|
|
85
|
-
});
|
|
86
|
-
case "CREDITAS":
|
|
87
|
-
return new CreditasConnector({
|
|
88
|
-
BASE_URI: env.FINBRICKS_BASE_URI,
|
|
89
|
-
MERCHANT_ID: env.FINBRICKS_MERCHANT_ID,
|
|
90
|
-
PRIVATE_KEY_PEM: env.FINBRICKS_PRIVATE_KEY_PEM,
|
|
91
|
-
REDIRECT_URI: env.REDIRECT_URI,
|
|
92
|
-
connectedAccounts
|
|
93
|
-
});
|
|
94
|
-
case "MOCK_COBS":
|
|
95
|
-
return new mockCobs_connector.MockCobsConnector({
|
|
96
|
-
BASE_URI: env.FINBRICKS_BASE_URI,
|
|
97
|
-
MERCHANT_ID: env.FINBRICKS_MERCHANT_ID,
|
|
98
|
-
PRIVATE_KEY_PEM: env.FINBRICKS_PRIVATE_KEY_PEM,
|
|
99
|
-
REDIRECT_URI: env.REDIRECT_URI,
|
|
100
|
-
connectedAccounts
|
|
101
|
-
});
|
|
102
|
-
case "FIO":
|
|
103
|
-
return new FioConnector({
|
|
104
|
-
BASE_URI: env.FINBRICKS_BASE_URI,
|
|
105
|
-
MERCHANT_ID: env.FINBRICKS_MERCHANT_ID,
|
|
106
|
-
PRIVATE_KEY_PEM: env.FINBRICKS_PRIVATE_KEY_PEM,
|
|
107
|
-
REDIRECT_URI: env.REDIRECT_URI,
|
|
108
|
-
connectedAccounts
|
|
109
|
-
});
|
|
110
|
-
case "MONETA":
|
|
111
|
-
return new MonetaConnector({
|
|
112
|
-
BASE_URI: env.FINBRICKS_BASE_URI,
|
|
113
|
-
MERCHANT_ID: env.FINBRICKS_MERCHANT_ID,
|
|
114
|
-
PRIVATE_KEY_PEM: env.FINBRICKS_PRIVATE_KEY_PEM,
|
|
115
|
-
REDIRECT_URI: env.REDIRECT_URI,
|
|
116
|
-
connectedAccounts
|
|
117
|
-
});
|
|
118
|
-
default:
|
|
119
|
-
return new database_schema.MockConnector();
|
|
120
|
-
}
|
|
121
|
-
};
|
|
122
|
-
|
|
123
|
-
function pushToQueue(queue, message) {
|
|
124
|
-
if (!Array.isArray(message)) return queue.send(message, { contentType: "v8" });
|
|
125
|
-
return queue.sendBatch(
|
|
126
|
-
message.map((m) => ({
|
|
127
|
-
body: m,
|
|
128
|
-
contentType: "v8"
|
|
129
|
-
}))
|
|
130
|
-
);
|
|
131
|
-
}
|
|
132
|
-
class SyncAccountPaymentsWorkflow extends cloudflare_workers.WorkflowEntrypoint {
|
|
133
|
-
async run(event, step) {
|
|
134
|
-
const { accountId } = event.payload;
|
|
135
|
-
const db = d1.drizzle(this.env.BANK_D1, { schema: database_schema.tables });
|
|
136
|
-
while (true) {
|
|
137
|
-
const account = await step.do("load account", async () => {
|
|
138
|
-
const account2 = await getAccountByIdQuery(db, { accountId });
|
|
139
|
-
if (!account2) {
|
|
140
|
-
throw new cloudflare_workflows.NonRetryableError(`Bank account not found: ${accountId}`);
|
|
141
|
-
}
|
|
142
|
-
return account2;
|
|
143
|
-
});
|
|
144
|
-
if (!account.lastSyncedAt) {
|
|
145
|
-
throw new Error(`lastSyncedAt is not set for account: ${accountId}`);
|
|
146
|
-
}
|
|
147
|
-
const credentials = await step.do(
|
|
148
|
-
"load account credentials",
|
|
149
|
-
async () => {
|
|
150
|
-
const credentials2 = await getCredentialsByAccountId(db, { accountId });
|
|
151
|
-
if (!credentials2) {
|
|
152
|
-
throw new cloudflare_workflows.NonRetryableError(
|
|
153
|
-
`No credentials found for account: ${accountId}`
|
|
154
|
-
);
|
|
155
|
-
}
|
|
156
|
-
return credentials2;
|
|
157
|
-
}
|
|
158
|
-
);
|
|
159
|
-
const payments = await step.do(
|
|
160
|
-
"fetch bank payments",
|
|
161
|
-
{
|
|
162
|
-
retries: { limit: 5, delay: 2e3, backoff: "constant" },
|
|
163
|
-
timeout: "30 seconds"
|
|
164
|
-
},
|
|
165
|
-
async () => {
|
|
166
|
-
const connector = initiateConnector({
|
|
167
|
-
env: this.env,
|
|
168
|
-
bank: account.connectorKey,
|
|
169
|
-
connectedAccounts: [
|
|
170
|
-
{
|
|
171
|
-
...account,
|
|
172
|
-
iban: account.iban,
|
|
173
|
-
token: credentials.value
|
|
174
|
-
}
|
|
175
|
-
]
|
|
176
|
-
});
|
|
177
|
-
const fetched = await connector.getAllAccountPayments({
|
|
178
|
-
environment: this.env.ENVIRONMENT,
|
|
179
|
-
db,
|
|
180
|
-
account,
|
|
181
|
-
filter: { dateFrom: account.lastSyncedAt }
|
|
182
|
-
});
|
|
183
|
-
return fetched.map((p) => ({
|
|
184
|
-
...p,
|
|
185
|
-
direction: database_schema.getPaymentDirection(p, account.iban)
|
|
186
|
-
}));
|
|
187
|
-
}
|
|
188
|
-
);
|
|
189
|
-
if (payments.length) {
|
|
190
|
-
const bankRefIds = payments.map((payment) => payment.bankRefId).filter(Boolean);
|
|
191
|
-
const existing = await step.do("load existing payments", async () => {
|
|
192
|
-
return await getPaymentsByBankRefIdsQuery(db, {
|
|
193
|
-
ids: bankRefIds
|
|
194
|
-
});
|
|
195
|
-
});
|
|
196
|
-
const paymentsToUpdate = payments.filter(
|
|
197
|
-
(p) => existing.some((e) => e.bankRefId === p.bankRefId)
|
|
198
|
-
);
|
|
199
|
-
const paymentsToCreate = payments.filter(
|
|
200
|
-
(p) => !existing.some((e) => e.bankRefId === p.bankRefId)
|
|
201
|
-
);
|
|
202
|
-
await step.do("process payments and update lastSyncAt", async () => {
|
|
203
|
-
const eventsToEmit = [];
|
|
204
|
-
const updateCommands = paymentsToUpdate.map(
|
|
205
|
-
(p) => updatePaymentCommand(db, { payment: p }).command
|
|
206
|
-
);
|
|
207
|
-
eventsToEmit.push(
|
|
208
|
-
...paymentsToUpdate.map((p) => ({
|
|
209
|
-
eventType: "BANK_PAYMENT",
|
|
210
|
-
eventSignal: "paymentUpdated",
|
|
211
|
-
bankPayment: p,
|
|
212
|
-
metadata: {
|
|
213
|
-
correlationId: p.correlationId,
|
|
214
|
-
entityId: p.id,
|
|
215
|
-
idempotencySuffix: p.status,
|
|
216
|
-
timestamp: (/* @__PURE__ */ new Date()).toDateString()
|
|
217
|
-
}
|
|
218
|
-
}))
|
|
219
|
-
);
|
|
220
|
-
const createCommands = paymentsToCreate.map(
|
|
221
|
-
(p) => createPaymentCommand(db, { payment: p }).command
|
|
222
|
-
);
|
|
223
|
-
eventsToEmit.push(
|
|
224
|
-
...paymentsToCreate.map((p) => ({
|
|
225
|
-
eventType: "BANK_PAYMENT",
|
|
226
|
-
eventSignal: "paymentCreated",
|
|
227
|
-
bankPayment: p,
|
|
228
|
-
metadata: {
|
|
229
|
-
correlationId: p.correlationId,
|
|
230
|
-
entityId: p.id,
|
|
231
|
-
timestamp: (/* @__PURE__ */ new Date()).toDateString()
|
|
232
|
-
}
|
|
233
|
-
}))
|
|
234
|
-
);
|
|
235
|
-
const latest = payments.reduce((current, p) => {
|
|
236
|
-
return new Date(p.processedAt).getTime() > new Date(current.processedAt).getTime() ? p : current;
|
|
237
|
-
}, payments[0]);
|
|
238
|
-
const updateLastSyncCommand = updateAccountLastSyncCommand(db, {
|
|
239
|
-
accountId: account.id,
|
|
240
|
-
lastSyncedAt: latest.processedAt
|
|
241
|
-
}).command;
|
|
242
|
-
if (eventsToEmit.length) {
|
|
243
|
-
await db.batch(
|
|
244
|
-
backendSdk.asNonEmpty([
|
|
245
|
-
updateLastSyncCommand,
|
|
246
|
-
...updateCommands,
|
|
247
|
-
...createCommands
|
|
248
|
-
])
|
|
249
|
-
);
|
|
250
|
-
await pushToQueue(
|
|
251
|
-
this.env.QUEUE_BUS_QUEUE,
|
|
252
|
-
eventsToEmit
|
|
253
|
-
);
|
|
254
|
-
}
|
|
255
|
-
return {
|
|
256
|
-
payments: payments.length,
|
|
257
|
-
updated: paymentsToUpdate.length,
|
|
258
|
-
created: paymentsToCreate.length,
|
|
259
|
-
eventsEmitted: eventsToEmit.length,
|
|
260
|
-
lastSyncedAt: latest?.createdAt
|
|
261
|
-
};
|
|
262
|
-
});
|
|
263
|
-
}
|
|
264
|
-
await step.sleep(
|
|
265
|
-
"Sleep for next sync",
|
|
266
|
-
`${account.syncIntervalS} seconds`
|
|
267
|
-
);
|
|
268
|
-
}
|
|
269
|
-
}
|
|
270
|
-
}
|
|
271
|
-
|
|
272
|
-
const workflows = {
|
|
273
|
-
__proto__: null,
|
|
274
|
-
SyncAccountPaymentsWorkflow: SyncAccountPaymentsWorkflow
|
|
275
|
-
};
|
|
276
|
-
|
|
277
|
-
exports.SyncAccountPaymentsWorkflow = SyncAccountPaymentsWorkflow;
|
|
278
|
-
exports.createPaymentCommand = createPaymentCommand;
|
|
279
|
-
exports.getCredentialsByAccountId = getCredentialsByAccountId;
|
|
280
|
-
exports.getPaymentsByBankRefIdsQuery = getPaymentsByBankRefIdsQuery;
|
|
281
|
-
exports.initiateConnector = initiateConnector;
|
|
282
|
-
exports.updateAccountLastSyncCommand = updateAccountLastSyncCommand;
|
|
283
|
-
exports.updatePaymentCommand = updatePaymentCommand;
|
|
284
|
-
exports.workflows = workflows;
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { WorkflowEntrypoint, WorkflowEvent, WorkflowStep } from 'cloudflare:workers';
|
|
2
|
-
|
|
3
|
-
type Params = {
|
|
4
|
-
accountId: string;
|
|
5
|
-
};
|
|
6
|
-
declare class SyncAccountPaymentsWorkflow extends WorkflowEntrypoint<BankEnv, Params> {
|
|
7
|
-
run(event: WorkflowEvent<Params>, step: WorkflowStep): Promise<void>;
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
type workflows_SyncAccountPaymentsWorkflow = SyncAccountPaymentsWorkflow;
|
|
11
|
-
declare const workflows_SyncAccountPaymentsWorkflow: typeof SyncAccountPaymentsWorkflow;
|
|
12
|
-
declare namespace workflows {
|
|
13
|
-
export {
|
|
14
|
-
workflows_SyncAccountPaymentsWorkflow as SyncAccountPaymentsWorkflow,
|
|
15
|
-
};
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
export { SyncAccountPaymentsWorkflow as S, workflows as w };
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { WorkflowEntrypoint, WorkflowEvent, WorkflowStep } from 'cloudflare:workers';
|
|
2
|
-
|
|
3
|
-
type Params = {
|
|
4
|
-
accountId: string;
|
|
5
|
-
};
|
|
6
|
-
declare class SyncAccountPaymentsWorkflow extends WorkflowEntrypoint<BankEnv, Params> {
|
|
7
|
-
run(event: WorkflowEvent<Params>, step: WorkflowStep): Promise<void>;
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
type workflows_SyncAccountPaymentsWorkflow = SyncAccountPaymentsWorkflow;
|
|
11
|
-
declare const workflows_SyncAccountPaymentsWorkflow: typeof SyncAccountPaymentsWorkflow;
|
|
12
|
-
declare namespace workflows {
|
|
13
|
-
export {
|
|
14
|
-
workflows_SyncAccountPaymentsWorkflow as SyncAccountPaymentsWorkflow,
|
|
15
|
-
};
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
export { SyncAccountPaymentsWorkflow as S, workflows as w };
|