Skip to content

Feat/Add Fragment Generation Support#4864

Open
Vladislavs-Silins-SAP wants to merge 6 commits into
mainfrom
feat/generate-fragment-function
Open

Feat/Add Fragment Generation Support#4864
Vladislavs-Silins-SAP wants to merge 6 commits into
mainfrom
feat/generate-fragment-function

Conversation

@Vladislavs-Silins-SAP

Copy link
Copy Markdown
Contributor

Summary

Add standalone fragment generation capability to fe-fpm-writer and specification packages for use in table columns and other UI customizations.

Changes

open-ux-tools (feat/generate-fragment-function)

  • Add generateFragment() function in fe-fpm-writer/src/column/index.ts
  • Add Fragment interface in fe-fpm-writer/src/column/types.ts following existing type patterns
  • Export Fragment type and generateFragment function from package index

specification (integration branch)

  • Add CustomExtensionType.Fragment enum value in packages/types/src/apiTypes.ts
  • Import Fragment type from @sap-ux/fe-fpm-writer
  • Register generateFragment in fpmWriterMap in packages/specification/src/api.ts

API

// Fragment generation
const fragment: Fragment = {
    name: 'MyFragment',
    folder: 'ext/fragment',  // optional, defaults to 'ext/fragment'
    content: '<Text text="..." />'  // optional, uses default template
};

await generateCustomExtension(basePath, CustomExtensionType.Fragment, fragment, fs);

Notes

  • Fragment interface follows same pattern as CustomTableColumn, CustomAction, etc.
  • Generates standalone .fragment.xml files without modifying manifest.json
  • Enables dynamic fragment generation for table columns and other custom UI elements

- Add Fragment interface with name, folder, and content properties
- Add generateFragment(basePath, fragment, fs) function
- Reuses same template and logic as generateCustomColumn
- Does NOT modify manifest.json (fragment-only generation)
- Export Fragment type and generateFragment function from main index
- Uses getDefaultFragmentContent() for sample <Text> content
- Follows same pattern as other fe-fpm-writer generators
- Move Fragment interface from column/index.ts to column/types.ts
- Follow same pattern as other types (CustomTableColumn, CustomAction, etc.)
- Update imports and exports accordingly
@Vladislavs-Silins-SAP Vladislavs-Silins-SAP requested a review from a team as a code owner June 19, 2026 08:07
@changeset-bot

