@onlyworlds/sdk 1.0.0 → 1.2.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.
package/dist/index.d.mts CHANGED
@@ -1,3 +1,26 @@
1
+ /**
2
+ * Modern branded types for type-safe element relationships
3
+ * Provides compile-time safety while maintaining zero runtime overhead
4
+ */
5
+ declare const __brand: unique symbol;
6
+ type Brand<B> = {
7
+ [__brand]: B;
8
+ };
9
+ /**
10
+ * Branded type for element IDs - ensures type safety for relationships
11
+ * @template T The element type this ID references
12
+ */
13
+ type ElementId<T extends ElementType> = string & Brand<T>;
14
+ /**
15
+ * Branded type for arrays of element IDs
16
+ * @template T The element type these IDs reference
17
+ */
18
+ type ElementIds<T extends ElementType> = ElementId<T>[];
19
+ /**
20
+ * Special type for IDs that can reference ANY element type
21
+ * Used in cases like Pin.element_type where the target can be any OnlyWorlds element
22
+ */
23
+ type AnyElementId = ElementId<ElementType>;
1
24
  /**
2
25
  * Base fields shared by all OnlyWorlds elements
3
26
  */
@@ -12,6 +35,41 @@ interface BaseElement {
12
35
  created_at?: string;
13
36
  updated_at?: string;
14
37
  }
38
+ /**
39
+ * World element type
40
+ */
41
+ interface World {
42
+ id?: string;
43
+ api_key: string;
44
+ name: string;
45
+ description?: string;
46
+ version?: string;
47
+ image_url?: string;
48
+ time_format_equivalents?: any[];
49
+ time_format_names?: any[];
50
+ time_basic_unit?: string;
51
+ time_range_min?: number;
52
+ time_range_max?: number;
53
+ time_current?: number;
54
+ user?: string;
55
+ created_at?: string;
56
+ updated_at?: string;
57
+ }
58
+ /**
59
+ * World input type for creation/updates
60
+ */
61
+ interface WorldInput {
62
+ name: string;
63
+ description?: string;
64
+ version?: string;
65
+ image_url?: string;
66
+ time_format_equivalents?: any[];
67
+ time_format_names?: any[];
68
+ time_basic_unit?: string;
69
+ time_range_min?: number;
70
+ time_range_max?: number;
71
+ time_current?: number;
72
+ }
15
73
  /**
16
74
  * Ability element type
17
75
  */
@@ -22,22 +80,14 @@ interface Ability extends BaseElement {
22
80
  range?: string;
23
81
  challenges?: string;
24
82
  prevalence?: string;
25
- /** Links to Construct */
26
- tradition?: string;
27
- /** Links to Phenomenon */
28
- source?: string;
29
- /** Links to Location */
30
- locus?: string;
31
- /** Links to Phenomenon */
32
- effects?: string[];
33
- /** Links to Trait */
34
- talents?: string[];
35
- /** Links to Construct */
36
- requisites?: string[];
37
- /** Links to Object */
38
- instruments?: string[];
39
- /** Links to Construct */
40
- systems?: string[];
83
+ tradition?: ElementId<ElementType.Construct>;
84
+ source?: ElementId<ElementType.Phenomenon>;
85
+ locus?: ElementId<ElementType.Location>;
86
+ effects?: ElementIds<ElementType.Phenomenon>;
87
+ talents?: ElementIds<ElementType.Trait>;
88
+ requisites?: ElementIds<ElementType.Construct>;
89
+ instruments?: ElementIds<ElementType.Object>;
90
+ systems?: ElementIds<ElementType.Construct>;
41
91
  }
42
92
  /**
43
93
  * Object element type
@@ -46,26 +96,17 @@ interface Object$1 extends BaseElement {
46
96
  aesthetics?: string;
47
97
  weight?: string;
48
98
  amount?: string;
49
- /** Links to Object */
50
- parent_object?: string;
99
+ parent_object?: ElementId<ElementType.Object>;
51
100
  utility?: string;
52
101
  origins?: string;
53
- /** Links to Location */
54
- location?: string;
55
- /** Links to Language */
56
- language?: string;
57
- /** Links to Construct */
58
- materials?: string[];
59
- /** Links to Construct */
60
- technology?: string[];
61
- /** Links to Phenomenon */
62
- effects?: string[];
63
- /** Links to Ability */
64
- abilities?: string[];
65
- /** Links to Construct */
66
- consumes?: string[];
67
- /** Links to Trait */
68
- affinities?: string[];
102
+ location?: ElementId<ElementType.Location>;
103
+ language?: ElementId<ElementType.Language>;
104
+ materials?: ElementIds<ElementType.Construct>;
105
+ technology?: ElementIds<ElementType.Construct>;
106
+ effects?: ElementIds<ElementType.Phenomenon>;
107
+ abilities?: ElementIds<ElementType.Ability>;
108
+ consumes?: ElementIds<ElementType.Construct>;
109
+ affinities?: ElementIds<ElementType.Trait>;
69
110
  }
70
111
  /**
71
112
  * Character element type
@@ -78,11 +119,9 @@ interface Character extends BaseElement {
78
119
  background?: string;
79
120
  motivations?: string;
80
121
  birth_date?: string;
81
- /** Links to Location */
82
- birthplace?: string;
122
+ birthplace?: ElementId<ElementType.Location>;
83
123
  reputation?: string;
84
- /** Links to Location */
85
- location?: string;
124
+ location?: ElementId<ElementType.Location>;
86
125
  charisma?: string;
87
126
  coercion?: string;
88
127
  competence?: string;
@@ -97,24 +136,15 @@ interface Character extends BaseElement {
97
136
  INT?: string;
98
137
  WIS?: string;
99
138
  CHA?: string;
100
- /** Links to Species */
101
- species?: string[];
102
- /** Links to Trait */
103
- traits?: string[];
104
- /** Links to Ability */
105
- abilities?: string[];
106
- /** Links to Language */
107
- languages?: string[];
108
- /** Links to Object */
109
- objects?: string[];
110
- /** Links to Institution */
111
- institutions?: string[];
112
- /** Links to Family */
113
- family?: string[];
114
- /** Links to Character */
115
- friends?: string[];
116
- /** Links to Character */
117
- rivals?: string[];
139
+ species?: ElementIds<ElementType.Species>;
140
+ traits?: ElementIds<ElementType.Trait>;
141
+ abilities?: ElementIds<ElementType.Ability>;
142
+ languages?: ElementIds<ElementType.Language>;
143
+ objects?: ElementIds<ElementType.Object>;
144
+ institutions?: ElementIds<ElementType.Institution>;
145
+ family?: ElementIds<ElementType.Family>;
146
+ friends?: ElementIds<ElementType.Character>;
147
+ rivals?: ElementIds<ElementType.Character>;
118
148
  }
