@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,59 @@
|
|
|
1
|
+
// arken/packages/node/modules/interface/interface.schema.ts
|
|
2
|
+
//
|
|
3
|
+
import { z, ObjectId, Entity } from '../schema';
|
|
4
|
+
|
|
5
|
+
// Patch ops for interface composition
|
|
6
|
+
const InterfacePatch = z.object({
|
|
7
|
+
op: z.enum(['merge', 'replace', 'remove', 'push', 'unshift', 'splice']).default('merge'),
|
|
8
|
+
key: z.string().min(1), // target node key (or special key like "root")
|
|
9
|
+
path: z.string().optional(), // optional deep path inside that node, ex: "props.omit"
|
|
10
|
+
value: z.unknown().optional(), // payload for merge/replace/push/etc
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
export const Interface = Entity.merge(
|
|
14
|
+
z.object({
|
|
15
|
+
ratingId: ObjectId.optional(),
|
|
16
|
+
groupId: ObjectId.optional(),
|
|
17
|
+
submissions: z.array(ObjectId).optional(),
|
|
18
|
+
|
|
19
|
+
// ✅ NEW: composition / inheritance
|
|
20
|
+
inherits: z.array(z.string()).default([]),
|
|
21
|
+
|
|
22
|
+
// ✅ NEW: variables available to formula scope + patch engine
|
|
23
|
+
variables: z.record(z.unknown()).default({}),
|
|
24
|
+
|
|
25
|
+
// ✅ NEW: patch list applied on top of inherited/base nodes
|
|
26
|
+
patches: z.array(InterfacePatch).default([]),
|
|
27
|
+
|
|
28
|
+
// existing
|
|
29
|
+
nodes: z.any(), // you can later tighten this to z.array(AnyNodeSchema)
|
|
30
|
+
version: z.number().optional(),
|
|
31
|
+
status: z.enum(['Paused', 'Pending', 'Active', 'Archived', 'Published', 'Draft']).default('Active'),
|
|
32
|
+
})
|
|
33
|
+
);
|
|
34
|
+
|
|
35
|
+
export const InterfaceGroup = Entity.merge(
|
|
36
|
+
z.object({
|
|
37
|
+
roles: z.array(ObjectId).optional(),
|
|
38
|
+
})
|
|
39
|
+
);
|
|
40
|
+
|
|
41
|
+
export const InterfaceComponent = Entity.merge(
|
|
42
|
+
z.object({
|
|
43
|
+
value: z.unknown().optional(),
|
|
44
|
+
data: z.record(z.unknown()).optional(),
|
|
45
|
+
type: z.string().optional(),
|
|
46
|
+
hasAttachment: z.boolean().optional(),
|
|
47
|
+
hasValidation: z.boolean().optional(),
|
|
48
|
+
isDisabled: z.boolean().optional(),
|
|
49
|
+
isEditable: z.boolean().optional(),
|
|
50
|
+
isRequired: z.boolean().optional(),
|
|
51
|
+
})
|
|
52
|
+
);
|
|
53
|
+
|
|
54
|
+
export const InterfaceSubmission = Entity.merge(
|
|
55
|
+
z.object({
|
|
56
|
+
interfaceId: ObjectId,
|
|
57
|
+
interface: ObjectId.optional(),
|
|
58
|
+
})
|
|
59
|
+
);
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { z, Model, Document } from '@arken/node/mongo';
|
|
2
|
+
import * as schema from './interface.schema';
|
|
3
|
+
|
|
4
|
+
export type * from './interface.router';
|
|
5
|
+
export type { RouterContext } from '../types';
|
|
6
|
+
|
|
7
|
+
export type Interface = z.infer<typeof schema.Interface>;
|
|
8
|
+
export type InterfaceDocument = Interface & Document;
|
|
9
|
+
|
|
10
|
+
export type InterfaceGroup = z.infer<typeof schema.InterfaceGroup>;
|
|
11
|
+
export type InterfaceGroupDocument = InterfaceGroup & Document;
|
|
12
|
+
|
|
13
|
+
export type InterfaceComponent = z.infer<typeof schema.InterfaceComponent>;
|
|
14
|
+
export type InterfaceComponentDocument = InterfaceComponent & Document;
|
|
15
|
+
|
|
16
|
+
export type InterfaceSubmission = z.infer<typeof schema.InterfaceSubmission>;
|
|
17
|
+
export type InterfaceSubmissionDocument = InterfaceSubmission & Document;
|
|
18
|
+
|
|
19
|
+
export type Mappings = {
|
|
20
|
+
Interface: Model<InterfaceDocument>;
|
|
21
|
+
InterfaceGroup: Model<InterfaceGroupDocument>;
|
|
22
|
+
InterfaceComponent: Model<InterfaceComponentDocument>;
|
|
23
|
+
InterfaceSubmission: Model<InterfaceSubmissionDocument>;
|
|
24
|
+
};
|
package/isles/index.ts
CHANGED
package/isles/isles.models.ts
CHANGED
package/isles/isles.router.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { z as zod } from 'zod';
|
|
2
2
|
import { initTRPC } from '@trpc/server';
|
|
3
|
-
import { customErrorFormatter, hasRole } from '@arken/rpc';
|
|
3
|
+
import { customErrorFormatter, hasRole } from '@arken/node/rpc';
|
|
4
4
|
import * as Arken from '@arken/node';
|
|
5
|
-
import { Query, getQueryInput, inferRouterOutputs, inferRouterInputs } from '@arken/schema';
|
|
6
|
-
import { RouterContext } from '
|
|
5
|
+
import { Query, getQueryInput, inferRouterOutputs, inferRouterInputs } from '@arken/node/schema';
|
|
6
|
+
import { RouterContext } from '../types';
|
|
7
7
|
|
|
8
8
|
export const z = zod;
|
|
9
9
|
export const t = initTRPC.context<RouterContext>().create();
|
|
@@ -1316,20 +1316,20 @@ export type RouterOutput = inferRouterOutputs<Router>;
|
|
|
1316
1316
|
// }
|
|
1317
1317
|
// });
|
|
1318
1318
|
|
|
1319
|
-
// import type * as Arken from '@arken/types';
|
|
1320
|
-
// import { isDebug, log } from '@arken/util';
|
|
1319
|
+
// import type * as Arken from '@arken/node/types';
|
|
1320
|
+
// import { isDebug, log } from '@arken/node/util';
|
|
1321
1321
|
// import * as dotenv from 'dotenv';
|
|
1322
|
-
// import { catchExceptions, subProcesses } from '@arken/process';
|
|
1322
|
+
// import { catchExceptions, subProcesses } from '@arken/node/process';
|
|
1323
1323
|
// import fetch from 'node-fetch';
|
|
1324
1324
|
|
|
1325
1325
|
// import path from 'path';
|
|
1326
1326
|
// import jetpack, { find } from 'fs-jetpack';
|
|
1327
1327
|
// import beautify from 'json-beautify';
|
|
1328
|
-
// import { fancyTimeFormat } from '@arken/time';
|
|
1328
|
+
// import { fancyTimeFormat } from '@arken/node/time';
|
|
1329
1329
|
// import md5 from 'js-md5';
|
|
1330
1330
|
// import { getClientSocket } from '@arken/websocket';
|
|
1331
|
-
// import { isValidRequest, getSignedRequest } from '@arken/web3';
|
|
1332
|
-
// import getUsername from '@arken/legacy/getOldUsername';
|
|
1331
|
+
// import { isValidRequest, getSignedRequest } from '@arken/node/web3';
|
|
1332
|
+
// import getUsername from '@arken/node/legacy/getOldUsername';
|
|
1333
1333
|
// import { z } from 'zod';
|
|
1334
1334
|
|
|
1335
1335
|
// export async function monitorEvolutionRealms(app) {}
|
package/isles/isles.schema.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import { z, ObjectId, Entity } from '@arken/schema';
|
|
1
|
+
import { z, ObjectId, Entity } from '@arken/node/schema';
|
package/isles/isles.types.ts
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
-
import { Model, Document } from '@arken/mongo';
|
|
2
|
+
import { Model, Document } from '@arken/node/mongo';
|
|
3
3
|
import * as schema from './isles.schema';
|
|
4
4
|
|
|
5
5
|
export type * from './isles.router';
|
|
6
|
-
export type
|
|
7
|
-
export type { RouterContext } from '../../types';
|
|
6
|
+
export type { RouterContext } from '../types';
|
|
8
7
|
|
|
9
8
|
// // Define types based on the schema
|
|
10
9
|
// export type Game = z.infer<typeof schema.Game>;
|
package/item/index.ts
ADDED
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
import * as mongo from '@arken/node/mongo';
|
|
2
|
+
import type * as Types from './item.types';
|
|
3
|
+
|
|
4
|
+
const { addTagVirtuals, addApplicationVirtual } = mongo;
|
|
5
|
+
|
|
6
|
+
export const Item = mongo.createModel<Types.ItemDocument>(
|
|
7
|
+
'Item',
|
|
8
|
+
{
|
|
9
|
+
token: { type: String, maxlength: 500, minlength: 1, required: true },
|
|
10
|
+
characterId: { type: mongo.Schema.Types.ObjectId, ref: 'Character', required: true },
|
|
11
|
+
assetId: { type: mongo.Schema.Types.ObjectId, ref: 'Asset', required: true },
|
|
12
|
+
chainId: { type: mongo.Schema.Types.ObjectId, ref: 'Chain', required: false },
|
|
13
|
+
materialId: { type: mongo.Schema.Types.ObjectId, ref: 'ItemMaterial', required: false },
|
|
14
|
+
skinId: { type: mongo.Schema.Types.ObjectId, ref: 'ItemSkin', required: false },
|
|
15
|
+
recipeId: { type: mongo.Schema.Types.ObjectId, ref: 'ItemRecipe', required: false },
|
|
16
|
+
typeId: { type: mongo.Schema.Types.ObjectId, ref: 'ItemType', required: false },
|
|
17
|
+
subTypeId: { type: mongo.Schema.Types.ObjectId, ref: 'ItemSubType', required: false },
|
|
18
|
+
specificTypeId: { type: mongo.Schema.Types.ObjectId, ref: 'ItemSpecificType', required: false },
|
|
19
|
+
rarityId: { type: mongo.Schema.Types.ObjectId, ref: 'ItemRarity', required: false },
|
|
20
|
+
rankId: { type: mongo.Schema.Types.ObjectId, ref: 'ItemRank', required: false },
|
|
21
|
+
rankValue: { type: Number, integer: true, min: 0, max: 100, required: false },
|
|
22
|
+
slotIds: [{ type: mongo.Schema.Types.ObjectId, ref: 'ItemSlot', required: false }],
|
|
23
|
+
setId: { type: mongo.Schema.Types.ObjectId, ref: 'ItemSet', required: false },
|
|
24
|
+
attributes: [{ type: mongo.Schema.Types.ObjectId, ref: 'ItemAttribute', required: false }],
|
|
25
|
+
quantity: { type: Number, integer: true, min: 0, default: 1 },
|
|
26
|
+
distribution: { type: String, default: 'Unknown' },
|
|
27
|
+
x: { type: Number, integer: true, min: 0, required: false },
|
|
28
|
+
y: { type: Number, integer: true, min: 0, required: false },
|
|
29
|
+
items: [{ type: mongo.Schema.Types.ObjectId, ref: 'Item', default: [] }],
|
|
30
|
+
capacity: { type: Number, integer: true, min: 0, default: 60 },
|
|
31
|
+
points: { type: Number, integer: true, min: 0, default: 0 },
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
extend: 'EntityFields',
|
|
35
|
+
indexes: [{ quantity: 1 }, { points: 1 }, { capacity: 1 }],
|
|
36
|
+
virtuals: [
|
|
37
|
+
...addTagVirtuals('Item'),
|
|
38
|
+
...addApplicationVirtual(),
|
|
39
|
+
{
|
|
40
|
+
name: 'character',
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
name: 'asset',
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
name: 'chain',
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
name: 'material',
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
name: 'skin',
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
name: 'recipe',
|
|
56
|
+
},
|
|
57
|
+
{
|
|
58
|
+
name: 'type',
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
name: 'subType',
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
name: 'specificType',
|
|
65
|
+
},
|
|
66
|
+
{
|
|
67
|
+
name: 'rarity',
|
|
68
|
+
},
|
|
69
|
+
],
|
|
70
|
+
}
|
|
71
|
+
);
|
|
72
|
+
|
|
73
|
+
export const ItemAttribute = mongo.createModel<Types.ItemAttributeDocument>('ItemAttribute', {});
|
|
74
|
+
|
|
75
|
+
export const ItemMaterial = mongo.createModel<Types.ItemMaterialDocument>('ItemMaterial', {});
|
|
76
|
+
|
|
77
|
+
export const ItemSet = mongo.createModel<Types.ItemSetDocument>('ItemSet', {});
|
|
78
|
+
|
|
79
|
+
export const ItemSlot = mongo.createModel<Types.ItemSlotDocument>('ItemSlot', {});
|
|
80
|
+
|
|
81
|
+
export const ItemRarity = mongo.createModel<Types.ItemRarityDocument>('ItemRarity', {});
|
|
82
|
+
|
|
83
|
+
export const ItemRank = mongo.createModel<Types.ItemRankDocument>('ItemRank', {
|
|
84
|
+
value: { type: Number },
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
export const ItemType = mongo.createModel<Types.ItemTypeDocument>('ItemType', {});
|
|
88
|
+
|
|
89
|
+
export const ItemSubType = mongo.createModel<Types.ItemSubTypeDocument>('ItemSubType', {});
|
|
90
|
+
|
|
91
|
+
export const ItemSpecificType = mongo.createModel<Types.ItemSpecificTypeDocument>('ItemSpecificType', {});
|
|
92
|
+
|
|
93
|
+
export const ItemAffix = mongo.createModel<Types.ItemAffixDocument>('ItemAffix', {
|
|
94
|
+
isPrefix: { type: Boolean, default: false },
|
|
95
|
+
isSuffix: { type: Boolean, default: false },
|
|
96
|
+
isTitle: { type: Boolean, default: false },
|
|
97
|
+
weight: { type: Number, min: 0, default: 1 },
|
|
98
|
+
typeIds: [{ type: mongo.Schema.Types.ObjectId, ref: 'ItemType', required: false }],
|
|
99
|
+
rarityIds: [{ type: mongo.Schema.Types.ObjectId, ref: 'ItemRarity', required: false }],
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
export const ItemRecipe = mongo.createModel<Types.ItemRecipeDocument>('ItemRecipe', {});
|
|
103
|
+
|
|
104
|
+
export const ItemSkin = mongo.createModel<Types.ItemSkinDocument>('ItemSkin', {});
|
|
105
|
+
|
|
106
|
+
export const ItemTransmute = mongo.createModel<Types.ItemTransmuteDocument>(
|
|
107
|
+
'ItemTransmute',
|
|
108
|
+
{
|
|
109
|
+
token: { type: String, maxlength: 500, required: true },
|
|
110
|
+
assetId: { type: mongo.Schema.Types.ObjectId, ref: 'Asset', required: true },
|
|
111
|
+
itemId: { type: mongo.Schema.Types.ObjectId, ref: 'Item', required: true },
|
|
112
|
+
chainId: { type: mongo.Schema.Types.ObjectId, ref: 'Chain' },
|
|
113
|
+
},
|
|
114
|
+
{
|
|
115
|
+
virtuals: [
|
|
116
|
+
{
|
|
117
|
+
name: 'item',
|
|
118
|
+
},
|
|
119
|
+
{
|
|
120
|
+
name: 'asset',
|
|
121
|
+
},
|
|
122
|
+
],
|
|
123
|
+
}
|
|
124
|
+
);
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import { z as zod } from 'zod';
|
|
2
|
+
import { initTRPC } from '@trpc/server';
|
|
3
|
+
import { customErrorFormatter, hasRole } from '@arken/node/rpc';
|
|
4
|
+
import type { RouterContext } from '../types';
|
|
5
|
+
import { Query, getQueryInput, inferRouterOutputs, inferRouterInputs } from '../schema';
|
|
6
|
+
import {
|
|
7
|
+
Item,
|
|
8
|
+
ItemAttribute,
|
|
9
|
+
ItemMaterial,
|
|
10
|
+
ItemSet,
|
|
11
|
+
ItemSlot,
|
|
12
|
+
ItemRarity,
|
|
13
|
+
ItemType,
|
|
14
|
+
ItemSubType,
|
|
15
|
+
ItemSpecificType,
|
|
16
|
+
ItemAffix,
|
|
17
|
+
ItemRecipe,
|
|
18
|
+
ItemSkin,
|
|
19
|
+
ItemTransmute,
|
|
20
|
+
} from './item.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
|
+
getItem: procedure
|
|
30
|
+
.use(hasRole('guest', t))
|
|
31
|
+
.input(getQueryInput(Item))
|
|
32
|
+
.output(Item)
|
|
33
|
+
.query(({ input, ctx }) => (ctx.app.service.Item.getItem as any)(input, ctx)),
|
|
34
|
+
|
|
35
|
+
getItems: procedure
|
|
36
|
+
.use(hasRole('guest', t))
|
|
37
|
+
.use(customErrorFormatter(t))
|
|
38
|
+
.input(getQueryInput(Item))
|
|
39
|
+
// .output(z.array(Item))
|
|
40
|
+
.query(({ input, ctx }) => (ctx.app.service.Item.getItems as any)(input, ctx)),
|
|
41
|
+
|
|
42
|
+
createItem: procedure
|
|
43
|
+
.use(hasRole('admin', t))
|
|
44
|
+
.use(customErrorFormatter(t))
|
|
45
|
+
.input(getQueryInput(Item))
|
|
46
|
+
.output(Item.pick({ id: true }))
|
|
47
|
+
.mutation(({ input, ctx }) => (ctx.app.service.Item.createItem as any)(input, ctx)),
|
|
48
|
+
|
|
49
|
+
updateItem: procedure
|
|
50
|
+
.use(hasRole('admin', t))
|
|
51
|
+
.use(customErrorFormatter(t))
|
|
52
|
+
.input(getQueryInput(Item))
|
|
53
|
+
.output(Item.pick({ id: true }))
|
|
54
|
+
.mutation(({ input, ctx }) => (ctx.app.service.Item.updateItem as any)(input, ctx)),
|
|
55
|
+
|
|
56
|
+
getItemAttribute: procedure
|
|
57
|
+
.use(hasRole('guest', t))
|
|
58
|
+
.use(customErrorFormatter(t))
|
|
59
|
+
.input(getQueryInput(ItemAttribute))
|
|
60
|
+
.output(ItemAttribute)
|
|
61
|
+
.query(({ input, ctx }) => (ctx.app.service.Item.getItemAttribute as any)(input, ctx)),
|
|
62
|
+
|
|
63
|
+
createItemAttribute: procedure
|
|
64
|
+
.use(hasRole('admin', t))
|
|
65
|
+
.use(customErrorFormatter(t))
|
|
66
|
+
.input(getQueryInput(ItemAttribute))
|
|
67
|
+
.output(ItemAttribute.pick({ id: true }))
|
|
68
|
+
.mutation(({ input, ctx }) => (ctx.app.service.Item.createItemAttribute as any)(input, ctx)),
|
|
69
|
+
|
|
70
|
+
updateItemAttribute: procedure
|
|
71
|
+
.use(hasRole('admin', t))
|
|
72
|
+
.use(customErrorFormatter(t))
|
|
73
|
+
.input(getQueryInput(ItemAttribute))
|
|
74
|
+
.output(ItemAttribute.pick({ id: true }))
|
|
75
|
+
.mutation(({ input, ctx }) => (ctx.app.service.Item.updateItemAttribute as any)(input, ctx)),
|
|
76
|
+
|
|
77
|
+
// Add more procedures for other entities like ItemMaterial, ItemSet, ItemSlot, ItemRarity, etc.
|
|
78
|
+
|
|
79
|
+
getItemTransmute: procedure
|
|
80
|
+
.use(hasRole('guest', t))
|
|
81
|
+
.use(customErrorFormatter(t))
|
|
82
|
+
.input(getQueryInput(ItemTransmute))
|
|
83
|
+
.output(ItemTransmute)
|
|
84
|
+
.query(({ input, ctx }) => (ctx.app.service.Item.getItemTransmute as any)(input, ctx)),
|
|
85
|
+
|
|
86
|
+
createItemTransmute: procedure
|
|
87
|
+
.use(hasRole('admin', t))
|
|
88
|
+
.use(customErrorFormatter(t))
|
|
89
|
+
.input(getQueryInput(ItemTransmute))
|
|
90
|
+
.output(ItemTransmute.pick({ id: true }))
|
|
91
|
+
.mutation(({ input, ctx }) => (ctx.app.service.Item.createItemTransmute as any)(input, ctx)),
|
|
92
|
+
|
|
93
|
+
updateItemTransmute: procedure
|
|
94
|
+
.use(hasRole('admin', t))
|
|
95
|
+
.use(customErrorFormatter(t))
|
|
96
|
+
.input(getQueryInput(ItemTransmute))
|
|
97
|
+
.output(ItemTransmute.pick({ id: true }))
|
|
98
|
+
.mutation(({ input, ctx }) => (ctx.app.service.Item.updateItemTransmute as any)(input, ctx)),
|
|
99
|
+
});
|
|
100
|
+
|
|
101
|
+
export type Router = ReturnType<typeof createRouter>;
|
|
102
|
+
export type RouterInput = inferRouterInputs<Router>;
|
|
103
|
+
export type RouterOutput = inferRouterOutputs<Router>;
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
import { z, ObjectId, Entity } from '../schema';
|
|
2
|
+
|
|
3
|
+
export const ItemAttribute = Entity.merge(
|
|
4
|
+
z.object({
|
|
5
|
+
// Define fields for ItemAttribute here if needed
|
|
6
|
+
})
|
|
7
|
+
);
|
|
8
|
+
|
|
9
|
+
export const ItemMaterial = Entity.merge(
|
|
10
|
+
z.object({
|
|
11
|
+
// Define fields for ItemMaterial here if needed
|
|
12
|
+
})
|
|
13
|
+
);
|
|
14
|
+
|
|
15
|
+
export const ItemSet = Entity.merge(
|
|
16
|
+
z.object({
|
|
17
|
+
// Define fields for ItemSet here if needed
|
|
18
|
+
})
|
|
19
|
+
);
|
|
20
|
+
|
|
21
|
+
export const ItemSlot = Entity.merge(
|
|
22
|
+
z.object({
|
|
23
|
+
// Define fields for ItemSlot here if needed
|
|
24
|
+
})
|
|
25
|
+
);
|
|
26
|
+
|
|
27
|
+
export const ItemRarity = Entity.merge(
|
|
28
|
+
z.object({
|
|
29
|
+
// Define fields for ItemRarity here if needed
|
|
30
|
+
})
|
|
31
|
+
);
|
|
32
|
+
|
|
33
|
+
export const ItemRank = Entity.merge(
|
|
34
|
+
z.object({
|
|
35
|
+
value: z.number(),
|
|
36
|
+
// Define fields for ItemRank here if needed
|
|
37
|
+
})
|
|
38
|
+
);
|
|
39
|
+
|
|
40
|
+
export const ItemType = Entity.merge(
|
|
41
|
+
z.object({
|
|
42
|
+
// Define fields for ItemType here if needed
|
|
43
|
+
})
|
|
44
|
+
);
|
|
45
|
+
|
|
46
|
+
export const ItemSubType = Entity.merge(
|
|
47
|
+
z.object({
|
|
48
|
+
// Define fields for ItemSubType here if needed
|
|
49
|
+
})
|
|
50
|
+
);
|
|
51
|
+
|
|
52
|
+
export const ItemSpecificType = Entity.merge(
|
|
53
|
+
z.object({
|
|
54
|
+
// Define fields for ItemSpecificType here if needed
|
|
55
|
+
})
|
|
56
|
+
);
|
|
57
|
+
|
|
58
|
+
export const ItemAffix = Entity.merge(
|
|
59
|
+
z.object({
|
|
60
|
+
isPrefix: z.boolean().default(false),
|
|
61
|
+
isSuffix: z.boolean().default(false),
|
|
62
|
+
isTitle: z.boolean().default(false),
|
|
63
|
+
weight: z
|
|
64
|
+
.number()
|
|
65
|
+
.min(0)
|
|
66
|
+
.default(1),
|
|
67
|
+
typeIds: z.array(ObjectId).optional(),
|
|
68
|
+
rarityIds: z.array(ObjectId).optional(),
|
|
69
|
+
})
|
|
70
|
+
);
|
|
71
|
+
|
|
72
|
+
export const ItemRecipe = Entity.merge(
|
|
73
|
+
z.object({
|
|
74
|
+
// Define fields for ItemRecipe here if needed
|
|
75
|
+
})
|
|
76
|
+
);
|
|
77
|
+
|
|
78
|
+
export const ItemSkin = Entity.merge(
|
|
79
|
+
z.object({
|
|
80
|
+
// Define fields for ItemSkin here if needed
|
|
81
|
+
})
|
|
82
|
+
);
|
|
83
|
+
|
|
84
|
+
export const ItemTransmute = Entity.merge(
|
|
85
|
+
z.object({
|
|
86
|
+
token: z
|
|
87
|
+
.string()
|
|
88
|
+
.max(500)
|
|
89
|
+
.min(1),
|
|
90
|
+
assetId: ObjectId,
|
|
91
|
+
itemId: ObjectId,
|
|
92
|
+
chainId: ObjectId.optional(),
|
|
93
|
+
})
|
|
94
|
+
);
|
|
95
|
+
|
|
96
|
+
export const Item = Entity.merge(
|
|
97
|
+
z.object({
|
|
98
|
+
characterId: ObjectId.optional(),
|
|
99
|
+
assetId: ObjectId.optional(),
|
|
100
|
+
chainId: ObjectId.optional(),
|
|
101
|
+
materialId: ItemMaterial.optional(),
|
|
102
|
+
skinId: ItemSkin.optional(),
|
|
103
|
+
recipeId: ItemRecipe.optional(),
|
|
104
|
+
typeId: ItemType.optional(),
|
|
105
|
+
subTypeId: ItemSubType.optional(),
|
|
106
|
+
specificTypeId: ItemSpecificType.optional(),
|
|
107
|
+
rankId: ItemRank.optional(),
|
|
108
|
+
rankValue: z.number(),
|
|
109
|
+
rarityId: ItemRarity.optional(),
|
|
110
|
+
slotIds: z.array(ItemSlot.optional()),
|
|
111
|
+
setId: ItemSet.optional(),
|
|
112
|
+
attributes: z.array(ItemAttribute).optional(),
|
|
113
|
+
token: z
|
|
114
|
+
.string()
|
|
115
|
+
.max(500)
|
|
116
|
+
.min(1)
|
|
117
|
+
.optional(),
|
|
118
|
+
quantity: z
|
|
119
|
+
.number()
|
|
120
|
+
.int()
|
|
121
|
+
.nonnegative()
|
|
122
|
+
.default(1),
|
|
123
|
+
x: z
|
|
124
|
+
.number()
|
|
125
|
+
.int()
|
|
126
|
+
.nonnegative()
|
|
127
|
+
.optional(),
|
|
128
|
+
y: z
|
|
129
|
+
.number()
|
|
130
|
+
.int()
|
|
131
|
+
.nonnegative()
|
|
132
|
+
.optional(),
|
|
133
|
+
distribution: z
|
|
134
|
+
.enum(['Unknown', 'Found', 'Fundraiser', 'Claimed', 'Crafted', 'Airdrop', 'Reward', 'Farmed', 'Migration'])
|
|
135
|
+
.default('Unknown'),
|
|
136
|
+
// properties: z.record(z.any()).optional(),
|
|
137
|
+
// type: z.string().default('bag'), // stash, bag, equipment, etc.
|
|
138
|
+
items: z.array(z.lazy(() => Item)).default([]),
|
|
139
|
+
capacity: z
|
|
140
|
+
.number()
|
|
141
|
+
.int()
|
|
142
|
+
.nonnegative()
|
|
143
|
+
.default(60),
|
|
144
|
+
points: z
|
|
145
|
+
.number()
|
|
146
|
+
.int()
|
|
147
|
+
.nonnegative()
|
|
148
|
+
.default(0),
|
|
149
|
+
})
|
|
150
|
+
);
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
// module/item.types.ts
|
|
2
|
+
|
|
3
|
+
import { z } from 'zod';
|
|
4
|
+
import * as schema from './item.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 './item.router';
|
|
9
|
+
|
|
10
|
+
export type * from './item.router';
|
|
11
|
+
export type { RouterContext };
|
|
12
|
+
|
|
13
|
+
export type Item = z.infer<typeof schema.Item>;
|
|
14
|
+
export type ItemDocument = Item & Document;
|
|
15
|
+
|
|
16
|
+
export type ItemAttribute = z.infer<typeof schema.ItemAttribute>;
|
|
17
|
+
export type ItemAttributeDocument = ItemAttribute & Document;
|
|
18
|
+
|
|
19
|
+
export type ItemMaterial = z.infer<typeof schema.ItemMaterial>;
|
|
20
|
+
export type ItemMaterialDocument = ItemMaterial & Document;
|
|
21
|
+
|
|
22
|
+
export type ItemSet = z.infer<typeof schema.ItemSet>;
|
|
23
|
+
export type ItemSetDocument = ItemSet & Document;
|
|
24
|
+
|
|
25
|
+
export type ItemSlot = z.infer<typeof schema.ItemSlot>;
|
|
26
|
+
export type ItemSlotDocument = ItemSlot & Document;
|
|
27
|
+
|
|
28
|
+
export type ItemRarity = z.infer<typeof schema.ItemRarity>;
|
|
29
|
+
export type ItemRarityDocument = ItemRarity & Document;
|
|
30
|
+
|
|
31
|
+
export type ItemRank = z.infer<typeof schema.ItemRank>;
|
|
32
|
+
export type ItemRankDocument = ItemRank & Document;
|
|
33
|
+
|
|
34
|
+
export type ItemType = z.infer<typeof schema.ItemType>;
|
|
35
|
+
export type ItemTypeDocument = ItemType & Document;
|
|
36
|
+
|
|
37
|
+
export type ItemSubType = z.infer<typeof schema.ItemSubType>;
|
|
38
|
+
export type ItemSubTypeDocument = ItemSubType & Document;
|
|
39
|
+
|
|
40
|
+
export type ItemSpecificType = z.infer<typeof schema.ItemSpecificType>;
|
|
41
|
+
export type ItemSpecificTypeDocument = ItemSpecificType & Document;
|
|
42
|
+
|
|
43
|
+
export type ItemAffix = z.infer<typeof schema.ItemAffix>;
|
|
44
|
+
export type ItemAffixDocument = ItemAffix & Document;
|
|
45
|
+
|
|
46
|
+
export type ItemRecipe = z.infer<typeof schema.ItemRecipe>;
|
|
47
|
+
export type ItemRecipeDocument = ItemRecipe & Document;
|
|
48
|
+
|
|
49
|
+
export type ItemSkin = z.infer<typeof schema.ItemSkin>;
|
|
50
|
+
export type ItemSkinDocument = ItemSkin & Document;
|
|
51
|
+
|
|
52
|
+
export type ItemTransmute = z.infer<typeof schema.ItemTransmute>;
|
|
53
|
+
export type ItemTransmuteDocument = ItemTransmute & Document;
|
|
54
|
+
|
|
55
|
+
export type Mappings = {
|
|
56
|
+
Item: Model<ItemDocument>;
|
|
57
|
+
ItemAttribute: Model<ItemAttributeDocument>;
|
|
58
|
+
ItemMaterial: Model<ItemMaterialDocument>;
|
|
59
|
+
ItemSet: Model<ItemSetDocument>;
|
|
60
|
+
ItemSlot: Model<ItemSlotDocument>;
|
|
61
|
+
ItemRarity: Model<ItemRarityDocument>;
|
|
62
|
+
ItemRank: Model<ItemRankDocument>;
|
|
63
|
+
ItemType: Model<ItemTypeDocument>;
|
|
64
|
+
ItemSubType: Model<ItemSubTypeDocument>;
|
|
65
|
+
ItemSpecificType: Model<ItemSpecificTypeDocument>;
|
|
66
|
+
ItemAffix: Model<ItemAffixDocument>;
|
|
67
|
+
ItemRecipe: Model<ItemRecipeDocument>;
|
|
68
|
+
ItemSkin: Model<ItemSkinDocument>;
|
|
69
|
+
ItemTransmute: Model<ItemTransmuteDocument>;
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
export type RouterInput = inferRouterInputs<Router>;
|
|
73
|
+
export type RouterOutput = inferRouterOutputs<Router>;
|
package/job/index.ts
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import * as mongo from '@arken/node/mongo';
|
|
2
|
+
import type * as Types from './job.types';
|
|
3
|
+
|
|
4
|
+
export const Job = mongo.createModel<Types.JobDocument>(
|
|
5
|
+
'Job',
|
|
6
|
+
{
|
|
7
|
+
mod: { type: String, required: true },
|
|
8
|
+
startDate: { type: Date },
|
|
9
|
+
expireDate: { type: Date },
|
|
10
|
+
},
|
|
11
|
+
{
|
|
12
|
+
indexes: [{ applicationId: 1, mod: 1, key: 1 }],
|
|
13
|
+
}
|
|
14
|
+
);
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
// job.router.ts
|
|
2
|
+
|
|
3
|
+
import { z as zod } from 'zod';
|
|
4
|
+
import { initTRPC, inferRouterInputs, inferRouterOutputs } from '@trpc/server';
|
|
5
|
+
import { customErrorFormatter, hasRole } from '@arken/node/rpc';
|
|
6
|
+
import type { RouterContext } from '../types';
|
|
7
|
+
import { Job } from './job.schema';
|
|
8
|
+
import { Query } from '../schema';
|
|
9
|
+
|
|
10
|
+
export const z = zod;
|
|
11
|
+
export const t = initTRPC.context<RouterContext>().create();
|
|
12
|
+
export const router = t.router;
|
|
13
|
+
export const procedure = t.procedure;
|
|
14
|
+
|
|
15
|
+
export const createRouter = () =>
|
|
16
|
+
router({
|
|
17
|
+
getJob: procedure
|
|
18
|
+
.use(hasRole('guest', t))
|
|
19
|
+
.use(customErrorFormatter(t))
|
|
20
|
+
.input(z.object({ query: Query }))
|
|
21
|
+
.query(({ input, ctx }) => (ctx.app.service.Job.getJob as any)(input, ctx)),
|
|
22
|
+
|
|
23
|
+
createJob: procedure
|
|
24
|
+
.use(hasRole('admin', t))
|
|
25
|
+
.use(customErrorFormatter(t))
|
|
26
|
+
.input(z.object({ data: Job }))
|
|
27
|
+
.mutation(({ input, ctx }) => (ctx.app.service.Job.createJob as any)(input, ctx)),
|
|
28
|
+
|
|
29
|
+
updateJob: procedure
|
|
30
|
+
.use(hasRole('admin', t))
|
|
31
|
+
.use(customErrorFormatter(t))
|
|
32
|
+
.input(z.object({ query: Query, data: Job.partial() }))
|
|
33
|
+
.mutation(({ input, ctx }) => (ctx.app.service.Job.updateJob as any)(input, ctx)),
|
|
34
|
+
|
|
35
|
+
updateMetrics: procedure
|
|
36
|
+
.use(hasRole('admin', t))
|
|
37
|
+
.use(customErrorFormatter(t))
|
|
38
|
+
.input(z.any())
|
|
39
|
+
.mutation(({ input, ctx }) => (ctx.app.service.Job.updateMetrics as any)(input, ctx)),
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
export type Router = ReturnType<typeof createRouter>;
|
|
43
|
+
export type RouterInput = inferRouterInputs<Router>;
|
|
44
|
+
export type RouterOutput = inferRouterOutputs<Router>;
|