changeset-bot Bot commented Jun 19, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 002d653

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 96 packages
Name Type
@sap-ux/fe-fpm-writer Minor
@sap-ux/fe-fpm-cli Patch
@sap-ux/odata-cli Patch
@sap-ux/generator-simple-fe Patch
@sap-ux-private/ui-prompting-examples Patch
@sap-ux/abap-deploy-config-inquirer Patch
@sap-ux/abap-deploy-config-sub-generator Patch
@sap-ux/abap-deploy-config-writer Patch
@sap-ux/adp-flp-config-sub-generator Patch
@sap-ux/adp-tooling Patch
@sap-ux/annotation-generator Patch
@sap-ux/app-config-writer Patch
@sap-ux/axios-extension Patch
@sap-ux/backend-proxy-middleware Patch
@sap-ux/backend-proxy-middleware-cf Patch
@sap-ux/btp-utils Patch
@sap-ux/cap-config-writer Patch
@sap-ux/cds-annotation-parser Patch
@sap-ux/cds-odata-annotation-converter Patch
@sap-ux/cf-deploy-config-inquirer Patch
@sap-ux/cf-deploy-config-sub-generator Patch
@sap-ux/cf-deploy-config-writer Patch
@sap-ux/control-property-editor Patch
@sap-ux-private/control-property-editor-common Patch
@sap-ux/create Patch
@sap-ux/deploy-config-generator-shared Patch
@sap-ux/deploy-config-sub-generator Patch
@sap-ux/deploy-tooling Patch
@sap-ux/environment-check Patch
@sap-ux/eslint-plugin-fiori-tools Patch
@sap-ux/feature-toggle Patch
@sap-ux/fiori-annotation-api Patch
@sap-ux/fiori-app-sub-generator Patch
@sap-ux/fiori-docs-embeddings Patch
@sap-ux/fiori-elements-writer Patch
@sap-ux/fiori-freestyle-writer Patch
@sap-ux/fiori-generator-shared Patch
@sap-ux/fiori-mcp-server Patch
@sap-ux/fiori-tools-settings Patch
@sap-ux/flp-config-inquirer Patch
@sap-ux/flp-config-sub-generator Patch
@sap-ux/generator-adp Patch
@sap-ux/generator-odata-downloader Patch
@sap-ux/guided-answers-helper Patch
@sap-ux/i18n Patch
@sap-ux/inquirer-common Patch
@sap-ux/jest-environment-ui5 Patch
@sap-ux/jest-file-matchers Patch
@sap-ux/jest-runner-puppeteer Patch
@sap-ux/launch-config Patch
@sap-ux/logger Patch
@sap-ux/mockserver-config-writer Patch
@sap-ux/nodejs-utils Patch
@sap-ux/odata-annotation-core Patch
@sap-ux/odata-annotation-core-types Patch
@sap-ux/odata-entity-model Patch
@sap-ux/odata-service-inquirer Patch
@sap-ux/odata-service-writer Patch
@sap-ux/odata-vocabularies Patch
@sap-ux-private/playwright Patch
@sap-ux/preview-middleware Patch
@sap-ux-private/preview-middleware-client Patch
@sap-ux/project-access Patch
@sap-ux/project-input-validator Patch
@sap-ux/project-integrity Patch
@sap-ux/reload-middleware Patch
@sap-ux/repo-app-import-sub-generator Patch
sap-ux-sap-systems-ext Patch
@sap-ux/sap-systems-ext-types Patch
@sap-ux/sap-systems-ext-webapp Patch
@sap-ux/serve-static-middleware Patch
@sap-ux/store Patch
@sap-ux/system-access Patch
@sap-ux/telemetry Patch
@sap-ux/text-document-utils Patch
@sap-ux/ui-components Patch
@sap-ux/ui-prompting Patch
@sap-ux/ui-service-inquirer Patch
@sap-ux/ui-service-sub-generator Patch
@sap-ux/ui5-application-inquirer Patch
@sap-ux/ui5-application-writer Patch
@sap-ux/ui5-config Patch
@sap-ux/ui5-info Patch
@sap-ux/ui5-library-inquirer Patch
@sap-ux/ui5-library-reference-inquirer Patch
@sap-ux/ui5-library-reference-sub-generator Patch
@sap-ux/ui5-library-reference-writer Patch
@sap-ux/ui5-library-sub-generator Patch
@sap-ux/ui5-library-writer Patch
@sap-ux/ui5-proxy-middleware Patch
@sap-ux/ui5-test-writer Patch
@sap-ux/xml-odata-annotation-converter Patch
@sap-ux/yaml Patch
test-project Patch
@sap-ux-private/adaptation-editor-tests Patch
@sap-ux/types Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@hyperspace-insights

Copy link
Copy Markdown
Contributor

Summary

The following content is AI-generated and provides a summary of the pull request:


Add Standalone Fragment Generation Capability to fe-fpm-writer

New Feature

✨ Introduces a generateFragment() function and Fragment interface to the fe-fpm-writer package, enabling standalone XML fragment file generation without modifying manifest.json. This is useful for dynamically generating fragments for table columns and other custom UI elements.

Changes

  • packages/fe-fpm-writer/src/column/types.ts: Added the Fragment interface with name (required), folder (optional, defaults to ext/fragment), and content (optional XML content) properties.

  • packages/fe-fpm-writer/src/column/index.ts: Implemented the generateFragment() async function. It validates the base path, resolves the output folder relative to the manifest location, generates default fragment content if none is provided, and writes the .fragment.xml file using the existing common/Fragment.xml template — without touching manifest.json.

  • packages/fe-fpm-writer/src/index.ts: Exported the new Fragment type and generateFragment function from the package's public API, alongside the existing CustomTableColumn and generateCustomColumn exports.

Example Usage

const fragment: Fragment = {
    name: 'MyFragment',
    folder: 'ext/fragment',  // optional, defaults to 'ext/fragment'
    content: '<Text text="..." />'  // optional, uses default template
};

await generateFragment(basePath, fragment, fs);

Note: generateFragment follows the same patterns as generateCustomColumn, generateCustomAction, etc., and only creates the .fragment.xml file — no manifest.json modifications are made.


  • 🔄 Regenerate and Update Summary
  • ✏️ Insert as PR Description (deletes this comment)
  • 🗑️ Delete comment
