@onlyworlds/sdk 4.105.0 → 4.107.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/CHANGELOG.md +17 -0
- package/dist/index.d.ts +50 -4
- package/dist/index.js +86 -5
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,23 @@ earlier history lives in git log only.
|
|
|
5
5
|
|
|
6
6
|
## [Unreleased]
|
|
7
7
|
|
|
8
|
+
## [4.107.0] - 2026-10-29
|
|
9
|
+
|
|
10
|
+
### Added
|
|
11
|
+
|
|
12
|
+
- **`doorsOf(element, tools = TOOLS)`**: which tools wrote an element, newest first, from its `doors` field, each `{ door, at, tool, last, from }` (`OwDoor`). `door` is the key (a tool's client name, or a door word such as `site` or `mcp`), `at` its time exactly as served, `tool` the first `tools` row whose `client` is the door as `{ id, name }` (else null), `from` is `doors`. Times are compared as instants at their full precision, offsets and microseconds included, never as strings and never through `Date`; entries at the same instant go by key, by Unicode code point. A key that is empty, or a value that is not a time (`YYYY-MM-DDTHH:MM:SS`, an optional fraction, then `Z` or `±HH:MM`, with a real date and clock), is skipped. `last` is true on the first entry at the same instant as `updated_at`; when none is, the last write came through no door the field records (a restore or a scrub). An element without `doors`, or with no valid entry in it, gives one entry from its last write (`changed_client`, else `changed_via`, at `updated_at`, `from: 'last-write'`), or `[]` when it has neither door or no valid `updated_at`, as a public reader's element does. Data only, no words: a "Last shaped in Atlas" line reads the first entry. An element that is not an object, or `tools` that is not an array, is a TypeError. The Python package's `doors_of` answers the same shared fixture (26 cases) entry for entry.
|
|
13
|
+
|
|
14
|
+
## [4.106.0] - 2026-10-29
|
|
15
|
+
|
|
16
|
+
### Added
|
|
17
|
+
|
|
18
|
+
- **`doors` on every element type**: each tool that wrote the element, with the time of its last write there, as the API serves it to a world's members since 2026-10-29. One key per tool (the name it sent in `X-OW-Client`, else the door word of that write, such as `site` or `mcp`), each value the `updated_at` that write left; at most 16 keys. Optional: absent for the public reader, on a known-of stub, in the change feed's bodies, in a world file, and on an element not written since the field arrived. Read-only; the server ignores it in a write.
|
|
19
|
+
|
|
20
|
+
### Changed
|
|
21
|
+
|
|
22
|
+
- The doc comments on `changed_by`, `changed_via` and `changed_client` say they are served to a world's members only and absent for the public reader, as the API serves them since the same day.
|
|
23
|
+
- The draught text fixture gains a `doors` case: the door history never prints as a field line.
|
|
24
|
+
|
|
8
25
|
## [4.105.0] - 2026-10-29
|
|
9
26
|
|
|
10
27
|
### Added
|
package/dist/index.d.ts
CHANGED
|
@@ -27,12 +27,14 @@ interface OwElementBase {
|
|
|
27
27
|
change_seq?: number;
|
|
28
28
|
/** The membership that created this element (server-managed, read-only); null for the world's owner and for anything created before memberships existed. */
|
|
29
29
|
created_by?: string | null;
|
|
30
|
-
/** The membership whose write last changed this element (server-managed, read-only); null for the world's owner and for anything last changed before writes recorded it. */
|
|
30
|
+
/** The membership whose write last changed this element (server-managed, read-only; served to the world's members only, absent for the public reader); null for the world's owner and for anything last changed before writes recorded it. */
|
|
31
31
|
changed_by?: string | null;
|
|
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`, `server` (keel's own writes) or `site` (the owner signed in on onlyworlds.com). The first three are agent-made. Null for anything last changed before writes recorded it. */
|
|
32
|
+
/** The door of the last write (server-managed, read-only; served to the world's members only, absent for the public reader): `seat` (an agent seat), `mcp`, `declared` (a client that sent X-OW-Agent), then `api`, `v1`, `sync`, `server` (keel's own writes) or `site` (the owner signed in on onlyworlds.com). The first three are agent-made. Null for anything last changed before writes recorded it. */
|
|
33
33
|
changed_via?: 'seat' | 'mcp' | 'declared' | 'api' | 'v1' | 'sync' | 'server' | 'site' | null;
|
|
34
|
-
/** The name the client gave in the X-OW-Client header on the last write (server-managed, read-only): lower case letters, digits and hyphens, 1 to 32 characters, such as `sdk` or `atlas`. It is the client's claim about itself, never proof, and says nothing about whether an agent drove the write (that is `changed_via`). Null when the last write sent no name or one outside the rule, for keel's own writes, and for anything last changed before names were recorded. Sent in a write it is ignored. This SDK sends its `client` option, `sdk` by default. */
|
|
34
|
+
/** The name the client gave in the X-OW-Client header on the last write (server-managed, read-only; served to the world's members only, absent for the public reader): lower case letters, digits and hyphens, 1 to 32 characters, such as `sdk` or `atlas`. It is the client's claim about itself, never proof, and says nothing about whether an agent drove the write (that is `changed_via`). Null when the last write sent no name or one outside the rule, for keel's own writes, and for anything last changed before names were recorded. Sent in a write it is ignored. This SDK sends its `client` option, `sdk` by default. */
|
|
35
35
|
changed_client?: string | null;
|
|
36
|
+
/** Each tool that wrote this element, with the time of its last write there (server-managed, read-only): one key per tool, the name it gave in X-OW-Client or else the door word of that write (`site`, `api`, `mcp`, ...), each value the `updated_at` that write left; at most 16 keys, the one with the oldest time dropped past that. Stamped from 2026-10-29 on, so an element not written since carries none. Served to the world's members only: absent for the public reader, on a known-of stub, in the change feed's bodies and in a world file. */
|
|
37
|
+
doors?: Record<string, string>;
|
|
36
38
|
/** Present, and true, only when the world's owner or a co-builder hid this element and this reader still sees it (server-managed, read-only): the owner, a co-builder, a key the owner minted, or the member who made it; to every other reader the element does not exist. Absent otherwise, whatever `fields` asked; on the read, the list, the change feed's upserts and MCP, never in the download, world sync or v1. Sent on a create (a POST, a PUT of a new id, a bulk item that creates), `hidden: true` creates the element hidden, from the owner's keys or a co-builder's; any other key gets 403 `hidden_not_allowed` and nothing is created. On any other write it is ignored: hide and unhide with hide() and unhide(). */
|
|
37
39
|
hidden?: true;
|
|
38
40
|
/** 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(). */
|
|
@@ -5636,6 +5638,50 @@ declare function openersFor(tools: readonly OwTool[], kind: OwOpenerKind, addres
|
|
|
5636
5638
|
/** The OnlyWorlds tools list's rows (format 1), in the list's order, as of this release: the keys openersFor reads. */
|
|
5637
5639
|
declare const TOOLS: readonly OwTool[];
|
|
5638
5640
|
|
|
5641
|
+
/** One tool that wrote an element, as `doorsOf` reads it. */
|
|
5642
|
+
interface OwDoor {
|
|
5643
|
+
/** The key: the tool's client name (`X-OW-Client`), or the door word of a write that named no client (`site`, `api`, `mcp`, `seat`, `declared`, `v1`, `sync`, `server`). */
|
|
5644
|
+
door: string;
|
|
5645
|
+
/** The time of this door's last write, exactly as served (ISO 8601 with an offset). */
|
|
5646
|
+
at: string;
|
|
5647
|
+
/** The tools list's row whose `client` is `door`, as its `id` and `name`; null for a door word or a client the list does not hold. */
|
|
5648
|
+
tool: {
|
|
5649
|
+
id: string;
|
|
5650
|
+
name: string;
|
|
5651
|
+
} | null;
|
|
5652
|
+
/** True on the one entry whose `at` is the element's `updated_at`: the door of its last write. */
|
|
5653
|
+
last: boolean;
|
|
5654
|
+
/** `doors` when the entry comes from the `doors` field; `last-write` when it is read from `changed_client` or `changed_via` and `updated_at`, for an element without `doors`. */
|
|
5655
|
+
from: 'doors' | 'last-write';
|
|
5656
|
+
}
|
|
5657
|
+
/**
|
|
5658
|
+
* Which tools wrote `element`, newest first: one entry per key of its `doors` field, each `{ door, at,
|
|
5659
|
+
* tool, last, from }`. Returns data only, no words or formatted dates; a UI's "Last shaped in Atlas" line
|
|
5660
|
+
* reads the first entry, a trail reads them all.
|
|
5661
|
+
*
|
|
5662
|
+
* - From `doors`: every key that is a non-empty string, with a value that is a time, is an entry
|
|
5663
|
+
* (`from: 'doors'`, `at` the value as served). An entry that is not one is skipped, never thrown on.
|
|
5664
|
+
* - Order: newest first, times compared as instants at their full precision (an offset and the
|
|
5665
|
+
* microseconds count; never as strings). Entries at the same instant go by key, by Unicode code point.
|
|
5666
|
+
* - Without `doors`, or with no valid entry in it: one entry from the last write, its door
|
|
5667
|
+
* `changed_client` if that is a non-empty string, else `changed_via`; `at` is `updated_at`, `from` is
|
|
5668
|
+
* `last-write`. With neither door, or no valid `updated_at`, the result is empty: a public reader,
|
|
5669
|
+
* served none of these fields, gets `[]`.
|
|
5670
|
+
* - `tool`: the first row of `tools` whose `client` is the door, as `{ id, name }`; else null.
|
|
5671
|
+
* - `last`: true on the first entry whose `at` is the same instant as `updated_at`, false on the rest.
|
|
5672
|
+
* When no entry is `last`, the last write came through no door the field records: the server moves
|
|
5673
|
+
* `updated_at` on a restore or a scrub, which no door writes. Without a valid `updated_at`, no entry is
|
|
5674
|
+
* `last`.
|
|
5675
|
+
*
|
|
5676
|
+
* A time is `YYYY-MM-DDTHH:MM:SS`, an optional `.` and fraction digits, then `Z` or `+HH:MM`/`-HH:MM`,
|
|
5677
|
+
* with a real calendar date and clock; anything else is not one. Who wrote it is the caller's: compare
|
|
5678
|
+
* `changed_by` with the reader's membership for "by you" on the `last` entry.
|
|
5679
|
+
*
|
|
5680
|
+
* A TypeError when `element` is not an object (null, an array, a string) or `tools` is not an array;
|
|
5681
|
+
* nothing else throws. `tools` defaults to `TOOLS`, the tools list baked into this release.
|
|
5682
|
+
*/
|
|
5683
|
+
declare function doorsOf(element: object, tools?: readonly OwTool[]): OwDoor[];
|
|
5684
|
+
|
|
5639
5685
|
/**
|
|
5640
5686
|
* The world file, `.owworld` (Folder Format spec §4.7; a `.zip` by another
|
|
5641
5687
|
* name): one archive holding one whole world as a portable copy (§4.1), and
|
|
@@ -6678,4 +6724,4 @@ declare class TokenResource {
|
|
|
6678
6724
|
getEncryptionInfo(): Promise<EncryptionInfo>;
|
|
6679
6725
|
}
|
|
6680
6726
|
|
|
6681
|
-
export { AGENT_DOORS, ASK_LIMITS, type AccessKeyResponse, CALENDAR_FIELD, CALENDAR_SUPERTYPE, CHARTER_PAIRS, type CalendarConfig, type CalendarEra, type CalendarIntercalary, type CalendarMonths, type CalendarWeek, DATE_FIELD, ELEMENT_FAMILIES, ELEMENT_GROUPS, ELEMENT_ICONS, ELEMENT_LABELS, ELEMENT_SECTIONS, ELEMENT_TYPES, type ElementFamily, type ElementGroup, type ElementType, type EncryptionInfo, type EraDomain, FAMILY_COLORS, FAMILY_ORDER, FIELD_ACRONYMS, FIELD_SCHEMA, FILE_EXTENSIONS, type FieldInfo, type FieldType, GROUP_COLORS, GROUP_ORDER, GameTier, type ListParams, MESSAGE_PAIR, NOTE_PAIR, ONLYWORLDS_VERSION, type OwAccountWorld, type OwAddress, OwAddressError, type OwAddressForm, type OwAddressReading, type OwAddressReason, type OwAddressingOptions, type OwAgentJoined, type OwAllowance, OwApiError, type OwAskAnswer, type OwAskContext, type OwAskContextOptions, type OwAskLeftOut, type OwAuthErrorCode, type OwBulkItem, type OwBulkItemResult, type OwBulkResponse, type OwCalendarElement, type OwChange, type OwChangeDelete, type OwChangeUpsert, type OwChangesPage, type OwCharterWorld, type OwClientConfig, type OwCreateAccountWorldInput, type OwCreatedAccountWorld, type OwCreatedWorldLink, type OwDeleteReason, type OwDraught, type OwDraughtCompact, type OwDraughtComponent, type OwDraughtItem, type OwDraughtLens, type OwDraughtPolicy, type OwEdited, type OwElement, type OwElementBase, type OwErrorBody, type OwFileAddedBy, type OwFileDownload, type OwFileKind, type OwFileRow, type OwFileTicket, type OwFrontDoor, type OwGraphCutReason, type OwGraphEdge, type OwGraphMark, type OwGraphNode, type OwGraphOptions, type OwHiddenRow, type OwJoinPreview, type OwJoined, type OwJoinedMembership, type OwKeyKind, type OwLensCutReason, type OwLensMail, type OwLensOptions, type OwLensReader, type OwLensReading, type OwLensWorld, type OwLinkEdit, type OwLookupElement, type OwLookupHit, type OwLookupLink, type OwLookupOptions, type OwLookupReason, type OwMe, type OwMediaTicket, type OwMember, type OwMemberLenses, type OwMemberRole, type OwMessageMember, type OwMintedKey, type OwMySeat, type OwNamesMap, OwNetworkError, type OwOpener, type OwOpenerKind, type OwOpenerState, type OwOpenerSurface, type OwPage, type OwPhotoOptions, type OwPhotoPlan, type OwPlayerJoined, OwPreconditionFailedError, type OwPreparedPhoto, type OwProposal, type OwProposalAccepted, type OwProposalConflict, type OwProposalList, type OwProposalQuery, type OwProposalState, type OwProposeInput, type OwProposed, OwProposedError, type OwProposedMark, type OwProposedNewElement, type OwReadWorldFile, type OwReadWorldFileOptions, type OwReadingAids, type OwReadingAidsCharter, type OwReadingAidsDomain, type OwReadingAidsGuide, type OwReadingAidsHub, type OwRemovalTicket, type OwRemovedImage, type OwRenderOptions, type OwResyncReason, type OwReviewInput, type OwReviewed, type OwSeat, type OwSeatCreated, type OwSender, type OwSenderStatus, type OwSignInBegin, type OwSignInBegun, type OwSignInComplete, OwSignInError, type OwSignInReason, type OwSignInResult, type OwSignInStorage, type OwSignedIn, type OwSortAddToRow, type OwSortAnswer, type OwSortAskRow, type OwSortLinkRow, type OwSortMakeRow, type OwSortNote, type OwSortRef, type OwSortRow, OwStaleProposalError, type OwTool, type OwToolNeeds, type OwToolOpen, type OwUploadedFile, type OwUploadedImage, OwV2Client, type OwWordPair, type OwWorldFileEntry, OwWorldFileError, type OwWorldFileReason, type OwWorldFileRow, type OwWorldFiles, type OwWorldGraph, type OwWorldIndex, type OwWorldLens, type OwWorldLensReading, type OwWorldLenses, type OwWorldLink, type OwWorldMeta, type OwWorldOrigin, type OwWorldProducer, type OwWorldProposalList, type OwWorldProposalQuery, type OwWorldProposalRow, type OwWorldPublicPage, type OwWorldSource, type OwWriteDoor, type OwWriteWorldFileOptions, type OwWriteWorldFileReport, PHOTO_MAX_BYTES, PHOTO_TYPES, PROPOSED_MARK, PUBLIC_FIELDS, type ParseError, type ParseOptions, type ParseResult, REVIEW_PROPOSED_LABEL, ROOM_PAIRS, type RevokeAllSessionsResponse, type RevokeSessionResponse, SPATIAL_TYPES, type SectionInfo, type StepBreakdown, TOOLS, type TokenConsumeParams, type TokenConsumeResponse, TokenResource, type TokenStatus, type TokenTransport, WORLD_FILE_MAX_BYTES, WORLD_FILE_MAX_ENTRIES, WORLD_FILE_MEDIA_TYPE, type WorldCalendar, absYearForEraYear, absoluteYear, approxYearLength, base64url, breakdownStep, buildAskContext, buildWorldIndex, charterOf, dateOf, degreeOf, detectKeyKind, displayYear, domainsOf, draughtText, editedBy, elementAddress, elementColor, eraForStep, errorFromResponse, familyOf, fieldLabel, fileKindOf, floorDiv, floorMod, formatDuration, formatMidLabel, formatStep, formatYearLabel, getElementIcon, getElementLabel, groupOf, handsOnAsProposed, hasUnseenRecipients, intercalaryInYear, isAddressedTo, isAgentDoor, isCharterElement, isDemoKey, isKnownOf, isLeapYear, isLens, isMessage, isNote, isParseError, isRoomElement, isSentBy, isTemplate, isToEveryone, kindCanWrite, lensesInUse, lookupWorld, monthStartSteps, nfc, noteOf, openersFor, outDegreeOf, parseDate, parseErrorEnvelope, parseOwLink, pinExpectation, pkceChallenge, planPhoto, preparePhoto, proposedMarkOf, readCalendarConfig, readCalendarValue, readMarkOf, readWorldFile, readingAidOf, recipientsOf, renderElement, resolveCalendar, resolveCalendarLens, resolveEraDomains, resolveLens, senderStatus, simpleCaseFold, threadOf, typeWord, unreadFor, validateCalendarConfig, weekdayForStep, worldCalendars, worldGraph, writeWorldFile, yearLength, yearStartStep };
|
|
6727
|
+
export { AGENT_DOORS, ASK_LIMITS, type AccessKeyResponse, CALENDAR_FIELD, CALENDAR_SUPERTYPE, CHARTER_PAIRS, type CalendarConfig, type CalendarEra, type CalendarIntercalary, type CalendarMonths, type CalendarWeek, DATE_FIELD, ELEMENT_FAMILIES, ELEMENT_GROUPS, ELEMENT_ICONS, ELEMENT_LABELS, ELEMENT_SECTIONS, ELEMENT_TYPES, type ElementFamily, type ElementGroup, type ElementType, type EncryptionInfo, type EraDomain, FAMILY_COLORS, FAMILY_ORDER, FIELD_ACRONYMS, FIELD_SCHEMA, FILE_EXTENSIONS, type FieldInfo, type FieldType, GROUP_COLORS, GROUP_ORDER, GameTier, type ListParams, MESSAGE_PAIR, NOTE_PAIR, ONLYWORLDS_VERSION, type OwAccountWorld, type OwAddress, OwAddressError, type OwAddressForm, type OwAddressReading, type OwAddressReason, type OwAddressingOptions, type OwAgentJoined, type OwAllowance, OwApiError, type OwAskAnswer, type OwAskContext, type OwAskContextOptions, type OwAskLeftOut, type OwAuthErrorCode, type OwBulkItem, type OwBulkItemResult, type OwBulkResponse, type OwCalendarElement, type OwChange, type OwChangeDelete, type OwChangeUpsert, type OwChangesPage, type OwCharterWorld, type OwClientConfig, type OwCreateAccountWorldInput, type OwCreatedAccountWorld, type OwCreatedWorldLink, type OwDeleteReason, type OwDoor, type OwDraught, type OwDraughtCompact, type OwDraughtComponent, type OwDraughtItem, type OwDraughtLens, type OwDraughtPolicy, type OwEdited, type OwElement, type OwElementBase, type OwErrorBody, type OwFileAddedBy, type OwFileDownload, type OwFileKind, type OwFileRow, type OwFileTicket, type OwFrontDoor, type OwGraphCutReason, type OwGraphEdge, type OwGraphMark, type OwGraphNode, type OwGraphOptions, type OwHiddenRow, type OwJoinPreview, type OwJoined, type OwJoinedMembership, type OwKeyKind, type OwLensCutReason, type OwLensMail, type OwLensOptions, type OwLensReader, type OwLensReading, type OwLensWorld, type OwLinkEdit, type OwLookupElement, type OwLookupHit, type OwLookupLink, type OwLookupOptions, type OwLookupReason, type OwMe, type OwMediaTicket, type OwMember, type OwMemberLenses, type OwMemberRole, type OwMessageMember, type OwMintedKey, type OwMySeat, type OwNamesMap, OwNetworkError, type OwOpener, type OwOpenerKind, type OwOpenerState, type OwOpenerSurface, type OwPage, type OwPhotoOptions, type OwPhotoPlan, type OwPlayerJoined, OwPreconditionFailedError, type OwPreparedPhoto, type OwProposal, type OwProposalAccepted, type OwProposalConflict, type OwProposalList, type OwProposalQuery, type OwProposalState, type OwProposeInput, type OwProposed, OwProposedError, type OwProposedMark, type OwProposedNewElement, type OwReadWorldFile, type OwReadWorldFileOptions, type OwReadingAids, type OwReadingAidsCharter, type OwReadingAidsDomain, type OwReadingAidsGuide, type OwReadingAidsHub, type OwRemovalTicket, type OwRemovedImage, type OwRenderOptions, type OwResyncReason, type OwReviewInput, type OwReviewed, type OwSeat, type OwSeatCreated, type OwSender, type OwSenderStatus, type OwSignInBegin, type OwSignInBegun, type OwSignInComplete, OwSignInError, type OwSignInReason, type OwSignInResult, type OwSignInStorage, type OwSignedIn, type OwSortAddToRow, type OwSortAnswer, type OwSortAskRow, type OwSortLinkRow, type OwSortMakeRow, type OwSortNote, type OwSortRef, type OwSortRow, OwStaleProposalError, type OwTool, type OwToolNeeds, type OwToolOpen, type OwUploadedFile, type OwUploadedImage, OwV2Client, type OwWordPair, type OwWorldFileEntry, OwWorldFileError, type OwWorldFileReason, type OwWorldFileRow, type OwWorldFiles, type OwWorldGraph, type OwWorldIndex, type OwWorldLens, type OwWorldLensReading, type OwWorldLenses, type OwWorldLink, type OwWorldMeta, type OwWorldOrigin, type OwWorldProducer, type OwWorldProposalList, type OwWorldProposalQuery, type OwWorldProposalRow, type OwWorldPublicPage, type OwWorldSource, type OwWriteDoor, type OwWriteWorldFileOptions, type OwWriteWorldFileReport, PHOTO_MAX_BYTES, PHOTO_TYPES, PROPOSED_MARK, PUBLIC_FIELDS, type ParseError, type ParseOptions, type ParseResult, REVIEW_PROPOSED_LABEL, ROOM_PAIRS, type RevokeAllSessionsResponse, type RevokeSessionResponse, SPATIAL_TYPES, type SectionInfo, type StepBreakdown, TOOLS, type TokenConsumeParams, type TokenConsumeResponse, TokenResource, type TokenStatus, type TokenTransport, WORLD_FILE_MAX_BYTES, WORLD_FILE_MAX_ENTRIES, WORLD_FILE_MEDIA_TYPE, type WorldCalendar, absYearForEraYear, absoluteYear, approxYearLength, base64url, breakdownStep, buildAskContext, buildWorldIndex, charterOf, dateOf, degreeOf, detectKeyKind, displayYear, domainsOf, doorsOf, draughtText, editedBy, elementAddress, elementColor, eraForStep, errorFromResponse, familyOf, fieldLabel, fileKindOf, floorDiv, floorMod, formatDuration, formatMidLabel, formatStep, formatYearLabel, getElementIcon, getElementLabel, groupOf, handsOnAsProposed, hasUnseenRecipients, intercalaryInYear, isAddressedTo, isAgentDoor, isCharterElement, isDemoKey, isKnownOf, isLeapYear, isLens, isMessage, isNote, isParseError, isRoomElement, isSentBy, isTemplate, isToEveryone, kindCanWrite, lensesInUse, lookupWorld, monthStartSteps, nfc, noteOf, openersFor, outDegreeOf, parseDate, parseErrorEnvelope, parseOwLink, pinExpectation, pkceChallenge, planPhoto, preparePhoto, proposedMarkOf, readCalendarConfig, readCalendarValue, readMarkOf, readWorldFile, readingAidOf, recipientsOf, renderElement, resolveCalendar, resolveCalendarLens, resolveEraDomains, resolveLens, senderStatus, simpleCaseFold, threadOf, typeWord, unreadFor, validateCalendarConfig, weekdayForStep, worldCalendars, worldGraph, writeWorldFile, yearLength, yearStartStep };
|
package/dist/index.js
CHANGED
|
@@ -2219,17 +2219,17 @@ function xhrUpload(XHR, url, headers, body, total, onProgress) {
|
|
|
2219
2219
|
last = loaded;
|
|
2220
2220
|
onProgress(loaded, total);
|
|
2221
2221
|
};
|
|
2222
|
-
const
|
|
2222
|
+
const fail3 = (why) => () => reject(new OwNetworkError(`OnlyWorlds file upload failed: POST ${url}`, new Error(why)));
|
|
2223
2223
|
xhr.open("POST", url);
|
|
2224
2224
|
for (const [k, v] of Object.entries(headers)) xhr.setRequestHeader(k, v);
|
|
2225
2225
|
if (xhr.upload) xhr.upload.onprogress = (e) => report(Math.min(e.loaded, total));
|
|
2226
|
-
xhr.onerror =
|
|
2227
|
-
xhr.onabort =
|
|
2228
|
-
xhr.ontimeout =
|
|
2226
|
+
xhr.onerror = fail3("network error");
|
|
2227
|
+
xhr.onabort = fail3("aborted");
|
|
2228
|
+
xhr.ontimeout = fail3("timed out");
|
|
2229
2229
|
xhr.onload = () => {
|
|
2230
2230
|
const status = xhr.status;
|
|
2231
2231
|
if (!status) {
|
|
2232
|
-
|
|
2232
|
+
fail3("no answer")();
|
|
2233
2233
|
return;
|
|
2234
2234
|
}
|
|
2235
2235
|
const ok = status >= 200 && status < 300;
|
|
@@ -5334,6 +5334,86 @@ var TOOLS = [
|
|
|
5334
5334
|
}
|
|
5335
5335
|
];
|
|
5336
5336
|
|
|
5337
|
+
// src/doors.ts
|
|
5338
|
+
var TIME = /^([0-9]{4})-([0-9]{2})-([0-9]{2})T([0-9]{2}):([0-9]{2}):([0-9]{2})(?:\.([0-9]+))?(Z|([+-])([0-9]{2}):([0-9]{2}))$/;
|
|
5339
|
+
var MONTH_DAYS = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
|
|
5340
|
+
var fail2 = (what) => {
|
|
5341
|
+
throw new TypeError(`doorsOf: ${what}`);
|
|
5342
|
+
};
|
|
5343
|
+
function daysFromCivil2(year, month, day) {
|
|
5344
|
+
const y = month <= 2 ? year - 1 : year;
|
|
5345
|
+
const era = Math.floor(y / 400);
|
|
5346
|
+
const yoe = y - era * 400;
|
|
5347
|
+
const doy = Math.floor((153 * (month > 2 ? month - 3 : month + 9) + 2) / 5) + day - 1;
|
|
5348
|
+
const doe = yoe * 365 + Math.floor(yoe / 4) - Math.floor(yoe / 100) + doy;
|
|
5349
|
+
return era * 146097 + doe - 719468;
|
|
5350
|
+
}
|
|
5351
|
+
function instantOf(value) {
|
|
5352
|
+
if (typeof value !== "string") return null;
|
|
5353
|
+
const m = TIME.exec(value);
|
|
5354
|
+
if (m === null) return null;
|
|
5355
|
+
const [year, month, day, hour, minute, second] = m.slice(1, 7).map(Number);
|
|
5356
|
+
if (month < 1 || month > 12) return null;
|
|
5357
|
+
const leap = year % 4 === 0 && (year % 100 !== 0 || year % 400 === 0);
|
|
5358
|
+
if (day < 1 || day > (month === 2 && leap ? 29 : MONTH_DAYS[month - 1])) return null;
|
|
5359
|
+
if (hour > 23 || minute > 59 || second > 59) return null;
|
|
5360
|
+
let offset = 0;
|
|
5361
|
+
if (m[8] !== "Z") {
|
|
5362
|
+
const oh = Number(m[10]);
|
|
5363
|
+
const om = Number(m[11]);
|
|
5364
|
+
if (oh > 23 || om > 59) return null;
|
|
5365
|
+
offset = (m[9] === "-" ? -1 : 1) * (oh * 3600 + om * 60);
|
|
5366
|
+
}
|
|
5367
|
+
const seconds = daysFromCivil2(year, month, day) * 86400 + hour * 3600 + minute * 60 + second - offset;
|
|
5368
|
+
return { seconds, fraction: (m[7] ?? "").replace(/0+$/, "") };
|
|
5369
|
+
}
|
|
5370
|
+
function compareInstants(a, b) {
|
|
5371
|
+
if (a.seconds !== b.seconds) return a.seconds < b.seconds ? -1 : 1;
|
|
5372
|
+
const width = Math.max(a.fraction.length, b.fraction.length);
|
|
5373
|
+
const fa = a.fraction.padEnd(width, "0");
|
|
5374
|
+
const fb = b.fraction.padEnd(width, "0");
|
|
5375
|
+
return fa === fb ? 0 : fa < fb ? -1 : 1;
|
|
5376
|
+
}
|
|
5377
|
+
function compareCodePoints(a, b) {
|
|
5378
|
+
const ca = Array.from(a, (c) => c.codePointAt(0));
|
|
5379
|
+
const cb = Array.from(b, (c) => c.codePointAt(0));
|
|
5380
|
+
for (let i = 0; i < Math.min(ca.length, cb.length); i++) {
|
|
5381
|
+
if (ca[i] !== cb[i]) return ca[i] < cb[i] ? -1 : 1;
|
|
5382
|
+
}
|
|
5383
|
+
return ca.length - cb.length;
|
|
5384
|
+
}
|
|
5385
|
+
var nonEmpty = (v) => typeof v === "string" && v.length > 0;
|
|
5386
|
+
function doorsOf(element, tools = TOOLS) {
|
|
5387
|
+
if (element === null || typeof element !== "object" || Array.isArray(element)) fail2("the element is an object, as the API serves it");
|
|
5388
|
+
if (!Array.isArray(tools)) fail2("tools is the tools list's rows, an array");
|
|
5389
|
+
const e = element;
|
|
5390
|
+
const toolOf = (door) => {
|
|
5391
|
+
const row = tools.find((r) => r !== null && typeof r === "object" && r.client === door);
|
|
5392
|
+
return row === void 0 ? null : { id: row.id, name: row.name };
|
|
5393
|
+
};
|
|
5394
|
+
const found = [];
|
|
5395
|
+
const doors = e.doors;
|
|
5396
|
+
if (doors !== null && typeof doors === "object" && !Array.isArray(doors)) {
|
|
5397
|
+
for (const [door, at] of Object.entries(doors)) {
|
|
5398
|
+
const instant = instantOf(at);
|
|
5399
|
+
if (door.length > 0 && instant !== null) found.push({ door, at, instant });
|
|
5400
|
+
}
|
|
5401
|
+
}
|
|
5402
|
+
const updated = instantOf(e.updated_at);
|
|
5403
|
+
if (found.length === 0) {
|
|
5404
|
+
const door = nonEmpty(e.changed_client) ? e.changed_client : nonEmpty(e.changed_via) ? e.changed_via : null;
|
|
5405
|
+
if (door === null || updated === null) return [];
|
|
5406
|
+
return [{ door, at: e.updated_at, tool: toolOf(door), last: true, from: "last-write" }];
|
|
5407
|
+
}
|
|
5408
|
+
found.sort((a, b) => compareInstants(b.instant, a.instant) || compareCodePoints(a.door, b.door));
|
|
5409
|
+
let lastSeen = false;
|
|
5410
|
+
return found.map(({ door, at, instant }) => {
|
|
5411
|
+
const last = !lastSeen && updated !== null && compareInstants(instant, updated) === 0;
|
|
5412
|
+
if (last) lastSeen = true;
|
|
5413
|
+
return { door, at, tool: toolOf(door), last, from: "doors" };
|
|
5414
|
+
});
|
|
5415
|
+
}
|
|
5416
|
+
|
|
5337
5417
|
// src/lookup.ts
|
|
5338
5418
|
var LOOKUP_OPTION_KEYS = ["limit"];
|
|
5339
5419
|
var RENDER_OPTION_KEYS = ["descMax", "linkMax", "incomingMax"];
|
|
@@ -6951,6 +7031,7 @@ export {
|
|
|
6951
7031
|
detectKeyKind,
|
|
6952
7032
|
displayYear,
|
|
6953
7033
|
domainsOf,
|
|
7034
|
+
doorsOf,
|
|
6954
7035
|
draughtText,
|
|
6955
7036
|
editedBy,
|
|
6956
7037
|
elementAddress,
|