@backstage/plugin-bitbucket-cloud-common 0.1.3-next.1 → 0.2.0-next.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,32 @@
1
1
  # @backstage/plugin-bitbucket-cloud-common
2
2
 
3
+ ## 0.2.0-next.0
4
+
5
+ ### Minor Changes
6
+
7
+ - ad74723fbf: Update Bitbucket Cloud models to latest OAS version.
8
+
9
+ The latest specification contained some BREAKING CHANGES
10
+ due to removed fields.
11
+
12
+ All of these fields are not used at other plugins, though.
13
+ Therefore, this change has no impact on other modules here.
14
+
15
+ ### Patch Changes
16
+
17
+ - Updated dependencies
18
+ - @backstage/integration@1.3.2-next.0
19
+
20
+ ## 0.1.3
21
+
22
+ ### Patch Changes
23
+
24
+ - 667d917488: Updated dependency `msw` to `^0.47.0`.
25
+ - 87ec2ba4d6: Updated dependency `msw` to `^0.46.0`.
26
+ - bf5e9030eb: Updated dependency `msw` to `^0.45.0`.
27
+ - Updated dependencies
28
+ - @backstage/integration@1.3.1
29
+
3
30
  ## 0.1.3-next.1
4
31
 
5
32
  ### Patch Changes
@@ -1 +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 Atlassian account ID.\n */\n account_id?: string;\n is_staff?: boolean;\n }\n}\n"],"names":["Request","fetch","Models"],"mappings":";;;;;;;;;;AAyBO,MAAM,cAGX,CAAA;AAAA,EACA,WAAA,CACmB,WACA,KACjB,EAAA;AAFiB,IAAA,IAAA,CAAA,SAAA,GAAA,SAAA,CAAA;AACA,IAAA,IAAA,CAAA,KAAA,GAAA,KAAA,CAAA;AAAA,GAChB;AAAA,EAEH,QAAQ,OAA6C,EAAA;AACnD,IAAA,MAAM,OAAO,EAAE,IAAA,EAAM,GAAG,OAAS,EAAA,GAAA,EAAK,GAAG,OAAQ,EAAA,CAAA;AACjD,IAAM,MAAA,GAAA,GAAM,IAAK,CAAA,SAAA,CAAU,IAAI,CAAA,CAAA;AAC/B,IAAO,OAAA,IAAA,CAAK,MAAM,GAAG,CAAA,CAAA;AAAA,GACvB;AAAA,EAEA,OAAO,aACL,OAC6B,EAAA;AAC7B,IAAA,MAAM,OAAO,EAAE,IAAA,EAAM,GAAG,OAAS,EAAA,GAAA,EAAK,GAAG,OAAQ,EAAA,CAAA;AACjD,IAAI,IAAA,GAAA,GAAuB,IAAK,CAAA,SAAA,CAAU,IAAI,CAAA,CAAA;AAC9C,IAAI,IAAA,GAAA,CAAA;AACJ,IAAG,GAAA;AACD,MAAM,GAAA,GAAA,MAAM,IAAK,CAAA,KAAA,CAAM,GAAG,CAAA,CAAA;AAC1B,MAAA,GAAA,GAAM,IAAI,IAAO,GAAA,IAAI,GAAI,CAAA,GAAA,CAAI,IAAI,CAAI,GAAA,KAAA,CAAA,CAAA;AACrC,MAAM,MAAA,GAAA,CAAA;AAAA,KACC,QAAA,GAAA,EAAA;AAAA,GACX;AAAA,EAEA,OAAO,eAAe,OAA6B,EAAA;AArDrD,IAAA,IAAA,EAAA,CAAA;AAsDI,IAAA,MAAM,OAAO,EAAE,IAAA,EAAM,G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AAM,EAAA,MAAA;AAAA,IACN,UAAY,EAAA,YAAA;AAAA,IACZ,aAAe,EAAA,eAAA;AAAA,IACf,MAAQ,EAAA,QAAA;AAAA,IACR,GAAK,EAAA,KAAA;AAAA,GACP,CAAA;AAsFO,EAAMA,QAAA,mBAAsB,GAAA;AAAA,IACjC,WAAa,EAAA,aAAA;AAAA,IACb,QAAU,EAAA,UAAA;AAAA,GACZ,CAAA;AAWO,EAAMA,QAAA,oBAAuB,GAAA;AAAA,IAClC,QAAU,EAAA,UAAA;AAAA,IACV,gBAAkB,EAAA,mBAAA;AAAA,IAClB,IAAM,EAAA,MAAA;AAAA,GACR,CAAA;AAqHO,EAAMA,QAAA,wBAA2B,GAAA;AAAA,IACtC,UAAY,EAAA,aAAA;AAAA,IACZ,aAAe,EAAA,iBAAA;AAAA,IACf,OAAS,EAAA,UAAA;AAAA,GACX,CAAA;AAkBO,EAAMA,QAAA,iBAAoB,GAAA;AAAA,IAC/B,GAAK,EAAA,KAAA;AAAA,GACP,CAAA;AAAA,CAhae,EAAAA,cAAA,KAAAA,cAAA,GAAA,EAAA,CAAA,CAAA;;;;;"}
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 created_on?: string;\n display_name?: string;\n links?: AccountLinks;\n username?: string;\n uuid?: string;\n }\n\n /**\n * Links related to an Account.\n * @public\n */\n export interface AccountLinks {\n [key: string]: unknown;\n avatar?: 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?: Account;\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 links?: TeamLinks;\n }\n\n /**\n * Links related to a Team.\n * @public\n */\n export interface TeamLinks extends AccountLinks {\n html?: Link;\n members?: Link;\n projects?: Link;\n repositories?: Link;\n self?: Link;\n }\n}\n"],"names":["Request","fetch","Models"],"mappings":";;;;;;;;;;AAyBO,MAAM,cAGX,CAAA;AAAA,EACA,WAAA,CACmB,WACA,KACjB,EAAA;AAF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A,UAAA;AAAA,GACZ,CAAA;AAWO,EAAMA,QAAA,oBAAuB,GAAA;AAAA,IAClC,QAAU,EAAA,UAAA;AAAA,IACV,gBAAkB,EAAA,mBAAA;AAAA,IAClB,IAAM,EAAA,MAAA;AAAA,GACR,CAAA;AAqHO,EAAMA,QAAA,wBAA2B,GAAA;AAAA,IACtC,UAAY,EAAA,aAAA;AAAA,IACZ,aAAe,EAAA,iBAAA;AAAA,IACf,OAAS,EAAA,UAAA;AAAA,GACX,CAAA;AAkBO,EAAMA,QAAA,iBAAoB,GAAA;AAAA,IAC/B,GAAK,EAAA,KAAA;AAAA,GACP,CAAA;AAAA,CAnZe,EAAAA,cAAA,KAAAA,cAAA,GAAA,EAAA,CAAA,CAAA;;;;;"}
package/dist/index.d.ts CHANGED
@@ -18,32 +18,19 @@ declare namespace Models {
18
18
  * @public
19
19
  */
20
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
21
  created_on?: string;
26
22
  display_name?: string;
27
- has_2fa_enabled?: boolean;
28
23
  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
24
  username?: string;
34
25
  uuid?: string;
35
- website?: string;
36
26
  }
