@onlyworlds/sdk 4.0.1 → 4.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/AGENTS.md CHANGED
@@ -1,34 +1,48 @@
1
- # For AI agents using @onlyworlds/sdk
2
-
3
- **Start with [SCHEMA.md](SCHEMA.md)** (in this package): the full generated schema reference —
4
- every type, every field with its meaning, link directions, families, icons, display sections.
5
- It is generated from the same canonical YAML as the types, so it cannot drift.
6
-
7
- **What this package is**: the canonical typed TypeScript client for the OnlyWorlds v2 API,
8
- plus the canonical constants (element types, icons, colour families, field schema).
9
- OnlyWorlds is an open standard for portable world data — 22 element types, UUID-linked.
10
-
11
- **Use the v2 surface.** `OwV2Client` + the `V2ElementType` slug union + the generated
12
- interfaces in `types.generated.ts` (emitted from the canonical schema YAML, validated
13
- against live data). The v1 surface (`OnlyWorldsClient`, the `ElementType` enum) is frozen
14
- legacy — do not build new work on it.
15
-
16
- **SDK vs MCP server — pick correctly**:
17
- - Known, deterministic operations (CRUD, sync, bulk) → **this SDK**. Typed calls, typed
18
- responses, far cheaper than tool-schema reasoning.
19
- - Live exploration of a user's world from a chat/agent context → the **MCP server** at
20
- `https://www.onlyworlds.com/mcp` (same `API-Key`/`API-Pin` headers, 11 tools).
21
-
22
- **Wire facts that bite** (full details in README):
23
- - Never send a `"world"` field in payloads — world identity comes from the API key (422 otherwise).
24
- - v2 link fields use ONE name both directions (no `_ids` suffix — that is v1 dialect only).
25
- - PATCH is destructive on sent fields; use `editLinks` (atomic add/remove) for relationships.
26
- - World-meta changes do NOT appear in `/changes` — poll `GET /world` separately.
27
- - Extension fields: `x_<toolname>_*` is the sanctioned namespace for tool-specific state;
28
- unknown unprefixed fields 422.
29
- - Colour carries the element's FAMILY (`elementColor(type, mode)`); the icon
30
- (`ELEMENT_ICONS`) carries the TYPE. Icon + label are required alongside colour, not optional.
31
-
32
- **Auth**: prefixed keys — `ow_w_` (read+write), `ow_r_` (read-only, no PIN — the share
33
- primitive), `ow_a_` (account Bearer). Demo keys `0000000000`–`0000000009` are read-only
34
- test credentials against real data.
1
+ # For AI agents using @onlyworlds/sdk
2
+
3
+ **Current as of**: SDK **4.x** · schema-dist **v0.30.1-dist.15** (canonical 00.30.01).
4
+ This line is asserted by `codegen:check` in CI — if the pin moves and this file is not
5
+ re-read against it, the check fails rather than letting this document rot quietly.
6
+
7
+ **Start with [SCHEMA.md](SCHEMA.md)** (in this package): the full generated schema reference —
8
+ every type, every field with its meaning, link directions, families, icons, display sections.
9
+ It is generated from the same canonical YAML as the types, so it cannot drift.
10
+
11
+ **What this package is**: the canonical typed TypeScript client for the OnlyWorlds v2 API,
12
+ plus the canonical constants (element types, icons, colour families, field schema).
13
+ OnlyWorlds is an open standard for portable world data — 22 element types, UUID-linked.
14
+
15
+ **Use the v2 surface.** `OwV2Client` + the `V2ElementType` slug union + the generated
16
+ interfaces in `types.generated.ts` (emitted from the canonical schema YAML, validated
17
+ against live data). The v1 surface (`OnlyWorldsClient`, the `ElementType` enum) is not in
18
+ 4.x — it was removed at 4.0.0 and lives only in 3.x. Do not build new work on it.
19
+
20
+ **SDK vs MCP server — pick correctly**:
21
+ - Known, deterministic operations (CRUD, sync, bulk) → **this SDK**. Typed calls, typed
22
+ responses, far cheaper than tool-schema reasoning.
23
+ - Live exploration of a user's world from a chat/agent context → the **MCP server** at
24
+ `https://www.onlyworlds.com/mcp` (same `API-Key`/`API-Pin` headers, 11 tools).
25
+
26
+ **Wire facts that bite** (full details in README):
27
+ - Never send a `"world"` field in payloads — world identity comes from the API key (422 otherwise).
28
+ - v2 link fields use ONE name both directions (no `_ids` suffix — that is v1 dialect only).
29
+ - PATCH is destructive on sent fields; use `editLinks` (atomic add/remove) for relationships.
30
+ - World-meta changes do NOT appear in `/changes` — poll `GET /world` separately.
31
+ - Extension fields: `x_<toolname>_*` is the sanctioned namespace for tool-specific state;
32
+ unknown unprefixed fields 422. Extensions are capped at **64 KB per element** (422,
33
+ `param: extensions`).
34
+ - List filters: only `name__icontains`, `supertype` and `subtype` are built. Any other
35
+ filter key — and `?ordering=` — returns 422 naming it. Filter or sort client-side.
36
+ - Ids: the client mints **UUIDv7** on an id-less `create` (since 4.2.0; keel mints v7 too).
37
+ A v4 or v7 id you supply is accepted. **Never sort elements by id**: worlds mix v7, v4
38
+ and legacy `06x…` ids (nibble 7 too, but seconds-first). For creation order use
39
+ `created_at`; `change_seq` is last-write order, not creation.
40
+ A PUT or bulk item whose id belongs to **another world** returns 409 `id_conflict`.
41
+ - A string holding an unpaired surrogate (text cut mid-emoji) is a 422 naming the field.
42
+ Slice strings by code point, not by UTF-16 unit.
43
+ - Colour carries the element's FAMILY (`elementColor(type, mode)`); the icon
44
+ (`ELEMENT_ICONS`) carries the TYPE. Icon + label are required alongside colour, not optional.
45
+
46
+ **Auth**: prefixed keys — `ow_w_` (read+write), `ow_r_` (read-only, no PIN — the share
47
+ primitive), `ow_a_` (account Bearer). Demo keys `0000000000`–`0000000009` are read-only
48
+ test credentials against real data.
package/CHANGELOG.md CHANGED
@@ -3,6 +3,118 @@
3
3
  All notable changes to `@onlyworlds/sdk`. Maintained from 3.1.0 onward (Kael, Assembly);
