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

Typescript definitions for operations #224

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
39162aa
WIP on generating TS type declarations for operations
oleksandrpravosudko-okta Feb 10, 2021
863684d
add templates for type files and add template helper functions
oleksandrpravosudko-okta Feb 14, 2021
e9eaddd
move typings to src/types
oleksandrpravosudko-okta Feb 14, 2021
a119473
break down TypeScript signature formatter for genrated client
oleksandrpravosudko-okta Feb 15, 2021
e19e7a7
re-use signature getter for models and generated client
oleksandrpravosudko-okta Feb 15, 2021
57daae0
extract output formatting code into helper functions
oleksandrpravosudko-okta Feb 15, 2021
1d2950e
move ts formatters to helpers, differentiate import path and return P…
oleksandrpravosudko-okta Feb 16, 2021
2576578
restrict self import for models, add conversion from double
oleksandrpravosudko-okta Feb 16, 2021
d804c8c
correct newline syntax
oleksandrpravosudko-okta Feb 16, 2021
d526143
update copyright year
oleksandrpravosudko-okta Feb 16, 2021
c8e378f
add typings for Collection, Resource, Request
oleksandrpravosudko-okta Feb 16, 2021
70619d5
push latest generated-client
oleksandrpravosudko-okta Feb 16, 2021
34cfc19
add types index and remove unused templates
oleksandrpravosudko-okta Feb 16, 2021
cb3980a
unify export syntax
oleksandrpravosudko-okta Feb 16, 2021
db16983
restrict inappropirate property overrides
oleksandrpravosudko-okta Feb 17, 2021
c9d24df
reduce blocklisted models filtering duplication
oleksandrpravosudko-okta Feb 18, 2021
861f74a
add comment on model return type
oleksandrpravosudko-okta Feb 18, 2021
4403d0a
export model types
oleksandrpravosudko-okta Feb 18, 2021
d1d7d92
enable eslint on templates dir
oleksandrpravosudko-okta Feb 19, 2021
3a9bc47
CR: add a note on blocklisted properties
oleksandrpravosudko-okta Feb 19, 2021
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
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
test/jest/coverage/
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"README.md"
],
"main": "src/index.js",
"types": "src/types/index.d.ts",
"scripts": {
"banners": "./utils/maintain-banners.js",
"prebuild": "rimraf ./src/models ./src/factories ./src/generated-client.js",
Expand Down
38 changes: 38 additions & 0 deletions src/types/collection.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/*!
* 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 Request from './request';

declare class Collection {
constructor(client: any, uri: string, factory: any, request?: Request);
nextUri: string;
client: any;
factory: any;
currentItems: any[];
request: Request;
next(): Promise<any>;
[Symbol.asyncIterator](): {
next: () => Promise<any>;
};
getNextPage(): any;
each(iterator: Function): any;
subscribe(config: {
interval: number;
next: Function;
error: Function;
complete: Function;
}): {
unsubscribe(): void;
};
}

export default Collection;
515 changes: 515 additions & 0 deletions src/types/generated-client.d.ts

Large diffs are not rendered by default.

19 changes: 19 additions & 0 deletions src/types/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/*!
* 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 Client from './generated-client';
import * as Models from './models';

export {
Client,
Models,
}
17 changes: 17 additions & 0 deletions src/types/request.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/*!
* 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 interface Request {
api<T>(url: string): Promise<T>;
}

export default Request;
17 changes: 17 additions & 0 deletions src/types/resource.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/*!
* 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 Resource {
constructor(resourceJson: any, client: any);
}

export default Resource;
16 changes: 16 additions & 0 deletions templates/.eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"parserOptions": {
"ecmaVersion": 8
},
"rules": {
"no-use-before-define": ["error", {"functions": false, "variables": false}]
},
"env": {
"node": true,
"es6": true
},
"extends": [
"../src/.eslintrc",
"eslint:recommended"
]
}
21 changes: 21 additions & 0 deletions templates/generated-client.d.ts.hbs
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.
*/

{{{typeScriptClientImportBuilder operations}}}

declare class GeneratedApiClient {
{{#each operations}}
{{{typeScriptOperationSignatureBuilder this}}}
{{/each}}
}

export default GeneratedApiClient;
Loading