copilotManagedSettings.ts ×15

Frontier kind: Code frontier

unlabeled · c_867fd01ddfac

12 tests · 12503 LOC · 63 files · introduces 0 tests · 70 LOC · 1 file

Introduces — evidence that enters the hierarchy at this concept

Code
15 ranges70 lines · 1 files
Tests
0 tests

Contains — complete concept membership

All code (extent)
1753 ranges12503 lines · 63 files · Browse complete extent
All tests (intent)
12 testsBrowse complete intent

Neighbourhood graph

The orange circle is the focus. Violet and green circles are every ancestor and descendant, broader and narrower, at any distance; blue squares and pink diamonds are the introduced files and exact introduced tests of every visible concept, not only the focus's. Arrows point from broader to narrower concepts and bridge only concepts omitted from this view. Undirected links show source or test introduction. Concept and file size follows LOC; exact test nodes use test-count units.

Introduced files, introduced tests, and structurally relevant concept specialization

In the embedded map, ordinary wheel input scrolls the page; use the visible controls to zoom and drag to pan. Open the full-screen map for canvas navigation: wheel pans, Ctrl/Command plus wheel zooms, and arrow keys pan when this region is focused. On touch screens, open the full-screen map to pan or pinch. If JavaScript or WebGL is unavailable, use the native relationship evidence on this page.

Graph controls are ready.

Interactive rendering requires JavaScript and WebGL. Use the native relationship evidence on this page while the interactive map is unavailable.

Native relationship evidence

Every exact file and test below is linked only from the concept that introduces it.

Introduced tests

Every collected test enters the hierarchy at exactly one concept.

No tests are introduced at this concept. Its intent tests are introduced by other concepts.

Introduced code

Every collected source range enters the hierarchy at exactly one concept.

1 file ranked by introduced lines: 70 introduced LOC across 15 ranges. Expand a file to inspect source; the > gutter marks introduced lines.

src/vs/platform/policy/common/copilotManagedSettings.ts 70 introduced LOC · 15 ranges

Open complete file

149 }
150
151 > function flattenManagedSettings(object: unknown): Record<string, string | number | boolean> { copilotManagedSettings.ts
152 > const result: Record<string, string | number | boolean> = {};
153 > flattenManagedSettingsValue(object, undefined, result);
154 > return result;
155 > }
156
157 > function flattenManagedSettingsValue(value: unknown, prefix: string | undefined, result: Record<string, string | number | boolean>): void { copilotManagedSettings.ts
158 > if (typeof value === 'string' || typeof value === 'number' || typeof value === 'boolean') {
159 if (prefix !== undefined) {
160 result[prefix] = value;
162 return;
163 }
165 > if (!isManagedSettingsObject(value)) {
166 return;
167 }
169 > for (const key in value) {
170 flattenManagedSettingsValue(value[key], prefix ? `${prefix}.${key}` : key, result);
171 }
173
174 > function isManagedSettingsObject(value: unknown): value is Record<string, unknown> { copilotManagedSettings.ts
175 > return typeof value === 'object' && value !== null && !Array.isArray(value);
176 > }
177
178 /**
391 * Returns `undefined` for a non-object input so the structured key is omitted.
392 */
393 > function encodeStringMap(value: unknown): Record<string, string> | undefined { copilotManagedSettings.ts
394 > if (!isObject(value)) {
395 > return undefined;
396 > }
397 const out: Record<string, string> = {};
398 for (const [k, v] of Object.entries(value)) {
410
411 /** Pass an object value through unchanged; omit the key for any non-object value. */
412 > function encodeObject(value: unknown): object | undefined { copilotManagedSettings.ts
413 > return isObject(value) ? value : undefined;
414 > }
415
416 /** Pass an array value through unchanged (including an empty array); omit the key otherwise. */
417 > function encodeArray(value: unknown): unknown[] | undefined { copilotManagedSettings.ts
418 > return Array.isArray(value) ? value : undefined;
419 > }
420
421 /**
424 * the key when there are none.
425 */
426 > function encodeExtraMarketplaces(value: unknown, onWarn?: (msg: string) => void): Record<string, string> | undefined { copilotManagedSettings.ts
427 > return extraKnownMarketplacesToConfigDict(normalizeExtraKnownMarketplaces(value, onWarn));
428 > }
429
430 const STRUCTURED_MANAGED_SETTINGS: readonly IStructuredManagedSetting[] = [
467 * object. Single-segment keys behave like a plain property read.
468 */
469 > function readNestedManagedKey(obj: Record<string, unknown>, dottedKey: string): unknown { copilotManagedSettings.ts
470 > let current: unknown = obj;
471 > for (const segment of dottedKey.split('.')) {
472 > if (!isObject(current)) {
473 > return undefined;
474 > }
475 > current = (current as Record<string, unknown>)[segment];
476 > }
477 > return current;
478 > }
479
480 /**
484 * an own `__proto__`) without triggering the inherited `__proto__` setter.
485 */
486 > function withNestedManagedKeyDeleted(obj: Record<string, unknown>, dottedKey: string): Record<string, unknown> { copilotManagedSettings.ts
487 > const dot = dottedKey.indexOf('.');
488 > if (dot === -1) {
489 > const clone = { ...obj };
490 > delete clone[dottedKey];
491 > return clone;
492 > }
493 > const head = dottedKey.slice(0, dot);
494 > const child = obj[head];
495 > if (!isObject(child)) {
496 > return obj;
497 > }
498 return { ...obj, [head]: withNestedManagedKeyDeleted(child as Record<string, unknown>, dottedKey.slice(dot + 1)) };
499 }
520 */
521 export function normalizeManagedSettings(parsed: Record<string, unknown>, onWarn?: (msg: string) => void): ManagedSettingsData {
522 > // Spread + delete (not for..in + assignment) so the scalar remainder keeps exact `{ ...rest }` copilotManagedSettings.ts
523 > // semantics: it never triggers the inherited `__proto__` setter for a source-sent own
524 > // `__proto__` key, matching a destructuring rest. Structured keys may be nested (e.g.
525 > // `telemetry.resourceAttributes`), so removal clones only the touched path.
526 > let scalarRest: Record<string, unknown> = { ...parsed };
527 > for (const setting of STRUCTURED_MANAGED_SETTINGS) {
528 > scalarRest = withNestedManagedKeyDeleted(scalarRest, setting.key);
529 > }
530 >
531 > const result: Record<string, ManagedSettingValue> = { ...flattenManagedSettings(scalarRest) };
532 >
533 > for (const setting of STRUCTURED_MANAGED_SETTINGS) {
534 > const encoded = setting.encode(readNestedManagedKey(parsed, setting.key), onWarn);
535 > if (encoded !== undefined) {
536 result[setting.key] = JSON.stringify(encoded);
537 }
539 >
540 > return result;
541 > }
542
543 /**
547 * (with an optional warning via {@link onWarn}).
548 */
549 > function normalizeExtraKnownMarketplaces(value: unknown, onWarn?: (msg: string) => void): IExtraKnownMarketplaceEntry[] | undefined { copilotManagedSettings.ts
550 > if (!isObject(value)) {
551 return undefined;
552 }