4
4
  earlier history lives in git log only.
5
5
 
6
+ ## [Unreleased]
7
+
8
+ ## [4.2.0] — staged 2026-09-28, not yet published
9
+
10
+ Ids, honest filter docs, and the schema repin. Nothing is removed; no call needs to change.
11
+
12
+ ### Changed
13
+ - **`create()` now mints an RFC 9562 UUIDv7** when the element has no id (was v4). The first
14
+ 48 bits are the creation millisecond, so ids this client mints a millisecond or more apart
15
+ sort by creation (while the clock does not step backwards), which gives databases better
16
+ index locality. **This holds within one client only**: worlds also hold v4 ids and legacy
17
+ v1-server ids (`06x…`, which also carry version nibble 7 but put seconds first), so never
18
+ order elements by id. For creation order use `created_at`; `change_seq` is last-write
19
+ order. This is a **default, not a
20
+ requirement**: a v4 or v7 id a caller supplies is still accepted as-is, and
21
+ every id already stored stays valid. Keel mints v7 server-side too (Captain's ruling,
22
+ 2026-09-28). Pinned by six tests: version and variant, the big-endian timestamp above
23
+ bit 32, fractional and pre-1970 clocks floored consistently, creation order across 50
24
+ consecutive milliseconds, 1,000 distinct ids inside one millisecond, and the no-`crypto`
25
+ fallback (asserting `Math.random` is actually used). Five injected defects (v4 nibble,
26
+ 32-bit truncation, a dropped random fill, a dropped variant mask, an unfloored clock)
27
+ each fail the suite on every run, on Node 20 and 22. An independent reviewer's decoder agreed on 20,000 random timestamps and the 48-bit
28
+ edges, and keel's `uuid7()` agrees on timestamp, version and variant for a pinned clock.
29
+ - **`elementColor()` on an unknown type now throws a `TypeError` that names the type.** It
30
+ used to crash with `Cannot read properties of undefined (reading 'dark')`. Found while
31
+ building the Forge's colour gate: atlas's own copy falls back to the `world` family for an
32
+ unknown type, so swapping it for this export is not a pure re-export for that input, and the
33
+ docstring now says so. Whether the package should fall back is left to its consumers.
34
+ - The generated field-schema comment no longer calls `maximum:` an open question or counts
35
+ its occurrences (the count was 41; since 00.30.01 it is 15). The question was ruled on
36
+ 2026-07-29.
37
+ - **`ListParams.filter` JSDoc names what the server actually accepts**: `name__icontains`,
38
+ `supertype`, `subtype`. It used to list `__in`, `__gte`, `__lte` and `__isnull`, copied
39
+ from keel's spec, which described them but never built them. Probed live 2026-09-28: the
40
+ three accepted keys answer 200; every other one, and `?ordering=`, answers 422.
41
+ - **Schema repinned `v0.30.1-dist.13` → `v0.30.1-dist.15`** (canonical unchanged, 00.30.01).
42
+ Two generated values move: `ELEMENT_ICONS.institution` `business` → `account_balance`,
43
+ `ELEMENT_ICONS.marker` `place` → `location_on` (both Material Symbols names). dist.15
44
+ also adds `minimum: 0` to `ability.potency`; the walk does not surface bounds, so nothing
45
+ generated changes for it. 31/31 file hashes recomputed from a fresh download.
46
+ - **`AGENTS.md` re-read against the new pin** (its gate fired on the repin, as designed).
47
+ It still called the v1 client "frozen legacy" in this package; v1 was removed at 4.0.0.
48
+ It now also names the wire behaviours keel deployed on 2026-09-28 (keel D70): the 64 KB
49
+ extension cap, the three built filters and the `?ordering=` 422, 409 `id_conflict` for a
50
+ PUT or bulk id that belongs to another world, and the 422 for unpaired surrogates. None of
51
+ them needs client code.
52
+
53
+ ### Also in this release (staged earlier)
54
+ - **`SCHEMA.md` now opens with its own provenance** (dist tag, canonical version, publish
55
+ date — rendered from `schema-pin.json`, never the wall clock). It ships in the tarball
56
+ and is read cold by agents outside this repo, where the pin file is not present; a
57
+ generated reference that cannot name its source was the one remaining self-dating gap.
58
+ - **`AGENTS.md` carries a "Current as of" line, asserted by `codegen:check`** — the tag it
59
+ names must match the pin or CI fails. A hand-maintained agent doc with an ungated date
60
+ is how this repo's previous agent doc went a major version stale. Gate watched firing
61
+ (tampered tag → exit 1, restored → 0).
62
+
63
+ ## [4.1.0] — 2026-07-29
64
+
65
+ Public-surface hygiene. Nothing breaks; one member is now marked for removal, and one
66
+ piece of long-standing speculation is retired by measurement.
67
+
68
+ ⚑ **4.0.2 was tagged in git and superseded before it reached npm.** Everything in it ships
69
+ here — the tag stays as a record rather than being moved or deleted.
70
+
71
+ ### Deprecated
72
+ - **`FieldType.integer_max` and `FieldInfo.max`** — removal scheduled for **5.0.0**. No
73
+ `FIELD_SCHEMA` entry has ever carried either, in this repository's entire history. They
74
+ existed to surface the schema's `maximum:` constraint, and that constraint is **advisory**:
75
+ keel declares no `MaxValueValidator`, and a `charisma: 9999` write against a `maximum: 100`
76
+ field returns 201 and stores it verbatim. The canonical schema walk therefore stays silent
77
+ on bounds permanently. There is no source to wire them to and no promise they could keep —
78
+ and a public type member meaning "hint the wire ignores" is one consumers read as
79
+ validation. Deprecating now rather than at the major so the signal arrives early; the
80
+ `@deprecated` tags surface in editors via the shipped `.d.ts`.
81
+
82
+ ### Changed
83
+ - **`TokenResource` is confirmed staying.** RFC-001 §5 asked the platform owner whether the
84
+ token routes were carried long-term or deprecated wire-side, and the question was never
85
+ answered in writing — so this package's own barrel carried "wire fate under review; may be
86
+ removed in a later 4.x" for months, on nobody's authority. Probed against production:
87
+ `GET /api/v2/tokens/status/` and `/tokens/encryption-info/` both return **200**, with a 404
88
+ control on a nonexistent route proving the check meant something. The wire carries it. The
89
+ speculation is retired and the comment now records the evidence instead.
90
+
91
+ ## [4.0.2] — 2026-07-29
92
+
93
+ Re-pinned to `v0.30.1-dist.13` (canonical **00.30.01**). No field shape changed and no
94
+ `FIELD_SCHEMA` entry changed — the schema walk is byte-identical between the two pins, so
95
+ nothing about decoding moved. Three things changed and nothing else.
96
+
97
+ ### Fixed
98
+ - **`construct.relations` and `event.languages` shipped with no description at all** — in
99
+ `types.generated.ts` and in `SCHEMA.md`. Their descriptions were nested one level too deep
100
+ inside `items:` in the canonical YAML, which made them invisible to every consumer that reads
101
+ field descriptions, this package included. `SCHEMA.md` is the package's AI-legibility artifact,
102
+ so the gap landed where it did the most harm.
103
+ - **Five description typos** corrected in published JSDoc and `SCHEMA.md`: `beapplied`,
104
+ `phyiscal`, `relating the`, `object grant`, `eventuated`. The rendered docs site had already
105
+ fixed all five by hand — the downstream copy was the correct one, and nobody noticed because
106
+ the fix went where it was visible rather than where it was true.
107
+
108
+ ### Changed
109
+ - `ONLYWORLDS_VERSION` `'00.30.00'` → `'00.30.01'`. It is a public `as const`, so its **literal
110
+ type** changes. Depending on that literal is pathological, but it is a type-level change and
111
+ should not be discovered rather than announced.
112
+ - The pin now carries canonical's numeric-bounds correction: the `maximum: 0` sentinel is gone
113
+ from 26 fields, 8 fields gained `minimum: 0`, and `rulings.yaml` carries the numeric-bounds
114
+ row. Nothing in this package consumes bounds — `maximum:` is **advisory** (keel does not
115
+ enforce it; a `charisma: 9999` write returns 201 and stores verbatim) and the walk stays
116
+ silent on bounds permanently. `integer_max` / `max` therefore remain declared no-ops here.
117
+
6
118
  ## [4.0.1] — 2026-07-29
