@onlyworlds/sdk 2.1.3 → 2.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
@@ -573,265 +573,266 @@ interface Pin extends BaseElement {
573
573
  z?: number;
574
574
  }
575
575
  /**
576
- * Input types for API requests (using _id and _ids suffixes)
576
+ * Input types for API requests
577
+ * Use field names without _id/_ids suffix - prepareRelations() handles conversion
577
578
  */
578
579
  interface AbilityInput extends Omit<Ability, 'tradition' | 'source' | 'locus' | 'effects' | 'talents' | 'requisites' | 'instruments' | 'systems'> {
579
- tradition_id?: string;
580
- source_id?: string;
581
- locus_id?: string;
582
- effects_ids?: string[];
583
- talents_ids?: string[];
584
- requisites_ids?: string[];
585
- instruments_ids?: string[];
586
- systems_ids?: string[];
580
+ tradition?: string;
581
+ source?: string;
582
+ locus?: string;
583
+ effects?: string[];
584
+ talents?: string[];
585
+ requisites?: string[];
586
+ instruments?: string[];
587
+ systems?: string[];
587
588
  }
588
589
  interface ObjectInput extends Omit<Object$1, 'parent_object' | 'location' | 'language' | 'materials' | 'technology' | 'effects' | 'abilities' | 'consumes' | 'affinities'> {
589
- parent_object_id?: string;
590
- location_id?: string;
591
- language_id?: string;
592
- materials_ids?: string[];
593
- technology_ids?: string[];
594
- effects_ids?: string[];
595
- abilities_ids?: string[];
596
- consumes_ids?: string[];
597
- affinities_ids?: string[];
590
+ parent_object?: string;
591
+ location?: string;
592
+ language?: string;
593
+ materials?: string[];
594
+ technology?: string[];
595
+ effects?: string[];
596
+ abilities?: string[];
597
+ consumes?: string[];
598
+ affinities?: string[];
598
599
  }
599
600
  interface CharacterInput extends Omit<Character, 'birthplace' | 'location' | 'species' | 'traits' | 'abilities' | 'languages' | 'objects' | 'institutions' | 'family' | 'friends' | 'rivals'> {
600
- birthplace_id?: string;
601
- location_id?: string;
602
- species_ids?: string[];
603
- traits_ids?: string[];
604
- abilities_ids?: string[];
605
- languages_ids?: string[];
606
- objects_ids?: string[];
607
- institutions_ids?: string[];
608
- family_ids?: string[];
609
- friends_ids?: string[];
610
- rivals_ids?: string[];
601
+ birthplace?: string;
602
+ location?: string;
603
+ species?: string[];
604
+ traits?: string[];
605
+ abilities?: string[];
606
+ languages?: string[];
607
+ objects?: string[];
608
+ institutions?: string[];
609
+ family?: string[];
610
+ friends?: string[];
611
+ rivals?: string[];
611
612
  }
612
613
  interface CollectiveInput extends Omit<Collective, 'operator' | 'equipment' | 'abilities' | 'symbolism' | 'species' | 'characters' | 'creatures' | 'phenomena'> {
613
- operator_id?: string;
614
- equipment_ids?: string[];
615
- abilities_ids?: string[];
616
- symbolism_ids?: string[];
617
- species_ids?: string[];
618
- characters_ids?: string[];
619
- creatures_ids?: string[];
620
- phenomena_ids?: string[];
614
+ operator?: string;
615
+ equipment?: string[];
616
+ abilities?: string[];
617
+ symbolism?: string[];
618
+ species?: string[];
619
+ characters?: string[];
620
+ creatures?: string[];
621
+ phenomena?: string[];
621
622
  }
622
623
  interface ConstructInput extends Omit<Construct, 'founder' | 'custodian' | 'characters' | 'objects' | 'locations' | 'species' | 'creatures' | 'institutions' | 'traits' | 'collectives' | 'zones' | 'abilities' | 'phenomena' | 'languages' | 'families' | 'relations' | 'titles' | 'constructs' | 'events' | 'narratives'> {
623
- founder_id?: string;
624
- custodian_id?: string;
625
- characters_ids?: string[];
626
- objects_ids?: string[];
627
- locations_ids?: string[];
628
- species_ids?: string[];
629
- creatures_ids?: string[];
630
- institutions_ids?: string[];
631
- traits_ids?: string[];
632
- collectives_ids?: string[];
633
- zones_ids?: string[];
634
- abilities_ids?: string[];
635
- phenomena_ids?: string[];
636
- languages_ids?: string[];
637
- families_ids?: string[];
638
- relations_ids?: string[];
639
- titles_ids?: string[];
640
- constructs_ids?: string[];
641
- events_ids?: string[];
642
- narratives_ids?: string[];
624
+ founder?: string;
625
+ custodian?: string;
626
+ characters?: string[];
627
+ objects?: string[];
628
+ locations?: string[];
629
+ species?: string[];
630
+ creatures?: string[];
631
+ institutions?: string[];
632
+ traits?: string[];
633
+ collectives?: string[];
634
+ zones?: string[];
635
+ abilities?: string[];
636
+ phenomena?: string[];
637
+ languages?: string[];
638
+ families?: string[];
639
+ relations?: string[];
640
+ titles?: string[];
641
+ constructs?: string[];
642
+ events?: string[];
643
+ narratives?: string[];
643
644
  }
