@relyio/sdk 0.7.0 → 0.9.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 +61 -0
- package/dist/.tsbuildinfo +1 -1
- package/dist/{chunk-GYHAVYND.js → chunk-LGNJIGHL.js} +884 -16
- package/dist/{chunk-VH2DE7HZ.cjs → chunk-SPFRDXAF.cjs} +889 -15
- package/dist/client/index.cjs +3 -3
- package/dist/client/index.d.cts +5 -4
- package/dist/client/index.d.ts +5 -4
- package/dist/client/index.js +1 -1
- package/dist/{define-content-type-DiVpbwNs.d.cts → define-content-type-cEGjIwT5.d.cts} +205 -10
- package/dist/{define-content-type-DiVpbwNs.d.ts → define-content-type-cEGjIwT5.d.ts} +205 -10
- package/dist/{define-schema-C-5an28C.d.ts → define-schema-BPj2srgh.d.ts} +1 -1
- package/dist/{define-schema-D7MButVt.d.cts → define-schema-DgbJ5Kwn.d.cts} +1 -1
- package/dist/{index-M0X45k7J.d.cts → index-B9axQW8s.d.cts} +265 -14
- package/dist/{index-DbsTUw3Q.d.cts → index-B_rIWO_l.d.cts} +47 -5
- package/dist/{index-BOQIHnsh.d.ts → index-Cv4tmcrw.d.ts} +47 -5
- package/dist/{index-1G97sNA8.d.ts → index-GIfaMlQ7.d.ts} +265 -14
- package/dist/index.cjs +119 -75
- package/dist/index.d.cts +152 -41
- package/dist/index.d.ts +152 -41
- package/dist/index.js +37 -12
- package/dist/schema/index.d.cts +3 -3
- package/dist/schema/index.d.ts +3 -3
- package/dist/types/index.d.cts +2 -2
- package/dist/types/index.d.ts +2 -2
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
|
-
import { C as
|
|
2
|
-
export { A as ActiveSandbox,
|
|
1
|
+
import { C as Change, a as ChangesExpiredError, b as ChangesExpiredReason } from './index-B9axQW8s.cjs';
|
|
2
|
+
export { A as ActiveSandbox, a6 as AdhocAggregateBlock, a5 as AdhocFetchBlock, a4 as AdhocQueryBuilder, a3 as AdhocQueryClient, ab as AdhocQueryDefinition, ac as AdhocQueryOptions, ae as AdhocQueryResult, a8 as AdhocSearchBlock, a7 as AggregateMetric, af as AssetClient, aq as AssetEntryResponse, am as AssetFileBlock, ag as AssetFileBuilder, an as AssetFileExtracted, ah as AssetUploadBuilder, ap as AssetUrls, aj as AssetVisibility, y as AutocompleteBuilder, K as AutocompleteResponse, J as AutocompleteSuggestion, Y as BatchBuilder, X as BatchClient, Z as BatchMethod, _ as BatchOperation, a0 as BatchOperationResult, $ as BatchOptions, a2 as BatchResponse, a1 as BatchSummary, k as ChangesHeadOptions, l as ChangesOptions, t as ChildrenOptions, e as ClientSchema, i as ConditionalWriteOptions, au as ConfirmInput, av as ConfirmResult, s as ContentByIdBuilder, o as ContentClient, r as ContentQueryBuilder, ay as CreateAssetOptions, E as ExtendedQueryResult, F as FeedChange, al as FileBackend, aI as FileErrorCode, ak as FileStatus, ao as FileStatusResult, aK as FileUploadError, aJ as FileUploadErrorCode, aM as FileValidationConstraints, aL as FileValidationError, a9 as FilterValue, aa as FullTextConfig, H as HttpClient, L as LIVE_KEEPALIVE_INTERVAL_MS, m as LIVE_SOCKET_OPEN_TIMEOUT_MS, n as LiveChangesOptions, aA as MultipartCreateResult, aB as MultipartPart, aC as MultipartTarget, ar as PopulatedAssetReference, as as PresignInput, at as PresignResult, P as Project, ad as QueryMetadata, R as Register, f as RegisteredSchema, aw as ResolveUrlInput, ax as ResolveUrlResult, aF as ResourceConflictError, aG as ResourceExpiredError, aE as ResourceNotFoundError, j as RetryableWriteOptions, S as SandboxState, x as SearchBuilder, w as SearchClient, W as SearchEntry, Q as SearchFields, O as SearchFilter, G as SearchHitMetadata, B as SearchMode, I as SearchResponse, D as SearchResultItem, U as SearchSort, V as SearchTypeName, g as SendOptions, q as SettingsClient, v as SettingsFetchOptions, z as SimilarBuilder, N as SimilarResponse, M as SimilarResult, p as SingletonClient, u as SingletonFetchOptions, d as TypedClientConfig, T as TypedRelyIOClient, aD as UploadProgress, az as WaitUntilReadyOptions, c as createClient, c as default, h as entityTagOf, ai as isAssetEntry, aH as isResourceNotFound, aN as validateFile } from './index-B9axQW8s.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-B_rIWO_l.cjs';
|
|
5
|
+
export { c as ApiMethod, A as ApiPath, w as ApiResponse, d as ApiSuccessBody, H as BaseValidationError, t as CacheConfig, y as CacheStrategy, k as ContentQueryResult, o as ContentTypeSchema, C as CreateInput, n as CustomQuery, D as DebugConfig, E as Environment, p as FieldOptions, F as FieldTypeName, J as InvalidPayloadError, L as LiveWebSocket, b as LiveWebSocketConstructor, z as LogLevel, M as MatchRouteOptions, P as PerformanceMetrics, Q as QueryOptions, u as RealtimeConfig, r as RealtimeEvent, q as RealtimeEventType, R as RelyIOConfig, a as RelyIOConfigUpdate, v as RequestConfig, x as RetryConfig, e as RouteMatch, l as SingletonContent, j as SortOptions, s as SubscriptionOptions, U as UpdateInput, I as ValidationError, V as ValidationRule, G as ValidationViolation, h as WhereClause, g as WhereFieldCondition, i as WhereOperator, f as WhereScalar, W as Wire, m as matchRoute } from './index-B_rIWO_l.cjs';
|
|
6
|
+
import { VisitorRetry } from './live-visitor.js';
|
|
6
7
|
export { camelToSnake, createDeferred, debounce, deepClone, generateId, isBrowser, isNode, isPlainObject, isValidEmail, isValidUrl, mergeDeep, omit, pick, retry, sleep, snakeToCamel, throttle, toSafeString } from './utils/index.cjs';
|
|
7
|
-
import { Q as EntryMetadata } from './define-content-type-
|
|
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-
|
|
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-
|
|
8
|
+
import { Q as EntryMetadata } from './define-content-type-cEGjIwT5.cjs';
|
|
9
|
+
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-cEGjIwT5.cjs';
|
|
10
|
+
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-DgbJ5Kwn.cjs';
|
|
10
11
|
import './dev-handshake/index.cjs';
|
|
11
12
|
|
|
12
13
|
/**
|
|
@@ -44,25 +45,36 @@ declare const isPublishableKey: (apiKey: string | undefined) => boolean;
|
|
|
44
45
|
* state mean to it.
|
|
45
46
|
*
|
|
46
47
|
* **The transport is a parameter.** A source opens from a cursor and yields
|
|
47
|
-
* changes.
|
|
48
|
-
*
|
|
49
|
-
*
|
|
50
|
-
*
|
|
51
|
-
*
|
|
52
|
-
*
|
|
53
|
-
*
|
|
54
|
-
*
|
|
55
|
-
*
|
|
56
|
-
*
|
|
57
|
-
*
|
|
58
|
-
* `
|
|
59
|
-
*
|
|
48
|
+
* changes. There are two: `relyio.changes()`, the long-poll over `/v1/changes`,
|
|
49
|
+
* and `relyio.liveChanges()` (LV5.2, REL-1158), a WebSocket to the live edge that
|
|
50
|
+
* polls the edge when a socket cannot open — each with whatever filter the caller
|
|
51
|
+
* binds in. The edge's refusals are `LiveEdgeError`s, which the default
|
|
52
|
+
* classifier reads, so neither needs a classifier of its own.
|
|
53
|
+
*
|
|
54
|
+
* The edge source calls `opened()` on the feed's `feed.opened` frame — not the
|
|
55
|
+
* socket's `open` event, which a refusal fires too, because the edge accepts a
|
|
56
|
+
* socket to close it with a code — and on each answered poll. A Worker deploy
|
|
57
|
+
* drops every socket, and a quiet dataset delivers no change, so without it each
|
|
58
|
+
* deploy would double the next reconnect's wait up to thirty seconds. It calls
|
|
59
|
+
* `reached()` with the cursor `feed.opened` names, so a socket dropped before its
|
|
60
|
+
* first change reconnects from that cursor instead of re-reading everything.
|
|
61
|
+
*
|
|
62
|
+
* The long-poll never calls `opened()`, so its back-off resets only on a
|
|
63
|
+
* delivered change. It calls `reached()` once, opened without a cursor, with the
|
|
64
|
+
* head its first poll answered (REL-1513) — the position it starts from, and
|
|
65
|
+
* where a failure before its first change reopens — and never with a later
|
|
66
|
+
* empty page's cursor, which for a filtered feed is past rows the filter hid.
|
|
60
67
|
*/
|
|
61
68
|
|
|
62
69
|
/** The ceiling of the first wait after a failure worth retrying; doubled per consecutive failure. */
|
|
63
70
|
declare const FOLLOW_RETRY_BASE_MS = 1000;
|
|
64
71
|
/** The ceiling never doubles past this. A server's hint is not capped by it. */
|
|
65
72
|
declare const FOLLOW_RETRY_MAX_MS = 30000;
|
|
73
|
+
/**
|
|
74
|
+
* A failure that backs off (a verdict's `backOffMs`) never waits longer than this, however often it
|
|
75
|
+
* repeats. A server's hint is not capped by it.
|
|
76
|
+
*/
|
|
77
|
+
declare const FOLLOW_BACK_OFF_MAX_MS: number;
|
|
66
78
|
/** What the loop hands a source each time it opens one. */
|
|
67
79
|
interface ChangeSourceOptions {
|
|
68
80
|
/**
|
|
@@ -91,11 +103,29 @@ interface ChangeSourceOptions {
|
|
|
91
103
|
* already failed changes nothing.
|
|
92
104
|
*/
|
|
93
105
|
readonly opened: () => void;
|
|
106
|
+
/**
|
|
107
|
+
* Call with a position the transport has reached without a change to carry
|
|
108
|
+
* it — the cursor a socket's `feed.opened` names, or a poll's answer with no
|
|
109
|
+
* changes. The loop reopens from it after a failure, as it would from a
|
|
110
|
+
* delivered change's cursor, so a connection dropped before its first change
|
|
111
|
+
* replays from there rather than re-reading everything.
|
|
112
|
+
*
|
|
113
|
+
* Call it only between changes, once every change before that position has
|
|
114
|
+
* been yielded and the loop has asked for the next — a position ahead of a
|
|
115
|
+
* change still being applied would skip that change on the next open. A call
|
|
116
|
+
* from an open that has already failed changes nothing.
|
|
117
|
+
*/
|
|
118
|
+
readonly reached: (cursor: string) => void;
|
|
94
119
|
}
|
|
95
120
|
/**
|
|
96
121
|
* A transport for the changes feed: open from a position and yield each change,
|
|
97
122
|
* in feed order, as ids (`INV-SS-CHANGE-IS-IDS`).
|
|
98
123
|
*
|
|
124
|
+
* `C` is what it yields. `relyio.changes()` and `relyio.liveChanges()` yield a
|
|
125
|
+
* `FeedChange` — a `Change` with the position a refetch for it names
|
|
126
|
+
* (`fresh`) — and the loop hands `onChange` exactly that. A source of plain
|
|
127
|
+
* `Change`s is followed alike and hands plain `Change`s on.
|
|
128
|
+
*
|
|
99
129
|
* A source ends **only** when its signal aborts. Every other end — a dropped
|
|
100
130
|
* connection, a refusal, a socket closed by a deploy — is thrown, so the loop's
|
|
101
131
|
* classifier can decide between reconnecting and stopping. `relyio.changes()` is
|
|
@@ -105,7 +135,7 @@ interface ChangeSourceOptions {
|
|
|
105
135
|
* const source: ChangeSource = from => relyio.changes({ ...from, types: ['post'] })
|
|
106
136
|
* ```
|
|
107
137
|
*/
|
|
108
|
-
type ChangeSource = (options: ChangeSourceOptions) => AsyncIterable<
|
|
138
|
+
type ChangeSource<C extends Change = Change> = (options: ChangeSourceOptions) => AsyncIterable<C>;
|
|
109
139
|
/**
|
|
110
140
|
* Why everything derived from the feed may be stale, so the consumer re-reads
|
|
111
141
|
* what it holds:
|
|
@@ -113,9 +143,10 @@ type ChangeSource = (options: ChangeSourceOptions) => AsyncIterable<Change>;
|
|
|
113
143
|
* - `expired` — the cursor could no longer be replayed. The source has resynced
|
|
114
144
|
* to the current position and yields nothing after it until the handler
|
|
115
145
|
* settles.
|
|
116
|
-
* - `no-cursor` — the source failed before any change arrived
|
|
117
|
-
* cursor to reopen from and whatever happened
|
|
118
|
-
* loop reopens from the current position once
|
|
146
|
+
* - `no-cursor` — the source failed before any change arrived or any position
|
|
147
|
+
* was `reached()`, so there is no cursor to reopen from and whatever happened
|
|
148
|
+
* meanwhile cannot be replayed. The loop reopens from the current position once
|
|
149
|
+
* the handler settles.
|
|
119
150
|
*/
|
|
120
151
|
type FollowResync = {
|
|
121
152
|
readonly cause: 'expired';
|
|
@@ -148,19 +179,14 @@ type FollowState = {
|
|
|
148
179
|
readonly kind: 'stopped';
|
|
149
180
|
readonly error: unknown;
|
|
150
181
|
};
|
|
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
182
|
type FollowVerdict = {
|
|
158
183
|
readonly retry: false;
|
|
159
184
|
} | {
|
|
160
185
|
readonly retry: true;
|
|
161
186
|
readonly afterMs?: number;
|
|
187
|
+
readonly backOffMs?: number;
|
|
162
188
|
};
|
|
163
|
-
interface FollowOptions {
|
|
189
|
+
interface FollowOptions<C extends Change = Change> {
|
|
164
190
|
/** Where to start: a change's cursor from an earlier follow. Omitted, the current position. */
|
|
165
191
|
readonly since?: string;
|
|
166
192
|
/** Ends the loop, which then resolves; a wait in progress ends at once. */
|
|
@@ -170,9 +196,16 @@ interface FollowOptions {
|
|
|
170
196
|
* cursor counts as reached — a change whose handler has not settled is
|
|
171
197
|
* replayed by the next open, never skipped. A throw is a failure like the
|
|
172
198
|
* source's own, and the classifier sees it.
|
|
199
|
+
*
|
|
200
|
+
* It is handed what the source yields: from `relyio.changes()` or
|
|
201
|
+
* `relyio.liveChanges()`, a `FeedChange`, whose `fresh` a refetch names.
|
|
202
|
+
*/
|
|
203
|
+
readonly onChange: (change: C) => void | Promise<void>;
|
|
204
|
+
/**
|
|
205
|
+
* Re-read everything derived from the feed. Awaited; see {@link FollowResync}.
|
|
206
|
+
* An `expired` resync's error carries the position it resynced to as `fresh`,
|
|
207
|
+
* which the re-reads name as a change's refetch does.
|
|
173
208
|
*/
|
|
174
|
-
readonly onChange: (change: Change) => void | Promise<void>;
|
|
175
|
-
/** Re-read everything derived from the feed. Awaited; see {@link FollowResync}. */
|
|
176
209
|
readonly onResync: (resync: FollowResync) => void | Promise<void>;
|
|
177
210
|
/** Observes each transition; see {@link FollowState}. It must not throw. */
|
|
178
211
|
readonly onState?: (state: FollowState) => void;
|
|
@@ -210,6 +243,11 @@ type FollowEnd = {
|
|
|
210
243
|
* service asked for: `Retry-After`, or a rate limit's `resetAt`. Anything else —
|
|
211
244
|
* a refused key, a malformed request, a defect — stops the loop, because
|
|
212
245
|
* retrying would meet the same refusal forever.
|
|
246
|
+
*
|
|
247
|
+
* A `LiveEdgeError` says what to do itself, from the edge's own tables: `stop`,
|
|
248
|
+
* `retry` (carrying a refused poll's `Retry-After`), or `back-off` — at least
|
|
249
|
+
* `VISITOR_ADMISSION_RETRY_AFTER_SECONDS` on the doubling schedule `backOffMs`
|
|
250
|
+
* describes.
|
|
213
251
|
*/
|
|
214
252
|
declare function classifyFollowFailure(error: unknown): FollowVerdict;
|
|
215
253
|
/**
|
|
@@ -221,12 +259,13 @@ declare function classifyFollowFailure(error: unknown): FollowVerdict;
|
|
|
221
259
|
* - **A failure worth retrying** (`classify`) reopens the source after a
|
|
222
260
|
* jittered, doubling wait — a ceiling of {@link FOLLOW_RETRY_BASE_MS} doubled
|
|
223
261
|
* 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
|
|
262
|
+
* jitter to no less than half of it, and never below the server's hint; a
|
|
263
|
+
* verdict's `backOffMs` puts it on the longer schedule that field describes. A
|
|
225
264
|
* delivered change resets the doubling, and so does the source calling
|
|
226
265
|
* `opened()` once its transport is up. The source reopens from the last
|
|
227
|
-
* change's cursor
|
|
228
|
-
* so `onResync({ cause: 'no-cursor' })`
|
|
229
|
-
* the current position.
|
|
266
|
+
* change's cursor — or the last position it `reached()` — so nothing is
|
|
267
|
+
* skipped; with neither there is none, so `onResync({ cause: 'no-cursor' })`
|
|
268
|
+
* runs first and the source reopens from the current position.
|
|
230
269
|
* - **Anything else** stops the loop: reported once as `stopped`, and returned.
|
|
231
270
|
*
|
|
232
271
|
* It never rejects. An abort — in the source, in a handler, or during a wait —
|
|
@@ -237,13 +276,14 @@ declare function classifyFollowFailure(error: unknown): FollowVerdict;
|
|
|
237
276
|
* const controller = new AbortController()
|
|
238
277
|
* const end = await followChanges(from => relyio.changes({ ...from, types: ['post'] }), {
|
|
239
278
|
* signal: controller.signal,
|
|
240
|
-
* onChange: change => refetch(change.contentType, change.entryId),
|
|
241
|
-
* onResync:
|
|
279
|
+
* onChange: change => refetch(change.contentType, change.entryId, change.fresh),
|
|
280
|
+
* onResync: resync =>
|
|
281
|
+
* refetchEverything(resync.cause === 'expired' ? resync.expired.fresh : undefined),
|
|
242
282
|
* })
|
|
243
283
|
* if (end.kind === 'stopped') console.error(end.error)
|
|
244
284
|
* ```
|
|
245
285
|
*/
|
|
246
|
-
declare function followChanges(source: ChangeSource
|
|
286
|
+
declare function followChanges<C extends Change>(source: ChangeSource<C>, options: FollowOptions<C>): Promise<FollowEnd>;
|
|
247
287
|
|
|
248
288
|
/**
|
|
249
289
|
* Network-related errors
|
|
@@ -447,6 +487,77 @@ declare class UnknownContractError extends SDKError {
|
|
|
447
487
|
getUserMessage(): string;
|
|
448
488
|
}
|
|
449
489
|
|
|
490
|
+
/**
|
|
491
|
+
* What ended a subscription at RelyIO's live edge (`relyio.liveChanges()`):
|
|
492
|
+
*
|
|
493
|
+
* - `closed` — the edge closed the socket, or it dropped. `code` and `reason` are the close's. A
|
|
494
|
+
* refusal is a socket accepted and closed at once, because a browser cannot read a refused
|
|
495
|
+
* handshake's status (`@relyio/api-contract`'s `VISITOR_CLOSE_CODES`); a Worker deploy drops every
|
|
496
|
+
* socket with a code of its own.
|
|
497
|
+
* - `refused` — a poll was refused with this contract code (`VISITOR_POLL_ROUTE`). The mapped error
|
|
498
|
+
* is the `cause`.
|
|
499
|
+
* - `lost` — the socket stopped answering its keepalive, so the connection is presumed dead.
|
|
500
|
+
* - `unreadable` — the edge sent a frame or a poll answer the wire does not declare.
|
|
501
|
+
* - `needs-publishable-key` — the client holds no publishable key (`rly_pub_…`), so nothing was
|
|
502
|
+
* sent: a secret or preview key never travels to the edge in a URL.
|
|
503
|
+
* - `needs-live-url` — the client cannot name the edge: `liveUrl` is not set and cannot be derived
|
|
504
|
+
* from `baseUrl`, or it is not a URL. Nothing was sent.
|
|
505
|
+
*/
|
|
506
|
+
type LiveEdgeEnd = {
|
|
507
|
+
readonly kind: 'closed';
|
|
508
|
+
readonly code: number;
|
|
509
|
+
readonly reason: string;
|
|
510
|
+
} | {
|
|
511
|
+
readonly kind: 'refused';
|
|
512
|
+
readonly code: string;
|
|
513
|
+
} | {
|
|
514
|
+
readonly kind: 'lost';
|
|
515
|
+
} | {
|
|
516
|
+
readonly kind: 'unreadable';
|
|
517
|
+
readonly what: string;
|
|
518
|
+
} | {
|
|
519
|
+
readonly kind: 'needs-publishable-key';
|
|
520
|
+
} | {
|
|
521
|
+
readonly kind: 'needs-live-url';
|
|
522
|
+
};
|
|
523
|
+
/**
|
|
524
|
+
* Every end of a live-edge subscription other than its signal aborting, and what to do about it.
|
|
525
|
+
*
|
|
526
|
+
* `retry` is the wire's own answer, read from `@relyio/api-contract`'s tables rather than restated
|
|
527
|
+
* here — `VISITOR_CLOSE_RETRY` for a close, `VISITOR_POLL_RETRY` for a refused poll:
|
|
528
|
+
*
|
|
529
|
+
* - `stop` — the same request meets the same answer (a refused key, origin or dataset, a malformed
|
|
530
|
+
* query, a configuration the client lacks). `retryable` is `false`.
|
|
531
|
+
* - `retry` — a dropped connection, or the edge could not decide just now: reconnect with back-off
|
|
532
|
+
* and jitter, from the last cursor.
|
|
533
|
+
* - `back-off` — the project, or this address, holds as many connections as it may (REL-1159). Wait
|
|
534
|
+
* at least `VISITOR_ADMISSION_RETRY_AFTER_SECONDS`, with jitter, doubling while it repeats — and do
|
|
535
|
+
* not fall back to polling, which the same admission refuses.
|
|
536
|
+
*
|
|
537
|
+
* `followChanges()`'s default classifier reads it, so a loop over `liveChanges()` needs no
|
|
538
|
+
* classifier of its own.
|
|
539
|
+
*/
|
|
540
|
+
declare class LiveEdgeError extends SDKError {
|
|
541
|
+
readonly code = "LIVE_EDGE_ENDED";
|
|
542
|
+
readonly retryable: boolean;
|
|
543
|
+
readonly end: LiveEdgeEnd;
|
|
544
|
+
readonly retry: VisitorRetry;
|
|
545
|
+
/** A refused poll's `Retry-After`, in milliseconds, where it carried a readable one. */
|
|
546
|
+
readonly retryAfterMs: number | undefined;
|
|
547
|
+
constructor(message: string, end: LiveEdgeEnd, retry: VisitorRetry, options?: {
|
|
548
|
+
readonly statusCode?: number;
|
|
549
|
+
readonly cause?: Error;
|
|
550
|
+
readonly retryAfterMs?: number;
|
|
551
|
+
readonly context?: Record<string, unknown>;
|
|
552
|
+
});
|
|
553
|
+
/**
|
|
554
|
+
* The base class rebuilds an error through its own four-argument constructor, which this class
|
|
555
|
+
* does not have; rebuilt that way, `end` would be a string and `retry` a number.
|
|
556
|
+
*/
|
|
557
|
+
withContext(context: Record<string, unknown>): this;
|
|
558
|
+
getUserMessage(): string;
|
|
559
|
+
}
|
|
560
|
+
|
|
450
561
|
/**
|
|
451
562
|
* Map a RelyIO refusal onto an SDK error class.
|
|
452
563
|
*
|
|
@@ -895,4 +1006,4 @@ declare function snapToLadder(value: number): number;
|
|
|
895
1006
|
|
|
896
1007
|
declare const VERSION = "__VERSION__";
|
|
897
1008
|
|
|
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 };
|
|
1009
|
+
export { AuthorizationError, BaseContent, Change, type ChangeSource, type ChangeSourceOptions, ChangesExpiredError, ChangesExpiredReason, ConnectionError, EntryMetadata, ErrorMapper, FOLLOW_BACK_OFF_MAX_MS, 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 LiveEdgeEnd, LiveEdgeError, 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 };
|