7
119
 
8
120
  **Metadata correction release.** No wire-path change: the client's reads and writes never
package/SCHEMA.md CHANGED
@@ -1,5 +1,7 @@
1
1
  # OnlyWorlds Schema Reference
2
2
 
3
+ **Source**: https://github.com/OnlyWorlds/schema-dist @ **v0.30.1-dist.15** — canonical schema **00.30.01**, published 2026-09-18.
4
+
3
5
  GENERATED from the canonical schema YAML — do not hand-edit (regenerate: `python codegen/generate_types.py`).
4
6
  Written for both humans and AI agents reading this package locally.
5
7
 
@@ -149,7 +151,7 @@ Families (colour semantics; icon carries the type): agents · world · abstract
149
151
  - `phenomena` (multi link → phenomenon) — Phenomena relevant to the construct
150
152
  - `languages` (multi link → language) — Languages relevant to the construct
151
153
  - `families` (multi link → family) — Families relevant to the construct
152
- - `relations` (multi link → relation)
154
+ - `relations` (multi link → relation) — Relations relevant to the construct
153
155
  - `titles` (multi link → title) — Titles relevant to the construct
154
156
  - `constructs` (multi link → construct) — Other constructs relevant to the construct
155
157
  - `events` (multi link → event) — Events relevant to the construct
