@backstage/plugin-scaffolder-backend-module-gitlab 0.11.9 → 0.11.10

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 (31) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/dist/actions/gitlab.cjs.js +13 -0
  3. package/dist/actions/gitlab.cjs.js.map +1 -1
  4. package/dist/actions/gitlabGroupAccessAction.cjs.js +7 -2
  5. package/dist/actions/gitlabGroupAccessAction.cjs.js.map +1 -1
  6. package/dist/actions/gitlabGroupEnsureExists.cjs.js +7 -2
  7. package/dist/actions/gitlabGroupEnsureExists.cjs.js.map +1 -1
  8. package/dist/actions/gitlabIssueCreate.cjs.js +7 -2
  9. package/dist/actions/gitlabIssueCreate.cjs.js.map +1 -1
  10. package/dist/actions/gitlabIssueEdit.cjs.js +7 -2
  11. package/dist/actions/gitlabIssueEdit.cjs.js.map +1 -1
  12. package/dist/actions/gitlabMergeRequest.cjs.js +3 -2
  13. package/dist/actions/gitlabMergeRequest.cjs.js.map +1 -1
  14. package/dist/actions/gitlabPipelineTrigger.cjs.js +7 -2
  15. package/dist/actions/gitlabPipelineTrigger.cjs.js.map +1 -1
  16. package/dist/actions/gitlabProjectAccessTokenCreate.cjs.js +6 -8
  17. package/dist/actions/gitlabProjectAccessTokenCreate.cjs.js.map +1 -1
  18. package/dist/actions/gitlabProjectDeployTokenCreate.cjs.js +7 -2
  19. package/dist/actions/gitlabProjectDeployTokenCreate.cjs.js.map +1 -1
  20. package/dist/actions/gitlabProjectVariableCreate.cjs.js +7 -2
  21. package/dist/actions/gitlabProjectVariableCreate.cjs.js.map +1 -1
  22. package/dist/actions/gitlabRepoPush.cjs.js +3 -2
  23. package/dist/actions/gitlabRepoPush.cjs.js.map +1 -1
  24. package/dist/actions/helpers.cjs.js +11 -1
  25. package/dist/actions/helpers.cjs.js.map +1 -1
  26. package/dist/index.d.ts +10 -0
  27. package/dist/module.cjs.js +35 -10
  28. package/dist/module.cjs.js.map +1 -1
  29. package/dist/util.cjs.js +12 -2
  30. package/dist/util.cjs.js.map +1 -1
  31. package/package.json +2 -2
package/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # @backstage/plugin-scaffolder-backend-module-gitlab
2
2
 
3
+ ## 0.11.10
4
+
5
+ ### Patch Changes
6
+
7
+ - 6fb2a41: Added support for requiring user-provided credentials for GitLab mutation actions when `scaffolder.requireScmUserCredentials` is enabled.
8
+ - Updated dependencies
9
+ - @backstage/integration@2.1.1
10
+
3
11
  ## 0.11.9
4
12
 
5
13
  ### Patch Changes
@@ -158,6 +158,19 @@ function createPublishGitlabAction(options) {
158
158
  `No matching integration configuration for host ${host}, please check your integrations config`
159
159
  );
160
160
  }
161
+ const requireScmUserCredentials = config.getOptionalBoolean(
162
+ "scaffolder.requireScmUserCredentials"
163
+ );
164
+ if (requireScmUserCredentials && !ctx.input.token) {
165
+ throw new errors.InputError(
166
+ `No user credentials provided for host ${host}, but scaffolder.requireScmUserCredentials is enabled`
167
+ );
168
+ }
169
+ if (requireScmUserCredentials && (setUserAsOwner || ctx.input.ownerUsername)) {
170
+ throw new errors.InputError(
171
+ "The setUserAsOwner and ownerUsername inputs cannot be used when scaffolder.requireScmUserCredentials is enabled because they require credentials from the GitLab integration"
172
+ );
173
+ }
161
174
  if (!integrationConfig.config.token && !ctx.input.token) {
162
175
  throw new errors.InputError(`No token available for host ${host}`);
163
176
  }
