@relyio/sdk 0.3.0 → 0.5.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 +109 -0
- package/dist/.tsbuildinfo +1 -1
- package/dist/{chunk-QIZOBT5F.js → chunk-5AZUUV5B.js} +349 -25
- package/dist/{chunk-54WP2PWG.cjs → chunk-CIRT6TVT.cjs} +350 -24
- package/dist/{chunk-HMVGXUGR.cjs → chunk-HAQELDZN.cjs} +2 -2
- package/dist/{chunk-LYRYCIX5.js → chunk-XY5KFEFY.js} +2 -2
- package/dist/client/index.cjs +3 -3
- package/dist/client/index.d.cts +4 -3
- package/dist/client/index.d.ts +4 -3
- package/dist/client/index.js +1 -1
- package/dist/{define-schema-BfXeR6K8.d.cts → define-schema-2xbHgtK-.d.cts} +8 -4
- package/dist/{define-schema-BD6HSPnG.d.ts → define-schema-DzYXk4HL.d.ts} +8 -4
- package/dist/{index-BDpar3FO.d.cts → index-BozPz4n1.d.cts} +320 -8
- package/dist/{index-ulOrcfPa.d.cts → index-C5mRBb6t.d.cts} +368 -11
- package/dist/{index-Dx01iwaf.d.ts → index-Dzo-upNS.d.ts} +320 -8
- package/dist/{index-DuEhsGdE.d.ts → index-mXUx2H99.d.ts} +368 -11
- package/dist/index.cjs +119 -66
- package/dist/index.d.cts +131 -46
- package/dist/index.d.ts +131 -46
- package/dist/index.js +44 -3
- package/dist/schema/index.cjs +35 -35
- package/dist/schema/index.d.cts +1 -1
- package/dist/schema/index.d.ts +1 -1
- package/dist/schema/index.js +1 -1
- package/dist/types/index.d.cts +1 -1
- package/dist/types/index.d.ts +1 -1
- package/package.json +3 -13
- package/dist/react/index.cjs +0 -4
- package/dist/react/index.d.cts +0 -2
- package/dist/react/index.d.ts +0 -2
- package/dist/react/index.js +0 -3
|
@@ -1,6 +1,69 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { a as SchemaDefinition, b as SchemaContentTypeNames, h as SchemaAssetTypeNames, M as InferAssetType, c as SchemaSingletonNames, t as InferSingleton, g as SchemaSettingsGroupNames, E as InferSettingsGroup, e as SchemaQueryNames, f as SchemaLocaleCodes } from './define-schema-
|
|
1
|
+
import { J as MergedRelyIOConfig, A as ApiPath, a as ApiMethod, K as PathParamsOf, t as ApiResponse, W as Wire, s as RequestConfig, B as BaseContent, d as WhereClause, f as SortOptions, g as ContentQueryResult, Q as QueryOptions, C as CreateInput, U as UpdateInput, S as SDKError, x as BaseValidationError, w as ValidationViolation, N as components, O as paths, R as RelyIOConfig } from './index-C5mRBb6t.cjs';
|
|
2
|
+
import { a as SchemaDefinition, b as SchemaContentTypeNames, h as SchemaAssetTypeNames, M as InferAssetType, c as SchemaSingletonNames, t as InferSingleton, g as SchemaSettingsGroupNames, E as InferSettingsGroup, e as SchemaQueryNames, f as SchemaLocaleCodes } from './define-schema-2xbHgtK-.cjs';
|
|
3
3
|
import { J as InferContentType } from './define-content-type-CBfnTWSS.cjs';
|
|
4
|
+
import { DevUnreadableReason } from './dev-handshake/index.cjs';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Dev-mode detection for `relyio dev` sandboxes — the SDK's I/O shell over `../dev-handshake`.
|
|
8
|
+
*
|
|
9
|
+
* Every rule about the handshake — the path, the env names, the required fields, the deadline —
|
|
10
|
+
* lives in `@relyio/sdk/dev-handshake`, which `relyio dev` imports too. What is left here is the
|
|
11
|
+
* part that is genuinely the SDK's: reading env and walking the filesystem from the cwd, both of
|
|
12
|
+
* which have to happen without a static `node:*` import so the module stays browser-safe.
|
|
13
|
+
*
|
|
14
|
+
* Node access goes through `process.getBuiltinModule` (Node ≥ 20.16 / 22, and the platform targets
|
|
15
|
+
* Node 24), which is absent in browsers and edge runtimes — so the resolver is inert everywhere it
|
|
16
|
+
* should be, and a bundler never has to shim `fs`.
|
|
17
|
+
*
|
|
18
|
+
* **Order: env, then file.** The wrapped-child env is the primary carrier and wins. Before REL-647
|
|
19
|
+
* it won *unconditionally*, because it had no deadline to lose on; it now goes through the same
|
|
20
|
+
* rule the file does.
|
|
21
|
+
*/
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* What the handshake says about the sandbox, as the preview toolbar displays it
|
|
25
|
+
* (`sdk-surfaces-spec.md` decision 22). `TypedRelyIOClient.sandbox` returns it.
|
|
26
|
+
*
|
|
27
|
+
* **Plain data, on purpose.** In Next the toolbar is rendered from a server layout, and a client
|
|
28
|
+
* cannot cross the RSC boundary — while the browser cannot read the handshake at all, because this
|
|
29
|
+
* module is inert without `process.getBuiltinModule`. So the server-created client's `sandbox` is the
|
|
30
|
+
* prop the toolbar is handed, and it has to survive `JSON` unchanged: strings and `null`, dates as
|
|
31
|
+
* the ISO strings the handshake carried, no class instances.
|
|
32
|
+
*
|
|
33
|
+
* **No key.** The handshake also carries the sandbox's preview key; that is the client's credential,
|
|
34
|
+
* held beside this value in {@link DevResolution} and never inside it, so handing the state around
|
|
35
|
+
* does not hand the key with it.
|
|
36
|
+
*
|
|
37
|
+
* - `active` — the client targets the sandbox. `branchId` is `null` from the env carrier, which names
|
|
38
|
+
* no branch; only `.relyio/dev.json` does. `expiresAt` is `null` for an unbounded sandbox.
|
|
39
|
+
* - `expired` / `unreadable` — a handshake was found and refused; the client targets the configured
|
|
40
|
+
* dataset and key, and `mergeConfig` has said so on the console.
|
|
41
|
+
* - `absent` — no handshake on either carrier. This is also what a browser or edge runtime reads,
|
|
42
|
+
* since neither can see the env or the file.
|
|
43
|
+
* - `disabled` — detection did not run: `dev: false` was passed, or `NODE_ENV === 'production'`
|
|
44
|
+
* and `dev: true` was not.
|
|
45
|
+
*/
|
|
46
|
+
type SandboxState = {
|
|
47
|
+
state: 'active';
|
|
48
|
+
datasetId: string;
|
|
49
|
+
branchId: string | null;
|
|
50
|
+
expiresAt: string | null;
|
|
51
|
+
source: 'env' | 'file';
|
|
52
|
+
} | {
|
|
53
|
+
state: 'expired';
|
|
54
|
+
expiredAt: string;
|
|
55
|
+
} | {
|
|
56
|
+
state: 'unreadable';
|
|
57
|
+
reason: DevUnreadableReason;
|
|
58
|
+
} | {
|
|
59
|
+
state: 'absent';
|
|
60
|
+
} | {
|
|
61
|
+
state: 'disabled';
|
|
62
|
+
};
|
|
63
|
+
/** The sandbox the client targets, once a carrier has been accepted. */
|
|
64
|
+
type ActiveSandbox = Extract<SandboxState, {
|
|
65
|
+
state: 'active';
|
|
66
|
+
}>;
|
|
4
67
|
|
|
5
68
|
/**
|
|
6
69
|
* What a call site supplies beside the route it named.
|
|
@@ -109,6 +172,16 @@ declare class HttpClient {
|
|
|
109
172
|
* Get current base URL
|
|
110
173
|
*/
|
|
111
174
|
getBaseUrl(): string;
|
|
175
|
+
/**
|
|
176
|
+
* One attempt.
|
|
177
|
+
*
|
|
178
|
+
* The caller's `signal` and the timeout both end it, through one controller.
|
|
179
|
+
* The incumbent handed `fetch` the caller's signal **instead of** its own, so a
|
|
180
|
+
* request that passed a signal had no timeout at all — and a caller abort then
|
|
181
|
+
* surfaced as `Request timed out`. `timedOut` is what tells the two apart: a
|
|
182
|
+
* timeout is a `TimeoutError`, a caller abort is the platform's `AbortError`,
|
|
183
|
+
* rethrown as it came.
|
|
184
|
+
*/
|
|
112
185
|
private makeRequest;
|
|
113
186
|
/**
|
|
114
187
|
* Filter headers that browsers don't allow to be set manually
|
|
@@ -123,6 +196,7 @@ declare class HttpClient {
|
|
|
123
196
|
private mergeRequestConfig;
|
|
124
197
|
private buildQueryString;
|
|
125
198
|
private headersToObject;
|
|
199
|
+
/** A backoff the caller's abort cuts short; the next attempt then refuses to send. */
|
|
126
200
|
private sleep;
|
|
127
201
|
private log;
|
|
128
202
|
}
|
|
@@ -2386,11 +2460,175 @@ declare class AdhocQueryClient {
|
|
|
2386
2460
|
}
|
|
2387
2461
|
|
|
2388
2462
|
/**
|
|
2389
|
-
*
|
|
2390
|
-
*
|
|
2391
|
-
*
|
|
2463
|
+
* Content and resource errors.
|
|
2464
|
+
*
|
|
2465
|
+
* `ContentTypeNotFoundError` and `ContentNotFoundError` were deleted at API5.
|
|
2466
|
+
* The mapper reached them by sniffing `CONTENT_TYPE_NOT_FOUND` and
|
|
2467
|
+
* `CONTENT_NOT_FOUND`, neither of which is in the closed vocabulary, so neither
|
|
2468
|
+
* class was reachable. Both cases are `RESOURCE_NOT_FOUND`, whose declared
|
|
2469
|
+
* `details` are `{ kind, id? }` — the same two facts, from the one code a route
|
|
2470
|
+
* can actually declare.
|
|
2471
|
+
*/
|
|
2472
|
+
declare class ResourceNotFoundError extends SDKError {
|
|
2473
|
+
readonly code = "RESOURCE_NOT_FOUND";
|
|
2474
|
+
readonly retryable = false;
|
|
2475
|
+
constructor(message?: string, statusCode?: number, cause?: Error, context?: Record<string, unknown>);
|
|
2476
|
+
getUserMessage(): string;
|
|
2477
|
+
}
|
|
2478
|
+
declare class ResourceConflictError extends SDKError {
|
|
2479
|
+
readonly code = "RESOURCE_CONFLICT";
|
|
2480
|
+
readonly retryable = false;
|
|
2481
|
+
constructor(message?: string, statusCode?: number, cause?: Error, context?: Record<string, unknown>);
|
|
2482
|
+
getUserMessage(): string;
|
|
2483
|
+
}
|
|
2484
|
+
declare class ResourceExpiredError extends SDKError {
|
|
2485
|
+
readonly code = "RESOURCE_EXPIRED";
|
|
2486
|
+
readonly retryable = false;
|
|
2487
|
+
constructor(message?: string, statusCode?: number, cause?: Error, context?: Record<string, unknown>);
|
|
2488
|
+
getUserMessage(): string;
|
|
2489
|
+
}
|
|
2490
|
+
/**
|
|
2491
|
+
* "Did the service say this resource does not exist?"
|
|
2492
|
+
*
|
|
2493
|
+
* Reads the **code**, not the status. Four contract codes are 4xx on a read and
|
|
2494
|
+
* only one of them means "not there"; the incumbent checked `statusCode === 404`
|
|
2495
|
+
* on the thrown value, and a second arm duck-typed a plain object for the same
|
|
2496
|
+
* number so a hand-written test double would pass. Both are the branch
|
|
2497
|
+
* `INV-API-CLIENT-IS-DERIVED` forbids where a code exists — and the second one
|
|
2498
|
+
* only existed because the tests faked the boundary (rule 20). They now stub
|
|
2499
|
+
* `fetch`, so the double is gone with the branch.
|
|
2500
|
+
*/
|
|
2501
|
+
declare function isResourceNotFound(error: unknown): boolean;
|
|
2502
|
+
|
|
2503
|
+
/**
|
|
2504
|
+
* `relyio.changes()` — the changes feed as a typed long-poll iterator
|
|
2505
|
+
* (`sdk-surfaces-spec.md` decisions 16–18).
|
|
2506
|
+
*
|
|
2507
|
+
* Long-poll only, on purpose. `GET /v1/changes` is an ordinary cursor-paged
|
|
2508
|
+
* collection the committed document declares, so each poll is one `send` over
|
|
2509
|
+
* the one HTTP client (`INV-SS-ONE-CORE`, `INV-API-CLIENT-IS-DERIVED`). The SSE
|
|
2510
|
+
* branch the route also serves would be a second transport path inside that
|
|
2511
|
+
* client, and `parseResponse` buffers a whole body; it stays for `EventSource`
|
|
2512
|
+
* and curl consumers.
|
|
2513
|
+
*/
|
|
2514
|
+
|
|
2515
|
+
type PollChanges = paths['/v1/changes']['get'];
|
|
2516
|
+
/**
|
|
2517
|
+
* The 200 body the document declares, read from its `application/json` content
|
|
2518
|
+
* **by name**. The route also negotiates `text/event-stream`; naming the JSON
|
|
2519
|
+
* content is what keeps that alternate from changing this type when the
|
|
2520
|
+
* document gains it.
|
|
2521
|
+
*/
|
|
2522
|
+
type ChangesPageBody = PollChanges['responses'][200]['content']['application/json'];
|
|
2523
|
+
/**
|
|
2524
|
+
* One change, as the committed document describes an item of the feed's `data`
|
|
2525
|
+
* (`INV-SS-CHANGE-IS-IDS`: ids, content type, locale, kind and cursor — never a
|
|
2526
|
+
* document).
|
|
2527
|
+
*
|
|
2528
|
+
* Read from the document, never written here: the api's route row names the
|
|
2529
|
+
* `Change` component schema, and a change to it reaches this type when the
|
|
2530
|
+
* document is regenerated. `changes.types.ts` holds it equal to the document's
|
|
2531
|
+
* item, and fails if it is ever `unknown` again.
|
|
2532
|
+
*/
|
|
2533
|
+
type Change = ChangesPageBody['data'][number];
|
|
2534
|
+
/** Why a cursor could no longer be replayed. `unknown` when the message named neither. */
|
|
2535
|
+
type ChangesExpiredReason = 'retention' | 'dataset-replaced' | 'unknown';
|
|
2536
|
+
/**
|
|
2537
|
+
* `RESOURCE_EXPIRED` from the changes feed: the cursor names a position the
|
|
2538
|
+
* ledger can no longer replay from (`INV-SS-CURSOR-REPLAYS`). The consumer
|
|
2539
|
+
* resyncs from the read path and starts again without a cursor.
|
|
2540
|
+
*
|
|
2541
|
+
* A `ResourceExpiredError`, so code that already catches that still does. The
|
|
2542
|
+
* refusal declares no details, so `reason` is read from the message the api
|
|
2543
|
+
* writes (`apps/services/api/src/changes/changes-request.ts` `refusalOf`).
|
|
2544
|
+
*/
|
|
2545
|
+
declare class ChangesExpiredError extends ResourceExpiredError {
|
|
2546
|
+
readonly reason: ChangesExpiredReason;
|
|
2547
|
+
/** The base class's signature, so `withContext` can rebuild one. */
|
|
2548
|
+
constructor(message: string, statusCode?: number, cause?: Error, context?: Record<string, unknown>);
|
|
2549
|
+
static of(expired: ResourceExpiredError): ChangesExpiredError;
|
|
2550
|
+
}
|
|
2551
|
+
interface ChangesOptions {
|
|
2552
|
+
/**
|
|
2553
|
+
* A `page.nextCursor` — or a change's `cursor` — from an earlier poll. Omitted,
|
|
2554
|
+
* the first poll answers the dataset's current position and no changes, at
|
|
2555
|
+
* once, and the feed starts from there.
|
|
2556
|
+
*/
|
|
2557
|
+
since?: string;
|
|
2558
|
+
/** Content types to keep. Omitted keeps every type; an empty list is refused (400). */
|
|
2559
|
+
types?: readonly string[];
|
|
2560
|
+
/**
|
|
2561
|
+
* Entry ids to keep. Omitted keeps every entry. The api refuses more than it
|
|
2562
|
+
* allows (100 today) as `REQUEST_INVALID`, thrown from the iterator as an
|
|
2563
|
+
* `InvalidPayloadError` on the first poll; the SDK does not restate the
|
|
2564
|
+
* cap, so it cannot drift from the service's.
|
|
2565
|
+
*/
|
|
2566
|
+
ids?: readonly string[];
|
|
2567
|
+
/** Ledger rows one poll scans, 1 to 500; the api defaults to 100. */
|
|
2568
|
+
limit?: number;
|
|
2569
|
+
/**
|
|
2570
|
+
* Ends the iteration. An abort — in flight, between polls, or while waiting
|
|
2571
|
+
* out a `Retry-After` — makes the `for await` **complete**, with no further
|
|
2572
|
+
* request and no `AbortError` thrown into the loop.
|
|
2573
|
+
*/
|
|
2574
|
+
signal?: AbortSignal;
|
|
2575
|
+
/**
|
|
2576
|
+
* What to do when the cursor has expired.
|
|
2577
|
+
*
|
|
2578
|
+
* - `'throw'` (default) — the iterator throws {@link ChangesExpiredError}.
|
|
2579
|
+
* - `'resync'` — restart from the dataset's current position and keep going.
|
|
2580
|
+
* - a function — resync, and call it with the error once the new position is
|
|
2581
|
+
* taken and before any change after it is yielded. This is the observable
|
|
2582
|
+
* form: whatever the consumer derived from the feed may be stale, so the
|
|
2583
|
+
* function is where it invalidates everything. The iterator waits for it.
|
|
2584
|
+
*/
|
|
2585
|
+
onExpired?: 'throw' | 'resync' | ((expired: ChangesExpiredError) => void | Promise<void>);
|
|
2586
|
+
}
|
|
2587
|
+
|
|
2588
|
+
/**
|
|
2589
|
+
* Any schema the client can be typed by. `any` is deliberate: the client accepts whatever content
|
|
2590
|
+
* types, components, singletons, queries and settings groups a customer declares.
|
|
2591
|
+
*
|
|
2592
|
+
* This is the constraint `TypedRelyIOClient`'s `TSchema` carries, so `RegisteredSchema` is inferred
|
|
2593
|
+
* against the same one — `createClient` returns `TypedRelyIOClient<RegisteredSchema>`, and a schema
|
|
2594
|
+
* inferred against any wider alias would not be provably inside the client's bound.
|
|
2392
2595
|
*/
|
|
2393
2596
|
type AnySchemaDefinition = SchemaDefinition<any, any, any, any, any>;
|
|
2597
|
+
/**
|
|
2598
|
+
* The seam `relyio generate-types` fills (`INV-SS-TYPES-INFERRED`).
|
|
2599
|
+
*
|
|
2600
|
+
* Empty here on purpose. The generated `schema.ts` augments it —
|
|
2601
|
+
*
|
|
2602
|
+
* ```ts
|
|
2603
|
+
* declare module '@relyio/sdk' {
|
|
2604
|
+
* interface Register {
|
|
2605
|
+
* schema: typeof schema
|
|
2606
|
+
* }
|
|
2607
|
+
* }
|
|
2608
|
+
* ```
|
|
2609
|
+
*
|
|
2610
|
+
* — and from then on `createClient({ apiKey })`, with no generic and no `schema:`, is typed by that
|
|
2611
|
+
* schema. The pattern is TanStack Router's. It is type-level only: nothing at runtime reads it.
|
|
2612
|
+
*/
|
|
2613
|
+
interface Register {
|
|
2614
|
+
}
|
|
2615
|
+
/**
|
|
2616
|
+
* The schema the project registered through `Register`, or `undefined` when nothing did — which is
|
|
2617
|
+
* the untyped client, exactly as before the generator ran.
|
|
2618
|
+
*/
|
|
2619
|
+
type RegisteredSchema = Register extends {
|
|
2620
|
+
schema: infer S extends AnySchemaDefinition;
|
|
2621
|
+
} ? S : undefined;
|
|
2622
|
+
|
|
2623
|
+
/**
|
|
2624
|
+
* The key's project, as `GET /v1/project` describes it: organization, project, dataset and branch,
|
|
2625
|
+
* each by id and name, and `studioUrl` — the Studio root the preview toolbar deep-links from
|
|
2626
|
+
* (`sdk-surfaces-spec.md` decision 24), or `null` when the service has no Dashboard address.
|
|
2627
|
+
*
|
|
2628
|
+
* Read from the committed document's `application/json` content by name, never written here
|
|
2629
|
+
* (`INV-API-CLIENT-IS-DERIVED`); `derived-transport.types.ts` holds the two equal.
|
|
2630
|
+
*/
|
|
2631
|
+
type Project = paths['/v1/project']['get']['responses'][200]['content']['application/json']['data'];
|
|
2394
2632
|
/**
|
|
2395
2633
|
* Client configuration with optional schema
|
|
2396
2634
|
*/
|
|
@@ -2426,6 +2664,7 @@ interface TypedClientConfig<TSchema extends AnySchemaDefinition | undefined = un
|
|
|
2426
2664
|
declare class TypedRelyIOClient<TSchema extends AnySchemaDefinition | undefined = undefined> {
|
|
2427
2665
|
private httpClient;
|
|
2428
2666
|
private config;
|
|
2667
|
+
private _sandbox;
|
|
2429
2668
|
private _search;
|
|
2430
2669
|
private _batch;
|
|
2431
2670
|
private _adhocQuery;
|
|
@@ -2435,6 +2674,21 @@ declare class TypedRelyIOClient<TSchema extends AnySchemaDefinition | undefined
|
|
|
2435
2674
|
* Get the schema definition
|
|
2436
2675
|
*/
|
|
2437
2676
|
get schema(): TSchema;
|
|
2677
|
+
/**
|
|
2678
|
+
* The `relyio dev` sandbox this client resolved at construction, as the preview toolbar displays
|
|
2679
|
+
* it (`sdk-surfaces-spec.md` decision 22).
|
|
2680
|
+
*
|
|
2681
|
+
* Plain, JSON-serializable data and no key, so a server component can hand it to a client
|
|
2682
|
+
* component as a prop — the browser cannot read the handshake itself, so a client created there
|
|
2683
|
+
* reports `absent`. See {@link SandboxState} for what each state means.
|
|
2684
|
+
*
|
|
2685
|
+
* @example
|
|
2686
|
+
* ```tsx
|
|
2687
|
+
* // app/layout.tsx — a server component handing the state to a client component
|
|
2688
|
+
* <SandboxBadge sandbox={relyio.sandbox} />
|
|
2689
|
+
* ```
|
|
2690
|
+
*/
|
|
2691
|
+
get sandbox(): SandboxState;
|
|
2438
2692
|
/**
|
|
2439
2693
|
* Get the ad-hoc query client
|
|
2440
2694
|
*/
|
|
@@ -2555,6 +2809,32 @@ declare class TypedRelyIOClient<TSchema extends AnySchemaDefinition | undefined
|
|
|
2555
2809
|
* ```
|
|
2556
2810
|
*/
|
|
2557
2811
|
batch(): BatchBuilder<NonNullable<TSchema>>;
|
|
2812
|
+
/**
|
|
2813
|
+
* Follow the dataset's changes feed: each write this key can see, as ids, in
|
|
2814
|
+
* order, long-polled from `GET /v1/changes`.
|
|
2815
|
+
*
|
|
2816
|
+
* Lazy — nothing is requested until the first `next()`. It runs until
|
|
2817
|
+
* `signal` aborts, which ends the `for await` cleanly rather than throwing.
|
|
2818
|
+
* A change names what changed; refetch it through the ordinary read path
|
|
2819
|
+
* (`INV-SS-CHANGE-IS-IDS`).
|
|
2820
|
+
*
|
|
2821
|
+
* @example
|
|
2822
|
+
* ```typescript
|
|
2823
|
+
* const controller = new AbortController()
|
|
2824
|
+
* for await (const change of relyio.changes({ since: cursor, types: ['post'], signal: controller.signal })) {
|
|
2825
|
+
* // { entryId, contentType, locale, kind, cursor }
|
|
2826
|
+
* }
|
|
2827
|
+
* ```
|
|
2828
|
+
*
|
|
2829
|
+
* @example Resync when the cursor has expired
|
|
2830
|
+
* ```typescript
|
|
2831
|
+
* for await (const change of relyio.changes({
|
|
2832
|
+
* since: cursor,
|
|
2833
|
+
* onExpired: async () => invalidateEverything(),
|
|
2834
|
+
* })) { … }
|
|
2835
|
+
* ```
|
|
2836
|
+
*/
|
|
2837
|
+
changes(options?: ChangesOptions): AsyncIterable<Change>;
|
|
2558
2838
|
/**
|
|
2559
2839
|
* Build and execute an ad-hoc query dynamically
|
|
2560
2840
|
*
|
|
@@ -2587,6 +2867,21 @@ declare class TypedRelyIOClient<TSchema extends AnySchemaDefinition | undefined
|
|
|
2587
2867
|
* ```
|
|
2588
2868
|
*/
|
|
2589
2869
|
executeQuery<K extends TSchema extends AnySchemaDefinition ? SchemaQueryNames<TSchema> : string>(queryName: K, params?: Record<string, unknown>): Promise<unknown[]>;
|
|
2870
|
+
/**
|
|
2871
|
+
* Describe the project this key resolves to — `GET /v1/project`.
|
|
2872
|
+
*
|
|
2873
|
+
* `dataset` is the one this client's requests select (`dataset`, a sandbox from the `relyio dev`
|
|
2874
|
+
* handshake, or the key's default), which is not always the project's default, so a Studio link
|
|
2875
|
+
* built from `studioUrl` should carry it as `?dataset=`. `studioUrl` is `null` — a value, not an
|
|
2876
|
+
* error — when the service has no Dashboard address configured.
|
|
2877
|
+
*
|
|
2878
|
+
* @example
|
|
2879
|
+
* ```typescript
|
|
2880
|
+
* const { studioUrl, dataset } = await relyio.project()
|
|
2881
|
+
* if (studioUrl !== null) window.open(`${studioUrl}?dataset=${dataset.id}`)
|
|
2882
|
+
* ```
|
|
2883
|
+
*/
|
|
2884
|
+
project(): Promise<Project>;
|
|
2590
2885
|
/**
|
|
2591
2886
|
* Get schema information from the API
|
|
2592
2887
|
*/
|
|
@@ -2713,12 +3008,29 @@ declare class TypedRelyIOClient<TSchema extends AnySchemaDefinition | undefined
|
|
|
2713
3008
|
* // Content type names autocomplete!
|
|
2714
3009
|
* const products = await relyio.content('product').fetchAll()
|
|
2715
3010
|
* ```
|
|
2716
|
-
|
|
3011
|
+
*
|
|
3012
|
+
* @example After `relyio generate-types` (inferred, `INV-SS-TYPES-INFERRED`)
|
|
3013
|
+
* ```typescript
|
|
3014
|
+
* import { createClient } from '@relyio/sdk'
|
|
3015
|
+
*
|
|
3016
|
+
* // The generated `schema.ts` augments `Register`, so no generic and no `schema:` are needed
|
|
3017
|
+
* const relyio = createClient({ apiKey: process.env.RELYIO_API_KEY! })
|
|
3018
|
+
* ```
|
|
3019
|
+
*
|
|
3020
|
+
* The overload without a schema comes first on purpose. Behind the generic one it was never
|
|
3021
|
+
* chosen: with no `schema` to infer from, `TSchema` fell back to its constraint and the call
|
|
3022
|
+
* resolved to `TypedRelyIOClient<AnySchemaDefinition>`. First, it takes every call that passes no
|
|
3023
|
+
* schema, and returns the registered schema's client — or the untyped one when nothing registered.
|
|
3024
|
+
* A `schema:` value fails its `schema?: undefined`, and an explicit generic skips it because it has
|
|
3025
|
+
* no type parameter, so both reach the generic overload unchanged.
|
|
3026
|
+
*/
|
|
3027
|
+
declare function createClient(config: RelyIOConfig & {
|
|
3028
|
+
schema?: undefined;
|
|
3029
|
+
}): TypedRelyIOClient<RegisteredSchema>;
|
|
2717
3030
|
declare function createClient<TSchema extends AnySchemaDefinition>(config: TypedClientConfig<TSchema>): TypedRelyIOClient<TSchema>;
|
|
2718
|
-
declare function createClient(config: RelyIOConfig): TypedRelyIOClient<undefined>;
|
|
2719
3031
|
/**
|
|
2720
3032
|
* Helper type to extract schema from client
|
|
2721
3033
|
*/
|
|
2722
3034
|
type ClientSchema<T extends TypedRelyIOClient<AnySchemaDefinition>> = T extends TypedRelyIOClient<infer TSchema> ? TSchema : never;
|
|
2723
3035
|
|
|
2724
|
-
export {
|
|
3036
|
+
export { type SearchBlock as $, type ActiveSandbox as A, type AutocompleteSuggestion as B, type Change as C, type AutocompleteResponse as D, type ExtendedQueryResult as E, type SimilarResult as F, type SimilarResponse as G, HttpClient as H, type SearchFilter as I, type SearchFields as J, BatchClient as K, BatchBuilder as L, type BatchMethod as M, type BatchOperation as N, type BatchOptions as O, type Project as P, type BatchOperationResult as Q, type Register as R, type SandboxState as S, TypedRelyIOClient as T, type BatchSummary as U, type BatchResponse as V, AdhocQueryClient as W, AdhocQueryBuilder as X, type FetchBlock as Y, type AggregateBlock as Z, type AggregateMetric as _, type TypedClientConfig as a, type SimilarBlock as a0, type FilterValue as a1, type FullTextConfig as a2, type AdhocQueryDefinition as a3, type AdhocQueryOptions as a4, type QueryMetadata as a5, type AdhocQueryResult as a6, AssetClient as a7, AssetFileBuilder as a8, AssetUploadBuilder as a9, FileUploadError as aA, FileValidationError as aB, type FileValidationConstraints as aC, validateFile as aD, isAssetEntry as aa, type AssetVisibility as ab, type FileStatus as ac, type FileBackend as ad, type AssetFileBlock as ae, type AssetFileExtracted as af, type AssetUrls as ag, type AssetEntryResponse as ah, type PopulatedAssetReference as ai, type PresignInput as aj, type PresignResult as ak, type ConfirmInput as al, type ConfirmResult as am, type ResolveUrlInput as an, type ResolveUrlResult as ao, type CreateAssetOptions as ap, type WaitUntilReadyOptions as aq, type MultipartCreateResult as ar, type MultipartPart as as, type MultipartTarget as at, type UploadProgress as au, ResourceNotFoundError as av, ResourceConflictError as aw, ResourceExpiredError as ax, isResourceNotFound as ay, type FileErrorCode as az, type ClientSchema as b, createClient as c, type RegisteredSchema as d, type SendOptions as e, entityTagOf as f, type ConditionalWriteOptions as g, type RetryableWriteOptions as h, ChangesExpiredError as i, type ChangesOptions as j, type ChangesExpiredReason as k, ContentClient as l, SingletonClient as m, SettingsClient as n, ContentQueryBuilder as o, ContentByIdBuilder as p, type ChildrenOptions as q, type SingletonFetchOptions as r, type SettingsFetchOptions as s, SearchClient as t, SearchBuilder as u, AutocompleteBuilder as v, SimilarBuilder as w, type SearchMode as x, type SearchResultItem as y, type SearchResponse as z };
|