diff --git a/core/data/schemas.ts b/core/data/schemas.ts new file mode 100644 index 00000000..74a7e288 --- /dev/null +++ b/core/data/schemas.ts @@ -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 +export type GlobalResolver = Static +export type Answers = Static diff --git a/server/src/helpers/skill-domain-helper.ts b/server/src/helpers/skill-domain-helper.ts index 2181554b..d4a5348b 100644 --- a/server/src/helpers/skill-domain-helper.ts +++ b/server/src/helpers/skill-domain-helper.ts @@ -3,7 +3,7 @@ import path from 'node:path' import type { ShortLanguageCode } from '@/helpers/lang-helper' 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 { Skill, SkillBridge } from '@/models/skill' diff --git a/server/src/models/global-entities.ts b/server/src/models/global-entities.ts deleted file mode 100644 index 0a326da7..00000000 --- a/server/src/models/global-entities.ts +++ /dev/null @@ -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 diff --git a/server/src/models/global-resolvers.ts b/server/src/models/global-resolvers.ts deleted file mode 100644 index 6443ac09..00000000 --- a/server/src/models/global-resolvers.ts +++ /dev/null @@ -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 diff --git a/skills/schemas.ts b/skills/schemas.ts new file mode 100644 index 00000000..70b786d1 --- /dev/null +++ b/skills/schemas.ts @@ -0,0 +1 @@ +// TODO