@codegouvfr/sill
Advanced tools
Comparing version 0.4.1 to 0.4.2
@@ -8,2 +8,2 @@ import { UserApi } from "../ports/UserApi"; | ||
}; | ||
export declare function createKeycloakUserApi(params: KeycloakUserApiParams): UserApi; | ||
export declare function createKeycloakUserApi(params: KeycloakUserApiParams): Promise<UserApi>; |
@@ -33,3 +33,3 @@ "use strict"; | ||
const memoizee_1 = __importDefault(require("memoizee")); | ||
function createKeycloakUserApi(params) { | ||
async function createKeycloakUserApi(params) { | ||
const { url, adminPassword, realm, organizationUserProfileAttributeName } = params; | ||
@@ -42,3 +42,3 @@ const keycloakAdminApiClient = (0, keycloakAdminApiClient_1.createKeycloakAdminApiClient)({ | ||
const groupRef = runExclusive.createGroupRef(); | ||
return { | ||
const userApi = { | ||
"updateUserEmail": runExclusive.build(groupRef, ({ userId, email }) => keycloakAdminApiClient.updateUser({ | ||
@@ -65,3 +65,4 @@ userId, | ||
"promise": true, | ||
"maxAge": 5 * 60 * 1000 | ||
"maxAge": 5 * 60 * 1000, | ||
"preFetch": true | ||
}), | ||
@@ -97,3 +98,4 @@ "getAllOrganizations": (0, memoizee_1.default)(async () => { | ||
"promise": true, | ||
"maxAge": 60 * 60 * 1000 | ||
"maxAge": 60 * 60 * 1000, | ||
"preFetch": true | ||
}), | ||
@@ -119,7 +121,11 @@ "getUserCount": (0, memoizee_1.default)(async () => { | ||
"promise": true, | ||
"maxAge": 60 * 60 * 1000 | ||
"maxAge": 60 * 60 * 1000, | ||
"preFetch": true | ||
}) | ||
}; | ||
//NOTE: Preload data | ||
await Promise.all([userApi.getUserCount(), userApi.getAllOrganizations(), userApi.getAllowedEmailRegexp()]); | ||
return userApi; | ||
} | ||
exports.createKeycloakUserApi = createKeycloakUserApi; | ||
//# sourceMappingURL=userApi.js.map |
@@ -15,2 +15,4 @@ "use strict"; | ||
const getSoftwareLatestVersion_1 = require("./adapters/getSoftwareLatestVersion"); | ||
const objectKeys_1 = require("tsafe/objectKeys"); | ||
const exclude_1 = require("tsafe/exclude"); | ||
async function createCore(params) { | ||
@@ -35,3 +37,3 @@ const { gitDbApiParams, keycloakUserApiParams, githubPersonalAccessTokenForApiRateLimit } = params; | ||
}) | ||
: (0, userApi_1.createKeycloakUserApi)(keycloakUserApiParams), | ||
: await (0, userApi_1.createKeycloakUserApi)(keycloakUserApiParams), | ||
compileData, | ||
@@ -45,2 +47,10 @@ getWikidataSoftwareOptions: getWikidataSoftwareOptions_1.getWikidataSoftwareOptions, | ||
await core.dispatch(usecases_1.usecases.readWriteSillData.privateThunks.initialize()); | ||
//NOTE: Cache initialization so that the first user do not get slow response. | ||
(0, objectKeys_1.objectKeys)(usecases_1.usecases) | ||
.map(usecaseName => usecases_1.usecases[usecaseName]) | ||
.map(usecase => ("selectors" in usecase ? usecase.selectors : undefined)) | ||
.filter((0, exclude_1.exclude)(undefined)) | ||
.forEach(selectors => (0, objectKeys_1.objectKeys)(selectors) | ||
.map(selectorName => selectors[selectorName]) | ||
.forEach(selector => selector(core.getState()))); | ||
return core; | ||
@@ -47,0 +57,0 @@ } |
{ | ||
"name": "@codegouvfr/sill", | ||
"version": "0.4.1", | ||
"version": "0.4.2", | ||
"description": "The backend of sill.etalab.gouv.fr", | ||
@@ -5,0 +5,0 @@ "repository": { |
@@ -13,3 +13,3 @@ import { createKeycloakAdminApiClient } from "../../tools/keycloakAdminApiClient"; | ||
export function createKeycloakUserApi(params: KeycloakUserApiParams): UserApi { | ||
export async function createKeycloakUserApi(params: KeycloakUserApiParams): Promise<UserApi> { | ||
const { url, adminPassword, realm, organizationUserProfileAttributeName } = params; | ||
@@ -25,3 +25,3 @@ | ||
return { | ||
const userApi: UserApi = { | ||
"updateUserEmail": runExclusive.build(groupRef, ({ userId, email }) => | ||
@@ -56,3 +56,4 @@ keycloakAdminApiClient.updateUser({ | ||
"promise": true, | ||
"maxAge": 5 * 60 * 1000 | ||
"maxAge": 5 * 60 * 1000, | ||
"preFetch": true | ||
} | ||
@@ -100,3 +101,4 @@ ), | ||
"promise": true, | ||
"maxAge": 60 * 60 * 1000 | ||
"maxAge": 60 * 60 * 1000, | ||
"preFetch": true | ||
} | ||
@@ -132,6 +134,12 @@ ), | ||
"promise": true, | ||
"maxAge": 60 * 60 * 1000 | ||
"maxAge": 60 * 60 * 1000, | ||
"preFetch": true | ||
} | ||
) | ||
}; | ||
//NOTE: Preload data | ||
await Promise.all([userApi.getUserCount(), userApi.getAllOrganizations(), userApi.getAllowedEmailRegexp()]); | ||
return userApi; | ||
} |
@@ -17,2 +17,4 @@ import type { ReturnType } from "tsafe"; | ||
import { createGetSoftwareLatestVersion } from "./adapters/getSoftwareLatestVersion"; | ||
import { objectKeys } from "tsafe/objectKeys"; | ||
import { exclude } from "tsafe/exclude"; | ||
@@ -46,3 +48,3 @@ export async function createCore(params: { | ||
}) | ||
: createKeycloakUserApi(keycloakUserApiParams), | ||
: await createKeycloakUserApi(keycloakUserApiParams), | ||
compileData, | ||
@@ -58,2 +60,13 @@ getWikidataSoftwareOptions, | ||
//NOTE: Cache initialization so that the first user do not get slow response. | ||
objectKeys(usecases) | ||
.map(usecaseName => usecases[usecaseName]) | ||
.map(usecase => ("selectors" in usecase ? usecase.selectors : undefined)) | ||
.filter(exclude(undefined)) | ||
.forEach(selectors => | ||
objectKeys(selectors) | ||
.map(selectorName => selectors[selectorName]) | ||
.forEach(selector => selector(core.getState())) | ||
); | ||
return core; | ||
@@ -60,0 +73,0 @@ } |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
615127
11683