@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.
@@ -0,0 +1,963 @@
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 initializes a git repository of the content in the workspace
446
+ * and publishes it to GitHub.
447
+ *
448
+ * @public
449
+ */
450
+ export declare function createPublishGithubAction(options: {
451
+ integrations: ScmIntegrationRegistry;
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;
485
+ }>;
486
+
487
+ /**
488
+ * Creates a Github Pull Request action.
489
+ * @public
490
+ */
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;
500
+ }>;
501
+
502
+ /**
503
+ * Creates a new action that initializes a git repository of the content in the workspace
504
+ * and publishes it to GitLab.
505
+ *
506
+ * @public
507
+ */
508
+ export declare function createPublishGitlabAction(options: {
509
+ integrations: ScmIntegrationRegistry;
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;
521
+ }>;
522
+
523
+ /**
524
+ * Create a new action that creates a gitlab merge request.
525
+ *
526
+ * @public
527
+ */
528
+ export declare const createPublishGitlabMergeRequestAction: (options: {
529
+ integrations: ScmIntegrationRegistry;
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;
541
+ }>;
542
+
543
+ /**
544
+ * A method to create a router for the scaffolder backend plugin.
545
+ * @public
546
+ */
547
+ export declare function createRouter(options: RouterOptions): Promise<express.Router>;
548
+
549
+ /**
550
+ * This function is used to create new template actions to get type safety.
551
+ * @public
552
+ */
553
+ export declare const createTemplateAction: <TInput extends JsonObject>(templateAction: TemplateAction<TInput>) => TemplateAction<TInput>;
554
+
555
+ /**
556
+ * CreateWorkerOptions
557
+ *
558
+ * @public
559
+ */
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
+ };
568
+
569
+ /**
570
+ * Stores the state of the current claimed task passed to the TaskContext
571
+ *
572
+ * @public
573
+ */
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
+
593
+ /**
594
+ * DatabaseTaskStore
595
+ *
596
+ * @public
597
+ */
598
+ export declare class DatabaseTaskStore implements TaskStore {
599
+ private readonly db;
600
+ static create(options: DatabaseTaskStoreOptions): Promise<DatabaseTaskStore>;
601
+ private constructor();
602
+ list(options: {
603
+ createdBy?: string;
604
+ }): Promise<{
605
+ tasks: SerializedTask[];
606
+ }>;
607
+ getTask(taskId: string): Promise<SerializedTask>;
608
+ createTask(options: TaskStoreCreateTaskOptions): Promise<TaskStoreCreateTaskResult>;
609
+ claimTask(): Promise<SerializedTask | undefined>;
610
+ heartbeatTask(taskId: string): Promise<void>;
611
+ listStaleTasks({ timeoutS }: {
612
+ timeoutS: number;
613
+ }): Promise<{
614
+ tasks: {
615
+ taskId: string;
616
+ }[];
617
+ }>;
618
+ completeTask({ taskId, status, eventBody, }: {
619
+ taskId: string;
620
+ status: TaskStatus;
621
+ eventBody: JsonObject;
622
+ }): Promise<void>;
623
+ emitLogEvent(options: TaskStoreEmitOptions<{
624
+ message: string;
625
+ } & JsonObject>): Promise<void>;
626
+ listEvents({ taskId, after, }: TaskStoreListEventsOptions): Promise<{
627
+ events: SerializedTaskEvent[];
628
+ }>;
629
+ }
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
+
814
+ /**
815
+ * TaskManager
816
+ *
817
+ * @public
818
+ */
819
+ export declare class TaskManager implements TaskContext {
820
+ private readonly task;
821
+ private readonly storage;
822
+ private readonly logger;
823
+ private isDone;
824
+ private heartbeatTimeoutId?;
825
+ static create(task: CurrentClaimedTask, storage: TaskStore, logger: Logger): TaskManager;
826
+ private constructor();
827
+ get spec(): TaskSpecV1beta3;
828
+ get secrets(): TaskSecrets | undefined;
829
+ get createdBy(): string | undefined;
830
+ getWorkspaceName(): Promise<string>;
831
+ get done(): boolean;
832
+ emitLog(message: string, logMetadata?: JsonObject): Promise<void>;
833
+ complete(result: TaskCompletionState, metadata?: JsonObject): Promise<void>;
834
+ private startTimeout;
835
+ }
836
+
837
+ /**
838
+ * TaskSecrets
839
+ *
840
+ * @public
841
+ */
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 = {
891
+ spec: TaskSpec;
892
+ createdBy?: string;
893
+ secrets?: TaskSecrets;
894
+ };
895
+
896
+ /**
897
+ * The response from {@link TaskStore.createTask}
898
+ * @public
899
+ */
900
+ export declare type TaskStoreCreateTaskResult = {
901
+ taskId: string;
902
+ };
903
+
904
+ /**
905
+ * TaskStoreEmitOptions
906
+ *
907
+ * @public
908
+ */
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;
922
+ };
923
+
924
+ /**
925
+ * TaskWorker
926
+ *
927
+ * @public
928
+ */
929
+ export declare class TaskWorker {
930
+ private readonly options;
931
+ private constructor();
932
+ static create(options: CreateWorkerOptions): Promise<TaskWorker>;
933
+ start(): void;
934
+ runOneTask(task: TaskContext): Promise<void>;
935
+ }
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
+
949
+ /**
950
+ * Registry of all registered template actions.
951
+ * @public
952
+ */
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>[];
958
+ }
959
+
960
+ /** @public */
961
+ export declare type TemplateFilter = (...args: JsonValue[]) => JsonValue | undefined;
962
+
963
+ export { }