@unisphere/nx 4.9.0 → 4.10.1
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/migrations/4-10-1/add-get-workspace-to-get-service.d.ts +9 -0
- package/dist/migrations/4-10-1/add-get-workspace-to-get-service.d.ts.map +1 -0
- package/dist/migrations/4-10-1/add-get-workspace-to-get-service.js +54 -0
- package/dist/migrations/4-10-1/update-unisphere-visual-target.d.ts +10 -0
- package/dist/migrations/4-10-1/update-unisphere-visual-target.d.ts.map +1 -0
- package/dist/migrations/4-10-1/update-unisphere-visual-target.js +168 -0
- package/dist/migrations/4-10-1/wrap-tiny-data-store-initial-value.d.ts +9 -0
- package/dist/migrations/4-10-1/wrap-tiny-data-store-initial-value.d.ts.map +1 -0
- package/dist/migrations/4-10-1/wrap-tiny-data-store-initial-value.js +65 -0
- package/dist/migrations/4-11-0/migrate-analytics-types.d.ts +9 -0
- package/dist/migrations/4-11-0/migrate-analytics-types.d.ts.map +1 -0
- package/dist/migrations/4-11-0/migrate-analytics-types.js +102 -0
- package/migrations.json +55 -0
- package/package.json +1 -1
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Migration: Add getWorkspace() call before getService in runtime files
|
|
3
|
+
*
|
|
4
|
+
* Transforms this._options.getService to this._options.getWorkspace().getService
|
|
5
|
+
* in runtime project files.
|
|
6
|
+
*/
|
|
7
|
+
import { Tree } from '@nx/devkit';
|
|
8
|
+
export default function update(tree: Tree): Promise<void>;
|
|
9
|
+
//# sourceMappingURL=add-get-workspace-to-get-service.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"add-get-workspace-to-get-service.d.ts","sourceRoot":"","sources":["../../../src/migrations/4-10-1/add-get-workspace-to-get-service.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,IAAI,EAA6C,MAAM,YAAY,CAAC;AAE7E,wBAA8B,MAAM,CAAC,IAAI,EAAE,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CA0D9D"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Migration: Add getWorkspace() call before getService in runtime files
|
|
4
|
+
*
|
|
5
|
+
* Transforms this._options.getService to this._options.getWorkspace().getService
|
|
6
|
+
* in runtime project files.
|
|
7
|
+
*/
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.default = update;
|
|
10
|
+
const devkit_1 = require("@nx/devkit");
|
|
11
|
+
async function update(tree) {
|
|
12
|
+
devkit_1.logger.info('🔄 Adding getWorkspace() before getService calls in runtime projects...');
|
|
13
|
+
const runtimesDir = 'unisphere/runtimes';
|
|
14
|
+
if (!tree.exists(runtimesDir)) {
|
|
15
|
+
devkit_1.logger.info('ℹ️ No runtimes directory found');
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
let updatedCount = 0;
|
|
19
|
+
(0, devkit_1.visitNotIgnoredFiles)(tree, runtimesDir, (filePath) => {
|
|
20
|
+
if (!filePath.endsWith('.ts') && !filePath.endsWith('.tsx'))
|
|
21
|
+
return;
|
|
22
|
+
const content = tree.read(filePath, 'utf-8');
|
|
23
|
+
if (!content)
|
|
24
|
+
return;
|
|
25
|
+
if (!content.includes('_options') || !content.includes('getService'))
|
|
26
|
+
return;
|
|
27
|
+
// Match this._options followed by optional whitespace/newline/dot then .getService
|
|
28
|
+
// Handles: this._options.getService / this._options.\n .getService / this._options\n .getService
|
|
29
|
+
const pattern = /this\._options\.?\s*\.getService/g;
|
|
30
|
+
if (!pattern.test(content))
|
|
31
|
+
return;
|
|
32
|
+
// Already migrated check: if getWorkspace().getService exists, skip
|
|
33
|
+
if (content.includes('.getWorkspace().getService') || content.includes('.getWorkspace()\n')) {
|
|
34
|
+
// More precise check: see if all occurrences are already migrated
|
|
35
|
+
const unmigrated = content.replace(/this\._options\.getWorkspace\(\)\s*\.getService/g, '');
|
|
36
|
+
if (!/this\._options\.?\s*\.getService/.test(unmigrated)) {
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
const updatedContent = content.replace(/this\._options\.?\s*\.\s*getService/g, 'this._options.getWorkspace().getService');
|
|
41
|
+
if (updatedContent !== content) {
|
|
42
|
+
tree.write(filePath, updatedContent);
|
|
43
|
+
updatedCount++;
|
|
44
|
+
devkit_1.logger.info(` ✅ Updated ${filePath}`);
|
|
45
|
+
}
|
|
46
|
+
});
|
|
47
|
+
if (updatedCount === 0) {
|
|
48
|
+
devkit_1.logger.info('ℹ️ No runtime files needed getWorkspace() insertion before getService');
|
|
49
|
+
}
|
|
50
|
+
else {
|
|
51
|
+
await (0, devkit_1.formatFiles)(tree);
|
|
52
|
+
devkit_1.logger.info(`✅ Updated ${updatedCount} runtime file(s)`);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Migration: Update UnisphereVisualTarget usage
|
|
3
|
+
*
|
|
4
|
+
* 1. Renames `target` property to `type` in visual target object literals
|
|
5
|
+
* (where value is 'body' or 'element')
|
|
6
|
+
* 2. Converts string visual targets to { type: 'element', elementId: '<string>' }
|
|
7
|
+
*/
|
|
8
|
+
import { Tree } from '@nx/devkit';
|
|
9
|
+
export default function update(tree: Tree): Promise<void>;
|
|
10
|
+
//# sourceMappingURL=update-unisphere-visual-target.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"update-unisphere-visual-target.d.ts","sourceRoot":"","sources":["../../../src/migrations/4-10-1/update-unisphere-visual-target.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,IAAI,EAA6C,MAAM,YAAY,CAAC;AAS7E,wBAA8B,MAAM,CAAC,IAAI,EAAE,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAoF9D"}
|
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Migration: Update UnisphereVisualTarget usage
|
|
4
|
+
*
|
|
5
|
+
* 1. Renames `target` property to `type` in visual target object literals
|
|
6
|
+
* (where value is 'body' or 'element')
|
|
7
|
+
* 2. Converts string visual targets to { type: 'element', elementId: '<string>' }
|
|
8
|
+
*/
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
exports.default = update;
|
|
11
|
+
const devkit_1 = require("@nx/devkit");
|
|
12
|
+
const ts_morph_1 = require("ts-morph");
|
|
13
|
+
async function update(tree) {
|
|
14
|
+
devkit_1.logger.info('🔄 Updating UnisphereVisualTarget usage...');
|
|
15
|
+
const project = new ts_morph_1.Project({
|
|
16
|
+
manipulationSettings: { quoteKind: ts_morph_1.QuoteKind.Single },
|
|
17
|
+
});
|
|
18
|
+
let updatedCount = 0;
|
|
19
|
+
(0, devkit_1.visitNotIgnoredFiles)(tree, '.', (filePath) => {
|
|
20
|
+
if (!filePath.endsWith('.ts') && !filePath.endsWith('.tsx'))
|
|
21
|
+
return;
|
|
22
|
+
if (!filePath.includes('unisphere/'))
|
|
23
|
+
return;
|
|
24
|
+
const content = tree.read(filePath, 'utf-8');
|
|
25
|
+
if (!content)
|
|
26
|
+
return;
|
|
27
|
+
if (!content.includes('target'))
|
|
28
|
+
return;
|
|
29
|
+
const sourceFile = project.createSourceFile(filePath, content, {
|
|
30
|
+
overwrite: true,
|
|
31
|
+
});
|
|
32
|
+
let hasChanges = false;
|
|
33
|
+
// Pass 1: Rename target → type in object literals where value is 'body' or 'element'
|
|
34
|
+
// Only in visual target contexts (mountVisual args, visuals config, nested in target property)
|
|
35
|
+
const allPropertyAssignments = sourceFile.getDescendantsOfKind(ts_morph_1.SyntaxKind.PropertyAssignment);
|
|
36
|
+
for (const prop of allPropertyAssignments) {
|
|
37
|
+
if (prop.getName() !== 'target')
|
|
38
|
+
continue;
|
|
39
|
+
const initializer = prop.getInitializerIfKind(ts_morph_1.SyntaxKind.StringLiteral);
|
|
40
|
+
if (!initializer)
|
|
41
|
+
continue;
|
|
42
|
+
const value = initializer.getLiteralValue();
|
|
43
|
+
if (value !== 'body' && value !== 'element')
|
|
44
|
+
continue;
|
|
45
|
+
if (!isVisualTargetObjectContext(prop))
|
|
46
|
+
continue;
|
|
47
|
+
prop.getNameNode().replaceWithText('type');
|
|
48
|
+
hasChanges = true;
|
|
49
|
+
}
|
|
50
|
+
// Pass 2: Convert string targets to objects in mountVisual calls and visuals config
|
|
51
|
+
// Re-query after Pass 1 modifications
|
|
52
|
+
const propertyAssignments = sourceFile.getDescendantsOfKind(ts_morph_1.SyntaxKind.PropertyAssignment);
|
|
53
|
+
for (const prop of propertyAssignments) {
|
|
54
|
+
if (prop.getName() !== 'target')
|
|
55
|
+
continue;
|
|
56
|
+
const initializer = prop.getInitializerIfKind(ts_morph_1.SyntaxKind.StringLiteral);
|
|
57
|
+
if (!initializer)
|
|
58
|
+
continue;
|
|
59
|
+
const value = initializer.getLiteralValue();
|
|
60
|
+
// Skip 'body' and 'element' - those were handled in Pass 1
|
|
61
|
+
if (value === 'body' || value === 'element')
|
|
62
|
+
continue;
|
|
63
|
+
// Check if this is in a visual target context
|
|
64
|
+
if (!isVisualTargetContext(prop))
|
|
65
|
+
continue;
|
|
66
|
+
// Transform string to { type: 'element', elementId: '<string>' }
|
|
67
|
+
initializer.replaceWithText(`{ type: 'element', elementId: '${value}' }`);
|
|
68
|
+
hasChanges = true;
|
|
69
|
+
}
|
|
70
|
+
if (hasChanges) {
|
|
71
|
+
tree.write(filePath, sourceFile.getFullText());
|
|
72
|
+
updatedCount++;
|
|
73
|
+
devkit_1.logger.info(` ✅ Updated ${filePath}`);
|
|
74
|
+
}
|
|
75
|
+
});
|
|
76
|
+
if (updatedCount === 0) {
|
|
77
|
+
devkit_1.logger.info('ℹ️ No UnisphereVisualTarget usages needed transformation');
|
|
78
|
+
}
|
|
79
|
+
else {
|
|
80
|
+
await (0, devkit_1.formatFiles)(tree);
|
|
81
|
+
devkit_1.logger.info(`✅ Updated UnisphereVisualTarget usage in ${updatedCount} file(s)`);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Checks if a `target` property with value 'body'/'element' is inside a UnisphereVisualTarget object.
|
|
86
|
+
* The object itself (containing target: 'body') is the visual target value, so we check
|
|
87
|
+
* whether it's nested inside a `target` property of a parent, a mountVisual call, or visuals array.
|
|
88
|
+
*/
|
|
89
|
+
function isVisualTargetObjectContext(prop) {
|
|
90
|
+
const objLiteral = prop.getParent();
|
|
91
|
+
if (!ts_morph_1.Node.isObjectLiteralExpression(objLiteral))
|
|
92
|
+
return false;
|
|
93
|
+
const objParent = objLiteral.getParent();
|
|
94
|
+
// Context 1: Object is value of a `target` property in a parent object
|
|
95
|
+
// e.g., mountVisual({ target: { target: 'body' } }) — inner object is the visual target
|
|
96
|
+
if (ts_morph_1.Node.isPropertyAssignment(objParent) && objParent.getName() === 'target')
|
|
97
|
+
return true;
|
|
98
|
+
// Context 2: Object is inside a mountVisual() call directly
|
|
99
|
+
// e.g., mountVisual({ target: 'body' }) — less common but possible
|
|
100
|
+
if (ts_morph_1.Node.isCallExpression(objParent)) {
|
|
101
|
+
const expr = objParent.getExpression();
|
|
102
|
+
if (expr.getText().endsWith('mountVisual'))
|
|
103
|
+
return true;
|
|
104
|
+
}
|
|
105
|
+
// Context 3: Object is inside a visuals array item's target property
|
|
106
|
+
// e.g., visuals: [{ target: { target: 'body' } }]
|
|
107
|
+
if (ts_morph_1.Node.isPropertyAssignment(objParent) && objParent.getName() === 'target') {
|
|
108
|
+
const outerObj = objParent.getParent();
|
|
109
|
+
if (ts_morph_1.Node.isObjectLiteralExpression(outerObj)) {
|
|
110
|
+
const arrayParent = outerObj.getParent();
|
|
111
|
+
if (ts_morph_1.Node.isArrayLiteralExpression(arrayParent)) {
|
|
112
|
+
const arrayPropParent = arrayParent.getParent();
|
|
113
|
+
if (ts_morph_1.Node.isPropertyAssignment(arrayPropParent) &&
|
|
114
|
+
arrayPropParent.getName() === 'visuals')
|
|
115
|
+
return true;
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
// Context 4: Object has sibling properties that indicate it's a visual target
|
|
120
|
+
// (has elementId for 'element' type, or classNames/style for 'body' type)
|
|
121
|
+
if (objLiteral.getProperty('elementId'))
|
|
122
|
+
return true;
|
|
123
|
+
if (objLiteral.getProperty('classNames'))
|
|
124
|
+
return true;
|
|
125
|
+
if (objLiteral.getProperty('style'))
|
|
126
|
+
return true;
|
|
127
|
+
return false;
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* Checks if a `target` property with a string value is in a visual target context
|
|
131
|
+
* (the string IS the visual target value, needing conversion to object).
|
|
132
|
+
*/
|
|
133
|
+
function isVisualTargetContext(prop) {
|
|
134
|
+
const parent = prop.getParent();
|
|
135
|
+
if (!ts_morph_1.Node.isObjectLiteralExpression(parent))
|
|
136
|
+
return false;
|
|
137
|
+
// Context 1: Inside mountVisual() call argument
|
|
138
|
+
// e.g., super.mountVisual({ type: 'popup', target: 'someId', settings: {} })
|
|
139
|
+
const grandparent = parent.getParent();
|
|
140
|
+
if (ts_morph_1.Node.isCallExpression(grandparent)) {
|
|
141
|
+
const expr = grandparent.getExpression();
|
|
142
|
+
if (expr.getText().endsWith('mountVisual'))
|
|
143
|
+
return true;
|
|
144
|
+
}
|
|
145
|
+
// Context 2: Inside a visuals array item
|
|
146
|
+
// e.g., visuals: [{ target: 'someId', ... }]
|
|
147
|
+
if (ts_morph_1.Node.isArrayLiteralExpression(grandparent)) {
|
|
148
|
+
const arrayParent = grandparent.getParent();
|
|
149
|
+
if (ts_morph_1.Node.isPropertyAssignment(arrayParent)) {
|
|
150
|
+
if (arrayParent.getName() === 'visuals')
|
|
151
|
+
return true;
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
// Context 3: Parent object has siblings suggesting visual config
|
|
155
|
+
// (has 'type' property with value like 'popup', 'inline', etc.)
|
|
156
|
+
const typeProp = parent.getProperty('type');
|
|
157
|
+
if (typeProp && ts_morph_1.Node.isPropertyAssignment(typeProp)) {
|
|
158
|
+
const typeInit = typeProp.getInitializerIfKind(ts_morph_1.SyntaxKind.StringLiteral);
|
|
159
|
+
if (typeInit) {
|
|
160
|
+
const typeValue = typeInit.getLiteralValue();
|
|
161
|
+
if (typeValue === 'popup' ||
|
|
162
|
+
typeValue === 'inline' ||
|
|
163
|
+
typeValue === 'drawer')
|
|
164
|
+
return true;
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
return false;
|
|
168
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Migration: Wrap TinyDataStore/TinyStorage constructor arguments in initialValue
|
|
3
|
+
*
|
|
4
|
+
* Transforms constructor calls to wrap the argument in an { initialValue: ... } object.
|
|
5
|
+
* Skips instances that already have an initialValue property.
|
|
6
|
+
*/
|
|
7
|
+
import { Tree } from '@nx/devkit';
|
|
8
|
+
export default function update(tree: Tree): Promise<void>;
|
|
9
|
+
//# sourceMappingURL=wrap-tiny-data-store-initial-value.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wrap-tiny-data-store-initial-value.d.ts","sourceRoot":"","sources":["../../../src/migrations/4-10-1/wrap-tiny-data-store-initial-value.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,IAAI,EAA6C,MAAM,YAAY,CAAC;AAK7E,wBAA8B,MAAM,CAAC,IAAI,EAAE,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAmE9D"}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Migration: Wrap TinyDataStore/TinyStorage constructor arguments in initialValue
|
|
4
|
+
*
|
|
5
|
+
* Transforms constructor calls to wrap the argument in an { initialValue: ... } object.
|
|
6
|
+
* Skips instances that already have an initialValue property.
|
|
7
|
+
*/
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.default = update;
|
|
10
|
+
const devkit_1 = require("@nx/devkit");
|
|
11
|
+
const ts_morph_1 = require("ts-morph");
|
|
12
|
+
const TARGET_CLASSES = ['TinyDataStore', 'TinyStorage'];
|
|
13
|
+
async function update(tree) {
|
|
14
|
+
devkit_1.logger.info('🔄 Wrapping TinyDataStore/TinyStorage constructor arguments in initialValue...');
|
|
15
|
+
const project = new ts_morph_1.Project({
|
|
16
|
+
manipulationSettings: { quoteKind: ts_morph_1.QuoteKind.Single },
|
|
17
|
+
});
|
|
18
|
+
let updatedCount = 0;
|
|
19
|
+
(0, devkit_1.visitNotIgnoredFiles)(tree, '.', (filePath) => {
|
|
20
|
+
if (!filePath.endsWith('.ts') && !filePath.endsWith('.tsx'))
|
|
21
|
+
return;
|
|
22
|
+
if (!filePath.includes('unisphere/'))
|
|
23
|
+
return;
|
|
24
|
+
const content = tree.read(filePath, 'utf-8');
|
|
25
|
+
if (!content)
|
|
26
|
+
return;
|
|
27
|
+
if (!TARGET_CLASSES.some((cls) => content.includes(cls)))
|
|
28
|
+
return;
|
|
29
|
+
const sourceFile = project.createSourceFile(filePath, content, {
|
|
30
|
+
overwrite: true,
|
|
31
|
+
});
|
|
32
|
+
let hasChanges = false;
|
|
33
|
+
const newExpressions = sourceFile.getDescendantsOfKind(ts_morph_1.SyntaxKind.NewExpression);
|
|
34
|
+
for (const expr of newExpressions) {
|
|
35
|
+
const exprText = expr.getExpression().getText();
|
|
36
|
+
if (!TARGET_CLASSES.includes(exprText))
|
|
37
|
+
continue;
|
|
38
|
+
const args = expr.getArguments();
|
|
39
|
+
if (args.length !== 1)
|
|
40
|
+
continue;
|
|
41
|
+
const arg = args[0];
|
|
42
|
+
// Skip if argument already has an initialValue property
|
|
43
|
+
if (arg.getKind() === ts_morph_1.SyntaxKind.ObjectLiteralExpression) {
|
|
44
|
+
const objLiteral = arg.asKind(ts_morph_1.SyntaxKind.ObjectLiteralExpression);
|
|
45
|
+
if (objLiteral?.getProperty('initialValue'))
|
|
46
|
+
continue;
|
|
47
|
+
}
|
|
48
|
+
const argText = arg.getText();
|
|
49
|
+
arg.replaceWithText(`{\n initialValue: ${argText},\n }`);
|
|
50
|
+
hasChanges = true;
|
|
51
|
+
}
|
|
52
|
+
if (hasChanges) {
|
|
53
|
+
tree.write(filePath, sourceFile.getFullText());
|
|
54
|
+
updatedCount++;
|
|
55
|
+
devkit_1.logger.info(` ✅ Updated ${filePath}`);
|
|
56
|
+
}
|
|
57
|
+
});
|
|
58
|
+
if (updatedCount === 0) {
|
|
59
|
+
devkit_1.logger.info('ℹ️ No TinyDataStore/TinyStorage instances needed transformation');
|
|
60
|
+
}
|
|
61
|
+
else {
|
|
62
|
+
await (0, devkit_1.formatFiles)(tree);
|
|
63
|
+
devkit_1.logger.info(`✅ Wrapped constructor arguments in initialValue for ${updatedCount} file(s)`);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Migration: Migrate Kava analytics types to Application Events bucket types
|
|
3
|
+
*
|
|
4
|
+
* Renames enums/types and adds the required `bucket: AnalyticsBucket.ApplicationEvents`
|
|
5
|
+
* field to all report() calls.
|
|
6
|
+
*/
|
|
7
|
+
import { Tree } from '@nx/devkit';
|
|
8
|
+
export default function update(tree: Tree): Promise<void>;
|
|
9
|
+
//# sourceMappingURL=migrate-analytics-types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"migrate-analytics-types.d.ts","sourceRoot":"","sources":["../../../src/migrations/4-11-0/migrate-analytics-types.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,IAAI,EAA6C,MAAM,YAAY,CAAC;AAa7E,wBAA8B,MAAM,CAAC,IAAI,EAAE,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CA2G9D"}
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Migration: Migrate Kava analytics types to Application Events bucket types
|
|
4
|
+
*
|
|
5
|
+
* Renames enums/types and adds the required `bucket: AnalyticsBucket.ApplicationEvents`
|
|
6
|
+
* field to all report() calls.
|
|
7
|
+
*/
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.default = update;
|
|
10
|
+
const devkit_1 = require("@nx/devkit");
|
|
11
|
+
const ts_morph_1 = require("ts-morph");
|
|
12
|
+
const RENAMES = {
|
|
13
|
+
KavaEventTypes: 'ApplicationEventTypes',
|
|
14
|
+
KavaButtonsTypes: 'ApplicationButtonTypes',
|
|
15
|
+
KavaPageTypes: 'ApplicationPageTypes',
|
|
16
|
+
KavaBaseTypePayload: 'ApplicationEventsBasePayload',
|
|
17
|
+
KavaButtonTypePayload: 'ApplicationButtonPayload',
|
|
18
|
+
KavaPageTypePayload: 'ApplicationPagePayload',
|
|
19
|
+
KavaRequestPayloadByType: 'AnalyticsPayloadByBucket',
|
|
20
|
+
};
|
|
21
|
+
async function update(tree) {
|
|
22
|
+
devkit_1.logger.info('🔄 Migrating Kava analytics types to Application Events bucket types...');
|
|
23
|
+
const runtimesDir = 'unisphere/runtimes';
|
|
24
|
+
if (!tree.exists(runtimesDir)) {
|
|
25
|
+
devkit_1.logger.info('ℹ️ No runtimes directory found');
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
const project = new ts_morph_1.Project({
|
|
29
|
+
manipulationSettings: { quoteKind: ts_morph_1.QuoteKind.Single },
|
|
30
|
+
});
|
|
31
|
+
let updatedCount = 0;
|
|
32
|
+
(0, devkit_1.visitNotIgnoredFiles)(tree, runtimesDir, (filePath) => {
|
|
33
|
+
if (!filePath.endsWith('.ts') && !filePath.endsWith('.tsx'))
|
|
34
|
+
return;
|
|
35
|
+
const content = tree.read(filePath, 'utf-8');
|
|
36
|
+
if (!content)
|
|
37
|
+
return;
|
|
38
|
+
const hasOldTypes = Object.keys(RENAMES).some((old) => content.includes(old));
|
|
39
|
+
if (!hasOldTypes)
|
|
40
|
+
return;
|
|
41
|
+
const sourceFile = project.createSourceFile(filePath, content, {
|
|
42
|
+
overwrite: true,
|
|
43
|
+
});
|
|
44
|
+
let hasChanges = false;
|
|
45
|
+
// Step 1: Add `bucket: AnalyticsBucket.ApplicationEvents` to any object literal
|
|
46
|
+
// containing an `eventType: KavaEventTypes.*` property (covers direct .report() calls
|
|
47
|
+
// and indirect patterns like wrapper functions).
|
|
48
|
+
const objectLiterals = sourceFile.getDescendantsOfKind(ts_morph_1.SyntaxKind.ObjectLiteralExpression);
|
|
49
|
+
for (const objLiteral of objectLiterals) {
|
|
50
|
+
if (objLiteral.getProperty('bucket'))
|
|
51
|
+
continue;
|
|
52
|
+
const eventTypeProp = objLiteral.getProperty('eventType');
|
|
53
|
+
if (!eventTypeProp)
|
|
54
|
+
continue;
|
|
55
|
+
const eventTypeText = eventTypeProp.getText();
|
|
56
|
+
if (!eventTypeText.includes('KavaEventTypes.') &&
|
|
57
|
+
!eventTypeText.includes('ApplicationEventTypes.'))
|
|
58
|
+
continue;
|
|
59
|
+
objLiteral.insertPropertyAssignment(0, {
|
|
60
|
+
name: 'bucket',
|
|
61
|
+
initializer: 'AnalyticsBucket.ApplicationEvents',
|
|
62
|
+
});
|
|
63
|
+
hasChanges = true;
|
|
64
|
+
}
|
|
65
|
+
// Step 2: Rename all old type/enum references
|
|
66
|
+
let updatedText = sourceFile.getFullText();
|
|
67
|
+
for (const [oldName, newName] of Object.entries(RENAMES)) {
|
|
68
|
+
const regex = new RegExp(`\\b${oldName}\\b`, 'g');
|
|
69
|
+
if (regex.test(updatedText)) {
|
|
70
|
+
updatedText = updatedText.replace(regex, newName);
|
|
71
|
+
hasChanges = true;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
// Step 3: Add AnalyticsBucket to imports from @unisphere/runtime
|
|
75
|
+
if (hasChanges) {
|
|
76
|
+
if (updatedText.includes('AnalyticsBucket') &&
|
|
77
|
+
!updatedText.match(/import\s*\{[^}]*AnalyticsBucket[^}]*\}\s*from\s*['"]@unisphere\/runtime['"]/)) {
|
|
78
|
+
updatedText = updatedText.replace(/(import\s*\{)([^}]*)(}\s*from\s*['"]@unisphere\/runtime['"])/, (_match, start, imports, end) => {
|
|
79
|
+
const importList = imports
|
|
80
|
+
.split(',')
|
|
81
|
+
.map((s) => s.trim())
|
|
82
|
+
.filter(Boolean);
|
|
83
|
+
if (!importList.includes('AnalyticsBucket')) {
|
|
84
|
+
importList.push('AnalyticsBucket');
|
|
85
|
+
importList.sort();
|
|
86
|
+
}
|
|
87
|
+
return `${start}\n ${importList.join(',\n ')},\n${end}`;
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
tree.write(filePath, updatedText);
|
|
91
|
+
updatedCount++;
|
|
92
|
+
devkit_1.logger.info(` ✅ Updated ${filePath}`);
|
|
93
|
+
}
|
|
94
|
+
});
|
|
95
|
+
if (updatedCount === 0) {
|
|
96
|
+
devkit_1.logger.info('ℹ️ No files needed analytics type migration');
|
|
97
|
+
}
|
|
98
|
+
else {
|
|
99
|
+
await (0, devkit_1.formatFiles)(tree);
|
|
100
|
+
devkit_1.logger.info(`✅ Migrated analytics types in ${updatedCount} file(s)`);
|
|
101
|
+
}
|
|
102
|
+
}
|
package/migrations.json
CHANGED
|
@@ -458,6 +458,38 @@
|
|
|
458
458
|
"cli": {
|
|
459
459
|
"postUpdateMessage": "✅ Security Audit step restored in cicd.yml"
|
|
460
460
|
}
|
|
461
|
+
},
|
|
462
|
+
"4-10-1-wrap-tiny-data-store-initial-value": {
|
|
463
|
+
"version": "4.10.1",
|
|
464
|
+
"description": "Wraps TinyDataStore/TinyStorage constructor arguments in initialValue property",
|
|
465
|
+
"factory": "./dist/migrations/4-10-1/wrap-tiny-data-store-initial-value.js",
|
|
466
|
+
"cli": {
|
|
467
|
+
"postUpdateMessage": "✅ TinyDataStore/TinyStorage constructor arguments wrapped in initialValue"
|
|
468
|
+
}
|
|
469
|
+
},
|
|
470
|
+
"4-10-1-add-get-workspace-to-get-service": {
|
|
471
|
+
"version": "4.10.1",
|
|
472
|
+
"description": "Adds getWorkspace() call before getService in runtime files",
|
|
473
|
+
"factory": "./dist/migrations/4-10-1/add-get-workspace-to-get-service.js",
|
|
474
|
+
"cli": {
|
|
475
|
+
"postUpdateMessage": "✅ Runtime files updated: this._options.getService → this._options.getWorkspace().getService"
|
|
476
|
+
}
|
|
477
|
+
},
|
|
478
|
+
"4-10-1-update-unisphere-visual-target": {
|
|
479
|
+
"version": "4.10.1",
|
|
480
|
+
"description": "Updates UnisphereVisualTarget usage: renames target→type, converts string targets to objects",
|
|
481
|
+
"factory": "./dist/migrations/4-10-1/update-unisphere-visual-target.js",
|
|
482
|
+
"cli": {
|
|
483
|
+
"postUpdateMessage": "✅ UnisphereVisualTarget usage updated (target→type, string→object)"
|
|
484
|
+
}
|
|
485
|
+
},
|
|
486
|
+
"4-11-0-migrate-analytics-types": {
|
|
487
|
+
"version": "4.11.0",
|
|
488
|
+
"description": "Migrates Kava analytics types to Application Events bucket types (KavaEventTypes→ApplicationEventTypes, KavaButtonsTypes→ApplicationButtonTypes, adds bucket field)",
|
|
489
|
+
"factory": "./dist/migrations/4-11-0/migrate-analytics-types.js",
|
|
490
|
+
"cli": {
|
|
491
|
+
"postUpdateMessage": "✅ Analytics types migrated to Application Events bucket pattern"
|
|
492
|
+
}
|
|
461
493
|
}
|
|
462
494
|
},
|
|
463
495
|
"packageJsonUpdates": {
|
|
@@ -791,6 +823,29 @@
|
|
|
791
823
|
"alwaysAddToPackageJson": false
|
|
792
824
|
}
|
|
793
825
|
}
|
|
826
|
+
},
|
|
827
|
+
"4.10.1": {
|
|
828
|
+
"version": "4.10.1",
|
|
829
|
+
"cli": "nx",
|
|
830
|
+
"postUpdateMessage": "🎉 Migration to @unisphere/nx 4.10.1 completed successfully!",
|
|
831
|
+
"packages": {
|
|
832
|
+
"@unisphere/core": {
|
|
833
|
+
"version": "^1.97.1",
|
|
834
|
+
"alwaysAddToPackageJson": false
|
|
835
|
+
},
|
|
836
|
+
"@unisphere/runtime": {
|
|
837
|
+
"version": "^1.97.0",
|
|
838
|
+
"alwaysAddToPackageJson": false
|
|
839
|
+
},
|
|
840
|
+
"@unisphere/runtime-js": {
|
|
841
|
+
"version": "^1.93.0",
|
|
842
|
+
"alwaysAddToPackageJson": false
|
|
843
|
+
},
|
|
844
|
+
"@unisphere/runtime-react": {
|
|
845
|
+
"version": "^1.87.0",
|
|
846
|
+
"alwaysAddToPackageJson": false
|
|
847
|
+
}
|
|
848
|
+
}
|
|
794
849
|
}
|
|
795
850
|
}
|
|
796
851
|
}
|