diff --git a/CHANGELOG.md b/CHANGELOG.md index 9e94fd6..a56eac5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,12 @@ earlier history lives in git log only. ## [Unreleased] +## [4.186.0] - 2026-11-21 + +### Added + +- **`house` on a proposal and on the queue's new-element row**, typed `OwProposalHouse | null` (`charter`, `skill` or `new_charter`): what part of the world's house rules the row would change. A world's Charter and the Objects it names are now changed only by the owner and co-builders, and anyone else proposes (`403` `keeper_only`); onlyworlds.com works the word out for the owner and co-builders and serves `null` to anyone else. + ## [4.185.0] - 2026-11-21 ### Added diff --git a/package-lock.json b/package-lock.json index e9a7bcc..d4b1375 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@onlyworlds/sdk", - "version": "4.185.0", + "version": "4.186.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@onlyworlds/sdk", - "version": "4.185.0", + "version": "4.186.0", "license": "MIT", "dependencies": { "fflate": "^0.8.3" diff --git a/package.json b/package.json index 194707b..11eea03 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@onlyworlds/sdk", - "version": "4.185.0", + "version": "4.186.0", "description": "TypeScript SDK for the OnlyWorlds API - build world-building applications with type safety", "type": "module", "exports": { diff --git a/src/index.ts b/src/index.ts index 126f54e..a95b357 100644 --- a/src/index.ts +++ b/src/index.ts @@ -26,7 +26,7 @@ export type { OwJoinPreview, OwJoinedMembership, OwAskAnswer, OwPaidBy, OwAllowance, OwAiUse, OwAiMeter, OwAiRefusal, OwFieldsRefusal,OwAiAskAnswer, OwAiSortAnswer, OwAiAskBody, OwAiSortBody, OwMe, OwFrontDoor, OwFrontDoorCharter, OwFrontDoorSkill, OwMySeat, OwReadingAids, OwServedReadingAids, OwReadingAidsCharter, OwReadingAidsGuide, OwReadingAidsDomain, OwReadingAidsHub, OwMember, OwMemberRole, OwWorldLink, OwCreatedWorldLink, OwSeat, OwSeatCreated, OwMemberLenses, OwAccountWorld, OwAccountToken, OwMintedAiToken, OwMintedKey, OwWorldKeyRow, OwWorldKeyMember, OwDraught, OwDraughtCompact, OwDraughtPolicy, OwDraughtComponent, OwDraughtItem, OwDraughtLens, OwWorldLenses, OwWorldLens, OwWorldLensReading, OwJoined, OwAgentJoined, OwPlayerJoined, OwSignedIn, OwSortRef, OwSortNote, OwSortRow, OwSortMakeRow, OwSortAddToRow, OwSortLinkRow, OwSortAskRow, OwSortAnswer, OwWriteDoor, OwChangeUpsert, OwChangeDelete, OwDeleteReason, OwHiddenRow, OwResyncReason, - OwProposal, OwProposalState, OwProposalList, OwProposed, OwProposalAccepted, OwProposalConflict, OwProposeInput, OwProposalQuery, OwWorldProposalQuery, + OwProposal, OwProposalState, OwProposalHouse, OwProposalList, OwProposed, OwProposalAccepted, OwProposalConflict, OwProposeInput, OwProposalQuery, OwWorldProposalQuery, OwProposedNewElement, OwWorldProposalRow, OwWorldProposalList, OwReviewInput, OwReviewed, OwCreateAccountWorldInput, OwCreatedAccountWorld, } from './v2'; diff --git a/src/v2/index.ts b/src/v2/index.ts index 950b8c9..8f328b1 100644 --- a/src/v2/index.ts +++ b/src/v2/index.ts @@ -29,7 +29,7 @@ export type { OwJoinPreview, OwJoinedMembership, OwAskAnswer, OwPaidBy, OwAllowance, OwAiUse, OwAiMeter, OwAiRefusal, OwFieldsRefusal,OwAiAskAnswer, OwAiSortAnswer, OwAiAskBody, OwAiSortBody, OwMe, OwFrontDoor, OwFrontDoorCharter, OwFrontDoorSkill, OwMySeat, OwReadingAids, OwServedReadingAids, OwReadingAidsCharter, OwReadingAidsGuide, OwReadingAidsDomain, OwReadingAidsHub, OwMember, OwMemberRole, OwWorldLink, OwCreatedWorldLink, OwSeat, OwSeatCreated, OwMemberLenses, OwAccountWorld, OwAccountToken, OwMintedAiToken, OwMintedKey, OwWorldKeyRow, OwWorldKeyMember, OwDraught, OwDraughtCompact, OwDraughtPolicy, OwDraughtComponent, OwDraughtItem, OwDraughtLens, OwWorldLenses, OwWorldLens, OwWorldLensReading, OwJoined, OwAgentJoined, OwPlayerJoined, OwSignedIn, OwSortRef, OwSortNote, OwSortRow, OwSortMakeRow, OwSortAddToRow, OwSortLinkRow, OwSortAskRow, OwSortAnswer, OwWriteDoor, OwChangeUpsert, OwChangeDelete, OwDeleteReason, OwHiddenRow, OwResyncReason, - OwProposal, OwProposalState, OwProposalList, OwProposed, OwProposalAccepted, OwProposalConflict, OwProposeInput, OwProposalQuery, OwWorldProposalQuery, + OwProposal, OwProposalState, OwProposalHouse, OwProposalList, OwProposed, OwProposalAccepted, OwProposalConflict, OwProposeInput, OwProposalQuery, OwWorldProposalQuery, OwProposedNewElement, OwWorldProposalRow, OwWorldProposalList, OwReviewInput, OwReviewed, OwCreateAccountWorldInput, OwCreatedAccountWorld, } from './types'; diff --git a/src/v2/types.ts b/src/v2/types.ts index c58f815..2943493 100644 --- a/src/v2/types.ts +++ b/src/v2/types.ts @@ -410,6 +410,15 @@ export interface OwLinkEdit { /** A proposal's state: `lapsed` once `expires` has passed (it may still be accepted or declined). */ export type OwProposalState = 'open' | 'lapsed' | 'accepted' | 'declined'; +/** + * What part of the world's house rules a queue row would change: `charter`, a Law that carries the + * Charter mark (`x_charter_of`); `skill`, an Object the text of such a Law names; `new_charter`, a + * Law an accept would make a Charter (on a proposal: it sets the mark, and the Law's supertype after + * it is `Charter`; on a new element's row: a new Law that carries the mark). The house rules are + * changed only by the world's owner and co-builders; anyone else proposes (403 `keeper_only`). + */ +export type OwProposalHouse = 'charter' | 'skill' | 'new_charter'; + /** * A proposed change to an element (the document's `Proposal`): a record kept beside * the element, never in its body. The element does not change until the world's owner or a @@ -424,6 +433,8 @@ export interface OwProposal { element_type: string; /** The element's id. */ element_id: string; + /** The part of the house rules this proposal would change, null for anything else. Read when the row is served, as the world stands then; worked out only for the world's owner and co-builders, null to any other reader. */ + house: OwProposalHouse | null; state: OwProposalState; /** * What the proposal changes, and only that: the proposed values of the fields (schema @@ -484,6 +495,8 @@ export interface OwProposedNewElement { element_type: string; /** The element's id, as `id`. */ element_id: string; + /** `new_charter` when the new element is a Law that carries the Charter mark, `skill` when it is an Object a marked Law's text names, else null. Worked out only for the world's owner and co-builders, null to any other reader. */ + house: OwProposalHouse | null; /** open; lapsed once the mark's `expires` has passed (it may still be accepted or declined). Never accepted or declined: a settled mark leaves the queue. */ state: 'open' | 'lapsed'; /** The mark's own `by`, the writer's word for who proposed it: a claim, never a record of who wrote the element or the mark (show it as `OwProposedMark.by` says); null when it names nobody. */ diff --git a/test/proposals.test.mjs b/test/proposals.test.mjs index 643ab3f..ecaaa6e 100644 --- a/test/proposals.test.mjs +++ b/test/proposals.test.mjs @@ -19,9 +19,9 @@ const API = 'https://www.onlyworlds.com/api/v2'; const EL = '018f0000-0000-7000-8000-0000000000e1'; const PID = '018f0000-0000-7000-8000-0000000000a1'; -/** One row as the document's Proposal component gives it: all nineteen keys (kind and omitted). */ +/** One row as the document's Proposal component gives it: all twenty keys (kind, omitted and house). */ const PROPOSAL = { - kind: 'proposal', id: PID, element_type: 'location', element_id: EL, state: 'open', + kind: 'proposal', id: PID, element_type: 'location', element_id: EL, house: null, state: 'open', fields: { description: 'A harbour town.' }, omitted: [], base: { description: '' }, base_seq: 41, evidence: 'Chapter 3 names the harbour.', expires: '2026-11-21T16:00:00Z', by: '018f0000-0000-7000-8000-0000000000b1', via: 'api', client: 'sdk', @@ -29,10 +29,10 @@ const PROPOSAL = { created_at: '2026-10-22T16:00:00Z', updated_at: '2026-10-22T16:00:00Z', }; const LIST = { data: [PROPOSAL], has_more: true, next_cursor: 'c2' }; -/** A queue row for a new element written as proposed (the document's ProposedNewElement): all ten keys. */ +/** A queue row for a new element written as proposed (the document's ProposedNewElement): all eleven keys. */ const NEW_EL = '018f0000-0000-7000-8000-0000000000e2'; const NEW_ELEMENT_ROW = { - kind: 'new_element', id: NEW_EL, element_type: 'character', element_id: NEW_EL, state: 'open', + kind: 'new_element', id: NEW_EL, element_type: 'character', element_id: NEW_EL, house: null, state: 'open', by: '018f0000-0000-7000-8000-0000000000b1', evidence: 'Met her in chapter 4.', expires: '2026-11-22', created_at: '2026-10-23T07:00:00Z', updated_at: '2026-10-23T07:00:00Z', }; @@ -399,7 +399,7 @@ test('every proposal options object refuses an unknown key before sending', asyn // -- the published types ----------------------------------------------------- -test('the published types: OwProposal has the document\'s nineteen keys, the list and the 202 body theirs, the world its switch', () => { +test('the published types: OwProposal has the document\'s twenty keys, the list and the 202 body theirs, the world its switch', () => { const all = readFileSync(new URL('../dist/index.d.ts', import.meta.url), 'utf8'); const block = (name) => { const at = all.indexOf(`interface ${name} {`); @@ -407,16 +407,19 @@ test('the published types: OwProposal has the document\'s nineteen keys, the lis return all.slice(at, all.indexOf('\n}', at)); }; const keys = (src) => [...src.matchAll(/^\s{4}(\w+)\??:/gm)].map((m) => m[1]); - assert.deepEqual(keys(block('OwProposal')), ['kind', 'id', 'element_type', 'element_id', 'state', 'fields', 'omitted', 'base', 'base_seq', 'evidence', + assert.deepEqual(keys(block('OwProposal')), ['kind', 'id', 'element_type', 'element_id', 'house', 'state', 'fields', 'omitted', 'base', 'base_seq', 'evidence', 'expires', 'by', 'via', 'client', 'decided_by', 'decided_at', 'decline_reason', 'created_at', 'updated_at']); assert.match(block('OwProposal'), /\bkind: 'proposal';/); assert.match(block('OwProposal'), /\bomitted: string\[\];/); assert.match(block('OwProposal'), /\bstate: OwProposalState;/); - // The queue's new-element row, its ten keys, and the queue a union told apart by kind - assert.deepEqual(keys(block('OwProposedNewElement')), ['kind', 'id', 'element_type', 'element_id', 'state', 'by', 'evidence', + assert.match(block('OwProposal'), /\bhouse: OwProposalHouse \| null;/); + assert.match(all, /type OwProposalHouse = 'charter' \| 'skill' \| 'new_charter';/); + // The queue's new-element row, its eleven keys, and the queue a union told apart by kind + assert.deepEqual(keys(block('OwProposedNewElement')), ['kind', 'id', 'element_type', 'element_id', 'house', 'state', 'by', 'evidence', 'expires', 'created_at', 'updated_at']); assert.match(block('OwProposedNewElement'), /\bkind: 'new_element';/); assert.match(block('OwProposedNewElement'), /\bstate: 'open' \| 'lapsed';/); + assert.match(block('OwProposedNewElement'), /\bhouse: OwProposalHouse \| null;/); // The mark's evidence and expires are served as stored, any JSON value (a list, a number, an object) assert.match(block('OwProposedNewElement'), /\bevidence: unknown;/); assert.match(block('OwProposedNewElement'), /\bexpires: unknown;/);