From 98fcfe34cb6d07fed2b7b2f4780fdfc620e6ce41 Mon Sep 17 00:00:00 2001 From: Frank Kilcommins Date: Tue, 27 Aug 2024 23:28:14 +0100 Subject: [PATCH] chore(rulesets): add arazzoTypes and refactor validations and tests --- ...arazzoStepFailureActionsValidation.test.ts | 49 +--------- .../arazzoStepParametersValidation.test.ts | 40 +------- .../arazzoStepRequestBodyValidation.test.ts | 52 +---------- ...arazzoStepSuccessActionsValidation.test.ts | 47 +--------- ...razzoStepSuccessCriteriaValidation.test.ts | 27 +----- .../__tests__/arazzoStepValidation.test.ts | 73 +-------------- .../arazzoWorkflowIdUniqueness.test.ts | 20 +--- ...razzoWorkflowOutputNamesValidation.test.ts | 59 +----------- ...arazzoWorkflowsDependsOnValidation.test.ts | 61 +----------- .../functions/arazzoCriterionValidation.ts | 28 +----- .../arazzoRuntimeExpressionValidation.ts | 72 +-------------- .../arazzoStepFailureActionsValidation.ts | 52 +---------- .../arazzoStepOutputNamesValidation.ts | 61 +----------- .../arazzoStepParametersValidation.ts | 37 +------- .../arazzoStepRequestBodyValidation.ts | 52 +---------- .../arazzoStepSuccessActionsValidation.ts | 50 +--------- .../arazzoStepSuccessCriteriaValidation.ts | 27 +----- .../arazzo/functions/arazzoStepValidation.ts | 75 +-------------- .../arazzoWorkflowDependsOnValidation.ts | 62 +------------ .../functions/arazzoWorkflowIdUniqueness.ts | 56 ++++------- .../arazzoWorkflowOutputNamesValidation.ts | 62 +------------ .../src/arazzo/functions/types/arazzoTypes.ts | 92 +++++++++++++++++++ .../functions/utils/getAllFailureActions.ts | 61 +----------- .../functions/utils/getAllParameters.ts | 63 +------------ .../functions/utils/getAllSuccessActions.ts | 61 +----------- .../arazzo/functions/utils/getAllWorkflows.ts | 9 +- 26 files changed, 139 insertions(+), 1209 deletions(-) create mode 100644 packages/rulesets/src/arazzo/functions/types/arazzoTypes.ts diff --git a/packages/rulesets/src/arazzo/functions/__tests__/arazzoStepFailureActionsValidation.test.ts b/packages/rulesets/src/arazzo/functions/__tests__/arazzoStepFailureActionsValidation.test.ts index 18bde30da..79d6ea8f0 100644 --- a/packages/rulesets/src/arazzo/functions/__tests__/arazzoStepFailureActionsValidation.test.ts +++ b/packages/rulesets/src/arazzo/functions/__tests__/arazzoStepFailureActionsValidation.test.ts @@ -1,53 +1,6 @@ import arazzoStepFailureActionsValidation from '../arazzoStepFailureActionsValidation'; import type { RulesetFunctionContext } from '@stoplight/spectral-core'; - -type FailureAction = { - name: string; - type: string; - workflowId?: string; - stepId?: string; - retryAfter?: number; - retryLimit?: number; - criteria?: Criterion[]; -}; - -type SourceDescription = { - name: string; - url: string; - type?: string; -}; - -type CriterionExpressionType = { - type: 'jsonpath' | 'xpath'; - version: 'draft-goessner-dispatch-jsonpath-00' | 'xpath-30' | 'xpath-20' | 'xpath-10'; -}; - -type Criterion = { - context?: string; - condition: string; - type?: 'simple' | 'regex' | 'jsonpath' | 'xpath' | CriterionExpressionType; -}; - -type ReusableObject = { - reference: string; -}; - -type Step = { - stepId: string; - onFailure?: (FailureAction | ReusableObject)[]; -}; - -type Workflow = { - workflowId: string; - steps: Step[]; - failureActions?: (FailureAction | ReusableObject)[]; -}; - -type ArazzoSpecification = { - sourceDescriptions?: SourceDescription[]; - workflows: Workflow[]; - components?: { failureActions?: Record }; -}; +import { ArazzoSpecification } from '../types/arazzoTypes'; const runRule = (target: ArazzoSpecification, _contextOverrides: Partial = {}) => { return arazzoStepFailureActionsValidation(target, null); diff --git a/packages/rulesets/src/arazzo/functions/__tests__/arazzoStepParametersValidation.test.ts b/packages/rulesets/src/arazzo/functions/__tests__/arazzoStepParametersValidation.test.ts index 4d6ec84a5..00efb026c 100644 --- a/packages/rulesets/src/arazzo/functions/__tests__/arazzoStepParametersValidation.test.ts +++ b/packages/rulesets/src/arazzo/functions/__tests__/arazzoStepParametersValidation.test.ts @@ -1,44 +1,6 @@ import arazzoStepParametersValidation from '../arazzoStepParametersValidation'; import type { RulesetFunctionContext } from '@stoplight/spectral-core'; - -type Parameter = { - name: string; - in?: string; - value: string; -}; - -type ReusableObject = { - reference: string; -}; - -type Step = { - stepId: string; - parameters?: (Parameter | ReusableObject)[]; - workflowId?: string; - operationId?: string; - operationPath?: string; -}; - -type Workflow = { - workflowId: string; - steps: Step[]; - inputs?: Record; -}; - -type SourceDescription = { - name: string; - url: string; - type?: string; -}; - -type ArazzoSpecification = { - workflows: Workflow[]; - components?: { - parameters?: Record; - inputs?: Record; - }; - sourceDescriptions?: SourceDescription[]; -}; +import { ArazzoSpecification } from '../types/arazzoTypes'; const runRule = (target: ArazzoSpecification, _contextOverrides: Partial = {}) => { return arazzoStepParametersValidation(target, null); diff --git a/packages/rulesets/src/arazzo/functions/__tests__/arazzoStepRequestBodyValidation.test.ts b/packages/rulesets/src/arazzo/functions/__tests__/arazzoStepRequestBodyValidation.test.ts index 159b2fc33..8a2e0f702 100644 --- a/packages/rulesets/src/arazzo/functions/__tests__/arazzoStepRequestBodyValidation.test.ts +++ b/packages/rulesets/src/arazzo/functions/__tests__/arazzoStepRequestBodyValidation.test.ts @@ -1,56 +1,6 @@ import arazzoStepRequestBodyValidation from '../arazzoStepRequestBodyValidation'; import type { RulesetFunctionContext } from '@stoplight/spectral-core'; - -type PayloadReplacement = { - target: string; - value: unknown | string; -}; - -type RequestBody = { - contentType?: string; - payload?: unknown | string; - replacements?: PayloadReplacement[]; -}; - -type Parameter = { - name: string; - in?: string; - value?: unknown; -}; - -type Step = { - stepId: string; - outputs?: Record; - requestBody?: RequestBody; - parameters?: (Parameter | ReusableObject)[]; -}; - -type ArazzoSpecification = { - workflows: Workflow[]; - sourceDescriptions?: SourceDescription[]; - components?: { - parameters?: Record; - [key: string]: unknown; - }; -}; - -type ReusableObject = { - reference: string; -}; - -type SourceDescription = { - name: string; - url: string; - type?: string; -}; - -type Workflow = { - workflowId: string; - steps: Step[]; - inputs?: Record; - parameters?: (Parameter | ReusableObject)[]; - outputs?: Record; -}; +import { ArazzoSpecification } from '../types/arazzoTypes'; const runRule = (target: ArazzoSpecification, _contextOverrides: Partial = {}) => { return arazzoStepRequestBodyValidation(target, null); diff --git a/packages/rulesets/src/arazzo/functions/__tests__/arazzoStepSuccessActionsValidation.test.ts b/packages/rulesets/src/arazzo/functions/__tests__/arazzoStepSuccessActionsValidation.test.ts index 03f2ccc12..85058a124 100644 --- a/packages/rulesets/src/arazzo/functions/__tests__/arazzoStepSuccessActionsValidation.test.ts +++ b/packages/rulesets/src/arazzo/functions/__tests__/arazzoStepSuccessActionsValidation.test.ts @@ -1,51 +1,6 @@ import arazzoStepSuccessActionsValidation from '../arazzoStepSuccessActionsValidation'; import type { RulesetFunctionContext } from '@stoplight/spectral-core'; - -type SuccessAction = { - name: string; - type: string; - workflowId?: string; - stepId?: string; - criteria?: Criterion[]; -}; - -type SourceDescription = { - name: string; - url: string; - type?: string; -}; - -type CriterionExpressionType = { - type: 'jsonpath' | 'xpath'; - version: 'draft-goessner-dispatch-jsonpath-00' | 'xpath-30' | 'xpath-20' | 'xpath-10'; -}; - -type Criterion = { - context?: string; - condition: string; - type?: 'simple' | 'regex' | 'jsonpath' | 'xpath' | CriterionExpressionType; -}; - -type ReusableObject = { - reference: string; -}; - -type Step = { - stepId: string; - onSuccess?: (SuccessAction | ReusableObject)[]; -}; - -type Workflow = { - workflowId: string; - steps: Step[]; - successActions?: (SuccessAction | ReusableObject)[]; -}; - -type ArazzoSpecification = { - workflows: Workflow[]; - sourceDescriptions?: SourceDescription[]; - components?: { successActions?: Record }; -}; +import { ArazzoSpecification } from '../types/arazzoTypes'; const runRule = (target: ArazzoSpecification, _contextOverrides: Partial = {}) => { return arazzoStepSuccessActionsValidation(target, null); diff --git a/packages/rulesets/src/arazzo/functions/__tests__/arazzoStepSuccessCriteriaValidation.test.ts b/packages/rulesets/src/arazzo/functions/__tests__/arazzoStepSuccessCriteriaValidation.test.ts index 316a5b6d2..b2c724cc6 100644 --- a/packages/rulesets/src/arazzo/functions/__tests__/arazzoStepSuccessCriteriaValidation.test.ts +++ b/packages/rulesets/src/arazzo/functions/__tests__/arazzoStepSuccessCriteriaValidation.test.ts @@ -1,31 +1,6 @@ import arazzoStepSuccessCriteriaValidation from '../arazzoStepSuccessCriteriaValidation'; import type { RulesetFunctionContext } from '@stoplight/spectral-core'; - -type CriterionExpressionType = { - type: 'jsonpath' | 'xpath'; - version: 'draft-goessner-dispatch-jsonpath-00' | 'xpath-30' | 'xpath-20' | 'xpath-10'; -}; - -type Criterion = { - context?: string; - condition: string; - type?: 'simple' | 'regex' | 'jsonpath' | 'xpath' | CriterionExpressionType; -}; - -type Step = { - stepId: string; - successCriteria?: Criterion[]; -}; - -type Workflow = { - workflowId: string; - steps: Step[]; -}; - -type ArazzoSpecification = { - workflows: Workflow[]; - components?: object; -}; +import { ArazzoSpecification } from '../types/arazzoTypes'; const runRule = (target: ArazzoSpecification, _contextOverrides: Partial = {}) => { return arazzoStepSuccessCriteriaValidation(target, null); diff --git a/packages/rulesets/src/arazzo/functions/__tests__/arazzoStepValidation.test.ts b/packages/rulesets/src/arazzo/functions/__tests__/arazzoStepValidation.test.ts index 1fcf1876e..90e8b025f 100644 --- a/packages/rulesets/src/arazzo/functions/__tests__/arazzoStepValidation.test.ts +++ b/packages/rulesets/src/arazzo/functions/__tests__/arazzoStepValidation.test.ts @@ -1,77 +1,6 @@ import arazzoStepValidation from '../arazzoStepValidation'; import type { IFunctionResult } from '@stoplight/spectral-core'; - -type SourceDescription = { - name: string; - url: string; - type?: string; -}; - -type ArazzoSpecification = { - workflows: Workflow[]; - sourceDescriptions?: SourceDescription[]; - components?: { - parameters?: Record; - successActions?: Record; - failureActions?: Record; - [key: string]: unknown; - }; -}; - -type Parameter = { - name: string; - in?: string; - value?: unknown; -}; - -type Workflow = { - workflowId: string; - steps: Step[]; - successActions?: (SuccessAction | ReusableObject)[]; - failureActions?: (FailureAction | ReusableObject)[]; - outputs?: Record; -}; - -type Step = { - stepId: string; - operationId?: string; - operationPath?: string; - workflowId?: string; - outputs?: Record; - onSuccess?: (SuccessAction | ReusableObject)[]; - onFailure?: (FailureAction | ReusableObject)[]; -}; - -type SuccessAction = { - name: string; - type: string; - workflowId?: string; - stepId?: string; - criteria?: Criterion[]; -}; - -type FailureAction = { - name: string; - type: string; - workflowId?: string; - stepId?: string; - criteria?: Criterion[]; -}; - -type Criterion = { - context?: string; - condition: string; - type?: 'simple' | 'regex' | 'jsonpath' | 'xpath' | CriterionExpressionType; -}; - -type CriterionExpressionType = { - type: 'jsonpath' | 'xpath'; - version: string; -}; - -type ReusableObject = { - reference: string; -}; +import { ArazzoSpecification } from '../types/arazzoTypes'; const runRule = (target: ArazzoSpecification): IFunctionResult[] => { return arazzoStepValidation(target, null); diff --git a/packages/rulesets/src/arazzo/functions/__tests__/arazzoWorkflowIdUniqueness.test.ts b/packages/rulesets/src/arazzo/functions/__tests__/arazzoWorkflowIdUniqueness.test.ts index 41d51d97f..08888ddac 100644 --- a/packages/rulesets/src/arazzo/functions/__tests__/arazzoWorkflowIdUniqueness.test.ts +++ b/packages/rulesets/src/arazzo/functions/__tests__/arazzoWorkflowIdUniqueness.test.ts @@ -1,21 +1,9 @@ -import { DeepPartial } from '@stoplight/types'; +import { IFunctionResult } from '@stoplight/spectral-core'; import arazzoWorkflowIdUniqueness from '../arazzoWorkflowIdUniqueness'; -import type { RulesetFunctionContext } from '@stoplight/spectral-core'; +import { ArazzoSpecification } from '../types/arazzoTypes'; -const runRule = (target: { workflows: Record[] }) => { - const context: DeepPartial = { - path: [], - documentInventory: { - graph: {} as any, // Mock the graph property - referencedDocuments: {}, // Mock the referencedDocuments property as a Dictionary - findAssociatedItemForPath: jest.fn(), // Mock the findAssociatedItemForPath function - }, - document: { - formats: new Set(), // Mock the formats property correctly - }, - }; - - return arazzoWorkflowIdUniqueness(target, null, context as RulesetFunctionContext); +const runRule = (target: ArazzoSpecification): IFunctionResult[] => { + return arazzoWorkflowIdUniqueness(target, null); }; describe('arazzoWorkflowIdUniqueness', () => { diff --git a/packages/rulesets/src/arazzo/functions/__tests__/arazzoWorkflowOutputNamesValidation.test.ts b/packages/rulesets/src/arazzo/functions/__tests__/arazzoWorkflowOutputNamesValidation.test.ts index 3a119d8fd..2dfae2e38 100644 --- a/packages/rulesets/src/arazzo/functions/__tests__/arazzoWorkflowOutputNamesValidation.test.ts +++ b/packages/rulesets/src/arazzo/functions/__tests__/arazzoWorkflowOutputNamesValidation.test.ts @@ -1,64 +1,7 @@ import arazzoWorkflowOutputNamesValidation from '../arazzoWorkflowOutputNamesValidation'; import { DeepPartial } from '@stoplight/types'; import type { RulesetFunctionContext } from '@stoplight/spectral-core'; - -type ArazzoSpecification = { - workflows: Workflow[]; - sourceDescriptions?: SourceDescription[]; - components?: { - successActions?: Record; - failureActions?: Record; - [key: string]: unknown; - }; -}; - -type SourceDescription = { - name: string; - url: string; - type?: string; -}; - -type SuccessAction = { - name: string; - type: string; - workflowId?: string; - stepId?: string; - criteria?: Criterion[]; -}; - -type FailureAction = { - name: string; - type: string; - workflowId?: string; - stepId?: string; - criteria?: Criterion[]; -}; - -type Workflow = { - workflowId: string; - steps: Step[]; - outputs?: { [key: string]: string }; -}; - -type Step = { - stepId: string; - operationId?: string; - workflowId?: string; - operationPath?: string; - parameters?: Record; - outputs?: { [key: string]: string }; -}; - -type Criterion = { - context?: string; - condition: string; - type?: 'simple' | 'regex' | 'jsonpath' | 'xpath' | CriterionExpressionType; -}; - -type CriterionExpressionType = { - type: 'jsonpath' | 'xpath'; - version: string; -}; +import { ArazzoSpecification } from '../types/arazzoTypes'; const runRule = (target: ArazzoSpecification, contextOverrides: Partial = {}) => { const context: DeepPartial = { diff --git a/packages/rulesets/src/arazzo/functions/__tests__/arazzoWorkflowsDependsOnValidation.test.ts b/packages/rulesets/src/arazzo/functions/__tests__/arazzoWorkflowsDependsOnValidation.test.ts index 7c06407c0..e1d88757c 100644 --- a/packages/rulesets/src/arazzo/functions/__tests__/arazzoWorkflowsDependsOnValidation.test.ts +++ b/packages/rulesets/src/arazzo/functions/__tests__/arazzoWorkflowsDependsOnValidation.test.ts @@ -1,66 +1,7 @@ import arazzoWorkflowDependsOnValidation from '../arazzoWorkflowDependsOnValidation'; import { IFunctionResult } from '@stoplight/spectral-core'; +import { ArazzoSpecification } from '../types/arazzoTypes'; -type SourceDescription = { - name: string; - url: string; - type?: string; -}; - -type Workflow = { - workflowId: string; - steps: Step[]; - dependsOn?: string[]; -}; - -type Step = { - stepId: string; - outputs?: { [key: string]: string }; -}; - -type Parameter = { - name: string; - in?: string; - value?: unknown; -}; - -type ArazzoSpecification = { - sourceDescriptions?: SourceDescription[]; - workflows: Workflow[]; - components?: { - parameters?: Record; - successActions?: Record; - failureActions?: Record; - [key: string]: unknown; - }; -}; - -type SuccessAction = { - name: string; - type: string; - workflowId?: string; - stepId?: string; - criteria?: Criterion[]; -}; - -type FailureAction = { - name: string; - type: string; - workflowId?: string; - stepId?: string; - criteria?: Criterion[]; -}; - -type Criterion = { - context?: string; - condition: string; - type?: 'simple' | 'regex' | 'jsonpath' | 'xpath' | CriterionExpressionType; -}; - -type CriterionExpressionType = { - type: 'jsonpath' | 'xpath'; - version: string; -}; const runRule = (target: ArazzoSpecification): IFunctionResult[] => { return arazzoWorkflowDependsOnValidation(target, null); }; diff --git a/packages/rulesets/src/arazzo/functions/arazzoCriterionValidation.ts b/packages/rulesets/src/arazzo/functions/arazzoCriterionValidation.ts index fa365e470..1debce61e 100644 --- a/packages/rulesets/src/arazzo/functions/arazzoCriterionValidation.ts +++ b/packages/rulesets/src/arazzo/functions/arazzoCriterionValidation.ts @@ -1,32 +1,6 @@ import { IFunctionResult } from '@stoplight/spectral-core'; import validateRuntimeExpression from './arazzoRuntimeExpressionValidation'; - -type CriterionExpressionType = { - type: 'jsonpath' | 'xpath'; - version: 'draft-goessner-dispatch-jsonpath-00' | 'xpath-30' | 'xpath-20' | 'xpath-10'; -}; - -type Criterion = { - context?: string; - condition: string; - type?: 'simple' | 'regex' | 'jsonpath' | 'xpath' | CriterionExpressionType; -}; - -type Step = { - stepId: string; - outputs?: { [key: string]: string }; -}; - -type Workflow = { - workflowId: string; - steps: Step[]; - outputs?: { [key: string]: string }; -}; - -type ArazzoSpecification = { - workflows: Workflow[]; - components?: { [key: string]: any }; -}; +import { Criterion, ArazzoSpecification } from './types/arazzoTypes'; export default function arazzoCriterionValidation( criterion: Criterion, diff --git a/packages/rulesets/src/arazzo/functions/arazzoRuntimeExpressionValidation.ts b/packages/rulesets/src/arazzo/functions/arazzoRuntimeExpressionValidation.ts index 8b8053962..e8e014e25 100644 --- a/packages/rulesets/src/arazzo/functions/arazzoRuntimeExpressionValidation.ts +++ b/packages/rulesets/src/arazzo/functions/arazzoRuntimeExpressionValidation.ts @@ -1,74 +1,4 @@ -type ArazzoSpecification = { - workflows: Workflow[]; - sourceDescriptions?: SourceDescription[]; - components?: { - parameters?: Record; - successActions?: Record; - failureActions?: Record; - [key: string]: unknown; - }; -}; - -type SourceDescription = { - name: string; - url: string; - type?: string; -}; - -type Workflow = { - workflowId: string; - steps: Step[]; - inputs?: Record; - parameters?: (Parameter | ReusableObject)[]; - successActions?: (SuccessAction | ReusableObject)[]; - failureActions?: (FailureAction | ReusableObject)[]; - outputs?: Record; -}; - -type Parameter = { - name: string; - in?: string; - value?: unknown; -}; - -type Step = { - stepId: string; - outputs?: Record; - parameters?: (Parameter | ReusableObject)[]; - onSuccess?: (SuccessAction | ReusableObject)[]; - onFailure?: (FailureAction | ReusableObject)[]; -}; - -type SuccessAction = { - name: string; - type: string; - workflowId?: string; - stepId?: string; - criteria?: Criterion[]; -}; - -type FailureAction = { - name: string; - type: string; - workflowId?: string; - stepId?: string; - criteria?: Criterion[]; -}; - -type Criterion = { - context?: string; - condition: string; - type?: 'simple' | 'regex' | 'jsonpath' | 'xpath' | CriterionExpressionType; -}; - -type CriterionExpressionType = { - type: 'jsonpath' | 'xpath'; - version: string; -}; - -type ReusableObject = { - reference: string; -}; +import { ArazzoSpecification, Step } from './types/arazzoTypes'; function isNonNullObject(value: unknown): value is Record { return value !== null && typeof value === 'object'; diff --git a/packages/rulesets/src/arazzo/functions/arazzoStepFailureActionsValidation.ts b/packages/rulesets/src/arazzo/functions/arazzoStepFailureActionsValidation.ts index 29a296abc..2e14caf46 100644 --- a/packages/rulesets/src/arazzo/functions/arazzoStepFailureActionsValidation.ts +++ b/packages/rulesets/src/arazzo/functions/arazzoStepFailureActionsValidation.ts @@ -2,57 +2,7 @@ import type { IFunctionResult } from '@stoplight/spectral-core'; import getAllFailureActions from './utils/getAllFailureActions'; import arazzoCriterionValidation from './arazzoCriterionValidation'; import arazzoRuntimeExpressionValidation from './arazzoRuntimeExpressionValidation'; - -type CriterionExpressionType = { - type: 'jsonpath' | 'xpath'; - version: 'draft-goessner-dispatch-jsonpath-00' | 'xpath-30' | 'xpath-20' | 'xpath-10'; -}; - -type Criterion = { - context?: string; - condition: string; - type?: 'simple' | 'regex' | 'jsonpath' | 'xpath' | CriterionExpressionType; -}; - -type FailureAction = { - name: string; - type: string; - workflowId?: string; - stepId?: string; - retryAfter?: number; - retryLimit?: number; - criteria?: Criterion[]; -}; - -type ReusableObject = { - reference: string; -}; - -type Step = { - stepId: string; - onFailure?: (FailureAction | ReusableObject)[]; - workflowId?: string; - operationId?: string; - operationPath?: string; -}; - -type SourceDescription = { - name: string; - url: string; - type?: string; -}; - -type Workflow = { - workflowId: string; - steps: Step[]; - failureActions?: (FailureAction | ReusableObject)[]; -}; - -type ArazzoSpecification = { - sourceDescriptions?: SourceDescription[]; - workflows: Workflow[]; - components?: { failureActions?: Record }; -}; +import { ArazzoSpecification } from './types/arazzoTypes'; export default function arazzoStepFailureActionsValidation( target: ArazzoSpecification, diff --git a/packages/rulesets/src/arazzo/functions/arazzoStepOutputNamesValidation.ts b/packages/rulesets/src/arazzo/functions/arazzoStepOutputNamesValidation.ts index 9be07d2fb..6fef6615d 100644 --- a/packages/rulesets/src/arazzo/functions/arazzoStepOutputNamesValidation.ts +++ b/packages/rulesets/src/arazzo/functions/arazzoStepOutputNamesValidation.ts @@ -1,69 +1,10 @@ import { createRulesetFunction, IFunctionResult } from '@stoplight/spectral-core'; import type { JsonPath } from '@stoplight/types'; import arazzoRuntimeExpressionValidation from './arazzoRuntimeExpressionValidation'; +import { ArazzoSpecification } from './types/arazzoTypes'; const OUTPUT_NAME_PATTERN = /^[a-zA-Z0-9.\-_]+$/; -type ArazzoSpecification = { - workflows: Workflow[]; - sourceDescriptions?: SourceDescription[]; - components?: { - parameters?: Record; - successActions?: Record; - failureActions?: Record; - [key: string]: unknown; - }; -}; - -type SourceDescription = { - name: string; - url: string; - type?: string; -}; - -type Parameter = { - name: string; - in?: string; - value?: unknown; -}; - -type SuccessAction = { - name: string; - type: string; - workflowId?: string; - stepId?: string; - criteria?: Criterion[]; -}; - -type FailureAction = { - name: string; - type: string; - workflowId?: string; - stepId?: string; - criteria?: Criterion[]; -}; -type Workflow = { - workflowId: string; - steps: Step[]; - outputs?: Record; -}; - -type Step = { - stepId: string; - outputs?: Record; -}; - -type Criterion = { - context?: string; - condition: string; - type?: 'simple' | 'regex' | 'jsonpath' | 'xpath' | CriterionExpressionType; -}; - -type CriterionExpressionType = { - type: 'jsonpath' | 'xpath'; - version: string; -}; - export default createRulesetFunction( { input: { diff --git a/packages/rulesets/src/arazzo/functions/arazzoStepParametersValidation.ts b/packages/rulesets/src/arazzo/functions/arazzoStepParametersValidation.ts index c6a223841..c55be5e3d 100644 --- a/packages/rulesets/src/arazzo/functions/arazzoStepParametersValidation.ts +++ b/packages/rulesets/src/arazzo/functions/arazzoStepParametersValidation.ts @@ -1,42 +1,7 @@ import type { IFunctionResult } from '@stoplight/spectral-core'; import getAllParameters from './utils/getAllParameters'; import arazzoRuntimeExpressionValidation from './arazzoRuntimeExpressionValidation'; - -type Parameter = { - name: string; - in?: string; - value?: unknown; -}; - -type ReusableObject = { - reference: string; -}; - -type Step = { - stepId: string; - parameters?: (Parameter | ReusableObject)[]; - workflowId?: string; - operationId?: string; - operationPath?: string; -}; - -type SourceDescription = { - name: string; - url: string; - type?: string; -}; - -type Workflow = { - workflowId: string; - steps: Step[]; - parameters?: (Parameter | ReusableObject)[]; -}; - -type ArazzoSpecification = { - sourceDescriptions?: SourceDescription[]; - workflows: Workflow[]; - components?: { parameters?: Record }; -}; +import { ArazzoSpecification } from './types/arazzoTypes'; export default function arazzoStepParametersValidation(target: ArazzoSpecification, _options: null): IFunctionResult[] { const results: IFunctionResult[] = []; diff --git a/packages/rulesets/src/arazzo/functions/arazzoStepRequestBodyValidation.ts b/packages/rulesets/src/arazzo/functions/arazzoStepRequestBodyValidation.ts index 38474eb85..64879aa76 100644 --- a/packages/rulesets/src/arazzo/functions/arazzoStepRequestBodyValidation.ts +++ b/packages/rulesets/src/arazzo/functions/arazzoStepRequestBodyValidation.ts @@ -1,56 +1,6 @@ import { IFunctionResult } from '@stoplight/spectral-core'; import arazzoRuntimeExpressionValidation from './arazzoRuntimeExpressionValidation'; - -type PayloadReplacement = { - target: string; - value: unknown | string; -}; - -type RequestBody = { - contentType?: string; - payload?: unknown | string; - replacements?: PayloadReplacement[]; -}; - -type Parameter = { - name: string; - in?: string; - value?: unknown; -}; - -type Step = { - stepId: string; - outputs?: Record; - requestBody?: RequestBody; - parameters?: (Parameter | ReusableObject)[]; -}; - -type ArazzoSpecification = { - workflows: Workflow[]; - sourceDescriptions?: SourceDescription[]; - components?: { - parameters?: Record; - [key: string]: unknown; - }; -}; - -type ReusableObject = { - reference: string; -}; - -type SourceDescription = { - name: string; - url: string; - type?: string; -}; - -type Workflow = { - workflowId: string; - steps: Step[]; - inputs?: Record; - parameters?: (Parameter | ReusableObject)[]; - outputs?: Record; -}; +import { ArazzoSpecification } from './types/arazzoTypes'; const MIME_TYPE_REGEX = /^(application|audio|font|example|image|message|model|multipart|text|video)\/[a-zA-Z0-9!#$&^_.+-]{1,127}$/; diff --git a/packages/rulesets/src/arazzo/functions/arazzoStepSuccessActionsValidation.ts b/packages/rulesets/src/arazzo/functions/arazzoStepSuccessActionsValidation.ts index f82dbd519..f2c074a57 100644 --- a/packages/rulesets/src/arazzo/functions/arazzoStepSuccessActionsValidation.ts +++ b/packages/rulesets/src/arazzo/functions/arazzoStepSuccessActionsValidation.ts @@ -2,55 +2,7 @@ import type { IFunctionResult } from '@stoplight/spectral-core'; import getAllSuccessActions from './utils/getAllSuccessActions'; import arazzoCriterionValidation from './arazzoCriterionValidation'; import arazzoRuntimeExpressionValidation from './arazzoRuntimeExpressionValidation'; - -type CriterionExpressionType = { - type: 'jsonpath' | 'xpath'; - version: 'draft-goessner-dispatch-jsonpath-00' | 'xpath-30' | 'xpath-20' | 'xpath-10'; -}; - -type Criterion = { - context?: string; - condition: string; - type?: 'simple' | 'regex' | 'jsonpath' | 'xpath' | CriterionExpressionType; -}; - -type SuccessAction = { - name: string; - type: string; - workflowId?: string; - stepId?: string; - criteria?: Criterion[]; -}; - -type ReusableObject = { - reference: string; -}; - -type Step = { - stepId: string; - onSuccess?: (SuccessAction | ReusableObject)[]; - workflowId?: string; - operationId?: string; - operationPath?: string; -}; - -type Workflow = { - workflowId: string; - steps: Step[]; - successActions?: (SuccessAction | ReusableObject)[]; -}; - -type SourceDescription = { - name: string; - url: string; - type?: string; -}; - -type ArazzoSpecification = { - sourceDescriptions?: SourceDescription[]; - workflows: Workflow[]; - components?: { successActions?: Record }; -}; +import { ArazzoSpecification } from './types/arazzoTypes'; export default function arazzoStepSuccessActionsValidation( target: ArazzoSpecification, diff --git a/packages/rulesets/src/arazzo/functions/arazzoStepSuccessCriteriaValidation.ts b/packages/rulesets/src/arazzo/functions/arazzoStepSuccessCriteriaValidation.ts index a1359af68..513a3043b 100644 --- a/packages/rulesets/src/arazzo/functions/arazzoStepSuccessCriteriaValidation.ts +++ b/packages/rulesets/src/arazzo/functions/arazzoStepSuccessCriteriaValidation.ts @@ -1,31 +1,6 @@ import { IFunctionResult } from '@stoplight/spectral-core'; import arazzoCriterionValidation from './arazzoCriterionValidation'; - -type CriterionExpressionType = { - type: 'jsonpath' | 'xpath'; - version: 'draft-goessner-dispatch-jsonpath-00' | 'xpath-30' | 'xpath-20' | 'xpath-10'; -}; - -type Criterion = { - context?: string; - condition: string; - type?: 'simple' | 'regex' | 'jsonpath' | 'xpath' | CriterionExpressionType; -}; - -type Step = { - stepId: string; - successCriteria?: Criterion[]; -}; - -type Workflow = { - workflowId: string; - steps: Step[]; -}; - -type ArazzoSpecification = { - workflows: Workflow[]; - components?: object; -}; +import { ArazzoSpecification } from './types/arazzoTypes'; export default function arazzoStepSuccessCriteriaValidation( targetVal: ArazzoSpecification, diff --git a/packages/rulesets/src/arazzo/functions/arazzoStepValidation.ts b/packages/rulesets/src/arazzo/functions/arazzoStepValidation.ts index a30378225..466e261b8 100644 --- a/packages/rulesets/src/arazzo/functions/arazzoStepValidation.ts +++ b/packages/rulesets/src/arazzo/functions/arazzoStepValidation.ts @@ -1,79 +1,6 @@ import type { IFunctionResult } from '@stoplight/spectral-core'; import arazzoRuntimeExpressionValidation from './arazzoRuntimeExpressionValidation'; - -type SourceDescription = { - name: string; - url: string; - type?: string; -}; - -type ArazzoSpecification = { - workflows: Workflow[]; - sourceDescriptions?: SourceDescription[]; - components?: { - parameters?: Record; - successActions?: Record; - failureActions?: Record; - [key: string]: unknown; - }; -}; - -type Workflow = { - workflowId: string; - steps: Step[]; - parameters?: (Parameter | ReusableObject)[]; - successActions?: (SuccessAction | ReusableObject)[]; - failureActions?: (FailureAction | ReusableObject)[]; - outputs?: Record; -}; - -type Step = { - stepId: string; - operationId?: string; - operationPath?: string; - workflowId?: string; - outputs?: Record; - parameters?: (Parameter | ReusableObject)[]; - onSuccess?: (SuccessAction | ReusableObject)[]; - onFailure?: (FailureAction | ReusableObject)[]; -}; - -type Parameter = { - name: string; - in?: string; - value?: unknown; -}; - -type SuccessAction = { - name: string; - type: string; - workflowId?: string; - stepId?: string; - criteria?: Criterion[]; -}; - -type FailureAction = { - name: string; - type: string; - workflowId?: string; - stepId?: string; - criteria?: Criterion[]; -}; - -type Criterion = { - context?: string; - condition: string; - type?: 'simple' | 'regex' | 'jsonpath' | 'xpath' | CriterionExpressionType; -}; - -type CriterionExpressionType = { - type: 'jsonpath' | 'xpath'; - version: string; -}; - -type ReusableObject = { - reference: string; -}; +import { ArazzoSpecification } from './types/arazzoTypes'; const OPERATION_PATH_REGEX = /^\{\$sourceDescriptions\.[a-zA-Z0-9_-]+\.(url)\}#.+$/; diff --git a/packages/rulesets/src/arazzo/functions/arazzoWorkflowDependsOnValidation.ts b/packages/rulesets/src/arazzo/functions/arazzoWorkflowDependsOnValidation.ts index eb1aea05b..d3cee8b65 100644 --- a/packages/rulesets/src/arazzo/functions/arazzoWorkflowDependsOnValidation.ts +++ b/packages/rulesets/src/arazzo/functions/arazzoWorkflowDependsOnValidation.ts @@ -1,67 +1,7 @@ import { IFunctionResult } from '@stoplight/spectral-core'; import { getAllWorkflows } from './utils/getAllWorkflows'; import arazzoRuntimeExpressionValidation from './arazzoRuntimeExpressionValidation'; - -type SourceDescription = { - name: string; - url: string; - type?: string; -}; - -type Workflow = { - workflowId: string; - steps: Step[]; - dependsOn?: string[]; -}; - -type Step = { - stepId: string; - outputs?: { [key: string]: string }; -}; - -type Parameter = { - name: string; - in?: string; - value?: unknown; -}; - -type ArazzoSpecification = { - workflows: Workflow[]; - sourceDescriptions?: SourceDescription[]; - components?: { - parameters?: Record; - successActions?: Record; - failureActions?: Record; - [key: string]: unknown; - }; -}; - -type SuccessAction = { - name: string; - type: string; - workflowId?: string; - stepId?: string; - criteria?: Criterion[]; -}; - -type FailureAction = { - name: string; - type: string; - workflowId?: string; - stepId?: string; - criteria?: Criterion[]; -}; - -type Criterion = { - context?: string; - condition: string; - type?: 'simple' | 'regex' | 'jsonpath' | 'xpath' | CriterionExpressionType; -}; - -type CriterionExpressionType = { - type: 'jsonpath' | 'xpath'; - version: string; -}; +import { ArazzoSpecification } from './types/arazzoTypes'; export default function arazzoWorkflowDependsOnValidation( targetVal: ArazzoSpecification, diff --git a/packages/rulesets/src/arazzo/functions/arazzoWorkflowIdUniqueness.ts b/packages/rulesets/src/arazzo/functions/arazzoWorkflowIdUniqueness.ts index 9e85e1de1..95347aa1a 100644 --- a/packages/rulesets/src/arazzo/functions/arazzoWorkflowIdUniqueness.ts +++ b/packages/rulesets/src/arazzo/functions/arazzoWorkflowIdUniqueness.ts @@ -1,43 +1,23 @@ -import { createRulesetFunction, IFunctionResult } from '@stoplight/spectral-core'; +import { IFunctionResult } from '@stoplight/spectral-core'; import { getAllWorkflows } from './utils/getAllWorkflows'; +import { ArazzoSpecification } from './types/arazzoTypes'; -export default createRulesetFunction<{ workflows: Record[] }, null>( - { - input: { - type: 'object', - properties: { - workflows: { - type: 'array', - items: { - type: 'object', - properties: { - workflowId: { - type: 'string', - }, - }, - }, - }, - }, - }, - options: null, - }, - function arazzoWorkflowIdUniqueness(targetVal, _) { - const results: IFunctionResult[] = []; - const workflows = getAllWorkflows(targetVal); +export default function arazzoWorkflowIdUniqueness(targetVal: ArazzoSpecification, _options: null): IFunctionResult[] { + const results: IFunctionResult[] = []; + const workflows = getAllWorkflows(targetVal); - const seenIds: Set = new Set(); - for (const { path, workflow } of workflows) { - const workflowId = workflow.workflowId as string; - if (seenIds.has(workflowId)) { - results.push({ - message: `"workflowId" must be unique across all workflows.`, - path: [...path, 'workflowId'], - }); - } else { - seenIds.add(workflowId); - } + const seenIds: Set = new Set(); + for (const { path, workflow } of workflows) { + const workflowId = workflow.workflowId; + if (seenIds.has(workflowId)) { + results.push({ + message: `"workflowId" must be unique across all workflows.`, + path: [...path, 'workflowId'], + }); + } else { + seenIds.add(workflowId); } + } - return results; - }, -); + return results; +} diff --git a/packages/rulesets/src/arazzo/functions/arazzoWorkflowOutputNamesValidation.ts b/packages/rulesets/src/arazzo/functions/arazzoWorkflowOutputNamesValidation.ts index 22a7bbe2a..658f2ac86 100644 --- a/packages/rulesets/src/arazzo/functions/arazzoWorkflowOutputNamesValidation.ts +++ b/packages/rulesets/src/arazzo/functions/arazzoWorkflowOutputNamesValidation.ts @@ -1,70 +1,10 @@ import { createRulesetFunction, IFunctionResult } from '@stoplight/spectral-core'; import type { JsonPath } from '@stoplight/types'; import arazzoRuntimeExpressionValidation from './arazzoRuntimeExpressionValidation'; +import { ArazzoSpecification } from './types/arazzoTypes'; const OUTPUT_NAME_PATTERN = /^[a-zA-Z0-9.\-_]+$/; -type ArazzoSpecification = { - workflows: Workflow[]; - sourceDescriptions?: SourceDescription[]; - components?: { - parameters?: Record; - successActions?: Record; - failureActions?: Record; - [key: string]: unknown; - }; -}; - -type SourceDescription = { - name: string; - url: string; - type?: string; -}; - -type Parameter = { - name: string; - in?: string; - value?: unknown; -}; - -type SuccessAction = { - name: string; - type: string; - workflowId?: string; - stepId?: string; - criteria?: Criterion[]; -}; - -type FailureAction = { - name: string; - type: string; - workflowId?: string; - stepId?: string; - criteria?: Criterion[]; -}; - -type Workflow = { - workflowId: string; - steps: Step[]; - outputs?: { [key: string]: string }; -}; - -type Step = { - stepId: string; - outputs?: { [key: string]: string }; -}; - -type Criterion = { - context?: string; - condition: string; - type?: 'simple' | 'regex' | 'jsonpath' | 'xpath' | CriterionExpressionType; -}; - -type CriterionExpressionType = { - type: 'jsonpath' | 'xpath'; - version: string; -}; - export default createRulesetFunction( { input: { diff --git a/packages/rulesets/src/arazzo/functions/types/arazzoTypes.ts b/packages/rulesets/src/arazzo/functions/types/arazzoTypes.ts new file mode 100644 index 000000000..16774b77a --- /dev/null +++ b/packages/rulesets/src/arazzo/functions/types/arazzoTypes.ts @@ -0,0 +1,92 @@ +export type CriterionExpressionType = { + type: 'jsonpath' | 'xpath'; + version: 'draft-goessner-dispatch-jsonpath-00' | 'xpath-30' | 'xpath-20' | 'xpath-10'; +}; + +export type Criterion = { + context?: string; + condition: string; + type?: 'simple' | 'regex' | 'jsonpath' | 'xpath' | CriterionExpressionType; +}; + +export type Parameter = { + name: string; + in?: string; + value?: unknown; +}; + +export type FailureAction = { + name: string; + type: string; + workflowId?: string; + stepId?: string; + retryAfter?: number; + retryLimit?: number; + criteria?: Criterion[]; +}; + +export type SuccessAction = { + name: string; + type: string; + workflowId?: string; + stepId?: string; + criteria?: Criterion[]; +}; + +export type ReusableObject = { + reference: string; + value?: unknown; +}; + +export type PayloadReplacement = { + target: string; + value: unknown | string; +}; + +export type RequestBody = { + contentType?: string; + payload?: unknown | string; + replacements?: PayloadReplacement[]; +}; + +export type Step = { + stepId: string; + onFailure?: (FailureAction | ReusableObject)[]; + onSuccess?: (SuccessAction | ReusableObject)[]; + parameters?: (Parameter | ReusableObject)[]; + successCriteria?: Criterion[]; + requestBody?: RequestBody; + outputs?: { [key: string]: string }; + workflowId?: string; + operationId?: string; + operationPath?: string; +}; + +export type SourceDescription = { + name: string; + url: string; + type?: 'arazzo' | 'openapi'; +}; + +export type Workflow = { + workflowId: string; + steps: Step[]; + inputs?: Record; + parameters?: (Parameter | ReusableObject)[]; + successActions?: (SuccessAction | ReusableObject)[]; + failureActions?: (FailureAction | ReusableObject)[]; + dependsOn?: string[]; + outputs?: { [key: string]: string }; +}; + +export type ArazzoSpecification = { + workflows: Workflow[]; + sourceDescriptions?: SourceDescription[]; + components?: { + inputs?: Record; + parameters?: Record; + successActions?: Record; + failureActions?: Record; + [key: string]: unknown; + }; +}; diff --git a/packages/rulesets/src/arazzo/functions/utils/getAllFailureActions.ts b/packages/rulesets/src/arazzo/functions/utils/getAllFailureActions.ts index 73b4743eb..0bdda3391 100644 --- a/packages/rulesets/src/arazzo/functions/utils/getAllFailureActions.ts +++ b/packages/rulesets/src/arazzo/functions/utils/getAllFailureActions.ts @@ -1,65 +1,6 @@ import { isPlainObject } from '@stoplight/json'; import arazzoRuntimeExpressionValidation from '../arazzoRuntimeExpressionValidation'; - -type ArazzoSpecification = { - workflows: Workflow[]; - sourceDescriptions?: SourceDescription[]; - components?: { - parameters?: Record; - successActions?: Record; - failureActions?: Record; - [key: string]: unknown; - }; -}; - -type Parameter = { - name: string; - in?: string; - value?: unknown; -}; - -type SourceDescription = { - name: string; - url: string; - type?: string; -}; - -type FailureAction = { - name: string; - type: string; - workflowId?: string; - stepId?: string; - retryAfter?: number; - retryLimit?: number; - criteria?: Criterion[]; -}; - -type SuccessAction = { - name: string; - type: string; - workflowId?: string; - stepId?: string; - criteria?: Criterion[]; -}; - -type Criterion = { - condition: string; -}; - -type ReusableObject = { - reference: string; -}; - -type Step = { - stepId: string; - onFailure?: (FailureAction | ReusableObject)[]; -}; - -type Workflow = { - workflowId: string; - steps: Step[]; - failureActions?: (FailureAction | ReusableObject)[]; -}; +import { ArazzoSpecification, Workflow, Step, ReusableObject, FailureAction } from '../types/arazzoTypes'; function isFailureAction(action: unknown): action is FailureAction { return typeof action === 'object' && action !== null && 'name' in action && 'type' in action; diff --git a/packages/rulesets/src/arazzo/functions/utils/getAllParameters.ts b/packages/rulesets/src/arazzo/functions/utils/getAllParameters.ts index 4c7875db3..bc49089cb 100644 --- a/packages/rulesets/src/arazzo/functions/utils/getAllParameters.ts +++ b/packages/rulesets/src/arazzo/functions/utils/getAllParameters.ts @@ -1,67 +1,6 @@ import { isPlainObject } from '@stoplight/json'; import arazzoRuntimeExpressionValidation from '../arazzoRuntimeExpressionValidation'; - -type Parameter = { - name: string; - in?: string; - value?: unknown; -}; - -type Workflow = { - workflowId: string; - steps: Step[]; - parameters?: (Parameter | ReusableObject)[]; - components?: { parameters?: Record }; -}; - -type ArazzoSpecification = { - workflows: Workflow[]; - sourceDescriptions?: SourceDescription[]; - components?: { - parameters?: Record; - successActions?: Record; - failureActions?: Record; - [key: string]: unknown; - }; -}; - -type SourceDescription = { - name: string; - url: string; - type?: string; -}; - -type FailureAction = { - name: string; - type: string; - workflowId?: string; - stepId?: string; - retryAfter?: number; - retryLimit?: number; - criteria?: Criterion[]; -}; - -type SuccessAction = { - name: string; - type: string; - workflowId?: string; - stepId?: string; - criteria?: Criterion[]; -}; - -type Criterion = { - condition: string; -}; - -type ReusableObject = { - reference: string; -}; - -type Step = { - stepId: string; - parameters?: (Parameter | ReusableObject)[]; - onFailure?: (FailureAction | ReusableObject)[]; -}; +import { ArazzoSpecification, Workflow, Step, ReusableObject, Parameter } from '../types/arazzoTypes'; const resolveReusableParameter = ( reusableObject: ReusableObject, diff --git a/packages/rulesets/src/arazzo/functions/utils/getAllSuccessActions.ts b/packages/rulesets/src/arazzo/functions/utils/getAllSuccessActions.ts index ad726a13e..dd9d745d8 100644 --- a/packages/rulesets/src/arazzo/functions/utils/getAllSuccessActions.ts +++ b/packages/rulesets/src/arazzo/functions/utils/getAllSuccessActions.ts @@ -1,65 +1,6 @@ import { isPlainObject } from '@stoplight/json'; import arazzoRuntimeExpressionValidation from '../arazzoRuntimeExpressionValidation'; - -type ArazzoSpecification = { - workflows: Workflow[]; - sourceDescriptions?: SourceDescription[]; - components?: { - parameters?: Record; - successActions?: Record; - failureActions?: Record; - [key: string]: unknown; - }; -}; - -type Parameter = { - name: string; - in?: string; - value?: unknown; -}; - -type SourceDescription = { - name: string; - url: string; - type?: string; -}; - -type SuccessAction = { - name: string; - type: string; - workflowId?: string; - stepId?: string; - criteria?: Criterion[]; -}; - -type FailureAction = { - name: string; - type: string; - workflowId?: string; - stepId?: string; - retryAfter?: number; - retryLimit?: number; - criteria?: Criterion[]; -}; - -type Criterion = { - condition: string; -}; - -type ReusableObject = { - reference: string; -}; - -type Step = { - stepId: string; - onSuccess?: (SuccessAction | ReusableObject)[]; -}; - -type Workflow = { - workflowId: string; - steps: Step[]; - successActions?: (SuccessAction | ReusableObject)[]; -}; +import { ArazzoSpecification, Workflow, Step, ReusableObject, SuccessAction } from '../types/arazzoTypes'; const resolveReusableSuccessActions = ( reusableObject: ReusableObject, diff --git a/packages/rulesets/src/arazzo/functions/utils/getAllWorkflows.ts b/packages/rulesets/src/arazzo/functions/utils/getAllWorkflows.ts index cace9917b..3ff3b16d1 100644 --- a/packages/rulesets/src/arazzo/functions/utils/getAllWorkflows.ts +++ b/packages/rulesets/src/arazzo/functions/utils/getAllWorkflows.ts @@ -1,13 +1,10 @@ import { isPlainObject } from '@stoplight/json'; import type { JsonPath } from '@stoplight/types'; +import { ArazzoSpecification, Workflow } from '../types/arazzoTypes'; -type WorkflowObject = Record; -type ArazzoDocument = { - workflows?: WorkflowObject[]; -}; -type Result = { path: JsonPath; workflow: WorkflowObject }; +type Result = { path: JsonPath; workflow: Workflow }; -export function* getAllWorkflows(arazzo: ArazzoDocument): IterableIterator { +export function* getAllWorkflows(arazzo: ArazzoSpecification): IterableIterator { const workflows = arazzo?.workflows; if (!Array.isArray(workflows)) { return;