@saurabh_singh_06/schema-registry 1.0.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/dist/confluent-client.d.ts +13 -0
- package/dist/confluent-client.js +37 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +18 -0
- package/dist/schema-registry-client.d.ts +6 -0
- package/dist/schema-registry-client.js +2 -0
- package/dist/types.d.ts +0 -0
- package/dist/types.js +1 -0
- package/package.json +17 -0
- package/src/confluent-client.ts +53 -0
- package/src/index.ts +3 -0
- package/src/schema-registry-client.ts +7 -0
- package/tsconfig.json +8 -0
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { SchemaRegistryClient } from "./schema-registry-client";
|
|
2
|
+
import { Schema } from "@saurabh_singh_06/kafka-core";
|
|
3
|
+
export interface ConfluentConfig {
|
|
4
|
+
baseUrl: string;
|
|
5
|
+
authToken?: string;
|
|
6
|
+
}
|
|
7
|
+
export declare class ConfluentSchemaRegistryClient implements SchemaRegistryClient {
|
|
8
|
+
private config;
|
|
9
|
+
constructor(config: ConfluentConfig);
|
|
10
|
+
getLatestSchema(subject: string): Promise<Schema>;
|
|
11
|
+
getSchemaById(id: number): Promise<Schema>;
|
|
12
|
+
registerSchema(subject: string, schema: string): Promise<number>;
|
|
13
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.ConfluentSchemaRegistryClient = void 0;
|
|
7
|
+
const axios_1 = __importDefault(require("axios"));
|
|
8
|
+
class ConfluentSchemaRegistryClient {
|
|
9
|
+
constructor(config) {
|
|
10
|
+
this.config = config;
|
|
11
|
+
}
|
|
12
|
+
async getLatestSchema(subject) {
|
|
13
|
+
const res = await axios_1.default.get(`${this.config.baseUrl}/subjects/${subject}/versions/latest`);
|
|
14
|
+
return {
|
|
15
|
+
id: res.data.id,
|
|
16
|
+
subject,
|
|
17
|
+
version: res.data.version,
|
|
18
|
+
definition: JSON.stringify(res.data.schema),
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
async getSchemaById(id) {
|
|
22
|
+
const res = await axios_1.default.get(`${this.config.baseUrl}/schemas/ids/${id}`);
|
|
23
|
+
return {
|
|
24
|
+
id,
|
|
25
|
+
subject: res.data.subject || "unknown",
|
|
26
|
+
version: res.data.version || 0,
|
|
27
|
+
definition: JSON.stringify(res.data.schema),
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
async registerSchema(subject, schema) {
|
|
31
|
+
const res = await axios_1.default.post(`${this.config.baseUrl}/subjects/${subject}/versions`, {
|
|
32
|
+
schema,
|
|
33
|
+
});
|
|
34
|
+
return res.data.id;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
exports.ConfluentSchemaRegistryClient = ConfluentSchemaRegistryClient;
|
package/dist/index.d.ts
ADDED
package/dist/index.js
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./schema-registry-client"), exports);
|
|
18
|
+
__exportStar(require("./confluent-client"), exports);
|
package/dist/types.d.ts
ADDED
|
File without changes
|
package/dist/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";
|
package/package.json
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@saurabh_singh_06/schema-registry",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"types": "dist/index.d.ts",
|
|
7
|
+
"keywords": [],
|
|
8
|
+
"author": "",
|
|
9
|
+
"license": "ISC",
|
|
10
|
+
"dependencies": {
|
|
11
|
+
"axios": "^1.18.1",
|
|
12
|
+
"@saurabh_singh_06/kafka-core": "1.0.0"
|
|
13
|
+
},
|
|
14
|
+
"scripts": {
|
|
15
|
+
"build": "tsc"
|
|
16
|
+
}
|
|
17
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import axios from "axios";
|
|
2
|
+
import {
|
|
3
|
+
SchemaRegistryClient,
|
|
4
|
+
} from "./schema-registry-client";
|
|
5
|
+
import { Schema } from "@saurabh_singh_06/kafka-core";
|
|
6
|
+
|
|
7
|
+
export interface ConfluentConfig {
|
|
8
|
+
baseUrl: string;
|
|
9
|
+
authToken?: string;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export class ConfluentSchemaRegistryClient
|
|
13
|
+
implements SchemaRegistryClient
|
|
14
|
+
{
|
|
15
|
+
constructor(private config: ConfluentConfig) {}
|
|
16
|
+
|
|
17
|
+
async getLatestSchema(subject: string): Promise<Schema> {
|
|
18
|
+
const res = await axios.get(
|
|
19
|
+
`${this.config.baseUrl}/subjects/${subject}/versions/latest`
|
|
20
|
+
);
|
|
21
|
+
|
|
22
|
+
return {
|
|
23
|
+
id: res.data.id,
|
|
24
|
+
subject,
|
|
25
|
+
version: res.data.version,
|
|
26
|
+
definition: JSON.stringify(res.data.schema),
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
async getSchemaById(id: number): Promise<Schema> {
|
|
31
|
+
const res = await axios.get(
|
|
32
|
+
`${this.config.baseUrl}/schemas/ids/${id}`
|
|
33
|
+
);
|
|
34
|
+
|
|
35
|
+
return {
|
|
36
|
+
id,
|
|
37
|
+
subject: res.data.subject || "unknown",
|
|
38
|
+
version: res.data.version || 0,
|
|
39
|
+
definition: JSON.stringify(res.data.schema),
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
async registerSchema(subject: string, schema: string): Promise<number> {
|
|
44
|
+
const res = await axios.post(
|
|
45
|
+
`${this.config.baseUrl}/subjects/${subject}/versions`,
|
|
46
|
+
{
|
|
47
|
+
schema,
|
|
48
|
+
}
|
|
49
|
+
);
|
|
50
|
+
|
|
51
|
+
return res.data.id;
|
|
52
|
+
}
|
|
53
|
+
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { Schema } from "@saurabh_singh_06/kafka-core";
|
|
2
|
+
|
|
3
|
+
export interface SchemaRegistryClient {
|
|
4
|
+
getLatestSchema(subject: string): Promise<Schema>;
|
|
5
|
+
getSchemaById(id: number): Promise<Schema>;
|
|
6
|
+
registerSchema(subject: string, schema: string): Promise<number>;
|
|
7
|
+
}
|