azure-kusto-data 2.2.3 → 3.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/.eslintignore +5 -0
- package/.eslintrc.js +247 -0
- package/.prettierignore +7 -0
- package/.prettierrc.json +5 -0
- package/README.md +38 -12
- package/example.js +3 -5
- package/index.js +0 -1
- package/index.js.map +1 -1
- package/package.json +63 -50
- package/source/client.d.ts +9 -7
- package/source/client.js +55 -28
- package/source/client.js.map +1 -1
- package/source/clientRequestProperties.d.ts +13 -2
- package/source/clientRequestProperties.js +11 -5
- package/source/clientRequestProperties.js.map +1 -1
- package/source/cloudSettings.js +2 -2
- package/source/cloudSettings.js.map +1 -1
- package/source/connectionBuilder.d.ts +24 -6
- package/source/connectionBuilder.js +128 -50
- package/source/connectionBuilder.js.map +1 -1
- package/source/errors.d.ts +6 -0
- package/source/errors.js +16 -0
- package/source/errors.js.map +1 -0
- package/source/models.d.ts +29 -5
- package/source/models.js +57 -20
- package/source/models.js.map +1 -1
- package/source/response.d.ts +2 -2
- package/source/response.js +15 -13
- package/source/response.js.map +1 -1
- package/source/security.d.ts +2 -2
- package/source/security.js +31 -20
- package/source/security.js.map +1 -1
- package/source/tokenProvider.d.ts +62 -27
- package/source/tokenProvider.js +143 -64
- package/source/tokenProvider.js.map +1 -1
- package/source/typeUtilts.d.ts +3 -0
- package/source/typeUtilts.js +5 -0
- package/source/typeUtilts.js.map +1 -0
- package/tsconfig.json +16 -16
- package/tsconfig.tsbuildinfo +1618 -1292
- package/index.ts +0 -13
- package/tslint.json +0 -18
package/source/client.js
CHANGED
|
@@ -20,6 +20,7 @@ const uuid_1 = require("uuid");
|
|
|
20
20
|
const security_1 = __importDefault(require("./security"));
|
|
21
21
|
const response_1 = require("./response");
|
|
22
22
|
const connectionBuilder_1 = __importDefault(require("./connectionBuilder"));
|
|
23
|
+
const clientRequestProperties_1 = __importDefault(require("./clientRequestProperties"));
|
|
23
24
|
const package_json_1 = __importDefault(require("../package.json"));
|
|
24
25
|
const axios_1 = __importDefault(require("axios"));
|
|
25
26
|
const http_1 = __importDefault(require("http"));
|
|
@@ -37,8 +38,9 @@ var ExecutionType;
|
|
|
37
38
|
})(ExecutionType || (ExecutionType = {}));
|
|
38
39
|
class KustoClient {
|
|
39
40
|
constructor(kcsb) {
|
|
40
|
-
this.connectionString = typeof
|
|
41
|
+
this.connectionString = typeof kcsb === "string" ? new connectionBuilder_1.default(kcsb) : kcsb;
|
|
41
42
|
this.cluster = this.connectionString.dataSource;
|
|
43
|
+
this.defaultDatabase = this.connectionString.initialCatalog;
|
|
42
44
|
this.endpoints = {
|
|
43
45
|
[ExecutionType.Mgmt]: `${this.cluster}/v1/rest/mgmt`,
|
|
44
46
|
[ExecutionType.Query]: `${this.cluster}/v2/rest/query`,
|
|
@@ -47,14 +49,14 @@ class KustoClient {
|
|
|
47
49
|
};
|
|
48
50
|
this.aadHelper = new security_1.default(this.connectionString);
|
|
49
51
|
const headers = {
|
|
50
|
-
|
|
52
|
+
Accept: "application/json",
|
|
51
53
|
"Accept-Encoding": "gzip,deflate",
|
|
52
54
|
"x-ms-client-version": `Kusto.Node.Client:${package_json_1.default.version}`,
|
|
53
|
-
|
|
55
|
+
Connection: "Keep-Alive",
|
|
54
56
|
};
|
|
55
57
|
this.axiosInstance = axios_1.default.create({
|
|
56
58
|
headers,
|
|
57
|
-
validateStatus: (status) => status
|
|
59
|
+
validateStatus: (status) => status === 200,
|
|
58
60
|
// keepAlive pools and reuses TCP connections, so it's faster
|
|
59
61
|
httpAgent: new http_1.default.Agent({ keepAlive: true }),
|
|
60
62
|
httpsAgent: new https_1.default.Agent({ keepAlive: true }),
|
|
@@ -84,54 +86,78 @@ class KustoClient {
|
|
|
84
86
|
return this._execute(this.endpoints[ExecutionType.Mgmt], ExecutionType.Mgmt, db, query, null, properties);
|
|
85
87
|
});
|
|
86
88
|
}
|
|
87
|
-
executeStreamingIngest(db, table, stream, streamFormat, mappingName) {
|
|
89
|
+
executeStreamingIngest(db, table, stream, streamFormat, mappingName, clientRequestId) {
|
|
88
90
|
return __awaiter(this, void 0, void 0, function* () {
|
|
89
|
-
let endpoint = `${this.endpoints[ExecutionType.Ingest]}/${db}/${table}?streamFormat=${streamFormat}`;
|
|
91
|
+
let endpoint = `${this.endpoints[ExecutionType.Ingest]}/${this.getDb(db)}/${table}?streamFormat=${streamFormat}`;
|
|
90
92
|
if (mappingName != null) {
|
|
91
93
|
endpoint += `&mappingName=${mappingName}`;
|
|
92
94
|
}
|
|
93
|
-
|
|
95
|
+
let properties = null;
|
|
96
|
+
if (clientRequestId) {
|
|
97
|
+
properties = new clientRequestProperties_1.default();
|
|
98
|
+
properties.clientRequestId = clientRequestId;
|
|
99
|
+
}
|
|
100
|
+
return this._execute(endpoint, ExecutionType.Ingest, db, null, stream, properties);
|
|
94
101
|
});
|
|
95
102
|
}
|
|
96
103
|
_execute(endpoint, executionType, db, query, stream, properties) {
|
|
97
104
|
return __awaiter(this, void 0, void 0, function* () {
|
|
105
|
+
db = this.getDb(db);
|
|
98
106
|
const headers = {};
|
|
99
107
|
let payload;
|
|
100
108
|
let clientRequestPrefix = "";
|
|
101
109
|
let clientRequestId;
|
|
102
110
|
const timeout = this._getClientTimeout(executionType, properties);
|
|
103
|
-
let
|
|
111
|
+
let payloadContent = "";
|
|
104
112
|
if (query != null) {
|
|
105
113
|
payload = {
|
|
106
|
-
|
|
107
|
-
|
|
114
|
+
db,
|
|
115
|
+
csl: query,
|
|
108
116
|
};
|
|
109
117
|
if (properties != null) {
|
|
110
|
-
payload.properties = properties.
|
|
111
|
-
clientRequestId = properties.clientRequestId;
|
|
112
|
-
if (properties.application != null) {
|
|
113
|
-
headers["x-ms-app"] = properties.application;
|
|
114
|
-
}
|
|
115
|
-
if (properties.user != null) {
|
|
116
|
-
headers["x-ms-user"] = properties.user;
|
|
117
|
-
}
|
|
118
|
+
payload.properties = properties.toJSON();
|
|
118
119
|
}
|
|
119
|
-
|
|
120
|
+
payloadContent = JSON.stringify(payload);
|
|
120
121
|
headers["Content-Type"] = "application/json; charset=utf-8";
|
|
121
122
|
clientRequestPrefix = "KNC.execute;";
|
|
122
123
|
}
|
|
123
124
|
else if (stream != null) {
|
|
124
|
-
|
|
125
|
+
payloadContent = stream;
|
|
125
126
|
clientRequestPrefix = "KNC.executeStreamingIngest;";
|
|
126
127
|
headers["Content-Encoding"] = "gzip";
|
|
127
|
-
headers["Content-Type"] = "
|
|
128
|
+
headers["Content-Type"] = "application/octet-stream";
|
|
129
|
+
}
|
|
130
|
+
else {
|
|
131
|
+
throw new Error("Invalid parameters - expected query or streaming ingest");
|
|
132
|
+
}
|
|
133
|
+
if (properties != null) {
|
|
134
|
+
clientRequestId = properties.clientRequestId;
|
|
135
|
+
if (properties.application != null) {
|
|
136
|
+
headers["x-ms-app"] = properties.application;
|
|
137
|
+
}
|
|
138
|
+
if (properties.user != null) {
|
|
139
|
+
headers["x-ms-user"] = properties.user;
|
|
140
|
+
}
|
|
128
141
|
}
|
|
129
142
|
headers["x-ms-client-request-id"] = clientRequestId || clientRequestPrefix + `${uuid_1.v4()}`;
|
|
130
|
-
|
|
131
|
-
|
|
143
|
+
const authHeader = yield this.aadHelper.getAuthHeader();
|
|
144
|
+
if (authHeader != null) {
|
|
145
|
+
headers.Authorization = authHeader;
|
|
146
|
+
}
|
|
147
|
+
return this._doRequest(endpoint, executionType, headers, payloadContent, timeout, properties);
|
|
132
148
|
});
|
|
133
149
|
}
|
|
150
|
+
getDb(db) {
|
|
151
|
+
if (db == null) {
|
|
152
|
+
if (this.defaultDatabase == null) {
|
|
153
|
+
throw new Error("No database provided, and no default database specified in connection string");
|
|
154
|
+
}
|
|
155
|
+
db = this.defaultDatabase;
|
|
156
|
+
}
|
|
157
|
+
return db;
|
|
158
|
+
}
|
|
134
159
|
_doRequest(endpoint, executionType, headers, payload, timeout, properties) {
|
|
160
|
+
var _a;
|
|
135
161
|
return __awaiter(this, void 0, void 0, function* () {
|
|
136
162
|
const axiosConfig = {
|
|
137
163
|
headers,
|
|
@@ -142,8 +168,9 @@ class KustoClient {
|
|
|
142
168
|
axiosResponse = yield this.axiosInstance.post(endpoint, payload, axiosConfig);
|
|
143
169
|
}
|
|
144
170
|
catch (error) {
|
|
145
|
-
if (error.response) {
|
|
146
|
-
|
|
171
|
+
if (axios_1.default.isAxiosError(error) && error.response) {
|
|
172
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
173
|
+
throw ((_a = error.response.data) === null || _a === void 0 ? void 0 : _a.error) || error.response.data;
|
|
147
174
|
}
|
|
148
175
|
throw error;
|
|
149
176
|
}
|
|
@@ -152,12 +179,12 @@ class KustoClient {
|
|
|
152
179
|
}
|
|
153
180
|
_parseResponse(response, executionType, properties, status) {
|
|
154
181
|
const { raw } = properties || {};
|
|
155
|
-
if (raw === true || executionType
|
|
182
|
+
if (raw === true || executionType === ExecutionType.Ingest) {
|
|
156
183
|
return response;
|
|
157
184
|
}
|
|
158
185
|
let kustoResponse = null;
|
|
159
186
|
try {
|
|
160
|
-
if (executionType
|
|
187
|
+
if (executionType === ExecutionType.Query) {
|
|
161
188
|
kustoResponse = new response_1.KustoResponseDataSetV2(response);
|
|
162
189
|
}
|
|
163
190
|
else {
|
|
@@ -183,7 +210,7 @@ class KustoClient {
|
|
|
183
210
|
return serverTimeout + CLIENT_SERVER_DELTA_IN_MILLISECS;
|
|
184
211
|
}
|
|
185
212
|
}
|
|
186
|
-
return
|
|
213
|
+
return executionType === ExecutionType.Query || executionType === ExecutionType.QueryV1 ? QUERY_TIMEOUT_IN_MILLISECS : COMMAND_TIMEOUT_IN_MILLISECS;
|
|
187
214
|
}
|
|
188
215
|
}
|
|
189
216
|
exports.KustoClient = KustoClient;
|
package/source/client.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.js","sourceRoot":"","sources":["client.ts"],"names":[],"mappings":";AAAA,uCAAuC;AACvC,kCAAkC;;;;;;;;;;;;;;;AAElC,oD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a,GAAG,UAAU,CAAC,UAAU,EAAE,CAAC;YAC9C,IAAI,aAAa,EAAE;gBACf,OAAO,aAAa,GAAG,gCAAgC,CAAC;aAC3D;SACJ;QAED,OAAO,aAAa,KAAK,aAAa,CAAC,KAAK,IAAI,aAAa,KAAK,aAAa,CAAC,OAAO,CAAC,CAAC,CAAC,0BAA0B,CAAC,CAAC,CAAC,4BAA4B,CAAC;IACxJ,CAAC;CACJ;AApND,kCAoNC;AAED,kBAAe,WAAW,CAAC"}
|
|
@@ -6,17 +6,20 @@ export declare class ClientRequestProperties {
|
|
|
6
6
|
user: string | null;
|
|
7
7
|
application: string | null;
|
|
8
8
|
raw?: boolean;
|
|
9
|
-
constructor(options?:
|
|
9
|
+
constructor(options?: Record<string, unknown>, parameters?: Record<string, unknown>, clientRequestId?: string, user?: string, application?: string);
|
|
10
10
|
setOption(name: string, value: any): void;
|
|
11
11
|
getOption(name: string, defaultValue?: any): any;
|
|
12
12
|
setParameter(name: string, value: any): void;
|
|
13
13
|
getParameter(name: string, defaultValue?: any): any;
|
|
14
14
|
clearParameters(): void;
|
|
15
15
|
setTimeout(timeoutMillis: number): void;
|
|
16
|
-
getTimeout():
|
|
16
|
+
getTimeout(): number | undefined;
|
|
17
17
|
setClientTimeout(timeoutMillis: number): void;
|
|
18
18
|
getClientTimeout(): number | undefined;
|
|
19
19
|
clearOptions(): void;
|
|
20
|
+
/**
|
|
21
|
+
* @deprecated use the compliant toJSON() instead
|
|
22
|
+
*/
|
|
20
23
|
toJson(): {
|
|
21
24
|
Options?: {
|
|
22
25
|
[option: string]: any;
|
|
@@ -25,6 +28,14 @@ export declare class ClientRequestProperties {
|
|
|
25
28
|
[option: string]: any;
|
|
26
29
|
} | undefined;
|
|
27
30
|
} | null;
|
|
31
|
+
toJSON(): {
|
|
32
|
+
Options?: {
|
|
33
|
+
[option: string]: any;
|
|
34
|
+
} | undefined;
|
|
35
|
+
Parameters?: {
|
|
36
|
+
[option: string]: any;
|
|
37
|
+
} | undefined;
|
|
38
|
+
} | null;
|
|
28
39
|
toString(): string;
|
|
29
40
|
_msToTimespan(duration: number): string;
|
|
30
41
|
}
|
|
@@ -46,7 +46,13 @@ class ClientRequestProperties {
|
|
|
46
46
|
clearOptions() {
|
|
47
47
|
this._options = {};
|
|
48
48
|
}
|
|
49
|
+
/**
|
|
50
|
+
* @deprecated use the compliant toJSON() instead
|
|
51
|
+
*/
|
|
49
52
|
toJson() {
|
|
53
|
+
return this.toJSON();
|
|
54
|
+
}
|
|
55
|
+
toJSON() {
|
|
50
56
|
const json = {};
|
|
51
57
|
if (Object.keys(this._options).length !== 0) {
|
|
52
58
|
json.Options = this._options;
|
|
@@ -60,17 +66,17 @@ class ClientRequestProperties {
|
|
|
60
66
|
return Object.keys(json).length !== 0 ? json : null;
|
|
61
67
|
}
|
|
62
68
|
toString() {
|
|
63
|
-
return JSON.stringify(this.
|
|
69
|
+
return JSON.stringify(this.toJSON());
|
|
64
70
|
}
|
|
65
71
|
_msToTimespan(duration) {
|
|
66
72
|
const milliseconds = Math.floor((duration % 1000) / 100);
|
|
67
73
|
const seconds = Math.floor((duration / 1000) % 60);
|
|
68
74
|
const minutes = Math.floor((duration / (1000 * 60)) % 60);
|
|
69
75
|
const hours = Math.floor((duration / (1000 * 60 * 60)) % 24);
|
|
70
|
-
const hoursStr =
|
|
71
|
-
const minutesStr =
|
|
72
|
-
const secondsStr =
|
|
73
|
-
return hoursStr
|
|
76
|
+
const hoursStr = hours < 10 ? `0${hours}` : String(hours);
|
|
77
|
+
const minutesStr = minutes < 10 ? `0${minutes}` : String(minutes);
|
|
78
|
+
const secondsStr = seconds < 10 ? `0${seconds}` : String(seconds);
|
|
79
|
+
return `${hoursStr}:${minutesStr}:${secondsStr}.${milliseconds}`;
|
|
74
80
|
}
|
|
75
81
|
}
|
|
76
82
|
exports.ClientRequestProperties = ClientRequestProperties;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"clientRequestProperties.js","sourceRoot":"","sources":["clientRequestProperties.ts"],"names":[],"mappings":";AAAA,uCAAuC;AACvC,kCAAkC;;;AAElC,MAAa,uBAAuB;IAShC,YAAY,
|
|
1
|
+
{"version":3,"file":"clientRequestProperties.js","sourceRoot":"","sources":["clientRequestProperties.ts"],"names":[],"mappings":";AAAA,uCAAuC;AACvC,kCAAkC;;;AAElC,MAAa,uBAAuB;IAShC,YAAY,OAAiC,EAAE,UAAoC,EAAE,eAAwB,EAAE,IAAa,EAAE,WAAoB;QAC9I,IAAI,CAAC,QAAQ,GAAG,OAAO,IAAI,EAAE,CAAC;QAC9B,IAAI,CAAC,WAAW,GAAG,UAAU,IAAI,EAAE,CAAC;QACpC,IAAI,CAAC,eAAe,GAAG,eAAe,IAAI,IAAI,CAAC;QAC/C,IAAI,CAAC,IAAI,GAAG,IAAI,IAAI,IAAI,CAAC;QACzB,IAAI,CAAC,WAAW,GAAG,WAAW,IAAI,IAAI,CAAC;IAC3C,CAAC;IAED,SAAS,CAAC,IAAY,EAAE,KAAU;QAC9B,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,GAAG,KAAK,CAAC;IAChC,CAAC;IAED,SAAS,CAAC,IAAY,EAAE,YAAkB;QACtC,IAAI,CAAC,IAAI,CAAC,QAAQ,IAAI,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,SAAS;YAAE,OAAO,YAAY,CAAC;QAE7E,OAAO,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;IAC/B,CAAC;IAED,YAAY,CAAC,IAAY,EAAE,KAAU;QACjC,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,GAAG,KAAK,CAAC;IACnC,CAAC;IAED,YAAY,CAAC,IAAY,EAAE,YAAkB;QACzC,IAAI,CAAC,IAAI,CAAC,WAAW,IAAI,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,KAAK,SAAS,EAAE;YAC3D,OAAO,YAAY,CAAC;SACvB;QAED,OAAO,IAAI,CAAC,WAAW,CAAC,IAAI,CA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49
|
-
if (response.status
|
|
49
|
+
if (response.status === 200) {
|
|
50
50
|
this.cloudCache[kustoUri] = response.data.AzureAD || this.defaultCloudInfo;
|
|
51
51
|
}
|
|
52
52
|
else {
|
|
@@ -54,7 +54,7 @@ class CloudSettings {
|
|
|
54
54
|
}
|
|
55
55
|
}
|
|
56
56
|
catch (ex) {
|
|
57
|
-
if (((_a = ex.response) === null || _a === void 0 ? void 0 : _a.status)
|
|
57
|
+
if (axios_1.default.isAxiosError(ex) && ((_a = ex.response) === null || _a === void 0 ? void 0 : _a.status) === 404) {
|
|
58
58
|
// For now as long not all proxies implement the metadata endpoint, if no endpoint exists return public cloud data
|
|
59
59
|
this.cloudCache[kustoUri] = this.defaultCloudInfo;
|
|
60
60
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cloudSettings.js","sourceRoot":"","sources":["cloudSettings.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,uCAAuC;AACvC,kCAAkC;AAClC,kDAA0B;AAW1B;;GAEG;AACH,MAAa,aAAa;IAatB;QAXA,sBAAiB,GAAG,wBAAwB,CAAC;QAC7C,qBAAgB,GAAc;YAC1B,aAAa,EAAE,OAAO,CAAC,GAAG,CAAC,eAAe,IAAI,mCAAmC;YACjF,gBAAgB,EAAE,KAAK;YACvB,gBAAgB,EAAE,sCAAsC;YACxD,sBAAsB,EAAE,+BAA+B;YACvD,sBAAsB,EAAE,iCAAiC;YACzD,sBAAsB,EAAE,wEAAwE;SACnG,
|
|
1
|
+
{"version":3,"file":"cloudSettings.js","sourceRoot":"","sources":["cloudSettings.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,uCAAuC;AACvC,kCAAkC;AAClC,kDAA0B;AAW1B;;GAEG;AACH,MAAa,aAAa;IAatB;QAXA,sBAAiB,GAAG,wBAAwB,CAAC;QAC7C,qBAAgB,GAAc;YAC1B,aAAa,EAAE,OAAO,CAAC,GAAG,CAAC,eAAe,IAAI,mCAAmC;YACjF,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AC,UAAU,CAAC,QAAQ,CAAC,CAAC;;KACpC;IAED,MAAM,CAAC,eAAe,CAAC,SAAoB,EAAE,WAAoB;QAC7D,OAAO,SAAS,CAAC,aAAa,GAAG,GAAG,GAAG,CAAC,WAAW,IAAI,eAAe,CAAC,CAAC;IAC5E,CAAC;CACJ;AAjDD,sCAiDC"}
|
|
@@ -1,22 +1,40 @@
|
|
|
1
1
|
import { DeviceCodeResponse } from "@azure/msal-common";
|
|
2
2
|
export declare class KustoConnectionStringBuilder {
|
|
3
|
-
|
|
3
|
+
static readonly DefaultDatabaseName = "NetDefaultDB";
|
|
4
|
+
static readonly SecretReplacement = "****";
|
|
5
|
+
static defaultDeviceCallback: (response: DeviceCodeResponse) => void;
|
|
4
6
|
dataSource?: string;
|
|
7
|
+
aadFederatedSecurity?: boolean;
|
|
8
|
+
initialCatalog?: string;
|
|
5
9
|
aadUserId?: string;
|
|
6
10
|
password?: string;
|
|
7
11
|
applicationClientId?: string;
|
|
12
|
+
msiClientId?: string;
|
|
8
13
|
applicationKey?: string;
|
|
9
14
|
applicationCertificatePrivateKey?: string;
|
|
10
15
|
applicationCertificateThumbprint?: string;
|
|
11
|
-
|
|
16
|
+
applicationCertificateX5c?: string;
|
|
17
|
+
authorityId: string;
|
|
12
18
|
deviceCodeCallback?: (response: DeviceCodeResponse) => void;
|
|
19
|
+
tokenProvider?: () => Promise<string>;
|
|
20
|
+
loginHint?: string;
|
|
21
|
+
timeoutMs?: number;
|
|
22
|
+
accessToken?: string;
|
|
23
|
+
useDeviceCodeAuth?: boolean;
|
|
24
|
+
useUserPromptAuth?: boolean;
|
|
25
|
+
useAzLoginAuth?: boolean;
|
|
26
|
+
useManagedIdentityAuth?: boolean;
|
|
13
27
|
constructor(connectionString: string);
|
|
28
|
+
toString(removeSecrets?: boolean): string;
|
|
29
|
+
static fromExisting(other: KustoConnectionStringBuilder): KustoConnectionStringBuilder;
|
|
14
30
|
static withAadUserPasswordAuthentication(connectionString: string, userId: string, password: string, authorityId?: string): KustoConnectionStringBuilder;
|
|
15
31
|
static withAadApplicationKeyAuthentication(connectionString: string, aadAppId: string, appKey: string, authorityId?: string): KustoConnectionStringBuilder;
|
|
16
32
|
static withAadApplicationCertificateAuthentication(connectionString: string, aadAppId: string, applicationCertificatePrivateKey: string, applicationCertificateThumbprint: string, authorityId?: string, applicationCertificateX5c?: string): KustoConnectionStringBuilder;
|
|
17
|
-
static withAadDeviceAuthentication(connectionString: string, authorityId
|
|
18
|
-
static withAadManagedIdentities(connectionString: string, msiClientId?: string): KustoConnectionStringBuilder;
|
|
19
|
-
static withAzLoginIdentity(connectionString: string): KustoConnectionStringBuilder;
|
|
20
|
-
static withAccessToken(connectionString: string, accessToken
|
|
33
|
+
static withAadDeviceAuthentication(connectionString: string, authorityId?: string, deviceCodeCallback?: (response: DeviceCodeResponse) => void): KustoConnectionStringBuilder;
|
|
34
|
+
static withAadManagedIdentities(connectionString: string, msiClientId?: string, authorityId?: string, timeoutMs?: number): KustoConnectionStringBuilder;
|
|
35
|
+
static withAzLoginIdentity(connectionString: string, authorityId?: string, timeoutMs?: number): KustoConnectionStringBuilder;
|
|
36
|
+
static withAccessToken(connectionString: string, accessToken: string): KustoConnectionStringBuilder;
|
|
37
|
+
static withTokenProvider(connectionString: string, tokenProvider: () => Promise<string>): KustoConnectionStringBuilder;
|
|
38
|
+
static withUserPrompt(connectionString: string, authorityId?: string, clientId?: string, timeoutMs?: number, loginHint?: string): KustoConnectionStringBuilder;
|
|
21
39
|
}
|
|
22
40
|
export default KustoConnectionStringBuilder;
|
|
@@ -5,64 +5,72 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
5
5
|
exports.KustoConnectionStringBuilder = void 0;
|
|
6
6
|
const KeywordMapping = Object.freeze({
|
|
7
7
|
dataSource: {
|
|
8
|
-
propName: "dataSource",
|
|
9
8
|
mappedTo: "Data Source",
|
|
10
|
-
validNames: ["data source", "addr", "address", "network address", "server"]
|
|
9
|
+
validNames: ["data source", "addr", "address", "network address", "server"],
|
|
10
|
+
},
|
|
11
|
+
aadFederatedSecurity: {
|
|
12
|
+
mappedTo: "AAD Federated Security",
|
|
13
|
+
validNames: ["aad federated security", "federated security", "federated", "fed", "aadfed"],
|
|
14
|
+
isBool: true,
|
|
15
|
+
},
|
|
16
|
+
initialCatalog: {
|
|
17
|
+
mappedTo: "Initial Catalog",
|
|
18
|
+
validNames: ["initial catalog", "database"],
|
|
11
19
|
},
|
|
12
20
|
aadUserId: {
|
|
13
|
-
propName: "aadUserId",
|
|
14
21
|
mappedTo: "AAD User ID",
|
|
15
|
-
validNames: ["aad user id"]
|
|
22
|
+
validNames: ["aad user id"],
|
|
16
23
|
},
|
|
17
24
|
password: {
|
|
18
|
-
propName: "password",
|
|
19
25
|
mappedTo: "Password",
|
|
20
|
-
validNames: ["password", "pwd"]
|
|
26
|
+
validNames: ["password", "pwd"],
|
|
27
|
+
isSecret: true,
|
|
21
28
|
},
|
|
22
29
|
applicationClientId: {
|
|
23
|
-
propName: "applicationClientId",
|
|
24
30
|
mappedTo: "Application Client Id",
|
|
25
|
-
validNames: ["application client id", "appclientid"]
|
|
31
|
+
validNames: ["application client id", "appclientid"],
|
|
26
32
|
},
|
|
27
33
|
applicationKey: {
|
|
28
|
-
propName: "applicationKey",
|
|
29
34
|
mappedTo: "Application Key",
|
|
30
|
-
validNames: ["application key", "appkey"]
|
|
35
|
+
validNames: ["application key", "appkey"],
|
|
36
|
+
isSecret: true,
|
|
31
37
|
},
|
|
32
38
|
applicationCertificatePrivateKey: {
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
39
|
+
mappedTo: "Application Certificate PrivateKey",
|
|
40
|
+
validNames: ["Application Certificate PrivateKey"],
|
|
41
|
+
isSecret: true,
|
|
36
42
|
},
|
|
37
43
|
applicationCertificateThumbprint: {
|
|
38
|
-
propName: "applicationCertificateThumbprint",
|
|
39
44
|
mappedTo: "Application Certificate Thumbprint",
|
|
40
|
-
validNames: ["application certificate thumbprint"]
|
|
45
|
+
validNames: ["application certificate thumbprint", "AppCert"],
|
|
41
46
|
},
|
|
42
47
|
applicationCertificateX5c: {
|
|
43
|
-
propName: "applicationCertificateX5c",
|
|
44
48
|
mappedTo: "Application Certificate x5c",
|
|
45
|
-
validNames: ["application certificate x5c"]
|
|
49
|
+
validNames: ["application certificate x5c", "Application Certificate Send Public Certificate", "Application Certificate SendX5c", "SendX5c"],
|
|
46
50
|
},
|
|
47
51
|
authorityId: {
|
|
48
|
-
propName: "authorityId",
|
|
49
52
|
mappedTo: "Authority Id",
|
|
50
|
-
validNames: ["authority id", "authorityid", "authority", "tenantid", "tenant", "tid"]
|
|
51
|
-
}
|
|
53
|
+
validNames: ["authority id", "authorityid", "authority", "tenantid", "tenant", "tid"],
|
|
54
|
+
},
|
|
52
55
|
});
|
|
53
56
|
const getPropName = (key) => {
|
|
54
57
|
const _key = key.trim().toLowerCase();
|
|
55
58
|
for (const keyword of Object.keys(KeywordMapping)) {
|
|
56
59
|
const k = KeywordMapping[keyword];
|
|
57
|
-
if (k
|
|
58
|
-
|
|
60
|
+
if (!k) {
|
|
61
|
+
continue;
|
|
62
|
+
}
|
|
63
|
+
if (k.validNames.map((n) => n.trim().toLowerCase()).indexOf(_key) >= 0) {
|
|
64
|
+
return [keyword, k];
|
|
59
65
|
}
|
|
60
66
|
}
|
|
61
|
-
throw new Error(key);
|
|
67
|
+
throw new Error("Failed to get prop: " + key);
|
|
62
68
|
};
|
|
63
69
|
class KustoConnectionStringBuilder {
|
|
64
70
|
constructor(connectionString) {
|
|
65
|
-
|
|
71
|
+
var _a;
|
|
72
|
+
this.authorityId = "common";
|
|
73
|
+
if (connectionString.trim().length === 0)
|
|
66
74
|
throw new Error("Missing connection string");
|
|
67
75
|
if (connectionString.endsWith("/") || connectionString.endsWith("\\")) {
|
|
68
76
|
connectionString = connectionString.slice(0, -1);
|
|
@@ -70,73 +78,143 @@ class KustoConnectionStringBuilder {
|
|
|
70
78
|
if (!!connectionString && connectionString.split(";")[0].indexOf("=") === -1) {
|
|
71
79
|
connectionString = "Data Source=" + connectionString;
|
|
72
80
|
}
|
|
73
|
-
this[KeywordMapping.authorityId.propName] = "common";
|
|
74
81
|
const params = connectionString.split(";");
|
|
75
82
|
for (const item of params) {
|
|
76
83
|
const kvp = item.split("=");
|
|
77
|
-
|
|
84
|
+
const [mappingTypeName, mappingType] = getPropName(kvp[0]);
|
|
85
|
+
if (mappingType.isBool) {
|
|
86
|
+
this[mappingTypeName] = kvp[1].trim().toLowerCase() === "true";
|
|
87
|
+
}
|
|
88
|
+
else {
|
|
89
|
+
this[mappingTypeName] = (_a = kvp[1]) === null || _a === void 0 ? void 0 : _a.trim();
|
|
90
|
+
}
|
|
78
91
|
}
|
|
92
|
+
if (!this.initialCatalog) {
|
|
93
|
+
this.initialCatalog = KustoConnectionStringBuilder.DefaultDatabaseName;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
toString(removeSecrets = true) {
|
|
97
|
+
return Object.entries(KeywordMapping)
|
|
98
|
+
.map(([key, mappingType]) => {
|
|
99
|
+
const value = this[key];
|
|
100
|
+
if (!mappingType || value === undefined) {
|
|
101
|
+
return "";
|
|
102
|
+
}
|
|
103
|
+
if (mappingType.isSecret && removeSecrets) {
|
|
104
|
+
return `${mappingType.mappedTo}=${KustoConnectionStringBuilder.SecretReplacement}`;
|
|
105
|
+
}
|
|
106
|
+
return `${mappingType.mappedTo}=${value.toString()}`;
|
|
107
|
+
})
|
|
108
|
+
.filter((x) => x !== "")
|
|
109
|
+
.join(";");
|
|
110
|
+
}
|
|
111
|
+
static fromExisting(other) {
|
|
112
|
+
return Object.assign({}, other);
|
|
79
113
|
}
|
|
80
114
|
static withAadUserPasswordAuthentication(connectionString, userId, password, authorityId) {
|
|
81
|
-
if (
|
|
115
|
+
if (userId.trim().length === 0)
|
|
82
116
|
throw new Error("Invalid user");
|
|
83
|
-
if (
|
|
117
|
+
if (password.trim().length === 0)
|
|
84
118
|
throw new Error("Invalid password");
|
|
85
119
|
const kcsb = new KustoConnectionStringBuilder(connectionString);
|
|
86
|
-
kcsb
|
|
87
|
-
kcsb
|
|
88
|
-
kcsb
|
|
120
|
+
kcsb.aadFederatedSecurity = true;
|
|
121
|
+
kcsb.aadUserId = userId;
|
|
122
|
+
kcsb.password = password;
|
|
123
|
+
if (authorityId) {
|
|
124
|
+
kcsb.authorityId = authorityId;
|
|
125
|
+
}
|
|
89
126
|
return kcsb;
|
|
90
127
|
}
|
|
91
128
|
static withAadApplicationKeyAuthentication(connectionString, aadAppId, appKey, authorityId) {
|
|
92
|
-
if (
|
|
129
|
+
if (aadAppId.trim().length === 0)
|
|
93
130
|
throw new Error("Invalid app id");
|
|
94
|
-
if (
|
|
131
|
+
if (appKey.trim().length === 0)
|
|
95
132
|
throw new Error("Invalid app key");
|
|
96
133
|
const kcsb = new KustoConnectionStringBuilder(connectionString);
|
|
97
|
-
kcsb
|
|
98
|
-
kcsb
|
|
99
|
-
kcsb
|
|
134
|
+
kcsb.aadFederatedSecurity = true;
|
|
135
|
+
kcsb.applicationClientId = aadAppId;
|
|
136
|
+
kcsb.applicationKey = appKey;
|
|
137
|
+
if (authorityId) {
|
|
138
|
+
kcsb.authorityId = authorityId;
|
|
139
|
+
}
|
|
100
140
|
return kcsb;
|
|
101
141
|
}
|
|
102
142
|
static withAadApplicationCertificateAuthentication(connectionString, aadAppId, applicationCertificatePrivateKey, applicationCertificateThumbprint, authorityId, applicationCertificateX5c) {
|
|
103
|
-
if (
|
|
143
|
+
if (aadAppId.trim().length === 0)
|
|
104
144
|
throw new Error("Invalid app id");
|
|
105
|
-
if (
|
|
145
|
+
if (applicationCertificatePrivateKey.trim().length === 0)
|
|
106
146
|
throw new Error("Invalid certificate");
|
|
107
|
-
if (
|
|
147
|
+
if (applicationCertificateThumbprint.trim().length === 0)
|
|
108
148
|
throw new Error("Invalid thumbprint");
|
|
109
149
|
const kcsb = new KustoConnectionStringBuilder(connectionString);
|
|
110
|
-
kcsb
|
|
111
|
-
kcsb
|
|
112
|
-
kcsb
|
|
113
|
-
kcsb
|
|
114
|
-
kcsb
|
|
150
|
+
kcsb.aadFederatedSecurity = true;
|
|
151
|
+
kcsb.applicationClientId = aadAppId;
|
|
152
|
+
kcsb.applicationCertificatePrivateKey = applicationCertificatePrivateKey;
|
|
153
|
+
kcsb.applicationCertificateThumbprint = applicationCertificateThumbprint;
|
|
154
|
+
kcsb.applicationCertificateX5c = applicationCertificateX5c;
|
|
155
|
+
if (authorityId) {
|
|
156
|
+
kcsb.authorityId = authorityId;
|
|
157
|
+
}
|
|
115
158
|
return kcsb;
|
|
116
159
|
}
|
|
117
|
-
static withAadDeviceAuthentication(connectionString, authorityId, deviceCodeCallback) {
|
|
160
|
+
static withAadDeviceAuthentication(connectionString, authorityId = "common", deviceCodeCallback = KustoConnectionStringBuilder.defaultDeviceCallback) {
|
|
118
161
|
const kcsb = new KustoConnectionStringBuilder(connectionString);
|
|
119
|
-
kcsb
|
|
162
|
+
kcsb.aadFederatedSecurity = true;
|
|
163
|
+
kcsb.authorityId = authorityId;
|
|
120
164
|
kcsb.deviceCodeCallback = deviceCodeCallback;
|
|
165
|
+
kcsb.useDeviceCodeAuth = true;
|
|
121
166
|
return kcsb;
|
|
122
167
|
}
|
|
123
|
-
static withAadManagedIdentities(connectionString, msiClientId) {
|
|
168
|
+
static withAadManagedIdentities(connectionString, msiClientId, authorityId, timeoutMs) {
|
|
124
169
|
const kcsb = new KustoConnectionStringBuilder(connectionString);
|
|
170
|
+
kcsb.aadFederatedSecurity = true;
|
|
171
|
+
if (authorityId) {
|
|
172
|
+
kcsb.authorityId = authorityId;
|
|
173
|
+
}
|
|
125
174
|
kcsb.msiClientId = msiClientId;
|
|
126
|
-
kcsb.
|
|
175
|
+
kcsb.timeoutMs = timeoutMs;
|
|
176
|
+
kcsb.useManagedIdentityAuth = true;
|
|
127
177
|
return kcsb;
|
|
128
178
|
}
|
|
129
|
-
static withAzLoginIdentity(connectionString) {
|
|
179
|
+
static withAzLoginIdentity(connectionString, authorityId, timeoutMs) {
|
|
130
180
|
const kcsb = new KustoConnectionStringBuilder(connectionString);
|
|
131
|
-
kcsb.
|
|
181
|
+
kcsb.aadFederatedSecurity = true;
|
|
182
|
+
kcsb.useAzLoginAuth = true;
|
|
183
|
+
if (authorityId) {
|
|
184
|
+
kcsb.authorityId = authorityId;
|
|
185
|
+
}
|
|
186
|
+
kcsb.timeoutMs = timeoutMs;
|
|
132
187
|
return kcsb;
|
|
133
188
|
}
|
|
134
189
|
static withAccessToken(connectionString, accessToken) {
|
|
135
190
|
const kcsb = new KustoConnectionStringBuilder(connectionString);
|
|
191
|
+
kcsb.aadFederatedSecurity = true;
|
|
136
192
|
kcsb.accessToken = accessToken;
|
|
137
193
|
return kcsb;
|
|
138
194
|
}
|
|
195
|
+
static withTokenProvider(connectionString, tokenProvider) {
|
|
196
|
+
const kcsb = new KustoConnectionStringBuilder(connectionString);
|
|
197
|
+
kcsb.aadFederatedSecurity = true;
|
|
198
|
+
kcsb.tokenProvider = tokenProvider;
|
|
199
|
+
return kcsb;
|
|
200
|
+
}
|
|
201
|
+
static withUserPrompt(connectionString, authorityId, clientId, timeoutMs, loginHint) {
|
|
202
|
+
const kcsb = new KustoConnectionStringBuilder(connectionString);
|
|
203
|
+
kcsb.aadFederatedSecurity = true;
|
|
204
|
+
kcsb.useUserPromptAuth = true;
|
|
205
|
+
if (authorityId) {
|
|
206
|
+
kcsb.authorityId = authorityId;
|
|
207
|
+
}
|
|
208
|
+
kcsb.loginHint = loginHint;
|
|
209
|
+
kcsb.applicationClientId = clientId;
|
|
210
|
+
kcsb.timeoutMs = timeoutMs;
|
|
211
|
+
return kcsb;
|
|
212
|
+
}
|
|
139
213
|
}
|
|
140
214
|
exports.KustoConnectionStringBuilder = KustoConnectionStringBuilder;
|
|
215
|
+
KustoConnectionStringBuilder.DefaultDatabaseName = "NetDefaultDB";
|
|
216
|
+
KustoConnectionStringBuilder.SecretReplacement = "****";
|
|
217
|
+
// eslint-disable-next-line no-console
|
|
218
|
+
KustoConnectionStringBuilder.defaultDeviceCallback = (response) => console.log(response.message);
|
|
141
219
|
exports.default = KustoConnectionStringBuilder;
|
|
142
220
|
//# sourceMappingURL=connectionBuilder.js.map
|