@backstage/plugin-scaffolder-node 0.1.1 → 0.1.2-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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,28 @@
1
1
  # @backstage/plugin-scaffolder-node
2
2
 
3
+ ## 0.1.2-next.1
4
+
5
+ ### Patch Changes
6
+
7
+ - a7eb36c6e38: Improve type-check for scaffolder output parameters
8
+ - 1e4f5e91b8e: Bump `zod` and `zod-to-json-schema` dependencies.
9
+ - Updated dependencies
10
+ - @backstage/plugin-scaffolder-common@1.2.7-next.1
11
+ - @backstage/backend-plugin-api@0.5.1-next.1
12
+ - @backstage/catalog-model@1.2.1
13
+ - @backstage/types@1.0.2
14
+
15
+ ## 0.1.2-next.0
16
+
17
+ ### Patch Changes
18
+
19
+ - e27ddc36dad: Added a possibility to cancel the running task (executing of a scaffolder template)
20
+ - Updated dependencies
21
+ - @backstage/plugin-scaffolder-common@1.2.7-next.0
22
+ - @backstage/backend-plugin-api@0.5.1-next.0
23
+ - @backstage/catalog-model@1.2.1
24
+ - @backstage/types@1.0.2
25
+
3
26
  ## 0.1.1
4
27
 
5
28
  ### Patch Changes
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@backstage/plugin-scaffolder-node",
3
- "version": "0.1.1",
3
+ "version": "0.1.2-next.1",
4
4
  "main": "../dist/index.cjs.js",
5
5
  "types": "../dist/index.alpha.d.ts"
6
6
  }
@@ -8,7 +8,6 @@
8
8
 
9
9
  import { ExtensionPoint } from '@backstage/backend-plugin-api';
10
10
  import { JsonObject } from '@backstage/types';
11
- import { JsonValue } from '@backstage/types';
12
11
  import { Logger } from 'winston';
13
12
  import { Schema } from 'jsonschema';
14
13
  import { TemplateInfo } from '@backstage/plugin-scaffolder-common';
@@ -20,13 +19,13 @@ import { z } from 'zod';
20
19
  * ActionContext is passed into scaffolder actions.
21
20
  * @public
22
21
  */