119
149
  /**
120
150
  * Collective element type
@@ -123,25 +153,17 @@ interface Collective extends BaseElement {
123
153
  composition?: string;
124
154
  count?: string;
125
155
  formation_date?: string;
126
- /** Links to Institution */
127
- operator?: string;
156
+ operator?: ElementId<ElementType.Institution>;
128
157
  activity?: string;
129
158
  disposition?: string;
130
159
  state?: string;
131
- /** Links to Construct */
132
- equipment?: string[];
133
- /** Links to Ability */
134
- abilities?: string[];
135
- /** Links to Construct */
136
- symbolism?: string[];
137
- /** Links to Species */
138
- species?: string[];
139
- /** Links to Character */
140
- characters?: string[];
141
- /** Links to Creature */
142
- creatures?: string[];
143
- /** Links to Phenomenon */
144
- phenomena?: string[];
160
+ equipment?: ElementIds<ElementType.Construct>;
161
+ abilities?: ElementIds<ElementType.Ability>;
162
+ symbolism?: ElementIds<ElementType.Construct>;
163
+ species?: ElementIds<ElementType.Species>;
164
+ characters?: ElementIds<ElementType.Character>;
165
+ creatures?: ElementIds<ElementType.Creature>;
166
+ phenomena?: ElementIds<ElementType.Phenomenon>;
145
167
  }
146
168
  /**
147
169
  * Construct element type
@@ -153,46 +175,26 @@ interface Construct extends BaseElement {
153
175
  reach?: string;
154
176
  start_date?: string;
155
177
  end_date?: string;
156
- /** Links to Character */
157
- founder?: string;
158
- /** Links to Institution */
159
- custodian?: string;
160
- /** Links to Character */
161
- characters?: string[];
162
- /** Links to Object */
163
- objects?: string[];
164
- /** Links to Location */
165
- locations?: string[];
166
- /** Links to Species */
167
- species?: string[];
168
- /** Links to Creature */
169
- creatures?: string[];
170
- /** Links to Institution */
171
- institutions?: string[];
172
- /** Links to Trait */
173
- traits?: string[];
174
- /** Links to Collective */
175
- collectives?: string[];
176
- /** Links to Zone */
177
- zones?: string[];
178
- /** Links to Ability */
179
- abilities?: string[];
180
- /** Links to Phenomenon */
181
- phenomena?: string[];
182
- /** Links to Language */
183
- languages?: string[];
184
- /** Links to Family */
185
- families?: string[];
186
- /** Links to Relation */
187
- relations?: string[];
188
- /** Links to Title */
189
- titles?: string[];
190
- /** Links to Construct */
191
- constructs?: string[];
192
- /** Links to Event */
193
- events?: string[];
194
- /** Links to Narrative */
195
- narratives?: string[];
178
+ founder?: ElementId<ElementType.Character>;
179
+ custodian?: ElementId<ElementType.Institution>;
180
+ characters?: ElementIds<ElementType.Character>;
181
+ objects?: ElementIds<ElementType.Object>;
182
+ locations?: ElementIds<ElementType.Location>;
183
+ species?: ElementIds<ElementType.Species>;
184
+ creatures?: ElementIds<ElementType.Creature>;
185
+ institutions?: ElementIds<ElementType.Institution>;
186
+ traits?: ElementIds<ElementType.Trait>;
187
+ collectives?: ElementIds<ElementType.Collective>;
188
+ zones?: ElementIds<ElementType.Zone>;
189
+ abilities?: ElementIds<ElementType.Ability>;
190
+ phenomena?: ElementIds<ElementType.Phenomenon>;
191
+ languages?: ElementIds<ElementType.Language>;
192
+ families?: ElementIds<ElementType.Family>;
193
+ relations?: ElementIds<ElementType.Relation>;
194
+ titles?: ElementIds<ElementType.Title>;
195
+ constructs?: ElementIds<ElementType.Construct>;
196
+ events?: ElementIds<ElementType.Event>;
197
+ narratives?: ElementIds<ElementType.Narrative>;
196
198
  }
197
199
  /**
198
200
  * Creature element type
@@ -205,24 +207,17 @@ interface Creature extends BaseElement {
205
207
  demeanor?: string;
206
208
  status?: string;
207
209
  birth_date?: string;
208
- /** Links to Location */
209
- location?: string;
210
- /** Links to Zone */
211
- zone?: string;
210
+ location?: ElementId<ElementType.Location>;
211
+ zone?: ElementId<ElementType.Zone>;
212
212
  challenge_rating?: string;
213
213
  hit_points?: string;
214
214
  armor_class?: string;
215
215
  speed?: string;
216
- /** Links to Species */
217
- species?: string[];
218
- /** Links to Trait */
219
- traits?: string[];
220
- /** Links to Ability */
221
- abilities?: string[];
222
- /** Links to Language */
223
- languages?: string[];
224
- /** Links to Ability */
225
- actions?: string[];
216
+ species?: ElementIds<ElementType.Species>;
217
+ traits?: ElementIds<ElementType.Trait>;
218
+ abilities?: ElementIds<ElementType.Ability>;
219
+ languages?: ElementIds<ElementType.Language>;
220
+ actions?: ElementIds<ElementType.Ability>;
226
221
  }
