@backstage/plugin-scaffolder-backend 1.4.0-next.0 → 1.4.0-next.3

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/dist/index.d.ts CHANGED
@@ -1,231 +1,42 @@
1
+ /**
2
+ * The Backstage backend plugin that helps you create new things
3
+ *
4
+ * @packageDocumentation
5
+ */
6
+
1
7
  /// <reference types="node" />
2
- import { ScmIntegrations, ScmIntegrationRegistry, GithubCredentialsProvider } from '@backstage/integration';
8
+
9
+ import { BackendRegistrable } from '@backstage/backend-plugin-api';
3
10
  import { CatalogApi } from '@backstage/catalog-client';
4
- import { Logger } from 'winston';
5
- import { Writable } from 'stream';
6
- import { JsonValue, JsonObject, Observable } from '@backstage/types';
7
- import { Schema } from 'jsonschema';
8
- import * as _backstage_plugin_scaffolder_common from '@backstage/plugin-scaffolder-common';
9
- import { TaskSpec, TemplateInfo } from '@backstage/plugin-scaffolder-common';
10
- import { Entity } from '@backstage/catalog-model';
11
- import { UrlReader, PluginDatabaseManager } from '@backstage/backend-common';
11
+ import { CatalogProcessor } from '@backstage/plugin-catalog-backend';
12
+ import { CatalogProcessorEmit } from '@backstage/plugin-catalog-backend';
12
13
  import { Config } from '@backstage/config';
13
14
  import { createPullRequest } from 'octokit-plugin-create-pull-request';
14
- import { SpawnOptionsWithoutStdio } from 'child_process';
15
- import { Knex } from 'knex';
15
+ import { Entity } from '@backstage/catalog-model';
16
16
  import express from 'express';
17
- import { CatalogProcessor, LocationSpec, CatalogProcessorEmit } from '@backstage/plugin-catalog-backend';
18
-
19
- /**
20
- * Registers entities from a catalog descriptor file in the workspace into the software catalog.
21
- * @public
22
- */
23
- declare function createCatalogRegisterAction(options: {
24
- catalogClient: CatalogApi;
25
- integrations: ScmIntegrations;
26
- }): TemplateAction<{
27
- catalogInfoUrl: string;
28
- optional?: boolean | undefined;
29
- } | {
30
- repoContentsUrl: string;
31
- catalogInfoPath?: string | undefined;
32
- optional?: boolean | undefined;
33
- }>;
34
-
35
- /**
36
- * Writes a catalog descriptor file containing the provided entity to a path in the workspace.
37
- * @public
38
- */
39
- declare function createCatalogWriteAction(): TemplateAction<{
40
- filePath?: string | undefined;
41
- entity: Entity;
42
- }>;
43
-
44
- /** @public */
45
- declare type TemplateFilter = (...args: JsonValue[]) => JsonValue | undefined;
46
-
47
- /**
48
- * The status of each step of the Task
49
- *
50
- * @public
51
- */
52
- declare type TaskStatus = 'open' | 'processing' | 'failed' | 'cancelled' | 'completed';
53
- /**
54
- * The state of a completed task.
55
- *
56
- * @public
57
- */
58
- declare type TaskCompletionState = 'failed' | 'completed';
59
- /**
60
- * SerializedTask
61
- *
62
- * @public
63
- */
64
- declare type SerializedTask = {
65
- id: string;
66
- spec: TaskSpec;
67
- status: TaskStatus;
68
- createdAt: string;
69
- lastHeartbeatAt?: string;
70
- createdBy?: string;
71
- secrets?: TaskSecrets;
72
- };
73
- /**
74
- * TaskEventType
75
- *
76
- * @public
77
- */
78
- declare type TaskEventType = 'completion' | 'log';
79
- /**
80
- * SerializedTaskEvent
81
- *
82
- * @public
83
- */
84
- declare type SerializedTaskEvent = {
85
- id: number;
86
- taskId: string;
87
- body: JsonObject;
88
- type: TaskEventType;
89
- createdAt: string;
90
- };
91
- /**
92
- * TaskSecrets
93
- *
94
- * @public
95
- */
96
- declare type TaskSecrets = Record<string, string> & {
97
- backstageToken?: string;
98
- };
99
- /**
100
- * The result of {@link TaskBroker.dispatch}
101
- *
102
- * @public
103
- */
104
- declare type TaskBrokerDispatchResult = {
105
- taskId: string;
106
- };
107
- /**
108
- * The options passed to {@link TaskBroker.dispatch}
109
- * Currently a spec and optional secrets
110
- *
111
- * @public
112
- */
113
- declare type TaskBrokerDispatchOptions = {
114
- spec: TaskSpec;
115
- secrets?: TaskSecrets;
116
- createdBy?: string;
117
- };
118
- /**
119
- * Task
120
- *
121
- * @public
122
- */
123
- interface TaskContext {
124
- spec: TaskSpec;
125
- secrets?: TaskSecrets;
126
- createdBy?: string;
127
- done: boolean;
128
- isDryRun?: boolean;
129
- emitLog(message: string, logMetadata?: JsonObject): Promise<void>;
130
- complete(result: TaskCompletionState, metadata?: JsonObject): Promise<void>;
131
- getWorkspaceName(): Promise<string>;
132
- }
133
- /**
134
- * TaskBroker
135
- *
136
- * @public
137
- */
138
- interface TaskBroker {
139
- claim(): Promise<TaskContext>;
140
- dispatch(options: TaskBrokerDispatchOptions): Promise<TaskBrokerDispatchResult>;
141
- vacuumTasks(options: {
142
- timeoutS: number;
143
- }): Promise<void>;
144
- event$(options: {
145
- taskId: string;
146
- after: number | undefined;
147
- }): Observable<{
148
- events: SerializedTaskEvent[];
149
- }>;
150
- get(taskId: string): Promise<SerializedTask>;
151
- list?(options?: {
152
- createdBy?: string;
153
- }): Promise<{
154
- tasks: SerializedTask[];
155
- }>;
156
- }
157
- /**
158
- * TaskStoreEmitOptions
159
- *
160
- * @public
161
- */
162
- declare type TaskStoreEmitOptions<TBody = JsonObject> = {
163
- taskId: string;
164
- body: TBody;
165
- };
166
- /**
167
- * TaskStoreListEventsOptions
168
- *
169
- * @public
170
- */
171
- declare type TaskStoreListEventsOptions = {
172
- taskId: string;
173
- after?: number | undefined;
174
- };
175
- /**
176
- * The options passed to {@link TaskStore.createTask}
177
- * @public
178
- */
179
- declare type TaskStoreCreateTaskOptions = {
180
- spec: TaskSpec;
181
- createdBy?: string;
182
- secrets?: TaskSecrets;
183
- };
184
- /**
185
- * The response from {@link TaskStore.createTask}
186
- * @public
187
- */
188
- declare type TaskStoreCreateTaskResult = {
189
- taskId: string;
190
- };
191
- /**
192
- * TaskStore
193
- *
194
- * @public
195
- */
196
- interface TaskStore {
197
- createTask(options: TaskStoreCreateTaskOptions): Promise<TaskStoreCreateTaskResult>;
198
- getTask(taskId: string): Promise<SerializedTask>;
199
- claimTask(): Promise<SerializedTask | undefined>;
200
- completeTask(options: {
201
- taskId: string;
202
- status: TaskStatus;
203
- eventBody: JsonObject;
204
- }): Promise<void>;
205
- heartbeatTask(taskId: string): Promise<void>;
206
- listStaleTasks(options: {
207
- timeoutS: number;
208
- }): Promise<{
209
- tasks: {
210
- taskId: string;
211
- }[];
212
- }>;
213
- list?(options: {
214
- createdBy?: string;
215
- }): Promise<{
216
- tasks: SerializedTask[];
217
- }>;
218
- emitLogEvent({ taskId, body }: TaskStoreEmitOptions): Promise<void>;
219
- listEvents({ taskId, after, }: TaskStoreListEventsOptions): Promise<{
220
- events: SerializedTaskEvent[];
221
- }>;
222
- }
17
+ import { GithubCredentialsProvider } from '@backstage/integration';
18
+ import { JsonObject } from '@backstage/types';
19
+ import { JsonValue } from '@backstage/types';
20
+ import { Knex } from 'knex';
21
+ import { LocationSpec } from '@backstage/plugin-catalog-backend';
22
+ import { Logger } from 'winston';
23
+ import { Observable } from '@backstage/types';
24
+ import { PluginDatabaseManager } from '@backstage/backend-common';
25
+ import { Schema } from 'jsonschema';
26
+ import { ScmIntegrationRegistry } from '@backstage/integration';
27
+ import { ScmIntegrations } from '@backstage/integration';
28
+ import { SpawnOptionsWithoutStdio } from 'child_process';
29
+ import { TaskSpec } from '@backstage/plugin-scaffolder-common';
30
+ import { TaskSpecV1beta3 } from '@backstage/plugin-scaffolder-common';
31
+ import { TemplateInfo } from '@backstage/plugin-scaffolder-common';
32
+ import { UrlReader } from '@backstage/backend-common';
33
+ import { Writable } from 'stream';
223
34
 
