diff --git a/package-lock.json b/package-lock.json index 6b693e8..4ff398c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@openworkflowspec/sdk", - "version": "1.0.3-alpha6", + "version": "1.0.3-alpha7", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@openworkflowspec/sdk", - "version": "1.0.3-alpha6", + "version": "1.0.3-alpha7", "license": "Apache-2.0", "dependencies": { "ajv": "^8.20.0", diff --git a/package.json b/package.json index 3fd0734..c4cadc3 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@openworkflowspec/sdk", - "version": "1.0.3-alpha6", + "version": "1.0.3-alpha7", "schemaVersion": "1.0.3", "supportedDslVersions": ">=1.0.0-0 <=1.0.3", "description": "Typescript SDK for Open Workflow Specification", diff --git a/src/lib/schema.ts b/src/lib/schema.ts new file mode 100644 index 0000000..cb81567 --- /dev/null +++ b/src/lib/schema.ts @@ -0,0 +1,26 @@ +/* + * Copyright 2021-Present The Open Workflow Specification Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * oUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +import type { SchemaObject } from 'ajv'; +import workflowSchemaJson from './generated/schema/workflow.json'; + +/** + * THE JSON Schema of the Open Workflow DSL - the exact document that {@link validate} uses to validate workflows. + * Versioned by the specification not by this package: $id and package.json schemaVersion bit have DSL version it was generated from. + **/ + +export const workflowSchema: SchemaObject = workflowSchemaJson; diff --git a/src/open-workflow-sdk.ts b/src/open-workflow-sdk.ts index fa6b1a0..6cb5d31 100644 --- a/src/open-workflow-sdk.ts +++ b/src/open-workflow-sdk.ts @@ -5,3 +5,4 @@ export * from './lib/errors'; export * from './lib/validation'; export * from './lib/graph-builder'; export * from './lib/mermaid-converter'; +export * from './lib/schema'; diff --git a/tests/validation/schema.spec.ts b/tests/validation/schema.spec.ts new file mode 100644 index 0000000..f53149d --- /dev/null +++ b/tests/validation/schema.spec.ts @@ -0,0 +1,31 @@ +/* + * Copyright 2021-Present The Open Workflow Specification Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * oUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +import { workflowSchema } from '../../src/lib/schema'; +import { schemaVersion } from '../../package.json'; + +describe('workflowSchema', () => { + it('it is the same schema the validatior enforces', () => { + expect(workflowSchema.$id).toBe(`https://open-workflow-specification.org/schemas/${schemaVersion}/workflow.json`); + }); + + it('it carries the definitions consumers navigate by (smoke test)', () => { + expect(workflowSchema.$defs?.task).toBeDefined(); + expect(workflowSchema.$defs?.taskList).toBeDefined(); + expect(workflowSchema.$defs?.callTask).toBeDefined(); + }); +});