@arken/seer-protocol 0.1.1 → 0.1.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/.rush/temp/shrinkwrap-deps.json +537 -56
- 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 +26 -0
- package/area/index.ts +5 -0
- package/asset/asset.models.ts +59 -0
- package/asset/asset.router.ts +55 -0
- package/asset/asset.schema.ts +27 -0
- package/asset/asset.types.ts +22 -0
- package/asset/index.ts +5 -0
- package/chain/chain.models.ts +50 -0
- package/chain/chain.router.ts +104 -0
- package/chain/chain.schema.ts +52 -0
- package/chain/chain.types.ts +24 -0
- package/chain/index.ts +5 -0
- package/character/character.models.ts +174 -0
- package/character/character.router.ts +314 -0
- package/character/character.schema.ts +147 -0
- package/character/character.types.ts +64 -0
- package/character/index.ts +5 -0
- package/chat/chat.models.ts +43 -0
- package/chat/chat.router.ts +67 -0
- package/chat/chat.schema.ts +36 -0
- package/chat/chat.types.ts +20 -0
- package/chat/index.ts +5 -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 +36 -0
- package/collection/index.ts +5 -0
- package/core/core.models.ts +1380 -0
- package/core/core.router.ts +1781 -0
- package/core/core.schema.ts +847 -0
- package/core/core.types.ts +340 -0
- package/core/index.ts +5 -0
- package/evolution/evolution.models.ts +1 -1
- package/evolution/evolution.router.ts +8 -8
- package/evolution/evolution.schema.ts +1 -1
- package/evolution/evolution.types.ts +1 -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 +28 -0
- package/game/index.ts +5 -0
- package/index.ts +39 -2
- package/infinite/infinite.models.ts +1 -1
- package/infinite/infinite.router.ts +8 -8
- package/infinite/infinite.schema.ts +1 -1
- package/infinite/infinite.types.ts +1 -1
- package/interface/index.ts +5 -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 +25 -0
- package/isles/isles.models.ts +1 -1
- package/isles/isles.router.ts +8 -8
- package/isles/isles.schema.ts +1 -1
- package/isles/isles.types.ts +1 -1
- package/item/index.ts +5 -0
- package/item/item.models.ts +124 -0
- package/item/item.router.ts +103 -0
- package/item/item.schema.ts +120 -0
- package/item/item.types.ts +74 -0
- package/job/index.ts +5 -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 +23 -0
- package/market/index.ts +5 -0
- package/market/market.models.ts +113 -0
- package/market/market.router.ts +73 -0
- package/market/market.schema.ts +140 -0
- package/market/market.types.ts +56 -0
- package/oasis/oasis.models.ts +1 -1
- package/oasis/oasis.router.ts +2 -2
- package/oasis/oasis.schema.ts +1 -1
- package/oasis/oasis.types.ts +1 -1
- package/package.json +10 -3
- package/product/index.ts +5 -0
- package/product/product.models.ts +166 -0
- package/product/product.router.ts +93 -0
- package/product/product.schema.ts +149 -0
- package/product/product.types.ts +33 -0
- package/profile/index.ts +5 -0
- package/profile/profile.models.ts +214 -0
- package/profile/profile.router.ts +72 -0
- package/profile/profile.schema.ts +156 -0
- package/profile/profile.types.ts +22 -0
- package/raffle/index.ts +5 -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 +30 -0
- package/router.ts +23 -29
- package/schema.ts +321 -0
- package/skill/index.ts +5 -0
- package/skill/skill.models.ts +16 -0
- package/skill/skill.router.ts +201 -0
- package/skill/skill.schema.ts +40 -0
- package/skill/skill.types.ts +33 -0
- package/trek/trek.models.ts +1 -1
- package/trek/trek.router.ts +1 -1
- package/trek/trek.schema.ts +1 -1
- package/trek/trek.types.ts +1 -1
- package/types.ts +172 -5
- package/video/index.ts +5 -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 +33 -0
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import * as mongo from '../../util/mongo';
|
|
2
|
+
import type * as Types from './area.types';
|
|
3
|
+
|
|
4
|
+
export const Area = mongo.createModel<Types.AreaDocument>('Area', {
|
|
5
|
+
type: { type: String, default: 'Zone' },
|
|
6
|
+
shortDescription: { type: String },
|
|
7
|
+
// landmarks: [{ type: mongo.Schema.Types.ObjectId, ref: 'AreaLandmark' }],
|
|
8
|
+
});
|
|
9
|
+
|
|
10
|
+
export const AreaLandmark = mongo.createModel<Types.AreaLandmarkDocument>('AreaLandmark', {
|
|
11
|
+
areaId: { type: mongo.Schema.Types.ObjectId, ref: 'Area' },
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
export const AreaType = mongo.createModel<Types.AreaTypeDocument>('AreaType', {});
|
|
15
|
+
export const AreaNameChoice = mongo.createModel<Types.AreaNameChoiceDocument>('AreaNameChoice', {});
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { z as zod } from 'zod';
|
|
2
|
+
import { initTRPC } from '@trpc/server';
|
|
3
|
+
import { customErrorFormatter, hasRole } from '../../util/rpc';
|
|
4
|
+
import type { RouterContext } from '../../types';
|
|
5
|
+
import { Area, AreaLandmark, AreaType } from './area.schema';
|
|
6
|
+
import { Query, getQueryInput, inferRouterOutputs, inferRouterInputs } from '../../schema';
|
|
7
|
+
|
|
8
|
+
export const z = zod;
|
|
9
|
+
export const t = initTRPC.context<RouterContext>().create();
|
|
10
|
+
export const router = t.router;
|
|
11
|
+
export const procedure = t.procedure;
|
|
12
|
+
|
|
13
|
+
export const createRouter = () =>
|
|
14
|
+
router({
|
|
15
|
+
getArea: procedure
|
|
16
|
+
.use(hasRole('guest', t))
|
|
17
|
+
.use(customErrorFormatter(t))
|
|
18
|
+
.input(getQueryInput(Area))
|
|
19
|
+
.query(({ input, ctx }) => (ctx.app.service.Area.getArea as any)(input, ctx)),
|
|
20
|
+
|
|
21
|
+
getAreas: procedure
|
|
22
|
+
.use(hasRole('guest', t))
|
|
23
|
+
.use(customErrorFormatter(t))
|
|
24
|
+
.input(getQueryInput(Area))
|
|
25
|
+
.query(({ input, ctx }) => (ctx.app.service.Area.getAreas as any)(input, ctx)),
|
|
26
|
+
|
|
27
|
+
saveArea: procedure
|
|
28
|
+
.use(hasRole('admin', t))
|
|
29
|
+
.use(customErrorFormatter(t))
|
|
30
|
+
.input(getQueryInput(Area))
|
|
31
|
+
.output(Area.pick({ id: true }))
|
|
32
|
+
.mutation(({ input, ctx }) => (ctx.app.service.Area.saveArea as any)(input, ctx)),
|
|
33
|
+
|
|
34
|
+
getAreaLandmark: procedure
|
|
35
|
+
.use(hasRole('guest', t))
|
|
36
|
+
.use(customErrorFormatter(t))
|
|
37
|
+
.input(z.object({ query: Query }))
|
|
38
|
+
.query(({ input, ctx }) => (ctx.app.service.Area.getAreaLandmark as any)(input, ctx)),
|
|
39
|
+
|
|
40
|
+
createAreaLandmark: procedure
|
|
41
|
+
.use(hasRole('admin', t))
|
|
42
|
+
.use(customErrorFormatter(t))
|
|
43
|
+
.input(z.object({ data: AreaLandmark.omit({ id: true }) }))
|
|
44
|
+
.mutation(({ input, ctx }) => (ctx.app.service.Area.createAreaLandmark as any)(input, ctx)),
|
|
45
|
+
|
|
46
|
+
updateAreaLandmark: procedure
|
|
47
|
+
.use(hasRole('admin', t))
|
|
48
|
+
.use(customErrorFormatter(t))
|
|
49
|
+
.input(z.object({ query: Query, data: AreaLandmark.partial() }))
|
|
50
|
+
.mutation(({ input, ctx }) => (ctx.app.service.Area.updateAreaLandmark as any)(input, ctx)),
|
|
51
|
+
|
|
52
|
+
getAreaType: procedure
|
|
53
|
+
.use(hasRole('guest', t))
|
|
54
|
+
.use(customErrorFormatter(t))
|
|
55
|
+
.input(z.object({ query: Query }))
|
|
56
|
+
.query(({ input, ctx }) => (ctx.app.service.Area.getAreaType as any)(input, ctx)),
|
|
57
|
+
|
|
58
|
+
createAreaType: procedure
|
|
59
|
+
.use(hasRole('admin', t))
|
|
60
|
+
.use(customErrorFormatter(t))
|
|
61
|
+
.input(z.object({ data: AreaType.omit({ id: true }) }))
|
|
62
|
+
.mutation(({ input, ctx }) => (ctx.app.service.Area.createAreaType as any)(input, ctx)),
|
|
63
|
+
|
|
64
|
+
updateAreaType: procedure
|
|
65
|
+
.use(hasRole('admin', t))
|
|
66
|
+
.use(customErrorFormatter(t))
|
|
67
|
+
.input(z.object({ query: Query, data: AreaType.partial() }))
|
|
68
|
+
.output(AreaType.partial())
|
|
69
|
+
.mutation(({ input, ctx }) => (ctx.app.service.Area.updateAreaType as any)(input, ctx)),
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
export type Router = ReturnType<typeof createRouter>;
|
|
73
|
+
export type RouterInput = inferRouterInputs<Router>;
|
|
74
|
+
export type RouterOutput = inferRouterOutputs<Router>;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
// arken/packages/node/modules/area/area.schema.ts
|
|
2
|
+
//
|
|
3
|
+
import { z, ObjectId, Entity } from '../../schema';
|
|
4
|
+
|
|
5
|
+
export const Area = Entity.merge(
|
|
6
|
+
z.object({
|
|
7
|
+
type: z.string().default('Zone'),
|
|
8
|
+
landmarks: z.array(ObjectId).optional(),
|
|
9
|
+
shortDescription: z.string(),
|
|
10
|
+
})
|
|
11
|
+
);
|
|
12
|
+
|
|
13
|
+
export const AreaLandmark = Entity.merge(
|
|
14
|
+
z.object({
|
|
15
|
+
areaId: ObjectId.optional(),
|
|
16
|
+
area: ObjectId.optional(),
|
|
17
|
+
})
|
|
18
|
+
);
|
|
19
|
+
|
|
20
|
+
export const AreaType = Entity.merge(z.object({}));
|
|
21
|
+
|
|
22
|
+
export const AreaNameChoice = Entity.merge(z.object({}));
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import * as schema from './area.schema';
|
|
3
|
+
import { Document, Model } from '../../util/mongo';
|
|
4
|
+
|
|
5
|
+
export type * from './area.router';
|
|
6
|
+
export type * from './area.service';
|
|
7
|
+
export type { RouterContext } from '../../types';
|
|
8
|
+
|
|
9
|
+
export type Area = z.infer<typeof schema.Area>;
|
|
10
|
+
export type AreaDocument = Area & Document;
|
|
11
|
+
|
|
12
|
+
export type AreaLandmark = z.infer<typeof schema.AreaLandmark>;
|
|
13
|
+
export type AreaLandmarkDocument = AreaLandmark & Document;
|
|
14
|
+
|
|
15
|
+
export type AreaType = z.infer<typeof schema.AreaType>;
|
|
16
|
+
export type AreaTypeDocument = AreaType & Document;
|
|
17
|
+
|
|
18
|
+
export type AreaNameChoice = z.infer<typeof schema.AreaNameChoice>;
|
|
19
|
+
export type AreaNameChoiceDocument = AreaNameChoice & Document;
|
|
20
|
+
|
|
21
|
+
export type Mappings = {
|
|
22
|
+
Area: Model<AreaDocument>;
|
|
23
|
+
AreaLandmark: Model<AreaLandmarkDocument>;
|
|
24
|
+
AreaType: Model<AreaTypeDocument>;
|
|
25
|
+
AreaNameChoice: Model<AreaNameChoiceDocument>;
|
|
26
|
+
};
|
package/area/index.ts
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import * as mongo from '../../util/mongo';
|
|
2
|
+
import type * as Types from './asset.types';
|
|
3
|
+
|
|
4
|
+
export const AssetStandard = mongo.createModel<Types.AssetStandardDocument>(
|
|
5
|
+
'AssetStandard',
|
|
6
|
+
{
|
|
7
|
+
version: { type: String, required: false },
|
|
8
|
+
parentId: { type: mongo.Schema.Types.ObjectId, ref: 'AssetStandard', required: false },
|
|
9
|
+
},
|
|
10
|
+
{
|
|
11
|
+
virtuals: [
|
|
12
|
+
{
|
|
13
|
+
name: 'children',
|
|
14
|
+
ref: 'AssetStandard',
|
|
15
|
+
localField: '_id',
|
|
16
|
+
foreignField: 'parent',
|
|
17
|
+
justOne: false,
|
|
18
|
+
},
|
|
19
|
+
],
|
|
20
|
+
}
|
|
21
|
+
);
|
|
22
|
+
|
|
23
|
+
export const Asset = mongo.createModel<Types.AssetDocument>(
|
|
24
|
+
'Asset',
|
|
25
|
+
{
|
|
26
|
+
uri: { type: String, required: true },
|
|
27
|
+
type: { type: String, maxlength: 100, required: true },
|
|
28
|
+
standards: [{ type: mongo.Schema.Types.ObjectId, ref: 'AssetStandard', required: true }],
|
|
29
|
+
licenseId: { type: mongo.Schema.Types.ObjectId, ref: 'AssetLicense' },
|
|
30
|
+
chainId: { type: mongo.Schema.Types.ObjectId, ref: 'Chain' },
|
|
31
|
+
ownerId: { type: mongo.Schema.Types.ObjectId, ref: 'Profile' }, // Added ownerId
|
|
32
|
+
// skin: { type: String },
|
|
33
|
+
// transmuteCount: { type: Number },
|
|
34
|
+
// score: { type: Number },
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
virtuals: [
|
|
38
|
+
{
|
|
39
|
+
name: 'items',
|
|
40
|
+
ref: 'Item',
|
|
41
|
+
localField: '_id',
|
|
42
|
+
foreignField: 'assetId',
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
name: 'offers',
|
|
46
|
+
ref: 'Node',
|
|
47
|
+
localField: '_id',
|
|
48
|
+
foreignField: 'fromOfferId',
|
|
49
|
+
justOne: false,
|
|
50
|
+
match: { relationKey: 'offers' },
|
|
51
|
+
},
|
|
52
|
+
],
|
|
53
|
+
}
|
|
54
|
+
);
|
|
55
|
+
|
|
56
|
+
export const AssetLicense = mongo.createModel<Types.AssetLicenseDocument>('AssetLicense', {
|
|
57
|
+
value: { type: String, required: true },
|
|
58
|
+
// assets: [{ type: mongo.Schema.Types.ObjectId, ref: 'Asset' }],
|
|
59
|
+
});
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
// module/asset.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 { Asset, AssetLicense } from './asset.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
|
+
getAsset: procedure
|
|
17
|
+
.use(hasRole('guest', t))
|
|
18
|
+
.use(customErrorFormatter(t))
|
|
19
|
+
.input(z.object({ assetId: z.string() }))
|
|
20
|
+
.query(({ input, ctx }) => (ctx.app.service.Asset.getAsset as any)(input, ctx)),
|
|
21
|
+
|
|
22
|
+
createAsset: procedure
|
|
23
|
+
.use(hasRole('admin', t))
|
|
24
|
+
.use(customErrorFormatter(t))
|
|
25
|
+
.input(Asset)
|
|
26
|
+
.mutation(({ input, ctx }) => (ctx.app.service.Asset.createAsset as any)(input, ctx)),
|
|
27
|
+
|
|
28
|
+
updateAsset: procedure
|
|
29
|
+
.use(hasRole('admin', t))
|
|
30
|
+
.use(customErrorFormatter(t))
|
|
31
|
+
.input(z.object({ assetId: z.string(), data: Asset.partial() }))
|
|
32
|
+
.mutation(({ input, ctx }) => (ctx.app.service.Asset.updateAsset as any)(input, ctx)),
|
|
33
|
+
|
|
34
|
+
getAssetLicense: procedure
|
|
35
|
+
.use(hasRole('guest', t))
|
|
36
|
+
.use(customErrorFormatter(t))
|
|
37
|
+
.input(z.object({ assetLicenseId: z.string() }))
|
|
38
|
+
.query(({ input, ctx }) => (ctx.app.service.Asset.getAssetLicense as any)(input, ctx)),
|
|
39
|
+
|
|
40
|
+
createAssetLicense: procedure
|
|
41
|
+
.use(hasRole('admin', t))
|
|
42
|
+
.use(customErrorFormatter(t))
|
|
43
|
+
.input(AssetLicense)
|
|
44
|
+
.mutation(({ input, ctx }) => (ctx.app.service.Asset.createAssetLicense as any)(input, ctx)),
|
|
45
|
+
|
|
46
|
+
updateAssetLicense: procedure
|
|
47
|
+
.use(hasRole('admin', t))
|
|
48
|
+
.use(customErrorFormatter(t))
|
|
49
|
+
.input(z.object({ assetLicenseId: z.string(), data: AssetLicense.partial() }))
|
|
50
|
+
.mutation(({ input, ctx }) => (ctx.app.service.Asset.updateAssetLicense as any)(input, ctx)),
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
export type Router = ReturnType<typeof createRouter>;
|
|
54
|
+
export type RouterInput = inferRouterInputs<Router>;
|
|
55
|
+
export type RouterOutput = inferRouterOutputs<Router>;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { z, ObjectId, Entity } from '../../schema';
|
|
2
|
+
|
|
3
|
+
export const AssetStandard = Entity.merge(
|
|
4
|
+
z.object({
|
|
5
|
+
version: z.string().optional(),
|
|
6
|
+
parentId: ObjectId.optional(),
|
|
7
|
+
})
|
|
8
|
+
);
|
|
9
|
+
|
|
10
|
+
export const Asset = Entity.merge(
|
|
11
|
+
z.object({
|
|
12
|
+
uri: z.string().min(1),
|
|
13
|
+
type: z.string().max(100).min(1),
|
|
14
|
+
standards: z.array(ObjectId),
|
|
15
|
+
licenseId: ObjectId.optional(),
|
|
16
|
+
license: ObjectId.optional(),
|
|
17
|
+
chainId: ObjectId.optional(),
|
|
18
|
+
items: z.array(ObjectId).optional(),
|
|
19
|
+
})
|
|
20
|
+
);
|
|
21
|
+
|
|
22
|
+
export const AssetLicense = Entity.merge(
|
|
23
|
+
z.object({
|
|
24
|
+
value: z.string().min(1),
|
|
25
|
+
assets: z.array(ObjectId).optional(),
|
|
26
|
+
})
|
|
27
|
+
);
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import * as schema from './asset.schema';
|
|
3
|
+
import { Document, Model } from '../../util/mongo';
|
|
4
|
+
|
|
5
|
+
export type * from './asset.router';
|
|
6
|
+
export type * from './asset.service';
|
|
7
|
+
export type { RouterContext } from '../../types';
|
|
8
|
+
|
|
9
|
+
export type Asset = z.infer<typeof schema.Asset>;
|
|
10
|
+
export type AssetDocument = Asset & Document;
|
|
11
|
+
|
|
12
|
+
export type AssetStandard = z.infer<typeof schema.AssetStandard>;
|
|
13
|
+
export type AssetStandardDocument = AssetStandard & Document;
|
|
14
|
+
|
|
15
|
+
export type AssetLicense = z.infer<typeof schema.AssetLicense>;
|
|
16
|
+
export type AssetLicenseDocument = AssetLicense & Document;
|
|
17
|
+
|
|
18
|
+
export type Mappings = {
|
|
19
|
+
Asset: Model<AssetDocument>;
|
|
20
|
+
AssetStandard: Model<AssetStandardDocument>;
|
|
21
|
+
AssetLicense: Model<AssetLicenseDocument>;
|
|
22
|
+
};
|
package/asset/index.ts
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import * as mongo from '../../util/mongo';
|
|
2
|
+
import type * as Types from './chain.types';
|
|
3
|
+
|
|
4
|
+
export const Chain = mongo.createModel<Types.ChainDocument>('Chain', {
|
|
5
|
+
content: { type: String, required: true },
|
|
6
|
+
type: { type: String, maxlength: 100, required: true },
|
|
7
|
+
});
|
|
8
|
+
|
|
9
|
+
export const ChainContract = mongo.createModel<Types.ChainContractDocument>('ChainContract', {
|
|
10
|
+
chainId: { type: mongo.Schema.Types.ObjectId, ref: 'Chain', required: true },
|
|
11
|
+
content: { type: String },
|
|
12
|
+
address: { type: String },
|
|
13
|
+
type: { type: String, maxlength: 100, required: true },
|
|
14
|
+
standards: [{ type: mongo.Schema.Types.ObjectId, ref: 'AssetStandard', required: true }],
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
export const ChainToken = mongo.createModel<Types.ChainTokenDocument>(
|
|
18
|
+
'ChainToken',
|
|
19
|
+
{
|
|
20
|
+
chainId: { type: mongo.Schema.Types.ObjectId, ref: 'Chain', required: true },
|
|
21
|
+
chainContractId: { type: mongo.Schema.Types.ObjectId, ref: 'ChainContract', required: true },
|
|
22
|
+
rank: { type: Number, min: 0, default: 0 },
|
|
23
|
+
description: { type: String, trim: true },
|
|
24
|
+
address: { type: String },
|
|
25
|
+
content: { type: String },
|
|
26
|
+
decimals: { type: Number, default: 0 },
|
|
27
|
+
price: { type: Number, min: 0, default: 0 },
|
|
28
|
+
hourChange: { type: Number, default: 0 },
|
|
29
|
+
dayChange: { type: Number, default: 0 },
|
|
30
|
+
weekChange: { type: Number, default: 0 },
|
|
31
|
+
marketCap: { type: Number, min: 0, default: 0 },
|
|
32
|
+
volume: { type: Number, min: 0, default: 0 },
|
|
33
|
+
symbol: { type: String, required: true, trim: true },
|
|
34
|
+
circulatingSupply: { type: Number, min: 0, default: 0 },
|
|
35
|
+
cmcLink: { type: String, trim: true },
|
|
36
|
+
movementDown: { type: Number, min: 0, default: 0 },
|
|
37
|
+
movementUp: { type: Number, min: 0, default: 0 },
|
|
38
|
+
enteredTop100: { type: Number, min: 0, default: 0 },
|
|
39
|
+
exitedTop100: { type: Number, min: 0, default: 0 },
|
|
40
|
+
largeMoveDown: { type: Number, min: 0, default: 0 },
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
indexes: [{ applicationId: 1, symbol: 1, unique: true }],
|
|
44
|
+
}
|
|
45
|
+
);
|
|
46
|
+
|
|
47
|
+
export const ChainTransaction = mongo.createModel<Types.ChainTransactionDocument>('ChainTransaction', {
|
|
48
|
+
value: { type: String, required: true },
|
|
49
|
+
chainId: { type: mongo.Schema.Types.ObjectId, ref: 'Chain', required: true },
|
|
50
|
+
});
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
// module/chain.router.ts
|
|
2
|
+
|
|
3
|
+
import { z as zod } from 'zod';
|
|
4
|
+
import { initTRPC, inferRouterInputs } from '@trpc/server';
|
|
5
|
+
import { customErrorFormatter, hasRole } from '../../util/rpc';
|
|
6
|
+
import type { RouterContext } from '../../types';
|
|
7
|
+
import { Chain, ChainContract, ChainToken, ChainTransaction } from './chain.schema';
|
|
8
|
+
import { Query, getQueryInput, getQueryOutput, inferRouterOutputs } 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
|
+
getChain: procedure
|
|
18
|
+
.use(hasRole('guest', t))
|
|
19
|
+
.use(customErrorFormatter(t))
|
|
20
|
+
.input(getQueryInput(Chain))
|
|
21
|
+
.output(Chain)
|
|
22
|
+
.query(({ input, ctx }) => (ctx.app.service.Chain.getChain as any)(input, ctx)),
|
|
23
|
+
|
|
24
|
+
createChain: procedure
|
|
25
|
+
.use(hasRole('admin', t))
|
|
26
|
+
.use(customErrorFormatter(t))
|
|
27
|
+
.input(getQueryInput(Chain))
|
|
28
|
+
.output(Chain.pick({ id: true }))
|
|
29
|
+
.mutation(({ input, ctx }) => (ctx.app.service.Chain.createChain as any)(input, ctx)),
|
|
30
|
+
|
|
31
|
+
updateChain: procedure
|
|
32
|
+
.use(hasRole('admin', t))
|
|
33
|
+
.use(customErrorFormatter(t))
|
|
34
|
+
.input(getQueryInput(Chain))
|
|
35
|
+
.output(Chain.pick({ id: true }))
|
|
36
|
+
.mutation(({ input, ctx }) => (ctx.app.service.Chain.updateChain as any)(input, ctx)),
|
|
37
|
+
|
|
38
|
+
getChainContract: procedure
|
|
39
|
+
.use(hasRole('guest', t))
|
|
40
|
+
.use(customErrorFormatter(t))
|
|
41
|
+
.input(getQueryInput(ChainContract))
|
|
42
|
+
.output(ChainContract)
|
|
43
|
+
.query(({ input, ctx }) => (ctx.app.service.Chain.getChainContract as any)(input, ctx)),
|
|
44
|
+
|
|
45
|
+
createChainContract: procedure
|
|
46
|
+
.use(hasRole('admin', t))
|
|
47
|
+
.use(customErrorFormatter(t))
|
|
48
|
+
.input(getQueryInput(ChainContract))
|
|
49
|
+
.output(ChainContract.pick({ id: true }))
|
|
50
|
+
.mutation(({ input, ctx }) => (ctx.app.service.Chain.createChainContract as any)(input, ctx)),
|
|
51
|
+
|
|
52
|
+
updateChainContract: procedure
|
|
53
|
+
.use(hasRole('admin', t))
|
|
54
|
+
.use(customErrorFormatter(t))
|
|
55
|
+
.input(getQueryInput(ChainContract))
|
|
56
|
+
.output(ChainContract.pick({ id: true }))
|
|
57
|
+
.mutation(({ input, ctx }) => (ctx.app.service.Chain.updateChainContract as any)(input, ctx)),
|
|
58
|
+
|
|
59
|
+
getChainToken: procedure
|
|
60
|
+
.use(hasRole('guest', t))
|
|
61
|
+
.use(customErrorFormatter(t))
|
|
62
|
+
.input(getQueryInput(ChainToken))
|
|
63
|
+
.output(ChainToken)
|
|
64
|
+
.query(({ input, ctx }) => (ctx.app.service.Chain.getChainToken as any)(input, ctx)),
|
|
65
|
+
|
|
66
|
+
createChainToken: procedure
|
|
67
|
+
.use(hasRole('admin', t))
|
|
68
|
+
.use(customErrorFormatter(t))
|
|
69
|
+
.input(getQueryInput(ChainToken))
|
|
70
|
+
.output(ChainToken.pick({ id: true }))
|
|
71
|
+
.mutation(({ input, ctx }) => (ctx.app.service.Chain.createChainToken as any)(input, ctx)),
|
|
72
|
+
|
|
73
|
+
updateChainToken: procedure
|
|
74
|
+
.use(hasRole('admin', t))
|
|
75
|
+
.use(customErrorFormatter(t))
|
|
76
|
+
.input(getQueryInput(ChainToken))
|
|
77
|
+
.output(ChainToken.pick({ id: true }))
|
|
78
|
+
.mutation(({ input, ctx }) => (ctx.app.service.Chain.updateChainToken as any)(input, ctx)),
|
|
79
|
+
|
|
80
|
+
getChainTransaction: procedure
|
|
81
|
+
.use(hasRole('guest', t))
|
|
82
|
+
.use(customErrorFormatter(t))
|
|
83
|
+
.input(getQueryInput(ChainTransaction))
|
|
84
|
+
.output(ChainTransaction)
|
|
85
|
+
.query(({ input, ctx }) => (ctx.app.service.Chain.getChainTransaction as any)(input, ctx)),
|
|
86
|
+
|
|
87
|
+
createChainTransaction: procedure
|
|
88
|
+
.use(hasRole('admin', t))
|
|
89
|
+
.use(customErrorFormatter(t))
|
|
90
|
+
.input(getQueryInput(ChainTransaction))
|
|
91
|
+
.output(ChainTransaction.pick({ id: true }))
|
|
92
|
+
.mutation(({ input, ctx }) => (ctx.app.service.Chain.createChainTransaction as any)(input, ctx)),
|
|
93
|
+
|
|
94
|
+
updateChainTransaction: procedure
|
|
95
|
+
.use(hasRole('admin', t))
|
|
96
|
+
.use(customErrorFormatter(t))
|
|
97
|
+
.input(getQueryInput(ChainTransaction))
|
|
98
|
+
.output(ChainTransaction.pick({ id: true }))
|
|
99
|
+
.mutation(({ input, ctx }) => (ctx.app.service.Chain.updateChainTransaction as any)(input, ctx)),
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
export type Router = ReturnType<typeof createRouter>;
|
|
103
|
+
export type RouterInput = inferRouterInputs<Router>;
|
|
104
|
+
export type RouterOutput = inferRouterOutputs<Router>;
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { z, ObjectId, Entity } from '../../schema';
|
|
2
|
+
|
|
3
|
+
export const Chain = Entity.merge(
|
|
4
|
+
z.object({
|
|
5
|
+
content: z.string().min(1),
|
|
6
|
+
type: z.string().max(100).min(1),
|
|
7
|
+
standard: z.string().max(100).min(1),
|
|
8
|
+
})
|
|
9
|
+
);
|
|
10
|
+
|
|
11
|
+
export const ChainContract = Entity.merge(
|
|
12
|
+
z.object({
|
|
13
|
+
chainId: ObjectId,
|
|
14
|
+
content: z.string().min(1).optional(),
|
|
15
|
+
address: z.string().max(100),
|
|
16
|
+
type: z.string().max(100).min(1),
|
|
17
|
+
standards: z.array(ObjectId),
|
|
18
|
+
})
|
|
19
|
+
);
|
|
20
|
+
|
|
21
|
+
export const ChainToken = Entity.merge(
|
|
22
|
+
z.object({
|
|
23
|
+
chainId: ObjectId,
|
|
24
|
+
chainContractId: ObjectId,
|
|
25
|
+
address: z.string().max(100), // TODO: validate address?
|
|
26
|
+
decimals: z.number().optional(),
|
|
27
|
+
rank: z.number().optional(),
|
|
28
|
+
description: z.string().optional(),
|
|
29
|
+
content: z.string().min(1).optional(),
|
|
30
|
+
price: z.number().optional(),
|
|
31
|
+
hourChange: z.number().optional(),
|
|
32
|
+
dayChange: z.number().optional(),
|
|
33
|
+
weekChange: z.number().optional(),
|
|
34
|
+
marketCap: z.number().optional(),
|
|
35
|
+
volume: z.number().optional(),
|
|
36
|
+
symbol: z.string().min(1),
|
|
37
|
+
circulatingSupply: z.number().optional(),
|
|
38
|
+
cmcLink: z.string().optional(),
|
|
39
|
+
movementDown: z.number().optional(),
|
|
40
|
+
movementUp: z.number().optional(),
|
|
41
|
+
enteredTop100: z.number().optional(),
|
|
42
|
+
exitedTop100: z.number().optional(),
|
|
43
|
+
largeMoveDown: z.number().optional(),
|
|
44
|
+
})
|
|
45
|
+
);
|
|
46
|
+
|
|
47
|
+
export const ChainTransaction = Entity.merge(
|
|
48
|
+
z.object({
|
|
49
|
+
value: z.string().min(1),
|
|
50
|
+
chainId: ObjectId,
|
|
51
|
+
})
|
|
52
|
+
);
|
|
@@ -0,0 +1,24 @@
|
|
|
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
|
+
};
|