@arken/node 1.5.0 → 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 (160) hide show
  1. package/build/modules/character/character.service.js.map +1 -1
  2. package/build/modules/chat/chat.service.js.map +1 -1
  3. package/build/modules/core/core.models.js.map +1 -1
  4. package/build/modules/core/core.service.js.map +1 -1
  5. package/build/modules/profile/profile.service.js.map +1 -1
  6. package/build/package.json +2 -2
  7. package/build/tsconfig.tsbuildinfo +1 -1
  8. package/build/types.d.ts +1 -0
  9. package/build/types.js +1 -0
  10. package/build/types.js.map +1 -1
  11. package/build/util/mongo.js.map +1 -1
  12. package/db.ts +76 -1
  13. package/index.ts +351 -18
  14. package/{util/mongo.ts → mongo.ts} +2 -0
  15. package/package.json +3 -3
  16. package/tsconfig.json +33 -2
  17. package/types.ts +2 -0
  18. package/util.ts +1 -0
  19. package/modules/area/area.models.ts +0 -15
  20. package/modules/area/area.router.ts +0 -74
  21. package/modules/area/area.schema.ts +0 -22
  22. package/modules/area/area.service.ts +0 -124
  23. package/modules/area/area.types.ts +0 -26
  24. package/modules/area/index.ts +0 -5
  25. package/modules/asset/asset.models.ts +0 -59
  26. package/modules/asset/asset.router.ts +0 -55
  27. package/modules/asset/asset.schema.ts +0 -27
  28. package/modules/asset/asset.service.ts +0 -85
  29. package/modules/asset/asset.types.ts +0 -22
  30. package/modules/asset/index.ts +0 -5
  31. package/modules/chain/chain.models.ts +0 -50
  32. package/modules/chain/chain.router.ts +0 -104
  33. package/modules/chain/chain.schema.ts +0 -52
  34. package/modules/chain/chain.service.ts +0 -167
  35. package/modules/chain/chain.types.ts +0 -24
  36. package/modules/chain/index.ts +0 -5
  37. package/modules/character/character.models.ts +0 -174
  38. package/modules/character/character.router.ts +0 -314
  39. package/modules/character/character.schema.ts +0 -147
  40. package/modules/character/character.service.ts +0 -875
  41. package/modules/character/character.types.ts +0 -64
  42. package/modules/character/index.ts +0 -5
  43. package/modules/chat/chat.models.ts +0 -43
  44. package/modules/chat/chat.router.ts +0 -67
  45. package/modules/chat/chat.schema.ts +0 -36
  46. package/modules/chat/chat.service.ts +0 -120
  47. package/modules/chat/chat.types.ts +0 -20
  48. package/modules/chat/index.ts +0 -5
  49. package/modules/collection/collection.models.ts +0 -76
  50. package/modules/collection/collection.router.ts +0 -91
  51. package/modules/collection/collection.schema.ts +0 -90
  52. package/modules/collection/collection.service.ts +0 -192
  53. package/modules/collection/collection.types.ts +0 -36
  54. package/modules/collection/index.ts +0 -5
  55. package/modules/core/core.models.ts +0 -1379
  56. package/modules/core/core.router.ts +0 -1781
  57. package/modules/core/core.schema.ts +0 -847
  58. package/modules/core/core.service.ts +0 -2822
  59. package/modules/core/core.types.ts +0 -340
  60. package/modules/core/index.ts +0 -5
  61. package/modules/core/mail/applyPatchesOrMail.ts +0 -568
  62. package/modules/core/mail/mailClaimablePatchesBatch.ts +0 -381
  63. package/modules/game/game.models.ts +0 -53
  64. package/modules/game/game.router.ts +0 -110
  65. package/modules/game/game.schema.ts +0 -23
  66. package/modules/game/game.service.ts +0 -143
  67. package/modules/game/game.types.ts +0 -28
  68. package/modules/game/index.ts +0 -5
  69. package/modules/interface/index.ts +0 -5
  70. package/modules/interface/interface.canonicalize.ts +0 -279
  71. package/modules/interface/interface.models.ts +0 -40
  72. package/modules/interface/interface.router.ts +0 -175
  73. package/modules/interface/interface.schema.ts +0 -59
  74. package/modules/interface/interface.service.ts +0 -356
  75. package/modules/interface/interface.types.ts +0 -25
  76. package/modules/item/index.ts +0 -5
  77. package/modules/item/item.models.ts +0 -124
  78. package/modules/item/item.router.ts +0 -103
  79. package/modules/item/item.schema.ts +0 -120
  80. package/modules/item/item.service.ts +0 -167
  81. package/modules/item/item.types.ts +0 -74
  82. package/modules/job/index.ts +0 -5
  83. package/modules/job/job.models.ts +0 -14
  84. package/modules/job/job.router.ts +0 -44
  85. package/modules/job/job.schema.ts +0 -9
  86. package/modules/job/job.service.ts +0 -243
  87. package/modules/job/job.types.ts +0 -23
  88. package/modules/market/index.ts +0 -5
  89. package/modules/market/market.models.ts +0 -113
  90. package/modules/market/market.router.ts +0 -73
  91. package/modules/market/market.schema.ts +0 -140
  92. package/modules/market/market.service.ts +0 -122
  93. package/modules/market/market.types.ts +0 -56
  94. package/modules/product/index.ts +0 -5
  95. package/modules/product/product.models.ts +0 -166
  96. package/modules/product/product.router.ts +0 -93
  97. package/modules/product/product.schema.ts +0 -149
  98. package/modules/product/product.service.ts +0 -160
  99. package/modules/product/product.types.ts +0 -33
  100. package/modules/profile/index.ts +0 -5
  101. package/modules/profile/profile.models.ts +0 -214
  102. package/modules/profile/profile.router.ts +0 -72
  103. package/modules/profile/profile.schema.ts +0 -156
  104. package/modules/profile/profile.service.ts +0 -147
  105. package/modules/profile/profile.types.ts +0 -22
  106. package/modules/raffle/index.ts +0 -5
  107. package/modules/raffle/raffle.models.ts +0 -44
  108. package/modules/raffle/raffle.router.ts +0 -90
  109. package/modules/raffle/raffle.schema.ts +0 -32
  110. package/modules/raffle/raffle.service.ts +0 -167
  111. package/modules/raffle/raffle.types.ts +0 -30
  112. package/modules/skill/index.ts +0 -5
  113. package/modules/skill/skill.models.ts +0 -16
  114. package/modules/skill/skill.router.ts +0 -201
  115. package/modules/skill/skill.schema.ts +0 -40
  116. package/modules/skill/skill.service.ts +0 -390
  117. package/modules/skill/skill.types.ts +0 -33
  118. package/modules/video/index.ts +0 -5
  119. package/modules/video/video.models.ts +0 -25
  120. package/modules/video/video.router.ts +0 -143
  121. package/modules/video/video.schema.ts +0 -46
  122. package/modules/video/video.service.ts +0 -274
  123. package/modules/video/video.types.ts +0 -33
  124. package/util/db/index.ts +0 -7
  125. package/util/db/isPostgresError.ts +0 -9
  126. package/util/db/isUniqueConstraintViolation.ts +0 -3
  127. package/util/db.ts +0 -62
  128. package/util/index.ts +0 -351
  129. /package/{util/api.ts → api.ts} +0 -0
  130. /package/{util/array.ts → array.ts} +0 -0
  131. /package/{util/browser.ts → browser.ts} +0 -0
  132. /package/{util/codebase.ts → codebase.ts} +0 -0
  133. /package/{util/config.ts → config.ts} +0 -0
  134. /package/{util/decoder.test.ts → decoder.test.ts} +0 -0
  135. /package/{util/decoder.ts → decoder.ts} +0 -0
  136. /package/{util/format.ts → format.ts} +0 -0
  137. /package/{util/guid.ts → guid.ts} +0 -0
  138. /package/{util/json.ts → json.ts} +0 -0
  139. /package/{util/log.ts → log.ts} +0 -0
  140. /package/{util/math.ts → math.ts} +0 -0
  141. /package/{util/merkle.ts → merkle.ts} +0 -0
  142. /package/{util/number.ts → number.ts} +0 -0
  143. /package/{util/object.ts → object.ts} +0 -0
  144. /package/{util/otp.ts → otp.ts} +0 -0
  145. /package/{util/physics.ts → physics.ts} +0 -0
  146. /package/{util/process.ts → process.ts} +0 -0
  147. /package/{util/rpc.ts → rpc.ts} +0 -0
  148. /package/{util/seer.ts → seer.ts} +0 -0
  149. /package/{util/string.ts → string.ts} +0 -0
  150. /package/{util/text.ts → text.ts} +0 -0
  151. /package/{util/time → time}/date.ts +0 -0
  152. /package/{util/time → time}/fancyTimeFormat.ts +0 -0
  153. /package/{util/time → time}/index.ts +0 -0
  154. /package/{util/time → time}/now.ts +0 -0
  155. /package/{util/types → types}/mongo.d.ts +0 -0
  156. /package/{util/web3 → web3}/httpProvider.ts +0 -0
  157. /package/{util/web3.ts → web3.ts} +0 -0
  158. /package/{util/websocket.ts → websocket.ts} +0 -0
  159. /package/{util/zk.ts → zk.ts} +0 -0
  160. /package/{util/zod.ts → zod.ts} +0 -0
