@backstage/plugin-scaffolder-backend 1.4.0-next.1 → 1.4.0

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