From 2022b75948ab737d57c53c838c5063ec8d6000b7 Mon Sep 17 00:00:00 2001 From: Jon Koops Date: Wed, 26 Jan 2022 12:21:27 +0100 Subject: [PATCH] Distribute code with ES module syntax --- .mocharc.json | 5 ++ package-lock.json | 62 ++++++++++--------- package.json | 20 +++--- src/client.ts | 40 ++++++------ src/defs/adminEventRepresentation.ts | 2 +- src/defs/authenticationFlowRepresentation.ts | 3 +- src/defs/clientPoliciesRepresentation.ts | 2 +- src/defs/clientPolicyRepresentation.ts | 2 +- src/defs/clientProfileRepresentation.ts | 2 +- src/defs/clientProfilesRepresentation.ts | 2 +- src/defs/clientRepresentation.ts | 4 +- src/defs/clientScopeRepresentation.ts | 2 +- src/defs/componentTypeRepresentation.ts | 2 +- src/defs/eventRepresentation.ts | 2 +- ...dentityProviderMapperTypeRepresentation.ts | 2 +- src/defs/mappingsRepresentation.ts | 2 +- src/defs/realmRepresentation.ts | 20 +++--- src/defs/resourceEvaluation.ts | 2 +- src/defs/resourceRepresentation.ts | 4 +- src/defs/resourceServerRepresentation.ts | 6 +- src/defs/rolesRepresentation.ts | 2 +- src/defs/scopeRepresentation.ts | 4 +- src/defs/serverInfoRepesentation.ts | 12 ++-- src/defs/userRepresentation.ts | 8 +-- src/index.ts | 4 +- src/resources/agent.ts | 4 +- src/resources/attackDetection.ts | 4 +- src/resources/authenticationManagement.ts | 19 +++--- src/resources/cache.ts | 4 +- src/resources/clientPolicies.ts | 9 ++- src/resources/clientScopes.ts | 12 ++-- src/resources/clients.ts | 38 ++++++------ src/resources/components.ts | 8 +-- src/resources/groups.ts | 17 +++-- src/resources/identityProviders.ts | 10 +-- src/resources/realms.ts | 31 +++++----- src/resources/resource.ts | 4 +- src/resources/roles.ts | 8 +-- src/resources/serverInfo.ts | 6 +- src/resources/sessions.ts | 4 +- src/resources/userStorageProvider.ts | 6 +- src/resources/users.ts | 27 ++++---- src/resources/whoAmI.ts | 6 +- src/utils/auth.ts | 2 +- test/attackDetection.spec.ts | 6 +- test/clients.spec.ts | 15 ++--- test/constants.ts | 2 +- test/groupUser.spec.ts | 13 ++-- test/users.spec.ts | 2 +- tsconfig.json | 15 +++-- tsconfig.release.json | 9 --- tsconfig.test.json | 7 +++ 52 files changed, 253 insertions(+), 251 deletions(-) create mode 100644 .mocharc.json delete mode 100644 tsconfig.release.json create mode 100644 tsconfig.test.json diff --git a/.mocharc.json b/.mocharc.json new file mode 100644 index 00000000..4e7c141a --- /dev/null +++ b/.mocharc.json @@ -0,0 +1,5 @@ +{ + "node-option": [ + "loader=ts-node/esm" + ] +} diff --git a/package-lock.json b/package-lock.json index dee7cd65..3eb7c4ad 100644 --- a/package-lock.json +++ b/package-lock.json @@ -12,7 +12,6 @@ "axios": "^0.26.1", "camelize-ts": "^1.0.8", "keycloak-js": "^17.0.1", - "lodash": "^4.17.21", "query-string": "^7.0.1", "url-join": "^4.0.0", "url-template": "^2.0.8" @@ -20,19 +19,23 @@ "devDependencies": { "@faker-js/faker": "^6.0.0", "@types/chai": "^4.2.14", - "@types/lodash": "^4.14.165", + "@types/lodash-es": "^4.17.5", "@types/mocha": "^9.0.0", "@types/node": "^17.0.1", "@types/url-join": "^4.0.0", "@types/url-template": "^2.0.28", "chai": "^4.1.2", + "lodash-es": "^4.17.21", "mocha": "^9.1.0", "nyc": "^15.1.0", "prettier": "^2.1.2", "rimraf": "^3.0.2", "ts-node": "^10.2.1", "tslint": "^6.1.3", - "typescript": "^4.0.5" + "typescript": "^4.6.0-dev.20220127" + }, + "engines": { + "node": "^12.20.0 || ^14.13.1 || >=16.0.0" } }, "node_modules/@ampproject/remapping": { @@ -603,6 +606,15 @@ "integrity": "sha512-XOKXa1KIxtNXgASAnwj7cnttJxS4fksBRywK/9LzRV5YxrF80BXZIGeQSuoESQ/VkUj30Ae0+YcuHc15wJCB2g==", "dev": true }, + "node_modules/@types/lodash-es": { + "version": "4.17.6", + "resolved": "https://registry.npmjs.org/@types/lodash-es/-/lodash-es-4.17.6.tgz", + "integrity": "sha512-R+zTeVUKDdfoRxpAryaQNRKk3105Rrgx2CFRClIgRGaqDTdjsm8h6IYA8ir584W3ePzkZfst5xIgDwYrlh9HLg==", + "dev": true, + "dependencies": { + "@types/lodash": "*" + } + }, "node_modules/@types/mocha": { "version": "9.1.0", "resolved": "https://registry.npmjs.org/@types/mocha/-/mocha-9.1.0.tgz", @@ -1317,20 +1329,6 @@ "integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=", "dev": true }, - "node_modules/fsevents": { - "version": "2.3.2", - "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.2.tgz", - "integrity": "sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA==", - "dev": true, - "hasInstallScript": true, - "optional": true, - "os": [ - "darwin" - ], - "engines": { - "node": "^8.16.0 || ^10.6.0 || >=11.0.0" - } - }, "node_modules/function-bind": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.1.tgz", @@ -1831,10 +1829,11 @@ "url": "https://github.com/sponsors/sindresorhus" } }, - "node_modules/lodash": { + "node_modules/lodash-es": { "version": "4.17.21", - "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz", - "integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==" + "resolved": "https://registry.npmjs.org/lodash-es/-/lodash-es-4.17.21.tgz", + "integrity": "sha512-mKnC+QJ9pWVzv+C4/U3rRsHapFfHvQFoFB92e52xeyGMcX6/OlIl78je1u8vePzYZSkkogMPJ2yjxxsb89cxyw==", + "dev": true }, "node_modules/lodash.flattendeep": { "version": "4.4.0", @@ -3617,6 +3616,15 @@ "integrity": "sha512-XOKXa1KIxtNXgASAnwj7cnttJxS4fksBRywK/9LzRV5YxrF80BXZIGeQSuoESQ/VkUj30Ae0+YcuHc15wJCB2g==", "dev": true }, + "@types/lodash-es": { + "version": "4.17.6", + "resolved": "https://registry.npmjs.org/@types/lodash-es/-/lodash-es-4.17.6.tgz", + "integrity": "sha512-R+zTeVUKDdfoRxpAryaQNRKk3105Rrgx2CFRClIgRGaqDTdjsm8h6IYA8ir584W3ePzkZfst5xIgDwYrlh9HLg==", + "dev": true, + "requires": { + "@types/lodash": "*" + } + }, "@types/mocha": { "version": "9.1.0", "resolved": "https://registry.npmjs.org/@types/mocha/-/mocha-9.1.0.tgz", @@ -4121,13 +4129,6 @@ "integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=", "dev": true }, - "fsevents": { - "version": "2.3.2", - "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.2.tgz", - "integrity": "sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA==", - "dev": true, - "optional": true - }, "function-bind": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.1.tgz", @@ -4499,10 +4500,11 @@ "p-locate": "^5.0.0" } }, - "lodash": { + "lodash-es": { "version": "4.17.21", - "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz", - "integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==" + "resolved": "https://registry.npmjs.org/lodash-es/-/lodash-es-4.17.21.tgz", + "integrity": "sha512-mKnC+QJ9pWVzv+C4/U3rRsHapFfHvQFoFB92e52xeyGMcX6/OlIl78je1u8vePzYZSkkogMPJ2yjxxsb89cxyw==", + "dev": true }, "lodash.flattendeep": { "version": "4.4.0", diff --git a/package.json b/package.json index 8d08af22..26eeba3f 100644 --- a/package.json +++ b/package.json @@ -2,18 +2,22 @@ "name": "@keycloak/keycloak-admin-client", "version": "18.0.0-dev.6", "description": "keycloak admin client", + "type": "module", "main": "lib/index.js", "files": [ "lib" ], "types": "lib/index.d.ts", + "engines": { + "node": "^12.20.0 || ^14.13.1 || >=16.0.0" + }, "scripts": { "clean": "rimraf lib", "lint": "tslint --force --format verbose \"src/**/*.ts\" \"test/*\"", - "build": "npm run clean && tsc -p ./tsconfig.release.json --pretty", - "test": "mocha --require ts-node/register --recursive \"test/**/*.spec.ts\"", - "test:subset": "mocha --require ts-node/register --recursive --", - "test:grep": "mocha --require ts-node/register", + "build": "npm run clean && tsc --pretty", + "test": "TS_NODE_PROJECT=tsconfig.test.json mocha --recursive \"test/**/*.spec.ts\"", + "test:subset": "TS_NODE_PROJECT=tsconfig.test.json mocha --recursive --", + "test:grep": "TS_NODE_PROJECT=tsconfig.test.json mocha", "coverage": "nyc npm run test", "watch": "npm run build -- --watch", "watch:test": "npm run test -- --watch", @@ -23,7 +27,6 @@ "axios": "^0.26.1", "camelize-ts": "^1.0.8", "keycloak-js": "^17.0.1", - "lodash": "^4.17.21", "query-string": "^7.0.1", "url-join": "^4.0.0", "url-template": "^2.0.8" @@ -31,19 +34,20 @@ "devDependencies": { "@faker-js/faker": "^6.0.0", "@types/chai": "^4.2.14", - "@types/lodash": "^4.14.165", + "@types/lodash-es": "^4.17.5", "@types/mocha": "^9.0.0", "@types/node": "^17.0.1", "@types/url-join": "^4.0.0", "@types/url-template": "^2.0.28", "chai": "^4.1.2", + "lodash-es": "^4.17.21", "mocha": "^9.1.0", "nyc": "^15.1.0", "prettier": "^2.1.2", "rimraf": "^3.0.2", "ts-node": "^10.2.1", "tslint": "^6.1.3", - "typescript": "^4.0.5" + "typescript": "^4.6.0-dev.20220127" }, "author": "wwwy3y3", "license": "Apache-2.0", @@ -52,4 +56,4 @@ "url": "https://github.com/keycloak/keycloak-nodejs-admin-client.git" }, "homepage": "https://www.keycloak.org/" -} +} \ No newline at end of file diff --git a/src/client.ts b/src/client.ts index 4d4ed580..816945de 100644 --- a/src/client.ts +++ b/src/client.ts @@ -1,23 +1,23 @@ -import {getToken, Credentials} from './utils/auth'; -import {defaultBaseUrl, defaultRealm} from './utils/constants'; -import {Cache} from './resources/cache'; -import {Users} from './resources/users'; -import {Groups} from './resources/groups'; -import {Roles} from './resources/roles'; -import {Clients} from './resources/clients'; -import {Realms} from './resources/realms'; -import {ClientScopes} from './resources/clientScopes'; -import {ClientPolicies} from './resources/clientPolicies'; -import {IdentityProviders} from './resources/identityProviders'; -import {Components} from './resources/components'; -import {AuthenticationManagement} from './resources/authenticationManagement'; -import {ServerInfo} from './resources/serverInfo'; -import {WhoAmI} from './resources/whoAmI'; -import {AttackDetection} from './resources/attackDetection'; -import {AxiosRequestConfig} from 'axios'; - -import {Sessions} from './resources/sessions'; -import {UserStorageProvider} from './resources/userStorageProvider'; +import {getToken, Credentials} from './utils/auth.js'; +import {defaultBaseUrl, defaultRealm} from './utils/constants.js'; +import {Cache} from './resources/cache.js'; +import {Users} from './resources/users.js'; +import {Groups} from './resources/groups.js'; +import {Roles} from './resources/roles.js'; +import {Clients} from './resources/clients.js'; +import {Realms} from './resources/realms.js'; +import {ClientScopes} from './resources/clientScopes.js'; +import {ClientPolicies} from './resources/clientPolicies.js'; +import {IdentityProviders} from './resources/identityProviders.js'; +import {Components} from './resources/components.js'; +import {AuthenticationManagement} from './resources/authenticationManagement.js'; +import {ServerInfo} from './resources/serverInfo.js'; +import {WhoAmI} from './resources/whoAmI.js'; +import {AttackDetection} from './resources/attackDetection.js'; +import type {AxiosRequestConfig} from 'axios'; + +import {Sessions} from './resources/sessions.js'; +import {UserStorageProvider} from './resources/userStorageProvider.js'; import type {KeycloakInstance, KeycloakInitOptions, KeycloakConfig} from 'keycloak-js'; import {RequestArgs} from './resources/agent'; diff --git a/src/defs/adminEventRepresentation.ts b/src/defs/adminEventRepresentation.ts index 09656926..880a6f54 100644 --- a/src/defs/adminEventRepresentation.ts +++ b/src/defs/adminEventRepresentation.ts @@ -1,4 +1,4 @@ -import AuthDetailsRepresentation from './authDetailsRepresentation'; +import type AuthDetailsRepresentation from './authDetailsRepresentation.js'; export default interface AdminEventRepresentation { authDetails?: AuthDetailsRepresentation; diff --git a/src/defs/authenticationFlowRepresentation.ts b/src/defs/authenticationFlowRepresentation.ts index 4813ea90..694f249e 100644 --- a/src/defs/authenticationFlowRepresentation.ts +++ b/src/defs/authenticationFlowRepresentation.ts @@ -1,5 +1,4 @@ - -import AuthenticationExecutionExportRepresentation from './authenticationExecutionExportRepresentation'; +import type AuthenticationExecutionExportRepresentation from './authenticationExecutionExportRepresentation.js'; /** * https://www.keycloak.org/docs-api/11.0/rest-api/index.html#_authenticationflowrepresentation diff --git a/src/defs/clientPoliciesRepresentation.ts b/src/defs/clientPoliciesRepresentation.ts index a221aacf..1e25c43f 100644 --- a/src/defs/clientPoliciesRepresentation.ts +++ b/src/defs/clientPoliciesRepresentation.ts @@ -1,4 +1,4 @@ -import ClientPolicyRepresentation from './clientPolicyRepresentation'; +import type ClientPolicyRepresentation from './clientPolicyRepresentation.js'; /** * https://www.keycloak.org/docs-api/15.0/rest-api/#_clientpoliciesrepresentation diff --git a/src/defs/clientPolicyRepresentation.ts b/src/defs/clientPolicyRepresentation.ts index 1b5d238e..f318402f 100644 --- a/src/defs/clientPolicyRepresentation.ts +++ b/src/defs/clientPolicyRepresentation.ts @@ -1,4 +1,4 @@ -import ClientPolicyConditionRepresentation from './clientPolicyConditionRepresentation'; +import type ClientPolicyConditionRepresentation from './clientPolicyConditionRepresentation.js'; /** * https://www.keycloak.org/docs-api/15.0/rest-api/#_clientpolicyrepresentation diff --git a/src/defs/clientProfileRepresentation.ts b/src/defs/clientProfileRepresentation.ts index 9576504a..87d5cd33 100644 --- a/src/defs/clientProfileRepresentation.ts +++ b/src/defs/clientProfileRepresentation.ts @@ -1,4 +1,4 @@ -import ClientPolicyExecutorRepresentation from './clientPolicyExecutorRepresentation'; +import type ClientPolicyExecutorRepresentation from './clientPolicyExecutorRepresentation.js'; /** * https://www.keycloak.org/docs-api/15.0/rest-api/#_clientprofilerepresentation diff --git a/src/defs/clientProfilesRepresentation.ts b/src/defs/clientProfilesRepresentation.ts index 2a27d6e2..092b76f0 100644 --- a/src/defs/clientProfilesRepresentation.ts +++ b/src/defs/clientProfilesRepresentation.ts @@ -1,4 +1,4 @@ -import ClientProfileRepresentation from './clientProfileRepresentation'; +import type ClientProfileRepresentation from './clientProfileRepresentation.js'; /** * https://www.keycloak.org/docs-api/15.0/rest-api/#_clientprofilesrepresentation diff --git a/src/defs/clientRepresentation.ts b/src/defs/clientRepresentation.ts index b7a2f252..de3498dc 100644 --- a/src/defs/clientRepresentation.ts +++ b/src/defs/clientRepresentation.ts @@ -1,8 +1,8 @@ /** * https://www.keycloak.org/docs-api/11.0/rest-api/index.html#_clientrepresentation */ -import ResourceServerRepresentation from './resourceServerRepresentation'; -import ProtocolMapperRepresentation from './protocolMapperRepresentation'; +import type ResourceServerRepresentation from './resourceServerRepresentation.js'; +import type ProtocolMapperRepresentation from './protocolMapperRepresentation.js'; export default interface ClientRepresentation { access?: Record; diff --git a/src/defs/clientScopeRepresentation.ts b/src/defs/clientScopeRepresentation.ts index 96719dbd..9babf7b6 100644 --- a/src/defs/clientScopeRepresentation.ts +++ b/src/defs/clientScopeRepresentation.ts @@ -1,7 +1,7 @@ /** * https://www.keycloak.org/docs-api/11.0/rest-api/index.html#_clientscoperepresentation */ -import ProtocolMapperRepresentation from './protocolMapperRepresentation'; +import type ProtocolMapperRepresentation from './protocolMapperRepresentation.js'; export default interface ClientScopeRepresentation { attributes?: Record; diff --git a/src/defs/componentTypeRepresentation.ts b/src/defs/componentTypeRepresentation.ts index 249ed0e7..1a36fdfe 100644 --- a/src/defs/componentTypeRepresentation.ts +++ b/src/defs/componentTypeRepresentation.ts @@ -1,4 +1,4 @@ -import {ConfigPropertyRepresentation} from './configPropertyRepresentation'; +import type {ConfigPropertyRepresentation} from './configPropertyRepresentation.js'; /** * https://www.keycloak.org/docs-api/11.0/rest-api/index.html#_componenttyperepresentation diff --git a/src/defs/eventRepresentation.ts b/src/defs/eventRepresentation.ts index 9b701f64..300c651b 100644 --- a/src/defs/eventRepresentation.ts +++ b/src/defs/eventRepresentation.ts @@ -1,7 +1,7 @@ /** * https://www.keycloak.org/docs-api/11.0/rest-api/index.html#_eventrepresentation */ -import EventType from './eventTypes'; +import type EventType from './eventTypes.js'; export default interface EventRepresentation { clientId?: string; diff --git a/src/defs/identityProviderMapperTypeRepresentation.ts b/src/defs/identityProviderMapperTypeRepresentation.ts index bfe7dd85..1498b2b4 100644 --- a/src/defs/identityProviderMapperTypeRepresentation.ts +++ b/src/defs/identityProviderMapperTypeRepresentation.ts @@ -1,4 +1,4 @@ -import {ConfigPropertyRepresentation} from './configPropertyRepresentation'; +import type {ConfigPropertyRepresentation} from './configPropertyRepresentation.js'; export interface IdentityProviderMapperTypeRepresentation { id?: string; diff --git a/src/defs/mappingsRepresentation.ts b/src/defs/mappingsRepresentation.ts index 5eccc20e..f49cde68 100644 --- a/src/defs/mappingsRepresentation.ts +++ b/src/defs/mappingsRepresentation.ts @@ -1,7 +1,7 @@ /** * https://www.keycloak.org/docs-api/11.0/rest-api/index.html#_mappingsrepresentation */ -import RoleRepresentation from './roleRepresentation'; +import type RoleRepresentation from './roleRepresentation.js'; export default interface MappingsRepresentation { clientMappings?: Record; diff --git a/src/defs/realmRepresentation.ts b/src/defs/realmRepresentation.ts index 71f6dac0..680258ea 100644 --- a/src/defs/realmRepresentation.ts +++ b/src/defs/realmRepresentation.ts @@ -1,13 +1,13 @@ -import ClientRepresentation from './clientRepresentation'; -import ComponentExportRepresentation from './componentExportRepresentation'; -import UserRepresentation from './userRepresentation'; -import GroupRepresentation from './groupRepresentation'; -import IdentityProviderRepresentation from './identityProviderRepresentation'; -import RequiredActionProviderRepresentation from './requiredActionProviderRepresentation'; -import RolesRepresentation from './rolesRepresentation'; -import ClientProfilesRepresentation from './clientProfilesRepresentation'; -import ClientPoliciesRepresentation from './clientPoliciesRepresentation'; -import RoleRepresentation from './roleRepresentation'; +import type ClientRepresentation from './clientRepresentation.js'; +import type ComponentExportRepresentation from './componentExportRepresentation.js'; +import type UserRepresentation from './userRepresentation.js'; +import type GroupRepresentation from './groupRepresentation.js'; +import type IdentityProviderRepresentation from './identityProviderRepresentation.js'; +import type RequiredActionProviderRepresentation from './requiredActionProviderRepresentation.js'; +import type RolesRepresentation from './rolesRepresentation.js'; +import type ClientProfilesRepresentation from './clientProfilesRepresentation.js'; +import type ClientPoliciesRepresentation from './clientPoliciesRepresentation.js'; +import type RoleRepresentation from './roleRepresentation.js'; /** * https://www.keycloak.org/docs-api/11.0/rest-api/index.html#_realmrepresentation diff --git a/src/defs/resourceEvaluation.ts b/src/defs/resourceEvaluation.ts index 8fb7cf3d..48b1bb7a 100644 --- a/src/defs/resourceEvaluation.ts +++ b/src/defs/resourceEvaluation.ts @@ -1,4 +1,4 @@ -import ResourceRepresentation from './resourceRepresentation'; +import type ResourceRepresentation from './resourceRepresentation.js'; export default interface ResourceEvaluation { roleIds?: string[]; diff --git a/src/defs/resourceRepresentation.ts b/src/defs/resourceRepresentation.ts index 868a455a..b8e4fa1d 100644 --- a/src/defs/resourceRepresentation.ts +++ b/src/defs/resourceRepresentation.ts @@ -1,8 +1,8 @@ /** * https://www.keycloak.org/docs-api/11.0/rest-api/index.html#_resourcerepresentation */ -import {ResourceOwnerRepresentation} from './resourceServerRepresentation'; -import ScopeRepresentation from './scopeRepresentation'; +import type {ResourceOwnerRepresentation} from './resourceServerRepresentation.js'; +import type ScopeRepresentation from './scopeRepresentation.js'; export default interface ResourceRepresentation { name?: string; diff --git a/src/defs/resourceServerRepresentation.ts b/src/defs/resourceServerRepresentation.ts index aefe36d6..e296703a 100644 --- a/src/defs/resourceServerRepresentation.ts +++ b/src/defs/resourceServerRepresentation.ts @@ -1,9 +1,9 @@ /** * https://www.keycloak.org/docs-api/11.0/rest-api/index.html#_policyrepresentation */ -import PolicyRepresentation from './policyRepresentation'; -import ResourceRepresentation from './resourceRepresentation'; -import ScopeRepresentation from './scopeRepresentation'; +import type PolicyRepresentation from './policyRepresentation.js'; +import type ResourceRepresentation from './resourceRepresentation.js'; +import type ScopeRepresentation from './scopeRepresentation.js'; export default interface ResourceServerRepresentation { id?: string; diff --git a/src/defs/rolesRepresentation.ts b/src/defs/rolesRepresentation.ts index 270b9bc2..b8d55828 100644 --- a/src/defs/rolesRepresentation.ts +++ b/src/defs/rolesRepresentation.ts @@ -2,7 +2,7 @@ * https://www.keycloak.org/docs-api/11.0/rest-api/index.html#_rolesrepresentation */ -import RoleRepresentation from './roleRepresentation'; +import type RoleRepresentation from './roleRepresentation.js'; export default interface RolesRepresentation { realm?: RoleRepresentation[]; diff --git a/src/defs/scopeRepresentation.ts b/src/defs/scopeRepresentation.ts index c37c3e0f..3a91a49a 100644 --- a/src/defs/scopeRepresentation.ts +++ b/src/defs/scopeRepresentation.ts @@ -1,8 +1,8 @@ /** * https://www.keycloak.org/docs-api/11.0/rest-api/index.html#_scoperepresentation */ -import PolicyRepresentation from './policyRepresentation'; -import ResourceRepresentation from './resourceRepresentation'; +import type PolicyRepresentation from './policyRepresentation.js'; +import type ResourceRepresentation from './resourceRepresentation.js'; export default interface ScopeRepresentation { displayName?: string; diff --git a/src/defs/serverInfoRepesentation.ts b/src/defs/serverInfoRepesentation.ts index 82f84077..014f0e3e 100644 --- a/src/defs/serverInfoRepesentation.ts +++ b/src/defs/serverInfoRepesentation.ts @@ -1,9 +1,9 @@ -import ComponentTypeRepresentation from './componentTypeRepresentation'; -import {ConfigPropertyRepresentation} from './configPropertyRepresentation'; -import PasswordPolicyTypeRepresentation from './passwordPolicyTypeRepresentation'; -import ProfileInfoRepresentation from './profileInfoRepresentation'; -import ProtocolMapperRepresentation from './protocolMapperRepresentation'; -import SystemInfoRepresentation from './systemInfoRepersantation'; +import type ComponentTypeRepresentation from './componentTypeRepresentation.js'; +import type {ConfigPropertyRepresentation} from './configPropertyRepresentation.js'; +import type PasswordPolicyTypeRepresentation from './passwordPolicyTypeRepresentation.js'; +import type ProfileInfoRepresentation from './profileInfoRepresentation.js'; +import type ProtocolMapperRepresentation from './protocolMapperRepresentation.js'; +import type SystemInfoRepresentation from './systemInfoRepersantation.js'; /** * https://www.keycloak.org/docs-api/11.0/rest-api/index.html#_serverinforepresentation diff --git a/src/defs/userRepresentation.ts b/src/defs/userRepresentation.ts index 9b551acf..c477ba35 100644 --- a/src/defs/userRepresentation.ts +++ b/src/defs/userRepresentation.ts @@ -1,7 +1,7 @@ -import UserConsentRepresentation from './userConsentRepresentation'; -import CredentialRepresentation from './credentialRepresentation'; -import FederatedIdentityRepresentation from './federatedIdentityRepresentation'; -import {RequiredActionAlias} from './requiredActionProviderRepresentation'; +import type UserConsentRepresentation from './userConsentRepresentation.js'; +import type CredentialRepresentation from './credentialRepresentation.js'; +import type FederatedIdentityRepresentation from './federatedIdentityRepresentation.js'; +import type {RequiredActionAlias} from './requiredActionProviderRepresentation.js'; export default interface UserRepresentation { id?: string; diff --git a/src/index.ts b/src/index.ts index d6255809..6f8e330e 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,5 +1,5 @@ -import {RequiredActionAlias} from './defs/requiredActionProviderRepresentation'; -import {KeycloakAdminClient} from './client'; +import {RequiredActionAlias} from './defs/requiredActionProviderRepresentation.js'; +import {KeycloakAdminClient} from './client.js'; export const requiredAction = RequiredActionAlias; export default KeycloakAdminClient; diff --git a/src/resources/agent.ts b/src/resources/agent.ts index f0a24348..aca69073 100644 --- a/src/resources/agent.ts +++ b/src/resources/agent.ts @@ -2,8 +2,8 @@ import urlJoin from 'url-join'; import template from 'url-template'; import axios, {AxiosRequestConfig, AxiosRequestHeaders, Method} from 'axios'; import querystring from 'query-string'; -import {pick, omit, isUndefined, last} from 'lodash'; -import {KeycloakAdminClient} from '../client'; +import {pick, omit, isUndefined, last} from 'lodash-es'; +import type {KeycloakAdminClient} from '../client.js'; // constants const SLASH = '/'; diff --git a/src/resources/attackDetection.ts b/src/resources/attackDetection.ts index a7895ec4..f57feac0 100644 --- a/src/resources/attackDetection.ts +++ b/src/resources/attackDetection.ts @@ -1,5 +1,5 @@ -import Resource from './resource'; -import KeycloakAdminClient from '..'; +import Resource from './resource.js'; +import type KeycloakAdminClient from '../index.js'; export class AttackDetection extends Resource<{realm?: string}> { public findOne = this.makeRequest< diff --git a/src/resources/authenticationManagement.ts b/src/resources/authenticationManagement.ts index 1bb9961c..a20904b9 100644 --- a/src/resources/authenticationManagement.ts +++ b/src/resources/authenticationManagement.ts @@ -1,13 +1,12 @@ -import Resource from './resource'; -import RequiredActionProviderRepresentation from '../defs/requiredActionProviderRepresentation'; -import {KeycloakAdminClient} from '../client'; -import AuthenticationExecutionInfoRepresentation from '../defs/authenticationExecutionInfoRepresentation'; -import AuthenticationFlowRepresentation from '../defs/authenticationFlowRepresentation'; -import AuthenticatorConfigRepresentation, { - AuthenticationProviderRepresentation, -} from '../defs/authenticatorConfigRepresentation'; -import AuthenticatorConfigInfoRepresentation from '../defs/authenticatorConfigInfoRepresentation'; -import RequiredActionProviderSimpleRepresentation from '../defs/requiredActionProviderSimpleRepresentation'; +import Resource from './resource.js'; +import type RequiredActionProviderRepresentation from '../defs/requiredActionProviderRepresentation.js'; +import type {KeycloakAdminClient} from '../client.js'; +import type AuthenticationExecutionInfoRepresentation from '../defs/authenticationExecutionInfoRepresentation.js'; +import type AuthenticationFlowRepresentation from '../defs/authenticationFlowRepresentation.js'; +import type AuthenticatorConfigRepresentation from '../defs/authenticatorConfigRepresentation.js'; +import type { AuthenticationProviderRepresentation } from '../defs/authenticatorConfigRepresentation.js'; +import type AuthenticatorConfigInfoRepresentation from '../defs/authenticatorConfigInfoRepresentation.js'; +import type RequiredActionProviderSimpleRepresentation from '../defs/requiredActionProviderSimpleRepresentation.js'; export class AuthenticationManagement extends Resource { /** diff --git a/src/resources/cache.ts b/src/resources/cache.ts index 8db6dd2f..38ef0ff3 100644 --- a/src/resources/cache.ts +++ b/src/resources/cache.ts @@ -1,5 +1,5 @@ -import Resource from './resource'; -import {KeycloakAdminClient} from '../client'; +import Resource from './resource.js'; +import type {KeycloakAdminClient} from '../client.js'; export class Cache extends Resource<{realm?: string}> { diff --git a/src/resources/clientPolicies.ts b/src/resources/clientPolicies.ts index 08fdfc73..f712616b 100644 --- a/src/resources/clientPolicies.ts +++ b/src/resources/clientPolicies.ts @@ -1,8 +1,7 @@ -import Resource from './resource'; -import {KeycloakAdminClient} from '../client'; -import ClientProfilesRepresentation from '../defs/clientProfilesRepresentation'; -import ClientPoliciesRepresentation from '../defs/clientPoliciesRepresentation'; -import ClientPolicyRepresentation from '../defs/clientPolicyRepresentation'; +import Resource from './resource.js'; +import type {KeycloakAdminClient} from '../client.js'; +import type ClientProfilesRepresentation from '../defs/clientProfilesRepresentation.js'; +import type ClientPoliciesRepresentation from '../defs/clientPoliciesRepresentation.js'; /** * https://www.keycloak.org/docs-api/15.0/rest-api/#_client_registration_policy_resource diff --git a/src/resources/clientScopes.ts b/src/resources/clientScopes.ts index bffd0213..0007e241 100644 --- a/src/resources/clientScopes.ts +++ b/src/resources/clientScopes.ts @@ -1,9 +1,9 @@ -import ClientScopeRepresentation from '../defs/clientScopeRepresentation'; -import Resource from './resource'; -import {KeycloakAdminClient} from '../client'; -import ProtocolMapperRepresentation from '../defs/protocolMapperRepresentation'; -import MappingsRepresentation from '../defs/mappingsRepresentation'; -import RoleRepresentation from '../defs/roleRepresentation'; +import type ClientScopeRepresentation from '../defs/clientScopeRepresentation.js'; +import Resource from './resource.js'; +import type {KeycloakAdminClient} from '../client.js'; +import type ProtocolMapperRepresentation from '../defs/protocolMapperRepresentation.js'; +import type MappingsRepresentation from '../defs/mappingsRepresentation.js'; +import type RoleRepresentation from '../defs/roleRepresentation.js'; export class ClientScopes extends Resource<{realm?: string}> { public find = this.makeRequest<{}, ClientScopeRepresentation[]>({ diff --git a/src/resources/clients.ts b/src/resources/clients.ts index df4e3ca0..87a6af50 100644 --- a/src/resources/clients.ts +++ b/src/resources/clients.ts @@ -1,22 +1,22 @@ -import {KeycloakAdminClient} from '../client'; -import ClientRepresentation from '../defs/clientRepresentation'; -import ClientScopeRepresentation from '../defs/clientScopeRepresentation'; -import CredentialRepresentation from '../defs/credentialRepresentation'; -import MappingsRepresentation from '../defs/mappingsRepresentation'; -import PolicyRepresentation from '../defs/policyRepresentation'; -import ResourceRepresentation from '../defs/resourceRepresentation'; -import ProtocolMapperRepresentation from '../defs/protocolMapperRepresentation'; -import RoleRepresentation from '../defs/roleRepresentation'; -import UserRepresentation from '../defs/userRepresentation'; -import UserSessionRepresentation from '../defs/userSessionRepresentation'; -import ResourceEvaluation from '../defs/resourceEvaluation'; -import GlobalRequestResult from '../defs/globalRequestResult'; -import Resource from './resource'; -import CertificateRepresentation from '../defs/certificateRepresentation'; -import KeyStoreConfig from '../defs/keystoreConfig'; -import ResourceServerRepresentation from '../defs/resourceServerRepresentation'; -import ScopeRepresentation from '../defs/scopeRepresentation'; -import PolicyProviderRepresentation from '../defs/policyProviderRepresentation'; +import type {KeycloakAdminClient} from '../client.js'; +import type ClientRepresentation from '../defs/clientRepresentation.js'; +import type ClientScopeRepresentation from '../defs/clientScopeRepresentation.js'; +import type CredentialRepresentation from '../defs/credentialRepresentation.js'; +import type MappingsRepresentation from '../defs/mappingsRepresentation.js'; +import type PolicyRepresentation from '../defs/policyRepresentation.js'; +import type ResourceRepresentation from '../defs/resourceRepresentation.js'; +import type ProtocolMapperRepresentation from '../defs/protocolMapperRepresentation.js'; +import type RoleRepresentation from '../defs/roleRepresentation.js'; +import type UserRepresentation from '../defs/userRepresentation.js'; +import type UserSessionRepresentation from '../defs/userSessionRepresentation.js'; +import type ResourceEvaluation from '../defs/resourceEvaluation.js'; +import type GlobalRequestResult from '../defs/globalRequestResult.js'; +import Resource from './resource.js'; +import type CertificateRepresentation from '../defs/certificateRepresentation.js'; +import type KeyStoreConfig from '../defs/keystoreConfig.js'; +import type ResourceServerRepresentation from '../defs/resourceServerRepresentation.js'; +import type ScopeRepresentation from '../defs/scopeRepresentation.js'; +import type PolicyProviderRepresentation from '../defs/policyProviderRepresentation.js'; export interface PaginatedQuery { first?: number; diff --git a/src/resources/components.ts b/src/resources/components.ts index f786f0a7..daa19f31 100644 --- a/src/resources/components.ts +++ b/src/resources/components.ts @@ -1,7 +1,7 @@ -import Resource from './resource'; -import ComponentRepresentation from '../defs/componentRepresentation'; -import ComponentTypeRepresentation from '../defs/componentTypeRepresentation'; -import {KeycloakAdminClient} from '../client'; +import Resource from './resource.js'; +import type ComponentRepresentation from '../defs/componentRepresentation.js'; +import type ComponentTypeRepresentation from '../defs/componentTypeRepresentation.js'; +import type {KeycloakAdminClient} from '../client.js'; export interface ComponentQuery { name?: string; diff --git a/src/resources/groups.ts b/src/resources/groups.ts index c976343f..228b95c1 100644 --- a/src/resources/groups.ts +++ b/src/resources/groups.ts @@ -1,12 +1,11 @@ -import {KeycloakAdminClient} from '../client'; -import GroupRepresentation from '../defs/groupRepresentation'; -import {ManagementPermissionReference} from '../defs/managementPermissionReference'; -import MappingsRepresentation from '../defs/mappingsRepresentation'; -import RoleRepresentation, { - RoleMappingPayload, -} from '../defs/roleRepresentation'; -import UserRepresentation from '../defs/userRepresentation'; -import Resource from './resource'; +import type {KeycloakAdminClient} from '../client.js'; +import type GroupRepresentation from '../defs/groupRepresentation.js'; +import type {ManagementPermissionReference} from '../defs/managementPermissionReference.js'; +import type MappingsRepresentation from '../defs/mappingsRepresentation.js'; +import type RoleRepresentation from '../defs/roleRepresentation.js'; +import type { RoleMappingPayload } from '../defs/roleRepresentation.js'; +import type UserRepresentation from '../defs/userRepresentation.js'; +import Resource from './resource.js'; export interface GroupQuery { first?: number; diff --git a/src/resources/identityProviders.ts b/src/resources/identityProviders.ts index 50c9d2fb..f631ee87 100644 --- a/src/resources/identityProviders.ts +++ b/src/resources/identityProviders.ts @@ -1,8 +1,8 @@ -import Resource from './resource'; -import IdentityProviderRepresentation from '../defs/identityProviderRepresentation'; -import IdentityProviderMapperRepresentation from '../defs/identityProviderMapperRepresentation'; -import {IdentityProviderMapperTypeRepresentation} from '../defs/identityProviderMapperTypeRepresentation'; -import {KeycloakAdminClient} from '../client'; +import Resource from './resource.js'; +import type IdentityProviderRepresentation from '../defs/identityProviderRepresentation.js'; +import type IdentityProviderMapperRepresentation from '../defs/identityProviderMapperRepresentation.js'; +import type {IdentityProviderMapperTypeRepresentation} from '../defs/identityProviderMapperTypeRepresentation.js'; +import type {KeycloakAdminClient} from '../client.js'; export class IdentityProviders extends Resource<{realm?: string}> { /** diff --git a/src/resources/realms.ts b/src/resources/realms.ts index 7ddc5aa1..5fbae4af 100644 --- a/src/resources/realms.ts +++ b/src/resources/realms.ts @@ -1,20 +1,17 @@ -import Resource from './resource'; -import AdminEventRepresentation from '../defs/adminEventRepresentation'; -import RealmRepresentation, { - PartialImportRealmRepresentation, - PartialImportResponse, -} from '../defs/realmRepresentation'; -import EventRepresentation from '../defs/eventRepresentation'; -import EventType from '../defs/eventTypes'; -import KeysMetadataRepresentation from '../defs/keyMetadataRepresentation'; -import ClientInitialAccessPresentation from '../defs/clientInitialAccessPresentation'; -import TestLdapConnectionRepresentation from '../defs/testLdapConnection'; - -import {KeycloakAdminClient} from '../client'; -import {RealmEventsConfigRepresentation} from '../defs/realmEventsConfigRepresentation'; -import ComponentRepresentation from '../defs/componentRepresentation'; -import GlobalRequestResult from '../defs/globalRequestResult'; -import GroupRepresentation from '../defs/groupRepresentation'; +import Resource from './resource.js'; +import type AdminEventRepresentation from '../defs/adminEventRepresentation.js'; +import type RealmRepresentation from '../defs/realmRepresentation.js'; +import type {PartialImportRealmRepresentation, PartialImportResponse} from '../defs/realmRepresentation.js'; +import type EventRepresentation from '../defs/eventRepresentation.js'; +import type EventType from '../defs/eventTypes.js'; +import type KeysMetadataRepresentation from '../defs/keyMetadataRepresentation.js'; +import type ClientInitialAccessPresentation from '../defs/clientInitialAccessPresentation.js'; +import type TestLdapConnectionRepresentation from '../defs/testLdapConnection.js'; + +import type {KeycloakAdminClient} from '../client.js'; +import type {RealmEventsConfigRepresentation} from '../defs/realmEventsConfigRepresentation.js'; +import type GlobalRequestResult from '../defs/globalRequestResult.js'; +import type GroupRepresentation from '../defs/groupRepresentation.js'; export class Realms extends Resource { /** diff --git a/src/resources/resource.ts b/src/resources/resource.ts index dec0c8ad..7c19a2ec 100644 --- a/src/resources/resource.ts +++ b/src/resources/resource.ts @@ -1,5 +1,5 @@ -import {KeycloakAdminClient} from '../client'; -import {Agent, RequestArgs} from './agent'; +import type {KeycloakAdminClient} from '../client.js'; +import {Agent, RequestArgs} from './agent.js'; export default class Resource { private agent: Agent; diff --git a/src/resources/roles.ts b/src/resources/roles.ts index d75eb966..1fb325c6 100644 --- a/src/resources/roles.ts +++ b/src/resources/roles.ts @@ -1,7 +1,7 @@ -import Resource from './resource'; -import RoleRepresentation from '../defs/roleRepresentation'; -import UserRepresentation from '../defs/userRepresentation'; -import {KeycloakAdminClient} from '../client'; +import Resource from './resource.js'; +import type RoleRepresentation from '../defs/roleRepresentation.js'; +import type UserRepresentation from '../defs/userRepresentation.js'; +import type {KeycloakAdminClient} from '../client.js'; export interface RoleQuery { first?: number; diff --git a/src/resources/serverInfo.ts b/src/resources/serverInfo.ts index ac9b64d1..878510a7 100644 --- a/src/resources/serverInfo.ts +++ b/src/resources/serverInfo.ts @@ -1,6 +1,6 @@ -import Resource from './resource'; -import {ServerInfoRepresentation} from '../defs/serverInfoRepesentation'; -import KeycloakAdminClient from '..'; +import Resource from './resource.js'; +import type {ServerInfoRepresentation} from '../defs/serverInfoRepesentation.js'; +import type KeycloakAdminClient from '../index.js'; export class ServerInfo extends Resource { constructor(client: KeycloakAdminClient) { diff --git a/src/resources/sessions.ts b/src/resources/sessions.ts index 6dceb640..a42ce454 100644 --- a/src/resources/sessions.ts +++ b/src/resources/sessions.ts @@ -1,5 +1,5 @@ -import Resource from './resource'; -import KeycloakAdminClient from '..'; +import Resource from './resource.js'; +import type KeycloakAdminClient from '../index.js'; export class Sessions extends Resource<{realm?: string}> { diff --git a/src/resources/userStorageProvider.ts b/src/resources/userStorageProvider.ts index ad443332..45b98a1f 100644 --- a/src/resources/userStorageProvider.ts +++ b/src/resources/userStorageProvider.ts @@ -1,6 +1,6 @@ -import {KeycloakAdminClient} from '../client'; -import SynchronizationResultRepresentation from '../defs/synchronizationResultRepresentation'; -import Resource from './resource'; +import type {KeycloakAdminClient} from '../client.js'; +import type SynchronizationResultRepresentation from '../defs/synchronizationResultRepresentation.js'; +import Resource from './resource.js'; type ActionType = 'triggerFullSync' | 'triggerChangedUsersSync'; type DirectionType = 'fedToKeycloak' | 'keycloakToFed'; diff --git a/src/resources/users.ts b/src/resources/users.ts index bea76400..b37a4b50 100644 --- a/src/resources/users.ts +++ b/src/resources/users.ts @@ -1,17 +1,16 @@ -import Resource from './resource'; -import UserRepresentation from '../defs/userRepresentation'; -import UserConsentRepresentation from '../defs/userConsentRepresentation'; -import UserSessionRepresentation from '../defs/userSessionRepresentation'; -import {KeycloakAdminClient} from '../client'; -import MappingsRepresentation from '../defs/mappingsRepresentation'; -import RoleRepresentation, { - RoleMappingPayload, -} from '../defs/roleRepresentation'; -import {RequiredActionAlias} from '../defs/requiredActionProviderRepresentation'; -import FederatedIdentityRepresentation from '../defs/federatedIdentityRepresentation'; -import GroupRepresentation from '../defs/groupRepresentation'; -import CredentialRepresentation from '../defs/credentialRepresentation'; -import UserProfileConfig from '../defs/userProfileConfig'; +import Resource from './resource.js'; +import type UserRepresentation from '../defs/userRepresentation.js'; +import type UserConsentRepresentation from '../defs/userConsentRepresentation.js'; +import type UserSessionRepresentation from '../defs/userSessionRepresentation.js'; +import type {KeycloakAdminClient} from '../client.js'; +import type MappingsRepresentation from '../defs/mappingsRepresentation.js'; +import type RoleRepresentation from '../defs/roleRepresentation.js'; +import type { RoleMappingPayload } from '../defs/roleRepresentation.js'; +import type {RequiredActionAlias} from '../defs/requiredActionProviderRepresentation.js'; +import type FederatedIdentityRepresentation from '../defs/federatedIdentityRepresentation.js'; +import type GroupRepresentation from '../defs/groupRepresentation.js'; +import type CredentialRepresentation from '../defs/credentialRepresentation.js'; +import type UserProfileConfig from '../defs/userProfileConfig.js'; export interface UserQuery { email?: string; diff --git a/src/resources/whoAmI.ts b/src/resources/whoAmI.ts index a96db77f..3ec0d6ca 100644 --- a/src/resources/whoAmI.ts +++ b/src/resources/whoAmI.ts @@ -1,6 +1,6 @@ -import WhoAmIRepresentation from '../defs/whoAmIRepresentation'; -import KeycloakAdminClient from '..'; -import Resource from './resource'; +import type WhoAmIRepresentation from '../defs/whoAmIRepresentation.js'; +import type KeycloakAdminClient from '../index.js'; +import Resource from './resource.js'; export class WhoAmI extends Resource<{realm?: string}> { constructor(client: KeycloakAdminClient) { diff --git a/src/utils/auth.ts b/src/utils/auth.ts index 40b06de4..705b8490 100644 --- a/src/utils/auth.ts +++ b/src/utils/auth.ts @@ -1,7 +1,7 @@ import axios, {AxiosRequestConfig, AxiosResponse} from 'axios'; import camelize from 'camelize-ts'; import querystring from 'query-string'; -import {defaultBaseUrl, defaultRealm} from './constants'; +import {defaultBaseUrl, defaultRealm} from './constants.js'; export type GrantTypes = 'client_credentials' | 'password' | 'refresh_token'; diff --git a/test/attackDetection.spec.ts b/test/attackDetection.spec.ts index 501a80da..8f2b75de 100644 --- a/test/attackDetection.spec.ts +++ b/test/attackDetection.spec.ts @@ -1,9 +1,9 @@ // tslint:disable:no-unused-expression import * as chai from 'chai'; -import {KeycloakAdminClient} from '../src/client'; -import {credentials} from './constants'; +import {KeycloakAdminClient} from '../src/client.js'; +import {credentials} from './constants.js'; import faker from '@faker-js/faker'; -import UserRepresentation from '../src/defs/userRepresentation'; +import type UserRepresentation from '../src/defs/userRepresentation.js'; const expect = chai.expect; describe('Attack Detection', () => { diff --git a/test/clients.spec.ts b/test/clients.spec.ts index 3439531a..d178f626 100644 --- a/test/clients.spec.ts +++ b/test/clients.spec.ts @@ -3,13 +3,14 @@ import * as chai from 'chai'; import {KeycloakAdminClient} from '../src/client'; import {credentials} from './constants'; import faker from '@faker-js/faker'; -import ClientRepresentation from '../src/defs/clientRepresentation'; -import ProtocolMapperRepresentation from '../src/defs/protocolMapperRepresentation'; -import ClientScopeRepresentation from '../src/defs/clientScopeRepresentation'; -import ScopeRepresentation from '../src/defs/scopeRepresentation'; -import ResourceRepresentation from '../src/defs/resourceRepresentation'; -import UserRepresentation from '../src/defs/userRepresentation'; -import PolicyRepresentation, {Logic} from '../src/defs/policyRepresentation'; +import type ClientRepresentation from '../src/defs/clientRepresentation.js'; +import type ProtocolMapperRepresentation from '../src/defs/protocolMapperRepresentation.js'; +import type ClientScopeRepresentation from '../src/defs/clientScopeRepresentation.js'; +import type ScopeRepresentation from '../src/defs/scopeRepresentation.js'; +import type ResourceRepresentation from '../src/defs/resourceRepresentation.js'; +import type UserRepresentation from '../src/defs/userRepresentation.js'; +import type PolicyRepresentation from '../src/defs/policyRepresentation.js'; +import type {Logic} from '../src/defs/policyRepresentation.js'; const expect = chai.expect; describe('Clients', () => { diff --git a/test/constants.ts b/test/constants.ts index 51131161..a87bccd1 100644 --- a/test/constants.ts +++ b/test/constants.ts @@ -1,4 +1,4 @@ -import {Credentials} from '../src/utils/auth'; +import type {Credentials} from '../src/utils/auth.js'; export const credentials: Credentials = { username: 'wwwy3y3', diff --git a/test/groupUser.spec.ts b/test/groupUser.spec.ts index a715d347..f4a0b910 100644 --- a/test/groupUser.spec.ts +++ b/test/groupUser.spec.ts @@ -1,13 +1,14 @@ // tslint:disable:no-unused-expression import * as chai from 'chai'; import faker from '@faker-js/faker'; -import {omit, pick} from 'lodash'; +import {omit, pick} from 'lodash-es'; import {KeycloakAdminClient} from '../src/client'; -import ClientRepresentation from '../src/defs/clientRepresentation'; -import GroupRepresentation from '../src/defs/groupRepresentation'; -import PolicyRepresentation, {DecisionStrategy, Logic} from '../src/defs/policyRepresentation'; -import UserRepresentation from '../src/defs/userRepresentation'; -import {credentials} from './constants'; +import type ClientRepresentation from '../src/defs/clientRepresentation.js'; +import type GroupRepresentation from '../src/defs/groupRepresentation.js'; +import type PolicyRepresentation from '../src/defs/policyRepresentation.js'; +import type {DecisionStrategy, Logic} from '../src/defs/policyRepresentation.js'; +import type UserRepresentation from '../src/defs/userRepresentation.js'; +import {credentials} from './constants.js'; const expect = chai.expect; diff --git a/test/users.spec.ts b/test/users.spec.ts index 33733a50..a18e3695 100644 --- a/test/users.spec.ts +++ b/test/users.spec.ts @@ -8,7 +8,7 @@ import RoleRepresentation from '../src/defs/roleRepresentation'; import ClientRepresentation from '../src/defs/clientRepresentation'; import {RequiredActionAlias} from '../src/defs/requiredActionProviderRepresentation'; import FederatedIdentityRepresentation from '../src/defs/federatedIdentityRepresentation'; -import {omit} from 'lodash'; +import {omit} from 'lodash-es'; import GroupRepresentation from '../src/defs/groupRepresentation'; import {fail} from 'assert'; diff --git a/tsconfig.json b/tsconfig.json index 228f96f6..87a66779 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,17 +1,16 @@ { "compilerOptions": { - "module": "commonjs", - "lib": ["es6", "dom"], - "moduleResolution": "node", + "rootDir": "src", + "outDir": "lib", + "module": "Node12", + "target": "ES2020", + "isolatedModules": true, + "importsNotUsedAsValues": "error", "removeComments": true, "sourceMap": true, "declaration": true, - "allowSyntheticDefaultImports": true, - "esModuleInterop": true, - "experimentalDecorators": true, "skipLibCheck": true, "strict": true }, - "include": ["src/**/*.ts", "docs/**/*.ts", "test/*"], - "exclude": ["./node_modules"] + "include": ["src"] } diff --git a/tsconfig.release.json b/tsconfig.release.json deleted file mode 100644 index 3256d3da..00000000 --- a/tsconfig.release.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "extends": "./tsconfig", - "compilerOptions": { - "rootDir": "src", - "outDir": "lib" - }, - "include": ["src/**/*.ts"], - "exclude": ["test/**/*.ts"] -} diff --git a/tsconfig.test.json b/tsconfig.test.json new file mode 100644 index 00000000..05bebb48 --- /dev/null +++ b/tsconfig.test.json @@ -0,0 +1,7 @@ +{ + "extends": "./tsconfig", + "compilerOptions": { + "target": "ES2015" + }, + "include": ["test"] +}