@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.
Files changed (182) hide show
  1. package/README.md +439 -89
  2. package/dist/api/definition.d.ts +11 -6
  3. package/dist/api/definition.d.ts.map +1 -1
  4. package/dist/api/definition.js +19 -12
  5. package/dist/api/definition.js.map +1 -1
  6. package/dist/api/definition.test.js +39 -15
  7. package/dist/api/definition.test.js.map +1 -1
  8. package/dist/errors.d.ts +1 -1
  9. package/dist/errors.js +1 -1
  10. package/dist/index.d.ts +10 -11
  11. package/dist/index.d.ts.map +1 -1
  12. package/dist/index.js +9 -5
  13. package/dist/index.js.map +1 -1
  14. package/dist/integrations/base/index.d.ts +2 -1
  15. package/dist/integrations/base/index.d.ts.map +1 -1
  16. package/dist/integrations/base/index.js +1 -0
  17. package/dist/integrations/base/index.js.map +1 -1
  18. package/dist/integrations/base/rest-api-client-base.d.ts +48 -0
  19. package/dist/integrations/base/rest-api-client-base.d.ts.map +1 -0
  20. package/dist/integrations/base/rest-api-client-base.js +98 -0
  21. package/dist/integrations/base/rest-api-client-base.js.map +1 -0
  22. package/dist/integrations/base/rest-api-integration-client.d.ts +10 -20
  23. package/dist/integrations/base/rest-api-integration-client.d.ts.map +1 -1
  24. package/dist/integrations/base/rest-api-integration-client.js +10 -65
  25. package/dist/integrations/base/rest-api-integration-client.js.map +1 -1
  26. package/dist/integrations/box/types.d.ts +1 -1
  27. package/dist/integrations/declarations.d.ts +5 -73
  28. package/dist/integrations/declarations.d.ts.map +1 -1
  29. package/dist/integrations/declarations.js +5 -68
  30. package/dist/integrations/declarations.js.map +1 -1
  31. package/dist/integrations/documentation.test.js +0 -2
  32. package/dist/integrations/documentation.test.js.map +1 -1
  33. package/dist/integrations/googledrive/types.d.ts +1 -1
  34. package/dist/integrations/index.d.ts +1 -11
  35. package/dist/integrations/index.d.ts.map +1 -1
  36. package/dist/integrations/index.js +1 -7
  37. package/dist/integrations/index.js.map +1 -1
  38. package/dist/integrations/registry.d.ts +1 -11
  39. package/dist/integrations/registry.d.ts.map +1 -1
  40. package/dist/integrations/registry.js +0 -29
  41. package/dist/integrations/registry.js.map +1 -1
  42. package/dist/integrations/slack/client.d.ts +13 -9
  43. package/dist/integrations/slack/client.d.ts.map +1 -1
  44. package/dist/integrations/slack/client.js +60 -8
  45. package/dist/integrations/slack/client.js.map +1 -1
  46. package/dist/integrations/slack/client.test.d.ts +11 -0
  47. package/dist/integrations/slack/client.test.d.ts.map +1 -0
  48. package/dist/integrations/slack/client.test.js +368 -0
  49. package/dist/integrations/slack/client.test.js.map +1 -0
  50. package/dist/integrations/slack/index.d.ts +2 -1
  51. package/dist/integrations/slack/index.d.ts.map +1 -1
  52. package/dist/integrations/slack/index.js +1 -0
  53. package/dist/integrations/slack/index.js.map +1 -1
  54. package/dist/integrations/slack/types.d.ts +127 -28
  55. package/dist/integrations/slack/types.d.ts.map +1 -1
  56. package/dist/integrations/slack/types.js +27 -1
  57. package/dist/integrations/slack/types.js.map +1 -1
  58. package/dist/integrations/snowflake/client.d.ts +2 -2
  59. package/dist/integrations/snowflake/client.js +2 -2
  60. package/dist/runtime/context.d.ts +1 -1
  61. package/dist/runtime/executor.d.ts +2 -2
  62. package/dist/types.d.ts +15 -6
  63. package/dist/types.d.ts.map +1 -1
  64. package/package.json +2 -2
  65. package/src/api/definition.test.ts +40 -15
  66. package/src/api/definition.ts +19 -12
  67. package/src/errors.ts +1 -1
  68. package/src/index.ts +13 -33
  69. package/src/integrations/asana/README.md +12 -12
  70. package/src/integrations/base/index.ts +2 -1
  71. package/src/integrations/base/rest-api-client-base.ts +134 -0
  72. package/src/integrations/base/rest-api-integration-client.ts +12 -89
  73. package/src/integrations/bitbucket/README.md +19 -19
  74. package/src/integrations/box/README.md +24 -24
  75. package/src/integrations/box/types.ts +1 -1
  76. package/src/integrations/circleci/README.md +18 -18
  77. package/src/integrations/declarations.ts +5 -105
  78. package/src/integrations/documentation.test.ts +0 -2
  79. package/src/integrations/googledrive/README.md +25 -22
  80. package/src/integrations/googledrive/types.ts +1 -1
  81. package/src/integrations/graphql/README.md +2 -2
  82. package/src/integrations/groq/README.md +8 -8
  83. package/src/integrations/index.ts +0 -51
  84. package/src/integrations/mongodb/README.md +65 -12
  85. package/src/integrations/perplexity/README.md +39 -48
  86. package/src/integrations/registry.ts +1 -39
  87. package/src/integrations/salesforce/README.md +11 -9
  88. package/src/integrations/slack/README.md +62 -19
  89. package/src/integrations/slack/client.test.ts +553 -0
  90. package/src/integrations/slack/client.ts +92 -12
  91. package/src/integrations/slack/index.ts +6 -1
  92. package/src/integrations/slack/types.ts +142 -29
  93. package/src/integrations/snowflake/client.ts +2 -2
  94. package/src/integrations/zoom/README.md +15 -15
  95. package/src/runtime/context.ts +1 -1
  96. package/src/runtime/executor.ts +2 -2
  97. package/src/types.ts +15 -6
  98. package/dist/integrations/couchbase/client.d.ts +0 -36
  99. package/dist/integrations/couchbase/client.d.ts.map +0 -1
  100. package/dist/integrations/couchbase/client.js +0 -148
  101. package/dist/integrations/couchbase/client.js.map +0 -1
  102. package/dist/integrations/couchbase/index.d.ts +0 -8
  103. package/dist/integrations/couchbase/index.d.ts.map +0 -1
  104. package/dist/integrations/couchbase/index.js +0 -7
  105. package/dist/integrations/couchbase/index.js.map +0 -1
  106. package/dist/integrations/couchbase/types.d.ts +0 -100
  107. package/dist/integrations/couchbase/types.d.ts.map +0 -1
  108. package/dist/integrations/couchbase/types.js +0 -5
  109. package/dist/integrations/couchbase/types.js.map +0 -1
  110. package/dist/integrations/kafka/client.d.ts +0 -25
  111. package/dist/integrations/kafka/client.d.ts.map +0 -1
  112. package/dist/integrations/kafka/client.js +0 -124
  113. package/dist/integrations/kafka/client.js.map +0 -1
  114. package/dist/integrations/kafka/index.d.ts +0 -8
  115. package/dist/integrations/kafka/index.d.ts.map +0 -1
  116. package/dist/integrations/kafka/index.js +0 -7
  117. package/dist/integrations/kafka/index.js.map +0 -1
  118. package/dist/integrations/kafka/types.d.ts +0 -113
  119. package/dist/integrations/kafka/types.d.ts.map +0 -1
  120. package/dist/integrations/kafka/types.js +0 -5
  121. package/dist/integrations/kafka/types.js.map +0 -1
  122. package/dist/integrations/kinesis/client.d.ts +0 -31
  123. package/dist/integrations/kinesis/client.d.ts.map +0 -1
  124. package/dist/integrations/kinesis/client.js +0 -101
  125. package/dist/integrations/kinesis/client.js.map +0 -1
  126. package/dist/integrations/kinesis/index.d.ts +0 -8
  127. package/dist/integrations/kinesis/index.d.ts.map +0 -1
  128. package/dist/integrations/kinesis/index.js +0 -7
  129. package/dist/integrations/kinesis/index.js.map +0 -1
  130. package/dist/integrations/kinesis/types.d.ts +0 -97
  131. package/dist/integrations/kinesis/types.d.ts.map +0 -1
  132. package/dist/integrations/kinesis/types.js +0 -7
  133. package/dist/integrations/kinesis/types.js.map +0 -1
  134. package/dist/integrations/python/client.d.ts +0 -42
  135. package/dist/integrations/python/client.d.ts.map +0 -1
  136. package/dist/integrations/python/client.js +0 -89
  137. package/dist/integrations/python/client.js.map +0 -1
  138. package/dist/integrations/python/client.test.d.ts +0 -5
  139. package/dist/integrations/python/client.test.d.ts.map +0 -1
  140. package/dist/integrations/python/client.test.js +0 -214
  141. package/dist/integrations/python/client.test.js.map +0 -1
  142. package/dist/integrations/python/index.d.ts +0 -6
  143. package/dist/integrations/python/index.d.ts.map +0 -1
  144. package/dist/integrations/python/index.js +0 -5
  145. package/dist/integrations/python/index.js.map +0 -1
  146. package/dist/integrations/python/types.d.ts +0 -85
  147. package/dist/integrations/python/types.d.ts.map +0 -1
  148. package/dist/integrations/python/types.js +0 -5
  149. package/dist/integrations/python/types.js.map +0 -1
  150. package/dist/integrations/redis/client.d.ts +0 -43
  151. package/dist/integrations/redis/client.d.ts.map +0 -1
  152. package/dist/integrations/redis/client.js +0 -142
  153. package/dist/integrations/redis/client.js.map +0 -1
  154. package/dist/integrations/redis/index.d.ts +0 -8
  155. package/dist/integrations/redis/index.d.ts.map +0 -1
  156. package/dist/integrations/redis/index.js +0 -7
  157. package/dist/integrations/redis/index.js.map +0 -1
  158. package/dist/integrations/redis/types.d.ts +0 -137
  159. package/dist/integrations/redis/types.d.ts.map +0 -1
  160. package/dist/integrations/redis/types.js +0 -5
  161. package/dist/integrations/redis/types.js.map +0 -1
  162. package/src/integrations/couchbase/README.md +0 -138
  163. package/src/integrations/couchbase/client.ts +0 -225
  164. package/src/integrations/couchbase/index.ts +0 -8
  165. package/src/integrations/couchbase/types.ts +0 -126
  166. package/src/integrations/kafka/README.md +0 -144
  167. package/src/integrations/kafka/client.ts +0 -216
  168. package/src/integrations/kafka/index.ts +0 -14
  169. package/src/integrations/kafka/types.ts +0 -128
  170. package/src/integrations/kinesis/README.md +0 -153
  171. package/src/integrations/kinesis/client.ts +0 -146
  172. package/src/integrations/kinesis/index.ts +0 -14
  173. package/src/integrations/kinesis/types.ts +0 -114
  174. package/src/integrations/python/README.md +0 -566
  175. package/src/integrations/python/client.test.ts +0 -341
  176. package/src/integrations/python/client.ts +0 -136
  177. package/src/integrations/python/index.ts +0 -6
  178. package/src/integrations/python/types.ts +0 -92
  179. package/src/integrations/redis/README.md +0 -200
  180. package/src/integrations/redis/client.ts +0 -208
  181. package/src/integrations/redis/index.ts +0 -8
  182. package/src/integrations/redis/types.ts +0 -167
