@develit-services/ledger 0.4.1 → 0.4.3
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 +35 -6
- package/dist/export/worker.d.cts +2 -2
- package/dist/export/worker.d.mts +2 -2
- package/dist/export/worker.d.ts +2 -2
- package/dist/export/worker.mjs +35 -6
- package/dist/shared/{ledger.ChKoo1xF.d.cts → ledger.2ZZR5AvH.d.ts} +73 -4
- package/dist/shared/{ledger.Dpxzz64a.mjs → ledger.B3xjxvWW.mjs} +2 -1
- package/dist/shared/{ledger.C4eXkZIj.cjs → ledger.C2YQGhdM.cjs} +2 -1
- package/dist/shared/{ledger.DmOERar_.d.mts → ledger.CPKrhfU8.d.mts} +73 -4
- package/dist/shared/{ledger.B9mOFtFf.d.cts → ledger.CZgIHlf1.d.cts} +25 -6
- package/dist/shared/{ledger.B9mOFtFf.d.mts → ledger.CZgIHlf1.d.mts} +25 -6
- package/dist/shared/{ledger.B9mOFtFf.d.ts → ledger.CZgIHlf1.d.ts} +25 -6
- package/dist/shared/{ledger.CAoxOU3F.cjs → ledger.ChjFG1yE.cjs} +12 -3
- package/dist/shared/{ledger.De19PrJa.mjs → ledger.DvHIBJap.mjs} +12 -3
- package/dist/shared/{ledger.BHSBmO94.d.ts → ledger.DxnspPg_.d.cts} +73 -4
- package/dist/types.cjs +1 -1
- package/dist/types.d.cts +5 -3
- package/dist/types.d.mts +5 -3
- package/dist/types.d.ts +5 -3
- package/dist/types.mjs +1 -1
- package/package.json +1 -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.C2YQGhdM.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.ChjFG1yE.cjs');
|
|
8
8
|
require('zod');
|
|
9
9
|
require('@develit-io/general-codes');
|
|
10
10
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { G as account, H as accountIdentifier, J as accountIdentifierMapping, K as accountIdentifierMappingRelations, L as accountIdentifierRelations, M as accountRelations, N as entry, O as transaction } from '../shared/ledger.
|
|
1
|
+
export { G as account, H as accountIdentifier, J as accountIdentifierMapping, K as accountIdentifierMappingRelations, L as accountIdentifierRelations, M as accountRelations, N as entry, O as transaction } from '../shared/ledger.CZgIHlf1.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 { G as account, H as accountIdentifier, J as accountIdentifierMapping, K as accountIdentifierMappingRelations, L as accountIdentifierRelations, M as accountRelations, N as entry, O as transaction } from '../shared/ledger.
|
|
1
|
+
export { G as account, H as accountIdentifier, J as accountIdentifierMapping, K as accountIdentifierMappingRelations, L as accountIdentifierRelations, M as accountRelations, N as entry, O as transaction } from '../shared/ledger.CZgIHlf1.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 { G as account, H as accountIdentifier, J as accountIdentifierMapping, K as accountIdentifierMappingRelations, L as accountIdentifierRelations, M as accountRelations, N as entry, O as transaction } from '../shared/ledger.
|
|
1
|
+
export { G as account, H as accountIdentifier, J as accountIdentifierMapping, K as accountIdentifierMappingRelations, L as accountIdentifierRelations, M as accountRelations, N as entry, O as transaction } from '../shared/ledger.CZgIHlf1.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, d as accountIdentifierMappingRelations, e as accountIdentifierRelations, f as accountRelations, g as entry, t as transaction } from '../shared/ledger.
|
|
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.B3xjxvWW.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.DvHIBJap.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.C2YQGhdM.cjs');
|
|
9
9
|
const drizzleOrm = require('drizzle-orm');
|
|
10
|
-
const updateTransactionStatus = require('../shared/ledger.
|
|
10
|
+
const updateTransactionStatus = require('../shared/ledger.ChjFG1yE.cjs');
|
|
11
11
|
require('@develit-io/general-codes');
|
|
12
12
|
require('drizzle-orm/sqlite-core');
|
|
13
13
|
require('zod');
|
|
@@ -50,6 +50,7 @@ const updateTransactionStatusCommand = (db, data) => {
|
|
|
50
50
|
transactionId,
|
|
51
51
|
status,
|
|
52
52
|
paymentId,
|
|
53
|
+
paymentRequestId,
|
|
53
54
|
completedAt,
|
|
54
55
|
statusReason,
|
|
55
56
|
receivedValue,
|
|
@@ -61,6 +62,7 @@ const updateTransactionStatusCommand = (db, data) => {
|
|
|
61
62
|
updatedAt: /* @__PURE__ */ new Date(),
|
|
62
63
|
completedAt,
|
|
63
64
|
paymentId,
|
|
65
|
+
...paymentRequestId !== void 0 && { paymentRequestId },
|
|
64
66
|
...receivedValue !== void 0 && { receivedValue },
|
|
65
67
|
...metadata !== void 0 && { metadata }
|
|
66
68
|
}).where(drizzleOrm.eq(tables.transaction.id, transactionId)).returning();
|
|
@@ -253,6 +255,8 @@ const getTransactionsWithPaginationQuery = async ({
|
|
|
253
255
|
filterTransactionCompletedAt,
|
|
254
256
|
filterTransactionStatus,
|
|
255
257
|
filterTransactionStatuses,
|
|
258
|
+
filterTransactionPaymentIds,
|
|
259
|
+
filterTransactionPaymentRequestIds,
|
|
256
260
|
search
|
|
257
261
|
}
|
|
258
262
|
}) => {
|
|
@@ -274,7 +278,12 @@ const getTransactionsWithPaginationQuery = async ({
|
|
|
274
278
|
filterTransactionDateTo ? drizzleOrm.lte(tables.transaction.createdAt, filterTransactionDateTo) : void 0,
|
|
275
279
|
filterTransactionCompletedAt ? drizzleOrm.eq(tables.transaction.completedAt, filterTransactionCompletedAt) : void 0,
|
|
276
280
|
filterTransactionStatus ? drizzleOrm.eq(tables.transaction.status, filterTransactionStatus) : void 0,
|
|
277
|
-
filterTransactionStatuses?.length ? drizzleOrm.inArray(tables.transaction.status, filterTransactionStatuses) : void 0
|
|
281
|
+
filterTransactionStatuses?.length ? drizzleOrm.inArray(tables.transaction.status, filterTransactionStatuses) : void 0,
|
|
282
|
+
filterTransactionPaymentIds?.length ? drizzleOrm.inArray(tables.transaction.paymentId, filterTransactionPaymentIds) : void 0,
|
|
283
|
+
filterTransactionPaymentRequestIds?.length ? drizzleOrm.inArray(
|
|
284
|
+
tables.transaction.paymentRequestId,
|
|
285
|
+
filterTransactionPaymentRequestIds
|
|
286
|
+
) : void 0
|
|
278
287
|
);
|
|
279
288
|
const sortColumn = resolveColumn(tables.transaction, sort.column);
|
|
280
289
|
const [{ totalCount }] = await db.select({ totalCount: drizzleOrm.sql`count(*)` }).from(tables.transaction).where(whereConditions);
|
|
@@ -343,6 +352,7 @@ let LedgerServiceBase = class extends backendSdk.develitWorker(
|
|
|
343
352
|
type,
|
|
344
353
|
description,
|
|
345
354
|
paymentId,
|
|
355
|
+
paymentRequestId,
|
|
346
356
|
metadata,
|
|
347
357
|
status,
|
|
348
358
|
value,
|
|
@@ -367,6 +377,7 @@ let LedgerServiceBase = class extends backendSdk.develitWorker(
|
|
|
367
377
|
completedAt: null,
|
|
368
378
|
status,
|
|
369
379
|
paymentId,
|
|
380
|
+
paymentRequestId,
|
|
370
381
|
metadata,
|
|
371
382
|
updatedAt: timestamp,
|
|
372
383
|
value,
|
|
@@ -419,6 +430,7 @@ let LedgerServiceBase = class extends backendSdk.develitWorker(
|
|
|
419
430
|
async _applyMatchAmount({
|
|
420
431
|
existingTransaction,
|
|
421
432
|
paymentId,
|
|
433
|
+
paymentRequestId,
|
|
422
434
|
amount,
|
|
423
435
|
completedAt,
|
|
424
436
|
extraMetadata
|
|
@@ -445,6 +457,7 @@ let LedgerServiceBase = class extends backendSdk.develitWorker(
|
|
|
445
457
|
status: isFullyMatched ? "MATCHED" : "PARTIALLY_MATCHED",
|
|
446
458
|
completedAt: isFullyMatched ? completedAt : void 0,
|
|
447
459
|
paymentId,
|
|
460
|
+
paymentRequestId,
|
|
448
461
|
receivedValue: newReceivedValue,
|
|
449
462
|
metadata: updatedMetadata
|
|
450
463
|
}).command.execute().then(backendSdk.first);
|
|
@@ -464,7 +477,8 @@ let LedgerServiceBase = class extends backendSdk.develitWorker(
|
|
|
464
477
|
transactionId,
|
|
465
478
|
status: "MATCHED",
|
|
466
479
|
completedAt,
|
|
467
|
-
paymentId
|
|
480
|
+
paymentId,
|
|
481
|
+
paymentRequestId
|
|
468
482
|
}).command.execute().then(backendSdk.first);
|
|
469
483
|
if (!transaction) {
|
|
470
484
|
throw backendSdk.createInternalError(null, {
|
|
@@ -480,7 +494,13 @@ let LedgerServiceBase = class extends backendSdk.develitWorker(
|
|
|
480
494
|
{ data: input, schema: updateTransactionStatus.matchTransactionInputSchema },
|
|
481
495
|
{ successMessage: "Transaction successfully matched." },
|
|
482
496
|
async (params) => {
|
|
483
|
-
const {
|
|
497
|
+
const {
|
|
498
|
+
transactionId,
|
|
499
|
+
completedAt,
|
|
500
|
+
paymentId,
|
|
501
|
+
paymentRequestId,
|
|
502
|
+
amount
|
|
503
|
+
} = params;
|
|
484
504
|
const existingTransaction = await getTransactionByIdQuery(
|
|
485
505
|
this.db,
|
|
486
506
|
transactionId
|
|
@@ -502,6 +522,7 @@ let LedgerServiceBase = class extends backendSdk.develitWorker(
|
|
|
502
522
|
const { transaction, signal } = await this._applyMatchAmount({
|
|
503
523
|
existingTransaction,
|
|
504
524
|
paymentId,
|
|
525
|
+
paymentRequestId,
|
|
505
526
|
amount,
|
|
506
527
|
completedAt
|
|
507
528
|
});
|
|
@@ -1111,7 +1132,14 @@ let LedgerServiceBase = class extends backendSdk.develitWorker(
|
|
|
1111
1132
|
{ data: input, schema: updateTransactionStatus.updateTransactionStatusInputSchema },
|
|
1112
1133
|
{ successMessage: "Transaction status successfully updated." },
|
|
1113
1134
|
async (params) => {
|
|
1114
|
-
const {
|
|
1135
|
+
const {
|
|
1136
|
+
transactionId,
|
|
1137
|
+
status,
|
|
1138
|
+
statusReason,
|
|
1139
|
+
paymentId,
|
|
1140
|
+
paymentRequestId,
|
|
1141
|
+
completedAt
|
|
1142
|
+
} = params;
|
|
1115
1143
|
const existingTransaction = await getTransactionByIdQuery(
|
|
1116
1144
|
this.db,
|
|
1117
1145
|
transactionId
|
|
@@ -1128,6 +1156,7 @@ let LedgerServiceBase = class extends backendSdk.develitWorker(
|
|
|
1128
1156
|
status,
|
|
1129
1157
|
statusReason,
|
|
1130
1158
|
paymentId,
|
|
1159
|
+
paymentRequestId,
|
|
1131
1160
|
completedAt
|
|
1132
1161
|
});
|
|
1133
1162
|
const [updatedTransaction] = await this.db.batch([command]);
|
package/dist/export/worker.d.cts
CHANGED
|
@@ -2,9 +2,9 @@ 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
4
|
import { DrizzleD1Database } from 'drizzle-orm/d1';
|
|
5
|
-
import { t as tables, C as CreateTransactionInput, a as CreateTransactionOutput, M as MatchTransactionInput, b as MatchTransactionOutput, R as ResolveUnmatchedTransactionInput, c as ResolveUnmatchedTransactionOutput, F as FailTransactionInput, d as FailTransactionOutput, e as CancelTransactionInput, f as CancelTransactionOutput, g as RefundTransactionInput, h as RefundTransactionOutput, G as GetTransactionByIdInput, i as GetTransactionByIdOutput, j as GetTransactionsByIdReferenceInput, k as GetTransactionsByReferenceIdOutput, l as GetTransactionsInput, m as GetTransactionsOutput, n as CreateAccountInput, o as CreateAccountOutput, U as UpdateAccountInput, p as UpdateAccountOutput, D as DeleteAccountInput, q as DeleteAccountOutput, r as GetAccountInput, s as GetAccountOutput, u as GetAccountsByOwnerInput, v as GetAccountsByOwnerOutput, L as ListAccountsInput, w as ListAccountsOutput, x as GetAccountIdentifierInput, y as GetAccountIdentifierOutput, z as ListAccountIdentifiersInput, A as ListAccountIdentifiersOutput, B as FindAccountByIdentifierInput, E as FindAccountByIdentifierOutput, H as GetAccountBalanceInput, I as GetAccountBalanceOutput, J as UpdateTransactionConfirmationSentAtInput, K as UpdateTransactionConfirmationSentAtOutput, N as UpdateTransactionStatusInput, O as UpdateTransactionStatusOutput } from '../shared/ledger.
|
|
5
|
+
import { t as tables, C as CreateTransactionInput, a as CreateTransactionOutput, M as MatchTransactionInput, b as MatchTransactionOutput, R as ResolveUnmatchedTransactionInput, c as ResolveUnmatchedTransactionOutput, F as FailTransactionInput, d as FailTransactionOutput, e as CancelTransactionInput, f as CancelTransactionOutput, g as RefundTransactionInput, h as RefundTransactionOutput, G as GetTransactionByIdInput, i as GetTransactionByIdOutput, j as GetTransactionsByIdReferenceInput, k as GetTransactionsByReferenceIdOutput, l as GetTransactionsInput, m as GetTransactionsOutput, n as CreateAccountInput, o as CreateAccountOutput, U as UpdateAccountInput, p as UpdateAccountOutput, D as DeleteAccountInput, q as DeleteAccountOutput, r as GetAccountInput, s as GetAccountOutput, u as GetAccountsByOwnerInput, v as GetAccountsByOwnerOutput, L as ListAccountsInput, w as ListAccountsOutput, x as GetAccountIdentifierInput, y as GetAccountIdentifierOutput, z as ListAccountIdentifiersInput, A as ListAccountIdentifiersOutput, B as FindAccountByIdentifierInput, E as FindAccountByIdentifierOutput, H as GetAccountBalanceInput, I as GetAccountBalanceOutput, J as UpdateTransactionConfirmationSentAtInput, K as UpdateTransactionConfirmationSentAtOutput, N as UpdateTransactionStatusInput, O as UpdateTransactionStatusOutput } from '../shared/ledger.DxnspPg_.cjs';
|
|
6
6
|
import 'zod';
|
|
7
|
-
import '../shared/ledger.
|
|
7
|
+
import '../shared/ledger.CZgIHlf1.cjs';
|
|
8
8
|
import 'drizzle-orm';
|
|
9
9
|
import 'drizzle-orm/sqlite-core';
|
|
10
10
|
import '@develit-io/general-codes';
|
package/dist/export/worker.d.mts
CHANGED
|
@@ -2,9 +2,9 @@ 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
4
|
import { DrizzleD1Database } from 'drizzle-orm/d1';
|
|
5
|
-
import { t as tables, C as CreateTransactionInput, a as CreateTransactionOutput, M as MatchTransactionInput, b as MatchTransactionOutput, R as ResolveUnmatchedTransactionInput, c as ResolveUnmatchedTransactionOutput, F as FailTransactionInput, d as FailTransactionOutput, e as CancelTransactionInput, f as CancelTransactionOutput, g as RefundTransactionInput, h as RefundTransactionOutput, G as GetTransactionByIdInput, i as GetTransactionByIdOutput, j as GetTransactionsByIdReferenceInput, k as GetTransactionsByReferenceIdOutput, l as GetTransactionsInput, m as GetTransactionsOutput, n as CreateAccountInput, o as CreateAccountOutput, U as UpdateAccountInput, p as UpdateAccountOutput, D as DeleteAccountInput, q as DeleteAccountOutput, r as GetAccountInput, s as GetAccountOutput, u as GetAccountsByOwnerInput, v as GetAccountsByOwnerOutput, L as ListAccountsInput, w as ListAccountsOutput, x as GetAccountIdentifierInput, y as GetAccountIdentifierOutput, z as ListAccountIdentifiersInput, A as ListAccountIdentifiersOutput, B as FindAccountByIdentifierInput, E as FindAccountByIdentifierOutput, H as GetAccountBalanceInput, I as GetAccountBalanceOutput, J as UpdateTransactionConfirmationSentAtInput, K as UpdateTransactionConfirmationSentAtOutput, N as UpdateTransactionStatusInput, O as UpdateTransactionStatusOutput } from '../shared/ledger.
|
|
5
|
+
import { t as tables, C as CreateTransactionInput, a as CreateTransactionOutput, M as MatchTransactionInput, b as MatchTransactionOutput, R as ResolveUnmatchedTransactionInput, c as ResolveUnmatchedTransactionOutput, F as FailTransactionInput, d as FailTransactionOutput, e as CancelTransactionInput, f as CancelTransactionOutput, g as RefundTransactionInput, h as RefundTransactionOutput, G as GetTransactionByIdInput, i as GetTransactionByIdOutput, j as GetTransactionsByIdReferenceInput, k as GetTransactionsByReferenceIdOutput, l as GetTransactionsInput, m as GetTransactionsOutput, n as CreateAccountInput, o as CreateAccountOutput, U as UpdateAccountInput, p as UpdateAccountOutput, D as DeleteAccountInput, q as DeleteAccountOutput, r as GetAccountInput, s as GetAccountOutput, u as GetAccountsByOwnerInput, v as GetAccountsByOwnerOutput, L as ListAccountsInput, w as ListAccountsOutput, x as GetAccountIdentifierInput, y as GetAccountIdentifierOutput, z as ListAccountIdentifiersInput, A as ListAccountIdentifiersOutput, B as FindAccountByIdentifierInput, E as FindAccountByIdentifierOutput, H as GetAccountBalanceInput, I as GetAccountBalanceOutput, J as UpdateTransactionConfirmationSentAtInput, K as UpdateTransactionConfirmationSentAtOutput, N as UpdateTransactionStatusInput, O as UpdateTransactionStatusOutput } from '../shared/ledger.CPKrhfU8.mjs';
|
|
6
6
|
import 'zod';
|
|
7
|
-
import '../shared/ledger.
|
|
7
|
+
import '../shared/ledger.CZgIHlf1.mjs';
|
|
8
8
|
import 'drizzle-orm';
|
|
9
9
|
import 'drizzle-orm/sqlite-core';
|
|
10
10
|
import '@develit-io/general-codes';
|
package/dist/export/worker.d.ts
CHANGED
|
@@ -2,9 +2,9 @@ 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
4
|
import { DrizzleD1Database } from 'drizzle-orm/d1';
|
|
5
|
-
import { t as tables, C as CreateTransactionInput, a as CreateTransactionOutput, M as MatchTransactionInput, b as MatchTransactionOutput, R as ResolveUnmatchedTransactionInput, c as ResolveUnmatchedTransactionOutput, F as FailTransactionInput, d as FailTransactionOutput, e as CancelTransactionInput, f as CancelTransactionOutput, g as RefundTransactionInput, h as RefundTransactionOutput, G as GetTransactionByIdInput, i as GetTransactionByIdOutput, j as GetTransactionsByIdReferenceInput, k as GetTransactionsByReferenceIdOutput, l as GetTransactionsInput, m as GetTransactionsOutput, n as CreateAccountInput, o as CreateAccountOutput, U as UpdateAccountInput, p as UpdateAccountOutput, D as DeleteAccountInput, q as DeleteAccountOutput, r as GetAccountInput, s as GetAccountOutput, u as GetAccountsByOwnerInput, v as GetAccountsByOwnerOutput, L as ListAccountsInput, w as ListAccountsOutput, x as GetAccountIdentifierInput, y as GetAccountIdentifierOutput, z as ListAccountIdentifiersInput, A as ListAccountIdentifiersOutput, B as FindAccountByIdentifierInput, E as FindAccountByIdentifierOutput, H as GetAccountBalanceInput, I as GetAccountBalanceOutput, J as UpdateTransactionConfirmationSentAtInput, K as UpdateTransactionConfirmationSentAtOutput, N as UpdateTransactionStatusInput, O as UpdateTransactionStatusOutput } from '../shared/ledger.
|
|
5
|
+
import { t as tables, C as CreateTransactionInput, a as CreateTransactionOutput, M as MatchTransactionInput, b as MatchTransactionOutput, R as ResolveUnmatchedTransactionInput, c as ResolveUnmatchedTransactionOutput, F as FailTransactionInput, d as FailTransactionOutput, e as CancelTransactionInput, f as CancelTransactionOutput, g as RefundTransactionInput, h as RefundTransactionOutput, G as GetTransactionByIdInput, i as GetTransactionByIdOutput, j as GetTransactionsByIdReferenceInput, k as GetTransactionsByReferenceIdOutput, l as GetTransactionsInput, m as GetTransactionsOutput, n as CreateAccountInput, o as CreateAccountOutput, U as UpdateAccountInput, p as UpdateAccountOutput, D as DeleteAccountInput, q as DeleteAccountOutput, r as GetAccountInput, s as GetAccountOutput, u as GetAccountsByOwnerInput, v as GetAccountsByOwnerOutput, L as ListAccountsInput, w as ListAccountsOutput, x as GetAccountIdentifierInput, y as GetAccountIdentifierOutput, z as ListAccountIdentifiersInput, A as ListAccountIdentifiersOutput, B as FindAccountByIdentifierInput, E as FindAccountByIdentifierOutput, H as GetAccountBalanceInput, I as GetAccountBalanceOutput, J as UpdateTransactionConfirmationSentAtInput, K as UpdateTransactionConfirmationSentAtOutput, N as UpdateTransactionStatusInput, O as UpdateTransactionStatusOutput } from '../shared/ledger.2ZZR5AvH.js';
|
|
6
6
|
import 'zod';
|
|
7
|
-
import '../shared/ledger.
|
|
7
|
+
import '../shared/ledger.CZgIHlf1.js';
|
|
8
8
|
import 'drizzle-orm';
|
|
9
9
|
import 'drizzle-orm/sqlite-core';
|
|
10
10
|
import '@develit-io/general-codes';
|
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.B3xjxvWW.mjs';
|
|
5
5
|
import { eq, and, inArray, or, count, gte, lte, sql, asc, desc } from 'drizzle-orm';
|
|
6
|
-
import { k as createTransactionInputSchema, x as matchTransactionInputSchema, z as resolveUnmatchedTransactionInputSchema, m as failTransactionInputSchema, i as cancelTransactionInputSchema, y as refundTransactionInputSchema, g as REFUNDABLE_TRANSACTION_STATUSES, s as getTransactionByIdInputSchema, t as getTransactionsByReferenceIdInputSchema, u as getTransactionsInputSchema, j as createAccountInputSchema, D as updateAccountInputSchema, l as deleteAccountInputSchema, q as getAccountInputSchema, r as getAccountsByOwnerInputSchema, w as listAccountsInputSchema, p as getAccountIdentifierInputSchema, v as listAccountIdentifiersInputSchema, n as findAccountByIdentifierInputSchema, o as getAccountBalanceInputSchema, F as updateTransactionConfirmationSentAtInputSchema, G as updateTransactionStatusInputSchema } from '../shared/ledger.
|
|
6
|
+
import { k as createTransactionInputSchema, x as matchTransactionInputSchema, z as resolveUnmatchedTransactionInputSchema, m as failTransactionInputSchema, i as cancelTransactionInputSchema, y as refundTransactionInputSchema, g as REFUNDABLE_TRANSACTION_STATUSES, s as getTransactionByIdInputSchema, t as getTransactionsByReferenceIdInputSchema, u as getTransactionsInputSchema, j as createAccountInputSchema, D as updateAccountInputSchema, l as deleteAccountInputSchema, q as getAccountInputSchema, r as getAccountsByOwnerInputSchema, w as listAccountsInputSchema, p as getAccountIdentifierInputSchema, v as listAccountIdentifiersInputSchema, n as findAccountByIdentifierInputSchema, o as getAccountBalanceInputSchema, F as updateTransactionConfirmationSentAtInputSchema, G as updateTransactionStatusInputSchema } from '../shared/ledger.DvHIBJap.mjs';
|
|
7
7
|
import '@develit-io/general-codes';
|
|
8
8
|
import 'drizzle-orm/sqlite-core';
|
|
9
9
|
import 'zod';
|
|
@@ -46,6 +46,7 @@ const updateTransactionStatusCommand = (db, data) => {
|
|
|
46
46
|
transactionId,
|
|
47
47
|
status,
|
|
48
48
|
paymentId,
|
|
49
|
+
paymentRequestId,
|
|
49
50
|
completedAt,
|
|
50
51
|
statusReason,
|
|
51
52
|
receivedValue,
|
|
@@ -57,6 +58,7 @@ const updateTransactionStatusCommand = (db, data) => {
|
|
|
57
58
|
updatedAt: /* @__PURE__ */ new Date(),
|
|
58
59
|
completedAt,
|
|
59
60
|
paymentId,
|
|
61
|
+
...paymentRequestId !== void 0 && { paymentRequestId },
|
|
60
62
|
...receivedValue !== void 0 && { receivedValue },
|
|
61
63
|
...metadata !== void 0 && { metadata }
|
|
62
64
|
}).where(eq(tables.transaction.id, transactionId)).returning();
|
|
@@ -249,6 +251,8 @@ const getTransactionsWithPaginationQuery = async ({
|
|
|
249
251
|
filterTransactionCompletedAt,
|
|
250
252
|
filterTransactionStatus,
|
|
251
253
|
filterTransactionStatuses,
|
|
254
|
+
filterTransactionPaymentIds,
|
|
255
|
+
filterTransactionPaymentRequestIds,
|
|
252
256
|
search
|
|
253
257
|
}
|
|
254
258
|
}) => {
|
|
@@ -270,7 +274,12 @@ const getTransactionsWithPaginationQuery = async ({
|
|
|
270
274
|
filterTransactionDateTo ? lte(tables.transaction.createdAt, filterTransactionDateTo) : void 0,
|
|
271
275
|
filterTransactionCompletedAt ? eq(tables.transaction.completedAt, filterTransactionCompletedAt) : void 0,
|
|
272
276
|
filterTransactionStatus ? eq(tables.transaction.status, filterTransactionStatus) : void 0,
|
|
273
|
-
filterTransactionStatuses?.length ? inArray(tables.transaction.status, filterTransactionStatuses) : void 0
|
|
277
|
+
filterTransactionStatuses?.length ? inArray(tables.transaction.status, filterTransactionStatuses) : void 0,
|
|
278
|
+
filterTransactionPaymentIds?.length ? inArray(tables.transaction.paymentId, filterTransactionPaymentIds) : void 0,
|
|
279
|
+
filterTransactionPaymentRequestIds?.length ? inArray(
|
|
280
|
+
tables.transaction.paymentRequestId,
|
|
281
|
+
filterTransactionPaymentRequestIds
|
|
282
|
+
) : void 0
|
|
274
283
|
);
|
|
275
284
|
const sortColumn = resolveColumn(tables.transaction, sort.column);
|
|
276
285
|
const [{ totalCount }] = await db.select({ totalCount: sql`count(*)` }).from(tables.transaction).where(whereConditions);
|
|
@@ -339,6 +348,7 @@ let LedgerServiceBase = class extends develitWorker(
|
|
|
339
348
|
type,
|
|
340
349
|
description,
|
|
341
350
|
paymentId,
|
|
351
|
+
paymentRequestId,
|
|
342
352
|
metadata,
|
|
343
353
|
status,
|
|
344
354
|
value,
|
|
@@ -363,6 +373,7 @@ let LedgerServiceBase = class extends develitWorker(
|
|
|
363
373
|
completedAt: null,
|
|
364
374
|
status,
|
|
365
375
|
paymentId,
|
|
376
|
+
paymentRequestId,
|
|
366
377
|
metadata,
|
|
367
378
|
updatedAt: timestamp,
|
|
368
379
|
value,
|
|
@@ -415,6 +426,7 @@ let LedgerServiceBase = class extends develitWorker(
|
|
|
415
426
|
async _applyMatchAmount({
|
|
416
427
|
existingTransaction,
|
|
417
428
|
paymentId,
|
|
429
|
+
paymentRequestId,
|
|
418
430
|
amount,
|
|
419
431
|
completedAt,
|
|
420
432
|
extraMetadata
|
|
@@ -441,6 +453,7 @@ let LedgerServiceBase = class extends develitWorker(
|
|
|
441
453
|
status: isFullyMatched ? "MATCHED" : "PARTIALLY_MATCHED",
|
|
442
454
|
completedAt: isFullyMatched ? completedAt : void 0,
|
|
443
455
|
paymentId,
|
|
456
|
+
paymentRequestId,
|
|
444
457
|
receivedValue: newReceivedValue,
|
|
445
458
|
metadata: updatedMetadata
|
|
446
459
|
}).command.execute().then(first);
|
|
@@ -460,7 +473,8 @@ let LedgerServiceBase = class extends develitWorker(
|
|
|
460
473
|
transactionId,
|
|
461
474
|
status: "MATCHED",
|
|
462
475
|
completedAt,
|
|
463
|
-
paymentId
|
|
476
|
+
paymentId,
|
|
477
|
+
paymentRequestId
|
|
464
478
|
}).command.execute().then(first);
|
|
465
479
|
if (!transaction) {
|
|
466
480
|
throw createInternalError(null, {
|
|
@@ -476,7 +490,13 @@ let LedgerServiceBase = class extends develitWorker(
|
|
|
476
490
|
{ data: input, schema: matchTransactionInputSchema },
|
|
477
491
|
{ successMessage: "Transaction successfully matched." },
|
|
478
492
|
async (params) => {
|
|
479
|
-
const {
|
|
493
|
+
const {
|
|
494
|
+
transactionId,
|
|
495
|
+
completedAt,
|
|
496
|
+
paymentId,
|
|
497
|
+
paymentRequestId,
|
|
498
|
+
amount
|
|
499
|
+
} = params;
|
|
480
500
|
const existingTransaction = await getTransactionByIdQuery(
|
|
481
501
|
this.db,
|
|
482
502
|
transactionId
|
|
@@ -498,6 +518,7 @@ let LedgerServiceBase = class extends develitWorker(
|
|
|
498
518
|
const { transaction, signal } = await this._applyMatchAmount({
|
|
499
519
|
existingTransaction,
|
|
500
520
|
paymentId,
|
|
521
|
+
paymentRequestId,
|
|
501
522
|
amount,
|
|
502
523
|
completedAt
|
|
503
524
|
});
|
|
@@ -1107,7 +1128,14 @@ let LedgerServiceBase = class extends develitWorker(
|
|
|
1107
1128
|
{ data: input, schema: updateTransactionStatusInputSchema },
|
|
1108
1129
|
{ successMessage: "Transaction status successfully updated." },
|
|
1109
1130
|
async (params) => {
|
|
1110
|
-
const {
|
|
1131
|
+
const {
|
|
1132
|
+
transactionId,
|
|
1133
|
+
status,
|
|
1134
|
+
statusReason,
|
|
1135
|
+
paymentId,
|
|
1136
|
+
paymentRequestId,
|
|
1137
|
+
completedAt
|
|
1138
|
+
} = params;
|
|
1111
1139
|
const existingTransaction = await getTransactionByIdQuery(
|
|
1112
1140
|
this.db,
|
|
1113
1141
|
transactionId
|
|
@@ -1124,6 +1152,7 @@ let LedgerServiceBase = class extends develitWorker(
|
|
|
1124
1152
|
status,
|
|
1125
1153
|
statusReason,
|
|
1126
1154
|
paymentId,
|
|
1155
|
+
paymentRequestId,
|
|
1127
1156
|
completedAt
|
|
1128
1157
|
});
|
|
1129
1158
|
const [updatedTransaction] = await this.db.batch([command]);
|