@wecode-team/cms-supabase-api 0.1.50 → 0.1.52-beta.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.
@@ -1,8 +1,12 @@
1
1
  import { Hono } from "hono";
2
- export declare function createModelRoute(app: Hono): Hono<import("hono/types").BlankEnv, import("hono/types").BlankSchema, "/">;
3
- export declare function createDataRoute(app: Hono, tableName: string): Hono<import("hono/types").BlankEnv, import("hono/types").BlankSchema, "/">;
4
- export declare function createDynamicDataRoute(app: Hono): Hono<import("hono/types").BlankEnv, import("hono/types").BlankSchema, "/">;
2
+ export type CmsRouteOptions = {
3
+ skipAuth?: boolean;
4
+ };
5
+ export declare function createModelRoute(app: Hono, options?: CmsRouteOptions): Hono<import("hono/types").BlankEnv, import("hono/types").BlankSchema, "/">;
6
+ export declare function createDataRoute(app: Hono, tableName: string, options?: CmsRouteOptions): Hono<import("hono/types").BlankEnv, import("hono/types").BlankSchema, "/">;
7
+ export declare function createDynamicDataRoute(app: Hono, options?: CmsRouteOptions): Hono<import("hono/types").BlankEnv, import("hono/types").BlankSchema, "/">;
5
8
  export declare function createDynamicAuthRoute(app: Hono): Hono<import("hono/types").BlankEnv, import("hono/types").BlankSchema, "/">;
6
9
  export declare function createAuthRoute(app: Hono, tableName: string): Hono<import("hono/types").BlankEnv, import("hono/types").BlankSchema, "/">;
7
- export declare function createOssUploadRoute(app: Hono): Hono<import("hono/types").BlankEnv, import("hono/types").BlankSchema, "/">;
8
- export declare function createCmsRoutes(app: Hono): Hono<import("hono/types").BlankEnv, import("hono/types").BlankSchema, "/">;
10
+ export declare function createOssUploadRoute(app: Hono, options?: CmsRouteOptions): Hono<import("hono/types").BlankEnv, import("hono/types").BlankSchema, "/">;
11
+ export declare function createConfigRoute(app: Hono, options?: CmsRouteOptions): Hono<import("hono/types").BlankEnv, import("hono/types").BlankSchema, "/">;
12
+ export declare function createCmsRoutes(app: Hono, options?: CmsRouteOptions): Hono<import("hono/types").BlankEnv, import("hono/types").BlankSchema, "/">;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wecode-team/cms-supabase-api",
3
- "version": "0.1.50",
3
+ "version": "0.1.52-beta.0",
4
4
  "description": "A CMS API package using Hono framework with Supabase and dynamic table management",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.esm.js",
@@ -24,6 +24,7 @@
24
24
  "dev": "tsx server.ts",
25
25
  "start": "node --loader tsx server.ts",
26
26
  "dev:all": "./start-dev.sh",
27
+ "publish:beta": "npm run build && npm publish --registry https://registry.npmjs.org/ --access public --tag beta --ignore-scripts",
27
28
  "publish:public": "npm run build && npm publish --registry https://registry.npmjs.org/ --access public --ignore-scripts",
28
29
  "publish:private": "npm run build && npm publish --registry https://packages.aliyun.com/691ae90ae6c3e0425dbdc56f/npm/npm-registry/ --access public --ignore-scripts",
29
30
  "publish:all": "npm run build && npm publish --registry https://registry.npmjs.org/ --access public --ignore-scripts && npm publish --registry https://packages.aliyun.com/691ae90ae6c3e0425dbdc56f/npm/npm-registry/ --access public --ignore-scripts",
@@ -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,13 +156,19 @@ 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';