@superblocksteam/sdk-api 2.0.104 → 2.0.105-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 (163) hide show
  1. package/README.md +202 -86
  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 -10
  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 -63
  28. package/dist/integrations/declarations.d.ts.map +1 -1
  29. package/dist/integrations/declarations.js +5 -59
  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 -9
  35. package/dist/integrations/index.d.ts.map +1 -1
  36. package/dist/integrations/index.js +1 -6
  37. package/dist/integrations/index.js.map +1 -1
  38. package/dist/integrations/registry.d.ts +1 -10
  39. package/dist/integrations/registry.d.ts.map +1 -1
  40. package/dist/integrations/registry.js +0 -25
  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 +14 -5
  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 -30
  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 -91
  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/index.ts +0 -45
  83. package/src/integrations/registry.ts +1 -34
  84. package/src/integrations/salesforce/README.md +11 -9
  85. package/src/integrations/slack/README.md +62 -19
  86. package/src/integrations/slack/client.test.ts +553 -0
  87. package/src/integrations/slack/client.ts +92 -12
  88. package/src/integrations/slack/index.ts +6 -1
  89. package/src/integrations/slack/types.ts +142 -29
  90. package/src/integrations/snowflake/client.ts +2 -2
  91. package/src/integrations/zoom/README.md +15 -15
  92. package/src/runtime/context.ts +1 -1
  93. package/src/runtime/executor.ts +2 -2
  94. package/src/types.ts +14 -5
  95. package/dist/integrations/couchbase/client.d.ts +0 -36
  96. package/dist/integrations/couchbase/client.d.ts.map +0 -1
  97. package/dist/integrations/couchbase/client.js +0 -148
  98. package/dist/integrations/couchbase/client.js.map +0 -1
  99. package/dist/integrations/couchbase/index.d.ts +0 -8
  100. package/dist/integrations/couchbase/index.d.ts.map +0 -1
  101. package/dist/integrations/couchbase/index.js +0 -7
  102. package/dist/integrations/couchbase/index.js.map +0 -1
  103. package/dist/integrations/couchbase/types.d.ts +0 -100
  104. package/dist/integrations/couchbase/types.d.ts.map +0 -1
  105. package/dist/integrations/couchbase/types.js +0 -5
  106. package/dist/integrations/couchbase/types.js.map +0 -1
  107. package/dist/integrations/kafka/client.d.ts +0 -25
  108. package/dist/integrations/kafka/client.d.ts.map +0 -1
  109. package/dist/integrations/kafka/client.js +0 -124
  110. package/dist/integrations/kafka/client.js.map +0 -1
  111. package/dist/integrations/kafka/index.d.ts +0 -8
  112. package/dist/integrations/kafka/index.d.ts.map +0 -1
  113. package/dist/integrations/kafka/index.js +0 -7
  114. package/dist/integrations/kafka/index.js.map +0 -1
  115. package/dist/integrations/kafka/types.d.ts +0 -113
  116. package/dist/integrations/kafka/types.d.ts.map +0 -1
  117. package/dist/integrations/kafka/types.js +0 -5
  118. package/dist/integrations/kafka/types.js.map +0 -1
  119. package/dist/integrations/kinesis/client.d.ts +0 -31
  120. package/dist/integrations/kinesis/client.d.ts.map +0 -1
  121. package/dist/integrations/kinesis/client.js +0 -101
  122. package/dist/integrations/kinesis/client.js.map +0 -1
  123. package/dist/integrations/kinesis/index.d.ts +0 -8
  124. package/dist/integrations/kinesis/index.d.ts.map +0 -1
  125. package/dist/integrations/kinesis/index.js +0 -7
  126. package/dist/integrations/kinesis/index.js.map +0 -1
  127. package/dist/integrations/kinesis/types.d.ts +0 -97
  128. package/dist/integrations/kinesis/types.d.ts.map +0 -1
  129. package/dist/integrations/kinesis/types.js +0 -7
  130. package/dist/integrations/kinesis/types.js.map +0 -1
  131. package/dist/integrations/python/client.d.ts +0 -42
  132. package/dist/integrations/python/client.d.ts.map +0 -1
  133. package/dist/integrations/python/client.js +0 -89
  134. package/dist/integrations/python/client.js.map +0 -1
  135. package/dist/integrations/python/client.test.d.ts +0 -5
  136. package/dist/integrations/python/client.test.d.ts.map +0 -1
  137. package/dist/integrations/python/client.test.js +0 -214
  138. package/dist/integrations/python/client.test.js.map +0 -1
  139. package/dist/integrations/python/index.d.ts +0 -6
  140. package/dist/integrations/python/index.d.ts.map +0 -1
  141. package/dist/integrations/python/index.js +0 -5
  142. package/dist/integrations/python/index.js.map +0 -1
  143. package/dist/integrations/python/types.d.ts +0 -85
  144. package/dist/integrations/python/types.d.ts.map +0 -1
  145. package/dist/integrations/python/types.js +0 -5
  146. package/dist/integrations/python/types.js.map +0 -1
  147. package/src/integrations/couchbase/README.md +0 -138
  148. package/src/integrations/couchbase/client.ts +0 -225
  149. package/src/integrations/couchbase/index.ts +0 -8
  150. package/src/integrations/couchbase/types.ts +0 -126
  151. package/src/integrations/kafka/README.md +0 -144
  152. package/src/integrations/kafka/client.ts +0 -216
  153. package/src/integrations/kafka/index.ts +0 -14
  154. package/src/integrations/kafka/types.ts +0 -128
  155. package/src/integrations/kinesis/README.md +0 -153
  156. package/src/integrations/kinesis/client.ts +0 -146
  157. package/src/integrations/kinesis/index.ts +0 -14
  158. package/src/integrations/kinesis/types.ts +0 -114
  159. package/src/integrations/python/README.md +0 -566
  160. package/src/integrations/python/client.test.ts +0 -341
  161. package/src/integrations/python/client.ts +0 -136
  162. package/src/integrations/python/index.ts +0 -6
  163. package/src/integrations/python/types.ts +0 -92
