@wecode-team/cms-supabase-api 0.1.46 → 0.1.47
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.
- package/dist/index.esm.js +54 -91
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +54 -91
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/supabase-setup.sql +26 -1
package/package.json
CHANGED
package/supabase-setup.sql
CHANGED
|
@@ -125,6 +125,25 @@ $$;
|
|
|
125
125
|
-- Initialize the CMS models table
|
|
126
126
|
SELECT create_cms_models_table_if_not_exists ();
|
|
127
127
|
|
|
128
|
+
-- Global CMS config table.
|
|
129
|
+
-- Runtime code uses ordinary select/upsert operations on this table, so config
|
|
130
|
+
-- reads and writes do not need the high-privilege execute_sql RPC.
|
|
131
|
+
CREATE TABLE IF NOT EXISTS "_cms_configs" (
|
|
132
|
+
id SERIAL PRIMARY KEY,
|
|
133
|
+
session_id TEXT NOT NULL,
|
|
134
|
+
namespace TEXT NOT NULL,
|
|
135
|
+
values JSONB NOT NULL DEFAULT '{}'::jsonb,
|
|
136
|
+
created_at TIMESTAMPTZ DEFAULT NOW(),
|
|
137
|
+
updated_at TIMESTAMPTZ DEFAULT NOW(),
|
|
138
|
+
UNIQUE (session_id, namespace)
|
|
139
|
+
);
|
|
140
|
+
|
|
141
|
+
DROP TRIGGER IF EXISTS update_cms_configs_updated_at ON "_cms_configs";
|
|
142
|
+
CREATE TRIGGER update_cms_configs_updated_at
|
|
143
|
+
BEFORE UPDATE ON "_cms_configs"
|
|
144
|
+
FOR EACH ROW
|
|
145
|
+
EXECUTE FUNCTION update_updated_at_column();
|
|
146
|
+
|
|
128
147
|
-- Grant necessary permissions (adjust as needed for your security requirements)
|
|
129
148
|
-- Note: Be careful with these permissions in production
|
|
130
149
|
GRANT USAGE ON SCHEMA public TO anon, authenticated;
|
|
@@ -137,15 +156,21 @@ GRANT ALL ON ALL FUNCTIONS IN SCHEMA public TO anon, authenticated;
|
|
|
137
156
|
|
|
138
157
|
-- Create RLS policies for the CMS models table (optional, adjust as needed)
|
|
139
158
|
ALTER TABLE "_cms_models" ENABLE ROW LEVEL SECURITY;
|
|
159
|
+
ALTER TABLE "_cms_configs" ENABLE ROW LEVEL SECURITY;
|
|
140
160
|
|
|
141
161
|
-- Allow all operations for all users (development environment)
|
|
142
162
|
CREATE POLICY "Allow all operations" ON "_cms_models" FOR ALL USING (true);
|
|
163
|
+
DROP POLICY IF EXISTS "Allow all operations" ON "_cms_configs";
|
|
164
|
+
CREATE POLICY "Allow all operations" ON "_cms_configs" FOR ALL USING (true);
|
|
143
165
|
|
|
144
166
|
COMMENT ON
|
|
145
167
|
TABLE "_cms_models" IS 'CMS models configuration table for we0-cms-supabase-hono-api';
|
|
146
168
|
|
|
169
|
+
COMMENT ON
|
|
170
|
+
TABLE "_cms_configs" IS 'Session-scoped CMS global configuration values';
|
|
171
|
+
|
|
147
172
|
COMMENT ON FUNCTION execute_sql (text) IS 'Execute SQL queries for dynamic table management';
|
|
148
173
|
|
|
149
174
|
COMMENT ON FUNCTION check_table_exists (text) IS 'Check if a table exists in the public schema';
|
|
150
175
|
|
|
151
|
-
COMMENT ON FUNCTION get_table_structure (text) IS 'Get the structure of a table';
|
|
176
|
+
COMMENT ON FUNCTION get_table_structure (text) IS 'Get the structure of a table';
|