@@ -200,7 +202,7 @@ Families (colour semantics; icon carries the type): agents · world · abstract
200
202
  - `consequences` (text) — Outcomes and impacts resulting from the event
201
203
  - `start_date` (integer) — Date on which the event began
202
204
  - `end_date` (integer) — Date on which the event concluded
203
- - `triggers` (multi link → event) — Events that eventuated the event
205
+ - `triggers` (multi link → event) — Events that precipitated this event
204
206
 
205
207
  ### Involves
206
208
 
@@ -215,7 +217,7 @@ Families (colour semantics; icon carries the type): agents · world · abstract
215
217
  - `zones` (multi link → zone) — Zones relevant to the event
216
218
  - `abilities` (multi link → ability) — Abilities relevant to the event
217
219
  - `phenomena` (multi link → phenomenon) — Natural or supernatural phenomena relevant to the event
218
- - `languages` (multi link → language)
220
+ - `languages` (multi link → language) — Languages relevant to the event
219
221
  - `families` (multi link → family) — Families relevant to the event
220
222
  - `relations` (multi link → relation) — Interpersonal or political relations relevant to the event
221
223
  - `titles` (multi link → title) — Titles relevant to the event
@@ -244,7 +246,7 @@ Families (colour semantics; icon carries the type): agents · world · abstract
244
246
  - `creatures` (multi link → creature) — Creatures owned, bonded to, or representing the family
