@onlyworlds/sdk 4.149.0 → 4.150.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 +6 -0
- package/README.md +9 -0
- package/dist/index.d.ts +45 -2
- package/dist/index.js +24 -5
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,12 @@ earlier history lives in git log only.
|
|
|
5
5
|
|
|
6
6
|
## [Unreleased]
|
|
7
7
|
|
|
8
|
+
## [4.150.0] - 2026-11-10
|
|
9
|
+
|
|
10
|
+
### Added
|
|
11
|
+
|
|
12
|
+
- **`search(q, { type, limit, viewAs })`**: the world's elements whose name or text fields hold every word of `q` as a whole word, ignoring case, as `GET /search` finds them (`OwSearchResults`: `query`, `results`, `count`, `truncated`; each `OwSearchResult` with its `type`, `id`, `name`, `supertype`, `subtype`, the `field` the words were found in, a `snippet` of it, and `known_of` on a row the reader knows of without seeing it whole). A word is a run of letters, digits or underscores, so `APP-142` is searched as two words; a snippet is a piece of one field, so read the element to keep only those that hold a key whole. No pages: `truncated` says more matched than `limit` (1 to 200) let through. On a client with `world` set it searches that world, like the other world reads. An unknown option or a `q` that is not a string sends nothing.
|
|
13
|
+
|
|
8
14
|
## [4.149.0] - 2026-11-10
|
|
9
15
|
|
|
10
16
|
### Changed
|
package/README.md
CHANGED
|
@@ -230,6 +230,15 @@ A world's owner can have agent seats propose instead of write (`agent_writes_pro
|
|
|
230
230
|
|
|
231
231
|
## Finding elements in a world
|
|
232
232
|
|
|
233
|
+
To ask onlyworlds.com, `search` finds the elements whose name or text holds every word you give, as whole words:
|
|
234
|
+
|
|
235
|
+
```typescript
|
|
236
|
+
const { results, truncated } = await client.search('APP-142', { limit: 200 });
|
|
237
|
+
results[0].field; results[0].snippet; // where the words were, and a piece of that field
|
|
238
|
+
```
|
|
239
|
+
|
|
240
|
+
A word is a run of letters, digits or underscores, so `APP-142` is two words; read an element before relying on a key it must hold whole. There are no pages: `truncated` means more matched than `limit` (at most 200) let through.
|
|
241
|
+
|
|
233
242
|
When you hold a world's elements in memory (from a sync, or a world file), `lookupWorld` finds the ones a plain question is about, with no model and no network:
|
|
234
243
|
|
|
235
244
|
```typescript
|
package/dist/index.d.ts
CHANGED
|
@@ -2491,6 +2491,30 @@ interface OwPage<T = OwElement> {
|
|
|
2491
2491
|
has_more: boolean;
|
|
2492
2492
|
next_cursor: string | null;
|
|
2493
2493
|
}
|
|
2494
|
+
/** One element `search()` found: where the words were, and a short plain-text piece around the first match. */
|
|
2495
|
+
interface OwSearchResult {
|
|
2496
|
+
type: ElementType;
|
|
2497
|
+
id: string;
|
|
2498
|
+
name: string;
|
|
2499
|
+
supertype: string;
|
|
2500
|
+
subtype: string;
|
|
2501
|
+
/** Where the words were found: `name`, or the first text field (in the type's schema order) that holds them all, else the first that holds any. */
|
|
2502
|
+
field: string;
|
|
2503
|
+
/** Up to 160 characters of that field around the first match, as plain text. Never the whole field: read the element for its text. */
|
|
2504
|
+
snippet: string;
|
|
2505
|
+
/** Present, and true, only when the reader knows of the element without seeing it whole: it matched on what a known-of stub keeps. */
|
|
2506
|
+
known_of?: true;
|
|
2507
|
+
}
|
|
2508
|
+
/** search()'s answer: every element whose name or text holds every word of `q` as a whole word, up to `limit`. */
|
|
2509
|
+
interface OwSearchResults {
|
|
2510
|
+
/** `q` as searched (trimmed). */
|
|
2511
|
+
query: string;
|
|
2512
|
+
results: OwSearchResult[];
|
|
2513
|
+
/** How many results came back. */
|
|
2514
|
+
count: number;
|
|
2515
|
+
/** True when more elements matched than `limit` let through. There are no further pages: narrow `q` or `type`, or raise `limit`. */
|
|
2516
|
+
truncated: boolean;
|
|
2517
|
+
}
|
|
2494
2518
|
/** /changes feed -- discriminated union on `op`. Apply in order -> convergence. */
|
|
2495
2519
|
type OwChange = OwChangeUpsert | OwChangeDelete;
|
|
2496
2520
|
/** A /changes item for an element written: the element whole, as GET returns it. */
|
|
@@ -4044,7 +4068,7 @@ interface OwClientConfig {
|
|
|
4044
4068
|
/**
|
|
4045
4069
|
* The key: an ow_w_ (write) or ow_r_ (read) world key, an ow_a_ account token (sent as a Bearer token, for the account routes, and with `world` set for that world's reads), or a 10-digit legacy key.
|
|
4046
4070
|
* Leave it out for a client that holds none, such as a friend with only a link (since 4.30.0): it can call health,
|
|
4047
|
-
* previewJoin, redeemJoin and signInWithPassword (and with `world` set, list, listAll, get, getWorld and draught), and any
|
|
4071
|
+
* previewJoin, redeemJoin and signInWithPassword (and with `world` set, list, listAll, get, search, getWorld and draught), and any
|
|
4048
4072
|
* other call is a TypeError before anything is sent.
|
|
4049
4073
|
*/
|
|
4050
4074
|
apiKey?: string;
|
|
@@ -4779,6 +4803,25 @@ declare class OwV2Client {
|
|
|
4779
4803
|
* it reads that world, sending `world=<id>`.
|
|
4780
4804
|
*/
|
|
4781
4805
|
get(type: ElementType | string, id: string, opts?: Pick<ListParams, 'expand' | 'fields' | 'viewAs' | 'signal'>): Promise<OwElement>;
|
|
4806
|
+
/**
|
|
4807
|
+
* GET /search -- the world's elements whose `name` or text fields (`description` and the type's other prose
|
|
4808
|
+
* fields; never supertype, subtype or image_url) hold every word of `q` as a whole word, ignoring case. A word
|
|
4809
|
+
* is a run of letters, digits or underscores, so `APP-142` is searched as the two words `APP` and `142`: a
|
|
4810
|
+
* result's `snippet` is a piece of one field, so read the element to keep only those that hold the key whole.
|
|
4811
|
+
* No stemming, no pages: `truncated` says more matched than `limit` (1 to 200, the server's default 50) let
|
|
4812
|
+
* through. `type` searches one type; `viewAs` reads as another reader (the owner's keys). A guest's key finds
|
|
4813
|
+
* only what it may read. On a client with `world` set (an account token or no key), it searches that world.
|
|
4814
|
+
*
|
|
4815
|
+
* ```ts
|
|
4816
|
+
* const { results, truncated } = await client.search('APP-142', { limit: 200 });
|
|
4817
|
+
* ```
|
|
4818
|
+
*/
|
|
4819
|
+
search(q: string, opts?: {
|
|
4820
|
+
type?: ElementType;
|
|
4821
|
+
limit?: number;
|
|
4822
|
+
viewAs?: string;
|
|
4823
|
+
signal?: AbortSignal;
|
|
4824
|
+
}): Promise<OwSearchResults>;
|
|
4782
4825
|
/**
|
|
4783
4826
|
* POST /{type}/ -- create one element, minting an id on the client when you leave id out.
|
|
4784
4827
|
* With an `idempotencyKey`, the minted id is derived from the key (a UUIDv5, the same one the
|
|
@@ -7709,4 +7752,4 @@ declare class TokenResource {
|
|
|
7709
7752
|
getEncryptionInfo(): Promise<EncryptionInfo>;
|
|
7710
7753
|
}
|
|
7711
7754
|
|
|
7712
|
-
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 OwAccountToken, type OwAccountWorld, type OwAddress, OwAddressError, type OwAddressForm, type OwAddressReading, type OwAddressReason, type OwAddressingOptions, type OwAgentJoined, type OwAiAskAnswer, type OwAiAskBody, type OwAiMeter, type OwAiRefusal, type OwAiSortAnswer, type OwAiSortBody, type OwAiToken, type OwAiUse, 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 OwDragField, type OwDraught, type OwDraughtCompact, type OwDraughtComponent, type OwDraughtItem, type OwDraughtLens, type OwDraughtPolicy, type OwEdited, type OwElement, type OwElementBase, type OwElementMark, 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 OwLanding, type OwLandingCluster, type OwLandingGap, type OwLandingGapKind, type OwLandingMember, type OwLandingMode, type OwLandingOptions, type OwLayoutOf, 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 OwMapSpace, type OwMapSpaceMap, type OwMapSpaceOutReason, type OwMapSpaceOutline, type OwMapSpacePin, type OwMapSpacePoint, type OwMe, type OwMediaTicket, type OwMember, type OwMemberLenses, type OwMemberRole, type OwMessageMember, type OwMintedAiToken, type OwMintedKey, type OwMySeat, type OwNamesMap, OwNetworkError, type OwOpener, type OwOpenerKind, type OwOpenerState, type OwOpenerSurface, type OwOpenersOptions, type OwPage, type OwPaidBy, 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 OwRecord, type OwRecordMark, type OwRecordStory, type OwRemovalTicket, type OwRemovedImage, type OwRenderOptions, type OwResyncReason, type OwReviewInput, type OwReviewed, type OwSeat, type OwSeatCreated, type OwSender, type OwSenderStatus, type OwServedReadingAids, 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 OwStrand, type OwStrandSlot, type OwStrandWorld, type OwTool, type OwToolNeeds, type OwToolOpen, type OwTrailGround, type OwTrailHanger, type OwTrailInput, type OwTrailLayout, type OwTrailPin, type OwTrailPlace, type OwTrailSettings, type OwTrailSpiral, type OwTrailTier, type OwUploadedFile, type OwUploadedImage, OwV2Client, type OwView, type OwViewRow, type OwViewsTable, type OwWordPair, type OwWorldFileEntry, OwWorldFileError, type OwWorldFileReason, type OwWorldFileRow, type OwWorldFiles, type OwWorldGraph, type OwWorldIndex, type OwWorldKeyMember, type OwWorldKeyRow, 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, RECORD_FIELD, REVIEW_PROPOSED_LABEL, ROOM_PAIRS, type RevokeAllSessionsResponse, type RevokeSessionResponse, SPATIAL_TYPES, STRAND_FIELD, type SectionInfo, type StepBreakdown, TOOLS, TRAIL_TIERS, type TokenConsumeParams, type TokenConsumeResponse, TokenResource, type TokenStatus, type TokenTransport, VIEWS, 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, doorWhere, doorsOf, dragField, 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, landingOf, layoutOf, lensesInUse, lookupWorld, mapSpace, monthStartSteps, nfc, noteOf, openersFor, outDegreeOf, parseDate, parseErrorEnvelope, parseOwLink, pinExpectation, pkceChallenge, planPhoto, preparePhoto, proposedMarkOf, readCalendarConfig, readCalendarValue, readMarkOf, readWorldFile, readingAidOf, recipientsOf, recordMarkOf, recordsOf, renderElement, resolveCalendar, resolveCalendarLens, resolveEraDomains, resolveLens, roundHalfEven, senderStatus, simpleCaseFold, strandOf, threadOf, trailByPlace, typeWord, unreadFor, validateCalendarConfig, viewOf, weekdayForStep, worldCalendars, worldGraph, writeWorldFile, yearLength, yearStartStep };
|
|
7755
|
+
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 OwAccountToken, type OwAccountWorld, type OwAddress, OwAddressError, type OwAddressForm, type OwAddressReading, type OwAddressReason, type OwAddressingOptions, type OwAgentJoined, type OwAiAskAnswer, type OwAiAskBody, type OwAiMeter, type OwAiRefusal, type OwAiSortAnswer, type OwAiSortBody, type OwAiToken, type OwAiUse, 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 OwDragField, type OwDraught, type OwDraughtCompact, type OwDraughtComponent, type OwDraughtItem, type OwDraughtLens, type OwDraughtPolicy, type OwEdited, type OwElement, type OwElementBase, type OwElementMark, 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 OwLanding, type OwLandingCluster, type OwLandingGap, type OwLandingGapKind, type OwLandingMember, type OwLandingMode, type OwLandingOptions, type OwLayoutOf, 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 OwMapSpace, type OwMapSpaceMap, type OwMapSpaceOutReason, type OwMapSpaceOutline, type OwMapSpacePin, type OwMapSpacePoint, type OwMe, type OwMediaTicket, type OwMember, type OwMemberLenses, type OwMemberRole, type OwMessageMember, type OwMintedAiToken, type OwMintedKey, type OwMySeat, type OwNamesMap, OwNetworkError, type OwOpener, type OwOpenerKind, type OwOpenerState, type OwOpenerSurface, type OwOpenersOptions, type OwPage, type OwPaidBy, 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 OwRecord, type OwRecordMark, type OwRecordStory, type OwRemovalTicket, type OwRemovedImage, type OwRenderOptions, type OwResyncReason, type OwReviewInput, type OwReviewed, type OwSearchResult, type OwSearchResults, type OwSeat, type OwSeatCreated, type OwSender, type OwSenderStatus, type OwServedReadingAids, 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 OwStrand, type OwStrandSlot, type OwStrandWorld, type OwTool, type OwToolNeeds, type OwToolOpen, type OwTrailGround, type OwTrailHanger, type OwTrailInput, type OwTrailLayout, type OwTrailPin, type OwTrailPlace, type OwTrailSettings, type OwTrailSpiral, type OwTrailTier, type OwUploadedFile, type OwUploadedImage, OwV2Client, type OwView, type OwViewRow, type OwViewsTable, type OwWordPair, type OwWorldFileEntry, OwWorldFileError, type OwWorldFileReason, type OwWorldFileRow, type OwWorldFiles, type OwWorldGraph, type OwWorldIndex, type OwWorldKeyMember, type OwWorldKeyRow, 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, RECORD_FIELD, REVIEW_PROPOSED_LABEL, ROOM_PAIRS, type RevokeAllSessionsResponse, type RevokeSessionResponse, SPATIAL_TYPES, STRAND_FIELD, type SectionInfo, type StepBreakdown, TOOLS, TRAIL_TIERS, type TokenConsumeParams, type TokenConsumeResponse, TokenResource, type TokenStatus, type TokenTransport, VIEWS, 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, doorWhere, doorsOf, dragField, 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, landingOf, layoutOf, lensesInUse, lookupWorld, mapSpace, monthStartSteps, nfc, noteOf, openersFor, outDegreeOf, parseDate, parseErrorEnvelope, parseOwLink, pinExpectation, pkceChallenge, planPhoto, preparePhoto, proposedMarkOf, readCalendarConfig, readCalendarValue, readMarkOf, readWorldFile, readingAidOf, recipientsOf, recordMarkOf, recordsOf, renderElement, resolveCalendar, resolveCalendarLens, resolveEraDomains, resolveLens, roundHalfEven, senderStatus, simpleCaseFold, strandOf, threadOf, trailByPlace, typeWord, unreadFor, validateCalendarConfig, viewOf, weekdayForStep, worldCalendars, worldGraph, writeWorldFile, yearLength, yearStartStep };
|
package/dist/index.js
CHANGED
|
@@ -1024,6 +1024,25 @@ var OwV2Client = class {
|
|
|
1024
1024
|
const query = buildQuery({ expand: opts.expand?.join(","), fields: opts.fields?.join(","), as: opts.viewAs });
|
|
1025
1025
|
return this.request("GET", `/${seg("type", type)}/${seg("id", id)}/`, { query, worldRead: true, ...withSignal(opts.signal) });
|
|
1026
1026
|
}
|
|
1027
|
+
/**
|
|
1028
|
+
* GET /search -- the world's elements whose `name` or text fields (`description` and the type's other prose
|
|
1029
|
+
* fields; never supertype, subtype or image_url) hold every word of `q` as a whole word, ignoring case. A word
|
|
1030
|
+
* is a run of letters, digits or underscores, so `APP-142` is searched as the two words `APP` and `142`: a
|
|
1031
|
+
* result's `snippet` is a piece of one field, so read the element to keep only those that hold the key whole.
|
|
1032
|
+
* No stemming, no pages: `truncated` says more matched than `limit` (1 to 200, the server's default 50) let
|
|
1033
|
+
* through. `type` searches one type; `viewAs` reads as another reader (the owner's keys). A guest's key finds
|
|
1034
|
+
* only what it may read. On a client with `world` set (an account token or no key), it searches that world.
|
|
1035
|
+
*
|
|
1036
|
+
* ```ts
|
|
1037
|
+
* const { results, truncated } = await client.search('APP-142', { limit: 200 });
|
|
1038
|
+
* ```
|
|
1039
|
+
*/
|
|
1040
|
+
async search(q, opts = {}) {
|
|
1041
|
+
only("search", opts, ["type", "limit", "viewAs", "signal"]);
|
|
1042
|
+
if (typeof q !== "string") throw new TypeError("search: `q` is the words to find, a string of 2 to 200 characters. Nothing was sent.");
|
|
1043
|
+
const query = buildQuery({ q, type: opts.type, limit: opts.limit, as: opts.viewAs });
|
|
1044
|
+
return this.request("GET", "/search", { query, worldRead: true, ...withSignal(opts.signal) });
|
|
1045
|
+
}
|
|
1027
1046
|
/**
|
|
1028
1047
|
* POST /{type}/ -- create one element, minting an id on the client when you leave id out.
|
|
1029
1048
|
* With an `idempotencyKey`, the minted id is derived from the key (a UUIDv5, the same one the
|
|
@@ -2338,14 +2357,14 @@ var OwV2Client = class {
|
|
|
2338
2357
|
const worldRead = opts.auth !== false && opts.worldRead === true && method.toUpperCase() === "GET";
|
|
2339
2358
|
const accountToken = opts.auth !== false && this.keyKind === "account" ? opts.accountToken : void 0;
|
|
2340
2359
|
if (opts.auth !== false && this.keyKind === "none" && !(worldRead && this.world !== void 0)) {
|
|
2341
|
-
throw new TypeError(`${method} ${path} needs a key, and this client holds none: without one, only health, previewJoin, redeemJoin and signInWithPassword work, and list, listAll, get, getWorld and draught with \`world\` set`);
|
|
2360
|
+
throw new TypeError(`${method} ${path} needs a key, and this client holds none: without one, only health, previewJoin, redeemJoin and signInWithPassword work, and list, listAll, get, search, getWorld and draught with \`world\` set`);
|
|
2342
2361
|
}
|
|
2343
2362
|
if (opts.auth !== false && this.keyKind === "account" && !ACCOUNT_ROUTE.test(path)) {
|
|
2344
2363
|
if (!worldRead && accountToken === void 0) {
|
|
2345
|
-
throw new TypeError(`${method} ${path} needs a world key: an account token sends the /account routes, worldLenses, setMyLenses and members, and with \`world\` set reads a world through list, listAll, get, getWorld and draught only. Nothing was sent.`);
|
|
2364
|
+
throw new TypeError(`${method} ${path} needs a world key: an account token sends the /account routes, worldLenses, setMyLenses and members, and with \`world\` set reads a world through list, listAll, get, search, getWorld and draught only. Nothing was sent.`);
|
|
2346
2365
|
}
|
|
2347
2366
|
if (worldRead && this.world === void 0) {
|
|
2348
|
-
throw new TypeError(`${method} ${path}: an account token reads a world only with \`world\` set (new OwV2Client({ apiKey, world })), through list, listAll, get, getWorld and draught. Nothing was sent.`);
|
|
2367
|
+
throw new TypeError(`${method} ${path}: an account token reads a world only with \`world\` set (new OwV2Client({ apiKey, world })), through list, listAll, get, search, getWorld and draught. Nothing was sent.`);
|
|
2349
2368
|
}
|
|
2350
2369
|
if (accountToken === "world" && this.world === void 0) {
|
|
2351
2370
|
throw new TypeError(`${method} ${path}: an account token names the world it sends to with \`world\`: set it (new OwV2Client({ apiKey, world })). Nothing was sent.`);
|
|
@@ -2611,10 +2630,10 @@ var CLIENT_CONFIG_KEYS = ["apiKey", "apiPin", "baseUrl", "pageSize", "changesPag
|
|
|
2611
2630
|
function worldOf(value, keyKind) {
|
|
2612
2631
|
if (value === void 0) return void 0;
|
|
2613
2632
|
if (typeof value !== "string" || value.trim() === "") {
|
|
2614
|
-
throw new TypeError(`OwV2Client: world is a world's id, a non-empty string; got ${JSON.stringify(value) ?? String(value)}. With it, an account token or no key reads that world through list, listAll, get, getWorld and draught.`);
|
|
2633
|
+
throw new TypeError(`OwV2Client: world is a world's id, a non-empty string; got ${JSON.stringify(value) ?? String(value)}. With it, an account token or no key reads that world through list, listAll, get, search, getWorld and draught.`);
|
|
2615
2634
|
}
|
|
2616
2635
|
if (keyKind !== "account" && keyKind !== "none") {
|
|
2617
|
-
throw new TypeError("OwV2Client: a world key reads its own world; `world` is for an account token or no key, which read the world it names through list, listAll, get, getWorld and draught.");
|
|
2636
|
+
throw new TypeError("OwV2Client: a world key reads its own world; `world` is for an account token or no key, which read the world it names through list, listAll, get, search, getWorld and draught.");
|
|
2618
2637
|
}
|
|
2619
2638
|
return value;
|
|
2620
2639
|
}
|