@@ -1,58 +1,33 @@
1
1
  /**
2
- * Base client for REST API Integration (OpenAPI) based integrations.
2
+ * Generic REST API Integration client with Zod response validation.
3
3
  *
4
- * Provides common apiRequest() method for all OpenAPI-based plugins.
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 { QueryExecutor, TraceMetadata } from "../registry.js";
15
- import type { IntegrationConfig, IntegrationClientImpl } from "../types.js";
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 extend this class to inherit
28
- * the generic apiRequest() method with runtime schema validation.
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
- implements IntegrationClientImpl, SupportsApiRequest
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
- // Validate request body against schema if both are present.
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: `/2.0/repositories/${workspace}`,
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: `/2.0/repositories/${workspace}/${repoSlug}`,
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: `/2.0/repositories/${workspace}/${repoSlug}/pullrequests`,
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: `/2.0/repositories/${workspace}/${repoSlug}/pullrequests`,
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: `/2.0/repositories/${workspace}/${repoSlug}/pullrequests/${prId}/merge`,
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: `/2.0/repositories/${workspace}/${repoSlug}/commits`,
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: `/2.0/repositories/${workspace}/${repoSlug}/refs/branches`,
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: `/2.0/repositories/${workspace}/${repoSlug}/src/main/README.md`,
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: `/2.0/repositories/${workspace}/${repoSlug}/pullrequests/${prId}/comments`,
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: `/2.0/repositories/${workspace}/${repo}/pullrequests`, body: { ... } },
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
- Always include `/2.0/` prefix:
310
+ The base URL already includes `/2.0`, so do not repeat it in paths:
311
311
 
312
312
  ```typescript
313
- // WRONG - Missing version
313
+ // CORRECT - No version prefix (base URL already has /2.0)
314
314
  const path = `/repositories/${workspace}/${repo}`;
315
315
 
316
- // CORRECT - Include version
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 = `/2.0/repositories/myworkspace/myrepo`;
326
+ const path = `/repositories/myworkspace/myrepo`;
327
327
 
328
328
  // Can also be username for personal repos
329
- const path = `/2.0/repositories/myusername/myrepo`;
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 = `/2.0/repositories/${workspace}/${repo}/pullrequests`;
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 = `/2.0/repositories/${workspace}/${repo}/src/${branchName}/file.txt`;
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: `/2.0/repositories/${workspace}/${repo}/src/main/file.txt`,
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: `/2.0/repositories/${workspace}/${repo}` },
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: `/2.0/folders/${folderId}/items`,
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: `/2.0/files/${fileId}`,
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: `/2.0/files/${fileId}/content`,
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: "/2.0/files/content",
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: "/2.0/folders",
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: `/2.0/files/${fileId}/copy`,
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: `/2.0/files/${fileId}`,
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: `/2.0/files/${fileId}`,
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: `/2.0/files/${fileId}`,
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: `/2.0/files/${fileId}`,
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: "/2.0/search",
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: "/2.0/comments",
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: `/2.0/folders/${folderId}/items`, params: { ... } },
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
- Box API paths include version:
410
+ The base URL already includes `/2.0`, so do not repeat it in paths:
411
411
 
412
412
  ```typescript
413
- // CORRECT - Include version
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: `/2.0/files/${fileId}` },
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: `/2.0/files/${fileId}`,
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: `/2.0/files/${fileId}`,
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: `/2.0/folders/${folderId}/items`,
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: `/2.0/folders/${folderId}/items`, params: { ... } },
560
+ { method: "GET", path: `/folders/${folderId}/items`, params: { ... } },
561
561
  { response: ListItemsResponseSchema }
562
562
  );
563
563
  } catch (error) {
@@ -24,7 +24,7 @@ import type { SupportsApiRequest } from "../base/index.js";
24
24
  * const result = await box.apiRequest(
25
25
  * {
26
26
  * method: 'GET',
27
- * path: '/2.0/folders/0',
27
+ * path: '/folders/0',
28
28
  * },
29
29
  * { response: ResponseSchema }
30
30
  * );
@@ -51,7 +51,7 @@ export default api({
51
51
  const result = await ctx.integrations.circleci.apiRequest(
52
52
  {
53
53
  method: "POST",
54
- path: `/api/v2/project/${projectSlug}/pipeline`,
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: `/api/v2/pipeline/${pipelineId}`,
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: `/api/v2/pipeline/${pipelineId}/workflow`,
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: `/api/v2/workflow/${workflowId}/job`,
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: `/api/v2/project/${projectSlug}/job/${jobNumber}`,
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: `/api/v2/workflow/${workflowId}/rerun`,
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: `/api/v2/workflow/${workflowId}/cancel`,
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: `/api/v2/project/${projectSlug}/pipeline`,
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: `/api/v2/project/${projectSlug}`,
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: `/api/v2/project/${projectSlug}/${jobNumber}/artifacts`,
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: `/api/v2/project/${slug}/pipeline`, body: { ... } },
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
- Always include `/api/v2/`:
320
+ The base URL already includes `/api/v2`, so do not repeat it in paths:
321
321
 
322
322
  ```typescript
323
- // WRONG
323
+ // CORRECT - No version prefix (base URL already has /api/v2)
324
324
  const path = `/project/${slug}/pipeline`;
325
325
 
326
- // CORRECT
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: `/api/v2/project/${projectSlug}/pipeline`,
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: `/api/v2/workflow/${workflowId}/rerun`,
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: `/api/v2/workflow/${workflowId}/rerun`,
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: `/api/v2/project/${slug}/pipeline`, body: { ... } },
460
+ { method: "POST", path: `/project/${slug}/pipeline`, body: { ... } },
461
461
  { response: PipelineSchema }
462
462
  );
463
463
  } catch (error) {