@nextblock-cms/db 0.16.3 → 0.17.0

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 (20) hide show
  1. package/package.json +1 -1
  2. package/supabase/functions/nextblock-migration-ingest/index.ts +8 -8
  3. package/supabase/migrations/00000000000000_baseline_schema.sql +2454 -2454
  4. package/supabase/migrations/00000000000001_baseline_constraints_and_indexes.sql +1071 -1071
  5. package/supabase/migrations/00000000000002_baseline_security_and_grants.sql +1335 -1335
  6. package/supabase/migrations/00000000000004_default_logo_email_safe.sql +24 -24
  7. package/supabase/migrations/00000000000005_add_custom_canonical.sql +13 -13
  8. package/supabase/migrations/00000000000008_setup_article_reorder.sql +30 -30
  9. package/supabase/migrations/00000000000013_youtube_nocookie_embeds.sql +136 -136
  10. package/supabase/migrations/00000000000032_seed_seo_score_optimizations.sql +1142 -1142
  11. package/supabase/migrations/00000000000033_seed_seo_score_optimizations_p2.sql +231 -231
  12. package/supabase/migrations/00000000000034_seed_seo_french_legal_readability.sql +23 -23
  13. package/supabase/migrations/00000000000035_digital_products_seo_optimizations.sql +134 -0
  14. package/supabase/migrations/00000000000036_seed_posts_missing_seo_metadata.sql +37 -0
  15. package/supabase/migrations/00000000000037_reposition_marketing_and_cortex_mcp.sql +501 -0
  16. package/supabase/migrations/00000000000038_mcp_guide_visual_refresh.sql +64 -0
  17. package/supabase/migrations/00000000000039_mcp_guide_diagram_dimensions.sql +21 -0
  18. package/supabase/migrations/00000000000040_home_comparison_chart_free_cms.sql +81 -0
  19. package/supabase/migrations/00000000000041_marketing_review_free_cms_trial.sql +141 -0
  20. package/supabase/migrations/00000000000042_how_nextblock_works_css_diagram.sql +66 -0
