rimecms 0.30.3 → 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 +1 -39
- package/dist/.rime-modules.d.ts +23 -0
- package/dist/.rime-modules.json +1 -0
- package/dist/adapter-sqlite/generate-schema/write.server.js +6 -6
- 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.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/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 +42 -0
- package/dist/core/dev/cli/init/index.server.js +11 -4
- package/dist/core/dev/cli/init/templates.d.ts +1 -1
- package/dist/core/dev/cli/init/templates.js +5 -3
- package/dist/core/dev/cli/util/package-manager.server.js +5 -3
- package/dist/core/dev/constants.d.ts +10 -0
- package/dist/core/dev/constants.js +15 -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 +31 -15
- package/dist/core/dev/generate/runtime/index.server.js +45 -53
- 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 +16 -39
- package/dist/core/dev/vite/index.server.js +217 -39
- package/dist/core/ensure.server.d.ts +4 -3
- package/dist/core/ensure.server.js +8 -8
- package/dist/core/handlers/index.js +2 -2
- 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/operations/hooks/index.server.d.ts +0 -4
- package/dist/core/operations/hooks/index.server.js +0 -4
- 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} +0 -1
- 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/link/index.js +59 -56
- package/dist/fields/relation/index.js +63 -70
- package/dist/index.d.ts +3 -3
- package/dist/index.js +3 -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/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/package.json +2 -2
|
@@ -2,7 +2,6 @@ import { type RequestHandler } from '@sveltejs/kit';
|
|
|
2
2
|
import { broadcast } from './broadcast.js';
|
|
3
3
|
export declare const sse: () => {
|
|
4
4
|
readonly name: "sse";
|
|
5
|
-
readonly type: "server";
|
|
6
5
|
readonly actions: {
|
|
7
6
|
readonly broadcast: (data: import("./types.js").ContentUpdatePayload) => void;
|
|
8
7
|
};
|
|
@@ -1761,13 +1761,13 @@ export declare function createRime<const C extends Config>(config: BuildConfig<C
|
|
|
1761
1761
|
$Infer: {
|
|
1762
1762
|
body: ({
|
|
1763
1763
|
permission: {
|
|
1764
|
-
readonly user?: ("
|
|
1764
|
+
readonly user?: ("create" | "update" | "delete" | "list" | "get" | "set-role" | "ban" | "impersonate" | "set-password")[] | undefined;
|
|
1765
1765
|
readonly session?: ("delete" | "list" | "revoke")[] | undefined;
|
|
1766
1766
|
};
|
|
1767
1767
|
permissions?: never | undefined;
|
|
1768
1768
|
} | {
|
|
1769
1769
|
permissions: {
|
|
1770
|
-
readonly user?: ("
|
|
1770
|
+
readonly user?: ("create" | "update" | "delete" | "list" | "get" | "set-role" | "ban" | "impersonate" | "set-password")[] | undefined;
|
|
1771
1771
|
readonly session?: ("delete" | "list" | "revoke")[] | undefined;
|
|
1772
1772
|
};
|
|
1773
1773
|
permission?: never | undefined;
|
|
@@ -1982,18 +1982,18 @@ export declare function createRime<const C extends Config>(config: BuildConfig<C
|
|
|
1982
1982
|
isValidLocale: (locale: string) => boolean;
|
|
1983
1983
|
getArea: (slug: string) => import("./config/types.js").BuiltArea;
|
|
1984
1984
|
getCollection: (slug: string) => import("./config/types.js").BuiltCollection;
|
|
1985
|
-
getBySlug: (slug: string) => import("./config/types.js").
|
|
1985
|
+
getBySlug: (slug: string) => import("./config/types.js").BuiltCollection | import("./config/types.js").BuiltArea;
|
|
1986
1986
|
isCollection: (slug?: string) => slug is import("./types/doc.js").CollectionSlug;
|
|
1987
1987
|
isArea: (slug?: string) => slug is import("./types/doc.js").AreaSlug;
|
|
1988
1988
|
getDocumentPrototype(slug: import("./types/doc.js").PrototypeSlug): "area" | "collection";
|
|
1989
1989
|
};
|
|
1990
1990
|
readonly plugins: {
|
|
1991
|
-
cache: import("./plugins/cache/
|
|
1992
|
-
sse: import("./plugins/sse/
|
|
1993
|
-
} & (C["$smtp"] extends import("./plugins/mailer/
|
|
1994
|
-
mailer: import("./plugins/mailer/
|
|
1991
|
+
cache: import("./plugins/cache/module.server.js").CacheActions;
|
|
1992
|
+
sse: import("./plugins/sse/module.server.js").SSEActions;
|
|
1993
|
+
} & (C["$smtp"] extends import("./plugins/mailer/module.server.js").SMTPConfig ? {
|
|
1994
|
+
mailer: import("./plugins/mailer/module.server.js").MailerActions;
|
|
1995
1995
|
} : Record<string, never>) & (C extends {
|
|
1996
|
-
|
|
1996
|
+
plugins: readonly (infer P)[];
|
|
1997
1997
|
} ? P extends {
|
|
1998
1998
|
name: infer N;
|
|
1999
1999
|
actions?: infer A;
|
|
@@ -2009,12 +2009,12 @@ export declare function createRime<const C extends Config>(config: BuildConfig<C
|
|
|
2009
2009
|
error: (...args: any[]) => void;
|
|
2010
2010
|
};
|
|
2011
2011
|
} & {
|
|
2012
|
-
cache: import("./plugins/cache/
|
|
2013
|
-
sse: import("./plugins/sse/
|
|
2014
|
-
} & (C["$smtp"] extends import("./plugins/mailer/
|
|
2015
|
-
mailer: import("./plugins/mailer/
|
|
2012
|
+
cache: import("./plugins/cache/module.server.js").CacheActions;
|
|
2013
|
+
sse: import("./plugins/sse/module.server.js").SSEActions;
|
|
2014
|
+
} & (C["$smtp"] extends import("./plugins/mailer/module.server.js").SMTPConfig ? {
|
|
2015
|
+
mailer: import("./plugins/mailer/module.server.js").MailerActions;
|
|
2016
2016
|
} : Record<string, never>) & (C extends {
|
|
2017
|
-
|
|
2017
|
+
plugins: readonly (infer P)[];
|
|
2018
2018
|
} ? P extends {
|
|
2019
2019
|
name: infer N;
|
|
2020
2020
|
actions?: infer A;
|
|
@@ -3767,13 +3767,13 @@ export declare function createRime<const C extends Config>(config: BuildConfig<C
|
|
|
3767
3767
|
$Infer: {
|
|
3768
3768
|
body: ({
|
|
3769
3769
|
permission: {
|
|
3770
|
-
readonly user?: ("
|
|
3770
|
+
readonly user?: ("create" | "update" | "delete" | "list" | "get" | "set-role" | "ban" | "impersonate" | "set-password")[] | undefined;
|
|
3771
3771
|
readonly session?: ("delete" | "list" | "revoke")[] | undefined;
|
|
3772
3772
|
};
|
|
3773
3773
|
permissions?: never | undefined;
|
|
3774
3774
|
} | {
|
|
3775
3775
|
permissions: {
|
|
3776
|
-
readonly user?: ("
|
|
3776
|
+
readonly user?: ("create" | "update" | "delete" | "list" | "get" | "set-role" | "ban" | "impersonate" | "set-password")[] | undefined;
|
|
3777
3777
|
readonly session?: ("delete" | "list" | "revoke")[] | undefined;
|
|
3778
3778
|
};
|
|
3779
3779
|
permission?: never | undefined;
|
|
@@ -4004,7 +4004,7 @@ export declare function createRime<const C extends Config>(config: BuildConfig<C
|
|
|
4004
4004
|
isValidLocale: (locale: string) => boolean;
|
|
4005
4005
|
getArea: (slug: string) => import("./config/types.js").BuiltArea;
|
|
4006
4006
|
getCollection: (slug: string) => import("./config/types.js").BuiltCollection;
|
|
4007
|
-
getBySlug: (slug: string) => import("./config/types.js").
|
|
4007
|
+
getBySlug: (slug: string) => import("./config/types.js").BuiltCollection | import("./config/types.js").BuiltArea;
|
|
4008
4008
|
isCollection: (slug?: string) => slug is import("./types/doc.js").CollectionSlug;
|
|
4009
4009
|
isArea: (slug?: string) => slug is import("./types/doc.js").AreaSlug;
|
|
4010
4010
|
getDocumentPrototype(slug: import("./types/doc.js").PrototypeSlug): "area" | "collection";
|
|
@@ -3,67 +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
|
-
import { populateRessourceURL } from
|
|
6
|
+
import { populateRessourceURL } from "$rime/modules/rimecms/fields/link";
|
|
7
7
|
export class LinkFieldBuilder extends FormFieldBuilder {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
};
|
|
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)
|
|
42
|
-
return undefined;
|
|
43
|
-
// Sanitize only the value and url properties of the link, other properties are left as is
|
|
44
|
-
const isLinkValue = (v) => typeof v === 'object' && !Array.isArray(v) && 'value' in v;
|
|
45
|
-
if (isLinkValue(link)) {
|
|
46
|
-
return {
|
|
47
|
-
...link,
|
|
48
|
-
url: link.url ? sanitize(link.url) : undefined,
|
|
49
|
-
value: link.value ? sanitize(link.value) : null
|
|
50
|
-
};
|
|
51
|
-
}
|
|
52
|
-
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]
|
|
53
17
|
};
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
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
|
+
};
|
|
59
50
|
}
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
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
|
+
};
|
|
60
|
+
}
|
|
61
|
+
return super.compile();
|
|
62
|
+
}
|
|
63
|
+
generateType() {
|
|
64
|
+
return `${this.name}${this.get.required ? '' : '?'}: {
|
|
65
|
+
type: ${this.get.types.map(t => `'${t}'`).join(' | ')};
|
|
63
66
|
value: string | null;
|
|
64
67
|
target: '_self' | '_blank';
|
|
65
68
|
url?: string;
|
|
66
69
|
}`;
|
|
67
|
-
|
|
70
|
+
}
|
|
68
71
|
}
|
|
69
|
-
export const link =
|
|
72
|
+
export const link = name => new LinkFieldBuilder(name);
|
|
@@ -1,54 +1,54 @@
|
|
|
1
1
|
import { FormFieldBuilder } from '../../core/fields/builders/form-field-builder.js';
|
|
2
2
|
import { hasProps, isObjectLiteral } from '../../util/object.js';
|
|
3
3
|
import { capitalize } from '../../util/string.js';
|
|
4
|
-
import { ensureRelationExists } from
|
|
4
|
+
import { ensureRelationExists } from "$rime/modules/rimecms/fields/relation";
|
|
5
5
|
import Cell from './component/Cell.svelte';
|
|
6
6
|
import RelationComponent from './component/Relation.svelte';
|
|
7
7
|
export class RelationFieldBuilder extends FormFieldBuilder {
|
|
8
|
-
|
|
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 =
|
|
51
|
+
export const relation = name => new RelationFieldBuilder(name);
|
|
52
52
|
/**
|
|
53
53
|
* Checks if a relation value is resolved (contains the actual referenced document).
|
|
54
54
|
*
|
|
@@ -56,8 +56,8 @@ export const relation = (name) => new RelationFieldBuilder(name);
|
|
|
56
56
|
* // Returns true for a resolved relation
|
|
57
57
|
* isRelationResolved({ title: 'Home Page', _prototype: 'collection', _type: 'pages' });
|
|
58
58
|
*/
|
|
59
|
-
export const isRelationResolved =
|
|
60
|
-
|
|
59
|
+
export const isRelationResolved = value => {
|
|
60
|
+
return value && isObjectLiteral(value) && hasProps(['title', '_prototype', '_type'], value);
|
|
61
61
|
};
|
|
62
62
|
/**
|
|
63
63
|
* Checks if a relation value is a reference (contains only the relationTo and documentId).
|
|
@@ -66,10 +66,7 @@ export const isRelationResolved = (value) => {
|
|
|
66
66
|
* // Returns true for a relation reference
|
|
67
67
|
* isRelationRef({ relationTo: 'pages', documentId: '123' });
|
|
68
68
|
*/
|
|
69
|
-
export const isRelationRef =
|
|
70
|
-
value !== null &&
|
|
71
|
-
typeof value.relationTo === 'string' &&
|
|
72
|
-
typeof value.documentId === 'string';
|
|
69
|
+
export const isRelationRef = value => typeof value === 'object' && value !== null && typeof value.relationTo === 'string' && typeof value.documentId === 'string';
|
|
73
70
|
/**
|
|
74
71
|
* Checks if a relation value is unresolved (contains only reference information).
|
|
75
72
|
*
|
|
@@ -77,8 +74,8 @@ export const isRelationRef = (value) => typeof value === 'object' &&
|
|
|
77
74
|
* // Returns true for an unresolved relation
|
|
78
75
|
* isRelationUnresolved({ relationTo: 'pages', documentId: '123' });
|
|
79
76
|
*/
|
|
80
|
-
export const isRelationUnresolved =
|
|
81
|
-
|
|
77
|
+
export const isRelationUnresolved = value => {
|
|
78
|
+
return value && isObjectLiteral(value) && hasProps(['relationTo', 'documentId'], value);
|
|
82
79
|
};
|
|
83
80
|
/**
|
|
84
81
|
* Resolves a relation reference to the actual document it points to.
|
|
@@ -88,19 +85,16 @@ export const isRelationUnresolved = (value) => {
|
|
|
88
85
|
* const doc = await resolveRelationRef({ relationTo: 'pages', documentId: '123' });
|
|
89
86
|
*/
|
|
90
87
|
export async function resolveRelationRef(item) {
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
return item;
|
|
102
|
-
}
|
|
103
|
-
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)}`);
|
|
104
98
|
}
|
|
105
99
|
/**
|
|
106
100
|
* Resolves a relation field value to the actual documents it points to.
|
|
@@ -110,8 +104,7 @@ export async function resolveRelationRef(item) {
|
|
|
110
104
|
* const docs = await resolveRelation([{ relationTo: 'pages', documentId: '123' }]);
|
|
111
105
|
*/
|
|
112
106
|
export async function resolveRelation(value) {
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
}
|
|
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
|
+
}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import i18n, { t__ } from './core/i18n/index.js';
|
|
2
|
-
import {
|
|
2
|
+
import { cache } from './core/plugins/cache/index.js';
|
|
3
3
|
import LiveConsumer from './panel/components/sections/live/Consumer.svelte';
|
|
4
4
|
import LiveEdit from './panel/components/sections/live/LiveEdit.svelte';
|
|
5
5
|
import LiveProvider from './panel/components/sections/live/Provider.svelte';
|
|
6
|
-
export { definePlugin
|
|
7
|
-
export {
|
|
6
|
+
export { definePlugin } from './core/plugins/index.js';
|
|
7
|
+
export { cache, i18n, LiveConsumer, LiveEdit, LiveProvider, t__ };
|
|
8
8
|
export type { Dictionaries, PanelLanguage } from './core/i18n/index.js';
|
|
9
9
|
declare module 'rimecms' {
|
|
10
10
|
interface RegisterCollection {
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import i18n, { t__ } from './core/i18n/index.js';
|
|
2
|
-
import {
|
|
2
|
+
import { cache } from './core/plugins/cache/index.js';
|
|
3
3
|
import LiveConsumer from './panel/components/sections/live/Consumer.svelte';
|
|
4
4
|
import LiveEdit from './panel/components/sections/live/LiveEdit.svelte';
|
|
5
5
|
import LiveProvider from './panel/components/sections/live/Provider.svelte';
|
|
6
|
-
export { definePlugin
|
|
7
|
-
export {
|
|
6
|
+
export { definePlugin } from './core/plugins/index.js';
|
|
7
|
+
export { cache, i18n, LiveConsumer, LiveEdit, LiveProvider, t__ };
|
|
@@ -8,7 +8,7 @@ export declare function setConfigContext(initial: BuiltConfigClient): {
|
|
|
8
8
|
getDocumentConfig: (args: {
|
|
9
9
|
prototype: Prototype;
|
|
10
10
|
slug: PrototypeSlug;
|
|
11
|
-
}) =>
|
|
11
|
+
}) => import("../../core/config/types.js").BuiltCollection | import("../../core/config/types.js").BuiltArea;
|
|
12
12
|
};
|
|
13
13
|
export declare function getConfigContext(): {
|
|
14
14
|
readonly raw: BuiltConfigClient;
|
|
@@ -17,5 +17,5 @@ export declare function getConfigContext(): {
|
|
|
17
17
|
getDocumentConfig: (args: {
|
|
18
18
|
prototype: Prototype;
|
|
19
19
|
slug: PrototypeSlug;
|
|
20
|
-
}) =>
|
|
20
|
+
}) => import("../../core/config/types.js").BuiltCollection | import("../../core/config/types.js").BuiltArea;
|
|
21
21
|
};
|
|
@@ -60,7 +60,7 @@ export declare function setDocumentFormContext<T extends WithOptional<GenericDoc
|
|
|
60
60
|
delete(key: string): void;
|
|
61
61
|
deleteAllThatStartWith(path: string): void;
|
|
62
62
|
};
|
|
63
|
-
readonly config:
|
|
63
|
+
readonly config: import("../../types.js").BuiltCollection;
|
|
64
64
|
readonly title: string | import("../../core/config/types.js").CollectionLabel;
|
|
65
65
|
readonly isLive: boolean;
|
|
66
66
|
reset(): void;
|
|
@@ -123,7 +123,7 @@ export declare function getDocumentFormContext<T extends WithOptional<GenericDoc
|
|
|
123
123
|
delete(key: string): void;
|
|
124
124
|
deleteAllThatStartWith(path: string): void;
|
|
125
125
|
};
|
|
126
|
-
readonly config:
|
|
126
|
+
readonly config: import("../../types.js").BuiltCollection;
|
|
127
127
|
readonly title: string | import("../../core/config/types.js").CollectionLabel;
|
|
128
128
|
readonly isLive: boolean;
|
|
129
129
|
reset(): void;
|
|
@@ -155,7 +155,7 @@ function createStore(href) {
|
|
|
155
155
|
get documentUpdateURI() {
|
|
156
156
|
const doc = page.data.doc;
|
|
157
157
|
if (!doc)
|
|
158
|
-
throw new Error('live.doc has not been set before accessing documentAPIUpdateURL');
|
|
158
|
+
throw new Error('live.doc has not been set before accessing documentAPIUpdateURL, be sure to provide a "doc" property in the page data, or provide an update property to the LiveEdit component.');
|
|
159
159
|
let uri = `/${doc._type}`;
|
|
160
160
|
if (doc._prototype === 'collection')
|
|
161
161
|
uri += `/${doc.id}`;
|
|
@@ -36,7 +36,12 @@
|
|
|
36
36
|
{#if context.status !== 429}
|
|
37
37
|
<form method="POST" action="/panel/sign-in" use:enhance={context.enhance}>
|
|
38
38
|
<Email config={emailField} form={context} />
|
|
39
|
-
<Text
|
|
39
|
+
<Text
|
|
40
|
+
type="password"
|
|
41
|
+
icon={KeyRound}
|
|
42
|
+
config={passwordField.clone().layout('compact')}
|
|
43
|
+
form={context}
|
|
44
|
+
/>
|
|
40
45
|
<Button size="xl" disabled={!context.canSubmit} type="submit">
|
|
41
46
|
{t__('common.signin')}
|
|
42
47
|
{#if context.pending}
|
package/dist/server.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import handlers from './core/handlers/index.js';
|
|
2
2
|
import { registerTranslation } from './core/i18n/register.server.js';
|
|
3
|
-
import { apiInit } from './core/plugins/api-init/index.
|
|
4
|
-
import { cache } from './core/plugins/cache/index.
|
|
5
|
-
import { mailer } from './core/plugins/mailer/index.
|
|
6
|
-
import { sse } from './core/plugins/sse/index.
|
|
3
|
+
import { apiInit } from './core/plugins/api-init/index.js';
|
|
4
|
+
import { cache } from './core/plugins/cache/index.js';
|
|
5
|
+
import { mailer } from './core/plugins/mailer/index.js';
|
|
6
|
+
import { sse } from './core/plugins/sse/index.js';
|
|
7
7
|
export { apiInit, cache, handlers, mailer, registerTranslation, sse };
|
package/dist/server.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import handlers from './core/handlers/index.js';
|
|
2
2
|
import { registerTranslation } from './core/i18n/register.server.js';
|
|
3
|
-
import { apiInit } from './core/plugins/api-init/index.
|
|
4
|
-
import { cache } from './core/plugins/cache/index.
|
|
5
|
-
import { mailer } from './core/plugins/mailer/index.
|
|
6
|
-
import { sse } from './core/plugins/sse/index.
|
|
3
|
+
import { apiInit } from './core/plugins/api-init/index.js';
|
|
4
|
+
import { cache } from './core/plugins/cache/index.js';
|
|
5
|
+
import { mailer } from './core/plugins/mailer/index.js';
|
|
6
|
+
import { sse } from './core/plugins/sse/index.js';
|
|
7
7
|
export { apiInit, cache, handlers, mailer, registerTranslation, sse };
|
package/dist/types.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export type { User } from './core/collections/auth/types.js';
|
|
2
|
-
export type { AdditionalStaffConfig, Area, AreaHooks, BuiltArea, BuiltCollection, BuiltConfig, BuiltConfigClient, Collection, CollectionHooks, Config, CustomPanelRoute, ImageSizesConfig, LocaleConfig, LocalizationConfig, RouteConfig } from './core/config/types.js';
|
|
2
|
+
export type { AdditionalStaffConfig, Area, AreaHooks, BuiltArea, BuiltAreaClient, BuiltCollection, BuiltCollectionClient, BuiltConfig, BuiltConfigClient, Collection, CollectionHooks, Config, CustomPanelRoute, ImageSizesConfig, LocaleConfig, LocalizationConfig, RouteConfig, SanitizedConfigClient } from './core/config/types.js';
|
|
3
3
|
export type { AreaSlug, BaseDoc, CollectionSlug, GenericBlock, GenericDoc, Prototype, PrototypeSlug, UploadDoc } from './core/types/doc.js';
|
|
4
4
|
export type * from './fields/types.js';
|
|
5
5
|
export type { CollectionProps, FieldPanelTableConfig, FormErrors, Navigation, Route } from './panel/types.js';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "rimecms",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.31.0",
|
|
4
4
|
"homepage": "https://github.com/bienbiendev/rime",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"dev": "vite dev",
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
"build:css": "postcss dist/**/*.css --replace --config ./postcss.config.cjs",
|
|
9
9
|
"rime:use": "bun ./src/scripts/useConfig.js",
|
|
10
10
|
"preview": "vite preview",
|
|
11
|
-
"package": "bun ./src/lib/core/dev/cli/index.ts clear --force &&
|
|
11
|
+
"package": "bun ./src/lib/core/dev/cli/index.ts clear --force && bun ./src/lib/core/dev/cli/index.ts package && publint",
|
|
12
12
|
"prepublishOnly": "rm -fr src/lib/site && npm run package && pnpm build:css",
|
|
13
13
|
"check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json",
|
|
14
14
|
"check:watch": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch",
|