@almadar/core 10.96.0 → 10.99.0

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 (101) hide show
  1. package/README.md +25 -0
  2. package/dist/builders.d.ts +5 -4
  3. package/dist/builders.js +60 -34
  4. package/dist/builders.js.map +1 -1
  5. package/dist/bus-BGDM3Xot.d.ts +565 -0
  6. package/dist/domain-Ds_7wZIL.d.ts +16213 -0
  7. package/dist/{effect-Bw8T4qh5.d.ts → effect-CW_IT0Jn.d.ts} +59 -4
  8. package/dist/{entityAccess-DfoXs9mc.d.ts → entityAccess-BLpOMojb.d.ts} +3 -3
  9. package/dist/{expression-WfTp2arD.d.ts → expression-DRwzVnMu.d.ts} +5 -1
  10. package/dist/factory/index.d.ts +5 -5
  11. package/dist/factory/index.js +22 -0
  12. package/dist/factory/index.js.map +1 -1
  13. package/dist/factory-runtime/index.d.ts +5 -4
  14. package/dist/factory-runtime/index.js +176 -34
  15. package/dist/factory-runtime/index.js.map +1 -1
  16. package/dist/fixtures.d.ts +45 -0
  17. package/dist/fixtures.js +693 -0
  18. package/dist/fixtures.js.map +1 -0
  19. package/dist/{index-CN16-h3i.d.ts → index-CHHuux4I.d.ts} +9 -375
  20. package/dist/index.d.ts +19 -15
  21. package/dist/index.js +9070 -44
  22. package/dist/index.js.map +1 -1
  23. package/dist/mock/index.d.ts +6 -5
  24. package/dist/mock/index.js +14 -0
  25. package/dist/mock/index.js.map +1 -1
  26. package/dist/patterns/component-mapping.json +1 -1
  27. package/dist/patterns/event-contracts.json +1 -1
  28. package/dist/patterns/index.d.ts +12 -8
  29. package/dist/patterns/index.js +15 -4
  30. package/dist/patterns/index.js.map +1 -1
  31. package/dist/patterns/patterns-registry.json +1 -1
  32. package/dist/patterns/registry.json +1 -1
  33. package/dist/{schema-DPpES4qj.d.ts → schema-BVjtoRYf.d.ts} +2134 -23608
  34. package/dist/state-machine/index.d.ts +1 -1
  35. package/dist/themes/index.d.ts +19 -0
  36. package/dist/themes/index.js +9251 -0
  37. package/dist/themes/index.js.map +1 -0
  38. package/dist/{trait-DXXRrRMP.d.ts → trait-C9lr222u.d.ts} +26 -26
  39. package/dist/types/index.d.ts +8 -6
  40. package/dist/types/index.js +208 -41
  41. package/dist/types/index.js.map +1 -1
  42. package/dist/{types-BMaTUGyk.d.ts → types-BoyvM79n.d.ts} +2 -2
  43. package/fixtures/events-wire/cascade-emitted-events/request.json +9 -0
  44. package/fixtures/events-wire/cascade-emitted-events/response.json +30 -0
  45. package/fixtures/events-wire/client-effects-by-trait/request.json +4 -0
  46. package/fixtures/events-wire/client-effects-by-trait/response.json +52 -0
  47. package/fixtures/events-wire/effect-results/request.json +9 -0
  48. package/fixtures/events-wire/effect-results/response.json +42 -0
  49. package/fixtures/events-wire/effect-results-every-kind/request.json +9 -0
  50. package/fixtures/events-wire/effect-results-every-kind/response.json +70 -0
  51. package/fixtures/events-wire/guard-rejected/request.json +6 -0
  52. package/fixtures/events-wire/guard-rejected/response.json +11 -0
  53. package/fixtures/events-wire/live-push/live-push.json +12 -0
  54. package/fixtures/events-wire/live-push/request.json +9 -0
  55. package/fixtures/events-wire/live-push/response.json +33 -0
  56. package/fixtures/events-wire/navigate-1/request.json +5 -0
  57. package/fixtures/events-wire/navigate-1/response.json +16 -0
  58. package/fixtures/events-wire/navigate-2/request.json +8 -0
  59. package/fixtures/events-wire/navigate-2/response.json +19 -0
  60. package/fixtures/events-wire/navigate-3/request.json +8 -0
  61. package/fixtures/events-wire/navigate-3/response.json +22 -0
  62. package/fixtures/events-wire/navigate-back/request.json +5 -0
  63. package/fixtures/events-wire/navigate-back/response.json +15 -0
  64. package/fixtures/events-wire/render-ui-3/request.json +5 -0
  65. package/fixtures/events-wire/render-ui-3/response.json +20 -0
  66. package/fixtures/events-wire/render-ui-4/request.json +5 -0
  67. package/fixtures/events-wire/render-ui-4/response.json +41 -0
  68. package/fixtures/events-wire/render-ui-5/request.json +9 -0
  69. package/fixtures/events-wire/render-ui-5/response.json +52 -0
  70. package/fixtures/events-wire/render-ui-clear/request.json +5 -0
  71. package/fixtures/events-wire/render-ui-clear/response.json +27 -0
  72. package/fixtures/events-wire/sse-stream/request.json +9 -0
  73. package/fixtures/events-wire/sse-stream/response.json +79 -0
  74. package/fixtures/events-wire/sse-stream/stream.json +131 -0
  75. package/fixtures/events-wire/stateless-traits/request.json +27 -0
  76. package/fixtures/events-wire/stateless-traits/response.json +15 -0
  77. package/fixtures/theme-tokens/every-key.json +43 -0
  78. package/package.json +18 -3
  79. package/themes/almadar-website.json +207 -0
  80. package/themes/almadar.json +203 -0
  81. package/themes/atelier.json +459 -0
  82. package/themes/bloomberg-dense.json +459 -0
  83. package/themes/clay.json +445 -0
  84. package/themes/comic.json +457 -0
  85. package/themes/corporate.json +445 -0
  86. package/themes/game-adventure.json +229 -0
  87. package/themes/game-rpg.json +230 -0
  88. package/themes/game-sci-fi.json +229 -0
  89. package/themes/game-ui-pack.json +230 -0
  90. package/themes/gazette.json +445 -0
  91. package/themes/glass.json +445 -0
  92. package/themes/kiosk.json +441 -0
  93. package/themes/linear-clean.json +459 -0
  94. package/themes/minimalist.json +445 -0
  95. package/themes/neon.json +445 -0
  96. package/themes/notion-editorial.json +459 -0
  97. package/themes/prism.json +203 -0
  98. package/themes/retro.json +445 -0
  99. package/themes/terminal.json +457 -0
  100. package/themes/trait-wars.json +493 -0
  101. package/themes/wireframe.json +445 -0