37
27
  /**
28
+ * Links related to an Account.
38
29
  * @public
39
30
  */
40
31
  interface AccountLinks {
32
+ [key: string]: unknown;
41
33
  avatar?: Link;
42
- followers?: Link;
43
- following?: Link;
44
- html?: Link;
45
- repositories?: Link;
46
- self?: Link;
47
34
  }
48
35
  /**
49
36
  * The author of a change in a repository
@@ -242,7 +229,7 @@ declare namespace Models {
242
229
  participated_on?: string;
243
230
  role?: ParticipantRoleEnum;
244
231
  state?: ParticipantStateEnum;
245
- user?: User;
232
+ user?: Account;
246
233
  }
247
234
  /**
248
235
  * @public
@@ -458,17 +445,18 @@ declare namespace Models {
458
445
  * @public
459
446
  */
460
447
  interface Team extends Account {
448
+ links?: TeamLinks;
461
449
  }
462
450
  /**
463
- * A user object.
451
+ * Links related to a Team.
464
452
  * @public
465
453
  */
466
- interface User extends Account {
467
- /**
468
- * The user's Atlassian account ID.
469
- */
470
- account_id?: string;
471
- is_staff?: boolean;
454
+ interface TeamLinks extends AccountLinks {
455
+ html?: Link;
456
+ members?: Link;
457
+ projects?: Link;
458
+ repositories?: Link;
459
+ self?: Link;
472
460
  }
473
461
  }
474
462
 
