@relyio/sdk 0.14.0 → 0.16.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 +59 -0
- package/dist/chunk-7BZW6XYJ.cjs +433 -0
- package/dist/chunk-CQHEG7QA.js +411 -0
- package/dist/{chunk-PCFTJLEP.js → chunk-DIZY6CKM.js} +2 -2
- package/dist/{chunk-X4KSS7PP.cjs → chunk-GHYB6IZK.cjs} +2 -2
- package/dist/{chunk-DBBZVZOS.js → chunk-NIUOPIIB.js} +413 -552
- package/dist/{chunk-GUPV2M3X.cjs → chunk-RLLZUFDB.cjs} +450 -585
- package/dist/client/index.cjs +4 -3
- package/dist/client/index.d.cts +3 -4
- package/dist/client/index.d.ts +3 -4
- package/dist/client/index.js +2 -1
- package/dist/{define-content-type-DOrZb_a_.d.ts → define-content-type-CAWSlgn0.d.ts} +579 -81
- package/dist/{define-content-type-BUZeWtpk.d.cts → define-content-type-LkI0rS2W.d.cts} +579 -81
- package/dist/{define-schema-5aHmsA8j.d.ts → define-schema-Dxu3RoHV.d.ts} +1 -1
- package/dist/{define-schema-nCfZeboB.d.cts → define-schema-wlsJOrnY.d.cts} +1 -1
- package/dist/{index-DOhFQbv7.d.ts → index-BH8JksfG.d.ts} +472 -179
- package/dist/{index-B97ZDj44.d.ts → index-CGtYxUuh.d.ts} +1 -1
- package/dist/{index-C-pcllqY.d.cts → index-CcHmRALk.d.cts} +1 -1
- package/dist/{index-DgVV5Nj7.d.cts → index-D80MXUkf.d.cts} +472 -179
- package/dist/index.cjs +96 -71
- package/dist/index.d.cts +26 -16
- package/dist/index.d.ts +26 -16
- package/dist/index.js +4 -3
- package/dist/markdown/index.cjs +10 -2
- package/dist/markdown/index.d.cts +12 -3
- package/dist/markdown/index.d.ts +12 -3
- package/dist/markdown/index.js +10 -2
- package/dist/preview/index.cjs +29 -0
- package/dist/preview/index.d.cts +117 -0
- package/dist/preview/index.d.ts +117 -0
- package/dist/preview/index.js +4 -0
- package/dist/rich-text/index.d.cts +2 -2
- package/dist/rich-text/index.d.ts +2 -2
- package/dist/schema/index.cjs +33 -33
- package/dist/schema/index.d.cts +3 -3
- package/dist/schema/index.d.ts +3 -3
- package/dist/schema/index.js +1 -1
- package/dist/types/index.d.cts +1 -1
- package/dist/types/index.d.ts +1 -1
- package/package.json +10 -4
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { c$ as paths,
|
|
2
|
-
import { a as SchemaDefinition, b as SchemaContentTypeNames, j as SchemaEntryOf, f as SchemaLocaleCodes, c as SchemaSingletonNames, A as AggregateBlock, K as QueryParameterValue, F as FullTextSearch, e as SchemaQueryNames, J as InferQueryParams, L as AnyQueryParameters, h as SchemaAssetTypeNames, g as SchemaSettingsGroupNames } from './define-schema-
|
|
3
|
-
import { VisitorResyncReason } from './live-visitor.js';
|
|
1
|
+
import { c$ as paths, cT as RetryConfig, d0 as MergedRelyIOConfig, cS as ApiResponse, aM as EntryMetadata, ap as Reading, cs as BaseContent, al as CheckedIncludes, d1 as ReadWhere, cx as WhereClause, d2 as components, aq as ReadWith, cF as UpdateInput, at as UntypedReading, cB as RevisedContent, cA as CreateInput, cE as ContentVersionRow, cD as ContentVersion, cC as RestoredContent, cl as SDKError, cY as BaseValidationError, cX as ValidationViolation, b2 as AssetServedBlocks, d3 as CheckedInclude, cw as WhereFieldCondition, cq as AssetFileBlock, ct as BaseSingleton, cu as BaseSettingsGroup, aN as InferContentType, an as ContentReading, aT as InferSingleton, cm as RelyIOConfig, b0 as InferAssetType, ak as AssetReading, as as SingletonReading, aY as InferSettingsGroup, ar as SettingsReading, cn as RelyIOConfigUpdate } from './define-content-type-CAWSlgn0.js';
|
|
2
|
+
import { a as SchemaDefinition, b as SchemaContentTypeNames, j as SchemaEntryOf, f as SchemaLocaleCodes, c as SchemaSingletonNames, A as AggregateBlock, K as QueryParameterValue, F as FullTextSearch, e as SchemaQueryNames, J as InferQueryParams, L as AnyQueryParameters, h as SchemaAssetTypeNames, g as SchemaSettingsGroupNames } from './define-schema-Dxu3RoHV.js';
|
|
4
3
|
import { DevUnreadableReason } from './dev-handshake/index.js';
|
|
5
4
|
|
|
6
5
|
/**
|
|
@@ -201,6 +200,81 @@ type ActiveSandbox = Extract<SandboxState, {
|
|
|
201
200
|
state: 'active';
|
|
202
201
|
}>;
|
|
203
202
|
|
|
203
|
+
/**
|
|
204
|
+
* The part of a request a retry decision is allowed to look at.
|
|
205
|
+
*
|
|
206
|
+
* `method` is typed as a plain `string` rather than as `RequestConfig['method']`
|
|
207
|
+
* on purpose. The five verbs that union names are the five the typed transport
|
|
208
|
+
* can express today; the question "may this be sent twice?" is a fact about
|
|
209
|
+
* HTTP, and an unrecognised verb has to reach the conservative arm rather than
|
|
210
|
+
* be unrepresentable.
|
|
211
|
+
*/
|
|
212
|
+
interface RetryableRequest {
|
|
213
|
+
method: string;
|
|
214
|
+
headers?: Record<string, string>;
|
|
215
|
+
}
|
|
216
|
+
/**
|
|
217
|
+
* Whether a failed request may be sent again, and after how long.
|
|
218
|
+
*
|
|
219
|
+
* The two halves are separate because they fail separately. The incumbent loop
|
|
220
|
+
* had neither: it asked `error.retryable` and nothing else, so a `POST` that met
|
|
221
|
+
* a 500 was sent again twice — and `SERVICE_INDETERMINATE`, whose whole meaning
|
|
222
|
+
* is "the service could not decide", is marked retryable, which means the write
|
|
223
|
+
* may already have landed. Meanwhile the `Retry-After` the service sent was
|
|
224
|
+
* collected by the transport and read by nobody, so a 429 whose window is
|
|
225
|
+
* measured in minutes was retried after an exponential guess capped at ten
|
|
226
|
+
* seconds.
|
|
227
|
+
*
|
|
228
|
+
* `error` is `Error`, not `SDKError`, because that is what the loop actually
|
|
229
|
+
* holds: a `TypeError: fetch failed` is only mapped to an `SDKError` **after**
|
|
230
|
+
* the loop gives up, so a policy typed to `SDKError` could not see the transport
|
|
231
|
+
* failures it most needs to retry.
|
|
232
|
+
*/
|
|
233
|
+
interface RetryPolicy {
|
|
234
|
+
/**
|
|
235
|
+
* Never replays a request that could apply twice: a write is retried only
|
|
236
|
+
* when it carries `Idempotency-Key`, or the verb is idempotent.
|
|
237
|
+
*
|
|
238
|
+
* @param attempt - How many attempts have been made, 1 for the first.
|
|
239
|
+
*/
|
|
240
|
+
shouldRetry(attempt: number, error: Error, request: RetryableRequest): boolean;
|
|
241
|
+
/** Honours `Retry-After` / `RateLimitError.resetAt` over exponential backoff. */
|
|
242
|
+
delayFor(attempt: number, error: Error): number;
|
|
243
|
+
}
|
|
244
|
+
/**
|
|
245
|
+
* Whether sending this request a second time can apply it a second time.
|
|
246
|
+
*
|
|
247
|
+
* Two ways to be safe, and they are genuinely different questions: the verb may
|
|
248
|
+
* be idempotent by definition, or the request may carry an `Idempotency-Key`
|
|
249
|
+
* that makes the service answer a replay from the original outcome rather than
|
|
250
|
+
* applying it again.
|
|
251
|
+
*/
|
|
252
|
+
declare function isReplaySafe(request: RetryableRequest): boolean;
|
|
253
|
+
/**
|
|
254
|
+
* The policy the SDK ships with.
|
|
255
|
+
*
|
|
256
|
+
* Construction takes the same `RetryConfig` the SDK has always exported; what
|
|
257
|
+
* it no longer takes is a `retryCondition`, because a caller-supplied predicate
|
|
258
|
+
* over `(error, attempt)` structurally **cannot** see the request and so cannot
|
|
259
|
+
* express the rule this class exists for.
|
|
260
|
+
*/
|
|
261
|
+
declare class DefaultRetryPolicy implements RetryPolicy {
|
|
262
|
+
private readonly config;
|
|
263
|
+
constructor(config: RetryConfig);
|
|
264
|
+
shouldRetry(attempt: number, error: Error, request: RetryableRequest): boolean;
|
|
265
|
+
delayFor(attempt: number, error: Error): number;
|
|
266
|
+
}
|
|
267
|
+
/**
|
|
268
|
+
* The retry policy a client sends with, at `maxAttempts` attempts (the first included): the SDK's
|
|
269
|
+
* own, from `retryAttempts`, and the CLI's (REL-721).
|
|
270
|
+
*
|
|
271
|
+
* The backoff numbers are stated here once. The CLI ran a second policy beside this one —
|
|
272
|
+
* `axios-retry` with its own delays and its own reading of a refusal, which retried by numeric
|
|
273
|
+
* status — so a refusal one client gave up on, the other sent again. Now both ask this function, and
|
|
274
|
+
* a change to when a request is replayed reaches both.
|
|
275
|
+
*/
|
|
276
|
+
declare function retryPolicyFor(maxAttempts: number): RetryPolicy;
|
|
277
|
+
|
|
204
278
|
/**
|
|
205
279
|
* What a call site supplies beside the route it named.
|
|
206
280
|
*
|
|
@@ -234,39 +308,35 @@ type SendOptions<P extends ApiPath, M extends ApiMethod<P>> = {
|
|
|
234
308
|
* then the one unwrap — there is no second spelling and no runtime test of
|
|
235
309
|
* which envelope arrived (`INV-API-CLIENT-IS-DERIVED`).
|
|
236
310
|
*
|
|
237
|
-
*
|
|
238
|
-
*
|
|
311
|
+
* What the class makes public is what something outside it calls: `send` and `fetchPayload` are
|
|
312
|
+
* the requests; `configure`, `withHeaders` and `setApiKey` are the owning client's (`updateConfig()`,
|
|
313
|
+
* `with()`, `setApiKey()`). There are no verb helpers, no header or base-URL accessors and no
|
|
314
|
+
* untyped `request` (REL-717): a route is named by its document path, or it is not called.
|
|
239
315
|
*/
|
|
240
316
|
declare class HttpClient {
|
|
241
317
|
/** What every request reads off the configuration, derived by {@link configure} and nowhere else. */
|
|
242
|
-
|
|
318
|
+
protected connection: Connection;
|
|
243
319
|
/**
|
|
244
320
|
* Set on a view {@link withHeaders} made: the client every request is sent through, and the
|
|
245
321
|
* headers laid beneath each request's own. A view keeps no connection of its own that matters —
|
|
246
322
|
* everything it is asked to change, it changes on that client.
|
|
247
323
|
*/
|
|
248
|
-
|
|
324
|
+
protected view?: {
|
|
325
|
+
readonly client: ControlledHttpClient;
|
|
326
|
+
readonly headers: Readonly<Record<string, string>>;
|
|
327
|
+
};
|
|
249
328
|
constructor(config: MergedRelyIOConfig);
|
|
329
|
+
protected announce(): void;
|
|
250
330
|
/**
|
|
251
|
-
*
|
|
252
|
-
*
|
|
253
|
-
*
|
|
254
|
-
*
|
|
255
|
-
* this client. `client.with({ dataset })` is one (REL-2417).
|
|
256
|
-
*/
|
|
257
|
-
withHeaders(headers: Readonly<Record<string, string>>): HttpClient;
|
|
258
|
-
/**
|
|
259
|
-
* Run on `config` from now on: every later request — whoever holds this client — is sent to its
|
|
260
|
-
* `baseUrl`, with its headers, key and dataset, its timeout and retries, through its `fetch`, and
|
|
261
|
-
* logged by its `debug` options.
|
|
331
|
+
* Send bytes to an address that is not a RelyIO route — an asset upload's presigned `PUT` and its
|
|
332
|
+
* multipart parts — through the client's configured `fetch`, so a wrapper that records, proxies or
|
|
333
|
+
* forbids network access sees every request this client makes (REL-2671). Nothing else is added: no
|
|
334
|
+
* key, no retry, no timeout, because the address belongs to the storage service, not to RelyIO.
|
|
262
335
|
*
|
|
263
|
-
*
|
|
264
|
-
*
|
|
265
|
-
* set on this client since it was last configured — `setDefaultHeaders()`, `setBaseUrl()` — is
|
|
266
|
-
* replaced by what `config` says.
|
|
336
|
+
* Static so the instances a customer holds stay `send` and `fetchPayload` (REL-3107). The `fetch`
|
|
337
|
+
* is read per call, from the client a view sends through, like the requests are.
|
|
267
338
|
*/
|
|
268
|
-
|
|
269
|
-
private announce;
|
|
339
|
+
static transfer(client: HttpClient, url: string, init: RequestInit): Promise<Response>;
|
|
270
340
|
/**
|
|
271
341
|
* Call a route the committed document declares, and get back the body that
|
|
272
342
|
* document says it serves.
|
|
@@ -301,62 +371,7 @@ declare class HttpClient {
|
|
|
301
371
|
* build that holds no key (REL-1120) — and so does one whose `setApiKey` was
|
|
302
372
|
* given none.
|
|
303
373
|
*/
|
|
304
|
-
request
|
|
305
|
-
/**
|
|
306
|
-
* Make a GET request
|
|
307
|
-
*/
|
|
308
|
-
get<T = unknown>(url: string, params?: Record<string, unknown>): Promise<ApiResponse<T>>;
|
|
309
|
-
/**
|
|
310
|
-
* Make a POST request
|
|
311
|
-
*/
|
|
312
|
-
post<T = unknown>(url: string, data?: unknown, params?: Record<string, unknown>): Promise<ApiResponse<T>>;
|
|
313
|
-
/**
|
|
314
|
-
* Make a PUT request
|
|
315
|
-
*/
|
|
316
|
-
put<T = unknown>(url: string, data?: unknown, params?: Record<string, unknown>): Promise<ApiResponse<T>>;
|
|
317
|
-
/**
|
|
318
|
-
* Make a DELETE request
|
|
319
|
-
*/
|
|
320
|
-
delete<T = unknown>(url: string, params?: Record<string, unknown>): Promise<ApiResponse<T>>;
|
|
321
|
-
/**
|
|
322
|
-
* Make a PATCH request
|
|
323
|
-
*/
|
|
324
|
-
patch<T = unknown>(url: string, data?: unknown, params?: Record<string, unknown>): Promise<ApiResponse<T>>;
|
|
325
|
-
/**
|
|
326
|
-
* Add headers to every later request, each replacing any header of the same name — the name
|
|
327
|
-
* matched without regard to case — until the client is next configured.
|
|
328
|
-
*/
|
|
329
|
-
setDefaultHeaders(headers: Record<string, string>): void;
|
|
330
|
-
/**
|
|
331
|
-
* Replace the key every later request sends as `X-API-Key`, and the `apiKey` the configuration
|
|
332
|
-
* reports.
|
|
333
|
-
*
|
|
334
|
-
* The key is read the way construction reads it (`presentKey`): an absent, empty or blank key is
|
|
335
|
-
* no key, so the header is dropped and the next request is refused with `MissingApiKeyError`
|
|
336
|
-
* before anything is sent. A key header of any other spelling — one given in `headers` — goes
|
|
337
|
-
* too, from the headers sent and from the headers the configuration reports, so the old key is
|
|
338
|
-
* never sent beside the new one.
|
|
339
|
-
*
|
|
340
|
-
* The configuration is the one the owning `TypedRelyIOClient` holds (it hands its own to the
|
|
341
|
-
* constructor), so its `getConfig().apiKey` — what a surface reads to decide a key's kind — is the
|
|
342
|
-
* key sent from here on.
|
|
343
|
-
*
|
|
344
|
-
* This replaced `setAuthToken`, which added `Authorization: Bearer` beside an `X-API-Key` it
|
|
345
|
-
* never touched: the API reads `X-API-Key` first, so the old key was the one used (REL-1385).
|
|
346
|
-
*/
|
|
347
|
-
setApiKey(apiKey: string): void;
|
|
348
|
-
/**
|
|
349
|
-
* Get current default headers
|
|
350
|
-
*/
|
|
351
|
-
getDefaultHeaders(): Record<string, string>;
|
|
352
|
-
/**
|
|
353
|
-
* Update base URL
|
|
354
|
-
*/
|
|
355
|
-
setBaseUrl(baseUrl: string): void;
|
|
356
|
-
/**
|
|
357
|
-
* Get current base URL
|
|
358
|
-
*/
|
|
359
|
-
getBaseUrl(): string;
|
|
374
|
+
private request;
|
|
360
375
|
/**
|
|
361
376
|
* One attempt.
|
|
362
377
|
*
|
|
@@ -388,6 +403,63 @@ declare class HttpClient {
|
|
|
388
403
|
private headersToObject;
|
|
389
404
|
private log;
|
|
390
405
|
}
|
|
406
|
+
/**
|
|
407
|
+
* The client the SDK's own factory holds: {@link HttpClient} plus the three things only the owning
|
|
408
|
+
* client does to it — `configure` (`updateConfig()`), `withHeaders` (`with()`) and `setApiKey`
|
|
409
|
+
* (`setApiKey()`). It is not exported from the package, so a customer holding the client from
|
|
410
|
+
* `getHttpClient()` sees `send` and `fetchPayload` and nothing else (REL-3107).
|
|
411
|
+
*/
|
|
412
|
+
declare class ControlledHttpClient extends HttpClient {
|
|
413
|
+
/**
|
|
414
|
+
* A view of this client that sends every request through it with `headers` added — beneath the
|
|
415
|
+
* request's own, over this client's — and changes nothing else: its key, base URL, timeout,
|
|
416
|
+
* retries and `fetch` are this client's as they are when each request is sent, so a later
|
|
417
|
+
* `configure()` or `setApiKey()` on this client reaches the view, and one on the view reaches
|
|
418
|
+
* this client. `client.with({ dataset })` is one (REL-2417).
|
|
419
|
+
*/
|
|
420
|
+
withHeaders(headers: Readonly<Record<string, string>>): ControlledHttpClient;
|
|
421
|
+
/**
|
|
422
|
+
* Run on `config` from now on: every later request — whoever holds this client — is sent to its
|
|
423
|
+
* `baseUrl`, with its headers, key and dataset, its timeout and retries, through its `fetch`, and
|
|
424
|
+
* logged by its `debug` options.
|
|
425
|
+
*
|
|
426
|
+
* The client's own `updateConfig()` calls this rather than building a second client, so a
|
|
427
|
+
* `content()` or other sub-client taken before the update sends through the update too. Anything
|
|
428
|
+
* set on this client since it was last configured — `setApiKey()` — is replaced by what `config`
|
|
429
|
+
* says.
|
|
430
|
+
*/
|
|
431
|
+
configure(config: MergedRelyIOConfig): void;
|
|
432
|
+
/**
|
|
433
|
+
* Replace the key every later request sends as `X-API-Key`, and the `apiKey` the configuration
|
|
434
|
+
* reports.
|
|
435
|
+
*
|
|
436
|
+
* The key is read the way construction reads it (`presentKey`): an absent, empty or blank key is
|
|
437
|
+
* no key, so the header is dropped and the next request is refused with `MissingApiKeyError`
|
|
438
|
+
* before anything is sent. A key header of any other spelling — one given in `headers` — goes
|
|
439
|
+
* too, from the headers sent and from the headers the configuration reports, so the old key is
|
|
440
|
+
* never sent beside the new one.
|
|
441
|
+
*
|
|
442
|
+
* The configuration is the one the owning `TypedRelyIOClient` holds (it hands its own to the
|
|
443
|
+
* constructor), so its `getConfig().apiKey` — what a surface reads to decide a key's kind — is the
|
|
444
|
+
* key sent from here on.
|
|
445
|
+
*
|
|
446
|
+
* This replaced `setAuthToken`, which added `Authorization: Bearer` beside an `X-API-Key` it
|
|
447
|
+
* never touched: the API reads `X-API-Key` first, so the old key was the one used (REL-1385).
|
|
448
|
+
*/
|
|
449
|
+
setApiKey(apiKey: string): void;
|
|
450
|
+
}
|
|
451
|
+
/** Everything a request reads off the configuration, replaced whole whenever it changes. */
|
|
452
|
+
interface Connection {
|
|
453
|
+
/**
|
|
454
|
+
* The configuration itself, for what is read per request — `fetch`, the `browser` options,
|
|
455
|
+
* `debug` — and the object `setApiKey` writes the key into, which the owning client reports.
|
|
456
|
+
*/
|
|
457
|
+
readonly config: MergedRelyIOConfig;
|
|
458
|
+
readonly baseUrl: string;
|
|
459
|
+
readonly defaultHeaders: Readonly<Record<string, string>>;
|
|
460
|
+
readonly timeout: number;
|
|
461
|
+
readonly retryPolicy: RetryPolicy;
|
|
462
|
+
}
|
|
391
463
|
|
|
392
464
|
/**
|
|
393
465
|
* API4's two request headers, as the SDK's writes send them.
|
|
@@ -453,6 +525,106 @@ declare function versionCheckOf(entry: ReadEntry): {
|
|
|
453
525
|
*/
|
|
454
526
|
type ClientLocale = string | (() => string | undefined);
|
|
455
527
|
|
|
528
|
+
/**
|
|
529
|
+
* Site-visitor live, declared once for everyone who speaks it (`live-layer-spec.md` decisions 15, 19
|
|
530
|
+
* and 20; phase LV5): the wire a visitor's browser meets at `live.relyio.com`, and the two internal
|
|
531
|
+
* routes the live Worker calls on `apps/services/api` to serve it.
|
|
532
|
+
*
|
|
533
|
+
* It sits in this package's root because three runtimes read it and this is the one package all
|
|
534
|
+
* three may import: `@relyio/sdk` through the customer-layer chokepoint (`INV-SS-CUSTOMER-FENCE`,
|
|
535
|
+
* which allows this root), the live Worker, and `apps/services/api`. Pure, like the rest of the root:
|
|
536
|
+
* no `node:` import, so it runs in workerd and a browser.
|
|
537
|
+
*
|
|
538
|
+
* ## The visitor front door — `wss://live.relyio.com/visitor/changes` and `GET` on the same path
|
|
539
|
+
*
|
|
540
|
+
* A visitor presents a **publishable** key (`rly_pub_…`, `sdk-surfaces-spec.md` decision 29) in the
|
|
541
|
+
* `key` query parameter — a browser cannot set a socket's headers, and a query parameter keeps the
|
|
542
|
+
* poll a simple request with no preflight. The door resolves the key's scope, checks the page's
|
|
543
|
+
* `Origin` against the key's allowed origins, and refuses a key it cannot use, an unlisted origin or
|
|
544
|
+
* a malformed request **before any object is addressed**. A secret or preview key is refused here:
|
|
545
|
+
* a preview key's live connection stays on the Content API's `/v1/changes`.
|
|
546
|
+
*
|
|
547
|
+
* Only the published lens exists at this door (`INV-SS-FEED-LENS-IS-THE-KEY`); no parameter names a
|
|
548
|
+
* lens. The dataset is `dataset` — an id or a name, as `X-RelyIO-Dataset` takes it — or the key's
|
|
549
|
+
* default. `types` and `ids` narrow what reaches this client, comma-separated, and the socket keeps
|
|
550
|
+
* them as its own filter (`INV-LV-VISITOR-AT-THE-EDGE`).
|
|
551
|
+
*
|
|
552
|
+
* ### The socket
|
|
553
|
+
*
|
|
554
|
+
* Every frame is text. From the client, only the keepalive {@link VISITOR_KEEPALIVE}, which the
|
|
555
|
+
* runtime answers without waking the feed; anything else is ignored. From the feed,
|
|
556
|
+
* {@link VisitorFrame}s:
|
|
557
|
+
*
|
|
558
|
+
* 1. Zero or more `feed.changes` / at most one `feed.resync`: the changes after the connect's
|
|
559
|
+
* `since` (`INV-SS-CURSOR-REPLAYS`), or the named reason none can be listed.
|
|
560
|
+
* 2. `feed.opened` exactly once, with the cursor the socket is caught up to: every change after it
|
|
561
|
+
* reaches this socket. A connect **without** `since` gets this first, and the client fetches what
|
|
562
|
+
* it shows after receiving it — fetching after the feed holds the cursor is what makes the view
|
|
563
|
+
* gap-free.
|
|
564
|
+
* 3. `feed.changes` as the dataset changes, each carrying ids only (`INV-SS-CHANGE-IS-IDS`) and the
|
|
565
|
+
* cursor after it. The client keeps the last cursor it received and reconnects with it as
|
|
566
|
+
* `since` — after a deploy or a dropped network alike — and is replayed what it missed.
|
|
567
|
+
*
|
|
568
|
+
* A change is at-least-once: a replay and the live frames that follow it may name one change twice.
|
|
569
|
+
* A client refetches what a change names, so a repeat costs a read and never a wrong view.
|
|
570
|
+
*
|
|
571
|
+
* A refusal is a socket closed at once with one of {@link VISITOR_CLOSE_CODES} and a reason string,
|
|
572
|
+
* because a browser cannot read the status of a refused WebSocket handshake; what a client does next
|
|
573
|
+
* is {@link VISITOR_CLOSE_RETRY}'s, per code.
|
|
574
|
+
*
|
|
575
|
+
* ### Admission (`INV-LV-LIVE-CEILINGS`)
|
|
576
|
+
*
|
|
577
|
+
* After the key, origin and dataset, the door asks the project's counter whether one more connection
|
|
578
|
+
* may open — against the project's plan allowance (Starter's 100), its safety ceiling (Pro's 50,000)
|
|
579
|
+
* and a per-address limit the Worker holds — and refuses before any feed is addressed. The counts are approximate
|
|
580
|
+
* by design: a feed reports its count within about a second of a change and at least every minute, so
|
|
581
|
+
* a refusal is decided on counts at most one reporting interval old.
|
|
582
|
+
*
|
|
583
|
+
* ### The poll
|
|
584
|
+
*
|
|
585
|
+
* `GET` on the same path with the same parameters and a `client` id (a random id the client keeps for
|
|
586
|
+
* the page's life, so one visitor polling counts once), answered **at once** — never held — with
|
|
587
|
+
* `{ data: VisitorPollAnswer }`. Where a WebSocket cannot open, a client polls about every
|
|
588
|
+
* {@link VISITOR_POLL_INTERVAL_MS}. A refusal is the one error envelope, `{ error: { code, messages } }`,
|
|
589
|
+
* at the code's status.
|
|
590
|
+
*
|
|
591
|
+
* ## The two internal routes (`apps/services/api`, `x-internal-secret`)
|
|
592
|
+
*
|
|
593
|
+
* - `POST /internal/live/visitor-key` — {@link VisitorKeyResolve} → {@link VisitorKeyResolution}:
|
|
594
|
+
* what a presented key may reach, in the binding shape `./edge.ts` already declares for the Content
|
|
595
|
+
* API's edge, plus the project's live regions the feed is placed by. The Worker keeps the answer
|
|
596
|
+
* under the key's SHA-256, with the tag origin minted for it, as `apps/edge/api` keeps a binding, so
|
|
597
|
+
* a revocation's purge evicts both.
|
|
598
|
+
* - `POST /internal/live/visitor-feed/{projectId}/{datasetId}/changes` — {@link VisitorLedgerRead} →
|
|
599
|
+
* {@link VisitorLedgerPage}: the ledger page after a cursor in the `public` lens, the same read and
|
|
600
|
+
* the same page shape the Studio service answers a dataset room with in the `preview` lens
|
|
601
|
+
* (`@relyio/live-contracts`' `rest/live-room.ts`), plus one resync reason a room never meets —
|
|
602
|
+
* a cursor a visitor's client supplied that this dataset's feed never issued.
|
|
603
|
+
*/
|
|
604
|
+
|
|
605
|
+
/**
|
|
606
|
+
* Why a ledger read cannot list the changes from a cursor to now:
|
|
607
|
+
*
|
|
608
|
+
* - `retention` — rows after the cursor may have been reaped (`@relyio/entry-changes`' retention).
|
|
609
|
+
* - `dataset-replaced` — the dataset was purged or populated wholesale.
|
|
610
|
+
* - `ahead-of-head` — the cursor is past the ledger's head: the ledger was reset under it.
|
|
611
|
+
* - `foreign-cursor` — the cursor is not one this dataset's feed issued (malformed, or another
|
|
612
|
+
* dataset's). A room never meets it; a visitor's client supplies its own cursor.
|
|
613
|
+
*/
|
|
614
|
+
type VisitorLedgerResyncReason = 'retention' | 'dataset-replaced' | 'ahead-of-head' | 'foreign-cursor';
|
|
615
|
+
/**
|
|
616
|
+
* Why a client is told to refetch everything: any reason the ledger gave, or `too-far-behind` — the
|
|
617
|
+
* client's cursor is further back than one replay lists (`VisitorFeed`'s `MAX_REPLAY_PAGES`), and a
|
|
618
|
+
* refetch is less than the replay would be.
|
|
619
|
+
*/
|
|
620
|
+
type VisitorResyncReason = VisitorLedgerResyncReason | 'too-far-behind';
|
|
621
|
+
/**
|
|
622
|
+
* What a client does after a refusal: `stop` (the same request meets the same answer), `retry`
|
|
623
|
+
* (backoff and jitter from about a second) or `back-off` (full now: wait at least
|
|
624
|
+
* {@link VISITOR_ADMISSION_RETRY_AFTER_SECONDS}, with jitter, doubling while it repeats).
|
|
625
|
+
*/
|
|
626
|
+
type VisitorRetry = 'stop' | 'retry' | 'back-off';
|
|
627
|
+
|
|
456
628
|
/**
|
|
457
629
|
* Two read terms every read that takes them writes the same way: the children an entry embeds,
|
|
458
630
|
* and the refusal of a condition on `_metadata`. Here once, for the list and entry reads
|
|
@@ -551,7 +723,7 @@ type FreshOption = true | NonNullable<Term<'/v1/{contentType}', 'get', '_fresh'>
|
|
|
551
723
|
* - `children` — each entry's children, of every content type, under `_children`: `true` for one
|
|
552
724
|
* level, or a depth of 1 to 3 and at most `limit` per parent (REL-1118).
|
|
553
725
|
*/
|
|
554
|
-
interface EntryReadOptions<R extends Reading, P extends readonly string[], L extends LocaleOption<ReadLocale<R>> | undefined = undefined> {
|
|
726
|
+
interface EntryReadOptions<R extends Reading, P extends readonly string[], L extends LocaleOption<ReadLocale<R>> | undefined = undefined, C extends ChildrenRead | undefined = ChildrenRead | undefined> {
|
|
555
727
|
/** Include paths: the references to expand into the entries they point at (REL-1801). */
|
|
556
728
|
readonly include?: CheckedIncludes<R, P>;
|
|
557
729
|
/** The locale, locales or `'*'` to read, over the client's locale (Q16). */
|
|
@@ -561,10 +733,16 @@ interface EntryReadOptions<R extends Reading, P extends readonly string[], L ext
|
|
|
561
733
|
/** How fresh the answer must be: a feed position, or `true` for past every cache. */
|
|
562
734
|
readonly fresh?: FreshOption;
|
|
563
735
|
/** Embed each entry's children: `true`, or a depth and a per-parent limit (REL-1118). */
|
|
564
|
-
readonly children?:
|
|
736
|
+
readonly children?: C;
|
|
737
|
+
/**
|
|
738
|
+
* Cancels the request when it aborts. The call then rejects with the platform's `AbortError` —
|
|
739
|
+
* not a `TimeoutError` — and a request already cancelled sends nothing. The client's timeout
|
|
740
|
+
* still applies.
|
|
741
|
+
*/
|
|
742
|
+
readonly signal?: AbortSignal;
|
|
565
743
|
}
|
|
566
744
|
/** The options a list read takes beside how it pages: what it keeps, how, and how many a page holds. */
|
|
567
|
-
interface ListReadOptions<T extends BaseContent, R extends Reading, P extends readonly string[], S extends readonly FieldKey<T>[] | undefined = undefined, L extends LocaleOption<ReadLocale<R>> | undefined = undefined> extends EntryReadOptions<R, P, L> {
|
|
745
|
+
interface ListReadOptions<T extends BaseContent, R extends Reading, P extends readonly string[], S extends readonly FieldKey<T>[] | undefined = undefined, L extends LocaleOption<ReadLocale<R>> | undefined = undefined, C extends ChildrenRead | undefined = ChildrenRead | undefined> extends EntryReadOptions<R, P, L, C> {
|
|
568
746
|
/**
|
|
569
747
|
* The conditions an entry must meet, by the paths the API filters on (REL-2136). A condition on
|
|
570
748
|
* `_metadata` is refused before anything is sent.
|
|
@@ -593,11 +771,20 @@ type Paging = {
|
|
|
593
771
|
readonly cursor?: never;
|
|
594
772
|
};
|
|
595
773
|
/** What `list(options)` takes. */
|
|
596
|
-
type ListOptions<T extends BaseContent, R extends Reading, P extends readonly string[], S extends readonly FieldKey<T>[] | undefined = undefined, L extends LocaleOption<ReadLocale<R>> | undefined = undefined> = ListReadOptions<T, R, P, S, L> & Paging;
|
|
774
|
+
type ListOptions<T extends BaseContent, R extends Reading, P extends readonly string[], S extends readonly FieldKey<T>[] | undefined = undefined, L extends LocaleOption<ReadLocale<R>> | undefined = undefined, C extends ChildrenRead | undefined = ChildrenRead | undefined> = ListReadOptions<T, R, P, S, L, C> & Paging;
|
|
775
|
+
/**
|
|
776
|
+
* What `children(id, options)` takes (REL-1864): an entry read's options and the page of the list
|
|
777
|
+
* — `limit` the page size, and the `cursor` a page handed back or a page number to choose which.
|
|
778
|
+
* No `where`, `select` or `sort`: the route declares none, and the order is the hierarchy's.
|
|
779
|
+
*/
|
|
780
|
+
type ChildrenListOptions<R extends Reading, P extends readonly string[], L extends LocaleOption<ReadLocale<R>> | undefined = undefined, C extends ChildrenRead | undefined = ChildrenRead | undefined> = EntryReadOptions<R, P, L, C> & {
|
|
781
|
+
/** How many children a page holds, whether it is read by cursor or by number. */
|
|
782
|
+
readonly limit?: Term<'/v1/{contentType}/{id}/children', 'get', 'limit'>;
|
|
783
|
+
} & Paging;
|
|
597
784
|
/** What `listAll(options)` takes: a list's options, paged by the walk itself. */
|
|
598
|
-
type ListAllOptions<T extends BaseContent, R extends Reading, P extends readonly string[], S extends readonly FieldKey<T>[] | undefined = undefined, L extends LocaleOption<ReadLocale<R>> | undefined = undefined> = ListReadOptions<T, R, P, S, L>;
|
|
785
|
+
type ListAllOptions<T extends BaseContent, R extends Reading, P extends readonly string[], S extends readonly FieldKey<T>[] | undefined = undefined, L extends LocaleOption<ReadLocale<R>> | undefined = undefined, C extends ChildrenRead | undefined = ChildrenRead | undefined> = ListReadOptions<T, R, P, S, L, C>;
|
|
599
786
|
/** What `get(idOrSlug, options)` takes. */
|
|
600
|
-
type GetOptions<R extends Reading, P extends readonly string[], L extends LocaleOption<ReadLocale<R>> | undefined = undefined> = EntryReadOptions<R, P, L>;
|
|
787
|
+
type GetOptions<R extends Reading, P extends readonly string[], L extends LocaleOption<ReadLocale<R>> | undefined = undefined, C extends ChildrenRead | undefined = ChildrenRead | undefined> = EntryReadOptions<R, P, L, C>;
|
|
601
788
|
/**
|
|
602
789
|
* What a one-document read takes — `singleton(key).get(options)` and `settings(group).get(options)`
|
|
603
790
|
* (REL-2419, REL-2409 decision Q18): a content read's options where their routes declare them.
|
|
@@ -618,6 +805,12 @@ interface DocumentReadOptions<R extends Reading, P extends readonly string[]> {
|
|
|
618
805
|
readonly dataset?: string;
|
|
619
806
|
/** How fresh the answer must be: a feed position, or `true` for past every cache. */
|
|
620
807
|
readonly fresh?: FreshOption;
|
|
808
|
+
/**
|
|
809
|
+
* Cancels the request when it aborts. The call then rejects with the platform's `AbortError` —
|
|
810
|
+
* not a `TimeoutError` — and a request already cancelled sends nothing. The client's timeout
|
|
811
|
+
* still applies.
|
|
812
|
+
*/
|
|
813
|
+
readonly signal?: AbortSignal;
|
|
621
814
|
}
|
|
622
815
|
/**
|
|
623
816
|
* What `version()` takes on every handle (REL-2427): the version to read, and the locale whose
|
|
@@ -655,8 +848,27 @@ type Localized<E, L, C extends string> = L extends '*' | readonly string[] ? E e
|
|
|
655
848
|
localizations: Localizations<E, L extends readonly string[] ? L[number] : C>;
|
|
656
849
|
};
|
|
657
850
|
} : E : E;
|
|
658
|
-
/** What a read
|
|
659
|
-
type
|
|
851
|
+
/** What a read's `children` takes: `true`, or a depth and a per-parent limit. */
|
|
852
|
+
type ChildrenRead = true | ChildrenOptions;
|
|
853
|
+
/**
|
|
854
|
+
* One child as the API serves it: an entry of any content type, the document's `Entry`. The
|
|
855
|
+
* children of an entry are of every content type (there is no filter by type), so no one schema
|
|
856
|
+
* types them.
|
|
857
|
+
*/
|
|
858
|
+
type ChildEntry = components['schemas']['Entry'];
|
|
859
|
+
/**
|
|
860
|
+
* What `children` adds to a read (REL-2456): `_children`, the document's own shape
|
|
861
|
+
* (`components['schemas']['Entry']['_children']`, which the API serves beside the fields), on a read
|
|
862
|
+
* that asked for them — and nothing on one that did not, since the API serves none then.
|
|
863
|
+
*/
|
|
864
|
+
type WithChildren<E, C> = [C] extends [undefined] ? E : [C] extends [ChildrenRead] ? E & {
|
|
865
|
+
readonly _children: NonNullable<ChildEntry['_children']>;
|
|
866
|
+
} : E;
|
|
867
|
+
/**
|
|
868
|
+
* What a read of `R` returns under its include paths `P`, selection `S`, locale `L` and children
|
|
869
|
+
* `C` (what its `children` option was).
|
|
870
|
+
*/
|
|
871
|
+
type ReadAs<R extends Reading, P extends readonly string[], S = undefined, L = undefined, C = undefined> = WithChildren<Localized<SelectedFields<ReadWith<R, P[number]>, S, P[number]>, L, ReadLocale<R>>, C>;
|
|
660
872
|
/**
|
|
661
873
|
* Where a read reads and how fresh it must be, as an implementation reads them whatever the type
|
|
662
874
|
* parameters checked: the clump every read takes — an entry read, a list, a one-document read, a
|
|
@@ -668,6 +880,12 @@ interface WrittenReadScope {
|
|
|
668
880
|
readonly locale?: string | readonly string[];
|
|
669
881
|
readonly dataset?: string;
|
|
670
882
|
readonly fresh?: FreshOption;
|
|
883
|
+
/**
|
|
884
|
+
* Cancels the request when it aborts. The call then rejects with the platform's `AbortError` —
|
|
885
|
+
* not a `TimeoutError` — and a request already cancelled sends nothing. The client's timeout
|
|
886
|
+
* still applies.
|
|
887
|
+
*/
|
|
888
|
+
readonly signal?: AbortSignal;
|
|
671
889
|
}
|
|
672
890
|
/**
|
|
673
891
|
* A `sort` as an implementation reads it, whatever keys the type checked ({@link SortOption}): a
|
|
@@ -724,7 +942,7 @@ declare abstract class EntryHandle<T extends BaseContent, R extends Reading, Rev
|
|
|
724
942
|
* })
|
|
725
943
|
* ```
|
|
726
944
|
*/
|
|
727
|
-
list<const P extends readonly string[] = [], const S extends readonly FieldKey<T>[] | undefined = undefined, const L extends LocaleOption<ReadLocale<R>> | undefined = undefined>(options?: ListOptions<T, R, P, S, L>): Promise<EntryList<ReadAs<R, P, S, L>>>;
|
|
945
|
+
list<const P extends readonly string[] = [], const S extends readonly FieldKey<T>[] | undefined = undefined, const L extends LocaleOption<ReadLocale<R>> | undefined = undefined, const C extends ChildrenRead | undefined = undefined>(options?: ListOptions<T, R, P, S, L, C>): Promise<EntryList<ReadAs<R, P, S, L, C>>>;
|
|
728
946
|
/**
|
|
729
947
|
* Every entry of this type that `where` keeps, page after page, as an async iterable: the walk
|
|
730
948
|
* follows each page's cursor and stops where the API says there is no more (REL-2415).
|
|
@@ -734,7 +952,7 @@ declare abstract class EntryHandle<T extends BaseContent, R extends Reading, Rev
|
|
|
734
952
|
* Iterating throws when a page says there is more and hands back no cursor to read it by, rather
|
|
735
953
|
* than ending the walk short.
|
|
736
954
|
*/
|
|
737
|
-
listAll<const P extends readonly string[] = [], const S extends readonly FieldKey<T>[] | undefined = undefined, const L extends LocaleOption<ReadLocale<R>> | undefined = undefined>(options?: ListAllOptions<T, R, P, S, L>): AsyncIterable<ReadAs<R, P, S, L>>;
|
|
955
|
+
listAll<const P extends readonly string[] = [], const S extends readonly FieldKey<T>[] | undefined = undefined, const L extends LocaleOption<ReadLocale<R>> | undefined = undefined, const C extends ChildrenRead | undefined = undefined>(options?: ListAllOptions<T, R, P, S, L, C>): AsyncIterable<ReadAs<R, P, S, L, C>>;
|
|
738
956
|
private walk;
|
|
739
957
|
/**
|
|
740
958
|
* One entry by its id or slug, or `null` when there is no such entry (REL-2415).
|
|
@@ -753,7 +971,7 @@ declare abstract class EntryHandle<T extends BaseContent, R extends Reading, Rev
|
|
|
753
971
|
* if (post === null) return notFound()
|
|
754
972
|
* ```
|
|
755
973
|
*/
|
|
756
|
-
get<const P extends readonly string[] = [], const L extends LocaleOption<ReadLocale<R>> | undefined = undefined>(idOrSlug: string, options?: GetOptions<R, P, L>): Promise<ReadAs<R, P, undefined, L> | null>;
|
|
974
|
+
get<const P extends readonly string[] = [], const L extends LocaleOption<ReadLocale<R>> | undefined = undefined, const C extends ChildrenRead | undefined = undefined>(idOrSlug: string, options?: GetOptions<R, P, L, C>): Promise<ReadAs<R, P, undefined, L, C> | null>;
|
|
757
975
|
/**
|
|
758
976
|
* Update an entry you read, checked against the version it was read at (REL-2418).
|
|
759
977
|
*
|
|
@@ -848,15 +1066,12 @@ declare class ContentClient<T extends BaseContent = BaseContent, R extends Readi
|
|
|
848
1066
|
* Versions are numbered per locale, so this is one locale's timeline: `locale` defaults to the
|
|
849
1067
|
* client's own, else the schema default; no fallback is applied, and a locale
|
|
850
1068
|
* with no history returns an empty array rather than another locale's rows. Every row names the
|
|
851
|
-
* locale it belongs to
|
|
1069
|
+
* locale it belongs to, and holds that locale's fields under `fields`.
|
|
852
1070
|
*/
|
|
853
1071
|
versions(id: string, options?: {
|
|
854
1072
|
limit?: number;
|
|
855
1073
|
locale?: string;
|
|
856
|
-
}): Promise<Array<T
|
|
857
|
-
versionNumber: number;
|
|
858
|
-
locale: string;
|
|
859
|
-
}>>;
|
|
1074
|
+
}): Promise<Array<ContentVersionRow<T>>>;
|
|
860
1075
|
/**
|
|
861
1076
|
* One version of an entry: `version(id, { version, locale })`.
|
|
862
1077
|
*
|
|
@@ -866,8 +1081,11 @@ declare class ContentClient<T extends BaseContent = BaseContent, R extends Readi
|
|
|
866
1081
|
* There is no `null`: a version the locale does not have, an entry that is not there, a type the
|
|
867
1082
|
* schema does not declare and a dataset with no schema all throw `ResourceNotFoundError`, its
|
|
868
1083
|
* `context.resourceType` naming which (REL-2409 Q12).
|
|
1084
|
+
*
|
|
1085
|
+
* It answers the version, not the entry: that locale's own fields as the version stored them, and
|
|
1086
|
+
* `_metadata` with `status: 'version'` ({@link ContentVersion}).
|
|
869
1087
|
*/
|
|
870
|
-
version(id: string, options: VersionOptions): Promise<T
|
|
1088
|
+
version(id: string, options: VersionOptions): Promise<ContentVersion<T>>;
|
|
871
1089
|
/**
|
|
872
1090
|
* Revert one locale of an entry you read to a previous version: `restore(entry, { version })`,
|
|
873
1091
|
* checked against the version the entry carries, in the locale it was read in — as
|
|
@@ -896,7 +1114,12 @@ declare class ContentClient<T extends BaseContent = BaseContent, R extends Readi
|
|
|
896
1114
|
locale: string;
|
|
897
1115
|
} & RetryableWriteOptions): Promise<RestoredContent<T>>;
|
|
898
1116
|
/**
|
|
899
|
-
*
|
|
1117
|
+
* One page of the direct children of a hierarchical entry, each read as `get` reads an entry:
|
|
1118
|
+
* the API's own `{ data, page }`, as `list` answers it (REL-1864).
|
|
1119
|
+
*
|
|
1120
|
+
* Page by `cursor` — the `page.nextCursor` a page handed back — to reach every child, or by
|
|
1121
|
+
* `page` number; `limit` is the page size for both. `page.hasMore` says whether there are more,
|
|
1122
|
+
* and a parent with more children than a page has them on the next one.
|
|
900
1123
|
*
|
|
901
1124
|
* It takes `get`'s options — `include` (checked against the type), `locale` (a code, a list or
|
|
902
1125
|
* `'*'`), `dataset`, `fresh` and `children` — the terms its route declares as the entry route
|
|
@@ -904,8 +1127,19 @@ declare class ContentClient<T extends BaseContent = BaseContent, R extends Readi
|
|
|
904
1127
|
* under each child is the `children` option.
|
|
905
1128
|
*
|
|
906
1129
|
* @param id - Parent entry ID
|
|
1130
|
+
*
|
|
1131
|
+
* @example
|
|
1132
|
+
* ```typescript
|
|
1133
|
+
* let page = await relyio.content('category').children('cat_1', { limit: 50 })
|
|
1134
|
+
* while (page.page.hasMore && page.page.nextCursor !== null) {
|
|
1135
|
+
* page = await relyio.content('category').children('cat_1', {
|
|
1136
|
+
* limit: 50,
|
|
1137
|
+
* cursor: page.page.nextCursor,
|
|
1138
|
+
* })
|
|
1139
|
+
* }
|
|
1140
|
+
* ```
|
|
907
1141
|
*/
|
|
908
|
-
children<const P extends readonly string[] = [], const L extends LocaleOption<ReadLocale<R>> | undefined = undefined>(id: string, options?:
|
|
1142
|
+
children<const P extends readonly string[] = [], const L extends LocaleOption<ReadLocale<R>> | undefined = undefined, const C extends ChildrenRead | undefined = undefined>(id: string, options?: ChildrenListOptions<R, P, L, C>): Promise<EntryList<ReadAs<R, P, undefined, L, C>>>;
|
|
909
1143
|
}
|
|
910
1144
|
|
|
911
1145
|
/**
|
|
@@ -1318,6 +1552,23 @@ declare class AssetUploadBuilder<T extends BaseContent = BaseContent> {
|
|
|
1318
1552
|
private putPartWithRetry;
|
|
1319
1553
|
private emitProgress;
|
|
1320
1554
|
}
|
|
1555
|
+
/**
|
|
1556
|
+
* The `file.*` paths an asset list filters by (REL-2456): the facets of the binding the route admits
|
|
1557
|
+
* on a public read (`QUERY_FILE_MEMBERS` in `@relyio/schema`), each taking the condition its value
|
|
1558
|
+
* does. The binding's server-only members — `objectKey`, `streamVideoId`, `storageVersion`,
|
|
1559
|
+
* `scan.*`, `extracted.text` — are refused by the API by name (REL-1501, REL-933), so they are no
|
|
1560
|
+
* key here; nor is `urls`, which is computed and never stored.
|
|
1561
|
+
*/
|
|
1562
|
+
interface AssetFileWhere {
|
|
1563
|
+
readonly 'file.status'?: WhereFieldCondition<AssetFileBlock['status']>;
|
|
1564
|
+
readonly 'file.backend'?: WhereFieldCondition<AssetFileBlock['backend']>;
|
|
1565
|
+
readonly 'file.mimeType'?: WhereFieldCondition<string>;
|
|
1566
|
+
readonly 'file.fileName'?: WhereFieldCondition<string>;
|
|
1567
|
+
readonly 'file.size'?: WhereFieldCondition<number>;
|
|
1568
|
+
readonly 'file.extracted.width'?: WhereFieldCondition<number>;
|
|
1569
|
+
readonly 'file.extracted.height'?: WhereFieldCondition<number>;
|
|
1570
|
+
readonly 'file.extracted.duration'?: WhereFieldCondition<number>;
|
|
1571
|
+
}
|
|
1321
1572
|
/**
|
|
1322
1573
|
* An asset read typed by the asset type's reading `R`: what the type's include paths make of its
|
|
1323
1574
|
* fields, beside the `file` and `urls` blocks every asset read carries (REL-1801).
|
|
@@ -1326,10 +1577,11 @@ interface AssetResponseReading<R extends Reading, T extends BaseContent = BaseCo
|
|
|
1326
1577
|
readonly read: AssetEntryResponse<Extract<ReadWith<R, this['include']>, BaseContent>>;
|
|
1327
1578
|
readonly checked: CheckedInclude<R, this['path']>;
|
|
1328
1579
|
/**
|
|
1329
|
-
* The asset type's own `where` — every path the API filters its fields by
|
|
1330
|
-
*
|
|
1580
|
+
* The asset type's own `where` — every path the API filters its fields by — and the `file.*`
|
|
1581
|
+
* facets the list admits ({@link AssetFileWhere}, REL-2456), or, where no schema types it, the
|
|
1582
|
+
* conditions `T`'s keys take (REL-2195).
|
|
1331
1583
|
*/
|
|
1332
|
-
readonly where: ReadWhere<WhereClause<T>, R
|
|
1584
|
+
readonly where: ReadWhere<WhereClause<T>, R> & AssetFileWhere;
|
|
1333
1585
|
/** The locale codes its `locale` may name: the asset type's reading's. */
|
|
1334
1586
|
readonly locale: ReadLocale<R>;
|
|
1335
1587
|
}
|
|
@@ -1398,11 +1650,21 @@ interface DocumentVersionsOptions {
|
|
|
1398
1650
|
/** The locale whose timeline it is; the client's own, then the schema default, when left out. */
|
|
1399
1651
|
readonly locale?: string;
|
|
1400
1652
|
}
|
|
1401
|
-
/**
|
|
1402
|
-
|
|
1403
|
-
|
|
1404
|
-
|
|
1653
|
+
/**
|
|
1654
|
+
* One version of a singleton or a settings group, as `version({ version })` reads it — the
|
|
1655
|
+
* document's `DocumentVersion` (REL-3181): which version of which locale, who wrote it and when, and
|
|
1656
|
+
* the fields that locale stored, nested under `fields`. Every field is optional: a locale's row
|
|
1657
|
+
* holds that locale's own fields, never the shared ones.
|
|
1658
|
+
*/
|
|
1659
|
+
type DocumentVersion<T> = Omit<components['schemas']['DocumentVersion'], 'fields'> & {
|
|
1660
|
+
fields: Partial<Omit<T, '_metadata'>>;
|
|
1405
1661
|
};
|
|
1662
|
+
/**
|
|
1663
|
+
* One row of a one-document handle's history, as `versions()` lists it — the document's
|
|
1664
|
+
* `DocumentVersionRow` (REL-3269): a version's number, locale, author and time, without its fields,
|
|
1665
|
+
* which the list does not send. Read one with `version({ version })` for what it stored.
|
|
1666
|
+
*/
|
|
1667
|
+
type DocumentVersionRow = components['schemas']['DocumentVersionRow'];
|
|
1406
1668
|
/**
|
|
1407
1669
|
* The verbs a singleton's and a settings group's handle share (REL-2419, REL-2409 decision Q18):
|
|
1408
1670
|
* `update`, `versions` and `version`, written once, as {@link EntryHandle} writes the entry routes'
|
|
@@ -1447,7 +1709,7 @@ declare abstract class DocumentHandle<T> {
|
|
|
1447
1709
|
* returns an empty array rather than another locale's rows. Every row names the locale it belongs
|
|
1448
1710
|
* to.
|
|
1449
1711
|
*/
|
|
1450
|
-
versions(options?: DocumentVersionsOptions): Promise<
|
|
1712
|
+
versions(options?: DocumentVersionsOptions): Promise<DocumentVersionRow[]>;
|
|
1451
1713
|
/**
|
|
1452
1714
|
* One version of the document: `version({ version, locale })`. `locale` defaults to the client's
|
|
1453
1715
|
* own, then the schema default; version numbers are per locale, so version 2 is different content
|
|
@@ -1457,7 +1719,7 @@ declare abstract class DocumentHandle<T> {
|
|
|
1457
1719
|
* schema does not declare and a dataset with no schema all throw `ResourceNotFoundError`, its
|
|
1458
1720
|
* `context.resourceType` naming which (REL-2409 Q12).
|
|
1459
1721
|
*/
|
|
1460
|
-
version(options: VersionOptions): Promise<T
|
|
1722
|
+
version(options: VersionOptions): Promise<DocumentVersion<T>>;
|
|
1461
1723
|
/** `PATCH` the document's route with this write. */
|
|
1462
1724
|
protected abstract patch(write: DocumentWrite<T>, options?: RetryableWriteOptions): Promise<T>;
|
|
1463
1725
|
/** `GET` the document's version history route. */
|
|
@@ -1465,12 +1727,12 @@ declare abstract class DocumentHandle<T> {
|
|
|
1465
1727
|
limit: number;
|
|
1466
1728
|
locale?: string;
|
|
1467
1729
|
}): Promise<{
|
|
1468
|
-
versions:
|
|
1730
|
+
versions: DocumentVersionRow[];
|
|
1469
1731
|
}>;
|
|
1470
1732
|
/** `GET` one version of the document. */
|
|
1471
1733
|
protected abstract readVersion(versionNumber: string, query: {
|
|
1472
1734
|
locale?: string;
|
|
1473
|
-
}): Promise<T
|
|
1735
|
+
}): Promise<DocumentVersion<T>>;
|
|
1474
1736
|
/** The locale a write or a history read sends: the call's, else the client's. */
|
|
1475
1737
|
protected localeOf(named: string | undefined): string | undefined;
|
|
1476
1738
|
/** The write's body: its data, and the locale it names when it names one. */
|
|
@@ -1525,11 +1787,11 @@ declare class SingletonClient<T = BaseSingleton, R extends Reading = UntypedRead
|
|
|
1525
1787
|
limit: number;
|
|
1526
1788
|
locale?: string;
|
|
1527
1789
|
}): Promise<{
|
|
1528
|
-
versions:
|
|
1790
|
+
versions: DocumentVersionRow[];
|
|
1529
1791
|
}>;
|
|
1530
1792
|
protected readVersion(versionNumber: string, query: {
|
|
1531
1793
|
locale?: string;
|
|
1532
|
-
}): Promise<T
|
|
1794
|
+
}): Promise<DocumentVersion<T>>;
|
|
1533
1795
|
}
|
|
1534
1796
|
|
|
1535
1797
|
/**
|
|
@@ -1595,11 +1857,11 @@ declare class SettingsClient<T = BaseSettingsGroup, R extends Reading = UntypedR
|
|
|
1595
1857
|
limit: number;
|
|
1596
1858
|
locale?: string;
|
|
1597
1859
|
}): Promise<{
|
|
1598
|
-
versions:
|
|
1860
|
+
versions: DocumentVersionRow[];
|
|
1599
1861
|
}>;
|
|
1600
1862
|
protected readVersion(versionNumber: string, query: {
|
|
1601
1863
|
locale?: string;
|
|
1602
|
-
}): Promise<T
|
|
1864
|
+
}): Promise<DocumentVersion<T>>;
|
|
1603
1865
|
}
|
|
1604
1866
|
|
|
1605
1867
|
/**
|
|
@@ -1779,6 +2041,12 @@ interface SearchReadOptions<C extends string> {
|
|
|
1779
2041
|
readonly dataset?: string;
|
|
1780
2042
|
/** How fresh the answer must be: a feed position, or `true` for past every cache. */
|
|
1781
2043
|
readonly fresh?: FreshOption;
|
|
2044
|
+
/**
|
|
2045
|
+
* Cancels the request when it aborts. The call then rejects with the platform's `AbortError` —
|
|
2046
|
+
* not a `TimeoutError` — and a request already cancelled sends nothing. The client's timeout
|
|
2047
|
+
* still applies.
|
|
2048
|
+
*/
|
|
2049
|
+
readonly signal?: AbortSignal;
|
|
1782
2050
|
}
|
|
1783
2051
|
/**
|
|
1784
2052
|
* What `search(q, options)` takes.
|
|
@@ -1968,6 +2236,12 @@ interface BatchWriteOptions {
|
|
|
1968
2236
|
readonly returnData?: boolean;
|
|
1969
2237
|
/** The dataset to write, by id or name, over the client's. */
|
|
1970
2238
|
readonly dataset?: string;
|
|
2239
|
+
/**
|
|
2240
|
+
* Cancels the request when it aborts. The call then rejects with the platform's `AbortError` —
|
|
2241
|
+
* not a `TimeoutError` — and a request already cancelled sends nothing. The client's timeout
|
|
2242
|
+
* still applies.
|
|
2243
|
+
*/
|
|
2244
|
+
readonly signal?: AbortSignal;
|
|
1971
2245
|
}
|
|
1972
2246
|
/**
|
|
1973
2247
|
* One batch item, as the committed document describes the `multi` kind: an `outcome` —
|
|
@@ -1984,21 +2258,26 @@ type BatchBody = Wire<'/v1/batch', 'post', BatchResponse>;
|
|
|
1984
2258
|
/**
|
|
1985
2259
|
* Ad-hoc and named queries as single calls: `client.query(…)` (REL-2421; REL-2409 decision Q22).
|
|
1986
2260
|
*
|
|
1987
|
-
* - `client.query({ from, … })` runs a query inline. It takes `list`'s
|
|
1988
|
-
*
|
|
1989
|
-
* plus its own: `aggregate`, `params` and `fullText`. `where` is `list`'s,
|
|
1990
|
-
* it (`{ views: { $gte: 10 } }`): the query route reads the `where` a list
|
|
1991
|
-
* REL-2409 decision D11), and refuses the bare form a saved query used to
|
|
2261
|
+
* - `client.query({ from, … })` runs a query inline. It takes `list`'s options, typed from the same
|
|
2262
|
+
* option types — `where`, `include`, `select`, `sort`, `limit`, `cursor`, `page`, `locale`,
|
|
2263
|
+
* `dataset`, `fresh` — plus its own: `aggregate`, `params` and `fullText`. `where` is `list`'s,
|
|
2264
|
+
* typed as `list` types it (`{ views: { $gte: 10 } }`): the query route reads the `where` a list
|
|
2265
|
+
* takes (REL-2439, REL-2409 decision D11), and refuses the bare form a saved query used to
|
|
2266
|
+
* declare. `locale` is a code, a list of codes or `'*'`, and `select` sits beside `include`, as
|
|
2267
|
+
* they do on `list` (REL-2460).
|
|
1992
2268
|
* - `client.query(name, { params, … })` runs the saved query the schema declares under `name`, by
|
|
1993
2269
|
* that name alone (`POST /v1/queries/{name}`, D9). Its parameters are typed from the declaration
|
|
1994
2270
|
* ({@link InferQueryParams}): a name it does not declare does not compile, and the API refuses it
|
|
1995
2271
|
* too, naming it.
|
|
1996
2272
|
*
|
|
1997
|
-
*
|
|
1998
|
-
*
|
|
1999
|
-
*
|
|
2000
|
-
* `
|
|
2273
|
+
* An ad-hoc query answers a list's envelope, `{ data, page, meta }` — its records the entries
|
|
2274
|
+
* `list` answers, an aggregate's rows or a singleton as a list of one, `page` the cursor page
|
|
2275
|
+
* `{ nextCursor, hasMore }` and `meta` how the query ran. A named query answers the API's body,
|
|
2276
|
+
* `{ data: { result, metadata } }`.
|
|
2001
2277
|
*
|
|
2278
|
+
* The cursor and the locale ride the POST's query string as they ride a list's (`?cursor=`,
|
|
2279
|
+
* `?locale=`, `?locales=`); a `page` number is sent as the offset that page starts at, so it needs the
|
|
2280
|
+
* `limit` that sizes it — the route has no default page size.
|
|
2002
2281
|
*/
|
|
2003
2282
|
|
|
2004
2283
|
/** The content types a query reads: the schema's, or any where no schema types the client. */
|
|
@@ -2018,45 +2297,35 @@ type NamedQueryParams<S, N> = S extends AnySchemaDefinition ? InferQueryParams<S
|
|
|
2018
2297
|
* route's `aggregate` block. Its source is `from`.
|
|
2019
2298
|
*/
|
|
2020
2299
|
type QueryAggregate = Omit<AggregateBlock, 'source'>;
|
|
2021
|
-
/**
|
|
2300
|
+
/**
|
|
2301
|
+
* Which page of a query: the `cursor` a previous answer's `page` handed back, or a page number, one
|
|
2302
|
+
* or the other as on `list`. A number is sent as the offset it starts at, `(page - 1) * limit`, so it
|
|
2303
|
+
* needs the `limit` that sizes it: the route has no default page size to count from.
|
|
2304
|
+
*/
|
|
2022
2305
|
type QueryPaging<T extends BaseContent, R extends Reading> = {
|
|
2306
|
+
/** The page after the one a previous answer ended on: its `page.nextCursor`. */
|
|
2307
|
+
readonly cursor?: string;
|
|
2023
2308
|
readonly page?: never;
|
|
2024
2309
|
} | {
|
|
2025
2310
|
/** Which page, from 1: sent as the offset it starts at, `(page - 1) * limit`. */
|
|
2026
2311
|
readonly page: number;
|
|
2027
2312
|
readonly limit: NonNullable<ListReadOptions<T, R, []>['limit']>;
|
|
2313
|
+
readonly cursor?: never;
|
|
2028
2314
|
};
|
|
2029
|
-
/**
|
|
2030
|
-
type
|
|
2031
|
-
readonly select?: Sel;
|
|
2032
|
-
readonly include?: undefined;
|
|
2033
|
-
} | {
|
|
2034
|
-
readonly select?: undefined;
|
|
2035
|
-
readonly include?: CheckedIncludes<R, P>;
|
|
2036
|
-
};
|
|
2315
|
+
/** The options a query takes exactly as `list` takes them, typed by `list`'s own types. */
|
|
2316
|
+
type ListedOptions = 'where' | 'include' | 'select' | 'sort' | 'limit' | 'locale' | 'dataset' | 'fresh' | 'signal';
|
|
2037
2317
|
/**
|
|
2038
|
-
* What `client.query({ from, … })` takes: `list`'s options
|
|
2039
|
-
* query's own.
|
|
2318
|
+
* What `client.query({ from, … })` takes: `list`'s options — the very types, so a change to one is a
|
|
2319
|
+
* change to both — and the query's own (REL-2460).
|
|
2320
|
+
*
|
|
2321
|
+
* `where` is `list`'s, a value, a list or `$`-prefixed operators (`{ views: { $gte: 10 } }`), and a
|
|
2322
|
+
* condition on `_metadata` is refused before anything is sent. `locale` is a code, a list of codes or
|
|
2323
|
+
* `'*'`. `select` sits beside `include`: the selected Fields, the expanded references and
|
|
2324
|
+
* `_metadata`.
|
|
2040
2325
|
*/
|
|
2041
|
-
type AdhocQuery<K extends string, T extends BaseContent, R extends Reading, P extends readonly string[], Sel extends readonly FieldKey<T>[] | undefined, A extends QueryAggregate | undefined> = {
|
|
2326
|
+
type AdhocQuery<K extends string, T extends BaseContent, R extends Reading, P extends readonly string[], Sel extends readonly FieldKey<T>[] | undefined, L extends LocaleOption<ReadLocale<R>> | undefined, A extends QueryAggregate | undefined> = {
|
|
2042
2327
|
/** The content type the query reads. */
|
|
2043
2328
|
readonly from: K;
|
|
2044
|
-
/**
|
|
2045
|
-
* The conditions an entry must meet: the `where` `list` takes, typed as `list` types it — a value,
|
|
2046
|
-
* a list, or `$`-prefixed operators (`{ views: { $gte: 10 } }`). A condition on `_metadata` is
|
|
2047
|
-
* refused before anything is sent.
|
|
2048
|
-
*/
|
|
2049
|
-
readonly where?: ListReadOptions<T, R, P>['where'];
|
|
2050
|
-
/** The order, by Field or system date, the key order the priority. */
|
|
2051
|
-
readonly sort?: SortOption<T>;
|
|
2052
|
-
/** How many entries the query answers — a page's size where `page` names one. */
|
|
2053
|
-
readonly limit?: ListReadOptions<T, R, P>['limit'];
|
|
2054
|
-
/** The one locale the entries are composed in, over the client's. */
|
|
2055
|
-
readonly locale?: ReadLocale<R>;
|
|
2056
|
-
/** The dataset to read, by id or name, over the client's. */
|
|
2057
|
-
readonly dataset?: string;
|
|
2058
|
-
/** How fresh the answer must be: a feed position, or `true` for past every cache. */
|
|
2059
|
-
readonly fresh?: FreshOption;
|
|
2060
2329
|
/** Groups and metrics computed over the entries fetched; the answer is then their rows. */
|
|
2061
2330
|
readonly aggregate?: A;
|
|
2062
2331
|
/** Values for the `${param}` expressions the query writes. */
|
|
@@ -2065,7 +2334,7 @@ type AdhocQuery<K extends string, T extends BaseContent, R extends Reading, P ex
|
|
|
2065
2334
|
};
|
|
2066
2335
|
/** A text search over the Fields it names, beside the fetch. */
|
|
2067
2336
|
readonly fullText?: FullTextSearch;
|
|
2068
|
-
} &
|
|
2337
|
+
} & Pick<ListReadOptions<T, R, P, Sel, L, undefined>, ListedOptions> & QueryPaging<T, R>;
|
|
2069
2338
|
/** What `client.query(name, options)` takes beside the parameters. */
|
|
2070
2339
|
interface NamedQueryReadOptions<L extends string> {
|
|
2071
2340
|
/** The one locale the query composes in, over the client's. */
|
|
@@ -2073,10 +2342,17 @@ interface NamedQueryReadOptions<L extends string> {
|
|
|
2073
2342
|
/** The dataset to read, by id or name, over the client's. */
|
|
2074
2343
|
readonly dataset?: string;
|
|
2075
2344
|
/**
|
|
2076
|
-
*
|
|
2077
|
-
*
|
|
2345
|
+
* How fresh the answer must be: a feed position (a change's `fresh`), or `true` for past every
|
|
2346
|
+
* cache. The route is kept at the edge for as long as the query's own `cache` policy allows
|
|
2347
|
+
* (REL-2451), so a position names a key no copy from before that change is under.
|
|
2078
2348
|
*/
|
|
2079
|
-
readonly fresh?:
|
|
2349
|
+
readonly fresh?: FreshOption;
|
|
2350
|
+
/**
|
|
2351
|
+
* Cancels the request when it aborts. The call then rejects with the platform's `AbortError` —
|
|
2352
|
+
* not a `TimeoutError` — and a request already cancelled sends nothing. The client's timeout
|
|
2353
|
+
* still applies.
|
|
2354
|
+
*/
|
|
2355
|
+
readonly signal?: AbortSignal;
|
|
2080
2356
|
}
|
|
2081
2357
|
/** What `client.query(name, options)` takes: `params` required where the query requires one. */
|
|
2082
2358
|
type NamedQueryOptions<Params, L extends string> = NamedQueryReadOptions<L> & (Record<never, never> extends Params ? {
|
|
@@ -2112,7 +2388,7 @@ interface QueryMetadata {
|
|
|
2112
2388
|
/** Validation warnings */
|
|
2113
2389
|
warnings?: string[];
|
|
2114
2390
|
}
|
|
2115
|
-
/** The API's body for a query: the records it produced and how it ran. */
|
|
2391
|
+
/** The API's body for a saved query: the records it produced and how it ran. */
|
|
2116
2392
|
interface QueryAnswer<T> {
|
|
2117
2393
|
readonly data: {
|
|
2118
2394
|
/** The records the query produced. */
|
|
@@ -2121,10 +2397,17 @@ interface QueryAnswer<T> {
|
|
|
2121
2397
|
};
|
|
2122
2398
|
}
|
|
2123
2399
|
/**
|
|
2124
|
-
*
|
|
2125
|
-
*
|
|
2400
|
+
* The API's body for an ad-hoc query: a list's envelope (REL-2460), as `list` answers it —
|
|
2401
|
+
* `data` the records, `page` the cursor dialect's `{ nextCursor, hasMore }` and no total, and
|
|
2402
|
+
* `meta` how the query ran ({@link QueryMetadata}).
|
|
2403
|
+
*/
|
|
2404
|
+
type AdhocAnswer<T> = Wire<'/v1/query', 'post', T>;
|
|
2405
|
+
/**
|
|
2406
|
+
* One record of an ad-hoc query: an aggregate's row, or the entry as `list` answers it — the
|
|
2407
|
+
* selected Fields beside `_metadata`, the expanded references of its include paths, and the other
|
|
2408
|
+
* locales under `_metadata.localizations` for a list of locales or `'*'`.
|
|
2126
2409
|
*/
|
|
2127
|
-
type AdhocRecord<R extends Reading, P extends readonly string[], Sel, A> = A extends QueryAggregate ? Readonly<Record<string, unknown>> :
|
|
2410
|
+
type AdhocRecord<R extends Reading, P extends readonly string[], Sel, L, A> = A extends QueryAggregate ? Readonly<Record<string, unknown>> : ReadAs<R, P, Sel, L>;
|
|
2128
2411
|
/**
|
|
2129
2412
|
* `client.query`: callable two ways, beside the chained client it was before.
|
|
2130
2413
|
*
|
|
@@ -2135,22 +2418,27 @@ type QueryCall<S extends AnySchemaDefinition | undefined> = AdhocQueryCall<S> &
|
|
|
2135
2418
|
/** `client.query({ from, … })`. */
|
|
2136
2419
|
type AdhocQueryCall<S extends AnySchemaDefinition | undefined> = {
|
|
2137
2420
|
/**
|
|
2138
|
-
* Run a query inline: `list`'s options plus `aggregate`, `params` and `fullText`. Answers
|
|
2139
|
-
*
|
|
2421
|
+
* Run a query inline: `list`'s options plus `aggregate`, `params` and `fullText`. Answers a
|
|
2422
|
+
* list's envelope, `{ data, page, meta }` — `data` the entries as `list` answers them, or the
|
|
2423
|
+
* aggregate's rows, `page` the cursor page and `meta` how the query ran.
|
|
2424
|
+
*
|
|
2425
|
+
* Page it by the `cursor` an answer's `page.nextCursor` hands back, as a list is paged; `locale`
|
|
2426
|
+
* is a code, a list of codes or `'*'`, and `select` sits beside `include`.
|
|
2140
2427
|
*
|
|
2141
2428
|
* @example
|
|
2142
2429
|
* ```typescript
|
|
2143
|
-
* const { data } = await relyio.query({
|
|
2430
|
+
* const { data, page } = await relyio.query({
|
|
2144
2431
|
* from: 'post',
|
|
2145
2432
|
* where: { views: { $gte: 100 } },
|
|
2146
2433
|
* select: ['title', 'views'],
|
|
2434
|
+
* include: ['author(name)'],
|
|
2147
2435
|
* sort: { views: 'desc' },
|
|
2148
2436
|
* limit: 10,
|
|
2149
|
-
* page: 2,
|
|
2150
2437
|
* })
|
|
2438
|
+
* const next = page.nextCursor && (await relyio.query({ from: 'post', limit: 10, cursor: page.nextCursor }))
|
|
2151
2439
|
* ```
|
|
2152
2440
|
*/
|
|
2153
|
-
run<K extends QueryTypeName<S>, const P extends readonly string[] = [], const Sel extends readonly FieldKey<EntryOf<S, K>>[] | undefined = undefined, const A extends QueryAggregate | undefined = undefined>(query: AdhocQuery<K, EntryOf<S, K>, ReadingOf<S, K>, P, Sel, A>): Promise<
|
|
2441
|
+
run<K extends QueryTypeName<S>, const P extends readonly string[] = [], const Sel extends readonly FieldKey<EntryOf<S, K>>[] | undefined = undefined, const L extends LocaleOption<ReadLocale<ReadingOf<S, K>>> | undefined = undefined, const A extends QueryAggregate | undefined = undefined>(query: AdhocQuery<K, EntryOf<S, K>, ReadingOf<S, K>, P, Sel, L, A>): Promise<AdhocAnswer<AdhocRecord<ReadingOf<S, K>, P, Sel, L, A>>>;
|
|
2154
2442
|
}['run'];
|
|
2155
2443
|
/** `client.query(name, { params, … })`. */
|
|
2156
2444
|
type NamedQueryCall<S extends AnySchemaDefinition | undefined> = {
|
|
@@ -2274,9 +2562,10 @@ type FeedChange = Change & {
|
|
|
2274
2562
|
};
|
|
2275
2563
|
/**
|
|
2276
2564
|
* Why a cursor could no longer be replayed, or why everything must be refetched. `/v1/changes`
|
|
2277
|
-
* names `retention` and `dataset-replaced
|
|
2278
|
-
* wire declares (`VisitorResyncReason` in
|
|
2279
|
-
* restated). `unknown` when the
|
|
2565
|
+
* names `retention` and `dataset-replaced` as its refusal's `details.reason`; the live edge's
|
|
2566
|
+
* `feed.resync` may name any reason its wire declares (`VisitorResyncReason` in
|
|
2567
|
+
* `@relyio/api-contract`, read from there rather than restated). `unknown` when the error named
|
|
2568
|
+
* none of them.
|
|
2280
2569
|
*/
|
|
2281
2570
|
type ChangesExpiredReason = VisitorResyncReason | 'unknown';
|
|
2282
2571
|
/**
|
|
@@ -2284,9 +2573,11 @@ type ChangesExpiredReason = VisitorResyncReason | 'unknown';
|
|
|
2284
2573
|
* ledger can no longer replay from (`INV-SS-CURSOR-REPLAYS`). The consumer
|
|
2285
2574
|
* resyncs from the read path and starts again without a cursor.
|
|
2286
2575
|
*
|
|
2287
|
-
* A `ResourceExpiredError`, so code that already catches that still does.
|
|
2288
|
-
*
|
|
2289
|
-
*
|
|
2576
|
+
* A `ResourceExpiredError`, so code that already catches that still does.
|
|
2577
|
+
* `reason` is the refusal's `details.reason`, which the error mapper puts on
|
|
2578
|
+
* `context.reason` (REL-3178) — never read from the message, which is English
|
|
2579
|
+
* for a developer and names no reason. An error built by hand names its reason
|
|
2580
|
+
* the same way, as `context.reason`.
|
|
2290
2581
|
*
|
|
2291
2582
|
* The live edge's `feed.resync` — a socket's frame or a poll's answer — is the
|
|
2292
2583
|
* same instruction and arrives as the same error ({@link ChangesExpiredError.resync}),
|
|
@@ -2613,14 +2904,16 @@ declare class TypedRelyIOClient<TSchema extends AnySchemaDefinition | undefined
|
|
|
2613
2904
|
/**
|
|
2614
2905
|
* Run a query in one call (REL-2421, REL-2409 Q22):
|
|
2615
2906
|
*
|
|
2616
|
-
* - `query({ from, … })` runs one inline, with `list`'s
|
|
2617
|
-
*
|
|
2618
|
-
* plus `aggregate`, `params` and `fullText
|
|
2907
|
+
* - `query({ from, … })` runs one inline, with `list`'s options — `where`, `include`, `select`
|
|
2908
|
+
* (beside `include`), `sort`, `limit`, `cursor`, `page`, `locale` (a code, a list or `'*'`),
|
|
2909
|
+
* `dataset`, `fresh` — plus `aggregate`, `params` and `fullText`. It answers a list's envelope,
|
|
2910
|
+
* `{ data, page, meta }` (REL-2460);
|
|
2619
2911
|
* - `query(name, { params, … })` runs the saved query the schema declares under `name`, its
|
|
2620
|
-
* `params` typed from that declaration.
|
|
2912
|
+
* `params` typed from that declaration. It answers the API's body,
|
|
2913
|
+
* `{ data: { result, metadata } }`.
|
|
2621
2914
|
*
|
|
2622
|
-
*
|
|
2623
|
-
*
|
|
2915
|
+
* See {@link QueryCall}. Every query is sent in the client's locale as it is then, unless it names
|
|
2916
|
+
* its own.
|
|
2624
2917
|
*/
|
|
2625
2918
|
get query(): QueryCall<TSchema>;
|
|
2626
2919
|
/**
|
|
@@ -2896,9 +3189,9 @@ declare class TypedRelyIOClient<TSchema extends AnySchemaDefinition | undefined
|
|
|
2896
3189
|
* - an option you name replaces the value the client holds;
|
|
2897
3190
|
* - an option left out, or given as `undefined`, keeps the value the client holds;
|
|
2898
3191
|
* - an option with no default given as `null` is cleared — `locale`, `dataset`, `apiKey`, `dev`,
|
|
2899
|
-
* `fetch`, `browser.onCorsError`, `
|
|
3192
|
+
* `fetch`, `browser.onCorsError`, `debug.logger` — so the client runs as though
|
|
2900
3193
|
* it had never been given one. An option with a default takes no `null`;
|
|
2901
|
-
* - a bag of options you name — `browser`, `cache`, `
|
|
3194
|
+
* - a bag of options you name — `browser`, `cache`, `debug` — keeps every field of it
|
|
2902
3195
|
* you do not name, so `updateConfig({ browser: { includeCredentials: true } })` keeps a
|
|
2903
3196
|
* configured `onCorsError`;
|
|
2904
3197
|
* - `headers` is laid over the headers the client sends, a name matched without regard to case: a
|
|
@@ -3062,4 +3355,4 @@ declare function createClient<TSchema extends AnySchemaDefinition>(config: Typed
|
|
|
3062
3355
|
*/
|
|
3063
3356
|
type ClientSchema<T extends TypedRelyIOClient<AnySchemaDefinition>> = T extends TypedRelyIOClient<infer TSchema> ? TSchema : never;
|
|
3064
3357
|
|
|
3065
|
-
export { type
|
|
3358
|
+
export { type ChildrenOptions as $, type AnySchemaDefinition as A, LIVE_KEEPALIVE_INTERVAL_MS as B, type Change as C, type DeployedLocale as D, LIVE_SOCKET_OPEN_TIMEOUT_MS as E, type FeedChange as F, type LiveChangesOptions as G, type Health as H, ContentClient as I, type CreateEntryOptions as J, type EntryPlacement as K, type LocaleCodeOf as L, type MatchRouteOptions as M, type EntryWriteOptions as N, SingletonClient as O, type Project as P, SettingsClient as Q, type Register as R, type SandboxState as S, TypedRelyIOClient as T, type DocumentFields as U, type VisitorRetry as V, type Wire as W, type DocumentVersion as X, type DocumentVersionRow as Y, type DocumentVersionsOptions as Z, type DocumentWriteOptions as _, ChangesExpiredError as a, AssetClient as a$, type ChildrenListOptions as a0, type DocumentReadOptions as a1, type EntryList as a2, type FieldKey as a3, type FreshOption as a4, type GetOptions as a5, type ListAllOptions as a6, type ListOptions as a7, type LocaleOption as a8, type Paging as a9, type SearchSortOption as aA, type SearchWhere as aB, type SimilarOptions as aC, type BatchOperationResult as aD, type BatchSummary as aE, type BatchResponse as aF, type BatchWrite as aG, type BatchWriteOptions as aH, type BatchBody as aI, type BatchCreate as aJ, type BatchUpdate as aK, type BatchReplace as aL, type BatchDelete as aM, type BatchSingletonWrite as aN, type BatchTarget as aO, type BatchDeleteTarget as aP, type AggregateMetric as aQ, type QueryMetadata as aR, type AdhocQuery as aS, type AdhocRecord as aT, type NamedQueryOptions as aU, type NamedQueryParams as aV, type QueryAggregate as aW, type QueryAnswer as aX, type QueryCall as aY, type QueryName as aZ, type QueryTypeName as a_, type ChildEntry as aa, type ChildrenRead as ab, type ReadAs as ac, type WithChildren as ad, type ReadLocale as ae, type SortOption as af, type VersionOptions as ag, type WrittenReadScope as ah, type WrittenSort as ai, type SearchResultItem as aj, type SearchHitMetadata as ak, type SearchResponse as al, type AutocompleteSuggestion as am, type AutocompleteResponse as an, type SimilarResult as ao, type SimilarResponse as ap, type SearchTypeName as aq, type SearchEntry as ar, type AutocompleteOptions as as, type SearchFacet as at, type SearchFieldKey as au, type SearchHighlight as av, type SearchOptions as aw, type SearchPage as ax, type SearchScope as ay, type SearchSelected as az, type ChangesExpiredReason as b, AssetFileBuilder as b0, AssetUploadBuilder as b1, isAssetEntry as b2, type AssetVisibility as b3, type FileStatus as b4, type FileBackend as b5, type AssetFileExtracted as b6, type FileStatusResult as b7, type AssetEntryResponse as b8, type AssetFileWhere as b9, type PopulatedAssetReference as ba, type PresignInput as bb, type PresignResult as bc, type ConfirmInput as bd, type ConfirmResult as be, type ResolveUrlInput as bf, type ResolveUrlResult as bg, type CreateAssetOptions as bh, type AssetPlacement as bi, type UpdateAssetOptions as bj, type WaitUntilReadyOptions as bk, type MultipartCreateResult as bl, type MultipartPart as bm, type MultipartTarget as bn, type UploadProgress as bo, ResourceNotFoundError as bp, ResourceConflictError as bq, ResourceExpiredError as br, isResourceNotFound as bs, isMissingEntry as bt, type FileErrorCode as bu, type FileUploadErrorCode as bv, FileUploadError as bw, FileValidationError as bx, type FileValidationConstraints as by, validateFile as bz, createClient as c, type TypedClientConfig as d, type ClientDefaults as e, type ClientSchema as f, type DeployedContentType as g, type RegisteredSchema as h, type ActiveSandbox as i, HttpClient as j, type SendOptions as k, type ApiPath as l, type ApiMethod as m, type ApiSuccessBody as n, matchRoute as o, type RouteMatch as p, type ReadEntry as q, type RetryableWriteOptions as r, DefaultRetryPolicy as s, isReplaySafe as t, retryPolicyFor as u, versionCheckOf as v, type RetryPolicy as w, type RetryableRequest as x, type ChangesHeadOptions as y, type ChangesOptions as z };
|