@superdurable/connector-atlassian-bitbucket 0.0.0-stage → 0.1.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/LICENSE +21 -0
- package/README.md +8 -2
- package/dex-connector.json +87 -0
- package/dist/chunk-WKSBYF2I.js +151 -0
- package/dist/connection-DbC0QPe8.d.ts +147 -0
- package/dist/index.d.ts +171 -0
- package/dist/index.js +327 -0
- package/dist/mock.d.ts +60 -0
- package/dist/mock.js +143 -0
- package/package.json +61 -4
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Super Durable
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,9 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Bitbucket TypeScript connector
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
`@superdurable/connector-atlassian-bitbucket` implements the `listRepositories` and `listPullRequests` read operations as typed Dex Query Steps. It uses the static connection name supplied by the consuming Flow and resolves the workspace access token at call time.
|
|
4
|
+
|
|
5
|
+
The [resource-read example](examples/resource-read/README.md) contains a runnable Worker, Flow starter, and a real Dex Worker/Client integration test. The [connector README](../README.md) describes authorization, configuration, branches, and retry behavior.
|
|
6
|
+
|
|
7
|
+
Error responses are classified by HTTP status even if their bodies cannot be read. A `null` item in a provider `values` array becomes a zero-value repository or pull request, matching the Go connector.
|
|
8
|
+
|
|
9
|
+
Run `npm ci && npm run check` to verify the package. Run `npm run test:integration` with `DEX_FLOW_SERVICE_ADDRESS` set to a running `dexcli dev` server.
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
{
|
|
2
|
+
"connectorId": "bitbucket",
|
|
3
|
+
"releaseTag": "connectors/atlassian/bitbucket/go/v0.2.0",
|
|
4
|
+
"package": {
|
|
5
|
+
"ecosystem": "npm",
|
|
6
|
+
"name": "@superdurable/connector-atlassian-bitbucket",
|
|
7
|
+
"version": "0.1.0"
|
|
8
|
+
},
|
|
9
|
+
"factories": [
|
|
10
|
+
{
|
|
11
|
+
"name": "newListRepositoriesStep",
|
|
12
|
+
"kind": "query",
|
|
13
|
+
"operationId": "listRepositories",
|
|
14
|
+
"fields": {
|
|
15
|
+
"stepType": "stepType",
|
|
16
|
+
"annotations": "annotations",
|
|
17
|
+
"connectionName": "connectionName",
|
|
18
|
+
"resultAttribute": "resultAttribute"
|
|
19
|
+
},
|
|
20
|
+
"branches": [
|
|
21
|
+
{
|
|
22
|
+
"id": "listed",
|
|
23
|
+
"field": "listed",
|
|
24
|
+
"optional": false
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
"id": "notFound",
|
|
28
|
+
"field": "notFound",
|
|
29
|
+
"optional": true
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
"id": "providerRejected",
|
|
33
|
+
"field": "providerRejected",
|
|
34
|
+
"optional": true
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
"id": "invalidResponse",
|
|
38
|
+
"field": "invalidResponse",
|
|
39
|
+
"optional": true
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
"id": "defect",
|
|
43
|
+
"field": "defect",
|
|
44
|
+
"optional": true
|
|
45
|
+
}
|
|
46
|
+
]
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
"name": "newListPullRequestsStep",
|
|
50
|
+
"kind": "query",
|
|
51
|
+
"operationId": "listPullRequests",
|
|
52
|
+
"fields": {
|
|
53
|
+
"stepType": "stepType",
|
|
54
|
+
"annotations": "annotations",
|
|
55
|
+
"connectionName": "connectionName",
|
|
56
|
+
"resultAttribute": "resultAttribute"
|
|
57
|
+
},
|
|
58
|
+
"branches": [
|
|
59
|
+
{
|
|
60
|
+
"id": "listed",
|
|
61
|
+
"field": "listed",
|
|
62
|
+
"optional": false
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
"id": "notFound",
|
|
66
|
+
"field": "notFound",
|
|
67
|
+
"optional": true
|
|
68
|
+
},
|
|
69
|
+
{
|
|
70
|
+
"id": "providerRejected",
|
|
71
|
+
"field": "providerRejected",
|
|
72
|
+
"optional": true
|
|
73
|
+
},
|
|
74
|
+
{
|
|
75
|
+
"id": "invalidResponse",
|
|
76
|
+
"field": "invalidResponse",
|
|
77
|
+
"optional": true
|
|
78
|
+
},
|
|
79
|
+
{
|
|
80
|
+
"id": "defect",
|
|
81
|
+
"field": "defect",
|
|
82
|
+
"optional": true
|
|
83
|
+
}
|
|
84
|
+
]
|
|
85
|
+
}
|
|
86
|
+
]
|
|
87
|
+
}
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
// src/generated/models.ts
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
var ConfigSchema = z.object({
|
|
4
|
+
"baseUrl": z.string().optional(),
|
|
5
|
+
"timeoutMs": z.number().int().optional(),
|
|
6
|
+
"maxResponseBytes": z.number().int().optional()
|
|
7
|
+
});
|
|
8
|
+
var ListRepositoriesInputSchema = z.strictObject({
|
|
9
|
+
"workspace": z.string()
|
|
10
|
+
});
|
|
11
|
+
var RepositorySchema = z.strictObject({
|
|
12
|
+
"uuid": z.string(),
|
|
13
|
+
"name": z.string(),
|
|
14
|
+
"full_name": z.string(),
|
|
15
|
+
"is_private": z.boolean()
|
|
16
|
+
});
|
|
17
|
+
var RepositoryPageSchema = z.strictObject({
|
|
18
|
+
"values": z.array(RepositorySchema).nullable(),
|
|
19
|
+
"next": z.string(),
|
|
20
|
+
"page": z.number().int(),
|
|
21
|
+
"pagelen": z.number().int()
|
|
22
|
+
});
|
|
23
|
+
var ListPullRequestsInputSchema = z.strictObject({
|
|
24
|
+
"workspace": z.string(),
|
|
25
|
+
"repository": z.string()
|
|
26
|
+
});
|
|
27
|
+
var PullRequestSchema = z.strictObject({
|
|
28
|
+
"id": z.number().int(),
|
|
29
|
+
"title": z.string(),
|
|
30
|
+
"state": z.string()
|
|
31
|
+
});
|
|
32
|
+
var PullRequestPageSchema = z.strictObject({
|
|
33
|
+
"values": z.array(PullRequestSchema).nullable(),
|
|
34
|
+
"next": z.string(),
|
|
35
|
+
"page": z.number().int(),
|
|
36
|
+
"pagelen": z.number().int()
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
// src/generated/definitions.ts
|
|
40
|
+
var ConnectorID = "bitbucket";
|
|
41
|
+
var ProviderID = "bitbucket";
|
|
42
|
+
var ListRepositoriesBranch = {
|
|
43
|
+
Listed: "listed",
|
|
44
|
+
NotFound: "notFound",
|
|
45
|
+
ProviderRejected: "providerRejected",
|
|
46
|
+
InvalidResponse: "invalidResponse",
|
|
47
|
+
Defect: "defect"
|
|
48
|
+
};
|
|
49
|
+
var ListRepositoriesBranchListed = ListRepositoriesBranch.Listed;
|
|
50
|
+
var ListRepositoriesBranchNotFound = ListRepositoriesBranch.NotFound;
|
|
51
|
+
var ListRepositoriesBranchProviderRejected = ListRepositoriesBranch.ProviderRejected;
|
|
52
|
+
var ListRepositoriesBranchInvalidResponse = ListRepositoriesBranch.InvalidResponse;
|
|
53
|
+
var ListRepositoriesBranchDefect = ListRepositoriesBranch.Defect;
|
|
54
|
+
var ListRepositoriesDefinition = {
|
|
55
|
+
operation: { connectorId: ConnectorID, operationId: "listRepositories" },
|
|
56
|
+
branches: [
|
|
57
|
+
{ id: "listed", description: "List repositories owned by a Bitbucket workspace." },
|
|
58
|
+
{ id: "notFound", description: "The requested resource was not found.", optional: true },
|
|
59
|
+
{ id: "providerRejected", description: "The provider conclusively rejected the request.", optional: true },
|
|
60
|
+
{ id: "invalidResponse", description: "The provider returned malformed or oversized JSON.", optional: true },
|
|
61
|
+
{ id: "defect", description: "Local input or connection credentials are invalid.", optional: true }
|
|
62
|
+
],
|
|
63
|
+
stepDefaults: { executeMethodTimeoutMs: 3e4, executeDurability: "async" }
|
|
64
|
+
};
|
|
65
|
+
var ListRepositoriesMetadata = { kind: "query", idempotency: "none", authorization: "required" };
|
|
66
|
+
var ListPullRequestsBranch = {
|
|
67
|
+
Listed: "listed",
|
|
68
|
+
NotFound: "notFound",
|
|
69
|
+
ProviderRejected: "providerRejected",
|
|
70
|
+
InvalidResponse: "invalidResponse",
|
|
71
|
+
Defect: "defect"
|
|
72
|
+
};
|
|
73
|
+
var ListPullRequestsBranchListed = ListPullRequestsBranch.Listed;
|
|
74
|
+
var ListPullRequestsBranchNotFound = ListPullRequestsBranch.NotFound;
|
|
75
|
+
var ListPullRequestsBranchProviderRejected = ListPullRequestsBranch.ProviderRejected;
|
|
76
|
+
var ListPullRequestsBranchInvalidResponse = ListPullRequestsBranch.InvalidResponse;
|
|
77
|
+
var ListPullRequestsBranchDefect = ListPullRequestsBranch.Defect;
|
|
78
|
+
var ListPullRequestsDefinition = {
|
|
79
|
+
operation: { connectorId: ConnectorID, operationId: "listPullRequests" },
|
|
80
|
+
branches: [
|
|
81
|
+
{ id: "listed", description: "List pull requests for a Bitbucket repository." },
|
|
82
|
+
{ id: "notFound", description: "The requested resource was not found.", optional: true },
|
|
83
|
+
{ id: "providerRejected", description: "The provider conclusively rejected the request.", optional: true },
|
|
84
|
+
{ id: "invalidResponse", description: "The provider returned malformed or oversized JSON.", optional: true },
|
|
85
|
+
{ id: "defect", description: "Local input or connection credentials are invalid.", optional: true }
|
|
86
|
+
],
|
|
87
|
+
stepDefaults: { executeMethodTimeoutMs: 3e4, executeDurability: "async" }
|
|
88
|
+
};
|
|
89
|
+
var ListPullRequestsMetadata = { kind: "query", idempotency: "none", authorization: "required" };
|
|
90
|
+
|
|
91
|
+
// src/generated/connection.ts
|
|
92
|
+
import { ConnectionRefSchema } from "@superdurable/connectors-sdk";
|
|
93
|
+
var Connection = class {
|
|
94
|
+
/** Stable provider and connection name. */
|
|
95
|
+
reference;
|
|
96
|
+
/** Bound provider operations. */
|
|
97
|
+
operations;
|
|
98
|
+
/** Validate a reference and bind operations. */
|
|
99
|
+
constructor(reference, operations) {
|
|
100
|
+
this.reference = ConnectionRefSchema.parse(reference);
|
|
101
|
+
if (this.reference.provider !== ProviderID) throw new TypeError("connection provider differs from the manifest");
|
|
102
|
+
if (!operations) throw new TypeError("connector operations are required");
|
|
103
|
+
this.operations = operations;
|
|
104
|
+
}
|
|
105
|
+
};
|
|
106
|
+
function newConnection(client, reference) {
|
|
107
|
+
if (!client) throw new TypeError("connector client is required");
|
|
108
|
+
return new Connection(reference, client);
|
|
109
|
+
}
|
|
110
|
+
function newConnectionWithOperations(operations, reference) {
|
|
111
|
+
return new Connection(reference, operations);
|
|
112
|
+
}
|
|
113
|
+
function newProjectConnection(project, connectionName, createClient) {
|
|
114
|
+
if (!project) throw new TypeError("loaded project is required");
|
|
115
|
+
const reference = ConnectionRefSchema.parse({ provider: ProviderID, name: connectionName });
|
|
116
|
+
const selected = project.configuration.connections.find((entry) => entry.connectorId === ConnectorID && entry.connectionName === connectionName);
|
|
117
|
+
if (!selected || selected.provider !== ProviderID) throw new TypeError("project connection is not configured");
|
|
118
|
+
return newConnection(createClient(project, connectionName), reference);
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
export {
|
|
122
|
+
ConfigSchema,
|
|
123
|
+
ListRepositoriesInputSchema,
|
|
124
|
+
RepositorySchema,
|
|
125
|
+
RepositoryPageSchema,
|
|
126
|
+
ListPullRequestsInputSchema,
|
|
127
|
+
PullRequestSchema,
|
|
128
|
+
PullRequestPageSchema,
|
|
129
|
+
ConnectorID,
|
|
130
|
+
ProviderID,
|
|
131
|
+
ListRepositoriesBranch,
|
|
132
|
+
ListRepositoriesBranchListed,
|
|
133
|
+
ListRepositoriesBranchNotFound,
|
|
134
|
+
ListRepositoriesBranchProviderRejected,
|
|
135
|
+
ListRepositoriesBranchInvalidResponse,
|
|
136
|
+
ListRepositoriesBranchDefect,
|
|
137
|
+
ListRepositoriesDefinition,
|
|
138
|
+
ListRepositoriesMetadata,
|
|
139
|
+
ListPullRequestsBranch,
|
|
140
|
+
ListPullRequestsBranchListed,
|
|
141
|
+
ListPullRequestsBranchNotFound,
|
|
142
|
+
ListPullRequestsBranchProviderRejected,
|
|
143
|
+
ListPullRequestsBranchInvalidResponse,
|
|
144
|
+
ListPullRequestsBranchDefect,
|
|
145
|
+
ListPullRequestsDefinition,
|
|
146
|
+
ListPullRequestsMetadata,
|
|
147
|
+
Connection,
|
|
148
|
+
newConnection,
|
|
149
|
+
newConnectionWithOperations,
|
|
150
|
+
newProjectConnection
|
|
151
|
+
};
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
import { SecretString, CredentialProvider, Query, ConnectionRef } from '@superdurable/connectors-sdk';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
|
|
4
|
+
/** Connector configuration; omitted fields use manifest defaults. */
|
|
5
|
+
interface Config {
|
|
6
|
+
/** Fixed provider API URL; blank uses the displayed default. Override only for a compatible gateway or loopback test server. */
|
|
7
|
+
baseUrl?: string;
|
|
8
|
+
/** Maximum duration of one provider HTTP request as a positive Go duration, such as 15s or 1m. Blank uses the displayed default; override for slow network paths. Runtime value in milliseconds. */
|
|
9
|
+
timeoutMs?: number;
|
|
10
|
+
/** Maximum provider JSON response size in bytes as a positive integer. Blank uses the displayed default; raise only for larger result pages. */
|
|
11
|
+
maxResponseBytes?: number;
|
|
12
|
+
}
|
|
13
|
+
/** Runtime schema for manifest configuration. */
|
|
14
|
+
declare const ConfigSchema: z.ZodObject<{
|
|
15
|
+
baseUrl: z.ZodOptional<z.ZodString>;
|
|
16
|
+
timeoutMs: z.ZodOptional<z.ZodNumber>;
|
|
17
|
+
maxResponseBytes: z.ZodOptional<z.ZodNumber>;
|
|
18
|
+
}, z.core.$strip>;
|
|
19
|
+
/** Private connector credentials resolved by the host. */
|
|
20
|
+
interface Credentials {
|
|
21
|
+
/** Secret Bitbucket workspace access token from https://bitbucket.org > workspace Settings > Access tokens > Create access token. Grant Repositories > Read and Pull requests > Read; copy the opaque token once into this secret field. Blank prevents calls. */
|
|
22
|
+
accessToken: SecretString;
|
|
23
|
+
}
|
|
24
|
+
/** Host-owned source of private connector credentials. */
|
|
25
|
+
type CredentialSource = CredentialProvider<Credentials>;
|
|
26
|
+
/** ListRepositoriesInput identifies the workspace whose repositories are read. */
|
|
27
|
+
interface ListRepositoriesInput {
|
|
28
|
+
/** Workspace is the Bitbucket workspace slug. */
|
|
29
|
+
"workspace": string;
|
|
30
|
+
}
|
|
31
|
+
/** Repository is a minimal Bitbucket repository summary. */
|
|
32
|
+
interface Repository {
|
|
33
|
+
/** UUID is the provider repository ID. */
|
|
34
|
+
"uuid": string;
|
|
35
|
+
/** Name is its display name. */
|
|
36
|
+
"name": string;
|
|
37
|
+
/** FullName combines workspace and repository slug. */
|
|
38
|
+
"full_name": string;
|
|
39
|
+
/** IsPrivate reports repository visibility. */
|
|
40
|
+
"is_private": boolean;
|
|
41
|
+
}
|
|
42
|
+
/** RepositoryPage is one Bitbucket repository page. */
|
|
43
|
+
interface RepositoryPage {
|
|
44
|
+
/** Values contains repositories, possibly none. */
|
|
45
|
+
"values": Array<Repository> | null;
|
|
46
|
+
/** Next is the provider's next page URL, if any; applications must treat it as untrusted. */
|
|
47
|
+
"next": string;
|
|
48
|
+
/** Page is the one-based page number. */
|
|
49
|
+
"page": number;
|
|
50
|
+
/** PageLength is the provider page length. */
|
|
51
|
+
"pagelen": number;
|
|
52
|
+
}
|
|
53
|
+
/** ListPullRequestsInput identifies a repository within a workspace. */
|
|
54
|
+
interface ListPullRequestsInput {
|
|
55
|
+
/** Workspace is the Bitbucket workspace slug. */
|
|
56
|
+
"workspace": string;
|
|
57
|
+
/** Repository is the repository slug within the workspace. */
|
|
58
|
+
"repository": string;
|
|
59
|
+
}
|
|
60
|
+
/** PullRequest is a minimal Bitbucket pull request summary. */
|
|
61
|
+
interface PullRequest {
|
|
62
|
+
/** ID is the repository-local numeric pull request ID. */
|
|
63
|
+
"id": number;
|
|
64
|
+
/** Title is the pull request title. */
|
|
65
|
+
"title": string;
|
|
66
|
+
/** State is the provider state such as OPEN. */
|
|
67
|
+
"state": string;
|
|
68
|
+
}
|
|
69
|
+
/** PullRequestPage is one Bitbucket pull request page. */
|
|
70
|
+
interface PullRequestPage {
|
|
71
|
+
/** Values contains pull requests, possibly none. */
|
|
72
|
+
"values": Array<PullRequest> | null;
|
|
73
|
+
/** Next is the provider's next page URL, if any; applications must treat it as untrusted. */
|
|
74
|
+
"next": string;
|
|
75
|
+
/** Page is the one-based page number. */
|
|
76
|
+
"page": number;
|
|
77
|
+
/** PageLength is the provider page length. */
|
|
78
|
+
"pagelen": number;
|
|
79
|
+
}
|
|
80
|
+
/** Runtime validator for ListRepositoriesInput. */
|
|
81
|
+
declare const ListRepositoriesInputSchema: z.ZodObject<{
|
|
82
|
+
workspace: z.ZodString;
|
|
83
|
+
}, z.core.$strict>;
|
|
84
|
+
/** Runtime validator for Repository. */
|
|
85
|
+
declare const RepositorySchema: z.ZodObject<{
|
|
86
|
+
uuid: z.ZodString;
|
|
87
|
+
name: z.ZodString;
|
|
88
|
+
full_name: z.ZodString;
|
|
89
|
+
is_private: z.ZodBoolean;
|
|
90
|
+
}, z.core.$strict>;
|
|
91
|
+
/** Runtime validator for RepositoryPage. */
|
|
92
|
+
declare const RepositoryPageSchema: z.ZodObject<{
|
|
93
|
+
values: z.ZodNullable<z.ZodArray<z.ZodObject<{
|
|
94
|
+
uuid: z.ZodString;
|
|
95
|
+
name: z.ZodString;
|
|
96
|
+
full_name: z.ZodString;
|
|
97
|
+
is_private: z.ZodBoolean;
|
|
98
|
+
}, z.core.$strict>>>;
|
|
99
|
+
next: z.ZodString;
|
|
100
|
+
page: z.ZodNumber;
|
|
101
|
+
pagelen: z.ZodNumber;
|
|
102
|
+
}, z.core.$strict>;
|
|
103
|
+
/** Runtime validator for ListPullRequestsInput. */
|
|
104
|
+
declare const ListPullRequestsInputSchema: z.ZodObject<{
|
|
105
|
+
workspace: z.ZodString;
|
|
106
|
+
repository: z.ZodString;
|
|
107
|
+
}, z.core.$strict>;
|
|
108
|
+
/** Runtime validator for PullRequest. */
|
|
109
|
+
declare const PullRequestSchema: z.ZodObject<{
|
|
110
|
+
id: z.ZodNumber;
|
|
111
|
+
title: z.ZodString;
|
|
112
|
+
state: z.ZodString;
|
|
113
|
+
}, z.core.$strict>;
|
|
114
|
+
/** Runtime validator for PullRequestPage. */
|
|
115
|
+
declare const PullRequestPageSchema: z.ZodObject<{
|
|
116
|
+
values: z.ZodNullable<z.ZodArray<z.ZodObject<{
|
|
117
|
+
id: z.ZodNumber;
|
|
118
|
+
title: z.ZodString;
|
|
119
|
+
state: z.ZodString;
|
|
120
|
+
}, z.core.$strict>>>;
|
|
121
|
+
next: z.ZodString;
|
|
122
|
+
page: z.ZodNumber;
|
|
123
|
+
pagelen: z.ZodNumber;
|
|
124
|
+
}, z.core.$strict>;
|
|
125
|
+
|
|
126
|
+
/** Typed operations supplied by a client or mock. */
|
|
127
|
+
interface Operations {
|
|
128
|
+
/** Invoke listRepositories through this connection. */
|
|
129
|
+
listRepositories(): Query<ListRepositoriesInput, RepositoryPage>;
|
|
130
|
+
/** Invoke listPullRequests through this connection. */
|
|
131
|
+
listPullRequests(): Query<ListPullRequestsInput, PullRequestPage>;
|
|
132
|
+
}
|
|
133
|
+
/** Named connector connection kept outside Flow state. */
|
|
134
|
+
declare class Connection<BoundOperations = Operations> {
|
|
135
|
+
/** Stable provider and connection name. */
|
|
136
|
+
readonly reference: ConnectionRef;
|
|
137
|
+
/** Bound provider operations. */
|
|
138
|
+
readonly operations: BoundOperations;
|
|
139
|
+
/** Validate a reference and bind operations. */
|
|
140
|
+
constructor(reference: ConnectionRef, operations: BoundOperations);
|
|
141
|
+
}
|
|
142
|
+
/** Bind a client to a named connection. */
|
|
143
|
+
declare function newConnection(client: Operations, reference: ConnectionRef): Connection;
|
|
144
|
+
/** Bind scripted operations to a named connection. */
|
|
145
|
+
declare function newConnectionWithOperations(operations: Operations, reference: ConnectionRef): Connection;
|
|
146
|
+
|
|
147
|
+
export { Connection as C, type ListPullRequestsInput as L, type Operations as O, type PullRequestPage as P, type RepositoryPage as R, type ListRepositoriesInput as a, type Config as b, type Credentials as c, ConfigSchema as d, type CredentialSource as e, ListPullRequestsInputSchema as f, ListRepositoriesInputSchema as g, type PullRequest as h, PullRequestPageSchema as i, PullRequestSchema as j, type Repository as k, RepositoryPageSchema as l, RepositorySchema as m, newConnection as n, newConnectionWithOperations as o };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
import { L as ListPullRequestsInput, P as PullRequestPage, C as Connection, a as ListRepositoriesInput, R as RepositoryPage, b as Config, c as Credentials, O as Operations } from './connection-DbC0QPe8.js';
|
|
2
|
+
export { d as ConfigSchema, e as CredentialSource, f as ListPullRequestsInputSchema, g as ListRepositoriesInputSchema, h as PullRequest, i as PullRequestPageSchema, j as PullRequestSchema, k as Repository, l as RepositoryPageSchema, m as RepositorySchema, n as newConnection, o as newConnectionWithOperations } from './connection-DbC0QPe8.js';
|
|
3
|
+
import * as _superdurable_connectors_sdk from '@superdurable/connectors-sdk';
|
|
4
|
+
import { QueryDefinition, QueryStepConfig, Query, QueryResult, QueryStep, Call, QueryAttempt, CredentialProvider, Failure } from '@superdurable/connectors-sdk';
|
|
5
|
+
import { StepTarget } from '@superdurable/dex';
|
|
6
|
+
import { ProviderRequest, ProviderResponse } from '@superdurable/connectors-sdk/providerhttp';
|
|
7
|
+
import { LoadedProject } from '@superdurable/connectors-sdk/projectconfig';
|
|
8
|
+
import 'zod';
|
|
9
|
+
|
|
10
|
+
/** Stable connector identity. */
|
|
11
|
+
declare const ConnectorID = "bitbucket";
|
|
12
|
+
/** Provider identity for named connections. */
|
|
13
|
+
declare const ProviderID = "bitbucket";
|
|
14
|
+
/** Branch IDs for listRepositories. */
|
|
15
|
+
declare const ListRepositoriesBranch: {
|
|
16
|
+
readonly Listed: "listed";
|
|
17
|
+
readonly NotFound: "notFound";
|
|
18
|
+
readonly ProviderRejected: "providerRejected";
|
|
19
|
+
readonly InvalidResponse: "invalidResponse";
|
|
20
|
+
readonly Defect: "defect";
|
|
21
|
+
};
|
|
22
|
+
/** List repositories owned by a Bitbucket workspace. */
|
|
23
|
+
declare const ListRepositoriesBranchListed: "listed";
|
|
24
|
+
/** The requested resource was not found. */
|
|
25
|
+
declare const ListRepositoriesBranchNotFound: "notFound";
|
|
26
|
+
/** The provider conclusively rejected the request. */
|
|
27
|
+
declare const ListRepositoriesBranchProviderRejected: "providerRejected";
|
|
28
|
+
/** The provider returned malformed or oversized JSON. */
|
|
29
|
+
declare const ListRepositoriesBranchInvalidResponse: "invalidResponse";
|
|
30
|
+
/** Local input or connection credentials are invalid. */
|
|
31
|
+
declare const ListRepositoriesBranchDefect: "defect";
|
|
32
|
+
/** Manifest definition for listRepositories. */
|
|
33
|
+
declare const ListRepositoriesDefinition: QueryDefinition;
|
|
34
|
+
/** Manifest metadata for listRepositories. */
|
|
35
|
+
declare const ListRepositoriesMetadata: {
|
|
36
|
+
readonly kind: "query";
|
|
37
|
+
readonly idempotency: "none";
|
|
38
|
+
readonly authorization: "required";
|
|
39
|
+
};
|
|
40
|
+
/** Branch IDs for listPullRequests. */
|
|
41
|
+
declare const ListPullRequestsBranch: {
|
|
42
|
+
readonly Listed: "listed";
|
|
43
|
+
readonly NotFound: "notFound";
|
|
44
|
+
readonly ProviderRejected: "providerRejected";
|
|
45
|
+
readonly InvalidResponse: "invalidResponse";
|
|
46
|
+
readonly Defect: "defect";
|
|
47
|
+
};
|
|
48
|
+
/** List pull requests for a Bitbucket repository. */
|
|
49
|
+
declare const ListPullRequestsBranchListed: "listed";
|
|
50
|
+
/** The requested resource was not found. */
|
|
51
|
+
declare const ListPullRequestsBranchNotFound: "notFound";
|
|
52
|
+
/** The provider conclusively rejected the request. */
|
|
53
|
+
declare const ListPullRequestsBranchProviderRejected: "providerRejected";
|
|
54
|
+
/** The provider returned malformed or oversized JSON. */
|
|
55
|
+
declare const ListPullRequestsBranchInvalidResponse: "invalidResponse";
|
|
56
|
+
/** Local input or connection credentials are invalid. */
|
|
57
|
+
declare const ListPullRequestsBranchDefect: "defect";
|
|
58
|
+
/** Manifest definition for listPullRequests. */
|
|
59
|
+
declare const ListPullRequestsDefinition: QueryDefinition;
|
|
60
|
+
/** Manifest metadata for listPullRequests. */
|
|
61
|
+
declare const ListPullRequestsMetadata: {
|
|
62
|
+
readonly kind: "query";
|
|
63
|
+
readonly idempotency: "none";
|
|
64
|
+
readonly authorization: "required";
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
/** Configuration for the listRepositories connector Step. */
|
|
68
|
+
interface ListRepositoriesStepConfig<StepInput, OperationInput = ListRepositoriesInput, OperationOutput = RepositoryPage> extends Omit<QueryStepConfig<StepInput, OperationInput, OperationOutput>, 'operation' | 'connection' | 'branches'> {
|
|
69
|
+
/** Named connection supplying this operation. */
|
|
70
|
+
connection: Connection<{
|
|
71
|
+
listRepositories(): Query<OperationInput, OperationOutput>;
|
|
72
|
+
}>;
|
|
73
|
+
/** Name matching the bound connection. */
|
|
74
|
+
connectionName: string;
|
|
75
|
+
/** List repositories owned by a Bitbucket workspace. */
|
|
76
|
+
listed: StepTarget<QueryResult<OperationOutput>>;
|
|
77
|
+
/** The requested resource was not found. */
|
|
78
|
+
notFound?: StepTarget<QueryResult<OperationOutput>>;
|
|
79
|
+
/** The provider conclusively rejected the request. */
|
|
80
|
+
providerRejected?: StepTarget<QueryResult<OperationOutput>>;
|
|
81
|
+
/** The provider returned malformed or oversized JSON. */
|
|
82
|
+
invalidResponse?: StepTarget<QueryResult<OperationOutput>>;
|
|
83
|
+
/** Local input or connection credentials are invalid. */
|
|
84
|
+
defect?: StepTarget<QueryResult<OperationOutput>>;
|
|
85
|
+
}
|
|
86
|
+
/** Build the listRepositories Step from a named connection. */
|
|
87
|
+
declare function newListRepositoriesStep<StepInput, OperationInput = ListRepositoriesInput, OperationOutput = RepositoryPage>(configuration: ListRepositoriesStepConfig<StepInput, OperationInput, OperationOutput>): QueryStep<StepInput, OperationInput, OperationOutput>;
|
|
88
|
+
/** Configuration for the listPullRequests connector Step. */
|
|
89
|
+
interface ListPullRequestsStepConfig<StepInput, OperationInput = ListPullRequestsInput, OperationOutput = PullRequestPage> extends Omit<QueryStepConfig<StepInput, OperationInput, OperationOutput>, 'operation' | 'connection' | 'branches'> {
|
|
90
|
+
/** Named connection supplying this operation. */
|
|
91
|
+
connection: Connection<{
|
|
92
|
+
listPullRequests(): Query<OperationInput, OperationOutput>;
|
|
93
|
+
}>;
|
|
94
|
+
/** Name matching the bound connection. */
|
|
95
|
+
connectionName: string;
|
|
96
|
+
/** List pull requests for a Bitbucket repository. */
|
|
97
|
+
listed: StepTarget<QueryResult<OperationOutput>>;
|
|
98
|
+
/** The requested resource was not found. */
|
|
99
|
+
notFound?: StepTarget<QueryResult<OperationOutput>>;
|
|
100
|
+
/** The provider conclusively rejected the request. */
|
|
101
|
+
providerRejected?: StepTarget<QueryResult<OperationOutput>>;
|
|
102
|
+
/** The provider returned malformed or oversized JSON. */
|
|
103
|
+
invalidResponse?: StepTarget<QueryResult<OperationOutput>>;
|
|
104
|
+
/** Local input or connection credentials are invalid. */
|
|
105
|
+
defect?: StepTarget<QueryResult<OperationOutput>>;
|
|
106
|
+
}
|
|
107
|
+
/** Build the listPullRequests Step from a named connection. */
|
|
108
|
+
declare function newListPullRequestsStep<StepInput, OperationInput = ListPullRequestsInput, OperationOutput = PullRequestPage>(configuration: ListPullRequestsStepConfig<StepInput, OperationInput, OperationOutput>): QueryStep<StepInput, OperationInput, OperationOutput>;
|
|
109
|
+
|
|
110
|
+
/** Query that reads one repository page. */
|
|
111
|
+
declare class ListRepositoriesOperation implements Query<ListRepositoriesInput, RepositoryPage> {
|
|
112
|
+
private readonly client;
|
|
113
|
+
/** Bind one Bitbucket client. */ constructor(client: BitbucketClient);
|
|
114
|
+
/** Return the manifest definition. */ definition(): _superdurable_connectors_sdk.QueryDefinition;
|
|
115
|
+
/** Validate the workspace and read one page. */
|
|
116
|
+
invoke(call: Call, input: ListRepositoriesInput): Promise<QueryAttempt<RepositoryPage>>;
|
|
117
|
+
}
|
|
118
|
+
/** Query that reads one pull request page. */
|
|
119
|
+
declare class ListPullRequestsOperation implements Query<ListPullRequestsInput, PullRequestPage> {
|
|
120
|
+
private readonly client;
|
|
121
|
+
/** Bind one Bitbucket client. */ constructor(client: BitbucketClient);
|
|
122
|
+
/** Return the manifest definition. */ definition(): _superdurable_connectors_sdk.QueryDefinition;
|
|
123
|
+
/** Validate both path segments and read one page. */
|
|
124
|
+
invoke(call: Call, input: ListPullRequestsInput): Promise<QueryAttempt<PullRequestPage>>;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
/** Injectable HTTP sender for deterministic Bitbucket provider tests. */
|
|
128
|
+
type BitbucketRequestSender = (request: ProviderRequest) => Promise<ProviderResponse>;
|
|
129
|
+
/** Dependencies for provider tests. */
|
|
130
|
+
interface BitbucketClientOptions {
|
|
131
|
+
/** Sender; defaults to the SDK's bounded, no redirect transport. */
|
|
132
|
+
send?: BitbucketRequestSender;
|
|
133
|
+
/** Clock for Retry-After parsing. */
|
|
134
|
+
now?: () => Date;
|
|
135
|
+
}
|
|
136
|
+
/** One provider exchange classified against the Go connector contract. */
|
|
137
|
+
type ReadResult = {
|
|
138
|
+
response: ProviderResponse;
|
|
139
|
+
} | {
|
|
140
|
+
branch: 'notFound' | 'providerRejected' | 'invalidResponse' | 'defect';
|
|
141
|
+
failure: Failure;
|
|
142
|
+
} | {
|
|
143
|
+
retry: true;
|
|
144
|
+
failure: Failure;
|
|
145
|
+
retryAfterMs: number;
|
|
146
|
+
};
|
|
147
|
+
/** Bitbucket client with immutable settings and call-time credential resolution. */
|
|
148
|
+
declare class BitbucketClient {
|
|
149
|
+
private readonly baseURL;
|
|
150
|
+
private readonly maxResponseBytes;
|
|
151
|
+
private readonly timeoutMs;
|
|
152
|
+
private readonly credentials;
|
|
153
|
+
private readonly send;
|
|
154
|
+
private readonly now;
|
|
155
|
+
/** Validate settings without contacting Bitbucket. */
|
|
156
|
+
constructor(config: Config, credentials: CredentialProvider<Credentials>, options?: BitbucketClientOptions);
|
|
157
|
+
/** Bind the repository listing Query. */
|
|
158
|
+
listRepositories(): ListRepositoriesOperation;
|
|
159
|
+
/** Bind the pull request listing Query. */
|
|
160
|
+
listPullRequests(): ListPullRequestsOperation;
|
|
161
|
+
/** Resolve credentials, send one bounded GET, and classify the exchange. */
|
|
162
|
+
read(call: Call, operation: string, path: string): Promise<ReadResult>;
|
|
163
|
+
private retryAfter;
|
|
164
|
+
private branch;
|
|
165
|
+
private retry;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
/** Open a static Bitbucket connection declared in a Dex project. */
|
|
169
|
+
declare function newProjectConnection(project: LoadedProject, connectionName: string): Connection<Operations>;
|
|
170
|
+
|
|
171
|
+
export { BitbucketClient, type BitbucketClientOptions, type BitbucketRequestSender, Config, Connection, ConnectorID, Credentials, ListPullRequestsBranch, ListPullRequestsBranchDefect, ListPullRequestsBranchInvalidResponse, ListPullRequestsBranchListed, ListPullRequestsBranchNotFound, ListPullRequestsBranchProviderRejected, ListPullRequestsDefinition, ListPullRequestsInput, ListPullRequestsMetadata, ListPullRequestsOperation, type ListPullRequestsStepConfig, ListRepositoriesBranch, ListRepositoriesBranchDefect, ListRepositoriesBranchInvalidResponse, ListRepositoriesBranchListed, ListRepositoriesBranchNotFound, ListRepositoriesBranchProviderRejected, ListRepositoriesDefinition, ListRepositoriesInput, ListRepositoriesMetadata, ListRepositoriesOperation, type ListRepositoriesStepConfig, ProviderID, PullRequestPage, RepositoryPage, newListPullRequestsStep, newListRepositoriesStep, newProjectConnection };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,327 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ConfigSchema,
|
|
3
|
+
Connection,
|
|
4
|
+
ConnectorID,
|
|
5
|
+
ListPullRequestsBranch,
|
|
6
|
+
ListPullRequestsBranchDefect,
|
|
7
|
+
ListPullRequestsBranchInvalidResponse,
|
|
8
|
+
ListPullRequestsBranchListed,
|
|
9
|
+
ListPullRequestsBranchNotFound,
|
|
10
|
+
ListPullRequestsBranchProviderRejected,
|
|
11
|
+
ListPullRequestsDefinition,
|
|
12
|
+
ListPullRequestsInputSchema,
|
|
13
|
+
ListPullRequestsMetadata,
|
|
14
|
+
ListRepositoriesBranch,
|
|
15
|
+
ListRepositoriesBranchDefect,
|
|
16
|
+
ListRepositoriesBranchInvalidResponse,
|
|
17
|
+
ListRepositoriesBranchListed,
|
|
18
|
+
ListRepositoriesBranchNotFound,
|
|
19
|
+
ListRepositoriesBranchProviderRejected,
|
|
20
|
+
ListRepositoriesDefinition,
|
|
21
|
+
ListRepositoriesInputSchema,
|
|
22
|
+
ListRepositoriesMetadata,
|
|
23
|
+
ProviderID,
|
|
24
|
+
PullRequestPageSchema,
|
|
25
|
+
PullRequestSchema,
|
|
26
|
+
RepositoryPageSchema,
|
|
27
|
+
RepositorySchema,
|
|
28
|
+
newConnection,
|
|
29
|
+
newConnectionWithOperations,
|
|
30
|
+
newProjectConnection
|
|
31
|
+
} from "./chunk-WKSBYF2I.js";
|
|
32
|
+
|
|
33
|
+
// src/generated/steps.ts
|
|
34
|
+
import { goToBranch, newQueryStep } from "@superdurable/connectors-sdk";
|
|
35
|
+
function newListRepositoriesStep(configuration) {
|
|
36
|
+
const { connection, connectionName, listed, notFound, providerRejected, invalidResponse, defect, ...stepConfiguration } = configuration;
|
|
37
|
+
if (!connection || connection.reference.name !== connectionName) throw new TypeError("Step connection name differs from the bound connection");
|
|
38
|
+
return newQueryStep({ ...stepConfiguration, operation: connection.operations.listRepositories(), connection: connection.reference, branches: [
|
|
39
|
+
goToBranch("listed", listed),
|
|
40
|
+
...notFound ? [goToBranch("notFound", notFound)] : [],
|
|
41
|
+
...providerRejected ? [goToBranch("providerRejected", providerRejected)] : [],
|
|
42
|
+
...invalidResponse ? [goToBranch("invalidResponse", invalidResponse)] : [],
|
|
43
|
+
...defect ? [goToBranch("defect", defect)] : []
|
|
44
|
+
] });
|
|
45
|
+
}
|
|
46
|
+
function newListPullRequestsStep(configuration) {
|
|
47
|
+
const { connection, connectionName, listed, notFound, providerRejected, invalidResponse, defect, ...stepConfiguration } = configuration;
|
|
48
|
+
if (!connection || connection.reference.name !== connectionName) throw new TypeError("Step connection name differs from the bound connection");
|
|
49
|
+
return newQueryStep({ ...stepConfiguration, operation: connection.operations.listPullRequests(), connection: connection.reference, branches: [
|
|
50
|
+
goToBranch("listed", listed),
|
|
51
|
+
...notFound ? [goToBranch("notFound", notFound)] : [],
|
|
52
|
+
...providerRejected ? [goToBranch("providerRejected", providerRejected)] : [],
|
|
53
|
+
...invalidResponse ? [goToBranch("invalidResponse", invalidResponse)] : [],
|
|
54
|
+
...defect ? [goToBranch("defect", defect)] : []
|
|
55
|
+
] });
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
// src/client.ts
|
|
59
|
+
import { BodyTooLargeError, isHeaderSafeCredential, parseRetryAfter, sendProviderRequest, validateBaseURL } from "@superdurable/connectors-sdk/providerhttp";
|
|
60
|
+
import { SecretString } from "@superdurable/connectors-sdk";
|
|
61
|
+
|
|
62
|
+
// src/operations.ts
|
|
63
|
+
import { newQueryBranch, newQueryRetry } from "@superdurable/connectors-sdk";
|
|
64
|
+
var zeroRepositories = { values: [], next: "", page: 0, pagelen: 0 };
|
|
65
|
+
var zeroPullRequests = { values: [], next: "", page: 0, pagelen: 0 };
|
|
66
|
+
var ListRepositoriesOperation = class {
|
|
67
|
+
/** Bind one Bitbucket client. */
|
|
68
|
+
constructor(client) {
|
|
69
|
+
this.client = client;
|
|
70
|
+
}
|
|
71
|
+
client;
|
|
72
|
+
/** Return the manifest definition. */
|
|
73
|
+
definition() {
|
|
74
|
+
return ListRepositoriesDefinition;
|
|
75
|
+
}
|
|
76
|
+
/** Validate the workspace and read one page. */
|
|
77
|
+
async invoke(call, input) {
|
|
78
|
+
if (!validSegment(input.workspace)) return failed("listRepositories", "defect", "VALIDATION", "workspace must be a path segment", zeroRepositories);
|
|
79
|
+
const result = await this.client.read(call, "listRepositories", `/repositories/${escapePathSegment(input.workspace)}`);
|
|
80
|
+
if (!("response" in result)) return readFailure(result, zeroRepositories);
|
|
81
|
+
try {
|
|
82
|
+
return newQueryBranch("listed", decodeRepositoryPage(result.response.body));
|
|
83
|
+
} catch {
|
|
84
|
+
return failed("listRepositories", "invalidResponse", "PROTOCOL", "provider returned invalid JSON", zeroRepositories);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
};
|
|
88
|
+
var ListPullRequestsOperation = class {
|
|
89
|
+
/** Bind one Bitbucket client. */
|
|
90
|
+
constructor(client) {
|
|
91
|
+
this.client = client;
|
|
92
|
+
}
|
|
93
|
+
client;
|
|
94
|
+
/** Return the manifest definition. */
|
|
95
|
+
definition() {
|
|
96
|
+
return ListPullRequestsDefinition;
|
|
97
|
+
}
|
|
98
|
+
/** Validate both path segments and read one page. */
|
|
99
|
+
async invoke(call, input) {
|
|
100
|
+
if (!validSegment(input.workspace)) return failed("listPullRequests", "defect", "VALIDATION", "workspace must be a path segment", zeroPullRequests);
|
|
101
|
+
if (!validSegment(input.repository)) return failed("listPullRequests", "defect", "VALIDATION", "repository must be a path segment", zeroPullRequests);
|
|
102
|
+
const path = `/repositories/${escapePathSegment(input.workspace)}/${escapePathSegment(input.repository)}/pullrequests`;
|
|
103
|
+
const result = await this.client.read(call, "listPullRequests", path);
|
|
104
|
+
if (!("response" in result)) return readFailure(result, zeroPullRequests);
|
|
105
|
+
try {
|
|
106
|
+
return newQueryBranch("listed", decodePullRequestPage(result.response.body));
|
|
107
|
+
} catch {
|
|
108
|
+
return failed("listPullRequests", "invalidResponse", "PROTOCOL", "provider returned invalid JSON", zeroPullRequests);
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
};
|
|
112
|
+
function validSegment(value) {
|
|
113
|
+
return typeof value === "string" && value !== "" && value !== "." && value !== ".." && !/[/?#]/.test(value) && ![...value].some((character) => character.charCodeAt(0) < 32);
|
|
114
|
+
}
|
|
115
|
+
function escapePathSegment(value) {
|
|
116
|
+
return encodeURIComponent(value).replace(/[!'()*]/g, (character) => `%${character.charCodeAt(0).toString(16).toUpperCase()}`).replace(/%24|%26|%2B|%3D|%3A|%40/gi, (encoded) => String.fromCharCode(Number.parseInt(encoded.slice(1), 16)));
|
|
117
|
+
}
|
|
118
|
+
function readFailure(result, zero) {
|
|
119
|
+
if ("retry" in result) return newQueryRetry(result.failure, result.retryAfterMs);
|
|
120
|
+
return newQueryBranch(result.branch, zero, {}, result.failure);
|
|
121
|
+
}
|
|
122
|
+
function failed(operation, branch, kind, message, zero) {
|
|
123
|
+
return newQueryBranch(branch, zero, {}, { kind, provider: "bitbucket", operation, message });
|
|
124
|
+
}
|
|
125
|
+
function decodePage(body) {
|
|
126
|
+
const value = JSON.parse(Buffer.from(body).toString("utf8"));
|
|
127
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) throw new TypeError("invalid page");
|
|
128
|
+
const page = value;
|
|
129
|
+
if (!Array.isArray(page.values)) throw new TypeError("missing values");
|
|
130
|
+
return page;
|
|
131
|
+
}
|
|
132
|
+
function goString(value) {
|
|
133
|
+
if (value === void 0 || value === null) return "";
|
|
134
|
+
if (typeof value !== "string") throw new TypeError("invalid string");
|
|
135
|
+
return value;
|
|
136
|
+
}
|
|
137
|
+
function goInteger(value) {
|
|
138
|
+
if (value === void 0 || value === null) return 0;
|
|
139
|
+
if (typeof value !== "number" || !Number.isSafeInteger(value)) throw new TypeError("invalid integer");
|
|
140
|
+
return value;
|
|
141
|
+
}
|
|
142
|
+
function goBoolean(value) {
|
|
143
|
+
if (value === void 0 || value === null) return false;
|
|
144
|
+
if (typeof value !== "boolean") throw new TypeError("invalid boolean");
|
|
145
|
+
return value;
|
|
146
|
+
}
|
|
147
|
+
function goObject(value) {
|
|
148
|
+
if (value === null) return {};
|
|
149
|
+
if (typeof value !== "object" || Array.isArray(value)) throw new TypeError("invalid item");
|
|
150
|
+
return value;
|
|
151
|
+
}
|
|
152
|
+
function decodeRepositoryPage(body) {
|
|
153
|
+
const page = decodePage(body);
|
|
154
|
+
return { values: page.values.map((item) => {
|
|
155
|
+
const repository = goObject(item);
|
|
156
|
+
return { uuid: goString(repository.uuid), name: goString(repository.name), full_name: goString(repository.full_name), is_private: goBoolean(repository.is_private) };
|
|
157
|
+
}), next: goString(page.next), page: goInteger(page.page), pagelen: goInteger(page.pagelen) };
|
|
158
|
+
}
|
|
159
|
+
function decodePullRequestPage(body) {
|
|
160
|
+
const page = decodePage(body);
|
|
161
|
+
return { values: page.values.map((item) => {
|
|
162
|
+
const pullRequest = goObject(item);
|
|
163
|
+
return { id: goInteger(pullRequest.id), title: goString(pullRequest.title), state: goString(pullRequest.state) };
|
|
164
|
+
}), next: goString(page.next), page: goInteger(page.page), pagelen: goInteger(page.pagelen) };
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
// src/client.ts
|
|
168
|
+
var defaultBaseURL = "https://api.bitbucket.org/2.0";
|
|
169
|
+
var defaultMaxResponseBytes = 2097152;
|
|
170
|
+
var defaultTimeoutMs = 15e3;
|
|
171
|
+
var BitbucketClient = class {
|
|
172
|
+
baseURL;
|
|
173
|
+
maxResponseBytes;
|
|
174
|
+
timeoutMs;
|
|
175
|
+
credentials;
|
|
176
|
+
send;
|
|
177
|
+
now;
|
|
178
|
+
/** Validate settings without contacting Bitbucket. */
|
|
179
|
+
constructor(config, credentials, options = {}) {
|
|
180
|
+
if (!config || !credentials) throw new TypeError("Bitbucket configuration and credential provider are required");
|
|
181
|
+
this.baseURL = validateBaseURL(config.baseUrl || defaultBaseURL);
|
|
182
|
+
this.maxResponseBytes = config.maxResponseBytes || defaultMaxResponseBytes;
|
|
183
|
+
this.timeoutMs = config.timeoutMs || defaultTimeoutMs;
|
|
184
|
+
if (!Number.isSafeInteger(this.maxResponseBytes) || this.maxResponseBytes <= 0 || !Number.isSafeInteger(this.timeoutMs) || this.timeoutMs <= 0) {
|
|
185
|
+
throw new TypeError("timeout and maxResponseBytes must be positive");
|
|
186
|
+
}
|
|
187
|
+
this.credentials = credentials;
|
|
188
|
+
this.send = options.send ?? sendProviderRequest;
|
|
189
|
+
this.now = options.now ?? (() => /* @__PURE__ */ new Date());
|
|
190
|
+
}
|
|
191
|
+
/** Bind the repository listing Query. */
|
|
192
|
+
listRepositories() {
|
|
193
|
+
return new ListRepositoriesOperation(this);
|
|
194
|
+
}
|
|
195
|
+
/** Bind the pull request listing Query. */
|
|
196
|
+
listPullRequests() {
|
|
197
|
+
return new ListPullRequestsOperation(this);
|
|
198
|
+
}
|
|
199
|
+
/** Resolve credentials, send one bounded GET, and classify the exchange. */
|
|
200
|
+
async read(call, operation, path) {
|
|
201
|
+
let token;
|
|
202
|
+
try {
|
|
203
|
+
const resolved = await this.credentials.resolve(call, call.context.cancellationSignal);
|
|
204
|
+
if (!(resolved.accessToken instanceof SecretString)) throw new TypeError("invalid token");
|
|
205
|
+
token = resolved.accessToken.reveal();
|
|
206
|
+
if (!isHeaderSafeCredential(token)) throw new TypeError("invalid token");
|
|
207
|
+
} catch {
|
|
208
|
+
return this.branch(operation, "defect", "AUTHENTICATION", "Bitbucket credentials are unavailable");
|
|
209
|
+
}
|
|
210
|
+
let response;
|
|
211
|
+
try {
|
|
212
|
+
response = await this.send({
|
|
213
|
+
url: this.baseURL + path,
|
|
214
|
+
method: "GET",
|
|
215
|
+
headers: { Accept: "application/json", Authorization: `Bearer ${token}` },
|
|
216
|
+
maxResponseBytes: this.maxResponseBytes,
|
|
217
|
+
timeoutMs: this.timeoutMs,
|
|
218
|
+
ignoreErrorBodyReadFailure: true,
|
|
219
|
+
addressPolicy: this.baseURL === defaultBaseURL ? "publicHTTPS" : "privateNetworkHTTP",
|
|
220
|
+
signal: call.context.cancellationSignal
|
|
221
|
+
});
|
|
222
|
+
} catch (error) {
|
|
223
|
+
if (error instanceof BodyTooLargeError) {
|
|
224
|
+
if (error.status !== void 0 && error.status !== 200) response = { status: error.status, headers: error.headers ?? {}, body: new Uint8Array() };
|
|
225
|
+
else return this.branch(operation, "invalidResponse", "RESPONSE_TOO_LARGE", "provider response exceeded the configured limit");
|
|
226
|
+
} else return this.retry(operation, "AVAILABILITY", "provider read failed");
|
|
227
|
+
}
|
|
228
|
+
const status = response.status;
|
|
229
|
+
if (status === 429) return this.retry(operation, "RATE_LIMIT", "provider rate limited the read", this.retryAfter(response));
|
|
230
|
+
if (status === 408 || status >= 500) return this.retry(operation, "AVAILABILITY", "provider read is temporarily unavailable", this.retryAfter(response));
|
|
231
|
+
if (status === 404) return this.branch(operation, "notFound", "PROVIDER_REJECTION", "resource was not found");
|
|
232
|
+
if (status === 401) return this.branch(operation, "providerRejected", "AUTHENTICATION", "provider rejected credentials");
|
|
233
|
+
if (status === 403) return this.branch(operation, "providerRejected", "AUTHORIZATION", "provider denied access");
|
|
234
|
+
if (status !== 200) return this.branch(operation, "providerRejected", "PROVIDER_REJECTION", `provider rejected read with HTTP ${status}`);
|
|
235
|
+
return { response };
|
|
236
|
+
}
|
|
237
|
+
retryAfter(response) {
|
|
238
|
+
const value = response.headers["retry-after"];
|
|
239
|
+
return parseRetryAfter(Array.isArray(value) ? value[0] ?? "" : value ?? "", this.now());
|
|
240
|
+
}
|
|
241
|
+
branch(operation, branch, kind, message) {
|
|
242
|
+
return { branch, failure: { kind, provider: "bitbucket", operation, message } };
|
|
243
|
+
}
|
|
244
|
+
retry(operation, kind, message, retryAfterMs = 0) {
|
|
245
|
+
return { retry: true, failure: { kind, provider: "bitbucket", operation, message }, retryAfterMs };
|
|
246
|
+
}
|
|
247
|
+
};
|
|
248
|
+
|
|
249
|
+
// src/project.ts
|
|
250
|
+
import { SecretString as SecretString2 } from "@superdurable/connectors-sdk";
|
|
251
|
+
import { z } from "zod";
|
|
252
|
+
var projectSettingsSchema = z.strictObject({
|
|
253
|
+
baseUrl: z.string().optional(),
|
|
254
|
+
timeout: z.union([z.string(), z.number().int()]).optional(),
|
|
255
|
+
maxResponseBytes: z.number().int().optional()
|
|
256
|
+
});
|
|
257
|
+
function newProjectConnection2(project, connectionName) {
|
|
258
|
+
return newProjectConnection(project, connectionName, (loadedProject, name) => {
|
|
259
|
+
const selected = loadedProject.configuration.connections.find((entry) => entry.connectorId === "bitbucket" && entry.connectionName === name);
|
|
260
|
+
if (!selected) throw new TypeError("Bitbucket project connection is not configured");
|
|
261
|
+
const settings = projectSettingsSchema.parse(selected.configuration);
|
|
262
|
+
const timeoutMs = typeof settings.timeout === "number" ? Math.ceil(settings.timeout / 1e6) : settings.timeout !== void 0 ? parseDurationMilliseconds(settings.timeout) : void 0;
|
|
263
|
+
const config = {
|
|
264
|
+
...settings.baseUrl !== void 0 ? { baseUrl: settings.baseUrl } : {},
|
|
265
|
+
...timeoutMs !== void 0 ? { timeoutMs } : {},
|
|
266
|
+
...settings.maxResponseBytes !== void 0 ? { maxResponseBytes: settings.maxResponseBytes } : {}
|
|
267
|
+
};
|
|
268
|
+
const credentials = {
|
|
269
|
+
async resolve(call, signal) {
|
|
270
|
+
void call;
|
|
271
|
+
const fields = await loadedProject.resolveCredential("bitbucket", name, signal);
|
|
272
|
+
const decoded = z.object({ access_token: z.string().min(1) }).parse(fields);
|
|
273
|
+
return { accessToken: new SecretString2(decoded.access_token) };
|
|
274
|
+
}
|
|
275
|
+
};
|
|
276
|
+
return new BitbucketClient(config, credentials);
|
|
277
|
+
});
|
|
278
|
+
}
|
|
279
|
+
function parseDurationMilliseconds(value) {
|
|
280
|
+
let remaining = value;
|
|
281
|
+
let milliseconds = 0;
|
|
282
|
+
const units = { ns: 1e-6, us: 1e-3, "\xB5s": 1e-3, ms: 1, s: 1e3, m: 6e4, h: 36e5 };
|
|
283
|
+
while (remaining) {
|
|
284
|
+
const component = /^(\d+(?:\.\d+)?)(ns|us|µs|ms|s|m|h)/.exec(remaining);
|
|
285
|
+
if (!component) throw new TypeError("Bitbucket timeout must be a positive Go duration");
|
|
286
|
+
milliseconds += Number(component[1]) * (units[component[2] ?? ""] ?? NaN);
|
|
287
|
+
remaining = remaining.slice(component[0].length);
|
|
288
|
+
}
|
|
289
|
+
if (!Number.isSafeInteger(milliseconds) || milliseconds <= 0) throw new TypeError("Bitbucket timeout must resolve to positive whole milliseconds");
|
|
290
|
+
return milliseconds;
|
|
291
|
+
}
|
|
292
|
+
export {
|
|
293
|
+
BitbucketClient,
|
|
294
|
+
ConfigSchema,
|
|
295
|
+
Connection,
|
|
296
|
+
ConnectorID,
|
|
297
|
+
ListPullRequestsBranch,
|
|
298
|
+
ListPullRequestsBranchDefect,
|
|
299
|
+
ListPullRequestsBranchInvalidResponse,
|
|
300
|
+
ListPullRequestsBranchListed,
|
|
301
|
+
ListPullRequestsBranchNotFound,
|
|
302
|
+
ListPullRequestsBranchProviderRejected,
|
|
303
|
+
ListPullRequestsDefinition,
|
|
304
|
+
ListPullRequestsInputSchema,
|
|
305
|
+
ListPullRequestsMetadata,
|
|
306
|
+
ListPullRequestsOperation,
|
|
307
|
+
ListRepositoriesBranch,
|
|
308
|
+
ListRepositoriesBranchDefect,
|
|
309
|
+
ListRepositoriesBranchInvalidResponse,
|
|
310
|
+
ListRepositoriesBranchListed,
|
|
311
|
+
ListRepositoriesBranchNotFound,
|
|
312
|
+
ListRepositoriesBranchProviderRejected,
|
|
313
|
+
ListRepositoriesDefinition,
|
|
314
|
+
ListRepositoriesInputSchema,
|
|
315
|
+
ListRepositoriesMetadata,
|
|
316
|
+
ListRepositoriesOperation,
|
|
317
|
+
ProviderID,
|
|
318
|
+
PullRequestPageSchema,
|
|
319
|
+
PullRequestSchema,
|
|
320
|
+
RepositoryPageSchema,
|
|
321
|
+
RepositorySchema,
|
|
322
|
+
newConnection,
|
|
323
|
+
newConnectionWithOperations,
|
|
324
|
+
newListPullRequestsStep,
|
|
325
|
+
newListRepositoriesStep,
|
|
326
|
+
newProjectConnection2 as newProjectConnection
|
|
327
|
+
};
|
package/dist/mock.d.ts
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { MockQuery, Case } from '@superdurable/connectors-sdk/connectormock';
|
|
2
|
+
import { Failure } from '@superdurable/connectors-sdk';
|
|
3
|
+
import { O as Operations, C as Connection, a as ListRepositoriesInput, R as RepositoryPage, L as ListPullRequestsInput, P as PullRequestPage, h as PullRequest, k as Repository } from './connection-DbC0QPe8.js';
|
|
4
|
+
import 'zod';
|
|
5
|
+
|
|
6
|
+
/** Go zero value for ListRepositoriesInput in scripted cases. */
|
|
7
|
+
declare const emptyListRepositoriesInput: ListRepositoriesInput;
|
|
8
|
+
/** Go zero value for Repository in scripted cases. */
|
|
9
|
+
declare const emptyRepository: Repository;
|
|
10
|
+
/** Go zero value for RepositoryPage in scripted cases. */
|
|
11
|
+
declare const emptyRepositoryPage: RepositoryPage;
|
|
12
|
+
/** Go zero value for ListPullRequestsInput in scripted cases. */
|
|
13
|
+
declare const emptyListPullRequestsInput: ListPullRequestsInput;
|
|
14
|
+
/** Go zero value for PullRequest in scripted cases. */
|
|
15
|
+
declare const emptyPullRequest: PullRequest;
|
|
16
|
+
/** Go zero value for PullRequestPage in scripted cases. */
|
|
17
|
+
declare const emptyPullRequestPage: PullRequestPage;
|
|
18
|
+
/** Script the listed branch. */
|
|
19
|
+
declare function listRepositoriesListed(value: RepositoryPage, failure?: Failure): Case<RepositoryPage>;
|
|
20
|
+
/** Script the notFound branch. */
|
|
21
|
+
declare function listRepositoriesNotFound(value: RepositoryPage, failure?: Failure): Case<RepositoryPage>;
|
|
22
|
+
/** Script the providerRejected branch. */
|
|
23
|
+
declare function listRepositoriesProviderRejected(value: RepositoryPage, failure?: Failure): Case<RepositoryPage>;
|
|
24
|
+
/** Script the invalidResponse branch. */
|
|
25
|
+
declare function listRepositoriesInvalidResponse(value: RepositoryPage, failure?: Failure): Case<RepositoryPage>;
|
|
26
|
+
/** Script the defect branch. */
|
|
27
|
+
declare function listRepositoriesDefect(value: RepositoryPage, failure?: Failure): Case<RepositoryPage>;
|
|
28
|
+
/** Script a safe retry of listRepositories. */
|
|
29
|
+
declare function listRepositoriesRetry(failure: Failure, retryAfterMs?: number): Case<RepositoryPage>;
|
|
30
|
+
/** Manifest scenario defaultAnswer for listRepositories. */
|
|
31
|
+
declare function listRepositoriesDefaultAnswer(): Case<RepositoryPage>;
|
|
32
|
+
/** Default listRepositories scenario. */
|
|
33
|
+
declare function listRepositoriesDefault(): Case<RepositoryPage>;
|
|
34
|
+
/** Script the listed branch. */
|
|
35
|
+
declare function listPullRequestsListed(value: PullRequestPage, failure?: Failure): Case<PullRequestPage>;
|
|
36
|
+
/** Script the notFound branch. */
|
|
37
|
+
declare function listPullRequestsNotFound(value: PullRequestPage, failure?: Failure): Case<PullRequestPage>;
|
|
38
|
+
/** Script the providerRejected branch. */
|
|
39
|
+
declare function listPullRequestsProviderRejected(value: PullRequestPage, failure?: Failure): Case<PullRequestPage>;
|
|
40
|
+
/** Script the invalidResponse branch. */
|
|
41
|
+
declare function listPullRequestsInvalidResponse(value: PullRequestPage, failure?: Failure): Case<PullRequestPage>;
|
|
42
|
+
/** Script the defect branch. */
|
|
43
|
+
declare function listPullRequestsDefect(value: PullRequestPage, failure?: Failure): Case<PullRequestPage>;
|
|
44
|
+
/** Script a safe retry of listPullRequests. */
|
|
45
|
+
declare function listPullRequestsRetry(failure: Failure, retryAfterMs?: number): Case<PullRequestPage>;
|
|
46
|
+
/** Manifest scenario defaultAnswer for listPullRequests. */
|
|
47
|
+
declare function listPullRequestsDefaultAnswer(): Case<PullRequestPage>;
|
|
48
|
+
/** Default listPullRequests scenario. */
|
|
49
|
+
declare function listPullRequestsDefault(): Case<PullRequestPage>;
|
|
50
|
+
/** Scripted operations and manifest defaults for this connector. */
|
|
51
|
+
declare class GeneratedMock implements Operations {
|
|
52
|
+
#private;
|
|
53
|
+
constructor(connectionName: string);
|
|
54
|
+
connection(): Connection;
|
|
55
|
+
listRepositories(): MockQuery<ListRepositoriesInput, RepositoryPage>;
|
|
56
|
+
listPullRequests(): MockQuery<ListPullRequestsInput, PullRequestPage>;
|
|
57
|
+
assertNoFailures(): void;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
export { GeneratedMock, emptyListPullRequestsInput, emptyListRepositoriesInput, emptyPullRequest, emptyPullRequestPage, emptyRepository, emptyRepositoryPage, listPullRequestsDefault, listPullRequestsDefaultAnswer, listPullRequestsDefect, listPullRequestsInvalidResponse, listPullRequestsListed, listPullRequestsNotFound, listPullRequestsProviderRejected, listPullRequestsRetry, listRepositoriesDefault, listRepositoriesDefaultAnswer, listRepositoriesDefect, listRepositoriesInvalidResponse, listRepositoriesListed, listRepositoriesNotFound, listRepositoriesProviderRejected, listRepositoriesRetry };
|
package/dist/mock.js
ADDED
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ListPullRequestsDefinition,
|
|
3
|
+
ListPullRequestsInputSchema,
|
|
4
|
+
ListRepositoriesDefinition,
|
|
5
|
+
ListRepositoriesInputSchema,
|
|
6
|
+
ProviderID,
|
|
7
|
+
PullRequestPageSchema,
|
|
8
|
+
PullRequestSchema,
|
|
9
|
+
RepositoryPageSchema,
|
|
10
|
+
RepositorySchema,
|
|
11
|
+
newConnectionWithOperations
|
|
12
|
+
} from "./chunk-WKSBYF2I.js";
|
|
13
|
+
|
|
14
|
+
// src/generated/mock.ts
|
|
15
|
+
import { branchCase, retryCase, newQuery } from "@superdurable/connectors-sdk/connectormock";
|
|
16
|
+
var emptyListRepositoriesInput = ListRepositoriesInputSchema.parse({
|
|
17
|
+
"workspace": ""
|
|
18
|
+
});
|
|
19
|
+
var emptyRepository = RepositorySchema.parse({
|
|
20
|
+
"uuid": "",
|
|
21
|
+
"name": "",
|
|
22
|
+
"full_name": "",
|
|
23
|
+
"is_private": false
|
|
24
|
+
});
|
|
25
|
+
var emptyRepositoryPage = RepositoryPageSchema.parse({
|
|
26
|
+
"values": [],
|
|
27
|
+
"next": "",
|
|
28
|
+
"page": 0,
|
|
29
|
+
"pagelen": 0
|
|
30
|
+
});
|
|
31
|
+
var emptyListPullRequestsInput = ListPullRequestsInputSchema.parse({
|
|
32
|
+
"workspace": "",
|
|
33
|
+
"repository": ""
|
|
34
|
+
});
|
|
35
|
+
var emptyPullRequest = PullRequestSchema.parse({
|
|
36
|
+
"id": 0,
|
|
37
|
+
"title": "",
|
|
38
|
+
"state": ""
|
|
39
|
+
});
|
|
40
|
+
var emptyPullRequestPage = PullRequestPageSchema.parse({
|
|
41
|
+
"values": [],
|
|
42
|
+
"next": "",
|
|
43
|
+
"page": 0,
|
|
44
|
+
"pagelen": 0
|
|
45
|
+
});
|
|
46
|
+
function listRepositoriesListed(value, failure) {
|
|
47
|
+
return branchCase("listed", value, failure);
|
|
48
|
+
}
|
|
49
|
+
function listRepositoriesNotFound(value, failure) {
|
|
50
|
+
return branchCase("notFound", value, failure);
|
|
51
|
+
}
|
|
52
|
+
function listRepositoriesProviderRejected(value, failure) {
|
|
53
|
+
return branchCase("providerRejected", value, failure);
|
|
54
|
+
}
|
|
55
|
+
function listRepositoriesInvalidResponse(value, failure) {
|
|
56
|
+
return branchCase("invalidResponse", value, failure);
|
|
57
|
+
}
|
|
58
|
+
function listRepositoriesDefect(value, failure) {
|
|
59
|
+
return branchCase("defect", value, failure);
|
|
60
|
+
}
|
|
61
|
+
function listRepositoriesRetry(failure, retryAfterMs = 0) {
|
|
62
|
+
return retryCase(failure, retryAfterMs);
|
|
63
|
+
}
|
|
64
|
+
function listRepositoriesDefaultAnswer() {
|
|
65
|
+
const value = RepositoryPageSchema.parse({ "next": "", "page": 1, "pagelen": 10, "values": [{ "full_name": "meridian/api", "is_private": true, "name": "Meridian API", "uuid": "{a1b2c3d4-1234-4567-89ab-1234567890ab}" }] });
|
|
66
|
+
return branchCase("listed", value);
|
|
67
|
+
}
|
|
68
|
+
function listRepositoriesDefault() {
|
|
69
|
+
return listRepositoriesDefaultAnswer();
|
|
70
|
+
}
|
|
71
|
+
function listPullRequestsListed(value, failure) {
|
|
72
|
+
return branchCase("listed", value, failure);
|
|
73
|
+
}
|
|
74
|
+
function listPullRequestsNotFound(value, failure) {
|
|
75
|
+
return branchCase("notFound", value, failure);
|
|
76
|
+
}
|
|
77
|
+
function listPullRequestsProviderRejected(value, failure) {
|
|
78
|
+
return branchCase("providerRejected", value, failure);
|
|
79
|
+
}
|
|
80
|
+
function listPullRequestsInvalidResponse(value, failure) {
|
|
81
|
+
return branchCase("invalidResponse", value, failure);
|
|
82
|
+
}
|
|
83
|
+
function listPullRequestsDefect(value, failure) {
|
|
84
|
+
return branchCase("defect", value, failure);
|
|
85
|
+
}
|
|
86
|
+
function listPullRequestsRetry(failure, retryAfterMs = 0) {
|
|
87
|
+
return retryCase(failure, retryAfterMs);
|
|
88
|
+
}
|
|
89
|
+
function listPullRequestsDefaultAnswer() {
|
|
90
|
+
const value = PullRequestPageSchema.parse({ "next": "", "page": 1, "pagelen": 10, "values": [{ "id": 7, "state": "OPEN", "title": "Add client tests" }] });
|
|
91
|
+
return branchCase("listed", value);
|
|
92
|
+
}
|
|
93
|
+
function listPullRequestsDefault() {
|
|
94
|
+
return listPullRequestsDefaultAnswer();
|
|
95
|
+
}
|
|
96
|
+
var GeneratedMock = class {
|
|
97
|
+
#listRepositories;
|
|
98
|
+
#listPullRequests;
|
|
99
|
+
#connection;
|
|
100
|
+
constructor(connectionName) {
|
|
101
|
+
this.#listRepositories = newQuery(ListRepositoriesDefinition).default(listRepositoriesDefault());
|
|
102
|
+
this.#listPullRequests = newQuery(ListPullRequestsDefinition).default(listPullRequestsDefault());
|
|
103
|
+
this.#connection = newConnectionWithOperations(this, { provider: ProviderID, name: connectionName });
|
|
104
|
+
}
|
|
105
|
+
connection() {
|
|
106
|
+
return this.#connection;
|
|
107
|
+
}
|
|
108
|
+
listRepositories() {
|
|
109
|
+
return this.#listRepositories;
|
|
110
|
+
}
|
|
111
|
+
listPullRequests() {
|
|
112
|
+
return this.#listPullRequests;
|
|
113
|
+
}
|
|
114
|
+
assertNoFailures() {
|
|
115
|
+
this.#listRepositories.assertNoFailures();
|
|
116
|
+
this.#listPullRequests.assertNoFailures();
|
|
117
|
+
}
|
|
118
|
+
};
|
|
119
|
+
export {
|
|
120
|
+
GeneratedMock,
|
|
121
|
+
emptyListPullRequestsInput,
|
|
122
|
+
emptyListRepositoriesInput,
|
|
123
|
+
emptyPullRequest,
|
|
124
|
+
emptyPullRequestPage,
|
|
125
|
+
emptyRepository,
|
|
126
|
+
emptyRepositoryPage,
|
|
127
|
+
listPullRequestsDefault,
|
|
128
|
+
listPullRequestsDefaultAnswer,
|
|
129
|
+
listPullRequestsDefect,
|
|
130
|
+
listPullRequestsInvalidResponse,
|
|
131
|
+
listPullRequestsListed,
|
|
132
|
+
listPullRequestsNotFound,
|
|
133
|
+
listPullRequestsProviderRejected,
|
|
134
|
+
listPullRequestsRetry,
|
|
135
|
+
listRepositoriesDefault,
|
|
136
|
+
listRepositoriesDefaultAnswer,
|
|
137
|
+
listRepositoriesDefect,
|
|
138
|
+
listRepositoriesInvalidResponse,
|
|
139
|
+
listRepositoriesListed,
|
|
140
|
+
listRepositoriesNotFound,
|
|
141
|
+
listRepositoriesProviderRejected,
|
|
142
|
+
listRepositoriesRetry
|
|
143
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,63 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@superdurable/connector-atlassian-bitbucket",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"description": "
|
|
6
|
-
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"license": "MIT",
|
|
5
|
+
"description": "Bitbucket read-only operations for Dex Flows",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "git+https://github.com/superdurable/dex-connectors-library.git",
|
|
9
|
+
"directory": "connectors/atlassian/bitbucket/typescript"
|
|
10
|
+
},
|
|
11
|
+
"type": "module",
|
|
12
|
+
"publishConfig": {
|
|
13
|
+
"access": "public",
|
|
14
|
+
"registry": "https://registry.npmjs.org"
|
|
15
|
+
},
|
|
16
|
+
"engines": {
|
|
17
|
+
"node": "^22.0.0 || ^24.0.0"
|
|
18
|
+
},
|
|
19
|
+
"module": "./dist/index.js",
|
|
20
|
+
"types": "./dist/index.d.ts",
|
|
21
|
+
"exports": {
|
|
22
|
+
".": {
|
|
23
|
+
"types": "./dist/index.d.ts",
|
|
24
|
+
"import": "./dist/index.js"
|
|
25
|
+
},
|
|
26
|
+
"./mock": {
|
|
27
|
+
"types": "./dist/mock.d.ts",
|
|
28
|
+
"import": "./dist/mock.js"
|
|
29
|
+
}
|
|
30
|
+
},
|
|
31
|
+
"files": [
|
|
32
|
+
"dist",
|
|
33
|
+
"dex-connector.json",
|
|
34
|
+
"LICENSE",
|
|
35
|
+
"README.md"
|
|
36
|
+
],
|
|
37
|
+
"scripts": {
|
|
38
|
+
"build": "tsup src/index.ts src/mock.ts --format esm --dts --clean",
|
|
39
|
+
"typecheck": "tsc --noEmit",
|
|
40
|
+
"lint": "eslint src test examples",
|
|
41
|
+
"test": "npm run build && vitest run --exclude 'test/integration/**'",
|
|
42
|
+
"test:integration": "npm run build && vitest run test/integration/*.integration.test.ts",
|
|
43
|
+
"check": "npm test && npm run typecheck && npm run lint",
|
|
44
|
+
"example:list": "npm run build && tsx examples/resource-read/main.ts",
|
|
45
|
+
"example:list:start": "npm run build && tsx examples/resource-read/start.ts"
|
|
46
|
+
},
|
|
47
|
+
"dependencies": {
|
|
48
|
+
"@superdurable/connectors-sdk": "0.2.0",
|
|
49
|
+
"@superdurable/dex": ">=1.28.0",
|
|
50
|
+
"zod": "^4.1.0"
|
|
51
|
+
},
|
|
52
|
+
"devDependencies": {
|
|
53
|
+
"@eslint/js": "^9.0.0",
|
|
54
|
+
"@types/node": "^22.0.0",
|
|
55
|
+
"eslint": "^9.0.0",
|
|
56
|
+
"tsup": "^8.0.0",
|
|
57
|
+
"tsx": "^4.23.15",
|
|
58
|
+
"typescript": "^5.9.0",
|
|
59
|
+
"typescript-eslint": "^8.0.0",
|
|
60
|
+
"vitest": "^3.0.0",
|
|
61
|
+
"yaml": "^2.9.1"
|
|
62
|
+
}
|
|
63
|
+
}
|