@rebasepro/client 0.9.1-canary.fd3754b → 0.9.1-canary.ff338b5

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/dist/index.d.ts CHANGED
@@ -7,6 +7,7 @@ import { createApiKeys, CreateApiKeysOptions } from "./api-keys";
7
7
  import { CollectionClient } from "./collection";
8
8
  import { createFunctionsClient } from "./functions";
9
9
  import { RebaseWebSocketClient } from "./websocket";
10
+ import { RebaseRealtimeChannel } from "./realtime-channel";
10
11
  import { InsertOf, RebaseClient, RebaseSdkData, RowOf, StorageSource, StorageSourceDefinition, StorageSourceRegistry, UpdateOf } from "@rebasepro/types";
11
12
  export { RebaseApiError } from "./transport";
12
13
  export { RebaseClientError } from "./errors";
@@ -27,6 +28,8 @@ export type { CreateBackupsOptions } from "./backups";
27
28
  export type { ApiKeyMasked, ApiKeyPermission, ApiKeyWithSecret, CreateApiKeyRequest, CreateApiKeysOptions, UpdateApiKeyRequest } from "./api-keys";
28
29
  export type { FunctionInvokeOptions, FunctionsClient } from "./functions";
29
30
  export { RebaseWebSocketClient } from "./websocket";
31
+ export { RebaseRealtimeChannel } from "./realtime-channel";
32
+ export type { PresenceState, PresenceDiff, BroadcastEvent, ChannelTransport } from "./realtime-channel";
30
33
  export interface CreateRebaseClientOptions extends RebaseClientConfig {
31
34
  auth?: CreateAuthOptions;
32
35
  admin?: CreateAdminOptions;
@@ -74,11 +77,35 @@ export type CreateRebaseClientResult<DB = Record<string, unknown>> = Omit<Rebase
74
77
  apiKeys: ReturnType<typeof createApiKeys>;
75
78
  functions: ReturnType<typeof createFunctionsClient>;
76
79
  ws?: RebaseWebSocketClient;
80
+ /**
81
+ * Broadcast and presence channels.
82
+ *
83
+ * Was missing from this type while present on the returned object, which
84
+ * made `client.realtime.channel(...)` a type error and forced every adopter
85
+ * to cast around the feature before they could reach it.
86
+ */
87
+ realtime: {
88
+ /**
89
+ * Join a broadcast/presence channel. Repeated calls with the same name
90
+ * return the same channel object. Throws only when the client was
91
+ * created with `realtime: false`.
92
+ */
93
+ channel: (name: string) => RebaseRealtimeChannel;
94
+ };
95
+ /**
96
+ * Release the realtime socket and its reconnect timer.
97
+ *
98
+ * An open socket keeps the Node event loop alive, so a script that does not
99
+ * call this will not exit on its own. Safe when realtime was never started
100
+ * (`realtime: false`), and safe to call twice.
101
+ */
102
+ close: () => void;
77
103
  storage: StorageSource;
78
104
  storageRegistry: StorageSourceRegistry;
79
105
  createStorageSource: (storageId: string) => StorageSource;
80
106
  fetchStorageSources: () => Promise<StorageSourceDefinition[]>;
81
107
  call: <T = unknown>(endpoint: string, payload?: unknown) => Promise<T>;
108
+ collection: <M extends Record<string, unknown> = Record<string, unknown>>(slug: string) => CollectionClient<M>;
82
109
  data: TypedDataLayer<DB>;
83
110
  };
84
111
  export declare function createRebaseClient<DB = Record<string, unknown>>(options: CreateRebaseClientOptions): CreateRebaseClientResult<DB>;