@onlyworlds/sdk 3.0.0 → 3.1.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/AGENTS.md +30 -0
- package/CHANGELOG.md +44 -0
- package/README.md +29 -6
- package/dist/index.d.mts +58 -2
- package/dist/index.d.ts +58 -2
- package/dist/index.js +49 -0
- package/dist/index.mjs +44 -0
- package/package.json +6 -2
package/AGENTS.md
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
# For AI agents using @onlyworlds/sdk
|
|
2
|
+
|
|
3
|
+
**What this package is**: the canonical typed TypeScript client for the OnlyWorlds v2 API,
|
|
4
|
+
plus the canonical constants (element types, icons, colour families, field schema).
|
|
5
|
+
OnlyWorlds is an open standard for portable world data — 22 element types, UUID-linked.
|
|
6
|
+
|
|
7
|
+
**Use the v2 surface.** `OwV2Client` + the `V2ElementType` slug union + the generated
|
|
8
|
+
interfaces in `types.generated.ts` (emitted from the canonical schema YAML, validated
|
|
9
|
+
against live data). The v1 surface (`OnlyWorldsClient`, the `ElementType` enum) is frozen
|
|
10
|
+
legacy — do not build new work on it.
|
|
11
|
+
|
|
12
|
+
**SDK vs MCP server — pick correctly**:
|
|
13
|
+
- Known, deterministic operations (CRUD, sync, bulk) → **this SDK**. Typed calls, typed
|
|
14
|
+
responses, far cheaper than tool-schema reasoning.
|
|
15
|
+
- Live exploration of a user's world from a chat/agent context → the **MCP server** at
|
|
16
|
+
`https://www.onlyworlds.com/mcp` (same `API-Key`/`API-Pin` headers, 11 tools).
|
|
17
|
+
|
|
18
|
+
**Wire facts that bite** (full details in README):
|
|
19
|
+
- Never send a `"world"` field in payloads — world identity comes from the API key (422 otherwise).
|
|
20
|
+
- v2 link fields use ONE name both directions (no `_ids` suffix — that is v1 dialect only).
|
|
21
|
+
- PATCH is destructive on sent fields; use `editLinks` (atomic add/remove) for relationships.
|
|
22
|
+
- World-meta changes do NOT appear in `/changes` — poll `GET /world` separately.
|
|
23
|
+
- Extension fields: `x_<toolname>_*` is the sanctioned namespace for tool-specific state;
|
|
24
|
+
unknown unprefixed fields 422.
|
|
25
|
+
- Colour carries the element's FAMILY (`elementColor(type, mode)`); the icon
|
|
26
|
+
(`ELEMENT_ICONS`) carries the TYPE. Icon + label are required alongside colour, not optional.
|
|
27
|
+
|
|
28
|
+
**Auth**: prefixed keys — `ow_w_` (read+write), `ow_r_` (read-only, no PIN — the share
|
|
29
|
+
primitive), `ow_a_` (account Bearer). Demo keys `0000000000`–`0000000009` are read-only
|
|
30
|
+
test credentials against real data.
|
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to `@onlyworlds/sdk`. Maintained from 3.1.0 onward (Kael, Assembly);
|
|
4
|
+
earlier history lives in git log only.
|
|
5
|
+
|
|
6
|
+
## [3.1.0] — 2026-07-23
|
|
7
|
+
|
|
8
|
+
### Added
|
|
9
|
+
- **Canonical element colour palette** (`src/v2/palette.ts`, exported from root):
|
|
10
|
+
`ELEMENT_FAMILIES` (type → family), `FAMILY_COLORS` (family → `{light, dark}` hex),
|
|
11
|
+
`familyOf(type)`, `elementColor(type, mode)`, `FAMILY_ORDER`, type `ElementFamily`.
|
|
12
|
+
Four semantic families (agents / world / abstract / temporal) ruled 2026-07-22 after
|
|
13
|
+
CVD-validated measurement (Orrery `product/schema/element-palette-measurements.md`).
|
|
14
|
+
Colour carries the FAMILY; `ELEMENT_ICONS` carries the TYPE. Keyed on the v2 slug
|
|
15
|
+
union. First proven live in atlas and council, whose local copies become re-exports.
|
|
16
|
+
**`ELEMENT_FAMILIES` is GENERATED** from the `family:` key in keel's schema YAML
|
|
17
|
+
(keel `c69366b`, a keel presentation-wrapper key — not part of the council-governed
|
|
18
|
+
OnlyWorlds standard); hexes are hand-authored design constants beside it. Membership
|
|
19
|
+
and hex invariants test-gated (`test/palette.test.mjs`); light hexes render-proven on
|
|
20
|
+
the ruled OnlyWorlds light mode (ow-house-light) 2026-07-23.
|
|
21
|
+
- **Codegen drift guard**: `python codegen/generate_types.py --check` fails if
|
|
22
|
+
`types.generated.ts` doesn't match the schema YAMLs (release gate; mirrors keel's
|
|
23
|
+
schema CI job). Codegen also hard-fails on missing/invalid `family:` keys — the
|
|
24
|
+
canary for a canonical-refresh that overwrote keel's wrapper layer.
|
|
25
|
+
- **CI**: GitHub Action building + running the full suite against the compiled bundle.
|
|
26
|
+
- **AGENTS.md** shipped in the tarball — usage guide for AI agents reading the package
|
|
27
|
+
locally, including the SDK-vs-MCP division of labor and the wire gotchas.
|
|
28
|
+
- README: worked create→link→read-back round-trip, schema-verified field by field
|
|
29
|
+
(also fixes the old example patching `'character'` with a location's id); canonical
|
|
30
|
+
colour section; SDK-vs-MCP guidance.
|
|
31
|
+
- This CHANGELOG.
|
|
32
|
+
|
|
33
|
+
### Fixed
|
|
34
|
+
- `FieldType` union now includes `'number'` — the legacy alias that 70 `FIELD_SCHEMA`
|
|
35
|
+
entries actually carry (consumers switch on it; data normalization deferred to 4.0).
|
|
36
|
+
- `generate_types.py` exits with a clear message when the sibling keel checkout is
|
|
37
|
+
absent instead of a bare traceback.
|
|
38
|
+
|
|
39
|
+
## [3.0.0] — 2026-07-18
|
|
40
|
+
|
|
41
|
+
- v2-native client (`OwV2Client`) absorbed from Assembly's ow-v2-client v0.9.0 (Kael),
|
|
42
|
+
wire-corrected against live staging fixtures (S22). Generated element types from the
|
|
43
|
+
canonical keel schema YAML (`src/v2/types.generated.ts`), validated against all 1,086
|
|
44
|
+
live W11 elements. v1 surface unchanged and frozen.
|
package/README.md
CHANGED
|
@@ -33,17 +33,28 @@ for await (const character of client.listAll('character')) {
|
|
|
33
33
|
// ...
|
|
34
34
|
}
|
|
35
35
|
|
|
36
|
-
//
|
|
36
|
+
// A worked round-trip: two elements, linked, read back. Byte-true v2 dialect:
|
|
37
|
+
// link fields use ONE bare name both directions (no _ids suffix — that's v1),
|
|
38
|
+
// and you NEVER send a "world" field (identity comes from the key; sending it 422s).
|
|
37
39
|
const location = await client.create('location', {
|
|
38
40
|
name: 'Dragon Peak',
|
|
39
41
|
description: 'A treacherous mountain peak where dragons nest',
|
|
42
|
+
}); // id minted client-side when omitted (retries stay idempotent)
|
|
43
|
+
|
|
44
|
+
const dragon = await client.create('creature', {
|
|
45
|
+
name: 'Vorrath the Ember-Scaled',
|
|
46
|
+
location: location.id, // single link: UUID (or null)
|
|
40
47
|
});
|
|
41
48
|
|
|
42
|
-
|
|
43
|
-
|
|
49
|
+
const fetched = await client.get('creature', dragon.id);
|
|
50
|
+
// fetched.location === location.id — reads the way it writes
|
|
51
|
+
|
|
52
|
+
// Partial update (PATCH is destructive on sent fields; arrays replace wholesale)
|
|
53
|
+
await client.patch('location', location.id, { supertype: 'Mountain' });
|
|
44
54
|
|
|
45
|
-
//
|
|
46
|
-
await client.
|
|
55
|
+
// For relationships, prefer the atomic link merge -- returns the full updated element
|
|
56
|
+
const fireBreath = await client.create('ability', { name: 'Ember Breath' });
|
|
57
|
+
await client.editLinks('creature', dragon.id, 'abilities', { add: [fireBreath.id], remove: [] });
|
|
47
58
|
|
|
48
59
|
// Bulk write (up to ~1000; partial success by default, atomic:true for all-or-nothing)
|
|
49
60
|
const res = await client.bulk([
|
|
@@ -59,10 +70,22 @@ for await (const change of client.changesAll(cursor)) {
|
|
|
59
70
|
}
|
|
60
71
|
```
|
|
61
72
|
|
|
62
|
-
###
|
|
73
|
+
### Canonical element colours
|
|
74
|
+
|
|
75
|
+
```typescript
|
|
76
|
+
import { elementColor, ELEMENT_FAMILIES, FAMILY_COLORS } from '@onlyworlds/sdk';
|
|
77
|
+
|
|
78
|
+
elementColor('character', 'dark'); // '#3987e5' — colour carries the FAMILY
|
|
79
|
+
// (agents / world / abstract / temporal); ELEMENT_ICONS carries the TYPE.
|
|
80
|
+
// CVD-validated: always pair colour with icon + label, never colour alone.
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
### AI-assistant access (MCP) — and when to use which
|
|
63
84
|
|
|
64
85
|
An MCP server exists at `https://www.onlyworlds.com/mcp` for AI assistants (Claude and other MCP clients) to read and write worlds directly -- no SDK code required. See the [docs](https://onlyworlds.github.io) for setup.
|
|
65
86
|
|
|
87
|
+
Division of labor: for **known, deterministic operations** (CRUD, sync, bulk) use this SDK — typed calls, no tool-schema overhead. For **live exploration of a user's world from a chat/agent context**, use the MCP server. Agents: see `AGENTS.md` in this package.
|
|
88
|
+
|
|
66
89
|
## Legacy: v1 client (`OnlyWorldsClient`)
|
|
67
90
|
|
|
68
91
|
The v1 resource-style client remains fully supported and served forever. Prefer `OwV2Client` for new code.
|
package/dist/index.d.mts
CHANGED
|
@@ -907,7 +907,7 @@ declare const ELEMENT_ICONS: Record<ElementType$1, string>;
|
|
|
907
907
|
/**
|
|
908
908
|
* Field type definitions for OnlyWorlds elements
|
|
909
909
|
*/
|
|
910
|
-
type FieldType = 'text' | 'integer' | 'integer_max' | 'single_link' | 'multi_link';
|
|
910
|
+
type FieldType = 'text' | 'integer' | 'integer_max' | 'number' | 'single_link' | 'multi_link';
|
|
911
911
|
/**
|
|
912
912
|
* Field metadata structure
|
|
913
913
|
*/
|
|
@@ -3146,6 +3146,12 @@ interface OwElementBase {
|
|
|
3146
3146
|
}
|
|
3147
3147
|
type ElementType = 'ability' | 'character' | 'collective' | 'construct' | 'creature' | 'event' | 'family' | 'institution' | 'language' | 'law' | 'location' | 'map' | 'marker' | 'narrative' | 'object' | 'phenomenon' | 'pin' | 'relation' | 'species' | 'title' | 'trait' | 'zone';
|
|
3148
3148
|
declare const ELEMENT_TYPES: ElementType[];
|
|
3149
|
+
/** The four semantic families (colour carries the family; ELEMENT_ICONS carries the type). */
|
|
3150
|
+
type ElementFamily = 'agents' | 'world' | 'abstract' | 'temporal';
|
|
3151
|
+
/** Per-type semantic family. Source: keel's PRESENTATION-WRAPPER schema key `family:`
|
|
3152
|
+
* (first-party rendering metadata, keel-only — NOT part of the council-governed
|
|
3153
|
+
* OnlyWorlds standard; see keel/schema-pipeline.md "The wrapper layer"). */
|
|
3154
|
+
declare const ELEMENT_FAMILIES: Record<ElementType, ElementFamily>;
|
|
3149
3155
|
|
|
3150
3156
|
/**
|
|
3151
3157
|
* keel v2 engine absorbed from Assembly's ow-v2-client v0.9.0 (Kael),
|
|
@@ -3458,4 +3464,54 @@ declare class OwV2Client {
|
|
|
3458
3464
|
private request;
|
|
3459
3465
|
}
|
|
3460
3466
|
|
|
3461
|
-
|
|
3467
|
+
/**
|
|
3468
|
+
* Canonical element colour palette — four semantic families.
|
|
3469
|
+
*
|
|
3470
|
+
* Ruled by Captain 2026-07-22 after Skeld's measurement pass (Orrery
|
|
3471
|
+
* `product/schema/element-palette-measurements.md`): 22 mutually-separable
|
|
3472
|
+
* hues is structurally impossible; four families is the ceiling that passes
|
|
3473
|
+
* all-pairs CVD separation in both modes. **Colour carries the FAMILY; the
|
|
3474
|
+
* icon (`ELEMENT_ICONS`) carries the TYPE.** Dark-mode pairs land in the 6–8
|
|
3475
|
+
* CVD floor band, so secondary encoding (icon + label) is REQUIRED alongside
|
|
3476
|
+
* colour, not optional.
|
|
3477
|
+
*
|
|
3478
|
+
* The type→family map is GENERATED: `ELEMENT_FAMILIES` is emitted by
|
|
3479
|
+
* `codegen/generate_types.py` from the `family:` key in keel's schema YAML
|
|
3480
|
+
* (added 2026-07-23, keel c69366b) — a keel PRESENTATION-WRAPPER key
|
|
3481
|
+
* (first-party rendering metadata, not part of the council-governed
|
|
3482
|
+
* OnlyWorlds standard). It cannot drift from the schema; membership and hex
|
|
3483
|
+
* invariants stay test-gated in `test/palette.test.mjs`.
|
|
3484
|
+
*
|
|
3485
|
+
* The hexes below are design constants, hand-authored beside the generated
|
|
3486
|
+
* map. Do not change any value without re-running the CVD validation (every
|
|
3487
|
+
* brighter World green collides with Temporal amber for protan viewers — the
|
|
3488
|
+
* green is pinned BY the accessibility budget).
|
|
3489
|
+
*
|
|
3490
|
+
* Provenance: first proven live in atlas (`src/core/element-colors.ts`) and
|
|
3491
|
+
* council (`src/cosmos/element-families.ts`) — both become re-exports of this
|
|
3492
|
+
* module.
|
|
3493
|
+
*/
|
|
3494
|
+
|
|
3495
|
+
/**
|
|
3496
|
+
* Family → validated hex per surface mode. `light` assumes near-white
|
|
3497
|
+
* surfaces, `dark` assumes near-black (measured against #0a0a0a).
|
|
3498
|
+
* World green is identical in both modes and sits at its low-contrast end
|
|
3499
|
+
* deliberately — see module header before "fixing" it.
|
|
3500
|
+
*/
|
|
3501
|
+
declare const FAMILY_COLORS: Record<ElementFamily, {
|
|
3502
|
+
light: string;
|
|
3503
|
+
dark: string;
|
|
3504
|
+
}>;
|
|
3505
|
+
/** Semantic family for an element type slug. */
|
|
3506
|
+
declare function familyOf(type: ElementType): ElementFamily;
|
|
3507
|
+
/**
|
|
3508
|
+
* The convenience most callers want: canonical colour for an element type.
|
|
3509
|
+
* Name matches the live atlas/council implementations so their SDK swap is a
|
|
3510
|
+
* re-export, not a rename. Defaults to `dark` (both current consumers are
|
|
3511
|
+
* dark-surface).
|
|
3512
|
+
*/
|
|
3513
|
+
declare function elementColor(type: ElementType, mode?: 'light' | 'dark'): string;
|
|
3514
|
+
/** All four families, in ruling order (the order IS the CVD-safety mechanism of the source palette). */
|
|
3515
|
+
declare const FAMILY_ORDER: readonly ElementFamily[];
|
|
3516
|
+
|
|
3517
|
+
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_FAMILIES, ELEMENT_ICONS, ELEMENT_LABELS, ELEMENT_SECTIONS, ELEMENT_TYPES, type ElementFamily, type ElementId, type ElementIds, ElementType$1 as ElementType, type EncryptionInfo, type Event, type EventInput, FAMILY_COLORS, FAMILY_ORDER, 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 ListParams, 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, OwApiError, type OwAuthErrorCode, type OwBulkItem, type OwBulkItemResult, type OwBulkResponse, type OwChange, type OwChangesPage, type OwClientConfig, type OwElement, type OwElementBase, type OwErrorBody, type OwKeyKind, type OwLinkEdit, OwNetworkError, type OwPage, OwV2Client, type OwWorldMeta, type Phenomenon, type PhenomenonInput, type Pin, type PinInput, type Relation, type RelationInput, type RevokeAllSessionsResponse, type RevokeSessionResponse, SPATIAL_TYPES, type SectionInfo, type Species, type SpeciesInput, type Title, type TitleInput, type TokenConsumeParams, type TokenConsumeResponse, type TokenStatus, type Trait, type TraitInput, type ElementType as V2ElementType, type World, type WorldInput, type Zone, type ZoneInput, createAnyElementId, createElementId, createElementIds, detectKeyKind, elementColor, errorFromResponse, familyOf, getElementIcon, getElementLabel, getElementSections, isDemoKey, kindCanWrite, parseEnvelope, pinExpectation };
|
package/dist/index.d.ts
CHANGED
|
@@ -907,7 +907,7 @@ declare const ELEMENT_ICONS: Record<ElementType$1, string>;
|
|
|
907
907
|
/**
|
|
908
908
|
* Field type definitions for OnlyWorlds elements
|
|
909
909
|
*/
|
|
910
|
-
type FieldType = 'text' | 'integer' | 'integer_max' | 'single_link' | 'multi_link';
|
|
910
|
+
type FieldType = 'text' | 'integer' | 'integer_max' | 'number' | 'single_link' | 'multi_link';
|
|
911
911
|
/**
|
|
912
912
|
* Field metadata structure
|
|
913
913
|
*/
|
|
@@ -3146,6 +3146,12 @@ interface OwElementBase {
|
|
|
3146
3146
|
}
|
|
3147
3147
|
type ElementType = 'ability' | 'character' | 'collective' | 'construct' | 'creature' | 'event' | 'family' | 'institution' | 'language' | 'law' | 'location' | 'map' | 'marker' | 'narrative' | 'object' | 'phenomenon' | 'pin' | 'relation' | 'species' | 'title' | 'trait' | 'zone';
|
|
3148
3148
|
declare const ELEMENT_TYPES: ElementType[];
|
|
3149
|
+
/** The four semantic families (colour carries the family; ELEMENT_ICONS carries the type). */
|
|
3150
|
+
type ElementFamily = 'agents' | 'world' | 'abstract' | 'temporal';
|
|
3151
|
+
/** Per-type semantic family. Source: keel's PRESENTATION-WRAPPER schema key `family:`
|
|
3152
|
+
* (first-party rendering metadata, keel-only — NOT part of the council-governed
|
|
3153
|
+
* OnlyWorlds standard; see keel/schema-pipeline.md "The wrapper layer"). */
|
|
3154
|
+
declare const ELEMENT_FAMILIES: Record<ElementType, ElementFamily>;
|
|
3149
3155
|
|
|
3150
3156
|
/**
|
|
3151
3157
|
* keel v2 engine absorbed from Assembly's ow-v2-client v0.9.0 (Kael),
|
|
@@ -3458,4 +3464,54 @@ declare class OwV2Client {
|
|
|
3458
3464
|
private request;
|
|
3459
3465
|
}
|
|
3460
3466
|
|
|
3461
|
-
|
|
3467
|
+
/**
|
|
3468
|
+
* Canonical element colour palette — four semantic families.
|
|
3469
|
+
*
|
|
3470
|
+
* Ruled by Captain 2026-07-22 after Skeld's measurement pass (Orrery
|
|
3471
|
+
* `product/schema/element-palette-measurements.md`): 22 mutually-separable
|
|
3472
|
+
* hues is structurally impossible; four families is the ceiling that passes
|
|
3473
|
+
* all-pairs CVD separation in both modes. **Colour carries the FAMILY; the
|
|
3474
|
+
* icon (`ELEMENT_ICONS`) carries the TYPE.** Dark-mode pairs land in the 6–8
|
|
3475
|
+
* CVD floor band, so secondary encoding (icon + label) is REQUIRED alongside
|
|
3476
|
+
* colour, not optional.
|
|
3477
|
+
*
|
|
3478
|
+
* The type→family map is GENERATED: `ELEMENT_FAMILIES` is emitted by
|
|
3479
|
+
* `codegen/generate_types.py` from the `family:` key in keel's schema YAML
|
|
3480
|
+
* (added 2026-07-23, keel c69366b) — a keel PRESENTATION-WRAPPER key
|
|
3481
|
+
* (first-party rendering metadata, not part of the council-governed
|
|
3482
|
+
* OnlyWorlds standard). It cannot drift from the schema; membership and hex
|
|
3483
|
+
* invariants stay test-gated in `test/palette.test.mjs`.
|
|
3484
|
+
*
|
|
3485
|
+
* The hexes below are design constants, hand-authored beside the generated
|
|
3486
|
+
* map. Do not change any value without re-running the CVD validation (every
|
|
3487
|
+
* brighter World green collides with Temporal amber for protan viewers — the
|
|
3488
|
+
* green is pinned BY the accessibility budget).
|
|
3489
|
+
*
|
|
3490
|
+
* Provenance: first proven live in atlas (`src/core/element-colors.ts`) and
|
|
3491
|
+
* council (`src/cosmos/element-families.ts`) — both become re-exports of this
|
|
3492
|
+
* module.
|
|
3493
|
+
*/
|
|
3494
|
+
|
|
3495
|
+
/**
|
|
3496
|
+
* Family → validated hex per surface mode. `light` assumes near-white
|
|
3497
|
+
* surfaces, `dark` assumes near-black (measured against #0a0a0a).
|
|
3498
|
+
* World green is identical in both modes and sits at its low-contrast end
|
|
3499
|
+
* deliberately — see module header before "fixing" it.
|
|
3500
|
+
*/
|
|
3501
|
+
declare const FAMILY_COLORS: Record<ElementFamily, {
|
|
3502
|
+
light: string;
|
|
3503
|
+
dark: string;
|
|
3504
|
+
}>;
|
|
3505
|
+
/** Semantic family for an element type slug. */
|
|
3506
|
+
declare function familyOf(type: ElementType): ElementFamily;
|
|
3507
|
+
/**
|
|
3508
|
+
* The convenience most callers want: canonical colour for an element type.
|
|
3509
|
+
* Name matches the live atlas/council implementations so their SDK swap is a
|
|
3510
|
+
* re-export, not a rename. Defaults to `dark` (both current consumers are
|
|
3511
|
+
* dark-surface).
|
|
3512
|
+
*/
|
|
3513
|
+
declare function elementColor(type: ElementType, mode?: 'light' | 'dark'): string;
|
|
3514
|
+
/** All four families, in ruling order (the order IS the CVD-safety mechanism of the source palette). */
|
|
3515
|
+
declare const FAMILY_ORDER: readonly ElementFamily[];
|
|
3516
|
+
|
|
3517
|
+
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_FAMILIES, ELEMENT_ICONS, ELEMENT_LABELS, ELEMENT_SECTIONS, ELEMENT_TYPES, type ElementFamily, type ElementId, type ElementIds, ElementType$1 as ElementType, type EncryptionInfo, type Event, type EventInput, FAMILY_COLORS, FAMILY_ORDER, 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 ListParams, 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, OwApiError, type OwAuthErrorCode, type OwBulkItem, type OwBulkItemResult, type OwBulkResponse, type OwChange, type OwChangesPage, type OwClientConfig, type OwElement, type OwElementBase, type OwErrorBody, type OwKeyKind, type OwLinkEdit, OwNetworkError, type OwPage, OwV2Client, type OwWorldMeta, type Phenomenon, type PhenomenonInput, type Pin, type PinInput, type Relation, type RelationInput, type RevokeAllSessionsResponse, type RevokeSessionResponse, SPATIAL_TYPES, type SectionInfo, type Species, type SpeciesInput, type Title, type TitleInput, type TokenConsumeParams, type TokenConsumeResponse, type TokenStatus, type Trait, type TraitInput, type ElementType as V2ElementType, type World, type WorldInput, type Zone, type ZoneInput, createAnyElementId, createElementId, createElementIds, detectKeyKind, elementColor, errorFromResponse, familyOf, getElementIcon, getElementLabel, getElementSections, isDemoKey, kindCanWrite, parseEnvelope, pinExpectation };
|
package/dist/index.js
CHANGED
|
@@ -20,11 +20,14 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
20
20
|
// src/index.ts
|
|
21
21
|
var index_exports = {};
|
|
22
22
|
__export(index_exports, {
|
|
23
|
+
ELEMENT_FAMILIES: () => ELEMENT_FAMILIES,
|
|
23
24
|
ELEMENT_ICONS: () => ELEMENT_ICONS,
|
|
24
25
|
ELEMENT_LABELS: () => ELEMENT_LABELS,
|
|
25
26
|
ELEMENT_SECTIONS: () => ELEMENT_SECTIONS,
|
|
26
27
|
ELEMENT_TYPES: () => ELEMENT_TYPES,
|
|
27
28
|
ElementType: () => ElementType,
|
|
29
|
+
FAMILY_COLORS: () => FAMILY_COLORS,
|
|
30
|
+
FAMILY_ORDER: () => FAMILY_ORDER,
|
|
28
31
|
FIELD_SCHEMA: () => FIELD_SCHEMA,
|
|
29
32
|
GameTier: () => GameTier,
|
|
30
33
|
ONLYWORLDS_VERSION: () => ONLYWORLDS_VERSION,
|
|
@@ -37,7 +40,9 @@ __export(index_exports, {
|
|
|
37
40
|
createElementId: () => createElementId,
|
|
38
41
|
createElementIds: () => createElementIds,
|
|
39
42
|
detectKeyKind: () => detectKeyKind,
|
|
43
|
+
elementColor: () => elementColor,
|
|
40
44
|
errorFromResponse: () => errorFromResponse,
|
|
45
|
+
familyOf: () => familyOf,
|
|
41
46
|
getElementIcon: () => getElementIcon,
|
|
42
47
|
getElementLabel: () => getElementLabel,
|
|
43
48
|
getElementSections: () => getElementSections,
|
|
@@ -1550,16 +1555,58 @@ function buildQuery(params) {
|
|
|
1550
1555
|
|
|
1551
1556
|
// src/v2/types.generated.ts
|
|
1552
1557
|
var ELEMENT_TYPES = ["ability", "character", "collective", "construct", "creature", "event", "family", "institution", "language", "law", "location", "map", "marker", "narrative", "object", "phenomenon", "pin", "relation", "species", "title", "trait", "zone"];
|
|
1558
|
+
var ELEMENT_FAMILIES = {
|
|
1559
|
+
ability: "abstract",
|
|
1560
|
+
character: "agents",
|
|
1561
|
+
collective: "agents",
|
|
1562
|
+
construct: "world",
|
|
1563
|
+
creature: "agents",
|
|
1564
|
+
event: "temporal",
|
|
1565
|
+
family: "agents",
|
|
1566
|
+
institution: "agents",
|
|
1567
|
+
language: "abstract",
|
|
1568
|
+
law: "abstract",
|
|
1569
|
+
location: "world",
|
|
1570
|
+
map: "world",
|
|
1571
|
+
marker: "world",
|
|
1572
|
+
narrative: "temporal",
|
|
1573
|
+
object: "world",
|
|
1574
|
+
phenomenon: "temporal",
|
|
1575
|
+
pin: "world",
|
|
1576
|
+
relation: "temporal",
|
|
1577
|
+
species: "agents",
|
|
1578
|
+
title: "abstract",
|
|
1579
|
+
trait: "abstract",
|
|
1580
|
+
zone: "world"
|
|
1581
|
+
};
|
|
1553
1582
|
|
|
1554
1583
|
// src/v2/types.ts
|
|
1555
1584
|
var SPATIAL_TYPES = ["map", "pin", "marker", "zone"];
|
|
1585
|
+
|
|
1586
|
+
// src/v2/palette.ts
|
|
1587
|
+
var FAMILY_COLORS = {
|
|
1588
|
+
agents: { light: "#2a78d6", dark: "#3987e5" },
|
|
1589
|
+
world: { light: "#008300", dark: "#008300" },
|
|
1590
|
+
abstract: { light: "#e87ba4", dark: "#d55181" },
|
|
1591
|
+
temporal: { light: "#eda100", dark: "#c98500" }
|
|
1592
|
+
};
|
|
1593
|
+
function familyOf(type) {
|
|
1594
|
+
return ELEMENT_FAMILIES[type];
|
|
1595
|
+
}
|
|
1596
|
+
function elementColor(type, mode = "dark") {
|
|
1597
|
+
return FAMILY_COLORS[ELEMENT_FAMILIES[type]][mode];
|
|
1598
|
+
}
|
|
1599
|
+
var FAMILY_ORDER = ["agents", "world", "abstract", "temporal"];
|
|
1556
1600
|
// Annotate the CommonJS export names for ESM import in node:
|
|
1557
1601
|
0 && (module.exports = {
|
|
1602
|
+
ELEMENT_FAMILIES,
|
|
1558
1603
|
ELEMENT_ICONS,
|
|
1559
1604
|
ELEMENT_LABELS,
|
|
1560
1605
|
ELEMENT_SECTIONS,
|
|
1561
1606
|
ELEMENT_TYPES,
|
|
1562
1607
|
ElementType,
|
|
1608
|
+
FAMILY_COLORS,
|
|
1609
|
+
FAMILY_ORDER,
|
|
1563
1610
|
FIELD_SCHEMA,
|
|
1564
1611
|
GameTier,
|
|
1565
1612
|
ONLYWORLDS_VERSION,
|
|
@@ -1572,7 +1619,9 @@ var SPATIAL_TYPES = ["map", "pin", "marker", "zone"];
|
|
|
1572
1619
|
createElementId,
|
|
1573
1620
|
createElementIds,
|
|
1574
1621
|
detectKeyKind,
|
|
1622
|
+
elementColor,
|
|
1575
1623
|
errorFromResponse,
|
|
1624
|
+
familyOf,
|
|
1576
1625
|
getElementIcon,
|
|
1577
1626
|
getElementLabel,
|
|
1578
1627
|
getElementSections,
|
package/dist/index.mjs
CHANGED
|
@@ -1500,15 +1500,57 @@ function buildQuery(params) {
|
|
|
1500
1500
|
|
|
1501
1501
|
// src/v2/types.generated.ts
|
|
1502
1502
|
var ELEMENT_TYPES = ["ability", "character", "collective", "construct", "creature", "event", "family", "institution", "language", "law", "location", "map", "marker", "narrative", "object", "phenomenon", "pin", "relation", "species", "title", "trait", "zone"];
|
|
1503
|
+
var ELEMENT_FAMILIES = {
|
|
1504
|
+
ability: "abstract",
|
|
1505
|
+
character: "agents",
|
|
1506
|
+
collective: "agents",
|
|
1507
|
+
construct: "world",
|
|
1508
|
+
creature: "agents",
|
|
1509
|
+
event: "temporal",
|
|
1510
|
+
family: "agents",
|
|
1511
|
+
institution: "agents",
|
|
1512
|
+
language: "abstract",
|
|
1513
|
+
law: "abstract",
|
|
1514
|
+
location: "world",
|
|
1515
|
+
map: "world",
|
|
1516
|
+
marker: "world",
|
|
1517
|
+
narrative: "temporal",
|
|
1518
|
+
object: "world",
|
|
1519
|
+
phenomenon: "temporal",
|
|
1520
|
+
pin: "world",
|
|
1521
|
+
relation: "temporal",
|
|
1522
|
+
species: "agents",
|
|
1523
|
+
title: "abstract",
|
|
1524
|
+
trait: "abstract",
|
|
1525
|
+
zone: "world"
|
|
1526
|
+
};
|
|
1503
1527
|
|
|
1504
1528
|
// src/v2/types.ts
|
|
1505
1529
|
var SPATIAL_TYPES = ["map", "pin", "marker", "zone"];
|
|
1530
|
+
|
|
1531
|
+
// src/v2/palette.ts
|
|
1532
|
+
var FAMILY_COLORS = {
|
|
1533
|
+
agents: { light: "#2a78d6", dark: "#3987e5" },
|
|
1534
|
+
world: { light: "#008300", dark: "#008300" },
|
|
1535
|
+
abstract: { light: "#e87ba4", dark: "#d55181" },
|
|
1536
|
+
temporal: { light: "#eda100", dark: "#c98500" }
|
|
1537
|
+
};
|
|
1538
|
+
function familyOf(type) {
|
|
1539
|
+
return ELEMENT_FAMILIES[type];
|
|
1540
|
+
}
|
|
1541
|
+
function elementColor(type, mode = "dark") {
|
|
1542
|
+
return FAMILY_COLORS[ELEMENT_FAMILIES[type]][mode];
|
|
1543
|
+
}
|
|
1544
|
+
var FAMILY_ORDER = ["agents", "world", "abstract", "temporal"];
|
|
1506
1545
|
export {
|
|
1546
|
+
ELEMENT_FAMILIES,
|
|
1507
1547
|
ELEMENT_ICONS,
|
|
1508
1548
|
ELEMENT_LABELS,
|
|
1509
1549
|
ELEMENT_SECTIONS,
|
|
1510
1550
|
ELEMENT_TYPES,
|
|
1511
1551
|
ElementType,
|
|
1552
|
+
FAMILY_COLORS,
|
|
1553
|
+
FAMILY_ORDER,
|
|
1512
1554
|
FIELD_SCHEMA,
|
|
1513
1555
|
GameTier,
|
|
1514
1556
|
ONLYWORLDS_VERSION,
|
|
@@ -1521,7 +1563,9 @@ export {
|
|
|
1521
1563
|
createElementId,
|
|
1522
1564
|
createElementIds,
|
|
1523
1565
|
detectKeyKind,
|
|
1566
|
+
elementColor,
|
|
1524
1567
|
errorFromResponse,
|
|
1568
|
+
familyOf,
|
|
1525
1569
|
getElementIcon,
|
|
1526
1570
|
getElementLabel,
|
|
1527
1571
|
getElementSections,
|
package/package.json
CHANGED
|
@@ -1,19 +1,23 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@onlyworlds/sdk",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.1.0",
|
|
4
4
|
"description": "TypeScript SDK for the OnlyWorlds API - build world-building applications with type safety",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.mjs",
|
|
7
7
|
"types": "dist/index.d.ts",
|
|
8
8
|
"files": [
|
|
9
9
|
"dist",
|
|
10
|
-
"README.md"
|
|
10
|
+
"README.md",
|
|
11
|
+
"AGENTS.md",
|
|
12
|
+
"CHANGELOG.md"
|
|
11
13
|
],
|
|
12
14
|
"scripts": {
|
|
13
15
|
"build": "tsup src/index.ts --format cjs,esm --dts --clean",
|
|
14
16
|
"dev": "tsup src/index.ts --format cjs,esm --dts --watch",
|
|
15
17
|
"pretest": "npm run build",
|
|
16
18
|
"test": "node --test \"test/**/*.test.mjs\"",
|
|
19
|
+
"codegen": "python codegen/generate_types.py",
|
|
20
|
+
"codegen:check": "python codegen/generate_types.py --check",
|
|
17
21
|
"prepublishOnly": "npm run build"
|
|
18
22
|
},
|
|
19
23
|
"keywords": [
|