@superblocksteam/sdk-api 2.0.99 → 2.0.100-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/dist/files.d.ts +68 -0
- package/dist/files.d.ts.map +1 -0
- package/dist/files.js +42 -0
- package/dist/files.js.map +1 -0
- package/dist/index.d.ts +7 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -1
- package/dist/index.js.map +1 -1
- package/dist/integrations/base/rest-api-integration-client.d.ts.map +1 -1
- package/dist/integrations/base/rest-api-integration-client.js +6 -35
- package/dist/integrations/base/rest-api-integration-client.js.map +1 -1
- package/dist/integrations/cosmosdb/client.d.ts.map +1 -1
- package/dist/integrations/cosmosdb/client.js +30 -63
- package/dist/integrations/cosmosdb/client.js.map +1 -1
- package/dist/integrations/cosmosdb/client.test.d.ts +8 -0
- package/dist/integrations/cosmosdb/client.test.d.ts.map +1 -0
- package/dist/integrations/cosmosdb/client.test.js +141 -0
- package/dist/integrations/cosmosdb/client.test.js.map +1 -0
- package/dist/integrations/declarations.d.ts +106 -66
- package/dist/integrations/declarations.d.ts.map +1 -1
- package/dist/integrations/declarations.js +33 -0
- package/dist/integrations/declarations.js.map +1 -1
- package/dist/integrations/declarations.test.d.ts +2 -0
- package/dist/integrations/declarations.test.d.ts.map +1 -0
- package/dist/integrations/declarations.test.js +40 -0
- package/dist/integrations/declarations.test.js.map +1 -0
- package/dist/integrations/gcs/client.d.ts.map +1 -1
- package/dist/integrations/gcs/client.js +1 -1
- package/dist/integrations/gcs/client.js.map +1 -1
- package/dist/integrations/index.d.ts +3 -1
- package/dist/integrations/index.d.ts.map +1 -1
- package/dist/integrations/index.js +2 -1
- package/dist/integrations/index.js.map +1 -1
- package/dist/integrations/python/client.test.js +1 -3
- package/dist/integrations/python/client.test.js.map +1 -1
- package/dist/integrations/redis/client.d.ts.map +1 -1
- package/dist/integrations/redis/client.js +8 -1
- package/dist/integrations/redis/client.js.map +1 -1
- package/dist/integrations/registry.d.ts +1 -0
- package/dist/integrations/registry.d.ts.map +1 -1
- package/dist/integrations/registry.js +6 -0
- package/dist/integrations/registry.js.map +1 -1
- package/dist/integrations/restapiintegration/client.d.ts +19 -0
- package/dist/integrations/restapiintegration/client.d.ts.map +1 -0
- package/dist/integrations/restapiintegration/client.js +18 -0
- package/dist/integrations/restapiintegration/client.js.map +1 -0
- package/dist/integrations/restapiintegration/index.d.ts +6 -0
- package/dist/integrations/restapiintegration/index.d.ts.map +1 -0
- package/dist/integrations/restapiintegration/index.js +5 -0
- package/dist/integrations/restapiintegration/index.js.map +1 -0
- package/dist/integrations/restapiintegration/types.d.ts +33 -0
- package/dist/integrations/restapiintegration/types.d.ts.map +1 -0
- package/dist/integrations/restapiintegration/types.js +5 -0
- package/dist/integrations/restapiintegration/types.js.map +1 -0
- package/dist/integrations/snowflake/types.d.ts +4 -4
- package/package.json +3 -2
- package/src/files.ts +54 -0
- package/src/index.ts +21 -0
- package/src/integrations/base/rest-api-integration-client.ts +6 -43
- package/src/integrations/cosmosdb/client.test.ts +209 -0
- package/src/integrations/cosmosdb/client.ts +66 -75
- package/src/integrations/declarations.test.ts +64 -0
- package/src/integrations/declarations.ts +231 -134
- package/src/integrations/gcs/client.ts +1 -5
- package/src/integrations/index.ts +6 -0
- package/src/integrations/python/client.test.ts +5 -3
- package/src/integrations/redis/client.ts +10 -1
- package/src/integrations/registry.ts +11 -0
- package/src/integrations/restapiintegration/client.ts +21 -0
- package/src/integrations/restapiintegration/index.ts +6 -0
- package/src/integrations/restapiintegration/types.ts +40 -0
- package/src/integrations/snowflake/README.md +7 -7
- package/src/integrations/snowflake/types.ts +4 -4
|
@@ -127,11 +127,7 @@ export class GCSClientImpl implements GCSClient, IntegrationClientImpl {
|
|
|
127
127
|
request.prefix = options.prefix;
|
|
128
128
|
}
|
|
129
129
|
|
|
130
|
-
const result = await this.execute(
|
|
131
|
-
"LIST_BUCKET_OBJECTS",
|
|
132
|
-
request,
|
|
133
|
-
metadata,
|
|
134
|
-
);
|
|
130
|
+
const result = await this.execute("LIST_OBJECTS", request, metadata);
|
|
135
131
|
return this.validate(result, schema, "listObjects");
|
|
136
132
|
});
|
|
137
133
|
}
|
|
@@ -81,6 +81,7 @@ export {
|
|
|
81
81
|
lakebase,
|
|
82
82
|
snowflakePostgres,
|
|
83
83
|
smtp,
|
|
84
|
+
restApiIntegration,
|
|
84
85
|
// Utility functions
|
|
85
86
|
extractIntegrationDeclarations,
|
|
86
87
|
getIntegrationDeclarations,
|
|
@@ -157,6 +158,7 @@ export {
|
|
|
157
158
|
type LakebaseRef,
|
|
158
159
|
type SnowflakePostgresRef,
|
|
159
160
|
type SmtpRef,
|
|
161
|
+
type RestApiIntegrationRef,
|
|
160
162
|
} from "./declarations.js";
|
|
161
163
|
|
|
162
164
|
// Registry and factory
|
|
@@ -467,4 +469,8 @@ export { SnowflakePostgresClientImpl } from "./snowflakepostgres/index.js";
|
|
|
467
469
|
export type { SmtpClient, SmtpSendOptions } from "./smtp/index.js";
|
|
468
470
|
export { SmtpClientImpl } from "./smtp/index.js";
|
|
469
471
|
|
|
472
|
+
// REST API Integration client
|
|
473
|
+
export type { RestApiIntegrationPluginClient } from "./restapiintegration/index.js";
|
|
474
|
+
export { RestApiIntegrationPluginClientImpl } from "./restapiintegration/index.js";
|
|
475
|
+
|
|
470
476
|
// Confluent and Redpanda reuse the Kafka client (same proto)
|
|
@@ -36,9 +36,11 @@ describe("PythonClientImpl", () => {
|
|
|
36
36
|
z.object({ result: z.number() }),
|
|
37
37
|
);
|
|
38
38
|
|
|
39
|
-
expect(mockExecutor).toHaveBeenCalledWith(
|
|
40
|
-
body: 'return {"result": 42}',
|
|
41
|
-
|
|
39
|
+
expect(mockExecutor).toHaveBeenCalledWith(
|
|
40
|
+
{ body: 'return {"result": 42}' },
|
|
41
|
+
undefined,
|
|
42
|
+
undefined,
|
|
43
|
+
);
|
|
42
44
|
});
|
|
43
45
|
|
|
44
46
|
it("injects string bindings as Python variables", async () => {
|
|
@@ -103,7 +103,16 @@ export class RedisClientImpl implements RedisClient, IntegrationClientImpl {
|
|
|
103
103
|
metadata?: TraceMetadata,
|
|
104
104
|
): Promise<T> {
|
|
105
105
|
const request = buildRawRequest(command);
|
|
106
|
-
const
|
|
106
|
+
const rawResult = await this.exec(request, "command", metadata);
|
|
107
|
+
|
|
108
|
+
// The Redis plugin wraps raw command results in { response: ... }.
|
|
109
|
+
// Unwrap to the actual value so callers can validate against the expected type.
|
|
110
|
+
const result =
|
|
111
|
+
rawResult !== null &&
|
|
112
|
+
typeof rawResult === "object" &&
|
|
113
|
+
"response" in (rawResult as object)
|
|
114
|
+
? (rawResult as { response: unknown }).response
|
|
115
|
+
: rawResult;
|
|
107
116
|
|
|
108
117
|
const parseResult = schema.safeParse(result);
|
|
109
118
|
|
|
@@ -71,6 +71,8 @@ import { SuperblocksOCRClientImpl } from "./superblocks-ocr/index.js";
|
|
|
71
71
|
import { LakebaseClientImpl } from "./lakebase/index.js";
|
|
72
72
|
import { SnowflakePostgresClientImpl } from "./snowflakepostgres/index.js";
|
|
73
73
|
import { SmtpClientImpl } from "./smtp/index.js";
|
|
74
|
+
// REST API plugins
|
|
75
|
+
import { RestApiIntegrationPluginClientImpl } from "./restapiintegration/index.js";
|
|
74
76
|
// Code execution clients
|
|
75
77
|
import { PythonClientImpl } from "./python/index.js";
|
|
76
78
|
|
|
@@ -148,6 +150,8 @@ export const SUPPORTED_PLUGINS = {
|
|
|
148
150
|
snowflakepostgres: "snowflakepostgres",
|
|
149
151
|
// Email
|
|
150
152
|
smtp: "smtp",
|
|
153
|
+
// REST API plugins
|
|
154
|
+
restapiintegration: "restapiintegration",
|
|
151
155
|
// Code execution
|
|
152
156
|
python: "python",
|
|
153
157
|
} as const;
|
|
@@ -514,6 +518,13 @@ export function createClient(
|
|
|
514
518
|
case SUPPORTED_PLUGINS.smtp:
|
|
515
519
|
return new SmtpClientImpl(config, executeQuery);
|
|
516
520
|
|
|
521
|
+
case SUPPORTED_PLUGINS.restapiintegration:
|
|
522
|
+
return new RestApiIntegrationPluginClientImpl(
|
|
523
|
+
config,
|
|
524
|
+
executeQuery,
|
|
525
|
+
executeStreamingQuery,
|
|
526
|
+
);
|
|
527
|
+
|
|
517
528
|
case SUPPORTED_PLUGINS.python:
|
|
518
529
|
return new PythonClientImpl(config, executeQuery);
|
|
519
530
|
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* REST API Integration client implementation.
|
|
3
|
+
*
|
|
4
|
+
* Uses the proto-generated REST API Integration Plugin type from @superblocksteam/types.
|
|
5
|
+
* This is the generic REST API Integration plugin that users configure with a base URL
|
|
6
|
+
* and authentication in the integrations page.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import { RestApiIntegrationClient } from "../base/index.js";
|
|
10
|
+
import type { RestApiIntegrationPluginClient } from "./types.js";
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Internal implementation of RestApiIntegrationPluginClient.
|
|
14
|
+
*
|
|
15
|
+
* Extends RestApiIntegrationClient to inherit the generic apiRequest() method.
|
|
16
|
+
* At runtime, the orchestrator handles base URL resolution, authentication,
|
|
17
|
+
* and API request execution.
|
|
18
|
+
*/
|
|
19
|
+
export class RestApiIntegrationPluginClientImpl
|
|
20
|
+
extends RestApiIntegrationClient
|
|
21
|
+
implements RestApiIntegrationPluginClient {}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* REST API Integration client types.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import type { BaseIntegrationClient } from "../../types.js";
|
|
6
|
+
import type {
|
|
7
|
+
SupportsApiRequest,
|
|
8
|
+
SupportsStreamingApiRequest,
|
|
9
|
+
} from "../base/index.js";
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* REST API Integration client for making HTTP requests to configured endpoints.
|
|
13
|
+
*
|
|
14
|
+
* This is the generic REST API Integration plugin. Use apiRequest() to make
|
|
15
|
+
* HTTP calls to any endpoint configured on the integration (base URL, auth, etc.).
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* ```typescript
|
|
19
|
+
* // Declare in api(): integrations: { myApi: restApiIntegration(INTEGRATION_ID) }
|
|
20
|
+
* // In run(), access via: ctx.integrations.myApi
|
|
21
|
+
*
|
|
22
|
+
* const ResponseSchema = z.object({
|
|
23
|
+
* data: z.array(z.object({ id: z.string(), name: z.string() })),
|
|
24
|
+
* });
|
|
25
|
+
*
|
|
26
|
+
* const result = await ctx.integrations.myApi.apiRequest(
|
|
27
|
+
* {
|
|
28
|
+
* method: 'GET',
|
|
29
|
+
* path: '/users',
|
|
30
|
+
* params: { limit: 10 },
|
|
31
|
+
* },
|
|
32
|
+
* { response: ResponseSchema },
|
|
33
|
+
* );
|
|
34
|
+
* ```
|
|
35
|
+
*/
|
|
36
|
+
export interface RestApiIntegrationPluginClient
|
|
37
|
+
extends
|
|
38
|
+
BaseIntegrationClient,
|
|
39
|
+
SupportsApiRequest,
|
|
40
|
+
SupportsStreamingApiRequest {}
|
|
@@ -40,7 +40,7 @@ export default api({
|
|
|
40
40
|
}),
|
|
41
41
|
async run(ctx, { status }) {
|
|
42
42
|
const users = await ctx.integrations.snowflake.query(
|
|
43
|
-
"SELECT ID, NAME, EMAIL, CREATED_AT FROM USERS WHERE STATUS =
|
|
43
|
+
"SELECT ID, NAME, EMAIL, CREATED_AT FROM USERS WHERE STATUS = ?",
|
|
44
44
|
UserSchema,
|
|
45
45
|
[status],
|
|
46
46
|
);
|
|
@@ -66,7 +66,7 @@ const users = await ctx.integrations.snowflake.query(
|
|
|
66
66
|
NAME as "name",
|
|
67
67
|
EMAIL as "email"
|
|
68
68
|
FROM USERS
|
|
69
|
-
WHERE STATUS =
|
|
69
|
+
WHERE STATUS = ?`,
|
|
70
70
|
UserSchema,
|
|
71
71
|
["active"],
|
|
72
72
|
);
|
|
@@ -77,13 +77,13 @@ const users = await ctx.integrations.snowflake.query(
|
|
|
77
77
|
```typescript
|
|
78
78
|
// INSERT
|
|
79
79
|
await ctx.integrations.snowflake.execute(
|
|
80
|
-
"INSERT INTO USERS (NAME, EMAIL) VALUES (
|
|
80
|
+
"INSERT INTO USERS (NAME, EMAIL) VALUES (?, ?)",
|
|
81
81
|
["John Doe", "john@example.com"],
|
|
82
82
|
);
|
|
83
83
|
|
|
84
84
|
// UPDATE
|
|
85
85
|
const updateResult = await ctx.integrations.snowflake.execute(
|
|
86
|
-
"UPDATE USERS SET LAST_LOGIN = CURRENT_TIMESTAMP() WHERE ID =
|
|
86
|
+
"UPDATE USERS SET LAST_LOGIN = CURRENT_TIMESTAMP() WHERE ID = ?",
|
|
87
87
|
[userId],
|
|
88
88
|
);
|
|
89
89
|
console.log(`Updated ${updateResult.rowCount} rows`);
|
|
@@ -137,7 +137,7 @@ const events = await ctx.integrations.snowflake.query(
|
|
|
137
137
|
EVENT_TYPE,
|
|
138
138
|
PARSE_JSON(PAYLOAD) as PAYLOAD
|
|
139
139
|
FROM EVENTS
|
|
140
|
-
WHERE EVENT_TYPE =
|
|
140
|
+
WHERE EVENT_TYPE = ?`,
|
|
141
141
|
EventSchema,
|
|
142
142
|
["user_action"],
|
|
143
143
|
);
|
|
@@ -212,7 +212,7 @@ const stats = await ctx.integrations.snowflake.query(
|
|
|
212
212
|
SUM(AMOUNT) as TOTAL_REVENUE,
|
|
213
213
|
AVG(AMOUNT) as AVG_ORDER_VALUE
|
|
214
214
|
FROM ORDERS
|
|
215
|
-
WHERE CREATED_AT >
|
|
215
|
+
WHERE CREATED_AT > ?`,
|
|
216
216
|
StatsSchema,
|
|
217
217
|
[startDate],
|
|
218
218
|
);
|
|
@@ -249,7 +249,7 @@ const users = await ctx.integrations.snowflake.query("SELECT * FROM USERS", [
|
|
|
249
249
|
|
|
250
250
|
// CORRECT - Schema is required as second parameter
|
|
251
251
|
const users = await ctx.integrations.snowflake.query(
|
|
252
|
-
"SELECT * FROM USERS WHERE ID =
|
|
252
|
+
"SELECT * FROM USERS WHERE ID = ?",
|
|
253
253
|
UserSchema,
|
|
254
254
|
[userId],
|
|
255
255
|
);
|
|
@@ -24,7 +24,7 @@ import type { TraceMetadata } from "../registry.js";
|
|
|
24
24
|
* });
|
|
25
25
|
*
|
|
26
26
|
* const users = await snowflake.query(
|
|
27
|
-
* 'SELECT * FROM users WHERE status =
|
|
27
|
+
* 'SELECT * FROM users WHERE status = ?',
|
|
28
28
|
* UserSchema,
|
|
29
29
|
* ['active']
|
|
30
30
|
* );
|
|
@@ -34,7 +34,7 @@ export interface SnowflakeClient extends BaseIntegrationClient {
|
|
|
34
34
|
/**
|
|
35
35
|
* Execute a SQL query and validate results against a Zod schema.
|
|
36
36
|
*
|
|
37
|
-
* @param sql - SQL query string (use
|
|
37
|
+
* @param sql - SQL query string (use ? placeholders for parameters)
|
|
38
38
|
* @param schema - Zod schema to validate the query results
|
|
39
39
|
* @param params - Optional query parameters
|
|
40
40
|
* @returns Promise resolving to validated query results
|
|
@@ -51,7 +51,7 @@ export interface SnowflakeClient extends BaseIntegrationClient {
|
|
|
51
51
|
* });
|
|
52
52
|
*
|
|
53
53
|
* const users = await snowflake.query(
|
|
54
|
-
* 'SELECT * FROM users WHERE status =
|
|
54
|
+
* 'SELECT * FROM users WHERE status = ?',
|
|
55
55
|
* UserSchema,
|
|
56
56
|
* ['active']
|
|
57
57
|
* );
|
|
@@ -74,7 +74,7 @@ export interface SnowflakeClient extends BaseIntegrationClient {
|
|
|
74
74
|
* @example
|
|
75
75
|
* ```typescript
|
|
76
76
|
* const result = await snowflake.execute(
|
|
77
|
-
* 'UPDATE users SET last_login = CURRENT_TIMESTAMP() WHERE id =
|
|
77
|
+
* 'UPDATE users SET last_login = CURRENT_TIMESTAMP() WHERE id = ?',
|
|
78
78
|
* [userId]
|
|
79
79
|
* );
|
|
80
80
|
* console.log(`Updated ${result.rowCount} rows`);
|