@onlyworlds/sdk 4.106.0 → 4.107.1

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,6 +1,6 @@
1
1
  # For AI agents using @onlyworlds/sdk
2
2
 
3
- **Current as of**: SDK **4.x** · schema-dist **v0.33.0-dist.90** (canonical 00.33.00).
3
+ **Current as of**: SDK **4.x** · schema-dist **v0.33.0-dist.91** (canonical 00.33.00).
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
 
package/CHANGELOG.md CHANGED
@@ -5,6 +5,18 @@ earlier history lives in git log only.
5
5
 
6
6
  ## [Unreleased]
7
7
 
8
+ ## [4.107.1] - 2026-10-29
9
+
10
+ ### Changed
11
+
12
+ - **Schema repinned to schema-dist `v0.33.0-dist.91`** (from dist.90; the same canonical 00.33.00, so `ONLYWORLDS_VERSION` stays `'00.33.00'`). Serial 91, no change to what the package reads or writes: the dist's folder checker (`walk/lint_folder.py`) moves to folder format 0.3.21 and takes `doors` on an element file as a server-managed key beside `changed_client`, and its README says 0.3.21. No code changed.
13
+
14
+ ## [4.107.0] - 2026-10-29
15
+
16
+ ### Added
17
+
18
+ - **`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.
19
+
8
20
  ## [4.106.0] - 2026-10-29
9
21
 
10
22
  ### Added
package/SCHEMA.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # OnlyWorlds Schema Reference
2
2
 
3
- **Source**: https://github.com/OnlyWorlds/schema-dist @ **v0.33.0-dist.90** — canonical schema **00.33.00**, published 2026-10-29.
3
+ **Source**: https://github.com/OnlyWorlds/schema-dist @ **v0.33.0-dist.91** — canonical schema **00.33.00**, published 2026-10-29.
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.
package/dist/index.d.ts CHANGED
@@ -5638,6 +5638,50 @@ declare function openersFor(tools: readonly OwTool[], kind: OwOpenerKind, addres
5638
5638
  /** The OnlyWorlds tools list's rows (format 1), in the list's order, as of this release: the keys openersFor reads. */
5639
5639
  declare const TOOLS: readonly OwTool[];
5640
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
+
5641
5685
  /**
5642
5686
  * The world file, `.owworld` (Folder Format spec §4.7; a `.zip` by another
5643
5687
  * name): one archive holding one whole world as a portable copy (§4.1), and
@@ -6680,4 +6724,4 @@ declare class TokenResource {
6680
6724
  getEncryptionInfo(): Promise<EncryptionInfo>;
6681
6725
  }
6682
6726
 
6683
- 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 fail2 = (why) => () => reject(new OwNetworkError(`OnlyWorlds file upload failed: POST ${url}`, new Error(why)));
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 = fail2("network error");
2227
- xhr.onabort = fail2("aborted");
2228
- xhr.ontimeout = fail2("timed out");
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
- fail2("no answer")();
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,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@onlyworlds/sdk",
3
- "version": "4.106.0",
3
+ "version": "4.107.1",
4
4
  "description": "TypeScript SDK for the OnlyWorlds API - build world-building applications with type safety",
5
5
  "type": "module",
6
6
  "exports": {