Skip to content

Commit 4b6bbb2

Browse files
committed
fix-remove-default-values
Signed-off-by: Antonio Mendoza Pérez <[email protected]>
1 parent 955dab0 commit 4b6bbb2

File tree

73 files changed

+397
-120
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

73 files changed

+397
-120
lines changed

src/lib/builders/action-builder.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ function actionBuildingFn(data: Specification.Action): () => Specification.Actio
2727
return () => {
2828
const model = new Specification.Action(data);
2929

30-
validate('Action', model);
30+
validate('Action', model.normalize());
3131
return model;
3232
};
3333
}

src/lib/builders/authdef-builder.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ function authdefBuildingFn(data: Specification.Authdef): () => Specification.Aut
2727
return () => {
2828
const model = new Specification.Authdef(data);
2929

30-
validate('Authdef', model);
30+
validate('Authdef', model.normalize());
3131
return model;
3232
};
3333
}

src/lib/builders/branch-builder.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ function branchBuildingFn(data: Specification.Branch): () => Specification.Branc
2727
return () => {
2828
const model = new Specification.Branch(data);
2929

30-
validate('Branch', model);
30+
validate('Branch', model.normalize());
3131
return model;
3232
};
3333
}

src/lib/builders/callbackstate-builder.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ function callbackstateBuildingFn(data: Specification.Callbackstate): () => Speci
3030

3131
setEndValueIfNoTransition(model);
3232

33-
validate('Callbackstate', model);
33+
validate('Callbackstate', model.normalize());
3434
return model;
3535
};
3636
}

src/lib/builders/continueasdef-builder.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ function continueasdefBuildingFn(data: Specification.Continueasdef): () => Speci
2727
return () => {
2828
const model = new Specification.Continueasdef(data);
2929

30-
validate('Continueasdef', model);
30+
validate('Continueasdef', model.normalize());
3131
return model;
3232
};
3333
}

src/lib/builders/databasedswitchstate-builder.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ function databasedswitchstateBuildingFn(
2929
return () => {
3030
const model = new Specification.Databasedswitchstate(data);
3131

32-
validate('Databasedswitchstate', model);
32+
validate('Databasedswitchstate', model.normalize());
3333
return model;
3434
};
3535
}

src/lib/builders/defaultconditiondef-builder.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ function defaultconditiondefBuildingFn(
2929
return () => {
3030
const model = new Specification.Defaultconditiondef(data);
3131

32-
validate('Defaultconditiondef', model);
32+
validate('Defaultconditiondef', model.normalize());
3333
return model;
3434
};
3535
}

src/lib/builders/end-builder.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ function endBuildingFn(data: Specification.End): () => Specification.End {
2727
return () => {
2828
const model = new Specification.End(data);
2929

30-
validate('End', model);
30+
validate('End', model.normalize());
3131
return model;
3232
};
3333
}

src/lib/builders/enddatacondition-builder.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ function enddataconditionBuildingFn(data: Specification.Enddatacondition): () =>
2727
return () => {
2828
const model = new Specification.Enddatacondition(data);
2929

30-
validate('Enddatacondition', model);
30+
validate('Enddatacondition', model.normalize());
3131
return model;
3232
};
3333
}

src/lib/builders/enddeventcondition-builder.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ function enddeventconditionBuildingFn(data: Specification.Enddeventcondition): (
2727
return () => {
2828
const model = new Specification.Enddeventcondition(data);
2929

30-
validate('Enddeventcondition', model);
30+
validate('Enddeventcondition', model.normalize());
3131
return model;
3232
};
3333
}

src/lib/builders/error-builder.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ function errorBuildingFn(data: Specification.Error): () => Specification.Error {
3030

3131
setEndValueIfNoTransition(model);
3232

33-
validate('Error', model);
33+
validate('Error', model.normalize());
3434
return model;
3535
};
3636
}

src/lib/builders/eventbasedswitchstate-builder.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ function eventbasedswitchstateBuildingFn(
2929
return () => {
3030
const model = new Specification.Eventbasedswitchstate(data);
3131

32-
validate('Eventbasedswitchstate', model);
32+
validate('Eventbasedswitchstate', model.normalize());
3333
return model;
3434
};
3535
}

src/lib/builders/eventdef-builder.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ function eventdefBuildingFn(data: Specification.Eventdef): () => Specification.E
2727
return () => {
2828
const model = new Specification.Eventdef(data);
2929

30-
validate('Eventdef', model);
30+
validate('Eventdef', model.normalize());
3131
return model;
3232
};
3333
}

src/lib/builders/eventref-builder.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ function eventrefBuildingFn(data: Specification.Eventref): () => Specification.E
2727
return () => {
2828
const model = new Specification.Eventref(data);
2929

30-
validate('Eventref', model);
30+
validate('Eventref', model.normalize());
3131
return model;
3232
};
3333
}