PR Bot Information

Version: 1.26.0

  • Event Trigger: pull_request.opened
  • Correlation ID: e1209edc-1402-4b83-8925-946222692dd7
  • Summary Prompt: Default Prompt
  • File Content Strategy: Full file content
  • Output Template: Default Template
  • LLM: anthropic--claude-4.6-sonnet

@Vladislavs-Silins-SAP Vladislavs-Silins-SAP changed the title Feat/generate fragment function Feat/Add Fragment Generation Support Jun 19, 2026

@hyperspace-insights hyperspace-insights Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The PR introduces a generateFragment function and associated types. Three issues were identified: (1) fragment.name is not validated, allowing empty strings or path-traversal values to produce malformed/unsafe file paths; (2) createIdGenerator performs an expensive async filesystem scan unconditionally even when fragment.content is already provided by the caller; (3) when the target fragment file already exists, the function silently returns a no-op with no error or signal to the caller. Additionally, no unit tests for generateFragment appear to be included in this PR, which falls below the project's 80% coverage requirement per AGENTS.md.

PR Bot Information

Version: 1.26.0

  • Event Trigger: pull_request.opened
  • Correlation ID: e1209edc-1402-4b83-8925-946222692dd7
  • Agent Instructions:
  • File Content Strategy: Full file content
  • LLM: anthropic--claude-4.6-sonnet

Comment thread packages/fe-fpm-writer/src/column/index.ts
Comment thread packages/fe-fpm-writer/src/column/index.ts
Comment thread packages/fe-fpm-writer/src/column/index.ts
@sonarqubecloud

Copy link
Copy Markdown

@heimwege heimwege added the fe-fpm-writer @sap-ux/fe-fpm-writer label Jun 19, 2026

@heimwege heimwege left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

see comments

