spine-framework 0.3.134 → 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.
@@ -137,14 +137,15 @@ function isAdminRole(roleSlug: string | undefined): boolean {
137
137
  // CIL[DOC-VECTOR type="constraint" content="No test paths identified."]
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
- export const checkFirstUser = createHandler(async (_ctx, _body) => {
141
- const { count, error } = await adminDb
140
+ export const checkFirstUser = createPublicHandler(async (_ctx, _body) => {
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"]
@@ -161,7 +162,7 @@ export const checkFirstUser = createHandler(async (_ctx, _body) => {
161
162
  // CIL[DOC-VECTOR type="constraint" content="No test paths identified."]
162
163
  // CIL[DOC-VECTOR type="implementation_pattern" content="" status="pending_human_input"]
163
164
  // CIL[DOC-VECTOR type="user_journey" content="" status="pending_human_input"]
164
- export const checkDomain = createHandler(async (_ctx, _body) => {
165
+ export const checkDomain = createPublicHandler(async (_ctx, _body) => {
165
166
  const email = _ctx.query?.email as string | undefined
166
167
  if (!email || !email.includes('@')) {
167
168
  throw new Error('Valid email is required')
@@ -198,7 +199,7 @@ export const checkDomain = createHandler(async (_ctx, _body) => {
198
199
  // CIL[DOC-VECTOR type="constraint" content="No test paths identified."]
199
200
  // CIL[DOC-VECTOR type="implementation_pattern" content="" status="pending_human_input"]
200
201
  // CIL[DOC-VECTOR type="user_journey" content="" status="pending_human_input"]
201
- export const validateToken = createHandler(async (_ctx, _body) => {
202
+ export const validateToken = createPublicHandler(async (_ctx, _body) => {
202
203
  const token = _ctx.query?.token as string | undefined
203
204
  if (!token) throw new Error('Token is required')
204
205
 
@@ -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';
@@ -0,0 +1,31 @@
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
20
+ INSERT INTO public.accounts (id, slug, display_name, description, data, is_active, design_schema, validation_schema, type_id)
21
+ SELECT
22
+ gen_random_uuid(),
23
+ 'spine-system',
24
+ 'Spine System',
25
+ 'Master system account for internal Spine operations',
26
+ '{}'::jsonb,
27
+ true,
28
+ '{}'::jsonb,
29
+ '{}'::jsonb,
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.134",
3
+ "version": "0.3.136",
4
4
  "description": "Multi-tenant, modular application platform for modern SaaS systems",
5
5
  "type": "module",
6
6
  "bin": {
@@ -26,6 +26,7 @@
26
26
  ".framework/migrations/008_items_target.sql",
27
27
  ".framework/migrations/009_roles_slug_unique.sql",
28
28
  ".framework/migrations/010_auth_user_trigger.sql",
29
+ ".framework/migrations/011_spine_system_account.sql",
29
30
  ".framework/public/",
30
31
  ".framework/scripts/",
31
32
  ".framework/seeds/",