245
247
 
246
248
 
247
- ## institution · family: agents · icon: business
249
+ ## institution · family: agents · icon: account_balance
248
250
 
249
251
 
250
252
  ### Foundation
@@ -294,7 +296,7 @@ Families (colour semantics; icon carries the type): agents · world · abstract
294
296
  - `purpose` (text) — The intent, motivation, or justification for the law's creation
295
297
  - `date` (integer) — Date the law was formally established, in world TIME units
296
298
  - `parent_law` (single link → law) — A law that this law derives from, modifies, or enhances
297
- - `penalties` (multi link → construct) — Consequences intended to beapplied when the law is contravened
299
+ - `penalties` (multi link → construct) — Consequences intended to be applied when the law is contravened
298
300
 
299
301
  ### World
300
302
 
@@ -376,7 +378,7 @@ Families (colour semantics; icon carries the type): agents · world · abstract
376
378
  - `location` (single link → location) — Location element that this map represents
377
379
 
378
380
 
379
- ## marker · family: world · icon: place
381
+ ## marker · family: world · icon: location_on
380
382
 
381
383
 
382
384
  ### Details
@@ -436,14 +438,14 @@ Families (colour semantics; icon carries the type): agents · world · abstract
436
438
  - `weight` (integer) — Approximate or exact mass of the object, defined by world MASS units
437
439
  - `amount` (integer) — The number of identical units in this object entry
438
440
  - `parent_object` (single link → object) — Larger object that this one is part of or contained within
439
- - `materials` (multi link → construct) — The phyiscal matter that constitutes the object
440
- - `technology` (multi link → construct) — Mechanisms relating the object's design or operation
441
+ - `materials` (multi link → construct) — The physical matter that constitutes the object
442
+ - `technology` (multi link → construct) — Mechanisms relating to the object's design or operation
441
443
 
442
444
  ### Function
443
445
 
444
446
  - `utility` (text) — Intended purpose or primary use of the object
445
447
  - `effects` (multi link → phenomenon) — Phenomena potentially triggered or emitted on object use
446
- - `abilities` (multi link → ability) — Abilities that the object grant or enables
448
+ - `abilities` (multi link → ability) — Abilities that the object grants or enables
447
449
  - `consumes` (multi link → construct) — What might be used or depleted on object use
448
450
 
449
451
  ### World
