@databricks/zerobus-ingest-sdk 0.0.1 → 0.1.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/build.rs ADDED
@@ -0,0 +1,5 @@
1
+ extern crate napi_build;
2
+
3
+ fn main() {
4
+ napi_build::setup();
5
+ }
package/package.json CHANGED
@@ -1,11 +1,93 @@
1
1
  {
2
2
  "name": "@databricks/zerobus-ingest-sdk",
3
- "version": "0.0.1",
4
- "description": "",
3
+ "version": "0.1.1",
4
+ "description": "TypeScript/Node.js SDK for streaming data ingestion into Databricks Delta tables using Zerobus",
5
5
  "main": "index.js",
6
+ "types": "index.d.ts",
7
+ "keywords": [
8
+ "databricks",
9
+ "delta",
10
+ "streaming",
11
+ "ingestion",
12
+ "zerobus",
13
+ "typescript",
14
+ "rust"
15
+ ],
16
+ "repository": {
17
+ "type": "git",
18
+ "url": "https://github.com/databricks/zerobus-sdk-ts.git"
19
+ },
20
+ "license": "Databricks License",
21
+ "files": [
22
+ "index.js",
23
+ "index.d.ts",
24
+ "README.md",
25
+ "LICENSE",
26
+ "src/",
27
+ "utils/",
28
+ "schemas/",
29
+ "Cargo.toml",
30
+ "Cargo.lock",
31
+ "build.rs",
32
+ "*.node"
33
+ ],
34
+ "napi": {
35
+ "name": "zerobus-ingest-sdk",
36
+ "triples": {
37
+ "defaults": true,
38
+ "additional": [
39
+ "x86_64-unknown-linux-musl",
40
+ "aarch64-unknown-linux-gnu",
41
+ "aarch64-apple-darwin",
42
+ "aarch64-unknown-linux-musl"
43
+ ]
44
+ }
45
+ },
46
+ "engines": {
47
+ "node": ">= 16"
48
+ },
6
49
  "scripts": {
7
- "test": "echo \"Error: no test specified\" && exit 1"
50
+ "artifacts": "napi artifacts",
51
+ "build": "napi build --platform --release",
52
+ "build:debug": "napi build --platform",
53
+ "build:proto": "mkdir -p examples/generated && pbjs -t static-module -w commonjs -o examples/generated/air_quality.js schemas/air_quality.proto && pbts -o examples/generated/air_quality.d.ts examples/generated/air_quality.js && protoc --descriptor_set_out=schemas/air_quality_descriptor.pb --include_imports schemas/air_quality.proto",
54
+ "prepublishOnly": "napi prepublish -t npm",
55
+ "test": "tsx --test test/unit.test.ts test/integration.test.ts",
56
+ "test:unit": "tsx --test test/unit.test.ts",
57
+ "test:integration": "tsx --test test/integration.test.ts",
58
+ "universal": "napi universal",
59
+ "version": "napi version",
60
+ "example:json": "tsx examples/json.ts",
61
+ "example:proto": "tsx examples/proto.ts",
62
+ "example:parallel": "tsx examples/parallel_streams.ts"
63
+ },
64
+ "peerDependencies": {
65
+ "protobufjs": "^7.0.0"
66
+ },
67
+ "peerDependenciesMeta": {
68
+ "protobufjs": {
69
+ "optional": true
70
+ }
71
+ },
72
+ "devDependencies": {
73
+ "@napi-rs/cli": "^2.18.0",
74
+ "@types/node": "^20.0.0",
75
+ "dotenv": "^17.2.3",
76
+ "protobufjs": "^7.5.4",
77
+ "protobufjs-cli": "^2.0.0",
78
+ "tsx": "^4.21.0",
79
+ "typescript": "^5.3.0"
80
+ },
81
+ "overrides": {
82
+ "glob": "^10.0.0"
8
83
  },
9
- "author": "",
10
- "license": "Apache-2.0"
84
+ "optionalDependencies": {
85
+ "@databricks/zerobus-ingest-sdk-win32-x64-msvc": "0.1.1",
86
+ "@databricks/zerobus-ingest-sdk-darwin-x64": "0.1.1",
87
+ "@databricks/zerobus-ingest-sdk-linux-x64-gnu": "0.1.1",
88
+ "@databricks/zerobus-ingest-sdk-linux-x64-musl": "0.1.1",
89
+ "@databricks/zerobus-ingest-sdk-linux-arm64-gnu": "0.1.1",
90
+ "@databricks/zerobus-ingest-sdk-darwin-arm64": "0.1.1",
91
+ "@databricks/zerobus-ingest-sdk-linux-arm64-musl": "0.1.1"
92
+ }
11
93
  }
