@progress-chef/platform-bundled-tools-service 1.0.0

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/README.md ADDED
@@ -0,0 +1,41 @@
1
+ # Platform Bundled Tools Service
2
+
3
+ This library provides bundled tools functionality for the Chef Platform UI ecosystem.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm install @progress-chef/platform-bundled-tools-service
9
+ ```
10
+
11
+ ## Usage
12
+
13
+ Import the service in your Angular component or module:
14
+
15
+ ```typescript
16
+ import { BundledToolsService } from '@progress-chef/platform-bundled-tools-service';
17
+
18
+ @Component({
19
+ selector: 'app-example',
20
+ templateUrl: './example.component.html'
21
+ })
22
+ export class ExampleComponent {
23
+ constructor(private bundledToolsService: BundledToolsService) {}
24
+ }
25
+ ```
26
+
27
+ ## Development
28
+
29
+ This library was generated with Angular CLI and follows the standard Angular library structure.
30
+
31
+ ### Building
32
+
33
+ To build the library, run:
34
+
35
+ ```bash
36
+ yarn build:platform-bundled-tools-service
37
+ ```
38
+
39
+ ### Testing
40
+
41
+ Run `ng test platform-bundled-tools-service` to execute the unit tests via Jest.
@@ -0,0 +1,128 @@
1
+ import { Injectable } from '@angular/core';
2
+ import { of } from 'rxjs';
3
+ import { catchError, map } from 'rxjs/operators';
4
+ import * as i0 from "@angular/core";
5
+ import * as i1 from "@angular/common/http";
6
+ export class BundledToolsService {
7
+ constructor(http) {
8
+ this.http = http;
9
+ this.DEFAULT_MAX_VERSION = ''; // Keep field empty when API fails to allow manual entry
10
+ // Base URL will be injected by consuming applications
11
+ this.baseUrl = '';
12
+ // Mapping for skill names that need transformation for API calls
13
+ this.skillNameMapping = {
14
+ 'inspec-interpreter': 'inspec_interpreter',
15
+ 'courier-runner': 'courier-client', // In bundletools, courier-runner is named as courier-client
16
+ };
17
+ }
18
+ /**
19
+ * Sets the base URL for API calls
20
+ * This should be called by the consuming application during initialization
21
+ * @param baseUrl The base URL for the bundled tools API
22
+ */
23
+ setBaseUrl(baseUrl) {
24
+ this.baseUrl = baseUrl;
25
+ }
26
+ /**
27
+ * Retrieves both min and max versions for a skill from a single API call
28
+ * Max version is the latest version, min version is major.0.0 derived from latest
29
+ * @param skillName The name of the skill to get versions for
30
+ * @returns Observable with object containing both maxVersion and minVersion
31
+ */
32
+ getSkillVersions(skillName) {
33
+ if (!skillName) {
34
+ return of({ maxVersion: '', minVersion: '' });
35
+ }
36
+ if (!this.baseUrl) {
37
+ console.error('Base URL not set. Call setBaseUrl() before using this service.');
38
+ return of({ maxVersion: '', minVersion: '' });
39
+ }
40
+ // Extract the actual skill name from the full identifier
41
+ const extractedSkillName = this.extractSkillName(skillName);
42
+ // Transform skill name if needed for API call
43
+ const apiSkillName = this.skillNameMapping[extractedSkillName] || extractedSkillName;
44
+ // Construct the bundled tools API endpoint
45
+ const endpoint = `${this.baseUrl}/platform/bundledtools/v1/static/downloads/${apiSkillName}/latest`;
46
+ return this.http.get(endpoint, { responseType: 'text' }).pipe(map((response) => {
47
+ const version = response.trim();
48
+ const maxVersion = version.startsWith('v') ? version.substring(1) : version;
49
+ const minVersion = this.calculateMinVersionFromLatest(maxVersion);
50
+ return { maxVersion, minVersion };
51
+ }), catchError((error) => {
52
+ console.error('Error fetching skill versions:', error);
53
+ return of({ maxVersion: '', minVersion: '' });
54
+ }));
55
+ }
56
+ /**
57
+ * Retrieves the latest version (max version) for a skill from bundled tools API
58
+ * @param skillName The name of the skill to get version for
59
+ * @returns Observable with the latest version string
60
+ */
61
+ getLatestSkillVersion(skillName) {
62
+ return this.getSkillVersions(skillName).pipe(map((versions) => versions.maxVersion));
63
+ }
64
+ /**
65
+ * Retrieves the calculated min version for a skill based on latest version
66
+ * Min version is major.0.0 derived from the latest version
67
+ * @param skillName The name of the skill to get min version for
68
+ * @returns Observable with the calculated min version or empty string on error
69
+ */
70
+ getSkillMinVersion(skillName) {
71
+ return this.getSkillVersions(skillName).pipe(map((versions) => versions.minVersion));
72
+ }
73
+ /**
74
+ * Extracts the skill name from full skill identifier
75
+ * @param skillIdentifier Full skill identifier like 'chef-platform/shell-interpreter'
76
+ * @returns Just the skill name like 'shell-interpreter'
77
+ */
78
+ extractSkillName(skillIdentifier) {
79
+ if (skillIdentifier.includes('/')) {
80
+ return skillIdentifier.split('/').pop() || skillIdentifier;
81
+ }
82
+ return skillIdentifier;
83
+ }
84
+ /**
85
+ * Gets the default max version fallback value
86
+ * @returns The default max version string
87
+ */
88
+ getDefaultMaxVersion() {
89
+ return this.DEFAULT_MAX_VERSION;
90
+ }
91
+ /**
92
+ * Checks if a skill name needs API transformation
93
+ * @param skillName The skill name to check
94
+ * @returns The transformed skill name for API calls
95
+ */
96
+ getApiSkillName(skillName) {
97
+ const extractedSkillName = this.extractSkillName(skillName);
98
+ return this.skillNameMapping[extractedSkillName] || extractedSkillName;
99
+ }
100
+ /**
101
+ * Calculates the min version from the latest version by setting minor and patch to 0
102
+ * Example: "1.2.3" -> "1.0.0", "2.5.1" -> "2.0.0"
103
+ * @param latestVersion The latest version string
104
+ * @returns The calculated min version (major.0.0)
105
+ */
106
+ calculateMinVersionFromLatest(latestVersion) {
107
+ if (!latestVersion) {
108
+ return '';
109
+ }
110
+ // Parse version string to extract major version
111
+ const versionParts = latestVersion.split('.');
112
+ if (versionParts.length < 3 || !versionParts[0]) {
113
+ return '';
114
+ }
115
+ // Get major version (first part) and set minor/patch to 0
116
+ const majorVersion = versionParts[0];
117
+ return `${majorVersion}.0.0`;
118
+ }
119
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: BundledToolsService, deps: [{ token: i1.HttpClient }], target: i0.ɵɵFactoryTarget.Injectable }); }
120
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: BundledToolsService, providedIn: 'root' }); }
121
+ }
122
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: BundledToolsService, decorators: [{
123
+ type: Injectable,
124
+ args: [{
125
+ providedIn: 'root',
126
+ }]
127
+ }], ctorParameters: () => [{ type: i1.HttpClient }] });
128
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYnVuZGxlZC10b29scy5zZXJ2aWNlLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vLi4vcHJvamVjdHMvcGxhdGZvcm0tYnVuZGxlZC10b29scy1zZXJ2aWNlL3NyYy9saWIvYnVuZGxlZC10b29scy5zZXJ2aWNlLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLE9BQU8sRUFBRSxVQUFVLEVBQUUsTUFBTSxlQUFlLENBQUM7QUFFM0MsT0FBTyxFQUFjLEVBQUUsRUFBRSxNQUFNLE1BQU0sQ0FBQztBQUN0QyxPQUFPLEVBQUUsVUFBVSxFQUFFLEdBQUcsRUFBRSxNQUFNLGdCQUFnQixDQUFDOzs7QUFLakQsTUFBTSxPQUFPLG1CQUFtQjtJQVk5QixZQUNtQixJQUFnQjtRQUFoQixTQUFJLEdBQUosSUFBSSxDQUFZO1FBWmxCLHdCQUFtQixHQUFHLEVBQUUsQ0FBQyxDQUFDLHdEQUF3RDtRQUVuRyxzREFBc0Q7UUFDOUMsWUFBTyxHQUFXLEVBQUUsQ0FBQztRQUU3QixpRUFBaUU7UUFDaEQscUJBQWdCLEdBQThCO1lBQzdELG9CQUFvQixFQUFFLG9CQUFvQjtZQUMxQyxnQkFBZ0IsRUFBRSxnQkFBZ0IsRUFBRSw0REFBNEQ7U0FDakcsQ0FBQztJQUlDLENBQUM7SUFFSjs7OztPQUlHO0lBQ0gsVUFBVSxDQUFDLE9BQWU7UUFDeEIsSUFBSSxDQUFDLE9BQU8sR0FBRyxPQUFPLENBQUM7SUFDekIsQ0FBQztJQUVEOzs7OztPQUtHO0lBQ0gsZ0JBQWdCLENBQUMsU0FBaUI7UUFDaE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b24gVGhlIGxhdGVzdCB2ZXJzaW9uIHN0cmluZ1xuICAgKiBAcmV0dXJucyBUaGUgY2FsY3VsYXRlZCBtaW4gdmVyc2lvbiAobWFqb3IuMC4wKVxuICAgKi9cbiAgcHJpdmF0ZSBjYWxjdWxhdGVNaW5WZXJzaW9uRnJvbUxhdGVzdChsYXRlc3RWZXJzaW9uOiBzdHJpbmcpOiBzdHJpbmcge1xuICAgIGlmICghbGF0ZXN0VmVyc2lvbikge1xuICAgICAgcmV0dXJuICcnO1xuICAgIH1cblxuICAgIC8vIFBhcnNlIHZlcnNpb24gc3RyaW5nIHRvIGV4dHJhY3QgbWFqb3IgdmVyc2lvblxuICAgIGNvbnN0IHZlcnNpb25QYXJ0cyA9IGxhdGVzdFZlcnNpb24uc3BsaXQoJy4nKTtcbiAgICBcbiAgICBpZiAodmVyc2lvblBhcnRzLmxlbmd0aCA8IDMgfHwgIXZlcnNpb25QYXJ0c1swXSkge1xuICAgICAgcmV0dXJuICcnO1xuICAgIH1cblxuICAgIC8vIEdldCBtYWpvciB2ZXJzaW9uIChmaXJzdCBwYXJ0KSBhbmQgc2V0IG1pbm9yL3BhdGNoIHRvIDBcbiAgICBjb25zdCBtYWpvclZlcnNpb24gPSB2ZXJzaW9uUGFydHNbMF07XG4gICAgcmV0dXJuIGAke21ham9yVmVyc2lvbn0uMC4wYDtcbiAgfVxufVxuIl19
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Generated bundle index. Do not edit.
3
+ */
4
+ export * from './public-api';
5
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicHJvZ3Jlc3MtY2hlZi1wbGF0Zm9ybS1idW5kbGVkLXRvb2xzLXNlcnZpY2UuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi9wcm9qZWN0cy9wbGF0Zm9ybS1idW5kbGVkLXRvb2xzLXNlcnZpY2Uvc3JjL3Byb2dyZXNzLWNoZWYtcGxhdGZvcm0tYnVuZGxlZC10b29scy1zZXJ2aWNlLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBOztHQUVHO0FBRUgsY0FBYyxjQUFjLENBQUMiLCJzb3VyY2VzQ29udGVudCI6WyIvKipcbiAqIEdlbmVyYXRlZCBidW5kbGUgaW5kZXguIERvIG5vdCBlZGl0LlxuICovXG5cbmV4cG9ydCAqIGZyb20gJy4vcHVibGljLWFwaSc7XG4iXX0=
@@ -0,0 +1,5 @@
1
+ /*
2
+ * Public API Surface of platform-bundled-tools-service
3
+ */
4
+ export * from './lib/bundled-tools.service';
5
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicHVibGljLWFwaS5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uL3Byb2plY3RzL3BsYXRmb3JtLWJ1bmRsZWQtdG9vbHMtc2VydmljZS9zcmMvcHVibGljLWFwaS50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQTs7R0FFRztBQUVILGNBQWMsNkJBQTZCLENBQUMiLCJzb3VyY2VzQ29udGVudCI6WyIvKlxuICogUHVibGljIEFQSSBTdXJmYWNlIG9mIHBsYXRmb3JtLWJ1bmRsZWQtdG9vbHMtc2VydmljZVxuICovXG5cbmV4cG9ydCAqIGZyb20gJy4vbGliL2J1bmRsZWQtdG9vbHMuc2VydmljZSc7XG4iXX0=
@@ -0,0 +1,139 @@
1
+ import * as i0 from '@angular/core';
2
+ import { Injectable } from '@angular/core';
3
+ import { of } from 'rxjs';
4
+ import { map, catchError } from 'rxjs/operators';
5
+ import * as i1 from '@angular/common/http';
6
+
7
+ class BundledToolsService {
8
+ constructor(http) {
9
+ this.http = http;
10
+ this.DEFAULT_MAX_VERSION = ''; // Keep field empty when API fails to allow manual entry
11
+ // Base URL will be injected by consuming applications
12
+ this.baseUrl = '';
13
+ // Mapping for skill names that need transformation for API calls
14
+ this.skillNameMapping = {
15
+ 'inspec-interpreter': 'inspec_interpreter',
16
+ 'courier-runner': 'courier-client', // In bundletools, courier-runner is named as courier-client
17
+ };
18
+ }
19
+ /**
20
+ * Sets the base URL for API calls
21
+ * This should be called by the consuming application during initialization
22
+ * @param baseUrl The base URL for the bundled tools API
23
+ */
24
+ setBaseUrl(baseUrl) {
25
+ this.baseUrl = baseUrl;
26
+ }
27
+ /**
28
+ * Retrieves both min and max versions for a skill from a single API call
29
+ * Max version is the latest version, min version is major.0.0 derived from latest
30
+ * @param skillName The name of the skill to get versions for
31
+ * @returns Observable with object containing both maxVersion and minVersion
32
+ */
33
+ getSkillVersions(skillName) {
34
+ if (!skillName) {
35
+ return of({ maxVersion: '', minVersion: '' });
36
+ }
37
+ if (!this.baseUrl) {
38
+ console.error('Base URL not set. Call setBaseUrl() before using this service.');
39
+ return of({ maxVersion: '', minVersion: '' });
40
+ }
41
+ // Extract the actual skill name from the full identifier
42
+ const extractedSkillName = this.extractSkillName(skillName);
43
+ // Transform skill name if needed for API call
44
+ const apiSkillName = this.skillNameMapping[extractedSkillName] || extractedSkillName;
45
+ // Construct the bundled tools API endpoint
46
+ const endpoint = `${this.baseUrl}/platform/bundledtools/v1/static/downloads/${apiSkillName}/latest`;
47
+ return this.http.get(endpoint, { responseType: 'text' }).pipe(map((response) => {
48
+ const version = response.trim();
49
+ const maxVersion = version.startsWith('v') ? version.substring(1) : version;
50
+ const minVersion = this.calculateMinVersionFromLatest(maxVersion);
51
+ return { maxVersion, minVersion };
52
+ }), catchError((error) => {
53
+ console.error('Error fetching skill versions:', error);
54
+ return of({ maxVersion: '', minVersion: '' });
55
+ }));
56
+ }
57
+ /**
58
+ * Retrieves the latest version (max version) for a skill from bundled tools API
59
+ * @param skillName The name of the skill to get version for
60
+ * @returns Observable with the latest version string
61
+ */
62
+ getLatestSkillVersion(skillName) {
63
+ return this.getSkillVersions(skillName).pipe(map((versions) => versions.maxVersion));
64
+ }
65
+ /**
66
+ * Retrieves the calculated min version for a skill based on latest version
67
+ * Min version is major.0.0 derived from the latest version
68
+ * @param skillName The name of the skill to get min version for
69
+ * @returns Observable with the calculated min version or empty string on error
70
+ */
71
+ getSkillMinVersion(skillName) {
72
+ return this.getSkillVersions(skillName).pipe(map((versions) => versions.minVersion));
73
+ }
74
+ /**
75
+ * Extracts the skill name from full skill identifier
76
+ * @param skillIdentifier Full skill identifier like 'chef-platform/shell-interpreter'
77
+ * @returns Just the skill name like 'shell-interpreter'
78
+ */
79
+ extractSkillName(skillIdentifier) {
80
+ if (skillIdentifier.includes('/')) {
81
+ return skillIdentifier.split('/').pop() || skillIdentifier;
82
+ }
83
+ return skillIdentifier;
84
+ }
85
+ /**
86
+ * Gets the default max version fallback value
87
+ * @returns The default max version string
88
+ */
89
+ getDefaultMaxVersion() {
90
+ return this.DEFAULT_MAX_VERSION;
91
+ }
92
+ /**
93
+ * Checks if a skill name needs API transformation
94
+ * @param skillName The skill name to check
95
+ * @returns The transformed skill name for API calls
96
+ */
97
+ getApiSkillName(skillName) {
98
+ const extractedSkillName = this.extractSkillName(skillName);
99
+ return this.skillNameMapping[extractedSkillName] || extractedSkillName;
100
+ }
101
+ /**
102
+ * Calculates the min version from the latest version by setting minor and patch to 0
103
+ * Example: "1.2.3" -> "1.0.0", "2.5.1" -> "2.0.0"
104
+ * @param latestVersion The latest version string
105
+ * @returns The calculated min version (major.0.0)
106
+ */
107
+ calculateMinVersionFromLatest(latestVersion) {
108
+ if (!latestVersion) {
109
+ return '';
110
+ }
111
+ // Parse version string to extract major version
112
+ const versionParts = latestVersion.split('.');
113
+ if (versionParts.length < 3 || !versionParts[0]) {
114
+ return '';
115
+ }
116
+ // Get major version (first part) and set minor/patch to 0
117
+ const majorVersion = versionParts[0];
118
+ return `${majorVersion}.0.0`;
119
+ }
120
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: BundledToolsService, deps: [{ token: i1.HttpClient }], target: i0.ɵɵFactoryTarget.Injectable }); }
121
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: BundledToolsService, providedIn: 'root' }); }
122
+ }
123
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: BundledToolsService, decorators: [{
124
+ type: Injectable,
125
+ args: [{
126
+ providedIn: 'root',
127
+ }]
128
+ }], ctorParameters: () => [{ type: i1.HttpClient }] });
129
+
130
+ /*
131
+ * Public API Surface of platform-bundled-tools-service
132
+ */
133
+
134
+ /**
135
+ * Generated bundle index. Do not edit.
136
+ */
137
+
138
+ export { BundledToolsService };
139
+ //# sourceMappingURL=progress-chef-platform-bundled-tools-service.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"progress-chef-platform-bundled-tools-service.mjs","sources":["../../../projects/platform-bundled-tools-service/src/lib/bundled-tools.service.ts","../../../projects/platform-bundled-tools-service/src/public-api.ts","../../../projects/platform-bundled-tools-service/src/progress-chef-platform-bundled-tools-service.ts"],"sourcesContent":["import { Injectable } from '@angular/core';\nimport { HttpClient } from '@angular/common/http';\nimport { Observable, of } from 'rxjs';\nimport { catchError, map } from 'rxjs/operators';\n\n@Injectable({\n providedIn: 'root',\n})\nexport class BundledToolsService {\n private readonly DEFAULT_MAX_VERSION = ''; // Keep field empty when API fails to allow manual entry\n\n // Base URL will be injected by consuming applications\n private baseUrl: string = '';\n\n // Mapping for skill names that need transformation for API calls\n private readonly skillNameMapping: { [key: string]: string } = {\n 'inspec-interpreter': 'inspec_interpreter',\n 'courier-runner': 'courier-client', // In bundletools, courier-runner is named as courier-client\n };\n \n constructor(\n private readonly http: HttpClient,\n ) {}\n\n /**\n * Sets the base URL for API calls\n * This should be called by the consuming application during initialization\n * @param baseUrl The base URL for the bundled tools API\n */\n setBaseUrl(baseUrl: string): void {\n this.baseUrl = baseUrl;\n }\n\n /**\n * Retrieves both min and max versions for a skill from a single API call\n * Max version is the latest version, min version is major.0.0 derived from latest\n * @param skillName The name of the skill to get versions for\n * @returns Observable with object containing both maxVersion and minVersion\n */\n getSkillVersions(skillName: string): Observable<{ maxVersion: string; minVersion: string }> {\n if (!skillName) {\n return of({ maxVersion: '', minVersion: '' });\n }\n\n if (!this.baseUrl) {\n console.error('Base URL not set. Call setBaseUrl() before using this service.');\n return of({ maxVersion: '', minVersion: '' });\n }\n\n // Extract the actual skill name from the full identifier\n const extractedSkillName = this.extractSkillName(skillName);\n \n // Transform skill name if needed for API call\n const apiSkillName = this.skillNameMapping[extractedSkillName] || extractedSkillName;\n \n // Construct the bundled tools API endpoint\n const endpoint = `${this.baseUrl}/platform/bundledtools/v1/static/downloads/${apiSkillName}/latest`;\n\n return this.http.get(endpoint, { responseType: 'text' }).pipe(\n map((response: string) => {\n const version = response.trim();\n const maxVersion = version.startsWith('v') ? version.substring(1) : version;\n const minVersion = this.calculateMinVersionFromLatest(maxVersion);\n return { maxVersion, minVersion };\n }),\n catchError((error) => {\n console.error('Error fetching skill versions:', error);\n return of({ maxVersion: '', minVersion: '' });\n })\n );\n }\n\n /**\n * Retrieves the latest version (max version) for a skill from bundled tools API\n * @param skillName The name of the skill to get version for\n * @returns Observable with the latest version string\n */\n getLatestSkillVersion(skillName: string): Observable<string> {\n return this.getSkillVersions(skillName).pipe(\n map((versions) => versions.maxVersion)\n );\n }\n\n /**\n * Retrieves the calculated min version for a skill based on latest version\n * Min version is major.0.0 derived from the latest version\n * @param skillName The name of the skill to get min version for\n * @returns Observable with the calculated min version or empty string on error\n */\n getSkillMinVersion(skillName: string): Observable<string> {\n return this.getSkillVersions(skillName).pipe(\n map((versions) => versions.minVersion)\n );\n }\n\n /**\n * Extracts the skill name from full skill identifier\n * @param skillIdentifier Full skill identifier like 'chef-platform/shell-interpreter'\n * @returns Just the skill name like 'shell-interpreter'\n */\n private extractSkillName(skillIdentifier: string): string {\n if (skillIdentifier.includes('/')) {\n return skillIdentifier.split('/').pop() || skillIdentifier;\n }\n return skillIdentifier;\n }\n\n /**\n * Gets the default max version fallback value\n * @returns The default max version string\n */\n getDefaultMaxVersion(): string {\n return this.DEFAULT_MAX_VERSION;\n }\n\n /**\n * Checks if a skill name needs API transformation\n * @param skillName The skill name to check\n * @returns The transformed skill name for API calls\n */\n getApiSkillName(skillName: string): string {\n const extractedSkillName = this.extractSkillName(skillName);\n return this.skillNameMapping[extractedSkillName] || extractedSkillName;\n }\n\n /**\n * Calculates the min version from the latest version by setting minor and patch to 0\n * Example: \"1.2.3\" -> \"1.0.0\", \"2.5.1\" -> \"2.0.0\"\n * @param latestVersion The latest version string\n * @returns The calculated min version (major.0.0)\n */\n private calculateMinVersionFromLatest(latestVersion: string): string {\n if (!latestVersion) {\n return '';\n }\n\n // Parse version string to extract major version\n const versionParts = latestVersion.split('.');\n \n if (versionParts.length < 3 || !versionParts[0]) {\n return '';\n }\n\n // Get major version (first part) and set minor/patch to 0\n const majorVersion = versionParts[0];\n return `${majorVersion}.0.0`;\n }\n}\n","/*\n * Public API Surface of platform-bundled-tools-service\n */\n\nexport * from './lib/bundled-tools.service';\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;;;;;MAQa,mBAAmB,CAAA;AAY9B,IAAA,WAAA,CACmB,IAAgB,EAAA;QAAhB,IAAA,CAAA,IAAI,GAAJ,IAAI;AAZN,QAAA,IAAA,CAAA,mBAAmB,GAAG,EAAE,CAAC;;QAGlC,IAAA,CAAA,OAAO,GAAW,EAAE;;AAGX,QAAA,IAAA,CAAA,gBAAgB,GAA8B;AAC7D,YAAA,oBAAoB,EAAE,oBAAoB;YAC1C,gBAAgB,EAAE,gBAAgB;SACnC;IAIE;AAEH;;;;AAIG;AACH,IAAA,UAAU,CAAC,OAAe,EAAA;AACxB,QAAA,IAAI,CAAC,OAAO,GAAG,OAAO;IACxB;AAEA;;;;;AAKG;AACH,IAAA,gBAAgB,CAAC,SAAiB,EAAA;QAChC,IAAI,CAAC,SAAS,EAAE;AACd,YAAA,O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Y,CAAA,IAAA,CAAM;IAC9B;+GA1IW,mBAAmB,EAAA,IAAA,EAAA,CAAA,EAAA,KAAA,EAAA,EAAA,CAAA,UAAA,EAAA,CAAA,EAAA,MAAA,EAAA,EAAA,CAAA,eAAA,CAAA,UAAA,EAAA,CAAA,CAAA;AAAnB,IAAA,SAAA,IAAA,CAAA,KAAA,GAAA,EAAA,CAAA,qBAAA,CAAA,EAAA,UAAA,EAAA,QAAA,EAAA,OAAA,EAAA,SAAA,EAAA,QAAA,EAAA,EAAA,EAAA,IAAA,EAAA,mBAAmB,cAFlB,MAAM,EAAA,CAAA,CAAA;;4FAEP,mBAAmB,EAAA,UAAA,EAAA,CAAA;kBAH/B,UAAU;AAAC,YAAA,IAAA,EAAA,CAAA;AACV,oBAAA,UAAU,EAAE,MAAM;AACnB,iBAAA;;;ACPD;;AAEG;;ACFH;;AAEG;;;;"}
package/index.d.ts ADDED
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Generated bundle index. Do not edit.
3
+ */
4
+ /// <amd-module name="@progress-chef/platform-bundled-tools-service" />
5
+ export * from './public-api';
@@ -0,0 +1,65 @@
1
+ import { HttpClient } from '@angular/common/http';
2
+ import { Observable } from 'rxjs';
3
+ import * as i0 from "@angular/core";
4
+ export declare class BundledToolsService {
5
+ private readonly http;
6
+ private readonly DEFAULT_MAX_VERSION;
7
+ private baseUrl;
8
+ private readonly skillNameMapping;
9
+ constructor(http: HttpClient);
10
+ /**
11
+ * Sets the base URL for API calls
12
+ * This should be called by the consuming application during initialization
13
+ * @param baseUrl The base URL for the bundled tools API
14
+ */
15
+ setBaseUrl(baseUrl: string): void;
16
+ /**
17
+ * Retrieves both min and max versions for a skill from a single API call
18
+ * Max version is the latest version, min version is major.0.0 derived from latest
19
+ * @param skillName The name of the skill to get versions for
20
+ * @returns Observable with object containing both maxVersion and minVersion
21
+ */
22
+ getSkillVersions(skillName: string): Observable<{
23
+ maxVersion: string;
24
+ minVersion: string;
25
+ }>;
26
+ /**
27
+ * Retrieves the latest version (max version) for a skill from bundled tools API
28
+ * @param skillName The name of the skill to get version for
29
+ * @returns Observable with the latest version string
30
+ */
31
+ getLatestSkillVersion(skillName: string): Observable<string>;
32
+ /**
33
+ * Retrieves the calculated min version for a skill based on latest version
34
+ * Min version is major.0.0 derived from the latest version
35
+ * @param skillName The name of the skill to get min version for
36
+ * @returns Observable with the calculated min version or empty string on error
37
+ */
38
+ getSkillMinVersion(skillName: string): Observable<string>;
39
+ /**
40
+ * Extracts the skill name from full skill identifier
41
+ * @param skillIdentifier Full skill identifier like 'chef-platform/shell-interpreter'
42
+ * @returns Just the skill name like 'shell-interpreter'
43
+ */
44
+ private extractSkillName;
45
+ /**
46
+ * Gets the default max version fallback value
47
+ * @returns The default max version string
48
+ */
49
+ getDefaultMaxVersion(): string;
50
+ /**
51
+ * Checks if a skill name needs API transformation
52
+ * @param skillName The skill name to check
53
+ * @returns The transformed skill name for API calls
54
+ */
55
+ getApiSkillName(skillName: string): string;
56
+ /**
57
+ * Calculates the min version from the latest version by setting minor and patch to 0
58
+ * Example: "1.2.3" -> "1.0.0", "2.5.1" -> "2.0.0"
59
+ * @param latestVersion The latest version string
60
+ * @returns The calculated min version (major.0.0)
61
+ */
62
+ private calculateMinVersionFromLatest;
63
+ static ɵfac: i0.ɵɵFactoryDeclaration<BundledToolsService, never>;
64
+ static ɵprov: i0.ɵɵInjectableDeclaration<BundledToolsService>;
65
+ }
package/package.json ADDED
@@ -0,0 +1,28 @@
1
+ {
2
+ "name": "@progress-chef/platform-bundled-tools-service",
3
+ "version": "1.0.0",
4
+ "peerDependencies": {
5
+ "@angular/common": "^19.2.17",
6
+ "@angular/core": "^19.2.17"
7
+ },
8
+ "dependencies": {
9
+ "tslib": "^2.3.0"
10
+ },
11
+ "sideEffects": false,
12
+ "publishConfig": {
13
+ "access": "public"
14
+ },
15
+ "module": "fesm2022/progress-chef-platform-bundled-tools-service.mjs",
16
+ "typings": "index.d.ts",
17
+ "exports": {
18
+ "./package.json": {
19
+ "default": "./package.json"
20
+ },
21
+ ".": {
22
+ "types": "./index.d.ts",
23
+ "esm2022": "./esm2022/progress-chef-platform-bundled-tools-service.mjs",
24
+ "esm": "./esm2022/progress-chef-platform-bundled-tools-service.mjs",
25
+ "default": "./fesm2022/progress-chef-platform-bundled-tools-service.mjs"
26
+ }
27
+ }
28
+ }
@@ -0,0 +1 @@
1
+ export * from './lib/bundled-tools.service';