227
222
  /**
228
223
  * Event element type
@@ -233,40 +228,23 @@ interface Event extends BaseElement {
233
228
  consequences?: string;
234
229
  start_date?: string;
235
230
  end_date?: string;
236
- /** Links to Event */
237
- triggers?: string[];
238
- /** Links to Character */
239
- characters?: string[];
240
- /** Links to Object */
241
- objects?: string[];
242
- /** Links to Location */
243
- locations?: string[];
244
- /** Links to Species */
245
- species?: string[];
246
- /** Links to Creature */
247
- creatures?: string[];
248
- /** Links to Institution */
249
- institutions?: string[];
250
- /** Links to Trait */
251
- traits?: string[];
252
- /** Links to Collective */
253
- collectives?: string[];
254
- /** Links to Zone */
255
- zones?: string[];
256
- /** Links to Ability */
257
- abilities?: string[];
258
- /** Links to Phenomenon */
259
- phenomena?: string[];
260
- /** Links to Language */
261
- languages?: string[];
262
- /** Links to Family */
263
- families?: string[];
264
- /** Links to Relation */
265
- relations?: string[];
266
- /** Links to Title */
267
- titles?: string[];
268
- /** Links to Construct */
269
- constructs?: string[];
231
+ triggers?: ElementIds<ElementType.Event>;
232
+ characters?: ElementIds<ElementType.Character>;
233
+ objects?: ElementIds<ElementType.Object>;
234
+ locations?: ElementIds<ElementType.Location>;
235
+ species?: ElementIds<ElementType.Species>;
236
+ creatures?: ElementIds<ElementType.Creature>;
237
+ institutions?: ElementIds<ElementType.Institution>;
238
+ traits?: ElementIds<ElementType.Trait>;
239
+ collectives?: ElementIds<ElementType.Collective>;
240
+ zones?: ElementIds<ElementType.Zone>;
241
+ abilities?: ElementIds<ElementType.Ability>;
242
+ phenomena?: ElementIds<ElementType.Phenomenon>;
243
+ languages?: ElementIds<ElementType.Language>;
244
+ families?: ElementIds<ElementType.Family>;
245
+ relations?: ElementIds<ElementType.Relation>;
246
+ titles?: ElementIds<ElementType.Title>;
247
+ constructs?: ElementIds<ElementType.Construct>;
270
248
  }
271
249
  /**
272
250
  * Family element type
@@ -275,24 +253,15 @@ interface Family extends BaseElement {
275
253
  spirit?: string;
276
254
  history?: string;
277
255
  reputation?: string;
278
- /** Links to Construct */
279
- traditions?: string[];
280
- /** Links to Trait */
281
- traits?: string[];
282
- /** Links to Ability */
283
- abilities?: string[];
284
- /** Links to Language */
285
- languages?: string[];
286
- /** Links to Character */
287
- ancestors?: string[];
288
- /** Links to Location */
289
- estates?: string[];
290
- /** Links to Institution */
291
- governs?: string[];
292
- /** Links to Object */
293
- heirlooms?: string[];
294
- /** Links to Creature */
295
- creatures?: string[];
256
+ traditions?: ElementIds<ElementType.Construct>;
257
+ traits?: ElementIds<ElementType.Trait>;
258
+ abilities?: ElementIds<ElementType.Ability>;
259
+ languages?: ElementIds<ElementType.Language>;
260
+ ancestors?: ElementIds<ElementType.Character>;
261
+ estates?: ElementIds<ElementType.Location>;
262
+ governs?: ElementIds<ElementType.Institution>;
263
+ heirlooms?: ElementIds<ElementType.Object>;
264
+ creatures?: ElementIds<ElementType.Creature>;
296
265
  }
297
266
  /**
298
267
  * Institution element type
@@ -300,21 +269,14 @@ interface Family extends BaseElement {
300
269
  interface Institution extends BaseElement {
301
270
  doctrine?: string;
302
271
  founding_date?: string;
303
- /** Links to Institution */
304
- parent_institution?: string;
272
+ parent_institution?: ElementId<ElementType.Institution>;
305
273
  status?: string;
306
- /** Links to Zone */
307
- zones?: string[];
308
- /** Links to Object */
309
- objects?: string[];
310
- /** Links to Creature */
311
- creatures?: string[];
312
- /** Links to Institution */
313
- allies?: string[];
314
- /** Links to Institution */
315
- adversaries?: string[];
316
- /** Links to Construct */
317
- constructs?: string[];
274
+ zones?: ElementIds<ElementType.Zone>;
275
+ objects?: ElementIds<ElementType.Object>;
276
+ creatures?: ElementIds<ElementType.Creature>;
277
+ allies?: ElementIds<ElementType.Institution>;
278
+ adversaries?: ElementIds<ElementType.Institution>;
279
+ constructs?: ElementIds<ElementType.Construct>;
318
280
  }
319
281
  /**
320
282
  * Language element type
@@ -324,13 +286,10 @@ interface Language extends BaseElement {
324
286
  grammar?: string;
325
287
  lexicon?: string;
326
288
  writing?: string;
327
- /** Links to Construct */
328
- classification?: string;
289
+ classification?: ElementId<ElementType.Construct>;
329
290
  status?: string;
330
- /** Links to Location */
331
- spread?: string[];
332
- /** Links to Language */
333
- dialects?: string[];
291
+ spread?: ElementIds<ElementType.Location>;
292
+ dialects?: ElementIds<ElementType.Language>;
334
293
  }
335
294
  /**
336
295
  * Law element type
@@ -339,22 +298,14 @@ interface Law extends BaseElement {
339
298
  declaration?: string;
340
299
  purpose?: string;
341
300
  date?: string;
342
- /** Links to Law */
343
- parent_law?: string;
344
- /** Links to Institution */
345
- author?: string;
346
- /** Links to Construct */
347
- penalties?: string[];
348
- /** Links to Location */
349
- locations?: string[];
350
- /** Links to Zone */
351
- zones?: string[];
352
- /** Links to Construct */
353
- prohibitions?: string[];
354
- /** Links to Title */
355
- adjudicators?: string[];
356
- /** Links to Title */
357
- enforcers?: string[];
301
+ parent_law?: ElementId<ElementType.Law>;
302
+ author?: ElementId<ElementType.Institution>;
303
+ penalties?: ElementIds<ElementType.Construct>;
304
+ locations?: ElementIds<ElementType.Location>;
305
+ zones?: ElementIds<ElementType.Zone>;
306
+ prohibitions?: ElementIds<ElementType.Construct>;
307
+ adjudicators?: ElementIds<ElementType.Title>;
308
+ enforcers?: ElementIds<ElementType.Title>;
358
309
  }
