@kosdev-code/kos-codegen-core 3.0.20 → 3.0.22
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/index.d.ts +2 -2
- package/index.d.ts.map +1 -1
- package/index.js +1284 -379
- package/index.js.map +1 -1
- package/index.mjs +1285 -380
- package/index.mjs.map +1 -1
- package/lib/generators/add-container-support/generate-add-container-support.d.ts +14 -0
- package/lib/generators/add-container-support/generate-add-container-support.d.ts.map +1 -1
- package/lib/generators/add-parent-aware/generate-add-parent-aware.d.ts +15 -0
- package/lib/generators/add-parent-aware/generate-add-parent-aware.d.ts.map +1 -0
- package/lib/generators/add-parent-aware/index.d.ts +2 -0
- package/lib/generators/add-parent-aware/index.d.ts.map +1 -0
- package/lib/generators/augment/find-model-declaration.d.ts +4 -0
- package/lib/generators/augment/find-model-declaration.d.ts.map +1 -0
- package/lib/generators/augment/model-mocks.d.ts +47 -0
- package/lib/generators/augment/model-mocks.d.ts.map +1 -0
- package/lib/generators/augment/resolve-child-model.d.ts +16 -0
- package/lib/generators/augment/resolve-child-model.d.ts.map +1 -0
- package/lib/generators/augment/resolve-model-file.d.ts.map +1 -1
- package/lib/generators/augment/ts-toolkit.d.ts +32 -1
- package/lib/generators/augment/ts-toolkit.d.ts.map +1 -1
- package/lib/generators/describe/describe-model.d.ts.map +1 -1
- package/lib/generators/generate-container-model.d.ts +7 -0
- package/lib/generators/generate-container-model.d.ts.map +1 -1
- package/lib/generators/generate-model-project.d.ts +36 -0
- package/lib/generators/generate-model-project.d.ts.map +1 -0
- package/lib/generators/generate-view-model.d.ts +27 -0
- package/lib/generators/generate-view-model.d.ts.map +1 -0
- package/lib/generators/index.d.ts +21 -16
- package/lib/generators/index.d.ts.map +1 -1
- package/lib/generators/member-mutators/add-child.d.ts +10 -2
- package/lib/generators/member-mutators/add-child.d.ts.map +1 -1
- package/lib/generators/member-mutators/add-service-request.d.ts +71 -0
- package/lib/generators/member-mutators/add-service-request.d.ts.map +1 -1
- package/lib/generators/member-mutators/index.d.ts +1 -1
- package/lib/generators/member-mutators/index.d.ts.map +1 -1
- package/lib/generators/normalize-options.d.ts +2 -0
- package/lib/generators/normalize-options.d.ts.map +1 -1
- package/lib/generators/registration/upsert-chain-entry.d.ts +13 -0
- package/lib/generators/registration/upsert-chain-entry.d.ts.map +1 -0
- package/lib/generators/service-catalog.d.ts +12 -0
- package/lib/generators/service-catalog.d.ts.map +1 -1
- package/package.json +2 -2
- package/templates/kos-container-model/model/types/index.d.ts.template +2 -2
- package/templates/kos-model/model/__nameDashCase__-model.ts.template +7 -4
- package/templates/kos-model-project/project/.eslintrc.json.template +33 -0
- package/templates/kos-model-project/project/.kos.json.template +14 -0
- package/templates/kos-model-project/project/README.md.template +7 -0
- package/templates/kos-model-project/project/package.json.template +9 -0
- package/templates/kos-model-project/project/project.json.template +35 -0
- package/templates/kos-model-project/project/src/index.ts.template +1 -0
- package/templates/kos-model-project/project/src/lib/__projectName__.ts.template +3 -0
- package/templates/kos-model-project/project/tsconfig.json.template +20 -0
- package/templates/kos-model-project/project/tsconfig.lib.json.template +10 -0
- package/templates/kos-model-project/project/vite.config.ts.template +47 -0
- package/templates/kos-view-model/__nameDashCase__-view-model.ts.template +30 -0
- package/templates/kos-view-model/index.ts.template +1 -0
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export interface UpsertChainEntryResult {
|
|
2
|
+
changed: boolean;
|
|
3
|
+
/** The full file text after the edit (only when `changed`). */
|
|
4
|
+
content?: string;
|
|
5
|
+
/** Whether an import for the bean had to be added (only when `changed`). */
|
|
6
|
+
importAdded?: boolean;
|
|
7
|
+
note?: string;
|
|
8
|
+
error?: string;
|
|
9
|
+
}
|
|
10
|
+
/** Number of `.model(...)` entries in a chain file. */
|
|
11
|
+
export declare function countChainEntries(content: string): number;
|
|
12
|
+
export declare function upsertChainEntry(content: string, bean: string, importSpec: string): UpsertChainEntryResult;
|
|
13
|
+
//# sourceMappingURL=upsert-chain-entry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"upsert-chain-entry.d.ts","sourceRoot":"","sources":["../../../../../../packages/kos-codegen-core/src/lib/generators/registration/upsert-chain-entry.ts"],"names":[],"mappings":"AAcA,MAAM,WAAW,sBAAsB;IACrC,OAAO,EAAE,OAAO,CAAC;IACjB,+DAA+D;IAC/D,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,4EAA4E;IAC5E,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAwCD,uDAAuD;AACvD,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAEzD;AAED,wBAAgB,gBAAgB,CAC9B,OAAO,EAAE,MAAM,EACf,IAAI,EAAE,MAAM,EACZ,UAAU,EAAE,MAAM,GACjB,sBAAsB,CA4CxB"}
|
|
@@ -35,5 +35,17 @@ export interface ServiceCatalogQuery {
|
|
|
35
35
|
* should tell the user to run `api:generate`, not treat it as "no endpoints".
|
|
36
36
|
*/
|
|
37
37
|
export declare function listServiceCatalog(codegenFs: CodegenFileSystem, query: ServiceCatalogQuery, projects?: Map<string, ProjectConfiguration>): ServiceCatalogEntry[];
|
|
38
|
+
/**
|
|
39
|
+
* The operations a generated service module types, for callers that hold the
|
|
40
|
+
* module rather than a project name — path validation, above all.
|
|
41
|
+
*
|
|
42
|
+
* `paths` normally lives in the `openapi.d.ts` beside the module, but the module
|
|
43
|
+
* may declare it inline instead. Returns null when NEITHER does: that is "these
|
|
44
|
+
* types cannot answer the question", which a caller must not read as "the
|
|
45
|
+
* endpoint does not exist".
|
|
46
|
+
*
|
|
47
|
+
* @param serviceModuleFile Root-relative path of the module, with or without `.ts`.
|
|
48
|
+
*/
|
|
49
|
+
export declare function readServiceModuleOperations(codegenFs: CodegenFileSystem, serviceModuleFile: string): ServiceOperation[] | null;
|
|
38
50
|
export {};
|
|
39
51
|
//# sourceMappingURL=service-catalog.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"service-catalog.d.ts","sourceRoot":"","sources":["../../../../../packages/kos-codegen-core/src/lib/generators/service-catalog.ts"],"names":[],"mappings":"AAoBA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAC/D,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAIjE,8EAA8E;AAC9E,QAAA,MAAM,eAAe,oDAAqD,CAAC;AAC3E,MAAM,MAAM,aAAa,GAAG,CAAC,OAAO,eAAe,CAAC,CAAC,MAAM,CAAC,CAAC;AAE7D,MAAM,WAAW,gBAAgB;IAC/B,4CAA4C;IAC5C,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,aAAa,CAAC;IACtB,6CAA6C;IAC7C,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,mEAAmE;IACnE,UAAU,EAAE,MAAM,EAAE,CAAC;CACtB;AAED,MAAM,WAAW,mBAAmB;IAClC,wDAAwD;IACxD,GAAG,EAAE,MAAM,CAAC;IACZ,gDAAgD;IAChD,OAAO,EAAE,MAAM,CAAC;IAChB,2EAA2E;IAC3E,iBAAiB,EAAE,MAAM,CAAC;IAC1B,UAAU,EAAE,gBAAgB,EAAE,CAAC;CAChC;AAID,MAAM,WAAW,mBAAmB;IAClC,6CAA6C;IAC7C,YAAY,EAAE,MAAM,CAAC;IACrB,kDAAkD;IAClD,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,mDAAmD;IACnD,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED;;;;GAIG;AACH,wBAAgB,kBAAkB,CAChC,SAAS,EAAE,iBAAiB,EAC5B,KAAK,EAAE,mBAAmB,EAC1B,QAAQ,CAAC,EAAE,GAAG,CAAC,MAAM,EAAE,oBAAoB,CAAC,GAC3C,mBAAmB,EAAE,CAiCvB"}
|
|
1
|
+
{"version":3,"file":"service-catalog.d.ts","sourceRoot":"","sources":["../../../../../packages/kos-codegen-core/src/lib/generators/service-catalog.ts"],"names":[],"mappings":"AAoBA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAC/D,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAIjE,8EAA8E;AAC9E,QAAA,MAAM,eAAe,oDAAqD,CAAC;AAC3E,MAAM,MAAM,aAAa,GAAG,CAAC,OAAO,eAAe,CAAC,CAAC,MAAM,CAAC,CAAC;AAE7D,MAAM,WAAW,gBAAgB;IAC/B,4CAA4C;IAC5C,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,aAAa,CAAC;IACtB,6CAA6C;IAC7C,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,mEAAmE;IACnE,UAAU,EAAE,MAAM,EAAE,CAAC;CACtB;AAED,MAAM,WAAW,mBAAmB;IAClC,wDAAwD;IACxD,GAAG,EAAE,MAAM,CAAC;IACZ,gDAAgD;IAChD,OAAO,EAAE,MAAM,CAAC;IAChB,2EAA2E;IAC3E,iBAAiB,EAAE,MAAM,CAAC;IAC1B,UAAU,EAAE,gBAAgB,EAAE,CAAC;CAChC;AAID,MAAM,WAAW,mBAAmB;IAClC,6CAA6C;IAC7C,YAAY,EAAE,MAAM,CAAC;IACrB,kDAAkD;IAClD,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,mDAAmD;IACnD,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED;;;;GAIG;AACH,wBAAgB,kBAAkB,CAChC,SAAS,EAAE,iBAAiB,EAC5B,KAAK,EAAE,mBAAmB,EAC1B,QAAQ,CAAC,EAAE,GAAG,CAAC,MAAM,EAAE,oBAAoB,CAAC,GAC3C,mBAAmB,EAAE,CAiCvB;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,2BAA2B,CACzC,SAAS,EAAE,iBAAiB,EAC5B,iBAAiB,EAAE,MAAM,GACxB,gBAAgB,EAAE,GAAG,IAAI,CAa3B"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kosdev-code/kos-codegen-core",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.22",
|
|
4
4
|
"type": "commonjs",
|
|
5
5
|
"main": "./index.js",
|
|
6
6
|
"module": "./index.mjs",
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
},
|
|
26
26
|
"kos": {
|
|
27
27
|
"build": {
|
|
28
|
-
"gitHash": "
|
|
28
|
+
"gitHash": "b64d9a0431aa83daea7eba6b84d7b39db7d47ea9"
|
|
29
29
|
}
|
|
30
30
|
}
|
|
31
31
|
}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
|
|
2
|
-
<% if (parentAware) { %>import type {KosParentAware} from "@kosdev-code/kos-ui-sdk";<% } %>
|
|
2
|
+
<% if (locals.parentAware) { %>import type {KosParentAware} from "@kosdev-code/kos-ui-sdk";<% } %>
|
|
3
3
|
|
|
4
4
|
|
|
5
5
|
// --------------- <%= modelNameProperCase %> ---------------
|
|
6
6
|
|
|
7
|
-
export interface <%= modelNameProperCase %>Options <% if (parentAware) { %>extends KosParentAware<% } %> {
|
|
7
|
+
export interface <%= modelNameProperCase %>Options <% if (locals.parentAware) { %>extends KosParentAware<% } %> {
|
|
8
8
|
|
|
9
9
|
}
|
|
10
10
|
|
|
@@ -9,7 +9,7 @@ import type {
|
|
|
9
9
|
IKosDataModel,
|
|
10
10
|
KosContextLogger
|
|
11
11
|
} from "../../../core/core/kosModel";
|
|
12
|
-
import type {
|
|
12
|
+
import type { KosRegistrationFor } from "../../../core/core/registration/model-registration";
|
|
13
13
|
import type { IKosIdentifiable } from "../../../core/core/types";
|
|
14
14
|
import type { PublicModelInterface } from "../../../core/types";
|
|
15
15
|
<% if (hasFutureSupport) { %>import type {
|
|
@@ -17,7 +17,7 @@ import type { PublicModelInterface } from "../../../core/types";
|
|
|
17
17
|
IFutureModel
|
|
18
18
|
} from "../../../models/types/future-interfaces";<% } %>
|
|
19
19
|
<% if (isDecoratorCompanion) { %>import { KosCompanionDecorator } from "../../../core/core/decorators";<% } %>
|
|
20
|
-
<% } else { %>import type { IKosDataModel, IKosIdentifiable, PublicModelInterface,
|
|
20
|
+
<% } else { %>import type { IKosDataModel, IKosIdentifiable, PublicModelInterface, KosRegistrationFor<% if (hasFutureSupport) { %>, ExternalFutureInterface, IFutureModel<% } %><% if (isDecoratorCompanion) { %>, KosCompanionDecorator<% } %> } from "@kosdev-code/kos-ui-sdk";
|
|
21
21
|
import { kosModel<% if (parentAware) { %>, kosParentAware<% } %><% if (hasFutureSupport) { %>, kosFuture, kosFutureAware, Kos<% if (isCompleteFuture) { %>FutureAwareFull<% } else { %>FutureAwareMinimal<% } %><% } %><% if (isDecoratorCompanion) { %>, kosCompanion<% } %>, kosLoggerAware, KosLoggerAware } from "@kosdev-code/kos-ui-sdk";
|
|
22
22
|
<% } %>
|
|
23
23
|
import type { <%= nameProperCase %>Options} from "./types";
|
|
@@ -34,14 +34,17 @@ export type <%= nameProperCase %>Model = PublicModelInterface<<%= nameProperCase
|
|
|
34
34
|
// eslint-disable-next-line @typescript-eslint/no-empty-interface
|
|
35
35
|
export interface <%= nameProperCase %>ModelImpl extends KosLoggerAware<% if (hasFutureSupport) { %>, Kos<% if (isCompleteFuture) { %>FutureAwareFull<% } else { %>FutureAwareMinimal<% } %><<%= nameProperCase %>OperationProgress><% } %><% if (isDecoratorCompanion) { %>, KosCompanionDecorator<<%= companionModelProperCase %>Model><% } %> {}
|
|
36
36
|
|
|
37
|
-
|
|
37
|
+
// Flipping `singleton` here moves the Registration type with it.
|
|
38
|
+
export const MODEL_CONFIG = { modelTypeId: MODEL_TYPE, singleton: <%= singleton ? "true" : "false" %><% if (autoRegister) { %>, autoRegister: true<% } %> } as const;
|
|
39
|
+
|
|
40
|
+
@kosModel(MODEL_CONFIG)
|
|
38
41
|
<% if (parentAware && !isDecoratorCompanion) { %>@kosParentAware()<% } %>
|
|
39
42
|
<% if (hasFutureSupport) { %>@kosFutureAware(<% if (!isCompleteFuture) { %>{ mode: 'minimal' }<% } %>)<% } %>
|
|
40
43
|
<% if (isDecoratorCompanion) { %>@kosCompanion()<% } %>
|
|
41
44
|
@kosLoggerAware()
|
|
42
45
|
export class <%= nameProperCase %>ModelImpl implements IKosDataModel, IKosIdentifiable {
|
|
43
46
|
// Registration property for type safety - actual value injected by @kosModel decorator
|
|
44
|
-
static Registration:
|
|
47
|
+
static Registration: KosRegistrationFor<typeof MODEL_CONFIG, <%= nameProperCase %>Model, <%= nameProperCase %>Options>;
|
|
45
48
|
|
|
46
49
|
id: string;
|
|
47
50
|
// logger property is automatically provided by @kosLoggerAware decorator
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
{
|
|
2
|
+
"extends": ["<%= offsetFromRoot %>.eslintrc.json"],
|
|
3
|
+
"ignorePatterns": ["!**/*"],
|
|
4
|
+
"overrides": [
|
|
5
|
+
{
|
|
6
|
+
"files": ["*.ts", "*.tsx", "*.js", "*.jsx"],
|
|
7
|
+
"rules": {}
|
|
8
|
+
},
|
|
9
|
+
{
|
|
10
|
+
"files": ["*.ts", "*.tsx"],
|
|
11
|
+
"rules": {}
|
|
12
|
+
},
|
|
13
|
+
{
|
|
14
|
+
"files": ["*.js", "*.jsx"],
|
|
15
|
+
"rules": {}
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
"files": ["*.json"],
|
|
19
|
+
"parser": "jsonc-eslint-parser",
|
|
20
|
+
"rules": {
|
|
21
|
+
"@nx/dependency-checks": [
|
|
22
|
+
"error",
|
|
23
|
+
{
|
|
24
|
+
"ignoredFiles": [
|
|
25
|
+
"{projectRoot}/eslint.config.{js,cjs,mjs,ts,cts,mts}",
|
|
26
|
+
"{projectRoot}/vite.config.{js,ts,mjs,mts}"
|
|
27
|
+
]
|
|
28
|
+
}
|
|
29
|
+
]
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
]
|
|
33
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "<%= projectName %>",
|
|
3
|
+
"$schema": "<%= offsetFromRoot %>node_modules/nx/schemas/project-schema.json",
|
|
4
|
+
"sourceRoot": "<%= projectRoot %>/src",
|
|
5
|
+
"projectType": "library",
|
|
6
|
+
"tags": [],
|
|
7
|
+
"targets": {
|
|
8
|
+
"build": {
|
|
9
|
+
"executor": "@nx/vite:build",
|
|
10
|
+
"outputs": ["{options.outputPath}"],
|
|
11
|
+
"defaultConfiguration": "production",
|
|
12
|
+
"options": {
|
|
13
|
+
"outputPath": "dist/<%= projectRoot %>"
|
|
14
|
+
},
|
|
15
|
+
"configurations": {
|
|
16
|
+
"development": {
|
|
17
|
+
"mode": "development"
|
|
18
|
+
},
|
|
19
|
+
"production": {
|
|
20
|
+
"mode": "production"
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
},
|
|
24
|
+
"lint": {
|
|
25
|
+
"executor": "@nx/eslint:lint"
|
|
26
|
+
},
|
|
27
|
+
"api": {
|
|
28
|
+
"command": "kosui api:generate --project=<%= projectName %>",
|
|
29
|
+
"options": {
|
|
30
|
+
"host": "http://127.0.0.1:8081",
|
|
31
|
+
"defaultVersion": "snapshot"
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './lib/<%= projectName %>';
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
{
|
|
2
|
+
"extends": "<%= offsetFromRoot %>tsconfig.base.json",
|
|
3
|
+
"compilerOptions": {
|
|
4
|
+
"module": "esnext",
|
|
5
|
+
"forceConsistentCasingInFileNames": true,
|
|
6
|
+
"strict": true,
|
|
7
|
+
"importHelpers": true,
|
|
8
|
+
"noImplicitOverride": true,
|
|
9
|
+
"noImplicitReturns": true,
|
|
10
|
+
"noFallthroughCasesInSwitch": true,
|
|
11
|
+
"noPropertyAccessFromIndexSignature": true
|
|
12
|
+
},
|
|
13
|
+
"files": [],
|
|
14
|
+
"include": [],
|
|
15
|
+
"references": [
|
|
16
|
+
{
|
|
17
|
+
"path": "./tsconfig.lib.json"
|
|
18
|
+
}
|
|
19
|
+
]
|
|
20
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/// <reference types='vitest' />
|
|
2
|
+
import { defineConfig } from 'vite';
|
|
3
|
+
import dts from 'vite-plugin-dts';
|
|
4
|
+
import * as path from 'path';
|
|
5
|
+
import { nxViteTsPaths } from '@nx/vite/plugins/nx-tsconfig-paths.plugin';
|
|
6
|
+
import { nxCopyAssetsPlugin } from '@nx/vite/plugins/nx-copy-assets.plugin';
|
|
7
|
+
|
|
8
|
+
export default defineConfig(() => ({
|
|
9
|
+
root: __dirname,
|
|
10
|
+
cacheDir: '<%= offsetFromRoot %>node_modules/.vite/<%= projectRoot %>',
|
|
11
|
+
plugins: [
|
|
12
|
+
nxViteTsPaths(),
|
|
13
|
+
nxCopyAssetsPlugin(['*.md']),
|
|
14
|
+
dts({
|
|
15
|
+
entryRoot: 'src',
|
|
16
|
+
tsconfigPath: path.join(__dirname, 'tsconfig.lib.json'),
|
|
17
|
+
pathsToAliases: false,
|
|
18
|
+
}),
|
|
19
|
+
],
|
|
20
|
+
// Uncomment this if you are using workers.
|
|
21
|
+
// worker: {
|
|
22
|
+
// plugins: [ nxViteTsPaths() ],
|
|
23
|
+
// },
|
|
24
|
+
// Configuration for building your library.
|
|
25
|
+
// See: https://vitejs.dev/guide/build.html#library-mode
|
|
26
|
+
build: {
|
|
27
|
+
outDir: '<%= offsetFromRoot %>dist/<%= projectRoot %>',
|
|
28
|
+
emptyOutDir: true,
|
|
29
|
+
reportCompressedSize: true,
|
|
30
|
+
commonjsOptions: {
|
|
31
|
+
transformMixedEsModules: true,
|
|
32
|
+
},
|
|
33
|
+
lib: {
|
|
34
|
+
// Could also be a dictionary or array of multiple entry points.
|
|
35
|
+
entry: 'src/index.ts',
|
|
36
|
+
name: '<%= projectName %>',
|
|
37
|
+
fileName: 'index',
|
|
38
|
+
// Change this to the formats you want to support.
|
|
39
|
+
// Don't forget to update your package.json as well.
|
|
40
|
+
formats: ['es' as const],
|
|
41
|
+
},
|
|
42
|
+
rollupOptions: {
|
|
43
|
+
// External packages that should not be bundled into your library.
|
|
44
|
+
external: [],
|
|
45
|
+
},
|
|
46
|
+
},
|
|
47
|
+
}));
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* UI-only state for the <%= nameProperCase %> view, held <% if (constructorParams.length) { %>beside the KOS data models it
|
|
3
|
+
* reads rather than inside them<% } else { %>outside the KOS data models<% } %>. A ViewModel is not registered and is
|
|
4
|
+
* not part of the model graph; create one per component with
|
|
5
|
+
* `useViewModel(() => new <%= nameProperCase %>ViewModel(<%= constructorArgs %>))`.
|
|
6
|
+
*/
|
|
7
|
+
<% if (internal) { %>import {
|
|
8
|
+
kosViewModel,
|
|
9
|
+
kosLoggerAware,
|
|
10
|
+
type KosViewModelLoggerAware,
|
|
11
|
+
} from "../../../core/core/decorators";
|
|
12
|
+
<% } else { %>import {
|
|
13
|
+
kosViewModel,
|
|
14
|
+
kosLoggerAware,
|
|
15
|
+
type KosViewModelLoggerAware,
|
|
16
|
+
} from "@kosdev-code/kos-ui-sdk";
|
|
17
|
+
<% } %><% modelImports.forEach(function (imp) { %>import type { <%= imp.types.join(", ") %> } from "<%= imp.module %>";
|
|
18
|
+
<% }); %>
|
|
19
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-declaration-merging
|
|
20
|
+
export interface <%= nameProperCase %>ViewModel extends KosViewModelLoggerAware {}
|
|
21
|
+
|
|
22
|
+
@kosViewModel({ typeId: "<%= typeId %>"<% if (devToolsEnabled) { %>, devToolsEnabled: true<% } %> })
|
|
23
|
+
@kosLoggerAware()
|
|
24
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-declaration-merging
|
|
25
|
+
export class <%= nameProperCase %>ViewModel {
|
|
26
|
+
<% if (constructorParams.length === 0) { %> constructor() {}
|
|
27
|
+
<% } else { %> constructor(
|
|
28
|
+
<% constructorParams.forEach(function (param, index) { %> private readonly <%= param.name %>: <%= param.type %><% if (index < constructorParams.length - 1) { %>,<% } %>
|
|
29
|
+
<% }); %> ) {}
|
|
30
|
+
<% } %>}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { <%= nameProperCase %>ViewModel } from "./<%= nameDashCase %>-view-model";
|