Skip to content

Commit

Permalink
Merge branch 'dev' into feat/o-auth
Browse files Browse the repository at this point in the history
  • Loading branch information
lukas-valenta committed Feb 15, 2022
2 parents 7ee5a67 + 2f74d49 commit ffa9032
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 6 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]
### Changed
- removed `typescript-is` and replaced it with `ajv` validation
- `isProfileDocumentNode` and `isMapDocumentNode` do full schema validation

## [1.1.0] - 2022-01-19
### Added
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@superfaceai/ast",
"version": "1.1.1-beta.0",
"version": "1.2.0-rc.0",
"description": "Superface profile and map language ASTs, https://superface.ai",
"main": "dist/index.js",
"source": "src/index.ts",
Expand Down
12 changes: 10 additions & 2 deletions src/interfaces/ast/map-ast.utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,16 @@ const assertMapDocument: Assert<MapDocumentNode> = prepareAssert(
'map-ast'
);

export const isMapDocumentNode = (node: unknown): node is MapDocumentNode => {
try {
assertMapDocument(node);

return true;
} catch {
return false;
}
};

// We don't need to do JSON Schema validation on these, as they should be already validated
export const isAssignmentNode = (node: MapASTNode): node is AssignmentNode =>
node.kind === 'Assignment';
Expand Down Expand Up @@ -55,8 +65,6 @@ export const isJessieExpressionNode = (
export const isMapDefinitionNode = (
node: MapASTNode
): node is MapDefinitionNode => node.kind === 'MapDefinition';
export const isMapDocumentNode = (node: MapASTNode): node is MapDocumentNode =>
node.kind === 'MapDocument';
export const isMapHeaderNode = (node: MapASTNode): node is MapHeaderNode =>
node.kind === 'MapHeader';
export const isObjectLiteralNode = (
Expand Down
15 changes: 12 additions & 3 deletions src/interfaces/ast/profile-ast.utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,18 @@ const assertProfileDocument: Assert<ProfileDocumentNode> = prepareAssert(
'profile-ast'
);

export const isProfileDocumentNode = (
node: unknown
): node is ProfileDocumentNode => {
try {
assertProfileDocument(node);

return true;
} catch {
return false;
}
};

// We don't need to do JSON Schema validation on these, as they should be already validated
export const isEnumDefinitionNode = (
node: ProfileASTNode
Expand Down Expand Up @@ -65,9 +77,6 @@ export const isObjectDefinitionNode = (
export const isPrimitiveTypeNameNode = (
node: ProfileASTNode
): node is PrimitiveTypeNameNode => node.kind === 'PrimitiveTypeName';
export const isProfileDocumentNode = (
node: ProfileASTNode
): node is ProfileDocumentNode => node.kind === 'ProfileDocument';
export const isProfileHeaderNode = (
node: ProfileASTNode
): node is ProfileHeaderNode => node.kind === 'ProfileHeader';
Expand Down

0 comments on commit ffa9032

Please sign in to comment.