@backstage/plugin-scaffolder-backend-module-bitbucket-cloud 0.2.1-next.1 → 0.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,106 @@
1
+ 'use strict';
2
+
3
+ var yaml = require('yaml');
4
+
5
+ function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e : { default: e }; }
6
+
7
+ var yaml__default = /*#__PURE__*/_interopDefaultCompat(yaml);
8
+
9
+ const examples = [
10
+ {
11
+ description: "Creating pull request on bitbucket cloud with required fields",
12
+ example: yaml__default.default.stringify({
13
+ steps: [
14
+ {
15
+ action: "publish:bitbucketCloud:pull-request",
16
+ id: "publish-bitbucket-cloud-pull-request-minimal",
17
+ name: "Creating pull request on bitbucket cloud",
18
+ input: {
19
+ repoUrl: "bitbucket.org?workspace=workspace&project=project&repo=repo",
20
+ title: "My pull request",
21
+ sourceBranch: "my-feature-branch"
22
+ }
23
+ }
24
+ ]
25
+ })
26
+ },
27
+ {
28
+ description: "Creating pull request on bitbucket cloud with custom descriptions",
29
+ example: yaml__default.default.stringify({
30
+ steps: [
31
+ {
32
+ action: "publish:bitbucketCloud:pull-request",
33
+ id: "publish-bitbucket-cloud-pull-request-minimal",
34
+ name: "Creating pull request on bitbucket cloud",
35
+ input: {
36
+ repoUrl: "bitbucket.org?workspace=workspace&project=project&repo=repo",
37
+ title: "My pull request",
38
+ sourceBranch: "my-feature-branch",
39
+ description: "This is a detailed description of my pull request"
40
+ }
41
+ }
42
+ ]
43
+ })
44
+ },
45
+ {
46
+ description: "Creating pull request on bitbucket cloud with different target branch",
47
+ example: yaml__default.default.stringify({
48
+ steps: [
49
+ {
50
+ action: "publish:bitbucketCloud:pull-request",
51
+ id: "publish-bitbucket-cloud-pull-request-target-branch",
52
+ name: "Creating pull request on bitbucket cloud",
53
+ input: {
54
+ repoUrl: "bitbucket.org?workspace=workspace&project=project&repo=repo",
55
+ title: "My pull request",
56
+ sourceBranch: "my-feature-branch",
57
+ targetBranch: "development"
58
+ }
59
+ }
60
+ ]
61
+ })
62
+ },
63
+ {
64
+ description: "Creating pull request on bitbucket cloud with authorization token",
65
+ example: yaml__default.default.stringify({
66
+ steps: [
67
+ {
68
+ action: "publish:bitbucketCloud:pull-request",
69
+ id: "publish-bitbucket-cloud-pull-request-minimal",
70
+ name: "Creating pull request on bitbucket cloud",
71
+ input: {
72
+ repoUrl: "bitbucket.org?workspace=workspace&project=project&repo=repo",
73
+ title: "My pull request",
74
+ sourceBranch: "my-feature-branch",
75
+ token: "my-auth-token"
76
+ }
77
+ }
78
+ ]
79
+ })
80
+ },
81
+ {
82
+ description: "Creating pull request on bitbucket cloud with all fields",
83
+ example: yaml__default.default.stringify({
84
+ steps: [
85
+ {
86
+ action: "publish:bitbucketCloud:pull-request",
87
+ id: "publish-bitbucket-cloud-pull-request-minimal",
88
+ name: "Creating pull request on bitbucket cloud",
89
+ input: {
90
+ repoUrl: "bitbucket.org?workspace=workspace&project=project&repo=repo",
91
+ title: "My pull request",
92
+ sourceBranch: "my-feature-branch",
93
+ targetBranch: "development",
94
+ description: "This is a detailed description of my pull request",
95
+ token: "my-auth-token",
96
+ gitAuthorName: "test-user",
97
+ gitAuthorEmail: "test-user@sample.com"
98
+ }
99
+ }
100
+ ]
101
+ })
102
+ }
103
+ ];
104
+
105
+ exports.examples = examples;
106
+ //# sourceMappingURL=bitbucketCloudPullRequest.examples.cjs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bitbucketCloudPullRequest.examples.cjs.js","sources":["../../src/actions/bitbucketCloudPullRequest.examples.ts"],"sourcesContent":["/*\n * Copyright 2024 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 { TemplateExample } from '@backstage/plugin-scaffolder-node';\nimport yaml from 'yaml';\n\nexport const examples: TemplateExample[] = [\n {\n description:\n 'Creating pull request on bitbucket cloud with required fields',\n example: yaml.stringify({\n steps: [\n {\n action: 'publish:bitbucketCloud:pull-request',\n id: 'publish-bitbucket-cloud-pull-request-minimal',\n name: 'Creating pull request on bitbucket cloud',\n input: {\n repoUrl:\n 'bitbucket.org?workspace=workspace&project=project&repo=repo',\n title: 'My pull request',\n sourceBranch: 'my-feature-branch',\n },\n },\n ],\n }),\n },\n {\n description:\n 'Creating pull request on bitbucket cloud with custom descriptions',\n example: yaml.stringify({\n steps: [\n {\n action: 'publish:bitbucketCloud:pull-request',\n id: 'publish-bitbucket-cloud-pull-request-minimal',\n name: 'Creating pull request on bitbucket cloud',\n input: {\n repoUrl:\n 'bitbucket.org?workspace=workspace&project=project&repo=repo',\n title: 'My pull request',\n sourceBranch: 'my-feature-branch',\n description: 'This is a detailed description of my pull request',\n },\n },\n ],\n }),\n },\n {\n description:\n 'Creating pull request on bitbucket cloud with different target branch',\n example: yaml.stringify({\n steps: [\n {\n action: 'publish:bitbucketCloud:pull-request',\n id: 'publish-bitbucket-cloud-pull-request-target-branch',\n name: 'Creating pull request on bitbucket cloud',\n input: {\n repoUrl:\n 'bitbucket.org?workspace=workspace&project=project&repo=repo',\n title: 'My pull request',\n sourceBranch: 'my-feature-branch',\n targetBranch: 'development',\n },\n },\n ],\n }),\n },\n {\n description:\n 'Creating pull request on bitbucket cloud with authorization token',\n example: yaml.stringify({\n steps: [\n {\n action: 'publish:bitbucketCloud:pull-request',\n id: 'publish-bitbucket-cloud-pull-request-minimal',\n name: 'Creating pull request on bitbucket cloud',\n input: {\n repoUrl:\n 'bitbucket.org?workspace=workspace&project=project&repo=repo',\n title: 'My pull request',\n sourceBranch: 'my-feature-branch',\n token: 'my-auth-token',\n },\n },\n ],\n }),\n },\n {\n description: 'Creating pull request on bitbucket cloud with all fields',\n example: yaml.stringify({\n steps: [\n {\n action: 'publish:bitbucketCloud:pull-request',\n id: 'publish-bitbucket-cloud-pull-request-minimal',\n name: 'Creating pull request on bitbucket cloud',\n input: {\n repoUrl:\n 'bitbucket.org?workspace=workspace&project=project&repo=repo',\n title: 'My pull request',\n sourceBranch: 'my-feature-branch',\n targetBranch: 'development',\n description: 'This is a detailed description of my pull request',\n token: 'my-auth-token',\n gitAuthorName: 'test-user',\n gitAuthorEmail: 'test-user@sample.com',\n },\n },\n ],\n }),\n },\n];\n"],"names":["yaml"],"mappings":";;;;;;;;AAmBO,MAAM,QAA8B,GAAA;AAAA,EACzC;AAAA,IACE,WACE,EAAA,+DAAA;AAAA,IACF,OAAA,EAASA,sBAAK,SAAU,CAAA;AAAA,MACtB,KAAO,EAAA;AAAA,QACL;AAAA,UACE,MAAQ,EAAA,qCAAA;AAAA,UACR,EAAI,EAAA,8CAAA;AAAA,UACJ,IAAM,EAAA,0CAAA;AAAA,UACN,KAAO,EAAA;AAAA,YACL,OACE,EAAA,6DAAA;AAAA,YACF,KAAO,EAAA,iBAAA;AAAA,YACP,YAAc,EAAA,mBAAA;AAAA,WAChB;AAAA,SACF;AAAA,OACF;AAAA,KACD,CAAA;AAAA,GACH;AAAA,EACA;AAAA,IACE,WACE,EAAA,mEAAA;AAAA,IACF,OAAA,EAASA,sBAAK,SAAU,CAAA;AAAA,MACtB,KAAO,EAAA;AAAA,QACL;AAAA,UACE,MAAQ,EAAA,qCAAA;AAAA,UACR,EAAI,EAAA,8CAAA;AAAA,UACJ,IAAM,EAAA,0CAAA;AAAA,UACN,KAAO,EAAA;AAAA,YACL,OACE,EAAA,6DAAA;AAAA,YACF,KAAO,EAAA,iBAAA;AAAA,YACP,YAAc,EAAA,mBAAA;AAAA,YACd,WAAa,EAAA,mDAAA;AAAA,WACf;AAAA,SACF;AAAA,OACF;AAAA,KACD,CAAA;AAAA,GACH;AAAA,E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ACP,aAAe,EAAA,WAAA;AAAA,YACf,cAAgB,EAAA,sBAAA;AAAA,WAClB;AAAA,SACF;AAAA,OACF;AAAA,KACD,CAAA;AAAA,GACH;AACF;;;;"}
@@ -0,0 +1,20 @@
1
+ 'use strict';
2
+
3
+ const getAuthorizationHeader = (config) => {
4
+ if (config.username && config.appPassword) {
5
+ const buffer = Buffer.from(
6
+ `${config.username}:${config.appPassword}`,
7
+ "utf8"
8
+ );
9
+ return `Basic ${buffer.toString("base64")}`;
10
+ }
11
+ if (config.token) {
12
+ return `Bearer ${config.token}`;
13
+ }
14
+ throw new Error(
15
+ `Authorization has not been provided for Bitbucket Cloud. Please add either username + appPassword to the Integrations config or a user login auth token`
16
+ );
17
+ };
18
+
19
+ exports.getAuthorizationHeader = getAuthorizationHeader;
20
+ //# sourceMappingURL=helpers.cjs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"helpers.cjs.js","sources":["../../src/actions/helpers.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\nexport const getAuthorizationHeader = (config: {\n username?: string;\n appPassword?: string;\n token?: string;\n}) => {\n if (config.username && config.appPassword) {\n const buffer = Buffer.from(\n `${config.username}:${config.appPassword}`,\n 'utf8',\n );\n\n return `Basic ${buffer.toString('base64')}`;\n }\n\n if (config.token) {\n return `Bearer ${config.token}`;\n }\n\n throw new Error(\n `Authorization has not been provided for Bitbucket Cloud. Please add either username + appPassword to the Integrations config or a user login auth token`,\n );\n};\n"],"names":[],"mappings":";;AAgBa,MAAA,sBAAA,GAAyB,CAAC,MAIjC,KAAA;AACJ,EAAI,IAAA,MAAA,CAAO,QAAY,IAAA,MAAA,CAAO,WAAa,EAAA;AACzC,IAAA,MAAM,SAAS,MAAO,CAAA,IAAA;AAAA,MACpB,CAAG,EAAA,MAAA,CAAO,QAAQ,CAAA,CAAA,EAAI,OAAO,WAAW,CAAA,CAAA;AAAA,MACxC,MAAA;AAAA,KACF,CAAA;AAEA,IAAA,OAAO,CAAS,MAAA,EAAA,MAAA,CAAO,QAAS,CAAA,QAAQ,CAAC,CAAA,CAAA,CAAA;AAAA,GAC3C;AAEA,EAAA,IAAI,OAAO,KAAO,EAAA;AAChB,IAAO,OAAA,CAAA,OAAA,EAAU,OAAO,KAAK,CAAA,CAAA,CAAA;AAAA,GAC/B;AAEA,EAAA,MAAM,IAAI,KAAA;AAAA,IACR,CAAA,uJAAA,CAAA;AAAA,GACF,CAAA;AACF;;;;"}
@@ -0,0 +1,131 @@
1
+ 'use strict';
2
+
3
+ const workspace = {
4
+ title: "Workspace",
5
+ description: `The workspace name`,
6
+ type: "string"
7
+ };
8
+ const repo_slug = {
9
+ title: "Repository name",
10
+ description: "The repository name",
11
+ type: "string"
12
+ };
13
+ const ref_type = {
14
+ title: "ref_type",
15
+ type: "string"
16
+ };
17
+ const type = {
18
+ title: "type",
19
+ type: "string"
20
+ };
21
+ const ref_name = {
22
+ title: "ref_name",
23
+ type: "string"
24
+ };
25
+ const source = {
26
+ title: "source",
27
+ type: "string"
28
+ };
29
+ const destination = {
30
+ title: "destination",
31
+ type: "string"
32
+ };
33
+ const hash = {
34
+ title: "hash",
35
+ type: "string"
36
+ };
37
+ const pattern = {
38
+ title: "pattern",
39
+ type: "string"
40
+ };
41
+ const id = {
42
+ title: "id",
43
+ type: "string"
44
+ };
45
+ const key = {
46
+ title: "key",
47
+ type: "string"
48
+ };
49
+ const value = {
50
+ title: "value",
51
+ type: "string"
52
+ };
53
+ const secured = {
54
+ title: "secured",
55
+ type: "boolean"
56
+ };
57
+ const token = {
58
+ title: "Authentication Token",
59
+ type: "string",
60
+ description: "The token to use for authorization to BitBucket Cloud"
61
+ };
62
+ const destination_commit = {
63
+ title: "destination_commit",
64
+ type: "object",
65
+ properties: {
66
+ hash
67
+ }
68
+ };
69
+ const commit = {
70
+ title: "commit",
71
+ type: "object",
72
+ properties: {
73
+ type,
74
+ hash
75
+ }
76
+ };
77
+ const selector = {
78
+ title: "selector",
79
+ type: "object",
80
+ properties: {
81
+ type,
82
+ pattern
83
+ }
84
+ };
85
+ const pull_request = {
86
+ title: "pull_request",
87
+ type: "object",
88
+ properties: {
89
+ id
90
+ }
91
+ };
92
+ const pipelinesRunBody = {
93
+ title: "Request Body",
94
+ description: "Request body properties: see Bitbucket Cloud Rest API documentation for more details",
95
+ type: "object",
96
+ properties: {
97
+ target: {
98
+ title: "target",
99
+ type: "object",
100
+ properties: {
101
+ ref_type,
102
+ type,
103
+ ref_name,
104
+ source,
105
+ destination,
106
+ destination_commit,
107
+ commit,
108
+ selector,
109
+ pull_request
110
+ }
111
+ },
112
+ variables: {
113
+ title: "variables",
114
+ type: "array",
115
+ items: {
116
+ type: "object",
117
+ properties: {
118
+ key,
119
+ value,
120
+ secured
121
+ }
122
+ }
123
+ }
124
+ }
125
+ };
126
+
127
+ exports.pipelinesRunBody = pipelinesRunBody;
128
+ exports.repo_slug = repo_slug;
129
+ exports.token = token;
130
+ exports.workspace = workspace;
131
+ //# sourceMappingURL=inputProperties.cjs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"inputProperties.cjs.js","sources":["../../src/actions/inputProperties.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\nconst workspace = {\n title: 'Workspace',\n description: `The workspace name`,\n type: 'string',\n};\n\nconst repo_slug = {\n title: 'Repository name',\n description: 'The repository name',\n type: 'string',\n};\n\nconst ref_type = {\n title: 'ref_type',\n type: 'string',\n};\n\nconst type = {\n title: 'type',\n type: 'string',\n};\n\nconst ref_name = {\n title: 'ref_name',\n type: 'string',\n};\nconst source = {\n title: 'source',\n type: 'string',\n};\nconst destination = {\n title: 'destination',\n type: 'string',\n};\nconst hash = {\n title: 'hash',\n type: 'string',\n};\n\nconst pattern = {\n title: 'pattern',\n type: 'string',\n};\n\nconst id = {\n title: 'id',\n type: 'string',\n};\n\nconst key = {\n title: 'key',\n type: 'string',\n};\nconst value = {\n title: 'value',\n type: 'string',\n};\nconst secured = {\n title: 'secured',\n type: 'boolean',\n};\n\nconst token = {\n title: 'Authentication Token',\n type: 'string',\n description: 'The token to use for authorization to BitBucket Cloud',\n};\n\nconst destination_commit = {\n title: 'destination_commit',\n type: 'object',\n properties: {\n hash,\n },\n};\n\nconst commit = {\n title: 'commit',\n type: 'object',\n properties: {\n type,\n hash,\n },\n};\n\nconst selector = {\n title: 'selector',\n type: 'object',\n properties: {\n type,\n pattern,\n },\n};\n\nconst pull_request = {\n title: 'pull_request',\n type: 'object',\n properties: {\n id,\n },\n};\n\nconst pipelinesRunBody = {\n title: 'Request Body',\n description:\n 'Request body properties: see Bitbucket Cloud Rest API documentation for more details',\n type: 'object',\n properties: {\n target: {\n title: 'target',\n type: 'object',\n properties: {\n ref_type,\n type,\n ref_name,\n source,\n destination,\n destination_commit,\n commit,\n selector,\n pull_request,\n },\n },\n variables: {\n title: 'variables',\n type: 'array',\n items: {\n type: 'object',\n properties: {\n key,\n value,\n secured,\n },\n },\n },\n },\n};\n\nexport { workspace, repo_slug, pipelinesRunBody, token };\n"],"names":[],"mappings":";;AAgBA,MAAM,SAAY,GAAA;AAAA,EAChB,KAAO,EAAA,WAAA;AAAA,EACP,WAAa,EAAA,C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AA;AAAA,MACT,KAAO,EAAA,WAAA;AAAA,MACP,IAAM,EAAA,OAAA;AAAA,MACN,KAAO,EAAA;AAAA,QACL,IAAM,EAAA,QAAA;AAAA,QACN,UAAY,EAAA;AAAA,UACV,GAAA;AAAA,UACA,KAAA;AAAA,UACA,OAAA;AAAA,SACF;AAAA,OACF;AAAA,KACF;AAAA,GACF;AACF;;;;;;;"}
@@ -0,0 +1,67 @@
1
+ 'use strict';
2
+
3
+ var errors = require('@backstage/errors');
4
+ var pluginBitbucketCloudCommon = require('@backstage/plugin-bitbucket-cloud-common');
5
+
6
+ async function handleAutocompleteRequest({
7
+ resource,
8
+ token,
9
+ context
10
+ }) {
11
+ const client = pluginBitbucketCloudCommon.BitbucketCloudClient.fromConfig({
12
+ host: "bitbucket.org",
13
+ apiBaseUrl: "https://api.bitbucket.org/2.0",
14
+ token
15
+ });
16
+ switch (resource) {
17
+ case "workspaces": {
18
+ const results = [];
19
+ for await (const page of client.listWorkspaces().iteratePages()) {
20
+ const slugs = [...page.values].map((p) => ({ title: p.slug }));
21
+ results.push(...slugs);
22
+ }
23
+ return { results };
24
+ }
25
+ case "projects": {
26
+ if (!context.workspace)
27
+ throw new errors.InputError("Missing workspace context parameter");
28
+ const results = [];
29
+ for await (const page of client.listProjectsByWorkspace(context.workspace).iteratePages()) {
30
+ const keys = [...page.values].map((p) => ({ title: p.key }));
31
+ results.push(...keys);
32
+ }
33
+ return { results };
34
+ }
35
+ case "repositories": {
36
+ if (!context.workspace || !context.project)
37
+ throw new errors.InputError(
38
+ "Missing workspace and/or project context parameter"
39
+ );
40
+ const results = [];
41
+ for await (const page of client.listRepositoriesByWorkspace(context.workspace, {
42
+ q: `project.key="${context.project}"`
43
+ }).iteratePages()) {
44
+ const slugs = [...page.values].map((p) => ({ title: p.slug }));
45
+ results.push(...slugs);
46
+ }
47
+ return { results };
48
+ }
49
+ case "branches": {
50
+ if (!context.workspace || !context.repository)
51
+ throw new errors.InputError(
52
+ "Missing workspace and/or repository context parameter"
53
+ );
54
+ const results = [];
55
+ for await (const page of client.listBranchesByRepository(context.repository, context.workspace).iteratePages()) {
56
+ const names = [...page.values].map((p) => ({ title: p.name }));
57
+ results.push(...names);
58
+ }
59
+ return { results };
60
+ }
61
+ default:
62
+ throw new errors.InputError(`Invalid resource: ${resource}`);
63
+ }
64
+ }
65
+
66
+ exports.handleAutocompleteRequest = handleAutocompleteRequest;
67
+ //# sourceMappingURL=autocomplete.cjs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"autocomplete.cjs.js","sources":["../../src/autocomplete/autocomplete.ts"],"sourcesContent":["/*\n * Copyright 2024 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 { BitbucketCloudClient } from '@backstage/plugin-bitbucket-cloud-common';\n\nexport async function handleAutocompleteRequest({\n resource,\n token,\n context,\n}: {\n resource: string;\n token: string;\n context: Record<string, string>;\n}): Promise<{ results: { title: string }[] }> {\n const client = BitbucketCloudClient.fromConfig({\n host: 'bitbucket.org',\n apiBaseUrl: 'https://api.bitbucket.org/2.0',\n token,\n });\n\n switch (resource) {\n case 'workspaces': {\n const results: { title: string }[] = [];\n\n for await (const page of client.listWorkspaces().iteratePages()) {\n const slugs = [...page.values!].map(p => ({ title: p.slug! }));\n results.push(...slugs);\n }\n\n return { results };\n }\n case 'projects': {\n if (!context.workspace)\n throw new InputError('Missing workspace context parameter');\n\n const results: { title: string }[] = [];\n\n for await (const page of client\n .listProjectsByWorkspace(context.workspace)\n .iteratePages()) {\n const keys = [...page.values!].map(p => ({ title: p.key! }));\n results.push(...keys);\n }\n\n return { results };\n }\n case 'repositories': {\n if (!context.workspace || !context.project)\n throw new InputError(\n 'Missing workspace and/or project context parameter',\n );\n\n const results: { title: string }[] = [];\n\n for await (const page of client\n .listRepositoriesByWorkspace(context.workspace, {\n q: `project.key=\"${context.project}\"`,\n })\n .iteratePages()) {\n const slugs = [...page.values!].map(p => ({ title: p.slug! }));\n results.push(...slugs);\n }\n\n return { results };\n }\n case 'branches': {\n if (!context.workspace || !context.repository)\n throw new InputError(\n 'Missing workspace and/or repository context parameter',\n );\n\n const results: { title: string }[] = [];\n\n for await (const page of client\n .listBranchesByRepository(context.repository, context.workspace)\n .iteratePages()) {\n const names = [...page.values!].map(p => ({ title: p.name! }));\n results.push(...names);\n }\n\n return { results };\n }\n default:\n throw new InputError(`Invalid resource: ${resource}`);\n }\n}\n"],"names":["BitbucketCloudClient","InputError"],"mappings":";;;;;AAmBA,eAAsB,yBAA0B,CAAA;AAAA,EAC9C,QAAA;AAAA,EACA,KAAA;AAAA,EACA,OAAA;AACF,CAI8C,EAAA;AAC5C,EAAM,MAAA,MAAA,GAASA,gDAAqB,UAAW,CAAA;AAAA,IAC7C,IAAM,EAAA,eAAA;AAAA,IACN,UAAY,EAAA,+BAAA;AAAA,IACZ,KAAA;AAAA,GACD,CAAA,CAAA;AAED,EAAA,QAAQ,QAAU;AAAA,IAChB,KAAK,YAAc,EAAA;AACjB,MAAA,MAAM,UAA+B,EAAC,CAAA;AAEtC,MAAA,WAAA,MAAiB,IAAQ,IAAA,MAAA,CAAO,cAAe,EAAA,CAAE,cAAgB,EAAA;AAC/D,QAAA,MAAM,KAAQ,GAAA,CAAC,GAAG,IAAA,CAAK,MAAO,CAAA,CAAE,GAAI,CAAA,CAAA,CAAA,MAAM,EAAE,KAAA,EAAO,CAAE,CAAA,IAAA,EAAQ,CAAA,CAAA,CAAA;AAC7D,QAAQ,OAAA,CAAA,IAAA,CAAK,GAAG,KAAK,CAAA,CAAA;AAAA,OACvB;AAEA,MAAA,OAAO,EA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