diff --git a/CHANGELOG.md b/CHANGELOG.md index c1bf71d..6755155 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ * Added `IterationAtomNode` * Added `IterationAtomNode` to `CallStatementNode` and `InlineCallNode` * Added `ConditionAtomNode` to `InlineCallNode` +* Moved `ProfileAstVisitor` and `MapAstVisitor` from sdk package ### Changed * Renamed `StatementConditionNode` to `ConditionAtomNode` diff --git a/src/interfaces/ast/map-ast.utils.ts b/src/interfaces/ast/map-ast.utils.ts index cbcdca4..5113cda 100644 --- a/src/interfaces/ast/map-ast.utils.ts +++ b/src/interfaces/ast/map-ast.utils.ts @@ -108,3 +108,24 @@ export function isHttpCallStatementNode( export function isInlineCallNode(node: MapASTNode): node is InlineCallNode { return node.kind === 'InlineCall'; } + +export interface MapAstVisitor { + visit(node: MapASTNode): R; + + visitPrimitiveLiteralNode(node: PrimitiveLiteralNode): R; + visitObjectLiteralNode(node: ObjectLiteralNode): R; + visitJessieExpressionNode(node: JessieExpressionNode): R; + visitAssignmentNode(node: AssignmentNode): R; + visitConditionAtomNode(node: ConditionAtomNode): R; + visitIterationAtomNode(node: IterationAtomNode): R; + visitSetStatementNode(node: SetStatementNode): R; + visitCallStatementNode(node: CallStatementNode): R; + visitHttpResponseHandlerNode(node: HttpResponseHandlerNode): R; + visitHttpCallStatementNode(node: HttpCallStatementNode): R; + visitMapDefinitionNode(node: MapDefinitionNode): R; + visitMapHeaderNode(node: MapHeaderNode): R; + visitOperationDefinitionNode(node: OperationDefinitionNode): R; + visitOutcomeStatementNode(node: OutcomeStatementNode): R; + visitInlineCallNode(node: InlineCallNode): R; + visitMapDocumentNode(node: MapDocumentNode): R; +} diff --git a/src/interfaces/ast/profile-ast.utils.ts b/src/interfaces/ast/profile-ast.utils.ts index 11bb71f..27ba31d 100644 --- a/src/interfaces/ast/profile-ast.utils.ts +++ b/src/interfaces/ast/profile-ast.utils.ts @@ -136,3 +136,54 @@ export function isDocumentDefinition( isNamedModelDefinitionNode(node) ); } + +export interface ProfileAstVisitor { + visit(node: ProfileASTNode, ...parameters: unknown[]): R; + visitEnumDefinitionNode( + node: EnumDefinitionNode, + ...parameters: unknown[] + ): R; + visitEnumValueNode(node: EnumValueNode, ...parameters: unknown[]): R; + visitFieldDefinitionNode( + node: FieldDefinitionNode, + ...parameters: unknown[] + ): R; + visitListDefinitionNode( + node: ListDefinitionNode, + ...parameters: unknown[] + ): R; + visitModelTypeNameNode(node: ModelTypeNameNode, ...parameters: unknown[]): R; + visitNamedFieldDefinitionNode( + node: NamedFieldDefinitionNode, + ...parameters: unknown[] + ): R; + visitNamedModelDefinitionNode( + node: NamedModelDefinitionNode, + ...parameters: unknown[] + ): R; + visitNonNullDefinitionNode( + node: NonNullDefinitionNode, + ...parameters: unknown[] + ): R; + visitObjectDefinitionNode( + node: ObjectDefinitionNode, + ...parameters: unknown[] + ): R; + visitPrimitiveTypeNameNode( + node: PrimitiveTypeNameNode, + ...parameters: unknown[] + ): R; + visitProfileDocumentNode( + node: ProfileDocumentNode, + ...parameters: unknown[] + ): R; + visitProfileHeaderNode(node: ProfileHeaderNode, ...parameters: unknown[]): R; + visitUnionDefinitionNode( + node: UnionDefinitionNode, + ...parameters: unknown[] + ): R; + visitUseCaseDefinitionNode( + node: UseCaseDefinitionNode, + ...parameters: unknown[] + ): R; +}