create-smoodly-app 0.0.25 → 0.0.27

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.
Files changed (25) hide show
  1. package/package.json +1 -1
  2. package/templates/blank/package.json +1 -1
  3. package/templates/blank/smoodly/admin.tsx +2 -2
  4. package/templates/blank/smoodly/server.ts +6 -1
  5. package/templates/blank/supabase/migrations/20260926130000_smoodly_v2.sql +26 -0
  6. package/templates/blank/supabase/migrations/20260926140000_smoodly_v3.sql +38 -0
  7. package/templates/blank/supabase/migrations/{20260926120100_smoodly_views.sql → 20260926140100_smoodly_views.sql} +1 -1
  8. package/templates/blank-intl/package.json +1 -1
  9. package/templates/blank-intl/smoodly/admin.tsx +2 -2
  10. package/templates/blank-intl/smoodly/server.ts +6 -1
  11. package/templates/blank-intl/supabase/migrations/20260926130000_smoodly_v2.sql +26 -0
  12. package/templates/blank-intl/supabase/migrations/20260926140000_smoodly_v3.sql +38 -0
  13. package/templates/blank-intl/supabase/migrations/{20260926120100_smoodly_views.sql → 20260926140100_smoodly_views.sql} +1 -1
  14. package/templates/lorem/package.json +1 -1
  15. package/templates/lorem/smoodly/admin.tsx +2 -2
  16. package/templates/lorem/smoodly/server.ts +6 -1
  17. package/templates/lorem/supabase/migrations/20260926130000_smoodly_v2.sql +26 -0
  18. package/templates/lorem/supabase/migrations/20260926140000_smoodly_v3.sql +38 -0
  19. package/templates/lorem/supabase/migrations/{20260926120100_smoodly_views.sql → 20260926140100_smoodly_views.sql} +1 -1
  20. package/templates/lorem-intl/package.json +1 -1
  21. package/templates/lorem-intl/smoodly/admin.tsx +2 -2
  22. package/templates/lorem-intl/smoodly/server.ts +6 -1
  23. package/templates/lorem-intl/supabase/migrations/20260926130000_smoodly_v2.sql +26 -0
  24. package/templates/lorem-intl/supabase/migrations/20260926140000_smoodly_v3.sql +38 -0
  25. package/templates/lorem-intl/supabase/migrations/{20260926120100_smoodly_views.sql → 20260926140100_smoodly_views.sql} +1 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-smoodly-app",
3
- "version": "0.0.25",
3
+ "version": "0.0.27",
4
4
  "description": "Create a Smoodly site: a fresh Next.js app with the admin mounted, a Supabase schema, an env file and a first editor.",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -14,7 +14,7 @@
14
14
  "next": "^16.3.4",
15
15
  "react": "^19",
16
16
  "react-dom": "^19",
17
- "smoodly": "0.0.25"
17
+ "smoodly": "0.0.27"
18
18
  },
