@arken/node 1.5.0 → 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.
Files changed (160) hide show
  1. package/build/modules/character/character.service.js.map +1 -1
  2. package/build/modules/chat/chat.service.js.map +1 -1
  3. package/build/modules/core/core.models.js.map +1 -1
  4. package/build/modules/core/core.service.js.map +1 -1
  5. package/build/modules/profile/profile.service.js.map +1 -1
  6. package/build/package.json +2 -2
  7. package/build/tsconfig.tsbuildinfo +1 -1
  8. package/build/types.d.ts +1 -0
  9. package/build/types.js +1 -0
  10. package/build/types.js.map +1 -1
  11. package/build/util/mongo.js.map +1 -1
  12. package/db.ts +76 -1
  13. package/index.ts +351 -18
  14. package/{util/mongo.ts → mongo.ts} +2 -0
  15. package/package.json +3 -3
  16. package/tsconfig.json +33 -2
  17. package/types.ts +2 -0
  18. package/util.ts +1 -0
  19. package/modules/area/area.models.ts +0 -15
  20. package/modules/area/area.router.ts +0 -74
  21. package/modules/area/area.schema.ts +0 -22
  22. package/modules/area/area.service.ts +0 -124
  23. package/modules/area/area.types.ts +0 -26
  24. package/modules/area/index.ts +0 -5
  25. package/modules/asset/asset.models.ts +0 -59
  26. package/modules/asset/asset.router.ts +0 -55
  27. package/modules/asset/asset.schema.ts +0 -27
  28. package/modules/asset/asset.service.ts +0 -85
  29. package/modules/asset/asset.types.ts +0 -22
  30. package/modules/asset/index.ts +0 -5
  31. package/modules/chain/chain.models.ts +0 -50
  32. package/modules/chain/chain.router.ts +0 -104
  33. package/modules/chain/chain.schema.ts +0 -52
  34. package/modules/chain/chain.service.ts +0 -167
  35. package/modules/chain/chain.types.ts +0 -24
  36. package/modules/chain/index.ts +0 -5
  37. package/modules/character/character.models.ts +0 -174
  38. package/modules/character/character.router.ts +0 -314
  39. package/modules/character/character.schema.ts +0 -147
  40. package/modules/character/character.service.ts +0 -875
  41. package/modules/character/character.types.ts +0 -64
  42. package/modules/character/index.ts +0 -5
  43. package/modules/chat/chat.models.ts +0 -43
  44. package/modules/chat/chat.router.ts +0 -67
  45. package/modules/chat/chat.schema.ts +0 -36
  46. package/modules/chat/chat.service.ts +0 -120
  47. package/modules/chat/chat.types.ts +0 -20
  48. package/modules/chat/index.ts +0 -5
  49. package/modules/collection/collection.models.ts +0 -76
  50. package/modules/collection/collection.router.ts +0 -91
  51. package/modules/collection/collection.schema.ts +0 -90
  52. package/modules/collection/collection.service.ts +0 -192
  53. package/modules/collection/collection.types.ts +0 -36
  54. package/modules/collection/index.ts +0 -5
  55. package/modules/core/core.models.ts +0 -1379
  56. package/modules/core/core.router.ts +0 -1781
  57. package/modules/core/core.schema.ts +0 -847
  58. package/modules/core/core.service.ts +0 -2822
  59. package/modules/core/core.types.ts +0 -340
  60. package/modules/core/index.ts +0 -5
  61. package/modules/core/mail/applyPatchesOrMail.ts +0 -568
  62. package/modules/core/mail/mailClaimablePatchesBatch.ts +0 -381
  63. package/modules/game/game.models.ts +0 -53
  64. package/modules/game/game.router.ts +0 -110
  65. package/modules/game/game.schema.ts +0 -23
  66. package/modules/game/game.service.ts +0 -143
  67. package/modules/game/game.types.ts +0 -28
  68. package/modules/game/index.ts +0 -5
  69. package/modules/interface/index.ts +0 -5
  70. package/modules/interface/interface.canonicalize.ts +0 -279
  71. package/modules/interface/interface.models.ts +0 -40
  72. package/modules/interface/interface.router.ts +0 -175
  73. package/modules/interface/interface.schema.ts +0 -59
  74. package/modules/interface/interface.service.ts +0 -356
  75. package/modules/interface/interface.types.ts +0 -25
  76. package/modules/item/index.ts +0 -5
  77. package/modules/item/item.models.ts +0 -124
  78. package/modules/item/item.router.ts +0 -103
  79. package/modules/item/item.schema.ts +0 -120
  80. package/modules/item/item.service.ts +0 -167
  81. package/modules/item/item.types.ts +0 -74
  82. package/modules/job/index.ts +0 -5
  83. package/modules/job/job.models.ts +0 -14
  84. package/modules/job/job.router.ts +0 -44
  85. package/modules/job/job.schema.ts +0 -9
  86. package/modules/job/job.service.ts +0 -243
  87. package/modules/job/job.types.ts +0 -23
  88. package/modules/market/index.ts +0 -5
  89. package/modules/market/market.models.ts +0 -113
  90. package/modules/market/market.router.ts +0 -73
  91. package/modules/market/market.schema.ts +0 -140
  92. package/modules/market/market.service.ts +0 -122
  93. package/modules/market/market.types.ts +0 -56
  94. package/modules/product/index.ts +0 -5
  95. package/modules/product/product.models.ts +0 -166
  96. package/modules/product/product.router.ts +0 -93
  97. package/modules/product/product.schema.ts +0 -149
  98. package/modules/product/product.service.ts +0 -160
  99. package/modules/product/product.types.ts +0 -33
  100. package/modules/profile/index.ts +0 -5
  101. package/modules/profile/profile.models.ts +0 -214
  102. package/modules/profile/profile.router.ts +0 -72
  103. package/modules/profile/profile.schema.ts +0 -156
  104. package/modules/profile/profile.service.ts +0 -147
  105. package/modules/profile/profile.types.ts +0 -22
  106. package/modules/raffle/index.ts +0 -5
  107. package/modules/raffle/raffle.models.ts +0 -44
  108. package/modules/raffle/raffle.router.ts +0 -90
  109. package/modules/raffle/raffle.schema.ts +0 -32
  110. package/modules/raffle/raffle.service.ts +0 -167
  111. package/modules/raffle/raffle.types.ts +0 -30
  112. package/modules/skill/index.ts +0 -5
  113. package/modules/skill/skill.models.ts +0 -16
  114. package/modules/skill/skill.router.ts +0 -201
  115. package/modules/skill/skill.schema.ts +0 -40
  116. package/modules/skill/skill.service.ts +0 -390
  117. package/modules/skill/skill.types.ts +0 -33
  118. package/modules/video/index.ts +0 -5
  119. package/modules/video/video.models.ts +0 -25
  120. package/modules/video/video.router.ts +0 -143
  121. package/modules/video/video.schema.ts +0 -46
  122. package/modules/video/video.service.ts +0 -274
  123. package/modules/video/video.types.ts +0 -33
  124. package/util/db/index.ts +0 -7
  125. package/util/db/isPostgresError.ts +0 -9
  126. package/util/db/isUniqueConstraintViolation.ts +0 -3
  127. package/util/db.ts +0 -62
  128. package/util/index.ts +0 -351
  129. /package/{util/api.ts → api.ts} +0 -0
  130. /package/{util/array.ts → array.ts} +0 -0
  131. /package/{util/browser.ts → browser.ts} +0 -0
  132. /package/{util/codebase.ts → codebase.ts} +0 -0
  133. /package/{util/config.ts → config.ts} +0 -0
  134. /package/{util/decoder.test.ts → decoder.test.ts} +0 -0
  135. /package/{util/decoder.ts → decoder.ts} +0 -0
  136. /package/{util/format.ts → format.ts} +0 -0
  137. /package/{util/guid.ts → guid.ts} +0 -0
  138. /package/{util/json.ts → json.ts} +0 -0
  139. /package/{util/log.ts → log.ts} +0 -0
  140. /package/{util/math.ts → math.ts} +0 -0
  141. /package/{util/merkle.ts → merkle.ts} +0 -0
  142. /package/{util/number.ts → number.ts} +0 -0
  143. /package/{util/object.ts → object.ts} +0 -0
  144. /package/{util/otp.ts → otp.ts} +0 -0
  145. /package/{util/physics.ts → physics.ts} +0 -0
  146. /package/{util/process.ts → process.ts} +0 -0
  147. /package/{util/rpc.ts → rpc.ts} +0 -0
  148. /package/{util/seer.ts → seer.ts} +0 -0
  149. /package/{util/string.ts → string.ts} +0 -0
  150. /package/{util/text.ts → text.ts} +0 -0
  151. /package/{util/time → time}/date.ts +0 -0
  152. /package/{util/time → time}/fancyTimeFormat.ts +0 -0
  153. /package/{util/time → time}/index.ts +0 -0
  154. /package/{util/time → time}/now.ts +0 -0
  155. /package/{util/types → types}/mongo.d.ts +0 -0
  156. /package/{util/web3 → web3}/httpProvider.ts +0 -0
  157. /package/{util/web3.ts → web3.ts} +0 -0
  158. /package/{util/websocket.ts → websocket.ts} +0 -0
  159. /package/{util/zk.ts → zk.ts} +0 -0
  160. /package/{util/zod.ts → zod.ts} +0 -0
