Move to new "nodenext" module type (#318)

* Change type to module + proper exports

* Add azure-kusto-data path

* Change module to nodenext

* Added fallback for webpack

* prettier

* Linting

* jest config

* jest config

* jest config

* try to fix dirname

* try to fix dirname

* Very hacky but we'll try

* Remove browser tests

* Remove browser tests

* Remove browser tests

* Remove browser tests

* hol up

* Fix assertion

* tests todos

* format

* try

* try

* try

* import style

* restore test

* restore test

* Separate browser unit tests to data and ingest

* Try different error printing

* Restore test

* Restore test

* Try to solve error

* Clarifying comments

* What happens if we do lint test files?

* try removing process/browser

* try removing process/browser
This commit is contained in:
AsafMah 2024-09-16 10:44:27 +03:00 коммит произвёл GitHub
Родитель 8fc8270ce1
Коммит a45a43029e
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: B5690EEEBB952194
60 изменённых файлов: 300 добавлений и 281 удалений

Просмотреть файл

@ -4,3 +4,5 @@ node_modules
coverage coverage
.nyc_output .nyc_output
jest.config.ts jest.config.ts
# Don't lint example files
packages/quick_start

3
.github/workflows/build.yml поставляемый
Просмотреть файл

@ -26,6 +26,7 @@ jobs:
package-lock.json package-lock.json
- run: npm ci - run: npm ci
- run: npm run checkFormat - run: npm run checkFormat
continue-on-error: true
- run: npm run lint - run: npm run lint
- name: Azure login - name: Azure login
uses: azure/login@v2 uses: azure/login@v2
@ -42,6 +43,8 @@ jobs:
DM_CONNECTION_STRING: "https://ingest-sdkse2etest.eastus.kusto.windows.net" DM_CONNECTION_STRING: "https://ingest-sdkse2etest.eastus.kusto.windows.net"
AZURE_CLIENT_ID: ${{ secrets.APP_ID }} AZURE_CLIENT_ID: ${{ secrets.APP_ID }}
AZURE_TENANT_ID: ${{ secrets.TENANT_ID }} AZURE_TENANT_ID: ${{ secrets.TENANT_ID }}
# Required for running tests when using ESM, see https://kulshekhar.github.io/ts-jest/docs/guides/esm-support
NODE_OPTIONS: "--experimental-vm-modules"
- name: Upload coverage to Codecov - name: Upload coverage to Codecov
uses: codecov/codecov-action@v2 uses: codecov/codecov-action@v2
- name: Publish Unit Test Results - name: Publish Unit Test Results

Просмотреть файл

@ -3,9 +3,17 @@
import { Config } from "jest"; import { Config } from "jest";
import type { JestConfigWithTsJest } from "ts-jest"; import type { JestConfigWithTsJest } from "ts-jest";
import { createDefaultEsmPreset } from "ts-jest";
// Note that this preset and the moduleNameMapper are necessary to run test with ecmascript modules.
// See https://kulshekhar.github.io/ts-jest/docs/guides/esm-support/
const defaultEsmPreset = createDefaultEsmPreset();
const baseConfig: Config = { const baseConfig: Config = {
preset: "ts-jest", ...defaultEsmPreset,
moduleNameMapper: {
"^(\\.{1,2}/.*)\\.js$": "$1",
},
testEnvironment: "node", testEnvironment: "node",
prettierPath: "prettier", prettierPath: "prettier",
maxWorkers: 200, maxWorkers: 200,

72
package-lock.json сгенерированный
Просмотреть файл

@ -10,7 +10,7 @@
"packages/azure-kusto-ingest" "packages/azure-kusto-ingest"
], ],
"devDependencies": { "devDependencies": {
"@types/jest": "^29.5.0", "@types/jest": "^29.5.12",
"@types/node": "^18.0.0", "@types/node": "^18.0.0",
"@types/webpack-dev-server": "^4.7.2", "@types/webpack-dev-server": "^4.7.2",
"@typescript-eslint/eslint-plugin": "^5.32.0", "@typescript-eslint/eslint-plugin": "^5.32.0",
@ -20,8 +20,8 @@
"eslint-plugin-header": "^3.1.1", "eslint-plugin-header": "^3.1.1",
"eslint-plugin-jsdoc": "^39.3.4", "eslint-plugin-jsdoc": "^39.3.4",
"eslint-plugin-prefer-arrow": "^1.2.3", "eslint-plugin-prefer-arrow": "^1.2.3",
"jest": "^29.5.0", "jest": "^29.7.0",
"jest-junit": "^15.0.0", "jest-junit": "^16.0.0",
"lerna": "^7.4.2", "lerna": "^7.4.2",
"npm": "^9.6.2", "npm": "^9.6.2",
"prettier": "^2.8.4", "prettier": "^2.8.4",
@ -29,7 +29,7 @@
"shx": "^0.3.4", "shx": "^0.3.4",
"sinon": "^14.0.0", "sinon": "^14.0.0",
"stream-browserify": "^3.0.0", "stream-browserify": "^3.0.0",
"ts-jest": "^29.1.1", "ts-jest": "^29.2.5",
"ts-loader": "^9.4.2", "ts-loader": "^9.4.2",
"ts-node": "^10.9.1", "ts-node": "^10.9.1",
"typescript": "^5.0.0", "typescript": "^5.0.0",
@ -3278,9 +3278,9 @@
} }
}, },
"node_modules/@types/jest": { "node_modules/@types/jest": {
"version": "29.5.7", "version": "29.5.12",
"resolved": "https://registry.npmjs.org/@types/jest/-/jest-29.5.7.tgz", "resolved": "https://registry.npmjs.org/@types/jest/-/jest-29.5.12.tgz",
"integrity": "sha512-HLyetab6KVPSiF+7pFcUyMeLsx25LDNDemw9mGsJBkai/oouwrjTycocSDYopMEwFhN2Y4s9oPyOCZNofgSt2g==", "integrity": "sha512-eDC8bTvT/QhYdxJAulQikueigY5AsdBRH2yDKW3yveW7svY3+DzN84/2NUgkw10RTiJbWqZrTtoGVdYlvFJdLw==",
"dev": true, "dev": true,
"dependencies": { "dependencies": {
"expect": "^29.0.0", "expect": "^29.0.0",
@ -8495,9 +8495,9 @@
} }
}, },
"node_modules/jest-junit": { "node_modules/jest-junit": {
"version": "15.0.0", "version": "16.0.0",
"resolved": "https://registry.npmjs.org/jest-junit/-/jest-junit-15.0.0.tgz", "resolved": "https://registry.npmjs.org/jest-junit/-/jest-junit-16.0.0.tgz",
"integrity": "sha512-Z5sVX0Ag3HZdMUnD5DFlG+1gciIFSy7yIVPhOdGUi8YJaI9iLvvBb530gtQL2CHmv0JJeiwRZenr0VrSR7frvg==", "integrity": "sha512-A94mmw6NfJab4Fg/BlvVOUXzXgF0XIH6EmTgJ5NDPp4xoKq0Kr7sErb+4Xs9nZvu58pJojz5RFGpqnZYJTrRfQ==",
"dev": true, "dev": true,
"dependencies": { "dependencies": {
"mkdirp": "^1.0.4", "mkdirp": "^1.0.4",
@ -13667,7 +13667,7 @@
"inBundle": true, "inBundle": true,
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"ip": "^2.0.1", "ip": "^2.0.0",
"smart-buffer": "^4.2.0" "smart-buffer": "^4.2.0"
}, },
"engines": { "engines": {
@ -16010,12 +16010,9 @@
} }
}, },
"node_modules/semver": { "node_modules/semver": {
"version": "7.5.4", "version": "7.6.3",
"resolved": "https://registry.npmjs.org/semver/-/semver-7.5.4.tgz", "resolved": "https://registry.npmjs.org/semver/-/semver-7.6.3.tgz",
"integrity": "sha512-1bCSESV6Pv+i21Hvpxp3Dx+pSD8lIPt8uVjRrxAUt/nbswYc+tK6Y2btiULjd4+fnq15PX+nqQDC7Oft7WkwcA==", "integrity": "sha512-oVekP1cKtI+CTDvHWYFUcMtsK/00wmAEfyqKfNdARm8u1wNVhSgaX7A8d4UuIlUI5e84iEwOhs7ZPYRmzU9U6A==",
"dependencies": {
"lru-cache": "^6.0.0"
},
"bin": { "bin": {
"semver": "bin/semver.js" "semver": "bin/semver.js"
}, },
@ -16023,22 +16020,6 @@
"node": ">=10" "node": ">=10"
} }
}, },
"node_modules/semver/node_modules/lru-cache": {
"version": "6.0.0",
"resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz",
"integrity": "sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==",
"dependencies": {
"yallist": "^4.0.0"
},
"engines": {
"node": ">=10"
}
},
"node_modules/semver/node_modules/yallist": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz",
"integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A=="
},
"node_modules/send": { "node_modules/send": {
"version": "0.18.0", "version": "0.18.0",
"resolved": "https://registry.npmjs.org/send/-/send-0.18.0.tgz", "resolved": "https://registry.npmjs.org/send/-/send-0.18.0.tgz",
@ -17382,28 +17363,30 @@
} }
}, },
"node_modules/ts-jest": { "node_modules/ts-jest": {
"version": "29.1.1", "version": "29.2.5",
"resolved": "https://registry.npmjs.org/ts-jest/-/ts-jest-29.1.1.tgz", "resolved": "https://registry.npmjs.org/ts-jest/-/ts-jest-29.2.5.tgz",
"integrity": "sha512-D6xjnnbP17cC85nliwGiL+tpoKN0StpgE0TeOjXQTU6MVCfsB4v7aW05CgQ/1OywGb0x/oy9hHFnN+sczTiRaA==", "integrity": "sha512-KD8zB2aAZrcKIdGk4OwpJggeLcH1FgrICqDSROWqlnJXGCXK4Mn6FcdK2B6670Xr73lHMG1kHw8R87A0ecZ+vA==",
"dev": true, "dev": true,
"dependencies": { "dependencies": {
"bs-logger": "0.x", "bs-logger": "^0.2.6",
"fast-json-stable-stringify": "2.x", "ejs": "^3.1.10",
"fast-json-stable-stringify": "^2.1.0",
"jest-util": "^29.0.0", "jest-util": "^29.0.0",
"json5": "^2.2.3", "json5": "^2.2.3",
"lodash.memoize": "4.x", "lodash.memoize": "^4.1.2",
"make-error": "1.x", "make-error": "^1.3.6",
"semver": "^7.5.3", "semver": "^7.6.3",
"yargs-parser": "^21.0.1" "yargs-parser": "^21.1.1"
}, },
"bin": { "bin": {
"ts-jest": "cli.js" "ts-jest": "cli.js"
}, },
"engines": { "engines": {
"node": "^14.15.0 || ^16.10.0 || >=18.0.0" "node": "^14.15.0 || ^16.10.0 || ^18.0.0 || >=20.0.0"
}, },
"peerDependencies": { "peerDependencies": {
"@babel/core": ">=7.0.0-beta.0 <8", "@babel/core": ">=7.0.0-beta.0 <8",
"@jest/transform": "^29.0.0",
"@jest/types": "^29.0.0", "@jest/types": "^29.0.0",
"babel-jest": "^29.0.0", "babel-jest": "^29.0.0",
"jest": "^29.0.0", "jest": "^29.0.0",
@ -17413,6 +17396,9 @@
"@babel/core": { "@babel/core": {
"optional": true "optional": true
}, },
"@jest/transform": {
"optional": true
},
"@jest/types": { "@jest/types": {
"optional": true "optional": true
}, },

Просмотреть файл

@ -26,7 +26,7 @@
"watch": "lerna exec --stream --parallel -- tsc -b -w" "watch": "lerna exec --stream --parallel -- tsc -b -w"
}, },
"devDependencies": { "devDependencies": {
"@types/jest": "^29.5.0", "@types/jest": "^29.5.12",
"@types/node": "^18.0.0", "@types/node": "^18.0.0",
"@types/webpack-dev-server": "^4.7.2", "@types/webpack-dev-server": "^4.7.2",
"@typescript-eslint/eslint-plugin": "^5.32.0", "@typescript-eslint/eslint-plugin": "^5.32.0",
@ -36,8 +36,8 @@
"eslint-plugin-header": "^3.1.1", "eslint-plugin-header": "^3.1.1",
"eslint-plugin-jsdoc": "^39.3.4", "eslint-plugin-jsdoc": "^39.3.4",
"eslint-plugin-prefer-arrow": "^1.2.3", "eslint-plugin-prefer-arrow": "^1.2.3",
"jest": "^29.5.0", "jest": "^29.7.0",
"jest-junit": "^15.0.0", "jest-junit": "^16.0.0",
"lerna": "^7.4.2", "lerna": "^7.4.2",
"npm": "^9.6.2", "npm": "^9.6.2",
"prettier": "^2.8.4", "prettier": "^2.8.4",
@ -45,7 +45,7 @@
"shx": "^0.3.4", "shx": "^0.3.4",
"sinon": "^14.0.0", "sinon": "^14.0.0",
"stream-browserify": "^3.0.0", "stream-browserify": "^3.0.0",
"ts-jest": "^29.1.1", "ts-jest": "^29.2.5",
"ts-loader": "^9.4.2", "ts-loader": "^9.4.2",
"ts-node": "^10.9.1", "ts-node": "^10.9.1",
"typescript": "^5.0.0", "typescript": "^5.0.0",

Просмотреть файл

@ -2,9 +2,13 @@
"name": "azure-kusto-data", "name": "azure-kusto-data",
"version": "6.0.2", "version": "6.0.2",
"description": "Azure Data Explorer Query SDK", "description": "Azure Data Explorer Query SDK",
"module": "dist-esm/src/index.js", "type": "module",
"types": "./types/src/index.d.ts", "exports": {
"main": "dist-esm/src/index", ".": {
"import": "./dist-esm/src/index.js",
"types": "./types/src/index.d.ts"
}
},
"scripts": { "scripts": {
"clean": "rimraf dist/* dist-esm/* types/*", "clean": "rimraf dist/* dist-esm/* types/*",
"build": "tsc -b" "build": "tsc -b"

Просмотреть файл

@ -6,15 +6,15 @@ import axios, { AxiosInstance, AxiosRequestConfig, RawAxiosRequestHeaders } from
import http from "http"; import http from "http";
import https from "https"; import https from "https";
import { v4 as uuidv4 } from "uuid"; import { v4 as uuidv4 } from "uuid";
import { KustoHeaders } from "./clientDetails"; import { KustoHeaders } from "./clientDetails.js";
import ClientRequestProperties from "./clientRequestProperties"; import ClientRequestProperties from "./clientRequestProperties.js";
import CloudSettings from "./cloudSettings"; import CloudSettings from "./cloudSettings.js";
import ConnectionStringBuilder from "./connectionBuilder"; import ConnectionStringBuilder from "./connectionBuilder.js";
import { ThrottlingError } from "./errors"; import { ThrottlingError } from "./errors.js";
import { kustoTrustedEndpoints } from "./kustoTrustedEndpoints"; import { kustoTrustedEndpoints } from "./kustoTrustedEndpoints.js";
import { KustoResponseDataSet, KustoResponseDataSetV1, KustoResponseDataSetV2, V1, V2Frames } from "./response"; import { KustoResponseDataSet, KustoResponseDataSetV1, KustoResponseDataSetV2, V1, V2Frames } from "./response.js";
import AadHelper from "./security"; import AadHelper from "./security.js";
import { toMilliseconds } from "./timeUtils"; import { toMilliseconds } from "./timeUtils.js";
const COMMAND_TIMEOUT_IN_MILLISECS = toMilliseconds(0, 10, 30); const COMMAND_TIMEOUT_IN_MILLISECS = toMilliseconds(0, 10, 30);
const QUERY_TIMEOUT_IN_MILLISECS = toMilliseconds(0, 4, 30); const QUERY_TIMEOUT_IN_MILLISECS = toMilliseconds(0, 4, 30);

Просмотреть файл

@ -3,7 +3,7 @@
import { isNode } from "@azure/core-util"; import { isNode } from "@azure/core-util";
import { userInfo } from "os"; import { userInfo } from "os";
import { SDK_VERSION } from "./version"; import { SDK_VERSION } from "./version.js";
// eslint-disable-next-line @typescript-eslint/no-namespace,@typescript-eslint/no-unused-vars -- This is the correct way to augment the global namespace // eslint-disable-next-line @typescript-eslint/no-namespace,@typescript-eslint/no-unused-vars -- This is the correct way to augment the global namespace
declare namespace NodeJS { declare namespace NodeJS {

Просмотреть файл

@ -1,7 +1,7 @@
// Copyright (c) Microsoft Corporation. // Copyright (c) Microsoft Corporation.
// Licensed under the MIT License. // Licensed under the MIT License.
import { KustoHeaders } from "./clientDetails"; import { KustoHeaders } from "./clientDetails.js";
export class ClientRequestProperties { export class ClientRequestProperties {
private _options: { [option: string]: any }; private _options: { [option: string]: any };

Просмотреть файл

@ -2,7 +2,7 @@
// Licensed under the MIT License. // Licensed under the MIT License.
import { DeviceCodeInfo, InteractiveBrowserCredentialInBrowserOptions, InteractiveBrowserCredentialNodeOptions, TokenCredential } from "@azure/identity"; import { DeviceCodeInfo, InteractiveBrowserCredentialInBrowserOptions, InteractiveBrowserCredentialNodeOptions, TokenCredential } from "@azure/identity";
import KustoConnectionStringBuilderBase from "./connectionBuilderBase"; import KustoConnectionStringBuilderBase from "./connectionBuilderBase.js";
/* eslint-disable @typescript-eslint/no-unused-vars */ /* eslint-disable @typescript-eslint/no-unused-vars */

Просмотреть файл

@ -2,7 +2,7 @@
// Licensed under the MIT License. // Licensed under the MIT License.
import { DeviceCodeInfo, InteractiveBrowserCredentialInBrowserOptions, InteractiveBrowserCredentialNodeOptions, TokenCredential } from "@azure/identity"; import { DeviceCodeInfo, InteractiveBrowserCredentialInBrowserOptions, InteractiveBrowserCredentialNodeOptions, TokenCredential } from "@azure/identity";
import { KustoConnectionStringBuilderBase } from "./connectionBuilderBase"; import { KustoConnectionStringBuilderBase } from "./connectionBuilderBase.js";
/* /*
* A builder for Kusto connection strings * A builder for Kusto connection strings

Просмотреть файл

@ -2,8 +2,8 @@
// Licensed under the MIT License. // Licensed under the MIT License.
import { DeviceCodeInfo, InteractiveBrowserCredentialInBrowserOptions, InteractiveBrowserCredentialNodeOptions, TokenCredential } from "@azure/identity"; import { DeviceCodeInfo, InteractiveBrowserCredentialInBrowserOptions, InteractiveBrowserCredentialNodeOptions, TokenCredential } from "@azure/identity";
import { KeyOfType } from "./typeUtilts"; import { KeyOfType } from "./typeUtilts.js";
import { ClientDetails } from "./clientDetails"; import { ClientDetails } from "./clientDetails.js";
interface MappingType { interface MappingType {
mappedTo: string; mappedTo: string;

Просмотреть файл

@ -1,15 +1,15 @@
// Copyright (c) Microsoft Corporation. // Copyright (c) Microsoft Corporation.
// Licensed under the MIT License. // Licensed under the MIT License.
import KustoClient from "./client"; import KustoClient from "./client.js";
import ClientRequestProperties from "./clientRequestProperties"; import ClientRequestProperties from "./clientRequestProperties.js";
import { CloudSettings, CloudInfo } from "./cloudSettings"; import { CloudSettings, CloudInfo } from "./cloudSettings.js";
import KustoConnectionStringBuilder from "./connectionBuilder"; import KustoConnectionStringBuilder from "./connectionBuilder.js";
import * as KustoDataErrors from "./errors"; import * as KustoDataErrors from "./errors.js";
import { kustoTrustedEndpoints, MatchRule } from "./kustoTrustedEndpoints"; import { kustoTrustedEndpoints, MatchRule } from "./kustoTrustedEndpoints.js";
import { KustoResultColumn, KustoResultRow, KustoResultTable } from "./models"; import { KustoResultColumn, KustoResultRow, KustoResultTable } from "./models.js";
import { KustoResponseDataSet } from "./response"; import { KustoResponseDataSet } from "./response.js";
import { toMilliseconds } from "./timeUtils"; import { toMilliseconds } from "./timeUtils.js";
const TimeUtils = { toMilliseconds }; const TimeUtils = { toMilliseconds };

Просмотреть файл

@ -1,7 +1,7 @@
// Copyright (c) Microsoft Corporation. // Copyright (c) Microsoft Corporation.
// Licensed under the MIT License. // Licensed under the MIT License.
import { getStringTailLowerCase } from "./utils"; import { getStringTailLowerCase } from "./utils.js";
import { default as endpointsData } from "./wellKnownKustoEndpoints.json"; import { default as endpointsData } from "./wellKnownKustoEndpoints.json";
export class MatchRule { export class MatchRule {

Просмотреть файл

@ -1,7 +1,7 @@
// Copyright (c) Microsoft Corporation. // Copyright (c) Microsoft Corporation.
// Licensed under the MIT License. // Licensed under the MIT License.
import { parseKustoTimestampToMillis } from "./timeUtils"; import { parseKustoTimestampToMillis } from "./timeUtils.js";
export enum WellKnownDataSet { export enum WellKnownDataSet {
PrimaryResult = "PrimaryResult", PrimaryResult = "PrimaryResult",

Просмотреть файл

@ -1,7 +1,7 @@
// Copyright (c) Microsoft Corporation. // Copyright (c) Microsoft Corporation.
// Licensed under the MIT License. // Licensed under the MIT License.
import { KustoResultTable, Table, WellKnownDataSet } from "./models"; import { KustoResultTable, Table, WellKnownDataSet } from "./models.js";
interface V2DataSetHeaderFrame { interface V2DataSetHeaderFrame {
FrameType: "DataSetHeader"; FrameType: "DataSetHeader";

Просмотреть файл

@ -1,9 +1,9 @@
// Copyright (c) Microsoft Corporation. // Copyright (c) Microsoft Corporation.
// Licensed under the MIT License. // Licensed under the MIT License.
import KustoConnectionStringBuilder from "./connectionBuilder"; import KustoConnectionStringBuilder from "./connectionBuilder.js";
import * as TokenProvider from "./tokenProvider"; import * as TokenProvider from "./tokenProvider.js";
import { KustoAuthenticationError } from "./errors"; import { KustoAuthenticationError } from "./errors.js";
import { BasicTokenProvider, CallbackTokenProvider, TokenProviderBase, UserPromptProvider, TokenCredentialProvider } from "./tokenProvider"; import { BasicTokenProvider, CallbackTokenProvider, TokenProviderBase, UserPromptProvider, TokenCredentialProvider } from "./tokenProvider.js";
export class AadHelper { export class AadHelper {
tokenProvider?: TokenProviderBase; tokenProvider?: TokenProviderBase;

Просмотреть файл

@ -15,7 +15,7 @@ import {
InteractiveBrowserCredential, InteractiveBrowserCredential,
} from "@azure/identity"; } from "@azure/identity";
import { TokenCredential } from "@azure/core-auth"; import { TokenCredential } from "@azure/core-auth";
import { CloudInfo, CloudSettings } from "./cloudSettings"; import { CloudInfo, CloudSettings } from "./cloudSettings.js";
export declare type TokenResponse = { export declare type TokenResponse = {
tokenType: string; tokenType: string;

Просмотреть файл

@ -0,0 +1,45 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
/* eslint-disable no-console */
import assert from "assert";
import { KustoConnectionStringBuilder as ConnectionStringBuilder } from "../src/connectionBuilder.browser.js";
const cluster = "https://somecluster.kusto.windows.net";
describe("Kcsb", () => {
it.concurrent("Fail to create non-browser compatible authentication", () => {
try {
ConnectionStringBuilder.withAadApplicationKeyAuthentication(cluster, "", "");
} catch (ex) {
assert(ex instanceof Error && ex.message.startsWith("Not supported in browser"));
return;
}
assert.fail();
});
it.concurrent("Create browser compatible authentication with params", () => {
ConnectionStringBuilder.withUserPrompt(cluster, { redirectUri: "redirect", clientId: "cid" });
});
it.concurrent("Create browser compatible authentication must provide clientId", () => {
try {
ConnectionStringBuilder.withUserPrompt(cluster, { redirectUri: "redirect" });
} catch (ex) {
assert((ex as Error).message.startsWith("Invalid parameters"));
return;
}
assert.fail();
});
it.concurrent("Create browser compatible authentication must provide redirectUri", () => {
try {
ConnectionStringBuilder.withUserPrompt(cluster, { clientId: "cid" });
} catch (ex) {
assert((ex as Error).message.startsWith("Invalid parameters"));
return;
}
assert.fail();
});
});

Просмотреть файл

@ -5,19 +5,19 @@ import assert from "assert";
import { v4 as uuidv4 } from "uuid"; import { v4 as uuidv4 } from "uuid";
import { KustoClient } from "../src/client"; import { KustoClient } from "../src/client.js";
import { ClientRequestProperties } from "../src/clientRequestProperties"; import { ClientRequestProperties } from "../src/clientRequestProperties.js";
import { KustoResponseDataSetV1, KustoResponseDataSetV2 } from "../src/response"; import { KustoResponseDataSetV1, KustoResponseDataSetV2 } from "../src/response.js";
import v2Response from "./data/response/v2.json"; import v2Response from "./data/response/v2.json";
import v2ResponseError from "./data/response/v2error.json"; import v2ResponseError from "./data/response/v2error.json";
import v1Response from "./data/response/v1.json"; import v1Response from "./data/response/v1.json";
import v1_2Response from "./data/response/v1_2.json"; import v1_2Response from "./data/response/v1_2.json";
import { Readable } from "stream"; import { Readable } from "stream";
import ConnectionBuilder from "../src/connectionBuilder"; import ConnectionBuilder from "../src/connectionBuilder.js";
import { CloudSettings } from "../src/cloudSettings"; import { CloudSettings } from "../src/cloudSettings.js";
import { toMilliseconds } from "../src/timeUtils"; import { toMilliseconds } from "../src/timeUtils.js";
enum ExecutionType { enum ExecutionType {
Mgmt = "mgmt", Mgmt = "mgmt",

Просмотреть файл

@ -5,7 +5,7 @@
import assert from "assert"; import assert from "assert";
import { v4 as uuidv4 } from "uuid"; import { v4 as uuidv4 } from "uuid";
import { KustoConnectionStringBuilder } from "../src/connectionBuilder"; import { KustoConnectionStringBuilder } from "../src/connectionBuilder.js";
import { DeviceCodeInfo } from "@azure/identity"; import { DeviceCodeInfo } from "@azure/identity";
const doComparsion = ( const doComparsion = (

Просмотреть файл

@ -1,6 +1,6 @@
// Copyright (c) Microsoft Corporation. // Copyright (c) Microsoft Corporation.
// Licensed under the MIT License. // Licensed under the MIT License.
import { ClientDetails } from "../src/clientDetails"; import { ClientDetails } from "../src/clientDetails.js";
import assert from "assert"; import assert from "assert";
describe("Test Headers", () => { describe("Test Headers", () => {

Просмотреть файл

@ -1,7 +1,7 @@
// Copyright (c) Microsoft Corporation. // Copyright (c) Microsoft Corporation.
// Licensed under the MIT License. // Licensed under the MIT License.
import { kustoTrustedEndpoints, MatchRule } from "../src/kustoTrustedEndpoints"; import { kustoTrustedEndpoints, MatchRule } from "azure-kusto-data";
const DEFAULT_PUBLIC_LOGIN_URL = "https://login.microsoftonline.com"; const DEFAULT_PUBLIC_LOGIN_URL = "https://login.microsoftonline.com";
const CHINA_CLOUD_LOGIN = "https://login.partner.microsoftonline.cn"; const CHINA_CLOUD_LOGIN = "https://login.partner.microsoftonline.cn";

Просмотреть файл

@ -2,9 +2,9 @@
// Licensed under the MIT License. // Licensed under the MIT License.
import assert from "assert"; import assert from "assert";
import { KustoResultColumn, KustoResultRow, KustoResultTable } from "../src/models"; import { KustoResultColumn, KustoResultRow, KustoResultTable } from "../src/models.js";
import v2 from "./data/response/v2"; import v2 from "./data/response/v2.js";
import { parseKustoTimestampToMillis } from "../src/timeUtils"; import { parseKustoTimestampToMillis } from "../src/timeUtils.js";
const v2Response = v2; const v2Response = v2;

Просмотреть файл

@ -4,7 +4,7 @@
import assert from "assert"; import assert from "assert";
import v2Response from "./data/response/v2.json"; import v2Response from "./data/response/v2.json";
import { KustoResponseDataSetV2, V2Frames } from "../src/response"; import { KustoResponseDataSetV2, V2Frames } from "../src/response.js";
describe("KustoResultDataSet", () => { describe("KustoResultDataSet", () => {
describe("#constructor()", () => { describe("#constructor()", () => {

Просмотреть файл

@ -1,13 +1,13 @@
// Copyright (c) Microsoft Corporation. // Copyright (c) Microsoft Corporation.
// Licensed under the MIT License. // Licensed under the MIT License.
import { KustoConnectionStringBuilder } from "../src/index"; import { KustoConnectionStringBuilder } from "../src/index.js";
import AadHelper from "../src/security"; import AadHelper from "../src/security.js";
import { CloudSettings } from "../src/cloudSettings"; import { CloudSettings } from "../src/cloudSettings.js";
import assert from "assert"; import assert from "assert";
import { KustoAuthenticationError } from "../src/errors"; import { KustoAuthenticationError } from "../src/errors.js";
import { CredentialUnavailableError } from "@azure/identity"; import { CredentialUnavailableError } from "@azure/identity";
import { loginTest, manualLoginTest } from "./data/testUtils"; import { loginTest, manualLoginTest } from "./data/testUtils.js";
beforeAll(() => { beforeAll(() => {
CloudSettings.writeToCache("https://somecluster.kusto.windows.net"); CloudSettings.writeToCache("https://somecluster.kusto.windows.net");

Просмотреть файл

@ -1,9 +1,9 @@
// Copyright (c) Microsoft Corporation. // Copyright (c) Microsoft Corporation.
// Licensed under the MIT License. // Licensed under the MIT License.
import { CloudSettings } from "../src/cloudSettings"; import { CloudSettings } from "../src/cloudSettings.js";
import assert from "assert"; import assert from "assert";
import { UserPassTokenProvider } from "../src/tokenProvider"; import { UserPassTokenProvider } from "../src/tokenProvider.js";
describe("CloudInfo", () => { describe("CloudInfo", () => {
describe("#CloudInfo", () => { describe("#CloudInfo", () => {

Просмотреть файл

@ -2,9 +2,13 @@
"name": "azure-kusto-ingest", "name": "azure-kusto-ingest",
"version": "6.0.2", "version": "6.0.2",
"description": "Azure Data Explorer Ingestion SDK", "description": "Azure Data Explorer Ingestion SDK",
"module": "dist-esm/src/index.js", "type": "module",
"types": "./types/src/index.d.ts", "exports": {
"main": "dist-esm/src/index", ".": {
"import": "./dist-esm/src/index.js",
"types": "./types/src/index.d.ts"
}
},
"scripts": { "scripts": {
"build": "tsc -b", "build": "tsc -b",
"clean": "rimraf dist/* dist-esm/* types/*" "clean": "rimraf dist/* dist-esm/* types/*"

Просмотреть файл

@ -1,8 +1,8 @@
// Copyright (c) Microsoft Corporation. // Copyright (c) Microsoft Corporation.
// Licensed under the MIT License. // Licensed under the MIT License.
import { IngestionProperties, IngestionPropertiesInput } from "./ingestionProperties"; import { IngestionProperties, IngestionPropertiesInput } from "./ingestionProperties.js";
import { StreamDescriptor, FileDescriptorBase, BlobDescriptor } from "./descriptors"; import { StreamDescriptor, FileDescriptorBase, BlobDescriptor } from "./descriptors.js";
import isIP from "is-ip"; import isIP from "is-ip";
const INGEST_PREFIX = "ingest-"; const INGEST_PREFIX = "ingest-";

Просмотреть файл

@ -3,7 +3,7 @@
/* eslint-disable @typescript-eslint/ban-types -- We legitimately want to use {} as a "any non-nullable type" */ /* eslint-disable @typescript-eslint/ban-types -- We legitimately want to use {} as a "any non-nullable type" */
import { IngestionMappingKind } from "./ingestionProperties"; import { IngestionMappingKind } from "./ingestionProperties.js";
export enum FieldTransformation { export enum FieldTransformation {
PropertyBagArrayToDictionary = "PropertyBagArrayToDictionary", PropertyBagArrayToDictionary = "PropertyBagArrayToDictionary",

Просмотреть файл

@ -4,7 +4,7 @@
import { v4 as uuidv4 } from "uuid"; import { v4 as uuidv4 } from "uuid";
import uuidValidate from "uuid-validate"; import uuidValidate from "uuid-validate";
import { Readable } from "stream"; import { Readable } from "stream";
import IngestionProperties from "./ingestionProperties"; import IngestionProperties from "./ingestionProperties.js";
import { BlobClient } from "@azure/storage-blob"; import { BlobClient } from "@azure/storage-blob";
export enum CompressionType { export enum CompressionType {

Просмотреть файл

@ -2,8 +2,8 @@
// Licensed under the MIT License. // Licensed under the MIT License.
import pako from "pako"; import pako from "pako";
import { AbstractDescriptor, CompressionType, FileDescriptorBase, shouldCompressFileByExtension } from "./descriptors"; import { AbstractDescriptor, CompressionType, FileDescriptorBase, shouldCompressFileByExtension } from "./descriptors.js";
import { IngestionPropertiesInput, shouldCompressFileByFormat } from "./ingestionProperties"; import { IngestionPropertiesInput, shouldCompressFileByFormat } from "./ingestionProperties.js";
export class FileDescriptor extends AbstractDescriptor implements FileDescriptorBase { export class FileDescriptor extends AbstractDescriptor implements FileDescriptorBase {
size: number | null; size: number | null;

Просмотреть файл

@ -6,8 +6,8 @@ import pathlib from "path";
import fs from "fs"; import fs from "fs";
import { file as tmpFile } from "tmp-promise"; import { file as tmpFile } from "tmp-promise";
import { promisify } from "util"; import { promisify } from "util";
import { AbstractDescriptor, CompressionType, FileDescriptorBase, shouldCompressFileByExtension } from "./descriptors"; import { AbstractDescriptor, CompressionType, FileDescriptorBase, shouldCompressFileByExtension } from "./descriptors.js";
import { IngestionPropertiesInput, shouldCompressFileByFormat } from "./ingestionProperties"; import { IngestionPropertiesInput, shouldCompressFileByFormat } from "./ingestionProperties.js";
/** /**
* Describes a file to be ingested. Use string to describe a local path in Node.JS and Blob object in browsers * Describes a file to be ingested. Use string to describe a local path in Node.JS and Blob object in browsers

Просмотреть файл

@ -1,15 +1,15 @@
// Copyright (c) Microsoft Corporation. // Copyright (c) Microsoft Corporation.
// Licensed under the MIT License. // Licensed under the MIT License.
import KustoIngestClient from "./ingestClient"; import KustoIngestClient from "./ingestClient.js";
import streamingIngestClient from "./streamingIngestClient"; import streamingIngestClient from "./streamingIngestClient.js";
import managedStreamingIngestClient from "./managedStreamingIngestClient"; import managedStreamingIngestClient from "./managedStreamingIngestClient.js";
import KustoIngestStatusQueues from "./status"; import KustoIngestStatusQueues from "./status.js";
import { IngestionResult, OperationStatus, IngestionStatus, IngestionStatusInTableDescription } from "./ingestionResult"; import { IngestionResult, OperationStatus, IngestionStatus, IngestionStatusInTableDescription } from "./ingestionResult.js";
import { import {
DataFormat, DataFormat,
IngestionMappingKind, IngestionMappingKind,
@ -19,7 +19,7 @@ import {
ValidationOptions, ValidationOptions,
ValidationPolicy, ValidationPolicy,
dataFormatMappingKind, dataFormatMappingKind,
} from "./ingestionProperties"; } from "./ingestionProperties.js";
import { import {
ApacheAvroColumnMapping, ApacheAvroColumnMapping,
@ -33,12 +33,12 @@ import {
ParquetColumnMapping, ParquetColumnMapping,
SStreamColumnMapping, SStreamColumnMapping,
W3CLogFileMapping, W3CLogFileMapping,
} from "./columnMappings"; } from "./columnMappings.js";
import { BlobDescriptor, CompressionType, StreamDescriptor } from "./descriptors"; import { BlobDescriptor, CompressionType, StreamDescriptor } from "./descriptors.js";
import { FileDescriptor } from "./fileDescriptor"; import { FileDescriptor } from "./fileDescriptor.js";
export { Transformation as ColumnMappingTransformation } from "./columnMappings"; export { Transformation as ColumnMappingTransformation } from "./columnMappings.js";
export { IngestionProperties } from "./ingestionProperties"; export { IngestionProperties } from "./ingestionProperties.js";
export { export {
KustoIngestClient as IngestClient, KustoIngestClient as IngestClient,
KustoIngestStatusQueues as IngestStatusQueues, KustoIngestStatusQueues as IngestStatusQueues,
@ -114,5 +114,5 @@ export const IngestionPropertiesEnums = {
ColumnMapping, ColumnMapping,
}; };
export { IngestionPropertiesValidationError } from "./errors"; export { IngestionPropertiesValidationError } from "./errors.js";
// eslint-disable-next-line no-console // eslint-disable-next-line no-console

Просмотреть файл

@ -3,12 +3,12 @@
import { KustoConnectionStringBuilder } from "azure-kusto-data"; import { KustoConnectionStringBuilder } from "azure-kusto-data";
import { BlobDescriptor, generateBlobName, StreamDescriptor } from "./descriptors"; import { BlobDescriptor, generateBlobName, StreamDescriptor } from "./descriptors.js";
import { FileDescriptor } from "./fileDescriptor.browser"; import { FileDescriptor } from "./fileDescriptor.browser.js";
import { IngestionPropertiesInput } from "./ingestionProperties"; import { IngestionPropertiesInput } from "./ingestionProperties.js";
import { KustoIngestClientBase } from "./ingestClientBase"; import { KustoIngestClientBase } from "./ingestClientBase.js";
import { IngestionResult } from "./ingestionResult"; import { IngestionResult } from "./ingestionResult.js";
export class KustoIngestClient extends KustoIngestClientBase { export class KustoIngestClient extends KustoIngestClientBase {
constructor(kcsb: string | KustoConnectionStringBuilder, defaultProps?: IngestionPropertiesInput, autoCorrectEndpoint?: boolean) { constructor(kcsb: string | KustoConnectionStringBuilder, defaultProps?: IngestionPropertiesInput, autoCorrectEndpoint?: boolean) {

Просмотреть файл

@ -3,13 +3,13 @@
import { KustoConnectionStringBuilder } from "azure-kusto-data"; import { KustoConnectionStringBuilder } from "azure-kusto-data";
import { BlobDescriptor, generateBlobName, StreamDescriptor } from "./descriptors"; import { BlobDescriptor, generateBlobName, StreamDescriptor } from "./descriptors.js";
import { FileDescriptor } from "./fileDescriptor"; import { FileDescriptor } from "./fileDescriptor.js";
import { IngestionPropertiesInput } from "./ingestionProperties"; import { IngestionPropertiesInput } from "./ingestionProperties.js";
import { KustoIngestClientBase } from "./ingestClientBase"; import { KustoIngestClientBase } from "./ingestClientBase.js";
import { Readable } from "stream"; import { Readable } from "stream";
import { IngestionResult } from "./ingestionResult"; import { IngestionResult } from "./ingestionResult.js";
export class KustoIngestClient extends KustoIngestClientBase { export class KustoIngestClient extends KustoIngestClientBase {
constructor(kcsb: string | KustoConnectionStringBuilder, defaultProps?: IngestionPropertiesInput, autoCorrectEndpoint?: boolean) { constructor(kcsb: string | KustoConnectionStringBuilder, defaultProps?: IngestionPropertiesInput, autoCorrectEndpoint?: boolean) {

Просмотреть файл

@ -3,15 +3,15 @@
import { Client as KustoClient, KustoConnectionStringBuilder } from "azure-kusto-data"; import { Client as KustoClient, KustoConnectionStringBuilder } from "azure-kusto-data";
import ResourceManager from "./resourceManager"; import ResourceManager from "./resourceManager.js";
import IngestionBlobInfo from "./ingestionBlobInfo"; import IngestionBlobInfo from "./ingestionBlobInfo.js";
import { ContainerClient } from "@azure/storage-blob"; import { ContainerClient } from "@azure/storage-blob";
import { QueueClient } from "@azure/storage-queue"; import { QueueClient } from "@azure/storage-queue";
import IngestionProperties, { IngestionPropertiesInput, ReportLevel, ReportMethod } from "./ingestionProperties"; import IngestionProperties, { IngestionPropertiesInput, ReportLevel, ReportMethod } from "./ingestionProperties.js";
import { AbstractKustoClient } from "./abstractKustoClient"; import { AbstractKustoClient } from "./abstractKustoClient.js";
import { import {
IngestionStatus, IngestionStatus,
TableReportIngestionResult, TableReportIngestionResult,
@ -20,10 +20,10 @@ import {
IngestionStatusResult, IngestionStatusResult,
OperationStatus, OperationStatus,
putRecordInTable, putRecordInTable,
} from "./ingestionResult"; } from "./ingestionResult.js";
import { Readable } from "stream"; import { Readable } from "stream";
import { BlobDescriptor, StreamDescriptor } from "./descriptors"; import { BlobDescriptor, StreamDescriptor } from "./descriptors.js";
export abstract class KustoIngestClientBase extends AbstractKustoClient { export abstract class KustoIngestClientBase extends AbstractKustoClient {
resourceManager: ResourceManager; resourceManager: ResourceManager;

Просмотреть файл

@ -2,9 +2,9 @@
// Licensed under the MIT License. // Licensed under the MIT License.
import { v4 as uuidv4 } from "uuid"; import { v4 as uuidv4 } from "uuid";
import { BlobDescriptor } from "./descriptors"; import { BlobDescriptor } from "./descriptors.js";
import IngestionProperties, { ReportLevel, ReportMethod } from "./ingestionProperties"; import IngestionProperties, { ReportLevel, ReportMethod } from "./ingestionProperties.js";
import { IngestionStatusInTableDescription } from "./ingestionResult"; import { IngestionStatusInTableDescription } from "./ingestionResult.js";
export class IngestionBlobInfo { export class IngestionBlobInfo {
BlobPath: string; BlobPath: string;

Просмотреть файл

@ -1,8 +1,8 @@
// Copyright (c) Microsoft Corporation. // Copyright (c) Microsoft Corporation.
// Licensed under the MIT License. // Licensed under the MIT License.
import { IngestionPropertiesValidationError } from "./errors"; import { IngestionPropertiesValidationError } from "./errors.js";
import { ColumnMapping } from "./columnMappings"; import { ColumnMapping } from "./columnMappings.js";
/** /**
* Data formats supported for Kusto ingestion. * Data formats supported for Kusto ingestion.

Просмотреть файл

@ -2,8 +2,8 @@
// Licensed under the MIT License. // Licensed under the MIT License.
import { TableClient, TableEntity } from "@azure/data-tables"; import { TableClient, TableEntity } from "@azure/data-tables";
import { ExponentialRetry } from "./retry"; import { ExponentialRetry } from "./retry.js";
import { createStatusTableClient } from "./resourceManager"; import { createStatusTableClient } from "./resourceManager.js";
export interface IngestionResult { export interface IngestionResult {
/// <summary> /// <summary>
/// Retrieves the detailed ingestion status of /// Retrieves the detailed ingestion status of

Просмотреть файл

@ -1,19 +1,19 @@
// Copyright (c) Microsoft Corporation. // Copyright (c) Microsoft Corporation.
// Licensed under the MIT License. // Licensed under the MIT License.
import { IngestionPropertiesInput } from "./ingestionProperties"; import { IngestionPropertiesInput } from "./ingestionProperties.js";
import { isNode } from "@azure/core-util"; import { isNode } from "@azure/core-util";
import { KustoConnectionStringBuilder, KustoResponseDataSet } from "azure-kusto-data"; import { KustoConnectionStringBuilder, KustoResponseDataSet } from "azure-kusto-data";
import { Readable } from "stream"; import { Readable } from "stream";
import { AbstractKustoClient } from "./abstractKustoClient"; import { AbstractKustoClient } from "./abstractKustoClient.js";
import { AbstractDescriptor, BlobDescriptor, StreamDescriptor } from "./descriptors"; import { AbstractDescriptor, BlobDescriptor, StreamDescriptor } from "./descriptors.js";
import { FileDescriptor } from "./fileDescriptor"; import { FileDescriptor } from "./fileDescriptor.js";
import IngestClient from "./ingestClient"; import IngestClient from "./ingestClient.js";
import { ExponentialRetry } from "./retry"; import { ExponentialRetry } from "./retry.js";
import { readableToStream, tryFileToBuffer, tryStreamToArray } from "./streamUtils"; import { readableToStream, tryFileToBuffer, tryStreamToArray } from "./streamUtils.js";
import StreamingIngestClient from "./streamingIngestClient"; import StreamingIngestClient from "./streamingIngestClient.js";
import { IngestionResult } from "./ingestionResult"; import { IngestionResult } from "./ingestionResult.js";
const maxStreamSize = 1024 * 1024 * 4; const maxStreamSize = 1024 * 1024 * 4;
const attemptCount = 3; const attemptCount = 3;

Просмотреть файл

@ -1,7 +1,7 @@
// Copyright (c) Microsoft Corporation. // Copyright (c) Microsoft Corporation.
// Licensed under the MIT License. // Licensed under the MIT License.
import { RankedStorageAccount } from "./rankedStorageAccount"; import { RankedStorageAccount } from "./rankedStorageAccount.js";
export class RankedStorageAccountSet { export class RankedStorageAccountSet {
public static readonly DefaultNumberOfBuckets: number = 6; public static readonly DefaultNumberOfBuckets: number = 6;

Просмотреть файл

@ -2,10 +2,10 @@
// Licensed under the MIT License. // Licensed under the MIT License.
import { Client, KustoDataErrors, TimeUtils } from "azure-kusto-data"; import { Client, KustoDataErrors, TimeUtils } from "azure-kusto-data";
import { ExponentialRetry } from "./retry"; import { ExponentialRetry } from "./retry.js";
import { ContainerClient } from "@azure/storage-blob"; import { ContainerClient } from "@azure/storage-blob";
import { TableClient } from "@azure/data-tables"; import { TableClient } from "@azure/data-tables";
import { RankedStorageAccountSet } from "./rankedStorageAccountSet"; import { RankedStorageAccountSet } from "./rankedStorageAccountSet.js";
import { QueueClient } from "@azure/storage-queue"; import { QueueClient } from "@azure/storage-queue";
const ATTEMPT_COUNT = 4; const ATTEMPT_COUNT = 4;

Просмотреть файл

@ -1,9 +1,9 @@
// Copyright (c) Microsoft Corporation. // Copyright (c) Microsoft Corporation.
// Licensed under the MIT License. // Licensed under the MIT License.
import { StatusQueue } from "./statusQ"; import { StatusQueue } from "./statusQ.js";
import KustoIngestClient from "./ingestClient"; import KustoIngestClient from "./ingestClient.js";
import { ResourceURI } from "./resourceManager"; import { ResourceURI } from "./resourceManager.js";
export class StatusMessage { export class StatusMessage {
OperationId?: string; OperationId?: string;

Просмотреть файл

@ -2,8 +2,8 @@
// Licensed under the MIT License. // Licensed under the MIT License.
import { PeekedMessageItem, QueueClient } from "@azure/storage-queue"; import { PeekedMessageItem, QueueClient } from "@azure/storage-queue";
import { ResourceURI } from "./resourceManager"; import { ResourceURI } from "./resourceManager.js";
import { StatusMessage } from "./status"; import { StatusMessage } from "./status.js";
class QueueDetails { class QueueDetails {
constructor(readonly name: string, readonly service: QueueClient) {} constructor(readonly name: string, readonly service: QueueClient) {}

Просмотреть файл

@ -1,8 +1,8 @@
// Copyright (c) Microsoft Corporation. // Copyright (c) Microsoft Corporation.
// Licensed under the MIT License. // Licensed under the MIT License.
import { CompressionType, StreamDescriptor } from "./descriptors"; import { CompressionType, StreamDescriptor } from "./descriptors.js";
import { FileDescriptor } from "./fileDescriptor.browser"; import { FileDescriptor } from "./fileDescriptor.browser.js";
export const fileToStream = async (file: FileDescriptor): Promise<StreamDescriptor> => { export const fileToStream = async (file: FileDescriptor): Promise<StreamDescriptor> => {
const streamFs = await (file.file as Blob).arrayBuffer(); const streamFs = await (file.file as Blob).arrayBuffer();

Просмотреть файл

@ -4,8 +4,8 @@
import fs from "fs"; import fs from "fs";
import { PassThrough, Readable } from "stream"; import { PassThrough, Readable } from "stream";
import streamify from "stream-array"; import streamify from "stream-array";
import { CompressionType, StreamDescriptor } from "./descriptors"; import { CompressionType, StreamDescriptor } from "./descriptors.js";
import { FileDescriptor } from "./fileDescriptor"; import { FileDescriptor } from "./fileDescriptor.js";
// Returns fs.ReadStream for node and NodeJS.ReadableStream in browser // Returns fs.ReadStream for node and NodeJS.ReadableStream in browser
export const fileToStream = (fileDescriptor: FileDescriptor): Promise<StreamDescriptor> => { export const fileToStream = (fileDescriptor: FileDescriptor): Promise<StreamDescriptor> => {

Просмотреть файл

@ -1,13 +1,13 @@
// Copyright (c) Microsoft Corporation. // Copyright (c) Microsoft Corporation.
// Licensed under the MIT License. // Licensed under the MIT License.
import { IngestionPropertiesInput } from "./ingestionProperties"; import { IngestionPropertiesInput } from "./ingestionProperties.js";
import { KustoConnectionStringBuilder, KustoResponseDataSet } from "azure-kusto-data"; import { KustoConnectionStringBuilder, KustoResponseDataSet } from "azure-kusto-data";
import { StreamDescriptor } from "./descriptors"; import { StreamDescriptor } from "./descriptors.js";
import { FileDescriptor } from "./fileDescriptor.browser"; import { FileDescriptor } from "./fileDescriptor.browser.js";
import { tryFileToBuffer } from "./streamUtils.browser"; import { tryFileToBuffer } from "./streamUtils.browser.js";
import { KustoStreamingIngestClientBase } from "./streamingIngestClientBase"; import { KustoStreamingIngestClientBase } from "./streamingIngestClientBase.js";
class KustoStreamingIngestClient extends KustoStreamingIngestClientBase { class KustoStreamingIngestClient extends KustoStreamingIngestClientBase {
constructor(kcsb: string | KustoConnectionStringBuilder, defaultProps?: IngestionPropertiesInput, autoCorrectEndpoint?: boolean) { constructor(kcsb: string | KustoConnectionStringBuilder, defaultProps?: IngestionPropertiesInput, autoCorrectEndpoint?: boolean) {

Просмотреть файл

@ -1,15 +1,15 @@
// Copyright (c) Microsoft Corporation. // Copyright (c) Microsoft Corporation.
// Licensed under the MIT License. // Licensed under the MIT License.
import { IngestionPropertiesInput } from "./ingestionProperties"; import { IngestionPropertiesInput } from "./ingestionProperties.js";
import { KustoConnectionStringBuilder, KustoResponseDataSet } from "azure-kusto-data"; import { KustoConnectionStringBuilder, KustoResponseDataSet } from "azure-kusto-data";
import { Readable } from "stream"; import { Readable } from "stream";
import zlib from "zlib"; import zlib from "zlib";
import { CompressionType, StreamDescriptor } from "./descriptors"; import { CompressionType, StreamDescriptor } from "./descriptors.js";
import { FileDescriptor } from "./fileDescriptor"; import { FileDescriptor } from "./fileDescriptor.js";
import { fileToStream } from "./streamUtils"; import { fileToStream } from "./streamUtils.js";
import { KustoStreamingIngestClientBase } from "./streamingIngestClientBase"; import { KustoStreamingIngestClientBase } from "./streamingIngestClientBase.js";
class KustoStreamingIngestClient extends KustoStreamingIngestClientBase { class KustoStreamingIngestClient extends KustoStreamingIngestClientBase {
constructor(kcsb: string | KustoConnectionStringBuilder, defaultProps?: IngestionPropertiesInput, autoCorrectEndpoint?: boolean) { constructor(kcsb: string | KustoConnectionStringBuilder, defaultProps?: IngestionPropertiesInput, autoCorrectEndpoint?: boolean) {

Просмотреть файл

@ -1,10 +1,10 @@
// Copyright (c) Microsoft Corporation. // Copyright (c) Microsoft Corporation.
// Licensed under the MIT License. // Licensed under the MIT License.
import { IngestionPropertiesInput } from "./ingestionProperties"; import { IngestionPropertiesInput } from "./ingestionProperties.js";
import { BlobDescriptor } from "./descriptors"; import { BlobDescriptor } from "./descriptors.js";
import { AbstractKustoClient } from "./abstractKustoClient"; import { AbstractKustoClient } from "./abstractKustoClient.js";
import { Client as KustoClient, KustoConnectionStringBuilder } from "azure-kusto-data"; import { Client as KustoClient, KustoConnectionStringBuilder } from "azure-kusto-data";
export abstract class KustoStreamingIngestClientBase extends AbstractKustoClient { export abstract class KustoStreamingIngestClientBase extends AbstractKustoClient {

Просмотреть файл

@ -4,48 +4,11 @@
/* eslint-disable no-console */ /* eslint-disable no-console */
import assert from "assert"; import assert from "assert";
import IngestClient from "../src/ingestClient.browser"; import IngestClient from "../src/ingestClient.browser.js";
import { KustoConnectionStringBuilder as ConnectionStringBuilder } from "azure-kusto-data/src/connectionBuilder.browser";
import sinon from "sinon"; import sinon from "sinon";
import { IngestionResult } from "../src/ingestionResult"; import { IngestionResult } from "azure-kusto-ingest";
describe(`Browser Unit tests`, () => {
const cluster = "https://somecluster.kusto.windows.net";
describe("Kcsb", () => { describe("Kcsb", () => {
it.concurrent("Fail to create non-browser compatible authentication", () => {
try {
ConnectionStringBuilder.withAadApplicationKeyAuthentication(cluster, "", "");
} catch (ex) {
assert(ex instanceof Error && ex.message.startsWith("Not supported in browser"));
return;
}
assert.fail();
});
it.concurrent("Create browser compatible authentication with params", () => {
ConnectionStringBuilder.withUserPrompt(cluster, { redirectUri: "redirect", clientId: "cid" });
});
it.concurrent("Create browser compatible authentication must provide clientId", () => {
try {
ConnectionStringBuilder.withUserPrompt(cluster, { redirectUri: "redirect" });
} catch (ex) {
assert((ex as Error).message.startsWith("Invalid parameters"));
return;
}
assert.fail();
});
it.concurrent("Create browser compatible authentication must provide redirectUri", () => {
try {
ConnectionStringBuilder.withUserPrompt(cluster, { clientId: "cid" });
} catch (ex) {
assert((ex as Error).message.startsWith("Invalid parameters"));
return;
}
assert.fail();
});
it.concurrent("Ingest from browser calls the right components", async () => { it.concurrent("Ingest from browser calls the right components", async () => {
const sandbox = sinon.createSandbox(); const sandbox = sinon.createSandbox();
@ -80,4 +43,3 @@ describe(`Browser Unit tests`, () => {
); );
}); });
}); });
});

Просмотреть файл

@ -3,8 +3,8 @@
import assert from "assert"; import assert from "assert";
import { Readable } from "stream"; import { Readable } from "stream";
import { DataFormat, IngestionDescriptors, IngestionProperties } from "../src"; import { DataFormat, IngestionDescriptors, IngestionProperties } from "azure-kusto-ingest";
import { generateBlobName } from "../src/descriptors"; import { generateBlobName } from "../src/descriptors.js";
describe("FileDescriptor", () => { describe("FileDescriptor", () => {
describe("#constructor()", () => { describe("#constructor()", () => {

Просмотреть файл

@ -24,17 +24,23 @@ import {
StreamingIngestClient, StreamingIngestClient,
IngestionStatus, IngestionStatus,
IngestionResult, IngestionResult,
} from "../../src"; } from "azure-kusto-ingest";
import { sleep } from "../../src/retry";
import { type AxiosError } from "axios";
import { sleep } from "../../src/retry.js";
import { AzureCliCredential } from "@azure/identity"; import { AzureCliCredential } from "@azure/identity";
import assert from "assert"; import assert from "assert";
import fs, { ReadStream } from "fs"; import fs, { ReadStream } from "fs";
import util from "util"; import util from "util";
import { v4 as uuidv4 } from "uuid"; import { v4 as uuidv4 } from "uuid";
import pathlib from "path"; import { basename, dirname } from "path";
import sinon from "sinon"; import sinon from "sinon";
import { TableReportIngestionResult } from "../../src/ingestionResult"; import { fileURLToPath } from "url";
const __filename = fileURLToPath(import.meta.url);
const __dirname = dirname(__filename);
interface ParsedJsonMapping { interface ParsedJsonMapping {
Properties: { Path: string }; Properties: { Path: string };
@ -254,7 +260,7 @@ const main = (): void => {
try { try {
const res: IngestionResult = await ingestClient.ingestFromFile(item.path, props); const res: IngestionResult = await ingestClient.ingestFromFile(item.path, props);
assert.ok(res, "ingest result returned null or undefined"); assert.ok(res, "ingest result returned null or undefined");
assert.ok(res instanceof TableReportIngestionResult); assert.equal(res.constructor.name, "TableReportIngestionResult");
let status: IngestionStatus; let status: IngestionStatus;
const endTime = Date.now() + 180000; // Timeout is 3 minutes const endTime = Date.now() + 180000; // Timeout is 3 minutes
while (Date.now() < endTime) { while (Date.now() < endTime) {
@ -334,7 +340,7 @@ const main = (): void => {
return { item: i }; return { item: i };
}) })
)("ingestFromBlob_$item.description", async ({ item }) => { )("ingestFromBlob_$item.description", async ({ item }) => {
const blobName = uuidv4() + pathlib.basename(item.path); const blobName = uuidv4() + basename(item.path);
const blobUri = await ingestClient.uploadToBlobWithRetry(item.path, blobName); const blobUri = await ingestClient.uploadToBlobWithRetry(item.path, blobName);
const table = tableNames[("streaming_blob" + "_" + item.description) as Table]; const table = tableNames[("streaming_blob" + "_" + item.description) as Table];

Просмотреть файл

@ -2,11 +2,11 @@
// Licensed under the MIT License. // Licensed under the MIT License.
import assert from "assert"; import assert from "assert";
import { KustoIngestClient } from "../src/ingestClient"; import { KustoIngestClient } from "../src/ingestClient.js";
import { DataFormat, IngestionProperties, IngestionPropertiesInput, ReportLevel, ReportMethod } from "../src/ingestionProperties"; import { DataFormat, IngestionProperties, IngestionPropertiesInput, ReportLevel, ReportMethod } from "../src/ingestionProperties.js";
import { IngestionPropertiesValidationError } from "../src/errors"; import { IngestionPropertiesValidationError } from "../src/errors.js";
import KustoStreamingIngestClient from "../src/streamingIngestClient"; import KustoStreamingIngestClient from "../src/streamingIngestClient.js";
import KustoManagedStreamingIngestClient from "../src/managedStreamingIngestClient"; import KustoManagedStreamingIngestClient from "../src/managedStreamingIngestClient.js";
import { KustoConnectionStringBuilder } from "azure-kusto-data"; import { KustoConnectionStringBuilder } from "azure-kusto-data";
import { Readable } from "stream"; import { Readable } from "stream";

Просмотреть файл

@ -18,8 +18,8 @@ import {
W3CLogFileMapping, W3CLogFileMapping,
} from "azure-kusto-ingest"; } from "azure-kusto-ingest";
import { IngestionBlobInfo } from "../src/ingestionBlobInfo"; import { IngestionBlobInfo } from "../src/ingestionBlobInfo.js";
import { BlobDescriptor } from "../src/descriptors"; import { BlobDescriptor } from "../src/descriptors.js";
describe("IngestionProperties", () => { describe("IngestionProperties", () => {
describe("#constructor()", () => { describe("#constructor()", () => {

Просмотреть файл

@ -4,16 +4,15 @@
/* eslint-disable no-console */ /* eslint-disable no-console */
import sinon from "sinon"; import sinon from "sinon";
import { StreamingIngestClient } from "../src"; import { StreamingIngestClient, IngestionResult } from "azure-kusto-ingest";
import { StreamDescriptor } from "../src/descriptors"; import { StreamDescriptor } from "../src/descriptors.js";
import { KustoIngestClient } from "../src/ingestClient"; import { KustoIngestClient } from "../src/ingestClient.js";
import { DataFormat, IngestionProperties, IngestionPropertiesInput } from "../src/ingestionProperties"; import { DataFormat, IngestionProperties, IngestionPropertiesInput } from "../src/ingestionProperties.js";
import KustoManagedStreamingIngestClient from "../src/managedStreamingIngestClient"; import KustoManagedStreamingIngestClient from "../src/managedStreamingIngestClient.js";
import { Readable } from "stream"; import { Readable } from "stream";
import { CloudSettings, KustoConnectionStringBuilder } from "azure-kusto-data"; import { CloudSettings, KustoConnectionStringBuilder } from "azure-kusto-data";
import assert from "assert"; import assert from "assert";
import uuidValidate from "uuid-validate"; import uuidValidate from "uuid-validate";
import { IngestionResult } from "../src/ingestionResult";
type IngestFromStreamStub = sinon.SinonStub<[StreamDescriptor | Readable | ArrayBuffer, IngestionPropertiesInput?, string?], Promise<IngestionResult>>; type IngestFromStreamStub = sinon.SinonStub<[StreamDescriptor | Readable | ArrayBuffer, IngestionPropertiesInput?, string?], Promise<IngestionResult>>;
beforeAll(() => { beforeAll(() => {

Просмотреть файл

@ -2,7 +2,7 @@
// Licensed under the MIT License. // Licensed under the MIT License.
import assert from "assert"; import assert from "assert";
import { RankedStorageAccountSet } from "../src/rankedStorageAccountSet"; import { RankedStorageAccountSet } from "../src/rankedStorageAccountSet.js";
describe("RankedStorageAccountSet", () => { describe("RankedStorageAccountSet", () => {
describe("Input validation.", () => { describe("Input validation.", () => {

Просмотреть файл

@ -6,7 +6,7 @@ import assert from "assert";
import sinon from "sinon"; import sinon from "sinon";
import { Client as KustoClient, KustoResponseDataSet, TimeUtils } from "azure-kusto-data"; import { Client as KustoClient, KustoResponseDataSet, TimeUtils } from "azure-kusto-data";
import { IngestClientResources, ResourceManager, ResourceType } from "../src/resourceManager"; import { IngestClientResources, ResourceManager, ResourceType } from "../src/resourceManager.js";
describe("ResourceManager", () => { describe("ResourceManager", () => {
const rows = [ const rows = [

Просмотреть файл

@ -1,7 +1,7 @@
{ {
"compilerOptions": { "compilerOptions": {
"target": "ES2017", "target": "ES2017",
"module": "CommonJS", "module": "NodeNext",
"esModuleInterop": true, "esModuleInterop": true,
"strict": true, "strict": true,
"incremental": true, "incremental": true,
@ -11,7 +11,6 @@
"declaration": true, "declaration": true,
"declarationMap": true, "declarationMap": true,
"noUnusedParameters": true, "noUnusedParameters": true,
"moduleResolution": "node",
"inlineSources": true "inlineSources": true
}, },
"include": [ "include": [

Просмотреть файл

@ -16,7 +16,11 @@ let config = {
}, },
resolve: { resolve: {
aliasFields: ["browser"], aliasFields: ["browser"],
fallback: { stream: require.resolve("stream-browserify") }, // Over fallbacks are in the package.json file fallback: {
stream: require.resolve("stream-browserify"),
// ESM has issue importing process/browser without this resolve
"process/browser": require.resolve("process/browser"),
}, // Over fallbacks are in the package.json file
extensions: [".ts", ".js"], extensions: [".ts", ".js"],
}, },
devtool: "inline-source-map", devtool: "inline-source-map",
@ -27,9 +31,6 @@ let config = {
port: 3000, // This port should be open in the SPA aad app port: 3000, // This port should be open in the SPA aad app
}, },
plugins: [ plugins: [
new webpack.ProvidePlugin({
process: "process/browser",
}),
// Work around for Buffer is undefined: // Work around for Buffer is undefined:
// https://github.com/webpack/changelog-v5/issues/10 // https://github.com/webpack/changelog-v5/issues/10
new webpack.ProvidePlugin({ new webpack.ProvidePlugin({