@relyio/sdk 0.5.0 → 0.7.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 +540 -0
- package/dist/.tsbuildinfo +1 -1
- package/dist/{chunk-HAQELDZN.cjs → chunk-72UK5U7T.cjs} +70 -60
- package/dist/{chunk-5AZUUV5B.js → chunk-GYHAVYND.js} +1086 -494
- package/dist/{chunk-I3ESNANB.js → chunk-H6IBQSMM.js} +2 -2
- package/dist/{chunk-HT6NFRM2.cjs → chunk-TZL374LS.cjs} +2 -2
- package/dist/{chunk-CIRT6TVT.cjs → chunk-VH2DE7HZ.cjs} +1088 -497
- package/dist/{chunk-XY5KFEFY.js → chunk-YEJUMW4X.js} +70 -60
- package/dist/client/index.cjs +4 -3
- package/dist/client/index.d.cts +4 -4
- package/dist/client/index.d.ts +4 -4
- package/dist/client/index.js +2 -1
- package/dist/{index-C5mRBb6t.d.cts → define-content-type-DiVpbwNs.d.cts} +1629 -665
- package/dist/{index-mXUx2H99.d.ts → define-content-type-DiVpbwNs.d.ts} +1629 -665
- package/dist/{define-schema-DzYXk4HL.d.ts → define-schema-C-5an28C.d.ts} +211 -429
- package/dist/{define-schema-2xbHgtK-.d.cts → define-schema-D7MButVt.d.cts} +211 -429
- package/dist/{index-Dzo-upNS.d.ts → index-1G97sNA8.d.ts} +677 -296
- package/dist/index-BOQIHnsh.d.ts +818 -0
- package/dist/index-DbsTUw3Q.d.cts +818 -0
- package/dist/{index-BozPz4n1.d.cts → index-M0X45k7J.d.cts} +677 -296
- package/dist/index.cjs +180 -103
- package/dist/index.d.cts +307 -32
- package/dist/index.d.ts +307 -32
- package/dist/index.js +95 -8
- package/dist/schema/index.cjs +35 -35
- package/dist/schema/index.d.cts +21 -15
- package/dist/schema/index.d.ts +21 -15
- package/dist/schema/index.js +1 -1
- package/dist/types/index.d.cts +2 -2
- package/dist/types/index.d.ts +2 -2
- package/dist/utils/index.cjs +19 -19
- package/dist/utils/index.d.cts +10 -1
- package/dist/utils/index.d.ts +10 -1
- package/dist/utils/index.js +1 -1
- package/package.json +4 -3
- package/dist/define-content-type-CBfnTWSS.d.cts +0 -716
- package/dist/define-content-type-CBfnTWSS.d.ts +0 -716
package/dist/index.d.cts
CHANGED
|
@@ -1,13 +1,250 @@
|
|
|
1
|
-
import { C as Change } from './index-
|
|
2
|
-
export { A as ActiveSandbox,
|
|
1
|
+
import { C as ChangesExpiredError, a as Change, b as ChangesExpiredReason } from './index-M0X45k7J.cjs';
|
|
2
|
+
export { A as ActiveSandbox, a2 as AdhocAggregateBlock, a1 as AdhocFetchBlock, a0 as AdhocQueryBuilder, $ as AdhocQueryClient, a7 as AdhocQueryDefinition, a8 as AdhocQueryOptions, aa as AdhocQueryResult, a4 as AdhocSearchBlock, a3 as AggregateMetric, ab as AssetClient, am as AssetEntryResponse, ai as AssetFileBlock, ac as AssetFileBuilder, aj as AssetFileExtracted, ad as AssetUploadBuilder, al as AssetUrls, af as AssetVisibility, w as AutocompleteBuilder, G as AutocompleteResponse, F as AutocompleteSuggestion, U as BatchBuilder, Q as BatchClient, V as BatchMethod, W as BatchOperation, Y as BatchOperationResult, X as BatchOptions, _ as BatchResponse, Z as BatchSummary, k as ChangesHeadOptions, l as ChangesOptions, r as ChildrenOptions, e as ClientSchema, i as ConditionalWriteOptions, aq as ConfirmInput, ar as ConfirmResult, q as ContentByIdBuilder, m as ContentClient, p as ContentQueryBuilder, au as CreateAssetOptions, E as ExtendedQueryResult, ah as FileBackend, aE as FileErrorCode, ag as FileStatus, ak as FileStatusResult, aG as FileUploadError, aF as FileUploadErrorCode, aI as FileValidationConstraints, aH as FileValidationError, a5 as FilterValue, a6 as FullTextConfig, H as HttpClient, aw as MultipartCreateResult, ax as MultipartPart, ay as MultipartTarget, an as PopulatedAssetReference, ao as PresignInput, ap as PresignResult, P as Project, a9 as QueryMetadata, R as Register, f as RegisteredSchema, as as ResolveUrlInput, at as ResolveUrlResult, aB as ResourceConflictError, aC as ResourceExpiredError, aA as ResourceNotFoundError, j as RetryableWriteOptions, S as SandboxState, v as SearchBuilder, u as SearchClient, O as SearchEntry, L as SearchFields, K as SearchFilter, B as SearchHitMetadata, y as SearchMode, D as SearchResponse, z as SearchResultItem, M as SearchSort, N as SearchTypeName, g as SendOptions, o as SettingsClient, t as SettingsFetchOptions, x as SimilarBuilder, J as SimilarResponse, I as SimilarResult, n as SingletonClient, s as SingletonFetchOptions, d as TypedClientConfig, T as TypedRelyIOClient, az as UploadProgress, av as WaitUntilReadyOptions, c as createClient, c as default, h as entityTagOf, ae as isAssetEntry, aD as isResourceNotFound, aJ as validateFile } from './index-M0X45k7J.cjs';
|
|
3
3
|
export { fields } from './schema/index.cjs';
|
|
4
|
-
import { S as SDKError, B as BaseContent } from './index-
|
|
5
|
-
export {
|
|
4
|
+
import { S as SDKError, B as BaseContent } from './index-DbsTUw3Q.cjs';
|
|
5
|
+
export { b as ApiMethod, A as ApiPath, v as ApiResponse, c as ApiSuccessBody, z as BaseValidationError, s as CacheConfig, x as CacheStrategy, j as ContentQueryResult, n as ContentTypeSchema, C as CreateInput, l as CustomQuery, D as DebugConfig, E as Environment, o as FieldOptions, F as FieldTypeName, I as InvalidPayloadError, L as LogLevel, M as MatchRouteOptions, P as PerformanceMetrics, Q as QueryOptions, t as RealtimeConfig, q as RealtimeEvent, p as RealtimeEventType, R as RelyIOConfig, a as RelyIOConfigUpdate, u as RequestConfig, w as RetryConfig, d as RouteMatch, k as SingletonContent, i as SortOptions, r as SubscriptionOptions, U as UpdateInput, G as ValidationError, V as ValidationRule, y as ValidationViolation, g as WhereClause, f as WhereFieldCondition, h as WhereOperator, e as WhereScalar, W as Wire, m as matchRoute } from './index-DbsTUw3Q.cjs';
|
|
6
6
|
export { camelToSnake, createDeferred, debounce, deepClone, generateId, isBrowser, isNode, isPlainObject, isValidEmail, isValidUrl, mergeDeep, omit, pick, retry, sleep, snakeToCamel, throttle, toSafeString } from './utils/index.cjs';
|
|
7
|
-
|
|
8
|
-
export { n as BaseFieldConfig,
|
|
7
|
+
import { Q as EntryMetadata } from './define-content-type-DiVpbwNs.cjs';
|
|
8
|
+
export { a5 as AssetTypeConfig, a9 as AssetTypeDefinition, n as BaseFieldConfig, M as ContentTypeConfig, N as ContentTypeConfigWithFields, O as ContentTypeConfigWithFieldsets, P as ContentTypeDefinition, c as FieldDefinition, b as FieldRule, v as FieldSchemaContext, p as FieldType, F as FieldUIConfig, w as FieldValue, x as FieldValues, K as Fieldset, ad as FileKindConfig, ar as FileScanConfig, aq as FileUploadConfig, aj as ImageExifConfig, ab as ImageKindConfig, ai as ImageSourceConfig, ah as ImageUploadConfig, aa as InferAssetType, W as InferContentType, a3 as InferSingleton, a2 as InferSingletonContentType, X as LocalePublicationFields, L as LocalizationConfig, a0 as SingletonContentTypeDefinition, a1 as SingletonMetadata, G as UnresolvedComponent, z as UnresolvedEntry, ak as VariantDefinition, an as VideoCaptionsConfig, ao as VideoDownloadConfig, ac as VideoKindConfig, am as VideoPosterConfig, al as VideoUploadConfig, ap as VideoWatermarkConfig, a4 as defineAssetType, H as defineContentType, Z as defineSingleton, Y as defineSingletonContentType, J as fieldset } from './define-content-type-DiVpbwNs.cjs';
|
|
9
|
+
export { aa as AggregateBlock, C as ComponentConfig, s as ComponentDefinition, t as ComponentMetadata, a9 as FetchBlock, an as FilterDefinition, aj as IncludeDefinition, ax as InferQueryParams, aw as InferQueryResponse, a5 as QueryConfig, a6 as QueryDefinition, h as SchemaAssetTypeNames, S as SchemaConfig, b as SchemaContentTypeNames, a as SchemaDefinition, i as SchemaEntry, j as SchemaEntryOf, f as SchemaLocaleCodes, e as SchemaQueryNames, g as SchemaSettingsGroupNames, c as SchemaSingletonNames, ab as SearchBlock, am as SelectMapping, x as SettingsGroupConfig, y as SettingsGroupDefinition, ah as SortCondition, ac as WhereCondition, r as defineComponent, a4 as defineQuery, d as defineSchema, w as defineSettingsGroup } from './define-schema-D7MButVt.cjs';
|
|
9
10
|
import './dev-handshake/index.cjs';
|
|
10
11
|
|
|
12
|
+
/**
|
|
13
|
+
* What a key may do is in its prefix. A RelyIO key is `rly_{scope}_v1_{entropy}_{checksum}`, and a
|
|
14
|
+
* publishable key — the one project key that may sit in a browser (`sdk-surfaces-spec.md` decision
|
|
15
|
+
* 29) — is scope `pub`. Its scope is in its prefix so that no stored flag can disagree with it.
|
|
16
|
+
*
|
|
17
|
+
* The truth is the service's: `isPublishableApiKey` in
|
|
18
|
+
* `packages/data/metadata-db/src/utils/api-key-generator.ts`, which decides whether a presented key is
|
|
19
|
+
* publishable. This package may not import it (`INV-SS-CUSTOMER-FENCE`), so the prefix is restated
|
|
20
|
+
* here, and `src/__tests__/key-kind.test.ts` reads that file and fails when the two part.
|
|
21
|
+
*/
|
|
22
|
+
declare const PUBLISHABLE_KEY_PREFIX = "rly_pub_";
|
|
23
|
+
/**
|
|
24
|
+
* Whether `apiKey` is a publishable key (`rly_pub_…`).
|
|
25
|
+
*
|
|
26
|
+
* The one reading of a key's kind a surface asks the core for: `@relyio/react`'s `live` refuses to
|
|
27
|
+
* start in a browser without one, and the edge transport (LV5.2) is chosen by it. It reads the prefix
|
|
28
|
+
* only — whether the key is valid, active or allowed from this origin is the service's to say.
|
|
29
|
+
*
|
|
30
|
+
* `undefined` is a client that holds no key: `createClient({ apiKey: process.env.X! })` with the
|
|
31
|
+
* variable unset constructs, and refuses at its first request (REL-1120). Such a client holds no
|
|
32
|
+
* publishable key, so the answer is `false` rather than a `TypeError` in a caller that only asked.
|
|
33
|
+
*/
|
|
34
|
+
declare const isPublishableKey: (apiKey: string | undefined) => boolean;
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* `followChanges()` — the one loop that follows a changes source until its
|
|
38
|
+
* signal aborts (`INV-SS-ONE-CORE`, REL-1215).
|
|
39
|
+
*
|
|
40
|
+
* `<RelyIOProvider live>` and the preview toolbar both follow the feed, and the
|
|
41
|
+
* toolbar may not import `@relyio/react` (`INV-SS-LAYER-DIRECTION`), so each
|
|
42
|
+
* carried its own copy of this policy until the core — the one package both may
|
|
43
|
+
* import — owned it. Each surface now says only what a change, a resync and a
|
|
44
|
+
* state mean to it.
|
|
45
|
+
*
|
|
46
|
+
* **The transport is a parameter.** A source opens from a cursor and yields
|
|
47
|
+
* changes. Today that is `relyio.changes()`, the long-poll, with whatever filter
|
|
48
|
+
* the caller binds in. LV5.2 (REL-1158, `live-layer-spec.md` LV5) adds a
|
|
49
|
+
* second — a WebSocket to the live edge, falling back to polling the edge when a
|
|
50
|
+
* socket cannot open — and hands it to this loop, with a classifier for its
|
|
51
|
+
* refusal close codes. That source calls `opened()` on the socket's `open`: a
|
|
52
|
+
* Worker deploy drops every socket, and a quiet dataset delivers no change, so
|
|
53
|
+
* without it each deploy would double the next reconnect's wait up to thirty
|
|
54
|
+
* seconds. With it, every drop after a healthy connection waits the base
|
|
55
|
+
* ceiling. The loop, and every handler a surface passes it, stay as they are.
|
|
56
|
+
*
|
|
57
|
+
* The long-poll does not call `opened()`: `relyio.changes()` takes the public
|
|
58
|
+
* `ChangesOptions`, which does not carry it, so its back-off resets only on a
|
|
59
|
+
* delivered change — as it did before this loop existed.
|
|
60
|
+
*/
|
|
61
|
+
|
|
62
|
+
/** The ceiling of the first wait after a failure worth retrying; doubled per consecutive failure. */
|
|
63
|
+
declare const FOLLOW_RETRY_BASE_MS = 1000;
|
|
64
|
+
/** The ceiling never doubles past this. A server's hint is not capped by it. */
|
|
65
|
+
declare const FOLLOW_RETRY_MAX_MS = 30000;
|
|
66
|
+
/** What the loop hands a source each time it opens one. */
|
|
67
|
+
interface ChangeSourceOptions {
|
|
68
|
+
/**
|
|
69
|
+
* The cursor of the last change the loop applied — or the `since` it was
|
|
70
|
+
* started with. Omitted, the source starts from the dataset's current position
|
|
71
|
+
* and replays nothing.
|
|
72
|
+
*/
|
|
73
|
+
readonly since?: string;
|
|
74
|
+
/**
|
|
75
|
+
* Ends the source. On an abort the iteration **completes**: no rejection, and
|
|
76
|
+
* no further request or frame.
|
|
77
|
+
*/
|
|
78
|
+
readonly signal: AbortSignal;
|
|
79
|
+
/**
|
|
80
|
+
* Call when `since` can no longer be replayed (`INV-SS-CURSOR-REPLAYS`):
|
|
81
|
+
* resync to the dataset's current position, call this with the error, and
|
|
82
|
+
* await it before yielding any change after the new position.
|
|
83
|
+
*/
|
|
84
|
+
readonly onExpired: (expired: ChangesExpiredError) => Promise<void>;
|
|
85
|
+
/**
|
|
86
|
+
* Call once the transport is established — a socket's `open`, say. The loop
|
|
87
|
+
* takes it as the source being healthy and resets its back-off, so a
|
|
88
|
+
* connection that is later dropped reconnects after the base wait however
|
|
89
|
+
* often that has happened. Optional to call: a source that never does has its
|
|
90
|
+
* back-off reset only by a delivered change. A call from an open that has
|
|
91
|
+
* already failed changes nothing.
|
|
92
|
+
*/
|
|
93
|
+
readonly opened: () => void;
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* A transport for the changes feed: open from a position and yield each change,
|
|
97
|
+
* in feed order, as ids (`INV-SS-CHANGE-IS-IDS`).
|
|
98
|
+
*
|
|
99
|
+
* A source ends **only** when its signal aborts. Every other end — a dropped
|
|
100
|
+
* connection, a refusal, a socket closed by a deploy — is thrown, so the loop's
|
|
101
|
+
* classifier can decide between reconnecting and stopping. `relyio.changes()` is
|
|
102
|
+
* one as it stands:
|
|
103
|
+
*
|
|
104
|
+
* ```ts
|
|
105
|
+
* const source: ChangeSource = from => relyio.changes({ ...from, types: ['post'] })
|
|
106
|
+
* ```
|
|
107
|
+
*/
|
|
108
|
+
type ChangeSource = (options: ChangeSourceOptions) => AsyncIterable<Change>;
|
|
109
|
+
/**
|
|
110
|
+
* Why everything derived from the feed may be stale, so the consumer re-reads
|
|
111
|
+
* what it holds:
|
|
112
|
+
*
|
|
113
|
+
* - `expired` — the cursor could no longer be replayed. The source has resynced
|
|
114
|
+
* to the current position and yields nothing after it until the handler
|
|
115
|
+
* settles.
|
|
116
|
+
* - `no-cursor` — the source failed before any change arrived, so there is no
|
|
117
|
+
* cursor to reopen from and whatever happened meanwhile cannot be replayed. The
|
|
118
|
+
* loop reopens from the current position once the handler settles.
|
|
119
|
+
*/
|
|
120
|
+
type FollowResync = {
|
|
121
|
+
readonly cause: 'expired';
|
|
122
|
+
readonly expired: ChangesExpiredError;
|
|
123
|
+
} | {
|
|
124
|
+
readonly cause: 'no-cursor';
|
|
125
|
+
};
|
|
126
|
+
/**
|
|
127
|
+
* What the loop is doing, reported on every transition so a surface can name it
|
|
128
|
+
* rather than keep its own count:
|
|
129
|
+
*
|
|
130
|
+
* - `following` — the source is open (reported on every open, reconnects too);
|
|
131
|
+
* - `resynced` — the consumer's resync handler has settled;
|
|
132
|
+
* - `reconnecting` — `error` was worth retrying; the source reopens after
|
|
133
|
+
* `retryInMs`;
|
|
134
|
+
* - `stopped` — `error` was not; the loop has ended. Reported once.
|
|
135
|
+
*
|
|
136
|
+
* Nothing is reported after the signal aborts.
|
|
137
|
+
*/
|
|
138
|
+
type FollowState = {
|
|
139
|
+
readonly kind: 'following';
|
|
140
|
+
} | {
|
|
141
|
+
readonly kind: 'resynced';
|
|
142
|
+
readonly resync: FollowResync;
|
|
143
|
+
} | {
|
|
144
|
+
readonly kind: 'reconnecting';
|
|
145
|
+
readonly error: unknown;
|
|
146
|
+
readonly retryInMs: number;
|
|
147
|
+
} | {
|
|
148
|
+
readonly kind: 'stopped';
|
|
149
|
+
readonly error: unknown;
|
|
150
|
+
};
|
|
151
|
+
/**
|
|
152
|
+
* A classifier's answer for one failure. `afterMs` is the server's hint — HTTP's
|
|
153
|
+
* `Retry-After`, a socket's close code — and a floor under the loop's own
|
|
154
|
+
* back-off: the wait is never shorter than it, and a hint longer than
|
|
155
|
+
* {@link FOLLOW_RETRY_MAX_MS} is waited out in full.
|
|
156
|
+
*/
|
|
157
|
+
type FollowVerdict = {
|
|
158
|
+
readonly retry: false;
|
|
159
|
+
} | {
|
|
160
|
+
readonly retry: true;
|
|
161
|
+
readonly afterMs?: number;
|
|
162
|
+
};
|
|
163
|
+
interface FollowOptions {
|
|
164
|
+
/** Where to start: a change's cursor from an earlier follow. Omitted, the current position. */
|
|
165
|
+
readonly since?: string;
|
|
166
|
+
/** Ends the loop, which then resolves; a wait in progress ends at once. */
|
|
167
|
+
readonly signal: AbortSignal;
|
|
168
|
+
/**
|
|
169
|
+
* Apply one change. Awaited before the next change is taken, and before its
|
|
170
|
+
* cursor counts as reached — a change whose handler has not settled is
|
|
171
|
+
* replayed by the next open, never skipped. A throw is a failure like the
|
|
172
|
+
* source's own, and the classifier sees it.
|
|
173
|
+
*/
|
|
174
|
+
readonly onChange: (change: Change) => void | Promise<void>;
|
|
175
|
+
/** Re-read everything derived from the feed. Awaited; see {@link FollowResync}. */
|
|
176
|
+
readonly onResync: (resync: FollowResync) => void | Promise<void>;
|
|
177
|
+
/** Observes each transition; see {@link FollowState}. It must not throw. */
|
|
178
|
+
readonly onState?: (state: FollowState) => void;
|
|
179
|
+
/**
|
|
180
|
+
* Whether a failure is worth reopening the source for, and any wait the
|
|
181
|
+
* server asked for. Default {@link classifyFollowFailure}. A transport whose
|
|
182
|
+
* failures the core's errors do not describe supplies its own, and delegates
|
|
183
|
+
* the rest to the default.
|
|
184
|
+
*/
|
|
185
|
+
readonly classify?: (error: unknown) => FollowVerdict;
|
|
186
|
+
/**
|
|
187
|
+
* The jitter's source of randomness, `Math.random` by default: a number in
|
|
188
|
+
* `[0, 1)`. `0` waits the whole ceiling; values towards `1` shorten the wait
|
|
189
|
+
* to just over half of it. A test fixes it.
|
|
190
|
+
*/
|
|
191
|
+
readonly random?: () => number;
|
|
192
|
+
}
|
|
193
|
+
/**
|
|
194
|
+
* How the loop ended — never a rejection. `since` is the cursor of the last
|
|
195
|
+
* change applied (or the starting `since`), which a caller that stopped the loop
|
|
196
|
+
* to reopen it with a different filter starts the next one from.
|
|
197
|
+
*/
|
|
198
|
+
type FollowEnd = {
|
|
199
|
+
readonly kind: 'aborted';
|
|
200
|
+
readonly since: string | undefined;
|
|
201
|
+
} | {
|
|
202
|
+
readonly kind: 'stopped';
|
|
203
|
+
readonly since: string | undefined;
|
|
204
|
+
readonly error: unknown;
|
|
205
|
+
};
|
|
206
|
+
/**
|
|
207
|
+
* The default classifier. A failure is worth retrying when the core calls it
|
|
208
|
+
* retryable — `SDKError.retryable`, **after** the client's own retries, so this
|
|
209
|
+
* is an outage that outlasted them — and the wait it carries is the one the
|
|
210
|
+
* service asked for: `Retry-After`, or a rate limit's `resetAt`. Anything else —
|
|
211
|
+
* a refused key, a malformed request, a defect — stops the loop, because
|
|
212
|
+
* retrying would meet the same refusal forever.
|
|
213
|
+
*/
|
|
214
|
+
declare function classifyFollowFailure(error: unknown): FollowVerdict;
|
|
215
|
+
/**
|
|
216
|
+
* Follow `source` until `signal` aborts: apply each change in feed order, one at
|
|
217
|
+
* a time, and carry the cursor.
|
|
218
|
+
*
|
|
219
|
+
* - **Expired cursor.** The source resyncs and awaits `onResync({ cause:
|
|
220
|
+
* 'expired' })` before yielding anything after the new position.
|
|
221
|
+
* - **A failure worth retrying** (`classify`) reopens the source after a
|
|
222
|
+
* jittered, doubling wait — a ceiling of {@link FOLLOW_RETRY_BASE_MS} doubled
|
|
223
|
+
* per consecutive failure up to {@link FOLLOW_RETRY_MAX_MS}, shortened by the
|
|
224
|
+
* jitter to no less than half of it, and never below the server's hint. A
|
|
225
|
+
* delivered change resets the doubling, and so does the source calling
|
|
226
|
+
* `opened()` once its transport is up. The source reopens from the last
|
|
227
|
+
* change's cursor so nothing is skipped; with no change seen yet there is none,
|
|
228
|
+
* so `onResync({ cause: 'no-cursor' })` runs first and the source reopens from
|
|
229
|
+
* the current position.
|
|
230
|
+
* - **Anything else** stops the loop: reported once as `stopped`, and returned.
|
|
231
|
+
*
|
|
232
|
+
* It never rejects. An abort — in the source, in a handler, or during a wait —
|
|
233
|
+
* resolves it at once with no further open, resync or state; a change whose
|
|
234
|
+
* handler is running when the abort lands is finished and its cursor kept.
|
|
235
|
+
*
|
|
236
|
+
* ```ts
|
|
237
|
+
* const controller = new AbortController()
|
|
238
|
+
* const end = await followChanges(from => relyio.changes({ ...from, types: ['post'] }), {
|
|
239
|
+
* signal: controller.signal,
|
|
240
|
+
* onChange: change => refetch(change.contentType, change.entryId),
|
|
241
|
+
* onResync: () => refetchEverything(),
|
|
242
|
+
* })
|
|
243
|
+
* if (end.kind === 'stopped') console.error(end.error)
|
|
244
|
+
* ```
|
|
245
|
+
*/
|
|
246
|
+
declare function followChanges(source: ChangeSource, options: FollowOptions): Promise<FollowEnd>;
|
|
247
|
+
|
|
11
248
|
/**
|
|
12
249
|
* Network-related errors
|
|
13
250
|
*/
|
|
@@ -20,7 +257,11 @@ declare class NetworkError extends SDKError {
|
|
|
20
257
|
declare class TimeoutError extends SDKError {
|
|
21
258
|
readonly code = "TIMEOUT_ERROR";
|
|
22
259
|
readonly retryable = true;
|
|
23
|
-
|
|
260
|
+
/**
|
|
261
|
+
* @param context - Carried beside `timeout`. The mapper passes a `REQUEST_TIMEOUT` refusal's body
|
|
262
|
+
* as `context.response`, as it does for every other contract code.
|
|
263
|
+
*/
|
|
264
|
+
constructor(message?: string, timeout?: number, statusCode?: number, cause?: Error, context?: Record<string, unknown>);
|
|
24
265
|
getUserMessage(): string;
|
|
25
266
|
}
|
|
26
267
|
declare class ConnectionError extends SDKError {
|
|
@@ -39,13 +280,13 @@ declare class ConnectionError extends SDKError {
|
|
|
39
280
|
* (`INV-API-CODES-ARE-A-CLOSED-UNION`: a code no route declares is deleted, not
|
|
40
281
|
* retained). An API key that has expired arrives as `INVALID_API_KEY` with
|
|
41
282
|
* `details.reason: 'expired'`.
|
|
283
|
+
*
|
|
284
|
+
* `AuthenticationError` was deleted by REL-1471 for the same reason. The
|
|
285
|
+
* vocabulary's two 401 codes are `MISSING_API_KEY` and `INVALID_API_KEY`, and
|
|
286
|
+
* the mapper throws `MissingApiKeyError` and `InvalidApiKeyError` for them —
|
|
287
|
+
* so a generic 401 class had no refusal left to stand for, and nothing
|
|
288
|
+
* constructed it.
|
|
42
289
|
*/
|
|
43
|
-
declare class AuthenticationError extends SDKError {
|
|
44
|
-
readonly code = "AUTHENTICATION_ERROR";
|
|
45
|
-
readonly retryable = false;
|
|
46
|
-
constructor(message?: string, statusCode?: number, cause?: Error, context?: Record<string, unknown>);
|
|
47
|
-
getUserMessage(): string;
|
|
48
|
-
}
|
|
49
290
|
declare class AuthorizationError extends SDKError {
|
|
50
291
|
readonly code = "AUTHORIZATION_ERROR";
|
|
51
292
|
readonly retryable = false;
|
|
@@ -268,28 +509,27 @@ declare class ErrorMapper {
|
|
|
268
509
|
* })
|
|
269
510
|
* ```
|
|
270
511
|
*/
|
|
512
|
+
|
|
271
513
|
/**
|
|
272
|
-
*
|
|
514
|
+
* One locale an entry has content in, as `_metadata.availableLocales` lists it: the document's
|
|
515
|
+
* `EntryLocale`. `version` is that locale's own counter and is always sent.
|
|
273
516
|
*/
|
|
274
|
-
|
|
275
|
-
code: string;
|
|
276
|
-
status: 'published' | 'draft' | 'archived';
|
|
277
|
-
version?: number;
|
|
278
|
-
publishedAt?: string;
|
|
279
|
-
}
|
|
517
|
+
type LocaleStatus = EntryMetadata['availableLocales'][number];
|
|
280
518
|
/**
|
|
281
|
-
*
|
|
519
|
+
* The locale facts of an entry's `_metadata` that these helpers read — a `Pick` of the document's
|
|
520
|
+
* `EntryMetadata`, so what they read is what a read declares, not a second, looser copy of it.
|
|
521
|
+
* `locale`, `defaultLocale` and `availableLocales` are always sent; `requestedLocale`,
|
|
522
|
+
* `localeFallbacksApplied` and `localizations` only when the request asked for them.
|
|
282
523
|
*/
|
|
283
|
-
|
|
284
|
-
locale?: string;
|
|
285
|
-
requestedLocale?: string;
|
|
286
|
-
defaultLocale?: string;
|
|
287
|
-
localeFallbacksApplied?: Record<string, string>;
|
|
288
|
-
availableLocales?: LocaleStatus[];
|
|
289
|
-
localizations?: Record<string, unknown>;
|
|
290
|
-
}
|
|
524
|
+
type LocaleMetadata = Pick<EntryMetadata, 'locale' | 'requestedLocale' | 'defaultLocale' | 'localeFallbacksApplied' | 'availableLocales' | 'localizations'>;
|
|
291
525
|
/**
|
|
292
|
-
* Entry with locale metadata
|
|
526
|
+
* Entry with locale metadata: an entry read — single, listed, a child or an expanded reference.
|
|
527
|
+
*
|
|
528
|
+
* Not a search or similar hit: a hit's `_metadata` is the document's `SearchHitMetadata`, which
|
|
529
|
+
* carries no `defaultLocale` or `availableLocales`, so passing one here is a compile error rather
|
|
530
|
+
* than an empty answer. That is what let the helpers below read `availableLocales` without an
|
|
531
|
+
* optional chain (REL-1413); the one on `_metadata` stays because a schema-defined query's row
|
|
532
|
+
* carries `_metadata` only when the query selects it.
|
|
293
533
|
*/
|
|
294
534
|
interface LocalizedEntry {
|
|
295
535
|
_metadata?: LocaleMetadata;
|
|
@@ -301,7 +541,7 @@ interface LocalizedEntry {
|
|
|
301
541
|
interface LanguageSwitcherOption {
|
|
302
542
|
code: string;
|
|
303
543
|
label: string;
|
|
304
|
-
status: '
|
|
544
|
+
status: LocaleStatus['status'];
|
|
305
545
|
isCurrent: boolean;
|
|
306
546
|
isDefault: boolean;
|
|
307
547
|
hasContent: boolean;
|
|
@@ -561,6 +801,41 @@ declare const RELYIO_CHANGE_EVENT = "relyio:change";
|
|
|
561
801
|
* ```
|
|
562
802
|
*/
|
|
563
803
|
type RelyIOChangeDetail = Change;
|
|
804
|
+
/**
|
|
805
|
+
* The DOM event a preview surface dispatches when **everything** on the page may be stale: the feed
|
|
806
|
+
* lost its place, so the surface re-read what it holds without a change to name (REL-1214). Same
|
|
807
|
+
* target and the same wire-contract rule as {@link RELYIO_CHANGE_EVENT}; `<RelyIORefresh />` listens
|
|
808
|
+
* for both.
|
|
809
|
+
*
|
|
810
|
+
* **A second name, not a second shape of the first.** A `relyio:change` listener reads `detail` as
|
|
811
|
+
* a {@link Change}. A resync dispatched under that name would hand it `undefined` ids at runtime —
|
|
812
|
+
* and a listener built against an earlier release, or written in JavaScript, gets no type error to
|
|
813
|
+
* warn it. Under its own name, a listener that knows only `relyio:change` behaves exactly as before:
|
|
814
|
+
* it does not hear a resync. Nor is a resync one synthetic change per re-read entry: a change carries
|
|
815
|
+
* a `cursor`, and the feed issued none for it.
|
|
816
|
+
*
|
|
817
|
+
* @example
|
|
818
|
+
* ```ts
|
|
819
|
+
* window.addEventListener(RELYIO_RESYNC_EVENT, () => refetchEverything())
|
|
820
|
+
* ```
|
|
821
|
+
*/
|
|
822
|
+
declare const RELYIO_RESYNC_EVENT = "relyio:resync";
|
|
823
|
+
/**
|
|
824
|
+
* The `detail` of a {@link RELYIO_RESYNC_EVENT} dispatch: why the feed lost its place, one arm per
|
|
825
|
+
* `FollowResync` cause, as plain data.
|
|
826
|
+
*
|
|
827
|
+
* - `expired` — the cursor could no longer be replayed; `reason` is the feed's own
|
|
828
|
+
* ({@link ChangesExpiredReason}).
|
|
829
|
+
* - `no-cursor` — the feed failed before any change arrived, so it had no cursor to resume from.
|
|
830
|
+
*
|
|
831
|
+
* A listener that only refreshes reads none of it.
|
|
832
|
+
*/
|
|
833
|
+
type RelyIOResyncDetail = {
|
|
834
|
+
readonly cause: 'expired';
|
|
835
|
+
readonly reason: ChangesExpiredReason;
|
|
836
|
+
} | {
|
|
837
|
+
readonly cause: 'no-cursor';
|
|
838
|
+
};
|
|
564
839
|
|
|
565
840
|
/**
|
|
566
841
|
* The width ladder the delivery Worker snaps every rendered dimension to
|
|
@@ -620,4 +895,4 @@ declare function snapToLadder(value: number): number;
|
|
|
620
895
|
|
|
621
896
|
declare const VERSION = "__VERSION__";
|
|
622
897
|
|
|
623
|
-
export {
|
|
898
|
+
export { AuthorizationError, BaseContent, Change, type ChangeSource, type ChangeSourceOptions, ChangesExpiredError, ChangesExpiredReason, ConnectionError, EntryMetadata, ErrorMapper, FOLLOW_RETRY_BASE_MS, FOLLOW_RETRY_MAX_MS, type FollowEnd, type FollowOptions, type FollowResync, type FollowState, type FollowVerdict, IMAGE_LADDER, InvalidApiKeyError, type LanguageSwitcherOption, type LanguageSwitcherOptions, type LocaleMetadata, type LocaleStatus, type LocalizedEntry, MethodNotAllowedError, MissingApiKeyError, NetworkError, PUBLISHABLE_KEY_PREFIX, PayloadTooLargeError, PlanFeatureUnavailableError, RELYIO_CHANGE_EVENT, RELYIO_RESYNC_EVENT, RateLimitError, ReadOnlyKeyError, type RelyIOChangeDetail, type RelyIOFieldAttributes, type RelyIOFieldName, type RelyIOResyncDetail, SDKError, ServerError, ServiceIndeterminateError, TimeoutError, TransactionRolledBackError, type TranslationCompleteness, UnknownContractError, UsageQuotaExceededError, VERSION, buildLanguageSwitcher, classifyFollowFailure, estimateTranslationCompleteness, followChanges, getAllLocalizedValues, getAvailableLocaleCodes, getDefaultLocale, getFallbackFields, getFieldFallbackLocale, getLocalizedField, getPublishedLocaleCodes, getRequestedLocale, hasLocale, isFieldFallback, isPublishableKey, isPublishedInLocale, localeHelpers, needsTranslation, relyioField, snapToLadder };
|