@backstage/plugin-scaffolder-backend 0.15.24 → 0.17.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
@@ -3,11 +3,10 @@ import { ScmIntegrations, ScmIntegrationRegistry, GithubCredentialsProvider } fr
3
3
  import { CatalogApi } from '@backstage/catalog-client';
4
4
  import { Logger } from 'winston';
5
5
  import { Writable } from 'stream';
6
- import * as _backstage_types from '@backstage/types';
7
- import { JsonValue, JsonObject } from '@backstage/types';
6
+ import { JsonValue, JsonObject, Observable } from '@backstage/types';
8
7
  import { Schema } from 'jsonschema';
9
- import { TaskSpec, TemplateMetadata } from '@backstage/plugin-scaffolder-common';
10
- export { TaskSpec, TaskSpecV1beta2, TaskSpecV1beta3, TemplateMetadata } from '@backstage/plugin-scaffolder-common';
8
+ import { TaskSpec, TemplateMetadata, TemplateInfo } from '@backstage/plugin-scaffolder-common';
9
+ import { Entity } from '@backstage/catalog-model';
11
10
  import { UrlReader, ContainerRunner, PluginDatabaseManager } from '@backstage/backend-common';
12
11
  import { Config } from '@backstage/config';
13
12
  import { createPullRequest } from 'octokit-plugin-create-pull-request';
@@ -16,191 +15,53 @@ export { createFetchCookiecutterAction } from '@backstage/plugin-scaffolder-back
16
15
  import { SpawnOptionsWithoutStdio } from 'child_process';
17
16
  import { Knex } from 'knex';
18
17
  import express from 'express';
19
- import { TemplateEntityV1beta2, Entity, LocationSpec } from '@backstage/catalog-model';
20
- import { CatalogProcessor, CatalogProcessorEmit } from '@backstage/plugin-catalog-backend';
18
+ import { CatalogProcessor, LocationSpec, CatalogProcessorEmit } from '@backstage/plugin-catalog-backend';
21
19
 
22
20
  declare function createCatalogRegisterAction(options: {
23
21
  catalogClient: CatalogApi;
24
22
  integrations: ScmIntegrations;
25
- }): TemplateAction<any>;
26
-
27
- declare function createCatalogWriteAction(): TemplateAction<any>;
23
+ }): TemplateAction<{
24
+ catalogInfoUrl: string;
25
+ optional?: boolean | undefined;
26
+ } | {
27
+ repoContentsUrl: string;
28
+ catalogInfoPath?: string | undefined;
29
+ optional?: boolean | undefined;
30
+ }>;
28
31
 
29
- /**
30
- * A catalog client tailored for reading out entity data from the catalog.
31
- */
32
- declare class CatalogEntityClient {
33
- private readonly catalogClient;
34
- constructor(catalogClient: CatalogApi);
35
- /**
36
- * Looks up a single template using a template name.
37
- *
38
- * Throws a NotFoundError or ConflictError if 0 or multiple templates are found.
39
- */
40
- findTemplate(templateName: string, options?: {
41
- token?: string;
42
- }): Promise<TemplateEntityV1beta2>;
43
- }
32
+ declare function createCatalogWriteAction(): TemplateAction<{
33
+ filePath?: string | undefined;
34
+ entity: Entity;
35
+ }>;
44
36
 
45
37
  declare type TemplateFilter = (...args: JsonValue[]) => JsonValue | undefined;
46
38
 
