@relyio/sdk 0.16.0 → 0.18.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 +23 -0
- package/dist/automations/index.cjs +70 -0
- package/dist/automations/index.d.cts +1309 -0
- package/dist/automations/index.d.ts +1309 -0
- package/dist/automations/index.js +5 -0
- package/dist/{chunk-RSHMA4KT.cjs → chunk-2SPPU2WG.cjs} +68 -68
- package/dist/chunk-7I3SC7SV.cjs +40 -0
- package/dist/chunk-DI6KFDBO.js +43 -0
- package/dist/chunk-EDE2H37D.js +686 -0
- package/dist/chunk-HDHBYYEY.js +36 -0
- package/dist/{chunk-RLLZUFDB.cjs → chunk-IFKF72VJ.cjs} +718 -331
- package/dist/chunk-L6DXCKVQ.cjs +50 -0
- package/dist/chunk-LSI26ZN2.cjs +535 -0
- package/dist/{chunk-TZL374LS.cjs → chunk-M7MWNV3Q.cjs} +21 -21
- package/dist/{chunk-H6IBQSMM.js → chunk-NJQK5STK.js} +3 -3
- package/dist/chunk-R6E4HE7R.js +520 -0
- package/dist/chunk-SHSK7UUY.cjs +706 -0
- package/dist/{chunk-BBUB7C2Z.js → chunk-W2A4OTCI.js} +3 -3
- package/dist/chunk-W7JFHSFM.js +18718 -0
- package/dist/{chunk-5UMY6CS4.js → chunk-ZAKEY6DY.js} +3 -3
- package/dist/chunk-ZAMAR3X2.cjs +18759 -0
- package/dist/{chunk-NIUOPIIB.js → chunk-ZHTJ7GXH.js} +400 -19
- package/dist/{chunk-LSRPMNPT.cjs → chunk-ZO6QDYJG.cjs} +7 -7
- package/dist/client/index.cjs +8 -7
- package/dist/client/index.d.cts +4 -3
- package/dist/client/index.d.ts +4 -3
- package/dist/client/index.js +6 -5
- package/dist/{define-content-type-LkI0rS2W.d.cts → define-content-type-NEQDrvdq.d.cts} +3420 -749
- package/dist/{define-content-type-CAWSlgn0.d.ts → define-content-type-fb-WCD5e.d.ts} +3420 -749
- package/dist/{define-schema-Dxu3RoHV.d.ts → define-schema-DZhtvLiK.d.cts} +157 -10
- package/dist/{define-schema-wlsJOrnY.d.cts → define-schema-Dlwh6l_J.d.ts} +157 -10
- package/dist/dev-handshake/index.cjs +9 -9
- package/dist/dev-handshake/index.js +2 -2
- package/dist/extensions/index.cjs +80 -0
- package/dist/extensions/index.d.cts +792 -0
- package/dist/extensions/index.d.ts +792 -0
- package/dist/extensions/index.js +76 -0
- package/dist/functions/index.cjs +68 -0
- package/dist/functions/index.d.cts +6 -0
- package/dist/functions/index.d.ts +6 -0
- package/dist/functions/index.js +59 -0
- package/dist/{index-CGtYxUuh.d.ts → index-C4LqrNd1.d.ts} +1 -1
- package/dist/{index-CcHmRALk.d.cts → index-Dnmt_UOo.d.cts} +1 -1
- package/dist/{index-D80MXUkf.d.cts → index-DwHcL6x5.d.cts} +103 -442
- package/dist/{index-BH8JksfG.d.ts → index-M3luH06A.d.ts} +103 -442
- package/dist/index.cjs +204 -185
- package/dist/index.d.cts +93 -13
- package/dist/index.d.ts +93 -13
- package/dist/index.js +11 -16
- package/dist/markdown/index.cjs +382 -382
- package/dist/markdown/index.js +1 -1
- package/dist/preview/index.cjs +11 -10
- package/dist/preview/index.js +3 -2
- package/dist/register-B53i97A9.d.ts +677 -0
- package/dist/register-BYCs0FpF.d.cts +677 -0
- package/dist/rich-text/index.cjs +12 -12
- package/dist/rich-text/index.d.cts +2 -2
- package/dist/rich-text/index.d.ts +2 -2
- package/dist/rich-text/index.js +2 -2
- package/dist/schema/index.cjs +62 -34
- package/dist/schema/index.d.cts +127 -5
- package/dist/schema/index.d.ts +127 -5
- package/dist/schema/index.js +2 -2
- package/dist/types/index.d.cts +1 -1
- package/dist/types/index.d.ts +1 -1
- package/dist/utils/index.cjs +20 -20
- package/dist/utils/index.js +2 -2
- package/package.json +21 -3
- package/dist/chunk-7BZW6XYJ.cjs +0 -433
- package/dist/chunk-CQHEG7QA.js +0 -411
- package/dist/chunk-DIZY6CKM.js +0 -950
- package/dist/chunk-GHYB6IZK.cjs +0 -983
- package/dist/chunk-MWMSFIWN.cjs +0 -17
- package/dist/chunk-XQ4QHWZE.js +0 -13
|
@@ -1,143 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { e as ApiPath, f as ApiMethod, Q as QueryOf, W as Wire, H as HttpClient, A as AnySchemaDefinition, l as RecordsClient, B as BaseRecord, y as RecordBatchOperation, C as RecordBatchOptions, b as RecordBatchResult, R as RegisteredSchema } from './register-BYCs0FpF.cjs';
|
|
2
|
+
import { aU as EntryMetadata, ax as Reading, cQ as BaseContent, at as CheckedIncludes, dp as ReadWhere, cV as WhereClause, cw as components, ay as ReadWith, d4 as UpdateInput, aB as UntypedReading, c_ as RevisedContent, cY as CreateInput, cZ as CreatedContent, d3 as ContentVersionRow, d2 as ContentVersion, d1 as RestoredContent, cJ as SDKError, dl as BaseValidationError, dk as ValidationViolation, ba as AssetServedBlocks, dq as CheckedInclude, cU as WhereFieldCondition, cO as AssetFileBlock, cR as BaseSingleton, c$ as WrittenSingleton, cS as BaseSettingsGroup, d0 as WrittenSettingsGroup, aV as InferContentType, av as ContentReading, a$ as InferSingleton, cF as paths, cK as RelyIOConfig, b8 as InferAssetType, as as AssetReading, aA as SingletonReading, b4 as InferSettingsGroup, az as SettingsReading, cL as RelyIOConfigUpdate, cH as MergedRelyIOConfig } from './define-content-type-NEQDrvdq.cjs';
|
|
3
|
+
import { a as SchemaContentTypeNames, l as SchemaEntryOf, c as SchemaLocaleCodes, h as SchemaSingletonNames, v as AggregateBlock, _ as QueryParameterValue, F as FullTextSearch, i as SchemaQueryNames, Z as InferQueryParams, $ as AnyQueryParameters, S as SchemaRecordTypeNames, I as InferRecordType, R as RecordWriteFieldsOf, d as RecordUpdateFieldsOf, k as SchemaAssetTypeNames, j as SchemaSettingsGroupNames } from './define-schema-DZhtvLiK.cjs';
|
|
3
4
|
import { DevUnreadableReason } from './dev-handshake/index.cjs';
|
|
4
5
|
|
|
5
|
-
/**
|
|
6
|
-
* Where the SDK's transport gets its truth.
|
|
7
|
-
*
|
|
8
|
-
* Every route this client calls is named by its **path template as the
|
|
9
|
-
* committed document spells it**, and the body type it expects is read out of
|
|
10
|
-
* that document rather than written down here. `api-schema.ts` beside this file
|
|
11
|
-
* is generated by `pnpm api:types` from `apps/services/api/openapi-spec.json`,
|
|
12
|
-
* which is itself generated from that service's `RouteContract`s
|
|
13
|
-
* (`INV-API-DOCUMENT-IS-DERIVED`). So the chain is: one declaration in
|
|
14
|
-
* `routes.ts` → the serializer that produces the body → the document → these
|
|
15
|
-
* types → the method that reads it.
|
|
16
|
-
*
|
|
17
|
-
* That chain is the answer to the question this phase exists to close. Before
|
|
18
|
-
* it, six SDK methods read a key the server does not send; each had no caller
|
|
19
|
-
* and no test, so nothing could see them. Now:
|
|
20
|
-
*
|
|
21
|
-
* - A route that changes **kind** — `collection` to `object`, say — changes
|
|
22
|
-
* whether the document's 200 body carries `page` and whether `data` is an
|
|
23
|
-
* array. `Wire<…>` follows, `readPayload` follows, and the method's declared
|
|
24
|
-
* return type stops matching. `tsc` names the method.
|
|
25
|
-
* - A route that changes **path** or is deleted stops being a `keyof paths`, so
|
|
26
|
-
* the call site fails on the literal.
|
|
27
|
-
* - A route that changes **dialect** changes `page` from `CursorPage` to
|
|
28
|
-
* `OffsetPage`, and anything reading `nextCursor` fails.
|
|
29
|
-
*
|
|
30
|
-
* `/v1` lives in these templates because it lives in the document
|
|
31
|
-
* (`INV-API-VERSION-IS-DECIDED-ONCE`). Before this phase the SDK's base URL was
|
|
32
|
-
* `https://api.relyio.com` and its paths were `/{contentType}`, so every
|
|
33
|
-
* versioned request went to a path the router does not serve.
|
|
34
|
-
*
|
|
35
|
-
* Spec: `devtools/docs/guide/engineering/api-contract-spec.md`,
|
|
36
|
-
* `INV-API-CLIENT-IS-DERIVED`.
|
|
37
|
-
*/
|
|
38
|
-
|
|
39
|
-
/** Every path the committed document declares. */
|
|
40
|
-
type ApiPath = keyof paths;
|
|
41
|
-
type Verb$1 = 'get' | 'post' | 'put' | 'patch' | 'delete';
|
|
42
|
-
/** The verbs the document declares on this path — not the seven HTTP has. */
|
|
43
|
-
type ApiMethod<P extends ApiPath> = {
|
|
44
|
-
[M in Verb$1]: M extends keyof paths[P] ? paths[P][M] extends {
|
|
45
|
-
responses: unknown;
|
|
46
|
-
} ? M : never : never;
|
|
47
|
-
}[Verb$1];
|
|
48
|
-
type Operation<P extends ApiPath, M extends ApiMethod<P>> = M extends keyof paths[P] ? paths[P][M] : never;
|
|
49
|
-
type JsonBody<R> = R extends {
|
|
50
|
-
content: {
|
|
51
|
-
'application/json': infer B;
|
|
52
|
-
};
|
|
53
|
-
} ? B : never;
|
|
54
|
-
/**
|
|
55
|
-
* The success body the document declares, preferring 200 where a route serves
|
|
56
|
-
* both. A route with neither — `kind: 'empty'`, which serves 204 — resolves to
|
|
57
|
-
* `never`, and `readPayload` cannot be called on it.
|
|
58
|
-
*/
|
|
59
|
-
type ApiSuccessBody<P extends ApiPath, M extends ApiMethod<P>> = Operation<P, M> extends {
|
|
60
|
-
responses: infer R;
|
|
61
|
-
} ? 200 extends keyof R ? JsonBody<R[200]> : 201 extends keyof R ? JsonBody<R[201]> : never : never;
|
|
62
|
-
/**
|
|
63
|
-
* The document's success body with the payload typed as the caller's `T`.
|
|
64
|
-
*
|
|
65
|
-
* The array arm is tested **first** on purpose: `{ data: unknown[] }` also
|
|
66
|
-
* satisfies `{ data: unknown }`, so the object arm would swallow every
|
|
67
|
-
* collection and hand a list route's caller a single entity — which is the
|
|
68
|
-
* exact defect class (`ContentClient.children` reading `.data.items` from an
|
|
69
|
-
* object route) that this phase makes unrepresentable.
|
|
70
|
-
*/
|
|
71
|
-
type Wire<P extends ApiPath, M extends ApiMethod<P>, T> = ApiSuccessBody<P, M> extends {
|
|
72
|
-
data: unknown[];
|
|
73
|
-
} ? Omit<ApiSuccessBody<P, M>, 'data'> & {
|
|
74
|
-
data: T[];
|
|
75
|
-
} : ApiSuccessBody<P, M> extends {
|
|
76
|
-
data: unknown;
|
|
77
|
-
} ? Omit<ApiSuccessBody<P, M>, 'data'> & {
|
|
78
|
-
data: T;
|
|
79
|
-
} : ApiSuccessBody<P, M>;
|
|
80
|
-
/**
|
|
81
|
-
* The path parameters the document declares for this operation, or `never`
|
|
82
|
-
* where it declares none.
|
|
83
|
-
*
|
|
84
|
-
* `never` rather than `{}`: a route with no segments must **forbid** a `path`
|
|
85
|
-
* argument, not merely tolerate an empty one, and `keyof Record<string, never>`
|
|
86
|
-
* is `string`, so an empty-object encoding cannot be told apart from a real
|
|
87
|
-
* one at the type level.
|
|
88
|
-
*/
|
|
89
|
-
type PathParamsOf<P extends ApiPath, M extends ApiMethod<P>> = Operation<P, M> extends {
|
|
90
|
-
parameters: {
|
|
91
|
-
path?: infer X;
|
|
92
|
-
};
|
|
93
|
-
} ? [X] extends [undefined] ? never : NonNullable<X> : never;
|
|
94
|
-
/**
|
|
95
|
-
* The query parameters the document declares for this operation, or `never` where it declares
|
|
96
|
-
* none (REL-687).
|
|
97
|
-
*
|
|
98
|
-
* The service declares them beside each route — a query DTO's whitelisted properties, the names a
|
|
99
|
-
* handler reads, `?_fresh` on a read the edge keeps — and `apps/services/api`'s
|
|
100
|
-
* `contract/query-parameters.spec.ts` holds the document to what each handler reads. So a name the
|
|
101
|
-
* API stops reading stops compiling here, and a name it refuses — `offset` on the entry list, which
|
|
102
|
-
* the SDK once sent on every `.offset()` and the API answered with a 400 — never compiled at all.
|
|
103
|
-
*
|
|
104
|
-
* `never` for the same reason {@link PathParamsOf} uses it: a route with no query must forbid one.
|
|
105
|
-
*/
|
|
106
|
-
type QueryOf<P extends ApiPath, M extends ApiMethod<P>> = Operation<P, M> extends {
|
|
107
|
-
parameters: {
|
|
108
|
-
query?: infer Q;
|
|
109
|
-
};
|
|
110
|
-
} ? [Q] extends [undefined] ? never : NonNullable<Q> : never;
|
|
111
|
-
/** What {@link matchRoute} recovers from a URL the client emitted. */
|
|
112
|
-
interface RouteMatch {
|
|
113
|
-
/** The document's path template — the value a tag translator switches on. */
|
|
114
|
-
path: ApiPath;
|
|
115
|
-
/** The template's `{name}` segments, decoded: the inverse of {@link fillPath}. */
|
|
116
|
-
params: Record<string, string>;
|
|
117
|
-
/** The query string; a key that appears more than once comes back as an array. */
|
|
118
|
-
query: Record<string, string | string[]>;
|
|
119
|
-
}
|
|
120
|
-
interface MatchRouteOptions {
|
|
121
|
-
/**
|
|
122
|
-
* The client's `baseUrl`, when it carries a path prefix of its own
|
|
123
|
-
* (`https://example.com/relyio`). Its path is removed before the template is
|
|
124
|
-
* matched. Unneeded for the default `https://api.relyio.com`.
|
|
125
|
-
*/
|
|
126
|
-
baseUrl?: string;
|
|
127
|
-
}
|
|
128
|
-
/**
|
|
129
|
-
* Recover the route a URL names: the inverse of {@link fillPath}, over the same
|
|
130
|
-
* committed document (`INV-API-CLIENT-IS-DERIVED`).
|
|
131
|
-
*
|
|
132
|
-
* `matchRoute(url).path` is an `ApiPath`, so anything that keys behaviour on a
|
|
133
|
-
* request — a cache-tag translator, say — switches on the document's templates
|
|
134
|
-
* and never on a route table of its own.
|
|
135
|
-
*
|
|
136
|
-
* Returns `null` for a URL no declared template matches — a presigned storage
|
|
137
|
-
* URL, or a path outside `baseUrl` — rather than a guess.
|
|
138
|
-
*/
|
|
139
|
-
declare function matchRoute(url: string | URL, options?: MatchRouteOptions): RouteMatch | null;
|
|
140
|
-
|
|
141
6
|
/**
|
|
142
7
|
* Dev-mode detection for `relyio dev` sandboxes — the SDK's I/O shell over `../dev-handshake`.
|
|
143
8
|
*
|
|
@@ -200,267 +65,6 @@ type ActiveSandbox = Extract<SandboxState, {
|
|
|
200
65
|
state: 'active';
|
|
201
66
|
}>;
|
|
202
67
|
|
|
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
|
-
|
|
278
|
-
/**
|
|
279
|
-
* What a call site supplies beside the route it named.
|
|
280
|
-
*
|
|
281
|
-
* `path` is required exactly when the document's template has segments, and
|
|
282
|
-
* forbidden when it does not — so a call that forgot to scope a request, or one
|
|
283
|
-
* that scoped a request the route does not scope, is a compile error rather
|
|
284
|
-
* than a URL with a literal `{id}` in it.
|
|
285
|
-
*/
|
|
286
|
-
type SendOptions<P extends ApiPath, M extends ApiMethod<P>> = {
|
|
287
|
-
/**
|
|
288
|
-
* Query string values: exactly the names the document declares for this route, at the types it
|
|
289
|
-
* declares them (`QueryOf`, REL-687). An undeclared name is a compile error, not a 400.
|
|
290
|
-
*/
|
|
291
|
-
query?: QueryOf<P, M>;
|
|
292
|
-
body?: unknown;
|
|
293
|
-
/** Request headers this call adds, e.g. `If-Match` / `Idempotency-Key` (API4). */
|
|
294
|
-
headers?: Record<string, string>;
|
|
295
|
-
signal?: AbortSignal;
|
|
296
|
-
timeout?: number;
|
|
297
|
-
} & ([PathParamsOf<P, M>] extends [never] ? {
|
|
298
|
-
path?: never;
|
|
299
|
-
} : {
|
|
300
|
-
path: PathParamsOf<P, M>;
|
|
301
|
-
});
|
|
302
|
-
/**
|
|
303
|
-
* Core HTTP client for the RelyIO SDK.
|
|
304
|
-
*
|
|
305
|
-
* `send` is **the** typed entry: it names a route by the path template the
|
|
306
|
-
* committed document declares, and returns that operation's body type with the
|
|
307
|
-
* payload typed as `T`. `readPayload` from `@relyio/api-contract/client` is
|
|
308
|
-
* then the one unwrap — there is no second spelling and no runtime test of
|
|
309
|
-
* which envelope arrived (`INV-API-CLIENT-IS-DERIVED`).
|
|
310
|
-
*
|
|
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.
|
|
315
|
-
*/
|
|
316
|
-
declare class HttpClient {
|
|
317
|
-
/** What every request reads off the configuration, derived by {@link configure} and nowhere else. */
|
|
318
|
-
protected connection: Connection;
|
|
319
|
-
/**
|
|
320
|
-
* Set on a view {@link withHeaders} made: the client every request is sent through, and the
|
|
321
|
-
* headers laid beneath each request's own. A view keeps no connection of its own that matters —
|
|
322
|
-
* everything it is asked to change, it changes on that client.
|
|
323
|
-
*/
|
|
324
|
-
protected view?: {
|
|
325
|
-
readonly client: ControlledHttpClient;
|
|
326
|
-
readonly headers: Readonly<Record<string, string>>;
|
|
327
|
-
};
|
|
328
|
-
constructor(config: MergedRelyIOConfig);
|
|
329
|
-
protected announce(): void;
|
|
330
|
-
/**
|
|
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.
|
|
335
|
-
*
|
|
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.
|
|
338
|
-
*/
|
|
339
|
-
static transfer(client: HttpClient, url: string, init: RequestInit): Promise<Response>;
|
|
340
|
-
/**
|
|
341
|
-
* Call a route the committed document declares, and get back the body that
|
|
342
|
-
* document says it serves.
|
|
343
|
-
*/
|
|
344
|
-
send<P extends ApiPath, M extends ApiMethod<P>, T = unknown>(path: P, method: M, options: SendOptions<P, M>): Promise<ApiResponse<Wire<P, M, T>>>;
|
|
345
|
-
/**
|
|
346
|
-
* Call a route and return its payload — `send` plus the one unwrap, which is
|
|
347
|
-
* what all but a handful of call sites want.
|
|
348
|
-
*/
|
|
349
|
-
fetchPayload<P extends ApiPath, M extends ApiMethod<P>, T = unknown>(path: P, method: M, options: SendOptions<P, M>): Promise<Wire<P, M, T> extends {
|
|
350
|
-
data: unknown;
|
|
351
|
-
} ? Wire<P, M, T>['data'] : never>;
|
|
352
|
-
/**
|
|
353
|
-
* Make an HTTP request, retrying only where a retry is safe.
|
|
354
|
-
*
|
|
355
|
-
* The headers are merged **once**, before the first attempt, and every attempt
|
|
356
|
-
* sends that same object. That is what makes a minted `Idempotency-Key` stable
|
|
357
|
-
* across the retries of one logical write: the service sees one key and
|
|
358
|
-
* answers the replay from the original outcome instead of applying it twice.
|
|
359
|
-
*
|
|
360
|
-
* The loop always makes one attempt. The incumbent's `while (attempt <
|
|
361
|
-
* maxAttempts)` made none at `retryAttempts: 0` — a value the config validator
|
|
362
|
-
* then accepted, and now refuses — and then dereferenced an unassigned
|
|
363
|
-
* `lastError`. `retryAttempts` is the most attempts, the first included; an
|
|
364
|
-
* `HttpClient` constructed directly is not validated, so the first attempt
|
|
365
|
-
* stays unconditional.
|
|
366
|
-
*
|
|
367
|
-
* A request that would carry no `X-API-Key` makes none: it rejects with
|
|
368
|
-
* `MissingApiKeyError` before `fetch` is called, is not retried, and names
|
|
369
|
-
* `apiKey`. This is where a client built without a key learns it — the
|
|
370
|
-
* constructor accepts one so that a module-scope client can be evaluated by a
|
|
371
|
-
* build that holds no key (REL-1120) — and so does one whose `setApiKey` was
|
|
372
|
-
* given none.
|
|
373
|
-
*/
|
|
374
|
-
private request;
|
|
375
|
-
/**
|
|
376
|
-
* One attempt.
|
|
377
|
-
*
|
|
378
|
-
* The caller's `signal` and the timeout both end it, through one controller.
|
|
379
|
-
* The incumbent handed `fetch` the caller's signal **instead of** its own, so a
|
|
380
|
-
* request that passed a signal had no timeout at all — and a caller abort then
|
|
381
|
-
* surfaced as `Request timed out`. `timedOut` is what tells the two apart: a
|
|
382
|
-
* timeout is a `TimeoutError`, a caller abort is the platform's `AbortError`,
|
|
383
|
-
* rethrown as it came.
|
|
384
|
-
*/
|
|
385
|
-
private makeRequest;
|
|
386
|
-
/**
|
|
387
|
-
* The headers without those a browser controls itself, when this is a browser; unchanged when it
|
|
388
|
-
* is not.
|
|
389
|
-
*
|
|
390
|
-
* A name is matched without regard to case (RFC 9110 §5.1), because a browser refuses `Origin`
|
|
391
|
-
* whatever case a page spells it in. This matched only the all-lowercase and all-uppercase
|
|
392
|
-
* spellings, so `Origin` and `User-Agent` — how people write them — reached `fetch` (REL-1409).
|
|
393
|
-
*/
|
|
394
|
-
private filterHeadersForBrowser;
|
|
395
|
-
/**
|
|
396
|
-
* Prepare request body based on content type and environment
|
|
397
|
-
*/
|
|
398
|
-
private prepareRequestBody;
|
|
399
|
-
private parseResponse;
|
|
400
|
-
private resolveUrl;
|
|
401
|
-
private mergeRequestConfig;
|
|
402
|
-
private buildQueryString;
|
|
403
|
-
private headersToObject;
|
|
404
|
-
private log;
|
|
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
|
-
}
|
|
463
|
-
|
|
464
68
|
/**
|
|
465
69
|
* API4's two request headers, as the SDK's writes send them.
|
|
466
70
|
*
|
|
@@ -1049,7 +653,10 @@ interface CreateEntryOptions extends EntryPlacement, RetryableWriteOptions {
|
|
|
1049
653
|
*/
|
|
1050
654
|
declare class ContentClient<T extends BaseContent = BaseContent, R extends Reading = UntypedReading<T>> extends EntryHandle<T, R, RevisedContent<T>, EntryPlacement> {
|
|
1051
655
|
/**
|
|
1052
|
-
* Create a new content entry.
|
|
656
|
+
* Create a new content entry, published. The answer's `_metadata.warnings` lists each reference
|
|
657
|
+
* the content type declares `weak` that the create made live while the entry it points at is
|
|
658
|
+
* unpublished (`REFERENCE_NOT_PUBLISHED`) — `[]` when there are none; the create is never refused
|
|
659
|
+
* for them.
|
|
1053
660
|
*
|
|
1054
661
|
* `locale` defaults to the client's own, and `dataset` to the client's (`client.with({ dataset })`
|
|
1055
662
|
* sets it for every call).
|
|
@@ -1059,7 +666,7 @@ declare class ContentClient<T extends BaseContent = BaseContent, R extends Readi
|
|
|
1059
666
|
* const post = await relyio.content('post').create({ title: 'Hello' }, { slug: 'hello' })
|
|
1060
667
|
* ```
|
|
1061
668
|
*/
|
|
1062
|
-
create(data: CreateInput<T>, options?: CreateEntryOptions): Promise<T
|
|
669
|
+
create(data: CreateInput<T>, options?: CreateEntryOptions): Promise<CreatedContent<T>>;
|
|
1063
670
|
/**
|
|
1064
671
|
* Get version history for one locale of an entry.
|
|
1065
672
|
*
|
|
@@ -1678,7 +1285,7 @@ type DocumentVersionRow = components['schemas']['DocumentVersionRow'];
|
|
|
1678
1285
|
* Every call is in the locale it names, and otherwise in the client's own as it is when the call is
|
|
1679
1286
|
* made; a write of a document you read writes the locale it was read in.
|
|
1680
1287
|
*/
|
|
1681
|
-
declare abstract class DocumentHandle<T> {
|
|
1288
|
+
declare abstract class DocumentHandle<T, W = T> {
|
|
1682
1289
|
protected readonly httpClient: HttpClient;
|
|
1683
1290
|
protected readonly name: string;
|
|
1684
1291
|
/** The client's locale, asked on every call rather than copied when this handle was taken. */
|
|
@@ -1695,12 +1302,12 @@ declare abstract class DocumentHandle<T> {
|
|
|
1695
1302
|
* read, the write is refused with `ResourceConflictError` naming both versions: re-read it with
|
|
1696
1303
|
* `fresh: true` and retry.
|
|
1697
1304
|
*/
|
|
1698
|
-
update(read: ReadEntry, data: DocumentFields<T>, options?: RetryableWriteOptions): Promise<
|
|
1305
|
+
update(read: ReadEntry, data: DocumentFields<T>, options?: RetryableWriteOptions): Promise<W>;
|
|
1699
1306
|
/**
|
|
1700
1307
|
* Write the document with no version check, on purpose, in `options.locale` or the client's own —
|
|
1701
1308
|
* creating it, when nobody has yet.
|
|
1702
1309
|
*/
|
|
1703
|
-
update(data: DocumentFields<T>, options?: DocumentWriteOptions): Promise<
|
|
1310
|
+
update(data: DocumentFields<T>, options?: DocumentWriteOptions): Promise<W>;
|
|
1704
1311
|
/**
|
|
1705
1312
|
* Version history for one locale of the document.
|
|
1706
1313
|
*
|
|
@@ -1720,8 +1327,8 @@ declare abstract class DocumentHandle<T> {
|
|
|
1720
1327
|
* `context.resourceType` naming which (REL-2409 Q12).
|
|
1721
1328
|
*/
|
|
1722
1329
|
version(options: VersionOptions): Promise<DocumentVersion<T>>;
|
|
1723
|
-
/** `PATCH` the document's route with this write. */
|
|
1724
|
-
protected abstract patch(write: DocumentWrite<T>, options?: RetryableWriteOptions): Promise<
|
|
1330
|
+
/** `PATCH` the document's route with this write, answering what the route answers a write. */
|
|
1331
|
+
protected abstract patch(write: DocumentWrite<T>, options?: RetryableWriteOptions): Promise<W>;
|
|
1725
1332
|
/** `GET` the document's version history route. */
|
|
1726
1333
|
protected abstract readVersions(query: {
|
|
1727
1334
|
limit: number;
|
|
@@ -1763,7 +1370,7 @@ declare abstract class DocumentHandle<T> {
|
|
|
1763
1370
|
* if (homepage) await client.singleton('homepage').update(homepage, { title: 'Welcome' })
|
|
1764
1371
|
* ```
|
|
1765
1372
|
*/
|
|
1766
|
-
declare class SingletonClient<T = BaseSingleton, R extends Reading = UntypedReading<T>> extends DocumentHandle<T
|
|
1373
|
+
declare class SingletonClient<T = BaseSingleton, R extends Reading = UntypedReading<T>> extends DocumentHandle<T, WrittenSingleton<T>> {
|
|
1767
1374
|
/**
|
|
1768
1375
|
* The singleton, or `null` when nobody has written it yet (REL-2419, REL-2409 Q18).
|
|
1769
1376
|
*
|
|
@@ -1781,8 +1388,11 @@ declare class SingletonClient<T = BaseSingleton, R extends Reading = UntypedRead
|
|
|
1781
1388
|
* ```
|
|
1782
1389
|
*/
|
|
1783
1390
|
get<const P extends readonly string[] = []>(options?: DocumentReadOptions<R, P>): Promise<ReadWith<R, P[number]> | null>;
|
|
1784
|
-
/**
|
|
1785
|
-
|
|
1391
|
+
/**
|
|
1392
|
+
* The API publishes on PATCH: there is no separate publish route. The answer's `_metadata` also
|
|
1393
|
+
* lists the links the write left pointing nowhere and its `warnings` (REL-3097).
|
|
1394
|
+
*/
|
|
1395
|
+
protected patch(write: DocumentWrite<T>, options?: RetryableWriteOptions): Promise<WrittenSingleton<T>>;
|
|
1786
1396
|
protected readVersions(query: {
|
|
1787
1397
|
limit: number;
|
|
1788
1398
|
locale?: string;
|
|
@@ -1818,7 +1428,7 @@ declare class SingletonClient<T = BaseSingleton, R extends Reading = UntypedRead
|
|
|
1818
1428
|
* await client.settings('email-config').update(emailConfig, { fromName: 'RelyIO' })
|
|
1819
1429
|
* ```
|
|
1820
1430
|
*/
|
|
1821
|
-
declare class SettingsClient<T = BaseSettingsGroup, R extends Reading = UntypedReading<T>> extends DocumentHandle<T
|
|
1431
|
+
declare class SettingsClient<T = BaseSettingsGroup, R extends Reading = UntypedReading<T>> extends DocumentHandle<T, WrittenSettingsGroup<T>> {
|
|
1822
1432
|
/**
|
|
1823
1433
|
* The settings group (REL-2419, REL-2409 Q18).
|
|
1824
1434
|
*
|
|
@@ -1843,16 +1453,16 @@ declare class SettingsClient<T = BaseSettingsGroup, R extends Reading = UntypedR
|
|
|
1843
1453
|
* in the locale it was read in (REL-2419) — refused with `ResourceConflictError` if it changed
|
|
1844
1454
|
* since the read.
|
|
1845
1455
|
*/
|
|
1846
|
-
reset(read: ReadEntry, options?: RetryableWriteOptions): Promise<T
|
|
1456
|
+
reset(read: ReadEntry, options?: RetryableWriteOptions): Promise<WrittenSettingsGroup<T>>;
|
|
1847
1457
|
/**
|
|
1848
1458
|
* Reset the group to its default values with no version check, in `options.locale` or the
|
|
1849
1459
|
* client's own. The route reads its locale from `?locale=` and takes no body, so that is where it
|
|
1850
1460
|
* is sent.
|
|
1851
1461
|
*/
|
|
1852
|
-
reset(options?: DocumentWriteOptions): Promise<T
|
|
1462
|
+
reset(options?: DocumentWriteOptions): Promise<WrittenSettingsGroup<T>>;
|
|
1853
1463
|
/** The group's default values, as the schema declares them. */
|
|
1854
1464
|
getDefaults(): Promise<T>;
|
|
1855
|
-
protected patch(write: DocumentWrite<T>, options?: RetryableWriteOptions): Promise<T
|
|
1465
|
+
protected patch(write: DocumentWrite<T>, options?: RetryableWriteOptions): Promise<WrittenSettingsGroup<T>>;
|
|
1856
1466
|
protected readVersions(query: {
|
|
1857
1467
|
limit: number;
|
|
1858
1468
|
locale?: string;
|
|
@@ -1865,39 +1475,42 @@ declare class SettingsClient<T = BaseSettingsGroup, R extends Reading = UntypedR
|
|
|
1865
1475
|
}
|
|
1866
1476
|
|
|
1867
1477
|
/**
|
|
1868
|
-
*
|
|
1869
|
-
*
|
|
1478
|
+
* The project's Functions over the Content API (spec 2, REL-3821): `relyio.functions.checkout(input)`
|
|
1479
|
+
* runs the Function `checkout` that the key's Branch runs, on the key's Dataset, and answers its
|
|
1480
|
+
* output.
|
|
1870
1481
|
*
|
|
1871
|
-
*
|
|
1872
|
-
*
|
|
1873
|
-
*
|
|
1482
|
+
* Call it from your server with a secret key: a publishable key is refused
|
|
1483
|
+
* (`PublishableKeyRefusedError`), and a read-only key runs only a Function whose reach writes
|
|
1484
|
+
* nothing (`ReadOnlyKeyError`). A run whose code threw or was ended at a limit throws
|
|
1485
|
+
* `FunctionRunFailedError`, and one that outlived the service's five-minute wait
|
|
1486
|
+
* `FunctionRunTimedOutError` — each naming the run (`runId`), whose record and console output Manage
|
|
1487
|
+
* serves. A call is never retried: a Function may write, and a second call would be a second run.
|
|
1874
1488
|
*/
|
|
1875
|
-
|
|
1876
|
-
/**
|
|
1877
|
-
|
|
1878
|
-
|
|
1879
|
-
|
|
1880
|
-
|
|
1881
|
-
|
|
1882
|
-
|
|
1883
|
-
|
|
1884
|
-
|
|
1885
|
-
|
|
1886
|
-
|
|
1887
|
-
|
|
1888
|
-
|
|
1889
|
-
|
|
1890
|
-
* schema. The pattern is TanStack Router's. It is type-level only: nothing at runtime reads it.
|
|
1891
|
-
*/
|
|
1892
|
-
interface Register {
|
|
1489
|
+
|
|
1490
|
+
/** What a Function call takes beside its input. */
|
|
1491
|
+
interface FunctionCallOptions {
|
|
1492
|
+
/** The dataset, by id or name, over the client's. */
|
|
1493
|
+
dataset?: string;
|
|
1494
|
+
signal?: AbortSignal;
|
|
1495
|
+
/** How long to wait, in milliseconds. {@link FUNCTION_CALL_TIMEOUT_MS} when left out. */
|
|
1496
|
+
timeout?: number;
|
|
1497
|
+
/**
|
|
1498
|
+
* A key naming this call (REL-3822): every Record batch the run sends is keyed by it, so the same
|
|
1499
|
+
* key sent again — a shopper's double click, your own retry — runs the Function again but writes
|
|
1500
|
+
* nothing the first call wrote, answering what it answered. Kept 24 hours. None is minted: a call
|
|
1501
|
+
* is never retried by this client.
|
|
1502
|
+
*/
|
|
1503
|
+
idempotencyKey?: string;
|
|
1893
1504
|
}
|
|
1505
|
+
/** One Function, called: its input, as its input Fields declare it, and its output. */
|
|
1506
|
+
type FunctionCall = (input?: Record<string, unknown>, options?: FunctionCallOptions) => Promise<unknown>;
|
|
1894
1507
|
/**
|
|
1895
|
-
*
|
|
1896
|
-
*
|
|
1508
|
+
* `relyio.functions`: every Function the key's Branch runs, by name. A name the Branch does not run
|
|
1509
|
+
* is refused by the service (`ResourceNotFoundError`), not here.
|
|
1897
1510
|
*/
|
|
1898
|
-
type
|
|
1899
|
-
|
|
1900
|
-
}
|
|
1511
|
+
type FunctionsAccessor = {
|
|
1512
|
+
readonly [name: string]: FunctionCall;
|
|
1513
|
+
};
|
|
1901
1514
|
|
|
1902
1515
|
/**
|
|
1903
1516
|
* What the search family's routes answer, read from the committed document, and what a search over
|
|
@@ -2855,6 +2468,21 @@ interface TypedClientConfig<TSchema extends AnySchemaDefinition | undefined = un
|
|
|
2855
2468
|
* const batch = await relyio.batch([{ create: 'product', data: { title: 'New' } }])
|
|
2856
2469
|
* ```
|
|
2857
2470
|
*/
|
|
2471
|
+
/** The Record type names a client's schema declares, or any string without one. */
|
|
2472
|
+
type RecordTypeNameOf<TSchema> = TSchema extends AnySchemaDefinition ? SchemaRecordTypeNames<TSchema> : string;
|
|
2473
|
+
/**
|
|
2474
|
+
* `relyio.records`: called with a Record type, that type's Records; `.batch([...])`, a list of
|
|
2475
|
+
* Record operations across types in one transaction, all or none (REL-3774).
|
|
2476
|
+
*/
|
|
2477
|
+
interface RecordsAccessor<TSchema extends AnySchemaDefinition | undefined> {
|
|
2478
|
+
<K extends RecordTypeNameOf<TSchema>>(recordType: K): TSchema extends AnySchemaDefinition ? RecordsClient<InferRecordType<NonNullable<TSchema['recordTypes']>[K & keyof NonNullable<TSchema['recordTypes']>]>, RecordWriteFieldsOf<NonNullable<TSchema['recordTypes']>[K & keyof NonNullable<TSchema['recordTypes']>]>, RecordUpdateFieldsOf<NonNullable<TSchema['recordTypes']>[K & keyof NonNullable<TSchema['recordTypes']>]>> : RecordsClient<BaseRecord>;
|
|
2479
|
+
/**
|
|
2480
|
+
* Run Record operations — `create`, `update`, `delete`, `increment`, `decrement`, across Record
|
|
2481
|
+
* types — in one transaction: every one lands, or none does. A refused one rolls the batch back
|
|
2482
|
+
* and throws naming it (`refusedOperationOf(error)` reads its index).
|
|
2483
|
+
*/
|
|
2484
|
+
batch(operations: ReadonlyArray<RecordBatchOperation<RecordTypeNameOf<TSchema>>>, options?: RecordBatchOptions): Promise<RecordBatchResult>;
|
|
2485
|
+
}
|
|
2858
2486
|
declare class TypedRelyIOClient<TSchema extends AnySchemaDefinition | undefined = undefined> {
|
|
2859
2487
|
/**
|
|
2860
2488
|
* The one HTTP client every sub-client sends through. `updateConfig()` and `setApiKey()` change it
|
|
@@ -2930,6 +2558,39 @@ declare class TypedRelyIOClient<TSchema extends AnySchemaDefinition | undefined
|
|
|
2930
2558
|
* ```
|
|
2931
2559
|
*/
|
|
2932
2560
|
content<K extends TSchema extends AnySchemaDefinition ? SchemaContentTypeNames<TSchema> : string>(contentType: K): TSchema extends AnySchemaDefinition ? ContentClient<InferContentType<TSchema['contentTypes'][K & keyof TSchema['contentTypes']], TSchema>, ContentReading<TSchema['contentTypes'][K & keyof TSchema['contentTypes']], TSchema>> : ContentClient<BaseContent>;
|
|
2561
|
+
/**
|
|
2562
|
+
* The Records of one Record type (spec 1, REL-3771): `create`, `list`, `get`, `update`, `delete`.
|
|
2563
|
+
* Type-safe when a schema is provided — the names autocomplete its `recordTypes` and the fields
|
|
2564
|
+
* are the type's. `relyio.records.batch([...])` writes Records of any types in one transaction,
|
|
2565
|
+
* all or none (REL-3774).
|
|
2566
|
+
*
|
|
2567
|
+
* A Record is an app's data, written by your server with a secret key and live the moment it
|
|
2568
|
+
* lands; a publishable key is refused on every Record route (`PUBLISHABLE_KEY_REFUSED`).
|
|
2569
|
+
*
|
|
2570
|
+
* @example
|
|
2571
|
+
* ```typescript
|
|
2572
|
+
* const order = await relyio.records('order').create({ shopperEmail: 'ada@example.com', total: 19 })
|
|
2573
|
+
* const { data: orders } = await relyio.records('order').list({ where: { status: 'paid' } })
|
|
2574
|
+
* await relyio.records.batch([
|
|
2575
|
+
* { op: 'decrement', type: 'inventory', where: { product: mugId }, field: 'available', by: 1 },
|
|
2576
|
+
* { op: 'create', type: 'order', fields: { shopperEmail: 'ada@example.com', total: 19 } },
|
|
2577
|
+
* ])
|
|
2578
|
+
* ```
|
|
2579
|
+
*/
|
|
2580
|
+
readonly records: RecordsAccessor<TSchema>;
|
|
2581
|
+
/**
|
|
2582
|
+
* The project's Functions, by name (spec 2, REL-3821): `relyio.functions.checkout({ cartId })`
|
|
2583
|
+
* runs the Function `checkout` that the key's Branch runs, on the key's Dataset, and answers its
|
|
2584
|
+
* output. Call it from your server with a secret key; a run that failed throws
|
|
2585
|
+
* `FunctionRunFailedError` and one past five minutes `FunctionRunTimedOutError`, each naming the
|
|
2586
|
+
* run. Never retried: a Function may write.
|
|
2587
|
+
*
|
|
2588
|
+
* @example
|
|
2589
|
+
* ```typescript
|
|
2590
|
+
* const { orderId } = (await relyio.functions.checkout({ cartId })) as { orderId: string }
|
|
2591
|
+
* ```
|
|
2592
|
+
*/
|
|
2593
|
+
readonly functions: FunctionsAccessor;
|
|
2933
2594
|
/**
|
|
2934
2595
|
* Get an asset client for a specific asset type.
|
|
2935
2596
|
*
|
|
@@ -3355,4 +3016,4 @@ declare function createClient<TSchema extends AnySchemaDefinition>(config: Typed
|
|
|
3355
3016
|
*/
|
|
3356
3017
|
type ClientSchema<T extends TypedRelyIOClient<AnySchemaDefinition>> = T extends TypedRelyIOClient<infer TSchema> ? TSchema : never;
|
|
3357
3018
|
|
|
3358
|
-
export { type
|
|
3019
|
+
export { type SortOption as $, type ActiveSandbox as A, type ChildrenListOptions as B, type Change as C, type DeployedLocale as D, type EntryPlacement as E, type FeedChange as F, type DocumentReadOptions as G, type Health as H, type EntryList as I, type FieldKey as J, type FreshOption as K, type LocaleCodeOf as L, type GetOptions as M, type ListAllOptions as N, type ListOptions as O, type Project as P, type LocaleOption as Q, type RecordsAccessor as R, type SandboxState as S, TypedRelyIOClient as T, type Paging as U, type VisitorRetry as V, type ChildEntry as W, type ChildrenRead as X, type ReadAs as Y, type WithChildren as Z, type ReadLocale as _, ChangesExpiredError as a, type ResolveUrlInput as a$, type VersionOptions as a0, type WrittenReadScope as a1, type WrittenSort as a2, type SearchResultItem as a3, type SearchHitMetadata as a4, type SearchResponse as a5, type AutocompleteSuggestion as a6, type AutocompleteResponse as a7, type SimilarResult as a8, type SimilarResponse as a9, type AggregateMetric as aA, type QueryMetadata as aB, type AdhocQuery as aC, type AdhocRecord as aD, type NamedQueryOptions as aE, type NamedQueryParams as aF, type QueryAggregate as aG, type QueryAnswer as aH, type QueryCall as aI, type QueryName as aJ, type QueryTypeName as aK, AssetClient as aL, AssetFileBuilder as aM, AssetUploadBuilder as aN, isAssetEntry as aO, type AssetVisibility as aP, type FileStatus as aQ, type FileBackend as aR, type AssetFileExtracted as aS, type FileStatusResult as aT, type AssetEntryResponse as aU, type AssetFileWhere as aV, type PopulatedAssetReference as aW, type PresignInput as aX, type PresignResult as aY, type ConfirmInput as aZ, type ConfirmResult as a_, type SearchTypeName as aa, type SearchEntry as ab, type AutocompleteOptions as ac, type SearchFacet as ad, type SearchFieldKey as ae, type SearchHighlight as af, type SearchOptions as ag, type SearchPage as ah, type SearchScope as ai, type SearchSelected as aj, type SearchSortOption as ak, type SearchWhere as al, type SimilarOptions as am, type BatchOperationResult as an, type BatchSummary as ao, type BatchResponse as ap, type BatchWrite as aq, type BatchWriteOptions as ar, type BatchBody as as, type BatchCreate as at, type BatchUpdate as au, type BatchReplace as av, type BatchDelete as aw, type BatchSingletonWrite as ax, type BatchTarget as ay, type BatchDeleteTarget as az, type ChangesExpiredReason as b, type ResolveUrlResult as b0, type CreateAssetOptions as b1, type AssetPlacement as b2, type UpdateAssetOptions as b3, type WaitUntilReadyOptions as b4, type MultipartCreateResult as b5, type MultipartPart as b6, type MultipartTarget as b7, type UploadProgress as b8, ResourceNotFoundError as b9, ResourceConflictError as ba, ResourceExpiredError as bb, isResourceNotFound as bc, isMissingEntry as bd, type FileErrorCode as be, type FileUploadErrorCode as bf, FileUploadError as bg, FileValidationError as bh, type FileValidationConstraints as bi, validateFile as bj, createClient as c, type TypedClientConfig as d, type ClientDefaults as e, type ClientSchema as f, type DeployedContentType as g, type ReadEntry as h, type RetryableWriteOptions as i, type ChangesHeadOptions as j, type ChangesOptions as k, LIVE_KEEPALIVE_INTERVAL_MS as l, LIVE_SOCKET_OPEN_TIMEOUT_MS as m, type LiveChangesOptions as n, ContentClient as o, type CreateEntryOptions as p, type EntryWriteOptions as q, SingletonClient as r, SettingsClient as s, type DocumentFields as t, type DocumentVersion as u, versionCheckOf as v, type DocumentVersionRow as w, type DocumentVersionsOptions as x, type DocumentWriteOptions as y, type ChildrenOptions as z };
|