644
645
  interface CreatureInput extends Omit<Creature, 'location' | 'zone' | 'species' | 'traits' | 'abilities' | 'languages' | 'actions'> {
645
- location_id?: string;
646
- zone_id?: string;
647
- species_ids?: string[];
648
- traits_ids?: string[];
649
- abilities_ids?: string[];
650
- languages_ids?: string[];
651
- actions_ids?: string[];
646
+ location?: string;
647
+ zone?: string;
648
+ species?: string[];
649
+ traits?: string[];
650
+ abilities?: string[];
651
+ languages?: string[];
652
+ actions?: string[];
652
653
  }
653
654
  interface EventInput extends Omit<Event, 'triggers' | 'characters' | 'objects' | 'locations' | 'species' | 'creatures' | 'institutions' | 'traits' | 'collectives' | 'zones' | 'abilities' | 'phenomena' | 'languages' | 'families' | 'relations' | 'titles' | 'constructs'> {
654
- triggers_ids?: string[];
655
- characters_ids?: string[];
656
- objects_ids?: string[];
657
- locations_ids?: string[];
658
- species_ids?: string[];
659
- creatures_ids?: string[];
660
- institutions_ids?: string[];
661
- traits_ids?: string[];
662
- collectives_ids?: string[];
663
- zones_ids?: string[];
664
- abilities_ids?: string[];
665
- phenomena_ids?: string[];
666
- languages_ids?: string[];
667
- families_ids?: string[];
668
- relations_ids?: string[];
669
- titles_ids?: string[];
670
- constructs_ids?: string[];
655
+ triggers?: string[];
656
+ characters?: string[];
657
+ objects?: string[];
658
+ locations?: string[];
659
+ species?: string[];
660
+ creatures?: string[];
661
+ institutions?: string[];
662
+ traits?: string[];
663
+ collectives?: string[];
664
+ zones?: string[];
665
+ abilities?: string[];
666
+ phenomena?: string[];
667
+ languages?: string[];
668
+ families?: string[];
669
+ relations?: string[];
670
+ titles?: string[];
671
+ constructs?: string[];
671
672
  }
672
673
  interface FamilyInput extends Omit<Family, 'traditions' | 'traits' | 'abilities' | 'languages' | 'ancestors' | 'estates' | 'governs' | 'heirlooms' | 'creatures'> {
673
- traditions_ids?: string[];
674
- traits_ids?: string[];
675
- abilities_ids?: string[];
676
- languages_ids?: string[];
677
- ancestors_ids?: string[];
678
- estates_ids?: string[];
679
- governs_ids?: string[];
680
- heirlooms_ids?: string[];
681
- creatures_ids?: string[];
674
+ traditions?: string[];
675
+ traits?: string[];
676
+ abilities?: string[];
677
+ languages?: string[];
678
+ ancestors?: string[];
679
+ estates?: string[];
680
+ governs?: string[];
681
+ heirlooms?: string[];
682
+ creatures?: string[];
682
683
  }
683
684
  interface InstitutionInput extends Omit<Institution, 'parent_institution' | 'zones' | 'objects' | 'creatures' | 'allies' | 'adversaries' | 'constructs'> {
684
- parent_institution_id?: string;
685
- zones_ids?: string[];
686
- objects_ids?: string[];
687
- creatures_ids?: string[];
688
- allies_ids?: string[];
689
- adversaries_ids?: string[];
690
- constructs_ids?: string[];
685
+ parent_institution?: string;
686
+ zones?: string[];
687
+ objects?: string[];
688
+ creatures?: string[];
689
+ allies?: string[];
690
+ adversaries?: string[];
691
+ constructs?: string[];
691
692
  }
