@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
|
@@ -1,13 +1,69 @@
|
|
|
1
|
+
// Reserved field names that conflict with system properties
|
|
2
|
+
const RESERVED_FIELD_NAMES = [
|
|
3
|
+
'id',
|
|
4
|
+
'type',
|
|
5
|
+
'status',
|
|
6
|
+
'organizationId',
|
|
7
|
+
'createdBy',
|
|
8
|
+
'updatedBy',
|
|
9
|
+
'createdAt',
|
|
10
|
+
'updatedAt',
|
|
11
|
+
'publishedAt',
|
|
12
|
+
'draftData',
|
|
13
|
+
'publishedData',
|
|
14
|
+
'publishedHash'
|
|
15
|
+
];
|
|
16
|
+
/**
|
|
17
|
+
* Check if a field name is reserved
|
|
18
|
+
*/
|
|
19
|
+
export function isReservedFieldName(fieldName) {
|
|
20
|
+
return RESERVED_FIELD_NAMES.includes(fieldName);
|
|
21
|
+
}
|
|
1
22
|
/**
|
|
2
23
|
* Validate all schema references to ensure they exist
|
|
3
24
|
*/
|
|
4
25
|
export function validateSchemaReferences(schemas) {
|
|
5
26
|
const schemaNames = new Set(schemas.map((schema) => schema.name));
|
|
6
27
|
const errors = [];
|
|
28
|
+
// Primitive field types that don't need schema validation
|
|
29
|
+
const primitiveTypes = [
|
|
30
|
+
'string',
|
|
31
|
+
'text',
|
|
32
|
+
'number',
|
|
33
|
+
'boolean',
|
|
34
|
+
'slug',
|
|
35
|
+
'url',
|
|
36
|
+
'image',
|
|
37
|
+
'date',
|
|
38
|
+
'datetime',
|
|
39
|
+
'reference'
|
|
40
|
+
];
|
|
41
|
+
const validFieldTypes = [...primitiveTypes, 'array', 'object'];
|
|
7
42
|
function validateField(field, parentSchema) {
|
|
43
|
+
// Check that field has a valid type (cast to any to access name property)
|
|
44
|
+
if (!field.type) {
|
|
45
|
+
errors.push(`Schema "${parentSchema}" field "${field.name || 'unknown'}" is missing required "type" property`);
|
|
46
|
+
return; // Skip further validation if type is missing
|
|
47
|
+
}
|
|
48
|
+
if (!validFieldTypes.includes(field.type)) {
|
|
49
|
+
errors.push(`Schema "${parentSchema}" field "${field.name}" has invalid type "${field.type}". Valid types: ${validFieldTypes.join(', ')}`);
|
|
50
|
+
}
|
|
51
|
+
// Check for reserved field names
|
|
52
|
+
if (isReservedFieldName(field.name)) {
|
|
53
|
+
errors.push(`Schema "${parentSchema}" uses reserved field name "${field.name}". Reserved names: ${RESERVED_FIELD_NAMES.join(', ')}`);
|
|
54
|
+
}
|
|
8
55
|
// Check array field references
|
|
9
56
|
if (field.type === 'array' && field.of) {
|
|
10
57
|
for (const arrayType of field.of) {
|
|
58
|
+
// Skip validation for primitive types and inline objects
|
|
59
|
+
if (primitiveTypes.includes(arrayType.type)) {
|
|
60
|
+
continue;
|
|
61
|
+
}
|
|
62
|
+
// Skip inline object definitions (has fields property)
|
|
63
|
+
if (arrayType.type === 'object' && arrayType.fields) {
|
|
64
|
+
continue;
|
|
65
|
+
}
|
|
66
|
+
// Only validate if it's a reference to another schema
|
|
11
67
|
if (!schemaNames.has(arrayType.type)) {
|
|
12
68
|
errors.push(`Schema "${parentSchema}" field "${field.name}" references unknown type "${arrayType.type}"`);
|
|
13
69
|
}
|
|
@@ -19,6 +75,14 @@ export function validateSchemaReferences(schemas) {
|
|
|
19
75
|
errors.push(`Schema "${parentSchema}" field "${field.name}" references unknown object type "${field.fields}"`);
|
|
20
76
|
}
|
|
21
77
|
}
|
|
78
|
+
// Check reference field targets
|
|
79
|
+
if (field.type === 'reference' && 'to' in field && field.to) {
|
|
80
|
+
for (const target of field.to) {
|
|
81
|
+
if (!schemaNames.has(target.type)) {
|
|
82
|
+
errors.push(`Schema "${parentSchema}" field "${field.name}" references unknown document type "${target.type}"`);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
}
|
|
22
86
|
// Recursively check nested fields -- cast type later or something. cba
|
|
23
87
|
if ('fields' in field && Array.isArray(field.fields)) {
|
|
24
88
|
for (const nestedField of field.fields) {
|
|
@@ -28,11 +92,67 @@ export function validateSchemaReferences(schemas) {
|
|
|
28
92
|
}
|
|
29
93
|
// Validate each schema
|
|
30
94
|
for (const schema of schemas) {
|
|
95
|
+
// Validate schema type
|
|
96
|
+
if (schema.type !== 'document' && schema.type !== 'object') {
|
|
97
|
+
errors.push(`Schema "${schema.name}" has invalid type "${schema.type}". Must be "document" or "object"`);
|
|
98
|
+
}
|
|
31
99
|
if (schema.fields) {
|
|
32
100
|
for (const field of schema.fields) {
|
|
33
101
|
validateField(field, schema.name);
|
|
34
102
|
}
|
|
35
103
|
}
|
|
104
|
+
// Validate preview config references
|
|
105
|
+
if (schema.preview?.select) {
|
|
106
|
+
const fieldNames = new Set(schema.fields?.map((f) => f.name) || []);
|
|
107
|
+
// Validate title field reference
|
|
108
|
+
if (schema.preview.select.title && !fieldNames.has(schema.preview.select.title)) {
|
|
109
|
+
errors.push(`Schema "${schema.name}" preview.select.title references unknown field "${schema.preview.select.title}"`);
|
|
110
|
+
}
|
|
111
|
+
// Validate subtitle field reference
|
|
112
|
+
if (schema.preview.select.subtitle && !fieldNames.has(schema.preview.select.subtitle)) {
|
|
113
|
+
errors.push(`Schema "${schema.name}" preview.select.subtitle references unknown field "${schema.preview.select.subtitle}"`);
|
|
114
|
+
}
|
|
115
|
+
// Validate media field reference
|
|
116
|
+
if (schema.preview.select.media && !fieldNames.has(schema.preview.select.media)) {
|
|
117
|
+
errors.push(`Schema "${schema.name}" preview.select.media references unknown field "${schema.preview.select.media}"`);
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
// Validate orderings
|
|
121
|
+
if (schema.orderings && schema.orderings.length > 0) {
|
|
122
|
+
const fieldNames = new Set(schema.fields?.map((f) => f.name) || []);
|
|
123
|
+
// Add meta fields that are always available
|
|
124
|
+
fieldNames.add('createdAt');
|
|
125
|
+
fieldNames.add('updatedAt');
|
|
126
|
+
for (const ordering of schema.orderings) {
|
|
127
|
+
// Validate ordering has required properties
|
|
128
|
+
if (!ordering.name) {
|
|
129
|
+
errors.push(`Schema "${schema.name}" has an ordering without a "name" property`);
|
|
130
|
+
continue;
|
|
131
|
+
}
|
|
132
|
+
if (!ordering.title) {
|
|
133
|
+
errors.push(`Schema "${schema.name}" ordering "${ordering.name}" is missing required "title" property`);
|
|
134
|
+
}
|
|
135
|
+
if (!ordering.by || ordering.by.length === 0) {
|
|
136
|
+
errors.push(`Schema "${schema.name}" ordering "${ordering.name}" is missing required "by" array`);
|
|
137
|
+
continue;
|
|
138
|
+
}
|
|
139
|
+
// Validate each field in the ordering
|
|
140
|
+
for (const orderItem of ordering.by) {
|
|
141
|
+
if (!orderItem.field) {
|
|
142
|
+
errors.push(`Schema "${schema.name}" ordering "${ordering.name}" has an item without a "field" property`);
|
|
143
|
+
continue;
|
|
144
|
+
}
|
|
145
|
+
if (!fieldNames.has(orderItem.field)) {
|
|
146
|
+
errors.push(`Schema "${schema.name}" ordering "${ordering.name}" references unknown field "${orderItem.field}"`);
|
|
147
|
+
}
|
|
148
|
+
if (orderItem.direction &&
|
|
149
|
+
orderItem.direction !== 'asc' &&
|
|
150
|
+
orderItem.direction !== 'desc') {
|
|
151
|
+
errors.push(`Schema "${schema.name}" ordering "${ordering.name}" field "${orderItem.field}" has invalid direction "${orderItem.direction}". Must be "asc" or "desc"`);
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
}
|
|
36
156
|
}
|
|
37
157
|
// Throw error if any validation issues found
|
|
38
158
|
if (errors.length > 0) {
|
package/dist/types/filters.d.ts
CHANGED
|
@@ -131,6 +131,19 @@ export interface FindOptions<T = unknown> {
|
|
|
131
131
|
* @default 'draft'
|
|
132
132
|
*/
|
|
133
133
|
perspective?: 'draft' | 'published';
|
|
134
|
+
/**
|
|
135
|
+
* Include documents from child organizations
|
|
136
|
+
* - Only applies when hierarchyEnabled is true
|
|
137
|
+
* @default false
|
|
138
|
+
*/
|
|
139
|
+
includeChildOrganizations?: boolean;
|
|
140
|
+
/**
|
|
141
|
+
* Filter to specific organization IDs
|
|
142
|
+
* - Overrides the default single organizationId filter
|
|
143
|
+
* - Useful for multi-org queries (e.g., parent + children)
|
|
144
|
+
* - RLS will still enforce access control
|
|
145
|
+
*/
|
|
146
|
+
filterOrganizationIds?: string[];
|
|
134
147
|
}
|
|
135
148
|
/**
|
|
136
149
|
* Result from find operations with pagination metadata
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"filters.d.ts","sourceRoot":"","sources":["../../src/lib/types/filters.ts"],"names":[],"mappings":"AAKA;;GAEG;AACH,MAAM,MAAM,WAAW,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,IAAI,GAAG,IAAI,CAAC;AAElE;;;GAGG;AACH,MAAM,WAAW,WAAW,CAAC,CAAC,GAAG,OAAO;IAEvC,MAAM,CAAC,EAAE,CAAC,CAAC;IACX,UAAU,CAAC,EAAE,CAAC,CAAC;IACf,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC;IACT,MAAM,CAAC,EAAE,CAAC,EAAE,CAAC;IAGb,MAAM,CAAC,EAAE,OAAO,CAAC;IAGjB,YAAY,CAAC,EAAE,CAAC,SAAS,MAAM,GAAG,IAAI,GAAG,CAAC,GAAG,MAAM,GAAG,IAAI,CAAC;IAC3D,kBAAkB,CAAC,EAAE,CAAC,SAAS,MAAM,GAAG,IAAI,GAAG,CAAC,GAAG,MAAM,GAAG,IAAI,CAAC;IACjE,SAAS,CAAC,EAAE,CAAC,SAAS,MAAM,GAAG,IAAI,GAAG,CAAC,GAAG,MAAM,GAAG,IAAI,CAAC;IACxD,eAAe,CAAC,EAAE,CAAC,SAAS,MAAM,GAAG,IAAI,GAAG,CAAC,GAAG,MAAM,GAAG,IAAI,CAAC;IAG9D,IAAI,CAAC,EAAE,CAAC,SAAS,MAAM,GAAG,MAAM,GAAG,MAAM,CAAC;IAC1C,QAAQ,CAAC,EAAE,CAAC,SAAS,MAAM,GAAG,MAAM,GAAG,MAAM,CAAC;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AAI,GAAG,IAAI,CAAC;CACxB;AAED,MAAM,WAAW,aAAa;IAC7B,cAAc,EAAE,MAAM,CAAC;IACvB,IAAI,EAAE,gBAAgB,CAAC;IACvB,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,IAAI,CAAC;IAChB,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,SAAS,CAAC,EAAE,IAAI,CAAC;IACjB,UAAU,CAAC,EAAE,IAAI,GAAG,IAAI,CAAC;CACzB;AAED,MAAM,WAAW,sBAAsB;IACtC,yBAAyB,CAAC,EAAE,OAAO,CAAC;CACpC;AAED,MAAM,WAAW,WAAW;IAC3B,SAAS,EAAE,IAAI,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;IACf,oBAAoB,EAAE,MAAM,GAAG,IAAI,CAAC;CACpC;AAED,MAAM,WAAW,cAAc;IAC9B,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,CAAC,EAAE,IAAI,CAAC;IACjB,oBAAoB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CACrC;AAGD,MAAM,WAAW,sBAAsB;IACtC,YAAY,EAAE,YAAY,CAAC;IAC3B,MAAM,EAAE,kBAAkB,CAAC;CAC3B;AAGD,MAAM,WAAW,0BAA0B;IAC1C,MAAM,EAAE,kBAAkB,CAAC;IAC3B,IAAI,EAAE;QACL,EAAE,EAAE,MAAM,CAAC;QACX,KAAK,EAAE,MAAM,CAAC;QACd,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;QACpB,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;KACrB,CAAC;CACF"}
|
package/dist/types/schemas.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Rule } from '../field-validation/rule.js';
|
|
2
2
|
import type { Icon as LucideIcon } from 'lucide-svelte';
|
|
3
|
-
export type FieldType = 'string' | 'text' | 'number' | 'boolean' | 'slug' | 'image' | 'array' | 'object' | 'reference';
|
|
3
|
+
export type FieldType = 'string' | 'text' | 'number' | 'boolean' | 'slug' | 'url' | 'image' | 'array' | 'object' | 'reference' | 'date' | 'datetime';
|
|
4
4
|
export interface BaseField {
|
|
5
5
|
name: string;
|
|
6
6
|
type: FieldType;
|
|
@@ -8,30 +8,54 @@ export interface BaseField {
|
|
|
8
8
|
description?: string;
|
|
9
9
|
validation?: ((rule: Rule) => Rule) | Array<(rule: Rule) => Rule>;
|
|
10
10
|
}
|
|
11
|
+
export interface DependentList {
|
|
12
|
+
dependsOn: string;
|
|
13
|
+
options: Record<string, Array<string | {
|
|
14
|
+
title: string;
|
|
15
|
+
value: string;
|
|
16
|
+
}>>;
|
|
17
|
+
}
|
|
11
18
|
export interface StringField extends BaseField {
|
|
12
19
|
type: 'string';
|
|
13
20
|
maxLength?: number;
|
|
14
21
|
placeholder?: string;
|
|
22
|
+
initialValue?: string | (() => string | Promise<string>);
|
|
23
|
+
list?: Array<string | {
|
|
24
|
+
title: string;
|
|
25
|
+
value: string;
|
|
26
|
+
}> | DependentList;
|
|
27
|
+
options?: {
|
|
28
|
+
layout?: 'dropdown' | 'radio';
|
|
29
|
+
direction?: 'horizontal' | 'vertical';
|
|
30
|
+
};
|
|
15
31
|
}
|
|
16
32
|
export interface TextField extends BaseField {
|
|
17
33
|
type: 'text';
|
|
18
34
|
rows?: number;
|
|
19
35
|
maxLength?: number;
|
|
20
36
|
placeholder?: string;
|
|
37
|
+
initialValue?: string | (() => string | Promise<string>);
|
|
21
38
|
}
|
|
22
39
|
export interface NumberField extends BaseField {
|
|
23
40
|
type: 'number';
|
|
24
41
|
min?: number;
|
|
25
42
|
max?: number;
|
|
43
|
+
initialValue?: number | (() => number | Promise<number>);
|
|
26
44
|
}
|
|
27
45
|
export interface BooleanField extends BaseField {
|
|
28
46
|
type: 'boolean';
|
|
29
|
-
initialValue?: boolean;
|
|
47
|
+
initialValue?: boolean | (() => boolean | Promise<boolean>);
|
|
30
48
|
}
|
|
31
49
|
export interface SlugField extends BaseField {
|
|
32
50
|
type: 'slug';
|
|
33
51
|
source?: string;
|
|
34
52
|
maxLength?: number;
|
|
53
|
+
initialValue?: string | (() => string | Promise<string>);
|
|
54
|
+
}
|
|
55
|
+
export interface URLField extends BaseField {
|
|
56
|
+
type: 'url';
|
|
57
|
+
placeholder?: string;
|
|
58
|
+
initialValue?: string | (() => string | Promise<string>);
|
|
35
59
|
}
|
|
36
60
|
export interface ImageField extends BaseField {
|
|
37
61
|
type: 'image';
|
|
@@ -40,27 +64,51 @@ export interface ImageField extends BaseField {
|
|
|
40
64
|
metadata?: string[];
|
|
41
65
|
fields?: Field[];
|
|
42
66
|
private?: boolean;
|
|
67
|
+
initialValue?: string | (() => string | Promise<string>);
|
|
43
68
|
}
|
|
44
69
|
export interface TypeReference {
|
|
45
70
|
type: string;
|
|
46
71
|
title?: string;
|
|
72
|
+
name?: string;
|
|
73
|
+
fields?: Field[];
|
|
47
74
|
}
|
|
48
75
|
export interface ArrayField extends BaseField {
|
|
49
76
|
type: 'array';
|
|
50
77
|
of: TypeReference[];
|
|
51
|
-
|
|
78
|
+
initialValue?: any[] | (() => any[] | Promise<any[]>);
|
|
52
79
|
}
|
|
53
80
|
export interface ObjectField extends BaseField {
|
|
54
81
|
type: 'object';
|
|
55
82
|
fields: Field[];
|
|
83
|
+
initialValue?: Record<string, any> | (() => Record<string, any> | Promise<Record<string, any>>);
|
|
84
|
+
}
|
|
85
|
+
export interface DateField extends BaseField {
|
|
86
|
+
type: 'date';
|
|
87
|
+
options?: {
|
|
88
|
+
dateFormat?: string;
|
|
89
|
+
calendarTodayLabel?: string;
|
|
90
|
+
};
|
|
91
|
+
initialValue?: string | (() => string | Promise<string>);
|
|
92
|
+
}
|
|
93
|
+
export interface DateTimeField extends BaseField {
|
|
94
|
+
type: 'datetime';
|
|
95
|
+
options?: {
|
|
96
|
+
dateFormat?: string;
|
|
97
|
+
timeFormat?: string;
|
|
98
|
+
timeStep?: number;
|
|
99
|
+
allowTimeZoneSwitch?: boolean;
|
|
100
|
+
displayTimeZone?: string;
|
|
101
|
+
};
|
|
102
|
+
initialValue?: string | (() => string | Promise<string>);
|
|
56
103
|
}
|
|
57
104
|
export interface ReferenceField extends BaseField {
|
|
58
105
|
type: 'reference';
|
|
59
106
|
to: Array<{
|
|
60
107
|
type: string;
|
|
61
108
|
}>;
|
|
109
|
+
initialValue?: any | (() => any | Promise<any>);
|
|
62
110
|
}
|
|
63
|
-
export type Field = StringField | TextField | NumberField | BooleanField | SlugField | ImageField | ArrayField | ObjectField | ReferenceField;
|
|
111
|
+
export type Field = StringField | TextField | NumberField | BooleanField | SlugField | URLField | ImageField | ArrayField | ObjectField | DateField | DateTimeField | ReferenceField;
|
|
64
112
|
export interface PreviewConfig {
|
|
65
113
|
select?: {
|
|
66
114
|
title?: string;
|
|
@@ -68,8 +116,17 @@ export interface PreviewConfig {
|
|
|
68
116
|
media?: string;
|
|
69
117
|
};
|
|
70
118
|
}
|
|
119
|
+
export interface OrderingItem {
|
|
120
|
+
field: string;
|
|
121
|
+
direction: 'asc' | 'desc';
|
|
122
|
+
}
|
|
123
|
+
export interface Ordering {
|
|
124
|
+
title: string;
|
|
125
|
+
name: string;
|
|
126
|
+
by: OrderingItem[];
|
|
127
|
+
}
|
|
71
128
|
export interface DocumentType {
|
|
72
|
-
id
|
|
129
|
+
id?: string;
|
|
73
130
|
type: 'document';
|
|
74
131
|
name: string;
|
|
75
132
|
title: string;
|
|
@@ -77,8 +134,9 @@ export interface DocumentType {
|
|
|
77
134
|
icon?: typeof LucideIcon;
|
|
78
135
|
fields: Field[];
|
|
79
136
|
preview?: PreviewConfig;
|
|
80
|
-
|
|
81
|
-
|
|
137
|
+
orderings?: Ordering[];
|
|
138
|
+
createdAt?: Date | null;
|
|
139
|
+
updatedAt?: Date | null;
|
|
82
140
|
}
|
|
83
141
|
export interface ObjectType {
|
|
84
142
|
type: 'object';
|
|
@@ -101,6 +159,7 @@ export interface SchemaType {
|
|
|
101
159
|
icon?: typeof LucideIcon;
|
|
102
160
|
fields: Field[];
|
|
103
161
|
preview?: PreviewConfig;
|
|
162
|
+
orderings?: Ordering[];
|
|
104
163
|
createdAt?: Date | null;
|
|
105
164
|
updatedAt?: Date | null;
|
|
106
165
|
}
|
|
@@ -113,6 +172,7 @@ export interface NewSchemaType {
|
|
|
113
172
|
icon?: typeof LucideIcon;
|
|
114
173
|
fields: Field[];
|
|
115
174
|
preview?: PreviewConfig;
|
|
175
|
+
orderings?: Ordering[];
|
|
116
176
|
createdAt?: Date | null;
|
|
117
177
|
updatedAt?: Date | null;
|
|
118
178
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schemas.d.ts","sourceRoot":"","sources":["../../src/lib/types/schemas.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,0BAA0B,CAAC;AACrD,OAAO,KAAK,EAAE,IAAI,IAAI,UAAU,EAAE,MAAM,eAAe,CAAC;AAGxD,MAAM,MAAM,SAAS,GAClB,QAAQ,GACR,MAAM,GACN,QAAQ,GACR,SAAS,GACT,MAAM,GACN,OAAO,GACP,OAAO,GACP,QAAQ,GACR,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"schemas.d.ts","sourceRoot":"","sources":["../../src/lib/types/schemas.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,0BAA0B,CAAC;AACrD,OAAO,KAAK,EAAE,IAAI,IAAI,UAAU,EAAE,MAAM,eAAe,CAAC;AAGxD,MAAM,MAAM,SAAS,GAClB,QAAQ,GACR,MAAM,GACN,QAAQ,GACR,SAAS,GACT,MAAM,GACN,KAAK,GACL,OAAO,GACP,OAAO,GACP,QAAQ,GACR,WAAW,GACX,MAAM,GACN,UAAU,CAAC;AAEd,MAAM,WAAW,SAAS;IACzB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,SAAS,CAAC;IAChB,KAAK,EAAE,MAAM,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,SAAS,CAAC,EAAE,IAAI,GAAG,IAAI,CAAC;CACxB"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { Ordering, SchemaType } from '../types/schemas.js';
|
|
2
|
+
/**
|
|
3
|
+
* Generate default orderings for a schema following Sanity's heuristics:
|
|
4
|
+
* 1. If the schema has custom orderings defined, use those
|
|
5
|
+
* 2. Otherwise, look for common title-like fields (title, name, label, etc.)
|
|
6
|
+
* 3. If no common fields, generate orderings for all primitive fields
|
|
7
|
+
* 4. Always include createdAt and updatedAt meta fields
|
|
8
|
+
*/
|
|
9
|
+
export declare function getOrderingsForSchema(schema: SchemaType): Ordering[];
|
|
10
|
+
//# sourceMappingURL=default-orderings.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"default-orderings.d.ts","sourceRoot":"","sources":["../../src/lib/utils/default-orderings.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAE7D;;;;;;GAMG;AACH,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,UAAU,GAAG,QAAQ,EAAE,CAuEpE"}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Generate default orderings for a schema following Sanity's heuristics:
|
|
3
|
+
* 1. If the schema has custom orderings defined, use those
|
|
4
|
+
* 2. Otherwise, look for common title-like fields (title, name, label, etc.)
|
|
5
|
+
* 3. If no common fields, generate orderings for all primitive fields
|
|
6
|
+
* 4. Always include createdAt and updatedAt meta fields
|
|
7
|
+
*/
|
|
8
|
+
export function getOrderingsForSchema(schema) {
|
|
9
|
+
// If custom orderings are defined, use those
|
|
10
|
+
if (schema.orderings && schema.orderings.length > 0) {
|
|
11
|
+
return schema.orderings;
|
|
12
|
+
}
|
|
13
|
+
// Generate default orderings
|
|
14
|
+
const orderings = [];
|
|
15
|
+
// Priority 1: Use preview.select.title if defined
|
|
16
|
+
let titleField = schema.fields.find((field) => schema.preview?.select?.title &&
|
|
17
|
+
field.name === schema.preview.select.title &&
|
|
18
|
+
field.type === 'string');
|
|
19
|
+
// Priority 2: Common field names in priority order (Sanity's heuristic)
|
|
20
|
+
if (!titleField) {
|
|
21
|
+
const commonTitleFields = [
|
|
22
|
+
'title',
|
|
23
|
+
'name',
|
|
24
|
+
'label',
|
|
25
|
+
'heading',
|
|
26
|
+
'header',
|
|
27
|
+
'caption',
|
|
28
|
+
'description'
|
|
29
|
+
];
|
|
30
|
+
titleField = schema.fields.find((field) => field.type === 'string' && commonTitleFields.includes(field.name));
|
|
31
|
+
}
|
|
32
|
+
if (titleField) {
|
|
33
|
+
// Generate ordering for the single most relevant title field (desc only, UI handles toggle)
|
|
34
|
+
orderings.push({
|
|
35
|
+
title: titleField.title,
|
|
36
|
+
name: `${titleField.name}Desc`,
|
|
37
|
+
by: [{ field: titleField.name, direction: 'desc' }]
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
else {
|
|
41
|
+
// No common fields found, generate for all primitive fields
|
|
42
|
+
const primitiveFields = schema.fields.filter((field) => ['string', 'number', 'boolean', 'date', 'datetime'].includes(field.type));
|
|
43
|
+
primitiveFields.forEach((field) => {
|
|
44
|
+
// Only generate desc version, UI handles toggle to asc
|
|
45
|
+
orderings.push({
|
|
46
|
+
title: field.title,
|
|
47
|
+
name: `${field.name}Desc`,
|
|
48
|
+
by: [{ field: field.name, direction: 'desc' }]
|
|
49
|
+
});
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
// Always add meta field orderings at the end (desc only, UI handles toggle)
|
|
53
|
+
orderings.push({
|
|
54
|
+
title: 'Last Edited',
|
|
55
|
+
name: 'updatedAtDesc',
|
|
56
|
+
by: [{ field: 'updatedAt', direction: 'desc' }]
|
|
57
|
+
}, {
|
|
58
|
+
title: 'Created',
|
|
59
|
+
name: 'createdAtDesc',
|
|
60
|
+
by: [{ field: 'createdAt', direction: 'desc' }]
|
|
61
|
+
});
|
|
62
|
+
return orderings;
|
|
63
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { FieldType } from '../types/schemas.js';
|
|
2
|
+
/**
|
|
3
|
+
* Get the default value for a field type
|
|
4
|
+
* @param fieldType - The field type
|
|
5
|
+
* @returns The default value for the field type
|
|
6
|
+
*/
|
|
7
|
+
export declare function getDefaultValueForFieldType(fieldType: FieldType): any;
|
|
8
|
+
//# sourceMappingURL=field-defaults.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"field-defaults.d.ts","sourceRoot":"","sources":["../../src/lib/utils/field-defaults.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAElD;;;;GAIG;AACH,wBAAgB,2BAA2B,CAAC,SAAS,EAAE,SAAS,GAAG,GAAG,CAcrE"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Get the default value for a field type
|
|
3
|
+
* @param fieldType - The field type
|
|
4
|
+
* @returns The default value for the field type
|
|
5
|
+
*/
|
|
6
|
+
export function getDefaultValueForFieldType(fieldType) {
|
|
7
|
+
switch (fieldType) {
|
|
8
|
+
case 'boolean':
|
|
9
|
+
return false;
|
|
10
|
+
case 'array':
|
|
11
|
+
return [];
|
|
12
|
+
case 'object':
|
|
13
|
+
return {};
|
|
14
|
+
case 'number':
|
|
15
|
+
return null;
|
|
16
|
+
default:
|
|
17
|
+
// string, text, slug, url, image, date, datetime, reference
|
|
18
|
+
return '';
|
|
19
|
+
}
|
|
20
|
+
}
|
package/dist/utils/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/lib/utils/index.ts"],"names":[],"mappings":"AAGA,cAAc,uBAAuB,CAAC;AAGtC,cAAc,2BAA2B,CAAC;AAG1C,cAAc,gBAAgB,CAAC;AAC/B,cAAc,QAAQ,CAAC;AACvB,cAAc,aAAa,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/lib/utils/index.ts"],"names":[],"mappings":"AAGA,cAAc,uBAAuB,CAAC;AAGtC,cAAc,2BAA2B,CAAC;AAG1C,cAAc,gBAAgB,CAAC;AAC/B,cAAc,QAAQ,CAAC;AACvB,cAAc,aAAa,CAAC;AAC5B,cAAc,yBAAyB,CAAC"}
|
package/dist/utils/index.js
CHANGED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Helper functions for initialValue date/datetime patterns
|
|
3
|
+
* These can be used directly as initialValue in field definitions
|
|
4
|
+
*
|
|
5
|
+
* Note: Returns values in storage format (ISO),
|
|
6
|
+
* which will be converted to the user's configured display format by the field components
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* Returns the current date in YYYY-MM-DD format (storage format)
|
|
10
|
+
* Usage: initialValue: currentDate
|
|
11
|
+
*/
|
|
12
|
+
export declare function currentDate(): string;
|
|
13
|
+
/**
|
|
14
|
+
* Returns a specific date offset from today
|
|
15
|
+
* Usage: initialValue: () => dateFromToday(7) // 7 days from now
|
|
16
|
+
* Usage: initialValue: () => dateFromToday(-7) // 7 days ago
|
|
17
|
+
*/
|
|
18
|
+
export declare function dateFromToday(days: number): string;
|
|
19
|
+
/**
|
|
20
|
+
* Returns the first day of the current month
|
|
21
|
+
* Usage: initialValue: firstDayOfMonth
|
|
22
|
+
*/
|
|
23
|
+
export declare function firstDayOfMonth(): string;
|
|
24
|
+
/**
|
|
25
|
+
* Returns the last day of the current month
|
|
26
|
+
* Usage: initialValue: lastDayOfMonth
|
|
27
|
+
*/
|
|
28
|
+
export declare function lastDayOfMonth(): string;
|
|
29
|
+
/**
|
|
30
|
+
* Returns the current datetime in ISO UTC format (storage format)
|
|
31
|
+
* Usage: initialValue: currentDateTime
|
|
32
|
+
*/
|
|
33
|
+
export declare function currentDateTime(): string;
|
|
34
|
+
/**
|
|
35
|
+
* Returns a datetime offset from now in ISO UTC format
|
|
36
|
+
* Usage: initialValue: () => dateTimeFromNow(1, 'hour') // 1 hour from now
|
|
37
|
+
* Usage: initialValue: () => dateTimeFromNow(-30, 'minute') // 30 minutes ago
|
|
38
|
+
*/
|
|
39
|
+
export declare function dateTimeFromNow(amount: number, unit: 'minute' | 'hour' | 'day' | 'week' | 'month' | 'year'): string;
|
|
40
|
+
/**
|
|
41
|
+
* Returns the start of the current day in ISO UTC format
|
|
42
|
+
* Usage: initialValue: startOfToday
|
|
43
|
+
*/
|
|
44
|
+
export declare function startOfToday(): string;
|
|
45
|
+
/**
|
|
46
|
+
* Returns the end of the current day in ISO UTC format
|
|
47
|
+
* Usage: initialValue: endOfToday
|
|
48
|
+
*/
|
|
49
|
+
export declare function endOfToday(): string;
|
|
50
|
+
//# sourceMappingURL=initial-value-helpers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"initial-value-helpers.d.ts","sourceRoot":"","sources":["../../src/lib/utils/initial-value-helpers.ts"],"names":[],"mappings":"AAKA;;;;;;GAMG;AAIH;;;GAGG;AACH,wBAAgB,WAAW,IAAI,MAAM,CAEpC;AAED;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAElD;AAED;;;GAGG;AACH,wBAAgB,eAAe,IAAI,MAAM,CAExC;AAED;;;GAGG;AACH,wBAAgB,cAAc,IAAI,MAAM,CAEvC;AAID;;;GAGG;AACH,wBAAgB,eAAe,IAAI,MAAM,CAExC;AAED;;;;GAIG;AACH,wBAAgB,eAAe,CAC9B,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,QAAQ,GAAG,MAAM,GAAG,KAAK,GAAG,MAAM,GAAG,OAAO,GAAG,MAAM,GACzD,MAAM,CAER;AAED;;;GAGG;AACH,wBAAgB,YAAY,IAAI,MAAM,CAErC;AAED;;;GAGG;AACH,wBAAgB,UAAU,IAAI,MAAM,CAEnC"}
|