@develit-services/ledger 0.3.0 → 0.3.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.
- package/dist/database/schema.cjs +2 -2
- 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 +2 -2
- package/dist/export/worker.cjs +73 -20
- package/dist/export/worker.d.cts +6 -4
- package/dist/export/worker.d.mts +6 -4
- package/dist/export/worker.d.ts +6 -4
- package/dist/export/worker.mjs +55 -2
- package/dist/export/wrangler.d.cts +1 -1
- package/dist/export/wrangler.d.mts +1 -1
- package/dist/export/wrangler.d.ts +1 -1
- package/dist/shared/{ledger.CvKXXw9R.mjs → ledger.BGgIPMu-.mjs} +2 -2
- package/dist/shared/{ledger.229hTbXo.mjs → ledger.BVNtjljl.mjs} +13 -3
- package/dist/shared/{ledger.B2SLAQpo.cjs → ledger.C7cMVCgk.cjs} +4 -4
- package/dist/shared/{ledger.DHX1YtaC.d.ts → ledger.CDdw0Nyc.d.ts} +34 -5
- package/dist/shared/{ledger.D9n1klaX.d.cts → ledger.CLVyCzRb.d.cts} +41 -521
- package/dist/shared/{ledger.D9n1klaX.d.mts → ledger.CLVyCzRb.d.mts} +41 -521
- package/dist/shared/{ledger.D9n1klaX.d.ts → ledger.CLVyCzRb.d.ts} +41 -521
- package/dist/shared/{ledger.o5dDJQGc.d.mts → ledger.D7boja6V.d.cts} +34 -5
- package/dist/shared/{ledger.B9-7wKL6.d.cts → ledger.D_uHoy5E.d.mts} +34 -5
- package/dist/shared/{ledger.C6xAPWKq.cjs → ledger.Dfi_K5W2.cjs} +13 -2
- package/dist/shared/{ledger.Ce2yPDUS.d.cts → ledger.VQWxyeV6.d.cts} +1 -1
- package/dist/shared/{ledger.Ce2yPDUS.d.mts → ledger.VQWxyeV6.d.mts} +1 -1
- package/dist/shared/{ledger.Ce2yPDUS.d.ts → ledger.VQWxyeV6.d.ts} +1 -1
- package/dist/types.cjs +35 -34
- package/dist/types.d.cts +4 -4
- package/dist/types.d.mts +4 -4
- package/dist/types.d.ts +4 -4
- package/dist/types.mjs +1 -1
- package/package.json +4 -1
package/dist/database/schema.cjs
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
const database_schema = require('../shared/ledger.
|
|
3
|
+
const database_schema = require('../shared/ledger.C7cMVCgk.cjs');
|
|
4
4
|
require('@develit-io/backend-sdk');
|
|
5
5
|
require('drizzle-orm');
|
|
6
6
|
require('drizzle-orm/sqlite-core');
|
|
7
|
-
require('../shared/ledger.
|
|
7
|
+
require('../shared/ledger.Dfi_K5W2.cjs');
|
|
8
8
|
require('zod');
|
|
9
9
|
require('@develit-io/general-codes');
|
|
10
10
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { F as account, G as accountIdentifier, H as accountIdentifierMapping,
|
|
1
|
+
export { F as account, G as accountIdentifier, H as accountIdentifierMapping, J as accountIdentifierMappingRelations, K as accountIdentifierRelations, L as accountRelations, M as entry, N as transaction } from '../shared/ledger.CLVyCzRb.cjs';
|
|
2
2
|
import 'drizzle-orm';
|
|
3
3
|
import 'drizzle-orm/sqlite-core';
|
|
4
4
|
import '@develit-io/backend-sdk';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { F as account, G as accountIdentifier, H as accountIdentifierMapping,
|
|
1
|
+
export { F as account, G as accountIdentifier, H as accountIdentifierMapping, J as accountIdentifierMappingRelations, K as accountIdentifierRelations, L as accountRelations, M as entry, N as transaction } from '../shared/ledger.CLVyCzRb.mjs';
|
|
2
2
|
import 'drizzle-orm';
|
|
3
3
|
import 'drizzle-orm/sqlite-core';
|
|
4
4
|
import '@develit-io/backend-sdk';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { F as account, G as accountIdentifier, H as accountIdentifierMapping,
|
|
1
|
+
export { F as account, G as accountIdentifier, H as accountIdentifierMapping, J as accountIdentifierMappingRelations, K as accountIdentifierRelations, L as accountRelations, M as entry, N as transaction } from '../shared/ledger.CLVyCzRb.js';
|
|
2
2
|
import 'drizzle-orm';
|
|
3
3
|
import 'drizzle-orm/sqlite-core';
|
|
4
4
|
import '@develit-io/backend-sdk';
|
package/dist/database/schema.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
export { a as account, b as accountIdentifier, c as accountIdentifierMapping,
|
|
1
|
+
export { a as account, b as accountIdentifier, c as accountIdentifierMapping, d as accountIdentifierMappingRelations, e as accountIdentifierRelations, f as accountRelations, g as entry, t as transaction } from '../shared/ledger.BGgIPMu-.mjs';
|
|
2
2
|
import '@develit-io/backend-sdk';
|
|
3
3
|
import 'drizzle-orm';
|
|
4
4
|
import 'drizzle-orm/sqlite-core';
|
|
5
|
-
import '../shared/ledger.
|
|
5
|
+
import '../shared/ledger.BVNtjljl.mjs';
|
|
6
6
|
import 'zod';
|
|
7
7
|
import '@develit-io/general-codes';
|
package/dist/export/worker.cjs
CHANGED
|
@@ -5,9 +5,9 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
5
5
|
const backendSdk = require('@develit-io/backend-sdk');
|
|
6
6
|
const cloudflare_workers = require('cloudflare:workers');
|
|
7
7
|
const d1 = require('drizzle-orm/d1');
|
|
8
|
-
const database_schema = require('../shared/ledger.
|
|
8
|
+
const database_schema = require('../shared/ledger.C7cMVCgk.cjs');
|
|
9
9
|
const drizzleOrm = require('drizzle-orm');
|
|
10
|
-
const
|
|
10
|
+
const updateTransactionStatus = require('../shared/ledger.Dfi_K5W2.cjs');
|
|
11
11
|
require('@develit-io/general-codes');
|
|
12
12
|
require('drizzle-orm/sqlite-core');
|
|
13
13
|
require('zod');
|
|
@@ -315,7 +315,7 @@ let LedgerServiceBase = class extends backendSdk.develitWorker(
|
|
|
315
315
|
return this.handleAction(
|
|
316
316
|
{
|
|
317
317
|
data: input,
|
|
318
|
-
schema:
|
|
318
|
+
schema: updateTransactionStatus.createTransactionInputSchema
|
|
319
319
|
},
|
|
320
320
|
{ successMessage: "Transaction successfully created." },
|
|
321
321
|
async (params) => {
|
|
@@ -397,7 +397,7 @@ let LedgerServiceBase = class extends backendSdk.develitWorker(
|
|
|
397
397
|
}
|
|
398
398
|
async matchTransaction(input) {
|
|
399
399
|
return this.handleAction(
|
|
400
|
-
{ data: input, schema:
|
|
400
|
+
{ data: input, schema: updateTransactionStatus.matchTransactionInputSchema },
|
|
401
401
|
{ successMessage: "Transaction successfully matched." },
|
|
402
402
|
async (params) => {
|
|
403
403
|
const { transactionId, completedAt, paymentId } = params;
|
|
@@ -444,7 +444,7 @@ let LedgerServiceBase = class extends backendSdk.develitWorker(
|
|
|
444
444
|
}
|
|
445
445
|
async failTransaction(input) {
|
|
446
446
|
return this.handleAction(
|
|
447
|
-
{ data: input, schema:
|
|
447
|
+
{ data: input, schema: updateTransactionStatus.failTransactionInputSchema },
|
|
448
448
|
{ successMessage: "Transaction successfully failed." },
|
|
449
449
|
async (params) => {
|
|
450
450
|
const { transactionId, completedAt, statusReason } = params;
|
|
@@ -493,7 +493,7 @@ let LedgerServiceBase = class extends backendSdk.develitWorker(
|
|
|
493
493
|
}
|
|
494
494
|
async cancelTransaction(input) {
|
|
495
495
|
return this.handleAction(
|
|
496
|
-
{ data: input, schema:
|
|
496
|
+
{ data: input, schema: updateTransactionStatus.cancelTransactionInputSchema },
|
|
497
497
|
{ successMessage: "Transaction successfully cancelled." },
|
|
498
498
|
async ({ transactionId, statusReason }) => {
|
|
499
499
|
const existingTransaction = await getTransactionByIdQuery(
|
|
@@ -540,7 +540,7 @@ let LedgerServiceBase = class extends backendSdk.develitWorker(
|
|
|
540
540
|
}
|
|
541
541
|
async getTransactionById(input) {
|
|
542
542
|
return this.handleAction(
|
|
543
|
-
{ data: input, schema:
|
|
543
|
+
{ data: input, schema: updateTransactionStatus.getTransactionByIdInputSchema },
|
|
544
544
|
{ successMessage: "Transaction successfully obtained." },
|
|
545
545
|
async (params) => {
|
|
546
546
|
const { id } = params;
|
|
@@ -551,7 +551,7 @@ let LedgerServiceBase = class extends backendSdk.develitWorker(
|
|
|
551
551
|
}
|
|
552
552
|
async getTransactionsByReferenceId(input) {
|
|
553
553
|
return this.handleAction(
|
|
554
|
-
{ data: input, schema:
|
|
554
|
+
{ data: input, schema: updateTransactionStatus.getTransactionsByReferenceIdInputSchema },
|
|
555
555
|
{ successMessage: "Transaction successfully obtained." },
|
|
556
556
|
async (params) => {
|
|
557
557
|
const { referenceType, referenceId } = params;
|
|
@@ -566,7 +566,7 @@ let LedgerServiceBase = class extends backendSdk.develitWorker(
|
|
|
566
566
|
}
|
|
567
567
|
async getTransactions(input) {
|
|
568
568
|
return this.handleAction(
|
|
569
|
-
{ data: input, schema:
|
|
569
|
+
{ data: input, schema: updateTransactionStatus.getTransactionsInputSchema },
|
|
570
570
|
{ successMessage: "Transactions fetched successfully" },
|
|
571
571
|
async (pagination) => {
|
|
572
572
|
const { transactions, totalCount } = await getTransactionsWithPaginationQuery({
|
|
@@ -579,7 +579,7 @@ let LedgerServiceBase = class extends backendSdk.develitWorker(
|
|
|
579
579
|
}
|
|
580
580
|
async createAccount(input) {
|
|
581
581
|
return this.handleAction(
|
|
582
|
-
{ data: input, schema:
|
|
582
|
+
{ data: input, schema: updateTransactionStatus.createAccountInputSchema },
|
|
583
583
|
{ successMessage: "Account successfully created." },
|
|
584
584
|
async (params) => {
|
|
585
585
|
const { identifier, ...accountData } = params;
|
|
@@ -619,7 +619,7 @@ let LedgerServiceBase = class extends backendSdk.develitWorker(
|
|
|
619
619
|
}
|
|
620
620
|
async updateAccount(input) {
|
|
621
621
|
return this.handleAction(
|
|
622
|
-
{ data: input, schema:
|
|
622
|
+
{ data: input, schema: updateTransactionStatus.updateAccountInputSchema },
|
|
623
623
|
{ successMessage: "Account successfully updated." },
|
|
624
624
|
async (params) => {
|
|
625
625
|
const { accountId, ...updateData } = params;
|
|
@@ -653,7 +653,7 @@ let LedgerServiceBase = class extends backendSdk.develitWorker(
|
|
|
653
653
|
}
|
|
654
654
|
async deleteAccount(input) {
|
|
655
655
|
return this.handleAction(
|
|
656
|
-
{ data: input, schema:
|
|
656
|
+
{ data: input, schema: updateTransactionStatus.deleteAccountInputSchema },
|
|
657
657
|
{ successMessage: "Account successfully deleted." },
|
|
658
658
|
async (params) => {
|
|
659
659
|
const { accountId } = params;
|
|
@@ -668,7 +668,7 @@ let LedgerServiceBase = class extends backendSdk.develitWorker(
|
|
|
668
668
|
}
|
|
669
669
|
async getAccount(input) {
|
|
670
670
|
return this.handleAction(
|
|
671
|
-
{ data: input, schema:
|
|
671
|
+
{ data: input, schema: updateTransactionStatus.getAccountInputSchema },
|
|
672
672
|
{ successMessage: "Account successfully retrieved." },
|
|
673
673
|
async (params) => {
|
|
674
674
|
const { accountId } = params;
|
|
@@ -686,7 +686,7 @@ let LedgerServiceBase = class extends backendSdk.develitWorker(
|
|
|
686
686
|
}
|
|
687
687
|
async getAccountsByOwner(input) {
|
|
688
688
|
return this.handleAction(
|
|
689
|
-
{ data: input, schema:
|
|
689
|
+
{ data: input, schema: updateTransactionStatus.getAccountsByOwnerInputSchema },
|
|
690
690
|
{ successMessage: "Accounts successfully retrieved." },
|
|
691
691
|
async (params) => {
|
|
692
692
|
const { ownerId } = params;
|
|
@@ -697,7 +697,7 @@ let LedgerServiceBase = class extends backendSdk.develitWorker(
|
|
|
697
697
|
}
|
|
698
698
|
async listAccounts(input) {
|
|
699
699
|
return this.handleAction(
|
|
700
|
-
{ data: input, schema:
|
|
700
|
+
{ data: input, schema: updateTransactionStatus.listAccountsInputSchema },
|
|
701
701
|
{ successMessage: "Accounts successfully listed." },
|
|
702
702
|
async (params) => {
|
|
703
703
|
const {
|
|
@@ -725,7 +725,7 @@ let LedgerServiceBase = class extends backendSdk.develitWorker(
|
|
|
725
725
|
}
|
|
726
726
|
async getAccountIdentifierById(input) {
|
|
727
727
|
return this.handleAction(
|
|
728
|
-
{ data: input, schema:
|
|
728
|
+
{ data: input, schema: updateTransactionStatus.getAccountIdentifierInputSchema },
|
|
729
729
|
{ successMessage: "Account identifier successfully retrieved." },
|
|
730
730
|
async (params) => {
|
|
731
731
|
const { identifierId } = params;
|
|
@@ -746,7 +746,7 @@ let LedgerServiceBase = class extends backendSdk.develitWorker(
|
|
|
746
746
|
}
|
|
747
747
|
async listAccountIdentifiers(input) {
|
|
748
748
|
return this.handleAction(
|
|
749
|
-
{ data: input, schema:
|
|
749
|
+
{ data: input, schema: updateTransactionStatus.listAccountIdentifiersInputSchema },
|
|
750
750
|
{ successMessage: "Account identifiers successfully listed." },
|
|
751
751
|
async (params) => {
|
|
752
752
|
const { accountId } = params;
|
|
@@ -760,7 +760,7 @@ let LedgerServiceBase = class extends backendSdk.develitWorker(
|
|
|
760
760
|
}
|
|
761
761
|
async findAccountByIdentifier(input) {
|
|
762
762
|
return this.handleAction(
|
|
763
|
-
{ data: input, schema:
|
|
763
|
+
{ data: input, schema: updateTransactionStatus.findAccountByIdentifierInputSchema },
|
|
764
764
|
{ successMessage: "Account search completed." },
|
|
765
765
|
async (params) => {
|
|
766
766
|
const searchParams = params;
|
|
@@ -774,7 +774,7 @@ let LedgerServiceBase = class extends backendSdk.develitWorker(
|
|
|
774
774
|
}
|
|
775
775
|
async getAccountBalance(input) {
|
|
776
776
|
return this.handleAction(
|
|
777
|
-
{ data: input, schema:
|
|
777
|
+
{ data: input, schema: updateTransactionStatus.getAccountBalanceInputSchema },
|
|
778
778
|
{ successMessage: "Balance successfully obtained." },
|
|
779
779
|
async (params) => {
|
|
780
780
|
const { accountId } = params;
|
|
@@ -789,7 +789,7 @@ let LedgerServiceBase = class extends backendSdk.develitWorker(
|
|
|
789
789
|
}
|
|
790
790
|
async updateTransactionConfirmationSentAt(input) {
|
|
791
791
|
return this.handleAction(
|
|
792
|
-
{ data: input, schema:
|
|
792
|
+
{ data: input, schema: updateTransactionStatus.updateTransactionConfirmationSentAtInputSchema },
|
|
793
793
|
{ successMessage: "Confirmation email sent successfully" },
|
|
794
794
|
async ({ transactionId }) => {
|
|
795
795
|
const { command: transactionCommand } = updateTransactionConfirmationSentAtCommand({
|
|
@@ -801,6 +801,56 @@ let LedgerServiceBase = class extends backendSdk.develitWorker(
|
|
|
801
801
|
}
|
|
802
802
|
);
|
|
803
803
|
}
|
|
804
|
+
async updateTransactionStatus(input) {
|
|
805
|
+
return this.handleAction(
|
|
806
|
+
{ data: input, schema: updateTransactionStatus.updateTransactionStatusInputSchema },
|
|
807
|
+
{ successMessage: "Transaction status successfully updated." },
|
|
808
|
+
async (params) => {
|
|
809
|
+
const { transactionId, status, statusReason, paymentId, completedAt } = params;
|
|
810
|
+
const existingTransaction = await getTransactionByIdQuery(
|
|
811
|
+
this.db,
|
|
812
|
+
transactionId
|
|
813
|
+
);
|
|
814
|
+
if (!existingTransaction) {
|
|
815
|
+
throw backendSdk.createInternalError(null, {
|
|
816
|
+
message: "Transaction not found",
|
|
817
|
+
status: 404,
|
|
818
|
+
code: "NOT_FOUND"
|
|
819
|
+
});
|
|
820
|
+
}
|
|
821
|
+
const { command } = updateTransactionStatusCommand(this.db, {
|
|
822
|
+
transactionId,
|
|
823
|
+
status,
|
|
824
|
+
statusReason,
|
|
825
|
+
paymentId,
|
|
826
|
+
completedAt
|
|
827
|
+
});
|
|
828
|
+
const [updatedTransaction] = await this.db.batch([command]);
|
|
829
|
+
if (!updatedTransaction) {
|
|
830
|
+
throw backendSdk.createInternalError(null, {
|
|
831
|
+
message: "Failed to update transaction",
|
|
832
|
+
status: 500,
|
|
833
|
+
code: "INTERNAL_ERROR"
|
|
834
|
+
});
|
|
835
|
+
}
|
|
836
|
+
const transaction = backendSdk.first(updatedTransaction);
|
|
837
|
+
await this.pushToQueue(
|
|
838
|
+
this.env.QUEUE_BUS_QUEUE,
|
|
839
|
+
{
|
|
840
|
+
eventType: "LEDGER_TRANSACTION",
|
|
841
|
+
eventSignal: "updated",
|
|
842
|
+
ledgerTransaction: transaction,
|
|
843
|
+
metadata: {
|
|
844
|
+
correlationId: backendSdk.uuidv4(),
|
|
845
|
+
entityId: transaction.id,
|
|
846
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
847
|
+
}
|
|
848
|
+
}
|
|
849
|
+
);
|
|
850
|
+
return transaction;
|
|
851
|
+
}
|
|
852
|
+
);
|
|
853
|
+
}
|
|
804
854
|
};
|
|
805
855
|
__decorateClass([
|
|
806
856
|
backendSdk.action("create-transaction")
|
|
@@ -856,6 +906,9 @@ __decorateClass([
|
|
|
856
906
|
__decorateClass([
|
|
857
907
|
backendSdk.action("update-transaction-confirmation-sent-at")
|
|
858
908
|
], LedgerServiceBase.prototype, "updateTransactionConfirmationSentAt", 1);
|
|
909
|
+
__decorateClass([
|
|
910
|
+
backendSdk.action("update-transaction-status")
|
|
911
|
+
], LedgerServiceBase.prototype, "updateTransactionStatus", 1);
|
|
859
912
|
LedgerServiceBase = __decorateClass([
|
|
860
913
|
backendSdk.service("ledger")
|
|
861
914
|
], LedgerServiceBase);
|
package/dist/export/worker.d.cts
CHANGED
|
@@ -1,14 +1,15 @@
|
|
|
1
|
+
import * as _develit_io_backend_sdk from '@develit-io/backend-sdk';
|
|
1
2
|
import { IRPCResponse } from '@develit-io/backend-sdk';
|
|
2
|
-
import { DrizzleD1Database } from 'drizzle-orm/d1';
|
|
3
|
-
import { t as tables, C as CreateTransactionInput, a as CreateTransactionOutput, M as MatchTransactionInput, b as MatchTransactionOutput, F as FailTransactionInput, c as FailTransactionOutput, d as CancelTransactionInput, e as CancelTransactionOutput, G as GetTransactionByIdInput, f as GetTransactionByIdOutput, g as GetTransactionsByIdReferenceInput, h as GetTransactionsByReferenceIdOutput, i as GetTransactionsInput, j as GetTransactionsOutput, k as CreateAccountInput, l as CreateAccountOutput, U as UpdateAccountInput, m as UpdateAccountOutput, D as DeleteAccountInput, n as DeleteAccountOutput, o as GetAccountInput, p as GetAccountOutput, q as GetAccountsByOwnerInput, r as GetAccountsByOwnerOutput, L as ListAccountsInput, s as ListAccountsOutput, u as GetAccountIdentifierInput, v as GetAccountIdentifierOutput, w as ListAccountIdentifiersInput, x as ListAccountIdentifiersOutput, y as FindAccountByIdentifierInput, z as FindAccountByIdentifierOutput, A as GetAccountBalanceInput, B as GetAccountBalanceOutput, E as UpdateTransactionConfirmationSentAtInput, H as UpdateTransactionConfirmationSentAtOutput } from '../shared/ledger.B9-7wKL6.cjs';
|
|
4
3
|
import { WorkerEntrypoint } from 'cloudflare:workers';
|
|
4
|
+
import { DrizzleD1Database } from 'drizzle-orm/d1';
|
|
5
|
+
import { t as tables, C as CreateTransactionInput, a as CreateTransactionOutput, M as MatchTransactionInput, b as MatchTransactionOutput, F as FailTransactionInput, c as FailTransactionOutput, d as CancelTransactionInput, e as CancelTransactionOutput, G as GetTransactionByIdInput, f as GetTransactionByIdOutput, g as GetTransactionsByIdReferenceInput, h as GetTransactionsByReferenceIdOutput, i as GetTransactionsInput, j as GetTransactionsOutput, k as CreateAccountInput, l as CreateAccountOutput, U as UpdateAccountInput, m as UpdateAccountOutput, D as DeleteAccountInput, n as DeleteAccountOutput, o as GetAccountInput, p as GetAccountOutput, q as GetAccountsByOwnerInput, r as GetAccountsByOwnerOutput, L as ListAccountsInput, s as ListAccountsOutput, u as GetAccountIdentifierInput, v as GetAccountIdentifierOutput, w as ListAccountIdentifiersInput, x as ListAccountIdentifiersOutput, y as FindAccountByIdentifierInput, z as FindAccountByIdentifierOutput, A as GetAccountBalanceInput, B as GetAccountBalanceOutput, E as UpdateTransactionConfirmationSentAtInput, H as UpdateTransactionConfirmationSentAtOutput, I as UpdateTransactionStatusInput, J as UpdateTransactionStatusOutput } from '../shared/ledger.D7boja6V.cjs';
|
|
5
6
|
import 'zod';
|
|
6
|
-
import '../shared/ledger.
|
|
7
|
+
import '../shared/ledger.CLVyCzRb.cjs';
|
|
7
8
|
import 'drizzle-orm';
|
|
8
9
|
import 'drizzle-orm/sqlite-core';
|
|
9
10
|
import '@develit-io/general-codes';
|
|
10
11
|
|
|
11
|
-
declare const LedgerServiceBase_base: any;
|
|
12
|
+
declare const LedgerServiceBase_base: (abstract new (ctx: ExecutionContext, env: LedgerEnv) => WorkerEntrypoint<LedgerEnv, {}>) & (abstract new (...args: any[]) => _develit_io_backend_sdk.DevelitWorkerMethods);
|
|
12
13
|
declare class LedgerServiceBase extends LedgerServiceBase_base {
|
|
13
14
|
readonly db: DrizzleD1Database<typeof tables>;
|
|
14
15
|
constructor(ctx: ExecutionContext, env: LedgerEnv);
|
|
@@ -30,6 +31,7 @@ declare class LedgerServiceBase extends LedgerServiceBase_base {
|
|
|
30
31
|
findAccountByIdentifier(input: FindAccountByIdentifierInput): Promise<IRPCResponse<FindAccountByIdentifierOutput>>;
|
|
31
32
|
getAccountBalance(input: GetAccountBalanceInput): Promise<IRPCResponse<GetAccountBalanceOutput>>;
|
|
32
33
|
updateTransactionConfirmationSentAt(input: UpdateTransactionConfirmationSentAtInput): Promise<IRPCResponse<UpdateTransactionConfirmationSentAtOutput>>;
|
|
34
|
+
updateTransactionStatus(input: UpdateTransactionStatusInput): Promise<IRPCResponse<UpdateTransactionStatusOutput>>;
|
|
33
35
|
}
|
|
34
36
|
declare function defineLedgerService(): new (ctx: ExecutionContext, env: LedgerEnv) => LedgerServiceBase;
|
|
35
37
|
|
package/dist/export/worker.d.mts
CHANGED
|
@@ -1,14 +1,15 @@
|
|
|
1
|
+
import * as _develit_io_backend_sdk from '@develit-io/backend-sdk';
|
|
1
2
|
import { IRPCResponse } from '@develit-io/backend-sdk';
|
|
2
|
-
import { DrizzleD1Database } from 'drizzle-orm/d1';
|
|
3
|
-
import { t as tables, C as CreateTransactionInput, a as CreateTransactionOutput, M as MatchTransactionInput, b as MatchTransactionOutput, F as FailTransactionInput, c as FailTransactionOutput, d as CancelTransactionInput, e as CancelTransactionOutput, G as GetTransactionByIdInput, f as GetTransactionByIdOutput, g as GetTransactionsByIdReferenceInput, h as GetTransactionsByReferenceIdOutput, i as GetTransactionsInput, j as GetTransactionsOutput, k as CreateAccountInput, l as CreateAccountOutput, U as UpdateAccountInput, m as UpdateAccountOutput, D as DeleteAccountInput, n as DeleteAccountOutput, o as GetAccountInput, p as GetAccountOutput, q as GetAccountsByOwnerInput, r as GetAccountsByOwnerOutput, L as ListAccountsInput, s as ListAccountsOutput, u as GetAccountIdentifierInput, v as GetAccountIdentifierOutput, w as ListAccountIdentifiersInput, x as ListAccountIdentifiersOutput, y as FindAccountByIdentifierInput, z as FindAccountByIdentifierOutput, A as GetAccountBalanceInput, B as GetAccountBalanceOutput, E as UpdateTransactionConfirmationSentAtInput, H as UpdateTransactionConfirmationSentAtOutput } from '../shared/ledger.o5dDJQGc.mjs';
|
|
4
3
|
import { WorkerEntrypoint } from 'cloudflare:workers';
|
|
4
|
+
import { DrizzleD1Database } from 'drizzle-orm/d1';
|
|
5
|
+
import { t as tables, C as CreateTransactionInput, a as CreateTransactionOutput, M as MatchTransactionInput, b as MatchTransactionOutput, F as FailTransactionInput, c as FailTransactionOutput, d as CancelTransactionInput, e as CancelTransactionOutput, G as GetTransactionByIdInput, f as GetTransactionByIdOutput, g as GetTransactionsByIdReferenceInput, h as GetTransactionsByReferenceIdOutput, i as GetTransactionsInput, j as GetTransactionsOutput, k as CreateAccountInput, l as CreateAccountOutput, U as UpdateAccountInput, m as UpdateAccountOutput, D as DeleteAccountInput, n as DeleteAccountOutput, o as GetAccountInput, p as GetAccountOutput, q as GetAccountsByOwnerInput, r as GetAccountsByOwnerOutput, L as ListAccountsInput, s as ListAccountsOutput, u as GetAccountIdentifierInput, v as GetAccountIdentifierOutput, w as ListAccountIdentifiersInput, x as ListAccountIdentifiersOutput, y as FindAccountByIdentifierInput, z as FindAccountByIdentifierOutput, A as GetAccountBalanceInput, B as GetAccountBalanceOutput, E as UpdateTransactionConfirmationSentAtInput, H as UpdateTransactionConfirmationSentAtOutput, I as UpdateTransactionStatusInput, J as UpdateTransactionStatusOutput } from '../shared/ledger.D_uHoy5E.mjs';
|
|
5
6
|
import 'zod';
|
|
6
|
-
import '../shared/ledger.
|
|
7
|
+
import '../shared/ledger.CLVyCzRb.mjs';
|
|
7
8
|
import 'drizzle-orm';
|
|
8
9
|
import 'drizzle-orm/sqlite-core';
|
|
9
10
|
import '@develit-io/general-codes';
|
|
10
11
|
|
|
11
|
-
declare const LedgerServiceBase_base: any;
|
|
12
|
+
declare const LedgerServiceBase_base: (abstract new (ctx: ExecutionContext, env: LedgerEnv) => WorkerEntrypoint<LedgerEnv, {}>) & (abstract new (...args: any[]) => _develit_io_backend_sdk.DevelitWorkerMethods);
|
|
12
13
|
declare class LedgerServiceBase extends LedgerServiceBase_base {
|
|
13
14
|
readonly db: DrizzleD1Database<typeof tables>;
|
|
14
15
|
constructor(ctx: ExecutionContext, env: LedgerEnv);
|
|
@@ -30,6 +31,7 @@ declare class LedgerServiceBase extends LedgerServiceBase_base {
|
|
|
30
31
|
findAccountByIdentifier(input: FindAccountByIdentifierInput): Promise<IRPCResponse<FindAccountByIdentifierOutput>>;
|
|
31
32
|
getAccountBalance(input: GetAccountBalanceInput): Promise<IRPCResponse<GetAccountBalanceOutput>>;
|
|
32
33
|
updateTransactionConfirmationSentAt(input: UpdateTransactionConfirmationSentAtInput): Promise<IRPCResponse<UpdateTransactionConfirmationSentAtOutput>>;
|
|
34
|
+
updateTransactionStatus(input: UpdateTransactionStatusInput): Promise<IRPCResponse<UpdateTransactionStatusOutput>>;
|
|
33
35
|
}
|
|
34
36
|
declare function defineLedgerService(): new (ctx: ExecutionContext, env: LedgerEnv) => LedgerServiceBase;
|
|
35
37
|
|
package/dist/export/worker.d.ts
CHANGED
|
@@ -1,14 +1,15 @@
|
|
|
1
|
+
import * as _develit_io_backend_sdk from '@develit-io/backend-sdk';
|
|
1
2
|
import { IRPCResponse } from '@develit-io/backend-sdk';
|
|
2
|
-
import { DrizzleD1Database } from 'drizzle-orm/d1';
|
|
3
|
-
import { t as tables, C as CreateTransactionInput, a as CreateTransactionOutput, M as MatchTransactionInput, b as MatchTransactionOutput, F as FailTransactionInput, c as FailTransactionOutput, d as CancelTransactionInput, e as CancelTransactionOutput, G as GetTransactionByIdInput, f as GetTransactionByIdOutput, g as GetTransactionsByIdReferenceInput, h as GetTransactionsByReferenceIdOutput, i as GetTransactionsInput, j as GetTransactionsOutput, k as CreateAccountInput, l as CreateAccountOutput, U as UpdateAccountInput, m as UpdateAccountOutput, D as DeleteAccountInput, n as DeleteAccountOutput, o as GetAccountInput, p as GetAccountOutput, q as GetAccountsByOwnerInput, r as GetAccountsByOwnerOutput, L as ListAccountsInput, s as ListAccountsOutput, u as GetAccountIdentifierInput, v as GetAccountIdentifierOutput, w as ListAccountIdentifiersInput, x as ListAccountIdentifiersOutput, y as FindAccountByIdentifierInput, z as FindAccountByIdentifierOutput, A as GetAccountBalanceInput, B as GetAccountBalanceOutput, E as UpdateTransactionConfirmationSentAtInput, H as UpdateTransactionConfirmationSentAtOutput } from '../shared/ledger.DHX1YtaC.js';
|
|
4
3
|
import { WorkerEntrypoint } from 'cloudflare:workers';
|
|
4
|
+
import { DrizzleD1Database } from 'drizzle-orm/d1';
|
|
5
|
+
import { t as tables, C as CreateTransactionInput, a as CreateTransactionOutput, M as MatchTransactionInput, b as MatchTransactionOutput, F as FailTransactionInput, c as FailTransactionOutput, d as CancelTransactionInput, e as CancelTransactionOutput, G as GetTransactionByIdInput, f as GetTransactionByIdOutput, g as GetTransactionsByIdReferenceInput, h as GetTransactionsByReferenceIdOutput, i as GetTransactionsInput, j as GetTransactionsOutput, k as CreateAccountInput, l as CreateAccountOutput, U as UpdateAccountInput, m as UpdateAccountOutput, D as DeleteAccountInput, n as DeleteAccountOutput, o as GetAccountInput, p as GetAccountOutput, q as GetAccountsByOwnerInput, r as GetAccountsByOwnerOutput, L as ListAccountsInput, s as ListAccountsOutput, u as GetAccountIdentifierInput, v as GetAccountIdentifierOutput, w as ListAccountIdentifiersInput, x as ListAccountIdentifiersOutput, y as FindAccountByIdentifierInput, z as FindAccountByIdentifierOutput, A as GetAccountBalanceInput, B as GetAccountBalanceOutput, E as UpdateTransactionConfirmationSentAtInput, H as UpdateTransactionConfirmationSentAtOutput, I as UpdateTransactionStatusInput, J as UpdateTransactionStatusOutput } from '../shared/ledger.CDdw0Nyc.js';
|
|
5
6
|
import 'zod';
|
|
6
|
-
import '../shared/ledger.
|
|
7
|
+
import '../shared/ledger.CLVyCzRb.js';
|
|
7
8
|
import 'drizzle-orm';
|
|
8
9
|
import 'drizzle-orm/sqlite-core';
|
|
9
10
|
import '@develit-io/general-codes';
|
|
10
11
|
|
|
11
|
-
declare const LedgerServiceBase_base: any;
|
|
12
|
+
declare const LedgerServiceBase_base: (abstract new (ctx: ExecutionContext, env: LedgerEnv) => WorkerEntrypoint<LedgerEnv, {}>) & (abstract new (...args: any[]) => _develit_io_backend_sdk.DevelitWorkerMethods);
|
|
12
13
|
declare class LedgerServiceBase extends LedgerServiceBase_base {
|
|
13
14
|
readonly db: DrizzleD1Database<typeof tables>;
|
|
14
15
|
constructor(ctx: ExecutionContext, env: LedgerEnv);
|
|
@@ -30,6 +31,7 @@ declare class LedgerServiceBase extends LedgerServiceBase_base {
|
|
|
30
31
|
findAccountByIdentifier(input: FindAccountByIdentifierInput): Promise<IRPCResponse<FindAccountByIdentifierOutput>>;
|
|
31
32
|
getAccountBalance(input: GetAccountBalanceInput): Promise<IRPCResponse<GetAccountBalanceOutput>>;
|
|
32
33
|
updateTransactionConfirmationSentAt(input: UpdateTransactionConfirmationSentAtInput): Promise<IRPCResponse<UpdateTransactionConfirmationSentAtOutput>>;
|
|
34
|
+
updateTransactionStatus(input: UpdateTransactionStatusInput): Promise<IRPCResponse<UpdateTransactionStatusOutput>>;
|
|
33
35
|
}
|
|
34
36
|
declare function defineLedgerService(): new (ctx: ExecutionContext, env: LedgerEnv) => LedgerServiceBase;
|
|
35
37
|
|
package/dist/export/worker.mjs
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { first, develitWorker, uuidv4, useResult, createInternalError, action, service } from '@develit-io/backend-sdk';
|
|
2
2
|
import { WorkerEntrypoint } from 'cloudflare:workers';
|
|
3
3
|
import { drizzle } from 'drizzle-orm/d1';
|
|
4
|
-
import { s as schema } from '../shared/ledger.
|
|
4
|
+
import { s as schema } from '../shared/ledger.BGgIPMu-.mjs';
|
|
5
5
|
import { eq, and, inArray, or, count, gte, lte, sql, asc, desc } from 'drizzle-orm';
|
|
6
|
-
import {
|
|
6
|
+
import { j as createTransactionInputSchema, w as matchTransactionInputSchema, l as failTransactionInputSchema, h as cancelTransactionInputSchema, r as getTransactionByIdInputSchema, s as getTransactionsByReferenceIdInputSchema, t as getTransactionsInputSchema, i as createAccountInputSchema, x as updateAccountInputSchema, k as deleteAccountInputSchema, p as getAccountInputSchema, q as getAccountsByOwnerInputSchema, v as listAccountsInputSchema, o as getAccountIdentifierInputSchema, u as listAccountIdentifiersInputSchema, m as findAccountByIdentifierInputSchema, n as getAccountBalanceInputSchema, y as updateTransactionConfirmationSentAtInputSchema, z as updateTransactionStatusInputSchema } from '../shared/ledger.BVNtjljl.mjs';
|
|
7
7
|
import '@develit-io/general-codes';
|
|
8
8
|
import 'drizzle-orm/sqlite-core';
|
|
9
9
|
import 'zod';
|
|
@@ -797,6 +797,56 @@ let LedgerServiceBase = class extends develitWorker(
|
|
|
797
797
|
}
|
|
798
798
|
);
|
|
799
799
|
}
|
|
800
|
+
async updateTransactionStatus(input) {
|
|
801
|
+
return this.handleAction(
|
|
802
|
+
{ data: input, schema: updateTransactionStatusInputSchema },
|
|
803
|
+
{ successMessage: "Transaction status successfully updated." },
|
|
804
|
+
async (params) => {
|
|
805
|
+
const { transactionId, status, statusReason, paymentId, completedAt } = params;
|
|
806
|
+
const existingTransaction = await getTransactionByIdQuery(
|
|
807
|
+
this.db,
|
|
808
|
+
transactionId
|
|
809
|
+
);
|
|
810
|
+
if (!existingTransaction) {
|
|
811
|
+
throw createInternalError(null, {
|
|
812
|
+
message: "Transaction not found",
|
|
813
|
+
status: 404,
|
|
814
|
+
code: "NOT_FOUND"
|
|
815
|
+
});
|
|
816
|
+
}
|
|
817
|
+
const { command } = updateTransactionStatusCommand(this.db, {
|
|
818
|
+
transactionId,
|
|
819
|
+
status,
|
|
820
|
+
statusReason,
|
|
821
|
+
paymentId,
|
|
822
|
+
completedAt
|
|
823
|
+
});
|
|
824
|
+
const [updatedTransaction] = await this.db.batch([command]);
|
|
825
|
+
if (!updatedTransaction) {
|
|
826
|
+
throw createInternalError(null, {
|
|
827
|
+
message: "Failed to update transaction",
|
|
828
|
+
status: 500,
|
|
829
|
+
code: "INTERNAL_ERROR"
|
|
830
|
+
});
|
|
831
|
+
}
|
|
832
|
+
const transaction = first(updatedTransaction);
|
|
833
|
+
await this.pushToQueue(
|
|
834
|
+
this.env.QUEUE_BUS_QUEUE,
|
|
835
|
+
{
|
|
836
|
+
eventType: "LEDGER_TRANSACTION",
|
|
837
|
+
eventSignal: "updated",
|
|
838
|
+
ledgerTransaction: transaction,
|
|
839
|
+
metadata: {
|
|
840
|
+
correlationId: uuidv4(),
|
|
841
|
+
entityId: transaction.id,
|
|
842
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
843
|
+
}
|
|
844
|
+
}
|
|
845
|
+
);
|
|
846
|
+
return transaction;
|
|
847
|
+
}
|
|
848
|
+
);
|
|
849
|
+
}
|
|
800
850
|
};
|
|
801
851
|
__decorateClass([
|
|
802
852
|
action("create-transaction")
|
|
@@ -852,6 +902,9 @@ __decorateClass([
|
|
|
852
902
|
__decorateClass([
|
|
853
903
|
action("update-transaction-confirmation-sent-at")
|
|
854
904
|
], LedgerServiceBase.prototype, "updateTransactionConfirmationSentAt", 1);
|
|
905
|
+
__decorateClass([
|
|
906
|
+
action("update-transaction-status")
|
|
907
|
+
], LedgerServiceBase.prototype, "updateTransactionStatus", 1);
|
|
855
908
|
LedgerServiceBase = __decorateClass([
|
|
856
909
|
service("ledger")
|
|
857
910
|
], LedgerServiceBase);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { base } from '@develit-io/backend-sdk';
|
|
2
2
|
import { relations } from 'drizzle-orm';
|
|
3
3
|
import { sqliteTable, integer, text, real } from 'drizzle-orm/sqlite-core';
|
|
4
|
-
import { T as TRANSACTION_STATUSES,
|
|
4
|
+
import { T as TRANSACTION_STATUSES, g as TRANSACTION_TYPES, R as REFERENCE_TYPES } from './ledger.BVNtjljl.mjs';
|
|
5
5
|
import '@develit-io/general-codes';
|
|
6
6
|
|
|
7
7
|
const account = sqliteTable("account", {
|
|
@@ -105,4 +105,4 @@ const schema = {
|
|
|
105
105
|
transaction: transaction
|
|
106
106
|
};
|
|
107
107
|
|
|
108
|
-
export { account as a, accountIdentifier as b, accountIdentifierMapping as c,
|
|
108
|
+
export { account as a, accountIdentifier as b, accountIdentifierMapping as c, accountIdentifierMappingRelations as d, accountIdentifierRelations as e, accountRelations as f, entry as g, schema as s, transaction as t };
|
|
@@ -82,15 +82,17 @@ const TRANSACTION_TYPES = [
|
|
|
82
82
|
// manual correction
|
|
83
83
|
"TRANSFER",
|
|
84
84
|
// internal transfer between accounts
|
|
85
|
-
"COLLATERAL"
|
|
85
|
+
"COLLATERAL",
|
|
86
86
|
// forward collateral payment from client
|
|
87
|
+
"REFUND"
|
|
87
88
|
];
|
|
88
89
|
const REFERENCE_TYPES = [
|
|
89
90
|
"PAYMENT",
|
|
90
91
|
"EXCHANGE",
|
|
91
92
|
"ORDER",
|
|
92
93
|
"INTERNAL-TRANSFER",
|
|
93
|
-
"FORWARD"
|
|
94
|
+
"FORWARD",
|
|
95
|
+
"TRANSACTION"
|
|
94
96
|
];
|
|
95
97
|
const PAYMENT_CHARGE_TYPES = ["SHA", "OUR", "BEN"];
|
|
96
98
|
const PAYMENT_TYPES = ["DOMESTIC", "SEPA", "SWIFT", "UNKNOWN"];
|
|
@@ -309,4 +311,12 @@ const updateTransactionConfirmationSentAtInputSchema = z.object({
|
|
|
309
311
|
transactionId: z.uuid()
|
|
310
312
|
});
|
|
311
313
|
|
|
312
|
-
|
|
314
|
+
const updateTransactionStatusInputSchema = z.object({
|
|
315
|
+
transactionId: z.uuid(),
|
|
316
|
+
status: z.enum(TRANSACTION_STATUSES),
|
|
317
|
+
statusReason: z.string().optional(),
|
|
318
|
+
paymentId: z.string().optional(),
|
|
319
|
+
completedAt: z.date().optional()
|
|
320
|
+
});
|
|
321
|
+
|
|
322
|
+
export { ACCOUNT_TYPES as A, BALANCE_STRATEGIES as B, COUNTRY_CODES as C, ENTRY_STATUSES as E, IDENTIFIER_KINDS as I, PAYMENT_CHARGE_TYPES as P, REFERENCE_TYPES as R, TRANSACTION_STATUSES as T, ALLOWED_TRANSACTION_FILTERS as a, ASSET_TYPES as b, BATCH_STATUSES as c, PAYMENT_DIRECTIONS as d, PAYMENT_STATUSES as e, PAYMENT_TYPES as f, TRANSACTION_TYPES as g, cancelTransactionInputSchema as h, createAccountInputSchema as i, createTransactionInputSchema as j, deleteAccountInputSchema as k, failTransactionInputSchema as l, findAccountByIdentifierInputSchema as m, getAccountBalanceInputSchema as n, getAccountIdentifierInputSchema as o, getAccountInputSchema as p, getAccountsByOwnerInputSchema as q, getTransactionByIdInputSchema as r, getTransactionsByReferenceIdInputSchema as s, getTransactionsInputSchema as t, listAccountIdentifiersInputSchema as u, listAccountsInputSchema as v, matchTransactionInputSchema as w, updateAccountInputSchema as x, updateTransactionConfirmationSentAtInputSchema as y, updateTransactionStatusInputSchema as z };
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
const backendSdk = require('@develit-io/backend-sdk');
|
|
4
4
|
const drizzleOrm = require('drizzle-orm');
|
|
5
5
|
const sqliteCore = require('drizzle-orm/sqlite-core');
|
|
6
|
-
const
|
|
6
|
+
const updateTransactionStatus = require('./ledger.Dfi_K5W2.cjs');
|
|
7
7
|
require('@develit-io/general-codes');
|
|
8
8
|
|
|
9
9
|
const account = sqliteCore.sqliteTable("account", {
|
|
@@ -80,14 +80,14 @@ const transaction = sqliteCore.sqliteTable("transaction", {
|
|
|
80
80
|
correlationId: sqliteCore.text("correlation_id").notNull(),
|
|
81
81
|
// Unique ID for the transaction, used for correlation
|
|
82
82
|
// Business context
|
|
83
|
-
referenceType: sqliteCore.text("reference_type", { enum:
|
|
83
|
+
referenceType: sqliteCore.text("reference_type", { enum: updateTransactionStatus.REFERENCE_TYPES }).$type().notNull(),
|
|
84
84
|
referenceId: sqliteCore.text("reference_id"),
|
|
85
85
|
// business transaction ID
|
|
86
|
-
type: sqliteCore.text("type", { enum:
|
|
86
|
+
type: sqliteCore.text("type", { enum: updateTransactionStatus.TRANSACTION_TYPES }).$type().notNull(),
|
|
87
87
|
description: sqliteCore.text("description"),
|
|
88
88
|
completedAt: sqliteCore.integer("completed_at", { mode: "timestamp_ms" }),
|
|
89
89
|
confirmationSentAt: sqliteCore.integer("confirmation_sent_at", { mode: "timestamp_ms" }),
|
|
90
|
-
status: sqliteCore.text("status", { enum:
|
|
90
|
+
status: sqliteCore.text("status", { enum: updateTransactionStatus.TRANSACTION_STATUSES }).$type().notNull(),
|
|
91
91
|
statusReason: sqliteCore.text("status_reason"),
|
|
92
92
|
paymentId: sqliteCore.text("payment_id"),
|
|
93
93
|
metadata: sqliteCore.text("metadata", { mode: "json" }).$type().notNull(),
|