@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/schema.ts
ADDED
|
@@ -0,0 +1,321 @@
|
|
|
1
|
+
// arken/packages/node/schema.ts
|
|
2
|
+
//
|
|
3
|
+
import Mongoose, { Types } from 'mongoose';
|
|
4
|
+
import { z as zod, ZodTypeAny, ZodLazy, ZodObject, ZodArray } from 'zod';
|
|
5
|
+
import { AnyProcedure, inferProcedureOutput, AnyRouter, AnyTRPCClientTypes, TRPCRouterRecord } from '@trpc/server';
|
|
6
|
+
|
|
7
|
+
export type { inferRouterInputs } from '@trpc/server';
|
|
8
|
+
|
|
9
|
+
export const z = zod;
|
|
10
|
+
|
|
11
|
+
// @ts-ignore
|
|
12
|
+
export const ObjectId = z.union([
|
|
13
|
+
z.string().refine((value) => Mongoose.isValidObjectId(value), {
|
|
14
|
+
// Accept valid ObjectId strings
|
|
15
|
+
message: 'Invalid ObjectId',
|
|
16
|
+
}),
|
|
17
|
+
z.instanceof(Types.ObjectId), // Accept Mongoose ObjectId instances
|
|
18
|
+
]);
|
|
19
|
+
|
|
20
|
+
export const Anything = z.any();
|
|
21
|
+
export const Nothing = z.object({});
|
|
22
|
+
export const Signature = z.object({ hash: z.string(), address: z.string() });
|
|
23
|
+
export const UnsignedData = z.object({ data: z.any() });
|
|
24
|
+
export const SignedData = z.object({
|
|
25
|
+
data: z.any(),
|
|
26
|
+
signature: Signature,
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
export const AnyInput = z.any();
|
|
30
|
+
export const OnlySignatureInput = z.object({ signature: Signature });
|
|
31
|
+
export const NoDataOutput = z.object({ status: z.number() });
|
|
32
|
+
export const AnyDataOutput = z.object({ data: z.any(), status: z.number() });
|
|
33
|
+
|
|
34
|
+
export enum Status {
|
|
35
|
+
Paused = 'Paused',
|
|
36
|
+
Pending = 'Pending',
|
|
37
|
+
Active = 'Active',
|
|
38
|
+
Archived = 'Archived',
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export type Meta = {
|
|
42
|
+
[key: string]: unknown;
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
export const Common = z.object({
|
|
46
|
+
id: ObjectId.optional(),
|
|
47
|
+
meta: z.any(), // Default value set here matches Mongoose
|
|
48
|
+
data: z.any(), // Default value set here matches Mongoose
|
|
49
|
+
status: z.enum(['Paused', 'Pending', 'Active', 'Archived']).default('Active'), // Default set in StatusEnum matches Mongoose
|
|
50
|
+
merkleLeaf: z.string().optional(),
|
|
51
|
+
merkleIndex: z.number().optional(),
|
|
52
|
+
createdById: ObjectId.optional(),
|
|
53
|
+
editedById: ObjectId.optional(),
|
|
54
|
+
deletedById: ObjectId.optional(),
|
|
55
|
+
createdDate: z.date().default(() => new Date()), // Default matches Mongoose
|
|
56
|
+
updatedDate: z.date().optional(),
|
|
57
|
+
deletedDate: z.date().optional(),
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
export type Common = zod.infer<typeof Common>;
|
|
61
|
+
|
|
62
|
+
export const Entity = z
|
|
63
|
+
.object({
|
|
64
|
+
id: z.string().min(24).max(24).trim().optional(),
|
|
65
|
+
key: z.string().min(1).max(200).trim().optional(),
|
|
66
|
+
name: z.string().min(1).max(200).trim().optional(),
|
|
67
|
+
description: z.string().optional(),
|
|
68
|
+
applicationId: ObjectId.optional(),
|
|
69
|
+
ownerId: ObjectId.optional(),
|
|
70
|
+
})
|
|
71
|
+
.merge(Common);
|
|
72
|
+
|
|
73
|
+
export type Entity = zod.infer<typeof Entity>;
|
|
74
|
+
|
|
75
|
+
const QueryFilterOperators = z.object({
|
|
76
|
+
equals: z.any().optional(),
|
|
77
|
+
not: z.any().optional(),
|
|
78
|
+
in: z.array(z.any()).optional(),
|
|
79
|
+
notIn: z.array(z.any()).optional(),
|
|
80
|
+
lt: z.any().optional(),
|
|
81
|
+
lte: z.any().optional(),
|
|
82
|
+
gt: z.any().optional(),
|
|
83
|
+
gte: z.any().optional(),
|
|
84
|
+
contains: z.string().optional(),
|
|
85
|
+
startsWith: z.string().optional(),
|
|
86
|
+
endsWith: z.string().optional(),
|
|
87
|
+
mode: z.enum(['default', 'insensitive']).optional(),
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
const QueryWhereSchema = z.lazy(() =>
|
|
91
|
+
z.object({
|
|
92
|
+
AND: z.array(QueryWhereSchema).optional(),
|
|
93
|
+
OR: z.array(QueryWhereSchema).optional(),
|
|
94
|
+
NOT: z.array(QueryWhereSchema).optional(),
|
|
95
|
+
id: QueryFilterOperators.optional(),
|
|
96
|
+
key: QueryFilterOperators.optional(),
|
|
97
|
+
name: QueryFilterOperators.optional(),
|
|
98
|
+
email: QueryFilterOperators.optional(),
|
|
99
|
+
status: QueryFilterOperators.optional(),
|
|
100
|
+
})
|
|
101
|
+
);
|
|
102
|
+
|
|
103
|
+
export const Query = z.object({
|
|
104
|
+
skip: z.number().default(0).optional(),
|
|
105
|
+
take: z.number().default(10).optional(),
|
|
106
|
+
cursor: z.record(z.any()).optional(),
|
|
107
|
+
where: QueryWhereSchema.optional(),
|
|
108
|
+
orderBy: z.record(z.enum(['asc', 'desc'])).optional(),
|
|
109
|
+
include: z.record(z.boolean()).optional(),
|
|
110
|
+
select: z.record(z.boolean()).optional(),
|
|
111
|
+
});
|
|
112
|
+
|
|
113
|
+
// // Operators for filtering in a Prisma-like way
|
|
114
|
+
// type PrismaFilterOperators<T extends ZodTypeAny> = zod.ZodObject<
|
|
115
|
+
// {
|
|
116
|
+
// equals?: T;
|
|
117
|
+
// not?: T;
|
|
118
|
+
// in?: zod.ZodArray<T>;
|
|
119
|
+
// notIn?: zod.ZodArray<T>;
|
|
120
|
+
// lt?: T;
|
|
121
|
+
// lte?: T;
|
|
122
|
+
// gt?: T;
|
|
123
|
+
// gte?: T;
|
|
124
|
+
// contains?: zod.ZodString; // T extends zod.ZodString ? zod.ZodString : never;
|
|
125
|
+
// startsWith?: zod.ZodString; // T extends zod.ZodString ? zod.ZodString : never;
|
|
126
|
+
// endsWith?: zod.ZodString; // T extends zod.ZodString ? zod.ZodString : never;
|
|
127
|
+
// mode?: zod.ZodString; // T extends zod.ZodString ? zod.ZodEnum<['default', 'insensitive']> : never;
|
|
128
|
+
// },
|
|
129
|
+
// 'strip',
|
|
130
|
+
// ZodTypeAny
|
|
131
|
+
// >;
|
|
132
|
+
|
|
133
|
+
// // Level 0: No AND, OR, NOT
|
|
134
|
+
// type PrismaWhereLevel0<T extends zod.ZodRawShape> = ZodObject<
|
|
135
|
+
// {
|
|
136
|
+
// [K in keyof T]?: PrismaFilterOperators<T[K]>;
|
|
137
|
+
// },
|
|
138
|
+
// 'strip',
|
|
139
|
+
// ZodTypeAny
|
|
140
|
+
// >;
|
|
141
|
+
|
|
142
|
+
// // Level 1: Includes AND, OR, NOT of Level 0
|
|
143
|
+
// type PrismaWhereLevel1<T extends zod.ZodRawShape> = ZodObject<
|
|
144
|
+
// {
|
|
145
|
+
// AND?: ZodArray<ZodLazy<PrismaWhereLevel0<T>>>;
|
|
146
|
+
// OR?: ZodArray<ZodLazy<PrismaWhereLevel0<T>>>;
|
|
147
|
+
// NOT?: ZodArray<ZodLazy<PrismaWhereLevel0<T>>>;
|
|
148
|
+
// } & {
|
|
149
|
+
// [K in keyof T]?: PrismaFilterOperators<T[K]>;
|
|
150
|
+
// },
|
|
151
|
+
// 'strip',
|
|
152
|
+
// ZodTypeAny
|
|
153
|
+
// >;
|
|
154
|
+
|
|
155
|
+
// // Level 2: Includes AND, OR, NOT of Level 1
|
|
156
|
+
// type PrismaWhereLevel2<T extends zod.ZodRawShape> = ZodObject<
|
|
157
|
+
// {
|
|
158
|
+
// AND?: ZodArray<ZodLazy<PrismaWhereLevel1<T>>>;
|
|
159
|
+
// OR?: ZodArray<ZodLazy<PrismaWhereLevel1<T>>>;
|
|
160
|
+
// NOT?: ZodArray<ZodLazy<PrismaWhereLevel1<T>>>;
|
|
161
|
+
// } & {
|
|
162
|
+
// [K in keyof T]?: PrismaFilterOperators<T[K]>;
|
|
163
|
+
// },
|
|
164
|
+
// 'strip',
|
|
165
|
+
// ZodTypeAny
|
|
166
|
+
// >;
|
|
167
|
+
|
|
168
|
+
// // Level 3: Includes AND, OR, NOT of Level 2
|
|
169
|
+
// type PrismaWhereLevel3<T extends zod.ZodRawShape> = ZodObject<
|
|
170
|
+
// {
|
|
171
|
+
// AND?: ZodArray<ZodLazy<PrismaWhereLevel2<T>>>;
|
|
172
|
+
// OR?: ZodArray<ZodLazy<PrismaWhereLevel2<T>>>;
|
|
173
|
+
// NOT?: ZodArray<ZodLazy<PrismaWhereLevel2<T>>>;
|
|
174
|
+
// } & {
|
|
175
|
+
// [K in keyof T]?: PrismaFilterOperators<T[K]>;
|
|
176
|
+
// },
|
|
177
|
+
// 'strip',
|
|
178
|
+
// ZodTypeAny
|
|
179
|
+
// >;
|
|
180
|
+
|
|
181
|
+
// // Level 4: Includes AND, OR, NOT of Level 3
|
|
182
|
+
// type PrismaWhereLevel4<T extends zod.ZodRawShape> = ZodObject<
|
|
183
|
+
// {
|
|
184
|
+
// AND?: ZodArray<ZodLazy<PrismaWhereLevel3<T>>>;
|
|
185
|
+
// OR?: ZodArray<ZodLazy<PrismaWhereLevel3<T>>>;
|
|
186
|
+
// NOT?: ZodArray<ZodLazy<PrismaWhereLevel3<T>>>;
|
|
187
|
+
// } & {
|
|
188
|
+
// [K in keyof T]?: PrismaFilterOperators<T[K]>;
|
|
189
|
+
// },
|
|
190
|
+
// 'strip',
|
|
191
|
+
// ZodTypeAny
|
|
192
|
+
// >;
|
|
193
|
+
|
|
194
|
+
// Function to create a recursive schema up to level 4
|
|
195
|
+
export const createPrismaWhereSchema = <T extends zod.ZodRawShape>(
|
|
196
|
+
modelSchema: zod.ZodObject<T>,
|
|
197
|
+
depth: number = 3
|
|
198
|
+
): zod.ZodObject<any> => {
|
|
199
|
+
const fields = modelSchema.shape;
|
|
200
|
+
|
|
201
|
+
/**
|
|
202
|
+
* For each field, accept either:
|
|
203
|
+
* - a full operator object: { equals, in, lt, ... }
|
|
204
|
+
* - OR a raw value shorthand: 'foo' -> { equals: 'foo' }
|
|
205
|
+
*/
|
|
206
|
+
const makeFieldFilter = (value: zod.ZodTypeAny) => {
|
|
207
|
+
const opsSchema = zod
|
|
208
|
+
.object({
|
|
209
|
+
equals: value.optional(),
|
|
210
|
+
not: value.optional(),
|
|
211
|
+
in: zod.array(value).optional(),
|
|
212
|
+
notIn: zod.array(value).optional(),
|
|
213
|
+
lt: value.optional(),
|
|
214
|
+
lte: value.optional(),
|
|
215
|
+
gt: value.optional(),
|
|
216
|
+
gte: value.optional(),
|
|
217
|
+
contains: zod.string().optional(),
|
|
218
|
+
startsWith: zod.string().optional(),
|
|
219
|
+
endsWith: zod.string().optional(),
|
|
220
|
+
mode: zod.string().optional(),
|
|
221
|
+
})
|
|
222
|
+
.partial();
|
|
223
|
+
|
|
224
|
+
return zod
|
|
225
|
+
.preprocess((input) => {
|
|
226
|
+
// let undefined through
|
|
227
|
+
if (input === undefined) return input;
|
|
228
|
+
|
|
229
|
+
// Already an object (likely { equals, in, ... }) → validate as-is
|
|
230
|
+
if (typeof input === 'object' && input !== null && !Array.isArray(input)) {
|
|
231
|
+
return input;
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
// Prisma-style shorthand: profileId: 'abc' -> { equals: 'abc' }
|
|
235
|
+
return { equals: input };
|
|
236
|
+
}, opsSchema)
|
|
237
|
+
.optional();
|
|
238
|
+
};
|
|
239
|
+
|
|
240
|
+
const fieldFilters = Object.fromEntries(Object.entries(fields).map(([key, value]) => [key, makeFieldFilter(value)]));
|
|
241
|
+
|
|
242
|
+
if (depth <= 0) {
|
|
243
|
+
// Base case: no AND/OR/NOT
|
|
244
|
+
return zod.object({
|
|
245
|
+
...fieldFilters,
|
|
246
|
+
});
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
return zod.object({
|
|
250
|
+
AND: zod.array(zod.lazy(() => createPrismaWhereSchema(modelSchema, depth - 1))).optional(),
|
|
251
|
+
OR: zod.array(zod.lazy(() => createPrismaWhereSchema(modelSchema, depth - 1))).optional(),
|
|
252
|
+
NOT: zod.array(zod.lazy(() => createPrismaWhereSchema(modelSchema, depth - 1))).optional(),
|
|
253
|
+
...fieldFilters,
|
|
254
|
+
});
|
|
255
|
+
};
|
|
256
|
+
|
|
257
|
+
export const getQueryOutput = <T extends zod.ZodTypeAny>(data: T) => {
|
|
258
|
+
return z.object({ status: z.number(), data: data.optional(), error: z.string().optional() });
|
|
259
|
+
};
|
|
260
|
+
|
|
261
|
+
export const getQueryInput = <S extends zod.ZodTypeAny>(schema: S, options: { partialData?: boolean } = {}) => {
|
|
262
|
+
const { partialData = true } = options;
|
|
263
|
+
|
|
264
|
+
// Only object schemas get "where" support.
|
|
265
|
+
const isObjectSchema = schema instanceof zod.ZodObject;
|
|
266
|
+
|
|
267
|
+
const whereSchema = isObjectSchema
|
|
268
|
+
? createPrismaWhereSchema(schema as any) // keep your existing recursive builder
|
|
269
|
+
: zod.never(); // not used; also prevents people from sending "where" for arrays
|
|
270
|
+
|
|
271
|
+
const dataSchema = isObjectSchema
|
|
272
|
+
? partialData
|
|
273
|
+
? (schema as any).partial().optional()
|
|
274
|
+
: (schema as any).optional()
|
|
275
|
+
: schema.optional(); // arrays: allow full array
|
|
276
|
+
|
|
277
|
+
const querySchema = zod
|
|
278
|
+
.object({
|
|
279
|
+
data: dataSchema,
|
|
280
|
+
|
|
281
|
+
// keep your query envelope fields
|
|
282
|
+
skip: zod.number().default(0).optional(),
|
|
283
|
+
limit: zod.number().default(10).optional(),
|
|
284
|
+
cursor: zod.record(zod.any()).optional(),
|
|
285
|
+
|
|
286
|
+
// only valid for object schemas
|
|
287
|
+
where: isObjectSchema ? whereSchema.optional() : zod.undefined().optional(),
|
|
288
|
+
|
|
289
|
+
orderBy: zod.record(zod.enum(['asc', 'desc'])).optional(),
|
|
290
|
+
include: zod.record(zod.boolean()).optional(),
|
|
291
|
+
select: zod.record(zod.boolean()).optional(),
|
|
292
|
+
})
|
|
293
|
+
.partial();
|
|
294
|
+
|
|
295
|
+
return zod.union([querySchema, zod.undefined()]);
|
|
296
|
+
};
|
|
297
|
+
|
|
298
|
+
export type inferQuery<T extends zod.ZodRawShape> = zod.infer<ReturnType<typeof createPrismaWhereSchema<T>>>;
|
|
299
|
+
|
|
300
|
+
export type GetInferenceHelpers<
|
|
301
|
+
TType extends 'input' | 'output',
|
|
302
|
+
TRoot extends AnyTRPCClientTypes,
|
|
303
|
+
TRecord extends TRPCRouterRecord
|
|
304
|
+
> = {
|
|
305
|
+
[TKey in keyof TRecord]: TRecord[TKey] extends infer $Value
|
|
306
|
+
? $Value extends TRPCRouterRecord
|
|
307
|
+
? GetInferenceHelpers<TType, TRoot, $Value>
|
|
308
|
+
: $Value extends AnyProcedure
|
|
309
|
+
? inferProcedureOutput<$Value> // inferTransformedProcedureOutput<TRoot, $Value>
|
|
310
|
+
: never
|
|
311
|
+
: never;
|
|
312
|
+
};
|
|
313
|
+
|
|
314
|
+
export type inferRouterOutputs<TRouter extends AnyRouter> = GetInferenceHelpers<
|
|
315
|
+
'output',
|
|
316
|
+
TRouter['_def']['_config']['$types'],
|
|
317
|
+
TRouter['_def']['record']
|
|
318
|
+
>;
|
|
319
|
+
|
|
320
|
+
// type SpecificOutput = Router['_def']['record']['createInterfaceDraft']['_def']['$types']['output'];
|
|
321
|
+
// type TestOutput = RouterOutput['createInterfaceDraft'];
|
package/skill/index.ts
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import * as mongo from '@arken/node/mongo';
|
|
2
|
+
import type * as Types from './skill.types';
|
|
3
|
+
|
|
4
|
+
export const Skill = mongo.createModel<Types.SkillDocument>('Skill', {});
|
|
5
|
+
|
|
6
|
+
export const SkillMod = mongo.createModel<Types.SkillModDocument>('SkillMod', {});
|
|
7
|
+
|
|
8
|
+
export const SkillClassification = mongo.createModel<Types.SkillClassificationDocument>('SkillClassification', {});
|
|
9
|
+
|
|
10
|
+
export const SkillCondition = mongo.createModel<Types.SkillConditionDocument>('SkillCondition', {});
|
|
11
|
+
|
|
12
|
+
export const SkillStatusEffect = mongo.createModel<Types.SkillStatusEffectDocument>('SkillStatusEffect', {});
|
|
13
|
+
|
|
14
|
+
export const SkillTree = mongo.createModel<Types.SkillTreeDocument>('SkillTree', {});
|
|
15
|
+
|
|
16
|
+
export const SkillTreeNode = mongo.createModel<Types.SkillTreeNodeDocument>('SkillTreeNode', {});
|
|
@@ -0,0 +1,201 @@
|
|
|
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 {
|
|
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,52 @@
|
|
|
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
|
|
7
|
+
.string()
|
|
8
|
+
.min(1)
|
|
9
|
+
.optional(),
|
|
10
|
+
type: z.enum(['attack', 'defense', 'utility']),
|
|
11
|
+
cooldown: z
|
|
12
|
+
.number()
|
|
13
|
+
.min(0)
|
|
14
|
+
.optional(),
|
|
15
|
+
power: z
|
|
16
|
+
.number()
|
|
17
|
+
.min(0)
|
|
18
|
+
.optional(),
|
|
19
|
+
})
|
|
20
|
+
);
|
|
21
|
+
|
|
22
|
+
export const SkillEffect = Entity.merge(
|
|
23
|
+
z.object({
|
|
24
|
+
skillId: ObjectId, // Reference to the associated Skill
|
|
25
|
+
effectType: z.enum(['damage', 'heal', 'buff', 'debuff']),
|
|
26
|
+
magnitude: z.number().min(0),
|
|
27
|
+
duration: z
|
|
28
|
+
.number()
|
|
29
|
+
.min(0)
|
|
30
|
+
.optional(),
|
|
31
|
+
})
|
|
32
|
+
);
|
|
33
|
+
|
|
34
|
+
export const SkillRequirement = Entity.merge(
|
|
35
|
+
z.object({
|
|
36
|
+
skillId: ObjectId, // Reference to the associated Skill
|
|
37
|
+
levelRequired: z.number().min(1),
|
|
38
|
+
previousSkillId: ObjectId.optional(), // Reference to a prerequisite skill
|
|
39
|
+
})
|
|
40
|
+
);
|
|
41
|
+
|
|
42
|
+
export const SkillMod = Entity.merge(z.object({}));
|
|
43
|
+
|
|
44
|
+
export const SkillClassification = Entity.merge(z.object({}));
|
|
45
|
+
|
|
46
|
+
export const SkillCondition = Entity.merge(z.object({}));
|
|
47
|
+
|
|
48
|
+
export const SkillStatusEffect = Entity.merge(z.object({}));
|
|
49
|
+
|
|
50
|
+
export const SkillTree = Entity.merge(z.object({}));
|
|
51
|
+
|
|
52
|
+
export const SkillTreeNode = Entity.merge(z.object({}));
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import * as schema from './skill.schema';
|
|
3
|
+
import { Document, Model } from '@arken/node/mongo';
|
|
4
|
+
|
|
5
|
+
export type * from './skill.router';
|
|
6
|
+
export type { RouterContext } from '../types';
|
|
7
|
+
|
|
8
|
+
export type Skill = z.infer<typeof schema.Skill>;
|
|
9
|
+
export type SkillMod = z.infer<typeof schema.SkillMod>;
|
|
10
|
+
export type SkillClassification = z.infer<typeof schema.SkillClassification>;
|
|
11
|
+
export type SkillCondition = z.infer<typeof schema.SkillCondition>;
|
|
12
|
+
export type SkillStatusEffect = z.infer<typeof schema.SkillStatusEffect>;
|
|
13
|
+
export type SkillTree = z.infer<typeof schema.SkillTree>;
|
|
14
|
+
export type SkillTreeNode = z.infer<typeof schema.SkillTreeNode>;
|
|
15
|
+
|
|
16
|
+
export type SkillDocument = Skill & Document;
|
|
17
|
+
export type SkillModDocument = SkillMod & Document;
|
|
18
|
+
export type SkillClassificationDocument = SkillClassification & Document;
|
|
19
|
+
export type SkillConditionDocument = SkillCondition & Document;
|
|
20
|
+
export type SkillStatusEffectDocument = SkillStatusEffect & Document;
|
|
21
|
+
export type SkillTreeDocument = SkillTree & Document;
|
|
22
|
+
export type SkillTreeNodeDocument = SkillTreeNode & Document;
|
|
23
|
+
|
|
24
|
+
export type Mappings = {
|
|
25
|
+
Skill: Model<SkillDocument>;
|
|
26
|
+
SkillMod: Model<SkillModDocument>;
|
|
27
|
+
SkillClassification: Model<SkillClassificationDocument>;
|
|
28
|
+
SkillCondition: Model<SkillConditionDocument>;
|
|
29
|
+
SkillStatusEffect: Model<SkillStatusEffectDocument>;
|
|
30
|
+
SkillTree: Model<SkillTreeDocument>;
|
|
31
|
+
SkillTreeNode: Model<SkillTreeNodeDocument>;
|
|
32
|
+
};
|
package/trek/index.ts
CHANGED
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,9 +2,9 @@
|
|
|
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
|
-
import type { RouterContext } from '
|
|
7
|
+
import type { RouterContext } from '../types';
|
|
8
8
|
|
|
9
9
|
export const z = zod;
|
|
10
10
|
export const t = initTRPC.context<RouterContext>().create();
|
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';
|