@arken/seer-protocol 0.1.1 → 0.1.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/.rush/temp/shrinkwrap-deps.json +537 -56
- 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 +26 -0
- package/area/index.ts +5 -0
- package/asset/asset.models.ts +59 -0
- package/asset/asset.router.ts +55 -0
- package/asset/asset.schema.ts +27 -0
- package/asset/asset.types.ts +22 -0
- package/asset/index.ts +5 -0
- package/chain/chain.models.ts +50 -0
- package/chain/chain.router.ts +104 -0
- package/chain/chain.schema.ts +52 -0
- package/chain/chain.types.ts +24 -0
- package/chain/index.ts +5 -0
- package/character/character.models.ts +174 -0
- package/character/character.router.ts +314 -0
- package/character/character.schema.ts +147 -0
- package/character/character.types.ts +64 -0
- package/character/index.ts +5 -0
- package/chat/chat.models.ts +43 -0
- package/chat/chat.router.ts +67 -0
- package/chat/chat.schema.ts +36 -0
- package/chat/chat.types.ts +20 -0
- package/chat/index.ts +5 -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 +36 -0
- package/collection/index.ts +5 -0
- package/core/core.models.ts +1380 -0
- package/core/core.router.ts +1781 -0
- package/core/core.schema.ts +847 -0
- package/core/core.types.ts +340 -0
- package/core/index.ts +5 -0
- package/evolution/evolution.models.ts +1 -1
- package/evolution/evolution.router.ts +8 -8
- package/evolution/evolution.schema.ts +1 -1
- package/evolution/evolution.types.ts +1 -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 +28 -0
- package/game/index.ts +5 -0
- package/index.ts +39 -2
- package/infinite/infinite.models.ts +1 -1
- package/infinite/infinite.router.ts +8 -8
- package/infinite/infinite.schema.ts +1 -1
- package/infinite/infinite.types.ts +1 -1
- package/interface/index.ts +5 -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 +25 -0
- package/isles/isles.models.ts +1 -1
- package/isles/isles.router.ts +8 -8
- package/isles/isles.schema.ts +1 -1
- package/isles/isles.types.ts +1 -1
- package/item/index.ts +5 -0
- package/item/item.models.ts +124 -0
- package/item/item.router.ts +103 -0
- package/item/item.schema.ts +120 -0
- package/item/item.types.ts +74 -0
- package/job/index.ts +5 -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 +23 -0
- package/market/index.ts +5 -0
- package/market/market.models.ts +113 -0
- package/market/market.router.ts +73 -0
- package/market/market.schema.ts +140 -0
- package/market/market.types.ts +56 -0
- package/oasis/oasis.models.ts +1 -1
- package/oasis/oasis.router.ts +2 -2
- package/oasis/oasis.schema.ts +1 -1
- package/oasis/oasis.types.ts +1 -1
- package/package.json +10 -3
- package/product/index.ts +5 -0
- package/product/product.models.ts +166 -0
- package/product/product.router.ts +93 -0
- package/product/product.schema.ts +149 -0
- package/product/product.types.ts +33 -0
- package/profile/index.ts +5 -0
- package/profile/profile.models.ts +214 -0
- package/profile/profile.router.ts +72 -0
- package/profile/profile.schema.ts +156 -0
- package/profile/profile.types.ts +22 -0
- package/raffle/index.ts +5 -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 +30 -0
- package/router.ts +23 -29
- package/schema.ts +321 -0
- package/skill/index.ts +5 -0
- package/skill/skill.models.ts +16 -0
- package/skill/skill.router.ts +201 -0
- package/skill/skill.schema.ts +40 -0
- package/skill/skill.types.ts +33 -0
- package/trek/trek.models.ts +1 -1
- package/trek/trek.router.ts +1 -1
- package/trek/trek.schema.ts +1 -1
- package/trek/trek.types.ts +1 -1
- package/types.ts +172 -5
- package/video/index.ts +5 -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 +33 -0
|
@@ -0,0 +1,201 @@
|
|
|
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>;
|
|
@@ -0,0 +1,40 @@
|
|
|
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({}));
|
|
@@ -0,0 +1,33 @@
|
|
|
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
|
+
};
|
package/trek/trek.models.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import { z, ObjectId, Entity } from '@arken/schema';
|
|
1
|
+
import { z, ObjectId, Entity } from '@arken/node/schema';
|
package/trek/trek.router.ts
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
import { z as zod } from 'zod';
|
|
4
4
|
import { initTRPC } from '@trpc/server';
|
|
5
|
-
import { customErrorFormatter, hasRole } from '@arken/rpc';
|
|
5
|
+
import { customErrorFormatter, hasRole } from '@arken/node/rpc';
|
|
6
6
|
import type { inferRouterOutputs, inferRouterInputs } from '@trpc/server';
|
|
7
7
|
import type { RouterContext } from '../../types';
|
|
8
8
|
|
package/trek/trek.schema.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import { z, ObjectId, Entity } from '@arken/schema';
|
|
1
|
+
import { z, ObjectId, Entity } from '@arken/node/schema';
|
package/trek/trek.types.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import { z, ObjectId, Entity } from '@arken/schema';
|
|
1
|
+
import { z, ObjectId, Entity } from '@arken/node/schema';
|
package/types.ts
CHANGED
|
@@ -1,10 +1,32 @@
|
|
|
1
|
+
|
|
2
|
+
// arken/packages/seer/protocol/types.ts
|
|
3
|
+
//
|
|
1
4
|
import * as Arken from '@arken/node';
|
|
2
5
|
import { Router, RouterInput, RouterOutput } from './router';
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
import * as
|
|
7
|
-
import
|
|
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';
|
|
8
30
|
|
|
9
31
|
export type { Router, RouterInput, RouterOutput };
|
|
10
32
|
|
|
@@ -104,3 +126,148 @@ export interface Client {
|
|
|
104
126
|
export interface ServiceContext {
|
|
105
127
|
client: Client;
|
|
106
128
|
}
|
|
129
|
+
|
|
130
|
+
|
|
131
|
+
import { createRouter } from './router';
|
|
132
|
+
|
|
133
|
+
export * as util from './util';
|
|
134
|
+
|
|
135
|
+
export type * as Schema from './schema';
|
|
136
|
+
|
|
137
|
+
export type Router = ReturnType<typeof createRouter>;
|
|
138
|
+
|
|
139
|
+
export type ApplicationServiceType = Partial<{
|
|
140
|
+
Area: Area.Service;
|
|
141
|
+
Asset: Asset.Service;
|
|
142
|
+
Chain: Chain.Service;
|
|
143
|
+
Character: Character.Service;
|
|
144
|
+
Chat: Chat.Service;
|
|
145
|
+
Collection: Collection.Service;
|
|
146
|
+
Core: Core.Service;
|
|
147
|
+
Game: Game.Service;
|
|
148
|
+
Interface: Interface.Service;
|
|
149
|
+
Item: Item.Service;
|
|
150
|
+
Job: Job.Service;
|
|
151
|
+
Market: Market.Service;
|
|
152
|
+
Product: Product.Service;
|
|
153
|
+
Profile: Profile.Service;
|
|
154
|
+
Raffle: Raffle.Service;
|
|
155
|
+
Skill: Skill.Service;
|
|
156
|
+
Video: Video.Service;
|
|
157
|
+
}>;
|
|
158
|
+
|
|
159
|
+
export type ApplicationModelType = Partial<
|
|
160
|
+
Area.Types.Mappings &
|
|
161
|
+
Asset.Types.Mappings &
|
|
162
|
+
Chain.Types.Mappings &
|
|
163
|
+
Character.Types.Mappings &
|
|
164
|
+
Chat.Types.Mappings &
|
|
165
|
+
Collection.Types.Mappings &
|
|
166
|
+
Core.Types.Mappings &
|
|
167
|
+
Game.Types.Mappings &
|
|
168
|
+
Interface.Types.Mappings &
|
|
169
|
+
Item.Types.Mappings &
|
|
170
|
+
Job.Types.Mappings &
|
|
171
|
+
Market.Types.Mappings &
|
|
172
|
+
Product.Types.Mappings &
|
|
173
|
+
Profile.Types.Mappings &
|
|
174
|
+
Raffle.Types.Mappings &
|
|
175
|
+
Skill.Types.Mappings &
|
|
176
|
+
Video.Types.Mappings
|
|
177
|
+
>;
|
|
178
|
+
|
|
179
|
+
export interface Application {
|
|
180
|
+
model: ApplicationModelType;
|
|
181
|
+
service: ApplicationServiceType;
|
|
182
|
+
web3?: any;
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
export type RouterClient = {
|
|
186
|
+
socket: any;
|
|
187
|
+
roles: string[];
|
|
188
|
+
permissions: any;
|
|
189
|
+
profile?: Profile.Types.Profile;
|
|
190
|
+
emit: any;
|
|
191
|
+
};
|
|
192
|
+
|
|
193
|
+
export type RouterContext = {
|
|
194
|
+
app: Application;
|
|
195
|
+
client?: RouterClient;
|
|
196
|
+
profile?: Profile.Types.Profile;
|
|
197
|
+
};
|
|
198
|
+
|
|
199
|
+
export interface Signature {
|
|
200
|
+
hash?: string;
|
|
201
|
+
address?: string;
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
export type Position = {
|
|
205
|
+
x: number;
|
|
206
|
+
y: number;
|
|
207
|
+
z?: number;
|
|
208
|
+
};
|
|
209
|
+
|
|
210
|
+
export type UnwrapPromise<T> = T extends Promise<infer U> ? U : T;
|
|
211
|
+
|
|
212
|
+
export type PatchOp =
|
|
213
|
+
| { op: 'set'; key: string; value: any }
|
|
214
|
+
| { op: 'unset'; key: string }
|
|
215
|
+
| { op: 'inc'; key: string; value: number }
|
|
216
|
+
| { op: 'push'; key: string; value: any }
|
|
217
|
+
| { op: 'merge'; key: string; value: Record<string, any> };
|
|
218
|
+
|
|
219
|
+
export type EntityPatch = {
|
|
220
|
+
entityType: string; // allow any string
|
|
221
|
+
entityId: string;
|
|
222
|
+
baseVersion?: number;
|
|
223
|
+
ops: PatchOp[];
|
|
224
|
+
claimable?: boolean;
|
|
225
|
+
};
|
|
226
|
+
|
|
227
|
+
export type GameObjectDef = {
|
|
228
|
+
id: string;
|
|
229
|
+
type: string; // allow any string
|
|
230
|
+
name: string;
|
|
231
|
+
position: { x: number; y: number };
|
|
232
|
+
radius?: number; // interaction distance
|
|
233
|
+
tags?: string[];
|
|
234
|
+
meta?: Record<string, any>;
|
|
235
|
+
};
|
|
236
|
+
|
|
237
|
+
export type Requirement =
|
|
238
|
+
| { kind: 'exists'; key: string }
|
|
239
|
+
| { kind: 'touchedObject'; objectId: string; afterKey?: string; writeKey: string };
|
|
240
|
+
|
|
241
|
+
// Generic effects (can be positive or negative)
|
|
242
|
+
export type Effect =
|
|
243
|
+
| { kind: 'item.grant'; itemKey: string; quantity?: number }
|
|
244
|
+
| { kind: 'currency.grant'; key: string; amount: number } // negative amount allowed
|
|
245
|
+
| { kind: 'reputation.delta'; npcId: string; amount: number } // negative allowed
|
|
246
|
+
| { kind: 'state.patch'; patch: EntityPatch } // generic patch against any entityType
|
|
247
|
+
| { kind: 'ui.unlock'; uiKey: string } // optional, future
|
|
248
|
+
| { kind: 'emit'; eventType: string; payload?: any }; // optional, future
|
|
249
|
+
|
|
250
|
+
export type QuestDef = {
|
|
251
|
+
id: string;
|
|
252
|
+
metaverseId: string;
|
|
253
|
+
name: string;
|
|
254
|
+
|
|
255
|
+
// Requirements can be checked shard-side (for anti-cheat) AND client-side (for UI state)
|
|
256
|
+
requirements: Requirement[];
|
|
257
|
+
|
|
258
|
+
// Effects are applied on completion/claim (seer-side)
|
|
259
|
+
effects: Effect[];
|
|
260
|
+
|
|
261
|
+
// keys shard will write (auditing + permissions)
|
|
262
|
+
writes?: string[];
|
|
263
|
+
};
|
|
264
|
+
|
|
265
|
+
type QuestCompleteOp = {
|
|
266
|
+
kind: 'quest.complete';
|
|
267
|
+
id: string;
|
|
268
|
+
ts: number;
|
|
269
|
+
questId: string;
|
|
270
|
+
metaverseId: string;
|
|
271
|
+
evidence?: Record<string, any>;
|
|
272
|
+
effects?: any[]; // can include effect refs for replay/debug
|
|
273
|
+
};
|
package/video/index.ts
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
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', {});
|
|
@@ -0,0 +1,143 @@
|
|
|
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>;
|