692
693
  interface LanguageInput extends Omit<Language, 'classification' | 'spread' | 'dialects'> {
693
- classification_id?: string;
694
- spread_ids?: string[];
695
- dialects_ids?: string[];
694
+ classification?: string;
695
+ spread?: string[];
696
+ dialects?: string[];
696
697
  }
697
698
  interface LawInput extends Omit<Law, 'parent_law' | 'author' | 'penalties' | 'locations' | 'zones' | 'prohibitions' | 'adjudicators' | 'enforcers'> {
698
- parent_law_id?: string;
699
- author_id?: string;
700
- penalties_ids?: string[];
701
- locations_ids?: string[];
702
- zones_ids?: string[];
703
- prohibitions_ids?: string[];
704
- adjudicators_ids?: string[];
705
- enforcers_ids?: string[];
699
+ parent_law?: string;
700
+ author?: string;
701
+ penalties?: string[];
702
+ locations?: string[];
703
+ zones?: string[];
704
+ prohibitions?: string[];
705
+ adjudicators?: string[];
706
+ enforcers?: string[];
706
707
  }
707
708
  interface LocationInput extends Omit<Location, 'parent_location' | 'primary_power' | 'governing_title' | 'zone' | 'rival' | 'partner' | 'populations' | 'secondary_powers' | 'founders' | 'cults' | 'delicacies' | 'extraction_methods' | 'extraction_goods' | 'industry_methods' | 'industry_goods' | 'extraction_markets' | 'industry_markets' | 'currencies' | 'buildings' | 'building_methods' | 'fighters' | 'defensive_objects'> {
708
- parent_location_id?: string;
709
- primary_power_id?: string;
710
- governing_title_id?: string;
711
- zone_id?: string;
712
- rival_id?: string;
713
- partner_id?: string;
714
- populations_ids?: string[];
715
- secondary_powers_ids?: string[];
716
- founders_ids?: string[];
717
- cults_ids?: string[];
718
- delicacies_ids?: string[];
719
- extraction_methods_ids?: string[];
720
- extraction_goods_ids?: string[];
721
- industry_methods_ids?: string[];
722
- industry_goods_ids?: string[];
723
- extraction_markets_ids?: string[];
724
- industry_markets_ids?: string[];
725
- currencies_ids?: string[];
726
- buildings_ids?: string[];
727
- building_methods_ids?: string[];
728
- fighters_ids?: string[];
729
- defensive_objects_ids?: string[];
709
+ parent_location?: string;
710
+ primary_power?: string;
711
+ governing_title?: string;
712
+ zone?: string;
713
+ rival?: string;
714
+ partner?: string;
715
+ populations?: string[];
716
+ secondary_powers?: string[];
717
+ founders?: string[];
718
+ cults?: string[];
719
+ delicacies?: string[];
720
+ extraction_methods?: string[];
721
+ extraction_goods?: string[];
722
+ industry_methods?: string[];
723
+ industry_goods?: string[];
724
+ extraction_markets?: string[];
725
+ industry_markets?: string[];
726
+ currencies?: string[];
727
+ buildings?: string[];
728
+ building_methods?: string[];
729
+ fighters?: string[];
730
+ defensive_objects?: string[];
730
731
  }
731
732
  interface PhenomenonInput extends Omit<Phenomenon, 'system' | 'catalysts' | 'empowerments' | 'triggers' | 'wielders' | 'environments'> {
732
- system_id?: string;
733
- catalysts_ids?: string[];
734
- empowerments_ids?: string[];
735
- triggers_ids?: string[];
736
- wielders_ids?: string[];
737
- environments_ids?: string[];
733
+ system?: string;
734
+ catalysts?: string[];
735
+ empowerments?: string[];
736
+ triggers?: string[];
737
+ wielders?: string[];
738
+ environments?: string[];
738
739
  }
739
740
  interface RelationInput extends Omit<Relation, 'actor' | 'characters' | 'objects' | 'locations' | 'species' | 'creatures' | 'institutions' | 'traits' | 'collectives' | 'zones' | 'abilities' | 'phenomena' | 'languages' | 'families' | 'titles' | 'constructs' | 'events' | 'narratives'> {
740
- actor_id?: string;
741
- characters_ids?: string[];
742
- objects_ids?: string[];
743
- locations_ids?: string[];
744
- species_ids?: string[];
745
- creatures_ids?: string[];
746
- institutions_ids?: string[];
747
- traits_ids?: string[];
748
- collectives_ids?: string[];
749
- zones_ids?: string[];
750
- abilities_ids?: string[];
751
- phenomena_ids?: string[];
752
- languages_ids?: string[];
753
- families_ids?: string[];
754
- titles_ids?: string[];
755
- constructs_ids?: string[];
756
- events_ids?: string[];
757
- narratives_ids?: string[];
741
+ actor?: string;
742
+ characters?: string[];
743
+ objects?: string[];
744
+ locations?: string[];
745
+ species?: string[];
746
+ creatures?: string[];
747
+ institutions?: string[];
748
+ traits?: string[];
749
+ collectives?: string[];
750
+ zones?: string[];
751
+ abilities?: string[];
752
+ phenomena?: string[];
753
+ languages?: string[];
754
+ families?: string[];
755
+ titles?: string[];
756
+ constructs?: string[];
757
+ events?: string[];
758
+ narratives?: string[];
758
759
  }