359
310
  /**
360
311
  * Location element type
@@ -363,56 +314,34 @@ interface Location extends BaseElement {
363
314
  form?: string;
364
315
  function?: string;
365
316
  founding_date?: string;
366
- /** Links to Location */
367
- parent_location?: string;
317
+ parent_location?: ElementId<ElementType.Location>;
368
318
  political_climate?: string;
369
- /** Links to Institution */
370
- primary_power?: string;
371
- /** Links to Title */
372
- governing_title?: string;
373
- /** Links to Zone */
374
- zone?: string;
375
- /** Links to Location */
376
- rival?: string;
377
- /** Links to Location */
378
- partner?: string;
319
+ primary_power?: ElementId<ElementType.Institution>;
320
+ governing_title?: ElementId<ElementType.Title>;
321
+ zone?: ElementId<ElementType.Zone>;
322
+ rival?: ElementId<ElementType.Location>;
323
+ partner?: ElementId<ElementType.Location>;
379
324
  customs?: string;
380
325
  infrastructure?: string;
381
326
  architecture?: string;
382
327
  defensibility?: string;
383
328
  elevation?: string;
384
- /** Links to Collective */
385
- populations?: string[];
386
- /** Links to Institution */
387
- secondary_powers?: string[];
388
- /** Links to Character */
389
- founders?: string[];
390
- /** Links to Construct */
391
- cults?: string[];
392
- /** Links to Species */
393
- delicacies?: string[];
394
- /** Links to Construct */
395
- extraction_methods?: string[];
396
- /** Links to Construct */
397
- extraction_goods?: string[];
398
- /** Links to Construct */
399
- industry_methods?: string[];
400
- /** Links to Construct */
401
- industry_goods?: string[];
402
- /** Links to Location */
403
- extraction_markets?: string[];
404
- /** Links to Location */
405
- industry_markets?: string[];
406
- /** Links to Construct */
407
- currencies?: string[];
408
- /** Links to Object */
409
- buildings?: string[];
410
- /** Links to Construct */
411
- building_methods?: string[];
412
- /** Links to Construct */
413
- fighters?: string[];
414
- /** Links to Object */
415
- defensive_objects?: string[];
329
+ populations?: ElementIds<ElementType.Collective>;
330
+ secondary_powers?: ElementIds<ElementType.Institution>;
331
+ founders?: ElementIds<ElementType.Character>;
332
+ cults?: ElementIds<ElementType.Construct>;
333
+ delicacies?: ElementIds<ElementType.Species>;
334
+ extraction_methods?: ElementIds<ElementType.Construct>;
335
+ extraction_goods?: ElementIds<ElementType.Construct>;
336
+ industry_methods?: ElementIds<ElementType.Construct>;
337
+ industry_goods?: ElementIds<ElementType.Construct>;
338
+ extraction_markets?: ElementIds<ElementType.Location>;
339
+ industry_markets?: ElementIds<ElementType.Location>;
340
+ currencies?: ElementIds<ElementType.Construct>;
341
+ buildings?: ElementIds<ElementType.Object>;
342
+ building_methods?: ElementIds<ElementType.Construct>;
343
+ fighters?: ElementIds<ElementType.Construct>;
344
+ defensive_objects?: ElementIds<ElementType.Object>;
416
345
  }
417
346
  /**
418
347
  * Phenomenon element type
@@ -422,18 +351,12 @@ interface Phenomenon extends BaseElement {
422
351
  effects?: string;
423
352
  duration?: string;
424
353
  mythology?: string;
425
- /** Links to Phenomenon */
426
- system?: string;
427
- /** Links to Object */
428
- catalysts?: string[];
429
- /** Links to Ability */
430
- empowerments?: string[];
431
- /** Links to Construct */
432
- triggers?: string[];
433
- /** Links to Character */
434
- wielders?: string[];
435
- /** Links to Location */
436
- environments?: string[];
354
+ system?: ElementId<ElementType.Phenomenon>;
355
+ catalysts?: ElementIds<ElementType.Object>;
356
+ empowerments?: ElementIds<ElementType.Ability>;
357
+ triggers?: ElementIds<ElementType.Construct>;
358
+ wielders?: ElementIds<ElementType.Character>;
359
+ environments?: ElementIds<ElementType.Location>;
437
360
  }
438
361
  /**
439
362
  * Relation element type
@@ -443,42 +366,24 @@ interface Relation extends BaseElement {
443
366
  start_date?: string;
444
367
  end_date?: string;
445
368
  intensity?: string;
446
- /** Links to Character */
447
- actor?: string;
448
- /** Links to Character */
449
- characters?: string[];
450
- /** Links to Object */
451
- objects?: string[];
452
- /** Links to Location */
453
- locations?: string[];
454
- /** Links to Species */
455
- species?: string[];
456
- /** Links to Creature */
457
- creatures?: string[];
458
- /** Links to Institution */
459
- institutions?: string[];
460
- /** Links to Trait */
461
- traits?: string[];
462
- /** Links to Collective */
463
- collectives?: string[];
464
- /** Links to Zone */
465
- zones?: string[];
466
- /** Links to Ability */
467
- abilities?: string[];
468
- /** Links to Phenomenon */
469
- phenomena?: string[];
470
- /** Links to Language */
471
- languages?: string[];
472
- /** Links to Family */
473
- families?: string[];
474
- /** Links to Title */
475
- titles?: string[];
476
- /** Links to Construct */
477
- constructs?: string[];
478
- /** Links to Event */
479
- events?: string[];
480
- /** Links to Narrative */
481
- narratives?: string[];
369
+ actor?: ElementId<ElementType.Character>;
370
+ characters?: ElementIds<ElementType.Character>;
371
+ objects?: ElementIds<ElementType.Object>;
372
+ locations?: ElementIds<ElementType.Location>;
373
+ species?: ElementIds<ElementType.Species>;
374
+ creatures?: ElementIds<ElementType.Creature>;
375
+ institutions?: ElementIds<ElementType.Institution>;
376
+ traits?: ElementIds<ElementType.Trait>;
377
+ collectives?: ElementIds<ElementType.Collective>;
378
+ zones?: ElementIds<ElementType.Zone>;
379
+ abilities?: ElementIds<ElementType.Ability>;
380
+ phenomena?: ElementIds<ElementType.Phenomenon>;
381
+ languages?: ElementIds<ElementType.Language>;
382
+ families?: ElementIds<ElementType.Family>;
383
+ titles?: ElementIds<ElementType.Title>;
384
+ constructs?: ElementIds<ElementType.Construct>;
385
+ events?: ElementIds<ElementType.Event>;
386
+ narratives?: ElementIds<ElementType.Narrative>;
482
387
  }