47
- declare const createBuiltinActions: (options: {
48
- reader: UrlReader;
49
- integrations: ScmIntegrations;
50
- catalogClient: CatalogApi;
51
- containerRunner?: ContainerRunner;
52
- config: Config;
53
- additionalTemplateFilters?: Record<string, TemplateFilter>;
54
- }) => TemplateAction<any>[];
55
-
56
- /**
57
- * This task is useful for local development and testing of both the scaffolder
58
- * and scaffolder templates.
59
- */
60
- declare function createDebugLogAction(): TemplateAction<any>;
61
-
62
- declare function createFetchPlainAction(options: {
63
- reader: UrlReader;
64
- integrations: ScmIntegrations;
65
- }): TemplateAction<any>;
66
-
67
- declare function createFetchTemplateAction(options: {
68
- reader: UrlReader;
69
- integrations: ScmIntegrations;
70
- additionalTemplateFilters?: Record<string, TemplateFilter>;
71
- }): TemplateAction<any>;
72
-
73
- declare function fetchContents({ reader, integrations, baseUrl, fetchUrl, outputPath, }: {
74
- reader: UrlReader;
75
- integrations: ScmIntegrations;
76
- baseUrl?: string;
77
- fetchUrl?: JsonValue;
78
- outputPath: string;
79
- }): Promise<void>;
80
-
81
- declare const createFilesystemDeleteAction: () => TemplateAction<any>;
82
-
83
- declare const createFilesystemRenameAction: () => TemplateAction<any>;
84
-
85
- declare function createPublishAzureAction(options: {
86
- integrations: ScmIntegrationRegistry;
87
- config: Config;
88
- }): TemplateAction<any>;
89
-
90
- declare function createPublishBitbucketAction(options: {
91
- integrations: ScmIntegrationRegistry;
92
- config: Config;
93
- }): TemplateAction<any>;
94
-
95
39
  /**
96
- * This task is useful for local development and testing of both the scaffolder
97
- * and scaffolder templates.
40
+ * The status of each step of the Task
98
41
  *
99
- * This action is not installed by default and should not be installed in
100
- * production, as it writes the files to the local filesystem of the scaffolder.
101
- */
102
- declare function createPublishFileAction(): TemplateAction<any>;
103
-
104
- declare function createPublishGithubAction(options: {
105
- integrations: ScmIntegrationRegistry;
106
- config: Config;
107
- githubCredentialsProvider?: GithubCredentialsProvider;
108
- }): TemplateAction<any>;
109
-
110
- declare type CreatePullRequestResponse = {
111
- data: {
112
- html_url: string;
113
- };
114
- };
115
- interface PullRequestCreator {
116
- createPullRequest(options: createPullRequest.Options): Promise<CreatePullRequestResponse | null>;
117
- }
118
- declare type ClientFactoryInput = {
119
- integrations: ScmIntegrationRegistry;
120
- githubCredentialsProvider?: GithubCredentialsProvider;
121
- host: string;
122
- owner: string;
123
- repo: string;
124
- token?: string;
125
- };
126
- interface CreateGithubPullRequestActionOptions {
127
- integrations: ScmIntegrationRegistry;
128
- githubCredentialsProvider?: GithubCredentialsProvider;
129
- clientFactory?: (input: ClientFactoryInput) => Promise<PullRequestCreator>;
130
- }
131
- declare const createPublishGithubPullRequestAction: ({ integrations, githubCredentialsProvider, clientFactory, }: CreateGithubPullRequestActionOptions) => TemplateAction<any>;
132
-
133
- declare function createPublishGitlabAction(options: {
134
- integrations: ScmIntegrationRegistry;
135
- config: Config;
136
- }): TemplateAction<any>;
137
-
138
- declare const createPublishGitlabMergeRequestAction: (options: {
139
- integrations: ScmIntegrationRegistry;
140
- }) => TemplateAction<any>;
141
-
142
- declare function createGithubActionsDispatchAction(options: {
143
- integrations: ScmIntegrations;
144
- githubCredentialsProvider?: GithubCredentialsProvider;
145
- }): TemplateAction<any>;
146
-
147
- declare function createGithubWebhookAction(options: {
148
- integrations: ScmIntegrationRegistry;
149
- defaultWebhookSecret?: string;
150
- githubCredentialsProvider?: GithubCredentialsProvider;
151
- }): TemplateAction<any>;
152
-
153
- declare type OctokitIntegration = {
154
- client: Octokit;
155
- token: string;
156
- owner: string;
157
- repo: string;
158
- };
159
- /**
160
- * OctokitProvider provides Octokit client based on ScmIntegrationsRegistry configuration.
161
- * OctokitProvider supports GitHub credentials caching out of the box.
42
+ * @public
162
43
  */
163
- declare class OctokitProvider {
164
- private readonly integrations;
165
- private readonly githubCredentialsProvider;
166
- constructor(integrations: ScmIntegrationRegistry, githubCredentialsProvider?: GithubCredentialsProvider);
167
- /**
168
- * gets standard Octokit client based on repository URL.
169
- *
170
- * @param repoUrl - Repository URL
171
- */
172
- getOctokit(repoUrl: string, options?: {
173
- token?: string;
174
- }): Promise<OctokitIntegration>;
175
- }
176
-
177
- declare type RunCommandOptions = {
178
- /** command to run */
179
- command: string;
180
- /** arguments to pass the command */
181
- args: string[];
182
- /** options to pass to spawn */
183
- options?: SpawnOptionsWithoutStdio;
184
- /** stream to capture stdout and stderr output */
185
- logStream?: Writable;
186
- };
44
+ declare type TaskStatus = 'open' | 'processing' | 'failed' | 'cancelled' | 'completed';
187
45
  /**
188
- * Run a command in a sub-process, normally a shell command.
46
+ * The status of each step of the Task
47
+ *
48
+ * @public
49
+ * @deprecated use TaskStatus instead
189
50
  */
