@aurabase/aurabase-js 0.3.0 → 0.4.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 +26 -795
- package/{packages/aurabase/dist/AuraClient-DAtDbfPB.d.ts → dist/AuraClient-BcFE8u1v.d.cts} +1 -1
- package/{packages/aurabase/dist/AuraClient-DAtDbfPB.d.cts → dist/AuraClient-BcFE8u1v.d.ts} +1 -1
- package/{packages/aurabase/dist → dist}/index.d.cts +1 -1
- package/{packages/aurabase/dist → dist}/index.d.ts +1 -1
- package/{packages/aurabase/dist → dist}/ssr.d.cts +1 -1
- package/{packages/aurabase/dist → dist}/ssr.d.ts +1 -1
- package/package.json +72 -82
- package/.changeset/config.json +0 -11
- package/CHANGELOG.md +0 -30
- package/packages/ai/LICENSE +0 -21
- package/packages/ai/README.md +0 -106
- package/packages/ai/dist/index.cjs +0 -229
- package/packages/ai/dist/index.d.cts +0 -139
- package/packages/ai/dist/index.d.ts +0 -139
- package/packages/ai/dist/index.js +0 -226
- 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/package.json +0 -61
- 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/LICENSE +0 -21
- package/packages/aurabase/README.md +0 -64
- 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/package.json +0 -80
- 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/aurabase/vitest.e2e.config.ts +0 -9
- package/packages/auth/LICENSE +0 -21
- package/packages/auth/README.md +0 -215
- package/packages/auth/dist/index.cjs +0 -1175
- package/packages/auth/dist/index.d.cts +0 -397
- package/packages/auth/dist/index.d.ts +0 -397
- package/packages/auth/dist/index.js +0 -1170
- 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/package.json +0 -61
- 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/LICENSE +0 -21
- package/packages/core/README.md +0 -132
- package/packages/core/dist/index.cjs +0 -695
- package/packages/core/dist/index.d.cts +0 -1137
- package/packages/core/dist/index.d.ts +0 -1137
- package/packages/core/dist/index.js +0 -673
- 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/package.json +0 -57
- 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/LICENSE +0 -21
- package/packages/db/README.md +0 -152
- package/packages/db/VENDORED.md +0 -93
- package/packages/db/dist/index.cjs +0 -544
- package/packages/db/dist/index.d.cts +0 -1111
- package/packages/db/dist/index.d.ts +0 -1111
- package/packages/db/dist/index.js +0 -541
- 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/package.json +0 -62
- 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/LICENSE +0 -21
- package/packages/functions/README.md +0 -96
- package/packages/functions/dist/index.cjs +0 -173
- package/packages/functions/dist/index.d.cts +0 -81
- package/packages/functions/dist/index.d.ts +0 -81
- package/packages/functions/dist/index.js +0 -168
- 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/package.json +0 -60
- 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/LICENSE +0 -21
- package/packages/gen/README.md +0 -84
- package/packages/gen/dist/cli.cjs +0 -334
- package/packages/gen/dist/cli.d.cts +0 -1
- package/packages/gen/dist/cli.d.ts +0 -1
- package/packages/gen/dist/cli.js +0 -332
- package/packages/gen/dist/index.cjs +0 -257
- package/packages/gen/dist/index.d.cts +0 -12
- package/packages/gen/dist/index.d.ts +0 -12
- package/packages/gen/dist/index.js +0 -255
- 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/package.json +0 -66
- 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/LICENSE +0 -21
- package/packages/notifications/README.md +0 -134
- package/packages/notifications/dist/index.cjs +0 -128
- package/packages/notifications/dist/index.d.cts +0 -81
- package/packages/notifications/dist/index.d.ts +0 -81
- package/packages/notifications/dist/index.js +0 -125
- 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/package.json +0 -60
- 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/LICENSE +0 -21
- package/packages/realtime/README.md +0 -183
- package/packages/realtime/dist/index.cjs +0 -977
- package/packages/realtime/dist/index.d.cts +0 -259
- package/packages/realtime/dist/index.d.ts +0 -259
- package/packages/realtime/dist/index.js +0 -973
- 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/package.json +0 -60
- 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/LICENSE +0 -21
- package/packages/storage/README.md +0 -141
- package/packages/storage/dist/index.cjs +0 -333
- package/packages/storage/dist/index.d.cts +0 -185
- package/packages/storage/dist/index.d.ts +0 -185
- package/packages/storage/dist/index.js +0 -329
- 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/package.json +0 -60
- 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
- /package/{packages/aurabase/dist → dist}/index.cjs +0 -0
- /package/{packages/aurabase/dist → dist}/index.js +0 -0
- /package/{packages/aurabase/dist → dist}/ssr.cjs +0 -0
- /package/{packages/aurabase/dist → dist}/ssr.js +0 -0
|
@@ -1,541 +0,0 @@
|
|
|
1
|
-
import { BaseService, fetchWithAuth, AuraError } from '@aurabase/core';
|
|
2
|
-
|
|
3
|
-
// src/DatabaseService.ts
|
|
4
|
-
function quoteReserved(v) {
|
|
5
|
-
const s = String(v);
|
|
6
|
-
return /[,()"]/.test(s) ? `"${s.replace(/"/g, '""')}"` : s;
|
|
7
|
-
}
|
|
8
|
-
function encodeFilterValue(op, value) {
|
|
9
|
-
if (op === "in" || op === "not.in") {
|
|
10
|
-
const arr = Array.isArray(value) ? value : [value];
|
|
11
|
-
return `${op}.(${arr.map(quoteReserved).join(",")})`;
|
|
12
|
-
}
|
|
13
|
-
if (op === "cs" || op === "cd" || op === "ov") {
|
|
14
|
-
if (Array.isArray(value)) return `${op}.{${value.map(quoteReserved).join(",")}}`;
|
|
15
|
-
if (value !== null && typeof value === "object") return `${op}.${JSON.stringify(value)}`;
|
|
16
|
-
return `${op}.${value}`;
|
|
17
|
-
}
|
|
18
|
-
if (op.endsWith("(all)") || op.endsWith("(any)")) {
|
|
19
|
-
const arr = Array.isArray(value) ? value : [value];
|
|
20
|
-
return `${op}.{${arr.map(quoteReserved).join(",")}}`;
|
|
21
|
-
}
|
|
22
|
-
return `${op}.${value}`;
|
|
23
|
-
}
|
|
24
|
-
var PGRST_OBJECT_ACCEPT = "application/vnd.pgrst.object+json";
|
|
25
|
-
function mentionsZeroRows(err) {
|
|
26
|
-
if (!err) return false;
|
|
27
|
-
const details = typeof err.details === "string" ? err.details : JSON.stringify(err.details ?? "");
|
|
28
|
-
return /\b0 rows\b/.test(`${err.message ?? ""} ${details}`);
|
|
29
|
-
}
|
|
30
|
-
function pgrst116(zeroRows) {
|
|
31
|
-
return new AuraError(406, {
|
|
32
|
-
error: {
|
|
33
|
-
code: "PGRST116",
|
|
34
|
-
message: zeroRows ? "JSON object requested, 0 rows returned" : "JSON object requested, multiple rows returned"
|
|
35
|
-
}
|
|
36
|
-
});
|
|
37
|
-
}
|
|
38
|
-
var AuraPostgrestBuilder = class {
|
|
39
|
-
_client;
|
|
40
|
-
_basePath;
|
|
41
|
-
_filters = [];
|
|
42
|
-
_orGroups = [];
|
|
43
|
-
_selectColumns = null;
|
|
44
|
-
// `select()` a-t-il été appelé ? (distinct de `_selectColumns`, que `select('*')`
|
|
45
|
-
// remet à `null`) — sert à poser `Prefer: return=representation` sur une mutation
|
|
46
|
-
// même avec `select('*')`.
|
|
47
|
-
_selectInvoked = false;
|
|
48
|
-
_sortColumn = null;
|
|
49
|
-
_sortDirection = "asc";
|
|
50
|
-
_limit = null;
|
|
51
|
-
_offset = null;
|
|
52
|
-
_cursor = null;
|
|
53
|
-
_count = null;
|
|
54
|
-
_rawSelect = false;
|
|
55
|
-
_single = false;
|
|
56
|
-
_maybeSingle = false;
|
|
57
|
-
_throwOnError = false;
|
|
58
|
-
_mutation = null;
|
|
59
|
-
_rpc = null;
|
|
60
|
-
constructor(client, basePath) {
|
|
61
|
-
this._client = client;
|
|
62
|
-
this._basePath = basePath;
|
|
63
|
-
}
|
|
64
|
-
throwOnError() {
|
|
65
|
-
this._throwOnError = true;
|
|
66
|
-
return this;
|
|
67
|
-
}
|
|
68
|
-
/**
|
|
69
|
-
* Positionne l'état interne `rpc` (args + verbe HTTP) — méthode package-interne
|
|
70
|
-
* utilisée par `DatabaseService.rpc()` pour éviter un cast sur un champ `protected`.
|
|
71
|
-
*
|
|
72
|
-
* `count` accepte `'planned'` (parité stricte `RpcOptions`, cf. `DatabaseService.rpc`)
|
|
73
|
-
* en plus de `CountMode` (`@aurabase/core`, qui ne connaît que `exact`/`estimated` —
|
|
74
|
-
* package partagé, non modifié ici). Le cast vers `_count` reste sans risque runtime :
|
|
75
|
-
* `buildQueryString` sérialise la valeur telle quelle en query param `count=`.
|
|
76
|
-
*/
|
|
77
|
-
_initRpc(args, verb, count) {
|
|
78
|
-
this._rpc = { args, verb };
|
|
79
|
-
if (count) this._count = count;
|
|
80
|
-
return this;
|
|
81
|
-
}
|
|
82
|
-
// -- Query string builder ---------------------------------------------------
|
|
83
|
-
buildQueryString() {
|
|
84
|
-
const params = new URLSearchParams();
|
|
85
|
-
if (this._selectColumns && this._selectColumns.length > 0) {
|
|
86
|
-
params.set("select", this._rawSelect ? this._selectColumns[0] : this._selectColumns.join(","));
|
|
87
|
-
}
|
|
88
|
-
for (const f of this._filters) {
|
|
89
|
-
params.append(f.column, encodeFilterValue(f.op, f.value));
|
|
90
|
-
}
|
|
91
|
-
for (const group of this._orGroups) {
|
|
92
|
-
const parts = group.filters.map((f) => `${f.column}.${encodeFilterValue(f.op, f.value)}`);
|
|
93
|
-
params.append("or", `(${parts.join(",")})`);
|
|
94
|
-
}
|
|
95
|
-
if (this._sortColumn) {
|
|
96
|
-
params.set("sort_by", this._sortColumn);
|
|
97
|
-
params.set("sort_order", this._sortDirection);
|
|
98
|
-
}
|
|
99
|
-
if (this._limit !== null) params.set("limit", String(this._limit));
|
|
100
|
-
if (this._offset !== null) params.set("offset", String(this._offset));
|
|
101
|
-
if (this._cursor !== null) params.set("cursor", this._cursor);
|
|
102
|
-
if (this._count) params.set("count", this._count);
|
|
103
|
-
if (this._rpc && (this._rpc.verb === "GET" || this._rpc.verb === "HEAD") && this._rpc.args && typeof this._rpc.args === "object") {
|
|
104
|
-
for (const [k, v] of Object.entries(this._rpc.args)) {
|
|
105
|
-
params.set(k, typeof v === "string" ? v : JSON.stringify(v));
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
return params.toString();
|
|
109
|
-
}
|
|
110
|
-
// -- Execution via PromiseLike ----------------------------------------------
|
|
111
|
-
then(onfulfilled, onrejected) {
|
|
112
|
-
return this._execute().then(onfulfilled, onrejected);
|
|
113
|
-
}
|
|
114
|
-
async _execute() {
|
|
115
|
-
let res;
|
|
116
|
-
const acceptSingle = this._single ? { Accept: PGRST_OBJECT_ACCEPT } : void 0;
|
|
117
|
-
if (this._rpc) {
|
|
118
|
-
const qs = this.buildQueryString();
|
|
119
|
-
const sep = qs ? "?" : "";
|
|
120
|
-
const url = `${this._client.baseUrl}${this._basePath}${sep}${qs}`;
|
|
121
|
-
const init = this._rpc.verb === "POST" ? { method: "POST", body: this._rpc.args, headers: acceptSingle } : { method: this._rpc.verb, headers: acceptSingle };
|
|
122
|
-
res = await fetchWithAuth(url, init, this._client);
|
|
123
|
-
} else if (this._mutation) {
|
|
124
|
-
const m = this._mutation;
|
|
125
|
-
const hasEffectiveFilter = this._filters.some((f) => f.column !== "") || this._orGroups.some((g) => g.filters.length > 0);
|
|
126
|
-
if ((m.type === "update" || m.type === "delete") && m.id === null && !hasEffectiveFilter) {
|
|
127
|
-
return {
|
|
128
|
-
data: null,
|
|
129
|
-
error: new AuraError(0, {
|
|
130
|
-
error: {
|
|
131
|
-
code: "unfiltered_mutation",
|
|
132
|
-
message: "update()/delete() sans filtre refus\xE9 (protection anti-wipe) \u2014 ajoutez un filtre .eq()/... ou utilisez une mutation id-based"
|
|
133
|
-
}
|
|
134
|
-
})
|
|
135
|
-
};
|
|
136
|
-
}
|
|
137
|
-
const prefer = [];
|
|
138
|
-
if (this._selectInvoked) prefer.push("return=representation");
|
|
139
|
-
if (this._count) prefer.push(`count=${this._count}`);
|
|
140
|
-
const merged = { ...acceptSingle };
|
|
141
|
-
if (prefer.length > 0) merged.Prefer = prefer.join(", ");
|
|
142
|
-
const headers = Object.keys(merged).length > 0 ? merged : void 0;
|
|
143
|
-
const qs = this.buildQueryString();
|
|
144
|
-
const sep = qs ? "?" : "";
|
|
145
|
-
switch (m.type) {
|
|
146
|
-
case "insert": {
|
|
147
|
-
res = await fetchWithAuth(
|
|
148
|
-
`${this._client.baseUrl}${this._basePath}${sep}${qs}`,
|
|
149
|
-
{ method: "POST", body: m.body, headers },
|
|
150
|
-
this._client
|
|
151
|
-
);
|
|
152
|
-
break;
|
|
153
|
-
}
|
|
154
|
-
case "update": {
|
|
155
|
-
const path = m.id !== null ? `${this._basePath}/${m.id}` : this._basePath;
|
|
156
|
-
res = await fetchWithAuth(
|
|
157
|
-
`${this._client.baseUrl}${path}${sep}${qs}`,
|
|
158
|
-
{ method: "PATCH", body: m.body, headers },
|
|
159
|
-
this._client
|
|
160
|
-
);
|
|
161
|
-
break;
|
|
162
|
-
}
|
|
163
|
-
case "delete": {
|
|
164
|
-
const path = m.id !== null ? `${this._basePath}/${m.id}` : this._basePath;
|
|
165
|
-
res = await fetchWithAuth(
|
|
166
|
-
`${this._client.baseUrl}${path}${sep}${qs}`,
|
|
167
|
-
{ method: "DELETE", headers },
|
|
168
|
-
this._client
|
|
169
|
-
);
|
|
170
|
-
break;
|
|
171
|
-
}
|
|
172
|
-
case "upsert": {
|
|
173
|
-
const params = new URLSearchParams(qs);
|
|
174
|
-
params.set("on_conflict", m.onConflict);
|
|
175
|
-
res = await fetchWithAuth(
|
|
176
|
-
`${this._client.baseUrl}${this._basePath}?${params.toString()}`,
|
|
177
|
-
{ method: "POST", body: m.body, headers },
|
|
178
|
-
this._client
|
|
179
|
-
);
|
|
180
|
-
break;
|
|
181
|
-
}
|
|
182
|
-
}
|
|
183
|
-
} else {
|
|
184
|
-
const qs = this.buildQueryString();
|
|
185
|
-
const sep = qs ? "?" : "";
|
|
186
|
-
res = await fetchWithAuth(
|
|
187
|
-
`${this._client.baseUrl}${this._basePath}${sep}${qs}`,
|
|
188
|
-
{ method: "GET", headers: acceptSingle },
|
|
189
|
-
this._client
|
|
190
|
-
);
|
|
191
|
-
}
|
|
192
|
-
if (!this._single && (this._mutation?.type === "insert" || this._mutation?.type === "upsert") && res.data !== null && typeof res.data === "object" && !Array.isArray(res.data)) {
|
|
193
|
-
res = { ...res, data: [res.data] };
|
|
194
|
-
}
|
|
195
|
-
if (this._single) {
|
|
196
|
-
if (res.error) {
|
|
197
|
-
const zero = res.error.status === 406 ? mentionsZeroRows(res.error) : res.error.status === 404 && res.error.code === "RECORD_NOT_FOUND" ? true : null;
|
|
198
|
-
if (zero !== null) {
|
|
199
|
-
res = this._maybeSingle && zero ? { ...res, data: null, error: null } : { ...res, data: null, error: pgrst116(zero) };
|
|
200
|
-
}
|
|
201
|
-
} else if (Array.isArray(res.data)) {
|
|
202
|
-
const rows = res.data;
|
|
203
|
-
if (this._maybeSingle) {
|
|
204
|
-
res = rows.length > 1 ? { ...res, data: null, error: pgrst116(false) } : { ...res, data: rows[0] ?? null };
|
|
205
|
-
} else if (rows.length === 1) {
|
|
206
|
-
res = { ...res, data: rows[0] };
|
|
207
|
-
} else {
|
|
208
|
-
res = { ...res, data: null, error: pgrst116(rows.length === 0) };
|
|
209
|
-
}
|
|
210
|
-
}
|
|
211
|
-
}
|
|
212
|
-
if (this._throwOnError && res.error) {
|
|
213
|
-
const err = new Error(res.error.message);
|
|
214
|
-
err.code = res.error.code;
|
|
215
|
-
err.details = res.error.details;
|
|
216
|
-
throw err;
|
|
217
|
-
}
|
|
218
|
-
return res;
|
|
219
|
-
}
|
|
220
|
-
};
|
|
221
|
-
var AuraTransformBuilder = class extends AuraPostgrestBuilder {
|
|
222
|
-
// -- Column selection & resource embedding -----------------------------------
|
|
223
|
-
/**
|
|
224
|
-
* Select columns and optionally embed related resources (PostgREST parity).
|
|
225
|
-
*
|
|
226
|
-
* @example
|
|
227
|
-
* // Simple columns
|
|
228
|
-
* db.from('users').select('id, name, email')
|
|
229
|
-
*
|
|
230
|
-
* // All columns (default)
|
|
231
|
-
* db.from('users').select('*')
|
|
232
|
-
*
|
|
233
|
-
* // Embed related table (many-to-one)
|
|
234
|
-
* db.from('orders').select('*, customer:customers(name, email)')
|
|
235
|
-
*
|
|
236
|
-
* // Embed related table (one-to-many)
|
|
237
|
-
* db.from('directors').select('last_name, films(title, year)')
|
|
238
|
-
*
|
|
239
|
-
* // FK disambiguation
|
|
240
|
-
* db.from('orders').select('*, billing:addresses!billing_address_id(name)')
|
|
241
|
-
*
|
|
242
|
-
* // Nested embedding
|
|
243
|
-
* db.from('actors').select('first_name, roles(character, films(title))')
|
|
244
|
-
*/
|
|
245
|
-
select(columns) {
|
|
246
|
-
this._selectInvoked = true;
|
|
247
|
-
const cols = columns;
|
|
248
|
-
if (cols === void 0 || cols === "*") {
|
|
249
|
-
this._selectColumns = null;
|
|
250
|
-
this._rawSelect = false;
|
|
251
|
-
} else if (typeof cols === "string") {
|
|
252
|
-
if (cols.includes("(")) {
|
|
253
|
-
this._selectColumns = [cols];
|
|
254
|
-
this._rawSelect = true;
|
|
255
|
-
} else {
|
|
256
|
-
this._selectColumns = cols.split(",").map((c) => c.trim());
|
|
257
|
-
this._rawSelect = false;
|
|
258
|
-
}
|
|
259
|
-
} else {
|
|
260
|
-
this._selectColumns = cols;
|
|
261
|
-
this._rawSelect = false;
|
|
262
|
-
}
|
|
263
|
-
return this;
|
|
264
|
-
}
|
|
265
|
-
// -- Sort / pagination ------------------------------------------------------
|
|
266
|
-
order(column, direction = "asc") {
|
|
267
|
-
this._sortColumn = column;
|
|
268
|
-
this._sortDirection = direction;
|
|
269
|
-
return this;
|
|
270
|
-
}
|
|
271
|
-
limit(n) {
|
|
272
|
-
this._limit = n;
|
|
273
|
-
return this;
|
|
274
|
-
}
|
|
275
|
-
offset(n) {
|
|
276
|
-
this._offset = n;
|
|
277
|
-
return this;
|
|
278
|
-
}
|
|
279
|
-
/**
|
|
280
|
-
* Pagination keyset : passer le `next_cursor` opaque de la page précédente (préférable à
|
|
281
|
-
* `offset` sur les grandes tables : stable, sans dup/skip). Renvoyer tel quel `meta.next_cursor` ;
|
|
282
|
-
* ne pas le construire/parser (format opaque).
|
|
283
|
-
*/
|
|
284
|
-
cursor(cursor) {
|
|
285
|
-
this._cursor = cursor;
|
|
286
|
-
return this;
|
|
287
|
-
}
|
|
288
|
-
count(mode = "exact") {
|
|
289
|
-
this._count = mode;
|
|
290
|
-
return this;
|
|
291
|
-
}
|
|
292
|
-
// -- Modifiers --------------------------------------------------------------
|
|
293
|
-
single() {
|
|
294
|
-
this._single = true;
|
|
295
|
-
return this;
|
|
296
|
-
}
|
|
297
|
-
maybeSingle() {
|
|
298
|
-
this._single = true;
|
|
299
|
-
this._maybeSingle = true;
|
|
300
|
-
return this;
|
|
301
|
-
}
|
|
302
|
-
};
|
|
303
|
-
var AuraFilterBuilder = class extends AuraTransformBuilder {
|
|
304
|
-
// -- Filter methods (each returns this for chaining) ------------------------
|
|
305
|
-
//
|
|
306
|
-
// Typées sur `Row` : `column` est contraint à `keyof Row & string` (autocomplete +
|
|
307
|
-
// erreur de compilation sur colonne inconnue) et `value`/`values` à `Row[C]` (erreur
|
|
308
|
-
// sur mauvais type). Runtime inchangé — seules les signatures changent.
|
|
309
|
-
eq(column, value) {
|
|
310
|
-
this._filters.push({ column, op: "eq", value });
|
|
311
|
-
return this;
|
|
312
|
-
}
|
|
313
|
-
neq(column, value) {
|
|
314
|
-
this._filters.push({ column, op: "neq", value });
|
|
315
|
-
return this;
|
|
316
|
-
}
|
|
317
|
-
gt(column, value) {
|
|
318
|
-
this._filters.push({ column, op: "gt", value });
|
|
319
|
-
return this;
|
|
320
|
-
}
|
|
321
|
-
gte(column, value) {
|
|
322
|
-
this._filters.push({ column, op: "gte", value });
|
|
323
|
-
return this;
|
|
324
|
-
}
|
|
325
|
-
lt(column, value) {
|
|
326
|
-
this._filters.push({ column, op: "lt", value });
|
|
327
|
-
return this;
|
|
328
|
-
}
|
|
329
|
-
lte(column, value) {
|
|
330
|
-
this._filters.push({ column, op: "lte", value });
|
|
331
|
-
return this;
|
|
332
|
-
}
|
|
333
|
-
like(column, pattern) {
|
|
334
|
-
this._filters.push({ column, op: "like", value: pattern });
|
|
335
|
-
return this;
|
|
336
|
-
}
|
|
337
|
-
ilike(column, pattern) {
|
|
338
|
-
this._filters.push({ column, op: "ilike", value: pattern });
|
|
339
|
-
return this;
|
|
340
|
-
}
|
|
341
|
-
/**
|
|
342
|
-
* IS NULL or IS NOT NULL filter.
|
|
343
|
-
* PostgREST accepts: is.null, is.true, is.false (no "not_null" — use neq for that).
|
|
344
|
-
* For IS NOT NULL, use `neq(column, null)` or `is(column, 'not.null')`.
|
|
345
|
-
*/
|
|
346
|
-
is(column, value) {
|
|
347
|
-
if (value === "not.null") {
|
|
348
|
-
this._filters.push({ column, op: "not.is", value: "null" });
|
|
349
|
-
} else {
|
|
350
|
-
this._filters.push({ column, op: "is", value });
|
|
351
|
-
}
|
|
352
|
-
return this;
|
|
353
|
-
}
|
|
354
|
-
in(column, values) {
|
|
355
|
-
this._filters.push({ column, op: "in", value: values });
|
|
356
|
-
return this;
|
|
357
|
-
}
|
|
358
|
-
/**
|
|
359
|
-
* Add an OR group: `or=(col1.eq.val1,col2.gt.val2)`
|
|
360
|
-
*/
|
|
361
|
-
or(filters) {
|
|
362
|
-
this._orGroups.push({
|
|
363
|
-
filters: filters.map((f) => ({ column: f.column, op: f.op, value: f.value }))
|
|
364
|
-
});
|
|
365
|
-
return this;
|
|
366
|
-
}
|
|
367
|
-
// -- Filtres étendus (parité PostgREST) -------------------------------------
|
|
368
|
-
notIn(column, values) {
|
|
369
|
-
this._filters.push({ column, op: "not.in", value: values });
|
|
370
|
-
return this;
|
|
371
|
-
}
|
|
372
|
-
contains(column, value) {
|
|
373
|
-
this._filters.push({ column, op: "cs", value });
|
|
374
|
-
return this;
|
|
375
|
-
}
|
|
376
|
-
containedBy(column, value) {
|
|
377
|
-
this._filters.push({ column, op: "cd", value });
|
|
378
|
-
return this;
|
|
379
|
-
}
|
|
380
|
-
overlaps(column, value) {
|
|
381
|
-
this._filters.push({ column, op: "ov", value });
|
|
382
|
-
return this;
|
|
383
|
-
}
|
|
384
|
-
rangeGt(column, range) {
|
|
385
|
-
this._filters.push({ column, op: "sr", value: range });
|
|
386
|
-
return this;
|
|
387
|
-
}
|
|
388
|
-
rangeGte(column, range) {
|
|
389
|
-
this._filters.push({ column, op: "nxl", value: range });
|
|
390
|
-
return this;
|
|
391
|
-
}
|
|
392
|
-
rangeLt(column, range) {
|
|
393
|
-
this._filters.push({ column, op: "sl", value: range });
|
|
394
|
-
return this;
|
|
395
|
-
}
|
|
396
|
-
rangeLte(column, range) {
|
|
397
|
-
this._filters.push({ column, op: "nxr", value: range });
|
|
398
|
-
return this;
|
|
399
|
-
}
|
|
400
|
-
rangeAdjacent(column, range) {
|
|
401
|
-
this._filters.push({ column, op: "adj", value: range });
|
|
402
|
-
return this;
|
|
403
|
-
}
|
|
404
|
-
isDistinct(column, value) {
|
|
405
|
-
this._filters.push({ column, op: "isdistinct", value });
|
|
406
|
-
return this;
|
|
407
|
-
}
|
|
408
|
-
// Échappatoires (parité postgrest-js) : colonne `string` permissive, pas de contrainte sur `Row`.
|
|
409
|
-
not(column, op, value) {
|
|
410
|
-
this._filters.push({ column, op: `not.${op}`, value });
|
|
411
|
-
return this;
|
|
412
|
-
}
|
|
413
|
-
filter(column, op, value) {
|
|
414
|
-
this._filters.push({ column, op, value });
|
|
415
|
-
return this;
|
|
416
|
-
}
|
|
417
|
-
match(query) {
|
|
418
|
-
for (const [column, value] of Object.entries(query)) this._filters.push({ column, op: "eq", value });
|
|
419
|
-
return this;
|
|
420
|
-
}
|
|
421
|
-
textSearch(column, query, options) {
|
|
422
|
-
const t = options?.type;
|
|
423
|
-
const token = t === "plain" ? "plfts" : t === "phrase" ? "phfts" : t === "websearch" ? "wfts" : "fts";
|
|
424
|
-
const op = options?.config ? `${token}(${options.config})` : token;
|
|
425
|
-
this._filters.push({ column, op, value: query });
|
|
426
|
-
return this;
|
|
427
|
-
}
|
|
428
|
-
likeAllOf(column, patterns) {
|
|
429
|
-
this._filters.push({ column, op: "like(all)", value: patterns });
|
|
430
|
-
return this;
|
|
431
|
-
}
|
|
432
|
-
likeAnyOf(column, patterns) {
|
|
433
|
-
this._filters.push({ column, op: "like(any)", value: patterns });
|
|
434
|
-
return this;
|
|
435
|
-
}
|
|
436
|
-
ilikeAllOf(column, patterns) {
|
|
437
|
-
this._filters.push({ column, op: "ilike(all)", value: patterns });
|
|
438
|
-
return this;
|
|
439
|
-
}
|
|
440
|
-
ilikeAnyOf(column, patterns) {
|
|
441
|
-
this._filters.push({ column, op: "ilike(any)", value: patterns });
|
|
442
|
-
return this;
|
|
443
|
-
}
|
|
444
|
-
};
|
|
445
|
-
var AuraQueryBuilder = class extends AuraFilterBuilder {
|
|
446
|
-
// -- Mutations --------------------------------------------------------------
|
|
447
|
-
//
|
|
448
|
-
// Typées sur `Relation['Insert']`/`Relation['Update']` (parité postgrest-js) :
|
|
449
|
-
// un champ requis manquant côté insert/upsert, ou une colonne inconnue côté
|
|
450
|
-
// update, est une erreur de compilation. Runtime inchangé.
|
|
451
|
-
//
|
|
452
|
-
// Extraction par type conditionnel (plutôt qu'un accès indexé direct
|
|
453
|
-
// `Relation['Insert']`) : `Relation` est contraint à `GenericTable | GenericView`
|
|
454
|
-
// et `GenericNonUpdatableView` ne porte pas `Insert`/`Update`. `infer` distribue
|
|
455
|
-
// sur cette union et retombe sur `never` pour la branche non-updatable, ce qui
|
|
456
|
-
// évite l'erreur TS2536 tout en gardant le typage strict pour les tables.
|
|
457
|
-
insert(body) {
|
|
458
|
-
this._mutation = { type: "insert", body };
|
|
459
|
-
return this;
|
|
460
|
-
}
|
|
461
|
-
update(idOrBody, body) {
|
|
462
|
-
if (typeof idOrBody === "string") {
|
|
463
|
-
this._mutation = { type: "update", id: idOrBody, body };
|
|
464
|
-
} else {
|
|
465
|
-
this._mutation = { type: "update", id: null, body: idOrBody };
|
|
466
|
-
}
|
|
467
|
-
return this;
|
|
468
|
-
}
|
|
469
|
-
// COMPAT `delete(id)` → route id-based ; FILTRÉ `delete()` → route Table
|
|
470
|
-
// (exige un filtre, garde-fou anti-wipe).
|
|
471
|
-
delete(id) {
|
|
472
|
-
this._mutation = { type: "delete", id: typeof id === "string" ? id : null };
|
|
473
|
-
return this;
|
|
474
|
-
}
|
|
475
|
-
upsert(body, options) {
|
|
476
|
-
this._mutation = { type: "upsert", body, onConflict: options?.onConflict ?? "id" };
|
|
477
|
-
return this;
|
|
478
|
-
}
|
|
479
|
-
};
|
|
480
|
-
|
|
481
|
-
// src/DatabaseService.ts
|
|
482
|
-
var DatabaseService = class extends BaseService {
|
|
483
|
-
constructor(client) {
|
|
484
|
-
super(client);
|
|
485
|
-
}
|
|
486
|
-
get prefix() {
|
|
487
|
-
return `/v1/db/${this.client.projectId}`;
|
|
488
|
-
}
|
|
489
|
-
from(table) {
|
|
490
|
-
return new AuraQueryBuilder(this.client, `${this.prefix}/${table}`);
|
|
491
|
-
}
|
|
492
|
-
/**
|
|
493
|
-
* Exécute une requête SQL brute (passthrough direct vers Postgres).
|
|
494
|
-
*
|
|
495
|
-
* ⚠️ N'est PAS en lecture seule : SELECT, INSERT, UPDATE, DELETE et DDL
|
|
496
|
-
* s'exécutent réellement et persistent, dans la limite des GRANTs du rôle
|
|
497
|
-
* Postgres connecté pour ce projet (seule barrière de sécurité — il n'y a
|
|
498
|
-
* aucun filtre applicatif par type d'instruction côté serveur). Ne pas
|
|
499
|
-
* exposer cet endpoint sans restriction à des clients non fiables.
|
|
500
|
-
*/
|
|
501
|
-
async sql(query, params) {
|
|
502
|
-
return this.request("POST", `${this.prefix}/raw`, { query, params });
|
|
503
|
-
}
|
|
504
|
-
/**
|
|
505
|
-
* Appelle une fonction Postgres exposée par PostgREST (`POST|GET|HEAD /rpc/{fn}`).
|
|
506
|
-
* Signature forte quand `Schema['Functions']` connaît `fn` (typage vendoré
|
|
507
|
-
* `GetRpcFunctionFilterBuilderByArgs`, parité postgrest-js) ; sinon repli permissif.
|
|
508
|
-
*
|
|
509
|
-
* @example
|
|
510
|
-
* const { data } = await db.rpc('add', { a: 1, b: 2 })
|
|
511
|
-
* const { data } = await db.rpc('list_things', {}).eq('id', 2).select('id,name').single()
|
|
512
|
-
*/
|
|
513
|
-
rpc(fn, args, options) {
|
|
514
|
-
const verb = options?.head ? "HEAD" : options?.get ? "GET" : "POST";
|
|
515
|
-
const builder = new AuraFilterBuilder(
|
|
516
|
-
this.client,
|
|
517
|
-
`${this.prefix}/rpc/${fn}`
|
|
518
|
-
)._initRpc(args ?? {}, verb, options?.count);
|
|
519
|
-
return builder;
|
|
520
|
-
}
|
|
521
|
-
/**
|
|
522
|
-
* Fetch the schema (tables & colonnes, fonctions Postgres exposées via PostgREST,
|
|
523
|
-
* types enum et vues) pour le projet courant.
|
|
524
|
-
*/
|
|
525
|
-
async schema() {
|
|
526
|
-
const res = await this.request("GET", `${this.prefix}/schema`);
|
|
527
|
-
if (res.error) return { data: null, error: res.error, meta: res.meta };
|
|
528
|
-
return {
|
|
529
|
-
data: {
|
|
530
|
-
tables: res.data?.tables ?? [],
|
|
531
|
-
functions: res.data?.functions ?? [],
|
|
532
|
-
enums: res.data?.enums ?? [],
|
|
533
|
-
views: res.data?.views ?? []
|
|
534
|
-
},
|
|
535
|
-
error: null,
|
|
536
|
-
meta: res.meta
|
|
537
|
-
};
|
|
538
|
-
}
|
|
539
|
-
};
|
|
540
|
-
|
|
541
|
-
export { DatabaseService, AuraQueryBuilder as QueryBuilder };
|
|
@@ -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/db/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/db/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/db/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/db/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
|