Skip to content

Commit 760a028

Browse files
committed
Add interfaces and plain objects based model
Signed-off-by: handreyrc <[email protected]>
1 parent 8549c07 commit 760a028

File tree

119 files changed

+9017
-10991
lines changed

Some content is hidden

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

119 files changed

+9017
-10991
lines changed

examples/node/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
*/
1616
import { injectstateBuilder, Specification, workflowBuilder } from '../../dist';
1717

18-
const workflow: Specification.Workflow = workflowBuilder()
18+
const workflow: Specification.IWorkflow = workflowBuilder()
1919
.id('helloworld')
2020
.version('1.0')
2121
.name('Hello World Workflow')

package-lock.json

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

package.json

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -39,34 +39,36 @@
3939
"devDependencies": {
4040
"@apidevtools/json-schema-ref-parser": "^9.0.7",
4141
"@dtsgenerator/replace-namespace": "^1.4.1",
42-
"@rollup/plugin-commonjs": "^19.0.0",
42+
"@rollup/plugin-commonjs": "^28.0.6",
4343
"@rollup/plugin-json": "^4.1.0",
4444
"@rollup/plugin-node-resolve": "^13.0.0",
45-
"@types/jest": "^27.0.3",
45+
"@types/jest": "^30.0.0",
4646
"@types/js-yaml": "^4.0.1",
47+
"@types/lodash": "^4.14.168",
4748
"@types/node-fetch": "^2.5.10",
48-
"@types/rimraf": "^3.0.0",
4949
"@types/yargs": "^16.0.1",
50-
"@typescript-eslint/eslint-plugin": "^4.23.0",
51-
"@typescript-eslint/parser": "^4.23.0",
50+
"@typescript-eslint/eslint-plugin": "^8.45.0",
51+
"@typescript-eslint/parser": "^8.45.0",
5252
"dtsgenerator": "^3.10.0",
53-
"eslint": "^7.26.0",
53+
"eslint": "^9.36.0",
5454
"eslint-config-prettier": "^8.3.0",
5555
"eslint-plugin-prettier": "^3.4.0",
5656
"husky": "6.0.0",
57-
"jest": "^27.4.3",
57+
"immer": "^10.0.3",
58+
"jest": "^30.2.0",
5859
"lint-staged": "11.0.0",
60+
"lodash": "^4.17.21",
5961
"node-fetch": "^2.6.1",
6062
"prettier": "^2.3.0",
61-
"rimraf": "^3.0.2",
63+
"rimraf": "^6.0.1",
6264
"rollup": "^2.47.0",
6365
"rollup-plugin-sourcemaps": "^0.6.3",
6466
"rollup-plugin-terser": "^7.0.2",
65-
"rollup-plugin-typescript2": "^0.30.0",
66-
"shx": "^0.3.3",
67-
"ts-jest": "^27.1.0",
67+
"rollup-plugin-typescript2": "^0.36.0",
68+
"shx": "^0.4.0",
69+
"ts-jest": "^29.4.4",
6870
"ts-node": "^9.1.1",
69-
"typescript": "^4.2.4",
71+
"typescript": "^5.5.3",
7072
"yargs": "^17.0.1"
7173
},
7274
"repository": {

src/lib/builders/README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,2 @@
11
# Auto generated notice
2-
32
This directory and its content has been generated automatically. Do not modify its content, it WILL be lost.

src/lib/builders/action-builder.ts

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,26 +16,33 @@
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
23-
* @param {Specification.Action} data The underlying object
24-
* @returns {Specification.Action} The validated underlying object
25+
* @param {Specification.IAction} data The underlying object
26+
* @returns {Specification.IAction} The validated underlying object
2527
*/
26-
function actionBuildingFn(data: Specification.Action): () => Specification.Action {
28+
function actionBuildingFn(data: Specification.IAction): () => Specification.IAction {
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

3542
/**
3643
* A factory to create a builder proxy for the type `Specification.Action`
37-
* @returns {Specification.Action} A builder for `Specification.Action`
44+
* @returns {Specification.IAction} A builder for `Specification.Action`
3845
*/
39-
export function actionBuilder(): Builder<Specification.Action> {
40-
return builder<Specification.Action>(actionBuildingFn);
46+
export function actionBuilder(): Builder<Specification.IAction> {
47+
return builder<Specification.IAction>(actionBuildingFn);
4148
}

src/lib/builders/actiondatafilter-builder.ts

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,26 +16,33 @@
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
23-
* @param {Specification.Actiondatafilter} data The underlying object
24-
* @returns {Specification.Actiondatafilter} The validated underlying object
25+
* @param {Specification.IActiondatafilter} data The underlying object
26+
* @returns {Specification.IActiondatafilter} The validated underlying object
2527
*/
26-
function actiondatafilterBuildingFn(data: Specification.Actiondatafilter): () => Specification.Actiondatafilter {
28+
function actiondatafilterBuildingFn(data: Specification.IActiondatafilter): () => 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

3542
/**
3643
* A factory to create a builder proxy for the type `Specification.Actiondatafilter`
37-
* @returns {Specification.Actiondatafilter} A builder for `Specification.Actiondatafilter`
44+
* @returns {Specification.IActiondatafilter} A builder for `Specification.Actiondatafilter`
3845
*/
39-
export function actiondatafilterBuilder(): Builder<Specification.Actiondatafilter> {
40-
return builder<Specification.Actiondatafilter>(actiondatafilterBuildingFn);
46+
export function actiondatafilterBuilder(): Builder<Specification.IActiondatafilter> {
47+
return builder<Specification.IActiondatafilter>(actiondatafilterBuildingFn);
4148
}

src/lib/builders/authdef-builder.ts

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,26 +16,33 @@
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
23-
* @param {Specification.Authdef} data The underlying object
24-
* @returns {Specification.Authdef} The validated underlying object
25+
* @param {Specification.IAuthdef} data The underlying object
26+
* @returns {Specification.IAuthdef} The validated underlying object
2527
*/
26-
function authdefBuildingFn(data: Specification.Authdef): () => Specification.Authdef {
28+
function authdefBuildingFn(data: Specification.IAuthdef): () => Specification.IAuthdef {
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

3542
/**
3643
* A factory to create a builder proxy for the type `Specification.Authdef`
37-
* @returns {Specification.Authdef} A builder for `Specification.Authdef`
44+
* @returns {Specification.IAuthdef} A builder for `Specification.Authdef`
3845
*/
39-
export function authdefBuilder(): Builder<Specification.Authdef> {
40-
return builder<Specification.Authdef>(authdefBuildingFn);
46+
export function authdefBuilder(): Builder<Specification.IAuthdef> {
47+
return builder<Specification.IAuthdef>(authdefBuildingFn);
4148
}

src/lib/builders/basicpropsdef-builder.ts

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,26 +16,33 @@
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
23-
* @param {Specification.Basicpropsdef} data The underlying object
24-
* @returns {Specification.Basicpropsdef} The validated underlying object
25+
* @param {Specification.IBasicpropsdef} data The underlying object
26+
* @returns {Specification.IBasicpropsdef} The validated underlying object
2527
*/
26-
function basicpropsdefBuildingFn(data: Specification.Basicpropsdef): () => Specification.Basicpropsdef {
28+
function basicpropsdefBuildingFn(data: Specification.IBasicpropsdef): () => Specification.IBasicpropsdef {
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

3542
/**
3643
* A factory to create a builder proxy for the type `Specification.Basicpropsdef`
37-
* @returns {Specification.Basicpropsdef} A builder for `Specification.Basicpropsdef`
44+
* @returns {Specification.IBasicpropsdef} A builder for `Specification.Basicpropsdef`
3845
*/
39-
export function basicpropsdefBuilder(): Builder<Specification.Basicpropsdef> {
40-
return builder<Specification.Basicpropsdef>(basicpropsdefBuildingFn);
46+
export function basicpropsdefBuilder(): Builder<Specification.IBasicpropsdef> {
47+
return builder<Specification.IBasicpropsdef>(basicpropsdefBuildingFn);
4148
}

src/lib/builders/bearerpropsdef-builder.ts

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,26 +16,33 @@
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
23-
* @param {Specification.Bearerpropsdef} data The underlying object
24-
* @returns {Specification.Bearerpropsdef} The validated underlying object
25+
* @param {Specification.IBearerpropsdef} data The underlying object
26+
* @returns {Specification.IBearerpropsdef} The validated underlying object
2527
*/
26-
function bearerpropsdefBuildingFn(data: Specification.Bearerpropsdef): () => Specification.Bearerpropsdef {
28+
function bearerpropsdefBuildingFn(data: Specification.IBearerpropsdef): () => Specification.IBearerpropsdef {
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

3542
/**
3643
* A factory to create a builder proxy for the type `Specification.Bearerpropsdef`
37-
* @returns {Specification.Bearerpropsdef} A builder for `Specification.Bearerpropsdef`
44+
* @returns {Specification.IBearerpropsdef} A builder for `Specification.Bearerpropsdef`
3845
*/
39-
export function bearerpropsdefBuilder(): Builder<Specification.Bearerpropsdef> {
40-
return builder<Specification.Bearerpropsdef>(bearerpropsdefBuildingFn);
46+
export function bearerpropsdefBuilder(): Builder<Specification.IBearerpropsdef> {
47+
return builder<Specification.IBearerpropsdef>(bearerpropsdefBuildingFn);
4148
}

src/lib/builders/branch-builder.ts

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,26 +16,33 @@
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
23-
* @param {Specification.Branch} data The underlying object
24-
* @returns {Specification.Branch} The validated underlying object
25+
* @param {Specification.IBranch} data The underlying object
26+
* @returns {Specification.IBranch} The validated underlying object
2527
*/
26-
function branchBuildingFn(data: Specification.Branch): () => Specification.Branch {
28+
function branchBuildingFn(data: Specification.IBranch): () => Specification.IBranch {
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

3542
/**
3643
* A factory to create a builder proxy for the type `Specification.Branch`
37-
* @returns {Specification.Branch} A builder for `Specification.Branch`
44+
* @returns {Specification.IBranch} A builder for `Specification.Branch`
3845
*/
39-
export function branchBuilder(): Builder<Specification.Branch> {
40-
return builder<Specification.Branch>(branchBuildingFn);
46+
export function branchBuilder(): Builder<Specification.IBranch> {
47+
return builder<Specification.IBranch>(branchBuildingFn);
4148
}

0 commit comments

Comments
 (0)