spine-framework 0.3.52 → 0.3.54
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.
|
@@ -200,14 +200,39 @@ async function seedApp(appDir: string, appSlug: string) {
|
|
|
200
200
|
auth: { persistSession: false },
|
|
201
201
|
})
|
|
202
202
|
|
|
203
|
-
//
|
|
204
|
-
|
|
203
|
+
// Upsert the app row first so we always have a real app_id UUID.
|
|
204
|
+
// apps.slug is UNIQUE NOT NULL, making it the only reliable conflict target
|
|
205
|
+
// at install time (we have no UUID yet).
|
|
206
|
+
const manifestPath = join(appDir, 'manifest.json')
|
|
207
|
+
let manifest: Record<string, any> = {}
|
|
208
|
+
try { manifest = JSON.parse(readFileSync(manifestPath, 'utf8')) } catch {}
|
|
209
|
+
|
|
210
|
+
const { data: appRow, error: appErr } = await db
|
|
205
211
|
.from('apps')
|
|
212
|
+
.upsert(
|
|
213
|
+
{
|
|
214
|
+
slug: appSlug,
|
|
215
|
+
name: manifest.name ?? appSlug,
|
|
216
|
+
description: manifest.description ?? '',
|
|
217
|
+
version: manifest.version ?? '1.0.0',
|
|
218
|
+
nav_items: manifest.nav_items ?? [],
|
|
219
|
+
app_type: 'custom',
|
|
220
|
+
source: 'npm',
|
|
221
|
+
is_active: true,
|
|
222
|
+
},
|
|
223
|
+
{ onConflict: 'slug' }
|
|
224
|
+
)
|
|
206
225
|
.select('id')
|
|
207
|
-
.eq('slug', appSlug)
|
|
208
226
|
.single()
|
|
209
227
|
|
|
210
|
-
|
|
228
|
+
if (appErr || !appRow?.id) {
|
|
229
|
+
console.warn(` ⚠ Could not upsert app row for ${appSlug}: ${appErr?.message ?? 'no id returned'}`)
|
|
230
|
+
console.warn(' ○ Skipping seed — fix the apps table and retry with: npx spine-framework install-app ' + appSlug)
|
|
231
|
+
return
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
const appId = appRow.id
|
|
235
|
+
console.log(` ✓ App registered (id: ${appId})`)
|
|
211
236
|
|
|
212
237
|
// Seed types
|
|
213
238
|
const typesPath = join(appDir, 'seed/types.json')
|
|
@@ -217,7 +242,7 @@ async function seedApp(appDir: string, appSlug: string) {
|
|
|
217
242
|
for (const type of types) {
|
|
218
243
|
const { error } = await db
|
|
219
244
|
.from('types')
|
|
220
|
-
.upsert({ ...type, app_id: appId }, { onConflict: 'slug' })
|
|
245
|
+
.upsert({ ...type, app_id: appId }, { onConflict: 'app_id,kind,slug' })
|
|
221
246
|
if (error) console.warn(` ⚠ type ${type.slug}: ${error.message}`)
|
|
222
247
|
}
|
|
223
248
|
console.log(` ✓ Types seeded`)
|
|
@@ -231,7 +256,7 @@ async function seedApp(appDir: string, appSlug: string) {
|
|
|
231
256
|
for (const role of roles) {
|
|
232
257
|
const { error } = await db
|
|
233
258
|
.from('roles')
|
|
234
|
-
.upsert({ ...role, app_id: appId }, { onConflict: 'slug' })
|
|
259
|
+
.upsert({ ...role, app_id: appId }, { onConflict: 'app_id,slug' })
|
|
235
260
|
if (error) console.warn(` ⚠ role ${role.slug}: ${error.message}`)
|
|
236
261
|
}
|
|
237
262
|
console.log(` ✓ Roles seeded`)
|
|
@@ -246,7 +271,7 @@ async function seedApp(appDir: string, appSlug: string) {
|
|
|
246
271
|
for (const lt of linkTypes) {
|
|
247
272
|
const { error } = await db
|
|
248
273
|
.from('link_types')
|
|
249
|
-
.upsert({ ...lt, app_id: appId }, { onConflict: 'slug' })
|
|
274
|
+
.upsert({ ...lt, app_id: appId }, { onConflict: 'app_id,slug' })
|
|
250
275
|
if (error) console.warn(` ⚠ link_type ${lt.slug}: ${error.message}`)
|
|
251
276
|
}
|
|
252
277
|
console.log(` ✓ Link types seeded`)
|