@myrialabs/clopen 0.4.38 → 0.4.40
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/backend/auth/permissions.ts +48 -0
- package/backend/chat/stream-manager.ts +1 -1
- package/backend/database/crypto/secret-columns.ts +9 -1
- package/backend/database/migrations/075_create_deploy_bindings.ts +54 -0
- package/backend/database/migrations/076_remove_memory_code_graph.ts +229 -0
- package/backend/database/migrations/077_create_integration_db_links.ts +150 -0
- package/backend/database/migrations/078_create_worktree_branch_tables.ts +158 -0
- package/backend/database/migrations/index.ts +28 -0
- package/backend/database/queries/db-client-connection-queries.ts +19 -0
- package/backend/database/queries/deploy-queries.ts +124 -0
- package/backend/database/queries/graph-queries.ts +291 -247
- package/backend/database/queries/index.ts +10 -0
- package/backend/database/queries/integration-db-link-queries.ts +168 -0
- package/backend/database/queries/integration-queries.ts +34 -6
- package/backend/database/queries/worktree-branch-queries.ts +331 -0
- package/backend/db-client/cloning.test.ts +161 -0
- package/backend/db-client/cloning.ts +672 -0
- package/backend/db-client/connection-url.test.ts +117 -0
- package/backend/db-client/connection-url.ts +126 -0
- package/backend/db-client/drivers/mongodb.ts +2 -14
- package/backend/db-client/drivers/mysql.ts +2 -8
- package/backend/db-client/drivers/postgres.ts +10 -13
- package/backend/db-client/drivers/redis.ts +2 -6
- package/backend/db-client/env/detect.ts +438 -0
- package/backend/db-client/env/diff.ts +94 -0
- package/backend/db-client/env/env.test.ts +574 -0
- package/backend/db-client/env/index.ts +15 -0
- package/backend/db-client/env/naming.ts +202 -0
- package/backend/db-client/env/service.ts +487 -0
- package/backend/db-client/integrations/index.ts +44 -0
- package/backend/db-client/integrations/links.ts +564 -0
- package/backend/db-client/integrations/projector.test.ts +280 -0
- package/backend/db-client/integrations/projector.ts +256 -0
- package/backend/db-client/integrations/supabase-service.ts +266 -0
- package/backend/db-client/providers/neon/adapter.ts +522 -0
- package/backend/db-client/providers/neon/api-types.ts +182 -0
- package/backend/db-client/providers/neon/client.ts +298 -0
- package/backend/db-client/providers/neon/endpoints.test.ts +201 -0
- package/backend/db-client/providers/neon/endpoints.ts +314 -0
- package/backend/db-client/providers/neon/list.test.ts +181 -0
- package/backend/db-client/providers/registry.ts +27 -0
- package/backend/db-client/providers/supabase/adapter.ts +523 -0
- package/backend/db-client/providers/supabase/api-types.ts +92 -0
- package/backend/db-client/providers/supabase/apply-migration.ts +104 -0
- package/backend/db-client/providers/supabase/client.ts +259 -0
- package/backend/db-client/providers/supabase/features.ts +502 -0
- package/backend/db-client/providers/supabase/local.test.ts +78 -0
- package/backend/db-client/providers/supabase/local.ts +137 -0
- package/backend/db-client/providers/types.ts +194 -0
- package/backend/deployments/bindings.test.ts +43 -0
- package/backend/deployments/bindings.ts +216 -0
- package/backend/deployments/index.ts +53 -0
- package/backend/deployments/log-streams.ts +214 -0
- package/backend/deployments/prompts.ts +70 -0
- package/backend/deployments/providers/vercel/adapter.ts +757 -0
- package/backend/deployments/providers/vercel/build-logs.test.ts +80 -0
- package/backend/deployments/providers/vercel/build-logs.ts +211 -0
- package/backend/deployments/providers/vercel/client.ts +203 -0
- package/backend/deployments/providers/vercel/list.test.ts +624 -0
- package/backend/deployments/providers/vercel/normalise.test.ts +115 -0
- package/backend/deployments/providers/vercel/normalise.ts +113 -0
- package/backend/deployments/providers/vercel/types.ts +104 -0
- package/backend/deployments/registry.ts +27 -0
- package/backend/deployments/service.ts +458 -0
- package/backend/deployments/types.ts +278 -0
- package/backend/env-files/discovery.ts +48 -0
- package/backend/env-files/edit.ts +213 -0
- package/backend/env-files/env-files.test.ts +515 -0
- package/backend/env-files/git.ts +27 -0
- package/backend/env-files/index.ts +44 -0
- package/backend/env-files/keys.ts +69 -0
- package/backend/env-files/parse.ts +157 -0
- package/backend/env-files/write.ts +229 -0
- package/backend/index.ts +4 -0
- package/backend/integrations/health.ts +18 -4
- package/backend/integrations/projections/index.ts +0 -0
- package/backend/integrations/projections/mcp-projector.ts +7 -3
- package/backend/integrations/projections/types.ts +28 -9
- package/backend/integrations/registry/index.ts +8 -1
- package/backend/integrations/registry/providers/context7.ts +1 -0
- package/backend/integrations/registry/providers/firecrawl.ts +1 -0
- package/backend/integrations/registry/providers/github.ts +1 -0
- package/backend/integrations/registry/providers/neon.ts +55 -0
- package/backend/integrations/registry/providers/supabase.ts +62 -0
- package/backend/integrations/registry/providers/vercel.ts +47 -0
- package/backend/integrations/registry/types.ts +2 -0
- package/backend/mcp/internal/servers/memory-graph/description.ts +3 -3
- package/backend/mcp/internal/servers/memory-graph/runner.ts +4 -9
- package/backend/mcp/internal/servers/memory-graph/schema.ts +0 -4
- package/backend/memory/README.md +57 -34
- package/backend/memory/compose.test.ts +3 -3
- package/backend/memory/compose.ts +6 -9
- package/backend/memory/config.ts +0 -5
- package/backend/memory/consolidate.ts +1 -2
- package/backend/memory/context.test.ts +8 -54
- package/backend/memory/context.ts +19 -25
- package/backend/memory/extract/episodic.ts +10 -12
- package/backend/memory/extract/index.ts +23 -52
- package/backend/memory/extract/scheduler.ts +3 -6
- package/backend/memory/index.ts +6 -5
- package/backend/memory/invalidate.ts +36 -48
- package/backend/memory/layout.ts +319 -130
- package/backend/memory/retention.ts +12 -42
- package/backend/memory/retrieval.eval.test.ts +2 -2
- package/backend/memory/retrieval.test.ts +228 -183
- package/backend/memory/retrieval.ts +22 -21
- package/backend/memory/revise.test.ts +62 -116
- package/backend/memory/revise.ts +0 -1
- package/backend/memory/view.ts +8 -5
- package/backend/snapshot/helpers.ts +35 -41
- package/backend/snapshot/snapshot-service.ts +90 -0
- package/backend/snapshot/turn-changes.test.ts +163 -0
- package/backend/snapshot/turn-changes.ts +131 -0
- package/backend/work/start-work.ts +4 -0
- package/backend/worktrees/branching/engine.ts +557 -0
- package/backend/worktrees/branching/index.ts +56 -0
- package/backend/worktrees/branching/naming.test.ts +118 -0
- package/backend/worktrees/branching/naming.ts +97 -0
- package/backend/worktrees/branching/projector.test.ts +229 -0
- package/backend/worktrees/branching/projector.ts +139 -0
- package/backend/worktrees/branching/providers/neon.ts +220 -0
- package/backend/worktrees/branching/registry.ts +27 -0
- package/backend/worktrees/branching/service.ts +620 -0
- package/backend/worktrees/branching/suggest.test.ts +154 -0
- package/backend/worktrees/branching/suggest.ts +202 -0
- package/backend/worktrees/branching/types.ts +88 -0
- package/backend/worktrees/index.ts +7 -0
- package/backend/worktrees/service.ts +48 -1
- package/backend/ws/db-client/accounts.ts +225 -0
- package/backend/ws/db-client/connections.ts +34 -3
- package/backend/ws/db-client/context.ts +37 -0
- package/backend/ws/db-client/env.ts +142 -0
- package/backend/ws/db-client/index.ts +22 -1
- package/backend/ws/db-client/supabase.ts +188 -0
- package/backend/ws/deployments/actions.ts +360 -0
- package/backend/ws/deployments/context.ts +43 -0
- package/backend/ws/deployments/crud.ts +152 -0
- package/backend/ws/deployments/index.ts +15 -0
- package/backend/ws/deployments/schemas.ts +183 -0
- package/backend/ws/index.ts +6 -2
- package/backend/ws/memory/crud.ts +4 -16
- package/backend/ws/projects/index.ts +6 -1
- package/backend/ws/projects/info.ts +70 -6
- package/backend/ws/projects/overview.test.ts +108 -0
- package/backend/ws/projects/overview.ts +300 -0
- package/backend/ws/snapshot/changes.ts +279 -0
- package/backend/ws/snapshot/index.ts +4 -3
- package/backend/ws/system/device-info.ts +307 -76
- package/backend/ws/worktrees/branching.ts +212 -0
- package/backend/ws/worktrees/crud.ts +33 -7
- package/backend/ws/worktrees/index.ts +14 -0
- package/dist/assets/{index-DSHIANSy.js → index-D4igjF6e.js} +1 -1
- package/dist/assets/{index-CyH7fSbR.js → index-DONNwiXm.js} +1 -1
- package/dist/assets/main-BrfXH1bL.js +1205 -0
- package/dist/assets/main-CT1PygsW.css +1 -0
- package/dist/index.html +2 -2
- package/package.json +1 -1
- package/shared/constants/tool-icons.ts +13 -0
- package/shared/types/db-client/connection.ts +6 -0
- package/shared/types/db-client/env.ts +192 -0
- package/shared/types/db-client/index.ts +3 -0
- package/shared/types/db-client/integrations.ts +204 -0
- package/shared/types/db-client/supabase.ts +131 -0
- package/shared/types/deployments.ts +382 -0
- package/shared/types/integrations.ts +9 -0
- package/shared/types/memory.ts +34 -51
- package/shared/types/ui/components.ts +1 -1
- package/shared/types/worktree-branching.ts +315 -0
- package/shared/utils/diff-calculator.test.ts +89 -0
- package/shared/utils/diff-calculator.ts +30 -65
- package/shared/utils/logger.ts +2 -0
- package/backend/memory/extract/languages.ts +0 -176
- package/backend/memory/extract/structural.test.ts +0 -215
- package/backend/memory/extract/structural.ts +0 -364
- package/backend/ws/snapshot/content.ts +0 -85
- package/dist/assets/main-D2IOjftb.css +0 -1
- package/dist/assets/main-DM-tHKbW.js +0 -1152
|
@@ -0,0 +1,266 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The Supabase surface, resolved against one DB Client connection.
|
|
3
|
+
*
|
|
4
|
+
* Everything here starts from the same question: given a connection the user is
|
|
5
|
+
* looking at, is this Supabase, and is there an account behind it? There are
|
|
6
|
+
* three answers, and the tabs behave differently for each:
|
|
7
|
+
*
|
|
8
|
+
* - **Linked**: the connection is a projection of a Supabase account. SQL and
|
|
9
|
+
* the Management API are both available.
|
|
10
|
+
* - **Local**: a `supabase start` stack detected from the working tree. SQL
|
|
11
|
+
* only, and the API-backed tabs say what they need instead of showing empty.
|
|
12
|
+
* - **Neither**: not a Supabase connection, and the surface does not appear.
|
|
13
|
+
*
|
|
14
|
+
* The project root matters even for a linked project, because migrations and
|
|
15
|
+
* generated types are files in the repository rather than facts about the
|
|
16
|
+
* database.
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
import { dirname, isAbsolute, join, relative } from 'path';
|
|
20
|
+
import { writeFile, mkdir } from 'fs/promises';
|
|
21
|
+
import {
|
|
22
|
+
dbClientConnectionQueries,
|
|
23
|
+
integrationAccountQueries
|
|
24
|
+
} from '$backend/database/queries';
|
|
25
|
+
import type {
|
|
26
|
+
SupabaseAuthUsersPage,
|
|
27
|
+
SupabaseBucket,
|
|
28
|
+
SupabaseConnectionContext,
|
|
29
|
+
SupabaseEdgeFunction,
|
|
30
|
+
SupabaseMigrationsReport,
|
|
31
|
+
SupabaseRlsReport,
|
|
32
|
+
SupabaseTypesResult
|
|
33
|
+
} from '$shared/types/db-client';
|
|
34
|
+
import { connectionManager } from '../connection-manager';
|
|
35
|
+
import type { DbClientDriverAdapter } from '../drivers/types';
|
|
36
|
+
import { SUPABASE_PROVIDER_ID, supabaseCredentialsOf } from '../providers/supabase/adapter';
|
|
37
|
+
import {
|
|
38
|
+
getSupabaseRateLimit,
|
|
39
|
+
primeSupabaseRateLimit,
|
|
40
|
+
type SupabaseCredentials
|
|
41
|
+
} from '../providers/supabase/client';
|
|
42
|
+
import { detectLocalSupabase, type SupabaseLocalProject } from '../providers/supabase/local';
|
|
43
|
+
import {
|
|
44
|
+
generateTypes,
|
|
45
|
+
readAuthUsers,
|
|
46
|
+
readBuckets,
|
|
47
|
+
readEdgeFunctionBody,
|
|
48
|
+
readEdgeFunctions,
|
|
49
|
+
readMigrations,
|
|
50
|
+
readMigrationSql,
|
|
51
|
+
readRls
|
|
52
|
+
} from '../providers/supabase/features';
|
|
53
|
+
import { applyMigration } from '../providers/supabase/apply-migration';
|
|
54
|
+
import { dbLinks } from './links';
|
|
55
|
+
import { debug } from '$shared/utils/logger';
|
|
56
|
+
|
|
57
|
+
/** Everything the routes need to serve one request about one connection. */
|
|
58
|
+
export interface SupabaseScope {
|
|
59
|
+
context: SupabaseConnectionContext;
|
|
60
|
+
adapter: DbClientDriverAdapter;
|
|
61
|
+
/** Null when there is no account — the API-backed tabs check this. */
|
|
62
|
+
remote: { credentials: SupabaseCredentials; ref: string } | null;
|
|
63
|
+
/** Which account owns this connection, for the surface's footer. */
|
|
64
|
+
accountLabel: string | null;
|
|
65
|
+
local: SupabaseLocalProject | null;
|
|
66
|
+
projectRoot: string | null;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* The `supabase` marker on a connection's options.
|
|
71
|
+
*
|
|
72
|
+
* Written by the projector (from the adapter's endpoint) and by the local
|
|
73
|
+
* adoption path. It is what lets db-client recognise a Supabase connection
|
|
74
|
+
* without learning what an integration account is.
|
|
75
|
+
*/
|
|
76
|
+
function optionsRef(options: Record<string, unknown>): { ref: string; local: boolean } | null {
|
|
77
|
+
const marker = options.supabase;
|
|
78
|
+
if (!marker || typeof marker !== 'object') return null;
|
|
79
|
+
const ref = (marker as { ref?: unknown }).ref;
|
|
80
|
+
if (typeof ref !== 'string' || !ref) return null;
|
|
81
|
+
return { ref, local: (marker as { local?: unknown }).local === true };
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* Resolve a connection into a Supabase scope, or null when it is not one.
|
|
86
|
+
*
|
|
87
|
+
* `projectRoot` is passed in rather than looked up: the routes already resolve
|
|
88
|
+
* and access-check a project, and a service that resolved its own would be a
|
|
89
|
+
* second, unchecked path to a user's files.
|
|
90
|
+
*/
|
|
91
|
+
export async function resolveSupabaseScope(
|
|
92
|
+
connectionId: string,
|
|
93
|
+
projectRoot: string | null
|
|
94
|
+
): Promise<SupabaseScope | null> {
|
|
95
|
+
const connection = dbClientConnectionQueries.get(connectionId);
|
|
96
|
+
if (!connection) return null;
|
|
97
|
+
|
|
98
|
+
const link = dbLinks.linkForConnection(connectionId);
|
|
99
|
+
const marker = optionsRef(connection.options ?? {});
|
|
100
|
+
const local = projectRoot ? await detectLocalSupabase(projectRoot) : null;
|
|
101
|
+
|
|
102
|
+
// A linked account wins over the marker: the marker is derived from it, and
|
|
103
|
+
// on a local connection there is no account to contradict.
|
|
104
|
+
const isSupabaseAccount = link?.account.provider === SUPABASE_PROVIDER_ID;
|
|
105
|
+
const ref = isSupabaseAccount ? link.link.remote_ref : marker?.ref ?? null;
|
|
106
|
+
if (!ref) return null;
|
|
107
|
+
|
|
108
|
+
const adapter = await connectionManager.get(connectionId);
|
|
109
|
+
|
|
110
|
+
let remote: SupabaseScope['remote'] = null;
|
|
111
|
+
if (isSupabaseAccount && link) {
|
|
112
|
+
const account = integrationAccountQueries.getById(link.account.id);
|
|
113
|
+
if (account && account.is_enabled === 1) {
|
|
114
|
+
try {
|
|
115
|
+
remote = {
|
|
116
|
+
credentials: supabaseCredentialsOf({
|
|
117
|
+
accountId: account.id,
|
|
118
|
+
credentials: integrationAccountQueries.credentialsOf(account)
|
|
119
|
+
}),
|
|
120
|
+
ref
|
|
121
|
+
};
|
|
122
|
+
} catch (error) {
|
|
123
|
+
// A credential the active key could not open. The SQL half still
|
|
124
|
+
// works, so the surface degrades rather than disappears.
|
|
125
|
+
debug.warn('db-client', `Supabase account ${account.id} has no usable token:`, error);
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
return {
|
|
131
|
+
context: {
|
|
132
|
+
ref,
|
|
133
|
+
accountId: remote ? link?.account.id ?? null : null,
|
|
134
|
+
projectName: link?.link.label ?? null,
|
|
135
|
+
// Local means "this connection points at a stack on this machine",
|
|
136
|
+
// which the marker records and a linked project never sets.
|
|
137
|
+
isLocal: marker?.local === true
|
|
138
|
+
},
|
|
139
|
+
adapter,
|
|
140
|
+
remote,
|
|
141
|
+
accountLabel: link?.account.label ?? null,
|
|
142
|
+
// Reported whenever the working tree has one, even for a LINKED remote
|
|
143
|
+
// project: the migration files live in the repository either way, and a
|
|
144
|
+
// linked project with no local checkout simply has none to compare
|
|
145
|
+
// against.
|
|
146
|
+
local,
|
|
147
|
+
projectRoot
|
|
148
|
+
};
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
function requireRemote(scope: SupabaseScope): { credentials: SupabaseCredentials; ref: string } {
|
|
152
|
+
if (!scope.remote) {
|
|
153
|
+
throw new Error(
|
|
154
|
+
'This needs a connected Supabase account — a local stack has no Management API to ask.'
|
|
155
|
+
);
|
|
156
|
+
}
|
|
157
|
+
return scope.remote;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
export const supabaseSurface = {
|
|
161
|
+
context(scope: SupabaseScope): SupabaseConnectionContext {
|
|
162
|
+
return scope.context;
|
|
163
|
+
},
|
|
164
|
+
|
|
165
|
+
/**
|
|
166
|
+
* The latest rate-limit reading for this scope's account, or null.
|
|
167
|
+
*
|
|
168
|
+
* Takes one if the account has never produced one, so the footer is correct
|
|
169
|
+
* the first time a connection is opened rather than only after some other tab
|
|
170
|
+
* happened to call the API.
|
|
171
|
+
*/
|
|
172
|
+
async rateLimit(scope: SupabaseScope) {
|
|
173
|
+
if (!scope.remote) return null;
|
|
174
|
+
await primeSupabaseRateLimit(scope.remote.credentials, scope.remote.ref);
|
|
175
|
+
return getSupabaseRateLimit(scope.remote.credentials);
|
|
176
|
+
},
|
|
177
|
+
|
|
178
|
+
migrations(scope: SupabaseScope): Promise<SupabaseMigrationsReport> {
|
|
179
|
+
return readMigrations(scope.adapter, scope.local?.migrationsDir ?? null);
|
|
180
|
+
},
|
|
181
|
+
|
|
182
|
+
migrationSql(path: string): Promise<string> {
|
|
183
|
+
return readMigrationSql(path);
|
|
184
|
+
},
|
|
185
|
+
|
|
186
|
+
/**
|
|
187
|
+
* Apply one pending migration.
|
|
188
|
+
*
|
|
189
|
+
* The path is re-derived from the report rather than taken from the client:
|
|
190
|
+
* a caller that could name any file would turn this into "run arbitrary SQL
|
|
191
|
+
* from anywhere on disk against the production database".
|
|
192
|
+
*/
|
|
193
|
+
async apply(scope: SupabaseScope, version: string): Promise<{ version: string; durationMs: number }> {
|
|
194
|
+
const report = await readMigrations(scope.adapter, scope.local?.migrationsDir ?? null);
|
|
195
|
+
const migration = report.migrations.find((entry) => entry.version === version);
|
|
196
|
+
if (!migration) throw new Error(`Migration ${version} is not in this project`);
|
|
197
|
+
if (migration.isApplied) throw new Error(`Migration ${version} is already applied`);
|
|
198
|
+
if (!migration.path) throw new Error(`Migration ${version} has no local file to apply`);
|
|
199
|
+
|
|
200
|
+
const sql = await readMigrationSql(migration.path);
|
|
201
|
+
return applyMigration({ adapter: scope.adapter, version, name: migration.name, sql });
|
|
202
|
+
},
|
|
203
|
+
|
|
204
|
+
rls(scope: SupabaseScope): Promise<SupabaseRlsReport> {
|
|
205
|
+
return readRls(scope.adapter, scope.remote);
|
|
206
|
+
},
|
|
207
|
+
|
|
208
|
+
buckets(scope: SupabaseScope): Promise<SupabaseBucket[]> {
|
|
209
|
+
return readBuckets(scope.adapter);
|
|
210
|
+
},
|
|
211
|
+
|
|
212
|
+
authUsers(
|
|
213
|
+
scope: SupabaseScope,
|
|
214
|
+
options: { search?: string; limit?: number; offset?: number }
|
|
215
|
+
): Promise<SupabaseAuthUsersPage> {
|
|
216
|
+
return readAuthUsers(scope.adapter, options);
|
|
217
|
+
},
|
|
218
|
+
|
|
219
|
+
functions(scope: SupabaseScope): Promise<SupabaseEdgeFunction[]> {
|
|
220
|
+
return readEdgeFunctions(scope.remote, scope.local?.functionsDir ?? null);
|
|
221
|
+
},
|
|
222
|
+
|
|
223
|
+
functionBody(scope: SupabaseScope, slug: string): Promise<string> {
|
|
224
|
+
return readEdgeFunctionBody(scope.remote, slug, scope.local?.functionsDir ?? null);
|
|
225
|
+
},
|
|
226
|
+
|
|
227
|
+
async types(scope: SupabaseScope, schemas: string[]): Promise<SupabaseTypesResult> {
|
|
228
|
+
const remote = requireRemote(scope);
|
|
229
|
+
return generateTypes(remote.credentials, remote.ref, schemas);
|
|
230
|
+
},
|
|
231
|
+
|
|
232
|
+
/**
|
|
233
|
+
* Write generated types into the project.
|
|
234
|
+
*
|
|
235
|
+
* The path is resolved against the project root and refused if it escapes —
|
|
236
|
+
* this is a client-supplied path that ends in a file write, so "somewhere
|
|
237
|
+
* inside this project" has to be enforced rather than assumed.
|
|
238
|
+
*/
|
|
239
|
+
async writeTypes(
|
|
240
|
+
scope: SupabaseScope,
|
|
241
|
+
relativePath: string,
|
|
242
|
+
contents: string
|
|
243
|
+
): Promise<{ path: string; bytes: number }> {
|
|
244
|
+
if (!scope.projectRoot) throw new Error('No project is open to write types into');
|
|
245
|
+
|
|
246
|
+
// Containment is checked with `relative()` rather than a string prefix:
|
|
247
|
+
// a prefix test has to know the platform's separator, and on Windows
|
|
248
|
+
// `join` returns backslashes, so `startsWith(root + '/')` refuses every
|
|
249
|
+
// legitimate path. `relative` normalises both sides first.
|
|
250
|
+
const target = join(scope.projectRoot, relativePath);
|
|
251
|
+
const inside = relative(scope.projectRoot, target);
|
|
252
|
+
if (!inside || inside.startsWith('..') || isAbsolute(inside)) {
|
|
253
|
+
throw new Error('That path is outside the project');
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
await mkdir(dirname(target), { recursive: true });
|
|
257
|
+
await writeFile(target, contents, 'utf-8');
|
|
258
|
+
debug.log('db-client', `Wrote Supabase types to ${target}`);
|
|
259
|
+
return { path: target, bytes: Buffer.byteLength(contents, 'utf-8') };
|
|
260
|
+
},
|
|
261
|
+
|
|
262
|
+
/** The local stack a project has, for the "adopt this" entry point. */
|
|
263
|
+
detectLocal(projectRoot: string) {
|
|
264
|
+
return detectLocalSupabase(projectRoot);
|
|
265
|
+
}
|
|
266
|
+
};
|