@arken/node 1.5.1 → 1.5.2

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 (148) hide show
  1. package/db.ts +76 -1
  2. package/index.ts +351 -18
  3. package/package.json +3 -3
  4. package/tsconfig.json +33 -2
  5. package/util.ts +1 -0
  6. package/modules/area/area.models.ts +0 -15
  7. package/modules/area/area.router.ts +0 -74
  8. package/modules/area/area.schema.ts +0 -22
  9. package/modules/area/area.service.ts +0 -124
  10. package/modules/area/area.types.ts +0 -26
  11. package/modules/area/index.ts +0 -5
  12. package/modules/asset/asset.models.ts +0 -59
  13. package/modules/asset/asset.router.ts +0 -55
  14. package/modules/asset/asset.schema.ts +0 -27
  15. package/modules/asset/asset.service.ts +0 -85
  16. package/modules/asset/asset.types.ts +0 -22
  17. package/modules/asset/index.ts +0 -5
  18. package/modules/chain/chain.models.ts +0 -50
  19. package/modules/chain/chain.router.ts +0 -104
  20. package/modules/chain/chain.schema.ts +0 -52
  21. package/modules/chain/chain.service.ts +0 -167
  22. package/modules/chain/chain.types.ts +0 -24
  23. package/modules/chain/index.ts +0 -5
  24. package/modules/character/character.models.ts +0 -174
  25. package/modules/character/character.router.ts +0 -314
  26. package/modules/character/character.schema.ts +0 -147
  27. package/modules/character/character.service.ts +0 -876
  28. package/modules/character/character.types.ts +0 -64
  29. package/modules/character/index.ts +0 -5
  30. package/modules/chat/chat.models.ts +0 -43
  31. package/modules/chat/chat.router.ts +0 -67
  32. package/modules/chat/chat.schema.ts +0 -36
  33. package/modules/chat/chat.service.ts +0 -128
  34. package/modules/chat/chat.types.ts +0 -20
  35. package/modules/chat/index.ts +0 -5
  36. package/modules/collection/collection.models.ts +0 -76
  37. package/modules/collection/collection.router.ts +0 -91
  38. package/modules/collection/collection.schema.ts +0 -90
  39. package/modules/collection/collection.service.ts +0 -192
  40. package/modules/collection/collection.types.ts +0 -36
  41. package/modules/collection/index.ts +0 -5
  42. package/modules/core/core.models.ts +0 -1380
  43. package/modules/core/core.router.ts +0 -1781
  44. package/modules/core/core.schema.ts +0 -847
  45. package/modules/core/core.service.ts +0 -2824
  46. package/modules/core/core.types.ts +0 -340
  47. package/modules/core/index.ts +0 -5
  48. package/modules/core/mail/applyPatchesOrMail.ts +0 -568
  49. package/modules/core/mail/mailClaimablePatchesBatch.ts +0 -381
  50. package/modules/game/game.models.ts +0 -53
  51. package/modules/game/game.router.ts +0 -110
  52. package/modules/game/game.schema.ts +0 -23
  53. package/modules/game/game.service.ts +0 -143
  54. package/modules/game/game.types.ts +0 -28
  55. package/modules/game/index.ts +0 -5
  56. package/modules/interface/index.ts +0 -5
  57. package/modules/interface/interface.canonicalize.ts +0 -279
  58. package/modules/interface/interface.models.ts +0 -40
  59. package/modules/interface/interface.router.ts +0 -175
  60. package/modules/interface/interface.schema.ts +0 -59
  61. package/modules/interface/interface.service.ts +0 -356
  62. package/modules/interface/interface.types.ts +0 -25
  63. package/modules/item/index.ts +0 -5
  64. package/modules/item/item.models.ts +0 -124
  65. package/modules/item/item.router.ts +0 -103
  66. package/modules/item/item.schema.ts +0 -120
  67. package/modules/item/item.service.ts +0 -167
  68. package/modules/item/item.types.ts +0 -74
  69. package/modules/job/index.ts +0 -5
  70. package/modules/job/job.models.ts +0 -14
  71. package/modules/job/job.router.ts +0 -44
  72. package/modules/job/job.schema.ts +0 -9
  73. package/modules/job/job.service.ts +0 -243
  74. package/modules/job/job.types.ts +0 -23
  75. package/modules/market/index.ts +0 -5
  76. package/modules/market/market.models.ts +0 -113
  77. package/modules/market/market.router.ts +0 -73
  78. package/modules/market/market.schema.ts +0 -140
  79. package/modules/market/market.service.ts +0 -122
  80. package/modules/market/market.types.ts +0 -56
  81. package/modules/product/index.ts +0 -5
  82. package/modules/product/product.models.ts +0 -166
  83. package/modules/product/product.router.ts +0 -93
  84. package/modules/product/product.schema.ts +0 -149
  85. package/modules/product/product.service.ts +0 -160
  86. package/modules/product/product.types.ts +0 -33
  87. package/modules/profile/index.ts +0 -5
  88. package/modules/profile/profile.models.ts +0 -214
  89. package/modules/profile/profile.router.ts +0 -72
  90. package/modules/profile/profile.schema.ts +0 -156
  91. package/modules/profile/profile.service.ts +0 -149
  92. package/modules/profile/profile.types.ts +0 -22
  93. package/modules/raffle/index.ts +0 -5
  94. package/modules/raffle/raffle.models.ts +0 -44
  95. package/modules/raffle/raffle.router.ts +0 -90
  96. package/modules/raffle/raffle.schema.ts +0 -32
  97. package/modules/raffle/raffle.service.ts +0 -167
  98. package/modules/raffle/raffle.types.ts +0 -30
  99. package/modules/skill/index.ts +0 -5
  100. package/modules/skill/skill.models.ts +0 -16
  101. package/modules/skill/skill.router.ts +0 -201
  102. package/modules/skill/skill.schema.ts +0 -40
  103. package/modules/skill/skill.service.ts +0 -390
  104. package/modules/skill/skill.types.ts +0 -33
  105. package/modules/video/index.ts +0 -5
  106. package/modules/video/video.models.ts +0 -25
  107. package/modules/video/video.router.ts +0 -143
  108. package/modules/video/video.schema.ts +0 -46
  109. package/modules/video/video.service.ts +0 -274
  110. package/modules/video/video.types.ts +0 -33
  111. package/util/db/index.ts +0 -7
  112. package/util/db/isPostgresError.ts +0 -9
  113. package/util/db/isUniqueConstraintViolation.ts +0 -3
  114. package/util/db.ts +0 -62
  115. package/util/index.ts +0 -351
  116. /package/{util/api.ts → api.ts} +0 -0
  117. /package/{util/array.ts → array.ts} +0 -0
  118. /package/{util/browser.ts → browser.ts} +0 -0
  119. /package/{util/codebase.ts → codebase.ts} +0 -0
  120. /package/{util/config.ts → config.ts} +0 -0
  121. /package/{util/decoder.test.ts → decoder.test.ts} +0 -0
  122. /package/{util/decoder.ts → decoder.ts} +0 -0
  123. /package/{util/format.ts → format.ts} +0 -0
  124. /package/{util/guid.ts → guid.ts} +0 -0
  125. /package/{util/json.ts → json.ts} +0 -0
  126. /package/{util/log.ts → log.ts} +0 -0
  127. /package/{util/math.ts → math.ts} +0 -0
  128. /package/{util/merkle.ts → merkle.ts} +0 -0
  129. /package/{util/mongo.ts → mongo.ts} +0 -0
  130. /package/{util/number.ts → number.ts} +0 -0
  131. /package/{util/object.ts → object.ts} +0 -0
  132. /package/{util/otp.ts → otp.ts} +0 -0
  133. /package/{util/physics.ts → physics.ts} +0 -0
  134. /package/{util/process.ts → process.ts} +0 -0
  135. /package/{util/rpc.ts → rpc.ts} +0 -0
  136. /package/{util/seer.ts → seer.ts} +0 -0
  137. /package/{util/string.ts → string.ts} +0 -0
  138. /package/{util/text.ts → text.ts} +0 -0
  139. /package/{util/time → time}/date.ts +0 -0
  140. /package/{util/time → time}/fancyTimeFormat.ts +0 -0
  141. /package/{util/time → time}/index.ts +0 -0
  142. /package/{util/time → time}/now.ts +0 -0
  143. /package/{util/types → types}/mongo.d.ts +0 -0
  144. /package/{util/web3 → web3}/httpProvider.ts +0 -0
  145. /package/{util/web3.ts → web3.ts} +0 -0
  146. /package/{util/websocket.ts → websocket.ts} +0 -0
  147. /package/{util/zk.ts → zk.ts} +0 -0
  148. /package/{util/zod.ts → zod.ts} +0 -0
