@backstage/plugin-scaffolder-node 0.1.1-next.0 → 0.1.1-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,15 @@
1
1
  # @backstage/plugin-scaffolder-node
2
2
 
3
+ ## 0.1.1-next.1
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies
8
+ - @backstage/backend-plugin-api@0.4.1-next.1
9
+ - @backstage/catalog-model@1.2.1-next.1
10
+ - @backstage/types@1.0.2
11
+ - @backstage/plugin-scaffolder-common@1.2.6-next.1
12
+
3
13
  ## 0.1.1-next.0
4
14
 
5
15
  ### Patch Changes
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@backstage/plugin-scaffolder-node",
3
- "version": "0.1.1-next.0",
3
+ "version": "0.1.1-next.1",
4
4
  "main": "../dist/index.cjs.js",
5
5
  "types": "../dist/index.alpha.d.ts"
6
6
  }
@@ -14,17 +14,18 @@ import { Schema } from 'jsonschema';
14
14
  import { TemplateInfo } from '@backstage/plugin-scaffolder-common';
15
15
  import { UserEntity } from '@backstage/catalog-model';
16
16
  import { Writable } from 'stream';
17
+ import { z } from 'zod';
17
18
 
18
19
  /**
19
20
  * ActionContext is passed into scaffolder actions.
20
21
  * @public
21
22
  */
