@superblocksteam/sdk-api 2.0.105 → 2.0.106-next.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +439 -89
- package/dist/api/definition.d.ts +11 -6
- package/dist/api/definition.d.ts.map +1 -1
- package/dist/api/definition.js +19 -12
- package/dist/api/definition.js.map +1 -1
- package/dist/api/definition.test.js +39 -15
- package/dist/api/definition.test.js.map +1 -1
- package/dist/errors.d.ts +1 -1
- package/dist/errors.js +1 -1
- package/dist/index.d.ts +10 -11
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +9 -5
- package/dist/index.js.map +1 -1
- package/dist/integrations/base/index.d.ts +2 -1
- package/dist/integrations/base/index.d.ts.map +1 -1
- package/dist/integrations/base/index.js +1 -0
- package/dist/integrations/base/index.js.map +1 -1
- package/dist/integrations/base/rest-api-client-base.d.ts +48 -0
- package/dist/integrations/base/rest-api-client-base.d.ts.map +1 -0
- package/dist/integrations/base/rest-api-client-base.js +98 -0
- package/dist/integrations/base/rest-api-client-base.js.map +1 -0
- package/dist/integrations/base/rest-api-integration-client.d.ts +10 -20
- package/dist/integrations/base/rest-api-integration-client.d.ts.map +1 -1
- package/dist/integrations/base/rest-api-integration-client.js +10 -65
- package/dist/integrations/base/rest-api-integration-client.js.map +1 -1
- package/dist/integrations/box/types.d.ts +1 -1
- package/dist/integrations/declarations.d.ts +5 -73
- package/dist/integrations/declarations.d.ts.map +1 -1
- package/dist/integrations/declarations.js +5 -68
- package/dist/integrations/declarations.js.map +1 -1
- package/dist/integrations/documentation.test.js +0 -2
- package/dist/integrations/documentation.test.js.map +1 -1
- package/dist/integrations/googledrive/types.d.ts +1 -1
- package/dist/integrations/index.d.ts +1 -11
- package/dist/integrations/index.d.ts.map +1 -1
- package/dist/integrations/index.js +1 -7
- package/dist/integrations/index.js.map +1 -1
- package/dist/integrations/registry.d.ts +1 -11
- package/dist/integrations/registry.d.ts.map +1 -1
- package/dist/integrations/registry.js +0 -29
- package/dist/integrations/registry.js.map +1 -1
- package/dist/integrations/slack/client.d.ts +13 -9
- package/dist/integrations/slack/client.d.ts.map +1 -1
- package/dist/integrations/slack/client.js +60 -8
- package/dist/integrations/slack/client.js.map +1 -1
- package/dist/integrations/slack/client.test.d.ts +11 -0
- package/dist/integrations/slack/client.test.d.ts.map +1 -0
- package/dist/integrations/slack/client.test.js +368 -0
- package/dist/integrations/slack/client.test.js.map +1 -0
- package/dist/integrations/slack/index.d.ts +2 -1
- package/dist/integrations/slack/index.d.ts.map +1 -1
- package/dist/integrations/slack/index.js +1 -0
- package/dist/integrations/slack/index.js.map +1 -1
- package/dist/integrations/slack/types.d.ts +127 -28
- package/dist/integrations/slack/types.d.ts.map +1 -1
- package/dist/integrations/slack/types.js +27 -1
- package/dist/integrations/slack/types.js.map +1 -1
- package/dist/integrations/snowflake/client.d.ts +2 -2
- package/dist/integrations/snowflake/client.js +2 -2
- package/dist/runtime/context.d.ts +1 -1
- package/dist/runtime/executor.d.ts +2 -2
- package/dist/types.d.ts +15 -6
- package/dist/types.d.ts.map +1 -1
- package/package.json +2 -2
- package/src/api/definition.test.ts +40 -15
- package/src/api/definition.ts +19 -12
- package/src/errors.ts +1 -1
- package/src/index.ts +13 -33
- package/src/integrations/asana/README.md +12 -12
- package/src/integrations/base/index.ts +2 -1
- package/src/integrations/base/rest-api-client-base.ts +134 -0
- package/src/integrations/base/rest-api-integration-client.ts +12 -89
- package/src/integrations/bitbucket/README.md +19 -19
- package/src/integrations/box/README.md +24 -24
- package/src/integrations/box/types.ts +1 -1
- package/src/integrations/circleci/README.md +18 -18
- package/src/integrations/declarations.ts +5 -105
- package/src/integrations/documentation.test.ts +0 -2
- package/src/integrations/googledrive/README.md +25 -22
- package/src/integrations/googledrive/types.ts +1 -1
- package/src/integrations/graphql/README.md +2 -2
- package/src/integrations/groq/README.md +8 -8
- package/src/integrations/index.ts +0 -51
- package/src/integrations/mongodb/README.md +65 -12
- package/src/integrations/perplexity/README.md +39 -48
- package/src/integrations/registry.ts +1 -39
- package/src/integrations/salesforce/README.md +11 -9
- package/src/integrations/slack/README.md +62 -19
- package/src/integrations/slack/client.test.ts +553 -0
- package/src/integrations/slack/client.ts +92 -12
- package/src/integrations/slack/index.ts +6 -1
- package/src/integrations/slack/types.ts +142 -29
- package/src/integrations/snowflake/client.ts +2 -2
- package/src/integrations/zoom/README.md +15 -15
- package/src/runtime/context.ts +1 -1
- package/src/runtime/executor.ts +2 -2
- package/src/types.ts +15 -6
- package/dist/integrations/couchbase/client.d.ts +0 -36
- package/dist/integrations/couchbase/client.d.ts.map +0 -1
- package/dist/integrations/couchbase/client.js +0 -148
- package/dist/integrations/couchbase/client.js.map +0 -1
- package/dist/integrations/couchbase/index.d.ts +0 -8
- package/dist/integrations/couchbase/index.d.ts.map +0 -1
- package/dist/integrations/couchbase/index.js +0 -7
- package/dist/integrations/couchbase/index.js.map +0 -1
- package/dist/integrations/couchbase/types.d.ts +0 -100
- package/dist/integrations/couchbase/types.d.ts.map +0 -1
- package/dist/integrations/couchbase/types.js +0 -5
- package/dist/integrations/couchbase/types.js.map +0 -1
- package/dist/integrations/kafka/client.d.ts +0 -25
- package/dist/integrations/kafka/client.d.ts.map +0 -1
- package/dist/integrations/kafka/client.js +0 -124
- package/dist/integrations/kafka/client.js.map +0 -1
- package/dist/integrations/kafka/index.d.ts +0 -8
- package/dist/integrations/kafka/index.d.ts.map +0 -1
- package/dist/integrations/kafka/index.js +0 -7
- package/dist/integrations/kafka/index.js.map +0 -1
- package/dist/integrations/kafka/types.d.ts +0 -113
- package/dist/integrations/kafka/types.d.ts.map +0 -1
- package/dist/integrations/kafka/types.js +0 -5
- package/dist/integrations/kafka/types.js.map +0 -1
- package/dist/integrations/kinesis/client.d.ts +0 -31
- package/dist/integrations/kinesis/client.d.ts.map +0 -1
- package/dist/integrations/kinesis/client.js +0 -101
- package/dist/integrations/kinesis/client.js.map +0 -1
- package/dist/integrations/kinesis/index.d.ts +0 -8
- package/dist/integrations/kinesis/index.d.ts.map +0 -1
- package/dist/integrations/kinesis/index.js +0 -7
- package/dist/integrations/kinesis/index.js.map +0 -1
- package/dist/integrations/kinesis/types.d.ts +0 -97
- package/dist/integrations/kinesis/types.d.ts.map +0 -1
- package/dist/integrations/kinesis/types.js +0 -7
- package/dist/integrations/kinesis/types.js.map +0 -1
- package/dist/integrations/python/client.d.ts +0 -42
- package/dist/integrations/python/client.d.ts.map +0 -1
- package/dist/integrations/python/client.js +0 -89
- package/dist/integrations/python/client.js.map +0 -1
- package/dist/integrations/python/client.test.d.ts +0 -5
- package/dist/integrations/python/client.test.d.ts.map +0 -1
- package/dist/integrations/python/client.test.js +0 -214
- package/dist/integrations/python/client.test.js.map +0 -1
- package/dist/integrations/python/index.d.ts +0 -6
- package/dist/integrations/python/index.d.ts.map +0 -1
- package/dist/integrations/python/index.js +0 -5
- package/dist/integrations/python/index.js.map +0 -1
- package/dist/integrations/python/types.d.ts +0 -85
- package/dist/integrations/python/types.d.ts.map +0 -1
- package/dist/integrations/python/types.js +0 -5
- package/dist/integrations/python/types.js.map +0 -1
- package/dist/integrations/redis/client.d.ts +0 -43
- package/dist/integrations/redis/client.d.ts.map +0 -1
- package/dist/integrations/redis/client.js +0 -142
- package/dist/integrations/redis/client.js.map +0 -1
- package/dist/integrations/redis/index.d.ts +0 -8
- package/dist/integrations/redis/index.d.ts.map +0 -1
- package/dist/integrations/redis/index.js +0 -7
- package/dist/integrations/redis/index.js.map +0 -1
- package/dist/integrations/redis/types.d.ts +0 -137
- package/dist/integrations/redis/types.d.ts.map +0 -1
- package/dist/integrations/redis/types.js +0 -5
- package/dist/integrations/redis/types.js.map +0 -1
- package/src/integrations/couchbase/README.md +0 -138
- package/src/integrations/couchbase/client.ts +0 -225
- package/src/integrations/couchbase/index.ts +0 -8
- package/src/integrations/couchbase/types.ts +0 -126
- package/src/integrations/kafka/README.md +0 -144
- package/src/integrations/kafka/client.ts +0 -216
- package/src/integrations/kafka/index.ts +0 -14
- package/src/integrations/kafka/types.ts +0 -128
- package/src/integrations/kinesis/README.md +0 -153
- package/src/integrations/kinesis/client.ts +0 -146
- package/src/integrations/kinesis/index.ts +0 -14
- package/src/integrations/kinesis/types.ts +0 -114
- package/src/integrations/python/README.md +0 -566
- package/src/integrations/python/client.test.ts +0 -341
- package/src/integrations/python/client.ts +0 -136
- package/src/integrations/python/index.ts +0 -6
- package/src/integrations/python/types.ts +0 -92
- package/src/integrations/redis/README.md +0 -200
- package/src/integrations/redis/client.ts +0 -208
- package/src/integrations/redis/index.ts +0 -8
- package/src/integrations/redis/types.ts +0 -167
|
@@ -1,58 +1,33 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* Generic REST API Integration client with Zod response validation.
|
|
3
3
|
*
|
|
4
|
-
*
|
|
4
|
+
* Extends RestApiClientBase with an apiRequest() that validates the
|
|
5
|
+
* full response against a caller-supplied Zod schema and throws
|
|
6
|
+
* RestApiValidationError on mismatch.
|
|
5
7
|
*/
|
|
6
8
|
|
|
7
|
-
import type { PartialMessage } from "@bufbuild/protobuf";
|
|
8
9
|
import type { z } from "zod";
|
|
9
10
|
|
|
10
|
-
import type { Property } from "@superblocksteam/types/dist/src/common/v1/plugin_pb";
|
|
11
|
-
import type { Plugin as RestApiIntegrationPlugin } from "@superblocksteam/types/dist/src/plugins/restapiintegration/v1/plugin_pb";
|
|
12
|
-
|
|
13
11
|
import { RestApiValidationError } from "../../errors.js";
|
|
14
|
-
import type {
|
|
15
|
-
import
|
|
12
|
+
import type { TraceMetadata } from "../registry.js";
|
|
13
|
+
import { RestApiClientBase } from "./rest-api-client-base.js";
|
|
16
14
|
import type {
|
|
17
15
|
ApiRequestOptions,
|
|
18
16
|
ApiRequestSchema,
|
|
19
17
|
SupportsApiRequest,
|
|
20
18
|
} from "./types.js";
|
|
21
19
|
|
|
22
|
-
export type RestApiRequest = PartialMessage<RestApiIntegrationPlugin>;
|
|
23
|
-
|
|
24
20
|
/**
|
|
25
21
|
* Base implementation for REST API Integration clients.
|
|
26
22
|
*
|
|
27
|
-
* All OpenAPI-based integration clients
|
|
28
|
-
*
|
|
23
|
+
* All OpenAPI-based integration clients (except those with
|
|
24
|
+
* integration-specific response handling) extend this class to
|
|
25
|
+
* inherit the generic apiRequest() method with runtime Zod validation.
|
|
29
26
|
*/
|
|
30
27
|
export abstract class RestApiIntegrationClient
|
|
31
|
-
|
|
28
|
+
extends RestApiClientBase
|
|
29
|
+
implements SupportsApiRequest
|
|
32
30
|
{
|
|
33
|
-
readonly name: string;
|
|
34
|
-
readonly pluginId: string;
|
|
35
|
-
readonly config: IntegrationConfig;
|
|
36
|
-
|
|
37
|
-
protected readonly executeQuery: QueryExecutor;
|
|
38
|
-
|
|
39
|
-
constructor(config: IntegrationConfig, executeQuery: QueryExecutor) {
|
|
40
|
-
this.name = config.name;
|
|
41
|
-
this.pluginId = config.pluginId;
|
|
42
|
-
this.config = config;
|
|
43
|
-
this.executeQuery = executeQuery;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
/**
|
|
47
|
-
* Helper to create a Property object for params.
|
|
48
|
-
*/
|
|
49
|
-
protected createParam(key: string, value: unknown): PartialMessage<Property> {
|
|
50
|
-
return {
|
|
51
|
-
key,
|
|
52
|
-
value: typeof value === "string" ? value : JSON.stringify(value),
|
|
53
|
-
};
|
|
54
|
-
}
|
|
55
|
-
|
|
56
31
|
async apiRequest<TBody, TResponse>(
|
|
57
32
|
options: ApiRequestOptions<TBody>,
|
|
58
33
|
schema: ApiRequestSchema<TBody, TResponse> & {
|
|
@@ -60,59 +35,7 @@ export abstract class RestApiIntegrationClient
|
|
|
60
35
|
},
|
|
61
36
|
metadata?: TraceMetadata,
|
|
62
37
|
): Promise<TResponse> {
|
|
63
|
-
|
|
64
|
-
// Body schema is optional — if not provided, the body is sent unvalidated.
|
|
65
|
-
if (options.body !== undefined && schema?.body) {
|
|
66
|
-
const bodyParseResult = schema.body.safeParse(options.body);
|
|
67
|
-
if (!bodyParseResult.success) {
|
|
68
|
-
throw new RestApiValidationError(
|
|
69
|
-
`Request body validation failed: ${bodyParseResult.error.message}`,
|
|
70
|
-
{
|
|
71
|
-
zodError: bodyParseResult.error,
|
|
72
|
-
data: options.body,
|
|
73
|
-
},
|
|
74
|
-
);
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
// Convert headers to Property array
|
|
79
|
-
const headers: PartialMessage<Property>[] = [];
|
|
80
|
-
if (options.headers) {
|
|
81
|
-
for (const [key, value] of Object.entries(options.headers)) {
|
|
82
|
-
headers.push(this.createParam(key, value));
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
// Convert query params to Property array
|
|
87
|
-
const params: PartialMessage<Property>[] = [];
|
|
88
|
-
if (options.params) {
|
|
89
|
-
for (const [key, value] of Object.entries(options.params)) {
|
|
90
|
-
params.push(this.createParam(key, value));
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
// Build the request using raw HTTP mode
|
|
95
|
-
const request: RestApiRequest = {
|
|
96
|
-
openApiAction: "genericHttpRequest",
|
|
97
|
-
httpMethod: options.method.toUpperCase(),
|
|
98
|
-
urlPath: options.path,
|
|
99
|
-
headers,
|
|
100
|
-
params,
|
|
101
|
-
responseType: "json",
|
|
102
|
-
};
|
|
103
|
-
|
|
104
|
-
// Add body if provided
|
|
105
|
-
if (options.body !== undefined) {
|
|
106
|
-
request.body = JSON.stringify(options.body);
|
|
107
|
-
request.bodyType = "jsonBody";
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
// Execute the request
|
|
111
|
-
const result = await this.executeQuery(
|
|
112
|
-
request as Record<string, unknown>,
|
|
113
|
-
undefined,
|
|
114
|
-
metadata,
|
|
115
|
-
);
|
|
38
|
+
const result = await this.executeApiRequest(options, schema.body, metadata);
|
|
116
39
|
|
|
117
40
|
// Response schema is REQUIRED - always validate
|
|
118
41
|
const responseParseResult = schema.response.safeParse(result);
|
|
@@ -54,7 +54,7 @@ export default api({
|
|
|
54
54
|
const result = await ctx.integrations.bitbucket.apiRequest(
|
|
55
55
|
{
|
|
56
56
|
method: "GET",
|
|
57
|
-
path: `/
|
|
57
|
+
path: `/repositories/${workspace}`,
|
|
58
58
|
params: {
|
|
59
59
|
pagelen: 50,
|
|
60
60
|
},
|
|
@@ -78,7 +78,7 @@ export default api({
|
|
|
78
78
|
const repo = await ctx.integrations.bitbucket.apiRequest(
|
|
79
79
|
{
|
|
80
80
|
method: "GET",
|
|
81
|
-
path: `/
|
|
81
|
+
path: `/repositories/${workspace}/${repoSlug}`,
|
|
82
82
|
},
|
|
83
83
|
{ response: RepositorySchema },
|
|
84
84
|
);
|
|
@@ -111,7 +111,7 @@ const PullRequestSchema = z.object({
|
|
|
111
111
|
const pr = await ctx.integrations.bitbucket.apiRequest(
|
|
112
112
|
{
|
|
113
113
|
method: "POST",
|
|
114
|
-
path: `/
|
|
114
|
+
path: `/repositories/${workspace}/${repoSlug}/pullrequests`,
|
|
115
115
|
body: {
|
|
116
116
|
title: "Add new feature",
|
|
117
117
|
description: "This PR adds...",
|
|
@@ -143,7 +143,7 @@ const ListPRsResponseSchema = z.object({
|
|
|
143
143
|
const result = await ctx.integrations.bitbucket.apiRequest(
|
|
144
144
|
{
|
|
145
145
|
method: "GET",
|
|
146
|
-
path: `/
|
|
146
|
+
path: `/repositories/${workspace}/${repoSlug}/pullrequests`,
|
|
147
147
|
params: {
|
|
148
148
|
state: "OPEN", // OPEN, MERGED, DECLINED, SUPERSEDED
|
|
149
149
|
pagelen: 25,
|
|
@@ -172,7 +172,7 @@ const MergeResponseSchema = z.object({
|
|
|
172
172
|
const result = await ctx.integrations.bitbucket.apiRequest(
|
|
173
173
|
{
|
|
174
174
|
method: "POST",
|
|
175
|
-
path: `/
|
|
175
|
+
path: `/repositories/${workspace}/${repoSlug}/pullrequests/${prId}/merge`,
|
|
176
176
|
body: {
|
|
177
177
|
type: "pullrequest",
|
|
178
178
|
message: "Merge pull request #123",
|
|
@@ -209,7 +209,7 @@ const ListCommitsResponseSchema = z.object({
|
|
|
209
209
|
const result = await ctx.integrations.bitbucket.apiRequest(
|
|
210
210
|
{
|
|
211
211
|
method: "GET",
|
|
212
|
-
path: `/
|
|
212
|
+
path: `/repositories/${workspace}/${repoSlug}/commits`,
|
|
213
213
|
params: {
|
|
214
214
|
branch: "main",
|
|
215
215
|
pagelen: 10,
|
|
@@ -232,7 +232,7 @@ const BranchSchema = z.object({
|
|
|
232
232
|
const branch = await ctx.integrations.bitbucket.apiRequest(
|
|
233
233
|
{
|
|
234
234
|
method: "POST",
|
|
235
|
-
path: `/
|
|
235
|
+
path: `/repositories/${workspace}/${repoSlug}/refs/branches`,
|
|
236
236
|
body: {
|
|
237
237
|
name: "feature/new-feature",
|
|
238
238
|
target: {
|
|
@@ -251,7 +251,7 @@ const branch = await ctx.integrations.bitbucket.apiRequest(
|
|
|
251
251
|
const content = await ctx.integrations.bitbucket.apiRequest(
|
|
252
252
|
{
|
|
253
253
|
method: "GET",
|
|
254
|
-
path: `/
|
|
254
|
+
path: `/repositories/${workspace}/${repoSlug}/src/main/README.md`,
|
|
255
255
|
},
|
|
256
256
|
{ response: z.string() },
|
|
257
257
|
);
|
|
@@ -274,7 +274,7 @@ const CommentSchema = z.object({
|
|
|
274
274
|
const comment = await ctx.integrations.bitbucket.apiRequest(
|
|
275
275
|
{
|
|
276
276
|
method: "POST",
|
|
277
|
-
path: `/
|
|
277
|
+
path: `/repositories/${workspace}/${repoSlug}/pullrequests/${prId}/comments`,
|
|
278
278
|
body: {
|
|
279
279
|
content: {
|
|
280
280
|
raw: "LGTM! :+1:",
|
|
@@ -300,20 +300,20 @@ await bitbucket.listRepos();
|
|
|
300
300
|
|
|
301
301
|
// CORRECT - Use apiRequest
|
|
302
302
|
await ctx.integrations.bitbucket.apiRequest(
|
|
303
|
-
{ method: "POST", path: `/
|
|
303
|
+
{ method: "POST", path: `/repositories/${workspace}/${repo}/pullrequests`, body: { ... } },
|
|
304
304
|
{ response: PullRequestSchema }
|
|
305
305
|
);
|
|
306
306
|
```
|
|
307
307
|
|
|
308
308
|
### API Version in Path
|
|
309
309
|
|
|
310
|
-
|
|
310
|
+
The base URL already includes `/2.0`, so do not repeat it in paths:
|
|
311
311
|
|
|
312
312
|
```typescript
|
|
313
|
-
//
|
|
313
|
+
// CORRECT - No version prefix (base URL already has /2.0)
|
|
314
314
|
const path = `/repositories/${workspace}/${repo}`;
|
|
315
315
|
|
|
316
|
-
//
|
|
316
|
+
// WRONG - Duplicates version from base URL
|
|
317
317
|
const path = `/2.0/repositories/${workspace}/${repo}`;
|
|
318
318
|
```
|
|
319
319
|
|
|
@@ -323,10 +323,10 @@ Use workspace slug for API calls:
|
|
|
323
323
|
|
|
324
324
|
```typescript
|
|
325
325
|
// Workspace slug (preferred)
|
|
326
|
-
const path = `/
|
|
326
|
+
const path = `/repositories/myworkspace/myrepo`;
|
|
327
327
|
|
|
328
328
|
// Can also be username for personal repos
|
|
329
|
-
const path = `/
|
|
329
|
+
const path = `/repositories/myusername/myrepo`;
|
|
330
330
|
```
|
|
331
331
|
|
|
332
332
|
### Pagination
|
|
@@ -340,7 +340,7 @@ async function getAllPRs(
|
|
|
340
340
|
repo: string,
|
|
341
341
|
) {
|
|
342
342
|
const allPRs: PullRequest[] = [];
|
|
343
|
-
let url = `/
|
|
343
|
+
let url = `/repositories/${workspace}/${repo}/pullrequests`;
|
|
344
344
|
|
|
345
345
|
while (url) {
|
|
346
346
|
const result = await ctx.integrations.bitbucket.apiRequest(
|
|
@@ -385,7 +385,7 @@ Branch names with slashes need encoding:
|
|
|
385
385
|
```typescript
|
|
386
386
|
// Branch name: feature/my-feature
|
|
387
387
|
const branchName = encodeURIComponent("feature/my-feature");
|
|
388
|
-
const path = `/
|
|
388
|
+
const path = `/repositories/${workspace}/${repo}/src/${branchName}/file.txt`;
|
|
389
389
|
```
|
|
390
390
|
|
|
391
391
|
### Raw File Content
|
|
@@ -397,7 +397,7 @@ File content endpoints return raw text, not JSON:
|
|
|
397
397
|
const content = await ctx.integrations.bitbucket.apiRequest(
|
|
398
398
|
{
|
|
399
399
|
method: "GET",
|
|
400
|
-
path: `/
|
|
400
|
+
path: `/repositories/${workspace}/${repo}/src/main/file.txt`,
|
|
401
401
|
},
|
|
402
402
|
{ response: z.string() }, // Not a JSON schema
|
|
403
403
|
);
|
|
@@ -410,7 +410,7 @@ import { RestApiValidationError } from "@superblocksteam/sdk-api";
|
|
|
410
410
|
|
|
411
411
|
try {
|
|
412
412
|
const result = await ctx.integrations.bitbucket.apiRequest(
|
|
413
|
-
{ method: "GET", path: `/
|
|
413
|
+
{ method: "GET", path: `/repositories/${workspace}/${repo}` },
|
|
414
414
|
{ response: RepositorySchema },
|
|
415
415
|
);
|
|
416
416
|
} catch (error) {
|
|
@@ -75,7 +75,7 @@ export default api({
|
|
|
75
75
|
const result = await ctx.integrations.box.apiRequest(
|
|
76
76
|
{
|
|
77
77
|
method: "GET",
|
|
78
|
-
path: `/
|
|
78
|
+
path: `/folders/${folderId}/items`,
|
|
79
79
|
params: {
|
|
80
80
|
limit: limit,
|
|
81
81
|
offset: 0,
|
|
@@ -133,7 +133,7 @@ const FileInfoSchema = z.object({
|
|
|
133
133
|
const file = await ctx.integrations.box.apiRequest(
|
|
134
134
|
{
|
|
135
135
|
method: "GET",
|
|
136
|
-
path: `/
|
|
136
|
+
path: `/files/${fileId}`,
|
|
137
137
|
params: {
|
|
138
138
|
fields:
|
|
139
139
|
"id,name,size,created_at,modified_at,created_by,modified_by,parent,sha1,shared_link",
|
|
@@ -154,7 +154,7 @@ const DownloadUrlResponseSchema = z.string();
|
|
|
154
154
|
const content = await ctx.integrations.box.apiRequest(
|
|
155
155
|
{
|
|
156
156
|
method: "GET",
|
|
157
|
-
path: `/
|
|
157
|
+
path: `/files/${fileId}/content`,
|
|
158
158
|
},
|
|
159
159
|
{ response: DownloadUrlResponseSchema },
|
|
160
160
|
);
|
|
@@ -172,7 +172,7 @@ const UploadResponseSchema = z.object({
|
|
|
172
172
|
const result = await ctx.integrations.box.apiRequest(
|
|
173
173
|
{
|
|
174
174
|
method: "POST",
|
|
175
|
-
path: "/
|
|
175
|
+
path: "/files/content",
|
|
176
176
|
headers: {
|
|
177
177
|
"Content-Type": "multipart/form-data",
|
|
178
178
|
},
|
|
@@ -209,7 +209,7 @@ const FolderInfoSchema = z.object({
|
|
|
209
209
|
const folder = await ctx.integrations.box.apiRequest(
|
|
210
210
|
{
|
|
211
211
|
method: "POST",
|
|
212
|
-
path: "/
|
|
212
|
+
path: "/folders",
|
|
213
213
|
body: {
|
|
214
214
|
name: "New Folder",
|
|
215
215
|
parent: {
|
|
@@ -229,7 +229,7 @@ console.log(`Created folder: ${folder.name} (${folder.id})`);
|
|
|
229
229
|
const copiedFile = await ctx.integrations.box.apiRequest(
|
|
230
230
|
{
|
|
231
231
|
method: "POST",
|
|
232
|
-
path: `/
|
|
232
|
+
path: `/files/${fileId}/copy`,
|
|
233
233
|
body: {
|
|
234
234
|
parent: {
|
|
235
235
|
id: destinationFolderId,
|
|
@@ -247,7 +247,7 @@ const copiedFile = await ctx.integrations.box.apiRequest(
|
|
|
247
247
|
const movedFile = await ctx.integrations.box.apiRequest(
|
|
248
248
|
{
|
|
249
249
|
method: "PUT",
|
|
250
|
-
path: `/
|
|
250
|
+
path: `/files/${fileId}`,
|
|
251
251
|
body: {
|
|
252
252
|
parent: {
|
|
253
253
|
id: newParentFolderId,
|
|
@@ -264,7 +264,7 @@ const movedFile = await ctx.integrations.box.apiRequest(
|
|
|
264
264
|
const updatedFile = await ctx.integrations.box.apiRequest(
|
|
265
265
|
{
|
|
266
266
|
method: "PUT",
|
|
267
|
-
path: `/
|
|
267
|
+
path: `/files/${fileId}`,
|
|
268
268
|
body: {
|
|
269
269
|
name: "renamed-file.txt",
|
|
270
270
|
description: "Updated file description",
|
|
@@ -281,7 +281,7 @@ const updatedFile = await ctx.integrations.box.apiRequest(
|
|
|
281
281
|
await ctx.integrations.box.apiRequest(
|
|
282
282
|
{
|
|
283
283
|
method: "DELETE",
|
|
284
|
-
path: `/
|
|
284
|
+
path: `/files/${fileId}`,
|
|
285
285
|
},
|
|
286
286
|
{ response: z.void() },
|
|
287
287
|
);
|
|
@@ -304,7 +304,7 @@ const SharedLinkSchema = z.object({
|
|
|
304
304
|
const file = await ctx.integrations.box.apiRequest(
|
|
305
305
|
{
|
|
306
306
|
method: "PUT",
|
|
307
|
-
path: `/
|
|
307
|
+
path: `/files/${fileId}`,
|
|
308
308
|
params: {
|
|
309
309
|
fields: "shared_link",
|
|
310
310
|
},
|
|
@@ -337,7 +337,7 @@ const SearchResponseSchema = z.object({
|
|
|
337
337
|
const result = await ctx.integrations.box.apiRequest(
|
|
338
338
|
{
|
|
339
339
|
method: "GET",
|
|
340
|
-
path: "/
|
|
340
|
+
path: "/search",
|
|
341
341
|
params: {
|
|
342
342
|
query: "quarterly report",
|
|
343
343
|
type: "file",
|
|
@@ -372,7 +372,7 @@ const CommentSchema = z.object({
|
|
|
372
372
|
const comment = await ctx.integrations.box.apiRequest(
|
|
373
373
|
{
|
|
374
374
|
method: "POST",
|
|
375
|
-
path: "/
|
|
375
|
+
path: "/comments",
|
|
376
376
|
body: {
|
|
377
377
|
item: {
|
|
378
378
|
type: "file",
|
|
@@ -400,22 +400,22 @@ await box.uploadFile({ ... });
|
|
|
400
400
|
|
|
401
401
|
// CORRECT - Use apiRequest
|
|
402
402
|
await ctx.integrations.box.apiRequest(
|
|
403
|
-
{ method: "GET", path: `/
|
|
403
|
+
{ method: "GET", path: `/folders/${folderId}/items`, params: { ... } },
|
|
404
404
|
{ response: ListItemsResponseSchema }
|
|
405
405
|
);
|
|
406
406
|
```
|
|
407
407
|
|
|
408
408
|
### API Version in Path
|
|
409
409
|
|
|
410
|
-
|
|
410
|
+
The base URL already includes `/2.0`, so do not repeat it in paths:
|
|
411
411
|
|
|
412
412
|
```typescript
|
|
413
|
-
// CORRECT -
|
|
414
|
-
const path = "/2.0/files/123";
|
|
415
|
-
const path = "/2.0/folders/0/items";
|
|
416
|
-
|
|
417
|
-
// WRONG - Missing version
|
|
413
|
+
// CORRECT - No version prefix (base URL already has /2.0)
|
|
418
414
|
const path = "/files/123";
|
|
415
|
+
const path = "/folders/0/items";
|
|
416
|
+
|
|
417
|
+
// WRONG - Duplicates version from base URL
|
|
418
|
+
const path = "/2.0/files/123";
|
|
419
419
|
```
|
|
420
420
|
|
|
421
421
|
### Root Folder ID is "0"
|
|
@@ -437,7 +437,7 @@ Use `fields` to get specific data:
|
|
|
437
437
|
```typescript
|
|
438
438
|
// Without fields, you get minimal data
|
|
439
439
|
const result = await ctx.integrations.box.apiRequest(
|
|
440
|
-
{ method: "GET", path: `/
|
|
440
|
+
{ method: "GET", path: `/files/${fileId}` },
|
|
441
441
|
{ response: FileSchema },
|
|
442
442
|
);
|
|
443
443
|
|
|
@@ -445,7 +445,7 @@ const result = await ctx.integrations.box.apiRequest(
|
|
|
445
445
|
const result = await ctx.integrations.box.apiRequest(
|
|
446
446
|
{
|
|
447
447
|
method: "GET",
|
|
448
|
-
path: `/
|
|
448
|
+
path: `/files/${fileId}`,
|
|
449
449
|
params: {
|
|
450
450
|
fields: "id,name,size,created_at,modified_at,parent,shared_link",
|
|
451
451
|
},
|
|
@@ -477,7 +477,7 @@ Use `If-Match` with etag for safe updates:
|
|
|
477
477
|
const result = await ctx.integrations.box.apiRequest(
|
|
478
478
|
{
|
|
479
479
|
method: "PUT",
|
|
480
|
-
path: `/
|
|
480
|
+
path: `/files/${fileId}`,
|
|
481
481
|
headers: {
|
|
482
482
|
"If-Match": file.etag, // Prevents overwriting concurrent changes
|
|
483
483
|
},
|
|
@@ -503,7 +503,7 @@ async function getAllItems(box: BoxClient, folderId: string) {
|
|
|
503
503
|
const result = await ctx.integrations.box.apiRequest(
|
|
504
504
|
{
|
|
505
505
|
method: "GET",
|
|
506
|
-
path: `/
|
|
506
|
+
path: `/folders/${folderId}/items`,
|
|
507
507
|
params: { limit, offset, fields: "id,name,type" },
|
|
508
508
|
},
|
|
509
509
|
{ response: ListItemsResponseSchema },
|
|
@@ -557,7 +557,7 @@ import { RestApiValidationError } from "@superblocksteam/sdk-api";
|
|
|
557
557
|
|
|
558
558
|
try {
|
|
559
559
|
const result = await ctx.integrations.box.apiRequest(
|
|
560
|
-
{ method: "GET", path: `/
|
|
560
|
+
{ method: "GET", path: `/folders/${folderId}/items`, params: { ... } },
|
|
561
561
|
{ response: ListItemsResponseSchema }
|
|
562
562
|
);
|
|
563
563
|
} catch (error) {
|
|
@@ -51,7 +51,7 @@ export default api({
|
|
|
51
51
|
const result = await ctx.integrations.circleci.apiRequest(
|
|
52
52
|
{
|
|
53
53
|
method: "POST",
|
|
54
|
-
path: `/
|
|
54
|
+
path: `/project/${projectSlug}/pipeline`,
|
|
55
55
|
body: {
|
|
56
56
|
branch: branch,
|
|
57
57
|
parameters: {
|
|
@@ -73,7 +73,7 @@ export default api({
|
|
|
73
73
|
const result = await ctx.integrations.circleci.apiRequest(
|
|
74
74
|
{
|
|
75
75
|
method: "GET",
|
|
76
|
-
path: `/
|
|
76
|
+
path: `/pipeline/${pipelineId}`,
|
|
77
77
|
},
|
|
78
78
|
{ response: PipelineSchema },
|
|
79
79
|
);
|
|
@@ -102,7 +102,7 @@ const ListWorkflowsResponseSchema = z.object({
|
|
|
102
102
|
const result = await ctx.integrations.circleci.apiRequest(
|
|
103
103
|
{
|
|
104
104
|
method: "GET",
|
|
105
|
-
path: `/
|
|
105
|
+
path: `/pipeline/${pipelineId}/workflow`,
|
|
106
106
|
},
|
|
107
107
|
{ response: ListWorkflowsResponseSchema },
|
|
108
108
|
);
|
|
@@ -133,7 +133,7 @@ const ListJobsResponseSchema = z.object({
|
|
|
133
133
|
const result = await ctx.integrations.circleci.apiRequest(
|
|
134
134
|
{
|
|
135
135
|
method: "GET",
|
|
136
|
-
path: `/
|
|
136
|
+
path: `/workflow/${workflowId}/job`,
|
|
137
137
|
},
|
|
138
138
|
{ response: ListJobsResponseSchema },
|
|
139
139
|
);
|
|
@@ -162,7 +162,7 @@ const JobDetailSchema = z.object({
|
|
|
162
162
|
const result = await ctx.integrations.circleci.apiRequest(
|
|
163
163
|
{
|
|
164
164
|
method: "GET",
|
|
165
|
-
path: `/
|
|
165
|
+
path: `/project/${projectSlug}/job/${jobNumber}`,
|
|
166
166
|
},
|
|
167
167
|
{ response: JobDetailSchema },
|
|
168
168
|
);
|
|
@@ -178,7 +178,7 @@ const RetryResponseSchema = z.object({
|
|
|
178
178
|
const result = await ctx.integrations.circleci.apiRequest(
|
|
179
179
|
{
|
|
180
180
|
method: "POST",
|
|
181
|
-
path: `/
|
|
181
|
+
path: `/workflow/${workflowId}/rerun`,
|
|
182
182
|
body: {
|
|
183
183
|
from_failed: true, // Only rerun failed jobs
|
|
184
184
|
},
|
|
@@ -199,7 +199,7 @@ const CancelResponseSchema = z.object({
|
|
|
199
199
|
const result = await ctx.integrations.circleci.apiRequest(
|
|
200
200
|
{
|
|
201
201
|
method: "POST",
|
|
202
|
-
path: `/
|
|
202
|
+
path: `/workflow/${workflowId}/cancel`,
|
|
203
203
|
},
|
|
204
204
|
{ response: CancelResponseSchema },
|
|
205
205
|
);
|
|
@@ -216,7 +216,7 @@ const ListPipelinesResponseSchema = z.object({
|
|
|
216
216
|
const result = await ctx.integrations.circleci.apiRequest(
|
|
217
217
|
{
|
|
218
218
|
method: "GET",
|
|
219
|
-
path: `/
|
|
219
|
+
path: `/project/${projectSlug}/pipeline`,
|
|
220
220
|
params: {
|
|
221
221
|
branch: "main",
|
|
222
222
|
"page-token": undefined, // For pagination
|
|
@@ -247,7 +247,7 @@ const ProjectSchema = z.object({
|
|
|
247
247
|
const result = await ctx.integrations.circleci.apiRequest(
|
|
248
248
|
{
|
|
249
249
|
method: "GET",
|
|
250
|
-
path: `/
|
|
250
|
+
path: `/project/${projectSlug}`,
|
|
251
251
|
},
|
|
252
252
|
{ response: ProjectSchema },
|
|
253
253
|
);
|
|
@@ -270,7 +270,7 @@ const ListArtifactsResponseSchema = z.object({
|
|
|
270
270
|
const result = await ctx.integrations.circleci.apiRequest(
|
|
271
271
|
{
|
|
272
272
|
method: "GET",
|
|
273
|
-
path: `/
|
|
273
|
+
path: `/project/${projectSlug}/${jobNumber}/artifacts`,
|
|
274
274
|
},
|
|
275
275
|
{ response: ListArtifactsResponseSchema },
|
|
276
276
|
);
|
|
@@ -295,7 +295,7 @@ await circleci.getWorkflow({ ... });
|
|
|
295
295
|
|
|
296
296
|
// CORRECT - Use apiRequest
|
|
297
297
|
await ctx.integrations.circleci.apiRequest(
|
|
298
|
-
{ method: "POST", path: `/
|
|
298
|
+
{ method: "POST", path: `/project/${slug}/pipeline`, body: { ... } },
|
|
299
299
|
{ response: PipelineSchema }
|
|
300
300
|
);
|
|
301
301
|
```
|
|
@@ -317,13 +317,13 @@ const slug = "gl/my-group/my-repo";
|
|
|
317
317
|
|
|
318
318
|
### API Version in Path
|
|
319
319
|
|
|
320
|
-
|
|
320
|
+
The base URL already includes `/api/v2`, so do not repeat it in paths:
|
|
321
321
|
|
|
322
322
|
```typescript
|
|
323
|
-
//
|
|
323
|
+
// CORRECT - No version prefix (base URL already has /api/v2)
|
|
324
324
|
const path = `/project/${slug}/pipeline`;
|
|
325
325
|
|
|
326
|
-
//
|
|
326
|
+
// WRONG - Duplicates version from base URL
|
|
327
327
|
const path = `/api/v2/project/${slug}/pipeline`;
|
|
328
328
|
```
|
|
329
329
|
|
|
@@ -406,7 +406,7 @@ async function getAllPipelines(circleci: CircleCIClient, projectSlug: string) {
|
|
|
406
406
|
const result = await ctx.integrations.circleci.apiRequest(
|
|
407
407
|
{
|
|
408
408
|
method: "GET",
|
|
409
|
-
path: `/
|
|
409
|
+
path: `/project/${projectSlug}/pipeline`,
|
|
410
410
|
params: pageToken ? { "page-token": pageToken } : {},
|
|
411
411
|
},
|
|
412
412
|
{ response: ListPipelinesResponseSchema },
|
|
@@ -429,7 +429,7 @@ When rerunning workflows:
|
|
|
429
429
|
await ctx.integrations.circleci.apiRequest(
|
|
430
430
|
{
|
|
431
431
|
method: "POST",
|
|
432
|
-
path: `/
|
|
432
|
+
path: `/workflow/${workflowId}/rerun`,
|
|
433
433
|
body: {
|
|
434
434
|
from_failed: false, // Rerun everything
|
|
435
435
|
},
|
|
@@ -441,7 +441,7 @@ await ctx.integrations.circleci.apiRequest(
|
|
|
441
441
|
await ctx.integrations.circleci.apiRequest(
|
|
442
442
|
{
|
|
443
443
|
method: "POST",
|
|
444
|
-
path: `/
|
|
444
|
+
path: `/workflow/${workflowId}/rerun`,
|
|
445
445
|
body: {
|
|
446
446
|
from_failed: true, // Only failed jobs
|
|
447
447
|
},
|
|
@@ -457,7 +457,7 @@ import { RestApiValidationError } from "@superblocksteam/sdk-api";
|
|
|
457
457
|
|
|
458
458
|
try {
|
|
459
459
|
const result = await ctx.integrations.circleci.apiRequest(
|
|
460
|
-
{ method: "POST", path: `/
|
|
460
|
+
{ method: "POST", path: `/project/${slug}/pipeline`, body: { ... } },
|
|
461
461
|
{ response: PipelineSchema }
|
|
462
462
|
);
|
|
463
463
|
} catch (error) {
|