-
Notifications
You must be signed in to change notification settings - Fork 61
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add templates and helpers for types generation
add generated models and factories types (#225) * WIP on generating TS type declarations for operations * add templates for type files and add template helper functions * move typings to src/types * re-use signature getter for models and generated client * add types index and remove unused templates * unify export syntax * reduce blocklisted models filtering duplication * export model types * add factories templates and push generated model types * switch to named model exports * actually run eslint on templates dir * set proper return type for Collection and mark optional arguments * mark read-only properties * do default export models along with named export * expose Client type and add missing types * add re-generated models and remove manually-generated types * restore array type value and read-only modifier * bring models named export back * generate factories types * export GeneratedClient * to be switched to Client in the downnstream branch * specify correct types for Model constructor arguments * import Client for all models * remove default exports from models * remove models and factories index template * add extra newline for generated models, remove indents from type map, do not re-export model types * move eslint target for templates to downstream branch * add missing 'autogenerated' warning banner to templates * remove extra whitespaces, regenerate files * parametrize Collection return type in generated files * include generic type into imports list and re-generate types * preserve non-optinal query parameters * correct return type to be Response instead of undefined, include CRUD return type into imports * CR: remove copyright banners from templates Add type definitions for core objects, add typescript-eslint-plugin + tsd (re-opened) (#230) * WIP on generating TS type declarations for operations * WIP on adding types for core objects * update type references in core objects * WIP on adding types for core objects * update type references in core objects * run typescript-eslint on src/types * WIP on fixing ts-lint errors * represent object type as Record<string, unknown> * define RequestOptions type * define more specific type for core objects * add basic tsd test * install @types/node-fetch types * specify sourceType: module for types eslint config * add more tsd assertions * complete basic coverage for core object types assertions * include tsd run into test target * export types matching code exports * fix syntactic error in command * fix indents and apply basic eslint rules to definitions files * parametrize Collection type definition * list known config properties, update jwt function return type * widen type for cache middleware next function * replace MemoryStore references with CacheStorage * extract IRequestExecutor interface, make MemoryStore parameters optional * allow request executors w/o event emission * correct types for collection subscribers * CR: cascade eslint configuration * fix revealed eslint errors * move type tests to a separate directory * CR: break down type tests * add type assertions for generated client methods * use named import for Response * allow imports for create and delete operations only * remove unused import * fix rebase artifact remove irrelevant changes update changelog entry for 4.5.0 OKTA-373751 <<<Jenkins Check-In of Tested SHA: 1013098 for [email protected]>>> Artifact: okta-sdk-nodejs
- Loading branch information
1 parent
dc5283c
commit 6714bc4
Showing
385 changed files
with
13,462 additions
and
270 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
test/jest/coverage/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
{ | ||
"parser": "@typescript-eslint/parser", | ||
"parserOptions": { | ||
"sourceType": "module" | ||
}, | ||
"rules": { | ||
"new-cap": [ | ||
2, | ||
{ | ||
"capIsNew": false, | ||
"properties": false | ||
} | ||
] | ||
}, | ||
"plugins": [ | ||
"@typescript-eslint" | ||
], | ||
"extends": [ | ||
"plugin:@typescript-eslint/recommended" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
|
||
/*! | ||
* Copyright (c) 2017-2021, Okta, Inc. and/or its affiliates. All rights reserved. | ||
* The Okta software accompanied by this notice is provided pursuant to the Apache License, Version 2.0 (the "License.") | ||
* | ||
* You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0. | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | ||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* | ||
* See the License for the specific language governing permissions and limitations under the License. | ||
*/ | ||
import { Headers } from 'node-fetch'; | ||
|
||
declare class OktaApiError extends Error { | ||
constructor(url: string, status: number, responseBody: Record<string, unknown>, headers: Headers); | ||
name: string; | ||
status: number; | ||
errorCode: string | number; | ||
errorSummary: string; | ||
errorCauses: string; | ||
errorLink: string; | ||
errorId: string; | ||
url: string; | ||
headers: Headers; | ||
stack: string; | ||
message: string; | ||
} | ||
|
||
export default OktaApiError; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
/*! | ||
* Copyright (c) 2017-2021, Okta, Inc. and/or its affiliates. All rights reserved. | ||
* The Okta software accompanied by this notice is provided pursuant to the Apache License, Version 2.0 (the "License.") | ||
* | ||
* You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0. | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | ||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* | ||
* See the License for the specific language governing permissions and limitations under the License. | ||
*/ | ||
|
||
import GeneratedApiClient from './generated-client'; | ||
import Oauth from './oauth'; | ||
import Http from './http'; | ||
import { IRequestExecutor } from './request-executor'; | ||
import defaultCacheMiddleware from './default-cache-middleware'; | ||
import { CacheStorage } from './memory-store'; | ||
|
||
interface ConfigProperties { | ||
orgUrl?: string, | ||
token?: string, | ||
clientId?: string, | ||
scopes?: string[], | ||
requestExecutor?: IRequestExecutor, | ||
authorizationMode?: string, | ||
privateKey?: string | Record<string, unknown> | ||
cacheStore?: CacheStorage, | ||
cacheMiddleware?: typeof defaultCacheMiddleware | unknown | ||
} | ||
|
||
declare class Client extends GeneratedApiClient { | ||
constructor(config?: ConfigProperties); | ||
|
||
requestExecutor: IRequestExecutor; | ||
authorizationMode: string; | ||
baseUrl: string; | ||
apiToken: string; | ||
clientId: string; | ||
scopes: string[]; | ||
privateKey: string; | ||
oauth: Oauth; | ||
http: Http; | ||
} | ||
|
||
export default Client; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
/*! | ||
* Copyright (c) 2017-2021, Okta, Inc. and/or its affiliates. All rights reserved. | ||
* The Okta software accompanied by this notice is provided pursuant to the Apache License, Version 2.0 (the "License.") | ||
* | ||
* You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0. | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | ||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* | ||
* See the License for the specific language governing permissions and limitations under the License. | ||
*/ | ||
|
||
import RequestOptions from './request-options'; | ||
import ModelFactory from './model-factory'; | ||
import ModelResolutionFactory from './resolution-factory'; | ||
import Client from './client'; | ||
|
||
declare class Collection<T> { | ||
constructor(client: Client, uri: string, factory: ModelFactory | ModelResolutionFactory, request?: RequestOptions); | ||
|
||
nextUri: string; | ||
client: Client; | ||
factory: ModelFactory | ModelResolutionFactory; | ||
currentItems: Record<string, unknown>[]; | ||
request: RequestOptions; | ||
next(): Promise<{ | ||
done: boolean, | ||
value: T | null | ||
}>; | ||
[Symbol.asyncIterator](): { | ||
next: () => Promise<{ | ||
done: boolean, | ||
value: T | null | ||
}>; | ||
}; | ||
getNextPage(): Promise<Record<string, unknown>>; | ||
each(iterator: (item: T) => Promise<unknown> | boolean | unknown): Promise<unknown>; | ||
subscribe(config: { | ||
interval: number; | ||
next: (item: T) => unknown | Promise<unknown>; | ||
error: (e: Error) => unknown | Promise<unknown>; | ||
complete: () => void; | ||
}): { | ||
unsubscribe(): void; | ||
}; | ||
} | ||
|
||
export default Collection; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
/*! | ||
* Copyright (c) 2017-2021, Okta, Inc. and/or its affiliates. All rights reserved. | ||
* The Okta software accompanied by this notice is provided pursuant to the Apache License, Version 2.0 (the "License.") | ||
* | ||
* You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0. | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | ||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* | ||
* See the License for the specific language governing permissions and limitations under the License. | ||
*/ | ||
|
||
declare class ConfigLoader { | ||
prefix: string; | ||
config: { | ||
client: { | ||
authorizationMode: string; | ||
orgUrl: string; | ||
token: string; | ||
clientId: string; | ||
scopes: string; | ||
privateKey: string; | ||
}; | ||
}; | ||
applyDefaults(): void; | ||
applyEnvVars(): void; | ||
applyYamlFile(path: string): void; | ||
apply(config: Record<string, unknown>): void; | ||
} | ||
|
||
export default ConfigLoader; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
/*! | ||
* Copyright (c) 2017-2021, Okta, Inc. and/or its affiliates. All rights reserved. | ||
* The Okta software accompanied by this notice is provided pursuant to the Apache License, Version 2.0 (the "License.") | ||
* | ||
* You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0. | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | ||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* | ||
* See the License for the specific language governing permissions and limitations under the License. | ||
*/ | ||
|
||
import { Response } from 'node-fetch'; | ||
import { CacheStorage } from './memory-store'; | ||
import RequestOptions from './request-options'; | ||
|
||
declare function defaultCacheMiddleware(ctx: { | ||
isCollection?: boolean, | ||
resources?: string[], | ||
res?: Response, | ||
req: RequestOptions, | ||
cacheStore: CacheStorage, | ||
}, next: () => unknown): Promise<Response>; | ||
|
||
export default defaultCacheMiddleware; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
/*! | ||
* Copyright (c) 2017-2021, Okta, Inc. and/or its affiliates. All rights reserved. | ||
* The Okta software accompanied by this notice is provided pursuant to the Apache License, Version 2.0 (the "License.") | ||
* | ||
* You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0. | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | ||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* | ||
* See the License for the specific language governing permissions and limitations under the License. | ||
*/ | ||
|
||
import { Response } from 'node-fetch'; | ||
import RequestExecutor from './request-executor'; | ||
import RequestOptions from './request-options'; | ||
|
||
|
||
declare class DefaultRequestExecutor extends RequestExecutor { | ||
constructor(config?: { | ||
maxRetries: number, | ||
requestTimeout: number, | ||
}); | ||
|
||
requestTimeout: number; | ||
maxRetries: number; | ||
retryCountHeader: string; | ||
retryForHeader: string; | ||
buildRetryRequest(request: RequestOptions, requestId: string, delayMs: number): RequestOptions; | ||
validateRetryResponseHeaders(response: Response): boolean; | ||
getOktaRequestId(response: Response): string; | ||
getRateLimitReset(response: Response): string; | ||
getResponseDate(response: Response): string; | ||
getRetryDelayMs(response: Response): number; | ||
parseResponse(request: RequestOptions, response: Response): Response | Promise<Response | Error>; | ||
maxRetriesReached(request: RequestOptions): boolean; | ||
retryRequest(request: RequestOptions, response: Response, delayMs: number): Promise<Response>; | ||
} | ||
|
||
export default DefaultRequestExecutor; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
/*! | ||
* Copyright (c) 2017-2021, Okta, Inc. and/or its affiliates. All rights reserved. | ||
* The Okta software accompanied by this notice is provided pursuant to the Apache License, Version 2.0 (the "License.") | ||
* | ||
* You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0. | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | ||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* | ||
* See the License for the specific language governing permissions and limitations under the License. | ||
*/ | ||
|
||
|
||
/* THIS FILE IS AUTO-GENERATED - SEE CONTRIBUTOR DOCUMENTATION */ | ||
|
||
import ModelResolutionFactory from '../resolution-factory'; | ||
|
||
declare class ApplicationFactory extends ModelResolutionFactory { | ||
} | ||
|
||
export default ApplicationFactory; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
/*! | ||
* Copyright (c) 2017-2021, Okta, Inc. and/or its affiliates. All rights reserved. | ||
* The Okta software accompanied by this notice is provided pursuant to the Apache License, Version 2.0 (the "License.") | ||
* | ||
* You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0. | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | ||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* | ||
* See the License for the specific language governing permissions and limitations under the License. | ||
*/ | ||
|
||
|
||
/* THIS FILE IS AUTO-GENERATED - SEE CONTRIBUTOR DOCUMENTATION */ | ||
|
||
import ModelResolutionFactory from '../resolution-factory'; | ||
|
||
declare class BrowserPluginApplicationFactory extends ModelResolutionFactory { | ||
} | ||
|
||
export default BrowserPluginApplicationFactory; |
Oops, something went wrong.