@@ -0,0 +1,693 @@
1
+ import { readFileSync } from 'fs';
2
+ import { join, dirname } from 'path';
3
+ import { fileURLToPath } from 'url';
4
+ import { z } from 'zod';
5
+
6
+ // src/fixtures.ts
7
+ var SExprDataSchema = z.lazy(
8
+ () => z.union([SExprAtomSchema, z.array(SExprDataSchema)])
9
+ );
10
+ var SExprAtomSchema = z.union([
11
+ z.string(),
12
+ z.number(),
13
+ z.boolean(),
14
+ z.null(),
15
+ z.record(SExprDataSchema)
16
+ // Objects for payload data
17
+ ]);
18
+ var SExprSchema = z.lazy(
19
+ () => z.union([
20
+ SExprAtomSchema,
21
+ z.array(z.lazy(() => SExprSchema)).min(1).refine(
22
+ (arr) => typeof arr[0] === "string",
23
+ { message: "S-expression array must have a string operator as first element" }
24
+ )
25
+ ])
26
+ );
27
+ var EventPayloadValueSchema = z.lazy(
28
+ () => z.union([
29
+ z.string(),
30
+ z.number(),
31
+ z.boolean(),
32
+ z.date(),
33
+ z.null(),
34
+ z.undefined(),
35
+ EventPayloadSchema,
36
+ z.array(EventPayloadValueSchema)
37
+ ])
38
+ );
39
+ var EventPayloadSchema = z.lazy(() => z.record(EventPayloadValueSchema));
40
+ var ID_PREFIXES = {
41
+ orbital: "orb_",
42
+ entity: "ent_",
43
+ trait: "trt_",
44
+ event: "evt_",
45
+ page: "pag_",
46
+ service: "svc_",
47
+ theme: "thm_",
48
+ palette: "pal_"
49
+ };
50
+ function brand(value) {
51
+ return value;
52
+ }
53
+ function makeIdKind(kind) {
54
+ const prefix = ID_PREFIXES[kind];
55
+ const is = (value) => value.startsWith(prefix) && value.length > prefix.length;
56
+ const as = (value) => {
57
+ if (!is(value)) {
58
+ throw new Error(
59
+ `Expected ${kind} id (prefix "${prefix}"), got: ${JSON.stringify(value)}`
60
+ );
61
+ }
62
+ return brand(value);
63
+ };
64
+ return { prefix, is, as };
65
+ }
66
+ var orbitalKind = makeIdKind("orbital");
67
+ var entityKind = makeIdKind("entity");
68
+ var traitKind = makeIdKind("trait");
69
+ var eventKind = makeIdKind("event");
70
+ var pageKind = makeIdKind("page");
71
+ var serviceKind = makeIdKind("service");
72
+ var themeKind = makeIdKind("theme");
73
+ var paletteKind = makeIdKind("palette");
74
+ var isOrbitalId = orbitalKind.is;
75
+ var isEntityId = entityKind.is;
76
+ var isTraitId = traitKind.is;
77
+ var isEventId = eventKind.is;
78
+ var isPageId = pageKind.is;
79
+ var isServiceId = serviceKind.is;
80
+ var isThemeId = themeKind.is;
81
+ var isPaletteEntryId = paletteKind.is;
82
+ var OrbitalIdSchema = z.string().refine(isOrbitalId, { message: `Expected an orbital id (prefix "${ID_PREFIXES.orbital}")` });
83
+ var EntityIdSchema = z.string().refine(isEntityId, { message: `Expected an entity id (prefix "${ID_PREFIXES.entity}")` });
84
+ var TraitIdSchema = z.string().refine(isTraitId, { message: `Expected a trait id (prefix "${ID_PREFIXES.trait}")` });
85
+ var EventIdSchema = z.string().refine(isEventId, { message: `Expected an event id (prefix "${ID_PREFIXES.event}")` });
86
+ z.string().refine(isPageId, { message: `Expected a page id (prefix "${ID_PREFIXES.page}")` });
87
+ z.string().refine(isServiceId, { message: `Expected a service id (prefix "${ID_PREFIXES.service}")` });
88
+ z.string().refine(isThemeId, { message: `Expected a theme id (prefix "${ID_PREFIXES.theme}")` });
89
+ z.string().refine(isPaletteEntryId, { message: `Expected a palette-entry id (prefix "${ID_PREFIXES.palette}")` });
90
+ var LedgerKindSchema = z.enum([
91
+ "orbital",
92
+ "entity",
93
+ "trait",
94
+ "event",
95
+ "page",
96
+ "service",
97
+ "theme"
98
+ ]);
99
+ var LedgerEntrySchema = z.object({
100
+ id: z.string(),
101
+ kind: LedgerKindSchema,
102
+ bakedName: z.string(),
103
+ curName: z.string(),
104
+ renames: z.array(
105
+ z.object({ from: z.string(), to: z.string(), at: z.string() })
106
+ ),
107
+ owner: z.enum(["std", "io", "workspace"]),
108
+ parent: TraitIdSchema.optional()
109
+ });
110
+ z.object({
111
+ schemaVersion: z.literal(1),
112
+ entries: z.record(LedgerEntrySchema)
113
+ });
114
+ var JsonValueSchema = z.lazy(
115
+ () => z.union([z.string(), z.number(), z.boolean(), z.null(), z.array(JsonValueSchema), z.record(JsonValueSchema)])
116
+ );
117
+
118
+ // src/types/field.ts
119
+ var FIELD_TYPES = [
120
+ "string",
121
+ "number",
122
+ "boolean",
123
+ "date",
124
+ "timestamp",
125
+ "datetime",
126
+ "email",
127
+ "url",
128
+ "phone",
129
+ "uuid",
130
+ "image",
131
+ "money",
132
+ "file",
133
+ "array",
134
+ "object",
135
+ "enum",
136
+ "relation",
137
+ "trait",
138
+ "slot",
139
+ "pattern",
140
+ "node",
141
+ "event",
142
+ "scalar",
143
+ "union"
144
+ ];
145
+ z.enum(FIELD_TYPES);
146
+ var RelationCardinalitySchema = z.enum([
147
+ "one",
148
+ "many",
149
+ "one-to-many",
150
+ "many-to-one",
151
+ "many-to-many"
152
+ ]);
153
+ var RelationConfigSchema = z.object({
154
+ entity: z.string().min(1, "Target entity is required"),
155
+ entityId: EntityIdSchema.optional(),
156
+ field: z.string().optional(),
157
+ cardinality: RelationCardinalitySchema.optional(),
158
+ onDelete: z.enum(["cascade", "nullify", "restrict"]).optional(),
159
+ // Legacy compatibility fields
160
+ foreignKey: z.string().optional(),
161
+ target: z.string().optional(),
162
+ type: RelationCardinalitySchema.optional()
163
+ }).transform((data) => {
164
+ const normalized = {
165
+ entity: data.entity || data.target || "",
166
+ entityId: data.entityId,
167
+ cardinality: data.cardinality || data.type,
168
+ field: data.field,
169
+ onDelete: data.onDelete
170
+ };
171
+ return normalized;
172
+ });
173
+ z.object({
174
+ name: z.string(),
175
+ url: z.string(),
176
+ mimeType: z.string(),
177
+ sizeBytes: z.number()
178
+ });
179
+ var FIELD_TYPE_ALIASES = {
180
+ text: "string",
181
+ int: "number",
182
+ float: "number",
183
+ ts: "timestamp"
184
+ };
185
+ var EntityFieldSchema = z.lazy(() => {
186
+ const baseFieldShape = {
187
+ name: z.string().min(1, "Field name is required").optional(),
188
+ required: z.boolean().optional(),
189
+ primaryKey: z.boolean().optional(),
190
+ default: JsonValueSchema.optional(),
191
+ min: z.number().optional(),
192
+ max: z.number().optional(),
193
+ properties: z.record(EntityFieldSchema).optional(),
194
+ intrinsic: z.boolean().optional(),
195
+ description: z.string().optional(),
196
+ synonyms: z.string().optional(),
197
+ mock: z.string().optional(),
198
+ mergedFrom: z.string().optional()
199
+ };
200
+ function scalarVariant(t) {
201
+ return z.object({
202
+ ...baseFieldShape,
203
+ type: z.literal(t),
204
+ values: z.array(z.string()).optional()
205
+ });
206
+ }
207
+ return z.preprocess(
208
+ (input) => {
209
+ if (input === null || typeof input !== "object" || !("type" in input) || typeof input.type !== "string") {
210
+ return input;
211
+ }
212
+ const obj = input;
213
+ const next = { ...obj };
214
+ const aliased = FIELD_TYPE_ALIASES[obj.type];
215
+ if (aliased !== void 0) next.type = aliased;
216
+ if (next.enum !== void 0 && next.values === void 0) {
217
+ next.values = next.enum;
218
+ }
219
+ delete next.enum;
220
+ return next;
221
+ },
222
+ z.discriminatedUnion("type", [
223
+ scalarVariant("string"),
224
+ scalarVariant("number"),
225
+ scalarVariant("boolean"),
226
+ scalarVariant("date"),
227
+ scalarVariant("timestamp"),
228
+ scalarVariant("datetime"),
229
+ scalarVariant("email"),
230
+ scalarVariant("url"),
231
+ scalarVariant("phone"),
232
+ scalarVariant("uuid"),
233
+ scalarVariant("image"),
234
+ scalarVariant("trait"),
235
+ scalarVariant("slot"),
236
+ scalarVariant("pattern"),
237
+ scalarVariant("node"),
238
+ scalarVariant("event"),
239
+ scalarVariant("money"),
240
+ scalarVariant("file"),
241
+ scalarVariant("scalar"),
242
+ // Enum variant — REQUIRES non-empty values.
243
+ z.object({
244
+ ...baseFieldShape,
245
+ type: z.literal("enum"),
246
+ values: z.array(z.string()).min(1, "Enum field requires a non-empty `values` array")
247
+ }),
248
+ // Union variant — tagged struct union; values = variant names,
249
+ // per-variant shapes in `properties` (absent on named recursion).
250
+ z.object({
251
+ ...baseFieldShape,
252
+ type: z.literal("union"),
253
+ values: z.array(z.string()).min(1, "Union field requires a non-empty `values` array")
254
+ }),
255
+ // Relation variant — REQUIRES relation config.
256
+ z.object({
257
+ ...baseFieldShape,
258
+ type: z.literal("relation"),
259
+ relation: RelationConfigSchema
260
+ }),
261
+ // Array variant — items optional to match relaxed TS shape.
262
+ z.object({
263
+ ...baseFieldShape,
264
+ type: z.literal("array"),
265
+ items: EntityFieldSchema.optional()
266
+ }),
267
+ // Object variant — fixed-key struct (`properties`) or dynamic-key
268
+ // map (`Map K V`, uniform value schema in `items`).
269
+ z.object({
270
+ ...baseFieldShape,
271
+ type: z.literal("object"),
272
+ items: EntityFieldSchema.optional(),
273
+ values: z.array(z.string()).optional()
274
+ })
275
+ ])
276
+ );
277
+ });
278
+ var ENTITY_ROLES = [
279
+ "player",
280
+ "enemy",
281
+ "npc",
282
+ "item",
283
+ "tile",
284
+ "projectile",
285
+ "effect",
286
+ "ui",
287
+ "decoration",
288
+ "vehicle"
289
+ ];
290
+ z.enum(ENTITY_ROLES);
291
+ var VISUAL_STYLES = ["pixel", "vector", "hd", "1-bit", "isometric"];
292
+ var VisualStyleSchema = z.enum(VISUAL_STYLES);
293
+ var ASSET_DIMENSIONS = ["2d", "3d"];
294
+ var AssetDimensionSchema = z.enum(ASSET_DIMENSIONS);
295
+ var ASSET_ASPECTS = ["1:1", "16:9", "5:7", "8:1", "4:1", "5:3", "1:2"];
296
+ var AssetAspectSchema = z.enum(ASSET_ASPECTS);
297
+ var ANIMATION_NAMES = ["idle", "walk", "skate", "jump", "fall", "attack", "hit", "death"];
298
+ z.enum(ANIMATION_NAMES);
299
+ var SPRITE_DIRECTIONS = ["se", "sw", "ne", "nw"];
300
+ var SpriteDirectionSchema = z.enum(SPRITE_DIRECTIONS);
301
+ var SHEET_PROJECTIONS = ["iso", "front", "back", "top", "perspective"];
302
+ z.enum(SHEET_PROJECTIONS);
303
+ var AnimationDefSchema = z.object({
304
+ row: z.number().int().nonnegative(),
305
+ frames: z.number().int().positive(),
306
+ frameRate: z.number().positive(),
307
+ loop: z.boolean()
308
+ });
309
+ z.object({
310
+ unit: z.string().optional(),
311
+ type: z.string().optional(),
312
+ frameWidth: z.number().positive(),
313
+ frameHeight: z.number().positive(),
314
+ columns: z.number().int().positive(),
315
+ rows: z.number().int().positive(),
316
+ directions: z.array(SpriteDirectionSchema),
317
+ sheets: z.record(SpriteDirectionSchema, z.string()),
318
+ animations: z.record(z.string(), AnimationDefSchema),
319
+ projections: z.object({
320
+ iso: z.record(SpriteDirectionSchema, z.string()).optional(),
321
+ front: z.string().optional(),
322
+ back: z.string().optional(),
323
+ top: z.string().optional(),
324
+ perspective: z.string().optional()
325
+ }).optional()
326
+ });
327
+ var SubTextureSchema = z.object({
328
+ x: z.number().nonnegative(),
329
+ y: z.number().nonnegative(),
330
+ width: z.number().positive(),
331
+ height: z.number().positive(),
332
+ frameX: z.number().optional(),
333
+ frameY: z.number().optional(),
334
+ frameWidth: z.number().positive().optional(),
335
+ frameHeight: z.number().positive().optional()
336
+ });
337
+ z.object({
338
+ imagePath: z.string(),
339
+ subTextures: z.record(z.string(), SubTextureSchema)
340
+ });
341
+ z.object({
342
+ imagePath: z.string(),
343
+ tileWidth: z.number().positive(),
344
+ tileHeight: z.number().positive(),
345
+ columns: z.number().int().positive(),
346
+ rows: z.number().int().positive(),
347
+ margin: z.number().nonnegative().optional(),
348
+ spacing: z.number().nonnegative().optional(),
349
+ names: z.array(z.string()).optional()
350
+ });
351
+ var SemanticAssetRefSchema = z.object({
352
+ role: z.string().min(1),
353
+ category: z.string().min(1),
354
+ animations: z.array(z.string()).optional(),
355
+ style: VisualStyleSchema.optional(),
356
+ variant: z.string().optional(),
357
+ dimension: AssetDimensionSchema.optional(),
358
+ aspect: AssetAspectSchema.optional()
359
+ });
360
+ SemanticAssetRefSchema.extend({
361
+ url: z.string(),
362
+ atlas: z.string().optional(),
363
+ sprite: z.string().optional(),
364
+ name: z.string().optional(),
365
+ thumbnailUrl: z.string().optional(),
366
+ prompt: z.string().optional(),
367
+ choreography: z.record(z.string(), z.array(z.string())).optional()
368
+ });
369
+ var AssetCatalogEntrySchema = z.object({
370
+ url: z.string(),
371
+ name: z.string(),
372
+ category: z.string(),
373
+ kind: z.enum(["image", "spritesheet", "audio", "scene", "portrait", "model", "other"]),
374
+ thumbnailUrl: z.string().optional(),
375
+ dimension: AssetDimensionSchema.optional(),
376
+ aspect: AssetAspectSchema.optional()
377
+ });
378
+ z.array(AssetCatalogEntrySchema);
379
+ var ScenePosSchema = z.object({
380
+ x: z.number(),
381
+ y: z.number(),
382
+ z: z.number().optional()
383
+ });
384
+ var CAMERA_MODES = ["isometric", "perspective", "top-down", "front", "follow", "chase"];
385
+ var CameraModeSchema = z.enum(CAMERA_MODES);
386
+ z.object({
387
+ pos: ScenePosSchema.optional(),
388
+ target: ScenePosSchema.optional(),
389
+ zoom: z.number().optional(),
390
+ fov: z.number().optional(),
391
+ mode: CameraModeSchema.optional(),
392
+ azimuth: z.number().optional(),
393
+ elevation: z.number().optional()
394
+ });
395
+ var MANIFEST_ENTRY_KINDS = ["model", "image", "spritesheet", "audio", "json"];
396
+ var ManifestEntryKindSchema = z.enum(MANIFEST_ENTRY_KINDS);
397
+ var SoundEntrySchema = z.object({
398
+ path: z.union([z.string(), z.array(z.string())]),
399
+ volume: z.number().optional(),
400
+ loop: z.boolean().optional(),
401
+ poolSize: z.number().optional(),
402
+ autostart: z.boolean().optional(),
403
+ crossfade: z.boolean().optional(),
404
+ crossfadeDurationMs: z.number().optional()
405
+ });
406
+ z.record(z.string(), SoundEntrySchema);
407
+ var MANIFEST_CANVAS_AFFINITIES = ["isometric", "hex", "flat", "side", "3d", "none"];
408
+ var ManifestCanvasAffinitySchema = z.enum(MANIFEST_CANVAS_AFFINITIES);
409
+ var MANIFEST_SOURCE_CATALOGS = ["kenny", "kekec-assets", "iram-assets", "trait-wars-assets", "kflow-assets"];
410
+ var ManifestSourceCatalogSchema = z.enum(MANIFEST_SOURCE_CATALOGS);
411
+ var MANIFEST_ASSET_LICENSES = ["CC0", "proprietary"];
412
+ var ManifestAssetLicenseSchema = z.enum(MANIFEST_ASSET_LICENSES);
413
+ var ManifestFrameSpecSchema = z.union([
414
+ z.object({ kind: z.literal("iso-tile"), w: z.number(), h: z.number() }),
415
+ z.object({ kind: z.literal("sprite-sheet"), frame: z.number(), cols: z.number(), rows: z.number() }),
416
+ z.string().min(1),
417
+ z.null()
418
+ ]);
419
+ z.object({
420
+ url: z.string(),
421
+ name: z.string(),
422
+ category: z.string(),
423
+ kind: ManifestEntryKindSchema,
424
+ width: z.number(),
425
+ height: z.number(),
426
+ canvasAffinity: ManifestCanvasAffinitySchema,
427
+ genreAffinity: z.array(z.string()),
428
+ swapClass: z.string(),
429
+ sourceCatalog: ManifestSourceCatalogSchema,
430
+ frameSpec: ManifestFrameSpecSchema,
431
+ license: ManifestAssetLicenseSchema.optional()
432
+ });
433
+
434
+ // src/types/entity.ts
435
+ var EntityPersistenceSchema = z.enum([
436
+ "persistent",
437
+ "runtime"
438
+ ]);
439
+ z.object({
440
+ name: z.string().min(1, "Entity name is required"),
441
+ // V4 arena id (`EntityDefinition.id`); declared so the strip-mode zod gate
442
+ // carries an imported entity's id through instead of erasing it.
443
+ id: EntityIdSchema.optional(),
444
+ persistence: EntityPersistenceSchema.default("persistent"),
445
+ shared: z.boolean().optional(),
446
+ // Must stay in step with the Rust serde field (`EntityDefinition.identity`,
447
+ // orbital-core/src/schema/types.rs). `z.object()` STRIPS unknown keys rather
448
+ // than rejecting them, so a Rust-only field works on the compiled path and
449
+ // silently vanishes on the interpreter path.
450
+ identity: z.boolean().optional(),
451
+ // Same "must stay in step with Rust serde" hazard as `identity` above —
452
+ // these four mirror `EntityDefinition.{read,create,update,delete}_policy`.
453
+ // Rust has no `rename_all` on this struct, so the wire key IS snake_case
454
+ // (unlike this file's other camelCase fields, which are Rust-side-absent
455
+ // and so never hit this cross-language constraint — see `visual_prompt`
456
+ // just below for the existing precedent).
457
+ read_policy: SExprSchema.optional(),
458
+ create_policy: SExprSchema.optional(),
459
+ update_policy: SExprSchema.optional(),
460
+ delete_policy: SExprSchema.optional(),
461
+ // Snake_case for the same cross-language reason as the four policies above.
462
+ access_waivers: z.object({
463
+ read: z.string().optional(),
464
+ create: z.string().optional(),
465
+ update: z.string().optional(),
466
+ delete: z.string().optional()
467
+ }).optional(),
468
+ collection: z.string().optional(),
469
+ fields: z.array(EntityFieldSchema).min(1, "At least one field is required"),
470
+ instances: z.array(z.record(JsonValueSchema)).optional(),
471
+ timestamps: z.boolean().optional(),
472
+ softDelete: z.boolean().optional(),
473
+ description: z.string().optional(),
474
+ visual_prompt: z.string().optional(),
475
+ assetRef: SemanticAssetRefSchema.optional()
476
+ });
477
+ var FieldValueSchema = z.lazy(
478
+ () => z.union([z.string(), z.number(), z.boolean(), z.date(), z.null(), z.array(FieldValueSchema), z.record(FieldValueSchema.optional())])
479
+ );
480
+ var EntityRowSchema = z.object({ id: z.string().optional() }).catchall(FieldValueSchema.optional());
481
+ var UI_SLOTS = [
482
+ // App slots
483
+ "main",
484
+ "sidebar",
485
+ "modal",
486
+ "drawer",
487
+ "overlay",
488
+ "center",
489
+ "toast",
490
+ "floating",
491
+ "system",
492
+ // For invisible system components (InputListener, CollisionDetector)
493
+ "content",
494
+ "screen",
495
+ // Game HUD slots
496
+ "hud",
497
+ "hud-top",
498
+ "hud-bottom",
499
+ "hud.health",
500
+ "hud.score",
501
+ "hud.inventory",
502
+ "hud.stamina",
503
+ // Game overlay slots
504
+ "overlay.inventory",
505
+ "overlay.dialogue",
506
+ "overlay.menu",
507
+ "overlay.pause"
508
+ ];
509
+ z.enum(UI_SLOTS);
510
+ var SERVER_REPORTED_EFFECTS = [
511
+ "set",
512
+ "persist",
513
+ "call-service",
514
+ "fetch",
515
+ "fetch-stream",
516
+ "ref",
517
+ "deref",
518
+ "swap!",
519
+ "atomic",
520
+ "emit"
521
+ ];
522
+ z.array(SExprDataSchema).min(1).refine(
523
+ (arr) => typeof arr[0] === "string",
524
+ { message: "Effect must be an S-expression with a string operator as first element" }
525
+ );
526
+ var PatternConfigSchema = z.custom(
527
+ (value) => value === null || typeof value === "object" && value !== null && !Array.isArray(value),
528
+ { message: "Expected a pattern config object or null" }
529
+ );
530
+ var ResolvedPatternPropsSchema = z.custom(
531
+ (value) => typeof value === "object" && value !== null && !Array.isArray(value),
532
+ { message: "Expected a resolved pattern props object" }
533
+ );
534
+ var RawUserClaimsSchema = z.object({
535
+ id: z.string().optional(),
536
+ uid: z.string().optional(),
537
+ email: z.string().nullable().optional(),
538
+ name: z.string().optional(),
539
+ displayName: z.string().nullable().optional(),
540
+ role: z.string().optional(),
541
+ permissions: z.array(z.string()).optional()
542
+ }).catchall(FieldValueSchema.optional());
543
+ var ServerBatchSummarySchema = z.object({
544
+ operations: z.array(EntityRowSchema),
545
+ completedCount: z.number(),
546
+ totalCount: z.number()
547
+ });
548
+ var ServerEffectResultSchema = z.object({
549
+ effect: z.union([z.enum(SERVER_REPORTED_EFFECTS), z.literal("substrate")]),
550
+ action: z.string().optional(),
551
+ entityType: z.string().optional(),
552
+ name: z.custom((v) => typeof v === "string" && /^[^/]+\/.+$/.test(v)).optional(),
553
+ data: z.union([EntityRowSchema, ServerBatchSummarySchema, EventPayloadValueSchema]).optional(),
554
+ success: z.boolean(),
555
+ denied: z.literal(true).optional(),
556
+ error: z.string().optional(),
557
+ code: z.enum(["not-found", "no-row-key"]).optional()
558
+ });
559
+
560
+ // src/types/bus.ts
561
+ var BusEventSourceSchema = z.object({
562
+ orbital: z.string().optional(),
563
+ orbitalId: OrbitalIdSchema.optional(),
564
+ trait: z.string().optional(),
565
+ traitId: TraitIdSchema.optional(),
566
+ eventId: EventIdSchema.optional(),
567
+ transition: z.string().optional(),
568
+ tick: z.string().optional(),
569
+ fromBridge: z.boolean().optional(),
570
+ dispatched: z.boolean().optional(),
571
+ originClientId: z.string().optional()
572
+ });
573
+ var EmittedEventSchema = z.object({
574
+ event: z.string(),
575
+ payload: EventPayloadSchema.optional(),
576
+ source: BusEventSourceSchema.optional()
577
+ });
578
+ var ClientRenderUITupleSchema = z.union([
579
+ z.tuple([z.literal("render-ui"), z.string(), PatternConfigSchema]),
580
+ z.tuple([z.literal("render-ui"), z.string(), PatternConfigSchema, ResolvedPatternPropsSchema]),
581
+ z.tuple([
582
+ z.literal("render-ui"),
583
+ z.string(),
584
+ PatternConfigSchema,
585
+ ResolvedPatternPropsSchema.optional(),
586
+ z.number().optional()
587
+ ])
588
+ ]);
589
+ var ClientNavigateTupleSchema = z.union([
590
+ z.tuple([z.literal("navigate"), z.string()]),
591
+ z.tuple([z.literal("navigate"), z.string(), z.record(z.string()).optional()]),
592
+ z.tuple([
593
+ z.literal("navigate"),
594
+ z.string(),
595
+ z.record(z.string()).optional(),
596
+ z.object({ crumb: z.string().optional() })
597
+ ])
598
+ ]);
599
+ var ClientNavigateBackTupleSchema = z.tuple([z.literal("navigate-back")]);
600
+ var ClientEffectTupleSchema = z.union([
601
+ ClientRenderUITupleSchema,
602
+ ClientNavigateTupleSchema,
603
+ ClientNavigateBackTupleSchema
604
+ ]);
605
+ var OrbitalEventRequestSchema = z.object({
606
+ event: z.string(),
607
+ eventId: EventIdSchema.optional(),
608
+ payload: EventPayloadSchema.optional(),
609
+ entityId: z.string().optional(),
610
+ targetTrait: z.string().optional(),
611
+ user: RawUserClaimsSchema.optional(),
612
+ clientId: z.string().optional(),
613
+ tick: z.string().optional(),
614
+ sourceTrait: z.string().optional(),
615
+ traits: z.array(z.object({ trait: z.string(), from: z.string() })).optional(),
616
+ entityByTrait: z.record(EntityRowSchema).optional(),
617
+ behavior: z.string().optional()
618
+ });
619
+ var OrbitalEventResponseSchema = z.object({
620
+ success: z.boolean(),
621
+ transitioned: z.boolean(),
622
+ states: z.record(z.string()),
623
+ emittedEvents: z.array(EmittedEventSchema),
624
+ data: z.record(z.array(EntityRowSchema)).optional(),
625
+ entityByTrait: z.record(EntityRowSchema).optional(),
626
+ clientEffects: z.array(ClientEffectTupleSchema).optional(),
627
+ clientEffectsByTrait: z.array(z.object({ traitName: z.string(), effect: ClientEffectTupleSchema })).optional(),
628
+ effectResults: z.array(ServerEffectResultSchema).optional(),
629
+ guardFailed: z.string().optional(),
630
+ error: z.string().optional()
631
+ });
632
+ var LiveBroadcastItemSchema = z.object({
633
+ event: z.string(),
634
+ payload: EventPayloadSchema.optional(),
635
+ source: BusEventSourceSchema,
636
+ originClientId: z.string().optional()
637
+ });
638
+
639
+ // src/fixtures.ts
640
+ var SSEStreamItemSchema = z.union([
641
+ z.object({ type: z.literal("event"), data: EmittedEventSchema, timestamp: z.number() }),
642
+ z.object({ type: z.literal("effect"), data: ClientEffectTupleSchema, timestamp: z.number() }),
643
+ z.object({ type: z.literal("complete"), data: OrbitalEventResponseSchema, timestamp: z.number() }),
644
+ z.object({ type: z.literal("error"), data: z.object({ message: z.string() }), timestamp: z.number() })
645
+ ]);
646
+ var EVENT_WIRE_FIXTURE_CASES = [
647
+ "cascade-emitted-events",
648
+ "client-effects-by-trait",
649
+ "effect-results",
650
+ "effect-results-every-kind",
651
+ "guard-rejected",
652
+ "live-push",
653
+ "navigate-1",
654
+ "navigate-2",
655
+ "navigate-3",
656
+ "navigate-back",
657
+ "render-ui-3",
658
+ "render-ui-4",
659
+ "render-ui-5",
660
+ "render-ui-clear",
661
+ "sse-stream",
662
+ "stateless-traits"
663
+ ];
664
+ var PACKAGE_ROOT = join(dirname(fileURLToPath(import.meta.url)), "..");
665
+ function readJsonIfExists(path) {
666
+ try {
667
+ const json = JSON.parse(readFileSync(path, "utf8"));
668
+ return json;
669
+ } catch (error) {
670
+ if (error.code === "ENOENT") return void 0;
671
+ throw error;
672
+ }
673
+ }
674
+ function loadValidated(caseDir, file, schema) {
675
+ const json = readJsonIfExists(join(caseDir, file));
676
+ return json === void 0 ? void 0 : schema.parse(json);
677
+ }
678
+ function loadEventWireFixture(caseName) {
679
+ if (!EVENT_WIRE_FIXTURE_CASES.includes(caseName)) {
680
+ throw new Error(`Unknown event-wire fixture case: "${caseName}". Known cases: ${EVENT_WIRE_FIXTURE_CASES.join(", ")}`);
681
+ }
682
+ const caseDir = join(PACKAGE_ROOT, "fixtures", "events-wire", caseName);
683
+ return {
684
+ request: loadValidated(caseDir, "request.json", OrbitalEventRequestSchema),
685
+ response: loadValidated(caseDir, "response.json", OrbitalEventResponseSchema),
686
+ stream: loadValidated(caseDir, "stream.json", z.array(SSEStreamItemSchema)),
687
+ livePush: loadValidated(caseDir, "live-push.json", LiveBroadcastItemSchema)
688
+ };
689
+ }
690
+
691
+ export { EVENT_WIRE_FIXTURE_CASES, SSEStreamItemSchema, loadEventWireFixture };
692
+ //# sourceMappingURL=fixtures.js.map
693
+ //# sourceMappingURL=fixtures.js.map