@aurabase/aurabase-js 0.5.0 → 0.5.2

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 CHANGED
@@ -1,10 +1,12 @@
1
- # aurabase
1
+ # @aurabase/aurabase-js
2
2
 
3
- Client JavaScript/TypeScript officiel d'Aurabase : point d'entrée principal du SDK, agrégeant les 8 packages de service (`@aurabase/*`) derrière `createClient`/`createAdminClient` et l'export `aurabase/ssr`.
3
+ Client JavaScript/TypeScript officiel pour [Aurabase](https://aurabase.cloud) : la plateforme Backend-as-a-Service open-source haute performance propulsée par Rust.
4
4
 
5
- ![npm](https://img.shields.io/npm/v/aurabase) ![license](https://img.shields.io/badge/license-MIT-blue)
5
+ [![npm version](https://img.shields.io/npm/v/@aurabase/aurabase-js)](https://www.npmjs.com/package/@aurabase/aurabase-js) [![license](https://img.shields.io/badge/license-MIT-blue)](https://github.com/daylami555/aurabase/blob/main/LICENSE)
6
6
 
7
- > Pre-release — pas encore publié sur npm.
7
+ 🌐 **Site officiel** : [https://aurabase.cloud](https://aurabase.cloud)
8
+ 📖 **Documentation** : [https://aurabase.cloud/docs](https://aurabase.cloud)
9
+ 🐙 **GitHub** : [daylami555/aurabase](https://github.com/daylami555/aurabase)
8
10
 
9
11
  ## Installation
10
12
 
@@ -18,7 +20,7 @@ Ce package ne réimplémente aucune logique de service : il compose `AuthService
18
20
 
19
21
  - `createClient(projectUrl, apiKey, options?)` — client applicatif standard. **L'URL est le projet** : chaque projet est servi sur son propre sous-domaine (`https://<slug>.aurabase.cloud`) et la passerelle injecte elle-même le `project_id` dans le chemin. Aucun identifiant de projet dans le code client.
20
22
  - `createAdminClient(projectUrl, serviceRoleKey, options?)` — client serveur avec `authAdmin` (clé `service_role`, jamais côté navigateur).
21
- - `aurabase/ssr` — `createServerClient`/`createBrowserClient` pour Next.js et frameworks SSR (cookies, session partagée serveur/navigateur).
23
+ - `@aurabase/aurabase-js/ssr` — `createServerClient`/`createBrowserClient` pour Next.js et frameworks SSR (cookies, session partagée serveur/navigateur).
22
24
 
23
25
  ## Quick Start
24
26
 
@@ -82,6 +82,21 @@ declare class AuraClient<Database = any> implements AuraClientLike {
82
82
  * ```
83
83
  */
84
84
  channel(name: string, options?: ChannelConfig): AuraChannel;
85
+ /**
86
+ * Shortcut: remove a realtime channel by name or AuraChannel instance.
87
+ * Equivalent to `aura.realtime.removeChannel(channel)`.
88
+ */
89
+ removeChannel(channel: string | AuraChannel): void;
90
+ /**
91
+ * Shortcut: remove all realtime channels and unsubscribe.
92
+ * Equivalent to `aura.realtime.removeAllChannels()`.
93
+ */
94
+ removeAllChannels(): void;
95
+ /**
96
+ * Shortcut: list all active realtime channels.
97
+ * Equivalent to `aura.realtime.getChannels()`.
98
+ */
99
+ getChannels(): AuraChannel[];
85
100
  }
86
101
 
87
102
  export { AuraClient as A };
@@ -82,6 +82,21 @@ declare class AuraClient<Database = any> implements AuraClientLike {
82
82
  * ```
83
83
  */
84
84
  channel(name: string, options?: ChannelConfig): AuraChannel;
85
+ /**
86
+ * Shortcut: remove a realtime channel by name or AuraChannel instance.
87
+ * Equivalent to `aura.realtime.removeChannel(channel)`.
88
+ */
89
+ removeChannel(channel: string | AuraChannel): void;
90
+ /**
91
+ * Shortcut: remove all realtime channels and unsubscribe.
92
+ * Equivalent to `aura.realtime.removeAllChannels()`.
93
+ */
94
+ removeAllChannels(): void;
95
+ /**
96
+ * Shortcut: list all active realtime channels.
97
+ * Equivalent to `aura.realtime.getChannels()`.
98
+ */
99
+ getChannels(): AuraChannel[];
85
100
  }
86
101
 
87
102
  export { AuraClient as A };
package/dist/index.cjs CHANGED
@@ -108,6 +108,15 @@ var AuraClient = class {
108
108
  persistSession: this._persistSession,
109
109
  detectSessionInUrl: this._detectSessionInUrl
110
110
  });
111
+ this._auth.onAuthStateChange(({ event, accessToken }) => {
112
+ if (this._realtime) {
113
+ if (accessToken) {
114
+ this._realtime.setAuth(accessToken);
115
+ } else if (event === "SIGNED_OUT") {
116
+ this._realtime.setAuth("");
117
+ }
118
+ }
119
+ });
111
120
  }
112
121
  return this._auth;
113
122
  }
@@ -158,6 +167,27 @@ var AuraClient = class {
158
167
  channel(name, options) {
159
168
  return this.realtime.channel(name, options);
160
169
  }
170
+ /**
171
+ * Shortcut: remove a realtime channel by name or AuraChannel instance.
172
+ * Equivalent to `aura.realtime.removeChannel(channel)`.
173
+ */
174
+ removeChannel(channel) {
175
+ return this.realtime.removeChannel(channel);
176
+ }
177
+ /**
178
+ * Shortcut: remove all realtime channels and unsubscribe.
179
+ * Equivalent to `aura.realtime.removeAllChannels()`.
180
+ */
181
+ removeAllChannels() {
182
+ return this.realtime.removeAllChannels();
183
+ }
184
+ /**
185
+ * Shortcut: list all active realtime channels.
186
+ * Equivalent to `aura.realtime.getChannels()`.
187
+ */
188
+ getChannels() {
189
+ return this.realtime.getChannels();
190
+ }
161
191
  };
162
192
 
163
193
  // src/index.ts
package/dist/index.d.cts CHANGED
@@ -7,7 +7,7 @@ export { FunctionsService } from '@aurabase/functions';
7
7
  export { NotificationsAdminService, NotificationsService } from '@aurabase/notifications';
8
8
  export { AuraChannel, RealtimeService } from '@aurabase/realtime';
9
9
  export { StorageService } from '@aurabase/storage';
10
- import { A as AuraClient } from './AuraClient-0WhqmK0u.cjs';
10
+ import { A as AuraClient } from './AuraClient-DL7mqfNu.cjs';
11
11
 
12
12
  /**
13
13
  * Create a new Aurabase client instance.
package/dist/index.d.ts CHANGED
@@ -7,7 +7,7 @@ export { FunctionsService } from '@aurabase/functions';
7
7
  export { NotificationsAdminService, NotificationsService } from '@aurabase/notifications';
8
8
  export { AuraChannel, RealtimeService } from '@aurabase/realtime';
9
9
  export { StorageService } from '@aurabase/storage';
10
- import { A as AuraClient } from './AuraClient-0WhqmK0u.js';
10
+ import { A as AuraClient } from './AuraClient-DL7mqfNu.js';
11
11
 
12
12
  /**
13
13
  * Create a new Aurabase client instance.
package/dist/index.js CHANGED
@@ -114,6 +114,15 @@ var AuraClient = class {
114
114
  persistSession: this._persistSession,
115
115
  detectSessionInUrl: this._detectSessionInUrl
116
116
  });
117
+ this._auth.onAuthStateChange(({ event, accessToken }) => {
118
+ if (this._realtime) {
119
+ if (accessToken) {
120
+ this._realtime.setAuth(accessToken);
121
+ } else if (event === "SIGNED_OUT") {
122
+ this._realtime.setAuth("");
123
+ }
124
+ }
125
+ });
117
126
  }
118
127
  return this._auth;
119
128
  }
@@ -164,6 +173,27 @@ var AuraClient = class {
164
173
  channel(name, options) {
165
174
  return this.realtime.channel(name, options);
166
175
  }
176
+ /**
177
+ * Shortcut: remove a realtime channel by name or AuraChannel instance.
178
+ * Equivalent to `aura.realtime.removeChannel(channel)`.
179
+ */
180
+ removeChannel(channel) {
181
+ return this.realtime.removeChannel(channel);
182
+ }
183
+ /**
184
+ * Shortcut: remove all realtime channels and unsubscribe.
185
+ * Equivalent to `aura.realtime.removeAllChannels()`.
186
+ */
187
+ removeAllChannels() {
188
+ return this.realtime.removeAllChannels();
189
+ }
190
+ /**
191
+ * Shortcut: list all active realtime channels.
192
+ * Equivalent to `aura.realtime.getChannels()`.
193
+ */
194
+ getChannels() {
195
+ return this.realtime.getChannels();
196
+ }
167
197
  };
168
198
 
169
199
  // src/index.ts
package/dist/ssr.cjs CHANGED
@@ -108,6 +108,15 @@ var AuraClient = class {
108
108
  persistSession: this._persistSession,
109
109
  detectSessionInUrl: this._detectSessionInUrl
110
110
  });
111
+ this._auth.onAuthStateChange(({ event, accessToken }) => {
112
+ if (this._realtime) {
113
+ if (accessToken) {
114
+ this._realtime.setAuth(accessToken);
115
+ } else if (event === "SIGNED_OUT") {
116
+ this._realtime.setAuth("");
117
+ }
118
+ }
119
+ });
111
120
  }
112
121
  return this._auth;
113
122
  }
