@firestartr/cli 2.1.0 → 2.2.0-snapshot-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/build/index.js CHANGED
@@ -358185,6 +358185,17 @@ const external_node_child_process_namespaceObject = __WEBPACK_EXTERNAL_createReq
358185
358185
  $schema: SCHEMA,
358186
358186
  $id: 'ComponentClaim',
358187
358187
  definitions: {
358188
+ ApiDefinition: {
358189
+ $id: 'firestartr.dev://common/ComponentClaimApiDefinition',
358190
+ type: 'object',
358191
+ properties: {
358192
+ name: { type: 'string' },
358193
+ definitionfile: { type: 'string' },
358194
+ type: { type: 'string' },
358195
+ },
358196
+ required: ['name', 'definitionfile', 'type'],
358197
+ additionalProperties: false,
358198
+ },
358188
358199
  ComponentClaim: {
358189
358200
  $id: 'firestartr.dev://common/ComponentClaim',
358190
358201
  type: 'object',
@@ -358209,6 +358220,26 @@ const external_node_child_process_namespaceObject = __WEBPACK_EXTERNAL_createReq
358209
358220
  subComponentOf: {
358210
358221
  $ref: 'firestartr.dev://common/FirestartrComponentRef',
358211
358222
  },
358223
+ providesApis: {
358224
+ anyOf: [
358225
+ {
358226
+ type: 'array',
358227
+ items: {
358228
+ $ref: 'firestartr.dev://common/ComponentClaimApiDefinition',
358229
+ },
358230
+ },
358231
+ {
358232
+ type: 'object',
358233
+ additionalProperties: {
358234
+ $ref: 'firestartr.dev://common/ComponentClaimApiDefinition',
358235
+ },
358236
+ },
358237
+ ],
358238
+ },
358239
+ consumesApis: {
358240
+ type: 'array',
358241
+ items: { type: 'string' },
358242
+ },
358212
358243
  providers: {
358213
358244
  type: 'object',
358214
358245
  properties: {
@@ -361980,6 +362011,12 @@ function isPathInside(pathA, pathB) {
361980
362011
  return (normalizedPathB.startsWith(pathAWithSeparator) ||
361981
362012
  normalizedPathB === normalizedPathA);
361982
362013
  }
362014
+ function sanitizeApiEntityName(name) {
362015
+ return name
362016
+ .toLowerCase()
362017
+ .replace(/[^a-z0-9-]/g, '-')
362018
+ .replace(/^-+|-+$/g, '');
362019
+ }
361983
362020
 
361984
362021
  ;// CONCATENATED MODULE: ../cdk8s_renderer/imports/firestartr.dev.ts
361985
362022
  // generated by cdk8s
@@ -365384,9 +365421,19 @@ class CatalogUserChart extends BaseCatalogChart {
365384
365421
  ;// CONCATENATED MODULE: ../cdk8s_renderer/src/charts/catalog/componentChart.ts
365385
365422
 
365386
365423
 
365424
+
365425
+ function claimProvidesApis(claim) {
365426
+ if (!claim.providesApis)
365427
+ return undefined;
365428
+ if (Array.isArray(claim.providesApis)) {
365429
+ return claim.providesApis.map((api) => sanitizeApiEntityName(api.name));
365430
+ }
365431
+ return Object.values(claim.providesApis).map((api) => sanitizeApiEntityName(api.name));
365432
+ }
365387
365433
  class CatalogComponentChart extends BaseCatalogChart {
365388
365434
  template() {
365389
365435
  const claim = this.get('claim');
365436
+ const providesApis = claimProvidesApis(claim);
365390
365437
  return {
365391
365438
  apiVersion: 'backstage.io/v1alpha1',
365392
365439
  kind: 'Component',
@@ -365400,6 +365447,8 @@ class CatalogComponentChart extends BaseCatalogChart {
365400
365447
  owner: claim.owner || 'nobody',
365401
365448
  system: claim.system,
365402
365449
  subComponentOf: claim.subComponentOf,
365450
+ ...(providesApis ? { providesApis } : {}),
365451
+ ...(claim.consumesApis ? { consumesApis: claim.consumesApis } : {}),
365403
365452
  },
365404
365453
  };
365405
365454
  }
@@ -365568,6 +365617,41 @@ class CatalogOrgWebhookChart extends BaseCatalogChart {
365568
365617
  }
365569
365618
  }
365570
365619
 
365620
+ ;// CONCATENATED MODULE: ../cdk8s_renderer/src/charts/catalog/apiChart.ts
365621
+
365622
+
365623
+ class CatalogApiChart extends BaseCatalogChart {
365624
+ template() {
365625
+ const claim = this.get('claim');
365626
+ return {
365627
+ apiVersion: 'backstage.io/v1alpha1',
365628
+ kind: 'API',
365629
+ metadata: {
365630
+ name: claim.name,
365631
+ annotations: claim.annotations || {},
365632
+ },
365633
+ spec: {
365634
+ type: claim.type,
365635
+ lifecycle: claim.lifecycle,
365636
+ owner: claim.owner || 'nobody',
365637
+ system: claim.system,
365638
+ definition: {
365639
+ $text: claim.definitionUrl,
365640
+ },
365641
+ },
365642
+ };
365643
+ }
365644
+ instanceApiObject(template) {
365645
+ return new lib.ApiObject(this, `${template.kind}-${template.metadata.name}`, template);
365646
+ }
365647
+ gvk() {
365648
+ return {
365649
+ kind: 'API',
365650
+ apiVersion: 'v1alpha1',
365651
+ };
365652
+ }
365653
+ }
365654
+
365571
365655
  ;// CONCATENATED MODULE: ../cdk8s_renderer/src/charts/catalog/index.ts
365572
365656
 
365573
365657
 
@@ -365579,6 +365663,7 @@ class CatalogOrgWebhookChart extends BaseCatalogChart {
365579
365663
 
365580
365664
 
365581
365665
 
365666
+
365582
365667
  ;// CONCATENATED MODULE: ../cdk8s_renderer/src/charts/workspaces/base.ts
365583
365668
 
365584
365669
  class BaseWorkspaceChart extends BaseChart {
@@ -365934,6 +366019,7 @@ class SecretsChart extends BaseSecretsChart {
365934
366019
  CatalogArgoDeployChart: CatalogArgoDeployChart,
365935
366020
  CatalogSecretsChart: CatalogSecretsChart,
365936
366021
  CatalogOrgWebhookChart: CatalogOrgWebhookChart,
366022
+ CatalogApiChart: CatalogApiChart,
365937
366023
  GithubGroupChart: GithubGroupChart,
365938
366024
  GithubMembershipChart: GithubMembershipChart,
365939
366025
  GithubRepositoryChart: GithubRepositoryChart,
@@ -365951,6 +366037,15 @@ class SecretsChart extends BaseSecretsChart {
365951
366037
 
365952
366038
 
365953
366039
 
366040
+
366041
+ function normalizeProvidesApis(providesApis) {
366042
+ if (!providesApis)
366043
+ return [];
366044
+ if (Array.isArray(providesApis)) {
366045
+ return providesApis;
366046
+ }
366047
+ return Object.values(providesApis);
366048
+ }
365954
366049
  async function renderClaims(catalogScope, firestartrScope, data) {
365955
366050
  const result = {};
365956
366051
  const { renderClaims, crs } = data;
@@ -365983,6 +366078,11 @@ async function renderClaims(catalogScope, firestartrScope, data) {
365983
366078
  result[`${catalogEntity.kind}-${catalogEntity.metadata.name}`] =
365984
366079
  catalogEntity.toJson();
365985
366080
  }
366081
+ for (const extraChart of extraCharts) {
366082
+ const { claim, chart } = extraChart;
366083
+ setRenderedClaim(claim, chart.toJson());
366084
+ result[`${chart.kind}-${chart.metadata.name}`] = chart.toJson();
366085
+ }
365986
366086
  /**
365987
366087
  * If there is no provider don't store the CR in the map
365988
366088
  */
@@ -365990,11 +366090,6 @@ async function renderClaims(catalogScope, firestartrScope, data) {
365990
366090
  continue;
365991
366091
  const firestartrEntityJson = firestartrEntity.toJson();
365992
366092
  setRenderedClaim(claim, firestartrEntityJson);
365993
- for (const extraChart of extraCharts) {
365994
- const { claim, chart } = extraChart;
365995
- setRenderedClaim(claim, chart.toJson());
365996
- result[`${chart.kind}-${chart.metadata.name}`] = chart.toJson();
365997
- }
365998
366093
  if (!firestartrEntityJson.metadata.annotations ||
365999
366094
  !firestartrEntityJson.metadata.name)
366000
366095
  throw firestartrEntityJson;
@@ -366010,6 +366105,7 @@ async function renderClaims(catalogScope, firestartrScope, data) {
366010
366105
  async function renderClaim(catalogScope, firestartrScope, claim, patches, previousCR = null) {
366011
366106
  let catalogEntity = undefined;
366012
366107
  let firestartrEntity = undefined;
366108
+ const extraCharts = [];
366013
366109
  const chartId = `${claim.kind}-${claim.name}`.toLowerCase();
366014
366110
  let firestartrId = null;
366015
366111
  if (previousCR) {
@@ -366056,6 +366152,47 @@ async function renderClaim(catalogScope, firestartrScope, claim, patches, previo
366056
366152
  }
366057
366153
  if (loadCatalog) {
366058
366154
  catalogEntity = new charts.CatalogComponentChart(catalogScope, chartId, firestartrId, claim, renderPatches);
366155
+ const githubProvider = claim.providers?.github;
366156
+ const org = githubProvider?.org;
366157
+ const repoName = githubProvider?.name;
366158
+ const defaultBranch = githubProvider?.branchStrategy?.defaultBranch || 'main';
366159
+ for (const apiDefinition of normalizeProvidesApis(claim.providesApis)) {
366160
+ if (!org ||
366161
+ !repoName ||
366162
+ !apiDefinition?.definitionfile ||
366163
+ !apiDefinition?.name) {
366164
+ cdk8s_renderer_src_logger.warn(`Skipping API generation for component ${claim.name} due to missing github provider fields or API definition data`);
366165
+ continue;
366166
+ }
366167
+ const definitionFilePath = String(apiDefinition.definitionfile).replace(/^\/+/, '');
366168
+ const encodedDefinitionFilePath = definitionFilePath
366169
+ .split('/')
366170
+ .map((segment) => encodeURIComponent(segment))
366171
+ .join('/');
366172
+ const definitionUrl = `https://raw.githubusercontent.com/${org}/${repoName}/refs/heads/${defaultBranch}/${encodedDefinitionFilePath}`;
366173
+ const sanitizedApiName = sanitizeApiEntityName(apiDefinition.name);
366174
+ const apiChart = new charts.CatalogApiChart(catalogScope, `${chartId}-api-${sanitizedApiName}`, firestartrId, {
366175
+ name: sanitizedApiName,
366176
+ type: apiDefinition.type,
366177
+ lifecycle: claim.lifecycle,
366178
+ owner: claim.owner,
366179
+ system: claim.system,
366180
+ definitionUrl,
366181
+ annotations: {
366182
+ ...(claim.annotations || {}),
366183
+ title: apiDefinition.name,
366184
+ },
366185
+ }, []);
366186
+ await apiChart.render();
366187
+ const apiObject = await apiChart.postRenderer([]);
366188
+ extraCharts.push({
366189
+ claim: {
366190
+ kind: 'API',
366191
+ name: sanitizedApiName,
366192
+ },
366193
+ chart: apiObject,
366194
+ });
366195
+ }
366059
366196
  }
366060
366197
  break;
366061
366198
  case 'TFWorkspaceClaim':
@@ -366128,7 +366265,10 @@ async function renderClaim(catalogScope, firestartrScope, claim, patches, previo
366128
366265
  firestartrEntity: await (firestartrEntityChart
366129
366266
  ? firestartrEntityChart.postRenderer(postPatches)
366130
366267
  : undefined),
366131
- extraCharts: (await firestartrEntity?.extraCharts()) || [],
366268
+ extraCharts: [
366269
+ ...((await firestartrEntity?.extraCharts()) || []),
366270
+ ...extraCharts,
366271
+ ],
366132
366272
  };
366133
366273
  }
366134
366274
 
@@ -379457,7 +379597,7 @@ const crs_analyzerSubcommand = {
379457
379597
  };
379458
379598
 
379459
379599
  ;// CONCATENATED MODULE: ./package.json
379460
- const package_namespaceObject = {"i8":"2.1.0"};
379600
+ const package_namespaceObject = JSON.parse('{"i8":"2.2.0-snapshot-0"}');
379461
379601
  ;// CONCATENATED MODULE: ../../package.json
379462
379602
  const package_namespaceObject_1 = {"i8":"2.1.0"};
379463
379603
  ;// CONCATENATED MODULE: ./src/subcommands/index.ts
@@ -0,0 +1,23 @@
1
+ import { BaseCatalogChart } from './base';
2
+ import { ApiObject, GroupVersionKind } from 'cdk8s';
3
+ export declare class CatalogApiChart extends BaseCatalogChart {
4
+ template(): {
5
+ apiVersion: string;
6
+ kind: string;
7
+ metadata: {
8
+ name: string;
9
+ annotations: Record<string, string>;
10
+ };
11
+ spec: {
12
+ type: string;
13
+ lifecycle: string;
14
+ owner: string;
15
+ system: string;
16
+ definition: {
17
+ $text: string;
18
+ };
19
+ };
20
+ };
21
+ instanceApiObject(template: any): ApiObject;
22
+ gvk(): GroupVersionKind;
23
+ }
@@ -11,6 +11,8 @@ export declare class CatalogComponentChart extends BaseCatalogChart {
11
11
  };
12
12
  };
13
13
  spec: {
14
+ consumesApis?: string[];
15
+ providesApis?: string[];
14
16
  type: string;
15
17
  lifecycle: string;
16
18
  owner: string;
@@ -7,3 +7,4 @@ export { CatalogTFWorkspaceChart } from './tfWorkspaceChart';
7
7
  export { CatalogArgoDeployChart } from './argodeployChart';
8
8
  export { CatalogSecretsChart } from './secretsChart';
9
9
  export { CatalogOrgWebhookChart } from './orgWebhookChart';
10
+ export { CatalogApiChart } from './apiChart';
@@ -1,5 +1,5 @@
1
1
  import { GithubGroupChart, GithubMembershipChart, GithubRepositoryChart, GithubOrgWebhookChart } from './github';
2
- import { CatalogComponentChart, CatalogDomainChart, CatalogGroupChart, CatalogSystemChart, CatalogUserChart, CatalogTFWorkspaceChart, CatalogArgoDeployChart, CatalogSecretsChart, CatalogOrgWebhookChart } from './catalog';
2
+ import { CatalogComponentChart, CatalogDomainChart, CatalogGroupChart, CatalogSystemChart, CatalogUserChart, CatalogTFWorkspaceChart, CatalogArgoDeployChart, CatalogSecretsChart, CatalogOrgWebhookChart, CatalogApiChart } from './catalog';
3
3
  import { TFWorkspaceChart } from './workspaces/tfworkspaceChart';
4
4
  import { ArgoDeployChart } from './argocd/argodeployChart';
5
5
  import { SecretsChart } from './secrets/secretsChart';
@@ -13,6 +13,7 @@ declare const _default: {
13
13
  CatalogArgoDeployChart: typeof CatalogArgoDeployChart;
14
14
  CatalogSecretsChart: typeof CatalogSecretsChart;
15
15
  CatalogOrgWebhookChart: typeof CatalogOrgWebhookChart;
16
+ CatalogApiChart: typeof CatalogApiChart;
16
17
  GithubGroupChart: typeof GithubGroupChart;
17
18
  GithubMembershipChart: typeof GithubMembershipChart;
18
19
  GithubRepositoryChart: typeof GithubRepositoryChart;
@@ -1,4 +1,9 @@
1
1
  import { IClaim } from '../base';
2
+ export interface IApiDefinition {
3
+ name: string;
4
+ definitionfile: string;
5
+ type: string;
6
+ }
2
7
  export interface IComponentClaim extends IClaim {
3
8
  type: string;
4
9
  lifecycle: string;
@@ -9,5 +14,7 @@ export interface IComponentClaim extends IClaim {
9
14
  providers: object;
10
15
  platformOwner?: `${string}:${string}`;
11
16
  maintainedBy?: `${string}:${string}`[];
17
+ providesApis?: IApiDefinition[] | Record<string, IApiDefinition>;
18
+ consumesApis?: string[];
12
19
  }
13
20
  export declare const schema = "firestartr.dev://common/ComponentClaim";
@@ -2,6 +2,23 @@ declare const _default: {
2
2
  $schema: string;
3
3
  $id: string;
4
4
  definitions: {
5
+ ApiDefinition: {
6
+ $id: string;
7
+ type: string;
8
+ properties: {
9
+ name: {
10
+ type: string;
11
+ };
12
+ definitionfile: {
13
+ type: string;
14
+ };
15
+ type: {
16
+ type: string;
17
+ };
18
+ };
19
+ required: string[];
20
+ additionalProperties: boolean;
21
+ };
5
22
  ComponentClaim: {
6
23
  $id: string;
7
24
  type: string;
@@ -33,6 +50,27 @@ declare const _default: {
33
50
  subComponentOf: {
34
51
  $ref: string;
35
52
  };
53
+ providesApis: {
54
+ anyOf: ({
55
+ type: string;
56
+ items: {
57
+ $ref: string;
58
+ };
59
+ additionalProperties?: undefined;
60
+ } | {
61
+ type: string;
62
+ additionalProperties: {
63
+ $ref: string;
64
+ };
65
+ items?: undefined;
66
+ })[];
67
+ };
68
+ consumesApis: {
69
+ type: string;
70
+ items: {
71
+ type: string;
72
+ };
73
+ };
36
74
  providers: {
37
75
  type: string;
38
76
  properties: {
@@ -247,6 +247,23 @@ declare const schemas: {
247
247
  $schema: string;
248
248
  $id: string;
249
249
  definitions: {
250
+ ApiDefinition: {
251
+ $id: string;
252
+ type: string;
253
+ properties: {
254
+ name: {
255
+ type: string;
256
+ };
257
+ definitionfile: {
258
+ type: string;
259
+ };
260
+ type: {
261
+ type: string;
262
+ };
263
+ };
264
+ required: string[];
265
+ additionalProperties: boolean;
266
+ };
250
267
  ComponentClaim: {
251
268
  $id: string;
252
269
  type: string;
@@ -278,6 +295,27 @@ declare const schemas: {
278
295
  subComponentOf: {
279
296
  $ref: string;
280
297
  };
298
+ providesApis: {
299
+ anyOf: ({
300
+ type: string;
301
+ items: {
302
+ $ref: string;
303
+ };
304
+ additionalProperties?: undefined;
305
+ } | {
306
+ type: string;
307
+ additionalProperties: {
308
+ $ref: string;
309
+ };
310
+ items?: undefined;
311
+ })[];
312
+ };
313
+ consumesApis: {
314
+ type: string;
315
+ items: {
316
+ type: string;
317
+ };
318
+ };
281
319
  providers: {
282
320
  type: string;
283
321
  properties: {
@@ -4,3 +4,4 @@ export declare function resolveClaimFilesList(claimRefsList: string): string[];
4
4
  export declare function resolveClaimEntries(claimRefsList: string[]): AsyncGenerator<string, void, unknown>;
5
5
  export declare function resolveClaimFileRef(claimFile: string): Promise<string>;
6
6
  export declare function getClaimsEntryAbsolutePath(claimsDir: string, entryPath: string): string;
7
+ export declare function sanitizeApiEntityName(name: string): string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@firestartr/cli",
3
- "version": "2.1.0",
3
+ "version": "2.2.0-snapshot-0",
4
4
  "private": false,
5
5
  "description": "Commandline tool",
6
6
  "main": "build/main.js",