rimecms 0.30.2 → 0.31.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 +2 -40
- package/dist/.rime-modules.d.ts +23 -0
- package/dist/.rime-modules.json +1 -0
- package/dist/adapter-sqlite/generate-schema/column.server.js +1 -4
- package/dist/adapter-sqlite/generate-schema/write.server.js +7 -9
- package/dist/core/areas/config/builder.server.d.ts +0 -1
- package/dist/core/collections/auth/hooks/before-upsert/augment-fields-password.server.d.ts +1 -1
- package/dist/core/collections/config/builder.server.d.ts +0 -1
- 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-hooks.server.js +6 -3
- package/dist/core/config/auth/better-auth.server.d.ts +3 -3
- package/dist/core/config/client/augment-plugins.d.ts +1 -5
- package/dist/core/config/client/augment-plugins.js +3 -3
- package/dist/core/config/client/build-config.d.ts +1 -5
- package/dist/core/config/config-context.server.d.ts +1 -1
- package/dist/core/config/server/augment-plugins.server.d.ts +2 -42
- package/dist/core/config/server/augment-plugins.server.js +11 -6
- package/dist/core/config/server/build-config.server.d.ts +9 -4007
- package/dist/core/config/types.d.ts +12 -11
- package/dist/core/dev/cache/index.server.js +1 -1
- package/dist/core/dev/cli/build/index.d.ts +1 -0
- package/dist/core/dev/cli/build/index.js +10 -5
- package/dist/core/dev/cli/build/templates.d.ts +1 -1
- package/dist/core/dev/cli/build/templates.js +10 -7
- package/dist/core/dev/cli/clear/index.server.js +2 -0
- package/dist/core/dev/cli/generate-manifest/index.server.d.ts +17 -0
- package/dist/core/dev/cli/generate-manifest/index.server.js +221 -0
- package/dist/core/dev/cli/index.js +43 -0
- package/dist/core/dev/cli/init/index.server.js +13 -6
- package/dist/core/dev/cli/init/templates.d.ts +1 -1
- package/dist/core/dev/cli/init/templates.js +13 -4
- package/dist/core/dev/cli/util/package-manager.server.js +29 -26
- package/dist/core/dev/constants.d.ts +21 -2
- package/dist/core/dev/constants.js +26 -0
- package/dist/core/dev/generate/routes/common.server.js +4 -7
- package/dist/core/dev/generate/routes/index.server.js +25 -4
- package/dist/core/dev/generate/runtime/index.server.d.ts +40 -0
- package/dist/core/dev/generate/runtime/index.server.js +85 -0
- package/dist/core/dev/generate/runtime/parse-exports.server.d.ts +7 -0
- package/dist/core/dev/generate/runtime/parse-exports.server.js +40 -0
- package/dist/core/dev/generate/sanitize/index.server.d.ts +0 -7
- package/dist/core/dev/generate/sanitize/index.server.js +57 -5
- package/dist/core/dev/generate/types/index.server.js +21 -20
- package/dist/core/dev/vite/index.server.js +227 -33
- package/dist/core/ensure.server.d.ts +4 -3
- package/dist/core/ensure.server.js +8 -8
- package/dist/core/fields/builders/boolean-builder.d.ts +1 -2
- package/dist/core/fields/builders/field-builder.d.ts +11 -6
- package/dist/core/fields/builders/field-builder.js +12 -5
- package/dist/core/fields/builders/form-field-builder.d.ts +11 -14
- package/dist/core/fields/builders/form-field-builder.js +17 -15
- package/dist/core/fields/util.js +1 -1
- package/dist/core/handlers/index.js +2 -2
- package/dist/core/operations/blocks/extract.server.js +1 -1
- package/dist/core/operations/hooks/before-read/process-document-fields.server.js +3 -3
- 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/set-default-values.server.js +3 -3
- package/dist/core/operations/hooks/before-upsert/validate-fields.server.d.ts +1 -1
- package/dist/core/operations/hooks/before-upsert/validate-fields.server.js +7 -7
- package/dist/core/operations/hooks/index.server.d.ts +0 -4
- package/dist/core/operations/hooks/index.server.js +0 -4
- package/dist/core/operations/shared/fallback-data-from-original.js +1 -1
- package/dist/core/operations/tree/extract.server.js +1 -1
- package/dist/core/plugins/api-init/index.d.ts +2 -0
- package/dist/core/plugins/api-init/index.js +1 -0
- package/dist/core/plugins/api-init/{index.server.d.ts → module.server.d.ts} +0 -1
- package/dist/core/plugins/api-init/{index.server.js → module.server.js} +2 -3
- package/dist/core/plugins/cache/index.d.ts +2 -5
- package/dist/core/plugins/cache/index.js +1 -21
- package/dist/core/plugins/cache/module.d.ts +4 -0
- package/dist/core/plugins/cache/module.js +22 -0
- package/dist/core/plugins/cache/{index.server.d.ts → module.server.d.ts} +1 -2
- package/dist/core/plugins/cache/{index.server.js → module.server.js} +0 -1
- package/dist/core/plugins/index.d.ts +1 -8
- package/dist/core/plugins/index.js +0 -3
- package/dist/core/plugins/mailer/index.d.ts +2 -0
- package/dist/core/plugins/mailer/index.js +1 -0
- package/dist/core/plugins/mailer/{index.server.d.ts → module.server.d.ts} +0 -1
- package/dist/core/plugins/mailer/{index.server.js → module.server.js} +0 -1
- package/dist/core/plugins/sse/index.d.ts +2 -0
- package/dist/core/plugins/sse/index.js +1 -0
- package/dist/core/plugins/sse/{index.server.d.ts → module.server.d.ts} +0 -1
- package/dist/core/plugins/sse/{index.server.js → module.server.js} +0 -1
- package/dist/core/rime.server.d.ts +16 -16
- package/dist/fields/blocks/index.d.ts +1 -1
- package/dist/fields/blocks/index.js +5 -2
- package/dist/fields/checkbox/index.d.ts +1 -1
- package/dist/fields/checkbox/index.js +3 -2
- package/dist/fields/combobox/index.d.ts +1 -1
- package/dist/fields/combobox/index.js +4 -2
- package/dist/fields/date/index.d.ts +2 -2
- package/dist/fields/date/index.js +7 -5
- package/dist/fields/email/index.d.ts +3 -3
- package/dist/fields/email/index.js +9 -8
- package/dist/fields/group/component/Group.svelte +1 -1
- package/dist/fields/group/index.d.ts +1 -1
- package/dist/fields/group/index.js +4 -2
- package/dist/fields/link/index.d.ts +1 -1
- package/dist/fields/link/index.js +63 -56
- package/dist/fields/link/module.server.d.ts +2 -0
- package/dist/fields/link/{runtime.server.js → module.server.js} +0 -8
- package/dist/fields/number/index.d.ts +1 -1
- package/dist/fields/number/index.js +3 -2
- package/dist/fields/radio/index.d.ts +1 -1
- package/dist/fields/radio/index.js +4 -2
- package/dist/fields/relation/index.d.ts +2 -6
- package/dist/fields/relation/index.js +64 -75
- package/dist/fields/relation/{runtime.d.ts → module.d.ts} +2 -2
- package/dist/fields/relation/module.js +4 -0
- package/dist/fields/relation/module.server.d.ts +5 -0
- package/dist/fields/relation/{runtime.server.js → module.server.js} +3 -6
- package/dist/fields/rich-text/index.d.ts +1 -1
- package/dist/fields/rich-text/index.js +3 -2
- package/dist/fields/select/index.d.ts +1 -1
- package/dist/fields/select/index.js +4 -1
- package/dist/fields/slug/index.d.ts +1 -1
- package/dist/fields/slug/index.js +3 -2
- package/dist/fields/tabs/index.d.ts +1 -1
- package/dist/fields/tabs/index.js +10 -2
- package/dist/fields/text/index.d.ts +1 -1
- package/dist/fields/text/index.js +3 -2
- package/dist/fields/textarea/index.d.ts +1 -1
- package/dist/fields/textarea/index.js +3 -2
- package/dist/fields/time/index.d.ts +1 -1
- package/dist/fields/time/index.js +3 -2
- package/dist/fields/toggle/index.d.ts +1 -1
- package/dist/fields/toggle/index.js +3 -3
- package/dist/fields/tree/index.d.ts +1 -1
- package/dist/fields/tree/index.js +4 -2
- package/dist/index.d.ts +3 -3
- package/dist/index.js +3 -3
- package/dist/panel/components/fields/RenderFields.svelte +1 -1
- package/dist/panel/context/collection.svelte.js +5 -3
- package/dist/panel/context/config.svelte.d.ts +2 -2
- package/dist/panel/context/documentForm.svelte.d.ts +2 -2
- package/dist/panel/context/documentForm.svelte.js +47 -28
- package/dist/panel/context/form.svelte.js +3 -3
- package/dist/panel/context/live.svelte.js +1 -1
- package/dist/panel/pages/auth/sign-in/SignIn.svelte +6 -1
- package/dist/server.d.ts +4 -4
- package/dist/server.js +4 -4
- package/dist/types.d.ts +1 -1
- package/dist/util/doc.js +1 -1
- package/package.json +2 -9
- package/dist/fields/blocks/index.server.d.ts +0 -3
- package/dist/fields/blocks/index.server.js +0 -5
- package/dist/fields/checkbox/index.server.d.ts +0 -3
- package/dist/fields/checkbox/index.server.js +0 -3
- package/dist/fields/combobox/index.server.d.ts +0 -3
- package/dist/fields/combobox/index.server.js +0 -4
- package/dist/fields/date/index.server.d.ts +0 -3
- package/dist/fields/date/index.server.js +0 -3
- package/dist/fields/email/index.server.d.ts +0 -4
- package/dist/fields/email/index.server.js +0 -3
- package/dist/fields/group/index.server.d.ts +0 -2
- package/dist/fields/group/index.server.js +0 -12
- package/dist/fields/index.server.d.ts +0 -14
- package/dist/fields/index.server.js +0 -65
- package/dist/fields/link/runtime.server.d.ts +0 -5
- package/dist/fields/number/index.server.d.ts +0 -3
- package/dist/fields/number/index.server.js +0 -3
- package/dist/fields/radio/index.server.d.ts +0 -3
- package/dist/fields/radio/index.server.js +0 -4
- package/dist/fields/relation/runtime.js +0 -4
- package/dist/fields/relation/runtime.server.d.ts +0 -8
- package/dist/fields/rich-text/index.server.d.ts +0 -3
- package/dist/fields/rich-text/index.server.js +0 -3
- package/dist/fields/select/index.server.d.ts +0 -3
- package/dist/fields/select/index.server.js +0 -4
- package/dist/fields/slug/index.server.d.ts +0 -3
- package/dist/fields/slug/index.server.js +0 -3
- package/dist/fields/tabs/index.server.d.ts +0 -3
- package/dist/fields/tabs/index.server.js +0 -18
- package/dist/fields/text/index.server.d.ts +0 -3
- package/dist/fields/text/index.server.js +0 -3
- package/dist/fields/textarea/index.server.d.ts +0 -3
- package/dist/fields/textarea/index.server.js +0 -3
- package/dist/fields/time/index.server.d.ts +0 -3
- package/dist/fields/time/index.server.js +0 -3
- package/dist/fields/toggle/index.server.d.ts +0 -3
- package/dist/fields/toggle/index.server.js +0 -3
- package/dist/fields/tree/index.server.d.ts +0 -3
- package/dist/fields/tree/index.server.js +0 -4
- /package/dist/fields/link/{runtime.d.ts → module.d.ts} +0 -0
- /package/dist/fields/link/{runtime.js → module.js} +0 -0
|
@@ -6,14 +6,16 @@ const stringToDate = (value) => {
|
|
|
6
6
|
return new Date(value);
|
|
7
7
|
};
|
|
8
8
|
export class DateFieldBuilder extends FormFieldBuilder {
|
|
9
|
-
//
|
|
10
|
-
_metaUrl = import.meta.url;
|
|
11
9
|
constructor(name) {
|
|
12
10
|
super(name, 'date');
|
|
11
|
+
this.field.defaultValue = () => new Date();
|
|
13
12
|
this.field.hooks = {
|
|
14
13
|
beforeValidate: [stringToDate]
|
|
15
14
|
};
|
|
16
15
|
}
|
|
16
|
+
get dataType() {
|
|
17
|
+
return 'timestamp';
|
|
18
|
+
}
|
|
17
19
|
get component() {
|
|
18
20
|
return DateComponent;
|
|
19
21
|
}
|
|
@@ -24,11 +26,11 @@ export class DateFieldBuilder extends FormFieldBuilder {
|
|
|
24
26
|
this.field.defaultValue = value;
|
|
25
27
|
return this;
|
|
26
28
|
}
|
|
27
|
-
get dataType() {
|
|
28
|
-
return 'timestamp';
|
|
29
|
-
}
|
|
30
29
|
isTitle() {
|
|
31
30
|
this.field.isTitle = true;
|
|
32
31
|
return this;
|
|
33
32
|
}
|
|
33
|
+
generateType() {
|
|
34
|
+
return `${this.name}${this.get.required ? '' : '?'}: Date`;
|
|
35
|
+
}
|
|
34
36
|
}
|
|
@@ -2,14 +2,14 @@ import type { DataType } from '../../core/fields/builders/form-field-builder.js'
|
|
|
2
2
|
import { FormFieldBuilder } from '../../core/fields/builders/form-field-builder.js';
|
|
3
3
|
import type { DefaultValueFn, FormField } from '../types.js';
|
|
4
4
|
export declare class EmailFieldBuilder extends FormFieldBuilder<EmailField> {
|
|
5
|
-
_metaUrl: string;
|
|
6
5
|
constructor(name: string);
|
|
7
|
-
|
|
6
|
+
get dataType(): DataType;
|
|
8
7
|
get component(): import("svelte").Component<import("./component/props").EmailFieldProps, {}, "">;
|
|
8
|
+
layout(layout: 'compact' | 'default'): this;
|
|
9
9
|
unique(bool?: boolean): this;
|
|
10
10
|
defaultValue(value: string | DefaultValueFn<string>): this;
|
|
11
|
-
get dataType(): DataType;
|
|
12
11
|
isTitle(): this;
|
|
12
|
+
protected generateType(): string;
|
|
13
13
|
}
|
|
14
14
|
export declare const email: (name: string) => EmailFieldBuilder;
|
|
15
15
|
/****************************************************/
|
|
@@ -3,8 +3,6 @@ import { sanitize } from '../../util/string.js';
|
|
|
3
3
|
import validate from '../../util/validate.js';
|
|
4
4
|
import EmailComp from './component/Email.svelte';
|
|
5
5
|
export class EmailFieldBuilder extends FormFieldBuilder {
|
|
6
|
-
//
|
|
7
|
-
_metaUrl = import.meta.url;
|
|
8
6
|
constructor(name) {
|
|
9
7
|
super(name, 'email');
|
|
10
8
|
this.field.validate = validate.email;
|
|
@@ -12,13 +10,16 @@ export class EmailFieldBuilder extends FormFieldBuilder {
|
|
|
12
10
|
beforeSave: [sanitize]
|
|
13
11
|
};
|
|
14
12
|
}
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
return this;
|
|
13
|
+
get dataType() {
|
|
14
|
+
return 'text';
|
|
18
15
|
}
|
|
19
16
|
get component() {
|
|
20
17
|
return EmailComp;
|
|
21
18
|
}
|
|
19
|
+
layout(layout) {
|
|
20
|
+
this.field.layout = layout;
|
|
21
|
+
return this;
|
|
22
|
+
}
|
|
22
23
|
unique(bool) {
|
|
23
24
|
this.field.unique = typeof bool === 'boolean' ? bool : true;
|
|
24
25
|
return this;
|
|
@@ -27,12 +28,12 @@ export class EmailFieldBuilder extends FormFieldBuilder {
|
|
|
27
28
|
this.field.defaultValue = value;
|
|
28
29
|
return this;
|
|
29
30
|
}
|
|
30
|
-
get dataType() {
|
|
31
|
-
return 'text';
|
|
32
|
-
}
|
|
33
31
|
isTitle() {
|
|
34
32
|
this.field.isTitle = true;
|
|
35
33
|
return this;
|
|
36
34
|
}
|
|
35
|
+
generateType() {
|
|
36
|
+
return `${this.name}${this.get.required ? '' : '?'}: string`;
|
|
37
|
+
}
|
|
37
38
|
}
|
|
38
39
|
export const email = (name) => new EmailFieldBuilder(name);
|
|
@@ -45,7 +45,7 @@
|
|
|
45
45
|
.filter((field) => !(field instanceof TabsBuilder))
|
|
46
46
|
.filter((field) => field instanceof FormFieldBuilder)
|
|
47
47
|
.filter((field) => !form.isLive || (form.isLive && field.get.live))
|
|
48
|
-
.filter((field) => field.
|
|
48
|
+
.filter((field) => field.use.accessRead(user.attributes, { id: form.values.id }));
|
|
49
49
|
});
|
|
50
50
|
|
|
51
51
|
const basePath = $derived(path ? `${path}.` : '');
|
|
@@ -3,7 +3,6 @@ import { FormFieldBuilder } from '../../core/fields/builders/form-field-builder.
|
|
|
3
3
|
import type { Field, FieldsPreviewProps, FormField } from '../types.js';
|
|
4
4
|
import type { Component } from 'svelte';
|
|
5
5
|
export declare class GroupFieldBuilder extends FormFieldBuilder<GroupField> {
|
|
6
|
-
_metaUrl: string;
|
|
7
6
|
constructor(name: string);
|
|
8
7
|
get component(): Component<{
|
|
9
8
|
path: string;
|
|
@@ -66,6 +65,7 @@ export declare class GroupFieldBuilder extends FormFieldBuilder<GroupField> {
|
|
|
66
65
|
_root?: boolean;
|
|
67
66
|
preview?: Component<FieldsPreviewProps>;
|
|
68
67
|
};
|
|
68
|
+
protected generateType(): string;
|
|
69
69
|
}
|
|
70
70
|
export declare const group: (name: string) => GroupFieldBuilder;
|
|
71
71
|
/**
|
|
@@ -7,8 +7,6 @@ const isEmpty = (value) => !!value === false ||
|
|
|
7
7
|
Object.getPrototypeOf(value) === Object.prototype &&
|
|
8
8
|
Object.keys(value).length === 0);
|
|
9
9
|
export class GroupFieldBuilder extends FormFieldBuilder {
|
|
10
|
-
//
|
|
11
|
-
_metaUrl = import.meta.url;
|
|
12
10
|
constructor(name) {
|
|
13
11
|
super(name, 'group');
|
|
14
12
|
this.field.isEmpty = isEmpty;
|
|
@@ -41,6 +39,10 @@ export class GroupFieldBuilder extends FormFieldBuilder {
|
|
|
41
39
|
compile() {
|
|
42
40
|
return { ...this.field, fields: this.field.fields.map((f) => f.compile()) };
|
|
43
41
|
}
|
|
42
|
+
generateType() {
|
|
43
|
+
const fieldsTypes = this.field.fields.map((field) => field.use.generateType()).filter(Boolean);
|
|
44
|
+
return this.field.fields.length ? `${this.name}: {${fieldsTypes.join(',\n\t')}}` : '';
|
|
45
|
+
}
|
|
44
46
|
}
|
|
45
47
|
export const group = (name) => new GroupFieldBuilder(name);
|
|
46
48
|
/**
|
|
@@ -3,7 +3,6 @@ import { FormFieldBuilder } from '../../core/fields/builders/form-field-builder.
|
|
|
3
3
|
import type { DefaultValueFn, FormField } from '../types.js';
|
|
4
4
|
import type { Link, LinkType } from './types.js';
|
|
5
5
|
export declare class LinkFieldBuilder extends FormFieldBuilder<LinkField> {
|
|
6
|
-
_metaUrl: string;
|
|
7
6
|
constructor(name: string);
|
|
8
7
|
get component(): import("svelte").Component<import("./component/props").LinkFieldProps, {}, "">;
|
|
9
8
|
get cell(): import("svelte").Component<{
|
|
@@ -63,6 +62,7 @@ export declare class LinkFieldBuilder extends FormFieldBuilder<LinkField> {
|
|
|
63
62
|
value: any;
|
|
64
63
|
}> | null;
|
|
65
64
|
};
|
|
65
|
+
protected generateType(): string;
|
|
66
66
|
}
|
|
67
67
|
export declare const link: (name: string) => LinkFieldBuilder;
|
|
68
68
|
/****************************************************/
|
|
@@ -3,63 +3,70 @@ import { sanitize } from '../../util/string.js';
|
|
|
3
3
|
import validate from '../../util/validate.js';
|
|
4
4
|
import Cell from './component/Cell.svelte';
|
|
5
5
|
import LinkComp from './component/Link.svelte';
|
|
6
|
-
|
|
7
|
-
// relation/runtime.server.ts (real check) or relation/runtime.ts (client no-op)
|
|
8
|
-
import { populateRessourceURL } from '$rime/runtime';
|
|
6
|
+
import { populateRessourceURL } from "$rime/modules/rimecms/fields/link";
|
|
9
7
|
export class LinkFieldBuilder extends FormFieldBuilder {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
beforeSave: [LinkFieldBuilder.sanitize],
|
|
20
|
-
beforeRead: [populateRessourceURL]
|
|
21
|
-
};
|
|
22
|
-
}
|
|
23
|
-
get component() {
|
|
24
|
-
return LinkComp;
|
|
25
|
-
}
|
|
26
|
-
get cell() {
|
|
27
|
-
return Cell;
|
|
28
|
-
}
|
|
29
|
-
layout(str) {
|
|
30
|
-
this.field.layout = str;
|
|
31
|
-
return this;
|
|
32
|
-
}
|
|
33
|
-
defaultValue(value) {
|
|
34
|
-
this.field.defaultValue = value;
|
|
35
|
-
return this;
|
|
36
|
-
}
|
|
37
|
-
get dataType() {
|
|
38
|
-
return 'json';
|
|
39
|
-
}
|
|
40
|
-
types(...values) {
|
|
41
|
-
this.field.types = values;
|
|
42
|
-
return this;
|
|
43
|
-
}
|
|
44
|
-
static sanitize = (link) => {
|
|
45
|
-
if (!link)
|
|
46
|
-
return undefined;
|
|
47
|
-
// Sanitize only the value and url properties of the link, other properties are left as is
|
|
48
|
-
const isLinkValue = (v) => typeof v === 'object' && !Array.isArray(v) && 'value' in v;
|
|
49
|
-
if (isLinkValue(link)) {
|
|
50
|
-
return {
|
|
51
|
-
...link,
|
|
52
|
-
url: link.url ? sanitize(link.url) : undefined,
|
|
53
|
-
value: link.value ? sanitize(link.value) : null
|
|
54
|
-
};
|
|
55
|
-
}
|
|
56
|
-
return undefined;
|
|
8
|
+
constructor(name) {
|
|
9
|
+
super(name, 'link');
|
|
10
|
+
this.field.isEmpty = link => !link || typeof link === 'object' && 'value' in link && !link.value;
|
|
11
|
+
this.field.validate = validate.link;
|
|
12
|
+
this.field.layout = 'default';
|
|
13
|
+
this.field.types = ['url'];
|
|
14
|
+
this.field.hooks = {
|
|
15
|
+
beforeSave: [LinkFieldBuilder.sanitize],
|
|
16
|
+
beforeRead: [populateRessourceURL]
|
|
57
17
|
};
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
18
|
+
}
|
|
19
|
+
get component() {
|
|
20
|
+
return LinkComp;
|
|
21
|
+
}
|
|
22
|
+
get cell() {
|
|
23
|
+
return Cell;
|
|
24
|
+
}
|
|
25
|
+
layout(str) {
|
|
26
|
+
this.field.layout = str;
|
|
27
|
+
return this;
|
|
28
|
+
}
|
|
29
|
+
defaultValue(value) {
|
|
30
|
+
this.field.defaultValue = value;
|
|
31
|
+
return this;
|
|
32
|
+
}
|
|
33
|
+
get dataType() {
|
|
34
|
+
return 'json';
|
|
35
|
+
}
|
|
36
|
+
types(...values) {
|
|
37
|
+
this.field.types = values;
|
|
38
|
+
return this;
|
|
39
|
+
}
|
|
40
|
+
static sanitize = link => {
|
|
41
|
+
if (!link) return undefined;
|
|
42
|
+
// Sanitize only the value and url properties of the link, other properties are left as is
|
|
43
|
+
const isLinkValue = v => typeof v === 'object' && !Array.isArray(v) && 'value' in v;
|
|
44
|
+
if (isLinkValue(link)) {
|
|
45
|
+
return {
|
|
46
|
+
...link,
|
|
47
|
+
url: link.url ? sanitize(link.url) : undefined,
|
|
48
|
+
value: link.value ? sanitize(link.value) : null
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
return undefined;
|
|
52
|
+
};
|
|
53
|
+
compile() {
|
|
54
|
+
if (!this.field.defaultValue) {
|
|
55
|
+
this.field.defaultValue = {
|
|
56
|
+
value: '',
|
|
57
|
+
target: '_self',
|
|
58
|
+
type: this.field.types[0]
|
|
59
|
+
};
|
|
63
60
|
}
|
|
61
|
+
return super.compile();
|
|
62
|
+
}
|
|
63
|
+
generateType() {
|
|
64
|
+
return `${this.name}${this.get.required ? '' : '?'}: {
|
|
65
|
+
type: ${this.get.types.map(t => `'${t}'`).join(' | ')};
|
|
66
|
+
value: string | null;
|
|
67
|
+
target: '_self' | '_blank';
|
|
68
|
+
url?: string;
|
|
69
|
+
}`;
|
|
70
|
+
}
|
|
64
71
|
}
|
|
65
|
-
export const link =
|
|
72
|
+
export const link = name => new LinkFieldBuilder(name);
|
|
@@ -1,14 +1,6 @@
|
|
|
1
1
|
import { RimeError } from '../../core/errors/index.js';
|
|
2
2
|
import { logger } from '../../core/logger/index.server.js';
|
|
3
3
|
import { trycatch } from '../../util/function.js';
|
|
4
|
-
export const toType = (field) => {
|
|
5
|
-
return `${field.name}${field.get.required ? '' : '?'}: {
|
|
6
|
-
type: ${field.get.types.map((t) => `'${t}'`).join(' | ')};
|
|
7
|
-
value: string | null;
|
|
8
|
-
target: '_self' | '_blank';
|
|
9
|
-
url?: string;
|
|
10
|
-
}`;
|
|
11
|
-
};
|
|
12
4
|
export const populateRessourceURL = async (link, { event, documentId, operation }) => {
|
|
13
5
|
if (!link)
|
|
14
6
|
return link;
|
|
@@ -3,7 +3,6 @@ import { FormFieldBuilder } from '../../core/fields/builders/form-field-builder.
|
|
|
3
3
|
import type { DefaultValueFn, FieldValidationFunc, FormField } from '../types.js';
|
|
4
4
|
export declare const number: (name: string) => NumberFieldBuilder;
|
|
5
5
|
export declare class NumberFieldBuilder extends FormFieldBuilder<NumberField> {
|
|
6
|
-
_metaUrl: string;
|
|
7
6
|
constructor(name: string);
|
|
8
7
|
get component(): import("svelte").Component<import("./component/props").NumberFieldProps, {}, "">;
|
|
9
8
|
defaultValue(value: number | DefaultValueFn<number>): this;
|
|
@@ -54,6 +53,7 @@ export declare class NumberFieldBuilder extends FormFieldBuilder<NumberField> {
|
|
|
54
53
|
value: any;
|
|
55
54
|
}> | null;
|
|
56
55
|
};
|
|
56
|
+
protected generateType(): string;
|
|
57
57
|
}
|
|
58
58
|
/****************************************************/
|
|
59
59
|
export type NumberField = FormField & {
|
|
@@ -14,8 +14,6 @@ const validateNumber = (value, { config }) => {
|
|
|
14
14
|
return true;
|
|
15
15
|
};
|
|
16
16
|
export class NumberFieldBuilder extends FormFieldBuilder {
|
|
17
|
-
//
|
|
18
|
-
_metaUrl = import.meta.url;
|
|
19
17
|
constructor(name) {
|
|
20
18
|
super(name, 'number');
|
|
21
19
|
this.field.validate = validateNumber;
|
|
@@ -45,4 +43,7 @@ export class NumberFieldBuilder extends FormFieldBuilder {
|
|
|
45
43
|
}
|
|
46
44
|
return super.compile();
|
|
47
45
|
}
|
|
46
|
+
generateType() {
|
|
47
|
+
return `${this.name}${this.get.required ? '' : '?'}: number`;
|
|
48
|
+
}
|
|
48
49
|
}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import type { DefaultValueFn, FormField, Option } from '../types.js';
|
|
2
2
|
import { PickOneFieldBuilder } from '../../core/fields/builders/select-builder.js';
|
|
3
3
|
export declare class RadioFieldBuilder extends PickOneFieldBuilder<RadioField> {
|
|
4
|
-
_metaUrl: string;
|
|
5
4
|
constructor(name: string);
|
|
6
5
|
get component(): import("svelte").Component<import("./component/props.js").RadioFieldProps, {}, "">;
|
|
7
6
|
layout(value: 'default' | 'row'): this;
|
|
8
7
|
compile(): RadioField;
|
|
8
|
+
protected generateType(): string;
|
|
9
9
|
}
|
|
10
10
|
export declare const radio: (name: string) => RadioFieldBuilder;
|
|
11
11
|
/****************************************************/
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import { PickOneFieldBuilder } from '../../core/fields/builders/select-builder.js';
|
|
2
2
|
import Radio from './component/Radio.svelte';
|
|
3
3
|
export class RadioFieldBuilder extends PickOneFieldBuilder {
|
|
4
|
-
//
|
|
5
|
-
_metaUrl = import.meta.url;
|
|
6
4
|
constructor(name) {
|
|
7
5
|
super(name, 'radio');
|
|
8
6
|
this.field.many = false;
|
|
@@ -23,5 +21,9 @@ export class RadioFieldBuilder extends PickOneFieldBuilder {
|
|
|
23
21
|
}
|
|
24
22
|
return this.field;
|
|
25
23
|
}
|
|
24
|
+
generateType() {
|
|
25
|
+
const optionsString = this.get.options.map((option) => `'${option.value}'`).join(' | ');
|
|
26
|
+
return `${this.name}${this.get.required ? '' : '?'}: ${optionsString}`;
|
|
27
|
+
}
|
|
26
28
|
}
|
|
27
29
|
export const radio = (name) => new RadioFieldBuilder(name);
|
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
import type { DataType } from '../../core/fields/builders/form-field-builder.js';
|
|
2
2
|
import { FormFieldBuilder } from '../../core/fields/builders/form-field-builder.js';
|
|
3
3
|
import type { CollectionSlug, GenericDoc } from '../../core/types/doc.js';
|
|
4
|
-
import type { DefaultValueFn,
|
|
4
|
+
import type { DefaultValueFn, FormField, RelationRef, RelationValue } from '../types.js';
|
|
5
5
|
import type { RegisterCollection } from '../../index.js';
|
|
6
6
|
import type { WithOptional } from '../../util/types.js';
|
|
7
7
|
export declare class RelationFieldBuilder<Doc extends GenericDoc = GenericDoc> extends FormFieldBuilder<RelationField<Doc>> {
|
|
8
|
-
_metaUrl: string;
|
|
9
8
|
constructor(name: string);
|
|
10
9
|
get component(): import("svelte").Component<{
|
|
11
10
|
path: string;
|
|
@@ -27,12 +26,9 @@ export declare class RelationFieldBuilder<Doc extends GenericDoc = GenericDoc> e
|
|
|
27
26
|
/** Documentation only — relation fields are diverted into relationFieldsMap/junction
|
|
28
27
|
* tables before reaching the adapter's generic column renderer (see root.server.ts). */
|
|
29
28
|
get dataType(): DataType;
|
|
29
|
+
protected generateType(): string;
|
|
30
30
|
}
|
|
31
31
|
export declare const relation: (name: string) => RelationFieldBuilder<GenericDoc>;
|
|
32
|
-
/**
|
|
33
|
-
* Checks if a field is a relation field.
|
|
34
|
-
*/
|
|
35
|
-
export declare const isRelationField: (field: Field) => field is RelationField;
|
|
36
32
|
/**
|
|
37
33
|
* Checks if a relation value is resolved (contains the actual referenced document).
|
|
38
34
|
*
|
|
@@ -1,58 +1,54 @@
|
|
|
1
1
|
import { FormFieldBuilder } from '../../core/fields/builders/form-field-builder.js';
|
|
2
2
|
import { hasProps, isObjectLiteral } from '../../util/object.js';
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
import { ensureRelationExists } from '$rime/runtime';
|
|
3
|
+
import { capitalize } from '../../util/string.js';
|
|
4
|
+
import { ensureRelationExists } from "$rime/modules/rimecms/fields/relation";
|
|
6
5
|
import Cell from './component/Cell.svelte';
|
|
7
6
|
import RelationComponent from './component/Relation.svelte';
|
|
8
7
|
export class RelationFieldBuilder extends FormFieldBuilder {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
}
|
|
8
|
+
constructor(name) {
|
|
9
|
+
super(name, 'relation');
|
|
10
|
+
this.field.isEmpty = value => !value || Array.isArray(value) && value.length === 0;
|
|
11
|
+
this.field.defaultValue = [];
|
|
12
|
+
this.field.hooks = {
|
|
13
|
+
beforeValidate: [ensureRelationExists]
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
get component() {
|
|
17
|
+
return RelationComponent;
|
|
18
|
+
}
|
|
19
|
+
get cell() {
|
|
20
|
+
return Cell;
|
|
21
|
+
}
|
|
22
|
+
isThumbnail(bool = true) {
|
|
23
|
+
this.field.isThumbnail = bool;
|
|
24
|
+
return this;
|
|
25
|
+
}
|
|
26
|
+
query(query) {
|
|
27
|
+
this.field.query = query;
|
|
28
|
+
return this;
|
|
29
|
+
}
|
|
30
|
+
to(slug) {
|
|
31
|
+
this.field.relationTo = slug;
|
|
32
|
+
return this;
|
|
33
|
+
}
|
|
34
|
+
many() {
|
|
35
|
+
this.field.many = true;
|
|
36
|
+
return this;
|
|
37
|
+
}
|
|
38
|
+
defaultValue(value) {
|
|
39
|
+
this.field.defaultValue = value;
|
|
40
|
+
return this;
|
|
41
|
+
}
|
|
42
|
+
/** Documentation only — relation fields are diverted into relationFieldsMap/junction
|
|
43
|
+
* tables before reaching the adapter's generic column renderer (see root.server.ts). */
|
|
44
|
+
get dataType() {
|
|
45
|
+
return 'json';
|
|
46
|
+
}
|
|
47
|
+
generateType() {
|
|
48
|
+
return `${this.name}${this.get.required ? '' : '?'}: RelationValue<${capitalize(this.get.relationTo)}Doc>`;
|
|
49
|
+
}
|
|
50
50
|
}
|
|
51
|
-
export const relation =
|
|
52
|
-
/**
|
|
53
|
-
* Checks if a field is a relation field.
|
|
54
|
-
*/
|
|
55
|
-
export const isRelationField = (field) => field.type === 'relation';
|
|
51
|
+
export const relation = name => new RelationFieldBuilder(name);
|
|
56
52
|
/**
|
|
57
53
|
* Checks if a relation value is resolved (contains the actual referenced document).
|
|
58
54
|
*
|
|
@@ -60,8 +56,8 @@ export const isRelationField = (field) => field.type === 'relation';
|
|
|
60
56
|
* // Returns true for a resolved relation
|
|
61
57
|
* isRelationResolved({ title: 'Home Page', _prototype: 'collection', _type: 'pages' });
|
|
62
58
|
*/
|
|
63
|
-
export const isRelationResolved =
|
|
64
|
-
|
|
59
|
+
export const isRelationResolved = value => {
|
|
60
|
+
return value && isObjectLiteral(value) && hasProps(['title', '_prototype', '_type'], value);
|
|
65
61
|
};
|
|
66
62
|
/**
|
|
67
63
|
* Checks if a relation value is a reference (contains only the relationTo and documentId).
|
|
@@ -70,10 +66,7 @@ export const isRelationResolved = (value) => {
|
|
|
70
66
|
* // Returns true for a relation reference
|
|
71
67
|
* isRelationRef({ relationTo: 'pages', documentId: '123' });
|
|
72
68
|
*/
|
|
73
|
-
export const isRelationRef =
|
|
74
|
-
value !== null &&
|
|
75
|
-
typeof value.relationTo === 'string' &&
|
|
76
|
-
typeof value.documentId === 'string';
|
|
69
|
+
export const isRelationRef = value => typeof value === 'object' && value !== null && typeof value.relationTo === 'string' && typeof value.documentId === 'string';
|
|
77
70
|
/**
|
|
78
71
|
* Checks if a relation value is unresolved (contains only reference information).
|
|
79
72
|
*
|
|
@@ -81,8 +74,8 @@ export const isRelationRef = (value) => typeof value === 'object' &&
|
|
|
81
74
|
* // Returns true for an unresolved relation
|
|
82
75
|
* isRelationUnresolved({ relationTo: 'pages', documentId: '123' });
|
|
83
76
|
*/
|
|
84
|
-
export const isRelationUnresolved =
|
|
85
|
-
|
|
77
|
+
export const isRelationUnresolved = value => {
|
|
78
|
+
return value && isObjectLiteral(value) && hasProps(['relationTo', 'documentId'], value);
|
|
86
79
|
};
|
|
87
80
|
/**
|
|
88
81
|
* Resolves a relation reference to the actual document it points to.
|
|
@@ -92,19 +85,16 @@ export const isRelationUnresolved = (value) => {
|
|
|
92
85
|
* const doc = await resolveRelationRef({ relationTo: 'pages', documentId: '123' });
|
|
93
86
|
*/
|
|
94
87
|
export async function resolveRelationRef(item) {
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
return item;
|
|
106
|
-
}
|
|
107
|
-
throw new Error(`Unrecognized relation shape: ${JSON.stringify(item)}`);
|
|
88
|
+
if (isRelationRef(item)) {
|
|
89
|
+
return fetch(`api/${item.relationTo}/${item.documentId}`).then(r => r.json()).then(r => r.doc);
|
|
90
|
+
}
|
|
91
|
+
if (typeof item === 'string') {
|
|
92
|
+
throw new Error(`Cannot resolve relation from a bare id ("${item}") — missing "relationTo". ` + `resolveRelationRef only works on populated docs or { relationTo, documentId } objects.`);
|
|
93
|
+
}
|
|
94
|
+
if (isRelationResolved(item)) {
|
|
95
|
+
return item;
|
|
96
|
+
}
|
|
97
|
+
throw new Error(`Unrecognized relation shape: ${JSON.stringify(item)}`);
|
|
108
98
|
}
|
|
109
99
|
/**
|
|
110
100
|
* Resolves a relation field value to the actual documents it points to.
|
|
@@ -114,8 +104,7 @@ export async function resolveRelationRef(item) {
|
|
|
114
104
|
* const docs = await resolveRelation([{ relationTo: 'pages', documentId: '123' }]);
|
|
115
105
|
*/
|
|
116
106
|
export async function resolveRelation(value) {
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
}
|
|
107
|
+
if (value === null || value === undefined) return value;
|
|
108
|
+
const items = Array.isArray(value) ? value : [value];
|
|
109
|
+
return Promise.all(items.map(item => resolveRelationRef(item)));
|
|
110
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { FieldHookShared } from '../types.js';
|
|
2
|
-
/** Client-side no-op — resolved via `$rime/
|
|
2
|
+
/** Client-side no-op — resolved via `$rime/fields/relation` when bundling for the browser (see
|
|
3
3
|
* relation/index.ts). The panel never needs to validate a relation actually exists;
|
|
4
|
-
* the real check (relation/
|
|
4
|
+
* the real check (relation/module.server.ts) runs server-side before any write lands. */
|
|
5
5
|
export declare const ensureRelationExists: FieldHookShared;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
/** Client-side no-op — resolved via `$rime/fields/relation` when bundling for the browser (see
|
|
2
|
+
* relation/index.ts). The panel never needs to validate a relation actually exists;
|
|
3
|
+
* the real check (relation/module.server.ts) runs server-side before any write lands. */
|
|
4
|
+
export const ensureRelationExists = async (value) => value;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { FieldHookShared } from '../types.js';
|
|
2
|
+
/** Real implementation — resolved server-side via `$rime/fields/relation` (see relation/index.ts,
|
|
3
|
+
* relation/module.ts for the client-side no-op counterpart). Uses a plain static import of
|
|
4
|
+
* `$app/server`, which SvelteKit's build blocks from ever reaching client code. */
|
|
5
|
+
export declare const ensureRelationExists: FieldHookShared;
|
|
@@ -2,12 +2,9 @@ import { getRequestEvent } from '$app/server';
|
|
|
2
2
|
import { env } from '$env/dynamic/public';
|
|
3
3
|
import { PARAMS } from '../../core/constant.js';
|
|
4
4
|
import { trycatchFetch } from '../../util/function.js';
|
|
5
|
-
import {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
};
|
|
9
|
-
/** Real implementation — resolved server-side via `$rime/runtime` (see relation/index.ts,
|
|
10
|
-
* relation/runtime.ts for the client-side no-op counterpart). Uses a plain static import of
|
|
5
|
+
import { toKebabCase } from '../../util/string.js';
|
|
6
|
+
/** Real implementation — resolved server-side via `$rime/fields/relation` (see relation/index.ts,
|
|
7
|
+
* relation/module.ts for the client-side no-op counterpart). Uses a plain static import of
|
|
11
8
|
* `$app/server`, which SvelteKit's build blocks from ever reaching client code. */
|
|
12
9
|
export const ensureRelationExists = async (value, { config }) => {
|
|
13
10
|
const output = [];
|
|
@@ -4,7 +4,6 @@ import type { DefaultValueFn, FormField } from '../types.js';
|
|
|
4
4
|
import type { JSONContent } from '@tiptap/core';
|
|
5
5
|
import type { RichTextFeature } from './core/types.js';
|
|
6
6
|
export declare class RichTextFieldBuilder extends FormFieldBuilder<RichTextField> {
|
|
7
|
-
_metaUrl: string;
|
|
8
7
|
constructor(name: string);
|
|
9
8
|
get component(): import("svelte").Component<import("./component/props").RichTextFieldProps, {}, "">;
|
|
10
9
|
get cell(): import("svelte").Component<{
|
|
@@ -30,6 +29,7 @@ export declare class RichTextFieldBuilder extends FormFieldBuilder<RichTextField
|
|
|
30
29
|
static readonly stringify: (value: string) => string;
|
|
31
30
|
defaultValue(value: RichTextContent | DefaultValueFn<RichTextContent>): this;
|
|
32
31
|
get dataType(): DataType;
|
|
32
|
+
protected generateType(): string;
|
|
33
33
|
}
|
|
34
34
|
export declare const richText: (name: string) => RichTextFieldBuilder;
|
|
35
35
|
/**
|