@@ -1,847 +0,0 @@
1
- // node/modules/core/core.schema.ts
2
-
3
- import { z, ObjectId, Entity } from '../../schema';
4
- import { Profile } from '../profile/profile.schema';
5
- import { ProfileDocument } from '../profile/profile.types';
6
-
7
- export const MerkleTree = Entity.merge(
8
- z.object({
9
- name: z.string().min(1).max(200).trim().default('global'),
10
- root: z.string(),
11
- depth: z.number().default(16), // log2(#leaves)
12
- })
13
- );
14
-
15
- export const MerkleNode = Entity.merge(
16
- z.object({
17
- treeId: ObjectId,
18
- level: z.number(), // 0 = leaves, up to max depth
19
- index: z.number(), // position within that level
20
- hash: z.string(), // Poseidon hash
21
- })
22
- );
23
-
24
- // Account Schema
25
- export const Account = Entity.merge(
26
- z.object({
27
- username: z.string().min(1),
28
- email: z.string().optional(),
29
- address: z.string().optional(),
30
- addressIndex: z.number().optional(),
31
- telegramUserId: z.number().optional(),
32
- activeProfileId: ObjectId.optional(),
33
- sessionUserId: z.string().optional(),
34
- })
35
- );
36
-
37
- // Achievement Schema
38
- export const Achievement = Entity.merge(z.object({}));
39
-
40
- // Act Schema
41
- export const Act = Entity.merge(z.object({}));
42
-
43
- // Agent Schema
44
- export const Agent = Entity.merge(z.object({}));
45
-
46
- // Application Schema
47
- export const Application = Entity.merge(
48
- z.object({
49
- ownerId: ObjectId.optional(),
50
- metaverseId: ObjectId.optional(),
51
- name: z.string().min(1),
52
- description: z.string().optional(),
53
- })
54
- );
55
-
56
- // Badge Schema
57
- export const Badge = Entity.merge(z.object({}));
58
-
59
- // BattlePass Schema
60
- export const BattlePass = Entity.merge(z.object({}));
61
-
62
- // Biome Schema
63
- export const Biome = Entity.merge(z.object({}));
64
-
65
- // BiomeFeature Schema
66
- export const BiomeFeature = Entity.merge(z.object({}));
67
-
68
- // Bounty Schema
69
- export const Bounty = Entity.merge(z.object({}));
70
-
71
- // Counter Schema
72
- export const Counter = Entity.merge(z.object({ seq: z.number().default(0) }));
73
-
74
- // Collection Schema
75
- export const Collection = Entity.merge(z.object({}));
76
-
77
- // Comment Schema
78
- export const Comment = Entity.merge(
79
- z.object({
80
- body: z.string().min(1),
81
- entity: ObjectId,
82
- entityModel: z.string(), // Changed from enum to string
83
- text: z.string(),
84
- ratingId: ObjectId.optional(),
85
- })
86
- );
87
-
88
- // Community Schema
89
- export const Community = Entity.merge(
90
- z.object({
91
- ideas: z.array(ObjectId).optional(),
92
- products: z.array(ObjectId).optional(),
93
- projects: z.array(ObjectId).optional(),
94
- })
95
- );
96
-
97
- // Company Schema
98
- export const Company = Entity.merge(
99
- z.object({
100
- content: z.string().optional(),
101
- people: z.array(ObjectId).optional(),
102
- })
103
- );
104
-
105
- // Conversation Schema
106
- export const Conversation = Entity.merge(
107
- z.object({
108
- // back-compat
109
- profileId: ObjectId.optional(),
110
- messages: z.array(ObjectId).optional(),
111
-
112
- kind: z.enum(['mail', 'dm', 'group', 'support', 'system']).default('mail'),
113
-
114
- participants: z
115
- .array(
116
- z.object({
117
- profileId: ObjectId,
118
- role: z.enum(['user', 'system', 'gm', 'npc']).default('user'),
119
- lastReadAt: z.coerce.date().default(new Date(0)),
120
- unreadCount: z.number().int().min(0).default(0),
121
- isMuted: z.boolean().default(false),
122
- isPinned: z.boolean().default(false),
123
- isArchived: z.boolean().default(false),
124
- isDeleted: z.boolean().default(false),
125
- })
126
- )
127
- .default([]),
128
-
129
- isLocked: z.boolean().default(true),
130
- allowUserSend: z.boolean().default(false),
131
-
132
- title: z.string().optional(),
133
- category: z.string().default('system'),
134
- importance: z.number().int().min(0).max(2).default(0),
135
-
136
- // ✅ use lastMessageDate consistently everywhere
137
- lastMessageDate: z.coerce.date().nullable().optional(),
138
- lastMessagePreview: z.string().default(''),
139
- messageCount: z.number().int().min(0).default(0),
140
- })
141
- );
142
-
143
- // ConversationMessage Schema
144
- export const ConversationMessage = Entity.merge(
145
- z.object({
146
- conversationId: ObjectId,
147
-
148
- role: z.enum(['user', 'assistant', 'system']),
149
-
150
- type: z.enum(['text', 'notice', 'reward', 'action', 'system']).default('text'),
151
-
152
- content: z.string().default(''),
153
-
154
- payload: z.any().optional(),
155
-
156
- replyToId: ObjectId.optional(),
157
-
158
- isStarred: z.boolean().default(false),
159
-
160
- claim: z
161
- .object({
162
- isClaimable: z.boolean().default(false),
163
-
164
- // ✅ align with Mongo: claimedDate (not claimedAt)
165
- claimedDate: z.coerce.date().nullable().optional(),
166
- claimedByProfileId: ObjectId.nullable().optional(),
167
-
168
- dedupeKey: z.string().nullable().optional(),
169
- attachments: z.array(z.any()).default([]),
170
-
171
- revokedDate: z.coerce.date().nullable().optional(),
172
- revokeReason: z.string().nullable().optional(),
173
- })
174
- .default({ isClaimable: false, attachments: [] }),
175
- })
176
- );
177
-
178
- // Data Schema
179
- export const Data = Entity.merge(
180
- z.object({
181
- mod: z.string(),
182
- })
183
- );
184
-
185
- // Meta Schema
186
- export const Meta = Entity.merge(z.object({}));
187
-
188
- // Discussion Schema
189
- export const Discussion = Entity.merge(
190
- z.object({
191
- content: z.string().optional(),
192
- parentId: ObjectId.optional(),
193
- rootMessageId: ObjectId.optional(),
194
- type: z.string().default('Discussion'),
195
- })
196
- );
197
-
198
- // Energy Schema
199
- export const Energy = Entity.merge(z.object({}));
200
-
201
- // Event Schema
202
- export const Event = Entity.merge(z.object({}));
203
-
204
- // File Schema
205
- export const File = Entity.merge(
206
- z.object({
207
- content: z.string().optional(),
208
- storageType: z.string().max(100).optional(),
209
- accessType: z.string().max(100).optional(),
210
- })
211
- );
212
-
213
- // Galaxy Schema
214
- export const Galaxy = Entity.merge(
215
- z.object({
216
- universeId: ObjectId.optional(),
217
- })
218
- );
219
-
220
- // Guide Schema
221
- export const Guide = Entity.merge(
222
- z.object({
223
- content: z.string().optional(),
224
- gameId: ObjectId.optional(),
225
- attachments: z.array(z.unknown()).optional(),
226
- })
227
- );
228
-
229
- // Idea Schema
230
- export const Idea = Entity.merge(
231
- z.object({
232
- type: z.string().max(100).optional(),
233
- communityId: ObjectId.optional(),
234
- })
235
- );
236
-
237
- // Leaderboard Schema
238
- export const Leaderboard = Entity.merge(
239
- z.object({
240
- productId: ObjectId.optional(),
241
- })
242
- );
243
-
244
- // Log Schema
245
- export const Log = Entity.merge(
246
- z.object({
247
- mod: z.string(),
248
- messages: z.array(z.unknown()).optional(),
249
- tags: z.array(z.unknown()).optional(),
250
- })
251
- );
252
-
253
- // Lore Schema
254
- export const Lore = Entity.merge(
255
- z.object({
256
- gameId: ObjectId.optional(),
257
- })
258
- );
259
-
260
- // Market Schema
261
- export const Market = Entity.merge(z.object({}));
262
-
263
- // Memory Schema
264
- export const Memory = Entity.merge(z.object({}));
265
-
266
- // Message Schema
267
- export const Message = Entity.merge(
268
- z.object({
269
- conversationId: ObjectId.optional(),
270
- content: z.string().optional(),
271
- type: z.string().max(100).optional(),
272
- replyToId: ObjectId.optional(),
273
- parentId: ObjectId.optional(),
274
- parent: ObjectId.optional(),
275
- messageIds: z.array(ObjectId).optional(),
276
- // messages: z.array(ObjectId).optional(),
277
- })
278
- );
279
-
280
- // Metaverse Schema
281
- export const Metaverse = Entity.merge(
282
- z.object({
283
- omniverseId: ObjectId,
284
- ratingId: ObjectId.optional(),
285
- })
286
- );
287
-
288
- // NewsArticle Schema
289
- export const NewsArticle = Entity.merge(
290
- z.object({
291
- href: z.string(),
292
- source: z.string(),
293
- })
294
- );
295
-
296
- // Npc Schema
297
- export const Npc = Entity.merge(
298
- z.object({
299
- characterRaceId: ObjectId.optional(),
300
- characterId: ObjectId.optional(),
301
- })
302
- );
303
-
304
- // Offer Schema
305
- export const Offer = Entity.merge(z.object({}));
306
-
307
- // Omniverse Schema
308
- export const Omniverse = Entity.merge(
309
- z.object({
310
- ratingId: ObjectId.optional(),
311
- })
312
- );
313
-
314
- // Order Schema
315
- export const Order = Entity.merge(z.object({}));
316
-
317
- // Payment Schema
318
- export const Payment = Entity.merge(
319
- z.object({
320
- owner: Profile.optional(),
321
- status: z
322
- .enum([
323
- 'Archived',
324
- 'Processing',
325
- 'Failed',
326
- 'Submitted',
327
- 'Denied',
328
- 'Processed',
329
- 'Voided',
330
- 'Completed',
331
- 'Refunding',
332
- 'Refunded',
333
- 'Expired',
334
- ])
335
- .default('Submitted'),
336
- })
337
- );
338
-
339
- // Permission Schema
340
- export const Permission = Entity.merge(
341
- z.object({
342
- roles: z.array(ObjectId).optional(),
343
- })
344
- );
345
-
346
- // Person Schema
347
- export const Person = Entity.merge(
348
- z.object({
349
- content: z.string().optional(),
350
- companyId: ObjectId.optional(),
351
- })
352
- );
353
-
354
- // Planet Schema
355
- export const Planet = Entity.merge(
356
- z.object({
357
- solarSystemId: ObjectId.optional(),
358
- })
359
- );
360
-
361
- // Poll Schema
362
- export const Poll = Entity.merge(z.object({}));
363
-
364
- // Project Schema
365
- export const Project = Entity.merge(
366
- z.object({
367
- content: z.string().optional(),
368
- contractStatus: z.string().default('Pending').optional(),
369
- parentId: ObjectId.optional(),
370
- realmId: ObjectId.optional(),
371
- communityId: ObjectId.optional(),
372
- productId: ObjectId.optional(),
373
- ratingId: ObjectId.optional(),
374
- })
375
- );
376
-
377
- // Proposal Schema
378
- export const Proposal = Entity.merge(
379
- z.object({
380
- content: z.string().optional(),
381
- })
382
- );
383
-
384
- // Quest Schema
385
- export const Quest = Entity.merge(
386
- z.object({
387
- type: z.string().default('zone'),
388
- })
389
- );
390
-
391
- // Question Schema
392
- export const Question = Entity.merge(
393
- z.object({
394
- topics: z.array(z.unknown()).optional(),
395
- text: z.string(),
396
- answer: z.string(),
397
- popularity: z.number().optional(),
398
- })
399
- );
400
-
401
- // Rating Schema
402
- export const Rating = Entity.merge(
403
- z.object({
404
- votes: z.array(ObjectId).optional(),
405
- projects: z.array(ObjectId).optional(),
406
- comments: z.array(ObjectId).optional(),
407
- })
408
- );
409
-
410
- // Referral Schema
411
- export const Referral = Entity.merge(
412
- z.object({
413
- recipientId: ObjectId.optional(),
414
- senderId: ObjectId.optional(),
415
- })
416
- );
417
-
418
- // Revision Schema
419
- export const Revision = Entity.merge(
420
- z.object({
421
- objectType: z.string().max(100),
422
- objectId: z.string().min(1),
423
- actionType: z.string().max(100),
424
- reason: z.string().max(100),
425
- interfaces: z.array(ObjectId).optional(),
426
- profiles: z.array(ObjectId).optional(),
427
- })
428
- );
429
-
430
- // Review Schema
431
- export const Review = Entity.merge(
432
- z.object({
433
- value: z.string().optional(),
434
- })
435
- );
436
-
437
- // Role Schema
438
- export const Role = Entity.merge(
439
- z.object({
440
- value: z.string().optional(),
441
- profiles: z.array(ObjectId).optional(),
442
- permissions: z.array(ObjectId).optional(),
443
- })
444
- );
445
-
446
- // Season Schema
447
- export const Season = Entity.merge(z.object({}));
448
-
449
- // RealmShard Schema
450
- export const RealmShard = Entity.merge(
451
- z.object({
452
- endpoint: z.string().max(100),
453
- realmId: ObjectId.optional(),
454
- status: z.string().default('Offline').optional(),
455
- clientCount: z.number(),
456
- })
457
- );
458
-
459
- // RealmTrait Schema
460
- export const RealmTrait = Entity.merge(
461
- z.object({
462
- description: z.string().optional(),
463
- })
464
- );
465
-
466
- // RealmEvent Schema
467
- export const RealmEvent = Entity.merge(
468
- z.object({
469
- description: z.string().optional(),
470
- startDate: z.date().optional(),
471
- endDate: z.date().optional(),
472
- })
473
- );
474
-
475
- // Realm Schema
476
- export const Realm = Entity.merge(
477
- z.object({
478
- endpoint: z.string().max(100).optional(),
479
- realmShards: z.array(RealmShard).optional(),
480
- realmEvents: z.array(RealmEvent).optional(),
481
- realmTraits: z.array(RealmTrait).optional(),
482
- gameId: ObjectId,
483
- status: z.string().default('Offline').optional(),
484
- clientCount: z.number(),
485
- regionCode: z.string(),
486
- })
487
- );
488
-
489
- // Session Schema
490
- export const Session = Entity.merge(
491
- z.object({
492
- expired: z.date(),
493
- })
494
- );
495
-
496
- // SolarSystem Schema
497
- export const SolarSystem = Entity.merge(
498
- z.object({
499
- galaxyId: ObjectId.optional(),
500
- })
501
- );
502
-
503
- // Star Schema
504
- export const Star = Entity.merge(z.object({}));
505
-
506
- // Stash Schema
507
- export const Stash = Entity.merge(z.object({}));
508
-
509
- // Stock Schema
510
- export const Stock = Entity.merge(
511
- z.object({
512
- rank: z.number().min(0).optional(),
513
- price: z.number().min(0).optional(),
514
- hourChange: z.number().optional(),
515
- dayChange: z.number().optional(),
516
- weekChange: z.number().optional(),
517
- marketCap: z.number().min(0).optional(),
518
- volume: z.number().min(0).optional(),
519
- ticker: z.string(),
520
- unusualActivity: z.number().min(0).optional(),
521
- })
522
- );
523
-
524
- // Suggestion Schema
525
- export const Suggestion = Entity.merge(
526
- z.object({
527
- content: z.string().optional(),
528
- })
529
- );
530
-
531
- // Tag Schema
532
- export const Tag = Entity.merge(
533
- z.object({
534
- value: z.string().optional(),
535
- })
536
- );
537
-
538
- // Team Schema
539
- export const Team = Entity.merge(
540
- z.object({
541
- ratingId: ObjectId.optional(),
542
- profiles: z.array(Profile).optional(), // TODO: convert to 'members'
543
- limit: z.number().optional().default(50),
544
- points: z.number().optional().default(0),
545
- memberCount: z.number().optional().default(0),
546
- })
547
- );
548
-
549
- // Party Schema
550
- export const Party = Entity.merge(
551
- z.object({
552
- targetAreaId: ObjectId.optional(),
553
- limit: z.number().default(6),
554
- isPublic: z.boolean().default(true),
555
- isVisibleToEnemies: z.boolean().default(true),
556
- isAlliesOnly: z.boolean().default(false),
557
- isApprovalRequired: z.boolean().default(false),
558
- isNonLeaderInviteAllowed: z.boolean().default(false),
559
- isCombatEnabled: z.boolean().default(true),
560
- isDisbandEnabled: z.boolean().default(false),
561
- isFriendlyFireEnabled: z.boolean().default(true),
562
- isLocalQuestShared: z.boolean().default(true),
563
- isGlobalQuestShared: z.boolean().default(true),
564
- isMergeEnabled: z.boolean().default(false),
565
- isRejoinEnabled: z.boolean().default(false),
566
- itemDistribution: z.enum(['Random', 'Personal']),
567
- leaderId: ObjectId.optional(),
568
- powerRequired: z.number().default(1),
569
- levelRequired: z.number().default(1),
570
- approvalMethod: z.enum(['Auto Accept', 'Approval Required']),
571
- memberIds: z.array(ObjectId).optional(),
572
- assistantIds: z.array(ObjectId).optional(), // have control over party even if not in party
573
- pendingMemberIds: z.array(ObjectId).optional(),
574
- blockedMemberIds: z.array(ObjectId).optional(),
575
- members: z.array(Profile).optional().default([]),
576
- })
577
- );
578
-
579
- // Tournament Schema
580
- export const Tournament = Entity.merge(z.object({}));
581
-
582
- // Trade Schema
583
- export const Trade = Entity.merge(
584
- z.object({
585
- status: z.enum(['Paused', 'Pending', 'Active', 'Delisted', 'Sold']).default('Active'), // Default set in StatusEnum matches Mongoose
586
- chainId: ObjectId.optional(),
587
- buyerId: ObjectId.optional(),
588
- parentId: ObjectId.optional(),
589
- productId: ObjectId.optional(),
590
- sellerId: ObjectId.optional(),
591
- itemId: ObjectId.optional(),
592
- tokenId: ObjectId.optional(),
593
- })
594
- );
595
-
596
- // Universe Schema
597
- export const Universe = Entity.merge(z.object({}));
598
-
599
- // Validator Schema
600
- export const Validator = Entity.merge(z.object({}));
601
-
602
- // Vote Schema
603
- export const Vote = Entity.merge(
604
- z.object({
605
- ratingId: ObjectId.optional(),
606
- })
607
- );
608
-
609
- // WorldEvent Schema
610
- export const WorldEvent = Entity.merge(
611
- z.object({
612
- text: z.string().min(1),
613
- importance: z.number().optional(),
614
- tags: z.array(z.unknown()).optional(),
615
- })
616
- );
617
-
618
- // WorldRecord Schema
619
- export const WorldRecord = Entity.merge(
620
- z.object({
621
- gameId: ObjectId.optional(),
622
- holderId: ObjectId,
623
- score: z.number().default(0),
624
- })
625
- );
626
-
627
- // Stat Schema
628
- export const Stat = Entity.merge(
629
- z.object({
630
- number: z.number().default(0),
631
- })
632
- );
633
-
634
- // Define the enum of model names
635
- export const ModelNames = z.enum([
636
- 'Account',
637
- 'Achievement',
638
- 'Act',
639
- 'Agent',
640
- 'Application',
641
- 'Badge',
642
- 'BattlePass',
643
- 'Biome',
644
- 'BiomeFeature',
645
- 'Bounty',
646
- 'Collection',
647
- 'Comment',
648
- 'Community',
649
- 'Company',
650
- 'Conversation',
651
- 'ConversationMessage',
652
- 'Data',
653
- 'Discussion',
654
- 'Energy',
655
- 'Event',
656
- 'File',
657
- 'Galaxy',
658
- 'Guide',
659
- 'Idea',
660
- 'Leaderboard',
661
- 'Log',
662
- 'Lore',
663
- 'Market',
664
- 'Memory',
665
- 'Message',
666
- 'Metaverse',
667
- 'NewsArticle',
668
- 'Npc',
669
- 'Offer',
670
- 'Omniverse',
671
- 'Order',
672
- 'ObjectInteraction',
673
- 'Payment',
674
- 'Party',
675
- 'Permission',
676
- 'Person',
677
- 'Planet',
678
- 'Poll',
679
- 'Project',
680
- 'Proposal',
681
- 'Quest',
682
- 'Question',
683
- 'Rating',
684
- 'Realm',
685
- 'Referral',
686
- 'Revision',
687
- 'Review',
688
- 'Role',
689
- 'Season',
690
- 'RealmShard',
691
- 'Session',
692
- 'SeerEvent',
693
- 'SeerPayload',
694
- 'Procedure',
695
- 'SolarSystem',
696
- 'Star',
697
- 'Stash',
698
- 'Stock',
699
- 'Suggestion',
700
- 'Tag',
701
- 'Team',
702
- 'Tournament',
703
- 'Trade',
704
- 'Universe',
705
- 'Validator',
706
- 'Vote',
707
- 'WorldEvent',
708
- 'WorldRecord',
709
- 'Stat',
710
- ]);
711
-
712
- // Node Schema for polymorphic relationships
713
- export const Node = z.object({
714
- relationKey: z.string(),
715
- fromModel: ModelNames,
716
- from: ObjectId,
717
- toModel: ModelNames,
718
- to: ObjectId,
719
- });
720
-
721
- export const Prefab = Entity.merge(
722
- z.object({
723
- name: z.string().min(1),
724
- fbxPath: z.string().min(1),
725
- customizationOptions: z.record(z.any()).optional(), // Allows flexibility for customizable properties
726
- childPrefabs: z
727
- .array(
728
- z.object({
729
- prefabId: ObjectId,
730
- position: z.object({
731
- x: z.number(),
732
- y: z.number(),
733
- z: z.number(),
734
- }),
735
- rotation: z
736
- .object({
737
- x: z.number(),
738
- y: z.number(),
739
- z: z.number(),
740
- })
741
- .optional(),
742
- scale: z.number().positive().default(1),
743
- })
744
- )
745
- .optional(),
746
- })
747
- );
748
-
749
- export const Object = Entity.merge(
750
- z.object({
751
- prefabId: ObjectId,
752
- playerId: ObjectId,
753
- coordinates: z.object({
754
- x: z.number(),
755
- y: z.number(),
756
- z: z.number(),
757
- }),
758
- rotation: z
759
- .object({
760
- x: z.number(),
761
- y: z.number(),
762
- z: z.number(),
763
- })
764
- .optional(),
765
- scale: z.number().positive().default(1),
766
- customizations: z.record(z.any()).optional(),
767
- childInstances: z
768
- .array(
769
- z.object({
770
- prefabId: ObjectId,
771
- coordinates: z.object({
772
- x: z.number(),
773
- y: z.number(),
774
- z: z.number(),
775
- }),
776
- rotation: z
777
- .object({
778
- x: z.number(),
779
- y: z.number(),
780
- z: z.number(),
781
- })
782
- .optional(),
783
- scale: z.number().positive().default(1),
784
- })
785
- )
786
- .optional(),
787
- })
788
- );
789
-
790
- export const ObjectInteraction = Entity.merge(
791
- z.object({
792
- profileId: ObjectId,
793
- objectId: ObjectId,
794
- interactionType: z.enum(['Use', 'Fight', 'Open', 'Talk', 'Touch']),
795
- outcome: z.record(z.any()).optional(),
796
- })
797
- );
798
-
799
- export const SeerEvent = Entity.merge(
800
- z.object({
801
- // Which model this event is about, e.g. "Character", "Item", "Zone", etc.
802
- kind: z.string().min(1),
803
-
804
- // Logical operation over that model
805
- operation: z.enum(['create', 'update', 'delete']),
806
-
807
- // ID of the affected record (Mongo _id as string)
808
- recordId: z.string().min(1),
809
-
810
- // Application scoping (optional)
811
- // applicationId: ObjectId.optional(),
812
-
813
- // Full payload for this version (we keep it generic / untyped here)
814
- payload: z.unknown(),
815
-
816
- // Monotonically increasing sequence number for ordering
817
- seq: z.number().int(),
818
-
819
- // When the event occurred
820
- timestamp: z.date(),
821
- })
822
- );
823
-
824
- export const SeerPayload = Entity.merge(
825
- z.object({
826
- // Which seer node / wallet this payload came from
827
- fromSeer: z.string().min(1),
828
-
829
- // Optional app scope (if you ever shard per app)
830
- // applicationId: ObjectId.optional(),
831
-
832
- // Batch of SeerEvent-like objects (kept generic to avoid cross-module coupling)
833
- events: z.array(z.unknown()).default([]),
834
-
835
- // Hash of events as used in your zk circuit
836
- eventsHash: z.string().min(1),
837
-
838
- // Merkle root representing this batch / state
839
- merkleRoot: z.string().min(1),
840
-
841
- // Groth16 proof object
842
- proof: z.unknown(),
843
-
844
- // Groth16 public signals
845
- publicSignals: z.unknown(),
846
- })
847
- );