Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
55 commits
Select commit Hold shift + click to select a range
8c69358
[js-yaml to yaml migration] Migrate @elastic/fleet files\n\nMigrate f…
jeramysoucy Feb 9, 2026
3bedfd2
Reduces complexity of agent policy to yaml
jeramysoucy Feb 10, 2026
de3d418
Fixes two replacements missed by Cursor
jeramysoucy Feb 10, 2026
451035d
Changes from node scripts/eslint_all_files --no-cache --fix
kibanamachine Feb 10, 2026
03e3dd1
Fixes another Cursor miss
jeramysoucy Feb 10, 2026
301acac
Increases bundle limit for the Fleet plugin
jeramysoucy Feb 10, 2026
c43f145
Resolve unit test failures
jeramysoucy Feb 10, 2026
0170d6f
Removes unused function input
jeramysoucy Feb 11, 2026
e859566
Resolves parsing differences from js-yaml
jeramysoucy Feb 13, 2026
b82d38f
Update YAML output formatting in getTemplateInputs and addCommentsToY…
jeramysoucy Feb 16, 2026
b8210e3
Fix error message formatting in parseAndVerifyArchive function to ens…
jeramysoucy Feb 17, 2026
fab2c15
Update contentForInstallation formatting to use single quotes
jeramysoucy Feb 17, 2026
51bdcb3
Updates error check based on review feedback
jeramysoucy Feb 17, 2026
99c8c13
Modularizes toYaml functionality in fullAgentConfigMapToYaml and full…
jeramysoucy Feb 18, 2026
ff5853e
Replaces import of toYaml with mock function in test file
jeramysoucy Feb 18, 2026
521de77
Implements async loading of yaml
jeramysoucy Feb 27, 2026
6fba99c
Changes from node scripts/generate codeowners
kibanamachine Feb 27, 2026
a823a22
Changes from node scripts/regenerate_moon_projects.js --update
kibanamachine Feb 27, 2026
a8620cf
Removes new usage of js-yaml
jeramysoucy Feb 27, 2026
49e3883
Updates flyout to remove js-yaml - lost change
jeramysoucy Feb 27, 2026
9701265
Fixes type issues
jeramysoucy Mar 11, 2026
c194741
Fixes moon file for new package
jeramysoucy Mar 13, 2026
ce8c12a
Fixes jest integration test failures
jeramysoucy Mar 13, 2026
04b4802
Updates async loading to cache module
jeramysoucy Mar 16, 2026
b0f6c79
Updates cypress test code to account for async loading
jeramysoucy Mar 17, 2026
daba1c1
Update initialization in package policy input panel
jeramysoucy Mar 18, 2026
b6d4fca
Monaco editor test changes to address timeout failures
jeramysoucy Mar 24, 2026
7e3cbfc
Address qa feedback
jeramysoucy Mar 25, 2026
a3e1bb8
Resolves advanced yaml settings issue
jeramysoucy Apr 1, 2026
973357d
Add meta IDs to fleet output schemas for named OAS components (#258986)
TinaHeiligers Mar 26, 2026
267fb83
[ResponseOps][Alerting] Alerting v2 (#247464)
cnasikas Mar 27, 2026
6b52805
[Agent Builder] Add attachment origin to Converse API (#259043)
machadoum Mar 31, 2026
7bec125
[Fleet] Update doc links in agent policy settings (#260245)
criamico Mar 31, 2026
8ce27a1
[Observability:Streams] Add await for monaco code editor to fix query…
couvq Mar 31, 2026
69fda14
Merge branch 'main' into migrate-js-yaml-to-yaml--elastic-fleet
jeramysoucy Apr 1, 2026
d87ef12
Changes from node scripts/lint.js --fix
kibanamachine Apr 1, 2026
a4e8274
Reverts bad merge changes
jeramysoucy Apr 1, 2026
aebda7f
Merge branch 'main' into migrate-js-yaml-to-yaml--elastic-fleet
jeramysoucy Apr 1, 2026
389bb00
Fix duplicate import
jeramysoucy Apr 1, 2026
55bf994
Changes from node scripts/regenerate_moon_projects.js --update
kibanamachine Apr 1, 2026
0cbac49
Addresses review feedback
jeramysoucy Apr 2, 2026
012d1f5
Merge branch 'main' into migrate-js-yaml-to-yaml--elastic-fleet
jeramysoucy Apr 2, 2026
8acce6a
Merge branch 'main' into migrate-js-yaml-to-yaml--elastic-fleet
jeramysoucy Apr 8, 2026
a31c485
Resolves test failure
jeramysoucy Apr 8, 2026
57c433b
Merge branch 'main' into migrate-js-yaml-to-yaml--elastic-fleet
jeramysoucy Apr 8, 2026
f1991b3
Merge branch 'main' into migrate-js-yaml-to-yaml--elastic-fleet
jeramysoucy Apr 8, 2026
6511b6e
Fix validateYamlConfig ReferenceError in otelExporterConfigInput
jeramysoucy Apr 8, 2026
0b674f3
Resolves bad merge
jeramysoucy Apr 8, 2026
789c915
Merge branch 'main' into migrate-js-yaml-to-yaml--elastic-fleet
jeramysoucy Apr 8, 2026
0520857
Removes unused variable
jeramysoucy Apr 8, 2026
6b5a79a
Merge branch 'main' into migrate-js-yaml-to-yaml--elastic-fleet
jeramysoucy Apr 9, 2026
bdfa1f5
Merge branch 'main' into migrate-js-yaml-to-yaml--elastic-fleet
jeramysoucy Apr 9, 2026
308057c
Removes unused transaltions
jeramysoucy Apr 9, 2026
c6fcf53
Merge branch 'main' into migrate-js-yaml-to-yaml--elastic-fleet
jeramysoucy Apr 9, 2026
d03d926
Merge branch 'main' into migrate-js-yaml-to-yaml--elastic-fleet
jeramysoucy Apr 14, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/CODEOWNERS
Original file line number Diff line number Diff line change
Expand Up @@ -693,6 +693,7 @@ src/platform/packages/shared/kbn-workflows @elastic/workflows-eng
src/platform/packages/shared/kbn-workflows-ui @elastic/workflows-eng
src/platform/packages/shared/kbn-workspaces @elastic/observability-ui
src/platform/packages/shared/kbn-xstate-utils @elastic/obs-onboarding-team
src/platform/packages/shared/kbn-yaml-loader @elastic/fleet
src/platform/packages/shared/kbn-zod @elastic/kibana-core
src/platform/packages/shared/kbn-zod-helpers @elastic/security-detection-rule-management
src/platform/packages/shared/presentation/presentation_publishing @elastic/kibana-presentation
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -1243,6 +1243,7 @@
"@kbn/workflows-ui": "link:src/platform/packages/shared/kbn-workflows-ui",
"@kbn/workplace-ai-app": "link:x-pack/solutions/workplaceai/plugins/workplace_ai_app",
"@kbn/xstate-utils": "link:src/platform/packages/shared/kbn-xstate-utils",
"@kbn/yaml-loader": "link:src/platform/packages/shared/kbn-yaml-loader",
"@kbn/yaml-rule-editor": "link:x-pack/platform/packages/shared/response-ops/yaml-rule-editor",
"@kbn/zod": "link:src/platform/packages/shared/kbn-zod",
"@kbn/zod-helpers": "link:src/platform/packages/shared/kbn-zod-helpers",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
*/

import type { Locator } from '@playwright/test';
import { expect } from '@playwright/test';
import type { ScoutPage } from '..';
import { expect } from '../../../ui';

/**
* Page object that wraps common interactions with the Kibana Monaco-based code editor.
Expand Down Expand Up @@ -40,28 +40,34 @@ export class KibanaCodeEditorWrapper {
* an empty string is returned.
*/
async getCodeEditorValue(nthIndex: number = 0): Promise<string> {
return await this.page.evaluate((index) => {
const monacoEnv = (window as any).MonacoEnvironment;
let result = '';

if (!monacoEnv?.monaco?.editor) {
throw new Error('MonacoEnvironment.monaco.editor is not available');
}
await expect(async () => {
result = await this.page.evaluate((index) => {
const monacoEnv = (window as any).MonacoEnvironment;

if (!monacoEnv?.monaco?.editor) {
throw new Error('MonacoEnvironment.monaco.editor is not available');
}

const values: string[] = monacoEnv.monaco.editor
.getModels()
.map((model: any) => model.getValue() as string);

const values: string[] = monacoEnv.monaco.editor
.getModels()
.map((model: any) => model.getValue() as string);
if (!values.length) {
return '';
}

if (!values.length) {
return '';
}
if (index >= 0 && index < values.length) {
return values[index]!;
}

if (index >= 0 && index < values.length) {
return values[index]!;
}
// Fallback to the first model value if the requested index is out of range
return values[0]!;
}, nthIndex);
}).toPass({ timeout: 30_000 });
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This might be overkill


// Fallback to the first model value if the requested index is out of range
return values[0]!;
}, nthIndex);
return result;
}

/**
Expand Down
11 changes: 11 additions & 0 deletions src/platform/packages/shared/kbn-yaml-loader/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the "Elastic License
* 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side
* Public License v 1"; you may not use this file except in compliance with, at
* your election, the "Elastic License 2.0", the "GNU Affero General Public
* License v3.0 only", or the "Server Side Public License, v 1".
*/

export { loadYaml } from './src/load_yaml';
export type { Document, Pair } from './src/types';
8 changes: 8 additions & 0 deletions src/platform/packages/shared/kbn-yaml-loader/kibana.jsonc
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"type": "shared-common",
"id": "@kbn/yaml-loader",
"owner": ["@elastic/fleet"],
"group": "platform",
"visibility": "shared",
"description": "Async loader for the yaml package to enable code-splitting and reduce initial bundle size"
}
32 changes: 32 additions & 0 deletions src/platform/packages/shared/kbn-yaml-loader/moon.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# This file is generated by the @kbn/moon package. Any manual edits will be erased!
# To extend this, write your extensions/overrides to 'moon.extend.yml'
# then regenerate this file with: 'node scripts/regenerate_moon_projects.js --update --filter @kbn/yaml-loader'

$schema: https://moonrepo.dev/schemas/project.json
id: '@kbn/yaml-loader'
layer: unknown
owners:
defaultOwner: '@elastic/fleet'
toolchains:
default: node
javascript:
rootPackageDependenciesOnly: false
language: typescript
project:
title: '@kbn/yaml-loader'
description: Moon project for @kbn/yaml-loader
channel: ''
owner: '@elastic/fleet'
sourceRoot: src/platform/packages/shared/kbn-yaml-loader
dependsOn: []
tags:
- shared-common
- package
- prod
- group-platform
- shared
fileGroups:
src:
- '**/*.ts'
- '!target/**/*'
tasks: {}
11 changes: 11 additions & 0 deletions src/platform/packages/shared/kbn-yaml-loader/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"name": "@kbn/yaml-loader",
"private": true,
"version": "1.0.0",
"license": "Elastic License 2.0 OR AGPL-3.0-only OR SSPL-1.0",
"main": "index.ts",
"types": "index.ts",
"dependencies": {
"yaml": "2.8.1"
}
}
17 changes: 17 additions & 0 deletions src/platform/packages/shared/kbn-yaml-loader/src/load_yaml.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the "Elastic License
* 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side
* Public License v 1"; you may not use this file except in compliance with, at
* your election, the "Elastic License 2.0", the "GNU Affero General Public
* License v3.0 only", or the "Server Side Public License, v 1".
*/

/**
* Loads the yaml package asynchronously. Use this in browser code to avoid
* pulling the full yaml library into the initial bundle.
* The returned promise resolves to the yaml module (parse, stringify, Document, etc.).
*/
export const loadYaml = (): Promise<typeof import('yaml')> => {
return import('yaml');
};
14 changes: 14 additions & 0 deletions src/platform/packages/shared/kbn-yaml-loader/src/types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the "Elastic License
* 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side
* Public License v 1"; you may not use this file except in compliance with, at
* your election, the "Elastic License 2.0", the "GNU Affero General Public
* License v3.0 only", or the "Server Side Public License, v 1".
*/

/**
* Type-only re-exports from the yaml package so consumers can type their APIs
* without pulling in the runtime. Use loadYaml() for runtime usage.
*/
export type { Document, Pair } from 'yaml';
10 changes: 10 additions & 0 deletions src/platform/packages/shared/kbn-yaml-loader/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"extends": "@kbn/tsconfig-base/tsconfig.json",
"compilerOptions": {
"outDir": "target/types",
"types": ["node"]
},
"include": ["**/*.ts"],
"exclude": ["target/**/*"],
"kbn_references": []
}
2 changes: 2 additions & 0 deletions tsconfig.base.json
Original file line number Diff line number Diff line change
Expand Up @@ -2642,6 +2642,8 @@
"@kbn/workspaces/*": ["src/platform/packages/shared/kbn-workspaces/*"],
"@kbn/xstate-utils": ["src/platform/packages/shared/kbn-xstate-utils"],
"@kbn/xstate-utils/*": ["src/platform/packages/shared/kbn-xstate-utils/*"],
"@kbn/yaml-loader": ["src/platform/packages/shared/kbn-yaml-loader"],
"@kbn/yaml-loader/*": ["src/platform/packages/shared/kbn-yaml-loader/*"],
"@kbn/yaml-rule-editor": ["x-pack/platform/packages/shared/response-ops/yaml-rule-editor"],
"@kbn/yaml-rule-editor/*": ["x-pack/platform/packages/shared/response-ops/yaml-rule-editor/*"],
"@kbn/yarn-install-scripts": ["packages/kbn-yarn-install-scripts"],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,30 +5,14 @@
* 2.0.
*/

import type { dump } from 'js-yaml';

import type { FullAgentConfigMap } from '../types/models/agent_cm';

const CM_KEYS_ORDER = ['apiVersion', 'kind', 'metadata', 'data'];

export const fullAgentConfigMapToYaml = (
policy: FullAgentConfigMap,
toYaml: typeof dump
): string => {
return toYaml(policy, {
skipInvalid: true,
sortKeys: (keyA: string, keyB: string) => {
const indexA = CM_KEYS_ORDER.indexOf(keyA);
const indexB = CM_KEYS_ORDER.indexOf(keyB);
if (indexA >= 0 && indexB < 0) {
return -1;
}
import type { YamlModule } from './yaml_utils';
import { createYamlKeysSorter, toYaml } from './yaml_utils';

if (indexA < 0 && indexB >= 0) {
return 1;
}
const CM_KEYS_ORDER = ['apiVersion', 'kind', 'metadata', 'data'];

return indexA - indexB;
},
});
export const fullAgentConfigMapToYaml = (policy: FullAgentConfigMap, yaml: YamlModule): string => {
const sortCmKeys = createYamlKeysSorter(CM_KEYS_ORDER, yaml);
return toYaml(policy, { sortMapEntries: sortCmKeys, strict: false }, yaml);
};
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,20 @@ import type { FullAgentPolicy } from '../types';

import { fullAgentPolicyToYaml } from './full_agent_policy_to_yaml';

// Mock yaml module for testing (matches YamlModule shape)
const mockYaml = {
Document: class {
private data: unknown;
constructor(data: unknown) {
this.data = data;
}
toString() {
return JSON.stringify(this.data);
}
},
isScalar: () => true,
};

describe('fullAgentPolicyToYaml', () => {
it('should replace secrets', () => {
const agentPolicyWithSecrets = {
Expand Down Expand Up @@ -45,9 +59,9 @@ describe('fullAgentPolicyToYaml', () => {
fleet: {},
} as unknown as FullAgentPolicy;

const yaml = fullAgentPolicyToYaml(agentPolicyWithSecrets, (policy) => JSON.stringify(policy));
const result = fullAgentPolicyToYaml(agentPolicyWithSecrets, mockYaml);

expect(yaml).toMatchInlineSnapshot(
expect(result).toMatchInlineSnapshot(
`"{\\"id\\":\\"1234\\",\\"outputs\\":{\\"default\\":{\\"type\\":\\"elasticsearch\\",\\"hosts\\":[\\"http://localhost:9200\\"]}},\\"inputs\\":[{\\"id\\":\\"test_input-secrets-abcd1234\\",\\"revision\\":1,\\"name\\":\\"secrets-1\\",\\"type\\":\\"test_input\\",\\"data_stream\\":{\\"namespace\\":\\"default\\"},\\"use_output\\":\\"default\\",\\"package_policy_id\\":\\"abcd1234\\",\\"package_var_secret\\":\\"\${SECRET_0}\\",\\"input_var_secret\\":\\"\${SECRET_1}\\",\\"streams\\":[{\\"id\\":\\"test_input-secrets.log-abcd1234\\",\\"data_stream\\":{\\"type\\":\\"logs\\",\\"dataset\\":\\"secrets.log\\"},\\"package_var_secret\\":\\"\${SECRET_0}\\",\\"input_var_secret\\":\\"\${SECRET_1}\\",\\"stream_var_secret\\":\\"\${SECRET_2}\\"}],\\"meta\\":{\\"package\\":{\\"name\\":\\"secrets\\",\\"version\\":\\"1.0.0\\"}}}],\\"secret_references\\":[{\\"id\\":\\"secret-id-1\\"},{\\"id\\":\\"secret-id-2\\"},{\\"id\\":\\"secret-id-3\\"}],\\"revision\\":2,\\"agent\\":{},\\"signed\\":{},\\"output_permissions\\":{},\\"fleet\\":{}}"`
);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,11 @@
* 2.0.
*/

import type { dump } from 'js-yaml';

import type { FullAgentPolicy } from '../types';

import type { YamlModule } from './yaml_utils';
import { createYamlKeysSorter, toYaml } from './yaml_utils';

const POLICY_KEYS_ORDER = [
'id',
'name',
Expand All @@ -30,34 +31,18 @@ const POLICY_KEYS_ORDER = [

export const fullAgentPolicyToYaml = (
policy: FullAgentPolicy,
toYaml: typeof dump,
yaml: YamlModule,
apiKey?: string
): string => {
const yaml = toYaml(policy, {
skipInvalid: true,
sortKeys: _sortYamlKeys,
});
const formattedYml = apiKey ? replaceApiKey(yaml, apiKey) : yaml;
const sortYamlKeys = createYamlKeysSorter(POLICY_KEYS_ORDER, yaml);
const yamlText = toYaml(policy, { sortMapEntries: sortYamlKeys, strict: false }, yaml);
const formattedYml = apiKey ? replaceApiKey(yamlText, apiKey) : yamlText;

if (!policy?.secret_references?.length) return formattedYml;

return _formatSecrets(policy.secret_references, formattedYml);
};

export function _sortYamlKeys(keyA: string, keyB: string) {
const indexA = POLICY_KEYS_ORDER.indexOf(keyA);
const indexB = POLICY_KEYS_ORDER.indexOf(keyB);
if (indexA >= 0 && indexB < 0) {
return -1;
}

if (indexA < 0 && indexB >= 0) {
return 1;
}

return indexA - indexB;
}

function _formatSecrets(
secretRefs: NonNullable<FullAgentPolicy['secret_references']>,
ymlText: string
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,8 @@ export {
// Cloud Connector accessor module
export * from './cloud_connectors';

export type { YamlModule } from './yaml_utils';
export { createYamlKeysSorter, toYaml } from './yaml_utils';
export {
packageInfoHasOtelInputs,
packagePolicyHasOtelInputs,
Expand Down
Loading
Loading