smoodly 0.0.35 → 0.0.36

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 (64) hide show
  1. package/README.md +29 -38
  2. package/dist/admin/drift.js +3 -2
  3. package/dist/admin/editor/SeoSettings.d.ts +7 -1
  4. package/dist/admin/editor/SeoSettings.js +2 -2
  5. package/dist/admin/field-label.d.ts +2 -0
  6. package/dist/admin/field-label.js +2 -0
  7. package/dist/admin/forms/FieldWidget.js +2 -2
  8. package/dist/admin/next/create-admin.d.ts +4 -4
  9. package/dist/admin/next/create-admin.js +5 -5
  10. package/dist/admin/next/index.d.ts +1 -1
  11. package/dist/admin/serialize.d.ts +8 -1
  12. package/dist/admin/serialize.js +23 -7
  13. package/dist/admin/shell/AdminApp.d.ts +3 -3
  14. package/dist/admin/shell/AdminApp.js +2 -2
  15. package/dist/admin/shell/EntryForm.js +8 -1
  16. package/dist/admin/shell/presence-realtime.d.ts +2 -2
  17. package/dist/cli/space-io.js +1 -1
  18. package/dist/collections.d.ts +4 -0
  19. package/dist/collections.js +9 -1
  20. package/dist/entry-page.d.ts +12 -10
  21. package/dist/entry-store.d.ts +29 -0
  22. package/dist/entry-store.js +53 -0
  23. package/dist/env.d.ts +5 -5
  24. package/dist/env.js +2 -2
  25. package/dist/fields.d.ts +13 -7
  26. package/dist/fields.js +2 -2
  27. package/dist/global.d.ts +4 -7
  28. package/dist/index.d.ts +10 -39
  29. package/dist/index.js +1 -1
  30. package/dist/migrations.js +1 -1
  31. package/dist/next/index.d.ts +1 -1
  32. package/dist/next/index.js +1 -1
  33. package/dist/next/meta.d.ts +6 -4
  34. package/dist/next/meta.js +14 -17
  35. package/dist/next/page-renderer.js +6 -3
  36. package/dist/next/queries.d.ts +10 -11
  37. package/dist/next/queries.js +7 -2
  38. package/dist/page.d.ts +5 -2
  39. package/dist/page.js +3 -1
  40. package/dist/pairing.d.ts +10 -10
  41. package/dist/path-index.d.ts +3 -0
  42. package/dist/path-index.js +7 -0
  43. package/dist/read-shapes.d.ts +64 -0
  44. package/dist/read-shapes.js +52 -0
  45. package/dist/render.d.ts +3 -3
  46. package/dist/resolve.d.ts +12 -0
  47. package/dist/resolve.js +29 -7
  48. package/dist/schema-version.d.ts +1 -1
  49. package/dist/schema-version.js +1 -1
  50. package/dist/schema.d.ts +22 -1
  51. package/dist/seo.d.ts +18 -0
  52. package/dist/seo.js +53 -0
  53. package/dist/site.d.ts +15 -16
  54. package/dist/site.js +64 -58
  55. package/dist/sql-space.d.ts +6 -5
  56. package/dist/sql-space.js +11 -24
  57. package/dist/sql.d.ts +6 -1
  58. package/dist/sql.js +60 -23
  59. package/dist/supabase-entry-store.d.ts +3 -1
  60. package/dist/supabase-entry-store.js +39 -0
  61. package/dist/supabase-path-index.d.ts +1 -0
  62. package/dist/supabase-path-index.js +16 -0
  63. package/migrations/20260930040956_smoodly_v7.sql +84 -0
  64. package/package.json +1 -1