Comment on lines +2 to +97
'@sap-ux/fe-fpm-writer': minor
'@sap-ux/fe-fpm-cli': patch
'@sap-ux/odata-cli': patch
'@sap-ux/generator-simple-fe': patch
'@sap-ux-private/ui-prompting-examples': patch
'@sap-ux/abap-deploy-config-inquirer': patch
'@sap-ux/abap-deploy-config-sub-generator': patch
'@sap-ux/abap-deploy-config-writer': patch
'@sap-ux/adp-flp-config-sub-generator': patch
'@sap-ux/adp-tooling': patch
'@sap-ux/annotation-generator': patch
'@sap-ux/app-config-writer': patch
'@sap-ux/axios-extension': patch
'@sap-ux/backend-proxy-middleware': patch
'@sap-ux/backend-proxy-middleware-cf': patch
'@sap-ux/btp-utils': patch
'@sap-ux/cap-config-writer': patch
'@sap-ux/cds-annotation-parser': patch
'@sap-ux/cds-odata-annotation-converter': patch
'@sap-ux/cf-deploy-config-inquirer': patch
'@sap-ux/cf-deploy-config-sub-generator': patch
'@sap-ux/cf-deploy-config-writer': patch
'@sap-ux/control-property-editor': patch
'@sap-ux-private/control-property-editor-common': patch
'@sap-ux/create': patch
'@sap-ux/deploy-config-generator-shared': patch
'@sap-ux/deploy-config-sub-generator': patch
'@sap-ux/deploy-tooling': patch
'@sap-ux/environment-check': patch
'@sap-ux/eslint-plugin-fiori-tools': patch
'@sap-ux/feature-toggle': patch
'@sap-ux/fiori-annotation-api': patch
'@sap-ux/fiori-app-sub-generator': patch
'@sap-ux/fiori-docs-embeddings': patch
'@sap-ux/fiori-elements-writer': patch
'@sap-ux/fiori-freestyle-writer': patch
'@sap-ux/fiori-generator-shared': patch
'@sap-ux/fiori-mcp-server': patch
'@sap-ux/fiori-tools-settings': patch
'@sap-ux/flp-config-inquirer': patch
'@sap-ux/flp-config-sub-generator': patch
'@sap-ux/generator-adp': patch
'@sap-ux/generator-odata-downloader': patch
'@sap-ux/guided-answers-helper': patch
'@sap-ux/i18n': patch
'@sap-ux/inquirer-common': patch
'@sap-ux/jest-environment-ui5': patch
'@sap-ux/jest-file-matchers': patch
'@sap-ux/jest-runner-puppeteer': patch
'@sap-ux/launch-config': patch
'@sap-ux/logger': patch
'@sap-ux/mockserver-config-writer': patch
'@sap-ux/nodejs-utils': patch
'@sap-ux/odata-annotation-core': patch
'@sap-ux/odata-annotation-core-types': patch
'@sap-ux/odata-entity-model': patch
'@sap-ux/odata-service-inquirer': patch
'@sap-ux/odata-service-writer': patch
'@sap-ux/odata-vocabularies': patch
'@sap-ux-private/playwright': patch
'@sap-ux/preview-middleware': patch
'@sap-ux-private/preview-middleware-client': patch
'@sap-ux/project-access': patch
'@sap-ux/project-input-validator': patch
'@sap-ux/project-integrity': patch
'@sap-ux/reload-middleware': patch
'@sap-ux/repo-app-import-sub-generator': patch
'sap-ux-sap-systems-ext': patch
'@sap-ux/sap-systems-ext-types': patch
'@sap-ux/sap-systems-ext-webapp': patch
'@sap-ux/serve-static-middleware': patch
'@sap-ux/store': patch
'@sap-ux/system-access': patch
'@sap-ux/telemetry': patch
'@sap-ux/text-document-utils': patch
'@sap-ux/ui-components': patch
'@sap-ux/ui-prompting': patch
'@sap-ux/ui-service-inquirer': patch
'@sap-ux/ui-service-sub-generator': patch
'@sap-ux/ui5-application-inquirer': patch
'@sap-ux/ui5-application-writer': patch
'@sap-ux/ui5-config': patch
'@sap-ux/ui5-info': patch
'@sap-ux/ui5-library-inquirer': patch
'@sap-ux/ui5-library-reference-inquirer': patch
'@sap-ux/ui5-library-reference-sub-generator': patch
'@sap-ux/ui5-library-reference-writer': patch
'@sap-ux/ui5-library-sub-generator': patch
'@sap-ux/ui5-library-writer': patch
'@sap-ux/ui5-proxy-middleware': patch
'@sap-ux/ui5-test-writer': patch
'@sap-ux/xml-odata-annotation-converter': patch
'@sap-ux/yaml': patch
'test-project': patch
'@sap-ux-private/adaptation-editor-tests': patch
'@sap-ux/types': patch

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Changes are only done in fe-fmp-writer. Dependencies will be handled by the workspace links

