@backstage/plugin-bitbucket-cloud-common 0.0.0-nightly-20220531024457

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md ADDED
@@ -0,0 +1,17 @@
1
+ # @backstage/plugin-bitbucket-cloud-common
2
+
3
+ ## 0.0.0-nightly-20220531024457
4
+
5
+ ### Minor Changes
6
+
7
+ - 1dffa7dd4d: Add new common library `bitbucket-cloud-common` with a client for Bitbucket Cloud.
8
+
9
+ This client can be reused across all packages and might be the future place for additional
10
+ features like managing the rate limits, etc.
11
+
12
+ The client itself was generated in parts using the `@openapitools/openapi-generator-cli`.
13
+
14
+ ### Patch Changes
15
+
16
+ - Updated dependencies
17
+ - @backstage/integration@0.0.0-nightly-20220531024457
package/README.md ADDED
@@ -0,0 +1,64 @@
1
+ # @backstage/plugin-bitbucket-cloud-common
2
+
3
+ Welcome to the common package for bitbucket-cloud plugins!
4
+
5
+ This common package provides a reusable API client for the Bitbucket Cloud API
6
+ which can be reused in catalog-backend-module plugins, scaffolder modules, etc.
7
+
8
+ Using a shared client allows to control all traffic going from Backstage to
9
+ the Bitbucket Cloud API compared to separate clients or inline API calls.
10
+
11
+ We may want to leverage this later to add rate limiting, etc.
12
+
13
+ ## How to maintain the generated code
14
+
15
+ ### Update the Models
16
+
17
+ This command will
18
+
19
+ 1. [refresh the schema/OpenAPI Specification](#refresh-the-schema)
20
+ 2. [re-generate the models](#generate-models)
21
+ 3. [reduce the models to the minimal needed](#reduce-models)
22
+
23
+ ### Refresh the schema
24
+
25
+ This command will download the latest version of the Bitbucket Cloud OpenAPI Specification
26
+ and apply some mutations to fix bugs or improve the schema for a better code generation output.
27
+
28
+ ```sh
29
+ yarn refresh-schema
30
+ ```
31
+
32
+ ### Generate Models
33
+
34
+ The models used are created based on the [local OpenAPI Specification file](bitbucket-cloud.oas.json)
35
+ using a code generator.
36
+ Some post-cleanup is applied to improve the generated output.
37
+
38
+ The client itself using the models is not generated.
39
+
40
+ ```sh
41
+ yarn generate-models
42
+ ```
43
+
44
+ ### Reduce Models
45
+
46
+ In order to keep the API surface minimal, this command helps to only keep the minimal part of the
47
+ generated models by considering all `Models` module members directly or transitively used by the
48
+ client implementation.
49
+
50
+ ```sh
51
+ yarn reduce-models
52
+ ```
53
+
54
+ ## Adding a New Client Method
55
+
56
+ If you want to add a new method to the client implementation which may use a new endpoint or "new" models
57
+ you can
58
+
59
+ 1. optionally [refresh the schema](#refresh-the-schema) to get the latest version
60
+ 2. and [generate the models](#generate-models).
61
+
62
+ At this point, you have **all** models usable for adding a new method using any of them.
63
+
64
+ If you are ready with your addition to the client, you can [reduce the models to the minimal needed](#reduce-models).
@@ -0,0 +1,141 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var fetch = require('cross-fetch');
6
+
7
+ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
8
+
9
+ var fetch__default = /*#__PURE__*/_interopDefaultLegacy(fetch);
10
+
11
+ class WithPagination {
12
+ constructor(createUrl, fetch) {
13
+ this.createUrl = createUrl;
14
+ this.fetch = fetch;
15
+ }
16
+ getPage(options) {
17
+ const opts = { page: 1, pagelen: 100, ...options };
18
+ const url = this.createUrl(opts);
19
+ return this.fetch(url);
20
+ }
21
+ async *iteratePages(options) {
22
+ const opts = { page: 1, pagelen: 100, ...options };
23
+ let url = this.createUrl(opts);
24
+ let res;
25
+ do {
26
+ res = await this.fetch(url);
27
+ url = res.next ? new URL(res.next) : void 0;
28
+ yield res;
29
+ } while (url);
30
+ }
31
+ async *iterateResults(options) {
32
+ var _a;
33
+ const opts = { page: 1, pagelen: 100, ...options };
34
+ let url = this.createUrl(opts);
35
+ let res;
36
+ do {
37
+ res = await this.fetch(url);
38
+ url = res.next ? new URL(res.next) : void 0;
39
+ for (const item of (_a = res.values) != null ? _a : []) {
40
+ yield item;
41
+ }
42
+ } while (url);
43
+ }
44
+ }
45
+
46
+ class BitbucketCloudClient {
47
+ constructor(config) {
48
+ this.config = config;
49
+ }
50
+ static fromConfig(config) {
51
+ return new BitbucketCloudClient(config);
52
+ }
53
+ searchCode(workspace, query, options) {
54
+ const workspaceEnc = encodeURIComponent(workspace);
55
+ return new WithPagination((paginationOptions) => this.createUrl(`/workspaces/${workspaceEnc}/search/code`, {
56
+ ...paginationOptions,
57
+ ...options,
58
+ search_query: query
59
+ }), (url) => this.getTypeMapped(url));
60
+ }
61
+ listRepositoriesByWorkspace(workspace, options) {
62
+ const workspaceEnc = encodeURIComponent(workspace);
63
+ return new WithPagination((paginationOptions) => this.createUrl(`/repositories/${workspaceEnc}`, {
64
+ ...paginationOptions,
65
+ ...options
66
+ }), (url) => this.getTypeMapped(url));
67
+ }
68
+ createUrl(endpoint, options) {
69
+ const request = new URL(this.config.apiBaseUrl + endpoint);
70
+ for (const key in options) {
71
+ if (options[key]) {
72
+ request.searchParams.append(key, options[key].toString());
73
+ }
74
+ }
75
+ return request;
76
+ }
77
+ async getTypeMapped(url) {
78
+ return this.get(url).then((response) => response.json());
79
+ }
80
+ async get(url) {
81
+ return this.request(new fetch.Request(url.toString(), { method: "GET" }));
82
+ }
83
+ async request(req) {
84
+ return fetch__default["default"](req, { headers: this.getAuthHeaders() }).then((response) => {
85
+ if (!response.ok) {
86
+ throw new Error(`Unexpected response for ${req.method} ${req.url}. Expected 200 but got ${response.status} - ${response.statusText}`);
87
+ }
88
+ return response;
89
+ });
90
+ }
91
+ getAuthHeaders() {
92
+ const headers = {};
93
+ if (this.config.username) {
94
+ const buffer = Buffer.from(`${this.config.username}:${this.config.appPassword}`, "utf8");
95
+ headers.Authorization = `Basic ${buffer.toString("base64")}`;
96
+ }
97
+ return headers;
98
+ }
99
+ }
100
+
101
+ exports.Models = void 0;
102
+ ((Models2) => {
103
+ Models2.BaseCommitSummaryMarkupEnum = {
104
+ Markdown: "markdown",
105
+ Creole: "creole",
106
+ Plaintext: "plaintext"
107
+ };
108
+ Models2.BranchMergeStrategiesEnum = {
109
+ MergeCommit: "merge_commit",
110
+ Squash: "squash",
111
+ FastForward: "fast_forward"
112
+ };
113
+ Models2.CommitFileAttributesEnum = {
114
+ Link: "link",
115
+ Executable: "executable",
116
+ Subrepository: "subrepository",
117
+ Binary: "binary",
118
+ Lfs: "lfs"
119
+ };
120
+ Models2.ParticipantRoleEnum = {
121
+ Participant: "PARTICIPANT",
122
+ Reviewer: "REVIEWER"
123
+ };
124
+ Models2.ParticipantStateEnum = {
125
+ Approved: "approved",
126
+ ChangesRequested: "changes_requested",
127
+ Null: "null"
128
+ };
129
+ Models2.RepositoryForkPolicyEnum = {
130
+ AllowForks: "allow_forks",
131
+ NoPublicForks: "no_public_forks",
132
+ NoForks: "no_forks"
133
+ };
134
+ Models2.RepositoryScmEnum = {
135
+ Git: "git"
136
+ };
137
+ })(exports.Models || (exports.Models = {}));
138
+
139
+ exports.BitbucketCloudClient = BitbucketCloudClient;
140
+ exports.WithPagination = WithPagination;
141
+ //# sourceMappingURL=index.cjs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.cjs.js","sources":["../src/pagination.ts","../src/BitbucketCloudClient.ts","../src/models/index.ts"],"sourcesContent":["/*\n * Copyright 2022 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { Models } from './models';\n\n/** @public */\nexport type PaginationOptions = {\n page?: number;\n pagelen?: number;\n};\n\n/** @public */\nexport class WithPagination<\n TPage extends Models.Paginated<TResultItem>,\n TResultItem,\n> {\n constructor(\n private readonly createUrl: (options: PaginationOptions) => URL,\n private readonly fetch: (url: URL) => Promise<TPage>,\n ) {}\n\n getPage(options?: PaginationOptions): Promise<TPage> {\n const opts = { page: 1, pagelen: 100, ...options };\n const url = this.createUrl(opts);\n return this.fetch(url);\n }\n\n async *iteratePages(\n options?: PaginationOptions,\n ): AsyncGenerator<TPage, void> {\n const opts = { page: 1, pagelen: 100, ...options };\n let url: URL | undefined = this.createUrl(opts);\n let res;\n do {\n res = await this.fetch(url);\n url = res.next ? new URL(res.next) : undefined;\n yield res;\n } while (url);\n }\n\n async *iterateResults(options?: PaginationOptions) {\n const opts = { page: 1, pagelen: 100, ...options };\n let url: URL | undefined = this.createUrl(opts);\n let res;\n do {\n res = await this.fetch(url);\n url = res.next ? new URL(res.next) : undefined;\n for (const item of res.values ?? []) {\n yield item;\n }\n } while (url);\n }\n}\n","/*\n * Copyright 2022 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { BitbucketCloudIntegrationConfig } from '@backstage/integration';\nimport fetch, { Request } from 'cross-fetch';\nimport { Models } from './models';\nimport { WithPagination } from './pagination';\nimport {\n FilterAndSortOptions,\n PartialResponseOptions,\n RequestOptions,\n} from './types';\n\n/** @public */\nexport class BitbucketCloudClient {\n static fromConfig(\n config: BitbucketCloudIntegrationConfig,\n ): BitbucketCloudClient {\n return new BitbucketCloudClient(config);\n }\n\n private constructor(\n private readonly config: BitbucketCloudIntegrationConfig,\n ) {}\n\n searchCode(\n workspace: string,\n query: string,\n options?: FilterAndSortOptions & PartialResponseOptions,\n ): WithPagination<Models.SearchResultPage, Models.SearchCodeSearchResult> {\n const workspaceEnc = encodeURIComponent(workspace);\n return new WithPagination(\n paginationOptions =>\n this.createUrl(`/workspaces/${workspaceEnc}/search/code`, {\n ...paginationOptions,\n ...options,\n search_query: query,\n }),\n url => this.getTypeMapped(url),\n );\n }\n\n listRepositoriesByWorkspace(\n workspace: string,\n options?: FilterAndSortOptions & PartialResponseOptions,\n ): WithPagination<Models.PaginatedRepositories, Models.Repository> {\n const workspaceEnc = encodeURIComponent(workspace);\n\n return new WithPagination(\n paginationOptions =>\n this.createUrl(`/repositories/${workspaceEnc}`, {\n ...paginationOptions,\n ...options,\n }),\n url => this.getTypeMapped(url),\n );\n }\n\n private createUrl(endpoint: string, options?: RequestOptions): URL {\n const request = new URL(this.config.apiBaseUrl + endpoint);\n for (const key in options) {\n if (options[key]) {\n request.searchParams.append(key, options[key]!.toString());\n }\n }\n\n return request;\n }\n\n private async getTypeMapped<T = any>(url: URL): Promise<T> {\n return this.get(url).then(\n (response: Response) => response.json() as Promise<T>,\n );\n }\n\n private async get(url: URL): Promise<Response> {\n return this.request(new Request(url.toString(), { method: 'GET' }));\n }\n\n private async request(req: Request): Promise<Response> {\n return fetch(req, { headers: this.getAuthHeaders() }).then(\n (response: Response) => {\n if (!response.ok) {\n throw new Error(\n `Unexpected response for ${req.method} ${req.url}. Expected 200 but got ${response.status} - ${response.statusText}`,\n );\n }\n\n return response;\n },\n );\n }\n\n private getAuthHeaders(): Record<string, string> {\n const headers: Record<string, string> = {};\n\n if (this.config.username) {\n const buffer = Buffer.from(\n `${this.config.username}:${this.config.appPassword}`,\n 'utf8',\n );\n headers.Authorization = `Basic ${buffer.toString('base64')}`;\n }\n\n return headers;\n }\n}\n","/*\n * Copyright 2022 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * Bitbucket API\n * Code against the Bitbucket API to automate simple tasks, embed Bitbucket data into your own site, build mobile or desktop apps, or even add custom UI add-ons into Bitbucket itself using the Connect framework.\n *\n * The version of the OpenAPI document: 2.0\n * Contact: support@bitbucket.org\n *\n * NOTE: This file was auto generated by OpenAPI Generator (https://openapi-generator.tech).\n * https://openapi-generator.tech\n * Do not edit the class manually.\n */\n\n/** @public */\nexport namespace Models {\n /**\n * An account object.\n * @public\n */\n export interface Account extends ModelObject {\n /**\n * The status of the account. Currently the only possible value is \"active\", but more values may be added in the future.\n */\n account_status?: string;\n created_on?: string;\n display_name?: string;\n has_2fa_enabled?: boolean;\n links?: AccountLinks;\n /**\n * Account name defined by the owner. Should be used instead of the \"username\" field. Note that \"nickname\" cannot be used in place of \"username\" in URLs and queries, as \"nickname\" is not guaranteed to be unique.\n */\n nickname?: string;\n username?: string;\n uuid?: string;\n website?: string;\n }\n\n /**\n * @public\n */\n export interface AccountLinks {\n avatar?: Link;\n followers?: Link;\n following?: Link;\n html?: Link;\n repositories?: Link;\n self?: Link;\n }\n\n /**\n * The author of a change in a repository\n * @public\n */\n export interface Author extends ModelObject {\n /**\n * The raw author value from the repository. This may be the only value available if the author does not match a user in Bitbucket.\n */\n raw?: string;\n user?: Account;\n }\n\n /**\n * The common base type for both repository and snippet commits.\n * @public\n */\n export interface BaseCommit extends ModelObject {\n author?: Author;\n date?: string;\n hash?: string;\n message?: string;\n parents?: Array<BaseCommit>;\n summary?: BaseCommitSummary;\n }\n\n /**\n * @public\n */\n export interface BaseCommitSummary {\n /**\n * The user's content rendered as HTML.\n */\n html?: string;\n /**\n * The type of markup language the raw content is to be interpreted in.\n */\n markup?: BaseCommitSummaryMarkupEnum;\n /**\n * The text as it was typed by a user.\n */\n raw?: string;\n }\n\n /**\n * The type of markup language the raw content is to be interpreted in.\n * @public\n */\n export const BaseCommitSummaryMarkupEnum = {\n Markdown: 'markdown',\n Creole: 'creole',\n Plaintext: 'plaintext',\n } as const;\n\n /**\n * The type of markup language the raw content is to be interpreted in.\n * @public\n */\n export type BaseCommitSummaryMarkupEnum =\n typeof BaseCommitSummaryMarkupEnum[keyof typeof BaseCommitSummaryMarkupEnum];\n\n /**\n * A branch object, representing a branch in a repository.\n * @public\n */\n export interface Branch {\n links?: RefLinks;\n /**\n * The name of the ref.\n */\n name?: string;\n target?: Commit;\n type: string;\n /**\n * The default merge strategy for pull requests targeting this branch.\n */\n default_merge_strategy?: string;\n /**\n * Available merge strategies for pull requests targeting this branch.\n */\n merge_strategies?: Array<BranchMergeStrategiesEnum>;\n }\n\n /**\n * Available merge strategies for pull requests targeting this branch.\n * @public\n */\n export const BranchMergeStrategiesEnum = {\n MergeCommit: 'merge_commit',\n Squash: 'squash',\n FastForward: 'fast_forward',\n } as const;\n\n /**\n * Available merge strategies for pull requests targeting this branch.\n * @public\n */\n export type BranchMergeStrategiesEnum =\n typeof BranchMergeStrategiesEnum[keyof typeof BranchMergeStrategiesEnum];\n\n /**\n * A repository commit object.\n * @public\n */\n export interface Commit extends BaseCommit {\n participants?: Array<Participant>;\n repository?: Repository;\n }\n\n /**\n * A file object, representing a file at a commit in a repository\n * @public\n */\n export interface CommitFile {\n [key: string]: unknown;\n attributes?: CommitFileAttributesEnum;\n commit?: Commit;\n /**\n * The escaped version of the path as it appears in a diff. If the path does not require escaping this will be the same as path.\n */\n escaped_path?: string;\n /**\n * The path in the repository\n */\n path?: string;\n type: string;\n }\n\n /**\n * @public\n */\n export const CommitFileAttributesEnum = {\n Link: 'link',\n Executable: 'executable',\n Subrepository: 'subrepository',\n Binary: 'binary',\n Lfs: 'lfs',\n } as const;\n\n /**\n * @public\n */\n export type CommitFileAttributesEnum =\n typeof CommitFileAttributesEnum[keyof typeof CommitFileAttributesEnum];\n\n /**\n * A link to a resource related to this object.\n * @public\n */\n export interface Link {\n href?: string;\n name?: string;\n }\n\n /**\n * Base type for most resource objects. It defines the common `type` element that identifies an object's type. It also identifies the element as Swagger's `discriminator`.\n * @public\n */\n export interface ModelObject {\n [key: string]: unknown;\n type: string;\n }\n\n /**\n * A generic paginated list.\n * @public\n */\n export interface Paginated<TResultItem> {\n /**\n * Link to the next page if it exists. The last page of a collection does not have this value. Use this link to navigate the result set and refrain from constructing your own URLs.\n */\n next?: string;\n /**\n * Page number of the current results. This is an optional element that is not provided in all responses.\n */\n page?: number;\n /**\n * Current number of objects on the existing page. The default value is 10 with 100 being the maximum allowed value. Individual APIs may enforce different values.\n */\n pagelen?: number;\n /**\n * Link to previous page if it exists. A collections first page does not have this value. This is an optional element that is not provided in all responses. Some result sets strictly support forward navigation and never provide previous links. Clients must anticipate that backwards navigation is not always available. Use this link to navigate the result set and refrain from constructing your own URLs.\n */\n previous?: string;\n /**\n * Total number of objects in the response. This is an optional element that is not provided in all responses, as it can be expensive to compute.\n */\n size?: number;\n /**\n * The values of the current page.\n */\n values?: Array<TResultItem> | Set<TResultItem>;\n }\n\n /**\n * A paginated list of repositories.\n * @public\n */\n export interface PaginatedRepositories extends Paginated<Repository> {\n /**\n * The values of the current page.\n */\n values?: Set<Repository>;\n }\n\n /**\n * Object describing a user's role on resources like commits or pull requests.\n * @public\n */\n export interface Participant extends ModelObject {\n approved?: boolean;\n /**\n * The ISO8601 timestamp of the participant's action. For approvers, this is the time of their approval. For commenters and pull request reviewers who are not approvers, this is the time they last commented, or null if they have not commented.\n */\n participated_on?: string;\n role?: ParticipantRoleEnum;\n state?: ParticipantStateEnum;\n user?: User;\n }\n\n /**\n * @public\n */\n export const ParticipantRoleEnum = {\n Participant: 'PARTICIPANT',\n Reviewer: 'REVIEWER',\n } as const;\n\n /**\n * @public\n */\n export type ParticipantRoleEnum =\n typeof ParticipantRoleEnum[keyof typeof ParticipantRoleEnum];\n\n /**\n * @public\n */\n export const ParticipantStateEnum = {\n Approved: 'approved',\n ChangesRequested: 'changes_requested',\n Null: 'null',\n } as const;\n\n /**\n * @public\n */\n export type ParticipantStateEnum =\n typeof ParticipantStateEnum[keyof typeof ParticipantStateEnum];\n\n /**\n * A Bitbucket project.\n * Projects are used by teams to organize repositories.\n * @public\n */\n export interface Project extends ModelObject {\n created_on?: string;\n description?: string;\n /**\n *\n * Indicates whether the project contains publicly visible repositories.\n * Note that private projects cannot contain public repositories.\n */\n has_publicly_visible_repos?: boolean;\n /**\n *\n * Indicates whether the project is publicly accessible, or whether it is\n * private to the team and consequently only visible to team members.\n * Note that private projects cannot contain public repositories.\n */\n is_private?: boolean;\n /**\n * The project's key.\n */\n key?: string;\n links?: ProjectLinks;\n /**\n * The name of the project.\n */\n name?: string;\n owner?: Team;\n updated_on?: string;\n /**\n * The project's immutable id.\n */\n uuid?: string;\n }\n\n /**\n * @public\n */\n export interface ProjectLinks {\n avatar?: Link;\n html?: Link;\n }\n\n /**\n * @public\n */\n export interface RefLinks {\n commits?: Link;\n html?: Link;\n self?: Link;\n }\n\n /**\n * A Bitbucket repository.\n * @public\n */\n export interface Repository extends ModelObject {\n created_on?: string;\n description?: string;\n /**\n *\n * Controls the rules for forking this repository.\n *\n * * **allow_forks**: unrestricted forking\n * * **no_public_forks**: restrict forking to private forks (forks cannot\n * be made public later)\n * * **no_forks**: deny all forking\n */\n fork_policy?: RepositoryForkPolicyEnum;\n /**\n * The concatenation of the repository owner's username and the slugified name, e.g. \"evzijst/interruptingcow\". This is the same string used in Bitbucket URLs.\n */\n full_name?: string;\n has_issues?: boolean;\n has_wiki?: boolean;\n is_private?: boolean;\n language?: string;\n links?: RepositoryLinks;\n mainbranch?: Branch;\n name?: string;\n owner?: Account;\n parent?: Repository;\n project?: Project;\n scm?: RepositoryScmEnum;\n size?: number;\n /**\n * The \"sluggified\" version of the repository's name. This contains only ASCII characters and can therefore be slightly different than the name\n */\n slug?: string;\n updated_on?: string;\n /**\n * The repository's immutable id. This can be used as a substitute for the slug segment in URLs. Doing this guarantees your URLs will survive renaming of the repository by its owner, or even transfer of the repository to a different user.\n */\n uuid?: string;\n }\n\n /**\n *\n * Controls the rules for forking this repository.\n *\n * * **allow_forks**: unrestricted forking\n * * **no_public_forks**: restrict forking to private forks (forks cannot\n * be made public later)\n * * **no_forks**: deny all forking\n * @public\n */\n export const RepositoryForkPolicyEnum = {\n AllowForks: 'allow_forks',\n NoPublicForks: 'no_public_forks',\n NoForks: 'no_forks',\n } as const;\n\n /**\n *\n * Controls the rules for forking this repository.\n *\n * * **allow_forks**: unrestricted forking\n * * **no_public_forks**: restrict forking to private forks (forks cannot\n * be made public later)\n * * **no_forks**: deny all forking\n * @public\n */\n export type RepositoryForkPolicyEnum =\n typeof RepositoryForkPolicyEnum[keyof typeof RepositoryForkPolicyEnum];\n\n /**\n * @public\n */\n export const RepositoryScmEnum = {\n Git: 'git',\n } as const;\n\n /**\n * @public\n */\n export type RepositoryScmEnum =\n typeof RepositoryScmEnum[keyof typeof RepositoryScmEnum];\n\n /**\n * @public\n */\n export interface RepositoryLinks {\n avatar?: Link;\n clone?: Array<Link>;\n commits?: Link;\n downloads?: Link;\n forks?: Link;\n hooks?: Link;\n html?: Link;\n pullrequests?: Link;\n self?: Link;\n watchers?: Link;\n }\n\n /**\n * @public\n */\n export interface SearchCodeSearchResult {\n readonly content_match_count?: number;\n readonly content_matches?: Array<SearchContentMatch>;\n file?: CommitFile;\n readonly path_matches?: Array<SearchSegment>;\n readonly type?: string;\n }\n\n /**\n * @public\n */\n export interface SearchContentMatch {\n readonly lines?: Array<SearchLine>;\n }\n\n /**\n * @public\n */\n export interface SearchLine {\n readonly line?: number;\n readonly segments?: Array<SearchSegment>;\n }\n\n /**\n * @public\n */\n export interface SearchResultPage extends Paginated<SearchCodeSearchResult> {\n readonly query_substituted?: boolean;\n /**\n * The values of the current page.\n */\n readonly values?: Array<SearchCodeSearchResult>;\n }\n\n /**\n * @public\n */\n export interface SearchSegment {\n readonly match?: boolean;\n readonly text?: string;\n }\n\n /**\n * A team object.\n * @public\n */\n export interface Team extends Account {}\n\n /**\n * A user object.\n * @public\n */\n export interface User extends Account {\n /**\n * The user's Atlass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QAAQ;AACpB,IAAI,WAAW,EAAE,cAAc;AAC/B,GAAG,CAAC;AACJ,EAAE,OAAO,CAAC,wBAAwB,GAAG;AACrC,IAAI,IAAI,EAAE,MAAM;AAChB,IAAI,UAAU,EAAE,YAAY;AAC5B,IAAI,aAAa,EAAE,eAAe;AAClC,IAAI,MAAM,EAAE,QAAQ;AACpB,IAAI,GAAG,EAAE,KAAK;AACd,GAAG,CAAC;AACJ,EAAE,OAAO,CAAC,mBAAmB,GAAG;AAChC,IAAI,WAAW,EAAE,aAAa;AAC9B,IAAI,QAAQ,EAAE,UAAU;AACxB,GAAG,CAAC;AACJ,EAAE,OAAO,CAAC,oBAAoB,GAAG;AACjC,IAAI,QAAQ,EAAE,UAAU;AACxB,IAAI,gBAAgB,EAAE,mBAAmB;AACzC,IAAI,IAAI,EAAE,MAAM;AAChB,GAAG,CAAC;AACJ,EAAE,OAAO,CAAC,wBAAwB,GAAG;AACrC,IAAI,UAAU,EAAE,aAAa;AAC7B,IAAI,aAAa,EAAE,iBAAiB;AACpC,IAAI,OAAO,EAAE,UAAU;AACvB,GAAG,CAAC;AACJ,EAAE,OAAO,CAAC,iBAAiB,GAAG;AAC9B,IAAI,GAAG,EAAE,KAAK;AACd,GAAG,CAAC;AACJ,CAAC,EAAEA,cAAM,KAAKA,cAAM,GAAG,EAAE,CAAC,CAAC;;;;;"}
@@ -0,0 +1,518 @@
1
+ import { BitbucketCloudIntegrationConfig } from '@backstage/integration';
2
+
3
+ /**
4
+ * Bitbucket API
5
+ * Code against the Bitbucket API to automate simple tasks, embed Bitbucket data into your own site, build mobile or desktop apps, or even add custom UI add-ons into Bitbucket itself using the Connect framework.
6
+ *
7
+ * The version of the OpenAPI document: 2.0
8
+ * Contact: support@bitbucket.org
9
+ *
10
+ * NOTE: This file was auto generated by OpenAPI Generator (https://openapi-generator.tech).
11
+ * https://openapi-generator.tech
12
+ * Do not edit the class manually.
13
+ */
14
+ /** @public */
15
+ declare namespace Models {
16
+ /**
17
+ * An account object.
18
+ * @public
19
+ */
20
+ interface Account extends ModelObject {
21
+ /**
22
+ * The status of the account. Currently the only possible value is "active", but more values may be added in the future.
23
+ */
24
+ account_status?: string;
25
+ created_on?: string;
26
+ display_name?: string;
27
+ has_2fa_enabled?: boolean;
28
+ links?: AccountLinks;
29
+ /**
30
+ * Account name defined by the owner. Should be used instead of the "username" field. Note that "nickname" cannot be used in place of "username" in URLs and queries, as "nickname" is not guaranteed to be unique.
31
+ */
32
+ nickname?: string;
33
+ username?: string;
34
+ uuid?: string;
35
+ website?: string;
36
+ }
37
+ /**
38
+ * @public
39
+ */
40
+ interface AccountLinks {
41
+ avatar?: Link;
42
+ followers?: Link;
43
+ following?: Link;
44
+ html?: Link;
45
+ repositories?: Link;
46
+ self?: Link;
47
+ }
48
+ /**
49
+ * The author of a change in a repository
50
+ * @public
51
+ */
52
+ interface Author extends ModelObject {
53
+ /**
54
+ * The raw author value from the repository. This may be the only value available if the author does not match a user in Bitbucket.
55
+ */
56
+ raw?: string;
57
+ user?: Account;
58
+ }
59
+ /**
60
+ * The common base type for both repository and snippet commits.
61
+ * @public
62
+ */
63
+ interface BaseCommit extends ModelObject {
64
+ author?: Author;
65
+ date?: string;
66
+ hash?: string;
67
+ message?: string;
68
+ parents?: Array<BaseCommit>;
69
+ summary?: BaseCommitSummary;
70
+ }
71
+ /**
72
+ * @public
73
+ */
74
+ interface BaseCommitSummary {
75
+ /**
76
+ * The user's content rendered as HTML.
77
+ */
78
+ html?: string;
79
+ /**
80
+ * The type of markup language the raw content is to be interpreted in.
81
+ */
82
+ markup?: BaseCommitSummaryMarkupEnum;
83
+ /**
84
+ * The text as it was typed by a user.
85
+ */
86
+ raw?: string;
87
+ }
88
+ /**
89
+ * The type of markup language the raw content is to be interpreted in.
90
+ * @public
91
+ */
92
+ const BaseCommitSummaryMarkupEnum: {
93
+ readonly Markdown: "markdown";
94
+ readonly Creole: "creole";
95
+ readonly Plaintext: "plaintext";
96
+ };
97
+ /**
98
+ * The type of markup language the raw content is to be interpreted in.
99
+ * @public
100
+ */
101
+ type BaseCommitSummaryMarkupEnum = typeof BaseCommitSummaryMarkupEnum[keyof typeof BaseCommitSummaryMarkupEnum];
102
+ /**
103
+ * A branch object, representing a branch in a repository.
104
+ * @public
105
+ */
106
+ interface Branch {
107
+ links?: RefLinks;
108
+ /**
109
+ * The name of the ref.
110
+ */
111
+ name?: string;
112
+ target?: Commit;
113
+ type: string;
114
+ /**
115
+ * The default merge strategy for pull requests targeting this branch.
116
+ */
117
+ default_merge_strategy?: string;
118
+ /**
119
+ * Available merge strategies for pull requests targeting this branch.
120
+ */
121
+ merge_strategies?: Array<BranchMergeStrategiesEnum>;
122
+ }
123
+ /**
124
+ * Available merge strategies for pull requests targeting this branch.
125
+ * @public
126
+ */
127
+ const BranchMergeStrategiesEnum: {
128
+ readonly MergeCommit: "merge_commit";
129
+ readonly Squash: "squash";
130
+ readonly FastForward: "fast_forward";
131
+ };
132
+ /**
133
+ * Available merge strategies for pull requests targeting this branch.
134
+ * @public
135
+ */
136
+ type BranchMergeStrategiesEnum = typeof BranchMergeStrategiesEnum[keyof typeof BranchMergeStrategiesEnum];
137
+ /**
138
+ * A repository commit object.
139
+ * @public
140
+ */
141
+ interface Commit extends BaseCommit {
142
+ participants?: Array<Participant>;
143
+ repository?: Repository;
144
+ }
145
+ /**
146
+ * A file object, representing a file at a commit in a repository
147
+ * @public
148
+ */
149
+ interface CommitFile {
150
+ [key: string]: unknown;
151
+ attributes?: CommitFileAttributesEnum;
152
+ commit?: Commit;
153
+ /**
154
+ * The escaped version of the path as it appears in a diff. If the path does not require escaping this will be the same as path.
155
+ */
156
+ escaped_path?: string;
157
+ /**
158
+ * The path in the repository
159
+ */
160
+ path?: string;
161
+ type: string;
162
+ }
163
+ /**
164
+ * @public
165
+ */
166
+ const CommitFileAttributesEnum: {
167
+ readonly Link: "link";
168
+ readonly Executable: "executable";
169
+ readonly Subrepository: "subrepository";
170
+ readonly Binary: "binary";
171
+ readonly Lfs: "lfs";
172
+ };
173
+ /**
174
+ * @public
175
+ */
176
+ type CommitFileAttributesEnum = typeof CommitFileAttributesEnum[keyof typeof CommitFileAttributesEnum];
177
+ /**
178
+ * A link to a resource related to this object.
179
+ * @public
180
+ */
181
+ interface Link {
182
+ href?: string;
183
+ name?: string;
184
+ }
185
+ /**
186
+ * Base type for most resource objects. It defines the common `type` element that identifies an object's type. It also identifies the element as Swagger's `discriminator`.
187
+ * @public
188
+ */
189
+ interface ModelObject {
190
+ [key: string]: unknown;
191
+ type: string;
192
+ }
193
+ /**
194
+ * A generic paginated list.
195
+ * @public
196
+ */
197
+ interface Paginated<TResultItem> {
198
+ /**
199
+ * Link to the next page if it exists. The last page of a collection does not have this value. Use this link to navigate the result set and refrain from constructing your own URLs.
200
+ */
201
+ next?: string;
202
+ /**
203
+ * Page number of the current results. This is an optional element that is not provided in all responses.
204
+ */
205
+ page?: number;
206
+ /**
207
+ * Current number of objects on the existing page. The default value is 10 with 100 being the maximum allowed value. Individual APIs may enforce different values.
208
+ */
209
+ pagelen?: number;
210
+ /**
211
+ * Link to previous page if it exists. A collections first page does not have this value. This is an optional element that is not provided in all responses. Some result sets strictly support forward navigation and never provide previous links. Clients must anticipate that backwards navigation is not always available. Use this link to navigate the result set and refrain from constructing your own URLs.
212
+ */
213
+ previous?: string;
214
+ /**
215
+ * Total number of objects in the response. This is an optional element that is not provided in all responses, as it can be expensive to compute.
216
+ */
217
+ size?: number;
218
+ /**
219
+ * The values of the current page.
220
+ */
221
+ values?: Array<TResultItem> | Set<TResultItem>;
222
+ }
223
+ /**
224
+ * A paginated list of repositories.
225
+ * @public
226
+ */
227
+ interface PaginatedRepositories extends Paginated<Repository> {
228
+ /**
229
+ * The values of the current page.
230
+ */
231
+ values?: Set<Repository>;
232
+ }
233
+ /**
234
+ * Object describing a user's role on resources like commits or pull requests.
235
+ * @public
236
+ */
237
+ interface Participant extends ModelObject {
238
+ approved?: boolean;
239
+ /**
240
+ * The ISO8601 timestamp of the participant's action. For approvers, this is the time of their approval. For commenters and pull request reviewers who are not approvers, this is the time they last commented, or null if they have not commented.
241
+ */
242
+ participated_on?: string;
243
+ role?: ParticipantRoleEnum;
244
+ state?: ParticipantStateEnum;
245
+ user?: User;
246
+ }
247
+ /**
248
+ * @public
249
+ */
250
+ const ParticipantRoleEnum: {
251
+ readonly Participant: "PARTICIPANT";
252
+ readonly Reviewer: "REVIEWER";
253
+ };
254
+ /**
255
+ * @public
256
+ */
257
+ type ParticipantRoleEnum = typeof ParticipantRoleEnum[keyof typeof ParticipantRoleEnum];
258
+ /**
259
+ * @public
260
+ */
261
+ const ParticipantStateEnum: {
262
+ readonly Approved: "approved";
263
+ readonly ChangesRequested: "changes_requested";
264
+ readonly Null: "null";
265
+ };
266
+ /**
267
+ * @public
268
+ */
269
+ type ParticipantStateEnum = typeof ParticipantStateEnum[keyof typeof ParticipantStateEnum];
270
+ /**
271
+ * A Bitbucket project.
272
+ * Projects are used by teams to organize repositories.
273
+ * @public
274
+ */
275
+ interface Project extends ModelObject {
276
+ created_on?: string;
277
+ description?: string;
278
+ /**
279
+ *
280
+ * Indicates whether the project contains publicly visible repositories.
281
+ * Note that private projects cannot contain public repositories.
282
+ */
283
+ has_publicly_visible_repos?: boolean;
284
+ /**
285
+ *
286
+ * Indicates whether the project is publicly accessible, or whether it is
287
+ * private to the team and consequently only visible to team members.
288
+ * Note that private projects cannot contain public repositories.
289
+ */
290
+ is_private?: boolean;
291
+ /**
292
+ * The project's key.
293
+ */
294
+ key?: string;
295
+ links?: ProjectLinks;
296
+ /**
297
+ * The name of the project.
298
+ */
299
+ name?: string;
300
+ owner?: Team;
301
+ updated_on?: string;
302
+ /**
303
+ * The project's immutable id.
304
+ */
305
+ uuid?: string;
306
+ }
307
+ /**
308
+ * @public
309
+ */
310
+ interface ProjectLinks {
311
+ avatar?: Link;
312
+ html?: Link;
313
+ }
314
+ /**
315
+ * @public
316
+ */
317
+ interface RefLinks {
318
+ commits?: Link;
319
+ html?: Link;
320
+ self?: Link;
321
+ }
322
+ /**
323
+ * A Bitbucket repository.
324
+ * @public
325
+ */
326
+ interface Repository extends ModelObject {
327
+ created_on?: string;
328
+ description?: string;
329
+ /**
330
+ *
331
+ * Controls the rules for forking this repository.
332
+ *
333
+ * * **allow_forks**: unrestricted forking
334
+ * * **no_public_forks**: restrict forking to private forks (forks cannot
335
+ * be made public later)
336
+ * * **no_forks**: deny all forking
337
+ */
338
+ fork_policy?: RepositoryForkPolicyEnum;
339
+ /**
340
+ * The concatenation of the repository owner's username and the slugified name, e.g. "evzijst/interruptingcow". This is the same string used in Bitbucket URLs.
341
+ */
342
+ full_name?: string;
343
+ has_issues?: boolean;
344
+ has_wiki?: boolean;
345
+ is_private?: boolean;
346
+ language?: string;
347
+ links?: RepositoryLinks;
348
+ mainbranch?: Branch;
349
+ name?: string;
350
+ owner?: Account;
351
+ parent?: Repository;
352
+ project?: Project;
353
+ scm?: RepositoryScmEnum;
354
+ size?: number;
355
+ /**
356
+ * The "sluggified" version of the repository's name. This contains only ASCII characters and can therefore be slightly different than the name
357
+ */
358
+ slug?: string;
359
+ updated_on?: string;
360
+ /**
361
+ * The repository's immutable id. This can be used as a substitute for the slug segment in URLs. Doing this guarantees your URLs will survive renaming of the repository by its owner, or even transfer of the repository to a different user.
362
+ */
363
+ uuid?: string;
364
+ }
365
+ /**
366
+ *
367
+ * Controls the rules for forking this repository.
368
+ *
369
+ * * **allow_forks**: unrestricted forking
370
+ * * **no_public_forks**: restrict forking to private forks (forks cannot
371
+ * be made public later)
372
+ * * **no_forks**: deny all forking
373
+ * @public
374
+ */
375
+ const RepositoryForkPolicyEnum: {
376
+ readonly AllowForks: "allow_forks";
377
+ readonly NoPublicForks: "no_public_forks";
378
+ readonly NoForks: "no_forks";
379
+ };
380
+ /**
381
+ *
382
+ * Controls the rules for forking this repository.
383
+ *
384
+ * * **allow_forks**: unrestricted forking
385
+ * * **no_public_forks**: restrict forking to private forks (forks cannot
386
+ * be made public later)
387
+ * * **no_forks**: deny all forking
388
+ * @public
389
+ */
390
+ type RepositoryForkPolicyEnum = typeof RepositoryForkPolicyEnum[keyof typeof RepositoryForkPolicyEnum];
391
+ /**
392
+ * @public
393
+ */
394
+ const RepositoryScmEnum: {
395
+ readonly Git: "git";
396
+ };
397
+ /**
398
+ * @public
399
+ */
400
+ type RepositoryScmEnum = typeof RepositoryScmEnum[keyof typeof RepositoryScmEnum];
401
+ /**
402
+ * @public
403
+ */
404
+ interface RepositoryLinks {
405
+ avatar?: Link;
406
+ clone?: Array<Link>;
407
+ commits?: Link;
408
+ downloads?: Link;
409
+ forks?: Link;
410
+ hooks?: Link;
411
+ html?: Link;
412
+ pullrequests?: Link;
413
+ self?: Link;
414
+ watchers?: Link;
415
+ }
416
+ /**
417
+ * @public
418
+ */
419
+ interface SearchCodeSearchResult {
420
+ readonly content_match_count?: number;
421
+ readonly content_matches?: Array<SearchContentMatch>;
422
+ file?: CommitFile;
423
+ readonly path_matches?: Array<SearchSegment>;
424
+ readonly type?: string;
425
+ }
426
+ /**
427
+ * @public
428
+ */
429
+ interface SearchContentMatch {
430
+ readonly lines?: Array<SearchLine>;
431
+ }
432
+ /**
433
+ * @public
434
+ */
435
+ interface SearchLine {
436
+ readonly line?: number;
437
+ readonly segments?: Array<SearchSegment>;
438
+ }
439
+ /**
440
+ * @public
441
+ */
442
+ interface SearchResultPage extends Paginated<SearchCodeSearchResult> {
443
+ readonly query_substituted?: boolean;
444
+ /**
445
+ * The values of the current page.
446
+ */
447
+ readonly values?: Array<SearchCodeSearchResult>;
448
+ }
449
+ /**
450
+ * @public
451
+ */
452
+ interface SearchSegment {
453
+ readonly match?: boolean;
454
+ readonly text?: string;
455
+ }
456
+ /**
457
+ * A team object.
458
+ * @public
459
+ */
460
+ interface Team extends Account {
461
+ }
462
+ /**
463
+ * A user object.
464
+ * @public
465
+ */
466
+ interface User extends Account {
467
+ /**
468
+ * The user's Atlassian account ID.
469
+ */
470
+ account_id?: string;
471
+ is_staff?: boolean;
472
+ }
473
+ }
474
+
475
+ /** @public */
476
+ declare type PaginationOptions = {
477
+ page?: number;
478
+ pagelen?: number;
479
+ };
480
+ /** @public */
481
+ declare class WithPagination<TPage extends Models.Paginated<TResultItem>, TResultItem> {
482
+ private readonly createUrl;
483
+ private readonly fetch;
484
+ constructor(createUrl: (options: PaginationOptions) => URL, fetch: (url: URL) => Promise<TPage>);
485
+ getPage(options?: PaginationOptions): Promise<TPage>;
486
+ iteratePages(options?: PaginationOptions): AsyncGenerator<TPage, void>;
487
+ iterateResults(options?: PaginationOptions): AsyncGenerator<Awaited<TResultItem>, void, unknown>;
488
+ }
489
+
490
+ /** @public */
491
+ declare type FilterAndSortOptions = {
492
+ q?: string;
493
+ sort?: string;
494
+ };
495
+ /** @public */
496
+ declare type PartialResponseOptions = {
497
+ fields?: string;
498
+ };
499
+ /** @public */
500
+ declare type RequestOptions = FilterAndSortOptions & PaginationOptions & PartialResponseOptions & {
501
+ [key: string]: string | number | undefined;
502
+ };
503
+
504
+ /** @public */
505
+ declare class BitbucketCloudClient {
506
+ private readonly config;
507
+ static fromConfig(config: BitbucketCloudIntegrationConfig): BitbucketCloudClient;
508
+ private constructor();
509
+ searchCode(workspace: string, query: string, options?: FilterAndSortOptions & PartialResponseOptions): WithPagination<Models.SearchResultPage, Models.SearchCodeSearchResult>;
510
+ listRepositoriesByWorkspace(workspace: string, options?: FilterAndSortOptions & PartialResponseOptions): WithPagination<Models.PaginatedRepositories, Models.Repository>;
511
+ private createUrl;
512
+ private getTypeMapped;
513
+ private get;
514
+ private request;
515
+ private getAuthHeaders;
516
+ }
517
+
518
+ export { BitbucketCloudClient, FilterAndSortOptions, Models, PaginationOptions, PartialResponseOptions, RequestOptions, WithPagination };
@@ -0,0 +1,132 @@
1
+ import fetch, { Request } from 'cross-fetch';
2
+
3
+ class WithPagination {
4
+ constructor(createUrl, fetch) {
5
+ this.createUrl = createUrl;
6
+ this.fetch = fetch;
7
+ }
8
+ getPage(options) {
9
+ const opts = { page: 1, pagelen: 100, ...options };
10
+ const url = this.createUrl(opts);
11
+ return this.fetch(url);
12
+ }
13
+ async *iteratePages(options) {
14
+ const opts = { page: 1, pagelen: 100, ...options };
15
+ let url = this.createUrl(opts);
16
+ let res;
17
+ do {
18
+ res = await this.fetch(url);
19
+ url = res.next ? new URL(res.next) : void 0;
20
+ yield res;
21
+ } while (url);
22
+ }
23
+ async *iterateResults(options) {
24
+ var _a;
25
+ const opts = { page: 1, pagelen: 100, ...options };
26
+ let url = this.createUrl(opts);
27
+ let res;
28
+ do {
29
+ res = await this.fetch(url);
30
+ url = res.next ? new URL(res.next) : void 0;
31
+ for (const item of (_a = res.values) != null ? _a : []) {
32
+ yield item;
33
+ }
34
+ } while (url);
35
+ }
36
+ }
37
+
38
+ class BitbucketCloudClient {
39
+ constructor(config) {
40
+ this.config = config;
41
+ }
42
+ static fromConfig(config) {
43
+ return new BitbucketCloudClient(config);
44
+ }
45
+ searchCode(workspace, query, options) {
46
+ const workspaceEnc = encodeURIComponent(workspace);
47
+ return new WithPagination((paginationOptions) => this.createUrl(`/workspaces/${workspaceEnc}/search/code`, {
48
+ ...paginationOptions,
49
+ ...options,
50
+ search_query: query
51
+ }), (url) => this.getTypeMapped(url));
52
+ }
53
+ listRepositoriesByWorkspace(workspace, options) {
54
+ const workspaceEnc = encodeURIComponent(workspace);
55
+ return new WithPagination((paginationOptions) => this.createUrl(`/repositories/${workspaceEnc}`, {
56
+ ...paginationOptions,
57
+ ...options
58
+ }), (url) => this.getTypeMapped(url));
59
+ }
60
+ createUrl(endpoint, options) {
61
+ const request = new URL(this.config.apiBaseUrl + endpoint);
62
+ for (const key in options) {
63
+ if (options[key]) {
64
+ request.searchParams.append(key, options[key].toString());
65
+ }
66
+ }
67
+ return request;
68
+ }
69
+ async getTypeMapped(url) {
70
+ return this.get(url).then((response) => response.json());
71
+ }
72
+ async get(url) {
73
+ return this.request(new Request(url.toString(), { method: "GET" }));
74
+ }
75
+ async request(req) {
76
+ return fetch(req, { headers: this.getAuthHeaders() }).then((response) => {
77
+ if (!response.ok) {
78
+ throw new Error(`Unexpected response for ${req.method} ${req.url}. Expected 200 but got ${response.status} - ${response.statusText}`);
79
+ }
80
+ return response;
81
+ });
82
+ }
83
+ getAuthHeaders() {
84
+ const headers = {};
85
+ if (this.config.username) {
86
+ const buffer = Buffer.from(`${this.config.username}:${this.config.appPassword}`, "utf8");
87
+ headers.Authorization = `Basic ${buffer.toString("base64")}`;
88
+ }
89
+ return headers;
90
+ }
91
+ }
92
+
93
+ var Models;
94
+ ((Models2) => {
95
+ Models2.BaseCommitSummaryMarkupEnum = {
96
+ Markdown: "markdown",
97
+ Creole: "creole",
98
+ Plaintext: "plaintext"
99
+ };
100
+ Models2.BranchMergeStrategiesEnum = {
101
+ MergeCommit: "merge_commit",
102
+ Squash: "squash",
103
+ FastForward: "fast_forward"
104
+ };
105
+ Models2.CommitFileAttributesEnum = {
106
+ Link: "link",
107
+ Executable: "executable",
108
+ Subrepository: "subrepository",
109
+ Binary: "binary",
110
+ Lfs: "lfs"
111
+ };
112
+ Models2.ParticipantRoleEnum = {
113
+ Participant: "PARTICIPANT",
114
+ Reviewer: "REVIEWER"
115
+ };
116
+ Models2.ParticipantStateEnum = {
117
+ Approved: "approved",
118
+ ChangesRequested: "changes_requested",
119
+ Null: "null"
120
+ };
121
+ Models2.RepositoryForkPolicyEnum = {
122
+ AllowForks: "allow_forks",
123
+ NoPublicForks: "no_public_forks",
124
+ NoForks: "no_forks"
125
+ };
126
+ Models2.RepositoryScmEnum = {
127
+ Git: "git"
128
+ };
129
+ })(Models || (Models = {}));
130
+
131
+ export { BitbucketCloudClient, Models, WithPagination };
132
+ //# sourceMappingURL=index.esm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.esm.js","sources":["../src/pagination.ts","../src/BitbucketCloudClient.ts","../src/models/index.ts"],"sourcesContent":["/*\n * Copyright 2022 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { Models } from './models';\n\n/** @public */\nexport type PaginationOptions = {\n page?: number;\n pagelen?: number;\n};\n\n/** @public */\nexport class WithPagination<\n TPage extends Models.Paginated<TResultItem>,\n TResultItem,\n> {\n constructor(\n private readonly createUrl: (options: PaginationOptions) => URL,\n private readonly fetch: (url: URL) => Promise<TPage>,\n ) {}\n\n getPage(options?: PaginationOptions): Promise<TPage> {\n const opts = { page: 1, pagelen: 100, ...options };\n const url = this.createUrl(opts);\n return this.fetch(url);\n }\n\n async *iteratePages(\n options?: PaginationOptions,\n ): AsyncGenerator<TPage, void> {\n const opts = { page: 1, pagelen: 100, ...options };\n let url: URL | undefined = this.createUrl(opts);\n let res;\n do {\n res = await this.fetch(url);\n url = res.next ? new URL(res.next) : undefined;\n yield res;\n } while (url);\n }\n\n async *iterateResults(options?: PaginationOptions) {\n const opts = { page: 1, pagelen: 100, ...options };\n let url: URL | undefined = this.createUrl(opts);\n let res;\n do {\n res = await this.fetch(url);\n url = res.next ? new URL(res.next) : undefined;\n for (const item of res.values ?? []) {\n yield item;\n }\n } while (url);\n }\n}\n","/*\n * Copyright 2022 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { BitbucketCloudIntegrationConfig } from '@backstage/integration';\nimport fetch, { Request } from 'cross-fetch';\nimport { Models } from './models';\nimport { WithPagination } from './pagination';\nimport {\n FilterAndSortOptions,\n PartialResponseOptions,\n RequestOptions,\n} from './types';\n\n/** @public */\nexport class BitbucketCloudClient {\n static fromConfig(\n config: BitbucketCloudIntegrationConfig,\n ): BitbucketCloudClient {\n return new BitbucketCloudClient(config);\n }\n\n private constructor(\n private readonly config: BitbucketCloudIntegrationConfig,\n ) {}\n\n searchCode(\n workspace: string,\n query: string,\n options?: FilterAndSortOptions & PartialResponseOptions,\n ): WithPagination<Models.SearchResultPage, Models.SearchCodeSearchResult> {\n const workspaceEnc = encodeURIComponent(workspace);\n return new WithPagination(\n paginationOptions =>\n this.createUrl(`/workspaces/${workspaceEnc}/search/code`, {\n ...paginationOptions,\n ...options,\n search_query: query,\n }),\n url => this.getTypeMapped(url),\n );\n }\n\n listRepositoriesByWorkspace(\n workspace: string,\n options?: FilterAndSortOptions & PartialResponseOptions,\n ): WithPagination<Models.PaginatedRepositories, Models.Repository> {\n const workspaceEnc = encodeURIComponent(workspace);\n\n return new WithPagination(\n paginationOptions =>\n this.createUrl(`/repositories/${workspaceEnc}`, {\n ...paginationOptions,\n ...options,\n }),\n url => this.getTypeMapped(url),\n );\n }\n\n private createUrl(endpoint: string, options?: RequestOptions): URL {\n const request = new URL(this.config.apiBaseUrl + endpoint);\n for (const key in options) {\n if (options[key]) {\n request.searchParams.append(key, options[key]!.toString());\n }\n }\n\n return request;\n }\n\n private async getTypeMapped<T = any>(url: URL): Promise<T> {\n return this.get(url).then(\n (response: Response) => response.json() as Promise<T>,\n );\n }\n\n private async get(url: URL): Promise<Response> {\n return this.request(new Request(url.toString(), { method: 'GET' }));\n }\n\n private async request(req: Request): Promise<Response> {\n return fetch(req, { headers: this.getAuthHeaders() }).then(\n (response: Response) => {\n if (!response.ok) {\n throw new Error(\n `Unexpected response for ${req.method} ${req.url}. Expected 200 but got ${response.status} - ${response.statusText}`,\n );\n }\n\n return response;\n },\n );\n }\n\n private getAuthHeaders(): Record<string, string> {\n const headers: Record<string, string> = {};\n\n if (this.config.username) {\n const buffer = Buffer.from(\n `${this.config.username}:${this.config.appPassword}`,\n 'utf8',\n );\n headers.Authorization = `Basic ${buffer.toString('base64')}`;\n }\n\n return headers;\n }\n}\n","/*\n * Copyright 2022 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * Bitbucket API\n * Code against the Bitbucket API to automate simple tasks, embed Bitbucket data into your own site, build mobile or desktop apps, or even add custom UI add-ons into Bitbucket itself using the Connect framework.\n *\n * The version of the OpenAPI document: 2.0\n * Contact: support@bitbucket.org\n *\n * NOTE: This file was auto generated by OpenAPI Generator (https://openapi-generator.tech).\n * https://openapi-generator.tech\n * Do not edit the class manually.\n */\n\n/** @public */\nexport namespace Models {\n /**\n * An account object.\n * @public\n */\n export interface Account extends ModelObject {\n /**\n * The status of the account. Currently the only possible value is \"active\", but more values may be added in the future.\n */\n account_status?: string;\n created_on?: string;\n display_name?: string;\n has_2fa_enabled?: boolean;\n links?: AccountLinks;\n /**\n * Account name defined by the owner. Should be used instead of the \"username\" field. Note that \"nickname\" cannot be used in place of \"username\" in URLs and queries, as \"nickname\" is not guaranteed to be unique.\n */\n nickname?: string;\n username?: string;\n uuid?: string;\n website?: string;\n }\n\n /**\n * @public\n */\n export interface AccountLinks {\n avatar?: Link;\n followers?: Link;\n following?: Link;\n html?: Link;\n repositories?: Link;\n self?: Link;\n }\n\n /**\n * The author of a change in a repository\n * @public\n */\n export interface Author extends ModelObject {\n /**\n * The raw author value from the repository. This may be the only value available if the author does not match a user in Bitbucket.\n */\n raw?: string;\n user?: Account;\n }\n\n /**\n * The common base type for both repository and snippet commits.\n * @public\n */\n export interface BaseCommit extends ModelObject {\n author?: Author;\n date?: string;\n hash?: string;\n message?: string;\n parents?: Array<BaseCommit>;\n summary?: BaseCommitSummary;\n }\n\n /**\n * @public\n */\n export interface BaseCommitSummary {\n /**\n * The user's content rendered as HTML.\n */\n html?: string;\n /**\n * The type of markup language the raw content is to be interpreted in.\n */\n markup?: BaseCommitSummaryMarkupEnum;\n /**\n * The text as it was typed by a user.\n */\n raw?: string;\n }\n\n /**\n * The type of markup language the raw content is to be interpreted in.\n * @public\n */\n export const BaseCommitSummaryMarkupEnum = {\n Markdown: 'markdown',\n Creole: 'creole',\n Plaintext: 'plaintext',\n } as const;\n\n /**\n * The type of markup language the raw content is to be interpreted in.\n * @public\n */\n export type BaseCommitSummaryMarkupEnum =\n typeof BaseCommitSummaryMarkupEnum[keyof typeof BaseCommitSummaryMarkupEnum];\n\n /**\n * A branch object, representing a branch in a repository.\n * @public\n */\n export interface Branch {\n links?: RefLinks;\n /**\n * The name of the ref.\n */\n name?: string;\n target?: Commit;\n type: string;\n /**\n * The default merge strategy for pull requests targeting this branch.\n */\n default_merge_strategy?: string;\n /**\n * Available merge strategies for pull requests targeting this branch.\n */\n merge_strategies?: Array<BranchMergeStrategiesEnum>;\n }\n\n /**\n * Available merge strategies for pull requests targeting this branch.\n * @public\n */\n export const BranchMergeStrategiesEnum = {\n MergeCommit: 'merge_commit',\n Squash: 'squash',\n FastForward: 'fast_forward',\n } as const;\n\n /**\n * Available merge strategies for pull requests targeting this branch.\n * @public\n */\n export type BranchMergeStrategiesEnum =\n typeof BranchMergeStrategiesEnum[keyof typeof BranchMergeStrategiesEnum];\n\n /**\n * A repository commit object.\n * @public\n */\n export interface Commit extends BaseCommit {\n participants?: Array<Participant>;\n repository?: Repository;\n }\n\n /**\n * A file object, representing a file at a commit in a repository\n * @public\n */\n export interface CommitFile {\n [key: string]: unknown;\n attributes?: CommitFileAttributesEnum;\n commit?: Commit;\n /**\n * The escaped version of the path as it appears in a diff. If the path does not require escaping this will be the same as path.\n */\n escaped_path?: string;\n /**\n * The path in the repository\n */\n path?: string;\n type: string;\n }\n\n /**\n * @public\n */\n export const CommitFileAttributesEnum = {\n Link: 'link',\n Executable: 'executable',\n Subrepository: 'subrepository',\n Binary: 'binary',\n Lfs: 'lfs',\n } as const;\n\n /**\n * @public\n */\n export type CommitFileAttributesEnum =\n typeof CommitFileAttributesEnum[keyof typeof CommitFileAttributesEnum];\n\n /**\n * A link to a resource related to this object.\n * @public\n */\n export interface Link {\n href?: string;\n name?: string;\n }\n\n /**\n * Base type for most resource objects. It defines the common `type` element that identifies an object's type. It also identifies the element as Swagger's `discriminator`.\n * @public\n */\n export interface ModelObject {\n [key: string]: unknown;\n type: string;\n }\n\n /**\n * A generic paginated list.\n * @public\n */\n export interface Paginated<TResultItem> {\n /**\n * Link to the next page if it exists. The last page of a collection does not have this value. Use this link to navigate the result set and refrain from constructing your own URLs.\n */\n next?: string;\n /**\n * Page number of the current results. This is an optional element that is not provided in all responses.\n */\n page?: number;\n /**\n * Current number of objects on the existing page. The default value is 10 with 100 being the maximum allowed value. Individual APIs may enforce different values.\n */\n pagelen?: number;\n /**\n * Link to previous page if it exists. A collections first page does not have this value. This is an optional element that is not provided in all responses. Some result sets strictly support forward navigation and never provide previous links. Clients must anticipate that backwards navigation is not always available. Use this link to navigate the result set and refrain from constructing your own URLs.\n */\n previous?: string;\n /**\n * Total number of objects in the response. This is an optional element that is not provided in all responses, as it can be expensive to compute.\n */\n size?: number;\n /**\n * The values of the current page.\n */\n values?: Array<TResultItem> | Set<TResultItem>;\n }\n\n /**\n * A paginated list of repositories.\n * @public\n */\n export interface PaginatedRepositories extends Paginated<Repository> {\n /**\n * The values of the current page.\n */\n values?: Set<Repository>;\n }\n\n /**\n * Object describing a user's role on resources like commits or pull requests.\n * @public\n */\n export interface Participant extends ModelObject {\n approved?: boolean;\n /**\n * The ISO8601 timestamp of the participant's action. For approvers, this is the time of their approval. For commenters and pull request reviewers who are not approvers, this is the time they last commented, or null if they have not commented.\n */\n participated_on?: string;\n role?: ParticipantRoleEnum;\n state?: ParticipantStateEnum;\n user?: User;\n }\n\n /**\n * @public\n */\n export const ParticipantRoleEnum = {\n Participant: 'PARTICIPANT',\n Reviewer: 'REVIEWER',\n } as const;\n\n /**\n * @public\n */\n export type ParticipantRoleEnum =\n typeof ParticipantRoleEnum[keyof typeof ParticipantRoleEnum];\n\n /**\n * @public\n */\n export const ParticipantStateEnum = {\n Approved: 'approved',\n ChangesRequested: 'changes_requested',\n Null: 'null',\n } as const;\n\n /**\n * @public\n */\n export type ParticipantStateEnum =\n typeof ParticipantStateEnum[keyof typeof ParticipantStateEnum];\n\n /**\n * A Bitbucket project.\n * Projects are used by teams to organize repositories.\n * @public\n */\n export interface Project extends ModelObject {\n created_on?: string;\n description?: string;\n /**\n *\n * Indicates whether the project contains publicly visible repositories.\n * Note that private projects cannot contain public repositories.\n */\n has_publicly_visible_repos?: boolean;\n /**\n *\n * Indicates whether the project is publicly accessible, or whether it is\n * private to the team and consequently only visible to team members.\n * Note that private projects cannot contain public repositories.\n */\n is_private?: boolean;\n /**\n * The project's key.\n */\n key?: string;\n links?: ProjectLinks;\n /**\n * The name of the project.\n */\n name?: string;\n owner?: Team;\n updated_on?: string;\n /**\n * The project's immutable id.\n */\n uuid?: string;\n }\n\n /**\n * @public\n */\n export interface ProjectLinks {\n avatar?: Link;\n html?: Link;\n }\n\n /**\n * @public\n */\n export interface RefLinks {\n commits?: Link;\n html?: Link;\n self?: Link;\n }\n\n /**\n * A Bitbucket repository.\n * @public\n */\n export interface Repository extends ModelObject {\n created_on?: string;\n description?: string;\n /**\n *\n * Controls the rules for forking this repository.\n *\n * * **allow_forks**: unrestricted forking\n * * **no_public_forks**: restrict forking to private forks (forks cannot\n * be made public later)\n * * **no_forks**: deny all forking\n */\n fork_policy?: RepositoryForkPolicyEnum;\n /**\n * The concatenation of the repository owner's username and the slugified name, e.g. \"evzijst/interruptingcow\". This is the same string used in Bitbucket URLs.\n */\n full_name?: string;\n has_issues?: boolean;\n has_wiki?: boolean;\n is_private?: boolean;\n language?: string;\n links?: RepositoryLinks;\n mainbranch?: Branch;\n name?: string;\n owner?: Account;\n parent?: Repository;\n project?: Project;\n scm?: RepositoryScmEnum;\n size?: number;\n /**\n * The \"sluggified\" version of the repository's name. This contains only ASCII characters and can therefore be slightly different than the name\n */\n slug?: string;\n updated_on?: string;\n /**\n * The repository's immutable id. This can be used as a substitute for the slug segment in URLs. Doing this guarantees your URLs will survive renaming of the repository by its owner, or even transfer of the repository to a different user.\n */\n uuid?: string;\n }\n\n /**\n *\n * Controls the rules for forking this repository.\n *\n * * **allow_forks**: unrestricted forking\n * * **no_public_forks**: restrict forking to private forks (forks cannot\n * be made public later)\n * * **no_forks**: deny all forking\n * @public\n */\n export const RepositoryForkPolicyEnum = {\n AllowForks: 'allow_forks',\n NoPublicForks: 'no_public_forks',\n NoForks: 'no_forks',\n } as const;\n\n /**\n *\n * Controls the rules for forking this repository.\n *\n * * **allow_forks**: unrestricted forking\n * * **no_public_forks**: restrict forking to private forks (forks cannot\n * be made public later)\n * * **no_forks**: deny all forking\n * @public\n */\n export type RepositoryForkPolicyEnum =\n typeof RepositoryForkPolicyEnum[keyof typeof RepositoryForkPolicyEnum];\n\n /**\n * @public\n */\n export const RepositoryScmEnum = {\n Git: 'git',\n } as const;\n\n /**\n * @public\n */\n export type RepositoryScmEnum =\n typeof RepositoryScmEnum[keyof typeof RepositoryScmEnum];\n\n /**\n * @public\n */\n export interface RepositoryLinks {\n avatar?: Link;\n clone?: Array<Link>;\n commits?: Link;\n downloads?: Link;\n forks?: Link;\n hooks?: Link;\n html?: Link;\n pullrequests?: Link;\n self?: Link;\n watchers?: Link;\n }\n\n /**\n * @public\n */\n export interface SearchCodeSearchResult {\n readonly content_match_count?: number;\n readonly content_matches?: Array<SearchContentMatch>;\n file?: CommitFile;\n readonly path_matches?: Array<SearchSegment>;\n readonly type?: string;\n }\n\n /**\n * @public\n */\n export interface SearchContentMatch {\n readonly lines?: Array<SearchLine>;\n }\n\n /**\n * @public\n */\n export interface SearchLine {\n readonly line?: number;\n readonly segments?: Array<SearchSegment>;\n }\n\n /**\n * @public\n */\n export interface SearchResultPage extends Paginated<SearchCodeSearchResult> {\n readonly query_substituted?: boolean;\n /**\n * The values of the current page.\n */\n readonly values?: Array<SearchCodeSearchResult>;\n }\n\n /**\n * @public\n */\n export interface SearchSegment {\n readonly match?: boolean;\n readonly text?: string;\n }\n\n /**\n * A team object.\n * @public\n */\n export interface Team extends Account {}\n\n /**\n * A user object.\n * @public\n */\n export interface User extends Account {\n /**\n * The user's Atlassian account ID.\n */\n account_id?: string;\n is_staff?: boolean;\n }\n}\n"],"names":[],"mappings":";;AAAO,MAAM,cAAc,CAAC;AAC5B,EAAE,WAAW,CAAC,SAAS,EAAE,KAAK,EAAE;AAChC,IAAI,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;AAC/B,IAAI,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;AACvB,GAAG;AACH,EAAE,OAAO,CAAC,OAAO,EAAE;AACnB,IAAI,MAAM,IAAI,GAAG,EAAE,IAAI,EAAE,CAAC,EAAE,OAAO,EAAE,GAAG,EAAE,GAAG,OAAO,EAAE,CAAC;AACvD,IAAI,MAAM,GAAG,GAAG,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;AACrC,IAAI,OAAO,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;AAC3B,GAAG;AACH,EAAE,OAAO,YAAY,CAAC,OAAO,EAAE;AAC/B,IAAI,MAAM,IAAI,GAAG,EAAE,IAAI,EAAE,CAAC,EAAE,OAAO,EAAE,GAAG,EAAE,GAAG,OAAO,EAAE,CAAC;AACvD,IAAI,IAAI,GAAG,GAAG,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;AACnC,IAAI,IAAI,GAAG,CAAC;AACZ,IAAI,GAAG;AACP,MAAM,GAAG,GAAG,MAAM,I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 -0,0 +1,44 @@
1
+ {
2
+ "name": "@backstage/plugin-bitbucket-cloud-common",
3
+ "description": "Common functionalities for bitbucket-cloud plugins",
4
+ "version": "0.0.0-nightly-20220531024457",
5
+ "main": "dist/index.cjs.js",
6
+ "types": "dist/index.d.ts",
7
+ "license": "Apache-2.0",
8
+ "private": false,
9
+ "publishConfig": {
10
+ "access": "public",
11
+ "main": "dist/index.cjs.js",
12
+ "module": "dist/index.esm.js",
13
+ "types": "dist/index.d.ts"
14
+ },
15
+ "backstage": {
16
+ "role": "common-library"
17
+ },
18
+ "scripts": {
19
+ "build": "backstage-cli package build",
20
+ "lint": "backstage-cli package lint",
21
+ "test": "backstage-cli package test",
22
+ "clean": "backstage-cli package clean",
23
+ "prepack": "backstage-cli package prepack",
24
+ "postpack": "backstage-cli package postpack",
25
+ "refresh-schema": "scripts/prepare-schema.js && prettier --check bitbucket-cloud.oas.json -w",
26
+ "generate-models": "scripts/generate-models.sh",
27
+ "reduce-models": "scripts/reduce-models.js",
28
+ "update-models": "yarn refresh-schema && yarn generate-models && yarn reduce-models"
29
+ },
30
+ "dependencies": {
31
+ "@backstage/integration": "^0.0.0-nightly-20220531024457",
32
+ "cross-fetch": "^3.1.5"
33
+ },
34
+ "devDependencies": {
35
+ "@backstage/cli": "^0.0.0-nightly-20220531024457",
36
+ "@openapitools/openapi-generator-cli": "^2.4.26",
37
+ "msw": "^0.35.0",
38
+ "ts-morph": "^15.0.0"
39
+ },
40
+ "files": [
41
+ "dist"
42
+ ],
43
+ "module": "dist/index.esm.js"
44
+ }