19
19
  "devDependencies": {
20
20
  "@next/env": "^16.3.4",
@@ -1,6 +1,6 @@
1
1
  import { createSmoodlyAdmin } from "smoodly/admin/next";
2
2
  import { config } from "./config";
3
3
  import { smoodlyOp } from "./ops";
4
- import { publicAuth } from "./server";
4
+ import { publicAuth, publicContent } from "./server";
5
5
 
6
- export const { AdminPage, AdminLayout } = createSmoodlyAdmin({ config, op: smoodlyOp, auth: publicAuth });
6
+ export const { AdminPage, AdminLayout } = createSmoodlyAdmin({ config, op: smoodlyOp, auth: publicAuth, content: publicContent });
@@ -9,7 +9,7 @@
9
9
  // admin route enters it from config.ts — so nothing here may read the
10
10
  // config at module scope.
11
11
  import {
12
- createSmoodlyClient, createSmoodlySite, smoodlyEnv, SupabaseAssetStore, SupabaseEntryStore, SupabaseMemberStore, SupabasePageStore, SupabasePathIndex, type SmoodlySite,
12
+ createSmoodlyClient, createSmoodlySite, publicContentConfig, smoodlyEnv, SupabaseAssetStore, SupabaseEntryStore, SupabaseMemberStore, SupabasePageStore, SupabasePathIndex, type ContentConfig, type SmoodlySite,
13
13
  } from "smoodly";
14
14
  import { supabaseAdminAuth, type AdminAuth, type AuthConfig } from "smoodly/admin/next";
15
15
  import { createPageRenderer, createSmoodlyQueries, type PageRegistration } from "smoodly/next";
@@ -81,6 +81,11 @@ export function publicAuth(): AuthConfig {
81
81
  return { url: env.authUrl, key: env.authKey };
82
82
  }
83
83
 
84
+ /** What the browser needs to join the editing-presence channel — public values only (spec 2026-09-26 concurrency §5). */
85
+ export function publicContent(): ContentConfig {
86
+ return publicContentConfig(smoodlyEnv());
87
+ }
88
+
84
89
  /** Locale-relative CMS path → site URL: the one seam for the renderer
85
90
  * (metadata alternates, the `page` prop's links) and the admin (canvas,
86
91
  * View live). The identity for a single-language site; with next-intl it
@@ -0,0 +1,26 @@
1
+ -- Smoodly core schema, version 2 (docs/superpowers/specs/2026-09-26-concurrency-guard-presence-design.md).
2
+ -- Shipped in the smoodly package; `npx smoodly migrate` copies it into supabase/migrations/.
3
+ -- Never edit a published file: the next change is the next file.
4
+ -- The delta over version 1: the draft pointers become foreign keys (the
5
+ -- token rides every locale row read) and the editing-presence channel
6
+ -- gets its policy on realtime.messages.
7
+
8
+ set client_min_messages = warning;
9
+
10
+ alter table "page_locales" drop constraint if exists "page_locales_draft_version_fkey";
11
+ alter table "page_locales" add constraint "page_locales_draft_version_fkey"
12
+ foreign key ("draft_version_id") references "page_versions" ("id") on delete set null;
13
+ alter table "entry_locales" drop constraint if exists "entry_locales_draft_version_fkey";
14
+ alter table "entry_locales" add constraint "entry_locales_draft_version_fkey"
15
+ foreign key ("draft_version_id") references "entry_versions" ("id") on delete set null;
16
+
17
+ drop policy if exists "smoodly_presence_read" on "realtime"."messages";
18
+ create policy "smoodly_presence_read" on "realtime"."messages" for select
19
+ using ((select realtime.topic()) = 'space:' || (select public."smoodly_current_space"())::text);
20
+
21
+ drop policy if exists "smoodly_presence_write" on "realtime"."messages";
22
+ create policy "smoodly_presence_write" on "realtime"."messages" for insert
23
+ with check ((select realtime.topic()) = 'space:' || (select public."smoodly_current_space"())::text);
24
+
25
+ insert into "smoodly_meta" ("key", "value") values ('schema_version', '2')
26
+ on conflict ("key") do update set "value" = excluded."value";
@@ -0,0 +1,38 @@
1
+ -- Smoodly core schema, version 3 (docs/superpowers/specs/2026-09-26-security-pass-design.md).
2
+ -- Shipped in the smoodly package; `npx smoodly migrate` copies it into supabase/migrations/.
3
+ -- Never edit a published file: the next change is the next file.
4
+ -- The delta over version 2: the presence channel admits a signed-in
5
+ -- member of the topic's space (a definer lookup in members by the session
6
+ -- token's user), the five unpinned functions get a search_path, and the
7
+ -- three mutation RPCs are no longer executable by anon or public.
8
+
9
+ set client_min_messages = warning;
10
+
11
+ create or replace function "smoodly_presence_member"() returns boolean
12
+ language sql stable security definer set search_path = public as $$
13
+ select exists (select 1 from "members" m
14
+ where m."user_id" = auth.uid()
15
+ and realtime.topic() = 'space:' || m."space_id"::text);
16
+ $$;
17
+
18
+ drop policy if exists "smoodly_presence_read" on "realtime"."messages";
19
+ create policy "smoodly_presence_read" on "realtime"."messages" for select
20
+ using ((select public."smoodly_presence_member"()));
21
+
22
+ drop policy if exists "smoodly_presence_write" on "realtime"."messages";
23
+ create policy "smoodly_presence_write" on "realtime"."messages" for insert
24
+ with check ((select public."smoodly_presence_member"()));
25
+
26
+ alter function "smoodly_current_space"() set search_path = '';
27
+ alter function "smoodly_key_kind"() set search_path = '';
28
+ alter function "smoodly_set_space"() set search_path = '';
29
+ alter function "smoodly_reorder"(text, uuid[]) set search_path = public;
30
+ alter function "smoodly_reorder_pages"(uuid[]) set search_path = public;
31
+ alter function "smoodly_rewrite_paths"(jsonb, jsonb) set search_path = public;
32
+
33
+ revoke execute on function "smoodly_reorder"(text, uuid[]) from public, anon;
34
+ revoke execute on function "smoodly_reorder_pages"(uuid[]) from public, anon;
35
+ revoke execute on function "smoodly_rewrite_paths"(jsonb, jsonb) from public, anon;
36
+
37
+ insert into "smoodly_meta" ("key", "value") values ('schema_version', '3')
38
+ on conflict ("key") do update set "value" = excluded."value";
@@ -1,5 +1,5 @@
1
1
  -- Smoodly: read views and order indexes for this app's collections, written by `npx smoodly migrate`
2
- -- (2026-09-26T12:01:00.000Z). One block per collection; the marker's hash is the block's SQL, compared on the next run.
2
+ -- (2026-09-26T14:01:00.000Z). One block per collection; the marker's hash is the block's SQL, compared on the next run.
3
3
  -- Never edit a written file: change the collection and run migrate again.
4
4
 
5
5
  -- smoodly:collection posts sha256:2e648b887b8e7146
@@ -14,7 +14,7 @@
14
14
  "next": "^16.3.4",
15
15
  "react": "^19",
16
16
  "react-dom": "^19",
17
- "smoodly": "0.0.25",
17
+ "smoodly": "0.0.27",
18
18
  "next-intl": "^4.14.2"
19
19
  },
20
20
  "devDependencies": {
@@ -1,6 +1,6 @@
1
1
  import { createSmoodlyAdmin } from "smoodly/admin/next";
2
2
  import { config } from "./config";
3
3
  import { smoodlyOp } from "./ops";
4
- import { publicAuth } from "./server";
4
+ import { publicAuth, publicContent } from "./server";
5
5
 
6
- export const { AdminPage, AdminLayout } = createSmoodlyAdmin({ config, op: smoodlyOp, auth: publicAuth });
6
+ export const { AdminPage, AdminLayout } = createSmoodlyAdmin({ config, op: smoodlyOp, auth: publicAuth, content: publicContent });
@@ -9,7 +9,7 @@
9
9
  // admin route enters it from config.ts — so nothing here may read the
10
10
  // config at module scope.
11
11
  import {
12
- createSmoodlyClient, createSmoodlySite, smoodlyEnv, SupabaseAssetStore, SupabaseEntryStore, SupabaseMemberStore, SupabasePageStore, SupabasePathIndex, type SmoodlySite,
12
+ createSmoodlyClient, createSmoodlySite, publicContentConfig, smoodlyEnv, SupabaseAssetStore, SupabaseEntryStore, SupabaseMemberStore, SupabasePageStore, SupabasePathIndex, type ContentConfig, type SmoodlySite,
13
13
  } from "smoodly";
14
14
  import { supabaseAdminAuth, type AdminAuth, type AuthConfig } from "smoodly/admin/next";
15
15
  import { createPageRenderer, createSmoodlyQueries, type PageRegistration } from "smoodly/next";
@@ -82,6 +82,11 @@ export function publicAuth(): AuthConfig {
82
82
  return { url: env.authUrl, key: env.authKey };
83
83
  }
84
84
 
85
+ /** What the browser needs to join the editing-presence channel — public values only (spec 2026-09-26 concurrency §5). */
86
+ export function publicContent(): ContentConfig {
87
+ return publicContentConfig(smoodlyEnv());
88
+ }
89
+
85
90
  /** Locale-relative CMS path → site URL: the one seam for the renderer
86
91
  * (metadata alternates, the `page` prop's links) and the admin (canvas,
87
92
  * View live). The identity for a single-language site; with next-intl it
@@ -0,0 +1,26 @@
1
+ -- Smoodly core schema, version 2 (docs/superpowers/specs/2026-09-26-concurrency-guard-presence-design.md).
2
+ -- Shipped in the smoodly package; `npx smoodly migrate` copies it into supabase/migrations/.
3
+ -- Never edit a published file: the next change is the next file.
4
+ -- The delta over version 1: the draft pointers become foreign keys (the
5
+ -- token rides every locale row read) and the editing-presence channel
6
+ -- gets its policy on realtime.messages.
7
+
8
+ set client_min_messages = warning;
9
+
10
+ alter table "page_locales" drop constraint if exists "page_locales_draft_version_fkey";
11
+ alter table "page_locales" add constraint "page_locales_draft_version_fkey"
12
+ foreign key ("draft_version_id") references "page_versions" ("id") on delete set null;
13
+ alter table "entry_locales" drop constraint if exists "entry_locales_draft_version_fkey";
14
+ alter table "entry_locales" add constraint "entry_locales_draft_version_fkey"
15
+ foreign key ("draft_version_id") references "entry_versions" ("id") on delete set null;
16
+
17
+ drop policy if exists "smoodly_presence_read" on "realtime"."messages";
18
+ create policy "smoodly_presence_read" on "realtime"."messages" for select
19
+ using ((select realtime.topic()) = 'space:' || (select public."smoodly_current_space"())::text);
20
+
21
+ drop policy if exists "smoodly_presence_write" on "realtime"."messages";
22
+ create policy "smoodly_presence_write" on "realtime"."messages" for insert
23
+ with check ((select realtime.topic()) = 'space:' || (select public."smoodly_current_space"())::text);
24
+
25
+ insert into "smoodly_meta" ("key", "value") values ('schema_version', '2')
26
+ on conflict ("key") do update set "value" = excluded."value";
@@ -0,0 +1,38 @@
1
+ -- Smoodly core schema, version 3 (docs/superpowers/specs/2026-09-26-security-pass-design.md).
2
+ -- Shipped in the smoodly package; `npx smoodly migrate` copies it into supabase/migrations/.
3
+ -- Never edit a published file: the next change is the next file.
4
+ -- The delta over version 2: the presence channel admits a signed-in
5
+ -- member of the topic's space (a definer lookup in members by the session
6
+ -- token's user), the five unpinned functions get a search_path, and the
7
+ -- three mutation RPCs are no longer executable by anon or public.
8
+
9
+ set client_min_messages = warning;
10
+
11
+ create or replace function "smoodly_presence_member"() returns boolean
12
+ language sql stable security definer set search_path = public as $$
13
+ select exists (select 1 from "members" m
14
+ where m."user_id" = auth.uid()
15
+ and realtime.topic() = 'space:' || m."space_id"::text);
16
+ $$;
17
+
18
+ drop policy if exists "smoodly_presence_read" on "realtime"."messages";
19
+ create policy "smoodly_presence_read" on "realtime"."messages" for select
20
+ using ((select public."smoodly_presence_member"()));
21
+
22
+ drop policy if exists "smoodly_presence_write" on "realtime"."messages";
23
+ create policy "smoodly_presence_write" on "realtime"."messages" for insert
24
+ with check ((select public."smoodly_presence_member"()));
25
+
26
+ alter function "smoodly_current_space"() set search_path = '';
27
+ alter function "smoodly_key_kind"() set search_path = '';
28
+ alter function "smoodly_set_space"() set search_path = '';
29
+ alter function "smoodly_reorder"(text, uuid[]) set search_path = public;
30
+ alter function "smoodly_reorder_pages"(uuid[]) set search_path = public;
31
+ alter function "smoodly_rewrite_paths"(jsonb, jsonb) set search_path = public;
32
+
33
+ revoke execute on function "smoodly_reorder"(text, uuid[]) from public, anon;
34
+ revoke execute on function "smoodly_reorder_pages"(uuid[]) from public, anon;
35
+ revoke execute on function "smoodly_rewrite_paths"(jsonb, jsonb) from public, anon;
36
+
37
+ insert into "smoodly_meta" ("key", "value") values ('schema_version', '3')
38
+ on conflict ("key") do update set "value" = excluded."value";
@@ -1,5 +1,5 @@
1
1
  -- Smoodly: read views and order indexes for this app's collections, written by `npx smoodly migrate`
2
- -- (2026-09-26T12:01:00.000Z). One block per collection; the marker's hash is the block's SQL, compared on the next run.
2
+ -- (2026-09-26T14:01:00.000Z). One block per collection; the marker's hash is the block's SQL, compared on the next run.
3
3
  -- Never edit a written file: change the collection and run migrate again.
4
4
 
5
5
  -- smoodly:collection posts sha256:2e648b887b8e7146
@@ -14,7 +14,7 @@
14
14
  "next": "^16.3.4",
15
15
  "react": "^19",
16
16
  "react-dom": "^19",
17
- "smoodly": "0.0.25"
17
+ "smoodly": "0.0.27"
18
18
  },
19
19
  "devDependencies": {
20
20
  "@next/env": "^16.3.4",
@@ -1,6 +1,6 @@
1
1
  import { createSmoodlyAdmin } from "smoodly/admin/next";
2
2
  import { config } from "./config";
3
3
  import { smoodlyOp } from "./ops";
4
- import { publicAuth } from "./server";
4
+ import { publicAuth, publicContent } from "./server";
5
5
 
6
- export const { AdminPage, AdminLayout } = createSmoodlyAdmin({ config, op: smoodlyOp, auth: publicAuth });
6
+ export const { AdminPage, AdminLayout } = createSmoodlyAdmin({ config, op: smoodlyOp, auth: publicAuth, content: publicContent });
@@ -9,7 +9,7 @@
9
9
  // admin route enters it from config.ts — so nothing here may read the
10
10
  // config at module scope.
11
11
  import {
12
- createSmoodlyClient, createSmoodlySite, smoodlyEnv, SupabaseAssetStore, SupabaseEntryStore, SupabaseMemberStore, SupabasePageStore, SupabasePathIndex, type SmoodlySite,
12
+ createSmoodlyClient, createSmoodlySite, publicContentConfig, smoodlyEnv, SupabaseAssetStore, SupabaseEntryStore, SupabaseMemberStore, SupabasePageStore, SupabasePathIndex, type ContentConfig, type SmoodlySite,
13
13
  } from "smoodly";
14
14
  import { supabaseAdminAuth, type AdminAuth, type AuthConfig } from "smoodly/admin/next";
15
15
  import { createPageRenderer, createSmoodlyQueries, type PageRegistration } from "smoodly/next";
@@ -81,6 +81,11 @@ export function publicAuth(): AuthConfig {
81
81
  return { url: env.authUrl, key: env.authKey };
82
82
  }
83
83
 
84
+ /** What the browser needs to join the editing-presence channel — public values only (spec 2026-09-26 concurrency §5). */
85
+ export function publicContent(): ContentConfig {
86
+ return publicContentConfig(smoodlyEnv());
87
+ }
88
+
84
89
  /** Locale-relative CMS path → site URL: the one seam for the renderer
85
90
  * (metadata alternates, the `page` prop's links) and the admin (canvas,
86
91
  * View live). The identity for a single-language site; with next-intl it
@@ -0,0 +1,26 @@
1
+ -- Smoodly core schema, version 2 (docs/superpowers/specs/2026-09-26-concurrency-guard-presence-design.md).
2
+ -- Shipped in the smoodly package; `npx smoodly migrate` copies it into supabase/migrations/.
3
+ -- Never edit a published file: the next change is the next file.
4
+ -- The delta over version 1: the draft pointers become foreign keys (the
5
+ -- token rides every locale row read) and the editing-presence channel
6
+ -- gets its policy on realtime.messages.
7
+
8
+ set client_min_messages = warning;
9
+
10
+ alter table "page_locales" drop constraint if exists "page_locales_draft_version_fkey";
11
+ alter table "page_locales" add constraint "page_locales_draft_version_fkey"
12
+ foreign key ("draft_version_id") references "page_versions" ("id") on delete set null;
13
+ alter table "entry_locales" drop constraint if exists "entry_locales_draft_version_fkey";
14
+ alter table "entry_locales" add constraint "entry_locales_draft_version_fkey"
15
+ foreign key ("draft_version_id") references "entry_versions" ("id") on delete set null;
16
+
17
+ drop policy if exists "smoodly_presence_read" on "realtime"."messages";
18
+ create policy "smoodly_presence_read" on "realtime"."messages" for select
19
+ using ((select realtime.topic()) = 'space:' || (select public."smoodly_current_space"())::text);
20
+
21
+ drop policy if exists "smoodly_presence_write" on "realtime"."messages";
22
+ create policy "smoodly_presence_write" on "realtime"."messages" for insert
23
+ with check ((select realtime.topic()) = 'space:' || (select public."smoodly_current_space"())::text);
24
+
25
+ insert into "smoodly_meta" ("key", "value") values ('schema_version', '2')
26
+ on conflict ("key") do update set "value" = excluded."value";
@@ -0,0 +1,38 @@
1
+ -- Smoodly core schema, version 3 (docs/superpowers/specs/2026-09-26-security-pass-design.md).
2
+ -- Shipped in the smoodly package; `npx smoodly migrate` copies it into supabase/migrations/.
3
+ -- Never edit a published file: the next change is the next file.
4
+ -- The delta over version 2: the presence channel admits a signed-in
5
+ -- member of the topic's space (a definer lookup in members by the session
6
+ -- token's user), the five unpinned functions get a search_path, and the
7
+ -- three mutation RPCs are no longer executable by anon or public.
8
+
9
+ set client_min_messages = warning;
10
+
11
+ create or replace function "smoodly_presence_member"() returns boolean
12
+ language sql stable security definer set search_path = public as $$
13
+ select exists (select 1 from "members" m
14
+ where m."user_id" = auth.uid()
15
+ and realtime.topic() = 'space:' || m."space_id"::text);
16
+ $$;
17
+
18
+ drop policy if exists "smoodly_presence_read" on "realtime"."messages";
19
+ create policy "smoodly_presence_read" on "realtime"."messages" for select
20
+ using ((select public."smoodly_presence_member"()));
21
+
22
+ drop policy if exists "smoodly_presence_write" on "realtime"."messages";
23
+ create policy "smoodly_presence_write" on "realtime"."messages" for insert
24
+ with check ((select public."smoodly_presence_member"()));
25
+
26
+ alter function "smoodly_current_space"() set search_path = '';
27
+ alter function "smoodly_key_kind"() set search_path = '';
28
+ alter function "smoodly_set_space"() set search_path = '';
29
+ alter function "smoodly_reorder"(text, uuid[]) set search_path = public;
30
+ alter function "smoodly_reorder_pages"(uuid[]) set search_path = public;
31
+ alter function "smoodly_rewrite_paths"(jsonb, jsonb) set search_path = public;
32
+
33
+ revoke execute on function "smoodly_reorder"(text, uuid[]) from public, anon;
34
+ revoke execute on function "smoodly_reorder_pages"(uuid[]) from public, anon;
35
+ revoke execute on function "smoodly_rewrite_paths"(jsonb, jsonb) from public, anon;
36
+
37
+ insert into "smoodly_meta" ("key", "value") values ('schema_version', '3')
38
+ on conflict ("key") do update set "value" = excluded."value";
@@ -1,5 +1,5 @@
1
1
  -- Smoodly: read views and order indexes for this app's collections, written by `npx smoodly migrate`
2
- -- (2026-09-26T12:01:00.000Z). One block per collection; the marker's hash is the block's SQL, compared on the next run.
2
+ -- (2026-09-26T14:01:00.000Z). One block per collection; the marker's hash is the block's SQL, compared on the next run.
3
3
  -- Never edit a written file: change the collection and run migrate again.
4
4
 
5
5
  -- smoodly:collection people sha256:929798ebb4fa2bb6
@@ -14,7 +14,7 @@
14
14
  "next": "^16.3.4",
15
15
  "react": "^19",
16
16
  "react-dom": "^19",
17
- "smoodly": "0.0.25",
17
+ "smoodly": "0.0.27",
18
18
  "next-intl": "^4.14.2"
19
19
  },
20
20
  "devDependencies": {
@@ -1,6 +1,6 @@
1
1
  import { createSmoodlyAdmin } from "smoodly/admin/next";
2
2
  import { config } from "./config";
3
3
  import { smoodlyOp } from "./ops";
4
- import { publicAuth } from "./server";
4
+ import { publicAuth, publicContent } from "./server";
5
5
 
6
- export const { AdminPage, AdminLayout } = createSmoodlyAdmin({ config, op: smoodlyOp, auth: publicAuth });
6
+ export const { AdminPage, AdminLayout } = createSmoodlyAdmin({ config, op: smoodlyOp, auth: publicAuth, content: publicContent });
@@ -9,7 +9,7 @@
9
9
  // admin route enters it from config.ts — so nothing here may read the
10
10
  // config at module scope.
11
11
  import {
12
- createSmoodlyClient, createSmoodlySite, smoodlyEnv, SupabaseAssetStore, SupabaseEntryStore, SupabaseMemberStore, SupabasePageStore, SupabasePathIndex, type SmoodlySite,
12
+ createSmoodlyClient, createSmoodlySite, publicContentConfig, smoodlyEnv, SupabaseAssetStore, SupabaseEntryStore, SupabaseMemberStore, SupabasePageStore, SupabasePathIndex, type ContentConfig, type SmoodlySite,
13
13
  } from "smoodly";
14
14
  import { supabaseAdminAuth, type AdminAuth, type AuthConfig } from "smoodly/admin/next";
15
15
  import { createPageRenderer, createSmoodlyQueries, type PageRegistration } from "smoodly/next";
@@ -82,6 +82,11 @@ export function publicAuth(): AuthConfig {
82
82
  return { url: env.authUrl, key: env.authKey };
83
83
  }
84
84
 
85
+ /** What the browser needs to join the editing-presence channel — public values only (spec 2026-09-26 concurrency §5). */
86
+ export function publicContent(): ContentConfig {
87
+ return publicContentConfig(smoodlyEnv());
88
+ }
89
+
85
90
  /** Locale-relative CMS path → site URL: the one seam for the renderer
86
91
  * (metadata alternates, the `page` prop's links) and the admin (canvas,
87
92
  * View live). The identity for a single-language site; with next-intl it
@@ -0,0 +1,26 @@
1
+ -- Smoodly core schema, version 2 (docs/superpowers/specs/2026-09-26-concurrency-guard-presence-design.md).
2
+ -- Shipped in the smoodly package; `npx smoodly migrate` copies it into supabase/migrations/.
3
+ -- Never edit a published file: the next change is the next file.
4
+ -- The delta over version 1: the draft pointers become foreign keys (the
5
+ -- token rides every locale row read) and the editing-presence channel
6
+ -- gets its policy on realtime.messages.
7
+
8
+ set client_min_messages = warning;
9
+
10
+ alter table "page_locales" drop constraint if exists "page_locales_draft_version_fkey";
11
+ alter table "page_locales" add constraint "page_locales_draft_version_fkey"
12
+ foreign key ("draft_version_id") references "page_versions" ("id") on delete set null;
13
+ alter table "entry_locales" drop constraint if exists "entry_locales_draft_version_fkey";
14
+ alter table "entry_locales" add constraint "entry_locales_draft_version_fkey"
15
+ foreign key ("draft_version_id") references "entry_versions" ("id") on delete set null;
16
+
17
+ drop policy if exists "smoodly_presence_read" on "realtime"."messages";
18
+ create policy "smoodly_presence_read" on "realtime"."messages" for select
19
+ using ((select realtime.topic()) = 'space:' || (select public."smoodly_current_space"())::text);
20
+
21
+ drop policy if exists "smoodly_presence_write" on "realtime"."messages";
22
+ create policy "smoodly_presence_write" on "realtime"."messages" for insert
23
+ with check ((select realtime.topic()) = 'space:' || (select public."smoodly_current_space"())::text);
24
+
25
+ insert into "smoodly_meta" ("key", "value") values ('schema_version', '2')
26
+ on conflict ("key") do update set "value" = excluded."value";
@@ -0,0 +1,38 @@
1
+ -- Smoodly core schema, version 3 (docs/superpowers/specs/2026-09-26-security-pass-design.md).
2
+ -- Shipped in the smoodly package; `npx smoodly migrate` copies it into supabase/migrations/.
3
+ -- Never edit a published file: the next change is the next file.
4
+ -- The delta over version 2: the presence channel admits a signed-in
5
+ -- member of the topic's space (a definer lookup in members by the session
6
+ -- token's user), the five unpinned functions get a search_path, and the
7
+ -- three mutation RPCs are no longer executable by anon or public.
8
+
9
+ set client_min_messages = warning;
10
+
11
+ create or replace function "smoodly_presence_member"() returns boolean
12
+ language sql stable security definer set search_path = public as $$
13
+ select exists (select 1 from "members" m
14
+ where m."user_id" = auth.uid()
15
+ and realtime.topic() = 'space:' || m."space_id"::text);
16
+ $$;
17
+
18
+ drop policy if exists "smoodly_presence_read" on "realtime"."messages";
19
+ create policy "smoodly_presence_read" on "realtime"."messages" for select
20
+ using ((select public."smoodly_presence_member"()));
21
+
22
+ drop policy if exists "smoodly_presence_write" on "realtime"."messages";
23
+ create policy "smoodly_presence_write" on "realtime"."messages" for insert
24
+ with check ((select public."smoodly_presence_member"()));
25
+
26
+ alter function "smoodly_current_space"() set search_path = '';
27
+ alter function "smoodly_key_kind"() set search_path = '';
28
+ alter function "smoodly_set_space"() set search_path = '';
29
+ alter function "smoodly_reorder"(text, uuid[]) set search_path = public;
30
+ alter function "smoodly_reorder_pages"(uuid[]) set search_path = public;
31
+ alter function "smoodly_rewrite_paths"(jsonb, jsonb) set search_path = public;
32
+
33
+ revoke execute on function "smoodly_reorder"(text, uuid[]) from public, anon;
34
+ revoke execute on function "smoodly_reorder_pages"(uuid[]) from public, anon;
35
+ revoke execute on function "smoodly_rewrite_paths"(jsonb, jsonb) from public, anon;
36
+
37
+ insert into "smoodly_meta" ("key", "value") values ('schema_version', '3')
38
+ on conflict ("key") do update set "value" = excluded."value";
@@ -1,5 +1,5 @@
1
1
  -- Smoodly: read views and order indexes for this app's collections, written by `npx smoodly migrate`
2
- -- (2026-09-26T12:01:00.000Z). One block per collection; the marker's hash is the block's SQL, compared on the next run.
2
+ -- (2026-09-26T14:01:00.000Z). One block per collection; the marker's hash is the block's SQL, compared on the next run.
3
3
  -- Never edit a written file: change the collection and run migrate again.
4
4
 
5
5
  -- smoodly:collection people sha256:929798ebb4fa2bb6