feat: built-in type read-only view,s chema list, states, spec files
This commit is contained in:
1 parent
3c67cd2314
commit
f514146fed
24 files changed
+1220
-88
No files matched your search
+30
-2
@@ -6459,6 +6459,29 @@ const schemaCustomTypes = [
|
||||
updated_at: updatedAt,
|
||||
}))
|
||||
|
||||
function schemaField(label: string, key: string, type: string, rest: object = {}) {
|
||||
return {
|
||||
key,
|
||||
label,
|
||||
type,
|
||||
required: false,
|
||||
unique: false,
|
||||
default: null,
|
||||
min: null,
|
||||
max: null,
|
||||
options: null,
|
||||
...rest,
|
||||
}
|
||||
}
|
||||
|
||||
const schemaArticleFields = [
|
||||
schemaField('Title', 'title', 'text', { required: true, max: 200 }),
|
||||
schemaField('Slug', 'slug', 'text', { required: true, unique: true }),
|
||||
schemaField('Body', 'body', 'richtext', { max: 10000 }),
|
||||
schemaField('Online', 'online', 'boolean', { default: false }),
|
||||
schemaField('Published on', 'published_on', 'date'),
|
||||
]
|
||||
|
||||
const schemaBuiltinTypes = [
|
||||
['articles', 'Articles', 5],
|
||||
['authors', 'Authors', 5],
|
||||
@@ -6468,7 +6491,12 @@ const schemaBuiltinTypes = [
|
||||
].map(([key, name, fieldCount]) => ({
|
||||
key,
|
||||
name,
|
||||
fields: Array.from({ length: fieldCount as number }, (_, field) => ({ key: `field_${field}` })),
|
||||
fields:
|
||||
key === 'articles'
|
||||
? schemaArticleFields
|
||||
: Array.from({ length: fieldCount as number }, (_, field) => ({
|
||||
key: `field_${field}`,
|
||||
})),
|
||||
}))
|
||||
|
||||
function schemaSession(role: string): ApiMock {
|
||||
@@ -6507,7 +6535,7 @@ const schemaStates: Record<string, VisualState> = {
|
||||
'GET /v1/auth/me': schemaSession('user'),
|
||||
}),
|
||||
},
|
||||
'Built-in type: read-only view': { path: '/schema', skip: 'pending' },
|
||||
'Built-in type: read-only view': { path: '/schema/articles', api: schemaApi() },
|
||||
}
|
||||
|
||||
export const visualStates: Record<string, Record<string, VisualState>> = {
|
||||
|
||||
Reference in new issue
Block a user