@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
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { z as zod } from 'zod';
|
|
2
|
+
import { initTRPC, inferRouterInputs } from '@trpc/server';
|
|
3
|
+
import { customErrorFormatter, hasRole } from '@arken/node/rpc';
|
|
4
|
+
import type { RouterContext } from '../types';
|
|
5
|
+
import { Profile } from './profile.schema';
|
|
6
|
+
import { Query, getQueryInput, getQueryOutput, inferRouterOutputs } from '../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
|
+
setProfileMode: procedure
|
|
16
|
+
.use(hasRole('user', t))
|
|
17
|
+
.use(customErrorFormatter(t))
|
|
18
|
+
.input(z.string())
|
|
19
|
+
.mutation(({ input, ctx }) => (ctx.app.service.Profile.setProfileMode as any)(input, ctx)),
|
|
20
|
+
|
|
21
|
+
// Profile endpoints
|
|
22
|
+
me: procedure
|
|
23
|
+
.use(hasRole('user', t))
|
|
24
|
+
.use(customErrorFormatter(t))
|
|
25
|
+
// .output(Profile.partial())
|
|
26
|
+
.query(({ input, ctx }) => (ctx.app.service.Profile.me as any)(input, ctx)),
|
|
27
|
+
|
|
28
|
+
// Profile endpoints
|
|
29
|
+
getProfile: procedure
|
|
30
|
+
.use(hasRole('guest', t))
|
|
31
|
+
.use(customErrorFormatter(t))
|
|
32
|
+
.input(getQueryInput(Profile))
|
|
33
|
+
// .output(Profile.partial())
|
|
34
|
+
.query(({ input, ctx }) => (ctx.app.service.Profile.getProfile as any)(input, ctx)),
|
|
35
|
+
|
|
36
|
+
getProfiles: procedure
|
|
37
|
+
.use(hasRole('guest', t))
|
|
38
|
+
.use(customErrorFormatter(t))
|
|
39
|
+
.input(getQueryInput(Profile))
|
|
40
|
+
.output(z.array(Profile))
|
|
41
|
+
.query(({ input, ctx }) => (ctx.app.service.Profile.getProfiles as any)(input, ctx)),
|
|
42
|
+
|
|
43
|
+
createProfile: procedure
|
|
44
|
+
.use(hasRole('user', t))
|
|
45
|
+
.use(customErrorFormatter(t))
|
|
46
|
+
.input(getQueryInput(Profile))
|
|
47
|
+
.output(Profile.partial())
|
|
48
|
+
.mutation(({ input, ctx }) => (ctx.app.service.Profile.createProfile as any)(input, ctx)),
|
|
49
|
+
|
|
50
|
+
updateProfile: procedure
|
|
51
|
+
.use(hasRole('user', t))
|
|
52
|
+
.use(customErrorFormatter(t))
|
|
53
|
+
.input(getQueryInput(Profile))
|
|
54
|
+
.output(Profile.partial())
|
|
55
|
+
.mutation(({ input, ctx }) => (ctx.app.service.Profile.updateProfile as any)(input, ctx)),
|
|
56
|
+
|
|
57
|
+
getProfileStats: procedure
|
|
58
|
+
.use(hasRole('guest', t))
|
|
59
|
+
.use(customErrorFormatter(t))
|
|
60
|
+
.input(z.object({ query: Query }))
|
|
61
|
+
.query(({ input, ctx }) => (ctx.app.service.Profile.getProfileStats as any)(input, ctx)),
|
|
62
|
+
|
|
63
|
+
updateProfileSettings: procedure
|
|
64
|
+
.use(hasRole('user', t))
|
|
65
|
+
.use(customErrorFormatter(t))
|
|
66
|
+
.input(z.object({ query: Query, settings: Profile.shape.settings }))
|
|
67
|
+
.mutation(({ input, ctx }) => (ctx.app.service.Profile.updateProfileSettings as any)(input, ctx)),
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
export type Router = ReturnType<typeof createRouter>;
|
|
71
|
+
export type RouterInput = inferRouterInputs<Router>;
|
|
72
|
+
export type RouterOutput = inferRouterOutputs<Router>;
|
|
@@ -0,0 +1,219 @@
|
|
|
1
|
+
// profile.schema.ts
|
|
2
|
+
//
|
|
3
|
+
import { z, ObjectId, Entity } from '../schema';
|
|
4
|
+
import { Character } from '../character/character.schema';
|
|
5
|
+
import { Achievement, Badge } from '../core/core.schema';
|
|
6
|
+
|
|
7
|
+
const RankingStatSchema = z.object({
|
|
8
|
+
total: z.number(),
|
|
9
|
+
position: z.number(),
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
// Define the Ranking schema
|
|
13
|
+
const RankingSchema = z.object({
|
|
14
|
+
orbs: RankingStatSchema,
|
|
15
|
+
wins: RankingStatSchema,
|
|
16
|
+
kills: RankingStatSchema,
|
|
17
|
+
deaths: RankingStatSchema,
|
|
18
|
+
points: RankingStatSchema,
|
|
19
|
+
rounds: RankingStatSchema,
|
|
20
|
+
evolves: RankingStatSchema,
|
|
21
|
+
rewards: RankingStatSchema,
|
|
22
|
+
powerups: RankingStatSchema,
|
|
23
|
+
revenges: RankingStatSchema,
|
|
24
|
+
winRatio: RankingStatSchema,
|
|
25
|
+
timeSpent: RankingStatSchema,
|
|
26
|
+
averageLatency: RankingStatSchema,
|
|
27
|
+
killDeathRatio: RankingStatSchema,
|
|
28
|
+
roundPointRatio: RankingStatSchema,
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
const ServerDataSchema = z.object({
|
|
32
|
+
orbs: z.number().optional(),
|
|
33
|
+
wins: z.number().optional(),
|
|
34
|
+
kills: z.number().optional(),
|
|
35
|
+
deaths: z.number().optional(),
|
|
36
|
+
points: z.number().optional(),
|
|
37
|
+
rounds: z.number().optional(),
|
|
38
|
+
evolves: z.number().optional(),
|
|
39
|
+
ranking: RankingSchema.optional(),
|
|
40
|
+
rewards: z.number().optional(),
|
|
41
|
+
earnings: z.number().optional(),
|
|
42
|
+
powerups: z.number().optional(),
|
|
43
|
+
revenges: z.number().optional(),
|
|
44
|
+
winRatio: z.number().optional(),
|
|
45
|
+
timeSpent: z.number().optional(),
|
|
46
|
+
winStreak: z.number().optional(),
|
|
47
|
+
averageLatency: z
|
|
48
|
+
.number()
|
|
49
|
+
.nullable()
|
|
50
|
+
.optional(),
|
|
51
|
+
killDeathRatio: z.number().optional(),
|
|
52
|
+
roundPointRatio: z.number().optional(),
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
// Profile schema for a user on a digital game platform
|
|
56
|
+
export const Profile = Entity.merge(
|
|
57
|
+
z.object({
|
|
58
|
+
accountId: ObjectId.optional(), // TODO; fix?
|
|
59
|
+
partyId: ObjectId.optional(),
|
|
60
|
+
points: z.number().optional(),
|
|
61
|
+
// currency: z.number().optional(),
|
|
62
|
+
telegramUserId: z.number().optional(),
|
|
63
|
+
interactions: z.number().default(0),
|
|
64
|
+
activityRating: z.number().default(0),
|
|
65
|
+
address: z
|
|
66
|
+
.string()
|
|
67
|
+
.max(100)
|
|
68
|
+
.optional(),
|
|
69
|
+
avatar: z
|
|
70
|
+
.string()
|
|
71
|
+
.max(100)
|
|
72
|
+
.optional(),
|
|
73
|
+
roleId: ObjectId.optional(),
|
|
74
|
+
privateKey: z
|
|
75
|
+
.string()
|
|
76
|
+
.max(300)
|
|
77
|
+
.optional(),
|
|
78
|
+
signature: z
|
|
79
|
+
.string()
|
|
80
|
+
.max(200)
|
|
81
|
+
.optional(),
|
|
82
|
+
chainId: ObjectId.optional(),
|
|
83
|
+
teamId: ObjectId.optional(),
|
|
84
|
+
characterId: ObjectId.optional(),
|
|
85
|
+
isBanned: z.boolean().optional(),
|
|
86
|
+
banExpireDate: z.date().optional(),
|
|
87
|
+
banReason: z.string().optional(),
|
|
88
|
+
mode: z
|
|
89
|
+
.string()
|
|
90
|
+
.default('gamer')
|
|
91
|
+
.optional(),
|
|
92
|
+
|
|
93
|
+
bio: z.string().optional(),
|
|
94
|
+
banner: z
|
|
95
|
+
.string()
|
|
96
|
+
.url()
|
|
97
|
+
.optional(), // URL to the user's banner image
|
|
98
|
+
friends: z
|
|
99
|
+
.array(
|
|
100
|
+
z.object({
|
|
101
|
+
friend: z.lazy(() => Profile),
|
|
102
|
+
meta: z.any().optional(),
|
|
103
|
+
})
|
|
104
|
+
)
|
|
105
|
+
.optional(),
|
|
106
|
+
achievements: z
|
|
107
|
+
.array(
|
|
108
|
+
z.object({
|
|
109
|
+
achievementId: ObjectId,
|
|
110
|
+
meta: z.any().optional(),
|
|
111
|
+
current: z.number().default(0),
|
|
112
|
+
})
|
|
113
|
+
)
|
|
114
|
+
.optional(),
|
|
115
|
+
badges: z
|
|
116
|
+
.array(
|
|
117
|
+
z.object({
|
|
118
|
+
badgeId: ObjectId,
|
|
119
|
+
meta: z.any().optional(),
|
|
120
|
+
})
|
|
121
|
+
)
|
|
122
|
+
.optional(),
|
|
123
|
+
character: Character.optional(),
|
|
124
|
+
characters: z.array(ObjectId.optional()).optional(),
|
|
125
|
+
settings: z
|
|
126
|
+
.object({
|
|
127
|
+
warp: z.any().default({}),
|
|
128
|
+
designer: z.any().default({}),
|
|
129
|
+
privacy: z.enum(['public', 'private', 'friends-only']).default('public'),
|
|
130
|
+
notifications: z.boolean().default(true),
|
|
131
|
+
})
|
|
132
|
+
.optional(),
|
|
133
|
+
stats: z
|
|
134
|
+
.object({
|
|
135
|
+
gamesOwned: z
|
|
136
|
+
.number()
|
|
137
|
+
.int()
|
|
138
|
+
.nonnegative()
|
|
139
|
+
.default(0),
|
|
140
|
+
playedMinutes: z
|
|
141
|
+
.number()
|
|
142
|
+
.nonnegative()
|
|
143
|
+
.default(0), // Total playtime in hours
|
|
144
|
+
leveledUpCount: z
|
|
145
|
+
.number()
|
|
146
|
+
.int()
|
|
147
|
+
.nonnegative()
|
|
148
|
+
.default(0),
|
|
149
|
+
xpEarnedCount: z
|
|
150
|
+
.number()
|
|
151
|
+
.int()
|
|
152
|
+
.nonnegative()
|
|
153
|
+
.default(0),
|
|
154
|
+
craftedItemCount: z
|
|
155
|
+
.number()
|
|
156
|
+
.int()
|
|
157
|
+
.nonnegative()
|
|
158
|
+
.default(0),
|
|
159
|
+
equippedItemCount: z
|
|
160
|
+
.number()
|
|
161
|
+
.int()
|
|
162
|
+
.nonnegative()
|
|
163
|
+
.default(0),
|
|
164
|
+
transferredInCount: z
|
|
165
|
+
.number()
|
|
166
|
+
.int()
|
|
167
|
+
.nonnegative()
|
|
168
|
+
.default(0),
|
|
169
|
+
transferredOutCount: z
|
|
170
|
+
.number()
|
|
171
|
+
.int()
|
|
172
|
+
.nonnegative()
|
|
173
|
+
.default(0),
|
|
174
|
+
marketTradeSoldCount: z
|
|
175
|
+
.number()
|
|
176
|
+
.int()
|
|
177
|
+
.nonnegative()
|
|
178
|
+
.default(0),
|
|
179
|
+
marketTradeListedCount: z
|
|
180
|
+
.number()
|
|
181
|
+
.int()
|
|
182
|
+
.nonnegative()
|
|
183
|
+
.default(0),
|
|
184
|
+
evolution: z
|
|
185
|
+
.object({
|
|
186
|
+
hashes: z.array(z.string()).default([]),
|
|
187
|
+
overall: z
|
|
188
|
+
.object({
|
|
189
|
+
orbs: z.number().optional(),
|
|
190
|
+
wins: z.number().optional(),
|
|
191
|
+
kills: z.number().optional(),
|
|
192
|
+
deaths: z.number().optional(),
|
|
193
|
+
points: z.number().optional(),
|
|
194
|
+
rounds: z.number().optional(),
|
|
195
|
+
evolves: z.number().optional(),
|
|
196
|
+
ranking: RankingSchema.optional(),
|
|
197
|
+
rewards: z.number().optional(),
|
|
198
|
+
earnings: z.number().optional(),
|
|
199
|
+
powerups: z.number().optional(),
|
|
200
|
+
revenges: z.number().optional(),
|
|
201
|
+
winRatio: z.number().optional(),
|
|
202
|
+
timeSpent: z.number().optional(),
|
|
203
|
+
winStreak: z.number().optional(),
|
|
204
|
+
averageLatency: z
|
|
205
|
+
.number()
|
|
206
|
+
.optional()
|
|
207
|
+
.nullable(),
|
|
208
|
+
killDeathRatio: z.number().optional(),
|
|
209
|
+
roundPointRatio: z.number().optional(),
|
|
210
|
+
})
|
|
211
|
+
.default({}),
|
|
212
|
+
servers: z.record(ServerDataSchema).optional(),
|
|
213
|
+
lastUpdated: z.number().optional(),
|
|
214
|
+
})
|
|
215
|
+
.optional(),
|
|
216
|
+
})
|
|
217
|
+
.optional(),
|
|
218
|
+
})
|
|
219
|
+
);
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
// profile.types.ts
|
|
2
|
+
//
|
|
3
|
+
import { z } from 'zod';
|
|
4
|
+
import * as schema from './profile.schema';
|
|
5
|
+
import { Document, Model } from '@arken/node/mongo';
|
|
6
|
+
import type { RouterContext } from '../types';
|
|
7
|
+
import type { inferRouterInputs, inferRouterOutputs } from '@trpc/server';
|
|
8
|
+
import type { Router } from './profile.router';
|
|
9
|
+
|
|
10
|
+
export type * from './profile.router';
|
|
11
|
+
export type { RouterContext };
|
|
12
|
+
|
|
13
|
+
export type Profile = z.infer<typeof schema.Profile>;
|
|
14
|
+
export type ProfileDocument = Profile & Document;
|
|
15
|
+
|
|
16
|
+
export type Mappings = {
|
|
17
|
+
Profile: Model<ProfileDocument>;
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
export type RouterInput = inferRouterInputs<Router>;
|
|
21
|
+
export type RouterOutput = inferRouterOutputs<Router>;
|
package/raffle/index.ts
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import * as mongo from '@arken/node/mongo';
|
|
2
|
+
import type * as Types from './raffle.types';
|
|
3
|
+
|
|
4
|
+
export const Raffle = mongo.createModel<Types.RaffleDocument>(
|
|
5
|
+
'Raffle',
|
|
6
|
+
{
|
|
7
|
+
content: { type: String, required: true },
|
|
8
|
+
rewards: [{ type: mongo.Schema.Types.ObjectId, ref: 'RaffleReward' }],
|
|
9
|
+
},
|
|
10
|
+
{
|
|
11
|
+
virtuals: [
|
|
12
|
+
{
|
|
13
|
+
name: 'raffleRequirements',
|
|
14
|
+
ref: 'RaffleRequirement',
|
|
15
|
+
localField: '_id',
|
|
16
|
+
foreignField: 'raffleId',
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
name: 'raffleEntries',
|
|
20
|
+
ref: 'RaffleEntry',
|
|
21
|
+
localField: '_id',
|
|
22
|
+
foreignField: 'raffleId',
|
|
23
|
+
},
|
|
24
|
+
],
|
|
25
|
+
}
|
|
26
|
+
);
|
|
27
|
+
|
|
28
|
+
export const RaffleRequirement = mongo.createModel<Types.RaffleRequirementDocument>('RaffleRequirement', {
|
|
29
|
+
amount: { type: Number, required: true },
|
|
30
|
+
raffleRewardId: { type: mongo.Schema.Types.ObjectId, ref: 'RaffleReward' },
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
export const RaffleReward = mongo.createModel<Types.RaffleRewardDocument>('RaffleReward', {
|
|
34
|
+
raffleId: { type: mongo.Schema.Types.ObjectId, ref: 'Raffle' },
|
|
35
|
+
winnerId: { type: mongo.Schema.Types.ObjectId, ref: 'Profile' },
|
|
36
|
+
requirements: [{ type: mongo.Schema.Types.ObjectId, ref: 'RaffleRequirement' }],
|
|
37
|
+
entries: [{ type: mongo.Schema.Types.ObjectId, ref: 'RaffleEntry' }],
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
export const RaffleEntry = mongo.createModel<Types.RaffleEntryDocument>('RaffleEntry', {
|
|
41
|
+
amount: { type: Number, required: true },
|
|
42
|
+
raffleRewardId: { type: mongo.Schema.Types.ObjectId, ref: 'RaffleReward' },
|
|
43
|
+
raffleId: { type: mongo.Schema.Types.ObjectId, ref: 'Raffle' },
|
|
44
|
+
});
|
|
@@ -0,0 +1,90 @@
|
|
|
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 { Raffle, RaffleRequirement, RaffleReward, RaffleEntry } from './raffle.schema';
|
|
6
|
+
|
|
7
|
+
export const z = zod;
|
|
8
|
+
export const t = initTRPC.context<RouterContext>().create();
|
|
9
|
+
export const router = t.router;
|
|
10
|
+
export const procedure = t.procedure;
|
|
11
|
+
|
|
12
|
+
export const createRouter = () =>
|
|
13
|
+
router({
|
|
14
|
+
// Raffle endpoints
|
|
15
|
+
getRaffle: procedure
|
|
16
|
+
.use(hasRole('guest', t))
|
|
17
|
+
.use(customErrorFormatter(t))
|
|
18
|
+
.input(z.object({ raffleId: z.string() }))
|
|
19
|
+
.query(({ input, ctx }) => (ctx.app.service.Raffle.getRaffle as any)(input, ctx)),
|
|
20
|
+
|
|
21
|
+
createRaffle: procedure
|
|
22
|
+
.use(hasRole('admin', t))
|
|
23
|
+
.use(customErrorFormatter(t))
|
|
24
|
+
.input(Raffle)
|
|
25
|
+
.mutation(({ input, ctx }) => (ctx.app.service.Raffle.createRaffle as any)(input, ctx)),
|
|
26
|
+
|
|
27
|
+
updateRaffle: procedure
|
|
28
|
+
.use(hasRole('admin', t))
|
|
29
|
+
.use(customErrorFormatter(t))
|
|
30
|
+
.input(z.object({ raffleId: z.string(), data: Raffle.partial() }))
|
|
31
|
+
.mutation(({ input, ctx }) => (ctx.app.service.Raffle.updateRaffle as any)(input, ctx)),
|
|
32
|
+
|
|
33
|
+
getRaffleRequirement: procedure
|
|
34
|
+
.use(hasRole('guest', t))
|
|
35
|
+
.use(customErrorFormatter(t))
|
|
36
|
+
.input(z.object({ raffleRequirementId: z.string() }))
|
|
37
|
+
.query(({ input, ctx }) => (ctx.app.service.Raffle.getRaffleRequirement as any)(input, ctx)),
|
|
38
|
+
|
|
39
|
+
createRaffleRequirement: procedure
|
|
40
|
+
.use(hasRole('admin', t))
|
|
41
|
+
.use(customErrorFormatter(t))
|
|
42
|
+
.input(RaffleRequirement)
|
|
43
|
+
.mutation(({ input, ctx }) => (ctx.app.service.Raffle.createRaffleRequirement as any)(input, ctx)),
|
|
44
|
+
|
|
45
|
+
updateRaffleRequirement: procedure
|
|
46
|
+
.use(hasRole('admin', t))
|
|
47
|
+
.use(customErrorFormatter(t))
|
|
48
|
+
.input(z.object({ raffleRequirementId: z.string(), data: RaffleRequirement.partial() }))
|
|
49
|
+
.mutation(({ input, ctx }) => (ctx.app.service.Raffle.updateRaffleRequirement as any)(input, ctx)),
|
|
50
|
+
|
|
51
|
+
getRaffleReward: procedure
|
|
52
|
+
.use(hasRole('guest', t))
|
|
53
|
+
.use(customErrorFormatter(t))
|
|
54
|
+
.input(z.object({ raffleRewardId: z.string() }))
|
|
55
|
+
.query(({ input, ctx }) => (ctx.app.service.Raffle.getRaffleReward as any)(input, ctx)),
|
|
56
|
+
|
|
57
|
+
createRaffleReward: procedure
|
|
58
|
+
.use(hasRole('admin', t))
|
|
59
|
+
.use(customErrorFormatter(t))
|
|
60
|
+
.input(RaffleReward)
|
|
61
|
+
.mutation(({ input, ctx }) => (ctx.app.service.Raffle.createRaffleReward as any)(input, ctx)),
|
|
62
|
+
|
|
63
|
+
updateRaffleReward: procedure
|
|
64
|
+
.use(hasRole('admin', t))
|
|
65
|
+
.use(customErrorFormatter(t))
|
|
66
|
+
.input(z.object({ raffleRewardId: z.string(), data: RaffleReward.partial() }))
|
|
67
|
+
.mutation(({ input, ctx }) => (ctx.app.service.Raffle.updateRaffleReward as any)(input, ctx)),
|
|
68
|
+
|
|
69
|
+
getRaffleEntry: procedure
|
|
70
|
+
.use(hasRole('guest', t))
|
|
71
|
+
.use(customErrorFormatter(t))
|
|
72
|
+
.input(z.object({ raffleEntryId: z.string() }))
|
|
73
|
+
.query(({ input, ctx }) => (ctx.app.service.Raffle.getRaffleEntry as any)(input, ctx)),
|
|
74
|
+
|
|
75
|
+
createRaffleEntry: procedure
|
|
76
|
+
.use(hasRole('admin', t))
|
|
77
|
+
.use(customErrorFormatter(t))
|
|
78
|
+
.input(RaffleEntry)
|
|
79
|
+
.mutation(({ input, ctx }) => (ctx.app.service.Raffle.createRaffleEntry as any)(input, ctx)),
|
|
80
|
+
|
|
81
|
+
updateRaffleEntry: procedure
|
|
82
|
+
.use(hasRole('admin', t))
|
|
83
|
+
.use(customErrorFormatter(t))
|
|
84
|
+
.input(z.object({ raffleEntryId: z.string(), data: RaffleEntry.partial() }))
|
|
85
|
+
.mutation(({ input, ctx }) => (ctx.app.service.Raffle.updateRaffleEntry as any)(input, ctx)),
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
export type Router = ReturnType<typeof createRouter>;
|
|
89
|
+
export type RouterInput = inferRouterInputs<Router>;
|
|
90
|
+
export type RouterOutput = inferRouterOutputs<Router>;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { z, ObjectId, Entity } from '../schema';
|
|
2
|
+
|
|
3
|
+
export const Raffle = Entity.merge(
|
|
4
|
+
z.object({
|
|
5
|
+
content: z.string().min(1),
|
|
6
|
+
rewards: z.array(ObjectId).optional(), // List of reward IDs
|
|
7
|
+
})
|
|
8
|
+
);
|
|
9
|
+
|
|
10
|
+
export const RaffleRequirement = Entity.merge(
|
|
11
|
+
z.object({
|
|
12
|
+
amount: z.number().min(1),
|
|
13
|
+
raffleRewardId: ObjectId.optional(), // Reference to the associated RaffleReward
|
|
14
|
+
})
|
|
15
|
+
);
|
|
16
|
+
|
|
17
|
+
export const RaffleReward = Entity.merge(
|
|
18
|
+
z.object({
|
|
19
|
+
raffleId: ObjectId.optional(), // Reference to the associated Raffle
|
|
20
|
+
winnerId: ObjectId.optional(), // Reference to the winning Profile
|
|
21
|
+
requirements: z.array(ObjectId).optional(), // List of associated RaffleRequirement IDs
|
|
22
|
+
entries: z.array(ObjectId).optional(), // List of associated RaffleEntry IDs
|
|
23
|
+
})
|
|
24
|
+
);
|
|
25
|
+
|
|
26
|
+
export const RaffleEntry = Entity.merge(
|
|
27
|
+
z.object({
|
|
28
|
+
amount: z.number().min(1),
|
|
29
|
+
raffleRewardId: ObjectId.optional(), // Reference to the associated RaffleReward
|
|
30
|
+
raffleId: ObjectId.optional(), // Reference to the associated Raffle
|
|
31
|
+
})
|
|
32
|
+
);
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import * as schema from './raffle.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 './raffle.router';
|
|
7
|
+
|
|
8
|
+
export type * from './raffle.router';
|
|
9
|
+
export type { RouterContext };
|
|
10
|
+
|
|
11
|
+
export type Raffle = z.infer<typeof schema.Raffle>;
|
|
12
|
+
export type RaffleRequirement = z.infer<typeof schema.RaffleRequirement>;
|
|
13
|
+
export type RaffleReward = z.infer<typeof schema.RaffleReward>;
|
|
14
|
+
export type RaffleEntry = z.infer<typeof schema.RaffleEntry>;
|
|
15
|
+
|
|
16
|
+
export type RaffleDocument = Raffle & Document;
|
|
17
|
+
export type RaffleRequirementDocument = RaffleRequirement & Document;
|
|
18
|
+
export type RaffleRewardDocument = RaffleReward & Document;
|
|
19
|
+
export type RaffleEntryDocument = RaffleEntry & Document;
|
|
20
|
+
|
|
21
|
+
export type Mappings = {
|
|
22
|
+
Raffle: Model<RaffleDocument>;
|
|
23
|
+
RaffleRequirement: Model<RaffleRequirementDocument>;
|
|
24
|
+
RaffleReward: Model<RaffleRewardDocument>;
|
|
25
|
+
RaffleEntry: Model<RaffleEntryDocument>;
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
export type RouterInput = inferRouterInputs<Router>;
|
|
29
|
+
export type RouterOutput = inferRouterOutputs<Router>;
|
package/router.ts
CHANGED
|
@@ -1,34 +1,28 @@
|
|
|
1
|
-
import util from '@arken/util';
|
|
2
1
|
import { initTRPC } from '@trpc/server';
|
|
3
|
-
import { observable } from '@trpc/server/observable';
|
|
4
|
-
import { serialize, deserialize } from '@arken/rpc';
|
|
5
2
|
import { z } from 'zod';
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
import * as
|
|
9
|
-
import * as
|
|
10
|
-
import * as
|
|
11
|
-
import * as
|
|
12
|
-
import * as
|
|
13
|
-
import * as
|
|
14
|
-
import * as
|
|
15
|
-
import * as
|
|
16
|
-
import * as
|
|
17
|
-
import * as
|
|
18
|
-
import * as
|
|
19
|
-
import * as
|
|
20
|
-
import * as
|
|
21
|
-
import * as
|
|
22
|
-
import * as
|
|
23
|
-
import * as
|
|
24
|
-
import * as
|
|
25
|
-
import * as
|
|
26
|
-
import * as
|
|
27
|
-
import * as
|
|
28
|
-
import * as
|
|
29
|
-
import * as Evolution from './modules/evolution/evolution.router';
|
|
30
|
-
import * as Infinite from './modules/infinite/infinite.router';
|
|
31
|
-
import * as Oasis from './modules/oasis/oasis.router';
|
|
3
|
+
import * as Schema from '@arken/node/schema';
|
|
4
|
+
import * as Area from './area/area.router';
|
|
5
|
+
import * as Asset from './asset/asset.router';
|
|
6
|
+
import * as Character from './character/character.router';
|
|
7
|
+
import * as Chain from './chain/chain.router';
|
|
8
|
+
import * as Chat from './chat/chat.router';
|
|
9
|
+
import * as Collection from './collection/collection.router';
|
|
10
|
+
import * as Core from './core/core.router';
|
|
11
|
+
import * as Game from './game/game.router';
|
|
12
|
+
import * as Interface from './interface/interface.router';
|
|
13
|
+
import * as Item from './item/item.router';
|
|
14
|
+
import * as Job from './job/job.router';
|
|
15
|
+
import * as Market from './market/market.router';
|
|
16
|
+
import * as Product from './product/product.router';
|
|
17
|
+
import * as Profile from './profile/profile.router';
|
|
18
|
+
import * as Raffle from './raffle/raffle.router';
|
|
19
|
+
import * as Skill from './skill/skill.router';
|
|
20
|
+
import * as Video from './video/video.router';
|
|
21
|
+
import * as Trek from './trek/trek.router';
|
|
22
|
+
import * as Isles from './isles/isles.router';
|
|
23
|
+
import * as Evolution from './evolution/evolution.router';
|
|
24
|
+
import * as Infinite from './infinite/infinite.router';
|
|
25
|
+
import * as Oasis from './oasis/oasis.router';
|
|
32
26
|
import type * as Types from './types';
|
|
33
27
|
|
|
34
28
|
export type RouterContext = {
|