@@ -158,6 +167,27 @@ var AuraClient = class {
158
167
  channel(name, options) {
159
168
  return this.realtime.channel(name, options);
160
169
  }
170
+ /**
171
+ * Shortcut: remove a realtime channel by name or AuraChannel instance.
172
+ * Equivalent to `aura.realtime.removeChannel(channel)`.
173
+ */
174
+ removeChannel(channel) {
175
+ return this.realtime.removeChannel(channel);
176
+ }
177
+ /**
178
+ * Shortcut: remove all realtime channels and unsubscribe.
179
+ * Equivalent to `aura.realtime.removeAllChannels()`.
180
+ */
181
+ removeAllChannels() {
182
+ return this.realtime.removeAllChannels();
183
+ }
184
+ /**
185
+ * Shortcut: list all active realtime channels.
186
+ * Equivalent to `aura.realtime.getChannels()`.
187
+ */
188
+ getChannels() {
189
+ return this.realtime.getChannels();
190
+ }
161
191
  };
162
192
  var MAX_CHUNK_SIZE = 3600;
163
193
  function createServerClient(baseUrl, apiKey, options) {
package/dist/ssr.d.cts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { SerializeCookieOptions, AuraClientOptions } from '@aurabase/core';
2
2
  export { SerializeCookieOptions, parseCookieHeader, serializeCookieHeader } from '@aurabase/core';
3
- import { A as AuraClient } from './AuraClient-0WhqmK0u.cjs';
3
+ import { A as AuraClient } from './AuraClient-DL7mqfNu.cjs';
4
4
  import '@aurabase/ai';
5
5
  import '@aurabase/auth';
6
6
  import '@aurabase/db';
@@ -14,7 +14,7 @@ import '@aurabase/storage';
14
14
  *
15
15
  * @example Next.js middleware
16
16
  * ```ts
17
- * import { createServerClient } from 'aurabase/ssr'
17
+ * import { createServerClient } from '@aurabase/aurabase-js/ssr'
18
18
  *
19
19
  * export async function middleware(request) {
20
20
  * let response = NextResponse.next({ request })
package/dist/ssr.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { SerializeCookieOptions, AuraClientOptions } from '@aurabase/core';
2
2
  export { SerializeCookieOptions, parseCookieHeader, serializeCookieHeader } from '@aurabase/core';
3
- import { A as AuraClient } from './AuraClient-0WhqmK0u.js';
3
+ import { A as AuraClient } from './AuraClient-DL7mqfNu.js';
4
4
  import '@aurabase/ai';
5
5
  import '@aurabase/auth';
6
6
  import '@aurabase/db';
@@ -14,7 +14,7 @@ import '@aurabase/storage';
14
14
  *
15
15
  * @example Next.js middleware
16
16
  * ```ts
17
- * import { createServerClient } from 'aurabase/ssr'
17
+ * import { createServerClient } from '@aurabase/aurabase-js/ssr'
18
18
  *
19
19
  * export async function middleware(request) {
20
20
  * let response = NextResponse.next({ request })
package/dist/ssr.js CHANGED
@@ -107,6 +107,15 @@ var AuraClient = class {
107
107
  persistSession: this._persistSession,
108
108
  detectSessionInUrl: this._detectSessionInUrl
109
109
  });
110
+ this._auth.onAuthStateChange(({ event, accessToken }) => {
111
+ if (this._realtime) {
112
+ if (accessToken) {
113
+ this._realtime.setAuth(accessToken);
114
+ } else if (event === "SIGNED_OUT") {
115
+ this._realtime.setAuth("");
116
+ }
117
+ }
118
+ });
110
119
  }
