@backstage/plugin-scaffolder-backend-module-gitlab 0.5.1-next.1 → 0.6.0-next.2

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.
Files changed (52) hide show
  1. package/CHANGELOG.md +15 -0
  2. package/dist/actions/gitlab.cjs.js +374 -0
  3. package/dist/actions/gitlab.cjs.js.map +1 -0
  4. package/dist/actions/gitlab.examples.cjs.js +155 -0
  5. package/dist/actions/gitlab.examples.cjs.js.map +1 -0
  6. package/dist/actions/gitlabGroupEnsureExists.cjs.js +68 -0
  7. package/dist/actions/gitlabGroupEnsureExists.cjs.js.map +1 -0
  8. package/dist/actions/gitlabGroupEnsureExists.examples.cjs.js +78 -0
  9. package/dist/actions/gitlabGroupEnsureExists.examples.cjs.js.map +1 -0
  10. package/dist/actions/gitlabIssueCreate.cjs.js +136 -0
  11. package/dist/actions/gitlabIssueCreate.cjs.js.map +1 -0
  12. package/dist/actions/gitlabIssueCreate.examples.cjs.js +235 -0
  13. package/dist/actions/gitlabIssueCreate.examples.cjs.js.map +1 -0
  14. package/dist/actions/gitlabIssueEdit.cjs.js +163 -0
  15. package/dist/actions/gitlabIssueEdit.cjs.js.map +1 -0
  16. package/dist/actions/gitlabIssueEdit.examples.cjs.js +250 -0
  17. package/dist/actions/gitlabIssueEdit.examples.cjs.js.map +1 -0
  18. package/dist/actions/gitlabMergeRequest.cjs.js +231 -0
  19. package/dist/actions/gitlabMergeRequest.cjs.js.map +1 -0
  20. package/dist/actions/gitlabMergeRequest.examples.cjs.js +134 -0
  21. package/dist/actions/gitlabMergeRequest.examples.cjs.js.map +1 -0
  22. package/dist/actions/gitlabPipelineTrigger.cjs.js +89 -0
  23. package/dist/actions/gitlabPipelineTrigger.cjs.js.map +1 -0
  24. package/dist/actions/gitlabPipelineTrigger.examples.cjs.js +94 -0
  25. package/dist/actions/gitlabPipelineTrigger.examples.cjs.js.map +1 -0
  26. package/dist/actions/gitlabProjectAccessTokenCreate.cjs.js +85 -0
  27. package/dist/actions/gitlabProjectAccessTokenCreate.cjs.js.map +1 -0
  28. package/dist/actions/gitlabProjectAccessTokenCreate.examples.cjs.js +250 -0
  29. package/dist/actions/gitlabProjectAccessTokenCreate.examples.cjs.js.map +1 -0
  30. package/dist/actions/gitlabProjectDeployTokenCreate.cjs.js +58 -0
  31. package/dist/actions/gitlabProjectDeployTokenCreate.cjs.js.map +1 -0
  32. package/dist/actions/gitlabProjectDeployTokenCreate.examples.cjs.js +100 -0
  33. package/dist/actions/gitlabProjectDeployTokenCreate.examples.cjs.js.map +1 -0
  34. package/dist/actions/gitlabProjectVariableCreate.cjs.js +61 -0
  35. package/dist/actions/gitlabProjectVariableCreate.cjs.js.map +1 -0
  36. package/dist/actions/gitlabProjectVariableCreate.examples.cjs.js +151 -0
  37. package/dist/actions/gitlabProjectVariableCreate.examples.cjs.js.map +1 -0
  38. package/dist/actions/gitlabRepoPush.cjs.js +154 -0
  39. package/dist/actions/gitlabRepoPush.cjs.js.map +1 -0
  40. package/dist/actions/gitlabRepoPush.examples.cjs.js +67 -0
  41. package/dist/actions/gitlabRepoPush.examples.cjs.js.map +1 -0
  42. package/dist/actions/helpers.cjs.js +28 -0
  43. package/dist/actions/helpers.cjs.js.map +1 -0
  44. package/dist/commonGitlabConfig.cjs.js +32 -0
  45. package/dist/commonGitlabConfig.cjs.js.map +1 -0
  46. package/dist/index.cjs.js +28 -2929
  47. package/dist/index.cjs.js.map +1 -1
  48. package/dist/module.cjs.js +47 -0
  49. package/dist/module.cjs.js.map +1 -0
  50. package/dist/util.cjs.js +129 -0
  51. package/dist/util.cjs.js.map +1 -0
  52. package/package.json +7 -7
