@adminide-stack/core 12.0.4-alpha.95 → 13.0.1-alpha.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.
Files changed (105) hide show
  1. package/lib/constants/configuration.d.ts +4 -0
  2. package/lib/constants/configuration.js +5 -1
  3. package/lib/constants/configuration.js.map +1 -1
  4. package/lib/constants/defaultIds.d.ts +10 -0
  5. package/lib/constants/defaultIds.js +14 -0
  6. package/lib/constants/defaultIds.js.map +1 -0
  7. package/lib/constants/index.d.ts +1 -0
  8. package/lib/constants/routes.js.map +1 -1
  9. package/lib/constants/urls.d.ts +3 -1
  10. package/lib/constants/urls.js +2 -0
  11. package/lib/constants/urls.js.map +1 -1
  12. package/lib/core/BaseDisposable.js.map +1 -1
  13. package/lib/core/configurations/configuration.js.map +1 -1
  14. package/lib/core/configurations/events/ConfigurationChangeEvent.js.map +1 -1
  15. package/lib/core/configurations/examples/configuration-wrapper-example.d.ts +67 -0
  16. package/lib/core/configurations/examples/configuration-wrapper.test.d.ts +1 -0
  17. package/lib/core/configurations/helpers/configuration.js.map +1 -1
  18. package/lib/core/configurations/index.d.ts +2 -0
  19. package/lib/core/configurations/models/ConfigurationModel.d.ts +26 -1
  20. package/lib/core/configurations/models/ConfigurationModel.js +123 -8
  21. package/lib/core/configurations/models/ConfigurationModel.js.map +1 -1
  22. package/lib/core/configurations/models/ConfigurationModel.multi-identifier.test.d.ts +1 -0
  23. package/lib/core/configurations/models/ConfigurationModelWrapper.d.ts +47 -0
  24. package/lib/core/configurations/models/ConfigurationModelWrapper.js +130 -0
  25. package/lib/core/configurations/models/ConfigurationModelWrapper.js.map +1 -0
  26. package/lib/core/configurations/models/ConfigurationModelWrapper.spec.d.ts +1 -0
  27. package/lib/core/configurations/models/ConfigurationModelWrapper.test.d.ts +1 -0
  28. package/lib/core/configurations/models/index.d.ts +1 -0
  29. package/lib/core/configurations/models/override.compound.test.d.ts +1 -0
  30. package/lib/core/configurations/models/override.edgecase.test.d.ts +1 -0
  31. package/lib/core/configurations/models/override.keys.test.d.ts +1 -0
  32. package/lib/core/configurations/models/override.strict.test.d.ts +1 -0
  33. package/lib/core/configurations/parser/configurationParser.d.ts +23 -0
  34. package/lib/core/configurations/parser/configurationParser.js +209 -0
  35. package/lib/core/configurations/parser/configurationParser.js.map +1 -0
  36. package/lib/core/configurations/parser/index.d.ts +1 -0
  37. package/lib/core/configurations/utils/QUICK_REFERENCE.d.ts +103 -0
  38. package/lib/core/configurations/utils/configurationExtractor.d.ts +224 -0
  39. package/lib/core/configurations/utils/configurationExtractor.js +315 -0
  40. package/lib/core/configurations/utils/configurationExtractor.js.map +1 -0
  41. package/lib/core/configurations/utils/configurationExtractor.test.d.ts +1 -0
  42. package/lib/core/configurations/utils/index.d.ts +5 -0
  43. package/lib/core/configurations/utils/model-creation-examples.d.ts +36 -0
  44. package/lib/core/configurations/utils/preferences-service-integration.d.ts +54 -0
  45. package/lib/core/configurations/utils/usage-examples.d.ts +39 -0
  46. package/lib/core/disposable.js.map +1 -1
  47. package/lib/core/event.js.map +1 -1
  48. package/lib/core/in-memory-providers/cde-code-provider.js.map +1 -1
  49. package/lib/core/in-memory-providers/in-memory-value-store.js.map +1 -1
  50. package/lib/core/organization/configuration.js +1 -1
  51. package/lib/core/organization/configuration.js.map +1 -1
  52. package/lib/core/organization/helpers/organization-helpers.js.map +1 -1
  53. package/lib/core/organization/organization.js.map +1 -1
  54. package/lib/core/path.js.map +1 -1
  55. package/lib/errors/auth-error.js.map +1 -1
  56. package/lib/index.js +1 -1
  57. package/lib/interfaces/configuration/configuration.js.map +1 -1
  58. package/lib/interfaces/configuration/configurationRegistry.d.ts +5 -0
  59. package/lib/interfaces/organization/organization-context.js.map +1 -1
  60. package/lib/interfaces/permissions.d.ts +2 -2
  61. package/lib/interfaces/permissions.js.map +1 -1
  62. package/lib/modules/account-api/enums/index.js.map +1 -1
  63. package/lib/modules/billing-api/enums/index.js.map +1 -1
  64. package/lib/modules/index.d.ts +0 -1
  65. package/lib/services/abstract-configuration.js +1 -1
  66. package/lib/services/abstract-configuration.js.map +1 -1
  67. package/lib/services/abstract-organization-context-service.js +1 -1
  68. package/lib/services/abstract-organization-context-service.js.map +1 -1
  69. package/lib/utils/cdecodeUri.d.ts +1 -1
  70. package/lib/utils/cdecodeUri.js +40 -7
  71. package/lib/utils/cdecodeUri.js.map +1 -1
  72. package/lib/utils/configuration-utils.js.map +1 -1
  73. package/lib/utils/date-utils.js.map +1 -1
  74. package/lib/utils/flatten-utils.js.map +1 -1
  75. package/lib/utils/generate-uri.js.map +1 -1
  76. package/lib/utils/generatePath.js.map +1 -1
  77. package/lib/utils/generateUserAlias.js.map +1 -1
  78. package/lib/utils/generated-settings-id.js +3 -5
  79. package/lib/utils/generated-settings-id.js.map +1 -1
  80. package/lib/utils/getLogger.js.map +1 -1
  81. package/lib/utils/getUserAlias.js.map +1 -1
  82. package/lib/utils/index.d.ts +1 -0
  83. package/lib/utils/nodeContext.d.ts +3 -1
  84. package/lib/utils/nodeContext.js +6 -5
  85. package/lib/utils/nodeContext.js.map +1 -1
  86. package/lib/utils/omit-deep.js.map +1 -1
  87. package/lib/utils/preferenceUri.d.ts +6 -5
  88. package/lib/utils/preferenceUri.js +145 -13
  89. package/lib/utils/preferenceUri.js.map +1 -1
  90. package/lib/utils/resourceUriConversion.d.ts +11 -1
  91. package/lib/utils/resourceUriConversion.js +19 -13
  92. package/lib/utils/resourceUriConversion.js.map +1 -1
  93. package/lib/utils/reviveUri.js.map +1 -1
  94. package/lib/utils/roles-utils.js.map +1 -1
  95. package/lib/utils/slug-utils.d.ts +87 -0
  96. package/lib/utils/slug-utils.js +95 -0
  97. package/lib/utils/slug-utils.js.map +1 -0
  98. package/lib/utils/splitCdecodeUri.js.map +1 -1
  99. package/lib/utils/utils.js.map +1 -1
  100. package/lib/utils/validations.js +2 -2
  101. package/lib/utils/validations.js.map +1 -1
  102. package/lib/utils/validations.test.d.ts +1 -0
  103. package/package.json +3 -3
  104. package/lib/modules/inbox/enums/index.js +0 -26
  105. package/lib/modules/inbox/enums/index.js.map +0 -1
