Skip to content

Commit

Permalink
ENG-0000 - Refresh
Browse files Browse the repository at this point in the history
- Updated typescript to 4.7.x
- Updated other packages to corresponding latest version
- AlApiClient renamed to AlXHRAdapter for accuracy
- AlDefaultClient renamed to AlRootClient (again, for accuracy)
- Added @ServiceClient decorator and AlBaseServiceClient, allowing JIT
  service instantiation and better tree shaking
- Updated AIMSClient and SubscriptionsClient to use new client model
- Retired some obsolete content

Client Architecture:

Previously, our API Client architecture has consisted of declaring the
client class and then immediately instantiating it as a global variable.
In practice, this means that clients a) cannot be tree shaken or bundled
outside of the main bundle, and b) every client must by compiled and
instantiated before application bootstrap.  This is dumb.

The new model uses a decorator to identify classes that represent a
client.  The decorator stores the class's constructor and some default
settings for it into a dictionary, which can be used to instantiate the
client on-demand.

For example:

```
@ServiceClient( {
    service_name: "gestalt",
    service_stack: AlLocation.GestaltAPI,
    version: 1
} )
export class AlsGestalt extends AlBaseServiceClient {
    ...
}
```

Or

```
@ServiceClient( {
    service_name: "iris",
    version: 'v3',
    residencyAware: true
} )
export class AlsIris extends AlBaseServiceClient {
    ...
}
```

These classes do not need to be instantiated until they are actually
needed. Additional, the properties provided to the ServiceClient
decorator as used as defaults, and the AlBaseServiceClient provides
convenience `get`, `put`, `post`, `delete`, and `request` methods to
facilitate extremely minimal implementations.

Nomenclature:

Client classes should begin with an "Als" prefix, and be stored with a
.service-client.ts extension.
  • Loading branch information
mcnielsen committed Aug 25, 2022
1 parent 8d52f1d commit 5d721b8
Show file tree
Hide file tree
Showing 48 changed files with 1,948 additions and 2,029 deletions.
1,278 changes: 799 additions & 479 deletions package-lock.json

Large diffs are not rendered by default.

17 changes: 9 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@al/core",
"version": "1.0.190",
"version": "2.0.0",
"description": "Node Enterprise Packages for Alert Logic (NEPAL) Core Library",
"main": "./dist/index.cjs.js",
"types": "./dist/index.d.ts",
Expand Down Expand Up @@ -41,28 +41,29 @@
"devDependencies": {
"@types/auth0-js": "^9.14.5",
"@types/chai": "^4.2.21",
"@types/karma": "^5.0.0",
"@types/karma": "^6.3.3",
"@types/mocha": "^7.0.2",
"@types/qs": "^6.9.7",
"@types/sinon": "^9.0.0",
"chai": "^4.2.0",
"copy-webpack-plugin": "^5.0.5",
"karma": "^6.3.4",
"karma-chrome-launcher": "^3.1.0",
"karma": "^6.4.0",
"karma-chrome-launcher": "^3.1.1",
"karma-cli": "^2.0.0",
"karma-mocha": "^1.3.0",
"karma-typescript": "^5.0.2",
"karma-mocha": "^2.0.1",
"karma-typescript": "^5.5.3",
"mocha": "~7.0.1",
"peer-deps-externals-webpack-plugin": "^1.0.4",
"rollup": "^2.56.2",
"rollup-plugin-copy": "^3.3.0",
"rollup-plugin-terser": "^5.3.0",
"rollup-plugin-typescript2": "^0.27.0",
"rollup-plugin-typescript2": "^0.32.1",
"sinon": "^9.0.2",
"ts-loader": "^6.2.2",
"tslib": "^2.4.0",
"tslint": "^5.12.1",
"tslint-config-airbnb": "^5.11.1",
"typescript": "^3.9.10",
"typescript": "^4.7.4",
"webpack": "^4.41.2",
"webpack-bundle-analyzer": "^3.6.0",
"webpack-cli": "^3.2.1",
Expand Down
Loading

0 comments on commit 5d721b8

Please sign in to comment.