190
- declare const runCommand: ({ command, args, logStream, options, }: RunCommandOptions) => Promise<void>;
191
-
51
+ declare type Status = TaskStatus;
192
52
  /**
193
- * Status
53
+ * The state of a completed task.
194
54
  *
195
55
  * @public
196
56
  */
197
- declare type Status = 'open' | 'processing' | 'failed' | 'cancelled' | 'completed';
57
+ declare type TaskCompletionState = 'failed' | 'completed';
198
58
  /**
199
- * CompletedTaskState
59
+ * The state of a completed task.
200
60
  *
201
61
  * @public
62
+ * @deprecated use TaskCompletionState instead
202
63
  */
203
- declare type CompletedTaskState = 'failed' | 'completed';
64
+ declare type CompletedTaskState = TaskCompletionState;
204
65
  /**
205
66
  * SerializedTask
206
67
  *
@@ -209,7 +70,7 @@ declare type CompletedTaskState = 'failed' | 'completed';
209
70
  declare type SerializedTask = {
210
71
  id: string;
211
72
  spec: TaskSpec;
212
- status: Status;
73
+ status: TaskStatus;
213
74
  createdAt: string;
214
75
  lastHeartbeatAt?: string;
215
76
  secrets?: TaskSecrets;
@@ -238,18 +99,33 @@ declare type SerializedTaskEvent = {
238
99
  * @public
239
100
  */
240
101
  declare type TaskSecrets = Record<string, string> & {
241
- /** @deprecated Use `backstageToken` instead */
242
- token?: string;
243
102
  backstageToken?: string;
244
103
  };
245
104
  /**
246
- * DispatchResult
105
+ * The result of {@link TaskBroker.dispatch}
247
106
  *
248
107
  * @public
249
108
  */