src/lib/builders/eventstate-builder.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ function eventstateBuildingFn(data: Specification.Eventstate): () => Specificati
3030

3131
setEndValueIfNoTransition(model);
3232

33-
validate('Eventstate', model);
33+
validate('Eventstate', model.normalize());
3434
return model;
3535
};
3636
}

src/lib/builders/foreachstate-builder.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ function foreachstateBuildingFn(data: Specification.Foreachstate): () => Specifi
3030

3131
setEndValueIfNoTransition(model);
3232

33-
validate('Foreachstate', model);
33+
validate('Foreachstate', model.normalize());
3434
return model;
3535
};
3636
}

src/lib/builders/function-builder.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ function functionBuildingFn(data: Specification.Function): () => Specification.F
2727
return () => {
2828
const model = new Specification.Function(data);
2929

30-
validate('Function', model);
30+
validate('Function', model.normalize());
3131
return model;
3232
};
3333
}

src/lib/builders/functionref-builder.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ function functionrefBuildingFn(data: Specification.Functionref): () => Specifica
2727
return () => {
2828
const model = new Specification.Functionref(data);
2929

30-
validate('Functionref', model);
30+
validate('Functionref', model.normalize());
3131
return model;
3232
};
3333
}

src/lib/builders/injectstate-builder.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ function injectstateBuildingFn(data: Specification.Injectstate): () => Specifica
3030

3131
setEndValueIfNoTransition(model);
3232

33-
validate('Injectstate', model);
33+
validate('Injectstate', model.normalize());
3434
return model;
3535
};
3636
}

src/lib/builders/onevents-builder.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ function oneventsBuildingFn(data: Specification.Onevents): () => Specification.O
2727
return () => {
2828
const model = new Specification.Onevents(data);
2929

30-
validate('Onevents', model);
30+
validate('Onevents', model.normalize());
3131
return model;
3232
};
3333
}

src/lib/builders/operationstate-builder.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ function operationstateBuildingFn(data: Specification.Operationstate): () => Spe
3030

3131
setEndValueIfNoTransition(model);
3232

33-
validate('Operationstate', model);
33+
validate('Operationstate', model.normalize());
3434
return model;
3535
};
3636
}

src/lib/builders/parallelstate-builder.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ function parallelstateBuildingFn(data: Specification.Parallelstate): () => Speci
3030

3131
setEndValueIfNoTransition(model);
3232

33-
validate('Parallelstate', model);
33+
validate('Parallelstate', model.normalize());
3434
return model;
3535
};
3636
}

src/lib/builders/sleepstate-builder.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ function sleepstateBuildingFn(data: Specification.Sleepstate): () => Specificati
2727
return () => {
2828
const model = new Specification.Sleepstate(data);
2929

30-
validate('Sleepstate', model);
30+
validate('Sleepstate', model.normalize());
3131
return model;
3232
};
3333
}

src/lib/builders/subflowref-builder.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ function subflowrefBuildingFn(data: Specification.Subflowref): () => Specificati
2727
return () => {
2828
const model = new Specification.Subflowref(data);
2929

30-
validate('Subflowref', model);
30+
validate('Subflowref', model.normalize());
3131
return model;
3232
};
3333
}

src/lib/builders/timeouts-builder.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ function timeoutsBuildingFn(data: Specification.Timeouts): () => Specification.T
2727
return () => {
2828
const model = new Specification.Timeouts(data);
2929

30-
validate('Timeouts', model);
30+
validate('Timeouts', model.normalize());
3131
return model;
3232
};
3333
}

src/lib/builders/transition-builder.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ function transitionBuildingFn(data: Specification.Transition): () => Specificati
2727
return () => {
2828
const model = new Specification.Transition(data);
2929

30-
validate('Transition', model);
30+
validate('Transition', model.normalize());
3131
return model;
3232
};
3333
}

src/lib/builders/transitiondatacondition-builder.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ function transitiondataconditionBuildingFn(
2929
return () => {
3030
const model = new Specification.Transitiondatacondition(data);
3131

32-
validate('Transitiondatacondition', model);
32+
validate('Transitiondatacondition', model.normalize());
3333
return model;
3434
};
3535
}

src/lib/builders/transitioneventcondition-builder.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ function transitioneventconditionBuildingFn(
2929
return () => {
3030
const model = new Specification.Transitioneventcondition(data);
3131

32-
validate('Transitioneventcondition', model);
32+
validate('Transitioneventcondition', model.normalize());
3333
return model;
3434
};
3535
}

src/lib/builders/workflow-builder.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ function workflowBuildingFn(data: Specification.Workflow): () => Specification.W
2727
return () => {
2828
const model = new Specification.Workflow(data);
2929

30-
validate('Workflow', model);
30+
validate('Workflow', model.normalize());
3131
return model;
3232
};
3333
}

