@kosdev-code/kos-nx-plugin 2.1.2 → 2.1.3

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 (38) hide show
  1. package/package.json +2 -2
  2. package/src/generators/kos-component/README.md +50 -29
  3. package/src/generators/kos-component/control-pour/__nameDashCase__.stories.tsx__template__ +1 -1
  4. package/src/generators/kos-component/cui/__nameDashCase__.stories.tsx__template__ +1 -1
  5. package/src/generators/kos-component/custom/__nameDashCase__.stories.tsx__template__ +31 -0
  6. package/src/generators/kos-component/custom/__nameDashCase__.tsx__template__ +53 -0
  7. package/src/generators/kos-component/custom/index.ts__template__ +1 -0
  8. package/src/generators/kos-component/generator.d.ts +3 -0
  9. package/src/generators/kos-component/generator.d.ts.map +1 -1
  10. package/src/generators/kos-component/generator.js +83 -282
  11. package/src/generators/kos-component/generator.js.map +1 -1
  12. package/src/generators/kos-component/index.d.ts +1 -1
  13. package/src/generators/kos-component/index.d.ts.map +1 -1
  14. package/src/generators/kos-component/index.js +4 -4
  15. package/src/generators/kos-component/index.js.map +1 -1
  16. package/src/generators/kos-component/nav/__nameDashCase__.stories.tsx__template__ +1 -1
  17. package/src/generators/kos-component/plugin-handlers/custom-handler.d.ts +11 -0
  18. package/src/generators/kos-component/plugin-handlers/custom-handler.d.ts.map +1 -0
  19. package/src/generators/kos-component/plugin-handlers/custom-handler.js +45 -0
  20. package/src/generators/kos-component/plugin-handlers/custom-handler.js.map +1 -0
  21. package/src/generators/kos-component/plugin-handlers/factory.d.ts.map +1 -1
  22. package/src/generators/kos-component/plugin-handlers/factory.js +2 -0
  23. package/src/generators/kos-component/plugin-handlers/factory.js.map +1 -1
  24. package/src/generators/kos-component/schema.d.ts +3 -1
  25. package/src/generators/kos-component/schema.json +12 -0
  26. package/src/generators/kos-component/setting/__nameDashCase__.stories.tsx__template__ +1 -1
  27. package/src/generators/kos-component/setup/__nameDashCase__.stories.tsx__template__ +1 -1
  28. package/src/generators/kos-component/trouble-action/__nameDashCase__.stories.tsx__template__ +1 -1
  29. package/src/generators/kos-component/types.d.ts +2 -0
  30. package/src/generators/kos-component/types.d.ts.map +1 -1
  31. package/src/generators/kos-component/types.js +3 -0
  32. package/src/generators/kos-component/types.js.map +1 -1
  33. package/src/generators/kos-component/utility/__nameDashCase__.stories.tsx__template__ +1 -1
  34. package/src/generators/kos-plugin-project/files/src/app/components/main-view/main-view.tsx.template +1 -1
  35. package/src/generators/kos-component/generator_refactored.d.ts +0 -8
  36. package/src/generators/kos-component/generator_refactored.d.ts.map +0 -1
  37. package/src/generators/kos-component/generator_refactored.js +0 -96
  38. package/src/generators/kos-component/generator_refactored.js.map +0 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kosdev-code/kos-nx-plugin",
3
- "version": "2.1.2",
3
+ "version": "2.1.3",
4
4
  "type": "commonjs",
5
5
  "generators": "./generators.json",
6
6
  "publishConfig": {
@@ -19,7 +19,7 @@
19
19
  "main": "./src/index.js",
20
20
  "kos": {
21
21
  "build": {
22
- "gitHash": "ced64602bed23fe8386ffbada4657bec2503a42f"
22
+ "gitHash": "22bfa6b003918abbc473ab6b5cae1728e473a7e9"
23
23
  }
24
24
  }
25
25
  }
@@ -33,12 +33,12 @@ Add your new plugin type to `types.ts`:
33
33
  // types.ts
34
34
  export const PLUGIN_TYPES = {
35
35
  // ... existing types
36
- MY_NEW_PLUGIN: 'myNewPlugin',
36
+ MY_NEW_PLUGIN: "myNewPlugin",
37
37
  } as const;
38
38
 
39
39
  export const CONTRIBUTION_TYPE_MAP: Record<string, string> = {
40
40
  // ... existing mappings
41
- [PLUGIN_TYPES.MY_NEW_PLUGIN]: 'my-new-contribution',
41
+ [PLUGIN_TYPES.MY_NEW_PLUGIN]: "my-new-contribution",
42
42
  };
