@thinkwise/testwise 0.1.97 → 0.2.0-beta.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/Testwise.ts +7 -9
- package/artifact-builder/ArtifactManager.ts +33 -0
- package/artifact-builder/InterfaceGenerator.ts +165 -0
- package/artifact-builder/ModelDataBuilder.ts +194 -0
- package/artifact-builder/ModelDataRefiner.ts +39 -0
- package/artifact-builder/SchemaGenerator.ts +131 -0
- package/artifact-builder/ScreenInterfaceRefiner.ts +154 -0
- package/artifact-builder/SelectorBuilder.ts +82 -0
- package/artifact-builder/SubjectComponentGenerator.ts +186 -0
- package/artifact-builder/SubjectGenerator.ts +332 -0
- package/artifact-builder/SubjectRegistration.ts +131 -0
- package/artifact-builder/helpers/DataRetriever.ts +64 -0
- package/artifact-builder/helpers/NamingHandler.ts +182 -0
- package/artifact-builder/helpers/Stopwatch.ts +13 -0
- package/artifact-builder/helpers/index.ts +3 -0
- package/artifact-builder/index.ts +9 -0
- package/components/{actionbar/Actionbar.ts → action-bar/ActionBar.ts} +12 -12
- package/components/{actionbar/ActionbarObjects.ts → action-bar/ActionBarObjects.ts} +4 -4
- package/components/{actionbar → action-bar}/CustomActionBar.ts +2 -2
- package/components/index.ts +3 -4
- package/components/tab/DetailTabPage.ts +20 -0
- package/components/tab/{DetailTabObjects.ts → DetailTabPageObjects.ts} +1 -1
- package/components/tab/Tab.ts +31 -5
- package/components/tab/TabObjects.ts +15 -3
- package/dist/Testwise.js +5 -1
- package/dist/Testwise.js.map +1 -1
- package/dist/artifact-builder/ArtifactManager.d.ts +8 -0
- package/dist/artifact-builder/ArtifactManager.js +27 -0
- package/dist/artifact-builder/ArtifactManager.js.map +1 -0
- package/dist/artifact-builder/InterfaceGenerator.d.ts +15 -0
- package/dist/artifact-builder/InterfaceGenerator.js +122 -0
- package/dist/artifact-builder/InterfaceGenerator.js.map +1 -0
- package/dist/artifact-builder/ModelDataBuilder.d.ts +2 -0
- package/dist/artifact-builder/ModelDataBuilder.js +141 -0
- package/dist/artifact-builder/ModelDataBuilder.js.map +1 -0
- package/dist/artifact-builder/ModelDataRefiner.d.ts +4 -0
- package/dist/artifact-builder/ModelDataRefiner.js +28 -0
- package/dist/artifact-builder/ModelDataRefiner.js.map +1 -0
- package/dist/artifact-builder/SchemaGenerator.d.ts +12 -0
- package/dist/artifact-builder/SchemaGenerator.js +102 -0
- package/dist/artifact-builder/SchemaGenerator.js.map +1 -0
- package/dist/artifact-builder/ScreenInterfaceRefiner.d.ts +15 -0
- package/dist/artifact-builder/ScreenInterfaceRefiner.js +120 -0
- package/dist/artifact-builder/ScreenInterfaceRefiner.js.map +1 -0
- package/dist/artifact-builder/SelectorBuilder.d.ts +13 -0
- package/dist/artifact-builder/SelectorBuilder.js +69 -0
- package/dist/artifact-builder/SelectorBuilder.js.map +1 -0
- package/dist/artifact-builder/SubjectComponentGenerator.d.ts +23 -0
- package/dist/artifact-builder/SubjectComponentGenerator.js +136 -0
- package/dist/artifact-builder/SubjectComponentGenerator.js.map +1 -0
- package/dist/artifact-builder/SubjectGenerator.d.ts +27 -0
- package/dist/artifact-builder/SubjectGenerator.js +235 -0
- package/dist/artifact-builder/SubjectGenerator.js.map +1 -0
- package/dist/artifact-builder/SubjectRegistration.d.ts +21 -0
- package/dist/artifact-builder/SubjectRegistration.js +95 -0
- package/dist/artifact-builder/SubjectRegistration.js.map +1 -0
- package/dist/artifact-builder/helpers/DataRetriever.d.ts +12 -0
- package/dist/artifact-builder/helpers/DataRetriever.js +52 -0
- package/dist/artifact-builder/helpers/DataRetriever.js.map +1 -0
- package/dist/artifact-builder/helpers/NamingHandler.d.ts +24 -0
- package/dist/artifact-builder/helpers/NamingHandler.js +147 -0
- package/dist/artifact-builder/helpers/NamingHandler.js.map +1 -0
- package/dist/artifact-builder/helpers/Stopwatch.d.ts +5 -0
- package/dist/artifact-builder/helpers/Stopwatch.js +13 -0
- package/dist/artifact-builder/helpers/Stopwatch.js.map +1 -0
- package/dist/artifact-builder/helpers/index.d.ts +3 -0
- package/dist/artifact-builder/helpers/index.js +4 -0
- package/dist/artifact-builder/helpers/index.js.map +1 -0
- package/dist/artifact-builder/index.d.ts +9 -0
- package/dist/artifact-builder/index.js +10 -0
- package/dist/artifact-builder/index.js.map +1 -0
- package/dist/components/{actionbar/Actionbar.d.ts → action-bar/ActionBar.d.ts} +4 -4
- package/dist/components/{actionbar/Actionbar.js → action-bar/ActionBar.js} +9 -9
- package/dist/components/action-bar/ActionBar.js.map +1 -0
- package/dist/components/{actionbar/ActionbarObjects.d.ts → action-bar/ActionBarObjects.d.ts} +2 -2
- package/dist/components/{actionbar/ActionbarObjects.js → action-bar/ActionBarObjects.js} +5 -5
- package/dist/components/action-bar/ActionBarObjects.js.map +1 -0
- package/dist/components/{actionbar → action-bar}/CustomActionBar.d.ts +2 -2
- package/dist/components/action-bar/CustomActionBar.js +7 -0
- package/dist/components/action-bar/CustomActionBar.js.map +1 -0
- package/dist/components/index.d.ts +3 -4
- package/dist/components/index.js +3 -4
- package/dist/components/index.js.map +1 -1
- package/dist/components/tab/DetailTabPage.d.ts +9 -0
- package/dist/components/tab/DetailTabPage.js +15 -0
- package/dist/components/tab/DetailTabPage.js.map +1 -0
- package/dist/components/tab/{DetailTabObjects.d.ts → DetailTabPageObjects.d.ts} +1 -1
- package/dist/components/tab/{DetailTabObjects.js → DetailTabPageObjects.js} +2 -2
- package/dist/components/tab/DetailTabPageObjects.js.map +1 -0
- package/dist/components/tab/Tab.d.ts +8 -3
- package/dist/components/tab/Tab.js +25 -4
- package/dist/components/tab/Tab.js.map +1 -1
- package/dist/components/tab/TabObjects.d.ts +7 -2
- package/dist/components/tab/TabObjects.js +9 -2
- package/dist/components/tab/TabObjects.js.map +1 -1
- package/dist/enums/ElementTypes.d.ts +8 -0
- package/dist/enums/ElementTypes.js +10 -0
- package/dist/enums/ElementTypes.js.map +1 -0
- package/dist/helpers/PathResolver.d.ts +3 -0
- package/dist/helpers/PathResolver.js +26 -0
- package/dist/helpers/PathResolver.js.map +1 -0
- package/dist/helpers/index.d.ts +1 -0
- package/dist/helpers/index.js +1 -0
- package/dist/helpers/index.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/interfaces/IProperty.d.ts +4 -0
- package/dist/interfaces/IProperty.js +2 -0
- package/dist/interfaces/IProperty.js.map +1 -0
- package/dist/interfaces/IRegisteredSubjects.d.ts +5 -0
- package/dist/interfaces/IRegisteredSubjects.js +2 -0
- package/dist/interfaces/IRegisteredSubjects.js.map +1 -0
- package/dist/interfaces/ISubject.d.ts +8 -0
- package/dist/interfaces/ISubject.js +2 -0
- package/dist/interfaces/ISubject.js.map +1 -0
- package/dist/page-extensions/SubjectProvider.d.ts +11 -0
- package/dist/page-extensions/SubjectProvider.js +24 -0
- package/dist/page-extensions/SubjectProvider.js.map +1 -0
- package/dist/page-extensions/SubjectRegistry.d.ts +14 -0
- package/dist/page-extensions/SubjectRegistry.js +14 -0
- package/dist/page-extensions/SubjectRegistry.js.map +1 -0
- package/dist/page-extensions/index.d.ts +3 -0
- package/dist/page-extensions/index.js +3 -0
- package/dist/page-extensions/index.js.map +1 -1
- package/dist/services/ConfigBuilder.d.ts +1 -0
- package/dist/services/ConfigBuilder.js +20 -1
- package/dist/services/ConfigBuilder.js.map +1 -1
- package/dist/test-artifacts/SubjectPageBase.d.ts +5 -0
- package/dist/test-artifacts/SubjectPageBase.js +6 -0
- package/dist/test-artifacts/SubjectPageBase.js.map +1 -0
- package/dist/test-artifacts/index.d.ts +3 -0
- package/dist/test-artifacts/index.js +4 -0
- package/dist/test-artifacts/index.js.map +1 -0
- package/dist/test-artifacts/screens/index.d.ts +1 -0
- package/dist/test-artifacts/screens/index.js +2 -0
- package/dist/test-artifacts/screens/index.js.map +1 -0
- package/dist/test-artifacts/subjects/index.d.ts +1 -0
- package/dist/test-artifacts/subjects/index.js +2 -0
- package/dist/test-artifacts/subjects/index.js.map +1 -0
- package/dist/types/Components.d.ts +7 -0
- package/dist/types/Components.js +28 -0
- package/dist/types/Components.js.map +1 -0
- package/enums/ElementTypes.ts +8 -0
- package/helpers/PathResolver.ts +30 -0
- package/helpers/index.ts +1 -0
- package/index.ts +1 -0
- package/interfaces/IProperty.ts +4 -0
- package/interfaces/IRegisteredSubjects.ts +5 -0
- package/interfaces/ISubject.ts +9 -0
- package/package.json +26 -8
- package/page-extensions/SubjectProvider.ts +41 -0
- package/page-extensions/SubjectRegistry.ts +30 -0
- package/page-extensions/index.ts +3 -0
- package/promptCredentials.js +124 -124
- package/scripts/Testwise.template.json +4 -1
- package/scripts/main.js +84 -11
- package/scripts/postinstall.js +39 -0
- package/scripts/setup.js +37 -34
- package/scripts/sync.js +102 -0
- package/scripts/tsconfig.template.json +1 -1
- package/services/ConfigBuilder.ts +25 -2
- package/test-artifacts/SubjectPageBase.ts +9 -0
- package/test-artifacts/index.ts +3 -0
- package/test-artifacts/screens/index.ts +0 -0
- package/test-artifacts/subjects/index.ts +0 -0
- package/tsconfig.json +1 -1
- package/types/Components.ts +55 -0
- package/components/tab/ComponentTab.ts +0 -40
- package/components/tab/ComponentTabObjects.ts +0 -17
- package/components/tab/DetailTab.ts +0 -20
- package/dist/Testwise.json +0 -25
- package/dist/bdd.d.ts +0 -6
- package/dist/bdd.js +0 -9
- package/dist/bdd.js.map +0 -1
- package/dist/biome.json +0 -52
- package/dist/components/actionbar/Actionbar.js.map +0 -1
- package/dist/components/actionbar/ActionbarObjects.js.map +0 -1
- package/dist/components/actionbar/CustomActionBar.js +0 -7
- package/dist/components/actionbar/CustomActionBar.js.map +0 -1
- package/dist/components/tab/ComponentTab.d.ts +0 -12
- package/dist/components/tab/ComponentTab.js +0 -31
- package/dist/components/tab/ComponentTab.js.map +0 -1
- package/dist/components/tab/ComponentTabObjects.d.ts +0 -8
- package/dist/components/tab/ComponentTabObjects.js +0 -11
- package/dist/components/tab/ComponentTabObjects.js.map +0 -1
- package/dist/components/tab/DetailTab.d.ts +0 -9
- package/dist/components/tab/DetailTab.js +0 -15
- package/dist/components/tab/DetailTab.js.map +0 -1
- package/dist/components/tab/DetailTabObjects.js.map +0 -1
- package/dist/helpers/TestExtensions.d.ts +0 -8
- package/dist/helpers/TestExtensions.js +0 -21
- package/dist/helpers/TestExtensions.js.map +0 -1
- package/dist/package-lock.json +0 -3852
- package/dist/package.json +0 -59
- package/dist/scripts/Testwise.template.json +0 -25
- package/dist/scripts/tsconfig.template.json +0 -12
- package/dist/services/ReportingService.d.ts +0 -8
- package/dist/services/ReportingService.js +0 -29
- package/dist/services/ReportingService.js.map +0 -1
- package/dist/tsconfig.json +0 -20
- package/services/ReportingService.ts +0 -37
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
import * as path from 'node:path';
|
|
2
|
+
import { KnownElementTypes } from '../../enums/ElementTypes.js';
|
|
3
|
+
import type { ScreenComponents, SubjectComponents } from '../../types/Components.js';
|
|
4
|
+
|
|
5
|
+
export class NamingHandler {
|
|
6
|
+
public getDefaultElementSuffixFromComponentType(componentType: SubjectComponents): KnownElementTypes {
|
|
7
|
+
const controlTypeMapping: Record<SubjectComponents, KnownElementTypes> = {
|
|
8
|
+
Form: KnownElementTypes.Input,
|
|
9
|
+
Grid: KnownElementTypes.Column
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
return controlTypeMapping[componentType];
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
public getElementSuffixFromControlTypeAndComponentType(
|
|
16
|
+
controlType: string,
|
|
17
|
+
componentType: SubjectComponents
|
|
18
|
+
): string {
|
|
19
|
+
controlType = controlType.toLowerCase();
|
|
20
|
+
|
|
21
|
+
const formDefaultSuffix: KnownElementTypes = this.getDefaultElementSuffixFromComponentType('Form');
|
|
22
|
+
const gridDefaultSuffix: KnownElementTypes = this.getDefaultElementSuffixFromComponentType('Grid');
|
|
23
|
+
|
|
24
|
+
const controlTypeMappingMatrix: Record<SubjectComponents, Record<string, KnownElementTypes>> = {
|
|
25
|
+
Form: {
|
|
26
|
+
email: formDefaultSuffix,
|
|
27
|
+
phone_number: formDefaultSuffix,
|
|
28
|
+
suggestion_starts_with: formDefaultSuffix,
|
|
29
|
+
lookup_dropdown: KnownElementTypes.Lookup,
|
|
30
|
+
checkbox: KnownElementTypes.Checkbox,
|
|
31
|
+
multiline: KnownElementTypes.Textarea,
|
|
32
|
+
combo: KnownElementTypes.Dropdown
|
|
33
|
+
},
|
|
34
|
+
Grid: {
|
|
35
|
+
email: gridDefaultSuffix,
|
|
36
|
+
phone_number: gridDefaultSuffix,
|
|
37
|
+
suggestion_starts_with: gridDefaultSuffix,
|
|
38
|
+
lookup_dropdown: gridDefaultSuffix,
|
|
39
|
+
checkbox: gridDefaultSuffix,
|
|
40
|
+
multiline: gridDefaultSuffix,
|
|
41
|
+
combo: gridDefaultSuffix
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
const componentMapping = controlTypeMappingMatrix[componentType];
|
|
46
|
+
return (
|
|
47
|
+
componentMapping[controlType] || this.getDefaultElementSuffixFromComponentType(componentType)
|
|
48
|
+
).toLowerCase();
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
public getIdFromElementName(elementName: string): string {
|
|
52
|
+
return (
|
|
53
|
+
elementName
|
|
54
|
+
// Remove the suffix at the end
|
|
55
|
+
.replace(/([A-Z][a-z0-9]*)$/, '')
|
|
56
|
+
// Convert to kebab-case
|
|
57
|
+
.replace(/([a-z])([A-Z])/g, '$1-$2')
|
|
58
|
+
.toLowerCase()
|
|
59
|
+
// Replace underscores with hyphens
|
|
60
|
+
.replace(/_/g, '-')
|
|
61
|
+
);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
public getComponentTypeFromFileName(fileName: string): SubjectComponents {
|
|
65
|
+
// ToDo: use this
|
|
66
|
+
const match = fileName.match(/([A-Z][a-z]+)(?=\.ts$)/);
|
|
67
|
+
if (match) {
|
|
68
|
+
const componentName = match[1];
|
|
69
|
+
if (componentName === 'Form') return 'Form';
|
|
70
|
+
if (componentName === 'Grid') return 'Grid';
|
|
71
|
+
}
|
|
72
|
+
throw new Error(`Unknown component type in file name: ${fileName}`);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
public getElementTypeFromElementName(elementName: string): string {
|
|
76
|
+
// Get the suffix at the end of the element name
|
|
77
|
+
const match = elementName.match(/([A-Z][a-z0-9]*)$/);
|
|
78
|
+
|
|
79
|
+
// verify that match is a known element type
|
|
80
|
+
if (match) {
|
|
81
|
+
const elementType = match[1].toLowerCase();
|
|
82
|
+
if (Object.values(KnownElementTypes).includes(elementType as KnownElementTypes)) {
|
|
83
|
+
return elementType;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
throw new Error(`Could not extract element type from element name: ${elementName}`);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
public getSubjectFromFileName(fileName: string): string {
|
|
91
|
+
return fileName.replace(/([A-Z][a-z0-9]*)$/, '');
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
public getPascalSubjectComponentName(file: string): string {
|
|
95
|
+
let fileName = path.basename(file, '.json').replace(/_([a-z])/g, (g) => g[1].toUpperCase());
|
|
96
|
+
fileName = fileName.charAt(0).toUpperCase() + fileName.slice(1);
|
|
97
|
+
return fileName;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
public formatPascalCaseName(name: string): string {
|
|
101
|
+
if (!name.includes('_')) {
|
|
102
|
+
return name.charAt(0).toUpperCase() + name.slice(1);
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
return name
|
|
106
|
+
.toLowerCase()
|
|
107
|
+
.split('_')
|
|
108
|
+
.map((part) => part.charAt(0).toUpperCase() + part.slice(1))
|
|
109
|
+
.join('');
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
public formatSubjectName(subjectName: string): string {
|
|
113
|
+
subjectName.replace(/_([a-z])/g, (g: string) => g[1].toUpperCase());
|
|
114
|
+
return subjectName.charAt(0).toUpperCase() + subjectName.slice(1);
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
public formatPropertyName(name: string): string {
|
|
118
|
+
return name.charAt(0).toLowerCase() + name.slice(1);
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
public generateScreenInterfaceName(screentypeId: string): string {
|
|
122
|
+
return `I${screentypeId
|
|
123
|
+
.toLowerCase()
|
|
124
|
+
.split('_')
|
|
125
|
+
.map((part) => part.charAt(0).toUpperCase() + part.slice(1))
|
|
126
|
+
.join('')}`;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
public snakeToPascalCase(value: string): string {
|
|
130
|
+
if (!value.includes('_')) {
|
|
131
|
+
return value.charAt(0).toUpperCase() + value.slice(1);
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
return value
|
|
135
|
+
.toLowerCase()
|
|
136
|
+
.split('_')
|
|
137
|
+
.map((part) => part.charAt(0).toUpperCase() + part.slice(1))
|
|
138
|
+
.join('');
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
public getComponentIdFromName(componentName: string, componentType: ScreenComponents): string {
|
|
142
|
+
if (componentType === 'ActionBar' || componentType === 'CustomActionBar') {
|
|
143
|
+
const capitalizedComponentName = this.capitalizeFirstLetter(componentName);
|
|
144
|
+
return capitalizedComponentName.replace(/Toolbar/, 'Toolbar_');
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
if (componentType === 'Splitter') {
|
|
148
|
+
const componentId = componentName.toLowerCase();
|
|
149
|
+
|
|
150
|
+
if (/^splitter\d+$/.test(componentId)) {
|
|
151
|
+
return componentId;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
return componentId.replace(/splitter/, 'splitter-');
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
if (componentType === 'Tab') {
|
|
158
|
+
return this.capitalizeFirstLetter(componentName);
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
return componentName;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
public capitalizeFirstLetter(value: string): string {
|
|
165
|
+
return value.charAt(0).toUpperCase() + value.slice(1);
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
public getTabParentFromComponentName(componentName: string): string {
|
|
169
|
+
const match = componentName.match(/^[a-z0-9]+(?=[A-Z])/);
|
|
170
|
+
if (match) {
|
|
171
|
+
return match[0];
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
throw new Error(`Could not extract tab parent from component name: ${componentName}`);
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
public generateSubjectClassName(subject: { subject: string; screentype_context: string; variant: string }): string {
|
|
178
|
+
const uniqueSubjectIdentifier = subject.variant !== '' ? `${subject.subject}_${subject.variant}` : subject.subject;
|
|
179
|
+
const className = `${uniqueSubjectIdentifier}_${subject.screentype_context}`;
|
|
180
|
+
return this.formatPascalCaseName(className);
|
|
181
|
+
}
|
|
182
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { performance } from 'node:perf_hooks';
|
|
2
|
+
|
|
3
|
+
export class Stopwatch {
|
|
4
|
+
start(message: string) {
|
|
5
|
+
const startTime = performance.now();
|
|
6
|
+
return {
|
|
7
|
+
stop() {
|
|
8
|
+
const duration = ((performance.now() - startTime) / 1000).toFixed(3);
|
|
9
|
+
console.log(`[${duration}s]: ${message}`);
|
|
10
|
+
}
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export * from './ArtifactManager.js';
|
|
2
|
+
export * from './helpers/index.js';
|
|
3
|
+
export * from './InterfaceGenerator.js';
|
|
4
|
+
export * from './ModelDataRefiner.js';
|
|
5
|
+
export * from './SchemaGenerator.js';
|
|
6
|
+
export * from './ScreenInterfaceRefiner.js';
|
|
7
|
+
export * from './SubjectComponentGenerator.js';
|
|
8
|
+
export * from './SubjectGenerator.js';
|
|
9
|
+
export * from './SubjectRegistration.js';
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import type { Locator, Page } from '@playwright/test';
|
|
2
|
-
import {
|
|
2
|
+
import { ActionBarObjects, ActionBarOverflowableObjects } from './ActionBarObjects.js';
|
|
3
3
|
|
|
4
|
-
class
|
|
5
|
-
private _objects:
|
|
4
|
+
class ActionBarActions {
|
|
5
|
+
private _objects: ActionBarOverflowableObjects;
|
|
6
6
|
|
|
7
7
|
constructor(page: Page, context: Locator | null = null) {
|
|
8
|
-
this._objects = new
|
|
8
|
+
this._objects = new ActionBarOverflowableObjects(page, context);
|
|
9
9
|
}
|
|
10
10
|
|
|
11
11
|
public getSearchInput = (): Locator => this._objects.searchInput();
|
|
@@ -86,18 +86,18 @@ class ActionbarActions {
|
|
|
86
86
|
public getCubeViewButtonByLabel = (label: string): Locator => this._objects.cubeViewButtonByLabel(label);
|
|
87
87
|
}
|
|
88
88
|
|
|
89
|
-
export class
|
|
90
|
-
private
|
|
91
|
-
private _overflowMenu:
|
|
89
|
+
export class ActionBar extends ActionBarActions {
|
|
90
|
+
private _actionBarObjects: ActionBarObjects;
|
|
91
|
+
private _overflowMenu: ActionBarOverflow;
|
|
92
92
|
|
|
93
93
|
constructor(page: Page, actionbarContext: Locator | null = null) {
|
|
94
94
|
super(page, actionbarContext);
|
|
95
|
-
this.
|
|
96
|
-
this._overflowMenu = new
|
|
95
|
+
this._actionBarObjects = new ActionBarObjects(page, actionbarContext);
|
|
96
|
+
this._overflowMenu = new ActionBarOverflow(page);
|
|
97
97
|
}
|
|
98
98
|
|
|
99
99
|
public openOverflowMenu = async (): Promise<void> => {
|
|
100
|
-
await this.
|
|
100
|
+
await this._actionBarObjects.overflowMenuButton().click();
|
|
101
101
|
};
|
|
102
102
|
|
|
103
103
|
overflowMenu = {
|
|
@@ -146,13 +146,13 @@ export class Actionbar extends ActionbarActions {
|
|
|
146
146
|
};
|
|
147
147
|
}
|
|
148
148
|
|
|
149
|
-
export class
|
|
149
|
+
export class ActionBarOverflow extends ActionBarActions {
|
|
150
150
|
constructor(page: Page) {
|
|
151
151
|
super(page, page.getByTestId('actionbar__overflow-menu__context'));
|
|
152
152
|
}
|
|
153
153
|
}
|
|
154
154
|
|
|
155
|
-
function wrapWithOverflowOpen(actionBarInstance:
|
|
155
|
+
function wrapWithOverflowOpen(actionBarInstance: ActionBar, getLocatorFn: () => Locator): Locator {
|
|
156
156
|
const locator = getLocatorFn();
|
|
157
157
|
|
|
158
158
|
return new Proxy(locator, {
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import type { Locator, Page } from '@playwright/test';
|
|
2
2
|
import { BaseComponentObjects } from '../BaseComponentObjects.js';
|
|
3
3
|
|
|
4
|
-
export class
|
|
4
|
+
export class ActionBarOverflowableObjects extends BaseComponentObjects {
|
|
5
5
|
constructor(page: Page, context: Locator | null = null) {
|
|
6
6
|
super(page, context);
|
|
7
7
|
}
|
|
8
8
|
|
|
9
|
-
//
|
|
9
|
+
// ActionBar-near
|
|
10
10
|
public searchInput = () => this.context.getByTestId('actionbar__search__input').locator('input');
|
|
11
11
|
|
|
12
12
|
public prefilterButton = () =>
|
|
@@ -14,7 +14,7 @@ export class ActionbarOverflowableObjects extends BaseComponentObjects {
|
|
|
14
14
|
|
|
15
15
|
public filterButton = () => this.context.getByTestId('actionbar__filter');
|
|
16
16
|
|
|
17
|
-
//
|
|
17
|
+
// ActionBar-far (overflowable)
|
|
18
18
|
public addButton = () => this.context.getByTestId('actionbar__add');
|
|
19
19
|
|
|
20
20
|
public copyButton = () => this.context.getByTestId('actionbar__copy');
|
|
@@ -99,7 +99,7 @@ export class ActionbarOverflowableObjects extends BaseComponentObjects {
|
|
|
99
99
|
this.context.getByTestId(new RegExp(`^prefilter-actionbar-group-${id}$`));
|
|
100
100
|
}
|
|
101
101
|
|
|
102
|
-
export class
|
|
102
|
+
export class ActionBarObjects extends ActionBarOverflowableObjects {
|
|
103
103
|
constructor(page: Page, context: Locator | null = null) {
|
|
104
104
|
super(page, context);
|
|
105
105
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { Locator, Page } from '@playwright/test';
|
|
2
|
-
import {
|
|
2
|
+
import { ActionBar } from './ActionBar.js';
|
|
3
3
|
|
|
4
|
-
export class CustomActionBar extends
|
|
4
|
+
export class CustomActionBar extends ActionBar {
|
|
5
5
|
constructor(page: Page, context: Locator | null = null) {
|
|
6
6
|
super(page, context);
|
|
7
7
|
}
|
package/components/index.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export * from './
|
|
2
|
-
export * from './
|
|
1
|
+
export * from './action-bar/ActionBar.js';
|
|
2
|
+
export * from './action-bar/CustomActionBar.js';
|
|
3
3
|
export * from './cardlist/Cardlist.js';
|
|
4
4
|
export * from './chart/Chart.js';
|
|
5
5
|
export * from './combined-filter/CombinedFilter.js';
|
|
@@ -20,8 +20,7 @@ export * from './report-tiles/ReportTiles.js';
|
|
|
20
20
|
export * from './scheduler/Scheduler.js';
|
|
21
21
|
export * from './snackbar/SnackBar.js';
|
|
22
22
|
export * from './splitter/Splitter.js';
|
|
23
|
-
export * from './tab/
|
|
24
|
-
export * from './tab/DetailTab.js';
|
|
23
|
+
export * from './tab/DetailTabPage.js';
|
|
25
24
|
export * from './tab/Tab.js';
|
|
26
25
|
export * from './task/TaskBar.js';
|
|
27
26
|
export * from './task/TaskTiles.js';
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { Locator, Page } from '@playwright/test';
|
|
2
|
+
import { BaseTab } from './BaseTab.js';
|
|
3
|
+
import { DetailTabPageObjects } from './DetailTabPageObjects.js';
|
|
4
|
+
|
|
5
|
+
export class DetailTabPage extends BaseTab {
|
|
6
|
+
protected _objects: DetailTabPageObjects;
|
|
7
|
+
|
|
8
|
+
constructor(page: Page, context: Locator | null = null) {
|
|
9
|
+
super(page, context);
|
|
10
|
+
this._objects = new DetailTabPageObjects(page, context);
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
public async getDetailTabPageById(name: string): Promise<Locator> {
|
|
14
|
+
return this._objects.detailTab(name);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
public async getDetailTabPageByIndex(index: number): Promise<Locator> {
|
|
18
|
+
return this._objects.tabByIndex(index);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { Locator, Page } from '@playwright/test';
|
|
2
2
|
import { BaseTabObjects } from './BaseTabObjects.js';
|
|
3
3
|
|
|
4
|
-
export class
|
|
4
|
+
export class DetailTabPageObjects extends BaseTabObjects {
|
|
5
5
|
constructor(page: Page, context: Locator | null = null) {
|
|
6
6
|
super(page, context);
|
|
7
7
|
}
|
package/components/tab/Tab.ts
CHANGED
|
@@ -1,14 +1,40 @@
|
|
|
1
1
|
import type { Locator, Page } from '@playwright/test';
|
|
2
|
+
import { BaseTab } from './BaseTab.js';
|
|
2
3
|
import { TabObjects } from './TabObjects.js';
|
|
3
4
|
|
|
4
|
-
export class Tab {
|
|
5
|
-
|
|
5
|
+
export class Tab extends BaseTab {
|
|
6
|
+
protected _objects: TabObjects;
|
|
6
7
|
|
|
7
8
|
constructor(page: Page, context: Locator | null = null) {
|
|
8
|
-
|
|
9
|
+
super(page, context);
|
|
10
|
+
this._objects = new TabObjects(page, context);
|
|
9
11
|
}
|
|
10
12
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
+
// --- Component-specific helpers ---
|
|
14
|
+
|
|
15
|
+
// Opens the “List” tab in this tabstrip (default tabindex = -1 for master).
|
|
16
|
+
// If tabindex is left empty, the default is "-1" which is the master/base list tabindex
|
|
17
|
+
public async openListTab(tabindex: string = '-1'): Promise<void> {
|
|
18
|
+
await this._objects.listTab(tabindex).click();
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
// Returns the “List” tab locator (scoped).
|
|
22
|
+
public async getListTab(tabindex: string = '-1'): Promise<Locator> {
|
|
23
|
+
return this._objects.listTab(tabindex);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
// Opens the “Form” tab in this tabstrip (scoped).
|
|
27
|
+
public async openFormTab(): Promise<void> {
|
|
28
|
+
await this._objects.formTab().click();
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
// Returns the “Form” tab locator (scoped).
|
|
32
|
+
public async getFormTab(): Promise<Locator> {
|
|
33
|
+
return this._objects.formTab();
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
// Opens a component tab by its ID in this tabstrip (scoped).
|
|
37
|
+
public async openTabByID(tabid: string): Promise<void> {
|
|
38
|
+
await this._objects.tab(tabid).click();
|
|
13
39
|
}
|
|
14
40
|
}
|
|
@@ -1,5 +1,17 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { Locator, Page } from '@playwright/test';
|
|
2
|
+
import { BaseTabObjects } from './BaseTabObjects.js';
|
|
2
3
|
|
|
3
|
-
export class TabObjects extends
|
|
4
|
-
|
|
4
|
+
export class TabObjects extends BaseTabObjects {
|
|
5
|
+
constructor(page: Page, context: Locator | null = null) {
|
|
6
|
+
super(page, context);
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
// Component-specific selectors
|
|
10
|
+
public listTab = (tabindex: string): Locator =>
|
|
11
|
+
this.tabList().locator(`[role="tab"][data-testid^="tabstrip__tab__list"][tabindex="${tabindex}"]`);
|
|
12
|
+
|
|
13
|
+
public formTab = (): Locator => this.tabList().locator(`[role="tab"][data-testid^="tabstrip__tab__form"]`);
|
|
14
|
+
|
|
15
|
+
public tab = (tabid: string): Locator =>
|
|
16
|
+
this.tabList().locator(`[role="tab"][data-testid^="tabstrip__tab__${tabid}"]`);
|
|
5
17
|
}
|
package/dist/Testwise.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { test as base } from '@playwright/test';
|
|
2
2
|
import { test as bddBase } from 'playwright-bdd';
|
|
3
3
|
import { Components, GoToDeepLink, LoginFeatures, UserSimulation } from './page-extensions/index.js';
|
|
4
|
+
import { SubjectProvider } from './page-extensions/SubjectProvider.js';
|
|
5
|
+
import { SubjectRegistry } from './page-extensions/SubjectRegistry.js';
|
|
4
6
|
import { WaitEventHandler } from './page-extensions/WaitEventHandler.js';
|
|
5
7
|
import { ClickOverride } from './page-overrides/ClickOverride.js';
|
|
6
8
|
import { FillOverride } from './page-overrides/FillOverride.js';
|
|
@@ -16,7 +18,9 @@ const extensions = [
|
|
|
16
18
|
GoToDeepLink,
|
|
17
19
|
LoginFeatures,
|
|
18
20
|
UserSimulation,
|
|
19
|
-
WaitEventHandler
|
|
21
|
+
WaitEventHandler,
|
|
22
|
+
SubjectRegistry,
|
|
23
|
+
SubjectProvider
|
|
20
24
|
];
|
|
21
25
|
export const test = combineExtensions(base, ...extensions);
|
|
22
26
|
export const bddTest = combineExtensions(bddBase, ...extensions);
|
package/dist/Testwise.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Testwise.js","sourceRoot":"","sources":["../Testwise.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,IAAI,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAChD,OAAO,EAAE,IAAI,IAAI,OAAO,EAAE,MAAM,gBAAgB,CAAC;AACjD,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AACrG,OAAO,EAAE,gBAAgB,EAAE,MAAM,uCAAuC,CAAC;AACzE,OAAO,EAAE,aAAa,EAAE,MAAM,mCAAmC,CAAC;AAClE,OAAO,EAAE,YAAY,EAAE,MAAM,kCAAkC,CAAC;AAGhE,SAAS,iBAAiB,CAAC,QAAc,EAAE,GAAG,UAAkD;IAC9F,OAAO,UAAU,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,SAAS,EAAE,EAAE,CAAC,IAAI,SAAS,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;AACpF,CAAC;AAED,MAAM,UAAU,GAAG;IACjB,mBAAmB;IACnB,aAAa;IACb,YAAY;IAEZ,iBAAiB;IACjB,UAAU;IACV,YAAY;IACZ,aAAa;IACb,cAAc;IACd,gBAAgB;
|
|
1
|
+
{"version":3,"file":"Testwise.js","sourceRoot":"","sources":["../Testwise.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,IAAI,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAChD,OAAO,EAAE,IAAI,IAAI,OAAO,EAAE,MAAM,gBAAgB,CAAC;AACjD,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AACrG,OAAO,EAAE,eAAe,EAAE,MAAM,sCAAsC,CAAC;AACvE,OAAO,EAAE,eAAe,EAAE,MAAM,sCAAsC,CAAC;AACvE,OAAO,EAAE,gBAAgB,EAAE,MAAM,uCAAuC,CAAC;AACzE,OAAO,EAAE,aAAa,EAAE,MAAM,mCAAmC,CAAC;AAClE,OAAO,EAAE,YAAY,EAAE,MAAM,kCAAkC,CAAC;AAGhE,SAAS,iBAAiB,CAAC,QAAc,EAAE,GAAG,UAAkD;IAC9F,OAAO,UAAU,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,SAAS,EAAE,EAAE,CAAC,IAAI,SAAS,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;AACpF,CAAC;AAED,MAAM,UAAU,GAAG;IACjB,mBAAmB;IACnB,aAAa;IACb,YAAY;IAEZ,iBAAiB;IACjB,UAAU;IACV,YAAY;IACZ,aAAa;IACb,cAAc;IACd,gBAAgB;IAChB,eAAe;IACf,eAAe;CAChB,CAAC;AAEF,MAAM,CAAC,MAAM,IAAI,GAAS,iBAAiB,CAAC,IAAI,EAAE,GAAG,UAAU,CAAC,CAAC;AAEjE,MAAM,CAAC,MAAM,OAAO,GAAS,iBAAiB,CAAC,OAAO,EAAE,GAAG,UAAU,CAAC,CAAC"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import * as fs from 'node:fs';
|
|
2
|
+
import * as path from 'node:path';
|
|
3
|
+
import { fileURLToPath } from 'node:url';
|
|
4
|
+
export class ArtifactManager {
|
|
5
|
+
constructor() {
|
|
6
|
+
const _filename = fileURLToPath(import.meta.url);
|
|
7
|
+
const _dirname = path.dirname(_filename);
|
|
8
|
+
this._backupPath = path.resolve(_dirname, '..', '..', '..', 'backups', 'test-artifacts');
|
|
9
|
+
this._artifactPath = path.resolve(_dirname, '..', '..', 'test-artifacts');
|
|
10
|
+
}
|
|
11
|
+
performBackup() {
|
|
12
|
+
if (fs.existsSync(this._artifactPath)) {
|
|
13
|
+
fs.rmSync(this._backupPath, { recursive: true, force: true });
|
|
14
|
+
fs.cpSync(this._artifactPath, this._backupPath, { recursive: true });
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
backupExists() {
|
|
18
|
+
return fs.existsSync(this._backupPath);
|
|
19
|
+
}
|
|
20
|
+
restoreBackup() {
|
|
21
|
+
if (fs.existsSync(this._backupPath)) {
|
|
22
|
+
fs.rmSync(this._artifactPath, { recursive: true, force: true });
|
|
23
|
+
fs.cpSync(this._backupPath, this._artifactPath, { recursive: true });
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
//# sourceMappingURL=ArtifactManager.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ArtifactManager.js","sourceRoot":"","sources":["../../artifact-builder/ArtifactManager.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAC9B,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAClC,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAEzC,MAAM,OAAO,eAAe;IAI1B;QACE,MAAM,SAAS,GAAG,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QACjD,MAAM,QAAQ,GAAG,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;QACzC,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC,OAAO,CAAC,QAAQ,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,SAAS,EAAE,gBAAgB,CAAC,CAAC;QACzF,IAAI,CAAC,aAAa,GAAG,IAAI,CAAC,OAAO,CAAC,QAAQ,EAAE,IAAI,EAAE,IAAI,EAAE,gBAAgB,CAAC,CAAC;IAC5E,CAAC;IAED,aAAa;QACX,IAAI,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC,aAAa,CAAC,EAAE,CAAC;YACtC,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,WAAW,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;YAC9D,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,aAAa,EAAE,IAAI,CAAC,WAAW,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;QACvE,CAAC;IACH,CAAC;IAED,YAAY;QACV,OAAO,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;IACzC,CAAC;IAED,aAAa;QACX,IAAI,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC,WAAW,CAAC,EAAE,CAAC;YACpC,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,aAAa,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;YAChE,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,WAAW,EAAE,IAAI,CAAC,aAAa,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;QACvE,CAAC;IACH,CAAC;CACF"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export declare class InterfaceGenerator {
|
|
2
|
+
private readonly _namingHandler;
|
|
3
|
+
private _filename;
|
|
4
|
+
private _dirname;
|
|
5
|
+
constructor();
|
|
6
|
+
generateScreenInterfacesFromSchemas(): Promise<void>;
|
|
7
|
+
generateSubjectInterfacesFromSchemas(): Promise<void>;
|
|
8
|
+
private verifyGeneratedSubjectSchemasDirectory;
|
|
9
|
+
private verifyOutputDirectory;
|
|
10
|
+
private getGeneratedSubjectSchemas;
|
|
11
|
+
private verifySubjectComponentsDirectory;
|
|
12
|
+
private createInterfaceFromSchema;
|
|
13
|
+
private generateInterfacesFromSchemaFiles;
|
|
14
|
+
getScreenSchemaFilesPath(): string;
|
|
15
|
+
}
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import fs from 'node:fs';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
import { fileURLToPath } from 'node:url';
|
|
4
|
+
import * as prettier from 'prettier';
|
|
5
|
+
import { FetchingJSONSchemaStore, InputData, JSONSchemaInput, quicktype } from 'quicktype-core';
|
|
6
|
+
import { PathResolver } from '../helpers/PathResolver.js';
|
|
7
|
+
import { NamingHandler } from '../index.js';
|
|
8
|
+
export class InterfaceGenerator {
|
|
9
|
+
constructor() {
|
|
10
|
+
this._namingHandler = new NamingHandler();
|
|
11
|
+
this._filename = fileURLToPath(import.meta.url);
|
|
12
|
+
this._dirname = path.dirname(this._filename);
|
|
13
|
+
}
|
|
14
|
+
async generateScreenInterfacesFromSchemas() {
|
|
15
|
+
const screenOutputDirectory = path.resolve(this._dirname, '..', '..', 'test-artifacts/screens/');
|
|
16
|
+
this.verifyOutputDirectory(screenOutputDirectory);
|
|
17
|
+
const schemasDirectory = this.getScreenSchemaFilesPath();
|
|
18
|
+
await this.generateInterfacesFromSchemaFiles(schemasDirectory, SchemaType.Screen, screenOutputDirectory);
|
|
19
|
+
console.info('All screen schemas processed.');
|
|
20
|
+
}
|
|
21
|
+
async generateSubjectInterfacesFromSchemas() {
|
|
22
|
+
const schemasDirectory = path.resolve(this._dirname, '../test-artifacts/schemas');
|
|
23
|
+
const subjectOutputDirectory = path.resolve(this._dirname, '..', '..', 'test-artifacts/subjects');
|
|
24
|
+
this.verifyGeneratedSubjectSchemasDirectory(schemasDirectory);
|
|
25
|
+
this.verifyOutputDirectory(subjectOutputDirectory);
|
|
26
|
+
await this.generateInterfacesFromSchemaFiles(schemasDirectory, SchemaType.Subject, subjectOutputDirectory);
|
|
27
|
+
console.info('All subject schemas processed.');
|
|
28
|
+
}
|
|
29
|
+
verifyGeneratedSubjectSchemasDirectory(directory) {
|
|
30
|
+
if (!fs.existsSync(directory)) {
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
verifyOutputDirectory(directory) {
|
|
35
|
+
if (!fs.existsSync(directory)) {
|
|
36
|
+
fs.mkdirSync(directory, { recursive: true });
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
getGeneratedSubjectSchemas(schemasDirectory) {
|
|
40
|
+
return fs.readdirSync(schemasDirectory).filter((f) => f.endsWith('.json'));
|
|
41
|
+
}
|
|
42
|
+
verifySubjectComponentsDirectory(directory, subject) {
|
|
43
|
+
const componentsDirectory = path.join(directory, `${subject}/Components`);
|
|
44
|
+
if (!fs.existsSync(componentsDirectory)) {
|
|
45
|
+
fs.mkdirSync(componentsDirectory, { recursive: true });
|
|
46
|
+
}
|
|
47
|
+
return componentsDirectory;
|
|
48
|
+
}
|
|
49
|
+
async createInterfaceFromSchema(schemasDirectory, outputPath, file, isInterface = false) {
|
|
50
|
+
try {
|
|
51
|
+
const baseFileName = file.slice(0, file.lastIndexOf('.'));
|
|
52
|
+
const correctInterfaceName = isInterface
|
|
53
|
+
? this._namingHandler.generateScreenInterfaceName(baseFileName)
|
|
54
|
+
: this._namingHandler.snakeToPascalCase(baseFileName);
|
|
55
|
+
const schemaPath = path.join(schemasDirectory, file);
|
|
56
|
+
const schemaContent = fs.readFileSync(schemaPath, 'utf-8');
|
|
57
|
+
const schemaInput = new JSONSchemaInput(new FetchingJSONSchemaStore());
|
|
58
|
+
await schemaInput.addSource({
|
|
59
|
+
name: correctInterfaceName,
|
|
60
|
+
schema: schemaContent
|
|
61
|
+
});
|
|
62
|
+
const inputData = new InputData();
|
|
63
|
+
inputData.addInput(schemaInput);
|
|
64
|
+
const result = await quicktype({
|
|
65
|
+
inputData,
|
|
66
|
+
lang: 'typescript',
|
|
67
|
+
rendererOptions: { 'just-types': 'true', 'nice-property-names': 'true' }
|
|
68
|
+
});
|
|
69
|
+
let updatedContent = result.lines.join('\n');
|
|
70
|
+
updatedContent = updatedContent.replace(/interface\s+\w+/, `interface ${correctInterfaceName}`);
|
|
71
|
+
const formattedContent = await prettier.format(updatedContent, {
|
|
72
|
+
parser: 'typescript',
|
|
73
|
+
singleQuote: true,
|
|
74
|
+
semi: true,
|
|
75
|
+
trailingComma: 'all'
|
|
76
|
+
});
|
|
77
|
+
fs.writeFileSync(outputPath, formattedContent, 'utf-8');
|
|
78
|
+
return true;
|
|
79
|
+
}
|
|
80
|
+
catch (error) {
|
|
81
|
+
if (error instanceof Error) {
|
|
82
|
+
console.error(`Error processing ${file}:`, error.message);
|
|
83
|
+
}
|
|
84
|
+
else {
|
|
85
|
+
console.error(`Error processing ${file}:`, error);
|
|
86
|
+
}
|
|
87
|
+
throw error;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
async generateInterfacesFromSchemaFiles(schemasDirectory, schemaType, outputPath) {
|
|
91
|
+
const schemaFiles = this.getGeneratedSubjectSchemas(schemasDirectory);
|
|
92
|
+
const tasks = schemaFiles.map(async (file) => {
|
|
93
|
+
const fileName = this._namingHandler.getPascalSubjectComponentName(file);
|
|
94
|
+
if (schemaType === SchemaType.Subject) {
|
|
95
|
+
const subject = this._namingHandler.getSubjectFromFileName(fileName);
|
|
96
|
+
const componentsDirectory = this.verifySubjectComponentsDirectory(outputPath, subject);
|
|
97
|
+
const perFileOutputPath = path.join(componentsDirectory, `${fileName}.ts`);
|
|
98
|
+
return this.createInterfaceFromSchema(schemasDirectory, perFileOutputPath, file);
|
|
99
|
+
}
|
|
100
|
+
if (schemaType === SchemaType.Screen) {
|
|
101
|
+
const perFileOutputPath = path.join(outputPath, `I${fileName}.ts`);
|
|
102
|
+
return this.createInterfaceFromSchema(schemasDirectory, perFileOutputPath, file, true);
|
|
103
|
+
}
|
|
104
|
+
throw new Error(`Unsupported schema type: ${schemaType}`);
|
|
105
|
+
});
|
|
106
|
+
await Promise.all(tasks);
|
|
107
|
+
}
|
|
108
|
+
getScreenSchemaFilesPath() {
|
|
109
|
+
const directory = new PathResolver().getConsumerRootDirectory();
|
|
110
|
+
const screenSchemasPath = path.join(directory, 'seed-data/screen-schemas/');
|
|
111
|
+
if (!fs.existsSync(screenSchemasPath)) {
|
|
112
|
+
throw new Error(`Screen schemas directory not found at: ${screenSchemasPath}`);
|
|
113
|
+
}
|
|
114
|
+
return screenSchemasPath;
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
var SchemaType;
|
|
118
|
+
(function (SchemaType) {
|
|
119
|
+
SchemaType["Subject"] = "Subject";
|
|
120
|
+
SchemaType["Screen"] = "Screen";
|
|
121
|
+
})(SchemaType || (SchemaType = {}));
|
|
122
|
+
//# sourceMappingURL=InterfaceGenerator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"InterfaceGenerator.js","sourceRoot":"","sources":["../../artifact-builder/InterfaceGenerator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,KAAK,QAAQ,MAAM,UAAU,CAAC;AACrC,OAAO,EAAE,uBAAuB,EAAE,SAAS,EAAE,eAAe,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAChG,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAC1D,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAE5C,MAAM,OAAO,kBAAkB;IAK7B;QACE,IAAI,CAAC,cAAc,GAAG,IAAI,aAAa,EAAE,CAAC;QAC1C,IAAI,CAAC,SAAS,GAAG,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CA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