@@ -1 +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":["Models"],"mappings":";;AAyBO,MAAM,cAGX,CAAA;AAAA,EACA,WAAA,CACmB,WACA,KACjB,EAAA;AAFiB,IAAA,IAAA,CAAA,SAAA,GAAA,SAAA,CAAA;AACA,IAAA,IAAA,CAAA,KAAA,GAAA,KAAA,CAAA;AAAA,GAChB;AAAA,EAEH,QAAQ,OAA6C,EAAA;AACnD,IAAA,MAAM,OAAO,EAAE,IAAA,EAAM,GAAG,OAAS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wBAA2B,GAAA;AAAA,IACtC,UAAY,EAAA,aAAA;AAAA,IACZ,aAAe,EAAA,iBAAA;AAAA,IACf,OAAS,EAAA,UAAA;AAAA,GACX,CAAA;AAkBO,EAAMA,QAAA,iBAAoB,GAAA;AAAA,IAC/B,GAAK,EAAA,KAAA;AAAA,GACP,CAAA;AAAA,CAhae,EAAA,MAAA,KAAA,MAAA,GAAA,EAAA,CAAA,CAAA;;;;"}
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 created_on?: string;\n display_name?: string;\n links?: AccountLinks;\n username?: string;\n uuid?: string;\n }\n\n /**\n * Links related to an Account.\n * @public\n */\n export interface AccountLinks {\n [key: string]: unknown;\n avatar?: 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?: Account;\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 links?: TeamLinks;\n }\n\n /**\n * Links related to a Team.\n * @public\n */\n export interface TeamLinks extends AccountLinks {\n html?: Link;\n members?: Link;\n projects?: Link;\n repositories?: Link;\n self?: Link;\n }\n}\n"],"names":["Models"],"mappings":";;AAyBO,MAAM,cAGX,CAAA;AAAA,EACA,WAAA,CACmB,WACA,KACjB,EAAA;AAFiB,IAAA,IAAA,CAAA,SAAA,GAAA,SAAA,CAAA;AACA,IAAA,IAAA,CAAA,KAAA,GAAA,KAAA,CAAA;AAAA,GAChB;AAAA,EAEH,QAAQ,OAA6C,EAAA;AACnD,IAAA,MAAM,OAAO,EAAE,IAAA,EAAM,GAAG,OAAS,EAAA,GAAA,EAAK,GAAG,OAAQ,EAAA,CAAA;AACjD,IAAM,MAAA,GAAA,GAAM,IAAK,CAAA,SAAA,CAAU,IAAI,CAAA,CAAA;AAC/B,IAAO,OAAA,IAAA,CAAK,MAAM,GAAG,CAAA,CAAA;AAAA,GACvB;AAAA,EAEA,OAAO,aACL,OAC6B,EAAA;AAC7B,IAAA,MAAM,OAAO,EAAE,IAAA,EA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CAAA;;;;"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@backstage/plugin-bitbucket-cloud-common",
3
3
  "description": "Common functionalities for bitbucket-cloud plugins",
4
- "version": "0.1.3-next.1",
4
+ "version": "0.2.0-next.0",
5
5
  "main": "dist/index.cjs.js",
6
6
  "types": "dist/index.d.ts",
7
7
  "license": "Apache-2.0",
@@ -21,17 +21,17 @@
21
21
  "clean": "backstage-cli package clean",
22
22
  "prepack": "backstage-cli package prepack",
23
23
  "postpack": "backstage-cli package postpack",
24
- "refresh-schema": "scripts/prepare-schema.js && prettier --check bitbucket-cloud.oas.json -w",
24
+ "refresh-schema": "scripts/prepare-schema.js && yarn run -T prettier --check bitbucket-cloud.oas.json -w",
25
25
  "generate-models": "scripts/generate-models.sh",
26
26
  "reduce-models": "scripts/reduce-models.js",
27
27
  "update-models": "yarn refresh-schema && yarn generate-models && yarn reduce-models"
28
28
  },
29
29
  "dependencies": {
30
- "@backstage/integration": "^1.3.1-next.1",
30
+ "@backstage/integration": "^1.3.2-next.0",
31
31
  "cross-fetch": "^3.1.5"
32
32
  },
