@sap-ux/cf-deploy-config-writer 1.1.7 → 1.1.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -121,6 +121,7 @@ export declare const MAX_MTA_ID_LENGTH = 128;
121
121
  export declare const MAX_MTA_PREFIX_LENGTH = 100;
122
122
  export declare const MAX_MTA_PREFIX_SHORT_LENGTH = 94;
123
123
  export declare const MAX_MTA_PREFIX_SHORTER_LENGTH = 96;
124
+ export declare const MAX_SERVICE_INSTANCE_NAME_LENGTH = 50;
124
125
  export declare const MAX_ABAP_SERVICE_PREFIX_LENGTH = 24;
125
126
  export declare const MAX_ABAP_SERVICE_NAME_LENGTH = 20;
126
127
  export declare const MTA_FILE_OPERATION_DELAY_MS = 1000;
package/dist/constants.js CHANGED
@@ -122,6 +122,12 @@ export const MAX_MTA_ID_LENGTH = 128;
122
122
  export const MAX_MTA_PREFIX_LENGTH = 100;
123
123
  export const MAX_MTA_PREFIX_SHORT_LENGTH = 94;
124
124
  export const MAX_MTA_PREFIX_SHORTER_LENGTH = 96;
125
+ // Cloud Foundry limits service instance names to 50 characters. The MTA deploy service silently renames
126
+ // any longer `service-name` to `<mta-id>-<hash>` (also capped at 50) at deploy time, but leaves the
127
+ // `destination-content` ServiceInstanceName reference pointing at the original untruncated name, which
128
+ // then fails content deployment. Keep every generated `service-name` within this limit so the name is
129
+ // used verbatim and references stay consistent.
130
+ export const MAX_SERVICE_INSTANCE_NAME_LENGTH = 50;
125
131
  export const MAX_ABAP_SERVICE_PREFIX_LENGTH = 24;
126
132
  export const MAX_ABAP_SERVICE_NAME_LENGTH = 20;
127
133
  // MTA file operation timing