@@ -1 +1 @@
1
- {"version":3,"file":"gitlab.cjs.js","sources":["../../src/actions/gitlab.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 { InputError } from '@backstage/errors';\nimport { ScmIntegrationRegistry } from '@backstage/integration';\nimport {\n createTemplateAction,\n getRepoSourceDirectory,\n initRepoAndPush,\n parseRepoUrl,\n} from '@backstage/plugin-scaffolder-node';\nimport { Gitlab, VariableType } from '@gitbeaker/rest';\nimport { Config } from '@backstage/config';\nimport { examples } from './gitlab.examples';\n\n/**\n * Creates a new action that initializes a git repository of the content in the workspace\n * and publishes it to GitLab.\n *\n * @public\n */\nexport function createPublishGitlabAction(options: {\n integrations: ScmIntegrationRegistry;\n config: Config;\n}) {\n const { integrations, config } = options;\n\n return createTemplateAction({\n id: 'publish:gitlab',\n description:\n 'Initializes a git repository of the content in the workspace, and publishes it to GitLab.',\n examples,\n schema: {\n input: {\n repoUrl: z =>\n z.string({\n description: `Accepts the format 'gitlab.com?repo=project_name&owner=group_name' where 'project_name' is the repository name and 'group_name' is a group or username`,\n }),\n repoVisibility: z =>\n z\n .enum(['private', 'public', 'internal'], {\n description: `Sets the visibility of the repository. The default value is 'private'. (deprecated, use settings.visibility instead)`,\n })\n .optional(),\n defaultBranch: z =>\n z\n .string({\n description: `Sets the default branch on the repository. The default value is 'master'`,\n })\n .optional(),\n gitCommitMessage: z =>\n z\n .string({\n description: `Sets the commit message on the repository. The default value is 'initial commit'`,\n })\n .optional(),\n gitAuthorName: z =>\n z\n .string({\n description: `Sets the default author name for the commit. The default value is 'Scaffolder'`,\n })\n .optional(),\n gitAuthorEmail: z =>\n z\n .string({\n description: `Sets the default author email for the commit.`,\n })\n .optional(),\n signCommit: z =>\n z\n .boolean({\n description: 'Sign commit with configured PGP private key',\n })\n .optional(),\n sourcePath: z =>\n z\n .union([z.string(), z.boolean()], {\n description:\n 'Path within the workspace that will be used as the repository root. If omitted or set to true, the entire workspace will be published as the repository. If set to false, the created repository will be empty.',\n })\n .optional(),\n skipExisting: z =>\n z\n .boolean({\n description:\n 'Do not publish the repository if it already exists. The default value is false.',\n })\n .optional(),\n token: z =>\n z\n .string({\n description: 'The token to use for authorization to GitLab',\n })\n .optional(),\n setUserAsOwner: z =>\n z\n .boolean({\n description:\n 'Set the token user as owner of the newly created repository. Requires a token authorized to do the edit in the integration configuration for the matching host',\n })\n .optional(),\n ownerUsername: z =>\n z\n .string({\n description:\n 'Username of a GitLab user to add as owner (access level 50) of the newly created project. Requires a privileged token in the integration configuration for the matching host.',\n })\n .optional(),\n topics: z =>\n z\n .array(z.string(), {\n description:\n 'Topic labels to apply on the repository. (deprecated, use settings.topics instead)',\n })\n .optional(),\n settings: z =>\n z\n .object({\n name: z\n .string({\n description:\n 'Human-readable project name (title). If not provided, the repository name from repoUrl is used.',\n })\n .optional(),\n path: z\n .string({\n description:\n 'Repository name for new project. Generated based on name if not provided (generated as lowercase with dashes).',\n })\n .optional(),\n auto_devops_enabled: z\n .boolean({\n description: 'Enable Auto DevOps for this project',\n })\n .optional(),\n ci_config_path: z\n .string({\n description: 'Custom CI config path for this project',\n })\n .optional(),\n description: z\n .string({\n description: 'Short project description',\n })\n .optional(),\n merge_method: z\n .enum(['merge', 'rebase_merge', 'ff'], {\n description: 'Merge Methods (merge, rebase_merge, ff)',\n })\n .optional(),\n squash_option: z\n .enum(['default_off', 'default_on', 'never', 'always'], {\n description:\n 'Set squash option for the project (never, always, default_on, default_off)',\n })\n .optional(),\n topics: z\n .array(z.string(), {\n description: 'Topic labels to apply on the repository',\n })\n .optional(),\n visibility: z\n .enum(['private', 'public', 'internal'], {\n description:\n 'The visibility of the project. Can be private, internal, or public. The default value is private.',\n })\n .optional(),\n only_allow_merge_if_all_discussions_are_resolved: z\n .boolean({\n description:\n 'Set whether merge requests can only be merged when all the discussions are resolved.',\n })\n .optional(),\n only_allow_merge_if_pipeline_succeeds: z\n .boolean({\n description:\n 'Set whether merge requests can only be merged with successful pipelines. This setting is named Pipelines must succeed in the project settings.',\n })\n .optional(),\n allow_merge_on_skipped_pipeline: z\n .boolean({\n description:\n 'Set whether or not merge requests can be merged with skipped jobs.',\n })\n .optional(),\n })\n .optional(),\n branches: z =>\n z\n .array(\n z.object({\n name: z.string(),\n protect: z.boolean().optional(),\n create: z.boolean().optional(),\n ref: z.string().optional(),\n }),\n )\n .optional(),\n projectVariables: z =>\n z\n .array(\n z.object({\n key: z.string(),\n value: z.string(),\n description: z.string().optional(),\n variable_type: z.enum(['env_var', 'file']).optional(),\n protected: z.boolean().optional(),\n masked: z.boolean().optional(),\n masked_and_hidden: z.boolean().optional(),\n raw: z.boolean().optional(),\n environment_scope: z.string().optional(),\n }),\n )\n .optional(),\n },\n output: {\n remoteUrl: z =>\n z.string({\n description: 'A URL to the repository with the provider',\n }),\n repoContentsUrl: z =>\n z.string({\n description: 'A URL to the root of the repository',\n }),\n projectId: z =>\n z.number({\n description: 'The ID of the project',\n }),\n commitHash: z =>\n z.string({\n description: 'The git commit hash of the initial commit',\n }),\n created: z =>\n z.boolean({\n description: 'Whether the repository was created or not',\n }),\n },\n },\n async handler(ctx) {\n const {\n repoUrl,\n repoVisibility = 'private',\n defaultBranch = 'master',\n gitCommitMessage = 'initial commit',\n gitAuthorName,\n gitAuthorEmail,\n setUserAsOwner = false,\n topics = [],\n settings = {},\n branches = [],\n projectVariables = [],\n skipExisting = false,\n signCommit,\n } = ctx.input;\n const { owner, repo, host } = parseRepoUrl(repoUrl, integrations);\n\n if (!owner) {\n throw new InputError(\n `No owner provided for host: ${host}, and repo ${repo}`,\n );\n }\n\n const integrationConfig = integrations.gitlab.byHost(host);\n\n if (!integrationConfig) {\n throw new InputError(\n `No matching integration configuration for host ${host}, please check your integrations config`,\n );\n }\n\n if (!integrationConfig.config.token && !ctx.input.token) {\n throw new InputError(`No token available for host ${host}`);\n }\n\n const token = ctx.input.token || integrationConfig.config.token!;\n const tokenType = ctx.input.token ? 'oauthToken' : 'token';\n\n const client = new Gitlab({\n host: integrationConfig.config.baseUrl,\n [tokenType]: token,\n });\n\n let targetNamespaceId;\n let targetNamespaceKind;\n try {\n const namespaceResponse = (await client.Namespaces.show(owner)) as {\n id: number;\n kind: string;\n };\n\n targetNamespaceId = namespaceResponse.id;\n targetNamespaceKind = namespaceResponse.kind;\n } catch (e) {\n if (e.cause?.response?.status === 404) {\n throw new InputError(\n `The namespace ${owner} is not found or the user doesn't have permissions to access it`,\n );\n }\n throw e;\n }\n\n const { id: userId } = (await client.Users.showCurrentUser()) as {\n id: number;\n };\n\n if (!targetNamespaceId) {\n targetNamespaceId = userId;\n targetNamespaceKind = 'user';\n }\n\n const existingProjects =\n targetNamespaceKind === 'user'\n ? await client.Users.allProjects(owner, { search: repo })\n : await client.Groups.allProjects(owner, { search: repo });\n\n const existingProject = existingProjects.find(\n project => project.path === repo,\n );\n\n if (!skipExisting || (skipExisting && !existingProject)) {\n ctx.logger.info(`Creating repo ${repo} in namespace ${owner}.`);\n const { id: projectId, http_url_to_repo } =\n await client.Projects.create({\n namespaceId: targetNamespaceId,\n name: repo,\n path: repo,\n visibility: repoVisibility,\n ...(topics.length ? { topics } : {}),\n ...(Object.keys(settings).length ? { ...settings } : {}),\n });\n\n // When setUserAsOwner is true the input token is expected to come from an unprivileged user GitLab\n // OAuth flow. In this case GitLab works in a way that allows the unprivileged user to\n // create the repository, but not to push the default protected branch (e.g. master).\n // In order to set the user as owner of the newly created repository we need to check that the\n // GitLab integration configuration for the matching host contains a token and use\n // such token to bootstrap a new privileged client.\n if (setUserAsOwner && integrationConfig.config.token) {\n const adminClient = new Gitlab({\n host: integrationConfig.config.baseUrl,\n token: integrationConfig.config.token,\n });\n\n await adminClient.ProjectMembers.add(projectId, 50, { userId });\n }\n\n if (ctx.input.ownerUsername && integrationConfig.config.token) {\n try {\n const adminClient = new Gitlab({\n host: integrationConfig.config.baseUrl,\n token: integrationConfig.config.token,\n });\n\n const users = await adminClient.Users.all({\n username: ctx.input.ownerUsername,\n });\n if (users.length > 0) {\n await adminClient.ProjectMembers.add(projectId, 50, {\n userId: users[0].id,\n });\n } else {\n ctx.logger.warn(\n `Could not find GitLab user with username '${ctx.input.ownerUsername}'. Skipping owner assignment.`,\n );\n }\n } catch (e) {\n const errorMessage = e instanceof Error ? e.message : String(e);\n ctx.logger.warn(\n `Failed to add user '${ctx.input.ownerUsername}' as owner: ${errorMessage}. Proceeding without owner assignment.`,\n );\n }\n }\n\n const remoteUrl = (http_url_to_repo as string).replace(/\\.git$/, '');\n const repoContentsUrl = `${remoteUrl}/-/blob/${defaultBranch}`;\n\n const gitAuthorInfo = {\n name: gitAuthorName\n ? gitAuthorName\n : config.getOptionalString('scaffolder.defaultAuthor.name'),\n email: gitAuthorEmail\n ? gitAuthorEmail\n : config.getOptionalString('scaffolder.defaultAuthor.email'),\n };\n const signingKey =\n integrationConfig.config.commitSigningKey ??\n config.getOptionalString('scaffolder.defaultCommitSigningKey');\n if (signCommit && !signingKey) {\n throw new Error(\n 'Signing commits is enabled but no signing key is provided in the configuration',\n );\n }\n\n const shouldSkipPublish =\n typeof ctx.input.sourcePath === 'boolean' && !ctx.input.sourcePath;\n if (!shouldSkipPublish) {\n const commitResult = await initRepoAndPush({\n dir:\n typeof ctx.input.sourcePath === 'boolean'\n ? ctx.workspacePath\n : getRepoSourceDirectory(\n ctx.workspacePath,\n ctx.input.sourcePath,\n ),\n remoteUrl: http_url_to_repo as string,\n defaultBranch,\n auth: {\n username: 'oauth2',\n password: token,\n },\n logger: ctx.logger,\n commitMessage: gitCommitMessage\n ? gitCommitMessage\n : config.getOptionalString('scaffolder.defaultCommitMessage'),\n gitAuthorInfo,\n signingKey: signCommit ? signingKey : undefined,\n });\n\n if (branches) {\n for (const branch of branches) {\n const {\n name,\n protect = false,\n create = false,\n ref = 'master',\n } = branch;\n\n if (create) {\n try {\n await client.Branches.create(projectId, name, ref);\n } catch (e) {\n throw new InputError(\n `Branch creation failed for ${name}. ${printGitlabError(\n e,\n )}`,\n );\n }\n ctx.logger.info(\n `Branch ${name} created for ${projectId} with ref ${ref}`,\n );\n }\n\n if (protect) {\n try {\n await client.ProtectedBranches.protect(projectId, name);\n } catch (e) {\n throw new InputError(\n `Branch protection failed for ${name}. ${printGitlabError(\n e,\n )}`,\n );\n }\n ctx.logger.info(`Branch ${name} protected for ${projectId}`);\n }\n }\n }\n ctx.output('commitHash', commitResult?.commitHash);\n }\n\n if (projectVariables) {\n for (const variable of projectVariables) {\n const variableWithDefaults = Object.assign(variable, {\n variable_type: (variable.variable_type ??\n 'env_var') as VariableType,\n protected: variable.protected ?? false,\n masked: variable.masked ?? false,\n masked_and_hidden: variable.masked_and_hidden ?? false,\n raw: variable.raw ?? false,\n environment_scope: variable.environment_scope ?? '*',\n });\n\n try {\n await client.ProjectVariables.create(\n projectId,\n variableWithDefaults.key,\n variableWithDefaults.value,\n {\n variableType: variableWithDefaults.variable_type,\n protected: variableWithDefaults.protected,\n masked: variableWithDefaults.masked,\n masked_and_hidden: variableWithDefaults.masked_and_hidden,\n environmentScope: variableWithDefaults.environment_scope,\n description: variableWithDefaults.description,\n raw: variableWithDefaults.raw,\n },\n );\n } catch (e) {\n throw new InputError(\n `Environment variable creation failed for ${\n variableWithDefaults.key\n }. ${printGitlabError(e)}`,\n );\n }\n }\n }\n ctx.output('remoteUrl', remoteUrl);\n ctx.output('repoContentsUrl', repoContentsUrl);\n ctx.output('projectId', projectId);\n ctx.output('created', true);\n } else if (existingProject) {\n ctx.logger.info(`Repo ${repo} already exists in namespace ${owner}.`);\n const {\n id: projectId,\n http_url_to_repo,\n default_branch,\n } = existingProject;\n const remoteUrl = (http_url_to_repo as string).replace(/\\.git$/, '');\n ctx.output('remoteUrl', remoteUrl);\n ctx.output('repoContentsUrl', `${remoteUrl}/-/blob/${default_branch}`);\n ctx.output('projectId', projectId);\n ctx.output('created', false);\n }\n },\n });\n}\n\nfunction printGitlabError(error: any): string {\n return JSON.stringify({ code: error.code, message: error.description });\n}\n"],"names":["createTemplateAction","examples","parseRepoUrl","InputError","Gitlab","initRepoAndPush","getRepoSourceDirectory"],"mappings":";;;;;;;AAkCO,SAAS,0BAA0B,OAAA,EAGvC;AACD,EAAA,MAAM,EAA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,CAAO,aAAa,SAAS,CAAA;AACjC,QAAA,GAAA,CAAI,MAAA,CAAO,WAAW,KAAK,CAAA;AAAA,MAC7B;AAAA,IACF;AAAA,GACD,CAAA;AACH;AAEA,SAAS,iBAAiB,KAAA,EAAoB;AAC5C,EAAA,OAAO,IAAA,CAAK,UAAU,EAAE,IAAA,EAAM,MAAM,IAAA,EAAM,OAAA,EAAS,KAAA,CAAM,WAAA,EAAa,CAAA;AACxE;;;;"}
1
+ {"version":3,"file":"gitlab.cjs.js","sources":["../../src/actions/gitlab.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 { InputError } from '@backstage/errors';\nimport { ScmIntegrationRegistry } from '@backstage/integration';\nimport {\n createTemplateAction,\n getRepoSourceDirectory,\n initRepoAndPush,\n parseRepoUrl,\n} from '@backstage/plugin-scaffolder-node';\nimport { Gitlab, VariableType } from '@gitbeaker/rest';\nimport { Config } from '@backstage/config';\nimport { examples } from './gitlab.examples';\n\n/**\n * Creates a new action that initializes a git repository of the content in the workspace\n * and publishes it to GitLab.\n *\n * @public\n */\nexport function createPublishGitlabAction(options: {\n integrations: ScmIntegrationRegistry;\n config: Config;\n}) {\n const { integrations, config } = options;\n\n return createTemplateAction({\n id: 'publish:gitlab',\n description:\n 'Initializes a git repository of the content in the workspace, and publishes it to GitLab.',\n examples,\n schema: {\n input: {\n repoUrl: z =>\n z.string({\n description: `Accepts the format 'gitlab.com?repo=project_name&owner=group_name' where 'project_name' is the repository name and 'group_name' is a group or username`,\n }),\n repoVisibility: z =>\n z\n .enum(['private', 'public', 'internal'], {\n description: `Sets the visibility of the repository. The default value is 'private'. (deprecated, use settings.visibility instead)`,\n })\n .optional(),\n defaultBranch: z =>\n z\n .string({\n description: `Sets the default branch on the repository. The default value is 'master'`,\n })\n .optional(),\n gitCommitMessage: z =>\n z\n .string({\n description: `Sets the commit message on the repository. The default value is 'initial commit'`,\n })\n .optional(),\n gitAuthorName: z =>\n z\n .string({\n description: `Sets the default author name for the commit. The default value is 'Scaffolder'`,\n })\n .optional(),\n gitAuthorEmail: z =>\n z\n .string({\n description: `Sets the default author email for the commit.`,\n })\n .optional(),\n signCommit: z =>\n z\n .boolean({\n description: 'Sign commit with configured PGP private key',\n })\n .optional(),\n sourcePath: z =>\n z\n .union([z.string(), z.boolean()], {\n description:\n 'Path within the workspace that will be used as the repository root. If omitted or set to true, the entire workspace will be published as the repository. If set to false, the created repository will be empty.',\n })\n .optional(),\n skipExisting: z =>\n z\n .boolean({\n description:\n 'Do not publish the repository if it already exists. The default value is false.',\n })\n .optional(),\n token: z =>\n z\n .string({\n description: 'The token to use for authorization to GitLab',\n })\n .optional(),\n setUserAsOwner: z =>\n z\n .boolean({\n description:\n 'Set the token user as owner of the newly created repository. Requires a token authorized to do the edit in the integration configuration for the matching host',\n })\n .optional(),\n ownerUsername: z =>\n z\n .string({\n description:\n 'Username of a GitLab user to add as owner (access level 50) of the newly created project. Requires a privileged token in the integration configuration for the matching host.',\n })\n .optional(),\n topics: z =>\n z\n .array(z.string(), {\n description:\n 'Topic labels to apply on the repository. (deprecated, use settings.topics instead)',\n })\n .optional(),\n settings: z =>\n z\n .object({\n name: z\n .string({\n description:\n 'Human-readable project name (title). If not provided, the repository name from repoUrl is used.',\n })\n .optional(),\n path: z\n .string({\n description:\n 'Repository name for new project. Generated based on name if not provided (generated as lowercase with dashes).',\n })\n .optional(),\n auto_devops_enabled: z\n .boolean({\n description: 'Enable Auto DevOps for this project',\n })\n .optional(),\n ci_config_path: z\n .string({\n description: 'Custom CI config path for this project',\n })\n .optional(),\n description: z\n .string({\n description: 'Short project description',\n })\n .optional(),\n merge_method: z\n .enum(['merge', 'rebase_merge', 'ff'], {\n description: 'Merge Methods (merge, rebase_merge, ff)',\n })\n .optional(),\n squash_option: z\n .enum(['default_off', 'default_on', 'never', 'always'], {\n description:\n 'Set squash option for the project (never, always, default_on, default_off)',\n })\n .optional(),\n topics: z\n .array(z.string(), {\n description: 'Topic labels to apply on the repository',\n })\n .optional(),\n visibility: z\n .enum(['private', 'public', 'internal'], {\n description:\n 'The visibility of the project. Can be private, internal, or public. The default value is private.',\n })\n .optional(),\n only_allow_merge_if_all_discussions_are_resolved: z\n .boolean({\n description:\n 'Set whether merge requests can only be merged when all the discussions are resolved.',\n })\n .optional(),\n only_allow_merge_if_pipeline_succeeds: z\n .boolean({\n description:\n 'Set whether merge requests can only be merged with successful pipelines. This setting is named Pipelines must succeed in the project settings.',\n })\n .optional(),\n allow_merge_on_skipped_pipeline: z\n .boolean({\n description:\n 'Set whether or not merge requests can be merged with skipped jobs.',\n })\n .optional(),\n })\n .optional(),\n branches: z =>\n z\n .array(\n z.object({\n name: z.string(),\n protect: z.boolean().optional(),\n create: z.boolean().optional(),\n ref: z.string().optional(),\n }),\n )\n .optional(),\n projectVariables: z =>\n z\n .array(\n z.object({\n key: z.string(),\n value: z.string(),\n description: z.string().optional(),\n variable_type: z.enum(['env_var', 'file']).optional(),\n protected: z.boolean().optional(),\n masked: z.boolean().optional(),\n masked_and_hidden: z.boolean().optional(),\n raw: z.boolean().optional(),\n environment_scope: z.string().optional(),\n }),\n )\n .optional(),\n },\n output: {\n remoteUrl: z =>\n z.string({\n description: 'A URL to the repository with the provider',\n }),\n repoContentsUrl: z =>\n z.string({\n description: 'A URL to the root of the repository',\n }),\n projectId: z =>\n z.number({\n description: 'The ID of the project',\n }),\n commitHash: z =>\n z.string({\n description: 'The git commit hash of the initial commit',\n }),\n created: z =>\n z.boolean({\n description: 'Whether the repository was created or not',\n }),\n },\n },\n async handler(ctx) {\n const {\n repoUrl,\n repoVisibility = 'private',\n defaultBranch = 'master',\n gitCommitMessage = 'initial commit',\n gitAuthorName,\n gitAuthorEmail,\n setUserAsOwner = false,\n topics = [],\n settings = {},\n branches = [],\n projectVariables = [],\n skipExisting = false,\n signCommit,\n } = ctx.input;\n const { owner, repo, host } = parseRepoUrl(repoUrl, integrations);\n\n if (!owner) {\n throw new InputError(\n `No owner provided for host: ${host}, and repo ${repo}`,\n );\n }\n\n const integrationConfig = integrations.gitlab.byHost(host);\n\n if (!integrationConfig) {\n throw new InputError(\n `No matching integration configuration for host ${host}, please check your integrations config`,\n );\n }\n\n const requireScmUserCredentials = config.getOptionalBoolean(\n 'scaffolder.requireScmUserCredentials',\n );\n if (requireScmUserCredentials && !ctx.input.token) {\n throw new InputError(\n `No user credentials provided for host ${host}, but scaffolder.requireScmUserCredentials is enabled`,\n );\n }\n if (\n requireScmUserCredentials &&\n (setUserAsOwner || ctx.input.ownerUsername)\n ) {\n throw new InputError(\n 'The setUserAsOwner and ownerUsername inputs cannot be used when scaffolder.requireScmUserCredentials is enabled because they require credentials from the GitLab integration',\n );\n }\n\n if (!integrationConfig.config.token && !ctx.input.token) {\n throw new InputError(`No token available for host ${host}`);\n }\n\n const token = ctx.input.token || integrationConfig.config.token!;\n const tokenType = ctx.input.token ? 'oauthToken' : 'token';\n\n const client = new Gitlab({\n host: integrationConfig.config.baseUrl,\n [tokenType]: token,\n });\n\n let targetNamespaceId;\n let targetNamespaceKind;\n try {\n const namespaceResponse = (await client.Namespaces.show(owner)) as {\n id: number;\n kind: string;\n };\n\n targetNamespaceId = namespaceResponse.id;\n targetNamespaceKind = namespaceResponse.kind;\n } catch (e) {\n if (e.cause?.response?.status === 404) {\n throw new InputError(\n `The namespace ${owner} is not found or the user doesn't have permissions to access it`,\n );\n }\n throw e;\n }\n\n const { id: userId } = (await client.Users.showCurrentUser()) as {\n id: number;\n };\n\n if (!targetNamespaceId) {\n targetNamespaceId = userId;\n targetNamespaceKind = 'user';\n }\n\n const existingProjects =\n targetNamespaceKind === 'user'\n ? await client.Users.allProjects(owner, { search: repo })\n : await client.Groups.allProjects(owner, { search: repo });\n\n const existingProject = existingProjects.find(\n project => project.path === repo,\n );\n\n if (!skipExisting || (skipExisting && !existingProject)) {\n ctx.logger.info(`Creating repo ${repo} in namespace ${owner}.`);\n const { id: projectId, http_url_to_repo } =\n await client.Projects.create({\n namespaceId: targetNamespaceId,\n name: repo,\n path: repo,\n visibility: repoVisibility,\n ...(topics.length ? { topics } : {}),\n ...(Object.keys(settings).length ? { ...settings } : {}),\n });\n\n // When setUserAsOwner is true the input token is expected to come from an unprivileged user GitLab\n // OAuth flow. In this case GitLab works in a way that allows the unprivileged user to\n // create the repository, but not to push the default protected branch (e.g. master).\n // In order to set the user as owner of the newly created repository we need to check that the\n // GitLab integration configuration for the matching host contains a token and use\n // such token to bootstrap a new privileged client.\n if (setUserAsOwner && integrationConfig.config.token) {\n const adminClient = new Gitlab({\n host: integrationConfig.config.baseUrl,\n token: integrationConfig.config.token,\n });\n\n await adminClient.ProjectMembers.add(projectId, 50, { userId });\n }\n\n if (ctx.input.ownerUsername && integrationConfig.config.token) {\n try {\n const adminClient = new Gitlab({\n host: integrationConfig.config.baseUrl,\n token: integrationConfig.config.token,\n });\n\n const users = await adminClient.Users.all({\n username: ctx.input.ownerUsername,\n });\n if (users.length > 0) {\n await adminClient.ProjectMembers.add(projectId, 50, {\n userId: users[0].id,\n });\n } else {\n ctx.logger.warn(\n `Could not find GitLab user with username '${ctx.input.ownerUsername}'. Skipping owner assignment.`,\n );\n }\n } catch (e) {\n const errorMessage = e instanceof Error ? e.message : String(e);\n ctx.logger.warn(\n `Failed to add user '${ctx.input.ownerUsername}' as owner: ${errorMessage}. Proceeding without owner assignment.`,\n );\n }\n }\n\n const remoteUrl = (http_url_to_repo as string).replace(/\\.git$/, '');\n const repoContentsUrl = `${remoteUrl}/-/blob/${defaultBranch}`;\n\n const gitAuthorInfo = {\n name: gitAuthorName\n ? gitAuthorName\n : config.getOptionalString('scaffolder.defaultAuthor.name'),\n email: gitAuthorEmail\n ? gitAuthorEmail\n : config.getOptionalString('scaffolder.defaultAuthor.email'),\n };\n const signingKey =\n integrationConfig.config.commitSigningKey ??\n config.getOptionalString('scaffolder.defaultCommitSigningKey');\n if (signCommit && !signingKey) {\n throw new Error(\n 'Signing commits is enabled but no signing key is provided in the configuration',\n );\n }\n\n const shouldSkipPublish =\n typeof ctx.input.sourcePath === 'boolean' && !ctx.input.sourcePath;\n if (!shouldSkipPublish) {\n const commitResult = await initRepoAndPush({\n dir:\n typeof ctx.input.sourcePath === 'boolean'\n ? ctx.workspacePath\n : getRepoSourceDirectory(\n ctx.workspacePath,\n ctx.input.sourcePath,\n ),\n remoteUrl: http_url_to_repo as string,\n defaultBranch,\n auth: {\n username: 'oauth2',\n password: token,\n },\n logger: ctx.logger,\n commitMessage: gitCommitMessage\n ? gitCommitMessage\n : config.getOptionalString('scaffolder.defaultCommitMessage'),\n gitAuthorInfo,\n signingKey: signCommit ? signingKey : undefined,\n });\n\n if (branches) {\n for (const branch of branches) {\n const {\n name,\n protect = false,\n create = false,\n ref = 'master',\n } = branch;\n\n if (create) {\n try {\n await client.Branches.create(projectId, name, ref);\n } catch (e) {\n throw new InputError(\n `Branch creation failed for ${name}. ${printGitlabError(\n e,\n )}`,\n );\n }\n ctx.logger.info(\n `Branch ${name} created for ${projectId} with ref ${ref}`,\n );\n }\n\n if (protect) {\n try {\n await client.ProtectedBranches.protect(projectId, name);\n } catch (e) {\n throw new InputError(\n `Branch protection failed for ${name}. ${printGitlabError(\n e,\n )}`,\n );\n }\n ctx.logger.info(`Branch ${name} protected for ${projectId}`);\n }\n }\n }\n ctx.output('commitHash', commitResult?.commitHash);\n }\n\n if (projectVariables) {\n for (const variable of projectVariables) {\n const variableWithDefaults = Object.assign(variable, {\n variable_type: (variable.variable_type ??\n 'env_var') as VariableType,\n protected: variable.protected ?? false,\n masked: variable.masked ?? false,\n masked_and_hidden: variable.masked_and_hidden ?? false,\n raw: variable.raw ?? false,\n environment_scope: variable.environment_scope ?? '*',\n });\n\n try {\n await client.ProjectVariables.create(\n projectId,\n variableWithDefaults.key,\n variableWithDefaults.value,\n {\n variableType: variableWithDefaults.variable_type,\n protected: variableWithDefaults.protected,\n masked: variableWithDefaults.masked,\n masked_and_hidden: variableWithDefaults.masked_and_hidden,\n environmentScope: variableWithDefaults.environment_scope,\n description: variableWithDefaults.description,\n raw: variableWithDefaults.raw,\n },\n );\n } catch (e) {\n throw new InputError(\n `Environment variable creation failed for ${\n variableWithDefaults.key\n }. ${printGitlabError(e)}`,\n );\n }\n }\n }\n ctx.output('remoteUrl', remoteUrl);\n ctx.output('repoContentsUrl', repoContentsUrl);\n ctx.output('projectId', projectId);\n ctx.output('created', true);\n } else if (existingProject) {\n ctx.logger.info(`Repo ${repo} already exists in namespace ${owner}.`);\n const {\n id: projectId,\n http_url_to_repo,\n default_branch,\n } = existingProject;\n const remoteUrl = (http_url_to_repo as string).replace(/\\.git$/, '');\n ctx.output('remoteUrl', remoteUrl);\n ctx.output('repoContentsUrl', `${remoteUrl}/-/blob/${default_branch}`);\n ctx.output('projectId', projectId);\n ctx.output('created', false);\n }\n },\n });\n}\n\nfunction printGitlabError(error: any): string {\n return JSON.stringify({ code: error.code, message: error.description });\n}\n"],"names":["createTemplateAction","examples","parseRepoUrl","InputError","Gitlab","initRepoAndPush","getRepoSourceDirectory"],"mappings":";;;;;;;AAkCO,SAAS,0BAA0B,OAAA,EAGvC;AACD,EAAA,MAAM,EAAE,YAAA,EAAc,MAAA,EAAO,GAAI,OAAA;AAEjC,EAAA,OAAOA,yCAAA,CAAqB;AAAA,IAC1B,EAAA,EAAI,gBAAA;AAAA,IACJ,WAAA,EACE,2FAAA;AAAA,cACFC,wBAAA;AAAA,IACA,MAAA,EAAQ;AAAA,MACN,KAAA,EAAO;AAAA,QACL,OAAA,EAAS,CAAA,CAAA,KACP,CAAA,CAAE,MAAA,CAAO;AAAA,UACP,WAAA,EAAa,CAAA,sJAAA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,EAAG,SAAS,CAAA,QAAA,EAAW,cAAc,CAAA,CAAE,CAAA;AACrE,QAAA,GAAA,CAAI,MAAA,CAAO,aAAa,SAAS,CAAA;AACjC,QAAA,GAAA,CAAI,MAAA,CAAO,WAAW,KAAK,CAAA;AAAA,MAC7B;AAAA,IACF;AAAA,GACD,CAAA;AACH;AAEA,SAAS,iBAAiB,KAAA,EAAoB;AAC5C,EAAA,OAAO,IAAA,CAAK,UAAU,EAAE,IAAA,EAAM,MAAM,IAAA,EAAM,OAAA,EAAS,KAAA,CAAM,WAAA,EAAa,CAAA;AACxE;;;;"}
@@ -28,7 +28,7 @@ function resolveAccessLevel(level) {
28
28
  return resolved;
29
29
  }
