diff --git a/plugins/scaffolder-backend/src/schema/openapi.yaml b/plugins/scaffolder-backend/src/schema/openapi.yaml index c6e832f0e0..b7f94d1fed 100644 --- a/plugins/scaffolder-backend/src/schema/openapi.yaml +++ b/plugins/scaffolder-backend/src/schema/openapi.yaml @@ -383,6 +383,31 @@ components: required: - tasks description: The response shape for the `listTasks` call to the `scaffolder-backend` + ListTemplatingExtensionsResponse: + type: object + properties: + filters: + type: object + additionalProperties: + $ref: '#/components/schemas/TemplateFilter' + globals: + type: object + properties: + functions: + type: object + additionalProperties: + $ref: '#/components/schemas/TemplateGlobalFunction' + values: + type: object + additionalProperties: + $ref: '#/components/schemas/TemplateGlobalValue' + required: + - functions + - values + required: + - filters + - globals + description: The response shape for the `listTemplatingExtensions` call to the `scaffolder-backend` # MapStringString: # type: object # properties: {} @@ -405,6 +430,18 @@ components: - templateRef - values description: The input options to the `scaffold` method of the `ScaffolderClient`. + ScaffolderUsageExample: + type: object + properties: + description: + type: string + example: + type: string + notes: + type: string + required: + - example + description: A single scaffolder usage example # Schema: # type: object # properties: @@ -826,6 +863,58 @@ components: # description: |- # Backstage catalog Template kind Entity. Templates are used by the Scaffolder # plugin to create new entities, such as Components. + TemplateGlobalFunction: + type: object + properties: + description: + type: string + schema: + type: object + properties: + arguments: + type: array + items: + $ref: '#/components/schemas/JsonObject' + output: + $ref: '#/components/schemas/JsonObject' + "'examples'": + type: array + items: + $ref: '#/components/schemas/ScaffolderUsageExample' + description: The response shape for a single global function in the `listTemplatingExtensions` call to the `scaffolder-backend` + TemplateGlobalValue: + type: object + properties: + description: + type: string + value: + type: object + nullable: true + # $ref: '#/components/schemas/JsonValue' + required: + - value + description: The response shape for a single global value in the `listTemplatingExtensions` call to the `scaffolder-backend` + TemplateFilter: + type: object + properties: + description: + type: string + schema: + type: object + properties: + input: + $ref: '#/components/schemas/JsonObject' + arguments: + type: array + items: + $ref: '#/components/schemas/JsonObject' + output: + $ref: '#/components/schemas/JsonObject' + "'examples'": + type: array + items: + $ref: '#/components/schemas/ScaffolderUsageExample' + description: The response shape for a single filter in the `listTemplatingExtensions` call to the `scaffolder-backend` # TemplateInfo: # type: object # properties: @@ -1351,3 +1440,19 @@ paths: allowReserved: true schema: type: string + + /v2/templating-extensions: + get: + operationId: ListTemplatingExtensions + description: Returns a structure describing the available templating extensions. + responses: + '200': + description: Ok + content: + application/json: + schema: + $ref: '#/components/schemas/ListTemplatingExtensionsResponse' + security: + - {} + - JWT: [] + parameters: [] diff --git a/plugins/scaffolder-backend/src/schema/openapi/generated/apis/Api.server.ts b/plugins/scaffolder-backend/src/schema/openapi/generated/apis/Api.server.ts index c81638fdf4..febb63606f 100644 --- a/plugins/scaffolder-backend/src/schema/openapi/generated/apis/Api.server.ts +++ b/plugins/scaffolder-backend/src/schema/openapi/generated/apis/Api.server.ts @@ -27,6 +27,7 @@ import { CancelTask200Response } from '../models/CancelTask200Response.model'; import { DryRun200Response } from '../models/DryRun200Response.model'; import { DryRunRequest } from '../models/DryRunRequest.model'; import { ListTasksResponse } from '../models/ListTasksResponse.model'; +import { ListTemplatingExtensionsResponse } from '../models/ListTemplatingExtensionsResponse.model'; import { RetryRequest } from '../models/RetryRequest.model'; import { Scaffold201Response } from '../models/Scaffold201Response.model'; import { Scaffold400Response } from '../models/Scaffold400Response.model'; @@ -101,6 +102,12 @@ export type ListTasks = { }; response: ListTasksResponse; }; +/** + * @public + */ +export type ListTemplatingExtensions = { + response: ListTemplatingExtensionsResponse; +}; /** * @public */ @@ -146,6 +153,8 @@ export type EndpointMap = { '#get|/v2/tasks': ListTasks; + '#get|/v2/templating-extensions': ListTemplatingExtensions; + '#post|/v2/tasks/{taskId}/retry': Retry; '#post|/v2/tasks': Scaffold; diff --git a/plugins/scaffolder-backend/src/schema/openapi/generated/models/ListTemplatingExtensionsResponse.model.ts b/plugins/scaffolder-backend/src/schema/openapi/generated/models/ListTemplatingExtensionsResponse.model.ts new file mode 100644 index 0000000000..74b7cd3780 --- /dev/null +++ b/plugins/scaffolder-backend/src/schema/openapi/generated/models/ListTemplatingExtensionsResponse.model.ts @@ -0,0 +1,30 @@ +/* + * Copyright 2025 The Backstage Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// ****************************************************************** +// * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. * +// ****************************************************************** +import { ListTemplatingExtensionsResponseGlobals } from '../models/ListTemplatingExtensionsResponseGlobals.model'; +import { TemplateFilter } from '../models/TemplateFilter.model'; + +/** + * The response shape for the `listTemplatingExtensions` call to the `scaffolder-backend` + * @public + */ +export interface ListTemplatingExtensionsResponse { + filters: { [key: string]: TemplateFilter }; + globals: ListTemplatingExtensionsResponseGlobals; +} diff --git a/plugins/scaffolder-backend/src/schema/openapi/generated/models/ListTemplatingExtensionsResponseGlobals.model.ts b/plugins/scaffolder-backend/src/schema/openapi/generated/models/ListTemplatingExtensionsResponseGlobals.model.ts new file mode 100644 index 0000000000..1f022a0675 --- /dev/null +++ b/plugins/scaffolder-backend/src/schema/openapi/generated/models/ListTemplatingExtensionsResponseGlobals.model.ts @@ -0,0 +1,29 @@ +/* + * Copyright 2025 The Backstage Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// ****************************************************************** +// * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. * +// ****************************************************************** +import { TemplateGlobalFunction } from '../models/TemplateGlobalFunction.model'; +import { TemplateGlobalValue } from '../models/TemplateGlobalValue.model'; + +/** + * @public + */ +export interface ListTemplatingExtensionsResponseGlobals { + functions: { [key: string]: TemplateGlobalFunction }; + values: { [key: string]: TemplateGlobalValue }; +} diff --git a/plugins/scaffolder-backend/src/schema/openapi/generated/models/ScaffolderUsageExample.model.ts b/plugins/scaffolder-backend/src/schema/openapi/generated/models/ScaffolderUsageExample.model.ts new file mode 100644 index 0000000000..3e0f4ef866 --- /dev/null +++ b/plugins/scaffolder-backend/src/schema/openapi/generated/models/ScaffolderUsageExample.model.ts @@ -0,0 +1,29 @@ +/* + * Copyright 2025 The Backstage Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// ****************************************************************** +// * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. * +// ****************************************************************** + +/** + * A single scaffolder usage example + * @public + */ +export interface ScaffolderUsageExample { + description?: string; + example: string; + notes?: string; +} diff --git a/plugins/scaffolder-backend/src/schema/openapi/generated/models/TemplateFilter.model.ts b/plugins/scaffolder-backend/src/schema/openapi/generated/models/TemplateFilter.model.ts new file mode 100644 index 0000000000..7c631978e6 --- /dev/null +++ b/plugins/scaffolder-backend/src/schema/openapi/generated/models/TemplateFilter.model.ts @@ -0,0 +1,31 @@ +/* + * Copyright 2025 The Backstage Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// ****************************************************************** +// * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. * +// ****************************************************************** +import { ScaffolderUsageExample } from '../models/ScaffolderUsageExample.model'; +import { TemplateFilterSchema } from '../models/TemplateFilterSchema.model'; + +/** + * The response shape for a single filter in the `listTemplatingExtensions` call to the `scaffolder-backend` + * @public + */ +export interface TemplateFilter { + description?: string; + schema?: TemplateFilterSchema; + examples?: Array; +} diff --git a/plugins/scaffolder-backend/src/schema/openapi/generated/models/TemplateFilterSchema.model.ts b/plugins/scaffolder-backend/src/schema/openapi/generated/models/TemplateFilterSchema.model.ts new file mode 100644 index 0000000000..5a95a58ead --- /dev/null +++ b/plugins/scaffolder-backend/src/schema/openapi/generated/models/TemplateFilterSchema.model.ts @@ -0,0 +1,34 @@ +/* + * Copyright 2025 The Backstage Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// ****************************************************************** +// * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. * +// ****************************************************************** + +/** + * @public + */ +export interface TemplateFilterSchema { + /** + * A type representing all allowed JSON object values. + */ + input?: { [key: string]: any }; + arguments?: Array<{ [key: string]: any }>; + /** + * A type representing all allowed JSON object values. + */ + output?: { [key: string]: any }; +} diff --git a/plugins/scaffolder-backend/src/schema/openapi/generated/models/TemplateGlobalFunction.model.ts b/plugins/scaffolder-backend/src/schema/openapi/generated/models/TemplateGlobalFunction.model.ts new file mode 100644 index 0000000000..ee19ce723b --- /dev/null +++ b/plugins/scaffolder-backend/src/schema/openapi/generated/models/TemplateGlobalFunction.model.ts @@ -0,0 +1,31 @@ +/* + * Copyright 2025 The Backstage Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// ****************************************************************** +// * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. * +// ****************************************************************** +import { ScaffolderUsageExample } from '../models/ScaffolderUsageExample.model'; +import { TemplateGlobalFunctionSchema } from '../models/TemplateGlobalFunctionSchema.model'; + +/** + * The response shape for a single global function in the `listTemplatingExtensions` call to the `scaffolder-backend` + * @public + */ +export interface TemplateGlobalFunction { + description?: string; + schema?: TemplateGlobalFunctionSchema; + examples?: Array; +} diff --git a/plugins/scaffolder-backend/src/schema/openapi/generated/models/TemplateGlobalFunctionSchema.model.ts b/plugins/scaffolder-backend/src/schema/openapi/generated/models/TemplateGlobalFunctionSchema.model.ts new file mode 100644 index 0000000000..b3a39c3b24 --- /dev/null +++ b/plugins/scaffolder-backend/src/schema/openapi/generated/models/TemplateGlobalFunctionSchema.model.ts @@ -0,0 +1,30 @@ +/* + * Copyright 2025 The Backstage Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// ****************************************************************** +// * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. * +// ****************************************************************** + +/** + * @public + */ +export interface TemplateGlobalFunctionSchema { + arguments?: Array<{ [key: string]: any }>; + /** + * A type representing all allowed JSON object values. + */ + output?: { [key: string]: any }; +} diff --git a/plugins/scaffolder-backend/src/schema/openapi/generated/models/TemplateGlobalValue.model.ts b/plugins/scaffolder-backend/src/schema/openapi/generated/models/TemplateGlobalValue.model.ts new file mode 100644 index 0000000000..95d177a05a --- /dev/null +++ b/plugins/scaffolder-backend/src/schema/openapi/generated/models/TemplateGlobalValue.model.ts @@ -0,0 +1,28 @@ +/* + * Copyright 2025 The Backstage Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// ****************************************************************** +// * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. * +// ****************************************************************** + +/** + * The response shape for a single global value in the `listTemplatingExtensions` call to the `scaffolder-backend` + * @public + */ +export interface TemplateGlobalValue { + description?: string; + value: any | null; +} diff --git a/plugins/scaffolder-backend/src/schema/openapi/generated/models/index.ts b/plugins/scaffolder-backend/src/schema/openapi/generated/models/index.ts index d9a4ff832c..17f7907003 100644 --- a/plugins/scaffolder-backend/src/schema/openapi/generated/models/index.ts +++ b/plugins/scaffolder-backend/src/schema/openapi/generated/models/index.ts @@ -38,11 +38,14 @@ export * from '../models/ErrorResponse.model'; export * from '../models/JsonPrimitive.model'; export * from '../models/JsonValue.model'; export * from '../models/ListTasksResponse.model'; +export * from '../models/ListTemplatingExtensionsResponse.model'; +export * from '../models/ListTemplatingExtensionsResponseGlobals.model'; export * from '../models/ModelError.model'; export * from '../models/RetryRequest.model'; export * from '../models/Scaffold201Response.model'; export * from '../models/Scaffold400Response.model'; export * from '../models/ScaffolderScaffoldOptions.model'; +export * from '../models/ScaffolderUsageExample.model'; export * from '../models/SerializedFile.model'; export * from '../models/SerializedTask.model'; export * from '../models/SerializedTaskEvent.model'; @@ -50,6 +53,11 @@ export * from '../models/TaskEventType.model'; export * from '../models/TaskSecrets.model'; export * from '../models/TaskSecretsAllOf.model'; export * from '../models/TaskStatus.model'; +export * from '../models/TemplateFilter.model'; +export * from '../models/TemplateFilterSchema.model'; +export * from '../models/TemplateGlobalFunction.model'; +export * from '../models/TemplateGlobalFunctionSchema.model'; +export * from '../models/TemplateGlobalValue.model'; export * from '../models/TemplateParameterSchema.model'; export * from '../models/TemplateParameterSchemaStepsInner.model'; export * from '../models/ValidationError.model'; diff --git a/plugins/scaffolder-backend/src/schema/openapi/generated/router.ts b/plugins/scaffolder-backend/src/schema/openapi/generated/router.ts index 3078fb9c4b..78802491b1 100644 --- a/plugins/scaffolder-backend/src/schema/openapi/generated/router.ts +++ b/plugins/scaffolder-backend/src/schema/openapi/generated/router.ts @@ -370,6 +370,38 @@ export const spec = { description: 'The response shape for the `listTasks` call to the `scaffolder-backend`', }, + ListTemplatingExtensionsResponse: { + type: 'object', + properties: { + filters: { + type: 'object', + additionalProperties: { + $ref: '#/components/schemas/TemplateFilter', + }, + }, + globals: { + type: 'object', + properties: { + functions: { + type: 'object', + additionalProperties: { + $ref: '#/components/schemas/TemplateGlobalFunction', + }, + }, + values: { + type: 'object', + additionalProperties: { + $ref: '#/components/schemas/TemplateGlobalValue', + }, + }, + }, + required: ['functions', 'values'], + }, + }, + required: ['filters', 'globals'], + description: + 'The response shape for the `listTemplatingExtensions` call to the `scaffolder-backend`', + }, ScaffolderScaffoldOptions: { type: 'object', properties: { @@ -391,6 +423,22 @@ export const spec = { description: 'The input options to the `scaffold` method of the `ScaffolderClient`.', }, + ScaffolderUsageExample: { + type: 'object', + properties: { + description: { + type: 'string', + }, + example: { + type: 'string', + }, + notes: { + type: 'string', + }, + }, + required: ['example'], + description: 'A single scaffolder usage example', + }, SerializedFile: { type: 'object', properties: { @@ -520,6 +568,84 @@ export const spec = { ], description: 'The status of each step of the Task', }, + TemplateGlobalFunction: { + type: 'object', + properties: { + description: { + type: 'string', + }, + schema: { + type: 'object', + properties: { + arguments: { + type: 'array', + items: { + $ref: '#/components/schemas/JsonObject', + }, + }, + output: { + $ref: '#/components/schemas/JsonObject', + }, + }, + }, + "'examples'": { + type: 'array', + items: { + $ref: '#/components/schemas/ScaffolderUsageExample', + }, + }, + }, + description: + 'The response shape for a single global function in the `listTemplatingExtensions` call to the `scaffolder-backend`', + }, + TemplateGlobalValue: { + type: 'object', + properties: { + description: { + type: 'string', + }, + value: { + type: 'object', + nullable: true, + }, + }, + required: ['value'], + description: + 'The response shape for a single global value in the `listTemplatingExtensions` call to the `scaffolder-backend`', + }, + TemplateFilter: { + type: 'object', + properties: { + description: { + type: 'string', + }, + schema: { + type: 'object', + properties: { + input: { + $ref: '#/components/schemas/JsonObject', + }, + arguments: { + type: 'array', + items: { + $ref: '#/components/schemas/JsonObject', + }, + }, + output: { + $ref: '#/components/schemas/JsonObject', + }, + }, + }, + "'examples'": { + type: 'array', + items: { + $ref: '#/components/schemas/ScaffolderUsageExample', + }, + }, + }, + description: + 'The response shape for a single filter in the `listTemplatingExtensions` call to the `scaffolder-backend`', + }, TemplateParameterSchema: { type: 'object', properties: { @@ -1157,6 +1283,32 @@ export const spec = { ], }, }, + '/v2/templating-extensions': { + get: { + operationId: 'ListTemplatingExtensions', + description: + 'Returns a structure describing the available templating extensions.', + responses: { + '200': { + description: 'Ok', + content: { + 'application/json': { + schema: { + $ref: '#/components/schemas/ListTemplatingExtensionsResponse', + }, + }, + }, + }, + }, + security: [ + {}, + { + JWT: [], + }, + ], + parameters: [], + }, + }, }, } as const; export const createOpenApiRouter = async ( diff --git a/plugins/scaffolder-common/report.api.md b/plugins/scaffolder-common/report.api.md index d2a5e83672..1496496450 100644 --- a/plugins/scaffolder-common/report.api.md +++ b/plugins/scaffolder-common/report.api.md @@ -25,13 +25,8 @@ export type Action = { examples?: ActionExample[]; }; -// @public -export interface ActionExample { - // (undocumented) - description: string; - // (undocumented) - example: string; -} +// @public @deprecated +export type ActionExample = ScaffolderUsageExample; // @public export const isTemplateEntityV1beta3: ( @@ -41,6 +36,15 @@ export const isTemplateEntityV1beta3: ( // @public export type ListActionsResponse = Array; +// @public +export type ListTemplatingExtensionsResponse = { + filters: Record; + globals: { + functions: Record; + values: Record; + }; +}; + // @public export type LogEvent = { type: TaskEventType; @@ -109,6 +113,9 @@ export interface ScaffolderApi { tasks: ScaffolderTask[]; totalTasks?: number; }>; + listTemplatingExtensions?( + options?: ScaffolderRequestOptions, + ): Promise; retry?( { secrets, @@ -205,6 +212,9 @@ export class ScaffolderClient implements ScaffolderApi { tasks: ScaffolderTask[]; totalTasks?: number; }>; + listTemplatingExtensions( + options?: ScaffolderRequestOptions, + ): Promise; retry?( { secrets, @@ -359,6 +369,13 @@ export const ScaffolderTaskStatus: { Skipped: ScaffolderTaskStatus; }; +// @public +export type ScaffolderUsageExample = { + description?: string; + example: string; + notes?: string; +}; + // @public (undocumented) export type TaskEventType = 'cancelled' | 'completion' | 'log' | 'recovered'; @@ -448,6 +465,33 @@ export interface TemplateEntityV1beta3 extends Entity { // @public export const templateEntityV1beta3Validator: KindValidator; +// @public +export type TemplateFilter = { + description?: string; + schema?: { + input?: JSONSchema7; + arguments?: JSONSchema7[]; + output?: JSONSchema7; + }; + examples?: ScaffolderUsageExample[]; +}; + +// @public +export type TemplateGlobalFunction = { + description?: string; + schema?: { + arguments?: JSONSchema7[]; + output?: JSONSchema7; + }; + examples?: ScaffolderUsageExample[]; +}; + +// @public +export type TemplateGlobalValue = { + description?: string; + value: JsonValue; +}; + // @public export type TemplateInfo = { entityRef: string; diff --git a/plugins/scaffolder-common/src/ScaffolderClient.ts b/plugins/scaffolder-common/src/ScaffolderClient.ts index aececc0e4b..43bcdb8ce5 100644 --- a/plugins/scaffolder-common/src/ScaffolderClient.ts +++ b/plugins/scaffolder-common/src/ScaffolderClient.ts @@ -355,15 +355,15 @@ export class ScaffolderClient implements ScaffolderApi { ); } - async listTemplatingExtensions(): Promise { - const baseUrl = await this.discoveryApi.getBaseUrl('scaffolder'); - const response = await this.fetchApi.fetch( - `${baseUrl}/v2/templating-extensions`, + /** + * {@inheritdoc ScaffolderApi.listTemplatingExtensions} + */ + async listTemplatingExtensions( + options?: ScaffolderRequestOptions, + ): Promise { + return await this.requestRequired( + await this.apiClient.listTemplatingExtensions(null as any, options), ); - if (!response.ok) { - throw ResponseError.fromResponse(response); - } - return response.json(); } /** diff --git a/plugins/scaffolder-common/src/schema/openapi/generated/apis/Api.client.ts b/plugins/scaffolder-common/src/schema/openapi/generated/apis/Api.client.ts index 9bb691b922..0151013378 100644 --- a/plugins/scaffolder-common/src/schema/openapi/generated/apis/Api.client.ts +++ b/plugins/scaffolder-common/src/schema/openapi/generated/apis/Api.client.ts @@ -29,6 +29,7 @@ import { CancelTask200Response } from '../models/CancelTask200Response.model'; import { DryRun200Response } from '../models/DryRun200Response.model'; import { DryRunRequest } from '../models/DryRunRequest.model'; import { ListTasksResponse } from '../models/ListTasksResponse.model'; +import { ListTemplatingExtensionsResponse } from '../models/ListTemplatingExtensionsResponse.model'; import { RetryRequest } from '../models/RetryRequest.model'; import { Scaffold201Response } from '../models/Scaffold201Response.model'; import { ScaffolderScaffoldOptions } from '../models/ScaffolderScaffoldOptions.model'; @@ -111,6 +112,10 @@ export type ListTasks = { status?: Array; }; }; +/** + * @public + */ +export type ListTemplatingExtensions = {}; /** * @public */ @@ -343,6 +348,29 @@ export class DefaultApiClient { }); } + /** + * Returns a structure describing the available templating extensions. + */ + public async listTemplatingExtensions( + // @ts-ignore + request: ListTemplatingExtensions, + options?: RequestOptions, + ): Promise> { + const baseUrl = await this.discoveryApi.getBaseUrl(pluginId); + + const uriTemplate = `/v2/templating-extensions`; + + const uri = parser.parse(uriTemplate).expand({}); + + return await this.fetchApi.fetch(`${baseUrl}${uri}`, { + headers: { + 'Content-Type': 'application/json', + ...(options?.token && { Authorization: `Bearer ${options?.token}` }), + }, + method: 'GET', + }); + } + /** * Starts the task again from the point where it failed. * @param taskId - diff --git a/plugins/scaffolder-common/src/schema/openapi/generated/models/ListTemplatingExtensionsResponse.model.ts b/plugins/scaffolder-common/src/schema/openapi/generated/models/ListTemplatingExtensionsResponse.model.ts new file mode 100644 index 0000000000..74b7cd3780 --- /dev/null +++ b/plugins/scaffolder-common/src/schema/openapi/generated/models/ListTemplatingExtensionsResponse.model.ts @@ -0,0 +1,30 @@ +/* + * Copyright 2025 The Backstage Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// ****************************************************************** +// * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. * +// ****************************************************************** +import { ListTemplatingExtensionsResponseGlobals } from '../models/ListTemplatingExtensionsResponseGlobals.model'; +import { TemplateFilter } from '../models/TemplateFilter.model'; + +/** + * The response shape for the `listTemplatingExtensions` call to the `scaffolder-backend` + * @public + */ +export interface ListTemplatingExtensionsResponse { + filters: { [key: string]: TemplateFilter }; + globals: ListTemplatingExtensionsResponseGlobals; +} diff --git a/plugins/scaffolder-common/src/schema/openapi/generated/models/ListTemplatingExtensionsResponseGlobals.model.ts b/plugins/scaffolder-common/src/schema/openapi/generated/models/ListTemplatingExtensionsResponseGlobals.model.ts new file mode 100644 index 0000000000..1f022a0675 --- /dev/null +++ b/plugins/scaffolder-common/src/schema/openapi/generated/models/ListTemplatingExtensionsResponseGlobals.model.ts @@ -0,0 +1,29 @@ +/* + * Copyright 2025 The Backstage Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// ****************************************************************** +// * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. * +// ****************************************************************** +import { TemplateGlobalFunction } from '../models/TemplateGlobalFunction.model'; +import { TemplateGlobalValue } from '../models/TemplateGlobalValue.model'; + +/** + * @public + */ +export interface ListTemplatingExtensionsResponseGlobals { + functions: { [key: string]: TemplateGlobalFunction }; + values: { [key: string]: TemplateGlobalValue }; +} diff --git a/plugins/scaffolder-common/src/schema/openapi/generated/models/ScaffolderUsageExample.model.ts b/plugins/scaffolder-common/src/schema/openapi/generated/models/ScaffolderUsageExample.model.ts new file mode 100644 index 0000000000..3e0f4ef866 --- /dev/null +++ b/plugins/scaffolder-common/src/schema/openapi/generated/models/ScaffolderUsageExample.model.ts @@ -0,0 +1,29 @@ +/* + * Copyright 2025 The Backstage Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// ****************************************************************** +// * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. * +// ****************************************************************** + +/** + * A single scaffolder usage example + * @public + */ +export interface ScaffolderUsageExample { + description?: string; + example: string; + notes?: string; +} diff --git a/plugins/scaffolder-common/src/schema/openapi/generated/models/TemplateFilter.model.ts b/plugins/scaffolder-common/src/schema/openapi/generated/models/TemplateFilter.model.ts new file mode 100644 index 0000000000..7c631978e6 --- /dev/null +++ b/plugins/scaffolder-common/src/schema/openapi/generated/models/TemplateFilter.model.ts @@ -0,0 +1,31 @@ +/* + * Copyright 2025 The Backstage Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// ****************************************************************** +// * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. * +// ****************************************************************** +import { ScaffolderUsageExample } from '../models/ScaffolderUsageExample.model'; +import { TemplateFilterSchema } from '../models/TemplateFilterSchema.model'; + +/** + * The response shape for a single filter in the `listTemplatingExtensions` call to the `scaffolder-backend` + * @public + */ +export interface TemplateFilter { + description?: string; + schema?: TemplateFilterSchema; + examples?: Array; +} diff --git a/plugins/scaffolder-common/src/schema/openapi/generated/models/TemplateFilterSchema.model.ts b/plugins/scaffolder-common/src/schema/openapi/generated/models/TemplateFilterSchema.model.ts new file mode 100644 index 0000000000..5a95a58ead --- /dev/null +++ b/plugins/scaffolder-common/src/schema/openapi/generated/models/TemplateFilterSchema.model.ts @@ -0,0 +1,34 @@ +/* + * Copyright 2025 The Backstage Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// ****************************************************************** +// * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. * +// ****************************************************************** + +/** + * @public + */ +export interface TemplateFilterSchema { + /** + * A type representing all allowed JSON object values. + */ + input?: { [key: string]: any }; + arguments?: Array<{ [key: string]: any }>; + /** + * A type representing all allowed JSON object values. + */ + output?: { [key: string]: any }; +} diff --git a/plugins/scaffolder-common/src/schema/openapi/generated/models/TemplateGlobalFunction.model.ts b/plugins/scaffolder-common/src/schema/openapi/generated/models/TemplateGlobalFunction.model.ts new file mode 100644 index 0000000000..ee19ce723b --- /dev/null +++ b/plugins/scaffolder-common/src/schema/openapi/generated/models/TemplateGlobalFunction.model.ts @@ -0,0 +1,31 @@ +/* + * Copyright 2025 The Backstage Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// ****************************************************************** +// * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. * +// ****************************************************************** +import { ScaffolderUsageExample } from '../models/ScaffolderUsageExample.model'; +import { TemplateGlobalFunctionSchema } from '../models/TemplateGlobalFunctionSchema.model'; + +/** + * The response shape for a single global function in the `listTemplatingExtensions` call to the `scaffolder-backend` + * @public + */ +export interface TemplateGlobalFunction { + description?: string; + schema?: TemplateGlobalFunctionSchema; + examples?: Array; +} diff --git a/plugins/scaffolder-common/src/schema/openapi/generated/models/TemplateGlobalFunctionSchema.model.ts b/plugins/scaffolder-common/src/schema/openapi/generated/models/TemplateGlobalFunctionSchema.model.ts new file mode 100644 index 0000000000..b3a39c3b24 --- /dev/null +++ b/plugins/scaffolder-common/src/schema/openapi/generated/models/TemplateGlobalFunctionSchema.model.ts @@ -0,0 +1,30 @@ +/* + * Copyright 2025 The Backstage Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// ****************************************************************** +// * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. * +// ****************************************************************** + +/** + * @public + */ +export interface TemplateGlobalFunctionSchema { + arguments?: Array<{ [key: string]: any }>; + /** + * A type representing all allowed JSON object values. + */ + output?: { [key: string]: any }; +} diff --git a/plugins/scaffolder-common/src/schema/openapi/generated/models/TemplateGlobalValue.model.ts b/plugins/scaffolder-common/src/schema/openapi/generated/models/TemplateGlobalValue.model.ts new file mode 100644 index 0000000000..95d177a05a --- /dev/null +++ b/plugins/scaffolder-common/src/schema/openapi/generated/models/TemplateGlobalValue.model.ts @@ -0,0 +1,28 @@ +/* + * Copyright 2025 The Backstage Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// ****************************************************************** +// * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. * +// ****************************************************************** + +/** + * The response shape for a single global value in the `listTemplatingExtensions` call to the `scaffolder-backend` + * @public + */ +export interface TemplateGlobalValue { + description?: string; + value: any | null; +} diff --git a/plugins/scaffolder-common/src/schema/openapi/generated/models/index.ts b/plugins/scaffolder-common/src/schema/openapi/generated/models/index.ts index d9a4ff832c..17f7907003 100644 --- a/plugins/scaffolder-common/src/schema/openapi/generated/models/index.ts +++ b/plugins/scaffolder-common/src/schema/openapi/generated/models/index.ts @@ -38,11 +38,14 @@ export * from '../models/ErrorResponse.model'; export * from '../models/JsonPrimitive.model'; export * from '../models/JsonValue.model'; export * from '../models/ListTasksResponse.model'; +export * from '../models/ListTemplatingExtensionsResponse.model'; +export * from '../models/ListTemplatingExtensionsResponseGlobals.model'; export * from '../models/ModelError.model'; export * from '../models/RetryRequest.model'; export * from '../models/Scaffold201Response.model'; export * from '../models/Scaffold400Response.model'; export * from '../models/ScaffolderScaffoldOptions.model'; +export * from '../models/ScaffolderUsageExample.model'; export * from '../models/SerializedFile.model'; export * from '../models/SerializedTask.model'; export * from '../models/SerializedTaskEvent.model'; @@ -50,6 +53,11 @@ export * from '../models/TaskEventType.model'; export * from '../models/TaskSecrets.model'; export * from '../models/TaskSecretsAllOf.model'; export * from '../models/TaskStatus.model'; +export * from '../models/TemplateFilter.model'; +export * from '../models/TemplateFilterSchema.model'; +export * from '../models/TemplateGlobalFunction.model'; +export * from '../models/TemplateGlobalFunctionSchema.model'; +export * from '../models/TemplateGlobalValue.model'; export * from '../models/TemplateParameterSchema.model'; export * from '../models/TemplateParameterSchemaStepsInner.model'; export * from '../models/ValidationError.model'; diff --git a/plugins/scaffolder-react/report.api.md b/plugins/scaffolder-react/report.api.md index 9d0404bbe5..4b81a18eb6 100644 --- a/plugins/scaffolder-react/report.api.md +++ b/plugins/scaffolder-react/report.api.md @@ -4,7 +4,6 @@ ```ts import { Action as Action_2 } from '@backstage/plugin-scaffolder-common'; -import { ActionExample as ActionExample_2 } from '@backstage/plugin-scaffolder-common'; import { ApiHolder } from '@backstage/core-plugin-api'; import { ApiRef } from '@backstage/frontend-plugin-api'; import { ComponentType } from 'react'; @@ -25,6 +24,7 @@ import { IChangeEvent } from '@rjsf/core'; import { IdSchema } from '@rjsf/utils'; import { JsonObject } from '@backstage/types'; import { JSONSchema7 } from 'json-schema'; +import { JSX as JSX_2 } from 'react/jsx-runtime'; import { ListActionsResponse as ListActionsResponse_2 } from '@backstage/plugin-scaffolder-common'; import { ListTemplatingExtensionsResponse as ListTemplatingExtensionsResponse_2 } from '@backstage/plugin-scaffolder-common'; import { LogEvent as LogEvent_2 } from '@backstage/plugin-scaffolder-common'; @@ -48,8 +48,12 @@ import { ScaffolderStreamLogsOptions as ScaffolderStreamLogsOptions_2 } from '@b import { ScaffolderTask as ScaffolderTask_2 } from '@backstage/plugin-scaffolder-common'; import { ScaffolderTaskOutput as ScaffolderTaskOutput_2 } from '@backstage/plugin-scaffolder-common'; import { ScaffolderTaskStatus as ScaffolderTaskStatus_2 } from '@backstage/plugin-scaffolder-common'; +import { ScaffolderUsageExample as ScaffolderUsageExample_2 } from '@backstage/plugin-scaffolder-common'; import { StrictRJSFSchema } from '@rjsf/utils'; import { TemplateEntityV1beta3 } from '@backstage/plugin-scaffolder-common'; +import { TemplateFilter as TemplateFilter_2 } from '@backstage/plugin-scaffolder-common'; +import { TemplateGlobalFunction as TemplateGlobalFunction_2 } from '@backstage/plugin-scaffolder-common'; +import { TemplateGlobalValue as TemplateGlobalValue_2 } from '@backstage/plugin-scaffolder-common'; import { TemplateParameterSchema as TemplateParameterSchema_2 } from '@backstage/plugin-scaffolder-common'; import { TemplatesType } from '@rjsf/utils'; import { UIOptionsType } from '@rjsf/utils'; @@ -61,7 +65,7 @@ import { z } from 'zod'; export type Action = Action_2; // @public @deprecated -export type ActionExample = ActionExample_2; +export type ActionExample = ScaffolderUsageExample; // @public export function createScaffolderFieldExtension< @@ -171,7 +175,8 @@ export type LayoutTemplate = NonNullable< export type ListActionsResponse = ListActionsResponse_2; // @public @deprecated -export type ListTemplatingExtensionsResponse = ListTemplatingExtensionsResponse_2; +export type ListTemplatingExtensionsResponse = + ListTemplatingExtensionsResponse_2; // @public @deprecated export type LogEvent = LogEvent_2; @@ -366,12 +371,8 @@ export type ScaffolderTaskOutput = ScaffolderTaskOutput_2; // @public @deprecated export type ScaffolderTaskStatus = ScaffolderTaskStatus_2; -// @public -export type ScaffolderUsageExample = { - description?: string; - example: string; - notes?: string; -}; +// @public @deprecated +export type ScaffolderUsageExample = ScaffolderUsageExample_2; // @public export interface ScaffolderUseTemplateSecrets { @@ -404,32 +405,14 @@ export type TaskStream = { output?: ScaffolderTaskOutput; }; -// @public -export type TemplateFilter = { - description?: string; - schema?: { - input?: JSONSchema7; - arguments?: JSONSchema7[]; - output?: JSONSchema7; - }; - examples?: ScaffolderUsageExample[]; -}; +// @public @deprecated +export type TemplateFilter = TemplateFilter_2; -// @public -export type TemplateGlobalFunction = { - description?: string; - schema?: { - arguments?: JSONSchema7[]; - output?: JSONSchema7; - }; - examples?: ScaffolderUsageExample[]; -}; +// @public @deprecated +export type TemplateGlobalFunction = TemplateGlobalFunction_2; -// @public -export type TemplateGlobalValue = { - description?: string; - value: JsonValue; -}; +// @public @deprecated +export type TemplateGlobalValue = TemplateGlobalValue_2; // @public (undocumented) export type TemplateGroupFilter = { diff --git a/plugins/scaffolder/report.api.md b/plugins/scaffolder/report.api.md index 53337c2408..fbb73f6225 100644 --- a/plugins/scaffolder/report.api.md +++ b/plugins/scaffolder/report.api.md @@ -18,7 +18,7 @@ import { FieldExtensionOptions as FieldExtensionOptions_2 } from '@backstage/plu import { FieldSchema as FieldSchema_2 } from '@backstage/plugin-scaffolder-react'; import { FieldValidation } from '@rjsf/utils'; import { FormProps } from '@backstage/plugin-scaffolder-react'; -import { JSX as JSX_2 } from 'react'; +import { JSX as JSX_2 } from 'react/jsx-runtime'; import { LayoutOptions as LayoutOptions_2 } from '@backstage/plugin-scaffolder-react'; import { LayoutTemplate as LayoutTemplate_2 } from '@backstage/plugin-scaffolder-react'; import { ListActionsResponse as ListActionsResponse_2 } from '@backstage/plugin-scaffolder-common';