rimecms 0.28.9 → 0.29.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.
- package/README.md +3 -3
- package/dist/adapter-sqlite/generate-schema/{util.d.ts → util.server.d.ts} +2 -2
- package/dist/adapter-sqlite/generate-schema/{util.js → util.server.js} +2 -2
- package/dist/adapter-sqlite/generate-schema/write.server.js +1 -1
- package/dist/adapter-sqlite/index.server.d.ts +2 -1
- package/dist/adapter-sqlite/index.server.js +2 -0
- package/dist/adapter-sqlite/transform.server.js +1 -1
- package/dist/adapter-sqlite/with.server.js +1 -1
- package/dist/core/areas/{api → rest}/get.server.d.ts +4 -2
- package/dist/core/areas/rest/get.server.js +45 -0
- package/dist/core/areas/rest/index.server.d.ts +6 -0
- package/dist/core/areas/rest/index.server.js +3 -0
- package/dist/core/areas/{api → rest}/update.server.d.ts +4 -2
- package/dist/core/areas/rest/update.server.js +43 -0
- package/dist/core/collections/auth/hooks/before-upsert/augment-fields-password.server.d.ts +1 -1
- package/dist/core/collections/config/augment-panel.d.ts +1 -1
- package/dist/core/collections/local-api.server.js +2 -1
- package/dist/core/collections/operations/duplicate.js +2 -2
- package/dist/core/collections/{api → rest}/create.server.d.ts +4 -2
- package/dist/core/collections/rest/create.server.js +37 -0
- package/dist/core/collections/{api → rest}/delete.server.d.ts +4 -2
- package/dist/core/collections/rest/delete.server.js +37 -0
- package/dist/core/collections/{api → rest}/deleteById.server.d.ts +4 -2
- package/dist/core/collections/rest/deleteById.server.js +21 -0
- package/dist/core/collections/{api → rest}/duplicate.server.d.ts +1 -1
- package/dist/core/collections/rest/duplicate.server.js +16 -0
- package/dist/core/collections/{api → rest}/get.server.d.ts +4 -2
- package/dist/core/collections/rest/get.server.js +50 -0
- package/dist/core/collections/{api → rest}/getById.server.d.ts +4 -2
- package/dist/core/collections/rest/getById.server.js +35 -0
- package/dist/core/collections/rest/index.server.d.ts +16 -0
- package/dist/core/collections/rest/index.server.js +16 -0
- package/dist/core/collections/{api → rest}/updateById.server.d.ts +4 -2
- package/dist/core/collections/rest/updateById.server.js +44 -0
- package/dist/core/collections/upload/hooks/convert-base64.server.d.ts +1 -1
- package/dist/core/collections/upload/hooks/extract-path.server.d.ts +1 -1
- package/dist/core/collections/upload/hooks/handle-path-creation.server.d.ts +1 -1
- package/dist/core/collections/upload/hooks/process-file-upload.server.d.ts +1 -1
- package/dist/core/config/auth/better-auth.server.d.ts +2 -2
- package/dist/core/config/client/augment-directories.js +1 -1
- package/dist/core/config/config-context.server.d.ts +3 -3
- package/dist/core/config/server/augment-directories.server.js +1 -1
- package/dist/core/config/server/augment-panel-access.server.d.ts +1 -1
- package/dist/core/config/server/build-config.server.d.ts +11 -11
- package/dist/core/config/server/validate.server.js +3 -3
- package/dist/core/config/shared/find-thumbnail.js +1 -1
- package/dist/core/constant.d.ts +1 -1
- package/dist/core/constant.js +1 -1
- package/dist/core/dev/cli/build/index.d.ts +1 -0
- package/dist/core/dev/cli/build/index.js +39 -10
- package/dist/core/dev/cli/build/templates.d.ts +1 -0
- package/dist/core/dev/cli/build/templates.js +24 -0
- package/dist/core/dev/cli/clear/index.server.js +1 -1
- package/dist/core/dev/cli/index.js +20 -0
- package/dist/core/dev/cli/init/index.server.js +3 -3
- package/dist/core/dev/cli/init/templates.d.ts +1 -1
- package/dist/core/dev/cli/init/templates.js +2 -2
- package/dist/core/dev/cli/util/log.server.d.ts +1 -0
- package/dist/core/dev/cli/util/log.server.js +4 -0
- package/dist/core/dev/cli/util/package-manager.server.d.ts +9 -0
- package/dist/core/dev/cli/{init/package-manager-util.server.js → util/package-manager.server.js} +15 -0
- package/dist/core/dev/cli/util/package.server.d.ts +9 -0
- package/dist/core/dev/cli/{init/get-package-info.server.js → util/package.server.js} +10 -0
- package/dist/core/dev/generate/routes/common.server.d.ts +10 -1
- package/dist/core/dev/generate/routes/common.server.js +248 -29
- package/dist/core/dev/generate/routes/index.server.d.ts +7 -1
- package/dist/core/dev/generate/routes/index.server.js +16 -55
- package/dist/core/dev/generate/routes/util.server.d.ts +6 -16
- package/dist/core/dev/generate/routes/util.server.js +8 -21
- package/dist/core/dev/generate/types/index.server.js +5 -3
- package/dist/core/dev/vite/index.server.js +1 -1
- package/dist/core/errors/handler.server.d.ts +22 -1
- package/dist/core/errors/handler.server.js +25 -2
- package/dist/core/errors/index.d.ts +0 -1
- package/dist/core/errors/index.js +0 -1
- package/dist/core/fields/util.d.ts +1 -1
- package/dist/core/handlers/routes.server.d.ts +70 -1
- package/dist/core/handlers/routes.server.js +55 -1
- package/dist/core/operations/hooks/before-upsert/data-config-map.server.d.ts +1 -1
- package/dist/core/operations/hooks/before-upsert/handle-new-version.server.d.ts +1 -1
- package/dist/core/operations/hooks/before-upsert/original-config-map.server.d.ts +1 -1
- package/dist/core/operations/hooks/before-upsert/set-default-values.server.d.ts +1 -1
- package/dist/core/operations/hooks/before-upsert/validate-fields.server.d.ts +1 -1
- package/dist/core/plugins/api-init/index.server.js +10 -5
- package/dist/core/plugins/cache/cache.server.js +1 -1
- package/dist/core/rime.server.d.ts +10 -10
- package/dist/core/rime.server.js +5 -1
- package/dist/fields/checkbox/index.server.js +1 -1
- package/dist/fields/combobox/index.server.js +1 -1
- package/dist/fields/date/index.server.js +1 -1
- package/dist/fields/email/index.js +1 -1
- package/dist/fields/email/index.server.js +1 -1
- package/dist/fields/link/component/RessourceInput.svelte +1 -1
- package/dist/fields/link/index.d.ts +1 -1
- package/dist/fields/link/index.js +1 -1
- package/dist/fields/link/index.server.js +1 -1
- package/dist/fields/number/index.server.js +1 -1
- package/dist/fields/radio/index.server.js +1 -1
- package/dist/fields/relation/client.d.ts +1 -1
- package/dist/fields/relation/client.js +1 -1
- package/dist/fields/relation/component/Cell.svelte +1 -1
- package/dist/fields/relation/component/Relation.svelte +1 -1
- package/dist/fields/relation/component/upload/Browse.svelte +1 -1
- package/dist/fields/relation/index.d.ts +1 -1
- package/dist/fields/relation/index.js +2 -2
- package/dist/fields/relation/index.server.js +1 -1
- package/dist/fields/rich-text/core/features/fields/extension.d.ts +2 -2
- package/dist/fields/rich-text/core/features/link/component/link-selector.svelte +1 -1
- package/dist/fields/rich-text/core/features/resource/resource-extension.d.ts +1 -1
- package/dist/fields/rich-text/core/features/resource/resource.svelte +1 -1
- package/dist/fields/rich-text/core/features/upload/upload-extension.d.ts +1 -1
- package/dist/fields/rich-text/core/features/upload/upload.svelte +1 -1
- package/dist/fields/rich-text/index.js +4 -2
- package/dist/fields/rich-text/index.server.js +1 -1
- package/dist/fields/select/index.server.js +1 -1
- package/dist/fields/slug/index.server.js +1 -1
- package/dist/fields/text/index.server.js +1 -1
- package/dist/fields/textarea/index.server.js +1 -1
- package/dist/fields/time/index.server.js +1 -1
- package/dist/fields/toggle/index.server.js +1 -1
- package/dist/index.d.ts +8 -3
- package/dist/index.js +7 -3
- package/dist/panel/components/sections/collection/folder/FolderWithActions.svelte +1 -1
- package/dist/panel/components/sections/document/ButtonStatus.svelte +1 -1
- package/dist/panel/components/sections/document/CurrentlyEdited.svelte +1 -1
- package/dist/panel/components/sections/document/Settings.svelte +1 -1
- package/dist/panel/context/collection.svelte.js +1 -1
- package/dist/panel/context/documentForm.svelte.js +1 -2
- package/dist/panel/context/form.svelte.d.ts +2 -0
- package/dist/panel/context/form.svelte.js +8 -2
- package/dist/panel/context/live.svelte.js +1 -1
- package/dist/panel/index.d.ts +9 -1
- package/dist/panel/index.js +7 -1
- package/dist/panel/pages/area/actions.server.d.ts +2 -21
- package/dist/panel/pages/area/actions.server.js +28 -27
- package/dist/panel/pages/area/load.server.d.ts +2 -17
- package/dist/panel/pages/area/load.server.js +37 -46
- package/dist/panel/pages/auth/sign-in/SignIn.svelte +7 -1
- package/dist/panel/pages/collection/load.server.d.ts +6 -6
- package/dist/panel/pages/collection/load.server.js +70 -72
- package/dist/panel/pages/collection-document/actions.server.d.ts +1 -1
- package/dist/panel/pages/collection-document/actions.server.js +78 -70
- package/dist/panel/pages/collection-document/load.server.d.ts +5 -20
- package/dist/panel/pages/collection-document/load.server.js +80 -82
- package/dist/server.d.ts +7 -0
- package/dist/server.js +7 -0
- package/dist/types.d.ts +1 -0
- package/dist/util/index.d.ts +9 -1
- package/dist/util/index.js +12 -1
- package/package.json +6 -49
- package/dist/core/api/index.d.ts +0 -7
- package/dist/core/api/index.js +0 -10
- package/dist/core/api/index.server.d.ts +0 -3
- package/dist/core/api/index.server.js +0 -3
- package/dist/core/areas/api/get.server.js +0 -36
- package/dist/core/areas/api/index.server.d.ts +0 -7
- package/dist/core/areas/api/index.server.js +0 -4
- package/dist/core/areas/api/update.server.js +0 -33
- package/dist/core/collections/api/create.server.js +0 -29
- package/dist/core/collections/api/delete.server.js +0 -32
- package/dist/core/collections/api/deleteById.server.js +0 -16
- package/dist/core/collections/api/duplicate.server.js +0 -18
- package/dist/core/collections/api/get.server.js +0 -45
- package/dist/core/collections/api/getById.server.js +0 -30
- package/dist/core/collections/api/index.server.d.ts +0 -17
- package/dist/core/collections/api/index.server.js +0 -9
- package/dist/core/collections/api/updateById.server.js +0 -38
- package/dist/core/dev/cli/init/get-package-info.server.d.ts +0 -1
- package/dist/core/dev/cli/init/package-manager-util.server.d.ts +0 -3
- package/dist/core/dev/generate/routes/area.server.d.ts +0 -7
- package/dist/core/dev/generate/routes/area.server.js +0 -69
- package/dist/core/dev/generate/routes/collection.server.d.ts +0 -14
- package/dist/core/dev/generate/routes/collection.server.js +0 -129
- package/dist/live.d.ts +0 -4
- package/dist/live.js +0 -4
- package/dist/panel/index.server.d.ts +0 -4
- package/dist/panel/index.server.js +0 -4
- package/dist/panel/pages/auth/index.d.ts +0 -4
- package/dist/panel/pages/auth/index.js +0 -4
- package/dist/panel/pages/auth/index.server.d.ts +0 -18
- package/dist/panel/pages/auth/index.server.js +0 -12
- package/dist/panel/pages/index.actions.server.d.ts +0 -13
- package/dist/panel/pages/index.actions.server.js +0 -10
- package/dist/panel/pages/index.load.server.d.ts +0 -23
- package/dist/panel/pages/index.load.server.js +0 -16
- package/dist/panel/ui.d.ts +0 -4
- package/dist/panel/ui.js +0 -5
- /package/dist/core/dev/cli/{util.server.d.ts → util/prompt.server.d.ts} +0 -0
- /package/dist/core/dev/cli/{util.server.js → util/prompt.server.js} +0 -0
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { PARAMS } from '../../constant.js';
|
|
2
|
+
import { ERROR_CONTEXT, handleError } from '../../errors/handler.server.js';
|
|
3
|
+
import { RimeError } from '../../errors/index.js';
|
|
4
|
+
import { extractData } from '../../operations/extract-data.server.js';
|
|
5
|
+
import { trycatch } from '../../../util/function.js';
|
|
6
|
+
import { json } from '@sveltejs/kit';
|
|
7
|
+
/**
|
|
8
|
+
* PATCH handler for the collection API endpoint to update a document by its ID.
|
|
9
|
+
*/
|
|
10
|
+
export async function restUpdateById(event) {
|
|
11
|
+
//
|
|
12
|
+
const { rime } = event.locals;
|
|
13
|
+
const slug = event.params.slug;
|
|
14
|
+
const id = event.params.id;
|
|
15
|
+
// Check if the slug corresponds to a valid collection and if the ID is provided
|
|
16
|
+
if (!rime.config.isCollection(slug) || !id) {
|
|
17
|
+
return handleError(new RimeError(RimeError.NOT_FOUND), { context: ERROR_CONTEXT.API });
|
|
18
|
+
}
|
|
19
|
+
// Extract query parameters for versioning and draft status
|
|
20
|
+
const versionId = event.url.searchParams.get(PARAMS.VERSION_ID) || undefined;
|
|
21
|
+
const draft = event.url.searchParams.get(PARAMS.DRAFT)
|
|
22
|
+
? event.url.searchParams.get(PARAMS.DRAFT) === 'true'
|
|
23
|
+
: undefined;
|
|
24
|
+
// Extract data from the request body
|
|
25
|
+
const [extractError, data] = await trycatch(() => extractData(event.request));
|
|
26
|
+
if (extractError) {
|
|
27
|
+
return handleError(extractError, { context: ERROR_CONTEXT.API });
|
|
28
|
+
}
|
|
29
|
+
// Set the locale if provided in the data
|
|
30
|
+
if (data.locale) {
|
|
31
|
+
rime.setLocale(data.locale);
|
|
32
|
+
}
|
|
33
|
+
const [error, document] = await trycatch(() => rime.collection(slug).updateById({
|
|
34
|
+
id,
|
|
35
|
+
data,
|
|
36
|
+
locale: rime.getLocale(),
|
|
37
|
+
versionId,
|
|
38
|
+
draft
|
|
39
|
+
}));
|
|
40
|
+
if (error) {
|
|
41
|
+
return handleError(error, { context: ERROR_CONTEXT.API });
|
|
42
|
+
}
|
|
43
|
+
return json({ doc: document });
|
|
44
|
+
}
|
|
@@ -10,4 +10,4 @@
|
|
|
10
10
|
* @param args Hook arguments containing the document to process
|
|
11
11
|
* @returns Updated args object with converted file data
|
|
12
12
|
*/
|
|
13
|
-
export declare const castBase64ToFile: import("../../../operations/hooks/index.server.js").Hook<"upload", "
|
|
13
|
+
export declare const castBase64ToFile: import("../../../operations/hooks/index.server.js").Hook<"upload", "update" | "create", "before">;
|
|
@@ -3,4 +3,4 @@
|
|
|
3
3
|
* the function nomalize and validate path ({slug}_directories.id).
|
|
4
4
|
* Then extract parent, name from the given path.
|
|
5
5
|
*/
|
|
6
|
-
export declare const exctractPath: import("../../../operations/hooks/index.server.js").Hook<"directory", "
|
|
6
|
+
export declare const exctractPath: import("../../../operations/hooks/index.server.js").Hook<"directory", "update" | "create", "before">;
|
|
@@ -3,4 +3,4 @@
|
|
|
3
3
|
* the function get the document _path and check if it exists,
|
|
4
4
|
* if it doesn't it create {upload_slug}_directories entries recursively
|
|
5
5
|
*/
|
|
6
|
-
export declare const handlePathCreation: import("../../../operations/hooks/index.server.js").Hook<"upload", "
|
|
6
|
+
export declare const handlePathCreation: import("../../../operations/hooks/index.server.js").Hook<"upload", "update" | "create", "before">;
|
|
@@ -17,4 +17,4 @@
|
|
|
17
17
|
* - Cleans up image variations
|
|
18
18
|
* - Nullifies related document fields
|
|
19
19
|
*/
|
|
20
|
-
export declare const processFileUpload: import("../../../operations/hooks/index.server.js").Hook<"upload", "
|
|
20
|
+
export declare const processFileUpload: import("../../../operations/hooks/index.server.js").Hook<"upload", "update" | "create", "before">;
|
|
@@ -1752,13 +1752,13 @@ export declare function getBaseAuthConfig<const C extends Config>(ctx: {
|
|
|
1752
1752
|
$Infer: {
|
|
1753
1753
|
body: ({
|
|
1754
1754
|
permission: {
|
|
1755
|
-
readonly user?: ("
|
|
1755
|
+
readonly user?: ("update" | "create" | "delete" | "list" | "get" | "set-role" | "ban" | "impersonate" | "set-password")[] | undefined;
|
|
1756
1756
|
readonly session?: ("delete" | "list" | "revoke")[] | undefined;
|
|
1757
1757
|
};
|
|
1758
1758
|
permissions?: never | undefined;
|
|
1759
1759
|
} | {
|
|
1760
1760
|
permissions: {
|
|
1761
|
-
readonly user?: ("
|
|
1761
|
+
readonly user?: ("update" | "create" | "delete" | "list" | "get" | "set-role" | "ban" | "impersonate" | "set-password")[] | undefined;
|
|
1762
1762
|
readonly session?: ("delete" | "list" | "revoke")[] | undefined;
|
|
1763
1763
|
};
|
|
1764
1764
|
permission?: never | undefined;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { isUploadConfig } from '../../collections/upload/util/config.js';
|
|
2
|
-
import { makeUploadDirectoriesCollectionClient } from '../shared/upload-directories';
|
|
2
|
+
import { makeUploadDirectoriesCollectionClient } from '../shared/upload-directories.js';
|
|
3
3
|
export const augmentDirectories = (config) => {
|
|
4
4
|
const direcotriesCollections = config.collections
|
|
5
5
|
?.filter(isUploadConfig)
|
|
@@ -54,15 +54,15 @@ export declare function createConfigContext<const C extends Config>(config: Buil
|
|
|
54
54
|
/**
|
|
55
55
|
* Retrieves either an area or collection configuration by its slug
|
|
56
56
|
*/
|
|
57
|
-
getBySlug: (slug: string) => import("../../types.js").
|
|
57
|
+
getBySlug: (slug: string) => import("../../types.js").BuiltArea | import("../../types.js").BuiltCollection;
|
|
58
58
|
/**
|
|
59
59
|
* Checks if a slug represents a collection
|
|
60
60
|
*/
|
|
61
|
-
isCollection: (slug
|
|
61
|
+
isCollection: (slug?: string) => slug is CollectionSlug;
|
|
62
62
|
/**
|
|
63
63
|
* Checks if a slug represents an area
|
|
64
64
|
*/
|
|
65
|
-
isArea: (slug
|
|
65
|
+
isArea: (slug?: string) => slug is AreaSlug;
|
|
66
66
|
/**
|
|
67
67
|
* Determines the prototype (collection or area) of a document by its slug
|
|
68
68
|
*/
|
|
@@ -2,7 +2,7 @@ import { augmentHooks } from '../../collections/config/augment-hooks.server.js';
|
|
|
2
2
|
import { exctractPath } from '../../collections/upload/hooks/extract-path.server.js';
|
|
3
3
|
import { prepareDirectoryChildren, updateDirectoryChildren } from '../../collections/upload/hooks/update-directory-children.server.js';
|
|
4
4
|
import { isUploadConfig } from '../../collections/upload/util/config.js';
|
|
5
|
-
import { makeUploadDirectoriesCollectionClient } from '../shared/upload-directories';
|
|
5
|
+
import { makeUploadDirectoriesCollectionClient } from '../shared/upload-directories.js';
|
|
6
6
|
export const augmentDirectoriesServer = (config) => {
|
|
7
7
|
const direcotriesCollections = config.collections
|
|
8
8
|
?.filter(isUploadConfig)
|
|
@@ -6,7 +6,7 @@ export declare const augmentPanelAccess: <const T extends {
|
|
|
6
6
|
readonly panel: {
|
|
7
7
|
$access: (user?: User) => boolean;
|
|
8
8
|
routes?: Record<string, import("../../../types.js").CustomPanelRoute>;
|
|
9
|
-
language?: import("
|
|
9
|
+
language?: import("../../..").PanelLanguage;
|
|
10
10
|
navigation?: {
|
|
11
11
|
groups: Array<{
|
|
12
12
|
label: string;
|
|
@@ -1749,13 +1749,13 @@ export declare const buildConfig: <const C extends Config>(config: C) => Promise
|
|
|
1749
1749
|
$Infer: {
|
|
1750
1750
|
body: ({
|
|
1751
1751
|
permission: {
|
|
1752
|
-
readonly user?: ("
|
|
1752
|
+
readonly user?: ("update" | "create" | "delete" | "list" | "get" | "set-role" | "ban" | "impersonate" | "set-password")[] | undefined;
|
|
1753
1753
|
readonly session?: ("delete" | "list" | "revoke")[] | undefined;
|
|
1754
1754
|
};
|
|
1755
1755
|
permissions?: never | undefined;
|
|
1756
1756
|
} | {
|
|
1757
1757
|
permissions: {
|
|
1758
|
-
readonly user?: ("
|
|
1758
|
+
readonly user?: ("update" | "create" | "delete" | "list" | "get" | "set-role" | "ban" | "impersonate" | "set-password")[] | undefined;
|
|
1759
1759
|
readonly session?: ("delete" | "list" | "revoke")[] | undefined;
|
|
1760
1760
|
};
|
|
1761
1761
|
permission?: never | undefined;
|
|
@@ -1962,9 +1962,9 @@ export declare const buildConfig: <const C extends Config>(config: C) => Promise
|
|
|
1962
1962
|
isValidLocale: (locale: string) => boolean;
|
|
1963
1963
|
getArea: (slug: string) => import("../types.js").BuiltArea;
|
|
1964
1964
|
getCollection: (slug: string) => import("../types.js").BuiltCollection;
|
|
1965
|
-
getBySlug: (slug: string) => import("../types.js").
|
|
1966
|
-
isCollection: (slug
|
|
1967
|
-
isArea: (slug
|
|
1965
|
+
getBySlug: (slug: string) => import("../types.js").BuiltArea | import("../types.js").BuiltCollection;
|
|
1966
|
+
isCollection: (slug?: string) => slug is import("../../types/doc.js").CollectionSlug;
|
|
1967
|
+
isArea: (slug?: string) => slug is import("../../types/doc.js").AreaSlug;
|
|
1968
1968
|
getDocumentPrototype(slug: import("../../types/doc.js").PrototypeSlug): "area" | "collection";
|
|
1969
1969
|
};
|
|
1970
1970
|
readonly plugins: InferPluginsServer<C>;
|
|
@@ -3731,13 +3731,13 @@ export declare const buildConfig: <const C extends Config>(config: C) => Promise
|
|
|
3731
3731
|
$Infer: {
|
|
3732
3732
|
body: ({
|
|
3733
3733
|
permission: {
|
|
3734
|
-
readonly user?: ("
|
|
3734
|
+
readonly user?: ("update" | "create" | "delete" | "list" | "get" | "set-role" | "ban" | "impersonate" | "set-password")[] | undefined;
|
|
3735
3735
|
readonly session?: ("delete" | "list" | "revoke")[] | undefined;
|
|
3736
3736
|
};
|
|
3737
3737
|
permissions?: never | undefined;
|
|
3738
3738
|
} | {
|
|
3739
3739
|
permissions: {
|
|
3740
|
-
readonly user?: ("
|
|
3740
|
+
readonly user?: ("update" | "create" | "delete" | "list" | "get" | "set-role" | "ban" | "impersonate" | "set-password")[] | undefined;
|
|
3741
3741
|
readonly session?: ("delete" | "list" | "revoke")[] | undefined;
|
|
3742
3742
|
};
|
|
3743
3743
|
permission?: never | undefined;
|
|
@@ -3944,9 +3944,9 @@ export declare const buildConfig: <const C extends Config>(config: C) => Promise
|
|
|
3944
3944
|
isValidLocale: (locale: string) => boolean;
|
|
3945
3945
|
getArea: (slug: string) => import("../types.js").BuiltArea;
|
|
3946
3946
|
getCollection: (slug: string) => import("../types.js").BuiltCollection;
|
|
3947
|
-
getBySlug: (slug: string) => import("../types.js").
|
|
3948
|
-
isCollection: (slug
|
|
3949
|
-
isArea: (slug
|
|
3947
|
+
getBySlug: (slug: string) => import("../types.js").BuiltArea | import("../types.js").BuiltCollection;
|
|
3948
|
+
isCollection: (slug?: string) => slug is import("../../types/doc.js").CollectionSlug;
|
|
3949
|
+
isArea: (slug?: string) => slug is import("../../types/doc.js").AreaSlug;
|
|
3950
3950
|
getDocumentPrototype(slug: import("../../types/doc.js").PrototypeSlug): "area" | "collection";
|
|
3951
3951
|
};
|
|
3952
3952
|
setLocale(locale: string | undefined): void;
|
|
@@ -3997,7 +3997,7 @@ declare function augmentConfig<T extends Config>(config: T): T & {
|
|
|
3997
3997
|
readonly panel: {
|
|
3998
3998
|
$access: (user?: import("../../../types.js").User) => boolean;
|
|
3999
3999
|
routes?: Record<string, import("../types.js").CustomPanelRoute>;
|
|
4000
|
-
language?: import("
|
|
4000
|
+
language?: import("../../..").PanelLanguage;
|
|
4001
4001
|
navigation?: {
|
|
4002
4002
|
groups: Array<{
|
|
4003
4003
|
label: string;
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { isAuthConfig } from '../../collections/auth/util.js';
|
|
2
2
|
import cache from '../../dev/cache/index.server.js';
|
|
3
3
|
import { isFormField } from '../../fields/util.js';
|
|
4
|
-
import { logger } from '../../logger/index.server';
|
|
4
|
+
import { logger } from '../../logger/index.server.js';
|
|
5
5
|
import { isBlocksFieldRaw } from '../../../fields/blocks/index.js';
|
|
6
6
|
import { isGroupFieldRaw } from '../../../fields/group/index.js';
|
|
7
|
-
import { isRelationField } from '../../../fields/relation';
|
|
7
|
+
import { isRelationField } from '../../../fields/relation/index.js';
|
|
8
8
|
import { isSelectField } from '../../../fields/select/index.js';
|
|
9
|
-
import { isTabsFieldRaw } from '../../../fields/tabs';
|
|
9
|
+
import { isTabsFieldRaw } from '../../../fields/tabs/index.js';
|
|
10
10
|
import { isTreeFieldRaw } from '../../../fields/tree/index.js';
|
|
11
11
|
function hasDuplicates(arr) {
|
|
12
12
|
return [...new Set(arr.filter((e, i, a) => a.indexOf(e) !== i))];
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { FormFieldBuilder } from '../../fields/builders/form-field-builder.js';
|
|
2
2
|
import { isGroupField } from '../../../fields/group/index.js';
|
|
3
|
-
import { RelationFieldBuilder } from '../../../fields/relation';
|
|
3
|
+
import { RelationFieldBuilder } from '../../../fields/relation/index.js';
|
|
4
4
|
import { TabsBuilder } from '../../../fields/tabs/index.js';
|
|
5
5
|
export function findThumbnailField(fields = [], basePath = '') {
|
|
6
6
|
for (const field of fields) {
|
package/dist/core/constant.d.ts
CHANGED
|
@@ -37,7 +37,7 @@ export declare const PARAMS: {
|
|
|
37
37
|
readonly SORT: "sort";
|
|
38
38
|
/** GET / UPDATE a specific version*/
|
|
39
39
|
readonly VERSION_ID: "versionId";
|
|
40
|
-
/**
|
|
40
|
+
/** On fetch (upload) list operation filter out documents from a specific uploadPath */
|
|
41
41
|
readonly UPLOAD_PATH: "uploadPath";
|
|
42
42
|
/**
|
|
43
43
|
* Disable validation on CREATE / UPDATE operations
|
package/dist/core/constant.js
CHANGED
|
@@ -37,7 +37,7 @@ export const PARAMS = {
|
|
|
37
37
|
SORT: 'sort',
|
|
38
38
|
/** GET / UPDATE a specific version*/
|
|
39
39
|
VERSION_ID: 'versionId',
|
|
40
|
-
/**
|
|
40
|
+
/** On fetch (upload) list operation filter out documents from a specific uploadPath */
|
|
41
41
|
UPLOAD_PATH: 'uploadPath',
|
|
42
42
|
/**
|
|
43
43
|
* Disable validation on CREATE / UPDATE operations
|
|
@@ -1,15 +1,29 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { spawnSync } from 'child_process';
|
|
3
|
-
import { copyFileSync, cpSync, existsSync, mkdirSync, renameSync, rmSync, writeFileSync } from 'fs';
|
|
4
|
-
import { polkaServer } from './templates.js';
|
|
5
2
|
import { logger } from '../../../logger/index.server.js';
|
|
3
|
+
import chalk from 'chalk';
|
|
4
|
+
import { copyFileSync, cpSync, existsSync, mkdirSync, renameSync, rmSync, writeFileSync } from 'fs';
|
|
5
|
+
import { getInvokingPackageManager } from '../util/package-manager.server.js';
|
|
6
|
+
import { envProduction, polkaServer } from './templates.js';
|
|
7
|
+
const installCommands = {
|
|
8
|
+
pnpm: {
|
|
9
|
+
addDeps: 'pnpm install polka sharp serve-static',
|
|
10
|
+
prodInstall: 'pnpm install --prod',
|
|
11
|
+
runEnv: 'pnpm rime env'
|
|
12
|
+
},
|
|
13
|
+
npm: {
|
|
14
|
+
addDeps: 'npm install polka sharp serve-static',
|
|
15
|
+
prodInstall: 'npm install --omit=dev',
|
|
16
|
+
runEnv: 'npx rime env'
|
|
17
|
+
}
|
|
18
|
+
};
|
|
6
19
|
export const build = (args) => {
|
|
7
20
|
// Delete app folder if it exists
|
|
8
21
|
if (existsSync('./app')) {
|
|
9
22
|
rmSync('./app', { recursive: true, force: true });
|
|
10
23
|
}
|
|
11
24
|
// Build
|
|
12
|
-
|
|
25
|
+
mkdirSync('./build', { recursive: true });
|
|
26
|
+
// spawnSync('./node_modules/.bin/vite', ['build'], { stdio: 'inherit' });
|
|
13
27
|
console.log('');
|
|
14
28
|
// Create app directory
|
|
15
29
|
mkdirSync('./app', { recursive: true });
|
|
@@ -24,13 +38,28 @@ export const build = (args) => {
|
|
|
24
38
|
cpSync('./db', './app/db', { recursive: true });
|
|
25
39
|
logger.info('[✓] database copied');
|
|
26
40
|
}
|
|
41
|
+
// Create main entry server file
|
|
27
42
|
writeFileSync('./app/index.js', polkaServer);
|
|
28
43
|
logger.info('[✓] polka server created at app/index.js');
|
|
44
|
+
// Create .env file if flag is set
|
|
45
|
+
const envContent = envProduction();
|
|
46
|
+
if (args.withEnv) {
|
|
47
|
+
writeFileSync('./app/.env', envContent);
|
|
48
|
+
logger.info('[✓] .env file created at app/.env');
|
|
49
|
+
}
|
|
50
|
+
console.log('----------------------------------------------------------------\n');
|
|
51
|
+
console.log('## Next steps :');
|
|
52
|
+
console.log('');
|
|
53
|
+
console.log(' cd ./app');
|
|
54
|
+
const pm = getInvokingPackageManager() === 'pnpm' ? 'pnpm' : 'npm';
|
|
55
|
+
if (!args.withEnv) {
|
|
56
|
+
console.log(' ' +
|
|
57
|
+
installCommands[pm].runEnv +
|
|
58
|
+
' ' +
|
|
59
|
+
chalk.dim(`# next time run \`${pm === 'pnpm' ? 'pnpm' : 'npx'} rime build -e\` to generate the .env file automatically`));
|
|
60
|
+
}
|
|
61
|
+
console.log(' ' + installCommands[pm].addDeps);
|
|
62
|
+
console.log(' ' + installCommands[pm].prodInstall);
|
|
29
63
|
console.log('');
|
|
30
|
-
|
|
31
|
-
logger.info('create a /app/.env file with ORIGIN HOST and PORT variables');
|
|
32
|
-
logger.info('cd ./app');
|
|
33
|
-
logger.info('pnpm install --prod');
|
|
34
|
-
logger.info('pnpm install polka sharp serve-static');
|
|
35
|
-
logger.info('node --env-file=.env index.js');
|
|
64
|
+
console.log(' node --env-file=.env index.js');
|
|
36
65
|
};
|
|
@@ -1 +1,2 @@
|
|
|
1
|
+
export declare const envProduction: () => string;
|
|
1
2
|
export declare const polkaServer = "import polka from 'polka';\nimport serveStatic from 'serve-static';\nimport { handler } from './build/handler.js';\n\nconst serve = serveStatic('./static');\n\nconst port = process.env.PORT || 3000;\nconst host = process.env.HOST || '127.0.0.1';\n\npolka()\n\t.use(serve)\n\t.use(handler)\n\t.listen(port, host, () => {\n\t\tconsole.log(`server running on ${host}:${port}`);\n\t});\n";
|
|
@@ -1,3 +1,27 @@
|
|
|
1
|
+
import { randomId } from '../../../../util/random.js';
|
|
2
|
+
export const envProduction = () => `# BETTER-AUTH
|
|
3
|
+
BETTER_AUTH_SECRET=${randomId(32)}
|
|
4
|
+
|
|
5
|
+
# RIME
|
|
6
|
+
PUBLIC_RIME_URL=http://localhost:3000
|
|
7
|
+
RIME_LOG_LEVEL=ERROR
|
|
8
|
+
RIME_LOG_TO_FILE=true
|
|
9
|
+
RIME_CACHE_ENABLED=true
|
|
10
|
+
RIME_CACHE_STRATEGY=memory
|
|
11
|
+
|
|
12
|
+
# RIME_SMTP_USER=user@host.org
|
|
13
|
+
# RIME_SMTP_PASSWORD=somepassword
|
|
14
|
+
# RIME_SMTP_HOST=smtp.host
|
|
15
|
+
# RIME_SMTP_PORT=465
|
|
16
|
+
|
|
17
|
+
# SVELTEKIT ADAPTER-NODE
|
|
18
|
+
ORIGIN=http://localhost:3000
|
|
19
|
+
PORT=3000
|
|
20
|
+
HOST=localhost
|
|
21
|
+
|
|
22
|
+
# MISC
|
|
23
|
+
BODY_SIZE_LIMIT=10485760 # 10(MB) * 1024 * 1024 = 10485760 bytes
|
|
24
|
+
`;
|
|
1
25
|
export const polkaServer = `import polka from 'polka';
|
|
2
26
|
import serveStatic from 'serve-static';
|
|
3
27
|
import { handler } from './build/handler.js';
|
|
@@ -2,7 +2,7 @@ import { logger } from '../../../logger/index.server.js';
|
|
|
2
2
|
import { rmSync } from 'node:fs';
|
|
3
3
|
import path from 'node:path';
|
|
4
4
|
import { INPUT_DIR, OUTPUT_DIR } from '../../constants.js';
|
|
5
|
-
import { prompt } from '../util.server.js';
|
|
5
|
+
import { prompt } from '../util/prompt.server.js';
|
|
6
6
|
const clearMessage = `Are you sure you want to delete all related rime files (Y/n):
|
|
7
7
|
- ./static/medias
|
|
8
8
|
- ./db
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
+
import { logger } from '../../logger/index.server.js';
|
|
2
3
|
import { program } from 'commander';
|
|
4
|
+
import { existsSync, writeFileSync } from 'fs';
|
|
5
|
+
import { envProduction } from './build/templates.js';
|
|
3
6
|
program.version('0.1').description('CMS utilities');
|
|
4
7
|
program.description('Rime utilities');
|
|
5
8
|
program
|
|
@@ -14,6 +17,7 @@ program
|
|
|
14
17
|
program
|
|
15
18
|
.command('build')
|
|
16
19
|
.option('-d, --with-database', 'Include database', false)
|
|
20
|
+
.option('-e, --with-env', 'Create the /app/.env file from the production template', false)
|
|
17
21
|
.action(async (args) => {
|
|
18
22
|
const build = await import('./build/index.js').then((m) => m.build);
|
|
19
23
|
build(args);
|
|
@@ -39,4 +43,20 @@ program
|
|
|
39
43
|
process.exitCode = 1;
|
|
40
44
|
}
|
|
41
45
|
});
|
|
46
|
+
program
|
|
47
|
+
.command('env')
|
|
48
|
+
.option('-f, --force', 'Force generation, overwrite current', false)
|
|
49
|
+
.action(async (args) => {
|
|
50
|
+
try {
|
|
51
|
+
if (existsSync('./.env') && !args.force) {
|
|
52
|
+
logger.info('.env file already exists. Use --force to overwrite.');
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
writeFileSync('./.env', envProduction());
|
|
56
|
+
logger.info('[✓] .env file created');
|
|
57
|
+
}
|
|
58
|
+
catch {
|
|
59
|
+
process.exitCode = 1;
|
|
60
|
+
}
|
|
61
|
+
});
|
|
42
62
|
program.parse(process.argv);
|
|
@@ -11,9 +11,9 @@ import path from 'path';
|
|
|
11
11
|
import { fileURLToPath } from 'url';
|
|
12
12
|
import { INPUT_DIR } from '../../constants.js';
|
|
13
13
|
import { generate } from '../generate/index.server.js';
|
|
14
|
-
import {
|
|
15
|
-
import { getPackageInfoByKey } from '
|
|
16
|
-
import {
|
|
14
|
+
import { installDependencies } from '../util/package-manager.server.js';
|
|
15
|
+
import { getPackageInfoByKey } from '../util/package.server.js';
|
|
16
|
+
import { prompt } from '../util/prompt.server.js';
|
|
17
17
|
import * as templates from './templates.js';
|
|
18
18
|
const PACKAGE = 'rimecms';
|
|
19
19
|
const root = process.cwd();
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
export declare const env: () => string;
|
|
2
2
|
export declare const defaultConfig: (name: string) => string;
|
|
3
3
|
export declare const drizzleConfig: (name: string) => string;
|
|
4
|
-
export declare const hooks = "import { sequence } from '@sveltejs/kit/hooks';\nimport { handlers } from 'rimecms';\nimport config from './lib/+rime.generated/rime.config.server.js';\n\nexport const handle = sequence(...(await handlers(config)));\n";
|
|
4
|
+
export declare const hooks = "import { sequence } from '@sveltejs/kit/hooks';\nimport { handlers } from 'rimecms/server';\nimport config from './lib/+rime.generated/rime.config.server.js';\n\nexport const handle = sequence(...(await handlers(config)));\n";
|
|
@@ -18,7 +18,7 @@ RIME_LOG_TO_FILE_MAX_DAYS=1
|
|
|
18
18
|
export const defaultConfig = (name) => `
|
|
19
19
|
import { Collection, rime } from '$rime/config';
|
|
20
20
|
import { text } from '${PACKAGE}/fields';
|
|
21
|
-
import { adapterSqlite } from '${PACKAGE}/sqlite';
|
|
21
|
+
import { adapterSqlite } from '${PACKAGE}/adapter-sqlite';
|
|
22
22
|
|
|
23
23
|
const Pages = Collection.create('pages', {
|
|
24
24
|
fields: [text('title').isTitle()]
|
|
@@ -45,7 +45,7 @@ export const config: Config = {
|
|
|
45
45
|
export default defineConfig(config);
|
|
46
46
|
`;
|
|
47
47
|
export const hooks = `import { sequence } from '@sveltejs/kit/hooks';
|
|
48
|
-
import { handlers } from '${PACKAGE}';
|
|
48
|
+
import { handlers } from '${PACKAGE}/server';
|
|
49
49
|
import config from './lib/${OUTPUT_DIR}/rime.config.server.js';
|
|
50
50
|
|
|
51
51
|
export const handle = sequence(...(await handlers(config)));
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const dim: (text: string) => void;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export type PackageManagerName = 'yarn' | 'pnpm' | 'bun' | 'npm' | 'deno';
|
|
2
|
+
export declare function getPackageManager(): PackageManagerName;
|
|
3
|
+
/**
|
|
4
|
+
* Detects the package manager used to invoke the currently running command
|
|
5
|
+
* (e.g. `pnpm rime build` vs `npx rime build`), based on the user agent npm/pnpm/yarn/bun
|
|
6
|
+
* set on the child process. Falls back to npm, which is also what npx reports.
|
|
7
|
+
*/
|
|
8
|
+
export declare function getInvokingPackageManager(): PackageManagerName;
|
|
9
|
+
export declare function installDependencies(): void;
|
package/dist/core/dev/cli/{init/package-manager-util.server.js → util/package-manager.server.js}
RENAMED
|
@@ -39,6 +39,21 @@ export function getPackageManager() {
|
|
|
39
39
|
}
|
|
40
40
|
return 'npm';
|
|
41
41
|
}
|
|
42
|
+
/**
|
|
43
|
+
* Detects the package manager used to invoke the currently running command
|
|
44
|
+
* (e.g. `pnpm rime build` vs `npx rime build`), based on the user agent npm/pnpm/yarn/bun
|
|
45
|
+
* set on the child process. Falls back to npm, which is also what npx reports.
|
|
46
|
+
*/
|
|
47
|
+
export function getInvokingPackageManager() {
|
|
48
|
+
const userAgent = process.env.npm_config_user_agent;
|
|
49
|
+
if (!userAgent)
|
|
50
|
+
return 'npm';
|
|
51
|
+
const name = userAgent.split('/')[0];
|
|
52
|
+
if (name === 'pnpm' || name === 'yarn' || name === 'bun' || name === 'npm' || name === 'deno') {
|
|
53
|
+
return name;
|
|
54
|
+
}
|
|
55
|
+
return 'npm';
|
|
56
|
+
}
|
|
42
57
|
export function installDependencies() {
|
|
43
58
|
const pm = getPackageManager();
|
|
44
59
|
if (pm === 'deno' || pm === 'yarn') {
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Vite (and every other rime command) resolves everything relative to cwd and
|
|
3
|
+
* fails when run from elsewhere (e.g. `vite build` from ./app errors with
|
|
4
|
+
* "Cannot resolve entry module index.html"). package.json alone isn't a
|
|
5
|
+
* reliable root marker since the build command copies one into ./app too;
|
|
6
|
+
* src/ is only ever present at the real project root.
|
|
7
|
+
*/
|
|
8
|
+
export declare function isProjectRoot(cwd?: string): boolean;
|
|
9
|
+
export declare function getPackageInfoByKey(key: string): string;
|
|
@@ -1,5 +1,15 @@
|
|
|
1
1
|
import path from 'path';
|
|
2
2
|
import fs from 'fs';
|
|
3
|
+
/**
|
|
4
|
+
* Vite (and every other rime command) resolves everything relative to cwd and
|
|
5
|
+
* fails when run from elsewhere (e.g. `vite build` from ./app errors with
|
|
6
|
+
* "Cannot resolve entry module index.html"). package.json alone isn't a
|
|
7
|
+
* reliable root marker since the build command copies one into ./app too;
|
|
8
|
+
* src/ is only ever present at the real project root.
|
|
9
|
+
*/
|
|
10
|
+
export function isProjectRoot(cwd = process.cwd()) {
|
|
11
|
+
return fs.existsSync(path.join(cwd, 'package.json')) && fs.existsSync(path.join(cwd, 'src'));
|
|
12
|
+
}
|
|
3
13
|
export function getPackageInfoByKey(key) {
|
|
4
14
|
try {
|
|
5
15
|
// Read the package.json file
|
|
@@ -1,8 +1,17 @@
|
|
|
1
1
|
import type { Routes } from './util.server.js';
|
|
2
|
+
/**
|
|
3
|
+
* Param matchers backing [slug=collection]/[slug=area] — bake in the actual
|
|
4
|
+
* configured slug list at generation time so they stay isomorphic (no
|
|
5
|
+
* server-only config import; SvelteKit resolves matchers on the client too
|
|
6
|
+
* for client-side navigation), same approach as this repo's own hand-written
|
|
7
|
+
* src/params/news.ts, lang.ts.
|
|
8
|
+
* src/params/collection.ts, src/params/area.ts
|
|
9
|
+
*/
|
|
10
|
+
declare const paramMatcher: (slugs: string[]) => string;
|
|
2
11
|
/**
|
|
3
12
|
* Custom route template generator
|
|
4
13
|
* Used for generating custom routes
|
|
5
14
|
*/
|
|
6
15
|
declare const customRoute: (config: any) => string;
|
|
7
16
|
export declare const commonRoutes: Routes;
|
|
8
|
-
export { customRoute };
|
|
17
|
+
export { customRoute, paramMatcher };
|