@@ -0,0 +1,68 @@
1
+ 'use strict';
2
+
3
+ var pluginScaffolderNode = require('@backstage/plugin-scaffolder-node');
4
+ var zod = require('zod');
5
+ var commonGitlabConfig = require('../commonGitlabConfig.cjs.js');
6
+ var util = require('../util.cjs.js');
7
+ var gitlabGroupEnsureExists_examples = require('./gitlabGroupEnsureExists.examples.cjs.js');
8
+
9
+ const createGitlabGroupEnsureExistsAction = (options) => {
10
+ const { integrations } = options;
11
+ return pluginScaffolderNode.createTemplateAction({
12
+ id: "gitlab:group:ensureExists",
13
+ description: "Ensures a Gitlab group exists",
14
+ supportsDryRun: true,
15
+ examples: gitlabGroupEnsureExists_examples.examples,
16
+ schema: {
17
+ input: commonGitlabConfig.default.merge(
18
+ zod.z.object({
19
+ path: zod.z.array(zod.z.string(), {
20
+ description: "A path of group names that is ensured to exist"
21
+ }).min(1)
22
+ })
23
+ ),
24
+ output: zod.z.object({
25
+ groupId: zod.z.number({ description: "The id of the innermost sub-group" }).optional()
26
+ })
27
+ },
28
+ async handler(ctx) {
29
+ if (ctx.isDryRun) {
30
+ ctx.output("groupId", 42);
31
+ return;
32
+ }
33
+ const { token, repoUrl, path } = ctx.input;
34
+ const { host } = util.parseRepoUrl(repoUrl, integrations);
35
+ const api = util.getClient({ host, integrations, token });
36
+ let currentPath = null;
37
+ let parentId = null;
38
+ for (const pathElement of path) {
39
+ const fullPath = currentPath ? `${currentPath}/${pathElement}` : pathElement;
40
+ const result = await api.Groups.search(
41
+ fullPath
42
+ );
43
+ const subGroup = result.find(
44
+ (searchPathElem) => searchPathElem.full_path === fullPath
45
+ );
46
+ if (!subGroup) {
47
+ ctx.logger.info(`creating missing group ${fullPath}`);
48
+ parentId = (await api.Groups.create(
49
+ pathElement,
50
+ pathElement,
51
+ parentId ? {
52
+ parentId
53
+ } : {}
54
+ ))?.id;
55
+ } else {
56
+ parentId = subGroup.id;
57
+ }
58
+ currentPath = fullPath;
59
+ }
60
+ if (parentId !== null) {
61
+ ctx.output("groupId", parentId);
62
+ }
63
+ }
64
+ });
65
+ };
66
+
67
+ exports.createGitlabGroupEnsureExistsAction = createGitlabGroupEnsureExistsAction;
68
+ //# sourceMappingURL=gitlabGroupEnsureExists.cjs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"gitlabGroupEnsureExists.cjs.js","sources":["../../src/actions/gitlabGroupEnsureExists.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 { ScmIntegrationRegistry } from '@backstage/integration';\nimport { createTemplateAction } from '@backstage/plugin-scaffolder-node';\nimport { GroupSchema } from '@gitbeaker/core/dist/types/resources/Groups';\nimport { z } from 'zod';\nimport commonGitlabConfig from '../commonGitlabConfig';\nimport { getClient, parseRepoUrl } from '../util';\nimport { examples } from './gitlabGroupEnsureExists.examples';\n\n/**\n * Creates an `gitlab:group:ensureExists` Scaffolder action.\n *\n * @public\n */\nexport const createGitlabGroupEnsureExistsAction = (options: {\n integrations: ScmIntegrationRegistry;\n}) => {\n const { integrations } = options;\n\n return createTemplateAction({\n id: 'gitlab:group:ensureExists',\n description: 'Ensures a Gitlab group exists',\n supportsDryRun: true,\n examples,\n schema: {\n input: commonGitlabConfig.merge(\n z.object({\n path: z\n .array(z.string(), {\n description: 'A path of group names that is ensured to exist',\n })\n .min(1),\n }),\n ),\n output: z.object({\n groupId: z\n .number({ description: 'The id of the innermost sub-group' })\n .optional(),\n }),\n },\n async handler(ctx) {\n if (ctx.isDryRun) {\n ctx.output('groupId', 42);\n return;\n }\n\n const { token, repoUrl, path } = ctx.input;\n\n const { host } = parseRepoUrl(repoUrl, integrations);\n\n const api = getClient({ host, integrations, token });\n\n let currentPath: string | null = null;\n let parentId: number | null = null;\n for (const pathElement of path) {\n const fullPath: string = currentPath\n ? `${currentPath}/${pathElement}`\n : pathElement;\n const result = (await api.Groups.search(\n fullPath,\n )) as unknown as Array<GroupSchema>; // recast since the return type for search is wrong in the gitbeaker typings\n const subGroup = result.find(\n searchPathElem => searchPathElem.full_path === fullPath,\n );\n if (!subGroup) {\n ctx.logger.info(`creating missing group ${fullPath}`);\n parentId = (\n await api.Groups.create(\n pathElement,\n pathElement,\n parentId\n ? {\n parentId: parentId,\n }\n : {},\n )\n )?.id;\n } else {\n parentId = subGroup.id;\n }\n currentPath = fullPath;\n }\n if (parentId !== null) {\n ctx.output('groupId', parentId);\n }\n },\n });\n};\n"],"names":["createTemplateAction","examples","commonGitlabConfig","z","parseRepoUrl","getClient"],"mappings":";;;;;;;;AA6Ba,MAAA,mCAAA,GAAsC,CAAC,OAE9C,KAAA;AACJ,EAAM,MAAA,EAAE,cAAiB,GAAA,OAAA,CAAA;AAEzB,EAAA,OAAOA,yCAAqB,CAAA;AAAA,IAC1B,EAAI,EAAA,2BAAA;AAAA,IACJ,WAAa,EAAA,+BAAA;AAAA,IACb,cAAgB,EAAA,IAAA;AAAA,cAChBC,yCAAA;AAAA,IACA,MAAQ,EAAA;AAAA,MACN,OAAOC,0BAAmB,CAAA,KAAA;AAAA,QACxBC,MAAE,MAAO,CAAA;AAAA,UACP,IAAM,EAAAA,KAAA,CACH,KAAM,CAAAA,KAAA,CAAE,QAAU,EAAA;AAAA,YACjB,WAAa,EAAA,gDAAA;AAAA,WACd,CACA,CAAA,GAAA,CAAI,CAAC,CAAA;AAAA,SACT,CAAA;AAAA,OACH;AAAA,MACA,MAAA,EAAQA,MAAE,MAAO,CAAA;AAAA,QACf,OAAA,EAASA,MACN,MAAO,CAAA,EAAE,aAAa,mCAAoC,EAAC,EAC3D,QAAS,EAAA;AAAA,OACb,CAAA;AAAA,KACH;AAAA,IACA,MAAM,QAAQ,GAAK,EAAA;AACjB,MAAA,IAAI,IAAI,QAAU,EAAA;AAChB,QAAI,GAAA,CAAA,MAAA,CAAO,WAAW,EAAE,CAAA,CAAA;AACxB,QAAA,OAAA;AAAA,OACF;AAEA,MAAA,MAAM,EAAE,KAAA,EAAO,OAAS,EAAA,IAA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CAAA;AACH;;;;"}
@@ -0,0 +1,78 @@
1
+ 'use strict';
2
+
3
+ var yaml = require('yaml');
4
+
5
+ function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e : { default: e }; }
6
+
7
+ var yaml__default = /*#__PURE__*/_interopDefaultCompat(yaml);
8
+
9
+ const examples = [
10
+ {
11
+ description: "Creating a group at the top level",
12
+ example: yaml__default.default.stringify({
13
+ steps: [
14
+ {
15
+ id: "gitlabGroup",
16
+ name: "Group",
17
+ action: "gitlab:group:ensureExists",
18
+ input: {
19
+ repoUrl: "gitlab.com",
20
+ path: ["group1"]
21
+ }
22
+ }
23
+ ]
24
+ })
25
+ },
26
+ {
27
+ description: "Create a group nested within another group",
28
+ example: yaml__default.default.stringify({
29
+ steps: [
30
+ {
31
+ id: "gitlabGroup",
32
+ name: "Group",
33
+ action: "gitlab:group:ensureExists",
34
+ input: {
35
+ repoUrl: "gitlab.com",
36
+ path: ["group1", "group2"]
37
+ }
38
+ }
39
+ ]
40
+ })
41
+ },
42
+ {
43
+ description: "Create a group nested within multiple other groups",
44
+ example: yaml__default.default.stringify({
45
+ steps: [
46
+ {
47
+ id: "gitlabGroup",
48
+ name: "Group",
49
+ action: "gitlab:group:ensureExists",
50
+ input: {
51
+ repoUrl: "gitlab.com",
52
+ path: ["group1", "group2", "group3"]
53
+ }
54
+ }
55
+ ]
56
+ })
57
+ },
58
+ {
59
+ description: "Create a group in dry run mode",
60
+ example: yaml__default.default.stringify({
61
+ steps: [
62
+ {
63
+ id: "gitlabGroup",
64
+ name: "Group",
65
+ action: "gitlab:group:ensureExists",
66
+ isDryRun: true,
67
+ input: {
68
+ repoUrl: "https://gitlab.com/my-repo",
69
+ path: ["group1", "group2", "group3"]
70
+ }
71
+ }
72
+ ]
73
+ })
74
+ }
75
+ ];
76
+
77
+ exports.examples = examples;
78
+ //# sourceMappingURL=gitlabGroupEnsureExists.examples.cjs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"gitlabGroupEnsureExists.examples.cjs.js","sources":["../../src/actions/gitlabGroupEnsureExists.examples.ts"],"sourcesContent":["/*\n * Copyright 2023 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 */\nimport { TemplateExample } from '@backstage/plugin-scaffolder-node';\nimport yaml from 'yaml';\n\nexport const examples: TemplateExample[] = [\n {\n description: 'Creating a group at the top level',\n example: yaml.stringify({\n steps: [\n {\n id: 'gitlabGroup',\n name: 'Group',\n action: 'gitlab:group:ensureExists',\n input: {\n repoUrl: 'gitlab.com',\n path: ['group1'],\n },\n },\n ],\n }),\n },\n {\n description: 'Create a group nested within another group',\n example: yaml.stringify({\n steps: [\n {\n id: 'gitlabGroup',\n name: 'Group',\n action: 'gitlab:group:ensureExists',\n input: {\n repoUrl: 'gitlab.com',\n path: ['group1', 'group2'],\n },\n },\n ],\n }),\n },\n {\n description: 'Create a group nested within multiple other groups',\n example: yaml.stringify({\n steps: [\n {\n id: 'gitlabGroup',\n name: 'Group',\n action: 'gitlab:group:ensureExists',\n input: {\n repoUrl: 'gitlab.com',\n path: ['group1', 'group2', 'group3'],\n },\n },\n ],\n }),\n },\n {\n description: 'Create a group in dry run mode',\n example: yaml.stringify({\n steps: [\n {\n id: 'gitlabGroup',\n name: 'Group',\n action: 'gitlab:group:ensureExists',\n isDryRun: true,\n input: {\n repoUrl: 'https://gitlab.com/my-repo',\n path: ['group1', 'group2', 'group3'],\n },\n },\n ],\n }),\n },\n];\n"],"names":["yaml"],"mappings":";;;;;;;;AAkBO,MAAM,QAA8B,GAAA;AAAA,EACzC;AAAA,IACE,WAAa,EAAA,mCAAA;AAAA,IACb,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,IAAM,EAAA,OAAA;AAAA,UACN,MAAQ,EAAA,2BAAA;AAAA,UACR,QAAU,EAAA,IAAA;AAAA,UACV,KAAO,EAAA;AAAA,YACL,OAAS,EAAA,4BAAA;AAAA,YACT,IAAM,EAAA,CAAC,QAAU,EAAA,QAAA,EAAU,QAAQ,CAAA;AAAA,WACrC;AAAA,SACF;AAAA,OACF;AAAA,KACD,CAAA;AAAA,GACH;AACF;;;;"}
@@ -0,0 +1,136 @@
1
+ 'use strict';
2
+
3
+ var errors = require('@backstage/errors');
4
+ var pluginScaffolderNode = require('@backstage/plugin-scaffolder-node');
5
+ var commonGitlabConfig = require('../commonGitlabConfig.cjs.js');
6
+ var gitlabIssueCreate_examples = require('./gitlabIssueCreate.examples.cjs.js');
7
+ var zod = require('zod');
8
+ var util = require('../util.cjs.js');
9
+
10
+ const issueInputProperties = zod.z.object({
11
+ projectId: zod.z.number().describe("Project Id"),
12
+ title: zod.z.string({ description: "Title of the issue" }),
13
+ assignees: zod.z.array(zod.z.number(), {
14
+ description: "IDs of the users to assign the issue to."
15
+ }).optional(),
16
+ confidential: zod.z.boolean({ description: "Issue Confidentiality" }).optional(),
17
+ description: zod.z.string().describe("Issue description").max(1048576).optional(),
18
+ createdAt: zod.z.string().describe("Creation date/time").regex(
19
+ /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:\.\d{3})?Z$/,
20
+ "Invalid date format. Use YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.SSSZ"
21
+ ).optional(),
22
+ dueDate: zod.z.string().describe("Due date/time").regex(
23
+ /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:\.\d{3})?Z$/,
24
+ "Invalid date format. Use YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.SSSZ"
25
+ ).optional(),
26
+ discussionToResolve: zod.z.string({
27
+ description: 'Id of a discussion to resolve. Use in combination with "merge_request_to_resolve_discussions_of"'
28
+ }).optional(),
29
+ epicId: zod.z.number({ description: "Id of the linked Epic" }).min(0, "Valid values should be equal or greater than zero").optional(),
30
+ labels: zod.z.string({ description: "Labels to apply" }).optional(),
31
+ issueType: zod.z.nativeEnum(commonGitlabConfig.IssueType, {
32
+ description: "Type of the issue"
33
+ }).optional(),
34
+ mergeRequestToResolveDiscussionsOf: zod.z.number({
35
+ description: "IID of a merge request in which to resolve all issues"
36
+ }).optional(),
37
+ milestoneId: zod.z.number({ description: "Global ID of a milestone to assign the issue" }).optional(),
38
+ weight: zod.z.number({ description: "The issue weight" }).min(0).refine((value) => {
39
+ const isValid = value >= 0;
40
+ if (!isValid) {
41
+ return {
42
+ message: "Valid values should be equal or greater than zero"
43
+ };
44
+ }
45
+ return isValid;
46
+ }).optional()
47
+ });
48
+ const issueOutputProperties = zod.z.object({
49
+ issueUrl: zod.z.string({ description: "Issue Url" }),
50
+ issueId: zod.z.number({ description: "Issue Id" }),
51
+ issueIid: zod.z.number({ description: "Issue Iid" })
52
+ });
53
+ const createGitlabIssueAction = (options) => {
54
+ const { integrations } = options;
55
+ return pluginScaffolderNode.createTemplateAction({
56
+ id: "gitlab:issues:create",
57
+ description: "Creates a Gitlab issue.",
58
+ examples: gitlabIssueCreate_examples.examples,
59
+ schema: {
60
+ input: commonGitlabConfig.default.merge(issueInputProperties),
61
+ output: issueOutputProperties
62
+ },
63
+ async handler(ctx) {
64
+ try {
65
+ const {
66
+ repoUrl,
67
+ projectId,
68
+ title,
69
+ description = "",
70
+ confidential = false,
71
+ assignees = [],
72
+ createdAt = "",
73
+ dueDate,
74
+ discussionToResolve = "",
75
+ epicId,
76
+ labels = "",
77
+ issueType,
78
+ mergeRequestToResolveDiscussionsOf,
79
+ milestoneId,
80
+ weight,
81
+ token
82
+ } = commonGitlabConfig.default.merge(issueInputProperties).parse(ctx.input);
83
+ const { host } = util.parseRepoUrl(repoUrl, integrations);
84
+ const api = util.getClient({ host, integrations, token });
85
+ let isEpicScoped = false;
86
+ if (epicId) {
87
+ isEpicScoped = await util.checkEpicScope(api, projectId, epicId);
88
+ if (isEpicScoped) {
89
+ ctx.logger.info("Epic is within Project Scope");
90
+ } else {
91
+ ctx.logger.warn(
92
+ "Chosen epic is not within the Project Scope. The issue will be created without an associated epic."
93
+ );
94
+ }
95
+ }
96
+ const mappedCreatedAt = util.convertDate(
97
+ String(createdAt),
98
+ (/* @__PURE__ */ new Date()).toISOString()
99
+ );
100
+ const mappedDueDate = dueDate ? util.convertDate(String(dueDate), (/* @__PURE__ */ new Date()).toISOString()) : void 0;
101
+ const issueOptions = {
102
+ description,
103
+ assigneeIds: assignees,
104
+ confidential,
105
+ epicId: isEpicScoped ? epicId : void 0,
106
+ labels,
107
+ createdAt: mappedCreatedAt,
108
+ dueDate: mappedDueDate,
109
+ discussionToResolve,
110
+ issueType,
111
+ mergeRequestToResolveDiscussionsOf,
112
+ milestoneId,
113
+ weight
114
+ };
115
+ const response = await api.Issues.create(
116
+ projectId,
117
+ title,
118
+ issueOptions
119
+ );
120
+ ctx.output("issueId", response.id);
121
+ ctx.output("issueUrl", response.web_url);
122
+ ctx.output("issueIid", response.iid);
123
+ } catch (error) {
124
+ if (error instanceof zod.z.ZodError) {
125
+ throw new errors.InputError(`Validation error: ${error.message}`, {
126
+ validationErrors: error.errors
127
+ });
128
+ }
129
+ throw new errors.InputError(`Failed to create GitLab issue: ${error.message}`);
130
+ }
131
+ }
132
+ });
133
+ };
134
+
135
+ exports.createGitlabIssueAction = createGitlabIssueAction;
136
+ //# sourceMappingURL=gitlabIssueCreate.cjs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"gitlabIssueCreate.cjs.js","sources":["../../src/actions/gitlabIssueCreate.ts"],"sourcesContent":["/*\n * Copyright 2023 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 { InputError } from '@backstage/errors';\nimport { ScmIntegrationRegistry } from '@backstage/integration';\nimport { createTemplateAction } from '@backstage/plugin-scaffolder-node';\nimport commonGitlabConfig, { IssueType } from '../commonGitlabConfig';\nimport { examples } from './gitlabIssueCreate.examples';\nimport { z } from 'zod';\nimport { checkEpicScope, convertDate, getClient, parseRepoUrl } from '../util';\nimport { CreateIssueOptions, IssueSchema } from '@gitbeaker/rest';\n\nconst issueInputProperties = z.object({\n projectId: z.number().describe('Project Id'),\n title: z.string({ description: 'Title of the issue' }),\n assignees: z\n .array(z.number(), {\n description: 'IDs of the users to assign the issue to.',\n })\n .optional(),\n confidential: z.boolean({ description: 'Issue Confidentiality' }).optional(),\n description: z.string().describe('Issue description').max(1048576).optional(),\n createdAt: z\n .string()\n .describe('Creation date/time')\n .regex(\n /^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(?:\\.\\d{3})?Z$/,\n 'Invalid date format. Use YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.SSSZ',\n )\n .optional(),\n dueDate: z\n .string()\n .describe('Due date/time')\n .regex(\n /^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(?:\\.\\d{3})?Z$/,\n 'Invalid date format. Use YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.SSSZ',\n )\n .optional(),\n discussionToResolve: z\n .string({\n description:\n 'Id of a discussion to resolve. Use in combination with \"merge_request_to_resolve_discussions_of\"',\n })\n .optional(),\n epicId: z\n .number({ description: 'Id of the linked Epic' })\n .min(0, 'Valid values should be equal or greater than zero')\n .optional(),\n labels: z.string({ description: 'Labels to apply' }).optional(),\n issueType: z\n .nativeEnum(IssueType, {\n description: 'Type of the issue',\n })\n .optional(),\n mergeRequestToResolveDiscussionsOf: z\n .number({\n description: 'IID of a merge request in which to resolve all issues',\n })\n .optional(),\n milestoneId: z\n .number({ description: 'Global ID of a milestone to assign the issue' })\n .optional(),\n weight: z\n .number({ description: 'The issue weight' })\n .min(0)\n .refine(value => {\n const isValid = value >= 0;\n if (!isValid) {\n return {\n message: 'Valid values should be equal or greater than zero',\n };\n }\n return isValid;\n })\n .optional(),\n});\n\nconst issueOutputProperties = z.object({\n issueUrl: z.string({ description: 'Issue Url' }),\n issueId: z.number({ description: 'Issue Id' }),\n issueIid: z.number({ description: 'Issue Iid' }),\n});\n\n/**\n * Creates a `gitlab:issues:create` Scaffolder action.\n *\n * @param options - Templating configuration.\n * @public\n */\nexport const createGitlabIssueAction = (options: {\n integrations: ScmIntegrationRegistry;\n}) => {\n const { integrations } = options;\n return createTemplateAction({\n id: 'gitlab:issues:create',\n description: 'Creates a Gitlab issue.',\n examples,\n schema: {\n input: commonGitlabConfig.merge(issueInputProperties),\n output: issueOutputProperties,\n },\n async handler(ctx) {\n try {\n const {\n repoUrl,\n projectId,\n title,\n description = '',\n confidential = false,\n assignees = [],\n createdAt = '',\n dueDate,\n discussionToResolve = '',\n epicId,\n labels = '',\n issueType,\n mergeRequestToResolveDiscussionsOf,\n milestoneId,\n weight,\n token,\n } = commonGitlabConfig.merge(issueInputProperties).parse(ctx.input);\n\n const { host } = parseRepoUrl(repoUrl, integrations);\n const api = getClient({ host, integrations, token });\n\n let isEpicScoped = false;\n\n if (epicId) {\n isEpicScoped = await checkEpicScope(api, projectId, epicId);\n\n if (isEpicScoped) {\n ctx.logger.info('Epic is within Project Scope');\n } else {\n ctx.logger.warn(\n 'Chosen epic is not within the Project Scope. The issue will be created without an associated epic.',\n );\n }\n }\n const mappedCreatedAt = convertDate(\n String(createdAt),\n new Date().toISOString(),\n );\n const mappedDueDate = dueDate\n ? convertDate(String(dueDate), new Date().toISOString())\n : undefined;\n\n const issueOptions: CreateIssueOptions = {\n description,\n assigneeIds: assignees,\n confidential,\n epicId: isEpicScoped ? epicId : undefined,\n labels,\n createdAt: mappedCreatedAt,\n dueDate: mappedDueDate,\n discussionToResolve,\n issueType,\n mergeRequestToResolveDiscussionsOf,\n milestoneId,\n weight,\n };\n\n const response = (await api.Issues.create(\n projectId,\n title,\n issueOptions,\n )) as IssueSchema;\n\n ctx.output('issueId', response.id);\n ctx.output('issueUrl', response.web_url);\n ctx.output('issueIid', response.iid);\n } catch (error: any) {\n if (error instanceof z.ZodError) {\n // Handling Zod validation errors\n throw new InputError(`Validation error: ${error.message}`, {\n validationErrors: error.errors,\n });\n }\n // Handling other errors\n throw new InputError(`Failed to create GitLab issue: ${error.message}`);\n }\n },\n });\n};\n"],"names":["z","IssueType","createTemplateAction","examples","commonGitlabConfig","parseRepoUrl","getClient","checkEpicScope","convertDate","InputError"],"mappings":";;;;;;;;;AAyBA,MAAM,oBAAA,GAAuBA,MAAE,MAAO,CAAA;AAAA,EACpC,SAAW,EAAAA,KAAA,CAAE,MAAO,EAAA,CAAE,SAAS,YAAY,CAAA;AAAA,EAC3C,OAAOA,KAAE,CAAA,MAAA,CAAO,EAAE,WAAA,EAAa,sBAAsB,CAAA;AAAA,EACrD,SAAW,EAAAA,KAAA,CACR,KAAM,CAAAA,KAAA,CAAE,QAAU,EAAA;AAAA,IACjB,WAAa,EAAA,0CAAA;AAAA,GACd,EACA,QAAS,EAAA;AAAA,EACZ,YAAA,EAAcA,MAAE,OAAQ,CAAA,EAAE,aAAa,uBAAwB,EAAC,EAAE,QAAS,EAAA;AAAA,EAC3E,WAAA,EAAaA,KAAE,CAAA,MAAA,EAAS,CAAA,QAAA,CAAS,mBAAmB,CAAE,CAAA,GAAA,CAAI,OAAO,CAAA,CAAE,QAAS,EAAA;AAAA,EAC5E,WAAWA,KACR,CAAA,MAAA,EACA,CAAA,QAAA,CAAS,oBAAoB,CAC7B,CAAA,KAAA;AAAA,IACC,oDAAA;AAAA,IACA,2EAAA;AAAA,IAED,QAAS,EAAA;AAAA,EACZ,SAAS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AACjC,QAAI,GAAA,CAAA,MAAA,CAAO,UAAY,EAAA,QAAA,CAAS,OAAO,CAAA,CAAA;AACvC,QAAI,GAAA,CAAA,MAAA,CAAO,UAAY,EAAA,QAAA,CAAS,GAAG,CAAA,CAAA;AAAA,eAC5B,KAAY,EAAA;AACnB,QAAI,IAAA,KAAA,YAAiBR,MAAE,QAAU,EAAA;AAE/B,UAAA,MAAM,IAAIS,iBAAA,CAAW,CAAqB,kBAAA,EAAA,KAAA,CAAM,OAAO,CAAI,CAAA,EAAA;AAAA,YACzD,kBAAkB,KAAM,CAAA,MAAA;AAAA,WACzB,CAAA,CAAA;AAAA,SACH;AAEA,QAAA,MAAM,IAAIA,iBAAA,CAAW,CAAkC,+BAAA,EAAA,KAAA,CAAM,OAAO,CAAE,CAAA,CAAA,CAAA;AAAA,OACxE;AAAA,KACF;AAAA,GACD,CAAA,CAAA;AACH;;;;"}
@@ -0,0 +1,235 @@
1
+ 'use strict';
2
+
3
+ var yaml = require('yaml');
4
+ var commonGitlabConfig = require('../commonGitlabConfig.cjs.js');
5
+
6
+ function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e : { default: e }; }
7
+
8
+ var yaml__default = /*#__PURE__*/_interopDefaultCompat(yaml);
9
+
10
+ const examples = [
11
+ {
12
+ description: "Create a GitLab issue with minimal options",
13
+ example: yaml__default.default.stringify({
14
+ steps: [
15
+ {
16
+ id: "gitlabIssue",
17
+ name: "Issues",
18
+ action: "gitlab:issues:create",
19
+ input: {
20
+ ...commonGitlabConfig.commonGitlabConfigExample,
21
+ projectId: 12,
22
+ title: "Test Issue",
23
+ description: "This is the description of the issue"
24
+ }
25
+ }
26
+ ]
27
+ })
28
+ },
29
+ {
30
+ description: "Create a GitLab issue with assignees and date options",
31
+ example: yaml__default.default.stringify({
32
+ steps: [
33
+ {
34
+ id: "gitlabIssue",
35
+ name: "Issues",
36
+ action: "gitlab:issues:create",
37
+ input: {
38
+ ...commonGitlabConfig.commonGitlabConfigExample,
39
+ projectId: 12,
40
+ title: "Test Issue",
41
+ assignees: [18],
42
+ description: "This is the description of the issue",
43
+ createdAt: "2022-09-27T18:00:00.000Z",
44
+ dueDate: "2022-09-28T12:00:00.000Z"
45
+ }
46
+ }
47
+ ]
48
+ })
49
+ },
50
+ {
51
+ description: "Create a GitLab Issue with several options",
52
+ example: yaml__default.default.stringify({
53
+ steps: [
54
+ {
55
+ id: "gitlabIssue",
56
+ name: "Issues",
57
+ action: "gitlab:issues:create",
58
+ input: {
59
+ ...commonGitlabConfig.commonGitlabConfigExample,
60
+ projectId: 12,
61
+ title: "Test Issue",
62
+ assignees: [18, 15],
63
+ description: "This is the description of the issue",
64
+ confidential: false,
65
+ createdAt: "2022-09-27T18:00:00.000Z",
66
+ dueDate: "2022-09-28T12:00:00.000Z",
67
+ discussionToResolve: "1",
68
+ epicId: 1,
69
+ labels: "phase1:label1,phase2:label2"
70
+ }
71
+ }
72
+ ]
73
+ })
74
+ },
75
+ {
76
+ description: "Create a GitLab issue with token",
77
+ example: yaml__default.default.stringify({
78
+ steps: [
79
+ {
80
+ id: "gitlabIssue",
81
+ name: "Issues",
82
+ action: "gitlab:issues:create",
83
+ input: {
84
+ ...commonGitlabConfig.commonGitlabConfigExample,
85
+ projectId: 12,
86
+ title: "Test Issue",
87
+ description: "This is the description of the issue",
88
+ token: "sample token"
89
+ }
90
+ }
91
+ ]
92
+ })
93
+ },
94
+ {
95
+ description: "Create a GitLab issue with a specific milestone and weight",
96
+ example: yaml__default.default.stringify({
97
+ steps: [
98
+ {
99
+ id: "gitlabIssue",
100
+ name: "Issues",
101
+ action: "gitlab:issues:create",
102
+ input: {
103
+ ...commonGitlabConfig.commonGitlabConfigExample,
104
+ projectId: 12,
105
+ title: "Test Issue with Milestone",
106
+ description: "This is the description of the issue",
107
+ milestoneId: 5,
108
+ weight: 3
109
+ }
110
+ }
111
+ ]
112
+ })
113
+ },
114
+ {
115
+ description: "Create a GitLab issue of type INCIDENT",
116
+ example: yaml__default.default.stringify({
117
+ steps: [
118
+ {
119
+ id: "gitlabIssue",
120
+ name: "Issues",
121
+ action: "gitlab:issues:create",
122
+ input: {
123
+ ...commonGitlabConfig.commonGitlabConfigExample,
124
+ projectId: 12,
125
+ title: "Confidential Test Issue",
126
+ description: "This is the description of the issue",
127
+ issueType: "incident"
128
+ }
129
+ }
130
+ ]
131
+ })
132
+ },
133
+ {
134
+ description: "Create a GitLab issue of type TEST",
135
+ example: yaml__default.default.stringify({
136
+ steps: [
137
+ {
138
+ id: "gitlabIssue",
139
+ name: "Issues",
140
+ action: "gitlab:issues:create",
141
+ input: {
142
+ ...commonGitlabConfig.commonGitlabConfigExample,
143
+ projectId: 12,
144
+ title: "Confidential Test Issue",
145
+ description: "This is the description of the issue",
146
+ issueType: "test_case"
147
+ }
148
+ }
149
+ ]
150
+ })
151
+ },
152
+ {
153
+ description: "Create a GitLab issue of type TASK with assignees",
154
+ example: yaml__default.default.stringify({
155
+ steps: [
156
+ {
157
+ id: "gitlabIssue",
158
+ name: "Issues",
159
+ action: "gitlab:issues:create",
160
+ input: {
161
+ ...commonGitlabConfig.commonGitlabConfigExample,
162
+ projectId: 12,
163
+ title: "Confidential Test Issue",
164
+ description: "This is the description of the issue",
165
+ issueType: "task",
166
+ assignees: [18, 22]
167
+ }
168
+ }
169
+ ]
170
+ })
171
+ },
172
+ {
173
+ description: "Create a GitLab issue of type ISSUE and close it",
174
+ example: yaml__default.default.stringify({
175
+ steps: [
176
+ {
177
+ id: "gitlabIssue",
178
+ name: "Issues",
179
+ action: "gitlab:issues:create",
180
+ input: {
181
+ ...commonGitlabConfig.commonGitlabConfigExample,
182
+ projectId: 12,
183
+ title: "Confidential Test Issue",
184
+ description: "This is the description of the issue",
185
+ issueType: "issue",
186
+ stateEvent: "close"
187
+ }
188
+ }
189
+ ]
190
+ })
191
+ },
192
+ {
193
+ description: "Create a GitLab issue of type INCIDENT and reopen it",
194
+ example: yaml__default.default.stringify({
195
+ steps: [
196
+ {
197
+ id: "gitlabIssue",
198
+ name: "Issues",
199
+ action: "gitlab:issues:create",
200
+ input: {
201
+ ...commonGitlabConfig.commonGitlabConfigExample,
202
+ projectId: 12,
203
+ title: "Confidential Test Issue",
204
+ description: "This is the description of the issue",
205
+ issueType: "incident",
206
+ stateEvent: "reopen"
207
+ }
208
+ }
209
+ ]
210
+ })
211
+ },
212
+ {
213
+ description: "Create a GitLab issue to resolve a discussion in a merge request",
214
+ example: yaml__default.default.stringify({
215
+ steps: [
216
+ {
217
+ id: "gitlabIssue",
218
+ name: "Issues",
219
+ action: "gitlab:issues:create",
220
+ input: {
221
+ ...commonGitlabConfig.commonGitlabConfigExample,
222
+ projectId: 12,
223
+ title: "Test Issue for MR Discussion",
224
+ description: "This is the description of the issue",
225
+ mergeRequestToResolveDiscussionsOf: 42,
226
+ discussionToResolve: "abc123"
227
+ }
228
+ }
229
+ ]
230
+ })
231
+ }
232
+ ];
233
+
234
+ exports.examples = examples;
235
+ //# sourceMappingURL=gitlabIssueCreate.examples.cjs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"gitlabIssueCreate.examples.cjs.js","sources":["../../src/actions/gitlabIssueCreate.examples.ts"],"sourcesContent":["/*\n * Copyright 2023 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 */\nimport { TemplateExample } from '@backstage/plugin-scaffolder-node';\nimport yaml from 'yaml';\nimport { commonGitlabConfigExample } from '../commonGitlabConfig';\n\nexport const examples: TemplateExample[] = [\n {\n description: 'Create a GitLab issue with minimal options',\n example: yaml.stringify({\n steps: [\n {\n id: 'gitlabIssue',\n name: 'Issues',\n action: 'gitlab:issues:create',\n input: {\n ...commonGitlabConfigExample,\n projectId: 12,\n title: 'Test Issue',\n description: 'This is the description of the issue',\n },\n },\n ],\n }),\n },\n {\n description: 'Create a GitLab issue with assignees and date options',\n example: yaml.stringify({\n steps: [\n {\n id: 'gitlabIssue',\n name: 'Issues',\n action: 'gitlab:issues:create',\n input: {\n ...commonGitlabConfigExample,\n projectId: 12,\n title: 'Test Issue',\n assignees: [18],\n description: 'This is the description of the issue',\n createdAt: '2022-09-27T18:00:00.000Z',\n dueDate: '2022-09-28T12:00:00.000Z',\n },\n },\n ],\n }),\n },\n {\n description: 'Create a GitLab Issue with several options',\n example: yaml.stringify({\n steps: [\n {\n id: 'gitlabIssue',\n name: 'Issues',\n action: 'gitlab:issues:create',\n input: {\n ...commonGitlabConfigExample,\n projectId: 12,\n title: 'Test Issue',\n assignees: [18, 15],\n description: 'This is the description of the issue',\n confidential: false,\n createdAt: '2022-09-27T18:00:00.000Z',\n dueDate: '2022-09-28T12:00:00.000Z',\n discussionToResolve: '1',\n epicId: 1,\n labels: 'phase1:label1,phase2:label2',\n },\n },\n ],\n }),\n },\n {\n description: 'Create a GitLab issue with token',\n example: yaml.stringify({\n steps: [\n {\n id: 'gitlabIssue',\n name: 'Issues',\n action: 'gitlab:issues:create',\n input: {\n ...commonGitlabConfigExample,\n projectId: 12,\n title: 'Test Issue',\n description: 'This is the description of the issue',\n token: 'sample token',\n },\n },\n ],\n }),\n },\n {\n description: 'Create a GitLab issue with a specific milestone and weight',\n example: yaml.stringify({\n steps: [\n {\n id: 'gitlabIssue',\n name: 'Issues',\n action: 'gitlab:issues:create',\n input: {\n ...commonGitlabConfigExample,\n projectId: 12,\n title: 'Test Issue with Milestone',\n description: 'This is the description of the issue',\n milestoneId: 5,\n weight: 3,\n },\n },\n ],\n }),\n },\n {\n description: 'Create a GitLab issue of type INCIDENT',\n example: yaml.stringify({\n steps: [\n {\n id: 'gitlabIssue',\n name: 'Issues',\n action: 'gitlab:issues:create',\n input: {\n ...commonGitlabConfigExample,\n projectId: 12,\n title: 'Confidential Test Issue',\n description: 'This is the description of the issue',\n issueType: 'incident',\n },\n },\n ],\n }),\n },\n {\n description: 'Create a GitLab issue of type TEST',\n example: yaml.stringify({\n steps: [\n {\n id: 'gitlabIssue',\n name: 'Issues',\n action: 'gitlab:issues:create',\n input: {\n ...commonGitlabConfigExample,\n projectId: 12,\n title: 'Confidential Test Issue',\n description: 'This is the description of the issue',\n issueType: 'test_case',\n },\n },\n ],\n }),\n },\n {\n description: 'Create a GitLab issue of type TASK with assignees',\n example: yaml.stringify({\n steps: [\n {\n id: 'gitlabIssue',\n name: 'Issues',\n action: 'gitlab:issues:create',\n input: {\n ...commonGitlabConfigExample,\n projectId: 12,\n title: 'Confidential Test Issue',\n description: 'This is the description of the issue',\n issueType: 'task',\n assignees: [18, 22],\n },\n },\n ],\n }),\n },\n {\n description: 'Create a GitLab issue of type ISSUE and close it',\n example: yaml.stringify({\n steps: [\n {\n id: 'gitlabIssue',\n name: 'Issues',\n action: 'gitlab:issues:create',\n input: {\n ...commonGitlabConfigExample,\n projectId: 12,\n title: 'Confidential Test Issue',\n description: 'This is the description of the issue',\n issueType: 'issue',\n stateEvent: 'close',\n },\n },\n ],\n }),\n },\n {\n description: 'Create a GitLab issue of type INCIDENT and reopen it',\n example: yaml.stringify({\n steps: [\n {\n id: 'gitlabIssue',\n name: 'Issues',\n action: 'gitlab:issues:create',\n input: {\n ...commonGitlabConfigExample,\n projectId: 12,\n title: 'Confidential Test Issue',\n description: 'This is the description of the issue',\n issueType: 'incident',\n stateEvent: 'reopen',\n },\n },\n ],\n }),\n },\n {\n description:\n 'Create a GitLab issue to resolve a discussion in a merge request',\n example: yaml.stringify({\n steps: [\n {\n id: 'gitlabIssue',\n name: 'Issues',\n action: 'gitlab:issues:create',\n input: {\n ...commonGitlabConfigExample,\n projectId: 12,\n title: 'Test Issue for MR Discussion',\n description: 'This is the description of the issue',\n mergeRequestToResolveDiscussionsOf: 42,\n discussionToResolve: 'abc123',\n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