Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Browser react sample project #269

Merged
merged 16 commits into from
Aug 22, 2023
Merged
Show file tree
Hide file tree
Changes from 13 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,12 @@ module.exports = {
"node_modules",
"**/*.d.ts",
"**/*.js",
"webpack.config.ts"
"webpack.config.ts",
"vite.config.ts"
],
"parser": "@typescript-eslint/parser",
"parserOptions": {
"project": ["tsconfig.json","packages/azure-kusto-data/tsconfig.json","packages/azure-kusto-ingest/tsconfig.json","packages/quick_start/tsconfig.json"],
"project": ["tsconfig.json","packages/azure-kusto-data/tsconfig.json","packages/azure-kusto-ingest/tsconfig.json","packages/quick_start/tsconfig.json","packages/quick_start-browser/tsconfig.json"],
"sourceType": "module"
},
"plugins": [
Expand Down
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -327,8 +327,9 @@ __main.js
*.d.ts.map
*.d.ts

# We still want example.js files
# We still want example files
!example.js
!config-overrides.js

**/.nyc_output
**/coverage
Expand Down
3 changes: 2 additions & 1 deletion lerna.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{
"version": "5.2.0"
"version": "5.2.0",
"useWorkspaces": true
}
18,100 changes: 8,217 additions & 9,883 deletions package-lock.json

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
"jsonwebtoken": "^9.0.0"
},
"workspaces": [
"packages/*"
"packages/azure-kusto-data",
"packages/azure-kusto-ingest"
]
}
1 change: 0 additions & 1 deletion packages/azure-kusto-data/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@
"@azure/msal-common": "^7.3.0",
"@types/uuid": "^8.3.4",
"axios": "^0.27.2",
"crypto-browserify": "^3.12.0",
"follow-redirects": "^1.15.1",
"https-browserify": "^1.0.0",
"stream-http": "^3.2.0",
Expand Down
4 changes: 4 additions & 0 deletions packages/azure-kusto-data/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import CloudSettings from "./cloudSettings";
import KustoConnectionStringBuilder from "./connectionBuilder";
import * as KustoDataErrors from "./errors";
import { kustoTrustedEndpoints, MatchRule } from "./kustoTrustedEndpoints";
import { KustoResultColumn, KustoResultRow, KustoResultTable } from "./models";
import { KustoResponseDataSet } from "./response";
import { toMilliseconds } from "./timeUtils";

Expand All @@ -19,6 +20,9 @@ export {
KustoConnectionStringBuilder,
KustoDataErrors,
KustoResponseDataSet,
KustoResultColumn,
KustoResultRow,
KustoResultTable,
kustoTrustedEndpoints,
MatchRule,
TimeUtils,
Expand Down
2 changes: 2 additions & 0 deletions packages/azure-kusto-ingest/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import {
ValidationImplications,
ValidationOptions,
ValidationPolicy,
dataFormatMappingKind,
} from "./ingestionProperties";

import {
Expand Down Expand Up @@ -76,6 +77,7 @@ export {
ValidationOptions,
ValidationPolicy,
W3CLogFileMapping,
dataFormatMappingKind,
};

/**
Expand Down
37 changes: 37 additions & 0 deletions packages/quick_start-browser/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# Quickstart App

The quickstart application is a **self-contained and runnable** example app that demonstrates authenticating, connecting to, administering, ingesting data
into and querying Azure Data Explorer using the Azure Kusto JS SDK.
You can use it as a baseline to write your own first kusto client application, altering the code as you go, or copy code sections out of it into your app.

**Tip:** The app includes comments with tips on recommendations, coding best practices, links to reference materials and recommended TODO changes when adapting the code to your needs.

## Using the App for the first time

### Prerequisites

1. Set up NodeJS version 14+ and npm on your machine. For instructions, consult a setup tutorial, like [this](https://docs.microsoft.com/en-us/windows/dev-environment/javascript/nodejs-on-windows)

### Retrieving the app from GitHub

1. Download the app files from this GitHub repository.
2. You may modify the `kusto_sample_config.json` file, changing `kustoUri`, `ingestUri` and `databaseName` appropriately for your cluster.

### Retrieving the app from OneClick

Not yet available.

### Run the app

1. Open a command line window and navigate to the folder where you extracted the app.
2. Either use an IDE of your choice to build and run the project, or execute the following using the command line window:
1. Run `npm install` in the sample folder
2. Run `npm run dev`

#### Troubleshooting

- If you are having trouble running the app from your IDE, first check if the app runs from the command line, then consult the troubleshooting references of your IDE.

#### Authenticaiton
This example uses @azure/identity InteractiveBrowserCredential, the authentication app id used in this method is taken from the App id field, the app should be granted admin consent to Azure Data Explorer and allow the redirectUri of the url of the runing site. See steps [here](https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/identity/identity/test/manual/interactive-browser-credential)
A production app should better authenticate users itself and use the "withTokenProvide" builder method of the Kusto client connectionStringBuilder.
13 changes: 13 additions & 0 deletions packages/quick_start-browser/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<link rel="icon" type="image/png" href="/download.png" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Kusto Browser React Sample</title>
</head>
<body>
<div id="root"></div>
<script type="module" src="/src/main.tsx"></script>
</body>
</html>
Loading
Loading