From 209ce9dfe5112f5dd4dca16bec881a60a600797f Mon Sep 17 00:00:00 2001 From: Ashwani Kumar Date: Thu, 20 Nov 2025 00:46:23 +0530 Subject: [PATCH 1/2] Updated server logic file to add customjs as suffix --- src/web/client/dal/remoteFetchProvider.ts | 8 +++++++- src/web/client/dal/remoteSaveProvider.ts | 7 ++++++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/src/web/client/dal/remoteFetchProvider.ts b/src/web/client/dal/remoteFetchProvider.ts index ebe024621..9cc515b38 100644 --- a/src/web/client/dal/remoteFetchProvider.ts +++ b/src/web/client/dal/remoteFetchProvider.ts @@ -426,7 +426,13 @@ async function processDataAndCreateFile( else { let fileCreationValid = true; let fileNameWithExtension = GetFileNameWithExtension(entityName, fileName, languageCode, fileExtension); - + if (entityName === schemaEntityName.SERVERLOGICS) { + // Modify filename for serverlogics: test.js -> test.serverlogics.customjs.js + if (fileNameWithExtension.endsWith('.js')) { + const baseName = fileNameWithExtension.slice(0, -3); // Remove .js + fileNameWithExtension = `${baseName}.serverlogic.customjs.js`; + } + } if (defaultFileInfo?.fileName) { fileCreationValid = defaultFileInfo?.fileName === fileNameWithExtension || (defaultFileInfo?.fileName.startsWith(fileName) && defaultFileInfo?.fileName.endsWith(fileExtension)); diff --git a/src/web/client/dal/remoteSaveProvider.ts b/src/web/client/dal/remoteSaveProvider.ts index 3ef4d0816..b78ed3764 100644 --- a/src/web/client/dal/remoteSaveProvider.ts +++ b/src/web/client/dal/remoteSaveProvider.ts @@ -94,7 +94,12 @@ async function getSaveParameters( if (webFileV2) { let fileName = fileDataMap.get(fileUri.fsPath)?.fileName as string; if (entityName === MultiFileSupportedEntityName.SERVERLOGICS && fileName && !fileName.endsWith('.sl')) { - const baseName = fileName.endsWith('.js') ? fileName.slice(0, -3) : fileName; + // Handle filenames like test.serverlogics.customjs.js -> extract base name (test) and append .sl + let baseName = fileName; + // Remove .serverlogics.customjs if present + if (baseName.endsWith('.serverlogics.customjs')) { + baseName = baseName.slice(0, -22); // Remove .serverlogics.customjs (22 characters) + } fileName = `${baseName}.sl`; } saveCallParameters.requestInit.headers = { From 1288669e9ff7f3cae1680505f41a0861b582734e Mon Sep 17 00:00:00 2001 From: ashwani123p Date: Thu, 20 Nov 2025 14:53:39 +0530 Subject: [PATCH 2/2] Moved serverlogic extension name to constants --- src/web/client/common/constants.ts | 1 + src/web/client/dal/remoteFetchProvider.ts | 2 +- src/web/client/dal/remoteSaveProvider.ts | 10 +++++----- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/web/client/common/constants.ts b/src/web/client/common/constants.ts index b6f33f43f..6f7ba6987 100644 --- a/src/web/client/common/constants.ts +++ b/src/web/client/common/constants.ts @@ -147,3 +147,4 @@ export const WEB_EXTENSION_COLLABORATION_OPTIONS_CONTACT = "Contact"; //Business logic constants export const SERVERLOGICS = "server-logics"; +export const SERVERLOGIC_FILE_EXTENSION = ".serverlogic.customjs.js"; diff --git a/src/web/client/dal/remoteFetchProvider.ts b/src/web/client/dal/remoteFetchProvider.ts index 9cc515b38..7dbfd5709 100644 --- a/src/web/client/dal/remoteFetchProvider.ts +++ b/src/web/client/dal/remoteFetchProvider.ts @@ -430,7 +430,7 @@ async function processDataAndCreateFile( // Modify filename for serverlogics: test.js -> test.serverlogics.customjs.js if (fileNameWithExtension.endsWith('.js')) { const baseName = fileNameWithExtension.slice(0, -3); // Remove .js - fileNameWithExtension = `${baseName}.serverlogic.customjs.js`; + fileNameWithExtension = `${baseName}${Constants.SERVERLOGIC_FILE_EXTENSION}`; } } if (defaultFileInfo?.fileName) { diff --git a/src/web/client/dal/remoteSaveProvider.ts b/src/web/client/dal/remoteSaveProvider.ts index b78ed3764..6526befc7 100644 --- a/src/web/client/dal/remoteSaveProvider.ts +++ b/src/web/client/dal/remoteSaveProvider.ts @@ -9,7 +9,7 @@ import { getCommonHeadersForDataverse } from "../../../common/services/Authentic import { BAD_REQUEST, MIMETYPE, queryParameters } from "../common/constants"; import { showErrorDialog } from "../../../common/utilities/errorHandlerUtil"; import { FileData } from "../context/fileData"; -import { httpMethod } from "../common/constants"; +import { httpMethod, SERVERLOGIC_FILE_EXTENSION } from "../common/constants"; import { getEntity, isWebFileV2, @@ -94,11 +94,11 @@ async function getSaveParameters( if (webFileV2) { let fileName = fileDataMap.get(fileUri.fsPath)?.fileName as string; if (entityName === MultiFileSupportedEntityName.SERVERLOGICS && fileName && !fileName.endsWith('.sl')) { - // Handle filenames like test.serverlogics.customjs.js -> extract base name (test) and append .sl + // Handle filenames like test.serverlogic.customjs.js -> extract base name (test) and append .sl let baseName = fileName; - // Remove .serverlogics.customjs if present - if (baseName.endsWith('.serverlogics.customjs')) { - baseName = baseName.slice(0, -22); // Remove .serverlogics.customjs (22 characters) + // Remove .serverlogic.customjs.js if present + if (baseName.endsWith(SERVERLOGIC_FILE_EXTENSION)) { + baseName = baseName.slice(0, -24); // Remove .serverlogic.customjs.js (24 characters) } fileName = `${baseName}.sl`; }