bitbucket-repository-provider 6.0.11 → 6.0.13

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/README.md CHANGED
@@ -1,5 +1,6 @@
1
1
  [![npm](https://img.shields.io/npm/v/bitbucket-repository-provider.svg)](https://www.npmjs.com/package/bitbucket-repository-provider)
2
2
  [![License](https://img.shields.io/badge/License-BSD%203--Clause-blue.svg)](https://opensource.org/licenses/BSD-3-Clause)
3
+ [![Typed with TypeScript](https://flat.badgen.net/badge/icon/Typed?icon=typescript\&label\&labelColor=blue\&color=555555)](https://typescriptlang.org)
3
4
  [![bundlejs](https://deno.bundlejs.com/?q=bitbucket-repository-provider\&badge=detailed)](https://bundlejs.com/?q=bitbucket-repository-provider)
4
5
  [![downloads](http://img.shields.io/npm/dm/bitbucket-repository-provider.svg?style=flat-square)](https://npmjs.org/package/bitbucket-repository-provider)
5
6
  [![GitHub Issues](https://img.shields.io/github/issues/arlac77/bitbucket-repository-provider.svg?style=flat-square)](https://github.com/arlac77/bitbucket-repository-provider/issues)
package/package.json CHANGED
@@ -1,12 +1,14 @@
1
1
  {
2
2
  "name": "bitbucket-repository-provider",
3
- "version": "6.0.11",
3
+ "version": "6.0.13",
4
4
  "publishConfig": {
5
5
  "access": "public",
6
6
  "provenance": true
7
7
  },
8
8
  "exports": {
9
- ".": "./src/bitbucket-provider.mjs"
9
+ ".": {
10
+ "default": "./src/bitbucket-provider.mjs"
11
+ }
10
12
  },
11
13
  "description": "repository provider for bitbucket",
12
14
  "keywords": [
@@ -22,26 +24,30 @@
22
24
  ],
23
25
  "license": "BSD-2-Clause",
24
26
  "scripts": {
27
+ "prepare": "tsc --allowJs --declaration --emitDeclarationOnly --declarationDir types -t esnext -m esnext --module nodenext --moduleResolution nodenext ./src**/*.mjs",
25
28
  "test": "npm run test:ava",
26
29
  "test:ava": "ava --timeout 4m tests/*-ava.mjs tests/*-ava-node.mjs",
27
30
  "cover": "c8 -x 'tests/**/*' --temp-directory build/tmp ava --timeout 4m tests/*-ava.mjs tests/*-ava-node.mjs && c8 report -r lcov -o build/coverage --temp-directory build/tmp",
28
31
  "docs": "documentation readme --section=API ./src/**/*.mjs",
29
- "lint": "npm run lint:docs",
30
- "lint:docs": "documentation lint ./src/**/*.mjs"
32
+ "lint": "npm run lint:docs && npm run lint:tsc",
33
+ "lint:docs": "documentation lint ./src/**/*.mjs",
34
+ "lint:tsc": "tsc --allowJs --checkJs --noEmit -t esnext -m esnext --module nodenext --moduleResolution nodenext ./src**/*.mjs"
31
35
  },
32
36
  "dependencies": {
33
37
  "content-entry": "^8.0.1",
34
- "fetch-rate-limit-util": "^4.2.0",
38
+ "fetch-rate-limit-util": "^4.2.1",
35
39
  "matching-iterator": "^2.1.3",
36
40
  "one-time-execution-method": "^3.1.1",
37
- "repository-provider": "^35.2.3"
41
+ "repository-provider": "^35.2.8"
38
42
  },
39
43
  "devDependencies": {
44
+ "@types/node": "^20.11.19",
40
45
  "ava": "^6.1.1",
41
46
  "c8": "^9.1.0",
42
47
  "documentation": "^14.0.3",
43
- "repository-provider-test-support": "^3.0.4",
44
- "semantic-release": "^23.0.2"
48
+ "repository-provider-test-support": "^3.0.6",
49
+ "semantic-release": "^23.0.2",
50
+ "typescript": "^5.3.3"
45
51
  },
46
52
  "engines": {
47
53
  "node": ">=20.11.1"
@@ -57,7 +63,8 @@
57
63
  "template": {
58
64
  "inheritFrom": [
59
65
  "arlac77/template-arlac77-github",
60
- "arlac77/template-javascript-component"
66
+ "arlac77/template-javascript-component",
67
+ "arlac77/template-typescript"
61
68
  ]
62
69
  }
63
70
  }
@@ -1,6 +1,11 @@
1
1
  import { replaceWithOneTimeExecutionMethod } from "one-time-execution-method";
2
2
  import { stateActionHandler } from "fetch-rate-limit-util";
3
- import { MultiGroupProvider, url_attribute, secret_attribute, default_attribute } from "repository-provider";
3
+ import {
4
+ MultiGroupProvider,
5
+ url_attribute,
6
+ secret_attribute,
7
+ default_attribute
8
+ } from "repository-provider";
4
9
  import { BitbucketBranch } from "./bitbucket-branch.mjs";
5
10
  import { BitbucketRepositoryGroup } from "./bitbucket-repository-group.mjs";
6
11
  import { BitbucketRepository } from "./bitbucket-repository.mjs";
@@ -77,7 +82,7 @@ export class BitbucketProvider extends MultiGroupProvider {
77
82
  ...secret_attribute,
78
83
  description: "API token",
79
84
  env: "{{instanceIdentifier}}TOKEN",
80
- additionalAttributes: { "authentication.type": "token" },
85
+ additionalAttributes: { "authentication.type": "token" }
81
86
  },
82
87
  "authentication.password": {
83
88
  ...secret_attribute,
@@ -86,7 +91,7 @@ export class BitbucketProvider extends MultiGroupProvider {
86
91
  "{{instanceIdentifier}}APP_PASSWORD",
87
92
  "{{instanceIdentifier}}PASSWORD"
88
93
  ],
89
- additionalAttributes: { "authentication.type": "basic" },
94
+ additionalAttributes: { "authentication.type": "basic" }
90
95
  },
91
96
  "authentication.username": {
92
97
  ...default_attribute,
@@ -105,37 +110,22 @@ export class BitbucketProvider extends MultiGroupProvider {
105
110
  return options["authentication.type"] !== undefined;
106
111
  }
107
112
 
108
- /**
109
- * @return {Class} repository group class used by the Provider
110
- */
111
113
  get repositoryGroupClass() {
112
114
  return BitbucketRepositoryGroup;
113
115
  }
114
116
 
115
- /**
116
- * @return {Class} BitbucketRepository
117
- */
118
117
  get repositoryClass() {
119
118
  return BitbucketRepository;
120
119
  }
121
120
 
122
- /**
123
- * @return {Class} BitbucketBranch
124
- */
125
121
  get branchClass() {
126
122
  return BitbucketBranch;
127
123
  }
128
124
 
129
- /**
130
- * @return {Class} pull request class used by the Provider
131
- */
132
125
  get pullRequestClass() {
133
126
  return BitbucketPullRequest;
134
127
  }
135
128
 
136
- /**
137
- * @return {Class} hook class used by the Provider
138
- */
139
129
  get hookClass() {
140
130
  return BitbucketHook;
141
131
  }
@@ -202,13 +192,10 @@ export class BitbucketProvider extends MultiGroupProvider {
202
192
 
203
193
  options.reporter = (url, ...args) => this.trace(url.toString(), ...args);
204
194
 
205
- return stateActionHandler(
206
- new URL(url, this.api),
207
- {
208
- ...options,
209
- headers
210
- }
211
- );
195
+ return stateActionHandler(new URL(url, this.api), {
196
+ ...options,
197
+ headers
198
+ });
212
199
  }
213
200
 
214
201
  fetchJSON(url, options = {}) {
@@ -1,5 +1,7 @@
1
1
  import {
2
2
  PullRequest,
3
+ Repository,
4
+ Branch,
3
5
  boolean_attribute,
4
6
  count_attribute,
5
7
  default_attribute
@@ -1,4 +1,4 @@
1
- import { RepositoryGroup, uuid_attribute } from "repository-provider";
1
+ import { Repository, RepositoryGroup, uuid_attribute } from "repository-provider";
2
2
 
3
3
  /**
4
4
  *
@@ -1,6 +1,7 @@
1
1
  import { replaceWithOneTimeExecutionMethod } from "one-time-execution-method";
2
2
  import {
3
3
  Repository,
4
+ RepositoryOwner,
4
5
  uuid_attribute,
5
6
  size_attribute,
6
7
  language_attribute,
@@ -9,7 +10,7 @@ import {
9
10
 
10
11
  /**
11
12
  * a repository hosted on bitbucket
12
- * @param {Owner} owner
13
+ * @param {RepositoryOwner} owner
13
14
  * @param {string} name
14
15
  * @param {Object} options
15
16
  * @param {string} [options.api]
@@ -32,7 +33,7 @@ export class BitbucketRepository extends Repository {
32
33
 
33
34
  static get attributMapping() {
34
35
  return {
35
- ...super.attributeMappin,
36
+ ...super.attributeMapping,
36
37
  is_private: "isPrivate",
37
38
  website: "homePageURL"
38
39
  };
@@ -63,7 +64,7 @@ export class BitbucketRepository extends Repository {
63
64
  }
64
65
 
65
66
  /**
66
- * {@link https://developer.atlassian.com/cloud/bitbucket/rest/api-group-repositories/#api-repositories-workspace-repo-slug-put}
67
+ * @link https://developer.atlassian.com/cloud/bitbucket/rest/api-group-repositories/#api-repositories-workspace-repo-slug-put
67
68
  */
68
69
  async update() {
69
70
  return this.provider.fetch(this.api, {
@@ -78,7 +79,7 @@ export class BitbucketRepository extends Repository {
78
79
  }
79
80
 
80
81
  /**
81
- * @{link https://developer.atlassian.com/cloud/bitbucket/rest/api-group-repositories/#api-repositories-workspace-repo-slug-hooks-get}
82
+ * @link https://developer.atlassian.com/cloud/bitbucket/rest/api-group-repositories/#api-repositories-workspace-repo-slug-hooks-get
82
83
  */
83
84
  async initializeHooks() {
84
85
  let url = `${this.api}/hooks`;
@@ -0,0 +1,46 @@
1
+ /**
2
+ * Branch of a bitbucket repository.
3
+ */
4
+ export class BitbucketBranch extends Branch {
5
+ initialize(): Promise<void>;
6
+ hash: any;
7
+ /**
8
+ *
9
+ * @param patterns
10
+ */
11
+ entries(patterns: any): AsyncGenerator<{
12
+ [x: string]: any;
13
+ readonly isCollection: boolean;
14
+ readonly types: string[];
15
+ readonly mode: number;
16
+ } | LazyBufferContentEntry, void, unknown>;
17
+ /**
18
+ * Commit entries
19
+ * @param {string} message commit message
20
+ * @param {ContentEntry[]} updates content to be commited
21
+ * @param {Object} [options]
22
+ * @return {Promise}
23
+ */
24
+ commit(message: string, updates: ContentEntry[], options?: any): Promise<any>;
25
+ get entryClass(): typeof BufferContentEntry;
26
+ }
27
+ import { Branch } from "repository-provider";
28
+ declare const LazyBufferContentEntry_base: {
29
+ new (): {
30
+ [x: string]: any;
31
+ readonly string: string;
32
+ readonly readStream: ReadableStream<any>;
33
+ readonly isEmpty: boolean;
34
+ readonly size: number;
35
+ getReadStream(): Promise<ReadableStream<any>>;
36
+ };
37
+ [x: string]: any;
38
+ };
39
+ declare class LazyBufferContentEntry extends LazyBufferContentEntry_base {
40
+ constructor(name: any, branch: any);
41
+ get buffer(): Promise<Buffer>;
42
+ _buffer(): Promise<Buffer>;
43
+ }
44
+ import { ContentEntry } from "content-entry";
45
+ import { BufferContentEntry } from "content-entry";
46
+ export {};
@@ -0,0 +1,9 @@
1
+ /**
2
+ *
3
+ */
4
+ export class BitbucketHook extends Hook {
5
+ static get attributeMapping(): {
6
+ uuid: string;
7
+ };
8
+ }
9
+ import { Hook } from "repository-provider";
@@ -0,0 +1,48 @@
1
+ /**
2
+ * Provider for bitbucket repositories.
3
+ *
4
+ * Supported name schemes are
5
+ * - https://user:aSecret@bitbucket.org/owner/repo-name.git
6
+ * - git+https://user:aSecret@bitbucket.org/owner/repo-name.git
7
+ * - git@bitbucket.org:owner/repo-name.git
8
+ * - owner/repo-name
9
+ * Known environment variables
10
+ * - BITBUCKET_API api
11
+ * - BITBUCKET_TOKEN api token
12
+ * - BITBUCKET_USERNAME username
13
+ * - BITBUCKET_APP_PASSWORD password
14
+ * - BITBUCKET_PASSWORD password
15
+ * @param {Object} config
16
+ * @param {string} config.url provider scm base
17
+ * @param {string} config.api provider api base
18
+ * @param {Object} config.authentication authentication
19
+ * @param {string} config.authentication.type
20
+ * @param {string} config.authentication.username
21
+ * @param {string} config.authentication.password
22
+ */
23
+ export class BitbucketProvider extends MultiGroupProvider {
24
+ /**
25
+ * Default configuration as given for the cloud privider.
26
+ * @return {Object}
27
+ */
28
+ static get attributes(): any;
29
+ get repositoryGroupClass(): typeof BitbucketRepositoryGroup;
30
+ get repositoryClass(): typeof BitbucketRepository;
31
+ get branchClass(): typeof BitbucketBranch;
32
+ get pullRequestClass(): typeof BitbucketPullRequest;
33
+ get hookClass(): typeof BitbucketHook;
34
+ /**
35
+ * {@link https://developer.atlassian.com/bitbucket/api/2/reference/resource/repositories}
36
+ */
37
+ initializeRepositories(): Promise<void>;
38
+ fetch(url: any, options?: {}): any;
39
+ fetchJSON(url: any, options?: {}): any;
40
+ }
41
+ export default BitbucketProvider;
42
+ import { BitbucketBranch } from "./bitbucket-branch.mjs";
43
+ import { BitbucketRepository } from "./bitbucket-repository.mjs";
44
+ import { BitbucketPullRequest } from "./bitbucket-pull-request.mjs";
45
+ import { BitbucketRepositoryGroup } from "./bitbucket-repository-group.mjs";
46
+ import { BitbucketHook } from "./bitbucket-hook.mjs";
47
+ import { MultiGroupProvider } from "repository-provider";
48
+ export { BitbucketBranch, BitbucketRepository, BitbucketPullRequest, BitbucketRepositoryGroup, BitbucketHook };
@@ -0,0 +1,63 @@
1
+ /**
2
+ * Pull request inside bitbucket
3
+ */
4
+ export class BitbucketPullRequest extends PullRequest {
5
+ static mergeStrategies: Set<string>;
6
+ static get attributes(): {
7
+ state: {
8
+ values: Set<string>;
9
+ writeable: boolean;
10
+ type: string;
11
+ isKey: boolean;
12
+ writable: boolean;
13
+ mandatory: boolean;
14
+ private?: boolean;
15
+ depends?: string;
16
+ additionalAttributes: string[];
17
+ description?: string;
18
+ default?: any;
19
+ set?: Function;
20
+ get?: Function;
21
+ env?: string | string[];
22
+ };
23
+ close_source_branch: import("pacc").AttributeDefinition;
24
+ task_count: import("pacc").AttributeDefinition;
25
+ body: import("pacc").AttributeDefinition;
26
+ title: import("pacc").AttributeDefinition;
27
+ url: import("pacc").AttributeDefinition;
28
+ locked: import("pacc").AttributeDefinition;
29
+ merged: import("pacc").AttributeDefinition;
30
+ draft: import("pacc").AttributeDefinition;
31
+ dry: import("pacc").AttributeDefinition;
32
+ empty: import("pacc").AttributeDefinition;
33
+ id: import("pacc").AttributeDefinition;
34
+ name: import("pacc").AttributeDefinition;
35
+ description: import("pacc").AttributeDefinition;
36
+ };
37
+ /**
38
+ * List all pull request for a given repo.
39
+ * Result will be filtered by source branch, destination branch and states
40
+ * @param {Repository} repository
41
+ * @param {Object} filter
42
+ * @param {Branch} [filter.source]
43
+ * @param {Branch} [filter.destination]
44
+ * @param {Set<string>} [filter.states]
45
+ * @return {AsyncIterator<PullRequest>}
46
+ */
47
+ static list(repository: Repository, filter?: {
48
+ source?: Branch;
49
+ destination?: Branch;
50
+ states?: Set<string>;
51
+ }): AsyncIterator<PullRequest>;
52
+ /**
53
+ * {@link https://developer.atlassian.com/bitbucket/api/2/reference/resource/repositories/%7Busername%7D/%7Brepo_slug%7D/pullrequests#post}
54
+ */
55
+ static open(source: any, destination: any, options: any): Promise<any>;
56
+ /**
57
+ * {@link https://developer.atlassian.com/bitbucket/api/2/reference/resource/repositories/%7Bworkspace%7D/%7Brepo_slug%7D/pullrequests/%7Bpull_request_id%7D/merge}
58
+ */
59
+ _merge(merge_strategy?: string): Promise<any>;
60
+ }
61
+ import { PullRequest } from "repository-provider";
62
+ import { Repository } from "repository-provider";
63
+ import { Branch } from "repository-provider";
@@ -0,0 +1,11 @@
1
+ /**
2
+ *
3
+ */
4
+ export class BitbucketRepositoryGroup extends RepositoryGroup {
5
+ static get attributeMapping(): {
6
+ display_name: string;
7
+ "links.avatar.href": string;
8
+ website: string;
9
+ };
10
+ }
11
+ import { RepositoryGroup } from "repository-provider";
@@ -0,0 +1,88 @@
1
+ /**
2
+ * a repository hosted on bitbucket
3
+ * @param {RepositoryOwner} owner
4
+ * @param {string} name
5
+ * @param {Object} options
6
+ * @param {string} [options.api]
7
+ * @param {string} [options.group]
8
+ *
9
+ * @property {string} api
10
+ * @property {string} group
11
+ * @property {string} user
12
+ */
13
+ export class BitbucketRepository extends Repository {
14
+ static get attributes(): {
15
+ uuid: import("pacc").AttributeDefinition;
16
+ size_attribute: import("pacc").AttributeDefinition;
17
+ language_attribute: import("pacc").AttributeDefinition;
18
+ fork_policy: {
19
+ default: string;
20
+ type: string;
21
+ isKey: boolean;
22
+ writable: boolean;
23
+ mandatory: boolean;
24
+ private?: boolean;
25
+ depends?: string;
26
+ additionalAttributes: string[];
27
+ description?: string;
28
+ set?: Function;
29
+ get?: Function;
30
+ env?: string | string[];
31
+ };
32
+ url: import("pacc").AttributeDefinition;
33
+ defaultBranchName: {
34
+ default: string;
35
+ type: string;
36
+ isKey: boolean;
37
+ writable: boolean;
38
+ mandatory: boolean;
39
+ private?: boolean;
40
+ depends?: string;
41
+ additionalAttributes: string[];
42
+ description?: string;
43
+ set?: Function;
44
+ get?: Function;
45
+ env?: string | string[];
46
+ };
47
+ cloneURL: import("pacc").AttributeDefinition;
48
+ isArchived: import("pacc").AttributeDefinition;
49
+ isLocked: import("pacc").AttributeDefinition;
50
+ isDisabled: import("pacc").AttributeDefinition;
51
+ isTemplate: import("pacc").AttributeDefinition;
52
+ isFork: import("pacc").AttributeDefinition;
53
+ id: import("pacc").AttributeDefinition;
54
+ name: import("pacc").AttributeDefinition;
55
+ description: import("pacc").AttributeDefinition;
56
+ };
57
+ static get attributMapping(): any;
58
+ get user(): any;
59
+ /**
60
+ * @link https://developer.atlassian.com/cloud/bitbucket/rest/api-group-repositories/#api-repositories-workspace-repo-slug-put
61
+ */
62
+ update(): Promise<any>;
63
+ /**
64
+ * @link https://developer.atlassian.com/cloud/bitbucket/rest/api-group-repositories/#api-repositories-workspace-repo-slug-hooks-get
65
+ */
66
+ initializeHooks(): Promise<void>;
67
+ /**
68
+ * {@link https://developer.atlassian.com/cloud/bitbucket/rest/api-group-refs/#api-group-refs}
69
+ */
70
+ initializeBranches(): Promise<void>;
71
+ /**
72
+ * Create a new branch
73
+ * {@link https://developer.atlassian.com/bitbucket/api/2/reference/resource/repositories/%7Busername%7D/%7Brepo_slug%7D/refs/branches?_ga=2.65542446.1034690805.1541022941-164225451.1541022941#post}
74
+ * @param {string} name of the new branch to create
75
+ * @param {BitbucketBranch} from
76
+ * @param {Object} options
77
+ * @param {string} options.message
78
+ */
79
+ createBranch(name: string, from: BitbucketBranch, options: {
80
+ message: string;
81
+ }): Promise<import("repository-provider").Branch>;
82
+ /**
83
+ * {@link https://docs.atlassian.com/bitbucket-server/rest/5.8.0/bitbucket-branch-rest.html#idm45555984542992}
84
+ * {@link https://developer.atlassian.com/bitbucket/api/2/reference/resource/repositories/%7Busername%7D/%7Brepo_slug%7D/refs/branches/%7Bname%7D#delete}
85
+ */
86
+ deleteBranch(name: any): Promise<any>;
87
+ }
88
+ import { Repository } from "repository-provider";