@helix-tools/sdk-typescript 1.2.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/LICENSE +20 -0
- package/README.md +23 -0
- package/dist/consumer.d.ts +226 -0
- package/dist/consumer.d.ts.map +1 -0
- package/dist/consumer.js +560 -0
- package/dist/consumer.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +8 -0
- package/dist/index.js.map +1 -0
- package/dist/producer.d.ts +160 -0
- package/dist/producer.d.ts.map +1 -0
- package/dist/producer.js +491 -0
- package/dist/producer.js.map +1 -0
- package/package.json +58 -0
package/dist/consumer.js
ADDED
|
@@ -0,0 +1,560 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Helix Connect Platform Consumer SDK
|
|
4
|
+
* For data consumers who want to download and access datasets
|
|
5
|
+
*/
|
|
6
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
7
|
+
if (k2 === undefined) k2 = k;
|
|
8
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
9
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
10
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
11
|
+
}
|
|
12
|
+
Object.defineProperty(o, k2, desc);
|
|
13
|
+
}) : (function(o, m, k, k2) {
|
|
14
|
+
if (k2 === undefined) k2 = k;
|
|
15
|
+
o[k2] = m[k];
|
|
16
|
+
}));
|
|
17
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
18
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
19
|
+
}) : function(o, v) {
|
|
20
|
+
o["default"] = v;
|
|
21
|
+
});
|
|
22
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
23
|
+
var ownKeys = function(o) {
|
|
24
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
25
|
+
var ar = [];
|
|
26
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
27
|
+
return ar;
|
|
28
|
+
};
|
|
29
|
+
return ownKeys(o);
|
|
30
|
+
};
|
|
31
|
+
return function (mod) {
|
|
32
|
+
if (mod && mod.__esModule) return mod;
|
|
33
|
+
var result = {};
|
|
34
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
35
|
+
__setModuleDefault(result, mod);
|
|
36
|
+
return result;
|
|
37
|
+
};
|
|
38
|
+
})();
|
|
39
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
40
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
41
|
+
};
|
|
42
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
43
|
+
exports.HelixConsumer = void 0;
|
|
44
|
+
const client_kms_1 = require("@aws-sdk/client-kms");
|
|
45
|
+
const client_sts_1 = require("@aws-sdk/client-sts");
|
|
46
|
+
const client_sqs_1 = require("@aws-sdk/client-sqs");
|
|
47
|
+
const client_ssm_1 = require("@aws-sdk/client-ssm");
|
|
48
|
+
const signature_v4_1 = require("@smithy/signature-v4");
|
|
49
|
+
const protocol_http_1 = require("@smithy/protocol-http");
|
|
50
|
+
const sha256_js_1 = require("@aws-crypto/sha256-js");
|
|
51
|
+
const axios_1 = __importDefault(require("axios"));
|
|
52
|
+
const pako = __importStar(require("pako"));
|
|
53
|
+
const fs = __importStar(require("fs"));
|
|
54
|
+
const crypto = __importStar(require("crypto"));
|
|
55
|
+
class HelixConsumer {
|
|
56
|
+
/**
|
|
57
|
+
* Creates a new Helix Consumer instance.
|
|
58
|
+
* Initializes AWS clients and validates credentials on construction.
|
|
59
|
+
*/
|
|
60
|
+
constructor(config) {
|
|
61
|
+
this.queueUrl = null; // Cache for per-consumer queue URL
|
|
62
|
+
this.customerId = config.customerId;
|
|
63
|
+
this.apiEndpoint = (config.apiEndpoint || 'https://api.helix.tools').replace(/\/$/, '');
|
|
64
|
+
this.region = config.region || 'us-east-1';
|
|
65
|
+
this.awsAccessKeyId = config.awsAccessKeyId;
|
|
66
|
+
this.awsSecretAccessKey = config.awsSecretAccessKey;
|
|
67
|
+
// Initialize AWS clients
|
|
68
|
+
const awsConfig = {
|
|
69
|
+
region: this.region,
|
|
70
|
+
credentials: {
|
|
71
|
+
accessKeyId: this.awsAccessKeyId,
|
|
72
|
+
secretAccessKey: this.awsSecretAccessKey,
|
|
73
|
+
},
|
|
74
|
+
};
|
|
75
|
+
this.kmsClient = new client_kms_1.KMSClient(awsConfig);
|
|
76
|
+
this.stsClient = new client_sts_1.STSClient(awsConfig);
|
|
77
|
+
this.sqsClient = new client_sqs_1.SQSClient(awsConfig);
|
|
78
|
+
this.ssmClient = new client_ssm_1.SSMClient(awsConfig);
|
|
79
|
+
// Validate credentials immediately
|
|
80
|
+
this.validateCredentials();
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Validates AWS credentials by making a test STS call.
|
|
84
|
+
* Throws an error if credentials are invalid.
|
|
85
|
+
*/
|
|
86
|
+
async validateCredentials() {
|
|
87
|
+
try {
|
|
88
|
+
const command = new client_sts_1.GetCallerIdentityCommand({});
|
|
89
|
+
await this.stsClient.send(command);
|
|
90
|
+
}
|
|
91
|
+
catch (error) {
|
|
92
|
+
throw new Error(`Invalid AWS credentials. Please check your access key and secret key. Error: ${error}`);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Signs an HTTP request using AWS Signature Version 4.
|
|
97
|
+
* Used for authenticating API requests to Helix Connect Platform.
|
|
98
|
+
*/
|
|
99
|
+
async signRequest(method, path, body) {
|
|
100
|
+
const url = new URL(this.apiEndpoint + path);
|
|
101
|
+
const request = new protocol_http_1.HttpRequest({
|
|
102
|
+
method,
|
|
103
|
+
protocol: url.protocol,
|
|
104
|
+
hostname: url.hostname,
|
|
105
|
+
path: url.pathname + url.search,
|
|
106
|
+
headers: {
|
|
107
|
+
'Content-Type': 'application/json',
|
|
108
|
+
host: url.hostname,
|
|
109
|
+
},
|
|
110
|
+
body,
|
|
111
|
+
});
|
|
112
|
+
const signer = new signature_v4_1.SignatureV4({
|
|
113
|
+
credentials: {
|
|
114
|
+
accessKeyId: this.awsAccessKeyId,
|
|
115
|
+
secretAccessKey: this.awsSecretAccessKey,
|
|
116
|
+
},
|
|
117
|
+
region: this.region,
|
|
118
|
+
service: 'execute-api',
|
|
119
|
+
sha256: sha256_js_1.Sha256,
|
|
120
|
+
});
|
|
121
|
+
const signedRequest = await signer.sign(request);
|
|
122
|
+
return signedRequest.headers;
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* Makes an authenticated API request to Helix Connect Platform.
|
|
126
|
+
* Handles request signing, error responses, and retries.
|
|
127
|
+
*/
|
|
128
|
+
async makeApiRequest(method, path, data) {
|
|
129
|
+
const body = data ? JSON.stringify(data) : undefined;
|
|
130
|
+
const headers = await this.signRequest(method, path, body);
|
|
131
|
+
const config = {
|
|
132
|
+
method,
|
|
133
|
+
url: this.apiEndpoint + path,
|
|
134
|
+
headers,
|
|
135
|
+
data,
|
|
136
|
+
timeout: 30000, // 30 second timeout
|
|
137
|
+
};
|
|
138
|
+
try {
|
|
139
|
+
const response = await (0, axios_1.default)(config);
|
|
140
|
+
return response.data;
|
|
141
|
+
}
|
|
142
|
+
catch (error) {
|
|
143
|
+
if (error.response) {
|
|
144
|
+
const status = error.response.status;
|
|
145
|
+
const message = error.response.data?.error || error.response.statusText;
|
|
146
|
+
if (status === 401) {
|
|
147
|
+
throw new Error(`Authentication failed: ${message}`);
|
|
148
|
+
}
|
|
149
|
+
else if (status === 403) {
|
|
150
|
+
throw new Error(`Permission denied: ${message}`);
|
|
151
|
+
}
|
|
152
|
+
else if (status === 404) {
|
|
153
|
+
throw new Error(`Dataset not found: ${message}`);
|
|
154
|
+
}
|
|
155
|
+
else {
|
|
156
|
+
throw new Error(`API request failed: ${status} - ${message}`);
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
throw error;
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
/**
|
|
163
|
+
* Retrieves metadata for a specific dataset.
|
|
164
|
+
* Returns information about the dataset including size, compression, and encryption status.
|
|
165
|
+
*/
|
|
166
|
+
async getDataset(datasetId) {
|
|
167
|
+
const encodedId = encodeURIComponent(datasetId);
|
|
168
|
+
return this.makeApiRequest('GET', `/v1/datasets/${encodedId}`);
|
|
169
|
+
}
|
|
170
|
+
/**
|
|
171
|
+
* Generates a pre-signed S3 download URL for a dataset.
|
|
172
|
+
* The URL expires after a limited time and grants temporary access to the encrypted dataset file.
|
|
173
|
+
*/
|
|
174
|
+
async getDownloadUrl(datasetId) {
|
|
175
|
+
const encodedId = encodeURIComponent(datasetId);
|
|
176
|
+
return this.makeApiRequest('GET', `/v1/datasets/${encodedId}/download`);
|
|
177
|
+
}
|
|
178
|
+
/**
|
|
179
|
+
* Decompresses gzip-compressed data.
|
|
180
|
+
* Used internally after decryption to restore original dataset format.
|
|
181
|
+
*/
|
|
182
|
+
decompressData(data) {
|
|
183
|
+
try {
|
|
184
|
+
return Buffer.from(pako.ungzip(data));
|
|
185
|
+
}
|
|
186
|
+
catch (error) {
|
|
187
|
+
throw new Error(`Decompression failed: ${error}`);
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
/**
|
|
191
|
+
* Decrypts data using envelope encryption with KMS.
|
|
192
|
+
* Process: Decrypt data key with KMS, then decrypt data with AES-256-GCM.
|
|
193
|
+
* Format: [4 bytes: key length][encrypted key][16 bytes: IV][16 bytes: tag][encrypted data]
|
|
194
|
+
*/
|
|
195
|
+
async decryptData(data) {
|
|
196
|
+
try {
|
|
197
|
+
let offset = 0;
|
|
198
|
+
// Read encrypted key length (4 bytes)
|
|
199
|
+
const keyLength = data.readUInt32BE(offset);
|
|
200
|
+
offset += 4;
|
|
201
|
+
// Read encrypted data key
|
|
202
|
+
const encryptedKey = data.subarray(offset, offset + keyLength);
|
|
203
|
+
offset += keyLength;
|
|
204
|
+
// Read IV (16 bytes)
|
|
205
|
+
const iv = data.subarray(offset, offset + 16);
|
|
206
|
+
offset += 16;
|
|
207
|
+
// Read authentication tag (16 bytes)
|
|
208
|
+
const authTag = data.subarray(offset, offset + 16);
|
|
209
|
+
offset += 16;
|
|
210
|
+
// Remaining bytes are the encrypted data
|
|
211
|
+
const encryptedData = data.subarray(offset);
|
|
212
|
+
// Decrypt the data key using KMS
|
|
213
|
+
const decryptCommand = new client_kms_1.DecryptCommand({
|
|
214
|
+
CiphertextBlob: encryptedKey,
|
|
215
|
+
});
|
|
216
|
+
const decryptResult = await this.kmsClient.send(decryptCommand);
|
|
217
|
+
if (!decryptResult.Plaintext) {
|
|
218
|
+
throw new Error('KMS decryption returned no plaintext');
|
|
219
|
+
}
|
|
220
|
+
const dataKey = Buffer.from(decryptResult.Plaintext);
|
|
221
|
+
// Decrypt the data using AES-256-GCM
|
|
222
|
+
const decipher = crypto.createDecipheriv('aes-256-gcm', dataKey, iv);
|
|
223
|
+
decipher.setAuthTag(authTag);
|
|
224
|
+
const decrypted = Buffer.concat([
|
|
225
|
+
decipher.update(encryptedData),
|
|
226
|
+
decipher.final(),
|
|
227
|
+
]);
|
|
228
|
+
return decrypted;
|
|
229
|
+
}
|
|
230
|
+
catch (error) {
|
|
231
|
+
throw new Error(`Decryption failed: ${error}. Ensure you have KMS grant for this dataset.`);
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
/**
|
|
235
|
+
* Downloads a dataset from S3, automatically decrypting and decompressing if needed.
|
|
236
|
+
* The downloaded file is saved to the specified output path in its original format.
|
|
237
|
+
*
|
|
238
|
+
* Optimized for large files (>1GB) using streaming when possible.
|
|
239
|
+
*/
|
|
240
|
+
async downloadDataset(datasetId, outputPath, options = {}) {
|
|
241
|
+
const autoDecompress = options.autoDecompress !== false;
|
|
242
|
+
const autoDecrypt = options.autoDecrypt !== false;
|
|
243
|
+
// Get dataset metadata
|
|
244
|
+
const dataset = await this.getDataset(datasetId);
|
|
245
|
+
const metadata = dataset.metadata || {};
|
|
246
|
+
const isCompressed = metadata.compression_enabled || false;
|
|
247
|
+
const isEncrypted = metadata.encryption_enabled || false;
|
|
248
|
+
console.log(`Downloading dataset ${datasetId}...`);
|
|
249
|
+
console.log(` Compressed: ${isCompressed}`);
|
|
250
|
+
console.log(` Encrypted: ${isEncrypted}`);
|
|
251
|
+
// Get signed download URL
|
|
252
|
+
const urlInfo = await this.getDownloadUrl(datasetId);
|
|
253
|
+
const downloadUrl = urlInfo.download_url;
|
|
254
|
+
// Download file
|
|
255
|
+
const response = await axios_1.default.get(downloadUrl, {
|
|
256
|
+
responseType: 'arraybuffer',
|
|
257
|
+
timeout: 0, // No timeout for downloads
|
|
258
|
+
});
|
|
259
|
+
let data = Buffer.from(response.data);
|
|
260
|
+
const downloadedSizeGB = data.length / (1024 ** 3);
|
|
261
|
+
console.log(`Downloaded ${data.length} bytes${downloadedSizeGB > 1 ? ` (${downloadedSizeGB.toFixed(2)} GB)` : ''}`);
|
|
262
|
+
// Step 1: Decrypt FIRST (if needed)
|
|
263
|
+
if (isEncrypted && autoDecrypt) {
|
|
264
|
+
console.log(`Decrypting ${data.length} bytes with KMS...`);
|
|
265
|
+
data = await this.decryptData(data);
|
|
266
|
+
console.log(`Decrypted to ${data.length} bytes`);
|
|
267
|
+
}
|
|
268
|
+
// Step 2: Decompress SECOND (if needed) - use streaming for large files
|
|
269
|
+
if (isCompressed && autoDecompress) {
|
|
270
|
+
console.log(`Decompressing ${data.length} bytes...`);
|
|
271
|
+
// Use streaming decompression for large files to avoid Buffer size limits (2GB max)
|
|
272
|
+
// Estimate decompressed size (typically 10-20x for text data)
|
|
273
|
+
const estimatedDecompressed = data.length * 20;
|
|
274
|
+
const bufferLimit = 2147483647; // 2GB - max Buffer size in Node.js
|
|
275
|
+
const largeFileThreshold = 100 * 1024 * 1024; // 100MB compressed
|
|
276
|
+
if (data.length > largeFileThreshold && estimatedDecompressed > bufferLimit) {
|
|
277
|
+
const estimatedGB = estimatedDecompressed / (1024 ** 3);
|
|
278
|
+
console.log(`Large file detected (estimated ${estimatedGB.toFixed(2)} GB decompressed) - using streaming decompression`);
|
|
279
|
+
await this.decompressDataStream(data, outputPath);
|
|
280
|
+
console.log(`Streamed to ${outputPath}`);
|
|
281
|
+
return outputPath;
|
|
282
|
+
}
|
|
283
|
+
else {
|
|
284
|
+
// Small files - use in-memory decompression
|
|
285
|
+
data = this.decompressData(data);
|
|
286
|
+
const decompressedSizeGB = data.length / (1024 ** 3);
|
|
287
|
+
if (decompressedSizeGB > 1) {
|
|
288
|
+
console.log(`Decompressed to ${decompressedSizeGB.toFixed(2)} GB`);
|
|
289
|
+
}
|
|
290
|
+
else {
|
|
291
|
+
console.log(`Decompressed to ${data.length} bytes`);
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
// Write to file (only for small files or uncompressed data)
|
|
296
|
+
fs.writeFileSync(outputPath, data);
|
|
297
|
+
console.log(`Saved to ${outputPath}`);
|
|
298
|
+
return outputPath;
|
|
299
|
+
}
|
|
300
|
+
/**
|
|
301
|
+
* Decompresses data using streaming to avoid buffer limits.
|
|
302
|
+
* Used for large files that would exceed Node.js Buffer size limits (2GB).
|
|
303
|
+
*/
|
|
304
|
+
async decompressDataStream(data, outputPath) {
|
|
305
|
+
return new Promise((resolve, reject) => {
|
|
306
|
+
const zlib = require('zlib');
|
|
307
|
+
const stream = require('stream');
|
|
308
|
+
// Create a readable stream from the buffer
|
|
309
|
+
const bufferStream = new stream.PassThrough();
|
|
310
|
+
bufferStream.end(data);
|
|
311
|
+
// Create gunzip stream
|
|
312
|
+
const gunzip = zlib.createGunzip();
|
|
313
|
+
// Create write stream to file
|
|
314
|
+
const writeStream = fs.createWriteStream(outputPath);
|
|
315
|
+
// Pipe: buffer -> gunzip -> file
|
|
316
|
+
bufferStream
|
|
317
|
+
.pipe(gunzip)
|
|
318
|
+
.pipe(writeStream)
|
|
319
|
+
.on('finish', () => {
|
|
320
|
+
// Get final file size
|
|
321
|
+
const stats = fs.statSync(outputPath);
|
|
322
|
+
const sizeGB = stats.size / (1024 ** 3);
|
|
323
|
+
if (sizeGB > 1) {
|
|
324
|
+
console.log(`Decompressed to ${sizeGB.toFixed(2)} GB`);
|
|
325
|
+
}
|
|
326
|
+
else {
|
|
327
|
+
console.log(`Decompressed to ${stats.size} bytes`);
|
|
328
|
+
}
|
|
329
|
+
resolve();
|
|
330
|
+
})
|
|
331
|
+
.on('error', (err) => reject(err));
|
|
332
|
+
});
|
|
333
|
+
}
|
|
334
|
+
/**
|
|
335
|
+
* Lists all datasets available to this consumer.
|
|
336
|
+
* Returns metadata for datasets the consumer has permission to access.
|
|
337
|
+
*/
|
|
338
|
+
async listDatasets() {
|
|
339
|
+
const response = await this.makeApiRequest('GET', '/v1/datasets');
|
|
340
|
+
return response.datasets;
|
|
341
|
+
}
|
|
342
|
+
/**
|
|
343
|
+
* Lists all active subscriptions for this consumer.
|
|
344
|
+
*
|
|
345
|
+
* @returns Array of subscription objects
|
|
346
|
+
*/
|
|
347
|
+
async listSubscriptions() {
|
|
348
|
+
const response = await this.makeApiRequest('GET', '/v1/subscriptions');
|
|
349
|
+
return response.subscriptions;
|
|
350
|
+
}
|
|
351
|
+
/**
|
|
352
|
+
* Creates a subscription request to access a producer's datasets.
|
|
353
|
+
* The producer must approve the request before the consumer gains access.
|
|
354
|
+
*/
|
|
355
|
+
async createSubscriptionRequest(params) {
|
|
356
|
+
const payload = {
|
|
357
|
+
producer_id: params.producerId,
|
|
358
|
+
tier: params.tier || 'basic',
|
|
359
|
+
};
|
|
360
|
+
if (params.datasetId) {
|
|
361
|
+
payload.dataset_id = params.datasetId;
|
|
362
|
+
}
|
|
363
|
+
if (params.message) {
|
|
364
|
+
payload.message = params.message;
|
|
365
|
+
}
|
|
366
|
+
return this.makeApiRequest('POST', '/v1/subscription-requests', payload);
|
|
367
|
+
}
|
|
368
|
+
/**
|
|
369
|
+
* Polls the shared SQS queue for dataset upload notifications.
|
|
370
|
+
*
|
|
371
|
+
* IMPORTANT: This uses a SHARED queue for all consumers. The application should
|
|
372
|
+
* filter notifications based on subscriptions. Only download datasets from
|
|
373
|
+
* producers you are subscribed to.
|
|
374
|
+
*
|
|
375
|
+
* Messages are automatically acknowledged (deleted) by default after retrieval.
|
|
376
|
+
* This prevents duplicate processing and simplifies the developer experience.
|
|
377
|
+
* Set autoAcknowledge to false if you need manual control over message deletion.
|
|
378
|
+
*
|
|
379
|
+
* @param maxMessages - Maximum number of messages to retrieve (1-10, default: 10)
|
|
380
|
+
* @param waitTimeSeconds - Long polling wait time (0-20 seconds, default: 20)
|
|
381
|
+
* @param visibilityTimeout - How long messages are hidden after retrieval (default: 300s)
|
|
382
|
+
* @param autoAcknowledge - Automatically acknowledge (delete) messages after receiving (default: true)
|
|
383
|
+
* @param subscriptionIds - Optional array of subscription IDs to filter notifications
|
|
384
|
+
* @returns Array of notification objects
|
|
385
|
+
*
|
|
386
|
+
* @example
|
|
387
|
+
* ```typescript
|
|
388
|
+
* const consumer = new HelixConsumer(...);
|
|
389
|
+
*
|
|
390
|
+
* // Simple usage - messages auto-deleted after poll
|
|
391
|
+
* const notifications = await consumer.pollNotifications({
|
|
392
|
+
* subscriptionIds: ['sub-123'],
|
|
393
|
+
* maxMessages: 5
|
|
394
|
+
* });
|
|
395
|
+
* for (const notif of notifications) {
|
|
396
|
+
* console.log(`New dataset: ${notif.dataset_name}`);
|
|
397
|
+
* await consumer.downloadDataset(notif.dataset_id, './output.json');
|
|
398
|
+
* // No need to delete - already handled automatically!
|
|
399
|
+
* }
|
|
400
|
+
*
|
|
401
|
+
* // Advanced usage - manual acknowledgment for custom retry logic
|
|
402
|
+
* const notifications = await consumer.pollNotifications({
|
|
403
|
+
* autoAcknowledge: false,
|
|
404
|
+
* maxMessages: 5
|
|
405
|
+
* });
|
|
406
|
+
* for (const notif of notifications) {
|
|
407
|
+
* try {
|
|
408
|
+
* await consumer.downloadDataset(notif.dataset_id, './output.json');
|
|
409
|
+
* // Manually acknowledge only after successful processing
|
|
410
|
+
* await consumer.deleteNotification(notif.receipt_handle);
|
|
411
|
+
* } catch (error) {
|
|
412
|
+
* console.error('Processing failed, message will retry:', error);
|
|
413
|
+
* // Message not deleted, will become visible again after visibility timeout
|
|
414
|
+
* }
|
|
415
|
+
* }
|
|
416
|
+
* ```
|
|
417
|
+
*/
|
|
418
|
+
async pollNotifications(options = {}) {
|
|
419
|
+
const maxMessages = Math.min(options.maxMessages || 10, 10); // AWS limit is 10
|
|
420
|
+
const waitTimeSeconds = Math.min(options.waitTimeSeconds || 20, 20); // AWS limit is 20
|
|
421
|
+
const visibilityTimeout = options.visibilityTimeout || 300;
|
|
422
|
+
const autoAcknowledge = options.autoAcknowledge !== undefined ? options.autoAcknowledge : true; // Default to true
|
|
423
|
+
const subscriptionIds = options.subscriptionIds || [];
|
|
424
|
+
// Get per-consumer queue URL from first active subscription
|
|
425
|
+
if (!this.queueUrl) {
|
|
426
|
+
try {
|
|
427
|
+
const subscriptions = await this.listSubscriptions();
|
|
428
|
+
if (subscriptions.length === 0) {
|
|
429
|
+
throw new Error('No active subscriptions found. Create a subscription first using createSubscriptionRequest()');
|
|
430
|
+
}
|
|
431
|
+
// Get queue URL from first subscription (all subscriptions for same consumer share same queue)
|
|
432
|
+
const subscription = subscriptions.find(sub => sub.sqs_queue_url);
|
|
433
|
+
if (!subscription || !subscription.sqs_queue_url) {
|
|
434
|
+
throw new Error('Per-consumer queue not provisioned. This may be a legacy subscription. ' +
|
|
435
|
+
'Please contact support or create a new subscription to get a dedicated queue.');
|
|
436
|
+
}
|
|
437
|
+
this.queueUrl = subscription.sqs_queue_url;
|
|
438
|
+
}
|
|
439
|
+
catch (error) {
|
|
440
|
+
throw new Error(`Failed to get per-consumer queue URL: ${error}`);
|
|
441
|
+
}
|
|
442
|
+
}
|
|
443
|
+
// Poll SQS for messages from per-consumer queue
|
|
444
|
+
let messages;
|
|
445
|
+
try {
|
|
446
|
+
const command = new client_sqs_1.ReceiveMessageCommand({
|
|
447
|
+
QueueUrl: this.queueUrl,
|
|
448
|
+
MaxNumberOfMessages: maxMessages,
|
|
449
|
+
WaitTimeSeconds: waitTimeSeconds,
|
|
450
|
+
VisibilityTimeout: visibilityTimeout,
|
|
451
|
+
MessageAttributeNames: ['All'],
|
|
452
|
+
});
|
|
453
|
+
const response = await this.sqsClient.send(command);
|
|
454
|
+
messages = response.Messages || [];
|
|
455
|
+
}
|
|
456
|
+
catch (error) {
|
|
457
|
+
throw new Error(`Failed to poll SQS queue: ${error}`);
|
|
458
|
+
}
|
|
459
|
+
const notifications = [];
|
|
460
|
+
for (const message of messages) {
|
|
461
|
+
try {
|
|
462
|
+
if (!message.Body)
|
|
463
|
+
continue;
|
|
464
|
+
// Parse SNS message to get the custom notification payload
|
|
465
|
+
const snsMessage = JSON.parse(message.Body);
|
|
466
|
+
const notificationData = JSON.parse(snsMessage.Message);
|
|
467
|
+
// SNS filter policy ensures only messages for this consumer reach this queue
|
|
468
|
+
// No need for subscriber_id filtering - it's already guaranteed by SNS
|
|
469
|
+
// Optional filter by subscription IDs if provided (for advanced use cases)
|
|
470
|
+
if (subscriptionIds.length > 0) {
|
|
471
|
+
if (!subscriptionIds.includes(notificationData.subscription_id)) {
|
|
472
|
+
continue; // Skip this notification - doesn't match our subscriptions
|
|
473
|
+
}
|
|
474
|
+
}
|
|
475
|
+
const notification = {
|
|
476
|
+
message_id: message.MessageId || '',
|
|
477
|
+
receipt_handle: message.ReceiptHandle || '',
|
|
478
|
+
event_type: notificationData.event_type,
|
|
479
|
+
producer_id: notificationData.producer_id,
|
|
480
|
+
dataset_id: notificationData.dataset_id,
|
|
481
|
+
dataset_name: notificationData.dataset_name,
|
|
482
|
+
s3_bucket: notificationData.s3_bucket,
|
|
483
|
+
s3_key: notificationData.s3_key,
|
|
484
|
+
size_bytes: notificationData.size_bytes,
|
|
485
|
+
timestamp: notificationData.timestamp,
|
|
486
|
+
subscriber_id: notificationData.subscriber_id,
|
|
487
|
+
subscription_id: notificationData.subscription_id,
|
|
488
|
+
raw_message: message.Body,
|
|
489
|
+
};
|
|
490
|
+
notifications.push(notification);
|
|
491
|
+
// Auto-acknowledge (delete) message by default
|
|
492
|
+
if (autoAcknowledge && message.ReceiptHandle) {
|
|
493
|
+
await this.deleteNotification(message.ReceiptHandle);
|
|
494
|
+
}
|
|
495
|
+
}
|
|
496
|
+
catch (error) {
|
|
497
|
+
console.warn(`Failed to parse notification message ${message.MessageId}: ${error}`);
|
|
498
|
+
continue;
|
|
499
|
+
}
|
|
500
|
+
}
|
|
501
|
+
return notifications;
|
|
502
|
+
}
|
|
503
|
+
/**
|
|
504
|
+
* Deletes a notification message from the SQS queue after processing.
|
|
505
|
+
*
|
|
506
|
+
* @param receiptHandle - The receipt handle from pollNotifications()
|
|
507
|
+
*
|
|
508
|
+
* @example
|
|
509
|
+
* ```typescript
|
|
510
|
+
* const consumer = new HelixConsumer(...);
|
|
511
|
+
* const notifications = await consumer.pollNotifications();
|
|
512
|
+
* for (const notif of notifications) {
|
|
513
|
+
* // Process notification...
|
|
514
|
+
* await consumer.deleteNotification(notif.receipt_handle);
|
|
515
|
+
* }
|
|
516
|
+
* ```
|
|
517
|
+
*/
|
|
518
|
+
async deleteNotification(receiptHandle) {
|
|
519
|
+
if (!this.queueUrl) {
|
|
520
|
+
throw new Error('Queue URL not initialized. Call pollNotifications() first.');
|
|
521
|
+
}
|
|
522
|
+
try {
|
|
523
|
+
const deleteCommand = new client_sqs_1.DeleteMessageCommand({
|
|
524
|
+
QueueUrl: this.queueUrl,
|
|
525
|
+
ReceiptHandle: receiptHandle,
|
|
526
|
+
});
|
|
527
|
+
await this.sqsClient.send(deleteCommand);
|
|
528
|
+
}
|
|
529
|
+
catch (error) {
|
|
530
|
+
throw new Error(`Failed to delete notification: ${error}`);
|
|
531
|
+
}
|
|
532
|
+
}
|
|
533
|
+
/**
|
|
534
|
+
* Extracts producer ID from S3 key path.
|
|
535
|
+
* S3 keys follow the pattern: datasets/{dataset_name}/{date}/{file}
|
|
536
|
+
*
|
|
537
|
+
* @param s3Key - S3 object key
|
|
538
|
+
* @returns Extracted producer ID (or 'unknown' if not found)
|
|
539
|
+
*/
|
|
540
|
+
extractProducerId(s3Key) {
|
|
541
|
+
try {
|
|
542
|
+
// Example key: datasets/company-123-producer-Dataset Name/2025-11-01/file.json.gz
|
|
543
|
+
const parts = s3Key.split('/');
|
|
544
|
+
if (parts.length >= 2) {
|
|
545
|
+
const datasetName = parts[1];
|
|
546
|
+
// Extract company ID from dataset name
|
|
547
|
+
if (datasetName.includes('company-')) {
|
|
548
|
+
const companyId = datasetName.split('-')[1];
|
|
549
|
+
return `company-${companyId}`;
|
|
550
|
+
}
|
|
551
|
+
}
|
|
552
|
+
return 'unknown';
|
|
553
|
+
}
|
|
554
|
+
catch (error) {
|
|
555
|
+
return 'unknown';
|
|
556
|
+
}
|
|
557
|
+
}
|
|
558
|
+
}
|
|
559
|
+
exports.HelixConsumer = HelixConsumer;
|
|
560
|
+
//# sourceMappingURL=consumer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"consumer.js","sourceRoot":"","sources":["../src/consumer.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,oDAAgE;AAChE,oDAA0E;AAC1E,oDAA6F;AAC7F,oDAAqE;AACrE,uDAAmD;AACnD,yDAAoD;AACpD,qDAA+C;AAC/C,kDAAkD;AAClD,2CAA6B;AAC7B,uCAAyB;AACzB,+CAAiC;AA0DjC,MAAa,aAAa;IAYxB;;;OAGG;IACH,YAAY,MAA2B;QAN/B,aAAQ,GAAkB,IAAI,CAAC,CAAC,mCAAmC;QAOzE,IAAI,CAAC,UAAU,GAAG,MAAM,CAAC,UAAU,CAAC;QACpC,IAAI,CAAC,WAAW,GAAG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,CAAC,CAAC,CAAC,CAAC;gBAC7B,uCAAuC;gBACvC,IAAI,WAAW,CAAC,QAAQ,CAAC,UAAU,CAAC,EAAE,CAAC;oBACrC,MAAM,SAAS,GAAG,WAAW,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;oBAC5C,OAAO,WAAW,SAAS,EAAE,CAAC;gBAChC,CAAC;YACH,CAAC;YACD,OAAO,SAAS,CAAC;QACnB,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,OAAO,SAAS,CAAC;QACnB,CAAC;IACH,CAAC;CACF;AAlmBD,sCAkmBC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export { HelixConsumer, type HelixConsumerConfig, type DatasetMetadata, type DownloadUrlInfo, type SubscriptionRequest } from './consumer';
|
|
2
|
+
export { HelixProducer, type HelixProducerConfig, type UploadOptions, type Dataset } from './producer';
|
|
3
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,KAAK,mBAAmB,EAAE,KAAK,eAAe,EAAE,KAAK,eAAe,EAAE,KAAK,mBAAmB,EAAE,MAAM,YAAY,CAAC;AAC3I,OAAO,EAAE,aAAa,EAAE,KAAK,mBAAmB,EAAE,KAAK,aAAa,EAAE,KAAK,OAAO,EAAE,MAAM,YAAY,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.HelixProducer = exports.HelixConsumer = void 0;
|
|
4
|
+
var consumer_1 = require("./consumer");
|
|
5
|
+
Object.defineProperty(exports, "HelixConsumer", { enumerable: true, get: function () { return consumer_1.HelixConsumer; } });
|
|
6
|
+
var producer_1 = require("./producer");
|
|
7
|
+
Object.defineProperty(exports, "HelixProducer", { enumerable: true, get: function () { return producer_1.HelixProducer; } });
|
|
8
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,uCAA2I;AAAlI,yGAAA,aAAa,OAAA;AACtB,uCAAuG;AAA9F,yGAAA,aAAa,OAAA"}
|