@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,224 @@
1
+ import { ConfigurationModel } from '../models/ConfigurationModel';
2
+ /**
3
+ * Utility to extract overrides and keys from configuration data
4
+ *
5
+ * This handles bracket-notation override identifiers like:
6
+ * - [desktop]
7
+ * - [/o/:orgName/vault]
8
+ * - [/o/:orgName/vault][desktop]
9
+ *
10
+ * Reuses existing utilities from configuration.ts:
11
+ * - OVERRIDE_PROPERTY_REGEX: Pattern to match bracket keys
12
+ * - overrideIdentifiersFromKey: Parse identifiers from bracket notation
13
+ */
14
+ export interface ConfigurationOverride {
15
+ identifiers: string[];
16
+ contents: any;
17
+ keys: string[];
18
+ }
19
+ export interface ExtractedConfiguration {
20
+ baseContents: any;
21
+ baseKeys: string[];
22
+ overrides: ConfigurationOverride[];
23
+ }
24
+ /**
25
+ * Check if a key is a bracket-notation override identifier
26
+ * Uses OVERRIDE_PROPERTY_REGEX from configuration.ts
27
+ *
28
+ * @param key - The key to check
29
+ * @returns True if the key matches the override pattern
30
+ *
31
+ * @example
32
+ * ```typescript
33
+ * isBracketKey('[desktop]') // true
34
+ * isBracketKey('[/o/:orgName/vault]') // true
35
+ * isBracketKey('[/route][desktop]') // true
36
+ * isBracketKey('headerBgColor') // false
37
+ * ```
38
+ */
39
+ export declare function isBracketKey(key: string): boolean;
40
+ /**
41
+ * Extract individual identifiers from a bracket key
42
+ * Reuses overrideIdentifiersFromKey from configuration.ts
43
+ * Handles compound identifiers like [/route][desktop]
44
+ *
45
+ * @param key - The bracket key to parse
46
+ * @returns Array of identifiers without brackets
47
+ *
48
+ * @example
49
+ * ```typescript
50
+ * extractIdentifiersFromKey('[desktop]')
51
+ * // Returns: ['desktop']
52
+ *
53
+ * extractIdentifiersFromKey('[/o/:orgName/vault]')
54
+ * // Returns: ['/o/:orgName/vault']
55
+ *
56
+ * extractIdentifiersFromKey('[/o/:orgName/vault][desktop]')
57
+ * // Returns: ['/o/:orgName/vault', 'desktop']
58
+ * ```
59
+ */
60
+ export declare function extractIdentifiersFromKey(key: string): string[];
61
+ /**
62
+ * Extract overrides and base configuration from settings object
63
+ *
64
+ * @param settings - Configuration object that may contain bracket-notation overrides
65
+ * @returns Extracted base contents, keys, and overrides array
66
+ *
67
+ * @example
68
+ * ```typescript
69
+ * const settings = {
70
+ * headerBgColor: "#000000",
71
+ * textColor: "#a19c9c",
72
+ * "[/o/:orgName/vault]": {
73
+ * navTheme: "realDark",
74
+ * primaryColor: "#1890ff"
75
+ * },
76
+ * "[/o/:orgName/pref/settings]": {
77
+ * header: { menuHeaderRender: false }
78
+ * }
79
+ * };
80
+ *
81
+ * const { baseContents, baseKeys, overrides } = extractConfiguration(settings);
82
+ * // baseContents: { headerBgColor: "#000000", textColor: "#a19c9c" }
83
+ * // baseKeys: ["headerBgColor", "textColor"]
84
+ * // overrides: [
85
+ * // { identifiers: ["/o/:orgName/vault"], contents: {...}, keys: [...] },
86
+ * // { identifiers: ["/o/:orgName/pref/settings"], contents: {...}, keys: [...] }
87
+ * // ]
88
+ * ```
89
+ */
90
+ export declare function extractConfiguration(settings: any): ExtractedConfiguration;
91
+ /**
92
+ * Get only the override keys (bracket-notation keys) from settings
93
+ *
94
+ * @param settings - Configuration object
95
+ * @returns Array of bracket keys
96
+ *
97
+ * @example
98
+ * ```typescript
99
+ * const settings = {
100
+ * headerBgColor: "#000000",
101
+ * "[/o/:orgName/vault]": {...},
102
+ * "[desktop]": {...}
103
+ * };
104
+ *
105
+ * getOverrideKeys(settings)
106
+ * // Returns: ['[/o/:orgName/vault]', '[desktop]']
107
+ * ```
108
+ */
109
+ export declare function getOverrideKeys(settings: any): string[];
110
+ /**
111
+ * Get only the base keys (non-bracket keys) from settings
112
+ *
113
+ * @param settings - Configuration object
114
+ * @returns Array of base keys
115
+ *
116
+ * @example
117
+ * ```typescript
118
+ * const settings = {
119
+ * headerBgColor: "#000000",
120
+ * textColor: "#a19c9c",
121
+ * "[/o/:orgName/vault]": {...}
122
+ * };
123
+ *
124
+ * getBaseKeys(settings)
125
+ * // Returns: ['headerBgColor', 'textColor']
126
+ * ```
127
+ */
128
+ export declare function getBaseKeys(settings: any): string[];
129
+ /**
130
+ * Remove all bracket-notation keys from an object
131
+ * Returns a new object with only base properties
132
+ *
133
+ * @param settings - Configuration object
134
+ * @returns New object without bracket keys
135
+ *
136
+ * @example
137
+ * ```typescript
138
+ * const settings = {
139
+ * headerBgColor: "#000000",
140
+ * "[/o/:orgName/vault]": {...},
141
+ * textColor: "#a19c9c"
142
+ * };
143
+ *
144
+ * removeOverrideKeys(settings)
145
+ * // Returns: { headerBgColor: "#000000", textColor: "#a19c9c" }
146
+ * ```
147
+ */
148
+ export declare function removeOverrideKeys(settings: any): any;
149
+ /**
150
+ * Check if settings object has any override identifiers
151
+ *
152
+ * @param settings - Configuration object
153
+ * @returns True if any bracket keys exist
154
+ *
155
+ * @example
156
+ * ```typescript
157
+ * hasOverrides({ headerBgColor: "#000" }) // false
158
+ * hasOverrides({ "[desktop]": {...} }) // true
159
+ * ```
160
+ */
161
+ export declare function hasOverrides(settings: any): boolean;
162
+ /**
163
+ * Get a specific override by identifier
164
+ *
165
+ * @param settings - Configuration object
166
+ * @param identifier - The identifier to search for (without brackets)
167
+ * @returns The override contents or undefined if not found
168
+ *
169
+ * @example
170
+ * ```typescript
171
+ * const settings = {
172
+ * "[/o/:orgName/vault]": { navTheme: "realDark" },
173
+ * "[desktop]": { theme: "dark" }
174
+ * };
175
+ *
176
+ * getOverrideByIdentifier(settings, '/o/:orgName/vault')
177
+ * // Returns: { navTheme: "realDark" }
178
+ *
179
+ * getOverrideByIdentifier(settings, 'desktop')
180
+ * // Returns: { theme: "dark" }
181
+ * ```
182
+ */
183
+ export declare function getOverrideByIdentifier(settings: any, identifier: string): any | undefined;
184
+ /**
185
+ * Convert extracted configuration directly into a ConfigurationModel
186
+ *
187
+ * @param settings - Configuration object with bracket-notation overrides
188
+ * @returns ConfigurationModel instance ready to use
189
+ *
190
+ * @example
191
+ * ```typescript
192
+ * const settings = {
193
+ * theme: "light",
194
+ * "[desktop]": { theme: "dark" },
195
+ * "[/o/:orgName/vault]": { navTheme: "realDark" }
196
+ * };
197
+ *
198
+ * const model = createConfigurationModel(settings);
199
+ * // Now you can use: model.getValue(), model.override('desktop'), etc.
200
+ * ```
201
+ */
202
+ export declare function createConfigurationModel(settings: any): ConfigurationModel;
203
+ /**
204
+ * Extract configuration and return both the extracted data and ConfigurationModel
205
+ *
206
+ * @param settings - Configuration object with bracket-notation overrides
207
+ * @returns Both extracted configuration and ConfigurationModel
208
+ *
209
+ * @example
210
+ * ```typescript
211
+ * const settings = {
212
+ * theme: "light",
213
+ * "[desktop]": { theme: "dark" }
214
+ * };
215
+ *
216
+ * const { extracted, model } = extractConfigurationWithModel(settings);
217
+ * // extracted: { baseContents, baseKeys, overrides }
218
+ * // model: ConfigurationModel instance
219
+ * ```
220
+ */
221
+ export declare function extractConfigurationWithModel(settings: any): {
222
+ extracted: ExtractedConfiguration;
223
+ model: ConfigurationModel;
224
+ };
@@ -0,0 +1,315 @@
1
+ import {OVERRIDE_PROPERTY_REGEX,overrideIdentifiersFromKey}from'../configuration.js';import {ConfigurationModel}from'../models/ConfigurationModel.js';/* eslint-disable @typescript-eslint/no-explicit-any */
2
+ // ============================================================================
3
+ // Core Utility Functions (Reusing existing utilities)
4
+ // ============================================================================
5
+ /**
6
+ * Check if a key is a bracket-notation override identifier
7
+ * Uses OVERRIDE_PROPERTY_REGEX from configuration.ts
8
+ *
9
+ * @param key - The key to check
10
+ * @returns True if the key matches the override pattern
11
+ *
12
+ * @example
13
+ * ```typescript
14
+ * isBracketKey('[desktop]') // true
15
+ * isBracketKey('[/o/:orgName/vault]') // true
16
+ * isBracketKey('[/route][desktop]') // true
17
+ * isBracketKey('headerBgColor') // false
18
+ * ```
19
+ */
20
+ function isBracketKey(key) {
21
+ return OVERRIDE_PROPERTY_REGEX.test(key);
22
+ }
23
+ /**
24
+ * Extract individual identifiers from a bracket key
25
+ * Reuses overrideIdentifiersFromKey from configuration.ts
26
+ * Handles compound identifiers like [/route][desktop]
27
+ *
28
+ * @param key - The bracket key to parse
29
+ * @returns Array of identifiers without brackets
30
+ *
31
+ * @example
32
+ * ```typescript
33
+ * extractIdentifiersFromKey('[desktop]')
34
+ * // Returns: ['desktop']
35
+ *
36
+ * extractIdentifiersFromKey('[/o/:orgName/vault]')
37
+ * // Returns: ['/o/:orgName/vault']
38
+ *
39
+ * extractIdentifiersFromKey('[/o/:orgName/vault][desktop]')
40
+ * // Returns: ['/o/:orgName/vault', 'desktop']
41
+ * ```
42
+ */
43
+ function extractIdentifiersFromKey(key) {
44
+ return overrideIdentifiersFromKey(key);
45
+ }
46
+ /**
47
+ * Extract overrides and base configuration from settings object
48
+ *
49
+ * @param settings - Configuration object that may contain bracket-notation overrides
50
+ * @returns Extracted base contents, keys, and overrides array
51
+ *
52
+ * @example
53
+ * ```typescript
54
+ * const settings = {
55
+ * headerBgColor: "#000000",
56
+ * textColor: "#a19c9c",
57
+ * "[/o/:orgName/vault]": {
58
+ * navTheme: "realDark",
59
+ * primaryColor: "#1890ff"
60
+ * },
61
+ * "[/o/:orgName/pref/settings]": {
62
+ * header: { menuHeaderRender: false }
63
+ * }
64
+ * };
65
+ *
66
+ * const { baseContents, baseKeys, overrides } = extractConfiguration(settings);
67
+ * // baseContents: { headerBgColor: "#000000", textColor: "#a19c9c" }
68
+ * // baseKeys: ["headerBgColor", "textColor"]
69
+ * // overrides: [
70
+ * // { identifiers: ["/o/:orgName/vault"], contents: {...}, keys: [...] },
71
+ * // { identifiers: ["/o/:orgName/pref/settings"], contents: {...}, keys: [...] }
72
+ * // ]
73
+ * ```
74
+ */
75
+ function extractConfiguration(settings) {
76
+ const baseContents = {};
77
+ const overrides = [];
78
+ if (!settings || typeof settings !== 'object') {
79
+ return {
80
+ baseContents: {},
81
+ baseKeys: [],
82
+ overrides: []
83
+ };
84
+ }
85
+ // Iterate through all keys in the settings object
86
+ Object.keys(settings).forEach(key => {
87
+ if (isBracketKey(key)) {
88
+ // This is a bracket override: [device] or [/route][device]
89
+ const overrideData = settings[key];
90
+ const identifiers = extractIdentifiersFromKey(key);
91
+ overrides.push({
92
+ identifiers,
93
+ contents: overrideData,
94
+ keys: Object.keys(overrideData || {})
95
+ });
96
+ } else {
97
+ // Base settings (flat, no wrapper)
98
+ baseContents[key] = settings[key];
99
+ }
100
+ });
101
+ const baseKeys = Object.keys(baseContents);
102
+ return {
103
+ baseContents,
104
+ baseKeys,
105
+ overrides
106
+ };
107
+ }
108
+ // ============================================================================
109
+ // Additional Helper Functions
110
+ // ============================================================================
111
+ /**
112
+ * Get only the override keys (bracket-notation keys) from settings
113
+ *
114
+ * @param settings - Configuration object
115
+ * @returns Array of bracket keys
116
+ *
117
+ * @example
118
+ * ```typescript
119
+ * const settings = {
120
+ * headerBgColor: "#000000",
121
+ * "[/o/:orgName/vault]": {...},
122
+ * "[desktop]": {...}
123
+ * };
124
+ *
125
+ * getOverrideKeys(settings)
126
+ * // Returns: ['[/o/:orgName/vault]', '[desktop]']
127
+ * ```
128
+ */
129
+ function getOverrideKeys(settings) {
130
+ if (!settings || typeof settings !== 'object') {
131
+ return [];
132
+ }
133
+ return Object.keys(settings).filter(isBracketKey);
134
+ }
135
+ /**
136
+ * Get only the base keys (non-bracket keys) from settings
137
+ *
138
+ * @param settings - Configuration object
139
+ * @returns Array of base keys
140
+ *
141
+ * @example
142
+ * ```typescript
143
+ * const settings = {
144
+ * headerBgColor: "#000000",
145
+ * textColor: "#a19c9c",
146
+ * "[/o/:orgName/vault]": {...}
147
+ * };
148
+ *
149
+ * getBaseKeys(settings)
150
+ * // Returns: ['headerBgColor', 'textColor']
151
+ * ```
152
+ */
153
+ function getBaseKeys(settings) {
154
+ if (!settings || typeof settings !== 'object') {
155
+ return [];
156
+ }
157
+ return Object.keys(settings).filter(key => !isBracketKey(key));
158
+ }
159
+ /**
160
+ * Remove all bracket-notation keys from an object
161
+ * Returns a new object with only base properties
162
+ *
163
+ * @param settings - Configuration object
164
+ * @returns New object without bracket keys
165
+ *
166
+ * @example
167
+ * ```typescript
168
+ * const settings = {
169
+ * headerBgColor: "#000000",
170
+ * "[/o/:orgName/vault]": {...},
171
+ * textColor: "#a19c9c"
172
+ * };
173
+ *
174
+ * removeOverrideKeys(settings)
175
+ * // Returns: { headerBgColor: "#000000", textColor: "#a19c9c" }
176
+ * ```
177
+ */
178
+ function removeOverrideKeys(settings) {
179
+ if (!settings || typeof settings !== 'object') {
180
+ return {};
181
+ }
182
+ const result = {};
183
+ Object.keys(settings).forEach(key => {
184
+ if (!isBracketKey(key)) {
185
+ result[key] = settings[key];
186
+ }
187
+ });
188
+ return result;
189
+ }
190
+ /**
191
+ * Check if settings object has any override identifiers
192
+ *
193
+ * @param settings - Configuration object
194
+ * @returns True if any bracket keys exist
195
+ *
196
+ * @example
197
+ * ```typescript
198
+ * hasOverrides({ headerBgColor: "#000" }) // false
199
+ * hasOverrides({ "[desktop]": {...} }) // true
200
+ * ```
201
+ */
202
+ function hasOverrides(settings) {
203
+ if (!settings || typeof settings !== 'object') {
204
+ return false;
205
+ }
206
+ return Object.keys(settings).some(isBracketKey);
207
+ }
208
+ /**
209
+ * Get a specific override by identifier
210
+ *
211
+ * @param settings - Configuration object
212
+ * @param identifier - The identifier to search for (without brackets)
213
+ * @returns The override contents or undefined if not found
214
+ *
215
+ * @example
216
+ * ```typescript
217
+ * const settings = {
218
+ * "[/o/:orgName/vault]": { navTheme: "realDark" },
219
+ * "[desktop]": { theme: "dark" }
220
+ * };
221
+ *
222
+ * getOverrideByIdentifier(settings, '/o/:orgName/vault')
223
+ * // Returns: { navTheme: "realDark" }
224
+ *
225
+ * getOverrideByIdentifier(settings, 'desktop')
226
+ * // Returns: { theme: "dark" }
227
+ * ```
228
+ */
229
+ function getOverrideByIdentifier(settings, identifier) {
230
+ if (!settings || typeof settings !== 'object' || !identifier) {
231
+ return undefined;
232
+ }
233
+ // Try exact match with brackets
234
+ const exactKey = `[${identifier}]`;
235
+ if (settings[exactKey]) {
236
+ return settings[exactKey];
237
+ }
238
+ // Try finding in compound keys
239
+ for (const key of Object.keys(settings)) {
240
+ if (isBracketKey(key)) {
241
+ const identifiers = extractIdentifiersFromKey(key);
242
+ if (identifiers.includes(identifier)) {
243
+ return settings[key];
244
+ }
245
+ }
246
+ }
247
+ return undefined;
248
+ }
249
+ // ============================================================================
250
+ // ConfigurationModel Creation
251
+ // ============================================================================
252
+ /**
253
+ * Convert extracted configuration directly into a ConfigurationModel
254
+ *
255
+ * @param settings - Configuration object with bracket-notation overrides
256
+ * @returns ConfigurationModel instance ready to use
257
+ *
258
+ * @example
259
+ * ```typescript
260
+ * const settings = {
261
+ * theme: "light",
262
+ * "[desktop]": { theme: "dark" },
263
+ * "[/o/:orgName/vault]": { navTheme: "realDark" }
264
+ * };
265
+ *
266
+ * const model = createConfigurationModel(settings);
267
+ * // Now you can use: model.getValue(), model.override('desktop'), etc.
268
+ * ```
269
+ */
270
+ function createConfigurationModel(settings) {
271
+ const {
272
+ baseContents,
273
+ baseKeys,
274
+ overrides
275
+ } = extractConfiguration(settings);
276
+ // Convert our ConfigurationOverride format to IOverrides format
277
+ const iOverrides = overrides.map(override => ({
278
+ identifiers: override.identifiers,
279
+ keys: override.keys,
280
+ contents: override.contents
281
+ }));
282
+ // Create and return ConfigurationModel
283
+ return new ConfigurationModel(baseContents, baseKeys, iOverrides);
284
+ }
285
+ /**
286
+ * Extract configuration and return both the extracted data and ConfigurationModel
287
+ *
288
+ * @param settings - Configuration object with bracket-notation overrides
289
+ * @returns Both extracted configuration and ConfigurationModel
290
+ *
291
+ * @example
292
+ * ```typescript
293
+ * const settings = {
294
+ * theme: "light",
295
+ * "[desktop]": { theme: "dark" }
296
+ * };
297
+ *
298
+ * const { extracted, model } = extractConfigurationWithModel(settings);
299
+ * // extracted: { baseContents, baseKeys, overrides }
300
+ * // model: ConfigurationModel instance
301
+ * ```
302
+ */
303
+ function extractConfigurationWithModel(settings) {
304
+ const extracted = extractConfiguration(settings);
305
+ const iOverrides = extracted.overrides.map(override => ({
306
+ identifiers: override.identifiers,
307
+ keys: override.keys,
308
+ contents: override.contents
309
+ }));
310
+ const model = new ConfigurationModel(extracted.baseContents, extracted.baseKeys, iOverrides);
311
+ return {
312
+ extracted,
313
+ model
314
+ };
315
+ }export{createConfigurationModel,extractConfiguration,extractConfigurationWithModel,extractIdentifiersFromKey,getBaseKeys,getOverrideByIdentifier,getOverrideKeys,hasOverrides,isBracketKey,removeOverrideKeys};//# sourceMappingURL=configurationExtractor.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"configurationExtractor.js","sources":["../../../../src/core/configurations/utils/configurationExtractor.ts"],"sourcesContent":[null],"names":[],"mappings":"sJAAA;AA+BA;AACA;AACA;AAEA;;;;;;;;;;;;;;AAcG;AACG,SAAU,YAAY,CAAC,GAAW,EAAA;AACpC,EAAA,OAAA,4BAA+B,CAAA,GAAK,CAAA;AACxC;AAEA;;;;;;;;;;;;;;;;;;;AAmBG;AACG,SAAU,yBAAyB,CAAC,GAAW,EAAA;AACjD,EAAA,OAAA,0BAAO,CAAA,GAA2B,CAAA;AACtC;AAEA;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4BG;AACG,SAAU,oBAAoB,CAAC,QAAa,EAAA;QAC9C,YAAM,GAAY,EAAQ;QAC1B,SAAM,GAAS,EAA4B;MAE3C,CAAA,YAAa,OAAI,aAAe,QAAK,EAAQ;WACzC;AACI,MAAA,YAAA,EAAA,EAAA;AACA,MAAA,QAAA,EAAA,EAAA;AACA,MAAA,SAAA,EAAA;;;;QAKR,CAAA,IAAO,CAAA,QAAK,CAAA,CAAQ,OAAE,CAAA,GAAS,IAAG;AAC9B,IAAA,IAAA,YAAI,CAAA,GAAY,CAAC,EAAA;;AAEb,MAAA,MAAA,uBAAqB,CAAA,GAAA,CAAA;AACrB,MAAA,MAAA,uCAAoB,CAAA,GAAA,CAAA;eAEpB,CAAA,IAAA,CAAS;mB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AAA,SAAS,CAAA,SAAQ,CAAA,GAAA,CAAA,QAAA,KAAA;AAC9B,IAAA,WAAG,EAAA,QAAA,CAAA,WAAA;AAEJ,IAAA,IAAA,EAAM,QAAQ,CAAA,IAAI;AAElB,IAAA,QAAO,EAAE,QAAS,CAAA;AACtB,GAAC,CAAA,CAAA;;;;;;"}
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Configuration utilities index
3
+ * Exports all utility functions for working with configuration data
4
+ */
5
+ export { ConfigurationOverride, ExtractedConfiguration, extractConfiguration, isBracketKey, extractIdentifiersFromKey, getOverrideKeys, getBaseKeys, removeOverrideKeys, hasOverrides, getOverrideByIdentifier, createConfigurationModel, extractConfigurationWithModel, } from './configurationExtractor';
@@ -0,0 +1,36 @@
1
+ /**
2
+ * Usage Examples: ConfigurationModel Creation Functions
3
+ *
4
+ * Demonstrates how to use createConfigurationModel() and extractConfigurationWithModel()
5
+ * to work with ConfigurationModel from raw settings data.
6
+ */
7
+ /**
8
+ * The simplest way to create a ConfigurationModel from settings.
9
+ * Use this when you just need a model and don't care about raw extraction data.
10
+ */
11
+ declare function example1_quickModelCreation(): void;
12
+ /**
13
+ * Convert server configuration response to ConfigurationModel
14
+ * for client-side configuration management.
15
+ */
16
+ declare function example2_serverResponseProcessing(): Promise<void>;
17
+ /**
18
+ * Use extractConfigurationWithModel when you need both:
19
+ * - Raw extraction data (for inspection, logging, debugging)
20
+ * - ConfigurationModel (for application logic)
21
+ */
22
+ declare function example3_dualPurpose(): void;
23
+ /**
24
+ * Validate configuration structure and apply business logic.
25
+ */
26
+ declare function example4_configurationValidation(): void;
27
+ /**
28
+ * Merge multiple configuration sources using ConfigurationModel.
29
+ */
30
+ declare function example5_configurationMerging(): void;
31
+ /**
32
+ * Handle dynamic route-based configuration in a web application.
33
+ */
34
+ declare function example6_dynamicRouteConfiguration(): void;
35
+ declare function example7_typeSafeConfiguration(): void;
36
+ export { example1_quickModelCreation, example2_serverResponseProcessing, example3_dualPurpose, example4_configurationValidation, example5_configurationMerging, example6_dynamicRouteConfiguration, example7_typeSafeConfiguration, };
@@ -0,0 +1,54 @@
1
+ /**
2
+ * Integration Example: In your preferences-service.ts
3
+ */
4
+ export declare function getPageSettings(_configKey: string, _overrideIdentifier: string, _strict: boolean): Promise<any>;
5
+ /**
6
+ * Benefits of using the utility:
7
+ *
8
+ * 1. ✅ Reuses existing OVERRIDE_PROPERTY_REGEX (consistent with parser)
9
+ * 2. ✅ Reuses existing overrideIdentifiersFromKey (handles compound keys properly)
10
+ * 3. ✅ One line instead of ~20 lines of inline logic
11
+ * 4. ✅ Tested and documented
12
+ * 5. ✅ Can be reused across your codebase
13
+ * 6. ✅ Properly handles edge cases (null, empty, compound identifiers)
14
+ * 7. ✅ TypeScript typed
15
+ * 8. ✅ Maintains same output structure
16
+ */
17
+ /**
18
+ * Your original commented code vs utility:
19
+ */
20
+ export declare function comparison(): void;
21
+ /**
22
+ * Complete integration example for preferences-service.ts
23
+ */
24
+ export declare class PreferencesServiceExample {
25
+ getPageSettings(targets: string[], configKey?: string, overrideIdentifier?: string, strict?: boolean): Promise<{
26
+ contents: any;
27
+ keys: string[];
28
+ overrides: {
29
+ identifiers: string[];
30
+ contents: any;
31
+ }[];
32
+ }>;
33
+ }
34
+ /**
35
+ * Quick reference for your use case:
36
+ *
37
+ * REPLACE THIS:
38
+ * -------------
39
+ * const baseContents: any = {};
40
+ * const overrides: any[] = [];
41
+ * Object.keys(cleanedSettings).forEach((key) => {
42
+ * if (key.startsWith('[') && key.endsWith(']')) {
43
+ * const overrideData = cleanedSettings[key];
44
+ * overrides.push({ identifiers: [key], contents: overrideData, keys: Object.keys(overrideData) });
45
+ * } else {
46
+ * baseContents[key] = cleanedSettings[key];
47
+ * }
48
+ * });
49
+ *
50
+ * WITH THIS:
51
+ * ----------
52
+ * import { extractConfiguration } from '@adminide/core/configurations/utils';
53
+ * const { baseContents, overrides } = extractConfiguration(cleanedSettings);
54
+ */
@@ -0,0 +1,39 @@
1
+ /**
2
+ * Example 1: Basic Extraction
3
+ * Extract base configuration and overrides
4
+ */
5
+ export declare function example1_BasicExtraction(): void;
6
+ /**
7
+ * Example 2: Working with Base Configuration
8
+ * Get and manipulate base configuration
9
+ */
10
+ export declare function example2_BaseConfiguration(): void;
11
+ /**
12
+ * Example 3: Route-Specific Configuration
13
+ * Get configuration for a specific route
14
+ */
15
+ export declare function example3_RouteConfiguration(): void;
16
+ /**
17
+ * Example 4: Checking and Filtering
18
+ * Various utility functions
19
+ */
20
+ export declare function example4_CheckingFiltering(): void;
21
+ /**
22
+ * Example 5: Parsing Identifiers
23
+ * Extract identifiers from bracket keys
24
+ */
25
+ export declare function example5_ParsingIdentifiers(): void;
26
+ /**
27
+ * Example 6: Lazy Loading Pattern
28
+ * Load configuration once, apply overrides as needed
29
+ */
30
+ export declare function example6_LazyLoadingPattern(): void;
31
+ /**
32
+ * Example 7: Configuration Merging
33
+ * Merge multiple configuration sources
34
+ */
35
+ export declare function example7_ConfigurationMerging(): void;
36
+ /**
37
+ * Run all examples
38
+ */
39
+ export declare function runAllExamples(): void;