Skip to content

Commit ea2606b

Browse files
Update Readme
Fix NPM run commands, those are deprecated, use run-script instead. Add advanced usage examples for scopes and endpoints. Fixed SDK naming. Bump Version
1 parent 5925306 commit ea2606b

File tree

7 files changed

+74
-16
lines changed

7 files changed

+74
-16
lines changed

.vscode/settings.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
"Entra",
44
"Lockdown",
55
"openapi",
6+
"readwrite",
67
"SSPR"
78
],
89
"github.copilot.editor.enableAutoCompletions": false

src/dataGateway/TypeScript/README.md

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,33 @@ for (const correlationRecord of results) {
3535
}
3636
```
3737

38+
### Advanced Usage
39+
40+
You can optionally configure the SDK client with a custom base URL, including support for it being nested deep in a L7 load balancer:
41+
42+
```TypeScript
43+
/** Custom host and endpoint base to as an example for something behind a layer 7 load balancer, E.g. Azure App Gateway or Azure API Gateway. If in debug mode, run against localhost. */
44+
const customBaseUrl = debugMode ? new URL('http://localhost:3002') : new URL('https://custom-host.example.com/Ballance/Instance1/');
45+
46+
/** Configured instance of the Data Gateway client. */
47+
const customConfiguredClient = dataGatewayClientFactory(credential, customBaseUrl);
48+
```
49+
50+
and/or scope (permission) list:
51+
52+
```TypeScript
53+
/**
54+
* This parameter defaults to ['4c40281b-a305-4aaf-90a4-d5bbee6eb8ed/.default'].
55+
* `.default` and explicit permissions can't exist in the same custom scope list at the same time, Entra ID doesn't support this.
56+
*
57+
* If not providing the `.default` scope, you can have any number of scopes (permissions) listed.
58+
*/
59+
const customScopes = ['your-custom-scope/something.read.all', 'your-custom-scope/everything.readwrite.all'];
60+
61+
// Initialize the SDK client with custom configuration.
62+
const customConfiguredClient = dataGatewayClientFactory(credential, void 0, customScopes);
63+
```
64+
3865
## Project Structure
3966

4067
- `bin/`: Compiled JavaScript files and type definitions.
@@ -54,15 +81,15 @@ for (const correlationRecord of results) {
5481
To regenerate the SDK from the OpenAPI specification, run:
5582

5683
```bash
57-
npm run generate:Sdk
84+
npm run-script generate:Sdk
5885
```
5986

6087
### Building the SDK
6188

6289
To build the SDK for production, run:
6390

6491
```bash
65-
npm run build:Prod
92+
npm run-script build:Prod
6693
```
6794

6895
## License

src/dataGateway/TypeScript/package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/dataGateway/TypeScript/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@shi-corp/sdk-data-gateway",
3-
"version": "1.0.4",
3+
"version": "1.0.4.1",
44
"type": "module",
55
"main": "bin/index.js",
66
"description": "SDK client used to interface with the SHI Data Gateway service.",

src/shield/TypeScript/README.md

Lines changed: 38 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# SHI Data Gateway - TypeScript SDK
1+
# SHIELD - TypeScript SDK
22

33
This SDK provides a convenient TypeScript client for interacting with the SHI SHIELD service. It is automatically generated from the OpenAPI specification located at [`SHIELD.json`](../../../specs/SHIELD.json) using [Kiota](https://github.com/microsoft/kiota).
44

@@ -20,14 +20,18 @@ Here's a basic example of how to use the SDK:
2020
import { DefaultAzureCredential } from '@azure/identity'
2121
import { shieldClientFactory } from '@shi-corp/sdk-shield';
2222

23-
/** Authentication session used to authenticate to the SHI Data Gateway. */
23+
/** Authentication session used to authenticate to SHIELD. */
2424
const credential = new DefaultAzureCredential();
2525

26-
/** Base URL for your SHIELD instance. No protocol specifier or trailing slash! */
27-
const baseUrl = 'shield.example.com';
26+
/** Base URL for your SHIELD instance. Protocol specifier (`http`/`https`) is required, even for localhost. */
27+
const baseUrl = new URL('https://shield.example.com');
2828

29-
/** Configured client for the data gateway that can make authenticated web requests against SDG. */
30-
const shieldClient = shieldClientFactory(credential, baseUrl);
29+
/**
30+
* Configured client for SHIELD that can make authenticated web requests against SDG.
31+
*
32+
* The third param, the scope is the `Application ID` of the `SHIELD - End User Login` app registration. This can also be found on SHIELD's `/Api/Auth/Id` endpoint.
33+
*/
34+
const shieldClient = shieldClientFactory(credential, baseUrl, ['b9689d4e-0036-4f2f-8430-07adedb9ae7c/.default']);
3135

3236
/** Flag that indicates if discover is currently running (`true`) or not (`false`). */
3337
const results = await shieldClient.api.discover.status.get();
@@ -38,6 +42,32 @@ if (results?.running === true) {
3842
}
3943
```
4044

45+
### Advanced Usage
46+
47+
You can optionally configure the SDK client with a custom base URL, including support for it being nested deep in a L7 load balancer:
48+
49+
```TypeScript
50+
/** Custom host and endpoint base to as an example for something behind a layer 7 load balancer, E.g. Azure App Gateway or Azure API Gateway. If in debug mode, run against localhost. */
51+
const customBaseUrl = debugMode ? new URL('http://localhost:3000') : new URL('https://custom-host.example.com/Ballance/Instance1/');
52+
53+
/** Configured instance of the SHIELD client. */
54+
const customConfiguredClient = shieldClientFactory(credential, customBaseUrl);
55+
```
56+
57+
and/or scope (permission) list:
58+
59+
```TypeScript
60+
/**
61+
* `.default` and explicit permissions can't exist in the same custom scope list at the same time, Entra ID doesn't support this.
62+
*
63+
* If not providing the `.default` scope, you can have any number of scopes (permissions) listed in different array indexes.
64+
*/
65+
const customScopes = ['your-custom-scope/something.read.all', 'your-custom-scope/everything.readwrite.all'];
66+
67+
// Initialize the SDK client with custom configuration.
68+
const customConfiguredClient = shieldClientFactory(credential, void 0, customScopes);
69+
```
70+
4171
## Project Structure
4272

4373
- `bin/`: Compiled JavaScript files and type definitions.
@@ -57,15 +87,15 @@ if (results?.running === true) {
5787
To regenerate the SDK from the OpenAPI specification, run:
5888

5989
```bash
60-
npm run generate:Sdk
90+
npm run-script generate:Sdk
6191
```
6292

6393
### Building the SDK
6494

6595
To build the SDK for production, run:
6696

6797
```bash
68-
npm run build:Prod
98+
npm run-script build:Prod
6999
```
70100

71101
## License

src/shield/TypeScript/package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/shield/TypeScript/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@shi-corp/sdk-shield",
3-
"version": "1.0.4",
3+
"version": "1.0.4.1",
44
"type": "module",
55
"main": "bin/index.js",
66
"description": "SDK client used to interface with the SHIELD application.",

0 commit comments

Comments
 (0)