@wecode-team/cms-supabase-api 0.1.47 → 0.1.49

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.
@@ -46,7 +46,7 @@ export interface SchemaField {
46
46
  name: string;
47
47
  /**
48
48
  * 字段类型
49
- * - 基础类型: string, text, integer, float, boolean, date, datetime, json, jsonb, email
49
+ * - 基础类型: string, text, richText, integer, float, boolean, date, datetime, json, jsonb, email
50
50
  * - 关系类型: relation (需要配置 relation 属性)
51
51
  */
52
52
  type: string;
@@ -116,6 +116,7 @@ export interface SupabaseFilter {
116
116
  export interface FieldTypeMapping {
117
117
  string: "text";
118
118
  text: "text";
119
+ richText: "text";
119
120
  integer: "int4";
120
121
  float: "float8";
121
122
  boolean: "bool";
@@ -13,4 +13,9 @@ export declare function getSessionAdminRow(supabase: SupabaseClient, sessionId:
13
13
  user_id: string;
14
14
  email?: string | null;
15
15
  } | null>;
16
+ export declare function getSessionAdminRowByEmail(supabase: SupabaseClient, sessionId: string, email: string): Promise<{
17
+ session_id: string;
18
+ user_id: string;
19
+ email?: string | null;
20
+ } | null>;
16
21
  export declare function isUserSessionAdmin(supabase: SupabaseClient, sessionId: string, userId: string): Promise<boolean>;
@@ -0,0 +1,13 @@
1
+ import { Context } from "hono";
2
+ type CmsCrudAction = "create" | "read" | "update" | "delete";
3
+ type CmsCrudAlertOptions = {
4
+ action: CmsCrudAction;
5
+ target: "data" | "model";
6
+ tableName?: string;
7
+ modelId?: number | string;
8
+ recordId?: number | string;
9
+ error: unknown;
10
+ };
11
+ export declare function notifyCmsCrudErrorToFeishu(c: Context, options: CmsCrudAlertOptions): Promise<void>;
12
+ export declare function reportCmsCrudErrorToFeishu(c: Context, options: CmsCrudAlertOptions): void;
13
+ export {};
@@ -5,5 +5,4 @@ export declare function createDynamicDataRoute(app: Hono): Hono<import("hono/typ
5
5
  export declare function createDynamicAuthRoute(app: Hono): Hono<import("hono/types").BlankEnv, import("hono/types").BlankSchema, "/">;
6
6
  export declare function createAuthRoute(app: Hono, tableName: string): Hono<import("hono/types").BlankEnv, import("hono/types").BlankSchema, "/">;
7
7
  export declare function createOssUploadRoute(app: Hono): Hono<import("hono/types").BlankEnv, import("hono/types").BlankSchema, "/">;
8
- export declare function createConfigRoute(app: Hono): Hono<import("hono/types").BlankEnv, import("hono/types").BlankSchema, "/">;
9
8
  export declare function createCmsRoutes(app: Hono): 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.47",
3
+ "version": "0.1.49",
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",
@@ -50,6 +50,7 @@
50
50
  },
51
51
  "dependencies": {
52
52
  "@babel/runtime": "^7.22.5",
53
+ "@wecode-team/email-verify": "^0.0.2",
53
54
  "@wecode-team/oss": "^0.0.1",
54
55
  "bcryptjs": "^2.4.3",
55
56
  "jsonwebtoken": "^9.0.2"
@@ -125,25 +125,6 @@ $$;
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
-
147
128
  -- Grant necessary permissions (adjust as needed for your security requirements)
148
129
  -- Note: Be careful with these permissions in production
149
130
  GRANT USAGE ON SCHEMA public TO anon, authenticated;
@@ -156,21 +137,15 @@ GRANT ALL ON ALL FUNCTIONS IN SCHEMA public TO anon, authenticated;
156
137
 
157
138
  -- Create RLS policies for the CMS models table (optional, adjust as needed)
158
139
  ALTER TABLE "_cms_models" ENABLE ROW LEVEL SECURITY;
159
- ALTER TABLE "_cms_configs" ENABLE ROW LEVEL SECURITY;
160
140
 
161
141
  -- Allow all operations for all users (development environment)
162
142
  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);
165
143
 
166
144
  COMMENT ON
167
145
  TABLE "_cms_models" IS 'CMS models configuration table for we0-cms-supabase-hono-api';
168
146
 
169
- COMMENT ON
170
- TABLE "_cms_configs" IS 'Session-scoped CMS global configuration values';
171
-
172
147
  COMMENT ON FUNCTION execute_sql (text) IS 'Execute SQL queries for dynamic table management';
173
148
 
174
149
  COMMENT ON FUNCTION check_table_exists (text) IS 'Check if a table exists in the public schema';
175
150
 
176
- COMMENT ON FUNCTION get_table_structure (text) IS 'Get the structure of a table';
151
+ COMMENT ON FUNCTION get_table_structure (text) IS 'Get the structure of a table';
@@ -1,11 +0,0 @@
1
- import { Context } from "hono";
2
- /**
3
- * 聚合查询 API
4
- * GET /data/:tableName/aggregate
5
- */
6
- export declare function getAggregateData(c: Context): Promise<Response>;
7
- /**
8
- * 时间序列查询 API
9
- * GET /data/:tableName/timeseries
10
- */
11
- export declare function getTimeSeriesData(c: Context): Promise<Response>;
@@ -1,23 +0,0 @@
1
- import { Context } from "hono";
2
- export declare function getConfig(c: Context): Promise<(Response & import("hono").TypedResponse<{
3
- success: boolean;
4
- message?: string | undefined;
5
- data?: any;
6
- error?: string | undefined;
7
- }, 200, "json">) | (Response & import("hono").TypedResponse<{
8
- success: boolean;
9
- message?: string | undefined;
10
- data?: any;
11
- error?: string | undefined;
12
- }, 500, "json">)>;
13
- export declare function updateConfig(c: Context): Promise<(Response & import("hono").TypedResponse<{
14
- success: boolean;
15
- message?: string | undefined;
16
- data?: any;
17
- error?: string | undefined;
18
- }, 200, "json">) | (Response & import("hono").TypedResponse<{
19
- success: boolean;
20
- message?: string | undefined;
21
- data?: any;
22
- error?: string | undefined;
23
- }, 500, "json">)>;