111
120
  return this._auth;
112
121
  }
@@ -157,6 +166,27 @@ var AuraClient = class {
157
166
  channel(name, options) {
158
167
  return this.realtime.channel(name, options);
159
168
  }
169
+ /**
170
+ * Shortcut: remove a realtime channel by name or AuraChannel instance.
171
+ * Equivalent to `aura.realtime.removeChannel(channel)`.
172
+ */
173
+ removeChannel(channel) {
174
+ return this.realtime.removeChannel(channel);
175
+ }
176
+ /**
177
+ * Shortcut: remove all realtime channels and unsubscribe.
178
+ * Equivalent to `aura.realtime.removeAllChannels()`.
179
+ */
180
+ removeAllChannels() {
181
+ return this.realtime.removeAllChannels();
182
+ }
183
+ /**
184
+ * Shortcut: list all active realtime channels.
185
+ * Equivalent to `aura.realtime.getChannels()`.
186
+ */
187
+ getChannels() {
188
+ return this.realtime.getChannels();
189
+ }
160
190
  };
161
191
  var MAX_CHUNK_SIZE = 3600;
162
192
  function createServerClient(baseUrl, apiKey, options) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aurabase/aurabase-js",
3
- "version": "0.5.0",
3
+ "version": "0.5.2",
4
4
  "description": "Official JavaScript/TypeScript client for Aurabase BaaS",