23
- export declare type ActionContext<TActionInput extends JsonObject> = {
22
+ export declare type ActionContext<TActionInput extends JsonObject, TActionOutput extends JsonObject = JsonObject> = {
24
23
  logger: Logger;
25
24
  logStream: Writable;
26
25
  secrets?: TaskSecrets;
27
26
  workspacePath: string;
28
27
  input: TActionInput;
29
- output(name: string, value: JsonValue): void;
28
+ output(name: keyof TActionOutput, value: TActionOutput[keyof TActionOutput]): void;
30
29
  /**
31
30
  * Creates a temporary directory for use by the action, which is then cleaned up automatically.
32
31
  */
@@ -50,6 +49,10 @@ export declare type ActionContext<TActionInput extends JsonObject> = {
50
49
  */
51
50
  ref?: string;
52
51
  };
52
+ /**
53
+ * Implement the signal to make your custom step abortable https://developer.mozilla.org/en-US/docs/Web/API/AbortController/signal
54
+ */
55
+ signal?: AbortSignal;
53
56
  };
54
57
 
55
58
  /**
@@ -57,7 +60,7 @@ export declare type ActionContext<TActionInput extends JsonObject> = {
57
60
  * Will convert zod schemas to json schemas for use throughout the system.
58
61
  * @public
59
62
  */
60
- export declare const createTemplateAction: <TParams, TInputSchema extends z.ZodType<any, z.ZodTypeDef, any> | Schema = {}, TOutputSchema extends z.ZodType<any, z.ZodTypeDef, any> | Schema = {}, TActionInput = TInputSchema extends z.ZodType<any, any, infer IReturn> ? IReturn : TParams>(action: TemplateActionOptions<TActionInput, TInputSchema, TOutputSchema>) => TemplateAction<TActionInput>;
63
+ export declare const createTemplateAction: <TInputParams extends JsonObject = JsonObject, TOutputParams extends JsonObject = JsonObject, TInputSchema extends z.ZodType<any, z.ZodTypeDef, any> | Schema = {}, TOutputSchema extends z.ZodType<any, z.ZodTypeDef, any> | Schema = {}, TActionInput = TInputSchema extends z.ZodType<any, any, infer IReturn> ? IReturn : TInputParams, TActionOutput = TOutputSchema extends z.ZodType<any, any, infer IReturn_1> ? IReturn_1 : TOutputParams>(action: TemplateActionOptions<TActionInput, TActionOutput, TInputSchema, TOutputSchema>) => TemplateAction<TActionInput, TActionOutput>;
61
64
 
62
65
  /**
63
66
  * Extension point for managing scaffolder actions.
@@ -85,7 +88,7 @@ export declare type TaskSecrets = Record<string, string> & {
85
88
  };
86
89
 
87
90
  /** @public */
88
- export declare type TemplateAction<TActionInput = unknown> = {
91
+ export declare type TemplateAction<TActionInput = unknown, TActionOutput = JsonObject> = {
89
92
  id: string;
90
93
  description?: string;
91
94
  examples?: {
@@ -97,11 +100,11 @@ export declare type TemplateAction<TActionInput = unknown> = {
97
100
  input?: Schema;
98
101
  output?: Schema;
99
102
  };
100
- handler: (ctx: ActionContext<TActionInput>) => Promise<void>;
103
+ handler: (ctx: ActionContext<TActionInput, TActionOutput>) => Promise<void>;
101
104
  };
102
105
 
103
106
  /** @public */
104
- export declare type TemplateActionOptions<TActionInput = {}, TInputSchema extends Schema | z.ZodType = {}, TOutputSchema extends Schema | z.ZodType = {}> = {
107
+ export declare type TemplateActionOptions<TActionInput = {}, TActionOutput = {}, TInputSchema extends Schema | z.ZodType = {}, TOutputSchema extends Schema | z.ZodType = {}> = {
105
108
  id: string;
106
109
  description?: string;
107
110
  examples?: {
@@ -113,7 +116,7 @@ export declare type TemplateActionOptions<TActionInput = {}, TInputSchema extend
113
116
  input?: TInputSchema;
114
117
  output?: TOutputSchema;
115
118
  };
116
- handler: (ctx: ActionContext<TActionInput>) => Promise<void>;
119
+ handler: (ctx: ActionContext<TActionInput, TActionOutput>) => Promise<void>;
117
120
  };
118
121
 
119
122
  export { }
@@ -8,7 +8,6 @@
8
8
 
9
9
  import { ExtensionPoint } from '@backstage/backend-plugin-api';
10
10
  import { JsonObject } from '@backstage/types';
11
- import { JsonValue } from '@backstage/types';
12
11
  import { Logger } from 'winston';
13
12
  import { Schema } from 'jsonschema';
14
13
  import { TemplateInfo } from '@backstage/plugin-scaffolder-common';
@@ -20,13 +19,13 @@ import { z } from 'zod';
20
19
  * ActionContext is passed into scaffolder actions.
21
20
  * @public
22
21
  */
23
- export declare type ActionContext<TActionInput extends JsonObject> = {
22
+ export declare type ActionContext<TActionInput extends JsonObject, TActionOutput extends JsonObject = JsonObject> = {
24
23
  logger: Logger;
25
24
  logStream: Writable;
26
25
  secrets?: TaskSecrets;
27
26
  workspacePath: string;
28
27
  input: TActionInput;
29
- output(name: string, value: JsonValue): void;
28
+ output(name: keyof TActionOutput, value: TActionOutput[keyof TActionOutput]): void;
30
29
  /**
31
30
  * Creates a temporary directory for use by the action, which is then cleaned up automatically.
32
31
  */
@@ -50,6 +49,10 @@ export declare type ActionContext<TActionInput extends JsonObject> = {
50
49
  */
51
50
  ref?: string;
52
51
  };
52
+ /**
53
+ * Implement the signal to make your custom step abortable https://developer.mozilla.org/en-US/docs/Web/API/AbortController/signal
54
+ */
55
+ signal?: AbortSignal;
53
56
  };
54
57
 
55
58
  /**
@@ -57,7 +60,7 @@ export declare type ActionContext<TActionInput extends JsonObject> = {
57
60
  * Will convert zod schemas to json schemas for use throughout the system.
58
61
  * @public
59
62
  */
60
- export declare const createTemplateAction: <TParams, TInputSchema extends z.ZodType<any, z.ZodTypeDef, any> | Schema = {}, TOutputSchema extends z.ZodType<any, z.ZodTypeDef, any> | Schema = {}, TActionInput = TInputSchema extends z.ZodType<any, any, infer IReturn> ? IReturn : TParams>(action: TemplateActionOptions<TActionInput, TInputSchema, TOutputSchema>) => TemplateAction<TActionInput>;
63
+ export declare const createTemplateAction: <TInputParams extends JsonObject = JsonObject, TOutputParams extends JsonObject = JsonObject, TInputSchema extends z.ZodType<any, z.ZodTypeDef, any> | Schema = {}, TOutputSchema extends z.ZodType<any, z.ZodTypeDef, any> | Schema = {}, TActionInput = TInputSchema extends z.ZodType<any, any, infer IReturn> ? IReturn : TInputParams, TActionOutput = TOutputSchema extends z.ZodType<any, any, infer IReturn_1> ? IReturn_1 : TOutputParams>(action: TemplateActionOptions<TActionInput, TActionOutput, TInputSchema, TOutputSchema>) => TemplateAction<TActionInput, TActionOutput>;
61
64
 
62
65
  /* Excluded from this release type: ScaffolderActionsExtensionPoint */
63
66
 
@@ -73,7 +76,7 @@ export declare type TaskSecrets = Record<string, string> & {
73
76
  };
74
77
 
75
78
  /** @public */
76
- export declare type TemplateAction<TActionInput = unknown> = {
79
+ export declare type TemplateAction<TActionInput = unknown, TActionOutput = JsonObject> = {
77
80
  id: string;
78
81
  description?: string;
79
82
  examples?: {
@@ -85,11 +88,11 @@ export declare type TemplateAction<TActionInput = unknown> = {
85
88
  input?: Schema;
86
89
  output?: Schema;
87
90
  };
88
- handler: (ctx: ActionContext<TActionInput>) => Promise<void>;
91
+ handler: (ctx: ActionContext<TActionInput, TActionOutput>) => Promise<void>;
89
92
  };
90
93
 
91
94
  /** @public */
92
- export declare type TemplateActionOptions<TActionInput = {}, TInputSchema extends Schema | z.ZodType = {}, TOutputSchema extends Schema | z.ZodType = {}> = {
95
+ export declare type TemplateActionOptions<TActionInput = {}, TActionOutput = {}, TInputSchema extends Schema | z.ZodType = {}, TOutputSchema extends Schema | z.ZodType = {}> = {
93
96
  id: string;
94
97
  description?: string;
95
98
  examples?: {
@@ -101,7 +104,7 @@ export declare type TemplateActionOptions<TActionInput = {}, TInputSchema extend
101
104
  input?: TInputSchema;
102
105
  output?: TOutputSchema;
103
106
  };
104
- handler: (ctx: ActionContext<TActionInput>) => Promise<void>;
107
+ handler: (ctx: ActionContext<TActionInput, TActionOutput>) => Promise<void>;
105
108
  };
106
109
 
107
110
  export { }
package/dist/index.cjs.js CHANGED
@@ -13,7 +13,7 @@ const createTemplateAction = (action) => {
13
13
  var _a, _b, _c, _d;
14
14
  const inputSchema = ((_a = action.schema) == null ? void 0 : _a.input) && "safeParseAsync" in action.schema.input ? zodToJsonSchema__default["default"](action.schema.input) : (_b = action.schema) == null ? void 0 : _b.input;
15
15
  const outputSchema = ((_c = action.schema) == null ? void 0 : _c.output) && "safeParseAsync" in action.schema.output ? zodToJsonSchema__default["default"](action.schema.output) : (_d = action.schema) == null ? void 0 : _d.output;
16
- const templateAction = {
16
+ return {
17
17
  ...action,
18
18
  schema: {
19
19
  ...action.schema,
@@ -21,7 +21,6 @@ const createTemplateAction = (action) => {
21
21
  output: outputSchema
22
22
  }
23
23
  };
24
- return templateAction;
25
24
  };
26
25
 
27
26
  const scaffolderActionsExtensionPoint = backendPluginApi.createExtensionPoint({
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs.js","sources":["../src/actions/createTemplateAction.ts","../src/extensions.ts"],"sourcesContent":["/*\n * Copyright 2021 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { ActionContext, TemplateAction } from './types';\nimport { z } from 'zod';\nimport { Schema } from 'jsonschema';\nimport zodToJsonSchema from 'zod-to-json-schema';\n\n/** @public */\nexport type TemplateActionOptions<\n TActionInput = {},\n TInputSchema extends Schema | z.ZodType = {},\n TOutputSchema extends Schema | z.ZodType = {},\n> = {\n id: string;\n description?: string;\n examples?: { description: string; example: string }[];\n supportsDryRun?: boolean;\n schema?: {\n input?: TInputSchema;\n output?: TOutputSchema;\n };\n handler: (ctx: ActionContext<TActionInput>) => Promise<void>;\n};\n\n/**\n * This function is used to create new template actions to get type safety.\n * Will convert zod schemas to json schemas for use throughout the system.\n * @public\n */\nexport const createTemplateAction = <\n TParams,\n TInputSchema extends Schema | z.ZodType = {},\n TOutputSchema extends Schema | z.ZodType = {},\n TActionInput = TInputSchema extends z.ZodType<any, any, infer IReturn>\n ? IReturn\n : TParams,\n>(\n action: TemplateActionOptions<TActionInput, TInputSchema, TOutputSchema>,\n): TemplateAction<TActionInput> => {\n const inputSchema =\n action.schema?.input && 'safeParseAsync' in action.schema.input\n ? zodToJsonSchema(action.schema.input)\n : action.schema?.input;\n\n const outputSchema =\n action.schema?.output && 'safeParseAsync' in action.schema.output\n ? zodToJsonSchema(action.schema.output)\n : action.schema?.output;\n\n const templateAction = {\n ...action,\n schema: {\n ...action.schema,\n input: inputSchema,\n output: outputSchema,\n },\n };\n\n return templateAction;\n};\n","/*\n * Copyright 2022 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { createExtensionPoint } from '@backstage/backend-plugin-api';\nimport { TemplateAction } from './actions';\n\n/**\n * Extension point for managing scaffolder actions.\n *\n * @alpha\n */\nexport interface ScaffolderActionsExtensionPoint {\n addActions(...actions: TemplateAction<any>[]): void;\n}\n\n/**\n * Extension point for managing scaffolder actions.\n *\n * @alpha\n */\nexport const scaffolderActionsExtensionPoint =\n createExtensionPoint<ScaffolderActionsExtensionPoint>({\n id: 'scaffolder.actions',\n });\n"],"names":["zodToJsonSchema","createExtensionPoint"],"mappings":";;;;;;;;;;;AA2Ca,MAAA,oBAAA,GAAuB,CAQlC,MACiC,KAAA;AApDnC,EAAA,IAAA,EAAA,EAAA,EAAA,EAAA,EAAA,EAAA,EAAA,CAAA;AAqDE,EAAA,MAAM,gBACJ,EAAO,GAAA,MAAA,CAAA,MAAA,KAAP,IAAe,GAAA,KAAA,CAAA,GAAA,EAAA,CAAA,KAAA,KAAS,oBAAoB,MAAO,CAAA,MAAA,CAAO,KACtD,GAAAA,mCAAA,CAAgB,OAAO,MAAO,CAAA,KAAK,CACnC,GAAA,CAAA,EAAA,GAAA,MAAA,CAAO,WAAP,IAAe,GAAA,KAAA,CAAA,GAAA,EAAA,CAAA,KAAA,CAAA;AAErB,EAAA,MAAM,iBACJ,EAAO,GAAA,MAAA,CAAA,MAAA,KAAP,IAAe,GAAA,KAAA,CAAA,GAAA,EAAA,CAAA,MAAA,KAAU,oBAAoB,MAAO,CAAA,MAAA,CAAO,MACvD,GAAAA,mCAAA,CAAgB,OAAO,MAAO,CAAA,MAAM,CACpC,GAAA,CAAA,EAAA,GAAA,MAAA,CAAO,WAAP,IAAe,GAAA,KAAA,CAAA,GAAA,EAAA,CAAA,MAAA,CAAA;AAErB,EAAA,MAAM,cAAiB,GAAA;AAAA,IACrB,GAAG,MAAA;AAAA,IACH,MAAQ,EAAA;AAAA,MACN,GAAG,MAAO,CAAA,MAAA;AAAA,MACV,KAAO,EAAA,WAAA;AAAA,MACP,MAAQ,EAAA,YAAA;AAAA,KACV;AAAA,GACF,CAAA;AAEA,EAAO,OAAA,cAAA,CAAA;AACT;;ACxCO,MAAM,kCACXC,qCAAsD,CAAA;AAAA,EACpD,EAAI,EAAA,oBAAA;AACN,CAAC;;;;;"}
1
+ {"version":3,"file":"index.cjs.js","sources":["../src/actions/createTemplateAction.ts","../src/extensions.ts"],"sourcesContent":["/*\n * Copyright 2021 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { ActionContext, TemplateAction } from './types';\nimport { z } from 'zod';\nimport { Schema } from 'jsonschema';\nimport zodToJsonSchema from 'zod-to-json-schema';\nimport { JsonObject } from '@backstage/types';\n\n/** @public */\nexport type TemplateActionOptions<\n TActionInput = {},\n TActionOutput = {},\n TInputSchema extends Schema | z.ZodType = {},\n TOutputSchema extends Schema | z.ZodType = {},\n> = {\n id: string;\n description?: string;\n examples?: { description: string; example: string }[];\n supportsDryRun?: boolean;\n schema?: {\n input?: TInputSchema;\n output?: TOutputSchema;\n };\n handler: (ctx: ActionContext<TActionInput, TActionOutput>) => Promise<void>;\n};\n\n/**\n * This function is used to create new template actions to get type safety.\n * Will convert zod schemas to json schemas for use throughout the system.\n * @public\n */\nexport const createTemplateAction = <\n TInputParams extends JsonObject = JsonObject,\n TOutputParams extends JsonObject = JsonObject,\n TInputSchema extends Schema | z.ZodType = {},\n TOutputSchema extends Schema | z.ZodType = {},\n TActionInput = TInputSchema extends z.ZodType<any, any, infer IReturn>\n ? IReturn\n : TInputParams,\n TActionOutput = TOutputSchema extends z.ZodType<any, any, infer IReturn>\n ? IReturn\n : TOutputParams,\n>(\n action: TemplateActionOptions<\n TActionInput,\n TActionOutput,\n TInputSchema,\n TOutputSchema\n >,\n): TemplateAction<TActionInput, TActionOutput> => {\n const inputSchema =\n action.schema?.input && 'safeParseAsync' in action.schema.input\n ? zodToJsonSchema(action.schema.input)\n : action.schema?.input;\n\n const outputSchema =\n action.schema?.output && 'safeParseAsync' in action.schema.output\n ? zodToJsonSchema(action.schema.output)\n : action.schema?.output;\n\n return {\n ...action,\n schema: {\n ...action.schema,\n input: inputSchema,\n output: outputSchema,\n },\n };\n};\n","/*\n * Copyright 2022 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { createExtensionPoint } from '@backstage/backend-plugin-api';\nimport { TemplateAction } from './actions';\n\n/**\n * Extension point for managing scaffolder actions.\n *\n * @alpha\n */\nexport interface ScaffolderActionsExtensionPoint {\n addActions(...actions: TemplateAction<any>[]): void;\n}\n\n/**\n * Extension point for managing scaffolder actions.\n *\n * @alpha\n */\nexport const scaffolderActionsExtensionPoint =\n createExtensionPoint<ScaffolderActionsExtensionPoint>({\n id: 'scaffolder.actions',\n });\n"],"names":["zodToJsonSchema","createExtensionPoint"],"mappings":";;;;;;;;;;;AA6Ca,MAAA,oBAAA,GAAuB,CAYlC,MAMgD,KAAA;AA/DlD,EAAA,IAAA,EAAA,EAAA,EAAA,EAAA,EAAA,EAAA,EAAA,CAAA;AAgEE,EAAA,MAAM,gBACJ,EAAO,GAAA,MAAA,CAAA,MAAA,KAAP,IAAe,GAAA,KAAA,CAAA,GAAA,EAAA,CAAA,KAAA,KAAS,oBAAoB,MAAO,CAAA,MAAA,CAAO,KACtD,GAAAA,mCAAA,CAAgB,OAAO,MAAO,CAAA,KAAK,CACnC,GAAA,CAAA,EAAA,GAAA,MAAA,CAAO,WAAP,IAAe,GAAA,KAAA,CAAA,GAAA,EAAA,CAAA,KAAA,CAAA;AAErB,EAAA,MAAM,iBACJ,EAAO,GAAA,MAAA,CAAA,MAAA,KAAP,IAAe,GAAA,KAAA,CAAA,GAAA,EAAA,CAAA,MAAA,KAAU,oBAAoB,MAAO,CAAA,MAAA,CAAO,MACvD,GAAAA,mCAAA,CAAgB,OAAO,MAAO,CAAA,MAAM,CACpC,GAAA,CAAA,EAAA,GAAA,MAAA,CAAO,WAAP,IAAe,GAAA,KAAA,CAAA,GAAA,EAAA,CAAA,MAAA,CAAA;AAErB,EAAO,OAAA;AAAA,IACL,GAAG,MAAA;AAAA,IACH,MAAQ,EAAA;AAAA,MACN,GAAG,MAAO,CAAA,MAAA;AAAA,MACV,KAAO,EAAA,WAAA;AAAA,MACP,MAAQ,EAAA,YAAA;AAAA,KACV;AAAA,GACF,CAAA;AACF;;ACjDO,MAAM,kCACXC,qCAAsD,CAAA;AAAA,EACpD,EAAI,EAAA,oBAAA;AACN,CAAC;;;;;"}
package/dist/index.d.ts CHANGED
@@ -8,7 +8,6 @@
8
8
 
9
9
  import { ExtensionPoint } from '@backstage/backend-plugin-api';
10
10
  import { JsonObject } from '@backstage/types';
11
- import { JsonValue } from '@backstage/types';
12
11
  import { Logger } from 'winston';
13
12
  import { Schema } from 'jsonschema';
14
13
  import { TemplateInfo } from '@backstage/plugin-scaffolder-common';
@@ -20,13 +19,13 @@ import { z } from 'zod';
20
19
  * ActionContext is passed into scaffolder actions.
21
20
  * @public
22
21
  */
23
- export declare type ActionContext<TActionInput extends JsonObject> = {
22
+ export declare type ActionContext<TActionInput extends JsonObject, TActionOutput extends JsonObject = JsonObject> = {
24
23
  logger: Logger;
25
24
  logStream: Writable;
26
25
  secrets?: TaskSecrets;
27
26
  workspacePath: string;
28
27
  input: TActionInput;
29
- output(name: string, value: JsonValue): void;
28
+ output(name: keyof TActionOutput, value: TActionOutput[keyof TActionOutput]): void;
30
29
  /**
31
30
  * Creates a temporary directory for use by the action, which is then cleaned up automatically.
32
31
  */
@@ -50,6 +49,10 @@ export declare type ActionContext<TActionInput extends JsonObject> = {
50
49
  */
51
50
  ref?: string;
52
51
  };
52
+ /**
53
+ * Implement the signal to make your custom step abortable https://developer.mozilla.org/en-US/docs/Web/API/AbortController/signal
54
+ */
55
+ signal?: AbortSignal;
53
56
  };
54
57
 
55
58
  /**
@@ -57,7 +60,7 @@ export declare type ActionContext<TActionInput extends JsonObject> = {
57
60
  * Will convert zod schemas to json schemas for use throughout the system.
58
61
  * @public
59
62
  */
60
- export declare const createTemplateAction: <TParams, TInputSchema extends z.ZodType<any, z.ZodTypeDef, any> | Schema = {}, TOutputSchema extends z.ZodType<any, z.ZodTypeDef, any> | Schema = {}, TActionInput = TInputSchema extends z.ZodType<any, any, infer IReturn> ? IReturn : TParams>(action: TemplateActionOptions<TActionInput, TInputSchema, TOutputSchema>) => TemplateAction<TActionInput>;
63
+ export declare const createTemplateAction: <TInputParams extends JsonObject = JsonObject, TOutputParams extends JsonObject = JsonObject, TInputSchema extends z.ZodType<any, z.ZodTypeDef, any> | Schema = {}, TOutputSchema extends z.ZodType<any, z.ZodTypeDef, any> | Schema = {}, TActionInput = TInputSchema extends z.ZodType<any, any, infer IReturn> ? IReturn : TInputParams, TActionOutput = TOutputSchema extends z.ZodType<any, any, infer IReturn_1> ? IReturn_1 : TOutputParams>(action: TemplateActionOptions<TActionInput, TActionOutput, TInputSchema, TOutputSchema>) => TemplateAction<TActionInput, TActionOutput>;
61
64
 
62
65
  /* Excluded from this release type: ScaffolderActionsExtensionPoint */
63
66
 
@@ -73,7 +76,7 @@ export declare type TaskSecrets = Record<string, string> & {
73
76
  };
74
77
 
75
78
  /** @public */
76
- export declare type TemplateAction<TActionInput = unknown> = {
79
+ export declare type TemplateAction<TActionInput = unknown, TActionOutput = JsonObject> = {
77
80
  id: string;
78
81
  description?: string;
79
82
  examples?: {
@@ -85,11 +88,11 @@ export declare type TemplateAction<TActionInput = unknown> = {
85
88
  input?: Schema;
86
89
  output?: Schema;
87
90
  };
88
- handler: (ctx: ActionContext<TActionInput>) => Promise<void>;
91
+ handler: (ctx: ActionContext<TActionInput, TActionOutput>) => Promise<void>;
89
92
  };
90
93
 
91
94
  /** @public */
92
- export declare type TemplateActionOptions<TActionInput = {}, TInputSchema extends Schema | z.ZodType = {}, TOutputSchema extends Schema | z.ZodType = {}> = {
95
+ export declare type TemplateActionOptions<TActionInput = {}, TActionOutput = {}, TInputSchema extends Schema | z.ZodType = {}, TOutputSchema extends Schema | z.ZodType = {}> = {
93
96
  id: string;
94
97
  description?: string;
95
98
  examples?: {
@@ -101,7 +104,7 @@ export declare type TemplateActionOptions<TActionInput = {}, TInputSchema extend
101
104
  input?: TInputSchema;
102
105
  output?: TOutputSchema;
103
106
  };
104
- handler: (ctx: ActionContext<TActionInput>) => Promise<void>;
107
+ handler: (ctx: ActionContext<TActionInput, TActionOutput>) => Promise<void>;
105
108
  };
106
109
 
107
110
  export { }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@backstage/plugin-scaffolder-node",
3
3
  "description": "The plugin-scaffolder-node module for @backstage/plugin-scaffolder-backend",
4
- "version": "0.1.1",
4
+ "version": "0.1.2-next.1",
5
5
  "main": "dist/index.cjs.js",
6
6
  "types": "dist/index.d.ts",
7
7
  "license": "Apache-2.0",
@@ -24,17 +24,17 @@
24
24
  "postpack": "backstage-cli package postpack"
25
25
  },
26
26
  "dependencies": {
27
- "@backstage/backend-plugin-api": "^0.5.0",
27
+ "@backstage/backend-plugin-api": "^0.5.1-next.1",
28
28
  "@backstage/catalog-model": "^1.2.1",
29
- "@backstage/plugin-scaffolder-common": "^1.2.6",
29
+ "@backstage/plugin-scaffolder-common": "^1.2.7-next.1",
30
30
  "@backstage/types": "^1.0.2",
31
31
  "jsonschema": "^1.2.6",
32
32
  "winston": "^3.2.1",
33
- "zod": "~3.18.0",
34
- "zod-to-json-schema": "~3.18.0"
33
+ "zod": "^3.21.4",
34
+ "zod-to-json-schema": "^3.20.4"
35
35
  },
36
36
  "devDependencies": {
37
- "@backstage/cli": "^0.22.4"
37
+ "@backstage/cli": "^0.22.6-next.1"
38
38
  },
39
39
  "files": [
40
40
  "alpha",