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