src/lib/builders/workflow-exec-timeout-builder.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ function workflowExecTimeoutBuildingFn(
2929
return () => {
3030
const model = new Specification.WorkflowExecTimeout(data);
3131

32-
validate('WorkflowExecTimeout', model);
32+
validate('WorkflowExecTimeout', model.normalize());
3333
return model;
3434
};
3535
}

src/lib/definitions/action.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import { Actiondatafilter } from './actiondatafilter';
1717
import { Eventref } from './eventref';
1818
import { Functionref } from './functionref';
1919
import {
20+
cleanSourceModelProperty,
2021
normalizeEventRef,
2122
normalizeFunctionRef,
2223
normalizeSubFlowRefIfObject,
@@ -30,7 +31,11 @@ import { Subflowref } from './subflowref';
3031
import { Sleep } from './sleep';
3132

3233
export class Action {
34+
sourceModel?: Action;
35+
3336
constructor(model: any) {
37+
this.sourceModel = Object.assign({}, model);
38+
3439
Object.assign(this, model);
3540

3641
overwriteFunctionRefIfObject(this);
@@ -81,6 +86,8 @@ export class Action {
8186
normalizeEventRef(clone);
8287
normalizeFunctionRef(clone);
8388

89+
cleanSourceModelProperty(clone);
90+
8491
return clone;
8592
};
8693
}

src/lib/definitions/authdef.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,15 @@
1414
* limitations under the License.
1515
*/
1616

17-
import { normalizeScheme, overwritePropertiesIfObject } from './utils';
17+
import { cleanSourceModelProperty, normalizeScheme, overwritePropertiesIfObject } from './utils';
1818
import { Properties } from './types';
1919

2020
export class Authdef {
21+
sourceModel?: Authdef;
22+
2123
constructor(model: any) {
24+
this.sourceModel = Object.assign({}, model);
25+
2226
const defaultModel = { scheme: 'basic' };
2327
Object.assign(this, defaultModel, model);
2428

@@ -41,7 +45,9 @@ export class Authdef {
4145
normalize = (): Authdef => {
4246
const clone = new Authdef(this);
4347

44-
normalizeScheme(clone);
48+
normalizeScheme(clone, this.sourceModel);
49+
50+
cleanSourceModelProperty(clone);
4551

4652
return clone;
4753
};

src/lib/definitions/branch.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,15 @@
1515
*/
1616

1717
import { Action } from './action';
18-
import { normalizeActions, overwriteActions, overwritePropertyAsPlainType } from './utils';
18+
import { cleanSourceModelProperty, normalizeActions, overwriteActions, overwritePropertyAsPlainType } from './utils';
1919
import { ActionExecTimeout, BranchExecTimeout } from './types';
2020

2121
export class Branch /* Branch Definition */ {
22+
sourceModel?: Branch;
23+
2224
constructor(model: any) {
25+
this.sourceModel = Object.assign({}, model);
26+
2327
Object.assign(this, model);
2428
overwriteActions(this);
2529
overwritePropertyAsPlainType('timeouts', this);
@@ -43,12 +47,13 @@ export class Branch /* Branch Definition */ {
4347

4448
/**
4549
* Normalize the value of each property by recursively deleting properties whose value is equal to its default value. Does not modify the object state.
46-
* @returns {Specification.Action} without deleted properties.
50+
* @returns {Specification.Branch} without deleted properties.
4751
*/
4852
normalize = (): Branch => {
4953
const clone = new Branch(this);
5054
normalizeActions(clone);
5155

56+
cleanSourceModelProperty(clone);
5257
return clone;
5358
};
5459
}

src/lib/definitions/callbackstate.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import { Metadata } from './metadata';
2222
import { Statedatafilter } from './statedatafilter';
2323
import { Transition } from './transition';
2424
import {
25+
cleanSourceModelProperty,
2526
normalizeAction,
2627
normalizeEndIfObject,
2728
normalizeOnErrors,
@@ -41,7 +42,11 @@ import { ActionExecTimeout, EventTimeout } from './types';
4142
import { StateExecTimeout } from './stateExecTimeout';
4243

4344
export class Callbackstate {
45+
sourceModel?: Callbackstate;
46+
4447
constructor(model: any) {
48+
this.sourceModel = Object.assign({}, model);
49+
4550
const defaultModel = { type: 'callback', usedForCompensation: false };
4651
Object.assign(this, defaultModel, model);
4752

@@ -124,9 +129,11 @@ export class Callbackstate {
124129
normalizeOnErrors(clone);
125130
normalizeTransitionIfObject(clone);
126131
normalizeEndIfObject(clone);
127-
normalizeUsedForCompensation(clone);
132+
normalizeUsedForCompensation(clone, this.sourceModel);
128133
setEndValueIfNoTransition(clone);
129134

135+
cleanSourceModelProperty(clone);
136+
130137
return clone;
131138
};
132139
}

0 commit comments

Comments
 (0)