483
388
  /**
484
389
  * Species element type
@@ -493,22 +398,14 @@ interface Species extends BaseElement {
493
398
  communication?: string;
494
399
  aggression?: string;
495
400
  role?: string;
496
- /** Links to Species */
497
- parent_species?: string;
498
- /** Links to Species */
499
- nourishment?: string[];
500
- /** Links to Construct */
501
- reproduction?: string[];
502
- /** Links to Ability */
503
- adaptations?: string[];
504
- /** Links to Trait */
505
- traits?: string[];
506
- /** Links to Location */
507
- locations?: string[];
508
- /** Links to Zone */
509
- zones?: string[];
510
- /** Links to Phenomenon */
511
- affinities?: string[];
401
+ parent_species?: ElementId<ElementType.Species>;
402
+ nourishment?: ElementIds<ElementType.Species>;
403
+ reproduction?: ElementIds<ElementType.Construct>;
404
+ adaptations?: ElementIds<ElementType.Ability>;
405
+ traits?: ElementIds<ElementType.Trait>;
406
+ locations?: ElementIds<ElementType.Location>;
407
+ zones?: ElementIds<ElementType.Zone>;
408
+ affinities?: ElementIds<ElementType.Phenomenon>;
512
409
  }
513
410
  /**
514
411
  * Zone element type
@@ -518,16 +415,11 @@ interface Zone extends BaseElement {
518
415
  start_date?: string;
519
416
  end_date?: string;
520
417
  context?: string;
521
- /** Links to Phenomenon */
522
- phenomena?: string[];
523
- /** Links to Zone */
524
- linked_zones?: string[];
525
- /** Links to Collective */
526
- populations?: string[];
527
- /** Links to Title */
528
- titles?: string[];
529
- /** Links to Construct */
530
- principles?: string[];
418
+ phenomena?: ElementIds<ElementType.Phenomenon>;
419
+ linked_zones?: ElementIds<ElementType.Zone>;
420
+ populations?: ElementIds<ElementType.Collective>;
421
+ titles?: ElementIds<ElementType.Title>;
422
+ principles?: ElementIds<ElementType.Construct>;
531
423
  }
532
424
  /**
533
425
  * Title element type
@@ -537,44 +429,26 @@ interface Title extends BaseElement {
537
429
  eligibility?: string;
538
430
  grant_date?: string;
539
431
  revoke_date?: string;
540
- /** Links to Institution */
541
- issuer?: string;
542
- /** Links to Institution */
543
- body?: string;
544
- /** Links to Title */
545
- superior_title?: string;
432
+ issuer?: ElementId<ElementType.Institution>;
433
+ body?: ElementId<ElementType.Institution>;
434
+ superior_title?: ElementId<ElementType.Title>;
546
435
  status?: string;
547
436
  history?: string;
548
- /** Links to Character */
549
- holders?: string[];
550
- /** Links to Object */
551
- symbols?: string[];
552
- /** Links to Character */
553
- characters?: string[];
554
- /** Links to Institution */
555
- institutions?: string[];
556
- /** Links to Family */
557
- families?: string[];
558
- /** Links to Zone */
559
- zones?: string[];
560
- /** Links to Location */
561
- locations?: string[];
562
- /** Links to Object */
563
- objects?: string[];
564
- /** Links to Construct */
565
- constructs?: string[];
566
- /** Links to Law */
567
- laws?: string[];
568
- /** Links to Collective */
569
- collectives?: string[];
570
- /** Links to Creature */
571
- creatures?: string[];
572
- /** Links to Phenomenon */
573
- phenomena?: string[];
574
- /** Links to Species */
575
- species?: string[];
576
- /** Links to Language */
577
- languages?: string[];
437
+ holders?: ElementIds<ElementType.Character>;
438
+ symbols?: ElementIds<ElementType.Object>;
439
+ characters?: ElementIds<ElementType.Character>;
440
+ institutions?: ElementIds<ElementType.Institution>;
441
+ families?: ElementIds<ElementType.Family>;
442
+ zones?: ElementIds<ElementType.Zone>;
443
+ locations?: ElementIds<ElementType.Location>;
444
+ objects?: ElementIds<ElementType.Object>;
445
+ constructs?: ElementIds<ElementType.Construct>;
446
+ laws?: ElementIds<ElementType.Law>;
447
+ collectives?: ElementIds<ElementType.Collective>;
448
+ creatures?: ElementIds<ElementType.Creature>;
449
+ phenomena?: ElementIds<ElementType.Phenomenon>;
450
+ species?: ElementIds<ElementType.Species>;
451
+ languages?: ElementIds<ElementType.Language>;
578
452
  }
579
453
  /**
580
454
  * Trait element type
@@ -592,10 +466,8 @@ interface Trait extends BaseElement {
592
466
  creativity?: string;
593
467
  courage?: string;
594
468
  significance?: string;
595
- /** Links to Trait */
596
- anti_trait?: string;
597
- /** Links to Ability */
598
- empowered_abilities?: string[];
469
+ anti_trait?: ElementId<ElementType.Trait>;
470
+ empowered_abilities?: ElementIds<ElementType.Ability>;
599
471
  }