33
33
  "devDependencies": {
34
- "@backstage/cli": "^0.19.0-next.2",
34
+ "@backstage/cli": "^0.20.0-next.0",
35
35
  "@openapitools/openapi-generator-cli": "^2.4.26",
36
36
  "msw": "^0.47.0",
37
37
  "ts-morph": "^15.0.0"
@@ -39,6 +39,5 @@
39
39
  "files": [
40
40
  "dist"
41
41
  ],
42
- "gitHead": "24f889f173370f060725fcf9404081e40769beb4",
43
42
  "module": "dist/index.esm.js"
44
- }
43
+ }
package/LICENSE DELETED
@@ -1,201 +0,0 @@
1
- Apache License
2
- Version 2.0, January 2004
3
- http://www.apache.org/licenses/
4
-
5
- TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
-
7
- 1. Definitions.
8
-
9
- "License" shall mean the terms and conditions for use, reproduction,
10
- and distribution as defined by Sections 1 through 9 of this document.
11
-
12
- "Licensor" shall mean the copyright owner or entity authorized by
13
- the copyright owner that is granting the License.
14
-
15
- "Legal Entity" shall mean the union of the acting entity and all
16
- other entities that control, are controlled by, or are under common
17
- control with that entity. For the purposes of this definition,
18
- "control" means (i) the power, direct or indirect, to cause the
19
- direction or management of such entity, whether by contract or
20
- otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
- outstanding shares, or (iii) beneficial ownership of such entity.
22
-
23
- "You" (or "Your") shall mean an individual or Legal Entity
24
- exercising permissions granted by this License.
25
-
26
- "Source" form shall mean the preferred form for making modifications,
27
- including but not limited to software source code, documentation
28
- source, and configuration files.
29
-
30
- "Object" form shall mean any form resulting from mechanical
31
- transformation or translation of a Source form, including but
32
- not limited to compiled object code, generated documentation,
33
- and conversions to other media types.
34
-
35
- "Work" shall mean the work of authorship, whether in Source or
36
- Object form, made available under the License, as indicated by a
37
- copyright notice that is included in or attached to the work
38
- (an example is provided in the Appendix below).
39
-
40
- "Derivative Works" shall mean any work, whether in Source or Object
41
- form, that is based on (or derived from) the Work and for which the
42
- editorial revisions, annotations, elaborations, or other modifications
43
- represent, as a whole, an original work of authorship. For the purposes
44
- of this License, Derivative Works shall not include works that remain
45
- separable from, or merely link (or bind by name) to the interfaces of,
46
- the Work and Derivative Works thereof.
47
-
48
- "Contribution" shall mean any work of authorship, including
49
- the original version of the Work and any modifications or additions
50
- to that Work or Derivative Works thereof, that is intentionally
51
- submitted to Licensor for inclusion in the Work by the copyright owner
52
- or by an individual or Legal Entity authorized to submit on behalf of
53
- the copyright owner. For the purposes of this definition, "submitted"
54
- means any form of electronic, verbal, or written communication sent
55
- to the Licensor or its representatives, including but not limited to
56
- communication on electronic mailing lists, source code control systems,
57
- and issue tracking systems that are managed by, or on behalf of, the
58
- Licensor for the purpose of discussing and improving the Work, but
59
- excluding communication that is conspicuously marked or otherwise
60
- designated in writing by the copyright owner as "Not a Contribution."
61
-
62
- "Contributor" shall mean Licensor and any individual or Legal Entity
63
- on behalf of whom a Contribution has been received by Licensor and
64
- subsequently incorporated within the Work.
65
-
66
- 2. Grant of Copyright License. Subject to the terms and conditions of
67
- this License, each Contributor hereby grants to You a perpetual,
68
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
- copyright license to reproduce, prepare Derivative Works of,
70
- publicly display, publicly perform, sublicense, and distribute the
71
- Work and such Derivative Works in Source or Object form.
72
-
73
- 3. Grant of Patent License. Subject to the terms and conditions of
74
- this License, each Contributor hereby grants to You a perpetual,
75
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
- (except as stated in this section) patent license to make, have made,
77
- use, offer to sell, sell, import, and otherwise transfer the Work,
78
- where such license applies only to those patent claims licensable
79
- by such Contributor that are necessarily infringed by their
80
- Contribution(s) alone or by combination of their Contribution(s)
81
- with the Work to which such Contribution(s) was submitted. If You
82
- institute patent litigation against any entity (including a
83
- cross-claim or counterclaim in a lawsuit) alleging that the Work
84
- or a Contribution incorporated within the Work constitutes direct
85
- or contributory patent infringement, then any patent licenses
86
- granted to You under this License for that Work shall terminate
87
- as of the date such litigation is filed.
88
-
89
- 4. Redistribution. You may reproduce and distribute copies of the
90
- Work or Derivative Works thereof in any medium, with or without
91
- modifications, and in Source or Object form, provided that You
92
- meet the following conditions:
93
-
94
- (a) You must give any other recipients of the Work or
95
- Derivative Works a copy of this License; and
96
-
97
- (b) You must cause any modified files to carry prominent notices
98
- stating that You changed the files; and
99
-
100
- (c) You must retain, in the Source form of any Derivative Works
101
- that You distribute, all copyright, patent, trademark, and
102
- attribution notices from the Source form of the Work,
103
- excluding those notices that do not pertain to any part of
104
- the Derivative Works; and
105
-
106
- (d) If the Work includes a "NOTICE" text file as part of its
107
- distribution, then any Derivative Works that You distribute must
108
- include a readable copy of the attribution notices contained
109
- within such NOTICE file, excluding those notices that do not
110
- pertain to any part of the Derivative Works, in at least one
111
- of the following places: within a NOTICE text file distributed
112
- as part of the Derivative Works; within the Source form or
113
- documentation, if provided along with the Derivative Works; or,
114
- within a display generated by the Derivative Works, if and
115
- wherever such third-party notices normally appear. The contents
116
- of the NOTICE file are for informational purposes only and
117
- do not modify the License. You may add Your own attribution
118
- notices within Derivative Works that You distribute, alongside
119
- or as an addendum to the NOTICE text from the Work, provided
120
- that such additional attribution notices cannot be construed
121
- as modifying the License.
122
-
123
- You may add Your own copyright statement to Your modifications and
124
- may provide additional or different license terms and conditions
125
- for use, reproduction, or distribution of Your modifications, or
126
- for any such Derivative Works as a whole, provided Your use,
127
- reproduction, and distribution of the Work otherwise complies with
128
- the conditions stated in this License.
129
-
130
- 5. Submission of Contributions. Unless You explicitly state otherwise,
131
- any Contribution intentionally submitted for inclusion in the Work
132
- by You to the Licensor shall be under the terms and conditions of
133
- this License, without any additional terms or conditions.
134
- Notwithstanding the above, nothing herein shall supersede or modify
135
- the terms of any separate license agreement you may have executed
136
- with Licensor regarding such Contributions.
137
-
138
- 6. Trademarks. This License does not grant permission to use the trade
139
- names, trademarks, service marks, or product names of the Licensor,
140
- except as required for reasonable and customary use in describing the
141
- origin of the Work and reproducing the content of the NOTICE file.
142
-
143
- 7. Disclaimer of Warranty. Unless required by applicable law or
144
- agreed to in writing, Licensor provides the Work (and each
145
- Contributor provides its Contributions) on an "AS IS" BASIS,
146
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
- implied, including, without limitation, any warranties or conditions
148
- of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
- PARTICULAR PURPOSE. You are solely responsible for determining the
150
- appropriateness of using or redistributing the Work and assume any
151
- risks associated with Your exercise of permissions under this License.
152
-
153
- 8. Limitation of Liability. In no event and under no legal theory,
154
- whether in tort (including negligence), contract, or otherwise,
155
- unless required by applicable law (such as deliberate and grossly
156
- negligent acts) or agreed to in writing, shall any Contributor be
157
- liable to You for damages, including any direct, indirect, special,
158
- incidental, or consequential damages of any character arising as a
159
- result of this License or out of the use or inability to use the
160
- Work (including but not limited to damages for loss of goodwill,
161
- work stoppage, computer failure or malfunction, or any and all
162
- other commercial damages or losses), even if such Contributor
163
- has been advised of the possibility of such damages.
164
-
165
- 9. Accepting Warranty or Additional Liability. While redistributing
166
- the Work or Derivative Works thereof, You may choose to offer,
167
- and charge a fee for, acceptance of support, warranty, indemnity,
168
- or other liability obligations and/or rights consistent with this
169
- License. However, in accepting such obligations, You may act only
170
- on Your own behalf and on Your sole responsibility, not on behalf
171
- of any other Contributor, and only if You agree to indemnify,
172
- defend, and hold each Contributor harmless for any liability
173
- incurred by, or claims asserted against, such Contributor by reason
174
- of your accepting any such warranty or additional liability.
175
-
176
- END OF TERMS AND CONDITIONS
177
-
178
- APPENDIX: How to apply the Apache License to your work.
179
-
180
- To apply the Apache License to your work, attach the following
181
- boilerplate notice, with the fields enclosed by brackets "[]"
182
- replaced with your own identifying information. (Don't include
183
- the brackets!) The text should be enclosed in the appropriate
184
- comment syntax for the file format. We also recommend that a
185
- file or class name and description of purpose be included on the
186
- same "printed page" as the copyright notice for easier
187
- identification within third-party archives.
188
-
189
- Copyright 2020 The Backstage Authors
190
-
191
- Licensed under the Apache License, Version 2.0 (the "License");
192
- you may not use this file except in compliance with the License.
193
- You may obtain a copy of the License at
194
-
195
- http://www.apache.org/licenses/LICENSE-2.0
196
-
197
- Unless required by applicable law or agreed to in writing, software
198
- distributed under the License is distributed on an "AS IS" BASIS,
199
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
- See the License for the specific language governing permissions and
201
- limitations under the License.