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

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