@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.
- package/db.ts +76 -1
- package/index.ts +351 -18
- package/package.json +3 -3
- package/tsconfig.json +33 -2
- package/util.ts +1 -0
- package/modules/area/area.models.ts +0 -15
- package/modules/area/area.router.ts +0 -74
- package/modules/area/area.schema.ts +0 -22
- package/modules/area/area.service.ts +0 -124
- package/modules/area/area.types.ts +0 -26
- package/modules/area/index.ts +0 -5
- package/modules/asset/asset.models.ts +0 -59
- package/modules/asset/asset.router.ts +0 -55
- package/modules/asset/asset.schema.ts +0 -27
- package/modules/asset/asset.service.ts +0 -85
- package/modules/asset/asset.types.ts +0 -22
- package/modules/asset/index.ts +0 -5
- package/modules/chain/chain.models.ts +0 -50
- package/modules/chain/chain.router.ts +0 -104
- package/modules/chain/chain.schema.ts +0 -52
- package/modules/chain/chain.service.ts +0 -167
- package/modules/chain/chain.types.ts +0 -24
- package/modules/chain/index.ts +0 -5
- package/modules/character/character.models.ts +0 -174
- package/modules/character/character.router.ts +0 -314
- package/modules/character/character.schema.ts +0 -147
- package/modules/character/character.service.ts +0 -876
- package/modules/character/character.types.ts +0 -64
- package/modules/character/index.ts +0 -5
- package/modules/chat/chat.models.ts +0 -43
- package/modules/chat/chat.router.ts +0 -67
- package/modules/chat/chat.schema.ts +0 -36
- package/modules/chat/chat.service.ts +0 -128
- package/modules/chat/chat.types.ts +0 -20
- package/modules/chat/index.ts +0 -5
- package/modules/collection/collection.models.ts +0 -76
- package/modules/collection/collection.router.ts +0 -91
- package/modules/collection/collection.schema.ts +0 -90
- package/modules/collection/collection.service.ts +0 -192
- package/modules/collection/collection.types.ts +0 -36
- package/modules/collection/index.ts +0 -5
- package/modules/core/core.models.ts +0 -1380
- package/modules/core/core.router.ts +0 -1781
- package/modules/core/core.schema.ts +0 -847
- package/modules/core/core.service.ts +0 -2824
- package/modules/core/core.types.ts +0 -340
- package/modules/core/index.ts +0 -5
- package/modules/core/mail/applyPatchesOrMail.ts +0 -568
- package/modules/core/mail/mailClaimablePatchesBatch.ts +0 -381
- package/modules/game/game.models.ts +0 -53
- package/modules/game/game.router.ts +0 -110
- package/modules/game/game.schema.ts +0 -23
- package/modules/game/game.service.ts +0 -143
- package/modules/game/game.types.ts +0 -28
- package/modules/game/index.ts +0 -5
- package/modules/interface/index.ts +0 -5
- package/modules/interface/interface.canonicalize.ts +0 -279
- package/modules/interface/interface.models.ts +0 -40
- package/modules/interface/interface.router.ts +0 -175
- package/modules/interface/interface.schema.ts +0 -59
- package/modules/interface/interface.service.ts +0 -356
- package/modules/interface/interface.types.ts +0 -25
- package/modules/item/index.ts +0 -5
- package/modules/item/item.models.ts +0 -124
- package/modules/item/item.router.ts +0 -103
- package/modules/item/item.schema.ts +0 -120
- package/modules/item/item.service.ts +0 -167
- package/modules/item/item.types.ts +0 -74
- package/modules/job/index.ts +0 -5
- package/modules/job/job.models.ts +0 -14
- package/modules/job/job.router.ts +0 -44
- package/modules/job/job.schema.ts +0 -9
- package/modules/job/job.service.ts +0 -243
- package/modules/job/job.types.ts +0 -23
- package/modules/market/index.ts +0 -5
- package/modules/market/market.models.ts +0 -113
- package/modules/market/market.router.ts +0 -73
- package/modules/market/market.schema.ts +0 -140
- package/modules/market/market.service.ts +0 -122
- package/modules/market/market.types.ts +0 -56
- package/modules/product/index.ts +0 -5
- package/modules/product/product.models.ts +0 -166
- package/modules/product/product.router.ts +0 -93
- package/modules/product/product.schema.ts +0 -149
- package/modules/product/product.service.ts +0 -160
- package/modules/product/product.types.ts +0 -33
- package/modules/profile/index.ts +0 -5
- package/modules/profile/profile.models.ts +0 -214
- package/modules/profile/profile.router.ts +0 -72
- package/modules/profile/profile.schema.ts +0 -156
- package/modules/profile/profile.service.ts +0 -149
- package/modules/profile/profile.types.ts +0 -22
- package/modules/raffle/index.ts +0 -5
- package/modules/raffle/raffle.models.ts +0 -44
- package/modules/raffle/raffle.router.ts +0 -90
- package/modules/raffle/raffle.schema.ts +0 -32
- package/modules/raffle/raffle.service.ts +0 -167
- package/modules/raffle/raffle.types.ts +0 -30
- package/modules/skill/index.ts +0 -5
- package/modules/skill/skill.models.ts +0 -16
- package/modules/skill/skill.router.ts +0 -201
- package/modules/skill/skill.schema.ts +0 -40
- package/modules/skill/skill.service.ts +0 -390
- package/modules/skill/skill.types.ts +0 -33
- package/modules/video/index.ts +0 -5
- package/modules/video/video.models.ts +0 -25
- package/modules/video/video.router.ts +0 -143
- package/modules/video/video.schema.ts +0 -46
- package/modules/video/video.service.ts +0 -274
- package/modules/video/video.types.ts +0 -33
- package/util/db/index.ts +0 -7
- package/util/db/isPostgresError.ts +0 -9
- package/util/db/isUniqueConstraintViolation.ts +0 -3
- package/util/db.ts +0 -62
- package/util/index.ts +0 -351
- /package/{util/api.ts → api.ts} +0 -0
- /package/{util/array.ts → array.ts} +0 -0
- /package/{util/browser.ts → browser.ts} +0 -0
- /package/{util/codebase.ts → codebase.ts} +0 -0
- /package/{util/config.ts → config.ts} +0 -0
- /package/{util/decoder.test.ts → decoder.test.ts} +0 -0
- /package/{util/decoder.ts → decoder.ts} +0 -0
- /package/{util/format.ts → format.ts} +0 -0
- /package/{util/guid.ts → guid.ts} +0 -0
- /package/{util/json.ts → json.ts} +0 -0
- /package/{util/log.ts → log.ts} +0 -0
- /package/{util/math.ts → math.ts} +0 -0
- /package/{util/merkle.ts → merkle.ts} +0 -0
- /package/{util/mongo.ts → mongo.ts} +0 -0
- /package/{util/number.ts → number.ts} +0 -0
- /package/{util/object.ts → object.ts} +0 -0
- /package/{util/otp.ts → otp.ts} +0 -0
- /package/{util/physics.ts → physics.ts} +0 -0
- /package/{util/process.ts → process.ts} +0 -0
- /package/{util/rpc.ts → rpc.ts} +0 -0
- /package/{util/seer.ts → seer.ts} +0 -0
- /package/{util/string.ts → string.ts} +0 -0
- /package/{util/text.ts → text.ts} +0 -0
- /package/{util/time → time}/date.ts +0 -0
- /package/{util/time → time}/fancyTimeFormat.ts +0 -0
- /package/{util/time → time}/index.ts +0 -0
- /package/{util/time → time}/now.ts +0 -0
- /package/{util/types → types}/mongo.d.ts +0 -0
- /package/{util/web3 → web3}/httpProvider.ts +0 -0
- /package/{util/web3.ts → web3.ts} +0 -0
- /package/{util/websocket.ts → websocket.ts} +0 -0
- /package/{util/zk.ts → zk.ts} +0 -0
- /package/{util/zod.ts → zod.ts} +0 -0
|
@@ -1,274 +0,0 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
Video,
|
|
3
|
-
VideoParticipant,
|
|
4
|
-
VideoDialogue,
|
|
5
|
-
VideoTranscript,
|
|
6
|
-
VideoScene,
|
|
7
|
-
RouterContext,
|
|
8
|
-
Router,
|
|
9
|
-
RouterInput,
|
|
10
|
-
RouterOutput,
|
|
11
|
-
} from './video.types';
|
|
12
|
-
import { getFilter } from '../../util/api';
|
|
13
|
-
|
|
14
|
-
export class Service {
|
|
15
|
-
async getVideo(input: RouterInput['getVideo'], ctx: RouterContext): Promise<RouterOutput['getVideo']> {
|
|
16
|
-
if (!input) throw new Error('Input should not be void');
|
|
17
|
-
console.log('Video.Service.getVideo', input.query);
|
|
18
|
-
|
|
19
|
-
const filter = getFilter(input.query);
|
|
20
|
-
const video = await ctx.app.model.Video.findOne(filter).lean().exec();
|
|
21
|
-
if (!video) throw new Error('Video not found');
|
|
22
|
-
|
|
23
|
-
return video as Video;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
async createVideo(input: RouterInput['createVideo'], ctx: RouterContext): Promise<RouterOutput['createVideo']> {
|
|
27
|
-
if (!input) throw new Error('Input should not be void');
|
|
28
|
-
console.log('Video.Service.createVideo', input.data);
|
|
29
|
-
|
|
30
|
-
const video = await ctx.app.model.Video.create(input.data);
|
|
31
|
-
return video as Video;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
async updateVideo(input: RouterInput['updateVideo'], ctx: RouterContext): Promise<RouterOutput['updateVideo']> {
|
|
35
|
-
if (!input) throw new Error('Input should not be void');
|
|
36
|
-
console.log('Video.Service.updateVideo', input.query, input.data);
|
|
37
|
-
|
|
38
|
-
const filter = getFilter(input.query);
|
|
39
|
-
const updatedVideo = await ctx.app.model.Video.findOneAndUpdate(filter, input.data, { new: true }).lean().exec();
|
|
40
|
-
if (!updatedVideo) throw new Error('Video update failed');
|
|
41
|
-
|
|
42
|
-
return updatedVideo as Video;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
async deleteVideo(input: RouterInput['deleteVideo'], ctx: RouterContext): Promise<RouterOutput['deleteVideo']> {
|
|
46
|
-
if (!input) throw new Error('Input should not be void');
|
|
47
|
-
console.log('Video.Service.deleteVideo', input.query);
|
|
48
|
-
|
|
49
|
-
const filter = getFilter(input.query);
|
|
50
|
-
const video = await ctx.app.model.Video.findOneAndDelete(filter).lean().exec();
|
|
51
|
-
if (!video) throw new Error('Video not found');
|
|
52
|
-
|
|
53
|
-
return video as Video;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
// Similar changes for VideoParticipant, VideoDialogue, VideoTranscript, VideoScene...
|
|
57
|
-
|
|
58
|
-
async getVideoParticipant(
|
|
59
|
-
input: RouterInput['getVideoParticipant'],
|
|
60
|
-
ctx: RouterContext
|
|
61
|
-
): Promise<RouterOutput['getVideoParticipant']> {
|
|
62
|
-
if (!input) throw new Error('Input should not be void');
|
|
63
|
-
console.log('Video.Service.getVideoParticipant', input.query);
|
|
64
|
-
|
|
65
|
-
const filter = getFilter(input.query);
|
|
66
|
-
const participant = await ctx.app.model.VideoParticipant.findOne(filter).lean().exec();
|
|
67
|
-
if (!participant) throw new Error('VideoParticipant not found');
|
|
68
|
-
|
|
69
|
-
return participant as VideoParticipant;
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
async createVideoParticipant(
|
|
73
|
-
input: RouterInput['createVideoParticipant'],
|
|
74
|
-
ctx: RouterContext
|
|
75
|
-
): Promise<RouterOutput['createVideoParticipant']> {
|
|
76
|
-
if (!input) throw new Error('Input should not be void');
|
|
77
|
-
console.log('Video.Service.createVideoParticipant', input.data);
|
|
78
|
-
|
|
79
|
-
const participant = await ctx.app.model.VideoParticipant.create(input.data);
|
|
80
|
-
return participant as VideoParticipant;
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
async updateVideoParticipant(
|
|
84
|
-
input: RouterInput['updateVideoParticipant'],
|
|
85
|
-
ctx: RouterContext
|
|
86
|
-
): Promise<RouterOutput['updateVideoParticipant']> {
|
|
87
|
-
if (!input) throw new Error('Input should not be void');
|
|
88
|
-
console.log('Video.Service.updateVideoParticipant', input.query, input.data);
|
|
89
|
-
|
|
90
|
-
const filter = getFilter(input.query);
|
|
91
|
-
const updatedParticipant = await ctx.app.model.VideoParticipant.findOneAndUpdate(filter, input.data, { new: true })
|
|
92
|
-
.lean()
|
|
93
|
-
.exec();
|
|
94
|
-
if (!updatedParticipant) throw new Error('VideoParticipant update failed');
|
|
95
|
-
|
|
96
|
-
return updatedParticipant as VideoParticipant;
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
async deleteVideoParticipant(
|
|
100
|
-
input: RouterInput['deleteVideoParticipant'],
|
|
101
|
-
ctx: RouterContext
|
|
102
|
-
): Promise<RouterOutput['deleteVideoParticipant']> {
|
|
103
|
-
if (!input) throw new Error('Input should not be void');
|
|
104
|
-
console.log('Video.Service.deleteVideoParticipant', input.query);
|
|
105
|
-
|
|
106
|
-
const filter = getFilter(input.query);
|
|
107
|
-
const participant = await ctx.app.model.VideoParticipant.findOneAndDelete(filter).lean().exec();
|
|
108
|
-
if (!participant) throw new Error('VideoParticipant not found');
|
|
109
|
-
|
|
110
|
-
return participant as VideoParticipant;
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
async getVideoDialogue(
|
|
114
|
-
input: RouterInput['getVideoDialogue'],
|
|
115
|
-
ctx: RouterContext
|
|
116
|
-
): Promise<RouterOutput['getVideoDialogue']> {
|
|
117
|
-
if (!input) throw new Error('Input should not be void');
|
|
118
|
-
console.log('Video.Service.getVideoDialogue', input.query);
|
|
119
|
-
|
|
120
|
-
const filter = getFilter(input.query);
|
|
121
|
-
const dialogue = await ctx.app.model.VideoDialogue.findOne(filter).lean().exec();
|
|
122
|
-
if (!dialogue) throw new Error('VideoDialogue not found');
|
|
123
|
-
|
|
124
|
-
return dialogue as VideoDialogue;
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
async createVideoDialogue(
|
|
128
|
-
input: RouterInput['createVideoDialogue'],
|
|
129
|
-
ctx: RouterContext
|
|
130
|
-
): Promise<RouterOutput['createVideoDialogue']> {
|
|
131
|
-
if (!input) throw new Error('Input should not be void');
|
|
132
|
-
console.log('Video.Service.createVideoDialogue', input.data);
|
|
133
|
-
|
|
134
|
-
const dialogue = await ctx.app.model.VideoDialogue.create(input.data);
|
|
135
|
-
return dialogue as VideoDialogue;
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
async updateVideoDialogue(
|
|
139
|
-
input: RouterInput['updateVideoDialogue'],
|
|
140
|
-
ctx: RouterContext
|
|
141
|
-
): Promise<RouterOutput['updateVideoDialogue']> {
|
|
142
|
-
if (!input) throw new Error('Input should not be void');
|
|
143
|
-
console.log('Video.Service.updateVideoDialogue', input.query, input.data);
|
|
144
|
-
|
|
145
|
-
const filter = getFilter(input.query);
|
|
146
|
-
const updatedDialogue = await ctx.app.model.VideoDialogue.findOneAndUpdate(filter, input.data, { new: true })
|
|
147
|
-
.lean()
|
|
148
|
-
.exec();
|
|
149
|
-
if (!updatedDialogue) throw new Error('VideoDialogue update failed');
|
|
150
|
-
|
|
151
|
-
return updatedDialogue as VideoDialogue;
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
async deleteVideoDialogue(
|
|
155
|
-
input: RouterInput['deleteVideoDialogue'],
|
|
156
|
-
ctx: RouterContext
|
|
157
|
-
): Promise<RouterOutput['deleteVideoDialogue']> {
|
|
158
|
-
if (!input) throw new Error('Input should not be void');
|
|
159
|
-
console.log('Video.Service.deleteVideoDialogue', input.query);
|
|
160
|
-
|
|
161
|
-
const filter = getFilter(input.query);
|
|
162
|
-
const dialogue = await ctx.app.model.VideoDialogue.findOneAndDelete(filter).lean().exec();
|
|
163
|
-
if (!dialogue) throw new Error('VideoDialogue not found');
|
|
164
|
-
|
|
165
|
-
return dialogue as VideoDialogue;
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
async getVideoTranscript(
|
|
169
|
-
input: RouterInput['getVideoTranscript'],
|
|
170
|
-
ctx: RouterContext
|
|
171
|
-
): Promise<RouterOutput['getVideoTranscript']> {
|
|
172
|
-
if (!input) throw new Error('Input should not be void');
|
|
173
|
-
console.log('Video.Service.getVideoTranscript', input.query);
|
|
174
|
-
|
|
175
|
-
const filter = getFilter(input.query);
|
|
176
|
-
const transcript = await ctx.app.model.VideoTranscript.findOne(filter).lean().exec();
|
|
177
|
-
if (!transcript) throw new Error('VideoTranscript not found');
|
|
178
|
-
|
|
179
|
-
return transcript as VideoTranscript;
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
async createVideoTranscript(
|
|
183
|
-
input: RouterInput['createVideoTranscript'],
|
|
184
|
-
ctx: RouterContext
|
|
185
|
-
): Promise<RouterOutput['createVideoTranscript']> {
|
|
186
|
-
if (!input) throw new Error('Input should not be void');
|
|
187
|
-
console.log('Video.Service.createVideoTranscript', input.data);
|
|
188
|
-
|
|
189
|
-
const transcript = await ctx.app.model.VideoTranscript.create(input.data);
|
|
190
|
-
return transcript as VideoTranscript;
|
|
191
|
-
}
|
|
192
|
-
|
|
193
|
-
async updateVideoTranscript(
|
|
194
|
-
input: RouterInput['updateVideoTranscript'],
|
|
195
|
-
ctx: RouterContext
|
|
196
|
-
): Promise<RouterOutput['updateVideoTranscript']> {
|
|
197
|
-
if (!input) throw new Error('Input should not be void');
|
|
198
|
-
console.log('Video.Service.updateVideoTranscript', input.query, input.data);
|
|
199
|
-
|
|
200
|
-
const filter = getFilter(input.query);
|
|
201
|
-
const updatedTranscript = await ctx.app.model.VideoTranscript.findOneAndUpdate(filter, input.data, { new: true })
|
|
202
|
-
.lean()
|
|
203
|
-
.exec();
|
|
204
|
-
if (!updatedTranscript) throw new Error('VideoTranscript update failed');
|
|
205
|
-
|
|
206
|
-
return updatedTranscript as VideoTranscript;
|
|
207
|
-
}
|
|
208
|
-
|
|
209
|
-
async deleteVideoTranscript(
|
|
210
|
-
input: RouterInput['deleteVideoTranscript'],
|
|
211
|
-
ctx: RouterContext
|
|
212
|
-
): Promise<RouterOutput['deleteVideoTranscript']> {
|
|
213
|
-
if (!input) throw new Error('Input should not be void');
|
|
214
|
-
console.log('Video.Service.deleteVideoTranscript', input.query);
|
|
215
|
-
|
|
216
|
-
const filter = getFilter(input.query);
|
|
217
|
-
const transcript = await ctx.app.model.VideoTranscript.findOneAndDelete(filter).lean().exec();
|
|
218
|
-
if (!transcript) throw new Error('VideoTranscript not found');
|
|
219
|
-
|
|
220
|
-
return transcript as VideoTranscript;
|
|
221
|
-
}
|
|
222
|
-
|
|
223
|
-
async getVideoScene(input: RouterInput['getVideoScene'], ctx: RouterContext): Promise<RouterOutput['getVideoScene']> {
|
|
224
|
-
if (!input) throw new Error('Input should not be void');
|
|
225
|
-
console.log('Video.Service.getVideoScene', input.query);
|
|
226
|
-
|
|
227
|
-
const filter = getFilter(input.query);
|
|
228
|
-
const scene = await ctx.app.model.VideoScene.findOne(filter).lean().exec();
|
|
229
|
-
if (!scene) throw new Error('VideoScene not found');
|
|
230
|
-
|
|
231
|
-
return scene as VideoScene;
|
|
232
|
-
}
|
|
233
|
-
|
|
234
|
-
async createVideoScene(
|
|
235
|
-
input: RouterInput['createVideoScene'],
|
|
236
|
-
ctx: RouterContext
|
|
237
|
-
): Promise<RouterOutput['createVideoScene']> {
|
|
238
|
-
if (!input) throw new Error('Input should not be void');
|
|
239
|
-
console.log('Video.Service.createVideoScene', input.data);
|
|
240
|
-
|
|
241
|
-
const scene = await ctx.app.model.VideoScene.create(input.data);
|
|
242
|
-
return scene as VideoScene;
|
|
243
|
-
}
|
|
244
|
-
|
|
245
|
-
async updateVideoScene(
|
|
246
|
-
input: RouterInput['updateVideoScene'],
|
|
247
|
-
ctx: RouterContext
|
|
248
|
-
): Promise<RouterOutput['updateVideoScene']> {
|
|
249
|
-
if (!input) throw new Error('Input should not be void');
|
|
250
|
-
console.log('Video.Service.updateVideoScene', input.query, input.data);
|
|
251
|
-
|
|
252
|
-
const filter = getFilter(input.query);
|
|
253
|
-
const updatedScene = await ctx.app.model.VideoScene.findOneAndUpdate(filter, input.data, { new: true })
|
|
254
|
-
.lean()
|
|
255
|
-
.exec();
|
|
256
|
-
if (!updatedScene) throw new Error('VideoScene update failed');
|
|
257
|
-
|
|
258
|
-
return updatedScene as VideoScene;
|
|
259
|
-
}
|
|
260
|
-
|
|
261
|
-
async deleteVideoScene(
|
|
262
|
-
input: RouterInput['deleteVideoScene'],
|
|
263
|
-
ctx: RouterContext
|
|
264
|
-
): Promise<RouterOutput['deleteVideoScene']> {
|
|
265
|
-
if (!input) throw new Error('Input should not be void');
|
|
266
|
-
console.log('Video.Service.deleteVideoScene', input.query);
|
|
267
|
-
|
|
268
|
-
const filter = getFilter(input.query);
|
|
269
|
-
const scene = await ctx.app.model.VideoScene.findOneAndDelete(filter).lean().exec();
|
|
270
|
-
if (!scene) throw new Error('VideoScene not found');
|
|
271
|
-
|
|
272
|
-
return scene as VideoScene;
|
|
273
|
-
}
|
|
274
|
-
}
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import { z } from 'zod';
|
|
2
|
-
import * as schema from './video.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 './video.router';
|
|
7
|
-
|
|
8
|
-
export type * from './video.router';
|
|
9
|
-
export type * from './video.service';
|
|
10
|
-
export type { RouterContext };
|
|
11
|
-
|
|
12
|
-
export type Video = z.infer<typeof schema.Video>;
|
|
13
|
-
export type VideoParticipant = z.infer<typeof schema.VideoParticipant>;
|
|
14
|
-
export type VideoDialogue = z.infer<typeof schema.VideoDialogue>;
|
|
15
|
-
export type VideoTranscript = z.infer<typeof schema.VideoTranscript>;
|
|
16
|
-
export type VideoScene = z.infer<typeof schema.VideoScene>;
|
|
17
|
-
|
|
18
|
-
export type VideoDocument = Video & Document;
|
|
19
|
-
export type VideoParticipantDocument = VideoParticipant & Document;
|
|
20
|
-
export type VideoDialogueDocument = VideoDialogue & Document;
|
|
21
|
-
export type VideoTranscriptDocument = VideoTranscript & Document;
|
|
22
|
-
export type VideoSceneDocument = VideoScene & Document;
|
|
23
|
-
|
|
24
|
-
export type Mappings = {
|
|
25
|
-
Video: Model<VideoDocument>;
|
|
26
|
-
VideoParticipant: Model<VideoParticipantDocument>;
|
|
27
|
-
VideoDialogue: Model<VideoDialogueDocument>;
|
|
28
|
-
VideoTranscript: Model<VideoTranscriptDocument>;
|
|
29
|
-
VideoScene: Model<VideoSceneDocument>;
|
|
30
|
-
};
|
|
31
|
-
|
|
32
|
-
export type RouterInput = inferRouterInputs<Router>;
|
|
33
|
-
export type RouterOutput = inferRouterOutputs<Router>;
|
package/util/db/index.ts
DELETED
package/util/db.ts
DELETED
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
import { v4 as uuidv4 } from 'uuid';
|
|
2
|
-
import _ from 'lodash';
|
|
3
|
-
|
|
4
|
-
export function generateLongId(): string {
|
|
5
|
-
return uuidv4().toUpperCase();
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
export function generateShortId() {
|
|
9
|
-
const timestamp = ((new Date().getTime() / 1000) | 0).toString(16);
|
|
10
|
-
return timestamp + 'xxxxxxxxxxxxxxxx'.replace(/[x]/g, () => ((Math.random() * 16) | 0).toString(16)).toLowerCase();
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
export const uuidFormat = 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx';
|
|
14
|
-
|
|
15
|
-
export function generateLongId2(): string {
|
|
16
|
-
return uuidFormat
|
|
17
|
-
.replace(/[xy]/g, (c) => {
|
|
18
|
-
const r = (Math.random() * 16) | 0;
|
|
19
|
-
const v = c === 'x' ? r : (r & 0x3) | 0x8;
|
|
20
|
-
return v.toString(16);
|
|
21
|
-
})
|
|
22
|
-
.toUpperCase();
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
export function decodeRequest(data: any): any {
|
|
26
|
-
if (
|
|
27
|
-
data === undefined ||
|
|
28
|
-
data === null ||
|
|
29
|
-
typeof data === 'string' ||
|
|
30
|
-
typeof data === 'number' ||
|
|
31
|
-
typeof data === 'boolean'
|
|
32
|
-
)
|
|
33
|
-
return data;
|
|
34
|
-
|
|
35
|
-
if (Array.isArray(data)) {
|
|
36
|
-
return data.map(decodeRequest);
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
if (typeof data !== 'object') return data;
|
|
40
|
-
|
|
41
|
-
const res: any = {};
|
|
42
|
-
|
|
43
|
-
for (const key in data) {
|
|
44
|
-
if (key === 'set') {
|
|
45
|
-
return data[key];
|
|
46
|
-
} else if (['create', 'connectOrCreate', 'upsert'].includes(key)) {
|
|
47
|
-
return decodeRequest(data[key]);
|
|
48
|
-
} else {
|
|
49
|
-
res[key] = decodeRequest(data[key]);
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
return Object.keys(res).length === 0 ? null : res;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
export function escapeStringRegexp(string: string): string {
|
|
57
|
-
if (typeof string !== 'string') {
|
|
58
|
-
throw new TypeError('Expected a string');
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
return string.replace(/[|\\{}()[\]^$+*?.]/g, '\\$&').replace(/-/g, '\\x2d');
|
|
62
|
-
}
|