@develit-services/ledger 0.0.8 → 0.0.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/database/schema.cjs +2 -2
- package/dist/database/schema.d.cts +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 +68 -14
- package/dist/export/worker.d.cts +4 -3
- package/dist/export/worker.d.mts +4 -3
- package/dist/export/worker.d.ts +4 -3
- package/dist/export/worker.mjs +68 -14
- package/dist/shared/{ledger.B097jcnG.d.ts → ledger.B059yF_1.d.cts} +642 -100
- package/dist/shared/{ledger.MnYNWZoo.d.ts → ledger.CBwk-FaO.d.cts} +135 -135
- package/dist/shared/{ledger.MnYNWZoo.d.cts → ledger.CBwk-FaO.d.mts} +135 -135
- package/dist/shared/{ledger.MnYNWZoo.d.mts → ledger.CBwk-FaO.d.ts} +135 -135
- package/dist/shared/{ledger.DGu3Pj-Y.cjs → ledger.CDuhIB9s.cjs} +1 -1
- package/dist/shared/{ledger.ByUO4e44.mjs → ledger.D8XNEnr1.mjs} +39 -35
- package/dist/shared/{ledger.D1MIlhpb.cjs → ledger.DXlB4bbD.cjs} +40 -35
- package/dist/shared/{ledger.DRJcpNto.d.cts → ledger.DibE_sEN.d.mts} +642 -100
- package/dist/shared/{ledger.w4G_kYoj.d.mts → ledger.DkvNelxD.d.ts} +642 -100
- package/dist/shared/{ledger.Bl4HgQDw.mjs → ledger.qEafj0Ix.mjs} +1 -1
- package/dist/types.cjs +3 -2
- package/dist/types.d.cts +4 -3
- package/dist/types.d.mts +4 -3
- package/dist/types.d.ts +4 -3
- package/dist/types.mjs +1 -1
- package/package.json +2 -2
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.CDuhIB9s.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.DXlB4bbD.cjs');
|
|
8
8
|
require('@develit-io/general-codes');
|
|
9
9
|
require('zod');
|
|
10
10
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { F as account, G as accountIdentifier, H as accountIdentifierMapping, L as accountIdentifierMappingRelations, K as accountIdentifierRelations, J as accountRelations, M as entry, N as transaction } from '../shared/ledger.
|
|
1
|
+
export { F as account, G as accountIdentifier, H as accountIdentifierMapping, L as accountIdentifierMappingRelations, K as accountIdentifierRelations, J as accountRelations, M as entry, N as transaction } from '../shared/ledger.CBwk-FaO.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, L as accountIdentifierMappingRelations, K as accountIdentifierRelations, J as accountRelations, M as entry, N as transaction } from '../shared/ledger.
|
|
1
|
+
export { F as account, G as accountIdentifier, H as accountIdentifierMapping, L as accountIdentifierMappingRelations, K as accountIdentifierRelations, J as accountRelations, M as entry, N as transaction } from '../shared/ledger.CBwk-FaO.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, L as accountIdentifierMappingRelations, K as accountIdentifierRelations, J as accountRelations, M as entry, N as transaction } from '../shared/ledger.
|
|
1
|
+
export { F as account, G as accountIdentifier, H as accountIdentifierMapping, L as accountIdentifierMappingRelations, K as accountIdentifierRelations, J as accountRelations, M as entry, N as transaction } from '../shared/ledger.CBwk-FaO.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, f as accountIdentifierMappingRelations, e as accountIdentifierRelations, d as accountRelations, g as entry, t as transaction } from '../shared/ledger.
|
|
1
|
+
export { a as account, b as accountIdentifier, c as accountIdentifierMapping, f as accountIdentifierMappingRelations, e as accountIdentifierRelations, d as accountRelations, g as entry, t as transaction } from '../shared/ledger.qEafj0Ix.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.D8XNEnr1.mjs';
|
|
6
6
|
import '@develit-io/general-codes';
|
|
7
7
|
import 'zod';
|
package/dist/export/worker.cjs
CHANGED
|
@@ -2,15 +2,15 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
const cloudflare_workers = require('cloudflare:workers');
|
|
6
5
|
const backendSdk = require('@develit-io/backend-sdk');
|
|
7
|
-
const
|
|
8
|
-
require('@develit-io/general-codes');
|
|
9
|
-
const database_schema = require('../shared/ledger.DGu3Pj-Y.cjs');
|
|
10
|
-
const drizzleOrm = require('drizzle-orm');
|
|
6
|
+
const cloudflare_workers = require('cloudflare:workers');
|
|
11
7
|
const d1 = require('drizzle-orm/d1');
|
|
12
|
-
require('
|
|
8
|
+
const database_schema = require('../shared/ledger.CDuhIB9s.cjs');
|
|
9
|
+
const drizzleOrm = require('drizzle-orm');
|
|
10
|
+
const updateTransactionConfirmationSentAt = require('../shared/ledger.DXlB4bbD.cjs');
|
|
11
|
+
require('@develit-io/general-codes');
|
|
13
12
|
require('drizzle-orm/sqlite-core');
|
|
13
|
+
require('zod');
|
|
14
14
|
|
|
15
15
|
const tables = database_schema.schema;
|
|
16
16
|
|
|
@@ -356,7 +356,8 @@ let LedgerServiceBase = class extends backendSdk.develitWorker(
|
|
|
356
356
|
throw backendSdk.createInternalError(null, {
|
|
357
357
|
message: "Failed to create transaction",
|
|
358
358
|
status: 500,
|
|
359
|
-
code: "
|
|
359
|
+
code: "DB-L-01"
|
|
360
|
+
// database, ledger, error 01
|
|
360
361
|
});
|
|
361
362
|
}
|
|
362
363
|
const result = {
|
|
@@ -368,6 +369,7 @@ let LedgerServiceBase = class extends backendSdk.develitWorker(
|
|
|
368
369
|
this.env.QUEUE_BUS_QUEUE,
|
|
369
370
|
{
|
|
370
371
|
eventType: "LEDGER_TRANSACTION",
|
|
372
|
+
eventSignal: "created",
|
|
371
373
|
ledgerTransaction: result.transaction,
|
|
372
374
|
metadata: {
|
|
373
375
|
correlationId: backendSdk.uuidv4(),
|
|
@@ -386,12 +388,60 @@ let LedgerServiceBase = class extends backendSdk.develitWorker(
|
|
|
386
388
|
}
|
|
387
389
|
);
|
|
388
390
|
}
|
|
389
|
-
async
|
|
391
|
+
async matchTransaction(input) {
|
|
392
|
+
return this.handleAction(
|
|
393
|
+
{ data: input, schema: updateTransactionConfirmationSentAt.matchTransactionInputSchema },
|
|
394
|
+
{ successMessage: "Transaction successfully matched." },
|
|
395
|
+
async (params) => {
|
|
396
|
+
const { transactionId, completedAt } = params;
|
|
397
|
+
const existingTransaction = await getTransactionByIdQuery(
|
|
398
|
+
this.db,
|
|
399
|
+
transactionId
|
|
400
|
+
);
|
|
401
|
+
if (!existingTransaction) {
|
|
402
|
+
throw backendSdk.createInternalError(null, {
|
|
403
|
+
message: "Transaction not found",
|
|
404
|
+
status: 404,
|
|
405
|
+
code: "NOT_FOUND"
|
|
406
|
+
});
|
|
407
|
+
}
|
|
408
|
+
const { command } = await updateTransactionStatusCommand(
|
|
409
|
+
this.db,
|
|
410
|
+
transactionId,
|
|
411
|
+
"MATCHED",
|
|
412
|
+
completedAt
|
|
413
|
+
);
|
|
414
|
+
const [updatedTransaction] = await this.db.batch([command]);
|
|
415
|
+
if (!updatedTransaction) {
|
|
416
|
+
throw backendSdk.createInternalError(null, {
|
|
417
|
+
message: "Failed to update transaction",
|
|
418
|
+
status: 500,
|
|
419
|
+
code: "INTERNAL_ERROR"
|
|
420
|
+
});
|
|
421
|
+
}
|
|
422
|
+
const transaction = backendSdk.first(updatedTransaction);
|
|
423
|
+
await this.pushToQueue(
|
|
424
|
+
this.env.QUEUE_BUS_QUEUE,
|
|
425
|
+
{
|
|
426
|
+
eventType: "LEDGER_TRANSACTION",
|
|
427
|
+
eventSignal: "matched",
|
|
428
|
+
ledgerTransaction: transaction,
|
|
429
|
+
metadata: {
|
|
430
|
+
correlationId: backendSdk.uuidv4(),
|
|
431
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
432
|
+
}
|
|
433
|
+
}
|
|
434
|
+
);
|
|
435
|
+
return transaction;
|
|
436
|
+
}
|
|
437
|
+
);
|
|
438
|
+
}
|
|
439
|
+
async failTransaction(input) {
|
|
390
440
|
return this.handleAction(
|
|
391
|
-
{ data: input, schema: updateTransactionConfirmationSentAt.
|
|
392
|
-
{ successMessage: "Transaction successfully
|
|
441
|
+
{ data: input, schema: updateTransactionConfirmationSentAt.failTransactionInputSchema },
|
|
442
|
+
{ successMessage: "Transaction successfully failed." },
|
|
393
443
|
async (params) => {
|
|
394
|
-
const { transactionId,
|
|
444
|
+
const { transactionId, completedAt } = params;
|
|
395
445
|
const existingTransaction = await getTransactionByIdQuery(
|
|
396
446
|
this.db,
|
|
397
447
|
transactionId
|
|
@@ -406,7 +456,7 @@ let LedgerServiceBase = class extends backendSdk.develitWorker(
|
|
|
406
456
|
const { command } = await updateTransactionStatusCommand(
|
|
407
457
|
this.db,
|
|
408
458
|
transactionId,
|
|
409
|
-
|
|
459
|
+
"FAILED",
|
|
410
460
|
completedAt
|
|
411
461
|
);
|
|
412
462
|
const [updatedTransaction] = await this.db.batch([command]);
|
|
@@ -422,6 +472,7 @@ let LedgerServiceBase = class extends backendSdk.develitWorker(
|
|
|
422
472
|
this.env.QUEUE_BUS_QUEUE,
|
|
423
473
|
{
|
|
424
474
|
eventType: "LEDGER_TRANSACTION",
|
|
475
|
+
eventSignal: "failed",
|
|
425
476
|
ledgerTransaction: transaction,
|
|
426
477
|
metadata: {
|
|
427
478
|
correlationId: backendSdk.uuidv4(),
|
|
@@ -701,8 +752,11 @@ __decorateClass([
|
|
|
701
752
|
backendSdk.action("create-transaction")
|
|
702
753
|
], LedgerServiceBase.prototype, "createTransaction", 1);
|
|
703
754
|
__decorateClass([
|
|
704
|
-
backendSdk.action("
|
|
705
|
-
], LedgerServiceBase.prototype, "
|
|
755
|
+
backendSdk.action("match-transaction")
|
|
756
|
+
], LedgerServiceBase.prototype, "matchTransaction", 1);
|
|
757
|
+
__decorateClass([
|
|
758
|
+
backendSdk.action("fail-transaction")
|
|
759
|
+
], LedgerServiceBase.prototype, "failTransaction", 1);
|
|
706
760
|
__decorateClass([
|
|
707
761
|
backendSdk.action("get-transaction-by-id")
|
|
708
762
|
], LedgerServiceBase.prototype, "getTransactionById", 1);
|
package/dist/export/worker.d.cts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import * as _develit_io_backend_sdk from '@develit-io/backend-sdk';
|
|
2
2
|
import { IRPCResponse } from '@develit-io/backend-sdk';
|
|
3
3
|
import { WorkerEntrypoint } from 'cloudflare:workers';
|
|
4
|
-
import { t as tables, C as CreateTransactionInput, a as CreateTransactionOutput, U as UpdateTransactionInput, b as UpdateTransactionOutput, G as GetTransactionByIdInput, c as GetTransactionByIdOutput, d as GetTransactionsByIdReferenceInput, e as GetTransactionsByReferenceIdOutput, f as GetTransactionsInput, g as GetTransactionsOutput, h as CreateAccountInput, i as CreateAccountOutput, j as UpdateAccountInput, k as UpdateAccountOutput, D as DeleteAccountInput, l as DeleteAccountOutput, m as GetAccountInput, n as GetAccountOutput, o as GetAccountsByOwnerInput, p as GetAccountsByOwnerOutput, L as ListAccountsInput, q as ListAccountsOutput, r as GetAccountIdentifierInput, s as GetAccountIdentifierOutput, u as ListAccountIdentifiersInput, v as ListAccountIdentifiersOutput, F as FindAccountByIdentifierInput, w as FindAccountByIdentifierOutput, x as GetAccountBalanceInput, y as GetAccountBalanceOutput, z as UpdateTransactionConfirmationSentAtInput, A as UpdateTransactionConfirmationSentAtOutput } from '../shared/ledger.DRJcpNto.cjs';
|
|
5
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, G as GetTransactionByIdInput, d as GetTransactionByIdOutput, e as GetTransactionsByIdReferenceInput, f as GetTransactionsByReferenceIdOutput, g as GetTransactionsInput, h as GetTransactionsOutput, i as CreateAccountInput, j as CreateAccountOutput, U as UpdateAccountInput, k as UpdateAccountOutput, D as DeleteAccountInput, l as DeleteAccountOutput, m as GetAccountInput, n as GetAccountOutput, o as GetAccountsByOwnerInput, p as GetAccountsByOwnerOutput, L as ListAccountsInput, q as ListAccountsOutput, r as GetAccountIdentifierInput, s as GetAccountIdentifierOutput, u as ListAccountIdentifiersInput, v as ListAccountIdentifiersOutput, w as FindAccountByIdentifierInput, x as FindAccountByIdentifierOutput, y as GetAccountBalanceInput, z as GetAccountBalanceOutput, A as UpdateTransactionConfirmationSentAtInput, B as UpdateTransactionConfirmationSentAtOutput } from '../shared/ledger.B059yF_1.cjs';
|
|
6
6
|
import 'zod';
|
|
7
|
-
import '../shared/ledger.
|
|
7
|
+
import '../shared/ledger.CBwk-FaO.cjs';
|
|
8
8
|
import 'drizzle-orm';
|
|
9
9
|
import 'drizzle-orm/sqlite-core';
|
|
10
10
|
import '@develit-io/general-codes';
|
|
@@ -14,7 +14,8 @@ declare class LedgerServiceBase extends LedgerServiceBase_base {
|
|
|
14
14
|
readonly db: DrizzleD1Database<typeof tables>;
|
|
15
15
|
constructor(ctx: ExecutionContext, env: LedgerEnv);
|
|
16
16
|
createTransaction(input: CreateTransactionInput): Promise<IRPCResponse<CreateTransactionOutput>>;
|
|
17
|
-
|
|
17
|
+
matchTransaction(input: MatchTransactionInput): Promise<IRPCResponse<MatchTransactionOutput>>;
|
|
18
|
+
failTransaction(input: FailTransactionInput): Promise<IRPCResponse<FailTransactionOutput>>;
|
|
18
19
|
getTransactionById(input: GetTransactionByIdInput): Promise<IRPCResponse<GetTransactionByIdOutput | undefined>>;
|
|
19
20
|
getTransactionsByReferenceId(input: GetTransactionsByIdReferenceInput): Promise<IRPCResponse<GetTransactionsByReferenceIdOutput | undefined>>;
|
|
20
21
|
getTransactions(input: GetTransactionsInput): Promise<IRPCResponse<GetTransactionsOutput>>;
|
package/dist/export/worker.d.mts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import * as _develit_io_backend_sdk from '@develit-io/backend-sdk';
|
|
2
2
|
import { IRPCResponse } from '@develit-io/backend-sdk';
|
|
3
3
|
import { WorkerEntrypoint } from 'cloudflare:workers';
|
|
4
|
-
import { t as tables, C as CreateTransactionInput, a as CreateTransactionOutput, U as UpdateTransactionInput, b as UpdateTransactionOutput, G as GetTransactionByIdInput, c as GetTransactionByIdOutput, d as GetTransactionsByIdReferenceInput, e as GetTransactionsByReferenceIdOutput, f as GetTransactionsInput, g as GetTransactionsOutput, h as CreateAccountInput, i as CreateAccountOutput, j as UpdateAccountInput, k as UpdateAccountOutput, D as DeleteAccountInput, l as DeleteAccountOutput, m as GetAccountInput, n as GetAccountOutput, o as GetAccountsByOwnerInput, p as GetAccountsByOwnerOutput, L as ListAccountsInput, q as ListAccountsOutput, r as GetAccountIdentifierInput, s as GetAccountIdentifierOutput, u as ListAccountIdentifiersInput, v as ListAccountIdentifiersOutput, F as FindAccountByIdentifierInput, w as FindAccountByIdentifierOutput, x as GetAccountBalanceInput, y as GetAccountBalanceOutput, z as UpdateTransactionConfirmationSentAtInput, A as UpdateTransactionConfirmationSentAtOutput } from '../shared/ledger.w4G_kYoj.mjs';
|
|
5
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, G as GetTransactionByIdInput, d as GetTransactionByIdOutput, e as GetTransactionsByIdReferenceInput, f as GetTransactionsByReferenceIdOutput, g as GetTransactionsInput, h as GetTransactionsOutput, i as CreateAccountInput, j as CreateAccountOutput, U as UpdateAccountInput, k as UpdateAccountOutput, D as DeleteAccountInput, l as DeleteAccountOutput, m as GetAccountInput, n as GetAccountOutput, o as GetAccountsByOwnerInput, p as GetAccountsByOwnerOutput, L as ListAccountsInput, q as ListAccountsOutput, r as GetAccountIdentifierInput, s as GetAccountIdentifierOutput, u as ListAccountIdentifiersInput, v as ListAccountIdentifiersOutput, w as FindAccountByIdentifierInput, x as FindAccountByIdentifierOutput, y as GetAccountBalanceInput, z as GetAccountBalanceOutput, A as UpdateTransactionConfirmationSentAtInput, B as UpdateTransactionConfirmationSentAtOutput } from '../shared/ledger.DibE_sEN.mjs';
|
|
6
6
|
import 'zod';
|
|
7
|
-
import '../shared/ledger.
|
|
7
|
+
import '../shared/ledger.CBwk-FaO.mjs';
|
|
8
8
|
import 'drizzle-orm';
|
|
9
9
|
import 'drizzle-orm/sqlite-core';
|
|
10
10
|
import '@develit-io/general-codes';
|
|
@@ -14,7 +14,8 @@ declare class LedgerServiceBase extends LedgerServiceBase_base {
|
|
|
14
14
|
readonly db: DrizzleD1Database<typeof tables>;
|
|
15
15
|
constructor(ctx: ExecutionContext, env: LedgerEnv);
|
|
16
16
|
createTransaction(input: CreateTransactionInput): Promise<IRPCResponse<CreateTransactionOutput>>;
|
|
17
|
-
|
|
17
|
+
matchTransaction(input: MatchTransactionInput): Promise<IRPCResponse<MatchTransactionOutput>>;
|
|
18
|
+
failTransaction(input: FailTransactionInput): Promise<IRPCResponse<FailTransactionOutput>>;
|
|
18
19
|
getTransactionById(input: GetTransactionByIdInput): Promise<IRPCResponse<GetTransactionByIdOutput | undefined>>;
|
|
19
20
|
getTransactionsByReferenceId(input: GetTransactionsByIdReferenceInput): Promise<IRPCResponse<GetTransactionsByReferenceIdOutput | undefined>>;
|
|
20
21
|
getTransactions(input: GetTransactionsInput): Promise<IRPCResponse<GetTransactionsOutput>>;
|
package/dist/export/worker.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import * as _develit_io_backend_sdk from '@develit-io/backend-sdk';
|
|
2
2
|
import { IRPCResponse } from '@develit-io/backend-sdk';
|
|
3
3
|
import { WorkerEntrypoint } from 'cloudflare:workers';
|
|
4
|
-
import { t as tables, C as CreateTransactionInput, a as CreateTransactionOutput, U as UpdateTransactionInput, b as UpdateTransactionOutput, G as GetTransactionByIdInput, c as GetTransactionByIdOutput, d as GetTransactionsByIdReferenceInput, e as GetTransactionsByReferenceIdOutput, f as GetTransactionsInput, g as GetTransactionsOutput, h as CreateAccountInput, i as CreateAccountOutput, j as UpdateAccountInput, k as UpdateAccountOutput, D as DeleteAccountInput, l as DeleteAccountOutput, m as GetAccountInput, n as GetAccountOutput, o as GetAccountsByOwnerInput, p as GetAccountsByOwnerOutput, L as ListAccountsInput, q as ListAccountsOutput, r as GetAccountIdentifierInput, s as GetAccountIdentifierOutput, u as ListAccountIdentifiersInput, v as ListAccountIdentifiersOutput, F as FindAccountByIdentifierInput, w as FindAccountByIdentifierOutput, x as GetAccountBalanceInput, y as GetAccountBalanceOutput, z as UpdateTransactionConfirmationSentAtInput, A as UpdateTransactionConfirmationSentAtOutput } from '../shared/ledger.B097jcnG.js';
|
|
5
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, G as GetTransactionByIdInput, d as GetTransactionByIdOutput, e as GetTransactionsByIdReferenceInput, f as GetTransactionsByReferenceIdOutput, g as GetTransactionsInput, h as GetTransactionsOutput, i as CreateAccountInput, j as CreateAccountOutput, U as UpdateAccountInput, k as UpdateAccountOutput, D as DeleteAccountInput, l as DeleteAccountOutput, m as GetAccountInput, n as GetAccountOutput, o as GetAccountsByOwnerInput, p as GetAccountsByOwnerOutput, L as ListAccountsInput, q as ListAccountsOutput, r as GetAccountIdentifierInput, s as GetAccountIdentifierOutput, u as ListAccountIdentifiersInput, v as ListAccountIdentifiersOutput, w as FindAccountByIdentifierInput, x as FindAccountByIdentifierOutput, y as GetAccountBalanceInput, z as GetAccountBalanceOutput, A as UpdateTransactionConfirmationSentAtInput, B as UpdateTransactionConfirmationSentAtOutput } from '../shared/ledger.DkvNelxD.js';
|
|
6
6
|
import 'zod';
|
|
7
|
-
import '../shared/ledger.
|
|
7
|
+
import '../shared/ledger.CBwk-FaO.js';
|
|
8
8
|
import 'drizzle-orm';
|
|
9
9
|
import 'drizzle-orm/sqlite-core';
|
|
10
10
|
import '@develit-io/general-codes';
|
|
@@ -14,7 +14,8 @@ declare class LedgerServiceBase extends LedgerServiceBase_base {
|
|
|
14
14
|
readonly db: DrizzleD1Database<typeof tables>;
|
|
15
15
|
constructor(ctx: ExecutionContext, env: LedgerEnv);
|
|
16
16
|
createTransaction(input: CreateTransactionInput): Promise<IRPCResponse<CreateTransactionOutput>>;
|
|
17
|
-
|
|
17
|
+
matchTransaction(input: MatchTransactionInput): Promise<IRPCResponse<MatchTransactionOutput>>;
|
|
18
|
+
failTransaction(input: FailTransactionInput): Promise<IRPCResponse<FailTransactionOutput>>;
|
|
18
19
|
getTransactionById(input: GetTransactionByIdInput): Promise<IRPCResponse<GetTransactionByIdOutput | undefined>>;
|
|
19
20
|
getTransactionsByReferenceId(input: GetTransactionsByIdReferenceInput): Promise<IRPCResponse<GetTransactionsByReferenceIdOutput | undefined>>;
|
|
20
21
|
getTransactions(input: GetTransactionsInput): Promise<IRPCResponse<GetTransactionsOutput>>;
|
package/dist/export/worker.mjs
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { WorkerEntrypoint } from 'cloudflare:workers';
|
|
2
1
|
import { first, develitWorker, uuidv4, useResult, createInternalError, action, service } from '@develit-io/backend-sdk';
|
|
3
|
-
import {
|
|
4
|
-
import '@develit-io/general-codes';
|
|
5
|
-
import { s as schema } from '../shared/ledger.Bl4HgQDw.mjs';
|
|
6
|
-
import { eq, and, inArray, or, count, gte, lte, sql, asc, desc } from 'drizzle-orm';
|
|
2
|
+
import { WorkerEntrypoint } from 'cloudflare:workers';
|
|
7
3
|
import { drizzle } from 'drizzle-orm/d1';
|
|
8
|
-
import '
|
|
4
|
+
import { s as schema } from '../shared/ledger.qEafj0Ix.mjs';
|
|
5
|
+
import { eq, and, inArray, or, count, gte, lte, sql, asc, desc } from 'drizzle-orm';
|
|
6
|
+
import { e as createTransactionInputSchema, r as matchTransactionInputSchema, g as failTransactionInputSchema, m as getTransactionByIdInputSchema, o as getTransactionsByReferenceIdInputSchema, n as getTransactionsInputSchema, d as createAccountInputSchema, u as updateAccountInputSchema, f as deleteAccountInputSchema, i as getAccountInputSchema, l as getAccountsByOwnerInputSchema, q as listAccountsInputSchema, k as getAccountIdentifierInputSchema, p as listAccountIdentifiersInputSchema, h as findAccountByIdentifierInputSchema, j as getAccountBalanceInputSchema, s as updateTransactionConfirmationSentAtInputSchema } from '../shared/ledger.D8XNEnr1.mjs';
|
|
7
|
+
import '@develit-io/general-codes';
|
|
9
8
|
import 'drizzle-orm/sqlite-core';
|
|
9
|
+
import 'zod';
|
|
10
10
|
|
|
11
11
|
const tables = schema;
|
|
12
12
|
|
|
@@ -352,7 +352,8 @@ let LedgerServiceBase = class extends develitWorker(
|
|
|
352
352
|
throw createInternalError(null, {
|
|
353
353
|
message: "Failed to create transaction",
|
|
354
354
|
status: 500,
|
|
355
|
-
code: "
|
|
355
|
+
code: "DB-L-01"
|
|
356
|
+
// database, ledger, error 01
|
|
356
357
|
});
|
|
357
358
|
}
|
|
358
359
|
const result = {
|
|
@@ -364,6 +365,7 @@ let LedgerServiceBase = class extends develitWorker(
|
|
|
364
365
|
this.env.QUEUE_BUS_QUEUE,
|
|
365
366
|
{
|
|
366
367
|
eventType: "LEDGER_TRANSACTION",
|
|
368
|
+
eventSignal: "created",
|
|
367
369
|
ledgerTransaction: result.transaction,
|
|
368
370
|
metadata: {
|
|
369
371
|
correlationId: uuidv4(),
|
|
@@ -382,12 +384,60 @@ let LedgerServiceBase = class extends develitWorker(
|
|
|
382
384
|
}
|
|
383
385
|
);
|
|
384
386
|
}
|
|
385
|
-
async
|
|
387
|
+
async matchTransaction(input) {
|
|
388
|
+
return this.handleAction(
|
|
389
|
+
{ data: input, schema: matchTransactionInputSchema },
|
|
390
|
+
{ successMessage: "Transaction successfully matched." },
|
|
391
|
+
async (params) => {
|
|
392
|
+
const { transactionId, completedAt } = params;
|
|
393
|
+
const existingTransaction = await getTransactionByIdQuery(
|
|
394
|
+
this.db,
|
|
395
|
+
transactionId
|
|
396
|
+
);
|
|
397
|
+
if (!existingTransaction) {
|
|
398
|
+
throw createInternalError(null, {
|
|
399
|
+
message: "Transaction not found",
|
|
400
|
+
status: 404,
|
|
401
|
+
code: "NOT_FOUND"
|
|
402
|
+
});
|
|
403
|
+
}
|
|
404
|
+
const { command } = await updateTransactionStatusCommand(
|
|
405
|
+
this.db,
|
|
406
|
+
transactionId,
|
|
407
|
+
"MATCHED",
|
|
408
|
+
completedAt
|
|
409
|
+
);
|
|
410
|
+
const [updatedTransaction] = await this.db.batch([command]);
|
|
411
|
+
if (!updatedTransaction) {
|
|
412
|
+
throw createInternalError(null, {
|
|
413
|
+
message: "Failed to update transaction",
|
|
414
|
+
status: 500,
|
|
415
|
+
code: "INTERNAL_ERROR"
|
|
416
|
+
});
|
|
417
|
+
}
|
|
418
|
+
const transaction = first(updatedTransaction);
|
|
419
|
+
await this.pushToQueue(
|
|
420
|
+
this.env.QUEUE_BUS_QUEUE,
|
|
421
|
+
{
|
|
422
|
+
eventType: "LEDGER_TRANSACTION",
|
|
423
|
+
eventSignal: "matched",
|
|
424
|
+
ledgerTransaction: transaction,
|
|
425
|
+
metadata: {
|
|
426
|
+
correlationId: uuidv4(),
|
|
427
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
428
|
+
}
|
|
429
|
+
}
|
|
430
|
+
);
|
|
431
|
+
return transaction;
|
|
432
|
+
}
|
|
433
|
+
);
|
|
434
|
+
}
|
|
435
|
+
async failTransaction(input) {
|
|
386
436
|
return this.handleAction(
|
|
387
|
-
{ data: input, schema:
|
|
388
|
-
{ successMessage: "Transaction successfully
|
|
437
|
+
{ data: input, schema: failTransactionInputSchema },
|
|
438
|
+
{ successMessage: "Transaction successfully failed." },
|
|
389
439
|
async (params) => {
|
|
390
|
-
const { transactionId,
|
|
440
|
+
const { transactionId, completedAt } = params;
|
|
391
441
|
const existingTransaction = await getTransactionByIdQuery(
|
|
392
442
|
this.db,
|
|
393
443
|
transactionId
|
|
@@ -402,7 +452,7 @@ let LedgerServiceBase = class extends develitWorker(
|
|
|
402
452
|
const { command } = await updateTransactionStatusCommand(
|
|
403
453
|
this.db,
|
|
404
454
|
transactionId,
|
|
405
|
-
|
|
455
|
+
"FAILED",
|
|
406
456
|
completedAt
|
|
407
457
|
);
|
|
408
458
|
const [updatedTransaction] = await this.db.batch([command]);
|
|
@@ -418,6 +468,7 @@ let LedgerServiceBase = class extends develitWorker(
|
|
|
418
468
|
this.env.QUEUE_BUS_QUEUE,
|
|
419
469
|
{
|
|
420
470
|
eventType: "LEDGER_TRANSACTION",
|
|
471
|
+
eventSignal: "failed",
|
|
421
472
|
ledgerTransaction: transaction,
|
|
422
473
|
metadata: {
|
|
423
474
|
correlationId: uuidv4(),
|
|
@@ -697,8 +748,11 @@ __decorateClass([
|
|
|
697
748
|
action("create-transaction")
|
|
698
749
|
], LedgerServiceBase.prototype, "createTransaction", 1);
|
|
699
750
|
__decorateClass([
|
|
700
|
-
action("
|
|
701
|
-
], LedgerServiceBase.prototype, "
|
|
751
|
+
action("match-transaction")
|
|
752
|
+
], LedgerServiceBase.prototype, "matchTransaction", 1);
|
|
753
|
+
__decorateClass([
|
|
754
|
+
action("fail-transaction")
|
|
755
|
+
], LedgerServiceBase.prototype, "failTransaction", 1);
|
|
702
756
|
__decorateClass([
|
|
703
757
|
action("get-transaction-by-id")
|
|
704
758
|
], LedgerServiceBase.prototype, "getTransactionById", 1);
|