@@ -1,390 +0,0 @@
1
- import type { RouterContext } from '../../types';
2
- import type { Router, RouterInput, RouterOutput } from './skill.types';
3
- import { getFilter } from '../../util/api';
4
- import type {
5
- Skill,
6
- SkillMod,
7
- SkillClassification,
8
- SkillCondition,
9
- SkillStatusEffect,
10
- SkillTree,
11
- SkillTreeNode,
12
- } from './skill.types';
13
-
14
- export class Service {
15
- // Skill Methods
16
- async getSkill(input: RouterInput['getSkill'], ctx: RouterContext): Promise<RouterOutput['getSkill']> {
17
- if (!input) throw new Error('Input should not be void');
18
- console.log('Skill.Service.getSkill', input.query);
19
-
20
- const filter = getFilter(input.query);
21
- const skill = await ctx.app.model.Skill.findOne(filter).lean().exec();
22
- if (!skill) throw new Error('Skill not found');
23
-
24
- return skill as Skill;
25
- }
26
-
27
- async createSkill(input: RouterInput['createSkill'], ctx: RouterContext): Promise<RouterOutput['createSkill']> {
28
- if (!input) throw new Error('Input should not be void');
29
- console.log('Skill.Service.createSkill', input.data);
30
-
31
- const skill = await ctx.app.model.Skill.create(input.data);
32
- return skill as Skill;
33
- }
34
-
35
- async updateSkill(input: RouterInput['updateSkill'], ctx: RouterContext): Promise<RouterOutput['updateSkill']> {
36
- if (!input) throw new Error('Input should not be void');
37
- console.log('Skill.Service.updateSkill', input.query, input.data);
38
-
39
- const filter = getFilter(input.query);
40
- const updatedSkill = await ctx.app.model.Skill.findOneAndUpdate(filter, input.data, { new: true }).lean().exec();
41
- if (!updatedSkill) throw new Error('Skill update failed');
42
-
43
- return updatedSkill as Skill;
44
- }
45
-
46
- async deleteSkill(input: RouterInput['deleteSkill'], ctx: RouterContext): Promise<RouterOutput['deleteSkill']> {
47
- if (!input) throw new Error('Input should not be void');
48
- console.log('Skill.Service.deleteSkill', input.query);
49
-
50
- const filter = getFilter(input.query);
51
- const deletedSkill = await ctx.app.model.Skill.findOneAndDelete(filter).lean().exec();
52
- if (!deletedSkill) throw new Error('Skill delete failed');
53
-
54
- return deletedSkill as Skill;
55
- }
56
-
57
- // SkillMod Methods
58
- async getSkillMod(input: RouterInput['getSkillMod'], ctx: RouterContext): Promise<RouterOutput['getSkillMod']> {
59
- if (!input) throw new Error('Input should not be void');
60
- console.log('Skill.Service.getSkillMod', input.query);
61
-
62
- const filter = getFilter(input.query);
63
- const skillMod = await ctx.app.model.SkillMod.findOne(filter).lean().exec();
64
- if (!skillMod) throw new Error('SkillMod not found');
65
-
66
- return skillMod as SkillMod;
67
- }
68
-
69
- async createSkillMod(
70
- input: RouterInput['createSkillMod'],
71
- ctx: RouterContext
72
- ): Promise<RouterOutput['createSkillMod']> {
73
- if (!input) throw new Error('Input should not be void');
74
- console.log('Skill.Service.createSkillMod', input.data);
75
-
76
- const skillMod = await ctx.app.model.SkillMod.create(input.data);
77
- return skillMod as SkillMod;
78
- }
79
-
80
- async updateSkillMod(
81
- input: RouterInput['updateSkillMod'],
82
- ctx: RouterContext
83
- ): Promise<RouterOutput['updateSkillMod']> {
84
- if (!input) throw new Error('Input should not be void');
85
- console.log('Skill.Service.updateSkillMod', input.query, input.data);
86
-
87
- const filter = getFilter(input.query);
88
- const updatedSkillMod = await ctx.app.model.SkillMod.findOneAndUpdate(filter, input.data, { new: true })
89
- .lean()
90
- .exec();
91
- if (!updatedSkillMod) throw new Error('SkillMod update failed');
92
-
93
- return updatedSkillMod as SkillMod;
94
- }
95
-
96
- async deleteSkillMod(
97
- input: RouterInput['deleteSkillMod'],
98
- ctx: RouterContext
99
- ): Promise<RouterOutput['deleteSkillMod']> {
100
- if (!input) throw new Error('Input should not be void');
101
- console.log('Skill.Service.deleteSkillMod', input.query);
102
-
103
- const filter = getFilter(input.query);
104
- const deletedSkillMod = await ctx.app.model.SkillMod.findOneAndDelete(filter).lean().exec();
105
- if (!deletedSkillMod) throw new Error('SkillMod delete failed');
106
-
107
- return deletedSkillMod as SkillMod;
108
- }
109
-
110
- // SkillClassification Methods
111
- async getSkillClassification(
112
- input: RouterInput['getSkillClassification'],
113
- ctx: RouterContext
114
- ): Promise<RouterOutput['getSkillClassification']> {
115
- if (!input) throw new Error('Input should not be void');
116
- console.log('Skill.Service.getSkillClassification', input.query);
117
-
118
- const filter = getFilter(input.query);
119
- const skillClassification = await ctx.app.model.SkillClassification.findOne(filter).lean().exec();
120
- if (!skillClassification) throw new Error('SkillClassification not found');
121
-
122
- return skillClassification as SkillClassification;
123
- }
124
-
125
- async createSkillClassification(
126
- input: RouterInput['createSkillClassification'],
127
- ctx: RouterContext
128
- ): Promise<RouterOutput['createSkillClassification']> {
129
- if (!input) throw new Error('Input should not be void');
130
- console.log('Skill.Service.createSkillClassification', input.data);
131
-
132
- const skillClassification = await ctx.app.model.SkillClassification.create(input.data);
133
- return skillClassification as SkillClassification;
134
- }
135
-
136
- async updateSkillClassification(
137
- input: RouterInput['updateSkillClassification'],
138
- ctx: RouterContext
139
- ): Promise<RouterOutput['updateSkillClassification']> {
140
- if (!input) throw new Error('Input should not be void');
141
- console.log('Skill.Service.updateSkillClassification', input.query, input.data);
142
-
143
- const filter = getFilter(input.query);
144
- const updatedSkillClassification = await ctx.app.model.SkillClassification.findOneAndUpdate(filter, input.data, {
145
- new: true,
146
- })
147
- .lean()
148
- .exec();
149
- if (!updatedSkillClassification) throw new Error('SkillClassification update failed');
150
-
151
- return updatedSkillClassification as SkillClassification;
152
- }
153
-
154
- async deleteSkillClassification(
155
- input: RouterInput['deleteSkillClassification'],
156
- ctx: RouterContext
157
- ): Promise<RouterOutput['deleteSkillClassification']> {
158
- if (!input) throw new Error('Input should not be void');
159
- console.log('Skill.Service.deleteSkillClassification', input.query);
160
-
161
- const filter = getFilter(input.query);
162
- const deletedSkillClassification = await ctx.app.model.SkillClassification.findOneAndDelete(filter).lean().exec();
163
- if (!deletedSkillClassification) throw new Error('SkillClassification delete failed');
164
-
165
- return deletedSkillClassification as SkillClassification;
166
- }
167
-
168
- // SkillCondition Methods
169
- async getSkillCondition(
170
- input: RouterInput['getSkillCondition'],
171
- ctx: RouterContext
172
- ): Promise<RouterOutput['getSkillCondition']> {
173
- if (!input) throw new Error('Input should not be void');
174
- console.log('Skill.Service.getSkillCondition', input.query);
175
-
176
- const filter = getFilter(input.query);
177
- const skillCondition = await ctx.app.model.SkillCondition.findOne(filter).lean().exec();
178
- if (!skillCondition) throw new Error('SkillCondition not found');
179
-
180
- return skillCondition as SkillCondition;
181
- }
182
-
183
- async createSkillCondition(
184
- input: RouterInput['createSkillCondition'],
185
- ctx: RouterContext
186
- ): Promise<RouterOutput['createSkillCondition']> {
187
- if (!input) throw new Error('Input should not be void');
188
- console.log('Skill.Service.createSkillCondition', input.data);
189
-
190
- const skillCondition = await ctx.app.model.SkillCondition.create(input.data);
191
- return skillCondition as SkillCondition;
192
- }
193
-
194
- async updateSkillCondition(
195
- input: RouterInput['updateSkillCondition'],
196
- ctx: RouterContext
197
- ): Promise<RouterOutput['updateSkillCondition']> {
198
- if (!input) throw new Error('Input should not be void');
199
- console.log('Skill.Service.updateSkillCondition', input.query, input.data);
200
-
201
- const filter = getFilter(input.query);
202
- const updatedSkillCondition = await ctx.app.model.SkillCondition.findOneAndUpdate(filter, input.data, { new: true })
203
- .lean()
204
- .exec();
205
- if (!updatedSkillCondition) throw new Error('SkillCondition update failed');
206
-
207
- return updatedSkillCondition as SkillCondition;
208
- }
209
-
210
- async deleteSkillCondition(
211
- input: RouterInput['deleteSkillCondition'],
212
- ctx: RouterContext
213
- ): Promise<RouterOutput['deleteSkillCondition']> {
214
- if (!input) throw new Error('Input should not be void');
215
- console.log('Skill.Service.deleteSkillCondition', input.query);
216
-
217
- const filter = getFilter(input.query);
218
- const deletedSkillCondition = await ctx.app.model.SkillCondition.findOneAndDelete(filter).lean().exec();
219
- if (!deletedSkillCondition) throw new Error('SkillCondition delete failed');
220
-
221
- return deletedSkillCondition as SkillCondition;
222
- }
223
-
224
- // SkillStatusEffect Methods
225
- async getSkillStatusEffect(
226
- input: RouterInput['getSkillStatusEffect'],
227
- ctx: RouterContext
228
- ): Promise<RouterOutput['getSkillStatusEffect']> {
229
- if (!input) throw new Error('Input should not be void');
230
- console.log('Skill.Service.getSkillStatusEffect', input.query);
231
-
232
- const filter = getFilter(input.query);
233
- const skillStatusEffect = await ctx.app.model.SkillStatusEffect.findOne(filter).lean().exec();
234
- if (!skillStatusEffect) throw new Error('SkillStatusEffect not found');
235
-
236
- return skillStatusEffect as SkillStatusEffect;
237
- }
238
-
239
- async createSkillStatusEffect(
240
- input: RouterInput['createSkillStatusEffect'],
241
- ctx: RouterContext
242
- ): Promise<RouterOutput['createSkillStatusEffect']> {
243
- if (!input) throw new Error('Input should not be void');
244
- console.log('Skill.Service.createSkillStatusEffect', input.data);
245
-
246
- const skillStatusEffect = await ctx.app.model.SkillStatusEffect.create(input.data);
247
- return skillStatusEffect as SkillStatusEffect;
248
- }
249
-
250
- async updateSkillStatusEffect(
251
- input: RouterInput['updateSkillStatusEffect'],
252
- ctx: RouterContext
253
- ): Promise<RouterOutput['updateSkillStatusEffect']> {
254
- if (!input) throw new Error('Input should not be void');
255
- console.log('Skill.Service.updateSkillStatusEffect', input.query, input.data);
256
-
257
- const filter = getFilter(input.query);
258
- const updatedSkillStatusEffect = await ctx.app.model.SkillStatusEffect.findOneAndUpdate(filter, input.data, {
259
- new: true,
260
- })
261
- .lean()
262
- .exec();
263
- if (!updatedSkillStatusEffect) throw new Error('SkillStatusEffect update failed');
264
-
265
- return updatedSkillStatusEffect as SkillStatusEffect;
266
- }
267
-
268
- async deleteSkillStatusEffect(
269
- input: RouterInput['deleteSkillStatusEffect'],
270
- ctx: RouterContext
271
- ): Promise<RouterOutput['deleteSkillStatusEffect']> {
272
- if (!input) throw new Error('Input should not be void');
273
- console.log('Skill.Service.deleteSkillStatusEffect', input.query);
274
-
275
- const filter = getFilter(input.query);
276
- const deletedSkillStatusEffect = await ctx.app.model.SkillStatusEffect.findOneAndDelete(filter).lean().exec();
277
- if (!deletedSkillStatusEffect) throw new Error('SkillStatusEffect delete failed');
278
-
279
- return deletedSkillStatusEffect as SkillStatusEffect;
280
- }
281
-
282
- // SkillTree Methods
283
- async getSkillTree(input: RouterInput['getSkillTree'], ctx: RouterContext): Promise<RouterOutput['getSkillTree']> {
284
- if (!input) throw new Error('Input should not be void');
285
- console.log('Skill.Service.getSkillTree', input.query);
286
-
287
- const filter = getFilter(input.query);
288
- const skillTree = await ctx.app.model.SkillTree.findOne(filter).lean().exec();
289
- if (!skillTree) throw new Error('SkillTree not found');
290
-
291
- return skillTree as SkillTree;
292
- }
293
-
294
- async createSkillTree(
295
- input: RouterInput['createSkillTree'],
296
- ctx: RouterContext
297
- ): Promise<RouterOutput['createSkillTree']> {
298
- if (!input) throw new Error('Input should not be void');
299
- console.log('Skill.Service.createSkillTree', input.data);
300
-
301
- const skillTree = await ctx.app.model.SkillTree.create(input.data);
302
- return skillTree as SkillTree;
303
- }
304
-
305
- async updateSkillTree(
306
- input: RouterInput['updateSkillTree'],
307
- ctx: RouterContext
308
- ): Promise<RouterOutput['updateSkillTree']> {
309
- if (!input) throw new Error('Input should not be void');
310
- console.log('Skill.Service.updateSkillTree', input.query, input.data);
311
-
312
- const filter = getFilter(input.query);
313
- const updatedSkillTree = await ctx.app.model.SkillTree.findOneAndUpdate(filter, input.data, { new: true })
314
- .lean()
315
- .exec();
316
- if (!updatedSkillTree) throw new Error('SkillTree update failed');
317
-
318
- return updatedSkillTree as SkillTree;
319
- }
320
-
321
- async deleteSkillTree(
322
- input: RouterInput['deleteSkillTree'],
323
- ctx: RouterContext
324
- ): Promise<RouterOutput['deleteSkillTree']> {
325
- if (!input) throw new Error('Input should not be void');
326
- console.log('Skill.Service.deleteSkillTree', input.query);
327
-
328
- const filter = getFilter(input.query);
329
- const deletedSkillTree = await ctx.app.model.SkillTree.findOneAndDelete(filter).lean().exec();
330
- if (!deletedSkillTree) throw new Error('SkillTree delete failed');
331
-
332
- return deletedSkillTree as SkillTree;
333
- }
334
-
335
- // SkillTreeNode Methods
336
- async getSkillTreeNode(
337
- input: RouterInput['getSkillTreeNode'],
338
- ctx: RouterContext
339
- ): Promise<RouterOutput['getSkillTreeNode']> {
340
- if (!input) throw new Error('Input should not be void');
341
- console.log('Skill.Service.getSkillTreeNode', input.query);
342
-
343
- const filter = getFilter(input.query);
344
- const skillTreeNode = await ctx.app.model.SkillTreeNode.findOne(filter).lean().exec();
345
- if (!skillTreeNode) throw new Error('SkillTreeNode not found');
346
-
347
- return skillTreeNode as SkillTreeNode;
348
- }
349
-
350
- async createSkillTreeNode(
351
- input: RouterInput['createSkillTreeNode'],
352
- ctx: RouterContext
353
- ): Promise<RouterOutput['createSkillTreeNode']> {
354
- if (!input) throw new Error('Input should not be void');
355
- console.log('Skill.Service.createSkillTreeNode', input.data);
356
-
357
- const skillTreeNode = await ctx.app.model.SkillTreeNode.create(input.data);
358
- return skillTreeNode as SkillTreeNode;
359
- }
360
-
361
- async updateSkillTreeNode(
362
- input: RouterInput['updateSkillTreeNode'],
363
- ctx: RouterContext
364
- ): Promise<RouterOutput['updateSkillTreeNode']> {
365
- if (!input) throw new Error('Input should not be void');
366
- console.log('Skill.Service.updateSkillTreeNode', input.query, input.data);
367
-
368
- const filter = getFilter(input.query);
369
- const updatedSkillTreeNode = await ctx.app.model.SkillTreeNode.findOneAndUpdate(filter, input.data, { new: true })
370
- .lean()
371
- .exec();
372
- if (!updatedSkillTreeNode) throw new Error('SkillTreeNode update failed');
373
-
374
- return updatedSkillTreeNode as SkillTreeNode;
375
- }
376
-
377
- async deleteSkillTreeNode(
378
- input: RouterInput['deleteSkillTreeNode'],
379
- ctx: RouterContext
380
- ): Promise<RouterOutput['deleteSkillTreeNode']> {
381
- if (!input) throw new Error('Input should not be void');
382
- console.log('Skill.Service.deleteSkillTreeNode', input.query);
383
-
384
- const filter = getFilter(input.query);
385
- const deletedSkillTreeNode = await ctx.app.model.SkillTreeNode.findOneAndDelete(filter).lean().exec();
386
- if (!deletedSkillTreeNode) throw new Error('SkillTreeNode delete failed');
387
-
388
- return deletedSkillTreeNode as SkillTreeNode;
389
- }
390
- }
@@ -1,33 +0,0 @@
1
- import { z } from 'zod';
2
- import * as schema from './skill.schema';
3
- import { Document, Model } from '../../util/mongo';
4
-
5
- export type * from './skill.router';
6
- export type * from './skill.service';
7
- export type { RouterContext } from '../../types';
8
-
9
- export type Skill = z.infer<typeof schema.Skill>;
10
- export type SkillMod = z.infer<typeof schema.SkillMod>;
11
- export type SkillClassification = z.infer<typeof schema.SkillClassification>;
12
- export type SkillCondition = z.infer<typeof schema.SkillCondition>;
13
- export type SkillStatusEffect = z.infer<typeof schema.SkillStatusEffect>;
14
- export type SkillTree = z.infer<typeof schema.SkillTree>;
15
- export type SkillTreeNode = z.infer<typeof schema.SkillTreeNode>;
16
-
17
- export type SkillDocument = Skill & Document;
18
- export type SkillModDocument = SkillMod & Document;
19
- export type SkillClassificationDocument = SkillClassification & Document;
20
- export type SkillConditionDocument = SkillCondition & Document;
21
- export type SkillStatusEffectDocument = SkillStatusEffect & Document;
22
- export type SkillTreeDocument = SkillTree & Document;
23
- export type SkillTreeNodeDocument = SkillTreeNode & Document;
24
-
25
- export type Mappings = {
26
- Skill: Model<SkillDocument>;
27
- SkillMod: Model<SkillModDocument>;
28
- SkillClassification: Model<SkillClassificationDocument>;
29
- SkillCondition: Model<SkillConditionDocument>;
30
- SkillStatusEffect: Model<SkillStatusEffectDocument>;
31
- SkillTree: Model<SkillTreeDocument>;
32
- SkillTreeNode: Model<SkillTreeNodeDocument>;
33
- };
@@ -1,5 +0,0 @@
1
- export * as Types from './video.types';
2
- export * as Models from './video.models';
3
- export * as Schemas from './video.schema';
4
- export * from './video.router';
5
- export * from './video.service';
@@ -1,25 +0,0 @@
1
- import * as mongo from '../../util/mongo';
2
- import type * as Types from './video.types';
3
-
4
- export const Video = mongo.createModel<Types.VideoDocument>('Video', {
5
- youtubeId: { type: String, unique: true, required: true },
6
- url: { type: String, required: true },
7
- });
8
-
9
- export const VideoParticipant = mongo.createModel<Types.VideoParticipantDocument>('VideoParticipant', {
10
- profileId: { type: mongo.Schema.Types.ObjectId, ref: 'Profile', required: true },
11
- });
12
-
13
- export const VideoDialogue = mongo.createModel<Types.VideoDialogueDocument>('VideoDialogue', {
14
- participantId: { type: mongo.Schema.Types.ObjectId, ref: 'VideoParticipant', required: true },
15
- text: { type: String, required: true },
16
- timestamp: { type: String, required: true },
17
- });
18
-
19
- export const VideoTranscript = mongo.createModel<Types.VideoTranscriptDocument>('VideoTranscript', {
20
- videoId: { type: mongo.Schema.Types.ObjectId, ref: 'Video', required: true },
21
- // transcript: { type: [mongo.Schema.Types.Mixed], required: true },
22
- summary: { type: String, optional: true },
23
- });
24
-
25
- export const VideoScene = mongo.createModel<Types.VideoSceneDocument>('VideoScene', {});
@@ -1,143 +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 { Video, VideoParticipant, VideoDialogue, VideoTranscript, VideoScene } from './video.schema';
6
- import { Query } from '../../schema'; // Assuming the Query schema is located in '../../schema'
7
-
8
- export const z = zod;
9
- export const t = initTRPC.context<RouterContext>().create();
10
- export const router = t.router;
11
- export const procedure = t.procedure;
12
-
13
- export const createRouter = () =>
14
- router({
15
- // Video endpoints
16
- getVideo: procedure
17
- .use(hasRole('guest', t))
18
- .use(customErrorFormatter(t))
19
- .input(z.object({ query: Query }))
20
- .query(({ input, ctx }) => (ctx.app.service.Video.getVideo as any)(input, ctx)),
21
-
22
- createVideo: procedure
23
- .use(hasRole('admin', t))
24
- .use(customErrorFormatter(t))
25
- .input(z.object({ data: Video.omit({ id: true }) }))
26
- .mutation(({ input, ctx }) => (ctx.app.service.Video.createVideo as any)(input, ctx)),
27
-
28
- updateVideo: procedure
29
- .use(hasRole('admin', t))
30
- .use(customErrorFormatter(t))
31
- .input(z.object({ query: Query, data: Video.partial() }))
32
- .mutation(({ input, ctx }) => (ctx.app.service.Video.updateVideo as any)(input, ctx)),
33
-
34
- deleteVideo: procedure
35
- .use(hasRole('admin', t))
36
- .use(customErrorFormatter(t))
37
- .input(z.object({ query: Query }))
38
- .mutation(({ input, ctx }) => (ctx.app.service.Video.deleteVideo as any)(input, ctx)),
39
-
40
- // Video Participant endpoints
41
- getVideoParticipant: procedure
42
- .use(hasRole('guest', t))
43
- .use(customErrorFormatter(t))
44
- .input(z.object({ query: Query }))
45
- .query(({ input, ctx }) => (ctx.app.service.Video.getVideoParticipant as any)(input, ctx)),
46
-
47
- createVideoParticipant: procedure
48
- .use(hasRole('admin', t))
49
- .use(customErrorFormatter(t))
50
- .input(z.object({ data: VideoParticipant.omit({ id: true }) }))
51
- .mutation(({ input, ctx }) => (ctx.app.service.Video.createVideoParticipant as any)(input, ctx)),
52
-
53
- updateVideoParticipant: procedure
54
- .use(hasRole('admin', t))
55
- .use(customErrorFormatter(t))
56
- .input(z.object({ query: Query, data: VideoParticipant.partial() }))
57
- .mutation(({ input, ctx }) => (ctx.app.service.Video.updateVideoParticipant as any)(input, ctx)),
58
-
59
- deleteVideoParticipant: procedure
60
- .use(hasRole('admin', t))
61
- .use(customErrorFormatter(t))
62
- .input(z.object({ query: Query }))
63
- .mutation(({ input, ctx }) => (ctx.app.service.Video.deleteVideoParticipant as any)(input, ctx)),
64
-
65
- // Video Dialogue endpoints
66
- getVideoDialogue: procedure
67
- .use(hasRole('guest', t))
68
- .use(customErrorFormatter(t))
69
- .input(z.object({ query: Query }))
70
- .query(({ input, ctx }) => (ctx.app.service.Video.getVideoDialogue as any)(input, ctx)),
71
-
72
- createVideoDialogue: procedure
73
- .use(hasRole('admin', t))
74
- .use(customErrorFormatter(t))
75
- .input(z.object({ data: VideoDialogue.omit({ id: true }) }))
76
- .mutation(({ input, ctx }) => (ctx.app.service.Video.createVideoDialogue as any)(input, ctx)),
77
-
78
- updateVideoDialogue: procedure
79
- .use(hasRole('admin', t))
80
- .use(customErrorFormatter(t))
81
- .input(z.object({ query: Query, data: VideoDialogue.partial() }))
82
- .mutation(({ input, ctx }) => (ctx.app.service.Video.updateVideoDialogue as any)(input, ctx)),
83
-
84
- deleteVideoDialogue: procedure
85
- .use(hasRole('admin', t))
86
- .use(customErrorFormatter(t))
87
- .input(z.object({ query: Query }))
88
- .mutation(({ input, ctx }) => (ctx.app.service.Video.deleteVideoDialogue as any)(input, ctx)),
89
-
90
- // Video Transcript endpoints
91
- getVideoTranscript: procedure
92
- .use(hasRole('guest', t))
93
- .use(customErrorFormatter(t))
94
- .input(z.object({ query: Query }))
95
- .query(({ input, ctx }) => (ctx.app.service.Video.getVideoTranscript as any)(input, ctx)),
96
-
97
- createVideoTranscript: procedure
98
- .use(hasRole('admin', t))
99
- .use(customErrorFormatter(t))
100
- .input(z.object({ data: VideoTranscript.omit({ id: true }) }))
101
- .mutation(({ input, ctx }) => (ctx.app.service.Video.createVideoTranscript as any)(input, ctx)),
102
-
103
- updateVideoTranscript: procedure
104
- .use(hasRole('admin', t))
105
- .use(customErrorFormatter(t))
106
- .input(z.object({ query: Query, data: VideoTranscript.partial() }))
107
- .mutation(({ input, ctx }) => (ctx.app.service.Video.updateVideoTranscript as any)(input, ctx)),
108
-
109
- deleteVideoTranscript: procedure
110
- .use(hasRole('admin', t))
111
- .use(customErrorFormatter(t))
112
- .input(z.object({ query: Query }))
113
- .mutation(({ input, ctx }) => (ctx.app.service.Video.deleteVideoTranscript as any)(input, ctx)),
114
-
115
- // Video Scene endpoints
116
- getVideoScene: procedure
117
- .use(hasRole('guest', t))
118
- .use(customErrorFormatter(t))
119
- .input(z.object({ query: Query }))
120
- .query(({ input, ctx }) => (ctx.app.service.Video.getVideoScene as any)(input, ctx)),
121
-
122
- createVideoScene: procedure
123
- .use(hasRole('admin', t))
124
- .use(customErrorFormatter(t))
125
- .input(z.object({ data: VideoScene.omit({ id: true }) }))
126
- .mutation(({ input, ctx }) => (ctx.app.service.Video.createVideoScene as any)(input, ctx)),
127
-
128
- updateVideoScene: procedure
129
- .use(hasRole('admin', t))
130
- .use(customErrorFormatter(t))
131
- .input(z.object({ query: Query, data: VideoScene.partial() }))
132
- .mutation(({ input, ctx }) => (ctx.app.service.Video.updateVideoScene as any)(input, ctx)),
133
-
134
- deleteVideoScene: procedure
135
- .use(hasRole('admin', t))
136
- .use(customErrorFormatter(t))
137
- .input(z.object({ query: Query }))
138
- .mutation(({ input, ctx }) => (ctx.app.service.Video.deleteVideoScene as any)(input, ctx)),
139
- });
140
-
141
- export type Router = ReturnType<typeof createRouter>;
142
- export type RouterInput = inferRouterInputs<Router>;
143
- export type RouterOutput = inferRouterOutputs<Router>;
@@ -1,46 +0,0 @@
1
- import { z, ObjectId, Entity } from '../../schema';
2
-
3
- export const Video = Entity.merge(
4
- z.object({
5
- youtubeId: z.string().min(1),
6
- url: z.string().url(),
7
- title: z.string().min(1),
8
- description: z.string().optional(),
9
- duration: z.number().min(0).optional(),
10
- // publishedAt: z.date().optional(),
11
- })
12
- );
13
-
14
- export const VideoParticipant = Entity.merge(
15
- z.object({
16
- videoId: ObjectId, // Reference to the associated Video
17
- profileId: ObjectId.optional(), // Reference to a participant profile
18
- role: z.enum(['Host', 'Contributor', 'Guest']).optional(),
19
- })
20
- );
21
-
22
- export const VideoDialogue = Entity.merge(
23
- z.object({
24
- videoId: ObjectId, // Reference to the associated Video
25
- participantId: ObjectId, // Reference to the VideoParticipant
26
- text: z.string().min(1),
27
- timestamp: z.string().regex(/^\d{2}:\d{2}:\d{2}$/), // Format HH:MM:SS
28
- })
29
- );
30
-
31
- export const VideoTranscript = Entity.merge(
32
- z.object({
33
- videoId: ObjectId, // Reference to the associated Video
34
- transcript: z.array(VideoDialogue), // Array of dialogues
35
- summary: z.string().optional(),
36
- })
37
- );
38
-
39
- export const VideoScene = Entity.merge(
40
- z.object({
41
- videoId: ObjectId, // Reference to the associated Video
42
- startTime: z.string().regex(/^\d{2}:\d{2}:\d{2}$/), // Format HH:MM:SS
43
- endTime: z.string().regex(/^\d{2}:\d{2}:\d{2}$/), // Format HH:MM:SS
44
- description: z.string().optional(),
45
- })
46
- );