5
5
  "type": "module",
6
6
  "main": "dist/index.cjs",
@@ -44,7 +44,7 @@
44
44
  "url": "git+https://github.com/daylami555/aurabase.git",
45
45
  "directory": "aurabase-js/packages/aurabase"
46
46
  },
47
- "homepage": "https://github.com/daylami555/aurabase/tree/main/aurabase-js/packages/aurabase#readme",
47
+ "homepage": "https://aurabase.cloud",
48
48
  "bugs": {
49
49
  "url": "https://github.com/daylami555/aurabase/issues"
50
50
  },
@@ -56,14 +56,14 @@
56
56
  "client"
57
57
  ],
58
58
  "dependencies": {
59
- "@aurabase/core": "0.5.0",
60
- "@aurabase/db": "0.5.0",
61
- "@aurabase/storage": "0.5.0",
62
- "@aurabase/realtime": "0.5.0",
63
- "@aurabase/functions": "0.5.0",
64
- "@aurabase/ai": "0.5.0",
65
- "@aurabase/notifications": "0.5.0",
66
- "@aurabase/auth": "0.5.0"
59
+ "@aurabase/core": "0.5.2",
60
+ "@aurabase/db": "0.5.2",
61
+ "@aurabase/storage": "0.5.2",
62
+ "@aurabase/auth": "0.5.2",
63
+ "@aurabase/realtime": "0.5.2",
64
+ "@aurabase/notifications": "0.5.2",
65
+ "@aurabase/ai": "0.5.2",
66
+ "@aurabase/functions": "0.5.2"
67
67
  },
68
68
  "devDependencies": {
69
69
  "@types/node": "20.14.15",