43
43
 
44
44
  // Add to localized types if your plugin needs i18n
@@ -53,18 +53,18 @@ export const LOCALIZED_PLUGIN_TYPES: ReadonlySet<string> = new Set([
53
53
  Create a new handler file `plugin-handlers/my-new-plugin-handler.ts`:
54
54
 
55
55
  ```typescript
56
- import { NormalizedOptions, PluginConfiguration, PLUGIN_TYPES } from '../types';
57
- import { BasePluginHandler } from './base';
56
+ import { NormalizedOptions, PluginConfiguration, PLUGIN_TYPES } from "../types";
57
+ import { BasePluginHandler } from "./base";
58
58
 
59
59
  export class MyNewPluginHandler extends BasePluginHandler {
60
60
  protected pluginType = PLUGIN_TYPES.MY_NEW_PLUGIN;
61
- protected contributionKey = 'my-new-contribution';
61
+ protected contributionKey = "my-new-contribution";
62
62
  protected requiresI18n = true; // or false if no localization needed
63
-
63
+
64
64
  createConfiguration(options: NormalizedOptions): PluginConfiguration {
65
65
  const configPrefix = this.getConfigPrefix(options);
66
66
  const experienceId = `${configPrefix}.myNewPlugin.experience`;
67
-
67
+
68
68
  const contribution = {
69
69
  id: `${configPrefix}.myNewPlugin`,
70
70
  title: `${configPrefix}.myNewPlugin.title`,
@@ -73,9 +73,9 @@ export class MyNewPluginHandler extends BasePluginHandler {
73
73
  myCustomProperty: options.nameCamelCase,
74
74
  experienceId,
75
75
  };
76
-
76
+
77
77
  const experience = this.createExperience(options, experienceId);
78
-
78
+
79
79
  return {
80
80
  contributions: {
81
81
  myNewContributions: [contribution], // Use appropriate contribution key
@@ -91,6 +91,7 @@ export class MyNewPluginHandler extends BasePluginHandler {
91
91
  #### Handler Customization Options
92
92
 
93
93
  **Override template path** if your plugin uses custom templates:
94
+
94
95
  ```typescript
95
96
  getTemplatePath(): string {
96
97
  return 'my-custom-template-folder';
@@ -98,6 +99,7 @@ getTemplatePath(): string {
98
99
  ```
99
100
 
100
101
  **Custom component path** if needed:
102
+
101
103
  ```typescript
102
104
  protected getComponentPath(options: NormalizedOptions): string {
103
105
  return `${options.appDirectory}/custom-path/${options.nameDashCase}/${options.nameDashCase}.tsx`;
@@ -122,15 +124,15 @@ private static handlers: Map<string, new () => PluginHandler> = new Map<
122
124
  ]);
123
125
  ```
124
126
 
125
- ### 4. Register CLI Command (Required for kosui plugin:* syntax)
127
+ ### 4. Register CLI Command (Required for kosui plugin:\* syntax)
126
128
 
127
129
  To make your plugin available via `kosui plugin:myNewPlugin`, update the CLI metadata in `/packages/sdk/kos-ui-cli/src/lib/generators/plugin/index.mjs`:
128
130
 
129
131
  ```javascript
130
132
  export const metadata = [
131
133
  // ... existing metadata
132
- {
133
- key: "plugin:myNewPlugin",
134
+ {
135
+ key: "plugin:myNewPlugin",
134
136
  name: "KOS UI Plugin My New Plugin",
135
137
  namedArguments: {
136
138
  name: "componentName",
@@ -138,8 +140,8 @@ export const metadata = [
138
140
  project: "componentProject",
139
141
  componentProject: "componentProject",
140
142
  // Add any plugin-specific arguments
141
- customOption: "customOption"
142
- }
143
+ customOption: "customOption",
144
+ },
143
145
  },
144
146
  ];
145
147
 
@@ -166,6 +168,7 @@ kos-component/
166
168
  ```
167
169
 
168
170
  **Component Template** (`__nameDashCase__.tsx__template__`):
171
+
169
172
  ```typescript
170
173
  import React from 'react';
171
174
 
@@ -186,12 +189,13 @@ export default <%= namePascalCase %>;
186
189
  ```
187
190
 
188
191
  **Storybook Template** (`__nameDashCase__.stories.tsx__template__`):
192
+
189
193
  ```typescript
190
194
  /**
191
195
  * Note: The plugin project Storybook configuration requires that the Studio
192
196
  * Simulator is running in order to retrieve model data...
193
197
  */
194
- import { MyNewPluginStoryContainer } from "@kosdev-code/kos-ui-plugin/dev";
198
+ import { MyNewPluginStoryContainer } from "@kosdev-code/kos-ui-plugin-dev";
195
199
  import type { Meta, StoryObj } from "@storybook/react";
196
200
  import { <%= namePascalCase %> } from "./<%= nameDashCase %>";
197
201
 
@@ -219,8 +223,9 @@ export const Default: Story = {
219
223
  ```
220
224
 
221
225
  **Available Story Containers:**
226
+
222
227
  - `CUIStoryContainer` - For CUI plugins
223
- - `UtilityStoryContainer` - For utility plugins
228
+ - `UtilityStoryContainer` - For utility plugins
224
229
  - `SetupStoryContainer` - For setup plugins
225
230
  - `SettingStoryContainer` - For setting plugins
226
231
  - `NavStoryContainer` - For navigation plugins
@@ -243,6 +248,7 @@ If your plugin needs additional CLI parameters, update `schema.json`:
243
248
  ```
244
249
 
245
250
  And update `schema.d.ts`:
251
+
246
252
  ```typescript
247
253
  export interface KosComponentGeneratorSchema {
248
254
  // ... existing properties
@@ -260,11 +266,11 @@ export function validateOptions(
260
266
  options: KosComponentGeneratorSchema
261
267
  ): void {
262
268
  // ... existing validation
263
-
269
+
264
270
  // Add custom validation for your plugin
265
- if (options.pluginType === 'myNewPlugin' && !options.myCustomOption) {
271
+ if (options.pluginType === "myNewPlugin" && !options.myCustomOption) {
266
272
  throw new ValidationError(
267
- 'myCustomOption is required for myNewPlugin type'
273
+ "myCustomOption is required for myNewPlugin type"
268
274
  );
269
275
  }
270
276
  }
@@ -273,11 +279,13 @@ export function validateOptions(
273
279
  ## Testing Your New Plugin Type
274
280
 
275
281
  ### 1. Build the Plugin
282
+
276
283
  ```bash
277
284
  nx build kos-nx-plugin
278
285
  ```
279
286
 
280
287
  ### 2. Test Generation
288
+
281
289
  ```bash
282
290
  # Test your new plugin type using the specific plugin generator
283
291
  kosui plugin:myNewPlugin --name test-component --project my-test-project
@@ -288,9 +296,11 @@ kosui pluginComponent --name test-component --project my-test-project
288
296
  ```
289
297
 
290
298
  ### 3. Verify Output
299
+
291
300
  Check that the generated files include:
301
+
292
302
  - Component files in the correct location (`.tsx`)
293
- - Storybook stories (`.stories.tsx`)
303
+ - Storybook stories (`.stories.tsx`)
294
304
  - Index files (`index.ts`)
295
305
  - Updated .kos.json with your contribution
296
306
  - Localization entries (if applicable)
@@ -299,12 +309,15 @@ Check that the generated files include:
299
309
  ## Best Practices
300
310
 
301
311
  ### 1. **Naming Conventions**
312
+
302
313
  - Plugin type: `camelCase` (e.g., `myNewPlugin`)
303
314
  - Contribution key: `kebab-case` (e.g., `my-new-contribution`)
304
315
  - Handler class: `PascalCase` + `Handler` (e.g., `MyNewPluginHandler`)
305
316
 
306
317
  ### 2. **Configuration Structure**
318
+
307
319
  Follow existing patterns for contribution objects:
320
+
308
321
  ```typescript
309
322
  {
310
323
  id: `${configPrefix}.${pluginType}`,
@@ -316,11 +329,13 @@ Follow existing patterns for contribution objects:
316
329
  ```
317
330
 
318
331
  ### 3. **Template Organization**
332
+
319
333
  - Use meaningful template folder names
320
334
  - Include index.ts for clean imports
321
335
  - Follow existing template variable patterns
322
336
 
323
337
  ### 4. **Documentation**
338
+
324
339
  - Update CLI help text if needed
325
340
  - Add examples to this README
326
341
  - Document any special requirements
@@ -328,13 +343,14 @@ Follow existing patterns for contribution objects:
328
343
  ## Extending Base Functionality
329
344
 
330
345
  ### Custom Experience Creation
346
+
331
347
  ```typescript
332
348
  protected createExperience(
333
349
  options: NormalizedOptions,
334
350
  experienceId: string
335
351
  ): ExperienceConfig {
336
352
  const compPath = this.getCustomComponentPath(options);
337
-
353
+
338
354
  return {
339
355
  id: experienceId,
340
356
  component: options.namePascalCase,
@@ -346,11 +362,12 @@ protected createExperience(
346
362
  ```
347
363
 
348
364
  ### Custom Contribution Logic
365
+
349
366
  ```typescript
350
367
  createConfiguration(options: NormalizedOptions): PluginConfiguration {
351
368
  // Create multiple contributions if needed
352
369
  const contributions = this.createMultipleContributions(options);
353
-
370
+
354
371
  return {
355
372
  contributions: {
356
373
  contribution1: contributions.first,
@@ -369,24 +386,24 @@ Here's a complete example for a "dashboard" plugin type:
369
386
  // plugin-handlers/dashboard-handler.ts
370
387
  export class DashboardPluginHandler extends BasePluginHandler {
371
388
  protected pluginType = PLUGIN_TYPES.DASHBOARD;
372
- protected contributionKey = 'dashboard';
389
+ protected contributionKey = "dashboard";
373
390
  protected requiresI18n = true;
374
-
391
+
375
392
  createConfiguration(options: NormalizedOptions): PluginConfiguration {
376
393
  const configPrefix = this.getConfigPrefix(options);
377
394
  const experienceId = `${configPrefix}.dashboard.experience`;
378
-
395
+
379
396
  const contribution = {
380
397
  id: `${configPrefix}.dashboard`,
381
398
  title: `${configPrefix}.dashboard.title`,
382
399
  namespace: options.appProject,
383
400
  dashboardType: options.nameCamelCase,
384
- layout: 'grid', // Dashboard-specific property
401
+ layout: "grid", // Dashboard-specific property
385
402
  experienceId,
386
403
  };
387
-
404
+
388
405
  const experience = this.createExperience(options, experienceId);
389
-
406
+
390
407
  return {
391
408
  contributions: {
392
409
  dashboards: [contribution],
@@ -421,21 +438,25 @@ kosui pluginComponent --name data-export --project admin-ui
421
438
  ## Troubleshooting
422
439
 
423
440
  **Plugin not recognized:**
441
+
424
442
  - Verify handler is registered in factory.ts
425
443
  - Check PLUGIN_TYPES constant is exported
426
444
  - Ensure plugin type matches exactly
427
445
 
428
446
  **Template not found:**
447
+
429
448
  - Check template folder name matches contributionKey
430
449
  - Verify template files exist and have correct extensions
431
450
  - Use `getTemplatePath()` if using custom path
432
451
 
433
452
  **Configuration not applied:**
453
+
434
454
  - Check .kos.json structure matches expected format
435
455
  - Verify contribution keys are correct
436
456
  - Test KosConfigBuilder logic with debug output
437
457
 
438
458
  **Localization not working:**
459
+
439
460
  - Ensure plugin type is in LOCALIZED_PLUGIN_TYPES
440
461
  - Check locale file exists at expected path
441
462
  - Verify updateLocalization is called for your handler
@@ -450,4 +471,4 @@ When contributing new plugin types to the KOS framework:
450
471
  4. Submit PR with clear description of the plugin's purpose
451
472
  5. Include usage examples
452
473
 
453
- For questions or support, refer to the KOS development team or create an issue in the project repository.
474
+ For questions or support, refer to the KOS development team or create an issue in the project repository.
@@ -2,7 +2,7 @@
2
2
  * Note: The plugin project Storybook configuration requires that the Studio
3
3
  * Simulator is running in order to retrieve model data...
4
4
  */
5
- import { ControlPourStoryContainer } from "@kosdev-code/kos-ui-plugin/dev";
5
+ import { ControlPourStoryContainer } from "@kosdev-code/kos-ui-plugin-dev";
6
6
  import type { Meta, StoryObj } from "@storybook/react";
7
7
  import { <%= namePascalCase %> } from "./<%= nameDashCase %>";
8
8
 
@@ -2,7 +2,7 @@
2
2
  * Note: The plugin project Storybook configuration requires that the Studio
3
3
  * Simulator is running in order to retrieve model data...
4
4
  */
5
- import { CUIStoryContainer } from "@kosdev-code/kos-ui-plugin/dev";
5
+ import { CUIStoryContainer } from "@kosdev-code/kos-ui-plugin-dev";
6
6
  import type { Meta, StoryObj } from "@storybook/react";
7
7
  import { <%= namePascalCase %> } from "./<%= nameDashCase %>";
8
8
 
@@ -0,0 +1,31 @@
1
+ import { Button } from '@kosdev-code/kos-ddk-components';
2
+ import { StoryObj } from '@storybook/react';
3
+ import { <%= namePascalCase %> } from './<%= nameDashCase %>';
4
+
5
+ const meta = {
6
+ title: '<%= appProject %>/<%= namePascalCase %> Custom Plugin',
7
+ component: <%= namePascalCase %>,
8
+ };
9
+
10
+ export default meta;
11
+
12
+ type Story = StoryObj<typeof meta>;
13
+
14
+ export const Default: Story = {
15
+ args: {
16
+ onComplete: () => console.log('Custom plugin completed'),
17
+ },
18
+ decorators: [
19
+ (Story) => (
20
+ <div style={{ padding: '20px' }}>
21
+ <Story />
22
+ </div>
23
+ ),
24
+ ],
25
+ };
26
+
27
+ export const WithCustomAction: Story = {
28
+ args: {
29
+ onComplete: () => alert('Custom action triggered!'),
30
+ },
31
+ };
@@ -0,0 +1,53 @@
1
+ import styled from '@emotion/styled';
2
+ import {
3
+ Button,
4
+ Footer,
5
+ type Experience,
6
+ } from '@kosdev-code/kos-ddk-components';
7
+ import {
8
+ KosLog,
9
+ kosComponent,
10
+ useKosTranslation,
11
+ } from '@kosdev-code/kos-ui-sdk';
12
+
13
+ const log = KosLog.createLogger({name: "<%= nameDashCase %>"})
14
+ log.debug("<%= nameDashCase %> component loaded");
15
+
16
+ const <%= namePascalCase %>Container = styled.div`
17
+ align-items: center;
18
+ display: flex;
19
+ flex-direction: column;
20
+ width: 100%;
21
+ `;
22
+
23
+ /**
24
+ * Custom plugin component for <%= contributionKey || 'custom' %> contribution
25
+ *
26
+ * TODO: Add additional fields to your .kos.json contribution as required by the plugin-explorer specification.
27
+ * Refer to the plugin-explorer documentation for your specific contribution type.
28
+ *
29
+ * The basic contribution structure has been created, but you may need to add fields such as:
30
+ * - icon: The icon to display for this contribution
31
+ * - order: The display order relative to other contributions
32
+ * - when: Conditional visibility expressions
33
+ * - category: The category this contribution belongs to
34
+ * - etc.
35
+ */
36
+ export const <%= namePascalCase %>: Experience = kosComponent(({ onComplete }) => {
37
+ const { t } = useKosTranslation('<%= appProject %>');
38
+
39
+ return (
40
+ <<%= namePascalCase %>Container>
41
+ <h2><%= namePascalCase %> Custom Plugin</h2>
42
+ <p>This is a custom plugin component with contribution key: <%= contributionKey || 'custom' %></p>
43
+
44
+ {/* TODO: Implement your custom plugin functionality here */}
45
+
46
+ <Footer>
47
+ <Button onClick={onComplete}>{t('proceed')}</Button>
48
+ </Footer>
49
+ </<%= namePascalCase %>Container>
50
+ );
51
+ });
52
+
53
+ export default <%= namePascalCase %>
@@ -0,0 +1 @@
1
+ export * from './<%= nameDashCase %>';
@@ -1,5 +1,8 @@
1
1
  import { Tree } from "@nx/devkit";
2
2
  import { KosComponentGeneratorSchema } from "./schema";
3
+ /**
4
+ * KOS Component Generator
5
+ */
3
6
  export declare function kosComponentGenerator(tree: Tree, options: KosComponentGeneratorSchema): Promise<void>;
4
7
  export default kosComponentGenerator;
5
8
  //# sourceMappingURL=generator.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"generator.d.ts","sourceRoot":"","sources":["../../../../../../../packages/plugins/kos-nx-plugin/src/generators/kos-component/generator.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,IAAI,EAEL,MAAM,YAAY,CAAC;AAIpB,OAAO,EAAE,2BAA2B,EAAE,MAAM,UAAU,CAAC;AAmBvD,wBAAsB,qBAAqB,CACzC,IAAI,EAAE,IAAI,EACV,OAAO,EAAE,2BAA2B,iBAmUrC;AAED,eAAe,qBAAqB,CAAC"}
1
+ {"version":3,"file":"generator.d.ts","sourceRoot":"","sources":["../../../../../../../packages/plugins/kos-nx-plugin/src/generators/kos-component/generator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAyC,IAAI,EAAE,MAAM,YAAY,CAAC;AAIzE,OAAO,EAAE,2BAA2B,EAAE,MAAM,UAAU,CAAC;AAQvD;;GAEG;AACH,wBAAsB,qBAAqB,CACzC,IAAI,EAAE,IAAI,EACV,OAAO,EAAE,2BAA2B,iBAiCrC;AA4FD,eAAe,qBAAqB,CAAC"}