spine-framework 0.3.135 → 0.3.136

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.
@@ -138,13 +138,14 @@ function isAdminRole(roleSlug: string | undefined): boolean {
138
138
  // CIL[DOC-VECTOR type="implementation_pattern" content="" status="pending_human_input"]
139
139
  // CIL[DOC-VECTOR type="user_journey" content="" status="pending_human_input"]
140
140
  export const checkFirstUser = createPublicHandler(async (_ctx, _body) => {
141
- const { count, error } = await adminDb
141
+ const { data, error } = await adminDb
142
142
  .from('people')
143
- .select('*', { count: 'exact', head: true })
143
+ .select('id')
144
+ .limit(1)
144
145
 
145
146
  if (error) throw new Error('Failed to check first user: ' + error.message)
146
147
 
147
- return { is_first_user: (count ?? 0) === 0 }
148
+ return { is_first_user: (data?.length ?? 0) === 0 }
148
149
  })
149
150
  // CIL[END chunk_id="invites_checkfirstuser_1783968140"]
150
151
  // CIL[BEGIN chunk_id="invites_checkdomain_1783968140" type="function" identity="checkDomain" parent="none"]
@@ -408,6 +408,36 @@ BEGIN
408
408
 
409
409
  ON CONFLICT (app_id, kind, slug) DO NOTHING;
410
410
 
411
+ -- Seed the runtime account type for the spine-system master account
412
+ INSERT INTO public.types (id, app_id, kind, slug, name, description, design_schema, validation_schema, ownership, is_active)
413
+ VALUES (
414
+ gen_random_uuid(),
415
+ v_spine_core_app_id,
416
+ 'account',
417
+ 'account',
418
+ 'Account',
419
+ 'Organization or tenant account',
420
+ '{}'::jsonb,
421
+ '{}'::jsonb,
422
+ 'pack',
423
+ true
424
+ )
425
+ ON CONFLICT (app_id, kind, slug) DO NOTHING;
426
+
427
+ -- Seed the spine-system master account
428
+ INSERT INTO public.accounts (id, slug, display_name, description, data, is_active, design_schema, validation_schema, type_id)
429
+ SELECT
430
+ gen_random_uuid(),
431
+ 'spine-system',
432
+ 'Spine System',
433
+ 'Master system account for internal Spine operations',
434
+ '{}'::jsonb,
435
+ true,
436
+ '{}'::jsonb,
437
+ '{}'::jsonb,
438
+ (SELECT id FROM public.types WHERE kind = 'account' AND slug = 'account' LIMIT 1)
439
+ WHERE NOT EXISTS (SELECT 1 FROM public.accounts WHERE slug = 'spine-system');
440
+
411
441
  UPDATE public.accounts
412
442
  SET type_id = (SELECT id FROM public.types WHERE slug = 'account' AND app_id = v_spine_core_app_id LIMIT 1)
413
443
  WHERE slug = 'spine-system';
@@ -1,4 +1,22 @@
1
- -- Seed the Spine system master account required by the auth trigger and existing-account registration flow
1
+ -- Seed the account type and Spine system master account required by the auth trigger and existing-account registration flow
2
+
3
+ -- Ensure the runtime account type exists
4
+ INSERT INTO public.types (id, app_id, kind, slug, name, description, design_schema, validation_schema, ownership, is_active)
5
+ SELECT
6
+ gen_random_uuid(),
7
+ (SELECT id FROM public.apps WHERE slug = 'spine-core' LIMIT 1),
8
+ 'account',
9
+ 'account',
10
+ 'Account',
11
+ 'Organization or tenant account',
12
+ '{}'::jsonb,
13
+ '{}'::jsonb,
14
+ 'pack',
15
+ true
16
+ WHERE NOT EXISTS (SELECT 1 FROM public.types WHERE kind = 'account' AND slug = 'account')
17
+ ON CONFLICT (app_id, kind, slug) DO NOTHING;
18
+
19
+ -- Ensure the spine-system master account exists
2
20
  INSERT INTO public.accounts (id, slug, display_name, description, data, is_active, design_schema, validation_schema, type_id)
3
21
  SELECT
4
22
  gen_random_uuid(),
@@ -9,7 +27,5 @@ SELECT
9
27
  true,
10
28
  '{}'::jsonb,
11
29
  '{}'::jsonb,
12
- id
13
- FROM public.types
14
- WHERE kind = 'account' AND slug = 'account'
15
- ON CONFLICT (slug) DO NOTHING;
30
+ (SELECT id FROM public.types WHERE kind = 'account' AND slug = 'account' LIMIT 1)
31
+ WHERE NOT EXISTS (SELECT 1 FROM public.accounts WHERE slug = 'spine-system');
@@ -294,6 +294,7 @@ export function RegisterPage() {
294
294
  }
295
295
 
296
296
  if (isFirstUser) {
297
+ await refreshUser()
297
298
  navigate('/spine-framework/admin', { replace: true })
298
299
  return
299
300
  }
@@ -353,6 +354,7 @@ export function RegisterPage() {
353
354
  return
354
355
  }
355
356
 
357
+ await refreshUser()
356
358
  const redirectPath = getPostRegistrationRedirect(regConfig, searchParams, false, effectiveRole)
357
359
  navigate(redirectPath, { replace: true })
358
360
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "spine-framework",
3
- "version": "0.3.135",
3
+ "version": "0.3.136",
4
4
  "description": "Multi-tenant, modular application platform for modern SaaS systems",
5
5
  "type": "module",
6
6
  "bin": {