@adminide-stack/marketplace-module-server 12.0.4-alpha.121 ā 12.0.4-alpha.124
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.
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"installed-extension-service-ext.d.ts","sourceRoot":"","sources":["../../src/services/installed-extension-service-ext.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAE1C,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC7C,OAAO,EAgBH,yBAAyB,EACzB,6BAA6B,
|
|
1
|
+
{"version":3,"file":"installed-extension-service-ext.d.ts","sourceRoot":"","sources":["../../src/services/installed-extension-service-ext.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAE1C,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC7C,OAAO,EAgBH,yBAAyB,EACzB,6BAA6B,EAM7B,YAAY,EACf,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,yBAAyB,EAAE,MAAM,+BAA+B,CAAC;AA0D1E;;;GAGG;AACH,qBACa,4BAA6B,SAAQ,yBAAyB;IAKnE,SAAS,CAAC,WAAW,EAAE,YAAY;gBAHiB,UAAU,EAAE,6BAA6B,EAC7C,eAAe,EAAE,yBAAyB,EAEhF,WAAW,EAAE,YAAY,EACE,MAAM,EAAE,aAAa,EAC/B,MAAM,EAAE,SAAS,CAAC,OAAO;IAMxD,OAAO,CAAC,mBAAmB;CA4Z9B"}
|
|
@@ -1,4 +1,51 @@
|
|
|
1
|
-
import {__decorate,__param,__metadata}from'tslib';import {injectable,inject}from'inversify';import {ServiceBroker}from'moleculer';import {CommonType}from'@common-stack/core';import'@cdm-logger/core';import {SERVER_TYPES,ConfigurationSchemaId,
|
|
1
|
+
import {__decorate,__param,__metadata}from'tslib';import {injectable,inject}from'inversify';import {ServiceBroker}from'moleculer';import {CommonType}from'@common-stack/core';import'@cdm-logger/core';import {SERVER_TYPES,ConfigurationSchemaId,SystemContributionExtensionNames,ExtensionServiceAction,MoleculerServiceName}from'common/server';import {InstalledExtensionService}from'./installed-extension-service.js';/**
|
|
2
|
+
* Convert scope string values from package.json to ConfigurationScope enum numbers
|
|
3
|
+
* Maps: "application" -> 1, "machine" -> 2, "window" -> 3, "resource" -> 4
|
|
4
|
+
*/
|
|
5
|
+
function convertScopeStringToNumber(scope) {
|
|
6
|
+
if (typeof scope === 'number') {
|
|
7
|
+
return scope; // Already a number
|
|
8
|
+
}
|
|
9
|
+
if (typeof scope === 'string') {
|
|
10
|
+
const scopeMap = {
|
|
11
|
+
application: 1 /* ConfigurationScope.APPLICATION */,
|
|
12
|
+
machine: 2 /* ConfigurationScope.MACHINE */,
|
|
13
|
+
window: 3 /* ConfigurationScope.WINDOW */,
|
|
14
|
+
resource: 4 /* ConfigurationScope.RESOURCE */
|
|
15
|
+
};
|
|
16
|
+
const normalizedScope = scope.toLowerCase();
|
|
17
|
+
if (normalizedScope in scopeMap) {
|
|
18
|
+
return scopeMap[normalizedScope];
|
|
19
|
+
}
|
|
20
|
+
console.warn(`Unknown scope string: "${scope}", defaulting to WINDOW`);
|
|
21
|
+
}
|
|
22
|
+
// Default to WINDOW scope if undefined or unknown
|
|
23
|
+
return 3 /* ConfigurationScope.WINDOW */;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Recursively process configuration properties to convert scope strings to numbers
|
|
27
|
+
*/
|
|
28
|
+
function processConfigurationProperties(properties) {
|
|
29
|
+
if (!properties || typeof properties !== 'object') {
|
|
30
|
+
return properties;
|
|
31
|
+
}
|
|
32
|
+
const processedProperties = {
|
|
33
|
+
...properties
|
|
34
|
+
};
|
|
35
|
+
for (const [key, value] of Object.entries(processedProperties)) {
|
|
36
|
+
if (value && typeof value === 'object') {
|
|
37
|
+
const objectValue = value;
|
|
38
|
+
// If this property has a scope, convert it
|
|
39
|
+
if ('scope' in objectValue) {
|
|
40
|
+
objectValue.scope = convertScopeStringToNumber(objectValue.scope);
|
|
41
|
+
}
|
|
42
|
+
// Recursively process nested properties
|
|
43
|
+
processedProperties[key] = processConfigurationProperties(objectValue);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
return processedProperties;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
2
49
|
* Extended InstalledExtensionService that handles Moleculer event broadcasting
|
|
3
50
|
* Follows the pattern of AccountService/AccountServiceExt
|
|
4
51
|
*/
|
|
@@ -47,19 +94,17 @@ let InstalledExtensionServiceExt = class InstalledExtensionServiceExt extends In
|
|
|
47
94
|
console.log('Configuration contributions found, processing...');
|
|
48
95
|
const configurations = Array.isArray(contributes.configuration) ? contributes.configuration : [contributes.configuration];
|
|
49
96
|
// Format contributions for configuration registry
|
|
50
|
-
configurationNodes = configurations.map(config =>
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
}
|
|
62
|
-
}));
|
|
97
|
+
configurationNodes = configurations.map(config => {
|
|
98
|
+
// Process properties to convert scope strings to numbers
|
|
99
|
+
const processedProperties = processConfigurationProperties(config.properties || {});
|
|
100
|
+
return {
|
|
101
|
+
id: `${event.extensionSlug}`,
|
|
102
|
+
title: config.title || registryExtension.name,
|
|
103
|
+
description: config.description,
|
|
104
|
+
properties: processedProperties,
|
|
105
|
+
type: config.type || ['object']
|
|
106
|
+
};
|
|
107
|
+
});
|
|
63
108
|
// Create configuration defaults
|
|
64
109
|
configurationDefaults = [{
|
|
65
110
|
source: {
|
|
@@ -90,11 +135,10 @@ let InstalledExtensionServiceExt = class InstalledExtensionServiceExt extends In
|
|
|
90
135
|
default: true,
|
|
91
136
|
// Default to enabled when installed
|
|
92
137
|
description: `Enable/disable ${event.extensionSlug} extension`,
|
|
93
|
-
scope:
|
|
138
|
+
scope: 3 /* ConfigurationScope.WINDOW */
|
|
94
139
|
}
|
|
95
140
|
},
|
|
96
141
|
type: ['object'],
|
|
97
|
-
scope: 3 /* ConfigurationScope.WINDOW */,
|
|
98
142
|
extensionInfo: {
|
|
99
143
|
id: event.extensionSlug,
|
|
100
144
|
displayName: registryExtension?.name || event.extensionSlug
|
|
@@ -125,13 +169,8 @@ let InstalledExtensionServiceExt = class InstalledExtensionServiceExt extends In
|
|
|
125
169
|
},
|
|
126
170
|
context
|
|
127
171
|
});
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
context,
|
|
131
|
-
timestamp: new Date()
|
|
132
|
-
}, [MoleculerServiceName.ConfigurationRegistryService
|
|
133
|
-
// MoleculerServiceName.MailService, // Using MailService instead of NotificationService
|
|
134
|
-
]);
|
|
172
|
+
// STEP 1: MANDATORY - Register extension in system_extension FIRST (REQUIRED FOR ALL EXTENSIONS)
|
|
173
|
+
console.log('\nš§ STEP 1: Registering extension in SYSTEM_EXTENSION (MANDATORY)');
|
|
135
174
|
// Create separate configuration node for system extension status
|
|
136
175
|
const systemExtensionNode = {
|
|
137
176
|
schemaId: ConfigurationSchemaId.Configuration,
|
|
@@ -146,46 +185,139 @@ let InstalledExtensionServiceExt = class InstalledExtensionServiceExt extends In
|
|
|
146
185
|
extensionName: SystemContributionExtensionNames.SystemExtension,
|
|
147
186
|
accountId: event.installedBy
|
|
148
187
|
};
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
188
|
+
let systemExtensionRegistered = false;
|
|
189
|
+
try {
|
|
190
|
+
console.log('Broadcasting SYSTEM extension registry (MANDATORY)...');
|
|
191
|
+
await this.broker.call('ConfigurationRegistryService.createConfigurationNodeRegistry', {
|
|
192
|
+
data: systemExtensionNode,
|
|
193
|
+
context: systemContext
|
|
194
|
+
});
|
|
195
|
+
systemExtensionRegistered = true;
|
|
196
|
+
console.log('ā
STEP 1 SUCCESS: Extension registered in system_extension');
|
|
197
|
+
} catch (systemError) {
|
|
198
|
+
console.error('ā STEP 1 FAILED: System extension registration failed:', systemError);
|
|
199
|
+
throw new Error(`Extension installation failed: Could not register in system (${systemError.message})`);
|
|
200
|
+
}
|
|
201
|
+
// STEP 2: CONDITIONAL - Create extension configuration ONLY IF CONTRIBUTIONS EXIST
|
|
202
|
+
let extensionConfigCreated = false;
|
|
203
|
+
if (configurationNodes.length > 0) {
|
|
204
|
+
console.log('\nš STEP 2: Creating extension configuration (contributions exist)');
|
|
205
|
+
try {
|
|
206
|
+
console.log('Broadcasting extension configuration registry...');
|
|
207
|
+
await this.broker.call('ConfigurationRegistryService.createConfigurationNodeRegistry', {
|
|
208
|
+
data: configurationNode,
|
|
209
|
+
context
|
|
210
|
+
});
|
|
211
|
+
extensionConfigCreated = true;
|
|
212
|
+
console.log('ā
STEP 2 SUCCESS: Extension configuration created');
|
|
213
|
+
} catch (configError) {
|
|
214
|
+
console.error('ā STEP 2 FAILED: Extension configuration creation failed:', configError);
|
|
215
|
+
// This is not fatal since system extension is already registered
|
|
216
|
+
console.warn('ā ļø Extension is registered in system but configuration creation failed');
|
|
217
|
+
}
|
|
218
|
+
} else {
|
|
219
|
+
console.log('\nā¹ļø STEP 2: Skipping extension configuration (no contributions found)');
|
|
220
|
+
}
|
|
221
|
+
console.log('\n=== EXTENSION INSTALLATION COMPLETED ===');
|
|
222
|
+
console.log('System Extension Registered:', systemExtensionRegistered ? 'ā
' : 'ā');
|
|
223
|
+
console.log('Extension Config Created:', extensionConfigCreated ? 'ā
' : 'ā¹ļø Not needed');
|
|
224
|
+
console.log('Overall Installation:', systemExtensionRegistered ? 'ā
SUCCESS' : 'ā FAILED');
|
|
156
225
|
} catch (error) {
|
|
157
226
|
console.error('Error processing extension installed event:', error);
|
|
158
227
|
}
|
|
159
228
|
});
|
|
160
229
|
// Listen to extension uninstalled events
|
|
161
230
|
this.onExtensionUninstalled.event(async event => {
|
|
231
|
+
console.log('=== EXTENSION UNINSTALLATION STARTED ===');
|
|
232
|
+
console.log('Extension slug:', event.extensionSlug);
|
|
233
|
+
console.log('Tenant:', event.tenantId);
|
|
234
|
+
let uninstallationSuccessful = false;
|
|
235
|
+
let extensionConfigRemoved = false;
|
|
236
|
+
let systemExtensionUpdated = false;
|
|
162
237
|
try {
|
|
163
|
-
// Remove extension
|
|
238
|
+
// STEP 1: Remove the extension's own configuration registry entry (if it exists)
|
|
239
|
+
console.log('\nšļø STEP 1: Removing extension configuration registry');
|
|
164
240
|
const context = {
|
|
165
241
|
schemaId: ConfigurationSchemaId.Configuration,
|
|
166
242
|
tenantId: event.tenantId,
|
|
167
243
|
extensionName: event.extensionSlug,
|
|
168
244
|
accountId: event.uninstalledBy
|
|
169
245
|
};
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
246
|
+
try {
|
|
247
|
+
console.log('Removing extension configuration document...');
|
|
248
|
+
await this.broker.call('ConfigurationRegistryService.removeConfigurationNodeRegistry', {
|
|
249
|
+
context
|
|
250
|
+
});
|
|
251
|
+
extensionConfigRemoved = true;
|
|
252
|
+
console.log('ā
STEP 1 SUCCESS: Extension configuration removed');
|
|
253
|
+
} catch (configError) {
|
|
254
|
+
console.warn('ā ļø STEP 1 WARNING: Extension configuration removal failed (may not exist):', configError);
|
|
255
|
+
// This is not fatal - extension might not have had configuration
|
|
256
|
+
}
|
|
257
|
+
// STEP 2: MANDATORY - Remove extension node from system_extension document
|
|
258
|
+
console.log('\nš§ STEP 2: Unregistering extension from SYSTEM_EXTENSION (MANDATORY)');
|
|
259
|
+
try {
|
|
260
|
+
// First, get the current system_extension document
|
|
261
|
+
const systemContext = {
|
|
262
|
+
schemaId: ConfigurationSchemaId.Configuration,
|
|
263
|
+
tenantId: event.tenantId,
|
|
264
|
+
extensionName: SystemContributionExtensionNames.SystemExtension,
|
|
265
|
+
accountId: event.uninstalledBy
|
|
266
|
+
};
|
|
267
|
+
console.log('Fetching current system_extension document...');
|
|
268
|
+
const currentSystemDoc = await this.broker.call('ConfigurationRegistryService.getConfigurationNodeRegistry', {
|
|
269
|
+
context: systemContext
|
|
270
|
+
});
|
|
271
|
+
if (currentSystemDoc && currentSystemDoc.configurationNodes) {
|
|
272
|
+
const systemDoc = currentSystemDoc;
|
|
273
|
+
// Filter out the specific extension's status node
|
|
274
|
+
const configurationNodes = systemDoc.configurationNodes;
|
|
275
|
+
const updatedConfigurationNodes = configurationNodes.filter(node => node.id !== `${event.extensionSlug}.status`);
|
|
276
|
+
console.log('Removing extension status node:', `${event.extensionSlug}.status`);
|
|
277
|
+
console.log(`Original nodes: ${configurationNodes.length}, After removal: ${updatedConfigurationNodes.length}`);
|
|
278
|
+
// Update the system_extension document with the filtered nodes
|
|
279
|
+
const updatedSystemExtensionNode = {
|
|
280
|
+
schemaId: ConfigurationSchemaId.Configuration,
|
|
281
|
+
tenantId: event.tenantId,
|
|
282
|
+
extensionName: SystemContributionExtensionNames.SystemExtension,
|
|
283
|
+
policyConfigs: systemDoc.policyConfigs || null,
|
|
284
|
+
configurationNodes: updatedConfigurationNodes,
|
|
285
|
+
configurationDefaults: systemDoc.configurationDefaults || []
|
|
286
|
+
};
|
|
287
|
+
console.log('Updating system_extension document...');
|
|
288
|
+
await this.broker.call('ConfigurationRegistryService.updateConfigurationNodeRegistry', {
|
|
289
|
+
data: updatedSystemExtensionNode,
|
|
290
|
+
context: systemContext
|
|
291
|
+
});
|
|
292
|
+
systemExtensionUpdated = true;
|
|
293
|
+
console.log('ā
STEP 2 SUCCESS: Extension unregistered from system_extension');
|
|
294
|
+
} else {
|
|
295
|
+
console.warn('ā ļø STEP 2 WARNING: No system_extension document found or no configuration nodes');
|
|
296
|
+
systemExtensionUpdated = true; // Consider it successful if document doesn't exist
|
|
297
|
+
}
|
|
298
|
+
} catch (systemError) {
|
|
299
|
+
console.error('ā STEP 2 FAILED: System extension unregistration failed:', systemError);
|
|
300
|
+
throw new Error(`Extension uninstallation failed: Could not unregister from system (${systemError.message})`);
|
|
301
|
+
}
|
|
302
|
+
// Uninstallation is successful if system extension is updated
|
|
303
|
+
uninstallationSuccessful = systemExtensionUpdated;
|
|
304
|
+
console.log('\n=== EXTENSION UNINSTALLATION COMPLETED ===');
|
|
305
|
+
console.log('Extension Config Removed:', extensionConfigRemoved ? 'ā
' : 'ā¹ļø Not found');
|
|
306
|
+
console.log('System Extension Updated:', systemExtensionUpdated ? 'ā
' : 'ā');
|
|
307
|
+
console.log('Overall Uninstallation:', uninstallationSuccessful ? 'ā
SUCCESS' : 'ā FAILED');
|
|
186
308
|
} catch (error) {
|
|
187
|
-
console.error('
|
|
309
|
+
console.error('ā EXTENSION UNINSTALLATION FAILED:', error);
|
|
310
|
+
console.error('Error details:', {
|
|
311
|
+
message: error.message,
|
|
312
|
+
stack: error.stack,
|
|
313
|
+
extensionSlug: event.extensionSlug,
|
|
314
|
+
tenantId: event.tenantId,
|
|
315
|
+
extensionConfigRemoved,
|
|
316
|
+
systemExtensionUpdated
|
|
317
|
+
});
|
|
318
|
+
throw error; // Re-throw to ensure calling code knows uninstallation failed
|
|
188
319
|
}
|
|
320
|
+
// Notify other services about the uninstallation
|
|
189
321
|
this.broker.broadcast(ExtensionServiceAction.OnExtensionUninstalled, {
|
|
190
322
|
event
|
|
191
323
|
}, [MoleculerServiceName.ConfigurationService, 'WorkbenchService',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"installed-extension-service-ext.js","sources":["../../src/services/installed-extension-service-ext.ts"],"sourcesContent":[null],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"installed-extension-service-ext.js","sources":["../../src/services/installed-extension-service-ext.ts"],"sourcesContent":[null],"names":[],"mappings":"4ZA0FG;AACH;;AAG4D;AAWxD,SAAA,0BAA2B,CAAA,KAAA,EAAA;AA4Z9B,EAAA,IAAA,OAAA,KAAA,KAAA,QAAA,EAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@adminide-stack/marketplace-module-server",
|
|
3
|
-
"version": "12.0.4-alpha.
|
|
3
|
+
"version": "12.0.4-alpha.124",
|
|
4
4
|
"description": "Sample core for higher packages to depend on",
|
|
5
5
|
"license": "UNLICENSED",
|
|
6
6
|
"author": "CDMBase LLC",
|
|
@@ -21,11 +21,11 @@
|
|
|
21
21
|
"watch": "yarn build:lib:watch"
|
|
22
22
|
},
|
|
23
23
|
"dependencies": {
|
|
24
|
-
"@adminide-stack/extension-api": "12.0.4-alpha.
|
|
24
|
+
"@adminide-stack/extension-api": "12.0.4-alpha.124",
|
|
25
25
|
"nanoid": "^5.1.5"
|
|
26
26
|
},
|
|
27
27
|
"devDependencies": {
|
|
28
|
-
"common": "12.0.4-alpha.
|
|
28
|
+
"common": "12.0.4-alpha.124"
|
|
29
29
|
},
|
|
30
30
|
"peerDependencies": {
|
|
31
31
|
"graphql-tag": ">=2.0.0"
|
|
@@ -57,5 +57,5 @@
|
|
|
57
57
|
"typescript": {
|
|
58
58
|
"definition": "lib/index.d.ts"
|
|
59
59
|
},
|
|
60
|
-
"gitHead": "
|
|
60
|
+
"gitHead": "c5b43e0809575b93b7b16a462a7f4cc50e9aab18"
|
|
61
61
|
}
|