@aurabase/aurabase-js 0.4.1 → 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/README.md +3 -7
- package/dist/{AuraClient-BcFE8u1v.d.cts → AuraClient-0WhqmK0u.d.cts} +17 -7
- package/dist/{AuraClient-BcFE8u1v.d.ts → AuraClient-0WhqmK0u.d.ts} +17 -7
- package/dist/index.cjs +48 -43
- package/dist/index.d.cts +17 -16
- package/dist/index.d.ts +17 -16
- package/dist/index.js +24 -19
- package/dist/ssr.cjs +23 -16
- package/dist/ssr.d.cts +7 -8
- package/dist/ssr.d.ts +7 -8
- package/dist/ssr.js +24 -17
- package/package.json +9 -9
package/README.md
CHANGED
|
@@ -16,8 +16,8 @@ npm i @aurabase/aurabase-js
|
|
|
16
16
|
|
|
17
17
|
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.
|
|
18
18
|
|
|
19
|
-
- `createClient(
|
|
20
|
-
- `createAdminClient(
|
|
19
|
+
- `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
|
+
- `createAdminClient(projectUrl, serviceRoleKey, options?)` — client serveur avec `authAdmin` (clé `service_role`, jamais côté navigateur).
|
|
21
21
|
- `aurabase/ssr` — `createServerClient`/`createBrowserClient` pour Next.js et frameworks SSR (cookies, session partagée serveur/navigateur).
|
|
22
22
|
|
|
23
23
|
## Quick Start
|
|
@@ -25,11 +25,7 @@ Ce package ne réimplémente aucune logique de service : il compose `AuthService
|
|
|
25
25
|
```ts
|
|
26
26
|
import { createClient } from '@aurabase/aurabase-js'
|
|
27
27
|
|
|
28
|
-
const aura = createClient(
|
|
29
|
-
'http://localhost:8080',
|
|
30
|
-
'00000000-0000-0000-0000-000000000001',
|
|
31
|
-
'aura_anon_xxx',
|
|
32
|
-
)
|
|
28
|
+
const aura = createClient('https://mon-projet.aurabase.cloud', 'aura_anon_xxx')
|
|
33
29
|
|
|
34
30
|
const { data, error } = await aura.db
|
|
35
31
|
.from('posts')
|
|
@@ -1,25 +1,31 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { AiService } from '@aurabase/ai';
|
|
2
2
|
import { AuthService, AuthAdminService } from '@aurabase/auth';
|
|
3
|
+
import { AuraClientLike, BaseAuthStore, AuraObservabilityEvent, AuraClientOptions, ChannelConfig } from '@aurabase/core';
|
|
3
4
|
import { DatabaseService } from '@aurabase/db';
|
|
4
|
-
import { StorageService } from '@aurabase/storage';
|
|
5
|
-
import { RealtimeService, AuraChannel } from '@aurabase/realtime';
|
|
6
5
|
import { FunctionsService } from '@aurabase/functions';
|
|
7
|
-
import { AiService } from '@aurabase/ai';
|
|
8
6
|
import { NotificationsService } from '@aurabase/notifications';
|
|
7
|
+
import { RealtimeService, AuraChannel } from '@aurabase/realtime';
|
|
8
|
+
import { StorageService } from '@aurabase/storage';
|
|
9
9
|
|
|
10
10
|
/**
|
|
11
11
|
* Main Aurabase client.
|
|
12
12
|
*
|
|
13
|
+
* L'URL EST le projet : chaque projet est servi sur son propre sous-domaine
|
|
14
|
+
* (`https://<slug>.aurabase.cloud`), et la passerelle résout le tenant depuis l'hôte puis
|
|
15
|
+
* injecte le `project_id` dans le chemin (`inject_project_id`,
|
|
16
|
+
* `services/aura-gateway/src/middleware/project_subdomain.rs`). Aucun identifiant de projet
|
|
17
|
+
* n'est donc écrit ni transporté par le client.
|
|
18
|
+
*
|
|
13
19
|
* @example
|
|
14
20
|
* ```ts
|
|
15
21
|
* import { createClient } from '@aurabase/aurabase-js'
|
|
16
|
-
* const aura = createClient('
|
|
22
|
+
* const aura = createClient('https://mon-projet.aurabase.cloud', 'aura_anon_xxx')
|
|
17
23
|
* const { data } = await aura.db.from('posts').eq('published', true)
|
|
18
24
|
* ```
|
|
19
25
|
*/
|
|
20
26
|
declare class AuraClient<Database = any> implements AuraClientLike {
|
|
27
|
+
/** URL du projet (`https://<slug>.aurabase.cloud`), sans barre finale. */
|
|
21
28
|
readonly baseUrl: string;
|
|
22
|
-
readonly projectId: string;
|
|
23
29
|
readonly apiKey: string | null;
|
|
24
30
|
readonly fetchFn: typeof globalThis.fetch;
|
|
25
31
|
readonly authStore: BaseAuthStore;
|
|
@@ -45,7 +51,11 @@ declare class AuraClient<Database = any> implements AuraClientLike {
|
|
|
45
51
|
private readonly _persistSession;
|
|
46
52
|
private readonly _autoRefresh;
|
|
47
53
|
private readonly _detectSessionInUrl;
|
|
48
|
-
|
|
54
|
+
/**
|
|
55
|
+
* @param baseUrl URL du projet (`https://<slug>.aurabase.cloud`).
|
|
56
|
+
* @param apiKey Clé API du projet (`aura_anon_…`, `aura_auth_…`, `aura_sk_…`).
|
|
57
|
+
*/
|
|
58
|
+
constructor(baseUrl: string, apiKey: string, options?: AuraClientOptions);
|
|
49
59
|
/**
|
|
50
60
|
* Démonte le client : arrête le refresh proactif (ticker + visibilité + BroadcastChannel),
|
|
51
61
|
* déconnecte le realtime, vide les listeners d'auth. Idempotent. À appeler en teardown
|
|
@@ -1,25 +1,31 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { AiService } from '@aurabase/ai';
|
|
2
2
|
import { AuthService, AuthAdminService } from '@aurabase/auth';
|
|
3
|
+
import { AuraClientLike, BaseAuthStore, AuraObservabilityEvent, AuraClientOptions, ChannelConfig } from '@aurabase/core';
|
|
3
4
|
import { DatabaseService } from '@aurabase/db';
|
|
4
|
-
import { StorageService } from '@aurabase/storage';
|
|
5
|
-
import { RealtimeService, AuraChannel } from '@aurabase/realtime';
|
|
6
5
|
import { FunctionsService } from '@aurabase/functions';
|
|
7
|
-
import { AiService } from '@aurabase/ai';
|
|
8
6
|
import { NotificationsService } from '@aurabase/notifications';
|
|
7
|
+
import { RealtimeService, AuraChannel } from '@aurabase/realtime';
|
|
8
|
+
import { StorageService } from '@aurabase/storage';
|
|
9
9
|
|
|
10
10
|
/**
|
|
11
11
|
* Main Aurabase client.
|
|
12
12
|
*
|
|
13
|
+
* L'URL EST le projet : chaque projet est servi sur son propre sous-domaine
|
|
14
|
+
* (`https://<slug>.aurabase.cloud`), et la passerelle résout le tenant depuis l'hôte puis
|
|
15
|
+
* injecte le `project_id` dans le chemin (`inject_project_id`,
|
|
16
|
+
* `services/aura-gateway/src/middleware/project_subdomain.rs`). Aucun identifiant de projet
|
|
17
|
+
* n'est donc écrit ni transporté par le client.
|
|
18
|
+
*
|
|
13
19
|
* @example
|
|
14
20
|
* ```ts
|
|
15
21
|
* import { createClient } from '@aurabase/aurabase-js'
|
|
16
|
-
* const aura = createClient('
|
|
22
|
+
* const aura = createClient('https://mon-projet.aurabase.cloud', 'aura_anon_xxx')
|
|
17
23
|
* const { data } = await aura.db.from('posts').eq('published', true)
|
|
18
24
|
* ```
|
|
19
25
|
*/
|
|
20
26
|
declare class AuraClient<Database = any> implements AuraClientLike {
|
|
27
|
+
/** URL du projet (`https://<slug>.aurabase.cloud`), sans barre finale. */
|
|
21
28
|
readonly baseUrl: string;
|
|
22
|
-
readonly projectId: string;
|
|
23
29
|
readonly apiKey: string | null;
|
|
24
30
|
readonly fetchFn: typeof globalThis.fetch;
|
|
25
31
|
readonly authStore: BaseAuthStore;
|
|
@@ -45,7 +51,11 @@ declare class AuraClient<Database = any> implements AuraClientLike {
|
|
|
45
51
|
private readonly _persistSession;
|
|
46
52
|
private readonly _autoRefresh;
|
|
47
53
|
private readonly _detectSessionInUrl;
|
|
48
|
-
|
|
54
|
+
/**
|
|
55
|
+
* @param baseUrl URL du projet (`https://<slug>.aurabase.cloud`).
|
|
56
|
+
* @param apiKey Clé API du projet (`aura_anon_…`, `aura_auth_…`, `aura_sk_…`).
|
|
57
|
+
*/
|
|
58
|
+
constructor(baseUrl: string, apiKey: string, options?: AuraClientOptions);
|
|
49
59
|
/**
|
|
50
60
|
* Démonte le client : arrête le refresh proactif (ticker + visibilité + BroadcastChannel),
|
|
51
61
|
* déconnecte le realtime, vide les listeners d'auth. Idempotent. À appeler en teardown
|
package/dist/index.cjs
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var ai = require('@aurabase/ai');
|
|
4
4
|
var auth = require('@aurabase/auth');
|
|
5
|
+
var core = require('@aurabase/core');
|
|
5
6
|
var db = require('@aurabase/db');
|
|
6
|
-
var storage = require('@aurabase/storage');
|
|
7
|
-
var realtime = require('@aurabase/realtime');
|
|
8
7
|
var functions = require('@aurabase/functions');
|
|
9
|
-
var ai = require('@aurabase/ai');
|
|
10
8
|
var notifications = require('@aurabase/notifications');
|
|
9
|
+
var realtime = require('@aurabase/realtime');
|
|
10
|
+
var storage = require('@aurabase/storage');
|
|
11
11
|
|
|
12
|
-
// src/
|
|
12
|
+
// src/index.ts
|
|
13
13
|
function isBrowserContext() {
|
|
14
14
|
if (typeof window !== "undefined") return true;
|
|
15
15
|
const g = globalThis;
|
|
@@ -19,8 +19,8 @@ function isBrowserContext() {
|
|
|
19
19
|
}
|
|
20
20
|
var SERVICE_ROLE_KEY_PREFIX = "aura_sk_";
|
|
21
21
|
var AuraClient = class {
|
|
22
|
+
/** URL du projet (`https://<slug>.aurabase.cloud`), sans barre finale. */
|
|
22
23
|
baseUrl;
|
|
23
|
-
projectId;
|
|
24
24
|
apiKey;
|
|
25
25
|
fetchFn;
|
|
26
26
|
authStore;
|
|
@@ -44,11 +44,14 @@ var AuraClient = class {
|
|
|
44
44
|
_persistSession;
|
|
45
45
|
_autoRefresh;
|
|
46
46
|
_detectSessionInUrl;
|
|
47
|
-
|
|
47
|
+
/**
|
|
48
|
+
* @param baseUrl URL du projet (`https://<slug>.aurabase.cloud`).
|
|
49
|
+
* @param apiKey Clé API du projet (`aura_anon_…`, `aura_auth_…`, `aura_sk_…`).
|
|
50
|
+
*/
|
|
51
|
+
constructor(baseUrl, apiKey, options) {
|
|
48
52
|
this.baseUrl = baseUrl.replace(/\/+$/, "");
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
this.apiKey = typeof apiKeyOrOptions === "string" ? apiKeyOrOptions : apiKeyOrOptions?.apiKey ?? null;
|
|
53
|
+
const resolvedOptions = options;
|
|
54
|
+
this.apiKey = apiKey || null;
|
|
52
55
|
this.fetchFn = resolvedOptions?.fetch ?? globalThis.fetch.bind(globalThis);
|
|
53
56
|
const r = resolvedOptions?.retry;
|
|
54
57
|
this.retryConfig = r === false ? { enabled: false, maxRetries: 0 } : r === void 0 || r === true ? { enabled: true, maxRetries: core.DEFAULT_MAX_RETRIES } : { enabled: r.enabled ?? true, maxRetries: r.maxRetries ?? core.DEFAULT_MAX_RETRIES };
|
|
@@ -74,7 +77,7 @@ var AuraClient = class {
|
|
|
74
77
|
} else if (resolvedOptions?.auth?.persistSession === false) {
|
|
75
78
|
this.authStore = new core.BaseAuthStore();
|
|
76
79
|
} else if (typeof localStorage !== "undefined") {
|
|
77
|
-
this.authStore = new core.LocalAuthStore();
|
|
80
|
+
this.authStore = new core.LocalAuthStore(`aura-${core.clientScope(this.baseUrl)}-auth`);
|
|
78
81
|
} else {
|
|
79
82
|
this.authStore = new core.BaseAuthStore();
|
|
80
83
|
}
|
|
@@ -156,33 +159,23 @@ var AuraClient = class {
|
|
|
156
159
|
return this.realtime.channel(name, options);
|
|
157
160
|
}
|
|
158
161
|
};
|
|
159
|
-
|
|
160
|
-
|
|
162
|
+
|
|
163
|
+
// src/index.ts
|
|
164
|
+
function createClient(baseUrl, apiKey, options) {
|
|
165
|
+
return new AuraClient(baseUrl, apiKey, options);
|
|
161
166
|
}
|
|
162
|
-
function createAdminClient(baseUrl,
|
|
167
|
+
function createAdminClient(baseUrl, serviceRoleKey, options) {
|
|
163
168
|
if (isBrowserContext()) {
|
|
164
169
|
throw new Error(
|
|
165
170
|
"[aurabase] createAdminClient() ne doit jamais \xEAtre appel\xE9 c\xF4t\xE9 navigateur : la cl\xE9 service_role serait expos\xE9e dans le bundle. \xC0 utiliser uniquement c\xF4t\xE9 serveur."
|
|
166
171
|
);
|
|
167
172
|
}
|
|
168
|
-
return new AuraClient(baseUrl,
|
|
173
|
+
return new AuraClient(baseUrl, serviceRoleKey, options);
|
|
169
174
|
}
|
|
170
175
|
|
|
171
|
-
Object.defineProperty(exports, "
|
|
172
|
-
enumerable: true,
|
|
173
|
-
get: function () { return core.AuraError; }
|
|
174
|
-
});
|
|
175
|
-
Object.defineProperty(exports, "BaseAuthStore", {
|
|
176
|
-
enumerable: true,
|
|
177
|
-
get: function () { return core.BaseAuthStore; }
|
|
178
|
-
});
|
|
179
|
-
Object.defineProperty(exports, "LocalAuthStore", {
|
|
180
|
-
enumerable: true,
|
|
181
|
-
get: function () { return core.LocalAuthStore; }
|
|
182
|
-
});
|
|
183
|
-
Object.defineProperty(exports, "isAuraError", {
|
|
176
|
+
Object.defineProperty(exports, "AiService", {
|
|
184
177
|
enumerable: true,
|
|
185
|
-
get: function () { return
|
|
178
|
+
get: function () { return ai.AiService; }
|
|
186
179
|
});
|
|
187
180
|
Object.defineProperty(exports, "AuthAdminService", {
|
|
188
181
|
enumerable: true,
|
|
@@ -196,33 +189,33 @@ Object.defineProperty(exports, "isMfaChallenge", {
|
|
|
196
189
|
enumerable: true,
|
|
197
190
|
get: function () { return auth.isMfaChallenge; }
|
|
198
191
|
});
|
|
199
|
-
Object.defineProperty(exports, "
|
|
192
|
+
Object.defineProperty(exports, "AuraError", {
|
|
200
193
|
enumerable: true,
|
|
201
|
-
get: function () { return
|
|
194
|
+
get: function () { return core.AuraError; }
|
|
202
195
|
});
|
|
203
|
-
Object.defineProperty(exports, "
|
|
196
|
+
Object.defineProperty(exports, "BaseAuthStore", {
|
|
204
197
|
enumerable: true,
|
|
205
|
-
get: function () { return
|
|
198
|
+
get: function () { return core.BaseAuthStore; }
|
|
206
199
|
});
|
|
207
|
-
Object.defineProperty(exports, "
|
|
200
|
+
Object.defineProperty(exports, "LocalAuthStore", {
|
|
208
201
|
enumerable: true,
|
|
209
|
-
get: function () { return
|
|
202
|
+
get: function () { return core.LocalAuthStore; }
|
|
210
203
|
});
|
|
211
|
-
Object.defineProperty(exports, "
|
|
204
|
+
Object.defineProperty(exports, "isAuraError", {
|
|
212
205
|
enumerable: true,
|
|
213
|
-
get: function () { return
|
|
206
|
+
get: function () { return core.isAuraError; }
|
|
214
207
|
});
|
|
215
|
-
Object.defineProperty(exports, "
|
|
208
|
+
Object.defineProperty(exports, "DatabaseService", {
|
|
216
209
|
enumerable: true,
|
|
217
|
-
get: function () { return
|
|
210
|
+
get: function () { return db.DatabaseService; }
|
|
218
211
|
});
|
|
219
|
-
Object.defineProperty(exports, "
|
|
212
|
+
Object.defineProperty(exports, "QueryBuilder", {
|
|
220
213
|
enumerable: true,
|
|
221
|
-
get: function () { return
|
|
214
|
+
get: function () { return db.QueryBuilder; }
|
|
222
215
|
});
|
|
223
|
-
Object.defineProperty(exports, "
|
|
216
|
+
Object.defineProperty(exports, "FunctionsService", {
|
|
224
217
|
enumerable: true,
|
|
225
|
-
get: function () { return
|
|
218
|
+
get: function () { return functions.FunctionsService; }
|
|
226
219
|
});
|
|
227
220
|
Object.defineProperty(exports, "NotificationsAdminService", {
|
|
228
221
|
enumerable: true,
|
|
@@ -232,6 +225,18 @@ Object.defineProperty(exports, "NotificationsService", {
|
|
|
232
225
|
enumerable: true,
|
|
233
226
|
get: function () { return notifications.NotificationsService; }
|
|
234
227
|
});
|
|
228
|
+
Object.defineProperty(exports, "AuraChannel", {
|
|
229
|
+
enumerable: true,
|
|
230
|
+
get: function () { return realtime.AuraChannel; }
|
|
231
|
+
});
|
|
232
|
+
Object.defineProperty(exports, "RealtimeService", {
|
|
233
|
+
enumerable: true,
|
|
234
|
+
get: function () { return realtime.RealtimeService; }
|
|
235
|
+
});
|
|
236
|
+
Object.defineProperty(exports, "StorageService", {
|
|
237
|
+
enumerable: true,
|
|
238
|
+
get: function () { return storage.StorageService; }
|
|
239
|
+
});
|
|
235
240
|
exports.AuraClient = AuraClient;
|
|
236
241
|
exports.createAdminClient = createAdminClient;
|
|
237
242
|
exports.createClient = createClient;
|
package/dist/index.d.cts
CHANGED
|
@@ -1,32 +1,33 @@
|
|
|
1
|
-
|
|
1
|
+
export { AiService } from '@aurabase/ai';
|
|
2
|
+
export { AuthAdminService, AuthService, isMfaChallenge } from '@aurabase/auth';
|
|
2
3
|
import { AuraClientOptions } from '@aurabase/core';
|
|
3
|
-
export { AdminCreateUserRequest, AdminUpdateUserRequest, AdminUser, AuditLogEntry, AuraClientOptions, AuraError, AuraErrorCode, AuraObservabilityEvent, AuraResponse, AuthChangePayload, AuthEvent, AuthSettings, BaseAuthStore, BatchSendResponse, BroadcastFilter, BroadcastPayload, ChannelConfig, ChatMessage, ChatResponse, CountMode, 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, OAuthSignInOptions, PasswordResetRequest, PostgresChangesFilter, PresenceFilter, PresenceInfo, PresenceState, QueryFilter, QueryOptions, RagIngestRequest, RagIngestResponse, RagRequest, RagResponse, RealtimeEvent, RealtimeListenType, RealtimeSubscribeStatus, SchemaColumn, 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, 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
5
|
export { DatabaseService, QueryBuilder } from '@aurabase/db';
|
|
5
|
-
export { AuthAdminService, AuthService, isMfaChallenge } from '@aurabase/auth';
|
|
6
|
-
export { StorageService } from '@aurabase/storage';
|
|
7
|
-
export { AuraChannel, RealtimeService } from '@aurabase/realtime';
|
|
8
6
|
export { FunctionsService } from '@aurabase/functions';
|
|
9
|
-
export { AiService } from '@aurabase/ai';
|
|
10
7
|
export { NotificationsAdminService, NotificationsService } from '@aurabase/notifications';
|
|
8
|
+
export { AuraChannel, RealtimeService } from '@aurabase/realtime';
|
|
9
|
+
export { StorageService } from '@aurabase/storage';
|
|
10
|
+
import { A as AuraClient } from './AuraClient-0WhqmK0u.cjs';
|
|
11
11
|
|
|
12
12
|
/**
|
|
13
13
|
* Create a new Aurabase client instance.
|
|
14
14
|
*
|
|
15
|
+
* **L'URL est le projet.** Chaque projet est servi sur son propre sous-domaine
|
|
16
|
+
* (`https://<slug>.aurabase.cloud`) : la passerelle résout le tenant depuis l'hôte et
|
|
17
|
+
* injecte elle-même le `project_id` dans le chemin. Aucun identifiant de projet ne figure
|
|
18
|
+
* donc dans le code client — l'URL de connexion du projet suffit, avec sa clé.
|
|
19
|
+
*
|
|
15
20
|
* @example
|
|
16
21
|
* ```ts
|
|
17
|
-
*
|
|
18
|
-
* const aura = createClient('http://localhost:8080', 'project-uuid', 'aura_anon_xxx')
|
|
22
|
+
* const aura = createClient('https://mon-projet.aurabase.cloud', 'aura_anon_xxx')
|
|
19
23
|
*
|
|
20
|
-
* //
|
|
21
|
-
* const aura = createClient('
|
|
24
|
+
* // Avec options
|
|
25
|
+
* const aura = createClient('https://mon-projet.aurabase.cloud', 'aura_anon_xxx', {
|
|
22
26
|
* auth: { persistSession: true }
|
|
23
27
|
* })
|
|
24
|
-
*
|
|
25
|
-
* // Without API key (backward compatible)
|
|
26
|
-
* const aura = createClient('http://localhost:8080', 'project-uuid')
|
|
27
28
|
* ```
|
|
28
29
|
*/
|
|
29
|
-
declare function createClient<Database = any>(baseUrl: string,
|
|
30
|
+
declare function createClient<Database = any>(baseUrl: string, apiKey: string, options?: AuraClientOptions): AuraClient<Database>;
|
|
30
31
|
/**
|
|
31
32
|
* Crée un client à usage **SERVEUR uniquement** pour les opérations d'administration
|
|
32
33
|
* (`client.authAdmin` : lister/créer/bannir des utilisateurs, lire l'audit). Exige une
|
|
@@ -37,10 +38,10 @@ declare function createClient<Database = any>(baseUrl: string, projectId: string
|
|
|
37
38
|
* @example
|
|
38
39
|
* ```ts
|
|
39
40
|
* // server-side only (API route, edge function, backend)
|
|
40
|
-
* const admin = createAdminClient(
|
|
41
|
+
* const admin = createAdminClient(projectUrl, process.env.SERVICE_ROLE_KEY!)
|
|
41
42
|
* await admin.authAdmin.listUsers()
|
|
42
43
|
* ```
|
|
43
44
|
*/
|
|
44
|
-
declare function createAdminClient<Database = any>(baseUrl: string,
|
|
45
|
+
declare function createAdminClient<Database = any>(baseUrl: string, serviceRoleKey: string, options?: AuraClientOptions): AuraClient<Database>;
|
|
45
46
|
|
|
46
47
|
export { AuraClient, createAdminClient, createClient };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,32 +1,33 @@
|
|
|
1
|
-
|
|
1
|
+
export { AiService } from '@aurabase/ai';
|
|
2
|
+
export { AuthAdminService, AuthService, isMfaChallenge } from '@aurabase/auth';
|
|
2
3
|
import { AuraClientOptions } from '@aurabase/core';
|
|
3
|
-
export { AdminCreateUserRequest, AdminUpdateUserRequest, AdminUser, AuditLogEntry, AuraClientOptions, AuraError, AuraErrorCode, AuraObservabilityEvent, AuraResponse, AuthChangePayload, AuthEvent, AuthSettings, BaseAuthStore, BatchSendResponse, BroadcastFilter, BroadcastPayload, ChannelConfig, ChatMessage, ChatResponse, CountMode, 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, OAuthSignInOptions, PasswordResetRequest, PostgresChangesFilter, PresenceFilter, PresenceInfo, PresenceState, QueryFilter, QueryOptions, RagIngestRequest, RagIngestResponse, RagRequest, RagResponse, RealtimeEvent, RealtimeListenType, RealtimeSubscribeStatus, SchemaColumn, 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, 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
5
|
export { DatabaseService, QueryBuilder } from '@aurabase/db';
|
|
5
|
-
export { AuthAdminService, AuthService, isMfaChallenge } from '@aurabase/auth';
|
|
6
|
-
export { StorageService } from '@aurabase/storage';
|
|
7
|
-
export { AuraChannel, RealtimeService } from '@aurabase/realtime';
|
|
8
6
|
export { FunctionsService } from '@aurabase/functions';
|
|
9
|
-
export { AiService } from '@aurabase/ai';
|
|
10
7
|
export { NotificationsAdminService, NotificationsService } from '@aurabase/notifications';
|
|
8
|
+
export { AuraChannel, RealtimeService } from '@aurabase/realtime';
|
|
9
|
+
export { StorageService } from '@aurabase/storage';
|
|
10
|
+
import { A as AuraClient } from './AuraClient-0WhqmK0u.js';
|
|
11
11
|
|
|
12
12
|
/**
|
|
13
13
|
* Create a new Aurabase client instance.
|
|
14
14
|
*
|
|
15
|
+
* **L'URL est le projet.** Chaque projet est servi sur son propre sous-domaine
|
|
16
|
+
* (`https://<slug>.aurabase.cloud`) : la passerelle résout le tenant depuis l'hôte et
|
|
17
|
+
* injecte elle-même le `project_id` dans le chemin. Aucun identifiant de projet ne figure
|
|
18
|
+
* donc dans le code client — l'URL de connexion du projet suffit, avec sa clé.
|
|
19
|
+
*
|
|
15
20
|
* @example
|
|
16
21
|
* ```ts
|
|
17
|
-
*
|
|
18
|
-
* const aura = createClient('http://localhost:8080', 'project-uuid', 'aura_anon_xxx')
|
|
22
|
+
* const aura = createClient('https://mon-projet.aurabase.cloud', 'aura_anon_xxx')
|
|
19
23
|
*
|
|
20
|
-
* //
|
|
21
|
-
* const aura = createClient('
|
|
24
|
+
* // Avec options
|
|
25
|
+
* const aura = createClient('https://mon-projet.aurabase.cloud', 'aura_anon_xxx', {
|
|
22
26
|
* auth: { persistSession: true }
|
|
23
27
|
* })
|
|
24
|
-
*
|
|
25
|
-
* // Without API key (backward compatible)
|
|
26
|
-
* const aura = createClient('http://localhost:8080', 'project-uuid')
|
|
27
28
|
* ```
|
|
28
29
|
*/
|
|
29
|
-
declare function createClient<Database = any>(baseUrl: string,
|
|
30
|
+
declare function createClient<Database = any>(baseUrl: string, apiKey: string, options?: AuraClientOptions): AuraClient<Database>;
|
|
30
31
|
/**
|
|
31
32
|
* Crée un client à usage **SERVEUR uniquement** pour les opérations d'administration
|
|
32
33
|
* (`client.authAdmin` : lister/créer/bannir des utilisateurs, lire l'audit). Exige une
|
|
@@ -37,10 +38,10 @@ declare function createClient<Database = any>(baseUrl: string, projectId: string
|
|
|
37
38
|
* @example
|
|
38
39
|
* ```ts
|
|
39
40
|
* // server-side only (API route, edge function, backend)
|
|
40
|
-
* const admin = createAdminClient(
|
|
41
|
+
* const admin = createAdminClient(projectUrl, process.env.SERVICE_ROLE_KEY!)
|
|
41
42
|
* await admin.authAdmin.listUsers()
|
|
42
43
|
* ```
|
|
43
44
|
*/
|
|
44
|
-
declare function createAdminClient<Database = any>(baseUrl: string,
|
|
45
|
+
declare function createAdminClient<Database = any>(baseUrl: string, serviceRoleKey: string, options?: AuraClientOptions): AuraClient<Database>;
|
|
45
46
|
|
|
46
47
|
export { AuraClient, createAdminClient, createClient };
|
package/dist/index.js
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export {
|
|
1
|
+
import { AiService } from '@aurabase/ai';
|
|
2
|
+
export { AiService } from '@aurabase/ai';
|
|
3
3
|
import { AuthService, AuthAdminService } from '@aurabase/auth';
|
|
4
4
|
export { AuthAdminService, AuthService, isMfaChallenge } from '@aurabase/auth';
|
|
5
|
+
import { DEFAULT_MAX_RETRIES, BaseAuthStore, LocalAuthStore, clientScope } from '@aurabase/core';
|
|
6
|
+
export { AuraError, BaseAuthStore, LocalAuthStore, isAuraError } from '@aurabase/core';
|
|
5
7
|
import { DatabaseService } from '@aurabase/db';
|
|
6
8
|
export { DatabaseService, QueryBuilder } from '@aurabase/db';
|
|
7
|
-
import { StorageService } from '@aurabase/storage';
|
|
8
|
-
export { StorageService } from '@aurabase/storage';
|
|
9
|
-
import { RealtimeService } from '@aurabase/realtime';
|
|
10
|
-
export { AuraChannel, RealtimeService } from '@aurabase/realtime';
|
|
11
9
|
import { FunctionsService } from '@aurabase/functions';
|
|
12
10
|
export { FunctionsService } from '@aurabase/functions';
|
|
13
|
-
import { AiService } from '@aurabase/ai';
|
|
14
|
-
export { AiService } from '@aurabase/ai';
|
|
15
11
|
import { NotificationsService } from '@aurabase/notifications';
|
|
16
12
|
export { NotificationsAdminService, NotificationsService } from '@aurabase/notifications';
|
|
13
|
+
import { RealtimeService } from '@aurabase/realtime';
|
|
14
|
+
export { AuraChannel, RealtimeService } from '@aurabase/realtime';
|
|
15
|
+
import { StorageService } from '@aurabase/storage';
|
|
16
|
+
export { StorageService } from '@aurabase/storage';
|
|
17
17
|
|
|
18
|
-
// src/
|
|
18
|
+
// src/index.ts
|
|
19
19
|
function isBrowserContext() {
|
|
20
20
|
if (typeof window !== "undefined") return true;
|
|
21
21
|
const g = globalThis;
|
|
@@ -25,8 +25,8 @@ function isBrowserContext() {
|
|
|
25
25
|
}
|
|
26
26
|
var SERVICE_ROLE_KEY_PREFIX = "aura_sk_";
|
|
27
27
|
var AuraClient = class {
|
|
28
|
+
/** URL du projet (`https://<slug>.aurabase.cloud`), sans barre finale. */
|
|
28
29
|
baseUrl;
|
|
29
|
-
projectId;
|
|
30
30
|
apiKey;
|
|
31
31
|
fetchFn;
|
|
32
32
|
authStore;
|
|
@@ -50,11 +50,14 @@ var AuraClient = class {
|
|
|
50
50
|
_persistSession;
|
|
51
51
|
_autoRefresh;
|
|
52
52
|
_detectSessionInUrl;
|
|
53
|
-
|
|
53
|
+
/**
|
|
54
|
+
* @param baseUrl URL du projet (`https://<slug>.aurabase.cloud`).
|
|
55
|
+
* @param apiKey Clé API du projet (`aura_anon_…`, `aura_auth_…`, `aura_sk_…`).
|
|
56
|
+
*/
|
|
57
|
+
constructor(baseUrl, apiKey, options) {
|
|
54
58
|
this.baseUrl = baseUrl.replace(/\/+$/, "");
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
this.apiKey = typeof apiKeyOrOptions === "string" ? apiKeyOrOptions : apiKeyOrOptions?.apiKey ?? null;
|
|
59
|
+
const resolvedOptions = options;
|
|
60
|
+
this.apiKey = apiKey || null;
|
|
58
61
|
this.fetchFn = resolvedOptions?.fetch ?? globalThis.fetch.bind(globalThis);
|
|
59
62
|
const r = resolvedOptions?.retry;
|
|
60
63
|
this.retryConfig = r === false ? { enabled: false, maxRetries: 0 } : r === void 0 || r === true ? { enabled: true, maxRetries: DEFAULT_MAX_RETRIES } : { enabled: r.enabled ?? true, maxRetries: r.maxRetries ?? DEFAULT_MAX_RETRIES };
|
|
@@ -80,7 +83,7 @@ var AuraClient = class {
|
|
|
80
83
|
} else if (resolvedOptions?.auth?.persistSession === false) {
|
|
81
84
|
this.authStore = new BaseAuthStore();
|
|
82
85
|
} else if (typeof localStorage !== "undefined") {
|
|
83
|
-
this.authStore = new LocalAuthStore();
|
|
86
|
+
this.authStore = new LocalAuthStore(`aura-${clientScope(this.baseUrl)}-auth`);
|
|
84
87
|
} else {
|
|
85
88
|
this.authStore = new BaseAuthStore();
|
|
86
89
|
}
|
|
@@ -162,16 +165,18 @@ var AuraClient = class {
|
|
|
162
165
|
return this.realtime.channel(name, options);
|
|
163
166
|
}
|
|
164
167
|
};
|
|
165
|
-
|
|
166
|
-
|
|
168
|
+
|
|
169
|
+
// src/index.ts
|
|
170
|
+
function createClient(baseUrl, apiKey, options) {
|
|
171
|
+
return new AuraClient(baseUrl, apiKey, options);
|
|
167
172
|
}
|
|
168
|
-
function createAdminClient(baseUrl,
|
|
173
|
+
function createAdminClient(baseUrl, serviceRoleKey, options) {
|
|
169
174
|
if (isBrowserContext()) {
|
|
170
175
|
throw new Error(
|
|
171
176
|
"[aurabase] createAdminClient() ne doit jamais \xEAtre appel\xE9 c\xF4t\xE9 navigateur : la cl\xE9 service_role serait expos\xE9e dans le bundle. \xC0 utiliser uniquement c\xF4t\xE9 serveur."
|
|
172
177
|
);
|
|
173
178
|
}
|
|
174
|
-
return new AuraClient(baseUrl,
|
|
179
|
+
return new AuraClient(baseUrl, serviceRoleKey, options);
|
|
175
180
|
}
|
|
176
181
|
|
|
177
182
|
export { AuraClient, createAdminClient, createClient };
|
package/dist/ssr.cjs
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var core = require('@aurabase/core');
|
|
4
|
+
var ai = require('@aurabase/ai');
|
|
4
5
|
var auth = require('@aurabase/auth');
|
|
5
6
|
var db = require('@aurabase/db');
|
|
6
|
-
var storage = require('@aurabase/storage');
|
|
7
|
-
var realtime = require('@aurabase/realtime');
|
|
8
7
|
var functions = require('@aurabase/functions');
|
|
9
|
-
var ai = require('@aurabase/ai');
|
|
10
8
|
var notifications = require('@aurabase/notifications');
|
|
9
|
+
var realtime = require('@aurabase/realtime');
|
|
10
|
+
var storage = require('@aurabase/storage');
|
|
11
11
|
|
|
12
|
-
// src/
|
|
12
|
+
// src/ssr.ts
|
|
13
13
|
function isBrowserContext() {
|
|
14
14
|
if (typeof window !== "undefined") return true;
|
|
15
15
|
const g = globalThis;
|
|
@@ -19,8 +19,8 @@ function isBrowserContext() {
|
|
|
19
19
|
}
|
|
20
20
|
var SERVICE_ROLE_KEY_PREFIX = "aura_sk_";
|
|
21
21
|
var AuraClient = class {
|
|
22
|
+
/** URL du projet (`https://<slug>.aurabase.cloud`), sans barre finale. */
|
|
22
23
|
baseUrl;
|
|
23
|
-
projectId;
|
|
24
24
|
apiKey;
|
|
25
25
|
fetchFn;
|
|
26
26
|
authStore;
|
|
@@ -44,11 +44,14 @@ var AuraClient = class {
|
|
|
44
44
|
_persistSession;
|
|
45
45
|
_autoRefresh;
|
|
46
46
|
_detectSessionInUrl;
|
|
47
|
-
|
|
47
|
+
/**
|
|
48
|
+
* @param baseUrl URL du projet (`https://<slug>.aurabase.cloud`).
|
|
49
|
+
* @param apiKey Clé API du projet (`aura_anon_…`, `aura_auth_…`, `aura_sk_…`).
|
|
50
|
+
*/
|
|
51
|
+
constructor(baseUrl, apiKey, options) {
|
|
48
52
|
this.baseUrl = baseUrl.replace(/\/+$/, "");
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
this.apiKey = typeof apiKeyOrOptions === "string" ? apiKeyOrOptions : apiKeyOrOptions?.apiKey ?? null;
|
|
53
|
+
const resolvedOptions = options;
|
|
54
|
+
this.apiKey = apiKey || null;
|
|
52
55
|
this.fetchFn = resolvedOptions?.fetch ?? globalThis.fetch.bind(globalThis);
|
|
53
56
|
const r = resolvedOptions?.retry;
|
|
54
57
|
this.retryConfig = r === false ? { enabled: false, maxRetries: 0 } : r === void 0 || r === true ? { enabled: true, maxRetries: core.DEFAULT_MAX_RETRIES } : { enabled: r.enabled ?? true, maxRetries: r.maxRetries ?? core.DEFAULT_MAX_RETRIES };
|
|
@@ -74,7 +77,7 @@ var AuraClient = class {
|
|
|
74
77
|
} else if (resolvedOptions?.auth?.persistSession === false) {
|
|
75
78
|
this.authStore = new core.BaseAuthStore();
|
|
76
79
|
} else if (typeof localStorage !== "undefined") {
|
|
77
|
-
this.authStore = new core.LocalAuthStore();
|
|
80
|
+
this.authStore = new core.LocalAuthStore(`aura-${core.clientScope(this.baseUrl)}-auth`);
|
|
78
81
|
} else {
|
|
79
82
|
this.authStore = new core.BaseAuthStore();
|
|
80
83
|
}
|
|
@@ -157,8 +160,8 @@ var AuraClient = class {
|
|
|
157
160
|
}
|
|
158
161
|
};
|
|
159
162
|
var MAX_CHUNK_SIZE = 3600;
|
|
160
|
-
function createServerClient(baseUrl,
|
|
161
|
-
const cookieName = `aura-${
|
|
163
|
+
function createServerClient(baseUrl, apiKey, options) {
|
|
164
|
+
const cookieName = `aura-${core.clientScope(baseUrl)}-auth`;
|
|
162
165
|
const store = new core.LocalAuthStore(cookieName);
|
|
163
166
|
const idxRe = new RegExp(`^${cookieName.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")}\\.(\\d+)$`);
|
|
164
167
|
const incoming = options.cookies.getAll();
|
|
@@ -193,7 +196,11 @@ function createServerClient(baseUrl, projectId, options) {
|
|
|
193
196
|
let idx = 0;
|
|
194
197
|
for (let i = 0; i < decoded.length; i += MAX_CHUNK_SIZE, idx++) {
|
|
195
198
|
const name = `${cookieName}.${idx}`;
|
|
196
|
-
toSet.push({
|
|
199
|
+
toSet.push({
|
|
200
|
+
name,
|
|
201
|
+
value: decoded.slice(i, i + MAX_CHUNK_SIZE),
|
|
202
|
+
options: defaultCookieOpts
|
|
203
|
+
});
|
|
197
204
|
used.add(name);
|
|
198
205
|
}
|
|
199
206
|
}
|
|
@@ -204,12 +211,12 @@ function createServerClient(baseUrl, projectId, options) {
|
|
|
204
211
|
}
|
|
205
212
|
if (toSet.length > 0) options.cookies.setAll(toSet);
|
|
206
213
|
});
|
|
207
|
-
return new AuraClient(baseUrl,
|
|
214
|
+
return new AuraClient(baseUrl, apiKey, {
|
|
208
215
|
auth: { persistSession: false, storage: store }
|
|
209
216
|
});
|
|
210
217
|
}
|
|
211
|
-
function createBrowserClient(baseUrl,
|
|
212
|
-
return new AuraClient(baseUrl,
|
|
218
|
+
function createBrowserClient(baseUrl, apiKey, options) {
|
|
219
|
+
return new AuraClient(baseUrl, apiKey, options);
|
|
213
220
|
}
|
|
214
221
|
|
|
215
222
|
Object.defineProperty(exports, "parseCookieHeader", {
|
package/dist/ssr.d.cts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { A as AuraClient } from './AuraClient-BcFE8u1v.cjs';
|
|
2
1
|
import { SerializeCookieOptions, AuraClientOptions } from '@aurabase/core';
|
|
3
2
|
export { SerializeCookieOptions, parseCookieHeader, serializeCookieHeader } from '@aurabase/core';
|
|
3
|
+
import { A as AuraClient } from './AuraClient-0WhqmK0u.cjs';
|
|
4
|
+
import '@aurabase/ai';
|
|
4
5
|
import '@aurabase/auth';
|
|
5
6
|
import '@aurabase/db';
|
|
6
|
-
import '@aurabase/storage';
|
|
7
|
-
import '@aurabase/realtime';
|
|
8
7
|
import '@aurabase/functions';
|
|
9
|
-
import '@aurabase/ai';
|
|
10
8
|
import '@aurabase/notifications';
|
|
9
|
+
import '@aurabase/realtime';
|
|
10
|
+
import '@aurabase/storage';
|
|
11
11
|
|
|
12
12
|
/**
|
|
13
13
|
* Server-side rendering helpers for Aurabase.
|
|
@@ -18,7 +18,7 @@ import '@aurabase/notifications';
|
|
|
18
18
|
*
|
|
19
19
|
* export async function middleware(request) {
|
|
20
20
|
* let response = NextResponse.next({ request })
|
|
21
|
-
* const client = createServerClient(
|
|
21
|
+
* const client = createServerClient(PROJECT_URL, ANON_KEY, {
|
|
22
22
|
* cookies: {
|
|
23
23
|
* getAll: () => request.cookies.getAll(),
|
|
24
24
|
* setAll: (cookies) => {
|
|
@@ -51,15 +51,14 @@ interface CookieHandler {
|
|
|
51
51
|
}>): void;
|
|
52
52
|
}
|
|
53
53
|
interface ServerClientOptions {
|
|
54
|
-
apiKey?: string;
|
|
55
54
|
cookies: CookieHandler;
|
|
56
55
|
cookieOptions?: SerializeCookieOptions;
|
|
57
56
|
}
|
|
58
|
-
declare function createServerClient<Database = any>(baseUrl: string,
|
|
57
|
+
declare function createServerClient<Database = any>(baseUrl: string, apiKey: string, options: ServerClientOptions): AuraClient<Database>;
|
|
59
58
|
/**
|
|
60
59
|
* Create an Aurabase client for browser usage.
|
|
61
60
|
* Thin wrapper around AuraClient with sensible browser defaults.
|
|
62
61
|
*/
|
|
63
|
-
declare function createBrowserClient<Database = any>(baseUrl: string,
|
|
62
|
+
declare function createBrowserClient<Database = any>(baseUrl: string, apiKey: string, options?: AuraClientOptions): AuraClient<Database>;
|
|
64
63
|
|
|
65
64
|
export { type CookieHandler, type ServerClientOptions, createBrowserClient, createServerClient };
|
package/dist/ssr.d.ts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { A as AuraClient } from './AuraClient-BcFE8u1v.js';
|
|
2
1
|
import { SerializeCookieOptions, AuraClientOptions } from '@aurabase/core';
|
|
3
2
|
export { SerializeCookieOptions, parseCookieHeader, serializeCookieHeader } from '@aurabase/core';
|
|
3
|
+
import { A as AuraClient } from './AuraClient-0WhqmK0u.js';
|
|
4
|
+
import '@aurabase/ai';
|
|
4
5
|
import '@aurabase/auth';
|
|
5
6
|
import '@aurabase/db';
|
|
6
|
-
import '@aurabase/storage';
|
|
7
|
-
import '@aurabase/realtime';
|
|
8
7
|
import '@aurabase/functions';
|
|
9
|
-
import '@aurabase/ai';
|
|
10
8
|
import '@aurabase/notifications';
|
|
9
|
+
import '@aurabase/realtime';
|
|
10
|
+
import '@aurabase/storage';
|
|
11
11
|
|
|
12
12
|
/**
|
|
13
13
|
* Server-side rendering helpers for Aurabase.
|
|
@@ -18,7 +18,7 @@ import '@aurabase/notifications';
|
|
|
18
18
|
*
|
|
19
19
|
* export async function middleware(request) {
|
|
20
20
|
* let response = NextResponse.next({ request })
|
|
21
|
-
* const client = createServerClient(
|
|
21
|
+
* const client = createServerClient(PROJECT_URL, ANON_KEY, {
|
|
22
22
|
* cookies: {
|
|
23
23
|
* getAll: () => request.cookies.getAll(),
|
|
24
24
|
* setAll: (cookies) => {
|
|
@@ -51,15 +51,14 @@ interface CookieHandler {
|
|
|
51
51
|
}>): void;
|
|
52
52
|
}
|
|
53
53
|
interface ServerClientOptions {
|
|
54
|
-
apiKey?: string;
|
|
55
54
|
cookies: CookieHandler;
|
|
56
55
|
cookieOptions?: SerializeCookieOptions;
|
|
57
56
|
}
|
|
58
|
-
declare function createServerClient<Database = any>(baseUrl: string,
|
|
57
|
+
declare function createServerClient<Database = any>(baseUrl: string, apiKey: string, options: ServerClientOptions): AuraClient<Database>;
|
|
59
58
|
/**
|
|
60
59
|
* Create an Aurabase client for browser usage.
|
|
61
60
|
* Thin wrapper around AuraClient with sensible browser defaults.
|
|
62
61
|
*/
|
|
63
|
-
declare function createBrowserClient<Database = any>(baseUrl: string,
|
|
62
|
+
declare function createBrowserClient<Database = any>(baseUrl: string, apiKey: string, options?: AuraClientOptions): AuraClient<Database>;
|
|
64
63
|
|
|
65
64
|
export { type CookieHandler, type ServerClientOptions, createBrowserClient, createServerClient };
|
package/dist/ssr.js
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import { LocalAuthStore, DEFAULT_MAX_RETRIES, BaseAuthStore } from '@aurabase/core';
|
|
1
|
+
import { clientScope, LocalAuthStore, DEFAULT_MAX_RETRIES, BaseAuthStore } from '@aurabase/core';
|
|
2
2
|
export { parseCookieHeader, serializeCookieHeader } from '@aurabase/core';
|
|
3
|
+
import { AiService } from '@aurabase/ai';
|
|
3
4
|
import { AuthService, AuthAdminService } from '@aurabase/auth';
|
|
4
5
|
import { DatabaseService } from '@aurabase/db';
|
|
5
|
-
import { StorageService } from '@aurabase/storage';
|
|
6
|
-
import { RealtimeService } from '@aurabase/realtime';
|
|
7
6
|
import { FunctionsService } from '@aurabase/functions';
|
|
8
|
-
import { AiService } from '@aurabase/ai';
|
|
9
7
|
import { NotificationsService } from '@aurabase/notifications';
|
|
8
|
+
import { RealtimeService } from '@aurabase/realtime';
|
|
9
|
+
import { StorageService } from '@aurabase/storage';
|
|
10
10
|
|
|
11
|
-
// src/
|
|
11
|
+
// src/ssr.ts
|
|
12
12
|
function isBrowserContext() {
|
|
13
13
|
if (typeof window !== "undefined") return true;
|
|
14
14
|
const g = globalThis;
|
|
@@ -18,8 +18,8 @@ function isBrowserContext() {
|
|
|
18
18
|
}
|
|
19
19
|
var SERVICE_ROLE_KEY_PREFIX = "aura_sk_";
|
|
20
20
|
var AuraClient = class {
|
|
21
|
+
/** URL du projet (`https://<slug>.aurabase.cloud`), sans barre finale. */
|
|
21
22
|
baseUrl;
|
|
22
|
-
projectId;
|
|
23
23
|
apiKey;
|
|
24
24
|
fetchFn;
|
|
25
25
|
authStore;
|
|
@@ -43,11 +43,14 @@ var AuraClient = class {
|
|
|
43
43
|
_persistSession;
|
|
44
44
|
_autoRefresh;
|
|
45
45
|
_detectSessionInUrl;
|
|
46
|
-
|
|
46
|
+
/**
|
|
47
|
+
* @param baseUrl URL du projet (`https://<slug>.aurabase.cloud`).
|
|
48
|
+
* @param apiKey Clé API du projet (`aura_anon_…`, `aura_auth_…`, `aura_sk_…`).
|
|
49
|
+
*/
|
|
50
|
+
constructor(baseUrl, apiKey, options) {
|
|
47
51
|
this.baseUrl = baseUrl.replace(/\/+$/, "");
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
this.apiKey = typeof apiKeyOrOptions === "string" ? apiKeyOrOptions : apiKeyOrOptions?.apiKey ?? null;
|
|
52
|
+
const resolvedOptions = options;
|
|
53
|
+
this.apiKey = apiKey || null;
|
|
51
54
|
this.fetchFn = resolvedOptions?.fetch ?? globalThis.fetch.bind(globalThis);
|
|
52
55
|
const r = resolvedOptions?.retry;
|
|
53
56
|
this.retryConfig = r === false ? { enabled: false, maxRetries: 0 } : r === void 0 || r === true ? { enabled: true, maxRetries: DEFAULT_MAX_RETRIES } : { enabled: r.enabled ?? true, maxRetries: r.maxRetries ?? DEFAULT_MAX_RETRIES };
|
|
@@ -73,7 +76,7 @@ var AuraClient = class {
|
|
|
73
76
|
} else if (resolvedOptions?.auth?.persistSession === false) {
|
|
74
77
|
this.authStore = new BaseAuthStore();
|
|
75
78
|
} else if (typeof localStorage !== "undefined") {
|
|
76
|
-
this.authStore = new LocalAuthStore();
|
|
79
|
+
this.authStore = new LocalAuthStore(`aura-${clientScope(this.baseUrl)}-auth`);
|
|
77
80
|
} else {
|
|
78
81
|
this.authStore = new BaseAuthStore();
|
|
79
82
|
}
|
|
@@ -156,8 +159,8 @@ var AuraClient = class {
|
|
|
156
159
|
}
|
|
157
160
|
};
|
|
158
161
|
var MAX_CHUNK_SIZE = 3600;
|
|
159
|
-
function createServerClient(baseUrl,
|
|
160
|
-
const cookieName = `aura-${
|
|
162
|
+
function createServerClient(baseUrl, apiKey, options) {
|
|
163
|
+
const cookieName = `aura-${clientScope(baseUrl)}-auth`;
|
|
161
164
|
const store = new LocalAuthStore(cookieName);
|
|
162
165
|
const idxRe = new RegExp(`^${cookieName.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")}\\.(\\d+)$`);
|
|
163
166
|
const incoming = options.cookies.getAll();
|
|
@@ -192,7 +195,11 @@ function createServerClient(baseUrl, projectId, options) {
|
|
|
192
195
|
let idx = 0;
|
|
193
196
|
for (let i = 0; i < decoded.length; i += MAX_CHUNK_SIZE, idx++) {
|
|
194
197
|
const name = `${cookieName}.${idx}`;
|
|
195
|
-
toSet.push({
|
|
198
|
+
toSet.push({
|
|
199
|
+
name,
|
|
200
|
+
value: decoded.slice(i, i + MAX_CHUNK_SIZE),
|
|
201
|
+
options: defaultCookieOpts
|
|
202
|
+
});
|
|
196
203
|
used.add(name);
|
|
197
204
|
}
|
|
198
205
|
}
|
|
@@ -203,12 +210,12 @@ function createServerClient(baseUrl, projectId, options) {
|
|
|
203
210
|
}
|
|
204
211
|
if (toSet.length > 0) options.cookies.setAll(toSet);
|
|
205
212
|
});
|
|
206
|
-
return new AuraClient(baseUrl,
|
|
213
|
+
return new AuraClient(baseUrl, apiKey, {
|
|
207
214
|
auth: { persistSession: false, storage: store }
|
|
208
215
|
});
|
|
209
216
|
}
|
|
210
|
-
function createBrowserClient(baseUrl,
|
|
211
|
-
return new AuraClient(baseUrl,
|
|
217
|
+
function createBrowserClient(baseUrl, apiKey, options) {
|
|
218
|
+
return new AuraClient(baseUrl, apiKey, options);
|
|
212
219
|
}
|
|
213
220
|
|
|
214
221
|
export { createBrowserClient, createServerClient };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aurabase/aurabase-js",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.0",
|
|
4
4
|
"description": "Official JavaScript/TypeScript client for Aurabase BaaS",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.cjs",
|
|
@@ -56,14 +56,14 @@
|
|
|
56
56
|
"client"
|
|
57
57
|
],
|
|
58
58
|
"dependencies": {
|
|
59
|
-
"@aurabase/core": "0.
|
|
60
|
-
"@aurabase/
|
|
61
|
-
"@aurabase/
|
|
62
|
-
"@aurabase/
|
|
63
|
-
"@aurabase/
|
|
64
|
-
"@aurabase/
|
|
65
|
-
"@aurabase/
|
|
66
|
-
"@aurabase/
|
|
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"
|
|
67
67
|
},
|
|
68
68
|
"devDependencies": {
|
|
69
69
|
"@types/node": "20.14.15",
|