Suggested change
'@sap-ux/fe-fpm-writer': minor
'@sap-ux/fe-fpm-cli': patch
'@sap-ux/odata-cli': patch
'@sap-ux/generator-simple-fe': patch
'@sap-ux-private/ui-prompting-examples': patch
'@sap-ux/abap-deploy-config-inquirer': patch
'@sap-ux/abap-deploy-config-sub-generator': patch
'@sap-ux/abap-deploy-config-writer': patch
'@sap-ux/adp-flp-config-sub-generator': patch
'@sap-ux/adp-tooling': patch
'@sap-ux/annotation-generator': patch
'@sap-ux/app-config-writer': patch
'@sap-ux/axios-extension': patch
'@sap-ux/backend-proxy-middleware': patch
'@sap-ux/backend-proxy-middleware-cf': patch
'@sap-ux/btp-utils': patch
'@sap-ux/cap-config-writer': patch
'@sap-ux/cds-annotation-parser': patch
'@sap-ux/cds-odata-annotation-converter': patch
'@sap-ux/cf-deploy-config-inquirer': patch
'@sap-ux/cf-deploy-config-sub-generator': patch
'@sap-ux/cf-deploy-config-writer': patch
'@sap-ux/control-property-editor': patch
'@sap-ux-private/control-property-editor-common': patch
'@sap-ux/create': patch
'@sap-ux/deploy-config-generator-shared': patch
'@sap-ux/deploy-config-sub-generator': patch
'@sap-ux/deploy-tooling': patch
'@sap-ux/environment-check': patch
'@sap-ux/eslint-plugin-fiori-tools': patch
'@sap-ux/feature-toggle': patch
'@sap-ux/fiori-annotation-api': patch
'@sap-ux/fiori-app-sub-generator': patch
'@sap-ux/fiori-docs-embeddings': patch
'@sap-ux/fiori-elements-writer': patch
'@sap-ux/fiori-freestyle-writer': patch
'@sap-ux/fiori-generator-shared': patch
'@sap-ux/fiori-mcp-server': patch
'@sap-ux/fiori-tools-settings': patch
'@sap-ux/flp-config-inquirer': patch
'@sap-ux/flp-config-sub-generator': patch
'@sap-ux/generator-adp': patch
'@sap-ux/generator-odata-downloader': patch
'@sap-ux/guided-answers-helper': patch
'@sap-ux/i18n': patch
'@sap-ux/inquirer-common': patch
'@sap-ux/jest-environment-ui5': patch
'@sap-ux/jest-file-matchers': patch
'@sap-ux/jest-runner-puppeteer': patch
'@sap-ux/launch-config': patch
'@sap-ux/logger': patch
'@sap-ux/mockserver-config-writer': patch
'@sap-ux/nodejs-utils': patch
'@sap-ux/odata-annotation-core': patch
'@sap-ux/odata-annotation-core-types': patch
'@sap-ux/odata-entity-model': patch
'@sap-ux/odata-service-inquirer': patch
'@sap-ux/odata-service-writer': patch
'@sap-ux/odata-vocabularies': patch
'@sap-ux-private/playwright': patch
'@sap-ux/preview-middleware': patch
'@sap-ux-private/preview-middleware-client': patch
'@sap-ux/project-access': patch
'@sap-ux/project-input-validator': patch
'@sap-ux/project-integrity': patch
'@sap-ux/reload-middleware': patch
'@sap-ux/repo-app-import-sub-generator': patch
'sap-ux-sap-systems-ext': patch
'@sap-ux/sap-systems-ext-types': patch
'@sap-ux/sap-systems-ext-webapp': patch
'@sap-ux/serve-static-middleware': patch
'@sap-ux/store': patch
'@sap-ux/system-access': patch
'@sap-ux/telemetry': patch
'@sap-ux/text-document-utils': patch
'@sap-ux/ui-components': patch
'@sap-ux/ui-prompting': patch
'@sap-ux/ui-service-inquirer': patch
'@sap-ux/ui-service-sub-generator': patch
'@sap-ux/ui5-application-inquirer': patch
'@sap-ux/ui5-application-writer': patch
'@sap-ux/ui5-config': patch
'@sap-ux/ui5-info': patch
'@sap-ux/ui5-library-inquirer': patch
'@sap-ux/ui5-library-reference-inquirer': patch
'@sap-ux/ui5-library-reference-sub-generator': patch
'@sap-ux/ui5-library-reference-writer': patch
'@sap-ux/ui5-library-sub-generator': patch
'@sap-ux/ui5-library-writer': patch
'@sap-ux/ui5-proxy-middleware': patch
'@sap-ux/ui5-test-writer': patch
'@sap-ux/xml-odata-annotation-converter': patch
'@sap-ux/yaml': patch
'test-project': patch
'@sap-ux-private/adaptation-editor-tests': patch
'@sap-ux/types': patch
'@sap-ux/fe-fpm-writer': minor

/**
* Fragment generation configuration.
*/
export interface Fragment {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The Fragment interface is placed in column/types.ts, but it has no conceptual relationship to columns - it's a general concept. This could live in a dedicated fragment/types.ts or common/types.ts.

});

test('generate fragment with default options', async () => {
const { generateFragment } = await import('../../src/index.js');

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Tests import generateFragment via dynamic await import('../../src/index.js') inside each test body - this is inconsistent with how the rest of the test file imports. Other tests in the file use static imports at the top. The dynamic imports here appear unnecessary.

const { path: manifestPath } = await getManifest(basePath, fs);

// Calculate path for fragment
const folder = fragment.folder || 'ext/fragment';

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The folder parameter is used directly in join() with no sanitization. A caller passing folder: '../../../etc' would write outside the project.

* @param {Editor} [fs] - the mem-fs editor instance
* @returns {Promise<Editor>} the updated mem-fs editor instance
*/
export async function generateFragment(basePath: string, fragment: Fragment, fs?: Editor): Promise<Editor> {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Why is this nested under /column? It's not just fragments for table columns, right? Then it should be e.g. in /fragment or /common

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

fe-fpm-writer @sap-ux/fe-fpm-writer

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants