@onlyworlds/sdk 4.39.0 → 4.41.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 +8 -1
- package/CHANGELOG.md +39 -0
- package/README.md +1 -0
- package/SCHEMA.md +3 -1
- package/dist/index.d.ts +59 -3
- package/dist/index.js +56 -2
- package/package.json +1 -1
package/AGENTS.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# For AI agents using @onlyworlds/sdk
|
|
2
2
|
|
|
3
|
-
**Current as of**: SDK **4.x** · schema-dist **v0.32.1-dist.
|
|
3
|
+
**Current as of**: SDK **4.x** · schema-dist **v0.32.1-dist.28** (canonical 00.32.01).
|
|
4
4
|
This line is asserted by `codegen:check` in CI — if the pin moves and this file is not
|
|
5
5
|
re-read against it, the check fails rather than letting this document rot quietly.
|
|
6
6
|
|
|
@@ -106,6 +106,13 @@ against live data). The v1 surface (`OnlyWorldsClient`, the `ElementType` enum)
|
|
|
106
106
|
`mcp`, `declared`, `api`, `v1`, `sync`, `server`), and a `/changes` delete carries
|
|
107
107
|
`deleted_by` and `deleted_via`; `isAgentDoor(door)` is true for the first three. An agent
|
|
108
108
|
seat's key is recorded as an agent without the option. Never set it in a tool people use.
|
|
109
|
+
- A guest or player reads what its own Character's sheet links to as a **stub**, marked
|
|
110
|
+
`known_of: true` (`isKnownOf(el)`): only `id`, `type`, `name`, `description`, `supertype`,
|
|
111
|
+
`subtype`, `image_url`, the timestamps and the fields its type lists in `PUBLIC_FIELDS` are
|
|
112
|
+
real; every other field reads unset, and its files are 404. Render it as known of, never
|
|
113
|
+
merge its empties over a whole copy, and never write it back: `upsert`, `patch`, `create`
|
|
114
|
+
and `bulk` throw a TypeError on one before sending. keel refuses any write carrying
|
|
115
|
+
`known_of` with 422 `known_of_not_writable` (`err.isKnownOfNotWritable`).
|
|
109
116
|
- A string holding an unpaired surrogate (text cut mid-emoji) is a 422 naming the field.
|
|
110
117
|
Slice strings by code point, not by UTF-16 unit.
|
|
111
118
|
- Colour carries the element's FAMILY (`elementColor(type, mode)`); the icon
|
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,45 @@ earlier history lives in git log only.
|
|
|
5
5
|
|
|
6
6
|
## [Unreleased]
|
|
7
7
|
|
|
8
|
+
## [4.41.0] - 2026-10-20
|
|
9
|
+
|
|
10
|
+
A known-of stub's public fields (keel PR 117, keel #448), live in production, and schema-dist v0.32.1-dist.28, which publishes them.
|
|
11
|
+
|
|
12
|
+
### Added
|
|
13
|
+
- **`PUBLIC_FIELDS`** (generated from the distribution's `presentation.json`, `types.<type>.public`): per element type,
|
|
14
|
+
the fields onlyworlds.com shows on a known-of stub besides the base fields, with their values, as a readonly
|
|
15
|
+
`as const` array; all 22 types present. A Character's are `physicality`, `height`, `weight`, `species` and
|
|
16
|
+
`reputation`; every other type's list is empty for now. Platform behaviour, not a default to override. Codegen
|
|
17
|
+
exits 1 on a tree without the sidecar, a type without the key, or a name that is not a field of its type.
|
|
18
|
+
- **`err.isKnownOfNotWritable`**: keel's named refusal of a write carrying `known_of`, true or false (422
|
|
19
|
+
`known_of_not_writable`, `param` known_of). This client never sends `known_of` (4.40.0's strip and refusal are
|
|
20
|
+
unchanged), so it reaches you only through `request()`; `/bulk` puts it in the item's slot.
|
|
21
|
+
|
|
22
|
+
### Changed
|
|
23
|
+
- Repinned to schema-dist v0.32.1-dist.28: `presentation.json` gains `types.<type>.public` and `_meta.public`; no
|
|
24
|
+
schema file moved, so the generated interfaces change only their source lines.
|
|
25
|
+
- **A stub's description** on `known_of` (the generated doc comment, `SCHEMA.md` and `AGENTS.md`) says a stub
|
|
26
|
+
keeps its type's `PUBLIC_FIELDS` with their values too; it said every other field reads unset.
|
|
27
|
+
|
|
28
|
+
## [4.40.0] - 2026-10-20
|
|
29
|
+
|
|
30
|
+
The "known of" stub's client half (keel PR 113, B16; keel #421 §7g), live in production since 2026-10-20 13:47.
|
|
31
|
+
|
|
32
|
+
### Added
|
|
33
|
+
- **`known_of?: true`** on `OwElementBase` (generated; `SCHEMA.md` says it too): present, and true, only on a
|
|
34
|
+
stub, an element a guest or player reaches only through its own Character's sheet, one step out. A stub
|
|
35
|
+
keeps `id`, `type`, `name`, `description`, `supertype`, `subtype`, `image_url`, `created_at`, `updated_at`
|
|
36
|
+
and `change_seq`; every other field reads unset (`""`, `null`, `[]`), `created_by`, `changed_by` and
|
|
37
|
+
`changed_via` are null, it has no extension fields, and its files are 404. For Lantern and Atlas, which
|
|
38
|
+
render stubs (Temper).
|
|
39
|
+
- **`isKnownOf(el)`**: true only for `known_of: true`; absent or anything else is a whole element.
|
|
40
|
+
|
|
41
|
+
### Changed
|
|
42
|
+
- **A stub is never written**: `upsert`, `patch`, `create` and `bulk` throw a `TypeError` before sending a
|
|
43
|
+
body with `known_of: true` (`bulk` names the item, and sends none of the batch). Stripping the marker would
|
|
44
|
+
turn keel's 422 into a write that blanks the element for any key that may write it (an owner pushing a
|
|
45
|
+
player's copy). `known_of` joins the strip list, so any other value of it is never sent.
|
|
46
|
+
|
|
8
47
|
## [4.39.0] - 2026-10-20
|
|
9
48
|
|
|
10
49
|
The party link (keel #422 PR 2, keel PR 110), live in production since 2026-10-20 13:15.
|
package/README.md
CHANGED
|
@@ -285,6 +285,7 @@ import {
|
|
|
285
285
|
ELEMENT_LABELS, // plural display labels
|
|
286
286
|
ELEMENT_SECTIONS, // field grouping and display order
|
|
287
287
|
FIELD_SCHEMA, // per-field type and link target
|
|
288
|
+
PUBLIC_FIELDS, // per type, the fields a known-of stub carries besides the base fields
|
|
288
289
|
elementColor, // colour by family; the icon carries the type
|
|
289
290
|
} from '@onlyworlds/sdk';
|
|
290
291
|
|
package/SCHEMA.md
CHANGED
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
# OnlyWorlds Schema Reference
|
|
2
2
|
|
|
3
|
-
**Source**: https://github.com/OnlyWorlds/schema-dist @ **v0.32.1-dist.
|
|
3
|
+
**Source**: https://github.com/OnlyWorlds/schema-dist @ **v0.32.1-dist.28** — canonical schema **00.32.01**, published 2026-10-20.
|
|
4
4
|
|
|
5
5
|
GENERATED from the canonical schema YAML — do not hand-edit (regenerate: `python codegen/generate_types.py`).
|
|
6
6
|
Written for both humans and AI agents reading this package locally.
|
|
7
7
|
|
|
8
8
|
**The shape rules** (v2 wire dialect): every element carries `id` (UUID), `name`, optional
|
|
9
9
|
`description`/`supertype`/`subtype`/`image_url`, server-managed `type`/`created_at`/`updated_at`/`change_seq`/`created_by`,
|
|
10
|
+
`known_of: true` only on a stub (an element a guest knows of through its Character's sheet:
|
|
11
|
+
its type's `PUBLIC_FIELDS` carry values, its other fields read unset and are not values; never write a stub back),
|
|
10
12
|
and namespaced extension fields (`x_*` etc.) returned verbatim. Link fields use ONE bare
|
|
11
13
|
name in both read and write (no `_ids` suffix). Single links are `UUID | null`; multi links
|
|
12
14
|
are `UUID[]`. **Links are owned one-way**: the type listed below owns the field (e.g.
|
package/dist/index.d.ts
CHANGED
|
@@ -2,7 +2,8 @@
|
|
|
2
2
|
* pass-through fields (atlas_* / shadow_* / x_*) returned verbatim by the server.
|
|
3
3
|
* Derived from base_properties.yaml: `World` is dropped (the API rejects it in
|
|
4
4
|
* bodies -- the key determines the world) and the seven server-managed fields are
|
|
5
|
-
* added, since they ride every wire body and appear in no element YAML
|
|
5
|
+
* added, since they ride every wire body and appear in no element YAML; `known_of`
|
|
6
|
+
* rides only a stub. */
|
|
6
7
|
interface OwElementBase {
|
|
7
8
|
/** Element type slug (server-managed, read-only). */
|
|
8
9
|
type: string;
|
|
@@ -30,6 +31,8 @@ interface OwElementBase {
|
|
|
30
31
|
changed_by?: string | null;
|
|
31
32
|
/** The door of the last write (server-managed, read-only): `seat` (an agent seat), `mcp`, `declared` (a client that sent X-OW-Agent), then `api`, `v1`, `sync`, or `server` (keel's own writes). The first three are agent-made. Null for anything last changed before writes recorded it. */
|
|
32
33
|
changed_via?: 'seat' | 'mcp' | 'declared' | 'api' | 'v1' | 'sync' | 'server' | null;
|
|
34
|
+
/** Present, and true, only on a stub (server-managed, read-only): an element a guest or player reaches only through its own Character's sheet. A stub keeps id, type, name, description, supertype, subtype, image_url, created_at, updated_at and change_seq, and the fields its type lists in PUBLIC_FIELDS with their values; every other field reads unset ("", null, []), created_by/changed_by/changed_via null, no extension fields, and its files are 404. Its empties are not values and not a deletion: never write a stub back. Absent: the element is whole. See isKnownOf(). */
|
|
35
|
+
known_of?: true;
|
|
33
36
|
/** Namespaced extension fields (atlas_* / shadow_* / x_*), returned verbatim. */
|
|
34
37
|
[ext: string]: unknown;
|
|
35
38
|
}
|
|
@@ -47,6 +50,34 @@ type ElementFamily = 'agents' | 'world' | 'abstract' | 'temporal';
|
|
|
47
50
|
declare const ELEMENT_FAMILIES: Record<ElementType, ElementFamily>;
|
|
48
51
|
/** Material Symbols icon name per type. Source: the distribution's `presentation.json` sidecar. */
|
|
49
52
|
declare const ELEMENT_ICONS: Record<ElementType, string>;
|
|
53
|
+
/** The fields onlyworlds.com shows on a known-of element (`known_of: true`, see isKnownOf)
|
|
54
|
+
* besides the base fields, with their values; every other field of a stub reads unset.
|
|
55
|
+
* Platform behaviour, not a default to override. Source: the distribution's
|
|
56
|
+
* `presentation.json` sidecar, `types.<type>.public` (keel PR 117). */
|
|
57
|
+
declare const PUBLIC_FIELDS: {
|
|
58
|
+
readonly ability: readonly [];
|
|
59
|
+
readonly character: readonly ["physicality", "height", "weight", "species", "reputation"];
|
|
60
|
+
readonly collective: readonly [];
|
|
61
|
+
readonly construct: readonly [];
|
|
62
|
+
readonly creature: readonly [];
|
|
63
|
+
readonly event: readonly [];
|
|
64
|
+
readonly family: readonly [];
|
|
65
|
+
readonly institution: readonly [];
|
|
66
|
+
readonly language: readonly [];
|
|
67
|
+
readonly law: readonly [];
|
|
68
|
+
readonly location: readonly [];
|
|
69
|
+
readonly map: readonly [];
|
|
70
|
+
readonly marker: readonly [];
|
|
71
|
+
readonly narrative: readonly [];
|
|
72
|
+
readonly object: readonly [];
|
|
73
|
+
readonly phenomenon: readonly [];
|
|
74
|
+
readonly pin: readonly [];
|
|
75
|
+
readonly relation: readonly [];
|
|
76
|
+
readonly species: readonly [];
|
|
77
|
+
readonly title: readonly [];
|
|
78
|
+
readonly trait: readonly [];
|
|
79
|
+
readonly zone: readonly [];
|
|
80
|
+
};
|
|
50
81
|
/** Field grouping for display. DERIVED from the canonical schema's own document
|
|
51
82
|
* structure (top-level property groups, document order = display order). */
|
|
52
83
|
interface SectionInfo {
|
|
@@ -1955,6 +1986,19 @@ type OwWriteDoor = NonNullable<OwElementBase['changed_via']>;
|
|
|
1955
1986
|
declare const AGENT_DOORS: readonly OwWriteDoor[];
|
|
1956
1987
|
/** Whether a write came through an agent's door (`changed_via` or `deleted_via`); false for null. */
|
|
1957
1988
|
declare function isAgentDoor(door: OwWriteDoor | null | undefined): boolean;
|
|
1989
|
+
/**
|
|
1990
|
+
* Whether an element body is a stub the reader only knows of (keel PR 113, B16; keel #421
|
|
1991
|
+
* §7g): a guest or player reaches it only through its own Character's sheet, one step out.
|
|
1992
|
+
* A stub keeps `id`, `type`, `name`, `description`, `supertype`, `subtype`, `image_url`,
|
|
1993
|
+
* `created_at`, `updated_at` and `change_seq`; every other field reads unset (`""`, `null`,
|
|
1994
|
+
* `[]`), `created_by`, `changed_by` and `changed_via` are null, it carries no extension
|
|
1995
|
+
* fields, and its files answer 404. Those empties are not the element's values and not a
|
|
1996
|
+
* deletion: never merge them over a whole copy, and never write a stub back (this client
|
|
1997
|
+
* refuses to). True only for `known_of: true`; absent or anything else is a whole element.
|
|
1998
|
+
*/
|
|
1999
|
+
declare function isKnownOf(element: {
|
|
2000
|
+
known_of?: unknown;
|
|
2001
|
+
} | null | undefined): boolean;
|
|
1958
2002
|
/**
|
|
1959
2003
|
* /changes response. Wire shape verified in keel source (core/changes.py) and
|
|
1960
2004
|
* pinned here: {cursor, changes, has_more, head}.
|
|
@@ -2728,6 +2772,14 @@ declare class OwApiError extends Error {
|
|
|
2728
2772
|
* keel's hidden mark is on; until then `viewAs` is an unknown parameter (422).
|
|
2729
2773
|
*/
|
|
2730
2774
|
get isViewAsOwnerOnly(): boolean;
|
|
2775
|
+
/**
|
|
2776
|
+
* An element write carried `known_of` (422 `known_of_not_writable`, `param` known_of; keel
|
|
2777
|
+
* PR 117), true or false: the key marks a stub and is never written. Drop it and send only
|
|
2778
|
+
* the fields you mean. This client never sends it (`known_of` is stripped, a stub is a
|
|
2779
|
+
* TypeError before sending), so it reaches you only through `request()`. `/bulk` never
|
|
2780
|
+
* throws for it: the item's slot carries the code, and its siblings apply.
|
|
2781
|
+
*/
|
|
2782
|
+
get isKnownOfNotWritable(): boolean;
|
|
2731
2783
|
/**
|
|
2732
2784
|
* A `patch` or `editLinks` sent with `ifMatch` found the element moved past that
|
|
2733
2785
|
* `change_seq` (412 `precondition_failed`, keel #210): nothing was written and nothing
|
|
@@ -2941,7 +2993,11 @@ declare class OwV2Client {
|
|
|
2941
2993
|
create(type: ElementType | string, element: OwElement | Record<string, unknown>, opts?: {
|
|
2942
2994
|
idempotencyKey?: string;
|
|
2943
2995
|
}): Promise<OwElement>;
|
|
2944
|
-
/**
|
|
2996
|
+
/**
|
|
2997
|
+
* PUT /{type}/{id}/ -- upsert-by-client-id. The local-first write primitive. A known-of
|
|
2998
|
+
* stub (`known_of: true`, see isKnownOf) is a TypeError before sending, here and on every
|
|
2999
|
+
* element write: a PUT of one would blank every field it does not keep.
|
|
3000
|
+
*/
|
|
2945
3001
|
upsert(type: ElementType | string, id: string, element: OwElement | Record<string, unknown>): Promise<OwElement>;
|
|
2946
3002
|
/**
|
|
2947
3003
|
* PATCH /{type}/{id}/ -- partial update. DESTRUCTIVE on sent fields: arrays
|
|
@@ -4383,4 +4439,4 @@ declare class TokenResource {
|
|
|
4383
4439
|
getEncryptionInfo(): Promise<EncryptionInfo>;
|
|
4384
4440
|
}
|
|
4385
4441
|
|
|
4386
|
-
export { AGENT_DOORS, ASK_LIMITS, type AccessKeyResponse, CALENDAR_FIELD, CALENDAR_SUPERTYPE, type CalendarConfig, type CalendarEra, type CalendarIntercalary, type CalendarMonths, type CalendarWeek, ELEMENT_FAMILIES, ELEMENT_ICONS, ELEMENT_LABELS, ELEMENT_SECTIONS, ELEMENT_TYPES, type ElementFamily, type ElementType, type EncryptionInfo, type EraDomain, FAMILY_COLORS, FAMILY_ORDER, FIELD_ACRONYMS, FIELD_SCHEMA, FILE_EXTENSIONS, type FieldInfo, type FieldType, GameTier, type ListParams, ONLYWORLDS_VERSION, type OwAgentJoined, type OwAllowance, OwApiError, type OwAskAnswer, type OwAskContext, type OwAuthErrorCode, type OwBulkItem, type OwBulkItemResult, type OwBulkResponse, type OwCalendarElement, type OwChange, type OwChangeDelete, type OwChangeUpsert, type OwChangesPage, type OwClientConfig, type OwCreatedWorldLink, type OwDeleteReason, type OwElement, type OwElementBase, type OwErrorBody, type OwFileAddedBy, type OwFileDownload, type OwFileKind, type OwFileRow, type OwFileTicket, type OwJoinPreview, type OwJoined, type OwJoinedMembership, type OwKeyKind, type OwLinkEdit, type OwLookupElement, type OwLookupHit, type OwLookupLink, type OwLookupOptions, type OwLookupReason, type OwMe, type OwMediaTicket, type OwMember, type OwMemberRole, OwNetworkError, type OwPage, type OwPhotoOptions, type OwPhotoPlan, type OwPlayerJoined, OwPreconditionFailedError, type OwPreparedPhoto, type OwReadWorldFile, type OwReadWorldFileOptions, type OwRemovalTicket, type OwRemovedImage, type OwRenderOptions, type OwResyncReason, type OwSeat, type OwSeatCreated, OwSignInError, type OwSignInReason, type OwSignedIn, type OwSortAddToRow, type OwSortAnswer, type OwSortAskRow, type OwSortLinkRow, type OwSortMakeRow, type OwSortNote, type OwSortRef, type OwSortRow, type OwUploadedFile, type OwUploadedImage, OwV2Client, type OwWorldFileEntry, OwWorldFileError, type OwWorldFileReason, type OwWorldFileRow, type OwWorldFiles, type OwWorldIndex, type OwWorldLink, type OwWorldMeta, type OwWriteDoor, PHOTO_MAX_BYTES, PHOTO_TYPES, type ParseError, type ParseOptions, type ParseResult, type RevokeAllSessionsResponse, type RevokeSessionResponse, SPATIAL_TYPES, type SectionInfo, type StepBreakdown, type TokenConsumeParams, type TokenConsumeResponse, TokenResource, type TokenStatus, type TokenTransport, WORLD_FILE_MAX_BYTES, WORLD_FILE_MAX_ENTRIES, type WorldCalendar, absYearForEraYear, absoluteYear, approxYearLength, breakdownStep, buildAskContext, buildWorldIndex, detectKeyKind, displayYear, elementColor, eraForStep, errorFromResponse, familyOf, fieldLabel, fileKindOf, floorDiv, floorMod, formatDuration, formatMidLabel, formatStep, formatYearLabel, getElementIcon, getElementLabel, isAgentDoor, isDemoKey, isLeapYear, isParseError, kindCanWrite, lookupWorld, monthStartSteps, parseDate, parseErrorEnvelope, pinExpectation, planPhoto, preparePhoto, readCalendarConfig, readCalendarValue, readWorldFile, renderElement, resolveCalendarLens, resolveEraDomains, validateCalendarConfig, weekdayForStep, worldCalendars, writeWorldFile, yearLength, yearStartStep };
|
|
4442
|
+
export { AGENT_DOORS, ASK_LIMITS, type AccessKeyResponse, CALENDAR_FIELD, CALENDAR_SUPERTYPE, type CalendarConfig, type CalendarEra, type CalendarIntercalary, type CalendarMonths, type CalendarWeek, ELEMENT_FAMILIES, ELEMENT_ICONS, ELEMENT_LABELS, ELEMENT_SECTIONS, ELEMENT_TYPES, type ElementFamily, type ElementType, type EncryptionInfo, type EraDomain, FAMILY_COLORS, FAMILY_ORDER, FIELD_ACRONYMS, FIELD_SCHEMA, FILE_EXTENSIONS, type FieldInfo, type FieldType, GameTier, type ListParams, ONLYWORLDS_VERSION, type OwAgentJoined, type OwAllowance, OwApiError, type OwAskAnswer, type OwAskContext, type OwAuthErrorCode, type OwBulkItem, type OwBulkItemResult, type OwBulkResponse, type OwCalendarElement, type OwChange, type OwChangeDelete, type OwChangeUpsert, type OwChangesPage, type OwClientConfig, type OwCreatedWorldLink, type OwDeleteReason, type OwElement, type OwElementBase, type OwErrorBody, type OwFileAddedBy, type OwFileDownload, type OwFileKind, type OwFileRow, type OwFileTicket, type OwJoinPreview, type OwJoined, type OwJoinedMembership, type OwKeyKind, type OwLinkEdit, type OwLookupElement, type OwLookupHit, type OwLookupLink, type OwLookupOptions, type OwLookupReason, type OwMe, type OwMediaTicket, type OwMember, type OwMemberRole, OwNetworkError, type OwPage, type OwPhotoOptions, type OwPhotoPlan, type OwPlayerJoined, OwPreconditionFailedError, type OwPreparedPhoto, type OwReadWorldFile, type OwReadWorldFileOptions, type OwRemovalTicket, type OwRemovedImage, type OwRenderOptions, type OwResyncReason, type OwSeat, type OwSeatCreated, OwSignInError, type OwSignInReason, type OwSignedIn, type OwSortAddToRow, type OwSortAnswer, type OwSortAskRow, type OwSortLinkRow, type OwSortMakeRow, type OwSortNote, type OwSortRef, type OwSortRow, type OwUploadedFile, type OwUploadedImage, OwV2Client, type OwWorldFileEntry, OwWorldFileError, type OwWorldFileReason, type OwWorldFileRow, type OwWorldFiles, type OwWorldIndex, type OwWorldLink, type OwWorldMeta, type OwWriteDoor, PHOTO_MAX_BYTES, PHOTO_TYPES, PUBLIC_FIELDS, type ParseError, type ParseOptions, type ParseResult, type RevokeAllSessionsResponse, type RevokeSessionResponse, SPATIAL_TYPES, type SectionInfo, type StepBreakdown, type TokenConsumeParams, type TokenConsumeResponse, TokenResource, type TokenStatus, type TokenTransport, WORLD_FILE_MAX_BYTES, WORLD_FILE_MAX_ENTRIES, type WorldCalendar, absYearForEraYear, absoluteYear, approxYearLength, breakdownStep, buildAskContext, buildWorldIndex, detectKeyKind, displayYear, elementColor, eraForStep, errorFromResponse, familyOf, fieldLabel, fileKindOf, floorDiv, floorMod, formatDuration, formatMidLabel, formatStep, formatYearLabel, getElementIcon, getElementLabel, isAgentDoor, isDemoKey, isKnownOf, isLeapYear, isParseError, kindCanWrite, lookupWorld, monthStartSteps, parseDate, parseErrorEnvelope, pinExpectation, planPhoto, preparePhoto, readCalendarConfig, readCalendarValue, readWorldFile, renderElement, resolveCalendarLens, resolveEraDomains, validateCalendarConfig, weekdayForStep, worldCalendars, writeWorldFile, yearLength, yearStartStep };
|
package/dist/index.js
CHANGED
|
@@ -160,6 +160,16 @@ var OwApiError = class extends Error {
|
|
|
160
160
|
get isViewAsOwnerOnly() {
|
|
161
161
|
return this.status === 403 && this.code === "view_as_owner_only";
|
|
162
162
|
}
|
|
163
|
+
/**
|
|
164
|
+
* An element write carried `known_of` (422 `known_of_not_writable`, `param` known_of; keel
|
|
165
|
+
* PR 117), true or false: the key marks a stub and is never written. Drop it and send only
|
|
166
|
+
* the fields you mean. This client never sends it (`known_of` is stripped, a stub is a
|
|
167
|
+
* TypeError before sending), so it reaches you only through `request()`. `/bulk` never
|
|
168
|
+
* throws for it: the item's slot carries the code, and its siblings apply.
|
|
169
|
+
*/
|
|
170
|
+
get isKnownOfNotWritable() {
|
|
171
|
+
return this.status === 422 && this.code === "known_of_not_writable";
|
|
172
|
+
}
|
|
163
173
|
/**
|
|
164
174
|
* A `patch` or `editLinks` sent with `ifMatch` found the element moved past that
|
|
165
175
|
* `change_seq` (412 `precondition_failed`, keel #210): nothing was written and nothing
|
|
@@ -429,6 +439,7 @@ var OwV2Client = class {
|
|
|
429
439
|
* `null` are accepted and stored as `''` (nameless Markers exist).
|
|
430
440
|
*/
|
|
431
441
|
async create(type, element, opts = {}) {
|
|
442
|
+
refuseKnownOf(element, "create");
|
|
432
443
|
const body = sanitizePayload(element);
|
|
433
444
|
if (body.id === void 0 || body.id === null || body.id === "") {
|
|
434
445
|
body.id = opts.idempotencyKey ? keyedId(opts.idempotencyKey, 0) : mintUuid();
|
|
@@ -439,8 +450,13 @@ var OwV2Client = class {
|
|
|
439
450
|
idempotencyKey: opts.idempotencyKey
|
|
440
451
|
});
|
|
441
452
|
}
|
|
442
|
-
/**
|
|
453
|
+
/**
|
|
454
|
+
* PUT /{type}/{id}/ -- upsert-by-client-id. The local-first write primitive. A known-of
|
|
455
|
+
* stub (`known_of: true`, see isKnownOf) is a TypeError before sending, here and on every
|
|
456
|
+
* element write: a PUT of one would blank every field it does not keep.
|
|
457
|
+
*/
|
|
443
458
|
async upsert(type, id, element) {
|
|
459
|
+
refuseKnownOf(element, "upsert");
|
|
444
460
|
return this.request("PUT", `/${type}/${id}/`, { write: true, body: sanitizePayload(element) });
|
|
445
461
|
}
|
|
446
462
|
/**
|
|
@@ -454,6 +470,7 @@ var OwV2Client = class {
|
|
|
454
470
|
* it for today's unconditional write.
|
|
455
471
|
*/
|
|
456
472
|
async patch(type, id, partial, opts = {}) {
|
|
473
|
+
refuseKnownOf(partial, "patch");
|
|
457
474
|
return this.request("PATCH", `/${type}/${id}/`, { write: true, body: sanitizePayload(partial), ifMatch: opts.ifMatch });
|
|
458
475
|
}
|
|
459
476
|
/**
|
|
@@ -492,6 +509,7 @@ var OwV2Client = class {
|
|
|
492
509
|
* fresh UUIDv7. Ids you supply are kept.
|
|
493
510
|
*/
|
|
494
511
|
async bulk(items, opts = {}) {
|
|
512
|
+
items.forEach((it, index) => refuseKnownOf(it.element, `bulk: items[${index}]`));
|
|
495
513
|
const body = {
|
|
496
514
|
items: items.map((it, index) => {
|
|
497
515
|
const element = sanitizePayload(it.element);
|
|
@@ -1191,13 +1209,20 @@ var OwV2Client = class {
|
|
|
1191
1209
|
return parsed;
|
|
1192
1210
|
}
|
|
1193
1211
|
};
|
|
1194
|
-
var READ_ONLY_FIELDS = ["world", "type", "created_at", "updated_at", "change_seq"];
|
|
1212
|
+
var READ_ONLY_FIELDS = ["world", "type", "created_at", "updated_at", "change_seq", "known_of"];
|
|
1195
1213
|
function sanitizePayload(payload) {
|
|
1196
1214
|
if (!payload || typeof payload !== "object") return payload;
|
|
1197
1215
|
const rest = { ...payload };
|
|
1198
1216
|
for (const field of READ_ONLY_FIELDS) delete rest[field];
|
|
1199
1217
|
return rest;
|
|
1200
1218
|
}
|
|
1219
|
+
function refuseKnownOf(payload, where) {
|
|
1220
|
+
if (payload && typeof payload === "object" && payload.known_of === true) {
|
|
1221
|
+
throw new TypeError(
|
|
1222
|
+
`${where}: this body is a known-of stub (known_of: true), not the element: its empty fields are not its values, and writing it would blank them. Write from a whole copy, or send only the fields you mean to change.`
|
|
1223
|
+
);
|
|
1224
|
+
}
|
|
1225
|
+
}
|
|
1201
1226
|
async function endAuthSession(fetchImpl, auth, session) {
|
|
1202
1227
|
const abort = new AbortController();
|
|
1203
1228
|
const timer = setTimeout(() => abort.abort(), 5e3);
|
|
@@ -1371,6 +1396,30 @@ var ELEMENT_ICONS = {
|
|
|
1371
1396
|
trait: "flaky",
|
|
1372
1397
|
zone: "pentagon"
|
|
1373
1398
|
};
|
|
1399
|
+
var PUBLIC_FIELDS = {
|
|
1400
|
+
ability: [],
|
|
1401
|
+
character: ["physicality", "height", "weight", "species", "reputation"],
|
|
1402
|
+
collective: [],
|
|
1403
|
+
construct: [],
|
|
1404
|
+
creature: [],
|
|
1405
|
+
event: [],
|
|
1406
|
+
family: [],
|
|
1407
|
+
institution: [],
|
|
1408
|
+
language: [],
|
|
1409
|
+
law: [],
|
|
1410
|
+
location: [],
|
|
1411
|
+
map: [],
|
|
1412
|
+
marker: [],
|
|
1413
|
+
narrative: [],
|
|
1414
|
+
object: [],
|
|
1415
|
+
phenomenon: [],
|
|
1416
|
+
pin: [],
|
|
1417
|
+
relation: [],
|
|
1418
|
+
species: [],
|
|
1419
|
+
title: [],
|
|
1420
|
+
trait: [],
|
|
1421
|
+
zone: []
|
|
1422
|
+
};
|
|
1374
1423
|
var ELEMENT_SECTIONS = {
|
|
1375
1424
|
ability: [
|
|
1376
1425
|
{ name: "Mechanics", order: 1, fields: ["activation", "duration", "potency", "range", "effects", "challenges", "talents", "requisites"] },
|
|
@@ -2072,6 +2121,9 @@ var AGENT_DOORS = ["seat", "mcp", "declared"];
|
|
|
2072
2121
|
function isAgentDoor(door) {
|
|
2073
2122
|
return door != null && AGENT_DOORS.includes(door);
|
|
2074
2123
|
}
|
|
2124
|
+
function isKnownOf(element) {
|
|
2125
|
+
return element != null && element.known_of === true;
|
|
2126
|
+
}
|
|
2075
2127
|
|
|
2076
2128
|
// src/v2/palette.ts
|
|
2077
2129
|
var FAMILY_COLORS = {
|
|
@@ -3539,6 +3591,7 @@ export {
|
|
|
3539
3591
|
OwWorldFileError,
|
|
3540
3592
|
PHOTO_MAX_BYTES,
|
|
3541
3593
|
PHOTO_TYPES,
|
|
3594
|
+
PUBLIC_FIELDS,
|
|
3542
3595
|
SPATIAL_TYPES,
|
|
3543
3596
|
TokenResource,
|
|
3544
3597
|
WORLD_FILE_MAX_BYTES,
|
|
@@ -3567,6 +3620,7 @@ export {
|
|
|
3567
3620
|
getElementLabel,
|
|
3568
3621
|
isAgentDoor,
|
|
3569
3622
|
isDemoKey,
|
|
3623
|
+
isKnownOf,
|
|
3570
3624
|
isLeapYear,
|
|
3571
3625
|
isParseError,
|
|
3572
3626
|
kindCanWrite,
|