@kattebak/openapi-generator-ts 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +189 -0
- package/dist/cli/commands/generate.d.ts +23 -0
- package/dist/cli/commands/generate.d.ts.map +1 -0
- package/dist/cli/commands/generate.js +116 -0
- package/dist/cli/commands/generate.js.map +1 -0
- package/dist/cli/commands/list.d.ts +2 -0
- package/dist/cli/commands/list.d.ts.map +1 -0
- package/dist/cli/commands/list.js +26 -0
- package/dist/cli/commands/list.js.map +1 -0
- package/dist/cli/commands/validate.d.ts +6 -0
- package/dist/cli/commands/validate.d.ts.map +1 -0
- package/dist/cli/commands/validate.js +80 -0
- package/dist/cli/commands/validate.js.map +1 -0
- package/dist/cli/convert-template.d.ts +31 -0
- package/dist/cli/convert-template.d.ts.map +1 -0
- package/dist/cli/convert-template.js +204 -0
- package/dist/cli/convert-template.js.map +1 -0
- package/dist/cli/convert-template.test.d.ts +2 -0
- package/dist/cli/convert-template.test.d.ts.map +1 -0
- package/dist/cli/convert-template.test.js +74 -0
- package/dist/cli/convert-template.test.js.map +1 -0
- package/dist/cli/index.d.ts +3 -0
- package/dist/cli/index.d.ts.map +1 -0
- package/dist/cli/index.js +246 -0
- package/dist/cli/index.js.map +1 -0
- package/dist/core/config.d.ts +252 -0
- package/dist/core/config.d.ts.map +1 -0
- package/dist/core/config.js +31 -0
- package/dist/core/config.js.map +1 -0
- package/dist/core/generator.d.ts +99 -0
- package/dist/core/generator.d.ts.map +1 -0
- package/dist/core/generator.js +492 -0
- package/dist/core/generator.js.map +1 -0
- package/dist/core/index.d.ts +4 -0
- package/dist/core/index.d.ts.map +1 -0
- package/dist/core/index.js +4 -0
- package/dist/core/index.js.map +1 -0
- package/dist/core/types.d.ts +47 -0
- package/dist/core/types.d.ts.map +1 -0
- package/dist/core/types.js +5 -0
- package/dist/core/types.js.map +1 -0
- package/dist/generators/generators.test.d.ts +6 -0
- package/dist/generators/generators.test.d.ts.map +1 -0
- package/dist/generators/generators.test.js +247 -0
- package/dist/generators/generators.test.js.map +1 -0
- package/dist/generators/go.d.ts +10 -0
- package/dist/generators/go.d.ts.map +1 -0
- package/dist/generators/go.js +327 -0
- package/dist/generators/go.js.map +1 -0
- package/dist/generators/index.d.ts +29 -0
- package/dist/generators/index.d.ts.map +1 -0
- package/dist/generators/index.js +58 -0
- package/dist/generators/index.js.map +1 -0
- package/dist/generators/php.d.ts +14 -0
- package/dist/generators/php.d.ts.map +1 -0
- package/dist/generators/php.js +241 -0
- package/dist/generators/php.js.map +1 -0
- package/dist/generators/python.d.ts +10 -0
- package/dist/generators/python.d.ts.map +1 -0
- package/dist/generators/python.js +273 -0
- package/dist/generators/python.js.map +1 -0
- package/dist/generators/typescript-fetch.d.ts +14 -0
- package/dist/generators/typescript-fetch.d.ts.map +1 -0
- package/dist/generators/typescript-fetch.js +217 -0
- package/dist/generators/typescript-fetch.js.map +1 -0
- package/dist/index.d.ts +14 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +16 -0
- package/dist/index.js.map +1 -0
- package/dist/models/codegen-model.d.ts +123 -0
- package/dist/models/codegen-model.d.ts.map +1 -0
- package/dist/models/codegen-model.js +64 -0
- package/dist/models/codegen-model.js.map +1 -0
- package/dist/models/codegen-model.test.d.ts +6 -0
- package/dist/models/codegen-model.test.d.ts.map +1 -0
- package/dist/models/codegen-model.test.js +143 -0
- package/dist/models/codegen-model.test.js.map +1 -0
- package/dist/models/codegen-operation.d.ts +95 -0
- package/dist/models/codegen-operation.d.ts.map +1 -0
- package/dist/models/codegen-operation.js +54 -0
- package/dist/models/codegen-operation.js.map +1 -0
- package/dist/models/codegen-parameter.d.ts +86 -0
- package/dist/models/codegen-parameter.d.ts.map +1 -0
- package/dist/models/codegen-parameter.js +47 -0
- package/dist/models/codegen-parameter.js.map +1 -0
- package/dist/models/codegen-property.d.ts +95 -0
- package/dist/models/codegen-property.d.ts.map +1 -0
- package/dist/models/codegen-property.js +47 -0
- package/dist/models/codegen-property.js.map +1 -0
- package/dist/models/codegen-response.d.ts +64 -0
- package/dist/models/codegen-response.d.ts.map +1 -0
- package/dist/models/codegen-response.js +42 -0
- package/dist/models/codegen-response.js.map +1 -0
- package/dist/models/codegen-security.d.ts +34 -0
- package/dist/models/codegen-security.d.ts.map +1 -0
- package/dist/models/codegen-security.js +18 -0
- package/dist/models/codegen-security.js.map +1 -0
- package/dist/models/index.d.ts +8 -0
- package/dist/models/index.d.ts.map +1 -0
- package/dist/models/index.js +7 -0
- package/dist/models/index.js.map +1 -0
- package/dist/parser/index.d.ts +4 -0
- package/dist/parser/index.d.ts.map +1 -0
- package/dist/parser/index.js +4 -0
- package/dist/parser/index.js.map +1 -0
- package/dist/parser/openapi-parser.d.ts +71 -0
- package/dist/parser/openapi-parser.d.ts.map +1 -0
- package/dist/parser/openapi-parser.js +195 -0
- package/dist/parser/openapi-parser.js.map +1 -0
- package/dist/parser/openapi-parser.test.d.ts +6 -0
- package/dist/parser/openapi-parser.test.d.ts.map +1 -0
- package/dist/parser/openapi-parser.test.js +238 -0
- package/dist/parser/openapi-parser.test.js.map +1 -0
- package/dist/parser/operation-transformer.d.ts +95 -0
- package/dist/parser/operation-transformer.d.ts.map +1 -0
- package/dist/parser/operation-transformer.js +634 -0
- package/dist/parser/operation-transformer.js.map +1 -0
- package/dist/parser/schema-transformer.d.ts +134 -0
- package/dist/parser/schema-transformer.d.ts.map +1 -0
- package/dist/parser/schema-transformer.js +557 -0
- package/dist/parser/schema-transformer.js.map +1 -0
- package/dist/template/engine-adapter.d.ts +55 -0
- package/dist/template/engine-adapter.d.ts.map +1 -0
- package/dist/template/engine-adapter.js +178 -0
- package/dist/template/engine-adapter.js.map +1 -0
- package/dist/template/engine-adapter.test.d.ts +6 -0
- package/dist/template/engine-adapter.test.d.ts.map +1 -0
- package/dist/template/engine-adapter.test.js +186 -0
- package/dist/template/engine-adapter.test.js.map +1 -0
- package/dist/template/index.d.ts +5 -0
- package/dist/template/index.d.ts.map +1 -0
- package/dist/template/index.js +5 -0
- package/dist/template/index.js.map +1 -0
- package/dist/template/lambdas/indent-lambdas.d.ts +40 -0
- package/dist/template/lambdas/indent-lambdas.d.ts.map +1 -0
- package/dist/template/lambdas/indent-lambdas.js +98 -0
- package/dist/template/lambdas/indent-lambdas.js.map +1 -0
- package/dist/template/lambdas/index.d.ts +44 -0
- package/dist/template/lambdas/index.d.ts.map +1 -0
- package/dist/template/lambdas/index.js +79 -0
- package/dist/template/lambdas/index.js.map +1 -0
- package/dist/template/lambdas/string-lambdas.d.ts +78 -0
- package/dist/template/lambdas/string-lambdas.d.ts.map +1 -0
- package/dist/template/lambdas/string-lambdas.js +148 -0
- package/dist/template/lambdas/string-lambdas.js.map +1 -0
- package/dist/template/lambdas/string-lambdas.test.d.ts +6 -0
- package/dist/template/lambdas/string-lambdas.test.d.ts.map +1 -0
- package/dist/template/lambdas/string-lambdas.test.js +158 -0
- package/dist/template/lambdas/string-lambdas.test.js.map +1 -0
- package/dist/template/template-locator.d.ts +72 -0
- package/dist/template/template-locator.d.ts.map +1 -0
- package/dist/template/template-locator.js +173 -0
- package/dist/template/template-locator.js.map +1 -0
- package/dist/template/template-manager.d.ts +65 -0
- package/dist/template/template-manager.d.ts.map +1 -0
- package/dist/template/template-manager.js +185 -0
- package/dist/template/template-manager.js.map +1 -0
- package/package.json +67 -0
- package/templates/go/.travis.yml +8 -0
- package/templates/go/README.mustache +236 -0
- package/templates/go/api.mustache +452 -0
- package/templates/go/api_doc.mustache +92 -0
- package/templates/go/api_test.mustache +59 -0
- package/templates/go/client.mustache +761 -0
- package/templates/go/configuration.mustache +332 -0
- package/templates/go/git_push.sh.mustache +57 -0
- package/templates/go/gitignore.mustache +24 -0
- package/templates/go/go.mod.mustache +16 -0
- package/templates/go/go.sum.mustache +19 -0
- package/templates/go/model.mustache +21 -0
- package/templates/go/model_anyof.mustache +93 -0
- package/templates/go/model_doc.mustache +97 -0
- package/templates/go/model_enum.mustache +101 -0
- package/templates/go/model_oneof.mustache +160 -0
- package/templates/go/model_simple.mustache +572 -0
- package/templates/go/nullable_model.mustache +35 -0
- package/templates/go/openapi.mustache +1 -0
- package/templates/go/partial_header.mustache +18 -0
- package/templates/go/response.mustache +38 -0
- package/templates/go/signing.mustache +453 -0
- package/templates/go/utils.mustache +352 -0
- package/templates/php/.php-cs-fixer.dist.php +29 -0
- package/templates/php/.travis.yml +8 -0
- package/templates/php/ApiException.mustache +111 -0
- package/templates/php/Configuration.mustache +606 -0
- package/templates/php/FormDataProcessor.mustache +238 -0
- package/templates/php/HeaderSelector.mustache +265 -0
- package/templates/php/ModelInterface.mustache +103 -0
- package/templates/php/ObjectSerializer.mustache +591 -0
- package/templates/php/README.mustache +151 -0
- package/templates/php/api.mustache +891 -0
- package/templates/php/api_doc.mustache +105 -0
- package/templates/php/api_test.mustache +80 -0
- package/templates/php/composer.mustache +44 -0
- package/templates/php/git_push.sh.mustache +57 -0
- package/templates/php/gitignore +15 -0
- package/templates/php/libraries/psr-18/ApiException.mustache +114 -0
- package/templates/php/libraries/psr-18/DebugPlugin.mustache +93 -0
- package/templates/php/libraries/psr-18/README.mustache +161 -0
- package/templates/php/libraries/psr-18/api.mustache +833 -0
- package/templates/php/libraries/psr-18/api_doc.mustache +79 -0
- package/templates/php/libraries/psr-18/composer.mustache +56 -0
- package/templates/php/model.mustache +47 -0
- package/templates/php/model_doc.mustache +10 -0
- package/templates/php/model_enum.mustache +33 -0
- package/templates/php/model_generic.mustache +565 -0
- package/templates/php/model_test.mustache +88 -0
- package/templates/php/partial_header.mustache +18 -0
- package/templates/php/php_doc_auth_partial.mustache +23 -0
- package/templates/php/phpunit.xml.mustache +18 -0
- package/templates/python/README.mustache +60 -0
- package/templates/python/README_onlypackage.mustache +50 -0
- package/templates/python/__init__.mustache +1 -0
- package/templates/python/__init__api.mustache +19 -0
- package/templates/python/__init__model.mustache +22 -0
- package/templates/python/__init__package.mustache +49 -0
- package/templates/python/api.mustache +244 -0
- package/templates/python/api_client.mustache +822 -0
- package/templates/python/api_doc.mustache +81 -0
- package/templates/python/api_doc_example.mustache +38 -0
- package/templates/python/api_response.mustache +21 -0
- package/templates/python/api_test.mustache +48 -0
- package/templates/python/asyncio/rest.mustache +209 -0
- package/templates/python/common_README.mustache +85 -0
- package/templates/python/configuration.mustache +806 -0
- package/templates/python/exceptions.mustache +210 -0
- package/templates/python/exports_api.mustache +3 -0
- package/templates/python/exports_model.mustache +3 -0
- package/templates/python/exports_package.mustache +20 -0
- package/templates/python/git_push.sh.mustache +57 -0
- package/templates/python/github-workflow.mustache +35 -0
- package/templates/python/gitignore.mustache +66 -0
- package/templates/python/gitlab-ci.mustache +31 -0
- package/templates/python/httpx/rest.mustache +190 -0
- package/templates/python/model.mustache +16 -0
- package/templates/python/model_anyof.mustache +182 -0
- package/templates/python/model_doc.mustache +40 -0
- package/templates/python/model_enum.mustache +36 -0
- package/templates/python/model_generic.mustache +403 -0
- package/templates/python/model_oneof.mustache +209 -0
- package/templates/python/model_test.mustache +60 -0
- package/templates/python/partial_api.mustache +52 -0
- package/templates/python/partial_api_args.mustache +18 -0
- package/templates/python/partial_header.mustache +19 -0
- package/templates/python/py.typed.mustache +1 -0
- package/templates/python/pyproject.mustache +172 -0
- package/templates/python/python_doc_auth_partial.mustache +108 -0
- package/templates/python/requirements.mustache +23 -0
- package/templates/python/rest.mustache +254 -0
- package/templates/python/setup.mustache +60 -0
- package/templates/python/setup_cfg.mustache +2 -0
- package/templates/python/signing.mustache +422 -0
- package/templates/python/test-requirements.mustache +6 -0
- package/templates/python/tornado/rest.mustache +148 -0
- package/templates/python/tox.mustache +9 -0
- package/templates/python/travis.mustache +17 -0
- package/templates/typescript-fetch/ApiEntitiesRecord.mustache +26 -0
- package/templates/typescript-fetch/ApiEntitiesReducer.mustache +21 -0
- package/templates/typescript-fetch/ApiEntitiesSelectors.mustache +5 -0
- package/templates/typescript-fetch/README.mustache +127 -0
- package/templates/typescript-fetch/allSagas.mustache +19 -0
- package/templates/typescript-fetch/api_doc.mustache +63 -0
- package/templates/typescript-fetch/api_example.mustache +44 -0
- package/templates/typescript-fetch/apis.index.mustache +16 -0
- package/templates/typescript-fetch/apis.mustache +483 -0
- package/templates/typescript-fetch/apisAssignQueryParam.mustache +12 -0
- package/templates/typescript-fetch/gitignore +4 -0
- package/templates/typescript-fetch/index.mustache +17 -0
- package/templates/typescript-fetch/licenseInfo.mustache +11 -0
- package/templates/typescript-fetch/modelEnum.mustache +28 -0
- package/templates/typescript-fetch/modelEnumInterfaces.mustache +37 -0
- package/templates/typescript-fetch/modelGeneric.mustache +261 -0
- package/templates/typescript-fetch/modelGenericInterfaces.mustache +50 -0
- package/templates/typescript-fetch/modelOneOf.mustache +255 -0
- package/templates/typescript-fetch/modelOneOfInterfaces.mustache +6 -0
- package/templates/typescript-fetch/model_doc.mustache +41 -0
- package/templates/typescript-fetch/models.index.mustache +32 -0
- package/templates/typescript-fetch/models.mustache +24 -0
- package/templates/typescript-fetch/npmignore.mustache +1 -0
- package/templates/typescript-fetch/package.mustache +43 -0
- package/templates/typescript-fetch/recordGeneric.mustache +295 -0
- package/templates/typescript-fetch/records.mustache +17 -0
- package/templates/typescript-fetch/runtime.mustache +424 -0
- package/templates/typescript-fetch/runtimeSagasAndRecords.mustache +120 -0
- package/templates/typescript-fetch/sagaApiManager.mustache +28 -0
- package/templates/typescript-fetch/sagas.mustache +245 -0
- package/templates/typescript-fetch/sourceLibraryIndex.mustache +1 -0
- package/templates/typescript-fetch/tsconfig.esm.mustache +7 -0
- package/templates/typescript-fetch/tsconfig.mustache +25 -0
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "{{npmName}}",
|
|
3
|
+
"version": "{{npmVersion}}",
|
|
4
|
+
"description": "OpenAPI client for {{npmName}}",
|
|
5
|
+
"author": "OpenAPI-Generator",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "https://{{gitHost}}/{{gitUserId}}/{{gitRepoId}}.git"
|
|
9
|
+
},
|
|
10
|
+
{{#if licenseName}}
|
|
11
|
+
"license": "{{licenseName}}",
|
|
12
|
+
{{/if}}
|
|
13
|
+
{{#packageAsSourceOnlyLibrary}}
|
|
14
|
+
"main": "./index.ts",
|
|
15
|
+
{{/packageAsSourceOnlyLibrary}}
|
|
16
|
+
{{^packageAsSourceOnlyLibrary}}
|
|
17
|
+
"main": "./dist/index.js",
|
|
18
|
+
"types": "./dist/index.d.ts",
|
|
19
|
+
{{#supportsES6}}
|
|
20
|
+
"module": "./dist/esm/index.js",
|
|
21
|
+
"sideEffects": false,
|
|
22
|
+
{{/supportsES6}}
|
|
23
|
+
"scripts": {
|
|
24
|
+
"build": "tsc{{#supportsES6}} && tsc -p tsconfig.esm.json{{/supportsES6}}"{{^sagasAndRecords}},
|
|
25
|
+
"prepare": "npm run build"{{/sagasAndRecords}}
|
|
26
|
+
},
|
|
27
|
+
{{/packageAsSourceOnlyLibrary}}
|
|
28
|
+
"devDependencies": {
|
|
29
|
+
{{#sagasAndRecords}}
|
|
30
|
+
"immutable": "^4.[0].0-rc.12",
|
|
31
|
+
"normalizr": "^3.[6].1",
|
|
32
|
+
"redux-saga": "^1.[1].3",
|
|
33
|
+
"redux-ts-simple": "^3.[2].0",
|
|
34
|
+
"reselect": "^4.[0].0",
|
|
35
|
+
{{/sagasAndRecords}}
|
|
36
|
+
"typescript": "^4.0 || ^5.0"
|
|
37
|
+
}{{#npmRepository}},{{/npmRepository}}
|
|
38
|
+
{{#npmRepository}}
|
|
39
|
+
"publishConfig": {
|
|
40
|
+
"registry": "{{npmRepository}}"
|
|
41
|
+
}
|
|
42
|
+
{{/npmRepository}}
|
|
43
|
+
}
|
|
@@ -0,0 +1,295 @@
|
|
|
1
|
+
import {ApiRecordUtils, knownRecordFactories{{#returnPassthrough}}, appFromJS, NormalizedRecordEntities{{/returnPassthrough}}} from "../runtimeSagasAndRecords{{importFileExtension}}";
|
|
2
|
+
import {getApiEntitiesState} from "../ApiEntitiesSelectors{{importFileExtension}}"
|
|
3
|
+
import {List, Record, RecordOf, Map} from 'immutable';
|
|
4
|
+
import {Schema, schema, NormalizedSchema} from "normalizr";
|
|
5
|
+
import {select, call} from "redux-saga/effects";
|
|
6
|
+
|
|
7
|
+
import {
|
|
8
|
+
{{classname}},
|
|
9
|
+
{{#vars}}
|
|
10
|
+
{{#isEnum}}
|
|
11
|
+
{{classname}}{{enumName}},
|
|
12
|
+
{{/isEnum}}
|
|
13
|
+
{{/vars}}
|
|
14
|
+
} from './{{classname}}{{importFileExtension}}';
|
|
15
|
+
|
|
16
|
+
{{#imports}}
|
|
17
|
+
import {
|
|
18
|
+
{{{.}}},
|
|
19
|
+
} from './{{{.}}}{{importFileExtension}}';
|
|
20
|
+
{{/imports}}
|
|
21
|
+
|
|
22
|
+
{{#modelImports}}
|
|
23
|
+
import {
|
|
24
|
+
{{{.}}}Record,
|
|
25
|
+
{{#camelcase}}{{.}}{{/camelcase}}RecordUtils
|
|
26
|
+
} from './{{{.}}}Record{{importFileExtension}}';
|
|
27
|
+
{{/modelImports}}
|
|
28
|
+
|
|
29
|
+
export const {{classname}}RecordProps = {
|
|
30
|
+
recType: "{{classname}}ApiRecord" as "{{classname}}ApiRecord",
|
|
31
|
+
{{#vars}}
|
|
32
|
+
{{#isArray}}
|
|
33
|
+
{{#items.isModel}}
|
|
34
|
+
{{#keepAsJSObject}}
|
|
35
|
+
{{name}}: {{#required}}new {{{dataType}}}(){{/required}}{{^required}}null as {{{dataType}}} | null{{/required}},
|
|
36
|
+
{{/keepAsJSObject}}
|
|
37
|
+
{{^keepAsJSObject}}
|
|
38
|
+
{{name}}: ({{{items.dataType}}}Record(), {{#required}}{{{defaultValue}}}{{/required}}{{^required}}null as {{{dataTypeAlternate}}} | null{{/required}}),
|
|
39
|
+
{{/keepAsJSObject}}
|
|
40
|
+
{{/items.isModel}}
|
|
41
|
+
{{^items.isModel}}
|
|
42
|
+
{{name}}: {{#required}}{{{defaultValue}}}{{/required}}{{^required}}null as {{{dataTypeAlternate}}} | null{{/required}},
|
|
43
|
+
{{/items.isModel}}
|
|
44
|
+
{{/isArray}}
|
|
45
|
+
{{#isModel}}
|
|
46
|
+
{{#keepAsJSObject}}
|
|
47
|
+
{{name}}: {{#required}}{} as any as {{{dataType}}}{{/required}}{{^required}}null as {{{dataType}}} | null{{/required}},
|
|
48
|
+
{{/keepAsJSObject}}
|
|
49
|
+
{{^keepAsJSObject}}
|
|
50
|
+
{{name}}: {{#required}}{{{defaultValue}}}{{/required}}{{^required}}({{{defaultValue}}}, null as {{{dataTypeAlternate}}} | null){{/required}},
|
|
51
|
+
{{/keepAsJSObject}}
|
|
52
|
+
{{/isModel}}
|
|
53
|
+
{{^isArray}}
|
|
54
|
+
{{^isModel}}
|
|
55
|
+
{{name}}: {{#required}}{{{defaultValue}}}{{/required}}{{^required}}null as {{{dataTypeAlternate}}} | null{{/required}},
|
|
56
|
+
{{/isModel}}
|
|
57
|
+
{{/isArray}}
|
|
58
|
+
{{/vars}}
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
export type {{classname}}RecordPropsType = typeof {{classname}}RecordProps;
|
|
62
|
+
export const {{classname}}Record = Record({{classname}}RecordProps, {{classname}}RecordProps.recType);
|
|
63
|
+
export type {{classname}}Record = RecordOf<{{classname}}RecordPropsType>;
|
|
64
|
+
|
|
65
|
+
knownRecordFactories.set({{classname}}RecordProps.recType, {{classname}}Record);
|
|
66
|
+
|
|
67
|
+
{{#isEntity}}
|
|
68
|
+
export const {{classname}}RecordEntityProps = {
|
|
69
|
+
...{{classname}}RecordProps,
|
|
70
|
+
recType: "{{classname}}ApiRecordEntity" as "{{classname}}ApiRecordEntity",
|
|
71
|
+
{{#vars}}
|
|
72
|
+
{{#isEntity}}
|
|
73
|
+
{{^keepAsJSObject}}
|
|
74
|
+
{{name}}: {{#required}}"-1"{{/required}}{{^required}}null as string | null{{/required}},
|
|
75
|
+
{{/keepAsJSObject}}
|
|
76
|
+
{{/isEntity}}
|
|
77
|
+
{{#isArray}}
|
|
78
|
+
{{#items.isEntity}}
|
|
79
|
+
{{^keepAsJSObject}}
|
|
80
|
+
{{name}}: {{#required}}List<string>(){{/required}}{{^required}}null as List<string> | null{{/required}},
|
|
81
|
+
{{/keepAsJSObject}}
|
|
82
|
+
{{/items.isEntity}}
|
|
83
|
+
{{/isArray}}
|
|
84
|
+
{{/vars}}
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
export type {{classname}}RecordEntityPropsType = typeof {{classname}}RecordEntityProps;
|
|
88
|
+
export const {{classname}}RecordEntity = Record({{classname}}RecordEntityProps, {{classname}}RecordEntityProps.recType);
|
|
89
|
+
export type {{classname}}RecordEntity = RecordOf<{{classname}}RecordEntityPropsType>;
|
|
90
|
+
|
|
91
|
+
knownRecordFactories.set({{classname}}RecordEntityProps.recType, {{classname}}RecordEntity);
|
|
92
|
+
{{/isEntity}}
|
|
93
|
+
|
|
94
|
+
class {{classname}}RecordUtils extends ApiRecordUtils<{{classname}}, {{classname}}Record> {
|
|
95
|
+
public normalize(apiObject: {{classname}}, asEntity?: boolean): {{classname}} {
|
|
96
|
+
(apiObject as any).recType = {{#isEntity}}asEntity ? {{classname}}RecordEntityProps.recType : {{/isEntity}}{{classname}}RecordProps.recType;
|
|
97
|
+
{{#vars}}
|
|
98
|
+
{{#isUniqueId}}
|
|
99
|
+
{{#isArray}}
|
|
100
|
+
{{#items.isArray}}
|
|
101
|
+
{{^required}}if (apiObject['{{name}}']) { {{/required}}(apiObject as any)['{{name}}'] = apiObject['{{name}}'].map(item => item.map(item2 => item2?.toString()));{{^required}} } {{/required}}
|
|
102
|
+
{{/items.isArray}}
|
|
103
|
+
{{^items.isArray}}
|
|
104
|
+
{{^required}}if (apiObject['{{name}}']) { {{/required}}(apiObject as any)['{{name}}'] = apiObject['{{name}}'].map(item => item?.toString());{{^required}} } {{/required}}
|
|
105
|
+
{{/items.isArray}}
|
|
106
|
+
{{/isArray}}
|
|
107
|
+
{{^isArray}}
|
|
108
|
+
{{^required}}if (apiObject['{{name}}']) { {{/required}}(apiObject as any)['{{name}}'] = apiObject['{{name}}'].toString();{{^required}} } {{/required}}
|
|
109
|
+
{{/isArray}}
|
|
110
|
+
{{/isUniqueId}}
|
|
111
|
+
{{^keepAsJSObject}}
|
|
112
|
+
{{#isModel}}
|
|
113
|
+
{{^required}}if (apiObject['{{name}}']) { {{/required}}{{#camelcase}}{{{dataTypeAlternate}}}{{/camelcase}}Utils.normalize(apiObject['{{name}}']);{{^required}} } {{/required}}
|
|
114
|
+
{{/isModel}}
|
|
115
|
+
{{#isArray}}
|
|
116
|
+
{{#items.isModel}}
|
|
117
|
+
{{^required}}if (apiObject['{{name}}']) { {{/required}}{{#camelcase}}{{items.dataType}}{{/camelcase}}RecordUtils.normalizeArray(apiObject['{{name}}']);{{^required}} } {{/required}}
|
|
118
|
+
{{/items.isModel}}
|
|
119
|
+
{{/isArray}}
|
|
120
|
+
{{/keepAsJSObject}}
|
|
121
|
+
{{/vars}}
|
|
122
|
+
return apiObject;
|
|
123
|
+
}
|
|
124
|
+
{{#isEntity}}
|
|
125
|
+
|
|
126
|
+
public getSchema(): Schema {
|
|
127
|
+
return new schema.Entity("{{#camelcase}}{{classname}}{{/camelcase}}", {
|
|
128
|
+
{{#vars}}
|
|
129
|
+
{{#isEntity}}
|
|
130
|
+
{{^keepAsJSObject}}
|
|
131
|
+
{{name}}: {{#camelcase}}{{{dataTypeAlternate}}}{{/camelcase}}Utils.getSchema(),
|
|
132
|
+
{{/keepAsJSObject}}
|
|
133
|
+
{{/isEntity}}
|
|
134
|
+
{{#isArray}}
|
|
135
|
+
{{#items.isEntity}}
|
|
136
|
+
{{^keepAsJSObject}}
|
|
137
|
+
{{name}}: [{{#camelcase}}{{items.dataType}}{{/camelcase}}RecordUtils.getSchema()],
|
|
138
|
+
{{/keepAsJSObject}}
|
|
139
|
+
{{/items.isEntity}}
|
|
140
|
+
{{/isArray}}
|
|
141
|
+
{{/vars}}
|
|
142
|
+
});
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
public *toInlined(entityId?: string | null) {
|
|
146
|
+
if (!entityId) {return undefined; }
|
|
147
|
+
// @ts-ignore
|
|
148
|
+
const entity = yield select(apiEntity{{classname}}Selector, {id: entityId});
|
|
149
|
+
if (!entity) {return undefined; }
|
|
150
|
+
|
|
151
|
+
const {
|
|
152
|
+
recType,
|
|
153
|
+
{{#vars}}
|
|
154
|
+
{{#isEntity}}
|
|
155
|
+
{{^keepAsJSObject}}
|
|
156
|
+
{{name}}: {{name}}_original,
|
|
157
|
+
{{/keepAsJSObject}}
|
|
158
|
+
{{/isEntity}}
|
|
159
|
+
{{#isArray}}
|
|
160
|
+
{{#items.isEntity}}
|
|
161
|
+
{{^keepAsJSObject}}
|
|
162
|
+
{{name}}: {{name}}_original,
|
|
163
|
+
{{/keepAsJSObject}}
|
|
164
|
+
{{/items.isEntity}}
|
|
165
|
+
{{/isArray}}
|
|
166
|
+
{{/vars}}
|
|
167
|
+
...unchangedProperties
|
|
168
|
+
} = entity;
|
|
169
|
+
|
|
170
|
+
const entityProperties = {
|
|
171
|
+
{{#vars}}
|
|
172
|
+
{{#isEntity}}
|
|
173
|
+
{{^keepAsJSObject}}
|
|
174
|
+
// @ts-ignore
|
|
175
|
+
{{name}}: {{^required}}entity['{{name}}'] ? {{/required}}yield call({{#camelcase}}{{{dataTypeAlternate}}}{{/camelcase}}Utils.toInlined, entity['{{name}}']){{^required}} : null{{/required}},
|
|
176
|
+
{{/keepAsJSObject}}
|
|
177
|
+
{{/isEntity}}
|
|
178
|
+
{{#isArray}}
|
|
179
|
+
{{#items.isEntity}}
|
|
180
|
+
{{^keepAsJSObject}}
|
|
181
|
+
// @ts-ignore
|
|
182
|
+
{{name}}: {{^required}}entity['{{name}}'] ? {{/required}}yield call({{#camelcase}}{{items.dataType}}{{/camelcase}}RecordUtils.toInlinedArray, entity['{{name}}']){{^required}} : null{{/required}},
|
|
183
|
+
{{/keepAsJSObject}}
|
|
184
|
+
{{/items.isEntity}}
|
|
185
|
+
{{/isArray}}
|
|
186
|
+
{{/vars}}
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
return {{classname}}Record({
|
|
190
|
+
...unchangedProperties,
|
|
191
|
+
...entityProperties
|
|
192
|
+
});
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
public *toInlinedArray(entityIds: List<string> | null) {
|
|
196
|
+
if (!entityIds) {return null; }
|
|
197
|
+
let entities = List<{{classname}}Record>();
|
|
198
|
+
for (let entityIndex = 0; entityIndex < entityIds.count(); entityIndex++) {
|
|
199
|
+
// @ts-ignore
|
|
200
|
+
const entity = yield call(this.toInlined, entityIds.get(entityIndex));
|
|
201
|
+
if (entity) {
|
|
202
|
+
entities.push(entity);
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
return entities;
|
|
206
|
+
}
|
|
207
|
+
{{/isEntity}}
|
|
208
|
+
|
|
209
|
+
public toApi(record: {{classname}}Record): {{classname}} {
|
|
210
|
+
const apiObject = super.toApi(record);
|
|
211
|
+
{{#vars}}
|
|
212
|
+
{{#isUniqueId}}
|
|
213
|
+
{{#isArray}}
|
|
214
|
+
{{#items.isArray}}
|
|
215
|
+
{{^required}}if (record['{{name}}']) { {{/required}}apiObject['{{name}}'] = {{#isArray}}record['{{name}}'].map(item => item.toArray().map(item2 => (item2 ? parseFloat(item2) : null) as number)).toArray(){{/isArray}};{{^required}} } {{/required}}
|
|
216
|
+
{{/items.isArray}}
|
|
217
|
+
{{^items.isArray}}
|
|
218
|
+
{{^required}}if (record['{{name}}']) { {{/required}}apiObject['{{name}}'] = {{#isArray}}record['{{name}}'].map(item => (item ? parseFloat(item) : null) as number).toArray(){{/isArray}};{{^required}} } {{/required}}
|
|
219
|
+
{{/items.isArray}}
|
|
220
|
+
{{/isArray}}
|
|
221
|
+
{{^isArray}}
|
|
222
|
+
{{^required}}if (record['{{name}}']) { {{/required}}apiObject['{{name}}'] = {{^isArray}}parseFloat(record['{{name}}']){{/isArray}};{{^required}} } {{/required}}
|
|
223
|
+
{{/isArray}}
|
|
224
|
+
{{/isUniqueId}}
|
|
225
|
+
{{^keepAsJSObject}}
|
|
226
|
+
{{#isModel}}
|
|
227
|
+
{{^required}}if (record['{{name}}']) { {{/required}}apiObject['{{name}}'] = {{#camelcase}}{{{dataTypeAlternate}}}{{/camelcase}}Utils.toApi(record['{{name}}']);{{^required}} } {{/required}}
|
|
228
|
+
{{/isModel}}
|
|
229
|
+
{{#isArray}}
|
|
230
|
+
{{#items.isModel}}
|
|
231
|
+
{{^required}}if (record['{{name}}']) { {{/required}}apiObject['{{name}}'] = {{#camelcase}}{{items.dataType}}{{/camelcase}}RecordUtils.toApiArray(record['{{name}}']);{{^required}} } {{/required}}
|
|
232
|
+
{{/items.isModel}}
|
|
233
|
+
{{/isArray}}
|
|
234
|
+
{{/keepAsJSObject}}
|
|
235
|
+
{{/vars}}
|
|
236
|
+
return apiObject;
|
|
237
|
+
}
|
|
238
|
+
{{#returnPassthrough}}
|
|
239
|
+
{{#vars.[1]}}
|
|
240
|
+
|
|
241
|
+
public fromApiPassthrough(apiObject: {{classname}}): {{{dataTypeAlternate}}} {
|
|
242
|
+
{{#isModel}}
|
|
243
|
+
if (!apiObject.{{{returnPassthrough}}}) {return {{{defaultValue}}}; }
|
|
244
|
+
const normalizedApiObject = {{#camelcase}}{{{dataTypeAlternate}}}{{/camelcase}}Utils.normalize(apiObject.{{{returnPassthrough}}});
|
|
245
|
+
return appFromJS(normalizedApiObject);
|
|
246
|
+
{{/isModel}}
|
|
247
|
+
{{#isArray}}
|
|
248
|
+
{{#items.isModel}}
|
|
249
|
+
if (!apiObject.{{{returnPassthrough}}}) {return {{{defaultValue}}}; }
|
|
250
|
+
const normalizedApiObject = {{#camelcase}}{{items.dataType}}{{/camelcase}}RecordUtils.normalizeArray(apiObject.{{{returnPassthrough}}});
|
|
251
|
+
return appFromJS(normalizedApiObject);
|
|
252
|
+
{{/items.isModel}}
|
|
253
|
+
{{^items.isModel}}
|
|
254
|
+
return appFromJS(apiObject.{{{returnPassthrough}}});
|
|
255
|
+
{{/items.isModel}}
|
|
256
|
+
{{/isArray}}
|
|
257
|
+
{{^isModel}}
|
|
258
|
+
{{^isArray}}
|
|
259
|
+
return apiObject.{{{returnPassthrough}}}!;
|
|
260
|
+
{{/isArray}}
|
|
261
|
+
{{/isModel}}
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
public fromApiPassthroughAsEntities(apiObject: {{classname}}): NormalizedRecordEntities {
|
|
265
|
+
{{#isEntity}}
|
|
266
|
+
if (!apiObject.{{{returnPassthrough}}}) {return {entities: {}, result: List<string>()}; }
|
|
267
|
+
return ApiRecordUtils.toNormalizedRecordEntities({{#camelcase}}{{{dataTypeAlternate}}}{{/camelcase}}Utils.normalizeArrayAsEntities([apiObject.{{{returnPassthrough}}}]), true);
|
|
268
|
+
{{/isEntity}}
|
|
269
|
+
{{#isArray}}
|
|
270
|
+
{{#items.isEntity}}
|
|
271
|
+
if (!apiObject.{{{returnPassthrough}}}) {return {entities: {}, result: List<string>()}; }
|
|
272
|
+
return ApiRecordUtils.toNormalizedRecordEntities({{#camelcase}}{{items.dataType}}{{/camelcase}}RecordUtils.normalizeArrayAsEntities(apiObject.{{{returnPassthrough}}}), true);
|
|
273
|
+
{{/items.isEntity}}
|
|
274
|
+
{{^items.isEntity}}
|
|
275
|
+
console.log("entities revival not supported on this response");
|
|
276
|
+
return {entities: {}, result: List<string>()};
|
|
277
|
+
{{/items.isEntity}}
|
|
278
|
+
{{/isArray}}
|
|
279
|
+
{{^isEntity}}
|
|
280
|
+
{{^isArray}}
|
|
281
|
+
console.log("entities revival not supported on this response");
|
|
282
|
+
return {entities: {}, result: List<string>()};
|
|
283
|
+
{{/isArray}}
|
|
284
|
+
{{/isEntity}}
|
|
285
|
+
}
|
|
286
|
+
{{/vars.[1]}}
|
|
287
|
+
{{/returnPassthrough}}
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
export const {{#camelcase}}{{classname}}{{/camelcase}}RecordUtils = new {{classname}}RecordUtils();
|
|
291
|
+
|
|
292
|
+
{{#isEntity}}
|
|
293
|
+
export const apiEntities{{classname}}Selector = (state: any) => getApiEntitiesState(state).{{#camelcase}}{{classname}}{{/camelcase}} as Map<string, {{classname}}RecordEntity>;
|
|
294
|
+
export const apiEntity{{classname}}Selector = (state: any, {id}: {id?: string | null}) => id ? apiEntities{{classname}}Selector(state).get(id) : undefined;
|
|
295
|
+
{{/isEntity}}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
{{#models}}
|
|
2
|
+
{{#model}}
|
|
3
|
+
{{#isEnum}}
|
|
4
|
+
// This file is not needed and was generated only because of how codegen is built... Enums do not need to be converted to Records and can be used directly.
|
|
5
|
+
{{/isEnum}}
|
|
6
|
+
{{^isEnum}}
|
|
7
|
+
{{^oneOf}}
|
|
8
|
+
/* tslint:disable */
|
|
9
|
+
/* eslint-disable */
|
|
10
|
+
{{>licenseInfo}}
|
|
11
|
+
|
|
12
|
+
{{>recordGeneric}}
|
|
13
|
+
|
|
14
|
+
{{/oneOf}}
|
|
15
|
+
{{/isEnum}}
|
|
16
|
+
{{/model}}
|
|
17
|
+
{{/models}}
|