@kapeta/local-cluster-service 0.60.0 → 0.60.1

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.
package/CHANGELOG.md CHANGED
@@ -1,3 +1,11 @@
1
+ ## [0.60.1](https://github.com/kapetacom/local-cluster-service/compare/v0.60.0...v0.60.1) (2024-08-06)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * broke tests ([e916371](https://github.com/kapetacom/local-cluster-service/commit/e9163710178a01259723346efa346c094794de0b))
7
+ * ensure valid base name for ai generated services ([b3a15ec](https://github.com/kapetacom/local-cluster-service/commit/b3a15ecc297b98671b3029d668b2da46113086ff))
8
+
1
9
  # [0.60.0](https://github.com/kapetacom/local-cluster-service/compare/v0.59.0...v0.60.0) (2024-08-05)
2
10
 
3
11
 
@@ -49,6 +49,7 @@ export declare class StormEventParser {
49
49
  static toInstanceId(handle: string, blockName: string): string;
50
50
  static toInstanceIdFromRef(ref: string): string;
51
51
  static toSafeName(name: string): string;
52
+ static toSafeArtifactName(name: string): string;
52
53
  static toRef(handle: string, name: string): KapetaURI;
53
54
  private events;
54
55
  private planName;
@@ -138,6 +138,13 @@ class StormEventParser {
138
138
  static toSafeName(name) {
139
139
  return name.toLowerCase().replace(/[^0-9a-z-]/gi, '');
140
140
  }
141
+ static toSafeArtifactName(name) {
142
+ let safeName = name.toLowerCase().replace(/[^0-9a-z]/g, '');
143
+ if (/^[0-9]/.test(safeName)) {
144
+ safeName = 'a' + safeName; // Prepend a letter if the string starts with a number
145
+ }
146
+ return safeName;
147
+ }
141
148
  static toRef(handle, name) {
142
149
  return (0, nodejs_utils_1.parseKapetaUri)(handle + '/' + this.toSafeName(name) + ':local');
143
150
  }
@@ -213,4 +213,8 @@ describe('event-parser', () => {
213
213
  expect(postService?.content?.spec?.providers?.length).toBe(1);
214
214
  expect(postService?.content?.spec?.providers[0].spec.source.value.startsWith('controller')).toBeTruthy();
215
215
  });
216
+ it('toSafeName produces valid artifact names', async () => {
217
+ const safeName = event_parser_1.StormEventParser.toSafeArtifactName('Browser-based CRM Application');
218
+ expect(safeName).toBe('browserbasedcrmapplication');
219
+ });
216
220
  });
@@ -49,6 +49,7 @@ export declare class StormEventParser {
49
49
  static toInstanceId(handle: string, blockName: string): string;
50
50
  static toInstanceIdFromRef(ref: string): string;
51
51
  static toSafeName(name: string): string;
52
+ static toSafeArtifactName(name: string): string;
52
53
  static toRef(handle: string, name: string): KapetaURI;
53
54
  private events;
54
55
  private planName;
@@ -138,6 +138,13 @@ class StormEventParser {
138
138
  static toSafeName(name) {
139
139
  return name.toLowerCase().replace(/[^0-9a-z-]/gi, '');
140
140
  }
141
+ static toSafeArtifactName(name) {
142
+ let safeName = name.toLowerCase().replace(/[^0-9a-z]/g, '');
143
+ if (/^[0-9]/.test(safeName)) {
144
+ safeName = 'a' + safeName; // Prepend a letter if the string starts with a number
145
+ }
146
+ return safeName;
147
+ }
141
148
  static toRef(handle, name) {
142
149
  return (0, nodejs_utils_1.parseKapetaUri)(handle + '/' + this.toSafeName(name) + ':local');
143
150
  }
@@ -213,4 +213,8 @@ describe('event-parser', () => {
213
213
  expect(postService?.content?.spec?.providers?.length).toBe(1);
214
214
  expect(postService?.content?.spec?.providers[0].spec.source.value.startsWith('controller')).toBeTruthy();
215
215
  });
216
+ it('toSafeName produces valid artifact names', async () => {
217
+ const safeName = event_parser_1.StormEventParser.toSafeArtifactName('Browser-based CRM Application');
218
+ expect(safeName).toBe('browserbasedcrmapplication');
219
+ });
216
220
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kapeta/local-cluster-service",
3
- "version": "0.60.0",
3
+ "version": "0.60.1",
4
4
  "description": "Manages configuration, ports and service discovery for locally running Kapeta systems",
5
5
  "type": "commonjs",
6
6
  "exports": {
@@ -246,6 +246,14 @@ export class StormEventParser {
246
246
  return name.toLowerCase().replace(/[^0-9a-z-]/gi, '');
247
247
  }
248
248
 
249
+ public static toSafeArtifactName(name: string): string {
250
+ let safeName = name.toLowerCase().replace(/[^0-9a-z]/g, '');
251
+ if (/^[0-9]/.test(safeName)) {
252
+ safeName = 'a' + safeName; // Prepend a letter if the string starts with a number
253
+ }
254
+ return safeName;
255
+ }
256
+
249
257
  public static toRef(handle: string, name: string) {
250
258
  return parseKapetaUri(handle + '/' + this.toSafeName(name) + ':local');
251
259
  }
@@ -240,4 +240,9 @@ describe('event-parser', () => {
240
240
  expect(postService?.content?.spec?.providers?.length).toBe(1);
241
241
  expect(postService?.content?.spec?.providers![0].spec.source.value.startsWith('controller')).toBeTruthy();
242
242
  });
243
+
244
+ it('toSafeName produces valid artifact names', async () => {
245
+ const safeName = StormEventParser.toSafeArtifactName('Browser-based CRM Application');
246
+ expect(safeName).toBe('browserbasedcrmapplication');
247
+ });
243
248
  });