@whaly/connector-sdk 0.1.1 → 0.3.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/README.md +92 -0
- package/dist/index.d.mts +568 -200
- package/dist/index.d.ts +568 -200
- package/dist/index.js +1389 -584
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1354 -579
- package/dist/index.mjs.map +1 -1
- package/package.json +16 -5
package/README.md
ADDED
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
# @whaly/connector-sdk
|
|
2
|
+
|
|
3
|
+
A TypeScript SDK for building data connectors with support for file processing (Excel/CSV), cloud storage, SFTP, and BigQuery.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @whaly/connector-sdk
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Overview
|
|
12
|
+
|
|
13
|
+
The SDK provides a pipeline architecture: **Tap** (data source) → **Stream** (data extraction) → **Target** (data destination).
|
|
14
|
+
|
|
15
|
+
It supports two main connector types:
|
|
16
|
+
- **API connectors** — sync data from REST APIs using `RESTStream` with built-in pagination, retries, and auth
|
|
17
|
+
- **File connectors** — ingest Excel/CSV files from GCS, SFTP, or local disk using `FileStream`
|
|
18
|
+
|
|
19
|
+
### Key Components
|
|
20
|
+
|
|
21
|
+
| Component | Description |
|
|
22
|
+
|---|---|
|
|
23
|
+
| `RESTStream` | Stream for REST API endpoints with pagination and auth |
|
|
24
|
+
| `FileStream` / `FileTap` | Stream and Tap implementations for file-based data sources |
|
|
25
|
+
| `CloudStorageService` | Google Cloud Storage client with marker-file tracking |
|
|
26
|
+
| `SftpClient` | SFTP client for remote file access |
|
|
27
|
+
| `BigQueryTarget` | BigQuery target implementation |
|
|
28
|
+
| `GCSStateProvider` | State management backed by GCS |
|
|
29
|
+
|
|
30
|
+
## Quick Start
|
|
31
|
+
|
|
32
|
+
```typescript
|
|
33
|
+
import {
|
|
34
|
+
CloudStorageService,
|
|
35
|
+
createExcelStreamConfig,
|
|
36
|
+
processFileStreams,
|
|
37
|
+
FilePatterns,
|
|
38
|
+
VariableExtractors,
|
|
39
|
+
ReplicationMethod,
|
|
40
|
+
} from "@whaly/connector-sdk";
|
|
41
|
+
|
|
42
|
+
// Define how to read your Excel file
|
|
43
|
+
const config = {
|
|
44
|
+
type: "single-sheet-extraction" as const,
|
|
45
|
+
extension: "xlsx",
|
|
46
|
+
tableName: "products",
|
|
47
|
+
sheetName: "Sheet1",
|
|
48
|
+
numberOfRowsToSkip: 1,
|
|
49
|
+
replicationMethod: ReplicationMethod.FULL_TABLE,
|
|
50
|
+
fileNameValidator: FilePatterns.startsWith("product"),
|
|
51
|
+
fileNameVariablesExtractor: VariableExtractors.filename(),
|
|
52
|
+
columns: {
|
|
53
|
+
product_id: { type: "STRING" as const, column: "A", primaryKey: true },
|
|
54
|
+
product_name: { type: "STRING" as const, column: "B" },
|
|
55
|
+
price: { type: "FLOAT" as const, column: "C" },
|
|
56
|
+
},
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
// Download from GCS, process, and send to target
|
|
60
|
+
const storage = new CloudStorageService("my-bucket", "incoming/", {
|
|
61
|
+
supportedExtensions: [".xlsx"],
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
const files = await storage.getUnprocessedFiles();
|
|
65
|
+
|
|
66
|
+
for (const filePath of files) {
|
|
67
|
+
const fileName = filePath.split("/").pop()!;
|
|
68
|
+
const localPath = await storage.downloadFile(filePath, fileName);
|
|
69
|
+
|
|
70
|
+
const streamConfig = createExcelStreamConfig(config, fileName, localPath);
|
|
71
|
+
await processFileStreams(
|
|
72
|
+
[{ config: streamConfig, filePath: localPath }],
|
|
73
|
+
{ bookmarks: {} },
|
|
74
|
+
target,
|
|
75
|
+
);
|
|
76
|
+
|
|
77
|
+
await storage.createMarkerFile(filePath);
|
|
78
|
+
}
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
## Documentation
|
|
82
|
+
|
|
83
|
+
| Document | Description |
|
|
84
|
+
|---|---|
|
|
85
|
+
| [API Reference](./docs/api-reference.md) | Building API connectors (RESTStream, Tap, Auth), core types, and full reference |
|
|
86
|
+
| [File Processing Guide](./docs/file-processing.md) | Excel & CSV import, services (GCS, SFTP, ZIP), full examples |
|
|
87
|
+
| [Changelog](./CHANGELOG.md) | Release history |
|
|
88
|
+
| [Migration Guide](./MIGRATION.md) | Upgrade instructions between versions |
|
|
89
|
+
|
|
90
|
+
## License
|
|
91
|
+
|
|
92
|
+
Apache-2.0
|