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
|
@@ -2,7 +2,7 @@ import { FormFieldBuilder } from '../../core/fields/builders/form-field-builder.
|
|
|
2
2
|
import { sanitize } from '../../util/string.js';
|
|
3
3
|
import Cell from './component/Cell.svelte';
|
|
4
4
|
import RichText from './component/RichText.svelte';
|
|
5
|
-
import { sanitizeJSONContent } from './sanitize';
|
|
5
|
+
import { sanitizeJSONContent } from './sanitize.js';
|
|
6
6
|
const isEmpty = (value) => {
|
|
7
7
|
if (!value)
|
|
8
8
|
return true;
|
|
@@ -63,7 +63,9 @@ export class RichTextFieldBuilder extends FormFieldBuilder {
|
|
|
63
63
|
});
|
|
64
64
|
}
|
|
65
65
|
catch (err) {
|
|
66
|
-
|
|
66
|
+
if (typeof window !== 'undefined') {
|
|
67
|
+
console.error('Error parsing rich text JSON:', err);
|
|
68
|
+
}
|
|
67
69
|
if (typeof value === 'string') {
|
|
68
70
|
return value;
|
|
69
71
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { templateUniqueRequired } from '../../adapter-sqlite/generate-schema/templates.server.js';
|
|
2
|
-
import { getSchemaColumnNames } from '../../adapter-sqlite/generate-schema/util.js';
|
|
2
|
+
import { getSchemaColumnNames } from '../../adapter-sqlite/generate-schema/util.server.js';
|
|
3
3
|
export const toSchema = (field, parentPath) => {
|
|
4
4
|
const { camel, snake } = getSchemaColumnNames({ name: field.name, parentPath });
|
|
5
5
|
const suffix = templateUniqueRequired(field.raw, typeof field.raw.defaultValue === 'object' ? field.raw.defaultValue : {});
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { templateUniqueRequired } from '../../adapter-sqlite/generate-schema/templates.server.js';
|
|
2
|
-
import { getSchemaColumnNames } from '../../adapter-sqlite/generate-schema/util.js';
|
|
2
|
+
import { getSchemaColumnNames } from '../../adapter-sqlite/generate-schema/util.server.js';
|
|
3
3
|
export const toSchema = (field, parentPath) => {
|
|
4
4
|
const { camel, snake } = getSchemaColumnNames({ name: field.raw.name, parentPath });
|
|
5
5
|
const defaultValue = field.raw.many ? [] : '';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { templateUniqueRequired } from '../../adapter-sqlite/generate-schema/templates.server.js';
|
|
2
|
-
import { getSchemaColumnNames } from '../../adapter-sqlite/generate-schema/util.js';
|
|
2
|
+
import { getSchemaColumnNames } from '../../adapter-sqlite/generate-schema/util.server.js';
|
|
3
3
|
export const toSchema = (field, parentPath) => {
|
|
4
4
|
const { camel, snake } = getSchemaColumnNames({ name: field.name, parentPath });
|
|
5
5
|
const suffix = templateUniqueRequired({ unique: field.raw.unique, required: field.raw.required }, typeof field.raw.defaultValue === 'string' ? field.raw.defaultValue : '');
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { templateUniqueRequired } from '../../adapter-sqlite/generate-schema/templates.server.js';
|
|
2
|
-
import { getSchemaColumnNames } from '../../adapter-sqlite/generate-schema/util.js';
|
|
2
|
+
import { getSchemaColumnNames } from '../../adapter-sqlite/generate-schema/util.server.js';
|
|
3
3
|
export const toSchema = (field, parentPath) => {
|
|
4
4
|
const { camel, snake } = getSchemaColumnNames({ name: field.name, parentPath });
|
|
5
5
|
const suffix = templateUniqueRequired({ unique: field.raw.unique, required: field.raw.required }, typeof field.raw.defaultValue === 'string' ? field.raw.defaultValue : '');
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { templateUniqueRequired } from '../../adapter-sqlite/generate-schema/templates.server.js';
|
|
2
|
-
import { getSchemaColumnNames } from '../../adapter-sqlite/generate-schema/util.js';
|
|
2
|
+
import { getSchemaColumnNames } from '../../adapter-sqlite/generate-schema/util.server.js';
|
|
3
3
|
export const toSchema = (field, parentPath) => {
|
|
4
4
|
const { camel, snake } = getSchemaColumnNames({ name: field.name, parentPath });
|
|
5
5
|
const suffix = templateUniqueRequired({ unique: false, required: field.raw.required }, typeof field.raw.defaultValue === 'string' ? field.raw.defaultValue : '');
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { templateUniqueRequired } from '../../adapter-sqlite/generate-schema/templates.server.js';
|
|
2
|
-
import { getSchemaColumnNames } from '../../adapter-sqlite/generate-schema/util.js';
|
|
2
|
+
import { getSchemaColumnNames } from '../../adapter-sqlite/generate-schema/util.server.js';
|
|
3
3
|
export const toSchema = (field, parentPath) => {
|
|
4
4
|
const { camel, snake } = getSchemaColumnNames({ name: field.name, parentPath });
|
|
5
5
|
const suffix = templateUniqueRequired(field.raw, typeof field.raw.defaultValue === 'string' ? field.raw.defaultValue : '00:00');
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { templateUniqueRequired } from '../../adapter-sqlite/generate-schema/templates.server.js';
|
|
2
|
-
import { getSchemaColumnNames } from '../../adapter-sqlite/generate-schema/util.js';
|
|
2
|
+
import { getSchemaColumnNames } from '../../adapter-sqlite/generate-schema/util.server.js';
|
|
3
3
|
export const toSchema = (field, parentPath) => {
|
|
4
4
|
const { camel, snake } = getSchemaColumnNames({ name: field.name, parentPath });
|
|
5
5
|
const suffix = templateUniqueRequired(field.raw, typeof field.raw.defaultValue === 'boolean' ? field.raw.defaultValue : false);
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,11 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import i18n, { t__ } from './core/i18n/index.js';
|
|
2
|
+
import { cacheClient } from './core/plugins/cache/index.js';
|
|
3
|
+
import LiveConsumer from './panel/components/sections/live/Consumer.svelte';
|
|
4
|
+
import LiveEdit from './panel/components/sections/live/LiveEdit.svelte';
|
|
5
|
+
import LiveProvider from './panel/components/sections/live/Provider.svelte';
|
|
6
|
+
export { definePlugin, definePluginClient } from './core/plugins/index.js';
|
|
7
|
+
export { cacheClient, i18n, LiveConsumer, LiveEdit, LiveProvider, t__ };
|
|
8
|
+
export type { Dictionaries, PanelLanguage } from './core/i18n/index.js';
|
|
4
9
|
declare module 'rimecms' {
|
|
5
10
|
interface RegisterCollection {
|
|
6
11
|
}
|
package/dist/index.js
CHANGED
|
@@ -1,3 +1,7 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import i18n, { t__ } from './core/i18n/index.js';
|
|
2
|
+
import { cacheClient } from './core/plugins/cache/index.js';
|
|
3
|
+
import LiveConsumer from './panel/components/sections/live/Consumer.svelte';
|
|
4
|
+
import LiveEdit from './panel/components/sections/live/LiveEdit.svelte';
|
|
5
|
+
import LiveProvider from './panel/components/sections/live/Provider.svelte';
|
|
6
|
+
export { definePlugin, definePluginClient } from './core/plugins/index.js';
|
|
7
|
+
export { cacheClient, i18n, LiveConsumer, LiveEdit, LiveProvider, t__ };
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
2
|
import { goto, invalidateAll } from '$app/navigation';
|
|
3
|
-
import { apiUrl } from '../../../../../core/api/index.js';
|
|
4
3
|
import type { Directory } from '../../../../../core/collections/upload/upload.js';
|
|
5
4
|
import type { BuiltCollectionClient } from '../../../../../core/config/types.js';
|
|
6
5
|
import { PARAMS } from '../../../../../core/constant.js';
|
|
@@ -13,6 +12,7 @@
|
|
|
13
12
|
import { getAPIProxyContext } from '../../../../context/api-proxy.svelte.js';
|
|
14
13
|
import { panelUrl } from '../../../../util/url.js';
|
|
15
14
|
import { trycatchFetch } from '../../../../../util/function.js';
|
|
15
|
+
import { apiUrl } from '../../../../../util/index.js';
|
|
16
16
|
import { Pencil, Trash2 } from '@lucide/svelte';
|
|
17
17
|
import { toast } from 'svelte-sonner';
|
|
18
18
|
import { t__ } from '../../../../../core/i18n/index.js';
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
2
|
import { invalidateAll } from '$app/navigation';
|
|
3
|
-
import { apiUrl } from '../../../../core/api/index.js';
|
|
4
3
|
import { PARAMS, VERSIONS_STATUS } from '../../../../core/constant.js';
|
|
5
4
|
import * as Dialog from '../../ui/dialog/index.js';
|
|
6
5
|
import * as Radio from '../../ui/radio-group/index.js';
|
|
7
6
|
import type { DocumentFormContext } from '../../../context/documentForm.svelte.js';
|
|
7
|
+
import { apiUrl } from '../../../../util/index.js';
|
|
8
8
|
import { toKebabCase } from '../../../../util/string';
|
|
9
9
|
import { toast } from 'svelte-sonner';
|
|
10
10
|
import { t__ } from '../../../../core/i18n/index.js';
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
|
-
import { apiUrl } from '../../../../core/api/index.js';
|
|
3
2
|
import type { User } from '../../../../core/collections/auth/types.js';
|
|
4
3
|
import type { GenericDoc } from '../../../../core/types/doc.js';
|
|
4
|
+
import { apiUrl } from '../../../../util/index.js';
|
|
5
5
|
import { toKebabCase } from '../../../../util/string.js';
|
|
6
6
|
import { onMount } from 'svelte';
|
|
7
7
|
import { Button } from '../../ui/button/index.js';
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
2
|
import { goto } from '$app/navigation';
|
|
3
3
|
import { page } from '$app/state';
|
|
4
|
-
import { apiUrl } from '../../../../core/api/index.js';
|
|
5
4
|
import { PARAMS, VERSIONS_STATUS } from '../../../../core/constant.js';
|
|
6
5
|
import * as Dialog from '../../ui/dialog/index.js';
|
|
7
6
|
import * as DropdownMenu from '../../ui/dropdown-menu/index.js';
|
|
@@ -10,6 +9,7 @@
|
|
|
10
9
|
import { panelUrl } from '../../../util/url.js';
|
|
11
10
|
import type { GenericDoc } from '../../../../types.js';
|
|
12
11
|
import { trycatchFetch } from '../../../../util/function.js';
|
|
12
|
+
import { apiUrl } from '../../../../util/index.js';
|
|
13
13
|
import { Copy, History, Import, Pickaxe, Settings, Trash2 } from '@lucide/svelte';
|
|
14
14
|
import { toast } from 'svelte-sonner';
|
|
15
15
|
import { t__ } from '../../../../core/i18n/index.js';
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { invalidateAll } from '$app/navigation';
|
|
2
|
-
import { apiUrl } from '../../core/api/index.js';
|
|
3
2
|
import { isUploadConfig } from '../../core/collections/upload/util/config.js';
|
|
4
3
|
import { PARAMS } from '../../core/constant.js';
|
|
5
4
|
import { isFormField } from '../../core/fields/util.js';
|
|
@@ -9,6 +8,7 @@ import { TabsBuilder } from '../../fields/tabs/index.js';
|
|
|
9
8
|
import { panelUrl } from '../util/url.js';
|
|
10
9
|
import { toNestedStructure } from '../../util/doc.js';
|
|
11
10
|
import { trycatch, trycatchFetch } from '../../util/function.js';
|
|
11
|
+
import { apiUrl } from '../../util/index.js';
|
|
12
12
|
import { getValueAtPath, hasProp } from '../../util/object.js';
|
|
13
13
|
import { getContext, onMount, setContext } from 'svelte';
|
|
14
14
|
import { toast } from 'svelte-sonner';
|
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
import { applyAction, deserialize } from '$app/forms';
|
|
2
2
|
import { page } from '$app/state';
|
|
3
|
-
import { apiUrl } from '../../core/api/index.js';
|
|
4
3
|
import { compileDocumentConfig } from '../../core/config/shared/compile.js';
|
|
5
4
|
import { PARAMS, VERSIONS_STATUS } from '../../core/constant.js';
|
|
6
5
|
import { getFieldConfigByPath } from '../../core/fields/util.js';
|
|
7
6
|
import { buildConfigMap } from '../../core/operations/configMap/index.js';
|
|
8
7
|
import { isJSONContent, richTextJSONToText } from '../../fields/rich-text/index.js';
|
|
9
8
|
import { normalizeFieldPath } from '../../util/doc.js';
|
|
10
|
-
import { random } from '../../util/index.js';
|
|
9
|
+
import { apiUrl, random } from '../../util/index.js';
|
|
11
10
|
import { isObjectLiteral, omit } from '../../util/object.js';
|
|
12
11
|
import cloneDeep from 'clone-deep';
|
|
13
12
|
import { diff } from 'deep-object-diff';
|
|
@@ -13,6 +13,7 @@ export declare function setFormContext(initial: Dic, key: string): {
|
|
|
13
13
|
readOnly: boolean;
|
|
14
14
|
enhance: SubmitFunction;
|
|
15
15
|
getRawValue: <T>(path: string) => NonNullable<T> | null;
|
|
16
|
+
readonly pending: boolean;
|
|
16
17
|
readonly canSubmit: boolean;
|
|
17
18
|
readonly errors: {
|
|
18
19
|
readonly length: number;
|
|
@@ -52,6 +53,7 @@ export declare function getFormContext(key: string): {
|
|
|
52
53
|
readOnly: boolean;
|
|
53
54
|
enhance: SubmitFunction;
|
|
54
55
|
getRawValue: <T>(path: string) => NonNullable<T> | null;
|
|
56
|
+
readonly pending: boolean;
|
|
55
57
|
readonly canSubmit: boolean;
|
|
56
58
|
readonly errors: {
|
|
57
59
|
readonly length: number;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { applyAction } from '$app/forms';
|
|
2
|
-
import { getValueAtPath } from '../../util/object';
|
|
3
|
-
import { snapshot } from '../../util/state';
|
|
2
|
+
import { getValueAtPath } from '../../util/object.js';
|
|
3
|
+
import { snapshot } from '../../util/state.js';
|
|
4
4
|
import { diff } from 'deep-object-diff';
|
|
5
5
|
import { getContext, setContext } from 'svelte';
|
|
6
6
|
import { setErrorsContext } from './errors.svelte';
|
|
@@ -12,6 +12,7 @@ function createFormStore(initial, key) {
|
|
|
12
12
|
const hasError = $derived(errors.length);
|
|
13
13
|
const canSubmit = $derived(Object.keys(changes).length > 0 && !hasError);
|
|
14
14
|
let status = $state();
|
|
15
|
+
let pending = $state(false);
|
|
15
16
|
$effect(() => {
|
|
16
17
|
if (Object.keys(changes).length) {
|
|
17
18
|
errors.value = {};
|
|
@@ -94,11 +95,13 @@ function createFormStore(initial, key) {
|
|
|
94
95
|
};
|
|
95
96
|
}
|
|
96
97
|
const enhance = async ({ formData }) => {
|
|
98
|
+
pending = true;
|
|
97
99
|
for (const key of Object.keys(form)) {
|
|
98
100
|
formData.set(key, form[key]);
|
|
99
101
|
}
|
|
100
102
|
return async ({ result }) => {
|
|
101
103
|
status = result.status;
|
|
104
|
+
pending = false;
|
|
102
105
|
switch (result.type) {
|
|
103
106
|
case 'failure':
|
|
104
107
|
if (result.data?.errors) {
|
|
@@ -122,6 +125,9 @@ function createFormStore(initial, key) {
|
|
|
122
125
|
readOnly: false,
|
|
123
126
|
enhance,
|
|
124
127
|
getRawValue,
|
|
128
|
+
get pending() {
|
|
129
|
+
return pending;
|
|
130
|
+
},
|
|
125
131
|
get canSubmit() {
|
|
126
132
|
return canSubmit;
|
|
127
133
|
},
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { page } from '$app/state';
|
|
2
2
|
import { env } from '$env/dynamic/public';
|
|
3
|
-
import { apiUrl } from '../../core/api/index.js';
|
|
4
3
|
import { PARAMS } from '../../core/constant.js';
|
|
4
|
+
import { apiUrl } from '../../util/index.js';
|
|
5
5
|
import { toKebabCase } from '../../util/string.js';
|
|
6
6
|
import { getContext, setContext } from 'svelte';
|
|
7
7
|
import { getValueAtPath, isObjectLiteral, setValueAtPath } from '../../util/object.js';
|
package/dist/panel/index.d.ts
CHANGED
|
@@ -4,15 +4,21 @@ import type { Snippet } from 'svelte';
|
|
|
4
4
|
import { Field } from './components/fields/index.js';
|
|
5
5
|
import Panel from './components/Root.svelte';
|
|
6
6
|
import Doc from './components/sections/document/Document.svelte';
|
|
7
|
+
import Button from './components/ui/button/button.svelte';
|
|
8
|
+
import Input from './components/ui/input/input.svelte';
|
|
9
|
+
import SpinLoader from './components/ui/spin-loader/SpinLoader.svelte';
|
|
7
10
|
import Area from './pages/area/Area.svelte';
|
|
8
11
|
import AreaVersionsDoc from './pages/area/AreaVersionsDoc.svelte';
|
|
12
|
+
import ForgotPassword from './pages/auth/forgot-password/ForgotPassword.svelte';
|
|
13
|
+
import ResetPassword from './pages/auth/reset-password/ResetPassword.svelte';
|
|
14
|
+
import SignIn from './pages/auth/sign-in/SignIn.svelte';
|
|
9
15
|
import CollectionDoc from './pages/collection-document/CollectionDocument.svelte';
|
|
10
16
|
import CollectionDocVersions from './pages/collection-document/CollectionDocVersions.svelte';
|
|
11
17
|
import Collection from './pages/collection/Collection.svelte';
|
|
12
18
|
import Dashboard from './pages/dashboard/Dashboard.svelte';
|
|
13
19
|
import Live from './pages/live/Live.svelte';
|
|
14
20
|
import type { Route } from './types.js';
|
|
15
|
-
export { Area, AreaVersionsDoc, Collection, CollectionDoc, CollectionDocVersions, Dashboard, Doc, Field, Live, Panel };
|
|
21
|
+
export { Area, AreaVersionsDoc, Button, Collection, CollectionDoc, CollectionDocVersions, Dashboard, Doc, Field, ForgotPassword, Input, Live, Panel, ResetPassword, SignIn, SpinLoader };
|
|
16
22
|
export type { DocumentFormContext } from './context/documentForm.svelte.js';
|
|
17
23
|
export type CollectionProps = {
|
|
18
24
|
data: {
|
|
@@ -48,3 +54,5 @@ export type CollectionDocData<V extends boolean = boolean> = DocVersions<V> & Ba
|
|
|
48
54
|
export type AreaDocData<V extends boolean = boolean> = DocVersions<V> & BaseDocData & {
|
|
49
55
|
operation: 'update';
|
|
50
56
|
};
|
|
57
|
+
export type CollectionDocumentDataWithVersions = CollectionDocData<true>;
|
|
58
|
+
export type AreaDataWithVersions = AreaDocData<true>;
|
package/dist/panel/index.js
CHANGED
|
@@ -1,8 +1,14 @@
|
|
|
1
1
|
import { Field } from './components/fields/index.js';
|
|
2
2
|
import Panel from './components/Root.svelte';
|
|
3
3
|
import Doc from './components/sections/document/Document.svelte';
|
|
4
|
+
import Button from './components/ui/button/button.svelte';
|
|
5
|
+
import Input from './components/ui/input/input.svelte';
|
|
6
|
+
import SpinLoader from './components/ui/spin-loader/SpinLoader.svelte';
|
|
4
7
|
import Area from './pages/area/Area.svelte';
|
|
5
8
|
import AreaVersionsDoc from './pages/area/AreaVersionsDoc.svelte';
|
|
9
|
+
import ForgotPassword from './pages/auth/forgot-password/ForgotPassword.svelte';
|
|
10
|
+
import ResetPassword from './pages/auth/reset-password/ResetPassword.svelte';
|
|
11
|
+
import SignIn from './pages/auth/sign-in/SignIn.svelte';
|
|
6
12
|
import CollectionDoc from './pages/collection-document/CollectionDocument.svelte';
|
|
7
13
|
import CollectionDocVersions from './pages/collection-document/CollectionDocVersions.svelte';
|
|
8
14
|
import Collection from './pages/collection/Collection.svelte';
|
|
@@ -10,4 +16,4 @@ import Dashboard from './pages/dashboard/Dashboard.svelte';
|
|
|
10
16
|
import Live from './pages/live/Live.svelte';
|
|
11
17
|
export {
|
|
12
18
|
// Components
|
|
13
|
-
Area, AreaVersionsDoc, Collection, CollectionDoc, CollectionDocVersions, Dashboard, Doc, Field, Live, Panel };
|
|
19
|
+
Area, AreaVersionsDoc, Button, Collection, CollectionDoc, CollectionDocVersions, Dashboard, Doc, Field, ForgotPassword, Input, Live, Panel, ResetPassword, SignIn, SpinLoader };
|
|
@@ -1,21 +1,2 @@
|
|
|
1
|
-
import type
|
|
2
|
-
|
|
3
|
-
export default function (slug: AreaSlug): {
|
|
4
|
-
update: (event: RequestEvent) => Promise<import("@sveltejs/kit").ActionFailure<{
|
|
5
|
-
form: Record<string, any>;
|
|
6
|
-
errors: import("../../types.js").FormErrors;
|
|
7
|
-
}> | import("@sveltejs/kit").ActionFailure<{
|
|
8
|
-
form: Record<string, any>;
|
|
9
|
-
errors: {
|
|
10
|
-
email: string;
|
|
11
|
-
};
|
|
12
|
-
}> | import("@sveltejs/kit").ActionFailure<{
|
|
13
|
-
form: {};
|
|
14
|
-
errors: {
|
|
15
|
-
_form: string;
|
|
16
|
-
};
|
|
17
|
-
}> | {
|
|
18
|
-
document: unknown;
|
|
19
|
-
message: string;
|
|
20
|
-
}>;
|
|
21
|
-
};
|
|
1
|
+
import { type Actions } from '@sveltejs/kit';
|
|
2
|
+
export declare const areaFormActions: Actions;
|
|
@@ -6,33 +6,34 @@ import { trycatch } from '../../../util/function.js';
|
|
|
6
6
|
import { toKebabCase } from '../../../util/string.js';
|
|
7
7
|
import { redirect } from '@sveltejs/kit';
|
|
8
8
|
import { t__ } from '../../../core/i18n/index.js';
|
|
9
|
-
export
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
9
|
+
export const areaFormActions = {
|
|
10
|
+
update: async (event) => {
|
|
11
|
+
const { rime, locale } = event.locals;
|
|
12
|
+
const slug = (event.params.slug || '');
|
|
13
|
+
const versionId = event.url.searchParams.get(PARAMS.VERSION_ID) || undefined;
|
|
14
|
+
const draft = event.url.searchParams.get(PARAMS.DRAFT) === 'true';
|
|
15
|
+
const [extractError, data] = await trycatch(() => extractData(event.request));
|
|
16
|
+
if (extractError) {
|
|
17
|
+
return handleError(extractError, { context: ERROR_CONTEXT.ACTION });
|
|
18
|
+
}
|
|
19
|
+
const [error, document] = await trycatch(() => rime.area(slug).update({
|
|
20
|
+
data,
|
|
21
|
+
versionId,
|
|
22
|
+
draft,
|
|
23
|
+
locale
|
|
24
|
+
}));
|
|
25
|
+
if (error) {
|
|
26
|
+
return handleError(error, { context: ERROR_CONTEXT.ACTION });
|
|
27
|
+
}
|
|
28
|
+
if (draft && 'versionId' in document) {
|
|
29
|
+
const referer = event.request.headers.get('referer');
|
|
30
|
+
if (referer && referer.includes('/versions')) {
|
|
31
|
+
return redirect(303, `${panelUrl(toKebabCase(slug))}/versions?versionId=${document.versionId}`);
|
|
24
32
|
}
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
if (referer && referer.includes('/versions')) {
|
|
28
|
-
return redirect(303, `${panelUrl(toKebabCase(slug))}/versions?versionId=${document.versionId}`);
|
|
29
|
-
}
|
|
30
|
-
else {
|
|
31
|
-
return redirect(303, `${panelUrl(toKebabCase(slug))}?versionId=${document.versionId}`);
|
|
32
|
-
}
|
|
33
|
+
else {
|
|
34
|
+
return redirect(303, `${panelUrl(toKebabCase(slug))}?versionId=${document.versionId}`);
|
|
33
35
|
}
|
|
34
|
-
return { document, message: t__('common.doc_updated') };
|
|
35
36
|
}
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
}
|
|
37
|
+
return { document, message: t__('common.doc_updated') };
|
|
38
|
+
}
|
|
39
|
+
};
|
|
@@ -1,18 +1,3 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type { Route } from '../../types.js';
|
|
1
|
+
import type { AreaDocData } from '../../index.js';
|
|
3
2
|
import type { ServerLoadEvent } from '@sveltejs/kit';
|
|
4
|
-
export
|
|
5
|
-
aria: Partial<Route>[];
|
|
6
|
-
doc: import("../../../core/types/doc.js").GenericDoc;
|
|
7
|
-
status: 200;
|
|
8
|
-
readOnly: boolean;
|
|
9
|
-
} & {
|
|
10
|
-
operation: "update";
|
|
11
|
-
}) | ({
|
|
12
|
-
aria: Partial<Route>[];
|
|
13
|
-
doc: {};
|
|
14
|
-
status: 401;
|
|
15
|
-
readOnly: true;
|
|
16
|
-
} & {
|
|
17
|
-
operation: "update";
|
|
18
|
-
})>;
|
|
3
|
+
export declare function areaLoad<V extends boolean = boolean>(event: ServerLoadEvent, withVersions?: V): Promise<AreaDocData<V>>;
|
|
@@ -1,55 +1,46 @@
|
|
|
1
|
-
import { apiUrl } from '../../../core/api/index.js';
|
|
2
1
|
import { PARAMS } from '../../../core/constant.js';
|
|
2
|
+
import { ERROR_CONTEXT, handleError } from '../../../core/errors/handler.server.js';
|
|
3
3
|
import { RimeError } from '../../../core/errors/index.js';
|
|
4
4
|
import { withVersionsSuffix } from '../../../core/naming.js';
|
|
5
5
|
import { panelUrl } from '../../util/url.js';
|
|
6
6
|
import { trycatch } from '../../../util/function.js';
|
|
7
|
+
import { apiUrl } from '../../../util/index.js';
|
|
7
8
|
import { toKebabCase } from '../../../util/string.js';
|
|
8
|
-
export
|
|
9
|
+
export async function areaLoad(event, withVersions) {
|
|
9
10
|
//
|
|
10
|
-
const
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
return { aria, doc, operation: 'update', status: 200, readOnly: true };
|
|
35
|
-
}
|
|
36
|
-
let data = {
|
|
37
|
-
aria,
|
|
38
|
-
doc,
|
|
39
|
-
operation: 'update',
|
|
40
|
-
status: 200,
|
|
41
|
-
readOnly: false
|
|
42
|
-
};
|
|
43
|
-
if (withVersions) {
|
|
44
|
-
const url = `${apiUrl(withVersionsSuffix(toKebabCase(doc._type)))}?where[ownerId][equals]=${doc.id}&sort=-updatedAt&select=updatedAt,status`;
|
|
45
|
-
const promise = fetch(url).then((r) => r.json());
|
|
46
|
-
const [error, result] = await trycatch(promise);
|
|
47
|
-
if (error || !Array.isArray(result.docs)) {
|
|
48
|
-
throw new RimeError(RimeError.OPERATION_ERROR, 'while getting versions');
|
|
49
|
-
}
|
|
50
|
-
data = { ...data, versions: result.docs };
|
|
51
|
-
}
|
|
52
|
-
return data;
|
|
11
|
+
const { locals, url, fetch } = event;
|
|
12
|
+
const { rime, locale } = locals;
|
|
13
|
+
const slug = (event.params.slug || '');
|
|
14
|
+
const area = rime.area(slug);
|
|
15
|
+
const authorizedRead = area.config.access.read(locals.user, {});
|
|
16
|
+
const authorizedUpdate = area.config.access.update(locals.user, {});
|
|
17
|
+
if (!authorizedRead) {
|
|
18
|
+
throw handleError(new RimeError(RimeError.UNAUTHORIZED), { context: ERROR_CONTEXT.LOAD });
|
|
19
|
+
}
|
|
20
|
+
const aria = [
|
|
21
|
+
{ title: 'Dashboard', icon: 'dashboard', url: panelUrl() },
|
|
22
|
+
{ title: area.config.label }
|
|
23
|
+
];
|
|
24
|
+
const versionId = url.searchParams.get(PARAMS.VERSION_ID) || undefined;
|
|
25
|
+
const draft = url.searchParams.get(PARAMS.DRAFT)
|
|
26
|
+
? url.searchParams.get(PARAMS.DRAFT) === 'true'
|
|
27
|
+
: undefined;
|
|
28
|
+
const doc = await area.find({ locale, versionId, draft });
|
|
29
|
+
let data = {
|
|
30
|
+
aria,
|
|
31
|
+
doc,
|
|
32
|
+
operation: 'update',
|
|
33
|
+
status: 200,
|
|
34
|
+
readOnly: !authorizedUpdate
|
|
53
35
|
};
|
|
54
|
-
|
|
36
|
+
if (withVersions) {
|
|
37
|
+
const url = `${apiUrl(withVersionsSuffix(toKebabCase(doc._type)))}?where[ownerId][equals]=${doc.id}&sort=-updatedAt&select=updatedAt,status`;
|
|
38
|
+
const promise = fetch(url).then((r) => r.json());
|
|
39
|
+
const [error, result] = await trycatch(promise);
|
|
40
|
+
if (error || !Array.isArray(result.docs)) {
|
|
41
|
+
throw new RimeError(RimeError.OPERATION_ERROR, 'while getting versions');
|
|
42
|
+
}
|
|
43
|
+
data = { ...data, versions: result.docs };
|
|
44
|
+
}
|
|
45
|
+
return data;
|
|
55
46
|
}
|
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
import Text from '../../../../fields/text/component/Text.svelte';
|
|
6
6
|
import AuthForm from '../../../components/sections/auth/AuthForm.svelte';
|
|
7
7
|
import Button from '../../../components/ui/button/button.svelte';
|
|
8
|
+
import SpinLoader from '../../../components/ui/spin-loader/SpinLoader.svelte';
|
|
8
9
|
import { setFormContext } from '../../../context/form.svelte';
|
|
9
10
|
import { emailField, passwordField } from '../fields.js';
|
|
10
11
|
import type { FormErrors } from '../../../../types.js';
|
|
@@ -36,7 +37,12 @@
|
|
|
36
37
|
<form method="POST" action="/panel/sign-in" use:enhance={context.enhance}>
|
|
37
38
|
<Email config={emailField} form={context} />
|
|
38
39
|
<Text type="password" icon={KeyRound} config={passwordField} form={context} />
|
|
39
|
-
<Button size="xl" disabled={!context.canSubmit} type="submit">
|
|
40
|
+
<Button size="xl" disabled={!context.canSubmit} type="submit">
|
|
41
|
+
{t__('common.signin')}
|
|
42
|
+
{#if context.pending}
|
|
43
|
+
<SpinLoader />
|
|
44
|
+
{/if}
|
|
45
|
+
</Button>
|
|
40
46
|
|
|
41
47
|
{#if data.forgotPasswordEnabled}
|
|
42
48
|
<Button variant="link" href="/forgot-password">
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
+
import type { Directory } from '../../../core/collections/upload/upload.js';
|
|
2
|
+
import { type UploadPath } from '../../../core/collections/upload/util/path.js';
|
|
1
3
|
import type { GenericDoc } from '../../../core/types/doc.js';
|
|
2
4
|
import type { Route } from '../../types.js';
|
|
3
5
|
import { type ServerLoadEvent } from '@sveltejs/kit';
|
|
4
|
-
import type { Directory } from '../../../core/collections/upload/upload.js';
|
|
5
|
-
import { type UploadPath } from '../../../core/collections/upload/util/path.js';
|
|
6
6
|
type Data = {
|
|
7
7
|
aria: Partial<Route>[];
|
|
8
8
|
docs: GenericDoc[];
|
|
@@ -14,8 +14,8 @@ type Data = {
|
|
|
14
14
|
parentDirectory: Directory;
|
|
15
15
|
};
|
|
16
16
|
};
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
export declare function collectionLoad(
|
|
17
|
+
/**
|
|
18
|
+
* Load function for the collection page in the panel.
|
|
19
|
+
*/
|
|
20
|
+
export declare function collectionLoad(event: ServerLoadEvent): Promise<Data>;
|
|
21
21
|
export {};
|