22
- export declare type ActionContext<TInput extends JsonObject> = {
23
+ export declare type ActionContext<TActionInput extends JsonObject> = {
23
24
  logger: Logger;
24
25
  logStream: Writable;
25
26
  secrets?: TaskSecrets;
26
27
  workspacePath: string;
27
- input: TInput;
28
+ input: TActionInput;
28
29
  output(name: string, value: JsonValue): void;
29
30
  /**
30
31
  * Creates a temporary directory for use by the action, which is then cleaned up automatically.
@@ -53,10 +54,10 @@ export declare type ActionContext<TInput extends JsonObject> = {
53
54
 
54
55
  /**
55
56
  * This function is used to create new template actions to get type safety.
56
- *
57
+ * Will convert zod schemas to json schemas for use throughout the system.
57
58
  * @public
58
59
  */
59
- export declare const createTemplateAction: <TInput extends JsonObject>(templateAction: TemplateAction<TInput>) => TemplateAction<TInput>;
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>;
60
61
 
61
62
  /**
62
63
  * Extension point for managing scaffolder actions.
@@ -84,7 +85,7 @@ export declare type TaskSecrets = Record<string, string> & {
84
85
  };
85
86
 
86
87
  /** @public */
87
- export declare type TemplateAction<TInput extends JsonObject> = {
88
+ export declare type TemplateAction<TActionInput = unknown> = {
88
89
  id: string;
89
90
  description?: string;
90
91
  examples?: {
@@ -96,7 +97,23 @@ export declare type TemplateAction<TInput extends JsonObject> = {
96
97
  input?: Schema;
97
98
  output?: Schema;
98
99
  };
99
- handler: (ctx: ActionContext<TInput>) => Promise<void>;
100
+ handler: (ctx: ActionContext<TActionInput>) => Promise<void>;
101
+ };
102
+
103
+ /** @public */
104
+ export declare type TemplateActionOptions<TActionInput = {}, TInputSchema extends Schema | z.ZodType = {}, TOutputSchema extends Schema | z.ZodType = {}> = {
105
+ id: string;
106
+ description?: string;
107
+ examples?: {
108
+ description: string;
109
+ example: string;
110
+ }[];
111
+ supportsDryRun?: boolean;
112
+ schema?: {
113
+ input?: TInputSchema;
114
+ output?: TOutputSchema;
115
+ };
116
+ handler: (ctx: ActionContext<TActionInput>) => Promise<void>;
100
117
  };
101
118
 
102
119
  export { }
@@ -14,17 +14,18 @@ import { Schema } from 'jsonschema';
14
14
  import { TemplateInfo } from '@backstage/plugin-scaffolder-common';
15
15
  import { UserEntity } from '@backstage/catalog-model';
16
16
  import { Writable } from 'stream';
17
+ import { z } from 'zod';
17
18
 
18
19
  /**
19
20
  * ActionContext is passed into scaffolder actions.
20
21
  * @public
21
22
  */
22
- export declare type ActionContext<TInput extends JsonObject> = {
23
+ export declare type ActionContext<TActionInput extends JsonObject> = {
23
24
  logger: Logger;
24
25
  logStream: Writable;
25
26
  secrets?: TaskSecrets;
26
27
  workspacePath: string;
27
- input: TInput;
28
+ input: TActionInput;
28
29
  output(name: string, value: JsonValue): void;
29
30
  /**
30
31
  * Creates a temporary directory for use by the action, which is then cleaned up automatically.
@@ -53,10 +54,10 @@ export declare type ActionContext<TInput extends JsonObject> = {
53
54
 
54
55
  /**
55
56
  * This function is used to create new template actions to get type safety.
56
- *
57
+ * Will convert zod schemas to json schemas for use throughout the system.
57
58
  * @public
58
59
  */
59
- export declare const createTemplateAction: <TInput extends JsonObject>(templateAction: TemplateAction<TInput>) => TemplateAction<TInput>;
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>;
60
61
 
61
62
  /* Excluded from this release type: ScaffolderActionsExtensionPoint */
62
63
 
@@ -72,7 +73,7 @@ export declare type TaskSecrets = Record<string, string> & {
72
73
  };
73
74
 
74
75
  /** @public */
75
- export declare type TemplateAction<TInput extends JsonObject> = {
76
+ export declare type TemplateAction<TActionInput = unknown> = {
76
77
  id: string;
77
78
  description?: string;
78
79
  examples?: {
@@ -84,7 +85,23 @@ export declare type TemplateAction<TInput extends JsonObject> = {
84
85
  input?: Schema;
85
86
  output?: Schema;
86
87
  };
87
- handler: (ctx: ActionContext<TInput>) => Promise<void>;
88
+ handler: (ctx: ActionContext<TActionInput>) => Promise<void>;
89
+ };
90
+
91
+ /** @public */
92
+ export declare type TemplateActionOptions<TActionInput = {}, TInputSchema extends Schema | z.ZodType = {}, TOutputSchema extends Schema | z.ZodType = {}> = {
93
+ id: string;
94
+ description?: string;
95
+ examples?: {
96
+ description: string;
97
+ example: string;
98
+ }[];
99
+ supportsDryRun?: boolean;
100
+ schema?: {
101
+ input?: TInputSchema;
102
+ output?: TOutputSchema;
103
+ };
104
+ handler: (ctx: ActionContext<TActionInput>) => Promise<void>;
88
105
  };
89
106
 
90
107
  export { }
package/dist/index.cjs.js CHANGED
@@ -2,9 +2,25 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
+ var zodToJsonSchema = require('zod-to-json-schema');
5
6
  var backendPluginApi = require('@backstage/backend-plugin-api');
6
7
 
7
- const createTemplateAction = (templateAction) => {
8
+ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
9
+
10
+ var zodToJsonSchema__default = /*#__PURE__*/_interopDefaultLegacy(zodToJsonSchema);
11
+
12
+ const createTemplateAction = (action) => {
13
+ var _a, _b, _c, _d;
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
+ 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 = {
17
+ ...action,
18
+ schema: {
19
+ ...action.schema,
20
+ input: inputSchema,
21
+ output: outputSchema
22
+ }
23
+ };
8
24
  return templateAction;
9
25
  };
10
26
 
@@ -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 { JsonObject } from '@backstage/types';\nimport { TemplateAction } from './types';\n\n/**\n * This function is used to create new template actions to get type safety.\n *\n * @public\n */\nexport const createTemplateAction = <TInput extends JsonObject>(\n templateAction: TemplateAction<TInput>,\n): TemplateAction<TInput> => {\n // TODO(blam): Can add some more validation here to validate the action later on\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":["createExtensionPoint"],"mappings":";;;;;;AAwBa,MAAA,oBAAA,GAAuB,CAClC,cAC2B,KAAA;AAE3B,EAAO,OAAA,cAAA,CAAA;AACT;;ACIO,MAAM,kCACXA,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';\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;;;;;"}
package/dist/index.d.ts CHANGED
@@ -14,17 +14,18 @@ import { Schema } from 'jsonschema';
14
14
  import { TemplateInfo } from '@backstage/plugin-scaffolder-common';
15
15
  import { UserEntity } from '@backstage/catalog-model';
16
16
  import { Writable } from 'stream';
17
+ import { z } from 'zod';
17
18
 
18
19
  /**
19
20
  * ActionContext is passed into scaffolder actions.
20
21
  * @public
21
22
  */
22
- export declare type ActionContext<TInput extends JsonObject> = {
23
+ export declare type ActionContext<TActionInput extends JsonObject> = {
23
24
  logger: Logger;
24
25
  logStream: Writable;
25
26
  secrets?: TaskSecrets;
26
27
  workspacePath: string;
27
- input: TInput;
28
+ input: TActionInput;
28
29
  output(name: string, value: JsonValue): void;
29
30
  /**
30
31
  * Creates a temporary directory for use by the action, which is then cleaned up automatically.
@@ -53,10 +54,10 @@ export declare type ActionContext<TInput extends JsonObject> = {
53
54
 
54
55
  /**
55
56
  * This function is used to create new template actions to get type safety.
56
- *
57
+ * Will convert zod schemas to json schemas for use throughout the system.
57
58
  * @public
58
59
  */
59
- export declare const createTemplateAction: <TInput extends JsonObject>(templateAction: TemplateAction<TInput>) => TemplateAction<TInput>;
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>;
60
61
 
61
62
  /* Excluded from this release type: ScaffolderActionsExtensionPoint */
62
63
 
@@ -72,7 +73,7 @@ export declare type TaskSecrets = Record<string, string> & {
72
73
  };
73
74
 
74
75
  /** @public */
75
- export declare type TemplateAction<TInput extends JsonObject> = {
76
+ export declare type TemplateAction<TActionInput = unknown> = {
76
77
  id: string;
77
78
  description?: string;
78
79
  examples?: {
@@ -84,7 +85,23 @@ export declare type TemplateAction<TInput extends JsonObject> = {
84
85
  input?: Schema;
85
86
  output?: Schema;
86
87
  };
87
- handler: (ctx: ActionContext<TInput>) => Promise<void>;
88
+ handler: (ctx: ActionContext<TActionInput>) => Promise<void>;
89
+ };
90
+
91
+ /** @public */
92
+ export declare type TemplateActionOptions<TActionInput = {}, TInputSchema extends Schema | z.ZodType = {}, TOutputSchema extends Schema | z.ZodType = {}> = {
93
+ id: string;
94
+ description?: string;
95
+ examples?: {
96
+ description: string;
97
+ example: string;
98
+ }[];
99
+ supportsDryRun?: boolean;
100
+ schema?: {
101
+ input?: TInputSchema;
102
+ output?: TOutputSchema;
103
+ };
104
+ handler: (ctx: ActionContext<TActionInput>) => Promise<void>;
88
105
  };
89
106
 
90
107
  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-next.0",
4
+ "version": "0.1.1-next.1",
5
5
  "main": "dist/index.cjs.js",
6
6
  "types": "dist/index.d.ts",
7
7
  "license": "Apache-2.0",
@@ -24,15 +24,17 @@
24
24
  "postpack": "backstage-cli package postpack"
25
25
  },
26
26
  "dependencies": {
27
- "@backstage/backend-plugin-api": "^0.4.1-next.0",
28
- "@backstage/catalog-model": "^1.2.1-next.0",
29
- "@backstage/plugin-scaffolder-common": "^1.2.6-next.0",
27
+ "@backstage/backend-plugin-api": "^0.4.1-next.1",
28
+ "@backstage/catalog-model": "^1.2.1-next.1",
29
+ "@backstage/plugin-scaffolder-common": "^1.2.6-next.1",
30
30
  "@backstage/types": "^1.0.2",
31
31
  "jsonschema": "^1.2.6",
32
- "winston": "^3.2.1"
32
+ "winston": "^3.2.1",
33
+ "zod": "~3.18.0",
34
+ "zod-to-json-schema": "~3.18.0"
33
35
  },
34
36
  "devDependencies": {
35
- "@backstage/cli": "^0.22.4-next.0"
37
+ "@backstage/cli": "^0.22.4-next.1"
36
38
  },
37
39
  "files": [
38
40
  "alpha",