spine-framework 0.3.53 → 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
- // Get spine-core app id for foreign key
204
- const { data: coreApp } = await db
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
- const appId = coreApp?.id
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')
@@ -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`)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "spine-framework",
3
- "version": "0.3.53",
3
+ "version": "0.3.54",
4
4
  "description": "Multi-tenant, modular application platform for modern SaaS systems",
5
5
  "type": "module",
6
6
  "bin": {