diff --git a/src/lib/builders/README.md b/src/lib/builders/README.md index 86d82d3e..7d5a8642 100644 --- a/src/lib/builders/README.md +++ b/src/lib/builders/README.md @@ -1,3 +1,2 @@ # Auto generated notice - This directory and its content has been generated automatically. Do not modify its content, it WILL be lost. \ No newline at end of file diff --git a/src/lib/builders/actiondatafilter-builder.ts b/src/lib/builders/actiondatafilter-builder.ts index c9f74ea0..cd2278be 100644 --- a/src/lib/builders/actiondatafilter-builder.ts +++ b/src/lib/builders/actiondatafilter-builder.ts @@ -27,7 +27,7 @@ function actiondatafilterBuildingFn(data: Specification.Actiondatafilter): () => return () => { const model = new Specification.Actiondatafilter(data); - validate('Actiondatafilter', model); + validate('Actiondatafilter', model.normalize()); return model; }; } diff --git a/src/lib/builders/basicpropsdef-builder.ts b/src/lib/builders/basicpropsdef-builder.ts index d12618e8..49c359cf 100644 --- a/src/lib/builders/basicpropsdef-builder.ts +++ b/src/lib/builders/basicpropsdef-builder.ts @@ -27,7 +27,7 @@ function basicpropsdefBuildingFn(data: Specification.Basicpropsdef): () => Speci return () => { const model = new Specification.Basicpropsdef(data); - validate('Basicpropsdef', model); + validate('Basicpropsdef', model.normalize()); return model; }; } diff --git a/src/lib/builders/bearerpropsdef-builder.ts b/src/lib/builders/bearerpropsdef-builder.ts index c77f1ac3..6c372fdc 100644 --- a/src/lib/builders/bearerpropsdef-builder.ts +++ b/src/lib/builders/bearerpropsdef-builder.ts @@ -27,7 +27,7 @@ function bearerpropsdefBuildingFn(data: Specification.Bearerpropsdef): () => Spe return () => { const model = new Specification.Bearerpropsdef(data); - validate('Bearerpropsdef', model); + validate('Bearerpropsdef', model.normalize()); return model; }; } diff --git a/src/lib/builders/correlation-def-builder.ts b/src/lib/builders/correlation-def-builder.ts index 3e15e621..048ddf3a 100644 --- a/src/lib/builders/correlation-def-builder.ts +++ b/src/lib/builders/correlation-def-builder.ts @@ -27,7 +27,7 @@ function correlationDefBuildingFn(data: Specification.CorrelationDef): () => Spe return () => { const model = new Specification.CorrelationDef(data); - validate('CorrelationDef', model); + validate('CorrelationDef', model.normalize()); return model; }; } diff --git a/src/lib/builders/crondef-builder.ts b/src/lib/builders/crondef-builder.ts index 3521c55b..f8172fac 100644 --- a/src/lib/builders/crondef-builder.ts +++ b/src/lib/builders/crondef-builder.ts @@ -27,7 +27,7 @@ function crondefBuildingFn(data: Specification.Crondef): () => Specification.Cro return () => { const model = new Specification.Crondef(data); - validate('Crondef', model); + validate('Crondef', model.normalize()); return model; }; } diff --git a/src/lib/builders/enddeventcondition-builder.ts b/src/lib/builders/endeventcondition-builder.ts similarity index 59% rename from src/lib/builders/enddeventcondition-builder.ts rename to src/lib/builders/endeventcondition-builder.ts index 9c8631c2..b6792bb6 100644 --- a/src/lib/builders/enddeventcondition-builder.ts +++ b/src/lib/builders/endeventcondition-builder.ts @@ -20,22 +20,22 @@ import { validate } from '../utils'; /** * The internal function used by the builder proxy to validate and return its underlying object - * @param {Specification.Enddeventcondition} data The underlying object - * @returns {Specification.Enddeventcondition} The validated underlying object + * @param {Specification.Endeventcondition} data The underlying object + * @returns {Specification.Endeventcondition} The validated underlying object */ -function enddeventconditionBuildingFn(data: Specification.Enddeventcondition): () => Specification.Enddeventcondition { +function endeventconditionBuildingFn(data: Specification.Endeventcondition): () => Specification.Endeventcondition { return () => { - const model = new Specification.Enddeventcondition(data); + const model = new Specification.Endeventcondition(data); - validate('Enddeventcondition', model.normalize()); + validate('Endeventcondition', model.normalize()); return model; }; } /** - * A factory to create a builder proxy for the type `Specification.Enddeventcondition` - * @returns {Specification.Enddeventcondition} A builder for `Specification.Enddeventcondition` + * A factory to create a builder proxy for the type `Specification.Endeventcondition` + * @returns {Specification.Endeventcondition} A builder for `Specification.Endeventcondition` */ -export function enddeventconditionBuilder(): Builder { - return builder(enddeventconditionBuildingFn); +export function endeventconditionBuilder(): Builder { + return builder(endeventconditionBuildingFn); } diff --git a/src/lib/builders/errordef-builder.ts b/src/lib/builders/errordef-builder.ts index 8abaa2f9..461aee0c 100644 --- a/src/lib/builders/errordef-builder.ts +++ b/src/lib/builders/errordef-builder.ts @@ -27,7 +27,7 @@ function errordefBuildingFn(data: Specification.Errordef): () => Specification.E return () => { const model = new Specification.Errordef(data); - validate('Errordef', model); + validate('Errordef', model.normalize()); return model; }; } diff --git a/src/lib/builders/eventdatafilter-builder.ts b/src/lib/builders/eventdatafilter-builder.ts index 6bf36387..d86487ed 100644 --- a/src/lib/builders/eventdatafilter-builder.ts +++ b/src/lib/builders/eventdatafilter-builder.ts @@ -27,7 +27,7 @@ function eventdatafilterBuildingFn(data: Specification.Eventdatafilter): () => S return () => { const model = new Specification.Eventdatafilter(data); - validate('Eventdatafilter', model); + validate('Eventdatafilter', model.normalize()); return model; }; } diff --git a/src/lib/builders/state-exec-timeout-builder.ts b/src/lib/builders/extension-builder.ts similarity index 61% rename from src/lib/builders/state-exec-timeout-builder.ts rename to src/lib/builders/extension-builder.ts index 4d9b59fe..bd90a3e0 100644 --- a/src/lib/builders/state-exec-timeout-builder.ts +++ b/src/lib/builders/extension-builder.ts @@ -20,22 +20,22 @@ import { validate } from '../utils'; /** * The internal function used by the builder proxy to validate and return its underlying object - * @param {Specification.StateExecTimeout} data The underlying object - * @returns {Specification.StateExecTimeout} The validated underlying object + * @param {Specification.Extension} data The underlying object + * @returns {Specification.Extension} The validated underlying object */ -function stateExecTimeoutBuildingFn(data: Specification.StateExecTimeout): () => Specification.StateExecTimeout { +function extensionBuildingFn(data: Specification.Extension): () => Specification.Extension { return () => { - const model = new Specification.StateExecTimeout(data); + const model = new Specification.Extension(data); - validate('StateExecTimeout', model); + validate('Extension', model.normalize()); return model; }; } /** - * A factory to create a builder proxy for the type `Specification.StateExecTimeout` - * @returns {Specification.StateExecTimeout} A builder for `Specification.StateExecTimeout` + * A factory to create a builder proxy for the type `Specification.Extension` + * @returns {Specification.Extension} A builder for `Specification.Extension` */ -export function stateExecTimeoutBuilder(): Builder { - return builder(stateExecTimeoutBuildingFn); +export function extensionBuilder(): Builder { + return builder(extensionBuildingFn); } diff --git a/src/lib/builders/index.ts b/src/lib/builders/index.ts index cd7065f0..737e880e 100644 --- a/src/lib/builders/index.ts +++ b/src/lib/builders/index.ts @@ -29,7 +29,7 @@ export * from './databasedswitchstate-builder'; export * from './defaultconditiondef-builder'; export * from './end-builder'; export * from './enddatacondition-builder'; -export * from './enddeventcondition-builder'; +export * from './endeventcondition-builder'; export * from './error-builder'; export * from './errordef-builder'; export * from './eventbasedswitchstate-builder'; @@ -37,6 +37,7 @@ export * from './eventdatafilter-builder'; export * from './eventdef-builder'; export * from './eventref-builder'; export * from './eventstate-builder'; +export * from './extension-builder'; export * from './foreachstate-builder'; export * from './function-builder'; export * from './functionref-builder'; @@ -52,7 +53,6 @@ export * from './schedule-builder'; export * from './sleep-builder'; export * from './sleepstate-builder'; export * from './startdef-builder'; -export * from './state-exec-timeout-builder'; export * from './statedatafilter-builder'; export * from './subflowref-builder'; export * from './timeouts-builder'; diff --git a/src/lib/builders/oauth2propsdef-builder.ts b/src/lib/builders/oauth2propsdef-builder.ts index 780a99ab..f078e3ac 100644 --- a/src/lib/builders/oauth2propsdef-builder.ts +++ b/src/lib/builders/oauth2propsdef-builder.ts @@ -27,7 +27,7 @@ function oauth2propsdefBuildingFn(data: Specification.Oauth2propsdef): () => Spe return () => { const model = new Specification.Oauth2propsdef(data); - validate('Oauth2propsdef', model); + validate('Oauth2propsdef', model.normalize()); return model; }; } diff --git a/src/lib/builders/produceeventdef-builder.ts b/src/lib/builders/produceeventdef-builder.ts index ca476710..5212cf77 100644 --- a/src/lib/builders/produceeventdef-builder.ts +++ b/src/lib/builders/produceeventdef-builder.ts @@ -27,7 +27,7 @@ function produceeventdefBuildingFn(data: Specification.Produceeventdef): () => S return () => { const model = new Specification.Produceeventdef(data); - validate('Produceeventdef', model); + validate('Produceeventdef', model.normalize()); return model; }; } diff --git a/src/lib/builders/retrydef-builder.ts b/src/lib/builders/retrydef-builder.ts index bbf254cf..c7ed6536 100644 --- a/src/lib/builders/retrydef-builder.ts +++ b/src/lib/builders/retrydef-builder.ts @@ -27,7 +27,7 @@ function retrydefBuildingFn(data: Specification.Retrydef): () => Specification.R return () => { const model = new Specification.Retrydef(data); - validate('Retrydef', model); + validate('Retrydef', model.normalize()); return model; }; } diff --git a/src/lib/builders/schedule-builder.ts b/src/lib/builders/schedule-builder.ts index 54fe3097..dbf26555 100644 --- a/src/lib/builders/schedule-builder.ts +++ b/src/lib/builders/schedule-builder.ts @@ -27,7 +27,7 @@ function scheduleBuildingFn(data: Specification.Schedule): () => Specification.S return () => { const model = new Specification.Schedule(data); - validate('Schedule', model); + validate('Schedule', model.normalize()); return model; }; } diff --git a/src/lib/builders/sleep-builder.ts b/src/lib/builders/sleep-builder.ts index af780040..d2d8e0bc 100644 --- a/src/lib/builders/sleep-builder.ts +++ b/src/lib/builders/sleep-builder.ts @@ -27,7 +27,7 @@ function sleepBuildingFn(data: Specification.Sleep): () => Specification.Sleep { return () => { const model = new Specification.Sleep(data); - validate('Sleep', model); + validate('Sleep', model.normalize()); return model; }; } diff --git a/src/lib/builders/startdef-builder.ts b/src/lib/builders/startdef-builder.ts index 3ed59f41..bc6fb7ff 100644 --- a/src/lib/builders/startdef-builder.ts +++ b/src/lib/builders/startdef-builder.ts @@ -27,7 +27,7 @@ function startdefBuildingFn(data: Specification.Startdef): () => Specification.S return () => { const model = new Specification.Startdef(data); - validate('Startdef', model); + validate('Startdef', model.normalize()); return model; }; } diff --git a/src/lib/builders/statedatafilter-builder.ts b/src/lib/builders/statedatafilter-builder.ts index a3e3246c..69d0aa1b 100644 --- a/src/lib/builders/statedatafilter-builder.ts +++ b/src/lib/builders/statedatafilter-builder.ts @@ -27,7 +27,7 @@ function statedatafilterBuildingFn(data: Specification.Statedatafilter): () => S return () => { const model = new Specification.Statedatafilter(data); - validate('Statedatafilter', model); + validate('Statedatafilter', model.normalize()); return model; }; } diff --git a/src/lib/definitions/action.ts b/src/lib/definitions/action.ts index b57d098d..d587d861 100644 --- a/src/lib/definitions/action.ts +++ b/src/lib/definitions/action.ts @@ -32,10 +32,6 @@ import { Sleep } from './sleep'; export class Action { sourceModel?: Action; - /** - * Unique action identifier - */ - id?: string; /** * Unique action definition name */ diff --git a/src/lib/definitions/actiondatafilter.ts b/src/lib/definitions/actiondatafilter.ts index a227be10..6500acad 100644 --- a/src/lib/definitions/actiondatafilter.ts +++ b/src/lib/definitions/actiondatafilter.ts @@ -35,4 +35,12 @@ export class Actiondatafilter { constructor(model: any) { Object.assign(this, model); } + /** + * Normalize the value of each property by recursively deleting properties whose value is equal to its default value. Does not modify the object state. + * @returns {Specification.Actiondatafilter} without deleted properties. + */ + normalize = (): Actiondatafilter => { + const clone = new Actiondatafilter(this); + return clone; + }; } diff --git a/src/lib/definitions/basicpropsdef.ts b/src/lib/definitions/basicpropsdef.ts index fb07db82..d51920cb 100644 --- a/src/lib/definitions/basicpropsdef.ts +++ b/src/lib/definitions/basicpropsdef.ts @@ -33,4 +33,12 @@ export class Basicpropsdef { overwriteMetadata(this); } + /** + * Normalize the value of each property by recursively deleting properties whose value is equal to its default value. Does not modify the object state. + * @returns {Specification.Basicpropsdef} without deleted properties. + */ + normalize = (): Basicpropsdef => { + const clone = new Basicpropsdef(this); + return clone; + }; } diff --git a/src/lib/definitions/bearerpropsdef.ts b/src/lib/definitions/bearerpropsdef.ts index bca83da8..9c444d7d 100644 --- a/src/lib/definitions/bearerpropsdef.ts +++ b/src/lib/definitions/bearerpropsdef.ts @@ -28,4 +28,12 @@ export class Bearerpropsdef { Object.assign(this, model); overwriteMetadata(this); } + /** + * Normalize the value of each property by recursively deleting properties whose value is equal to its default value. Does not modify the object state. + * @returns {Specification.Bearerpropsdef} without deleted properties. + */ + normalize = (): Bearerpropsdef => { + const clone = new Bearerpropsdef(this); + return clone; + }; } diff --git a/src/lib/definitions/branch.ts b/src/lib/definitions/branch.ts index 0ce27539..9a82edd2 100644 --- a/src/lib/definitions/branch.ts +++ b/src/lib/definitions/branch.ts @@ -28,8 +28,8 @@ export class Branch /* Branch Definition */ { * State specific timeouts */ timeouts?: { - actionExecTimeout?: /* Single actions definition execution timeout duration (ISO 8601 duration format) */ ActionExecTimeout; - branchExecTimeout?: /* Single branch execution timeout duration (ISO 8601 duration format) */ BranchExecTimeout; + actionExecTimeout?: /* Action execution timeout duration (ISO 8601 duration format) */ ActionExecTimeout; + branchExecTimeout?: /* Branch execution timeout duration (ISO 8601 duration format) */ BranchExecTimeout; }; /** * Actions to be executed in this branch diff --git a/src/lib/definitions/callbackstate.ts b/src/lib/definitions/callbackstate.ts index 3b66b2e1..49e1d8d6 100644 --- a/src/lib/definitions/callbackstate.ts +++ b/src/lib/definitions/callbackstate.ts @@ -33,13 +33,12 @@ import { overwriteEventDataFilter, overwriteMetadata, overwriteOnErrors, + overwritePropertyAsPlainType, overwriteStateDataFilter, - overwriteTimeoutWithStateExecTimeout, overwriteTransition, setEndValueIfNoTransition, } from './utils'; -import { ActionExecTimeout, EventTimeout } from './types'; -import { StateExecTimeout } from './stateExecTimeout'; +import { ActionExecTimeout, EventTimeout, StateExecTimeout } from './types'; export class Callbackstate { sourceModel?: Callbackstate; @@ -67,8 +66,8 @@ export class Callbackstate { * State specific timeouts */ timeouts?: { - stateExecTimeout?: StateExecTimeout; - actionExecTimeout?: /* Single actions definition execution timeout duration (ISO 8601 duration format) */ ActionExecTimeout; + stateExecTimeout?: /* Workflow state execution timeout duration (ISO 8601 duration format) */ StateExecTimeout; + actionExecTimeout?: /* Action execution timeout duration (ISO 8601 duration format) */ ActionExecTimeout; eventTimeout?: /* Timeout duration to wait for consuming defined events (ISO 8601 duration format) */ EventTimeout; }; /** @@ -113,7 +112,7 @@ export class Callbackstate { Object.assign(this, defaultModel, model); overwriteAction(this); - overwriteTimeoutWithStateExecTimeout(this); + overwritePropertyAsPlainType('timeouts', this); overwriteEventDataFilter(this); overwriteStateDataFilter(this); overwriteOnErrors(this); diff --git a/src/lib/definitions/continueasdef.ts b/src/lib/definitions/continueasdef.ts index 0360d571..ff5208c6 100644 --- a/src/lib/definitions/continueasdef.ts +++ b/src/lib/definitions/continueasdef.ts @@ -32,7 +32,7 @@ export class Continueasdef { /** * Version of the workflow to continue execution as */ - version?: string; + version?: string; // ^(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-]+)*))?$ /** * If string type, an expression which selects parts of the states data output to become the workflow data input of continued execution. If object type, a custom object to become the workflow data input of the continued execution */ diff --git a/src/lib/definitions/correlationDef.ts b/src/lib/definitions/correlationDef.ts index f487fd59..824f52e8 100644 --- a/src/lib/definitions/correlationDef.ts +++ b/src/lib/definitions/correlationDef.ts @@ -27,4 +27,12 @@ export class CorrelationDef { constructor(model: any) { Object.assign(this, model); } + /** + * Normalize the value of each property by recursively deleting properties whose value is equal to its default value. Does not modify the object state. + * @returns {Specification.CorrelationDef} without deleted properties. + */ + normalize = (): CorrelationDef => { + const clone = new CorrelationDef(this); + return clone; + }; } diff --git a/src/lib/definitions/crondef.ts b/src/lib/definitions/crondef.ts index 50d3b101..a7aefb41 100644 --- a/src/lib/definitions/crondef.ts +++ b/src/lib/definitions/crondef.ts @@ -27,4 +27,12 @@ export class Crondef { constructor(model: any) { Object.assign(this, model); } + /** + * Normalize the value of each property by recursively deleting properties whose value is equal to its default value. Does not modify the object state. + * @returns {Specification.Crondef} without deleted properties. + */ + normalize = (): Crondef => { + const clone = new Crondef(this); + return clone; + }; } diff --git a/src/lib/definitions/databasedswitchstate.ts b/src/lib/definitions/databasedswitchstate.ts index c0b14de9..013b3695 100644 --- a/src/lib/definitions/databasedswitchstate.ts +++ b/src/lib/definitions/databasedswitchstate.ts @@ -29,17 +29,12 @@ import { overwriteMetadata, overwriteOnErrors, overwriteStateDataFilter, - overwriteTimeoutWithStateExecTimeout, + overwritePropertyAsPlainType, } from './utils'; -import { Datacondition } from './types'; -import { StateExecTimeout } from './stateExecTimeout'; +import { Datacondition, StateExecTimeout } from './types'; export class Databasedswitchstate { sourceModel?: Databasedswitchstate; - /** - * Unique State id - */ - id?: string; /** * State name */ @@ -56,7 +51,7 @@ export class Databasedswitchstate { * State specific timeouts */ timeouts?: { - stateExecTimeout?: StateExecTimeout; + stateExecTimeout?: /* Workflow state execution timeout duration (ISO 8601 duration format) */ StateExecTimeout; }; /** * Defines conditions evaluated against state data @@ -87,7 +82,7 @@ export class Databasedswitchstate { Object.assign(this, defaultModel, model); overwriteStateDataFilter(this); - overwriteTimeoutWithStateExecTimeout(this); + overwritePropertyAsPlainType('timeouts', this); overwriteDataConditions(this); overwriteOnErrors(this); overwriteDefaultCondition(this); diff --git a/src/lib/definitions/defaultconditiondef.ts b/src/lib/definitions/defaultconditiondef.ts index 5617012d..d95fecd3 100644 --- a/src/lib/definitions/defaultconditiondef.ts +++ b/src/lib/definitions/defaultconditiondef.ts @@ -27,6 +27,10 @@ import { export class Defaultconditiondef /* DefaultCondition definition. Can be either a transition or end definition */ { sourceModel?: Defaultconditiondef; + /** + * The optional name of the default condition, used solely for display purposes + */ + name?: string; transition: string | Transition; end?: boolean | End; diff --git a/src/lib/definitions/enddeventcondition.ts b/src/lib/definitions/endeventcondition.ts similarity index 87% rename from src/lib/definitions/enddeventcondition.ts rename to src/lib/definitions/endeventcondition.ts index fcd77e70..9c98e01e 100644 --- a/src/lib/definitions/enddeventcondition.ts +++ b/src/lib/definitions/endeventcondition.ts @@ -24,8 +24,8 @@ import { overwriteMetadata, } from './utils'; -export class Enddeventcondition { - sourceModel?: Enddeventcondition; +export class Endeventcondition { + sourceModel?: Endeventcondition; /** * Event condition name */ @@ -56,10 +56,10 @@ export class Enddeventcondition { /** * Normalize the value of each property by recursively deleting properties whose value is equal to its default value. Does not modify the object state. - * @returns {Specification.Enddeventcondition} without deleted properties. + * @returns {Specification.Endeventcondition} without deleted properties. */ - normalize = (): Enddeventcondition => { - const clone = new Enddeventcondition(this); + normalize = (): Endeventcondition => { + const clone = new Endeventcondition(this); normalizeEnd(clone); diff --git a/src/lib/definitions/errordef.ts b/src/lib/definitions/errordef.ts index e0e56c26..78aa011c 100644 --- a/src/lib/definitions/errordef.ts +++ b/src/lib/definitions/errordef.ts @@ -31,4 +31,13 @@ export class Errordef { constructor(model: any) { Object.assign(this, model); } + + /** + * Normalize the value of each property by recursively deleting properties whose value is equal to its default value. Does not modify the object state. + * @returns {Specification.Errordef} without deleted properties. + */ + normalize = (): Errordef => { + const clone = new Errordef(this); + return clone; + }; } diff --git a/src/lib/definitions/eventbasedswitchstate.ts b/src/lib/definitions/eventbasedswitchstate.ts index ac0c77d8..089935c6 100644 --- a/src/lib/definitions/eventbasedswitchstate.ts +++ b/src/lib/definitions/eventbasedswitchstate.ts @@ -29,17 +29,12 @@ import { overwriteMetadata, overwriteOnErrors, overwriteStateDataFilter, - overwriteTimeoutWithStateExecTimeout, + overwritePropertyAsPlainType, } from './utils'; -import { Eventcondition, EventTimeout } from './types'; -import { StateExecTimeout } from './stateExecTimeout'; +import { Eventcondition, EventTimeout, StateExecTimeout } from './types'; export class Eventbasedswitchstate { sourceModel?: Eventbasedswitchstate; - /** - * Unique State id - */ - id?: string; /** * State name */ @@ -56,7 +51,7 @@ export class Eventbasedswitchstate { * State specific timeouts */ timeouts?: { - stateExecTimeout?: StateExecTimeout; + stateExecTimeout?: /* Workflow state execution timeout duration (ISO 8601 duration format) */ StateExecTimeout; eventTimeout?: /* Timeout duration to wait for consuming defined events (ISO 8601 duration format) */ EventTimeout; }; /** @@ -88,7 +83,7 @@ export class Eventbasedswitchstate { Object.assign(this, defaultModel, model); overwriteStateDataFilter(this); - overwriteTimeoutWithStateExecTimeout(this); + overwritePropertyAsPlainType('timeouts', this); overwriteEventConditions(this); overwriteOnErrors(this); overwriteDefaultCondition(this); diff --git a/src/lib/definitions/eventdatafilter.ts b/src/lib/definitions/eventdatafilter.ts index 28a22140..9a462827 100644 --- a/src/lib/definitions/eventdatafilter.ts +++ b/src/lib/definitions/eventdatafilter.ts @@ -31,4 +31,13 @@ export class Eventdatafilter { constructor(model: any) { Object.assign(this, model); } + + /** + * Normalize the value of each property by recursively deleting properties whose value is equal to its default value. Does not modify the object state. + * @returns {Specification.Eventdatafilter} without deleted properties. + */ + normalize = (): Eventdatafilter => { + const clone = new Eventdatafilter(this); + return clone; + }; } diff --git a/src/lib/definitions/eventref.ts b/src/lib/definitions/eventref.ts index c89e3dd8..02dc0bdc 100644 --- a/src/lib/definitions/eventref.ts +++ b/src/lib/definitions/eventref.ts @@ -14,24 +14,24 @@ * limitations under the License. */ -import { cleanSourceModelProperty, normalizeInvoke, overwritePropertyAsPlainType } from './utils'; +import { cleanSourceModelProperty, overwritePropertyAsPlainType } from './utils'; export class Eventref { sourceModel?: Eventref; /** * Reference to the unique name of a 'produced' event definition */ - triggerEventRef: string; + produceEventRef: string; /** * Reference to the unique name of a 'consumed' event definition */ - resultEventRef: string; + consumeEventRef?: string; /** * Maximum amount of time (ISO 8601 format) to wait for the result event. If not defined it should default to the actionExecutionTimeout */ - resultEventTimeout?: string; + consumeEventTimeout?: string; /** - * If string type, an expression which selects parts of the states data output to become the data (payload) of the event referenced by 'triggerEventRef'. If object type, a custom object to become the data (payload) of the event referenced by 'triggerEventRef'. + * If string type, an expression which selects parts of the states data output to become the data (payload) of the event referenced by 'produceEventRef'. If object type, a custom object to become the data (payload) of the event referenced by 'produceEventRef'. */ data?: | string @@ -44,11 +44,6 @@ export class Eventref { contextAttributes?: { [name: string]: string; }; - /** - * Specifies if the function should be invoked sync or async. Default is sync. - */ - invoke?: 'sync' | 'async'; - constructor(model: any) { this.sourceModel = Object.assign({}, model); @@ -64,8 +59,6 @@ export class Eventref { normalize = (): Eventref => { const clone = new Eventref(this); - normalizeInvoke(clone, this.sourceModel); - cleanSourceModelProperty(clone); return clone; diff --git a/src/lib/definitions/eventstate.ts b/src/lib/definitions/eventstate.ts index f26a8d66..836cd4fc 100644 --- a/src/lib/definitions/eventstate.ts +++ b/src/lib/definitions/eventstate.ts @@ -31,19 +31,14 @@ import { overwriteOnErrors, overwriteOnEvents, overwriteStateDataFilter, - overwriteTimeoutWithStateExecTimeout, + overwritePropertyAsPlainType, overwriteTransition, setEndValueIfNoTransition, } from './utils'; -import { ActionExecTimeout, EventTimeout } from './types'; -import { StateExecTimeout } from './stateExecTimeout'; +import { ActionExecTimeout, EventTimeout, StateExecTimeout } from './types'; export class Eventstate /* This state is used to wait for events from event sources, then consumes them and invoke one or more actions to run in sequence or parallel */ { sourceModel?: Eventstate; - /** - * Unique State id - */ - id?: string; /** * State name */ @@ -64,8 +59,8 @@ export class Eventstate /* This state is used to wait for events from event sour * State specific timeouts */ timeouts?: { - stateExecTimeout?: StateExecTimeout; - actionExecTimeout?: /* Single actions definition execution timeout duration (ISO 8601 duration format) */ ActionExecTimeout; + stateExecTimeout?: /* Workflow state execution timeout duration (ISO 8601 duration format) */ StateExecTimeout; + actionExecTimeout?: /* Action execution timeout duration (ISO 8601 duration format) */ ActionExecTimeout; eventTimeout?: /* Timeout duration to wait for consuming defined events (ISO 8601 duration format) */ EventTimeout; }; stateDataFilter?: Statedatafilter; @@ -93,7 +88,7 @@ export class Eventstate /* This state is used to wait for events from event sour Object.assign(this, defaultModel, model); overwriteOnEvents(this); - overwriteTimeoutWithStateExecTimeout(this); + overwritePropertyAsPlainType('timeouts', this); overwriteStateDataFilter(this); overwriteOnErrors(this); overwriteTransition(this); diff --git a/src/lib/definitions/extension.ts b/src/lib/definitions/extension.ts new file mode 100644 index 00000000..40166a22 --- /dev/null +++ b/src/lib/definitions/extension.ts @@ -0,0 +1,39 @@ +/* + * Copyright 2021-Present The Serverless 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, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export class Extension { + /** + * Unique extension id + */ + extensionId: string; + /** + * URI to a resource containing this workflow extension definitions (json or yaml) + */ + resource: string; + + constructor(model: any) { + Object.assign(this, model); + } + + /** + * Normalize the value of each property by recursively deleting properties whose value is equal to its default value. Does not modify the object state. + * @returns {Specification.Extension} without deleted properties. + */ + normalize = (): Extension => { + const clone = new Extension(this); + return clone; + }; +} diff --git a/src/lib/definitions/foreachstate.ts b/src/lib/definitions/foreachstate.ts index 98a83b76..d9e2857f 100644 --- a/src/lib/definitions/foreachstate.ts +++ b/src/lib/definitions/foreachstate.ts @@ -32,19 +32,14 @@ import { overwriteMetadata, overwriteOnErrors, overwriteStateDataFilter, - overwriteTimeoutWithStateExecTimeout, + overwritePropertyAsPlainType, overwriteTransition, setEndValueIfNoTransition, } from './utils'; -import { ActionExecTimeout } from './types'; -import { StateExecTimeout } from './stateExecTimeout'; +import { ActionExecTimeout, StateExecTimeout } from './types'; export class Foreachstate { sourceModel?: Foreachstate; - /** - * Unique State id - */ - id?: string; /** * State name */ @@ -81,8 +76,8 @@ export class Foreachstate { * State specific timeouts */ timeouts?: { - stateExecTimeout?: StateExecTimeout; - actionExecTimeout?: /* Single actions definition execution timeout duration (ISO 8601 duration format) */ ActionExecTimeout; + stateExecTimeout?: /* Workflow state execution timeout duration (ISO 8601 duration format) */ StateExecTimeout; + actionExecTimeout?: /* Action execution timeout duration (ISO 8601 duration format) */ ActionExecTimeout; }; /** * State data filter @@ -124,7 +119,7 @@ export class Foreachstate { overwriteEnd(this); overwriteActions(this); - overwriteTimeoutWithStateExecTimeout(this); + overwritePropertyAsPlainType('timeouts', this); overwriteStateDataFilter(this); overwriteOnErrors(this); overwriteTransition(this); diff --git a/src/lib/definitions/function.ts b/src/lib/definitions/function.ts index 94446c99..bdb7ed97 100644 --- a/src/lib/definitions/function.ts +++ b/src/lib/definitions/function.ts @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -import { cleanSourceModelProperty, normalizeType, overwriteMetadata } from './utils'; +import { cleanSourceModelProperty, normalizeType, overwriteMetadata, overwritePropertyAsPlainType } from './utils'; import { Metadata } from './metadata'; @@ -31,10 +31,18 @@ export class Function { * Defines the function type. Is either `rest`, `asyncapi, `rpc`, `graphql`, `odata`, `expression`, or `custom`. Default is `rest` */ type?: 'rest' | 'asyncapi' | 'rpc' | 'graphql' | 'odata' | 'expression' | 'custom'; - /** - * References an auth definition name to be used to access to resource defined in the operation parameter - */ - authRef?: string; + authRef?: + | string + | { + /** + * References an auth definition to be used to access the resource defined in the operation parameter + */ + resource: string; + /** + * References an auth definition to be used to invoke the operation + */ + invocation?: string; + }; metadata?: /* Metadata information */ Metadata; constructor(model: any) { @@ -42,6 +50,7 @@ export class Function { const defaultModel = { type: 'rest' }; Object.assign(this, defaultModel, model); + overwritePropertyAsPlainType('authRef', this); overwriteMetadata(this); } diff --git a/src/lib/definitions/injectstate.ts b/src/lib/definitions/injectstate.ts index e0a3cf12..e25c657f 100644 --- a/src/lib/definitions/injectstate.ts +++ b/src/lib/definitions/injectstate.ts @@ -25,20 +25,14 @@ import { normalizeUsedForCompensation, overwriteEnd, overwriteMetadata, - overwritePropertyAsPlainType, overwriteStateDataFilter, - overwriteTimeoutWithStateExecTimeout, + overwritePropertyAsPlainType, overwriteTransition, setEndValueIfNoTransition, } from './utils'; -import { StateExecTimeout } from './stateExecTimeout'; export class Injectstate { sourceModel?: Injectstate; - /** - * Unique state id - */ - id?: string; /** * State name */ @@ -57,12 +51,6 @@ export class Injectstate { data?: { [key: string]: any; }; - /** - * State specific timeouts - */ - timeouts?: { - stateExecTimeout?: StateExecTimeout; - }; /** * State data filter */ @@ -94,7 +82,6 @@ export class Injectstate { overwriteEnd(this); overwritePropertyAsPlainType('data', this); - overwriteTimeoutWithStateExecTimeout(this); overwriteStateDataFilter(this); overwriteTransition(this); overwriteMetadata(this); diff --git a/src/lib/definitions/oauth2propsdef.ts b/src/lib/definitions/oauth2propsdef.ts index d297c55e..3d2b9943 100644 --- a/src/lib/definitions/oauth2propsdef.ts +++ b/src/lib/definitions/oauth2propsdef.ts @@ -68,4 +68,13 @@ export class Oauth2propsdef { Object.assign(this, model); overwriteMetadata(this); } + + /** + * Normalize the value of each property by recursively deleting properties whose value is equal to its default value. Does not modify the object state. + * @returns {Specification.Oauth2propsdef} without deleted properties. + */ + normalize = (): Oauth2propsdef => { + const clone = new Oauth2propsdef(this); + return clone; + }; } diff --git a/src/lib/definitions/operationstate.ts b/src/lib/definitions/operationstate.ts index 70823c09..3de32e52 100644 --- a/src/lib/definitions/operationstate.ts +++ b/src/lib/definitions/operationstate.ts @@ -32,19 +32,14 @@ import { overwriteMetadata, overwriteOnErrors, overwriteStateDataFilter, - overwriteTimeoutWithStateExecTimeout, + overwritePropertyAsPlainType, overwriteTransition, setEndValueIfNoTransition, } from './utils'; -import { ActionExecTimeout } from './types'; -import { StateExecTimeout } from './stateExecTimeout'; +import { ActionExecTimeout, StateExecTimeout } from './types'; export class Operationstate { sourceModel?: Operationstate; - /** - * Unique State id - */ - id?: string; /** * State name */ @@ -73,8 +68,8 @@ export class Operationstate { * State specific timeouts */ timeouts?: { - stateExecTimeout?: StateExecTimeout; - actionExecTimeout?: /* Single actions definition execution timeout duration (ISO 8601 duration format) */ ActionExecTimeout; + stateExecTimeout?: /* Workflow state execution timeout duration (ISO 8601 duration format) */ StateExecTimeout; + actionExecTimeout?: /* Action execution timeout duration (ISO 8601 duration format) */ ActionExecTimeout; }; /** * States error handling definitions @@ -109,7 +104,7 @@ export class Operationstate { overwriteEnd(this); overwriteStateDataFilter(this); overwriteActions(this); - overwriteTimeoutWithStateExecTimeout(this); + overwritePropertyAsPlainType('timeouts', this); overwriteOnErrors(this); overwriteTransition(this); overwriteMetadata(this); diff --git a/src/lib/definitions/parallelstate.ts b/src/lib/definitions/parallelstate.ts index 32761c3e..2a3d6d50 100644 --- a/src/lib/definitions/parallelstate.ts +++ b/src/lib/definitions/parallelstate.ts @@ -33,19 +33,14 @@ import { overwriteMetadata, overwriteOnErrors, overwriteStateDataFilter, - overwriteTimeoutWithStateExecTimeout, + overwritePropertyAsPlainType, overwriteTransition, setEndValueIfNoTransition, } from './utils'; -import { BranchExecTimeout } from './types'; -import { StateExecTimeout } from './stateExecTimeout'; +import { BranchExecTimeout, StateExecTimeout } from './types'; export class Parallelstate { sourceModel?: Parallelstate; - /** - * Unique State id - */ - id?: string; /** * State name */ @@ -66,8 +61,8 @@ export class Parallelstate { * State specific timeouts */ timeouts?: { - stateExecTimeout?: StateExecTimeout; - branchExecTimeout?: /* Single branch execution timeout duration (ISO 8601 duration format) */ BranchExecTimeout; + stateExecTimeout?: /* Workflow state execution timeout duration (ISO 8601 duration format) */ StateExecTimeout; + branchExecTimeout?: /* Branch execution timeout duration (ISO 8601 duration format) */ BranchExecTimeout; }; /** * Branch Definitions @@ -113,7 +108,7 @@ export class Parallelstate { overwriteEnd(this); overwriteStateDataFilter(this); - overwriteTimeoutWithStateExecTimeout(this); + overwritePropertyAsPlainType('timeouts', this); overwriteBranches(this); overwriteOnErrors(this); overwriteTransition(this); diff --git a/src/lib/definitions/produceeventdef.ts b/src/lib/definitions/produceeventdef.ts index d0bb5504..3750cb01 100644 --- a/src/lib/definitions/produceeventdef.ts +++ b/src/lib/definitions/produceeventdef.ts @@ -41,4 +41,13 @@ export class Produceeventdef { overwritePropertyAsPlainType('data', this); overwritePropertyAsPlainType('contextAttributes', this); } + + /** + * Normalize the value of each property by recursively deleting properties whose value is equal to its default value. Does not modify the object state. + * @returns {Specification.Produceeventdef} without deleted properties. + */ + normalize = (): Produceeventdef => { + const clone = new Produceeventdef(this); + return clone; + }; } diff --git a/src/lib/definitions/retrydef.ts b/src/lib/definitions/retrydef.ts index e0a141b9..a85313f8 100644 --- a/src/lib/definitions/retrydef.ts +++ b/src/lib/definitions/retrydef.ts @@ -47,4 +47,13 @@ export class Retrydef { constructor(model: any) { Object.assign(this, model); } + + /** + * Normalize the value of each property by recursively deleting properties whose value is equal to its default value. Does not modify the object state. + * @returns {Specification.Retrydef} without deleted properties. + */ + normalize = (): Retrydef => { + const clone = new Retrydef(this); + return clone; + }; } diff --git a/src/lib/definitions/schedule.ts b/src/lib/definitions/schedule.ts index f6064ab7..c3f7506d 100644 --- a/src/lib/definitions/schedule.ts +++ b/src/lib/definitions/schedule.ts @@ -32,4 +32,13 @@ export class Schedule { overwriteCron(this); } + + /** + * Normalize the value of each property by recursively deleting properties whose value is equal to its default value. Does not modify the object state. + * @returns {Specification.Schedule} without deleted properties. + */ + normalize = (): Schedule => { + const clone = new Schedule(this); + return clone; + }; } diff --git a/src/lib/definitions/sleep.ts b/src/lib/definitions/sleep.ts index f9c45b0c..cfbd4a35 100644 --- a/src/lib/definitions/sleep.ts +++ b/src/lib/definitions/sleep.ts @@ -27,4 +27,13 @@ export class Sleep { constructor(model: any) { Object.assign(this, model); } + + /** + * Normalize the value of each property by recursively deleting properties whose value is equal to its default value. Does not modify the object state. + * @returns {Specification.Sleep} without deleted properties. + */ + normalize = (): Sleep => { + const clone = new Sleep(this); + return clone; + }; } diff --git a/src/lib/definitions/sleepstate.ts b/src/lib/definitions/sleepstate.ts index 0895db1c..58843cee 100644 --- a/src/lib/definitions/sleepstate.ts +++ b/src/lib/definitions/sleepstate.ts @@ -15,32 +15,20 @@ */ import { End } from './end'; -import { Error } from './error'; import { Metadata } from './metadata'; -import { Statedatafilter } from './statedatafilter'; import { Transition } from './transition'; import { cleanSourceModelProperty, normalizeEnd, - normalizeOnErrors, normalizeTransition, - normalizeUsedForCompensation, overwriteEnd, overwriteMetadata, - overwriteOnErrors, - overwriteStateDataFilter, - overwriteTimeoutWithStateExecTimeout, overwriteTransition, setEndValueIfNoTransition, } from './utils'; -import { StateExecTimeout } from './stateExecTimeout'; export class Sleepstate { sourceModel?: Sleepstate; - /** - * Unique State id - */ - id?: string; /** * State name */ @@ -48,41 +36,15 @@ export class Sleepstate { /** * State type */ - type?: 'sleep'; - /** - * State end definition - */ - end?: boolean | End; - /** - * State data filter - */ - stateDataFilter?: Statedatafilter; + type: 'sleep'; + end?: End; /** * Duration (ISO 8601 duration format) to sleep */ duration?: string; - /** - * State specific timeouts - */ - timeouts?: { - stateExecTimeout?: StateExecTimeout; - }; - /** - * States error handling definitions - */ - onErrors?: Error[]; - /** - * Next transition of the workflow after the workflow sleep - */ + transition?: string | Transition; - /** - * Unique Name of a workflow state which is responsible for compensation of this state - */ - compensatedBy?: string; - /** - * If true, this state is used to compensate another state. Default is false - */ - usedForCompensation?: boolean; + metadata?: /* Metadata information */ Metadata; constructor(model: any) { @@ -92,14 +54,10 @@ export class Sleepstate { id: undefined, name: undefined, type: 'sleep', - usedForCompensation: false, }; Object.assign(this, defaultModel, model); overwriteEnd(this); - overwriteStateDataFilter(this); - overwriteTimeoutWithStateExecTimeout(this); - overwriteOnErrors(this); overwriteTransition(this); overwriteMetadata(this); } @@ -112,9 +70,7 @@ export class Sleepstate { const clone = new Sleepstate(this); normalizeEnd(clone); - normalizeOnErrors(clone); normalizeTransition(clone); - normalizeUsedForCompensation(clone, this.sourceModel); setEndValueIfNoTransition(clone); cleanSourceModelProperty(clone); diff --git a/src/lib/definitions/specification.ts b/src/lib/definitions/specification.ts index c163f755..436473bd 100644 --- a/src/lib/definitions/specification.ts +++ b/src/lib/definitions/specification.ts @@ -29,7 +29,7 @@ export * from './databasedswitchstate'; export * from './defaultconditiondef'; export * from './end'; export * from './enddatacondition'; -export * from './enddeventcondition'; +export * from './endeventcondition'; export * from './error'; export * from './errordef'; export * from './eventbasedswitchstate'; @@ -37,6 +37,7 @@ export * from './eventdatafilter'; export * from './eventdef'; export * from './eventref'; export * from './eventstate'; +export * from './extension'; export * from './foreachstate'; export * from './function'; export * from './functionref'; @@ -52,7 +53,6 @@ export * from './schedule'; export * from './sleep'; export * from './sleepstate'; export * from './startdef'; -export * from './stateExecTimeout'; export * from './statedatafilter'; export * from './subflowref'; export * from './timeouts'; diff --git a/src/lib/definitions/startdef.ts b/src/lib/definitions/startdef.ts index 088494a9..e53c520f 100644 --- a/src/lib/definitions/startdef.ts +++ b/src/lib/definitions/startdef.ts @@ -20,7 +20,7 @@ export class Startdef { /** * Name of the starting workflow state */ - stateName: string; + stateName?: string; /** * Define the time/repeating intervals or cron at which workflow instances should be automatically started. */ @@ -31,4 +31,13 @@ export class Startdef { overwriteSchedule(this); } + + /** + * Normalize the value of each property by recursively deleting properties whose value is equal to its default value. Does not modify the object state. + * @returns {Specification.Startdef} without deleted properties. + */ + normalize = (): Startdef => { + const clone = new Startdef(this); + return clone; + }; } diff --git a/src/lib/definitions/statedatafilter.ts b/src/lib/definitions/statedatafilter.ts index f55234ec..e7487ab6 100644 --- a/src/lib/definitions/statedatafilter.ts +++ b/src/lib/definitions/statedatafilter.ts @@ -27,4 +27,12 @@ export class Statedatafilter { constructor(model: any) { Object.assign(this, model); } + /** + * Normalize the value of each property by recursively deleting properties whose value is equal to its default value. Does not modify the object state. + * @returns {Specification.Statedatafilter} without deleted properties. + */ + normalize = (): Statedatafilter => { + const clone = new Statedatafilter(this); + return clone; + }; } diff --git a/src/lib/definitions/subflowref.ts b/src/lib/definitions/subflowref.ts index 5becbe40..9cc3445d 100644 --- a/src/lib/definitions/subflowref.ts +++ b/src/lib/definitions/subflowref.ts @@ -25,7 +25,7 @@ export class Subflowref { /** * Version of the sub-workflow to be invoked */ - version?: string; + version?: string; // ^(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-]+)*))?$ /** * If invoke is 'async', specifies how subflow execution should behave when parent workflow completes. Default is 'terminate' */ diff --git a/src/lib/definitions/timeouts.ts b/src/lib/definitions/timeouts.ts index 0f07aca0..d6c54908 100644 --- a/src/lib/definitions/timeouts.ts +++ b/src/lib/definitions/timeouts.ts @@ -14,21 +14,15 @@ * limitations under the License. */ import { WorkflowExecTimeout } from './workflowExecTimeout'; -import { ActionExecTimeout, BranchExecTimeout, EventTimeout } from './types'; -import { - cleanSourceModelProperty, - normalizeWorkflowExecTimeout, - overwriteStateExecTimeout, - overwriteWorkflowExecTimeout, -} from './utils'; -import { StateExecTimeout } from './stateExecTimeout'; +import { ActionExecTimeout, BranchExecTimeout, EventTimeout, StateExecTimeout } from './types'; +import { cleanSourceModelProperty, normalizeWorkflowExecTimeout, overwriteWorkflowExecTimeout } from './utils'; export class Timeouts { sourceModel?: Timeouts; workflowExecTimeout?: WorkflowExecTimeout; - stateExecTimeout?: StateExecTimeout; - actionExecTimeout?: /* Single actions definition execution timeout duration (ISO 8601 duration format) */ ActionExecTimeout; - branchExecTimeout?: /* Single branch execution timeout duration (ISO 8601 duration format) */ BranchExecTimeout; + stateExecTimeout?: /* Workflow state execution timeout duration (ISO 8601 duration format) */ StateExecTimeout; + actionExecTimeout?: /* Action execution timeout duration (ISO 8601 duration format) */ ActionExecTimeout; + branchExecTimeout?: /* Branch execution timeout duration (ISO 8601 duration format) */ BranchExecTimeout; eventTimeout?: /* Timeout duration to wait for consuming defined events (ISO 8601 duration format) */ EventTimeout; constructor(model: any) { @@ -36,7 +30,6 @@ export class Timeouts { Object.assign(this, model); overwriteWorkflowExecTimeout(this); - overwriteStateExecTimeout(this); } /** diff --git a/src/lib/definitions/types.ts b/src/lib/definitions/types.ts index b6055c16..87254a23 100644 --- a/src/lib/definitions/types.ts +++ b/src/lib/definitions/types.ts @@ -21,7 +21,7 @@ import { Function } from './function'; import { Databasedswitchstate } from './databasedswitchstate'; import { Eventbasedswitchstate } from './eventbasedswitchstate'; import { Transitioneventcondition } from './transitioneventcondition'; -import { Enddeventcondition } from './enddeventcondition'; +import { Endeventcondition } from './endeventcondition'; import { Eventstate } from './eventstate'; import { Operationstate } from './operationstate'; import { Parallelstate } from './parallelstate'; @@ -33,6 +33,7 @@ import { Sleepstate } from './sleepstate'; import { Authdef } from './authdef'; import { Errordef } from './errordef'; import { Specification } from './index'; +import { Extension } from './extension'; export type CorrelationDefs = [ /* CloudEvent correlation definition */ CorrelationDef, @@ -53,7 +54,7 @@ export type Switchstate /* Permits transitions to other states based on data con export type Eventcondition /* Switch state data event condition */ = | Transitioneventcondition - | /* Switch state data event condition */ Enddeventcondition; + | /* Switch state data event condition */ Endeventcondition; export type States = [ ( @@ -79,12 +80,12 @@ export type States = [ ]; /** - * Single branch execution timeout duration (ISO 8601 duration format) + * Branch execution timeout duration (ISO 8601 duration format) */ export type BranchExecTimeout = string; /** - * Single actions definition execution timeout duration (ISO 8601 duration format) + * Action execution timeout duration (ISO 8601 duration format) */ export type ActionExecTimeout = string; @@ -102,3 +103,10 @@ export type Auth = string /* uri */ | [Authdef, ...Authdef[]]; export type Errors = string /* uri */ | [Errordef, ...Errordef[]]; export type Properties = Specification.Basicpropsdef | Specification.Bearerpropsdef | Specification.Oauth2propsdef; + +export type Extensions = string /* uri */ | [Extension, ...Extension[]]; + +/** + * Workflow state execution timeout duration (ISO 8601 duration format) + */ +export type StateExecTimeout = string; diff --git a/src/lib/definitions/utils.ts b/src/lib/definitions/utils.ts index 1fab6f52..47684c04 100644 --- a/src/lib/definitions/utils.ts +++ b/src/lib/definitions/utils.ts @@ -76,7 +76,7 @@ export function overwriteDefaultCondition(object: { defaultCondition?: Specifica /** * Modify the provided object, set the value to 'eventConditions' property as an instance of Specification.Eventcondition[] class - * Throws an error if provided value is neither a Transitioneventcondition nor a Enddeventcondition + * Throws an error if provided value is neither a Transitioneventcondition nor a Endeventcondition * @param object to set/overwrite the property */ export function overwriteEventConditions(object: { eventConditions: Specification.Eventcondition[] }): void { @@ -87,11 +87,11 @@ export function overwriteEventConditions(object: { eventConditions: Specificatio } if (eventCondition.end) { - return new Specification.Enddeventcondition(eventCondition); + return new Specification.Endeventcondition(eventCondition); } throw new Error( - `Provided value is neither Transitioneventcondition nor Enddeventcondition \n data= ${eventCondition} ` + `Provided value is neither Transitioneventcondition nor Endeventcondition \n data= ${eventCondition} ` ); }); } @@ -190,6 +190,18 @@ export function overwriteErrors(object: { errors?: Specification.Errors }) { } } +/** + * Modify the provided object, set the value to 'extensions' property as an instance of Specification.Auth class + * @param object to set/overwrite the property + */ +export function overwriteExtensions(object: { extensions?: Specification.Extensions }) { + if (Array.isArray(object.extensions)) { + object.extensions = (object.extensions as Specification.Extension[]).map( + (f) => new Specification.Extension(f) + ) as Specification.Extensions; + } +} + /** * Modify the provided object, set the value to 'auth' property as an instance of Specification.Auth class * @param object to set/overwrite the property @@ -307,14 +319,6 @@ export function overwriteWorkflowExecTimeout(object: { object.workflowExecTimeout && new Specification.WorkflowExecTimeout(object.workflowExecTimeout); } -/** - * Modify the provided object, set the value to 'stateExecTimeout' property as an instance of Specification.StateExecTimeout class - * @param object to set/overwrite the property - */ -export function overwriteStateExecTimeout(object: { stateExecTimeout?: Specification.StateExecTimeout }): void { - object.stateExecTimeout = object.stateExecTimeout && new Specification.StateExecTimeout(object.stateExecTimeout); -} - /** * Modify the provided object, set the value to 'eventDataFilter' property as an instance of Specification.Eventdatafilter class * @param object to set/overwrite the property @@ -441,24 +445,6 @@ export function overwritePropertyAsPlainType(property: string, object: any): voi } } -/** - * Modify the provided object, set the value to 'timeouts.stateExecTimeout' property as an instance of Specification.StateExecTimeout class, - * for the rest of the properties the value is cloned - * @param object to set/overwrite the property - */ -export function overwriteTimeoutWithStateExecTimeout(object: { - timeouts?: { - stateExecTimeout?: Specification.StateExecTimeout; - }; -}): void { - overwritePropertyAsPlainType('timeouts', object); - - const timeouts = object.timeouts!; - if (timeouts && isObject(timeouts.stateExecTimeout)) { - timeouts.stateExecTimeout = new Specification.StateExecTimeout(timeouts.stateExecTimeout); - } -} - /** * Modify the provided object, set the value to 'timeouts' property as an instance of Specification.Timeouts class * @param object to set/overwrite the property @@ -591,6 +577,18 @@ export function normalizeStates(object: { states: Specification.States }) { }) as Specification.States; } +/** + * Modify the provided object by normalizing the 'extensions' property. + * @param object to be modified + */ +export function normalizeExtensions(object: { extensions?: Specification.Extensions }) { + if (Array.isArray(object.extensions)) { + object.extensions = object.extensions.map((extension) => { + return extension.normalize(); + }) as Specification.Extensions; + } +} + /** * Modify the provided object by normalizing the 'auth' property. * @param object to be modified @@ -659,7 +657,8 @@ export function normalizeFunctionRef(object: { functionRef?: string | Specificat /** * Modify the provided object by normalizing the 'actionMode' property. - * @param object to be modified + * @param target to be modified + * @param source */ export function normalizeActionMode(target: { actionMode?: string }, source?: { actionMode?: string }) { if (!source?.actionMode) { @@ -670,6 +669,7 @@ export function normalizeActionMode(target: { actionMode?: string }, source?: { /** * Modify the provided object by normalizing the 'completionType' property. * @param object to be modified + * @param source */ export function normalizeCompletionType(object: { completionType?: string }, source?: { completionType?: string }) { if (!source?.completionType) { @@ -680,6 +680,7 @@ export function normalizeCompletionType(object: { completionType?: string }, sou /** * Modify the provided object by normalizing the 'usedForCompensation' property. * @param object to be modified + * @param source */ export function normalizeUsedForCompensation( object: { usedForCompensation?: boolean }, @@ -693,6 +694,7 @@ export function normalizeUsedForCompensation( /** * Modify the provided object by normalizing the 'mode' property. * @param object to be modified + * @param source */ export function normalizeMode(object: { mode?: string }, source?: { mode?: string }) { if (!source?.mode) { @@ -703,6 +705,7 @@ export function normalizeMode(object: { mode?: string }, source?: { mode?: strin /** * Modify the provided object by normalizing the 'compensate' property. * @param object to be modified + * @param source */ export function normalizeCompensate(object: { compensate?: boolean }, source?: { compensate?: boolean }) { if (source?.compensate === undefined) { @@ -713,6 +716,7 @@ export function normalizeCompensate(object: { compensate?: boolean }, source?: { /** * Modify the provided object by normalizing the 'scheme' property. * @param object to be modified + * @param source */ export function normalizeScheme(object: { scheme?: string }, source?: { scheme?: string }) { if (!source?.scheme) { @@ -723,6 +727,7 @@ export function normalizeScheme(object: { scheme?: string }, source?: { scheme?: /** * Modify the provided object by normalizing the 'terminate' property. * @param object to be modified + * @param source */ export function normalizeTerminate(object: { terminate?: boolean }, source?: { terminate?: boolean }) { if (source?.terminate === undefined) { @@ -733,6 +738,7 @@ export function normalizeTerminate(object: { terminate?: boolean }, source?: { t /** * Modify the provided object by normalizing the 'exclusive' property. * @param object to be modified + * @param source */ export function normalizeExclusive(object: { exclusive?: boolean }, source?: { exclusive?: boolean }) { if (source?.exclusive === undefined) { @@ -743,6 +749,7 @@ export function normalizeExclusive(object: { exclusive?: boolean }, source?: { e /** * Modify the provided object by normalizing the 'keepActive' property. * @param object to be modified + * @param source */ export function normalizeKeepActive(object: { keepActive?: boolean }, source?: { keepActive?: boolean }) { if (source?.keepActive === undefined) { @@ -753,6 +760,7 @@ export function normalizeKeepActive(object: { keepActive?: boolean }, source?: { /** * Modify the provided object by normalizing the 'expressionLang' property. * @param object to be modified + * @param source */ export function normalizeExpressionLang(object: { expressionLang?: string }, source?: { expressionLang?: string }) { if (!source?.expressionLang) { @@ -763,6 +771,7 @@ export function normalizeExpressionLang(object: { expressionLang?: string }, sou /** * Modify the provided object by normalizing the 'interrupt' property. * @param object to be modified + * @param source */ export function normalizeInterrupt(object: { interrupt?: boolean }, source?: { interrupt?: boolean }) { if (source?.interrupt === undefined) { @@ -773,6 +782,7 @@ export function normalizeInterrupt(object: { interrupt?: boolean }, source?: { i /** * Modify the provided object by normalizing the 'type' property. * @param object to be modified + * @param source */ export function normalizeType(object: { type?: string }, source?: { type?: string }) { if (!source?.type) { @@ -783,6 +793,7 @@ export function normalizeType(object: { type?: string }, source?: { type?: strin /** * Modify the provided object by normalizing the 'invoke' property. * @param object to be modified + * @param source */ export function normalizeInvoke(object: { invoke?: string }, source?: { invoke?: string }) { if (!source?.invoke) { @@ -793,6 +804,7 @@ export function normalizeInvoke(object: { invoke?: string }, source?: { invoke?: /** * Modify the provided object by normalizing the 'onParentComplete' property. * @param object to be modified + * @param source */ export function normalizeOnParentComplete( object: { onParentComplete?: 'continue' | 'terminate' }, @@ -806,6 +818,7 @@ export function normalizeOnParentComplete( /** * Modify the provided object by normalizing the 'kind' property. * @param object to be modified + * @param source */ export function normalizeKind(object: { kind?: string }, source?: { kind?: string }) { if (!source?.kind) { @@ -816,6 +829,7 @@ export function normalizeKind(object: { kind?: string }, source?: { kind?: strin /** * Modify the provided object by normalizing the 'dataOnly' property. * @param object to be modified + * @param source */ export function normalizeDataOnly(object: { dataOnly?: boolean }, source?: { dataOnly?: boolean }) { if (source?.dataOnly === undefined) { diff --git a/src/lib/definitions/workflow.ts b/src/lib/definitions/workflow.ts index 52889226..39c0a2ce 100644 --- a/src/lib/definitions/workflow.ts +++ b/src/lib/definitions/workflow.ts @@ -27,6 +27,7 @@ import { normalizeAuth, normalizeEvents, normalizeExpressionLang, + normalizeExtensions, normalizeFunctions, normalizeKeepActive, normalizeStates, @@ -34,6 +35,7 @@ import { overwriteAuth, overwriteErrors, overwriteEvents, + overwriteExtensions, overwriteFunctions, overwriteMetadata, overwritePropertyAsPlainType, @@ -42,7 +44,7 @@ import { overwriteStates, overwriteTimeouts, } from './utils'; -import { Auth, Errors, Events, Functions, Retries, Secrets, States } from './types'; +import { Auth, Errors, Events, Extensions, Functions, Retries, Secrets, States } from './types'; export class Workflow { sourceModel?: Workflow; @@ -65,7 +67,7 @@ export class Workflow { /** * Workflow version */ - version?: string; + version?: string; // ^(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-]+)*))?$ /** * List of helpful terms describing the workflows intended purpose, subject areas, or other important qualities */ @@ -73,14 +75,11 @@ export class Workflow { dataInputSchema?: | string | { - /** - * URI of the JSON Schema used to validate the workflow data input - */ - schema: string; + schema: any; /** * Determines if workflow execution should continue if there are validation errors */ - failOnValidationErrors: boolean; + failOnValidationErrors?: boolean; }; secrets?: Secrets; constants?: @@ -112,6 +111,7 @@ export class Workflow { autoRetries?: boolean; retries?: Retries; auth?: Auth; + extensions?: Extensions; /** * State definitions */ @@ -147,6 +147,7 @@ export class Workflow { overwriteEvents(this); overwriteFunctions(this); overwriteRetries(this); + overwriteExtensions(this); overwriteAuth(this); overwriteStates(this); } @@ -198,6 +199,7 @@ export class Workflow { normalizeEvents(clone); normalizeFunctions(clone); normalizeAuth(clone); + normalizeExtensions(clone); normalizeStates(clone); cleanSourceModelProperty(clone); diff --git a/src/lib/diagram/mermaidState.ts b/src/lib/diagram/mermaidState.ts index d912a9c0..bf550dd1 100644 --- a/src/lib/diagram/mermaidState.ts +++ b/src/lib/diagram/mermaidState.ts @@ -13,8 +13,8 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -import {Specification} from '../definitions'; -import {isObject} from '../utils'; +import { Specification } from '../definitions'; +import { isObject } from '../utils'; export class MermaidState { constructor( @@ -114,7 +114,7 @@ export class MermaidState { ...this.naturalTransition(stateName, transitionEventCondition.transition, transitionEventCondition.eventRef) ); - const endEventCondition = eventCondition as Specification.Enddeventcondition; + const endEventCondition = eventCondition as Specification.Endeventcondition; if (endEventCondition.end) { transitions.push(this.transitionDescription(stateName, '[*]')); } diff --git a/src/lib/schema/README.md b/src/lib/schema/README.md deleted file mode 100644 index 86d82d3e..00000000 --- a/src/lib/schema/README.md +++ /dev/null @@ -1,3 +0,0 @@ -# Auto generated notice - -This directory and its content has been generated automatically. Do not modify its content, it WILL be lost. \ No newline at end of file diff --git a/src/lib/schema/__merged.json b/src/lib/schema/__merged.json index eaf79d82..e26c6c5d 100644 --- a/src/lib/schema/__merged.json +++ b/src/lib/schema/__merged.json @@ -2004,6 +2004,29 @@ "additionalProperties": false, "required": [] }, + "errordef": { + "type": "object", + "properties": { + "name": { + "type": "string", + "description": "Domain-specific error name", + "minLength": 1 + }, + "code": { + "type": "string", + "description": "Error code. Can be used in addition to the name to help runtimes resolve to technical errors/exceptions. Should not be defined if error is set to '*'", + "minLength": 1 + }, + "description": { + "type": "string", + "description": "Error description" + } + }, + "additionalProperties": false, + "required": [ + "name" + ] + }, "retrydef": { "type": "object", "properties": { @@ -2059,48 +2082,6 @@ "maxAttempts" ] }, - "function": { - "type": "object", - "properties": { - "name": { - "type": "string", - "description": "Unique function name", - "minLength": 1 - }, - "operation": { - "type": "string", - "description": "If type is `rest`, #. If type is `asyncapi`, #. If type is `rpc`, ##. If type is `graphql`, ##. If type is `odata`, #. If type is `expression`, defines the workflow expression.", - "minLength": 1 - }, - "type": { - "type": "string", - "description": "Defines the function type. Is either `rest`, `asyncapi, `rpc`, `graphql`, `odata`, `expression`, or `custom`. Default is `rest`", - "enum": [ - "rest", - "asyncapi", - "rpc", - "graphql", - "odata", - "expression", - "custom" - ], - "default": "rest" - }, - "authRef": { - "type": "string", - "description": "References an auth definition name to be used to access to resource defined in the operation parameter", - "minLength": 1 - }, - "metadata": { - "$ref": "#/definitions/metadata" - } - }, - "additionalProperties": false, - "required": [ - "name", - "operation" - ] - }, "metadata": { "type": "object", "description": "Metadata information", @@ -2153,150 +2134,168 @@ ] }, "basicpropsdef": { - "oneOf": [ - { + "type": "object", + "description": "Basic auth information", + "properties": { + "username": { "type": "string", - "description": "Expression referencing a workflow secret that contains all needed basic auth info" + "description": "String or a workflow expression. Contains the user name", + "minLength": 1 }, - { - "type": "object", - "description": "Basic auth information", - "properties": { - "username": { - "type": "string", - "description": "String or a workflow expression. Contains the user name", - "minLength": 1 - }, - "password": { - "type": "string", - "description": "String or a workflow expression. Contains the user password", - "minLength": 1 - }, - "metadata": { - "$ref": "#/definitions/metadata" - } - }, - "required": [ - "username", - "password" - ], - "additionalProperties": false + "password": { + "type": "string", + "description": "String or a workflow expression. Contains the user password", + "minLength": 1 + }, + "metadata": { + "$ref": "#/definitions/metadata" } - ] + }, + "required": [ + "username", + "password" + ], + "additionalProperties": false }, "bearerpropsdef": { - "oneOf": [ - { + "type": "object", + "description": "Bearer auth information", + "properties": { + "token": { "type": "string", - "description": "Expression referencing a workflow secret that contains all needed bearer auth info" + "description": "String or a workflow expression. Contains the token", + "minLength": 1 }, - { - "type": "object", - "description": "Bearer auth information", - "properties": { - "token": { - "type": "string", - "description": "String or a workflow expression. Contains the token", - "minLength": 1 - }, - "metadata": { - "$ref": "#/definitions/metadata" - } - }, - "required": [ - "token" - ], - "additionalProperties": false + "metadata": { + "$ref": "#/definitions/metadata" } - ] + }, + "required": [ + "token" + ], + "additionalProperties": false }, "oauth2propsdef": { - "oneOf": [ - { + "type": "object", + "description": "OAuth2 information", + "properties": { + "authority": { "type": "string", - "description": "Expression referencing a workflow secret that contains all needed OAuth2 auth info" + "description": "String or a workflow expression. Contains the authority information", + "minLength": 1 }, - { - "type": "object", - "description": "OAuth2 information", - "properties": { - "authority": { - "type": "string", - "description": "String or a workflow expression. Contains the authority information", - "minLength": 1 - }, - "grantType": { - "type": "string", - "description": "Defines the grant type", - "enum": [ - "password", - "clientCredentials", - "tokenExchange" - ], - "additionalItems": false - }, - "clientId": { - "type": "string", - "description": "String or a workflow expression. Contains the client identifier", - "minLength": 1 - }, - "clientSecret": { - "type": "string", - "description": "Workflow secret or a workflow expression. Contains the client secret", - "minLength": 1 - }, - "scopes": { - "type": "array", - "description": "Array containing strings or workflow expressions. Contains the OAuth2 scopes", - "items": { - "type": "string" - }, - "minItems": 1, - "additionalItems": false - }, - "username": { - "type": "string", - "description": "String or a workflow expression. Contains the user name. Used only if grantType is 'resourceOwner'", - "minLength": 1 - }, - "password": { - "type": "string", - "description": "String or a workflow expression. Contains the user password. Used only if grantType is 'resourceOwner'", - "minLength": 1 - }, - "audiences": { - "type": "array", - "description": "Array containing strings or workflow expressions. Contains the OAuth2 audiences", - "items": { - "type": "string" - }, - "minItems": 1, - "additionalItems": false - }, - "subjectToken": { - "type": "string", - "description": "String or a workflow expression. Contains the subject token", - "minLength": 1 - }, - "requestedSubject": { - "type": "string", - "description": "String or a workflow expression. Contains the requested subject", - "minLength": 1 - }, - "requestedIssuer": { - "type": "string", - "description": "String or a workflow expression. Contains the requested issuer", - "minLength": 1 - }, - "metadata": { - "$ref": "#/definitions/metadata" - } + "grantType": { + "type": "string", + "description": "Defines the grant type", + "enum": [ + "password", + "clientCredentials", + "tokenExchange" + ], + "additionalItems": false + }, + "clientId": { + "type": "string", + "description": "String or a workflow expression. Contains the client identifier", + "minLength": 1 + }, + "clientSecret": { + "type": "string", + "description": "Workflow secret or a workflow expression. Contains the client secret", + "minLength": 1 + }, + "scopes": { + "type": "array", + "description": "Array containing strings or workflow expressions. Contains the OAuth2 scopes", + "items": { + "type": "string" }, - "required": [ - "grantType", - "clientId" - ] + "minItems": 1, + "additionalItems": false + }, + "username": { + "type": "string", + "description": "String or a workflow expression. Contains the user name. Used only if grantType is 'resourceOwner'", + "minLength": 1 + }, + "password": { + "type": "string", + "description": "String or a workflow expression. Contains the user password. Used only if grantType is 'resourceOwner'", + "minLength": 1 + }, + "audiences": { + "type": "array", + "description": "Array containing strings or workflow expressions. Contains the OAuth2 audiences", + "items": { + "type": "string" + }, + "minItems": 1, + "additionalItems": false + }, + "subjectToken": { + "type": "string", + "description": "String or a workflow expression. Contains the subject token", + "minLength": 1 + }, + "requestedSubject": { + "type": "string", + "description": "String or a workflow expression. Contains the requested subject", + "minLength": 1 + }, + "requestedIssuer": { + "type": "string", + "description": "String or a workflow expression. Contains the requested issuer", + "minLength": 1 + }, + "metadata": { + "$ref": "#/definitions/metadata" } + }, + "required": [ + "grantType", + "clientId" + ] + }, + "function": { + "type": "object", + "properties": { + "name": { + "type": "string", + "description": "Unique function name", + "minLength": 1 + }, + "operation": { + "type": "string", + "description": "If type is `rest`, #. If type is `asyncapi`, #. If type is `rpc`, ##. If type is `graphql`, ##. If type is `odata`, #. If type is `expression`, defines the workflow expression.", + "minLength": 1 + }, + "type": { + "type": "string", + "description": "Defines the function type. Is either `rest`, `asyncapi, `rpc`, `graphql`, `odata`, `expression`, or `custom`. Default is `rest`", + "enum": [ + "rest", + "asyncapi", + "rpc", + "graphql", + "odata", + "expression", + "custom" + ], + "default": "rest" + }, + "authRef": { + "type": "string", + "description": "References an auth definition name to be used to access to resource defined in the operation parameter", + "minLength": 1 + }, + "metadata": { + "$ref": "#/definitions/metadata" + } + }, + "additionalProperties": false, + "required": [ + "name", + "operation" ] }, "workflowExecTimeout": { @@ -2463,29 +2462,6 @@ "contextAttributeName" ] }, - "errordef": { - "type": "object", - "properties": { - "name": { - "type": "string", - "description": "Domain-specific error name", - "minLength": 1 - }, - "code": { - "type": "string", - "description": "Error code. Can be used in addition to the name to help runtimes resolve to technical errors/exceptions. Should not be defined if error is set to '*'", - "minLength": 1 - }, - "description": { - "type": "string", - "description": "Error description" - } - }, - "additionalProperties": false, - "required": [ - "name" - ] - }, "secrets": { "oneOf": [ { diff --git a/src/lib/schema/auth.json b/src/lib/schema/auth.json index 8be26b4e..253ab07b 100644 --- a/src/lib/schema/auth.json +++ b/src/lib/schema/auth.json @@ -71,151 +71,124 @@ ] }, "basicpropsdef": { - "oneOf": [ - { - "type": "string", - "description": "Expression referencing a workflow secret that contains all needed basic auth info" - }, - { - "type": "object", - "description": "Basic auth information", - "properties": { - "username": { - "type": "string", - "description": "String or a workflow expression. Contains the user name", - "minLength": 1 - }, - "password": { - "type": "string", - "description": "String or a workflow expression. Contains the user password", - "minLength": 1 - }, - "metadata": { - "$ref": "common.json#/definitions/metadata" - } + "type": "object", + "description": "Basic auth information", + "properties": { + "username": { + "type": "string", + "description": "String or a workflow expression. Contains the user name", + "minLength": 1 }, - "required": [ - "username", - "password" - ], - "additionalProperties": false - } - ] + "password": { + "type": "string", + "description": "String or a workflow expression. Contains the user password", + "minLength": 1 + }, + "metadata": { + "$ref": "common.json#/definitions/metadata" + } + }, + "required": [ + "username", + "password" + ], + "additionalProperties": false }, "bearerpropsdef": { - "oneOf": [ - { - "type": "string", - "description": "Expression referencing a workflow secret that contains all needed bearer auth info" - }, - { - "type": "object", - "description": "Bearer auth information", - "properties": { - "token": { - "type": "string", - "description": "String or a workflow expression. Contains the token", - "minLength": 1 - }, - "metadata": { - "$ref": "common.json#/definitions/metadata" - } + "type": "object", + "description": "Bearer auth information", + "properties": { + "token": { + "type": "string", + "description": "String or a workflow expression. Contains the token", + "minLength": 1 }, - "required": [ - "token" - ], - "additionalProperties": false - } - ] + "metadata": { + "$ref": "common.json#/definitions/metadata" + } + }, + "required": [ + "token" + ], + "additionalProperties": false }, "oauth2propsdef": { - "oneOf": [ - { - "type": "string", - "description": "Expression referencing a workflow secret that contains all needed OAuth2 auth info" - }, - { - "type": "object", - "description": "OAuth2 information", - "properties": { - "authority": { - "type": "string", - "description": "String or a workflow expression. Contains the authority information", - "minLength": 1 - }, - "grantType": { - "type": "string", - "description": "Defines the grant type", - "enum": [ - "password", - "clientCredentials", - "tokenExchange" - ], - "additionalItems": false - }, - "clientId": { - "type": "string", - "description": "String or a workflow expression. Contains the client identifier", - "minLength": 1 - }, - "clientSecret": { - "type": "string", - "description": "Workflow secret or a workflow expression. Contains the client secret", - "minLength": 1 - }, - "scopes": { - "type": "array", - "description": "Array containing strings or workflow expressions. Contains the OAuth2 scopes", - "items": { - "type": "string" - }, - "minItems": 1, - "additionalItems": false - }, - "username": { - "type": "string", - "description": "String or a workflow expression. Contains the user name. Used only if grantType is 'resourceOwner'", - "minLength": 1 - }, - "password": { - "type": "string", - "description": "String or a workflow expression. Contains the user password. Used only if grantType is 'resourceOwner'", - "minLength": 1 - }, - "audiences": { - "type": "array", - "description": "Array containing strings or workflow expressions. Contains the OAuth2 audiences", - "items": { - "type": "string" - }, - "minItems": 1, - "additionalItems": false - }, - "subjectToken": { - "type": "string", - "description": "String or a workflow expression. Contains the subject token", - "minLength": 1 - }, - "requestedSubject": { - "type": "string", - "description": "String or a workflow expression. Contains the requested subject", - "minLength": 1 - }, - "requestedIssuer": { - "type": "string", - "description": "String or a workflow expression. Contains the requested issuer", - "minLength": 1 - }, - "metadata": { - "$ref": "common.json#/definitions/metadata" - } + "type": "object", + "description": "OAuth2 information", + "properties": { + "authority": { + "type": "string", + "description": "String or a workflow expression. Contains the authority information", + "minLength": 1 }, - "required": [ - "grantType", - "clientId" - ] - } - ] + "grantType": { + "type": "string", + "description": "Defines the grant type", + "enum": [ + "password", + "clientCredentials", + "tokenExchange" + ], + "additionalItems": false + }, + "clientId": { + "type": "string", + "description": "String or a workflow expression. Contains the client identifier", + "minLength": 1 + }, + "clientSecret": { + "type": "string", + "description": "Workflow secret or a workflow expression. Contains the client secret", + "minLength": 1 + }, + "scopes": { + "type": "array", + "description": "Array containing strings or workflow expressions. Contains the OAuth2 scopes", + "items": { + "type": "string" + }, + "minItems": 1, + "additionalItems": false + }, + "username": { + "type": "string", + "description": "String or a workflow expression. Contains the user name. Used only if grantType is 'resourceOwner'", + "minLength": 1 + }, + "password": { + "type": "string", + "description": "String or a workflow expression. Contains the user password. Used only if grantType is 'resourceOwner'", + "minLength": 1 + }, + "audiences": { + "type": "array", + "description": "Array containing strings or workflow expressions. Contains the OAuth2 audiences", + "items": { + "type": "string" + }, + "minItems": 1, + "additionalItems": false + }, + "subjectToken": { + "type": "string", + "description": "String or a workflow expression. Contains the subject token", + "minLength": 1 + }, + "requestedSubject": { + "type": "string", + "description": "String or a workflow expression. Contains the requested subject", + "minLength": 1 + }, + "requestedIssuer": { + "type": "string", + "description": "String or a workflow expression. Contains the requested issuer", + "minLength": 1 + }, + "metadata": { + "$ref": "common.json#/definitions/metadata" + } + }, + "required": ["grantType", "clientId"] } } } \ No newline at end of file diff --git a/src/lib/schema/errors.json b/src/lib/schema/errors.json index c855548f..52088967 100644 --- a/src/lib/schema/errors.json +++ b/src/lib/schema/errors.json @@ -50,4 +50,4 @@ ] } } -} \ No newline at end of file +} diff --git a/src/lib/schema/events.json b/src/lib/schema/events.json index 61d16e1c..59ef767d 100644 --- a/src/lib/schema/events.json +++ b/src/lib/schema/events.json @@ -74,22 +74,21 @@ "additionalProperties": false, "if": { "properties": { - "kind": { - "const": "consumed" + "source": { + "type": "null" } } }, "then": { "required": [ "name", - "source", "type" ] }, "else": { "required": [ "name", - "type" + "source" ] } }, diff --git a/src/lib/schema/extensions/kpi.json b/src/lib/schema/extensions/kpi.json new file mode 100644 index 00000000..08a81382 --- /dev/null +++ b/src/lib/schema/extensions/kpi.json @@ -0,0 +1,289 @@ +{ + "$id": "https://serverlessworkflow.io/schemas/0.8/extensions/kpi.json", + "$schema": "http://json-schema.org/draft-07/schema#", + "description": "Serverless Workflow specification - KPIs Extension Schema", + "type": "object", + "definitions": { + "kpi": { + "type": "object", + "description": "Serverless Workflow KPI Extension", + "properties": { + "extensionid": { + "type": "string", + "default": "workflow-kpi-extension", + "description": "Extension unique identifier" + }, + "workflowid": { + "type": "string", + "minLength": 1, + "description": "Workflow definition unique identifier (workflow id property)" + }, + "workflowVersions": { + "type": "array", + "description": "Workflow versions. If not defined, applies to all workflow instances (regardless of their associated workflow version)", + "items": { + "type": "string" + } + }, + "currency": { + "type": "string", + "default": "USD", + "description": "Unit for all cost-based KPI parameters. Default 'USD'" + }, + "events": { + "type": "array", + "description": "Events KPIs", + "items": { + "type": "object", + "$ref": "#/definitions/eventskpi" + } + }, + "functions": { + "type": "array", + "description": "Functions KPIs", + "items": { + "type": "object", + "$ref": "#/definitions/functionskpi" + } + }, + "states": { + "type": "array", + "description": "States KPIs", + "items": { + "type": "object", + "$ref": "#/definitions/stateskpi" + } + }, + "workflow": { + "description": "Workflow KPIs", + "$ref": "#/definitions/workflowkpi" + } + }, + "required": [ + "extensionid", + "workflowid" + ] + }, + "eventskpi": { + "type": "object", + "properties": { + "for": { + "type": "string", + "description": "References an unique event name in the defined workflow events" + }, + "per": { + "description": "Define the kpi thresholds in terms of time and/or num of workflow instances", + "$ref": "#/definitions/thresholds" + }, + "maxConsumed": { + "type": "string", + "description": "If event kind is 'consumed', the max amount of times this event is consumed" + }, + "minConsumed": { + "type": "string", + "description": "If event kind is 'consumed', the min amount of times this event is consumed" + }, + "avgConsumed": { + "type": "string", + "description": "If event kind is 'consumed', the avg amount of times this event is consumed" + }, + "maxProduced": { + "type": "string", + "description": "If event kind is 'produced', the max amount of times this event is produced" + }, + "minProduced": { + "type": "string", + "description": "If event kind is 'produced', the min amount times this event is produced" + }, + "avgProduced": { + "type": "string", + "description": "If event kind is 'produced', the avg amount of times this event is produced" + } + }, + "required": [ + "for", + "per" + ] + }, + "functionskpi": { + "type": "object", + "allOf": [ + { + "properties": { + "for": { + "type": "string", + "description": "References an unique function name in the defined workflow functions" + }, + "per": { + "description": "Define the kpi thresholds in terms of time and/or num of workflow instances", + "$ref": "#/definitions/thresholds" + }, + "maxErrors": { + "type": "string", + "description": "Max number of errors during function invocation" + }, + "maxRetry": { + "type": "string", + "description": "Max number of retries done for this function invocation" + }, + "maxTimeout": { + "type": "string", + "description": "Max number of times the function timeout time was reached" + } + } + }, + { + "$ref": "#/definitions/invocationkpis" + }, + { + "$ref": "#/definitions/costkpis" + } + ], + "required": [ + "for", + "per" + ] + }, + "stateskpi": { + "type": "object", + "allOf": [ + { + "properties": { + "for": { + "type": "string", + "description": "References an unique state name in the defined workflow events" + }, + "per": { + "description": "Define the kpi thresholds in terms of time and/or num of workflow instances", + "$ref": "#/definitions/thresholds" + } + } + }, + { + "$ref": "#/definitions/execkpis" + }, + { + "$ref": "#/definitions/durationkpis" + }, + { + "$ref": "#/definitions/costkpis" + } + ], + "required": [ + "for", + "per" + ] + }, + "workflowkpi": { + "type": "object", + "allOf": [ + { + "properties": { + "per": { + "description": "Define the kpi thresholds in terms of time and/or num of workflow instances", + "$ref": "#/definitions/thresholds" + } + } + }, + { + "$ref": "#/definitions/invocationkpis" + }, + { + "$ref": "#/definitions/durationkpis" + }, + { + "$ref": "#/definitions/costkpis" + } + ], + "required": [ + "per" + ] + }, + "thresholds": { + "type": "object", + "properties": { + "time": { + "type": "string", + "default": "PT1D", + "description": "ISO_8601 time. 1 day default" + }, + "instances": { + "type": "integer", + "minimum": 1, + "default": 1, + "description": "Number of workflow instances" + } + }, + "required": [ + ] + }, + "costkpis": { + "type": "object", + "properties": { + "maxCost": { + "type": "string", + "description": "Max cost" + }, + "minCost": { + "type": "string", + "description": "Min cost" + }, + "avgCost": { + "type": "string", + "description": "Avg cost" + } + } + }, + "invocationkpis": { + "type": "object", + "properties": { + "maxInvoked": { + "type": "string", + "description": "Max number of invocation times" + }, + "minInvoked": { + "type": "string", + "description": "Min number of invocation times" + }, + "avgInvoked": { + "type": "string", + "description": "Avg number of invocation times" + } + } + }, + "durationkpis": { + "type": "object", + "properties": { + "maxDuration": { + "type": "string", + "description": "ISO 8601. Max duration" + }, + "minDuration": { + "type": "string", + "description": "ISO 8601. Min duration" + }, + "avgDuration": { + "type": "string", + "description": "ISO 8601. Avg duration" + } + } + }, + "execkpis": { + "type": "object", + "properties": { + "maxExec": { + "type": "string", + "description": "Max exec number" + }, + "minExec": { + "type": "string", + "description": "Min exec numbe" + }, + "avgExec": { + "type": "string", + "description": "Avg exec number" + } + } + } + } +} \ No newline at end of file diff --git a/src/lib/schema/extensions/ratelimiting.json b/src/lib/schema/extensions/ratelimiting.json new file mode 100644 index 00000000..a7bc6f2c --- /dev/null +++ b/src/lib/schema/extensions/ratelimiting.json @@ -0,0 +1,73 @@ +{ + "$id": "https://serverlessworkflow.io/schemas/0.8/extensions/ratelimiting.json", + "$schema": "http://json-schema.org/draft-07/schema#", + "description": "Serverless Workflow specification - Various workflow rate limiting settings", + "type": "object", + "definitions": { + "ratelimiting": { + "type": "object", + "description": "Serverless Workflow Rate Limiting Extension", + "properties": { + "extensionid": { + "type": "string", + "default": "workflow-ratelimiting-extension", + "description": "Extension unique identifier" + }, + "workflowid": { + "type": "string", + "minLength": 1, + "description": "Workflow definition unique identifier (workflow id property)" + }, + "workflowVersions": { + "type": "array", + "description": "Workflow versions. If not defined, applies to all workflow instances (regardless of their associated workflow version)", + "items": { + "type": "string" + } + }, + "singleInstance": { + "description": "Rate Limit settings per single instance of a workflow with provided workflowid", + "$ref": "#/definitions/ratelimits" + }, + "allInstances": { + "description": "Rate Limit settings across all instance of a workflow with provided workflowid", + "$ref": "#/definitions/ratelimits" + } + }, + "required": [ + "extensionid", + "workflowid" + ] + }, + "ratelimits": { + "type": "object", + "properties": { + "maxActionsPerSecond": { + "type": "number", + "default": 0, + "description": "Sets the rate limiting on number of actions that can be executed per second. Notice that the number is represented as number type, so that you can set it to less than 1 if needed. For example, set the number to 0.1 means workflow actions can be executed once every 10 seconds. Default zero value means 'unlimited'" + }, + "maxConcurrentActions": { + "type": "number", + "default": 100, + "description": "Maximum number of actions that can be executed in parallel" + }, + "maxProducedEventsPerSecond": { + "type": "number", + "default": 0, + "description": "Sets the rate limiting on number of events that can be produced per second. Notice that the number is represented as number type, so that you can set it to less than 1 if needed. For example, set the number to 0.1 means workflow can produce events once every 10 seconds. Default zero value means 'unlimited'" + }, + "maxStates": { + "type": "integer", + "default": 0, + "description": "Maximum number of workflow states that should be executed. Default is zero, meaning unlimited." + }, + "maxTransitions": { + "type": "integer", + "default": 0, + "description": "Maximum number of workflow transitions that should be executed. Default is zero, meaning unlimited." + } + } + } + } +} \ No newline at end of file diff --git a/src/lib/schema/functions.json b/src/lib/schema/functions.json index 08f3b345..a29bd2d7 100644 --- a/src/lib/schema/functions.json +++ b/src/lib/schema/functions.json @@ -54,9 +54,32 @@ "default": "rest" }, "authRef": { - "type": "string", - "description": "References an auth definition name to be used to access to resource defined in the operation parameter", - "minLength": 1 + "oneOf": [ + { + "type": "string", + "description": "References the auth definition to be used to invoke the operation", + "minLength": 1 + }, + { + "type": "object", + "description": "Configures both the auth definition used to retrieve the operation's resource and the auth definition used to invoke said operation", + "properties":{ + "resource":{ + "type": "string", + "description": "References an auth definition to be used to access the resource defined in the operation parameter", + "minLength": 1 + }, + "invocation":{ + "type": "string", + "description": "References an auth definition to be used to invoke the operation" + } + }, + "additionalProperties": false, + "required": [ + "resource" + ] + } + ] }, "metadata": { "$ref": "common.json#/definitions/metadata" diff --git a/src/lib/schema/odata.json b/src/lib/schema/odata.json new file mode 100644 index 00000000..958cd99c --- /dev/null +++ b/src/lib/schema/odata.json @@ -0,0 +1,81 @@ +{ + "$id": "https://serverlessworkflow.io/schemas/0.8/odata.json", + "$schema": "http://json-schema.org/draft-07/schema#", + "description": "Serverless Workflow specification - OData command options schema", + "type": "object", + "key": { + "type": "string", + "description": "The unique identifier of the single entry to query", + "minLength": 1 + }, + "queryOptions":{ + "$ref": "#/definitions/queryoptions" + }, + "definitions": { + "queryoptions": { + "type": "object", + "properties": { + "filter": { + "type": "string", + "description": "The $filter system query option allows clients to filter the set of resources that are addressed by a request URL. $filter specifies conditions that MUST be met by a resource for it to be returned in the set of matching resources", + "minLength": 1 + }, + "expand": { + "type": "string", + "description": "The $expand system query option allows clients to request related resources when a resource that satisfies a particular request is retrieved", + "minLength": 1 + }, + "select": { + "type": "string", + "description": "The $select system query option allows clients to requests a limited set of information for each entity or complex type identified by the ResourcePath and other System Query Options like $filter, $top, $skip etc. The $select query option is often used in conjunction with the $expand query option, to first increase the scope of the resource graph returned ($expand) and then selectively prune that resource graph ($select)", + "minLength": 1 + }, + "orderBy": { + "type": "string", + "description": "The $orderby system query option allows clients to request resource in a particular order", + "minLength": 1 + }, + "top": { + "type": "integer", + "description": "The $top system query option allows clients a required number of resources. Usually used in conjunction with the $skip query options", + "minLength": 1 + }, + "skip": { + "type": "integer", + "description": "The $skip system query option allows clients to skip a given number of resources. Usually used in conjunction with the $top query options", + "minLength": 1 + }, + "count": { + "type": "boolean", + "description": "The $count system query option allows clients to request a count of the matching resources included with the resources in the response" + }, + "search": { + "type": "string", + "description": "The $search system query option allows clients to request items within a collection matching a free-text search expression", + "minLength": 1 + }, + "format": { + "type": "string", + "description": "The $format system query option if supported allows clients to request a response in a particular format", + "minLength": 1 + }, + "compute": { + "type": "string", + "description": "The $compute system query option allows clients to define computed properties that can be used in a $select or within a $filter or $orderby expression.", + "minLength": 1 + }, + "index": { + "type": "string", + "description": "The $index system query option allows clients to do a positional insert into a collection annotated with using the Core.PositionalInsert term (see http://docs.oasis-open.org/odata/odata/v4.01/odata-v4.01-part2-url-conventions.html#VocCore)", + "minLength": 1 + }, + "schemaVersion": { + "type": "string", + "description": "The $schemaversion system query option allows clients to specify the version of the schema against which the request is made. The semantics of $schemaversion is covered in the OData-Protocol (http://docs.oasis-open.org/odata/odata/v4.01/odata-v4.01-part2-url-conventions.html#odata) document.", + "minLength": 1 + } + }, + "additionalProperties": false + } + } +} \ No newline at end of file diff --git a/src/lib/schema/retries.json b/src/lib/schema/retries.json index 743b758c..1690abd7 100644 --- a/src/lib/schema/retries.json +++ b/src/lib/schema/retries.json @@ -82,4 +82,4 @@ ] } } -} \ No newline at end of file +} diff --git a/src/lib/schema/timeouts.json b/src/lib/schema/timeouts.json index 3bd565af..95f30ce5 100644 --- a/src/lib/schema/timeouts.json +++ b/src/lib/schema/timeouts.json @@ -73,42 +73,18 @@ ] }, "stateExecTimeout": { - "oneOf": [ - { - "type": "string", - "description": "Total state execution timeout (including retries) (ISO 8601 duration format)", - "minLength": 1 - }, - { - "type": "object", - "description": "Workflow default timeouts", - "properties": { - "single": { - "type": "string", - "description": "Single state execution timeout, not including retries (ISO 8601 duration format)", - "minLength": 1 - }, - "total": { - "type": "string", - "description": "Total state execution timeout, including retries (ISO 8601 duration format)", - "minLength": 1 - } - }, - "additionalProperties": false, - "required": [ - "total" - ] - } - ] + "type": "string", + "description": "Workflow state execution timeout duration (ISO 8601 duration format)", + "minLength": 1 }, "actionExecTimeout": { "type": "string", - "description": "Single actions definition execution timeout duration (ISO 8601 duration format)", + "description": "Action execution timeout duration (ISO 8601 duration format)", "minLength": 1 }, "branchExecTimeout": { "type": "string", - "description": "Single branch execution timeout duration (ISO 8601 duration format)", + "description": "Branch execution timeout duration (ISO 8601 duration format)", "minLength": 1 }, "eventTimeout": { diff --git a/src/lib/schema/types/README.md b/src/lib/schema/types/README.md index 86d82d3e..7d5a8642 100644 --- a/src/lib/schema/types/README.md +++ b/src/lib/schema/types/README.md @@ -1,3 +1,2 @@ # Auto generated notice - This directory and its content has been generated automatically. Do not modify its content, it WILL be lost. \ No newline at end of file diff --git a/src/lib/definitions/stateExecTimeout.ts b/src/lib/schema/types/index.ts similarity index 66% rename from src/lib/definitions/stateExecTimeout.ts rename to src/lib/schema/types/index.ts index f872a266..1754cf0f 100644 --- a/src/lib/definitions/stateExecTimeout.ts +++ b/src/lib/schema/types/index.ts @@ -14,17 +14,4 @@ * limitations under the License. */ -export class StateExecTimeout { - /** - * Single state execution timeout, not including retries (ISO 8601 duration format) - */ - single?: string; - /** - * Total state execution timeout, including retries (ISO 8601 duration format) - */ - total: string; - - constructor(model: any) { - Object.assign(this, model); - } -} +export * as Specification from './workflow'; diff --git a/src/lib/schema/types/workflow.ts b/src/lib/schema/types/workflow.ts index e4e98bba..dbde7db2 100644 --- a/src/lib/schema/types/workflow.ts +++ b/src/lib/schema/types/workflow.ts @@ -38,7 +38,7 @@ export type Workflow /* Serverless Workflow specification - workflow schema */ = /** * Workflow version */ - version?: string; + version?: string; // ^(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-]+)*))?$ /** * List of helpful terms describing the workflows intended purpose, subject areas, or other important qualities */ @@ -46,14 +46,11 @@ export type Workflow /* Serverless Workflow specification - workflow schema */ = dataInputSchema?: | string | { - /** - * URI of the JSON Schema used to validate the workflow data input - */ - schema: string; + schema: any; /** * Determines if workflow execution should continue if there are validation errors */ - failOnValidationErrors: boolean; + failOnValidationErrors?: boolean; }; secrets?: Secrets; constants?: @@ -85,6 +82,7 @@ export type Workflow /* Serverless Workflow specification - workflow schema */ = autoRetries?: boolean; retries?: Retries; auth?: Auth; + extensions?: Extensions; /** * State definitions */ @@ -131,7 +129,7 @@ export type Workflow /* Serverless Workflow specification - workflow schema */ = /** * Workflow version */ - version?: string; + version?: string; // ^(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-]+)*))?$ /** * List of helpful terms describing the workflows intended purpose, subject areas, or other important qualities */ @@ -139,14 +137,11 @@ export type Workflow /* Serverless Workflow specification - workflow schema */ = dataInputSchema?: | string | { - /** - * URI of the JSON Schema used to validate the workflow data input - */ - schema: string; + schema: any; /** * Determines if workflow execution should continue if there are validation errors */ - failOnValidationErrors: boolean; + failOnValidationErrors?: boolean; }; secrets?: Secrets; constants?: @@ -178,6 +173,7 @@ export type Workflow /* Serverless Workflow specification - workflow schema */ = autoRetries?: boolean; retries?: Retries; auth?: Auth; + extensions?: Extensions; /** * State definitions */ @@ -206,10 +202,6 @@ export type Workflow /* Serverless Workflow specification - workflow schema */ = }; export type Action = | { - /** - * Unique action identifier - */ - id?: string; /** * Unique action definition name */ @@ -237,10 +229,6 @@ export type Action = condition?: string; } | { - /** - * Unique action identifier - */ - id?: string; /** * Unique action definition name */ @@ -268,10 +256,6 @@ export type Action = condition?: string; } | { - /** - * Unique action identifier - */ - id?: string; /** * Unique action definition name */ @@ -299,10 +283,9 @@ export type Action = condition?: string; }; /** - * Single actions definition execution timeout duration (ISO 8601 duration format) + * Action execution timeout duration (ISO 8601 duration format) */ export type ActionExecTimeout = string; - export interface Actiondatafilter { /** * Workflow expression that selects state data that the state action can use @@ -321,9 +304,7 @@ export interface Actiondatafilter { */ toStateData?: string; } - export type Auth = string /* uri */ | [Authdef, ...Authdef[]]; - export interface Authdef { /** * Unique auth definition name @@ -333,32 +314,36 @@ export interface Authdef { * Defines the auth type */ scheme?: 'basic' | 'bearer' | 'oauth2'; - properties: string | Basicpropsdef | Bearerpropsdef | Oauth2propsdef; + properties: + | string + | /* Basic auth information */ Basicpropsdef + | /* Bearer auth information */ Bearerpropsdef + | /* OAuth2 information */ Oauth2propsdef; +} +/** + * Basic auth information + */ +export interface Basicpropsdef { + /** + * String or a workflow expression. Contains the user name + */ + username: string; + /** + * String or a workflow expression. Contains the user password + */ + password: string; + metadata?: /* Metadata information */ Metadata; +} +/** + * Bearer auth information + */ +export interface Bearerpropsdef { + /** + * String or a workflow expression. Contains the token + */ + token: string; + metadata?: /* Metadata information */ Metadata; } - -export type Basicpropsdef = - | string - | { - /** - * String or a workflow expression. Contains the user name - */ - username: string; - /** - * String or a workflow expression. Contains the user password - */ - password: string; - metadata?: /* Metadata information */ Metadata; - }; -export type Bearerpropsdef = - | string - | { - /** - * String or a workflow expression. Contains the token - */ - token: string; - metadata?: /* Metadata information */ Metadata; - }; - /** * Branch Definition */ @@ -371,28 +356,22 @@ export interface Branch { * State specific timeouts */ timeouts?: { - actionExecTimeout?: /* Single actions definition execution timeout duration (ISO 8601 duration format) */ ActionExecTimeout; - branchExecTimeout?: /* Single branch execution timeout duration (ISO 8601 duration format) */ BranchExecTimeout; + actionExecTimeout?: /* Action execution timeout duration (ISO 8601 duration format) */ ActionExecTimeout; + branchExecTimeout?: /* Branch execution timeout duration (ISO 8601 duration format) */ BranchExecTimeout; }; /** * Actions to be executed in this branch */ actions: Action[]; } - /** - * Single branch execution timeout duration (ISO 8601 duration format) + * Branch execution timeout duration (ISO 8601 duration format) */ export type BranchExecTimeout = string; - /** * This state performs an action, then waits for the callback event that denotes completion of the action */ export interface Callbackstate { - /** - * Unique state id - */ - id?: string; /** * State name */ @@ -413,8 +392,8 @@ export interface Callbackstate { * State specific timeouts */ timeouts?: { - stateExecTimeout?: StateExecTimeout; - actionExecTimeout?: /* Single actions definition execution timeout duration (ISO 8601 duration format) */ ActionExecTimeout; + stateExecTimeout?: /* Workflow state execution timeout duration (ISO 8601 duration format) */ StateExecTimeout; + actionExecTimeout?: /* Action execution timeout duration (ISO 8601 duration format) */ ActionExecTimeout; eventTimeout?: /* Timeout duration to wait for consuming defined events (ISO 8601 duration format) */ EventTimeout; }; /** @@ -447,7 +426,6 @@ export interface Callbackstate { usedForCompensation?: boolean; metadata?: /* Metadata information */ Metadata; } - export type Continueasdef = | string | { @@ -458,7 +436,7 @@ export type Continueasdef = /** * Version of the workflow to continue execution as */ - version?: string; + version?: string; // ^(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-]+)*))?$ /** * If string type, an expression which selects parts of the states data output to become the workflow data input of continued execution. If object type, a custom object to become the workflow data input of the continued execution */ @@ -472,7 +450,6 @@ export type Continueasdef = */ workflowExecTimeout?: WorkflowExecTimeout; }; - /** * CloudEvent correlation definition */ @@ -486,7 +463,6 @@ export interface CorrelationDef { */ contextAttributeValue?: string; } - export type Crondef = | string | { @@ -499,15 +475,10 @@ export type Crondef = */ validUntil?: string; }; - /** * Permits transitions to other states based on data conditions */ export interface Databasedswitchstate { - /** - * Unique State id - */ - id?: string; /** * State name */ @@ -524,7 +495,7 @@ export interface Databasedswitchstate { * State specific timeouts */ timeouts?: { - stateExecTimeout?: StateExecTimeout; + stateExecTimeout?: /* Workflow state execution timeout duration (ISO 8601 duration format) */ StateExecTimeout; }; /** * Defines conditions evaluated against state data @@ -548,7 +519,6 @@ export interface Databasedswitchstate { usedForCompensation?: boolean; metadata?: /* Metadata information */ Metadata; } - export type Datacondition /* Switch state data based condition */ = | Transitiondatacondition | /* Switch state data based condition */ Enddatacondition; @@ -557,10 +527,18 @@ export type Datacondition /* Switch state data based condition */ = */ export type Defaultconditiondef /* DefaultCondition definition. Can be either a transition or end definition */ = | { + /** + * The optional name of the default condition, used solely for display purposes + */ + name?: string; transition: Transition; end?: End; } | { + /** + * The optional name of the default condition, used solely for display purposes + */ + name?: string; transition?: Transition; end: End; }; @@ -581,7 +559,6 @@ export type End = compensate?: boolean; continueAs?: Continueasdef; }; - /** * Switch state data based condition */ @@ -600,11 +577,10 @@ export interface Enddatacondition { end: End; metadata?: /* Metadata information */ Metadata; } - /** * Switch state data event condition */ -export interface Enddeventcondition { +export interface Endeventcondition { /** * Event condition name */ @@ -623,7 +599,6 @@ export interface Enddeventcondition { eventDataFilter?: Eventdatafilter; metadata?: /* Metadata information */ Metadata; } - export type Error = | { /** @@ -673,7 +648,6 @@ export type Error = transition?: Transition; end: End; }; - export interface Errordef { /** * Domain-specific error name @@ -688,21 +662,15 @@ export interface Errordef { */ description?: string; } - export type Errors = string /* uri */ | [Errordef, ...Errordef[]]; /** * Timeout duration to wait for consuming defined events (ISO 8601 duration format) */ export type EventTimeout = string; - /** * Permits transitions to other states based on events */ export interface Eventbasedswitchstate { - /** - * Unique State id - */ - id?: string; /** * State name */ @@ -719,7 +687,7 @@ export interface Eventbasedswitchstate { * State specific timeouts */ timeouts?: { - stateExecTimeout?: StateExecTimeout; + stateExecTimeout?: /* Workflow state execution timeout duration (ISO 8601 duration format) */ StateExecTimeout; eventTimeout?: /* Timeout duration to wait for consuming defined events (ISO 8601 duration format) */ EventTimeout; }; /** @@ -744,11 +712,9 @@ export interface Eventbasedswitchstate { usedForCompensation?: boolean; metadata?: /* Metadata information */ Metadata; } - export type Eventcondition /* Switch state data event condition */ = | Transitioneventcondition - | /* Switch state data event condition */ Enddeventcondition; - + | /* Switch state data event condition */ Endeventcondition; export interface Eventdatafilter { /** * If set to false, event payload is not added/merged to state data. In this case 'data' and 'toStateData' should be ignored. Default is true. @@ -763,7 +729,6 @@ export interface Eventdatafilter { */ toStateData?: string; } - export interface Eventdef { /** * Unique event name @@ -797,7 +762,6 @@ export interface Eventdef { */ metadata?: /* Metadata information */ Metadata; } - /** * Event References */ @@ -805,17 +769,17 @@ export interface Eventref { /** * Reference to the unique name of a 'produced' event definition */ - triggerEventRef: string; + produceEventRef: string; /** * Reference to the unique name of a 'consumed' event definition */ - resultEventRef: string; + consumeEventRef?: string; /** * Maximum amount of time (ISO 8601 format) to wait for the result event. If not defined it should default to the actionExecutionTimeout */ - resultEventTimeout?: string; + consumeEventTimeout?: string; /** - * If string type, an expression which selects parts of the states data output to become the data (payload) of the event referenced by 'triggerEventRef'. If object type, a custom object to become the data (payload) of the event referenced by 'triggerEventRef'. + * If string type, an expression which selects parts of the states data output to become the data (payload) of the event referenced by 'produceEventRef'. If object type, a custom object to become the data (payload) of the event referenced by 'produceEventRef'. */ data?: | string @@ -828,12 +792,7 @@ export interface Eventref { contextAttributes?: { [name: string]: string; }; - /** - * Specifies if the function should be invoked sync or async. Default is sync. - */ - invoke?: 'sync' | 'async'; } - export type Events = string /* uri */ | [Eventdef, ...Eventdef[]]; /** * This state is used to wait for events from event sources, then consumes them and invoke one or more actions to run in sequence or parallel @@ -841,10 +800,6 @@ export type Events = string /* uri */ | [Eventdef, ...Eventdef[]]; export type Eventstate = /* This state is used to wait for events from event sources, then consumes them and invoke one or more actions to run in sequence or parallel */ | { - /** - * Unique State id - */ - id?: string; /** * State name */ @@ -865,8 +820,8 @@ export type Eventstate = * State specific timeouts */ timeouts?: { - stateExecTimeout?: StateExecTimeout; - actionExecTimeout?: /* Single actions definition execution timeout duration (ISO 8601 duration format) */ ActionExecTimeout; + stateExecTimeout?: /* Workflow state execution timeout duration (ISO 8601 duration format) */ StateExecTimeout; + actionExecTimeout?: /* Action execution timeout duration (ISO 8601 duration format) */ ActionExecTimeout; eventTimeout?: /* Timeout duration to wait for consuming defined events (ISO 8601 duration format) */ EventTimeout; }; stateDataFilter?: Statedatafilter; @@ -883,10 +838,6 @@ export type Eventstate = metadata?: /* Metadata information */ Metadata; } | { - /** - * Unique State id - */ - id?: string; /** * State name */ @@ -907,8 +858,8 @@ export type Eventstate = * State specific timeouts */ timeouts?: { - stateExecTimeout?: StateExecTimeout; - actionExecTimeout?: /* Single actions definition execution timeout duration (ISO 8601 duration format) */ ActionExecTimeout; + stateExecTimeout?: /* Workflow state execution timeout duration (ISO 8601 duration format) */ StateExecTimeout; + actionExecTimeout?: /* Action execution timeout duration (ISO 8601 duration format) */ ActionExecTimeout; eventTimeout?: /* Timeout duration to wait for consuming defined events (ISO 8601 duration format) */ EventTimeout; }; stateDataFilter?: Statedatafilter; @@ -924,15 +875,21 @@ export type Eventstate = compensatedBy?: string; metadata?: /* Metadata information */ Metadata; }; - +export interface Extension { + /** + * Unique extension id + */ + extensionId: string; + /** + * URI to a resource containing this workflow extension definitions (json or yaml) + */ + resource: string; +} +export type Extensions = string /* uri */ | [Extension, ...Extension[]]; /** * Execute a set of defined actions or workflows for each element of a data array */ export interface Foreachstate { - /** - * Unique State id - */ - id?: string; /** * State name */ @@ -969,8 +926,8 @@ export interface Foreachstate { * State specific timeouts */ timeouts?: { - stateExecTimeout?: StateExecTimeout; - actionExecTimeout?: /* Single actions definition execution timeout duration (ISO 8601 duration format) */ ActionExecTimeout; + stateExecTimeout?: /* Workflow state execution timeout duration (ISO 8601 duration format) */ StateExecTimeout; + actionExecTimeout?: /* Action execution timeout duration (ISO 8601 duration format) */ ActionExecTimeout; }; /** * State data filter @@ -998,7 +955,6 @@ export interface Foreachstate { mode?: 'sequential' | 'parallel'; metadata?: /* Metadata information */ Metadata; } - export interface Function { /** * Unique function name @@ -1012,13 +968,20 @@ export interface Function { * Defines the function type. Is either `rest`, `asyncapi, `rpc`, `graphql`, `odata`, `expression`, or `custom`. Default is `rest` */ type?: 'rest' | 'asyncapi' | 'rpc' | 'graphql' | 'odata' | 'expression' | 'custom'; - /** - * References an auth definition name to be used to access to resource defined in the operation parameter - */ - authRef?: string; + authRef?: + | string + | { + /** + * References an auth definition to be used to access the resource defined in the operation parameter + */ + resource: string; + /** + * References an auth definition to be used to invoke the operation + */ + invocation?: string; + }; metadata?: /* Metadata information */ Metadata; } - export type Functionref = | string | { @@ -1042,15 +1005,10 @@ export type Functionref = invoke?: 'sync' | 'async'; }; export type Functions = string /* uri */ | [Function, ...Function[]]; - /** * Inject static data into state data. Does not perform any actions */ export interface Injectstate { - /** - * Unique state id - */ - id?: string; /** * State name */ @@ -1069,12 +1027,6 @@ export interface Injectstate { data?: { [key: string]: any; }; - /** - * State specific timeouts - */ - timeouts?: { - stateExecTimeout?: StateExecTimeout; - }; /** * State data filter */ @@ -1093,64 +1045,62 @@ export interface Injectstate { usedForCompensation?: boolean; metadata?: /* Metadata information */ Metadata; } - /** * Metadata information */ export interface Metadata { [name: string]: string; } - -export type Oauth2propsdef = - | string - | { - /** - * String or a workflow expression. Contains the authority information - */ - authority?: string; - /** - * Defines the grant type - */ - grantType: 'password' | 'clientCredentials' | 'tokenExchange'; - /** - * String or a workflow expression. Contains the client identifier - */ - clientId: string; - /** - * Workflow secret or a workflow expression. Contains the client secret - */ - clientSecret?: string; - /** - * Array containing strings or workflow expressions. Contains the OAuth2 scopes - */ - scopes?: [string, ...string[]]; - /** - * String or a workflow expression. Contains the user name. Used only if grantType is 'resourceOwner' - */ - username?: string; - /** - * String or a workflow expression. Contains the user password. Used only if grantType is 'resourceOwner' - */ - password?: string; - /** - * Array containing strings or workflow expressions. Contains the OAuth2 audiences - */ - audiences?: [string, ...string[]]; - /** - * String or a workflow expression. Contains the subject token - */ - subjectToken?: string; - /** - * String or a workflow expression. Contains the requested subject - */ - requestedSubject?: string; - /** - * String or a workflow expression. Contains the requested issuer - */ - requestedIssuer?: string; - metadata?: /* Metadata information */ Metadata; - }; - +/** + * OAuth2 information + */ +export interface Oauth2propsdef { + /** + * String or a workflow expression. Contains the authority information + */ + authority?: string; + /** + * Defines the grant type + */ + grantType: 'password' | 'clientCredentials' | 'tokenExchange'; + /** + * String or a workflow expression. Contains the client identifier + */ + clientId: string; + /** + * Workflow secret or a workflow expression. Contains the client secret + */ + clientSecret?: string; + /** + * Array containing strings or workflow expressions. Contains the OAuth2 scopes + */ + scopes?: [string, ...string[]]; + /** + * String or a workflow expression. Contains the user name. Used only if grantType is 'resourceOwner' + */ + username?: string; + /** + * String or a workflow expression. Contains the user password. Used only if grantType is 'resourceOwner' + */ + password?: string; + /** + * Array containing strings or workflow expressions. Contains the OAuth2 audiences + */ + audiences?: [string, ...string[]]; + /** + * String or a workflow expression. Contains the subject token + */ + subjectToken?: string; + /** + * String or a workflow expression. Contains the requested subject + */ + requestedSubject?: string; + /** + * String or a workflow expression. Contains the requested issuer + */ + requestedIssuer?: string; + metadata?: /* Metadata information */ Metadata; +} export interface Onevents { /** * References one or more unique event names in the defined workflow events @@ -1169,15 +1119,10 @@ export interface Onevents { */ eventDataFilter?: Eventdatafilter; } - /** * Defines actions be performed. Does not wait for incoming events */ export interface Operationstate { - /** - * Unique State id - */ - id?: string; /** * State name */ @@ -1206,8 +1151,8 @@ export interface Operationstate { * State specific timeouts */ timeouts?: { - stateExecTimeout?: StateExecTimeout; - actionExecTimeout?: /* Single actions definition execution timeout duration (ISO 8601 duration format) */ ActionExecTimeout; + stateExecTimeout?: /* Workflow state execution timeout duration (ISO 8601 duration format) */ StateExecTimeout; + actionExecTimeout?: /* Action execution timeout duration (ISO 8601 duration format) */ ActionExecTimeout; }; /** * States error handling definitions @@ -1227,15 +1172,10 @@ export interface Operationstate { usedForCompensation?: boolean; metadata?: /* Metadata information */ Metadata; } - /** * Consists of a number of states that are executed in parallel */ export interface Parallelstate { - /** - * Unique State id - */ - id?: string; /** * State name */ @@ -1256,8 +1196,8 @@ export interface Parallelstate { * State specific timeouts */ timeouts?: { - stateExecTimeout?: StateExecTimeout; - branchExecTimeout?: /* Single branch execution timeout duration (ISO 8601 duration format) */ BranchExecTimeout; + stateExecTimeout?: /* Workflow state execution timeout duration (ISO 8601 duration format) */ StateExecTimeout; + branchExecTimeout?: /* Branch execution timeout duration (ISO 8601 duration format) */ BranchExecTimeout; }; /** * Branch Definitions @@ -1289,7 +1229,6 @@ export interface Parallelstate { usedForCompensation?: boolean; metadata?: /* Metadata information */ Metadata; } - /** * Produce an event and set its data */ @@ -1313,9 +1252,7 @@ export interface Produceeventdef { [name: string]: string; }; } - export type Retries = string /* uri */ | [Retrydef, ...Retrydef[]]; - export interface Retrydef { /** * Unique retry strategy name @@ -1346,7 +1283,6 @@ export interface Retrydef { */ jitter?: number | string; } - export type Schedule = | string | /* Start state schedule definition */ ( @@ -1405,85 +1341,60 @@ export type Sleep = */ after: string; }; - /** * Causes the workflow execution to sleep for a specified duration */ -export interface Sleepstate { - /** - * Unique State id - */ - id?: string; - /** - * State name - */ - name?: string; - /** - * State type - */ - type?: 'sleep'; - /** - * State end definition - */ - end?: End; - /** - * State data filter - */ - stateDataFilter?: Statedatafilter; - /** - * Duration (ISO 8601 duration format) to sleep - */ - duration?: string; - /** - * State specific timeouts - */ - timeouts?: { - stateExecTimeout?: StateExecTimeout; - }; - /** - * States error handling definitions - */ - onErrors?: Error[]; - /** - * Next transition of the workflow after the workflow sleep - */ - transition?: Transition; - /** - * Unique Name of a workflow state which is responsible for compensation of this state - */ - compensatedBy?: string; - /** - * If true, this state is used to compensate another state. Default is false - */ - usedForCompensation?: boolean; - metadata?: /* Metadata information */ Metadata; -} - -export type Startdef = - | string +export type Sleepstate /* Causes the workflow execution to sleep for a specified duration */ = | { /** - * Name of the starting workflow state + * State name */ - stateName: string; + name: string; /** - * Define the time/repeating intervals or cron at which workflow instances should be automatically started. + * State type */ - schedule: Schedule; + type: 'sleep'; + end: End; + /** + * Duration (ISO 8601 duration format) to sleep + */ + duration: string; + transition?: Transition; + metadata?: /* Metadata information */ Metadata; + } + | { + /** + * State name + */ + name: string; + /** + * State type + */ + type: 'sleep'; + end?: End; + /** + * Duration (ISO 8601 duration format) to sleep + */ + duration: string; + transition: Transition; + metadata?: /* Metadata information */ Metadata; }; -export type StateExecTimeout = +export type Startdef = | string | { /** - * Single state execution timeout, not including retries (ISO 8601 duration format) + * Name of the starting workflow state */ - single?: string; + stateName?: string; /** - * Total state execution timeout, including retries (ISO 8601 duration format) + * Define the time/repeating intervals or cron at which workflow instances should be automatically started. */ - total: string; + schedule: Schedule; }; - +/** + * Workflow state execution timeout duration (ISO 8601 duration format) + */ +export type StateExecTimeout = string; export interface Statedatafilter { /** * Workflow expression to filter the state data input @@ -1494,7 +1405,6 @@ export interface Statedatafilter { */ output?: string; } - export type Subflowref = | string | { @@ -1505,7 +1415,7 @@ export type Subflowref = /** * Version of the sub-workflow to be invoked */ - version?: string; + version?: string; // ^(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-]+)*))?$ /** * If invoke is 'async', specifies how subflow execution should behave when parent workflow completes. Default is 'terminate' */ @@ -1522,9 +1432,9 @@ export type Timeouts = | string /* uri */ | { workflowExecTimeout?: WorkflowExecTimeout; - stateExecTimeout?: StateExecTimeout; - actionExecTimeout?: /* Single actions definition execution timeout duration (ISO 8601 duration format) */ ActionExecTimeout; - branchExecTimeout?: /* Single branch execution timeout duration (ISO 8601 duration format) */ BranchExecTimeout; + stateExecTimeout?: /* Workflow state execution timeout duration (ISO 8601 duration format) */ StateExecTimeout; + actionExecTimeout?: /* Action execution timeout duration (ISO 8601 duration format) */ ActionExecTimeout; + branchExecTimeout?: /* Branch execution timeout duration (ISO 8601 duration format) */ BranchExecTimeout; eventTimeout?: /* Timeout duration to wait for consuming defined events (ISO 8601 duration format) */ EventTimeout; }; export type Transition = @@ -1543,7 +1453,6 @@ export type Transition = */ compensate?: boolean; }; - /** * Switch state data based condition */ @@ -1562,7 +1471,6 @@ export interface Transitiondatacondition { transition: Transition; metadata?: /* Metadata information */ Metadata; } - /** * Switch state data event condition */ @@ -1585,7 +1493,6 @@ export interface Transitioneventcondition { eventDataFilter?: Eventdatafilter; metadata?: /* Metadata information */ Metadata; } - export type WorkflowExecTimeout = | string | { diff --git a/src/lib/schema/validation/README.md b/src/lib/schema/validation/README.md deleted file mode 100644 index 86d82d3e..00000000 --- a/src/lib/schema/validation/README.md +++ /dev/null @@ -1,3 +0,0 @@ -# Auto generated notice - -This directory and its content has been generated automatically. Do not modify its content, it WILL be lost. \ No newline at end of file diff --git a/src/lib/schema/validation/validators-paths.ts b/src/lib/schema/validation/validators-paths.ts deleted file mode 100644 index 50161dd3..00000000 --- a/src/lib/schema/validation/validators-paths.ts +++ /dev/null @@ -1,88 +0,0 @@ -/* - * Copyright 2021-Present The Serverless 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, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/** - * A map of type names and their corresponding schema - */ -export const validatorsPaths: [string, string][] = [ - ['Workflow', 'https://serverlessworkflow.io/schemas/0.8/workflow.json'], - ['Sleep', 'https://serverlessworkflow.io/schemas/0.8/workflow.json#/definitions/sleep'], - ['Crondef', 'https://serverlessworkflow.io/schemas/0.8/workflow.json#/definitions/crondef'], - ['Continueasdef', 'https://serverlessworkflow.io/schemas/0.8/workflow.json#/definitions/continueasdef'], - ['Transition', 'https://serverlessworkflow.io/schemas/0.8/workflow.json#/definitions/transition'], - ['Error', 'https://serverlessworkflow.io/schemas/0.8/workflow.json#/definitions/error'], - ['Onevents', 'https://serverlessworkflow.io/schemas/0.8/workflow.json#/definitions/onevents'], - ['Action', 'https://serverlessworkflow.io/schemas/0.8/workflow.json#/definitions/action'], - ['Functionref', 'https://serverlessworkflow.io/schemas/0.8/workflow.json#/definitions/functionref'], - ['Eventref', 'https://serverlessworkflow.io/schemas/0.8/workflow.json#/definitions/eventref'], - ['Subflowref', 'https://serverlessworkflow.io/schemas/0.8/workflow.json#/definitions/subflowref'], - ['Branch', 'https://serverlessworkflow.io/schemas/0.8/workflow.json#/definitions/branch'], - ['Sleepstate', 'https://serverlessworkflow.io/schemas/0.8/workflow.json#/definitions/sleepstate'], - ['Eventstate', 'https://serverlessworkflow.io/schemas/0.8/workflow.json#/definitions/eventstate'], - ['Operationstate', 'https://serverlessworkflow.io/schemas/0.8/workflow.json#/definitions/operationstate'], - ['Parallelstate', 'https://serverlessworkflow.io/schemas/0.8/workflow.json#/definitions/parallelstate'], - ['Switchstate', 'https://serverlessworkflow.io/schemas/0.8/workflow.json#/definitions/switchstate'], - [ - 'Eventbasedswitchstate', - 'https://serverlessworkflow.io/schemas/0.8/workflow.json#/definitions/eventbasedswitchstate', - ], - ['Databasedswitchstate', 'https://serverlessworkflow.io/schemas/0.8/workflow.json#/definitions/databasedswitchstate'], - ['Defaultconditiondef', 'https://serverlessworkflow.io/schemas/0.8/workflow.json#/definitions/defaultconditiondef'], - ['Eventcondition', 'https://serverlessworkflow.io/schemas/0.8/workflow.json#/definitions/eventcondition'], - [ - 'Transitioneventcondition', - 'https://serverlessworkflow.io/schemas/0.8/workflow.json#/definitions/transitioneventcondition', - ], - ['Enddeventcondition', 'https://serverlessworkflow.io/schemas/0.8/workflow.json#/definitions/enddeventcondition'], - ['Datacondition', 'https://serverlessworkflow.io/schemas/0.8/workflow.json#/definitions/datacondition'], - [ - 'Transitiondatacondition', - 'https://serverlessworkflow.io/schemas/0.8/workflow.json#/definitions/transitiondatacondition', - ], - ['Enddatacondition', 'https://serverlessworkflow.io/schemas/0.8/workflow.json#/definitions/enddatacondition'], - ['Injectstate', 'https://serverlessworkflow.io/schemas/0.8/workflow.json#/definitions/injectstate'], - ['Foreachstate', 'https://serverlessworkflow.io/schemas/0.8/workflow.json#/definitions/foreachstate'], - ['Callbackstate', 'https://serverlessworkflow.io/schemas/0.8/workflow.json#/definitions/callbackstate'], - ['Startdef', 'https://serverlessworkflow.io/schemas/0.8/workflow.json#/definitions/startdef'], - ['Schedule', 'https://serverlessworkflow.io/schemas/0.8/workflow.json#/definitions/schedule'], - ['End', 'https://serverlessworkflow.io/schemas/0.8/workflow.json#/definitions/end'], - ['Produceeventdef', 'https://serverlessworkflow.io/schemas/0.8/workflow.json#/definitions/produceeventdef'], - ['Statedatafilter', 'https://serverlessworkflow.io/schemas/0.8/workflow.json#/definitions/statedatafilter'], - ['Eventdatafilter', 'https://serverlessworkflow.io/schemas/0.8/workflow.json#/definitions/eventdatafilter'], - ['Actiondatafilter', 'https://serverlessworkflow.io/schemas/0.8/workflow.json#/definitions/actiondatafilter'], - ['WorkflowExecTimeout', 'https://serverlessworkflow.io/schemas/0.8/timeouts.json#/definitions/workflowExecTimeout'], - ['StateExecTimeout', 'https://serverlessworkflow.io/schemas/0.8/timeouts.json#/definitions/stateExecTimeout'], - ['ActionExecTimeout', 'https://serverlessworkflow.io/schemas/0.8/timeouts.json#/definitions/actionExecTimeout'], - ['BranchExecTimeout', 'https://serverlessworkflow.io/schemas/0.8/timeouts.json#/definitions/branchExecTimeout'], - ['EventTimeout', 'https://serverlessworkflow.io/schemas/0.8/timeouts.json#/definitions/eventTimeout'], - ['Errordef', 'https://serverlessworkflow.io/schemas/0.8/errors.json#/definitions/errordef'], - ['Metadata', 'https://serverlessworkflow.io/schemas/0.8/common.json#/definitions/metadata'], - ['Eventdef', 'https://serverlessworkflow.io/schemas/0.8/events.json#/definitions/eventdef'], - ['CorrelationDef', 'https://serverlessworkflow.io/schemas/0.8/events.json#/definitions/correlationDef'], - ['Function', 'https://serverlessworkflow.io/schemas/0.8/functions.json#/definitions/function'], - ['Retrydef', 'https://serverlessworkflow.io/schemas/0.8/retries.json#/definitions/retrydef'], - ['Authdef', 'https://serverlessworkflow.io/schemas/0.8/auth.json#/definitions/authdef'], - ['Basicpropsdef', 'https://serverlessworkflow.io/schemas/0.8/auth.json#/definitions/basicpropsdef'], - ['Bearerpropsdef', 'https://serverlessworkflow.io/schemas/0.8/auth.json#/definitions/bearerpropsdef'], - ['Oauth2propsdef', 'https://serverlessworkflow.io/schemas/0.8/auth.json#/definitions/oauth2propsdef'], - ['Secrets', 'https://serverlessworkflow.io/schemas/0.8/secrets.json#/secrets'], - ['Timeouts', 'https://serverlessworkflow.io/schemas/0.8/timeouts.json#/timeouts'], - ['Errors', 'https://serverlessworkflow.io/schemas/0.8/errors.json#/errors'], - ['Events', 'https://serverlessworkflow.io/schemas/0.8/events.json#/events'], - ['Functions', 'https://serverlessworkflow.io/schemas/0.8/functions.json#/functions'], - ['Retries', 'https://serverlessworkflow.io/schemas/0.8/retries.json#/retries'], - ['Auth', 'https://serverlessworkflow.io/schemas/0.8/auth.json#/auth'], -]; diff --git a/src/lib/schema/workflow.json b/src/lib/schema/workflow.json index 2d11730a..dae1bd54 100644 --- a/src/lib/schema/workflow.json +++ b/src/lib/schema/workflow.json @@ -26,7 +26,8 @@ "version": { "type": "string", "description": "Workflow version", - "minLength": 1 + "minLength": 1, + "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-]+)*))?$" }, "annotations": { "type": "array", @@ -49,9 +50,18 @@ "description": "Workflow data input schema definition", "properties": { "schema": { - "type": "string", - "description": "URI of the JSON Schema used to validate the workflow data input", - "minLength": 1 + "oneof": [ + { + "type": "string", + "description": "URI of the JSON Schema used to validate the workflow data input", + "minLength": 1 + }, + { + "type": "object", + "description": "The JSON Schema object used to validate the workflow data input", + "$schema": "http://json-schema.org/draft-07/schema#" + } + ] }, "failOnValidationErrors": { "type": "boolean", @@ -61,8 +71,7 @@ }, "additionalProperties": false, "required": [ - "schema", - "failOnValidationErrors" + "schema" ] } ] @@ -128,6 +137,9 @@ "auth": { "$ref": "auth.json#/auth" }, + "extensions": { + "$ref": "workflowextensions.json#/extensions" + }, "states": { "type": "array", "description": "State definitions", @@ -200,7 +212,7 @@ "description": "Amount of time (ISO 8601 duration format) to sleep after function/subflow invocation. Does not apply if 'eventRef' is defined." } }, - "oneOf": [ + "anyOf": [ { "required": [ "before" @@ -263,7 +275,8 @@ "version": { "type": "string", "description": "Version of the workflow to continue execution as", - "minLength": 1 + "minLength": 1, + "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-]+)*))?$" }, "data": { "type": [ @@ -419,10 +432,6 @@ "action": { "type": "object", "properties": { - "id": { - "type": "string", - "description": "Unique action identifier" - }, "name": { "type": "string", "description": "Unique action definition name" @@ -432,7 +441,7 @@ "$ref": "#/definitions/functionref" }, "eventRef": { - "description": "References a 'trigger' and 'result' reusable event definitions", + "description": "References a `produce` and `consume` reusable event definitions", "$ref": "#/definitions/eventref" }, "subFlowRef": { @@ -538,15 +547,15 @@ "type": "object", "description": "Event References", "properties": { - "triggerEventRef": { + "produceEventRef": { "type": "string", "description": "Reference to the unique name of a 'produced' event definition" }, - "resultEventRef": { + "consumeEventRef": { "type": "string", "description": "Reference to the unique name of a 'consumed' event definition" }, - "resultEventTimeout": { + "consumeEventTimeout": { "type": "string", "description": "Maximum amount of time (ISO 8601 format) to wait for the result event. If not defined it should default to the actionExecutionTimeout" }, @@ -555,7 +564,7 @@ "string", "object" ], - "description": "If string type, an expression which selects parts of the states data output to become the data (payload) of the event referenced by 'triggerEventRef'. If object type, a custom object to become the data (payload) of the event referenced by 'triggerEventRef'." + "description": "If string type, an expression which selects parts of the states data output to become the data (payload) of the event referenced by 'produceEventRef'. If object type, a custom object to become the data (payload) of the event referenced by 'produceEventRef'." }, "contextAttributes": { "type": "object", @@ -563,21 +572,11 @@ "additionalProperties": { "type": "string" } - }, - "invoke": { - "type": "string", - "enum": [ - "sync", - "async" - ], - "description": "Specifies if the function should be invoked sync or async. Default is sync.", - "default": "sync" } }, "additionalProperties": false, "required": [ - "triggerEventRef", - "resultEventRef" + "produceEventRef" ] }, "subflowref": { @@ -598,7 +597,8 @@ "version": { "type": "string", "description": "Version of the sub-workflow to be invoked", - "minLength": 1 + "minLength": 1, + "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-]+)*))?$" }, "onParentComplete": { "type": "string", @@ -666,11 +666,6 @@ "type": "object", "description": "Causes the workflow execution to sleep for a specified duration", "properties": { - "id": { - "type": "string", - "description": "Unique State id", - "minLength": 1 - }, "name": { "type": "string", "description": "State name" @@ -684,99 +679,42 @@ "$ref": "#/definitions/end", "description": "State end definition" }, - "stateDataFilter": { - "description": "State data filter", - "$ref": "#/definitions/statedatafilter" - }, "duration": { "type": "string", "description": "Duration (ISO 8601 duration format) to sleep" }, - "timeouts": { - "type": "object", - "description": "State specific timeouts", - "properties": { - "stateExecTimeout": { - "$ref": "timeouts.json#/definitions/stateExecTimeout" - } - }, - "required": [] - }, - "onErrors": { - "type": "array", - "description": "States error handling definitions", - "items": { - "type": "object", - "$ref": "#/definitions/error" - }, - "additionalItems": false - }, "transition": { "description": "Next transition of the workflow after the workflow sleep", "$ref": "#/definitions/transition" }, - "compensatedBy": { - "type": "string", - "minLength": 1, - "description": "Unique Name of a workflow state which is responsible for compensation of this state" - }, - "usedForCompensation": { - "type": "boolean", - "default": false, - "description": "If true, this state is used to compensate another state. Default is false" - }, "metadata": { "$ref": "common.json#/definitions/metadata" } }, "additionalProperties": false, - "if": { - "properties": { - "usedForCompensation": { - "const": true - } + "oneOf": [ + { + "required": [ + "name", + "type", + "duration", + "end" + ] }, - "required": [ - "usedForCompensation" - ] - }, - "then": { - "required": [ - "name", - "type", - "duration" - ] - }, - "else": { - "oneOf": [ - { - "required": [ - "name", - "type", - "duration", - "end" - ] - }, - { - "required": [ - "name", - "type", - "duration", - "transition" - ] - } - ] - } + { + "required": [ + "name", + "type", + "duration", + "transition" + ] + } + ] }, "eventstate": { "type": "object", "description": "This state is used to wait for events from event sources, then consumes them and invoke one or more actions to run in sequence or parallel", "properties": { - "id": { - "type": "string", - "description": "Unique State id", - "minLength": 1 - }, "name": { "type": "string", "description": "State name" @@ -870,11 +808,6 @@ "type": "object", "description": "Defines actions be performed. Does not wait for incoming events", "properties": { - "id": { - "type": "string", - "description": "Unique State id", - "minLength": 1 - }, "name": { "type": "string", "description": "State name" @@ -992,11 +925,6 @@ "type": "object", "description": "Consists of a number of states that are executed in parallel", "properties": { - "id": { - "type": "string", - "description": "Unique State id", - "minLength": 1 - }, "name": { "type": "string", "description": "State name" @@ -1134,11 +1062,6 @@ "type": "object", "description": "Permits transitions to other states based on events", "properties": { - "id": { - "type": "string", - "description": "Unique State id", - "minLength": 1 - }, "name": { "type": "string", "description": "State name" @@ -1213,11 +1136,6 @@ "type": "object", "description": "Permits transitions to other states based on data conditions", "properties": { - "id": { - "type": "string", - "description": "Unique State id", - "minLength": 1 - }, "name": { "type": "string", "description": "State name" @@ -1289,6 +1207,10 @@ "type": "object", "description": "DefaultCondition definition. Can be either a transition or end definition", "properties": { + "name": { + "type": "string", + "description": "The optional name of the default condition, used solely for display purposes" + }, "transition": { "$ref": "#/definitions/transition" }, @@ -1316,7 +1238,7 @@ "$ref": "#/definitions/transitioneventcondition" }, { - "$ref": "#/definitions/enddeventcondition" + "$ref": "#/definitions/endeventcondition" } ] }, @@ -1350,7 +1272,7 @@ "transition" ] }, - "enddeventcondition": { + "endeventcondition": { "type": "object", "description": "Switch state data event condition", "properties": { @@ -1446,11 +1368,6 @@ "type": "object", "description": "Inject static data into state data. Does not perform any actions", "properties": { - "id": { - "type": "string", - "description": "Unique state id", - "minLength": 1 - }, "name": { "type": "string", "description": "State name" @@ -1468,16 +1385,6 @@ "type": "object", "description": "JSON object which can be set as states data input and can be manipulated via filters" }, - "timeouts": { - "type": "object", - "description": "State specific timeouts", - "properties": { - "stateExecTimeout": { - "$ref": "timeouts.json#/definitions/stateExecTimeout" - } - }, - "required": [] - }, "stateDataFilter": { "description": "State data filter", "$ref": "#/definitions/statedatafilter" @@ -1543,11 +1450,6 @@ "type": "object", "description": "Execute a set of defined actions or workflows for each element of a data array", "properties": { - "id": { - "type": "string", - "description": "Unique State id", - "minLength": 1 - }, "name": { "type": "string", "description": "State name" @@ -1690,11 +1592,6 @@ "type": "object", "description": "This state performs an action, then waits for the callback event that denotes completion of the action", "properties": { - "id": { - "type": "string", - "description": "Unique state id", - "minLength": 1 - }, "name": { "type": "string", "description": "State name" @@ -1832,7 +1729,6 @@ }, "additionalProperties": false, "required": [ - "stateName", "schedule" ] } @@ -2005,4 +1901,4 @@ "required": [] } } -} \ No newline at end of file +} diff --git a/src/lib/schema/workflowextensions.json b/src/lib/schema/workflowextensions.json new file mode 100644 index 00000000..324f23d1 --- /dev/null +++ b/src/lib/schema/workflowextensions.json @@ -0,0 +1,50 @@ +{ + "$id": "https://serverlessworkflow.io/schemas/0.8/workflowextensions.json", + "$schema": "http://json-schema.org/draft-07/schema#", + "description": "Serverless Workflow specification - extensions schema", + "type": "object", + "extensions": { + "oneOf": [ + { + "type": "string", + "format": "uri", + "description": "URI to a resource containing workflow extensions definitions (json or yaml)" + }, + { + "type": "array", + "description": "Workflow extensions definitions", + "items": { + "type": "object", + "$ref": "#/definitions/extension" + }, + "additionalItems": false, + "minItems": 1 + } + ] + }, + "required": [ + "extensions" + ], + "definitions": { + "extension": { + "type": "object", + "properties": { + "extensionId": { + "type": "string", + "description": "Unique extension id", + "minLength": 1 + }, + "resource": { + "type": "string", + "description": "URI to a resource containing this workflow extension definitions (json or yaml)", + "minLength": 1 + } + }, + "additionalProperties": false, + "required": [ + "extensionId", + "resource" + ] + } + } +} \ No newline at end of file diff --git a/src/lib/validation/README.md b/src/lib/validation/README.md index 86d82d3e..7d5a8642 100644 --- a/src/lib/validation/README.md +++ b/src/lib/validation/README.md @@ -1,3 +1,2 @@ # Auto generated notice - This directory and its content has been generated automatically. Do not modify its content, it WILL be lost. \ No newline at end of file diff --git a/src/lib/validation/validators-paths.ts b/src/lib/validation/validators-paths.ts index 7d5f4132..82a9944c 100644 --- a/src/lib/validation/validators-paths.ts +++ b/src/lib/validation/validators-paths.ts @@ -1,88 +1,81 @@ /* - * Copyright 2021-Present The Serverless 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, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +* Copyright 2021-Present The Serverless 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, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ /** - * A map of type names and their corresponding schema - */ +* A map of type names and their corresponding schema +*/ export const validatorsPaths: [string, string][] = [ - ['Workflow', 'https://serverlessworkflow.io/schemas/0.8/workflow.json'], - ['Sleep', 'https://serverlessworkflow.io/schemas/0.8/workflow.json#/definitions/sleep'], - ['Crondef', 'https://serverlessworkflow.io/schemas/0.8/workflow.json#/definitions/crondef'], - ['Continueasdef', 'https://serverlessworkflow.io/schemas/0.8/workflow.json#/definitions/continueasdef'], - ['Transition', 'https://serverlessworkflow.io/schemas/0.8/workflow.json#/definitions/transition'], - ['Error', 'https://serverlessworkflow.io/schemas/0.8/workflow.json#/definitions/error'], - ['Onevents', 'https://serverlessworkflow.io/schemas/0.8/workflow.json#/definitions/onevents'], - ['Action', 'https://serverlessworkflow.io/schemas/0.8/workflow.json#/definitions/action'], - ['Functionref', 'https://serverlessworkflow.io/schemas/0.8/workflow.json#/definitions/functionref'], - ['Eventref', 'https://serverlessworkflow.io/schemas/0.8/workflow.json#/definitions/eventref'], - ['Subflowref', 'https://serverlessworkflow.io/schemas/0.8/workflow.json#/definitions/subflowref'], - ['Branch', 'https://serverlessworkflow.io/schemas/0.8/workflow.json#/definitions/branch'], - ['Sleepstate', 'https://serverlessworkflow.io/schemas/0.8/workflow.json#/definitions/sleepstate'], - ['Eventstate', 'https://serverlessworkflow.io/schemas/0.8/workflow.json#/definitions/eventstate'], - ['Operationstate', 'https://serverlessworkflow.io/schemas/0.8/workflow.json#/definitions/operationstate'], - ['Parallelstate', 'https://serverlessworkflow.io/schemas/0.8/workflow.json#/definitions/parallelstate'], - ['Switchstate', 'https://serverlessworkflow.io/schemas/0.8/workflow.json#/definitions/switchstate'], - [ - 'Eventbasedswitchstate', - 'https://serverlessworkflow.io/schemas/0.8/workflow.json#/definitions/eventbasedswitchstate', - ], - ['Databasedswitchstate', 'https://serverlessworkflow.io/schemas/0.8/workflow.json#/definitions/databasedswitchstate'], - ['Defaultconditiondef', 'https://serverlessworkflow.io/schemas/0.8/workflow.json#/definitions/defaultconditiondef'], - ['Eventcondition', 'https://serverlessworkflow.io/schemas/0.8/workflow.json#/definitions/eventcondition'], - [ - 'Transitioneventcondition', - 'https://serverlessworkflow.io/schemas/0.8/workflow.json#/definitions/transitioneventcondition', - ], - ['Enddeventcondition', 'https://serverlessworkflow.io/schemas/0.8/workflow.json#/definitions/enddeventcondition'], - ['Datacondition', 'https://serverlessworkflow.io/schemas/0.8/workflow.json#/definitions/datacondition'], - [ - 'Transitiondatacondition', - 'https://serverlessworkflow.io/schemas/0.8/workflow.json#/definitions/transitiondatacondition', - ], - ['Enddatacondition', 'https://serverlessworkflow.io/schemas/0.8/workflow.json#/definitions/enddatacondition'], - ['Injectstate', 'https://serverlessworkflow.io/schemas/0.8/workflow.json#/definitions/injectstate'], - ['Foreachstate', 'https://serverlessworkflow.io/schemas/0.8/workflow.json#/definitions/foreachstate'], - ['Callbackstate', 'https://serverlessworkflow.io/schemas/0.8/workflow.json#/definitions/callbackstate'], - ['Startdef', 'https://serverlessworkflow.io/schemas/0.8/workflow.json#/definitions/startdef'], - ['Schedule', 'https://serverlessworkflow.io/schemas/0.8/workflow.json#/definitions/schedule'], - ['End', 'https://serverlessworkflow.io/schemas/0.8/workflow.json#/definitions/end'], - ['Produceeventdef', 'https://serverlessworkflow.io/schemas/0.8/workflow.json#/definitions/produceeventdef'], - ['Statedatafilter', 'https://serverlessworkflow.io/schemas/0.8/workflow.json#/definitions/statedatafilter'], - ['Eventdatafilter', 'https://serverlessworkflow.io/schemas/0.8/workflow.json#/definitions/eventdatafilter'], - ['Actiondatafilter', 'https://serverlessworkflow.io/schemas/0.8/workflow.json#/definitions/actiondatafilter'], - ['WorkflowExecTimeout', 'https://serverlessworkflow.io/schemas/0.8/timeouts.json#/definitions/workflowExecTimeout'], - ['StateExecTimeout', 'https://serverlessworkflow.io/schemas/0.8/timeouts.json#/definitions/stateExecTimeout'], - ['ActionExecTimeout', 'https://serverlessworkflow.io/schemas/0.8/timeouts.json#/definitions/actionExecTimeout'], - ['BranchExecTimeout', 'https://serverlessworkflow.io/schemas/0.8/timeouts.json#/definitions/branchExecTimeout'], - ['EventTimeout', 'https://serverlessworkflow.io/schemas/0.8/timeouts.json#/definitions/eventTimeout'], - ['Errordef', 'https://serverlessworkflow.io/schemas/0.8/errors.json#/definitions/errordef'], - ['Metadata', 'https://serverlessworkflow.io/schemas/0.8/common.json#/definitions/metadata'], - ['Eventdef', 'https://serverlessworkflow.io/schemas/0.8/events.json#/definitions/eventdef'], - ['CorrelationDef', 'https://serverlessworkflow.io/schemas/0.8/events.json#/definitions/correlationDef'], - ['Function', 'https://serverlessworkflow.io/schemas/0.8/functions.json#/definitions/function'], - ['Retrydef', 'https://serverlessworkflow.io/schemas/0.8/retries.json#/definitions/retrydef'], - ['Authdef', 'https://serverlessworkflow.io/schemas/0.8/auth.json#/definitions/authdef'], - ['Basicpropsdef', 'https://serverlessworkflow.io/schemas/0.8/auth.json#/definitions/basicpropsdef'], - ['Bearerpropsdef', 'https://serverlessworkflow.io/schemas/0.8/auth.json#/definitions/bearerpropsdef'], - ['Oauth2propsdef', 'https://serverlessworkflow.io/schemas/0.8/auth.json#/definitions/oauth2propsdef'], - ['Secrets', 'https://serverlessworkflow.io/schemas/0.8/secrets.json#/secrets'], - ['Timeouts', 'https://serverlessworkflow.io/schemas/0.8/timeouts.json#/timeouts'], - ['Errors', 'https://serverlessworkflow.io/schemas/0.8/errors.json#/errors'], - ['Events', 'https://serverlessworkflow.io/schemas/0.8/events.json#/events'], - ['Functions', 'https://serverlessworkflow.io/schemas/0.8/functions.json#/functions'], - ['Retries', 'https://serverlessworkflow.io/schemas/0.8/retries.json#/retries'], - ['Auth', 'https://serverlessworkflow.io/schemas/0.8/auth.json#/auth'], -]; + ['Workflow', 'https://serverlessworkflow.io/schemas/0.8/workflow.json'], + ['Sleep', 'https://serverlessworkflow.io/schemas/0.8/workflow.json#/definitions/sleep'], + ['Crondef', 'https://serverlessworkflow.io/schemas/0.8/workflow.json#/definitions/crondef'], + ['Continueasdef', 'https://serverlessworkflow.io/schemas/0.8/workflow.json#/definitions/continueasdef'], + ['Transition', 'https://serverlessworkflow.io/schemas/0.8/workflow.json#/definitions/transition'], + ['Error', 'https://serverlessworkflow.io/schemas/0.8/workflow.json#/definitions/error'], + ['Onevents', 'https://serverlessworkflow.io/schemas/0.8/workflow.json#/definitions/onevents'], + ['Action', 'https://serverlessworkflow.io/schemas/0.8/workflow.json#/definitions/action'], + ['Functionref', 'https://serverlessworkflow.io/schemas/0.8/workflow.json#/definitions/functionref'], + ['Eventref', 'https://serverlessworkflow.io/schemas/0.8/workflow.json#/definitions/eventref'], + ['Subflowref', 'https://serverlessworkflow.io/schemas/0.8/workflow.json#/definitions/subflowref'], + ['Branch', 'https://serverlessworkflow.io/schemas/0.8/workflow.json#/definitions/branch'], + ['Sleepstate', 'https://serverlessworkflow.io/schemas/0.8/workflow.json#/definitions/sleepstate'], + ['Eventstate', 'https://serverlessworkflow.io/schemas/0.8/workflow.json#/definitions/eventstate'], + ['Operationstate', 'https://serverlessworkflow.io/schemas/0.8/workflow.json#/definitions/operationstate'], + ['Parallelstate', 'https://serverlessworkflow.io/schemas/0.8/workflow.json#/definitions/parallelstate'], + ['Switchstate', 'https://serverlessworkflow.io/schemas/0.8/workflow.json#/definitions/switchstate'], + ['Eventbasedswitchstate', 'https://serverlessworkflow.io/schemas/0.8/workflow.json#/definitions/eventbasedswitchstate'], + ['Databasedswitchstate', 'https://serverlessworkflow.io/schemas/0.8/workflow.json#/definitions/databasedswitchstate'], + ['Defaultconditiondef', 'https://serverlessworkflow.io/schemas/0.8/workflow.json#/definitions/defaultconditiondef'], + ['Eventcondition', 'https://serverlessworkflow.io/schemas/0.8/workflow.json#/definitions/eventcondition'], + ['Transitioneventcondition', 'https://serverlessworkflow.io/schemas/0.8/workflow.json#/definitions/transitioneventcondition'], + ['Endeventcondition', 'https://serverlessworkflow.io/schemas/0.8/workflow.json#/definitions/endeventcondition'], + ['Datacondition', 'https://serverlessworkflow.io/schemas/0.8/workflow.json#/definitions/datacondition'], + ['Transitiondatacondition', 'https://serverlessworkflow.io/schemas/0.8/workflow.json#/definitions/transitiondatacondition'], + ['Enddatacondition', 'https://serverlessworkflow.io/schemas/0.8/workflow.json#/definitions/enddatacondition'], + ['Injectstate', 'https://serverlessworkflow.io/schemas/0.8/workflow.json#/definitions/injectstate'], + ['Foreachstate', 'https://serverlessworkflow.io/schemas/0.8/workflow.json#/definitions/foreachstate'], + ['Callbackstate', 'https://serverlessworkflow.io/schemas/0.8/workflow.json#/definitions/callbackstate'], + ['Startdef', 'https://serverlessworkflow.io/schemas/0.8/workflow.json#/definitions/startdef'], + ['Schedule', 'https://serverlessworkflow.io/schemas/0.8/workflow.json#/definitions/schedule'], + ['End', 'https://serverlessworkflow.io/schemas/0.8/workflow.json#/definitions/end'], + ['Produceeventdef', 'https://serverlessworkflow.io/schemas/0.8/workflow.json#/definitions/produceeventdef'], + ['Statedatafilter', 'https://serverlessworkflow.io/schemas/0.8/workflow.json#/definitions/statedatafilter'], + ['Eventdatafilter', 'https://serverlessworkflow.io/schemas/0.8/workflow.json#/definitions/eventdatafilter'], + ['Actiondatafilter', 'https://serverlessworkflow.io/schemas/0.8/workflow.json#/definitions/actiondatafilter'], + ['Metadata', 'https://serverlessworkflow.io/schemas/0.8/common.json#/definitions/metadata'], + ['WorkflowExecTimeout', 'https://serverlessworkflow.io/schemas/0.8/timeouts.json#/definitions/workflowExecTimeout'], + ['StateExecTimeout', 'https://serverlessworkflow.io/schemas/0.8/timeouts.json#/definitions/stateExecTimeout'], + ['ActionExecTimeout', 'https://serverlessworkflow.io/schemas/0.8/timeouts.json#/definitions/actionExecTimeout'], + ['BranchExecTimeout', 'https://serverlessworkflow.io/schemas/0.8/timeouts.json#/definitions/branchExecTimeout'], + ['EventTimeout', 'https://serverlessworkflow.io/schemas/0.8/timeouts.json#/definitions/eventTimeout'], + ['Eventdef', 'https://serverlessworkflow.io/schemas/0.8/events.json#/definitions/eventdef'], + ['CorrelationDef', 'https://serverlessworkflow.io/schemas/0.8/events.json#/definitions/correlationDef'], + ['Function', 'https://serverlessworkflow.io/schemas/0.8/functions.json#/definitions/function'], + ['Authdef', 'https://serverlessworkflow.io/schemas/0.8/auth.json#/definitions/authdef'], + ['Basicpropsdef', 'https://serverlessworkflow.io/schemas/0.8/auth.json#/definitions/basicpropsdef'], + ['Bearerpropsdef', 'https://serverlessworkflow.io/schemas/0.8/auth.json#/definitions/bearerpropsdef'], + ['Oauth2propsdef', 'https://serverlessworkflow.io/schemas/0.8/auth.json#/definitions/oauth2propsdef'], + ['Retrydef', 'https://serverlessworkflow.io/schemas/0.8/retries.json#/definitions/retrydef'], + ['Errordef', 'https://serverlessworkflow.io/schemas/0.8/errors.json#/definitions/errordef'], + ['Extension', 'https://serverlessworkflow.io/schemas/0.8/workflowextensions.json#/definitions/extension'], + ['Secrets', 'https://serverlessworkflow.io/schemas/0.8/secrets.json#/secrets'], + ['Timeouts', 'https://serverlessworkflow.io/schemas/0.8/timeouts.json#/timeouts'], + ['Errors', 'https://serverlessworkflow.io/schemas/0.8/errors.json#/errors'], + ['Events', 'https://serverlessworkflow.io/schemas/0.8/events.json#/events'], + ['Functions', 'https://serverlessworkflow.io/schemas/0.8/functions.json#/functions'], + ['Retries', 'https://serverlessworkflow.io/schemas/0.8/retries.json#/retries'], + ['Auth', 'https://serverlessworkflow.io/schemas/0.8/auth.json#/auth'], + ['Extensions', 'https://serverlessworkflow.io/schemas/0.8/workflowextensions.json#/extensions'], +] \ No newline at end of file diff --git a/src/lib/validators.ts b/src/lib/validators.ts index 761acb6f..394bd1a1 100644 --- a/src/lib/validators.ts +++ b/src/lib/validators.ts @@ -23,7 +23,9 @@ import functionsSchema from './schema/functions.json'; import retriesSchema from './schema/retries.json'; import secretsSchema from './schema/secrets.json'; import timeoutsSchema from './schema/timeouts.json'; +import odataSchema from './schema/odata.json'; import workflowSchema from './schema/workflow.json'; +import workflowExtensionsSchema from './schema/workflowextensions.json'; import { validatorsPaths } from './validation/validators-paths'; const schemas: any[] = [ @@ -32,10 +34,12 @@ const schemas: any[] = [ eventsSchema, errorsSchema, functionsSchema, + odataSchema, retriesSchema, secretsSchema, timeoutsSchema, workflowSchema, + workflowExtensionsSchema, ]; const strict: boolean = false; const ajv = new Ajv({ schemas, strict }); diff --git a/tests/examples/applicantrequest.json b/tests/examples/applicantrequest.json index 8a05887b..6a295a96 100644 --- a/tests/examples/applicantrequest.json +++ b/tests/examples/applicantrequest.json @@ -1,7 +1,7 @@ { "id": "applicantrequest", "name": "Applicant Request Decision Workflow", - "version": "1.0", + "version": "1.0.0", "description": "Determine if applicant request is valid", "specVersion": "0.8", "start": "CheckApplication", diff --git a/tests/examples/applicantrequest.spec.ts b/tests/examples/applicantrequest.spec.ts index 6be412d9..2f00b4e6 100644 --- a/tests/examples/applicantrequest.spec.ts +++ b/tests/examples/applicantrequest.spec.ts @@ -30,7 +30,7 @@ describe('applicationrequest workflow example', () => { it('should generate Workflow object', function () { const workflow = workflowBuilder() .id('applicantrequest') - .version('1.0') + .version('1.0.0') .specVersion('0.8') .name('Applicant Request Decision Workflow') .description('Determine if applicant request is valid') diff --git a/tests/examples/booklending.json b/tests/examples/booklending.json index cc640fc0..fc3c8df1 100644 --- a/tests/examples/booklending.json +++ b/tests/examples/booklending.json @@ -1,7 +1,7 @@ { "id": "booklending", "name": "Book Lending Workflow", - "version": "1.0", + "version": "1.0.0", "specVersion": "0.8", "start": "Book Lending Request", "states": [ diff --git a/tests/examples/booklending.spec.ts b/tests/examples/booklending.spec.ts index 289506ea..bda3e65a 100644 --- a/tests/examples/booklending.spec.ts +++ b/tests/examples/booklending.spec.ts @@ -35,7 +35,7 @@ describe('booklending workflow example', () => { const workflow = workflowBuilder() .id('booklending') .name('Book Lending Workflow') - .version('1.0') + .version('1.0.0') .specVersion('0.8') .start('Book Lending Request') .states([ diff --git a/tests/examples/carauctionbids.json b/tests/examples/carauctionbids.json index 25880311..9c6ac0d7 100644 --- a/tests/examples/carauctionbids.json +++ b/tests/examples/carauctionbids.json @@ -1,7 +1,7 @@ { "id": "handleCarAuctionBid", "name": "Car Auction Bidding Workflow", - "version": "1.0", + "version": "1.0.0", "description": "Store a single bid whole the car auction is active", "specVersion": "0.8", "start": { diff --git a/tests/examples/carauctionbids.spec.ts b/tests/examples/carauctionbids.spec.ts index 6e42a711..12f6b011 100644 --- a/tests/examples/carauctionbids.spec.ts +++ b/tests/examples/carauctionbids.spec.ts @@ -21,6 +21,7 @@ import { functionBuilder, functionrefBuilder, oneventsBuilder, + startdefBuilder, workflowBuilder, } from '../../src'; @@ -28,14 +29,11 @@ describe('carauctionbids workflow example', () => { it('should generate Workflow object', function () { const workflow = workflowBuilder() .id('handleCarAuctionBid') - .version('1.0') + .version('1.0.0') .specVersion('0.8') .name('Car Auction Bidding Workflow') .description('Store a single bid whole the car auction is active') - .start({ - stateName: 'StoreCarAuctionBid', - schedule: 'R/PT2H', - }) + .start(startdefBuilder().stateName('StoreCarAuctionBid').schedule('R/PT2H').build()) .functions([ functionBuilder().name('StoreBidFunction').operation('http://myapis.org/carauctionapi.json#storeBid').build(), ]) diff --git a/tests/examples/checkcarvitals.json b/tests/examples/checkcarvitals.json index af6ecd31..79a61d63 100644 --- a/tests/examples/checkcarvitals.json +++ b/tests/examples/checkcarvitals.json @@ -1,7 +1,7 @@ { "id": "checkcarvitals", "name": "Check Car Vitals Workflow", - "version": "1.0", + "version": "1.0.0", "specVersion": "0.8", "start": "WhenCarIsOn", "states": [ diff --git a/tests/examples/checkcarvitals.spec.ts b/tests/examples/checkcarvitals.spec.ts index d8656307..d4e954a2 100644 --- a/tests/examples/checkcarvitals.spec.ts +++ b/tests/examples/checkcarvitals.spec.ts @@ -18,7 +18,7 @@ import * as fs from 'fs'; import { actionBuilder, defaultconditiondefBuilder, - enddeventconditionBuilder, + endeventconditionBuilder, eventbasedswitchstateBuilder, eventdefBuilder, eventstateBuilder, @@ -33,7 +33,7 @@ describe('checkcarvitals workflow example', () => { const workflow = workflowBuilder() .id('checkcarvitals') .name('Check Car Vitals Workflow') - .version('1.0') + .version('1.0.0') .specVersion('0.8') .start('WhenCarIsOn') .states([ @@ -52,11 +52,7 @@ describe('checkcarvitals workflow example', () => { eventbasedswitchstateBuilder() .name('CheckContinueVitalChecks') .eventConditions([ - enddeventconditionBuilder() - .name('Car Turned Off Condition') - .eventRef('CarTurnedOffEvent') - .end(true) - .build(), + endeventconditionBuilder().name('Car Turned Off Condition').eventRef('CarTurnedOffEvent').end(true).build(), ]) .defaultCondition(defaultconditiondefBuilder().transition('DoCarVitalChecks').build()) .build(), diff --git a/tests/examples/jobmonitoring.json b/tests/examples/jobmonitoring.json index 815b7117..6ec7505b 100644 --- a/tests/examples/jobmonitoring.json +++ b/tests/examples/jobmonitoring.json @@ -1,7 +1,7 @@ { "id": "jobmonitoring", "name": "Job Monitoring", - "version": "1.0", + "version": "1.0.0", "description": "Monitor finished execution of a submitted job", "specVersion": "0.8", "start": "SubmitJob", diff --git a/tests/examples/jobmonitoring.spec.ts b/tests/examples/jobmonitoring.spec.ts index 8c45351c..67e2051d 100644 --- a/tests/examples/jobmonitoring.spec.ts +++ b/tests/examples/jobmonitoring.spec.ts @@ -33,7 +33,7 @@ describe('jobmonitoring workflow example', () => { it('should generate Workflow object', function () { const workflow = workflowBuilder() .id('jobmonitoring') - .version('1.0') + .version('1.0.0') .specVersion('0.8') .name('Job Monitoring') .description('Monitor finished execution of a submitted job') diff --git a/tests/examples/parallel.json b/tests/examples/parallel.json index 6282297f..3cc3e50a 100644 --- a/tests/examples/parallel.json +++ b/tests/examples/parallel.json @@ -1,7 +1,7 @@ { "id": "parallelexec", "name": "Parallel Execution Workflow", - "version": "1.0", + "version": "1.0.0", "description": "Executes two branches in parallel", "specVersion": "0.8", "start": "ParallelExec", diff --git a/tests/examples/parallel.spec.ts b/tests/examples/parallel.spec.ts index 25f6a353..420c0dc2 100644 --- a/tests/examples/parallel.spec.ts +++ b/tests/examples/parallel.spec.ts @@ -21,7 +21,7 @@ describe('parallel workflow example', () => { it('should generate Workflow object', function () { const workflow = workflowBuilder() .id('parallelexec') - .version('1.0') + .version('1.0.0') .specVersion('0.8') .name('Parallel Execution Workflow') .description('Executes two branches in parallel') diff --git a/tests/examples/provisionorder.json b/tests/examples/provisionorder.json index 2ef8d235..85239754 100644 --- a/tests/examples/provisionorder.json +++ b/tests/examples/provisionorder.json @@ -1,7 +1,7 @@ { "id": "provisionorders", "name": "Provision Orders", - "version": "1.0", + "version": "1.0.0", "description": "Provision Orders and handle errors thrown", "specVersion": "0.8", "start": "ProvisionOrder", diff --git a/tests/examples/provisionorder.spec.ts b/tests/examples/provisionorder.spec.ts index d37e9a87..c49bf80c 100644 --- a/tests/examples/provisionorder.spec.ts +++ b/tests/examples/provisionorder.spec.ts @@ -30,7 +30,7 @@ describe('provisionorder workflow example', () => { it('should generate Workflow object', function () { const workflow = workflowBuilder() .id('provisionorders') - .version('1.0') + .version('1.0.0') .specVersion('0.8') .name('Provision Orders') .description('Provision Orders and handle errors thrown') diff --git a/tests/examples/sendcloudevent.json b/tests/examples/sendcloudevent.json index 11f5ac8a..8ba8023f 100644 --- a/tests/examples/sendcloudevent.json +++ b/tests/examples/sendcloudevent.json @@ -1,7 +1,7 @@ { "id": "sendcloudeventonprovision", "name": "Send CloudEvent on provision completion", - "version": "1.0", + "version": "1.0.0", "specVersion": "0.8", "start": "ProvisionOrdersState", "states": [ diff --git a/tests/examples/sendcloudevent.spec.ts b/tests/examples/sendcloudevent.spec.ts index 0bb63bf0..38b323e7 100644 --- a/tests/examples/sendcloudevent.spec.ts +++ b/tests/examples/sendcloudevent.spec.ts @@ -29,7 +29,7 @@ describe('sendcloudevent workflow example', () => { it('should generate Workflow object', function () { const workflow = workflowBuilder() .id('sendcloudeventonprovision') - .version('1.0') + .version('1.0.0') .specVersion('0.8') .name('Send CloudEvent on provision completion') .start('ProvisionOrdersState') diff --git a/tests/examples/solvemathproblems.json b/tests/examples/solvemathproblems.json index d525922f..9a887acc 100644 --- a/tests/examples/solvemathproblems.json +++ b/tests/examples/solvemathproblems.json @@ -1,7 +1,7 @@ { "id": "solvemathproblems", "name": "Solve Math Problems Workflow", - "version": "1.0", + "version": "1.0.0", "description": "Solve math problems", "specVersion": "0.8", "start": "Solve", diff --git a/tests/examples/solvemathproblems.spec.ts b/tests/examples/solvemathproblems.spec.ts index a9eb5ac8..f3e717af 100644 --- a/tests/examples/solvemathproblems.spec.ts +++ b/tests/examples/solvemathproblems.spec.ts @@ -27,7 +27,7 @@ describe('solvemathproblems workflow example', () => { it('should generate Workflow object', function () { const workflow = workflowBuilder() .id('solvemathproblems') - .version('1.0') + .version('1.0.0') .specVersion('0.8') .name('Solve Math Problems Workflow') .description('Solve math problems') diff --git a/tests/lib/definitions/eventdef.spec.ts b/tests/lib/definitions/eventdef.spec.ts index 091905ed..7f087315 100644 --- a/tests/lib/definitions/eventdef.spec.ts +++ b/tests/lib/definitions/eventdef.spec.ts @@ -19,8 +19,7 @@ import { Eventdef } from '../../../src/lib/definitions/eventdef'; describe('Eventdef ', () => { it('should convert non-primitive properties to the desired class', () => { - // @ts-ignore - const data: Eventdef = { + const data = { correlation: [{ contextAttributeName: 'contextAttributeName' }], metadata: { key: 'value' }, }; diff --git a/tests/lib/definitions/schedule.spec.ts b/tests/lib/definitions/schedule.spec.ts index 066a7e37..0d3ca438 100644 --- a/tests/lib/definitions/schedule.spec.ts +++ b/tests/lib/definitions/schedule.spec.ts @@ -19,7 +19,7 @@ import { Schedule } from '../../../src/lib/definitions/schedule'; describe('schedule ', () => { it('should convert non-primitive properties to the desired class', () => { - const data: Schedule = { + const data = { cron: { expression: '* * * ? * *' }, }; @@ -28,7 +28,7 @@ describe('schedule ', () => { }); it('should not convert primitive properties', () => { - const data: Schedule = { + const data = { cron: '* * * ? * *', }; diff --git a/tests/lib/definitions/util.spec.ts b/tests/lib/definitions/util.spec.ts index 25fbf19f..2ed49dd7 100644 --- a/tests/lib/definitions/util.spec.ts +++ b/tests/lib/definitions/util.spec.ts @@ -15,13 +15,8 @@ * */ -import { - overwriteProperties, - overwritePropertyAsPlainType, - overwriteTimeoutWithStateExecTimeout, -} from '../../../src/lib/definitions/utils'; +import { overwriteProperties, overwritePropertyAsPlainType } from '../../../src/lib/definitions/utils'; import { Properties } from '../../../src/lib/definitions/types'; -import { StateExecTimeout } from '../../../src/lib/definitions/stateExecTimeout'; describe('Util ', () => { describe('overwritePropertyAsPlainType ', () => { @@ -128,32 +123,4 @@ describe('Util ', () => { expect(target.properties.constructor.name).toBe('String'); }); }); - - describe('overwriteTimeoutWithStateExecTimeout ', () => { - it('should create an instance of StateExecTimeout only for stateExecTimeout property ', () => { - class HasStateExecTimeout { - timeouts?: { - stateExecTimeout?: StateExecTimeout; - eventTimeout?: string; - }; - } - - const source = { - timeouts: { - stateExecTimeout: { - total: 'P3Y6M4DT12H30M5S', - }, - eventTimeout: 'eventTimeoutValue', - }, - } as HasStateExecTimeout; - - const target = Object.assign({}, source); - overwriteTimeoutWithStateExecTimeout(target); - expect(target.timeouts!.stateExecTimeout!.constructor.name).toBe('StateExecTimeout'); - - expect(target.timeouts!.eventTimeout).toBe('eventTimeoutValue'); - source.timeouts!.eventTimeout = 'eventTimeoutValue2'; - expect(target.timeouts!.eventTimeout).toBe('eventTimeoutValue'); - }); - }); }); diff --git a/tests/lib/definitions/workflow.spec.ts b/tests/lib/definitions/workflow.spec.ts index 59c67262..0ce6f755 100644 --- a/tests/lib/definitions/workflow.spec.ts +++ b/tests/lib/definitions/workflow.spec.ts @@ -94,7 +94,7 @@ describe('workflow ', () => { const jsonWorkflow: string = Workflow.toJson( workflowBuilder() .id('helloworld') - .version('1.0') + .version('1.0.0') .specVersion('0.8') .name('Hello World Workflow') .description('Inject Hello World') @@ -114,7 +114,7 @@ describe('workflow ', () => { '{' + '"id":"helloworld",' + '"name":"Hello World Workflow",' + - '"version":"1.0",' + + '"version":"1.0.0",' + '"description":"Inject Hello World",' + '"specVersion":"0.8",' + '"start":"Hello State",' + @@ -136,7 +136,7 @@ describe('workflow ', () => { const yamlWorkflow: string = Workflow.toYaml( workflowBuilder() .id('helloworld') - .version('1.0') + .version('1.0.0') .specVersion('0.8') .name('Hello World Workflow') .description('Inject Hello World') @@ -155,7 +155,7 @@ describe('workflow ', () => { expect(yamlWorkflow).toBe( 'id: helloworld\n' + 'name: Hello World Workflow\n' + - "version: '1.0'\n" + + 'version: 1.0.0\n' + 'description: Inject Hello World\n' + "specVersion: '0.8'\n" + 'start: Hello State\n' + diff --git a/tests/lib/diagram/mermaidState.spec.ts b/tests/lib/diagram/mermaidState.spec.ts index c4fe7c13..a8d723ac 100644 --- a/tests/lib/diagram/mermaidState.spec.ts +++ b/tests/lib/diagram/mermaidState.spec.ts @@ -111,7 +111,7 @@ CheckApplication --> RejectApplication : default`); it('should create source code for data-based state with end = true ', () => { const databasedswitch = new Specification.Databasedswitchstate( - JSON.parse(`{ + JSON.parse(`{ "type":"switch", "name":"CheckApplication", "dataConditions": [ @@ -138,10 +138,9 @@ CheckApplication --> [*] : \${ .applicants | .age < 18 } CheckApplication --> StartApplication : default`); }); - it('should create source code for operation state with end.terminate = true ', () => { const databasedswitch = new Specification.Databasedswitchstate( - JSON.parse(`{ + JSON.parse(`{ "name": "GreetPerson", "type": "operation", "actions": [ diff --git a/tests/lib/workflow-validator.spec.ts b/tests/lib/workflow-validator.spec.ts index f602b865..9e9c8682 100644 --- a/tests/lib/workflow-validator.spec.ts +++ b/tests/lib/workflow-validator.spec.ts @@ -21,7 +21,7 @@ import * as fs from 'fs'; describe('workflow-validator, invalid state', () => { const validWorkflow = { id: 'helloworld', - version: '1.0', + version: '1.0.0', specVersion: '0.8', name: 'Hello World Workflow', description: 'Inject Hello World', diff --git a/tools/download-schemas.ts b/tools/download-schemas.ts index cf3f430e..963f0194 100644 --- a/tools/download-schemas.ts +++ b/tools/download-schemas.ts @@ -14,10 +14,10 @@ * limitations under the License. */ import $RefParser from '@apidevtools/json-schema-ref-parser'; -import {promises as fsPromises} from 'fs'; +import { promises as fsPromises } from 'fs'; import * as path from 'path'; -import {URL} from 'url'; -import {schemaDir, reset, schemaUrl} from './utils'; +import { URL } from 'url'; +import { schemaDir, reset, schemaUrl } from './utils'; const { writeFile, mkdir } = fsPromises; @@ -52,5 +52,4 @@ const download = async (schemaUrl: URL, destDir: string): Promise => { } }; - download(schemaUrl, schemaDir).then(console.log.bind(console)).catch(console.error.bind(console)); diff --git a/tools/generate-definitions.ts b/tools/generate-definitions.ts index 6ab3d315..e58bdfbf 100644 --- a/tools/generate-definitions.ts +++ b/tools/generate-definitions.ts @@ -96,7 +96,7 @@ const generate = async (source: string, dest: string, additionnalSchemas: string await reset(destDir); await writeFile(dest, fileHeader + generatedTS); await writeFile(path.resolve(destDir, 'index.ts'), fileHeader + "export * as Specification from './workflow';"); - const validatorsDest = path.resolve(path.dirname(dest), '../validation/validators-paths.ts'); + const validatorsDest = path.resolve(path.dirname(dest), '../../validation/validators-paths.ts'); const $id = $refParser.schema.$id; const baseUrl = path.dirname($id); await createValidatorsPaths(validatorsDest, known$Refs, baseUrl); diff --git a/tools/generate-merged_json.ts b/tools/generate-merged_json.ts index 9f494014..84881d83 100644 --- a/tools/generate-merged_json.ts +++ b/tools/generate-merged_json.ts @@ -17,9 +17,9 @@ import $RefParser from '@apidevtools/json-schema-ref-parser'; import { promises as fsPromises } from 'fs'; import * as path from 'path'; import { URL } from 'url'; -import {schemaDir, mergeDefinitions, mergeSchemas, schemaUrl} from './utils'; +import { schemaDir, mergeDefinitions, mergeSchemas, schemaUrl } from './utils'; -const { writeFile} = fsPromises; +const { writeFile } = fsPromises; /** * Generate a merged schema `__merged.json` from schemas in schemas directory diff --git a/tools/utils.ts b/tools/utils.ts index d287e5ad..36ee7cce 100644 --- a/tools/utils.ts +++ b/tools/utils.ts @@ -19,9 +19,9 @@ import { promises as fsPromises } from 'fs'; import * as path from 'path'; import rimraf from 'rimraf'; import { readMeDisclaimer } from './consts'; -import {URL} from "url"; -import yargs from "yargs"; -import {schemaVersion} from "../package.json"; +import { URL } from 'url'; +import yargs from 'yargs'; +import { schemaVersion } from '../package.json'; const { writeFile, mkdir } = fsPromises; @@ -179,13 +179,11 @@ export const reset = async (destDir: string) => .then(() => mkdir(destDir, { recursive: true })) .then(() => writeFile(path.resolve(destDir, 'README.md'), readMeDisclaimer)); - /** Schemas directory */ export const schemaDir = path.resolve(process.cwd(), 'src/lib/schema'); - /** The URL to download the schema from */ export const schemaUrl: URL = new URL( - (yargs(process.argv.slice(2)).argv.url as string) || + (yargs(process.argv.slice(2)).argv.url as string) || `https://raw.githubusercontent.com/serverlessworkflow/specification/${schemaVersion}.x/schema/workflow.json` );