600
472
  /**
601
473
  * Narrative element type
@@ -606,52 +478,29 @@ interface Narrative extends BaseElement {
606
478
  start_date?: string;
607
479
  end_date?: string;
608
480
  order?: string;
609
- /** Links to Narrative */
610
- parent_narrative?: string;
611
- /** Links to Character */
612
- protagonist?: string;
613
- /** Links to Character */
614
- antagonist?: string;
615
- /** Links to Character */
616
- narrator?: string;
617
- /** Links to Institution */
618
- conservator?: string;
619
- /** Links to Event */
620
- events?: string[];
621
- /** Links to Character */
622
- characters?: string[];
623
- /** Links to Object */
624
- objects?: string[];
625
- /** Links to Location */
626
- locations?: string[];
627
- /** Links to Species */
628
- species?: string[];
629
- /** Links to Creature */
630
- creatures?: string[];
631
- /** Links to Institution */
632
- institutions?: string[];
633
- /** Links to Trait */
634
- traits?: string[];
635
- /** Links to Collective */
636
- collectives?: string[];
637
- /** Links to Zone */
638
- zones?: string[];
639
- /** Links to Ability */
640
- abilities?: string[];
641
- /** Links to Phenomenon */
642
- phenomena?: string[];
643
- /** Links to Language */
644
- languages?: string[];
645
- /** Links to Family */
646
- families?: string[];
647
- /** Links to Relation */
648
- relations?: string[];
649
- /** Links to Title */
650
- titles?: string[];
651
- /** Links to Construct */
652
- constructs?: string[];
653
- /** Links to Law */
654
- laws?: string[];
481
+ parent_narrative?: ElementId<ElementType.Narrative>;
482
+ protagonist?: ElementId<ElementType.Character>;
483
+ antagonist?: ElementId<ElementType.Character>;
484
+ narrator?: ElementId<ElementType.Character>;
485
+ conservator?: ElementId<ElementType.Institution>;
486
+ events?: ElementIds<ElementType.Event>;
487
+ characters?: ElementIds<ElementType.Character>;
488
+ objects?: ElementIds<ElementType.Object>;
489
+ locations?: ElementIds<ElementType.Location>;
490
+ species?: ElementIds<ElementType.Species>;
491
+ creatures?: ElementIds<ElementType.Creature>;
492
+ institutions?: ElementIds<ElementType.Institution>;
493
+ traits?: ElementIds<ElementType.Trait>;
494
+ collectives?: ElementIds<ElementType.Collective>;
495
+ zones?: ElementIds<ElementType.Zone>;
496
+ abilities?: ElementIds<ElementType.Ability>;
497
+ phenomena?: ElementIds<ElementType.Phenomenon>;
498
+ languages?: ElementIds<ElementType.Language>;
499
+ families?: ElementIds<ElementType.Family>;
500
+ relations?: ElementIds<ElementType.Relation>;
501
+ titles?: ElementIds<ElementType.Title>;
502
+ constructs?: ElementIds<ElementType.Construct>;
503
+ laws?: ElementIds<ElementType.Law>;
655
504
  }
656
505
  /**
657
506
  * Map element type
@@ -662,19 +511,15 @@ interface Map extends BaseElement {
662
511
  width?: string;
663
512
  height?: string;
664
513
  depth?: string;
665
- /** Links to Map */
666
- parent_map?: string;
667
- /** Links to Location */
668
- location?: string;
514
+ parent_map?: ElementId<ElementType.Map>;
515
+ location?: ElementId<ElementType.Location>;
669
516
  }
670
517
  /**
671
518
  * Marker element type
672
519
  */
