@helix-tools/sdk-typescript 1.2.0

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/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ PROPRIETARY LICENSE
2
+
3
+ Copyright (c) 2025 Helix. All rights reserved.
4
+
5
+ This software and associated documentation files (the "Software") are the
6
+ proprietary and confidential property of Helix.
7
+
8
+ NOTICE: All information contained herein is, and remains the property of
9
+ Helix and its suppliers, if any. The intellectual and technical concepts
10
+ contained herein are proprietary to Helix and its suppliers and may be
11
+ covered by U.S. and Foreign Patents, patents in process, and are protected
12
+ by trade secret or copyright law.
13
+
14
+ Dissemination of this information or reproduction of this material is
15
+ strictly forbidden unless prior written permission is obtained from Helix.
16
+
17
+ Unauthorized copying, distribution, modification, public display, or public
18
+ performance of this Software, via any medium, is strictly prohibited.
19
+
20
+ For licensing inquiries, please contact: contact@helix.tools
package/README.md ADDED
@@ -0,0 +1,23 @@
1
+ # Helix Connect Platform TypeScript SDK
2
+
3
+ Official TypeScript/Node.js SDK for the Helix Connect data marketplace platform.
4
+
5
+ ## Overview
6
+
7
+ The Helix Connect TypeScript SDK enables data producers and consumers to securely exchange and consume datasets through the Helix Connect platform.
8
+
9
+ ## Installation
10
+
11
+ ```bash
12
+ npm install @helix-tools/sdk-typescript
13
+ ```
14
+
15
+ ## Support
16
+
17
+ - Documentation: https://docs.helix.tools
18
+ - Issues: https://github.com/helix-tools/sdk-typescript/issues
19
+ - Email: support@helix.tools
20
+
21
+ ## License
22
+
23
+ See LICENSE file for details.
@@ -0,0 +1,226 @@
1
+ /**
2
+ * Helix Connect Platform Consumer SDK
3
+ * For data consumers who want to download and access datasets
4
+ */
5
+ export interface HelixConsumerConfig {
6
+ awsAccessKeyId: string;
7
+ awsSecretAccessKey: string;
8
+ customerId: string;
9
+ apiEndpoint?: string;
10
+ region?: string;
11
+ }
12
+ export interface DatasetMetadata {
13
+ _id: string;
14
+ name: string;
15
+ producer_id: string;
16
+ size_bytes: number;
17
+ s3_key: string;
18
+ metadata?: {
19
+ compression_enabled?: boolean;
20
+ encryption_enabled?: boolean;
21
+ };
22
+ }
23
+ export interface DownloadUrlInfo {
24
+ download_url: string;
25
+ expires_at: string;
26
+ dataset: {
27
+ id: string;
28
+ name: string;
29
+ size_bytes: number;
30
+ };
31
+ }
32
+ export interface SubscriptionRequest {
33
+ request_id: string;
34
+ producer_id: string;
35
+ consumer_id: string;
36
+ dataset_id?: string;
37
+ tier: string;
38
+ status: string;
39
+ created_at: string;
40
+ }
41
+ export interface Notification {
42
+ message_id: string;
43
+ receipt_handle: string;
44
+ event_type: string;
45
+ producer_id: string;
46
+ dataset_id: string;
47
+ dataset_name?: string;
48
+ s3_bucket: string;
49
+ s3_key: string;
50
+ size_bytes: number;
51
+ timestamp: string;
52
+ subscriber_id: string;
53
+ subscription_id: string;
54
+ raw_message: string;
55
+ }
56
+ export declare class HelixConsumer {
57
+ private customerId;
58
+ private apiEndpoint;
59
+ private region;
60
+ private kmsClient;
61
+ private stsClient;
62
+ private sqsClient;
63
+ private ssmClient;
64
+ private awsAccessKeyId;
65
+ private awsSecretAccessKey;
66
+ private queueUrl;
67
+ /**
68
+ * Creates a new Helix Consumer instance.
69
+ * Initializes AWS clients and validates credentials on construction.
70
+ */
71
+ constructor(config: HelixConsumerConfig);
72
+ /**
73
+ * Validates AWS credentials by making a test STS call.
74
+ * Throws an error if credentials are invalid.
75
+ */
76
+ private validateCredentials;
77
+ /**
78
+ * Signs an HTTP request using AWS Signature Version 4.
79
+ * Used for authenticating API requests to Helix Connect Platform.
80
+ */
81
+ private signRequest;
82
+ /**
83
+ * Makes an authenticated API request to Helix Connect Platform.
84
+ * Handles request signing, error responses, and retries.
85
+ */
86
+ private makeApiRequest;
87
+ /**
88
+ * Retrieves metadata for a specific dataset.
89
+ * Returns information about the dataset including size, compression, and encryption status.
90
+ */
91
+ getDataset(datasetId: string): Promise<DatasetMetadata>;
92
+ /**
93
+ * Generates a pre-signed S3 download URL for a dataset.
94
+ * The URL expires after a limited time and grants temporary access to the encrypted dataset file.
95
+ */
96
+ getDownloadUrl(datasetId: string): Promise<DownloadUrlInfo>;
97
+ /**
98
+ * Decompresses gzip-compressed data.
99
+ * Used internally after decryption to restore original dataset format.
100
+ */
101
+ private decompressData;
102
+ /**
103
+ * Decrypts data using envelope encryption with KMS.
104
+ * Process: Decrypt data key with KMS, then decrypt data with AES-256-GCM.
105
+ * Format: [4 bytes: key length][encrypted key][16 bytes: IV][16 bytes: tag][encrypted data]
106
+ */
107
+ private decryptData;
108
+ /**
109
+ * Downloads a dataset from S3, automatically decrypting and decompressing if needed.
110
+ * The downloaded file is saved to the specified output path in its original format.
111
+ *
112
+ * Optimized for large files (>1GB) using streaming when possible.
113
+ */
114
+ downloadDataset(datasetId: string, outputPath: string, options?: {
115
+ autoDecompress?: boolean;
116
+ autoDecrypt?: boolean;
117
+ }): Promise<string>;
118
+ /**
119
+ * Decompresses data using streaming to avoid buffer limits.
120
+ * Used for large files that would exceed Node.js Buffer size limits (2GB).
121
+ */
122
+ private decompressDataStream;
123
+ /**
124
+ * Lists all datasets available to this consumer.
125
+ * Returns metadata for datasets the consumer has permission to access.
126
+ */
127
+ listDatasets(): Promise<DatasetMetadata[]>;
128
+ /**
129
+ * Lists all active subscriptions for this consumer.
130
+ *
131
+ * @returns Array of subscription objects
132
+ */
133
+ listSubscriptions(): Promise<any[]>;
134
+ /**
135
+ * Creates a subscription request to access a producer's datasets.
136
+ * The producer must approve the request before the consumer gains access.
137
+ */
138
+ createSubscriptionRequest(params: {
139
+ producerId: string;
140
+ datasetId?: string;
141
+ tier?: string;
142
+ message?: string;
143
+ }): Promise<SubscriptionRequest>;
144
+ /**
145
+ * Polls the shared SQS queue for dataset upload notifications.
146
+ *
147
+ * IMPORTANT: This uses a SHARED queue for all consumers. The application should
148
+ * filter notifications based on subscriptions. Only download datasets from
149
+ * producers you are subscribed to.
150
+ *
151
+ * Messages are automatically acknowledged (deleted) by default after retrieval.
152
+ * This prevents duplicate processing and simplifies the developer experience.
153
+ * Set autoAcknowledge to false if you need manual control over message deletion.
154
+ *
155
+ * @param maxMessages - Maximum number of messages to retrieve (1-10, default: 10)
156
+ * @param waitTimeSeconds - Long polling wait time (0-20 seconds, default: 20)
157
+ * @param visibilityTimeout - How long messages are hidden after retrieval (default: 300s)
158
+ * @param autoAcknowledge - Automatically acknowledge (delete) messages after receiving (default: true)
159
+ * @param subscriptionIds - Optional array of subscription IDs to filter notifications
160
+ * @returns Array of notification objects
161
+ *
162
+ * @example
163
+ * ```typescript
164
+ * const consumer = new HelixConsumer(...);
165
+ *
166
+ * // Simple usage - messages auto-deleted after poll
167
+ * const notifications = await consumer.pollNotifications({
168
+ * subscriptionIds: ['sub-123'],
169
+ * maxMessages: 5
170
+ * });
171
+ * for (const notif of notifications) {
172
+ * console.log(`New dataset: ${notif.dataset_name}`);
173
+ * await consumer.downloadDataset(notif.dataset_id, './output.json');
174
+ * // No need to delete - already handled automatically!
175
+ * }
176
+ *
177
+ * // Advanced usage - manual acknowledgment for custom retry logic
178
+ * const notifications = await consumer.pollNotifications({
179
+ * autoAcknowledge: false,
180
+ * maxMessages: 5
181
+ * });
182
+ * for (const notif of notifications) {
183
+ * try {
184
+ * await consumer.downloadDataset(notif.dataset_id, './output.json');
185
+ * // Manually acknowledge only after successful processing
186
+ * await consumer.deleteNotification(notif.receipt_handle);
187
+ * } catch (error) {
188
+ * console.error('Processing failed, message will retry:', error);
189
+ * // Message not deleted, will become visible again after visibility timeout
190
+ * }
191
+ * }
192
+ * ```
193
+ */
194
+ pollNotifications(options?: {
195
+ maxMessages?: number;
196
+ waitTimeSeconds?: number;
197
+ visibilityTimeout?: number;
198
+ autoAcknowledge?: boolean;
199
+ subscriptionIds?: string[];
200
+ }): Promise<Notification[]>;
201
+ /**
202
+ * Deletes a notification message from the SQS queue after processing.
203
+ *
204
+ * @param receiptHandle - The receipt handle from pollNotifications()
205
+ *
206
+ * @example
207
+ * ```typescript
208
+ * const consumer = new HelixConsumer(...);
209
+ * const notifications = await consumer.pollNotifications();
210
+ * for (const notif of notifications) {
211
+ * // Process notification...
212
+ * await consumer.deleteNotification(notif.receipt_handle);
213
+ * }
214
+ * ```
215
+ */
216
+ deleteNotification(receiptHandle: string): Promise<void>;
217
+ /**
218
+ * Extracts producer ID from S3 key path.
219
+ * S3 keys follow the pattern: datasets/{dataset_name}/{date}/{file}
220
+ *
221
+ * @param s3Key - S3 object key
222
+ * @returns Extracted producer ID (or 'unknown' if not found)
223
+ */
224
+ private extractProducerId;
225
+ }
226
+ //# sourceMappingURL=consumer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"consumer.d.ts","sourceRoot":"","sources":["../src/consumer.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAcH,MAAM,WAAW,mBAAmB;IAClC,cAAc,EAAE,MAAM,CAAC;IACvB,kBAAkB,EAAE,MAAM,CAAC;IAC3B,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,eAAe;IAC9B,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE;QACT,mBAAmB,CAAC,EAAE,OAAO,CAAC;QAC9B,kBAAkB,CAAC,EAAE,OAAO,CAAC;KAC9B,CAAC;CACH;AAED,MAAM,WAAW,eAAe;IAC9B,YAAY,EAAE,MAAM,CAAC;IACrB,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,EAAE;QACP,EAAE,EAAE,MAAM,CAAC;QACX,IAAI,EAAE,MAAM,CAAC;QACb,UAAU,EAAE,MAAM,CAAC;KACpB,CAAC;CACH;AAED,MAAM,WAAW,mBAAmB;IAClC,UAAU,EAAE,MA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