@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.
Files changed (112) hide show
  1. package/.rush/temp/shrinkwrap-deps.json +537 -56
  2. package/area/area.models.ts +15 -0
  3. package/area/area.router.ts +74 -0
  4. package/area/area.schema.ts +22 -0
  5. package/area/area.types.ts +26 -0
  6. package/area/index.ts +5 -0
  7. package/asset/asset.models.ts +59 -0
  8. package/asset/asset.router.ts +55 -0
  9. package/asset/asset.schema.ts +27 -0
  10. package/asset/asset.types.ts +22 -0
  11. package/asset/index.ts +5 -0
  12. package/chain/chain.models.ts +50 -0
  13. package/chain/chain.router.ts +104 -0
  14. package/chain/chain.schema.ts +52 -0
  15. package/chain/chain.types.ts +24 -0
  16. package/chain/index.ts +5 -0
  17. package/character/character.models.ts +174 -0
  18. package/character/character.router.ts +314 -0
  19. package/character/character.schema.ts +147 -0
  20. package/character/character.types.ts +64 -0
  21. package/character/index.ts +5 -0
  22. package/chat/chat.models.ts +43 -0
  23. package/chat/chat.router.ts +67 -0
  24. package/chat/chat.schema.ts +36 -0
  25. package/chat/chat.types.ts +20 -0
  26. package/chat/index.ts +5 -0
  27. package/collection/collection.models.ts +76 -0
  28. package/collection/collection.router.ts +91 -0
  29. package/collection/collection.schema.ts +90 -0
  30. package/collection/collection.types.ts +36 -0
  31. package/collection/index.ts +5 -0
  32. package/core/core.models.ts +1380 -0
  33. package/core/core.router.ts +1781 -0
  34. package/core/core.schema.ts +847 -0
  35. package/core/core.types.ts +340 -0
  36. package/core/index.ts +5 -0
  37. package/evolution/evolution.models.ts +1 -1
  38. package/evolution/evolution.router.ts +8 -8
  39. package/evolution/evolution.schema.ts +1 -1
  40. package/evolution/evolution.types.ts +1 -1
  41. package/game/game.models.ts +53 -0
  42. package/game/game.router.ts +110 -0
  43. package/game/game.schema.ts +23 -0
  44. package/game/game.types.ts +28 -0
  45. package/game/index.ts +5 -0
  46. package/index.ts +39 -2
  47. package/infinite/infinite.models.ts +1 -1
  48. package/infinite/infinite.router.ts +8 -8
  49. package/infinite/infinite.schema.ts +1 -1
  50. package/infinite/infinite.types.ts +1 -1
  51. package/interface/index.ts +5 -0
  52. package/interface/interface.canonicalize.ts +279 -0
  53. package/interface/interface.models.ts +40 -0
  54. package/interface/interface.router.ts +175 -0
  55. package/interface/interface.schema.ts +59 -0
  56. package/interface/interface.types.ts +25 -0
  57. package/isles/isles.models.ts +1 -1
  58. package/isles/isles.router.ts +8 -8
  59. package/isles/isles.schema.ts +1 -1
  60. package/isles/isles.types.ts +1 -1
  61. package/item/index.ts +5 -0
  62. package/item/item.models.ts +124 -0
  63. package/item/item.router.ts +103 -0
  64. package/item/item.schema.ts +120 -0
  65. package/item/item.types.ts +74 -0
  66. package/job/index.ts +5 -0
  67. package/job/job.models.ts +14 -0
  68. package/job/job.router.ts +44 -0
  69. package/job/job.schema.ts +9 -0
  70. package/job/job.types.ts +23 -0
  71. package/market/index.ts +5 -0
  72. package/market/market.models.ts +113 -0
  73. package/market/market.router.ts +73 -0
  74. package/market/market.schema.ts +140 -0
  75. package/market/market.types.ts +56 -0
  76. package/oasis/oasis.models.ts +1 -1
  77. package/oasis/oasis.router.ts +2 -2
  78. package/oasis/oasis.schema.ts +1 -1
  79. package/oasis/oasis.types.ts +1 -1
  80. package/package.json +10 -3
  81. package/product/index.ts +5 -0
  82. package/product/product.models.ts +166 -0
  83. package/product/product.router.ts +93 -0
  84. package/product/product.schema.ts +149 -0
  85. package/product/product.types.ts +33 -0
  86. package/profile/index.ts +5 -0
  87. package/profile/profile.models.ts +214 -0
  88. package/profile/profile.router.ts +72 -0
  89. package/profile/profile.schema.ts +156 -0
  90. package/profile/profile.types.ts +22 -0
  91. package/raffle/index.ts +5 -0
  92. package/raffle/raffle.models.ts +44 -0
  93. package/raffle/raffle.router.ts +90 -0
  94. package/raffle/raffle.schema.ts +32 -0
  95. package/raffle/raffle.types.ts +30 -0
  96. package/router.ts +23 -29
  97. package/schema.ts +321 -0
  98. package/skill/index.ts +5 -0
  99. package/skill/skill.models.ts +16 -0
  100. package/skill/skill.router.ts +201 -0
  101. package/skill/skill.schema.ts +40 -0
  102. package/skill/skill.types.ts +33 -0
  103. package/trek/trek.models.ts +1 -1
  104. package/trek/trek.router.ts +1 -1
  105. package/trek/trek.schema.ts +1 -1
  106. package/trek/trek.types.ts +1 -1
  107. package/types.ts +172 -5
  108. package/video/index.ts +5 -0
  109. package/video/video.models.ts +25 -0
  110. package/video/video.router.ts +143 -0
  111. package/video/video.schema.ts +46 -0
  112. package/video/video.types.ts +33 -0
