@windrun-huaiin/backend-core 30.0.0 → 31.0.1

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.
Files changed (61) hide show
  1. package/README.md +95 -0
  2. package/dist/app/api/user/anonymous/init/fingerprint-only-route.d.ts +8 -0
  3. package/dist/app/api/user/anonymous/init/fingerprint-only-route.d.ts.map +1 -0
  4. package/dist/app/api/user/anonymous/init/fingerprint-only-route.js +20 -0
  5. package/dist/app/api/user/anonymous/init/fingerprint-only-route.mjs +18 -0
  6. package/dist/app/api/user/anonymous/init/route-shared.d.ts +10 -0
  7. package/dist/app/api/user/anonymous/init/route-shared.d.ts.map +1 -0
  8. package/dist/app/api/user/anonymous/init/route-shared.js +557 -0
  9. package/dist/app/api/user/anonymous/init/route-shared.mjs +555 -0
  10. package/dist/app/api/user/anonymous/init/route.d.ts +3 -3
  11. package/dist/app/api/user/anonymous/init/route.d.ts.map +1 -1
  12. package/dist/app/api/user/anonymous/init/route.js +6 -554
  13. package/dist/app/api/user/anonymous/init/route.mjs +7 -555
  14. package/dist/app/api/webhook/clerk/user/route.js +16 -16
  15. package/dist/app/api/webhook/clerk/user/route.mjs +16 -16
  16. package/dist/auth/auth-utils.d.ts +8 -23
  17. package/dist/auth/auth-utils.d.ts.map +1 -1
  18. package/dist/auth/auth-utils.js +8 -20
  19. package/dist/auth/auth-utils.mjs +8 -20
  20. package/dist/lib/money-price-config.d.ts +28 -28
  21. package/dist/lib/money-price-config.js +31 -31
  22. package/dist/lib/money-price-config.mjs +31 -31
  23. package/dist/lib/stripe-config.js +3 -3
  24. package/dist/lib/stripe-config.mjs +3 -3
  25. package/dist/prisma/prisma-transaction-util.js +1 -1
  26. package/dist/prisma/prisma-transaction-util.mjs +1 -1
  27. package/dist/prisma/prisma.d.ts.map +1 -1
  28. package/dist/prisma/prisma.js +18 -19
  29. package/dist/prisma/prisma.mjs +18 -19
  30. package/dist/services/aggregate/billing.aggregate.service.js +6 -6
  31. package/dist/services/aggregate/billing.aggregate.service.mjs +6 -6
  32. package/dist/services/aggregate/user.aggregate.service.d.ts +9 -9
  33. package/dist/services/aggregate/user.aggregate.service.js +16 -16
  34. package/dist/services/aggregate/user.aggregate.service.mjs +16 -16
  35. package/dist/services/database/constants.js +34 -34
  36. package/dist/services/database/constants.mjs +34 -34
  37. package/dist/services/database/credit.service.js +2 -2
  38. package/dist/services/database/credit.service.mjs +2 -2
  39. package/dist/services/database/transaction.service.js +1 -1
  40. package/dist/services/database/transaction.service.mjs +1 -1
  41. package/dist/services/database/user.service.js +2 -2
  42. package/dist/services/database/user.service.mjs +2 -2
  43. package/dist/services/stripe/webhook-handler.js +5 -5
  44. package/dist/services/stripe/webhook-handler.mjs +5 -5
  45. package/package.json +18 -6
  46. package/src/app/api/user/anonymous/init/fingerprint-only-route.ts +14 -0
  47. package/src/app/api/user/anonymous/init/route-shared.ts +710 -0
  48. package/src/app/api/user/anonymous/init/route.ts +7 -712
  49. package/src/app/api/webhook/clerk/user/route.ts +17 -17
  50. package/src/auth/auth-utils.ts +8 -23
  51. package/src/lib/money-price-config.ts +31 -32
  52. package/src/lib/stripe-config.ts +3 -3
  53. package/src/prisma/prisma-transaction-util.ts +1 -1
  54. package/src/prisma/prisma.ts +18 -19
  55. package/src/services/aggregate/billing.aggregate.service.ts +7 -7
  56. package/src/services/aggregate/user.aggregate.service.ts +16 -16
  57. package/src/services/database/constants.ts +34 -34
  58. package/src/services/database/credit.service.ts +2 -2
  59. package/src/services/database/transaction.service.ts +1 -1
  60. package/src/services/database/user.service.ts +2 -2
  61. package/src/services/stripe/webhook-handler.ts +5 -5
