Skip to content

order-properties-on-serialization #159

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 28, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions src/lib/definitions/callbackstate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,12 @@ export class Callbackstate {
constructor(model: any) {
this.sourceModel = Object.assign({}, model);

const defaultModel = { type: 'callback', usedForCompensation: false };
const defaultModel = {
id: undefined,
name: undefined,
type: 'callback',
usedForCompensation: false,
};
Object.assign(this, defaultModel, model);

overwriteAction(this);
Expand All @@ -59,7 +64,6 @@ export class Callbackstate {
overwriteEnd(this);
overwriteMetadata(this);
}

/**
* Unique state id
*/
Expand Down
2 changes: 1 addition & 1 deletion src/lib/definitions/databasedswitchstate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export class Databasedswitchstate {
constructor(model: any) {
this.sourceModel = Object.assign({}, model);

const defaultModel = { type: 'switch', usedForCompensation: false };
const defaultModel = { id: undefined, name: undefined, type: 'switch', usedForCompensation: false };
Object.assign(this, defaultModel, model);

overwriteStateDataFilter(this);
Expand Down
6 changes: 1 addition & 5 deletions src/lib/definitions/eventbasedswitchstate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,7 @@ export class Eventbasedswitchstate {
constructor(model: any) {
this.sourceModel = Object.assign({}, model);

const defaultModel = {
type: 'switch',
usedForCompensation: false,
};
const defaultModel = { id: undefined, name: undefined, type: 'switch', usedForCompensation: false };
Object.assign(this, defaultModel, model);

overwriteStateDataFilter(this);
Expand All @@ -53,7 +50,6 @@ export class Eventbasedswitchstate {
overwriteDefaultCondition(this);
overwriteMetadata(this);
}

/**
* Unique State id
*/
Expand Down
11 changes: 8 additions & 3 deletions src/lib/definitions/eventstate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import { Onevents } from './onevents';
import { Statedatafilter } from './statedatafilter';
import { Transition } from './transition';
import {
cleanSourceModelProperty,
normalizeEnd,
normalizeExclusive,
normalizeOnErrors,
Expand All @@ -30,10 +31,9 @@ import {
overwriteOnErrors,
overwriteOnEvents,
overwriteStateDataFilter,
overwriteTimeoutWithStateExecTimeout,
overwriteTransition,
setEndValueIfNoTransition,
overwriteTimeoutWithStateExecTimeout,
cleanSourceModelProperty,
} from './utils';
import { ActionExecTimeout, EventTimeout } from './types';
import { StateExecTimeout } from './stateExecTimeout';
Expand All @@ -44,7 +44,12 @@ export class Eventstate /* This state is used to wait for events from event sour
constructor(model: any) {
this.sourceModel = Object.assign({}, model);

const defaultModel = { type: 'event', exclusive: true };
const defaultModel = {
id: undefined,
name: undefined,
type: 'event',
exclusive: true,
};
Object.assign(this, defaultModel, model);

overwriteOnEvents(this);
Expand Down
15 changes: 10 additions & 5 deletions src/lib/definitions/foreachstate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,10 @@ import { Metadata } from './metadata';
import { Statedatafilter } from './statedatafilter';
import { Transition } from './transition';
import {
cleanSourceModelProperty,
normalizeActions,
normalizeEnd,
normalizeMode,
normalizeOnErrors,
normalizeTransition,
normalizeUsedForCompensation,
Expand All @@ -30,11 +32,9 @@ import {
overwriteMetadata,
overwriteOnErrors,
overwriteStateDataFilter,
overwriteTimeoutWithStateExecTimeout,
overwriteTransition,
setEndValueIfNoTransition,
normalizeMode,
overwriteTimeoutWithStateExecTimeout,
cleanSourceModelProperty,
} from './utils';
import { ActionExecTimeout } from './types';
import { StateExecTimeout } from './stateExecTimeout';
Expand All @@ -45,7 +45,13 @@ export class Foreachstate {
constructor(model: any) {
this.sourceModel = Object.assign({}, model);

const defaultModel = { type: 'foreach', usedForCompensation: false, mode: 'parallel' };
const defaultModel = {
id: undefined,
name: undefined,
type: 'foreach',
usedForCompensation: false,
mode: 'parallel',
};
Object.assign(this, defaultModel, model);

overwriteEnd(this);
Expand Down Expand Up @@ -120,7 +126,6 @@ export class Foreachstate {
* If true, this state is used to compensate another state. Default is false
*/
usedForCompensation?: boolean;

/**
* Specifies how iterations are to be performed (sequentially or in parallel)
*/
Expand Down
7 changes: 6 additions & 1 deletion src/lib/definitions/injectstate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,12 @@ export class Injectstate {
constructor(model: any) {
this.sourceModel = Object.assign({}, model);

const defaultModel = { type: 'inject', usedForCompensation: false };
const defaultModel = {
id: undefined,
name: undefined,
type: 'inject',
usedForCompensation: false,
};
Object.assign(this, defaultModel, model);

overwriteEnd(this);
Expand Down
2 changes: 2 additions & 0 deletions src/lib/definitions/operationstate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ export class Operationstate {
this.sourceModel = Object.assign({}, model);

const defaultModel = {
id: undefined,
name: undefined,
type: 'operation',
actionMode: 'sequential',
usedForCompensation: false,
Expand Down
6 changes: 4 additions & 2 deletions src/lib/definitions/parallelstate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import { Metadata } from './metadata';
import { Statedatafilter } from './statedatafilter';
import { Transition } from './transition';
import {
cleanSourceModelProperty,
normalizeBranches,
normalizeCompletionType,
normalizeEnd,
Expand All @@ -32,10 +33,9 @@ import {
overwriteMetadata,
overwriteOnErrors,
overwriteStateDataFilter,
overwriteTimeoutWithStateExecTimeout,
overwriteTransition,
setEndValueIfNoTransition,
overwriteTimeoutWithStateExecTimeout,
cleanSourceModelProperty,
} from './utils';
import { BranchExecTimeout } from './types';
import { StateExecTimeout } from './stateExecTimeout';
Expand All @@ -47,6 +47,8 @@ export class Parallelstate {
this.sourceModel = Object.assign({}, model);

const defaultModel = {
id: undefined,
name: undefined,
type: 'parallel',
completionType: 'allOf',
usedForCompensation: false,
Expand Down
2 changes: 2 additions & 0 deletions src/lib/definitions/sleepstate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ export class Sleepstate {
this.sourceModel = Object.assign({}, model);

const defaultModel = {
id: undefined,
name: undefined,
type: 'sleep',
usedForCompensation: false,
};
Expand Down
13 changes: 12 additions & 1 deletion src/lib/definitions/workflow.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,20 @@ export class Workflow {
this.sourceModel = Object.assign({}, model);

const defaultModel = {
id: undefined,
name: undefined,
version: undefined,
description: undefined,
specVersion: undefined,
start: undefined,
states: undefined,
functions: undefined,
events: undefined,
retries: undefined,
timeouts: undefined,
expressionLang: 'jq',
keepActive: true,
} as Specification.Workflow;
};

Object.assign(this, defaultModel, model);

Expand Down
22 changes: 11 additions & 11 deletions tests/examples/applicantrequest.json
Original file line number Diff line number Diff line change
@@ -1,20 +1,14 @@
{
"id": "applicantrequest",
"version": "1.0",
"specVersion": "0.8",
"name": "Applicant Request Decision Workflow",
"version": "1.0",
"description": "Determine if applicant request is valid",
"specVersion": "0.8",
"start": "CheckApplication",
"functions": [
{
"name": "sendRejectionEmailFunction",
"operation": "http://myapis.org/applicationapi.json#emailRejection"
}
],
"states":[
{
"type":"switch",
"name":"CheckApplication",
"type":"switch",
"dataConditions": [
{
"condition": "${ .applicants | .age >= 18 }",
Expand All @@ -30,8 +24,8 @@
}
},
{
"type": "operation",
"name": "StartApplication",
"type": "operation",
"actions": [
{
"subFlowRef": "startApplicationWorkflowId"
Expand All @@ -40,9 +34,9 @@
"end": true
},
{
"name":"RejectApplication",
"type":"operation",
"actionMode":"sequential",
"name":"RejectApplication",
"actions":[
{
"functionRef": {
Expand All @@ -55,5 +49,11 @@
],
"end": true
}
],
"functions": [
{
"name": "sendRejectionEmailFunction",
"operation": "http://myapis.org/applicationapi.json#emailRejection"
}
]
}
16 changes: 8 additions & 8 deletions tests/examples/booklending.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
"start": "Book Lending Request",
"states": [
{
"type": "event",
"name": "Book Lending Request",
"type": "event",
"onEvents": [
{
"eventRefs": ["Book Lending Request Event"]
Expand All @@ -16,8 +16,8 @@
"transition": "Get Book Status"
},
{
"type": "operation",
"name": "Get Book Status",
"type": "operation",
"actions": [
{
"functionRef": {
Expand All @@ -31,8 +31,8 @@
"transition": "Book Status Decision"
},
{
"type": "switch",
"name": "Book Status Decision",
"type": "switch",
"dataConditions": [
{
"name": "Book is on loan",
Expand All @@ -50,8 +50,8 @@
}
},
{
"type": "operation",
"name": "Report Status To Lender",
"type": "operation",
"actions": [
{
"functionRef": {
Expand All @@ -66,8 +66,8 @@
"transition": "Wait for Lender response"
},
{
"type": "switch",
"name": "Wait for Lender response",
"type": "switch",
"eventConditions": [
{
"name": "Hold Book",
Expand All @@ -85,8 +85,8 @@
}
},
{
"type": "operation",
"name": "Request Hold",
"type": "operation",
"actions": [
{
"functionRef": {
Expand All @@ -101,14 +101,14 @@
"transition": "Sleep two weeks"
},
{
"type": "sleep",
"name": "Sleep two weeks",
"type": "sleep",
"duration": "PT2W",
"transition": "Get Book Status"
},
{
"type": "operation",
"name": "Check Out Book",
"type": "operation",
"actions": [
{
"functionRef": {
Expand Down
Loading