@windrun-huaiin/backend-core 28.0.0 → 29.0.0
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/app/api/stripe/checkout/route.js +0 -1
- package/dist/app/api/stripe/checkout/route.mjs +0 -1
- package/dist/app/api/stripe/customer-portal/route.js +0 -1
- package/dist/app/api/stripe/customer-portal/route.mjs +0 -1
- package/dist/app/api/user/credit-overview/route.d.ts +13 -0
- package/dist/app/api/user/credit-overview/route.d.ts.map +1 -0
- package/dist/app/api/user/credit-overview/route.js +32 -0
- package/dist/app/api/user/credit-overview/route.mjs +30 -0
- package/dist/app/api/user/pricing-context/route.d.ts +3 -0
- package/dist/app/api/user/pricing-context/route.d.ts.map +1 -0
- package/dist/app/api/user/pricing-context/route.js +19 -0
- package/dist/app/api/user/pricing-context/route.mjs +17 -0
- package/dist/app/api/webhook/clerk/user/route.js +0 -1
- package/dist/app/api/webhook/clerk/user/route.mjs +0 -1
- package/dist/auth/auth-utils.js +0 -1
- package/dist/auth/auth-utils.mjs +0 -1
- package/dist/credit/server.d.ts +1 -0
- package/dist/credit/server.d.ts.map +1 -1
- package/dist/credit/server.js +2 -0
- package/dist/credit/server.mjs +1 -0
- package/dist/index.js +0 -3
- package/dist/index.mjs +0 -3
- package/dist/lib/credit-overview.d.ts +17 -0
- package/dist/lib/credit-overview.d.ts.map +1 -0
- package/dist/lib/credit-overview.js +116 -0
- package/dist/lib/credit-overview.mjs +114 -0
- package/dist/lib/stripe-config.js +0 -1
- package/dist/lib/stripe-config.mjs +0 -1
- package/dist/prisma/index.d.ts +2 -2
- package/dist/prisma/index.d.ts.map +1 -1
- package/dist/prisma/index.js +0 -3
- package/dist/prisma/index.mjs +0 -3
- package/dist/prisma/prisma-transaction-util.d.ts +1 -1
- package/dist/prisma/prisma-transaction-util.d.ts.map +1 -1
- package/dist/prisma/prisma.d.ts +6 -6
- package/dist/prisma/prisma.d.ts.map +1 -1
- package/dist/prisma/prisma.js +4 -37
- package/dist/prisma/prisma.mjs +4 -37
- package/dist/services/aggregate/anonymous.aggregate.service.d.ts +2 -3
- package/dist/services/aggregate/anonymous.aggregate.service.d.ts.map +1 -1
- package/dist/services/aggregate/anonymous.aggregate.service.js +2 -8
- package/dist/services/aggregate/anonymous.aggregate.service.mjs +2 -8
- package/dist/services/aggregate/billing.aggregate.service.js +0 -1
- package/dist/services/aggregate/billing.aggregate.service.mjs +0 -1
- package/dist/services/aggregate/user.aggregate.service.d.ts +3 -3
- package/dist/services/aggregate/user.aggregate.service.d.ts.map +1 -1
- package/dist/services/aggregate/user.aggregate.service.js +0 -1
- package/dist/services/aggregate/user.aggregate.service.mjs +0 -1
- package/dist/services/context/user-context-service.js +0 -1
- package/dist/services/context/user-context-service.mjs +0 -1
- package/dist/services/database/apilog.service.js +0 -1
- package/dist/services/database/apilog.service.mjs +0 -1
- package/dist/services/database/core-entities.d.ts +123 -0
- package/dist/services/database/core-entities.d.ts.map +1 -0
- package/dist/services/database/credit.service.d.ts +1 -1
- package/dist/services/database/credit.service.d.ts.map +1 -1
- package/dist/services/database/credit.service.js +3 -8
- package/dist/services/database/credit.service.mjs +3 -8
- package/dist/services/database/creditAuditLog.service.d.ts +1 -1
- package/dist/services/database/creditAuditLog.service.d.ts.map +1 -1
- package/dist/services/database/creditAuditLog.service.js +6 -6
- package/dist/services/database/creditAuditLog.service.mjs +6 -6
- package/dist/services/database/prisma-model-type.d.ts +28 -2
- package/dist/services/database/prisma-model-type.d.ts.map +1 -1
- package/dist/services/database/subscription.service.js +1 -2
- package/dist/services/database/subscription.service.mjs +1 -2
- package/dist/services/database/transaction.service.d.ts +1 -1
- package/dist/services/database/transaction.service.d.ts.map +1 -1
- package/dist/services/database/transaction.service.js +14 -19
- package/dist/services/database/transaction.service.mjs +14 -19
- package/dist/services/database/user.service.d.ts +13 -4
- package/dist/services/database/user.service.d.ts.map +1 -1
- package/dist/services/database/user.service.js +5 -3
- package/dist/services/database/user.service.mjs +5 -3
- package/dist/services/database/userBackup.service.js +0 -1
- package/dist/services/database/userBackup.service.mjs +0 -1
- package/dist/services/stripe/webhook-handler.js +0 -1
- package/dist/services/stripe/webhook-handler.mjs +0 -1
- package/package.json +18 -15
- package/src/app/api/user/anonymous/init/route.ts +2 -2
- package/src/app/api/user/credit-overview/route.ts +43 -0
- package/src/app/api/user/pricing-context/route.ts +14 -0
- package/src/credit/server.ts +1 -0
- package/src/lib/credit-overview.ts +153 -0
- package/src/prisma/index.ts +6 -2
- package/src/prisma/prisma-transaction-util.ts +1 -1
- package/src/prisma/prisma.ts +14 -47
- package/src/services/aggregate/anonymous.aggregate.service.ts +7 -9
- package/src/services/aggregate/user.aggregate.service.ts +3 -3
- package/src/services/database/core-entities.ts +128 -0
- package/src/services/database/credit.service.ts +7 -8
- package/src/services/database/creditAuditLog.service.ts +11 -9
- package/src/services/database/prisma-model-type.ts +33 -4
- package/src/services/database/subscription.service.ts +2 -2
- package/src/services/database/transaction.service.ts +22 -23
- package/src/services/database/user.service.ts +23 -6
- package/dist/core-prisma/browser.d.ts +0 -40
- package/dist/core-prisma/browser.d.ts.map +0 -1
- package/dist/core-prisma/client.d.ts +0 -57
- package/dist/core-prisma/client.d.ts.map +0 -1
- package/dist/core-prisma/client.js +0 -55
- package/dist/core-prisma/client.mjs +0 -33
- package/dist/core-prisma/commonInputTypes.d.ts +0 -495
- package/dist/core-prisma/commonInputTypes.d.ts.map +0 -1
- package/dist/core-prisma/enums.d.ts +0 -2
- package/dist/core-prisma/enums.d.ts.map +0 -1
- package/dist/core-prisma/internal/class.d.ts +0 -193
- package/dist/core-prisma/internal/class.d.ts.map +0 -1
- package/dist/core-prisma/internal/class.js +0 -108
- package/dist/core-prisma/internal/class.mjs +0 -87
- package/dist/core-prisma/internal/prismaNamespace.d.ts +0 -1180
- package/dist/core-prisma/internal/prismaNamespace.d.ts.map +0 -1
- package/dist/core-prisma/internal/prismaNamespace.js +0 -278
- package/dist/core-prisma/internal/prismaNamespace.mjs +0 -226
- package/dist/core-prisma/internal/prismaNamespaceBrowser.d.ts +0 -233
- package/dist/core-prisma/internal/prismaNamespaceBrowser.d.ts.map +0 -1
- package/dist/core-prisma/models/Apilog.d.ts +0 -1088
- package/dist/core-prisma/models/Apilog.d.ts.map +0 -1
- package/dist/core-prisma/models/Credit.d.ts +0 -1554
- package/dist/core-prisma/models/Credit.d.ts.map +0 -1
- package/dist/core-prisma/models/CreditAuditLog.d.ts +0 -1362
- package/dist/core-prisma/models/CreditAuditLog.d.ts.map +0 -1
- package/dist/core-prisma/models/Subscription.d.ts +0 -1441
- package/dist/core-prisma/models/Subscription.d.ts.map +0 -1
- package/dist/core-prisma/models/Transaction.d.ts +0 -2222
- package/dist/core-prisma/models/Transaction.d.ts.map +0 -1
- package/dist/core-prisma/models/User.d.ts +0 -1775
- package/dist/core-prisma/models/User.d.ts.map +0 -1
- package/dist/core-prisma/models/UserBackup.d.ts +0 -1228
- package/dist/core-prisma/models/UserBackup.d.ts.map +0 -1
- package/dist/core-prisma/models.d.ts +0 -9
- package/dist/core-prisma/models.d.ts.map +0 -1
- package/migrations/create.sql +0 -176
- package/migrations/init-schema.sql +0 -20
- package/prisma/schema.prisma +0 -193
- package/src/core-prisma/browser.ts +0 -54
- package/src/core-prisma/client.ts +0 -78
- package/src/core-prisma/commonInputTypes.ts +0 -565
- package/src/core-prisma/enums.ts +0 -15
- package/src/core-prisma/internal/class.ts +0 -293
- package/src/core-prisma/internal/prismaNamespace.ts +0 -1419
- package/src/core-prisma/internal/prismaNamespaceBrowser.ts +0 -259
- package/src/core-prisma/models/Apilog.ts +0 -1244
- package/src/core-prisma/models/Credit.ts +0 -1722
- package/src/core-prisma/models/CreditAuditLog.ts +0 -1536
- package/src/core-prisma/models/Subscription.ts +0 -1610
- package/src/core-prisma/models/Transaction.ts +0 -2398
- package/src/core-prisma/models/User.ts +0 -1982
- package/src/core-prisma/models/UserBackup.ts +0 -1384
- package/src/core-prisma/models.ts +0 -18
|
@@ -1,3 +1,29 @@
|
|
|
1
|
-
export type { User, Subscription, Credit, CreditAuditLog, Transaction, Apilog, UserBackup, } from '
|
|
2
|
-
|
|
1
|
+
export type { User, Subscription, Credit, CreditAuditLog, Transaction, Apilog, UserBackup, CoreJsonArray, CoreJsonObject, CoreJsonPrimitive, CoreJsonValue, } from './core-entities';
|
|
2
|
+
import type { BackendCoreHostPrismaClient } from '../../prisma/prisma';
|
|
3
|
+
import type { CoreJsonObject, CoreJsonValue } from './core-entities';
|
|
4
|
+
export declare namespace Prisma {
|
|
5
|
+
type TransactionClient = BackendCoreHostPrismaClient;
|
|
6
|
+
type QueryEvent = {
|
|
7
|
+
query: string;
|
|
8
|
+
params: string;
|
|
9
|
+
duration: number;
|
|
10
|
+
};
|
|
11
|
+
type InputJsonValue = CoreJsonValue;
|
|
12
|
+
type InputJsonObject = CoreJsonObject;
|
|
13
|
+
type NullableJsonNullValueInput = null;
|
|
14
|
+
type UserUpdateInput = Record<string, unknown>;
|
|
15
|
+
type CreditUpdateInput = Record<string, unknown>;
|
|
16
|
+
type SubscriptionUpdateInput = Record<string, unknown>;
|
|
17
|
+
type TransactionUpdateInput = Record<string, unknown>;
|
|
18
|
+
type CreditAuditLogUncheckedCreateInput = Record<string, unknown>;
|
|
19
|
+
type CreditAuditLogCreateManyInput = Record<string, unknown>;
|
|
20
|
+
type CreditAuditLogOrderByWithRelationInput = Record<string, unknown>;
|
|
21
|
+
type CreditAuditLogWhereInput = Record<string, any>;
|
|
22
|
+
type TransactionOrderByWithRelationInput = Record<string, unknown>;
|
|
23
|
+
type TransactionWhereInput = Record<string, any>;
|
|
24
|
+
type TransactionCreateManyInput = Record<string, unknown>;
|
|
25
|
+
type UserWhereInput = Record<string, any>;
|
|
26
|
+
type UserBackupOrderByWithRelationInput = Record<string, unknown>;
|
|
27
|
+
type UserBackupWhereInput = Record<string, any>;
|
|
28
|
+
}
|
|
3
29
|
//# sourceMappingURL=prisma-model-type.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prisma-model-type.d.ts","sourceRoot":"","sources":["../../../src/services/database/prisma-model-type.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"prisma-model-type.d.ts","sourceRoot":"","sources":["../../../src/services/database/prisma-model-type.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,IAAI,EACJ,YAAY,EACZ,MAAM,EACN,cAAc,EACd,WAAW,EACX,MAAM,EACN,UAAU,EACV,aAAa,EACb,cAAc,EACd,iBAAiB,EACjB,aAAa,GACd,MAAM,iBAAiB,CAAC;AAEzB,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,qBAAqB,CAAC;AACvE,OAAO,KAAK,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAErE,yBAAiB,MAAM,CAAC;IACtB,KAAY,iBAAiB,GAAG,2BAA2B,CAAC;IAC5D,KAAY,UAAU,GAAG;QACvB,KAAK,EAAE,MAAM,CAAC;QACd,MAAM,EAAE,MAAM,CAAC;QACf,QAAQ,EAAE,MAAM,CAAC;KAClB,CAAC;IACF,KAAY,cAAc,GAAG,aAAa,CAAC;IAC3C,KAAY,eAAe,GAAG,cAAc,CAAC;IAC7C,KAAY,0BAA0B,GAAG,IAAI,CAAC;IAC9C,KAAY,eAAe,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACtD,KAAY,iBAAiB,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACxD,KAAY,uBAAuB,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC9D,KAAY,sBAAsB,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC7D,KAAY,kCAAkC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACzE,KAAY,6BAA6B,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACpE,KAAY,sCAAsC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC7E,KAAY,wBAAwB,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAC3D,KAAY,mCAAmC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC1E,KAAY,qBAAqB,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IACxD,KAAY,0BAA0B,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACjE,KAAY,cAAc,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IACjD,KAAY,kCAAkC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACzE,KAAY,oBAAoB,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;CACxD"}
|
|
@@ -3,7 +3,6 @@
|
|
|
3
3
|
var tslib = require('tslib');
|
|
4
4
|
var constants = require('./constants.js');
|
|
5
5
|
var prisma = require('../../prisma/prisma.js');
|
|
6
|
-
require('../../core-prisma/client.js');
|
|
7
6
|
|
|
8
7
|
class SubscriptionService {
|
|
9
8
|
/**
|
|
@@ -249,7 +248,7 @@ class SubscriptionService {
|
|
|
249
248
|
where: {
|
|
250
249
|
paySubscriptionId: {
|
|
251
250
|
in: activeSubscriptions
|
|
252
|
-
.map(s => s.paySubscriptionId)
|
|
251
|
+
.map((s) => s.paySubscriptionId)
|
|
253
252
|
.filter(Boolean),
|
|
254
253
|
},
|
|
255
254
|
orderStatus: 'success',
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { __awaiter } from 'tslib';
|
|
2
2
|
import { SubscriptionStatus } from './constants.mjs';
|
|
3
3
|
import { checkAndFallbackWithNonTCClient } from '../../prisma/prisma.mjs';
|
|
4
|
-
import '../../core-prisma/client.mjs';
|
|
5
4
|
|
|
6
5
|
class SubscriptionService {
|
|
7
6
|
/**
|
|
@@ -247,7 +246,7 @@ class SubscriptionService {
|
|
|
247
246
|
where: {
|
|
248
247
|
paySubscriptionId: {
|
|
249
248
|
in: activeSubscriptions
|
|
250
|
-
.map(s => s.paySubscriptionId)
|
|
249
|
+
.map((s) => s.paySubscriptionId)
|
|
251
250
|
.filter(Boolean),
|
|
252
251
|
},
|
|
253
252
|
orderStatus: 'success',
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Prisma } from '@core/db/prisma-model-type';
|
|
1
|
+
import type { Prisma } from '@core/db/prisma-model-type';
|
|
2
2
|
import type { Transaction } from '@core/db/prisma-model-type';
|
|
3
3
|
import { PaySupplier } from '@core/db/constants';
|
|
4
4
|
export declare class TransactionService {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transaction.service.d.ts","sourceRoot":"","sources":["../../../src/services/database/transaction.service.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,MAAM,EAAE,MAAM,4BAA4B,CAAC;
|
|
1
|
+
{"version":3,"file":"transaction.service.d.ts","sourceRoot":"","sources":["../../../src/services/database/transaction.service.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,4BAA4B,CAAC;AACzD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AAC9D,OAAO,EAAgC,WAAW,EAAiB,MAAM,oBAAoB,CAAC;AAG9F,qBAAa,kBAAkB;IAGvB,iBAAiB,CAAC,IAAI,EAAE;QAC5B,MAAM,EAAE,MAAM,CAAC;QACf,OAAO,EAAE,MAAM,CAAC;QAChB,WAAW,CAAC,EAAE,MAAM,CAAC;QACrB,aAAa,CAAC,EAAE,MAAM,CAAC;QACvB,WAAW,CAAC,EAAE,WAAW,CAAC;QAC1B,gBAAgB,CAAC,EAAE,MAAM,CAAC;QAC1B,iBAAiB,CAAC,EAAE,MAAM,CAAC;QAC3B,cAAc,CAAC,EAAG,IAAI,CAAC;QACvB,YAAY,CAAC,EAAG,IAAI,CAAC;QACrB,YAAY,CAAC,EAAE,MAAM,CAAC;QAC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B,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC;IA0BjF,iBAAiB,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE,CAAC,EAAE,MAAM,CAAC,iBAAiB,GAAG,OAAO,CAAC,IAAI,CAAC;IAUhF,uBAAuB,CAC3B,YAAY,EAAE,MAAM,CAAC,0BAA0B,EAAE,EACjD,EAAE,CAAC,EAAE,MAAM,CAAC,iBAAiB,GAC5B,OAAO,CAAC,MAAM,CAAC;CASnB;AAED,eAAO,MAAM,kBAAkB,oBAA2B,CAAC"}
|
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var tslib = require('tslib');
|
|
4
|
-
require('../../core-prisma/client.js');
|
|
5
4
|
var constants = require('./constants.js');
|
|
6
5
|
var prisma = require('../../prisma/prisma.js');
|
|
7
|
-
var prismaNamespace = require('../../core-prisma/internal/prismaNamespace.js');
|
|
8
6
|
|
|
9
7
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
10
8
|
class TransactionService {
|
|
@@ -257,10 +255,10 @@ class TransactionService {
|
|
|
257
255
|
// Calculate statistics
|
|
258
256
|
const totalRevenue = successfulTransactions.reduce((sum, t) => sum + (t.amount ? parseFloat(t.amount.toString()) : 0), 0);
|
|
259
257
|
const subscriptionRevenue = successfulTransactions
|
|
260
|
-
.filter(t => t.type === constants.TransactionType.SUBSCRIPTION)
|
|
258
|
+
.filter((t) => t.type === constants.TransactionType.SUBSCRIPTION)
|
|
261
259
|
.reduce((sum, t) => sum + (t.amount ? parseFloat(t.amount.toString()) : 0), 0);
|
|
262
260
|
const oneTimeRevenue = successfulTransactions
|
|
263
|
-
.filter(t => t.type === constants.TransactionType.ONE_TIME)
|
|
261
|
+
.filter((t) => t.type === constants.TransactionType.ONE_TIME)
|
|
264
262
|
.reduce((sum, t) => sum + (t.amount ? parseFloat(t.amount.toString()) : 0), 0);
|
|
265
263
|
const refundedAmount = refundedTransactions.reduce((sum, t) => sum + (t.amount ? parseFloat(t.amount.toString()) : 0), 0);
|
|
266
264
|
return {
|
|
@@ -281,21 +279,18 @@ class TransactionService {
|
|
|
281
279
|
const startDate = new Date();
|
|
282
280
|
startDate.setDate(startDate.getDate() - days);
|
|
283
281
|
const client = prisma.checkAndFallbackWithNonTCClient(tx);
|
|
284
|
-
const
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
ORDER BY date DESC
|
|
297
|
-
`;
|
|
298
|
-
const result = yield client.$queryRaw(query);
|
|
282
|
+
const result = yield client.$queryRawUnsafe(`SELECT
|
|
283
|
+
DATE(paid_at) as date,
|
|
284
|
+
COUNT(*) as transactions,
|
|
285
|
+
SUM(amount) as revenue,
|
|
286
|
+
SUM(CASE WHEN type = 'subscription' THEN amount ELSE 0 END) as subscription_revenue,
|
|
287
|
+
SUM(CASE WHEN type = 'one_time' THEN amount ELSE 0 END) as onetime_revenue
|
|
288
|
+
FROM transactions
|
|
289
|
+
WHERE order_status = 'success'
|
|
290
|
+
AND deleted = 0
|
|
291
|
+
AND paid_at >= $1
|
|
292
|
+
GROUP BY DATE(paid_at)
|
|
293
|
+
ORDER BY date DESC`, startDate);
|
|
299
294
|
return result;
|
|
300
295
|
});
|
|
301
296
|
}
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import { __awaiter } from 'tslib';
|
|
2
|
-
import '../../core-prisma/client.mjs';
|
|
3
2
|
import { PaymentStatus, OrderStatus, TransactionType } from './constants.mjs';
|
|
4
3
|
import { checkAndFallbackWithNonTCClient } from '../../prisma/prisma.mjs';
|
|
5
|
-
import { sql } from '../../core-prisma/internal/prismaNamespace.mjs';
|
|
6
4
|
|
|
7
5
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
8
6
|
class TransactionService {
|
|
@@ -255,10 +253,10 @@ class TransactionService {
|
|
|
255
253
|
// Calculate statistics
|
|
256
254
|
const totalRevenue = successfulTransactions.reduce((sum, t) => sum + (t.amount ? parseFloat(t.amount.toString()) : 0), 0);
|
|
257
255
|
const subscriptionRevenue = successfulTransactions
|
|
258
|
-
.filter(t => t.type === TransactionType.SUBSCRIPTION)
|
|
256
|
+
.filter((t) => t.type === TransactionType.SUBSCRIPTION)
|
|
259
257
|
.reduce((sum, t) => sum + (t.amount ? parseFloat(t.amount.toString()) : 0), 0);
|
|
260
258
|
const oneTimeRevenue = successfulTransactions
|
|
261
|
-
.filter(t => t.type === TransactionType.ONE_TIME)
|
|
259
|
+
.filter((t) => t.type === TransactionType.ONE_TIME)
|
|
262
260
|
.reduce((sum, t) => sum + (t.amount ? parseFloat(t.amount.toString()) : 0), 0);
|
|
263
261
|
const refundedAmount = refundedTransactions.reduce((sum, t) => sum + (t.amount ? parseFloat(t.amount.toString()) : 0), 0);
|
|
264
262
|
return {
|
|
@@ -279,21 +277,18 @@ class TransactionService {
|
|
|
279
277
|
const startDate = new Date();
|
|
280
278
|
startDate.setDate(startDate.getDate() - days);
|
|
281
279
|
const client = checkAndFallbackWithNonTCClient(tx);
|
|
282
|
-
const
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
ORDER BY date DESC
|
|
295
|
-
`;
|
|
296
|
-
const result = yield client.$queryRaw(query);
|
|
280
|
+
const result = yield client.$queryRawUnsafe(`SELECT
|
|
281
|
+
DATE(paid_at) as date,
|
|
282
|
+
COUNT(*) as transactions,
|
|
283
|
+
SUM(amount) as revenue,
|
|
284
|
+
SUM(CASE WHEN type = 'subscription' THEN amount ELSE 0 END) as subscription_revenue,
|
|
285
|
+
SUM(CASE WHEN type = 'one_time' THEN amount ELSE 0 END) as onetime_revenue
|
|
286
|
+
FROM transactions
|
|
287
|
+
WHERE order_status = 'success'
|
|
288
|
+
AND deleted = 0
|
|
289
|
+
AND paid_at >= $1
|
|
290
|
+
GROUP BY DATE(paid_at)
|
|
291
|
+
ORDER BY date DESC`, startDate);
|
|
297
292
|
return result;
|
|
298
293
|
});
|
|
299
294
|
}
|
|
@@ -1,9 +1,18 @@
|
|
|
1
1
|
import type { Prisma } from '@core/db/prisma-model-type';
|
|
2
|
-
import type { User } from '@core/db/prisma-model-type';
|
|
2
|
+
import type { CoreJsonValue, User } from '@core/db/prisma-model-type';
|
|
3
|
+
export interface UpdateUserInput {
|
|
4
|
+
fingerprintId?: string | null;
|
|
5
|
+
sourceRef?: CoreJsonValue | null;
|
|
6
|
+
clerkUserId?: string | null;
|
|
7
|
+
stripeCusId?: string | null;
|
|
8
|
+
email?: string | null;
|
|
9
|
+
userName?: string | null;
|
|
10
|
+
status?: string;
|
|
11
|
+
}
|
|
3
12
|
export declare class UserService {
|
|
4
13
|
createUser(data: {
|
|
5
14
|
fingerprintId?: string;
|
|
6
|
-
sourceRef?:
|
|
15
|
+
sourceRef?: CoreJsonValue;
|
|
7
16
|
clerkUserId?: string;
|
|
8
17
|
stripeCusId?: string;
|
|
9
18
|
email?: string;
|
|
@@ -14,7 +23,7 @@ export declare class UserService {
|
|
|
14
23
|
findByEmail(email: string, tx?: Prisma.TransactionClient): Promise<User | null>;
|
|
15
24
|
findListByFingerprintId(fingerprintId: string, tx?: Prisma.TransactionClient): Promise<User[]>;
|
|
16
25
|
findByClerkUserId(clerkUserId: string, tx?: Prisma.TransactionClient): Promise<User | null>;
|
|
17
|
-
updateUser(userId: string, data:
|
|
26
|
+
updateUser(userId: string, data: UpdateUserInput, tx?: Prisma.TransactionClient): Promise<User>;
|
|
18
27
|
updateStripeCustomerId(userId: string, stripeCusId: string | null, tx?: Prisma.TransactionClient): Promise<User>;
|
|
19
28
|
upgradeToRegistered(userId: string, data: {
|
|
20
29
|
email: string;
|
|
@@ -26,7 +35,7 @@ export declare class UserService {
|
|
|
26
35
|
skip?: number;
|
|
27
36
|
take?: number;
|
|
28
37
|
status?: string;
|
|
29
|
-
orderBy?:
|
|
38
|
+
orderBy?: Record<string, 'asc' | 'desc'>;
|
|
30
39
|
}, tx?: Prisma.TransactionClient): Promise<{
|
|
31
40
|
users: User[];
|
|
32
41
|
total: number;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"user.service.d.ts","sourceRoot":"","sources":["../../../src/services/database/user.service.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,4BAA4B,CAAC;AACzD,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,4BAA4B,CAAC;
|
|
1
|
+
{"version":3,"file":"user.service.d.ts","sourceRoot":"","sources":["../../../src/services/database/user.service.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,4BAA4B,CAAC;AACzD,OAAO,KAAK,EAAE,aAAa,EAAE,IAAI,EAAE,MAAM,4BAA4B,CAAC;AAItE,MAAM,WAAW,eAAe;IAC9B,aAAa,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC9B,SAAS,CAAC,EAAE,aAAa,GAAG,IAAI,CAAC;IACjC,WAAW,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B,WAAW,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAMD,qBAAa,WAAW;IAGhB,UAAU,CAAC,IAAI,EAAE;QACrB,aAAa,CAAC,EAAE,MAAM,CAAC;QACvB,SAAS,CAAC,EAAE,aAAa,CAAC;QAC1B,WAAW,CAAC,EAAE,MAAM,CAAC;QACrB,WAAW,CAAC,EAAE,MAAM,CAAC;QACrB,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,QAAQ,CAAC,EAAE,MAAM,CAA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AAI,CAAC;IAYxE,SAAS,CAAC,MAAM,EAAE;QACtB,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,KAAK,GAAG,MAAM,CAAC,CAAC;KAC1C,EAAE,EAAE,CAAC,EAAE,MAAM,CAAC,iBAAiB,GAAG,OAAO,CAAC;QAAE,KAAK,EAAE,IAAI,EAAE,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC;IAoBtE,yBAAyB,CAC7B,cAAc,EAAE,MAAM,EAAE,EACxB,EAAE,CAAC,EAAE,MAAM,CAAC,iBAAiB,GAC5B,OAAO,CAAC,MAAM,CAAC;IAgBZ,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,EAAE,CAAC,EAAE,MAAM,CAAC,iBAAiB,GAAG,OAAO,CAAC,OAAO,CAAC;IASvE,YAAY,CAAC,EAAE,CAAC,EAAE,MAAM,CAAC,iBAAiB,GAAG,OAAO,CAAC;QACzD,KAAK,EAAE,MAAM,CAAC;QACd,SAAS,EAAE,MAAM,CAAC;QAClB,UAAU,EAAE,MAAM,CAAC;QACnB,MAAM,EAAE,MAAM,CAAC;QACf,OAAO,EAAE,MAAM,CAAC;KACjB,CAAC;CAYH;AAED,eAAO,MAAM,WAAW,aAAoB,CAAC"}
|
|
@@ -3,9 +3,11 @@
|
|
|
3
3
|
var tslib = require('tslib');
|
|
4
4
|
var constants = require('./constants.js');
|
|
5
5
|
var prisma = require('../../prisma/prisma.js');
|
|
6
|
-
require('../../core-prisma/client.js');
|
|
7
6
|
|
|
8
7
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
8
|
+
function toPrismaJsonValue(value) {
|
|
9
|
+
return value === undefined ? undefined : value;
|
|
10
|
+
}
|
|
9
11
|
class UserService {
|
|
10
12
|
// Create user
|
|
11
13
|
createUser(data, tx) {
|
|
@@ -14,7 +16,7 @@ class UserService {
|
|
|
14
16
|
return yield client.user.create({
|
|
15
17
|
data: {
|
|
16
18
|
fingerprintId: data.fingerprintId,
|
|
17
|
-
sourceRef: data.sourceRef,
|
|
19
|
+
sourceRef: toPrismaJsonValue(data.sourceRef),
|
|
18
20
|
clerkUserId: data.clerkUserId,
|
|
19
21
|
stripeCusId: data.stripeCusId,
|
|
20
22
|
email: data.email,
|
|
@@ -78,7 +80,7 @@ class UserService {
|
|
|
78
80
|
const client = prisma.checkAndFallbackWithNonTCClient(tx);
|
|
79
81
|
return yield client.user.update({
|
|
80
82
|
where: { userId },
|
|
81
|
-
data,
|
|
83
|
+
data: Object.assign(Object.assign({}, data), { sourceRef: toPrismaJsonValue(data.sourceRef) }),
|
|
82
84
|
});
|
|
83
85
|
});
|
|
84
86
|
}
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import { __awaiter } from 'tslib';
|
|
2
2
|
import { UserStatus } from './constants.mjs';
|
|
3
3
|
import { checkAndFallbackWithNonTCClient } from '../../prisma/prisma.mjs';
|
|
4
|
-
import '../../core-prisma/client.mjs';
|
|
5
4
|
|
|
6
5
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
6
|
+
function toPrismaJsonValue(value) {
|
|
7
|
+
return value === undefined ? undefined : value;
|
|
8
|
+
}
|
|
7
9
|
class UserService {
|
|
8
10
|
// Create user
|
|
9
11
|
createUser(data, tx) {
|
|
@@ -12,7 +14,7 @@ class UserService {
|
|
|
12
14
|
return yield client.user.create({
|
|
13
15
|
data: {
|
|
14
16
|
fingerprintId: data.fingerprintId,
|
|
15
|
-
sourceRef: data.sourceRef,
|
|
17
|
+
sourceRef: toPrismaJsonValue(data.sourceRef),
|
|
16
18
|
clerkUserId: data.clerkUserId,
|
|
17
19
|
stripeCusId: data.stripeCusId,
|
|
18
20
|
email: data.email,
|
|
@@ -76,7 +78,7 @@ class UserService {
|
|
|
76
78
|
const client = checkAndFallbackWithNonTCClient(tx);
|
|
77
79
|
return yield client.user.update({
|
|
78
80
|
where: { userId },
|
|
79
|
-
data,
|
|
81
|
+
data: Object.assign(Object.assign({}, data), { sourceRef: toPrismaJsonValue(data.sourceRef) }),
|
|
80
82
|
});
|
|
81
83
|
});
|
|
82
84
|
}
|
|
@@ -4,7 +4,6 @@ var tslib = require('tslib');
|
|
|
4
4
|
var billing_aggregate_service = require('../aggregate/billing.aggregate.service.js');
|
|
5
5
|
var constants = require('../database/constants.js');
|
|
6
6
|
require('../../prisma/prisma.js');
|
|
7
|
-
require('../../core-prisma/client.js');
|
|
8
7
|
var subscription_service = require('../database/subscription.service.js');
|
|
9
8
|
require('../database/credit.service.js');
|
|
10
9
|
var transaction_service = require('../database/transaction.service.js');
|
|
@@ -2,7 +2,6 @@ import { __awaiter } from 'tslib';
|
|
|
2
2
|
import { billingAggregateService } from '../aggregate/billing.aggregate.service.mjs';
|
|
3
3
|
import { OrderStatus, TransactionType, PaymentStatus, BillingReason } from '../database/constants.mjs';
|
|
4
4
|
import '../../prisma/prisma.mjs';
|
|
5
|
-
import '../../core-prisma/client.mjs';
|
|
6
5
|
import { subscriptionService } from '../database/subscription.service.mjs';
|
|
7
6
|
import '../database/credit.service.mjs';
|
|
8
7
|
import { transactionService } from '../database/transaction.service.mjs';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@windrun-huaiin/backend-core",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "29.0.0",
|
|
4
4
|
"description": "Shared backend primitives: Prisma schema/client, database services, routing helpers",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -107,6 +107,16 @@
|
|
|
107
107
|
"import": "./dist/app/api/user/anonymous/init/route.mjs",
|
|
108
108
|
"require": "./dist/app/api/user/anonymous/init/route.js"
|
|
109
109
|
},
|
|
110
|
+
"./app/api/user/credit-overview/route": {
|
|
111
|
+
"types": "./dist/app/api/user/credit-overview/route.d.ts",
|
|
112
|
+
"import": "./dist/app/api/user/credit-overview/route.mjs",
|
|
113
|
+
"require": "./dist/app/api/user/credit-overview/route.js"
|
|
114
|
+
},
|
|
115
|
+
"./app/api/user/pricing-context/route": {
|
|
116
|
+
"types": "./dist/app/api/user/pricing-context/route.d.ts",
|
|
117
|
+
"import": "./dist/app/api/user/pricing-context/route.mjs",
|
|
118
|
+
"require": "./dist/app/api/user/pricing-context/route.js"
|
|
119
|
+
},
|
|
110
120
|
"./app/api/stripe/checkout/route": {
|
|
111
121
|
"types": "./dist/app/api/stripe/checkout/route.d.ts",
|
|
112
122
|
"import": "./dist/app/api/stripe/checkout/route.mjs",
|
|
@@ -124,28 +134,23 @@
|
|
|
124
134
|
"!dist/node_modules",
|
|
125
135
|
"!dist/node_modules/**",
|
|
126
136
|
"src",
|
|
127
|
-
"prisma",
|
|
128
|
-
"migrations",
|
|
129
137
|
"package.json",
|
|
130
138
|
"README.md",
|
|
131
139
|
"LICENSE"
|
|
132
140
|
],
|
|
133
141
|
"dependencies": {
|
|
134
142
|
"@clerk/nextjs": "^7.0.5",
|
|
135
|
-
"@prisma/adapter-pg": "^6.19.0",
|
|
136
|
-
"@prisma/client": "^6.19.0",
|
|
137
143
|
"@upstash/redis": "^1.34.0",
|
|
138
144
|
"@upstash/qstash": "^2.7.0",
|
|
139
145
|
"@upstash/lock": "^0.2.1",
|
|
140
146
|
"next": "16.1.6",
|
|
141
|
-
"prisma": "^6.19.0",
|
|
142
147
|
"stripe": "22.0.2",
|
|
143
148
|
"svix": "^1.86.0",
|
|
144
149
|
"tslib": "^2.8.1",
|
|
145
150
|
"zod": "^4.3.6",
|
|
146
|
-
"@windrun-huaiin/
|
|
147
|
-
"@windrun-huaiin/lib": "^
|
|
148
|
-
"@windrun-huaiin/
|
|
151
|
+
"@windrun-huaiin/third-ui": "^29.0.0",
|
|
152
|
+
"@windrun-huaiin/lib": "^29.0.0",
|
|
153
|
+
"@windrun-huaiin/contracts": "^29.0.0"
|
|
149
154
|
},
|
|
150
155
|
"devDependencies": {
|
|
151
156
|
"@rollup/plugin-alias": "^5.1.1",
|
|
@@ -161,7 +166,6 @@
|
|
|
161
166
|
"@clerk/nextjs": "^7.0.5",
|
|
162
167
|
"@prisma/client": "^6.19.0",
|
|
163
168
|
"next": "16.1.6",
|
|
164
|
-
"prisma": "^6.19.0",
|
|
165
169
|
"stripe": "22.0.2",
|
|
166
170
|
"svix": "^1.86.0"
|
|
167
171
|
},
|
|
@@ -169,11 +173,10 @@
|
|
|
169
173
|
"access": "public"
|
|
170
174
|
},
|
|
171
175
|
"scripts": {
|
|
172
|
-
"
|
|
173
|
-
"build": "
|
|
174
|
-
"
|
|
175
|
-
"dev": "pnpm prisma:generate && rollup -c rollup.config.mjs --watch",
|
|
176
|
+
"build": "rm -rf dist && rollup -c rollup.config.mjs",
|
|
177
|
+
"build:prod": "rm -rf dist && rollup -c rollup.config.mjs",
|
|
178
|
+
"dev": "rollup -c rollup.config.mjs --watch",
|
|
176
179
|
"clean": "rm -rf dist",
|
|
177
|
-
"type-check": "
|
|
180
|
+
"type-check": "tsc --noEmit"
|
|
178
181
|
}
|
|
179
182
|
}
|
|
@@ -20,7 +20,7 @@ import {
|
|
|
20
20
|
} from '@core/context/user-context-service';
|
|
21
21
|
import { finalizeUserContext } from '@core/context/user-context-finalizer';
|
|
22
22
|
|
|
23
|
-
import type {
|
|
23
|
+
import type { CoreJsonObject } from '@core/db/prisma-model-type';
|
|
24
24
|
|
|
25
25
|
|
|
26
26
|
// ==================== 类型定义 ====================
|
|
@@ -70,7 +70,7 @@ function createErrorResponse(message: string, status = 400): NextResponse {
|
|
|
70
70
|
return NextResponse.json(errorResponse, { status });
|
|
71
71
|
}
|
|
72
72
|
|
|
73
|
-
type SourceRefData =
|
|
73
|
+
type SourceRefData = CoreJsonObject & {
|
|
74
74
|
capturedAt?: string;
|
|
75
75
|
landingUrl?: string;
|
|
76
76
|
landingPath?: string;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
2
|
+
|
|
3
|
+
// Fix BigInt serialization issue
|
|
4
|
+
(BigInt.prototype as any).toJSON = function () {
|
|
5
|
+
return this.toString();
|
|
6
|
+
};
|
|
7
|
+
|
|
8
|
+
import type { CreditOverviewTranslations } from '@windrun-huaiin/third-ui/main/credit';
|
|
9
|
+
import { NextResponse } from 'next/server';
|
|
10
|
+
import { buildCreditOverviewPayload } from '@core/lib/credit-overview';
|
|
11
|
+
|
|
12
|
+
export type CreditOverviewTranslationsResolver = (
|
|
13
|
+
locale: string,
|
|
14
|
+
) => CreditOverviewTranslations | Promise<CreditOverviewTranslations>;
|
|
15
|
+
|
|
16
|
+
export interface CreateGETOptions {
|
|
17
|
+
defaultLocale?: string;
|
|
18
|
+
localePrefixAsNeeded?: boolean;
|
|
19
|
+
resolveTranslations: CreditOverviewTranslationsResolver;
|
|
20
|
+
pricingPath?: string;
|
|
21
|
+
checkoutApiEndpoint?: string;
|
|
22
|
+
customerPortalApiEndpoint?: string;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export function createGET(options: CreateGETOptions) {
|
|
26
|
+
return async function GET(request: Request) {
|
|
27
|
+
const { searchParams } = new URL(request.url);
|
|
28
|
+
const locale = searchParams.get('locale') || options.defaultLocale || 'en';
|
|
29
|
+
const translations = await options.resolveTranslations(locale);
|
|
30
|
+
|
|
31
|
+
const payload = await buildCreditOverviewPayload({
|
|
32
|
+
locale,
|
|
33
|
+
defaultLocale: options.defaultLocale,
|
|
34
|
+
localePrefixAsNeeded: options.localePrefixAsNeeded,
|
|
35
|
+
translations,
|
|
36
|
+
pricingPath: options.pricingPath,
|
|
37
|
+
checkoutApiEndpoint: options.checkoutApiEndpoint,
|
|
38
|
+
customerPortalApiEndpoint: options.customerPortalApiEndpoint,
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
return NextResponse.json(payload);
|
|
42
|
+
};
|
|
43
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
2
|
+
|
|
3
|
+
// Fix BigInt serialization issue
|
|
4
|
+
(BigInt.prototype as any).toJSON = function () {
|
|
5
|
+
return this.toString();
|
|
6
|
+
};
|
|
7
|
+
|
|
8
|
+
import { getMoneyPriceInitUserContext } from '@core/lib/money-price-helper';
|
|
9
|
+
import { NextResponse } from 'next/server';
|
|
10
|
+
|
|
11
|
+
export async function GET() {
|
|
12
|
+
const initUserContext = await getMoneyPriceInitUserContext();
|
|
13
|
+
return NextResponse.json(initUserContext);
|
|
14
|
+
}
|
package/src/credit/server.ts
CHANGED