@@ -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,C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AK,CAAA,IAAI,CAAA;aACZ;wBAAO;AACJ,MAAA;;WAEP,KAAA;AAED,EAAA;;AAGJ;;AAEG,EAAA,gBAAA,GAAA;IACH,OAAA,IAAA,CAAA,aAAgB;;"}
@@ -1 +1,2 @@
1
1
  export * from './ConfigurationModel';
2
+ export * from './ConfigurationModelWrapper';
@@ -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
@@ -0,0 +1 @@
1
+ {"version":3,"file":"configurationParser.js","sources":["../../../../src/core/configurations/parser/configurationParser.ts"],"sourcesContent":[null],"names":[],"mappings":"uRAAA;AAcA;;;;;;;;AAQG;AACI,eAAe,kBAAkB,CACpC,OAAkC,EAClC,uBAA6F,EAC7F,IAAY,EACZ,OAAkC,EAAA;MAMlC,CAAA,OAAK,EAAO;;WAER;aACI,IAAK,kBAAM,EAAA;AACX,MAAA,UAAA,EAAA,EAAA;AACA,MAAA,MAAA,EAAA;;;;AAKR,EAAA,MAAA;IAEA,GAAA;AACA,IAAA;MAEA,cAAO,CAAA,OAAA,EAAA,IAAA,CAAA;;QAEH;AACA,IAAA,KAAA;;AAER,GAAC,GAAA,MAAA,UAAA,CAAA,GAAA,EAAA,uBAAA,EAAA,IAAA,EAAA,OAAA,CAAA;AAED,EAAA,OAAA;;AAEG,IAAA,UAAA,EAAA,UAAA,IAAA,EAAA;AACH,IAAA,MAAS,EAAA;;;;;;SAOL,cAAiB,CAAA,OAAU,EAAA,IAAA,EAAA;AACvB,EAAA,IAAA,GAAA,GAAI;AACC,EAAA,MAAA,WAAA,GAAA,EAAA;qBACJ,GAAA,IAAA;AAAM,EAAA,IAAA,aAAI,GAAA,EAAA;AACP,EAAA,MAAA,eAAA,GAAc,EAAA;WACjB,OAAA,CAAA,KAAA,EAAA;IACL,IAAC,KAAA,CAAA,OAAA,CAAA,aAAA,CAAA,EAAA;AAED,MAAA,aAAa,CAAqB,IAAA,CAAA,KAAA,CAAA;WAC9B,IAAA,eAAoB,KAAA,IAAA,EAAA;mBACV,CAAA,eAAY,CAAA,GAAA,KAAA;;AAEl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,CAAA,CAAA,GAAA,OAAA,CAAA,MAAA,CAAA,QAAA,CAAA,KAAA,CAAA,CAAA;;uBACG,IAAA,EAAA,OAAA,CAAqB,cAAQ,IAAA,cAAA,EAAA,UAAA,CAAA,EAAA;YACjC,GAAC,CAAA,GAAA,UAAA,CAAA,GAAA,CAAA;aACJ;QACJ,qBAAA,GAAA,IAAA;AAED,MAAA;AACJ,IAAC;AAED,EAAA;;AAEG,IAAA,GAAA;AACH,IAAA,UAAS;IACL;;AAEI;;;;oBAIK,CAAA,GAAA,EAAA,gBAAA,EAAA;iBACD,GAAA,EAAU;AACN,EAAA,KAAA,MAAA,GAAA,IAAA,MAAA,CAAW,IAAE,CAAA,GAAA,CAAA,EAAA;AACb,IAAA,IAAA,uBAAa,CAAA;AACb,MAAA,MAAA,WAAA,GAAU,EAAA;AACb,MAAA,KAAA,MAAE,gBAAA,IAAA,GAAA,CAAA,GAAA,CAAA,EAAA;QACP,WAAC,CAAA,gBAAA,CAAA,GAAA,GAAA,CAAA,GAAA,CAAA,CAAA,gBAAA,CAAA;MACJ;AACD,MAAA,cAAgB,CAAC;AACrB,QAAC,WAAA,EAAA,0BAAA,CAAA,GAAA,CAAA;;;;;;;"}
@@ -0,0 +1 @@
1
+ export * from './configurationParser';
@@ -0,0 +1,103 @@
1
+ /**
2
+ * QUICK REFERENCE: Configuration Extractor Utilities
3
+ * ==================================================
4
+ *
5
+ * Import:
6
+ * import { extractConfiguration, ... } from '@adminide/core/configurations/utils';
7
+ *
8
+ * REUSES EXISTING CODE:
9
+ * - OVERRIDE_PROPERTY_REGEX from configuration.ts
10
+ * - overrideIdentifiersFromKey from configuration.ts
11
+ *
12
+ * ==================================================
13
+ * MAIN FUNCTION
14
+ * ==================================================
15
+ *
16
+ * extractConfiguration(settings)
17
+ * Returns: { baseContents, baseKeys, overrides }
18
+ *
19
+ * Example:
20
+ * const { baseContents, baseKeys, overrides } = extractConfiguration({
21
+ * theme: "light",
22
+ * "[desktop]": { theme: "dark" }
23
+ * });
24
+ *
25
+ * ==================================================
26
+ * HELPER FUNCTIONS
27
+ * ==================================================
28
+ *
29
+ * isBracketKey(key: string): boolean
30
+ * Check if key is bracket notation: [desktop], [/route]
31
+ *
32
+ * extractIdentifiersFromKey(key: string): string[]
33
+ * Parse identifiers from key: "[/route][desktop]" => ["/route", "desktop"]
34
+ *
35
+ * getOverrideKeys(settings): string[]
36
+ * Get all bracket keys: ["[desktop]", "[mobile]"]
37
+ *
38
+ * getBaseKeys(settings): string[]
39
+ * Get all non-bracket keys: ["theme", "color"]
40
+ *
41
+ * removeOverrideKeys(settings): object
42
+ * Return new object without bracket keys
43
+ *
44
+ * hasOverrides(settings): boolean
45
+ * Check if settings has any overrides
46
+ *
47
+ * getOverrideByIdentifier(settings, identifier): contents | undefined
48
+ * Get specific override: getOverrideByIdentifier(settings, "desktop")
49
+ *
50
+ * ==================================================
51
+ * COMMON PATTERNS
52
+ * ==================================================
53
+ *
54
+ * 1. EXTRACT AND SEPARATE
55
+ * ------------------------
56
+ * const { baseContents, overrides } = extractConfiguration(settings);
57
+ *
58
+ * 2. GET ROUTE CONFIG
59
+ * -------------------
60
+ * const override = overrides.find(o => o.identifiers.includes(route));
61
+ * const config = override ? { ...baseContents, ...override.contents } : baseContents;
62
+ *
63
+ * 3. CLEAN CONFIG
64
+ * ---------------
65
+ * const cleanConfig = removeOverrideKeys(settings);
66
+ *
67
+ * 4. CHECK FOR OVERRIDES
68
+ * ----------------------
69
+ * if (hasOverrides(settings)) { ... }
70
+ *
71
+ * 5. GET SPECIFIC OVERRIDE
72
+ * ------------------------
73
+ * const desktopConfig = getOverrideByIdentifier(settings, "desktop");
74
+ *
75
+ * ==================================================
76
+ * TYPES
77
+ * ==================================================
78
+ *
79
+ * interface ExtractedConfiguration {
80
+ * baseContents: any;
81
+ * baseKeys: string[];
82
+ * overrides: ConfigurationOverride[];
83
+ * }
84
+ *
85
+ * interface ConfigurationOverride {
86
+ * identifiers: string[]; // e.g., ["/o/:orgName/vault"]
87
+ * contents: any; // Override data
88
+ * keys: string[]; // Keys in override
89
+ * }
90
+ *
91
+ * ==================================================
92
+ * WHEN TO USE
93
+ * ==================================================
94
+ *
95
+ * ✅ Parsing server responses
96
+ * ✅ Client-side route handling
97
+ * ✅ Data transformation
98
+ * ✅ Testing configuration structure
99
+ * ✅ API response formatting
100
+ *
101
+ * ==================================================
102
+ */
103
+ export {};