@nextblock-cms/db 0.11.3 → 0.12.1

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 (62) hide show
  1. package/lib/supabase/server.d.ts +9 -0
  2. package/lib/supabase/types.d.ts +9 -0
  3. package/package.json +1 -1
  4. package/supabase/migrations/00000000000000_baseline_schema.sql +2454 -0
  5. package/supabase/migrations/00000000000001_baseline_constraints_and_indexes.sql +1071 -0
  6. package/supabase/migrations/00000000000002_baseline_security_and_grants.sql +1335 -0
  7. package/supabase/migrations/00000000000003_baseline_seed.sql +468 -0
  8. package/supabase/migrations/00000000000004_default_logo_email_safe.sql +24 -0
  9. package/supabase/migrations/00000000000005_add_custom_canonical.sql +13 -0
  10. package/supabase/migrations/00000000000006_home_live_demo_promo.sql +67 -0
  11. package/supabase/migrations/00000000000007_home_live_demo_promo_copy_fix.sql +49 -0
  12. package/supabase/templates/confirmation.html +1 -1
  13. package/supabase/templates/email_change.html +1 -1
  14. package/supabase/templates/invite.html +1 -1
  15. package/supabase/templates/magic_link.html +1 -1
  16. package/supabase/templates/reauthentication.html +1 -1
  17. package/supabase/templates/recovery.html +1 -1
  18. package/supabase/migrations/00000000000000_setup_foundation_and_enums.sql +0 -40
  19. package/supabase/migrations/00000000000001_setup_cms_core.sql +0 -124
  20. package/supabase/migrations/00000000000002_setup_content_tables.sql +0 -138
  21. package/supabase/migrations/00000000000003_setup_catalog_and_licensing.sql +0 -160
  22. package/supabase/migrations/00000000000004_setup_fulfillment_shipping_taxes_and_currencies.sql +0 -797
  23. package/supabase/migrations/00000000000005_setup_functions_and_triggers.sql +0 -767
  24. package/supabase/migrations/00000000000006_setup_rls_and_grants.sql +0 -872
  25. package/supabase/migrations/00000000000007_setup_indexes.sql +0 -158
  26. package/supabase/migrations/00000000000008_seed_platform_defaults.sql +0 -155
  27. package/supabase/migrations/00000000000009_seed_translations.sql +0 -801
  28. package/supabase/migrations/00000000000010_seed_content_scaffold.sql +0 -1088
  29. package/supabase/migrations/00000000000011_setup_cortex_ai_settings.sql +0 -81
  30. package/supabase/migrations/00000000000012_setup_commerce_coupons.sql +0 -275
  31. package/supabase/migrations/00000000000013_setup_cortex_ai_db_mutation_audit.sql +0 -47
  32. package/supabase/migrations/00000000000014_setup_content_drafts.sql +0 -119
  33. package/supabase/migrations/00000000000015_setup_product_drafts.sql +0 -97
  34. package/supabase/migrations/00000000000016_add_feature_image_to_pages.sql +0 -8
  35. package/supabase/migrations/00000000000017_add_product_blocks.sql +0 -118
  36. package/supabase/migrations/00000000000018_setup_bot_protection_settings.sql +0 -77
  37. package/supabase/migrations/00000000000019_add_product_categories.sql +0 -64
  38. package/supabase/migrations/00000000000020_add_category_translations.sql +0 -10
  39. package/supabase/migrations/00000000000021_migrate_hero_blocks_to_sections.sql +0 -29
  40. package/supabase/migrations/00000000000022_seed_cortex_ai_guide_post.sql +0 -184
  41. package/supabase/migrations/00000000000023_setup_custom_block_definitions.sql +0 -183
  42. package/supabase/migrations/00000000000024_setup_ucp_cart_sessions.sql +0 -72
  43. package/supabase/migrations/00000000000025_add_sale_schedule_columns.sql +0 -406
  44. package/supabase/migrations/00000000000026_seed_on_sale_translation.sql +0 -9
  45. package/supabase/migrations/00000000000027_setup_privacy_and_mfa.sql +0 -479
  46. package/supabase/migrations/00000000000028_clear_advisor_warnings.sql +0 -93
  47. package/supabase/migrations/00000000000029_refresh_setup_article.sql +0 -252
  48. package/supabase/migrations/00000000000030_setup_system_configuration.sql +0 -80
  49. package/supabase/migrations/00000000000031_seed_footer_navigation.sql +0 -85
  50. package/supabase/migrations/00000000000032_neutralize_seeded_contact_emails.sql +0 -34
  51. package/supabase/migrations/00000000000033_setup_config_settings.sql +0 -99
  52. package/supabase/migrations/00000000000034_enable_staff_2fa_reminder_default.sql +0 -15
  53. package/supabase/migrations/00000000000035_reassert_advisor_fixes.sql +0 -33
  54. package/supabase/migrations/00000000000036_setup_system_alerts.sql +0 -72
  55. package/supabase/migrations/00000000000037_refresh_setup_article_install_paths.sql +0 -317
  56. package/supabase/migrations/00000000000038_seed_consent_banner_translations.sql +0 -126
  57. package/supabase/migrations/00000000000039_setup_interactions.sql +0 -153
  58. package/supabase/migrations/00000000000040_add_profiles_fk_to_interactions.sql +0 -8
  59. package/supabase/migrations/00000000000041_seed_interactions_translations.sql +0 -145
  60. package/supabase/migrations/00000000000042_seed_deploy_to_vercel_ctas.sql +0 -72
  61. package/supabase/migrations/00000000000043_swap_home_hero_media_to_youtube.sql +0 -42
  62. package/supabase/migrations/00000000000044_swap_article_nx_graph_for_youtube.sql +0 -66