673
520
  interface Marker extends BaseElement {
674
- /** Links to Map */
675
- map?: string;
676
- /** Links to Zone */
677
- zone?: string;
521
+ map?: ElementId<ElementType.Map>;
522
+ zone?: ElementId<ElementType.Zone>;
678
523
  x?: string;
679
524
  y?: string;
680
525
  z?: string;
@@ -683,10 +528,9 @@ interface Marker extends BaseElement {
683
528
  * Pin element type
684
529
  */
685
530
  interface Pin extends BaseElement {
686
- /** Links to Map */
687
- map?: string;
688
- /** Links to ContentType */
689
- element_type?: string;
531
+ map?: ElementId<ElementType.Map>;
532
+ element_type?: ElementType;
533
+ element_id?: AnyElementId;
690
534
  x?: string;
691
535
  y?: string;
692
536
  z?: string;
@@ -949,9 +793,9 @@ interface MarkerInput extends Omit<Marker, 'map' | 'zone'> {
949
793
  map_id?: string;
950
794
  zone_id?: string;
951
795
  }
952
- interface PinInput extends Omit<Pin, 'map' | 'element_type'> {
796
+ interface PinInput extends Omit<Pin, 'map' | 'element_id'> {
953
797
  map_id?: string;
954
- element_type_id?: string;
798
+ element_id?: string;
955
799
  }
956
800
  /**
957
801
  * All available element types in OnlyWorlds
@@ -980,6 +824,293 @@ declare enum ElementType {
980
824
  Trait = "trait",
981
825
  Zone = "zone"
982
826
  }
827
+ /**
828
+ * Runtime metadata for field relationships - enables tooling and dynamic processing
829
+ * Maps element types to their field relationships for runtime introspection
830
+ */
831
+ declare const FIELD_MAPPINGS: {
832
+ readonly ability: {
833
+ readonly tradition: "construct";
834
+ readonly source: "phenomenon";
835
+ readonly locus: "location";
836
+ readonly effects: "phenomenon";
837
+ readonly talents: "trait";
838
+ readonly requisites: "construct";
839
+ readonly instruments: "object";
840
+ readonly systems: "construct";
841
+ };
842
+ readonly character: {
843
+ readonly birthplace: "location";
844
+ readonly location: "location";
845
+ readonly species: "species";
846
+ readonly traits: "trait";
847
+ readonly abilities: "ability";
848
+ readonly languages: "language";
849
+ readonly objects: "object";
850
+ readonly institutions: "institution";
851
+ readonly family: "family";
852
+ readonly friends: "character";
853
+ readonly rivals: "character";
854
+ };
855
+ readonly collective: {
856
+ readonly operator: "institution";
857
+ readonly equipment: "construct";
858
+ readonly abilities: "ability";
859
+ readonly symbolism: "construct";
860
+ readonly species: "species";
861
+ readonly characters: "character";
862
+ readonly creatures: "creature";
863
+ readonly phenomena: "phenomenon";
864
+ };
865
+ readonly construct: {
866
+ readonly founder: "character";
867
+ readonly custodian: "institution";
868
+ readonly characters: "character";
869
+ readonly objects: "object";
870
+ readonly locations: "location";
871
+ readonly species: "species";
872
+ readonly creatures: "creature";
873
+ readonly institutions: "institution";
874
+ readonly traits: "trait";
875
+ readonly collectives: "collective";
876
+ readonly zones: "zone";
877
+ readonly abilities: "ability";
878
+ readonly phenomena: "phenomenon";
879
+ readonly languages: "language";
880
+ readonly families: "family";
881
+ readonly relations: "relation";
882
+ readonly titles: "title";
883
+ readonly constructs: "construct";
884
+ readonly events: "event";
885
+ readonly narratives: "narrative";
886
+ };
887
+ readonly creature: {
888
+ readonly location: "location";
889
+ readonly zone: "zone";
890
+ readonly species: "species";
891
+ readonly traits: "trait";
892
+ readonly abilities: "ability";
893
+ readonly languages: "language";
894
+ readonly actions: "ability";
895
+ };
896
+ readonly event: {
897
+ readonly triggers: "event";
898
+ readonly characters: "character";
899
+ readonly objects: "object";
900
+ readonly locations: "location";
901
+ readonly species: "species";
902
+ readonly creatures: "creature";
903
+ readonly institutions: "institution";
904
+ readonly traits: "trait";
905
+ readonly collectives: "collective";
906
+ readonly zones: "zone";
907
+ readonly abilities: "ability";
908
+ readonly phenomena: "phenomenon";
909
+ readonly languages: "language";
910
+ readonly families: "family";
911
+ readonly relations: "relation";
912
+ readonly titles: "title";
913
+ readonly constructs: "construct";
914
+ };
915
+ readonly family: {
916
+ readonly traditions: "construct";
917
+ readonly traits: "trait";
918
+ readonly abilities: "ability";
919
+ readonly languages: "language";
920
+ readonly ancestors: "character";
921
+ readonly estates: "location";
922
+ readonly governs: "institution";
923
+ readonly heirlooms: "object";
924
+ readonly creatures: "creature";
925
+ };
926
+ readonly institution: {
927
+ readonly parent_institution: "institution";
928
+ readonly zones: "zone";
929
+ readonly objects: "object";
930
+ readonly creatures: "creature";
931
+ readonly allies: "institution";
932
+ readonly adversaries: "institution";
933
+ readonly constructs: "construct";
934
+ };
935
+ readonly language: {
936
+ readonly classification: "construct";
937
+ readonly spread: "location";
938
+ readonly dialects: "language";
939
+ };
940
+ readonly law: {
941
+ readonly parent_law: "law";
942
+ readonly author: "institution";
943
+ readonly penalties: "construct";
944
+ readonly locations: "location";
945
+ readonly zones: "zone";
946
+ readonly prohibitions: "construct";
947
+ readonly adjudicators: "title";
948
+ readonly enforcers: "title";
949
+ };
950
+ readonly location: {
951
+ readonly parent_location: "location";
952
+ readonly primary_power: "institution";
953
+ readonly governing_title: "title";
954
+ readonly zone: "zone";
955
+ readonly rival: "location";
956
+ readonly partner: "location";
957
+ readonly populations: "collective";
958
+ readonly secondary_powers: "institution";
959
+ readonly founders: "character";
960
+ readonly cults: "construct";
961
+ readonly delicacies: "species";
962
+ readonly extraction_methods: "construct";
963
+ readonly extraction_goods: "construct";
964
+ readonly industry_methods: "construct";
965
+ readonly industry_goods: "construct";
966
+ readonly extraction_markets: "location";
967
+ readonly industry_markets: "location";
968
+ readonly currencies: "construct";
969
+ readonly buildings: "object";
970
+ readonly building_methods: "construct";
971
+ readonly fighters: "construct";
972
+ readonly defensive_objects: "object";
973
+ };
974
+ readonly map: {
975
+ readonly parent_map: "map";
976
+ readonly location: "location";
977
+ };
978
+ readonly marker: {
979
+ readonly map: "map";
980
+ readonly zone: "zone";
981
+ };
982
+ readonly narrative: {
983
+ readonly parent_narrative: "narrative";
984
+ readonly protagonist: "character";
985
+ readonly antagonist: "character";
986
+ readonly narrator: "character";
987
+ readonly conservator: "institution";
988
+ readonly events: "event";
989
+ readonly characters: "character";
990
+ readonly objects: "object";
991
+ readonly locations: "location";
992
+ readonly species: "species";
993
+ readonly creatures: "creature";
994
+ readonly institutions: "institution";
995
+ readonly traits: "trait";
996
+ readonly collectives: "collective";
997
+ readonly zones: "zone";
998
+ readonly abilities: "ability";
999
+ readonly phenomena: "phenomenon";
1000
+ readonly languages: "language";
1001
+ readonly families: "family";
1002
+ readonly relations: "relation";
1003
+ readonly titles: "title";
1004
+ readonly constructs: "construct";
1005
+ readonly laws: "law";
1006
+ };
1007
+ readonly object: {
1008
+ readonly parent_object: "object";
1009
+ readonly location: "location";
1010
+ readonly language: "language";
1011
+ readonly materials: "construct";
1012
+ readonly technology: "construct";
1013
+ readonly effects: "phenomenon";
1014
+ readonly abilities: "ability";
1015
+ readonly consumes: "construct";
1016
+ readonly affinities: "trait";
1017
+ };
1018
+ readonly phenomenon: {
1019
+ readonly system: "phenomenon";
1020
+ readonly catalysts: "object";
1021
+ readonly empowerments: "ability";
1022
+ readonly triggers: "construct";
1023
+ readonly wielders: "character";
1024
+ readonly environments: "location";
1025
+ };
1026
+ readonly pin: {
1027
+ readonly map: "map";
1028
+ readonly element_id: "any_element";
1029
+ };
1030
+ readonly relation: {
1031
+ readonly actor: "character";
1032
+ readonly characters: "character";
1033
+ readonly objects: "object";
1034
+ readonly locations: "location";
1035
+ readonly species: "species";
1036
+ readonly creatures: "creature";
1037
+ readonly institutions: "institution";
1038
+ readonly traits: "trait";
1039
+ readonly collectives: "collective";
1040
+ readonly zones: "zone";
1041
+ readonly abilities: "ability";
1042
+ readonly phenomena: "phenomenon";
1043
+ readonly languages: "language";
1044
+ readonly families: "family";
1045
+ readonly titles: "title";
1046
+ readonly constructs: "construct";
1047
+ readonly events: "event";
1048
+ readonly narratives: "narrative";
1049
+ };
1050
+ readonly species: {
1051
+ readonly parent_species: "species";
1052
+ readonly nourishment: "species";
1053
+ readonly reproduction: "construct";
1054
+ readonly adaptations: "ability";
1055
+ readonly traits: "trait";
1056
+ readonly locations: "location";
1057
+ readonly zones: "zone";
1058
+ readonly affinities: "phenomenon";
1059
+ };
1060
+ readonly title: {
1061
+ readonly issuer: "institution";
1062
+ readonly body: "institution";
1063
+ readonly superior_title: "title";
1064
+ readonly holders: "character";
1065
+ readonly symbols: "object";
1066
+ readonly characters: "character";
1067
+ readonly institutions: "institution";
1068
+ readonly families: "family";
1069
+ readonly zones: "zone";
1070
+ readonly locations: "location";
1071
+ readonly objects: "object";
1072
+ readonly constructs: "construct";
1073
+ readonly laws: "law";
1074
+ readonly collectives: "collective";
1075
+ readonly creatures: "creature";
1076
+ readonly phenomena: "phenomenon";
1077
+ readonly species: "species";
1078
+ readonly languages: "language";
1079
+ };
1080
+ readonly trait: {
1081
+ readonly anti_trait: "trait";
1082
+ readonly empowered_abilities: "ability";
1083
+ };
1084
+ readonly zone: {
1085
+ readonly phenomena: "phenomenon";
1086
+ readonly linked_zones: "zone";
1087
+ readonly populations: "collective";
1088
+ readonly titles: "title";
1089
+ readonly principles: "construct";
1090
+ };
1091
+ };
1092
+ /**
1093
+ * Type for the field mappings - enables type-safe access to relationship metadata
1094
+ */
1095
+ type FieldMappingsType = typeof FIELD_MAPPINGS;
1096
+ /**
1097
+ * Creates a typed element ID from a string
1098
+ * @param id The string ID to brand
1099
+ * @returns Branded ElementId
1100
+ */
1101
+ declare function createElementId<T extends ElementType>(id: string): ElementId<T>;
1102
+ /**
1103
+ * Creates typed element IDs array from string array
1104
+ * @param ids The string IDs to brand
1105
+ * @returns Branded ElementIds array
1106
+ */
1107
+ declare function createElementIds<T extends ElementType>(ids: string[]): ElementIds<T>;
1108
+ /**
1109
+ * Creates an AnyElementId that can reference any element type
1110
+ * @param id The string ID to brand
1111
+ * @returns AnyElementId
1112
+ */
1113
+ declare function createAnyElementId(id: string): AnyElementId;
983
1114
 
984
1115
  interface OnlyWorldsConfig {
985
1116
  apiKey: string;
@@ -1018,6 +1149,7 @@ declare class Resource<T, TInput> {
1018
1149
  declare class OnlyWorldsClient {
1019
1150
  private baseUrl;
1020
1151
  private headers;
1152
+ worlds: Resource<World, WorldInput>;
1021
1153
  abilities: Resource<Ability, AbilityInput>;
1022
1154
  characters: Resource<Character, CharacterInput>;
1023
1155
  collectives: Resource<Collective, CollectiveInput>;
@@ -1050,12 +1182,13 @@ declare class OnlyWorldsClient {
1050
1182
  }): Promise<T>;
1051
1183
  /**
1052
1184
  * Get all worlds accessible with current credentials
1185
+ * @deprecated Use client.worlds.list() instead for consistent API
1053
1186
  */
1054
- getWorlds(): Promise<any>;
1187
+ getWorlds(): Promise<ApiResponse<World>>;
1055
1188
  /**
1056
1189
  * Helper to convert nested objects to _id/_ids format
1057
1190
  */
1058
1191
  static prepareInput<T extends Record<string, any>>(data: T): any;
1059
1192
  }
1060
1193
 
1061
- export { type Ability, type AbilityInput, type ApiResponse, type BaseElement, type Character, type CharacterInput, type Collective, type CollectiveInput, type Construct, type ConstructInput, type Creature, type CreatureInput, ElementType, type Event, type EventInput, type Family, type FamilyInput, type Institution, type InstitutionInput, type Language, type LanguageInput, type Law, type LawInput, type ListOptions, type Location, type LocationInput, type Map, type MapInput, type Marker, type MarkerInput, type Narrative, type NarrativeInput, type Object$1 as Object, type ObjectInput, OnlyWorldsClient, type OnlyWorldsConfig, type Phenomenon, type PhenomenonInput, type Pin, type PinInput, type Relation, type RelationInput, type Species, type SpeciesInput, type Title, type TitleInput, type Trait, type TraitInput, type Zone, type ZoneInput };
1194
+ export { type Ability, type AbilityInput, type AnyElementId, type ApiResponse, type BaseElement, type Character, type CharacterInput, type Collective, type CollectiveInput, type Construct, type ConstructInput, type Creature, type CreatureInput, type ElementId, type ElementIds, ElementType, type Event, type EventInput, FIELD_MAPPINGS, type Family, type FamilyInput, type FieldMappingsType, type Institution, type InstitutionInput, type Language, type LanguageInput, type Law, type LawInput, type ListOptions, type Location, type LocationInput, type Map, type MapInput, type Marker, type MarkerInput, type Narrative, type NarrativeInput, type Object$1 as Object, type ObjectInput, OnlyWorldsClient, type OnlyWorldsConfig, type Phenomenon, type PhenomenonInput, type Pin, type PinInput, type Relation, type RelationInput, type Species, type SpeciesInput, type Title, type TitleInput, type Trait, type TraitInput, type World, type WorldInput, type Zone, type ZoneInput, createAnyElementId, createElementId, createElementIds };