From 721959ecc043557324841a1a7559d0d10ff63003 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Eduard=20Lavu=C5=A1?= Date: Wed, 6 Jan 2021 11:59:16 +0100 Subject: [PATCH 1/2] feat: update profile and map header nodes * removed separate subnodes, all profile and map info is now in one header node * profile: has `scope`, `name` and `version` fields * map: has `provider` and `variant` fields as well as `profile: { scope, name, version }` --- src/interfaces/ast/map-ast.ts | 43 ++++++++++++------------------- src/interfaces/ast/profile-ast.ts | 27 ++++++++++--------- 2 files changed, 29 insertions(+), 41 deletions(-) diff --git a/src/interfaces/ast/map-ast.ts b/src/interfaces/ast/map-ast.ts index 9334731..1a49e0a 100644 --- a/src/interfaces/ast/map-ast.ts +++ b/src/interfaces/ast/map-ast.ts @@ -20,9 +20,7 @@ export type MapNodeKind = | 'MapDefinition' | 'OperationDefinition' // DOCUMENT - | 'ProfileId' - | 'Provider' - | 'Map' + | 'MapHeader' | 'MapDocument'; export interface MapASTNodeBase { @@ -187,31 +185,24 @@ export interface OperationDefinitionNode extends MapASTNodeBase { // DOCUMENT -/** - * `profileId = ` - */ -export interface MapProfileIdNode extends MapASTNodeBase { - kind: 'ProfileId'; - profileId: string; -} - -/** - * `provider = ` - */ -export interface ProviderNode extends MapASTNodeBase { - kind: 'Provider'; - providerId: string; -} - -export interface MapNode extends MapASTNodeBase { - kind: 'Map'; - profileId: MapProfileIdNode; - provider: ProviderNode; +export interface MapHeaderNode extends MapASTNodeBase { + kind: 'MapHeader'; + profile: { + scope?: string; + name: string; + version: { + major: number, + minor: number, + patch: number + }; + }; + provider: string; + variant?: string; } export interface MapDocumentNode extends MapASTNodeBase { kind: 'MapDocument'; - map: MapNode; + header: MapHeaderNode; definitions: (MapDefinitionNode | OperationDefinitionNode)[]; } @@ -229,8 +220,6 @@ export type MapASTNode = | HttpCallStatementNode | MapDefinitionNode | OperationDefinitionNode - | MapProfileIdNode - | ProviderNode - | MapNode + | MapHeaderNode | MapDocumentNode | InlineCallNode; diff --git a/src/interfaces/ast/profile-ast.ts b/src/interfaces/ast/profile-ast.ts index b91ee49..d061e70 100644 --- a/src/interfaces/ast/profile-ast.ts +++ b/src/interfaces/ast/profile-ast.ts @@ -21,8 +21,7 @@ export type ProfileNodeKind = | 'UseCaseSlotDefinition' | 'UseCaseDefinition' // DOCUMENT - | 'ProfileId' - | 'Profile' + | 'ProfileHeader' | 'ProfileDocument'; export interface ProfileASTNodeBase { @@ -202,22 +201,23 @@ export interface UseCaseDefinitionNode // DOCUMENT // -/** `profile = string` */ -export interface ProfileIdNode extends ProfileASTNodeBase { - kind: 'ProfileId'; - profileId: string; -} /** - * The node containing document information at the top of the document. + * The node containing document information. */ -export interface ProfileNode extends ProfileASTNodeBase, DocumentedNode { - kind: 'Profile'; - profileId: ProfileIdNode; +export interface ProfileHeaderNode extends ProfileASTNodeBase, DocumentedNode { + kind: 'ProfileHeader'; + scope?: string; + name: string; + version: { + major: number, + minor: number, + patch: number + }; } /** Node enclosing the whole document */ export interface ProfileDocumentNode extends ProfileASTNodeBase { kind: 'ProfileDocument'; - profile: ProfileNode; + header: ProfileHeaderNode; definitions: DocumentDefinition[]; } export type DocumentDefinition = @@ -237,8 +237,7 @@ export type ProfileASTNode = | ObjectDefinitionNode | PrimitiveTypeNameNode | ProfileDocumentNode - | ProfileIdNode - | ProfileNode + | ProfileHeaderNode | UnionDefinitionNode | UseCaseDefinitionNode | UseCaseSlotDefinitionNode; From b885eb81bafc7dbf113f490ea5c5678407ba6628 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Eduard=20Lavu=C5=A1?= Date: Wed, 6 Jan 2021 12:19:04 +0100 Subject: [PATCH 2/2] fix: fix ast.utils files, run format:fix --- src/interfaces/ast/index.ts | 2 +- src/interfaces/ast/map-ast.ts | 6 +++--- src/interfaces/ast/map-ast.utils.ts | 16 +++------------- src/interfaces/ast/profile-ast.ts | 6 +++--- src/interfaces/ast/profile-ast.utils.ts | 13 +++++-------- 5 files changed, 15 insertions(+), 28 deletions(-) diff --git a/src/interfaces/ast/index.ts b/src/interfaces/ast/index.ts index 502f5cf..6cce541 100644 --- a/src/interfaces/ast/index.ts +++ b/src/interfaces/ast/index.ts @@ -1,4 +1,4 @@ export * from './map-ast'; export * from './map-ast.utils'; export * from './profile-ast'; -export * from './profile-ast.utils'; \ No newline at end of file +export * from './profile-ast.utils'; diff --git a/src/interfaces/ast/map-ast.ts b/src/interfaces/ast/map-ast.ts index 1a49e0a..659958d 100644 --- a/src/interfaces/ast/map-ast.ts +++ b/src/interfaces/ast/map-ast.ts @@ -191,9 +191,9 @@ export interface MapHeaderNode extends MapASTNodeBase { scope?: string; name: string; version: { - major: number, - minor: number, - patch: number + major: number; + minor: number; + patch: number; }; }; provider: string; diff --git a/src/interfaces/ast/map-ast.utils.ts b/src/interfaces/ast/map-ast.utils.ts index 4f24715..5469bad 100644 --- a/src/interfaces/ast/map-ast.utils.ts +++ b/src/interfaces/ast/map-ast.utils.ts @@ -9,13 +9,11 @@ import { MapASTNode, MapDefinitionNode, MapDocumentNode, - MapNode, - MapProfileIdNode, + MapHeaderNode, ObjectLiteralNode, OperationDefinitionNode, OutcomeStatementNode, PrimitiveLiteralNode, - ProviderNode, SetStatementNode, StatementConditionNode, } from './map-ast'; @@ -32,16 +30,12 @@ export function isOperationDefinitionNode( return node.kind === 'OperationDefinition'; } -export function isProviderNode(node: MapASTNode): node is ProviderNode { - return node.kind === 'Provider'; -} - export function isSetStatementNode(node: MapASTNode): node is SetStatementNode { return node.kind === 'SetStatement'; } -export function isMapNode(node: MapASTNode): node is MapNode { - return node.kind === 'Map'; +export function isMapHeaderNode(node: MapASTNode): node is MapHeaderNode { + return node.kind === 'MapHeader'; } export function isMapDefinitionNode( @@ -104,10 +98,6 @@ export function isHttpCallStatementNode( return node.kind === 'HttpCallStatement'; } -export function isMapProfileIdNode(node: MapASTNode): node is MapProfileIdNode { - return node.kind === 'ProfileId'; -} - export function isInlineCallNode(node: MapASTNode): node is InlineCallNode { return node.kind === 'InlineCall'; } diff --git a/src/interfaces/ast/profile-ast.ts b/src/interfaces/ast/profile-ast.ts index d061e70..842155d 100644 --- a/src/interfaces/ast/profile-ast.ts +++ b/src/interfaces/ast/profile-ast.ts @@ -209,9 +209,9 @@ export interface ProfileHeaderNode extends ProfileASTNodeBase, DocumentedNode { scope?: string; name: string; version: { - major: number, - minor: number, - patch: number + major: number; + minor: number; + patch: number; }; } /** Node enclosing the whole document */ diff --git a/src/interfaces/ast/profile-ast.utils.ts b/src/interfaces/ast/profile-ast.utils.ts index 4118b32..11bb71f 100644 --- a/src/interfaces/ast/profile-ast.utils.ts +++ b/src/interfaces/ast/profile-ast.utils.ts @@ -12,8 +12,7 @@ import { PrimitiveTypeNameNode, ProfileASTNode, ProfileDocumentNode, - ProfileIdNode, - ProfileNode, + ProfileHeaderNode, Type, TypeDefinition, TypeName, @@ -116,12 +115,10 @@ export function isUseCaseDefinitionNode( return node.kind === 'UseCaseDefinition'; } -export function isProfileIdNode(node: ProfileASTNode): node is ProfileIdNode { - return node.kind === 'ProfileId'; -} - -export function isProfileNode(node: ProfileASTNode): node is ProfileNode { - return node.kind === 'Profile'; +export function isProfileHeaderNode( + node: ProfileASTNode +): node is ProfileHeaderNode { + return node.kind === 'ProfileHeader'; } export function isProfileDocumentNode(