@backstage/plugin-scaffolder-backend 1.11.0 → 1.12.0-next.1

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.
@@ -1,1091 +0,0 @@
1
- /**
2
- * The Backstage backend plugin that helps you create new things
3
- *
4
- * @packageDocumentation
5
- */
6
-
7
- /// <reference types="node" />
8
-
9
- import { ActionContext as ActionContext_2 } from '@backstage/plugin-scaffolder-node';
10
- import { BackendFeature } from '@backstage/backend-plugin-api';
11
- import { CatalogApi } from '@backstage/catalog-client';
12
- import { CatalogProcessor } from '@backstage/plugin-catalog-backend';
13
- import { CatalogProcessorEmit } from '@backstage/plugin-catalog-backend';
14
- import { Config } from '@backstage/config';
15
- import { createPullRequest } from 'octokit-plugin-create-pull-request';
16
- import { Entity } from '@backstage/catalog-model';
17
- import express from 'express';
18
- import { GithubCredentialsProvider } from '@backstage/integration';
19
- import { IdentityApi } from '@backstage/plugin-auth-node';
20
- import { JsonObject } from '@backstage/types';
21
- import { JsonValue } from '@backstage/types';
22
- import { Knex } from 'knex';
23
- import { LocationSpec } from '@backstage/plugin-catalog-backend';
24
- import { Logger } from 'winston';
25
- import { Observable } from '@backstage/types';
26
- import { Octokit } from 'octokit';
27
- import { PluginDatabaseManager } from '@backstage/backend-common';
28
- import { PluginTaskScheduler } from '@backstage/backend-tasks';
29
- import { ScmIntegrationRegistry } from '@backstage/integration';
30
- import { ScmIntegrations } from '@backstage/integration';
31
- import { SpawnOptionsWithoutStdio } from 'child_process';
32
- import { TaskSecrets as TaskSecrets_2 } from '@backstage/plugin-scaffolder-node';
33
- import { TaskSpec } from '@backstage/plugin-scaffolder-common';
34
- import { TaskSpecV1beta3 } from '@backstage/plugin-scaffolder-common';
35
- import { TemplateAction as TemplateAction_2 } from '@backstage/plugin-scaffolder-node';
36
- import { UrlReader } from '@backstage/backend-common';
37
- import { Writable } from 'stream';
38
-
39
- /**
40
- * @public
41
- * @deprecated Import from {@link @backstage/plugin-scaffolder-node#ActionContext} instead
42
- */
43
- export declare type ActionContext<TInput extends JsonObject> = ActionContext_2<TInput>;
44
-
45
- /**
46
- * Registers support for the Template kind to the catalog backend plugin.
47
- *
48
- * @alpha
49
- */
50
- export declare const catalogModuleTemplateKind: () => BackendFeature;
51
-
52
- /**
53
- * A function to generate create a list of default actions that the scaffolder provides.
54
- * Is called internally in the default setup, but can be used when adding your own actions or overriding the default ones
55
- *
56
- * @public
57
- * @returns A list of actions that can be used in the scaffolder
58
- */
59
- export declare const createBuiltinActions: (options: CreateBuiltInActionsOptions) => TemplateAction_2<JsonObject>[];
60
-
61
- /**
62
- * The options passed to {@link createBuiltinActions}
63
- * @public
64
- */
65
- export declare interface CreateBuiltInActionsOptions {
66
- /**
67
- * The {@link @backstage/backend-common#UrlReader} interface that will be used in the default actions.
68
- */
69
- reader: UrlReader;
70
- /**
71
- * The {@link @backstage/integrations#ScmIntegrations} that will be used in the default actions.
72
- */
73
- integrations: ScmIntegrations;
74
- /**
75
- * The {@link @backstage/catalog-client#CatalogApi} that will be used in the default actions.
76
- */
77
- catalogClient: CatalogApi;
78
- /**
79
- * The {@link @backstage/config#Config} that will be used in the default actions.
80
- */
81
- config: Config;
82
- /**
83
- * Additional custom filters that will be passed to the nunjucks template engine for use in
84
- * Template Manifests and also template skeleton files when using `fetch:template`.
85
- */
86
- additionalTemplateFilters?: Record<string, TemplateFilter>;
87
- additionalTemplateGlobals?: Record<string, TemplateGlobal>;
88
- }
89
-
90
- /**
91
- * Registers entities from a catalog descriptor file in the workspace into the software catalog.
92
- * @public
93
- */
94
- export declare function createCatalogRegisterAction(options: {
95
- catalogClient: CatalogApi;
96
- integrations: ScmIntegrations;
97
- }): TemplateAction_2< {
98
- catalogInfoUrl: string;
99
- optional?: boolean | undefined;
100
- } | {
101
- repoContentsUrl: string;
102
- catalogInfoPath?: string | undefined;
103
- optional?: boolean | undefined;
104
- }>;
105
-
106
- /**
107
- * Writes a catalog descriptor file containing the provided entity to a path in the workspace.
108
- * @public
109
- */
110
- export declare function createCatalogWriteAction(): TemplateAction_2< {
111
- filePath?: string | undefined;
112
- entity: Entity;
113
- }>;
114
-
115
- /**
116
- * Writes a message into the log or lists all files in the workspace
117
- *
118
- * @remarks
119
- *
120
- * This task is useful for local development and testing of both the scaffolder
121
- * and scaffolder templates.
122
- *
123
- * @public
124
- */
125
- export declare function createDebugLogAction(): TemplateAction_2< {
126
- message?: string | undefined;
127
- listWorkspace?: boolean | undefined;
128
- }>;
129
-
130
- /**
131
- * Returns entity from the catalog by entity reference.
132
- * @public
133
- */
134
- export declare function createFetchCatalogEntityAction(options: {
135
- catalogClient: CatalogApi;
136
- }): TemplateAction_2< {
137
- entityRef: string;
138
- optional?: boolean | undefined;
139
- }>;
140
-
141
- /**
142
- * Downloads content and places it in the workspace, or optionally
143
- * in a subdirectory specified by the 'targetPath' input option.
144
- * @public
145
- */
146
- export declare function createFetchPlainAction(options: {
147
- reader: UrlReader;
148
- integrations: ScmIntegrations;
149
- }): TemplateAction_2< {
150
- url: string;
151
- targetPath?: string | undefined;
152
- }>;
153
-
154
- /**
155
- * Downloads a skeleton, templates variables into file and directory names and content.
156
- * Then places the result in the workspace, or optionally in a subdirectory
157
- * specified by the 'targetPath' input option.
158
- *
159
- * @public
160
- */
161
- export declare function createFetchTemplateAction(options: {
162
- reader: UrlReader;
163
- integrations: ScmIntegrations;
164
- additionalTemplateFilters?: Record<string, TemplateFilter>;
165
- additionalTemplateGlobals?: Record<string, TemplateGlobal>;
166
- }): TemplateAction_2< {
167
- url: string;
168
- targetPath?: string | undefined;
169
- values: any;
170
- templateFileExtension?: string | boolean | undefined;
171
- /**
172
- * @deprecated This field is deprecated in favor of copyWithoutTemplating.
173
- */
174
- copyWithoutRender?: string[] | undefined;
175
- copyWithoutTemplating?: string[] | undefined;
176
- cookiecutterCompat?: boolean | undefined;
177
- replace?: boolean | undefined;
178
- }>;
179
-
180
- /**
181
- * Creates new action that enables deletion of files and directories in the workspace.
182
- * @public
183
- */
184
- export declare const createFilesystemDeleteAction: () => TemplateAction_2< {
185
- files: string[];
186
- }>;
187
-
188
- /**
189
- * Creates a new action that allows renames of files and directories in the workspace.
190
- * @public
191
- */
192
- export declare const createFilesystemRenameAction: () => TemplateAction_2< {
193
- files: Array<{
194
- from: string;
195
- to: string;
196
- overwrite?: boolean;
197
- }>;
198
- }>;
199
-
200
- /**
201
- * Creates a new action that dispatches a GitHub Action workflow for a given branch or tag.
202
- * @public
203
- */
204
- export declare function createGithubActionsDispatchAction(options: {
205
- integrations: ScmIntegrations;
206
- githubCredentialsProvider?: GithubCredentialsProvider;
207
- }): TemplateAction_2< {
208
- repoUrl: string;
209
- workflowId: string;
210
- branchOrTagName: string;
211
- workflowInputs?: {
212
- [key: string]: string;
213
- } | undefined;
214
- token?: string | undefined;
215
- }>;
216
-
217
- /**
218
- * Adds labels to a pull request or issue on GitHub
219
- * @public
220
- */
221
- export declare function createGithubIssuesLabelAction(options: {
222
- integrations: ScmIntegrationRegistry;
223
- githubCredentialsProvider?: GithubCredentialsProvider;
224
- }): TemplateAction_2< {
225
- repoUrl: string;
226
- number: number;
227
- labels: string[];
228
- token?: string | undefined;
229
- }>;
230
-
231
- /**
232
- * The options passed to {@link createPublishGithubPullRequestAction} method
233
- * @public
234
- */
235
- export declare interface CreateGithubPullRequestActionOptions {
236
- /**
237
- * An instance of {@link @backstage/integration#ScmIntegrationRegistry} that will be used in the action.
238
- */
239
- integrations: ScmIntegrationRegistry;
240
- /**
241
- * An instance of {@link @backstage/integration#GithubCredentialsProvider} that will be used to get credentials for the action.
242
- */
243
- githubCredentialsProvider?: GithubCredentialsProvider;
244
- /**
245
- * A method to return the Octokit client with the Pull Request Plugin.
246
- */
247
- clientFactory?: (input: CreateGithubPullRequestClientFactoryInput) => Promise<OctokitWithPullRequestPluginClient>;
248
- }
249
-
250
- /**
251
- * The options passed to the client factory function.
252
- * @public
253
- */
254
- export declare type CreateGithubPullRequestClientFactoryInput = {
255
- integrations: ScmIntegrationRegistry;
256
- githubCredentialsProvider?: GithubCredentialsProvider;
257
- host: string;
258
- owner: string;
259
- repo: string;
260
- token?: string;
261
- };
262
-
263
- /**
264
- * Creates a new action that initializes a git repository
265
- *
266
- * @public
267
- */
268
- export declare function createGithubRepoCreateAction(options: {
269
- integrations: ScmIntegrationRegistry;
270
- githubCredentialsProvider?: GithubCredentialsProvider;
271
- }): TemplateAction_2< {
272
- repoUrl: string;
273
- description?: string | undefined;
274
- homepage?: string | undefined;
275
- access?: string | undefined;
276
- deleteBranchOnMerge?: boolean | undefined;
277
- gitAuthorName?: string | undefined;
278
- gitAuthorEmail?: string | undefined;
279
- allowRebaseMerge?: boolean | undefined;
280
- allowSquashMerge?: boolean | undefined;
281
- squashMergeCommitTitle?: "PR_TITLE" | "COMMIT_OR_PR_TITLE" | undefined;
282
- squashMergeCommitMessage?: "PR_BODY" | "COMMIT_MESSAGES" | "BLANK" | undefined;
283
- allowMergeCommit?: boolean | undefined;
284
- allowAutoMerge?: boolean | undefined;
285
- requireCodeOwnerReviews?: boolean | undefined;
286
- bypassPullRequestAllowances?: {
287
- users?: string[] | undefined;
288
- teams?: string[] | undefined;
289
- apps?: string[] | undefined;
290
- } | undefined;
291
- requiredApprovingReviewCount?: number | undefined;
292
- restrictions?: {
293
- users: string[];
294
- teams: string[];
295
- apps?: string[] | undefined;
296
- } | undefined;
297
- requiredStatusCheckContexts?: string[] | undefined;
298
- requireBranchesToBeUpToDate?: boolean | undefined;
299
- requiredConversationResolution?: boolean | undefined;
300
- repoVisibility?: "internal" | "private" | "public" | undefined;
301
- collaborators?: ({
302
- user: string;
303
- access: string;
304
- } | {
305
- team: string;
306
- access: string;
307
- } | {
308
- /** @deprecated This field is deprecated in favor of team */
309
- username: string;
310
- access: 'pull' | 'push' | 'admin' | 'maintain' | 'triage';
311
- })[] | undefined;
312
- hasProjects?: boolean | undefined;
313
- hasWiki?: boolean | undefined;
314
- hasIssues?: boolean | undefined;
315
- token?: string | undefined;
316
- topics?: string[] | undefined;
317
- requireCommitSigning?: boolean | undefined;
318
- }>;
319
-
320
- /**
321
- * Creates a new action that initializes a git repository of the content in the workspace
322
- * and publishes it to GitHub.
323
- *
324
- * @public
325
- */
326
- export declare function createGithubRepoPushAction(options: {
327
- integrations: ScmIntegrationRegistry;
328
- config: Config;
329
- githubCredentialsProvider?: GithubCredentialsProvider;
330
- }): TemplateAction_2< {
331
- repoUrl: string;
332
- description?: string | undefined;
333
- defaultBranch?: string | undefined;
334
- protectDefaultBranch?: boolean | undefined;
335
- protectEnforceAdmins?: boolean | undefined;
336
- gitCommitMessage?: string | undefined;
337
- gitAuthorName?: string | undefined;
338
- gitAuthorEmail?: string | undefined;
339
- requireCodeOwnerReviews?: boolean | undefined;
340
- dismissStaleReviews?: boolean | undefined;
341
- bypassPullRequestAllowances?: {
342
- users?: string[];
343
- teams?: string[];
344
- apps?: string[];
345
- } | undefined;
346
- requiredApprovingReviewCount?: number | undefined;
347
- restrictions?: {
348
- users: string[];
349
- teams: string[];
350
- apps?: string[];
351
- } | undefined;
352
- requiredStatusCheckContexts?: string[] | undefined;
353
- requireBranchesToBeUpToDate?: boolean | undefined;
354
- requiredConversationResolution?: boolean | undefined;
355
- sourcePath?: string | undefined;
356
- token?: string | undefined;
357
- requiredCommitSigning?: boolean | undefined;
358
- }>;
359
-
360
- /**
361
- * Creates new action that creates a webhook for a repository on GitHub.
362
- * @public
363
- */
364
- export declare function createGithubWebhookAction(options: {
365
- integrations: ScmIntegrationRegistry;
366
- defaultWebhookSecret?: string;
367
- githubCredentialsProvider?: GithubCredentialsProvider;
368
- }): TemplateAction_2< {
369
- repoUrl: string;
370
- webhookUrl: string;
371
- webhookSecret?: string | undefined;
372
- events?: string[] | undefined;
373
- active?: boolean | undefined;
374
- contentType?: "form" | "json" | undefined;
375
- insecureSsl?: boolean | undefined;
376
- token?: string | undefined;
377
- }>;
378
-
379
- /**
380
- * Creates a new action that initializes a git repository of the content in the workspace
381
- * and publishes it to Azure.
382
- * @public
383
- */
384
- export declare function createPublishAzureAction(options: {
385
- integrations: ScmIntegrationRegistry;
386
- config: Config;
387
- }): TemplateAction_2< {
388
- repoUrl: string;
389
- description?: string | undefined;
390
- defaultBranch?: string | undefined;
391
- sourcePath?: string | undefined;
392
- token?: string | undefined;
393
- gitCommitMessage?: string | undefined;
394
- gitAuthorName?: string | undefined;
395
- gitAuthorEmail?: string | undefined;
396
- }>;
397
-
398
- /**
399
- * Creates a new action that initializes a git repository of the content in the workspace
400
- * and publishes it to Bitbucket.
401
- * @public
402
- * @deprecated in favor of createPublishBitbucketCloudAction and createPublishBitbucketServerAction
403
- */
404
- export declare function createPublishBitbucketAction(options: {
405
- integrations: ScmIntegrationRegistry;
406
- config: Config;
407
- }): TemplateAction_2< {
408
- repoUrl: string;
409
- description?: string | undefined;
410
- defaultBranch?: string | undefined;
411
- repoVisibility?: "private" | "public" | undefined;
412
- sourcePath?: string | undefined;
413
- enableLFS?: boolean | undefined;
414
- token?: string | undefined;
415
- gitCommitMessage?: string | undefined;
416
- gitAuthorName?: string | undefined;
417
- gitAuthorEmail?: string | undefined;
418
- }>;
419
-
420
- /**
421
- * Creates a new action that initializes a git repository of the content in the workspace
422
- * and publishes it to Bitbucket Cloud.
423
- * @public
424
- */
425
- export declare function createPublishBitbucketCloudAction(options: {
426
- integrations: ScmIntegrationRegistry;
427
- config: Config;
428
- }): TemplateAction_2< {
429
- repoUrl: string;
430
- description?: string | undefined;
431
- defaultBranch?: string | undefined;
432
- repoVisibility?: "private" | "public" | undefined;
433
- sourcePath?: string | undefined;
434
- token?: string | undefined;
435
- }>;
436
-
437
- /**
438
- * Creates a new action that initializes a git repository of the content in the workspace
439
- * and publishes it to Bitbucket Server.
440
- * @public
441
- */
442
- export declare function createPublishBitbucketServerAction(options: {
443
- integrations: ScmIntegrationRegistry;
444
- config: Config;
445
- }): TemplateAction_2< {
446
- repoUrl: string;
447
- description?: string | undefined;
448
- defaultBranch?: string | undefined;
449
- repoVisibility?: "private" | "public" | undefined;
450
- sourcePath?: string | undefined;
451
- enableLFS?: boolean | undefined;
452
- token?: string | undefined;
453
- gitCommitMessage?: string | undefined;
454
- gitAuthorName?: string | undefined;
455
- gitAuthorEmail?: string | undefined;
456
- }>;
457
-
458
- /**
459
- * Creates a new action that initializes a git repository of the content in the workspace
460
- * and publishes it to a Gerrit instance.
461
- * @public
462
- */
463
- export declare function createPublishGerritAction(options: {
464
- integrations: ScmIntegrationRegistry;
465
- config: Config;
466
- }): TemplateAction_2< {
467
- repoUrl: string;
468
- description: string;
469
- defaultBranch?: string | undefined;
470
- gitCommitMessage?: string | undefined;
471
- gitAuthorName?: string | undefined;
472
- gitAuthorEmail?: string | undefined;
473
- sourcePath?: string | undefined;
474
- }>;
475
-
476
- /**
477
- * Creates a new action that creates a Gerrit review
478
- * @public
479
- */
480
- export declare function createPublishGerritReviewAction(options: {
481
- integrations: ScmIntegrationRegistry;
482
- config: Config;
483
- }): TemplateAction_2< {
484
- repoUrl: string;
485
- branch?: string | undefined;
486
- sourcePath?: string | undefined;
487
- gitCommitMessage?: string | undefined;
488
- gitAuthorName?: string | undefined;
489
- gitAuthorEmail?: string | undefined;
490
- }>;
491
-
492
- /**
493
- * Creates a new action that initializes a git repository of the content in the workspace
494
- * and publishes it to GitHub.
495
- *
496
- * @public
497
- */
498
- export declare function createPublishGithubAction(options: {
499
- integrations: ScmIntegrationRegistry;
500
- config: Config;
501
- githubCredentialsProvider?: GithubCredentialsProvider;
502
- }): TemplateAction_2< {
503
- repoUrl: string;
504
- description?: string | undefined;
505
- homepage?: string | undefined;
506
- access?: string | undefined;
507
- defaultBranch?: string | undefined;
508
- protectDefaultBranch?: boolean | undefined;
509
- protectEnforceAdmins?: boolean | undefined;
510
- deleteBranchOnMerge?: boolean | undefined;
511
- gitCommitMessage?: string | undefined;
512
- gitAuthorName?: string | undefined;
513
- gitAuthorEmail?: string | undefined;
514
- allowRebaseMerge?: boolean | undefined;
515
- allowSquashMerge?: boolean | undefined;
516
- squashMergeCommitTitle?: "PR_TITLE" | "COMMIT_OR_PR_TITLE" | undefined;
517
- squashMergeCommitMessage?: "PR_BODY" | "COMMIT_MESSAGES" | "BLANK" | undefined;
518
- allowMergeCommit?: boolean | undefined;
519
- allowAutoMerge?: boolean | undefined;
520
- sourcePath?: string | undefined;
521
- bypassPullRequestAllowances?: {
522
- users?: string[];
523
- teams?: string[];
524
- apps?: string[];
525
- } | undefined;
526
- requiredApprovingReviewCount?: number | undefined;
527
- restrictions?: {
528
- users: string[];
529
- teams: string[];
530
- apps?: string[];
531
- } | undefined;
532
- requireCodeOwnerReviews?: boolean | undefined;
533
- dismissStaleReviews?: boolean | undefined;
534
- requiredStatusCheckContexts?: string[] | undefined;
535
- requireBranchesToBeUpToDate?: boolean | undefined;
536
- requiredConversationResolution?: boolean | undefined;
537
- repoVisibility?: "internal" | "private" | "public" | undefined;
538
- collaborators?: ({
539
- user: string;
540
- access: string;
541
- } | {
542
- team: string;
543
- access: string;
544
- } | {
545
- /** @deprecated This field is deprecated in favor of team */
546
- username: string;
547
- access: 'pull' | 'push' | 'admin' | 'maintain' | 'triage';
548
- })[] | undefined;
549
- hasProjects?: boolean | undefined;
550
- hasWiki?: boolean | undefined;
551
- hasIssues?: boolean | undefined;
552
- token?: string | undefined;
553
- topics?: string[] | undefined;
554
- requiredCommitSigning?: boolean | undefined;
555
- }>;
556
-
557
- /**
558
- * Creates a Github Pull Request action.
559
- * @public
560
- */
561
- export declare const createPublishGithubPullRequestAction: ({ integrations, githubCredentialsProvider, clientFactory, }: CreateGithubPullRequestActionOptions) => TemplateAction_2< {
562
- title: string;
563
- branchName: string;
564
- description: string;
565
- repoUrl: string;
566
- draft?: boolean | undefined;
567
- targetPath?: string | undefined;
568
- sourcePath?: string | undefined;
569
- token?: string | undefined;
570
- reviewers?: string[] | undefined;
571
- teamReviewers?: string[] | undefined;
572
- }>;
573
-
574
- /**
575
- * Creates a new action that initializes a git repository of the content in the workspace
576
- * and publishes it to GitLab.
577
- *
578
- * @public
579
- */
580
- export declare function createPublishGitlabAction(options: {
581
- integrations: ScmIntegrationRegistry;
582
- config: Config;
583
- }): TemplateAction_2< {
584
- repoUrl: string;
585
- defaultBranch?: string | undefined;
586
- repoVisibility?: "internal" | "private" | "public" | undefined;
587
- sourcePath?: string | undefined;
588
- token?: string | undefined;
589
- gitCommitMessage?: string | undefined;
590
- gitAuthorName?: string | undefined;
591
- gitAuthorEmail?: string | undefined;
592
- setUserAsOwner?: boolean | undefined;
593
- topics?: string[] | undefined;
594
- }>;
595
-
596
- /**
597
- * Create a new action that creates a gitlab merge request.
598
- *
599
- * @public
600
- */
601
- export declare const createPublishGitlabMergeRequestAction: (options: {
602
- integrations: ScmIntegrationRegistry;
603
- }) => TemplateAction_2< {
604
- repoUrl: string;
605
- title: string;
606
- description: string;
607
- branchName: string;
608
- sourcePath?: string | undefined;
609
- targetPath?: string | undefined;
610
- token?: string | undefined;
611
- commitAction?: "update" | "delete" | "create" | undefined;
612
- /** @deprecated projectID passed as query parameters in the repoUrl */
613
- projectid?: string | undefined;
614
- removeSourceBranch?: boolean | undefined;
615
- assignee?: string | undefined;
616
- }>;
617
-
618
- /**
619
- * A method to create a router for the scaffolder backend plugin.
620
- * @public
621
- */
622
- export declare function createRouter(options: RouterOptions): Promise<express.Router>;
623
-
624
- /**
625
- * @public
626
- * @deprecated Use `createTemplateAction` from `@backstage/plugin-scaffolder-node` instead
627
- */
628
- export declare const createTemplateAction: <TInput extends JsonObject>(templateAction: TemplateAction_2<TInput>) => TemplateAction_2<TInput>;
629
-
630
- /**
631
- * CreateWorkerOptions
632
- *
633
- * @public
634
- */
635
- export declare type CreateWorkerOptions = {
636
- taskBroker: TaskBroker;
637
- actionRegistry: TemplateActionRegistry;
638
- integrations: ScmIntegrations;
639
- workingDirectory: string;
640
- logger: Logger;
641
- additionalTemplateFilters?: Record<string, TemplateFilter>;
642
- /**
643
- * The number of tasks that can be executed at the same time by the worker
644
- * @defaultValue 10
645
- * @example
646
- * ```
647
- * {
648
- * concurrentTasksLimit: 1,
649
- * // OR
650
- * concurrentTasksLimit: Infinity
651
- * }
652
- * ```
653
- */
654
- concurrentTasksLimit?: number;
655
- additionalTemplateGlobals?: Record<string, TemplateGlobal>;
656
- };
657
-
658
- /**
659
- * Stores the state of the current claimed task passed to the TaskContext
660
- *
661
- * @public
662
- */
663
- export declare interface CurrentClaimedTask {
664
- /**
665
- * The TaskSpec of the current claimed task.
666
- */
667
- spec: TaskSpec;
668
- /**
669
- * The uuid of the current claimed task.
670
- */
671
- taskId: string;
672
- /**
673
- * The secrets that are stored with the task.
674
- */
675
- secrets?: TaskSecrets_2;
676
- /**
677
- * The creator of the task.
678
- */
679
- createdBy?: string;
680
- }
681
-
682
- /**
683
- * DatabaseTaskStore
684
- *
685
- * @public
686
- */
687
- export declare class DatabaseTaskStore implements TaskStore {
688
- private readonly db;
689
- static create(options: DatabaseTaskStoreOptions): Promise<DatabaseTaskStore>;
690
- private static getClient;
691
- private static runMigrations;
692
- private constructor();
693
- list(options: {
694
- createdBy?: string;
695
- }): Promise<{
696
- tasks: SerializedTask[];
697
- }>;
698
- getTask(taskId: string): Promise<SerializedTask>;
699
- createTask(options: TaskStoreCreateTaskOptions): Promise<TaskStoreCreateTaskResult>;
700
- claimTask(): Promise<SerializedTask | undefined>;
701
- heartbeatTask(taskId: string): Promise<void>;
702
- listStaleTasks(options: {
703
- timeoutS: number;
704
- }): Promise<{
705
- tasks: {
706
- taskId: string;
707
- }[];
708
- }>;
709
- completeTask(options: {
710
- taskId: string;
711
- status: TaskStatus;
712
- eventBody: JsonObject;
713
- }): Promise<void>;
714
- emitLogEvent(options: TaskStoreEmitOptions<{
715
- message: string;
716
- } & JsonObject>): Promise<void>;
717
- listEvents(options: TaskStoreListEventsOptions): Promise<{
718
- events: SerializedTaskEvent[];
719
- }>;
720
- shutdownTask({ taskId }: TaskStoreShutDownTaskOptions): Promise<void>;
721
- }
722
-
723
- /**
724
- * DatabaseTaskStore
725
- *
726
- * @public
727
- */
728
- export declare type DatabaseTaskStoreOptions = {
729
- database: PluginDatabaseManager | Knex;
730
- };
731
-
732
- /**
733
- * Run a command in a sub-process, normally a shell command.
734
- *
735
- * @public
736
- */
737
- export declare const executeShellCommand: (options: RunCommandOptions) => Promise<void>;
738
-
739
- /**
740
- * A helper function that reads the contents of a directory from the given URL.
741
- * Can be used in your own actions, and also used behind fetch:template and fetch:plain
742
- *
743
- * @public
744
- */
745
- export declare function fetchContents(options: {
746
- reader: UrlReader;
747
- integrations: ScmIntegrations;
748
- baseUrl?: string;
749
- fetchUrl?: string;
750
- outputPath: string;
751
- }): Promise<void>;
752
-
753
- /** @public */
754
- export declare type OctokitWithPullRequestPluginClient = Octokit & {
755
- createPullRequest(options: createPullRequest.Options): Promise<{
756
- data: {
757
- html_url: string;
758
- number: number;
759
- };
760
- } | null>;
761
- };
762
-
763
- /**
764
- * RouterOptions
765
- *
766
- * @public
767
- */
768
- export declare interface RouterOptions {
769
- logger: Logger;
770
- config: Config;
771
- reader: UrlReader;
772
- database: PluginDatabaseManager;
773
- catalogClient: CatalogApi;
774
- scheduler?: PluginTaskScheduler;
775
- actions?: TemplateAction_2<any>[];
776
- /**
777
- * @deprecated taskWorkers is deprecated in favor of concurrentTasksLimit option with a single TaskWorker
778
- * @defaultValue 1
779
- */
780
- taskWorkers?: number;
781
- /**
782
- * Sets the number of concurrent tasks that can be run at any given time on the TaskWorker
783
- * @defaultValue 10
784
- */
785
- concurrentTasksLimit?: number;
786
- taskBroker?: TaskBroker;
787
- additionalTemplateFilters?: Record<string, TemplateFilter>;
788
- additionalTemplateGlobals?: Record<string, TemplateGlobal>;
789
- identity?: IdentityApi;
790
- }
791
-
792
- /** @public */
793
- export declare type RunCommandOptions = {
794
- /** command to run */
795
- command: string;
796
- /** arguments to pass the command */
797
- args: string[];
798
- /** options to pass to spawn */
799
- options?: SpawnOptionsWithoutStdio;
800
- /** stream to capture stdout and stderr output */
801
- logStream?: Writable;
802
- };
803
-
804
- /** @public */
805
- export declare class ScaffolderEntitiesProcessor implements CatalogProcessor {
806
- getProcessorName(): string;
807
- private readonly validators;
808
- validateEntityKind(entity: Entity): Promise<boolean>;
809
- postProcessEntity(entity: Entity, _location: LocationSpec, emit: CatalogProcessorEmit): Promise<Entity>;
810
- }
811
-
812
- /**
813
- * Catalog plugin
814
- *
815
- * @alpha
816
- */
817
- export declare const scaffolderPlugin: (options: ScaffolderPluginOptions) => BackendFeature;
818
-
819
- /**
820
- * Catalog plugin options
821
- *
822
- * @alpha
823
- */
824
- export declare type ScaffolderPluginOptions = {
825
- actions?: TemplateAction_2<any>[];
826
- taskWorkers?: number;
827
- taskBroker?: TaskBroker;
828
- additionalTemplateFilters?: Record<string, TemplateFilter>;
829
- additionalTemplateGlobals?: Record<string, TemplateGlobal>;
830
- };
831
-
832
- /**
833
- * SerializedTask
834
- *
835
- * @public
836
- */
837
- export declare type SerializedTask = {
838
- id: string;
839
- spec: TaskSpec;
840
- status: TaskStatus;
841
- createdAt: string;
842
- lastHeartbeatAt?: string;
843
- createdBy?: string;
844
- secrets?: TaskSecrets_2;
845
- };
846
-
847
- /**
848
- * SerializedTaskEvent
849
- *
850
- * @public
851
- */
852
- export declare type SerializedTaskEvent = {
853
- id: number;
854
- taskId: string;
855
- body: JsonObject;
856
- type: TaskEventType;
857
- createdAt: string;
858
- };
859
-
860
- /**
861
- * TaskBroker
862
- *
863
- * @public
864
- */
865
- export declare interface TaskBroker {
866
- claim(): Promise<TaskContext>;
867
- dispatch(options: TaskBrokerDispatchOptions): Promise<TaskBrokerDispatchResult>;
868
- vacuumTasks(options: {
869
- timeoutS: number;
870
- }): Promise<void>;
871
- event$(options: {
872
- taskId: string;
873
- after: number | undefined;
874
- }): Observable<{
875
- events: SerializedTaskEvent[];
876
- }>;
877
- get(taskId: string): Promise<SerializedTask>;
878
- list?(options?: {
879
- createdBy?: string;
880
- }): Promise<{
881
- tasks: SerializedTask[];
882
- }>;
883
- }
884
-
885
- /**
886
- * The options passed to {@link TaskBroker.dispatch}
887
- * Currently a spec and optional secrets
888
- *
889
- * @public
890
- */
891
- export declare type TaskBrokerDispatchOptions = {
892
- spec: TaskSpec;
893
- secrets?: TaskSecrets_2;
894
- createdBy?: string;
895
- };
896
-
897
- /**
898
- * The result of {@link TaskBroker.dispatch}
899
- *
900
- * @public
901
- */
902
- export declare type TaskBrokerDispatchResult = {
903
- taskId: string;
904
- };
905
-
906
- /**
907
- * The state of a completed task.
908
- *
909
- * @public
910
- */
911
- export declare type TaskCompletionState = 'failed' | 'completed';
912
-
913
- /**
914
- * Task
915
- *
916
- * @public
917
- */
918
- export declare interface TaskContext {
919
- spec: TaskSpec;
920
- secrets?: TaskSecrets_2;
921
- createdBy?: string;
922
- done: boolean;
923
- isDryRun?: boolean;
924
- emitLog(message: string, logMetadata?: JsonObject): Promise<void>;
925
- complete(result: TaskCompletionState, metadata?: JsonObject): Promise<void>;
926
- getWorkspaceName(): Promise<string>;
927
- }
928
-
929
- /**
930
- * TaskEventType
931
- *
932
- * @public
933
- */
934
- export declare type TaskEventType = 'completion' | 'log';
935
-
936
- /**
937
- * TaskManager
938
- *
939
- * @public
940
- */
941
- export declare class TaskManager implements TaskContext {
942
- private readonly task;
943
- private readonly storage;
944
- private readonly logger;
945
- private isDone;
946
- private heartbeatTimeoutId?;
947
- static create(task: CurrentClaimedTask, storage: TaskStore, logger: Logger): TaskManager;
948
- private constructor();
949
- get spec(): TaskSpecV1beta3;
950
- get secrets(): TaskSecrets_2 | undefined;
951
- get createdBy(): string | undefined;
952
- getWorkspaceName(): Promise<string>;
953
- get done(): boolean;
954
- emitLog(message: string, logMetadata?: JsonObject): Promise<void>;
955
- complete(result: TaskCompletionState, metadata?: JsonObject): Promise<void>;
956
- private startTimeout;
957
- }
958
-
959
- /**
960
- * @public
961
- * @deprecated Use `TaskSecrets` from `@backstage/plugin-scaffolder-node` instead
962
- */
963
- export declare type TaskSecrets = TaskSecrets_2;
964
-
965
- /**
966
- * The status of each step of the Task
967
- *
968
- * @public
969
- */
970
- export declare type TaskStatus = 'open' | 'processing' | 'failed' | 'cancelled' | 'completed';
971
-
972
- /**
973
- * TaskStore
974
- *
975
- * @public
976
- */
977
- export declare interface TaskStore {
978
- createTask(options: TaskStoreCreateTaskOptions): Promise<TaskStoreCreateTaskResult>;
979
- getTask(taskId: string): Promise<SerializedTask>;
980
- claimTask(): Promise<SerializedTask | undefined>;
981
- completeTask(options: {
982
- taskId: string;
983
- status: TaskStatus;
984
- eventBody: JsonObject;
985
- }): Promise<void>;
986
- heartbeatTask(taskId: string): Promise<void>;
987
- listStaleTasks(options: {
988
- timeoutS: number;
989
- }): Promise<{
990
- tasks: {
991
- taskId: string;
992
- }[];
993
- }>;
994
- list?(options: {
995
- createdBy?: string;
996
- }): Promise<{
997
- tasks: SerializedTask[];
998
- }>;
999
- emitLogEvent({ taskId, body }: TaskStoreEmitOptions): Promise<void>;
1000
- listEvents({ taskId, after, }: TaskStoreListEventsOptions): Promise<{
1001
- events: SerializedTaskEvent[];
1002
- }>;
1003
- shutdownTask?({ taskId }: TaskStoreShutDownTaskOptions): Promise<void>;
1004
- }
1005
-
1006
- /**
1007
- * The options passed to {@link TaskStore.createTask}
1008
- * @public
1009
- */
1010
- export declare type TaskStoreCreateTaskOptions = {
1011
- spec: TaskSpec;
1012
- createdBy?: string;
1013
- secrets?: TaskSecrets_2;
1014
- };
1015
-
1016
- /**
1017
- * The response from {@link TaskStore.createTask}
1018
- * @public
1019
- */
1020
- export declare type TaskStoreCreateTaskResult = {
1021
- taskId: string;
1022
- };
1023
-
1024
- /**
1025
- * TaskStoreEmitOptions
1026
- *
1027
- * @public
1028
- */
1029
- export declare type TaskStoreEmitOptions<TBody = JsonObject> = {
1030
- taskId: string;
1031
- body: TBody;
1032
- };
1033
-
1034
- /**
1035
- * TaskStoreListEventsOptions
1036
- *
1037
- * @public
1038
- */
1039
- export declare type TaskStoreListEventsOptions = {
1040
- taskId: string;
1041
- after?: number | undefined;
1042
- };
1043
-
1044
- /**
1045
- * TaskStoreShutDownTaskOptions
1046
- *
1047
- * @public
1048
- */
1049
- export declare type TaskStoreShutDownTaskOptions = {
1050
- taskId: string;
1051
- };
1052
-
1053
- /**
1054
- * TaskWorker
1055
- *
1056
- * @public
1057
- */
1058
- export declare class TaskWorker {
1059
- private readonly options;
1060
- private constructor();
1061
- private taskQueue;
1062
- static create(options: CreateWorkerOptions): Promise<TaskWorker>;
1063
- start(): void;
1064
- protected onReadyToClaimTask(): Promise<void>;
1065
- runOneTask(task: TaskContext): Promise<void>;
1066
- }
1067
-
1068
- /**
1069
- * @public
1070
- * @deprecated Use `TemplateAction` from `@backstage/plugin-scaffolder-node` instead
1071
- */
1072
- export declare type TemplateAction<TInput extends JsonObject> = TemplateAction_2<TInput>;
1073
-
1074
- /**
1075
- * Registry of all registered template actions.
1076
- * @public
1077
- */
1078
- export declare class TemplateActionRegistry {
1079
- private readonly actions;
1080
- register<TInput extends JsonObject>(action: TemplateAction_2<TInput>): void;
1081
- get(actionId: string): TemplateAction_2<JsonObject>;
1082
- list(): TemplateAction_2<JsonObject>[];
1083
- }
1084
-
1085
- /** @public */
1086
- export declare type TemplateFilter = (...args: JsonValue[]) => JsonValue | undefined;
1087
-
1088
- /** @public */
1089
- export declare type TemplateGlobal = ((...args: JsonValue[]) => JsonValue | undefined) | JsonValue;
1090
-
1091
- export { }