@kosdev-code/kos-nx-plugin 2.0.41 → 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.
Files changed (21) hide show
  1. package/package.json +2 -2
  2. package/src/generators/kos-add-future-to-model/generator.d.ts.map +1 -1
  3. package/src/generators/kos-add-future-to-model/generator.js.map +1 -1
  4. package/src/generators/kos-add-future-to-model/lib/model-transformer.d.ts +8 -3
  5. package/src/generators/kos-add-future-to-model/lib/model-transformer.d.ts.map +1 -1
  6. package/src/generators/kos-add-future-to-model/lib/model-transformer.js +191 -155
  7. package/src/generators/kos-add-future-to-model/lib/model-transformer.js.map +1 -1
  8. package/src/generators/kos-container-model/files/model/__nameDashCase__-model.ts.template +25 -40
  9. package/src/generators/kos-container-model/files/model/index.ts.template +20 -5
  10. package/src/generators/kos-model/files/model/__nameDashCase__-model.ts.template +35 -43
  11. package/src/generators/kos-model/files/model/index.ts__template__ +11 -3
  12. package/src/generators/kos-model/schema.d.ts +1 -0
  13. package/src/generators/kos-model/schema.json +5 -0
  14. package/src/generators/kos-plugin-project/generator.js +6 -6
  15. package/src/generators/kos-plugin-project/generator.js.map +1 -1
  16. package/src/generators/preset/generator.d.ts.map +1 -1
  17. package/src/generators/preset/generator.js +7 -5
  18. package/src/generators/preset/generator.js.map +1 -1
  19. package/src/generators/preset/tools/tools/scripts/update.mjs.template +29 -8
  20. package/src/generators/kos-container-model/files/model/__nameDashCase__-registration.ts.template +0 -113
  21. package/src/generators/kos-model/files/model/__nameDashCase__-registration.ts.template +0 -144
@@ -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
- });