@adminide-stack/core 12.0.4-alpha.92 → 13.0.1-alpha.0
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/lib/constants/configuration.d.ts +4 -0
- package/lib/constants/configuration.js +5 -1
- package/lib/constants/configuration.js.map +1 -1
- package/lib/constants/defaultIds.d.ts +10 -0
- package/lib/constants/defaultIds.js +14 -0
- package/lib/constants/defaultIds.js.map +1 -0
- package/lib/constants/index.d.ts +1 -0
- package/lib/constants/routes.js.map +1 -1
- package/lib/constants/urls.d.ts +3 -1
- package/lib/constants/urls.js +2 -0
- package/lib/constants/urls.js.map +1 -1
- package/lib/core/BaseDisposable.d.ts +91 -0
- package/lib/core/BaseDisposable.js +97 -0
- package/lib/core/BaseDisposable.js.map +1 -0
- package/lib/core/configurations/configuration.js.map +1 -1
- package/lib/core/configurations/events/ConfigurationChangeEvent.js.map +1 -1
- package/lib/core/configurations/examples/configuration-wrapper-example.d.ts +67 -0
- package/lib/core/configurations/examples/configuration-wrapper.test.d.ts +1 -0
- package/lib/core/configurations/helpers/configuration.js.map +1 -1
- package/lib/core/configurations/index.d.ts +2 -0
- package/lib/core/configurations/models/ConfigurationModel.d.ts +26 -1
- package/lib/core/configurations/models/ConfigurationModel.js +123 -8
- package/lib/core/configurations/models/ConfigurationModel.js.map +1 -1
- package/lib/core/configurations/models/ConfigurationModel.multi-identifier.test.d.ts +1 -0
- package/lib/core/configurations/models/ConfigurationModelWrapper.d.ts +47 -0
- package/lib/core/configurations/models/ConfigurationModelWrapper.js +130 -0
- package/lib/core/configurations/models/ConfigurationModelWrapper.js.map +1 -0
- package/lib/core/configurations/models/ConfigurationModelWrapper.spec.d.ts +1 -0
- package/lib/core/configurations/models/ConfigurationModelWrapper.test.d.ts +1 -0
- package/lib/core/configurations/models/index.d.ts +1 -0
- package/lib/core/configurations/models/override.compound.test.d.ts +1 -0
- package/lib/core/configurations/models/override.edgecase.test.d.ts +1 -0
- package/lib/core/configurations/models/override.keys.test.d.ts +1 -0
- package/lib/core/configurations/models/override.strict.test.d.ts +1 -0
- package/lib/core/configurations/parser/configurationParser.d.ts +23 -0
- package/lib/core/configurations/parser/configurationParser.js +209 -0
- package/lib/core/configurations/parser/configurationParser.js.map +1 -0
- package/lib/core/configurations/parser/index.d.ts +1 -0
- package/lib/core/configurations/utils/QUICK_REFERENCE.d.ts +103 -0
- package/lib/core/configurations/utils/configurationExtractor.d.ts +224 -0
- package/lib/core/configurations/utils/configurationExtractor.js +315 -0
- package/lib/core/configurations/utils/configurationExtractor.js.map +1 -0
- package/lib/core/configurations/utils/configurationExtractor.test.d.ts +1 -0
- package/lib/core/configurations/utils/index.d.ts +5 -0
- package/lib/core/configurations/utils/model-creation-examples.d.ts +36 -0
- package/lib/core/configurations/utils/preferences-service-integration.d.ts +54 -0
- package/lib/core/configurations/utils/usage-examples.d.ts +39 -0
- package/lib/core/disposable.js +4 -2
- package/lib/core/disposable.js.map +1 -1
- package/lib/core/event.js.map +1 -1
- package/lib/core/in-memory-providers/cde-code-provider.js.map +1 -1
- package/lib/core/in-memory-providers/in-memory-value-store.js.map +1 -1
- package/lib/core/index.d.ts +1 -0
- package/lib/core/organization/configuration.js +1 -1
- package/lib/core/organization/configuration.js.map +1 -1
- package/lib/core/organization/helpers/organization-helpers.js.map +1 -1
- package/lib/core/organization/organization.d.ts +3 -1
- package/lib/core/organization/organization.js +8 -1
- package/lib/core/organization/organization.js.map +1 -1
- package/lib/core/path.js.map +1 -1
- package/lib/errors/auth-error.js.map +1 -1
- package/lib/index.js +1 -1
- package/lib/interfaces/configuration/configuration.js.map +1 -1
- package/lib/interfaces/configuration/configurationRegistry.d.ts +5 -0
- package/lib/interfaces/configuration/configuraton-service.d.ts +9 -1
- package/lib/interfaces/organization/organization-context.js.map +1 -1
- package/lib/interfaces/organization/organizations-context.d.ts +1 -0
- package/lib/interfaces/permissions.d.ts +2 -2
- package/lib/interfaces/permissions.js.map +1 -1
- package/lib/modules/account-api/enums/index.js.map +1 -1
- package/lib/modules/billing-api/enums/index.js.map +1 -1
- package/lib/modules/index.d.ts +0 -1
- package/lib/services/abstract-configuration.d.ts +9 -1
- package/lib/services/abstract-configuration.js +24 -1
- package/lib/services/abstract-configuration.js.map +1 -1
- package/lib/services/abstract-organization-context-service.js +2 -2
- package/lib/services/abstract-organization-context-service.js.map +1 -1
- package/lib/utils/cdecodeUri.d.ts +1 -1
- package/lib/utils/cdecodeUri.js +40 -7
- package/lib/utils/cdecodeUri.js.map +1 -1
- package/lib/utils/configuration-utils.js.map +1 -1
- package/lib/utils/date-utils.js.map +1 -1
- package/lib/utils/flatten-utils.js.map +1 -1
- package/lib/utils/generate-uri.js.map +1 -1
- package/lib/utils/generatePath.js.map +1 -1
- package/lib/utils/generateUserAlias.js.map +1 -1
- package/lib/utils/generated-settings-id.d.ts +1 -1
- package/lib/utils/generated-settings-id.js +4 -6
- package/lib/utils/generated-settings-id.js.map +1 -1
- package/lib/utils/getLogger.js.map +1 -1
- package/lib/utils/getUserAlias.js.map +1 -1
- package/lib/utils/index.d.ts +1 -0
- package/lib/utils/nodeContext.d.ts +17 -3
- package/lib/utils/nodeContext.js +26 -7
- package/lib/utils/nodeContext.js.map +1 -1
- package/lib/utils/omit-deep.js.map +1 -1
- package/lib/utils/preferenceUri.d.ts +6 -5
- package/lib/utils/preferenceUri.js +145 -13
- package/lib/utils/preferenceUri.js.map +1 -1
- package/lib/utils/resourceUriConversion.d.ts +11 -1
- package/lib/utils/resourceUriConversion.js +19 -13
- package/lib/utils/resourceUriConversion.js.map +1 -1
- package/lib/utils/reviveUri.js.map +1 -1
- package/lib/utils/roles-utils.js.map +1 -1
- package/lib/utils/slug-utils.d.ts +87 -0
- package/lib/utils/slug-utils.js +95 -0
- package/lib/utils/slug-utils.js.map +1 -0
- package/lib/utils/splitCdecodeUri.js.map +1 -1
- package/lib/utils/utils.js.map +1 -1
- package/lib/utils/validations.js +2 -2
- package/lib/utils/validations.js.map +1 -1
- package/lib/utils/validations.test.d.ts +1 -0
- package/package.json +3 -3
- package/lib/modules/inbox/enums/index.js +0 -26
- package/lib/modules/inbox/enums/index.js.map +0 -1
|
@@ -55,11 +55,14 @@ class ConfigurationModel {
|
|
|
55
55
|
}
|
|
56
56
|
return arrays.distinct(result);
|
|
57
57
|
}
|
|
58
|
-
override(identifier) {
|
|
59
|
-
|
|
58
|
+
override(identifier, options) {
|
|
59
|
+
// Normalize to string for caching
|
|
60
|
+
const normalizedKey = Array.isArray(identifier) ? `[${identifier.map(id => `'${id}'`).join(', ')}]` : identifier;
|
|
61
|
+
const cacheKey = options?.strict ? `${normalizedKey}:strict` : normalizedKey;
|
|
62
|
+
let overrideConfigurationModel = this.overrideConfigurations.get(cacheKey);
|
|
60
63
|
if (!overrideConfigurationModel) {
|
|
61
|
-
overrideConfigurationModel = this.createOverrideConfigurationModel(identifier);
|
|
62
|
-
this.overrideConfigurations.set(
|
|
64
|
+
overrideConfigurationModel = this.createOverrideConfigurationModel(identifier, options?.strict);
|
|
65
|
+
this.overrideConfigurations.set(cacheKey, overrideConfigurationModel);
|
|
63
66
|
}
|
|
64
67
|
return overrideConfigurationModel;
|
|
65
68
|
}
|
|
@@ -115,8 +118,8 @@ class ConfigurationModel {
|
|
|
115
118
|
removeFromValueTree(this.contents, key);
|
|
116
119
|
}
|
|
117
120
|
}
|
|
118
|
-
createOverrideConfigurationModel(identifier) {
|
|
119
|
-
const overrideContents = this.getContentsForOverrideIdentifer(identifier);
|
|
121
|
+
createOverrideConfigurationModel(identifier, strict = false) {
|
|
122
|
+
const overrideContents = this.getContentsForOverrideIdentifer(identifier, strict);
|
|
120
123
|
if (!overrideContents || typeof overrideContents !== 'object' || !Object.keys(overrideContents).length) {
|
|
121
124
|
// If there are no valid overrides, return self
|
|
122
125
|
return this;
|
|
@@ -157,7 +160,40 @@ class ConfigurationModel {
|
|
|
157
160
|
}
|
|
158
161
|
return data;
|
|
159
162
|
}
|
|
160
|
-
getContentsForOverrideIdentifer(identifier) {
|
|
163
|
+
getContentsForOverrideIdentifer(identifier, strict = false) {
|
|
164
|
+
// Normalize identifier to array
|
|
165
|
+
const identifiers = this.parseIdentifier(identifier);
|
|
166
|
+
if (identifiers.length === 1) {
|
|
167
|
+
// Single identifier - original logic
|
|
168
|
+
return this.getSingleIdentifierContents(identifiers[0], strict);
|
|
169
|
+
}
|
|
170
|
+
// Multiple identifiers - use multi-identifier logic
|
|
171
|
+
return this.getMultiIdentifierContents(identifiers, strict);
|
|
172
|
+
}
|
|
173
|
+
/**
|
|
174
|
+
* Parse identifier - handles string, string array, and bracket notation
|
|
175
|
+
* - 'desktop' → ['desktop']
|
|
176
|
+
* - ['desktop', '/path'] → ['desktop', '/path']
|
|
177
|
+
* - "['/path', 'desktop']" → ['/path', 'desktop']
|
|
178
|
+
*/
|
|
179
|
+
parseIdentifier(identifier) {
|
|
180
|
+
// Already an array - return as is
|
|
181
|
+
if (Array.isArray(identifier)) {
|
|
182
|
+
return identifier;
|
|
183
|
+
}
|
|
184
|
+
// Check if it's array format: starts with '[' and ends with ']'
|
|
185
|
+
if (identifier.startsWith('[') && identifier.endsWith(']')) {
|
|
186
|
+
// Remove outer brackets and split by comma
|
|
187
|
+
const inner = identifier.slice(1, -1);
|
|
188
|
+
return inner.split(',').map(id => id.trim().replace(/^['"]|['"]$/g, ''));
|
|
189
|
+
}
|
|
190
|
+
// Single identifier string
|
|
191
|
+
return [identifier];
|
|
192
|
+
}
|
|
193
|
+
/**
|
|
194
|
+
* Get contents for single identifier (original logic)
|
|
195
|
+
*/
|
|
196
|
+
getSingleIdentifierContents(identifier, strict) {
|
|
161
197
|
let contentsForIdentifierOnly = null;
|
|
162
198
|
let contents = null;
|
|
163
199
|
const mergeContents = contentsToMerge => {
|
|
@@ -171,8 +207,15 @@ class ConfigurationModel {
|
|
|
171
207
|
};
|
|
172
208
|
for (const override of this.overrides) {
|
|
173
209
|
if (arrays.equals(override.identifiers, [identifier])) {
|
|
210
|
+
// Exact match: only this identifier
|
|
174
211
|
contentsForIdentifierOnly = override.contents;
|
|
175
|
-
} else if (override.identifiers.includes(identifier)) {
|
|
212
|
+
} else if (strict && override.identifiers.length === 1 && override.identifiers.includes(identifier)) {
|
|
213
|
+
// Strict mode: ONLY apply overrides where ALL identifiers match exactly
|
|
214
|
+
// Skip compound overrides like [/o/:orgName/vault][desktop]
|
|
215
|
+
mergeContents(override.contents);
|
|
216
|
+
} else if (!strict && override.identifiers.includes(identifier)) {
|
|
217
|
+
// Original behavior (non-strict): Apply if identifier is included
|
|
218
|
+
// This maintains backward compatibility with existing tests
|
|
176
219
|
mergeContents(override.contents);
|
|
177
220
|
}
|
|
178
221
|
}
|
|
@@ -180,6 +223,78 @@ class ConfigurationModel {
|
|
|
180
223
|
mergeContents(contentsForIdentifierOnly);
|
|
181
224
|
return contents;
|
|
182
225
|
}
|
|
226
|
+
/**
|
|
227
|
+
* Get contents for multiple override identifiers with proper precedence
|
|
228
|
+
* Merge order (in strict mode):
|
|
229
|
+
* 1. Individual overrides in right-to-left order (rightmost first, leftmost last)
|
|
230
|
+
* 2. Partial compound overrides (subset of identifiers) by specificity
|
|
231
|
+
* 3. Full compound override (all identifiers match) - highest precedence
|
|
232
|
+
*
|
|
233
|
+
* Example: For identifiers ['/patha', 'desktop']
|
|
234
|
+
* - Apply: base → [desktop] → [/patha] → [/patha][desktop]
|
|
235
|
+
* - Result: leftmost individual override ([/patha]) has higher precedence than rightmost ([desktop])
|
|
236
|
+
*/
|
|
237
|
+
getMultiIdentifierContents(identifiers, strict) {
|
|
238
|
+
let contents = null;
|
|
239
|
+
const mergeContents = contentsToMerge => {
|
|
240
|
+
if (contentsToMerge) {
|
|
241
|
+
if (contents) {
|
|
242
|
+
this.mergeContents(contents, contentsToMerge);
|
|
243
|
+
} else {
|
|
244
|
+
contents = objects.deepClone(contentsToMerge);
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
};
|
|
248
|
+
// Group overrides by specificity (number of matching identifiers)
|
|
249
|
+
const applicableOverrides = [];
|
|
250
|
+
for (const override of this.overrides) {
|
|
251
|
+
if (strict) {
|
|
252
|
+
// In strict mode: only apply if ALL override identifiers are in our list
|
|
253
|
+
const matchCount = override.identifiers.filter(id => identifiers.includes(id)).length;
|
|
254
|
+
// Only include if all override identifiers match
|
|
255
|
+
if (matchCount === override.identifiers.length && matchCount > 0) {
|
|
256
|
+
// For single-identifier overrides, track their position (right-to-left)
|
|
257
|
+
const position = override.identifiers.length === 1 ? identifiers.indexOf(override.identifiers[0]) : -1;
|
|
258
|
+
applicableOverrides.push({
|
|
259
|
+
override,
|
|
260
|
+
matchCount,
|
|
261
|
+
position
|
|
262
|
+
});
|
|
263
|
+
}
|
|
264
|
+
} else {
|
|
265
|
+
// Non-strict mode: apply if ANY identifier matches (backward compatible)
|
|
266
|
+
const matchCount = override.identifiers.filter(id => identifiers.includes(id)).length;
|
|
267
|
+
if (matchCount > 0) {
|
|
268
|
+
const position = override.identifiers.length === 1 ? identifiers.indexOf(override.identifiers[0]) : -1;
|
|
269
|
+
applicableOverrides.push({
|
|
270
|
+
override,
|
|
271
|
+
matchCount,
|
|
272
|
+
position
|
|
273
|
+
});
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
// Sort by specificity and position
|
|
278
|
+
// 1. Primary sort: by match count (ascending) - less specific first
|
|
279
|
+
// 2. Secondary sort: for single identifiers (matchCount=1), by position (descending) - rightmost first
|
|
280
|
+
applicableOverrides.sort((a, b) => {
|
|
281
|
+
if (a.matchCount !== b.matchCount) {
|
|
282
|
+
return a.matchCount - b.matchCount; // Less specific first
|
|
283
|
+
}
|
|
284
|
+
// Same match count - apply position-based sort for single identifiers
|
|
285
|
+
if (a.matchCount === 1) {
|
|
286
|
+
return b.position - a.position; // Higher position (rightmost) first
|
|
287
|
+
}
|
|
288
|
+
return 0;
|
|
289
|
+
});
|
|
290
|
+
// Apply overrides in order of specificity
|
|
291
|
+
for (const {
|
|
292
|
+
override
|
|
293
|
+
} of applicableOverrides) {
|
|
294
|
+
mergeContents(override.contents);
|
|
295
|
+
}
|
|
296
|
+
return contents;
|
|
297
|
+
}
|
|
183
298
|
addKey(key) {
|
|
184
299
|
let index = this.keys.length;
|
|
185
300
|
for (let i = 0; i < index; i++) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ConfigurationModel.js","sources":["../../../../src/core/configurations/models/ConfigurationModel.ts"],"sourcesContent":[null],"names":[],"mappings":"6UAQA;MACa,kBAAkB,CAAA;AAeN,EAAA,SAAA;AACA,EAAA,KAAA;AACA,EAAA,UAAA;
|
|
1
|
+
{"version":3,"file":"ConfigurationModel.js","sources":["../../../../src/core/configurations/models/ConfigurationModel.ts"],"sourcesContent":[null],"names":[],"mappings":"6UAQA;MACa,kBAAkB,CAAA;AAeN,EAAA,SAAA;AACA,EAAA,KAAA;AACA,EAAA,UAAA;QAhBb,GAAM;AAEG,EAAA,sBAAA,GAAsB,IAAG,GAAI,EAAG;SAEjD,QAAO,CAAA,IAAS,EAAS;;AAErB,IAAA,MAAA,eAAiB,CAAA,QAAK,IAAQ,EAAA;AAC9B,IAAA,MAAA,IAAM,OAAO,CAAA,IAAK,IAAI,EAAA;AACtB,IAAA,MAAA,gBAAkB,CAAA,SAAK,IAAS,EAAA;WAEhC,IAAO,2BAAuB,EAAA,IAAU,EAAA,SAAM,CAAA;;AAGlD,EAAA,WAAA,CAAA,cACsC,EAAE,UACD,EAAE,eACO,EAAE;QAF7B,CAAA,SAAA,GAAA;QACA,CAAA,KAAA,GAAA;QACA,CAAA,UAAA,GAAA;;AAGrB,EAAA,IAAA,QAAI,GAAQ;WACR,IAAO,CAAA,cAAK,CAAA,IAAe,UAAK,CAAA;;AAGpC,EAAA,IAAA,SAAI,GAAS;WACT,IAAO,CAAA,cAAK,CAAA,IAAe,WAAK,CAAA;;AAGpC,EAAA,IAAA,IAAI,GAAI;WACJ,IAAO,CAAA,cAAK,CAAA,IAAe,MAAK,CAAA;;SAGpC,GAAO;AACH,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IAAQ,CAAA;oBAEd;sBACH;YACL;;;;AAGI,IAAA;AACI;;;uBAIP,CAAA,IAAA,CAAA,CAAA,CAAA,EAAA,CAAA,KAAA;UACJ,CAAA,CAAA,UAAA,KAAA,CAAA,CAAA,UAAA,EAAA;QAED,OAAA,CAAA,CAAA,UAAA,GAAA,CAAA,CAAA,UAAA,CAAmC;;;UAGnC,CAAA,CAAA,UAAA,KAAmB,CAAC;eAChB,CAAI,CAAC,QAAC,GAAU,CAAA,CAAA,QAAO,CAAA;;aAEtB,CAAA;;AAED;;;AAGA,KAAA,IAAA,mBAAS,EAAA;AACb,MAAA,aAAG,CAAA,QAAA,CAAA,QAAA,CAAA;;AAGH,IAAA,OAAA,QAAW;AACP,EAAA;QACJ,CAAC,GAAA,EAAA;AAED,IAAA,IAAA,KAAA,YAAgB,CAAA,MAAA;IACpB,KAAC,IAAA,CAAA,GAAA,CAAA,EAAA,CAAA,GAAA,KAAA,EAAA,CAAA,EAAA,EAAA;AAEO,MAAA,IAAM,GAAC,CAAW,OAAA,CAAA,IAAA,CAAA,IAAA,CAAA,CAAA,CAAA,CAAA,KAAA,CAAA,EAAA;AACtB,QAAA,SAAS;AACT,MAAA;AACI,IAAA;oBACI,CAAK,KAAK,EAAA,CAAA,EAAA,GAAA,CAAA;;WAEjB,CAAA,GAAA,EAAA;UACD,KAAK,GAAK,IAAA,CAAA,IAAO,CAAA,OAAU,CAAA,GAAI,CAAC;IACpC,IAAC,KAAA,KAAA,EAAA,EAAA;AAEO,MAAA,IAAA,CAAA,IAAU,CAAA,MAAW,CAAA,KAAA,EAAA,CAAA,CAAA;aACzB,IAAM;AACN,IAAA;gBACQ;AACJ,EAAA;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { ConfigurationModel } from './ConfigurationModel';
|
|
2
|
+
/**
|
|
3
|
+
* Enhanced configuration model that includes compound override information
|
|
4
|
+
*/
|
|
5
|
+
export declare class EnhancedConfigurationModel {
|
|
6
|
+
private baseModel;
|
|
7
|
+
private identifier;
|
|
8
|
+
private options?;
|
|
9
|
+
private overrideModel;
|
|
10
|
+
private compoundOverrides;
|
|
11
|
+
constructor(baseModel: ConfigurationModel, identifier: string, options?: {
|
|
12
|
+
strict?: boolean;
|
|
13
|
+
});
|
|
14
|
+
/**
|
|
15
|
+
* Extract compound overrides that include the current identifier
|
|
16
|
+
* Returns them without the current identifier in the key
|
|
17
|
+
*/
|
|
18
|
+
private extractCompoundOverrides;
|
|
19
|
+
/**
|
|
20
|
+
* Get value with compound overrides included in the result
|
|
21
|
+
* @param section Configuration section to retrieve
|
|
22
|
+
* @returns Value merged with base + identifier, and compound overrides as additional keys
|
|
23
|
+
*/
|
|
24
|
+
getValue<T>(section?: string): T;
|
|
25
|
+
/**
|
|
26
|
+
* Filter out bracket-notation keys from an object
|
|
27
|
+
*/
|
|
28
|
+
private filterBracketKeys;
|
|
29
|
+
/**
|
|
30
|
+
* Get all available compound override keys (without the current identifier)
|
|
31
|
+
*/
|
|
32
|
+
getCompoundOverrideKeys(): string[];
|
|
33
|
+
/**
|
|
34
|
+
* Get a specific compound override value
|
|
35
|
+
* @param compoundKey The compound key (e.g., '[/o/:orgName/vault]')
|
|
36
|
+
* @param section Optional section to retrieve
|
|
37
|
+
*/
|
|
38
|
+
getCompoundOverride<T>(compoundKey: string, section?: string): T | undefined;
|
|
39
|
+
/**
|
|
40
|
+
* Helper to extract value from contents by section path
|
|
41
|
+
*/
|
|
42
|
+
private getValueFromContents;
|
|
43
|
+
/**
|
|
44
|
+
* Get the underlying override model
|
|
45
|
+
*/
|
|
46
|
+
getOverrideModel(): ConfigurationModel;
|
|
47
|
+
}
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Enhanced configuration model that includes compound override information
|
|
3
|
+
*/
|
|
4
|
+
class EnhancedConfigurationModel {
|
|
5
|
+
baseModel;
|
|
6
|
+
identifier;
|
|
7
|
+
options;
|
|
8
|
+
overrideModel;
|
|
9
|
+
compoundOverrides;
|
|
10
|
+
constructor(baseModel, identifier, options) {
|
|
11
|
+
this.baseModel = baseModel;
|
|
12
|
+
this.identifier = identifier;
|
|
13
|
+
this.options = options;
|
|
14
|
+
// Get the override model (base + identifier override)
|
|
15
|
+
this.overrideModel = baseModel.override(identifier, options);
|
|
16
|
+
// Find all compound overrides containing this identifier
|
|
17
|
+
this.compoundOverrides = this.extractCompoundOverrides();
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Extract compound overrides that include the current identifier
|
|
21
|
+
* Returns them without the current identifier in the key
|
|
22
|
+
*/
|
|
23
|
+
extractCompoundOverrides() {
|
|
24
|
+
const compounds = new Map();
|
|
25
|
+
for (const override of this.baseModel.overrides) {
|
|
26
|
+
// Skip if no identifiers or not a compound override
|
|
27
|
+
if (!override.identifiers || override.identifiers.length <= 1) {
|
|
28
|
+
// eslint-disable-next-line no-continue
|
|
29
|
+
continue;
|
|
30
|
+
}
|
|
31
|
+
// Check if this compound override includes our identifier
|
|
32
|
+
if (override.identifiers.includes(this.identifier)) {
|
|
33
|
+
// Extract the other identifiers (not the current one)
|
|
34
|
+
const otherIdentifiers = override.identifiers.filter(id => id !== this.identifier);
|
|
35
|
+
// Create a key without the current identifier
|
|
36
|
+
const key = otherIdentifiers.map(id => `[${id}]`).join('');
|
|
37
|
+
compounds.set(key, override.contents);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
return compounds;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Get value with compound overrides included in the result
|
|
44
|
+
* @param section Configuration section to retrieve
|
|
45
|
+
* @returns Value merged with base + identifier, and compound overrides as additional keys
|
|
46
|
+
*/
|
|
47
|
+
getValue(section) {
|
|
48
|
+
// Get the merged value (base + identifier override)
|
|
49
|
+
const mergedValue = section ? this.overrideModel.getValue(section) : this.overrideModel.contents;
|
|
50
|
+
// If no compound overrides, return as-is (but filter out bracket keys if no section)
|
|
51
|
+
if (this.compoundOverrides.size === 0) {
|
|
52
|
+
if (!section) {
|
|
53
|
+
// Filter out any bracket-notation keys from the result
|
|
54
|
+
return this.filterBracketKeys(mergedValue);
|
|
55
|
+
}
|
|
56
|
+
return mergedValue;
|
|
57
|
+
}
|
|
58
|
+
// Create result object with merged value and compound overrides
|
|
59
|
+
// When no section is specified, filter out bracket keys from base contents
|
|
60
|
+
const baseResult = section ? mergedValue : this.filterBracketKeys(mergedValue);
|
|
61
|
+
const result = {
|
|
62
|
+
...(baseResult || {})
|
|
63
|
+
};
|
|
64
|
+
// Add compound overrides as separate keys
|
|
65
|
+
for (const [key, contents] of this.compoundOverrides.entries()) {
|
|
66
|
+
// Extract the value for the specific section if provided
|
|
67
|
+
// Note: contents already has the section wrapped, so we need to unwrap it
|
|
68
|
+
const compoundValue = section ? this.getValueFromContents(contents, section) : contents;
|
|
69
|
+
if (compoundValue !== undefined) {
|
|
70
|
+
result[key] = compoundValue;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
return result;
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Filter out bracket-notation keys from an object
|
|
77
|
+
*/
|
|
78
|
+
filterBracketKeys(obj) {
|
|
79
|
+
if (!obj || typeof obj !== 'object') {
|
|
80
|
+
return obj;
|
|
81
|
+
}
|
|
82
|
+
const filtered = {};
|
|
83
|
+
for (const key of Object.keys(obj)) {
|
|
84
|
+
// Skip keys that start with '[' (bracket notation)
|
|
85
|
+
if (!key.startsWith('[')) {
|
|
86
|
+
filtered[key] = obj[key];
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
return filtered;
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Get all available compound override keys (without the current identifier)
|
|
93
|
+
*/
|
|
94
|
+
getCompoundOverrideKeys() {
|
|
95
|
+
return Array.from(this.compoundOverrides.keys());
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Get a specific compound override value
|
|
99
|
+
* @param compoundKey The compound key (e.g., '[/o/:orgName/vault]')
|
|
100
|
+
* @param section Optional section to retrieve
|
|
101
|
+
*/
|
|
102
|
+
getCompoundOverride(compoundKey, section) {
|
|
103
|
+
const contents = this.compoundOverrides.get(compoundKey);
|
|
104
|
+
if (!contents) {
|
|
105
|
+
return undefined;
|
|
106
|
+
}
|
|
107
|
+
return section ? this.getValueFromContents(contents, section) : contents;
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Helper to extract value from contents by section path
|
|
111
|
+
*/
|
|
112
|
+
getValueFromContents(contents, section) {
|
|
113
|
+
const parts = section.split('.');
|
|
114
|
+
let value = contents;
|
|
115
|
+
for (const part of parts) {
|
|
116
|
+
if (value && typeof value === 'object' && part in value) {
|
|
117
|
+
value = value[part];
|
|
118
|
+
} else {
|
|
119
|
+
return undefined;
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
return value;
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* Get the underlying override model
|
|
126
|
+
*/
|
|
127
|
+
getOverrideModel() {
|
|
128
|
+
return this.overrideModel;
|
|
129
|
+
}
|
|
130
|
+
}export{EnhancedConfigurationModel};//# sourceMappingURL=ConfigurationModelWrapper.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ConfigurationModelWrapper.js","sources":["../../../../src/core/configurations/models/ConfigurationModelWrapper.ts"],"sourcesContent":[null],"names":[],"mappings":"AAIA;;AAEG;MACU,0BAA0B,CAAA;AAMvB,EAAA,SAAA;AACA,EAAA,UAAA;AACA,EAAA,OAAA;AAPJ,EAAA,aAAA;AAEA,EAAA,iBAAA;AAER,EAAA,WAAA,CAAA,SACY,EAA6B,UAC7B,EAAkB,OAClB,EAA8B;QAF9B,CAAA,SAAA,GAAA;QACA,CAAA,UAAA,GAAA;QACA,CAAA,OAAA,GAAA;;QAGR,CAAA,aAAK,GAAA,SAAgB,CAAA,QAAU,CAAA,UAAS,EAAA,OAAY,CAAA;;AAGpD,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CAAA,aAAgB;;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { ConfigurationScope } from 'common/server';
|
|
2
|
+
import { IConfigurationPropertySchema } from '../../../interfaces/configuration';
|
|
3
|
+
import { ConfigurationModel } from '../models';
|
|
4
|
+
export interface ConfigurationParseOptions {
|
|
5
|
+
scopes?: ConfigurationScope[];
|
|
6
|
+
skipRestricted?: boolean;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Parses the given JSON content into a ConfigurationModel, fetching property schemas
|
|
10
|
+
* from the provided registry based on "options.context" for multi-tenant use.
|
|
11
|
+
*
|
|
12
|
+
* 1. Converts JSON -> raw object (with error tracking).
|
|
13
|
+
* 2. Fetches tenant-specific configuration properties from the registry.
|
|
14
|
+
* 3. Filters raw object by scopes, restricted properties, or override sections.
|
|
15
|
+
* 4. Returns a { model, restricted, errors } object in a stateless manner.
|
|
16
|
+
*/
|
|
17
|
+
export declare function parseConfiguration(content: string | undefined | null, configurationProperties: {
|
|
18
|
+
[qualifiedKey: string]: IConfigurationPropertySchema | undefined;
|
|
19
|
+
}, name: string, options: ConfigurationParseOptions): Promise<{
|
|
20
|
+
model: ConfigurationModel;
|
|
21
|
+
restricted: string[];
|
|
22
|
+
errors: any[];
|
|
23
|
+
}>;
|
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
import*as json from'@vscode-alt/monaco-editor/esm/vs/base/common/json.js';import {ConfigurationModel}from'../models/ConfigurationModel.js';import {toValuesTree}from'../helpers/configuration.js';import {OVERRIDE_PROPERTY_REGEX,overrideIdentifiersFromKey}from'../configuration.js';/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
2
|
+
/**
|
|
3
|
+
* Parses the given JSON content into a ConfigurationModel, fetching property schemas
|
|
4
|
+
* from the provided registry based on "options.context" for multi-tenant use.
|
|
5
|
+
*
|
|
6
|
+
* 1. Converts JSON -> raw object (with error tracking).
|
|
7
|
+
* 2. Fetches tenant-specific configuration properties from the registry.
|
|
8
|
+
* 3. Filters raw object by scopes, restricted properties, or override sections.
|
|
9
|
+
* 4. Returns a { model, restricted, errors } object in a stateless manner.
|
|
10
|
+
*/
|
|
11
|
+
async function parseConfiguration(content, configurationProperties, name, options) {
|
|
12
|
+
if (!content) {
|
|
13
|
+
// No content to parse -> return empty model
|
|
14
|
+
return {
|
|
15
|
+
model: new ConfigurationModel(),
|
|
16
|
+
restricted: [],
|
|
17
|
+
errors: []
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
// 1) Convert JSON -> raw object
|
|
21
|
+
const {
|
|
22
|
+
raw,
|
|
23
|
+
parseErrors
|
|
24
|
+
} = doParseContent(content, name);
|
|
25
|
+
// 2) Build full model from raw
|
|
26
|
+
const {
|
|
27
|
+
model,
|
|
28
|
+
restricted
|
|
29
|
+
} = await doParseRaw(raw, configurationProperties, name, options);
|
|
30
|
+
return {
|
|
31
|
+
model,
|
|
32
|
+
restricted: restricted || [],
|
|
33
|
+
errors: parseErrors
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* JSON -> Raw object, tracking parse errors. No class-level storage.
|
|
38
|
+
*/
|
|
39
|
+
function doParseContent(content, name) {
|
|
40
|
+
let raw = {};
|
|
41
|
+
const parseErrors = [];
|
|
42
|
+
let currentProperty = null;
|
|
43
|
+
let currentParent = [];
|
|
44
|
+
const previousParents = [];
|
|
45
|
+
function onValue(value) {
|
|
46
|
+
if (Array.isArray(currentParent)) {
|
|
47
|
+
currentParent.push(value);
|
|
48
|
+
} else if (currentProperty !== null) {
|
|
49
|
+
currentParent[currentProperty] = value;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
const visitor = {
|
|
53
|
+
onObjectBegin: () => {
|
|
54
|
+
const object = {};
|
|
55
|
+
onValue(object);
|
|
56
|
+
previousParents.push(currentParent);
|
|
57
|
+
currentParent = object;
|
|
58
|
+
currentProperty = null;
|
|
59
|
+
},
|
|
60
|
+
onObjectProperty: name => {
|
|
61
|
+
currentProperty = name;
|
|
62
|
+
},
|
|
63
|
+
onObjectEnd: () => {
|
|
64
|
+
currentParent = previousParents.pop();
|
|
65
|
+
},
|
|
66
|
+
onArrayBegin: () => {
|
|
67
|
+
const array = [];
|
|
68
|
+
onValue(array);
|
|
69
|
+
previousParents.push(currentParent);
|
|
70
|
+
currentParent = array;
|
|
71
|
+
currentProperty = null;
|
|
72
|
+
},
|
|
73
|
+
onArrayEnd: () => {
|
|
74
|
+
currentParent = previousParents.pop();
|
|
75
|
+
},
|
|
76
|
+
onLiteralValue: onValue,
|
|
77
|
+
onError: (error, offset, length) => {
|
|
78
|
+
parseErrors.push({
|
|
79
|
+
error,
|
|
80
|
+
offset,
|
|
81
|
+
length
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
};
|
|
85
|
+
if (content) {
|
|
86
|
+
try {
|
|
87
|
+
json.visit(content, visitor);
|
|
88
|
+
// If valid array in top-level JSON, it might end up as currentParent[0],
|
|
89
|
+
// else we interpret root as an object.
|
|
90
|
+
raw = currentParent[0] || {};
|
|
91
|
+
} catch (e) {
|
|
92
|
+
console.error(`Error while parsing file ${name}: ${e}`);
|
|
93
|
+
parseErrors.push(e);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
return {
|
|
97
|
+
raw,
|
|
98
|
+
parseErrors
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* Given the raw JSON object and registry, filter and convert into a ConfigurationModel.
|
|
103
|
+
*/
|
|
104
|
+
async function doParseRaw(raw, configurationProperties, name, options) {
|
|
105
|
+
// 1) Fetch tenant-specific properties from registry
|
|
106
|
+
// 2) Filter raw object
|
|
107
|
+
const filtered = filterRaw(raw, configurationProperties, true, options);
|
|
108
|
+
const finalRaw = filtered.raw;
|
|
109
|
+
// 3) Build the final model
|
|
110
|
+
// Check if any keys are override identifiers - if so, handle them specially
|
|
111
|
+
const hasOverrideIdentifiers = Object.keys(finalRaw).some(key => OVERRIDE_PROPERTY_REGEX.test(key));
|
|
112
|
+
let contents;
|
|
113
|
+
if (hasOverrideIdentifiers) {
|
|
114
|
+
// For override identifiers, we need to convert the override sections to nested objects
|
|
115
|
+
// but keep the override identifier keys as-is (not dot-split)
|
|
116
|
+
contents = {};
|
|
117
|
+
for (const key of Object.keys(finalRaw)) {
|
|
118
|
+
if (OVERRIDE_PROPERTY_REGEX.test(key)) {
|
|
119
|
+
// This is an override identifier - convert its contents to nested object
|
|
120
|
+
contents[key] = toValuesTree(finalRaw[key], message => console.error(`Conflict in settings file ${name}: ${message}`));
|
|
121
|
+
} else {
|
|
122
|
+
// Regular key - add directly (will be converted by toValuesTree at the end)
|
|
123
|
+
contents[key] = finalRaw[key];
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
// Now convert the non-override keys
|
|
127
|
+
const nonOverrideContents = {};
|
|
128
|
+
for (const key of Object.keys(contents)) {
|
|
129
|
+
if (!OVERRIDE_PROPERTY_REGEX.test(key)) {
|
|
130
|
+
nonOverrideContents[key] = contents[key];
|
|
131
|
+
delete contents[key];
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
const convertedNonOverride = toValuesTree(nonOverrideContents, message => console.error(`Conflict in settings file ${name}: ${message}`));
|
|
135
|
+
// Merge back
|
|
136
|
+
contents = {
|
|
137
|
+
...convertedNonOverride,
|
|
138
|
+
...contents
|
|
139
|
+
};
|
|
140
|
+
} else {
|
|
141
|
+
contents = toValuesTree(finalRaw, message => console.error(`Conflict in settings file ${name}: ${message}`));
|
|
142
|
+
}
|
|
143
|
+
const keys = Object.keys(finalRaw);
|
|
144
|
+
const overrides = toOverrides(finalRaw, message => console.error(`Conflict in settings file ${name}: ${message}`));
|
|
145
|
+
return {
|
|
146
|
+
model: new ConfigurationModel(contents, keys, overrides),
|
|
147
|
+
restricted: filtered.restricted
|
|
148
|
+
};
|
|
149
|
+
}
|
|
150
|
+
/**
|
|
151
|
+
* Synchronously filters out properties not matching scopes,
|
|
152
|
+
* or restricted properties (if skipRestricted is set).
|
|
153
|
+
*/
|
|
154
|
+
function filterRaw(properties, configurationProperties, filterOverriddenProperties, options) {
|
|
155
|
+
let hasExcludedProperties = false;
|
|
156
|
+
const raw = {};
|
|
157
|
+
const restricted = [];
|
|
158
|
+
// if (!options.scopes && !options.skipRestricted) {
|
|
159
|
+
// // No filtering needed
|
|
160
|
+
// return { raw: properties, restricted, hasExcludedProperties };
|
|
161
|
+
// }
|
|
162
|
+
for (const key in properties) {
|
|
163
|
+
if (OVERRIDE_PROPERTY_REGEX.test(key) && filterOverriddenProperties) {
|
|
164
|
+
const overrideResult = filterRaw(properties[key], configurationProperties, false, options);
|
|
165
|
+
raw[key] = overrideResult.raw;
|
|
166
|
+
hasExcludedProperties = hasExcludedProperties || overrideResult.hasExcludedProperties;
|
|
167
|
+
restricted.push(...overrideResult.restricted);
|
|
168
|
+
} else {
|
|
169
|
+
const propertySchema = configurationProperties[key];
|
|
170
|
+
const scope = propertySchema?.scope ?? 3 /* ConfigurationScope.WINDOW */;
|
|
171
|
+
if (propertySchema?.restricted) {
|
|
172
|
+
restricted.push(key);
|
|
173
|
+
}
|
|
174
|
+
// Debug scope filtering logic
|
|
175
|
+
const scopeIncluded = !options.scopes || Array.isArray(options.scopes) && (Array.isArray(scope) ? scope.some(s => options.scopes.includes(s)) : options.scopes.includes(scope));
|
|
176
|
+
// Check scope and skipRestricted
|
|
177
|
+
if (scopeIncluded && !(options.skipRestricted && propertySchema?.restricted)) {
|
|
178
|
+
raw[key] = properties[key];
|
|
179
|
+
} else {
|
|
180
|
+
hasExcludedProperties = true;
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
return {
|
|
185
|
+
raw,
|
|
186
|
+
restricted,
|
|
187
|
+
hasExcludedProperties
|
|
188
|
+
};
|
|
189
|
+
}
|
|
190
|
+
/**
|
|
191
|
+
* Builds override sections (e.g. "[mySetting]": { ... }) into IOverrides[].
|
|
192
|
+
*/
|
|
193
|
+
function toOverrides(raw, conflictReporter) {
|
|
194
|
+
const overrides = [];
|
|
195
|
+
for (const key of Object.keys(raw)) {
|
|
196
|
+
if (OVERRIDE_PROPERTY_REGEX.test(key)) {
|
|
197
|
+
const overrideRaw = {};
|
|
198
|
+
for (const keyInOverrideRaw in raw[key]) {
|
|
199
|
+
overrideRaw[keyInOverrideRaw] = raw[key][keyInOverrideRaw];
|
|
200
|
+
}
|
|
201
|
+
overrides.push({
|
|
202
|
+
identifiers: overrideIdentifiersFromKey(key),
|
|
203
|
+
keys: Object.keys(overrideRaw),
|
|
204
|
+
contents: toValuesTree(overrideRaw, conflictReporter)
|
|
205
|
+
});
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
return overrides;
|
|
209
|
+
}export{parseConfiguration};//# sourceMappingURL=configurationParser.js.map
|