759
760
  interface SpeciesInput extends Omit<Species, 'parent_species' | 'nourishment' | 'reproduction' | 'adaptations' | 'traits' | 'locations' | 'zones' | 'affinities'> {
760
- parent_species_id?: string;
761
- nourishment_ids?: string[];
762
- reproduction_ids?: string[];
763
- adaptations_ids?: string[];
764
- traits_ids?: string[];
765
- locations_ids?: string[];
766
- zones_ids?: string[];
767
- affinities_ids?: string[];
761
+ parent_species?: string;
762
+ nourishment?: string[];
763
+ reproduction?: string[];
764
+ adaptations?: string[];
765
+ traits?: string[];
766
+ locations?: string[];
767
+ zones?: string[];
768
+ affinities?: string[];
768
769
  }
769
770
  interface ZoneInput extends Omit<Zone, 'phenomena' | 'linked_zones' | 'populations' | 'titles' | 'principles'> {
770
- phenomena_ids?: string[];
771
- linked_zones_ids?: string[];
772
- populations_ids?: string[];
773
- titles_ids?: string[];
774
- principles_ids?: string[];
771
+ phenomena?: string[];
772
+ linked_zones?: string[];
773
+ populations?: string[];
774
+ titles?: string[];
775
+ principles?: string[];
775
776
  }
776
777
  interface TitleInput extends Omit<Title, 'issuer' | 'body' | 'superior_title' | 'holders' | 'symbols' | 'characters' | 'institutions' | 'families' | 'zones' | 'locations' | 'objects' | 'constructs' | 'laws' | 'collectives' | 'creatures' | 'phenomena' | 'species' | 'languages'> {
777
- issuer_id?: string;
778
- body_id?: string;
779
- superior_title_id?: string;
780
- holders_ids?: string[];
781
- symbols_ids?: string[];
782
- characters_ids?: string[];
783
- institutions_ids?: string[];
784
- families_ids?: string[];
785
- zones_ids?: string[];
786
- locations_ids?: string[];
787
- objects_ids?: string[];
788
- constructs_ids?: string[];
789
- laws_ids?: string[];
790
- collectives_ids?: string[];
791
- creatures_ids?: string[];
792
- phenomena_ids?: string[];
793
- species_ids?: string[];
794
- languages_ids?: string[];
778
+ issuer?: string;
779
+ body?: string;
780
+ superior_title?: string;
781
+ holders?: string[];
782
+ symbols?: string[];
783
+ characters?: string[];
784
+ institutions?: string[];
785
+ families?: string[];
786
+ zones?: string[];
787
+ locations?: string[];
788
+ objects?: string[];
789
+ constructs?: string[];
790
+ laws?: string[];
791
+ collectives?: string[];
792
+ creatures?: string[];
793
+ phenomena?: string[];
794
+ species?: string[];
795
+ languages?: string[];
795
796
  }
796
797
  interface TraitInput extends Omit<Trait, 'anti_trait' | 'empowered_abilities'> {
797
- anti_trait_id?: string;
798
- empowered_abilities_ids?: string[];
798
+ anti_trait?: string;
799
+ empowered_abilities?: string[];
799
800
  }