@@ -0,0 +1,84 @@
1
+ -- Smoodly core schema, version 7 (docs/superpowers/specs/2026-09-29-content-api-contract-design.md §5).
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 6: smoodly_list_entries, which filters, orders and
5
+ -- limits a collection over the snapshot the reader is shown, and the read
6
+ -- policies of every content table admit a write key only (§8).
7
+
8
+ -- The shown snapshot of one collection's entries in a locale, filtered,
9
+ -- ordered and limited in one query (spec 2026-09-29 content API contract
10
+ -- §5): the published snapshot, or the live merge in preview. Invoker
11
+ -- rights, so RLS decides what a key sees; a preview read needs the
12
+ -- service role or a write key, anything else reads published.
13
+ create or replace function "smoodly_list_entries"(
14
+ p_collection text, p_locale text, p_draft boolean, p_where jsonb, p_order jsonb,
15
+ p_limit integer, p_parent uuid, p_has_parent boolean, p_ids uuid[]
16
+ ) returns table ("id" uuid, "fields" jsonb) language sql stable set search_path = public as $$
17
+ with mode as (
18
+ select p_draft and (current_user = 'service_role' or "smoodly_key_kind"() = 'write') as draft
19
+ ), shown as (
20
+ select e."id", e."sort", e."created_at", l."updated_at",
21
+ case when (select draft from mode) then e."fields" || l."fields" || jsonb_build_object('slug', l."slug")
22
+ else coalesce(v."fields", e."fields" || l."fields" || jsonb_build_object('slug', l."slug")) end as "fields"
23
+ from "entries" e
24
+ join "entry_locales" l on l."entry_id" = e."id" and l."locale" = p_locale
25
+ left join "entry_versions" v on v."id" = l."published_version_id"
26
+ where e."collection" = p_collection
27
+ and ((select draft from mode) or l."status" = 'published')
28
+ and (not p_has_parent or e."parent_id" is not distinct from p_parent)
29
+ and (p_ids is null or e."id" = any(p_ids))
30
+ )
31
+ select s."id", s."fields" from shown s
32
+ where not exists (
33
+ select 1 from jsonb_each(coalesce(p_where, '{}'::jsonb)) w
34
+ where not (case when w.value ? 'in'
35
+ then (s."fields" ->> w.key) = any (select jsonb_array_elements_text(w.value -> 'in'))
36
+ else s."fields" @> jsonb_build_object(w.key, w.value -> 'contains') end))
37
+ order by
38
+ case when p_order ->> 'by' = 'manual' then s."sort" end asc nulls last,
39
+ case when p_order ->> 'direction' = 'asc' then
40
+ case p_order ->> 'by' when 'createdAt' then to_jsonb(s."created_at") when 'updatedAt' then to_jsonb(s."updated_at")
41
+ when 'manual' then null else nullif(nullif(s."fields" -> (p_order ->> 'by'), 'null'::jsonb), '""'::jsonb) end end asc nulls last,
42
+ case when p_order ->> 'direction' = 'desc' then
43
+ case p_order ->> 'by' when 'createdAt' then to_jsonb(s."created_at") when 'updatedAt' then to_jsonb(s."updated_at")
44
+ when 'manual' then null else nullif(nullif(s."fields" -> (p_order ->> 'by'), 'null'::jsonb), '""'::jsonb) end end desc nulls last,
45
+ s."created_at" asc, s."id" asc
46
+ limit p_limit;
47
+ $$;
48
+
49
+ -- No public content reads (spec 2026-09-29 content API contract §8): the
50
+ -- publishable key and a read key read nothing; a write key reads its own space.
51
+ drop policy if exists "smoodly_read" on "pages";
52
+ create policy "smoodly_read" on "pages" for select
53
+ using ("space_id" = (select "smoodly_current_space"()) and not (select "smoodly_space_key_revoked"()) and (select "smoodly_key_kind"()) = 'write');
54
+
55
+ drop policy if exists "smoodly_read" on "page_locales";
56
+ create policy "smoodly_read" on "page_locales" for select
57
+ using ("space_id" = (select "smoodly_current_space"()) and not (select "smoodly_space_key_revoked"()) and (select "smoodly_key_kind"()) = 'write');
58
+
59
+ drop policy if exists "smoodly_read" on "page_versions";
60
+ create policy "smoodly_read" on "page_versions" for select
61
+ using ("space_id" = (select "smoodly_current_space"()) and not (select "smoodly_space_key_revoked"()) and (select "smoodly_key_kind"()) = 'write');
62
+
63
+ drop policy if exists "smoodly_read" on "entries";
64
+ create policy "smoodly_read" on "entries" for select
65
+ using ("space_id" = (select "smoodly_current_space"()) and not (select "smoodly_space_key_revoked"()) and (select "smoodly_key_kind"()) = 'write');
66
+
67
+ drop policy if exists "smoodly_read" on "entry_locales";
68
+ create policy "smoodly_read" on "entry_locales" for select
69
+ using ("space_id" = (select "smoodly_current_space"()) and not (select "smoodly_space_key_revoked"()) and (select "smoodly_key_kind"()) = 'write');
70
+
71
+ drop policy if exists "smoodly_read" on "entry_versions";
72
+ create policy "smoodly_read" on "entry_versions" for select
73
+ using ("space_id" = (select "smoodly_current_space"()) and not (select "smoodly_space_key_revoked"()) and (select "smoodly_key_kind"()) = 'write');
74
+
75
+ drop policy if exists "smoodly_read" on "paths";
76
+ create policy "smoodly_read" on "paths" for select
77
+ using ("space_id" = (select "smoodly_current_space"()) and not (select "smoodly_space_key_revoked"()) and (select "smoodly_key_kind"()) = 'write');
78
+
79
+ drop policy if exists "smoodly_read" on "assets";
80
+ create policy "smoodly_read" on "assets" for select
81
+ using ("space_id" = (select "smoodly_current_space"()) and not (select "smoodly_space_key_revoked"()) and (select "smoodly_key_kind"()) = 'write');
82
+
83
+ insert into "smoodly_meta" ("key", "value") values ('schema_version', '7')
84
+ on conflict ("key") do update set "value" = excluded."value";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "smoodly",
3
- "version": "0.0.35",
3
+ "version": "0.0.36",
4
4
  "description": "Open-source, code-first CMS for Next.js on Supabase: define a component once, it becomes a typed, editable building block.",
5
5
  "license": "MIT",
6
6
  "repository": {