224
35
  /**
225
36
  * ActionContext is passed into scaffolder actions.
226
37
  * @public
227
38
  */
228
- declare type ActionContext<Input extends JsonObject> = {
39
+ export declare type ActionContext<Input extends JsonObject> = {
229
40
  logger: Logger;
230
41
  logStream: Writable;
231
42
  secrets?: TaskSecrets;
@@ -243,23 +54,21 @@ declare type ActionContext<Input extends JsonObject> = {
243
54
  */
244
55
  isDryRun?: boolean;
245
56
  };
246
- /** @public */
247
- declare type TemplateAction<Input extends JsonObject> = {
248
- id: string;
249
- description?: string;
250
- supportsDryRun?: boolean;
251
- schema?: {
252
- input?: Schema;
253
- output?: Schema;
254
- };
255
- handler: (ctx: ActionContext<Input>) => Promise<void>;
256
- };
57
+
58
+ /**
59
+ * A function to generate create a list of default actions that the scaffolder provides.
60
+ * Is called internally in the default setup, but can be used when adding your own actions or overriding the default ones
61
+ *
62
+ * @public
63
+ * @returns A list of actions that can be used in the scaffolder
64
+ */
65
+ export declare const createBuiltinActions: (options: CreateBuiltInActionsOptions) => TemplateAction<JsonObject>[];
257
66
 
258
67
  /**
259
68
  * The options passed to {@link createBuiltinActions}
260
69
  * @public
261
70
  */
262
- interface CreateBuiltInActionsOptions {
71
+ export declare interface CreateBuiltInActionsOptions {
263
72
  /**
264
73
  * The {@link @backstage/backend-common#UrlReader} interface that will be used in the default actions.
265
74
  */
@@ -282,14 +91,31 @@ interface CreateBuiltInActionsOptions {
282
91
  */
283
92
  additionalTemplateFilters?: Record<string, TemplateFilter>;
284
93
  }
94
+
285
95
  /**
286
- * A function to generate create a list of default actions that the scaffolder provides.
287
- * Is called internally in the default setup, but can be used when adding your own actions or overriding the default ones
288
- *
96
+ * Registers entities from a catalog descriptor file in the workspace into the software catalog.
97
+ * @public
98
+ */
99
+ export declare function createCatalogRegisterAction(options: {
100
+ catalogClient: CatalogApi;
101
+ integrations: ScmIntegrations;
102
+ }): TemplateAction< {
103
+ catalogInfoUrl: string;
104
+ optional?: boolean | undefined;
105
+ } | {
106
+ repoContentsUrl: string;
107
+ catalogInfoPath?: string | undefined;
108
+ optional?: boolean | undefined;
109
+ }>;
110
+
111
+ /**
112
+ * Writes a catalog descriptor file containing the provided entity to a path in the workspace.
289
113
  * @public
290
- * @returns A list of actions that can be used in the scaffolder
291
114
  */
292
- declare const createBuiltinActions: (options: CreateBuiltInActionsOptions) => TemplateAction<JsonObject>[];
115
+ export declare function createCatalogWriteAction(): TemplateAction< {
116
+ filePath?: string | undefined;
117
+ entity: Entity;
118
+ }>;
293
119
 
294
120
  /**
295
121
  * Writes a message into the log or lists all files in the workspace
@@ -301,9 +127,9 @@ declare const createBuiltinActions: (options: CreateBuiltInActionsOptions) => Te
301
127
  *
302
128
  * @public
303
129
  */
304
- declare function createDebugLogAction(): TemplateAction<{
305
- message?: string | undefined;
306
- listWorkspace?: boolean | undefined;
130
+ export declare function createDebugLogAction(): TemplateAction< {
131
+ message?: string | undefined;
132
+ listWorkspace?: boolean | undefined;
307
133
  }>;
308
134
 
309
135
  /**
@@ -311,12 +137,12 @@ declare function createDebugLogAction(): TemplateAction<{
311
137
  * in a subdirectory specified by the 'targetPath' input option.
312
138
  * @public
313
139
  */
314
- declare function createFetchPlainAction(options: {
140
+ export declare function createFetchPlainAction(options: {
315
141
  reader: UrlReader;
316
142
  integrations: ScmIntegrations;
317
- }): TemplateAction<{
318
- url: string;
319
- targetPath?: string | undefined;
143
+ }): TemplateAction< {
144
+ url: string;
145
+ targetPath?: string | undefined;
320
146
  }>;
321
147
 
322
148
  /**
@@ -326,394 +152,442 @@ declare function createFetchPlainAction(options: {
326
152
  *
327
153
  * @public
328
154
  */
329
- declare function createFetchTemplateAction(options: {
155
+ export declare function createFetchTemplateAction(options: {
330
156
  reader: UrlReader;
331
157
  integrations: ScmIntegrations;
332
158
  additionalTemplateFilters?: Record<string, TemplateFilter>;
333
- }): TemplateAction<{
334
- url: string;
335
- targetPath?: string | undefined;
336
- values: any;
337
- templateFileExtension?: string | boolean | undefined;
338
- copyWithoutRender?: string[] | undefined;
339
- cookiecutterCompat?: boolean | undefined;
159
+ }): TemplateAction< {
160
+ url: string;
161
+ targetPath?: string | undefined;
162
+ values: any;
163
+ templateFileExtension?: string | boolean | undefined;
164
+ copyWithoutRender?: string[] | undefined;
165
+ cookiecutterCompat?: boolean | undefined;
340
166
  }>;
341
167
 
342
- /**
343
- * A helper function that reads the contents of a directory from the given URL.
344
- * Can be used in your own actions, and also used behind fetch:template and fetch:plain
345
- *
346
- * @public
347
- */
348
- declare function fetchContents({ reader, integrations, baseUrl, fetchUrl, outputPath, }: {
349
- reader: UrlReader;
350
- integrations: ScmIntegrations;
351
- baseUrl?: string;
352
- fetchUrl?: string;
353
- outputPath: string;
354
- }): Promise<void>;
355
-
356
168
  /**
357
169
  * Creates new action that enables deletion of files and directories in the workspace.
358
170
  * @public
359
171
  */
360
- declare const createFilesystemDeleteAction: () => TemplateAction<{
361
- files: string[];
172
+ export declare const createFilesystemDeleteAction: () => TemplateAction< {
173
+ files: string[];
362
174
  }>;
363
175
 
364
176
  /**
365
177
  * Creates a new action that allows renames of files and directories in the workspace.
366
178
  * @public
367
179
  */
368
- declare const createFilesystemRenameAction: () => TemplateAction<{
369
- files: Array<{
370
- from: string;
371
- to: string;
372
- overwrite?: boolean;
373
- }>;
180
+ export declare const createFilesystemRenameAction: () => TemplateAction< {
181
+ files: Array<{
182
+ from: string;
183
+ to: string;
184
+ overwrite?: boolean;
185
+ }>;
374
186
  }>;
375
187
 
376
188
  /**
377
- * Creates a new action that initializes a git repository of the content in the workspace
378
- * and publishes it to Azure.
189
+ * Creates a new action that dispatches a GitHub Action workflow for a given branch or tag.
379
190
  * @public
380
191
  */
381
- declare function createPublishAzureAction(options: {
382
- integrations: ScmIntegrationRegistry;
383
- config: Config;
384
- }): TemplateAction<{
385
- repoUrl: string;
386
- description?: string | undefined;
387
- defaultBranch?: string | undefined;
388
- sourcePath?: string | undefined;
389
- token?: string | undefined;
390
- gitCommitMessage?: string | undefined;
391
- gitAuthorName?: string | undefined;
392
- gitAuthorEmail?: string | undefined;
192
+ export declare function createGithubActionsDispatchAction(options: {
193
+ integrations: ScmIntegrations;
194
+ githubCredentialsProvider?: GithubCredentialsProvider;
195
+ }): TemplateAction< {
196
+ repoUrl: string;
197
+ workflowId: string;
198
+ branchOrTagName: string;
199
+ workflowInputs?: {
200
+ [key: string]: string;
201
+ } | undefined;
202
+ token?: string | undefined;
393
203
  }>;
394
204
 
395
205
  /**
396
- * Creates a new action that initializes a git repository of the content in the workspace
397
- * and publishes it to Bitbucket.
206
+ * Adds labels to a pull request or issue on GitHub
398
207
  * @public
399
- * @deprecated in favor of createPublishBitbucketCloudAction and createPublishBitbucketServerAction
400
208
  */
401
- declare function createPublishBitbucketAction(options: {
209
+ export declare function createGithubIssuesLabelAction(options: {
402
210
  integrations: ScmIntegrationRegistry;
403
- config: Config;
404
- }): TemplateAction<{
405
- repoUrl: string;
406
- description?: string | undefined;
407
- defaultBranch?: string | undefined;
408
- repoVisibility?: "private" | "public" | undefined;
409
- sourcePath?: string | undefined;
410
- enableLFS?: boolean | undefined;
411
- token?: string | undefined;
412
- gitCommitMessage?: string | undefined;
413
- gitAuthorName?: string | undefined;
414
- gitAuthorEmail?: string | undefined;
211
+ githubCredentialsProvider?: GithubCredentialsProvider;
212
+ }): TemplateAction< {
213
+ repoUrl: string;
214
+ number: number;
215
+ labels: string[];
216
+ token?: string | undefined;
415
217
  }>;
416
218
 
417
219
  /**
418
- * Creates a new action that initializes a git repository of the content in the workspace
419
- * and publishes it to Bitbucket Cloud.
220
+ * The options passed to {@link createPublishGithubPullRequestAction} method
420
221
  * @public
421
222
  */
422
- declare function createPublishBitbucketCloudAction(options: {
223
+ export declare interface CreateGithubPullRequestActionOptions {
224
+ /**
225
+ * An instance of {@link @backstage/integration#ScmIntegrationRegistry} that will be used in the action.
226
+ */
423
227
  integrations: ScmIntegrationRegistry;
424
- config: Config;
425
- }): TemplateAction<{
426
- repoUrl: string;
427
- description?: string | undefined;
428
- defaultBranch?: string | undefined;
429
- repoVisibility?: "private" | "public" | undefined;
430
- sourcePath?: string | undefined;
431
- token?: string | undefined;
228
+ /**
229
+ * An instance of {@link @backstage/integration#GithubCredentialsProvider} that will be used to get credentials for the action.
230
+ */
231
+ githubCredentialsProvider?: GithubCredentialsProvider;
232
+ /**
233
+ * A method to return the Octokit client with the Pull Request Plugin.
234
+ */
235
+ clientFactory?: (input: CreateGithubPullRequestClientFactoryInput) => Promise<OctokitWithPullRequestPluginClient>;
236
+ }
237
+
238
+ /**
239
+ * The options passed to the client factory function.
240
+ * @public
241
+ */
242
+ export declare type CreateGithubPullRequestClientFactoryInput = {
243
+ integrations: ScmIntegrationRegistry;
244
+ githubCredentialsProvider?: GithubCredentialsProvider;
245
+ host: string;
246
+ owner: string;
247
+ repo: string;
248
+ token?: string;
249
+ };
250
+
251
+ /**
252
+ * Creates a new action that initializes a git repository
253
+ *
254
+ * @public
255
+ */
256
+ export declare function createGithubRepoCreateAction(options: {
257
+ integrations: ScmIntegrationRegistry;
258
+ githubCredentialsProvider?: GithubCredentialsProvider;
259
+ }): TemplateAction< {
260
+ repoUrl: string;
261
+ description?: string | undefined;
262
+ access?: string | undefined;
263
+ deleteBranchOnMerge?: boolean | undefined;
264
+ gitAuthorName?: string | undefined;
265
+ gitAuthorEmail?: string | undefined;
266
+ allowRebaseMerge?: boolean | undefined;
267
+ allowSquashMerge?: boolean | undefined;
268
+ allowMergeCommit?: boolean | undefined;
269
+ requireCodeOwnerReviews?: boolean | undefined;
270
+ requiredStatusCheckContexts?: string[] | undefined;
271
+ repoVisibility?: "internal" | "private" | "public" | undefined;
272
+ collaborators?: ({
273
+ user: string;
274
+ access: 'pull' | 'push' | 'admin' | 'maintain' | 'triage';
275
+ } | {
276
+ team: string;
277
+ access: 'pull' | 'push' | 'admin' | 'maintain' | 'triage';
278
+ } | {
279
+ /** @deprecated This field is deprecated in favor of team */
280
+ username: string;
281
+ access: 'pull' | 'push' | 'admin' | 'maintain' | 'triage';
282
+ })[] | undefined;
283
+ token?: string | undefined;
284
+ topics?: string[] | undefined;
432
285
  }>;
433
286
 
434
287
  /**
435
288
  * Creates a new action that initializes a git repository of the content in the workspace
436
- * and publishes it to Bitbucket Server.
289
+ * and publishes it to GitHub.
290
+ *
437
291
  * @public
438
292
  */
439
- declare function createPublishBitbucketServerAction(options: {
293
+ export declare function createGithubRepoPushAction(options: {
440
294
  integrations: ScmIntegrationRegistry;
441
295
  config: Config;
442
- }): TemplateAction<{
443
- repoUrl: string;
444
- description?: string | undefined;
445
- defaultBranch?: string | undefined;
446
- repoVisibility?: "private" | "public" | undefined;
447
- sourcePath?: string | undefined;
448
- enableLFS?: boolean | undefined;
449
- token?: string | undefined;
296
+ githubCredentialsProvider?: GithubCredentialsProvider;
297
+ }): TemplateAction< {
298
+ repoUrl: string;
299
+ description?: string | undefined;
300
+ defaultBranch?: string | undefined;
301
+ protectDefaultBranch?: boolean | undefined;
302
+ gitCommitMessage?: string | undefined;
303
+ gitAuthorName?: string | undefined;
304
+ gitAuthorEmail?: string | undefined;
305
+ requireCodeOwnerReviews?: boolean | undefined;
306
+ requiredStatusCheckContexts?: string[] | undefined;
307
+ sourcePath?: string | undefined;
308
+ token?: string | undefined;
450
309
  }>;
451
310
 
452
311
  /**
453
- * This task is useful for local development and testing of both the scaffolder
454
- * and scaffolder templates.
455
- *
456
- * @remarks
457
- *
458
- * This action is not installed by default and should not be installed in
459
- * production, as it writes the files to the local filesystem of the scaffolder.
460
- *
312
+ * Creates new action that creates a webhook for a repository on GitHub.
461
313
  * @public
462
314
  */
463
- declare function createPublishFileAction(): TemplateAction<{
464
- path: string;
315
+ export declare function createGithubWebhookAction(options: {
316
+ integrations: ScmIntegrationRegistry;
317
+ defaultWebhookSecret?: string;
318
+ githubCredentialsProvider?: GithubCredentialsProvider;
319
+ }): TemplateAction< {
320
+ repoUrl: string;
321
+ webhookUrl: string;
322
+ webhookSecret?: string | undefined;
323
+ events?: string[] | undefined;
324
+ active?: boolean | undefined;
325
+ contentType?: "form" | "json" | undefined;
326
+ insecureSsl?: boolean | undefined;
327
+ token?: string | undefined;
465
328
  }>;
466
329
 
467
330
  /**
468
331
  * Creates a new action that initializes a git repository of the content in the workspace
469
- * and publishes it to a Gerrit instance.
332
+ * and publishes it to Azure.
470
333
  * @public
471
334
  */
472
- declare function createPublishGerritAction(options: {
335
+ export declare function createPublishAzureAction(options: {
473
336
  integrations: ScmIntegrationRegistry;
474
337
  config: Config;
475
- }): TemplateAction<{
476
- repoUrl: string;
477
- description: string;
478
- defaultBranch?: string | undefined;
479
- gitCommitMessage?: string | undefined;
480
- gitAuthorName?: string | undefined;
481
- gitAuthorEmail?: string | undefined;
338
+ }): TemplateAction< {
339
+ repoUrl: string;
340
+ description?: string | undefined;
341
+ defaultBranch?: string | undefined;
342
+ sourcePath?: string | undefined;
343
+ token?: string | undefined;
344
+ gitCommitMessage?: string | undefined;
345
+ gitAuthorName?: string | undefined;
346
+ gitAuthorEmail?: string | undefined;
482
347
  }>;
483
348
 
484
349
  /**
485
350
  * Creates a new action that initializes a git repository of the content in the workspace
486
- * and publishes it to GitHub.
487
- *
351
+ * and publishes it to Bitbucket.
488
352
  * @public
353
+ * @deprecated in favor of createPublishBitbucketCloudAction and createPublishBitbucketServerAction
489
354
  */
490
- declare function createPublishGithubAction(options: {
355
+ export declare function createPublishBitbucketAction(options: {
491
356
  integrations: ScmIntegrationRegistry;
492
357
  config: Config;
493
- githubCredentialsProvider?: GithubCredentialsProvider;
494
- }): TemplateAction<{
495
- repoUrl: string;
496
- description?: string | undefined;
497
- access?: string | undefined;
498
- defaultBranch?: string | undefined;
499
- protectDefaultBranch?: boolean | undefined;
500
- deleteBranchOnMerge?: boolean | undefined;
501
- gitCommitMessage?: string | undefined;
502
- gitAuthorName?: string | undefined;
503
- gitAuthorEmail?: string | undefined;
504
- allowRebaseMerge?: boolean | undefined;
505
- allowSquashMerge?: boolean | undefined;
506
- allowMergeCommit?: boolean | undefined;
507
- sourcePath?: string | undefined;
508
- requireCodeOwnerReviews?: boolean | undefined;
509
- requiredStatusCheckContexts?: string[] | undefined;
510
- repoVisibility?: "internal" | "private" | "public" | undefined;
511
- collaborators?: ({
512
- user: string;
513
- access: 'pull' | 'push' | 'admin' | 'maintain' | 'triage';
514
- } | {
515
- team: string;
516
- access: 'pull' | 'push' | 'admin' | 'maintain' | 'triage';
517
- } | {
518
- /** @deprecated This field is deprecated in favor of team */
519
- username: string;
520
- access: 'pull' | 'push' | 'admin' | 'maintain' | 'triage';
521
- })[] | undefined;
522
- token?: string | undefined;
523
- topics?: string[] | undefined;
358
+ }): TemplateAction< {
359
+ repoUrl: string;
360
+ description?: string | undefined;
361
+ defaultBranch?: string | undefined;
362
+ repoVisibility?: "private" | "public" | undefined;
363
+ sourcePath?: string | undefined;
364
+ enableLFS?: boolean | undefined;
365
+ token?: string | undefined;
366
+ gitCommitMessage?: string | undefined;
367
+ gitAuthorName?: string | undefined;
368
+ gitAuthorEmail?: string | undefined;
524
369
  }>;
525
370
 
526
- /** @public */
527
- interface OctokitWithPullRequestPluginClient {
528
- createPullRequest(options: createPullRequest.Options): Promise<{
529
- data: {
530
- html_url: string;
531
- number: number;
532
- };
533
- } | null>;
534
- }
535
371
  /**
536
- * The options passed to the client factory function.
372
+ * Creates a new action that initializes a git repository of the content in the workspace
373
+ * and publishes it to Bitbucket Cloud.
537
374
  * @public
538
375
  */
539
- declare type CreateGithubPullRequestClientFactoryInput = {
376
+ export declare function createPublishBitbucketCloudAction(options: {
540
377
  integrations: ScmIntegrationRegistry;
541
- githubCredentialsProvider?: GithubCredentialsProvider;
542
- host: string;
543
- owner: string;
544
- repo: string;
545
- token?: string;
546
- };
378
+ config: Config;
379
+ }): TemplateAction< {
380
+ repoUrl: string;
381
+ description?: string | undefined;
382
+ defaultBranch?: string | undefined;
383
+ repoVisibility?: "private" | "public" | undefined;
384
+ sourcePath?: string | undefined;
385
+ token?: string | undefined;
386
+ }>;
387
+
547
388
  /**
548
- * The options passed to {@link createPublishGithubPullRequestAction} method
389
+ * Creates a new action that initializes a git repository of the content in the workspace
390
+ * and publishes it to Bitbucket Server.
549
391
  * @public
550
392
  */
551
- interface CreateGithubPullRequestActionOptions {
552
- /**
553
- * An instance of {@link @backstage/integration#ScmIntegrationRegistry} that will be used in the action.
554
- */
393
+ export declare function createPublishBitbucketServerAction(options: {
555
394
  integrations: ScmIntegrationRegistry;
556
- /**
557
- * An instance of {@link @backstage/integration#GithubCredentialsProvider} that will be used to get credentials for the action.
558
- */
559
- githubCredentialsProvider?: GithubCredentialsProvider;
560
- /**
561
- * A method to return the Octokit client with the Pull Request Plugin.
562
- */
563
- clientFactory?: (input: CreateGithubPullRequestClientFactoryInput) => Promise<OctokitWithPullRequestPluginClient>;
564
- }
395
+ config: Config;
396
+ }): TemplateAction< {
397
+ repoUrl: string;
398
+ description?: string | undefined;
399
+ defaultBranch?: string | undefined;
400
+ repoVisibility?: "private" | "public" | undefined;
401
+ sourcePath?: string | undefined;
402
+ enableLFS?: boolean | undefined;
403
+ token?: string | undefined;
404
+ }>;
405
+
565
406
  /**
566
- * Creates a Github Pull Request action.
407
+ * This task is useful for local development and testing of both the scaffolder
408
+ * and scaffolder templates.
409
+ *
410
+ * @remarks
411
+ *
412
+ * This action is not installed by default and should not be installed in
413
+ * production, as it writes the files to the local filesystem of the scaffolder.
414
+ *
567
415
  * @public
568
416
  */
569
- declare const createPublishGithubPullRequestAction: ({ integrations, githubCredentialsProvider, clientFactory, }: CreateGithubPullRequestActionOptions) => TemplateAction<{
570
- title: string;
571
- branchName: string;
572
- description: string;
573
- repoUrl: string;
574
- draft?: boolean | undefined;
575
- targetPath?: string | undefined;
576
- sourcePath?: string | undefined;
577
- token?: string | undefined;
417
+ export declare function createPublishFileAction(): TemplateAction< {
418
+ path: string;
578
419
  }>;
579
420
 
580
421
  /**
581
422
  * Creates a new action that initializes a git repository of the content in the workspace
582
- * and publishes it to GitLab.
583
- *
423
+ * and publishes it to a Gerrit instance.
584
424
  * @public
585
425
  */
586
- declare function createPublishGitlabAction(options: {
426
+ export declare function createPublishGerritAction(options: {
587
427
  integrations: ScmIntegrationRegistry;
588
428
  config: Config;
589
- }): TemplateAction<{
590
- repoUrl: string;
591
- defaultBranch?: string | undefined;
592
- repoVisibility?: "internal" | "private" | "public" | undefined;
593
- sourcePath?: string | undefined;
594
- token?: string | undefined;
595
- gitCommitMessage?: string | undefined;
596
- gitAuthorName?: string | undefined;
597
- gitAuthorEmail?: string | undefined;
429
+ }): TemplateAction< {
430
+ repoUrl: string;
431
+ description: string;
432
+ defaultBranch?: string | undefined;
433
+ gitCommitMessage?: string | undefined;
434
+ gitAuthorName?: string | undefined;
435
+ gitAuthorEmail?: string | undefined;
598
436
  }>;
599
437
 
600
438
  /**
601
- * Create a new action that creates a gitlab merge request.
439
+ * Creates a new action that initializes a git repository of the content in the workspace
440
+ * and publishes it to GitHub.
602
441
  *
603
442
  * @public
604
443
  */
605
- declare const createPublishGitlabMergeRequestAction: (options: {
444
+ export declare function createPublishGithubAction(options: {
606
445
  integrations: ScmIntegrationRegistry;
607
- }) => TemplateAction<{
608
- repoUrl: string;
609
- title: string;
610
- description: string;
611
- branchName: string;
612
- targetPath: string;
613
- token?: string | undefined;
614
- /** @deprecated Use projectPath instead */
615
- projectid?: string | undefined;
446
+ config: Config;
447
+ githubCredentialsProvider?: GithubCredentialsProvider;
448
+ }): TemplateAction< {
449
+ repoUrl: string;
450
+ description?: string | undefined;
451
+ access?: string | undefined;
452
+ defaultBranch?: string | undefined;
453
+ protectDefaultBranch?: boolean | undefined;
454
+ deleteBranchOnMerge?: boolean | undefined;
455
+ gitCommitMessage?: string | undefined;
456
+ gitAuthorName?: string | undefined;
457
+ gitAuthorEmail?: string | undefined;
458
+ allowRebaseMerge?: boolean | undefined;
459
+ allowSquashMerge?: boolean | undefined;
460
+ allowMergeCommit?: boolean | undefined;
461
+ sourcePath?: string | undefined;
462
+ requireCodeOwnerReviews?: boolean | undefined;
463
+ requiredStatusCheckContexts?: string[] | undefined;
464
+ repoVisibility?: "internal" | "private" | "public" | undefined;
465
+ collaborators?: ({
466
+ user: string;
467
+ access: 'pull' | 'push' | 'admin' | 'maintain' | 'triage';
468
+ } | {
469
+ team: string;
470
+ access: 'pull' | 'push' | 'admin' | 'maintain' | 'triage';
471
+ } | {
472
+ /** @deprecated This field is deprecated in favor of team */
473
+ username: string;
474
+ access: 'pull' | 'push' | 'admin' | 'maintain' | 'triage';
475
+ })[] | undefined;
476
+ token?: string | undefined;
477
+ topics?: string[] | undefined;
616
478
  }>;
617
479
 
618
480
  /**
619
- * Creates a new action that dispatches a GitHub Action workflow for a given branch or tag.
481
+ * Creates a Github Pull Request action.
620
482
  * @public
621
483
  */
622
- declare function createGithubActionsDispatchAction(options: {
623
- integrations: ScmIntegrations;
624
- githubCredentialsProvider?: GithubCredentialsProvider;
625
- }): TemplateAction<{
626
- repoUrl: string;
627
- workflowId: string;
628
- branchOrTagName: string;
629
- workflowInputs?: {
630
- [key: string]: string;
631
- } | undefined;
632
- token?: string | undefined;
484
+ export declare const createPublishGithubPullRequestAction: ({ integrations, githubCredentialsProvider, clientFactory, }: CreateGithubPullRequestActionOptions) => TemplateAction< {
485
+ title: string;
486
+ branchName: string;
487
+ description: string;
488
+ repoUrl: string;
489
+ draft?: boolean | undefined;
490
+ targetPath?: string | undefined;
491
+ sourcePath?: string | undefined;
492
+ token?: string | undefined;
633
493
  }>;
634
494
 
635
495
  /**
636
- * Creates new action that creates a webhook for a repository on GitHub.
496
+ * Creates a new action that initializes a git repository of the content in the workspace
497
+ * and publishes it to GitLab.
498
+ *
637
499
  * @public
638
500
  */
639
- declare function createGithubWebhookAction(options: {
501
+ export declare function createPublishGitlabAction(options: {
640
502
  integrations: ScmIntegrationRegistry;
641
- defaultWebhookSecret?: string;
642
- githubCredentialsProvider?: GithubCredentialsProvider;
643
- }): TemplateAction<{
644
- repoUrl: string;
645
- webhookUrl: string;
646
- webhookSecret?: string | undefined;
647
- events?: string[] | undefined;
648
- active?: boolean | undefined;
649
- contentType?: "form" | "json" | undefined;
650
- insecureSsl?: boolean | undefined;
651
- token?: string | undefined;
503
+ config: Config;
504
+ }): TemplateAction< {
505
+ repoUrl: string;
506
+ defaultBranch?: string | undefined;
507
+ repoVisibility?: "internal" | "private" | "public" | undefined;
508
+ sourcePath?: string | undefined;
509
+ token?: string | undefined;
510
+ gitCommitMessage?: string | undefined;
511
+ gitAuthorName?: string | undefined;
512
+ gitAuthorEmail?: string | undefined;
513
+ setUserAsOwner?: boolean | undefined;
652
514
  }>;
653
515
 
654
516
  /**
655
- * Adds labels to a pull request or issue on GitHub
517
+ * Create a new action that creates a gitlab merge request.
518
+ *
656
519
  * @public
657
520
  */
658
- declare function createGithubIssuesLabelAction(options: {
521
+ export declare const createPublishGitlabMergeRequestAction: (options: {
659
522
  integrations: ScmIntegrationRegistry;
660
- githubCredentialsProvider?: GithubCredentialsProvider;
661
- }): TemplateAction<{
662
- repoUrl: string;
663
- number: number;
664
- labels: string[];
665
- token?: string | undefined;
523
+ }) => TemplateAction< {
524
+ repoUrl: string;
525
+ title: string;
526
+ description: string;
527
+ branchName: string;
528
+ targetPath: string;
529
+ token?: string | undefined;
530
+ /** @deprecated Use projectPath instead */
531
+ projectid?: string | undefined;
532
+ removeSourceBranch?: boolean | undefined;
666
533
  }>;
667
534
 
668
- /** @public */
669
- declare type RunCommandOptions = {
670
- /** command to run */
671
- command: string;
672
- /** arguments to pass the command */
673
- args: string[];
674
- /** options to pass to spawn */
675
- options?: SpawnOptionsWithoutStdio;
676
- /** stream to capture stdout and stderr output */
677
- logStream?: Writable;
678
- };
679
535
  /**
680
- * Run a command in a sub-process, normally a shell command.
681
- *
536
+ * A method to create a router for the scaffolder backend plugin.
682
537
  * @public
683
538
  */
684
- declare const executeShellCommand: (options: RunCommandOptions) => Promise<void>;
539
+ export declare function createRouter(options: RouterOptions): Promise<express.Router>;
685
540
 
686
541
  /**
687
- * Registry of all registered template actions.
542
+ * This function is used to create new template actions to get type safety.
688
543
  * @public
689
544
  */
690
- declare class TemplateActionRegistry {
691
- private readonly actions;
692
- register<TInput extends JsonObject>(action: TemplateAction<TInput>): void;
693
- get(actionId: string): TemplateAction<JsonObject>;
694
- list(): TemplateAction<JsonObject>[];
695
- }
545
+ export declare const createTemplateAction: <TInput extends JsonObject>(templateAction: TemplateAction<TInput>) => TemplateAction<TInput>;
696
546
 
697
547
  /**
698
- * This function is used to create new template actions to get type safety.
548
+ * CreateWorkerOptions
549
+ *
699
550
  * @public
700
551
  */
701
- declare const createTemplateAction: <TInput extends JsonObject>(templateAction: TemplateAction<TInput>) => TemplateAction<TInput>;
552
+ export declare type CreateWorkerOptions = {
553
+ taskBroker: TaskBroker;
554
+ actionRegistry: TemplateActionRegistry;
555
+ integrations: ScmIntegrations;
556
+ workingDirectory: string;
557
+ logger: Logger;
558
+ additionalTemplateFilters?: Record<string, TemplateFilter>;
559
+ };
702
560
 
703
561
  /**
704
- * DatabaseTaskStore
562
+ * Stores the state of the current claimed task passed to the TaskContext
705
563
  *
706
564
  * @public
707
565
  */
708
- declare type DatabaseTaskStoreOptions = {
709
- database: Knex;
710
- };
566
+ export declare interface CurrentClaimedTask {
567
+ /**
568
+ * The TaskSpec of the current claimed task.
569
+ */
570
+ spec: TaskSpec;
571
+ /**
572
+ * The uuid of the current claimed task.
573
+ */
574
+ taskId: string;
575
+ /**
576
+ * The secrets that are stored with the task.
577
+ */
578
+ secrets?: TaskSecrets;
579
+ /**
580
+ * The creator of the task.
581
+ */
582
+ createdBy?: string;
583
+ }
584
+
711
585
  /**
712
586
  * DatabaseTaskStore
713
587
  *
714
588
  * @public
715
589
  */
716
- declare class DatabaseTaskStore implements TaskStore {
590
+ export declare class DatabaseTaskStore implements TaskStore {
717
591
  private readonly db;
718
592
  static create(options: DatabaseTaskStoreOptions): Promise<DatabaseTaskStore>;
719
593
  private constructor();
@@ -746,12 +620,195 @@ declare class DatabaseTaskStore implements TaskStore {
746
620
  }>;
747
621
  }
748
622
 
623
+ /**
624
+ * DatabaseTaskStore
625
+ *
626
+ * @public
627
+ */
628
+ export declare type DatabaseTaskStoreOptions = {
629
+ database: Knex;
630
+ };
631
+
632
+ /**
633
+ * Run a command in a sub-process, normally a shell command.
634
+ *
635
+ * @public
636
+ */
637
+ export declare const executeShellCommand: (options: RunCommandOptions) => Promise<void>;
638
+
639
+ /**
640
+ * A helper function that reads the contents of a directory from the given URL.
641
+ * Can be used in your own actions, and also used behind fetch:template and fetch:plain
642
+ *
643
+ * @public
644
+ */
645
+ export declare function fetchContents({ reader, integrations, baseUrl, fetchUrl, outputPath, }: {
646
+ reader: UrlReader;
647
+ integrations: ScmIntegrations;
648
+ baseUrl?: string;
649
+ fetchUrl?: string;
650
+ outputPath: string;
651
+ }): Promise<void>;
652
+
653
+ /** @public */
654
+ export declare interface OctokitWithPullRequestPluginClient {
655
+ createPullRequest(options: createPullRequest.Options): Promise<{
656
+ data: {
657
+ html_url: string;
658
+ number: number;
659
+ };
660
+ } | null>;
661
+ }
662
+
663
+ /**
664
+ * RouterOptions
665
+ *
666
+ * @public
667
+ */
668
+ export declare interface RouterOptions {
669
+ logger: Logger;
670
+ config: Config;
671
+ reader: UrlReader;
672
+ database: PluginDatabaseManager;
673
+ catalogClient: CatalogApi;
674
+ actions?: TemplateAction<any>[];
675
+ taskWorkers?: number;
676
+ taskBroker?: TaskBroker;
677
+ additionalTemplateFilters?: Record<string, TemplateFilter>;
678
+ }
679
+
680
+ /** @public */
681
+ export declare type RunCommandOptions = {
682
+ /** command to run */
683
+ command: string;
684
+ /** arguments to pass the command */
685
+ args: string[];
686
+ /** options to pass to spawn */
687
+ options?: SpawnOptionsWithoutStdio;
688
+ /** stream to capture stdout and stderr output */
689
+ logStream?: Writable;
690
+ };
691
+
692
+ /* Excluded from this release type: scaffolderCatalogModule */
693
+
694
+ /** @public */
695
+ export declare class ScaffolderEntitiesProcessor implements CatalogProcessor {
696
+ getProcessorName(): string;
697
+ private readonly validators;
698
+ validateEntityKind(entity: Entity): Promise<boolean>;
699
+ postProcessEntity(entity: Entity, _location: LocationSpec, emit: CatalogProcessorEmit): Promise<Entity>;
700
+ }
701
+
702
+ /**
703
+ * SerializedTask
704
+ *
705
+ * @public
706
+ */
707
+ export declare type SerializedTask = {
708
+ id: string;
709
+ spec: TaskSpec;
710
+ status: TaskStatus;
711
+ createdAt: string;
712
+ lastHeartbeatAt?: string;
713
+ createdBy?: string;
714
+ secrets?: TaskSecrets;
715
+ };
716
+
717
+ /**
718
+ * SerializedTaskEvent
719
+ *
720
+ * @public
721
+ */
722
+ export declare type SerializedTaskEvent = {
723
+ id: number;
724
+ taskId: string;
725
+ body: JsonObject;
726
+ type: TaskEventType;
727
+ createdAt: string;
728
+ };
729
+
730
+ /**
731
+ * TaskBroker
732
+ *
733
+ * @public
734
+ */
735
+ export declare interface TaskBroker {
736
+ claim(): Promise<TaskContext>;
737
+ dispatch(options: TaskBrokerDispatchOptions): Promise<TaskBrokerDispatchResult>;
738
+ vacuumTasks(options: {
739
+ timeoutS: number;
740
+ }): Promise<void>;
741
+ event$(options: {
742
+ taskId: string;
743
+ after: number | undefined;
744
+ }): Observable<{
745
+ events: SerializedTaskEvent[];
746
+ }>;
747
+ get(taskId: string): Promise<SerializedTask>;
748
+ list?(options?: {
749
+ createdBy?: string;
750
+ }): Promise<{
751
+ tasks: SerializedTask[];
752
+ }>;
753
+ }
754
+
755
+ /**
756
+ * The options passed to {@link TaskBroker.dispatch}
757
+ * Currently a spec and optional secrets
758
+ *
759
+ * @public
760
+ */
761
+ export declare type TaskBrokerDispatchOptions = {
762
+ spec: TaskSpec;
763
+ secrets?: TaskSecrets;
764
+ createdBy?: string;
765
+ };
766
+
767
+ /**
768
+ * The result of {@link TaskBroker.dispatch}
769
+ *
770
+ * @public
771
+ */
772
+ export declare type TaskBrokerDispatchResult = {
773
+ taskId: string;
774
+ };
775
+
776
+ /**
777
+ * The state of a completed task.
778
+ *
779
+ * @public
780
+ */
781
+ export declare type TaskCompletionState = 'failed' | 'completed';
782
+
783
+ /**
784
+ * Task
785
+ *
786
+ * @public
787
+ */
788
+ export declare interface TaskContext {
789
+ spec: TaskSpec;
790
+ secrets?: TaskSecrets;
791
+ createdBy?: string;
792
+ done: boolean;
793
+ isDryRun?: boolean;
794
+ emitLog(message: string, logMetadata?: JsonObject): Promise<void>;
795
+ complete(result: TaskCompletionState, metadata?: JsonObject): Promise<void>;
796
+ getWorkspaceName(): Promise<string>;
797
+ }
798
+
799
+ /**
800
+ * TaskEventType
801
+ *
802
+ * @public
803
+ */
804
+ export declare type TaskEventType = 'completion' | 'log';
805
+
749
806
  /**
750
807
  * TaskManager
751
808
  *
752
809
  * @public
753
810
  */
754
- declare class TaskManager implements TaskContext {
811
+ export declare class TaskManager implements TaskContext {
755
812
  private readonly task;
756
813
  private readonly storage;
757
814
  private readonly logger;
@@ -759,7 +816,7 @@ declare class TaskManager implements TaskContext {
759
816
  private heartbeatTimeoutId?;
760
817
  static create(task: CurrentClaimedTask, storage: TaskStore, logger: Logger): TaskManager;
761
818
  private constructor();
762
- get spec(): _backstage_plugin_scaffolder_common.TaskSpecV1beta3;
819
+ get spec(): TaskSpecV1beta3;
763
820
  get secrets(): TaskSecrets | undefined;
764
821
  get createdBy(): string | undefined;
765
822
  getWorkspaceName(): Promise<string>;
@@ -768,49 +825,100 @@ declare class TaskManager implements TaskContext {
768
825
  complete(result: TaskCompletionState, metadata?: JsonObject): Promise<void>;
769
826
  private startTimeout;
770
827
  }
828
+
771
829
  /**
772
- * Stores the state of the current claimed task passed to the TaskContext
830
+ * TaskSecrets
773
831
  *
774
832
  * @public
775
833
  */
776
- interface CurrentClaimedTask {
777
- /**
778
- * The TaskSpec of the current claimed task.
779
- */
834
+ export declare type TaskSecrets = Record<string, string> & {
835
+ backstageToken?: string;
836
+ };
837
+
838
+ /**
839
+ * The status of each step of the Task
840
+ *
841
+ * @public
842
+ */
843
+ export declare type TaskStatus = 'open' | 'processing' | 'failed' | 'cancelled' | 'completed';
844
+
845
+ /**
846
+ * TaskStore
847
+ *
848
+ * @public
849
+ */
850
+ export declare interface TaskStore {
851
+ createTask(options: TaskStoreCreateTaskOptions): Promise<TaskStoreCreateTaskResult>;
852
+ getTask(taskId: string): Promise<SerializedTask>;
853
+ claimTask(): Promise<SerializedTask | undefined>;
854
+ completeTask(options: {
855
+ taskId: string;
856
+ status: TaskStatus;
857
+ eventBody: JsonObject;
858
+ }): Promise<void>;
859
+ heartbeatTask(taskId: string): Promise<void>;
860
+ listStaleTasks(options: {
861
+ timeoutS: number;
862
+ }): Promise<{
863
+ tasks: {
864
+ taskId: string;
865
+ }[];
866
+ }>;
867
+ list?(options: {
868
+ createdBy?: string;
869
+ }): Promise<{
870
+ tasks: SerializedTask[];
871
+ }>;
872
+ emitLogEvent({ taskId, body }: TaskStoreEmitOptions): Promise<void>;
873
+ listEvents({ taskId, after, }: TaskStoreListEventsOptions): Promise<{
874
+ events: SerializedTaskEvent[];
875
+ }>;
876
+ }
877
+
878
+ /**
879
+ * The options passed to {@link TaskStore.createTask}
880
+ * @public
881
+ */
882
+ export declare type TaskStoreCreateTaskOptions = {
780
883
  spec: TaskSpec;
781
- /**
782
- * The uuid of the current claimed task.
783
- */
784
- taskId: string;
785
- /**
786
- * The secrets that are stored with the task.
787
- */
788
- secrets?: TaskSecrets;
789
- /**
790
- * The creator of the task.
791
- */
792
884
  createdBy?: string;
793
- }
885
+ secrets?: TaskSecrets;
886
+ };
794
887
 
795
888
  /**
796
- * CreateWorkerOptions
889
+ * The response from {@link TaskStore.createTask}
890
+ * @public
891
+ */
892
+ export declare type TaskStoreCreateTaskResult = {
893
+ taskId: string;
894
+ };
895
+
896
+ /**
897
+ * TaskStoreEmitOptions
797
898
  *
798
899
  * @public
799
900
  */
800
- declare type CreateWorkerOptions = {
801
- taskBroker: TaskBroker;
802
- actionRegistry: TemplateActionRegistry;
803
- integrations: ScmIntegrations;
804
- workingDirectory: string;
805
- logger: Logger;
806
- additionalTemplateFilters?: Record<string, TemplateFilter>;
901
+ export declare type TaskStoreEmitOptions<TBody = JsonObject> = {
902
+ taskId: string;
903
+ body: TBody;
904
+ };
905
+
906
+ /**
907
+ * TaskStoreListEventsOptions
908
+ *
909
+ * @public
910
+ */
911
+ export declare type TaskStoreListEventsOptions = {
912
+ taskId: string;
913
+ after?: number | undefined;
807
914
  };
915
+
808
916
  /**
809
917
  * TaskWorker
810
918
  *
811
919
  * @public
812
920
  */
813
- declare class TaskWorker {
921
+ export declare class TaskWorker {
814
922
  private readonly options;
815
923
  private constructor();
816
924
  static create(options: CreateWorkerOptions): Promise<TaskWorker>;
@@ -818,34 +926,30 @@ declare class TaskWorker {
818
926
  runOneTask(task: TaskContext): Promise<void>;
819
927
  }
820
928
 
929
+ /** @public */
930
+ export declare type TemplateAction<Input extends JsonObject> = {
931
+ id: string;
932
+ description?: string;
933
+ supportsDryRun?: boolean;
934
+ schema?: {
935
+ input?: Schema;
936
+ output?: Schema;
937
+ };
938
+ handler: (ctx: ActionContext<Input>) => Promise<void>;
939
+ };
940
+
821
941
  /**
822
- * RouterOptions
823
- *
942
+ * Registry of all registered template actions.
824
943
  * @public
825
944
  */
826
- interface RouterOptions {
827
- logger: Logger;
828
- config: Config;
829
- reader: UrlReader;
830
- database: PluginDatabaseManager;
831
- catalogClient: CatalogApi;
832
- actions?: TemplateAction<any>[];
833
- taskWorkers?: number;
834
- taskBroker?: TaskBroker;
835
- additionalTemplateFilters?: Record<string, TemplateFilter>;
945
+ export declare class TemplateActionRegistry {
946
+ private readonly actions;
947
+ register<TInput extends JsonObject>(action: TemplateAction<TInput>): void;
948
+ get(actionId: string): TemplateAction<JsonObject>;
949
+ list(): TemplateAction<JsonObject>[];
836
950
  }
837
- /**
838
- * A method to create a router for the scaffolder backend plugin.
839
- * @public
840
- */
841
- declare function createRouter(options: RouterOptions): Promise<express.Router>;
842
951
 
843
952
  /** @public */
844
- declare class ScaffolderEntitiesProcessor implements CatalogProcessor {
845
- getProcessorName(): string;
846
- private readonly validators;
847
- validateEntityKind(entity: Entity): Promise<boolean>;
848
- postProcessEntity(entity: Entity, _location: LocationSpec, emit: CatalogProcessorEmit): Promise<Entity>;
849
- }
953
+ export declare type TemplateFilter = (...args: JsonValue[]) => JsonValue | undefined;
850
954
 
851
- export { ActionContext, CreateBuiltInActionsOptions, CreateGithubPullRequestActionOptions, CreateGithubPullRequestClientFactoryInput, CreateWorkerOptions, CurrentClaimedTask, DatabaseTaskStore, DatabaseTaskStoreOptions, OctokitWithPullRequestPluginClient, RouterOptions, RunCommandOptions, ScaffolderEntitiesProcessor, SerializedTask, SerializedTaskEvent, TaskBroker, TaskBrokerDispatchOptions, TaskBrokerDispatchResult, TaskCompletionState, TaskContext, TaskEventType, TaskManager, TaskSecrets, TaskStatus, TaskStore, TaskStoreCreateTaskOptions, TaskStoreCreateTaskResult, TaskStoreEmitOptions, TaskStoreListEventsOptions, TaskWorker, TemplateAction, TemplateActionRegistry, TemplateFilter, createBuiltinActions, createCatalogRegisterAction, createCatalogWriteAction, createDebugLogAction, createFetchPlainAction, createFetchTemplateAction, createFilesystemDeleteAction, createFilesystemRenameAction, createGithubActionsDispatchAction, createGithubIssuesLabelAction, createGithubWebhookAction, createPublishAzureAction, createPublishBitbucketAction, createPublishBitbucketCloudAction, createPublishBitbucketServerAction, createPublishFileAction, createPublishGerritAction, createPublishGithubAction, createPublishGithubPullRequestAction, createPublishGitlabAction, createPublishGitlabMergeRequestAction, createRouter, createTemplateAction, executeShellCommand, fetchContents };
955
+ export { }