800
801
  interface NarrativeInput extends Omit<Narrative, 'parent_narrative' | 'protagonist' | 'antagonist' | 'narrator' | 'conservator' | 'events' | 'characters' | 'objects' | 'locations' | 'species' | 'creatures' | 'institutions' | 'traits' | 'collectives' | 'zones' | 'abilities' | 'phenomena' | 'languages' | 'families' | 'relations' | 'titles' | 'constructs' | 'laws'> {
801
- parent_narrative_id?: string;
802
- protagonist_id?: string;
803
- antagonist_id?: string;
804
- narrator_id?: string;
805
- conservator_id?: string;
806
- events_ids?: string[];
807
- characters_ids?: string[];
808
- objects_ids?: string[];
809
- locations_ids?: string[];
810
- species_ids?: string[];
811
- creatures_ids?: string[];
812
- institutions_ids?: string[];
813
- traits_ids?: string[];
814
- collectives_ids?: string[];
815
- zones_ids?: string[];
816
- abilities_ids?: string[];
817
- phenomena_ids?: string[];
818
- languages_ids?: string[];
819
- families_ids?: string[];
820
- relations_ids?: string[];
821
- titles_ids?: string[];
822
- constructs_ids?: string[];
823
- laws_ids?: string[];
802
+ parent_narrative?: string;
803
+ protagonist?: string;
804
+ antagonist?: string;
805
+ narrator?: string;
806
+ conservator?: string;
807
+ events?: string[];
808
+ characters?: string[];
809
+ objects?: string[];
810
+ locations?: string[];
811
+ species?: string[];
812
+ creatures?: string[];
813
+ institutions?: string[];
814
+ traits?: string[];
815
+ collectives?: string[];
816
+ zones?: string[];
817
+ abilities?: string[];
818
+ phenomena?: string[];
819
+ languages?: string[];
820
+ families?: string[];
821
+ relations?: string[];
822
+ titles?: string[];
823
+ constructs?: string[];
824
+ laws?: string[];
824
825
  }
825
826
  interface MapInput extends Omit<Map, 'parent_map' | 'location'> {
826
- parent_map_id?: string;
827
- location_id?: string;
827
+ parent_map?: string;
828
+ location?: string;
828
829
  }
829
830
  interface MarkerInput extends Omit<Marker, 'map' | 'zone'> {
830
- map_id?: string;
831
- zone_id?: string;
831
+ map?: string;
832
+ zone?: string;
832
833
  }
833
834
  interface PinInput extends Omit<Pin, 'map' | 'element_id'> {
834
- map_id?: string;
835
+ map?: string;
835
836
  element_id?: string;
836
837
  }
837
838
  /**
@@ -3088,9 +3089,25 @@ declare class OnlyWorldsClient {
3088
3089
  body?: any;
3089
3090
  }): Promise<T>;
3090
3091
  /**
3091
- * Helper to convert nested objects to _id/_ids format
3092
+ * Helper to convert nested objects to _id/_ids format (legacy method)
3093
+ * @deprecated Use prepareRelations instead - it's called automatically in create/update
3092
3094
  */
3093
3095
  static prepareInput<T extends Record<string, any>>(data: T): any;
3096
+ /**
3097
+ * Convert relation fields to API format (_id/_ids suffix)
3098
+ *
3099
+ * The OnlyWorlds API expects:
3100
+ * - single_link fields: fieldname_id (e.g., birthplace_id)
3101
+ * - multi_link fields: fieldname_ids (e.g., species_ids)
3102
+ *
3103
+ * This method auto-converts based on FIELD_SCHEMA:
3104
+ * - { species: ["id1", "id2"] } → { species_ids: ["id1", "id2"] }
3105
+ * - { birthplace: "location-id" } → { birthplace_id: "location-id" }
3106
+ * - { species: [{id: "id1", name: "X"}] } → { species_ids: ["id1"] }
3107
+ *
3108
+ * Called automatically by create() and update() methods.
3109
+ */
3110
+ static prepareRelations<T extends Record<string, any>>(data: T, elementType: string): any;
3094
3111
  }
3095
3112
 
3096
3113
  export { type Ability, type AbilityInput, type AccessKeyResponse, type AnyElementId, type ApiResponse, type BaseElement, type Character, type CharacterInput, type Collective, type CollectiveInput, type Construct, type ConstructInput, type Creature, type CreatureInput, ELEMENT_ICONS, ELEMENT_LABELS, ELEMENT_SECTIONS, ELEMENT_UNICODE_ICONS, type ElementId, type ElementIds, ElementType, type EncryptionInfo, type Event, type EventInput, FIELD_SCHEMA, type Family, type FamilyInput, type FieldInfo, type FieldType, GameTier, 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, ONLYWORLDS_VERSION, type Object$1 as Object, type ObjectInput, OnlyWorldsClient, type OnlyWorldsConfig, type Phenomenon, type PhenomenonInput, type Pin, type PinInput, type Relation, type RelationInput, type RevokeAllSessionsResponse, type RevokeSessionResponse, type SectionInfo, type Species, type SpeciesInput, type Title, type TitleInput, type TokenConsumeParams, type TokenConsumeResponse, type TokenStatus, type Trait, type TraitInput, type World, type WorldInput, type Zone, type ZoneInput, createAnyElementId, createElementId, createElementIds, getElementIcon, getElementLabel, getElementSections, getElementUnicodeIcon };