spine-framework 0.3.135 → 0.3.137

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,67 @@ 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_build_object(
421
+ 'scope', 'platform',
422
+ 'fields', jsonb_build_object(
423
+ 'display_name', jsonb_build_object('data_type', 'text', 'label', 'Account Name', 'required', true, 'system', true, 'validation', null),
424
+ 'description', jsonb_build_object('data_type', 'textarea', 'label', 'Description', 'required', false, 'system', true, 'validation', null),
425
+ 'is_active', jsonb_build_object('data_type', 'boolean', 'label', 'Active', 'required', true, 'system', true, 'validation', null),
426
+ 'created_at', jsonb_build_object('data_type', 'datetime', 'label', 'Created', 'required', false, 'system', true, 'readonly', true, 'validation', null),
427
+ 'updated_at', jsonb_build_object('data_type', 'datetime', 'label', 'Updated', 'required', false, 'system', true, 'readonly', true, 'validation', null)
428
+ ),
429
+ 'views', jsonb_build_object(
430
+ 'default_list', jsonb_build_object('type', 'list', 'display', 'table', 'label', 'Accounts',
431
+ 'fields', jsonb_build_object(
432
+ 'display_name', jsonb_build_object('sortable', true, 'display_type', 'text'),
433
+ 'is_active', jsonb_build_object('sortable', true, 'display_type', 'badge'),
434
+ 'created_at', jsonb_build_object('sortable', true, 'display_type', 'timestamp')
435
+ ),
436
+ 'default_sort', jsonb_build_object('field', 'created_at', 'direction', 'desc')
437
+ ),
438
+ 'default_detail', jsonb_build_object('type', 'detail', 'label', 'Account',
439
+ 'sections', jsonb_build_array(
440
+ jsonb_build_object('title', 'Details', 'fields', jsonb_build_array('display_name', 'description', 'is_active')),
441
+ jsonb_build_object('title', 'Metadata', 'fields', jsonb_build_array('created_at', 'updated_at'))
442
+ )
443
+ )
444
+ ),
445
+ 'record_permissions', jsonb_build_object(
446
+ 'system_admin', ARRAY['create', 'read', 'update', 'delete']
447
+ ),
448
+ 'functionality', null
449
+ ),
450
+ '{}'::jsonb,
451
+ 'pack',
452
+ true
453
+ )
454
+ ON CONFLICT (app_id, kind, slug) DO NOTHING;
455
+
456
+ -- Seed the spine-system master account, stamping the account type's design/validation schema
457
+ INSERT INTO public.accounts (id, slug, display_name, description, data, is_active, design_schema, validation_schema, type_id)
458
+ SELECT
459
+ gen_random_uuid(),
460
+ 'spine-system',
461
+ 'Spine System',
462
+ 'Master system account for internal Spine operations',
463
+ '{}'::jsonb,
464
+ true,
465
+ t.design_schema,
466
+ t.validation_schema,
467
+ t.id
468
+ FROM public.types t
469
+ WHERE t.kind = 'account' AND t.slug = 'account'
470
+ AND NOT EXISTS (SELECT 1 FROM public.accounts a WHERE a.slug = 'spine-system');
471
+
411
472
  UPDATE public.accounts
412
473
  SET type_id = (SELECT id FROM public.types WHERE slug = 'account' AND app_id = v_spine_core_app_id LIMIT 1)
413
474
  WHERE slug = 'spine-system';
@@ -1,4 +1,51 @@
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_build_object(
13
+ 'scope', 'platform',
14
+ 'fields', jsonb_build_object(
15
+ 'display_name', jsonb_build_object('data_type', 'text', 'label', 'Account Name', 'required', true, 'system', true, 'validation', null),
16
+ 'description', jsonb_build_object('data_type', 'textarea', 'label', 'Description', 'required', false, 'system', true, 'validation', null),
17
+ 'is_active', jsonb_build_object('data_type', 'boolean', 'label', 'Active', 'required', true, 'system', true, 'validation', null),
18
+ 'created_at', jsonb_build_object('data_type', 'datetime', 'label', 'Created', 'required', false, 'system', true, 'readonly', true, 'validation', null),
19
+ 'updated_at', jsonb_build_object('data_type', 'datetime', 'label', 'Updated', 'required', false, 'system', true, 'readonly', true, 'validation', null)
20
+ ),
21
+ 'views', jsonb_build_object(
22
+ 'default_list', jsonb_build_object('type', 'list', 'display', 'table', 'label', 'Accounts',
23
+ 'fields', jsonb_build_object(
24
+ 'display_name', jsonb_build_object('sortable', true, 'display_type', 'text'),
25
+ 'is_active', jsonb_build_object('sortable', true, 'display_type', 'badge'),
26
+ 'created_at', jsonb_build_object('sortable', true, 'display_type', 'timestamp')
27
+ ),
28
+ 'default_sort', jsonb_build_object('field', 'created_at', 'direction', 'desc')
29
+ ),
30
+ 'default_detail', jsonb_build_object('type', 'detail', 'label', 'Account',
31
+ 'sections', jsonb_build_array(
32
+ jsonb_build_object('title', 'Details', 'fields', jsonb_build_array('display_name', 'description', 'is_active')),
33
+ jsonb_build_object('title', 'Metadata', 'fields', jsonb_build_array('created_at', 'updated_at'))
34
+ )
35
+ )
36
+ ),
37
+ 'record_permissions', jsonb_build_object(
38
+ 'system_admin', ARRAY['create', 'read', 'update', 'delete']
39
+ ),
40
+ 'functionality', null
41
+ ),
42
+ '{}'::jsonb,
43
+ 'pack',
44
+ true
45
+ WHERE NOT EXISTS (SELECT 1 FROM public.types WHERE kind = 'account' AND slug = 'account')
46
+ ON CONFLICT (app_id, kind, slug) DO NOTHING;
47
+
48
+ -- Ensure the spine-system master account exists, stamping the account type's schema
2
49
  INSERT INTO public.accounts (id, slug, display_name, description, data, is_active, design_schema, validation_schema, type_id)
3
50
  SELECT
4
51
  gen_random_uuid(),
@@ -7,9 +54,9 @@ SELECT
7
54
  'Master system account for internal Spine operations',
8
55
  '{}'::jsonb,
9
56
  true,
10
- '{}'::jsonb,
11
- '{}'::jsonb,
12
- id
13
- FROM public.types
14
- WHERE kind = 'account' AND slug = 'account'
15
- ON CONFLICT (slug) DO NOTHING;
57
+ t.design_schema,
58
+ t.validation_schema,
59
+ t.id
60
+ FROM public.types t
61
+ WHERE t.kind = 'account' AND t.slug = 'account'
62
+ AND NOT EXISTS (SELECT 1 FROM public.accounts a WHERE a.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.137",
4
4
  "description": "Multi-tenant, modular application platform for modern SaaS systems",
5
5
  "type": "module",
6
6
  "bin": {