250
- declare type DispatchResult = {
109
+ declare type TaskBrokerDispatchResult = {
251
110
  taskId: string;
252
111
  };
112
+ /**
113
+ * The options passed to {@link TaskBroker.dispatch}
114
+ * Currently a spec and optional secrets
115
+ *
116
+ * @public
117
+ */
118
+ declare type TaskBrokerDispatchOptions = {
119
+ spec: TaskSpec;
120
+ secrets?: TaskSecrets;
121
+ };
122
+ /**
123
+ * DispatchResult
124
+ *
125
+ * @public
126
+ * @deprecated use TaskBrokerDispatchResult instead
127
+ */
128
+ declare type DispatchResult = TaskBrokerDispatchResult;
253
129
  /**
254
130
  * Task
255
131
  *
@@ -259,8 +135,8 @@ interface TaskContext {
259
135
  spec: TaskSpec;
260
136
  secrets?: TaskSecrets;
261
137
  done: boolean;
262
- emitLog(message: string, metadata?: JsonValue): Promise<void>;
263
- complete(result: CompletedTaskState, metadata?: JsonValue): Promise<void>;
138
+ emitLog(message: string, logMetadata?: JsonObject): Promise<void>;
139
+ complete(result: TaskCompletionState, metadata?: JsonObject): Promise<void>;
264
140
  getWorkspaceName(): Promise<string>;
265
141
  }
266
142
  /**
@@ -270,18 +146,16 @@ interface TaskContext {
270
146
  */
271
147
  interface TaskBroker {
272
148
  claim(): Promise<TaskContext>;
273
- dispatch(spec: TaskSpec, secrets?: TaskSecrets): Promise<DispatchResult>;
274
- vacuumTasks(timeoutS: {
149
+ dispatch(options: TaskBrokerDispatchOptions): Promise<TaskBrokerDispatchResult>;
150
+ vacuumTasks(options: {
275
151
  timeoutS: number;
276
152
  }): Promise<void>;
277
- observe(options: {
153
+ event$(options: {
278
154
  taskId: string;
279
155
  after: number | undefined;
280
- }, callback: (error: Error | undefined, result: {
156
+ }): Observable<{
281
157
  events: SerializedTaskEvent[];
282
- }) => void): {
283
- unsubscribe: () => void;
284
- };
158
+ }>;
285
159
  get(taskId: string): Promise<SerializedTask>;
286
160
  }
287
161
  /**
@@ -289,9 +163,9 @@ interface TaskBroker {
289
163
  *
290
164
  * @public
291
165
  */
292
- declare type TaskStoreEmitOptions = {
166
+ declare type TaskStoreEmitOptions<TBody = JsonObject> = {
293
167
  taskId: string;
294
- body: JsonObject;
168
+ body: TBody;
295
169
  };
296
170
  /**
297
171
  * TaskStoreListEventsOptions
@@ -302,20 +176,33 @@ declare type TaskStoreListEventsOptions = {
302
176
  taskId: string;
303
177
  after?: number | undefined;
304
178
  };
179
+ /**
180
+ * The options passed to {@link TaskStore.createTask}
181
+ * @public
182
+ */
183
+ declare type TaskStoreCreateTaskOptions = {
184
+ spec: TaskSpec;
185
+ secrets?: TaskSecrets;
186
+ };
187
+ /**
188
+ * The response from {@link TaskStore.createTask}
189
+ * @public
190
+ */
191
+ declare type TaskStoreCreateTaskResult = {
192
+ taskId: string;
193
+ };
305
194
  /**
306
195
  * TaskStore
307
196
  *
308
197
  * @public
309
198
  */
310
199
  interface TaskStore {
311
- createTask(task: TaskSpec, secrets?: TaskSecrets): Promise<{
312
- taskId: string;
313
- }>;
200
+ createTask(options: TaskStoreCreateTaskOptions): Promise<TaskStoreCreateTaskResult>;
314
201
  getTask(taskId: string): Promise<SerializedTask>;
315
202
  claimTask(): Promise<SerializedTask | undefined>;
316
203
  completeTask(options: {
317
204
  taskId: string;
318
- status: Status;
205
+ status: TaskStatus;
319
206
  eventBody: JsonObject;
320
207
  }): Promise<void>;
321
208
  heartbeatTask(taskId: string): Promise<void>;
@@ -332,23 +219,14 @@ interface TaskStore {
332
219
  }>;
333
220
  }
334
221
 
335
- declare type PartialJsonObject = Partial<JsonObject>;
336
- declare type PartialJsonValue = PartialJsonObject | JsonValue | undefined;
337
- declare type InputBase = Partial<{
338
- [name: string]: PartialJsonValue;
339
- }>;
340
- declare type ActionContext<Input extends InputBase> = {
222
+ declare type ActionContext<Input extends JsonObject> = {
341
223
  /**
342
224
  * Base URL for the location of the task spec, typically the url of the source entity file.
225
+ * @deprecated please use templateInfo.baseUrl instead
343
226
  */
344
227
  baseUrl?: string;
345
228
  logger: Logger;
346
229
  logStream: Writable;
347
- /**
348
- * User token forwarded from initial request, for use in subsequent api requests
349
- * @deprecated use `secrets.backstageToken` instead
350
- */
351
- token?: string | undefined;
352
230
  secrets?: TaskSecrets;
353
231
  workspacePath: string;
354
232
  input: Input;
@@ -357,9 +235,13 @@ declare type ActionContext<Input extends InputBase> = {
357
235
  * Creates a temporary directory for use by the action, which is then cleaned up automatically.
358
236
  */
359
237
  createTemporaryDirectory(): Promise<string>;
238
+ /**
239
+ * @deprecated please use templateInfo instead
240
+ */
360
241
  metadata?: TemplateMetadata;
242
+ templateInfo?: TemplateInfo;
361
243
  };
362
- declare type TemplateAction<Input extends InputBase> = {
244
+ declare type TemplateAction<Input extends JsonObject> = {
363
245
  id: string;
364
246
  description?: string;
365
247
  schema?: {
@@ -369,16 +251,282 @@ declare type TemplateAction<Input extends InputBase> = {
369
251
  handler: (ctx: ActionContext<Input>) => Promise<void>;
370
252
  };
371
253
 
254
+ /**
255
+ * The options passed to {@link createBuiltinActions}
256
+ * @public
257
+ */
258
+ interface CreateBuiltInActionsOptions {
259
+ reader: UrlReader;
260
+ integrations: ScmIntegrations;
261
+ catalogClient: CatalogApi;
262
+ /** @deprecated when the cookiecutter action is removed this won't be necessary */
263
+ containerRunner?: ContainerRunner;
264
+ config: Config;
265
+ additionalTemplateFilters?: Record<string, TemplateFilter>;
266
+ }
267
+ /**
268
+ * A function to generate create a list of default actions that the scaffolder provides.
269
+ * Is called internally in the default setup, but can be used when adding your own actions or overriding the default ones
270
+ *
271
+ * @public
272
+ * @returns A list of actions that can be used in the scaffolder
273
+ */
274
+ declare const createBuiltinActions: (options: CreateBuiltInActionsOptions) => TemplateAction<JsonObject>[];
275
+
276
+ /**
277
+ * This task is useful for local development and testing of both the scaffolder
278
+ * and scaffolder templates.
279
+ */
280
+ declare function createDebugLogAction(): TemplateAction<{
281
+ message?: string | undefined;
282
+ listWorkspace?: boolean | undefined;
283
+ }>;
284
+
285
+ declare function createFetchPlainAction(options: {
286
+ reader: UrlReader;
287
+ integrations: ScmIntegrations;
288
+ }): TemplateAction<{
289
+ url: string;
290
+ targetPath?: string | undefined;
291
+ }>;
292
+
293
+ declare function createFetchTemplateAction(options: {
294
+ reader: UrlReader;
295
+ integrations: ScmIntegrations;
296
+ additionalTemplateFilters?: Record<string, TemplateFilter>;
297
+ }): TemplateAction<{
298
+ url: string;
299
+ targetPath?: string | undefined;
300
+ values: any;
301
+ templateFileExtension?: string | boolean | undefined;
302
+ copyWithoutRender?: string[] | undefined;
303
+ cookiecutterCompat?: boolean | undefined;
304
+ }>;
305
+
306
+ /**
307
+ * A helper function that reads the contents of a directory from the given URL.
308
+ * Can be used in your own actions, and also used behind fetch:template and fetch:plain
309
+ *
310
+ * @public
311
+ */
312
+ declare function fetchContents({ reader, integrations, baseUrl, fetchUrl, outputPath, }: {
313
+ reader: UrlReader;
314
+ integrations: ScmIntegrations;
315
+ baseUrl?: string;
316
+ fetchUrl?: string;
317
+ outputPath: string;
318
+ }): Promise<void>;
319
+
320
+ declare const createFilesystemDeleteAction: () => TemplateAction<{
321
+ files: string[];
322
+ }>;
323
+
324
+ declare const createFilesystemRenameAction: () => TemplateAction<{
325
+ files: Array<{
326
+ from: string;
327
+ to: string;
328
+ overwrite?: boolean;
329
+ }>;
330
+ }>;
331
+
332
+ declare function createPublishAzureAction(options: {
333
+ integrations: ScmIntegrationRegistry;
334
+ config: Config;
335
+ }): TemplateAction<{
336
+ repoUrl: string;
337
+ description?: string | undefined;
338
+ defaultBranch?: string | undefined;
339
+ sourcePath?: string | undefined;
340
+ token?: string | undefined;
341
+ }>;
342
+
343
+ declare function createPublishBitbucketAction(options: {
344
+ integrations: ScmIntegrationRegistry;
345
+ config: Config;
346
+ }): TemplateAction<{
347
+ repoUrl: string;
348
+ description?: string | undefined;
349
+ defaultBranch?: string | undefined;
350
+ repoVisibility?: "private" | "public" | undefined;
351
+ sourcePath?: string | undefined;
352
+ enableLFS?: boolean | undefined;
353
+ token?: string | undefined;
354
+ }>;
355
+
356
+ /**
357
+ * This task is useful for local development and testing of both the scaffolder
358
+ * and scaffolder templates.
359
+ *
360
+ * This action is not installed by default and should not be installed in
361
+ * production, as it writes the files to the local filesystem of the scaffolder.
362
+ */
363
+ declare function createPublishFileAction(): TemplateAction<{
364
+ path: string;
365
+ }>;
366
+
367
+ declare function createPublishGithubAction(options: {
368
+ integrations: ScmIntegrationRegistry;
369
+ config: Config;
370
+ githubCredentialsProvider?: GithubCredentialsProvider;
371
+ }): TemplateAction<{
372
+ repoUrl: string;
373
+ description?: string | undefined;
374
+ access?: string | undefined;
375
+ defaultBranch?: string | undefined;
376
+ sourcePath?: string | undefined;
377
+ requireCodeOwnerReviews?: boolean | undefined;
378
+ repoVisibility?: "internal" | "private" | "public" | undefined;
379
+ collaborators?: {
380
+ username: string;
381
+ access: 'pull' | 'push' | 'admin' | 'maintain' | 'triage';
382
+ }[] | undefined;
383
+ token?: string | undefined;
384
+ topics?: string[] | undefined;
385
+ }>;
386
+
387
+ declare type CreatePullRequestResponse = {
388
+ data: {
389
+ html_url: string;
390
+ };
391
+ };
392
+ interface PullRequestCreator {
393
+ createPullRequest(options: createPullRequest.Options): Promise<CreatePullRequestResponse | null>;
394
+ }
395
+ declare type ClientFactoryInput = {
396
+ integrations: ScmIntegrationRegistry;
397
+ githubCredentialsProvider?: GithubCredentialsProvider;
398
+ host: string;
399
+ owner: string;
400
+ repo: string;
401
+ token?: string;
402
+ };
403
+ interface CreateGithubPullRequestActionOptions {
404
+ integrations: ScmIntegrationRegistry;
405
+ githubCredentialsProvider?: GithubCredentialsProvider;
406
+ clientFactory?: (input: ClientFactoryInput) => Promise<PullRequestCreator>;
407
+ }
408
+ declare const createPublishGithubPullRequestAction: ({ integrations, githubCredentialsProvider, clientFactory, }: CreateGithubPullRequestActionOptions) => TemplateAction<{
409
+ title: string;
410
+ branchName: string;
411
+ description: string;
412
+ repoUrl: string;
413
+ targetPath?: string | undefined;
414
+ sourcePath?: string | undefined;
415
+ token?: string | undefined;
416
+ }>;
417
+
418
+ declare function createPublishGitlabAction(options: {
419
+ integrations: ScmIntegrationRegistry;
420
+ config: Config;
421
+ }): TemplateAction<{
422
+ repoUrl: string;
423
+ defaultBranch?: string | undefined;
424
+ repoVisibility?: "internal" | "private" | "public" | undefined;
425
+ sourcePath?: string | undefined;
426
+ token?: string | undefined;
427
+ }>;
428
+
429
+ declare const createPublishGitlabMergeRequestAction: (options: {
430
+ integrations: ScmIntegrationRegistry;
431
+ }) => TemplateAction<{
432
+ projectid: string;
433
+ repoUrl: string;
434
+ title: string;
435
+ description: string;
436
+ branchName: string;
437
+ targetPath: string;
438
+ token?: string | undefined;
439
+ }>;
440
+
441
+ declare function createGithubActionsDispatchAction(options: {
442
+ integrations: ScmIntegrations;
443
+ githubCredentialsProvider?: GithubCredentialsProvider;
444
+ }): TemplateAction<{
445
+ repoUrl: string;
446
+ workflowId: string;
447
+ branchOrTagName: string;
448
+ workflowInputs?: {
449
+ [key: string]: string;
450
+ } | undefined;
451
+ token?: string | undefined;
452
+ }>;
453
+
454
+ declare function createGithubWebhookAction(options: {
455
+ integrations: ScmIntegrationRegistry;
456
+ defaultWebhookSecret?: string;
457
+ githubCredentialsProvider?: GithubCredentialsProvider;
458
+ }): TemplateAction<{
459
+ repoUrl: string;
460
+ webhookUrl: string;
461
+ webhookSecret?: string | undefined;
462
+ events?: string[] | undefined;
463
+ active?: boolean | undefined;
464
+ contentType?: "form" | "json" | undefined;
465
+ insecureSsl?: boolean | undefined;
466
+ token?: string | undefined;
467
+ }>;
468
+
469
+ declare type OctokitIntegration = {
470
+ client: Octokit;
471
+ token: string;
472
+ owner: string;
473
+ repo: string;
474
+ };
475
+ /**
476
+ * OctokitProvider provides Octokit client based on ScmIntegrationsRegistry configuration.
477
+ * OctokitProvider supports GitHub credentials caching out of the box.
478
+ *
479
+ * @deprecated we are no longer providing a way from the scaffolder to generate octokit instances.
480
+ * Implement your own if you're using this method from an external package, or use the internal `getOctokitOptions` function instead
481
+ */
482
+ declare class OctokitProvider {
483
+ private readonly integrations;
484
+ private readonly githubCredentialsProvider;
485
+ constructor(integrations: ScmIntegrationRegistry, githubCredentialsProvider?: GithubCredentialsProvider);
486
+ /**
487
+ * gets standard Octokit client based on repository URL.
488
+ *
489
+ * @param repoUrl - Repository URL
490
+ *
491
+ * @deprecated we are no longer providing a way from the scaffolder to generate octokit instances.
492
+ * Implement your own if you're using this method from an external package, or use the internal `getOctokitOptions` function instead
493
+ */
494
+ getOctokit(repoUrl: string, options?: {
495
+ token?: string;
496
+ }): Promise<OctokitIntegration>;
497
+ }
498
+
499
+ declare type RunCommandOptions = {
500
+ /** command to run */
501
+ command: string;
502
+ /** arguments to pass the command */
503
+ args: string[];
504
+ /** options to pass to spawn */
505
+ options?: SpawnOptionsWithoutStdio;
506
+ /** stream to capture stdout and stderr output */
507
+ logStream?: Writable;
508
+ };
509
+ /**
510
+ * Run a command in a sub-process, normally a shell command.
511
+ *
512
+ * @public
513
+ */
514
+ declare const executeShellCommand: (options: RunCommandOptions) => Promise<void>;
515
+ /**
516
+ * Run a command in a sub-process, normally a shell command.
517
+ * @public
518
+ * @deprecated use {@link executeShellCommand} instead
519
+ */
520
+ declare const runCommand: (options: RunCommandOptions) => Promise<void>;
521
+
372
522
  declare class TemplateActionRegistry {
373
523
  private readonly actions;
374
- register<Parameters extends InputBase>(action: TemplateAction<Parameters>): void;
375
- get(actionId: string): TemplateAction<any>;
376
- list(): TemplateAction<any>[];
524
+ register<TInput extends JsonObject>(action: TemplateAction<TInput>): void;
525
+ get(actionId: string): TemplateAction<JsonObject>;
526
+ list(): TemplateAction<JsonObject>[];
377
527
  }
378
528
 
379
- declare const createTemplateAction: <Input extends Partial<{
380
- [name: string]: _backstage_types.JsonValue | Partial<_backstage_types.JsonObject> | undefined;
381
- }>>(templateAction: TemplateAction<Input>) => TemplateAction<any>;
529
+ declare const createTemplateAction: <TInput extends JsonObject>(templateAction: TemplateAction<TInput>) => TemplateAction<TInput>;
382
530
 
383
531
  /**
384
532
  * DatabaseTaskStore
@@ -396,11 +544,9 @@ declare type DatabaseTaskStoreOptions = {
396
544
  declare class DatabaseTaskStore implements TaskStore {
397
545
  private readonly db;
398
546
  static create(options: DatabaseTaskStoreOptions): Promise<DatabaseTaskStore>;
399
- constructor(options: DatabaseTaskStoreOptions);
547
+ private constructor();
400
548
  getTask(taskId: string): Promise<SerializedTask>;
401
- createTask(spec: TaskSpec, secrets?: TaskSecrets): Promise<{
402
- taskId: string;
403
- }>;
549
+ createTask(options: TaskStoreCreateTaskOptions): Promise<TaskStoreCreateTaskResult>;
404
550
  claimTask(): Promise<SerializedTask | undefined>;
405
551
  heartbeatTask(taskId: string): Promise<void>;
406
552
  listStaleTasks({ timeoutS }: {
@@ -412,10 +558,12 @@ declare class DatabaseTaskStore implements TaskStore {
412
558
  }>;
413
559
  completeTask({ taskId, status, eventBody, }: {
414
560
  taskId: string;
415
- status: Status;
561
+ status: TaskStatus;
416
562
  eventBody: JsonObject;
417
563
  }): Promise<void>;
418
- emitLogEvent({ taskId, body }: TaskStoreEmitOptions): Promise<void>;
564
+ emitLogEvent(options: TaskStoreEmitOptions<{
565
+ message: string;
566
+ } & JsonObject>): Promise<void>;
419
567
  listEvents({ taskId, after, }: TaskStoreListEventsOptions): Promise<{
420
568
  events: SerializedTaskEvent[];
421
569
  }>;
@@ -427,31 +575,38 @@ declare class DatabaseTaskStore implements TaskStore {
427
575
  * @public
428
576
  */
429
577
  declare class TaskManager implements TaskContext {
430
- private readonly state;
578
+ private readonly task;
431
579
  private readonly storage;
432
580
  private readonly logger;
433
581
  private isDone;
434
582
  private heartbeatTimeoutId?;
435
- static create(state: TaskState, storage: TaskStore, logger: Logger): TaskManager;
583
+ static create(task: CurrentClaimedTask, storage: TaskStore, logger: Logger): TaskManager;
436
584
  private constructor();
437
585
  get spec(): TaskSpec;
438
586
  get secrets(): TaskSecrets | undefined;
439
587
  getWorkspaceName(): Promise<string>;
440
588
  get done(): boolean;
441
- emitLog(message: string, metadata?: JsonObject): Promise<void>;
442
- complete(result: CompletedTaskState, metadata?: JsonObject): Promise<void>;
589
+ emitLog(message: string, logMetadata?: JsonObject): Promise<void>;
590
+ complete(result: TaskCompletionState, metadata?: JsonObject): Promise<void>;
443
591
  private startTimeout;
444
592
  }
445
593
  /**
446
- * TaskState
594
+ * Stores the state of the current claimed task passed to the TaskContext
447
595
  *
448
596
  * @public
449
597
  */
450
- interface TaskState {
598
+ interface CurrentClaimedTask {
451
599
  spec: TaskSpec;
452
600
  taskId: string;
453
601
  secrets?: TaskSecrets;
454
602
  }
603
+ /**
604
+ * TaskState
605
+ *
606
+ * @public
607
+ * @deprecated use CurrentClaimedTask instead
608
+ */
609
+ declare type TaskState = CurrentClaimedTask;
455
610
 
456
611
  /**
457
612
  * CreateWorkerOptions
@@ -500,9 +655,10 @@ declare function createRouter(options: RouterOptions): Promise<express.Router>;
500
655
 
501
656
  /** @public */
502
657
  declare class ScaffolderEntitiesProcessor implements CatalogProcessor {
658
+ getProcessorName(): string;
503
659
  private readonly validators;
504
660
  validateEntityKind(entity: Entity): Promise<boolean>;
505
661
  postProcessEntity(entity: Entity, _location: LocationSpec, emit: CatalogProcessorEmit): Promise<Entity>;
506
662
  }
507
663
 
508
- export { ActionContext, CatalogEntityClient, CompletedTaskState, CreateWorkerOptions, DatabaseTaskStore, DispatchResult, OctokitProvider, RouterOptions, ScaffolderEntitiesProcessor, SerializedTask, SerializedTaskEvent, Status, TaskBroker, TaskContext, TaskEventType, TaskManager, TaskSecrets, TaskState, TaskStore, TaskStoreEmitOptions, TaskStoreListEventsOptions, TaskWorker, TemplateAction, TemplateActionRegistry, TemplateFilter, createBuiltinActions, createCatalogRegisterAction, createCatalogWriteAction, createDebugLogAction, createFetchPlainAction, createFetchTemplateAction, createFilesystemDeleteAction, createFilesystemRenameAction, createGithubActionsDispatchAction, createGithubWebhookAction, createPublishAzureAction, createPublishBitbucketAction, createPublishFileAction, createPublishGithubAction, createPublishGithubPullRequestAction, createPublishGitlabAction, createPublishGitlabMergeRequestAction, createRouter, createTemplateAction, fetchContents, runCommand };
664
+ export { ActionContext, CompletedTaskState, CreateBuiltInActionsOptions, CreateWorkerOptions, CurrentClaimedTask, DatabaseTaskStore, DispatchResult, OctokitProvider, RouterOptions, ScaffolderEntitiesProcessor, SerializedTask, SerializedTaskEvent, Status, TaskBroker, TaskBrokerDispatchOptions, TaskBrokerDispatchResult, TaskCompletionState, TaskContext, TaskEventType, TaskManager, TaskSecrets, TaskState, TaskStatus, TaskStore, TaskStoreCreateTaskOptions, TaskStoreCreateTaskResult, TaskStoreEmitOptions, TaskStoreListEventsOptions, TaskWorker, TemplateAction, TemplateActionRegistry, TemplateFilter, createBuiltinActions, createCatalogRegisterAction, createCatalogWriteAction, createDebugLogAction, createFetchPlainAction, createFetchTemplateAction, createFilesystemDeleteAction, createFilesystemRenameAction, createGithubActionsDispatchAction, createGithubWebhookAction, createPublishAzureAction, createPublishBitbucketAction, createPublishFileAction, createPublishGithubAction, createPublishGithubPullRequestAction, createPublishGitlabAction, createPublishGitlabMergeRequestAction, createRouter, createTemplateAction, executeShellCommand, fetchContents, runCommand };