From 9112566985d22d0f4eee15d43a6fe65fa25d5268 Mon Sep 17 00:00:00 2001 From: Previn Wong Date: Tue, 5 May 2026 14:01:39 -0700 Subject: [PATCH] Handle feature service name substitution Handle feature service name substitution --- packages/common/src/featureServiceHelpers.ts | 5 ++++- .../common/test/featureServiceHelpers.test.ts | 20 +++++++++++++++++++ 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/packages/common/src/featureServiceHelpers.ts b/packages/common/src/featureServiceHelpers.ts index e9ecd4c14..8eeffbffa 100644 --- a/packages/common/src/featureServiceHelpers.ts +++ b/packages/common/src/featureServiceHelpers.ts @@ -555,7 +555,10 @@ export function setNamesAndTitles(templates: IItemTemplate[]): IItemTemplate[] { // The name length limit is 98 // Limit the baseName to 50 characters before the _ - const name: string = baseName.substring(0, 50) + "_" + guid; + // If the baseName includes '{{params' it is likely being used in a template replacement, so do not truncate. + const name: string = baseName.includes("{{params") + ? baseName + "_" + guid + : baseName.substring(0, 50) + "_" + guid; // If the name + GUID already exists then append "_occurrenceCount" t.item.name = names.indexOf(name) === -1 ? name : `${name}_${names.filter((n) => n === name).length}`; diff --git a/packages/common/test/featureServiceHelpers.test.ts b/packages/common/test/featureServiceHelpers.test.ts index 07f00e9f3..2ac0450cc 100644 --- a/packages/common/test/featureServiceHelpers.test.ts +++ b/packages/common/test/featureServiceHelpers.test.ts @@ -1972,6 +1972,26 @@ describe("Module `featureServiceHelpers`: utility functions for feature-service const actual: IItemTemplate[] = setNamesAndTitles(_templates); expect(actual).toEqual(expected); }); + + it("should not truncate if '{{param' is used", () => { + const t: IItemTemplate = templates.getItemTemplateSkeleton(); + t.item.type = "Feature Service"; + t.item.name = "{{params.buildSolution.items.46c2f61bc5bc4f3aad6b391360e8e53d.title}}"; + t.item.title = "TheName"; + const _templates: IItemTemplate[] = [t]; + + spyOn(generalHelpers, "generateGUID").and.returnValue("212dbc19b03943008fdfaf8d6adca00e"); + + const expectedTemplate: IItemTemplate = templates.getItemTemplateSkeleton(); + expectedTemplate.item.type = "Feature Service"; + expectedTemplate.item.name = `{{params.buildSolution.items.46c2f61bc5bc4f3aad6b391360e8e53d.title}}_212dbc19b03943008fdfaf8d6adca00e`; + expectedTemplate.item.title = "TheName"; + const expected: IItemTemplate[] = [expectedTemplate]; + + const actual: IItemTemplate[] = setNamesAndTitles(_templates); + expect(actual).toEqual(expected); + }); + }); describe("updateSettingsFieldInfos", () => {