@getunblocked/sdk 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 +211 -0
- package/dist/agents.d.ts +301 -0
- package/dist/agents.d.ts.map +1 -0
- package/dist/agents.js +262 -0
- package/dist/agents.js.map +1 -0
- package/dist/client.d.ts +39 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +76 -0
- package/dist/client.js.map +1 -0
- package/dist/errors.d.ts +70 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +96 -0
- package/dist/errors.js.map +1 -0
- package/dist/http.d.ts +16 -0
- package/dist/http.d.ts.map +1 -0
- package/dist/http.js +222 -0
- package/dist/http.js.map +1 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +7 -0
- package/dist/index.js.map +1 -0
- package/dist/timing.d.ts +9 -0
- package/dist/timing.d.ts.map +1 -0
- package/dist/timing.js +86 -0
- package/dist/timing.js.map +1 -0
- package/dist/types.d.ts +273 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +2 -0
- package/dist/types.js.map +1 -0
- package/dist/version.d.ts +14 -0
- package/dist/version.d.ts.map +1 -0
- package/dist/version.js +22 -0
- package/dist/version.js.map +1 -0
- package/docs/README.md +28 -0
- package/docs/agent-frameworks.md +84 -0
- package/docs/api-design.md +53 -0
- package/docs/authentication.md +71 -0
- package/docs/configuration.md +67 -0
- package/docs/context.md +131 -0
- package/docs/contributing.md +51 -0
- package/docs/errors-and-retries.md +135 -0
- package/docs/getting-started.md +62 -0
- package/docs/low-level-requests.md +72 -0
- package/docs/pagination.md +29 -0
- package/docs/release.md +73 -0
- package/docs/runtime-and-packaging.md +57 -0
- package/docs/typescript.md +102 -0
- package/examples/context-research-tool.ts +10 -0
- package/package.json +51 -0
package/dist/agents.js
ADDED
|
@@ -0,0 +1,262 @@
|
|
|
1
|
+
import { UnblockedClient } from "./client.js";
|
|
2
|
+
export function createUnblockedTools(clientOrOptions = {}) {
|
|
3
|
+
const client = clientOrOptions instanceof UnblockedClient ? clientOrOptions : new UnblockedClient(clientOrOptions);
|
|
4
|
+
return {
|
|
5
|
+
research(input) {
|
|
6
|
+
return client.context.research(input);
|
|
7
|
+
},
|
|
8
|
+
searchCode(input) {
|
|
9
|
+
return client.context.search.code(input);
|
|
10
|
+
},
|
|
11
|
+
searchPrs(input) {
|
|
12
|
+
return client.context.search.prs(input);
|
|
13
|
+
},
|
|
14
|
+
searchIssues(input) {
|
|
15
|
+
return client.context.search.issues(input);
|
|
16
|
+
},
|
|
17
|
+
searchDocumentation(input) {
|
|
18
|
+
return client.context.search.documentation(input);
|
|
19
|
+
},
|
|
20
|
+
searchMessages(input) {
|
|
21
|
+
return client.context.search.messages(input);
|
|
22
|
+
},
|
|
23
|
+
queryIssues(input) {
|
|
24
|
+
return client.context.query.issues(input);
|
|
25
|
+
},
|
|
26
|
+
queryPrs(input) {
|
|
27
|
+
return client.context.query.prs(input);
|
|
28
|
+
},
|
|
29
|
+
getUrls(input) {
|
|
30
|
+
return client.context.get.urls(input);
|
|
31
|
+
},
|
|
32
|
+
getRules(input) {
|
|
33
|
+
return client.context.get.rules(input);
|
|
34
|
+
},
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
const toolCallIdSchema = {
|
|
38
|
+
type: "string",
|
|
39
|
+
description: "Optional identifier correlating this call with the originating tool call.",
|
|
40
|
+
};
|
|
41
|
+
const sessionIdSchema = {
|
|
42
|
+
type: "string",
|
|
43
|
+
description: "Optional session identifier grouping related context calls.",
|
|
44
|
+
};
|
|
45
|
+
export const unblockedToolSchemas = {
|
|
46
|
+
research: {
|
|
47
|
+
description: "Unified multi-source research across all connected context; synthesizes an answer with references.",
|
|
48
|
+
parameters: {
|
|
49
|
+
type: "object",
|
|
50
|
+
properties: {
|
|
51
|
+
query: {
|
|
52
|
+
type: "string",
|
|
53
|
+
description: "The research question to investigate.",
|
|
54
|
+
},
|
|
55
|
+
instruction: {
|
|
56
|
+
type: "string",
|
|
57
|
+
description: "Optional guidance shaping how the research is performed or presented.",
|
|
58
|
+
},
|
|
59
|
+
effort: {
|
|
60
|
+
type: "string",
|
|
61
|
+
enum: ["low", "medium", "high"],
|
|
62
|
+
description: "Effort level: low (quick lookup), medium (normal), high (broad cross-system research).",
|
|
63
|
+
},
|
|
64
|
+
toolCallId: toolCallIdSchema,
|
|
65
|
+
sessionId: sessionIdSchema,
|
|
66
|
+
},
|
|
67
|
+
required: ["query"],
|
|
68
|
+
},
|
|
69
|
+
},
|
|
70
|
+
searchCode: {
|
|
71
|
+
description: "Search the connected codebase for relevant code.",
|
|
72
|
+
parameters: {
|
|
73
|
+
type: "object",
|
|
74
|
+
properties: {
|
|
75
|
+
query: {
|
|
76
|
+
type: "string",
|
|
77
|
+
description: "The code search query.",
|
|
78
|
+
},
|
|
79
|
+
instruction: {
|
|
80
|
+
type: "string",
|
|
81
|
+
description: "Optional guidance shaping how the search is performed or presented.",
|
|
82
|
+
},
|
|
83
|
+
toolCallId: toolCallIdSchema,
|
|
84
|
+
sessionId: sessionIdSchema,
|
|
85
|
+
},
|
|
86
|
+
required: ["query"],
|
|
87
|
+
},
|
|
88
|
+
},
|
|
89
|
+
searchPrs: {
|
|
90
|
+
description: "Search pull requests for relevant changes and discussion.",
|
|
91
|
+
parameters: {
|
|
92
|
+
type: "object",
|
|
93
|
+
properties: {
|
|
94
|
+
query: {
|
|
95
|
+
type: "string",
|
|
96
|
+
description: "The pull request search query.",
|
|
97
|
+
},
|
|
98
|
+
instruction: {
|
|
99
|
+
type: "string",
|
|
100
|
+
description: "Optional guidance shaping how the search is performed or presented.",
|
|
101
|
+
},
|
|
102
|
+
toolCallId: toolCallIdSchema,
|
|
103
|
+
sessionId: sessionIdSchema,
|
|
104
|
+
},
|
|
105
|
+
required: ["query"],
|
|
106
|
+
},
|
|
107
|
+
},
|
|
108
|
+
searchIssues: {
|
|
109
|
+
description: "Search issues for relevant reports and discussion.",
|
|
110
|
+
parameters: {
|
|
111
|
+
type: "object",
|
|
112
|
+
properties: {
|
|
113
|
+
query: {
|
|
114
|
+
type: "string",
|
|
115
|
+
description: "The issue search query.",
|
|
116
|
+
},
|
|
117
|
+
instruction: {
|
|
118
|
+
type: "string",
|
|
119
|
+
description: "Optional guidance shaping how the search is performed or presented.",
|
|
120
|
+
},
|
|
121
|
+
toolCallId: toolCallIdSchema,
|
|
122
|
+
sessionId: sessionIdSchema,
|
|
123
|
+
},
|
|
124
|
+
required: ["query"],
|
|
125
|
+
},
|
|
126
|
+
},
|
|
127
|
+
searchDocumentation: {
|
|
128
|
+
description: "Search connected documentation for relevant content.",
|
|
129
|
+
parameters: {
|
|
130
|
+
type: "object",
|
|
131
|
+
properties: {
|
|
132
|
+
query: {
|
|
133
|
+
type: "string",
|
|
134
|
+
description: "The documentation search query.",
|
|
135
|
+
},
|
|
136
|
+
instruction: {
|
|
137
|
+
type: "string",
|
|
138
|
+
description: "Optional guidance shaping how the search is performed or presented.",
|
|
139
|
+
},
|
|
140
|
+
toolCallId: toolCallIdSchema,
|
|
141
|
+
sessionId: sessionIdSchema,
|
|
142
|
+
},
|
|
143
|
+
required: ["query"],
|
|
144
|
+
},
|
|
145
|
+
},
|
|
146
|
+
searchMessages: {
|
|
147
|
+
description: "Search connected messages and conversations for relevant discussion.",
|
|
148
|
+
parameters: {
|
|
149
|
+
type: "object",
|
|
150
|
+
properties: {
|
|
151
|
+
query: {
|
|
152
|
+
type: "string",
|
|
153
|
+
description: "The message search query.",
|
|
154
|
+
},
|
|
155
|
+
instruction: {
|
|
156
|
+
type: "string",
|
|
157
|
+
description: "Optional guidance shaping how the search is performed or presented.",
|
|
158
|
+
},
|
|
159
|
+
toolCallId: toolCallIdSchema,
|
|
160
|
+
sessionId: sessionIdSchema,
|
|
161
|
+
},
|
|
162
|
+
required: ["query"],
|
|
163
|
+
},
|
|
164
|
+
},
|
|
165
|
+
queryIssues: {
|
|
166
|
+
description: "Query issues by natural-language query, optionally scoped by projects and/or user.",
|
|
167
|
+
parameters: {
|
|
168
|
+
type: "object",
|
|
169
|
+
properties: {
|
|
170
|
+
query: {
|
|
171
|
+
type: "string",
|
|
172
|
+
description: "The issue query.",
|
|
173
|
+
},
|
|
174
|
+
projects: {
|
|
175
|
+
type: "array",
|
|
176
|
+
items: { type: "string" },
|
|
177
|
+
description: "Optional list of projects to scope the query to.",
|
|
178
|
+
},
|
|
179
|
+
user_name: {
|
|
180
|
+
type: "string",
|
|
181
|
+
description: "Optional user name to scope the query to.",
|
|
182
|
+
},
|
|
183
|
+
toolCallId: toolCallIdSchema,
|
|
184
|
+
sessionId: sessionIdSchema,
|
|
185
|
+
},
|
|
186
|
+
required: ["query"],
|
|
187
|
+
},
|
|
188
|
+
},
|
|
189
|
+
queryPrs: {
|
|
190
|
+
description: "Query pull requests by natural-language query, optionally scoped by projects and/or user.",
|
|
191
|
+
parameters: {
|
|
192
|
+
type: "object",
|
|
193
|
+
properties: {
|
|
194
|
+
query: {
|
|
195
|
+
type: "string",
|
|
196
|
+
description: "The pull request query.",
|
|
197
|
+
},
|
|
198
|
+
projects: {
|
|
199
|
+
type: "array",
|
|
200
|
+
items: { type: "string" },
|
|
201
|
+
description: "Optional list of projects to scope the query to.",
|
|
202
|
+
},
|
|
203
|
+
user_name: {
|
|
204
|
+
type: "string",
|
|
205
|
+
description: "Optional user name to scope the query to.",
|
|
206
|
+
},
|
|
207
|
+
toolCallId: toolCallIdSchema,
|
|
208
|
+
sessionId: sessionIdSchema,
|
|
209
|
+
},
|
|
210
|
+
required: ["query"],
|
|
211
|
+
},
|
|
212
|
+
},
|
|
213
|
+
getUrls: {
|
|
214
|
+
description: "Fetch and summarize the content of specific URLs.",
|
|
215
|
+
parameters: {
|
|
216
|
+
type: "object",
|
|
217
|
+
properties: {
|
|
218
|
+
urls: {
|
|
219
|
+
type: "array",
|
|
220
|
+
items: { type: "string" },
|
|
221
|
+
description: "The URLs to fetch content for.",
|
|
222
|
+
},
|
|
223
|
+
toolCallId: toolCallIdSchema,
|
|
224
|
+
sessionId: sessionIdSchema,
|
|
225
|
+
},
|
|
226
|
+
required: ["urls"],
|
|
227
|
+
},
|
|
228
|
+
},
|
|
229
|
+
getRules: {
|
|
230
|
+
description: "Get the coding rules and conventions for a repository, optionally scoped by task, language, and paths.",
|
|
231
|
+
parameters: {
|
|
232
|
+
type: "object",
|
|
233
|
+
properties: {
|
|
234
|
+
repoName: {
|
|
235
|
+
type: "string",
|
|
236
|
+
description: "The repository to fetch rules for.",
|
|
237
|
+
},
|
|
238
|
+
ruleId: {
|
|
239
|
+
type: "string",
|
|
240
|
+
description: "Optional specific rule identifier to fetch.",
|
|
241
|
+
},
|
|
242
|
+
task: {
|
|
243
|
+
type: "string",
|
|
244
|
+
description: "Optional task description to scope the rules lookup to.",
|
|
245
|
+
},
|
|
246
|
+
language: {
|
|
247
|
+
type: "string",
|
|
248
|
+
description: "Optional programming language to scope the rules lookup to.",
|
|
249
|
+
},
|
|
250
|
+
paths: {
|
|
251
|
+
type: "array",
|
|
252
|
+
items: { type: "string" },
|
|
253
|
+
description: "Optional file paths to scope the rules lookup to.",
|
|
254
|
+
},
|
|
255
|
+
toolCallId: toolCallIdSchema,
|
|
256
|
+
sessionId: sessionIdSchema,
|
|
257
|
+
},
|
|
258
|
+
required: ["repoName"],
|
|
259
|
+
},
|
|
260
|
+
},
|
|
261
|
+
};
|
|
262
|
+
//# sourceMappingURL=agents.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agents.js","sourceRoot":"","sources":["../src/agents.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AA4B9C,MAAM,UAAU,oBAAoB,CAAC,kBAA4D,EAAE;IACjG,MAAM,MAAM,GAAG,eAAe,YAAY,eAAe,CAAC,CAAC,CAAC,eAAe,CAAC,CAAC,CAAC,IAAI,eAAe,CAAC,eAAe,CAAC,CAAC;IAEnH,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gB;gBAC5B,SAAS,EAAE,eAAe;aAC3B;YACD,QAAQ,EAAE,CAAC,MAAM,CAAC;SACnB;KACF;IACD,QAAQ,EAAE;QACR,WAAW,EAAE,wGAAwG;QACrH,UAAU,EAAE;YACV,IAAI,EAAE,QAAQ;YACd,UAAU,EAAE;gBACV,QAAQ,EAAE;oBACR,IAAI,EAAE,QAAQ;oBACd,WAAW,EAAE,oCAAoC;iBAClD;gBACD,MAAM,EAAE;oBACN,IAAI,EAAE,QAAQ;oBACd,WAAW,EAAE,6CAA6C;iBAC3D;gBACD,IAAI,EAAE;oBACJ,IAAI,EAAE,QAAQ;oBACd,WAAW,EAAE,yDAAyD;iBACvE;gBACD,QAAQ,EAAE;oBACR,IAAI,EAAE,QAAQ;oBACd,WAAW,EAAE,6DAA6D;iBAC3E;gBACD,KAAK,EAAE;oBACL,IAAI,EAAE,OAAO;oBACb,KAAK,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;oBACzB,WAAW,EAAE,mDAAmD;iBACjE;gBACD,UAAU,EAAE,gBAAgB;gBAC5B,SAAS,EAAE,eAAe;aAC3B;YACD,QAAQ,EAAE,CAAC,UAAU,CAAC;SACvB;KACF;CACO,CAAC"}
|
package/dist/client.d.ts
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { HttpClient } from "./http.js";
|
|
2
|
+
import type { ContextGetResponse, ContextGetRulesRequest, ContextGetUrlsRequest, ContextQueryIssuesRequest, ContextQueryPrsRequest, ContextQueryResponse, ContextResearchRequest, ContextResearchResponse, ContextSearchRequest, ContextSearchResponse, HttpMethod, JsonRequestOptions, RawResponse, RequestOptions, UnblockedClientOptions } from "./types.js";
|
|
3
|
+
export declare class UnblockedClient {
|
|
4
|
+
readonly context: ContextResource;
|
|
5
|
+
private readonly http;
|
|
6
|
+
constructor(options?: UnblockedClientOptions);
|
|
7
|
+
request<T>(method: HttpMethod, path: string, options?: JsonRequestOptions): Promise<T>;
|
|
8
|
+
requestRaw<T>(method: HttpMethod, path: string, options?: JsonRequestOptions): Promise<RawResponse<T>>;
|
|
9
|
+
}
|
|
10
|
+
export declare class ContextResource {
|
|
11
|
+
private readonly http;
|
|
12
|
+
readonly search: ContextSearchResource;
|
|
13
|
+
readonly query: ContextQueryResource;
|
|
14
|
+
readonly get: ContextGetResource;
|
|
15
|
+
constructor(http: HttpClient);
|
|
16
|
+
research(request: ContextResearchRequest, options?: RequestOptions): Promise<ContextResearchResponse>;
|
|
17
|
+
}
|
|
18
|
+
export declare class ContextSearchResource {
|
|
19
|
+
private readonly http;
|
|
20
|
+
constructor(http: HttpClient);
|
|
21
|
+
code(request: ContextSearchRequest, options?: RequestOptions): Promise<ContextSearchResponse>;
|
|
22
|
+
prs(request: ContextSearchRequest, options?: RequestOptions): Promise<ContextSearchResponse>;
|
|
23
|
+
documentation(request: ContextSearchRequest, options?: RequestOptions): Promise<ContextSearchResponse>;
|
|
24
|
+
issues(request: ContextSearchRequest, options?: RequestOptions): Promise<ContextSearchResponse>;
|
|
25
|
+
messages(request: ContextSearchRequest, options?: RequestOptions): Promise<ContextSearchResponse>;
|
|
26
|
+
}
|
|
27
|
+
export declare class ContextQueryResource {
|
|
28
|
+
private readonly http;
|
|
29
|
+
constructor(http: HttpClient);
|
|
30
|
+
issues(request: ContextQueryIssuesRequest, options?: RequestOptions): Promise<ContextQueryResponse>;
|
|
31
|
+
prs(request: ContextQueryPrsRequest, options?: RequestOptions): Promise<ContextQueryResponse>;
|
|
32
|
+
}
|
|
33
|
+
export declare class ContextGetResource {
|
|
34
|
+
private readonly http;
|
|
35
|
+
constructor(http: HttpClient);
|
|
36
|
+
urls(request: ContextGetUrlsRequest, options?: RequestOptions): Promise<ContextGetResponse>;
|
|
37
|
+
rules(request: ContextGetRulesRequest, options?: RequestOptions): Promise<ContextGetResponse>;
|
|
38
|
+
}
|
|
39
|
+
//# sourceMappingURL=client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":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Client(options);
|
|
7
|
+
this.context = new ContextResource(this.http);
|
|
8
|
+
}
|
|
9
|
+
request(method, path, options) {
|
|
10
|
+
return this.http.request(method, path, options);
|
|
11
|
+
}
|
|
12
|
+
requestRaw(method, path, options) {
|
|
13
|
+
return this.http.requestRaw(method, path, options);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
export class ContextResource {
|
|
17
|
+
http;
|
|
18
|
+
search;
|
|
19
|
+
query;
|
|
20
|
+
get;
|
|
21
|
+
constructor(http) {
|
|
22
|
+
this.http = http;
|
|
23
|
+
this.search = new ContextSearchResource(http);
|
|
24
|
+
this.query = new ContextQueryResource(http);
|
|
25
|
+
this.get = new ContextGetResource(http);
|
|
26
|
+
}
|
|
27
|
+
research(request, options) {
|
|
28
|
+
return this.http.request("POST", "/tools/context/research", { ...options, body: request });
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
export class ContextSearchResource {
|
|
32
|
+
http;
|
|
33
|
+
constructor(http) {
|
|
34
|
+
this.http = http;
|
|
35
|
+
}
|
|
36
|
+
code(request, options) {
|
|
37
|
+
return this.http.request("POST", "/tools/context/search/code", { ...options, body: request });
|
|
38
|
+
}
|
|
39
|
+
prs(request, options) {
|
|
40
|
+
return this.http.request("POST", "/tools/context/search/prs", { ...options, body: request });
|
|
41
|
+
}
|
|
42
|
+
documentation(request, options) {
|
|
43
|
+
return this.http.request("POST", "/tools/context/search/documentation", { ...options, body: request });
|
|
44
|
+
}
|
|
45
|
+
issues(request, options) {
|
|
46
|
+
return this.http.request("POST", "/tools/context/search/issues", { ...options, body: request });
|
|
47
|
+
}
|
|
48
|
+
messages(request, options) {
|
|
49
|
+
return this.http.request("POST", "/tools/context/search/messages", { ...options, body: request });
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
export class ContextQueryResource {
|
|
53
|
+
http;
|
|
54
|
+
constructor(http) {
|
|
55
|
+
this.http = http;
|
|
56
|
+
}
|
|
57
|
+
issues(request, options) {
|
|
58
|
+
return this.http.request("POST", "/tools/context/query/issues", { ...options, body: request });
|
|
59
|
+
}
|
|
60
|
+
prs(request, options) {
|
|
61
|
+
return this.http.request("POST", "/tools/context/query/prs", { ...options, body: request });
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
export class ContextGetResource {
|
|
65
|
+
http;
|
|
66
|
+
constructor(http) {
|
|
67
|
+
this.http = http;
|
|
68
|
+
}
|
|
69
|
+
urls(request, options) {
|
|
70
|
+
return this.http.request("POST", "/tools/context/get/urls", { ...options, body: request });
|
|
71
|
+
}
|
|
72
|
+
rules(request, options) {
|
|
73
|
+
return this.http.request("POST", "/tools/context/get/rules", { ...options, body: request });
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
//# sourceMappingURL=client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAmBvC,MAAM,OAAO,eAAe;IACjB,OAAO,CAAkB;IACjB,IAAI,CAAa;IAElC,YAAY,UAAkC,EAAE;QAC9C,IAAI,CAAC,IAAI,GAAG,IAAI,UAAU,CAAC,OAAO,CAAC,CAAC;QACpC,IAAI,CAAC,OAAO,GAAG,IAAI,eAAe,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAChD,CAAC;IAED,OAAO,CAAI,MAAkB,EAAE,IAAY,EAAE,OAA4B;QACvE,OAAO,IAAI,CAAC,IAAI,CAAC,OAAO,CAAI,MAAM,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC;IACrD,CAAC;IAED,UAAU,CAAI,MAAkB,EAAE,IAAY,EAAE,OAA4B;QAC1E,OAAO,IAAI,CAAC,IAAI,CAAC,UAAU,CAAI,MAAM,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC;IACxD,CAAC;CACF;AAED,MAAM,OAAO,eAAe;IAKG;IAJpB,MAAM,CAAwB;IAC9B,KA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CAAC;IAClH,CAAC;CACF"}
|
package/dist/errors.d.ts
ADDED
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shape of the JSON body the Unblocked API returns on non-2xx responses
|
|
3
|
+
* (the `ApiError` schema). Only `status` is guaranteed to be present.
|
|
4
|
+
*/
|
|
5
|
+
export interface ApiErrorBody {
|
|
6
|
+
status: number;
|
|
7
|
+
title?: string;
|
|
8
|
+
detail?: string;
|
|
9
|
+
url?: string;
|
|
10
|
+
urlLabel?: string;
|
|
11
|
+
cause?: unknown;
|
|
12
|
+
}
|
|
13
|
+
export interface UnblockedApiErrorOptions {
|
|
14
|
+
status: number;
|
|
15
|
+
statusText: string;
|
|
16
|
+
url: string;
|
|
17
|
+
method: string;
|
|
18
|
+
body: unknown;
|
|
19
|
+
headers: Headers;
|
|
20
|
+
requestId: string | undefined;
|
|
21
|
+
}
|
|
22
|
+
export declare class UnblockedApiError extends Error {
|
|
23
|
+
readonly name: string;
|
|
24
|
+
readonly status: number;
|
|
25
|
+
readonly statusText: string;
|
|
26
|
+
readonly url: string;
|
|
27
|
+
readonly method: string;
|
|
28
|
+
readonly body: unknown;
|
|
29
|
+
readonly headers: Headers;
|
|
30
|
+
/**
|
|
31
|
+
* Value of the `X-Request-ID` response header. Include this when reporting
|
|
32
|
+
* an issue to Unblocked support so the request can be traced.
|
|
33
|
+
*/
|
|
34
|
+
readonly requestId: string | undefined;
|
|
35
|
+
constructor(options: UnblockedApiErrorOptions);
|
|
36
|
+
}
|
|
37
|
+
/** 400 — invalid or missing request fields. */
|
|
38
|
+
export declare class UnblockedBadRequestError extends UnblockedApiError {
|
|
39
|
+
readonly name = "UnblockedBadRequestError";
|
|
40
|
+
}
|
|
41
|
+
/** 401 — invalid or missing API token. */
|
|
42
|
+
export declare class UnblockedAuthenticationError extends UnblockedApiError {
|
|
43
|
+
readonly name = "UnblockedAuthenticationError";
|
|
44
|
+
}
|
|
45
|
+
/** 403 — the token lacks access (e.g. the plan or workspace does not include the requested context tools). */
|
|
46
|
+
export declare class UnblockedPermissionDeniedError extends UnblockedApiError {
|
|
47
|
+
readonly name = "UnblockedPermissionDeniedError";
|
|
48
|
+
}
|
|
49
|
+
/** 404 — the requested resource does not exist. */
|
|
50
|
+
export declare class UnblockedNotFoundError extends UnblockedApiError {
|
|
51
|
+
readonly name = "UnblockedNotFoundError";
|
|
52
|
+
}
|
|
53
|
+
/** 429 — a rate limit or daily quota was exceeded. */
|
|
54
|
+
export declare class UnblockedRateLimitError extends UnblockedApiError {
|
|
55
|
+
readonly name = "UnblockedRateLimitError";
|
|
56
|
+
}
|
|
57
|
+
/** 5xx — the API failed to process the request. */
|
|
58
|
+
export declare class UnblockedServerError extends UnblockedApiError {
|
|
59
|
+
readonly name = "UnblockedServerError";
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Constructs the most specific `UnblockedApiError` subclass for a response
|
|
63
|
+
* status. Unmapped statuses fall back to the base `UnblockedApiError`.
|
|
64
|
+
*/
|
|
65
|
+
export declare function createApiError(options: UnblockedApiErrorOptions): UnblockedApiError;
|
|
66
|
+
export declare class UnblockedTimeoutError extends Error {
|
|
67
|
+
readonly name = "UnblockedTimeoutError";
|
|
68
|
+
constructor(resource: string, timeoutMs: number);
|
|
69
|
+
}
|
|
70
|
+
//# sourceMappingURL=errors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,WAAW,YAAY;IAC3B,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB;AAED,MAAM,WAAW,wBAAwB;IACvC,MAAM,EAAE,MAA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BAAiB,CAiBnF;AAwBD,qBAAa,qBAAsB,SAAQ,KAAK;IAC9C,QAAQ,CAAC,IAAI,2BAA2B;gBAE5B,QAAQ,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM;CAGhD"}
|
package/dist/errors.js
ADDED
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
export class UnblockedApiError extends Error {
|
|
2
|
+
name = "UnblockedApiError";
|
|
3
|
+
status;
|
|
4
|
+
statusText;
|
|
5
|
+
url;
|
|
6
|
+
method;
|
|
7
|
+
body;
|
|
8
|
+
headers;
|
|
9
|
+
/**
|
|
10
|
+
* Value of the `X-Request-ID` response header. Include this when reporting
|
|
11
|
+
* an issue to Unblocked support so the request can be traced.
|
|
12
|
+
*/
|
|
13
|
+
requestId;
|
|
14
|
+
constructor(options) {
|
|
15
|
+
super(buildApiErrorMessage(options));
|
|
16
|
+
this.status = options.status;
|
|
17
|
+
this.statusText = options.statusText;
|
|
18
|
+
this.url = options.url;
|
|
19
|
+
this.method = options.method;
|
|
20
|
+
this.body = options.body;
|
|
21
|
+
this.headers = options.headers;
|
|
22
|
+
this.requestId = options.requestId;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
/** 400 — invalid or missing request fields. */
|
|
26
|
+
export class UnblockedBadRequestError extends UnblockedApiError {
|
|
27
|
+
name = "UnblockedBadRequestError";
|
|
28
|
+
}
|
|
29
|
+
/** 401 — invalid or missing API token. */
|
|
30
|
+
export class UnblockedAuthenticationError extends UnblockedApiError {
|
|
31
|
+
name = "UnblockedAuthenticationError";
|
|
32
|
+
}
|
|
33
|
+
/** 403 — the token lacks access (e.g. the plan or workspace does not include the requested context tools). */
|
|
34
|
+
export class UnblockedPermissionDeniedError extends UnblockedApiError {
|
|
35
|
+
name = "UnblockedPermissionDeniedError";
|
|
36
|
+
}
|
|
37
|
+
/** 404 — the requested resource does not exist. */
|
|
38
|
+
export class UnblockedNotFoundError extends UnblockedApiError {
|
|
39
|
+
name = "UnblockedNotFoundError";
|
|
40
|
+
}
|
|
41
|
+
/** 429 — a rate limit or daily quota was exceeded. */
|
|
42
|
+
export class UnblockedRateLimitError extends UnblockedApiError {
|
|
43
|
+
name = "UnblockedRateLimitError";
|
|
44
|
+
}
|
|
45
|
+
/** 5xx — the API failed to process the request. */
|
|
46
|
+
export class UnblockedServerError extends UnblockedApiError {
|
|
47
|
+
name = "UnblockedServerError";
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Constructs the most specific `UnblockedApiError` subclass for a response
|
|
51
|
+
* status. Unmapped statuses fall back to the base `UnblockedApiError`.
|
|
52
|
+
*/
|
|
53
|
+
export function createApiError(options) {
|
|
54
|
+
switch (options.status) {
|
|
55
|
+
case 400:
|
|
56
|
+
return new UnblockedBadRequestError(options);
|
|
57
|
+
case 401:
|
|
58
|
+
return new UnblockedAuthenticationError(options);
|
|
59
|
+
case 403:
|
|
60
|
+
return new UnblockedPermissionDeniedError(options);
|
|
61
|
+
case 404:
|
|
62
|
+
return new UnblockedNotFoundError(options);
|
|
63
|
+
case 429:
|
|
64
|
+
return new UnblockedRateLimitError(options);
|
|
65
|
+
default:
|
|
66
|
+
return options.status >= 500
|
|
67
|
+
? new UnblockedServerError(options)
|
|
68
|
+
: new UnblockedApiError(options);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
function buildApiErrorMessage(options) {
|
|
72
|
+
const statusText = options.statusText ? ` ${options.statusText}` : "";
|
|
73
|
+
const detail = apiErrorDetail(options.body);
|
|
74
|
+
const detailSuffix = detail ? ` - ${detail}` : "";
|
|
75
|
+
return `Unblocked API request failed: ${options.method} ${options.url} returned ${options.status}${statusText}${detailSuffix}`;
|
|
76
|
+
}
|
|
77
|
+
function apiErrorDetail(body) {
|
|
78
|
+
if (typeof body !== "object" || body === null) {
|
|
79
|
+
return undefined;
|
|
80
|
+
}
|
|
81
|
+
const { detail, title } = body;
|
|
82
|
+
if (typeof detail === "string" && detail.length > 0) {
|
|
83
|
+
return detail;
|
|
84
|
+
}
|
|
85
|
+
if (typeof title === "string" && title.length > 0) {
|
|
86
|
+
return title;
|
|
87
|
+
}
|
|
88
|
+
return undefined;
|
|
89
|
+
}
|
|
90
|
+
export class UnblockedTimeoutError extends Error {
|
|
91
|
+
name = "UnblockedTimeoutError";
|
|
92
|
+
constructor(resource, timeoutMs) {
|
|
93
|
+
super(`Timed out waiting ${timeoutMs}ms for ${resource}`);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
//# sourceMappingURL=errors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAuBA,MAAM,OAAO,iBAAkB,SAAQ,KAAK;IACjC,IAAI,GAAW,mBAAmB,CAAC;IACnC,MAAM,CAAS;IACf,UAAU,CAAS;IACnB,GAAG,CAAS;IACZ,MAAM,CAAS;IACf,IAAI,CAAU;IACd,OAAO,CAAU;IAC1B;;;OAGG;IACM,SAAS,CAAqB;IAEvC,YAAY,OAAiC;QAC3C,KAAK,CAAC,oBAAoB,CAAC,OAAO,CAAC,CAAC,CAAC;QACrC,IAAI,CAAC,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;QAC7B,IAAI,CAAC,UAAU,GAAG,OAAO,CAAC,UAAU,CAAC;QACrC,IAAI,CAAC,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC;QACvB,IAAI,CAAC,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;QAC7B,IAAI,CAAC,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC;QACzB,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC;QAC/B,IAAI,CAAC,SAAS,GAAG,OAAO,CAAC,SAAS,CAAC;IACrC,CAAC;CACF;AAED,+CAA+C;AAC/C,MAAM,OAAO,wBAAyB,SAAQ,iBAAiB;IAC3C,IAAI,GAAG,0BAA0B,CAAC;CACrD;AAED,0CAA0C;AAC1C,MAAM,OAAO,4BA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cAAc,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;IAC5C,MAAM,YAAY,GAAG,MAAM,CAAC,CAAC,CAAC,MAAM,MAAM,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;IAClD,OAAO,iCAAiC,OAAO,CAAC,MAAM,IAAI,OAAO,CAAC,GAAG,aAAa,OAAO,CAAC,MAAM,GAAG,UAAU,GAAG,YAAY,EAAE,CAAC;AACjI,CAAC;AAED,SAAS,cAAc,CAAC,IAAa;IACnC,IAAI,OAAO,IAAI,KAAK,QAAQ,IAAI,IAAI,KAAK,IAAI,EAAE,CAAC;QAC9C,OAAO,SAAS,CAAC;IACnB,CAAC;IAED,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,IAA6C,CAAC;IACxE,IAAI,OAAO,MAAM,KAAK,QAAQ,IAAI,MAAM,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACpD,OAAO,MAAM,CAAC;IAChB,CAAC;IACD,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QAClD,OAAO,KAAK,CAAC;IACf,CAAC;IACD,OAAO,SAAS,CAAC;AACnB,CAAC;AAED,MAAM,OAAO,qBAAsB,SAAQ,KAAK;IACrC,IAAI,GAAG,uBAAuB,CAAC;IAExC,YAAY,QAAgB,EAAE,SAAiB;QAC7C,KAAK,CAAC,qBAAqB,SAAS,UAAU,QAAQ,EAAE,CAAC,CAAC;IAC5D,CAAC;CACF"}
|
package/dist/http.d.ts
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { HttpMethod, JsonRequestOptions, RawResponse, UnblockedClientOptions } from "./types.js";
|
|
2
|
+
export declare class HttpClient {
|
|
3
|
+
private readonly tokenProvider;
|
|
4
|
+
private readonly baseUrl;
|
|
5
|
+
private readonly fetchFn;
|
|
6
|
+
private readonly headers;
|
|
7
|
+
private readonly timeoutMs;
|
|
8
|
+
private readonly maxRetries;
|
|
9
|
+
private readonly retryDelayMs;
|
|
10
|
+
constructor(options?: UnblockedClientOptions);
|
|
11
|
+
request<T>(method: HttpMethod, path: string, options?: JsonRequestOptions): Promise<T>;
|
|
12
|
+
requestRaw<T>(method: HttpMethod, path: string, options?: JsonRequestOptions): Promise<RawResponse<T>>;
|
|
13
|
+
private createRequestInit;
|
|
14
|
+
private fetchWithTimeout;
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=http.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"http.d.ts","sourceRoot":"","sources":["../src/http.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAEV,UAAU,EACV,kBAAkB,EAElB,WAAW,EAEX,sBAAsB,EACvB,MAAM,YAAY,CAAC;AASpB,qBAAa,UAAU;IACrB,OAAO,CAAC,QAAQ,CAAC,aAAa,CAAgB;IAC9C,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAS;IACjC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAe;IACvC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAA0B;IAClD,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAS;IACnC,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAS;IACpC,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAS;gBAE1B,OAAO,GAAE,sBAA2B;IA4B1C,OAAO,CAAC,CAAC,EAAE,MAAM,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,GAAE,kBAAuB,GAAG,OAAO,CAAC,CAAC,CAAC;IAK1F,UAAU,CAAC,CAAC,EAAE,MAAM,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,GAAE,kBAAuB,GAAG,OAAO,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC;YAoDlG,iBAAiB;YAyBjB,gBAAgB;CAkB/B"}
|