rimecms 0.25.10 → 0.25.11
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/adapter-sqlite/transform.js +27 -1
- package/dist/core/config/auth/better-auth.server.d.ts +1 -1
- package/dist/core/config/auth/better-auth.server.js +2 -1
- package/dist/core/config/server/build-config.server.d.ts +2 -2
- package/dist/core/rime.server.d.ts +2 -2
- package/dist/util/doc.d.ts +11 -0
- package/dist/util/doc.js +14 -0
- package/package.json +1 -1
|
@@ -4,7 +4,7 @@ import { getTableColumns } from 'drizzle-orm';
|
|
|
4
4
|
import { flatten, unflatten } from 'flat';
|
|
5
5
|
import { logger } from '../core/logger/index.server.js';
|
|
6
6
|
import { extractFieldName } from '../fields/tree/util.js';
|
|
7
|
-
import { omit } from '../util/object.js';
|
|
7
|
+
import { isObjectLiteral, omit } from '../util/object.js';
|
|
8
8
|
import { getBlocksTableNames, getTreeTableNames, makeBlockTableSlug, makeTreeTableSlug } from './generate-schema/util.js';
|
|
9
9
|
import { transformDatabaseColumnsToPaths } from './util.js';
|
|
10
10
|
/**
|
|
@@ -165,6 +165,15 @@ export const transformerFacade = (args) => {
|
|
|
165
165
|
}
|
|
166
166
|
/** Assign relation */
|
|
167
167
|
if (!relation.locale || relation.locale === locale) {
|
|
168
|
+
const parentPath = relationPath.split('.').slice(0, -1).join('.');
|
|
169
|
+
// If parent path ends with .[digits], it means the relation is inside a blocks/tree array,
|
|
170
|
+
// then check if the parent path exists in the flatDoc.
|
|
171
|
+
if (/.*\.[\d]+$/.test(parentPath)) {
|
|
172
|
+
if (!flatDoc[parentPath]) {
|
|
173
|
+
logger.warn(`Orphean ${config.slug} relation at ${relationPath} with id ${relation.id} because parent path ${parentPath} doesn't exist in the document`);
|
|
174
|
+
continue;
|
|
175
|
+
}
|
|
176
|
+
}
|
|
168
177
|
flatDoc[relationPath] = [...(flatDoc[relationPath] || []), relationOutput];
|
|
169
178
|
}
|
|
170
179
|
}
|
|
@@ -177,6 +186,23 @@ export const transformerFacade = (args) => {
|
|
|
177
186
|
if (tableNameRelationFields in output) {
|
|
178
187
|
keysToDelete.push(tableNameRelationFields);
|
|
179
188
|
}
|
|
189
|
+
// Filter out arrays that contains empty elements
|
|
190
|
+
function cleanEmptyElementsInArrays(obj) {
|
|
191
|
+
if (Array.isArray(obj)) {
|
|
192
|
+
return obj
|
|
193
|
+
.map((item) => cleanEmptyElementsInArrays(item))
|
|
194
|
+
.filter((item) => item !== null && item !== undefined);
|
|
195
|
+
}
|
|
196
|
+
else if (isObjectLiteral(obj)) {
|
|
197
|
+
const cleanedObj = {};
|
|
198
|
+
for (const key in obj) {
|
|
199
|
+
cleanedObj[key] = cleanEmptyElementsInArrays(obj[key]);
|
|
200
|
+
}
|
|
201
|
+
return cleanedObj;
|
|
202
|
+
}
|
|
203
|
+
return obj;
|
|
204
|
+
}
|
|
205
|
+
output = cleanEmptyElementsInArrays(output);
|
|
180
206
|
if (!isPanel || !event.locals.user) {
|
|
181
207
|
keysToDelete.push('editedBy');
|
|
182
208
|
}
|
|
@@ -5,7 +5,7 @@ export declare function getBaseAuthConfig<const C extends Config>(ctx: {
|
|
|
5
5
|
mailer: MailerActions | undefined;
|
|
6
6
|
config: ConfigContext<C>;
|
|
7
7
|
}): {
|
|
8
|
-
readonly baseURL:
|
|
8
|
+
readonly baseURL: any;
|
|
9
9
|
readonly plugins: ({
|
|
10
10
|
id: "api-key";
|
|
11
11
|
$ERROR_CODES: {
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { dev } from '$app/environment';
|
|
2
|
+
import { env } from '$env/dynamic/public';
|
|
2
3
|
import { admin as adminPlugin, apiKey } from 'better-auth/plugins';
|
|
3
4
|
import { betterAuthAfterHook, betterAuthBeforeHook } from './better-auth-hooks.js';
|
|
4
5
|
import { accessControl, admin, staff, user } from './better-auth-permissions.js';
|
|
5
6
|
export function getBaseAuthConfig(ctx) {
|
|
6
7
|
const betterAuthOptions = {
|
|
7
|
-
baseURL:
|
|
8
|
+
baseURL: env.PUBLIC_RIME_URL,
|
|
8
9
|
plugins: configurePlugins(ctx.config.raw),
|
|
9
10
|
rateLimit: {
|
|
10
11
|
enabled: !dev,
|
|
@@ -1909,7 +1909,7 @@ export declare const buildConfig: <const C extends Config>(config: C) => Promise
|
|
|
1909
1909
|
plugins: any;
|
|
1910
1910
|
} ? C["$auth"]["plugins"] : [])[number])[];
|
|
1911
1911
|
database: (options: import("better-auth/types").BetterAuthOptions) => import("better-auth/types").DBAdapter<import("better-auth/types").BetterAuthOptions>;
|
|
1912
|
-
baseURL:
|
|
1912
|
+
baseURL: any;
|
|
1913
1913
|
rateLimit: {
|
|
1914
1914
|
readonly enabled: boolean;
|
|
1915
1915
|
readonly window: 10;
|
|
@@ -3891,7 +3891,7 @@ export declare const buildConfig: <const C extends Config>(config: C) => Promise
|
|
|
3891
3891
|
plugins: any;
|
|
3892
3892
|
} ? C["$auth"]["plugins"] : [])[number])[];
|
|
3893
3893
|
database: (options: import("better-auth/types").BetterAuthOptions) => import("better-auth/types").DBAdapter<import("better-auth/types").BetterAuthOptions>;
|
|
3894
|
-
baseURL:
|
|
3894
|
+
baseURL: any;
|
|
3895
3895
|
rateLimit: {
|
|
3896
3896
|
readonly enabled: boolean;
|
|
3897
3897
|
readonly window: 10;
|
|
@@ -1921,7 +1921,7 @@ export declare function createRime<const C extends Config>(config: BuildConfig<C
|
|
|
1921
1921
|
plugins: any;
|
|
1922
1922
|
} ? C["$auth"]["plugins"] : [])[number])[];
|
|
1923
1923
|
database: (options: import("better-auth/*").BetterAuthOptions) => import("better-auth/*").DBAdapter<import("better-auth/*").BetterAuthOptions>;
|
|
1924
|
-
baseURL:
|
|
1924
|
+
baseURL: any;
|
|
1925
1925
|
rateLimit: {
|
|
1926
1926
|
readonly enabled: boolean;
|
|
1927
1927
|
readonly window: 10;
|
|
@@ -3927,7 +3927,7 @@ export declare function createRime<const C extends Config>(config: BuildConfig<C
|
|
|
3927
3927
|
plugins: any;
|
|
3928
3928
|
} ? C["$auth"]["plugins"] : [])[number])[];
|
|
3929
3929
|
database: (options: import("better-auth/*").BetterAuthOptions) => import("better-auth/*").DBAdapter<import("better-auth/*").BetterAuthOptions>;
|
|
3930
|
-
baseURL:
|
|
3930
|
+
baseURL: any;
|
|
3931
3931
|
rateLimit: {
|
|
3932
3932
|
readonly enabled: boolean;
|
|
3933
3933
|
readonly window: 10;
|
package/dist/util/doc.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { GenericDoc } from '../core/types/doc.js';
|
|
2
2
|
import type { BuiltArea, BuiltCollection } from '../types.js';
|
|
3
|
+
import type { Dic } from './types.js';
|
|
3
4
|
import type { RequestEvent } from '@sveltejs/kit';
|
|
4
5
|
/**
|
|
5
6
|
* Creates a blank document based on a collection or area configuration.
|
|
@@ -37,3 +38,13 @@ export declare const toNestedStructure: (documents: GenericDoc[]) => GenericDoc[
|
|
|
37
38
|
* // return foo.bar.0.baz
|
|
38
39
|
*/
|
|
39
40
|
export declare const normalizeFieldPath: (path: string) => string;
|
|
41
|
+
/**
|
|
42
|
+
* Ensure path exists, meaning the path hold anything else than undefined.
|
|
43
|
+
*
|
|
44
|
+
* @example
|
|
45
|
+
* const obj = { foo: { baz: null }, bar: 1 };
|
|
46
|
+
* ensurePathExists('foo.bar', obj); // false
|
|
47
|
+
* ensurePathExists('foo.baz', obj); // true
|
|
48
|
+
* ensurePathExists('bar', obj); // true
|
|
49
|
+
*/
|
|
50
|
+
export declare const ensurePathExists: (path: string, obj: Dic) => boolean;
|
package/dist/util/doc.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { isUploadConfig } from '../core/collections/upload/util/config.js';
|
|
2
2
|
import { TabsBuilder } from '../fields/tabs/index.js';
|
|
3
|
+
import { getValueAtPath } from './object.js';
|
|
3
4
|
import { snapshot } from './state.js';
|
|
4
5
|
/**
|
|
5
6
|
* Creates a blank document based on a collection or area configuration.
|
|
@@ -126,3 +127,16 @@ export const normalizeFieldPath = (path) => {
|
|
|
126
127
|
const regExpBlockType = /:[a-zA-Z0-9]+/g;
|
|
127
128
|
return path.replace(regExpBlockType, '');
|
|
128
129
|
};
|
|
130
|
+
/**
|
|
131
|
+
* Ensure path exists, meaning the path hold anything else than undefined.
|
|
132
|
+
*
|
|
133
|
+
* @example
|
|
134
|
+
* const obj = { foo: { baz: null }, bar: 1 };
|
|
135
|
+
* ensurePathExists('foo.bar', obj); // false
|
|
136
|
+
* ensurePathExists('foo.baz', obj); // true
|
|
137
|
+
* ensurePathExists('bar', obj); // true
|
|
138
|
+
*/
|
|
139
|
+
export const ensurePathExists = (path, obj) => {
|
|
140
|
+
const value = getValueAtPath(path, obj);
|
|
141
|
+
return value !== undefined;
|
|
142
|
+
};
|