@@ -1,136 +1,136 @@
1
- -- 00000000000013_youtube_nocookie_embeds.sql
2
- --
3
- -- Lighthouse Best Practices scored 96 instead of 100: the `inspector-issues` audit
4
- -- (binary, weight 1 of 27 -> 26/27 = 96) failed with a DevTools "Cookie" issue
5
- -- attributed to www.youtube.com/embed/71MyfoL4YVM. The seeded home-page hero and the
6
- -- seeded articles embed raw <iframe> markup pointing at www.youtube.com, whose player
7
- -- writes cookies on load.
8
- --
9
- -- The real fix is the render-time click-to-play facade added in
10
- -- apps/nextblock/components/media/YouTubeFacade.tsx (the nocookie host does NOT stop
11
- -- the player's document.cookie writes -- only not loading the player does). This
12
- -- migration is the data-hygiene half: it rewrites every stored embed to the
13
- -- privacy-enhanced host so any surface that still renders a raw iframe (published-lib
14
- -- renderers, CMS previews, exports, downstream installs on an older app build) is at
15
- -- least cookie-reduced, and so the stored content matches what we ship.
16
- --
17
- -- It also fixes the bogus Permissions Policy feature in the seeded allow attribute:
18
- -- 'accelerated-motion' is not a real feature (Chrome logs "Unrecognized feature");
19
- -- the canonical YouTube embed uses 'accelerometer'.
20
- --
21
- -- Append-only: 00000000000003_baseline_seed.sql is applied everywhere and is NOT edited.
22
- -- Scoped by CONTENT MATCH, never by block id -- ids drift on installs where the demo
23
- -- content was re-created (see the convention documented in 00000000000006:11-13 and
24
- -- used by 007/009). This is a pure host-substring swap, so it never clobbers a user's
25
- -- edited copy, it also repairs author-pasted embeds, and it is naturally idempotent
26
- -- (a second run matches zero rows) which matters because the nightly sandbox reset
27
- -- replays the whole migration chain from a truncated history.
28
- --
29
- -- No dollar-quoting is needed here: neither search nor replacement literal contains a
30
- -- single quote, and neither contains a JSON metacharacter, so the ::text round-trip
31
- -- always re-parses as valid JSON. Query strings (?si=...) are preserved.
32
- --
33
- -- NOTE: keep the word "sandbox" OUT of this filename -- generate-sandbox-reset.ts
34
- -- excludes any migration whose filename contains "sandbox".
35
-
36
- -- 1. Live page/post block content (the 4 seeded rows + any author-added embed).
37
- UPDATE public.blocks
38
- SET content = replace(
39
- replace(content::text, 'www.youtube.com/embed/', 'www.youtube-nocookie.com/embed/'),
40
- 'accelerated-motion', 'accelerometer'
41
- )::jsonb
42
- WHERE content IS NOT NULL
43
- AND (content::text LIKE '%www.youtube.com/embed/%'
44
- OR content::text LIKE '%accelerated-motion%');
45
-
46
- -- 2. Live Draft Mode snapshots. Publishing a pre-existing draft would otherwise write
47
- -- the cookie host straight back into public.blocks.
48
- UPDATE public.content_drafts
49
- SET blocks = replace(
50
- replace(blocks::text, 'www.youtube.com/embed/', 'www.youtube-nocookie.com/embed/'),
51
- 'accelerated-motion', 'accelerometer'
52
- )::jsonb
53
- WHERE blocks::text LIKE '%www.youtube.com/embed/%'
54
- OR blocks::text LIKE '%accelerated-motion%';
55
-
56
- UPDATE public.content_drafts
57
- SET meta = replace(
58
- replace(meta::text, 'www.youtube.com/embed/', 'www.youtube-nocookie.com/embed/'),
59
- 'accelerated-motion', 'accelerometer'
60
- )::jsonb
61
- WHERE meta::text LIKE '%www.youtube.com/embed/%'
62
- OR meta::text LIKE '%accelerated-motion%';
63
-
64
- UPDATE public.product_drafts
65
- SET blocks = replace(
66
- replace(blocks::text, 'www.youtube.com/embed/', 'www.youtube-nocookie.com/embed/'),
67
- 'accelerated-motion', 'accelerometer'
68
- )::jsonb
69
- WHERE blocks::text LIKE '%www.youtube.com/embed/%'
70
- OR blocks::text LIKE '%accelerated-motion%';
71
-
72
- -- product_drafts.meta carries short_description / description_json.
73
- UPDATE public.product_drafts
74
- SET meta = replace(
75
- replace(meta::text, 'www.youtube.com/embed/', 'www.youtube-nocookie.com/embed/'),
76
- 'accelerated-motion', 'accelerometer'
77
- )::jsonb
78
- WHERE meta::text LIKE '%www.youtube.com/embed/%'
79
- OR meta::text LIKE '%accelerated-motion%';
80
-
81
- -- 3. Revision history. apps/nextblock/app/cms/revisions/service.ts replays a snapshot
82
- -- verbatim, so one "Restore version" click would otherwise reintroduce the issue.
83
- -- URL-only rewrite; nothing else about the historical snapshot is touched.
84
- UPDATE public.page_revisions
85
- SET content = replace(
86
- replace(content::text, 'www.youtube.com/embed/', 'www.youtube-nocookie.com/embed/'),
87
- 'accelerated-motion', 'accelerometer'
88
- )::jsonb
89
- WHERE content::text LIKE '%www.youtube.com/embed/%'
90
- OR content::text LIKE '%accelerated-motion%';
91
-
92
- UPDATE public.post_revisions
93
- SET content = replace(
94
- replace(content::text, 'www.youtube.com/embed/', 'www.youtube-nocookie.com/embed/'),
95
- 'accelerated-motion', 'accelerometer'
96
- )::jsonb
97
- WHERE content::text LIKE '%www.youtube.com/embed/%'
98
- OR content::text LIKE '%accelerated-motion%';
99
-
100
- -- 4. Product rich text rendered on public /product/* routes.
101
- UPDATE public.products
102
- SET short_description = replace(
103
- replace(short_description, 'www.youtube.com/embed/', 'www.youtube-nocookie.com/embed/'),
104
- 'accelerated-motion', 'accelerometer'
105
- )
106
- WHERE short_description IS NOT NULL
107
- AND (short_description LIKE '%www.youtube.com/embed/%'
108
- OR short_description LIKE '%accelerated-motion%');
109
-
110
- UPDATE public.products
111
- SET description_json = replace(
112
- replace(description_json::text, 'www.youtube.com/embed/', 'www.youtube-nocookie.com/embed/'),
113
- 'accelerated-motion', 'accelerometer'
114
- )::jsonb
115
- WHERE description_json IS NOT NULL
116
- AND (description_json::text LIKE '%www.youtube.com/embed/%'
117
- OR description_json::text LIKE '%accelerated-motion%');
118
-
119
- -- 5. Custom block definitions (rich-text defaults / emptyFallback markup rendered by
120
- -- DynamicLayoutEngine). Host-only swap, so the is_valid_custom_block_* CHECK
121
- -- constraints still hold. No-op on a fresh install.
122
- UPDATE public.custom_block_definitions
123
- SET fields = replace(
124
- replace(fields::text, 'www.youtube.com/embed/', 'www.youtube-nocookie.com/embed/'),
125
- 'accelerated-motion', 'accelerometer'
126
- )::jsonb
127
- WHERE fields::text LIKE '%www.youtube.com/embed/%'
128
- OR fields::text LIKE '%accelerated-motion%';
129
-
130
- UPDATE public.custom_block_definitions
131
- SET layout_schema = replace(
132
- replace(layout_schema::text, 'www.youtube.com/embed/', 'www.youtube-nocookie.com/embed/'),
133
- 'accelerated-motion', 'accelerometer'
134
- )::jsonb
135
- WHERE layout_schema::text LIKE '%www.youtube.com/embed/%'
136
- OR layout_schema::text LIKE '%accelerated-motion%';
1
+ -- 00000000000013_youtube_nocookie_embeds.sql
2
+ --
3
+ -- Lighthouse Best Practices scored 96 instead of 100: the `inspector-issues` audit
4
+ -- (binary, weight 1 of 27 -> 26/27 = 96) failed with a DevTools "Cookie" issue
5
+ -- attributed to www.youtube.com/embed/71MyfoL4YVM. The seeded home-page hero and the
6
+ -- seeded articles embed raw <iframe> markup pointing at www.youtube.com, whose player
7
+ -- writes cookies on load.
8
+ --
9
+ -- The real fix is the render-time click-to-play facade added in
10
+ -- apps/nextblock/components/media/YouTubeFacade.tsx (the nocookie host does NOT stop
11
+ -- the player's document.cookie writes -- only not loading the player does). This
12
+ -- migration is the data-hygiene half: it rewrites every stored embed to the
13
+ -- privacy-enhanced host so any surface that still renders a raw iframe (published-lib
14
+ -- renderers, CMS previews, exports, downstream installs on an older app build) is at
15
+ -- least cookie-reduced, and so the stored content matches what we ship.
16
+ --
17
+ -- It also fixes the bogus Permissions Policy feature in the seeded allow attribute:
18
+ -- 'accelerated-motion' is not a real feature (Chrome logs "Unrecognized feature");
19
+ -- the canonical YouTube embed uses 'accelerometer'.
20
+ --
21
+ -- Append-only: 00000000000003_baseline_seed.sql is applied everywhere and is NOT edited.
22
+ -- Scoped by CONTENT MATCH, never by block id -- ids drift on installs where the demo
23
+ -- content was re-created (see the convention documented in 00000000000006:11-13 and
24
+ -- used by 007/009). This is a pure host-substring swap, so it never clobbers a user's
25
+ -- edited copy, it also repairs author-pasted embeds, and it is naturally idempotent
26
+ -- (a second run matches zero rows) which matters because the nightly sandbox reset
27
+ -- replays the whole migration chain from a truncated history.
28
+ --
29
+ -- No dollar-quoting is needed here: neither search nor replacement literal contains a
30
+ -- single quote, and neither contains a JSON metacharacter, so the ::text round-trip
31
+ -- always re-parses as valid JSON. Query strings (?si=...) are preserved.
32
+ --
33
+ -- NOTE: keep the word "sandbox" OUT of this filename -- generate-sandbox-reset.ts
34
+ -- excludes any migration whose filename contains "sandbox".
35
+
36
+ -- 1. Live page/post block content (the 4 seeded rows + any author-added embed).
37
+ UPDATE public.blocks
38
+ SET content = replace(
39
+ replace(content::text, 'www.youtube.com/embed/', 'www.youtube-nocookie.com/embed/'),
40
+ 'accelerated-motion', 'accelerometer'
41
+ )::jsonb
42
+ WHERE content IS NOT NULL
43
+ AND (content::text LIKE '%www.youtube.com/embed/%'
44
+ OR content::text LIKE '%accelerated-motion%');
45
+
46
+ -- 2. Live Draft Mode snapshots. Publishing a pre-existing draft would otherwise write
47
+ -- the cookie host straight back into public.blocks.
48
+ UPDATE public.content_drafts
49
+ SET blocks = replace(
50
+ replace(blocks::text, 'www.youtube.com/embed/', 'www.youtube-nocookie.com/embed/'),
51
+ 'accelerated-motion', 'accelerometer'
52
+ )::jsonb
53
+ WHERE blocks::text LIKE '%www.youtube.com/embed/%'
54
+ OR blocks::text LIKE '%accelerated-motion%';
55
+
56
+ UPDATE public.content_drafts
57
+ SET meta = replace(
58
+ replace(meta::text, 'www.youtube.com/embed/', 'www.youtube-nocookie.com/embed/'),
59
+ 'accelerated-motion', 'accelerometer'
60
+ )::jsonb
61
+ WHERE meta::text LIKE '%www.youtube.com/embed/%'
62
+ OR meta::text LIKE '%accelerated-motion%';
63
+
64
+ UPDATE public.product_drafts
65
+ SET blocks = replace(
66
+ replace(blocks::text, 'www.youtube.com/embed/', 'www.youtube-nocookie.com/embed/'),
67
+ 'accelerated-motion', 'accelerometer'
68
+ )::jsonb
69
+ WHERE blocks::text LIKE '%www.youtube.com/embed/%'
70
+ OR blocks::text LIKE '%accelerated-motion%';
71
+
72
+ -- product_drafts.meta carries short_description / description_json.
73
+ UPDATE public.product_drafts
74
+ SET meta = replace(
75
+ replace(meta::text, 'www.youtube.com/embed/', 'www.youtube-nocookie.com/embed/'),
76
+ 'accelerated-motion', 'accelerometer'
77
+ )::jsonb
78
+ WHERE meta::text LIKE '%www.youtube.com/embed/%'
79
+ OR meta::text LIKE '%accelerated-motion%';
80
+
81
+ -- 3. Revision history. apps/nextblock/app/cms/revisions/service.ts replays a snapshot
82
+ -- verbatim, so one "Restore version" click would otherwise reintroduce the issue.
83
+ -- URL-only rewrite; nothing else about the historical snapshot is touched.
84
+ UPDATE public.page_revisions
85
+ SET content = replace(
86
+ replace(content::text, 'www.youtube.com/embed/', 'www.youtube-nocookie.com/embed/'),
87
+ 'accelerated-motion', 'accelerometer'
88
+ )::jsonb
89
+ WHERE content::text LIKE '%www.youtube.com/embed/%'
90
+ OR content::text LIKE '%accelerated-motion%';
91
+
92
+ UPDATE public.post_revisions
93
+ SET content = replace(
94
+ replace(content::text, 'www.youtube.com/embed/', 'www.youtube-nocookie.com/embed/'),
95
+ 'accelerated-motion', 'accelerometer'
96
+ )::jsonb
97
+ WHERE content::text LIKE '%www.youtube.com/embed/%'
98
+ OR content::text LIKE '%accelerated-motion%';
99
+
100
+ -- 4. Product rich text rendered on public /product/* routes.
101
+ UPDATE public.products
102
+ SET short_description = replace(
103
+ replace(short_description, 'www.youtube.com/embed/', 'www.youtube-nocookie.com/embed/'),
104
+ 'accelerated-motion', 'accelerometer'
105
+ )
106
+ WHERE short_description IS NOT NULL
107
+ AND (short_description LIKE '%www.youtube.com/embed/%'
108
+ OR short_description LIKE '%accelerated-motion%');
109
+
110
+ UPDATE public.products
111
+ SET description_json = replace(
112
+ replace(description_json::text, 'www.youtube.com/embed/', 'www.youtube-nocookie.com/embed/'),
113
+ 'accelerated-motion', 'accelerometer'
114
+ )::jsonb
115
+ WHERE description_json IS NOT NULL
116
+ AND (description_json::text LIKE '%www.youtube.com/embed/%'
117
+ OR description_json::text LIKE '%accelerated-motion%');
118
+
119
+ -- 5. Custom block definitions (rich-text defaults / emptyFallback markup rendered by
120
+ -- DynamicLayoutEngine). Host-only swap, so the is_valid_custom_block_* CHECK
121
+ -- constraints still hold. No-op on a fresh install.
122
+ UPDATE public.custom_block_definitions
123
+ SET fields = replace(
124
+ replace(fields::text, 'www.youtube.com/embed/', 'www.youtube-nocookie.com/embed/'),
125
+ 'accelerated-motion', 'accelerometer'
126
+ )::jsonb
127
+ WHERE fields::text LIKE '%www.youtube.com/embed/%'
128
+ OR fields::text LIKE '%accelerated-motion%';
129
+
130
+ UPDATE public.custom_block_definitions
131
+ SET layout_schema = replace(
132
+ replace(layout_schema::text, 'www.youtube.com/embed/', 'www.youtube-nocookie.com/embed/'),
133
+ 'accelerated-motion', 'accelerometer'
134
+ )::jsonb
135
+ WHERE layout_schema::text LIKE '%www.youtube.com/embed/%'
136
+ OR layout_schema::text LIKE '%accelerated-motion%';