@@ -18,10 +18,10 @@ function POST(request) {
18
18
  return __awaiter(this, void 0, void 0, function* () {
19
19
  var _a, _b, _c;
20
20
  try {
21
- // 获取原始请求体
21
+ // Read the raw request body.
22
22
  const rawBody = yield request.text();
23
23
  let event;
24
- // 开发环境跳过签名校验
24
+ // Skip signature verification in development.
25
25
  if (process.env.NODE_ENV === 'development') {
26
26
  console.log('Development mode: skipping webhook signature verification');
27
27
  try {
@@ -33,22 +33,22 @@ function POST(request) {
33
33
  }
34
34
  }
35
35
  else {
36
- // 生产环境进行签名校验
36
+ // Verify the signature in production.
37
37
  const headerPayload = yield headers();
38
38
  const svix_id = headerPayload.get('svix-id');
39
39
  const svix_timestamp = headerPayload.get('svix-timestamp');
40
40
  const svix_signature = headerPayload.get('svix-signature');
41
- // 如果缺少必要的header,返回错误
41
+ // Reject requests missing required headers.
42
42
  if (!svix_id || !svix_timestamp || !svix_signature) {
43
43
  return NextResponse.json({ error: 'Missing webhook headers' }, { status: 400 });
44
44
  }
45
- // 获取webhook signing secret
45
+ // Load the webhook signing secret.
46
46
  const webhookSecret = process.env.CLERK_WEBHOOK_SECRET;
47
47
  if (!webhookSecret) {
48
48
  console.error('CLERK_WEBHOOK_SECRET is not configured');
49
49
  return NextResponse.json({ error: 'Webhook configuration error' }, { status: 500 });
50
50
  }
51
- // 验证webhook签名
51
+ // Verify the webhook signature.
52
52
  try {
53
53
  const wh = new Webhook(webhookSecret);
54
54
  event = wh.verify(rawBody, {
@@ -70,7 +70,7 @@ function POST(request) {
70
70
  }, event);
71
71
  let processingResult = { success: true, message: 'Event processed successfully' };
72
72
  try {
73
- // 处理不同的事件类型
73
+ // Dispatch by event type.
74
74
  const { type } = event;
75
75
  switch (type) {
76
76
  case 'user.created':
@@ -106,7 +106,7 @@ function POST(request) {
106
106
  });
107
107
  }
108
108
  /**
109
- * 处理用户创建事件
109
+ * Handle the user.created event.
110
110
  */
111
111
  function handleUserCreated(event) {
112
112
  return __awaiter(this, void 0, void 0, function* () {
@@ -125,7 +125,7 @@ function handleUserCreated(event) {
125
125
  fingerprintId,
126
126
  userName
127
127
  });
128
- // 检查必要参数
128
+ // Validate required fields.
129
129
  if (!fingerprintId) {
130
130
  console.error('Missing fingerprintId in webhook data, process flow error');
131
131
  return;
@@ -135,16 +135,16 @@ function handleUserCreated(event) {
135
135
  return;
136
136
  }
137
137
  try {
138
- // 按fingerprintId查询该设备的所有未注销过的用户记录,注销过的记录相当于是死数据
138
+ // Find all non-deleted users for this device fingerprint.
139
139
  const existingUsers = yield userService.findListByFingerprintId(fingerprintId);
140
140
  if (!existingUsers || existingUsers.length === 0) {
141
141
  console.error('Invalid fingerprintId in webhook data, process flow error');
142
142
  return;
143
143
  }
144
- // 查找email相同的记录
144
+ // Find an existing user with the same email.
145
145
  const sameEmailUser = existingUsers.find(user => user.email === email);
146
146
  if (sameEmailUser) {
147
- // 同一账号,检查是否需要更新clerkUserId
147
+ // Same account; update clerkUserId if needed.
148
148
  if (sameEmailUser.clerkUserId !== clerkUserId) {
149
149
  yield userService.updateUser(sameEmailUser.userId, { clerkUserId, userName: userName, status: UserStatus.REGISTERED });
150
150
  console.log(`Updated clerkUserId for user ${sameEmailUser.userId}`);
@@ -154,15 +154,15 @@ function handleUserCreated(event) {
154
154
  }
155
155
  return;
156
156
  }
157
- // 查找匿名用户(email为空且clerkUserId为空)
157
+ // Find an anonymous user with no email or clerkUserId.
158
158
  const anonymousUser = existingUsers.find(user => !user.email && !user.clerkUserId && user.status === UserStatus.ANONYMOUS);
159
159
  if (anonymousUser) {
160
- // 匿名用户升级
160
+ // Upgrade the anonymous user.
161
161
  yield userAggregateService.upgradeToRegistered(anonymousUser.userId, email, clerkUserId, userName);
162
162
  console.log(`Successfully upgraded anonymous user ${anonymousUser.userId} to registered user`);
163
163
  return;
164
164
  }
165
- // 同设备新账号,创建新用户
165
+ // New account on the same device; create a new user.
166
166
  yield userAggregateService.createNewRegisteredUser(clerkUserId, email, fingerprintId, userName);
167
167
  console.log(`Created new user for device ${fingerprintId} with email ${email}`);
168
168
  }
@@ -173,7 +173,7 @@ function handleUserCreated(event) {
173
173
  });
174
174
  }
175
175
  /**
176
- * 处理用户删除事件
176
+ * Handle the user.deleted event.
177
177
  */
178
178
  function handleUserDeleted(event) {
179
179
  return __awaiter(this, void 0, void 0, function* () {
@@ -1,9 +1,6 @@
1
1
  import { NextRequest } from 'next/server';
2
2
  import { User } from '../services/database/prisma-model-type';
3
3
  import { type AuthProvider, type ProviderIdentity } from './auth-shared';
4
- /**
5
- * 认证结果类型
6
- */
7
4
  export interface AuthResult {
8
5
  userId: string;
9
6
  user: User;
@@ -11,48 +8,36 @@ export interface AuthResult {
11
8
  providerUserId: string;
12
9
  }
13
10
  /**
14
- * 从中间件设置的 Clerk ID 获取完整用户信息
11
+ * Fetch User's info from header field by Middleware
15
12
  */
16
13
  export declare function getAuthenticatedUser(req: NextRequest): Promise<AuthResult>;
17
14
  /**
18
- * 要求用户必须已认证,返回用户ID
15
+ * Require Auth, success back user's id
19
16
  */
20
17
  export declare function requireAuth(req: NextRequest): Promise<string>;
21
18
  /**
22
- * 要求用户必须已认证,返回完整用户信息
19
+ * Require Auth, success back user's info
23
20
  */
24
21
  export declare function requireAuthWithUser(req: NextRequest): Promise<AuthResult>;
25
22
  /**
26
- * 服务端场景下获取当前已认证身份(如果存在)
27
- * 适用于只依赖登录态、不需要查询业务用户的逻辑
23
+ * Only use in server side
24
+ * Server Component / Server Action, just need user's login status
28
25
  */
29
26
  export declare function getOptionalServerAuthIdentity(): Promise<ProviderIdentity | null>;
30
27
  /**
31
- * 服务端场景下获取当前已认证用户(如果存在)
32
- * 适用于 Server Component / Server Action 中基于登录态控制展示的逻辑
28
+ * Only use in server side
29
+ * Server Component / Server Action, need user's login status and user's data, will check db
33
30
  */
34
31
  export declare function getOptionalServerAuthUser(): Promise<AuthResult | null>;
35
32
  /**
36
- * API Route版本的认证工具函数
33
+ * API Route Auth Util
37
34
  */
38
35
  export declare class ApiAuthUtils {
39
36
  private req;
40
37
  constructor(req: NextRequest);
41
- /**
42
- * 要求用户必须已认证,返回用户ID
43
- */
44
38
  requireAuth(): Promise<string>;
45
- /**
46
- * 要求用户必须已认证,返回完整用户信息
47
- */
48
39
  requireAuthWithUser(): Promise<AuthResult>;
49
- /**
50
- * 获取用户ID(如果已认证)
51
- */
52
40
  getUserId(): Promise<string | null>;
53
- /**
54
- * 获取完整用户信息(如果已认证)
55
- */
56
41
  getUser(): Promise<AuthResult | null>;
57
42
  }
58
43
  //# sourceMappingURL=auth-utils.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"auth-utils.d.ts","sourceRoot":"","sources":["../../src/auth/auth-utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAG1C,OAAO,EAAE,IAAI,EAAE,MAAM,wCAAwC,CAAC;AAC9D,OAAO,EAA6B,KAAK,YAAY,EAAE,KAAK,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAEpG;;GAEG;AACH,MAAM,WAAW,UAAU;IACzB,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,IAAI,CAAC;IACX,QAAQ,EAAE,YAAY,CAAC;IACvB,cAAc,EAAE,MAAM,CAAC;CACxB;AAED;;GAEG;AACH,wBAAsB,oBAAoB,CAAC,GAAG,EAAE,WAAW,GAAG,OAAO,CAAC,UAAU,CAAC,CAuBhF;AAED;;GAEG;AACH,wBAAsB,WAAW,CAAC,GAAG,EAAE,WAAW,GAAG,OAAO,CAAC,MAAM,CAAC,CAGnE;AAED;;GAEG;AACH,wBAAsB,mBAAmB,CAAC,GAAG,EAAE,WAAW,GAAG,OAAO,CAAC,UAAU,CAAC,CAE/E;AAED;;;GAGG;AACH,wBAAsB,6BAA6B,IAAI,OAAO,CAAC,gBAAgB,GAAG,IAAI,CAAC,CAetF;AAED;;;GAGG;AACH,wBAAsB,yBAAyB,IAAI,OAAO,CAAC,UAAU,GAAG,IAAI,CAAC,CAsB5E;AAED;;GAEG;AACH,qBAAa,YAAY;IACvB,OAAO,CAAC,GAAG,CAAc;gBAEb,GAAG,EAAE,WAAW;IAI5B;;OAEG;IACG,WAAW,IAAI,OAAO,CAAC,MAAM,CAAC;IAIpC;;OAEG;IACG,mBAAmB,IAAI,OAAO,CAAC,UAAU,CAAC;IAIhD;;OAEG;IACG,SAAS,IAAI,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC;IASzC;;OAEG;IACG,OAAO,IAAI,OAAO,CAAC,UAAU,GAAG,IAAI,CAAC;CAO5C"}
1
+ {"version":3,"file":"auth-utils.d.ts","sourceRoot":"","sources":["../../src/auth/auth-utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAG1C,OAAO,EAAE,IAAI,EAAE,MAAM,wCAAwC,CAAC;AAC9D,OAAO,EAA6B,KAAK,YAAY,EAAE,KAAK,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAEpG,MAAM,WAAW,UAAU;IACzB,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,IAAI,CAAC;IACX,QAAQ,EAAE,YAAY,CAAC;IACvB,cAAc,EAAE,MAAM,CAAC;CACxB;AAED;;GAEG;AACH,wBAAsB,oBAAoB,CAAC,GAAG,EAAE,WAAW,GAAG,OAAO,CAAC,UAAU,CAAC,CAuBhF;AAED;;GAEG;AACH,wBAAsB,WAAW,CAAC,GAAG,EAAE,WAAW,GAAG,OAAO,CAAC,MAAM,CAAC,CAGnE;AAED;;GAEG;AACH,wBAAsB,mBAAmB,CAAC,GAAG,EAAE,WAAW,GAAG,OAAO,CAAC,UAAU,CAAC,CAE/E;AAED;;;GAGG;AACH,wBAAsB,6BAA6B,IAAI,OAAO,CAAC,gBAAgB,GAAG,IAAI,CAAC,CAetF;AAED;;;GAGG;AACH,wBAAsB,yBAAyB,IAAI,OAAO,CAAC,UAAU,GAAG,IAAI,CAAC,CAsB5E;AAED;;GAEG;AACH,qBAAa,YAAY;IACvB,OAAO,CAAC,GAAG,CAAc;gBAEb,GAAG,EAAE,WAAW;IAItB,WAAW,IAAI,OAAO,CAAC,MAAM,CAAC;IAI9B,mBAAmB,IAAI,OAAO,CAAC,UAAU,CAAC;IAI1C,SAAS,IAAI,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC;IASnC,OAAO,IAAI,OAAO,CAAC,UAAU,GAAG,IAAI,CAAC;CAO5C"}
@@ -8,7 +8,7 @@ require('../services/database/credit.service.js');
8
8
  var authShared = require('./auth-shared.js');
9
9
 
10
10
  /**
11
- * 从中间件设置的 Clerk ID 获取完整用户信息
11
+ * Fetch User's info from header field by Middleware
12
12
  */
13
13
  function getAuthenticatedUser(req) {
14
14
  return tslib.__awaiter(this, void 0, void 0, function* () {
@@ -36,7 +36,7 @@ function getAuthenticatedUser(req) {
36
36
  });
37
37
  }
38
38
  /**
39
- * 要求用户必须已认证,返回用户ID
39
+ * Require Auth, success back user's id
40
40
  */
41
41
  function requireAuth(req) {
42
42
  return tslib.__awaiter(this, void 0, void 0, function* () {
@@ -45,7 +45,7 @@ function requireAuth(req) {
45
45
  });
46
46
  }
47
47
  /**
48
- * 要求用户必须已认证,返回完整用户信息
48
+ * Require Auth, success back user's info
49
49
  */
50
50
  function requireAuthWithUser(req) {
51
51
  return tslib.__awaiter(this, void 0, void 0, function* () {
@@ -53,8 +53,8 @@ function requireAuthWithUser(req) {
53
53
  });
54
54
  }
55
55
  /**
56
- * 服务端场景下获取当前已认证身份(如果存在)
57
- * 适用于只依赖登录态、不需要查询业务用户的逻辑
56
+ * Only use in server side
57
+ * Server Component / Server Action, just need user's login status
58
58
  */
59
59
  function getOptionalServerAuthIdentity() {
60
60
  return tslib.__awaiter(this, void 0, void 0, function* () {
@@ -75,8 +75,8 @@ function getOptionalServerAuthIdentity() {
75
75
  });
76
76
  }
77
77
  /**
78
- * 服务端场景下获取当前已认证用户(如果存在)
79
- * 适用于 Server Component / Server Action 中基于登录态控制展示的逻辑
78
+ * Only use in server side
79
+ * Server Component / Server Action, need user's login status and user's data, will check db
80
80
  */
81
81
  function getOptionalServerAuthUser() {
82
82
  return tslib.__awaiter(this, void 0, void 0, function* () {
@@ -103,31 +103,22 @@ function getOptionalServerAuthUser() {
103
103
  });
104
104
  }
105
105
  /**
106
- * API Route版本的认证工具函数
106
+ * API Route Auth Util
107
107
  */
108
108
  class ApiAuthUtils {
109
109
  constructor(req) {
110
110
  this.req = req;
111
111
  }
112
- /**
113
- * 要求用户必须已认证,返回用户ID
114
- */
115
112
  requireAuth() {
116
113
  return tslib.__awaiter(this, void 0, void 0, function* () {
117
114
  return yield requireAuth(this.req);
118
115
  });
119
116
  }
120
- /**
121
- * 要求用户必须已认证,返回完整用户信息
122
- */
123
117
  requireAuthWithUser() {
124
118
  return tslib.__awaiter(this, void 0, void 0, function* () {
125
119
  return yield requireAuthWithUser(this.req);
126
120
  });
127
121
  }
128
- /**
129
- * 获取用户ID(如果已认证)
130
- */
131
122
  getUserId() {
132
123
  return tslib.__awaiter(this, void 0, void 0, function* () {
133
124
  try {
@@ -139,9 +130,6 @@ class ApiAuthUtils {
139
130
  }
140
131
  });
141
132
  }
142
- /**
143
- * 获取完整用户信息(如果已认证)
144
- */
145
133
  getUser() {
146
134
  return tslib.__awaiter(this, void 0, void 0, function* () {
147
135
  try {
@@ -6,7 +6,7 @@ import '../services/database/credit.service.mjs';
6
6
  import { AUTH_HEADERS, AUTH_ERRORS } from './auth-shared.mjs';
7
7
 
8
8
  /**
9
- * 从中间件设置的 Clerk ID 获取完整用户信息
9
+ * Fetch User's info from header field by Middleware
10
10
  */
11
11
  function getAuthenticatedUser(req) {
12
12
  return __awaiter(this, void 0, void 0, function* () {
@@ -34,7 +34,7 @@ function getAuthenticatedUser(req) {
34
34
  });
35
35
  }
36
36
  /**
37
- * 要求用户必须已认证,返回用户ID
37
+ * Require Auth, success back user's id
38
38
  */
39
39
  function requireAuth(req) {
40
40
  return __awaiter(this, void 0, void 0, function* () {
@@ -43,7 +43,7 @@ function requireAuth(req) {
43
43
  });
44
44
  }
45
45
  /**
46
- * 要求用户必须已认证,返回完整用户信息
46
+ * Require Auth, success back user's info
47
47
  */
48
48
  function requireAuthWithUser(req) {
49
49
  return __awaiter(this, void 0, void 0, function* () {
@@ -51,8 +51,8 @@ function requireAuthWithUser(req) {
51
51
  });
52
52
  }
53
53
  /**
54
- * 服务端场景下获取当前已认证身份(如果存在)
55
- * 适用于只依赖登录态、不需要查询业务用户的逻辑
54
+ * Only use in server side
55
+ * Server Component / Server Action, just need user's login status
56
56
  */
57
57
  function getOptionalServerAuthIdentity() {
58
58
  return __awaiter(this, void 0, void 0, function* () {
@@ -73,8 +73,8 @@ function getOptionalServerAuthIdentity() {
73
73
  });
74
74
  }
75
75
  /**
76
- * 服务端场景下获取当前已认证用户(如果存在)
77
- * 适用于 Server Component / Server Action 中基于登录态控制展示的逻辑
76
+ * Only use in server side
77
+ * Server Component / Server Action, need user's login status and user's data, will check db
78
78
  */
79
79
  function getOptionalServerAuthUser() {
80
80
  return __awaiter(this, void 0, void 0, function* () {
@@ -101,31 +101,22 @@ function getOptionalServerAuthUser() {
101
101
  });
102
102
  }
103
103
  /**
104
- * API Route版本的认证工具函数
104
+ * API Route Auth Util
105
105
  */
106
106
  class ApiAuthUtils {
107
107
  constructor(req) {
108
108
  this.req = req;
109
109
  }
110
- /**
111
- * 要求用户必须已认证,返回用户ID
112
- */
113
110
  requireAuth() {
114
111
  return __awaiter(this, void 0, void 0, function* () {
115
112
  return yield requireAuth(this.req);
116
113
  });
117
114
  }
118
- /**
119
- * 要求用户必须已认证,返回完整用户信息
120
- */
121
115
  requireAuthWithUser() {
122
116
  return __awaiter(this, void 0, void 0, function* () {
123
117
  return yield requireAuthWithUser(this.req);
124
118
  });
125
119
  }
126
- /**
127
- * 获取用户ID(如果已认证)
128
- */
129
120
  getUserId() {
130
121
  return __awaiter(this, void 0, void 0, function* () {
131
122
  try {
@@ -137,9 +128,6 @@ class ApiAuthUtils {
137
128
  }
138
129
  });
139
130
  }
140
- /**
141
- * 获取完整用户信息(如果已认证)
142
- */
143
131
  getUser() {
144
132
  return __awaiter(this, void 0, void 0, function* () {
145
133
  try {
@@ -1,47 +1,47 @@
1
1
  import { MoneyPriceConfig, PaymentProviderConfig, EnhancePricePlan } from '@windrun-huaiin/third-ui/main/server';
2
2
  export declare const moneyPriceConfig: MoneyPriceConfig;
3
3
  /**
4
- * 获取当前激活的支付供应商配置
4
+ * Get the currently active payment provider configuration.
5
5
  *
6
- * 🔒 安全设计:
7
- * - wrapper函数隐藏moneyPriceConfig
8
- * - util层负责从config中提取激活的provider配置
9
- * - 外部只能通过这个wrapper访问,看不到config对象
6
+ * Security design:
7
+ * - Wrapper functions keep moneyPriceConfig private.
8
+ * - Utility functions extract the active provider configuration from the config.
9
+ * - External callers can access only this wrapper, not the full config object.
10
10
  *
11
- * @returns 当前激活的支付供应商配置
11
+ * @returns The currently active payment provider configuration.
12
12
  */
13
13
  export declare function getActiveProviderConfig(): PaymentProviderConfig;
14
14
  /**
15
- * 根据 priceId 获取对应的积分数量
15
+ * Get the credit amount for a price ID.
16
16
  *
17
- * 🔒 安全设计:
18
- * - wrapper函数隐藏moneyPriceConfig
19
- * - util层负责解析config并提取结果
20
- * - 外部只能通过这个wrapper访问,看不到config对象
17
+ * Security design:
18
+ * - Wrapper functions keep moneyPriceConfig private.
19
+ * - Utility functions parse the config and extract the result.
20
+ * - External callers can access only this wrapper, not the full config object.
21
21
  *
22
- * @param priceId - 查询的价格ID
23
- * @param _provider - 保留参数(向后兼容),暂未使用
24
- * @returns 对应的积分数量,或null
22
+ * @param priceId - Price ID to query.
23
+ * @param _provider - Reserved for backward compatibility; currently unused.
24
+ * @returns The matching credit amount, or null.
25
25
  */
26
26
  export declare function getCreditsFromPriceId(priceId?: string, _provider?: string): number | null;
27
27
  /**
28
- * 根据查询参数获取价格配置
28
+ * Get price configuration by query parameters.
29
29
  *
30
- * 支持三种查询方式:
31
- * 1. priceId 查询:getPriceConfig(priceId='price_xxx')
32
- * 2. plan billingType 查询:getPriceConfig(undefined, 'P2', 'monthly')
33
- * 3. plan 查询:getPriceConfig(undefined, 'P2')
30
+ * Supported query modes:
31
+ * 1. By priceId: getPriceConfig(priceId='price_xxx')
32
+ * 2. By plan and billingType: getPriceConfig(undefined, 'P2', 'monthly')
33
+ * 3. By plan: getPriceConfig(undefined, 'P2')
34
34
  *
35
- * 🔒 安全设计:
36
- * - wrapper函数隐藏moneyPriceConfig
37
- * - util层负责解析config并提取匹配的结果
38
- * - 外部只能通过这个wrapper访问,看不到config对象
35
+ * Security design:
36
+ * - Wrapper functions keep moneyPriceConfig private.
37
+ * - Utility functions parse the config and extract the matching result.
38
+ * - External callers can access only this wrapper, not the full config object.
39
39
  *
40
- * @param priceId - 查询的价格ID(可选)
41
- * @param plan - 查询的套餐名称如'P2''U3'(可选)
42
- * @param billingType - 查询的计费类型如'monthly''yearly'(可选)
43
- * @param _provider - 保留参数(向后兼容),暂未使用
44
- * @returns 匹配的价格配置,包含计算好的元数据(priceNamedescriptioninterval
40
+ * @param priceId - Optional price ID to query.
41
+ * @param plan - Optional plan name, such as 'P2' or 'U3'.
42
+ * @param billingType - Optional billing type, such as 'monthly' or 'yearly'.
43
+ * @param _provider - Reserved for backward compatibility; currently unused.
44
+ * @returns The matching price config with derived metadata: priceName, description, and interval.
45
45
  */
46
46
  export declare function getPriceConfig(priceId?: string, plan?: string, billingType?: string, _provider?: string): (EnhancePricePlan & {
47
47
  priceName: string;
@@ -7,7 +7,7 @@ const moneyPriceConfig = {
7
7
  stripe: {
8
8
  provider: 'stripe',
9
9
  enabled: true,
10
- // 订阅模式产品
10
+ // Subscription products
11
11
  subscriptionProducts: {
12
12
  F1: {
13
13
  key: 'F1',
@@ -65,7 +65,7 @@ const moneyPriceConfig = {
65
65
  }
66
66
  }
67
67
  },
68
- // 积分包产品
68
+ // Credit pack products
69
69
  creditPackProducts: {
70
70
  F1: {
71
71
  key: 'F1',
@@ -98,53 +98,53 @@ const moneyPriceConfig = {
98
98
  minFeaturesCount: 4
99
99
  }
100
100
  };
101
- // ============ 应用层wrapper - 隐藏moneyPriceConfig细节 ============
101
+ // ============ Application-level wrappers that hide moneyPriceConfig details ============
102
102
  /**
103
- * 获取当前激活的支付供应商配置
103
+ * Get the currently active payment provider configuration.
104
104
  *
105
- * 🔒 安全设计:
106
- * - wrapper函数隐藏moneyPriceConfig
107
- * - util层负责从config中提取激活的provider配置
108
- * - 外部只能通过这个wrapper访问,看不到config对象
105
+ * Security design:
106
+ * - Wrapper functions keep moneyPriceConfig private.
107
+ * - Utility functions extract the active provider configuration from the config.
108
+ * - External callers can access only this wrapper, not the full config object.
109
109
  *
110
- * @returns 当前激活的支付供应商配置
110
+ * @returns The currently active payment provider configuration.
111
111
  */
112
112
  function getActiveProviderConfig() {
113
113
  return server.getActiveProviderConfigUtil(moneyPriceConfig);
114
114
  }
115
115
  /**
116
- * 根据 priceId 获取对应的积分数量
116
+ * Get the credit amount for a price ID.
117
117
  *
118
- * 🔒 安全设计:
119
- * - wrapper函数隐藏moneyPriceConfig
120
- * - util层负责解析config并提取结果
121
- * - 外部只能通过这个wrapper访问,看不到config对象
118
+ * Security design:
119
+ * - Wrapper functions keep moneyPriceConfig private.
120
+ * - Utility functions parse the config and extract the result.
121
+ * - External callers can access only this wrapper, not the full config object.
122
122
  *
123
- * @param priceId - 查询的价格ID
124
- * @param _provider - 保留参数(向后兼容),暂未使用
125
- * @returns 对应的积分数量,或null
123
+ * @param priceId - Price ID to query.
124
+ * @param _provider - Reserved for backward compatibility; currently unused.
125
+ * @returns The matching credit amount, or null.
126
126
  */
127
127
  function getCreditsFromPriceId(priceId, _provider) {
128
128
  return server.getCreditsFromPriceIdUtil(priceId, moneyPriceConfig);
129
129
  }
130
130
  /**
131
- * 根据查询参数获取价格配置
131
+ * Get price configuration by query parameters.
132
132
  *
133
- * 支持三种查询方式:
134
- * 1. priceId 查询:getPriceConfig(priceId='price_xxx')
135
- * 2. plan billingType 查询:getPriceConfig(undefined, 'P2', 'monthly')
136
- * 3. plan 查询:getPriceConfig(undefined, 'P2')
133
+ * Supported query modes:
134
+ * 1. By priceId: getPriceConfig(priceId='price_xxx')
135
+ * 2. By plan and billingType: getPriceConfig(undefined, 'P2', 'monthly')
136
+ * 3. By plan: getPriceConfig(undefined, 'P2')
137
137
  *
138
- * 🔒 安全设计:
139
- * - wrapper函数隐藏moneyPriceConfig
140
- * - util层负责解析config并提取匹配的结果
141
- * - 外部只能通过这个wrapper访问,看不到config对象
138
+ * Security design:
139
+ * - Wrapper functions keep moneyPriceConfig private.
140
+ * - Utility functions parse the config and extract the matching result.
141
+ * - External callers can access only this wrapper, not the full config object.
142
142
  *
143
- * @param priceId - 查询的价格ID(可选)
144
- * @param plan - 查询的套餐名称如'P2''U3'(可选)
145
- * @param billingType - 查询的计费类型如'monthly''yearly'(可选)
146
- * @param _provider - 保留参数(向后兼容),暂未使用
147
- * @returns 匹配的价格配置,包含计算好的元数据(priceNamedescriptioninterval
143
+ * @param priceId - Optional price ID to query.
144
+ * @param plan - Optional plan name, such as 'P2' or 'U3'.
145
+ * @param billingType - Optional billing type, such as 'monthly' or 'yearly'.
146
+ * @param _provider - Reserved for backward compatibility; currently unused.
147
+ * @returns The matching price config with derived metadata: priceName, description, and interval.
148
148
  */
149
149
  function getPriceConfig(priceId, plan, billingType, _provider) {
150
150
  return server.getPriceConfigUtil(priceId, plan, billingType, moneyPriceConfig);
@@ -5,7 +5,7 @@ const moneyPriceConfig = {
5
5
  stripe: {
6
6
  provider: 'stripe',
7
7
  enabled: true,
8
- // 订阅模式产品
8
+ // Subscription products
9
9
  subscriptionProducts: {
10
10
  F1: {
11
11
  key: 'F1',
@@ -63,7 +63,7 @@ const moneyPriceConfig = {
63
63
  }
64
64
  }
65
65
  },
66
- // 积分包产品
66
+ // Credit pack products
67
67
  creditPackProducts: {
68
68
  F1: {
69
69
  key: 'F1',
@@ -96,53 +96,53 @@ const moneyPriceConfig = {
96
96
  minFeaturesCount: 4
97
97
  }
98
98
  };
99
- // ============ 应用层wrapper - 隐藏moneyPriceConfig细节 ============
99
+ // ============ Application-level wrappers that hide moneyPriceConfig details ============
100
100
  /**
101
- * 获取当前激活的支付供应商配置
101
+ * Get the currently active payment provider configuration.
102
102
  *
103
- * 🔒 安全设计:
104
- * - wrapper函数隐藏moneyPriceConfig
105
- * - util层负责从config中提取激活的provider配置
106
- * - 外部只能通过这个wrapper访问,看不到config对象
103
+ * Security design:
104
+ * - Wrapper functions keep moneyPriceConfig private.
105
+ * - Utility functions extract the active provider configuration from the config.
106
+ * - External callers can access only this wrapper, not the full config object.
107
107
  *
108
- * @returns 当前激活的支付供应商配置
108
+ * @returns The currently active payment provider configuration.
109
109
  */
110
110
  function getActiveProviderConfig() {
111
111
  return getActiveProviderConfigUtil(moneyPriceConfig);
112
112
  }
113
113
  /**
114
- * 根据 priceId 获取对应的积分数量
114
+ * Get the credit amount for a price ID.
115
115
  *
116
- * 🔒 安全设计:
117
- * - wrapper函数隐藏moneyPriceConfig
118
- * - util层负责解析config并提取结果
119
- * - 外部只能通过这个wrapper访问,看不到config对象
116
+ * Security design:
117
+ * - Wrapper functions keep moneyPriceConfig private.
118
+ * - Utility functions parse the config and extract the result.
119
+ * - External callers can access only this wrapper, not the full config object.
120
120
  *
121
- * @param priceId - 查询的价格ID
122
- * @param _provider - 保留参数(向后兼容),暂未使用
123
- * @returns 对应的积分数量,或null
121
+ * @param priceId - Price ID to query.
122
+ * @param _provider - Reserved for backward compatibility; currently unused.
123
+ * @returns The matching credit amount, or null.
124
124
  */
125
125
  function getCreditsFromPriceId(priceId, _provider) {
126
126
  return getCreditsFromPriceIdUtil(priceId, moneyPriceConfig);
127
127
  }
128
128
  /**
129
- * 根据查询参数获取价格配置
129
+ * Get price configuration by query parameters.
130
130
  *
131
- * 支持三种查询方式:
132
- * 1. priceId 查询:getPriceConfig(priceId='price_xxx')
133
- * 2. plan billingType 查询:getPriceConfig(undefined, 'P2', 'monthly')
134
- * 3. plan 查询:getPriceConfig(undefined, 'P2')
131
+ * Supported query modes:
132
+ * 1. By priceId: getPriceConfig(priceId='price_xxx')
133
+ * 2. By plan and billingType: getPriceConfig(undefined, 'P2', 'monthly')
134
+ * 3. By plan: getPriceConfig(undefined, 'P2')
135
135
  *
136
- * 🔒 安全设计:
137
- * - wrapper函数隐藏moneyPriceConfig
138
- * - util层负责解析config并提取匹配的结果
139
- * - 外部只能通过这个wrapper访问,看不到config对象
136
+ * Security design:
137
+ * - Wrapper functions keep moneyPriceConfig private.
138
+ * - Utility functions parse the config and extract the matching result.
139
+ * - External callers can access only this wrapper, not the full config object.
140
140
  *
141
- * @param priceId - 查询的价格ID(可选)
142
- * @param plan - 查询的套餐名称如'P2''U3'(可选)
143
- * @param billingType - 查询的计费类型如'monthly''yearly'(可选)
144
- * @param _provider - 保留参数(向后兼容),暂未使用
145
- * @returns 匹配的价格配置,包含计算好的元数据(priceNamedescriptioninterval
141
+ * @param priceId - Optional price ID to query.
142
+ * @param plan - Optional plan name, such as 'P2' or 'U3'.
143
+ * @param billingType - Optional billing type, such as 'monthly' or 'yearly'.
144
+ * @param _provider - Reserved for backward compatibility; currently unused.
145
+ * @returns The matching price config with derived metadata: priceName, description, and interval.
146
146
  */
147
147
  function getPriceConfig(priceId, plan, billingType, _provider) {
148
148
  return getPriceConfigUtil(priceId, plan, billingType, moneyPriceConfig);