@r2wa-org/eden 0.0.102 → 0.0.104

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.
@@ -0,0 +1,477 @@
1
+ import type { TeamMilestoneRewardPlanCreateInputType, TeamMilestoneRewardPlanUpdateInputType, TeamMilestoneRewardRuleCreateInputType, TeamMilestoneRewardRuleUpdateInputType } from './reward.dto.schemas';
2
+ export declare abstract class AdminTeamMilestoneRewardConfigService {
3
+ private static formatPlanRow;
4
+ private static sortRules;
5
+ private static loadPlanDetail;
6
+ private static touchPlanUpdatedBy;
7
+ private static validatePlanAssetsAndAccounts;
8
+ private static createRuleInTx;
9
+ private static isRuleUpdateItem;
10
+ private static updateRuleInTx;
11
+ private static syncRulesInTx;
12
+ static getDefaultPlan(): Promise<{
13
+ rules: {
14
+ createdAt: Date;
15
+ createdBy: string;
16
+ creator: {
17
+ email: string;
18
+ id: string;
19
+ name: string;
20
+ };
21
+ id: string;
22
+ isEnabled: boolean;
23
+ planId: string;
24
+ platformRewardAmount: string;
25
+ rewardDescription: string | null;
26
+ sortOrder: number;
27
+ thresholdMemberCount: number;
28
+ updatedAt: Date;
29
+ updatedBy: string | null;
30
+ updater: {
31
+ email: string;
32
+ id: string;
33
+ name: string;
34
+ } | null;
35
+ valueAddedRewardAmount: string;
36
+ }[];
37
+ createdAt: Date;
38
+ createdBy: string;
39
+ creator: {
40
+ email: string;
41
+ id: string;
42
+ name: string;
43
+ };
44
+ id: string;
45
+ isEnabled: boolean;
46
+ maxDepth: number;
47
+ name: string;
48
+ platformAsset: {
49
+ code: string;
50
+ id: string;
51
+ isActive: boolean;
52
+ name: string;
53
+ precision: number;
54
+ symbol: string | null;
55
+ };
56
+ platformAssetId: string;
57
+ platformPayoutAccountType: {
58
+ id: string;
59
+ isActive: boolean;
60
+ key: string;
61
+ name: string;
62
+ };
63
+ platformPayoutAccountTypeId: string;
64
+ sortOrder: number;
65
+ updatedAt: Date;
66
+ updatedBy: string | null;
67
+ updater: {
68
+ email: string;
69
+ id: string;
70
+ name: string;
71
+ } | null;
72
+ valueAddedAsset: {
73
+ code: string;
74
+ id: string;
75
+ isActive: boolean;
76
+ name: string;
77
+ precision: number;
78
+ symbol: string | null;
79
+ };
80
+ valueAddedAssetId: string;
81
+ valueAddedPayoutAccountType: {
82
+ id: string;
83
+ isActive: boolean;
84
+ key: string;
85
+ name: string;
86
+ };
87
+ valueAddedPayoutAccountTypeId: string;
88
+ } | null>;
89
+ static createPlan(operatorId: string, input: TeamMilestoneRewardPlanCreateInputType): Promise<{
90
+ rules: {
91
+ createdAt: Date;
92
+ createdBy: string;
93
+ creator: {
94
+ email: string;
95
+ id: string;
96
+ name: string;
97
+ };
98
+ id: string;
99
+ isEnabled: boolean;
100
+ planId: string;
101
+ platformRewardAmount: string;
102
+ rewardDescription: string | null;
103
+ sortOrder: number;
104
+ thresholdMemberCount: number;
105
+ updatedAt: Date;
106
+ updatedBy: string | null;
107
+ updater: {
108
+ email: string;
109
+ id: string;
110
+ name: string;
111
+ } | null;
112
+ valueAddedRewardAmount: string;
113
+ }[];
114
+ createdAt: Date;
115
+ createdBy: string;
116
+ creator: {
117
+ email: string;
118
+ id: string;
119
+ name: string;
120
+ };
121
+ id: string;
122
+ isEnabled: boolean;
123
+ maxDepth: number;
124
+ name: string;
125
+ platformAsset: {
126
+ code: string;
127
+ id: string;
128
+ isActive: boolean;
129
+ name: string;
130
+ precision: number;
131
+ symbol: string | null;
132
+ };
133
+ platformAssetId: string;
134
+ platformPayoutAccountType: {
135
+ id: string;
136
+ isActive: boolean;
137
+ key: string;
138
+ name: string;
139
+ };
140
+ platformPayoutAccountTypeId: string;
141
+ sortOrder: number;
142
+ updatedAt: Date;
143
+ updatedBy: string | null;
144
+ updater: {
145
+ email: string;
146
+ id: string;
147
+ name: string;
148
+ } | null;
149
+ valueAddedAsset: {
150
+ code: string;
151
+ id: string;
152
+ isActive: boolean;
153
+ name: string;
154
+ precision: number;
155
+ symbol: string | null;
156
+ };
157
+ valueAddedAssetId: string;
158
+ valueAddedPayoutAccountType: {
159
+ id: string;
160
+ isActive: boolean;
161
+ key: string;
162
+ name: string;
163
+ };
164
+ valueAddedPayoutAccountTypeId: string;
165
+ }>;
166
+ static updateDefaultPlan(operatorId: string, input: TeamMilestoneRewardPlanUpdateInputType): Promise<{
167
+ rules: {
168
+ createdAt: Date;
169
+ createdBy: string;
170
+ creator: {
171
+ email: string;
172
+ id: string;
173
+ name: string;
174
+ };
175
+ id: string;
176
+ isEnabled: boolean;
177
+ planId: string;
178
+ platformRewardAmount: string;
179
+ rewardDescription: string | null;
180
+ sortOrder: number;
181
+ thresholdMemberCount: number;
182
+ updatedAt: Date;
183
+ updatedBy: string | null;
184
+ updater: {
185
+ email: string;
186
+ id: string;
187
+ name: string;
188
+ } | null;
189
+ valueAddedRewardAmount: string;
190
+ }[];
191
+ createdAt: Date;
192
+ createdBy: string;
193
+ creator: {
194
+ email: string;
195
+ id: string;
196
+ name: string;
197
+ };
198
+ id: string;
199
+ isEnabled: boolean;
200
+ maxDepth: number;
201
+ name: string;
202
+ platformAsset: {
203
+ code: string;
204
+ id: string;
205
+ isActive: boolean;
206
+ name: string;
207
+ precision: number;
208
+ symbol: string | null;
209
+ };
210
+ platformAssetId: string;
211
+ platformPayoutAccountType: {
212
+ id: string;
213
+ isActive: boolean;
214
+ key: string;
215
+ name: string;
216
+ };
217
+ platformPayoutAccountTypeId: string;
218
+ sortOrder: number;
219
+ updatedAt: Date;
220
+ updatedBy: string | null;
221
+ updater: {
222
+ email: string;
223
+ id: string;
224
+ name: string;
225
+ } | null;
226
+ valueAddedAsset: {
227
+ code: string;
228
+ id: string;
229
+ isActive: boolean;
230
+ name: string;
231
+ precision: number;
232
+ symbol: string | null;
233
+ };
234
+ valueAddedAssetId: string;
235
+ valueAddedPayoutAccountType: {
236
+ id: string;
237
+ isActive: boolean;
238
+ key: string;
239
+ name: string;
240
+ };
241
+ valueAddedPayoutAccountTypeId: string;
242
+ }>;
243
+ static deleteDefaultPlan(_operatorId: string): Promise<{
244
+ success: true;
245
+ }>;
246
+ static createRule(operatorId: string, input: TeamMilestoneRewardRuleCreateInputType): Promise<{
247
+ rules: {
248
+ createdAt: Date;
249
+ createdBy: string;
250
+ creator: {
251
+ email: string;
252
+ id: string;
253
+ name: string;
254
+ };
255
+ id: string;
256
+ isEnabled: boolean;
257
+ planId: string;
258
+ platformRewardAmount: string;
259
+ rewardDescription: string | null;
260
+ sortOrder: number;
261
+ thresholdMemberCount: number;
262
+ updatedAt: Date;
263
+ updatedBy: string | null;
264
+ updater: {
265
+ email: string;
266
+ id: string;
267
+ name: string;
268
+ } | null;
269
+ valueAddedRewardAmount: string;
270
+ }[];
271
+ createdAt: Date;
272
+ createdBy: string;
273
+ creator: {
274
+ email: string;
275
+ id: string;
276
+ name: string;
277
+ };
278
+ id: string;
279
+ isEnabled: boolean;
280
+ maxDepth: number;
281
+ name: string;
282
+ platformAsset: {
283
+ code: string;
284
+ id: string;
285
+ isActive: boolean;
286
+ name: string;
287
+ precision: number;
288
+ symbol: string | null;
289
+ };
290
+ platformAssetId: string;
291
+ platformPayoutAccountType: {
292
+ id: string;
293
+ isActive: boolean;
294
+ key: string;
295
+ name: string;
296
+ };
297
+ platformPayoutAccountTypeId: string;
298
+ sortOrder: number;
299
+ updatedAt: Date;
300
+ updatedBy: string | null;
301
+ updater: {
302
+ email: string;
303
+ id: string;
304
+ name: string;
305
+ } | null;
306
+ valueAddedAsset: {
307
+ code: string;
308
+ id: string;
309
+ isActive: boolean;
310
+ name: string;
311
+ precision: number;
312
+ symbol: string | null;
313
+ };
314
+ valueAddedAssetId: string;
315
+ valueAddedPayoutAccountType: {
316
+ id: string;
317
+ isActive: boolean;
318
+ key: string;
319
+ name: string;
320
+ };
321
+ valueAddedPayoutAccountTypeId: string;
322
+ }>;
323
+ static updateRule(operatorId: string, ruleId: string, input: TeamMilestoneRewardRuleUpdateInputType): Promise<{
324
+ rules: {
325
+ createdAt: Date;
326
+ createdBy: string;
327
+ creator: {
328
+ email: string;
329
+ id: string;
330
+ name: string;
331
+ };
332
+ id: string;
333
+ isEnabled: boolean;
334
+ planId: string;
335
+ platformRewardAmount: string;
336
+ rewardDescription: string | null;
337
+ sortOrder: number;
338
+ thresholdMemberCount: number;
339
+ updatedAt: Date;
340
+ updatedBy: string | null;
341
+ updater: {
342
+ email: string;
343
+ id: string;
344
+ name: string;
345
+ } | null;
346
+ valueAddedRewardAmount: string;
347
+ }[];
348
+ createdAt: Date;
349
+ createdBy: string;
350
+ creator: {
351
+ email: string;
352
+ id: string;
353
+ name: string;
354
+ };
355
+ id: string;
356
+ isEnabled: boolean;
357
+ maxDepth: number;
358
+ name: string;
359
+ platformAsset: {
360
+ code: string;
361
+ id: string;
362
+ isActive: boolean;
363
+ name: string;
364
+ precision: number;
365
+ symbol: string | null;
366
+ };
367
+ platformAssetId: string;
368
+ platformPayoutAccountType: {
369
+ id: string;
370
+ isActive: boolean;
371
+ key: string;
372
+ name: string;
373
+ };
374
+ platformPayoutAccountTypeId: string;
375
+ sortOrder: number;
376
+ updatedAt: Date;
377
+ updatedBy: string | null;
378
+ updater: {
379
+ email: string;
380
+ id: string;
381
+ name: string;
382
+ } | null;
383
+ valueAddedAsset: {
384
+ code: string;
385
+ id: string;
386
+ isActive: boolean;
387
+ name: string;
388
+ precision: number;
389
+ symbol: string | null;
390
+ };
391
+ valueAddedAssetId: string;
392
+ valueAddedPayoutAccountType: {
393
+ id: string;
394
+ isActive: boolean;
395
+ key: string;
396
+ name: string;
397
+ };
398
+ valueAddedPayoutAccountTypeId: string;
399
+ }>;
400
+ static deleteRule(operatorId: string, ruleId: string): Promise<{
401
+ rules: {
402
+ createdAt: Date;
403
+ createdBy: string;
404
+ creator: {
405
+ email: string;
406
+ id: string;
407
+ name: string;
408
+ };
409
+ id: string;
410
+ isEnabled: boolean;
411
+ planId: string;
412
+ platformRewardAmount: string;
413
+ rewardDescription: string | null;
414
+ sortOrder: number;
415
+ thresholdMemberCount: number;
416
+ updatedAt: Date;
417
+ updatedBy: string | null;
418
+ updater: {
419
+ email: string;
420
+ id: string;
421
+ name: string;
422
+ } | null;
423
+ valueAddedRewardAmount: string;
424
+ }[];
425
+ createdAt: Date;
426
+ createdBy: string;
427
+ creator: {
428
+ email: string;
429
+ id: string;
430
+ name: string;
431
+ };
432
+ id: string;
433
+ isEnabled: boolean;
434
+ maxDepth: number;
435
+ name: string;
436
+ platformAsset: {
437
+ code: string;
438
+ id: string;
439
+ isActive: boolean;
440
+ name: string;
441
+ precision: number;
442
+ symbol: string | null;
443
+ };
444
+ platformAssetId: string;
445
+ platformPayoutAccountType: {
446
+ id: string;
447
+ isActive: boolean;
448
+ key: string;
449
+ name: string;
450
+ };
451
+ platformPayoutAccountTypeId: string;
452
+ sortOrder: number;
453
+ updatedAt: Date;
454
+ updatedBy: string | null;
455
+ updater: {
456
+ email: string;
457
+ id: string;
458
+ name: string;
459
+ } | null;
460
+ valueAddedAsset: {
461
+ code: string;
462
+ id: string;
463
+ isActive: boolean;
464
+ name: string;
465
+ precision: number;
466
+ symbol: string | null;
467
+ };
468
+ valueAddedAssetId: string;
469
+ valueAddedPayoutAccountType: {
470
+ id: string;
471
+ isActive: boolean;
472
+ key: string;
473
+ name: string;
474
+ };
475
+ valueAddedPayoutAccountTypeId: string;
476
+ }>;
477
+ }
@@ -0,0 +1,2 @@
1
+ /** 团队里程碑默认统计深度(三级内) */
2
+ export declare const TEAM_MILESTONE_DEFAULT_MAX_DEPTH = 3;
@@ -0,0 +1,20 @@
1
+ export * from './locales/zh';
2
+ export declare const TeamMilestoneRewardErrorCodes: {
3
+ readonly TEAM_MILESTONE_REWARD_PLAN_NOT_FOUND: 'TEAM_MILESTONE_REWARD_PLAN_NOT_FOUND';
4
+ readonly TEAM_MILESTONE_REWARD_PLAN_ALREADY_EXISTS: 'TEAM_MILESTONE_REWARD_PLAN_ALREADY_EXISTS';
5
+ readonly TEAM_MILESTONE_REWARD_RULE_NOT_FOUND: 'TEAM_MILESTONE_REWARD_RULE_NOT_FOUND';
6
+ readonly TEAM_MILESTONE_REWARD_RULE_ALREADY_EXISTS: 'TEAM_MILESTONE_REWARD_RULE_ALREADY_EXISTS';
7
+ readonly TEAM_MILESTONE_REWARD_AMOUNT_INVALID: 'TEAM_MILESTONE_REWARD_AMOUNT_INVALID';
8
+ readonly TEAM_MILESTONE_REWARD_THRESHOLD_INVALID: 'TEAM_MILESTONE_REWARD_THRESHOLD_INVALID';
9
+ readonly TEAM_MILESTONE_REWARD_MAX_DEPTH_INVALID: 'TEAM_MILESTONE_REWARD_MAX_DEPTH_INVALID';
10
+ readonly TEAM_MILESTONE_REWARD_ASSET_NOT_FOUND: 'TEAM_MILESTONE_REWARD_ASSET_NOT_FOUND';
11
+ readonly TEAM_MILESTONE_REWARD_ASSET_INACTIVE: 'TEAM_MILESTONE_REWARD_ASSET_INACTIVE';
12
+ readonly TEAM_MILESTONE_REWARD_ACCOUNT_TYPE_NOT_FOUND: 'TEAM_MILESTONE_REWARD_ACCOUNT_TYPE_NOT_FOUND';
13
+ readonly TEAM_MILESTONE_REWARD_ACCOUNT_TYPE_INACTIVE: 'TEAM_MILESTONE_REWARD_ACCOUNT_TYPE_INACTIVE';
14
+ };
15
+ type TeamMilestoneRewardErrorCodesType = typeof TeamMilestoneRewardErrorCodes;
16
+ export type TeamMilestoneRewardErrorCode = keyof TeamMilestoneRewardErrorCodesType;
17
+ declare module '../../../error/errorcode' {
18
+ interface ErrorCodeRegistry extends TeamMilestoneRewardErrorCodesType {
19
+ }
20
+ }
@@ -0,0 +1,19 @@
1
+ export declare const zh: {
2
+ TEAM_MILESTONE_REWARD_PLAN_NOT_FOUND: string;
3
+ TEAM_MILESTONE_REWARD_PLAN_ALREADY_EXISTS: string;
4
+ TEAM_MILESTONE_REWARD_RULE_NOT_FOUND: string;
5
+ TEAM_MILESTONE_REWARD_RULE_ALREADY_EXISTS: string;
6
+ TEAM_MILESTONE_REWARD_AMOUNT_INVALID: string;
7
+ TEAM_MILESTONE_REWARD_THRESHOLD_INVALID: string;
8
+ TEAM_MILESTONE_REWARD_MAX_DEPTH_INVALID: string;
9
+ TEAM_MILESTONE_REWARD_ASSET_NOT_FOUND: string;
10
+ TEAM_MILESTONE_REWARD_ASSET_INACTIVE: string;
11
+ TEAM_MILESTONE_REWARD_ACCOUNT_TYPE_NOT_FOUND: string;
12
+ TEAM_MILESTONE_REWARD_ACCOUNT_TYPE_INACTIVE: string;
13
+ };
14
+ type ZHType = typeof zh;
15
+ declare module '../../../../error/messages' {
16
+ interface ErrorMessageRegistry extends ZHType {
17
+ }
18
+ }
19
+ export {};
@@ -0,0 +1,96 @@
1
+ import type { TransactionTx } from '../../../db/transaction';
2
+ import { TeamMilestoneRewardErrorCodes } from '../errors';
3
+ export declare abstract class InternalTeamMilestoneRewardConfigService {
4
+ static assertPositiveAmount(value: string, invalidCode: typeof TeamMilestoneRewardErrorCodes.TEAM_MILESTONE_REWARD_AMOUNT_INVALID): string;
5
+ static assertPositiveThresholdMemberCount(thresholdMemberCount: number): void;
6
+ static assertPositiveMaxDepth(maxDepth: number): void;
7
+ static ensureRewardAssetValid(tx: TransactionTx, assetId: string): Promise<{
8
+ category: "CRYPTO" | "FIAT" | "POINT" | "RWA";
9
+ code: string;
10
+ createdAt: Date;
11
+ iconUrl: string;
12
+ id: string;
13
+ isActive: boolean;
14
+ name: string;
15
+ precision: number;
16
+ symbol: string | null;
17
+ typeId: string | null;
18
+ updatedAt: Date;
19
+ }>;
20
+ static ensurePayoutAccountTypeValid(tx: TransactionTx, accountTypeId: string): Promise<{
21
+ allowDeposit: boolean;
22
+ allowInternalReceiveTransfer: boolean;
23
+ allowInternalTransfer: boolean;
24
+ allowTransaction: boolean;
25
+ allowTransfer: boolean;
26
+ allowWithdraw: boolean;
27
+ createdAt: Date;
28
+ description: string | null;
29
+ expiryDays: number | null;
30
+ hasExpiry: boolean;
31
+ id: string;
32
+ internalTransferRatio: string;
33
+ isActive: boolean;
34
+ key: string;
35
+ maxInternalTransferAmount: string;
36
+ maxTransferAmount: string;
37
+ maxWithdrawAmount: string;
38
+ minInternalTransferAmount: string;
39
+ minTransferAmount: string;
40
+ minWithdrawAmount: string;
41
+ name: string;
42
+ sortOrder: number;
43
+ updatedAt: Date;
44
+ }>;
45
+ static ensurePlanExists(tx: TransactionTx, planId: string): Promise<{
46
+ createdAt: Date;
47
+ createdBy: string;
48
+ id: string;
49
+ isEnabled: boolean;
50
+ maxDepth: number;
51
+ name: string;
52
+ platformAssetId: string;
53
+ platformPayoutAccountTypeId: string;
54
+ sortOrder: number;
55
+ updatedAt: Date;
56
+ updatedBy: string | null;
57
+ valueAddedAssetId: string;
58
+ valueAddedPayoutAccountTypeId: string;
59
+ }>;
60
+ static findSingletonPlan(tx: TransactionTx): Promise<{
61
+ createdAt: Date;
62
+ createdBy: string;
63
+ id: string;
64
+ isEnabled: boolean;
65
+ maxDepth: number;
66
+ name: string;
67
+ platformAssetId: string;
68
+ platformPayoutAccountTypeId: string;
69
+ sortOrder: number;
70
+ updatedAt: Date;
71
+ updatedBy: string | null;
72
+ valueAddedAssetId: string;
73
+ valueAddedPayoutAccountTypeId: string;
74
+ } | undefined>;
75
+ static ensureSingletonPlan(tx: TransactionTx): Promise<{
76
+ createdAt: Date;
77
+ createdBy: string;
78
+ id: string;
79
+ isEnabled: boolean;
80
+ maxDepth: number;
81
+ name: string;
82
+ platformAssetId: string;
83
+ platformPayoutAccountTypeId: string;
84
+ sortOrder: number;
85
+ updatedAt: Date;
86
+ updatedBy: string | null;
87
+ valueAddedAssetId: string;
88
+ valueAddedPayoutAccountTypeId: string;
89
+ }>;
90
+ static assertNoSingletonPlan(tx: TransactionTx): Promise<void>;
91
+ static assertRuleUnique(tx: TransactionTx, input: {
92
+ planId: string;
93
+ thresholdMemberCount: number;
94
+ excludeRuleId?: string;
95
+ }): Promise<void>;
96
+ }
@@ -0,0 +1,38 @@
1
+ export declare abstract class InternalTeamMilestoneRewardService {
2
+ static sortRules<T extends {
3
+ sortOrder: number;
4
+ thresholdMemberCount: number;
5
+ }>(rules: T[]): T[];
6
+ /** 查询已启用的团队里程碑奖励方案(含已启用规则),未配置或未启用时返回 null */
7
+ static getActivePlan(): Promise<{
8
+ id: string;
9
+ name: string;
10
+ maxDepth: number;
11
+ platformAsset: {
12
+ code: string;
13
+ iconUrl: string;
14
+ id: string;
15
+ isActive: boolean;
16
+ name: string;
17
+ precision: number;
18
+ symbol: string | null;
19
+ };
20
+ valueAddedAsset: {
21
+ code: string;
22
+ iconUrl: string;
23
+ id: string;
24
+ isActive: boolean;
25
+ name: string;
26
+ precision: number;
27
+ symbol: string | null;
28
+ };
29
+ rules: {
30
+ id: string;
31
+ thresholdMemberCount: number;
32
+ platformRewardAmount: string;
33
+ valueAddedRewardAmount: string;
34
+ rewardDescription: string | null;
35
+ sortOrder: number;
36
+ }[];
37
+ } | null>;
38
+ }