@arken/seer-protocol 0.1.1 → 0.1.3
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/.rush/temp/shrinkwrap-deps.json +778 -53
- package/area/area.models.ts +15 -0
- package/area/area.router.ts +74 -0
- package/area/area.schema.ts +22 -0
- package/area/area.types.ts +25 -0
- package/area/index.ts +4 -0
- package/asset/asset.models.ts +59 -0
- package/asset/asset.router.ts +55 -0
- package/asset/asset.schema.ts +30 -0
- package/asset/asset.types.ts +21 -0
- package/asset/index.ts +4 -0
- package/chain/chain.models.ts +50 -0
- package/chain/chain.router.ts +104 -0
- package/chain/chain.schema.ts +67 -0
- package/chain/chain.types.ts +23 -0
- package/chain/index.ts +4 -0
- package/character/character.models.ts +174 -0
- package/character/character.router.ts +314 -0
- package/character/character.schema.ts +150 -0
- package/character/character.types.ts +63 -0
- package/character/index.ts +4 -0
- package/chat/chat.models.ts +43 -0
- package/chat/chat.router.ts +67 -0
- package/chat/chat.schema.ts +39 -0
- package/chat/chat.types.ts +19 -0
- package/chat/index.ts +4 -0
- package/collection/collection.models.ts +76 -0
- package/collection/collection.router.ts +91 -0
- package/collection/collection.schema.ts +90 -0
- package/collection/collection.types.ts +35 -0
- package/collection/index.ts +4 -0
- package/core/core.models.ts +1380 -0
- package/core/core.router.ts +1781 -0
- package/core/core.schema.ts +940 -0
- package/core/core.types.ts +339 -0
- package/core/index.ts +4 -0
- package/evolution/evolution.models.ts +1 -1
- package/evolution/evolution.router.ts +19 -19
- package/evolution/evolution.schema.ts +1 -1
- package/evolution/evolution.types.ts +2 -3
- package/evolution/index.ts +0 -1
- package/game/game.models.ts +53 -0
- package/game/game.router.ts +110 -0
- package/game/game.schema.ts +23 -0
- package/game/game.types.ts +27 -0
- package/game/index.ts +4 -0
- package/index.ts +43 -6
- package/infinite/index.ts +0 -1
- package/infinite/infinite.models.ts +1 -1
- package/infinite/infinite.router.ts +9 -9
- package/infinite/infinite.schema.ts +1 -1
- package/infinite/infinite.types.ts +2 -3
- package/interface/index.ts +4 -0
- package/interface/interface.canonicalize.ts +279 -0
- package/interface/interface.models.ts +40 -0
- package/interface/interface.router.ts +175 -0
- package/interface/interface.schema.ts +59 -0
- package/interface/interface.types.ts +24 -0
- package/isles/index.ts +0 -1
- package/isles/isles.models.ts +1 -1
- package/isles/isles.router.ts +9 -9
- package/isles/isles.schema.ts +1 -1
- package/isles/isles.types.ts +2 -3
- package/item/index.ts +4 -0
- package/item/item.models.ts +124 -0
- package/item/item.router.ts +103 -0
- package/item/item.schema.ts +150 -0
- package/item/item.types.ts +73 -0
- package/job/index.ts +4 -0
- package/job/job.models.ts +14 -0
- package/job/job.router.ts +44 -0
- package/job/job.schema.ts +9 -0
- package/job/job.types.ts +22 -0
- package/market/index.ts +4 -0
- package/market/market.models.ts +113 -0
- package/market/market.router.ts +73 -0
- package/market/market.schema.ts +149 -0
- package/market/market.types.ts +55 -0
- package/oasis/index.ts +0 -1
- package/oasis/oasis.models.ts +1 -1
- package/oasis/oasis.router.ts +5 -6
- package/oasis/oasis.schema.ts +1 -1
- package/oasis/oasis.types.ts +2 -3
- package/package.json +17 -4
- package/product/index.ts +4 -0
- package/product/product.models.ts +166 -0
- package/product/product.router.ts +93 -0
- package/product/product.schema.ts +186 -0
- package/product/product.types.ts +32 -0
- package/profile/index.ts +4 -0
- package/profile/profile.models.ts +214 -0
- package/profile/profile.router.ts +72 -0
- package/profile/profile.schema.ts +219 -0
- package/profile/profile.types.ts +21 -0
- package/raffle/index.ts +4 -0
- package/raffle/raffle.models.ts +44 -0
- package/raffle/raffle.router.ts +90 -0
- package/raffle/raffle.schema.ts +32 -0
- package/raffle/raffle.types.ts +29 -0
- package/router.ts +23 -29
- package/schema.ts +321 -0
- package/skill/index.ts +4 -0
- package/skill/skill.models.ts +16 -0
- package/skill/skill.router.ts +201 -0
- package/skill/skill.schema.ts +52 -0
- package/skill/skill.types.ts +32 -0
- package/trek/index.ts +0 -1
- package/trek/trek.models.ts +1 -1
- package/trek/trek.router.ts +2 -2
- package/trek/trek.schema.ts +1 -1
- package/trek/trek.types.ts +1 -1
- package/tsconfig.json +25 -17
- package/types.ts +174 -26
- package/video/index.ts +4 -0
- package/video/video.models.ts +25 -0
- package/video/video.router.ts +143 -0
- package/video/video.schema.ts +46 -0
- package/video/video.types.ts +32 -0
package/tsconfig.json
CHANGED
|
@@ -1,25 +1,33 @@
|
|
|
1
1
|
{
|
|
2
2
|
"compilerOptions": {
|
|
3
|
-
"module": "CommonJS",
|
|
4
|
-
"preserveSymlinks": true,
|
|
5
3
|
"esModuleInterop": true,
|
|
4
|
+
"module": "ESNext",
|
|
5
|
+
"lib": ["ES2020", "DOM"],
|
|
6
|
+
"noImplicitAny": false,
|
|
7
|
+
"outDir": "build",
|
|
8
|
+
"preserveSymlinks": false,
|
|
9
|
+
"preserveConstEnums": true,
|
|
6
10
|
"experimentalDecorators": true,
|
|
7
11
|
"emitDecoratorMetadata": true,
|
|
12
|
+
"removeComments": true,
|
|
13
|
+
"skipLibCheck": true,
|
|
14
|
+
"forceConsistentCasingInFileNames": true,
|
|
15
|
+
"strict": false,
|
|
16
|
+
"checkJs": true,
|
|
17
|
+
"sourceMap": true,
|
|
18
|
+
"target": "ES2020",
|
|
19
|
+
"moduleResolution": "Node",
|
|
8
20
|
"resolveJsonModule": true,
|
|
9
21
|
"allowSyntheticDefaultImports": true,
|
|
10
|
-
"
|
|
11
|
-
"
|
|
12
|
-
"
|
|
13
|
-
"
|
|
14
|
-
"
|
|
15
|
-
"
|
|
16
|
-
"
|
|
17
|
-
|
|
18
|
-
},
|
|
19
|
-
"target": "ESNext",
|
|
20
|
-
"lib": ["ESNext"],
|
|
21
|
-
"moduleResolution": "Node"
|
|
22
|
+
"types": ["jest", "node"],
|
|
23
|
+
"paths": {},
|
|
24
|
+
"allowJs": true,
|
|
25
|
+
"declaration": true,
|
|
26
|
+
"isolatedModules": true,
|
|
27
|
+
"noFallthroughCasesInSwitch": true,
|
|
28
|
+
"noEmit": false,
|
|
29
|
+
"composite": true
|
|
22
30
|
},
|
|
23
|
-
"include": ["./
|
|
24
|
-
"exclude": []
|
|
25
|
-
}
|
|
31
|
+
"include": ["./area/**/*","./asset/**/*", "./chain/**/*","./chain/**/*","./character/**/*","./chat/**/*","./collection/**/*","./core/**/*","./evolution/**/*", "./game/**/*","./infinite/**/*","./interface/**/*","./isles/**/*","./item/**/*","./job/**/*","./market/**/*","./oasis/**/*","./product/**/*","./profile/**/*","./raffle/**/*","./skill/**/*","./trek/**/*","./video/**/*","./index.ts","./router.ts","./schema.ts","./types.ts"],
|
|
32
|
+
"exclude": ["node_modules", "build"]
|
|
33
|
+
}
|
package/types.ts
CHANGED
|
@@ -1,29 +1,61 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
import * as
|
|
5
|
-
import
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
1
|
+
|
|
2
|
+
// arken/packages/seer/protocol/types.ts
|
|
3
|
+
//
|
|
4
|
+
// import * as Arken from '@arken/node';
|
|
5
|
+
// import { Router, RouterInput, RouterOutput } from './router';
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
// Imports
|
|
9
|
+
import * as Area from './area';
|
|
10
|
+
import * as Asset from './asset';
|
|
11
|
+
import * as Chain from './chain';
|
|
12
|
+
import * as Character from './character';
|
|
13
|
+
import * as Chat from './chat';
|
|
14
|
+
import * as Collection from './collection';
|
|
15
|
+
import * as Core from './core';
|
|
16
|
+
import * as Game from './game';
|
|
17
|
+
import * as Interface from './interface';
|
|
18
|
+
import * as Item from './item';
|
|
19
|
+
import * as Job from './job';
|
|
20
|
+
import * as Market from './market';
|
|
21
|
+
import * as Product from './product';
|
|
22
|
+
import * as Profile from './profile';
|
|
23
|
+
import * as Raffle from './raffle';
|
|
24
|
+
import * as Skill from './skill';
|
|
25
|
+
import * as Video from './video';
|
|
26
|
+
import * as Evolution from './evolution';
|
|
27
|
+
import * as Infinite from './infinite';
|
|
28
|
+
import * as Oasis from './oasis';
|
|
29
|
+
import * as Trek from './trek';
|
|
30
|
+
|
|
31
|
+
// Exports
|
|
32
|
+
export * as Area from './area';
|
|
33
|
+
export * as Asset from './asset';
|
|
34
|
+
export * as Chain from './chain';
|
|
35
|
+
export * as Character from './character';
|
|
36
|
+
export * as Chat from './chat';
|
|
37
|
+
export * as Collection from './collection';
|
|
38
|
+
export * as Core from './core';
|
|
39
|
+
export * as Game from './game';
|
|
40
|
+
export * as Interface from './interface';
|
|
41
|
+
export * as Item from './item';
|
|
42
|
+
export * as Job from './job';
|
|
43
|
+
export * as Market from './market';
|
|
44
|
+
export * as Product from './product';
|
|
45
|
+
export * as Profile from './profile';
|
|
46
|
+
export * as Raffle from './raffle';
|
|
47
|
+
export * as Skill from './skill';
|
|
48
|
+
export * as Video from './video';
|
|
49
|
+
export * as Evolution from './evolution';
|
|
50
|
+
export * as Infinite from './infinite';
|
|
51
|
+
export * as Oasis from './oasis';
|
|
52
|
+
export * as Trek from './trek';
|
|
53
|
+
|
|
54
|
+
export class Application<ServiceType> {
|
|
23
55
|
router: Router;
|
|
24
|
-
service:
|
|
56
|
+
service: ServiceType;
|
|
25
57
|
model: ApplicationModelType = {};
|
|
26
|
-
realms:
|
|
58
|
+
realms: Core.Types.Realm[] = [];
|
|
27
59
|
|
|
28
60
|
server: any;
|
|
29
61
|
http: any;
|
|
@@ -81,8 +113,10 @@ export type ApplicationType = typeof Application;
|
|
|
81
113
|
// };
|
|
82
114
|
|
|
83
115
|
export type RouterContext = {
|
|
84
|
-
app: Application
|
|
85
|
-
|
|
116
|
+
app: Application<any>;
|
|
117
|
+
client?: RouterClient;
|
|
118
|
+
profile?: Profile.Types.Profile;
|
|
119
|
+
};
|
|
86
120
|
|
|
87
121
|
export interface Client {
|
|
88
122
|
id: string;
|
|
@@ -104,3 +138,117 @@ export interface Client {
|
|
|
104
138
|
export interface ServiceContext {
|
|
105
139
|
client: Client;
|
|
106
140
|
}
|
|
141
|
+
|
|
142
|
+
|
|
143
|
+
import { createRouter } from './router';
|
|
144
|
+
|
|
145
|
+
export type * as Schema from './schema';
|
|
146
|
+
|
|
147
|
+
export type Router = ReturnType<typeof createRouter>;
|
|
148
|
+
|
|
149
|
+
export type ApplicationModelType = Partial<
|
|
150
|
+
Area.Types.Mappings &
|
|
151
|
+
Asset.Types.Mappings &
|
|
152
|
+
Chain.Types.Mappings &
|
|
153
|
+
Character.Types.Mappings &
|
|
154
|
+
Chat.Types.Mappings &
|
|
155
|
+
Collection.Types.Mappings &
|
|
156
|
+
Core.Types.Mappings &
|
|
157
|
+
Game.Types.Mappings &
|
|
158
|
+
Interface.Types.Mappings &
|
|
159
|
+
Item.Types.Mappings &
|
|
160
|
+
Job.Types.Mappings &
|
|
161
|
+
Market.Types.Mappings &
|
|
162
|
+
Product.Types.Mappings &
|
|
163
|
+
Profile.Types.Mappings &
|
|
164
|
+
Raffle.Types.Mappings &
|
|
165
|
+
Skill.Types.Mappings &
|
|
166
|
+
Video.Types.Mappings &
|
|
167
|
+
Evolution.Types.Mappings &
|
|
168
|
+
Infinite.Types.Mappings
|
|
169
|
+
>;
|
|
170
|
+
|
|
171
|
+
export type RouterClient = {
|
|
172
|
+
socket: any;
|
|
173
|
+
roles: string[];
|
|
174
|
+
permissions: any;
|
|
175
|
+
profile?: Profile.Types.Profile;
|
|
176
|
+
emit: any;
|
|
177
|
+
};
|
|
178
|
+
|
|
179
|
+
|
|
180
|
+
export interface Signature {
|
|
181
|
+
hash?: string;
|
|
182
|
+
address?: string;
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
export type Position = {
|
|
186
|
+
x: number;
|
|
187
|
+
y: number;
|
|
188
|
+
z?: number;
|
|
189
|
+
};
|
|
190
|
+
|
|
191
|
+
export type UnwrapPromise<T> = T extends Promise<infer U> ? U : T;
|
|
192
|
+
|
|
193
|
+
export type PatchOp =
|
|
194
|
+
| { op: 'set'; key: string; value: any }
|
|
195
|
+
| { op: 'unset'; key: string }
|
|
196
|
+
| { op: 'inc'; key: string; value: number }
|
|
197
|
+
| { op: 'push'; key: string; value: any }
|
|
198
|
+
| { op: 'merge'; key: string; value: Record<string, any> };
|
|
199
|
+
|
|
200
|
+
export type EntityPatch = {
|
|
201
|
+
entityType: string; // allow any string
|
|
202
|
+
entityId: string;
|
|
203
|
+
baseVersion?: number;
|
|
204
|
+
ops: PatchOp[];
|
|
205
|
+
claimable?: boolean;
|
|
206
|
+
};
|
|
207
|
+
|
|
208
|
+
export type GameObjectDef = {
|
|
209
|
+
id: string;
|
|
210
|
+
type: string; // allow any string
|
|
211
|
+
name: string;
|
|
212
|
+
position: { x: number; y: number };
|
|
213
|
+
radius?: number; // interaction distance
|
|
214
|
+
tags?: string[];
|
|
215
|
+
meta?: Record<string, any>;
|
|
216
|
+
};
|
|
217
|
+
|
|
218
|
+
export type Requirement =
|
|
219
|
+
| { kind: 'exists'; key: string }
|
|
220
|
+
| { kind: 'touchedObject'; objectId: string; afterKey?: string; writeKey: string };
|
|
221
|
+
|
|
222
|
+
// Generic effects (can be positive or negative)
|
|
223
|
+
export type Effect =
|
|
224
|
+
| { kind: 'item.grant'; itemKey: string; quantity?: number }
|
|
225
|
+
| { kind: 'currency.grant'; key: string; amount: number } // negative amount allowed
|
|
226
|
+
| { kind: 'reputation.delta'; npcId: string; amount: number } // negative allowed
|
|
227
|
+
| { kind: 'state.patch'; patch: EntityPatch } // generic patch against any entityType
|
|
228
|
+
| { kind: 'ui.unlock'; uiKey: string } // optional, future
|
|
229
|
+
| { kind: 'emit'; eventType: string; payload?: any }; // optional, future
|
|
230
|
+
|
|
231
|
+
export type QuestDef = {
|
|
232
|
+
id: string;
|
|
233
|
+
metaverseId: string;
|
|
234
|
+
name: string;
|
|
235
|
+
|
|
236
|
+
// Requirements can be checked shard-side (for anti-cheat) AND client-side (for UI state)
|
|
237
|
+
requirements: Requirement[];
|
|
238
|
+
|
|
239
|
+
// Effects are applied on completion/claim (seer-side)
|
|
240
|
+
effects: Effect[];
|
|
241
|
+
|
|
242
|
+
// keys shard will write (auditing + permissions)
|
|
243
|
+
writes?: string[];
|
|
244
|
+
};
|
|
245
|
+
|
|
246
|
+
type QuestCompleteOp = {
|
|
247
|
+
kind: 'quest.complete';
|
|
248
|
+
id: string;
|
|
249
|
+
ts: number;
|
|
250
|
+
questId: string;
|
|
251
|
+
metaverseId: string;
|
|
252
|
+
evidence?: Record<string, any>;
|
|
253
|
+
effects?: any[]; // can include effect refs for replay/debug
|
|
254
|
+
};
|
package/video/index.ts
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import * as mongo from '@arken/node/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', {});
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
import { z as zod } from 'zod';
|
|
2
|
+
import { initTRPC, inferRouterInputs, inferRouterOutputs } from '@trpc/server';
|
|
3
|
+
import { customErrorFormatter, hasRole } from '@arken/node/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>;
|
|
@@ -0,0 +1,46 @@
|
|
|
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
|
+
);
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import * as schema from './video.schema';
|
|
3
|
+
import { Document, Model } from '@arken/node/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 { RouterContext };
|
|
10
|
+
|
|
11
|
+
export type Video = z.infer<typeof schema.Video>;
|
|
12
|
+
export type VideoParticipant = z.infer<typeof schema.VideoParticipant>;
|
|
13
|
+
export type VideoDialogue = z.infer<typeof schema.VideoDialogue>;
|
|
14
|
+
export type VideoTranscript = z.infer<typeof schema.VideoTranscript>;
|
|
15
|
+
export type VideoScene = z.infer<typeof schema.VideoScene>;
|
|
16
|
+
|
|
17
|
+
export type VideoDocument = Video & Document;
|
|
18
|
+
export type VideoParticipantDocument = VideoParticipant & Document;
|
|
19
|
+
export type VideoDialogueDocument = VideoDialogue & Document;
|
|
20
|
+
export type VideoTranscriptDocument = VideoTranscript & Document;
|
|
21
|
+
export type VideoSceneDocument = VideoScene & Document;
|
|
22
|
+
|
|
23
|
+
export type Mappings = {
|
|
24
|
+
Video: Model<VideoDocument>;
|
|
25
|
+
VideoParticipant: Model<VideoParticipantDocument>;
|
|
26
|
+
VideoDialogue: Model<VideoDialogueDocument>;
|
|
27
|
+
VideoTranscript: Model<VideoTranscriptDocument>;
|
|
28
|
+
VideoScene: Model<VideoSceneDocument>;
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
export type RouterInput = inferRouterInputs<Router>;
|
|
32
|
+
export type RouterOutput = inferRouterOutputs<Router>;
|