@kapeta/local-cluster-service 0.60.0 → 0.60.2
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 +15 -0
- package/dist/cjs/src/storm/event-parser.d.ts +1 -0
- package/dist/cjs/src/storm/event-parser.js +8 -1
- package/dist/cjs/test/storm/event-parser.test.js +4 -0
- package/dist/esm/src/storm/event-parser.d.ts +1 -0
- package/dist/esm/src/storm/event-parser.js +8 -1
- package/dist/esm/test/storm/event-parser.test.js +4 -0
- package/package.json +1 -1
- package/src/storm/event-parser.ts +9 -1
- package/test/storm/event-parser.test.ts +5 -0
package/CHANGELOG.md
CHANGED
@@ -1,3 +1,18 @@
|
|
1
|
+
## [0.60.2](https://github.com/kapetacom/local-cluster-service/compare/v0.60.1...v0.60.2) (2024-08-06)
|
2
|
+
|
3
|
+
|
4
|
+
### Bug Fixes
|
5
|
+
|
6
|
+
* actually use the new toSafeArtifactName() function ([41f5033](https://github.com/kapetacom/local-cluster-service/commit/41f5033d0a2b2cd21ff6954d2ef3468644ee56c7))
|
7
|
+
|
8
|
+
## [0.60.1](https://github.com/kapetacom/local-cluster-service/compare/v0.60.0...v0.60.1) (2024-08-06)
|
9
|
+
|
10
|
+
|
11
|
+
### Bug Fixes
|
12
|
+
|
13
|
+
* broke tests ([e916371](https://github.com/kapetacom/local-cluster-service/commit/e9163710178a01259723346efa346c094794de0b))
|
14
|
+
* ensure valid base name for ai generated services ([b3a15ec](https://github.com/kapetacom/local-cluster-service/commit/b3a15ecc297b98671b3029d668b2da46113086ff))
|
15
|
+
|
1
16
|
# [0.60.0](https://github.com/kapetacom/local-cluster-service/compare/v0.59.0...v0.60.0) (2024-08-05)
|
2
17
|
|
3
18
|
|
@@ -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
|
}
|
@@ -670,7 +677,7 @@ class StormEventParser {
|
|
670
677
|
let options = {};
|
671
678
|
if (kind.includes('java')) {
|
672
679
|
const groupId = `ai.${StormEventParser.toSafeName(handle)}`;
|
673
|
-
const artifactId = StormEventParser.
|
680
|
+
const artifactId = StormEventParser.toSafeArtifactName(this.planName);
|
674
681
|
options = {
|
675
682
|
groupId,
|
676
683
|
artifactId,
|
@@ -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
|
}
|
@@ -670,7 +677,7 @@ class StormEventParser {
|
|
670
677
|
let options = {};
|
671
678
|
if (kind.includes('java')) {
|
672
679
|
const groupId = `ai.${StormEventParser.toSafeName(handle)}`;
|
673
|
-
const artifactId = StormEventParser.
|
680
|
+
const artifactId = StormEventParser.toSafeArtifactName(this.planName);
|
674
681
|
options = {
|
675
682
|
groupId,
|
676
683
|
artifactId,
|
@@ -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
@@ -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
|
}
|
@@ -874,7 +882,7 @@ export class StormEventParser {
|
|
874
882
|
|
875
883
|
if (kind.includes('java')) {
|
876
884
|
const groupId = `ai.${StormEventParser.toSafeName(handle)}`;
|
877
|
-
const artifactId = StormEventParser.
|
885
|
+
const artifactId = StormEventParser.toSafeArtifactName(this.planName);
|
878
886
|
options = {
|
879
887
|
groupId,
|
880
888
|
artifactId,
|
@@ -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
|
});
|