@kosdev-code/kos-nx-plugin 2.0.40 → 2.1.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/generators.json +5 -0
- package/package.json +2 -2
- package/src/generators/kos-add-future-to-model/generator.d.ts.map +1 -1
- package/src/generators/kos-add-future-to-model/generator.js.map +1 -1
- package/src/generators/kos-add-future-to-model/lib/model-transformer.d.ts +8 -3
- package/src/generators/kos-add-future-to-model/lib/model-transformer.d.ts.map +1 -1
- package/src/generators/kos-add-future-to-model/lib/model-transformer.js +191 -155
- package/src/generators/kos-add-future-to-model/lib/model-transformer.js.map +1 -1
- package/src/generators/kos-container-model/files/model/__nameDashCase__-model.ts.template +25 -40
- package/src/generators/kos-container-model/files/model/index.ts.template +20 -5
- package/src/generators/kos-content-project/files/assets/.gitkeep +2 -0
- package/src/generators/kos-content-project/files/vite.config.ts.template +48 -0
- package/src/generators/kos-content-project/generator.d.ts +5 -0
- package/src/generators/kos-content-project/generator.d.ts.map +1 -0
- package/src/generators/kos-content-project/generator.js +55 -0
- package/src/generators/kos-content-project/generator.js.map +1 -0
- package/src/generators/kos-content-project/schema.d.ts +3 -0
- package/src/generators/kos-content-project/schema.json +18 -0
- package/src/generators/kos-model/files/model/__nameDashCase__-model.ts.template +35 -43
- package/src/generators/kos-model/files/model/index.ts__template__ +11 -3
- package/src/generators/kos-model/schema.d.ts +1 -0
- package/src/generators/kos-model/schema.json +5 -0
- package/src/generators/kos-plugin-project/generator.js +6 -6
- package/src/generators/kos-plugin-project/generator.js.map +1 -1
- package/src/generators/preset/generator.d.ts.map +1 -1
- package/src/generators/preset/generator.js +7 -5
- package/src/generators/preset/generator.js.map +1 -1
- package/src/generators/preset/tools/tools/scripts/update.mjs.template +29 -8
- package/src/generators/kos-container-model/files/model/__nameDashCase__-registration.ts.template +0 -113
- package/src/generators/kos-model/files/model/__nameDashCase__-registration.ts.template +0 -144
package/src/generators/kos-container-model/files/model/__nameDashCase__-registration.ts.template
DELETED
|
@@ -1,113 +0,0 @@
|
|
|
1
|
-
import { <% if (singleton) { %>Singleton<% } %>KosModelRegistrationFactory } from "@kosdev-code/kos-ui-sdk";
|
|
2
|
-
import type { <%= nameProperCase %>Options } from "./types";
|
|
3
|
-
import { <%= modelNameProperCase %> } from "./<%= modelNameDashCase %>-registration";
|
|
4
|
-
import { <%= nameProperCase %>ModelImpl, MODEL_TYPE } from "./<%= nameDashCase %>-model";
|
|
5
|
-
import type { <%= nameProperCase %>Model } from "./<%= nameDashCase %>-model";
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* # <%= nameProperCase %>
|
|
10
|
-
*
|
|
11
|
-
* The registration bean includes convenience methods for creating and working with <%= nameProperCase %>Model instances.
|
|
12
|
-
*
|
|
13
|
-
* ## type
|
|
14
|
-
* The type property is a string that identifies the model type.
|
|
15
|
-
* The type is used to identify the model type in the model registry and to narrow down the model type in type predicates. It's most frequently
|
|
16
|
-
* used when declaring dependencies on models.
|
|
17
|
-
*
|
|
18
|
-
* @example
|
|
19
|
-
* ```typescript
|
|
20
|
-
*
|
|
21
|
-
* @kosDependency({modelType: <%= nameProperCase %>.type, id: "<%= nameCamelCase %>Id"})
|
|
22
|
-
* private <%= nameCamelCase %>Model: <%= nameProperCase %>Model;
|
|
23
|
-
* ```
|
|
24
|
-
*
|
|
25
|
-
*
|
|
26
|
-
* ## factory
|
|
27
|
-
*
|
|
28
|
-
* The factory method creates a factory function that can be used to create new <%= nameProperCase %>Model instances.
|
|
29
|
-
*
|
|
30
|
-
<% if (singleton) { %>
|
|
31
|
-
* As this is a singleton model, the factory function accepts the model options as its argument.
|
|
32
|
-
*
|
|
33
|
-
* If a model with the same model type already exists, the factory function will return the existing model. The options will be ignored
|
|
34
|
-
* in this case and the existing model will be returned in its current state.
|
|
35
|
-
*
|
|
36
|
-
* @example
|
|
37
|
-
* ```typescript
|
|
38
|
-
* const model = <%= nameProperCase %>.factory({
|
|
39
|
-
* // Add option data
|
|
40
|
-
* });
|
|
41
|
-
* ```
|
|
42
|
-
<% } else { %>
|
|
43
|
-
* The factory function is a curried function that takes the model id as the first argument and the options as the second argument.
|
|
44
|
-
*
|
|
45
|
-
* If a model with the specified id already exists, the factory function will return the existing model. The options will be ignored
|
|
46
|
-
* in this case and the existing model will be returned in its current state.
|
|
47
|
-
*
|
|
48
|
-
* @example
|
|
49
|
-
* ```typescript
|
|
50
|
-
* const model = <%= nameProperCase %>.factory("<%= nameCamelCase %>Id")({
|
|
51
|
-
* // Add option data
|
|
52
|
-
* });
|
|
53
|
-
* ```
|
|
54
|
-
<% } %>
|
|
55
|
-
|
|
56
|
-
*
|
|
57
|
-
* ## predicate
|
|
58
|
-
*
|
|
59
|
-
* [Typescript type predicate](https://www.typescriptlang.org/docs/handbook/2/narrowing.html#using-type-predicates) function that will identify and narrow down a model to a <%= nameProperCase %>Model.
|
|
60
|
-
*
|
|
61
|
-
* @example
|
|
62
|
-
* ```typescript
|
|
63
|
-
*
|
|
64
|
-
* const model: IKosDataModel = ...; // some model
|
|
65
|
-
*
|
|
66
|
-
* if (<%= nameProperCase %>.predicate(model)) {
|
|
67
|
-
* // if the function evaluates to true, the model is narrowed down to <%= nameProperCase %>Model
|
|
68
|
-
* // and the compiler will know that the model has the <%= nameProperCase %>Model interface
|
|
69
|
-
* model.updateAvailability(false);
|
|
70
|
-
* }
|
|
71
|
-
* ```
|
|
72
|
-
*
|
|
73
|
-
* ## registration
|
|
74
|
-
*
|
|
75
|
-
* The registration property is an object that can be used to simplify registration of the model with the model registry. The registration object
|
|
76
|
-
* can be spread into the model registration and provides all of the required information to register the model implementation class against the model type.
|
|
77
|
-
*
|
|
78
|
-
*
|
|
79
|
-
* @example
|
|
80
|
-
*
|
|
81
|
-
* In an application registration file you can declare the model registration as follows:
|
|
82
|
-
*
|
|
83
|
-
* **registration.ts**
|
|
84
|
-
* ```typescript
|
|
85
|
-
* import { <%= nameProperCase %> } from "<%= importPath %>";
|
|
86
|
-
* ...
|
|
87
|
-
* import { ExtensionManager, IKosRegistry } from "@kosdev-code/kos-ui-sdk";
|
|
88
|
-
* export const kosModels: IKosRegistry["models"] = {
|
|
89
|
-
* ...<%= nameProperCase %>.registration,
|
|
90
|
-
* };
|
|
91
|
-
* ```
|
|
92
|
-
*
|
|
93
|
-
* ## registration.singleton
|
|
94
|
-
<% if (singleton) { %>
|
|
95
|
-
* The <%= nameCamelCase %> model is a singleton model. This means that each time the factory function is called , the same instance will be returned.
|
|
96
|
-
* If the model does not yet exist, it will be created passing in the provided options to initialize it.
|
|
97
|
-
*
|
|
98
|
-
* Singleton models don't require an ID as they will use the model type as their ID to guarantee uniqueness throughout the system.
|
|
99
|
-
<% } else { %>
|
|
100
|
-
* The <%= nameCamelCase %> model is NOT a singleton model. This means that each time the factory function is called with a unique ID, a new model instance will be created.
|
|
101
|
-
* If the factory function is called with an ID that already exists, the existing model will be returned.
|
|
102
|
-
<% } %>
|
|
103
|
-
* */
|
|
104
|
-
export const <%= nameProperCase %> = new <% if (singleton) { %>Singleton<% } %>KosModelRegistrationFactory<
|
|
105
|
-
<%= nameProperCase %>Model,
|
|
106
|
-
<%= nameProperCase %>Options
|
|
107
|
-
>({
|
|
108
|
-
class: <%= nameProperCase %>ModelImpl,
|
|
109
|
-
type: MODEL_TYPE,
|
|
110
|
-
});
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
<%= nameProperCase %>.addRelatedModel(<%= modelNameProperCase %>);
|
|
@@ -1,144 +0,0 @@
|
|
|
1
|
-
<% const hasFutureSupport = futureAware && futureAware !== 'none'; %>
|
|
2
|
-
<% const hasCompanionSupport = companion; %>
|
|
3
|
-
<% const needsAnyCast = hasFutureSupport || hasCompanionSupport; %>
|
|
4
|
-
import { <% if (singleton) { %>Singleton<% } %>KosModelRegistrationFactory } from "<% if (internal) {%>../../../core/core/registration<% } else { %>@kosdev-code/kos-ui-sdk<% } %>";
|
|
5
|
-
import type { <%= nameProperCase %>Options } from "./types";
|
|
6
|
-
import { <%= nameProperCase %>ModelImpl, MODEL_TYPE, <%= nameProperCase %>Model } from "./<%= nameDashCase %>-model";
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* # <%= nameProperCase %>
|
|
10
|
-
*
|
|
11
|
-
* The registration bean includes convenience methods for creating and working with <%= nameProperCase %>Model instances.
|
|
12
|
-
<% if (hasFutureSupport) { %>
|
|
13
|
-
*
|
|
14
|
-
* ## Future Support
|
|
15
|
-
* This model includes <%= futureAware %> Future support for tracking long-running operations with:
|
|
16
|
-
* - Progress tracking (0-1) with reactive updates
|
|
17
|
-
* - Status messages during operation
|
|
18
|
-
* - Cancellation support with bi-directional AbortController integration
|
|
19
|
-
* - Reactive integration for UI updates
|
|
20
|
-
<% if (futureAware === 'complete') { %>
|
|
21
|
-
* - Internal access to Future state for custom logic and computed properties
|
|
22
|
-
<% } %>
|
|
23
|
-
<% } %>
|
|
24
|
-
*
|
|
25
|
-
* ## type
|
|
26
|
-
* The type property is a string that identifies the model type.
|
|
27
|
-
* The type is used to identify the model type in the model registry and to narrow down the model type in type predicates. It's most frequently
|
|
28
|
-
* used when declaring dependencies on models.
|
|
29
|
-
*
|
|
30
|
-
* @example
|
|
31
|
-
* ```typescript
|
|
32
|
-
*
|
|
33
|
-
* @kosDependency({modelType: <%= nameProperCase %>.type, id: "<%= nameCamelCase %>Id"})
|
|
34
|
-
* private <%= nameCamelCase %>Model: <%= nameProperCase %>Model;
|
|
35
|
-
* ```
|
|
36
|
-
*
|
|
37
|
-
*
|
|
38
|
-
* ## factory
|
|
39
|
-
*
|
|
40
|
-
* The factory method creates a factory function that can be used to create new <%= nameProperCase %>Model instances.
|
|
41
|
-
*
|
|
42
|
-
<% if (singleton) { %>
|
|
43
|
-
* As this is a singleton model, the factory function accepts the model options as its argument.
|
|
44
|
-
*
|
|
45
|
-
* If a model with the same model type already exists, the factory function will return the existing model. The options will be ignored
|
|
46
|
-
* in this case and the existing model will be returned in its current state.
|
|
47
|
-
*
|
|
48
|
-
* @example
|
|
49
|
-
* ```typescript
|
|
50
|
-
* const model = <%= nameProperCase %>.factory({
|
|
51
|
-
* // Add option data
|
|
52
|
-
* });
|
|
53
|
-
<% if (hasFutureSupport) { %>
|
|
54
|
-
*
|
|
55
|
-
* // Example: Accessing Future state (when a Future is active)
|
|
56
|
-
* const isRunning = model.futureIsRunning;
|
|
57
|
-
* const progress = model.futureProgress; // 0-1
|
|
58
|
-
* const status = model.futureStatus; // Current status message
|
|
59
|
-
<% } %>
|
|
60
|
-
* ```
|
|
61
|
-
<% } else { %>
|
|
62
|
-
* The factory function is a curried function that takes the model id as the first argument and the options as the second argument.
|
|
63
|
-
*
|
|
64
|
-
* If a model with the specified id already exists, the factory function will return the existing model. The options will be ignored
|
|
65
|
-
* in this case and the existing model will be returned in its current state.
|
|
66
|
-
*
|
|
67
|
-
* @example
|
|
68
|
-
* ```typescript
|
|
69
|
-
* const model = <%= nameProperCase %>.factory("<%= nameCamelCase %>Id")({
|
|
70
|
-
* // Add option data
|
|
71
|
-
* });
|
|
72
|
-
<% if (hasFutureSupport) { %>
|
|
73
|
-
*
|
|
74
|
-
* // Example: Accessing Future state (when a Future is active)
|
|
75
|
-
* const isRunning = model.futureIsRunning;
|
|
76
|
-
* const progress = model.futureProgress; // 0-1
|
|
77
|
-
* const status = model.futureStatus; // Current status message
|
|
78
|
-
<% } %>
|
|
79
|
-
* ```
|
|
80
|
-
<% } %>
|
|
81
|
-
|
|
82
|
-
*
|
|
83
|
-
* ## predicate
|
|
84
|
-
*
|
|
85
|
-
* [Typescript type predicate](https://www.typescriptlang.org/docs/handbook/2/narrowing.html#using-type-predicates) function that will identify and narrow down a model to a <%= nameProperCase %>Model.
|
|
86
|
-
*
|
|
87
|
-
* @example
|
|
88
|
-
* ```typescript
|
|
89
|
-
*
|
|
90
|
-
* const model: IKosDataModel = ...; // some model
|
|
91
|
-
*
|
|
92
|
-
* if (<%= nameProperCase %>.predicate(model)) {
|
|
93
|
-
* // if the function evaluates to true, the model is narrowed down to <%= nameProperCase %>Model
|
|
94
|
-
* // and the compiler will know that the model has the <%= nameProperCase %>Model interface
|
|
95
|
-
* model.updateAvailability(false);
|
|
96
|
-
<% if (hasFutureSupport) { %>
|
|
97
|
-
*
|
|
98
|
-
* // Future capabilities are also available
|
|
99
|
-
* const isRunning = model.futureIsRunning;
|
|
100
|
-
* const progress = model.futureProgress;
|
|
101
|
-
<% } %>
|
|
102
|
-
* }
|
|
103
|
-
* ```
|
|
104
|
-
*
|
|
105
|
-
* ## registration
|
|
106
|
-
*
|
|
107
|
-
* The registration property is an object that can be used to simplify registration of the model with the model registry. The registration object
|
|
108
|
-
* can be spread into the model registration and provides all of the required information to register the model implementation class against the model type.
|
|
109
|
-
*
|
|
110
|
-
*
|
|
111
|
-
* @example
|
|
112
|
-
*
|
|
113
|
-
* In an application registration file you can declare the model registration as follows:
|
|
114
|
-
*
|
|
115
|
-
* **registration.ts**
|
|
116
|
-
* ```typescript
|
|
117
|
-
* import { <%= nameProperCase %> } from "@kos-ui/project-models";
|
|
118
|
-
* import { KosModelRegistry } from "@kosdev-code/kos-dispense-sdk";
|
|
119
|
-
*
|
|
120
|
-
* import { initKosProvider } from "@kosdev-code/kos-ui-sdk";
|
|
121
|
-
*
|
|
122
|
-
* KosModelRegistry.dispense
|
|
123
|
-
* .models()
|
|
124
|
-
* .model(<%= nameProperCase %>);
|
|
125
|
-
* ```
|
|
126
|
-
*
|
|
127
|
-
* ## registration.singleton
|
|
128
|
-
<% if (singleton) { %>
|
|
129
|
-
* The <%= nameCamelCase %> model is a singleton model. This means that each time the factory function is called , the same instance will be returned.
|
|
130
|
-
* If the model does not yet exist, it will be created passing in the provided options to initialize it.
|
|
131
|
-
*
|
|
132
|
-
* Singleton models don't require an ID as they will use the model type as their ID to guarantee uniqueness throughout the system.
|
|
133
|
-
<% } else { %>
|
|
134
|
-
* The <%= nameCamelCase %> model is NOT a singleton model. This means that each time the factory function is called with a unique ID, a new model instance will be created.
|
|
135
|
-
* If the factory function is called with an ID that already exists, the existing model will be returned.
|
|
136
|
-
<% } %>
|
|
137
|
-
* */
|
|
138
|
-
export const <%= nameProperCase %> = new <% if (singleton) { %>Singleton<% } %>KosModelRegistrationFactory<
|
|
139
|
-
<%= nameProperCase %>Model,
|
|
140
|
-
<%= nameProperCase %>Options
|
|
141
|
-
>({
|
|
142
|
-
class: <%= nameProperCase %>ModelImpl<% if (needsAnyCast) { %> as any<% } %>, <% if (needsAnyCast) { %>// Type cast needed for<% if (hasFutureSupport && hasCompanionSupport) { %> Future and companion<% } else if (hasFutureSupport) { %> Future<% } else { %> companion<% } %> intersection<% } %>
|
|
143
|
-
type: MODEL_TYPE,
|
|
144
|
-
});
|