@rebasepro/client 0.23.0 → 0.24.1-canary.g56af4a4
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/README.md +8 -8
- package/dist/admin-contract.types.d.ts +21 -0
- package/dist/admin.d.ts +11 -5
- package/dist/api-keys.d.ts +29 -11
- package/dist/auth.d.ts +65 -11
- package/dist/backups.d.ts +14 -7
- package/dist/collection.d.ts +40 -19
- package/dist/cron.d.ts +13 -8
- package/dist/exports-contract.types.d.ts +39 -0
- package/dist/functions.d.ts +2 -12
- package/dist/index.d.ts +44 -19
- package/dist/index.es.js +1509 -3924
- package/dist/index.es.js.map +1 -1
- package/dist/offline-8Ks3yp9n.js +3307 -0
- package/dist/offline-8Ks3yp9n.js.map +1 -0
- package/dist/offline-codec.d.ts +12 -0
- package/dist/offline-connectivity.d.ts +6 -0
- package/dist/offline-errors.d.ts +9 -0
- package/dist/offline-lazy.d.ts +58 -0
- package/dist/offline-store-D9ytNNaa.js +1825 -0
- package/dist/offline-store-D9ytNNaa.js.map +1 -0
- package/dist/offline-store.d.ts +45 -0
- package/dist/offline.d.ts +315 -19
- package/dist/query-contract.types.d.ts +76 -24
- package/dist/realtime-channel.d.ts +30 -0
- package/dist/reviver.d.ts +18 -0
- package/dist/sdk_query_builder.d.ts +2 -2
- package/dist/sql-script.d.ts +10 -0
- package/dist/storage-resumable-VO-cMpse.js +2 -0
- package/dist/storage-resumable.d.ts +1 -0
- package/dist/transport.d.ts +95 -7
- package/dist/websocket.d.ts +183 -21
- package/package.json +4 -4
- package/dist/query_builder.d.ts +0 -1
package/dist/index.d.ts
CHANGED
|
@@ -3,41 +3,43 @@ import { createAuth, CreateAuthOptions } from "./auth.js";
|
|
|
3
3
|
import { createAdmin, CreateAdminOptions } from "./admin.js";
|
|
4
4
|
import { createCron, CreateCronOptions } from "./cron.js";
|
|
5
5
|
import { createBackups } from "./backups.js";
|
|
6
|
-
import { createApiKeys, CreateApiKeysOptions } from "./api-keys.js";
|
|
6
|
+
import { createApiKeys, CreateApiKeysOptions, createPersonalKeys, CreatePersonalKeysOptions } from "./api-keys.js";
|
|
7
7
|
import { CollectionClient } from "./collection.js";
|
|
8
8
|
import { createFunctionsClient } from "./functions.js";
|
|
9
9
|
import { RebaseWebSocketClient } from "./websocket.js";
|
|
10
10
|
import { RebaseRealtimeChannel, type ChannelOptions } from "./realtime-channel.js";
|
|
11
|
-
import {
|
|
12
|
-
import { type BatchOperation, type BatchResult, InsertOf, RebaseClient, RebaseSdkData, RowOf, StorageSource, StorageSourceDefinition, StorageSourceRegistry, UpdateOf, type WriteOptions } from "@rebasepro/types";
|
|
11
|
+
import type { OfflineApi, OfflineConfig } from "./offline.js";
|
|
12
|
+
import { type BatchOperation, type BatchResult, type IncludeOf, InsertOf, RebaseClient, RebaseSdkData, RowOf, StorageSource, StorageSourceDefinition, StorageSourceRegistry, UpdateOf, type WriteOptions } from "@rebasepro/types";
|
|
13
13
|
export { RebaseApiError } from "./transport.js";
|
|
14
14
|
export { RebaseClientError } from "./errors.js";
|
|
15
15
|
export type { RebaseErrorCode } from "@rebasepro/types";
|
|
16
16
|
export type { RebaseClientConfig, FindParams, FindResponse } from "./transport.js";
|
|
17
|
-
export type { CollectionClient } from "./collection.js";
|
|
17
|
+
export type { CollectionClient, RestoreOptions, TrashClient } from "./collection.js";
|
|
18
18
|
export type { FindResult, SDKCollectionClient, SDKQueryBuilderInterface, PaginationMeta } from "@rebasepro/types";
|
|
19
19
|
export type { IterateParams, FindAllParams, PageWalkOptions, CursorSpec } from "@rebasepro/types";
|
|
20
20
|
export { RebasePaginationError } from "@rebasepro/common";
|
|
21
21
|
export type { PaginationErrorCode } from "@rebasepro/common";
|
|
22
|
-
export {
|
|
22
|
+
export { or, and, not, cond } from "@rebasepro/common";
|
|
23
|
+
export { resolveStorageReferences, storageReference, parseStorageReference, isStorageReference, STORAGE_REFERENCE_SCHEME, storageTargetOfDownloadUrl, storageReferencesForDownloadUrls, storageTargetsInText } from "@rebasepro/types";
|
|
24
|
+
export type { StorageReferenceTarget, StorageReferenceResolver } from "@rebasepro/types";
|
|
23
25
|
export { createCookieStorage, createMemoryStorage } from "./auth.js";
|
|
24
|
-
export type { AuthConfig, AuthStorage, CookieStorageOptions, CreateAuthOptions } from "./auth.js";
|
|
26
|
+
export type { AuthConfig, AuthStorage, CookieStorageOptions, CreateAuthOptions, SessionRestoreOutcome } from "./auth.js";
|
|
25
27
|
export type { User, RebaseSession, AuthTokens, AuthChangeEvent, DeviceSession } from "@rebasepro/types";
|
|
26
28
|
export type { CreateAdminOptions, ListUsersOptions } from "./admin.js";
|
|
27
29
|
export type { AdminUser } from "./admin.js";
|
|
28
30
|
export type { CreateCronOptions } from "./cron.js";
|
|
29
|
-
export {
|
|
30
|
-
export type {
|
|
31
|
-
export type { ApiKeyMasked, ApiKeyPermission, ApiKeyWithSecret, CreateApiKeyRequest, CreateApiKeysOptions, UpdateApiKeyRequest } from "./api-keys.js";
|
|
31
|
+
export type { BackupStream } from "./backups.js";
|
|
32
|
+
export type { ApiKeyKind, ApiKeyMasked, ApiKeyWithSecret, CreateApiKeyRequest, CreateApiKeysOptions, CreatePersonalKeyRequest, CreatePersonalKeysOptions, UpdateApiKeyRequest } from "./api-keys.js";
|
|
32
33
|
export type { FunctionInvokeOptions, FunctionsClient } from "./functions.js";
|
|
33
34
|
export { RebaseWebSocketClient } from "./websocket.js";
|
|
34
35
|
export { RebaseRealtimeChannel } from "./realtime-channel.js";
|
|
35
36
|
export type { PresenceState, PresenceDiff, BroadcastEvent, ChannelTransport, ChannelOptions, ChannelHistoryEntry, ChannelHistoryResult } from "./realtime-channel.js";
|
|
36
|
-
export type { OfflineApi, OfflineConfig, OfflineStatus } from "./offline.js";
|
|
37
|
-
export { isOfflineError } from "./offline.js";
|
|
38
|
-
export type { LiveResult, ObserveOptions, RowSnapshotMeta } from "./collection.js";
|
|
37
|
+
export type { ConflictResolution, OfflineApi, OfflineConfig, OfflineQueueOptions, OfflineStatus } from "./offline.js";
|
|
38
|
+
export { isOfflineError } from "./offline-errors.js";
|
|
39
|
+
export type { LiveResult, ObserveByIdOptions, ObserveOptions, RowSnapshotMeta } from "./collection.js";
|
|
39
40
|
export { etagOf } from "./collection.js";
|
|
40
41
|
export type { BatchOperation, BatchRef, BatchResult, FieldOperation, UpdateValues, UpsertOptions } from "@rebasepro/types";
|
|
42
|
+
export type { WriteOptions, WhereFilterOp, WhereFor, WhereConditionFor, WhereValueFor, FilterValues, FieldPath, OrderBySpec, LogicalCondition, LogicalConditionFor, FilterCondition, FilterConditionFor, AggregateParams, AggregateSelect, AggregateRow, AggregateResult, AggregateMeta, IncludeSpec, IncludeOptions, QueryComputedFields, RowOf, InsertOf, UpdateOf, StorageSource } from "@rebasepro/types";
|
|
41
43
|
export type { OfflineStore, OfflineCacheEntry, OfflineCacheRecord, PendingMutation, MutationRollback } from "./offline-store.js";
|
|
42
44
|
export { MemoryOfflineStore } from "./offline-store.js";
|
|
43
45
|
export interface CreateRebaseClientOptions extends RebaseClientConfig {
|
|
@@ -45,6 +47,7 @@ export interface CreateRebaseClientOptions extends RebaseClientConfig {
|
|
|
45
47
|
admin?: CreateAdminOptions;
|
|
46
48
|
cron?: CreateCronOptions;
|
|
47
49
|
apiKeys?: CreateApiKeysOptions;
|
|
50
|
+
personalKeys?: CreatePersonalKeysOptions;
|
|
48
51
|
/**
|
|
49
52
|
* Declared storage sources for multi-backend support. Server-transport
|
|
50
53
|
* entries are auto-wired into `client.storageRegistry`; `direct` sources
|
|
@@ -77,12 +80,20 @@ export interface CreateRebaseClientOptions extends RebaseClientConfig {
|
|
|
77
80
|
offline?: boolean | OfflineConfig;
|
|
78
81
|
}
|
|
79
82
|
type KebabToCamelCase<S extends string> = S extends `${infer T}-${infer U}` ? `${T}${Capitalize<KebabToCamelCase<U>>}` : S;
|
|
80
|
-
|
|
83
|
+
/** The accessor whose generated entry declares `Slug: S`, or `never`. */
|
|
84
|
+
type AccessorOfSlug<DB, S extends string> = {
|
|
85
|
+
[K in keyof DB]: DB[K] extends {
|
|
86
|
+
Slug: S;
|
|
87
|
+
} ? K : never;
|
|
88
|
+
}[keyof DB];
|
|
89
|
+
type DBEntry<DB, S extends string> = [
|
|
90
|
+
AccessorOfSlug<DB, S>
|
|
91
|
+
] extends [never] ? (KebabToCamelCase<S> extends keyof DB ? DB[KebabToCamelCase<S>] : unknown) : DB[AccessorOfSlug<DB, S>];
|
|
81
92
|
type TypedDataLayer<DB> = {
|
|
82
|
-
collection<S extends string>(slug: S): CollectionClient<RowOf<DBEntry<DB, S>>, InsertOf<DBEntry<DB, S>>, UpdateOf<DBEntry<DB, S
|
|
93
|
+
collection<S extends string>(slug: S): CollectionClient<RowOf<DBEntry<DB, S>>, InsertOf<DBEntry<DB, S>>, UpdateOf<DBEntry<DB, S>>, IncludeOf<DBEntry<DB, S>, DB>>;
|
|
83
94
|
} & {
|
|
84
|
-
[K in keyof DB]: CollectionClient<RowOf<DB[K]>, InsertOf<DB[K]>, UpdateOf<DB[K]>>;
|
|
85
|
-
} & RebaseSdkData;
|
|
95
|
+
[K in keyof DB]: CollectionClient<RowOf<DB[K]>, InsertOf<DB[K]>, UpdateOf<DB[K]>, IncludeOf<DB[K], DB>>;
|
|
96
|
+
} & (string extends keyof DB ? RebaseSdkData : Pick<RebaseSdkData, "collection">);
|
|
86
97
|
/**
|
|
87
98
|
* The return type of `createRebaseClient<DB>()`.
|
|
88
99
|
*
|
|
@@ -100,6 +111,7 @@ export type CreateRebaseClientResult<DB = Record<string, unknown>> = Omit<Rebase
|
|
|
100
111
|
cron: ReturnType<typeof createCron>;
|
|
101
112
|
backups: ReturnType<typeof createBackups>;
|
|
102
113
|
apiKeys: ReturnType<typeof createApiKeys>;
|
|
114
|
+
personalKeys: ReturnType<typeof createPersonalKeys>;
|
|
103
115
|
functions: ReturnType<typeof createFunctionsClient>;
|
|
104
116
|
ws?: RebaseWebSocketClient;
|
|
105
117
|
/**
|
|
@@ -147,7 +159,15 @@ export type CreateRebaseClientResult<DB = Record<string, unknown>> = Omit<Rebase
|
|
|
147
159
|
* Neither reaches into the response for a `data` key.
|
|
148
160
|
*/
|
|
149
161
|
call: <T = unknown>(endpoint: string, payload?: unknown) => Promise<T>;
|
|
150
|
-
|
|
162
|
+
/**
|
|
163
|
+
* A collection by slug — the same client `data.collection(slug)` returns,
|
|
164
|
+
* typed from the generated `Database` when the slug is one of its
|
|
165
|
+
* collections, or by the row type passed explicitly.
|
|
166
|
+
*/
|
|
167
|
+
collection: {
|
|
168
|
+
<S extends string>(slug: S): CollectionClient<RowOf<DBEntry<DB, S>>, InsertOf<DBEntry<DB, S>>, UpdateOf<DBEntry<DB, S>>, IncludeOf<DBEntry<DB, S>, DB>>;
|
|
169
|
+
<M extends Record<string, unknown> = Record<string, unknown>>(slug: string): CollectionClient<M>;
|
|
170
|
+
};
|
|
151
171
|
/**
|
|
152
172
|
* Write across collections in one transaction.
|
|
153
173
|
*
|
|
@@ -170,12 +190,17 @@ export type CreateRebaseClientResult<DB = Record<string, unknown>> = Omit<Rebase
|
|
|
170
190
|
* `data` is aligned to `operations`: the written row for a create, upsert
|
|
171
191
|
* or update, and `null` for a delete.
|
|
172
192
|
*
|
|
193
|
+
* `collection` is the accessor `client.data.<accessor>` takes — `orderItems`
|
|
194
|
+
* for the slug `order_items` — and is sent as the slug through the
|
|
195
|
+
* `collections` dictionary. A name that is not an accessor goes out as
|
|
196
|
+
* written, so an untyped client can still pass the slug.
|
|
197
|
+
*
|
|
173
198
|
* @example
|
|
174
199
|
* ```ts
|
|
175
200
|
* await client.batch([
|
|
176
201
|
* { op: "create", collection: "orders", values: { total: 40 }, ref: "order" },
|
|
177
|
-
* { op: "create", collection: "
|
|
178
|
-
* values: {
|
|
202
|
+
* { op: "create", collection: "orderItems",
|
|
203
|
+
* values: { orderId: { $ref: "order.id" }, sku: "A-1" } },
|
|
179
204
|
* { op: "update", collection: "stock", id: "A-1", values: { count: { $inc: -1 } } }
|
|
180
205
|
* ]);
|
|
181
206
|
* ```
|