@aurabase/aurabase-js 0.6.0 → 0.6.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
@@ -2,18 +2,24 @@
2
2
 
3
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 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)
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/Aurabase-cloud/Aurabase/blob/main/LICENSE)
6
6
 
7
7
  🌐 **Site officiel** : [https://aurabase.cloud](https://aurabase.cloud)
8
8
  📖 **Documentation** : [https://aurabase.cloud/docs](https://aurabase.cloud)
9
- 🐙 **GitHub** : [daylami555/aurabase](https://github.com/daylami555/aurabase)
9
+ 🐙 **GitHub** : [Aurabase-cloud/Aurabase](https://github.com/Aurabase-cloud/Aurabase)
10
10
 
11
11
  ## Installation
12
12
 
13
13
  ```bash
14
14
  npm i @aurabase/aurabase-js
15
+ # ou
16
+ pnpm add @aurabase/aurabase-js
17
+ yarn add @aurabase/aurabase-js
18
+ bun add @aurabase/aurabase-js
15
19
  ```
16
20
 
21
+ > **Attention au nom.** Le paquet officiel est `@aurabase/aurabase-js` (avec la portée `@aurabase/`). Le paquet `aurabase-js` sans portée n'est **pas** maintenu par Aurabase : ne l'installez pas.
22
+
17
23
  ## Rôle
18
24
 
19
25
  Ce package ne réimplémente aucune logique de service : il compose `AuthService`, `DatabaseService`, `StorageService`, `RealtimeService`, `FunctionsService`, `AiService` et `NotificationsService` (chacun dans son propre package `@aurabase/*`) derrière un seul client.
@@ -33,7 +39,7 @@ const { data, error } = await aura.db
33
39
  .from('posts')
34
40
  .select('id,title,published')
35
41
  .eq('published', true)
36
- .order('created_at', 'desc')
42
+ .order('created_at', { ascending: false })
37
43
  .limit(10)
38
44
 
39
45
  if (error) {
@@ -28,9 +28,21 @@ declare class AuraClient<Database = any, Schema extends GenericSchema = Database
28
28
  } ? S extends GenericSchema ? S : any : any> implements AuraClientLike {
29
29
  /** URL du projet (`https://<slug>.aurabase.cloud`), sans barre finale. */
30
30
  readonly baseUrl: string;
31
+ /**
32
+ * Clé API du projet (`anon` ou `service_role`) envoyée dans l'en-tête `apikey` ; `null` si aucune n'a été fournie.
33
+ */
31
34
  readonly apiKey: string | null;
35
+ /**
36
+ * Fonction `fetch` utilisée pour toutes les requêtes (celle de `options.fetch`, sinon `globalThis.fetch`).
37
+ */
32
38
  readonly fetchFn: typeof globalThis.fetch;
39
+ /**
40
+ * Magasin de session (jeton d'accès, jeton de rafraîchissement, utilisateur) : mémoire, `localStorage` ou cookies selon le contexte.
41
+ */
33
42
  readonly authStore: BaseAuthStore;
43
+ /**
44
+ * Politique de reprise des requêtes de lecture (`GET`, `HEAD`) sur erreur transitoire : activée ou non, et nombre maximal de reprises.
45
+ */
34
46
  readonly retryConfig: {
35
47
  enabled: boolean;
36
48
  maxRetries: number;
@@ -64,13 +76,34 @@ declare class AuraClient<Database = any, Schema extends GenericSchema = Database
64
76
  * (React Strict Mode / HMR / tests).
65
77
  */
66
78
  dispose(): void;
79
+ /**
80
+ * Service d'authentification : inscription, connexion, session, MFA, OAuth, identités. Créé à la première utilisation.
81
+ */
67
82
  get auth(): AuthService;
83
+ /**
84
+ * API d'administration de l'authentification (utilisateurs, sessions, journal d'audit, modèles d'e-mail).
85
+ * Exige une clé `service_role` et lève une erreur dans un navigateur : utilisez `createAdminClient()` côté serveur.
86
+ */
68
87
  get authAdmin(): AuthAdminService;
88
+ /**
89
+ * Service de base de données : requêtes sur les tables et vues, appels de fonctions SQL (`rpc`), SQL brut.
90
+ */
69
91
  get db(): DatabaseService<Database, Schema>;
92
+ /**
93
+ * Service de stockage : buckets, envoi, téléchargement, URL signées et publiques, transformations d'image.
94
+ */
70
95
  get storage(): StorageService;
96
+ /** Service temps réel : canaux, changements Postgres, diffusion (`broadcast`) et présence. */
71
97
  get realtime(): RealtimeService;
98
+ /**
99
+ * Service Edge Functions : invocation, et gestion des jobs et du cron avec une clé `service_role`.
100
+ */
72
101
  get functions(): FunctionsService;
102
+ /** Service IA : conversation (`chat`), embeddings, RAG (ingestion, requêtes, espaces de noms), recherche sémantique et sessions. */
73
103
  get ai(): AiService;
104
+ /**
105
+ * Service de notifications : envoi (e-mail, SMS, push, webhook), historique, modèles et administration. Exige une clé `service_role`.
106
+ */
74
107
  get notifications(): NotificationsService;
75
108
  /**
76
109
  * Shortcut: query a database table or view (Supabase-compatible API).
@@ -28,9 +28,21 @@ declare class AuraClient<Database = any, Schema extends GenericSchema = Database
28
28
  } ? S extends GenericSchema ? S : any : any> implements AuraClientLike {
29
29
  /** URL du projet (`https://<slug>.aurabase.cloud`), sans barre finale. */
30
30
  readonly baseUrl: string;
31
+ /**
32
+ * Clé API du projet (`anon` ou `service_role`) envoyée dans l'en-tête `apikey` ; `null` si aucune n'a été fournie.
33
+ */
31
34
  readonly apiKey: string | null;
35
+ /**
36
+ * Fonction `fetch` utilisée pour toutes les requêtes (celle de `options.fetch`, sinon `globalThis.fetch`).
37
+ */
32
38
  readonly fetchFn: typeof globalThis.fetch;
39
+ /**
40
+ * Magasin de session (jeton d'accès, jeton de rafraîchissement, utilisateur) : mémoire, `localStorage` ou cookies selon le contexte.
41
+ */
33
42
  readonly authStore: BaseAuthStore;
43
+ /**
44
+ * Politique de reprise des requêtes de lecture (`GET`, `HEAD`) sur erreur transitoire : activée ou non, et nombre maximal de reprises.
45
+ */
34
46
  readonly retryConfig: {
35
47
  enabled: boolean;
36
48
  maxRetries: number;
@@ -64,13 +76,34 @@ declare class AuraClient<Database = any, Schema extends GenericSchema = Database
64
76
  * (React Strict Mode / HMR / tests).
65
77
  */
66
78
  dispose(): void;
79
+ /**
80
+ * Service d'authentification : inscription, connexion, session, MFA, OAuth, identités. Créé à la première utilisation.
81
+ */
67
82
  get auth(): AuthService;
83
+ /**
84
+ * API d'administration de l'authentification (utilisateurs, sessions, journal d'audit, modèles d'e-mail).
85
+ * Exige une clé `service_role` et lève une erreur dans un navigateur : utilisez `createAdminClient()` côté serveur.
86
+ */
68
87
  get authAdmin(): AuthAdminService;
88
+ /**
89
+ * Service de base de données : requêtes sur les tables et vues, appels de fonctions SQL (`rpc`), SQL brut.
90
+ */
69
91
  get db(): DatabaseService<Database, Schema>;
92
+ /**
93
+ * Service de stockage : buckets, envoi, téléchargement, URL signées et publiques, transformations d'image.
94
+ */
70
95
  get storage(): StorageService;
96
+ /** Service temps réel : canaux, changements Postgres, diffusion (`broadcast`) et présence. */
71
97
  get realtime(): RealtimeService;
98
+ /**
99
+ * Service Edge Functions : invocation, et gestion des jobs et du cron avec une clé `service_role`.
100
+ */
72
101
  get functions(): FunctionsService;
102
+ /** Service IA : conversation (`chat`), embeddings, RAG (ingestion, requêtes, espaces de noms), recherche sémantique et sessions. */
73
103
  get ai(): AiService;
104
+ /**
105
+ * Service de notifications : envoi (e-mail, SMS, push, webhook), historique, modèles et administration. Exige une clé `service_role`.
106
+ */
74
107
  get notifications(): NotificationsService;
75
108
  /**
76
109
  * Shortcut: query a database table or view (Supabase-compatible API).
package/dist/index.cjs CHANGED
@@ -21,9 +21,21 @@ var SERVICE_ROLE_KEY_PREFIX = "aura_sk_";
21
21
  var AuraClient = class {
22
22
  /** URL du projet (`https://<slug>.aurabase.cloud`), sans barre finale. */
23
23
  baseUrl;
24
+ /**
25
+ * Clé API du projet (`anon` ou `service_role`) envoyée dans l'en-tête `apikey` ; `null` si aucune n'a été fournie.
26
+ */
24
27
  apiKey;
28
+ /**
29
+ * Fonction `fetch` utilisée pour toutes les requêtes (celle de `options.fetch`, sinon `globalThis.fetch`).
30
+ */
25
31
  fetchFn;
32
+ /**
33
+ * Magasin de session (jeton d'accès, jeton de rafraîchissement, utilisateur) : mémoire, `localStorage` ou cookies selon le contexte.
34
+ */
26
35
  authStore;
36
+ /**
37
+ * Politique de reprise des requêtes de lecture (`GET`, `HEAD`) sur erreur transitoire : activée ou non, et nombre maximal de reprises.
38
+ */
27
39
  retryConfig;
28
40
  /** Timeout par défaut (ms) des requêtes JSON sans signal. `undefined` → défaut core (30s). */
29
41
  requestTimeoutMs;
@@ -49,6 +61,21 @@ var AuraClient = class {
49
61
  * @param apiKey Clé API du projet (`aura_anon_…`, `aura_auth_…`, `aura_sk_…`).
50
62
  */
51
63
  constructor(baseUrl, apiKey, options) {
64
+ if (typeof baseUrl !== "string" || baseUrl.trim() === "") {
65
+ throw new Error(
66
+ "[aurabase] Project URL is required: set NEXT_PUBLIC_AURABASE_URL to the project URL shown in Studio \u203A Settings \u203A Connection (e.g. http://<slug>.localhost:8080), then pass it to createClient(url, key)."
67
+ );
68
+ }
69
+ if (!/^https?:\/\//i.test(baseUrl.trim())) {
70
+ throw new Error(
71
+ `[aurabase] baseUrl must start with http:// or https:// (got "${baseUrl}"): copy the project URL from Studio \u203A Settings \u203A Connection (e.g. http://<slug>.localhost:8080).`
72
+ );
73
+ }
74
+ if (apiKey === void 0 || apiKey === null) {
75
+ throw new Error(
76
+ "[aurabase] API key is required: set NEXT_PUBLIC_AURABASE_ANON_KEY (browser) or AURABASE_SERVICE_ROLE_KEY (server only) to a key shown in Studio \u203A Settings \u203A Connection, then pass it to createClient(url, key)."
77
+ );
78
+ }
52
79
  this.baseUrl = baseUrl.replace(/\/+$/, "");
53
80
  const resolvedOptions = options;
54
81
  this.apiKey = apiKey || null;
@@ -111,6 +138,9 @@ var AuraClient = class {
111
138
  this._realtime?.disconnect();
112
139
  }
113
140
  // -- Lazy service getters ---------------------------------------------------
141
+ /**
142
+ * Service d'authentification : inscription, connexion, session, MFA, OAuth, identités. Créé à la première utilisation.
143
+ */
114
144
  get auth() {
115
145
  if (!this._auth) {
116
146
  this._auth = new auth.AuthService(this, {
@@ -130,6 +160,10 @@ var AuraClient = class {
130
160
  }
131
161
  return this._auth;
132
162
  }
163
+ /**
164
+ * API d'administration de l'authentification (utilisateurs, sessions, journal d'audit, modèles d'e-mail).
165
+ * Exige une clé `service_role` et lève une erreur dans un navigateur : utilisez `createAdminClient()` côté serveur.
166
+ */
133
167
  get authAdmin() {
134
168
  if (isBrowserContext()) {
135
169
  throw new Error(
@@ -139,26 +173,40 @@ var AuraClient = class {
139
173
  if (!this._authAdmin) this._authAdmin = new auth.AuthAdminService(this);
140
174
  return this._authAdmin;
141
175
  }
176
+ /**
177
+ * Service de base de données : requêtes sur les tables et vues, appels de fonctions SQL (`rpc`), SQL brut.
178
+ */
142
179
  get db() {
143
180
  if (!this._db) this._db = new db.DatabaseService(this);
144
181
  return this._db;
145
182
  }
183
+ /**
184
+ * Service de stockage : buckets, envoi, téléchargement, URL signées et publiques, transformations d'image.
185
+ */
146
186
  get storage() {
147
187
  if (!this._storage) this._storage = new storage.StorageService(this);
148
188
  return this._storage;
149
189
  }
190
+ /** Service temps réel : canaux, changements Postgres, diffusion (`broadcast`) et présence. */
150
191
  get realtime() {
151
192
  if (!this._realtime) this._realtime = new realtime.RealtimeService(this);
152
193
  return this._realtime;
153
194
  }
195
+ /**
196
+ * Service Edge Functions : invocation, et gestion des jobs et du cron avec une clé `service_role`.
197
+ */
154
198
  get functions() {
155
199
  if (!this._functions) this._functions = new functions.FunctionsService(this);
156
200
  return this._functions;
157
201
  }
202
+ /** Service IA : conversation (`chat`), embeddings, RAG (ingestion, requêtes, espaces de noms), recherche sémantique et sessions. */
158
203
  get ai() {
159
204
  if (!this._ai) this._ai = new ai.AiService(this);
160
205
  return this._ai;
161
206
  }
207
+ /**
208
+ * Service de notifications : envoi (e-mail, SMS, push, webhook), historique, modèles et administration. Exige une clé `service_role`.
209
+ */
162
210
  get notifications() {
163
211
  if (!this._notifications) this._notifications = new notifications.NotificationsService(this);
164
212
  return this._notifications;
package/dist/index.d.cts CHANGED
@@ -1,13 +1,13 @@
1
1
  export { AiService } from '@aurabase/ai';
2
2
  export { AuthAdminService, AuthService, isMfaChallenge } from '@aurabase/auth';
3
3
  import { AuraClientOptions } from '@aurabase/core';
4
- export { AdminCreateUserRequest, AdminUpdateUserRequest, AdminUser, AuditLogEntry, AuraClientOptions, AuraError, AuraErrorCode, AuraObservabilityEvent, AuraResponse, AuthChangePayload, AuthEvent, AuthSettings, AuthSettingsUpdate, BaseAuthStore, BatchSendResponse, BroadcastFilter, BroadcastPayload, BroadcastSendStatus, ChannelConfig, ChatMessage, ChatResponse, CountMode, CreatePgFunctionRequest, CreatePgTriggerRequest, CronJob, EmailTemplateUpdate, EmbedRequest, EmbedResponse, FileEntry, FilterOp, FunctionDef, IdentityInfo, Job, LocalAuthStore, LoginResponse, MagicLinkRequest, Meta, MfaChallenge, MfaEnrollResponse, MfaVerifyRequest, Notification, NotificationAttempt, NotificationDeadLetter, NotificationEvent, NotificationProviderLog, NotificationQueueStats, NotificationRule, NotificationSettings, NotificationStats, NotificationTemplate, NotificationTemplatePreview, OAuthProviderSetting, OAuthSignInOptions, PasswordResetRequest, PgExecutableRole, PgFunctionInfo, PgTriggerInfo, PostgresChangesFilter, PresenceFilter, PresenceInfo, PresenceState, QueryFilter, QueryOptions, RagIngestRequest, RagIngestResponse, RagRequest, RagResponse, RealtimeEvent, RealtimeListenType, RealtimeSubscribeStatus, SchemaColumn, SchemaEnum, SchemaFunction, SchemaFunctionArg, SchemaTable, SemanticSearchResult, SendNotificationRequest, SessionInfo, SignInRequest, SignUpRequest, StorageBucket, TokenPair, UpdateUserRequest, UploadResult, User, isAuraError } from '@aurabase/core';
4
+ export { AdminCreateUserRequest, AdminUpdateUserRequest, AdminUser, AuditLogEntry, AuraClientOptions, AuraError, AuraErrorCode, AuraObservabilityEvent, AuraResponse, AuthChangePayload, AuthEvent, AuthSettings, AuthSettingsUpdate, BaseAuthStore, BatchSendResponse, BroadcastFilter, BroadcastPayload, BroadcastSendStatus, ChannelConfig, ChatMessage, ChatResponse, CountMode, CreatePgFunctionRequest, CreatePgTriggerRequest, CronJob, EmailTemplateUpdate, EmbedRequest, EmbedResponse, FileEntry, FilterOp, FunctionDef, FunctionPermissions, IdentityInfo, Job, LocalAuthStore, LoginResponse, MagicLinkRequest, Meta, MfaChallenge, MfaEnrollResponse, MfaVerifyRequest, Notification, NotificationAttempt, NotificationDeadLetter, NotificationEvent, NotificationProviderLog, NotificationQueueStats, NotificationRule, NotificationSettings, NotificationStats, NotificationTemplate, NotificationTemplatePreview, OAuthProviderSetting, OAuthSignInOptions, PasswordResetRequest, PgExecutableRole, PgFunctionInfo, PgTriggerInfo, PostgresChangesFilter, PresenceFilter, PresenceInfo, PresenceState, QueryFilter, QueryOptions, RagIngestRequest, RagIngestResponse, RagRequest, RagResponse, RealtimeEvent, RealtimeListenType, RealtimeSubscribeStatus, SchemaColumn, SchemaEnum, SchemaFunction, SchemaFunctionArg, SchemaTable, SemanticSearchResult, SendNotificationRequest, SessionInfo, SignInRequest, SignUpRequest, StorageBucket, TokenPair, UpdateUserRequest, UploadResult, User, isAuraError } from '@aurabase/core';
5
5
  export { DatabaseService, QueryBuilder } from '@aurabase/db';
6
6
  export { FunctionsHttpError, FunctionsRelayError, FunctionsResponseType, FunctionsService, isRelayStatus } from '@aurabase/functions';
7
7
  export { NotificationsAdminService, NotificationsService } from '@aurabase/notifications';
8
8
  export { AuraChannel, RealtimeService } from '@aurabase/realtime';
9
9
  export { StorageBucketClient, StorageService } from '@aurabase/storage';
10
- import { A as AuraClient } from './AuraClient-5jDiXjrO.cjs';
10
+ import { A as AuraClient } from './AuraClient-BWdcX_k0.cjs';
11
11
 
12
12
  /**
13
13
  * Create a new Aurabase client instance.
@@ -38,7 +38,7 @@ declare function createClient<Database = any>(baseUrl: string, apiKey: string, o
38
38
  * @example
39
39
  * ```ts
40
40
  * // server-side only (API route, edge function, backend)
41
- * const admin = createAdminClient(projectUrl, process.env.SERVICE_ROLE_KEY!)
41
+ * const admin = createAdminClient(projectUrl, process.env.AURABASE_SERVICE_ROLE_KEY!)
42
42
  * await admin.authAdmin.listUsers()
43
43
  * ```
44
44
  */
package/dist/index.d.ts CHANGED
@@ -1,13 +1,13 @@
1
1
  export { AiService } from '@aurabase/ai';
2
2
  export { AuthAdminService, AuthService, isMfaChallenge } from '@aurabase/auth';
3
3
  import { AuraClientOptions } from '@aurabase/core';
4
- export { AdminCreateUserRequest, AdminUpdateUserRequest, AdminUser, AuditLogEntry, AuraClientOptions, AuraError, AuraErrorCode, AuraObservabilityEvent, AuraResponse, AuthChangePayload, AuthEvent, AuthSettings, AuthSettingsUpdate, BaseAuthStore, BatchSendResponse, BroadcastFilter, BroadcastPayload, BroadcastSendStatus, ChannelConfig, ChatMessage, ChatResponse, CountMode, CreatePgFunctionRequest, CreatePgTriggerRequest, CronJob, EmailTemplateUpdate, EmbedRequest, EmbedResponse, FileEntry, FilterOp, FunctionDef, IdentityInfo, Job, LocalAuthStore, LoginResponse, MagicLinkRequest, Meta, MfaChallenge, MfaEnrollResponse, MfaVerifyRequest, Notification, NotificationAttempt, NotificationDeadLetter, NotificationEvent, NotificationProviderLog, NotificationQueueStats, NotificationRule, NotificationSettings, NotificationStats, NotificationTemplate, NotificationTemplatePreview, OAuthProviderSetting, OAuthSignInOptions, PasswordResetRequest, PgExecutableRole, PgFunctionInfo, PgTriggerInfo, PostgresChangesFilter, PresenceFilter, PresenceInfo, PresenceState, QueryFilter, QueryOptions, RagIngestRequest, RagIngestResponse, RagRequest, RagResponse, RealtimeEvent, RealtimeListenType, RealtimeSubscribeStatus, SchemaColumn, SchemaEnum, SchemaFunction, SchemaFunctionArg, SchemaTable, SemanticSearchResult, SendNotificationRequest, SessionInfo, SignInRequest, SignUpRequest, StorageBucket, TokenPair, UpdateUserRequest, UploadResult, User, isAuraError } from '@aurabase/core';
4
+ export { AdminCreateUserRequest, AdminUpdateUserRequest, AdminUser, AuditLogEntry, AuraClientOptions, AuraError, AuraErrorCode, AuraObservabilityEvent, AuraResponse, AuthChangePayload, AuthEvent, AuthSettings, AuthSettingsUpdate, BaseAuthStore, BatchSendResponse, BroadcastFilter, BroadcastPayload, BroadcastSendStatus, ChannelConfig, ChatMessage, ChatResponse, CountMode, CreatePgFunctionRequest, CreatePgTriggerRequest, CronJob, EmailTemplateUpdate, EmbedRequest, EmbedResponse, FileEntry, FilterOp, FunctionDef, FunctionPermissions, IdentityInfo, Job, LocalAuthStore, LoginResponse, MagicLinkRequest, Meta, MfaChallenge, MfaEnrollResponse, MfaVerifyRequest, Notification, NotificationAttempt, NotificationDeadLetter, NotificationEvent, NotificationProviderLog, NotificationQueueStats, NotificationRule, NotificationSettings, NotificationStats, NotificationTemplate, NotificationTemplatePreview, OAuthProviderSetting, OAuthSignInOptions, PasswordResetRequest, PgExecutableRole, PgFunctionInfo, PgTriggerInfo, PostgresChangesFilter, PresenceFilter, PresenceInfo, PresenceState, QueryFilter, QueryOptions, RagIngestRequest, RagIngestResponse, RagRequest, RagResponse, RealtimeEvent, RealtimeListenType, RealtimeSubscribeStatus, SchemaColumn, SchemaEnum, SchemaFunction, SchemaFunctionArg, SchemaTable, SemanticSearchResult, SendNotificationRequest, SessionInfo, SignInRequest, SignUpRequest, StorageBucket, TokenPair, UpdateUserRequest, UploadResult, User, isAuraError } from '@aurabase/core';
5
5
  export { DatabaseService, QueryBuilder } from '@aurabase/db';
6
6
  export { FunctionsHttpError, FunctionsRelayError, FunctionsResponseType, FunctionsService, isRelayStatus } from '@aurabase/functions';
7
7
  export { NotificationsAdminService, NotificationsService } from '@aurabase/notifications';
8
8
  export { AuraChannel, RealtimeService } from '@aurabase/realtime';
9
9
  export { StorageBucketClient, StorageService } from '@aurabase/storage';
10
- import { A as AuraClient } from './AuraClient-5jDiXjrO.js';
10
+ import { A as AuraClient } from './AuraClient-BWdcX_k0.js';
11
11
 
12
12
  /**
13
13
  * Create a new Aurabase client instance.
@@ -38,7 +38,7 @@ declare function createClient<Database = any>(baseUrl: string, apiKey: string, o
38
38
  * @example
39
39
  * ```ts
40
40
  * // server-side only (API route, edge function, backend)
41
- * const admin = createAdminClient(projectUrl, process.env.SERVICE_ROLE_KEY!)
41
+ * const admin = createAdminClient(projectUrl, process.env.AURABASE_SERVICE_ROLE_KEY!)
42
42
  * await admin.authAdmin.listUsers()
43
43
  * ```
44
44
  */
package/dist/index.js CHANGED
@@ -27,9 +27,21 @@ var SERVICE_ROLE_KEY_PREFIX = "aura_sk_";
27
27
  var AuraClient = class {
28
28
  /** URL du projet (`https://<slug>.aurabase.cloud`), sans barre finale. */
29
29
  baseUrl;
30
+ /**
31
+ * Clé API du projet (`anon` ou `service_role`) envoyée dans l'en-tête `apikey` ; `null` si aucune n'a été fournie.
32
+ */
30
33
  apiKey;
34
+ /**
35
+ * Fonction `fetch` utilisée pour toutes les requêtes (celle de `options.fetch`, sinon `globalThis.fetch`).
36
+ */
31
37
  fetchFn;
38
+ /**
39
+ * Magasin de session (jeton d'accès, jeton de rafraîchissement, utilisateur) : mémoire, `localStorage` ou cookies selon le contexte.
40
+ */
32
41
  authStore;
42
+ /**
43
+ * Politique de reprise des requêtes de lecture (`GET`, `HEAD`) sur erreur transitoire : activée ou non, et nombre maximal de reprises.
44
+ */
33
45
  retryConfig;
34
46
  /** Timeout par défaut (ms) des requêtes JSON sans signal. `undefined` → défaut core (30s). */
35
47
  requestTimeoutMs;
@@ -55,6 +67,21 @@ var AuraClient = class {
55
67
  * @param apiKey Clé API du projet (`aura_anon_…`, `aura_auth_…`, `aura_sk_…`).
56
68
  */
57
69
  constructor(baseUrl, apiKey, options) {
70
+ if (typeof baseUrl !== "string" || baseUrl.trim() === "") {
71
+ throw new Error(
72
+ "[aurabase] Project URL is required: set NEXT_PUBLIC_AURABASE_URL to the project URL shown in Studio \u203A Settings \u203A Connection (e.g. http://<slug>.localhost:8080), then pass it to createClient(url, key)."
73
+ );
74
+ }
75
+ if (!/^https?:\/\//i.test(baseUrl.trim())) {
76
+ throw new Error(
77
+ `[aurabase] baseUrl must start with http:// or https:// (got "${baseUrl}"): copy the project URL from Studio \u203A Settings \u203A Connection (e.g. http://<slug>.localhost:8080).`
78
+ );
79
+ }
80
+ if (apiKey === void 0 || apiKey === null) {
81
+ throw new Error(
82
+ "[aurabase] API key is required: set NEXT_PUBLIC_AURABASE_ANON_KEY (browser) or AURABASE_SERVICE_ROLE_KEY (server only) to a key shown in Studio \u203A Settings \u203A Connection, then pass it to createClient(url, key)."
83
+ );
84
+ }
58
85
  this.baseUrl = baseUrl.replace(/\/+$/, "");
59
86
  const resolvedOptions = options;
60
87
  this.apiKey = apiKey || null;
@@ -117,6 +144,9 @@ var AuraClient = class {
117
144
  this._realtime?.disconnect();
118
145
  }
119
146
  // -- Lazy service getters ---------------------------------------------------
147
+ /**
148
+ * Service d'authentification : inscription, connexion, session, MFA, OAuth, identités. Créé à la première utilisation.
149
+ */
120
150
  get auth() {
121
151
  if (!this._auth) {
122
152
  this._auth = new AuthService(this, {
@@ -136,6 +166,10 @@ var AuraClient = class {
136
166
  }
137
167
  return this._auth;
138
168
  }
169
+ /**
170
+ * API d'administration de l'authentification (utilisateurs, sessions, journal d'audit, modèles d'e-mail).
171
+ * Exige une clé `service_role` et lève une erreur dans un navigateur : utilisez `createAdminClient()` côté serveur.
172
+ */
139
173
  get authAdmin() {
140
174
  if (isBrowserContext()) {
141
175
  throw new Error(
@@ -145,26 +179,40 @@ var AuraClient = class {
145
179
  if (!this._authAdmin) this._authAdmin = new AuthAdminService(this);
146
180
  return this._authAdmin;
147
181
  }
182
+ /**
183
+ * Service de base de données : requêtes sur les tables et vues, appels de fonctions SQL (`rpc`), SQL brut.
184
+ */
148
185
  get db() {
149
186
  if (!this._db) this._db = new DatabaseService(this);
150
187
  return this._db;
151
188
  }
189
+ /**
190
+ * Service de stockage : buckets, envoi, téléchargement, URL signées et publiques, transformations d'image.
191
+ */
152
192
  get storage() {
153
193
  if (!this._storage) this._storage = new StorageService(this);
154
194
  return this._storage;
155
195
  }
196
+ /** Service temps réel : canaux, changements Postgres, diffusion (`broadcast`) et présence. */
156
197
  get realtime() {
157
198
  if (!this._realtime) this._realtime = new RealtimeService(this);
158
199
  return this._realtime;
159
200
  }
201
+ /**
202
+ * Service Edge Functions : invocation, et gestion des jobs et du cron avec une clé `service_role`.
203
+ */
160
204
  get functions() {
161
205
  if (!this._functions) this._functions = new FunctionsService(this);
162
206
  return this._functions;
163
207
  }
208
+ /** Service IA : conversation (`chat`), embeddings, RAG (ingestion, requêtes, espaces de noms), recherche sémantique et sessions. */
164
209
  get ai() {
165
210
  if (!this._ai) this._ai = new AiService(this);
166
211
  return this._ai;
167
212
  }
213
+ /**
214
+ * Service de notifications : envoi (e-mail, SMS, push, webhook), historique, modèles et administration. Exige une clé `service_role`.
215
+ */
168
216
  get notifications() {
169
217
  if (!this._notifications) this._notifications = new NotificationsService(this);
170
218
  return this._notifications;
package/dist/nextjs.cjs CHANGED
@@ -21,9 +21,21 @@ var SERVICE_ROLE_KEY_PREFIX = "aura_sk_";
21
21
  var AuraClient = class {
22
22
  /** URL du projet (`https://<slug>.aurabase.cloud`), sans barre finale. */
23
23
  baseUrl;
24
+ /**
25
+ * Clé API du projet (`anon` ou `service_role`) envoyée dans l'en-tête `apikey` ; `null` si aucune n'a été fournie.
26
+ */
24
27
  apiKey;
28
+ /**
29
+ * Fonction `fetch` utilisée pour toutes les requêtes (celle de `options.fetch`, sinon `globalThis.fetch`).
30
+ */
25
31
  fetchFn;
32
+ /**
33
+ * Magasin de session (jeton d'accès, jeton de rafraîchissement, utilisateur) : mémoire, `localStorage` ou cookies selon le contexte.
34
+ */
26
35
  authStore;
36
+ /**
37
+ * Politique de reprise des requêtes de lecture (`GET`, `HEAD`) sur erreur transitoire : activée ou non, et nombre maximal de reprises.
38
+ */
27
39
  retryConfig;
28
40
  /** Timeout par défaut (ms) des requêtes JSON sans signal. `undefined` → défaut core (30s). */
29
41
  requestTimeoutMs;
@@ -49,6 +61,21 @@ var AuraClient = class {
49
61
  * @param apiKey Clé API du projet (`aura_anon_…`, `aura_auth_…`, `aura_sk_…`).
50
62
  */
51
63
  constructor(baseUrl, apiKey, options) {
64
+ if (typeof baseUrl !== "string" || baseUrl.trim() === "") {
65
+ throw new Error(
66
+ "[aurabase] Project URL is required: set NEXT_PUBLIC_AURABASE_URL to the project URL shown in Studio \u203A Settings \u203A Connection (e.g. http://<slug>.localhost:8080), then pass it to createClient(url, key)."
67
+ );
68
+ }
69
+ if (!/^https?:\/\//i.test(baseUrl.trim())) {
70
+ throw new Error(
71
+ `[aurabase] baseUrl must start with http:// or https:// (got "${baseUrl}"): copy the project URL from Studio \u203A Settings \u203A Connection (e.g. http://<slug>.localhost:8080).`
72
+ );
73
+ }
74
+ if (apiKey === void 0 || apiKey === null) {
75
+ throw new Error(
76
+ "[aurabase] API key is required: set NEXT_PUBLIC_AURABASE_ANON_KEY (browser) or AURABASE_SERVICE_ROLE_KEY (server only) to a key shown in Studio \u203A Settings \u203A Connection, then pass it to createClient(url, key)."
77
+ );
78
+ }
52
79
  this.baseUrl = baseUrl.replace(/\/+$/, "");
53
80
  const resolvedOptions = options;
54
81
  this.apiKey = apiKey || null;
@@ -111,6 +138,9 @@ var AuraClient = class {
111
138
  this._realtime?.disconnect();
112
139
  }
113
140
  // -- Lazy service getters ---------------------------------------------------
141
+ /**
142
+ * Service d'authentification : inscription, connexion, session, MFA, OAuth, identités. Créé à la première utilisation.
143
+ */
114
144
  get auth() {
115
145
  if (!this._auth) {
116
146
  this._auth = new auth$1.AuthService(this, {
@@ -130,6 +160,10 @@ var AuraClient = class {
130
160
  }
131
161
  return this._auth;
132
162
  }
163
+ /**
164
+ * API d'administration de l'authentification (utilisateurs, sessions, journal d'audit, modèles d'e-mail).
165
+ * Exige une clé `service_role` et lève une erreur dans un navigateur : utilisez `createAdminClient()` côté serveur.
166
+ */
133
167
  get authAdmin() {
134
168
  if (isBrowserContext()) {
135
169
  throw new Error(
@@ -139,26 +173,40 @@ var AuraClient = class {
139
173
  if (!this._authAdmin) this._authAdmin = new auth$1.AuthAdminService(this);
140
174
  return this._authAdmin;
141
175
  }
176
+ /**
177
+ * Service de base de données : requêtes sur les tables et vues, appels de fonctions SQL (`rpc`), SQL brut.
178
+ */
142
179
  get db() {
143
180
  if (!this._db) this._db = new db.DatabaseService(this);
144
181
  return this._db;
145
182
  }
183
+ /**
184
+ * Service de stockage : buckets, envoi, téléchargement, URL signées et publiques, transformations d'image.
185
+ */
146
186
  get storage() {
147
187
  if (!this._storage) this._storage = new storage.StorageService(this);
148
188
  return this._storage;
149
189
  }
190
+ /** Service temps réel : canaux, changements Postgres, diffusion (`broadcast`) et présence. */
150
191
  get realtime() {
151
192
  if (!this._realtime) this._realtime = new realtime.RealtimeService(this);
152
193
  return this._realtime;
153
194
  }
195
+ /**
196
+ * Service Edge Functions : invocation, et gestion des jobs et du cron avec une clé `service_role`.
197
+ */
154
198
  get functions() {
155
199
  if (!this._functions) this._functions = new functions.FunctionsService(this);
156
200
  return this._functions;
157
201
  }
202
+ /** Service IA : conversation (`chat`), embeddings, RAG (ingestion, requêtes, espaces de noms), recherche sémantique et sessions. */
158
203
  get ai() {
159
204
  if (!this._ai) this._ai = new ai.AiService(this);
160
205
  return this._ai;
161
206
  }
207
+ /**
208
+ * Service de notifications : envoi (e-mail, SMS, push, webhook), historique, modèles et administration. Exige une clé `service_role`.
209
+ */
162
210
  get notifications() {
163
211
  if (!this._notifications) this._notifications = new notifications.NotificationsService(this);
164
212
  return this._notifications;
@@ -230,7 +278,7 @@ function createServerClient(baseUrl, apiKey, options) {
230
278
  const defaultCookieOpts = {
231
279
  path: "/",
232
280
  secure: baseUrl.startsWith("https://"),
233
- sameSite: "Lax",
281
+ sameSite: "lax",
234
282
  httpOnly: true,
235
283
  maxAge: 60 * 60 * 24 * 30,
236
284
  // 30 days
@@ -292,8 +340,8 @@ function createAuthMiddleware(options = {}) {
292
340
  );
293
341
  }
294
342
  const { NextResponse } = nextServer;
295
- const projectUrl = options.projectUrl ?? process.env.NEXT_PUBLIC_AURABASE_URL ?? process.env.AURABASE_URL ?? "";
296
- const anonKey = options.anonKey ?? process.env.NEXT_PUBLIC_AURABASE_ANON_KEY ?? process.env.AURABASE_ANON_KEY ?? "";
343
+ const projectUrl = options.projectUrl ?? process.env.NEXT_PUBLIC_AURABASE_URL ?? "";
344
+ const anonKey = options.anonKey ?? process.env.NEXT_PUBLIC_AURABASE_ANON_KEY ?? "";
297
345
  if (!projectUrl || !anonKey) {
298
346
  console.warn(
299
347
  "[@aurabase/nextjs] Variables d'environnement manquantes : NEXT_PUBLIC_AURABASE_URL ou NEXT_PUBLIC_AURABASE_ANON_KEY non d\xE9finies."
@@ -337,8 +385,8 @@ function createAuthMiddleware(options = {}) {
337
385
  };
338
386
  }
339
387
  function createClientForServerComponent(cookieStore, projectUrl, apiKey) {
340
- const url = projectUrl ?? process.env.NEXT_PUBLIC_AURABASE_URL ?? process.env.AURABASE_URL ?? "";
341
- const key = apiKey ?? process.env.NEXT_PUBLIC_AURABASE_ANON_KEY ?? process.env.AURABASE_ANON_KEY ?? "";
388
+ const url = projectUrl ?? process.env.NEXT_PUBLIC_AURABASE_URL ?? "";
389
+ const key = apiKey ?? process.env.NEXT_PUBLIC_AURABASE_ANON_KEY ?? "";
342
390
  return createServerClient(url, key, {
343
391
  cookies: {
344
392
  getAll: () => cookieStore.getAll(),
@@ -348,8 +396,8 @@ function createClientForServerComponent(cookieStore, projectUrl, apiKey) {
348
396
  });
349
397
  }
350
398
  function createClientForServerAction(cookieStore, projectUrl, apiKey) {
351
- const url = projectUrl ?? process.env.NEXT_PUBLIC_AURABASE_URL ?? process.env.AURABASE_URL ?? "";
352
- const key = apiKey ?? process.env.NEXT_PUBLIC_AURABASE_ANON_KEY ?? process.env.AURABASE_ANON_KEY ?? "";
399
+ const url = projectUrl ?? process.env.NEXT_PUBLIC_AURABASE_URL ?? "";
400
+ const key = apiKey ?? process.env.NEXT_PUBLIC_AURABASE_ANON_KEY ?? "";
353
401
  return createServerClient(url, key, {
354
402
  cookies: {
355
403
  getAll: () => cookieStore.getAll(),
package/dist/nextjs.d.cts CHANGED
@@ -1,4 +1,4 @@
1
- import { A as AuraClient } from './AuraClient-5jDiXjrO.cjs';
1
+ import { A as AuraClient } from './AuraClient-BWdcX_k0.cjs';
2
2
  import { User, Session } from '@aurabase/core';
3
3
  import '@aurabase/ai';
4
4
  import '@aurabase/auth';
@@ -53,9 +53,9 @@ interface AuthContextParam {
53
53
  request: NextRequestLike;
54
54
  }
55
55
  interface AuthMiddlewareOptions {
56
- /** Project URL (defaults to process.env.NEXT_PUBLIC_AURABASE_URL or process.env.AURABASE_URL). */
56
+ /** Project URL (defaults to process.env.NEXT_PUBLIC_AURABASE_URL — J1-004 : seul nom reconnu). */
57
57
  projectUrl?: string;
58
- /** Anon API Key (defaults to process.env.NEXT_PUBLIC_AURABASE_ANON_KEY or process.env.AURABASE_ANON_KEY). */
58
+ /** Anon API Key (defaults to process.env.NEXT_PUBLIC_AURABASE_ANON_KEY — J1-004 : seul nom reconnu). */
59
59
  anonKey?: string;
60
60
  /** List of route patterns that do not require authentication (e.g. ['/', '/login', '/signup', '/auth/*']). */
61
61
  publicRoutes?: string[];
package/dist/nextjs.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { A as AuraClient } from './AuraClient-5jDiXjrO.js';
1
+ import { A as AuraClient } from './AuraClient-BWdcX_k0.js';
2
2
  import { User, Session } from '@aurabase/core';
3
3
  import '@aurabase/ai';
4
4
  import '@aurabase/auth';
@@ -53,9 +53,9 @@ interface AuthContextParam {
53
53
  request: NextRequestLike;
54
54
  }
55
55
  interface AuthMiddlewareOptions {
56
- /** Project URL (defaults to process.env.NEXT_PUBLIC_AURABASE_URL or process.env.AURABASE_URL). */
56
+ /** Project URL (defaults to process.env.NEXT_PUBLIC_AURABASE_URL — J1-004 : seul nom reconnu). */
57
57
  projectUrl?: string;
58
- /** Anon API Key (defaults to process.env.NEXT_PUBLIC_AURABASE_ANON_KEY or process.env.AURABASE_ANON_KEY). */
58
+ /** Anon API Key (defaults to process.env.NEXT_PUBLIC_AURABASE_ANON_KEY — J1-004 : seul nom reconnu). */
59
59
  anonKey?: string;
60
60
  /** List of route patterns that do not require authentication (e.g. ['/', '/login', '/signup', '/auth/*']). */
61
61
  publicRoutes?: string[];
package/dist/nextjs.js CHANGED
@@ -19,9 +19,21 @@ var SERVICE_ROLE_KEY_PREFIX = "aura_sk_";
19
19
  var AuraClient = class {
20
20
  /** URL du projet (`https://<slug>.aurabase.cloud`), sans barre finale. */
21
21
  baseUrl;
22
+ /**
23
+ * Clé API du projet (`anon` ou `service_role`) envoyée dans l'en-tête `apikey` ; `null` si aucune n'a été fournie.
24
+ */
22
25
  apiKey;
26
+ /**
27
+ * Fonction `fetch` utilisée pour toutes les requêtes (celle de `options.fetch`, sinon `globalThis.fetch`).
28
+ */
23
29
  fetchFn;
30
+ /**
31
+ * Magasin de session (jeton d'accès, jeton de rafraîchissement, utilisateur) : mémoire, `localStorage` ou cookies selon le contexte.
32
+ */
24
33
  authStore;
34
+ /**
35
+ * Politique de reprise des requêtes de lecture (`GET`, `HEAD`) sur erreur transitoire : activée ou non, et nombre maximal de reprises.
36
+ */
25
37
  retryConfig;
26
38
  /** Timeout par défaut (ms) des requêtes JSON sans signal. `undefined` → défaut core (30s). */
27
39
  requestTimeoutMs;
@@ -47,6 +59,21 @@ var AuraClient = class {
47
59
  * @param apiKey Clé API du projet (`aura_anon_…`, `aura_auth_…`, `aura_sk_…`).
48
60
  */
49
61
  constructor(baseUrl, apiKey, options) {
62
+ if (typeof baseUrl !== "string" || baseUrl.trim() === "") {
63
+ throw new Error(
64
+ "[aurabase] Project URL is required: set NEXT_PUBLIC_AURABASE_URL to the project URL shown in Studio \u203A Settings \u203A Connection (e.g. http://<slug>.localhost:8080), then pass it to createClient(url, key)."
65
+ );
66
+ }
67
+ if (!/^https?:\/\//i.test(baseUrl.trim())) {
68
+ throw new Error(
69
+ `[aurabase] baseUrl must start with http:// or https:// (got "${baseUrl}"): copy the project URL from Studio \u203A Settings \u203A Connection (e.g. http://<slug>.localhost:8080).`
70
+ );
71
+ }
72
+ if (apiKey === void 0 || apiKey === null) {
73
+ throw new Error(
74
+ "[aurabase] API key is required: set NEXT_PUBLIC_AURABASE_ANON_KEY (browser) or AURABASE_SERVICE_ROLE_KEY (server only) to a key shown in Studio \u203A Settings \u203A Connection, then pass it to createClient(url, key)."
75
+ );
76
+ }
50
77
  this.baseUrl = baseUrl.replace(/\/+$/, "");
51
78
  const resolvedOptions = options;
52
79
  this.apiKey = apiKey || null;
@@ -109,6 +136,9 @@ var AuraClient = class {
109
136
  this._realtime?.disconnect();
110
137
  }
111
138
  // -- Lazy service getters ---------------------------------------------------
139
+ /**
140
+ * Service d'authentification : inscription, connexion, session, MFA, OAuth, identités. Créé à la première utilisation.
141
+ */
112
142
  get auth() {
113
143
  if (!this._auth) {
114
144
  this._auth = new AuthService(this, {
@@ -128,6 +158,10 @@ var AuraClient = class {
128
158
  }
129
159
  return this._auth;
130
160
  }
161
+ /**
162
+ * API d'administration de l'authentification (utilisateurs, sessions, journal d'audit, modèles d'e-mail).
163
+ * Exige une clé `service_role` et lève une erreur dans un navigateur : utilisez `createAdminClient()` côté serveur.
164
+ */
131
165
  get authAdmin() {
132
166
  if (isBrowserContext()) {
133
167
  throw new Error(
@@ -137,26 +171,40 @@ var AuraClient = class {
137
171
  if (!this._authAdmin) this._authAdmin = new AuthAdminService(this);
138
172
  return this._authAdmin;
139
173
  }
174
+ /**
175
+ * Service de base de données : requêtes sur les tables et vues, appels de fonctions SQL (`rpc`), SQL brut.
176
+ */
140
177
  get db() {
141
178
  if (!this._db) this._db = new DatabaseService(this);
142
179
  return this._db;
143
180
  }
181
+ /**
182
+ * Service de stockage : buckets, envoi, téléchargement, URL signées et publiques, transformations d'image.
183
+ */
144
184
  get storage() {
145
185
  if (!this._storage) this._storage = new StorageService(this);
146
186
  return this._storage;
147
187
  }
188
+ /** Service temps réel : canaux, changements Postgres, diffusion (`broadcast`) et présence. */
148
189
  get realtime() {
149
190
  if (!this._realtime) this._realtime = new RealtimeService(this);
150
191
  return this._realtime;
151
192
  }
193
+ /**
194
+ * Service Edge Functions : invocation, et gestion des jobs et du cron avec une clé `service_role`.
195
+ */
152
196
  get functions() {
153
197
  if (!this._functions) this._functions = new FunctionsService(this);
154
198
  return this._functions;
155
199
  }
200
+ /** Service IA : conversation (`chat`), embeddings, RAG (ingestion, requêtes, espaces de noms), recherche sémantique et sessions. */
156
201
  get ai() {
157
202
  if (!this._ai) this._ai = new AiService(this);
158
203
  return this._ai;
159
204
  }
205
+ /**
206
+ * Service de notifications : envoi (e-mail, SMS, push, webhook), historique, modèles et administration. Exige une clé `service_role`.
207
+ */
160
208
  get notifications() {
161
209
  if (!this._notifications) this._notifications = new NotificationsService(this);
162
210
  return this._notifications;
@@ -228,7 +276,7 @@ function createServerClient(baseUrl, apiKey, options) {
228
276
  const defaultCookieOpts = {
229
277
  path: "/",
230
278
  secure: baseUrl.startsWith("https://"),
231
- sameSite: "Lax",
279
+ sameSite: "lax",
232
280
  httpOnly: true,
233
281
  maxAge: 60 * 60 * 24 * 30,
234
282
  // 30 days
@@ -290,8 +338,8 @@ function createAuthMiddleware(options = {}) {
290
338
  );
291
339
  }
292
340
  const { NextResponse } = nextServer;
293
- const projectUrl = options.projectUrl ?? process.env.NEXT_PUBLIC_AURABASE_URL ?? process.env.AURABASE_URL ?? "";
294
- const anonKey = options.anonKey ?? process.env.NEXT_PUBLIC_AURABASE_ANON_KEY ?? process.env.AURABASE_ANON_KEY ?? "";
341
+ const projectUrl = options.projectUrl ?? process.env.NEXT_PUBLIC_AURABASE_URL ?? "";
342
+ const anonKey = options.anonKey ?? process.env.NEXT_PUBLIC_AURABASE_ANON_KEY ?? "";
295
343
  if (!projectUrl || !anonKey) {
296
344
  console.warn(
297
345
  "[@aurabase/nextjs] Variables d'environnement manquantes : NEXT_PUBLIC_AURABASE_URL ou NEXT_PUBLIC_AURABASE_ANON_KEY non d\xE9finies."
@@ -335,8 +383,8 @@ function createAuthMiddleware(options = {}) {
335
383
  };
336
384
  }
337
385
  function createClientForServerComponent(cookieStore, projectUrl, apiKey) {
338
- const url = projectUrl ?? process.env.NEXT_PUBLIC_AURABASE_URL ?? process.env.AURABASE_URL ?? "";
339
- const key = apiKey ?? process.env.NEXT_PUBLIC_AURABASE_ANON_KEY ?? process.env.AURABASE_ANON_KEY ?? "";
386
+ const url = projectUrl ?? process.env.NEXT_PUBLIC_AURABASE_URL ?? "";
387
+ const key = apiKey ?? process.env.NEXT_PUBLIC_AURABASE_ANON_KEY ?? "";
340
388
  return createServerClient(url, key, {
341
389
  cookies: {
342
390
  getAll: () => cookieStore.getAll(),
@@ -346,8 +394,8 @@ function createClientForServerComponent(cookieStore, projectUrl, apiKey) {
346
394
  });
347
395
  }
348
396
  function createClientForServerAction(cookieStore, projectUrl, apiKey) {
349
- const url = projectUrl ?? process.env.NEXT_PUBLIC_AURABASE_URL ?? process.env.AURABASE_URL ?? "";
350
- const key = apiKey ?? process.env.NEXT_PUBLIC_AURABASE_ANON_KEY ?? process.env.AURABASE_ANON_KEY ?? "";
397
+ const url = projectUrl ?? process.env.NEXT_PUBLIC_AURABASE_URL ?? "";
398
+ const key = apiKey ?? process.env.NEXT_PUBLIC_AURABASE_ANON_KEY ?? "";
351
399
  return createServerClient(url, key, {
352
400
  cookies: {
353
401
  getAll: () => cookieStore.getAll(),
package/dist/react.d.cts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { User, Session } from '@aurabase/core';
2
- import { A as AuraClient } from './AuraClient-5jDiXjrO.cjs';
2
+ import { A as AuraClient } from './AuraClient-BWdcX_k0.cjs';
3
3
  import '@aurabase/ai';
4
4
  import '@aurabase/auth';
5
5
  import '@aurabase/db';
package/dist/react.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { User, Session } from '@aurabase/core';
2
- import { A as AuraClient } from './AuraClient-5jDiXjrO.js';
2
+ import { A as AuraClient } from './AuraClient-BWdcX_k0.js';
3
3
  import '@aurabase/ai';
4
4
  import '@aurabase/auth';
5
5
  import '@aurabase/db';
package/dist/ssr.cjs CHANGED
@@ -21,9 +21,21 @@ var SERVICE_ROLE_KEY_PREFIX = "aura_sk_";
21
21
  var AuraClient = class {
22
22
  /** URL du projet (`https://<slug>.aurabase.cloud`), sans barre finale. */
23
23
  baseUrl;
24
+ /**
25
+ * Clé API du projet (`anon` ou `service_role`) envoyée dans l'en-tête `apikey` ; `null` si aucune n'a été fournie.
26
+ */
24
27
  apiKey;
28
+ /**
29
+ * Fonction `fetch` utilisée pour toutes les requêtes (celle de `options.fetch`, sinon `globalThis.fetch`).
30
+ */
25
31
  fetchFn;
32
+ /**
33
+ * Magasin de session (jeton d'accès, jeton de rafraîchissement, utilisateur) : mémoire, `localStorage` ou cookies selon le contexte.
34
+ */
26
35
  authStore;
36
+ /**
37
+ * Politique de reprise des requêtes de lecture (`GET`, `HEAD`) sur erreur transitoire : activée ou non, et nombre maximal de reprises.
38
+ */
27
39
  retryConfig;
28
40
  /** Timeout par défaut (ms) des requêtes JSON sans signal. `undefined` → défaut core (30s). */
29
41
  requestTimeoutMs;
@@ -49,6 +61,21 @@ var AuraClient = class {
49
61
  * @param apiKey Clé API du projet (`aura_anon_…`, `aura_auth_…`, `aura_sk_…`).
50
62
  */
51
63
  constructor(baseUrl, apiKey, options) {
64
+ if (typeof baseUrl !== "string" || baseUrl.trim() === "") {
65
+ throw new Error(
66
+ "[aurabase] Project URL is required: set NEXT_PUBLIC_AURABASE_URL to the project URL shown in Studio \u203A Settings \u203A Connection (e.g. http://<slug>.localhost:8080), then pass it to createClient(url, key)."
67
+ );
68
+ }
69
+ if (!/^https?:\/\//i.test(baseUrl.trim())) {
70
+ throw new Error(
71
+ `[aurabase] baseUrl must start with http:// or https:// (got "${baseUrl}"): copy the project URL from Studio \u203A Settings \u203A Connection (e.g. http://<slug>.localhost:8080).`
72
+ );
73
+ }
74
+ if (apiKey === void 0 || apiKey === null) {
75
+ throw new Error(
76
+ "[aurabase] API key is required: set NEXT_PUBLIC_AURABASE_ANON_KEY (browser) or AURABASE_SERVICE_ROLE_KEY (server only) to a key shown in Studio \u203A Settings \u203A Connection, then pass it to createClient(url, key)."
77
+ );
78
+ }
52
79
  this.baseUrl = baseUrl.replace(/\/+$/, "");
53
80
  const resolvedOptions = options;
54
81
  this.apiKey = apiKey || null;
@@ -111,6 +138,9 @@ var AuraClient = class {
111
138
  this._realtime?.disconnect();
112
139
  }
113
140
  // -- Lazy service getters ---------------------------------------------------
141
+ /**
142
+ * Service d'authentification : inscription, connexion, session, MFA, OAuth, identités. Créé à la première utilisation.
143
+ */
114
144
  get auth() {
115
145
  if (!this._auth) {
116
146
  this._auth = new auth.AuthService(this, {
@@ -130,6 +160,10 @@ var AuraClient = class {
130
160
  }
131
161
  return this._auth;
132
162
  }
163
+ /**
164
+ * API d'administration de l'authentification (utilisateurs, sessions, journal d'audit, modèles d'e-mail).
165
+ * Exige une clé `service_role` et lève une erreur dans un navigateur : utilisez `createAdminClient()` côté serveur.
166
+ */
133
167
  get authAdmin() {
134
168
  if (isBrowserContext()) {
135
169
  throw new Error(
@@ -139,26 +173,40 @@ var AuraClient = class {
139
173
  if (!this._authAdmin) this._authAdmin = new auth.AuthAdminService(this);
140
174
  return this._authAdmin;
141
175
  }
176
+ /**
177
+ * Service de base de données : requêtes sur les tables et vues, appels de fonctions SQL (`rpc`), SQL brut.
178
+ */
142
179
  get db() {
143
180
  if (!this._db) this._db = new db.DatabaseService(this);
144
181
  return this._db;
145
182
  }
183
+ /**
184
+ * Service de stockage : buckets, envoi, téléchargement, URL signées et publiques, transformations d'image.
185
+ */
146
186
  get storage() {
147
187
  if (!this._storage) this._storage = new storage.StorageService(this);
148
188
  return this._storage;
149
189
  }
190
+ /** Service temps réel : canaux, changements Postgres, diffusion (`broadcast`) et présence. */
150
191
  get realtime() {
151
192
  if (!this._realtime) this._realtime = new realtime.RealtimeService(this);
152
193
  return this._realtime;
153
194
  }
195
+ /**
196
+ * Service Edge Functions : invocation, et gestion des jobs et du cron avec une clé `service_role`.
197
+ */
154
198
  get functions() {
155
199
  if (!this._functions) this._functions = new functions.FunctionsService(this);
156
200
  return this._functions;
157
201
  }
202
+ /** Service IA : conversation (`chat`), embeddings, RAG (ingestion, requêtes, espaces de noms), recherche sémantique et sessions. */
158
203
  get ai() {
159
204
  if (!this._ai) this._ai = new ai.AiService(this);
160
205
  return this._ai;
161
206
  }
207
+ /**
208
+ * Service de notifications : envoi (e-mail, SMS, push, webhook), historique, modèles et administration. Exige une clé `service_role`.
209
+ */
162
210
  get notifications() {
163
211
  if (!this._notifications) this._notifications = new notifications.NotificationsService(this);
164
212
  return this._notifications;
@@ -230,7 +278,7 @@ function createServerClient(baseUrl, apiKey, options) {
230
278
  const defaultCookieOpts = {
231
279
  path: "/",
232
280
  secure: baseUrl.startsWith("https://"),
233
- sameSite: "Lax",
281
+ sameSite: "lax",
234
282
  httpOnly: true,
235
283
  maxAge: 60 * 60 * 24 * 30,
236
284
  // 30 days
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-5jDiXjrO.cjs';
3
+ import { A as AuraClient } from './AuraClient-BWdcX_k0.cjs';
4
4
  import '@aurabase/ai';
5
5
  import '@aurabase/auth';
6
6
  import '@aurabase/db';
@@ -18,7 +18,7 @@ import '@aurabase/storage';
18
18
  *
19
19
  * export async function middleware(request) {
20
20
  * let response = NextResponse.next({ request })
21
- * const client = createServerClient(PROJECT_URL, ANON_KEY, {
21
+ * const client = createServerClient(NEXT_PUBLIC_AURABASE_URL, NEXT_PUBLIC_AURABASE_ANON_KEY, {
22
22
  * cookies: {
23
23
  * getAll: () => request.cookies.getAll(),
24
24
  * setAll: (cookies) => {
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-5jDiXjrO.js';
3
+ import { A as AuraClient } from './AuraClient-BWdcX_k0.js';
4
4
  import '@aurabase/ai';
5
5
  import '@aurabase/auth';
6
6
  import '@aurabase/db';
@@ -18,7 +18,7 @@ import '@aurabase/storage';
18
18
  *
19
19
  * export async function middleware(request) {
20
20
  * let response = NextResponse.next({ request })
21
- * const client = createServerClient(PROJECT_URL, ANON_KEY, {
21
+ * const client = createServerClient(NEXT_PUBLIC_AURABASE_URL, NEXT_PUBLIC_AURABASE_ANON_KEY, {
22
22
  * cookies: {
23
23
  * getAll: () => request.cookies.getAll(),
24
24
  * setAll: (cookies) => {
package/dist/ssr.js CHANGED
@@ -20,9 +20,21 @@ var SERVICE_ROLE_KEY_PREFIX = "aura_sk_";
20
20
  var AuraClient = class {
21
21
  /** URL du projet (`https://<slug>.aurabase.cloud`), sans barre finale. */
22
22
  baseUrl;
23
+ /**
24
+ * Clé API du projet (`anon` ou `service_role`) envoyée dans l'en-tête `apikey` ; `null` si aucune n'a été fournie.
25
+ */
23
26
  apiKey;
27
+ /**
28
+ * Fonction `fetch` utilisée pour toutes les requêtes (celle de `options.fetch`, sinon `globalThis.fetch`).
29
+ */
24
30
  fetchFn;
31
+ /**
32
+ * Magasin de session (jeton d'accès, jeton de rafraîchissement, utilisateur) : mémoire, `localStorage` ou cookies selon le contexte.
33
+ */
25
34
  authStore;
35
+ /**
36
+ * Politique de reprise des requêtes de lecture (`GET`, `HEAD`) sur erreur transitoire : activée ou non, et nombre maximal de reprises.
37
+ */
26
38
  retryConfig;
27
39
  /** Timeout par défaut (ms) des requêtes JSON sans signal. `undefined` → défaut core (30s). */
28
40
  requestTimeoutMs;
@@ -48,6 +60,21 @@ var AuraClient = class {
48
60
  * @param apiKey Clé API du projet (`aura_anon_…`, `aura_auth_…`, `aura_sk_…`).
49
61
  */
50
62
  constructor(baseUrl, apiKey, options) {
63
+ if (typeof baseUrl !== "string" || baseUrl.trim() === "") {
64
+ throw new Error(
65
+ "[aurabase] Project URL is required: set NEXT_PUBLIC_AURABASE_URL to the project URL shown in Studio \u203A Settings \u203A Connection (e.g. http://<slug>.localhost:8080), then pass it to createClient(url, key)."
66
+ );
67
+ }
68
+ if (!/^https?:\/\//i.test(baseUrl.trim())) {
69
+ throw new Error(
70
+ `[aurabase] baseUrl must start with http:// or https:// (got "${baseUrl}"): copy the project URL from Studio \u203A Settings \u203A Connection (e.g. http://<slug>.localhost:8080).`
71
+ );
72
+ }
73
+ if (apiKey === void 0 || apiKey === null) {
74
+ throw new Error(
75
+ "[aurabase] API key is required: set NEXT_PUBLIC_AURABASE_ANON_KEY (browser) or AURABASE_SERVICE_ROLE_KEY (server only) to a key shown in Studio \u203A Settings \u203A Connection, then pass it to createClient(url, key)."
76
+ );
77
+ }
51
78
  this.baseUrl = baseUrl.replace(/\/+$/, "");
52
79
  const resolvedOptions = options;
53
80
  this.apiKey = apiKey || null;
@@ -110,6 +137,9 @@ var AuraClient = class {
110
137
  this._realtime?.disconnect();
111
138
  }
112
139
  // -- Lazy service getters ---------------------------------------------------
140
+ /**
141
+ * Service d'authentification : inscription, connexion, session, MFA, OAuth, identités. Créé à la première utilisation.
142
+ */
113
143
  get auth() {
114
144
  if (!this._auth) {
115
145
  this._auth = new AuthService(this, {
@@ -129,6 +159,10 @@ var AuraClient = class {
129
159
  }
130
160
  return this._auth;
131
161
  }
162
+ /**
163
+ * API d'administration de l'authentification (utilisateurs, sessions, journal d'audit, modèles d'e-mail).
164
+ * Exige une clé `service_role` et lève une erreur dans un navigateur : utilisez `createAdminClient()` côté serveur.
165
+ */
132
166
  get authAdmin() {
133
167
  if (isBrowserContext()) {
134
168
  throw new Error(
@@ -138,26 +172,40 @@ var AuraClient = class {
138
172
  if (!this._authAdmin) this._authAdmin = new AuthAdminService(this);
139
173
  return this._authAdmin;
140
174
  }
175
+ /**
176
+ * Service de base de données : requêtes sur les tables et vues, appels de fonctions SQL (`rpc`), SQL brut.
177
+ */
141
178
  get db() {
142
179
  if (!this._db) this._db = new DatabaseService(this);
143
180
  return this._db;
144
181
  }
182
+ /**
183
+ * Service de stockage : buckets, envoi, téléchargement, URL signées et publiques, transformations d'image.
184
+ */
145
185
  get storage() {
146
186
  if (!this._storage) this._storage = new StorageService(this);
147
187
  return this._storage;
148
188
  }
189
+ /** Service temps réel : canaux, changements Postgres, diffusion (`broadcast`) et présence. */
149
190
  get realtime() {
150
191
  if (!this._realtime) this._realtime = new RealtimeService(this);
151
192
  return this._realtime;
152
193
  }
194
+ /**
195
+ * Service Edge Functions : invocation, et gestion des jobs et du cron avec une clé `service_role`.
196
+ */
153
197
  get functions() {
154
198
  if (!this._functions) this._functions = new FunctionsService(this);
155
199
  return this._functions;
156
200
  }
201
+ /** Service IA : conversation (`chat`), embeddings, RAG (ingestion, requêtes, espaces de noms), recherche sémantique et sessions. */
157
202
  get ai() {
158
203
  if (!this._ai) this._ai = new AiService(this);
159
204
  return this._ai;
160
205
  }
206
+ /**
207
+ * Service de notifications : envoi (e-mail, SMS, push, webhook), historique, modèles et administration. Exige une clé `service_role`.
208
+ */
161
209
  get notifications() {
162
210
  if (!this._notifications) this._notifications = new NotificationsService(this);
163
211
  return this._notifications;
@@ -229,7 +277,7 @@ function createServerClient(baseUrl, apiKey, options) {
229
277
  const defaultCookieOpts = {
230
278
  path: "/",
231
279
  secure: baseUrl.startsWith("https://"),
232
- sameSite: "Lax",
280
+ sameSite: "lax",
233
281
  httpOnly: true,
234
282
  maxAge: 60 * 60 * 24 * 30,
235
283
  // 30 days
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aurabase/aurabase-js",
3
- "version": "0.6.0",
3
+ "version": "0.6.2",
4
4
  "description": "Official JavaScript/TypeScript client for Aurabase BaaS",
5
5
  "type": "module",
6
6
  "main": "dist/index.cjs",
@@ -61,12 +61,12 @@
61
61
  "author": "Aurabase",
62
62
  "repository": {
63
63
  "type": "git",
64
- "url": "git+https://github.com/daylami555/aurabase.git",
64
+ "url": "git+https://github.com/Aurabase-cloud/Aurabase.git",
65
65
  "directory": "aurabase-js/packages/aurabase"
66
66
  },
67
67
  "homepage": "https://aurabase.cloud",
68
68
  "bugs": {
69
- "url": "https://github.com/daylami555/aurabase/issues"
69
+ "url": "https://github.com/Aurabase-cloud/Aurabase/issues"
70
70
  },
71
71
  "keywords": [
72
72
  "aurabase",
@@ -76,14 +76,14 @@
76
76
  "client"
77
77
  ],
78
78
  "dependencies": {
79
- "@aurabase/core": "0.6.0",
80
- "@aurabase/storage": "0.6.0",
81
- "@aurabase/db": "0.6.0",
82
- "@aurabase/auth": "0.6.0",
83
- "@aurabase/functions": "0.6.0",
84
- "@aurabase/ai": "0.6.0",
85
- "@aurabase/notifications": "0.6.0",
86
- "@aurabase/realtime": "0.6.0"
79
+ "@aurabase/core": "0.6.2",
80
+ "@aurabase/auth": "0.6.2",
81
+ "@aurabase/db": "0.6.2",
82
+ "@aurabase/storage": "0.6.2",
83
+ "@aurabase/realtime": "0.6.2",
84
+ "@aurabase/functions": "0.6.2",
85
+ "@aurabase/ai": "0.6.2",
86
+ "@aurabase/notifications": "0.6.2"
87
87
  },
88
88
  "devDependencies": {
89
89
  "@types/node": "20.14.15",