@arken/node 1.5.1 → 1.5.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/db.ts +76 -1
- package/index.ts +351 -18
- package/package.json +3 -3
- package/tsconfig.json +33 -2
- package/util.ts +1 -0
- package/modules/area/area.models.ts +0 -15
- package/modules/area/area.router.ts +0 -74
- package/modules/area/area.schema.ts +0 -22
- package/modules/area/area.service.ts +0 -124
- package/modules/area/area.types.ts +0 -26
- package/modules/area/index.ts +0 -5
- package/modules/asset/asset.models.ts +0 -59
- package/modules/asset/asset.router.ts +0 -55
- package/modules/asset/asset.schema.ts +0 -27
- package/modules/asset/asset.service.ts +0 -85
- package/modules/asset/asset.types.ts +0 -22
- package/modules/asset/index.ts +0 -5
- package/modules/chain/chain.models.ts +0 -50
- package/modules/chain/chain.router.ts +0 -104
- package/modules/chain/chain.schema.ts +0 -52
- package/modules/chain/chain.service.ts +0 -167
- package/modules/chain/chain.types.ts +0 -24
- package/modules/chain/index.ts +0 -5
- package/modules/character/character.models.ts +0 -174
- package/modules/character/character.router.ts +0 -314
- package/modules/character/character.schema.ts +0 -147
- package/modules/character/character.service.ts +0 -876
- package/modules/character/character.types.ts +0 -64
- package/modules/character/index.ts +0 -5
- package/modules/chat/chat.models.ts +0 -43
- package/modules/chat/chat.router.ts +0 -67
- package/modules/chat/chat.schema.ts +0 -36
- package/modules/chat/chat.service.ts +0 -128
- package/modules/chat/chat.types.ts +0 -20
- package/modules/chat/index.ts +0 -5
- package/modules/collection/collection.models.ts +0 -76
- package/modules/collection/collection.router.ts +0 -91
- package/modules/collection/collection.schema.ts +0 -90
- package/modules/collection/collection.service.ts +0 -192
- package/modules/collection/collection.types.ts +0 -36
- package/modules/collection/index.ts +0 -5
- package/modules/core/core.models.ts +0 -1380
- package/modules/core/core.router.ts +0 -1781
- package/modules/core/core.schema.ts +0 -847
- package/modules/core/core.service.ts +0 -2824
- package/modules/core/core.types.ts +0 -340
- package/modules/core/index.ts +0 -5
- package/modules/core/mail/applyPatchesOrMail.ts +0 -568
- package/modules/core/mail/mailClaimablePatchesBatch.ts +0 -381
- package/modules/game/game.models.ts +0 -53
- package/modules/game/game.router.ts +0 -110
- package/modules/game/game.schema.ts +0 -23
- package/modules/game/game.service.ts +0 -143
- package/modules/game/game.types.ts +0 -28
- package/modules/game/index.ts +0 -5
- package/modules/interface/index.ts +0 -5
- package/modules/interface/interface.canonicalize.ts +0 -279
- package/modules/interface/interface.models.ts +0 -40
- package/modules/interface/interface.router.ts +0 -175
- package/modules/interface/interface.schema.ts +0 -59
- package/modules/interface/interface.service.ts +0 -356
- package/modules/interface/interface.types.ts +0 -25
- package/modules/item/index.ts +0 -5
- package/modules/item/item.models.ts +0 -124
- package/modules/item/item.router.ts +0 -103
- package/modules/item/item.schema.ts +0 -120
- package/modules/item/item.service.ts +0 -167
- package/modules/item/item.types.ts +0 -74
- package/modules/job/index.ts +0 -5
- package/modules/job/job.models.ts +0 -14
- package/modules/job/job.router.ts +0 -44
- package/modules/job/job.schema.ts +0 -9
- package/modules/job/job.service.ts +0 -243
- package/modules/job/job.types.ts +0 -23
- package/modules/market/index.ts +0 -5
- package/modules/market/market.models.ts +0 -113
- package/modules/market/market.router.ts +0 -73
- package/modules/market/market.schema.ts +0 -140
- package/modules/market/market.service.ts +0 -122
- package/modules/market/market.types.ts +0 -56
- package/modules/product/index.ts +0 -5
- package/modules/product/product.models.ts +0 -166
- package/modules/product/product.router.ts +0 -93
- package/modules/product/product.schema.ts +0 -149
- package/modules/product/product.service.ts +0 -160
- package/modules/product/product.types.ts +0 -33
- package/modules/profile/index.ts +0 -5
- package/modules/profile/profile.models.ts +0 -214
- package/modules/profile/profile.router.ts +0 -72
- package/modules/profile/profile.schema.ts +0 -156
- package/modules/profile/profile.service.ts +0 -149
- package/modules/profile/profile.types.ts +0 -22
- package/modules/raffle/index.ts +0 -5
- package/modules/raffle/raffle.models.ts +0 -44
- package/modules/raffle/raffle.router.ts +0 -90
- package/modules/raffle/raffle.schema.ts +0 -32
- package/modules/raffle/raffle.service.ts +0 -167
- package/modules/raffle/raffle.types.ts +0 -30
- package/modules/skill/index.ts +0 -5
- package/modules/skill/skill.models.ts +0 -16
- package/modules/skill/skill.router.ts +0 -201
- package/modules/skill/skill.schema.ts +0 -40
- package/modules/skill/skill.service.ts +0 -390
- package/modules/skill/skill.types.ts +0 -33
- package/modules/video/index.ts +0 -5
- package/modules/video/video.models.ts +0 -25
- package/modules/video/video.router.ts +0 -143
- package/modules/video/video.schema.ts +0 -46
- package/modules/video/video.service.ts +0 -274
- package/modules/video/video.types.ts +0 -33
- package/util/db/index.ts +0 -7
- package/util/db/isPostgresError.ts +0 -9
- package/util/db/isUniqueConstraintViolation.ts +0 -3
- package/util/db.ts +0 -62
- package/util/index.ts +0 -351
- /package/{util/api.ts → api.ts} +0 -0
- /package/{util/array.ts → array.ts} +0 -0
- /package/{util/browser.ts → browser.ts} +0 -0
- /package/{util/codebase.ts → codebase.ts} +0 -0
- /package/{util/config.ts → config.ts} +0 -0
- /package/{util/decoder.test.ts → decoder.test.ts} +0 -0
- /package/{util/decoder.ts → decoder.ts} +0 -0
- /package/{util/format.ts → format.ts} +0 -0
- /package/{util/guid.ts → guid.ts} +0 -0
- /package/{util/json.ts → json.ts} +0 -0
- /package/{util/log.ts → log.ts} +0 -0
- /package/{util/math.ts → math.ts} +0 -0
- /package/{util/merkle.ts → merkle.ts} +0 -0
- /package/{util/mongo.ts → mongo.ts} +0 -0
- /package/{util/number.ts → number.ts} +0 -0
- /package/{util/object.ts → object.ts} +0 -0
- /package/{util/otp.ts → otp.ts} +0 -0
- /package/{util/physics.ts → physics.ts} +0 -0
- /package/{util/process.ts → process.ts} +0 -0
- /package/{util/rpc.ts → rpc.ts} +0 -0
- /package/{util/seer.ts → seer.ts} +0 -0
- /package/{util/string.ts → string.ts} +0 -0
- /package/{util/text.ts → text.ts} +0 -0
- /package/{util/time → time}/date.ts +0 -0
- /package/{util/time → time}/fancyTimeFormat.ts +0 -0
- /package/{util/time → time}/index.ts +0 -0
- /package/{util/time → time}/now.ts +0 -0
- /package/{util/types → types}/mongo.d.ts +0 -0
- /package/{util/web3 → web3}/httpProvider.ts +0 -0
- /package/{util/web3.ts → web3.ts} +0 -0
- /package/{util/websocket.ts → websocket.ts} +0 -0
- /package/{util/zk.ts → zk.ts} +0 -0
- /package/{util/zod.ts → zod.ts} +0 -0
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
import { z } from 'zod';
|
|
2
|
-
import * as schema from './character.schema';
|
|
3
|
-
import { Document, Model } from '../../util/mongo';
|
|
4
|
-
|
|
5
|
-
export type * from './character.router';
|
|
6
|
-
export type * from './character.service';
|
|
7
|
-
export type { RouterContext } from '../../types';
|
|
8
|
-
|
|
9
|
-
export type Character = z.infer<typeof schema.Character>;
|
|
10
|
-
export type CharacterDocument = Character & Document;
|
|
11
|
-
|
|
12
|
-
export type CharacterEquipment = z.infer<typeof schema.CharacterEquipment>;
|
|
13
|
-
export type CharacterEquipmentDocument = CharacterEquipment & Document;
|
|
14
|
-
|
|
15
|
-
export type CharacterInventory = z.infer<typeof schema.CharacterInventory>;
|
|
16
|
-
export type CharacterInventoryDocument = CharacterInventory & Document;
|
|
17
|
-
|
|
18
|
-
export type CharacterAbility = z.infer<typeof schema.CharacterAbility>;
|
|
19
|
-
export type CharacterAbilityDocument = CharacterAbility & Document;
|
|
20
|
-
|
|
21
|
-
export type CharacterAttribute = z.infer<typeof schema.CharacterAttribute>;
|
|
22
|
-
export type CharacterAttributeDocument = CharacterAttribute & Document;
|
|
23
|
-
|
|
24
|
-
export type CharacterClass = z.infer<typeof schema.CharacterClass>;
|
|
25
|
-
export type CharacterClassDocument = CharacterClass & Document;
|
|
26
|
-
|
|
27
|
-
export type CharacterFaction = z.infer<typeof schema.CharacterFaction>;
|
|
28
|
-
export type CharacterFactionDocument = CharacterFaction & Document;
|
|
29
|
-
|
|
30
|
-
export type CharacterGender = z.infer<typeof schema.CharacterGender>;
|
|
31
|
-
export type CharacterGenderDocument = CharacterGender & Document;
|
|
32
|
-
|
|
33
|
-
export type CharacterNameChoice = z.infer<typeof schema.CharacterNameChoice>;
|
|
34
|
-
export type CharacterNameChoiceDocument = CharacterNameChoice & Document;
|
|
35
|
-
|
|
36
|
-
export type CharacterPersonality = z.infer<typeof schema.CharacterPersonality>;
|
|
37
|
-
export type CharacterPersonalityDocument = CharacterPersonality & Document;
|
|
38
|
-
|
|
39
|
-
export type CharacterRace = z.infer<typeof schema.CharacterRace>;
|
|
40
|
-
export type CharacterRaceDocument = CharacterRace & Document;
|
|
41
|
-
|
|
42
|
-
export type CharacterTitle = z.infer<typeof schema.CharacterTitle>;
|
|
43
|
-
export type CharacterTitleDocument = CharacterTitle & Document;
|
|
44
|
-
|
|
45
|
-
export type CharacterType = z.infer<typeof schema.CharacterType>;
|
|
46
|
-
export type CharacterTypeDocument = CharacterType & Document;
|
|
47
|
-
|
|
48
|
-
export type CharacterGuild = z.infer<typeof schema.CharacterGuild>;
|
|
49
|
-
export type CharacterGuildDocument = CharacterGuild & Document;
|
|
50
|
-
|
|
51
|
-
export type Mappings = {
|
|
52
|
-
Character: Model<CharacterDocument>;
|
|
53
|
-
CharacterAbility: Model<CharacterAbilityDocument>;
|
|
54
|
-
CharacterAttribute: Model<CharacterAttributeDocument>;
|
|
55
|
-
CharacterClass: Model<CharacterClassDocument>;
|
|
56
|
-
CharacterFaction: Model<CharacterFactionDocument>;
|
|
57
|
-
CharacterGender: Model<CharacterGenderDocument>;
|
|
58
|
-
CharacterNameChoice: Model<CharacterNameChoiceDocument>;
|
|
59
|
-
CharacterPersonality: Model<CharacterPersonalityDocument>;
|
|
60
|
-
CharacterRace: Model<CharacterRaceDocument>;
|
|
61
|
-
CharacterTitle: Model<CharacterTitleDocument>;
|
|
62
|
-
CharacterType: Model<CharacterTypeDocument>;
|
|
63
|
-
CharacterGuild: Model<CharacterGuildDocument>;
|
|
64
|
-
};
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import * as mongo from '../../util/mongo';
|
|
2
|
-
import type * as Types from './chat.types';
|
|
3
|
-
|
|
4
|
-
// ChatGroup
|
|
5
|
-
export const ChatGroup = mongo.createModel<Types.ChatGroupDocument>('ChatGroup', {
|
|
6
|
-
name: { type: String, required: true, maxlength: 100 },
|
|
7
|
-
type: { type: String, required: true, enum: ['group', 'private'] },
|
|
8
|
-
members: [{ type: mongo.Schema.Types.ObjectId, ref: 'Profile' }],
|
|
9
|
-
externalId: { type: String },
|
|
10
|
-
externalPlatform: { type: String, enum: ['Telegram', 'Discord'] },
|
|
11
|
-
});
|
|
12
|
-
|
|
13
|
-
// ChatMessage
|
|
14
|
-
export const ChatMessage = mongo.createModel<Types.ChatMessageDocument>(
|
|
15
|
-
'ChatMessage',
|
|
16
|
-
{
|
|
17
|
-
groupId: { type: mongo.Schema.Types.ObjectId, ref: 'ChatGroup', required: true },
|
|
18
|
-
profileId: { type: mongo.Schema.Types.ObjectId, ref: 'Profile', required: true },
|
|
19
|
-
content: { type: String },
|
|
20
|
-
mediaUrl: { type: String },
|
|
21
|
-
replyToId: { type: mongo.Schema.Types.ObjectId, ref: 'ChatMessage' },
|
|
22
|
-
reactions: [
|
|
23
|
-
{
|
|
24
|
-
profileId: { type: mongo.Schema.Types.ObjectId, ref: 'Profile' },
|
|
25
|
-
reaction: { type: String },
|
|
26
|
-
},
|
|
27
|
-
],
|
|
28
|
-
externalId: { type: String },
|
|
29
|
-
externalPlatform: { type: String, enum: ['Telegram', 'Discord'] },
|
|
30
|
-
isSpam: { type: Boolean, default: false },
|
|
31
|
-
tags: { type: mongo.Schema.Types.Mixed }, // Correctly define as array of Mixed
|
|
32
|
-
summary: { type: String },
|
|
33
|
-
entities: { type: mongo.Schema.Types.Mixed }, // Correctly define as array of Mixed
|
|
34
|
-
type: {
|
|
35
|
-
type: String,
|
|
36
|
-
default: 'text',
|
|
37
|
-
enum: ['text', 'image', 'video', 'audio', 'file', 'system'],
|
|
38
|
-
},
|
|
39
|
-
},
|
|
40
|
-
{
|
|
41
|
-
indexes: [{ groupId: 1, createdDate: 1 }, { profileId: 1 }, { status: 1 }, { replyToId: 1 }, { type: 1 }],
|
|
42
|
-
}
|
|
43
|
-
);
|
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
// module/chat.router.ts
|
|
2
|
-
|
|
3
|
-
import { z as zod } from 'zod';
|
|
4
|
-
import { initTRPC, inferRouterInputs, inferRouterOutputs } from '@trpc/server';
|
|
5
|
-
import { customErrorFormatter, hasRole } from '../../util/rpc';
|
|
6
|
-
import type { RouterContext } from '../../types';
|
|
7
|
-
import { ChatGroup, ChatMessage } from './chat.schema';
|
|
8
|
-
|
|
9
|
-
export const z = zod;
|
|
10
|
-
export const t = initTRPC.context<RouterContext>().create();
|
|
11
|
-
export const router = t.router;
|
|
12
|
-
export const procedure = t.procedure;
|
|
13
|
-
|
|
14
|
-
export const createRouter = () =>
|
|
15
|
-
router({
|
|
16
|
-
getChatGroup: procedure
|
|
17
|
-
.use(hasRole('guest', t))
|
|
18
|
-
.use(customErrorFormatter(t))
|
|
19
|
-
.input(z.object({ chatGroupId: z.string() }))
|
|
20
|
-
.query(({ input, ctx }) => (ctx.app.service.Chat.getChatGroup as any)(input, ctx)),
|
|
21
|
-
|
|
22
|
-
getChatGroups: procedure
|
|
23
|
-
.use(hasRole('guest', t))
|
|
24
|
-
.use(customErrorFormatter(t))
|
|
25
|
-
.input(z.object({ chatGroupId: z.string() }))
|
|
26
|
-
.query(({ input, ctx }) => (ctx.app.service.Chat.getChatGroup as any)(input, ctx)),
|
|
27
|
-
|
|
28
|
-
createChatGroup: procedure
|
|
29
|
-
.use(hasRole('admin', t))
|
|
30
|
-
.use(customErrorFormatter(t))
|
|
31
|
-
.input(ChatGroup)
|
|
32
|
-
.mutation(({ input, ctx }) => (ctx.app.service.Chat.createChatGroup as any)(input, ctx)),
|
|
33
|
-
|
|
34
|
-
updateChatGroup: procedure
|
|
35
|
-
.use(hasRole('admin', t))
|
|
36
|
-
.use(customErrorFormatter(t))
|
|
37
|
-
.input(z.object({ chatGroupId: z.string(), data: ChatGroup.partial() }))
|
|
38
|
-
.mutation(({ input, ctx }) => (ctx.app.service.Chat.updateChatGroup as any)(input, ctx)),
|
|
39
|
-
|
|
40
|
-
getChatMessage: procedure
|
|
41
|
-
.use(hasRole('guest', t))
|
|
42
|
-
.use(customErrorFormatter(t))
|
|
43
|
-
.input(z.object({ chatMessageId: z.string() }))
|
|
44
|
-
.query(({ input, ctx }) => (ctx.app.service.Chat.getChatMessage as any)(input, ctx)),
|
|
45
|
-
|
|
46
|
-
getChatMessages: procedure
|
|
47
|
-
.use(hasRole('guest', t))
|
|
48
|
-
.use(customErrorFormatter(t))
|
|
49
|
-
.input(z.object({ chatMessageId: z.string() }))
|
|
50
|
-
.query(({ input, ctx }) => (ctx.app.service.Chat.getChatMessage as any)(input, ctx)),
|
|
51
|
-
|
|
52
|
-
createChatMessage: procedure
|
|
53
|
-
.use(hasRole('admin', t))
|
|
54
|
-
.use(customErrorFormatter(t))
|
|
55
|
-
.input(ChatMessage)
|
|
56
|
-
.mutation(({ input, ctx }) => (ctx.app.service.Chat.createChatMessage as any)(input, ctx)),
|
|
57
|
-
|
|
58
|
-
updateChatMessage: procedure
|
|
59
|
-
.use(hasRole('admin', t))
|
|
60
|
-
.use(customErrorFormatter(t))
|
|
61
|
-
.input(z.object({ chatMessageId: z.string(), data: ChatMessage.partial() }))
|
|
62
|
-
.mutation(({ input, ctx }) => (ctx.app.service.Chat.updateChatMessage as any)(input, ctx)),
|
|
63
|
-
});
|
|
64
|
-
|
|
65
|
-
export type Router = ReturnType<typeof createRouter>;
|
|
66
|
-
export type RouterInput = inferRouterInputs<Router>;
|
|
67
|
-
export type RouterOutput = inferRouterOutputs<Router>;
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import { z, ObjectId, Entity } from '../../schema';
|
|
2
|
-
|
|
3
|
-
export const ChatGroup = Entity.merge(
|
|
4
|
-
z.object({
|
|
5
|
-
name: z.string().max(100).min(1),
|
|
6
|
-
type: z.enum(['group', 'private']),
|
|
7
|
-
members: z.array(ObjectId),
|
|
8
|
-
externalId: z.string().optional(),
|
|
9
|
-
externalPlatform: z.enum(['Telegram', 'Discord']).optional(),
|
|
10
|
-
})
|
|
11
|
-
);
|
|
12
|
-
|
|
13
|
-
export const ChatMessage = Entity.merge(
|
|
14
|
-
z.object({
|
|
15
|
-
groupId: ObjectId,
|
|
16
|
-
profileId: ObjectId,
|
|
17
|
-
content: z.string().optional(),
|
|
18
|
-
mediaUrl: z.string().optional(),
|
|
19
|
-
replyToId: ObjectId.optional(),
|
|
20
|
-
reactions: z
|
|
21
|
-
.array(
|
|
22
|
-
z.object({
|
|
23
|
-
profileId: ObjectId,
|
|
24
|
-
reaction: z.string(),
|
|
25
|
-
})
|
|
26
|
-
)
|
|
27
|
-
.optional(),
|
|
28
|
-
externalId: z.string().optional(),
|
|
29
|
-
externalPlatform: z.enum(['Telegram', 'Discord']).optional(),
|
|
30
|
-
isSpam: z.boolean().default(false),
|
|
31
|
-
tags: z.array(z.unknown()).default([]),
|
|
32
|
-
summary: z.string().optional(),
|
|
33
|
-
entities: z.array(z.unknown()).default([]),
|
|
34
|
-
type: z.enum(['text', 'image', 'video', 'audio', 'file', 'system']).default('text'),
|
|
35
|
-
})
|
|
36
|
-
);
|
|
@@ -1,128 +0,0 @@
|
|
|
1
|
-
// module/chat.service.ts
|
|
2
|
-
|
|
3
|
-
import { getFilter } from '../../util/api';
|
|
4
|
-
import type { RouterContext, RouterInput, RouterOutput, ChatGroupDocument, ChatMessageDocument } from './chat.types';
|
|
5
|
-
|
|
6
|
-
export class Service {
|
|
7
|
-
constructor() {}
|
|
8
|
-
|
|
9
|
-
// ChatGroup Methods
|
|
10
|
-
async getChatGroup(input: RouterInput['getChatGroup'], ctx: RouterContext): Promise<RouterOutput['getChatGroup']> {
|
|
11
|
-
if (!input) throw new Error('Input should not be void');
|
|
12
|
-
console.log('Chat.Service.getChatGroup', input);
|
|
13
|
-
|
|
14
|
-
const filter = getFilter(input);
|
|
15
|
-
const chatGroup = await ctx.app.model.ChatGroup.findOne(filter).lean().exec();
|
|
16
|
-
if (!chatGroup) throw new Error('ChatGroup not found');
|
|
17
|
-
|
|
18
|
-
// @ts-ignore
|
|
19
|
-
return chatGroup as ChatGroupDocument;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
async getChatGroups(input: RouterInput['getChatGroups'], ctx: RouterContext): Promise<RouterOutput['getChatGroups']> {
|
|
23
|
-
if (!input) throw new Error('Input should not be void');
|
|
24
|
-
console.log('Chat.Service.getChatGroups', input);
|
|
25
|
-
|
|
26
|
-
const filter = getFilter(input);
|
|
27
|
-
const chatGroups = await ctx.app.model.ChatGroup.find(filter).lean().exec();
|
|
28
|
-
if (!chatGroups) throw new Error('ChatGroups not found');
|
|
29
|
-
|
|
30
|
-
// @ts-ignore
|
|
31
|
-
return chatGroups as ChatGroupDocument[];
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
async createChatGroup(
|
|
35
|
-
input: RouterInput['createChatGroup'],
|
|
36
|
-
ctx: RouterContext
|
|
37
|
-
): Promise<RouterOutput['createChatGroup']> {
|
|
38
|
-
if (!input) throw new Error('Input should not be void');
|
|
39
|
-
console.log('Chat.Service.createChatGroup', input);
|
|
40
|
-
|
|
41
|
-
const newChatGroup = await ctx.app.model.ChatGroup.create(input.data);
|
|
42
|
-
|
|
43
|
-
// @ts-ignore
|
|
44
|
-
return newChatGroup as ChatGroupDocument;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
async updateChatGroup(
|
|
48
|
-
input: RouterInput['updateChatGroup'],
|
|
49
|
-
ctx: RouterContext
|
|
50
|
-
): Promise<RouterOutput['updateChatGroup']> {
|
|
51
|
-
if (!input) throw new Error('Input should not be void');
|
|
52
|
-
console.log('Chat.Service.updateChatGroup', input);
|
|
53
|
-
|
|
54
|
-
const filter = getFilter(input);
|
|
55
|
-
await ctx.app.model.ChatGroup.updateOne(filter, input.data, {
|
|
56
|
-
runValidators: true,
|
|
57
|
-
}).exec();
|
|
58
|
-
|
|
59
|
-
const updatedChatGroup = await ctx.app.model.ChatGroup.findOne(filter).lean().exec();
|
|
60
|
-
if (!updatedChatGroup) throw new Error('ChatGroup update failed');
|
|
61
|
-
|
|
62
|
-
// @ts-ignore
|
|
63
|
-
return updatedChatGroup as ChatGroupDocument;
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
// ChatMessage Methods
|
|
67
|
-
async getChatMessage(
|
|
68
|
-
input: RouterInput['getChatMessage'],
|
|
69
|
-
ctx: RouterContext
|
|
70
|
-
): Promise<RouterOutput['getChatMessage']> {
|
|
71
|
-
if (!input) throw new Error('Input should not be void');
|
|
72
|
-
console.log('Chat.Service.getChatMessage', input);
|
|
73
|
-
|
|
74
|
-
const filter = getFilter(input);
|
|
75
|
-
const chatMessage = await ctx.app.model.ChatMessage.findOne(filter).lean().exec();
|
|
76
|
-
if (!chatMessage) throw new Error('ChatMessage not found');
|
|
77
|
-
|
|
78
|
-
// @ts-ignore
|
|
79
|
-
return chatMessage as ChatMessageDocument;
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
async getChatMessages(
|
|
83
|
-
input: RouterInput['getChatMessages'],
|
|
84
|
-
ctx: RouterContext
|
|
85
|
-
): Promise<RouterOutput['getChatMessages']> {
|
|
86
|
-
if (!input) throw new Error('Input should not be void');
|
|
87
|
-
console.log('Chat.Service.getChatMessages', input);
|
|
88
|
-
|
|
89
|
-
const filter = getFilter(input);
|
|
90
|
-
const chatMessages = await ctx.app.model.ChatMessage.find(filter).lean().exec();
|
|
91
|
-
if (!chatMessages) throw new Error('ChatMessages not found');
|
|
92
|
-
|
|
93
|
-
// @ts-ignore
|
|
94
|
-
return chatMessages as ChatMessageDocument[];
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
async createChatMessage(
|
|
98
|
-
input: RouterInput['createChatMessage'],
|
|
99
|
-
ctx: RouterContext
|
|
100
|
-
): Promise<RouterOutput['createChatMessage']> {
|
|
101
|
-
if (!input) throw new Error('Input should not be void');
|
|
102
|
-
console.log('Chat.Service.createChatMessage', input);
|
|
103
|
-
|
|
104
|
-
const newChatMessage = await ctx.app.model.ChatMessage.create(input.data);
|
|
105
|
-
|
|
106
|
-
// @ts-ignore
|
|
107
|
-
return newChatMessage as ChatMessageDocument;
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
async updateChatMessage(
|
|
111
|
-
input: RouterInput['updateChatMessage'],
|
|
112
|
-
ctx: RouterContext
|
|
113
|
-
): Promise<RouterOutput['updateChatMessage']> {
|
|
114
|
-
if (!input) throw new Error('Input should not be void');
|
|
115
|
-
console.log('Chat.Service.updateChatMessage', input);
|
|
116
|
-
|
|
117
|
-
const filter = getFilter(input);
|
|
118
|
-
await ctx.app.model.ChatMessage.updateOne(filter, input.data, {
|
|
119
|
-
runValidators: true,
|
|
120
|
-
}).exec();
|
|
121
|
-
|
|
122
|
-
const updatedChatMessage = await ctx.app.model.ChatMessage.findOne(filter).lean().exec();
|
|
123
|
-
if (!updatedChatMessage) throw new Error('ChatMessage update failed');
|
|
124
|
-
|
|
125
|
-
// @ts-ignore
|
|
126
|
-
return updatedChatMessage as ChatMessageDocument;
|
|
127
|
-
}
|
|
128
|
-
}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
// module/chat.types.ts
|
|
2
|
-
|
|
3
|
-
import { z } from 'zod';
|
|
4
|
-
import * as schema from './chat.schema';
|
|
5
|
-
import { Document, Model } from '../../util/mongo';
|
|
6
|
-
|
|
7
|
-
export type * from './chat.router';
|
|
8
|
-
export type * from './chat.service';
|
|
9
|
-
export type { RouterContext } from '../../types';
|
|
10
|
-
|
|
11
|
-
export type ChatGroup = z.infer<typeof schema.ChatGroup>;
|
|
12
|
-
export type ChatGroupDocument = ChatGroup & Document;
|
|
13
|
-
|
|
14
|
-
export type ChatMessage = z.infer<typeof schema.ChatMessage>;
|
|
15
|
-
export type ChatMessageDocument = ChatMessage & Document;
|
|
16
|
-
|
|
17
|
-
export type Mappings = {
|
|
18
|
-
ChatGroup: Model<ChatGroupDocument>;
|
|
19
|
-
ChatMessage: Model<ChatMessageDocument>;
|
|
20
|
-
};
|
package/modules/chat/index.ts
DELETED
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
import * as mongo from '../../util/mongo';
|
|
2
|
-
import type * as Types from './collection.types';
|
|
3
|
-
|
|
4
|
-
export const CollectibleCollection = mongo.createModel<Types.CollectibleCollectionDocument>('CollectibleCollection', {
|
|
5
|
-
hype: { type: Number, default: 0 },
|
|
6
|
-
value: { type: Number, default: 0 },
|
|
7
|
-
});
|
|
8
|
-
|
|
9
|
-
export const CollectibleCardBox = mongo.createModel<Types.CollectibleCardBoxDocument>('CollectibleCardBox', {
|
|
10
|
-
collectibleCollectionId: { type: mongo.Schema.Types.ObjectId, ref: 'CollectibleCollection', required: true },
|
|
11
|
-
franchise: { type: String, required: true, trim: true },
|
|
12
|
-
});
|
|
13
|
-
|
|
14
|
-
export const CollectibleCardPack = mongo.createModel<Types.CollectibleCardPackDocument>('CollectibleCardPack', {
|
|
15
|
-
collectibleCollectionId: { type: mongo.Schema.Types.ObjectId, ref: 'CollectibleCollection', required: true },
|
|
16
|
-
franchise: { type: String, required: true, trim: true },
|
|
17
|
-
ungraded: { type: Number, default: 0 },
|
|
18
|
-
grade10: { type: Number, default: 0 },
|
|
19
|
-
grade9: { type: Number, default: 0 },
|
|
20
|
-
grade8: { type: Number, default: 0 },
|
|
21
|
-
grade7: { type: Number, default: 0 },
|
|
22
|
-
grade6: { type: Number, default: 0 },
|
|
23
|
-
grade5: { type: Number, default: 0 },
|
|
24
|
-
grade4: { type: Number, default: 0 },
|
|
25
|
-
grade3: { type: Number, default: 0 },
|
|
26
|
-
grade2: { type: Number, default: 0 },
|
|
27
|
-
grade1: { type: Number, default: 0 },
|
|
28
|
-
additional: { type: String, trim: true },
|
|
29
|
-
code: { type: String, trim: true },
|
|
30
|
-
hype: { type: Number, default: 0 },
|
|
31
|
-
series: { type: String, trim: true },
|
|
32
|
-
category: { type: String, trim: true },
|
|
33
|
-
year: { type: Number },
|
|
34
|
-
});
|
|
35
|
-
|
|
36
|
-
export const CollectibleCard = mongo.createModel<Types.CollectibleCardDocument>('CollectibleCard', {
|
|
37
|
-
collectibleCollectionId: { type: mongo.Schema.Types.ObjectId, ref: 'CollectibleCollection', required: true },
|
|
38
|
-
franchise: { type: String, required: true, trim: true },
|
|
39
|
-
ungraded: { type: Number, default: 0 },
|
|
40
|
-
grade10: { type: Number, default: 0 },
|
|
41
|
-
grade9: { type: Number, default: 0 },
|
|
42
|
-
grade8: { type: Number, default: 0 },
|
|
43
|
-
grade7: { type: Number, default: 0 },
|
|
44
|
-
grade6: { type: Number, default: 0 },
|
|
45
|
-
grade5: { type: Number, default: 0 },
|
|
46
|
-
grade4: { type: Number, default: 0 },
|
|
47
|
-
grade3: { type: Number, default: 0 },
|
|
48
|
-
grade2: { type: Number, default: 0 },
|
|
49
|
-
grade1: { type: Number, default: 0 },
|
|
50
|
-
additional: { type: String, trim: true },
|
|
51
|
-
code: { type: String, trim: true },
|
|
52
|
-
hype: { type: Number, default: 0 },
|
|
53
|
-
series: { type: String, trim: true },
|
|
54
|
-
category: { type: String, trim: true },
|
|
55
|
-
year: { type: Number },
|
|
56
|
-
});
|
|
57
|
-
|
|
58
|
-
export const Set = mongo.createModel<Types.SetDocument>('Set', {
|
|
59
|
-
seriesId: { type: mongo.Schema.Types.ObjectId, ref: 'Series', required: true },
|
|
60
|
-
name: { type: String, required: true, trim: true },
|
|
61
|
-
language: { type: String, required: true, trim: true },
|
|
62
|
-
live: { type: Boolean, default: false },
|
|
63
|
-
releaseDate: { type: String, required: true, trim: true },
|
|
64
|
-
});
|
|
65
|
-
|
|
66
|
-
export const Card = mongo.createModel<Types.CardDocument>('Card', {
|
|
67
|
-
setId: { type: mongo.Schema.Types.ObjectId, ref: 'Set', required: true },
|
|
68
|
-
name: { type: String, required: true, trim: true },
|
|
69
|
-
language: { type: String, required: true, trim: true },
|
|
70
|
-
releaseDate: { type: String, required: true, trim: true },
|
|
71
|
-
cardId: { type: Number, required: true },
|
|
72
|
-
});
|
|
73
|
-
|
|
74
|
-
export const Series = mongo.createModel<Types.SeriesDocument>('Series', {
|
|
75
|
-
name: { type: String, required: true, trim: true },
|
|
76
|
-
});
|
|
@@ -1,91 +0,0 @@
|
|
|
1
|
-
// module/collection.router.ts
|
|
2
|
-
|
|
3
|
-
import { z as zod } from 'zod';
|
|
4
|
-
import { initTRPC, inferRouterInputs, inferRouterOutputs } from '@trpc/server';
|
|
5
|
-
import { customErrorFormatter, hasRole } from '../../util/rpc';
|
|
6
|
-
import type { RouterContext } from '../../types';
|
|
7
|
-
import { CollectibleCollection, CollectibleCardBox, CollectibleCardPack, CollectibleCard } from './collection.schema';
|
|
8
|
-
|
|
9
|
-
export const z = zod;
|
|
10
|
-
export const t = initTRPC.context<RouterContext>().create();
|
|
11
|
-
export const router = t.router;
|
|
12
|
-
export const procedure = t.procedure;
|
|
13
|
-
|
|
14
|
-
export const createRouter = () =>
|
|
15
|
-
router({
|
|
16
|
-
getCollectibleCollection: procedure
|
|
17
|
-
.use(hasRole('guest', t))
|
|
18
|
-
.use(customErrorFormatter(t))
|
|
19
|
-
.input(z.object({ collectibleCollectionId: z.string() }))
|
|
20
|
-
.query(({ input, ctx }) => (ctx.app.service.Collection.getCollectibleCollection as any)(input, ctx)),
|
|
21
|
-
|
|
22
|
-
createCollectibleCollection: procedure
|
|
23
|
-
.use(hasRole('admin', t))
|
|
24
|
-
.use(customErrorFormatter(t))
|
|
25
|
-
.input(CollectibleCollection)
|
|
26
|
-
.mutation(({ input, ctx }) => (ctx.app.service.Collection.createCollectibleCollection as any)(input, ctx)),
|
|
27
|
-
|
|
28
|
-
updateCollectibleCollection: procedure
|
|
29
|
-
.use(hasRole('admin', t))
|
|
30
|
-
.use(customErrorFormatter(t))
|
|
31
|
-
.input(z.object({ collectibleCollectionId: z.string(), data: CollectibleCollection.partial() }))
|
|
32
|
-
.mutation(({ input, ctx }) => (ctx.app.service.Collection.updateCollectibleCollection as any)(input, ctx)),
|
|
33
|
-
|
|
34
|
-
getCollectibleCardBox: procedure
|
|
35
|
-
.use(hasRole('guest', t))
|
|
36
|
-
.use(customErrorFormatter(t))
|
|
37
|
-
.input(z.object({ collectibleCardBoxId: z.string() }))
|
|
38
|
-
.query(({ input, ctx }) => (ctx.app.service.Collection.getCollectibleCardBox as any)(input, ctx)),
|
|
39
|
-
|
|
40
|
-
createCollectibleCardBox: procedure
|
|
41
|
-
.use(hasRole('admin', t))
|
|
42
|
-
.use(customErrorFormatter(t))
|
|
43
|
-
.input(CollectibleCardBox)
|
|
44
|
-
.mutation(({ input, ctx }) => (ctx.app.service.Collection.createCollectibleCardBox as any)(input, ctx)),
|
|
45
|
-
|
|
46
|
-
updateCollectibleCardBox: procedure
|
|
47
|
-
.use(hasRole('admin', t))
|
|
48
|
-
.use(customErrorFormatter(t))
|
|
49
|
-
.input(z.object({ collectibleCardBoxId: z.string(), data: CollectibleCardBox.partial() }))
|
|
50
|
-
.mutation(({ input, ctx }) => (ctx.app.service.Collection.updateCollectibleCardBox as any)(input, ctx)),
|
|
51
|
-
|
|
52
|
-
getCollectibleCardPack: procedure
|
|
53
|
-
.use(hasRole('guest', t))
|
|
54
|
-
.use(customErrorFormatter(t))
|
|
55
|
-
.input(z.object({ collectibleCardPackId: z.string() }))
|
|
56
|
-
.query(({ input, ctx }) => (ctx.app.service.Collection.getCollectibleCardPack as any)(input, ctx)),
|
|
57
|
-
|
|
58
|
-
createCollectibleCardPack: procedure
|
|
59
|
-
.use(hasRole('admin', t))
|
|
60
|
-
.use(customErrorFormatter(t))
|
|
61
|
-
.input(CollectibleCardPack)
|
|
62
|
-
.mutation(({ input, ctx }) => (ctx.app.service.Collection.createCollectibleCardPack as any)(input, ctx)),
|
|
63
|
-
|
|
64
|
-
updateCollectibleCardPack: procedure
|
|
65
|
-
.use(hasRole('admin', t))
|
|
66
|
-
.use(customErrorFormatter(t))
|
|
67
|
-
.input(z.object({ collectibleCardPackId: z.string(), data: CollectibleCardPack.partial() }))
|
|
68
|
-
.mutation(({ input, ctx }) => (ctx.app.service.Collection.updateCollectibleCardPack as any)(input, ctx)),
|
|
69
|
-
|
|
70
|
-
getCollectibleCard: procedure
|
|
71
|
-
.use(hasRole('guest', t))
|
|
72
|
-
.use(customErrorFormatter(t))
|
|
73
|
-
.input(z.object({ collectibleCardId: z.string() }))
|
|
74
|
-
.query(({ input, ctx }) => (ctx.app.service.Collection.getCollectibleCard as any)(input, ctx)),
|
|
75
|
-
|
|
76
|
-
createCollectibleCard: procedure
|
|
77
|
-
.use(hasRole('admin', t))
|
|
78
|
-
.use(customErrorFormatter(t))
|
|
79
|
-
.input(CollectibleCard)
|
|
80
|
-
.mutation(({ input, ctx }) => (ctx.app.service.Collection.createCollectibleCard as any)(input, ctx)),
|
|
81
|
-
|
|
82
|
-
updateCollectibleCard: procedure
|
|
83
|
-
.use(hasRole('admin', t))
|
|
84
|
-
.use(customErrorFormatter(t))
|
|
85
|
-
.input(z.object({ collectibleCardId: z.string(), data: CollectibleCard.partial() }))
|
|
86
|
-
.mutation(({ input, ctx }) => (ctx.app.service.Collection.updateCollectibleCard as any)(input, ctx)),
|
|
87
|
-
});
|
|
88
|
-
|
|
89
|
-
export type Router = ReturnType<typeof createRouter>;
|
|
90
|
-
export type RouterInput = inferRouterInputs<Router>;
|
|
91
|
-
export type RouterOutput = inferRouterOutputs<Router>;
|
|
@@ -1,90 +0,0 @@
|
|
|
1
|
-
import { z, ObjectId, Entity } from '../../schema';
|
|
2
|
-
|
|
3
|
-
export const CollectibleCollection = Entity.merge(
|
|
4
|
-
z.object({
|
|
5
|
-
hype: z.number().optional(),
|
|
6
|
-
value: z.number().optional(),
|
|
7
|
-
})
|
|
8
|
-
);
|
|
9
|
-
|
|
10
|
-
export const CollectibleCardBox = Entity.merge(
|
|
11
|
-
z.object({
|
|
12
|
-
collectibleCollectionId: ObjectId,
|
|
13
|
-
franchise: z.string().min(1),
|
|
14
|
-
})
|
|
15
|
-
);
|
|
16
|
-
|
|
17
|
-
export const CollectibleCardPack = Entity.merge(
|
|
18
|
-
z.object({
|
|
19
|
-
collectibleCollectionId: ObjectId,
|
|
20
|
-
franchise: z.string().min(1),
|
|
21
|
-
ungraded: z.number().optional(),
|
|
22
|
-
grade10: z.number().optional(),
|
|
23
|
-
grade9: z.number().optional(),
|
|
24
|
-
grade8: z.number().optional(),
|
|
25
|
-
grade7: z.number().optional(),
|
|
26
|
-
grade6: z.number().optional(),
|
|
27
|
-
grade5: z.number().optional(),
|
|
28
|
-
grade4: z.number().optional(),
|
|
29
|
-
grade3: z.number().optional(),
|
|
30
|
-
grade2: z.number().optional(),
|
|
31
|
-
grade1: z.number().optional(),
|
|
32
|
-
additional: z.string().optional(),
|
|
33
|
-
code: z.string().optional(),
|
|
34
|
-
hype: z.number().optional(),
|
|
35
|
-
series: z.string().optional(),
|
|
36
|
-
category: z.string().optional(),
|
|
37
|
-
year: z.number().optional(),
|
|
38
|
-
})
|
|
39
|
-
);
|
|
40
|
-
|
|
41
|
-
export const CollectibleCard = Entity.merge(
|
|
42
|
-
z.object({
|
|
43
|
-
collectibleCollectionId: ObjectId,
|
|
44
|
-
franchise: z.string().min(1),
|
|
45
|
-
ungraded: z.number().optional(),
|
|
46
|
-
grade10: z.number().optional(),
|
|
47
|
-
grade9: z.number().optional(),
|
|
48
|
-
grade8: z.number().optional(),
|
|
49
|
-
grade7: z.number().optional(),
|
|
50
|
-
grade6: z.number().optional(),
|
|
51
|
-
grade5: z.number().optional(),
|
|
52
|
-
grade4: z.number().optional(),
|
|
53
|
-
grade3: z.number().optional(),
|
|
54
|
-
grade2: z.number().optional(),
|
|
55
|
-
grade1: z.number().optional(),
|
|
56
|
-
additional: z.string().optional(),
|
|
57
|
-
code: z.string().optional(),
|
|
58
|
-
hype: z.number().optional(),
|
|
59
|
-
series: z.string().optional(),
|
|
60
|
-
category: z.string().optional(),
|
|
61
|
-
year: z.number().optional(),
|
|
62
|
-
})
|
|
63
|
-
);
|
|
64
|
-
|
|
65
|
-
export const Card = Entity.merge(
|
|
66
|
-
z.object({
|
|
67
|
-
setId: ObjectId,
|
|
68
|
-
name: z.string(),
|
|
69
|
-
language: z.string(),
|
|
70
|
-
releaseDate: z.string(),
|
|
71
|
-
cardId: z.number(),
|
|
72
|
-
})
|
|
73
|
-
);
|
|
74
|
-
|
|
75
|
-
export const Set = Entity.merge(
|
|
76
|
-
z.object({
|
|
77
|
-
seriesId: ObjectId,
|
|
78
|
-
name: z.string(),
|
|
79
|
-
language: z.string(),
|
|
80
|
-
live: z.boolean(),
|
|
81
|
-
releaseDate: z.string(),
|
|
82
|
-
cards: z.array(Card).optional(),
|
|
83
|
-
})
|
|
84
|
-
);
|
|
85
|
-
|
|
86
|
-
export const Series = Entity.merge(
|
|
87
|
-
z.object({
|
|
88
|
-
name: z.string(),
|
|
89
|
-
})
|
|
90
|
-
);
|