@backstage/plugin-scaffolder-backend 1.4.0-next.2 → 1.5.0-next.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.
@@ -0,0 +1,980 @@
1
+ /**
2
+ * The Backstage backend plugin that helps you create new things
3
+ *
4
+ * @packageDocumentation
5
+ */
6
+
7
+ /// <reference types="node" />
8
+
9
+ import { BackendRegistrable } from '@backstage/backend-plugin-api';
10
+ import { CatalogApi } from '@backstage/catalog-client';
11
+ import { CatalogProcessor } from '@backstage/plugin-catalog-backend';
12
+ import { CatalogProcessorEmit } from '@backstage/plugin-catalog-backend';
13
+ import { Config } from '@backstage/config';
14
+ import { createPullRequest } from 'octokit-plugin-create-pull-request';
15
+ import { Entity } from '@backstage/catalog-model';
16
+ import express from 'express';
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';
34
+
35
+ /**
36
+ * ActionContext is passed into scaffolder actions.
37
+ * @public
38
+ */
39
+ export declare type ActionContext<Input extends JsonObject> = {
40
+ logger: Logger;
41
+ logStream: Writable;
42
+ secrets?: TaskSecrets;
43
+ workspacePath: string;
44
+ input: Input;
45
+ output(name: string, value: JsonValue): void;
46
+ /**
47
+ * Creates a temporary directory for use by the action, which is then cleaned up automatically.
48
+ */
49
+ createTemporaryDirectory(): Promise<string>;
50
+ templateInfo?: TemplateInfo;
51
+ /**
52
+ * Whether this action invocation is a dry-run or not.
53
+ * This will only ever be true if the actions as marked as supporting dry-runs.
54
+ */
55
+ isDryRun?: boolean;
56
+ };
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>[];
66
+
67
+ /**
68
+ * The options passed to {@link createBuiltinActions}
69
+ * @public
70
+ */
71
+ export declare interface CreateBuiltInActionsOptions {
72
+ /**
73
+ * The {@link @backstage/backend-common#UrlReader} interface that will be used in the default actions.
74
+ */
75
+ reader: UrlReader;
76
+ /**
77
+ * The {@link @backstage/integrations#ScmIntegrations} that will be used in the default actions.
78
+ */
79
+ integrations: ScmIntegrations;
80
+ /**
81
+ * The {@link @backstage/catalog-client#CatalogApi} that will be used in the default actions.
82
+ */
83
+ catalogClient: CatalogApi;
84
+ /**
85
+ * The {@link @backstage/config#Config} that will be used in the default actions.
86
+ */
87
+ config: Config;
88
+ /**
89
+ * Additional custom filters that will be passed to the nunjucks template engine for use in
90
+ * Template Manifests and also template skeleton files when using `fetch:template`.
91
+ */
92
+ additionalTemplateFilters?: Record<string, TemplateFilter>;
93
+ }
94
+
95
+ /**
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.
113
+ * @public
114
+ */
115
+ export declare function createCatalogWriteAction(): TemplateAction< {
116
+ filePath?: string | undefined;
117
+ entity: Entity;
118
+ }>;
119
+
120
+ /**
121
+ * Writes a message into the log or lists all files in the workspace
122
+ *
123
+ * @remarks
124
+ *
125
+ * This task is useful for local development and testing of both the scaffolder
126
+ * and scaffolder templates.
127
+ *
128
+ * @public
129
+ */
130
+ export declare function createDebugLogAction(): TemplateAction< {
131
+ message?: string | undefined;
132
+ listWorkspace?: boolean | undefined;
133
+ }>;
134
+
135
+ /**
136
+ * Downloads content and places it in the workspace, or optionally
137
+ * in a subdirectory specified by the 'targetPath' input option.
138
+ * @public
139
+ */
140
+ export declare function createFetchPlainAction(options: {
141
+ reader: UrlReader;
142
+ integrations: ScmIntegrations;
143
+ }): TemplateAction< {
144
+ url: string;
145
+ targetPath?: string | undefined;
146
+ }>;
147
+
148
+ /**
149
+ * Downloads a skeleton, templates variables into file and directory names and content.
150
+ * Then places the result in the workspace, or optionally in a subdirectory
151
+ * specified by the 'targetPath' input option.
152
+ *
153
+ * @public
154
+ */
155
+ export declare function createFetchTemplateAction(options: {
156
+ reader: UrlReader;
157
+ integrations: ScmIntegrations;
158
+ additionalTemplateFilters?: Record<string, TemplateFilter>;
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;
170
+ }>;
171
+
172
+ /**
173
+ * Creates new action that enables deletion of files and directories in the workspace.
174
+ * @public
175
+ */
176
+ export declare const createFilesystemDeleteAction: () => TemplateAction< {
177
+ files: string[];
178
+ }>;
179
+
180
+ /**
181
+ * Creates a new action that allows renames of files and directories in the workspace.
182
+ * @public
183
+ */
184
+ export declare const createFilesystemRenameAction: () => TemplateAction< {
185
+ files: Array<{
186
+ from: string;
187
+ to: string;
188
+ overwrite?: boolean;
189
+ }>;
190
+ }>;
191
+
192
+ /**
193
+ * Creates a new action that dispatches a GitHub Action workflow for a given branch or tag.
194
+ * @public
195
+ */
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;
207
+ }>;
208
+
209
+ /**
210
+ * Adds labels to a pull request or issue on GitHub
211
+ * @public
212
+ */
213
+ export declare function createGithubIssuesLabelAction(options: {
214
+ integrations: ScmIntegrationRegistry;
215
+ githubCredentialsProvider?: GithubCredentialsProvider;
216
+ }): TemplateAction< {
217
+ repoUrl: string;
218
+ number: number;
219
+ labels: string[];
220
+ token?: string | undefined;
221
+ }>;
222
+
223
+ /**
224
+ * The options passed to {@link createPublishGithubPullRequestAction} method
225
+ * @public
226
+ */
227
+ export declare interface CreateGithubPullRequestActionOptions {
228
+ /**
229
+ * An instance of {@link @backstage/integration#ScmIntegrationRegistry} that will be used in the action.
230
+ */
231
+ integrations: ScmIntegrationRegistry;
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;
289
+ }>;
290
+
291
+ /**
292
+ * Creates a new action that initializes a git repository of the content in the workspace
293
+ * and publishes it to GitHub.
294
+ *
295
+ * @public
296
+ */
297
+ export declare function createGithubRepoPushAction(options: {
298
+ integrations: ScmIntegrationRegistry;
299
+ config: Config;
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;
314
+ }>;
315
+
316
+ /**
317
+ * Creates new action that creates a webhook for a repository on GitHub.
318
+ * @public
319
+ */
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;
333
+ }>;
334
+
335
+ /**
336
+ * Creates a new action that initializes a git repository of the content in the workspace
337
+ * and publishes it to Azure.
338
+ * @public
339
+ */
340
+ export declare function createPublishAzureAction(options: {
341
+ integrations: ScmIntegrationRegistry;
342
+ config: Config;
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;
352
+ }>;
353
+
354
+ /**
355
+ * Creates a new action that initializes a git repository of the content in the workspace
356
+ * and publishes it to Bitbucket.
357
+ * @public
358
+ * @deprecated in favor of createPublishBitbucketCloudAction and createPublishBitbucketServerAction
359
+ */
360
+ export declare function createPublishBitbucketAction(options: {
361
+ integrations: ScmIntegrationRegistry;
362
+ config: Config;
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;
374
+ }>;
375
+
376
+ /**
377
+ * Creates a new action that initializes a git repository of the content in the workspace
378
+ * and publishes it to Bitbucket Cloud.
379
+ * @public
380
+ */
381
+ export declare function createPublishBitbucketCloudAction(options: {
382
+ integrations: ScmIntegrationRegistry;
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
+
393
+ /**
394
+ * Creates a new action that initializes a git repository of the content in the workspace
395
+ * and publishes it to Bitbucket Server.
396
+ * @public
397
+ */
398
+ export declare function createPublishBitbucketServerAction(options: {
399
+ integrations: ScmIntegrationRegistry;
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
+
411
+ /**
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
+ *
420
+ * @public
421
+ */
422
+ export declare function createPublishFileAction(): TemplateAction< {
423
+ path: string;
424
+ }>;
425
+
426
+ /**
427
+ * Creates a new action that initializes a git repository of the content in the workspace
428
+ * and publishes it to a Gerrit instance.
429
+ * @public
430
+ */
431
+ export declare function createPublishGerritAction(options: {
432
+ integrations: ScmIntegrationRegistry;
433
+ config: Config;
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;
442
+ }>;
443
+
444
+ /**
445
+ * Creates a new action that creates a Gerrit review
446
+ * @public
447
+ */
448
+ export declare function createPublishGerritReviewAction(options: {
449
+ integrations: ScmIntegrationRegistry;
450
+ config: Config;
451
+ }): TemplateAction< {
452
+ repoUrl: string;
453
+ branch?: string | undefined;
454
+ sourcePath?: string | undefined;
455
+ gitCommitMessage?: string | undefined;
456
+ gitAuthorName?: string | undefined;
457
+ gitAuthorEmail?: string | undefined;
458
+ }>;
459
+
460
+ /**
461
+ * Creates a new action that initializes a git repository of the content in the workspace
462
+ * and publishes it to GitHub.
463
+ *
464
+ * @public
465
+ */
466
+ export declare function createPublishGithubAction(options: {
467
+ integrations: ScmIntegrationRegistry;
468
+ config: Config;
469
+ githubCredentialsProvider?: GithubCredentialsProvider;
470
+ }): TemplateAction< {
471
+ repoUrl: string;
472
+ description?: string | undefined;
473
+ access?: string | undefined;
474
+ defaultBranch?: string | undefined;
475
+ protectDefaultBranch?: boolean | undefined;
476
+ protectEnforceAdmins?: boolean | undefined;
477
+ deleteBranchOnMerge?: boolean | undefined;
478
+ gitCommitMessage?: string | undefined;
479
+ gitAuthorName?: string | undefined;
480
+ gitAuthorEmail?: string | undefined;
481
+ allowRebaseMerge?: boolean | undefined;
482
+ allowSquashMerge?: boolean | undefined;
483
+ allowMergeCommit?: boolean | undefined;
484
+ sourcePath?: string | undefined;
485
+ requireCodeOwnerReviews?: boolean | undefined;
486
+ requiredStatusCheckContexts?: string[] | undefined;
487
+ repoVisibility?: "internal" | "private" | "public" | undefined;
488
+ collaborators?: ({
489
+ user: string;
490
+ access: 'pull' | 'push' | 'admin' | 'maintain' | 'triage';
491
+ } | {
492
+ team: string;
493
+ access: 'pull' | 'push' | 'admin' | 'maintain' | 'triage';
494
+ } | {
495
+ /** @deprecated This field is deprecated in favor of team */
496
+ username: string;
497
+ access: 'pull' | 'push' | 'admin' | 'maintain' | 'triage';
498
+ })[] | undefined;
499
+ token?: string | undefined;
500
+ topics?: string[] | undefined;
501
+ }>;
502
+
503
+ /**
504
+ * Creates a Github Pull Request action.
505
+ * @public
506
+ */
507
+ export declare const createPublishGithubPullRequestAction: ({ integrations, githubCredentialsProvider, clientFactory, }: CreateGithubPullRequestActionOptions) => TemplateAction< {
508
+ title: string;
509
+ branchName: string;
510
+ description: string;
511
+ repoUrl: string;
512
+ draft?: boolean | undefined;
513
+ targetPath?: string | undefined;
514
+ sourcePath?: string | undefined;
515
+ token?: string | undefined;
516
+ }>;
517
+
518
+ /**
519
+ * Creates a new action that initializes a git repository of the content in the workspace
520
+ * and publishes it to GitLab.
521
+ *
522
+ * @public
523
+ */
524
+ export declare function createPublishGitlabAction(options: {
525
+ integrations: ScmIntegrationRegistry;
526
+ config: Config;
527
+ }): TemplateAction< {
528
+ repoUrl: string;
529
+ defaultBranch?: string | undefined;
530
+ repoVisibility?: "internal" | "private" | "public" | undefined;
531
+ sourcePath?: string | undefined;
532
+ token?: string | undefined;
533
+ gitCommitMessage?: string | undefined;
534
+ gitAuthorName?: string | undefined;
535
+ gitAuthorEmail?: string | undefined;
536
+ setUserAsOwner?: boolean | undefined;
537
+ }>;
538
+
539
+ /**
540
+ * Create a new action that creates a gitlab merge request.
541
+ *
542
+ * @public
543
+ */
544
+ export declare const createPublishGitlabMergeRequestAction: (options: {
545
+ integrations: ScmIntegrationRegistry;
546
+ }) => TemplateAction< {
547
+ repoUrl: string;
548
+ title: string;
549
+ description: string;
550
+ branchName: string;
551
+ targetPath: string;
552
+ token?: string | undefined;
553
+ commitAction?: "update" | "create" | "delete" | undefined;
554
+ /** @deprecated Use projectPath instead */
555
+ projectid?: string | undefined;
556
+ removeSourceBranch?: boolean | undefined;
557
+ assignee?: string | undefined;
558
+ }>;
559
+
560
+ /**
561
+ * A method to create a router for the scaffolder backend plugin.
562
+ * @public
563
+ */
564
+ export declare function createRouter(options: RouterOptions): Promise<express.Router>;
565
+
566
+ /**
567
+ * This function is used to create new template actions to get type safety.
568
+ * @public
569
+ */
570
+ export declare const createTemplateAction: <TInput extends JsonObject>(templateAction: TemplateAction<TInput>) => TemplateAction<TInput>;
571
+
572
+ /**
573
+ * CreateWorkerOptions
574
+ *
575
+ * @public
576
+ */
577
+ export declare type CreateWorkerOptions = {
578
+ taskBroker: TaskBroker;
579
+ actionRegistry: TemplateActionRegistry;
580
+ integrations: ScmIntegrations;
581
+ workingDirectory: string;
582
+ logger: Logger;
583
+ additionalTemplateFilters?: Record<string, TemplateFilter>;
584
+ };
585
+
586
+ /**
587
+ * Stores the state of the current claimed task passed to the TaskContext
588
+ *
589
+ * @public
590
+ */
591
+ export declare interface CurrentClaimedTask {
592
+ /**
593
+ * The TaskSpec of the current claimed task.
594
+ */
595
+ spec: TaskSpec;
596
+ /**
597
+ * The uuid of the current claimed task.
598
+ */
599
+ taskId: string;
600
+ /**
601
+ * The secrets that are stored with the task.
602
+ */
603
+ secrets?: TaskSecrets;
604
+ /**
605
+ * The creator of the task.
606
+ */
607
+ createdBy?: string;
608
+ }
609
+
610
+ /**
611
+ * DatabaseTaskStore
612
+ *
613
+ * @public
614
+ */
615
+ export declare class DatabaseTaskStore implements TaskStore {
616
+ private readonly db;
617
+ static create(options: DatabaseTaskStoreOptions): Promise<DatabaseTaskStore>;
618
+ private constructor();
619
+ list(options: {
620
+ createdBy?: string;
621
+ }): Promise<{
622
+ tasks: SerializedTask[];
623
+ }>;
624
+ getTask(taskId: string): Promise<SerializedTask>;
625
+ createTask(options: TaskStoreCreateTaskOptions): Promise<TaskStoreCreateTaskResult>;
626
+ claimTask(): Promise<SerializedTask | undefined>;
627
+ heartbeatTask(taskId: string): Promise<void>;
628
+ listStaleTasks({ timeoutS }: {
629
+ timeoutS: number;
630
+ }): Promise<{
631
+ tasks: {
632
+ taskId: string;
633
+ }[];
634
+ }>;
635
+ completeTask({ taskId, status, eventBody, }: {
636
+ taskId: string;
637
+ status: TaskStatus;
638
+ eventBody: JsonObject;
639
+ }): Promise<void>;
640
+ emitLogEvent(options: TaskStoreEmitOptions<{
641
+ message: string;
642
+ } & JsonObject>): Promise<void>;
643
+ listEvents({ taskId, after, }: TaskStoreListEventsOptions): Promise<{
644
+ events: SerializedTaskEvent[];
645
+ }>;
646
+ }
647
+
648
+ /**
649
+ * DatabaseTaskStore
650
+ *
651
+ * @public
652
+ */
653
+ export declare type DatabaseTaskStoreOptions = {
654
+ database: Knex;
655
+ };
656
+
657
+ /**
658
+ * Run a command in a sub-process, normally a shell command.
659
+ *
660
+ * @public
661
+ */
662
+ export declare const executeShellCommand: (options: RunCommandOptions) => Promise<void>;
663
+
664
+ /**
665
+ * A helper function that reads the contents of a directory from the given URL.
666
+ * Can be used in your own actions, and also used behind fetch:template and fetch:plain
667
+ *
668
+ * @public
669
+ */
670
+ export declare function fetchContents({ reader, integrations, baseUrl, fetchUrl, outputPath, }: {
671
+ reader: UrlReader;
672
+ integrations: ScmIntegrations;
673
+ baseUrl?: string;
674
+ fetchUrl?: string;
675
+ outputPath: string;
676
+ }): Promise<void>;
677
+
678
+ /** @public */
679
+ export declare interface OctokitWithPullRequestPluginClient {
680
+ createPullRequest(options: createPullRequest.Options): Promise<{
681
+ data: {
682
+ html_url: string;
683
+ number: number;
684
+ };
685
+ } | null>;
686
+ }
687
+
688
+ /**
689
+ * RouterOptions
690
+ *
691
+ * @public
692
+ */
693
+ export declare interface RouterOptions {
694
+ logger: Logger;
695
+ config: Config;
696
+ reader: UrlReader;
697
+ database: PluginDatabaseManager;
698
+ catalogClient: CatalogApi;
699
+ actions?: TemplateAction<any>[];
700
+ taskWorkers?: number;
701
+ taskBroker?: TaskBroker;
702
+ additionalTemplateFilters?: Record<string, TemplateFilter>;
703
+ }
704
+
705
+ /** @public */
706
+ export declare type RunCommandOptions = {
707
+ /** command to run */
708
+ command: string;
709
+ /** arguments to pass the command */
710
+ args: string[];
711
+ /** options to pass to spawn */
712
+ options?: SpawnOptionsWithoutStdio;
713
+ /** stream to capture stdout and stderr output */
714
+ logStream?: Writable;
715
+ };
716
+
717
+ /* Excluded from this release type: scaffolderCatalogModule */
718
+
719
+ /** @public */
720
+ export declare class ScaffolderEntitiesProcessor implements CatalogProcessor {
721
+ getProcessorName(): string;
722
+ private readonly validators;
723
+ validateEntityKind(entity: Entity): Promise<boolean>;
724
+ postProcessEntity(entity: Entity, _location: LocationSpec, emit: CatalogProcessorEmit): Promise<Entity>;
725
+ }
726
+
727
+ /**
728
+ * SerializedTask
729
+ *
730
+ * @public
731
+ */
732
+ export declare type SerializedTask = {
733
+ id: string;
734
+ spec: TaskSpec;
735
+ status: TaskStatus;
736
+ createdAt: string;
737
+ lastHeartbeatAt?: string;
738
+ createdBy?: string;
739
+ secrets?: TaskSecrets;
740
+ };
741
+
742
+ /**
743
+ * SerializedTaskEvent
744
+ *
745
+ * @public
746
+ */
747
+ export declare type SerializedTaskEvent = {
748
+ id: number;
749
+ taskId: string;
750
+ body: JsonObject;
751
+ type: TaskEventType;
752
+ createdAt: string;
753
+ };
754
+
755
+ /**
756
+ * TaskBroker
757
+ *
758
+ * @public
759
+ */
760
+ export declare interface TaskBroker {
761
+ claim(): Promise<TaskContext>;
762
+ dispatch(options: TaskBrokerDispatchOptions): Promise<TaskBrokerDispatchResult>;
763
+ vacuumTasks(options: {
764
+ timeoutS: number;
765
+ }): Promise<void>;
766
+ event$(options: {
767
+ taskId: string;
768
+ after: number | undefined;
769
+ }): Observable<{
770
+ events: SerializedTaskEvent[];
771
+ }>;
772
+ get(taskId: string): Promise<SerializedTask>;
773
+ list?(options?: {
774
+ createdBy?: string;
775
+ }): Promise<{
776
+ tasks: SerializedTask[];
777
+ }>;
778
+ }
779
+
780
+ /**
781
+ * The options passed to {@link TaskBroker.dispatch}
782
+ * Currently a spec and optional secrets
783
+ *
784
+ * @public
785
+ */
786
+ export declare type TaskBrokerDispatchOptions = {
787
+ spec: TaskSpec;
788
+ secrets?: TaskSecrets;
789
+ createdBy?: string;
790
+ };
791
+
792
+ /**
793
+ * The result of {@link TaskBroker.dispatch}
794
+ *
795
+ * @public
796
+ */
797
+ export declare type TaskBrokerDispatchResult = {
798
+ taskId: string;
799
+ };
800
+
801
+ /**
802
+ * The state of a completed task.
803
+ *
804
+ * @public
805
+ */
806
+ export declare type TaskCompletionState = 'failed' | 'completed';
807
+
808
+ /**
809
+ * Task
810
+ *
811
+ * @public
812
+ */
813
+ export declare interface TaskContext {
814
+ spec: TaskSpec;
815
+ secrets?: TaskSecrets;
816
+ createdBy?: string;
817
+ done: boolean;
818
+ isDryRun?: boolean;
819
+ emitLog(message: string, logMetadata?: JsonObject): Promise<void>;
820
+ complete(result: TaskCompletionState, metadata?: JsonObject): Promise<void>;
821
+ getWorkspaceName(): Promise<string>;
822
+ }
823
+
824
+ /**
825
+ * TaskEventType
826
+ *
827
+ * @public
828
+ */
829
+ export declare type TaskEventType = 'completion' | 'log';
830
+
831
+ /**
832
+ * TaskManager
833
+ *
834
+ * @public
835
+ */
836
+ export declare class TaskManager implements TaskContext {
837
+ private readonly task;
838
+ private readonly storage;
839
+ private readonly logger;
840
+ private isDone;
841
+ private heartbeatTimeoutId?;
842
+ static create(task: CurrentClaimedTask, storage: TaskStore, logger: Logger): TaskManager;
843
+ private constructor();
844
+ get spec(): TaskSpecV1beta3;
845
+ get secrets(): TaskSecrets | undefined;
846
+ get createdBy(): string | undefined;
847
+ getWorkspaceName(): Promise<string>;
848
+ get done(): boolean;
849
+ emitLog(message: string, logMetadata?: JsonObject): Promise<void>;
850
+ complete(result: TaskCompletionState, metadata?: JsonObject): Promise<void>;
851
+ private startTimeout;
852
+ }
853
+
854
+ /**
855
+ * TaskSecrets
856
+ *
857
+ * @public
858
+ */
859
+ export declare type TaskSecrets = Record<string, string> & {
860
+ backstageToken?: string;
861
+ };
862
+
863
+ /**
864
+ * The status of each step of the Task
865
+ *
866
+ * @public
867
+ */
868
+ export declare type TaskStatus = 'open' | 'processing' | 'failed' | 'cancelled' | 'completed';
869
+
870
+ /**
871
+ * TaskStore
872
+ *
873
+ * @public
874
+ */
875
+ export declare interface TaskStore {
876
+ createTask(options: TaskStoreCreateTaskOptions): Promise<TaskStoreCreateTaskResult>;
877
+ getTask(taskId: string): Promise<SerializedTask>;
878
+ claimTask(): Promise<SerializedTask | undefined>;
879
+ completeTask(options: {
880
+ taskId: string;
881
+ status: TaskStatus;
882
+ eventBody: JsonObject;
883
+ }): Promise<void>;
884
+ heartbeatTask(taskId: string): Promise<void>;
885
+ listStaleTasks(options: {
886
+ timeoutS: number;
887
+ }): Promise<{
888
+ tasks: {
889
+ taskId: string;
890
+ }[];
891
+ }>;
892
+ list?(options: {
893
+ createdBy?: string;
894
+ }): Promise<{
895
+ tasks: SerializedTask[];
896
+ }>;
897
+ emitLogEvent({ taskId, body }: TaskStoreEmitOptions): Promise<void>;
898
+ listEvents({ taskId, after, }: TaskStoreListEventsOptions): Promise<{
899
+ events: SerializedTaskEvent[];
900
+ }>;
901
+ }
902
+
903
+ /**
904
+ * The options passed to {@link TaskStore.createTask}
905
+ * @public
906
+ */
907
+ export declare type TaskStoreCreateTaskOptions = {
908
+ spec: TaskSpec;
909
+ createdBy?: string;
910
+ secrets?: TaskSecrets;
911
+ };
912
+
913
+ /**
914
+ * The response from {@link TaskStore.createTask}
915
+ * @public
916
+ */
917
+ export declare type TaskStoreCreateTaskResult = {
918
+ taskId: string;
919
+ };
920
+
921
+ /**
922
+ * TaskStoreEmitOptions
923
+ *
924
+ * @public
925
+ */
926
+ export declare type TaskStoreEmitOptions<TBody = JsonObject> = {
927
+ taskId: string;
928
+ body: TBody;
929
+ };
930
+
931
+ /**
932
+ * TaskStoreListEventsOptions
933
+ *
934
+ * @public
935
+ */
936
+ export declare type TaskStoreListEventsOptions = {
937
+ taskId: string;
938
+ after?: number | undefined;
939
+ };
940
+
941
+ /**
942
+ * TaskWorker
943
+ *
944
+ * @public
945
+ */
946
+ export declare class TaskWorker {
947
+ private readonly options;
948
+ private constructor();
949
+ static create(options: CreateWorkerOptions): Promise<TaskWorker>;
950
+ start(): void;
951
+ runOneTask(task: TaskContext): Promise<void>;
952
+ }
953
+
954
+ /** @public */
955
+ export declare type TemplateAction<Input extends JsonObject> = {
956
+ id: string;
957
+ description?: string;
958
+ supportsDryRun?: boolean;
959
+ schema?: {
960
+ input?: Schema;
961
+ output?: Schema;
962
+ };
963
+ handler: (ctx: ActionContext<Input>) => Promise<void>;
964
+ };
965
+
966
+ /**
967
+ * Registry of all registered template actions.
968
+ * @public
969
+ */
970
+ export declare class TemplateActionRegistry {
971
+ private readonly actions;
972
+ register<TInput extends JsonObject>(action: TemplateAction<TInput>): void;
973
+ get(actionId: string): TemplateAction<JsonObject>;
974
+ list(): TemplateAction<JsonObject>[];
975
+ }
976
+
977
+ /** @public */
978
+ export declare type TemplateFilter = (...args: JsonValue[]) => JsonValue | undefined;
979
+
980
+ export { }