@relyio/sdk 0.4.0 → 0.6.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 +193 -0
- package/dist/.tsbuildinfo +1 -1
- package/dist/{chunk-43VPZT2G.js → chunk-7ABNXVWL.js} +464 -200
- package/dist/{chunk-HAQELDZN.cjs → chunk-DY2XT7OF.cjs} +2 -2
- package/dist/{chunk-XS32U2UP.cjs → chunk-GCMQUM6N.cjs} +466 -199
- package/dist/{chunk-XY5KFEFY.js → chunk-XJVY2CLY.js} +2 -2
- package/dist/client/index.cjs +3 -3
- package/dist/client/index.d.cts +5 -4
- package/dist/client/index.d.ts +5 -4
- package/dist/client/index.js +1 -1
- package/dist/define-content-type-CDB3kyeA.d.cts +1173 -0
- package/dist/define-content-type-CDB3kyeA.d.ts +1173 -0
- package/dist/{define-schema-DzYXk4HL.d.ts → define-schema-1kr2HIzN.d.cts} +25 -347
- package/dist/{define-schema-2xbHgtK-.d.cts → define-schema-ChvAzY8H.d.ts} +25 -347
- package/dist/{index-BzOFJJKS.d.ts → index-Df1VsfJR.d.cts} +334 -72
- package/dist/{index-BvO6HDtY.d.cts → index-XqoGUaAY.d.ts} +334 -72
- package/dist/{index-DFehx5sI.d.cts → index-d1Kz1e19.d.cts} +191 -29
- package/dist/{index-FDak5ofk.d.ts → index-yPbhZc6q.d.ts} +191 -29
- package/dist/index.cjs +161 -68
- package/dist/index.d.cts +302 -8
- package/dist/index.d.ts +302 -8
- package/dist/index.js +90 -3
- package/dist/schema/index.cjs +35 -35
- package/dist/schema/index.d.cts +11 -7
- package/dist/schema/index.d.ts +11 -7
- package/dist/schema/index.js +1 -1
- package/dist/types/index.d.cts +2 -2
- package/dist/types/index.d.ts +2 -2
- package/package.json +3 -3
- package/dist/define-content-type-CBfnTWSS.d.cts +0 -716
- package/dist/define-content-type-CBfnTWSS.d.ts +0 -716
|
@@ -1,6 +1,69 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { a as SchemaDefinition, b as SchemaContentTypeNames,
|
|
3
|
-
import {
|
|
1
|
+
import { N as MergedRelyIOConfig, A as ApiPath, a as ApiMethod, O as PathParamsOf, v as ApiResponse, W as Wire, u as RequestConfig, B as BaseContent, f as WhereClause, h as SortOptions, i as ContentQueryResult, Q as QueryOptions, C as CreateInput, U as UpdateInput, S as SDKError, z as BaseValidationError, y as ValidationViolation, T as components, X as paths, R as RelyIOConfig } from './index-yPbhZc6q.js';
|
|
2
|
+
import { a as SchemaDefinition, b as SchemaContentTypeNames, j as SchemaEntryOf, h as SchemaAssetTypeNames, c as SchemaSingletonNames, g as SchemaSettingsGroupNames, I as InferSettingsGroup, e as SchemaQueryNames, f as SchemaLocaleCodes } from './define-schema-ChvAzY8H.js';
|
|
3
|
+
import { Q as InferContentType, a6 as InferAssetType, a0 as InferSingleton } from './define-content-type-CDB3kyeA.js';
|
|
4
|
+
import { DevUnreadableReason } from './dev-handshake/index.js';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Dev-mode detection for `relyio dev` sandboxes — the SDK's I/O shell over `../dev-handshake`.
|
|
8
|
+
*
|
|
9
|
+
* Every rule about the handshake — the path, the env names, the required fields, the deadline —
|
|
10
|
+
* lives in `@relyio/sdk/dev-handshake`, which `relyio dev` imports too. What is left here is the
|
|
11
|
+
* part that is genuinely the SDK's: reading env and walking the filesystem from the cwd, both of
|
|
12
|
+
* which have to happen without a static `node:*` import so the module stays browser-safe.
|
|
13
|
+
*
|
|
14
|
+
* Node access goes through `process.getBuiltinModule` (Node ≥ 20.16 / 22, and the platform targets
|
|
15
|
+
* Node 24), which is absent in browsers and edge runtimes — so the resolver is inert everywhere it
|
|
16
|
+
* should be, and a bundler never has to shim `fs`.
|
|
17
|
+
*
|
|
18
|
+
* **Order: env, then file.** The wrapped-child env is the primary carrier and wins. Before REL-647
|
|
19
|
+
* it won *unconditionally*, because it had no deadline to lose on; it now goes through the same
|
|
20
|
+
* rule the file does.
|
|
21
|
+
*/
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* What the handshake says about the sandbox, as the preview toolbar displays it
|
|
25
|
+
* (`sdk-surfaces-spec.md` decision 22). `TypedRelyIOClient.sandbox` returns it.
|
|
26
|
+
*
|
|
27
|
+
* **Plain data, on purpose.** In Next the toolbar is rendered from a server layout, and a client
|
|
28
|
+
* cannot cross the RSC boundary — while the browser cannot read the handshake at all, because this
|
|
29
|
+
* module is inert without `process.getBuiltinModule`. So the server-created client's `sandbox` is the
|
|
30
|
+
* prop the toolbar is handed, and it has to survive `JSON` unchanged: strings and `null`, dates as
|
|
31
|
+
* the ISO strings the handshake carried, no class instances.
|
|
32
|
+
*
|
|
33
|
+
* **No key.** The handshake also carries the sandbox's preview key; that is the client's credential,
|
|
34
|
+
* held beside this value in {@link DevResolution} and never inside it, so handing the state around
|
|
35
|
+
* does not hand the key with it.
|
|
36
|
+
*
|
|
37
|
+
* - `active` — the client targets the sandbox. `branchId` is `null` from the env carrier, which names
|
|
38
|
+
* no branch; only `.relyio/dev.json` does. `expiresAt` is `null` for an unbounded sandbox.
|
|
39
|
+
* - `expired` / `unreadable` — a handshake was found and refused; the client targets the configured
|
|
40
|
+
* dataset and key, and `mergeConfig` has said so on the console.
|
|
41
|
+
* - `absent` — no handshake on either carrier. This is also what a browser or edge runtime reads,
|
|
42
|
+
* since neither can see the env or the file.
|
|
43
|
+
* - `disabled` — detection did not run: `dev: false` was passed, or `NODE_ENV === 'production'`
|
|
44
|
+
* and `dev: true` was not.
|
|
45
|
+
*/
|
|
46
|
+
type SandboxState = {
|
|
47
|
+
state: 'active';
|
|
48
|
+
datasetId: string;
|
|
49
|
+
branchId: string | null;
|
|
50
|
+
expiresAt: string | null;
|
|
51
|
+
source: 'env' | 'file';
|
|
52
|
+
} | {
|
|
53
|
+
state: 'expired';
|
|
54
|
+
expiredAt: string;
|
|
55
|
+
} | {
|
|
56
|
+
state: 'unreadable';
|
|
57
|
+
reason: DevUnreadableReason;
|
|
58
|
+
} | {
|
|
59
|
+
state: 'absent';
|
|
60
|
+
} | {
|
|
61
|
+
state: 'disabled';
|
|
62
|
+
};
|
|
63
|
+
/** The sandbox the client targets, once a carrier has been accepted. */
|
|
64
|
+
type ActiveSandbox = Extract<SandboxState, {
|
|
65
|
+
state: 'active';
|
|
66
|
+
}>;
|
|
4
67
|
|
|
5
68
|
/**
|
|
6
69
|
* What a call site supplies beside the route it named.
|
|
@@ -67,6 +130,12 @@ declare class HttpClient {
|
|
|
67
130
|
* The loop always makes one attempt. The incumbent's `while (attempt <
|
|
68
131
|
* maxAttempts)` made none at `retryAttempts: 0` — a value the config validator
|
|
69
132
|
* accepts — and then dereferenced an unassigned `lastError`.
|
|
133
|
+
*
|
|
134
|
+
* A request that would carry no `X-API-Key` makes none: it rejects with
|
|
135
|
+
* `MissingApiKeyError` before `fetch` is called, is not retried, and names
|
|
136
|
+
* `apiKey`. This is where a client built without a key learns it — the
|
|
137
|
+
* constructor accepts one so that a module-scope client can be evaluated by a
|
|
138
|
+
* build that holds no key (REL-1120).
|
|
70
139
|
*/
|
|
71
140
|
request<T = unknown>(config: RequestConfig): Promise<ApiResponse<T>>;
|
|
72
141
|
/**
|
|
@@ -133,8 +202,6 @@ declare class HttpClient {
|
|
|
133
202
|
private mergeRequestConfig;
|
|
134
203
|
private buildQueryString;
|
|
135
204
|
private headersToObject;
|
|
136
|
-
/** A backoff the caller's abort cuts short; the next attempt then refuses to send. */
|
|
137
|
-
private sleep;
|
|
138
205
|
private log;
|
|
139
206
|
}
|
|
140
207
|
|
|
@@ -189,7 +256,14 @@ declare class ContentQueryBuilder<T extends BaseContent = BaseContent> {
|
|
|
189
256
|
private childrenOptions?;
|
|
190
257
|
private pageNumber?;
|
|
191
258
|
private pageSizeValue?;
|
|
259
|
+
private requestHeaders?;
|
|
192
260
|
constructor(httpClient: HttpClient, contentType: string, defaultLocale?: string | undefined);
|
|
261
|
+
/**
|
|
262
|
+
* Headers this query adds to the client's own, e.g. `X-RelyIO-Dataset` to list another dataset
|
|
263
|
+
* the key can see. A name the client already sends is replaced for this query only; the client
|
|
264
|
+
* is not changed.
|
|
265
|
+
*/
|
|
266
|
+
headers(headers: Record<string, string>): this;
|
|
193
267
|
/**
|
|
194
268
|
* Add where conditions to the query
|
|
195
269
|
*/
|
|
@@ -391,6 +465,7 @@ declare class ContentByIdBuilder<T extends BaseContent = BaseContent> {
|
|
|
391
465
|
private localesArray?;
|
|
392
466
|
private fetchAllLocales;
|
|
393
467
|
private childrenOptions?;
|
|
468
|
+
private requestHeaders?;
|
|
394
469
|
constructor(httpClient: HttpClient, contentType: string, id: string, defaultLocale?: string | undefined);
|
|
395
470
|
/**
|
|
396
471
|
* Include related content in the response
|
|
@@ -408,6 +483,12 @@ declare class ContentByIdBuilder<T extends BaseContent = BaseContent> {
|
|
|
408
483
|
* @param localeCodes - Array of locale codes to fetch
|
|
409
484
|
*/
|
|
410
485
|
locales(localeCodes: string[]): this;
|
|
486
|
+
/**
|
|
487
|
+
* Headers this one read adds to the client's own, e.g. `X-RelyIO-Dataset` to read another dataset
|
|
488
|
+
* the key can see. A name the client already sends is replaced for this request only; the client
|
|
489
|
+
* is not changed.
|
|
490
|
+
*/
|
|
491
|
+
headers(headers: Record<string, string>): this;
|
|
411
492
|
/**
|
|
412
493
|
* Fetch content in all available locales
|
|
413
494
|
* Returns default locale at top level, others in _metadata.localizations
|
|
@@ -556,11 +637,13 @@ declare class ContentClient<T extends BaseContent = BaseContent> {
|
|
|
556
637
|
/**
|
|
557
638
|
* Fetch a single content item by ID
|
|
558
639
|
* @param id - Entry ID or slug
|
|
559
|
-
* @param options - Fetch options (include, locale
|
|
640
|
+
* @param options - Fetch options (include, locale, and `headers` this one request adds — e.g.
|
|
641
|
+
* `{ 'X-RelyIO-Dataset': 'staging' }` to read a dataset other than the client's)
|
|
560
642
|
*/
|
|
561
643
|
fetchOne(id: string, options?: {
|
|
562
644
|
include?: string[];
|
|
563
645
|
locale?: string;
|
|
646
|
+
headers?: Record<string, string>;
|
|
564
647
|
}): Promise<T | null>;
|
|
565
648
|
/**
|
|
566
649
|
* Fetch one entry **and the entity tag that read served**.
|
|
@@ -574,10 +657,16 @@ declare class ContentClient<T extends BaseContent = BaseContent> {
|
|
|
574
657
|
* `entityTag` is `undefined` when the response came from the cache: a cached
|
|
575
658
|
* body cannot know the current version, and an absent tag beats a stale one
|
|
576
659
|
* that would refuse the next write.
|
|
660
|
+
*
|
|
661
|
+
* Unlike {@link fetchOne}, a missing entry is not `null`: the service's
|
|
662
|
+
* `RESOURCE_NOT_FOUND` is thrown as it arrived, with the `kind` that says
|
|
663
|
+
* whether the entry, the content type or the schema was missing. `headers`
|
|
664
|
+
* are the ones this read adds, as for `fetchOne`.
|
|
577
665
|
*/
|
|
578
666
|
fetchOneWithTag(id: string, options?: {
|
|
579
667
|
include?: string[];
|
|
580
668
|
locale?: string;
|
|
669
|
+
headers?: Record<string, string>;
|
|
581
670
|
}): Promise<{
|
|
582
671
|
entry: T;
|
|
583
672
|
entityTag?: string;
|
|
@@ -591,25 +680,32 @@ declare class ContentClient<T extends BaseContent = BaseContent> {
|
|
|
591
680
|
/**
|
|
592
681
|
* Create a new content item
|
|
593
682
|
* @param data - Content data
|
|
594
|
-
* @param options - Create options (slug, locale, parentId, sortOrder)
|
|
683
|
+
* @param options - Create options (slug, locale, parentId, sortOrder), and `headers` this one
|
|
684
|
+
* request adds — e.g. `{ 'X-RelyIO-Dataset': 'staging' }` to write a dataset other than the
|
|
685
|
+
* client's. They are sent, never put in the body; `idempotencyKey` still wins over an
|
|
686
|
+
* `Idempotency-Key` among them.
|
|
595
687
|
*/
|
|
596
688
|
create(data: CreateInput<T>, options?: {
|
|
597
689
|
slug?: string;
|
|
598
690
|
locale?: string;
|
|
599
691
|
parentId?: string;
|
|
600
692
|
sortOrder?: number;
|
|
693
|
+
headers?: Record<string, string>;
|
|
601
694
|
} & RetryableWriteOptions): Promise<T>;
|
|
602
695
|
/**
|
|
603
696
|
* Update a content item by ID (partial update)
|
|
604
697
|
* @param id - Entry ID
|
|
605
698
|
* @param data - Fields to update
|
|
606
|
-
* @param options - Update options (slug, locale, parentId, sortOrder)
|
|
699
|
+
* @param options - Update options (slug, locale, parentId, sortOrder), and `headers` this one
|
|
700
|
+
* request adds, as for {@link create}. `ifMatch` and `idempotencyKey` win over the same
|
|
701
|
+
* header among them.
|
|
607
702
|
*/
|
|
608
703
|
update(id: string, data: UpdateInput<T>, options?: {
|
|
609
704
|
slug?: string;
|
|
610
705
|
locale?: string;
|
|
611
706
|
parentId?: string;
|
|
612
707
|
sortOrder?: number;
|
|
708
|
+
headers?: Record<string, string>;
|
|
613
709
|
} & ConditionalWriteOptions): Promise<T>;
|
|
614
710
|
/**
|
|
615
711
|
* Delete a content item by ID
|
|
@@ -1167,6 +1263,9 @@ interface SingletonFetchOptions {
|
|
|
1167
1263
|
* Singleton client for managing singleton content operations
|
|
1168
1264
|
* Provides a fluent API for singleton operations following the same pattern as ContentClient
|
|
1169
1265
|
*
|
|
1266
|
+
* A read is in the locale it names — `fetch({ locale })`, then `.locale()` — and otherwise in
|
|
1267
|
+
* `defaultLocale`, the client's own (`withLocale()`), as `content()`'s reads are.
|
|
1268
|
+
*
|
|
1170
1269
|
* @example
|
|
1171
1270
|
* ```typescript
|
|
1172
1271
|
* const homepage = await client.singleton('homepage')
|
|
@@ -1178,9 +1277,10 @@ interface SingletonFetchOptions {
|
|
|
1178
1277
|
declare class SingletonClient<T = unknown> {
|
|
1179
1278
|
private httpClient;
|
|
1180
1279
|
private singletonKey;
|
|
1280
|
+
private readonly defaultLocale?;
|
|
1181
1281
|
private includeFields?;
|
|
1182
1282
|
private localeValue?;
|
|
1183
|
-
constructor(httpClient: HttpClient, singletonKey: string);
|
|
1283
|
+
constructor(httpClient: HttpClient, singletonKey: string, defaultLocale?: string | undefined);
|
|
1184
1284
|
/**
|
|
1185
1285
|
* Include reference fields in the response
|
|
1186
1286
|
* @param fields - Reference field names to populate
|
|
@@ -1265,6 +1365,9 @@ interface SettingsFetchOptions {
|
|
|
1265
1365
|
* Settings client for managing settings group operations
|
|
1266
1366
|
* Provides a fluent API for settings operations following the same pattern as ContentClient
|
|
1267
1367
|
*
|
|
1368
|
+
* A read is in the locale it names — `fetch({ locale })`, then `.locale()` — and otherwise in
|
|
1369
|
+
* `defaultLocale`, the client's own (`withLocale()`), as `content()`'s reads are.
|
|
1370
|
+
*
|
|
1268
1371
|
* @example
|
|
1269
1372
|
* ```typescript
|
|
1270
1373
|
* const emailConfig = await client.settings('email-config')
|
|
@@ -1276,9 +1379,10 @@ interface SettingsFetchOptions {
|
|
|
1276
1379
|
declare class SettingsClient<T = unknown> {
|
|
1277
1380
|
private readonly httpClient;
|
|
1278
1381
|
private readonly groupId;
|
|
1382
|
+
private readonly defaultLocale?;
|
|
1279
1383
|
private includeFields?;
|
|
1280
1384
|
private localeValue?;
|
|
1281
|
-
constructor(httpClient: HttpClient, groupId: string);
|
|
1385
|
+
constructor(httpClient: HttpClient, groupId: string, defaultLocale?: string | undefined);
|
|
1282
1386
|
/**
|
|
1283
1387
|
* Include reference fields in the response
|
|
1284
1388
|
* @param fields - Reference field names to populate
|
|
@@ -1355,6 +1459,41 @@ declare class SettingsClient<T = unknown> {
|
|
|
1355
1459
|
resetOptions(): this;
|
|
1356
1460
|
}
|
|
1357
1461
|
|
|
1462
|
+
/**
|
|
1463
|
+
* Any schema the client can be typed by. `any` is deliberate: the client accepts whatever content
|
|
1464
|
+
* types, components, singletons, queries and settings groups a customer declares.
|
|
1465
|
+
*
|
|
1466
|
+
* This is the constraint `TypedRelyIOClient`'s `TSchema` carries, so `RegisteredSchema` is inferred
|
|
1467
|
+
* against the same one — `createClient` returns `TypedRelyIOClient<RegisteredSchema>`, and a schema
|
|
1468
|
+
* inferred against any wider alias would not be provably inside the client's bound.
|
|
1469
|
+
*/
|
|
1470
|
+
type AnySchemaDefinition = SchemaDefinition<any, any, any, any, any>;
|
|
1471
|
+
/**
|
|
1472
|
+
* The seam `relyio generate-types` fills (`INV-SS-TYPES-INFERRED`).
|
|
1473
|
+
*
|
|
1474
|
+
* Empty here on purpose. The generated `schema.ts` augments it —
|
|
1475
|
+
*
|
|
1476
|
+
* ```ts
|
|
1477
|
+
* declare module '@relyio/sdk' {
|
|
1478
|
+
* interface Register {
|
|
1479
|
+
* schema: typeof schema
|
|
1480
|
+
* }
|
|
1481
|
+
* }
|
|
1482
|
+
* ```
|
|
1483
|
+
*
|
|
1484
|
+
* — and from then on `createClient({ apiKey })`, with no generic and no `schema:`, is typed by that
|
|
1485
|
+
* schema. The pattern is TanStack Router's. It is type-level only: nothing at runtime reads it.
|
|
1486
|
+
*/
|
|
1487
|
+
interface Register {
|
|
1488
|
+
}
|
|
1489
|
+
/**
|
|
1490
|
+
* The schema the project registered through `Register`, or `undefined` when nothing did — which is
|
|
1491
|
+
* the untyped client, exactly as before the generator ran.
|
|
1492
|
+
*/
|
|
1493
|
+
type RegisteredSchema = Register extends {
|
|
1494
|
+
schema: infer S extends AnySchemaDefinition;
|
|
1495
|
+
} ? S : undefined;
|
|
1496
|
+
|
|
1358
1497
|
/**
|
|
1359
1498
|
* Search mode for content queries
|
|
1360
1499
|
*/
|
|
@@ -1430,12 +1569,31 @@ type SimilarResponse<T = unknown> = Wire<'/v1/search/similar', 'post', SimilarRe
|
|
|
1430
1569
|
* Filter conditions for search
|
|
1431
1570
|
*/
|
|
1432
1571
|
type SearchFilter = Record<string, unknown>;
|
|
1572
|
+
/**
|
|
1573
|
+
* The content type names a search may be scoped to: the schema's where one types the client, any
|
|
1574
|
+
* name where none does.
|
|
1575
|
+
*/
|
|
1576
|
+
type SearchTypeName<S extends AnySchemaDefinition | undefined> = S extends AnySchemaDefinition ? SchemaContentTypeNames<S> : string;
|
|
1577
|
+
/**
|
|
1578
|
+
* What a search over the content types `K` returns: their entries, typed by the schema
|
|
1579
|
+
* (`INV-SS-TYPES-INFERRED`) — or `T` unchanged where no schema types the client.
|
|
1580
|
+
*/
|
|
1581
|
+
type SearchEntry<S extends AnySchemaDefinition | undefined, K extends SearchTypeName<S> = SearchTypeName<S>, T extends BaseContent = BaseContent> = S extends AnySchemaDefinition ? SchemaEntryOf<S, K & SchemaContentTypeNames<S>> : T;
|
|
1433
1582
|
/**
|
|
1434
1583
|
* Field projection for search results
|
|
1435
1584
|
*/
|
|
1436
1585
|
type SearchFields<T> = {
|
|
1437
1586
|
[K: string]: keyof T | string;
|
|
1438
1587
|
};
|
|
1588
|
+
/**
|
|
1589
|
+
* One ordering of `POST /v1/search`'s results, as the route's `sort` array takes it.
|
|
1590
|
+
*/
|
|
1591
|
+
interface SearchSort {
|
|
1592
|
+
/** Field path, or `_score` for relevance */
|
|
1593
|
+
field: string;
|
|
1594
|
+
/** Direction; the route's default is `desc` */
|
|
1595
|
+
direction: 'asc' | 'desc';
|
|
1596
|
+
}
|
|
1439
1597
|
/**
|
|
1440
1598
|
* Fluent builder for search queries
|
|
1441
1599
|
*
|
|
@@ -1450,21 +1608,33 @@ type SearchFields<T> = {
|
|
|
1450
1608
|
* .execute()
|
|
1451
1609
|
* ```
|
|
1452
1610
|
*/
|
|
1453
|
-
declare class SearchBuilder<T extends BaseContent = BaseContent> {
|
|
1611
|
+
declare class SearchBuilder<T extends BaseContent = BaseContent, S extends AnySchemaDefinition | undefined = undefined> {
|
|
1454
1612
|
private readonly httpClient;
|
|
1613
|
+
private readonly defaultLocale?;
|
|
1455
1614
|
private query;
|
|
1456
1615
|
private searchOptions;
|
|
1457
|
-
|
|
1616
|
+
private requestHeaders?;
|
|
1458
1617
|
/**
|
|
1459
|
-
*
|
|
1618
|
+
* @param defaultLocale - The client's locale (`withLocale()`), sent when `.locale()` names none
|
|
1619
|
+
*/
|
|
1620
|
+
constructor(httpClient: HttpClient, query: string, defaultLocale?: string | undefined);
|
|
1621
|
+
/**
|
|
1622
|
+
* Headers this search adds to the client's own, e.g. `X-RelyIO-Dataset` to search another
|
|
1623
|
+
* dataset the key can see. A name the client already sends is replaced for this search only.
|
|
1624
|
+
*/
|
|
1625
|
+
headers(headers: Record<string, string>): this;
|
|
1626
|
+
/**
|
|
1627
|
+
* Search within a single content type. Where a schema types the client, the name is one of its
|
|
1628
|
+
* content types and the results are that type's entries.
|
|
1460
1629
|
* @param contentType - Content type to search in
|
|
1461
1630
|
*/
|
|
1462
|
-
in<K extends
|
|
1631
|
+
in<K extends SearchTypeName<S>>(contentType: K): SearchBuilder<SearchEntry<S, K, T>, S>;
|
|
1463
1632
|
/**
|
|
1464
|
-
* Search across multiple content types
|
|
1633
|
+
* Search across multiple content types. Where a schema types the client, the names are its content
|
|
1634
|
+
* types and the results are a union of their entries — every type's, for `'*'`.
|
|
1465
1635
|
* @param contentTypes - Array of content types or '*' for all
|
|
1466
1636
|
*/
|
|
1467
|
-
across(contentTypes:
|
|
1637
|
+
across<K extends SearchTypeName<S>>(contentTypes: K[] | '*'): SearchBuilder<SearchEntry<S, K, T>, S>;
|
|
1468
1638
|
/**
|
|
1469
1639
|
* Add filter conditions
|
|
1470
1640
|
* @param conditions - Filter conditions
|
|
@@ -1480,6 +1650,13 @@ declare class SearchBuilder<T extends BaseContent = BaseContent> {
|
|
|
1480
1650
|
* @param projection - Field mapping
|
|
1481
1651
|
*/
|
|
1482
1652
|
fields(projection: Record<string, string>): this;
|
|
1653
|
+
/**
|
|
1654
|
+
* Order the results by a field instead of by relevance. Called again, it adds a tie-breaker.
|
|
1655
|
+
* `_score` names relevance itself.
|
|
1656
|
+
* @param field - Field path to sort by (e.g. `updatedAt`, `pricing.basePrice`)
|
|
1657
|
+
* @param direction - `asc` or `desc` (the route's default is `desc`)
|
|
1658
|
+
*/
|
|
1659
|
+
sort(field: string, direction?: 'asc' | 'desc'): this;
|
|
1483
1660
|
/**
|
|
1484
1661
|
* Limit number of results
|
|
1485
1662
|
* @param count - Maximum results
|
|
@@ -1531,9 +1708,13 @@ declare class SearchBuilder<T extends BaseContent = BaseContent> {
|
|
|
1531
1708
|
*/
|
|
1532
1709
|
declare class AutocompleteBuilder {
|
|
1533
1710
|
private readonly httpClient;
|
|
1711
|
+
private readonly defaultLocale?;
|
|
1534
1712
|
private query;
|
|
1535
1713
|
private autocompleteOptions;
|
|
1536
|
-
|
|
1714
|
+
/**
|
|
1715
|
+
* @param defaultLocale - The client's locale (`withLocale()`), sent when `.locale()` names none
|
|
1716
|
+
*/
|
|
1717
|
+
constructor(httpClient: HttpClient, query: string, defaultLocale?: string | undefined);
|
|
1537
1718
|
/**
|
|
1538
1719
|
* Autocomplete within a content type
|
|
1539
1720
|
* @param contentType - Content type to search
|
|
@@ -1586,14 +1767,29 @@ declare class AutocompleteBuilder {
|
|
|
1586
1767
|
*/
|
|
1587
1768
|
declare class SimilarBuilder<T extends BaseContent = BaseContent> {
|
|
1588
1769
|
private readonly httpClient;
|
|
1770
|
+
private readonly defaultLocale?;
|
|
1589
1771
|
private sourceId;
|
|
1590
1772
|
private similarOptions;
|
|
1591
|
-
|
|
1773
|
+
private requestHeaders?;
|
|
1774
|
+
/**
|
|
1775
|
+
* @param defaultLocale - The client's locale (`withLocale()`), sent when `.locale()` names none
|
|
1776
|
+
*/
|
|
1777
|
+
constructor(httpClient: HttpClient, sourceId: string, defaultLocale?: string | undefined);
|
|
1778
|
+
/**
|
|
1779
|
+
* Headers this read adds to the client's own, e.g. `X-RelyIO-Dataset` to read another dataset
|
|
1780
|
+
* the key can see. A name the client already sends is replaced for this read only.
|
|
1781
|
+
*/
|
|
1782
|
+
headers(headers: Record<string, string>): this;
|
|
1592
1783
|
/**
|
|
1593
1784
|
* Find similar content within a content type
|
|
1594
1785
|
* @param contentType - Content type to search
|
|
1595
1786
|
*/
|
|
1596
1787
|
in(contentType: string): this;
|
|
1788
|
+
/**
|
|
1789
|
+
* Find similar content across several content types, or `'*'` for every type
|
|
1790
|
+
* @param contentTypes - Array of content types or '*' for all
|
|
1791
|
+
*/
|
|
1792
|
+
across(contentTypes: string[] | '*'): this;
|
|
1597
1793
|
/**
|
|
1598
1794
|
* Add filter conditions
|
|
1599
1795
|
* @param conditions - Filter conditions
|
|
@@ -1649,12 +1845,17 @@ declare class SimilarBuilder<T extends BaseContent = BaseContent> {
|
|
|
1649
1845
|
*/
|
|
1650
1846
|
declare class SearchClient {
|
|
1651
1847
|
private readonly httpClient;
|
|
1652
|
-
|
|
1848
|
+
private readonly defaultLocale?;
|
|
1849
|
+
/**
|
|
1850
|
+
* @param defaultLocale - The client's locale (`withLocale()`): every builder here sends it when
|
|
1851
|
+
* the query names none, as `content()`'s reads do
|
|
1852
|
+
*/
|
|
1853
|
+
constructor(httpClient: HttpClient, defaultLocale?: string | undefined);
|
|
1653
1854
|
/**
|
|
1654
1855
|
* Start a search query
|
|
1655
1856
|
* @param query - Search query string
|
|
1656
1857
|
*/
|
|
1657
|
-
search<T extends BaseContent = BaseContent>(query: string): SearchBuilder<T>;
|
|
1858
|
+
search<T extends BaseContent = BaseContent, S extends AnySchemaDefinition | undefined = undefined>(query: string): SearchBuilder<T, S>;
|
|
1658
1859
|
/**
|
|
1659
1860
|
* Start an autocomplete query
|
|
1660
1861
|
* @param query - Partial query to autocomplete
|
|
@@ -1773,6 +1974,7 @@ declare class BatchBuilder<TSchema = unknown> {
|
|
|
1773
1974
|
private readonly httpClient;
|
|
1774
1975
|
private operations;
|
|
1775
1976
|
private defaultOptions;
|
|
1977
|
+
private requestHeaders;
|
|
1776
1978
|
constructor(httpClient: HttpClient);
|
|
1777
1979
|
/**
|
|
1778
1980
|
* Add a create operation
|
|
@@ -1910,6 +2112,12 @@ declare class BatchBuilder<TSchema = unknown> {
|
|
|
1910
2112
|
* Stop on first error (non-atomic mode)
|
|
1911
2113
|
*/
|
|
1912
2114
|
stopOnError(): this;
|
|
2115
|
+
/**
|
|
2116
|
+
* Headers the batch request adds — e.g. `{ 'X-RelyIO-Dataset': 'staging' }` to write a dataset
|
|
2117
|
+
* other than the client's. They replace the client's own header of the same name for this
|
|
2118
|
+
* request alone, and apply to every operation in it: a batch is one request.
|
|
2119
|
+
*/
|
|
2120
|
+
headers(headers: Record<string, string>): this;
|
|
1913
2121
|
/**
|
|
1914
2122
|
* Get the current list of operations
|
|
1915
2123
|
*/
|
|
@@ -2030,20 +2238,26 @@ interface FetchBlock {
|
|
|
2030
2238
|
interface AggregateBlock {
|
|
2031
2239
|
/** Source content type or query reference */
|
|
2032
2240
|
source: string;
|
|
2241
|
+
/**
|
|
2242
|
+
* Filter conditions applied before grouping, in the Query DSL's spelling — bare operator names
|
|
2243
|
+
* (`{ price: { gte: 10 } }`), not the list route's `$gte`. A `$`-prefixed key is not an operator
|
|
2244
|
+
* in this dialect: the service reads the object as a nested field and drops it.
|
|
2245
|
+
*/
|
|
2246
|
+
where?: Record<string, unknown>;
|
|
2033
2247
|
/** Field to group by */
|
|
2034
2248
|
by?: string | string[];
|
|
2035
|
-
/** Metrics to compute */
|
|
2249
|
+
/** Metrics to compute, keyed by the name each one answers under */
|
|
2036
2250
|
metrics: Record<string, AggregateMetric>;
|
|
2037
2251
|
}
|
|
2038
2252
|
/**
|
|
2039
|
-
*
|
|
2253
|
+
* One metric, as the Query DSL writes it: `<field>.<fn>`, where `fn` is `count`, `sum`, `avg`,
|
|
2254
|
+
* `min` or `max` — `'id.count'`, `'pricing.basePrice.avg'`. The service validates every metric
|
|
2255
|
+
* against that form (`INVALID_AGGREGATION_EXPRESSION`); `count` ignores the field it names.
|
|
2256
|
+
*
|
|
2257
|
+
* It used to be `{ fn, field? }`, a shape the service refuses on every request: the validator
|
|
2258
|
+
* tests the metric as a string, so an object arrives as `[object Object]`.
|
|
2040
2259
|
*/
|
|
2041
|
-
|
|
2042
|
-
/** Aggregation function */
|
|
2043
|
-
fn: 'count' | 'sum' | 'avg' | 'min' | 'max' | 'first' | 'last';
|
|
2044
|
-
/** Field to aggregate (optional for count) */
|
|
2045
|
-
field?: string;
|
|
2046
|
-
}
|
|
2260
|
+
type AggregateMetric = `${string}.${'count' | 'sum' | 'avg' | 'min' | 'max'}`;
|
|
2047
2261
|
/**
|
|
2048
2262
|
* Search block for full-text/semantic search
|
|
2049
2263
|
*/
|
|
@@ -2202,10 +2416,15 @@ interface AdhocQueryResult<T = unknown> {
|
|
|
2202
2416
|
*/
|
|
2203
2417
|
declare class AdhocQueryBuilder<T = unknown> {
|
|
2204
2418
|
private readonly httpClient;
|
|
2419
|
+
private readonly defaultLocale?;
|
|
2205
2420
|
private queryDef;
|
|
2206
2421
|
private parameters;
|
|
2207
2422
|
private options;
|
|
2208
|
-
|
|
2423
|
+
/**
|
|
2424
|
+
* @param defaultLocale - The client's locale (`withLocale()`), sent as the `locale` parameter
|
|
2425
|
+
* when `.param('locale', …)` binds none
|
|
2426
|
+
*/
|
|
2427
|
+
constructor(httpClient: HttpClient, defaultLocale?: string | undefined);
|
|
2209
2428
|
/**
|
|
2210
2429
|
* Add a fetch block to retrieve content
|
|
2211
2430
|
* @param config - Fetch configuration
|
|
@@ -2364,7 +2583,12 @@ declare class AdhocQueryBuilder<T = unknown> {
|
|
|
2364
2583
|
*/
|
|
2365
2584
|
declare class AdhocQueryClient {
|
|
2366
2585
|
private readonly httpClient;
|
|
2367
|
-
|
|
2586
|
+
private readonly defaultLocale?;
|
|
2587
|
+
/**
|
|
2588
|
+
* @param defaultLocale - The client's locale (`withLocale()`), sent as the `locale` parameter of
|
|
2589
|
+
* every query that binds none
|
|
2590
|
+
*/
|
|
2591
|
+
constructor(httpClient: HttpClient, defaultLocale?: string | undefined);
|
|
2368
2592
|
/**
|
|
2369
2593
|
* Create a new query builder
|
|
2370
2594
|
*/
|
|
@@ -2374,8 +2598,13 @@ declare class AdhocQueryClient {
|
|
|
2374
2598
|
* @param definition - Query definition
|
|
2375
2599
|
* @param parameters - Parameter values
|
|
2376
2600
|
* @param options - Execution options
|
|
2601
|
+
* @param request - `headers` this one request adds to the client's own, e.g. `X-RelyIO-Dataset`
|
|
2602
|
+
* to query another dataset the key can see. A name the client already sends is replaced for
|
|
2603
|
+
* this request only.
|
|
2377
2604
|
*/
|
|
2378
|
-
execute<T = unknown>(definition: AdhocQueryDefinition, parameters?: Record<string, unknown>, options?: AdhocQueryOptions
|
|
2605
|
+
execute<T = unknown>(definition: AdhocQueryDefinition, parameters?: Record<string, unknown>, options?: AdhocQueryOptions, request?: {
|
|
2606
|
+
headers?: Record<string, string>;
|
|
2607
|
+
}): Promise<AdhocQueryResult<T>>;
|
|
2379
2608
|
/**
|
|
2380
2609
|
* Quick fetch helper
|
|
2381
2610
|
* @param contentType - Content type
|
|
@@ -2521,42 +2750,20 @@ interface ChangesOptions {
|
|
|
2521
2750
|
*/
|
|
2522
2751
|
onExpired?: 'throw' | 'resync' | ((expired: ChangesExpiredError) => void | Promise<void>);
|
|
2523
2752
|
}
|
|
2753
|
+
interface ChangesHeadOptions {
|
|
2754
|
+
/** Cancels the request; the promise then rejects. */
|
|
2755
|
+
signal?: AbortSignal;
|
|
2756
|
+
}
|
|
2524
2757
|
|
|
2525
2758
|
/**
|
|
2526
|
-
*
|
|
2527
|
-
*
|
|
2528
|
-
*
|
|
2529
|
-
* This is the constraint `TypedRelyIOClient`'s `TSchema` carries, so `RegisteredSchema` is inferred
|
|
2530
|
-
* against the same one — `createClient` returns `TypedRelyIOClient<RegisteredSchema>`, and a schema
|
|
2531
|
-
* inferred against any wider alias would not be provably inside the client's bound.
|
|
2532
|
-
*/
|
|
2533
|
-
type AnySchemaDefinition = SchemaDefinition<any, any, any, any, any>;
|
|
2534
|
-
/**
|
|
2535
|
-
* The seam `relyio generate-types` fills (`INV-SS-TYPES-INFERRED`).
|
|
2536
|
-
*
|
|
2537
|
-
* Empty here on purpose. The generated `schema.ts` augments it —
|
|
2538
|
-
*
|
|
2539
|
-
* ```ts
|
|
2540
|
-
* declare module '@relyio/sdk' {
|
|
2541
|
-
* interface Register {
|
|
2542
|
-
* schema: typeof schema
|
|
2543
|
-
* }
|
|
2544
|
-
* }
|
|
2545
|
-
* ```
|
|
2759
|
+
* The key's project, as `GET /v1/project` describes it: organization, project, dataset and branch,
|
|
2760
|
+
* each by id and name, and `studioUrl` — the Studio root the preview toolbar deep-links from
|
|
2761
|
+
* (`sdk-surfaces-spec.md` decision 24), or `null` when the service has no Dashboard address.
|
|
2546
2762
|
*
|
|
2547
|
-
*
|
|
2548
|
-
*
|
|
2549
|
-
*/
|
|
2550
|
-
interface Register {
|
|
2551
|
-
}
|
|
2552
|
-
/**
|
|
2553
|
-
* The schema the project registered through `Register`, or `undefined` when nothing did — which is
|
|
2554
|
-
* the untyped client, exactly as before the generator ran.
|
|
2763
|
+
* Read from the committed document's `application/json` content by name, never written here
|
|
2764
|
+
* (`INV-API-CLIENT-IS-DERIVED`); `derived-transport.types.ts` holds the two equal.
|
|
2555
2765
|
*/
|
|
2556
|
-
type
|
|
2557
|
-
schema: infer S extends AnySchemaDefinition;
|
|
2558
|
-
} ? S : undefined;
|
|
2559
|
-
|
|
2766
|
+
type Project = paths['/v1/project']['get']['responses'][200]['content']['application/json']['data'];
|
|
2560
2767
|
/**
|
|
2561
2768
|
* Client configuration with optional schema
|
|
2562
2769
|
*/
|
|
@@ -2592,6 +2799,7 @@ interface TypedClientConfig<TSchema extends AnySchemaDefinition | undefined = un
|
|
|
2592
2799
|
declare class TypedRelyIOClient<TSchema extends AnySchemaDefinition | undefined = undefined> {
|
|
2593
2800
|
private httpClient;
|
|
2594
2801
|
private config;
|
|
2802
|
+
private _sandbox;
|
|
2595
2803
|
private _search;
|
|
2596
2804
|
private _batch;
|
|
2597
2805
|
private _adhocQuery;
|
|
@@ -2601,6 +2809,21 @@ declare class TypedRelyIOClient<TSchema extends AnySchemaDefinition | undefined
|
|
|
2601
2809
|
* Get the schema definition
|
|
2602
2810
|
*/
|
|
2603
2811
|
get schema(): TSchema;
|
|
2812
|
+
/**
|
|
2813
|
+
* The `relyio dev` sandbox this client resolved at construction, as the preview toolbar displays
|
|
2814
|
+
* it (`sdk-surfaces-spec.md` decision 22).
|
|
2815
|
+
*
|
|
2816
|
+
* Plain, JSON-serializable data and no key, so a server component can hand it to a client
|
|
2817
|
+
* component as a prop — the browser cannot read the handshake itself, so a client created there
|
|
2818
|
+
* reports `absent`. See {@link SandboxState} for what each state means.
|
|
2819
|
+
*
|
|
2820
|
+
* @example
|
|
2821
|
+
* ```tsx
|
|
2822
|
+
* // app/layout.tsx — a server component handing the state to a client component
|
|
2823
|
+
* <SandboxBadge sandbox={relyio.sandbox} />
|
|
2824
|
+
* ```
|
|
2825
|
+
*/
|
|
2826
|
+
get sandbox(): SandboxState;
|
|
2604
2827
|
/**
|
|
2605
2828
|
* Get the ad-hoc query client
|
|
2606
2829
|
*/
|
|
@@ -2619,7 +2842,7 @@ declare class TypedRelyIOClient<TSchema extends AnySchemaDefinition | undefined
|
|
|
2619
2842
|
* .execute()
|
|
2620
2843
|
* ```
|
|
2621
2844
|
*/
|
|
2622
|
-
content<K extends TSchema extends AnySchemaDefinition ? SchemaContentTypeNames<TSchema> : string>(contentType: K): TSchema extends AnySchemaDefinition ? ContentClient<InferContentType<TSchema['contentTypes'][K & keyof TSchema['contentTypes']]>> : ContentClient<BaseContent>;
|
|
2845
|
+
content<K extends TSchema extends AnySchemaDefinition ? SchemaContentTypeNames<TSchema> : string>(contentType: K): TSchema extends AnySchemaDefinition ? ContentClient<InferContentType<TSchema['contentTypes'][K & keyof TSchema['contentTypes']], TSchema>> : ContentClient<BaseContent>;
|
|
2623
2846
|
/**
|
|
2624
2847
|
* Get an asset client for a specific asset type.
|
|
2625
2848
|
*
|
|
@@ -2638,7 +2861,7 @@ declare class TypedRelyIOClient<TSchema extends AnySchemaDefinition | undefined
|
|
|
2638
2861
|
* const heroUrl = await relyio.asset('productPhoto').file(photo._metadata.id).url({ variantId: 'hero' })
|
|
2639
2862
|
* ```
|
|
2640
2863
|
*/
|
|
2641
|
-
asset<K extends TSchema extends AnySchemaDefinition ? SchemaAssetTypeNames<TSchema> : string>(assetType: K): TSchema extends AnySchemaDefinition ? AssetClient<InferAssetType<NonNullable<TSchema['assetTypes']>[K & keyof NonNullable<TSchema['assetTypes']>]>> : AssetClient<BaseContent>;
|
|
2864
|
+
asset<K extends TSchema extends AnySchemaDefinition ? SchemaAssetTypeNames<TSchema> : string>(assetType: K): TSchema extends AnySchemaDefinition ? AssetClient<InferAssetType<NonNullable<TSchema['assetTypes']>[K & keyof NonNullable<TSchema['assetTypes']>], TSchema>> : AssetClient<BaseContent>;
|
|
2642
2865
|
/**
|
|
2643
2866
|
* Get a singleton client for a specific singleton key
|
|
2644
2867
|
* Type-safe when schema is provided: autocompletes singleton names AND field names
|
|
@@ -2651,7 +2874,7 @@ declare class TypedRelyIOClient<TSchema extends AnySchemaDefinition | undefined
|
|
|
2651
2874
|
* .fetch()
|
|
2652
2875
|
* ```
|
|
2653
2876
|
*/
|
|
2654
|
-
singleton<K extends TSchema extends AnySchemaDefinition ? SchemaSingletonNames<TSchema> : string>(key: K): TSchema extends AnySchemaDefinition ? SingletonClient<InferSingleton<TSchema['singletonContentTypes'][K & keyof TSchema['singletonContentTypes']]>> : SingletonClient<unknown>;
|
|
2877
|
+
singleton<K extends TSchema extends AnySchemaDefinition ? SchemaSingletonNames<TSchema> : string>(key: K): TSchema extends AnySchemaDefinition ? SingletonClient<InferSingleton<TSchema['singletonContentTypes'][K & keyof TSchema['singletonContentTypes']], TSchema>> : SingletonClient<unknown>;
|
|
2655
2878
|
/**
|
|
2656
2879
|
* Get a settings client for a specific settings group
|
|
2657
2880
|
* Type-safe when schema is provided: autocompletes settings group names AND field names
|
|
@@ -2663,9 +2886,12 @@ declare class TypedRelyIOClient<TSchema extends AnySchemaDefinition | undefined
|
|
|
2663
2886
|
* .fetch()
|
|
2664
2887
|
* ```
|
|
2665
2888
|
*/
|
|
2666
|
-
settings<K extends TSchema extends AnySchemaDefinition ? SchemaSettingsGroupNames<TSchema> : string>(groupId: K): TSchema extends AnySchemaDefinition ? SettingsClient<InferSettingsGroup<NonNullable<TSchema['settingsGroups']>[K & keyof NonNullable<TSchema['settingsGroups']>]>> : SettingsClient<unknown>;
|
|
2889
|
+
settings<K extends TSchema extends AnySchemaDefinition ? SchemaSettingsGroupNames<TSchema> : string>(groupId: K): TSchema extends AnySchemaDefinition ? SettingsClient<InferSettingsGroup<NonNullable<TSchema['settingsGroups']>[K & keyof NonNullable<TSchema['settingsGroups']>], TSchema>> : SettingsClient<unknown>;
|
|
2667
2890
|
/**
|
|
2668
|
-
* Start a search query with full-text, semantic, or hybrid search
|
|
2891
|
+
* Start a search query with full-text, semantic, or hybrid search.
|
|
2892
|
+
*
|
|
2893
|
+
* Where a schema types the client, the results are its entries — every content type's until
|
|
2894
|
+
* `in()` or `across()` narrows them (`INV-SS-TYPES-INFERRED`).
|
|
2669
2895
|
*
|
|
2670
2896
|
* @example
|
|
2671
2897
|
* ```typescript
|
|
@@ -2677,7 +2903,7 @@ declare class TypedRelyIOClient<TSchema extends AnySchemaDefinition | undefined
|
|
|
2677
2903
|
* .execute()
|
|
2678
2904
|
* ```
|
|
2679
2905
|
*/
|
|
2680
|
-
search<T extends BaseContent =
|
|
2906
|
+
search<T extends BaseContent = SearchEntry<TSchema>>(query: string): SearchBuilder<T, TSchema>;
|
|
2681
2907
|
/**
|
|
2682
2908
|
* Start an autocomplete query for search suggestions
|
|
2683
2909
|
*
|
|
@@ -2747,6 +2973,23 @@ declare class TypedRelyIOClient<TSchema extends AnySchemaDefinition | undefined
|
|
|
2747
2973
|
* ```
|
|
2748
2974
|
*/
|
|
2749
2975
|
changes(options?: ChangesOptions): AsyncIterable<Change>;
|
|
2976
|
+
/**
|
|
2977
|
+
* The dataset's current position in the changes feed, as a cursor to start
|
|
2978
|
+
* `changes({ since })` or `followChanges(…, { since })` from. One
|
|
2979
|
+
* `GET /v1/changes` without a cursor: answered at once, holding nothing.
|
|
2980
|
+
*
|
|
2981
|
+
* Take it **before** you read what you will follow. A write your read did not
|
|
2982
|
+
* see is then after the position and replayed; opening the feed afterwards
|
|
2983
|
+
* without a `since` starts after it and misses it.
|
|
2984
|
+
*
|
|
2985
|
+
* @example
|
|
2986
|
+
* ```typescript
|
|
2987
|
+
* const since = await relyio.changesHead()
|
|
2988
|
+
* const post = await relyio.content('post').findById(id).execute()
|
|
2989
|
+
* for await (const change of relyio.changes({ since, ids: [id] })) { … }
|
|
2990
|
+
* ```
|
|
2991
|
+
*/
|
|
2992
|
+
changesHead(options?: ChangesHeadOptions): Promise<string>;
|
|
2750
2993
|
/**
|
|
2751
2994
|
* Build and execute an ad-hoc query dynamically
|
|
2752
2995
|
*
|
|
@@ -2779,6 +3022,21 @@ declare class TypedRelyIOClient<TSchema extends AnySchemaDefinition | undefined
|
|
|
2779
3022
|
* ```
|
|
2780
3023
|
*/
|
|
2781
3024
|
executeQuery<K extends TSchema extends AnySchemaDefinition ? SchemaQueryNames<TSchema> : string>(queryName: K, params?: Record<string, unknown>): Promise<unknown[]>;
|
|
3025
|
+
/**
|
|
3026
|
+
* Describe the project this key resolves to — `GET /v1/project`.
|
|
3027
|
+
*
|
|
3028
|
+
* `dataset` is the one this client's requests select (`dataset`, a sandbox from the `relyio dev`
|
|
3029
|
+
* handshake, or the key's default), which is not always the project's default, so a Studio link
|
|
3030
|
+
* built from `studioUrl` should carry it as `?dataset=`. `studioUrl` is `null` — a value, not an
|
|
3031
|
+
* error — when the service has no Dashboard address configured.
|
|
3032
|
+
*
|
|
3033
|
+
* @example
|
|
3034
|
+
* ```typescript
|
|
3035
|
+
* const { studioUrl, dataset } = await relyio.project()
|
|
3036
|
+
* if (studioUrl !== null) window.open(`${studioUrl}?dataset=${dataset.id}`)
|
|
3037
|
+
* ```
|
|
3038
|
+
*/
|
|
3039
|
+
project(): Promise<Project>;
|
|
2782
3040
|
/**
|
|
2783
3041
|
* Get schema information from the API
|
|
2784
3042
|
*/
|
|
@@ -2824,7 +3082,10 @@ declare class TypedRelyIOClient<TSchema extends AnySchemaDefinition | undefined
|
|
|
2824
3082
|
getHttpClient(): HttpClient;
|
|
2825
3083
|
/**
|
|
2826
3084
|
* Create a locale-scoped client
|
|
2827
|
-
*
|
|
3085
|
+
*
|
|
3086
|
+
* Every read the returned client builds — `content()`, `asset()`, `singleton()`, `settings()`,
|
|
3087
|
+
* `search()`, `similar()`, `autocomplete()`, `executeQuery()` and the ad-hoc queries — is in this
|
|
3088
|
+
* locale unless the call names one of its own, which wins.
|
|
2828
3089
|
*
|
|
2829
3090
|
* Type-safe when schema is provided: autocompletes valid locale codes!
|
|
2830
3091
|
*
|
|
@@ -2832,9 +3093,10 @@ declare class TypedRelyIOClient<TSchema extends AnySchemaDefinition | undefined
|
|
|
2832
3093
|
* ```typescript
|
|
2833
3094
|
* const spanish = relyio.withLocale('es-ES') // ← Autocompletes with schema!
|
|
2834
3095
|
*
|
|
2835
|
-
* //
|
|
3096
|
+
* // Reads use Spanish
|
|
2836
3097
|
* const products = await spanish.content('product').query().execute()
|
|
2837
3098
|
* const homepage = await spanish.singleton('homepage').fetch()
|
|
3099
|
+
* const results = await spanish.search('zapatos').execute()
|
|
2838
3100
|
*
|
|
2839
3101
|
* // Original client unchanged
|
|
2840
3102
|
* const englishProducts = await relyio.content('product').query().execute()
|
|
@@ -2930,4 +3192,4 @@ declare function createClient<TSchema extends AnySchemaDefinition>(config: Typed
|
|
|
2930
3192
|
*/
|
|
2931
3193
|
type ClientSchema<T extends TypedRelyIOClient<AnySchemaDefinition>> = T extends TypedRelyIOClient<infer TSchema> ? TSchema : never;
|
|
2932
3194
|
|
|
2933
|
-
export {
|
|
3195
|
+
export { AdhocQueryBuilder as $, type ActiveSandbox as A, type SearchResponse as B, ChangesExpiredError as C, type AutocompleteSuggestion as D, type ExtendedQueryResult as E, type AutocompleteResponse as F, type SimilarResult as G, HttpClient as H, type SimilarResponse as I, type SearchFilter as J, type SearchFields as K, type SearchSort as L, type SearchTypeName as M, type SearchEntry as N, BatchClient as O, type Project as P, BatchBuilder as Q, type Register as R, type SandboxState as S, TypedRelyIOClient as T, type BatchMethod as U, type BatchOperation as V, type BatchOptions as W, type BatchOperationResult as X, type BatchSummary as Y, type BatchResponse as Z, AdhocQueryClient as _, type Change as a, type FetchBlock as a0, type AggregateBlock as a1, type AggregateMetric as a2, type SearchBlock as a3, type SimilarBlock as a4, type FilterValue as a5, type FullTextConfig as a6, type AdhocQueryDefinition as a7, type AdhocQueryOptions as a8, type QueryMetadata as a9, ResourceConflictError as aA, ResourceExpiredError as aB, isResourceNotFound as aC, type FileErrorCode as aD, FileUploadError as aE, FileValidationError as aF, type FileValidationConstraints as aG, validateFile as aH, type AdhocQueryResult as aa, AssetClient as ab, AssetFileBuilder as ac, AssetUploadBuilder as ad, isAssetEntry as ae, type AssetVisibility as af, type FileStatus as ag, type FileBackend as ah, type AssetFileBlock as ai, type AssetFileExtracted as aj, type AssetUrls as ak, type AssetEntryResponse as al, type PopulatedAssetReference as am, type PresignInput as an, type PresignResult as ao, type ConfirmInput as ap, type ConfirmResult as aq, type ResolveUrlInput as ar, type ResolveUrlResult as as, type CreateAssetOptions as at, type WaitUntilReadyOptions as au, type MultipartCreateResult as av, type MultipartPart as aw, type MultipartTarget as ax, type UploadProgress as ay, ResourceNotFoundError as az, type ChangesExpiredReason as b, createClient as c, type TypedClientConfig as d, type ClientSchema as e, type RegisteredSchema as f, type SendOptions as g, entityTagOf as h, type ConditionalWriteOptions as i, type RetryableWriteOptions as j, type ChangesHeadOptions as k, type ChangesOptions as l, ContentClient as m, SingletonClient as n, SettingsClient as o, ContentQueryBuilder as p, ContentByIdBuilder as q, type ChildrenOptions as r, type SingletonFetchOptions as s, type SettingsFetchOptions as t, SearchClient as u, SearchBuilder as v, AutocompleteBuilder as w, SimilarBuilder as x, type SearchMode as y, type SearchResultItem as z };
|