@aurabase/core 0.5.3 → 0.6.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/dist/index.d.cts CHANGED
@@ -715,6 +715,51 @@ interface CdcPayload {
715
715
  record: Record<string, unknown>;
716
716
  old_record: Record<string, unknown> | null;
717
717
  _truncated?: boolean;
718
+ [key: string]: unknown;
719
+ }
720
+ /** Base commune des métadonnées pour un événement CDC PostgreSQL */
721
+ interface RealtimePostgresChangesBasePayload {
722
+ schema: string;
723
+ table: string;
724
+ commit_timestamp: string;
725
+ errors?: string[];
726
+ id: string;
727
+ topic: string;
728
+ timestamp: string;
729
+ payload: CdcPayload | Record<string, unknown>;
730
+ event: 'insert' | 'update' | 'delete';
731
+ }
732
+ /** Payload enrichi pour un événement CDC PostgreSQL d'insertion */
733
+ interface RealtimePostgresInsertPayload<T = Record<string, unknown>> extends RealtimePostgresChangesBasePayload {
734
+ eventType: 'INSERT';
735
+ event: 'insert';
736
+ new: T;
737
+ old: null;
738
+ }
739
+ /** Payload enrichi pour un événement CDC PostgreSQL de mise à jour */
740
+ interface RealtimePostgresUpdatePayload<T = Record<string, unknown>> extends RealtimePostgresChangesBasePayload {
741
+ eventType: 'UPDATE';
742
+ event: 'update';
743
+ new: T;
744
+ old: Partial<T>;
745
+ }
746
+ /** Payload enrichi pour un événement CDC PostgreSQL de suppression */
747
+ interface RealtimePostgresDeletePayload<T = Record<string, unknown>> extends RealtimePostgresChangesBasePayload {
748
+ eventType: 'DELETE';
749
+ event: 'delete';
750
+ new: null;
751
+ old: Partial<T> | null;
752
+ }
753
+ /** Union discriminée par eventType pour les événements CDC PostgreSQL */
754
+ type RealtimePostgresChangesPayload<T = Record<string, unknown>> = RealtimePostgresInsertPayload<T> | RealtimePostgresUpdatePayload<T> | RealtimePostgresDeletePayload<T>;
755
+ /** Événement broadcast reçu avec payload typé */
756
+ interface RealtimeBroadcastEvent<T = Record<string, unknown>> {
757
+ event: string;
758
+ payload: T;
759
+ id?: string;
760
+ topic?: string;
761
+ timestamp?: string;
762
+ allowed_sub_ids?: string[];
718
763
  }
719
764
  /** Status de subscription */
720
765
  type RealtimeSubscribeStatus = 'SUBSCRIBED' | 'CLOSED' | 'CHANNEL_ERROR' | 'TIMED_OUT';
@@ -832,7 +877,12 @@ interface ChannelConfig {
832
877
  };
833
878
  /** Configuration présence directe */
834
879
  presence?: {
835
- /** Clé de présence — permet de regrouper plusieurs onglets/devices du même user */
880
+ /**
881
+ * @deprecated La présence distribuée est indexée de manière autoritaire par le serveur
882
+ * à l'aide de l'identité vérifiée (`user_id` extrait du JWT) et de l'identifiant de connexion WebSocket
883
+ * (`client_id` dans NATS KV). Une clé libre côté client n'est pas utilisée pour partitionner le cluster
884
+ * afin d'empêcher les collisions d'état et les risques d'usurpation d'identité.
885
+ */
836
886
  key?: string;
837
887
  };
838
888
  /** Configuration compatible Supabase sous `config` */
@@ -842,6 +892,9 @@ interface ChannelConfig {
842
892
  self?: boolean;
843
893
  };
844
894
  presence?: {
895
+ /**
896
+ * @deprecated Voir `ChannelConfig.presence.key`. L'identité de présence est sécurisée par `user_id`/`client_id`.
897
+ */
845
898
  key?: string;
846
899
  };
847
900
  private?: boolean;
@@ -940,6 +993,19 @@ interface SemanticSearchResult {
940
993
  metadata: Record<string, unknown>;
941
994
  similarity: number;
942
995
  }
