Skip to content

Commit 8e499a5

Browse files
committed
Fix builders
1 parent 692b4d1 commit 8e499a5

File tree

92 files changed

+2715
-1617
lines changed

Some content is hidden

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

92 files changed

+2715
-1617
lines changed

package-lock.json

Lines changed: 1216 additions & 1169 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444
"@rollup/plugin-node-resolve": "^13.0.0",
4545
"@types/jest": "^27.0.3",
4646
"@types/js-yaml": "^4.0.1",
47+
"@types/lodash": "^4.14.168",
4748
"@types/node-fetch": "^2.5.10",
4849
"@types/rimraf": "^3.0.0",
4950
"@types/yargs": "^16.0.1",
@@ -54,8 +55,10 @@
5455
"eslint-config-prettier": "^8.3.0",
5556
"eslint-plugin-prettier": "^3.4.0",
5657
"husky": "6.0.0",
57-
"jest": "^27.4.3",
58+
"immer": "^10.0.3",
59+
"jest": "^29.7.0",
5860
"lint-staged": "11.0.0",
61+
"lodash": "^4.17.21",
5962
"node-fetch": "^2.6.1",
6063
"prettier": "^2.3.0",
6164
"rimraf": "^3.0.2",
@@ -64,9 +67,9 @@
6467
"rollup-plugin-terser": "^7.0.2",
6568
"rollup-plugin-typescript2": "^0.36.0",
6669
"shx": "^0.3.3",
67-
"ts-jest": "^27.1.0",
70+
"ts-jest": "^29.1.5",
6871
"ts-node": "^9.1.1",
69-
"typescript": "^5.2.0",
72+
"typescript": "^5.5.3",
7073
"yargs": "^17.0.1"
7174
},
7275
"repository": {

src/lib/builders/action-builder.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,9 @@
1616

1717
import { Builder, builder } from '../builder';
1818
import { Specification } from '../definitions';
19+
import { hasProperty } from '../definitions/utils';
1920
import { validate } from '../utils';
21+
import { toPlainObject } from 'lodash';
2022

2123
/**
2224
* The internal function used by the builder proxy to validate and return its underlying object
@@ -27,8 +29,13 @@ function actionBuildingFn(data: Specification.IAction): () => Specification.IAct
2729
return () => {
2830
const model = new Specification.Action(data);
2931

30-
validate('Action', model.normalize());
31-
return model;
32+
if (hasProperty(model, 'normalize')) {
33+
validate('Action', (model as any).normalize());
34+
} else {
35+
validate('Action', model);
36+
}
37+
38+
return toPlainObject(model);
3239
};
3340
}
3441

src/lib/builders/actiondatafilter-builder.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,9 @@
1616

1717
import { Builder, builder } from '../builder';
1818
import { Specification } from '../definitions';
19+
import { hasProperty } from '../definitions/utils';
1920
import { validate } from '../utils';
21+
import { toPlainObject } from 'lodash';
2022

2123
/**
2224
* The internal function used by the builder proxy to validate and return its underlying object
@@ -27,8 +29,13 @@ function actiondatafilterBuildingFn(data: Specification.IActiondatafilter): () =
2729
return () => {
2830
const model = new Specification.Actiondatafilter(data);
2931

30-
validate('Actiondatafilter', model);
31-
return model;
32+
if (hasProperty(model, 'normalize')) {
33+
validate('Actiondatafilter', (model as any).normalize());
34+
} else {
35+
validate('Actiondatafilter', model);
36+
}
37+
38+
return toPlainObject(model);
3239
};
3340
}
3441

src/lib/builders/authdef-builder.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,9 @@
1616

1717
import { Builder, builder } from '../builder';
1818
import { Specification } from '../definitions';
19+
import { hasProperty } from '../definitions/utils';
1920
import { validate } from '../utils';
21+
import { toPlainObject } from 'lodash';
2022

2123
/**
2224
* The internal function used by the builder proxy to validate and return its underlying object
@@ -27,8 +29,13 @@ function authdefBuildingFn(data: Specification.IAuthdef): () => Specification.IA
2729
return () => {
2830
const model = new Specification.Authdef(data);
2931

30-
validate('Authdef', model.normalize());
31-
return model;
32+
if (hasProperty(model, 'normalize')) {
33+
validate('Authdef', (model as any).normalize());
34+
} else {
35+
validate('Authdef', model);
36+
}
37+
38+
return toPlainObject(model);
3239
};
3340
}
3441

src/lib/builders/basicpropsdef-builder.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,9 @@
1616

1717
import { Builder, builder } from '../builder';
1818
import { Specification } from '../definitions';
19+
import { hasProperty } from '../definitions/utils';
1920
import { validate } from '../utils';
21+
import { toPlainObject } from 'lodash';
2022

2123
/**
2224
* The internal function used by the builder proxy to validate and return its underlying object
@@ -27,8 +29,13 @@ function basicpropsdefBuildingFn(data: Specification.IBasicpropsdef): () => Spec
2729
return () => {
2830
const model = new Specification.Basicpropsdef(data);
2931

30-
validate('Basicpropsdef', model);
31-
return model;
32+
if (hasProperty(model, 'normalize')) {
33+
validate('Basicpropsdef', (model as any).normalize());
34+
} else {
35+
validate('Basicpropsdef', model);
36+
}
37+
38+
return toPlainObject(model);
3239
};
3340
}
3441

src/lib/builders/bearerpropsdef-builder.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,9 @@
1616

1717
import { Builder, builder } from '../builder';
1818
import { Specification } from '../definitions';
19+
import { hasProperty } from '../definitions/utils';
1920
import { validate } from '../utils';
21+
import { toPlainObject } from 'lodash';
2022

2123
/**
2224
* The internal function used by the builder proxy to validate and return its underlying object
@@ -27,8 +29,13 @@ function bearerpropsdefBuildingFn(data: Specification.IBearerpropsdef): () => Sp
2729
return () => {
2830
const model = new Specification.Bearerpropsdef(data);
2931

30-
validate('Bearerpropsdef', model);
31-
return model;
32+
if (hasProperty(model, 'normalize')) {
33+
validate('Bearerpropsdef', (model as any).normalize());
34+
} else {
35+
validate('Bearerpropsdef', model);
36+
}
37+
38+
return toPlainObject(model);
3239
};
3340
}
3441

src/lib/builders/branch-builder.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,9 @@
1616

1717
import { Builder, builder } from '../builder';
1818
import { Specification } from '../definitions';
19+
import { hasProperty } from '../definitions/utils';
1920
import { validate } from '../utils';
21+
import { toPlainObject } from 'lodash';
2022

2123
/**
2224
* The internal function used by the builder proxy to validate and return its underlying object
@@ -27,8 +29,13 @@ function branchBuildingFn(data: Specification.IBranch): () => Specification.IBra
2729
return () => {
2830
const model = new Specification.Branch(data);
2931

30-
validate('Branch', model.normalize());
31-
return model;
32+
if (hasProperty(model, 'normalize')) {
33+
validate('Branch', (model as any).normalize());
34+
} else {
35+
validate('Branch', model);
36+
}
37+
38+
return toPlainObject(model);
3239
};
3340
}
3441

src/lib/builders/callbackstate-builder.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,9 @@
1616

1717
import { Builder, builder } from '../builder';
1818
import { Specification } from '../definitions';
19+
import { hasProperty } from '../definitions/utils';
1920
import { validate } from '../utils';
21+
import { toPlainObject } from 'lodash';
2022
import { setEndValueIfNoTransition } from '../definitions/utils';
2123

2224
/**
@@ -30,8 +32,13 @@ function callbackstateBuildingFn(data: Specification.ICallbackstate): () => Spec
3032

3133
setEndValueIfNoTransition(model);
3234

33-
validate('Callbackstate', model.normalize());
34-
return model;
35+
if (hasProperty(model, 'normalize')) {
36+
validate('Callbackstate', (model as any).normalize());
37+
} else {
38+
validate('Callbackstate', model);
39+
}
40+
41+
return toPlainObject(model);
3542
};
3643
}
3744

src/lib/builders/continueasdef-builder.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,9 @@
1616

1717
import { Builder, builder } from '../builder';
1818
import { Specification } from '../definitions';
19+
import { hasProperty } from '../definitions/utils';
1920
import { validate } from '../utils';
21+
import { toPlainObject } from 'lodash';
2022

2123
/**
2224
* The internal function used by the builder proxy to validate and return its underlying object
@@ -27,8 +29,13 @@ function continueasdefBuildingFn(data: Specification.IContinueasdef): () => Spec
2729
return () => {
2830
const model = new Specification.Continueasdef(data);
2931

30-
validate('Continueasdef', model.normalize());
31-
return model;
32+
if (hasProperty(model, 'normalize')) {
33+
validate('Continueasdef', (model as any).normalize());
34+
} else {
35+
validate('Continueasdef', model);
36+
}
37+
38+
return toPlainObject(model);
3239
};
3340
}
3441

0 commit comments

Comments
 (0)