@@ -1 +1 @@
1
- import { z, ObjectId, Entity } from '@arken/schema';
1
+ import { z, ObjectId, Entity } from '@arken/node/schema';
@@ -1,5 +1,5 @@
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';
package/item/index.ts ADDED
@@ -0,0 +1,5 @@
1
+ export * as Types from './item.types';
2
+ export * as Models from './item.models';
3
+ export * as Schemas from './item.schema';
4
+ export * from './item.router';
5
+ export * from './item.service';
@@ -0,0 +1,124 @@
1
+ import * as mongo from '../../util/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 '../../util/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,120 @@
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.number().min(0).default(1),
64
+ typeIds: z.array(ObjectId).optional(),
65
+ rarityIds: z.array(ObjectId).optional(),
66
+ })
67
+ );
68
+
69
+ export const ItemRecipe = Entity.merge(
70
+ z.object({
71
+ // Define fields for ItemRecipe here if needed
72
+ })
73
+ );
74
+
75
+ export const ItemSkin = Entity.merge(
76
+ z.object({
77
+ // Define fields for ItemSkin here if needed
78
+ })
79
+ );
80
+
81
+ export const ItemTransmute = Entity.merge(
82
+ z.object({
83
+ token: z.string().max(500).min(1),
84
+ assetId: ObjectId,
85
+ itemId: ObjectId,
86
+ chainId: ObjectId.optional(),
87
+ })
88
+ );
89
+
90
+ export const Item = Entity.merge(
91
+ z.object({
92
+ characterId: ObjectId.optional(),
93
+ assetId: ObjectId.optional(),
94
+ chainId: ObjectId.optional(),
95
+ materialId: ItemMaterial.optional(),
96
+ skinId: ItemSkin.optional(),
97
+ recipeId: ItemRecipe.optional(),
98
+ typeId: ItemType.optional(),
99
+ subTypeId: ItemSubType.optional(),
100
+ specificTypeId: ItemSpecificType.optional(),
101
+ rankId: ItemRank.optional(),
102
+ rankValue: z.number(),
103
+ rarityId: ItemRarity.optional(),
104
+ slotIds: z.array(ItemSlot.optional()),
105
+ setId: ItemSet.optional(),
106
+ attributes: z.array(ItemAttribute).optional(),
107
+ token: z.string().max(500).min(1).optional(),
108
+ quantity: z.number().int().nonnegative().default(1),
109
+ x: z.number().int().nonnegative().optional(),
110
+ y: z.number().int().nonnegative().optional(),
111
+ distribution: z
112
+ .enum(['Unknown', 'Found', 'Fundraiser', 'Claimed', 'Crafted', 'Airdrop', 'Reward', 'Farmed', 'Migration'])
113
+ .default('Unknown'),
114
+ // properties: z.record(z.any()).optional(),
115
+ // type: z.string().default('bag'), // stash, bag, equipment, etc.
116
+ items: z.array(z.lazy(() => Item)).default([]),
117
+ capacity: z.number().int().nonnegative().default(60),
118
+ points: z.number().int().nonnegative().default(0),
119
+ })
120
+ );
@@ -0,0 +1,74 @@
1
+ // module/item.types.ts
2
+
3
+ import { z } from 'zod';
4
+ import * as schema from './item.schema';
5
+ import { Document, Model } from '../../util/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 * from './item.service';
12
+ export type { RouterContext };
13
+
14
+ export type Item = z.infer<typeof schema.Item>;
15
+ export type ItemDocument = Item & Document;
16
+
17
+ export type ItemAttribute = z.infer<typeof schema.ItemAttribute>;
18
+ export type ItemAttributeDocument = ItemAttribute & Document;
19
+
20
+ export type ItemMaterial = z.infer<typeof schema.ItemMaterial>;
21
+ export type ItemMaterialDocument = ItemMaterial & Document;
22
+
23
+ export type ItemSet = z.infer<typeof schema.ItemSet>;
24
+ export type ItemSetDocument = ItemSet & Document;
25
+
26
+ export type ItemSlot = z.infer<typeof schema.ItemSlot>;
27
+ export type ItemSlotDocument = ItemSlot & Document;
28
+
29
+ export type ItemRarity = z.infer<typeof schema.ItemRarity>;
30
+ export type ItemRarityDocument = ItemRarity & Document;
31
+
32
+ export type ItemRank = z.infer<typeof schema.ItemRank>;
33
+ export type ItemRankDocument = ItemRank & Document;
34
+
35
+ export type ItemType = z.infer<typeof schema.ItemType>;
36
+ export type ItemTypeDocument = ItemType & Document;
37
+
38
+ export type ItemSubType = z.infer<typeof schema.ItemSubType>;
39
+ export type ItemSubTypeDocument = ItemSubType & Document;
40
+
41
+ export type ItemSpecificType = z.infer<typeof schema.ItemSpecificType>;
42
+ export type ItemSpecificTypeDocument = ItemSpecificType & Document;
43
+
44
+ export type ItemAffix = z.infer<typeof schema.ItemAffix>;
45
+ export type ItemAffixDocument = ItemAffix & Document;
46
+
47
+ export type ItemRecipe = z.infer<typeof schema.ItemRecipe>;
48
+ export type ItemRecipeDocument = ItemRecipe & Document;
49
+
50
+ export type ItemSkin = z.infer<typeof schema.ItemSkin>;
51
+ export type ItemSkinDocument = ItemSkin & Document;
52
+
53
+ export type ItemTransmute = z.infer<typeof schema.ItemTransmute>;
54
+ export type ItemTransmuteDocument = ItemTransmute & Document;
55
+
56
+ export type Mappings = {
57
+ Item: Model<ItemDocument>;
58
+ ItemAttribute: Model<ItemAttributeDocument>;
59
+ ItemMaterial: Model<ItemMaterialDocument>;
60
+ ItemSet: Model<ItemSetDocument>;
61
+ ItemSlot: Model<ItemSlotDocument>;
62
+ ItemRarity: Model<ItemRarityDocument>;
63
+ ItemRank: Model<ItemRankDocument>;
64
+ ItemType: Model<ItemTypeDocument>;
65
+ ItemSubType: Model<ItemSubTypeDocument>;
66
+ ItemSpecificType: Model<ItemSpecificTypeDocument>;
67
+ ItemAffix: Model<ItemAffixDocument>;
68
+ ItemRecipe: Model<ItemRecipeDocument>;
69
+ ItemSkin: Model<ItemSkinDocument>;
70
+ ItemTransmute: Model<ItemTransmuteDocument>;
71
+ };
72
+
73
+ export type RouterInput = inferRouterInputs<Router>;
74
+ export type RouterOutput = inferRouterOutputs<Router>;
package/job/index.ts ADDED
@@ -0,0 +1,5 @@
1
+ export * as Types from './job.types';
2
+ export * as Models from './job.models';
3
+ export * as Schemas from './job.schema';
4
+ export * from './job.router';
5
+ export * from './job.service';
@@ -0,0 +1,14 @@
1
+ import * as mongo from '../../util/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 '../../util/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>;
@@ -0,0 +1,9 @@
1
+ import { z, ObjectId, Entity } from '../../schema';
2
+
3
+ export const Job = Entity.merge(
4
+ z.object({
5
+ mod: z.string(),
6
+ startDate: z.date().optional(),
7
+ expireDate: z.date().optional(),
8
+ })
9
+ );
@@ -0,0 +1,23 @@
1
+ // module/job.types.ts
2
+
3
+ import { z } from 'zod';
4
+ import * as schema from './job.schema';
5
+ import { Document, Model } from '../../util/mongo';
6
+ import type { RouterContext } from '../../types';
7
+ import type { inferRouterInputs, inferRouterOutputs } from '@trpc/server';
8
+ import type { Router } from './job.router';
9
+
10
+ export type * from './job.router';
11
+ export type * from './job.service';
12
+ export type { RouterContext };
13
+
14
+ export type Job = z.infer<typeof schema.Job>;
15
+
16
+ export type JobDocument = Job & Document;
17
+
18
+ export type Mappings = {
19
+ Job: Model<JobDocument>;
20
+ };
21
+
22
+ export type RouterInput = inferRouterInputs<Router>;
23
+ export type RouterOutput = inferRouterOutputs<Router>;
@@ -0,0 +1,5 @@
1
+ export * as Types from './market.types';
2
+ export * as Models from './market.models';
3
+ export * as Schemas from './market.schema';
4
+ export * from './market.router';
5
+ export * from './market.service';
@@ -0,0 +1,113 @@
1
+ import * as mongo from '../../util/mongo';
2
+ import type * as Types from './market.types';
3
+
4
+ export const Market = mongo.createModel<Types.MarketDocument>('Market', {
5
+ value: { type: String, required: true },
6
+ });
7
+
8
+ export const MarketPair = mongo.createModel<Types.MarketPairDocument>('MarketPair', {
9
+ value: { type: String, required: true },
10
+ });
11
+
12
+ export const MarketExchange = mongo.createModel<Types.MarketExchangeDocument>('MarketExchange', {
13
+ value: { type: String },
14
+ });
15
+
16
+ export const MarketAnalysis = mongo.createModel<Types.MarketAnalysisDocument>('MarketAnalysis', {
17
+ action: { type: String, required: true },
18
+ asset: { type: String, required: true },
19
+ signalType: { type: String, required: true },
20
+ confidence: { type: Number, required: true },
21
+ riskLevel: { type: String, required: true },
22
+ timeFrame: { type: String, required: true },
23
+ source: { type: String, required: true },
24
+ summary: { type: String, required: true },
25
+ labels: {
26
+ sector: { type: String },
27
+ topic: { type: String },
28
+ sentiment: { type: String },
29
+ },
30
+ });
31
+
32
+ export const MarketInvestor = mongo.createModel<Types.MarketInvestorDocument>('MarketInvestor', {
33
+ portfolioIds: [{ type: mongo.Schema.Types.ObjectId, required: true }],
34
+ totalPnl: { type: Number },
35
+ });
36
+
37
+ export const MarketInvestmentPortfolio = mongo.createModel<Types.MarketInvestmentPortfolioDocument>(
38
+ 'MarketInvestmentPortfolio',
39
+ {
40
+ categoryGoals: [
41
+ {
42
+ category: { type: String, required: true },
43
+ goalPercentage: { type: Number, required: true },
44
+ currentPnL: { type: Number },
45
+ historicalPnL: { type: Number },
46
+ },
47
+ ],
48
+ investmentIds: [{ type: mongo.Schema.Types.ObjectId, required: true }],
49
+ totalPnl: { type: Number },
50
+ }
51
+ );
52
+
53
+ export const MarketInvestment = mongo.createModel<Types.MarketInvestmentDocument>('MarketInvestment', {
54
+ type: { type: String, required: true },
55
+ amount: { type: Number, required: true },
56
+ category: { type: String, required: true },
57
+ purchasePrice: { type: Number, required: true },
58
+ currentValue: { type: Number, required: true },
59
+ pnl: { type: Number, required: true },
60
+ transactions: [
61
+ {
62
+ date: { type: Date, required: true },
63
+ type: { type: String, required: true },
64
+ price: { type: Number, required: true },
65
+ quantity: { type: Number, required: true },
66
+ },
67
+ ],
68
+ stockId: { type: mongo.Schema.Types.ObjectId },
69
+ chainTokenId: { type: mongo.Schema.Types.ObjectId },
70
+ });
71
+
72
+ export const MarketStock = mongo.createModel<Types.MarketStockDocument>('MarketStock', {
73
+ ticker: { type: String, required: true },
74
+ companyId: { type: mongo.Schema.Types.ObjectId, required: true, ref: 'StockCompany' },
75
+ currentPrice: { type: Number, required: true },
76
+ marketCap: { type: Number },
77
+ volume: { type: Number },
78
+ currency: { type: String, required: true },
79
+ aum: { type: Number },
80
+ quoteType: { type: String },
81
+ dailyChange: { type: Number },
82
+ dailyChangePercent: { type: Number },
83
+ });
84
+
85
+ export const MarketToken = mongo.createModel<Types.MarketTokenDocument>('MarketToken', {
86
+ symbol: { type: String, required: true },
87
+ currentPrice: { type: Number, required: true },
88
+ });
89
+
90
+ export const MarketCompany = mongo.createModel<Types.MarketCompanyDocument>('MarketCompany', {
91
+ ticker: { type: String, required: true },
92
+ country: { type: String, required: true },
93
+ industry: { type: String, required: true },
94
+ sector: { type: String, required: true },
95
+ type: { type: String, required: true },
96
+ issuedETFs: [{ type: mongo.Schema.Types.ObjectId, ref: 'MarketETF' }],
97
+ });
98
+
99
+ export const MarketETF = mongo.createModel<Types.MarketETFDocument>('ETF', {
100
+ ticker: { type: String, required: true },
101
+ issuerId: { type: mongo.Schema.Types.ObjectId, required: true },
102
+ leverage: { type: Number, required: false },
103
+ });
104
+
105
+ export const MarketStockSentiment = mongo.createModel<Types.MarketStockSentimentDocument>('MarketStockSentiment', {
106
+ ticker: { type: String, required: true },
107
+ companyId: { type: mongo.Schema.Types.ObjectId, required: true, ref: 'StockCompany' },
108
+ sentiment: {
109
+ label: { type: String, required: true },
110
+ score: { type: Number, required: true },
111
+ },
112
+ confidence: { type: Number, required: true },
113
+ });