@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.
Files changed (73) hide show
  1. package/dist/files.d.ts +68 -0
  2. package/dist/files.d.ts.map +1 -0
  3. package/dist/files.js +42 -0
  4. package/dist/files.js.map +1 -0
  5. package/dist/index.d.ts +7 -1
  6. package/dist/index.d.ts.map +1 -1
  7. package/dist/index.js +3 -1
  8. package/dist/index.js.map +1 -1
  9. package/dist/integrations/base/rest-api-integration-client.d.ts.map +1 -1
  10. package/dist/integrations/base/rest-api-integration-client.js +6 -35
  11. package/dist/integrations/base/rest-api-integration-client.js.map +1 -1
  12. package/dist/integrations/cosmosdb/client.d.ts.map +1 -1
  13. package/dist/integrations/cosmosdb/client.js +30 -63
  14. package/dist/integrations/cosmosdb/client.js.map +1 -1
  15. package/dist/integrations/cosmosdb/client.test.d.ts +8 -0
  16. package/dist/integrations/cosmosdb/client.test.d.ts.map +1 -0
  17. package/dist/integrations/cosmosdb/client.test.js +141 -0
  18. package/dist/integrations/cosmosdb/client.test.js.map +1 -0
  19. package/dist/integrations/declarations.d.ts +106 -66
  20. package/dist/integrations/declarations.d.ts.map +1 -1
  21. package/dist/integrations/declarations.js +33 -0
  22. package/dist/integrations/declarations.js.map +1 -1
  23. package/dist/integrations/declarations.test.d.ts +2 -0
  24. package/dist/integrations/declarations.test.d.ts.map +1 -0
  25. package/dist/integrations/declarations.test.js +40 -0
  26. package/dist/integrations/declarations.test.js.map +1 -0
  27. package/dist/integrations/gcs/client.d.ts.map +1 -1
  28. package/dist/integrations/gcs/client.js +1 -1
  29. package/dist/integrations/gcs/client.js.map +1 -1
  30. package/dist/integrations/index.d.ts +3 -1
  31. package/dist/integrations/index.d.ts.map +1 -1
  32. package/dist/integrations/index.js +2 -1
  33. package/dist/integrations/index.js.map +1 -1
  34. package/dist/integrations/python/client.test.js +1 -3
  35. package/dist/integrations/python/client.test.js.map +1 -1
  36. package/dist/integrations/redis/client.d.ts.map +1 -1
  37. package/dist/integrations/redis/client.js +8 -1
  38. package/dist/integrations/redis/client.js.map +1 -1
  39. package/dist/integrations/registry.d.ts +1 -0
  40. package/dist/integrations/registry.d.ts.map +1 -1
  41. package/dist/integrations/registry.js +6 -0
  42. package/dist/integrations/registry.js.map +1 -1
  43. package/dist/integrations/restapiintegration/client.d.ts +19 -0
  44. package/dist/integrations/restapiintegration/client.d.ts.map +1 -0
  45. package/dist/integrations/restapiintegration/client.js +18 -0
  46. package/dist/integrations/restapiintegration/client.js.map +1 -0
  47. package/dist/integrations/restapiintegration/index.d.ts +6 -0
  48. package/dist/integrations/restapiintegration/index.d.ts.map +1 -0
  49. package/dist/integrations/restapiintegration/index.js +5 -0
  50. package/dist/integrations/restapiintegration/index.js.map +1 -0
  51. package/dist/integrations/restapiintegration/types.d.ts +33 -0
  52. package/dist/integrations/restapiintegration/types.d.ts.map +1 -0
  53. package/dist/integrations/restapiintegration/types.js +5 -0
  54. package/dist/integrations/restapiintegration/types.js.map +1 -0
  55. package/dist/integrations/snowflake/types.d.ts +4 -4
  56. package/package.json +3 -2
  57. package/src/files.ts +54 -0
  58. package/src/index.ts +21 -0
  59. package/src/integrations/base/rest-api-integration-client.ts +6 -43
  60. package/src/integrations/cosmosdb/client.test.ts +209 -0
  61. package/src/integrations/cosmosdb/client.ts +66 -75
  62. package/src/integrations/declarations.test.ts +64 -0
  63. package/src/integrations/declarations.ts +231 -134
  64. package/src/integrations/gcs/client.ts +1 -5
  65. package/src/integrations/index.ts +6 -0
  66. package/src/integrations/python/client.test.ts +5 -3
  67. package/src/integrations/redis/client.ts +10 -1
  68. package/src/integrations/registry.ts +11 -0
  69. package/src/integrations/restapiintegration/client.ts +21 -0
  70. package/src/integrations/restapiintegration/index.ts +6 -0
  71. package/src/integrations/restapiintegration/types.ts +40 -0
  72. package/src/integrations/snowflake/README.md +7 -7
  73. 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
- const request: CosmosDBRequest = {
101
- cosmosdbAction: {
102
- case: "sql",
103
- value: {
104
- action: {
105
- case: "singleton",
106
- value: {
107
- containerId,
108
- query: sql,
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(request, "query", metadata);
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
- const request: CosmosDBRequest = {
129
- cosmosdbAction: {
130
- case: "pointOperation",
131
- value: {
132
- containerId,
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(request, "read", metadata);
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: CosmosDBRequest = {
152
- cosmosdbAction: {
153
- case: "pointOperation",
154
- value: {
155
- containerId,
156
- action: {
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(request, "create", metadata);
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: CosmosDBRequest = {
177
- cosmosdbAction: {
178
- case: "pointOperation",
179
- value: {
180
- containerId,
181
- action: {
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(request, "replace", metadata);
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: CosmosDBRequest = {
202
- cosmosdbAction: {
203
- case: "pointOperation",
204
- value: {
205
- containerId,
206
- action: {
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(request, "upsert", metadata);
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: CosmosDBRequest = {
227
- cosmosdbAction: {
228
- case: "pointOperation",
229
- value: {
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(request, "delete", metadata);
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
+ });