spine-framework 0.2.7 → 0.2.9
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.
|
@@ -99,13 +99,10 @@ async function migrateCommand(options: MigrateOptions): Promise<void> {
|
|
|
99
99
|
// Dollar-quoted strings ($$ ... $$ or $tag$ ... $tag$) can contain semicolons
|
|
100
100
|
// that are NOT statement terminators.
|
|
101
101
|
function splitSqlStatements(sql: string): string[] {
|
|
102
|
-
// Simple approach: use regex to split, but protect dollar-quoted blocks first
|
|
103
|
-
// Replace dollar-quoted blocks with placeholders, split by semicolons, then restore
|
|
104
|
-
|
|
105
102
|
const dollarBlocks: string[] = []
|
|
106
103
|
let blockIndex = 0
|
|
107
104
|
|
|
108
|
-
//
|
|
105
|
+
// Step 1: Protect dollar-quoted blocks with placeholders (preserves internal semicolons)
|
|
109
106
|
const protectedSql = sql.replace(/\$[A-Za-z_]*\$[\s\S]*?\$[A-Za-z_]*\$/g, (match) => {
|
|
110
107
|
const placeholder = `__DOLLAR_BLOCK_${blockIndex}__`
|
|
111
108
|
dollarBlocks[blockIndex] = match
|
|
@@ -113,23 +110,23 @@ async function migrateCommand(options: MigrateOptions): Promise<void> {
|
|
|
113
110
|
return placeholder
|
|
114
111
|
})
|
|
115
112
|
|
|
116
|
-
//
|
|
117
|
-
|
|
113
|
+
// Step 2: Strip single-line comments (prevents semicolons inside -- comments
|
|
114
|
+
// from being treated as statement terminators)
|
|
115
|
+
const noComments = protectedSql.replace(/--[^\n]*/g, '')
|
|
118
116
|
|
|
119
|
-
//
|
|
120
|
-
|
|
117
|
+
// Step 3: Split by semicolons, restore dollar blocks, and filter empty statements
|
|
118
|
+
return noComments
|
|
119
|
+
.split(';')
|
|
121
120
|
.map(s => {
|
|
122
121
|
let restored = s.trim()
|
|
123
|
-
//
|
|
122
|
+
// Use function form of replace — prevents JS from interpreting $$ as $
|
|
124
123
|
dollarBlocks.forEach((block, idx) => {
|
|
125
|
-
restored = restored.replace(`__DOLLAR_BLOCK_${idx}__`, block)
|
|
124
|
+
restored = restored.replace(`__DOLLAR_BLOCK_${idx}__`, () => block)
|
|
126
125
|
})
|
|
127
126
|
return restored
|
|
128
127
|
})
|
|
129
|
-
.filter(s => s.length > 0
|
|
128
|
+
.filter(s => s.length > 0)
|
|
130
129
|
.map(s => s + ';')
|
|
131
|
-
|
|
132
|
-
return statements
|
|
133
130
|
}
|
|
134
131
|
|
|
135
132
|
const statements = splitSqlStatements(sql)
|
|
@@ -1278,3 +1278,20 @@ BEGIN
|
|
|
1278
1278
|
ORDER BY e.embedding <=> p_query_embedding LIMIT p_limit;
|
|
1279
1279
|
END;
|
|
1280
1280
|
$$;
|
|
1281
|
+
|
|
1282
|
+
-- ---------------------------------------------------------------------------
|
|
1283
|
+
-- Role Grants
|
|
1284
|
+
-- Raw SQL migrations bypass Supabase's automatic grant setup. These grants
|
|
1285
|
+
-- are required for the PostgREST API to function with anon/service_role keys.
|
|
1286
|
+
-- ---------------------------------------------------------------------------
|
|
1287
|
+
GRANT USAGE ON SCHEMA public TO anon, authenticated, service_role;
|
|
1288
|
+
GRANT ALL ON ALL TABLES IN SCHEMA public TO service_role;
|
|
1289
|
+
GRANT ALL ON ALL SEQUENCES IN SCHEMA public TO service_role;
|
|
1290
|
+
GRANT ALL ON ALL FUNCTIONS IN SCHEMA public TO service_role;
|
|
1291
|
+
GRANT SELECT, INSERT, UPDATE, DELETE ON ALL TABLES IN SCHEMA public TO authenticated;
|
|
1292
|
+
GRANT SELECT ON ALL TABLES IN SCHEMA public TO anon;
|
|
1293
|
+
ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT ALL ON TABLES TO service_role;
|
|
1294
|
+
ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT SELECT, INSERT, UPDATE, DELETE ON TABLES TO authenticated;
|
|
1295
|
+
ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT SELECT ON TABLES TO anon;
|
|
1296
|
+
ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT ALL ON SEQUENCES TO service_role, authenticated;
|
|
1297
|
+
ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT ALL ON FUNCTIONS TO service_role, authenticated;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"migrate.d.ts","sourceRoot":"","sources":["../../../.framework/cli/commands/migrate.ts"],"names":[],"mappings":"AACA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;
|
|
1
|
+
{"version":3,"file":"migrate.d.ts","sourceRoot":"","sources":["../../../.framework/cli/commands/migrate.ts"],"names":[],"mappings":"AACA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AA8IxC,wBAAgB,uBAAuB,CAAC,OAAO,EAAE,OAAO,QAevD"}
|