rimecms 0.23.6 → 0.23.8

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,4 +1,3 @@
1
- import { OUTPUT_DIR } from '../core/dev/constants.js';
2
1
  import { drizzle, LibSQLDatabase } from 'drizzle-orm/libsql';
3
2
  import path from 'path';
4
3
  import createAreaFacade from './area.js';
@@ -20,7 +19,7 @@ export function adapterSqlite(database) {
20
19
  }
21
20
  const createAdapter = async (args) => {
22
21
  const { database, configCtx } = args;
23
- const schema = (await import(path.resolve(/* @vite-ignore */ process.cwd(), `src/lib/${OUTPUT_DIR}/schema.server.js`)));
22
+ const schema = (await import('$rime/schema'));
24
23
  const dbPath = path.join(process.cwd(), 'db', database);
25
24
  const db = drizzle('file:' + dbPath, { schema: schema.default });
26
25
  const tables = schema.tables;
@@ -112,6 +112,9 @@ const templateDeclareVirtualModule = () => [
112
112
  `declare module '$rime/config' {`,
113
113
  ...(IS_PACKAGE_DEV ? ['\t// eslint-disable-next-line no-restricted-imports'] : []),
114
114
  `\texport * from '${PACKAGE_NAME}/config/server';`,
115
+ `}`,
116
+ `declare module '$rime/schema' {`,
117
+ `\texport * from '$lib/+rime.generated/schema.server.js';`,
115
118
  `}`
116
119
  ].join('\n');
117
120
  /**
@@ -9,6 +9,7 @@ dotenv.config({ override: true });
9
9
  const dev = process.env.NODE_ENV === 'development';
10
10
  export function rime() {
11
11
  const VCoreId = '$rime/config';
12
+ const VSchemaId = '$rime/schema';
12
13
  const resolvedVModule = (name) => '\0' + name;
13
14
  return {
14
15
  name: 'virtual-rime',
@@ -85,6 +86,9 @@ export function rime() {
85
86
  if (id === VCoreId) {
86
87
  return resolvedVModule(id);
87
88
  }
89
+ if (id === VSchemaId) {
90
+ return resolvedVModule(id);
91
+ }
88
92
  return null;
89
93
  },
90
94
  load(id) {
@@ -93,6 +97,13 @@ export function rime() {
93
97
  const corePath = isServer ? 'rimecms/config/server' : 'rimecms/config/client';
94
98
  return `export * from '${corePath}';`;
95
99
  }
100
+ if (id === resolvedVModule(VSchemaId) && isServer) {
101
+ const schemaPath = path.resolve(process.cwd(), `src/lib/${OUTPUT_DIR}/schema.server.ts`);
102
+ if (existsSync(schemaPath)) {
103
+ const modulePath = schemaPath.replace('.ts', '.js');
104
+ return `export * from '${modulePath}'; export { default } from '${modulePath}';`;
105
+ }
106
+ }
96
107
  return null;
97
108
  }
98
109
  };
@@ -16,7 +16,7 @@ function analyzeRoute(pathname) {
16
16
  * Ensures panel is properly set up before allowing access
17
17
  */
18
18
  async function ensureFirstAuthSetup(rime) {
19
- if ((await rime.adapter.auth.hasAuthUser()) && !dev) {
19
+ if (!(await rime.adapter.auth.hasAuthUser()) && !dev) {
20
20
  throw new RimeError(RimeError.NOT_FOUND);
21
21
  }
22
22
  }
@@ -84,15 +84,8 @@ export declare const isCamelCase: (str: string) => boolean;
84
84
  */
85
85
  export declare const isValidSlug: (str: string) => boolean;
86
86
  /**
87
- * Sanitizes user input by removing dangerous HTML tags while preserving allowed formatting tags
88
- * default options :
89
- * ```ts
90
- * const options = {
91
- * allowedTags: ['strong', 'b', 'em', 'i', 'u', 'br', 'a'],
92
- * allowedAttributes: {
93
- * a: ['href', '_target']
94
- * }
95
- * }
96
- * ```
87
+ * Sanitizes user input by removing dangerous HTML tags while preserving allowed formatting tags,
88
+ * allowed tags : ['strong', 'b', 'em', 'i', 'u', 'br', 'a']
89
+ * allowedAttributes : ['href', '_target']
97
90
  */
98
91
  export declare const sanitize: (value?: string) => string;
@@ -1,5 +1,5 @@
1
1
  import camelCase from 'camelcase';
2
- import sanitizeHtml from 'sanitize-html';
2
+ import DOMPurify from 'isomorphic-dompurify';
3
3
  /**
4
4
  * Capitalizes the first letter of a string.
5
5
  *
@@ -145,25 +145,16 @@ export const isCamelCase = (str) => /^[a-z][a-zA-Z0-9]*$/.test(str);
145
145
  */
146
146
  export const isValidSlug = (str) => /^[a-zA-Z][a-zA-Z0-9_-]*$/.test(str);
147
147
  /**
148
- * Sanitizes user input by removing dangerous HTML tags while preserving allowed formatting tags
149
- * default options :
150
- * ```ts
151
- * const options = {
152
- * allowedTags: ['strong', 'b', 'em', 'i', 'u', 'br', 'a'],
153
- * allowedAttributes: {
154
- * a: ['href', '_target']
155
- * }
156
- * }
157
- * ```
148
+ * Sanitizes user input by removing dangerous HTML tags while preserving allowed formatting tags,
149
+ * allowed tags : ['strong', 'b', 'em', 'i', 'u', 'br', 'a']
150
+ * allowedAttributes : ['href', '_target']
158
151
  */
159
152
  export const sanitize = (value) => {
160
153
  if (!value)
161
154
  return value || '';
162
155
  const options = {
163
- allowedTags: ['strong', 'b', 'em', 'i', 'u', 'br', 'a'],
164
- allowedAttributes: {
165
- a: ['href', '_target']
166
- }
156
+ ALLOWED_TAGS: ['strong', 'b', 'em', 'i', 'u', 'br', 'a'],
157
+ ALLOWED_ATTR: ['href', '_target']
167
158
  };
168
- return sanitizeHtml(value, options);
159
+ return DOMPurify.sanitize(value, options);
169
160
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rimecms",
3
- "version": "0.23.6",
3
+ "version": "0.23.8",
4
4
  "homepage": "https://github.com/bienbiendev/rime",
5
5
  "scripts": {
6
6
  "dev": "vite dev",
@@ -206,6 +206,7 @@
206
206
  "dotenv": "^16.4.7",
207
207
  "drizzle-orm": "^0.44.2",
208
208
  "flat": "^6.0.1",
209
+ "isomorphic-dompurify": "^2.32.0",
209
210
  "js-cookie": "^3.0.5",
210
211
  "magic-string-ast": "^1.0.2",
211
212
  "nodemailer": "^6.10.0",