From a6b68f1f30b89ae97272c00cd02273727e029bf7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20Musil?= Date: Tue, 18 Jul 2023 18:29:39 +0200 Subject: [PATCH 1/4] feat: add optional field bodyType to ApiKeySecurityScheme --- CHANGELOG.md | 6 +++ .../providerjson/providerjson.schema.json | 48 ++++--------------- src/interfaces/providerjson/providerjson.ts | 43 ++++++----------- .../providerjson/providerjson.utils.ts | 9 ---- 4 files changed, 29 insertions(+), 77 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3842b56..52f8b9d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,12 @@ 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] +## Added +- **BREAKING CHANGE**: Added `bodyType` to `ApiKeySecurityScheme` + +## Removed +- **BREAKING CHANGE**: Removed `DigestSecurityScheme` + ### Fixed - Profile AST JSON Schema regenerated diff --git a/src/interfaces/providerjson/providerjson.schema.json b/src/interfaces/providerjson/providerjson.schema.json index 539e9ea..20176bb 100644 --- a/src/interfaces/providerjson/providerjson.schema.json +++ b/src/interfaces/providerjson/providerjson.schema.json @@ -55,6 +55,14 @@ "additionalProperties": false, "description": "Security scheme for api key authorization.", "properties": { + "bodyType": { + "$id": "ApiKeyBodyType", + "description": "Body type to inject security value to.", + "enum": [ + "json" + ], + "type": "string" + }, "id": { "type": "string" }, @@ -136,46 +144,6 @@ "type" ], "type": "object" - }, - { - "$id": "DigestSecurityScheme", - "additionalProperties": false, - "description": "Security scheme for digest authorization.", - "properties": { - "authorizationHeader": { - "description": "Name of header containing authorization eg. Authorization", - "type": "string" - }, - "challengeHeader": { - "description": "Name of header containing challenge from the server eg. www-authenticate", - "type": "string" - }, - "id": { - "type": "string" - }, - "scheme": { - "enum": [ - "digest" - ], - "type": "string" - }, - "statusCode": { - "description": "Code that should be returned from initial call for challenge eg. 401", - "type": "number" - }, - "type": { - "enum": [ - "http" - ], - "type": "string" - } - }, - "required": [ - "id", - "scheme", - "type" - ], - "type": "object" } ], "description": "Type describing general security scheme." diff --git a/src/interfaces/providerjson/providerjson.ts b/src/interfaces/providerjson/providerjson.ts index 7057eb3..4c84565 100644 --- a/src/interfaces/providerjson/providerjson.ts +++ b/src/interfaces/providerjson/providerjson.ts @@ -12,7 +12,7 @@ export enum SecurityType { /** * The placement of the API key. * @$id ApiKeyPlacement - **/ + */ export enum ApiKeyPlacement { HEADER = 'header', BODY = 'body', @@ -20,12 +20,23 @@ export enum ApiKeyPlacement { QUERY = 'query', } +/** + * Type of HTTP Authentication Scheme. + */ export enum HttpScheme { BASIC = 'basic', BEARER = 'bearer', DIGEST = 'digest', } +/** + * Body type to inject security value to. + * @$id ApiKeyBodyType + */ +export enum ApiKeyBodyType { + JSON = 'json', +} + /** * Security scheme for api key authorization. * @$id ApiKeySecurityScheme @@ -33,10 +44,9 @@ export enum HttpScheme { export type ApiKeySecurityScheme = { id: string; type: SecurityType.APIKEY; - /** - * @$ref ApiKeyPlacement - */ + /** @$ref ApiKeyPlacement */ in: ApiKeyPlacement; + bodyType?: ApiKeyBodyType; name?: string; }; @@ -61,36 +71,13 @@ export type BearerTokenSecurityScheme = { bearerFormat?: string; }; -/** - * Security scheme for digest authorization. - * @$id DigestSecurityScheme - */ -export type DigestSecurityScheme = { - id: string; - type: SecurityType.HTTP; - scheme: HttpScheme.DIGEST; - /** - * Code that should be returned from initial call for challenge eg. 401 - */ - statusCode?: number; - /** - * Name of header containing challenge from the server eg. www-authenticate - */ - challengeHeader?: string; - /** - * Name of header containing authorization eg. Authorization - */ - authorizationHeader?: string; -}; - /** * Type describing general security scheme. */ export type SecurityScheme = | ApiKeySecurityScheme | BasicAuthSecurityScheme - | BearerTokenSecurityScheme - | DigestSecurityScheme; + | BearerTokenSecurityScheme; export type ProviderService = { id: string; diff --git a/src/interfaces/providerjson/providerjson.utils.ts b/src/interfaces/providerjson/providerjson.utils.ts index 4c8646b..942f794 100644 --- a/src/interfaces/providerjson/providerjson.utils.ts +++ b/src/interfaces/providerjson/providerjson.utils.ts @@ -6,7 +6,6 @@ import { ApiKeySecurityScheme, BasicAuthSecurityScheme, BearerTokenSecurityScheme, - DigestSecurityScheme, PROVIDER_NAME_REGEX, ProviderJson, SecurityScheme, @@ -38,8 +37,6 @@ export const isBasicAuthSecurityScheme: Guard = prepareIs('BasicAuthSecurityScheme'); export const isBearerTokenSecurityScheme: Guard = prepareIs('BearerTokenSecurityScheme'); -export const isDigestSecurityScheme: Guard = - prepareIs('DigestSecurityScheme'); export function prepareSecurityValues( providerName: string, @@ -65,12 +62,6 @@ export function prepareSecurityValues( id: scheme.id, token: `$${envProviderName}_TOKEN`, }); - } else if (isDigestSecurityScheme(scheme)) { - security.push({ - id: scheme.id, - username: `$${envProviderName}_USERNAME`, - password: `$${envProviderName}_PASSWORD`, - }); } } From 7542b877f4986ca690e796b0160e78eb62b1a812 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20Musil?= Date: Tue, 18 Jul 2023 21:10:35 +0200 Subject: [PATCH 2/4] feat: remove digest security --- src/interfaces/providerjson/providerjson.ts | 1 - .../providerjson/providerjson.utils.test.ts | 148 +------------ .../superjson/superjson.schema.json | 22 -- src/interfaces/superjson/superjson.ts | 196 +++++++++--------- .../superjson/superjson.utils.test.ts | 17 -- src/interfaces/superjson/superjson.utils.ts | 3 - 6 files changed, 104 insertions(+), 283 deletions(-) diff --git a/src/interfaces/providerjson/providerjson.ts b/src/interfaces/providerjson/providerjson.ts index 4c84565..088ab7f 100644 --- a/src/interfaces/providerjson/providerjson.ts +++ b/src/interfaces/providerjson/providerjson.ts @@ -26,7 +26,6 @@ export enum ApiKeyPlacement { export enum HttpScheme { BASIC = 'basic', BEARER = 'bearer', - DIGEST = 'digest', } /** diff --git a/src/interfaces/providerjson/providerjson.utils.test.ts b/src/interfaces/providerjson/providerjson.utils.test.ts index 8c8b373..c17ca72 100644 --- a/src/interfaces/providerjson/providerjson.utils.test.ts +++ b/src/interfaces/providerjson/providerjson.utils.test.ts @@ -1,5 +1,6 @@ import { IntegrationParameter, prepareProviderParameters } from '.'; import { + ApiKeyBodyType, ApiKeyPlacement, HttpScheme, SecurityScheme, @@ -10,7 +11,6 @@ import { isApiKeySecurityScheme, isBasicAuthSecurityScheme, isBearerTokenSecurityScheme, - isDigestSecurityScheme, isValidProviderName, prepareSecurityValues, } from './providerjson.utils'; @@ -42,14 +42,6 @@ describe('ProviderJsonDocument', () => { "id": "swapidev", "type": "http", "scheme": "basic" - }, - { - "id": "swapidev", - "type": "http", - "scheme": "digest", - "statusCode": 401, - "challengeHeader": "www-authenticate", - "authorizationHeader": "authorizaation" } ], "defaultService": "swapidev", @@ -81,15 +73,7 @@ describe('ProviderJsonDocument', () => { id: 'swapidev', type: 'http', scheme: 'basic', - }, - { - id: 'swapidev', - type: 'http', - scheme: 'digest', - statusCode: 401, - challengeHeader: 'www-authenticate', - authorizationHeader: 'authorizaation', - }, + } ], defaultService: 'swapidev', parameters: [{ name: 'userId', description: "some user's id" }], @@ -382,7 +366,8 @@ describe('ProviderJsonDocument', () => { isApiKeySecurityScheme({ id: 'swapidev', type: SecurityType.APIKEY, - in: ApiKeyPlacement.PATH, + in: ApiKeyPlacement.BODY, + bodyType: ApiKeyBodyType.JSON, name: 'X-API-Key', }) ).toEqual(true); @@ -392,7 +377,7 @@ describe('ProviderJsonDocument', () => { isApiKeySecurityScheme({ id: 'swapidev', type: SecurityType.APIKEY, - in: ApiKeyPlacement.QUERY, + in: ApiKeyPlacement.PATH, name: 'X-API-Key', }) ).toEqual(true); @@ -401,17 +386,18 @@ describe('ProviderJsonDocument', () => { expect( isApiKeySecurityScheme({ id: 'swapidev', - type: SecurityType.HTTP, - scheme: HttpScheme.BEARER, + type: SecurityType.APIKEY, + in: ApiKeyPlacement.QUERY, + name: 'X-API-Key', }) - ).toEqual(false); + ).toEqual(true); } { expect( isApiKeySecurityScheme({ id: 'swapidev', type: SecurityType.HTTP, - scheme: HttpScheme.BASIC, + scheme: HttpScheme.BEARER, }) ).toEqual(false); } @@ -420,7 +406,7 @@ describe('ProviderJsonDocument', () => { isApiKeySecurityScheme({ id: 'swapidev', type: SecurityType.HTTP, - scheme: HttpScheme.DIGEST, + scheme: HttpScheme.BASIC, }) ).toEqual(false); } @@ -455,15 +441,6 @@ describe('ProviderJsonDocument', () => { }) ).toEqual(true); } - { - expect( - isBasicAuthSecurityScheme({ - id: 'swapidev', - type: SecurityType.HTTP, - scheme: HttpScheme.DIGEST, - }) - ).toEqual(false); - } }); it('checks BearerTokenSecurity type correctly', () => { @@ -495,101 +472,8 @@ describe('ProviderJsonDocument', () => { }) ).toEqual(false); } - { - expect( - isBearerTokenSecurityScheme({ - id: 'swapidev', - type: SecurityType.HTTP, - scheme: HttpScheme.DIGEST, - }) - ).toEqual(false); - } }); - it('checks DigestAuthSecurity type correctly', () => { - { - expect( - isDigestSecurityScheme({ - id: 'swapidev', - type: SecurityType.APIKEY, - in: ApiKeyPlacement.HEADER, - name: 'X-API-Key', - }) - ).toEqual(false); - } - { - expect( - isDigestSecurityScheme({ - id: 'swapidev', - type: SecurityType.HTTP, - scheme: HttpScheme.BEARER, - }) - ).toEqual(false); - } - { - expect( - isDigestSecurityScheme({ - id: 'swapidev', - type: SecurityType.HTTP, - scheme: HttpScheme.BASIC, - }) - ).toEqual(false); - } - { - expect( - isDigestSecurityScheme({ - id: 'swapidev', - type: SecurityType.HTTP, - scheme: HttpScheme.DIGEST, - }) - ).toEqual(true); - } - { - expect( - isDigestSecurityScheme({ - id: 'swapidev', - type: SecurityType.HTTP, - scheme: HttpScheme.DIGEST, - statusCode: 401, - }) - ).toEqual(true); - } - { - expect( - isDigestSecurityScheme({ - id: 'swapidev', - type: SecurityType.HTTP, - scheme: HttpScheme.DIGEST, - statusCode: 401, - challengeHeader: 'test', - }) - ).toEqual(true); - } - { - expect( - isDigestSecurityScheme({ - id: 'swapidev', - type: SecurityType.HTTP, - scheme: HttpScheme.DIGEST, - statusCode: 401, - challengeHeader: 'test', - authorizationHeader: 'auth', - }) - ).toEqual(true); - } - { - expect( - isDigestSecurityScheme({ - id: 'swapidev', - type: SecurityType.HTTP, - scheme: HttpScheme.DIGEST, - statusCode: undefined, - challengeHeader: undefined, - authorizationHeader: undefined, - }) - ).toEqual(true); - } - }); }); describe('ProviderJson name check', () => { it('checks Provider name correctly', () => { @@ -622,11 +506,6 @@ describe('prepareSecurityValues', () => { type: SecurityType.HTTP, scheme: HttpScheme.BASIC, }, - { - id: 'digest', - type: SecurityType.HTTP, - scheme: HttpScheme.DIGEST, - }, ]; it('prepares security values', () => { @@ -644,11 +523,6 @@ describe('prepareSecurityValues', () => { username: `$TEST_PROVIDER_USERNAME`, password: `$TEST_PROVIDER_PASSWORD`, }, - { - id: 'digest', - username: `$TEST_PROVIDER_USERNAME`, - password: `$TEST_PROVIDER_PASSWORD`, - }, ]); }); diff --git a/src/interfaces/superjson/superjson.schema.json b/src/interfaces/superjson/superjson.schema.json index 0c98f52..2e4f57a 100644 --- a/src/interfaces/superjson/superjson.schema.json +++ b/src/interfaces/superjson/superjson.schema.json @@ -733,28 +733,6 @@ "token" ], "type": "object" - }, - { - "$id": "DigestSecurityValues", - "additionalProperties": false, - "description": "Security values for digest security scheme", - "properties": { - "id": { - "type": "string" - }, - "password": { - "type": "string" - }, - "username": { - "type": "string" - } - }, - "required": [ - "id", - "password", - "username" - ], - "type": "object" } ], "description": "Authorization variables." diff --git a/src/interfaces/superjson/superjson.ts b/src/interfaces/superjson/superjson.ts index 4273fa5..a669050 100644 --- a/src/interfaces/superjson/superjson.ts +++ b/src/interfaces/superjson/superjson.ts @@ -32,18 +32,18 @@ export enum BackoffKind { export type BackoffPolicy = | BackoffKind.EXPONENTIAL | { - kind: BackoffKind.EXPONENTIAL; - /** - * @TJS-minimum 0 - * @TJS-type integer - **/ - start?: number; - /** - * @TJS-minimum 0 - * @TJS-type integer - **/ - factor?: number; - }; + kind: BackoffKind.EXPONENTIAL; + /** + * @TJS-minimum 0 + * @TJS-type integer + **/ + start?: number; + /** + * @TJS-minimum 0 + * @TJS-type integer + **/ + factor?: number; + }; /** * Retry policy configuration. @@ -51,42 +51,42 @@ export type BackoffPolicy = export type RetryPolicy = | OnFail.NONE | { - kind: OnFail.NONE; - } + kind: OnFail.NONE; + } | OnFail.SIMPLE | { - kind: OnFail.SIMPLE; - /** - * @TJS-minimum 0 - * @TJS-type integer - **/ - maxContiguousRetries?: number; - /** - * @TJS-minimum 0 - * @TJS-type integer - **/ - requestTimeout?: number; - } + kind: OnFail.SIMPLE; + /** + * @TJS-minimum 0 + * @TJS-type integer + **/ + maxContiguousRetries?: number; + /** + * @TJS-minimum 0 + * @TJS-type integer + **/ + requestTimeout?: number; + } | OnFail.CIRCUIT_BREAKER | { - kind: OnFail.CIRCUIT_BREAKER; - /** - * @TJS-minimum 0 - * @TJS-type integer - **/ - maxContiguousRetries?: number; - /** - * @TJS-minimum 0 - * @TJS-type integer - **/ - openTime?: number; - /** - * @TJS-minimum 0 - * @TJS-type integer - **/ - requestTimeout?: number; - backoff?: BackoffPolicy; - }; + kind: OnFail.CIRCUIT_BREAKER; + /** + * @TJS-minimum 0 + * @TJS-type integer + **/ + maxContiguousRetries?: number; + /** + * @TJS-minimum 0 + * @TJS-type integer + **/ + openTime?: number; + /** + * @TJS-minimum 0 + * @TJS-type integer + **/ + requestTimeout?: number; + backoff?: BackoffPolicy; + }; export type NormalizedBackoffPolicy = { kind: BackoffKind.EXPONENTIAL; @@ -104,40 +104,40 @@ export type NormalizedBackoffPolicy = { export type NormalizedRetryPolicy = | { - kind: OnFail.NONE; - } + kind: OnFail.NONE; + } | { - kind: OnFail.SIMPLE; - /** - * @TJS-minimum 0 - * @TJS-type integer - **/ - maxContiguousRetries?: number; - /** - * @TJS-minimum 0 - * @TJS-type integer - **/ - requestTimeout?: number; - } + kind: OnFail.SIMPLE; + /** + * @TJS-minimum 0 + * @TJS-type integer + **/ + maxContiguousRetries?: number; + /** + * @TJS-minimum 0 + * @TJS-type integer + **/ + requestTimeout?: number; + } | { - kind: OnFail.CIRCUIT_BREAKER; - /** - * @TJS-minimum 0 - * @TJS-type integer - **/ - maxContiguousRetries?: number; - /** - * @TJS-minimum 0 - * @TJS-type integer - **/ - openTime?: number; - /** - * @TJS-minimum 0 - * @TJS-type integer - **/ - requestTimeout?: number; - backoff: NormalizedBackoffPolicy; - }; + kind: OnFail.CIRCUIT_BREAKER; + /** + * @TJS-minimum 0 + * @TJS-type integer + **/ + maxContiguousRetries?: number; + /** + * @TJS-minimum 0 + * @TJS-type integer + **/ + openTime?: number; + /** + * @TJS-minimum 0 + * @TJS-type integer + **/ + requestTimeout?: number; + backoff: NormalizedBackoffPolicy; + }; /** * Default per usecase values. @@ -179,25 +179,25 @@ export type NormalizedProfileProviderDefaults = { export type ProfileProviderSettings = { defaults?: ProfileProviderDefaults; } & ( - | { + | { file: string; } - | { + | { mapVariant?: string; mapRevision?: string; } -); + ); export type NormalizedProfileProviderSettings = | { - file: string; - defaults: NormalizedProfileProviderDefaults; - } + file: string; + defaults: NormalizedProfileProviderDefaults; + } | { - mapVariant?: string; - mapRevision?: string; - defaults: NormalizedProfileProviderDefaults; - }; + mapVariant?: string; + mapRevision?: string; + defaults: NormalizedProfileProviderDefaults; + }; /** * Profile provider entry containing either `profileProviderSettings` or shorthands. @@ -212,29 +212,29 @@ export type ProfileSettings = { defaults?: UsecaseDefaults; providers?: { [provider: string]: UriPath | ProfileProviderEntry }; } & ( - | { + | { version: SemanticVersion; } - | { + | { file: string; } -); + ); export type NormalizedProfileSettings = { priority: string[]; defaults: NormalizedUsecaseDefaults; providers: { [provider: string]: NormalizedProfileProviderSettings }; } & ( - | { + | { version: SemanticVersion; } - | { + | { file: string; priority: string[]; defaults: NormalizedUsecaseDefaults; providers: { [provider: string]: NormalizedProfileProviderSettings }; } -); + ); /** * Profile entry containing either `profileSettings` or shorthands. @@ -267,23 +267,13 @@ export type BearerTokenSecurityValues = IdBase & { token: string; }; -/** - * Security values for digest security scheme - * @$id DigestSecurityValues - **/ -export type DigestSecurityValues = IdBase & { - username: string; - password: string; -}; - /** * Authorization variables. */ export type SecurityValues = | ApiKeySecurityValues | BasicAuthSecurityValues - | BearerTokenSecurityValues - | DigestSecurityValues; + | BearerTokenSecurityValues; /** * Expanded provider settings for one provider name. diff --git a/src/interfaces/superjson/superjson.utils.test.ts b/src/interfaces/superjson/superjson.utils.test.ts index 9c840b3..f28aae6 100644 --- a/src/interfaces/superjson/superjson.utils.test.ts +++ b/src/interfaces/superjson/superjson.utils.test.ts @@ -3,7 +3,6 @@ import { isApiKeySecurityValues, isBasicAuthSecurityValues, isBearerTokenSecurityValues, - isDigestSecurityValues, isFileURIString, isVersionString, } from './superjson.utils'; @@ -153,20 +152,4 @@ describe('super.json utils', () => { expect(isBearerTokenSecurityValues({ id: 7 })).toBe(false); }); }); - - describe('isDigestSecurityValues', () => { - it('should return true on valid values', () => { - expect( - isDigestSecurityValues({ - id: 'some-id', - username: 'some-user-name', - password: 'some-password', - }) - ).toBe(true); - }); - - it('should return false on invalid values', () => { - expect(isDigestSecurityValues({ id: 7 })).toBe(false); - }); - }); }); diff --git a/src/interfaces/superjson/superjson.utils.ts b/src/interfaces/superjson/superjson.utils.ts index 6d9630b..99e71b7 100644 --- a/src/interfaces/superjson/superjson.utils.ts +++ b/src/interfaces/superjson/superjson.utils.ts @@ -5,7 +5,6 @@ import { ApiKeySecurityValues, BasicAuthSecurityValues, BearerTokenSecurityValues, - DigestSecurityValues, FILE_URI_REGEX, SEMVER_REGEX, SuperJsonDocument, @@ -40,5 +39,3 @@ export const isBasicAuthSecurityValues: Guard = prepareIs('BasicAuthSecurityValues'); export const isBearerTokenSecurityValues: Guard = prepareIs('BearerTokenSecurityValues'); -export const isDigestSecurityValues: Guard = - prepareIs('DigestSecurityValues'); From f25297eb29beb5fb6358f3de7b1920757fc0a1f6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20Musil?= Date: Wed, 19 Jul 2023 10:26:37 +0200 Subject: [PATCH 3/4] chore: remove superjson --- .husky/pre-commit | 7 - CHANGELOG.md | 1 + package.json | 5 +- src/interfaces/index.ts | 1 - .../providerjson/providerjson.schema.json | 187 +++-- src/interfaces/providerjson/providerjson.ts | 34 + .../providerjson/providerjson.utils.ts | 3 +- src/interfaces/superjson/index.ts | 2 - .../superjson/superjson.schema.json | 755 ------------------ src/interfaces/superjson/superjson.ts | 318 -------- .../superjson/superjson.utils.test.ts | 155 ---- src/interfaces/superjson/superjson.utils.ts | 41 - 12 files changed, 127 insertions(+), 1382 deletions(-) delete mode 100644 src/interfaces/superjson/index.ts delete mode 100644 src/interfaces/superjson/superjson.schema.json delete mode 100644 src/interfaces/superjson/superjson.ts delete mode 100644 src/interfaces/superjson/superjson.utils.test.ts delete mode 100644 src/interfaces/superjson/superjson.utils.ts diff --git a/.husky/pre-commit b/.husky/pre-commit index 1359698..87b189d 100755 --- a/.husky/pre-commit +++ b/.husky/pre-commit @@ -6,12 +6,10 @@ GENERATED=0 if [[ "$OSTYPE" == "darwin"* ]]; then MAP_AST_CHANGED=$((`stat -f "%c" src/interfaces/ast/map-ast.ts` - `stat -f "%c" src/interfaces/ast/map-ast.schema.json`)) PROFILE_AST_CHANGED=$((`stat -f "%c" src/interfaces/ast/profile-ast.ts` - `stat -f "%c" src/interfaces/ast/profile-ast.schema.json`)) - SUPERJSON_AST_CHANGED=$((`stat -f "%c" src/interfaces/superjson/superjson.ts` - `stat -f "%c" src/interfaces/superjson/superjson.schema.json`)) PROVIDERJSON_AST_CHANGED=$((`stat -f "%c" src/interfaces/providerjson/providerjson.ts` - `stat -f "%c" src/interfaces/providerjson/providerjson.schema.json`)) else MAP_AST_CHANGED=$((`stat --format="%Y" src/interfaces/ast/map-ast.ts` - `stat --format="%Y" src/interfaces/ast/map-ast.schema.json`)) PROFILE_AST_CHANGED=$((`stat --format="%Y" src/interfaces/ast/profile-ast.ts` - `stat --format="%Y" src/interfaces/ast/profile-ast.schema.json`)) - SUPERJSON_AST_CHANGED=$((`stat --format="%Y" src/interfaces/superjson/superjson.ts` - `stat --format="%Y" src/interfaces/superjson/superjson.schema.json`)) PROVIDERJSON_AST_CHANGED=$((`stat --format="%Y" src/interfaces/providerjson/providerjson.ts` - `stat --format="%Y" src/interfaces/providerjson/providerjson.schema.json`)) fi @@ -26,11 +24,6 @@ if [ $PROFILE_AST_CHANGED -gt 0 ]; then GENERATED=1 fi -if [ $SUPERJSON_AST_CHANGED -gt 0 ]; then - yarn run --silent generate_superjson_schema - GENERATED=1 -fi - if [ $PROVIDERJSON_AST_CHANGED -gt 0 ]; then yarn run --silent generate_providerjson_schema GENERATED=1 diff --git a/CHANGELOG.md b/CHANGELOG.md index 52f8b9d..495ce57 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## Removed - **BREAKING CHANGE**: Removed `DigestSecurityScheme` +- **BREAKING CHANGE**: Removed superjson schema ### Fixed - Profile AST JSON Schema regenerated diff --git a/package.json b/package.json index 7e8e8dc..28cb3b1 100644 --- a/package.json +++ b/package.json @@ -24,9 +24,8 @@ "generate_schema": "typescript-json-schema --noExtraProps --required --strictNullChecks --tsNodeRegister --topRef", "generate_profile_schema": "yarn run generate_schema src/interfaces/ast/profile-ast.ts ProfileDocumentNode -o src/interfaces/ast/profile-ast.schema.json", "generate_map_schema": "yarn run generate_schema src/interfaces/ast/map-ast.ts MapDocumentNode -o src/interfaces/ast/map-ast.schema.json", - "generate_superjson_schema": "yarn run generate_schema src/interfaces/superjson/superjson.ts SuperJsonDocument -o src/interfaces/superjson/superjson.schema.json", "generate_providerjson_schema": "yarn run generate_schema src/interfaces/providerjson/providerjson.ts ProviderJson -o src/interfaces/providerjson/providerjson.schema.json", - "generate_schemas": "yarn run generate_profile_schema && yarn run generate_map_schema && yarn run generate_superjson_schema && yarn run generate_providerjson_schema", + "generate_schemas": "yarn run generate_profile_schema && yarn run generate_map_schema && yarn run generate_providerjson_schema", "prepare": "husky install" }, "dependencies": { @@ -52,4 +51,4 @@ "typescript": "^4", "typescript-json-schema": "^0.50.1" } -} +} \ No newline at end of file diff --git a/src/interfaces/index.ts b/src/interfaces/index.ts index f735675..e7a3dbf 100644 --- a/src/interfaces/index.ts +++ b/src/interfaces/index.ts @@ -1,3 +1,2 @@ export * from './ast'; -export * from './superjson'; export * from './providerjson'; diff --git a/src/interfaces/providerjson/providerjson.schema.json b/src/interfaces/providerjson/providerjson.schema.json index 20176bb..90a75af 100644 --- a/src/interfaces/providerjson/providerjson.schema.json +++ b/src/interfaces/providerjson/providerjson.schema.json @@ -13,6 +13,94 @@ "query" ], "type": "string" + }, + "SecurityScheme": { + "anyOf": [ + { + "$id": "ApiKeySecurityScheme", + "additionalProperties": false, + "description": "Security scheme for api key authorization.", + "properties": { + "bodyType": { + "$id": "ApiKeyBodyType", + "const": "json", + "description": "Body type to inject security value to.", + "type": "string" + }, + "id": { + "type": "string" + }, + "in": { + "$ref": "ApiKeyPlacement" + }, + "name": { + "type": "string" + }, + "type": { + "const": "apiKey", + "type": "string" + } + }, + "required": [ + "id", + "in", + "type" + ], + "type": "object" + }, + { + "$id": "BasicAuthSecurityScheme", + "additionalProperties": false, + "description": "Security scheme for basic authorization.", + "properties": { + "id": { + "type": "string" + }, + "scheme": { + "const": "basic", + "type": "string" + }, + "type": { + "const": "http", + "type": "string" + } + }, + "required": [ + "id", + "scheme", + "type" + ], + "type": "object" + }, + { + "$id": "BearerTokenSecurityScheme", + "additionalProperties": false, + "description": "Security scheme for bearer authorization.", + "properties": { + "bearerFormat": { + "type": "string" + }, + "id": { + "type": "string" + }, + "scheme": { + "const": "bearer", + "type": "string" + }, + "type": { + "const": "http", + "type": "string" + } + }, + "required": [ + "id", + "scheme", + "type" + ], + "type": "object" + } + ], + "description": "Type describing general security scheme." } }, "description": "Type decribing provider.json document.", @@ -49,104 +137,7 @@ }, "securitySchemes": { "items": { - "anyOf": [ - { - "$id": "ApiKeySecurityScheme", - "additionalProperties": false, - "description": "Security scheme for api key authorization.", - "properties": { - "bodyType": { - "$id": "ApiKeyBodyType", - "description": "Body type to inject security value to.", - "enum": [ - "json" - ], - "type": "string" - }, - "id": { - "type": "string" - }, - "in": { - "$ref": "ApiKeyPlacement" - }, - "name": { - "type": "string" - }, - "type": { - "enum": [ - "apiKey" - ], - "type": "string" - } - }, - "required": [ - "id", - "in", - "type" - ], - "type": "object" - }, - { - "$id": "BasicAuthSecurityScheme", - "additionalProperties": false, - "description": "Security scheme for basic authorization.", - "properties": { - "id": { - "type": "string" - }, - "scheme": { - "enum": [ - "basic" - ], - "type": "string" - }, - "type": { - "enum": [ - "http" - ], - "type": "string" - } - }, - "required": [ - "id", - "scheme", - "type" - ], - "type": "object" - }, - { - "$id": "BearerTokenSecurityScheme", - "additionalProperties": false, - "description": "Security scheme for bearer authorization.", - "properties": { - "bearerFormat": { - "type": "string" - }, - "id": { - "type": "string" - }, - "scheme": { - "enum": [ - "bearer" - ], - "type": "string" - }, - "type": { - "enum": [ - "http" - ], - "type": "string" - } - }, - "required": [ - "id", - "scheme", - "type" - ], - "type": "object" - } - ], - "description": "Type describing general security scheme." + "$ref": "#/definitions/SecurityScheme" }, "type": "array" }, diff --git a/src/interfaces/providerjson/providerjson.ts b/src/interfaces/providerjson/providerjson.ts index 088ab7f..3c5be15 100644 --- a/src/interfaces/providerjson/providerjson.ts +++ b/src/interfaces/providerjson/providerjson.ts @@ -95,6 +95,40 @@ export type IntegrationParameter = { default?: string; }; +export type IdBase = { + id: string; +}; + +/** + * @$id ApiKeySecurityValues + **/ +export type ApiKeySecurityValues = IdBase & { + apikey: string; +}; + +/** + * @$id BasicAuthSecurityValues + **/ +export type BasicAuthSecurityValues = IdBase & { + username: string; + password: string; +}; + +/** + * @$id BearerTokenSecurityValues + **/ +export type BearerTokenSecurityValues = IdBase & { + token: string; +}; + +/** + * Authorization variables. + */ +export type SecurityValues = + | ApiKeySecurityValues + | BasicAuthSecurityValues + | BearerTokenSecurityValues; + /** * Type decribing provider.json document. * @$id ProviderJson diff --git a/src/interfaces/providerjson/providerjson.utils.ts b/src/interfaces/providerjson/providerjson.utils.ts index 942f794..8ae46cb 100644 --- a/src/interfaces/providerjson/providerjson.utils.ts +++ b/src/interfaces/providerjson/providerjson.utils.ts @@ -1,7 +1,6 @@ import { prepareAssert, preparePrepareIs } from '../../validation'; import { Assert, Guard } from '../ast'; -import { SecurityValues } from '../superjson'; -import { IntegrationParameter } from '.'; +import { IntegrationParameter, SecurityValues } from '.'; import { ApiKeySecurityScheme, BasicAuthSecurityScheme, diff --git a/src/interfaces/superjson/index.ts b/src/interfaces/superjson/index.ts deleted file mode 100644 index b7413f1..0000000 --- a/src/interfaces/superjson/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -export * from './superjson'; -export * from './superjson.utils'; diff --git a/src/interfaces/superjson/superjson.schema.json b/src/interfaces/superjson/superjson.schema.json deleted file mode 100644 index 2e4f57a..0000000 --- a/src/interfaces/superjson/superjson.schema.json +++ /dev/null @@ -1,755 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-07/schema#", - "additionalProperties": false, - "properties": { - "profiles": { - "additionalProperties": { - "anyOf": [ - { - "additionalProperties": false, - "properties": { - "defaults": { - "additionalProperties": { - "additionalProperties": false, - "properties": { - "input": { - "additionalProperties": { - }, - "type": "object" - }, - "providerFailover": { - "type": "boolean" - } - }, - "type": "object" - }, - "description": "Default per usecase values.", - "type": "object" - }, - "priority": { - "items": { - "type": "string" - }, - "type": "array" - }, - "providers": { - "additionalProperties": { - "anyOf": [ - { - "additionalProperties": false, - "properties": { - "defaults": { - "additionalProperties": { - "additionalProperties": false, - "properties": { - "input": { - "additionalProperties": { - }, - "type": "object" - }, - "retryPolicy": { - "anyOf": [ - { - "additionalProperties": false, - "properties": { - "kind": { - "enum": [ - "none" - ], - "type": "string" - } - }, - "required": [ - "kind" - ], - "type": "object" - }, - { - "additionalProperties": false, - "properties": { - "kind": { - "enum": [ - "simple" - ], - "type": "string" - }, - "maxContiguousRetries": { - "minimum": 0, - "type": "integer" - }, - "requestTimeout": { - "minimum": 0, - "type": "integer" - } - }, - "required": [ - "kind" - ], - "type": "object" - }, - { - "additionalProperties": false, - "properties": { - "backoff": { - "anyOf": [ - { - "additionalProperties": false, - "properties": { - "factor": { - "minimum": 0, - "type": "integer" - }, - "kind": { - "enum": [ - "exponential" - ], - "type": "string" - }, - "start": { - "minimum": 0, - "type": "integer" - } - }, - "required": [ - "kind" - ], - "type": "object" - }, - { - "enum": [ - "exponential" - ], - "type": "string" - } - ] - }, - "kind": { - "enum": [ - "circuit-breaker" - ], - "type": "string" - }, - "maxContiguousRetries": { - "minimum": 0, - "type": "integer" - }, - "openTime": { - "minimum": 0, - "type": "integer" - }, - "requestTimeout": { - "minimum": 0, - "type": "integer" - } - }, - "required": [ - "kind" - ], - "type": "object" - }, - { - "enum": [ - "circuit-breaker", - "none", - "simple" - ], - "type": "string" - } - ], - "description": "Retry policy configuration." - } - }, - "type": "object" - }, - "description": "Default per provider usecase values.", - "type": "object" - }, - "file": { - "type": "string" - } - }, - "required": [ - "file" - ], - "type": "object" - }, - { - "additionalProperties": false, - "properties": { - "defaults": { - "additionalProperties": { - "additionalProperties": false, - "properties": { - "input": { - "additionalProperties": { - }, - "type": "object" - }, - "retryPolicy": { - "anyOf": [ - { - "additionalProperties": false, - "properties": { - "kind": { - "enum": [ - "none" - ], - "type": "string" - } - }, - "required": [ - "kind" - ], - "type": "object" - }, - { - "additionalProperties": false, - "properties": { - "kind": { - "enum": [ - "simple" - ], - "type": "string" - }, - "maxContiguousRetries": { - "minimum": 0, - "type": "integer" - }, - "requestTimeout": { - "minimum": 0, - "type": "integer" - } - }, - "required": [ - "kind" - ], - "type": "object" - }, - { - "additionalProperties": false, - "properties": { - "backoff": { - "anyOf": [ - { - "additionalProperties": false, - "properties": { - "factor": { - "minimum": 0, - "type": "integer" - }, - "kind": { - "enum": [ - "exponential" - ], - "type": "string" - }, - "start": { - "minimum": 0, - "type": "integer" - } - }, - "required": [ - "kind" - ], - "type": "object" - }, - { - "enum": [ - "exponential" - ], - "type": "string" - } - ] - }, - "kind": { - "enum": [ - "circuit-breaker" - ], - "type": "string" - }, - "maxContiguousRetries": { - "minimum": 0, - "type": "integer" - }, - "openTime": { - "minimum": 0, - "type": "integer" - }, - "requestTimeout": { - "minimum": 0, - "type": "integer" - } - }, - "required": [ - "kind" - ], - "type": "object" - }, - { - "enum": [ - "circuit-breaker", - "none", - "simple" - ], - "type": "string" - } - ], - "description": "Retry policy configuration." - } - }, - "type": "object" - }, - "description": "Default per provider usecase values.", - "type": "object" - }, - "mapRevision": { - "type": "string" - }, - "mapVariant": { - "type": "string" - } - }, - "type": "object" - }, - { - "type": "string" - } - ], - "description": "Profile provider entry containing either `profileProviderSettings` or shorthands." - }, - "type": "object" - }, - "version": { - "pattern": "^(0|[1-9]\\d*)\\.(0|[1-9]\\d*)\\.(0|[1-9]\\d*)(?:-((?:0|[1-9]\\d*|\\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\\.(?:0|[1-9]\\d*|\\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\\+([0-9a-zA-Z-]+(?:\\.[0-9a-zA-Z-]+)*))?$", - "type": "string" - } - }, - "required": [ - "version" - ], - "type": "object" - }, - { - "additionalProperties": false, - "properties": { - "defaults": { - "additionalProperties": { - "additionalProperties": false, - "properties": { - "input": { - "additionalProperties": { - }, - "type": "object" - }, - "providerFailover": { - "type": "boolean" - } - }, - "type": "object" - }, - "description": "Default per usecase values.", - "type": "object" - }, - "file": { - "type": "string" - }, - "priority": { - "items": { - "type": "string" - }, - "type": "array" - }, - "providers": { - "additionalProperties": { - "anyOf": [ - { - "additionalProperties": false, - "properties": { - "defaults": { - "additionalProperties": { - "additionalProperties": false, - "properties": { - "input": { - "additionalProperties": { - }, - "type": "object" - }, - "retryPolicy": { - "anyOf": [ - { - "additionalProperties": false, - "properties": { - "kind": { - "enum": [ - "none" - ], - "type": "string" - } - }, - "required": [ - "kind" - ], - "type": "object" - }, - { - "additionalProperties": false, - "properties": { - "kind": { - "enum": [ - "simple" - ], - "type": "string" - }, - "maxContiguousRetries": { - "minimum": 0, - "type": "integer" - }, - "requestTimeout": { - "minimum": 0, - "type": "integer" - } - }, - "required": [ - "kind" - ], - "type": "object" - }, - { - "additionalProperties": false, - "properties": { - "backoff": { - "anyOf": [ - { - "additionalProperties": false, - "properties": { - "factor": { - "minimum": 0, - "type": "integer" - }, - "kind": { - "enum": [ - "exponential" - ], - "type": "string" - }, - "start": { - "minimum": 0, - "type": "integer" - } - }, - "required": [ - "kind" - ], - "type": "object" - }, - { - "enum": [ - "exponential" - ], - "type": "string" - } - ] - }, - "kind": { - "enum": [ - "circuit-breaker" - ], - "type": "string" - }, - "maxContiguousRetries": { - "minimum": 0, - "type": "integer" - }, - "openTime": { - "minimum": 0, - "type": "integer" - }, - "requestTimeout": { - "minimum": 0, - "type": "integer" - } - }, - "required": [ - "kind" - ], - "type": "object" - }, - { - "enum": [ - "circuit-breaker", - "none", - "simple" - ], - "type": "string" - } - ], - "description": "Retry policy configuration." - } - }, - "type": "object" - }, - "description": "Default per provider usecase values.", - "type": "object" - }, - "file": { - "type": "string" - } - }, - "required": [ - "file" - ], - "type": "object" - }, - { - "additionalProperties": false, - "properties": { - "defaults": { - "additionalProperties": { - "additionalProperties": false, - "properties": { - "input": { - "additionalProperties": { - }, - "type": "object" - }, - "retryPolicy": { - "anyOf": [ - { - "additionalProperties": false, - "properties": { - "kind": { - "enum": [ - "none" - ], - "type": "string" - } - }, - "required": [ - "kind" - ], - "type": "object" - }, - { - "additionalProperties": false, - "properties": { - "kind": { - "enum": [ - "simple" - ], - "type": "string" - }, - "maxContiguousRetries": { - "minimum": 0, - "type": "integer" - }, - "requestTimeout": { - "minimum": 0, - "type": "integer" - } - }, - "required": [ - "kind" - ], - "type": "object" - }, - { - "additionalProperties": false, - "properties": { - "backoff": { - "anyOf": [ - { - "additionalProperties": false, - "properties": { - "factor": { - "minimum": 0, - "type": "integer" - }, - "kind": { - "enum": [ - "exponential" - ], - "type": "string" - }, - "start": { - "minimum": 0, - "type": "integer" - } - }, - "required": [ - "kind" - ], - "type": "object" - }, - { - "enum": [ - "exponential" - ], - "type": "string" - } - ] - }, - "kind": { - "enum": [ - "circuit-breaker" - ], - "type": "string" - }, - "maxContiguousRetries": { - "minimum": 0, - "type": "integer" - }, - "openTime": { - "minimum": 0, - "type": "integer" - }, - "requestTimeout": { - "minimum": 0, - "type": "integer" - } - }, - "required": [ - "kind" - ], - "type": "object" - }, - { - "enum": [ - "circuit-breaker", - "none", - "simple" - ], - "type": "string" - } - ], - "description": "Retry policy configuration." - } - }, - "type": "object" - }, - "description": "Default per provider usecase values.", - "type": "object" - }, - "mapRevision": { - "type": "string" - }, - "mapVariant": { - "type": "string" - } - }, - "type": "object" - }, - { - "type": "string" - } - ], - "description": "Profile provider entry containing either `profileProviderSettings` or shorthands." - }, - "type": "object" - } - }, - "required": [ - "file" - ], - "type": "object" - }, - { - "type": "string" - } - ], - "description": "Profile entry containing either `profileSettings` or shorthands." - }, - "type": "object" - }, - "providers": { - "additionalProperties": { - "anyOf": [ - { - "additionalProperties": false, - "description": "Expanded provider settings for one provider name.", - "properties": { - "file": { - "type": "string" - }, - "parameters": { - "additionalProperties": { - "type": "string" - }, - "type": "object" - }, - "security": { - "items": { - "anyOf": [ - { - "$id": "ApiKeySecurityValues", - "additionalProperties": false, - "properties": { - "apikey": { - "type": "string" - }, - "id": { - "type": "string" - } - }, - "required": [ - "apikey", - "id" - ], - "type": "object" - }, - { - "$id": "BasicAuthSecurityValues", - "additionalProperties": false, - "properties": { - "id": { - "type": "string" - }, - "password": { - "type": "string" - }, - "username": { - "type": "string" - } - }, - "required": [ - "id", - "password", - "username" - ], - "type": "object" - }, - { - "$id": "BearerTokenSecurityValues", - "additionalProperties": false, - "properties": { - "id": { - "type": "string" - }, - "token": { - "type": "string" - } - }, - "required": [ - "id", - "token" - ], - "type": "object" - } - ], - "description": "Authorization variables." - }, - "type": "array" - } - }, - "type": "object" - }, - { - "type": "string" - } - ] - }, - "type": "object" - } - }, - "type": "object" -} - diff --git a/src/interfaces/superjson/superjson.ts b/src/interfaces/superjson/superjson.ts deleted file mode 100644 index a669050..0000000 --- a/src/interfaces/superjson/superjson.ts +++ /dev/null @@ -1,318 +0,0 @@ -// 'Official' regex https://semver.org/#is-there-a-suggested-regular-expression-regex-to-check-a-semver-string -export const SEMVER_REGEX = - /^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$/; -export const SEMVER_REGEX_SOURCE = SEMVER_REGEX.source; - -// NOT comprehensive at all -export const FILE_URI_PROTOCOL = 'file://'; -export const FILE_URI_REGEX = /^file:\/\//; -export const FILE_URI_REGEX_SOURCE = FILE_URI_REGEX.source; - -/** - * @pattern require('.').SEMVER_REGEX_SOURCE - **/ -export type SemanticVersion = string; - -/** - * @pattern require('.').FILE_URI_REGEX_SOURCE - **/ -export type UriPath = string; - -// Retry policy -export enum OnFail { - NONE = 'none', - SIMPLE = 'simple', - CIRCUIT_BREAKER = 'circuit-breaker', -} - -export enum BackoffKind { - EXPONENTIAL = 'exponential', -} - -export type BackoffPolicy = - | BackoffKind.EXPONENTIAL - | { - kind: BackoffKind.EXPONENTIAL; - /** - * @TJS-minimum 0 - * @TJS-type integer - **/ - start?: number; - /** - * @TJS-minimum 0 - * @TJS-type integer - **/ - factor?: number; - }; - -/** - * Retry policy configuration. - */ -export type RetryPolicy = - | OnFail.NONE - | { - kind: OnFail.NONE; - } - | OnFail.SIMPLE - | { - kind: OnFail.SIMPLE; - /** - * @TJS-minimum 0 - * @TJS-type integer - **/ - maxContiguousRetries?: number; - /** - * @TJS-minimum 0 - * @TJS-type integer - **/ - requestTimeout?: number; - } - | OnFail.CIRCUIT_BREAKER - | { - kind: OnFail.CIRCUIT_BREAKER; - /** - * @TJS-minimum 0 - * @TJS-type integer - **/ - maxContiguousRetries?: number; - /** - * @TJS-minimum 0 - * @TJS-type integer - **/ - openTime?: number; - /** - * @TJS-minimum 0 - * @TJS-type integer - **/ - requestTimeout?: number; - backoff?: BackoffPolicy; - }; - -export type NormalizedBackoffPolicy = { - kind: BackoffKind.EXPONENTIAL; - /** - * @TJS-minimum 0 - * @TJS-type integer - **/ - start?: number; - /** - * @TJS-minimum 0 - * @TJS-type integer - **/ - factor?: number; -}; - -export type NormalizedRetryPolicy = - | { - kind: OnFail.NONE; - } - | { - kind: OnFail.SIMPLE; - /** - * @TJS-minimum 0 - * @TJS-type integer - **/ - maxContiguousRetries?: number; - /** - * @TJS-minimum 0 - * @TJS-type integer - **/ - requestTimeout?: number; - } - | { - kind: OnFail.CIRCUIT_BREAKER; - /** - * @TJS-minimum 0 - * @TJS-type integer - **/ - maxContiguousRetries?: number; - /** - * @TJS-minimum 0 - * @TJS-type integer - **/ - openTime?: number; - /** - * @TJS-minimum 0 - * @TJS-type integer - **/ - requestTimeout?: number; - backoff: NormalizedBackoffPolicy; - }; - -/** - * Default per usecase values. - */ -export type UsecaseDefaults = { - [usecase: string]: { - input?: { [key: string]: unknown }; - providerFailover?: boolean; - }; -}; - -export type NormalizedUsecaseDefaults = { - [usecase: string]: { - input: { [key: string]: unknown }; - providerFailover: boolean; - }; -}; - -/** - * Default per provider usecase values. - */ -export type ProfileProviderDefaults = { - [provider: string]: { - input?: { [key: string]: unknown }; - retryPolicy?: RetryPolicy; - }; -}; - -export type NormalizedProfileProviderDefaults = { - [provider: string]: { - input: { [key: string]: unknown }; - retryPolicy: NormalizedRetryPolicy; - }; -}; - -/** - * Provider settings for specific profile. - */ -export type ProfileProviderSettings = { - defaults?: ProfileProviderDefaults; -} & ( - | { - file: string; - } - | { - mapVariant?: string; - mapRevision?: string; - } - ); - -export type NormalizedProfileProviderSettings = - | { - file: string; - defaults: NormalizedProfileProviderDefaults; - } - | { - mapVariant?: string; - mapRevision?: string; - defaults: NormalizedProfileProviderDefaults; - }; - -/** - * Profile provider entry containing either `profileProviderSettings` or shorthands. - */ -export type ProfileProviderEntry = UriPath | ProfileProviderSettings; - -/** - * Expanded profile settings for one profile id. - */ -export type ProfileSettings = { - priority?: string[]; - defaults?: UsecaseDefaults; - providers?: { [provider: string]: UriPath | ProfileProviderEntry }; -} & ( - | { - version: SemanticVersion; - } - | { - file: string; - } - ); - -export type NormalizedProfileSettings = { - priority: string[]; - defaults: NormalizedUsecaseDefaults; - providers: { [provider: string]: NormalizedProfileProviderSettings }; -} & ( - | { - version: SemanticVersion; - } - | { - file: string; - priority: string[]; - defaults: NormalizedUsecaseDefaults; - providers: { [provider: string]: NormalizedProfileProviderSettings }; - } - ); - -/** - * Profile entry containing either `profileSettings` or shorthands. - */ -export type ProfileEntry = SemanticVersion | UriPath | ProfileSettings; - -export type IdBase = { - id: string; -}; - -/** - * @$id ApiKeySecurityValues - **/ -export type ApiKeySecurityValues = IdBase & { - apikey: string; -}; - -/** - * @$id BasicAuthSecurityValues - **/ -export type BasicAuthSecurityValues = IdBase & { - username: string; - password: string; -}; - -/** - * @$id BearerTokenSecurityValues - **/ -export type BearerTokenSecurityValues = IdBase & { - token: string; -}; - -/** - * Authorization variables. - */ -export type SecurityValues = - | ApiKeySecurityValues - | BasicAuthSecurityValues - | BearerTokenSecurityValues; - -/** - * Expanded provider settings for one provider name. - */ -export type ProviderSettings = { - file?: string; - security?: SecurityValues[]; - parameters?: { [key: string]: string }; -}; - -export type NormalizedProviderSettings = { - file?: string; - security: SecurityValues[]; - parameters: { [key: string]: string }; -}; - -export type ProviderEntry = UriPath | ProviderSettings; - -export type SuperJsonDocument = { - profiles?: { [profile: string]: ProfileEntry }; - providers?: { [provider: string]: ProviderEntry }; -}; - -export type NormalizedSuperJsonDocument = { - profiles: { [profile: string]: NormalizedProfileSettings }; - providers: { [provider: string]: NormalizedProviderSettings }; -}; - -export type AnonymizedSuperJsonDocument = { - profiles: Record< - string, - { - version: SemanticVersion | 'file'; - providers: { - provider: string; - priority?: number; - version: SemanticVersion | 'file'; - }[]; - } - >; - providers: string[]; -}; diff --git a/src/interfaces/superjson/superjson.utils.test.ts b/src/interfaces/superjson/superjson.utils.test.ts deleted file mode 100644 index f28aae6..0000000 --- a/src/interfaces/superjson/superjson.utils.test.ts +++ /dev/null @@ -1,155 +0,0 @@ -import { - assertSuperJsonDocument, - isApiKeySecurityValues, - isBasicAuthSecurityValues, - isBearerTokenSecurityValues, - isFileURIString, - isVersionString, -} from './superjson.utils'; - -describe('super.json utils', () => { - describe('assertSuperJsonDocument', () => { - it('should not throw on valid SuperJsonDocument', () => { - const superjson = { - profiles: { - 'send-message': { - version: '1.0.0', - providers: { - acme: { - defaults: { - SomeUsecase: { - input: { - some: 'input', - }, - }, - }, - mapVariant: 'my-bugfix', - mapRevision: '1113', - }, - }, - }, - }, - providers: { - acme: { - security: [ - { - id: 'myApiKey', - apikey: 'SECRET', - }, - ], - }, - }, - }; - expect(() => assertSuperJsonDocument(superjson)).not.toThrow(); - }); - - it('should throw on invalid SuperJsonDocument', () => { - const superjson = { - profiles: { - 'send-message': { - version: '1.0.0', - providers: { - acme: { - defaults: { - bla: { - inputs: { - bla: 'bla', - }, - }, - }, - mapVariant: 'my-bugfix', - mapRevision: '1113', - }, - }, - }, - }, - providers: { - acme: { - security: [ - { - id: 'myApiKey', - apikey: 'SECRET', - }, - ], - }, - }, - in: 'valid', - }; - expect(() => assertSuperJsonDocument(superjson)).toThrow( - '$: must not have additional property "in"' - ); - }); - }); - - describe('isVersionString', () => { - it.each(['1.0.0', '0.0.1-beta.0', '1.2.3-alpha', '1.0.0-alpha+1'])( - 'should return true on valid semver string: %s', - semver => { - expect(isVersionString(semver)).toBe(true); - } - ); - - it.each(['0', 'seven', '1.1', '0.0.0.0', 'v1.1.0'])( - 'should return false on invalid semver string: %s', - notSemver => { - expect(isVersionString(notSemver)).toBe(false); - } - ); - }); - - describe('isFileURIString', () => { - it('should return true on valid file URI string', () => { - expect(isFileURIString('file://../some/path.json')).toBe(true); - }); - - it('should return false on invalid file URI string', () => { - expect(isFileURIString('file:/some/path')).toBe(false); - expect( - isFileURIString('literally any string not starting with file://') - ).toBe(false); - }); - }); - - describe('isApiKeySecurityValues', () => { - it('should return true on valid values', () => { - expect( - isApiKeySecurityValues({ id: 'some-id', apikey: 'some-key' }) - ).toBe(true); - }); - - it('should return false on invalid values', () => { - expect(isApiKeySecurityValues({ id: 7 })).toBe(false); - }); - }); - - describe('isBasicAuthSecurityValues', () => { - it('should return true on valid values', () => { - expect( - isBasicAuthSecurityValues({ - id: 'some-id', - username: 'some-user-name', - password: 'some-password', - }) - ).toBe(true); - }); - - it('should return false on invalid values', () => { - expect(isBasicAuthSecurityValues({ id: 7 })).toBe(false); - }); - }); - - describe('isBearerTokenSecurityValues', () => { - it('should return true on valid values', () => { - expect( - isBearerTokenSecurityValues({ - id: 'some-id', - token: 'some-token', - }) - ).toBe(true); - }); - - it('should return false on invalid values', () => { - expect(isBearerTokenSecurityValues({ id: 7 })).toBe(false); - }); - }); -}); diff --git a/src/interfaces/superjson/superjson.utils.ts b/src/interfaces/superjson/superjson.utils.ts deleted file mode 100644 index 99e71b7..0000000 --- a/src/interfaces/superjson/superjson.utils.ts +++ /dev/null @@ -1,41 +0,0 @@ -import { prepareAssert, preparePrepareIs } from '../../validation'; -import { Guard } from '..'; -import { Assert } from '../ast'; -import { - ApiKeySecurityValues, - BasicAuthSecurityValues, - BearerTokenSecurityValues, - FILE_URI_REGEX, - SEMVER_REGEX, - SuperJsonDocument, -} from './superjson'; -import * as schema from './superjson.schema.json'; - -const prepareIs = preparePrepareIs(schema); -const assertSuperJson: Assert = prepareAssert( - schema, - 'super-json' -); - -export function isVersionString(input: string): boolean { - return SEMVER_REGEX.test(input); -} - -export function isFileURIString(input: string): boolean { - return FILE_URI_REGEX.test(input); -} - -export const assertSuperJsonDocument: (input: unknown) => SuperJsonDocument = ( - input: unknown -) => { - assertSuperJson(input); - - return input; -}; - -export const isApiKeySecurityValues: Guard = - prepareIs('ApiKeySecurityValues'); -export const isBasicAuthSecurityValues: Guard = - prepareIs('BasicAuthSecurityValues'); -export const isBearerTokenSecurityValues: Guard = - prepareIs('BearerTokenSecurityValues'); From d9743f51ba614f6e122d178df8b21666ef4e70a7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20Musil?= Date: Wed, 19 Jul 2023 11:12:36 +0200 Subject: [PATCH 4/4] chore: remove map AST --- .husky/pre-commit | 8 - CHANGELOG.md | 1 + package.json | 3 +- src/interfaces/ast/index.ts | 2 - src/interfaces/ast/map-ast.schema.json | 1943 ---------------------- src/interfaces/ast/map-ast.ts | 312 ---- src/interfaces/ast/map-ast.utils.test.ts | 623 ------- src/interfaces/ast/map-ast.utils.ts | 111 -- 8 files changed, 2 insertions(+), 3001 deletions(-) delete mode 100644 src/interfaces/ast/map-ast.schema.json delete mode 100644 src/interfaces/ast/map-ast.ts delete mode 100644 src/interfaces/ast/map-ast.utils.test.ts delete mode 100644 src/interfaces/ast/map-ast.utils.ts diff --git a/.husky/pre-commit b/.husky/pre-commit index 87b189d..dcde95a 100755 --- a/.husky/pre-commit +++ b/.husky/pre-commit @@ -4,21 +4,13 @@ GENERATED=0 #Hack: stat is different for OSX if [[ "$OSTYPE" == "darwin"* ]]; then - MAP_AST_CHANGED=$((`stat -f "%c" src/interfaces/ast/map-ast.ts` - `stat -f "%c" src/interfaces/ast/map-ast.schema.json`)) PROFILE_AST_CHANGED=$((`stat -f "%c" src/interfaces/ast/profile-ast.ts` - `stat -f "%c" src/interfaces/ast/profile-ast.schema.json`)) PROVIDERJSON_AST_CHANGED=$((`stat -f "%c" src/interfaces/providerjson/providerjson.ts` - `stat -f "%c" src/interfaces/providerjson/providerjson.schema.json`)) else - MAP_AST_CHANGED=$((`stat --format="%Y" src/interfaces/ast/map-ast.ts` - `stat --format="%Y" src/interfaces/ast/map-ast.schema.json`)) PROFILE_AST_CHANGED=$((`stat --format="%Y" src/interfaces/ast/profile-ast.ts` - `stat --format="%Y" src/interfaces/ast/profile-ast.schema.json`)) PROVIDERJSON_AST_CHANGED=$((`stat --format="%Y" src/interfaces/providerjson/providerjson.ts` - `stat --format="%Y" src/interfaces/providerjson/providerjson.schema.json`)) fi - -if [ $MAP_AST_CHANGED -gt 0 ]; then - yarn run --silent generate_map_schema - GENERATED=1 -fi - if [ $PROFILE_AST_CHANGED -gt 0 ]; then yarn run --silent generate_profile_schema GENERATED=1 diff --git a/CHANGELOG.md b/CHANGELOG.md index 495ce57..48874f0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## Removed - **BREAKING CHANGE**: Removed `DigestSecurityScheme` - **BREAKING CHANGE**: Removed superjson schema +- **BREAKING CHANGE**: Removed map AST schema ### Fixed - Profile AST JSON Schema regenerated diff --git a/package.json b/package.json index 28cb3b1..8734271 100644 --- a/package.json +++ b/package.json @@ -23,9 +23,8 @@ "format:fix": "prettier --write src/", "generate_schema": "typescript-json-schema --noExtraProps --required --strictNullChecks --tsNodeRegister --topRef", "generate_profile_schema": "yarn run generate_schema src/interfaces/ast/profile-ast.ts ProfileDocumentNode -o src/interfaces/ast/profile-ast.schema.json", - "generate_map_schema": "yarn run generate_schema src/interfaces/ast/map-ast.ts MapDocumentNode -o src/interfaces/ast/map-ast.schema.json", "generate_providerjson_schema": "yarn run generate_schema src/interfaces/providerjson/providerjson.ts ProviderJson -o src/interfaces/providerjson/providerjson.schema.json", - "generate_schemas": "yarn run generate_profile_schema && yarn run generate_map_schema && yarn run generate_providerjson_schema", + "generate_schemas": "yarn run generate_profile_schema && yarn run generate_providerjson_schema", "prepare": "husky install" }, "dependencies": { diff --git a/src/interfaces/ast/index.ts b/src/interfaces/ast/index.ts index d1a5321..54ace71 100644 --- a/src/interfaces/ast/index.ts +++ b/src/interfaces/ast/index.ts @@ -1,6 +1,4 @@ export * from './document'; -export * from './map-ast'; -export * from './map-ast.utils'; export * from './profile-ast'; export * from './profile-ast.utils'; export * from './split'; diff --git a/src/interfaces/ast/map-ast.schema.json b/src/interfaces/ast/map-ast.schema.json deleted file mode 100644 index d15a72e..0000000 --- a/src/interfaces/ast/map-ast.schema.json +++ /dev/null @@ -1,1943 +0,0 @@ -{ - "$ref": "#/definitions/MapDocumentNode", - "$schema": "http://json-schema.org/draft-07/schema#", - "definitions": { - "AssignmentNode": { - "additionalProperties": false, - "description": "Assignment node: `key.\"b.az\".bar = `", - "properties": { - "key": { - "items": { - "type": "string" - }, - "type": "array" - }, - "kind": { - "enum": [ - "Assignment" - ], - "type": "string" - }, - "location": { - "additionalProperties": false, - "description": "Location span within the source.", - "properties": { - "end": { - "additionalProperties": false, - "description": "Location within the source.\n\nContains both the human-readable line:column information and character index.", - "properties": { - "charIndex": { - "description": "Character index within the source code - starts at 0", - "type": "number" - }, - "column": { - "description": "Column number - starts at 1", - "type": "number" - }, - "line": { - "description": "Line number - starts at 1", - "type": "number" - } - }, - "required": [ - "charIndex", - "column", - "line" - ], - "type": "object" - }, - "start": { - "additionalProperties": false, - "description": "Location within the source.\n\nContains both the human-readable line:column information and character index.", - "properties": { - "charIndex": { - "description": "Character index within the source code - starts at 0", - "type": "number" - }, - "column": { - "description": "Column number - starts at 1", - "type": "number" - }, - "line": { - "description": "Line number - starts at 1", - "type": "number" - } - }, - "required": [ - "charIndex", - "column", - "line" - ], - "type": "object" - } - }, - "required": [ - "end", - "start" - ], - "type": "object" - }, - "value": { - "$ref": "#/definitions/LiteralNode" - } - }, - "required": [ - "key", - "kind", - "value" - ], - "type": "object" - }, - "AstMetadata": { - "$id": "AstMetadata", - "additionalProperties": false, - "description": "Information about AST and Parser used to compile provided AST", - "properties": { - "astVersion": { - "additionalProperties": false, - "properties": { - "label": { - "type": "string" - }, - "major": { - "type": "number" - }, - "minor": { - "type": "number" - }, - "patch": { - "type": "number" - } - }, - "required": [ - "major", - "minor", - "patch" - ], - "type": "object" - }, - "parserVersion": { - "additionalProperties": false, - "properties": { - "label": { - "type": "string" - }, - "major": { - "type": "number" - }, - "minor": { - "type": "number" - }, - "patch": { - "type": "number" - } - }, - "required": [ - "major", - "minor", - "patch" - ], - "type": "object" - }, - "sourceChecksum": { - "type": "string" - } - }, - "required": [ - "astVersion", - "parserVersion", - "sourceChecksum" - ], - "type": "object" - }, - "CallStatementNode": { - "additionalProperties": false, - "description": "Call statement, possibly with a condition and iteration: `call (<...args>) { <...statements> }`", - "properties": { - "arguments": { - "items": { - "$ref": "#/definitions/AssignmentNode" - }, - "type": "array" - }, - "condition": { - "$ref": "#/definitions/ConditionAtomNode", - "description": "Statement condition atom: `if ()`" - }, - "iteration": { - "$ref": "#/definitions/IterationAtomNode", - "description": "Iteration atom: `foreach ( of )`" - }, - "kind": { - "enum": [ - "CallStatement" - ], - "type": "string" - }, - "location": { - "additionalProperties": false, - "description": "Location span within the source.", - "properties": { - "end": { - "additionalProperties": false, - "description": "Location within the source.\n\nContains both the human-readable line:column information and character index.", - "properties": { - "charIndex": { - "description": "Character index within the source code - starts at 0", - "type": "number" - }, - "column": { - "description": "Column number - starts at 1", - "type": "number" - }, - "line": { - "description": "Line number - starts at 1", - "type": "number" - } - }, - "required": [ - "charIndex", - "column", - "line" - ], - "type": "object" - }, - "start": { - "additionalProperties": false, - "description": "Location within the source.\n\nContains both the human-readable line:column information and character index.", - "properties": { - "charIndex": { - "description": "Character index within the source code - starts at 0", - "type": "number" - }, - "column": { - "description": "Column number - starts at 1", - "type": "number" - }, - "line": { - "description": "Line number - starts at 1", - "type": "number" - } - }, - "required": [ - "charIndex", - "column", - "line" - ], - "type": "object" - } - }, - "required": [ - "end", - "start" - ], - "type": "object" - }, - "operationName": { - "type": "string" - }, - "statements": { - "items": { - "anyOf": [ - { - "$ref": "#/definitions/OutcomeStatementNode" - }, - { - "$ref": "#/definitions/SetStatementNode" - } - ] - }, - "type": "array" - } - }, - "required": [ - "arguments", - "kind", - "operationName", - "statements" - ], - "type": "object" - }, - "ConditionAtomNode": { - "additionalProperties": false, - "description": "Statement condition atom: `if ()`", - "properties": { - "expression": { - "$ref": "#/definitions/JessieExpressionNode" - }, - "kind": { - "enum": [ - "ConditionAtom" - ], - "type": "string" - }, - "location": { - "additionalProperties": false, - "description": "Location span within the source.", - "properties": { - "end": { - "additionalProperties": false, - "description": "Location within the source.\n\nContains both the human-readable line:column information and character index.", - "properties": { - "charIndex": { - "description": "Character index within the source code - starts at 0", - "type": "number" - }, - "column": { - "description": "Column number - starts at 1", - "type": "number" - }, - "line": { - "description": "Line number - starts at 1", - "type": "number" - } - }, - "required": [ - "charIndex", - "column", - "line" - ], - "type": "object" - }, - "start": { - "additionalProperties": false, - "description": "Location within the source.\n\nContains both the human-readable line:column information and character index.", - "properties": { - "charIndex": { - "description": "Character index within the source code - starts at 0", - "type": "number" - }, - "column": { - "description": "Column number - starts at 1", - "type": "number" - }, - "line": { - "description": "Line number - starts at 1", - "type": "number" - } - }, - "required": [ - "charIndex", - "column", - "line" - ], - "type": "object" - } - }, - "required": [ - "end", - "start" - ], - "type": "object" - } - }, - "required": [ - "expression", - "kind" - ], - "type": "object" - }, - "HttpCallStatementNode": { - "additionalProperties": false, - "description": "Http call statement: `http { <...responseHandlers> }`", - "properties": { - "kind": { - "enum": [ - "HttpCallStatement" - ], - "type": "string" - }, - "location": { - "additionalProperties": false, - "description": "Location span within the source.", - "properties": { - "end": { - "additionalProperties": false, - "description": "Location within the source.\n\nContains both the human-readable line:column information and character index.", - "properties": { - "charIndex": { - "description": "Character index within the source code - starts at 0", - "type": "number" - }, - "column": { - "description": "Column number - starts at 1", - "type": "number" - }, - "line": { - "description": "Line number - starts at 1", - "type": "number" - } - }, - "required": [ - "charIndex", - "column", - "line" - ], - "type": "object" - }, - "start": { - "additionalProperties": false, - "description": "Location within the source.\n\nContains both the human-readable line:column information and character index.", - "properties": { - "charIndex": { - "description": "Character index within the source code - starts at 0", - "type": "number" - }, - "column": { - "description": "Column number - starts at 1", - "type": "number" - }, - "line": { - "description": "Line number - starts at 1", - "type": "number" - } - }, - "required": [ - "charIndex", - "column", - "line" - ], - "type": "object" - } - }, - "required": [ - "end", - "start" - ], - "type": "object" - }, - "method": { - "type": "string" - }, - "request": { - "$ref": "#/definitions/HttpRequestNode", - "description": "Request definition for http:\n`request { }`" - }, - "responseHandlers": { - "items": { - "$ref": "#/definitions/HttpResponseHandlerNode" - }, - "type": "array" - }, - "serviceId": { - "type": "string" - }, - "url": { - "type": "string" - } - }, - "required": [ - "kind", - "method", - "responseHandlers", - "url" - ], - "type": "object" - }, - "HttpRequestNode": { - "additionalProperties": false, - "description": "Request definition for http:\n`request { }`", - "properties": { - "body": { - "anyOf": [ - { - "$ref": "#/definitions/PrimitiveLiteralNode" - }, - { - "$ref": "#/definitions/ObjectLiteralNode" - }, - { - "$ref": "#/definitions/JessieExpressionNode" - }, - { - "$ref": "#/definitions/InlineCallNode" - } - ] - }, - "contentLanguage": { - "type": "string" - }, - "contentType": { - "type": "string" - }, - "headers": { - "$ref": "#/definitions/ObjectLiteralNode", - "description": "Object literal node: `{ <...assignments> }`" - }, - "kind": { - "enum": [ - "HttpRequest" - ], - "type": "string" - }, - "location": { - "additionalProperties": false, - "description": "Location span within the source.", - "properties": { - "end": { - "additionalProperties": false, - "description": "Location within the source.\n\nContains both the human-readable line:column information and character index.", - "properties": { - "charIndex": { - "description": "Character index within the source code - starts at 0", - "type": "number" - }, - "column": { - "description": "Column number - starts at 1", - "type": "number" - }, - "line": { - "description": "Line number - starts at 1", - "type": "number" - } - }, - "required": [ - "charIndex", - "column", - "line" - ], - "type": "object" - }, - "start": { - "additionalProperties": false, - "description": "Location within the source.\n\nContains both the human-readable line:column information and character index.", - "properties": { - "charIndex": { - "description": "Character index within the source code - starts at 0", - "type": "number" - }, - "column": { - "description": "Column number - starts at 1", - "type": "number" - }, - "line": { - "description": "Line number - starts at 1", - "type": "number" - } - }, - "required": [ - "charIndex", - "column", - "line" - ], - "type": "object" - } - }, - "required": [ - "end", - "start" - ], - "type": "object" - }, - "query": { - "$ref": "#/definitions/ObjectLiteralNode", - "description": "Object literal node: `{ <...assignments> }`" - }, - "security": { - "items": { - "additionalProperties": false, - "description": "Http security requirement: `security `", - "properties": { - "id": { - "type": "string" - }, - "scheme": { - "description": "Optional scheme information.", - "enum": [ - "apikey", - "basic", - "bearer" - ], - "type": "string" - } - }, - "required": [ - "id" - ], - "type": "object" - }, - "type": "array" - } - }, - "required": [ - "kind", - "security" - ], - "type": "object" - }, - "HttpResponseHandlerNode": { - "additionalProperties": false, - "description": "Response handler for http: `response { <...statements> }`", - "properties": { - "contentLanguage": { - "type": "string" - }, - "contentType": { - "type": "string" - }, - "kind": { - "enum": [ - "HttpResponseHandler" - ], - "type": "string" - }, - "location": { - "additionalProperties": false, - "description": "Location span within the source.", - "properties": { - "end": { - "additionalProperties": false, - "description": "Location within the source.\n\nContains both the human-readable line:column information and character index.", - "properties": { - "charIndex": { - "description": "Character index within the source code - starts at 0", - "type": "number" - }, - "column": { - "description": "Column number - starts at 1", - "type": "number" - }, - "line": { - "description": "Line number - starts at 1", - "type": "number" - } - }, - "required": [ - "charIndex", - "column", - "line" - ], - "type": "object" - }, - "start": { - "additionalProperties": false, - "description": "Location within the source.\n\nContains both the human-readable line:column information and character index.", - "properties": { - "charIndex": { - "description": "Character index within the source code - starts at 0", - "type": "number" - }, - "column": { - "description": "Column number - starts at 1", - "type": "number" - }, - "line": { - "description": "Line number - starts at 1", - "type": "number" - } - }, - "required": [ - "charIndex", - "column", - "line" - ], - "type": "object" - } - }, - "required": [ - "end", - "start" - ], - "type": "object" - }, - "statements": { - "items": { - "anyOf": [ - { - "$ref": "#/definitions/OutcomeStatementNode" - }, - { - "$ref": "#/definitions/SetStatementNode" - } - ] - }, - "type": "array" - }, - "statusCode": { - "maximum": 599, - "minimum": 200, - "type": "integer" - } - }, - "required": [ - "kind", - "statements" - ], - "type": "object" - }, - "InlineCallNode": { - "additionalProperties": false, - "description": "Inline call, can appear on rhs in assignment: `call (<...args>) `", - "properties": { - "arguments": { - "items": { - "$ref": "#/definitions/AssignmentNode" - }, - "type": "array" - }, - "condition": { - "$ref": "#/definitions/ConditionAtomNode", - "description": "Statement condition atom: `if ()`" - }, - "iteration": { - "$ref": "#/definitions/IterationAtomNode", - "description": "Iteration atom: `foreach ( of )`" - }, - "kind": { - "enum": [ - "InlineCall" - ], - "type": "string" - }, - "location": { - "additionalProperties": false, - "description": "Location span within the source.", - "properties": { - "end": { - "additionalProperties": false, - "description": "Location within the source.\n\nContains both the human-readable line:column information and character index.", - "properties": { - "charIndex": { - "description": "Character index within the source code - starts at 0", - "type": "number" - }, - "column": { - "description": "Column number - starts at 1", - "type": "number" - }, - "line": { - "description": "Line number - starts at 1", - "type": "number" - } - }, - "required": [ - "charIndex", - "column", - "line" - ], - "type": "object" - }, - "start": { - "additionalProperties": false, - "description": "Location within the source.\n\nContains both the human-readable line:column information and character index.", - "properties": { - "charIndex": { - "description": "Character index within the source code - starts at 0", - "type": "number" - }, - "column": { - "description": "Column number - starts at 1", - "type": "number" - }, - "line": { - "description": "Line number - starts at 1", - "type": "number" - } - }, - "required": [ - "charIndex", - "column", - "line" - ], - "type": "object" - } - }, - "required": [ - "end", - "start" - ], - "type": "object" - }, - "operationName": { - "type": "string" - } - }, - "required": [ - "arguments", - "kind", - "operationName" - ], - "type": "object" - }, - "IterationAtomNode": { - "additionalProperties": false, - "description": "Iteration atom: `foreach ( of )`", - "properties": { - "iterable": { - "$ref": "#/definitions/JessieExpressionNode" - }, - "iterationVariable": { - "type": "string" - }, - "kind": { - "enum": [ - "IterationAtom" - ], - "type": "string" - }, - "location": { - "additionalProperties": false, - "description": "Location span within the source.", - "properties": { - "end": { - "additionalProperties": false, - "description": "Location within the source.\n\nContains both the human-readable line:column information and character index.", - "properties": { - "charIndex": { - "description": "Character index within the source code - starts at 0", - "type": "number" - }, - "column": { - "description": "Column number - starts at 1", - "type": "number" - }, - "line": { - "description": "Line number - starts at 1", - "type": "number" - } - }, - "required": [ - "charIndex", - "column", - "line" - ], - "type": "object" - }, - "start": { - "additionalProperties": false, - "description": "Location within the source.\n\nContains both the human-readable line:column information and character index.", - "properties": { - "charIndex": { - "description": "Character index within the source code - starts at 0", - "type": "number" - }, - "column": { - "description": "Column number - starts at 1", - "type": "number" - }, - "line": { - "description": "Line number - starts at 1", - "type": "number" - } - }, - "required": [ - "charIndex", - "column", - "line" - ], - "type": "object" - } - }, - "required": [ - "end", - "start" - ], - "type": "object" - } - }, - "required": [ - "iterable", - "iterationVariable", - "kind" - ], - "type": "object" - }, - "JessieExpressionNode": { - "additionalProperties": false, - "description": "Jessie expression node: ``", - "properties": { - "expression": { - "type": "string" - }, - "kind": { - "enum": [ - "JessieExpression" - ], - "type": "string" - }, - "location": { - "additionalProperties": false, - "description": "Location span within the source.", - "properties": { - "end": { - "additionalProperties": false, - "description": "Location within the source.\n\nContains both the human-readable line:column information and character index.", - "properties": { - "charIndex": { - "description": "Character index within the source code - starts at 0", - "type": "number" - }, - "column": { - "description": "Column number - starts at 1", - "type": "number" - }, - "line": { - "description": "Line number - starts at 1", - "type": "number" - } - }, - "required": [ - "charIndex", - "column", - "line" - ], - "type": "object" - }, - "start": { - "additionalProperties": false, - "description": "Location within the source.\n\nContains both the human-readable line:column information and character index.", - "properties": { - "charIndex": { - "description": "Character index within the source code - starts at 0", - "type": "number" - }, - "column": { - "description": "Column number - starts at 1", - "type": "number" - }, - "line": { - "description": "Line number - starts at 1", - "type": "number" - } - }, - "required": [ - "charIndex", - "column", - "line" - ], - "type": "object" - } - }, - "required": [ - "end", - "start" - ], - "type": "object" - }, - "source": { - "type": "string" - }, - "sourceMap": { - "type": "string" - } - }, - "required": [ - "expression", - "kind" - ], - "type": "object" - }, - "LiteralNode": { - "anyOf": [ - { - "$ref": "#/definitions/PrimitiveLiteralNode" - }, - { - "$ref": "#/definitions/ObjectLiteralNode" - }, - { - "$ref": "#/definitions/JessieExpressionNode" - }, - { - "$ref": "#/definitions/InlineCallNode" - } - ] - }, - "MapDefinitionNode": { - "additionalProperties": false, - "description": "Map definition: `map { <...statements> }`", - "properties": { - "documentation": { - "additionalProperties": false, - "properties": { - "description": { - "type": "string" - }, - "location": { - "additionalProperties": false, - "description": "Location span within the source.", - "properties": { - "end": { - "additionalProperties": false, - "description": "Location within the source.\n\nContains both the human-readable line:column information and character index.", - "properties": { - "charIndex": { - "description": "Character index within the source code - starts at 0", - "type": "number" - }, - "column": { - "description": "Column number - starts at 1", - "type": "number" - }, - "line": { - "description": "Line number - starts at 1", - "type": "number" - } - }, - "required": [ - "charIndex", - "column", - "line" - ], - "type": "object" - }, - "start": { - "additionalProperties": false, - "description": "Location within the source.\n\nContains both the human-readable line:column information and character index.", - "properties": { - "charIndex": { - "description": "Character index within the source code - starts at 0", - "type": "number" - }, - "column": { - "description": "Column number - starts at 1", - "type": "number" - }, - "line": { - "description": "Line number - starts at 1", - "type": "number" - } - }, - "required": [ - "charIndex", - "column", - "line" - ], - "type": "object" - } - }, - "required": [ - "end", - "start" - ], - "type": "object" - }, - "title": { - "type": "string" - } - }, - "required": [ - "title" - ], - "type": "object" - }, - "kind": { - "enum": [ - "MapDefinition" - ], - "type": "string" - }, - "location": { - "additionalProperties": false, - "description": "Location span within the source.", - "properties": { - "end": { - "additionalProperties": false, - "description": "Location within the source.\n\nContains both the human-readable line:column information and character index.", - "properties": { - "charIndex": { - "description": "Character index within the source code - starts at 0", - "type": "number" - }, - "column": { - "description": "Column number - starts at 1", - "type": "number" - }, - "line": { - "description": "Line number - starts at 1", - "type": "number" - } - }, - "required": [ - "charIndex", - "column", - "line" - ], - "type": "object" - }, - "start": { - "additionalProperties": false, - "description": "Location within the source.\n\nContains both the human-readable line:column information and character index.", - "properties": { - "charIndex": { - "description": "Character index within the source code - starts at 0", - "type": "number" - }, - "column": { - "description": "Column number - starts at 1", - "type": "number" - }, - "line": { - "description": "Line number - starts at 1", - "type": "number" - } - }, - "required": [ - "charIndex", - "column", - "line" - ], - "type": "object" - } - }, - "required": [ - "end", - "start" - ], - "type": "object" - }, - "name": { - "pattern": "^[_a-zA-Z][_a-zA-Z0-9]*$", - "type": "string" - }, - "statements": { - "items": { - "anyOf": [ - { - "$ref": "#/definitions/OutcomeStatementNode" - }, - { - "$ref": "#/definitions/SetStatementNode" - }, - { - "$ref": "#/definitions/CallStatementNode" - }, - { - "$ref": "#/definitions/HttpCallStatementNode" - } - ] - }, - "type": "array" - }, - "usecaseName": { - "pattern": "^[_a-zA-Z][_a-zA-Z0-9]*$", - "type": "string" - } - }, - "required": [ - "kind", - "name", - "statements", - "usecaseName" - ], - "type": "object" - }, - "MapDocumentNode": { - "additionalProperties": false, - "description": "Map document:\n`
`\n`<...definitions>`", - "properties": { - "astMetadata": { - "$ref": "AstMetadata" - }, - "definitions": { - "items": { - "anyOf": [ - { - "$ref": "#/definitions/MapDefinitionNode" - }, - { - "$ref": "#/definitions/OperationDefinitionNode" - } - ] - }, - "type": "array" - }, - "header": { - "$ref": "#/definitions/MapHeaderNode" - }, - "kind": { - "enum": [ - "MapDocument" - ], - "type": "string" - }, - "location": { - "additionalProperties": false, - "description": "Location span within the source.", - "properties": { - "end": { - "additionalProperties": false, - "description": "Location within the source.\n\nContains both the human-readable line:column information and character index.", - "properties": { - "charIndex": { - "description": "Character index within the source code - starts at 0", - "type": "number" - }, - "column": { - "description": "Column number - starts at 1", - "type": "number" - }, - "line": { - "description": "Line number - starts at 1", - "type": "number" - } - }, - "required": [ - "charIndex", - "column", - "line" - ], - "type": "object" - }, - "start": { - "additionalProperties": false, - "description": "Location within the source.\n\nContains both the human-readable line:column information and character index.", - "properties": { - "charIndex": { - "description": "Character index within the source code - starts at 0", - "type": "number" - }, - "column": { - "description": "Column number - starts at 1", - "type": "number" - }, - "line": { - "description": "Line number - starts at 1", - "type": "number" - } - }, - "required": [ - "charIndex", - "column", - "line" - ], - "type": "object" - } - }, - "required": [ - "end", - "start" - ], - "type": "object" - } - }, - "required": [ - "astMetadata", - "definitions", - "header", - "kind" - ], - "type": "object" - }, - "MapHeaderNode": { - "additionalProperties": false, - "description": "Map header:\n`profile = `\n`provider = `", - "properties": { - "documentation": { - "additionalProperties": false, - "properties": { - "description": { - "type": "string" - }, - "location": { - "additionalProperties": false, - "description": "Location span within the source.", - "properties": { - "end": { - "additionalProperties": false, - "description": "Location within the source.\n\nContains both the human-readable line:column information and character index.", - "properties": { - "charIndex": { - "description": "Character index within the source code - starts at 0", - "type": "number" - }, - "column": { - "description": "Column number - starts at 1", - "type": "number" - }, - "line": { - "description": "Line number - starts at 1", - "type": "number" - } - }, - "required": [ - "charIndex", - "column", - "line" - ], - "type": "object" - }, - "start": { - "additionalProperties": false, - "description": "Location within the source.\n\nContains both the human-readable line:column information and character index.", - "properties": { - "charIndex": { - "description": "Character index within the source code - starts at 0", - "type": "number" - }, - "column": { - "description": "Column number - starts at 1", - "type": "number" - }, - "line": { - "description": "Line number - starts at 1", - "type": "number" - } - }, - "required": [ - "charIndex", - "column", - "line" - ], - "type": "object" - } - }, - "required": [ - "end", - "start" - ], - "type": "object" - }, - "title": { - "type": "string" - } - }, - "required": [ - "title" - ], - "type": "object" - }, - "kind": { - "enum": [ - "MapHeader" - ], - "type": "string" - }, - "location": { - "additionalProperties": false, - "description": "Location span within the source.", - "properties": { - "end": { - "additionalProperties": false, - "description": "Location within the source.\n\nContains both the human-readable line:column information and character index.", - "properties": { - "charIndex": { - "description": "Character index within the source code - starts at 0", - "type": "number" - }, - "column": { - "description": "Column number - starts at 1", - "type": "number" - }, - "line": { - "description": "Line number - starts at 1", - "type": "number" - } - }, - "required": [ - "charIndex", - "column", - "line" - ], - "type": "object" - }, - "start": { - "additionalProperties": false, - "description": "Location within the source.\n\nContains both the human-readable line:column information and character index.", - "properties": { - "charIndex": { - "description": "Character index within the source code - starts at 0", - "type": "number" - }, - "column": { - "description": "Column number - starts at 1", - "type": "number" - }, - "line": { - "description": "Line number - starts at 1", - "type": "number" - } - }, - "required": [ - "charIndex", - "column", - "line" - ], - "type": "object" - } - }, - "required": [ - "end", - "start" - ], - "type": "object" - }, - "profile": { - "additionalProperties": false, - "properties": { - "name": { - "pattern": "^[a-z][a-z0-9_-]*$", - "type": "string" - }, - "scope": { - "pattern": "^[a-z][a-z0-9_-]*$", - "type": "string" - }, - "version": { - "additionalProperties": false, - "properties": { - "label": { - "pattern": "^[a-z][a-z0-9_-]*$", - "type": "string" - }, - "major": { - "minimum": 0, - "type": "integer" - }, - "minor": { - "minimum": 0, - "type": "integer" - }, - "patch": { - "minimum": 0, - "type": "integer" - } - }, - "required": [ - "major", - "minor" - ], - "type": "object" - } - }, - "required": [ - "name", - "version" - ], - "type": "object" - }, - "provider": { - "pattern": "^[a-z][a-z0-9_-]*$", - "type": "string" - }, - "variant": { - "pattern": "^[a-z][a-z0-9_-]*$", - "type": "string" - } - }, - "required": [ - "kind", - "profile", - "provider" - ], - "type": "object" - }, - "ObjectLiteralNode": { - "additionalProperties": false, - "description": "Object literal node: `{ <...assignments> }`", - "properties": { - "fields": { - "items": { - "$ref": "#/definitions/AssignmentNode" - }, - "type": "array" - }, - "kind": { - "enum": [ - "ObjectLiteral" - ], - "type": "string" - }, - "location": { - "additionalProperties": false, - "description": "Location span within the source.", - "properties": { - "end": { - "additionalProperties": false, - "description": "Location within the source.\n\nContains both the human-readable line:column information and character index.", - "properties": { - "charIndex": { - "description": "Character index within the source code - starts at 0", - "type": "number" - }, - "column": { - "description": "Column number - starts at 1", - "type": "number" - }, - "line": { - "description": "Line number - starts at 1", - "type": "number" - } - }, - "required": [ - "charIndex", - "column", - "line" - ], - "type": "object" - }, - "start": { - "additionalProperties": false, - "description": "Location within the source.\n\nContains both the human-readable line:column information and character index.", - "properties": { - "charIndex": { - "description": "Character index within the source code - starts at 0", - "type": "number" - }, - "column": { - "description": "Column number - starts at 1", - "type": "number" - }, - "line": { - "description": "Line number - starts at 1", - "type": "number" - } - }, - "required": [ - "charIndex", - "column", - "line" - ], - "type": "object" - } - }, - "required": [ - "end", - "start" - ], - "type": "object" - } - }, - "required": [ - "fields", - "kind" - ], - "type": "object" - }, - "OperationDefinitionNode": { - "additionalProperties": false, - "description": "Operation definition: `operation { <...statements> }`", - "properties": { - "documentation": { - "additionalProperties": false, - "properties": { - "description": { - "type": "string" - }, - "location": { - "additionalProperties": false, - "description": "Location span within the source.", - "properties": { - "end": { - "additionalProperties": false, - "description": "Location within the source.\n\nContains both the human-readable line:column information and character index.", - "properties": { - "charIndex": { - "description": "Character index within the source code - starts at 0", - "type": "number" - }, - "column": { - "description": "Column number - starts at 1", - "type": "number" - }, - "line": { - "description": "Line number - starts at 1", - "type": "number" - } - }, - "required": [ - "charIndex", - "column", - "line" - ], - "type": "object" - }, - "start": { - "additionalProperties": false, - "description": "Location within the source.\n\nContains both the human-readable line:column information and character index.", - "properties": { - "charIndex": { - "description": "Character index within the source code - starts at 0", - "type": "number" - }, - "column": { - "description": "Column number - starts at 1", - "type": "number" - }, - "line": { - "description": "Line number - starts at 1", - "type": "number" - } - }, - "required": [ - "charIndex", - "column", - "line" - ], - "type": "object" - } - }, - "required": [ - "end", - "start" - ], - "type": "object" - }, - "title": { - "type": "string" - } - }, - "required": [ - "title" - ], - "type": "object" - }, - "kind": { - "enum": [ - "OperationDefinition" - ], - "type": "string" - }, - "location": { - "additionalProperties": false, - "description": "Location span within the source.", - "properties": { - "end": { - "additionalProperties": false, - "description": "Location within the source.\n\nContains both the human-readable line:column information and character index.", - "properties": { - "charIndex": { - "description": "Character index within the source code - starts at 0", - "type": "number" - }, - "column": { - "description": "Column number - starts at 1", - "type": "number" - }, - "line": { - "description": "Line number - starts at 1", - "type": "number" - } - }, - "required": [ - "charIndex", - "column", - "line" - ], - "type": "object" - }, - "start": { - "additionalProperties": false, - "description": "Location within the source.\n\nContains both the human-readable line:column information and character index.", - "properties": { - "charIndex": { - "description": "Character index within the source code - starts at 0", - "type": "number" - }, - "column": { - "description": "Column number - starts at 1", - "type": "number" - }, - "line": { - "description": "Line number - starts at 1", - "type": "number" - } - }, - "required": [ - "charIndex", - "column", - "line" - ], - "type": "object" - } - }, - "required": [ - "end", - "start" - ], - "type": "object" - }, - "name": { - "pattern": "^[_a-zA-Z][_a-zA-Z0-9]*$", - "type": "string" - }, - "statements": { - "items": { - "anyOf": [ - { - "$ref": "#/definitions/OutcomeStatementNode" - }, - { - "$ref": "#/definitions/SetStatementNode" - }, - { - "$ref": "#/definitions/CallStatementNode" - }, - { - "$ref": "#/definitions/HttpCallStatementNode" - } - ] - }, - "type": "array" - } - }, - "required": [ - "kind", - "name", - "statements" - ], - "type": "object" - }, - "OutcomeStatementNode": { - "additionalProperties": false, - "description": "Outcome node, specifying what value to return and whether to terminate the flow immediately:\n`return/fail `\n`map result/error `", - "properties": { - "condition": { - "$ref": "#/definitions/ConditionAtomNode", - "description": "Statement condition atom: `if ()`" - }, - "isError": { - "type": "boolean" - }, - "kind": { - "enum": [ - "OutcomeStatement" - ], - "type": "string" - }, - "location": { - "additionalProperties": false, - "description": "Location span within the source.", - "properties": { - "end": { - "additionalProperties": false, - "description": "Location within the source.\n\nContains both the human-readable line:column information and character index.", - "properties": { - "charIndex": { - "description": "Character index within the source code - starts at 0", - "type": "number" - }, - "column": { - "description": "Column number - starts at 1", - "type": "number" - }, - "line": { - "description": "Line number - starts at 1", - "type": "number" - } - }, - "required": [ - "charIndex", - "column", - "line" - ], - "type": "object" - }, - "start": { - "additionalProperties": false, - "description": "Location within the source.\n\nContains both the human-readable line:column information and character index.", - "properties": { - "charIndex": { - "description": "Character index within the source code - starts at 0", - "type": "number" - }, - "column": { - "description": "Column number - starts at 1", - "type": "number" - }, - "line": { - "description": "Line number - starts at 1", - "type": "number" - } - }, - "required": [ - "charIndex", - "column", - "line" - ], - "type": "object" - } - }, - "required": [ - "end", - "start" - ], - "type": "object" - }, - "terminateFlow": { - "type": "boolean" - }, - "value": { - "$ref": "#/definitions/LiteralNode" - } - }, - "required": [ - "isError", - "kind", - "terminateFlow", - "value" - ], - "type": "object" - }, - "PrimitiveLiteralNode": { - "additionalProperties": false, - "description": "Primitive literal atom like booleans, strings and numbers.", - "properties": { - "kind": { - "enum": [ - "PrimitiveLiteral" - ], - "type": "string" - }, - "location": { - "additionalProperties": false, - "description": "Location span within the source.", - "properties": { - "end": { - "additionalProperties": false, - "description": "Location within the source.\n\nContains both the human-readable line:column information and character index.", - "properties": { - "charIndex": { - "description": "Character index within the source code - starts at 0", - "type": "number" - }, - "column": { - "description": "Column number - starts at 1", - "type": "number" - }, - "line": { - "description": "Line number - starts at 1", - "type": "number" - } - }, - "required": [ - "charIndex", - "column", - "line" - ], - "type": "object" - }, - "start": { - "additionalProperties": false, - "description": "Location within the source.\n\nContains both the human-readable line:column information and character index.", - "properties": { - "charIndex": { - "description": "Character index within the source code - starts at 0", - "type": "number" - }, - "column": { - "description": "Column number - starts at 1", - "type": "number" - }, - "line": { - "description": "Line number - starts at 1", - "type": "number" - } - }, - "required": [ - "charIndex", - "column", - "line" - ], - "type": "object" - } - }, - "required": [ - "end", - "start" - ], - "type": "object" - }, - "value": { - "type": [ - "string", - "number", - "boolean" - ] - } - }, - "required": [ - "kind", - "value" - ], - "type": "object" - }, - "SetStatementNode": { - "additionalProperties": false, - "description": "Set statement, possibly with a condition: `set { <...assignments> }`", - "properties": { - "assignments": { - "items": { - "$ref": "#/definitions/AssignmentNode" - }, - "type": "array" - }, - "condition": { - "$ref": "#/definitions/ConditionAtomNode", - "description": "Statement condition atom: `if ()`" - }, - "kind": { - "enum": [ - "SetStatement" - ], - "type": "string" - }, - "location": { - "additionalProperties": false, - "description": "Location span within the source.", - "properties": { - "end": { - "additionalProperties": false, - "description": "Location within the source.\n\nContains both the human-readable line:column information and character index.", - "properties": { - "charIndex": { - "description": "Character index within the source code - starts at 0", - "type": "number" - }, - "column": { - "description": "Column number - starts at 1", - "type": "number" - }, - "line": { - "description": "Line number - starts at 1", - "type": "number" - } - }, - "required": [ - "charIndex", - "column", - "line" - ], - "type": "object" - }, - "start": { - "additionalProperties": false, - "description": "Location within the source.\n\nContains both the human-readable line:column information and character index.", - "properties": { - "charIndex": { - "description": "Character index within the source code - starts at 0", - "type": "number" - }, - "column": { - "description": "Column number - starts at 1", - "type": "number" - }, - "line": { - "description": "Line number - starts at 1", - "type": "number" - } - }, - "required": [ - "charIndex", - "column", - "line" - ], - "type": "object" - } - }, - "required": [ - "end", - "start" - ], - "type": "object" - } - }, - "required": [ - "assignments", - "kind" - ], - "type": "object" - } - } -} - diff --git a/src/interfaces/ast/map-ast.ts b/src/interfaces/ast/map-ast.ts deleted file mode 100644 index 9f33481..0000000 --- a/src/interfaces/ast/map-ast.ts +++ /dev/null @@ -1,312 +0,0 @@ -import { AstMetadata, DocumentedNode, LocationSpan } from './source'; - -export type MapNodeKind = - // ATOMS - | 'PrimitiveLiteral' - | 'ObjectLiteral' - | 'JessieExpression' - | 'InlineCall' - | 'Assignment' - | 'ConditionAtom' - | 'IterationAtom' - // STATEMENTS - | 'SetStatement' - | 'OutcomeStatement' - // CONTEXTUAL STATEMENTS - | 'CallStatement' - | 'HttpRequest' - | 'HttpResponseHandler' - | 'HttpCallStatement' - // DEFINITIONS - | 'MapDefinition' - | 'OperationDefinition' - // DOCUMENT - | 'MapHeader' - | 'MapDocument'; - -export interface MapASTNodeBase { - kind: MapNodeKind; - location?: LocationSpan; -} - -// ATOMS - -/** - * Primitive literal atom like booleans, strings and numbers. - */ -export interface PrimitiveLiteralNode extends MapASTNodeBase { - kind: 'PrimitiveLiteral'; - value: number | string | boolean; -} - -/** - * Object literal node: `{ <...assignments> }` - */ -export interface ObjectLiteralNode extends MapASTNodeBase { - kind: 'ObjectLiteral'; - fields: AssignmentNode[]; -} - -/** - * Jessie expression node: `` - */ -export interface JessieExpressionNode extends MapASTNodeBase { - kind: 'JessieExpression'; - expression: string; - source?: string; - sourceMap?: string; -} - -/** - * Inline call, can appear on rhs in assignment: `call (<...args>) ` - */ -export interface InlineCallNode extends MapASTNodeBase { - kind: 'InlineCall'; - condition?: ConditionAtomNode; - iteration?: IterationAtomNode; - operationName: string; - arguments: AssignmentNode[]; -} - -export type LiteralNode = - | ObjectLiteralNode - | InlineCallNode - | PrimitiveLiteralNode - | JessieExpressionNode; - -/** - * Assignment node: `key."b.az".bar = ` - */ -export interface AssignmentNode extends MapASTNodeBase { - kind: 'Assignment'; - key: string[]; - value: LiteralNode; -} - -/** - * Statement condition atom: `if ()` - */ -export interface ConditionAtomNode extends MapASTNodeBase { - kind: 'ConditionAtom'; - expression: JessieExpressionNode; -} - -/** - * Iteration atom: `foreach ( of )` - */ -export interface IterationAtomNode extends MapASTNodeBase { - kind: 'IterationAtom'; - iterationVariable: string; - iterable: JessieExpressionNode; -} - -// STATEMENTS - -/** - * Outcome node, specifying what value to return and whether to terminate the flow immediately: - * `return/fail ` - * `map result/error ` - */ -export interface OutcomeStatementNode extends MapASTNodeBase { - kind: 'OutcomeStatement'; - condition?: ConditionAtomNode; - isError: boolean; - terminateFlow: boolean; - value: LiteralNode; -} - -// SCOPING STATEMENTS - -/** - * Set statement, possibly with a condition: `set { <...assignments> }` - */ -export interface SetStatementNode extends MapASTNodeBase { - kind: 'SetStatement'; - condition?: ConditionAtomNode; - assignments: AssignmentNode[]; -} - -/** - * Call statement, possibly with a condition and iteration: `call (<...args>) { <...statements> }` - */ -export interface CallStatementNode extends MapASTNodeBase { - kind: 'CallStatement'; - iteration?: IterationAtomNode; - condition?: ConditionAtomNode; - operationName: string; - arguments: AssignmentNode[]; - statements: (SetStatementNode | OutcomeStatementNode)[]; -} - -/** - * Http security requirement: `security ` - */ -export type HttpSecurityRequirement = { - id: string; - /** Optional scheme information. */ - scheme?: 'apikey' | 'basic' | 'bearer'; -}; - -/** - * Request definition for http: - * `request { }` - */ -export interface HttpRequestNode extends MapASTNodeBase { - kind: 'HttpRequest'; - contentType?: string; - contentLanguage?: string; - query?: ObjectLiteralNode; - headers?: ObjectLiteralNode; - body?: LiteralNode; - security: HttpSecurityRequirement[]; -} - -/** - * Response handler for http: `response { <...statements> }` - */ -export interface HttpResponseHandlerNode extends MapASTNodeBase { - kind: 'HttpResponseHandler'; - /** - * @TJS-type integer - * @TJS-minimum 200 - * @TJS-maximum 599 - **/ - statusCode?: number; - contentType?: string; - contentLanguage?: string; - statements: (SetStatementNode | OutcomeStatementNode)[]; -} - -/** - * Http call statement: `http { <...responseHandlers> }` - */ -export interface HttpCallStatementNode extends MapASTNodeBase { - kind: 'HttpCallStatement'; - method: string; - serviceId?: string; - url: string; - request?: HttpRequestNode; - responseHandlers: HttpResponseHandlerNode[]; -} - -// DEFINITIONS - -export type Substatement = - | SetStatementNode - | OutcomeStatementNode - | CallStatementNode - | HttpCallStatementNode; - -/** - * Map definition: `map { <...statements> }` - */ -export interface MapDefinitionNode extends MapASTNodeBase, DocumentedNode { - kind: 'MapDefinition'; - - /** - * @pattern require('./utils').IDENTIFIER_RE_SOURCE - */ - name: string; - /** - * @pattern require('./utils').IDENTIFIER_RE_SOURCE - */ - usecaseName: string; - statements: Substatement[]; -} - -/** - * Operation definition: `operation { <...statements> }` - */ -export interface OperationDefinitionNode - extends MapASTNodeBase, - DocumentedNode { - kind: 'OperationDefinition'; - /** - * @pattern require('./utils').IDENTIFIER_RE_SOURCE - */ - name: string; - statements: Substatement[]; -} - -// DOCUMENT - -/** - * Map header: - * `profile = ` - * `provider = ` - */ -export interface MapHeaderNode extends MapASTNodeBase, DocumentedNode { - kind: 'MapHeader'; - profile: { - /** - * @pattern require('./utils').DOCUMENT_NAME_RE_SOURCE - **/ - scope?: string; - /** - * @pattern require('./utils').DOCUMENT_NAME_RE_SOURCE - **/ - name: string; - version: { - /** - * @TJS-minimum 0 - * @TJS-type integer - **/ - major: number; - /** - * @TJS-minimum 0 - * @TJS-type integer - **/ - minor: number; - /** - * @TJS-minimum 0 - * @TJS-type integer - **/ - patch?: number; - /** - * @pattern require('./utils').DOCUMENT_NAME_RE_SOURCE - **/ - label?: string; - }; - }; - - /** - * @pattern require("./utils.ts").DOCUMENT_NAME_RE_SOURCE - **/ - provider: string; - /** - * @pattern require('./utils').DOCUMENT_NAME_RE_SOURCE - **/ - variant?: string; -} - -/** - * Map document: - * `
` - * `<...definitions>` - */ -export interface MapDocumentNode extends MapASTNodeBase { - /** @$ref AstMetadata */ - astMetadata: AstMetadata; - kind: 'MapDocument'; - header: MapHeaderNode; - definitions: (MapDefinitionNode | OperationDefinitionNode)[]; -} - -export type MapASTNode = - | PrimitiveLiteralNode - | ObjectLiteralNode - | JessieExpressionNode - | AssignmentNode - | ConditionAtomNode - | IterationAtomNode - | SetStatementNode - | OutcomeStatementNode - | CallStatementNode - | HttpRequestNode - | HttpResponseHandlerNode - | HttpCallStatementNode - | MapDefinitionNode - | OperationDefinitionNode - | MapHeaderNode - | MapDocumentNode - | InlineCallNode; diff --git a/src/interfaces/ast/map-ast.utils.test.ts b/src/interfaces/ast/map-ast.utils.test.ts deleted file mode 100644 index 32df314..0000000 --- a/src/interfaces/ast/map-ast.utils.test.ts +++ /dev/null @@ -1,623 +0,0 @@ -import { - assertMapDocumentNode, - AssignmentNode, - CallStatementNode, - ConditionAtomNode, - HttpCallStatementNode, - HttpRequestNode, - HttpResponseHandlerNode, - InlineCallNode, - isAssignmentNode, - isCallStatementNode, - isConditionAtomNode, - isHttpCallStatementNode, - isHttpRequestNode, - isHttpResponseHandlerNode, - isInlineCallNode, - isIterationAtomNode, - isJessieExpressionNode, - isMapDefinitionNode, - isMapDocumentNode, - isMapHeaderNode, - isObjectLiteralNode, - isOperationDefinitionNode, - isOutcomeStatementNode, - isPrimitiveLiteralNode, - isSetStatementNode, - IterationAtomNode, - JessieExpressionNode, - MapDefinitionNode, - MapDocumentNode, - MapHeaderNode, - ObjectLiteralNode, - OperationDefinitionNode, - OutcomeStatementNode, - PrimitiveLiteralNode, - SetStatementNode, -} from '.'; - -describe('map-ast.utils', () => { - describe('isOutcomeStatementNode', () => { - it('checks if node is outcome statement node', () => { - const outcomeNode: OutcomeStatementNode = { - kind: 'OutcomeStatement', - isError: false, - terminateFlow: false, - value: { - kind: 'ObjectLiteral', - fields: [], - }, - }; - expect(isOutcomeStatementNode(outcomeNode)).toEqual(true); - - const operationNode: OperationDefinitionNode = { - kind: 'OperationDefinition', - name: 'test', - statements: [], - }; - expect(isOutcomeStatementNode(operationNode)).toEqual(false); - }); - }); - - describe('isOperationDefinitionNode', () => { - it('checks if node is operation definition node', () => { - const outcomeNode: OutcomeStatementNode = { - kind: 'OutcomeStatement', - isError: false, - terminateFlow: false, - value: { - kind: 'ObjectLiteral', - fields: [], - }, - }; - expect(isOperationDefinitionNode(outcomeNode)).toEqual(false); - - const operationNode: OperationDefinitionNode = { - kind: 'OperationDefinition', - name: 'test', - statements: [], - }; - expect(isOperationDefinitionNode(operationNode)).toEqual(true); - }); - }); - - describe('isSetStatementNode', () => { - it('checks if node is set statement node', () => { - const outcomeNode: OutcomeStatementNode = { - kind: 'OutcomeStatement', - isError: false, - terminateFlow: false, - value: { - kind: 'ObjectLiteral', - fields: [], - }, - }; - expect(isSetStatementNode(outcomeNode)).toEqual(false); - - const node: SetStatementNode = { - kind: 'SetStatement', - assignments: [], - }; - expect(isSetStatementNode(node)).toEqual(true); - }); - }); - - describe('isMapHeaderNode', () => { - it('checks if node is map header node', () => { - const outcomeNode: OutcomeStatementNode = { - kind: 'OutcomeStatement', - isError: false, - terminateFlow: false, - value: { - kind: 'ObjectLiteral', - fields: [], - }, - }; - expect(isMapHeaderNode(outcomeNode)).toEqual(false); - - const node: MapHeaderNode = { - kind: 'MapHeader', - profile: { - name: 'test', - version: { - major: 1, - minor: 0, - }, - }, - provider: 'provider', - }; - expect(isMapHeaderNode(node)).toEqual(true); - }); - }); - - describe('isMapDefinitionNode', () => { - it('checks if node is map definition node', () => { - const outcomeNode: OutcomeStatementNode = { - kind: 'OutcomeStatement', - isError: false, - terminateFlow: false, - value: { - kind: 'ObjectLiteral', - fields: [], - }, - }; - expect(isMapDefinitionNode(outcomeNode)).toEqual(false); - - const node: MapDefinitionNode = { - kind: 'MapDefinition', - name: 'test', - usecaseName: 'test', - statements: [], - }; - expect(isMapDefinitionNode(node)).toEqual(true); - }); - }); - - describe('isMapDocumentNode', () => { - it('checks if node is map definition node', () => { - const outcomeNode: OutcomeStatementNode = { - kind: 'OutcomeStatement', - isError: false, - terminateFlow: false, - value: { - kind: 'ObjectLiteral', - fields: [], - }, - }; - expect(isMapDocumentNode(outcomeNode)).toEqual(false); - - const node: MapDocumentNode = { - kind: 'MapDocument', - astMetadata: { - astVersion: { major: 1, minor: 0, patch: 0 }, - parserVersion: { major: 1, minor: 0, patch: 0 }, - sourceChecksum: 'dsdds', - }, - header: { - kind: 'MapHeader', - profile: { - name: 'test', - version: { - major: 1, - minor: 0, - }, - }, - provider: 'provider', - }, - definitions: [], - }; - expect(isMapDocumentNode(node)).toEqual(true); - }); - }); - - describe('isPrimitiveLiteralNode', () => { - it('checks if node is primitive literal node', () => { - const outcomeNode: OutcomeStatementNode = { - kind: 'OutcomeStatement', - isError: false, - terminateFlow: false, - value: { - kind: 'ObjectLiteral', - fields: [], - }, - }; - expect(isPrimitiveLiteralNode(outcomeNode)).toEqual(false); - - const node: PrimitiveLiteralNode = { - kind: 'PrimitiveLiteral', - value: 1, - }; - expect(isPrimitiveLiteralNode(node)).toEqual(true); - }); - }); - - describe('isObjectLiteralNode', () => { - it('checks if node is object literal node', () => { - const outcomeNode: OutcomeStatementNode = { - kind: 'OutcomeStatement', - isError: false, - terminateFlow: false, - value: { - kind: 'ObjectLiteral', - fields: [], - }, - }; - expect(isObjectLiteralNode(outcomeNode)).toEqual(false); - - const node: ObjectLiteralNode = { - kind: 'ObjectLiteral', - fields: [], - }; - expect(isObjectLiteralNode(node)).toEqual(true); - }); - }); - - describe('isJessieExpressionNode', () => { - it('checks if node is jessie expression node', () => { - const outcomeNode: OutcomeStatementNode = { - kind: 'OutcomeStatement', - isError: false, - terminateFlow: false, - value: { - kind: 'ObjectLiteral', - fields: [], - }, - }; - expect(isJessieExpressionNode(outcomeNode)).toEqual(false); - - const node: JessieExpressionNode = { - kind: 'JessieExpression', - expression: 'test', - }; - expect(isJessieExpressionNode(node)).toEqual(true); - }); - }); - - describe('isAssignmentNode', () => { - it('checks if node is assignment node', () => { - const outcomeNode: OutcomeStatementNode = { - kind: 'OutcomeStatement', - isError: false, - terminateFlow: false, - value: { - kind: 'ObjectLiteral', - fields: [], - }, - }; - expect(isAssignmentNode(outcomeNode)).toEqual(false); - - const node: AssignmentNode = { - kind: 'Assignment', - key: [], - value: { - kind: 'ObjectLiteral', - fields: [], - }, - }; - expect(isAssignmentNode(node)).toEqual(true); - }); - }); - - describe('isConditionAtomNode', () => { - it('checks if node is condition atom node', () => { - const outcomeNode: OutcomeStatementNode = { - kind: 'OutcomeStatement', - isError: false, - terminateFlow: false, - value: { - kind: 'ObjectLiteral', - fields: [], - }, - }; - expect(isConditionAtomNode(outcomeNode)).toEqual(false); - - const node: ConditionAtomNode = { - kind: 'ConditionAtom', - expression: { - kind: 'JessieExpression', - expression: 'test', - }, - }; - expect(isConditionAtomNode(node)).toEqual(true); - }); - }); - - describe('isIterationAtomNode', () => { - it('checks if node is iteration atom node', () => { - const outcomeNode: OutcomeStatementNode = { - kind: 'OutcomeStatement', - isError: false, - terminateFlow: false, - value: { - kind: 'ObjectLiteral', - fields: [], - }, - }; - expect(isIterationAtomNode(outcomeNode)).toEqual(false); - - const node: IterationAtomNode = { - kind: 'IterationAtom', - iterationVariable: 'test', - iterable: { - kind: 'JessieExpression', - expression: 'test', - }, - }; - expect(isIterationAtomNode(node)).toEqual(true); - }); - }); - - describe('isCallStatementNode', () => { - it('checks if node is call statement node', () => { - const outcomeNode: OutcomeStatementNode = { - kind: 'OutcomeStatement', - isError: false, - terminateFlow: false, - value: { - kind: 'ObjectLiteral', - fields: [], - }, - }; - expect(isCallStatementNode(outcomeNode)).toEqual(false); - - const node: CallStatementNode = { - kind: 'CallStatement', - operationName: 'test', - arguments: [], - statements: [], - }; - expect(isCallStatementNode(node)).toEqual(true); - }); - }); - - describe('isHttpRequestNode', () => { - it('checks if node is http request node', () => { - const outcomeNode: OutcomeStatementNode = { - kind: 'OutcomeStatement', - isError: false, - terminateFlow: false, - value: { - kind: 'ObjectLiteral', - fields: [], - }, - }; - expect(isHttpRequestNode(outcomeNode)).toEqual(false); - - const node: HttpRequestNode = { - kind: 'HttpRequest', - security: [], - }; - expect(isHttpRequestNode(node)).toEqual(true); - }); - }); - - describe('isHttpResponseHandlerNode', () => { - it('checks if node is http request node', () => { - const outcomeNode: OutcomeStatementNode = { - kind: 'OutcomeStatement', - isError: false, - terminateFlow: false, - value: { - kind: 'ObjectLiteral', - fields: [], - }, - }; - expect(isHttpResponseHandlerNode(outcomeNode)).toEqual(false); - - const node: HttpResponseHandlerNode = { - kind: 'HttpResponseHandler', - statements: [], - }; - expect(isHttpResponseHandlerNode(node)).toEqual(true); - }); - }); - - describe('isHttpCallStatementNode', () => { - it('checks if node is http call statement node', () => { - const outcomeNode: OutcomeStatementNode = { - kind: 'OutcomeStatement', - isError: false, - terminateFlow: false, - value: { - kind: 'ObjectLiteral', - fields: [], - }, - }; - expect(isHttpCallStatementNode(outcomeNode)).toEqual(false); - - const node: HttpCallStatementNode = { - kind: 'HttpCallStatement', - method: 'GET', - url: 'test/url', - responseHandlers: [], - }; - expect(isHttpCallStatementNode(node)).toEqual(true); - }); - }); - - describe('isInlineCallNode', () => { - it('checks if node is http call statement node', () => { - const outcomeNode: OutcomeStatementNode = { - kind: 'OutcomeStatement', - isError: false, - terminateFlow: false, - value: { - kind: 'ObjectLiteral', - fields: [], - }, - }; - expect(isInlineCallNode(outcomeNode)).toEqual(false); - - const node: InlineCallNode = { - kind: 'InlineCall', - operationName: 'test', - arguments: [], - }; - expect(isInlineCallNode(node)).toEqual(true); - }); - }); - - describe('assertMapDocumentNode', () => { - it('asserts node is map definition node', () => { - { - const invalidNode = { - astMetadata: { - sourceChecksum: 'checksum', - astVersion: { - major: 1, - minor: 0, - patch: 0, - }, - parserVersion: { - major: 1, - minor: 0, - patch: 0, - }, - }, - kind: 'MapDocument', - header: { - kind: 'MapHeader', - profile: { - name: 'test', - version: { - major: 'banana', - minor: 0, - }, - }, - provider: 'provider', - }, - definitions: [], - }; - expect(() => assertMapDocumentNode(invalidNode)).toThrow( - 'header.profile.version.major: must be integer, received string' - ); - } - - { - const invalidNode = { - astMetadata: { - sourceChecksum: 'checksum', - astVersion: { - major: 1, - minor: 0, - patch: 0, - }, - parserVersion: { - major: 1, - minor: 0, - patch: 0, - }, - }, - kind: 'MapDocument', - header: { - kind: 'MapHeader', - profile: { - name: 'test', - version: { - major: 7, - minor: 0, - }, - }, - provider: 'provider', - }, - definitions: [ - { - kind: 'MapDefinition', - name: 'test', - statements: [ - { - kind: 'OutcomeStatement', - isError: false, - terminateFlow: 'a banana', - value: { - kind: 'PrimitiveLiteral', - value: 7, - }, - }, - ], - usecaseName: 'test', - }, - ], - }; - - expect(() => assertMapDocumentNode(invalidNode)).toThrow( - 'definitions.0.statements.0.terminateFlow: must be boolean, received string' - ); - } - - const validNode: MapDocumentNode = { - astMetadata: { - sourceChecksum: 'checksum', - astVersion: { - major: 1, - minor: 0, - patch: 0, - }, - parserVersion: { - major: 1, - minor: 0, - patch: 0, - }, - }, - kind: 'MapDocument', - header: { - kind: 'MapHeader', - profile: { - name: 'test', - version: { - major: 1, - minor: 0, - }, - }, - provider: 'provider', - }, - definitions: [ - { - kind: 'MapDefinition', - name: 'test', - statements: [ - { - kind: 'OutcomeStatement', - isError: false, - terminateFlow: true, - value: { - kind: 'PrimitiveLiteral', - value: 7, - }, - }, - ], - usecaseName: 'test', - }, - ], - }; - expect(assertMapDocumentNode(validNode)).toEqual(validNode); - }); - - it('should not trip up assertion with special chars in url', () => { - const validNode: MapDocumentNode = { - astMetadata: { - sourceChecksum: 'checksum', - astVersion: { - major: 1, - minor: 0, - patch: 0, - }, - parserVersion: { - major: 1, - minor: 0, - patch: 0, - }, - }, - kind: 'MapDocument', - header: { - kind: 'MapHeader', - profile: { - name: 'test', - version: { - major: 1, - minor: 0, - }, - }, - provider: 'provider', - }, - definitions: [ - { - kind: 'MapDefinition', - name: 'test', - usecaseName: 'test', - statements: [ - { - kind: 'HttpCallStatement', - method: 'GET', - url: '/api/{input.wtf}[]\\{}/omg', - responseHandlers: [] - } - ], - }, - ], - }; - - expect(() => assertMapDocumentNode(validNode)).not.toThrow(); - }); - }); -}); diff --git a/src/interfaces/ast/map-ast.utils.ts b/src/interfaces/ast/map-ast.utils.ts deleted file mode 100644 index 16ab8ba..0000000 --- a/src/interfaces/ast/map-ast.utils.ts +++ /dev/null @@ -1,111 +0,0 @@ -import { prepareAssert } from '../../validation'; -import { - AssignmentNode, - CallStatementNode, - ConditionAtomNode, - HttpCallStatementNode, - HttpRequestNode, - HttpResponseHandlerNode, - InlineCallNode, - IterationAtomNode, - JessieExpressionNode, - MapASTNode, - MapDefinitionNode, - MapDocumentNode, - MapHeaderNode, - ObjectLiteralNode, - OperationDefinitionNode, - OutcomeStatementNode, - PrimitiveLiteralNode, - SetStatementNode, -} from './map-ast'; -import * as schema from './map-ast.schema.json'; -import { Assert } from './utils'; - -const assertMapDocument: Assert = prepareAssert( - schema, - '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'; -export const isCallStatementNode = ( - node: MapASTNode -): node is CallStatementNode => node.kind === 'CallStatement'; -export const isConditionAtomNode = ( - node: MapASTNode -): node is ConditionAtomNode => node.kind === 'ConditionAtom'; -export const isHttpCallStatementNode = ( - node: MapASTNode -): node is HttpCallStatementNode => node.kind === 'HttpCallStatement'; -export const isHttpRequestNode = (node: MapASTNode): node is HttpRequestNode => - node.kind === 'HttpRequest'; -export const isHttpResponseHandlerNode = ( - node: MapASTNode -): node is HttpResponseHandlerNode => node.kind === 'HttpResponseHandler'; -export const isInlineCallNode = (node: MapASTNode): node is InlineCallNode => - node.kind === 'InlineCall'; -export const isIterationAtomNode = ( - node: MapASTNode -): node is IterationAtomNode => node.kind === 'IterationAtom'; -export const isJessieExpressionNode = ( - node: MapASTNode -): node is JessieExpressionNode => node.kind === 'JessieExpression'; -export const isMapDefinitionNode = ( - node: MapASTNode -): node is MapDefinitionNode => node.kind === 'MapDefinition'; -export const isMapHeaderNode = (node: MapASTNode): node is MapHeaderNode => - node.kind === 'MapHeader'; -export const isObjectLiteralNode = ( - node: MapASTNode -): node is ObjectLiteralNode => node.kind === 'ObjectLiteral'; -export const isOperationDefinitionNode = ( - node: MapASTNode -): node is OperationDefinitionNode => node.kind === 'OperationDefinition'; -export const isOutcomeStatementNode = ( - node: MapASTNode -): node is OutcomeStatementNode => node.kind === 'OutcomeStatement'; -export const isPrimitiveLiteralNode = ( - node: MapASTNode -): node is PrimitiveLiteralNode => node.kind === 'PrimitiveLiteral'; -export const isSetStatementNode = ( - node: MapASTNode -): node is SetStatementNode => node.kind === 'SetStatement'; - -export function assertMapDocumentNode(node: unknown): MapDocumentNode { - assertMapDocument(node); - - return node; -} - -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; -}