@@ -1,158 +0,0 @@
1
- -- 00000000000007_setup_indexes.sql
2
- -- Consolidated migration preserving original statement order within grouped sections.
3
-
4
- -- 00000000000021_setup_cms_indexes.sql
5
- -- Supporting indexes for accounts, content, and revisions.
6
-
7
- CREATE INDEX idx_user_addresses_user_id
8
- ON public.user_addresses (user_id);
9
-
10
- CREATE INDEX idx_user_addresses_type
11
- ON public.user_addresses (address_type);
12
-
13
- CREATE INDEX idx_media_uploader_id
14
- ON public.media (uploader_id);
15
-
16
- CREATE INDEX media_folder_idx
17
- ON public.media (folder);
18
-
19
- CREATE INDEX idx_posts_feature_image_id
20
- ON public.posts (feature_image_id);
21
-
22
- CREATE INDEX idx_posts_author_id
23
- ON public.posts (author_id);
24
-
25
- CREATE INDEX idx_posts_translation_group_id
26
- ON public.posts (translation_group_id);
27
-
28
- CREATE INDEX idx_pages_author_id
29
- ON public.pages (author_id);
30
-
31
- CREATE INDEX idx_pages_translation_group_id
32
- ON public.pages (translation_group_id);
33
-
34
- CREATE INDEX idx_blocks_language_id
35
- ON public.blocks (language_id);
36
-
37
- CREATE INDEX idx_blocks_page_id
38
- ON public.blocks (page_id);
39
-
40
- CREATE INDEX idx_blocks_post_id
41
- ON public.blocks (post_id);
42
-
43
- CREATE INDEX idx_navigation_items_menu_lang_order
44
- ON public.navigation_items (menu_key, language_id, "order");
45
-
46
- CREATE INDEX idx_navigation_items_language_id
47
- ON public.navigation_items (language_id);
48
-
49
- CREATE INDEX idx_navigation_items_page_id
50
- ON public.navigation_items (page_id);
51
-
52
- CREATE INDEX idx_navigation_items_parent_id
53
- ON public.navigation_items (parent_id);
54
-
55
- CREATE INDEX idx_logos_media_id
56
- ON public.logos (media_id);
57
-
58
- CREATE INDEX idx_page_revisions_page_id_version
59
- ON public.page_revisions (page_id, version);
60
-
61
- CREATE INDEX idx_page_revisions_author_id
62
- ON public.page_revisions (author_id);
63
-
64
- CREATE INDEX idx_post_revisions_post_id_version
65
- ON public.post_revisions (post_id, version);
66
-
67
- CREATE INDEX idx_post_revisions_author_id
68
- ON public.post_revisions (author_id);
69
-
70
- -- 00000000000022_setup_commerce_indexes.sql
71
- -- Consolidated commerce, shipping, and financial indexes.
72
-
73
- CREATE INDEX idx_products_slug
74
- ON public.products (slug);
75
-
76
- CREATE INDEX idx_products_translation_group_id
77
- ON public.products (translation_group_id);
78
-
79
- CREATE INDEX idx_products_prices_gin
80
- ON public.products
81
- USING gin (prices jsonb_path_ops);
82
-
83
- CREATE INDEX idx_product_media_product_id
84
- ON public.product_media (product_id);
85
-
86
- CREATE INDEX idx_product_media_media_id
87
- ON public.product_media (media_id);
88
-
89
- CREATE INDEX idx_order_items_order_id
90
- ON public.order_items (order_id);
91
-
92
- CREATE INDEX idx_order_items_variant_id
93
- ON public.order_items (variant_id);
94
-
95
- CREATE INDEX idx_order_items_product_id
96
- ON public.order_items (product_id);
97
-
98
- CREATE INDEX idx_orders_user_id
99
- ON public.orders (user_id);
100
-
101
- CREATE INDEX idx_orders_freemius_license_id
102
- ON public.orders (freemius_license_id)
103
- WHERE freemius_license_id IS NOT NULL;
104
-
105
- CREATE INDEX idx_orders_freemius_subscription_id
106
- ON public.orders (freemius_subscription_id)
107
- WHERE freemius_subscription_id IS NOT NULL;
108
-
109
- CREATE INDEX idx_orders_freemius_trial_id
110
- ON public.orders (freemius_trial_id)
111
- WHERE freemius_trial_id IS NOT NULL;
112
-
113
- CREATE INDEX idx_package_activations_package_id
114
- ON public.package_activations (package_id);
115
-
116
- CREATE INDEX idx_package_activations_license_key
117
- ON public.package_activations (license_key);
118
-
119
- CREATE INDEX idx_freemius_plans_product_id
120
- ON public.freemius_plans (product_id);
121
-
122
- CREATE INDEX idx_freemius_pricing_plan_id
123
- ON public.freemius_pricing (plan_id);
124
-
125
- CREATE INDEX idx_product_attribute_terms_attribute_id
126
- ON public.product_attribute_terms (attribute_id);
127
-
128
- CREATE INDEX idx_product_variants_product_id
129
- ON public.product_variants (product_id);
130
-
131
- CREATE INDEX idx_product_variants_main_media_id
132
- ON public.product_variants (main_media_id);
133
-
134
- CREATE INDEX idx_product_variants_prices_gin
135
- ON public.product_variants
136
- USING gin (prices jsonb_path_ops);
137
-
138
- CREATE INDEX idx_variant_attribute_mapping_attribute_term_id
139
- ON public.variant_attribute_mapping (attribute_term_id);
140
-
141
- CREATE INDEX idx_inventory_items_updated_at
142
- ON public.inventory_items (updated_at DESC);
143
-
144
- CREATE INDEX idx_shipping_zone_locations_zone_id
145
- ON public.shipping_zone_locations (zone_id);
146
-
147
- CREATE INDEX idx_shipping_zone_locations_country_state_postal
148
- ON public.shipping_zone_locations (country_code, state_code, postal_code);
149
-
150
- CREATE INDEX idx_shipping_zone_methods_name_translations
151
- ON public.shipping_zone_methods
152
- USING gin (name_translations);
153
-
154
- CREATE INDEX idx_shipping_zone_methods_zone_id
155
- ON public.shipping_zone_methods (zone_id);
156
-
157
- CREATE INDEX idx_tax_rates_country_state
158
- ON public.tax_rates (country_code, state_code);
@@ -1,155 +0,0 @@
1
- -- 00000000000008_seed_platform_defaults.sql
2
- -- Consolidated migration preserving original statement order within grouped sections.
3
-
4
- -- 00000000000023_seed_platform_defaults.sql
5
- -- Default settings, base languages, and the store currency seed.
6
-
7
- INSERT INTO public.site_settings (key, value)
8
- VALUES ('footer_copyright', '{"en": "© {year} Nextblock CMS. All rights reserved.", "fr": "© {year} Nextblock CMS. Tous droits réservés."}')
9
- ON CONFLICT (key) DO NOTHING;
10
-
11
- INSERT INTO public.site_settings (key, value)
12
- VALUES ('is_admin_created', 'false'::jsonb)
13
- ON CONFLICT (key) DO NOTHING;
14
-
15
- INSERT INTO public.site_settings (key, value)
16
- VALUES (
17
- 'enabled_payment_providers',
18
- '{"stripe": false, "freemius": false}'::jsonb
19
- )
20
- ON CONFLICT (key) DO NOTHING;
21
-
22
- INSERT INTO public.site_settings (key, value)
23
- VALUES ('site_title', '"NextBlock™ CMS"'::jsonb)
24
- ON CONFLICT (key) DO NOTHING;
25
-
26
- INSERT INTO public.site_settings (key, value)
27
- VALUES ('site_description', '"NextBlock™ is an open-source CMS on Next.js + Supabase — a visual block editor, blazing-fast multilingual pages, and built-in e-commerce."'::jsonb)
28
- ON CONFLICT (key) DO NOTHING;
29
-
30
- INSERT INTO public.site_settings (key, value)
31
- VALUES ('site_keywords', '"NextBlock, CMS, Next.js, Supabase, headless CMS, block editor, visual page builder, multilingual, e-commerce, open source"'::jsonb)
32
- ON CONFLICT (key) DO NOTHING;
33
-
34
- INSERT INTO public.site_settings (key, value)
35
- VALUES (
36
- 'ecommerce_inventory_settings',
37
- '{"track_quantities": true, "enable_taxes": false}'::jsonb
38
- )
39
- ON CONFLICT (key) DO UPDATE
40
- SET value = CASE
41
- WHEN jsonb_typeof(site_settings.value) = 'object' THEN
42
- jsonb_set(
43
- jsonb_set(
44
- site_settings.value,
45
- '{track_quantities}',
46
- COALESCE(
47
- site_settings.value->'track_quantities',
48
- site_settings.value->'trackQuantities',
49
- 'true'::jsonb
50
- ),
51
- true
52
- ),
53
- '{enable_taxes}',
54
- COALESCE(
55
- site_settings.value->'enable_taxes',
56
- site_settings.value->'enableTaxes',
57
- 'false'::jsonb
58
- ),
59
- true
60
- )
61
- ELSE
62
- jsonb_build_object(
63
- 'track_quantities',
64
- CASE
65
- WHEN lower(trim(BOTH '"' FROM site_settings.value::text)) IN ('false', 'f', '0', 'no', 'off') THEN false
66
- ELSE true
67
- END,
68
- 'enable_taxes',
69
- false
70
- )
71
- END;
72
-
73
- INSERT INTO public.site_settings (key, value)
74
- VALUES (
75
- 'invoice_settings',
76
- '{
77
- "business_name": "",
78
- "email": "",
79
- "phone": "",
80
- "address": {
81
- "line1": "",
82
- "line2": "",
83
- "city": "",
84
- "state": "",
85
- "postal_code": "",
86
- "country_code": "CA"
87
- },
88
- "tax_registrations": []
89
- }'::jsonb
90
- )
91
- ON CONFLICT (key) DO UPDATE
92
- SET value = CASE
93
- WHEN jsonb_typeof(site_settings.value) = 'object' THEN
94
- jsonb_build_object(
95
- 'business_name', COALESCE(site_settings.value->>'business_name', ''),
96
- 'email', COALESCE(site_settings.value->>'email', ''),
97
- 'phone', COALESCE(site_settings.value->>'phone', ''),
98
- 'address', CASE
99
- WHEN jsonb_typeof(site_settings.value->'address') = 'object' THEN
100
- jsonb_build_object(
101
- 'line1', COALESCE(site_settings.value->'address'->>'line1', ''),
102
- 'line2', COALESCE(site_settings.value->'address'->>'line2', ''),
103
- 'city', COALESCE(site_settings.value->'address'->>'city', ''),
104
- 'state', COALESCE(site_settings.value->'address'->>'state', ''),
105
- 'postal_code', COALESCE(site_settings.value->'address'->>'postal_code', ''),
106
- 'country_code', COALESCE(NULLIF(site_settings.value->'address'->>'country_code', ''), 'CA')
107
- )
108
- ELSE
109
- jsonb_build_object(
110
- 'line1', '',
111
- 'line2', '',
112
- 'city', '',
113
- 'state', '',
114
- 'postal_code', '',
115
- 'country_code', 'CA'
116
- )
117
- END,
118
- 'tax_registrations', CASE
119
- WHEN jsonb_typeof(site_settings.value->'tax_registrations') = 'array' THEN
120
- site_settings.value->'tax_registrations'
121
- ELSE
122
- '[]'::jsonb
123
- END
124
- )
125
- ELSE
126
- '{
127
- "business_name": "",
128
- "email": "",
129
- "phone": "",
130
- "address": {
131
- "line1": "",
132
- "line2": "",
133
- "city": "",
134
- "state": "",
135
- "postal_code": "",
136
- "country_code": "CA"
137
- },
138
- "tax_registrations": []
139
- }'::jsonb
140
- END;
141
-
142
- INSERT INTO public.languages (code, name, is_default, is_active)
143
- VALUES
144
- ('en', 'English', true, true),
145
- ('fr', 'Français', false, true);
146
-
147
- INSERT INTO public.currencies (code, symbol, exchange_rate, is_default, is_active)
148
- VALUES ('USD', '$', 1, true, true)
149
- ON CONFLICT (code) DO UPDATE
150
- SET
151
- symbol = EXCLUDED.symbol,
152
- exchange_rate = EXCLUDED.exchange_rate,
153
- is_default = EXCLUDED.is_default,
154
- is_active = EXCLUDED.is_active,
155
- updated_at = now();