@@ -1,216 +0,0 @@
1
- /**
2
- * Kafka client implementation.
3
- *
4
- * Constructs request objects matching the expected backend format.
5
- */
6
-
7
- import type { z } from "zod";
8
-
9
- import { RestApiValidationError } from "../../errors.js";
10
- import { IntegrationError } from "../../runtime/errors.js";
11
- import type { QueryExecutor, TraceMetadata } from "../registry.js";
12
- import type { IntegrationConfig, IntegrationClientImpl } from "../types.js";
13
- import type {
14
- KafkaClient,
15
- KafkaConsumeParams,
16
- KafkaProduceParams,
17
- } from "./types.js";
18
-
19
- /**
20
- * Consume request structure.
21
- */
22
- interface KafkaConsumeRequest {
23
- operation: "OPERATION_CONSUME";
24
- consume: {
25
- topic: string;
26
- from: string;
27
- groupId?: string;
28
- clientId?: string;
29
- readUncommitted?: boolean;
30
- seek?: {
31
- topic?: string;
32
- offset?: string;
33
- partition?: number;
34
- };
35
- };
36
- }
37
-
38
- /**
39
- * Produce request structure.
40
- */
41
- interface KafkaProduceRequest {
42
- operation: "OPERATION_PRODUCE";
43
- produce: {
44
- messages: string;
45
- acks?: string;
46
- clientId?: string;
47
- timeout?: number;
48
- compression?: string;
49
- transactionId?: string;
50
- autoCreateTopic?: boolean;
51
- idempotent?: boolean;
52
- transaction?: boolean;
53
- };
54
- }
55
-
56
- /**
57
- * Kafka plugin request - discriminated union on operation.
58
- */
59
- type KafkaRequest = KafkaConsumeRequest | KafkaProduceRequest;
60
-
61
- /**
62
- * Operation string values expected by the Kafka plugin.
63
- */
64
- const OPERATION = {
65
- CONSUME: "OPERATION_CONSUME",
66
- PRODUCE: "OPERATION_PRODUCE",
67
- } as const;
68
-
69
- /**
70
- * Consume from string values.
71
- */
72
- const CONSUME_FROM = {
73
- BEGINNING: "FROM_BEGINNING",
74
- LATEST: "FROM_LATEST",
75
- SEEK: "FROM_SEEK",
76
- } as const;
77
-
78
- /**
79
- * Acks string values.
80
- */
81
- const ACKS = {
82
- NONE: "ACKS_NONE",
83
- LEADER: "ACKS_LEADER",
84
- ALL: "ACKS_ALL",
85
- } as const;
86
-
87
- /**
88
- * Compression string values.
89
- */
90
- const COMPRESSION = {
91
- GZIP: "COMPRESSION_GZIP",
92
- SNAPPY: "COMPRESSION_SNAPPY",
93
- LZ4: "COMPRESSION_LZ4",
94
- ZSTD: "COMPRESSION_ZSTD",
95
- } as const;
96
-
97
- /**
98
- * Internal implementation of KafkaClient.
99
- */
100
- export class KafkaClientImpl implements KafkaClient, IntegrationClientImpl {
101
- readonly config: IntegrationConfig;
102
- private readonly executeQuery: QueryExecutor;
103
-
104
- constructor(config: IntegrationConfig, executeQuery: QueryExecutor) {
105
- this.config = config;
106
- this.executeQuery = executeQuery;
107
- }
108
-
109
- get name(): string {
110
- return this.config.name;
111
- }
112
-
113
- get pluginId(): string {
114
- return this.config.pluginId;
115
- }
116
-
117
- private buildConsumeRequest(params: KafkaConsumeParams): KafkaConsumeRequest {
118
- const request: KafkaConsumeRequest = {
119
- operation: OPERATION.CONSUME,
120
- consume: {
121
- topic: params.topic,
122
- from: params.from ? CONSUME_FROM[params.from] : CONSUME_FROM.LATEST,
123
- groupId: params.groupId,
124
- clientId: params.clientId,
125
- readUncommitted: params.readUncommitted ?? false,
126
- },
127
- };
128
-
129
- if (params.seek && request.consume) {
130
- request.consume.seek = {
131
- topic: params.seek.topic,
132
- offset: String(params.seek.offset),
133
- partition: params.seek.partition,
134
- };
135
- }
136
-
137
- return request;
138
- }
139
-
140
- private buildProduceRequest(params: KafkaProduceParams): KafkaProduceRequest {
141
- const request: KafkaProduceRequest = {
142
- operation: OPERATION.PRODUCE,
143
- produce: {
144
- messages: params.messages,
145
- acks: params.acks ? ACKS[params.acks] : ACKS.ALL,
146
- clientId: params.clientId,
147
- timeout: params.timeout,
148
- compression: params.compression
149
- ? COMPRESSION[params.compression]
150
- : undefined,
151
- transactionId: params.transactionId,
152
- autoCreateTopic: params.autoCreateTopic ?? false,
153
- idempotent: params.idempotent ?? false,
154
- transaction: params.transaction ?? false,
155
- },
156
- };
157
-
158
- return request;
159
- }
160
-
161
- private async executeAndValidate<T>(
162
- request: KafkaRequest,
163
- schema: z.ZodSchema<T>,
164
- operation: string,
165
- metadata?: TraceMetadata,
166
- ): Promise<T> {
167
- try {
168
- const result = await this.executeQuery(
169
- request as unknown as Record<string, unknown>,
170
- undefined,
171
- metadata,
172
- );
173
-
174
- const parseResult = schema.safeParse(result);
175
-
176
- if (!parseResult.success) {
177
- throw new RestApiValidationError(
178
- `Result validation failed: ${parseResult.error.message}`,
179
- {
180
- zodError: parseResult.error,
181
- data: result,
182
- },
183
- );
184
- }
185
-
186
- return parseResult.data;
187
- } catch (error) {
188
- if (
189
- error instanceof RestApiValidationError ||
190
- error instanceof IntegrationError
191
- ) {
192
- throw error;
193
- }
194
-
195
- throw new IntegrationError(this.config.name, operation, error);
196
- }
197
- }
198
-
199
- async consume<T>(
200
- schema: z.ZodSchema<T>,
201
- params: KafkaConsumeParams,
202
- metadata?: TraceMetadata,
203
- ): Promise<T> {
204
- const request = this.buildConsumeRequest(params);
205
- return this.executeAndValidate(request, schema, "consume", metadata);
206
- }
207
-
208
- async produce<T>(
209
- schema: z.ZodSchema<T>,
210
- params: KafkaProduceParams,
211
- metadata?: TraceMetadata,
212
- ): Promise<T> {
213
- const request = this.buildProduceRequest(params);
214
- return this.executeAndValidate(request, schema, "produce", metadata);
215
- }
216
- }
@@ -1,14 +0,0 @@
1
- /**
2
- * Kafka integration client.
3
- *
4
- * @module
5
- */
6
-
7
- export type {
8
- KafkaClient,
9
- KafkaOperation,
10
- KafkaSeek,
11
- KafkaConsumeParams,
12
- KafkaProduceParams,
13
- } from "./types.js";
14
- export { KafkaClientImpl } from "./client.js";
@@ -1,128 +0,0 @@
1
- /**
2
- * Kafka client types.
3
- */
4
-
5
- import type { z } from "zod";
6
-
7
- import type { BaseIntegrationClient } from "../../types.js";
8
- import type { TraceMetadata } from "../registry.js";
9
-
10
- /**
11
- * Kafka operation types.
12
- */
13
- export type KafkaOperation = "CONSUME" | "PRODUCE";
14
-
15
- /**
16
- * Seek position for consuming from a specific offset.
17
- */
18
- export interface KafkaSeek {
19
- /** Topic name */
20
- topic: string;
21
- /** Offset to start from */
22
- offset: number;
23
- /** Partition to consume from */
24
- partition: number;
25
- }
26
-
27
- /**
28
- * Parameters for Kafka consume operation.
29
- */
30
- export interface KafkaConsumeParams {
31
- /** Topic to consume from */
32
- topic: string;
33
- /** Where to start consuming from */
34
- from?: "BEGINNING" | "LATEST" | "SEEK";
35
- /** Consumer group ID */
36
- groupId?: string;
37
- /** Client ID */
38
- clientId?: string;
39
- /** Seek position for SEEK mode */
40
- seek?: KafkaSeek;
41
- /** Whether to read uncommitted messages */
42
- readUncommitted?: boolean;
43
- }
44
-
45
- /**
46
- * Parameters for Kafka produce operation.
47
- */
48
- export interface KafkaProduceParams {
49
- /** Messages to produce (JSON string) */
50
- messages: string;
51
- /** Acknowledgment level */
52
- acks?: "NONE" | "LEADER" | "ALL";
53
- /** Client ID */
54
- clientId?: string;
55
- /** Timeout in milliseconds */
56
- timeout?: number;
57
- /** Compression type */
58
- compression?: "GZIP" | "SNAPPY" | "LZ4" | "ZSTD";
59
- /** Transaction ID for transactional produce */
60
- transactionId?: string;
61
- /** Whether to auto-create topic */
62
- autoCreateTopic?: boolean;
63
- /** Whether to enable idempotent delivery */
64
- idempotent?: boolean;
65
- /** Whether to use transactions */
66
- transaction?: boolean;
67
- }
68
-
69
- /**
70
- * Kafka client for message streaming operations.
71
- *
72
- * Provides consume() and produce() methods for Kafka operations.
73
- *
74
- * @example
75
- * ```typescript
76
- * // Declare in api(): integrations: { kafka: kafka(INTEGRATION_ID) }
77
- * // In run(), access via ctx.integrations.kafka
78
- *
79
- * // Consume messages
80
- * const MessageSchema = z.array(z.object({
81
- * topic: z.string(),
82
- * partition: z.number(),
83
- * offset: z.number(),
84
- * value: z.unknown(),
85
- * }));
86
- *
87
- * const messages = await kafka.consume(MessageSchema, {
88
- * topic: 'my-topic',
89
- * from: 'LATEST',
90
- * groupId: 'my-consumer-group',
91
- * });
92
- *
93
- * // Produce messages
94
- * const result = await kafka.produce(z.any(), {
95
- * messages: JSON.stringify([
96
- * { topic: 'my-topic', value: { key: 'value' } }
97
- * ]),
98
- * });
99
- * ```
100
- */
101
- export interface KafkaClient extends BaseIntegrationClient {
102
- /**
103
- * Consume messages from Kafka.
104
- *
105
- * @param schema - Zod schema for validating the result
106
- * @param params - Consume parameters
107
- * @returns The validated result
108
- */
109
- consume<T>(
110
- schema: z.ZodSchema<T>,
111
- params: KafkaConsumeParams,
112
- metadata?: TraceMetadata,
113
- ): Promise<T>;
114
-
115
- /**
116
- * Produce messages to Kafka.
117
- *
118
- * @param schema - Zod schema for validating the result
119
- * @param params - Produce parameters
120
- * @param metadata - Optional trace metadata for diagnostics
121
- * @returns The validated result
122
- */
123
- produce<T>(
124
- schema: z.ZodSchema<T>,
125
- params: KafkaProduceParams,
126
- metadata?: TraceMetadata,
127
- ): Promise<T>;
128
- }
@@ -1,153 +0,0 @@
1
- # Kinesis Client
2
-
3
- Write records to and read records from Amazon Kinesis Data Streams.
4
-
5
- ## Methods
6
-
7
- | Method | Description |
8
- | ------------------------------- | ----------------------------------------- |
9
- | `putRecord(params, metadata?)` | Write a single record to a Kinesis stream |
10
- | `getRecords(params, metadata?)` | Read records from a Kinesis stream shard |
11
-
12
- ## Usage
13
-
14
- ### Put Record
15
-
16
- ```typescript
17
- import { api, z, kinesis } from "@superblocksteam/sdk-api";
18
-
19
- // Integration ID from the integrations panel
20
- const PROD_KINESIS = "a1b2c3d4-5678-90ab-cdef-kinesis00001";
21
-
22
- export default api({
23
- integrations: {
24
- kinesis: kinesis(PROD_KINESIS),
25
- },
26
- name: "KinesisExample",
27
- input: z.object({
28
- userId: z.string(),
29
- event: z.string(),
30
- }),
31
- output: z.object({
32
- success: z.boolean(),
33
- }),
34
- async run(ctx, { userId, event }) {
35
- await kinesis.putRecord({
36
- data: JSON.stringify({ event, userId, timestamp: Date.now() }),
37
- partitionKey: userId,
38
- streamName: "user-events",
39
- });
40
-
41
- return { success: true };
42
- },
43
- });
44
- ```
45
-
46
- ### Put Record with Stream ARN
47
-
48
- ```typescript
49
- await kinesis.putRecord({
50
- data: JSON.stringify({ event: "signup" }),
51
- partitionKey: "user-123",
52
- streamIdentifierType: "STREAM_ARN",
53
- streamArn: "arn:aws:kinesis:us-east-1:123456789:stream/user-events",
54
- });
55
- ```
56
-
57
- ### Get Records
58
-
59
- ```typescript
60
- const records = await kinesis.getRecords({
61
- shardId: "shardId-000000000000",
62
- shardIteratorType: "LATEST",
63
- streamName: "user-events",
64
- limit: 10,
65
- });
66
- ```
67
-
68
- ### Get Records from Specific Sequence Number
69
-
70
- ```typescript
71
- const records = await kinesis.getRecords({
72
- shardId: "shardId-000000000000",
73
- shardIteratorType: "AFTER_SEQUENCE_NUMBER",
74
- startingSequenceNumber:
75
- "49590338271490256608559692538361571095921575989136588898",
76
- streamName: "user-events",
77
- });
78
- ```
79
-
80
- ### Get Records at Timestamp
81
-
82
- ```typescript
83
- const records = await kinesis.getRecords({
84
- shardId: "shardId-000000000000",
85
- shardIteratorType: "AT_TIMESTAMP",
86
- timestamp: "2024-01-15T00:00:00Z",
87
- streamName: "user-events",
88
- });
89
- ```
90
-
91
- ## Parameters
92
-
93
- ### KinesisPutParams
94
-
95
- | Parameter | Type | Required | Description |
96
- | ---------------------- | ------------------------------- | -------- | -------------------------------------------- |
97
- | `data` | `string` | Yes | The data payload (JSON string or raw string) |
98
- | `partitionKey` | `string` | Yes | The partition key for the record |
99
- | `streamIdentifierType` | `'STREAM_NAME' \| 'STREAM_ARN'` | No | How to identify the stream |
100
- | `streamName` | `string` | No | Stream name (when using STREAM_NAME) |
101
- | `streamArn` | `string` | No | Stream ARN (when using STREAM_ARN) |
102
-
103
- ### KinesisGetParams
104
-
105
- | Parameter | Type | Required | Description |
106
- | ------------------------ | ------------------------------- | -------- | ---------------------------------------------- |
107
- | `shardId` | `string` | Yes | The shard ID to read from |
108
- | `shardIteratorType` | `ShardIteratorType` | Yes | How to position the shard iterator |
109
- | `limit` | `number` | No | Maximum number of records to return |
110
- | `pollingCooldownMs` | `number` | No | Polling cooldown in milliseconds |
111
- | `startingSequenceNumber` | `string` | No | Sequence number (for AT/AFTER_SEQUENCE_NUMBER) |
112
- | `timestamp` | `string` | No | ISO timestamp (for AT_TIMESTAMP) |
113
- | `streamIdentifierType` | `'STREAM_NAME' \| 'STREAM_ARN'` | No | How to identify the stream |
114
- | `streamName` | `string` | No | Stream name (when using STREAM_NAME) |
115
- | `streamArn` | `string` | No | Stream ARN (when using STREAM_ARN) |
116
-
117
- ### Shard Iterator Types
118
-
119
- | Type | Description |
120
- | ----------------------- | ----------------------------------------- |
121
- | `AT_SEQUENCE_NUMBER` | Start at the specified sequence number |
122
- | `AFTER_SEQUENCE_NUMBER` | Start after the specified sequence number |
123
- | `AT_TIMESTAMP` | Start at the specified timestamp |
124
- | `TRIM_HORIZON` | Start at the oldest record in the shard |
125
- | `LATEST` | Start at the most recent record |
126
-
127
- ## Trace Metadata
128
-
129
- All methods accept an optional `metadata` parameter as the last argument for diagnostics labeling. See the [root SDK README](../../../README.md#trace-metadata) for details.
130
-
131
- ## Error Handling
132
-
133
- ```typescript
134
- import { IntegrationError } from "@superblocksteam/sdk-api";
135
-
136
- try {
137
- await kinesis.putRecord({
138
- data: JSON.stringify({ event: "test" }),
139
- partitionKey: "key-1",
140
- streamName: "my-stream",
141
- });
142
- } catch (error) {
143
- if (error instanceof IntegrationError) {
144
- console.error("Kinesis error:", error.message);
145
- }
146
- }
147
- ```
148
-
149
- ## API Reference
150
-
151
- - [Amazon Kinesis Data Streams](https://docs.aws.amazon.com/streams/latest/dev/introduction.html)
152
- - [PutRecord](https://docs.aws.amazon.com/kinesis/latest/APIReference/API_PutRecord.html)
153
- - [GetRecords](https://docs.aws.amazon.com/kinesis/latest/APIReference/API_GetRecords.html)
@@ -1,146 +0,0 @@
1
- /**
2
- * Kinesis client implementation.
3
- *
4
- * Uses the native Kinesis plugin type from @superblocksteam/types.
5
- * Supports PUT (write records) and GET (read records) operations.
6
- */
7
-
8
- import { IntegrationError } from "../../runtime/errors.js";
9
- import type { QueryExecutor, TraceMetadata } from "../registry.js";
10
- import type { IntegrationConfig, IntegrationClientImpl } from "../types.js";
11
- import type {
12
- KinesisClient,
13
- KinesisPutParams,
14
- KinesisGetParams,
15
- } from "./types.js";
16
-
17
- /**
18
- * Kinesis operation type enum values matching the proto.
19
- */
20
- const OPERATION_TYPE = {
21
- PUT: "OPERATION_TYPE_PUT",
22
- GET: "OPERATION_TYPE_GET",
23
- } as const;
24
-
25
- /**
26
- * Internal implementation of KinesisClient.
27
- *
28
- * Sends requests matching the Kinesis plugin proto structure:
29
- * - `operationType`: PUT or GET
30
- * - `put`: PUT operation parameters
31
- * - `get`: GET operation parameters
32
- */
33
- export class KinesisClientImpl implements KinesisClient, IntegrationClientImpl {
34
- readonly config: IntegrationConfig;
35
- private readonly executeQuery: QueryExecutor;
36
-
37
- constructor(config: IntegrationConfig, executeQuery: QueryExecutor) {
38
- this.config = config;
39
- this.executeQuery = executeQuery;
40
- }
41
-
42
- get name(): string {
43
- return this.config.name;
44
- }
45
-
46
- get pluginId(): string {
47
- return this.config.pluginId;
48
- }
49
-
50
- /**
51
- * Execute a request and wrap errors.
52
- */
53
- private async exec(
54
- request: Record<string, unknown>,
55
- operation: string,
56
- metadata?: TraceMetadata,
57
- ): Promise<unknown> {
58
- try {
59
- return await this.executeQuery(request, undefined, metadata);
60
- } catch (error) {
61
- if (error instanceof IntegrationError) {
62
- throw error;
63
- }
64
-
65
- throw new IntegrationError(this.config.name, operation, error);
66
- }
67
- }
68
-
69
- async putRecord(
70
- params: KinesisPutParams,
71
- metadata?: TraceMetadata,
72
- ): Promise<unknown> {
73
- const put: Record<string, unknown> = {
74
- data: params.data,
75
- partitionKey: params.partitionKey,
76
- };
77
-
78
- if (params.streamIdentifierType) {
79
- put.streamIdentifierType = params.streamIdentifierType;
80
- }
81
-
82
- if (params.streamName) {
83
- put.streamName = params.streamName;
84
- }
85
-
86
- if (params.streamArn) {
87
- put.streamArn = params.streamArn;
88
- }
89
-
90
- return this.exec(
91
- {
92
- operationType: OPERATION_TYPE.PUT,
93
- put,
94
- },
95
- "putRecord",
96
- metadata,
97
- );
98
- }
99
-
100
- async getRecords(
101
- params: KinesisGetParams,
102
- metadata?: TraceMetadata,
103
- ): Promise<unknown> {
104
- const get: Record<string, unknown> = {
105
- shardId: params.shardId,
106
- shardIteratorType: params.shardIteratorType,
107
- };
108
-
109
- if (params.limit !== undefined) {
110
- get.limit = params.limit;
111
- }
112
-
113
- if (params.pollingCooldownMs !== undefined) {
114
- get.pollingCooldownMs = params.pollingCooldownMs;
115
- }
116
-
117
- if (params.startingSequenceNumber) {
118
- get.startingSequenceNumber = params.startingSequenceNumber;
119
- }
120
-
121
- if (params.timestamp) {
122
- get.timestamp = params.timestamp;
123
- }
124
-
125
- if (params.streamIdentifierType) {
126
- get.streamIdentifierType = params.streamIdentifierType;
127
- }
128
-
129
- if (params.streamName) {
130
- get.streamName = params.streamName;
131
- }
132
-
133
- if (params.streamArn) {
134
- get.streamArn = params.streamArn;
135
- }
136
-
137
- return this.exec(
138
- {
139
- operationType: OPERATION_TYPE.GET,
140
- get,
141
- },
142
- "getRecords",
143
- metadata,
144
- );
145
- }
146
- }
@@ -1,14 +0,0 @@
1
- /**
2
- * Kinesis integration client.
3
- *
4
- * @module
5
- */
6
-
7
- export type {
8
- KinesisClient,
9
- KinesisPutParams,
10
- KinesisGetParams,
11
- KinesisStreamIdentifier,
12
- KinesisShardIteratorType,
13
- } from "./types.js";
14
- export { KinesisClientImpl } from "./client.js";