996
+ /** Limites d'exécution d'une fonction (`PATCH /v1/functions/{project}/{name}`). */
997
+ interface FunctionPermissions {
998
+ /** Domaines autorisés en sortie. Stocké mais non appliqué par le runtime actuel. */
999
+ allow_net: string[];
1000
+ /** 16 à 1024, défaut 128. */
1001
+ memory_mb: number;
1002
+ /** 1 à 300, défaut 30 — durée maximale (wall-clock). */
1003
+ timeout_secs: number;
1004
+ }
1005
+ /**
1006
+ * Définition d'une fonction. Contient le code source et les variables d'environnement :
1007
+ * `list()` et `get()` exigent donc une clé `service_role` (usage serveur uniquement).
1008
+ */
943
1009
  interface FunctionDef {
944
1010
  id: string;
945
1011
  project_id: string;
@@ -947,7 +1013,8 @@ interface FunctionDef {
947
1013
  runtime: string;
948
1014
  code: string;
949
1015
  code_hash: string;
950
- env_vars: Record<string, unknown>;
1016
+ env_vars: Record<string, string>;
1017
+ permissions: FunctionPermissions;
951
1018
  is_active: boolean;
952
1019
  created_at: string;
953
1020
  updated_at: string;
@@ -1182,16 +1249,160 @@ interface NotificationStats {
1182
1249
  dead_lettered: number;
1183
1250
  }>;
1184
1251
  }
1252
+ type NotificationChannel = 'email' | 'sms' | 'push' | 'webhook';
1253
+ type NotificationStatus = 'queued' | 'processing' | 'sent' | 'failed' | 'delivered' | 'expired' | 'dead_lettered';
1254
+ type NotificationStatsWindow = '1h' | '24h' | '7d' | '30d';
1255
+ type NotificationAttemptStatus = 'processing' | 'sent' | 'failed' | 'retry_scheduled' | 'dead_lettered';
1256
+ type SettingsSource = 'project' | 'environment' | 'none';
1257
+ interface SmtpPublicSettings {
1258
+ configured: boolean;
1259
+ source: SettingsSource;
1260
+ host?: string | null;
1261
+ port?: number | null;
1262
+ user?: string | null;
1263
+ password_set: boolean;
1264
+ from_email?: string | null;
1265
+ from_name?: string | null;
1266
+ tls: boolean;
1267
+ }
1268
+ interface TwilioPublicSettings {
1269
+ configured: boolean;
1270
+ source: SettingsSource;
1271
+ account_sid_prefix?: string | null;
1272
+ auth_token_set: boolean;
1273
+ from_number?: string | null;
1274
+ status_callback_url?: string | null;
1275
+ }
1276
+ interface FcmPublicSettings {
1277
+ configured: boolean;
1278
+ source: SettingsSource;
1279
+ project_id?: string | null;
1280
+ service_account_json_set: boolean;
1281
+ legacy_server_key_present: boolean;
1282
+ api: string;
1283
+ }
1284
+ interface ApnsPublicSettings {
1285
+ configured: boolean;
1286
+ source: SettingsSource;
1287
+ key_id?: string | null;
1288
+ team_id?: string | null;
1289
+ private_key_set: boolean;
1290
+ bundle_id?: string | null;
1291
+ production: boolean;
1292
+ }
1293
+ interface WebhookPublicSettings {
1294
+ configured: boolean;
1295
+ source: SettingsSource;
1296
+ max_retries: number;
1297
+ retry_delay_ms: number;
1298
+ timeout_secs: number;
1299
+ secret_set: boolean;
1300
+ signature_tolerance_secs: number;
1301
+ }
1302
+ interface QuotaPublicSettings {
1303
+ source: SettingsSource;
1304
+ project_rate_limit_per_minute: number;
1305
+ channel_rate_limit_per_minute: number;
1306
+ batch_max_size: number;
1307
+ }
1308
+ interface SmtpSettingsPatch {
1309
+ host?: string | null;
1310
+ port?: number | null;
1311
+ user?: string | null;
1312
+ password?: string | null;
1313
+ from_email?: string | null;
1314
+ from_name?: string | null;
1315
+ tls?: boolean | null;
1316
+ }
1317
+ interface TwilioSettingsPatch {
1318
+ account_sid?: string | null;
1319
+ auth_token?: string | null;
1320
+ from_number?: string | null;
1321
+ }
1322
+ interface FcmSettingsPatch {
1323
+ project_id?: string | null;
1324
+ service_account_json?: string | null;
1325
+ }
1326
+ interface ApnsSettingsPatch {
1327
+ key_id?: string | null;
1328
+ team_id?: string | null;
1329
+ private_key_b64?: string | null;
1330
+ bundle_id?: string | null;
1331
+ production?: boolean | null;
1332
+ }
1333
+ interface WebhookSettingsPatch {
1334
+ max_retries?: number | null;
1335
+ retry_delay_ms?: number | null;
1336
+ timeout_secs?: number | null;
1337
+ secret?: string | null;
1338
+ }
1339
+ interface QuotaSettingsPatch {
1340
+ project_rate_limit_per_minute?: number | null;
1341
+ channel_rate_limit_per_minute?: number | null;
1342
+ batch_max_size?: number | null;
1343
+ }
1344
+ interface NotificationSettingsPatch {
1345
+ smtp?: SmtpSettingsPatch | null;
1346
+ twilio?: TwilioSettingsPatch | null;
1347
+ fcm?: FcmSettingsPatch | null;
1348
+ apns?: ApnsSettingsPatch | null;
1349
+ webhook?: WebhookSettingsPatch | null;
1350
+ quotas?: QuotaSettingsPatch | null;
1351
+ }
1185
1352
  interface NotificationSettings {
1186
1353
  project_id: string;
1187
- smtp?: Record<string, unknown>;
1188
- twilio?: Record<string, unknown>;
1189
- fcm?: Record<string, unknown>;
1190
- apns?: Record<string, unknown>;
1191
- webhook?: Record<string, unknown>;
1192
- quotas?: Record<string, unknown>;
1354
+ smtp?: SmtpPublicSettings | Record<string, unknown>;
1355
+ twilio?: TwilioPublicSettings | Record<string, unknown>;
1356
+ fcm?: FcmPublicSettings | Record<string, unknown>;
1357
+ apns?: ApnsPublicSettings | Record<string, unknown>;
1358
+ webhook?: WebhookPublicSettings | Record<string, unknown>;
1359
+ quotas?: QuotaPublicSettings | Record<string, unknown>;
1193
1360
  updated_at?: string | null;
1194
1361
  }
1362
+ type NotificationSettingsPublic = NotificationSettings;
1363
+ interface CreateNotificationRuleRequest {
1364
+ name: string;
1365
+ trigger_type: string;
1366
+ condition?: Record<string, unknown>;
1367
+ template_id?: string | null;
1368
+ channel: NotificationChannel;
1369
+ recipient_expr: string;
1370
+ delay_seconds?: number;
1371
+ }
1372
+ interface UpdateNotificationRuleRequest {
1373
+ name?: string;
1374
+ enabled?: boolean;
1375
+ trigger_type?: string;
1376
+ condition?: Record<string, unknown>;
1377
+ template_id?: string | null;
1378
+ channel?: NotificationChannel;
1379
+ recipient_expr?: string;
1380
+ delay_seconds?: number;
1381
+ }
1382
+ interface SendNotificationOptions {
1383
+ channel: NotificationChannel;
1384
+ recipient: string;
1385
+ body?: string;
1386
+ subject?: string;
1387
+ templateId?: string;
1388
+ template_id?: string;
1389
+ variables?: Record<string, unknown>;
1390
+ metadata?: Record<string, unknown>;
1391
+ idempotencyKey?: string;
1392
+ idempotency_key?: string;
1393
+ }
1394
+ interface SendNotificationItem {
1395
+ channel: NotificationChannel;
1396
+ recipient: string;
1397
+ body?: string;
1398
+ subject?: string;
1399
+ templateId?: string;
1400
+ template_id?: string;
1401
+ variables?: Record<string, unknown>;
1402
+ metadata?: Record<string, unknown>;
1403
+ idempotencyKey?: string;
1404
+ idempotency_key?: string;
1405
+ }
1195
1406
  interface NotificationRule {
1196
1407
  id: string;
1197
1408
  project_id: string;
@@ -1199,7 +1410,7 @@ interface NotificationRule {
1199
1410
  trigger_type: string;
1200
1411
  condition: Record<string, unknown>;
1201
1412
  template_id?: string | null;
1202
- channel: 'email' | 'sms' | 'push' | 'webhook';
1413
+ channel: NotificationChannel;
1203
1414
  recipient_expr: string;
1204
1415
  enabled: boolean;
1205
1416
  delay_seconds: number;
@@ -1554,6 +1765,10 @@ interface GetClaimsResult {
1554
1765
  kid?: string;
1555
1766
  typ?: string;
1556
1767
  };
1768
+ sub?: string;
1769
+ email?: string | null;
1770
+ role?: string;
1771
+ [key: string]: unknown;
1557
1772
  }
1558
1773
 
1559
1774
  type AuthChangeCallback = (token: string | null, user: User | null) => void;
@@ -1625,6 +1840,8 @@ interface AuraClientLike {
1625
1840
  */
1626
1841
  readonly baseUrl: string;
1627
1842
  readonly apiKey: string | null;
1843
+ /** Identifiant optionnel du projet résolu ou configuré sur le client */
1844
+ readonly projectId?: string;
1628
1845
  readonly fetchFn: typeof globalThis.fetch;
1629
1846
  readonly authStore: BaseAuthStore;
1630
1847
  /** Consommé uniquement par le service realtime (refresh proactif du token). */
@@ -1818,4 +2035,4 @@ declare class LocalAuthStore extends BaseAuthStore {
1818
2035
  private _removeStorage;
1819
2036
  }
1820
2037
 
1821
- export { AUTH_SETTINGS_WRITABLE_FIELDS, type AdminCreateUserRequest, type AdminSessionInfo, type AdminUpdateUserRequest, type AdminUser, type AuditLogEntry, type AuraClientLike, type AuraClientOptions, AuraError, type AuraErrorCode, type AuraFailure, type AuraNoContent, type AuraObservabilityEvent, type AuraResponse, type AuraSuccess, type AuthChangePayload, type AuthEvent, type AuthSettings, type AuthSettingsUpdate, BaseAuthStore, BaseService, type BatchSendItemResult, type BatchSendResponse, type BroadcastAckMessage, type BroadcastFilter, type BroadcastPayload, type BroadcastSendStatus, type CdcPayload, type ChannelConfig, type ChatMessage, type ChatResponse, type CountMode, type CreatePgFunctionRequest, type CreatePgTriggerRequest, type CronJob, DEFAULT_MAX_RETRIES, DEFAULT_REQUEST_TIMEOUT_MS, type EmailTemplateUpdate, type EmbedRequest, type EmbedResponse, type FetchInit, type FileEntry, type FilterOp, type FunctionDef, type GenerateLinkResult, type GenerateLinkType, type GetClaimsResult, type IdentityInfo, type ImageTransform, type Job, type JwtClaims, LocalAuthStore, type LoginResponse, type MagicLinkRequest, type Meta, type MfaChallenge, type MfaEnrollResponse, type MfaVerifyRequest, type Notification, type NotificationAttempt, type NotificationChannelStats, type NotificationDeadLetter, type NotificationEvent, type NotificationProviderLog, type NotificationQueueStats, type NotificationRule, type NotificationSettings, type NotificationStats, type NotificationTemplate, type NotificationTemplatePreview, type OAuthProviderSetting, type OAuthSignInOptions, type ObjectMeta, type PasswordResetRequest, type PgExecutableRole, type PgFunctionInfo, type PgTriggerInfo, type PostgresChangesFilter, type PresenceFilter, type PresenceInfo, type PresenceState, type QueryFilter, type QueryOptions, RETRYABLE_METHODS, RETRYABLE_STATUS, type RagIngestRequest, type RagIngestResponse, type RagRequest, type RagResponse, type RealtimeEvent, type RealtimeListenType, type RealtimeSubscribeStatus, type SchemaColumn, type SchemaEnum, type SchemaFunction, type SchemaFunctionArg, type SchemaIndex, type SchemaTable, type SemanticSearchResult, type SendNotificationRequest, type SerializeCookieOptions, type ServerErrorMsg, type ServerEventMsg, type ServerMessage, type ServerPongMsg, type ServerPresenceStateMsg, type ServerSubscribedMsg, type ServerTokenRefreshedMsg, type Session, type SessionInfo, type SignInRequest, type SignUpRequest, type StorageBucket, type SubscribeCallback, type TokenPair, type UpdateUserRequest, type UploadResult, type User, type UserStats, abortableSleep, clientScope, computeBackoff, emitAuraEvent, fetchWithAuth, isAbortError, isAuraError, isRetryableMethod, isRetryableStatus, isTokenExpired, parseCookieHeader, parseRetryAfter, refreshOnce, serializeBody, serializeCookieHeader };
2038
+ export { AUTH_SETTINGS_WRITABLE_FIELDS, type AdminCreateUserRequest, type AdminSessionInfo, type AdminUpdateUserRequest, type AdminUser, type ApnsPublicSettings, type ApnsSettingsPatch, type AuditLogEntry, type AuraClientLike, type AuraClientOptions, AuraError, type AuraErrorCode, type AuraFailure, type AuraNoContent, type AuraObservabilityEvent, type AuraResponse, type AuraSuccess, type AuthChangePayload, type AuthEvent, type AuthSettings, type AuthSettingsUpdate, BaseAuthStore, BaseService, type BatchSendItemResult, type BatchSendResponse, type BroadcastAckMessage, type BroadcastFilter, type BroadcastPayload, type BroadcastSendStatus, type CdcPayload, type ChannelConfig, type ChatMessage, type ChatResponse, type CountMode, type CreateNotificationRuleRequest, type CreatePgFunctionRequest, type CreatePgTriggerRequest, type CronJob, DEFAULT_MAX_RETRIES, DEFAULT_REQUEST_TIMEOUT_MS, type EmailTemplateUpdate, type EmbedRequest, type EmbedResponse, type FcmPublicSettings, type FcmSettingsPatch, type FetchInit, type FileEntry, type FilterOp, type FunctionDef, type FunctionPermissions, type GenerateLinkResult, type GenerateLinkType, type GetClaimsResult, type IdentityInfo, type ImageTransform, type Job, type JwtClaims, LocalAuthStore, type LoginResponse, type MagicLinkRequest, type Meta, type MfaChallenge, type MfaEnrollResponse, type MfaVerifyRequest, type Notification, type NotificationAttempt, type NotificationAttemptStatus, type NotificationChannel, type NotificationChannelStats, type NotificationDeadLetter, type NotificationEvent, type NotificationProviderLog, type NotificationQueueStats, type NotificationRule, type NotificationSettings, type NotificationSettingsPatch, type NotificationSettingsPublic, type NotificationStats, type NotificationStatsWindow, type NotificationStatus, type NotificationTemplate, type NotificationTemplatePreview, type OAuthProviderSetting, type OAuthSignInOptions, type ObjectMeta, type PasswordResetRequest, type PgExecutableRole, type PgFunctionInfo, type PgTriggerInfo, type PostgresChangesFilter, type PresenceFilter, type PresenceInfo, type PresenceState, type QueryFilter, type QueryOptions, type QuotaPublicSettings, type QuotaSettingsPatch, RETRYABLE_METHODS, RETRYABLE_STATUS, type RagIngestRequest, type RagIngestResponse, type RagRequest, type RagResponse, type RealtimeBroadcastEvent, type RealtimeEvent, type RealtimeListenType, type RealtimePostgresChangesBasePayload, type RealtimePostgresChangesPayload, type RealtimePostgresDeletePayload, type RealtimePostgresInsertPayload, type RealtimePostgresUpdatePayload, type RealtimeSubscribeStatus, type SchemaColumn, type SchemaEnum, type SchemaFunction, type SchemaFunctionArg, type SchemaIndex, type SchemaTable, type SemanticSearchResult, type SendNotificationItem, type SendNotificationOptions, type SendNotificationRequest, type SerializeCookieOptions, type ServerErrorMsg, type ServerEventMsg, type ServerMessage, type ServerPongMsg, type ServerPresenceStateMsg, type ServerSubscribedMsg, type ServerTokenRefreshedMsg, type Session, type SessionInfo, type SettingsSource, type SignInRequest, type SignUpRequest, type SmtpPublicSettings, type SmtpSettingsPatch, type StorageBucket, type SubscribeCallback, type TokenPair, type TwilioPublicSettings, type TwilioSettingsPatch, type UpdateNotificationRuleRequest, type UpdateUserRequest, type UploadResult, type User, type UserStats, type WebhookPublicSettings, type WebhookSettingsPatch, abortableSleep, clientScope, computeBackoff, emitAuraEvent, fetchWithAuth, isAbortError, isAuraError, isRetryableMethod, isRetryableStatus, isTokenExpired, parseCookieHeader, parseRetryAfter, refreshOnce, serializeBody, serializeCookieHeader };
package/dist/index.d.ts CHANGED
@@ -715,6 +715,51 @@ interface CdcPayload {
715
715
  record: Record<string, unknown>;
716
716
  old_record: Record<string, unknown> | null;
717
717
  _truncated?: boolean;
718
+ [key: string]: unknown;
719
+ }
720
+ /** Base commune des métadonnées pour un événement CDC PostgreSQL */
721
+ interface RealtimePostgresChangesBasePayload {
722
+ schema: string;
723
+ table: string;
724
+ commit_timestamp: string;
725
+ errors?: string[];
726
+ id: string;
727
+ topic: string;
728
+ timestamp: string;
729
+ payload: CdcPayload | Record<string, unknown>;
730
+ event: 'insert' | 'update' | 'delete';
731
+ }
732
+ /** Payload enrichi pour un événement CDC PostgreSQL d'insertion */
733
+ interface RealtimePostgresInsertPayload<T = Record<string, unknown>> extends RealtimePostgresChangesBasePayload {
734
+ eventType: 'INSERT';
735
+ event: 'insert';
736
+ new: T;
737
+ old: null;
738
+ }
739
+ /** Payload enrichi pour un événement CDC PostgreSQL de mise à jour */
740
+ interface RealtimePostgresUpdatePayload<T = Record<string, unknown>> extends RealtimePostgresChangesBasePayload {
741
+ eventType: 'UPDATE';
742
+ event: 'update';
743
+ new: T;
744
+ old: Partial<T>;
745
+ }
746
+ /** Payload enrichi pour un événement CDC PostgreSQL de suppression */
747
+ interface RealtimePostgresDeletePayload<T = Record<string, unknown>> extends RealtimePostgresChangesBasePayload {
748
+ eventType: 'DELETE';
749
+ event: 'delete';
750
+ new: null;
751
+ old: Partial<T> | null;
752
+ }
753
+ /** Union discriminée par eventType pour les événements CDC PostgreSQL */
754
+ type RealtimePostgresChangesPayload<T = Record<string, unknown>> = RealtimePostgresInsertPayload<T> | RealtimePostgresUpdatePayload<T> | RealtimePostgresDeletePayload<T>;
755
+ /** Événement broadcast reçu avec payload typé */
756
+ interface RealtimeBroadcastEvent<T = Record<string, unknown>> {
757
+ event: string;
758
+ payload: T;
759
+ id?: string;
760
+ topic?: string;
761
+ timestamp?: string;
762
+ allowed_sub_ids?: string[];
718
763
  }
719
764
  /** Status de subscription */
720
765
  type RealtimeSubscribeStatus = 'SUBSCRIBED' | 'CLOSED' | 'CHANNEL_ERROR' | 'TIMED_OUT';
@@ -832,7 +877,12 @@ interface ChannelConfig {
832
877
  };
833
878
  /** Configuration présence directe */
834
879
  presence?: {
835
- /** Clé de présence — permet de regrouper plusieurs onglets/devices du même user */
880
+ /**
881
+ * @deprecated La présence distribuée est indexée de manière autoritaire par le serveur
882
+ * à l'aide de l'identité vérifiée (`user_id` extrait du JWT) et de l'identifiant de connexion WebSocket
883
+ * (`client_id` dans NATS KV). Une clé libre côté client n'est pas utilisée pour partitionner le cluster
884
+ * afin d'empêcher les collisions d'état et les risques d'usurpation d'identité.
885
+ */
836
886
  key?: string;
837
887
  };
838
888
  /** Configuration compatible Supabase sous `config` */
@@ -842,6 +892,9 @@ interface ChannelConfig {
842
892
  self?: boolean;
843
893
  };
844
894
  presence?: {
895
+ /**
896
+ * @deprecated Voir `ChannelConfig.presence.key`. L'identité de présence est sécurisée par `user_id`/`client_id`.
897
+ */
845
898
  key?: string;
846
899
  };
847
900
  private?: boolean;
@@ -940,6 +993,19 @@ interface SemanticSearchResult {
940
993
  metadata: Record<string, unknown>;
941
994
  similarity: number;
942
995
  }
996
+ /** Limites d'exécution d'une fonction (`PATCH /v1/functions/{project}/{name}`). */
997
+ interface FunctionPermissions {
998
+ /** Domaines autorisés en sortie. Stocké mais non appliqué par le runtime actuel. */
999
+ allow_net: string[];
1000
+ /** 16 à 1024, défaut 128. */
1001
+ memory_mb: number;
1002
+ /** 1 à 300, défaut 30 — durée maximale (wall-clock). */
1003
+ timeout_secs: number;
1004
+ }
1005
+ /**
1006
+ * Définition d'une fonction. Contient le code source et les variables d'environnement :
1007
+ * `list()` et `get()` exigent donc une clé `service_role` (usage serveur uniquement).
1008
+ */
943
1009
  interface FunctionDef {
944
1010
  id: string;
945
1011
  project_id: string;
@@ -947,7 +1013,8 @@ interface FunctionDef {
947
1013
  runtime: string;
948
1014
  code: string;
949
1015
  code_hash: string;
950
- env_vars: Record<string, unknown>;
1016
+ env_vars: Record<string, string>;
1017
+ permissions: FunctionPermissions;
951
1018
  is_active: boolean;
952
1019
  created_at: string;
953
1020
  updated_at: string;
@@ -1182,16 +1249,160 @@ interface NotificationStats {
1182
1249
  dead_lettered: number;
1183
1250
  }>;
1184
1251
  }
1252
+ type NotificationChannel = 'email' | 'sms' | 'push' | 'webhook';
1253
+ type NotificationStatus = 'queued' | 'processing' | 'sent' | 'failed' | 'delivered' | 'expired' | 'dead_lettered';
1254
+ type NotificationStatsWindow = '1h' | '24h' | '7d' | '30d';
1255
+ type NotificationAttemptStatus = 'processing' | 'sent' | 'failed' | 'retry_scheduled' | 'dead_lettered';
1256
+ type SettingsSource = 'project' | 'environment' | 'none';
1257
+ interface SmtpPublicSettings {
1258
+ configured: boolean;
1259
+ source: SettingsSource;
1260
+ host?: string | null;
1261
+ port?: number | null;
1262
+ user?: string | null;
1263
+ password_set: boolean;
1264
+ from_email?: string | null;
1265
+ from_name?: string | null;
1266
+ tls: boolean;
1267
+ }
1268
+ interface TwilioPublicSettings {
1269
+ configured: boolean;
1270
+ source: SettingsSource;
1271
+ account_sid_prefix?: string | null;
1272
+ auth_token_set: boolean;
1273
+ from_number?: string | null;
1274
+ status_callback_url?: string | null;
1275
+ }
1276
+ interface FcmPublicSettings {
1277
+ configured: boolean;
1278
+ source: SettingsSource;
1279
+ project_id?: string | null;
1280
+ service_account_json_set: boolean;
1281
+ legacy_server_key_present: boolean;
1282
+ api: string;
1283
+ }
1284
+ interface ApnsPublicSettings {
1285
+ configured: boolean;
1286
+ source: SettingsSource;
1287
+ key_id?: string | null;
1288
+ team_id?: string | null;
1289
+ private_key_set: boolean;
1290
+ bundle_id?: string | null;
1291
+ production: boolean;
1292
+ }
1293
+ interface WebhookPublicSettings {
1294
+ configured: boolean;
1295
+ source: SettingsSource;
1296
+ max_retries: number;
1297
+ retry_delay_ms: number;
1298
+ timeout_secs: number;
1299
+ secret_set: boolean;
1300
+ signature_tolerance_secs: number;
1301
+ }
1302
+ interface QuotaPublicSettings {
1303
+ source: SettingsSource;
1304
+ project_rate_limit_per_minute: number;
1305
+ channel_rate_limit_per_minute: number;
1306
+ batch_max_size: number;
1307
+ }
1308
+ interface SmtpSettingsPatch {
1309
+ host?: string | null;
1310
+ port?: number | null;
1311
+ user?: string | null;
1312
+ password?: string | null;
1313
+ from_email?: string | null;
1314
+ from_name?: string | null;
1315
+ tls?: boolean | null;
1316
+ }
1317
+ interface TwilioSettingsPatch {
1318
+ account_sid?: string | null;
1319
+ auth_token?: string | null;
1320
+ from_number?: string | null;
1321
+ }
1322
+ interface FcmSettingsPatch {
1323
+ project_id?: string | null;
1324
+ service_account_json?: string | null;
1325
+ }
1326
+ interface ApnsSettingsPatch {
1327
+ key_id?: string | null;
1328
+ team_id?: string | null;
1329
+ private_key_b64?: string | null;
1330
+ bundle_id?: string | null;
1331
+ production?: boolean | null;
1332
+ }
1333
+ interface WebhookSettingsPatch {
1334
+ max_retries?: number | null;
1335
+ retry_delay_ms?: number | null;
1336
+ timeout_secs?: number | null;
1337
+ secret?: string | null;
1338
+ }
1339
+ interface QuotaSettingsPatch {
1340
+ project_rate_limit_per_minute?: number | null;
1341
+ channel_rate_limit_per_minute?: number | null;
1342
+ batch_max_size?: number | null;
1343
+ }
1344
+ interface NotificationSettingsPatch {
1345
+ smtp?: SmtpSettingsPatch | null;
1346
+ twilio?: TwilioSettingsPatch | null;
1347
+ fcm?: FcmSettingsPatch | null;
1348
+ apns?: ApnsSettingsPatch | null;
1349
+ webhook?: WebhookSettingsPatch | null;
1350
+ quotas?: QuotaSettingsPatch | null;
1351
+ }
1185
1352
  interface NotificationSettings {
1186
1353
  project_id: string;
1187
- smtp?: Record<string, unknown>;
1188
- twilio?: Record<string, unknown>;
1189
- fcm?: Record<string, unknown>;
1190
- apns?: Record<string, unknown>;
1191
- webhook?: Record<string, unknown>;
1192
- quotas?: Record<string, unknown>;
1354
+ smtp?: SmtpPublicSettings | Record<string, unknown>;
1355
+ twilio?: TwilioPublicSettings | Record<string, unknown>;
1356
+ fcm?: FcmPublicSettings | Record<string, unknown>;
1357
+ apns?: ApnsPublicSettings | Record<string, unknown>;
1358
+ webhook?: WebhookPublicSettings | Record<string, unknown>;
1359
+ quotas?: QuotaPublicSettings | Record<string, unknown>;
1193
1360
  updated_at?: string | null;
1194
1361
  }
1362
+ type NotificationSettingsPublic = NotificationSettings;
1363
+ interface CreateNotificationRuleRequest {
1364
+ name: string;
1365
+ trigger_type: string;
1366
+ condition?: Record<string, unknown>;
1367
+ template_id?: string | null;
1368
+ channel: NotificationChannel;
1369
+ recipient_expr: string;
1370
+ delay_seconds?: number;
1371
+ }
1372
+ interface UpdateNotificationRuleRequest {
1373
+ name?: string;
1374
+ enabled?: boolean;
1375
+ trigger_type?: string;
1376
+ condition?: Record<string, unknown>;
1377
+ template_id?: string | null;
1378
+ channel?: NotificationChannel;
1379
+ recipient_expr?: string;
1380
+ delay_seconds?: number;
1381
+ }
1382
+ interface SendNotificationOptions {
1383
+ channel: NotificationChannel;
1384
+ recipient: string;
1385
+ body?: string;
1386
+ subject?: string;
1387
+ templateId?: string;
1388
+ template_id?: string;
1389
+ variables?: Record<string, unknown>;
1390
+ metadata?: Record<string, unknown>;
1391
+ idempotencyKey?: string;
1392
+ idempotency_key?: string;
1393
+ }
1394
+ interface SendNotificationItem {
1395
+ channel: NotificationChannel;
1396
+ recipient: string;
1397
+ body?: string;
1398
+ subject?: string;
1399
+ templateId?: string;
1400
+ template_id?: string;
1401
+ variables?: Record<string, unknown>;
1402
+ metadata?: Record<string, unknown>;
1403
+ idempotencyKey?: string;
1404
+ idempotency_key?: string;
1405
+ }
1195
1406
  interface NotificationRule {
1196
1407
  id: string;
1197
1408
  project_id: string;
@@ -1199,7 +1410,7 @@ interface NotificationRule {
1199
1410
  trigger_type: string;
1200
1411
  condition: Record<string, unknown>;
1201
1412
  template_id?: string | null;
1202
- channel: 'email' | 'sms' | 'push' | 'webhook';
1413
+ channel: NotificationChannel;
1203
1414
  recipient_expr: string;
1204
1415
  enabled: boolean;
1205
1416
  delay_seconds: number;
@@ -1554,6 +1765,10 @@ interface GetClaimsResult {
1554
1765
  kid?: string;
1555
1766
  typ?: string;
1556
1767
  };
1768
+ sub?: string;
1769
+ email?: string | null;
1770
+ role?: string;
1771
+ [key: string]: unknown;
1557
1772
  }
1558
1773
 
1559
1774
  type AuthChangeCallback = (token: string | null, user: User | null) => void;
@@ -1625,6 +1840,8 @@ interface AuraClientLike {
1625
1840
  */
1626
1841
  readonly baseUrl: string;
1627
1842
  readonly apiKey: string | null;
1843
+ /** Identifiant optionnel du projet résolu ou configuré sur le client */
1844
+ readonly projectId?: string;
1628
1845
  readonly fetchFn: typeof globalThis.fetch;
1629
1846
  readonly authStore: BaseAuthStore;
1630
1847
  /** Consommé uniquement par le service realtime (refresh proactif du token). */
@@ -1818,4 +2035,4 @@ declare class LocalAuthStore extends BaseAuthStore {
1818
2035
  private _removeStorage;
1819
2036
  }
1820
2037
 
1821
- export { AUTH_SETTINGS_WRITABLE_FIELDS, type AdminCreateUserRequest, type AdminSessionInfo, type AdminUpdateUserRequest, type AdminUser, type AuditLogEntry, type AuraClientLike, type AuraClientOptions, AuraError, type AuraErrorCode, type AuraFailure, type AuraNoContent, type AuraObservabilityEvent, type AuraResponse, type AuraSuccess, type AuthChangePayload, type AuthEvent, type AuthSettings, type AuthSettingsUpdate, BaseAuthStore, BaseService, type BatchSendItemResult, type BatchSendResponse, type BroadcastAckMessage, type BroadcastFilter, type BroadcastPayload, type BroadcastSendStatus, type CdcPayload, type ChannelConfig, type ChatMessage, type ChatResponse, type CountMode, type CreatePgFunctionRequest, type CreatePgTriggerRequest, type CronJob, DEFAULT_MAX_RETRIES, DEFAULT_REQUEST_TIMEOUT_MS, type EmailTemplateUpdate, type EmbedRequest, type EmbedResponse, type FetchInit, type FileEntry, type FilterOp, type FunctionDef, type GenerateLinkResult, type GenerateLinkType, type GetClaimsResult, type IdentityInfo, type ImageTransform, type Job, type JwtClaims, LocalAuthStore, type LoginResponse, type MagicLinkRequest, type Meta, type MfaChallenge, type MfaEnrollResponse, type MfaVerifyRequest, type Notification, type NotificationAttempt, type NotificationChannelStats, type NotificationDeadLetter, type NotificationEvent, type NotificationProviderLog, type NotificationQueueStats, type NotificationRule, type NotificationSettings, type NotificationStats, type NotificationTemplate, type NotificationTemplatePreview, type OAuthProviderSetting, type OAuthSignInOptions, type ObjectMeta, type PasswordResetRequest, type PgExecutableRole, type PgFunctionInfo, type PgTriggerInfo, type PostgresChangesFilter, type PresenceFilter, type PresenceInfo, type PresenceState, type QueryFilter, type QueryOptions, RETRYABLE_METHODS, RETRYABLE_STATUS, type RagIngestRequest, type RagIngestResponse, type RagRequest, type RagResponse, type RealtimeEvent, type RealtimeListenType, type RealtimeSubscribeStatus, type SchemaColumn, type SchemaEnum, type SchemaFunction, type SchemaFunctionArg, type SchemaIndex, type SchemaTable, type SemanticSearchResult, type SendNotificationRequest, type SerializeCookieOptions, type ServerErrorMsg, type ServerEventMsg, type ServerMessage, type ServerPongMsg, type ServerPresenceStateMsg, type ServerSubscribedMsg, type ServerTokenRefreshedMsg, type Session, type SessionInfo, type SignInRequest, type SignUpRequest, type StorageBucket, type SubscribeCallback, type TokenPair, type UpdateUserRequest, type UploadResult, type User, type UserStats, abortableSleep, clientScope, computeBackoff, emitAuraEvent, fetchWithAuth, isAbortError, isAuraError, isRetryableMethod, isRetryableStatus, isTokenExpired, parseCookieHeader, parseRetryAfter, refreshOnce, serializeBody, serializeCookieHeader };
2038
+ export { AUTH_SETTINGS_WRITABLE_FIELDS, type AdminCreateUserRequest, type AdminSessionInfo, type AdminUpdateUserRequest, type AdminUser, type ApnsPublicSettings, type ApnsSettingsPatch, type AuditLogEntry, type AuraClientLike, type AuraClientOptions, AuraError, type AuraErrorCode, type AuraFailure, type AuraNoContent, type AuraObservabilityEvent, type AuraResponse, type AuraSuccess, type AuthChangePayload, type AuthEvent, type AuthSettings, type AuthSettingsUpdate, BaseAuthStore, BaseService, type BatchSendItemResult, type BatchSendResponse, type BroadcastAckMessage, type BroadcastFilter, type BroadcastPayload, type BroadcastSendStatus, type CdcPayload, type ChannelConfig, type ChatMessage, type ChatResponse, type CountMode, type CreateNotificationRuleRequest, type CreatePgFunctionRequest, type CreatePgTriggerRequest, type CronJob, DEFAULT_MAX_RETRIES, DEFAULT_REQUEST_TIMEOUT_MS, type EmailTemplateUpdate, type EmbedRequest, type EmbedResponse, type FcmPublicSettings, type FcmSettingsPatch, type FetchInit, type FileEntry, type FilterOp, type FunctionDef, type FunctionPermissions, type GenerateLinkResult, type GenerateLinkType, type GetClaimsResult, type IdentityInfo, type ImageTransform, type Job, type JwtClaims, LocalAuthStore, type LoginResponse, type MagicLinkRequest, type Meta, type MfaChallenge, type MfaEnrollResponse, type MfaVerifyRequest, type Notification, type NotificationAttempt, type NotificationAttemptStatus, type NotificationChannel, type NotificationChannelStats, type NotificationDeadLetter, type NotificationEvent, type NotificationProviderLog, type NotificationQueueStats, type NotificationRule, type NotificationSettings, type NotificationSettingsPatch, type NotificationSettingsPublic, type NotificationStats, type NotificationStatsWindow, type NotificationStatus, type NotificationTemplate, type NotificationTemplatePreview, type OAuthProviderSetting, type OAuthSignInOptions, type ObjectMeta, type PasswordResetRequest, type PgExecutableRole, type PgFunctionInfo, type PgTriggerInfo, type PostgresChangesFilter, type PresenceFilter, type PresenceInfo, type PresenceState, type QueryFilter, type QueryOptions, type QuotaPublicSettings, type QuotaSettingsPatch, RETRYABLE_METHODS, RETRYABLE_STATUS, type RagIngestRequest, type RagIngestResponse, type RagRequest, type RagResponse, type RealtimeBroadcastEvent, type RealtimeEvent, type RealtimeListenType, type RealtimePostgresChangesBasePayload, type RealtimePostgresChangesPayload, type RealtimePostgresDeletePayload, type RealtimePostgresInsertPayload, type RealtimePostgresUpdatePayload, type RealtimeSubscribeStatus, type SchemaColumn, type SchemaEnum, type SchemaFunction, type SchemaFunctionArg, type SchemaIndex, type SchemaTable, type SemanticSearchResult, type SendNotificationItem, type SendNotificationOptions, type SendNotificationRequest, type SerializeCookieOptions, type ServerErrorMsg, type ServerEventMsg, type ServerMessage, type ServerPongMsg, type ServerPresenceStateMsg, type ServerSubscribedMsg, type ServerTokenRefreshedMsg, type Session, type SessionInfo, type SettingsSource, type SignInRequest, type SignUpRequest, type SmtpPublicSettings, type SmtpSettingsPatch, type StorageBucket, type SubscribeCallback, type TokenPair, type TwilioPublicSettings, type TwilioSettingsPatch, type UpdateNotificationRuleRequest, type UpdateUserRequest, type UploadResult, type User, type UserStats, type WebhookPublicSettings, type WebhookSettingsPatch, abortableSleep, clientScope, computeBackoff, emitAuraEvent, fetchWithAuth, isAbortError, isAuraError, isRetryableMethod, isRetryableStatus, isTokenExpired, parseCookieHeader, parseRetryAfter, refreshOnce, serializeBody, serializeCookieHeader };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aurabase/core",
3
- "version": "0.5.3",
3
+ "version": "0.6.0",
4
4
  "description": "Cœur du SDK Aurabase : fetch résilient, erreurs, stores auth, types de réponse (infrastructure interne)",
5
5
  "type": "module",
6
6
  "main": "dist/index.cjs",