package/dist/index.d.ts CHANGED
@@ -1,9 +1,12 @@
1
1
  /** Every element carries these. The extension index signature admits namespaced
2
- * pass-through fields (atlas_* / shadow_* / x_*) returned verbatim by the server. */
2
+ * pass-through fields (atlas_* / shadow_* / x_*) returned verbatim by the server.
3
+ * Derived from base_properties.yaml: `World` is dropped (the API rejects it in
4
+ * bodies -- the key determines the world) and the four server-managed fields are
5
+ * added, since they ride every wire body and appear in no element YAML. */
3
6
  interface OwElementBase {
4
7
  /** Element type slug (server-managed, read-only). */
5
8
  type: string;
6
- /** Unique identifier, uuidv7 format. */
9
+ /** Unique identifier for the element, uuidv7 format. */
7
10
  id: string;
8
11
  /** Name of the element. */
9
12
  name: string;
@@ -28,7 +31,7 @@ type ElementType = 'ability' | 'character' | 'collective' | 'construct' | 'creat
28
31
  declare const ELEMENT_TYPES: ElementType[];
29
32
  /** Canonical OnlyWorlds schema version. Source: the `canonical:` value of the pinned
30
33
  * distribution's VERSION file (see the provenance block at the top of this file). */
31
- declare const ONLYWORLDS_VERSION: "00.30.00";
34
+ declare const ONLYWORLDS_VERSION: "00.30.01";
32
35
  /** The four semantic families (colour carries the family; ELEMENT_ICONS carries the type). */
33
36
  type ElementFamily = 'agents' | 'world' | 'abstract' | 'temporal';
34
37
  /** Per-type semantic family. Source: the distribution's `presentation.json` sidecar
@@ -47,11 +50,24 @@ interface SectionInfo {
47
50
  }
48
51
  declare const ELEMENT_SECTIONS: Record<ElementType, SectionInfo[]>;
49
52
  /** Field type definitions for OnlyWorlds elements. */
50
- type FieldType = 'text' | 'integer' | 'integer_max' | 'single_link' | 'multi_link';
53
+ type FieldType = 'text' | 'integer'
54
+ /**
55
+ * @deprecated Emitted by nothing, and scheduled for removal in 5.0.0.
56
+ *
57
+ * No `FIELD_SCHEMA` entry has ever carried this type, in the entire history of
58
+ * this repository. It was meant to surface the schema's `maximum:` constraint,
59
+ * and that constraint is **advisory**: keel declares no `MaxValueValidator` and
60
+ * the wire stores `charisma: 9999` against a `maximum: 100` field (201, verbatim).
61
+ * The canonical schema walk therefore stays silent on bounds permanently, so
62
+ * there is no source to wire this to and no promise it could keep. A public type
63
+ * member meaning "hint the wire ignores" is one consumers read as validation.
64
+ */
65
+ | 'integer_max' | 'single_link' | 'multi_link';
51
66
  /** Field metadata structure. */
52
67
  interface FieldInfo {
53
68
  type: FieldType;
54
69
  target?: string;
70
+ /** @deprecated Never populated; removed in 5.0.0. See `FieldType.integer_max`. */
55
71
  max?: number;
56
72
  required?: boolean;
57
73
  }
@@ -1942,9 +1958,10 @@ interface ListParams {
1942
1958
  /** Sparse include-set of field names. */
1943
1959
  fields?: string[];
1944
1960
  /**
1945
- * Blessed Django-style filters: __icontains, __in, __gte, __lte, __isnull,
1946
- * supertype/subtype equality. Unknown params 422 loudly server-side -- the
1947
- * client passes them through and lets the platform name the typo.
1961
+ * Accepted: `name__icontains`, `supertype`, `subtype`. Any other key 422s
1962
+ * server-side, which names the typo -- the client passes keys through
1963
+ * unchecked and lets the platform say so. (`__in`, `__gte`, `__lte` and
1964
+ * `__isnull` are designed in keel's spec but not built; `ordering` 422s too.)
1948
1965
  */
1949
1966
  filter?: Record<string, string | number | boolean>;
1950
1967
  }
@@ -2083,7 +2100,7 @@ declare class OwV2Client {
2083
2100
  /** GET /{type}/{id}/ -- optional one-level stub expansion / sparse fields. */
2084
2101
  get(type: ElementType | string, id: string, opts?: Pick<ListParams, 'expand' | 'fields'>): Promise<OwElement>;
2085
2102
  /**
2086
- * POST /{type}/ -- create. Mints an RFC-4122 UUID for element.id when the
2103
+ * POST /{type}/ -- create. Mints an RFC 9562 UUIDv7 for element.id when the
2087
2104
  * caller omits one (design ruling D29d) so a retry carrying the same
2088
2105
  * Idempotency-Key is structurally safe. Callers MAY still supply their own id.
2089
2106
  */
@@ -2207,6 +2224,13 @@ declare function familyOf(type: ElementType): ElementFamily;
2207
2224
  * Name matches the live atlas/council implementations so their SDK swap is a
2208
2225
  * re-export, not a rename. Defaults to `dark` (both current consumers are
2209
2226
  * dark-surface).
2227
+ *
2228
+ * An unknown type throws a TypeError naming it (since 4.2.0; before, it crashed
2229
+ * with "Cannot read properties of undefined"). This is the one place a swap from
2230
+ * atlas's own copy is NOT a pure re-export: atlas falls back to the `world`
2231
+ * family for an unknown type. A caller that wants a fallback catches, or checks
2232
+ * `type in ELEMENT_FAMILIES` first; which fallback, if any, is a design call
2233
+ * this package does not make for its consumers.
2210
2234
  */
2211
2235
  declare function elementColor(type: ElementType, mode?: 'light' | 'dark'): string;
2212
2236
  /** All four families, in ruling order (the order IS the CVD-safety mechanism of the source palette). */
package/dist/index.js CHANGED
@@ -143,7 +143,7 @@ var OwV2Client = class {
143
143
  return this.request("GET", `/${type}/${id}/`, { query });
144
144
  }
145
145
  /**
146
- * POST /{type}/ -- create. Mints an RFC-4122 UUID for element.id when the
146
+ * POST /{type}/ -- create. Mints an RFC 9562 UUIDv7 for element.id when the
147
147
  * caller omits one (design ruling D29d) so a retry carrying the same
148
148
  * Idempotency-Key is structurally safe. Callers MAY still supply their own id.
149
149
  */
@@ -289,16 +289,22 @@ function readReplayHeader(headers) {
289
289
  const v = headers.get("Idempotent-Replay");
290
290
  return v != null && v.toLowerCase() === "true";
291
291
  }
292
- function mintUuid() {
292
+ function mintUuid(now = Date.now()) {
293
293
  const c = globalThis.crypto;
294
- if (c && typeof c.randomUUID === "function") return c.randomUUID();
295
294
  const bytes = new Uint8Array(16);
296
295
  if (c && typeof c.getRandomValues === "function") {
297
296
  c.getRandomValues(bytes);
298
297
  } else {
299
298
  for (let i = 0; i < 16; i++) bytes[i] = Math.floor(Math.random() * 256);
300
299
  }
301
- bytes[6] = bytes[6] & 15 | 64;
300
+ const ms = Math.floor(now);
301
+ bytes[0] = Math.floor(ms / 2 ** 40) & 255;
302
+ bytes[1] = Math.floor(ms / 2 ** 32) & 255;
303
+ bytes[2] = ms >>> 24 & 255;
304
+ bytes[3] = ms >>> 16 & 255;
305
+ bytes[4] = ms >>> 8 & 255;
306
+ bytes[5] = ms & 255;
307
+ bytes[6] = bytes[6] & 15 | 112;
302
308
  bytes[8] = bytes[8] & 63 | 128;
303
309
  const hex = [];
304
310
  for (let i = 0; i < 256; i++) hex.push((i + 256).toString(16).slice(1));
@@ -314,7 +320,7 @@ function buildQuery(params) {
314
320
 
315
321
  // src/v2/types.generated.ts
316
322
  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"];
317
- var ONLYWORLDS_VERSION = "00.30.00";
323
+ var ONLYWORLDS_VERSION = "00.30.01";
318
324
  var ELEMENT_FAMILIES = {
319
325
  ability: "abstract",
320
326
  character: "agents",
@@ -347,12 +353,12 @@ var ELEMENT_ICONS = {
347
353
  creature: "bug_report",
348
354
  event: "saved_search",
349
355
  family: "supervisor_account",
350
- institution: "business",
356
+ institution: "account_balance",
351
357
  language: "edit_road",
352
358
  law: "gpp_bad",
353
359
  location: "castle",
354
360
  map: "map",
355
- marker: "place",
361
+ marker: "location_on",
356
362
  narrative: "menu_book",
357
363
  object: "webhook",
358
364
  phenomenon: "thunderstorm",
@@ -1072,7 +1078,9 @@ function familyOf(type) {
1072
1078
  return ELEMENT_FAMILIES[type];
1073
1079
  }
1074
1080
  function elementColor(type, mode = "dark") {
1075
- return FAMILY_COLORS[ELEMENT_FAMILIES[type]][mode];
1081
+ const family = ELEMENT_FAMILIES[type];
1082
+ if (family === void 0) throw new TypeError(`elementColor: unknown element type "${String(type)}"`);
1083
+ return FAMILY_COLORS[family][mode];
1076
1084
  }
1077
1085
  var FAMILY_ORDER = ["agents", "world", "abstract", "temporal"];
1078
1086
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@onlyworlds/sdk",
3
- "version": "4.0.1",
3
+ "version": "4.2.0",
4
4
  "description": "TypeScript SDK for the OnlyWorlds API - build world-building applications with type safety",
5
5
  "type": "module",
6
6
  "exports": {
@@ -28,7 +28,8 @@
28
28
  "codegen:check": "python codegen/generate_types.py --check",
29
29
  "schema:verify": "python codegen/verify_dist.py",
30
30
  "schema:check": "npm run schema:verify && npm run codegen:check",
31
- "prepublishOnly": "npm run build"
31
+ "prepublishOnly": "npm run build",
32
+ "release:verify": "node codegen/verify_release.mjs"
32
33
  },
33
34
  "keywords": [
34
35
  "onlyworlds",