klasik 1.0.10 โ 1.0.12
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/dist/k8s-client-generator.js +3 -0
- package/package.json +4 -2
- package/test-discriminated-output/.openapi-generator-ignore +23 -0
- package/test-discriminated-output/api/default-api.ts +142 -0
- package/test-discriminated-output/api.ts +19 -0
- package/test-discriminated-output/base.ts +86 -0
- package/test-discriminated-output/common.ts +151 -0
- package/test-discriminated-output/configuration.ts +152 -0
- package/test-discriminated-output/index.ts +18 -0
- package/test-discriminated-output/models/capability.js +80 -0
- package/test-discriminated-output/models/capability.ts +74 -0
- package/test-discriminated-output/models/helm-component.js +82 -0
- package/test-discriminated-output/models/helm-component.ts +83 -0
- package/test-discriminated-output/models/index.ts +4 -0
- package/test-discriminated-output/models/kustomize-component.js +70 -0
- package/test-discriminated-output/models/kustomize-component.ts +70 -0
- package/test-discriminated-output/models/manifest-component.js +58 -0
- package/test-discriminated-output/models/manifest-component.ts +57 -0
- package/test-runtime.js +72 -0
- package/test-runtime.ts +80 -0
package/test-runtime.ts
ADDED
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import 'reflect-metadata';
|
|
2
|
+
import { plainToInstance } from 'class-transformer';
|
|
3
|
+
import { Capability } from './test-discriminated-output/models/capability.js';
|
|
4
|
+
import { HelmComponent } from './test-discriminated-output/models/helm-component.js';
|
|
5
|
+
import { KustomizeComponent } from './test-discriminated-output/models/kustomize-component.js';
|
|
6
|
+
import { ManifestComponent } from './test-discriminated-output/models/manifest-component.js';
|
|
7
|
+
|
|
8
|
+
// Test data with discriminated union
|
|
9
|
+
const plainData = {
|
|
10
|
+
name: 'my-app',
|
|
11
|
+
description: 'Application deployment',
|
|
12
|
+
components: [
|
|
13
|
+
{
|
|
14
|
+
type: 'helm',
|
|
15
|
+
chartName: 'nginx',
|
|
16
|
+
version: '1.0.0',
|
|
17
|
+
values: { replicas: 3 }
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
type: 'kustomize',
|
|
21
|
+
path: './overlays/production',
|
|
22
|
+
namespace: 'prod'
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
type: 'manifest',
|
|
26
|
+
manifests: [
|
|
27
|
+
'apiVersion: v1\nkind: ConfigMap',
|
|
28
|
+
'apiVersion: v1\nkind: Service'
|
|
29
|
+
]
|
|
30
|
+
}
|
|
31
|
+
]
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
console.log('๐งช Testing Discriminated Union Runtime Transformation\n');
|
|
35
|
+
|
|
36
|
+
// Transform using plainToInstance
|
|
37
|
+
const capability = plainToInstance(Capability, plainData);
|
|
38
|
+
|
|
39
|
+
// Verify instance types
|
|
40
|
+
console.log('โ
Verification Results:');
|
|
41
|
+
console.log(' capability instanceof Capability:', capability instanceof Capability);
|
|
42
|
+
console.log(' capability.name:', capability.name);
|
|
43
|
+
console.log(' capability.components.length:', capability.components.length);
|
|
44
|
+
console.log('');
|
|
45
|
+
|
|
46
|
+
console.log('โ
Component Type Verification:');
|
|
47
|
+
console.log(' components[0] instanceof HelmComponent:', capability.components[0] instanceof HelmComponent);
|
|
48
|
+
console.log(' components[1] instanceof KustomizeComponent:', capability.components[1] instanceof KustomizeComponent);
|
|
49
|
+
console.log(' components[2] instanceof ManifestComponent:', capability.components[2] instanceof ManifestComponent);
|
|
50
|
+
console.log('');
|
|
51
|
+
|
|
52
|
+
console.log('โ
Property Access:');
|
|
53
|
+
console.log(' HelmComponent.chartName:', (capability.components[0] as HelmComponent).chartName);
|
|
54
|
+
console.log(' KustomizeComponent.path:', (capability.components[1] as KustomizeComponent).path);
|
|
55
|
+
console.log(' ManifestComponent.manifests.length:', (capability.components[2] as ManifestComponent).manifests?.length);
|
|
56
|
+
console.log('');
|
|
57
|
+
|
|
58
|
+
console.log('โ
attributeTypeMap Check:');
|
|
59
|
+
const componentsMetadata = Capability.attributeTypeMap.find(m => m.name === 'components');
|
|
60
|
+
console.log(' type:', componentsMetadata?.type);
|
|
61
|
+
console.log(' modelClasses:', (componentsMetadata as any)?.modelClasses?.map((c: any) => c.name));
|
|
62
|
+
console.log(' discriminatorProperty:', (componentsMetadata as any)?.discriminatorProperty);
|
|
63
|
+
console.log('');
|
|
64
|
+
|
|
65
|
+
// Final verification
|
|
66
|
+
const allCorrect =
|
|
67
|
+
capability instanceof Capability &&
|
|
68
|
+
capability.components[0] instanceof HelmComponent &&
|
|
69
|
+
capability.components[1] instanceof KustomizeComponent &&
|
|
70
|
+
capability.components[2] instanceof ManifestComponent &&
|
|
71
|
+
(capability.components[0] as HelmComponent).chartName === 'nginx' &&
|
|
72
|
+
(capability.components[1] as KustomizeComponent).path === './overlays/production' &&
|
|
73
|
+
(capability.components[2] as ManifestComponent).manifests?.length === 2;
|
|
74
|
+
|
|
75
|
+
if (allCorrect) {
|
|
76
|
+
console.log('๐ SUCCESS! All discriminated union transformations working correctly!');
|
|
77
|
+
} else {
|
|
78
|
+
console.log('โ FAILED! Some transformations did not work as expected.');
|
|
79
|
+
process.exit(1);
|
|
80
|
+
}
|