rimecms 0.30.2 → 0.30.3
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 -1
- package/dist/adapter-sqlite/generate-schema/column.server.js +1 -4
- package/dist/adapter-sqlite/generate-schema/write.server.js +1 -3
- package/dist/core/config/auth/better-auth-hooks.server.js +6 -3
- 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/index.js +1 -0
- package/dist/core/dev/cli/init/index.server.js +3 -3
- package/dist/core/dev/cli/init/templates.js +8 -1
- package/dist/core/dev/cli/util/package-manager.server.js +27 -26
- package/dist/core/dev/constants.d.ts +11 -2
- package/dist/core/dev/constants.js +11 -0
- package/dist/core/dev/generate/runtime/index.server.d.ts +24 -0
- package/dist/core/dev/generate/runtime/index.server.js +93 -0
- package/dist/core/dev/generate/types/index.server.js +42 -18
- package/dist/core/dev/vite/index.server.js +39 -23
- 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/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/set-default-values.server.js +3 -3
- package/dist/core/operations/hooks/before-upsert/validate-fields.server.js +7 -7
- 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.server.js +2 -2
- 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 +9 -5
- 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 +5 -9
- 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/panel/components/fields/RenderFields.svelte +1 -1
- package/dist/panel/context/collection.svelte.js +5 -3
- package/dist/panel/context/documentForm.svelte.js +47 -28
- package/dist/panel/context/form.svelte.js +3 -3
- package/dist/util/doc.js +1 -1
- package/package.json +1 -8
- 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
|
@@ -2,12 +2,9 @@ import { BooleanFieldBuilder } from '../../core/fields/builders/boolean-builder.
|
|
|
2
2
|
import Cell from './component/Cell.svelte';
|
|
3
3
|
import Toggle from './component/Toggle.svelte';
|
|
4
4
|
export class ToggleFieldBuilder extends BooleanFieldBuilder {
|
|
5
|
-
//
|
|
6
|
-
_metaUrl = import.meta.url;
|
|
7
5
|
constructor(name) {
|
|
8
6
|
super(name, 'toggle');
|
|
9
7
|
this.field.isEmpty = (value) => typeof value !== 'boolean';
|
|
10
|
-
this.field.defaultValue = false;
|
|
11
8
|
}
|
|
12
9
|
get component() {
|
|
13
10
|
return Toggle;
|
|
@@ -27,5 +24,8 @@ export class ToggleFieldBuilder extends BooleanFieldBuilder {
|
|
|
27
24
|
}
|
|
28
25
|
return super.compile();
|
|
29
26
|
}
|
|
27
|
+
generateType() {
|
|
28
|
+
return `${this.name}${this.get.required ? '' : '?'}: boolean`;
|
|
29
|
+
}
|
|
30
30
|
}
|
|
31
31
|
export const toggle = (name) => new ToggleFieldBuilder(name);
|
|
@@ -4,7 +4,6 @@ import type { Field, FormField } from '../types.js';
|
|
|
4
4
|
import type { Dic } from '../../util/types.js';
|
|
5
5
|
export declare const tree: (name: string) => TreeBuilder;
|
|
6
6
|
export declare class TreeBuilder extends FormFieldBuilder<TreeField> {
|
|
7
|
-
_metaUrl: string;
|
|
8
7
|
constructor(name: string);
|
|
9
8
|
get component(): import("svelte").Component<import("./component/props.js").TreeProps, {}, "">;
|
|
10
9
|
get cell(): import("svelte").Component<{
|
|
@@ -71,6 +70,7 @@ export declare class TreeBuilder extends FormFieldBuilder<TreeField> {
|
|
|
71
70
|
renderTitle?: TreeFieldBlockRenderTitle;
|
|
72
71
|
addItemLabel: string;
|
|
73
72
|
};
|
|
73
|
+
protected generateType(): string;
|
|
74
74
|
}
|
|
75
75
|
/**
|
|
76
76
|
* Checks if a field is a tree field.
|
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
import { FieldBuilder } from '../../core/fields/builders/field-builder.js';
|
|
2
2
|
import { FormFieldBuilder } from '../../core/fields/builders/form-field-builder.js';
|
|
3
|
+
import { toPascalCase } from '../../util/string.js';
|
|
3
4
|
import { number } from '../number/index.js';
|
|
4
5
|
import { text } from '../text/index.js';
|
|
5
6
|
import Cell from './component/Cell.svelte';
|
|
6
7
|
import Tree from './component/Tree.svelte';
|
|
7
8
|
export const tree = (name) => new TreeBuilder(name);
|
|
8
9
|
export class TreeBuilder extends FormFieldBuilder {
|
|
9
|
-
//
|
|
10
|
-
_metaUrl = import.meta.url;
|
|
11
10
|
constructor(name) {
|
|
12
11
|
super(name, 'tree');
|
|
13
12
|
this.field.defaultValue = [];
|
|
@@ -75,6 +74,9 @@ export class TreeBuilder extends FormFieldBuilder {
|
|
|
75
74
|
fields: this.field.fields.map((f) => f.compile())
|
|
76
75
|
};
|
|
77
76
|
}
|
|
77
|
+
generateType() {
|
|
78
|
+
return `${this.name}: Array<Tree${toPascalCase(this.name)}>,`;
|
|
79
|
+
}
|
|
78
80
|
}
|
|
79
81
|
/**
|
|
80
82
|
* Checks if a field is a tree field.
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
const user = getUserContext();
|
|
21
21
|
|
|
22
22
|
const authorizedFields = $derived(
|
|
23
|
-
fields.filter((field) => field.
|
|
23
|
+
fields.filter((field) => field.use.accessRead(user.attributes, { id: form.values.id }))
|
|
24
24
|
);
|
|
25
25
|
|
|
26
26
|
const path = $derived(initialPath === '' ? '' : `${initialPath}.`);
|
|
@@ -38,9 +38,11 @@ function createCollectionStore(args) {
|
|
|
38
38
|
const hasVersions = $derived(!!config.versions);
|
|
39
39
|
const hasDraft = $derived(config.versions && config.versions.draft);
|
|
40
40
|
onMount(() => {
|
|
41
|
+
const storedDisplay = localStorage.getItem(`collection.${config.slug}.display`);
|
|
41
42
|
displayMode =
|
|
42
|
-
|
|
43
|
-
|
|
43
|
+
storedDisplay && (storedDisplay !== DISPLAY_MODE.NESTED || config.nested)
|
|
44
|
+
? storedDisplay
|
|
45
|
+
: DISPLAY_MODE.LIST;
|
|
44
46
|
const localSortBy = localStorage.getItem(`collection.${config.slug}.sortBy`);
|
|
45
47
|
sortingBy = localSortBy || 'updatedAt';
|
|
46
48
|
const localSortOrder = localStorage.getItem(`collection.${config.slug}.sortOrder`);
|
|
@@ -246,7 +248,7 @@ function createCollectionStore(args) {
|
|
|
246
248
|
return displayMode === DISPLAY_MODE.GRID;
|
|
247
249
|
}
|
|
248
250
|
function isNested() {
|
|
249
|
-
return displayMode === DISPLAY_MODE.NESTED;
|
|
251
|
+
return displayMode === DISPLAY_MODE.NESTED && !!config.nested;
|
|
250
252
|
}
|
|
251
253
|
function toggleSelectOf(docId) {
|
|
252
254
|
if (selected.includes(docId)) {
|
|
@@ -356,11 +356,11 @@ function createDocumentFormState({ initial, config, readOnly, key, onNestedDocum
|
|
|
356
356
|
path = path ? normalizeFieldPath(path) : config.name;
|
|
357
357
|
const parts = $derived(path.split('.'));
|
|
358
358
|
const validate = (value) => {
|
|
359
|
-
if (config.get.required && config.
|
|
359
|
+
if (config.get.required && config.use.isEmpty(value)) {
|
|
360
360
|
errors.set(path, 'required::required_field');
|
|
361
361
|
return 'required';
|
|
362
362
|
}
|
|
363
|
-
const validated = config.
|
|
363
|
+
const validated = config.use.validate(value, {
|
|
364
364
|
data: doc,
|
|
365
365
|
locale: locale.code,
|
|
366
366
|
id: doc.id ?? undefined,
|
|
@@ -409,14 +409,14 @@ function createDocumentFormState({ initial, config, readOnly, key, onNestedDocum
|
|
|
409
409
|
}
|
|
410
410
|
};
|
|
411
411
|
const setFieldValue = async (value) => {
|
|
412
|
-
value = await config.
|
|
412
|
+
value = await config.use.beforeValidate(value, { config, data: doc });
|
|
413
413
|
const valid = validate(value);
|
|
414
|
-
if (operation === 'update' && !config.
|
|
414
|
+
if (operation === 'update' && !config.use.accessUpdate(user.attributes)) {
|
|
415
415
|
return;
|
|
416
416
|
}
|
|
417
417
|
if (valid) {
|
|
418
418
|
setValue(path, value);
|
|
419
|
-
config.
|
|
419
|
+
config.use.onChange?.(value, {
|
|
420
420
|
siblings: getSiblings(),
|
|
421
421
|
useField,
|
|
422
422
|
useBlocks,
|
|
@@ -437,26 +437,32 @@ function createDocumentFormState({ initial, config, readOnly, key, onNestedDocum
|
|
|
437
437
|
if (readOnly)
|
|
438
438
|
return false;
|
|
439
439
|
if (operation === 'create') {
|
|
440
|
-
return !!config.
|
|
440
|
+
return !!config.use.accessCreate?.(user.attributes);
|
|
441
441
|
}
|
|
442
442
|
else {
|
|
443
|
-
return !!config.
|
|
443
|
+
return !!config.use.accessUpdate?.(user.attributes);
|
|
444
444
|
}
|
|
445
445
|
},
|
|
446
446
|
get visible() {
|
|
447
|
-
if (!config.
|
|
447
|
+
if (!config.use.accessRead(user.attributes)) {
|
|
448
448
|
return false;
|
|
449
449
|
}
|
|
450
|
-
return config.
|
|
450
|
+
return config.use.isVisible(doc, getSiblings());
|
|
451
451
|
},
|
|
452
452
|
get error() {
|
|
453
453
|
return errors.value[path] || false;
|
|
454
454
|
},
|
|
455
455
|
get isEmpty() {
|
|
456
|
-
return config.
|
|
456
|
+
return config.use.isEmpty(getValueAtPath(path, doc));
|
|
457
457
|
}
|
|
458
458
|
};
|
|
459
459
|
}
|
|
460
|
+
/**
|
|
461
|
+
* Prepare the form data for submission.
|
|
462
|
+
* This function collects the changed fields from the document,
|
|
463
|
+
* applies any beforeSubmit hooks, and constructs a FormData object
|
|
464
|
+
* to be sent in the request body.
|
|
465
|
+
*/
|
|
460
466
|
const prepareData = async () => {
|
|
461
467
|
let data = {};
|
|
462
468
|
for (const key of Object.keys(changes)) {
|
|
@@ -481,6 +487,9 @@ function createDocumentFormState({ initial, config, readOnly, key, onNestedDocum
|
|
|
481
487
|
}
|
|
482
488
|
return formData;
|
|
483
489
|
};
|
|
490
|
+
/**
|
|
491
|
+
* Submit the form data to the server.
|
|
492
|
+
*/
|
|
484
493
|
const submit = async (action) => {
|
|
485
494
|
if (processing)
|
|
486
495
|
return;
|
|
@@ -537,29 +546,35 @@ function createDocumentFormState({ initial, config, readOnly, key, onNestedDocum
|
|
|
537
546
|
}
|
|
538
547
|
processing = false;
|
|
539
548
|
};
|
|
549
|
+
/**
|
|
550
|
+
* Enhance the form element to handle submission.
|
|
551
|
+
* This function attaches a submit event listener to the form element,
|
|
552
|
+
* which prevents the default submission behavior, sets the status field
|
|
553
|
+
* if applicable, and calls the submit function with the appropriate action URL.
|
|
554
|
+
*/
|
|
540
555
|
const enhance = (node) => {
|
|
541
556
|
// Assign form element
|
|
542
557
|
formElement = node;
|
|
543
558
|
// Set status field if submitter has a data-status attribute
|
|
544
559
|
const setStatus = (submitter) => {
|
|
545
|
-
const
|
|
546
|
-
if (
|
|
560
|
+
const SUBMITER_HAS_DATA_STATUS = !!submitter?.dataset.status;
|
|
561
|
+
if (SUBMITER_HAS_DATA_STATUS && documentConfig.versions && documentConfig.versions.draft) {
|
|
547
562
|
setValue('status', submitter?.dataset.status);
|
|
548
563
|
}
|
|
549
564
|
};
|
|
550
565
|
// Build full action URL with query params based on submitter attributes (draft, versionId)
|
|
551
566
|
const enhanceAction = (submitter) => {
|
|
552
|
-
let
|
|
553
|
-
const
|
|
554
|
-
|
|
555
|
-
|
|
567
|
+
let actionUrl = buildPanelActionUrl();
|
|
568
|
+
const SUBMITER_HAS_DATA_DRAFT = !!submitter?.dataset.draft;
|
|
569
|
+
const DOC_HAS_VERSION = documentConfig.versions && !!doc.versionId;
|
|
570
|
+
const { DRAFT, VERSION_ID } = PARAMS;
|
|
571
|
+
if (SUBMITER_HAS_DATA_DRAFT) {
|
|
572
|
+
actionUrl += `&${DRAFT}=true`;
|
|
556
573
|
}
|
|
557
|
-
if (
|
|
558
|
-
|
|
559
|
-
action += `&versionId=${doc.versionId}`;
|
|
560
|
-
}
|
|
574
|
+
else if (DOC_HAS_VERSION) {
|
|
575
|
+
actionUrl += `&${VERSION_ID}=${doc.versionId}`;
|
|
561
576
|
}
|
|
562
|
-
return
|
|
577
|
+
return actionUrl;
|
|
563
578
|
};
|
|
564
579
|
const listener = async (event) => {
|
|
565
580
|
event.preventDefault();
|
|
@@ -573,6 +588,11 @@ function createDocumentFormState({ initial, config, readOnly, key, onNestedDocum
|
|
|
573
588
|
}
|
|
574
589
|
};
|
|
575
590
|
};
|
|
591
|
+
/**
|
|
592
|
+
* Build the action URL for the form submission based on the current operation (create or update),
|
|
593
|
+
* the document type (collection or area), and any nested form levels.
|
|
594
|
+
* This function constructs the appropriate URL to which the form data will be submitted.
|
|
595
|
+
*/
|
|
576
596
|
const buildPanelActionUrl = () => {
|
|
577
597
|
// Start with the base URI for the panel
|
|
578
598
|
let panelUri = `/panel/${config.kebab}`;
|
|
@@ -581,19 +601,18 @@ function createDocumentFormState({ initial, config, readOnly, key, onNestedDocum
|
|
|
581
601
|
panelUri += `/${initial.id}`;
|
|
582
602
|
}
|
|
583
603
|
// Determine the appropriate action based on whether we're creating or updating
|
|
584
|
-
|
|
585
|
-
if (operation === 'create') {
|
|
586
|
-
actionSuffix = '/create?/create';
|
|
587
|
-
}
|
|
588
|
-
else {
|
|
589
|
-
actionSuffix = '?/update';
|
|
590
|
-
}
|
|
604
|
+
const actionSuffix = operation === 'create' ? '/create?/create' : '?/update';
|
|
591
605
|
// Add a redirect parameter if we're in a nested form ex: relation creation
|
|
592
606
|
// to prevent redirect after creation
|
|
593
607
|
const redirectParam = nestedLevel > 0 ? `&${PARAMS.REDIRECT}=false` : '';
|
|
594
608
|
// Combine all parts to form the final action URL
|
|
595
609
|
return `${panelUri}${actionSuffix}${redirectParam}`;
|
|
596
610
|
};
|
|
611
|
+
/**
|
|
612
|
+
* Import data from the default locale for the current document.
|
|
613
|
+
* This function fetches the document data from the default locale and updates the current document state.
|
|
614
|
+
* It processes localized fields to ensure they are correctly set for the current locale.
|
|
615
|
+
*/
|
|
597
616
|
const importDataFromDefaultLocale = async () => {
|
|
598
617
|
const BASE_API_URL = `${apiUrl(documentConfig.kebab)}`;
|
|
599
618
|
let fetchURL = BASE_API_URL;
|
|
@@ -43,7 +43,7 @@ function createFormStore(initial, key) {
|
|
|
43
43
|
const validate = (value) => {
|
|
44
44
|
let isEmpty;
|
|
45
45
|
try {
|
|
46
|
-
isEmpty = config.
|
|
46
|
+
isEmpty = config.use.isEmpty(value);
|
|
47
47
|
}
|
|
48
48
|
catch (err) {
|
|
49
49
|
console.error(err.message);
|
|
@@ -53,7 +53,7 @@ function createFormStore(initial, key) {
|
|
|
53
53
|
errors.value[path] = 'required::required_field';
|
|
54
54
|
return false;
|
|
55
55
|
}
|
|
56
|
-
const validated = config.
|
|
56
|
+
const validated = config.use.validate(value, {
|
|
57
57
|
data: form,
|
|
58
58
|
id: undefined,
|
|
59
59
|
operation: undefined,
|
|
@@ -85,7 +85,7 @@ function createFormStore(initial, key) {
|
|
|
85
85
|
}
|
|
86
86
|
},
|
|
87
87
|
get visible() {
|
|
88
|
-
return config.
|
|
88
|
+
return config.use.isVisible(form, {});
|
|
89
89
|
},
|
|
90
90
|
get error() {
|
|
91
91
|
return errors.value[path] || false;
|
package/dist/util/doc.js
CHANGED
|
@@ -38,7 +38,7 @@ export const createBlankDocument = (config, event) => {
|
|
|
38
38
|
// than assigned `prev['']` (they never got a real name) — that used
|
|
39
39
|
// to corrupt the parent object into looking array-like once
|
|
40
40
|
// flattened/unflattened.
|
|
41
|
-
const defaultValue = curr.
|
|
41
|
+
const defaultValue = curr.use.defaultValue({ event });
|
|
42
42
|
prev[curr.name] = defaultValue !== undefined ? defaultValue : null;
|
|
43
43
|
}
|
|
44
44
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "rimecms",
|
|
3
|
-
"version": "0.30.
|
|
3
|
+
"version": "0.30.3",
|
|
4
4
|
"homepage": "https://github.com/bienbiendev/rime",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"dev": "vite dev",
|
|
@@ -179,18 +179,11 @@
|
|
|
179
179
|
"magic-string-ast": "^1.0.2",
|
|
180
180
|
"nodemailer": "^8.0.5",
|
|
181
181
|
"paneforge": "^1.0.2",
|
|
182
|
-
"polka": "^0.5.2",
|
|
183
182
|
"postcss-import": "^16.1.1",
|
|
184
183
|
"qs": "^6.14.0",
|
|
185
184
|
"runed": "^0.37.1",
|
|
186
185
|
"sharp": "^0.35.3",
|
|
187
186
|
"sortablejs": "^1.15.6",
|
|
188
187
|
"svelte-sonner": "^1.0.5"
|
|
189
|
-
},
|
|
190
|
-
"pnpm": {
|
|
191
|
-
"onlyBuiltDependencies": [
|
|
192
|
-
"sharp",
|
|
193
|
-
"esbuild"
|
|
194
|
-
]
|
|
195
188
|
}
|
|
196
189
|
}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { getFieldPrivateModule } from '../index.server.js';
|
|
2
|
-
export async function toType(group) {
|
|
3
|
-
const fieldsTypes = [];
|
|
4
|
-
for (const field of group.get.fields) {
|
|
5
|
-
const fieldServerMethods = await getFieldPrivateModule(field);
|
|
6
|
-
if (fieldServerMethods) {
|
|
7
|
-
const result = await Promise.resolve(fieldServerMethods.toType(field));
|
|
8
|
-
fieldsTypes.push(result);
|
|
9
|
-
}
|
|
10
|
-
}
|
|
11
|
-
return group.get.fields.length ? `${group.name}: {${fieldsTypes.join(',\n\t')}}` : '';
|
|
12
|
-
}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import type { FieldBuilder } from '../core/fields/builders/field-builder.js';
|
|
2
|
-
export type ToType<T extends FieldBuilder<any> = FieldBuilder<any>> = (field: T) => Promise<string> | string;
|
|
3
|
-
/**
|
|
4
|
-
* Dynamically imports the server-side module for a form field if it exists
|
|
5
|
-
* Returns the imported module or false if no server module is found or import fails
|
|
6
|
-
* @example
|
|
7
|
-
* const serverModule = await getFieldPrivateModule(fieldBuilder);
|
|
8
|
-
* if (serverModule) {
|
|
9
|
-
* serverModule.toType(fieldBuilder)
|
|
10
|
-
* }
|
|
11
|
-
*/
|
|
12
|
-
export declare function getFieldPrivateModule(field: FieldBuilder<any>): Promise<{
|
|
13
|
-
toType: ToType;
|
|
14
|
-
} | null>;
|
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
import { existsSync } from 'fs';
|
|
2
|
-
import { fileURLToPath } from 'node:url';
|
|
3
|
-
import { dirname, extname, join } from 'path';
|
|
4
|
-
/**
|
|
5
|
-
* Converts a file URL to its corresponding server module path and checks if the file exists.
|
|
6
|
-
* Prefers a sibling `runtime.server.ts` (the generic per-field server-only file, also used to
|
|
7
|
-
* resolve `$rime/runtime` — see relation/ for the first user), falling back to the older
|
|
8
|
-
* `<basename>.server.ts` convention most fields still use. Tries both .ts and .js extensions
|
|
9
|
-
* either way.
|
|
10
|
-
* @example
|
|
11
|
-
* convertToServerModulePath('file:///path/to/relation/index.ts') // '/path/to/relation/runtime.server.ts'
|
|
12
|
-
* convertToServerModulePath('file:///path/to/text/index.ts') // '/path/to/text/index.server.ts'
|
|
13
|
-
*/
|
|
14
|
-
function convertToServerModulePath(metaUrl) {
|
|
15
|
-
try {
|
|
16
|
-
// Convert file:// URL to file path
|
|
17
|
-
const filePath = fileURLToPath(metaUrl);
|
|
18
|
-
const dir = dirname(filePath);
|
|
19
|
-
// Get the filename without extension
|
|
20
|
-
const baseName = filePath.replace(extname(filePath), '');
|
|
21
|
-
const candidates = [join(dir, 'runtime.server'), `${baseName}.server`];
|
|
22
|
-
for (const candidate of candidates) {
|
|
23
|
-
for (const ext of ['.ts', '.js']) {
|
|
24
|
-
const fullPath = `${candidate}${ext}`;
|
|
25
|
-
if (existsSync(fullPath)) {
|
|
26
|
-
return fullPath;
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
return null;
|
|
31
|
-
}
|
|
32
|
-
catch (error) {
|
|
33
|
-
console.error('Error converting metaUrl to server module path:', error);
|
|
34
|
-
return null;
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
/**
|
|
38
|
-
* Dynamically imports the server-side module for a form field if it exists
|
|
39
|
-
* Returns the imported module or false if no server module is found or import fails
|
|
40
|
-
* @example
|
|
41
|
-
* const serverModule = await getFieldPrivateModule(fieldBuilder);
|
|
42
|
-
* if (serverModule) {
|
|
43
|
-
* serverModule.toType(fieldBuilder)
|
|
44
|
-
* }
|
|
45
|
-
*/
|
|
46
|
-
export async function getFieldPrivateModule(field) {
|
|
47
|
-
if (field._metaUrl) {
|
|
48
|
-
const serverModulePath = convertToServerModulePath(field._metaUrl);
|
|
49
|
-
if (serverModulePath) {
|
|
50
|
-
try {
|
|
51
|
-
const serverField = await import(/* @vite-ignore */ serverModulePath);
|
|
52
|
-
return serverField;
|
|
53
|
-
}
|
|
54
|
-
catch (error) {
|
|
55
|
-
console.error('Error importing server module:', error);
|
|
56
|
-
return null;
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
else {
|
|
60
|
-
console.warn('Server module not found for:', field._metaUrl);
|
|
61
|
-
return null;
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
return null;
|
|
65
|
-
}
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import type { ToType } from '../index.server.js';
|
|
2
|
-
import type { FieldHook, LinkField } from '../types.js';
|
|
3
|
-
import type { LinkFieldBuilder } from './index.js';
|
|
4
|
-
export declare const toType: ToType<LinkFieldBuilder>;
|
|
5
|
-
export declare const populateRessourceURL: FieldHook<LinkField>;
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
/** Client-side no-op — resolved via `$rime/runtime` 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/runtime.server.ts) runs server-side before any write lands. */
|
|
4
|
-
export const ensureRelationExists = async (value) => value;
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import type { FieldHookShared } from '../types.js';
|
|
2
|
-
import type { ToType } from '../index.server.js';
|
|
3
|
-
import type { RelationFieldBuilder } from './index.js';
|
|
4
|
-
export declare const toType: ToType<RelationFieldBuilder<any>>;
|
|
5
|
-
/** Real implementation — resolved server-side via `$rime/runtime` (see relation/index.ts,
|
|
6
|
-
* relation/runtime.ts for the client-side no-op counterpart). Uses a plain static import of
|
|
7
|
-
* `$app/server`, which SvelteKit's build blocks from ever reaching client code. */
|
|
8
|
-
export declare const ensureRelationExists: FieldHookShared;
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { getFieldPrivateModule } from '../index.server.js';
|
|
2
|
-
export const toType = async (field) => {
|
|
3
|
-
const types = [];
|
|
4
|
-
for (const tab of field.get.tabs) {
|
|
5
|
-
const fieldsTypes = [];
|
|
6
|
-
for (const field of tab.get.fields) {
|
|
7
|
-
const fieldServerMethods = await getFieldPrivateModule(field);
|
|
8
|
-
if (fieldServerMethods) {
|
|
9
|
-
const result = await Promise.resolve(fieldServerMethods.toType(field));
|
|
10
|
-
fieldsTypes.push(result);
|
|
11
|
-
}
|
|
12
|
-
}
|
|
13
|
-
if (fieldsTypes.length) {
|
|
14
|
-
types.push(`${tab.name}: {${fieldsTypes.join(',\n\t\t')}}`);
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
return types.length ? types.join(',\n\t').replaceAll(',,', ',') : '';
|
|
18
|
-
};
|
|
File without changes
|