30
30
  const createGitlabGroupAccessAction = (options) => {
31
- const { integrations } = options;
31
+ const { integrations, requireScmUserCredentials } = options;
32
32
  return pluginScaffolderNode.createTemplateAction({
33
33
  id: "gitlab:group:access",
34
34
  description: "Adds or removes users and groups from a GitLab group",
@@ -103,7 +103,12 @@ const createGitlabGroupAccessAction = (options) => {
103
103
  return;
104
104
  }
105
105
  const host = util.parseRepoHost(repoUrl);
106
- const api = util.getClient({ host, integrations, token });
106
+ const api = util.getClient({
107
+ host,
108
+ integrations,
109
+ token,
110
+ requireScmUserCredentials
111
+ });
107
112
  for (const userId of userIds) {
108
113
  ctx.logger.info(
109
114
  `${action === "add" ? "Adding" : "Removing"} user ${userId} ${action === "add" ? "to" : "from"} group ${path}`
@@ -1 +1 @@
1
- {"version":3,"file":"gitlabGroupAccessAction.cjs.js","sources":["../../src/actions/gitlabGroupAccessAction.ts"],"sourcesContent":["/*\n * Copyright 2026 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 { AccessLevel } from '@gitbeaker/core';\nimport { getClient, parseRepoHost } from '../util';\nimport { examples } from './gitlabGroupAccessAction.examples';\n\ntype NonAdminAccessLevel = Exclude<AccessLevel, AccessLevel.ADMIN>;\n\nconst accessLevelMapping: Record<string, number> = {\n no_access: 0,\n minimal_access: 5,\n guest: 10,\n planner: 15,\n reporter: 20,\n developer: 30,\n maintainer: 40,\n owner: 50,\n};\n\nfunction resolveAccessLevel(level: string | number): number {\n if (typeof level === 'number') return level;\n const resolved = accessLevelMapping[level.toLocaleLowerCase('en-US')];\n if (resolved === undefined) {\n throw new InputError(\n `Invalid access level: \"${level}\". Valid values are: ${Object.keys(\n accessLevelMapping,\n ).join(', ')} or a numeric GitLab access level`,\n );\n }\n return resolved;\n}\n\n/**\n * Creates a `gitlab:group:access` Scaffolder action.\n *\n * @public\n */\nexport const createGitlabGroupAccessAction = (options: {\n integrations: ScmIntegrationRegistry;\n}) => {\n const { integrations } = options;\n\n return createTemplateAction({\n id: 'gitlab:group:access',\n description: 'Adds or removes users and groups from a GitLab group',\n supportsDryRun: true,\n examples,\n schema: {\n input: {\n repoUrl: z =>\n z.string({\n description:\n \"The host of the GitLab instance, for example 'gitlab.com' or 'gitlab.my-company.com'.\",\n }),\n token: z =>\n z\n .string({\n description: 'The token to use for authorization to GitLab',\n })\n .optional(),\n path: z =>\n z.union([z.number(), z.string()], {\n description:\n 'The ID or path of the group to add/remove members from',\n }),\n userIds: z =>\n z\n .array(z.number(), {\n description: 'The IDs of the users to add/remove',\n })\n .optional(),\n groupIds: z =>\n z\n .array(z.number(), {\n description:\n 'The IDs of the groups to share with or unshare from the target group',\n })\n .optional(),\n action: z =>\n z\n .enum(['add', 'remove'], {\n description:\n 'The action to perform: add or remove the members. Defaults to \"add\".',\n })\n .default('add')\n .optional(),\n accessLevel: z =>\n z\n .union([z.number(), z.string()], {\n description:\n 'The access level for the members. Can be a number (0=No access, 5=Minimal access, 10=Guest, 15=Planner, 20=Reporter, 30=Developer, 40=Maintainer, 50=Owner) or a string (e.g., \"guest\", \"developer\"). Defaults to 30 (Developer).',\n })\n .default(30)\n .optional(),\n },\n output: {\n userIds: z =>\n z\n .array(z.number(), {\n description: 'The IDs of the users that were added or removed',\n })\n .optional(),\n groupIds: z =>\n z\n .array(z.number(), {\n description:\n 'The IDs of the groups that were shared with or unshared from',\n })\n .optional(),\n path: z =>\n z\n .union([z.number(), z.string()], {\n description:\n 'The ID or path of the group the members were added to or removed from',\n })\n .optional(),\n accessLevel: z =>\n z\n .number({\n description:\n 'The access level granted to the members (only for add action)',\n })\n .optional(),\n },\n },\n async handler(ctx) {\n const {\n token,\n repoUrl,\n path,\n userIds = [],\n groupIds = [],\n accessLevel: rawAccessLevel = 30,\n action = 'add',\n } = ctx.input;\n\n if (userIds.length === 0 && groupIds.length === 0) {\n throw new InputError(\n 'At least one of userIds or groupIds must be provided and non-empty',\n );\n }\n\n const accessLevel = resolveAccessLevel(rawAccessLevel);\n\n if (ctx.isDryRun) {\n if (userIds.length > 0) {\n ctx.output('userIds', userIds);\n }\n if (groupIds.length > 0) {\n ctx.output('groupIds', groupIds);\n }\n ctx.output('path', path);\n if (action === 'add') {\n ctx.output('accessLevel', accessLevel);\n }\n return;\n }\n\n const host = parseRepoHost(repoUrl);\n\n const api = getClient({ host, integrations, token });\n\n // Process users\n for (const userId of userIds) {\n ctx.logger.info(\n `${action === 'add' ? 'Adding' : 'Removing'} user ${userId} ${\n action === 'add' ? 'to' : 'from'\n } group ${path}`,\n );\n await ctx.checkpoint({\n key: `gitlab.group.member.user.${action}.${path}.${userId}`,\n fn: async () => {\n if (action === 'add') {\n try {\n await api.GroupMembers.add(\n path,\n accessLevel as NonAdminAccessLevel,\n { userId },\n );\n } catch (error: any) {\n // If member already exists, try to edit instead\n if (error.cause?.response?.status === 409) {\n await api.GroupMembers.edit(\n path,\n userId,\n accessLevel as NonAdminAccessLevel,\n );\n return;\n }\n throw error;\n }\n } else {\n await api.GroupMembers.remove(path, userId);\n }\n },\n });\n }\n\n // Process groups\n for (const sharedGroupId of groupIds) {\n ctx.logger.info(\n `${action === 'add' ? 'Adding' : 'Removing'} group ${sharedGroupId} ${\n action === 'add' ? 'to' : 'from'\n } group ${path}`,\n );\n await ctx.checkpoint({\n key: `gitlab.group.member.group.${action}.${path}.${sharedGroupId}`,\n fn: async () => {\n if (action === 'add') {\n try {\n await api.Groups.share(path, sharedGroupId, accessLevel, {});\n } catch (error: any) {\n // If group is already shared, unshare and re-share\n if (error.cause?.response?.status === 409) {\n await api.Groups.unshare(path, sharedGroupId, {});\n await api.Groups.share(path, sharedGroupId, accessLevel, {});\n return;\n }\n throw error;\n }\n } else {\n await api.Groups.unshare(path, sharedGroupId, {});\n }\n },\n });\n }\n\n ctx.output('path', path);\n\n if (userIds.length > 0) {\n ctx.output('userIds', userIds);\n }\n if (groupIds.length > 0) {\n ctx.output('groupIds', groupIds);\n }\n\n if (action === 'add') {\n ctx.output('accessLevel', accessLevel);\n }\n },\n });\n};\n"],"names":["InputError","createTemplateAction","examples","parseRepoHost","getClient"],"mappings":";;;;;;;AAyBA,MAAM,kBAAA,GAA6C;AAAA,EACjD,SAAA,EAAW,CAAA;AAAA,EACX,cAAA,EAAgB,CAAA;AAAA,EAChB,KAAA,EAAO,EAAA;AAAA,EACP,OAAA,EAAS,EAAA;AAAA,EACT,QAAA,EAAU,EAAA;AAAA,EACV,SAAA,EAAW,EAAA;AAAA,EACX,UAAA,EAAY,EAAA;AAAA,EACZ,KAAA,EAAO;AACT,CAAA;AAEA,SAAS,mBAAmB,KAAA,EAAgC;AAC1D,EAAA,IAAI,OAAO,KAAA,KAAU,QAAA,EAAU,OAAO,KAAA;AACtC,EAAA,MAAM,QAAA,GAAW,kBAAA,CAAmB,KAAA,CAAM,iBAAA,CAAkB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kBAAA,MAAM,IAAI,MAAA,CAAO,OAAA,CAAQ,IAAA,EAAM,aAAA,EAAe,EAAE,CAAA;AAChD,kBAAA,MAAM,IAAI,MAAA,CAAO,KAAA,CAAM,MAAM,aAAA,EAAe,WAAA,EAAa,EAAE,CAAA;AAC3D,kBAAA;AAAA,gBACF;AACA,gBAAA,MAAM,KAAA;AAAA,cACR;AAAA,YACF,CAAA,MAAO;AACL,cAAA,MAAM,IAAI,MAAA,CAAO,OAAA,CAAQ,IAAA,EAAM,aAAA,EAAe,EAAE,CAAA;AAAA,YAClD;AAAA,UACF;AAAA,SACD,CAAA;AAAA,MACH;AAEA,MAAA,GAAA,CAAI,MAAA,CAAO,QAAQ,IAAI,CAAA;AAEvB,MAAA,IAAI,OAAA,CAAQ,SAAS,CAAA,EAAG;AACtB,QAAA,GAAA,CAAI,MAAA,CAAO,WAAW,OAAO,CAAA;AAAA,MAC/B;AACA,MAAA,IAAI,QAAA,CAAS,SAAS,CAAA,EAAG;AACvB,QAAA,GAAA,CAAI,MAAA,CAAO,YAAY,QAAQ,CAAA;AAAA,MACjC;AAEA,MAAA,IAAI,WAAW,KAAA,EAAO;AACpB,QAAA,GAAA,CAAI,MAAA,CAAO,eAAe,WAAW,CAAA;AAAA,MACvC;AAAA,IACF;AAAA,GACD,CAAA;AACH;;;;"}
1
+ {"version":3,"file":"gitlabGroupAccessAction.cjs.js","sources":["../../src/actions/gitlabGroupAccessAction.ts"],"sourcesContent":["/*\n * Copyright 2026 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 { AccessLevel } from '@gitbeaker/core';\nimport { getClient, parseRepoHost } from '../util';\nimport { examples } from './gitlabGroupAccessAction.examples';\n\ntype NonAdminAccessLevel = Exclude<AccessLevel, AccessLevel.ADMIN>;\n\nconst accessLevelMapping: Record<string, number> = {\n no_access: 0,\n minimal_access: 5,\n guest: 10,\n planner: 15,\n reporter: 20,\n developer: 30,\n maintainer: 40,\n owner: 50,\n};\n\nfunction resolveAccessLevel(level: string | number): number {\n if (typeof level === 'number') return level;\n const resolved = accessLevelMapping[level.toLocaleLowerCase('en-US')];\n if (resolved === undefined) {\n throw new InputError(\n `Invalid access level: \"${level}\". Valid values are: ${Object.keys(\n accessLevelMapping,\n ).join(', ')} or a numeric GitLab access level`,\n );\n }\n return resolved;\n}\n\n/**\n * Creates a `gitlab:group:access` Scaffolder action.\n *\n * @public\n */\nexport const createGitlabGroupAccessAction = (options: {\n integrations: ScmIntegrationRegistry;\n requireScmUserCredentials?: boolean;\n}) => {\n const { integrations, requireScmUserCredentials } = options;\n\n return createTemplateAction({\n id: 'gitlab:group:access',\n description: 'Adds or removes users and groups from a GitLab group',\n supportsDryRun: true,\n examples,\n schema: {\n input: {\n repoUrl: z =>\n z.string({\n description:\n \"The host of the GitLab instance, for example 'gitlab.com' or 'gitlab.my-company.com'.\",\n }),\n token: z =>\n z\n .string({\n description: 'The token to use for authorization to GitLab',\n })\n .optional(),\n path: z =>\n z.union([z.number(), z.string()], {\n description:\n 'The ID or path of the group to add/remove members from',\n }),\n userIds: z =>\n z\n .array(z.number(), {\n description: 'The IDs of the users to add/remove',\n })\n .optional(),\n groupIds: z =>\n z\n .array(z.number(), {\n description:\n 'The IDs of the groups to share with or unshare from the target group',\n })\n .optional(),\n action: z =>\n z\n .enum(['add', 'remove'], {\n description:\n 'The action to perform: add or remove the members. Defaults to \"add\".',\n })\n .default('add')\n .optional(),\n accessLevel: z =>\n z\n .union([z.number(), z.string()], {\n description:\n 'The access level for the members. Can be a number (0=No access, 5=Minimal access, 10=Guest, 15=Planner, 20=Reporter, 30=Developer, 40=Maintainer, 50=Owner) or a string (e.g., \"guest\", \"developer\"). Defaults to 30 (Developer).',\n })\n .default(30)\n .optional(),\n },\n output: {\n userIds: z =>\n z\n .array(z.number(), {\n description: 'The IDs of the users that were added or removed',\n })\n .optional(),\n groupIds: z =>\n z\n .array(z.number(), {\n description:\n 'The IDs of the groups that were shared with or unshared from',\n })\n .optional(),\n path: z =>\n z\n .union([z.number(), z.string()], {\n description:\n 'The ID or path of the group the members were added to or removed from',\n })\n .optional(),\n accessLevel: z =>\n z\n .number({\n description:\n 'The access level granted to the members (only for add action)',\n })\n .optional(),\n },\n },\n async handler(ctx) {\n const {\n token,\n repoUrl,\n path,\n userIds = [],\n groupIds = [],\n accessLevel: rawAccessLevel = 30,\n action = 'add',\n } = ctx.input;\n\n if (userIds.length === 0 && groupIds.length === 0) {\n throw new InputError(\n 'At least one of userIds or groupIds must be provided and non-empty',\n );\n }\n\n const accessLevel = resolveAccessLevel(rawAccessLevel);\n\n if (ctx.isDryRun) {\n if (userIds.length > 0) {\n ctx.output('userIds', userIds);\n }\n if (groupIds.length > 0) {\n ctx.output('groupIds', groupIds);\n }\n ctx.output('path', path);\n if (action === 'add') {\n ctx.output('accessLevel', accessLevel);\n }\n return;\n }\n\n const host = parseRepoHost(repoUrl);\n\n const api = getClient({\n host,\n integrations,\n token,\n requireScmUserCredentials,\n });\n\n // Process users\n for (const userId of userIds) {\n ctx.logger.info(\n `${action === 'add' ? 'Adding' : 'Removing'} user ${userId} ${\n action === 'add' ? 'to' : 'from'\n } group ${path}`,\n );\n await ctx.checkpoint({\n key: `gitlab.group.member.user.${action}.${path}.${userId}`,\n fn: async () => {\n if (action === 'add') {\n try {\n await api.GroupMembers.add(\n path,\n accessLevel as NonAdminAccessLevel,\n { userId },\n );\n } catch (error: any) {\n // If member already exists, try to edit instead\n if (error.cause?.response?.status === 409) {\n await api.GroupMembers.edit(\n path,\n userId,\n accessLevel as NonAdminAccessLevel,\n );\n return;\n }\n throw error;\n }\n } else {\n await api.GroupMembers.remove(path, userId);\n }\n },\n });\n }\n\n // Process groups\n for (const sharedGroupId of groupIds) {\n ctx.logger.info(\n `${action === 'add' ? 'Adding' : 'Removing'} group ${sharedGroupId} ${\n action === 'add' ? 'to' : 'from'\n } group ${path}`,\n );\n await ctx.checkpoint({\n key: `gitlab.group.member.group.${action}.${path}.${sharedGroupId}`,\n fn: async () => {\n if (action === 'add') {\n try {\n await api.Groups.share(path, sharedGroupId, accessLevel, {});\n } catch (error: any) {\n // If group is already shared, unshare and re-share\n if (error.cause?.response?.status === 409) {\n await api.Groups.unshare(path, sharedGroupId, {});\n await api.Groups.share(path, sharedGroupId, accessLevel, {});\n return;\n }\n throw error;\n }\n } else {\n await api.Groups.unshare(path, sharedGroupId, {});\n }\n },\n });\n }\n\n ctx.output('path', path);\n\n if (userIds.length > 0) {\n ctx.output('userIds', userIds);\n }\n if (groupIds.length > 0) {\n ctx.output('groupIds', groupIds);\n }\n\n if (action === 'add') {\n ctx.output('accessLevel', accessLevel);\n }\n },\n });\n};\n"],"names":["InputError","createTemplateAction","examples","parseRepoHost","getClient"],"mappings":";;;;;;;AAyBA,MAAM,kBAAA,GAA6C;AAAA,EACjD,SAAA,EAAW,CAAA;AAAA,EACX,cAAA,EAAgB,CAAA;AAAA,EAChB,KAAA,EAAO,EAAA;AAAA,EACP,OAAA,EAAS,EAAA;AAAA,EACT,QAAA,EAAU,EAAA;AAAA,EACV,SAAA,EAAW,EAAA;AAAA,EACX,UAAA,EAAY,EAAA;AAAA,EACZ,KAAA,EAAO;AACT,CAAA;AAEA,SAAS,mBAAmB,KAAA,EAAgC;AAC1D,EAAA,IAAI,OAAO,KAAA,KAAU,QAAA,EAAU,OAAO,KAAA;AACtC,EAAA,MAAM,QAAA,GAAW,kBAAA,CAAmB,KAAA,CAAM,iBAAA,CAAkB,OAAO,CAAC,CAAA;A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,EAAU,MAAA,KAAW,GAAA,EAAK;AACzC,kBAAA,MAAM,IAAI,MAAA,CAAO,OAAA,CAAQ,IAAA,EAAM,aAAA,EAAe,EAAE,CAAA;AAChD,kBAAA,MAAM,IAAI,MAAA,CAAO,KAAA,CAAM,MAAM,aAAA,EAAe,WAAA,EAAa,EAAE,CAAA;AAC3D,kBAAA;AAAA,gBACF;AACA,gBAAA,MAAM,KAAA;AAAA,cACR;AAAA,YACF,CAAA,MAAO;AACL,cAAA,MAAM,IAAI,MAAA,CAAO,OAAA,CAAQ,IAAA,EAAM,aAAA,EAAe,EAAE,CAAA;AAAA,YAClD;AAAA,UACF;AAAA,SACD,CAAA;AAAA,MACH;AAEA,MAAA,GAAA,CAAI,MAAA,CAAO,QAAQ,IAAI,CAAA;AAEvB,MAAA,IAAI,OAAA,CAAQ,SAAS,CAAA,EAAG;AACtB,QAAA,GAAA,CAAI,MAAA,CAAO,WAAW,OAAO,CAAA;AAAA,MAC/B;AACA,MAAA,IAAI,QAAA,CAAS,SAAS,CAAA,EAAG;AACvB,QAAA,GAAA,CAAI,MAAA,CAAO,YAAY,QAAQ,CAAA;AAAA,MACjC;AAEA,MAAA,IAAI,WAAW,KAAA,EAAO;AACpB,QAAA,GAAA,CAAI,MAAA,CAAO,eAAe,WAAW,CAAA;AAAA,MACvC;AAAA,IACF;AAAA,GACD,CAAA;AACH;;;;"}
@@ -5,7 +5,7 @@ var util = require('../util.cjs.js');
5
5
  var gitlabGroupEnsureExists_examples = require('./gitlabGroupEnsureExists.examples.cjs.js');
6
6
 
7
7
  const createGitlabGroupEnsureExistsAction = (options) => {
8
- const { integrations } = options;
8
+ const { integrations, requireScmUserCredentials } = options;
9
9
  return pluginScaffolderNode.createTemplateAction({
10
10
  id: "gitlab:group:ensureExists",
11
11
  description: "Ensures a Gitlab group exists",
@@ -47,7 +47,12 @@ const createGitlabGroupEnsureExistsAction = (options) => {
47
47
  }
48
48
  const { token, repoUrl, path, description } = ctx.input;
49
49
  const { host } = util.parseRepoUrl(repoUrl, integrations);
50
- const api = util.getClient({ host, integrations, token });
50
+ const api = util.getClient({
51
+ host,
52
+ integrations,
53
+ token,
54
+ requireScmUserCredentials
55
+ });
51
56
  let currentPath = null;
52
57
  let parentId = null;
53
58
  const pathParts = [...pathIterator(path)];
@@ -1 +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, CreateGroupOptions } from '@gitbeaker/rest';\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: {\n repoUrl: z =>\n z.string({\n description: `Accepts the format 'gitlab.com?repo=project_name&owner=group_name' where 'project_name' is the repository name and 'group_name' is a group or username`,\n }),\n token: z =>\n z\n .string({\n description: 'The token to use for authorization to GitLab',\n })\n .optional(),\n description: z =>\n z\n .string({\n description: 'The group’s description',\n })\n .optional(),\n path: z =>\n z\n .array(\n z.string().or(\n z.object({\n name: z.string(),\n slug: z.string(),\n }),\n ),\n {\n description:\n 'A path of group names or objects (name and slug) that is ensured to exist',\n },\n )\n .min(1),\n },\n output: {\n groupId: z =>\n z\n .number({\n description: 'The id of the innermost sub-group',\n })\n .optional(),\n },\n },\n async handler(ctx) {\n if (ctx.isDryRun) {\n ctx.output('groupId', 42);\n return;\n }\n const { token, repoUrl, path, description } = 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 const pathParts = [...pathIterator(path)];\n const lastIndex = pathParts.length - 1;\n for (let i = 0; i < pathParts.length; i++) {\n const { name, slug } = pathParts[i];\n const fullPath: string = currentPath ? `${currentPath}/${slug}` : slug;\n let subGroup: GroupSchema | undefined;\n try {\n subGroup = (await api.Groups.show(\n fullPath,\n )) as unknown as GroupSchema;\n } catch (error: any) {\n // 404 means the group doesn't exist - we'll create it below\n // Any other error should be thrown\n if (error.cause?.response?.status !== 404) {\n throw error;\n }\n }\n if (!subGroup) {\n ctx.logger.info(`creating missing group ${fullPath}`);\n\n parentId = await ctx.checkpoint({\n key: `ensure.${name}.${slug}.${parentId}`,\n // eslint-disable-next-line no-loop-func\n fn: async () => {\n const groupOptions: CreateGroupOptions = {\n ...(parentId ? { parentId } : {}),\n ...(description && i === lastIndex ? { description } : {}),\n };\n return (await api.Groups.create(name, slug, groupOptions))?.id;\n },\n });\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\ntype PathPart = { name: string; slug: string };\ntype PathItem = string | PathPart;\n\nfunction* pathIterator(items: PathItem[]): Generator<PathPart> {\n for (const item of items) {\n if (typeof item === 'string') {\n const parts = item.split('/');\n for (const part of parts) {\n yield { name: part, slug: part };\n }\n } else {\n yield item;\n }\n }\n}\n"],"names":["createTemplateAction","examples","parseRepoUrl","getClient"],"mappings":";;;;;;AA2BO,MAAM,mCAAA,GAAsC,CAAC,OAAA,KA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,YAAY;AACd,cAAA,MAAM,YAAA,GAAmC;AAAA,gBACvC,GAAI,QAAA,GAAW,EAAE,QAAA,KAAa,EAAC;AAAA,gBAC/B,GAAI,WAAA,IAAe,CAAA,KAAM,YAAY,EAAE,WAAA,KAAgB;AAAC,eAC1D;AACA,cAAA,OAAA,CAAQ,MAAM,GAAA,CAAI,MAAA,CAAO,OAAO,IAAA,EAAM,IAAA,EAAM,YAAY,CAAA,GAAI,EAAA;AAAA,YAC9D;AAAA,WACD,CAAA;AAAA,QACH,CAAA,MAAO;AACL,UAAA,QAAA,GAAW,QAAA,CAAS,EAAA;AAAA,QACtB;AACA,QAAA,WAAA,GAAc,QAAA;AAAA,MAChB;AACA,MAAA,IAAI,aAAa,IAAA,EAAM;AACrB,QAAA,GAAA,CAAI,MAAA,CAAO,WAAW,QAAQ,CAAA;AAAA,MAChC;AAAA,IACF;AAAA,GACD,CAAA;AACH;AAKA,UAAU,aAAa,KAAA,EAAwC;AAC7D,EAAA,KAAA,MAAW,QAAQ,KAAA,EAAO;AACxB,IAAA,IAAI,OAAO,SAAS,QAAA,EAAU;AAC5B,MAAA,MAAM,KAAA,GAAQ,IAAA,CAAK,KAAA,CAAM,GAAG,CAAA;AAC5B,MAAA,KAAA,MAAW,QAAQ,KAAA,EAAO;AACxB,QAAA,MAAM,EAAE,IAAA,EAAM,IAAA,EAAM,IAAA,EAAM,IAAA,EAAK;AAAA,MACjC;AAAA,IACF,CAAA,MAAO;AACL,MAAA,MAAM,IAAA;AAAA,IACR;AAAA,EACF;AACF;;;;"}
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, CreateGroupOptions } from '@gitbeaker/rest';\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 requireScmUserCredentials?: boolean;\n}) => {\n const { integrations, requireScmUserCredentials } = 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: {\n repoUrl: z =>\n z.string({\n description: `Accepts the format 'gitlab.com?repo=project_name&owner=group_name' where 'project_name' is the repository name and 'group_name' is a group or username`,\n }),\n token: z =>\n z\n .string({\n description: 'The token to use for authorization to GitLab',\n })\n .optional(),\n description: z =>\n z\n .string({\n description: 'The group’s description',\n })\n .optional(),\n path: z =>\n z\n .array(\n z.string().or(\n z.object({\n name: z.string(),\n slug: z.string(),\n }),\n ),\n {\n description:\n 'A path of group names or objects (name and slug) that is ensured to exist',\n },\n )\n .min(1),\n },\n output: {\n groupId: z =>\n z\n .number({\n description: 'The id of the innermost sub-group',\n })\n .optional(),\n },\n },\n async handler(ctx) {\n if (ctx.isDryRun) {\n ctx.output('groupId', 42);\n return;\n }\n const { token, repoUrl, path, description } = ctx.input;\n\n const { host } = parseRepoUrl(repoUrl, integrations);\n\n const api = getClient({\n host,\n integrations,\n token,\n requireScmUserCredentials,\n });\n\n let currentPath: string | null = null;\n let parentId: number | null = null;\n const pathParts = [...pathIterator(path)];\n const lastIndex = pathParts.length - 1;\n for (let i = 0; i < pathParts.length; i++) {\n const { name, slug } = pathParts[i];\n const fullPath: string = currentPath ? `${currentPath}/${slug}` : slug;\n let subGroup: GroupSchema | undefined;\n try {\n subGroup = (await api.Groups.show(\n fullPath,\n )) as unknown as GroupSchema;\n } catch (error: any) {\n // 404 means the group doesn't exist - we'll create it below\n // Any other error should be thrown\n if (error.cause?.response?.status !== 404) {\n throw error;\n }\n }\n if (!subGroup) {\n ctx.logger.info(`creating missing group ${fullPath}`);\n\n parentId = await ctx.checkpoint({\n key: `ensure.${name}.${slug}.${parentId}`,\n // eslint-disable-next-line no-loop-func\n fn: async () => {\n const groupOptions: CreateGroupOptions = {\n ...(parentId ? { parentId } : {}),\n ...(description && i === lastIndex ? { description } : {}),\n };\n return (await api.Groups.create(name, slug, groupOptions))?.id;\n },\n });\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\ntype PathPart = { name: string; slug: string };\ntype PathItem = string | PathPart;\n\nfunction* pathIterator(items: PathItem[]): Generator<PathPart> {\n for (const item of items) {\n if (typeof item === 'string') {\n const parts = item.split('/');\n for (const part of parts) {\n yield { name: part, slug: part };\n }\n } else {\n yield item;\n }\n }\n}\n"],"names":["createTemplateAction","examples","parseRepoUrl","getClient"],"mappings":";;;;;;AA2BO,MAAM,mCAAA,GAAsC,CAAC,OAAA,KAG9C;AACJ,EAAA,MAAM,EAAE,YAAA,EAAc,yBAAA,EAA0B,GAAI,OAAA;AAEpD,EAAA,OAAOA,yCAAA,CAAqB;AAAA,IAC1B,EAAA,EAAI,2BAAA;AAAA,IACJ,WAAA,EAAa,+BAAA;AAAA,IACb,cAAA,EAAgB,IAAA;AAAA,cAChBC,yCAAA;AAAA,IACA,MAAA,EAAQ;AAAA,MACN,KAAA,EAAO;AAAA,QACL,OAAA,EAAS,CAAA,CAAA,KACP,CAAA,CAAE,MAAA,CAAO;AAAA,UACP,WAAA,EAAa,CAAA,sJAAA;AAAA,SACd,CAAA;AAAA,QACH,KAAA,EAAO,CAAA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,GAAW,QAAA,CAAS,EAAA;AAAA,QACtB;AACA,QAAA,WAAA,GAAc,QAAA;AAAA,MAChB;AACA,MAAA,IAAI,aAAa,IAAA,EAAM;AACrB,QAAA,GAAA,CAAI,MAAA,CAAO,WAAW,QAAQ,CAAA;AAAA,MAChC;AAAA,IACF;AAAA,GACD,CAAA;AACH;AAKA,UAAU,aAAa,KAAA,EAAwC;AAC7D,EAAA,KAAA,MAAW,QAAQ,KAAA,EAAO;AACxB,IAAA,IAAI,OAAO,SAAS,QAAA,EAAU;AAC5B,MAAA,MAAM,KAAA,GAAQ,IAAA,CAAK,KAAA,CAAM,GAAG,CAAA;AAC5B,MAAA,KAAA,MAAW,QAAQ,KAAA,EAAO;AACxB,QAAA,MAAM,EAAE,IAAA,EAAM,IAAA,EAAM,IAAA,EAAM,IAAA,EAAK;AAAA,MACjC;AAAA,IACF,CAAA,MAAO;AACL,MAAA,MAAM,IAAA;AAAA,IACR;AAAA,EACF;AACF;;;;"}
@@ -8,7 +8,7 @@ var util = require('../util.cjs.js');
8
8
  var helpers = require('./helpers.cjs.js');
9
9
 
10
10
  const createGitlabIssueAction = (options) => {
11
- const { integrations } = options;
11
+ const { integrations, requireScmUserCredentials } = options;
12
12
  return pluginScaffolderNode.createTemplateAction({
13
13
  id: "gitlab:issues:create",
14
14
  description: "Creates a Gitlab issue.",
@@ -110,7 +110,12 @@ const createGitlabIssueAction = (options) => {
110
110
  token
111
111
  } = ctx.input;
112
112
  const { host } = util.parseRepoUrl(repoUrl, integrations);
113
- const api = util.getClient({ host, integrations, token });
113
+ const api = util.getClient({
114
+ host,
115
+ integrations,
116
+ token,
117
+ requireScmUserCredentials
118
+ });
114
119
  let isEpicScoped = false;
115
120
  isEpicScoped = await ctx.checkpoint({
116
121
  key: `is.epic.scoped.${projectId}.${title}`,
@@ -1 +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 { IssueType } from '../commonGitlabConfig';\nimport { examples } from './gitlabIssueCreate.examples';\nimport { checkEpicScope, convertDate, getClient, parseRepoUrl } from '../util';\nimport { CreateIssueOptions, IssueSchema } from '@gitbeaker/rest';\nimport { getErrorMessage } from './helpers';\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: {\n repoUrl: z =>\n z.string({\n description: `Accepts the format 'gitlab.com?repo=project_name&owner=group_name' where 'project_name' is the repository name and 'group_name' is a group or username`,\n }),\n token: z =>\n z\n .string({\n description: 'The token to use for authorization to GitLab',\n })\n .optional(),\n projectId: z =>\n z.number({\n description: 'Project Id',\n }),\n title: z =>\n z.string({\n description: 'Title of the issue',\n }),\n assignees: z =>\n z\n .array(z.number(), {\n description: 'IDs of the users to assign the issue to.',\n })\n .optional(),\n confidential: z =>\n z\n .boolean({\n description: 'Issue Confidentiality',\n })\n .optional(),\n description: z =>\n z\n .string({\n description: 'Issue description',\n })\n .max(1048576)\n .optional(),\n createdAt: z =>\n z\n .string({\n description: 'Creation date/time',\n })\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 z\n .string({\n description: 'Due date/time',\n })\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 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 z\n .number({\n description: 'Id of the linked Epic',\n })\n .min(0, 'Valid values should be equal or greater than zero')\n .optional(),\n labels: z =>\n z\n .string({\n description: 'Labels to apply',\n })\n .optional(),\n issueType: z =>\n z\n .nativeEnum(IssueType, {\n description: 'Type of the issue',\n })\n .optional(),\n mergeRequestToResolveDiscussionsOf: z =>\n z\n .number({\n description:\n 'IID of a merge request in which to resolve all issues',\n })\n .optional(),\n milestoneId: z =>\n z\n .number({\n description: 'Global ID of a milestone to assign the issue',\n })\n .optional(),\n weight: z =>\n z\n .number({\n description: 'The issue weight',\n })\n .min(0)\n .refine(\n value => {\n return value >= 0;\n },\n {\n message: 'Valid values should be equal or greater than zero',\n },\n )\n .optional(),\n },\n output: {\n issueUrl: z =>\n z.string({\n description: 'Issue Url',\n }),\n issueId: z =>\n z.number({\n description: 'Issue Id',\n }),\n issueIid: z =>\n z.number({\n description: 'Issue Iid',\n }),\n },\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 } = ctx.input;\n\n const { host } = parseRepoUrl(repoUrl, integrations);\n const api = getClient({ host, integrations, token });\n\n let isEpicScoped = false;\n\n isEpicScoped = await ctx.checkpoint({\n key: `is.epic.scoped.${projectId}.${title}`,\n fn: async () => {\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 return isEpicScoped;\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 ctx.checkpoint({\n key: `issue.${projectId}.${title}`,\n fn: async () => {\n const issue = (await api.Issues.create(\n projectId,\n title,\n issueOptions,\n )) as IssueSchema;\n\n return {\n id: issue.id,\n web_url: issue.web_url,\n iid: issue.iid,\n };\n },\n });\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 // Handling other errors\n throw new InputError(\n `Failed to create GitLab issue: ${getErrorMessage(error)}`,\n );\n }\n },\n });\n};\n"],"names":["createTemplateAction","examples","IssueType","parseRepoUrl","getClient","checkEpicScope","convertDate","InputError","getErrorMessage"],"mappings":";;;;;;;;;AA+BO,MAAM,uBAAA,GAA0B,CAAC,OAAA,KAElC;AACJ,EAAA,MAAM,EAAE,cAAa,GAAI,OAAA;AACzB,EAAA,OAAOA,yCAAA,CAAqB;AAAA,IAC1B,EAAA,EAAI,sBAAA;AAAA,IACJ,WAAA,EAAa,yBAAA;AAAA,cACbC,mCAAA;AAAA,IACA,MAAA,EAAQ;AAAA,MACN,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AA,EAAY,QAAA,CAAS,GAAG,CAAA;AAAA,MACrC,SAAS,KAAA,EAAY;AAEnB,QAAA,MAAM,IAAIC,iBAAA;AAAA,UACR,CAAA,+BAAA,EAAkCC,uBAAA,CAAgB,KAAK,CAAC,CAAA;AAAA,SAC1D;AAAA,MACF;AAAA,IACF;AAAA,GACD,CAAA;AACH;;;;"}
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 { IssueType } from '../commonGitlabConfig';\nimport { examples } from './gitlabIssueCreate.examples';\nimport { checkEpicScope, convertDate, getClient, parseRepoUrl } from '../util';\nimport { CreateIssueOptions, IssueSchema } from '@gitbeaker/rest';\nimport { getErrorMessage } from './helpers';\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 requireScmUserCredentials?: boolean;\n}) => {\n const { integrations, requireScmUserCredentials } = options;\n return createTemplateAction({\n id: 'gitlab:issues:create',\n description: 'Creates a Gitlab issue.',\n examples,\n schema: {\n input: {\n repoUrl: z =>\n z.string({\n description: `Accepts the format 'gitlab.com?repo=project_name&owner=group_name' where 'project_name' is the repository name and 'group_name' is a group or username`,\n }),\n token: z =>\n z\n .string({\n description: 'The token to use for authorization to GitLab',\n })\n .optional(),\n projectId: z =>\n z.number({\n description: 'Project Id',\n }),\n title: z =>\n z.string({\n description: 'Title of the issue',\n }),\n assignees: z =>\n z\n .array(z.number(), {\n description: 'IDs of the users to assign the issue to.',\n })\n .optional(),\n confidential: z =>\n z\n .boolean({\n description: 'Issue Confidentiality',\n })\n .optional(),\n description: z =>\n z\n .string({\n description: 'Issue description',\n })\n .max(1048576)\n .optional(),\n createdAt: z =>\n z\n .string({\n description: 'Creation date/time',\n })\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 z\n .string({\n description: 'Due date/time',\n })\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 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 z\n .number({\n description: 'Id of the linked Epic',\n })\n .min(0, 'Valid values should be equal or greater than zero')\n .optional(),\n labels: z =>\n z\n .string({\n description: 'Labels to apply',\n })\n .optional(),\n issueType: z =>\n z\n .nativeEnum(IssueType, {\n description: 'Type of the issue',\n })\n .optional(),\n mergeRequestToResolveDiscussionsOf: z =>\n z\n .number({\n description:\n 'IID of a merge request in which to resolve all issues',\n })\n .optional(),\n milestoneId: z =>\n z\n .number({\n description: 'Global ID of a milestone to assign the issue',\n })\n .optional(),\n weight: z =>\n z\n .number({\n description: 'The issue weight',\n })\n .min(0)\n .refine(\n value => {\n return value >= 0;\n },\n {\n message: 'Valid values should be equal or greater than zero',\n },\n )\n .optional(),\n },\n output: {\n issueUrl: z =>\n z.string({\n description: 'Issue Url',\n }),\n issueId: z =>\n z.number({\n description: 'Issue Id',\n }),\n issueIid: z =>\n z.number({\n description: 'Issue Iid',\n }),\n },\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 } = ctx.input;\n\n const { host } = parseRepoUrl(repoUrl, integrations);\n const api = getClient({\n host,\n integrations,\n token,\n requireScmUserCredentials,\n });\n\n let isEpicScoped = false;\n\n isEpicScoped = await ctx.checkpoint({\n key: `is.epic.scoped.${projectId}.${title}`,\n fn: async () => {\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 return isEpicScoped;\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 ctx.checkpoint({\n key: `issue.${projectId}.${title}`,\n fn: async () => {\n const issue = (await api.Issues.create(\n projectId,\n title,\n issueOptions,\n )) as IssueSchema;\n\n return {\n id: issue.id,\n web_url: issue.web_url,\n iid: issue.iid,\n };\n },\n });\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 // Handling other errors\n throw new InputError(\n `Failed to create GitLab issue: ${getErrorMessage(error)}`,\n );\n }\n },\n });\n};\n"],"names":["createTemplateAction","examples","IssueType","parseRepoUrl","getClient","checkEpicScope","convertDate","InputError","getErrorMessage"],"mappings":";;;;;;;;;AA+BO,MAAM,uBAAA,GAA0B,CAAC,OAAA,KAGlC;AACJ,EAAA,MAAM,EAAE,YAAA,EAAc,yBAAA,EAA0B,GAAI,OAAA;AACpD,EAAA,OAAOA,yCAAA,CAAqB;AAAA,IAC1B,EAAA,EAAI,sBAAA;AAAA,IACJ,WAAA,EAAa,yBAAA;AAAA,cACbC,mCAAA;AAAA,IACA,MAAA,EAAQ;AAAA,MACN,KAAA,EAAO;AAAA,QACL,OAAA,EAAS,CAAA,CAAA,KACP,CAAA,CAAE,MAAA,CAAO;AAAA,UACP,WAAA,EAAa,CAAA,sJAAA;AAAA,SACd,CAAA;AAAA,QACH,KAAA,EAAO,CAAA,CAAA,KACL,CAAA,CACG,MAAA,CAAO;AAAA,UACN,WAAA,EAAa;AAAA,SACd,EACA,QAAA,EAAS;AAAA,QACd,SAAA,EAAW,CAAA,CAAA,KACT,CAAA,CAAE,MAAA,CAAO;AAAA,UACP,WAAA,EAAa;AAAA,SACd,CAAA;AAAA,QACH,KAAA,EAAO,CAAA,CAAA,KACL,CAAA,CAAE,MAAA,CAAO;AAAA,UACP,WAAA,EAAa;AAAA,SACd,CAAA;AAAA,QACH,WAAW,CAAA,CAAA,KACT,CAAA,CACG,KAAA,CAAM,CAAA,CAAE,QAAO,EAAG;AAAA,UACjB,WAAA,EAAa;AAAA,SACd,EACA,QAAA,EAAS;AAAA,QACd,YAAA,EAAc,CAAA,CAAA,KACZ,CAAA,CACG,OAAA,CAAQ;AAAA,UACP,WAAA,EAAa;AAAA,SACd,EACA,QAAA,EAAS;AAAA,QACd,WAAA,EAAa,CAAA,CAAA,KACX,CAAA,CACG,MAAA,CAAO;AAAA,UACN,WAAA,EAAa;AAAA,SACd,CAAA,CACA,GAAA,CAAI,OAAO,EACX,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AA,GAAS,MAAM,GAAA,CAAI,MAAA,CAAO,MAAA;AAAA,cAC9B,SAAA;AAAA,cACA,KAAA;AAAA,cACA;AAAA,aACF;AAEA,YAAA,OAAO;AAAA,cACL,IAAI,KAAA,CAAM,EAAA;AAAA,cACV,SAAS,KAAA,CAAM,OAAA;AAAA,cACf,KAAK,KAAA,CAAM;AAAA,aACb;AAAA,UACF;AAAA,SACD,CAAA;AAED,QAAA,GAAA,CAAI,MAAA,CAAO,SAAA,EAAW,QAAA,CAAS,EAAE,CAAA;AACjC,QAAA,GAAA,CAAI,MAAA,CAAO,UAAA,EAAY,QAAA,CAAS,OAAO,CAAA;AACvC,QAAA,GAAA,CAAI,MAAA,CAAO,UAAA,EAAY,QAAA,CAAS,GAAG,CAAA;AAAA,MACrC,SAAS,KAAA,EAAY;AAEnB,QAAA,MAAM,IAAIC,iBAAA;AAAA,UACR,CAAA,+BAAA,EAAkCC,uBAAA,CAAgB,KAAK,CAAC,CAAA;AAAA,SAC1D;AAAA,MACF;AAAA,IACF;AAAA,GACD,CAAA;AACH;;;;"}
@@ -8,7 +8,7 @@ var util = require('../util.cjs.js');
8
8
  var helpers = require('./helpers.cjs.js');
9
9
 
10
10
  const editGitlabIssueAction = (options) => {
11
- const { integrations } = options;
11
+ const { integrations, requireScmUserCredentials } = options;
12
12
  return pluginScaffolderNode.createTemplateAction({
13
13
  id: "gitlab:issue:edit",
14
14
  description: "Edit a Gitlab issue.",
@@ -124,7 +124,12 @@ const editGitlabIssueAction = (options) => {
124
124
  token
125
125
  } = ctx.input;
126
126
  const { host } = util.parseRepoUrl(repoUrl, integrations);
127
- const api = util.getClient({ host, integrations, token });
127
+ const api = util.getClient({
128
+ host,
129
+ integrations,
130
+ token,
131
+ requireScmUserCredentials
132
+ });
128
133
  let isEpicScoped = false;
129
134
  isEpicScoped = await ctx.checkpoint({
130
135
  key: `issue.edit.is.scoped.${projectId}.${epicId}`,
@@ -1 +1 @@
1
- {"version":3,"file":"gitlabIssueEdit.cjs.js","sources":["../../src/actions/gitlabIssueEdit.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 { IssueStateEvent, IssueType } from '../commonGitlabConfig';\nimport { examples } from './gitlabIssueEdit.examples';\nimport { checkEpicScope, convertDate, getClient, parseRepoUrl } from '../util';\nimport { EditIssueOptions, IssueSchema } from '@gitbeaker/rest';\nimport { getErrorMessage } from './helpers';\n\n/**\n * Creates a `gitlab:issue:edit` Scaffolder action.\n *\n * @param options - Templating configuration.\n * @public\n */\nexport const editGitlabIssueAction = (options: {\n integrations: ScmIntegrationRegistry;\n}) => {\n const { integrations } = options;\n return createTemplateAction({\n id: 'gitlab:issue:edit',\n description: 'Edit a Gitlab issue.',\n examples,\n schema: {\n input: {\n repoUrl: z =>\n z.string({\n description: `Accepts the format 'gitlab.com?repo=project_name&owner=group_name' where 'project_name' is the repository name and 'group_name' is a group or username`,\n }),\n token: z =>\n z\n .string({\n description: 'The token to use for authorization to GitLab',\n })\n .optional(),\n projectId: z =>\n z.number({\n description:\n 'The global ID or URL-encoded path of the project owned by the authenticated user.',\n }),\n issueIid: z =>\n z.number({\n description: \"The internal ID of a project's issue\",\n }),\n addLabels: z =>\n z\n .string({\n description:\n 'Comma-separated label names to add to an issue. If a label does not already exist, this creates a new project label and assigns it to the issue.',\n })\n .optional(),\n assignees: z =>\n z\n .array(z.number(), {\n description: 'IDs of the users to assign the issue to.',\n })\n .optional(),\n confidential: z =>\n z\n .boolean({\n description: 'Updates an issue to be confidential.',\n })\n .optional(),\n description: z =>\n z\n .string({\n description:\n 'The description of an issue. Limited to 1,048,576 characters.',\n })\n .max(1048576)\n .optional(),\n discussionLocked: z =>\n z\n .boolean({\n description:\n 'Flag indicating if the issue discussion is locked. If the discussion is locked only project members can add or edit comments.',\n })\n .optional(),\n dueDate: z =>\n z\n .string({\n description:\n 'The due date. Date time string in the format YYYY-MM-DD, for example 2016-03-11.',\n })\n .regex(/^\\d{4}-\\d{2}-\\d{2}$/, 'Invalid date format. Use YYYY-MM-DD')\n .optional(),\n epicId: z =>\n z\n .number({\n description:\n 'ID of the epic to add the issue to. Valid values are greater than or equal to 0.',\n })\n .min(0, 'Valid values should be equal or greater than zero')\n .optional(),\n issueType: z =>\n z\n .nativeEnum(IssueType, {\n description:\n 'Updates the type of issue. One of issue, incident, test_case or task.',\n })\n .optional(),\n labels: z =>\n z\n .string({\n description:\n 'Comma-separated label names for an issue. Set to an empty string to unassign all labels. If a label does not already exist, this creates a new project label and assigns it to the issue.',\n })\n .optional(),\n milestoneId: z =>\n z\n .number({\n description:\n 'The global ID of a milestone to assign the issue to. Set to 0 or provide an empty value to unassign a milestone',\n })\n .optional(),\n removeLabels: z =>\n z\n .string({\n description:\n 'Comma-separated label names to remove from an issue.',\n })\n .optional(),\n stateEvent: z =>\n z\n .nativeEnum(IssueStateEvent, {\n description:\n 'The state event of an issue. To close the issue, use close, and to reopen it, use reopen.',\n })\n .optional(),\n title: z =>\n z\n .string({\n description: 'The title of an issue.',\n })\n .optional(),\n updatedAt: z =>\n z\n .string({\n description:\n 'When the issue was updated. Date time string, ISO 8601 formatted',\n })\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 weight: z =>\n z\n .number({\n description: 'The issue weight',\n })\n .min(0, 'Valid values should be equal or greater than zero')\n .max(10, 'Valid values should be equal or less than 10')\n .optional(),\n },\n output: {\n issueUrl: z =>\n z.string({\n description: 'Issue WebUrl',\n }),\n projectId: z =>\n z.number({\n description: 'The project id the issue belongs to WebUrl',\n }),\n issueId: z =>\n z.number({\n description: 'The issues Id',\n }),\n issueIid: z =>\n z.number({\n description: \"The issues internal ID of a project's issue\",\n }),\n state: z =>\n z.string({\n description: 'The state event of an issue',\n }),\n title: z =>\n z.string({\n description: 'The title of an issue.',\n }),\n updatedAt: z =>\n z.string({\n description: 'The last updated time of the issue.',\n }),\n },\n },\n async handler(ctx) {\n try {\n const {\n repoUrl,\n projectId,\n title,\n addLabels,\n removeLabels,\n issueIid,\n description,\n confidential = false,\n assignees = [],\n updatedAt = '',\n dueDate,\n discussionLocked = false,\n epicId,\n labels,\n issueType,\n milestoneId,\n stateEvent,\n weight,\n token,\n } = ctx.input;\n\n const { host } = parseRepoUrl(repoUrl, integrations);\n const api = getClient({ host, integrations, token });\n\n let isEpicScoped = false;\n\n isEpicScoped = await ctx.checkpoint({\n key: `issue.edit.is.scoped.${projectId}.${epicId}`,\n fn: async () => {\n if (epicId) {\n const scoped = await checkEpicScope(api, projectId, epicId);\n\n if (scoped) {\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 return scoped;\n }\n return false;\n },\n });\n\n const mappedUpdatedAt = convertDate(\n String(updatedAt),\n new Date().toISOString(),\n );\n\n const editIssueOptions: EditIssueOptions = {\n addLabels,\n assigneeIds: assignees,\n confidential,\n description,\n discussionLocked,\n dueDate,\n epicId: isEpicScoped ? epicId : undefined,\n issueType,\n labels,\n milestoneId,\n removeLabels,\n stateEvent,\n title,\n updatedAt: mappedUpdatedAt,\n weight,\n };\n\n const editedIssue = await ctx.checkpoint({\n key: `issue.edit.${projectId}.${issueIid}`,\n fn: async () => {\n const response = (await api.Issues.edit(\n projectId,\n issueIid,\n editIssueOptions,\n )) as IssueSchema;\n\n return {\n issueId: response.id,\n issueUrl: response.web_url,\n projectId: response.project_id,\n issueIid: response.iid,\n title: response.title,\n state: response.state,\n updatedAt: response.updated_at,\n };\n },\n });\n\n ctx.output('issueId', editedIssue.issueId);\n ctx.output('projectId', editedIssue.projectId);\n ctx.output('issueUrl', editedIssue.issueUrl);\n ctx.output('issueIid', editedIssue.issueIid);\n ctx.output('title', editedIssue.title);\n ctx.output('state', editedIssue.state);\n ctx.output('updatedAt', editedIssue.updatedAt);\n } catch (error: any) {\n // Handling other errors\n throw new InputError(\n `Failed to edit/modify GitLab issue: ${getErrorMessage(error)}`,\n );\n }\n },\n });\n};\n"],"names":["createTemplateAction","examples","IssueType","IssueStateEvent","parseRepoUrl","getClient","checkEpicScope","convertDate","InputError","getErrorMessage"],"mappings":";;;;;;;;;AA+BO,MAAM,qBAAA,GAAwB,CAAC,OAAA,KAEhC;AACJ,EAAA,MAAM,EAAE,cAAa,GAAI,OAAA;AACzB,EAAA,OAAOA,yCAAA,CAAqB;AAAA,IAC1B,EAAA,EAAI,mBAAA;AAAA,IACJ,WAAA,EAAa,sBAAA;AAAA,cACbC,iCAAA;AAAA,IACA,MAAA,EAAQ;AAAA,MACN,KAAA,EAAO;AAAA,QACL,OAAA,EAAS,CAAA,CAAA,KACP,CAAA,CAAE,MAAA,CAAO;AAAA,UACP,WAAA,EAAa,CAAA,sJAAA;AAAA,SACd,CAAA;AAAA,QACH,KAAA,EAAO,CAAA,CAAA,KACL,CAAA,CACG,MAAA,CAAO;AAAA,UACN,WAAA,EAAa;AAAA,SACd,EACA,QAAA,EAAS;AAAA,QACd,SAAA,EAAW,CAAA,CAAA,KACT,CAAA,CAAE,MAAA,CAAO;AAAA,UACP,WAAA,EACE;AAAA,SACH,CAAA;AAAA,QACH,QAAA,EAAU,CAAA,CAAA,KACR,CAAA,CAAE,MAAA,CAAO;AAAA,UACP,WAAA,EAAa;AAA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cACnB,OAAO,QAAA,CAAS,KAAA;AAAA,cAChB,OAAO,QAAA,CAAS,KAAA;AAAA,cAChB,WAAW,QAAA,CAAS;AAAA,aACtB;AAAA,UACF;AAAA,SACD,CAAA;AAED,QAAA,GAAA,CAAI,MAAA,CAAO,SAAA,EAAW,WAAA,CAAY,OAAO,CAAA;AACzC,QAAA,GAAA,CAAI,MAAA,CAAO,WAAA,EAAa,WAAA,CAAY,SAAS,CAAA;AAC7C,QAAA,GAAA,CAAI,MAAA,CAAO,UAAA,EAAY,WAAA,CAAY,QAAQ,CAAA;AAC3C,QAAA,GAAA,CAAI,MAAA,CAAO,UAAA,EAAY,WAAA,CAAY,QAAQ,CAAA;AAC3C,QAAA,GAAA,CAAI,MAAA,CAAO,OAAA,EAAS,WAAA,CAAY,KAAK,CAAA;AACrC,QAAA,GAAA,CAAI,MAAA,CAAO,OAAA,EAAS,WAAA,CAAY,KAAK,CAAA;AACrC,QAAA,GAAA,CAAI,MAAA,CAAO,WAAA,EAAa,WAAA,CAAY,SAAS,CAAA;AAAA,MAC/C,SAAS,KAAA,EAAY;AAEnB,QAAA,MAAM,IAAIC,iBAAA;AAAA,UACR,CAAA,oCAAA,EAAuCC,uBAAA,CAAgB,KAAK,CAAC,CAAA;AAAA,SAC/D;AAAA,MACF;AAAA,IACF;AAAA,GACD,CAAA;AACH;;;;"}
1
+ {"version":3,"file":"gitlabIssueEdit.cjs.js","sources":["../../src/actions/gitlabIssueEdit.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 { IssueStateEvent, IssueType } from '../commonGitlabConfig';\nimport { examples } from './gitlabIssueEdit.examples';\nimport { checkEpicScope, convertDate, getClient, parseRepoUrl } from '../util';\nimport { EditIssueOptions, IssueSchema } from '@gitbeaker/rest';\nimport { getErrorMessage } from './helpers';\n\n/**\n * Creates a `gitlab:issue:edit` Scaffolder action.\n *\n * @param options - Templating configuration.\n * @public\n */\nexport const editGitlabIssueAction = (options: {\n integrations: ScmIntegrationRegistry;\n requireScmUserCredentials?: boolean;\n}) => {\n const { integrations, requireScmUserCredentials } = options;\n return createTemplateAction({\n id: 'gitlab:issue:edit',\n description: 'Edit a Gitlab issue.',\n examples,\n schema: {\n input: {\n repoUrl: z =>\n z.string({\n description: `Accepts the format 'gitlab.com?repo=project_name&owner=group_name' where 'project_name' is the repository name and 'group_name' is a group or username`,\n }),\n token: z =>\n z\n .string({\n description: 'The token to use for authorization to GitLab',\n })\n .optional(),\n projectId: z =>\n z.number({\n description:\n 'The global ID or URL-encoded path of the project owned by the authenticated user.',\n }),\n issueIid: z =>\n z.number({\n description: \"The internal ID of a project's issue\",\n }),\n addLabels: z =>\n z\n .string({\n description:\n 'Comma-separated label names to add to an issue. If a label does not already exist, this creates a new project label and assigns it to the issue.',\n })\n .optional(),\n assignees: z =>\n z\n .array(z.number(), {\n description: 'IDs of the users to assign the issue to.',\n })\n .optional(),\n confidential: z =>\n z\n .boolean({\n description: 'Updates an issue to be confidential.',\n })\n .optional(),\n description: z =>\n z\n .string({\n description:\n 'The description of an issue. Limited to 1,048,576 characters.',\n })\n .max(1048576)\n .optional(),\n discussionLocked: z =>\n z\n .boolean({\n description:\n 'Flag indicating if the issue discussion is locked. If the discussion is locked only project members can add or edit comments.',\n })\n .optional(),\n dueDate: z =>\n z\n .string({\n description:\n 'The due date. Date time string in the format YYYY-MM-DD, for example 2016-03-11.',\n })\n .regex(/^\\d{4}-\\d{2}-\\d{2}$/, 'Invalid date format. Use YYYY-MM-DD')\n .optional(),\n epicId: z =>\n z\n .number({\n description:\n 'ID of the epic to add the issue to. Valid values are greater than or equal to 0.',\n })\n .min(0, 'Valid values should be equal or greater than zero')\n .optional(),\n issueType: z =>\n z\n .nativeEnum(IssueType, {\n description:\n 'Updates the type of issue. One of issue, incident, test_case or task.',\n })\n .optional(),\n labels: z =>\n z\n .string({\n description:\n 'Comma-separated label names for an issue. Set to an empty string to unassign all labels. If a label does not already exist, this creates a new project label and assigns it to the issue.',\n })\n .optional(),\n milestoneId: z =>\n z\n .number({\n description:\n 'The global ID of a milestone to assign the issue to. Set to 0 or provide an empty value to unassign a milestone',\n })\n .optional(),\n removeLabels: z =>\n z\n .string({\n description:\n 'Comma-separated label names to remove from an issue.',\n })\n .optional(),\n stateEvent: z =>\n z\n .nativeEnum(IssueStateEvent, {\n description:\n 'The state event of an issue. To close the issue, use close, and to reopen it, use reopen.',\n })\n .optional(),\n title: z =>\n z\n .string({\n description: 'The title of an issue.',\n })\n .optional(),\n updatedAt: z =>\n z\n .string({\n description:\n 'When the issue was updated. Date time string, ISO 8601 formatted',\n })\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 weight: z =>\n z\n .number({\n description: 'The issue weight',\n })\n .min(0, 'Valid values should be equal or greater than zero')\n .max(10, 'Valid values should be equal or less than 10')\n .optional(),\n },\n output: {\n issueUrl: z =>\n z.string({\n description: 'Issue WebUrl',\n }),\n projectId: z =>\n z.number({\n description: 'The project id the issue belongs to WebUrl',\n }),\n issueId: z =>\n z.number({\n description: 'The issues Id',\n }),\n issueIid: z =>\n z.number({\n description: \"The issues internal ID of a project's issue\",\n }),\n state: z =>\n z.string({\n description: 'The state event of an issue',\n }),\n title: z =>\n z.string({\n description: 'The title of an issue.',\n }),\n updatedAt: z =>\n z.string({\n description: 'The last updated time of the issue.',\n }),\n },\n },\n async handler(ctx) {\n try {\n const {\n repoUrl,\n projectId,\n title,\n addLabels,\n removeLabels,\n issueIid,\n description,\n confidential = false,\n assignees = [],\n updatedAt = '',\n dueDate,\n discussionLocked = false,\n epicId,\n labels,\n issueType,\n milestoneId,\n stateEvent,\n weight,\n token,\n } = ctx.input;\n\n const { host } = parseRepoUrl(repoUrl, integrations);\n const api = getClient({\n host,\n integrations,\n token,\n requireScmUserCredentials,\n });\n\n let isEpicScoped = false;\n\n isEpicScoped = await ctx.checkpoint({\n key: `issue.edit.is.scoped.${projectId}.${epicId}`,\n fn: async () => {\n if (epicId) {\n const scoped = await checkEpicScope(api, projectId, epicId);\n\n if (scoped) {\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 return scoped;\n }\n return false;\n },\n });\n\n const mappedUpdatedAt = convertDate(\n String(updatedAt),\n new Date().toISOString(),\n );\n\n const editIssueOptions: EditIssueOptions = {\n addLabels,\n assigneeIds: assignees,\n confidential,\n description,\n discussionLocked,\n dueDate,\n epicId: isEpicScoped ? epicId : undefined,\n issueType,\n labels,\n milestoneId,\n removeLabels,\n stateEvent,\n title,\n updatedAt: mappedUpdatedAt,\n weight,\n };\n\n const editedIssue = await ctx.checkpoint({\n key: `issue.edit.${projectId}.${issueIid}`,\n fn: async () => {\n const response = (await api.Issues.edit(\n projectId,\n issueIid,\n editIssueOptions,\n )) as IssueSchema;\n\n return {\n issueId: response.id,\n issueUrl: response.web_url,\n projectId: response.project_id,\n issueIid: response.iid,\n title: response.title,\n state: response.state,\n updatedAt: response.updated_at,\n };\n },\n });\n\n ctx.output('issueId', editedIssue.issueId);\n ctx.output('projectId', editedIssue.projectId);\n ctx.output('issueUrl', editedIssue.issueUrl);\n ctx.output('issueIid', editedIssue.issueIid);\n ctx.output('title', editedIssue.title);\n ctx.output('state', editedIssue.state);\n ctx.output('updatedAt', editedIssue.updatedAt);\n } catch (error: any) {\n // Handling other errors\n throw new InputError(\n `Failed to edit/modify GitLab issue: ${getErrorMessage(error)}`,\n );\n }\n },\n });\n};\n"],"names":["createTemplateAction","examples","IssueType","IssueStateEvent","parseRepoUrl","getClient","checkEpicScope","convertDate","InputError","getErrorMessage"],"mappings":";;;;;;;;;AA+BO,MAAM,qBAAA,GAAwB,CAAC,OAAA,KAGhC;AACJ,EAAA,MAAM,EAAE,YAAA,EAAc,yBAAA,EAA0B,GAAI,OAAA;AACpD,EAAA,OAAOA,yCAAA,CAAqB;AAAA,IAC1B,EAAA,EAAI,mBAAA;AAAA,IACJ,WAAA,EAAa,sBAAA;AAAA,cACbC,iCAAA;AAAA,IACA,MAAA,EAAQ;AAAA,MACN,KAAA,EAAO;AAAA,QACL,OAAA,EAAS,CAAA,CAAA,KACP,CAAA,CAAE,MAAA,CAAO;AAAA,UACP,WAAA,EAAa,CAAA,sJAAA;AAAA,SACd,CAAA;AAAA,QACH,KAAA,EAAO,CAAA,CAAA,KACL,CAAA,CACG,MAAA,CAAO;AAAA,UACN,WAAA,EAAa;AAAA,SACd,EACA,QAAA,EAAS;AAAA,QACd,SAAA,EAAW,CAAA,CAAA,KACT,CAAA,CAAE,MAAA,CAAO;AAAA,UACP,WAAA,EACE;AAAA,SACH,CAAA;AAAA,QACH,QAAA,EAAU,CAAA,CAAA,KACR,CAAA,CAAE,MAAA,CAAO;AAAA,UACP,WAAA,EAAa;AAAA,SACd,CAAA;AAAA,QACH,SAAA,EAAW,CAAA,CAAA,KACT,CAAA,CACG,MAAA,CAAO;AAAA,UACN,WAAA,EACE;AAAA,SACH,EACA,QAAA,EAAS;AAAA,QACd,WAAW,CAAA,CAAA,KACT,CAAA,CACG,KAAA,CAAM,CAAA,CAAE,QAAO,EAAG;AAAA,UACjB,WAAA,EAAa;AAAA,SACd,EACA,QAAA,EAAS;AAAA,QACd,YAAA,EAAc,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AA,EAAa,WAAA,CAAY,SAAS,CAAA;AAC7C,QAAA,GAAA,CAAI,MAAA,CAAO,UAAA,EAAY,WAAA,CAAY,QAAQ,CAAA;AAC3C,QAAA,GAAA,CAAI,MAAA,CAAO,UAAA,EAAY,WAAA,CAAY,QAAQ,CAAA;AAC3C,QAAA,GAAA,CAAI,MAAA,CAAO,OAAA,EAAS,WAAA,CAAY,KAAK,CAAA;AACrC,QAAA,GAAA,CAAI,MAAA,CAAO,OAAA,EAAS,WAAA,CAAY,KAAK,CAAA;AACrC,QAAA,GAAA,CAAI,MAAA,CAAO,WAAA,EAAa,WAAA,CAAY,SAAS,CAAA;AAAA,MAC/C,SAAS,KAAA,EAAY;AAEnB,QAAA,MAAM,IAAIC,iBAAA;AAAA,UACR,CAAA,oCAAA,EAAuCC,uBAAA,CAAgB,KAAK,CAAC,CAAA;AAAA,SAC/D;AAAA,MACF;AAAA,IACF;AAAA,GACD,CAAA;AACH;;;;"}
@@ -42,7 +42,7 @@ async function getReviewersFromApprovalRules(api, mergerequestIId, repoID, ctx)
42
42
  }
43
43
  const commitActions = ["create", "delete", "update", "skip", "auto"];
44
44
  const createPublishGitlabMergeRequestAction = (options) => {
45
- const { integrations } = options;
45
+ const { integrations, requireScmUserCredentials } = options;
46
46
  return pluginScaffolderNode.createTemplateAction({
47
47
  id: "publish:gitlab:merge-request",
48
48
  examples: gitlabMergeRequest_examples.examples,
@@ -102,7 +102,8 @@ _deprecated_: \`projectid\` passed as query parameters in the \`repoUrl\``
102
102
  const api = helpers.createGitlabApi({
103
103
  integrations,
104
104
  token,
105
- repoUrl
105
+ repoUrl,
106
+ requireScmUserCredentials
106
107
  });
107
108
  let assigneeId = void 0;
108
109
  if (assignee !== void 0) {