@@ -1,90 +0,0 @@
1
- import { z as zod } from 'zod';
2
- import { initTRPC, inferRouterInputs, inferRouterOutputs } from '@trpc/server';
3
- import { customErrorFormatter, hasRole } from '../../util/rpc';
4
- import type { RouterContext } from '../../types';
5
- import { Raffle, RaffleRequirement, RaffleReward, RaffleEntry } from './raffle.schema';
6
-
7
- export const z = zod;
8
- export const t = initTRPC.context<RouterContext>().create();
9
- export const router = t.router;
10
- export const procedure = t.procedure;
11
-
12
- export const createRouter = () =>
13
- router({
14
- // Raffle endpoints
15
- getRaffle: procedure
16
- .use(hasRole('guest', t))
17
- .use(customErrorFormatter(t))
18
- .input(z.object({ raffleId: z.string() }))
19
- .query(({ input, ctx }) => (ctx.app.service.Raffle.getRaffle as any)(input, ctx)),
20
-
21
- createRaffle: procedure
22
- .use(hasRole('admin', t))
23
- .use(customErrorFormatter(t))
24
- .input(Raffle)
25
- .mutation(({ input, ctx }) => (ctx.app.service.Raffle.createRaffle as any)(input, ctx)),
26
-
27
- updateRaffle: procedure
28
- .use(hasRole('admin', t))
29
- .use(customErrorFormatter(t))
30
- .input(z.object({ raffleId: z.string(), data: Raffle.partial() }))
31
- .mutation(({ input, ctx }) => (ctx.app.service.Raffle.updateRaffle as any)(input, ctx)),
32
-
33
- getRaffleRequirement: procedure
34
- .use(hasRole('guest', t))
35
- .use(customErrorFormatter(t))
36
- .input(z.object({ raffleRequirementId: z.string() }))
37
- .query(({ input, ctx }) => (ctx.app.service.Raffle.getRaffleRequirement as any)(input, ctx)),
38
-
39
- createRaffleRequirement: procedure
40
- .use(hasRole('admin', t))
41
- .use(customErrorFormatter(t))
42
- .input(RaffleRequirement)
43
- .mutation(({ input, ctx }) => (ctx.app.service.Raffle.createRaffleRequirement as any)(input, ctx)),
44
-
45
- updateRaffleRequirement: procedure
46
- .use(hasRole('admin', t))
47
- .use(customErrorFormatter(t))
48
- .input(z.object({ raffleRequirementId: z.string(), data: RaffleRequirement.partial() }))
49
- .mutation(({ input, ctx }) => (ctx.app.service.Raffle.updateRaffleRequirement as any)(input, ctx)),
50
-
51
- getRaffleReward: procedure
52
- .use(hasRole('guest', t))
53
- .use(customErrorFormatter(t))
54
- .input(z.object({ raffleRewardId: z.string() }))
55
- .query(({ input, ctx }) => (ctx.app.service.Raffle.getRaffleReward as any)(input, ctx)),
56
-
57
- createRaffleReward: procedure
58
- .use(hasRole('admin', t))
59
- .use(customErrorFormatter(t))
60
- .input(RaffleReward)
61
- .mutation(({ input, ctx }) => (ctx.app.service.Raffle.createRaffleReward as any)(input, ctx)),
62
-
63
- updateRaffleReward: procedure
64
- .use(hasRole('admin', t))
65
- .use(customErrorFormatter(t))
66
- .input(z.object({ raffleRewardId: z.string(), data: RaffleReward.partial() }))
67
- .mutation(({ input, ctx }) => (ctx.app.service.Raffle.updateRaffleReward as any)(input, ctx)),
68
-
69
- getRaffleEntry: procedure
70
- .use(hasRole('guest', t))
71
- .use(customErrorFormatter(t))
72
- .input(z.object({ raffleEntryId: z.string() }))
73
- .query(({ input, ctx }) => (ctx.app.service.Raffle.getRaffleEntry as any)(input, ctx)),
74
-
75
- createRaffleEntry: procedure
76
- .use(hasRole('admin', t))
77
- .use(customErrorFormatter(t))
78
- .input(RaffleEntry)
79
- .mutation(({ input, ctx }) => (ctx.app.service.Raffle.createRaffleEntry as any)(input, ctx)),
80
-
81
- updateRaffleEntry: procedure
82
- .use(hasRole('admin', t))
83
- .use(customErrorFormatter(t))
84
- .input(z.object({ raffleEntryId: z.string(), data: RaffleEntry.partial() }))
85
- .mutation(({ input, ctx }) => (ctx.app.service.Raffle.updateRaffleEntry as any)(input, ctx)),
86
- });
87
-
88
- export type Router = ReturnType<typeof createRouter>;
89
- export type RouterInput = inferRouterInputs<Router>;
90
- export type RouterOutput = inferRouterOutputs<Router>;
@@ -1,32 +0,0 @@
1
- import { z, ObjectId, Entity } from '../../schema';
2
-
3
- export const Raffle = Entity.merge(
4
- z.object({
5
- content: z.string().min(1),
6
- rewards: z.array(ObjectId).optional(), // List of reward IDs
7
- })
8
- );
9
-
10
- export const RaffleRequirement = Entity.merge(
11
- z.object({
12
- amount: z.number().min(1),
13
- raffleRewardId: ObjectId.optional(), // Reference to the associated RaffleReward
14
- })
15
- );
16
-
17
- export const RaffleReward = Entity.merge(
18
- z.object({
19
- raffleId: ObjectId.optional(), // Reference to the associated Raffle
20
- winnerId: ObjectId.optional(), // Reference to the winning Profile
21
- requirements: z.array(ObjectId).optional(), // List of associated RaffleRequirement IDs
22
- entries: z.array(ObjectId).optional(), // List of associated RaffleEntry IDs
23
- })
24
- );
25
-
26
- export const RaffleEntry = Entity.merge(
27
- z.object({
28
- amount: z.number().min(1),
29
- raffleRewardId: ObjectId.optional(), // Reference to the associated RaffleReward
30
- raffleId: ObjectId.optional(), // Reference to the associated Raffle
31
- })
32
- );
@@ -1,167 +0,0 @@
1
- import type {
2
- Raffle,
3
- RaffleRequirement,
4
- RaffleReward,
5
- RaffleEntry,
6
- RouterContext,
7
- Router,
8
- RouterInput,
9
- RouterOutput,
10
- } from './raffle.types';
11
-
12
- export class Service {
13
- async getRaffle(input: RouterInput['getRaffle'], ctx: RouterContext): Promise<RouterOutput['getRaffle']> {
14
- if (!input) throw new Error('Input should not be void');
15
- console.log('Raffle.Service.getRaffle', input.raffleId);
16
-
17
- const raffle = await ctx.app.model.Raffle.findById(input.raffleId).lean().exec();
18
- if (!raffle) throw new Error('Raffle not found');
19
-
20
- return raffle as Raffle;
21
- }
22
-
23
- async createRaffle(input: RouterInput['createRaffle'], ctx: RouterContext): Promise<RouterOutput['createRaffle']> {
24
- if (!input) throw new Error('Input should not be void');
25
- console.log('Raffle.Service.createRaffle', input);
26
-
27
- const raffle = await ctx.app.model.Raffle.create(input);
28
- return raffle as Raffle;
29
- }
30
-
31
- async updateRaffle(input: RouterInput['updateRaffle'], ctx: RouterContext): Promise<RouterOutput['updateRaffle']> {
32
- if (!input) throw new Error('Input should not be void');
33
- console.log('Raffle.Service.updateRaffle', input.raffleId, input.data);
34
-
35
- const updatedRaffle = await ctx.app.model.Raffle.findByIdAndUpdate(input.raffleId, input.data, { new: true })
36
- .lean()
37
- .exec();
38
- if (!updatedRaffle) throw new Error('Raffle update failed');
39
-
40
- return updatedRaffle as Raffle;
41
- }
42
-
43
- async getRaffleRequirement(
44
- input: RouterInput['getRaffleRequirement'],
45
- ctx: RouterContext
46
- ): Promise<RouterOutput['getRaffleRequirement']> {
47
- if (!input) throw new Error('Input should not be void');
48
- console.log('Raffle.Service.getRaffleRequirement', input.raffleRequirementId);
49
-
50
- const raffleRequirement = await ctx.app.model.RaffleRequirement.findById(input.raffleRequirementId).lean().exec();
51
- if (!raffleRequirement) throw new Error('Raffle Requirement not found');
52
-
53
- return raffleRequirement as RaffleRequirement;
54
- }
55
-
56
- async createRaffleRequirement(
57
- input: RouterInput['createRaffleRequirement'],
58
- ctx: RouterContext
59
- ): Promise<RouterOutput['createRaffleRequirement']> {
60
- if (!input) throw new Error('Input should not be void');
61
- console.log('Raffle.Service.createRaffleRequirement', input);
62
-
63
- const raffleRequirement = await ctx.app.model.RaffleRequirement.create(input);
64
- return raffleRequirement as RaffleRequirement;
65
- }
66
-
67
- async updateRaffleRequirement(
68
- input: RouterInput['updateRaffleRequirement'],
69
- ctx: RouterContext
70
- ): Promise<RouterOutput['updateRaffleRequirement']> {
71
- if (!input) throw new Error('Input should not be void');
72
- console.log('Raffle.Service.updateRaffleRequirement', input.raffleRequirementId, input.data);
73
-
74
- const updatedRaffleRequirement = await ctx.app.model.RaffleRequirement.findByIdAndUpdate(
75
- input.raffleRequirementId,
76
- input.data,
77
- { new: true }
78
- )
79
- .lean()
80
- .exec();
81
- if (!updatedRaffleRequirement) throw new Error('Raffle Requirement update failed');
82
-
83
- return updatedRaffleRequirement as RaffleRequirement;
84
- }
85
-
86
- async getRaffleReward(
87
- input: RouterInput['getRaffleReward'],
88
- ctx: RouterContext
89
- ): Promise<RouterOutput['getRaffleReward']> {
90
- if (!input) throw new Error('Input should not be void');
91
- console.log('Raffle.Service.getRaffleReward', input.raffleRewardId);
92
-
93
- const raffleReward = await ctx.app.model.RaffleReward.findById(input.raffleRewardId).lean().exec();
94
- if (!raffleReward) throw new Error('Raffle Reward not found');
95
-
96
- return raffleReward as RaffleReward;
97
- }
98
-
99
- async createRaffleReward(
100
- input: RouterInput['createRaffleReward'],
101
- ctx: RouterContext
102
- ): Promise<RouterOutput['createRaffleReward']> {
103
- if (!input) throw new Error('Input should not be void');
104
- console.log('Raffle.Service.createRaffleReward', input);
105
-
106
- const raffleReward = await ctx.app.model.RaffleReward.create(input);
107
- return raffleReward as RaffleReward;
108
- }
109
-
110
- async updateRaffleReward(
111
- input: RouterInput['updateRaffleReward'],
112
- ctx: RouterContext
113
- ): Promise<RouterOutput['updateRaffleReward']> {
114
- if (!input) throw new Error('Input should not be void');
115
- console.log('Raffle.Service.updateRaffleReward', input.raffleRewardId, input.data);
116
-
117
- const updatedRaffleReward = await ctx.app.model.RaffleReward.findByIdAndUpdate(input.raffleRewardId, input.data, {
118
- new: true,
119
- })
120
- .lean()
121
- .exec();
122
- if (!updatedRaffleReward) throw new Error('Raffle Reward update failed');
123
-
124
- return updatedRaffleReward as RaffleReward;
125
- }
126
-
127
- async getRaffleEntry(
128
- input: RouterInput['getRaffleEntry'],
129
- ctx: RouterContext
130
- ): Promise<RouterOutput['getRaffleEntry']> {
131
- if (!input) throw new Error('Input should not be void');
132
- console.log('Raffle.Service.getRaffleEntry', input.raffleEntryId);
133
-
134
- const raffleEntry = await ctx.app.model.RaffleEntry.findById(input.raffleEntryId).lean().exec();
135
- if (!raffleEntry) throw new Error('Raffle Entry not found');
136
-
137
- return raffleEntry as RaffleEntry;
138
- }
139
-
140
- async createRaffleEntry(
141
- input: RouterInput['createRaffleEntry'],
142
- ctx: RouterContext
143
- ): Promise<RouterOutput['createRaffleEntry']> {
144
- if (!input) throw new Error('Input should not be void');
145
- console.log('Raffle.Service.createRaffleEntry', input);
146
-
147
- const raffleEntry = await ctx.app.model.RaffleEntry.create(input);
148
- return raffleEntry as RaffleEntry;
149
- }
150
-
151
- async updateRaffleEntry(
152
- input: RouterInput['updateRaffleEntry'],
153
- ctx: RouterContext
154
- ): Promise<RouterOutput['updateRaffleEntry']> {
155
- if (!input) throw new Error('Input should not be void');
156
- console.log('Raffle.Service.updateRaffleEntry', input.raffleEntryId, input.data);
157
-
158
- const updatedRaffleEntry = await ctx.app.model.RaffleEntry.findByIdAndUpdate(input.raffleEntryId, input.data, {
159
- new: true,
160
- })
161
- .lean()
162
- .exec();
163
- if (!updatedRaffleEntry) throw new Error('Raffle Entry update failed');
164
-
165
- return updatedRaffleEntry as RaffleEntry;
166
- }
167
- }
@@ -1,30 +0,0 @@
1
- import { z } from 'zod';
2
- import * as schema from './raffle.schema';
3
- import { Document, Model } from '../../util/mongo';
4
- import type { RouterContext } from '../../types';
5
- import type { inferRouterInputs, inferRouterOutputs } from '@trpc/server';
6
- import type { Router } from './raffle.router';
7
-
8
- export type * from './raffle.router';
9
- export type * from './raffle.service';
10
- export type { RouterContext };
11
-
12
- export type Raffle = z.infer<typeof schema.Raffle>;
13
- export type RaffleRequirement = z.infer<typeof schema.RaffleRequirement>;
14
- export type RaffleReward = z.infer<typeof schema.RaffleReward>;
15
- export type RaffleEntry = z.infer<typeof schema.RaffleEntry>;
16
-
17
- export type RaffleDocument = Raffle & Document;
18
- export type RaffleRequirementDocument = RaffleRequirement & Document;
19
- export type RaffleRewardDocument = RaffleReward & Document;
20
- export type RaffleEntryDocument = RaffleEntry & Document;
21
-
22
- export type Mappings = {
23
- Raffle: Model<RaffleDocument>;
24
- RaffleRequirement: Model<RaffleRequirementDocument>;
25
- RaffleReward: Model<RaffleRewardDocument>;
26
- RaffleEntry: Model<RaffleEntryDocument>;
27
- };
28
-
29
- export type RouterInput = inferRouterInputs<Router>;
30
- export type RouterOutput = inferRouterOutputs<Router>;
@@ -1,5 +0,0 @@
1
- export * as Types from './skill.types';
2
- export * as Models from './skill.models';
3
- export * as Schemas from './skill.schema';
4
- export * from './skill.router';
5
- export * from './skill.service';
@@ -1,16 +0,0 @@
1
- import * as mongo from '../../util/mongo';
2
- import type * as Types from './skill.types';
3
-
4
- export const Skill = mongo.createModel<Types.SkillDocument>('Skill', {});
5
-
6
- export const SkillMod = mongo.createModel<Types.SkillModDocument>('SkillMod', {});
7
-
8
- export const SkillClassification = mongo.createModel<Types.SkillClassificationDocument>('SkillClassification', {});
9
-
10
- export const SkillCondition = mongo.createModel<Types.SkillConditionDocument>('SkillCondition', {});
11
-
12
- export const SkillStatusEffect = mongo.createModel<Types.SkillStatusEffectDocument>('SkillStatusEffect', {});
13
-
14
- export const SkillTree = mongo.createModel<Types.SkillTreeDocument>('SkillTree', {});
15
-
16
- export const SkillTreeNode = mongo.createModel<Types.SkillTreeNodeDocument>('SkillTreeNode', {});
@@ -1,201 +0,0 @@
1
- import { z as zod } from 'zod';
2
- import { initTRPC, inferRouterInputs, inferRouterOutputs } from '@trpc/server';
3
- import { customErrorFormatter, hasRole } from '../../util/rpc';
4
- import type { RouterContext } from '../../types';
5
- import {
6
- Skill,
7
- SkillMod,
8
- SkillClassification,
9
- SkillCondition,
10
- SkillStatusEffect,
11
- SkillTree,
12
- SkillTreeNode,
13
- } from './skill.schema';
14
- import { Query } from '../../schema';
15
-
16
- export const z = zod;
17
- export const t = initTRPC.context<RouterContext>().create();
18
- export const router = t.router;
19
- export const procedure = t.procedure;
20
-
21
- export const createRouter = () =>
22
- router({
23
- // Skill Procedures
24
- getSkill: procedure
25
- .use(hasRole('guest', t))
26
- .use(customErrorFormatter(t))
27
- .input(z.object({ query: Query }))
28
- .query(({ input, ctx }) => (ctx.app.service.Skill.getSkill as any)(input, ctx)),
29
-
30
- createSkill: procedure
31
- .use(hasRole('admin', t))
32
- .use(customErrorFormatter(t))
33
- .input(z.object({ data: Skill.omit({ id: true }) }))
34
- .mutation(({ input, ctx }) => (ctx.app.service.Skill.createSkill as any)(input, ctx)),
35
-
36
- updateSkill: procedure
37
- .use(hasRole('admin', t))
38
- .use(customErrorFormatter(t))
39
- .input(z.object({ query: Query, data: Skill.partial() }))
40
- .mutation(({ input, ctx }) => (ctx.app.service.Skill.updateSkill as any)(input, ctx)),
41
-
42
- deleteSkill: procedure
43
- .use(hasRole('admin', t))
44
- .use(customErrorFormatter(t))
45
- .input(z.object({ query: Query }))
46
- .mutation(({ input, ctx }) => (ctx.app.service.Skill.deleteSkill as any)(input, ctx)),
47
-
48
- // SkillMod Procedures
49
- getSkillMod: procedure
50
- .use(hasRole('guest', t))
51
- .use(customErrorFormatter(t))
52
- .input(z.object({ query: Query }))
53
- .query(({ input, ctx }) => (ctx.app.service.Skill.getSkillMod as any)(input, ctx)),
54
-
55
- createSkillMod: procedure
56
- .use(hasRole('admin', t))
57
- .use(customErrorFormatter(t))
58
- .input(z.object({ data: SkillMod.omit({ id: true }) }))
59
- .mutation(({ input, ctx }) => (ctx.app.service.Skill.createSkillMod as any)(input, ctx)),
60
-
61
- updateSkillMod: procedure
62
- .use(hasRole('admin', t))
63
- .use(customErrorFormatter(t))
64
- .input(z.object({ query: Query, data: SkillMod.partial() }))
65
- .mutation(({ input, ctx }) => (ctx.app.service.Skill.updateSkillMod as any)(input, ctx)),
66
-
67
- deleteSkillMod: procedure
68
- .use(hasRole('admin', t))
69
- .use(customErrorFormatter(t))
70
- .input(z.object({ query: Query }))
71
- .mutation(({ input, ctx }) => (ctx.app.service.Skill.deleteSkillMod as any)(input, ctx)),
72
-
73
- // SkillClassification Procedures
74
- getSkillClassification: procedure
75
- .use(hasRole('guest', t))
76
- .use(customErrorFormatter(t))
77
- .input(z.object({ query: Query }))
78
- .query(({ input, ctx }) => (ctx.app.service.Skill.getSkillClassification as any)(input, ctx)),
79
-
80
- createSkillClassification: procedure
81
- .use(hasRole('admin', t))
82
- .use(customErrorFormatter(t))
83
- .input(z.object({ data: SkillClassification.omit({ id: true }) }))
84
- .mutation(({ input, ctx }) => (ctx.app.service.Skill.createSkillClassification as any)(input, ctx)),
85
-
86
- updateSkillClassification: procedure
87
- .use(hasRole('admin', t))
88
- .use(customErrorFormatter(t))
89
- .input(z.object({ query: Query, data: SkillClassification.partial() }))
90
- .mutation(({ input, ctx }) => (ctx.app.service.Skill.updateSkillClassification as any)(input, ctx)),
91
-
92
- deleteSkillClassification: procedure
93
- .use(hasRole('admin', t))
94
- .use(customErrorFormatter(t))
95
- .input(z.object({ query: Query }))
96
- .mutation(({ input, ctx }) => (ctx.app.service.Skill.deleteSkillClassification as any)(input, ctx)),
97
-
98
- // SkillCondition Procedures
99
- getSkillCondition: procedure
100
- .use(hasRole('guest', t))
101
- .use(customErrorFormatter(t))
102
- .input(z.object({ query: Query }))
103
- .query(({ input, ctx }) => (ctx.app.service.Skill.getSkillCondition as any)(input, ctx)),
104
-
105
- createSkillCondition: procedure
106
- .use(hasRole('admin', t))
107
- .use(customErrorFormatter(t))
108
- .input(z.object({ data: SkillCondition.omit({ id: true }) }))
109
- .mutation(({ input, ctx }) => (ctx.app.service.Skill.createSkillCondition as any)(input, ctx)),
110
-
111
- updateSkillCondition: procedure
112
- .use(hasRole('admin', t))
113
- .use(customErrorFormatter(t))
114
- .input(z.object({ query: Query, data: SkillCondition.partial() }))
115
- .mutation(({ input, ctx }) => (ctx.app.service.Skill.updateSkillCondition as any)(input, ctx)),
116
-
117
- deleteSkillCondition: procedure
118
- .use(hasRole('admin', t))
119
- .use(customErrorFormatter(t))
120
- .input(z.object({ query: Query }))
121
- .mutation(({ input, ctx }) => (ctx.app.service.Skill.deleteSkillCondition as any)(input, ctx)),
122
-
123
- // SkillStatusEffect Procedures
124
- getSkillStatusEffect: procedure
125
- .use(hasRole('guest', t))
126
- .use(customErrorFormatter(t))
127
- .input(z.object({ query: Query }))
128
- .query(({ input, ctx }) => (ctx.app.service.Skill.getSkillStatusEffect as any)(input, ctx)),
129
-
130
- createSkillStatusEffect: procedure
131
- .use(hasRole('admin', t))
132
- .use(customErrorFormatter(t))
133
- .input(z.object({ data: SkillStatusEffect.omit({ id: true }) }))
134
- .mutation(({ input, ctx }) => (ctx.app.service.Skill.createSkillStatusEffect as any)(input, ctx)),
135
-
136
- updateSkillStatusEffect: procedure
137
- .use(hasRole('admin', t))
138
- .use(customErrorFormatter(t))
139
- .input(z.object({ query: Query, data: SkillStatusEffect.partial() }))
140
- .mutation(({ input, ctx }) => (ctx.app.service.Skill.updateSkillStatusEffect as any)(input, ctx)),
141
-
142
- deleteSkillStatusEffect: procedure
143
- .use(hasRole('admin', t))
144
- .use(customErrorFormatter(t))
145
- .input(z.object({ query: Query }))
146
- .mutation(({ input, ctx }) => (ctx.app.service.Skill.deleteSkillStatusEffect as any)(input, ctx)),
147
-
148
- // SkillTree Procedures
149
- getSkillTree: procedure
150
- .use(hasRole('guest', t))
151
- .use(customErrorFormatter(t))
152
- .input(z.object({ query: Query }))
153
- .query(({ input, ctx }) => (ctx.app.service.Skill.getSkillTree as any)(input, ctx)),
154
-
155
- createSkillTree: procedure
156
- .use(hasRole('admin', t))
157
- .use(customErrorFormatter(t))
158
- .input(z.object({ data: SkillTree.omit({ id: true }) }))
159
- .mutation(({ input, ctx }) => (ctx.app.service.Skill.createSkillTree as any)(input, ctx)),
160
-
161
- updateSkillTree: procedure
162
- .use(hasRole('admin', t))
163
- .use(customErrorFormatter(t))
164
- .input(z.object({ query: Query, data: SkillTree.partial() }))
165
- .mutation(({ input, ctx }) => (ctx.app.service.Skill.updateSkillTree as any)(input, ctx)),
166
-
167
- deleteSkillTree: procedure
168
- .use(hasRole('admin', t))
169
- .use(customErrorFormatter(t))
170
- .input(z.object({ query: Query }))
171
- .mutation(({ input, ctx }) => (ctx.app.service.Skill.deleteSkillTree as any)(input, ctx)),
172
-
173
- // SkillTreeNode Procedures
174
- getSkillTreeNode: procedure
175
- .use(hasRole('guest', t))
176
- .use(customErrorFormatter(t))
177
- .input(z.object({ query: Query }))
178
- .query(({ input, ctx }) => (ctx.app.service.Skill.getSkillTreeNode as any)(input, ctx)),
179
-
180
- createSkillTreeNode: procedure
181
- .use(hasRole('admin', t))
182
- .use(customErrorFormatter(t))
183
- .input(z.object({ data: SkillTreeNode.omit({ id: true }) }))
184
- .mutation(({ input, ctx }) => (ctx.app.service.Skill.createSkillTreeNode as any)(input, ctx)),
185
-
186
- updateSkillTreeNode: procedure
187
- .use(hasRole('admin', t))
188
- .use(customErrorFormatter(t))
189
- .input(z.object({ query: Query, data: SkillTreeNode.partial() }))
190
- .mutation(({ input, ctx }) => (ctx.app.service.Skill.updateSkillTreeNode as any)(input, ctx)),
191
-
192
- deleteSkillTreeNode: procedure
193
- .use(hasRole('admin', t))
194
- .use(customErrorFormatter(t))
195
- .input(z.object({ query: Query }))
196
- .mutation(({ input, ctx }) => (ctx.app.service.Skill.deleteSkillTreeNode as any)(input, ctx)),
197
- });
198
-
199
- export type Router = ReturnType<typeof createRouter>;
200
- export type RouterInput = inferRouterInputs<Router>;
201
- export type RouterOutput = inferRouterOutputs<Router>;
@@ -1,40 +0,0 @@
1
- import { z, ObjectId, Entity } from '../../schema';
2
-
3
- export const Skill = Entity.merge(
4
- z.object({
5
- name: z.string().min(1),
6
- description: z.string().min(1).optional(),
7
- type: z.enum(['attack', 'defense', 'utility']),
8
- cooldown: z.number().min(0).optional(),
9
- power: z.number().min(0).optional(),
10
- })
11
- );
12
-
13
- export const SkillEffect = Entity.merge(
14
- z.object({
15
- skillId: ObjectId, // Reference to the associated Skill
16
- effectType: z.enum(['damage', 'heal', 'buff', 'debuff']),
17
- magnitude: z.number().min(0),
18
- duration: z.number().min(0).optional(),
19
- })
20
- );
21
-
22
- export const SkillRequirement = Entity.merge(
23
- z.object({
24
- skillId: ObjectId, // Reference to the associated Skill
25
- levelRequired: z.number().min(1),
26
- previousSkillId: ObjectId.optional(), // Reference to a prerequisite skill
27
- })
28
- );
29
-
30
- export const SkillMod = Entity.merge(z.object({}));
31
-
32
- export const SkillClassification = Entity.merge(z.object({}));
33
-
34
- export const SkillCondition = Entity.merge(z.object({}));
35
-
36
- export const SkillStatusEffect = Entity.merge(z.object({}));
37
-
38
- export const SkillTree = Entity.merge(z.object({}));
39
-
40
- export const SkillTreeNode = Entity.merge(z.object({}));