@@ -65,6 +65,16 @@ export declare class MtaConfig {
65
65
  * @returns {string | undefined} The service instance name to use in destinations
66
66
  */
67
67
  private getServiceInstanceName;
68
+ /**
69
+ * Builds a Cloud Foundry service instance name from the MTA prefix and a suffix, capped at the
70
+ * CF 50 character limit. The prefix is truncated (never the suffix) so the resulting `service-name`
71
+ * is used verbatim by the MTA deploy service instead of being silently renamed to `<mta-id>-<hash>`,
72
+ * which would otherwise break the matching `destination-content` ServiceInstanceName reference.
73
+ *
74
+ * @param {string} suffix - The service suffix including its leading dash (e.g. `-html5-service`)
75
+ * @returns {string} The service instance name, guaranteed to be at most 50 characters
76
+ */
77
+ private buildServiceInstanceName;
68
78
  private addAppFrontResource;
69
79
  private addHtml5Host;
70
80
  /**
@@ -5,7 +5,7 @@ import { Mta } from '@sap/mta-lib';
5
5
  import { isGenericODataDestination, isAbapEnvironmentOnBtp } from '@sap-ux/btp-utils';
6
6
  import { YamlDocument } from '@sap-ux/yaml';
7
7
  import { FileName, getMtaPath, hasDependency } from '@sap-ux/project-access';
8
- import { CloudFoundry, RouterModule, DefaultMTADestination, SRV_API, ManagedXSUAA, MTABuildParams, MTABuildResult, DestinationServiceConfig, UI5ResourceDestination, UI5Destination, MTAAPIDestination, UI5StandaloneModuleDestination, ServiceAPIRequires, HTMLAppBuildParams, HTML5RepoHost, UI5AppfrontDestinationParameter, ManagedAppFront, CAPAppfrontDestination, deployMode, enableParallelDeployments, MAX_MTA_PREFIX_LENGTH, MAX_MTA_PREFIX_SHORT_LENGTH, MAX_MTA_PREFIX_SHORTER_LENGTH, MAX_ABAP_SERVICE_PREFIX_LENGTH, MAX_ABAP_SERVICE_NAME_LENGTH, MAX_MTA_ID_LENGTH } from '../constants.js';
8
+ import { CloudFoundry, RouterModule, DefaultMTADestination, SRV_API, ManagedXSUAA, MTABuildParams, MTABuildResult, DestinationServiceConfig, UI5ResourceDestination, UI5Destination, MTAAPIDestination, UI5StandaloneModuleDestination, ServiceAPIRequires, HTMLAppBuildParams, HTML5RepoHost, UI5AppfrontDestinationParameter, ManagedAppFront, CAPAppfrontDestination, deployMode, enableParallelDeployments, MAX_MTA_PREFIX_LENGTH, MAX_MTA_PREFIX_SHORT_LENGTH, MAX_ABAP_SERVICE_PREFIX_LENGTH, MAX_ABAP_SERVICE_NAME_LENGTH, MAX_MTA_ID_LENGTH, MAX_SERVICE_INSTANCE_NAME_LENGTH } from '../constants.js';
9
9
  import { t } from '../i18n.js';
10
10
  import { CloudFoundryServiceType, RouterModuleType } from '../types/index.js';
11
11
  import { renderTemplateToDisk } from './template-renderer.js';
@@ -159,7 +159,7 @@ export class MtaConfig {
159
159
  service: 'xsuaa',
160
160
  'service-plan': 'application',
161
161
  path: './xs-security.json',
162
- 'service-name': `${this.prefix?.slice(0, MAX_MTA_PREFIX_LENGTH)}-xsuaa-service`,
162
+ 'service-name': this.buildServiceInstanceName('-xsuaa-service'),
163
163
  config: {
164
164
  xsappname: `${this.prefix?.slice(0, MAX_MTA_PREFIX_LENGTH)}-\${org}-\${space}`,
165
165
  'tenant-mode': 'dedicated',
@@ -194,7 +194,7 @@ export class MtaConfig {
194
194
  if (resource && !resource.parameters?.['service-name']) {
195
195
  resource.parameters = {
196
196
  ...(resource.parameters ?? {}),
197
- 'service-name': `${this.prefix?.slice(0, MAX_MTA_PREFIX_LENGTH)}-${serviceName}-service`
197
+ 'service-name': this.buildServiceInstanceName(`-${serviceName}-service`)
198
198
  };
199
199
  await this.mta?.updateResource(resource);
200
200
  this.resources.set(resourceName, resource);
@@ -219,13 +219,26 @@ export class MtaConfig {
219
219
  // This matches what Cloud Foundry actually creates when service-name is missing
220
220
  return resource?.name;
221
221
  }
222
+ /**
223
+ * Builds a Cloud Foundry service instance name from the MTA prefix and a suffix, capped at the
224
+ * CF 50 character limit. The prefix is truncated (never the suffix) so the resulting `service-name`
225
+ * is used verbatim by the MTA deploy service instead of being silently renamed to `<mta-id>-<hash>`,
226
+ * which would otherwise break the matching `destination-content` ServiceInstanceName reference.
227
+ *
228
+ * @param {string} suffix - The service suffix including its leading dash (e.g. `-html5-service`)
229
+ * @returns {string} The service instance name, guaranteed to be at most 50 characters
230
+ */
231
+ buildServiceInstanceName(suffix) {
232
+ const maxPrefixLength = Math.max(0, MAX_SERVICE_INSTANCE_NAME_LENGTH - suffix.length);
233
+ return `${this.prefix?.slice(0, maxPrefixLength)}${suffix}`;
234
+ }
222
235
  async addAppFrontResource() {
223
236
  const resource = {
224
237
  name: `${this.prefix?.slice(0, MAX_MTA_PREFIX_SHORT_LENGTH)}-app-front`,
225
238
  type: 'org.cloudfoundry.managed-service',
226
239
  parameters: {
227
240
  service: 'app-front',
228
- 'service-name': `${this.prefix?.slice(0, MAX_MTA_PREFIX_SHORTER_LENGTH)}-app-front-service`,
241
+ 'service-name': this.buildServiceInstanceName('-app-front-service'),
229
242
  'service-plan': 'developer'
230
243
  }
231
244
  };
@@ -239,7 +252,7 @@ export class MtaConfig {
239
252
  name: html5host,
240
253
  type: 'org.cloudfoundry.managed-service',
241
254
  parameters: {
242
- 'service-name': `${this.prefix?.slice(0, MAX_MTA_PREFIX_LENGTH)}-html5-service`,
255
+ 'service-name': this.buildServiceInstanceName('-html5-service'),
243
256
  'service-plan': 'app-host',
244
257
  service: 'html5-apps-repo'
245
258
  }
@@ -260,7 +273,7 @@ export class MtaConfig {
260
273
  type: 'org.cloudfoundry.managed-service',
261
274
  parameters: {
262
275
  service: 'destination',
263
- 'service-name': destinationName,
276
+ 'service-name': this.buildServiceInstanceName('-destination-service'),
264
277
  'service-plan': 'lite',
265
278
  config: {
266
279
  ...DestinationServiceConfig.config,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@sap-ux/cf-deploy-config-writer",
3
3
  "description": "Add or amend Cloud Foundry and ABAP deployment configuration for SAP projects",
4
- "version": "1.1.7",
4
+ "version": "1.1.9",
5
5
  "repository": {
6
6
  "type": "git",
7
7
  "url": "https://github.com/SAP/open-ux-tools.git",
@@ -30,7 +30,7 @@
30
30
  "mem-fs": "2.1.0",
31
31
  "mem-fs-editor": "9.4.0",
32
32
  "hasbin": "1.2.3",
33
- "@sap-ux/project-access": "2.2.2",
33
+ "@sap-ux/project-access": "2.3.0",
34
34
  "@sap-ux/yaml": "1.0.2",
35
35
  "@sap-ux/btp-utils": "2.0.6",
36
36
  "@sap-ux/logger": "1.0.3",