@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
|
@@ -97,24 +97,24 @@ export class CosmosDBClientImpl
|
|
|
97
97
|
options?: CosmosDBQueryOptions,
|
|
98
98
|
metadata?: TraceMetadata,
|
|
99
99
|
): Promise<T> {
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
crossPartition: options?.crossPartition ?? false,
|
|
110
|
-
partitionKey: options?.partitionKey,
|
|
111
|
-
},
|
|
112
|
-
},
|
|
100
|
+
// Proto JSON format for: oneof cosmosdb_action { Sql sql = 5; }
|
|
101
|
+
// Sql.oneof action { Singleton singleton = 1; }
|
|
102
|
+
const request = {
|
|
103
|
+
sql: {
|
|
104
|
+
singleton: {
|
|
105
|
+
containerId,
|
|
106
|
+
query: sql,
|
|
107
|
+
crossPartition: options?.crossPartition ?? false,
|
|
108
|
+
partitionKey: options?.partitionKey,
|
|
113
109
|
},
|
|
114
110
|
},
|
|
115
111
|
};
|
|
116
112
|
|
|
117
|
-
const result = await this.exec(
|
|
113
|
+
const result = await this.exec(
|
|
114
|
+
request as unknown as Record<string, unknown>,
|
|
115
|
+
"query",
|
|
116
|
+
metadata,
|
|
117
|
+
);
|
|
118
118
|
return this.validate(result, schema);
|
|
119
119
|
}
|
|
120
120
|
|
|
@@ -125,20 +125,19 @@ export class CosmosDBClientImpl
|
|
|
125
125
|
partitionKey?: string,
|
|
126
126
|
metadata?: TraceMetadata,
|
|
127
127
|
): Promise<T> {
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
action: {
|
|
134
|
-
case: "read",
|
|
135
|
-
value: { id, partitionKey },
|
|
136
|
-
},
|
|
137
|
-
},
|
|
128
|
+
// Proto JSON format for: oneof cosmosdb_action { PointOperation point_operation = 6; }
|
|
129
|
+
const request = {
|
|
130
|
+
pointOperation: {
|
|
131
|
+
containerId,
|
|
132
|
+
read: { id, partitionKey },
|
|
138
133
|
},
|
|
139
134
|
};
|
|
140
135
|
|
|
141
|
-
const result = await this.exec(
|
|
136
|
+
const result = await this.exec(
|
|
137
|
+
request as unknown as Record<string, unknown>,
|
|
138
|
+
"read",
|
|
139
|
+
metadata,
|
|
140
|
+
);
|
|
142
141
|
return this.validate(result, schema);
|
|
143
142
|
}
|
|
144
143
|
|
|
@@ -148,23 +147,21 @@ export class CosmosDBClientImpl
|
|
|
148
147
|
partitionKey?: string,
|
|
149
148
|
metadata?: TraceMetadata,
|
|
150
149
|
): Promise<unknown> {
|
|
151
|
-
const request
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
case: "create",
|
|
158
|
-
value: {
|
|
159
|
-
body: typeof body === "string" ? body : JSON.stringify(body),
|
|
160
|
-
partitionKey,
|
|
161
|
-
},
|
|
162
|
-
},
|
|
150
|
+
const request = {
|
|
151
|
+
pointOperation: {
|
|
152
|
+
containerId,
|
|
153
|
+
create: {
|
|
154
|
+
body: typeof body === "string" ? body : JSON.stringify(body),
|
|
155
|
+
partitionKey,
|
|
163
156
|
},
|
|
164
157
|
},
|
|
165
158
|
};
|
|
166
159
|
|
|
167
|
-
return this.exec(
|
|
160
|
+
return this.exec(
|
|
161
|
+
request as unknown as Record<string, unknown>,
|
|
162
|
+
"create",
|
|
163
|
+
metadata,
|
|
164
|
+
);
|
|
168
165
|
}
|
|
169
166
|
|
|
170
167
|
async replace(
|
|
@@ -173,23 +170,21 @@ export class CosmosDBClientImpl
|
|
|
173
170
|
partitionKey?: string,
|
|
174
171
|
metadata?: TraceMetadata,
|
|
175
172
|
): Promise<unknown> {
|
|
176
|
-
const request
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
case: "replace",
|
|
183
|
-
value: {
|
|
184
|
-
body: typeof body === "string" ? body : JSON.stringify(body),
|
|
185
|
-
partitionKey,
|
|
186
|
-
},
|
|
187
|
-
},
|
|
173
|
+
const request = {
|
|
174
|
+
pointOperation: {
|
|
175
|
+
containerId,
|
|
176
|
+
replace: {
|
|
177
|
+
body: typeof body === "string" ? body : JSON.stringify(body),
|
|
178
|
+
partitionKey,
|
|
188
179
|
},
|
|
189
180
|
},
|
|
190
181
|
};
|
|
191
182
|
|
|
192
|
-
return this.exec(
|
|
183
|
+
return this.exec(
|
|
184
|
+
request as unknown as Record<string, unknown>,
|
|
185
|
+
"replace",
|
|
186
|
+
metadata,
|
|
187
|
+
);
|
|
193
188
|
}
|
|
194
189
|
|
|
195
190
|
async upsert(
|
|
@@ -198,23 +193,21 @@ export class CosmosDBClientImpl
|
|
|
198
193
|
partitionKey?: string,
|
|
199
194
|
metadata?: TraceMetadata,
|
|
200
195
|
): Promise<unknown> {
|
|
201
|
-
const request
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
case: "upsert",
|
|
208
|
-
value: {
|
|
209
|
-
body: typeof body === "string" ? body : JSON.stringify(body),
|
|
210
|
-
partitionKey,
|
|
211
|
-
},
|
|
212
|
-
},
|
|
196
|
+
const request = {
|
|
197
|
+
pointOperation: {
|
|
198
|
+
containerId,
|
|
199
|
+
upsert: {
|
|
200
|
+
body: typeof body === "string" ? body : JSON.stringify(body),
|
|
201
|
+
partitionKey,
|
|
213
202
|
},
|
|
214
203
|
},
|
|
215
204
|
};
|
|
216
205
|
|
|
217
|
-
return this.exec(
|
|
206
|
+
return this.exec(
|
|
207
|
+
request as unknown as Record<string, unknown>,
|
|
208
|
+
"upsert",
|
|
209
|
+
metadata,
|
|
210
|
+
);
|
|
218
211
|
}
|
|
219
212
|
|
|
220
213
|
async deleteItem(
|
|
@@ -223,19 +216,17 @@ export class CosmosDBClientImpl
|
|
|
223
216
|
partitionKey?: string,
|
|
224
217
|
metadata?: TraceMetadata,
|
|
225
218
|
): Promise<unknown> {
|
|
226
|
-
const request
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
containerId,
|
|
231
|
-
action: {
|
|
232
|
-
case: "delete",
|
|
233
|
-
value: { id, partitionKey },
|
|
234
|
-
},
|
|
235
|
-
},
|
|
219
|
+
const request = {
|
|
220
|
+
pointOperation: {
|
|
221
|
+
containerId,
|
|
222
|
+
delete: { id, partitionKey },
|
|
236
223
|
},
|
|
237
224
|
};
|
|
238
225
|
|
|
239
|
-
return this.exec(
|
|
226
|
+
return this.exec(
|
|
227
|
+
request as unknown as Record<string, unknown>,
|
|
228
|
+
"delete",
|
|
229
|
+
metadata,
|
|
230
|
+
);
|
|
240
231
|
}
|
|
241
232
|
}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { describe, expectTypeOf, it } from "vitest";
|
|
2
|
+
import {
|
|
3
|
+
mysql,
|
|
4
|
+
openai,
|
|
5
|
+
postgres,
|
|
6
|
+
slack,
|
|
7
|
+
type MySQLRef,
|
|
8
|
+
type OpenAIRef,
|
|
9
|
+
type PostgresRef,
|
|
10
|
+
type SlackRef,
|
|
11
|
+
} from "./declarations.js";
|
|
12
|
+
|
|
13
|
+
type LiteralString<T extends string> = string extends T ? never : T;
|
|
14
|
+
type LiteralOnlyFactory<TRef> = <T extends string>(
|
|
15
|
+
id: LiteralString<T>,
|
|
16
|
+
) => TRef;
|
|
17
|
+
|
|
18
|
+
describe("LiteralString", () => {
|
|
19
|
+
it("preserves string literals", () => {
|
|
20
|
+
expectTypeOf<LiteralString<"abc-123">>().toEqualTypeOf<"abc-123">();
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
it("rejects broad string", () => {
|
|
24
|
+
expectTypeOf<LiteralString<string>>().toBeNever();
|
|
25
|
+
});
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
describe("integration declaration signatures", () => {
|
|
29
|
+
it("enforces literal-only postgres declarations", () => {
|
|
30
|
+
expectTypeOf(postgres).toEqualTypeOf<LiteralOnlyFactory<PostgresRef>>();
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
it("enforces literal-only slack declarations", () => {
|
|
34
|
+
expectTypeOf(slack).toEqualTypeOf<LiteralOnlyFactory<SlackRef>>();
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
it("enforces literal-only mysql declarations", () => {
|
|
38
|
+
expectTypeOf(mysql).toEqualTypeOf<LiteralOnlyFactory<MySQLRef>>();
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
it("enforces literal-only openai declarations", () => {
|
|
42
|
+
expectTypeOf(openai).toEqualTypeOf<LiteralOnlyFactory<OpenAIRef>>();
|
|
43
|
+
});
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
describe("integration declaration calls", () => {
|
|
47
|
+
it("accepts inline literals", () => {
|
|
48
|
+
const ref = postgres("a1b2c3d4-e5f6-7890-abcd-ef1234567890");
|
|
49
|
+
|
|
50
|
+
expectTypeOf(ref.pluginId).toEqualTypeOf<"postgres">();
|
|
51
|
+
expectTypeOf(ref.id).toBeString();
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
it("accepts const variables with preserved literal types", () => {
|
|
55
|
+
const PROD_DB = "a1b2c3d4-e5f6-7890-abcd-ef1234567890";
|
|
56
|
+
const OPS_SLACK = "b2c3d4e5-f678-9012-abcd-ef1234567890";
|
|
57
|
+
|
|
58
|
+
const dbRef = postgres(PROD_DB);
|
|
59
|
+
const slackRef = slack(OPS_SLACK);
|
|
60
|
+
|
|
61
|
+
expectTypeOf(dbRef.pluginId).toEqualTypeOf<"postgres">();
|
|
62
|
+
expectTypeOf(slackRef.pluginId).toEqualTypeOf<"slack">();
|
|
63
|
+
});
|
|
64
|
+
});
|