@@ -0,0 +1,10 @@
1
+ syntax = "proto2";
2
+
3
+ package examples;
4
+
5
+ // Example message representing air quality sensor data
6
+ message AirQuality {
7
+ optional string device_name = 1;
8
+ optional int32 temp = 2;
9
+ optional int64 humidity = 3;
10
+ }
@@ -0,0 +1,82 @@
1
+ /**
2
+ * Interface for providing custom headers to Zerobus streams.
3
+ *
4
+ * Implement this interface to use custom authentication beyond OAuth,
5
+ * such as Personal Access Tokens (PAT) or custom auth tokens.
6
+ */
7
+ export interface HeadersProvider {
8
+ /**
9
+ * Returns headers as array of [name, value] tuples.
10
+ *
11
+ * Required headers:
12
+ * - ["authorization", "Bearer <token>"]
13
+ * - ["x-databricks-zerobus-table-name", "<table_name>"]
14
+ *
15
+ * @returns Promise resolving to array of header name-value pairs
16
+ */
17
+ getHeaders(): Promise<Array<[string, string]>>;
18
+ }
19
+
20
+ /**
21
+ * OAuth 2.0 Client Credentials headers provider.
22
+ *
23
+ * **IMPORTANT: DO NOT instantiate this class directly.**
24
+ *
25
+ * OAuth authentication is handled automatically by the Rust SDK when you call
26
+ * `createStream()` with clientId and clientSecret parameters (without providing
27
+ * a headers_provider).
28
+ *
29
+ * This class exists for:
30
+ * 1. Documentation purposes - showing the HeadersProvider pattern
31
+ * 2. API consistency with other Zerobus SDKs (Python, Java, Rust)
32
+ *
33
+ * **How to use OAuth authentication:**
34
+ * ```typescript
35
+ * // OAuth is the default - just pass clientId and clientSecret
36
+ * const stream = await sdk.createStream(
37
+ * tableProperties,
38
+ * clientId, // OAuth client ID
39
+ * clientSecret, // OAuth client secret
40
+ * options
41
+ * // No headers_provider parameter = OAuth authentication
42
+ * );
43
+ * ```
44
+ *
45
+ * **How to use custom authentication (PAT, etc.):**
46
+ * ```typescript
47
+ * class CustomHeadersProvider implements HeadersProvider {
48
+ * async getHeaders() {
49
+ * return [
50
+ * ["authorization", `Bearer ${myToken}`],
51
+ * ["x-databricks-zerobus-table-name", tableName]
52
+ * ];
53
+ * }
54
+ * }
55
+ *
56
+ * const provider = new CustomHeadersProvider();
57
+ * const stream = await sdk.createStream(
58
+ * tableProperties,
59
+ * '', // ignored
60
+ * '', // ignored
61
+ * options,
62
+ * { getHeadersCallback: provider.getHeaders.bind(provider) }
63
+ * );
64
+ * ```
65
+ */
66
+ export class OAuthHeadersProvider implements HeadersProvider {
67
+ constructor(
68
+ private clientId: string,
69
+ private clientSecret: string,
70
+ private tableName: string,
71
+ private workspaceUrl: string
72
+ ) {}
73
+
74
+ async getHeaders(): Promise<Array<[string, string]>> {
75
+ throw new Error(
76
+ 'OAuthHeadersProvider should not be instantiated directly. ' +
77
+ 'OAuth authentication is handled internally by the Rust SDK. ' +
78
+ 'To use OAuth: call createStream(tableProperties, clientId, clientSecret, options) without the headers_provider parameter. ' +
79
+ 'To use custom authentication: implement the HeadersProvider interface.'
80
+ );
81
+ }
82
+ }