@inploi/core
Advanced tools
Comparing version 1.5.2 to 1.5.3
import { z } from 'zod'; | ||
import { exhaustive, uniqueByPropertyOrThrow, uniqueOrThrow } from '../common/common.utils'; | ||
import { uniqueByPropertyOrThrow, uniqueOrThrow } from '../common/common.utils'; | ||
@@ -189,36 +189,19 @@ const FIELD_KEY_VALIDATION_REGEX = /^[a-zA-Z_0-9-]+$/; | ||
export const getSchemaForNodeType = (nodeType: FlowNodeType) => { | ||
switch (nodeType) { | ||
case 'text': | ||
return TextNodeSchema; | ||
case 'question-text': | ||
return QuestionTextSchema; | ||
case 'question-file': | ||
return QuestionFileSchema; | ||
case 'complete-flow': | ||
return CompleteFlowNodeSchema; | ||
case 'abandon-flow': | ||
return AbandonFlowNodeSchema; | ||
case 'image': | ||
return ImageNodeSchema; | ||
case 'question-boolean': | ||
return QuestionBooleanSchema; | ||
case 'question-enum': | ||
return QuestionEnumSchema; | ||
case 'question-address': | ||
return QuestionAddressSchema; | ||
case 'if-block': | ||
return IfBlockSchema; | ||
case 'jump': | ||
return JumpNodeSchema; | ||
case 'question-number': | ||
return QuestionNumberSchema; | ||
default: | ||
exhaustive(nodeType); | ||
} | ||
}; | ||
export type FlowNode = z.infer<typeof FlowNodeSchema>; | ||
export const FlowNodesSchema = z.array(FlowNodeSchema); | ||
export const nodeTypeToSchema = { | ||
text: TextNodeSchema, | ||
'question-text': QuestionTextSchema, | ||
'question-file': QuestionFileSchema, | ||
'complete-flow': CompleteFlowNodeSchema, | ||
'abandon-flow': AbandonFlowNodeSchema, | ||
image: ImageNodeSchema, | ||
'question-boolean': QuestionBooleanSchema, | ||
'question-enum': QuestionEnumSchema, | ||
'question-address': QuestionAddressSchema, | ||
'if-block': IfBlockSchema, | ||
jump: JumpNodeSchema, | ||
'question-number': QuestionNumberSchema, | ||
} satisfies Record<FlowNodeType, z.ZodSchema>; | ||
export type FlowNode = z.infer<typeof FlowNodeSchema>; | ||
export type FlowNodeType = FlowNode['type']; |
{ | ||
"name": "@inploi/core", | ||
"version": "1.5.2", | ||
"version": "1.5.3", | ||
"license": "MIT", | ||
@@ -24,3 +24,3 @@ "exports": { | ||
"tsup": "^7.2.0", | ||
"typescript": "^5.1.6", | ||
"typescript": "^5.3.2", | ||
"zod": "^3.22.0", | ||
@@ -34,4 +34,4 @@ "eslint-config-custom": "0.1.0", | ||
"scripts": { | ||
"lint": "eslint ./ --fix --max-warnings 0" | ||
"check": "eslint ./ --fix --max-warnings 0 && tsc" | ||
} | ||
} |
8338
219