@aurabase/aurabase-js 0.3.0 → 0.3.1
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/package.json +4 -4
- package/packages/ai/node_modules/.bin/esbuild +0 -19
- package/packages/ai/node_modules/.bin/tsc +0 -22
- package/packages/ai/node_modules/.bin/tsserver +0 -22
- package/packages/ai/node_modules/.bin/tsup +0 -22
- package/packages/ai/node_modules/.bin/tsup-node +0 -22
- package/packages/ai/node_modules/.bin/vite +0 -22
- package/packages/ai/node_modules/.bin/vitest +0 -22
- package/packages/ai/node_modules/.vite/vitest/da39a3ee5e6b4b0d3255bfef95601890afd80709/results.json +0 -1
- package/packages/ai/src/AiService.ts +0 -226
- package/packages/ai/src/index.ts +0 -18
- package/packages/ai/src/sse.ts +0 -141
- package/packages/ai/src/types.ts +0 -30
- package/packages/ai/tests/chat-stream.test.ts +0 -151
- package/packages/ai/tests/rag-namespaces.test.ts +0 -54
- package/packages/ai/tests/sse.test.ts +0 -69
- package/packages/ai/tsconfig.json +0 -5
- package/packages/ai/tsup.config.ts +0 -11
- package/packages/aurabase/node_modules/.bin/esbuild +0 -19
- package/packages/aurabase/node_modules/.bin/tsc +0 -22
- package/packages/aurabase/node_modules/.bin/tsserver +0 -22
- package/packages/aurabase/node_modules/.bin/tsup +0 -22
- package/packages/aurabase/node_modules/.bin/tsup-node +0 -22
- package/packages/aurabase/node_modules/.bin/vite +0 -22
- package/packages/aurabase/node_modules/.bin/vitest +0 -22
- package/packages/aurabase/node_modules/.vite/vitest/da39a3ee5e6b4b0d3255bfef95601890afd80709/results.json +0 -1
- package/packages/aurabase/src/AuraClient.ts +0 -237
- package/packages/aurabase/src/index.ts +0 -152
- package/packages/aurabase/src/ssr.ts +0 -156
- package/packages/aurabase/tests/ai-streaming-rag-e2e.test.ts +0 -82
- package/packages/aurabase/tests/ai.test.ts +0 -111
- package/packages/aurabase/tests/auth-admin.test.ts +0 -515
- package/packages/aurabase/tests/auth-e2e.test.ts +0 -135
- package/packages/aurabase/tests/auth-hardening.test.ts +0 -206
- package/packages/aurabase/tests/auth.test.ts +0 -947
- package/packages/aurabase/tests/database.test.ts +0 -230
- package/packages/aurabase/tests/db-types-e2e.test.ts +0 -217
- package/packages/aurabase/tests/dispose.test.ts +0 -23
- package/packages/aurabase/tests/foreign-token.e2e.test.ts +0 -129
- package/packages/aurabase/tests/functions.test.ts +0 -107
- package/packages/aurabase/tests/integration.test.ts +0 -413
- package/packages/aurabase/tests/live-production-validation.js +0 -241
- package/packages/aurabase/tests/live-sdk-production-validation.js +0 -293
- package/packages/aurabase/tests/mocks.ts +0 -139
- package/packages/aurabase/tests/notifications.test.ts +0 -314
- package/packages/aurabase/tests/observability-backup.test.ts +0 -186
- package/packages/aurabase/tests/observability-hook.test.ts +0 -130
- package/packages/aurabase/tests/production-robustness.test.ts +0 -268
- package/packages/aurabase/tests/public-api-surface.test.ts +0 -53
- package/packages/aurabase/tests/query-builder.test.ts +0 -329
- package/packages/aurabase/tests/readme-smoke-e2e.test.ts +0 -231
- package/packages/aurabase/tests/realtime-filter-e2e.test.ts +0 -344
- package/packages/aurabase/tests/refresh-locks.test.ts +0 -210
- package/packages/aurabase/tests/retry-option.test.ts +0 -17
- package/packages/aurabase/tests/rpc-e2e.test.ts +0 -254
- package/packages/aurabase/tests/rs256-local-e2e.test.ts +0 -114
- package/packages/aurabase/tests/rt-alias-public-e2e.test.ts +0 -235
- package/packages/aurabase/tests/rt-http-broadcast-e2e.test.ts +0 -124
- package/packages/aurabase/tests/service-role-guard.test.ts +0 -99
- package/packages/aurabase/tests/ssr.test.ts +0 -91
- package/packages/aurabase/tests/storage-backend-e2e.test.ts +0 -481
- package/packages/aurabase/tests/storage-sdk-parity-e2e.test.ts +0 -104
- package/packages/aurabase/tests/storage-transform-e2e.test.ts +0 -684
- package/packages/aurabase/tests/storage.test.ts +0 -55
- package/packages/aurabase/tests/types/client-generic.test-d.ts +0 -79
- package/packages/aurabase/tests/types/docs-snippets.test-d.ts +0 -571
- package/packages/aurabase/tests/types/error-code.test-d.ts +0 -53
- package/packages/aurabase/tsconfig.json +0 -5
- package/packages/aurabase/tsconfig.test-d.json +0 -5
- package/packages/aurabase/tsup.config.ts +0 -11
- package/packages/aurabase/vitest.config.ts +0 -16
- package/packages/auth/node_modules/.bin/esbuild +0 -19
- package/packages/auth/node_modules/.bin/tsc +0 -22
- package/packages/auth/node_modules/.bin/tsserver +0 -22
- package/packages/auth/node_modules/.bin/tsup +0 -22
- package/packages/auth/node_modules/.bin/tsup-node +0 -22
- package/packages/auth/node_modules/.bin/vite +0 -22
- package/packages/auth/node_modules/.bin/vitest +0 -22
- package/packages/auth/node_modules/.vite/vitest/da39a3ee5e6b4b0d3255bfef95601890afd80709/results.json +0 -1
- package/packages/auth/src/AuthAdminService.ts +0 -149
- package/packages/auth/src/AuthService.ts +0 -1166
- package/packages/auth/src/SessionManager.ts +0 -92
- package/packages/auth/src/index.ts +0 -17
- package/packages/auth/src/jwks.ts +0 -337
- package/packages/auth/src/pkce.ts +0 -27
- package/packages/auth/src/types.ts +0 -89
- package/packages/auth/tests/auth-lifecycle.test.ts +0 -149
- package/packages/auth/tests/detect-session.test.ts +0 -361
- package/packages/auth/tests/getclaims.test.ts +0 -780
- package/packages/auth/tests/is-mfa-challenge.test.ts +0 -27
- package/packages/auth/tests/password-recovery.test.ts +0 -124
- package/packages/auth/tests/pkce.test.ts +0 -192
- package/packages/auth/tests/session-manager.test.ts +0 -103
- package/packages/auth/tests/set-session.test.ts +0 -139
- package/packages/auth/tests/verify-otp.test.ts +0 -153
- package/packages/auth/tsconfig.json +0 -5
- package/packages/auth/tsup.config.ts +0 -11
- package/packages/core/node_modules/.bin/esbuild +0 -22
- package/packages/core/node_modules/.bin/tsc +0 -22
- package/packages/core/node_modules/.bin/tsserver +0 -22
- package/packages/core/node_modules/.bin/tsup +0 -22
- package/packages/core/node_modules/.bin/tsup-node +0 -22
- package/packages/core/node_modules/.bin/vite +0 -22
- package/packages/core/node_modules/.bin/vitest +0 -22
- package/packages/core/node_modules/.vite/vitest/da39a3ee5e6b4b0d3255bfef95601890afd80709/results.json +0 -1
- package/packages/core/src/AuraError.ts +0 -89
- package/packages/core/src/BaseService.ts +0 -44
- package/packages/core/src/client.ts +0 -34
- package/packages/core/src/cookie-utils.ts +0 -42
- package/packages/core/src/fetch.ts +0 -435
- package/packages/core/src/index.ts +0 -22
- package/packages/core/src/retry.ts +0 -63
- package/packages/core/src/serialize.ts +0 -6
- package/packages/core/src/stores/BaseAuthStore.ts +0 -164
- package/packages/core/src/stores/LocalAuthStore.ts +0 -199
- package/packages/core/src/types.ts +0 -1042
- package/packages/core/tests/auth-store.test.ts +0 -300
- package/packages/core/tests/error-code.test.ts +0 -61
- package/packages/core/tests/error.test.ts +0 -24
- package/packages/core/tests/fetch.test.ts +0 -286
- package/packages/core/tests/mocks.ts +0 -139
- package/packages/core/tests/observability.test.ts +0 -86
- package/packages/core/tests/refresh-hardening.test.ts +0 -164
- package/packages/core/tests/refresh-observability.test.ts +0 -111
- package/packages/core/tests/retry.test.ts +0 -106
- package/packages/core/tests/serialize.test.ts +0 -12
- package/packages/core/tests/timeout.test.ts +0 -79
- package/packages/core/tsconfig.json +0 -5
- package/packages/core/tsup.config.ts +0 -11
- package/packages/db/node_modules/.bin/esbuild +0 -19
- package/packages/db/node_modules/.bin/tsc +0 -22
- package/packages/db/node_modules/.bin/tsserver +0 -22
- package/packages/db/node_modules/.bin/tsup +0 -22
- package/packages/db/node_modules/.bin/tsup-node +0 -22
- package/packages/db/node_modules/.bin/vite +0 -22
- package/packages/db/node_modules/.bin/vitest +0 -22
- package/packages/db/node_modules/.vite/vitest/da39a3ee5e6b4b0d3255bfef95601890afd80709/results.json +0 -1
- package/packages/db/src/DatabaseService.ts +0 -170
- package/packages/db/src/QueryBuilder.ts +0 -830
- package/packages/db/src/index.ts +0 -2
- package/packages/db/src/pgrst-types/common/common.ts +0 -86
- package/packages/db/src/pgrst-types/common/rpc.ts +0 -151
- package/packages/db/src/pgrst-types/feature-flags.ts +0 -20
- package/packages/db/src/pgrst-types/types.ts +0 -134
- package/packages/db/src/select-query-parser/parser.ts +0 -479
- package/packages/db/src/select-query-parser/result.ts +0 -553
- package/packages/db/src/select-query-parser/types.ts +0 -132
- package/packages/db/src/select-query-parser/utils.ts +0 -707
- package/packages/db/tests/filters.test.ts +0 -81
- package/packages/db/tests/mutations-filtered.e2e.test.ts +0 -132
- package/packages/db/tests/mutations-filtered.test.ts +0 -188
- package/packages/db/tests/order.test.ts +0 -45
- package/packages/db/tests/rpc.test.ts +0 -41
- package/packages/db/tests/scale/build-large-schema.ts +0 -94
- package/packages/db/tests/scale/scale-compile.test.ts +0 -167
- package/packages/db/tests/schema.test.ts +0 -77
- package/packages/db/tests/single-accept.e2e.test.ts +0 -123
- package/packages/db/tests/single.test.ts +0 -211
- package/packages/db/tests/types/filters.test-d.ts +0 -52
- package/packages/db/tests/types/fixtures.ts +0 -40
- package/packages/db/tests/types/from-views.test-d.ts +0 -18
- package/packages/db/tests/types/mutations.test-d.ts +0 -23
- package/packages/db/tests/types/rpc.test-d.ts +0 -60
- package/packages/db/tests/types/schema-shape.test-d.ts +0 -8
- package/packages/db/tests/types/select-inference.test-d.ts +0 -38
- package/packages/db/tests/vendored/fixtures.ts +0 -83
- package/packages/db/tests/vendored/get-result.test-d.ts +0 -75
- package/packages/db/tsconfig.json +0 -5
- package/packages/db/tsconfig.test-d.json +0 -5
- package/packages/db/tsup.config.ts +0 -11
- package/packages/db/vitest.config.ts +0 -8
- package/packages/functions/node_modules/.bin/esbuild +0 -19
- package/packages/functions/node_modules/.bin/tsc +0 -22
- package/packages/functions/node_modules/.bin/tsserver +0 -22
- package/packages/functions/node_modules/.bin/tsup +0 -22
- package/packages/functions/node_modules/.bin/tsup-node +0 -22
- package/packages/functions/node_modules/.bin/vite +0 -22
- package/packages/functions/node_modules/.bin/vitest +0 -22
- package/packages/functions/node_modules/.vite/vitest/da39a3ee5e6b4b0d3255bfef95601890afd80709/results.json +0 -1
- package/packages/functions/src/FunctionsService.ts +0 -188
- package/packages/functions/src/errors.ts +0 -70
- package/packages/functions/src/index.ts +0 -6
- package/packages/functions/tests/invoke.test.ts +0 -97
- package/packages/functions/tests/response-type-errors.test.ts +0 -135
- package/packages/functions/tsconfig.json +0 -5
- package/packages/functions/tsup.config.ts +0 -11
- package/packages/gen/node_modules/.bin/esbuild +0 -19
- package/packages/gen/node_modules/.bin/tsc +0 -22
- package/packages/gen/node_modules/.bin/tsserver +0 -22
- package/packages/gen/node_modules/.bin/tsup +0 -22
- package/packages/gen/node_modules/.bin/tsup-node +0 -22
- package/packages/gen/node_modules/.bin/vite +0 -22
- package/packages/gen/node_modules/.bin/vitest +0 -22
- package/packages/gen/node_modules/.vite/vitest/da39a3ee5e6b4b0d3255bfef95601890afd80709/results.json +0 -1
- package/packages/gen/src/cli.ts +0 -67
- package/packages/gen/src/generate.ts +0 -0
- package/packages/gen/src/index.ts +0 -2
- package/packages/gen/tests/compile.test.ts +0 -213
- package/packages/gen/tests/e2e.test.ts +0 -130
- package/packages/gen/tests/generate.test.ts +0 -396
- package/packages/gen/tsconfig.json +0 -5
- package/packages/gen/tsup.config.ts +0 -11
- package/packages/notifications/node_modules/.bin/esbuild +0 -19
- package/packages/notifications/node_modules/.bin/tsc +0 -22
- package/packages/notifications/node_modules/.bin/tsserver +0 -22
- package/packages/notifications/node_modules/.bin/tsup +0 -22
- package/packages/notifications/node_modules/.bin/tsup-node +0 -22
- package/packages/notifications/node_modules/.bin/vite +0 -22
- package/packages/notifications/node_modules/.bin/vitest +0 -22
- package/packages/notifications/src/NotificationsService.ts +0 -230
- package/packages/notifications/src/index.ts +0 -19
- package/packages/notifications/tsconfig.json +0 -5
- package/packages/notifications/tsup.config.ts +0 -11
- package/packages/realtime/node_modules/.bin/esbuild +0 -19
- package/packages/realtime/node_modules/.bin/tsc +0 -22
- package/packages/realtime/node_modules/.bin/tsserver +0 -22
- package/packages/realtime/node_modules/.bin/tsup +0 -22
- package/packages/realtime/node_modules/.bin/tsup-node +0 -22
- package/packages/realtime/node_modules/.bin/vite +0 -22
- package/packages/realtime/node_modules/.bin/vitest +0 -22
- package/packages/realtime/node_modules/.vite/vitest/da39a3ee5e6b4b0d3255bfef95601890afd80709/results.json +0 -1
- package/packages/realtime/src/AuraChannel.ts +0 -485
- package/packages/realtime/src/HeartbeatManager.ts +0 -73
- package/packages/realtime/src/RealtimeService.ts +0 -505
- package/packages/realtime/src/columnFilter.ts +0 -301
- package/packages/realtime/src/index.ts +0 -4
- package/packages/realtime/tests/ack-routing.test.ts +0 -81
- package/packages/realtime/tests/column-filter.test.ts +0 -144
- package/packages/realtime/tests/dispatch.test.ts +0 -191
- package/packages/realtime/tests/heartbeat.test.ts +0 -67
- package/packages/realtime/tests/http-broadcast.test.ts +0 -68
- package/packages/realtime/tests/realtime-token.test.ts +0 -43
- package/packages/realtime/tests/reconnect-race.test.ts +0 -149
- package/packages/realtime/tests/ref-id.test.ts +0 -34
- package/packages/realtime/tests/set-auth.test.ts +0 -70
- package/packages/realtime/tsconfig.json +0 -5
- package/packages/realtime/tsup.config.ts +0 -11
- package/packages/storage/node_modules/.bin/esbuild +0 -19
- package/packages/storage/node_modules/.bin/tsc +0 -22
- package/packages/storage/node_modules/.bin/tsserver +0 -22
- package/packages/storage/node_modules/.bin/tsup +0 -22
- package/packages/storage/node_modules/.bin/tsup-node +0 -22
- package/packages/storage/node_modules/.bin/vite +0 -22
- package/packages/storage/node_modules/.bin/vitest +0 -22
- package/packages/storage/node_modules/.vite/vitest/da39a3ee5e6b4b0d3255bfef95601890afd80709/results.json +0 -1
- package/packages/storage/src/DownloadBuilder.ts +0 -60
- package/packages/storage/src/StorageService.ts +0 -323
- package/packages/storage/src/index.ts +0 -2
- package/packages/storage/src/path.ts +0 -35
- package/packages/storage/src/transform.ts +0 -15
- package/packages/storage/tests/download.test.ts +0 -64
- package/packages/storage/tests/parity.test.ts +0 -154
- package/packages/storage/tests/path.test.ts +0 -87
- package/packages/storage/tests/transform.test.ts +0 -79
- package/packages/storage/tsconfig.json +0 -5
- package/packages/storage/tsup.config.ts +0 -11
- package/pnpm-workspace.yaml +0 -24
- package/tsconfig.base.json +0 -15
|
@@ -1,188 +0,0 @@
|
|
|
1
|
-
import { BaseService, AuraError, isTokenExpired, refreshOnce, isAbortError } from '@aurabase/core'
|
|
2
|
-
import type { AuraResponse, CronJob, FunctionDef, Job } from '@aurabase/core'
|
|
3
|
-
import type { AuraClientLike } from '@aurabase/core'
|
|
4
|
-
import { FunctionsRelayError, toFunctionsError } from './errors'
|
|
5
|
-
|
|
6
|
-
/** Type de réponse attendu de l'invocation (parité `@supabase/functions-js`). */
|
|
7
|
-
export type FunctionsResponseType = 'json' | 'text' | 'blob' | 'arrayBuffer'
|
|
8
|
-
|
|
9
|
-
export class FunctionsService extends BaseService {
|
|
10
|
-
constructor(client: AuraClientLike) {
|
|
11
|
-
super(client)
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
private get prefix(): string {
|
|
15
|
-
return `/v1/functions/${this.client.projectId}`
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
// -- Function invocation ----------------------------------------------------
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
* Invoque une edge function.
|
|
22
|
-
*
|
|
23
|
-
* `responseType` (parité `@supabase/functions-js`, défaut `'json'`) :
|
|
24
|
-
* - `'json'` : chemin PIPELINE inchangé (refresh proactif centralisé, injection
|
|
25
|
-
* apikey/Authorization, dé-wrapping `{data,meta}`, retryConfig). Non-régression.
|
|
26
|
-
* - `'text' | 'blob' | 'arrayBuffer'` : chemin TRANSPORT BRUT `client.fetchFn`
|
|
27
|
-
* (patron `StorageService`, SANS toucher `core/fetch.ts`) — refresh proactif
|
|
28
|
-
* manuel, pose de `Authorization`/`apikey`, puis `res.text()/blob()/arrayBuffer()`
|
|
29
|
-
* sans dé-wrapping (le corps HTTP est renvoyé tel quel).
|
|
30
|
-
*
|
|
31
|
-
* Erreurs typées (parité) : une réponse HTTP non-2xx → `FunctionsHttpError`, une
|
|
32
|
-
* panne de relais/infra (réseau, 502/503/504) → `FunctionsRelayError` ; les deux
|
|
33
|
-
* sous-classent `AuraError` (rétrocompat `isAuraError`/champ `error`). `timeout`/
|
|
34
|
-
* `signal` continuent de produire le code `timeout`.
|
|
35
|
-
*/
|
|
36
|
-
async invoke<T = unknown>(
|
|
37
|
-
slug: string,
|
|
38
|
-
options?: {
|
|
39
|
-
body?: unknown
|
|
40
|
-
method?: string
|
|
41
|
-
path?: string
|
|
42
|
-
headers?: Record<string, string>
|
|
43
|
-
signal?: AbortSignal
|
|
44
|
-
timeout?: number
|
|
45
|
-
responseType?: FunctionsResponseType
|
|
46
|
-
},
|
|
47
|
-
): Promise<AuraResponse<T>> {
|
|
48
|
-
const controller = new AbortController()
|
|
49
|
-
let timeoutId: ReturnType<typeof setTimeout> | undefined
|
|
50
|
-
const userSignal = options?.signal
|
|
51
|
-
const onAbort = () => controller.abort()
|
|
52
|
-
if (options?.timeout) timeoutId = setTimeout(() => controller.abort(), options.timeout)
|
|
53
|
-
if (userSignal) {
|
|
54
|
-
// Un signal déjà avorté à l'entrée doit couper immédiatement (addEventListener ne
|
|
55
|
-
// rejouerait pas un 'abort' déjà émis).
|
|
56
|
-
if (userSignal.aborted) controller.abort()
|
|
57
|
-
else userSignal.addEventListener('abort', onAbort, { once: true })
|
|
58
|
-
}
|
|
59
|
-
// Nettoyage exécuté en succès ET en erreur — évite de fuir le listener quand l'appelant
|
|
60
|
-
// réutilise un même AbortSignal longue-durée sur plusieurs invoke().
|
|
61
|
-
const cleanup = () => {
|
|
62
|
-
if (timeoutId) clearTimeout(timeoutId)
|
|
63
|
-
if (userSignal) userSignal.removeEventListener('abort', onAbort)
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
const envelope = { method: options?.method, path: options?.path, headers: options?.headers, body: options?.body }
|
|
67
|
-
const responseType = options?.responseType ?? 'json'
|
|
68
|
-
const timeoutError = (): AuraResponse<T> => ({
|
|
69
|
-
data: null,
|
|
70
|
-
error: new AuraError(0, {
|
|
71
|
-
error: { code: 'timeout', message: 'Function invocation aborted or timed out' },
|
|
72
|
-
}),
|
|
73
|
-
})
|
|
74
|
-
|
|
75
|
-
try {
|
|
76
|
-
if (responseType === 'json') {
|
|
77
|
-
// Passe par le pipeline unifié (fetchWithAuth via BaseService.request) : refresh
|
|
78
|
-
// proactif à marge CENTRALISÉE, injection apikey/Authorization, dé-wrapping
|
|
79
|
-
// `{data,meta}` et respect de `retryConfig`. Un POST n'est jamais rejoué.
|
|
80
|
-
const res = await this.request<T>('POST', `${this.prefix}/${slug}/invoke`, envelope, {
|
|
81
|
-
signal: controller.signal,
|
|
82
|
-
})
|
|
83
|
-
if (res.error && controller.signal.aborted) return timeoutError()
|
|
84
|
-
// Taxonomie d'erreurs : mappe une erreur HTTP vers FunctionsHttpError/RelayError.
|
|
85
|
-
if (res.error) return { data: null, error: toFunctionsError(res.error) }
|
|
86
|
-
return res
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
// ── Chemin transport BRUT (text/blob/arrayBuffer) ──────────────────────
|
|
90
|
-
const client = this.client
|
|
91
|
-
const store = client.authStore
|
|
92
|
-
if (store.token && store.refreshToken && isTokenExpired(store.token, 30)) {
|
|
93
|
-
await refreshOnce(client)
|
|
94
|
-
}
|
|
95
|
-
const headers: Record<string, string> = {
|
|
96
|
-
'Content-Type': 'application/json',
|
|
97
|
-
// Négocie le mode passthrough côté backend : réponse HTTP BRUTE (statut réel de la
|
|
98
|
-
// fonction + content-type réel + corps brut) au lieu de l'enveloppe `{data,meta}`.
|
|
99
|
-
// Indispensable pour que `res.text()/blob()/arrayBuffer()` reçoive le corps de la
|
|
100
|
-
// fonction (et non l'enveloppe JSON) et que `res.status` porte le statut fonction.
|
|
101
|
-
'X-Aurabase-Invoke-Mode': 'raw',
|
|
102
|
-
}
|
|
103
|
-
if (store.token) headers['Authorization'] = `Bearer ${store.token}`
|
|
104
|
-
if (client.apiKey) headers['apikey'] = client.apiKey
|
|
105
|
-
|
|
106
|
-
const res = await client.fetchFn(this.url(`${this.prefix}/${slug}/invoke`), {
|
|
107
|
-
method: 'POST',
|
|
108
|
-
headers,
|
|
109
|
-
body: JSON.stringify(envelope),
|
|
110
|
-
signal: controller.signal,
|
|
111
|
-
})
|
|
112
|
-
if (!res.ok) {
|
|
113
|
-
let parsed: { error?: { code?: string; message?: string }; message?: string } | null = null
|
|
114
|
-
try {
|
|
115
|
-
parsed = (await res.json()) as typeof parsed
|
|
116
|
-
} catch {
|
|
117
|
-
// corps non-JSON → AuraError générique sur le status
|
|
118
|
-
}
|
|
119
|
-
return { data: null, error: toFunctionsError(new AuraError(res.status, parsed)) }
|
|
120
|
-
}
|
|
121
|
-
let data: unknown
|
|
122
|
-
if (responseType === 'text') data = await res.text()
|
|
123
|
-
else if (responseType === 'blob') data = await res.blob()
|
|
124
|
-
else data = await res.arrayBuffer()
|
|
125
|
-
return { data: data as T, error: null }
|
|
126
|
-
} catch (err) {
|
|
127
|
-
// Annulation/timeout : conserve le code `timeout` (non-régression).
|
|
128
|
-
if (controller.signal.aborted || isAbortError(err)) return timeoutError()
|
|
129
|
-
// Toute autre exception (panne réseau : fonction injoignable) → relais.
|
|
130
|
-
return {
|
|
131
|
-
data: null,
|
|
132
|
-
error: new FunctionsRelayError(0, {
|
|
133
|
-
error: { code: 'network_error', message: err instanceof Error ? err.message : 'Function relay error' },
|
|
134
|
-
}),
|
|
135
|
-
}
|
|
136
|
-
} finally {
|
|
137
|
-
cleanup()
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
// -- Function CRUD ----------------------------------------------------------
|
|
142
|
-
|
|
143
|
-
async list(): Promise<AuraResponse<FunctionDef[]>> {
|
|
144
|
-
return this.request('GET', `${this.prefix}`)
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
async get(id: string): Promise<AuraResponse<FunctionDef>> {
|
|
148
|
-
return this.request('GET', `${this.prefix}/${id}`)
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
// -- Jobs -------------------------------------------------------------------
|
|
152
|
-
|
|
153
|
-
async listJobs(options?: { status?: string; limit?: number }): Promise<AuraResponse<Job[]>> {
|
|
154
|
-
const params = new URLSearchParams()
|
|
155
|
-
if (options?.status) params.set('status', options.status)
|
|
156
|
-
if (options?.limit !== undefined) params.set('limit', String(options.limit))
|
|
157
|
-
const qs = params.toString() ? `?${params.toString()}` : ''
|
|
158
|
-
return this.request('GET', `${this.prefix}/jobs${qs}`)
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
async getJob(jobId: string): Promise<AuraResponse<Job>> {
|
|
162
|
-
return this.request('GET', `${this.prefix}/jobs/${jobId}`)
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
// -- Cron -------------------------------------------------------------------
|
|
166
|
-
|
|
167
|
-
async listCronJobs(): Promise<AuraResponse<CronJob[]>> {
|
|
168
|
-
return this.request('GET', `${this.prefix}/cron`)
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
async createCronJob(
|
|
172
|
-
name: string,
|
|
173
|
-
schedule: string,
|
|
174
|
-
functionName: string,
|
|
175
|
-
options?: { payload?: unknown },
|
|
176
|
-
): Promise<AuraResponse<CronJob>> {
|
|
177
|
-
return this.request('POST', `${this.prefix}/cron`, {
|
|
178
|
-
name,
|
|
179
|
-
schedule,
|
|
180
|
-
function_name: functionName,
|
|
181
|
-
payload: options?.payload,
|
|
182
|
-
})
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
async deleteCronJob(name: string): Promise<AuraResponse<null>> {
|
|
186
|
-
return this.request('DELETE', `${this.prefix}/cron/${name}`)
|
|
187
|
-
}
|
|
188
|
-
}
|
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
import { AuraError } from '@aurabase/core'
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Statuts HTTP considérés comme des pannes de RELAIS/infra (passerelle, cold
|
|
5
|
-
* start, service indisponible) plutôt que des erreurs applicatives de la fonction.
|
|
6
|
-
* `0` = échec réseau (aucune réponse HTTP).
|
|
7
|
-
*/
|
|
8
|
-
const RELAY_STATUSES = new Set([502, 503, 504])
|
|
9
|
-
|
|
10
|
-
export function isRelayStatus(status: number): boolean {
|
|
11
|
-
return status === 0 || RELAY_STATUSES.has(status)
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* Erreur HTTP APPLICATIVE renvoyée par l'invocation d'une edge function
|
|
16
|
-
* (réponse HTTP non-2xx). Parité `FunctionsHttpError` de `@supabase/functions-js`.
|
|
17
|
-
* Sous-classe `AuraError` → `isAuraError()` reste vrai, `status` porte le code HTTP.
|
|
18
|
-
* `context` conserve le corps déjà lu (JSON/texte) pour inspection.
|
|
19
|
-
*/
|
|
20
|
-
export class FunctionsHttpError extends AuraError {
|
|
21
|
-
readonly context: unknown
|
|
22
|
-
|
|
23
|
-
constructor(
|
|
24
|
-
status: number,
|
|
25
|
-
body?: { error?: { code?: string; message?: string }; message?: string } | null,
|
|
26
|
-
context?: unknown,
|
|
27
|
-
) {
|
|
28
|
-
super(status, body)
|
|
29
|
-
this.name = 'FunctionsHttpError'
|
|
30
|
-
this.context = context
|
|
31
|
-
Object.setPrototypeOf(this, FunctionsHttpError.prototype)
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
/**
|
|
36
|
-
* Erreur de RELAIS/infra : fonction injoignable (échec réseau), 502/503/504 de la
|
|
37
|
-
* passerelle, cold start échoué, corps non exploitable. Parité `FunctionsRelayError`
|
|
38
|
-
* de `@supabase/functions-js`. Sous-classe `AuraError`.
|
|
39
|
-
*/
|
|
40
|
-
export class FunctionsRelayError extends AuraError {
|
|
41
|
-
readonly context: unknown
|
|
42
|
-
|
|
43
|
-
constructor(
|
|
44
|
-
status: number,
|
|
45
|
-
body?: { error?: { code?: string; message?: string }; message?: string } | null,
|
|
46
|
-
context?: unknown,
|
|
47
|
-
) {
|
|
48
|
-
super(status, body)
|
|
49
|
-
this.name = 'FunctionsRelayError'
|
|
50
|
-
this.context = context
|
|
51
|
-
Object.setPrototypeOf(this, FunctionsRelayError.prototype)
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
/**
|
|
56
|
-
* Convertit une `AuraError` générique (produite par le pipeline ou un `!res.ok`)
|
|
57
|
-
* en la sous-classe Functions appropriée, selon le statut HTTP :
|
|
58
|
-
* - relais (0/502/503/504) → `FunctionsRelayError` ;
|
|
59
|
-
* - toute autre erreur HTTP → `FunctionsHttpError`.
|
|
60
|
-
* Préserve le corps original (`details`) → code/message conservés.
|
|
61
|
-
*/
|
|
62
|
-
export function toFunctionsError(err: AuraError, context?: unknown): AuraError {
|
|
63
|
-
const body =
|
|
64
|
-
err.details != null
|
|
65
|
-
? (err.details as { error?: { code?: string; message?: string }; message?: string })
|
|
66
|
-
: { error: { code: err.code, message: err.message } }
|
|
67
|
-
return isRelayStatus(err.status)
|
|
68
|
-
? new FunctionsRelayError(err.status, body, context ?? err.details)
|
|
69
|
-
: new FunctionsHttpError(err.status, body, context ?? err.details)
|
|
70
|
-
}
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
export { FunctionsService } from './FunctionsService'
|
|
2
|
-
export type { FunctionsResponseType } from './FunctionsService'
|
|
3
|
-
export { FunctionsHttpError, FunctionsRelayError, isRelayStatus } from './errors'
|
|
4
|
-
|
|
5
|
-
// Types publics (utilisables en consommant `@aurabase/functions` seul).
|
|
6
|
-
export type { AuraResponse, FunctionDef, Job, CronJob } from '@aurabase/core'
|
|
@@ -1,97 +0,0 @@
|
|
|
1
|
-
import { describe, it, expect, vi, afterEach } from 'vitest'
|
|
2
|
-
import { FunctionsService } from '../src/FunctionsService'
|
|
3
|
-
import { BaseAuthStore } from '@aurabase/core'
|
|
4
|
-
import type { AuraClientLike } from '@aurabase/core'
|
|
5
|
-
|
|
6
|
-
afterEach(() => vi.useRealTimers())
|
|
7
|
-
|
|
8
|
-
function b64url(o: unknown) { return btoa(JSON.stringify(o)).replace(/\+/g, '-').replace(/\//g, '_').replace(/=+$/, '') }
|
|
9
|
-
function expiredJwt() { return `${b64url({ alg: 'HS256' })}.${b64url({ exp: Math.floor(Date.now() / 1000) - 60 })}.s` }
|
|
10
|
-
function validJwt() { return `${b64url({ alg: 'HS256' })}.${b64url({ exp: Math.floor(Date.now() / 1000) + 3600 })}.s` }
|
|
11
|
-
function fakeUser() { return { id: 'u', email: null, role: 'authenticated', email_verified: true, is_banned: false, is_anonymous: false, mfa_enabled: false, user_metadata: {}, app_metadata: {}, created_at: '2025-01-01T00:00:00Z' } }
|
|
12
|
-
|
|
13
|
-
function make(responder: (url: string, init: RequestInit) => Response | Promise<Response>, store = new BaseAuthStore()) {
|
|
14
|
-
const calls: string[] = []
|
|
15
|
-
const client: AuraClientLike = {
|
|
16
|
-
baseUrl: 'http://x', projectId: 'p', apiKey: 'k', authStore: store,
|
|
17
|
-
fetchFn: (async (url: string, init: RequestInit) => { calls.push(String(url)); return responder(String(url), init) }) as unknown as typeof globalThis.fetch,
|
|
18
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
19
|
-
auth: { refreshSession: async () => ({ data: null, error: null }) as any },
|
|
20
|
-
}
|
|
21
|
-
return { fns: new FunctionsService(client), calls }
|
|
22
|
-
}
|
|
23
|
-
const json = (o: unknown, s = 200) => new Response(JSON.stringify(o), { status: s, headers: { 'Content-Type': 'application/json' } })
|
|
24
|
-
|
|
25
|
-
describe('functions.invoke — dé-wrap enveloppe + timeout', () => {
|
|
26
|
-
it('dé-wrappe l’enveloppe ApiResponse {data, meta}', async () => {
|
|
27
|
-
const { fns } = make(() => json({ data: { status: 200, body: { ok: true } }, meta: null }))
|
|
28
|
-
const { data, error } = await fns.invoke('hello')
|
|
29
|
-
expect(error).toBeNull()
|
|
30
|
-
expect(data).toEqual({ status: 200, body: { ok: true } }) // contenu, pas l'enveloppe
|
|
31
|
-
})
|
|
32
|
-
it('réponse sans enveloppe → renvoyée telle quelle (fallback data ?? parsed)', async () => {
|
|
33
|
-
const { fns } = make(() => json({ ok: true }))
|
|
34
|
-
const { data } = await fns.invoke('hello')
|
|
35
|
-
expect(data).toEqual({ ok: true })
|
|
36
|
-
})
|
|
37
|
-
it('propage meta', async () => {
|
|
38
|
-
const { fns } = make(() => json({ data: { x: 1 }, meta: { total: 5 } }))
|
|
39
|
-
const { meta } = await fns.invoke('hello')
|
|
40
|
-
expect(meta).toEqual({ total: 5 })
|
|
41
|
-
})
|
|
42
|
-
it('signal déjà avorté à l’entrée → coupe la requête (controller interne aborté)', async () => {
|
|
43
|
-
const ac = new AbortController()
|
|
44
|
-
ac.abort()
|
|
45
|
-
// Le responder rejette UNIQUEMENT si le signal reçu est déjà aborté → prouve le pré-abort.
|
|
46
|
-
const { fns } = make((_url, init) =>
|
|
47
|
-
init.signal?.aborted
|
|
48
|
-
? Promise.reject(Object.assign(new Error('aborted'), { name: 'AbortError' }))
|
|
49
|
-
: Promise.resolve(json({ data: { ok: 1 } })),
|
|
50
|
-
)
|
|
51
|
-
const { error } = await fns.invoke('hello', { signal: ac.signal })
|
|
52
|
-
expect(error?.code).toBe('timeout') // aborté, pas résolu
|
|
53
|
-
})
|
|
54
|
-
it('!ok → erreur status', async () => {
|
|
55
|
-
const { fns } = make(() => json({ error: { code: 'boom', message: 'x' } }, 500))
|
|
56
|
-
const { error } = await fns.invoke('hello')
|
|
57
|
-
expect(error?.status).toBe(500)
|
|
58
|
-
})
|
|
59
|
-
it('timeout → error code timeout', async () => {
|
|
60
|
-
vi.useFakeTimers()
|
|
61
|
-
const { fns } = make((_url, init) => new Promise<Response>((_res, rej) => {
|
|
62
|
-
init.signal?.addEventListener('abort', () => rej(Object.assign(new Error('aborted'), { name: 'AbortError' })))
|
|
63
|
-
}))
|
|
64
|
-
const p = fns.invoke('slow', { timeout: 100 })
|
|
65
|
-
await vi.advanceTimersByTimeAsync(100)
|
|
66
|
-
const { error } = await p
|
|
67
|
-
expect(error?.code).toBe('timeout')
|
|
68
|
-
})
|
|
69
|
-
it('passe par le pipeline unifié : injecte apikey/Authorization et ne rejoue PAS un POST (503)', async () => {
|
|
70
|
-
const store = new BaseAuthStore()
|
|
71
|
-
store.save(validJwt(), 'rt', fakeUser())
|
|
72
|
-
let count = 0
|
|
73
|
-
const seen: Record<string, string> = {}
|
|
74
|
-
const { fns } = make((_url, init) => {
|
|
75
|
-
count++
|
|
76
|
-
Object.assign(seen, init.headers as Record<string, string>)
|
|
77
|
-
return json({ error: { code: 'unavailable', message: 'x' } }, 503)
|
|
78
|
-
}, store)
|
|
79
|
-
const { error } = await fns.invoke('hello')
|
|
80
|
-
expect(count).toBe(1) // POST non-idempotent → jamais rejoué même sur 503
|
|
81
|
-
expect(error?.status).toBe(503)
|
|
82
|
-
expect(seen['apikey']).toBe('k')
|
|
83
|
-
expect(seen['Authorization']).toBe(`Bearer ${store.token}`)
|
|
84
|
-
})
|
|
85
|
-
|
|
86
|
-
it('refresh proactif si token expiré', async () => {
|
|
87
|
-
const store = new BaseAuthStore()
|
|
88
|
-
store.save(expiredJwt(), 'rt', fakeUser())
|
|
89
|
-
const { fns, calls } = make((url) => {
|
|
90
|
-
if (url.includes('/v1/auth/')) return json({ access_token: validJwt(), refresh_token: 'rt2', token_type: 'bearer', expires_in: 3600, user: fakeUser() })
|
|
91
|
-
return json({ ok: 1 })
|
|
92
|
-
}, store)
|
|
93
|
-
await fns.invoke('hello')
|
|
94
|
-
expect(calls[0]).toContain('/v1/auth/p/refresh')
|
|
95
|
-
expect(calls[1]).toContain('/hello/invoke')
|
|
96
|
-
})
|
|
97
|
-
})
|
|
@@ -1,135 +0,0 @@
|
|
|
1
|
-
import { describe, it, expect } from 'vitest'
|
|
2
|
-
import { FunctionsService } from '../src/FunctionsService'
|
|
3
|
-
import { FunctionsHttpError, FunctionsRelayError } from '../src/errors'
|
|
4
|
-
import { BaseAuthStore, isAuraError } from '@aurabase/core'
|
|
5
|
-
import type { AuraClientLike } from '@aurabase/core'
|
|
6
|
-
|
|
7
|
-
function make(responder: (url: string, init: RequestInit) => Response | Promise<Response>, store = new BaseAuthStore()) {
|
|
8
|
-
const calls: Array<{ url: string; init: RequestInit }> = []
|
|
9
|
-
const client: AuraClientLike = {
|
|
10
|
-
baseUrl: 'http://x', projectId: 'p', apiKey: 'k', authStore: store,
|
|
11
|
-
fetchFn: (async (url: string, init: RequestInit) => { calls.push({ url: String(url), init }); return responder(String(url), init) }) as unknown as typeof globalThis.fetch,
|
|
12
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
13
|
-
auth: { refreshSession: async () => ({ data: null, error: null }) as any },
|
|
14
|
-
}
|
|
15
|
-
return { fns: new FunctionsService(client), calls }
|
|
16
|
-
}
|
|
17
|
-
const json = (o: unknown, s = 200) => new Response(JSON.stringify(o), { status: s, headers: { 'Content-Type': 'application/json' } })
|
|
18
|
-
|
|
19
|
-
describe('functions.invoke — responseType', () => {
|
|
20
|
-
it("défaut = json : dé-wrappe l'enveloppe (non-régression)", async () => {
|
|
21
|
-
const { fns } = make(() => json({ data: { ok: true } }))
|
|
22
|
-
const { data, error } = await fns.invoke('hello')
|
|
23
|
-
expect(error).toBeNull()
|
|
24
|
-
expect(data).toEqual({ ok: true })
|
|
25
|
-
})
|
|
26
|
-
|
|
27
|
-
it("responseType 'text' → data est la chaîne brute (pas de dé-wrapping)", async () => {
|
|
28
|
-
const { fns } = make(() => new Response('bonjour brut', { status: 200, headers: { 'Content-Type': 'text/plain' } }))
|
|
29
|
-
const { data, error } = await fns.invoke<string>('hello', { responseType: 'text' })
|
|
30
|
-
expect(error).toBeNull()
|
|
31
|
-
expect(data).toBe('bonjour brut')
|
|
32
|
-
})
|
|
33
|
-
|
|
34
|
-
it("responseType 'blob' → data est un Blob", async () => {
|
|
35
|
-
const { fns } = make(() => new Response(new Blob([new Uint8Array([1, 2, 3])]), { status: 200 }))
|
|
36
|
-
const { data, error } = await fns.invoke<Blob>('hello', { responseType: 'blob' })
|
|
37
|
-
expect(error).toBeNull()
|
|
38
|
-
expect(data).toBeInstanceOf(Blob)
|
|
39
|
-
})
|
|
40
|
-
|
|
41
|
-
it("responseType 'arrayBuffer' → data est un ArrayBuffer", async () => {
|
|
42
|
-
const { fns } = make(() => new Response(new Uint8Array([1, 2, 3]), { status: 200 }))
|
|
43
|
-
const { data, error } = await fns.invoke<ArrayBuffer>('hello', { responseType: 'arrayBuffer' })
|
|
44
|
-
expect(error).toBeNull()
|
|
45
|
-
expect(data).toBeInstanceOf(ArrayBuffer)
|
|
46
|
-
expect(new Uint8Array(data as ArrayBuffer)).toEqual(new Uint8Array([1, 2, 3]))
|
|
47
|
-
})
|
|
48
|
-
|
|
49
|
-
it("chemin brut : POST vers /invoke avec apikey + Authorization", async () => {
|
|
50
|
-
const store = new BaseAuthStore()
|
|
51
|
-
const jwt = `${btoa(JSON.stringify({ alg: 'HS256' }))}.${btoa(JSON.stringify({ exp: Math.floor(Date.now() / 1000) + 3600 }))}.s`.replace(/=+/g, '')
|
|
52
|
-
store.save(jwt, 'rt', { id: 'u', email: null, role: 'authenticated', email_verified: true, is_banned: false, is_anonymous: false, mfa_enabled: false, user_metadata: {}, app_metadata: {}, created_at: '2025-01-01T00:00:00Z' })
|
|
53
|
-
const { fns, calls } = make(() => new Response('x', { status: 200 }), store)
|
|
54
|
-
await fns.invoke('hello', { responseType: 'text' })
|
|
55
|
-
expect(calls[0]!.url).toBe('http://x/v1/functions/p/hello/invoke')
|
|
56
|
-
expect(calls[0]!.init.method).toBe('POST')
|
|
57
|
-
const h = calls[0]!.init.headers as Record<string, string>
|
|
58
|
-
expect(h['apikey']).toBe('k')
|
|
59
|
-
expect(h['Authorization']).toBe(`Bearer ${store.token}`)
|
|
60
|
-
// Négocie le mode passthrough backend (réponse brute, pas l'enveloppe).
|
|
61
|
-
expect(h['X-Aurabase-Invoke-Mode']).toBe('raw')
|
|
62
|
-
})
|
|
63
|
-
|
|
64
|
-
it("chemin json (défaut) : n'envoie PAS X-Aurabase-Invoke-Mode (enveloppe, non-régression)", async () => {
|
|
65
|
-
const { fns, calls } = make(() => json({ data: { ok: true } }))
|
|
66
|
-
await fns.invoke('hello')
|
|
67
|
-
const h = (calls[0]!.init.headers ?? {}) as Record<string, string>
|
|
68
|
-
expect(h['X-Aurabase-Invoke-Mode']).toBeUndefined()
|
|
69
|
-
})
|
|
70
|
-
})
|
|
71
|
-
|
|
72
|
-
describe('functions.invoke — erreurs typées', () => {
|
|
73
|
-
it('4xx applicatif (json) → FunctionsHttpError, status correct, isAuraError', async () => {
|
|
74
|
-
const { fns } = make(() => json({ error: { code: 'bad', message: 'nope' } }, 400))
|
|
75
|
-
const { data, error } = await fns.invoke('hello')
|
|
76
|
-
expect(data).toBeNull()
|
|
77
|
-
expect(error).toBeInstanceOf(FunctionsHttpError)
|
|
78
|
-
expect(error?.status).toBe(400)
|
|
79
|
-
expect(isAuraError(error)).toBe(true)
|
|
80
|
-
})
|
|
81
|
-
|
|
82
|
-
it('4xx applicatif (chemin brut text) → FunctionsHttpError', async () => {
|
|
83
|
-
const { fns } = make(() => new Response('nope', { status: 422, headers: { 'Content-Type': 'text/plain' } }))
|
|
84
|
-
const { error } = await fns.invoke('hello', { responseType: 'text' })
|
|
85
|
-
expect(error).toBeInstanceOf(FunctionsHttpError)
|
|
86
|
-
expect(error?.status).toBe(422)
|
|
87
|
-
})
|
|
88
|
-
|
|
89
|
-
it('503 relais → FunctionsRelayError', async () => {
|
|
90
|
-
const { fns } = make(() => json({ error: { code: 'unavailable', message: 'x' } }, 503))
|
|
91
|
-
const { error } = await fns.invoke('hello')
|
|
92
|
-
expect(error).toBeInstanceOf(FunctionsRelayError)
|
|
93
|
-
expect(error?.status).toBe(503)
|
|
94
|
-
})
|
|
95
|
-
|
|
96
|
-
it('502 relais (chemin brut) → FunctionsRelayError', async () => {
|
|
97
|
-
const { fns } = make(() => new Response('bad gateway', { status: 502 }))
|
|
98
|
-
const { error } = await fns.invoke('hello', { responseType: 'text' })
|
|
99
|
-
expect(error).toBeInstanceOf(FunctionsRelayError)
|
|
100
|
-
expect(error?.status).toBe(502)
|
|
101
|
-
})
|
|
102
|
-
|
|
103
|
-
it('panne réseau (chemin brut) → FunctionsRelayError', async () => {
|
|
104
|
-
const { fns } = make(() => Promise.reject(new TypeError('fetch failed')))
|
|
105
|
-
const { error } = await fns.invoke('hello', { responseType: 'text' })
|
|
106
|
-
expect(error).toBeInstanceOf(FunctionsRelayError)
|
|
107
|
-
expect(error?.status).toBe(0)
|
|
108
|
-
})
|
|
109
|
-
|
|
110
|
-
it('timeout → code timeout (non-régression, PAS une FunctionsError)', async () => {
|
|
111
|
-
const ac = new AbortController()
|
|
112
|
-
ac.abort()
|
|
113
|
-
const { fns } = make((_url, init) =>
|
|
114
|
-
init.signal?.aborted
|
|
115
|
-
? Promise.reject(Object.assign(new Error('aborted'), { name: 'AbortError' }))
|
|
116
|
-
: Promise.resolve(json({ data: { ok: 1 } })),
|
|
117
|
-
)
|
|
118
|
-
const { error } = await fns.invoke('hello', { signal: ac.signal })
|
|
119
|
-
expect(error?.code).toBe('timeout')
|
|
120
|
-
expect(error).not.toBeInstanceOf(FunctionsHttpError)
|
|
121
|
-
expect(error).not.toBeInstanceOf(FunctionsRelayError)
|
|
122
|
-
})
|
|
123
|
-
|
|
124
|
-
it("timeout sur chemin brut (text) → code timeout", async () => {
|
|
125
|
-
const ac = new AbortController()
|
|
126
|
-
ac.abort()
|
|
127
|
-
const { fns } = make((_url, init) =>
|
|
128
|
-
init.signal?.aborted
|
|
129
|
-
? Promise.reject(Object.assign(new Error('aborted'), { name: 'AbortError' }))
|
|
130
|
-
: Promise.resolve(new Response('x', { status: 200 })),
|
|
131
|
-
)
|
|
132
|
-
const { error } = await fns.invoke('hello', { responseType: 'text', signal: ac.signal })
|
|
133
|
-
expect(error?.code).toBe('timeout')
|
|
134
|
-
})
|
|
135
|
-
})
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
#!/bin/sh
|
|
2
|
-
basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
|
|
3
|
-
|
|
4
|
-
case `uname` in
|
|
5
|
-
*CYGWIN*|*MINGW*|*MSYS*)
|
|
6
|
-
if command -v cygpath > /dev/null 2>&1; then
|
|
7
|
-
basedir=`cygpath -w "$basedir"`
|
|
8
|
-
fi
|
|
9
|
-
;;
|
|
10
|
-
esac
|
|
11
|
-
|
|
12
|
-
if [ -z "$NODE_PATH" ]; then
|
|
13
|
-
export NODE_PATH="/Users/affanedaylami/aurabase/aurabase-js/node_modules/.pnpm/esbuild@0.27.7/node_modules/esbuild/node_modules:/Users/affanedaylami/aurabase/aurabase-js/node_modules/.pnpm/esbuild@0.27.7/node_modules:/Users/affanedaylami/aurabase/aurabase-js/node_modules/.pnpm/node_modules"
|
|
14
|
-
else
|
|
15
|
-
export NODE_PATH="/Users/affanedaylami/aurabase/aurabase-js/node_modules/.pnpm/esbuild@0.27.7/node_modules/esbuild/node_modules:/Users/affanedaylami/aurabase/aurabase-js/node_modules/.pnpm/esbuild@0.27.7/node_modules:/Users/affanedaylami/aurabase/aurabase-js/node_modules/.pnpm/node_modules:$NODE_PATH"
|
|
16
|
-
fi
|
|
17
|
-
"$basedir/../../../../node_modules/.pnpm/esbuild@0.27.7/node_modules/esbuild/bin/esbuild" "$@"
|
|
18
|
-
exit $?
|
|
19
|
-
# cmd-shim-target=/Users/affanedaylami/aurabase/aurabase-js/node_modules/.pnpm/esbuild@0.27.7/node_modules/esbuild/bin/esbuild
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
#!/bin/sh
|
|
2
|
-
basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
|
|
3
|
-
|
|
4
|
-
case `uname` in
|
|
5
|
-
*CYGWIN*|*MINGW*|*MSYS*)
|
|
6
|
-
if command -v cygpath > /dev/null 2>&1; then
|
|
7
|
-
basedir=`cygpath -w "$basedir"`
|
|
8
|
-
fi
|
|
9
|
-
;;
|
|
10
|
-
esac
|
|
11
|
-
|
|
12
|
-
if [ -z "$NODE_PATH" ]; then
|
|
13
|
-
export NODE_PATH="/Users/affanedaylami/aurabase/aurabase-js/node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/node_modules:/Users/affanedaylami/aurabase/aurabase-js/node_modules/.pnpm/typescript@5.9.3/node_modules:/Users/affanedaylami/aurabase/aurabase-js/node_modules/.pnpm/node_modules"
|
|
14
|
-
else
|
|
15
|
-
export NODE_PATH="/Users/affanedaylami/aurabase/aurabase-js/node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/node_modules:/Users/affanedaylami/aurabase/aurabase-js/node_modules/.pnpm/typescript@5.9.3/node_modules:/Users/affanedaylami/aurabase/aurabase-js/node_modules/.pnpm/node_modules:$NODE_PATH"
|
|
16
|
-
fi
|
|
17
|
-
if [ -x "$basedir/node" ]; then
|
|
18
|
-
exec "$basedir/node" "$basedir/../typescript/bin/tsc" "$@"
|
|
19
|
-
else
|
|
20
|
-
exec node "$basedir/../typescript/bin/tsc" "$@"
|
|
21
|
-
fi
|
|
22
|
-
# cmd-shim-target=/Users/affanedaylami/aurabase/aurabase-js/packages/gen/node_modules/typescript/bin/tsc
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
#!/bin/sh
|
|
2
|
-
basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
|
|
3
|
-
|
|
4
|
-
case `uname` in
|
|
5
|
-
*CYGWIN*|*MINGW*|*MSYS*)
|
|
6
|
-
if command -v cygpath > /dev/null 2>&1; then
|
|
7
|
-
basedir=`cygpath -w "$basedir"`
|
|
8
|
-
fi
|
|
9
|
-
;;
|
|
10
|
-
esac
|
|
11
|
-
|
|
12
|
-
if [ -z "$NODE_PATH" ]; then
|
|
13
|
-
export NODE_PATH="/Users/affanedaylami/aurabase/aurabase-js/node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/node_modules:/Users/affanedaylami/aurabase/aurabase-js/node_modules/.pnpm/typescript@5.9.3/node_modules:/Users/affanedaylami/aurabase/aurabase-js/node_modules/.pnpm/node_modules"
|
|
14
|
-
else
|
|
15
|
-
export NODE_PATH="/Users/affanedaylami/aurabase/aurabase-js/node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/node_modules:/Users/affanedaylami/aurabase/aurabase-js/node_modules/.pnpm/typescript@5.9.3/node_modules:/Users/affanedaylami/aurabase/aurabase-js/node_modules/.pnpm/node_modules:$NODE_PATH"
|
|
16
|
-
fi
|
|
17
|
-
if [ -x "$basedir/node" ]; then
|
|
18
|
-
exec "$basedir/node" "$basedir/../typescript/bin/tsserver" "$@"
|
|
19
|
-
else
|
|
20
|
-
exec node "$basedir/../typescript/bin/tsserver" "$@"
|
|
21
|
-
fi
|
|
22
|
-
# cmd-shim-target=/Users/affanedaylami/aurabase/aurabase-js/packages/gen/node_modules/typescript/bin/tsserver
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
#!/bin/sh
|
|
2
|
-
basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
|
|
3
|
-
|
|
4
|
-
case `uname` in
|
|
5
|
-
*CYGWIN*|*MINGW*|*MSYS*)
|
|
6
|
-
if command -v cygpath > /dev/null 2>&1; then
|
|
7
|
-
basedir=`cygpath -w "$basedir"`
|
|
8
|
-
fi
|
|
9
|
-
;;
|
|
10
|
-
esac
|
|
11
|
-
|
|
12
|
-
if [ -z "$NODE_PATH" ]; then
|
|
13
|
-
export NODE_PATH="/Users/affanedaylami/aurabase/aurabase-js/node_modules/.pnpm/tsup@8.5.1_postcss@8.5.16_typescript@5.9.3/node_modules/tsup/node_modules:/Users/affanedaylami/aurabase/aurabase-js/node_modules/.pnpm/tsup@8.5.1_postcss@8.5.16_typescript@5.9.3/node_modules:/Users/affanedaylami/aurabase/aurabase-js/node_modules/.pnpm/node_modules"
|
|
14
|
-
else
|
|
15
|
-
export NODE_PATH="/Users/affanedaylami/aurabase/aurabase-js/node_modules/.pnpm/tsup@8.5.1_postcss@8.5.16_typescript@5.9.3/node_modules/tsup/node_modules:/Users/affanedaylami/aurabase/aurabase-js/node_modules/.pnpm/tsup@8.5.1_postcss@8.5.16_typescript@5.9.3/node_modules:/Users/affanedaylami/aurabase/aurabase-js/node_modules/.pnpm/node_modules:$NODE_PATH"
|
|
16
|
-
fi
|
|
17
|
-
if [ -x "$basedir/node" ]; then
|
|
18
|
-
exec "$basedir/node" "$basedir/../tsup/dist/cli-default.js" "$@"
|
|
19
|
-
else
|
|
20
|
-
exec node "$basedir/../tsup/dist/cli-default.js" "$@"
|
|
21
|
-
fi
|
|
22
|
-
# cmd-shim-target=/Users/affanedaylami/aurabase/aurabase-js/packages/gen/node_modules/tsup/dist/cli-default.js
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
#!/bin/sh
|
|
2
|
-
basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
|
|
3
|
-
|
|
4
|
-
case `uname` in
|
|
5
|
-
*CYGWIN*|*MINGW*|*MSYS*)
|
|
6
|
-
if command -v cygpath > /dev/null 2>&1; then
|
|
7
|
-
basedir=`cygpath -w "$basedir"`
|
|
8
|
-
fi
|
|
9
|
-
;;
|
|
10
|
-
esac
|
|
11
|
-
|
|
12
|
-
if [ -z "$NODE_PATH" ]; then
|
|
13
|
-
export NODE_PATH="/Users/affanedaylami/aurabase/aurabase-js/node_modules/.pnpm/tsup@8.5.1_postcss@8.5.16_typescript@5.9.3/node_modules/tsup/node_modules:/Users/affanedaylami/aurabase/aurabase-js/node_modules/.pnpm/tsup@8.5.1_postcss@8.5.16_typescript@5.9.3/node_modules:/Users/affanedaylami/aurabase/aurabase-js/node_modules/.pnpm/node_modules"
|
|
14
|
-
else
|
|
15
|
-
export NODE_PATH="/Users/affanedaylami/aurabase/aurabase-js/node_modules/.pnpm/tsup@8.5.1_postcss@8.5.16_typescript@5.9.3/node_modules/tsup/node_modules:/Users/affanedaylami/aurabase/aurabase-js/node_modules/.pnpm/tsup@8.5.1_postcss@8.5.16_typescript@5.9.3/node_modules:/Users/affanedaylami/aurabase/aurabase-js/node_modules/.pnpm/node_modules:$NODE_PATH"
|
|
16
|
-
fi
|
|
17
|
-
if [ -x "$basedir/node" ]; then
|
|
18
|
-
exec "$basedir/node" "$basedir/../tsup/dist/cli-node.js" "$@"
|
|
19
|
-
else
|
|
20
|
-
exec node "$basedir/../tsup/dist/cli-node.js" "$@"
|
|
21
|
-
fi
|
|
22
|
-
# cmd-shim-target=/Users/affanedaylami/aurabase/aurabase-js/packages/gen/node_modules/tsup/dist/cli-node.js
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
#!/bin/sh
|
|
2
|
-
basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
|
|
3
|
-
|
|
4
|
-
case `uname` in
|
|
5
|
-
*CYGWIN*|*MINGW*|*MSYS*)
|
|
6
|
-
if command -v cygpath > /dev/null 2>&1; then
|
|
7
|
-
basedir=`cygpath -w "$basedir"`
|
|
8
|
-
fi
|
|
9
|
-
;;
|
|
10
|
-
esac
|
|
11
|
-
|
|
12
|
-
if [ -z "$NODE_PATH" ]; then
|
|
13
|
-
export NODE_PATH="/Users/affanedaylami/aurabase/aurabase-js/node_modules/.pnpm/vite@8.1.3_@types+node@20.14.15_esbuild@0.27.7/node_modules/vite/node_modules:/Users/affanedaylami/aurabase/aurabase-js/node_modules/.pnpm/vite@8.1.3_@types+node@20.14.15_esbuild@0.27.7/node_modules:/Users/affanedaylami/aurabase/aurabase-js/node_modules/.pnpm/node_modules"
|
|
14
|
-
else
|
|
15
|
-
export NODE_PATH="/Users/affanedaylami/aurabase/aurabase-js/node_modules/.pnpm/vite@8.1.3_@types+node@20.14.15_esbuild@0.27.7/node_modules/vite/node_modules:/Users/affanedaylami/aurabase/aurabase-js/node_modules/.pnpm/vite@8.1.3_@types+node@20.14.15_esbuild@0.27.7/node_modules:/Users/affanedaylami/aurabase/aurabase-js/node_modules/.pnpm/node_modules:$NODE_PATH"
|
|
16
|
-
fi
|
|
17
|
-
if [ -x "$basedir/node" ]; then
|
|
18
|
-
exec "$basedir/node" "$basedir/../../../../node_modules/.pnpm/vite@8.1.3_@types+node@20.14.15_esbuild@0.27.7/node_modules/vite/bin/vite.js" "$@"
|
|
19
|
-
else
|
|
20
|
-
exec node "$basedir/../../../../node_modules/.pnpm/vite@8.1.3_@types+node@20.14.15_esbuild@0.27.7/node_modules/vite/bin/vite.js" "$@"
|
|
21
|
-
fi
|
|
22
|
-
# cmd-shim-target=/Users/affanedaylami/aurabase/aurabase-js/node_modules/.pnpm/vite@8.1.3_@types+node@20.14.15_esbuild@0.27.7/node_modules/vite/bin/vite.js
|