@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,167 +0,0 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
Chain,
|
|
3
|
-
ChainContract,
|
|
4
|
-
ChainToken,
|
|
5
|
-
ChainTransaction,
|
|
6
|
-
Router,
|
|
7
|
-
RouterInput,
|
|
8
|
-
RouterOutput,
|
|
9
|
-
RouterContext,
|
|
10
|
-
} from './chain.types';
|
|
11
|
-
import { ARXError } from '../../util/rpc';
|
|
12
|
-
import { getFilter } from '../../util/api';
|
|
13
|
-
|
|
14
|
-
export class Service {
|
|
15
|
-
async getChain(input: RouterInput['getChain'], ctx: RouterContext): Promise<RouterOutput['getChain']> {
|
|
16
|
-
if (!input) throw new ARXError('NO_INPUT');
|
|
17
|
-
console.log('Chain.Service.getChain', input);
|
|
18
|
-
|
|
19
|
-
const chain = await ctx.app.model.Chain.findOne(getFilter(input)).lean().exec();
|
|
20
|
-
if (!chain) throw new Error('Chain not found');
|
|
21
|
-
|
|
22
|
-
return chain as Chain;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
async getChainContract(
|
|
26
|
-
input: RouterInput['getChainContract'],
|
|
27
|
-
ctx: RouterContext
|
|
28
|
-
): Promise<RouterOutput['getChainContract']> {
|
|
29
|
-
if (!input) throw new ARXError('NO_INPUT');
|
|
30
|
-
console.log('Chain.Service.getChainContract', input);
|
|
31
|
-
|
|
32
|
-
const chainContract = await ctx.app.model.ChainContract.findOne(getFilter(input)).lean().exec();
|
|
33
|
-
if (!chainContract) throw new Error('ChainContract not found');
|
|
34
|
-
|
|
35
|
-
return chainContract as ChainContract;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
async getChainToken(input: RouterInput['getChainToken'], ctx: RouterContext): Promise<RouterOutput['getChainToken']> {
|
|
39
|
-
if (!input) throw new ARXError('NO_INPUT');
|
|
40
|
-
console.log('Chain.Service.getChainToken', input);
|
|
41
|
-
|
|
42
|
-
const chainToken = await ctx.app.model.ChainToken.findOne(getFilter(input)).lean().exec();
|
|
43
|
-
if (!chainToken) throw new Error('ChainToken not found');
|
|
44
|
-
|
|
45
|
-
return chainToken as ChainToken;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
async getChainTransaction(
|
|
49
|
-
input: RouterInput['getChainTransaction'],
|
|
50
|
-
ctx: RouterContext
|
|
51
|
-
): Promise<RouterOutput['getChainTransaction']> {
|
|
52
|
-
if (!input) throw new ARXError('NO_INPUT');
|
|
53
|
-
console.log('Chain.Service.getChainTransaction', input);
|
|
54
|
-
|
|
55
|
-
const chainTransaction = await ctx.app.model.ChainTransaction.findOne(getFilter(input)).lean().exec();
|
|
56
|
-
if (!chainTransaction) throw new Error('ChainTransaction not found');
|
|
57
|
-
|
|
58
|
-
return chainTransaction as ChainTransaction;
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
async createChain(input: RouterInput['createChain'], ctx: RouterContext): Promise<RouterOutput['createChain']> {
|
|
62
|
-
if (!input) throw new ARXError('NO_INPUT');
|
|
63
|
-
console.log('Chain.Service.createChain', input);
|
|
64
|
-
|
|
65
|
-
const chain = await ctx.app.model.Chain.create(input);
|
|
66
|
-
|
|
67
|
-
return chain as Chain;
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
async createChainContract(
|
|
71
|
-
input: RouterInput['createChainContract'],
|
|
72
|
-
ctx: RouterContext
|
|
73
|
-
): Promise<RouterOutput['createChainContract']> {
|
|
74
|
-
if (!input) throw new ARXError('NO_INPUT');
|
|
75
|
-
console.log('Chain.Service.createChainContract', input);
|
|
76
|
-
|
|
77
|
-
const chainContract = await ctx.app.model.ChainContract.create(input);
|
|
78
|
-
|
|
79
|
-
return chainContract as ChainContract;
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
async createChainToken(
|
|
83
|
-
input: RouterInput['createChainToken'],
|
|
84
|
-
ctx: RouterContext
|
|
85
|
-
): Promise<RouterOutput['createChainToken']> {
|
|
86
|
-
if (!input) throw new ARXError('NO_INPUT');
|
|
87
|
-
console.log('Chain.Service.createChainToken', input);
|
|
88
|
-
|
|
89
|
-
const chainToken = await ctx.app.model.ChainToken.create(input);
|
|
90
|
-
|
|
91
|
-
return chainToken as ChainToken;
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
async createChainTransaction(
|
|
95
|
-
input: RouterInput['createChainTransaction'],
|
|
96
|
-
ctx: RouterContext
|
|
97
|
-
): Promise<RouterOutput['createChainTransaction']> {
|
|
98
|
-
if (!input) throw new ARXError('NO_INPUT');
|
|
99
|
-
console.log('Chain.Service.createChainTransaction', input);
|
|
100
|
-
|
|
101
|
-
const chainTransaction = await ctx.app.model.ChainToken.create(input);
|
|
102
|
-
|
|
103
|
-
return chainTransaction as ChainTransaction;
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
async updateChain(input: RouterInput['updateChain'], ctx: RouterContext): Promise<RouterOutput['updateChain']> {
|
|
107
|
-
if (!input) throw new ARXError('NO_INPUT');
|
|
108
|
-
console.log('Chain.Service.updateChain', input);
|
|
109
|
-
|
|
110
|
-
const updatedChain = await ctx.app.model.Game.findByIdAndUpdate(input.where.id.equals, { new: true }).lean().exec();
|
|
111
|
-
if (!updatedChain) throw new Error('Chain update failed');
|
|
112
|
-
|
|
113
|
-
return updatedChain as Chain;
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
async updateChainContract(
|
|
117
|
-
input: RouterInput['updateChainContract'],
|
|
118
|
-
ctx: RouterContext
|
|
119
|
-
): Promise<RouterOutput['updateChainContract']> {
|
|
120
|
-
if (!input) throw new ARXError('NO_INPUT');
|
|
121
|
-
console.log('Chain.Service.updateChainContract', input);
|
|
122
|
-
|
|
123
|
-
const updatedChainContract = await ctx.app.model.ChainContract.findByIdAndUpdate(input.where.id.equals, {
|
|
124
|
-
new: true,
|
|
125
|
-
})
|
|
126
|
-
.lean()
|
|
127
|
-
.exec();
|
|
128
|
-
|
|
129
|
-
if (!updatedChainContract) throw new Error('ChainContract update failed');
|
|
130
|
-
|
|
131
|
-
return updatedChainContract as ChainContract;
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
async updateChainToken(
|
|
135
|
-
input: RouterInput['updateChainToken'],
|
|
136
|
-
ctx: RouterContext
|
|
137
|
-
): Promise<RouterOutput['updateChainToken']> {
|
|
138
|
-
if (!input) throw new ARXError('NO_INPUT');
|
|
139
|
-
console.log('Chain.Service.updateChainToken', input);
|
|
140
|
-
|
|
141
|
-
const updatedChainToken = await ctx.app.model.ChainToken.findByIdAndUpdate(input.where.id.equals, { new: true })
|
|
142
|
-
.lean()
|
|
143
|
-
.exec();
|
|
144
|
-
|
|
145
|
-
if (!updatedChainToken) throw new Error('ChainToken update failed');
|
|
146
|
-
|
|
147
|
-
return updatedChainToken as ChainToken;
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
async updateChainTransaction(
|
|
151
|
-
input: RouterInput['updateChainTransaction'],
|
|
152
|
-
ctx: RouterContext
|
|
153
|
-
): Promise<RouterOutput['updateChainTransaction']> {
|
|
154
|
-
if (!input) throw new ARXError('NO_INPUT');
|
|
155
|
-
console.log('Chain.Service.updateChainTransaction', input);
|
|
156
|
-
|
|
157
|
-
const updatedChainTransaction = await ctx.app.model.ChainTransaction.findByIdAndUpdate(input.where.id.equals, {
|
|
158
|
-
new: true,
|
|
159
|
-
})
|
|
160
|
-
.lean()
|
|
161
|
-
.exec();
|
|
162
|
-
|
|
163
|
-
if (!updatedChainTransaction) throw new Error('ChainTransaction update failed');
|
|
164
|
-
|
|
165
|
-
return updatedChainTransaction as ChainTransaction;
|
|
166
|
-
}
|
|
167
|
-
}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { z } from 'zod';
|
|
2
|
-
import * as schema from './chain.schema';
|
|
3
|
-
import { Document, Model } from '../../util/mongo';
|
|
4
|
-
|
|
5
|
-
export type * from './chain.router';
|
|
6
|
-
export type * from './chain.service';
|
|
7
|
-
export type { RouterContext } from '../../types';
|
|
8
|
-
|
|
9
|
-
export type Chain = z.infer<typeof schema.Chain>;
|
|
10
|
-
export type ChainContract = z.infer<typeof schema.ChainContract>;
|
|
11
|
-
export type ChainToken = z.infer<typeof schema.ChainToken>;
|
|
12
|
-
export type ChainTransaction = z.infer<typeof schema.ChainTransaction>;
|
|
13
|
-
|
|
14
|
-
export type ChainDocument = Chain & Document;
|
|
15
|
-
export type ChainContractDocument = ChainContract & Document;
|
|
16
|
-
export type ChainTokenDocument = ChainToken & Document;
|
|
17
|
-
export type ChainTransactionDocument = ChainTransaction & Document;
|
|
18
|
-
|
|
19
|
-
export type Mappings = {
|
|
20
|
-
Chain: Model<ChainDocument>;
|
|
21
|
-
ChainContract: Model<ChainContractDocument>;
|
|
22
|
-
ChainToken: Model<ChainTokenDocument>;
|
|
23
|
-
ChainTransaction: Model<ChainTransactionDocument>;
|
|
24
|
-
};
|
package/modules/chain/index.ts
DELETED
|
@@ -1,174 +0,0 @@
|
|
|
1
|
-
import * as mongo from '../../util/mongo';
|
|
2
|
-
import type * as Types from './character.types';
|
|
3
|
-
|
|
4
|
-
const { addTagVirtuals, addApplicationVirtual } = mongo;
|
|
5
|
-
|
|
6
|
-
// CharacterEquipment Schema
|
|
7
|
-
const CharacterEquipment = new mongo.Schema(
|
|
8
|
-
{
|
|
9
|
-
items: [
|
|
10
|
-
{
|
|
11
|
-
itemId: { type: mongo.Schema.Types.ObjectId, ref: 'Item', required: true },
|
|
12
|
-
slotId: { type: mongo.Schema.Types.ObjectId, ref: 'ItemSlot', required: true }, // e.g., 'head', 'chest', etc.
|
|
13
|
-
},
|
|
14
|
-
],
|
|
15
|
-
},
|
|
16
|
-
{
|
|
17
|
-
_id: false,
|
|
18
|
-
toJSON: { virtuals: true }, // Ensure virtuals are included in JSON responses
|
|
19
|
-
toObject: { virtuals: true }, // Ensure virtuals are included in object responses
|
|
20
|
-
} // Prevents Mongoose from creating an _id field for subdocuments
|
|
21
|
-
);
|
|
22
|
-
|
|
23
|
-
// Add virtual for `item`
|
|
24
|
-
CharacterEquipment.virtual('item', {
|
|
25
|
-
ref: 'Item',
|
|
26
|
-
localField: 'items.itemId',
|
|
27
|
-
foreignField: '_id',
|
|
28
|
-
justOne: true, // Assuming an `itemId` corresponds to one `Item`
|
|
29
|
-
});
|
|
30
|
-
|
|
31
|
-
// Add virtual for `slot`
|
|
32
|
-
CharacterEquipment.virtual('slot', {
|
|
33
|
-
ref: 'ItemSlot',
|
|
34
|
-
localField: 'items.slotId',
|
|
35
|
-
foreignField: '_id',
|
|
36
|
-
justOne: true, // Assuming a `slotId` corresponds to one `ItemSlot`
|
|
37
|
-
});
|
|
38
|
-
|
|
39
|
-
// CharacterInventory Schema
|
|
40
|
-
const CharacterInventory = new mongo.Schema(
|
|
41
|
-
{
|
|
42
|
-
items: [
|
|
43
|
-
{
|
|
44
|
-
itemId: { type: mongo.Schema.Types.ObjectId, ref: 'Item', required: true },
|
|
45
|
-
x: { type: Number },
|
|
46
|
-
y: { type: Number },
|
|
47
|
-
},
|
|
48
|
-
],
|
|
49
|
-
},
|
|
50
|
-
{ _id: false }
|
|
51
|
-
);
|
|
52
|
-
|
|
53
|
-
// Add virtual for `item`
|
|
54
|
-
CharacterEquipment.virtual('item', {
|
|
55
|
-
ref: 'Item',
|
|
56
|
-
localField: 'items.itemId',
|
|
57
|
-
foreignField: '_id',
|
|
58
|
-
justOne: true, // Assuming an `itemId` corresponds to one `Item`
|
|
59
|
-
});
|
|
60
|
-
|
|
61
|
-
export const Character = mongo.createModel<Types.CharacterDocument>(
|
|
62
|
-
'Character',
|
|
63
|
-
{
|
|
64
|
-
// teamId: { type: mongo.Schema.Types.ObjectId, ref: 'Team', required: false, autopopulate: true },
|
|
65
|
-
ratingId: { type: mongo.Schema.Types.ObjectId, ref: 'Rating', required: false },
|
|
66
|
-
classId: { type: mongo.Schema.Types.ObjectId, ref: 'CharacterClass', required: false },
|
|
67
|
-
raceId: { type: mongo.Schema.Types.ObjectId, ref: 'CharacterRace', required: false },
|
|
68
|
-
factionId: { type: mongo.Schema.Types.ObjectId, ref: 'CharacterFaction', required: false },
|
|
69
|
-
genderId: { type: mongo.Schema.Types.ObjectId, ref: 'CharacterGender', required: false },
|
|
70
|
-
guildId: { type: mongo.Schema.Types.ObjectId, ref: 'CharacterGuild', required: false },
|
|
71
|
-
isPrimary: { type: Boolean, required: false, default: false },
|
|
72
|
-
isBoss: { type: Boolean, required: false, default: false },
|
|
73
|
-
token: { type: String, required: false, trim: true },
|
|
74
|
-
points: { type: Number, default: 0, required: true },
|
|
75
|
-
equipmentIndex: { type: Number, default: 0 },
|
|
76
|
-
equipment: [{ type: CharacterEquipment, default: [] }],
|
|
77
|
-
inventoryIndex: { type: Number, default: 0 },
|
|
78
|
-
inventory: [{ type: CharacterInventory, default: [] }],
|
|
79
|
-
energyIds: [{ type: mongo.Schema.Types.ObjectId, ref: 'Energy', required: false }],
|
|
80
|
-
areaIds: [{ type: mongo.Schema.Types.ObjectId, ref: 'Area', required: false }],
|
|
81
|
-
typeIds: [{ type: mongo.Schema.Types.ObjectId, ref: 'CharacterType', required: false }],
|
|
82
|
-
itemMaterialIds: [{ type: mongo.Schema.Types.ObjectId, ref: 'ItemMaterial', required: false }],
|
|
83
|
-
// level: { type: Number, required: true },
|
|
84
|
-
// experience: { type: Number, required: true },
|
|
85
|
-
// gold: { type: Number, default: 0 },
|
|
86
|
-
},
|
|
87
|
-
{
|
|
88
|
-
extend: 'EntityFields',
|
|
89
|
-
cache: { enabled: true, ttlMs: 5 * 60 * 1000 },
|
|
90
|
-
indexes: [{ points: 1 }, { token: 1 }],
|
|
91
|
-
virtuals: [
|
|
92
|
-
...addTagVirtuals('Character'),
|
|
93
|
-
...addApplicationVirtual(),
|
|
94
|
-
// {
|
|
95
|
-
// name: 'team',
|
|
96
|
-
// },
|
|
97
|
-
{
|
|
98
|
-
name: 'energies',
|
|
99
|
-
ref: 'Energy',
|
|
100
|
-
localField: 'energyIds',
|
|
101
|
-
foreignField: '_id',
|
|
102
|
-
},
|
|
103
|
-
{
|
|
104
|
-
name: 'areas',
|
|
105
|
-
ref: 'Area',
|
|
106
|
-
localField: 'areaIds',
|
|
107
|
-
foreignField: '_id',
|
|
108
|
-
},
|
|
109
|
-
{
|
|
110
|
-
name: 'types',
|
|
111
|
-
ref: 'CharacterType',
|
|
112
|
-
localField: 'typeIds',
|
|
113
|
-
foreignField: '_id',
|
|
114
|
-
},
|
|
115
|
-
{
|
|
116
|
-
name: 'itemMaterials',
|
|
117
|
-
ref: 'ItemMaterial',
|
|
118
|
-
localField: 'itemMaterialIds',
|
|
119
|
-
foreignField: '_id',
|
|
120
|
-
},
|
|
121
|
-
{
|
|
122
|
-
name: 'profile',
|
|
123
|
-
},
|
|
124
|
-
{
|
|
125
|
-
name: 'rating',
|
|
126
|
-
},
|
|
127
|
-
{
|
|
128
|
-
name: 'class',
|
|
129
|
-
},
|
|
130
|
-
{
|
|
131
|
-
name: 'race',
|
|
132
|
-
},
|
|
133
|
-
{
|
|
134
|
-
name: 'faction',
|
|
135
|
-
},
|
|
136
|
-
{
|
|
137
|
-
name: 'gender',
|
|
138
|
-
},
|
|
139
|
-
// { name: 'types', ref: 'CharacterType', localField: '_id', foreignField: 'characterId' },
|
|
140
|
-
// {
|
|
141
|
-
// name: 'inventory'
|
|
142
|
-
// ref: 'ItemSlot',
|
|
143
|
-
// localField: 'items.slotId',
|
|
144
|
-
// foreignField: '_id',
|
|
145
|
-
// justOne: true, // Assuming a `slotId` corresponds to one `ItemSlot`
|
|
146
|
-
// },
|
|
147
|
-
// {
|
|
148
|
-
// name: 'quests'
|
|
149
|
-
// },
|
|
150
|
-
],
|
|
151
|
-
}
|
|
152
|
-
);
|
|
153
|
-
|
|
154
|
-
export const CharacterAbility = mongo.createModel<Types.CharacterAbilityDocument>('CharacterAbility', {});
|
|
155
|
-
|
|
156
|
-
export const CharacterAttribute = mongo.createModel<Types.CharacterAttributeDocument>('CharacterAttribute', {});
|
|
157
|
-
|
|
158
|
-
export const CharacterType = mongo.createModel<Types.CharacterTypeDocument>('CharacterType', {});
|
|
159
|
-
|
|
160
|
-
export const CharacterClass = mongo.createModel<Types.CharacterClassDocument>('CharacterClass', {});
|
|
161
|
-
|
|
162
|
-
export const CharacterFaction = mongo.createModel<Types.CharacterFactionDocument>('CharacterFaction', {});
|
|
163
|
-
|
|
164
|
-
export const CharacterRace = mongo.createModel<Types.CharacterRaceDocument>('CharacterRace', {});
|
|
165
|
-
|
|
166
|
-
export const CharacterGender = mongo.createModel<Types.CharacterGenderDocument>('CharacterGender', {});
|
|
167
|
-
|
|
168
|
-
export const CharacterPersonality = mongo.createModel<Types.CharacterPersonalityDocument>('CharacterPersonality', {});
|
|
169
|
-
|
|
170
|
-
export const CharacterTitle = mongo.createModel<Types.CharacterTitleDocument>('CharacterTitle', {});
|
|
171
|
-
|
|
172
|
-
export const CharacterGuild = mongo.createModel<Types.CharacterGuildDocument>('CharacterGuild', {});
|
|
173
|
-
|
|
174
|
-
export const CharacterNameChoice = mongo.createModel<Types.CharacterNameChoiceDocument>('CharacterNameChoice', {});
|
|
@@ -1,314 +0,0 @@
|
|
|
1
|
-
// module/character.router.ts
|
|
2
|
-
|
|
3
|
-
import { z as zod } from 'zod';
|
|
4
|
-
import { initTRPC } from '@trpc/server';
|
|
5
|
-
import { customErrorFormatter, hasRole } from '../../util/rpc';
|
|
6
|
-
import type { RouterContext } from '../../types';
|
|
7
|
-
import {
|
|
8
|
-
Character,
|
|
9
|
-
CharacterAbility,
|
|
10
|
-
CharacterAttribute,
|
|
11
|
-
CharacterType,
|
|
12
|
-
CharacterClass,
|
|
13
|
-
CharacterRace,
|
|
14
|
-
CharacterGender,
|
|
15
|
-
CharacterPersonality,
|
|
16
|
-
CharacterTitle,
|
|
17
|
-
CharacterFaction,
|
|
18
|
-
CharacterNameChoice,
|
|
19
|
-
} from './character.schema';
|
|
20
|
-
import { Query, getQueryInput, inferRouterOutputs, inferRouterInputs } from '../../schema';
|
|
21
|
-
|
|
22
|
-
export const z = zod;
|
|
23
|
-
export const t = initTRPC.context<RouterContext>().create();
|
|
24
|
-
export const router = t.router;
|
|
25
|
-
export const procedure = t.procedure;
|
|
26
|
-
|
|
27
|
-
export const createRouter = () =>
|
|
28
|
-
router({
|
|
29
|
-
getCharacterInventory: procedure
|
|
30
|
-
.use(hasRole('user', t))
|
|
31
|
-
.use(customErrorFormatter(t))
|
|
32
|
-
.input(
|
|
33
|
-
z.object({
|
|
34
|
-
characterId: z.string(),
|
|
35
|
-
})
|
|
36
|
-
)
|
|
37
|
-
.mutation(({ input, ctx }) => (ctx.app.service.Character.getCharacterInventory as any)(input, ctx)),
|
|
38
|
-
|
|
39
|
-
setActiveCharacter: procedure
|
|
40
|
-
.use(hasRole('user', t))
|
|
41
|
-
.use(customErrorFormatter(t))
|
|
42
|
-
.input(
|
|
43
|
-
z.object({
|
|
44
|
-
characterId: z.string(),
|
|
45
|
-
})
|
|
46
|
-
)
|
|
47
|
-
.mutation(({ input, ctx }) => (ctx.app.service.Character.setActiveCharacter as any)(input, ctx)),
|
|
48
|
-
|
|
49
|
-
exchangeCharacterItem: procedure
|
|
50
|
-
.use(hasRole('user', t))
|
|
51
|
-
.use(customErrorFormatter(t))
|
|
52
|
-
.input(
|
|
53
|
-
z.object({
|
|
54
|
-
characterId: z.string(),
|
|
55
|
-
itemId: z.string(),
|
|
56
|
-
})
|
|
57
|
-
)
|
|
58
|
-
.mutation(({ input, ctx }) => (ctx.app.service.Character.exchangeCharacterItem as any)(input, ctx)),
|
|
59
|
-
|
|
60
|
-
getCharacterData: procedure
|
|
61
|
-
.use(hasRole('guest', t))
|
|
62
|
-
.use(customErrorFormatter(t))
|
|
63
|
-
.input(getQueryInput(Character))
|
|
64
|
-
.query(({ input, ctx }) => (ctx.app.service.Character.getCharacterData as any)(input, ctx)),
|
|
65
|
-
|
|
66
|
-
getCharacter: procedure
|
|
67
|
-
.use(hasRole('guest', t))
|
|
68
|
-
.use(customErrorFormatter(t))
|
|
69
|
-
.input(getQueryInput(Character))
|
|
70
|
-
// .output(Character)
|
|
71
|
-
.query(({ input, ctx }) => (ctx.app.service.Character.getCharacter as any)(input, ctx)),
|
|
72
|
-
|
|
73
|
-
getCharacters: procedure
|
|
74
|
-
.use(hasRole('guest', t))
|
|
75
|
-
.use(customErrorFormatter(t))
|
|
76
|
-
.input(getQueryInput(Character))
|
|
77
|
-
// .output(z.array(Character))
|
|
78
|
-
.query(({ input, ctx }) => (ctx.app.service.Character.getCharacters as any)(input, ctx)),
|
|
79
|
-
|
|
80
|
-
saveCharacters: procedure
|
|
81
|
-
.use(hasRole('admin', t))
|
|
82
|
-
.use(customErrorFormatter(t))
|
|
83
|
-
.input(getQueryInput(z.array(Character), { partialData: false }))
|
|
84
|
-
// .output(z.array(Character.pick({ id: true })))
|
|
85
|
-
.mutation(({ input, ctx }) => (ctx.app.service.Character.saveCharacters as any)(input, ctx)),
|
|
86
|
-
|
|
87
|
-
updateCharacter: procedure
|
|
88
|
-
.use(hasRole('admin', t))
|
|
89
|
-
.use(customErrorFormatter(t))
|
|
90
|
-
.input(getQueryInput(Character))
|
|
91
|
-
.output(Character.pick({ id: true }))
|
|
92
|
-
.mutation(({ input, ctx }) => (ctx.app.service.Character.updateCharacter as any)(input, ctx)),
|
|
93
|
-
|
|
94
|
-
getCharacterAbility: procedure
|
|
95
|
-
.use(hasRole('guest', t))
|
|
96
|
-
.use(customErrorFormatter(t))
|
|
97
|
-
.input(getQueryInput(CharacterAbility))
|
|
98
|
-
.output(CharacterAbility)
|
|
99
|
-
.query(({ input, ctx }) => (ctx.app.service.Character.getCharacterAbility as any)(input, ctx)),
|
|
100
|
-
|
|
101
|
-
createCharacterAbility: procedure
|
|
102
|
-
.use(hasRole('admin', t))
|
|
103
|
-
.use(customErrorFormatter(t))
|
|
104
|
-
.input(getQueryInput(CharacterAbility))
|
|
105
|
-
.output(CharacterAbility.pick({ id: true }))
|
|
106
|
-
.mutation(({ input, ctx }) => (ctx.app.service.Character.createCharacterAbility as any)(input, ctx)),
|
|
107
|
-
|
|
108
|
-
updateCharacterAbility: procedure
|
|
109
|
-
.use(hasRole('admin', t))
|
|
110
|
-
.use(customErrorFormatter(t))
|
|
111
|
-
.input(getQueryInput(CharacterAbility))
|
|
112
|
-
.output(CharacterAbility.pick({ id: true }))
|
|
113
|
-
.mutation(({ input, ctx }) => (ctx.app.service.Character.updateCharacterAbility as any)(input, ctx)),
|
|
114
|
-
|
|
115
|
-
getCharacterAttribute: procedure
|
|
116
|
-
.use(hasRole('guest', t))
|
|
117
|
-
.use(customErrorFormatter(t))
|
|
118
|
-
.input(getQueryInput(CharacterAttribute))
|
|
119
|
-
.output(CharacterAttribute)
|
|
120
|
-
.query(({ input, ctx }) => (ctx.app.service.Character.getCharacterAttribute as any)(input, ctx)),
|
|
121
|
-
|
|
122
|
-
createCharacterAttribute: procedure
|
|
123
|
-
.use(hasRole('admin', t))
|
|
124
|
-
.use(customErrorFormatter(t))
|
|
125
|
-
.input(getQueryInput(CharacterAttribute))
|
|
126
|
-
.output(CharacterAttribute.pick({ id: true }))
|
|
127
|
-
.mutation(({ input, ctx }) => (ctx.app.service.Character.createCharacterAttribute as any)(input, ctx)),
|
|
128
|
-
|
|
129
|
-
updateCharacterAttribute: procedure
|
|
130
|
-
.use(hasRole('admin', t))
|
|
131
|
-
.use(customErrorFormatter(t))
|
|
132
|
-
.input(getQueryInput(Character))
|
|
133
|
-
.output(Character.pick({ id: true }))
|
|
134
|
-
.mutation(({ input, ctx }) => (ctx.app.service.Character.updateCharacterAttribute as any)(input, ctx)),
|
|
135
|
-
|
|
136
|
-
getCharacterType: procedure
|
|
137
|
-
.use(hasRole('guest', t))
|
|
138
|
-
.use(customErrorFormatter(t))
|
|
139
|
-
.input(getQueryInput(CharacterType))
|
|
140
|
-
.output(CharacterType)
|
|
141
|
-
.query(({ input, ctx }) => (ctx.app.service.Character.getCharacterType as any)(input, ctx)),
|
|
142
|
-
|
|
143
|
-
createCharacterType: procedure
|
|
144
|
-
.use(hasRole('admin', t))
|
|
145
|
-
.use(customErrorFormatter(t))
|
|
146
|
-
.input(getQueryInput(CharacterType))
|
|
147
|
-
.output(CharacterType.pick({ id: true }))
|
|
148
|
-
.mutation(({ input, ctx }) => (ctx.app.service.Character.createCharacterType as any)(input, ctx)),
|
|
149
|
-
|
|
150
|
-
updateCharacterType: procedure
|
|
151
|
-
.use(hasRole('admin', t))
|
|
152
|
-
.use(customErrorFormatter(t))
|
|
153
|
-
.input(getQueryInput(CharacterType))
|
|
154
|
-
.output(CharacterType.pick({ id: true }))
|
|
155
|
-
.mutation(({ input, ctx }) => (ctx.app.service.Character.updateCharacterType as any)(input, ctx)),
|
|
156
|
-
|
|
157
|
-
getCharacterClass: procedure
|
|
158
|
-
.use(hasRole('guest', t))
|
|
159
|
-
.use(customErrorFormatter(t))
|
|
160
|
-
.input(getQueryInput(CharacterClass))
|
|
161
|
-
.output(CharacterClass)
|
|
162
|
-
.query(({ input, ctx }) => (ctx.app.service.Character.getCharacterClass as any)(input, ctx)),
|
|
163
|
-
|
|
164
|
-
createCharacterClass: procedure
|
|
165
|
-
.use(hasRole('admin', t))
|
|
166
|
-
.use(customErrorFormatter(t))
|
|
167
|
-
.input(getQueryInput(CharacterClass))
|
|
168
|
-
.output(CharacterClass.pick({ id: true }))
|
|
169
|
-
.mutation(({ input, ctx }) => (ctx.app.service.Character.createCharacterClass as any)(input, ctx)),
|
|
170
|
-
|
|
171
|
-
updateCharacterClass: procedure
|
|
172
|
-
.use(hasRole('admin', t))
|
|
173
|
-
.use(customErrorFormatter(t))
|
|
174
|
-
.input(getQueryInput(CharacterClass))
|
|
175
|
-
.output(CharacterClass.pick({ id: true }))
|
|
176
|
-
.mutation(({ input, ctx }) => (ctx.app.service.Character.updateCharacterClass as any)(input, ctx)),
|
|
177
|
-
|
|
178
|
-
getCharacterRace: procedure
|
|
179
|
-
.use(hasRole('guest', t))
|
|
180
|
-
.use(customErrorFormatter(t))
|
|
181
|
-
.input(getQueryInput(Character))
|
|
182
|
-
.output(Character)
|
|
183
|
-
.query(({ input, ctx }) => (ctx.app.service.Character.getCharacterRace as any)(input, ctx)),
|
|
184
|
-
|
|
185
|
-
createCharacterRace: procedure
|
|
186
|
-
.use(hasRole('admin', t))
|
|
187
|
-
.use(customErrorFormatter(t))
|
|
188
|
-
.input(getQueryInput(CharacterRace))
|
|
189
|
-
.output(CharacterRace.pick({ id: true }))
|
|
190
|
-
.mutation(({ input, ctx }) => (ctx.app.service.Character.createCharacterRace as any)(input, ctx)),
|
|
191
|
-
|
|
192
|
-
updateCharacterRace: procedure
|
|
193
|
-
.use(hasRole('admin', t))
|
|
194
|
-
.use(customErrorFormatter(t))
|
|
195
|
-
.input(getQueryInput(CharacterRace))
|
|
196
|
-
.output(CharacterRace.pick({ id: true }))
|
|
197
|
-
.mutation(({ input, ctx }) => (ctx.app.service.Character.updateCharacterRace as any)(input, ctx)),
|
|
198
|
-
|
|
199
|
-
getCharacterGender: procedure
|
|
200
|
-
.use(hasRole('guest', t))
|
|
201
|
-
.use(customErrorFormatter(t))
|
|
202
|
-
.input(getQueryInput(CharacterGender))
|
|
203
|
-
.output(CharacterGender)
|
|
204
|
-
.query(({ input, ctx }) => (ctx.app.service.Character.getCharacterGender as any)(input, ctx)),
|
|
205
|
-
|
|
206
|
-
createCharacterGender: procedure
|
|
207
|
-
.use(hasRole('admin', t))
|
|
208
|
-
.use(customErrorFormatter(t))
|
|
209
|
-
.input(getQueryInput(CharacterGender))
|
|
210
|
-
.output(CharacterGender.pick({ id: true }))
|
|
211
|
-
.mutation(({ input, ctx }) => (ctx.app.service.Character.createCharacterGender as any)(input, ctx)),
|
|
212
|
-
|
|
213
|
-
updateCharacterGender: procedure
|
|
214
|
-
.use(hasRole('admin', t))
|
|
215
|
-
.use(customErrorFormatter(t))
|
|
216
|
-
.input(getQueryInput(Character))
|
|
217
|
-
.output(Character.pick({ id: true }))
|
|
218
|
-
.mutation(({ input, ctx }) => (ctx.app.service.Character.updateCharacterGender as any)(input, ctx)),
|
|
219
|
-
|
|
220
|
-
getCharacterPersonality: procedure
|
|
221
|
-
.use(hasRole('guest', t))
|
|
222
|
-
.use(customErrorFormatter(t))
|
|
223
|
-
.input(getQueryInput(CharacterPersonality))
|
|
224
|
-
.output(CharacterPersonality)
|
|
225
|
-
.query(({ input, ctx }) => (ctx.app.service.Character.getCharacterPersonality as any)(input, ctx)),
|
|
226
|
-
|
|
227
|
-
createCharacterPersonality: procedure
|
|
228
|
-
.use(hasRole('admin', t))
|
|
229
|
-
.use(customErrorFormatter(t))
|
|
230
|
-
.input(getQueryInput(CharacterPersonality))
|
|
231
|
-
.output(CharacterPersonality.pick({ id: true }))
|
|
232
|
-
.mutation(({ input, ctx }) => (ctx.app.service.Character.createCharacterPersonality as any)(input, ctx)),
|
|
233
|
-
|
|
234
|
-
updateCharacterPersonality: procedure
|
|
235
|
-
.use(hasRole('admin', t))
|
|
236
|
-
.use(customErrorFormatter(t))
|
|
237
|
-
.input(getQueryInput(CharacterPersonality))
|
|
238
|
-
.output(CharacterPersonality.pick({ id: true }))
|
|
239
|
-
.mutation(({ input, ctx }) => (ctx.app.service.Character.updateCharacterPersonality as any)(input, ctx)),
|
|
240
|
-
|
|
241
|
-
getCharacterTitle: procedure
|
|
242
|
-
.use(hasRole('guest', t))
|
|
243
|
-
.use(customErrorFormatter(t))
|
|
244
|
-
.input(getQueryInput(CharacterTitle))
|
|
245
|
-
.output(CharacterTitle)
|
|
246
|
-
.query(({ input, ctx }) => (ctx.app.service.Character.getCharacterTitle as any)(input, ctx)),
|
|
247
|
-
|
|
248
|
-
createCharacterTitle: procedure
|
|
249
|
-
.use(hasRole('admin', t))
|
|
250
|
-
.use(customErrorFormatter(t))
|
|
251
|
-
.input(getQueryInput(CharacterTitle))
|
|
252
|
-
.output(CharacterTitle.pick({ id: true }))
|
|
253
|
-
.mutation(({ input, ctx }) => (ctx.app.service.Character.createCharacterTitle as any)(input, ctx)),
|
|
254
|
-
|
|
255
|
-
updateCharacterTitle: procedure
|
|
256
|
-
.use(hasRole('admin', t))
|
|
257
|
-
.use(customErrorFormatter(t))
|
|
258
|
-
.input(getQueryInput(CharacterTitle))
|
|
259
|
-
.output(CharacterTitle.pick({ id: true }))
|
|
260
|
-
.mutation(({ input, ctx }) => (ctx.app.service.Character.updateCharacterTitle as any)(input, ctx)),
|
|
261
|
-
|
|
262
|
-
getCharacterFaction: procedure
|
|
263
|
-
.use(hasRole('guest', t))
|
|
264
|
-
.use(customErrorFormatter(t))
|
|
265
|
-
.input(getQueryInput(CharacterFaction))
|
|
266
|
-
.output(CharacterFaction)
|
|
267
|
-
.query(({ input, ctx }) => (ctx.app.service.Character.getCharacterFaction as any)(input, ctx)),
|
|
268
|
-
|
|
269
|
-
getCharacterFactions: procedure
|
|
270
|
-
.use(hasRole('guest', t))
|
|
271
|
-
.use(customErrorFormatter(t))
|
|
272
|
-
.input(getQueryInput(CharacterFaction))
|
|
273
|
-
.output(z.array(CharacterFaction))
|
|
274
|
-
.query(({ input, ctx }) => (ctx.app.service.Character.getCharacterFactions as any)(input, ctx)),
|
|
275
|
-
|
|
276
|
-
createCharacterFaction: procedure
|
|
277
|
-
.use(hasRole('admin', t))
|
|
278
|
-
.use(customErrorFormatter(t))
|
|
279
|
-
.input(getQueryInput(CharacterFaction))
|
|
280
|
-
.output(CharacterFaction.pick({ id: true }))
|
|
281
|
-
.mutation(({ input, ctx }) => (ctx.app.service.Character.createCharacterFaction as any)(input, ctx)),
|
|
282
|
-
|
|
283
|
-
updateCharacterFaction: procedure
|
|
284
|
-
.use(hasRole('admin', t))
|
|
285
|
-
.use(customErrorFormatter(t))
|
|
286
|
-
.input(getQueryInput(CharacterFaction))
|
|
287
|
-
.output(CharacterFaction.pick({ id: true }))
|
|
288
|
-
.mutation(({ input, ctx }) => (ctx.app.service.Character.updateCharacterFaction as any)(input, ctx)),
|
|
289
|
-
|
|
290
|
-
getCharacterNameChoice: procedure
|
|
291
|
-
.use(hasRole('guest', t))
|
|
292
|
-
.use(customErrorFormatter(t))
|
|
293
|
-
.input(getQueryInput(CharacterNameChoice))
|
|
294
|
-
.output(CharacterNameChoice)
|
|
295
|
-
.query(({ input, ctx }) => (ctx.app.service.Character.getCharacterNameChoice as any)(input, ctx)),
|
|
296
|
-
|
|
297
|
-
createCharacterNameChoice: procedure
|
|
298
|
-
.use(hasRole('admin', t))
|
|
299
|
-
.use(customErrorFormatter(t))
|
|
300
|
-
.input(getQueryInput(CharacterNameChoice))
|
|
301
|
-
.output(CharacterNameChoice.pick({ id: true }))
|
|
302
|
-
.mutation(({ input, ctx }) => (ctx.app.service.Character.createCharacterNameChoice as any)(input, ctx)),
|
|
303
|
-
|
|
304
|
-
updateCharacterNameChoice: procedure
|
|
305
|
-
.use(hasRole('admin', t))
|
|
306
|
-
.use(customErrorFormatter(t))
|
|
307
|
-
.input(getQueryInput(CharacterNameChoice))
|
|
308
|
-
.output(CharacterNameChoice.pick({ id: true }))
|
|
309
|
-
.mutation(({ input, ctx }) => (ctx.app.service.Character.updateCharacterNameChoice as any)(input, ctx)),
|
|
310
|
-
});
|
|
311
|
-
|
|
312
|
-
export type Router = ReturnType<typeof createRouter>;
|
|
313
|
-
export type RouterInput = inferRouterInputs<Router>;
|
|
314
|
-
export type RouterOutput = inferRouterOutputs<Router>;
|