1
1
mirror of https://github.com/leon-ai/leon.git synced 2024-11-10 15:19:18 +03:00

feat: add data schemas

This commit is contained in:
louistiti 2022-11-02 00:21:14 +08:00
parent 29d7f16b2c
commit 6c292994fd
No known key found for this signature in database
GPG Key ID: 7ECA3DD523793FE6
5 changed files with 47 additions and 38 deletions

45
core/data/schemas.ts Normal file
View File

@ -0,0 +1,45 @@
import type { Static } from '@sinclair/typebox'
import { Type } from '@sinclair/typebox'
const globalEntity = {
options: Type.Record(
Type.String(),
Type.Object({
synonyms: Type.Array(Type.String()),
data: Type.Record(Type.String(), Type.Array(Type.String()))
})
)
}
const globalResolver = {
name: Type.String(),
intents: Type.Record(
Type.String(),
Type.Object({
utterance_samples: Type.Array(Type.String()),
value: Type.Unknown()
})
)
}
const answers = {
answers: Type.Record(
Type.String(),
Type.Union([
Type.Record(Type.String(), Type.String()),
Type.Array(Type.String())
])
)
}
const globalEntitySchemaObject = Type.Strict(
Type.Object(globalEntity, { additionalProperties: false })
)
const globalResolverSchemaObject = Type.Strict(
Type.Object(globalResolver, { additionalProperties: false })
)
const answersSchemaObject = Type.Strict(
Type.Object(answers, { additionalProperties: false })
)
export type GlobalEntity = Static<typeof globalEntitySchemaObject>
export type GlobalResolver = Static<typeof globalResolverSchemaObject>
export type Answers = Static<typeof answersSchemaObject>

View File

@ -3,7 +3,7 @@ import path from 'node:path'
import type { ShortLanguageCode } from '@/helpers/lang-helper' import type { ShortLanguageCode } from '@/helpers/lang-helper'
import type { Domain } from '@/models/domain' import type { Domain } from '@/models/domain'
import type { GlobalEntity } from '@/models/global-entities' import type { GlobalEntity } from '@@/core/data/schemas'
import type { SkillConfig } from '@/models/skill-config' import type { SkillConfig } from '@/models/skill-config'
import type { Skill, SkillBridge } from '@/models/skill' import type { Skill, SkillBridge } from '@/models/skill'

View File

@ -1,18 +0,0 @@
import type { Static } from '@sinclair/typebox'
import { Type } from '@sinclair/typebox'
export const globalEntity = {
options: Type.Record(
Type.String(),
Type.Object({
synonyms: Type.Array(Type.String()),
data: Type.Record(Type.String(), Type.Array(Type.String()))
})
)
}
export const globalEntitySchemaObject = Type.Strict(
Type.Object(globalEntity, { additionalProperties: false })
)
export type GlobalEntity = Static<typeof globalEntitySchemaObject>

View File

@ -1,19 +0,0 @@
import type { Static } from '@sinclair/typebox'
import { Type } from '@sinclair/typebox'
export const globalResolver = {
name: Type.String(),
intents: Type.Record(
Type.String(),
Type.Object({
utterance_samples: Type.Array(Type.String()),
value: Type.Unknown()
})
)
}
export const globalResolverSchemaObject = Type.Strict(
Type.Object(globalResolver, { additionalProperties: false })
)
export type GlobalResolver = Static<typeof globalResolverSchemaObject>

1
skills/schemas.ts Normal file
View File

@ -0,0 +1 @@
// TODO