@aphexcms/cms-core 0.1.16 → 0.2.1
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/dist/api/client.d.ts.map +1 -1
- package/dist/api/client.js +7 -1
- package/dist/api/types.d.ts +2 -0
- package/dist/api/types.d.ts.map +1 -1
- package/dist/cli/generate-types.js +62 -17
- package/dist/cli/index.js +1 -1
- package/dist/client/index.d.ts +0 -1
- package/dist/client/index.d.ts.map +1 -1
- package/dist/client/index.js +0 -1
- package/dist/components/AdminApp.svelte +278 -45
- package/dist/components/AdminApp.svelte.d.ts +2 -0
- package/dist/components/AdminApp.svelte.d.ts.map +1 -1
- package/dist/components/admin/DocumentEditor.svelte +60 -13
- package/dist/components/admin/DocumentEditor.svelte.d.ts.map +1 -1
- package/dist/components/admin/ObjectModal.svelte +15 -4
- package/dist/components/admin/ObjectModal.svelte.d.ts +1 -0
- package/dist/components/admin/ObjectModal.svelte.d.ts.map +1 -1
- package/dist/components/admin/SchemaField.svelte +64 -5
- package/dist/components/admin/SchemaField.svelte.d.ts +1 -0
- package/dist/components/admin/SchemaField.svelte.d.ts.map +1 -1
- package/dist/components/admin/fields/ArrayField.svelte +402 -111
- package/dist/components/admin/fields/ArrayField.svelte.d.ts +1 -0
- package/dist/components/admin/fields/ArrayField.svelte.d.ts.map +1 -1
- package/dist/components/admin/fields/DateField.svelte +145 -0
- package/dist/components/admin/fields/DateField.svelte.d.ts +14 -0
- package/dist/components/admin/fields/DateField.svelte.d.ts.map +1 -0
- package/dist/components/admin/fields/DateTimeField.svelte +225 -0
- package/dist/components/admin/fields/DateTimeField.svelte.d.ts +14 -0
- package/dist/components/admin/fields/DateTimeField.svelte.d.ts.map +1 -0
- package/dist/components/admin/fields/ImageField.svelte +221 -110
- package/dist/components/admin/fields/ImageField.svelte.d.ts +2 -0
- package/dist/components/admin/fields/ImageField.svelte.d.ts.map +1 -1
- package/dist/components/admin/fields/ReferenceField.svelte +1 -1
- package/dist/components/admin/fields/SlugField.svelte +21 -13
- package/dist/components/admin/fields/SlugField.svelte.d.ts +2 -2
- package/dist/components/admin/fields/SlugField.svelte.d.ts.map +1 -1
- package/dist/components/admin/fields/StringField.svelte +156 -12
- package/dist/components/admin/fields/StringField.svelte.d.ts +3 -2
- package/dist/components/admin/fields/StringField.svelte.d.ts.map +1 -1
- package/dist/components/admin/fields/URLField.svelte +41 -0
- package/dist/components/admin/fields/URLField.svelte.d.ts +14 -0
- package/dist/components/admin/fields/URLField.svelte.d.ts.map +1 -0
- package/dist/components/index.d.ts +0 -1
- package/dist/components/index.d.ts.map +1 -1
- package/dist/components/index.js +0 -1
- package/dist/db/interfaces/asset.d.ts.map +1 -1
- package/dist/db/interfaces/document.d.ts +0 -2
- package/dist/db/interfaces/document.d.ts.map +1 -1
- package/dist/db/interfaces/index.d.ts +2 -1
- package/dist/db/interfaces/index.d.ts.map +1 -1
- package/dist/db/interfaces/user.d.ts +2 -0
- package/dist/db/interfaces/user.d.ts.map +1 -1
- package/dist/db/utils/reference-resolver.js +1 -1
- package/dist/engine.d.ts.map +1 -1
- package/dist/engine.js +3 -0
- package/dist/field-validation/date-utils.d.ts +30 -0
- package/dist/field-validation/date-utils.d.ts.map +1 -0
- package/dist/field-validation/date-utils.js +147 -0
- package/dist/field-validation/rule.d.ts +4 -0
- package/dist/field-validation/rule.d.ts.map +1 -1
- package/dist/field-validation/rule.js +170 -4
- package/dist/field-validation/utils.d.ts +7 -3
- package/dist/field-validation/utils.d.ts.map +1 -1
- package/dist/field-validation/utils.js +130 -38
- package/dist/hooks.d.ts.map +1 -1
- package/dist/hooks.js +38 -21
- package/dist/lib/field-validation/date-utils.js +147 -0
- package/dist/lib/field-validation/rule.js +170 -4
- package/dist/lib/field-validation/utils.js +130 -38
- package/dist/local-api/collection-api.d.ts +16 -4
- package/dist/local-api/collection-api.d.ts.map +1 -1
- package/dist/local-api/collection-api.js +51 -17
- package/dist/local-api/index.d.ts +1 -1
- package/dist/local-api/index.d.ts.map +1 -1
- package/dist/routes/assets-cdn.d.ts.map +1 -1
- package/dist/routes/assets-cdn.js +14 -7
- package/dist/routes/assets.d.ts.map +1 -1
- package/dist/routes/assets.js +6 -1
- package/dist/routes/documents-by-id.d.ts.map +1 -1
- package/dist/routes/documents-by-id.js +18 -7
- package/dist/routes/documents-publish.js +2 -2
- package/dist/routes/documents-query.d.ts +3 -1
- package/dist/routes/documents-query.d.ts.map +1 -1
- package/dist/routes/documents-query.js +6 -2
- package/dist/routes/documents.d.ts.map +1 -1
- package/dist/routes/documents.js +20 -4
- package/dist/routes/index.d.ts +1 -0
- package/dist/routes/index.d.ts.map +1 -1
- package/dist/routes/index.js +2 -0
- package/dist/routes/user-preferences.d.ts +4 -0
- package/dist/routes/user-preferences.d.ts.map +1 -0
- package/dist/routes/user-preferences.js +77 -0
- package/dist/schema-utils/utils.d.ts +4 -0
- package/dist/schema-utils/utils.d.ts.map +1 -1
- package/dist/schema-utils/utils.js +23 -2
- package/dist/schema-utils/validator.d.ts +4 -0
- package/dist/schema-utils/validator.d.ts.map +1 -1
- package/dist/schema-utils/validator.js +120 -0
- package/dist/types/filters.d.ts +13 -0
- package/dist/types/filters.d.ts.map +1 -1
- package/dist/types/organization.d.ts +3 -0
- package/dist/types/organization.d.ts.map +1 -1
- package/dist/types/schemas.d.ts +67 -7
- package/dist/types/schemas.d.ts.map +1 -1
- package/dist/utils/default-orderings.d.ts +10 -0
- package/dist/utils/default-orderings.d.ts.map +1 -0
- package/dist/utils/default-orderings.js +63 -0
- package/dist/utils/field-defaults.d.ts +8 -0
- package/dist/utils/field-defaults.d.ts.map +1 -0
- package/dist/utils/field-defaults.js +20 -0
- package/dist/utils/index.d.ts +1 -0
- package/dist/utils/index.d.ts.map +1 -1
- package/dist/utils/index.js +1 -0
- package/dist/utils/initial-value-helpers.d.ts +50 -0
- package/dist/utils/initial-value-helpers.d.ts.map +1 -0
- package/dist/utils/initial-value-helpers.js +70 -0
- package/package.json +6 -4
- package/dist/components/admin/DocumentTypesList.svelte +0 -97
- package/dist/components/admin/DocumentTypesList.svelte.d.ts +0 -14
- package/dist/components/admin/DocumentTypesList.svelte.d.ts.map +0 -1
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
import * as Card from '@aphexcms/ui/shadcn/card';
|
|
4
4
|
import type { SchemaType } from 'src/types/schemas.js';
|
|
5
5
|
import SchemaField from './SchemaField.svelte';
|
|
6
|
+
import { getDefaultValueForFieldType } from '../../utils/field-defaults';
|
|
6
7
|
|
|
7
8
|
interface Props {
|
|
8
9
|
open: boolean;
|
|
@@ -13,6 +14,7 @@
|
|
|
13
14
|
onUpdate?: (value: Record<string, any>) => void; // For real-time updates
|
|
14
15
|
onOpenReference?: (documentId: string, documentType: string) => void;
|
|
15
16
|
readonly?: boolean;
|
|
17
|
+
organizationId?: string; // For asset uploads to org-specific storage
|
|
16
18
|
}
|
|
17
19
|
|
|
18
20
|
// TODO: add onUpdate to auto save
|
|
@@ -24,7 +26,8 @@
|
|
|
24
26
|
onSave,
|
|
25
27
|
onUpdate,
|
|
26
28
|
onOpenReference,
|
|
27
|
-
readonly = false
|
|
29
|
+
readonly = false,
|
|
30
|
+
organizationId
|
|
28
31
|
}: Props = $props();
|
|
29
32
|
|
|
30
33
|
// Initialize editing data with defaults and existing values
|
|
@@ -33,10 +36,17 @@
|
|
|
33
36
|
|
|
34
37
|
if (schema?.fields) {
|
|
35
38
|
schema.fields.forEach((field) => {
|
|
36
|
-
if (
|
|
37
|
-
|
|
39
|
+
if ('initialValue' in field && field.initialValue !== undefined) {
|
|
40
|
+
// Only use literal initialValue (skip functions to keep this synchronous)
|
|
41
|
+
if (typeof field.initialValue !== 'function') {
|
|
42
|
+
initialData[field.name] = field.initialValue;
|
|
43
|
+
} else {
|
|
44
|
+
// Function-based initialValues are skipped for nested items
|
|
45
|
+
// They will use field type defaults instead
|
|
46
|
+
initialData[field.name] = getDefaultValueForFieldType(field.type);
|
|
47
|
+
}
|
|
38
48
|
} else {
|
|
39
|
-
initialData[field.name] =
|
|
49
|
+
initialData[field.name] = getDefaultValueForFieldType(field.type);
|
|
40
50
|
}
|
|
41
51
|
});
|
|
42
52
|
}
|
|
@@ -116,6 +126,7 @@
|
|
|
116
126
|
}}
|
|
117
127
|
{onOpenReference}
|
|
118
128
|
{readonly}
|
|
129
|
+
{organizationId}
|
|
119
130
|
/>
|
|
120
131
|
{/each}
|
|
121
132
|
{/if}
|
|
@@ -8,6 +8,7 @@ interface Props {
|
|
|
8
8
|
onUpdate?: (value: Record<string, any>) => void;
|
|
9
9
|
onOpenReference?: (documentId: string, documentType: string) => void;
|
|
10
10
|
readonly?: boolean;
|
|
11
|
+
organizationId?: string;
|
|
11
12
|
}
|
|
12
13
|
declare const ObjectModal: import("svelte").Component<Props, {}, "">;
|
|
13
14
|
type ObjectModal = ReturnType<typeof ObjectModal>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ObjectModal.svelte.d.ts","sourceRoot":"","sources":["../../../src/lib/components/admin/ObjectModal.svelte.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"ObjectModal.svelte.d.ts","sourceRoot":"","sources":["../../../src/lib/components/admin/ObjectModal.svelte.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAKtD,UAAU,KAAK;IACd,IAAI,EAAE,OAAO,CAAC;IACd,MAAM,EAAE,UAAU,CAAC;IACnB,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAC3B,OAAO,EAAE,MAAM,IAAI,CAAC;IACpB,MAAM,EAAE,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,KAAK,IAAI,CAAC;IAC7C,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,KAAK,IAAI,CAAC;IAChD,eAAe,CAAC,EAAE,CAAC,UAAU,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,KAAK,IAAI,CAAC;IACrE,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,cAAc,CAAC,EAAE,MAAM,CAAC;CACxB;AAwHF,QAAA,MAAM,WAAW,2CAAwC,CAAC;AAC1D,KAAK,WAAW,GAAG,UAAU,CAAC,OAAO,WAAW,CAAC,CAAC;AAClD,eAAe,WAAW,CAAC"}
|
|
@@ -2,22 +2,33 @@
|
|
|
2
2
|
import { Label } from '@aphexcms/ui/shadcn/label';
|
|
3
3
|
import { Badge } from '@aphexcms/ui/shadcn/badge';
|
|
4
4
|
import * as Alert from '@aphexcms/ui/shadcn/alert';
|
|
5
|
-
import type {
|
|
5
|
+
import type {
|
|
6
|
+
Field,
|
|
7
|
+
DateField as DateFieldType,
|
|
8
|
+
DateTimeField as DateTimeFieldType
|
|
9
|
+
} from 'src/types/schemas.js';
|
|
6
10
|
import {
|
|
7
11
|
isFieldRequired,
|
|
8
12
|
validateField,
|
|
9
13
|
getValidationClasses,
|
|
10
14
|
type ValidationError
|
|
11
15
|
} from '../../field-validation/utils';
|
|
16
|
+
import {
|
|
17
|
+
convertDateToUserFormat,
|
|
18
|
+
convertDateTimeToUserFormat
|
|
19
|
+
} from '../../field-validation/date-utils';
|
|
12
20
|
|
|
13
21
|
// Import individual field components
|
|
14
22
|
import StringField from './fields/StringField.svelte';
|
|
15
23
|
import SlugField from './fields/SlugField.svelte';
|
|
24
|
+
import URLField from './fields/URLField.svelte';
|
|
16
25
|
import TextareaField from './fields/TextareaField.svelte';
|
|
17
26
|
import NumberField from './fields/NumberField.svelte';
|
|
18
27
|
import BooleanField from './fields/BooleanField.svelte';
|
|
19
28
|
import ImageField from './fields/ImageField.svelte';
|
|
20
29
|
import ArrayField from './fields/ArrayField.svelte';
|
|
30
|
+
import DateField from './fields/DateField.svelte';
|
|
31
|
+
import DateTimeField from './fields/DateTimeField.svelte';
|
|
21
32
|
import ReferenceField from './fields/ReferenceField.svelte';
|
|
22
33
|
import SchemaField from './SchemaField.svelte';
|
|
23
34
|
|
|
@@ -31,6 +42,7 @@
|
|
|
31
42
|
schemaType?: string; // Document type
|
|
32
43
|
parentPath?: string; // Parent field path for nested fields
|
|
33
44
|
readonly?: boolean; // Read-only mode for viewers
|
|
45
|
+
organizationId?: string; // Document's organization ID for asset uploads
|
|
34
46
|
}
|
|
35
47
|
|
|
36
48
|
let {
|
|
@@ -42,7 +54,8 @@
|
|
|
42
54
|
doValidation,
|
|
43
55
|
schemaType,
|
|
44
56
|
parentPath,
|
|
45
|
-
readonly = false
|
|
57
|
+
readonly = false,
|
|
58
|
+
organizationId
|
|
46
59
|
}: Props = $props();
|
|
47
60
|
|
|
48
61
|
// Build full field path
|
|
@@ -54,9 +67,47 @@
|
|
|
54
67
|
// Real-time validation for wrapper display
|
|
55
68
|
export async function performValidation(currentValue: any, context: any = {}) {
|
|
56
69
|
validationErrors = []; // Clear previous errors
|
|
57
|
-
|
|
70
|
+
|
|
71
|
+
console.log(`[SchemaField.performValidation] Field "${field.name}" type="${field.type}"`, {
|
|
72
|
+
currentValue,
|
|
73
|
+
context
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
// Convert date/datetime values from ISO to user format for validation
|
|
77
|
+
let valueForValidation = currentValue;
|
|
78
|
+
if (field.type === 'date' && currentValue && typeof currentValue === 'string') {
|
|
79
|
+
const dateField = field as DateFieldType;
|
|
80
|
+
const userFormat = dateField.options?.dateFormat || 'YYYY-MM-DD';
|
|
81
|
+
console.log(`[SchemaField.performValidation] Converting DATE field "${field.name}"`, {
|
|
82
|
+
currentValue,
|
|
83
|
+
userFormat
|
|
84
|
+
});
|
|
85
|
+
valueForValidation = convertDateToUserFormat(currentValue, userFormat);
|
|
86
|
+
console.log(`[SchemaField.performValidation] DATE converted`, {
|
|
87
|
+
valueForValidation
|
|
88
|
+
});
|
|
89
|
+
} else if (field.type === 'datetime' && currentValue && typeof currentValue === 'string') {
|
|
90
|
+
const dateTimeField = field as DateTimeFieldType;
|
|
91
|
+
const dateFormat = dateTimeField.options?.dateFormat || 'YYYY-MM-DD';
|
|
92
|
+
const timeFormat = dateTimeField.options?.timeFormat || 'HH:mm';
|
|
93
|
+
console.log(`[SchemaField.performValidation] Converting DATETIME field "${field.name}"`, {
|
|
94
|
+
currentValue,
|
|
95
|
+
dateFormat,
|
|
96
|
+
timeFormat
|
|
97
|
+
});
|
|
98
|
+
valueForValidation = convertDateTimeToUserFormat(currentValue, dateFormat, timeFormat);
|
|
99
|
+
console.log(`[SchemaField.performValidation] DATETIME converted`, {
|
|
100
|
+
valueForValidation
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
const result = await validateField(field, valueForValidation, context);
|
|
105
|
+
console.log(`[SchemaField.performValidation] Validation result for "${field.name}"`, {
|
|
106
|
+
errors: result.errors
|
|
107
|
+
});
|
|
58
108
|
validationErrors = result.errors;
|
|
59
109
|
}
|
|
110
|
+
|
|
60
111
|
// Computed values
|
|
61
112
|
const hasErrors = $derived(validationErrors.filter((e) => e.level === 'error').length > 0);
|
|
62
113
|
const validationClasses = $derived(getValidationClasses(hasErrors));
|
|
@@ -109,15 +160,21 @@
|
|
|
109
160
|
|
|
110
161
|
<!-- Field type routing to individual components -->
|
|
111
162
|
{#if field.type === 'string'}
|
|
112
|
-
<StringField {field} {value} {onUpdate} {validationClasses} {readonly} />
|
|
163
|
+
<StringField {field} {value} {documentData} {onUpdate} {validationClasses} {readonly} />
|
|
113
164
|
{:else if field.type === 'text'}
|
|
114
165
|
<TextareaField {field} {value} {onUpdate} {validationClasses} {readonly} />
|
|
115
166
|
{:else if field.type === 'slug'}
|
|
116
167
|
<SlugField {field} {value} {documentData} {onUpdate} {validationClasses} {readonly} />
|
|
168
|
+
{:else if field.type === 'url'}
|
|
169
|
+
<URLField {field} {value} {onUpdate} {validationClasses} {readonly} />
|
|
117
170
|
{:else if field.type === 'number'}
|
|
118
171
|
<NumberField {field} {value} {onUpdate} {validationClasses} {readonly} />
|
|
119
172
|
{:else if field.type === 'boolean'}
|
|
120
173
|
<BooleanField {field} {value} {onUpdate} {validationClasses} {readonly} />
|
|
174
|
+
{:else if field.type === 'date'}
|
|
175
|
+
<DateField {field} {value} {onUpdate} {validationClasses} {readonly} />
|
|
176
|
+
{:else if field.type === 'datetime'}
|
|
177
|
+
<DateTimeField {field} {value} {onUpdate} {validationClasses} {readonly} />
|
|
121
178
|
|
|
122
179
|
<!-- Image Field -->
|
|
123
180
|
{:else if field.type === 'image'}
|
|
@@ -129,6 +186,7 @@
|
|
|
129
186
|
{schemaType}
|
|
130
187
|
{fieldPath}
|
|
131
188
|
{readonly}
|
|
189
|
+
{organizationId}
|
|
132
190
|
/>
|
|
133
191
|
|
|
134
192
|
<!-- Object Field -->
|
|
@@ -145,13 +203,14 @@
|
|
|
145
203
|
{schemaType}
|
|
146
204
|
parentPath={fieldPath}
|
|
147
205
|
{readonly}
|
|
206
|
+
{organizationId}
|
|
148
207
|
/>
|
|
149
208
|
{/each}
|
|
150
209
|
</div>
|
|
151
210
|
|
|
152
211
|
<!-- Array Field -->
|
|
153
212
|
{:else if field.type === 'array' && field.of}
|
|
154
|
-
<ArrayField {field} {value} {onUpdate} {onOpenReference} {readonly} />
|
|
213
|
+
<ArrayField {field} {value} {onUpdate} {onOpenReference} {readonly} {organizationId} />
|
|
155
214
|
|
|
156
215
|
<!-- Reference Field -->
|
|
157
216
|
{:else if field.type === 'reference' && field.to}
|
|
@@ -10,6 +10,7 @@ interface Props {
|
|
|
10
10
|
schemaType?: string;
|
|
11
11
|
parentPath?: string;
|
|
12
12
|
readonly?: boolean;
|
|
13
|
+
organizationId?: string;
|
|
13
14
|
}
|
|
14
15
|
declare const SchemaField: import("svelte").Component<Props, {
|
|
15
16
|
performValidation: (currentValue: any, context?: any) => Promise<void>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SchemaField.svelte.d.ts","sourceRoot":"","sources":["../../../src/lib/components/admin/SchemaField.svelte.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"SchemaField.svelte.d.ts","sourceRoot":"","sources":["../../../src/lib/components/admin/SchemaField.svelte.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EACV,KAAK,EAGL,MAAM,sBAAsB,CAAC;AAuB/B,OAAO,WAAW,MAAM,sBAAsB,CAAC;AAG9C,UAAU,KAAK;IACd,KAAK,EAAE,KAAK,CAAC;IACb,KAAK,EAAE,GAAG,CAAC;IACX,YAAY,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IACnC,QAAQ,EAAE,CAAC,KAAK,EAAE,GAAG,KAAK,IAAI,CAAC;IAC/B,eAAe,CAAC,EAAE,CAAC,UAAU,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,KAAK,IAAI,CAAC;IACrE,YAAY,CAAC,EAAE,MAAM,IAAI,CAAC;IAC1B,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,cAAc,CAAC,EAAE,MAAM,CAAC;CACxB;AA6LF,QAAA,MAAM,WAAW;sCAjJgC,GAAG,YAAW,GAAG;MAiJT,CAAC;AAC1D,KAAK,WAAW,GAAG,UAAU,CAAC,OAAO,WAAW,CAAC,CAAC;AAClD,eAAe,WAAW,CAAC"}
|