@codegouvfr/sill
Advanced tools
Comparing version 1.15.2 to 1.16.0
@@ -881,3 +881,3 @@ import type { ReturnType } from "tsafe"; | ||
}) => Promise<void>; | ||
getAgentAbout: (params: { | ||
getAgentIsPublic: (params: { | ||
email: string; | ||
@@ -946,11 +946,146 @@ }) => (dispatch: import("redux-thunk").ThunkDispatch<{ | ||
}>; | ||
}) => { | ||
}) => boolean; | ||
getAgent: (params: { | ||
email: string; | ||
}) => (dispatch: import("redux-thunk").ThunkDispatch<{ | ||
readWriteSillData: { | ||
db: import("./ports/DbApi").Db; | ||
compiledData: import("./ports/CompileData").CompiledData<"private">; | ||
}; | ||
}, { | ||
createStoreParams: { | ||
gitDbApiParams: import("./adapters/dbApi").GitDbApiParams; | ||
keycloakUserApiParams: import("./adapters/userApi").KeycloakUserApiParams | undefined; | ||
githubPersonalAccessTokenForApiRateLimit: string; | ||
doPerPerformPeriodicalCompilation: boolean; | ||
doPerformCacheInitialization: boolean; | ||
}; | ||
dbApi: import("./ports/DbApi").DbApi; | ||
userApi: import("./ports/UserApi").UserApi; | ||
compileData: import("./ports/CompileData").CompileData; | ||
getWikidataSoftwareOptions: import("./ports/GetWikidataSoftwareOptions").GetWikidataSoftwareOptions; | ||
comptoirDuLibreApi: import("./ports/GetComptoirDuLibre").ComptoirDuLibreApi; | ||
getWikidataSoftware: import("./ports/GetWikidataSoftware").GetWikidataSoftware; | ||
getSoftwareLatestVersion: import("./ports/GetSoftwareLatestVersion").GetSoftwareLatestVersion; | ||
} & { | ||
evtAction: import("evt").NonPostableEvt<{ | ||
sliceName: "readWriteSillData"; | ||
} & { | ||
actionName: "updated"; | ||
} & { | ||
payload: { | ||
db: import("./ports/DbApi").Db; | ||
compiledData: import("./ports/CompileData").CompiledData<"private">; | ||
}; | ||
}>; | ||
}, import("redux").Action<string>>, getState: () => { | ||
readWriteSillData: { | ||
db: import("./ports/DbApi").Db; | ||
compiledData: import("./ports/CompileData").CompiledData<"private">; | ||
}; | ||
}, extraArgument: { | ||
createStoreParams: { | ||
gitDbApiParams: import("./adapters/dbApi").GitDbApiParams; | ||
keycloakUserApiParams: import("./adapters/userApi").KeycloakUserApiParams | undefined; | ||
githubPersonalAccessTokenForApiRateLimit: string; | ||
doPerPerformPeriodicalCompilation: boolean; | ||
doPerformCacheInitialization: boolean; | ||
}; | ||
dbApi: import("./ports/DbApi").DbApi; | ||
userApi: import("./ports/UserApi").UserApi; | ||
compileData: import("./ports/CompileData").CompileData; | ||
getWikidataSoftwareOptions: import("./ports/GetWikidataSoftwareOptions").GetWikidataSoftwareOptions; | ||
comptoirDuLibreApi: import("./ports/GetComptoirDuLibre").ComptoirDuLibreApi; | ||
getWikidataSoftware: import("./ports/GetWikidataSoftware").GetWikidataSoftware; | ||
getSoftwareLatestVersion: import("./ports/GetSoftwareLatestVersion").GetSoftwareLatestVersion; | ||
} & { | ||
evtAction: import("evt").NonPostableEvt<{ | ||
sliceName: "readWriteSillData"; | ||
} & { | ||
actionName: "updated"; | ||
} & { | ||
payload: { | ||
db: import("./ports/DbApi").Db; | ||
compiledData: import("./ports/CompileData").CompiledData<"private">; | ||
}; | ||
}>; | ||
}) => Promise<import("./usecases/readWriteSillData").Agent & { | ||
isPublic: boolean; | ||
about: string | undefined; | ||
}>; | ||
updateIsAgentProfilePublic: (params: { | ||
agent: { | ||
email: string; | ||
organization: string; | ||
}; | ||
isPublic: boolean; | ||
}; | ||
}) => (dispatch: import("redux-thunk").ThunkDispatch<{ | ||
readWriteSillData: { | ||
db: import("./ports/DbApi").Db; | ||
compiledData: import("./ports/CompileData").CompiledData<"private">; | ||
}; | ||
}, { | ||
createStoreParams: { | ||
gitDbApiParams: import("./adapters/dbApi").GitDbApiParams; | ||
keycloakUserApiParams: import("./adapters/userApi").KeycloakUserApiParams | undefined; | ||
githubPersonalAccessTokenForApiRateLimit: string; | ||
doPerPerformPeriodicalCompilation: boolean; | ||
doPerformCacheInitialization: boolean; | ||
}; | ||
dbApi: import("./ports/DbApi").DbApi; | ||
userApi: import("./ports/UserApi").UserApi; | ||
compileData: import("./ports/CompileData").CompileData; | ||
getWikidataSoftwareOptions: import("./ports/GetWikidataSoftwareOptions").GetWikidataSoftwareOptions; | ||
comptoirDuLibreApi: import("./ports/GetComptoirDuLibre").ComptoirDuLibreApi; | ||
getWikidataSoftware: import("./ports/GetWikidataSoftware").GetWikidataSoftware; | ||
getSoftwareLatestVersion: import("./ports/GetSoftwareLatestVersion").GetSoftwareLatestVersion; | ||
} & { | ||
evtAction: import("evt").NonPostableEvt<{ | ||
sliceName: "readWriteSillData"; | ||
} & { | ||
actionName: "updated"; | ||
} & { | ||
payload: { | ||
db: import("./ports/DbApi").Db; | ||
compiledData: import("./ports/CompileData").CompiledData<"private">; | ||
}; | ||
}>; | ||
}, import("redux").Action<string>>, getState: () => { | ||
readWriteSillData: { | ||
db: import("./ports/DbApi").Db; | ||
compiledData: import("./ports/CompileData").CompiledData<"private">; | ||
}; | ||
}, extraArgument: { | ||
createStoreParams: { | ||
gitDbApiParams: import("./adapters/dbApi").GitDbApiParams; | ||
keycloakUserApiParams: import("./adapters/userApi").KeycloakUserApiParams | undefined; | ||
githubPersonalAccessTokenForApiRateLimit: string; | ||
doPerPerformPeriodicalCompilation: boolean; | ||
doPerformCacheInitialization: boolean; | ||
}; | ||
dbApi: import("./ports/DbApi").DbApi; | ||
userApi: import("./ports/UserApi").UserApi; | ||
compileData: import("./ports/CompileData").CompileData; | ||
getWikidataSoftwareOptions: import("./ports/GetWikidataSoftwareOptions").GetWikidataSoftwareOptions; | ||
comptoirDuLibreApi: import("./ports/GetComptoirDuLibre").ComptoirDuLibreApi; | ||
getWikidataSoftware: import("./ports/GetWikidataSoftware").GetWikidataSoftware; | ||
getSoftwareLatestVersion: import("./ports/GetSoftwareLatestVersion").GetSoftwareLatestVersion; | ||
} & { | ||
evtAction: import("evt").NonPostableEvt<{ | ||
sliceName: "readWriteSillData"; | ||
} & { | ||
actionName: "updated"; | ||
} & { | ||
payload: { | ||
db: import("./ports/DbApi").Db; | ||
compiledData: import("./ports/CompileData").CompiledData<"private">; | ||
}; | ||
}>; | ||
}) => Promise<void>; | ||
updateAgentAbout: (params: { | ||
email: string; | ||
organization: string; | ||
agent: { | ||
email: string; | ||
organization: string; | ||
}; | ||
about: string | undefined; | ||
isPublic: boolean; | ||
}) => (dispatch: import("redux-thunk").ThunkDispatch<{ | ||
@@ -957,0 +1092,0 @@ readWriteSillData: { |
@@ -68,3 +68,2 @@ import type { PayloadAction } from "@reduxjs/toolkit"; | ||
})[]; | ||
isPublic: boolean; | ||
}; | ||
@@ -809,3 +808,3 @@ export type Instance = { | ||
}) => Promise<void>; | ||
getAgentAbout: (params: { | ||
getAgentIsPublic: (params: { | ||
email: string; | ||
@@ -862,11 +861,122 @@ }) => (dispatch: import("@reduxjs/toolkit").ThunkDispatch<{ | ||
}>; | ||
}) => { | ||
}) => boolean; | ||
getAgent: (params: { | ||
email: string; | ||
}) => (dispatch: import("@reduxjs/toolkit").ThunkDispatch<{ | ||
readWriteSillData: State; | ||
}, { | ||
createStoreParams: { | ||
gitDbApiParams: import("../adapters/dbApi").GitDbApiParams; | ||
keycloakUserApiParams: import("../adapters/userApi").KeycloakUserApiParams | undefined; | ||
githubPersonalAccessTokenForApiRateLimit: string; | ||
doPerPerformPeriodicalCompilation: boolean; | ||
doPerformCacheInitialization: boolean; | ||
}; | ||
dbApi: import("../ports/DbApi").DbApi; | ||
userApi: import("../ports/UserApi").UserApi; | ||
compileData: import("../ports/CompileData").CompileData; | ||
getWikidataSoftwareOptions: import("../ports/GetWikidataSoftwareOptions").GetWikidataSoftwareOptions; | ||
comptoirDuLibreApi: import("../ports/GetComptoirDuLibre").ComptoirDuLibreApi; | ||
getWikidataSoftware: import("../ports/GetWikidataSoftware").GetWikidataSoftware; | ||
getSoftwareLatestVersion: import("../ports/GetSoftwareLatestVersion").GetSoftwareLatestVersion; | ||
} & { | ||
evtAction: import("evt").NonPostableEvt<{ | ||
sliceName: "readWriteSillData"; | ||
} & { | ||
actionName: "updated"; | ||
} & { | ||
payload: State; | ||
}>; | ||
}, import("redux").Action<string>>, getState: () => { | ||
readWriteSillData: State; | ||
}, extraArgument: { | ||
createStoreParams: { | ||
gitDbApiParams: import("../adapters/dbApi").GitDbApiParams; | ||
keycloakUserApiParams: import("../adapters/userApi").KeycloakUserApiParams | undefined; | ||
githubPersonalAccessTokenForApiRateLimit: string; | ||
doPerPerformPeriodicalCompilation: boolean; | ||
doPerformCacheInitialization: boolean; | ||
}; | ||
dbApi: import("../ports/DbApi").DbApi; | ||
userApi: import("../ports/UserApi").UserApi; | ||
compileData: import("../ports/CompileData").CompileData; | ||
getWikidataSoftwareOptions: import("../ports/GetWikidataSoftwareOptions").GetWikidataSoftwareOptions; | ||
comptoirDuLibreApi: import("../ports/GetComptoirDuLibre").ComptoirDuLibreApi; | ||
getWikidataSoftware: import("../ports/GetWikidataSoftware").GetWikidataSoftware; | ||
getSoftwareLatestVersion: import("../ports/GetSoftwareLatestVersion").GetSoftwareLatestVersion; | ||
} & { | ||
evtAction: import("evt").NonPostableEvt<{ | ||
sliceName: "readWriteSillData"; | ||
} & { | ||
actionName: "updated"; | ||
} & { | ||
payload: State; | ||
}>; | ||
}) => Promise<Agent & { | ||
isPublic: boolean; | ||
about: string | undefined; | ||
}>; | ||
updateIsAgentProfilePublic: (params: { | ||
agent: { | ||
email: string; | ||
organization: string; | ||
}; | ||
isPublic: boolean; | ||
}; | ||
}) => (dispatch: import("@reduxjs/toolkit").ThunkDispatch<{ | ||
readWriteSillData: State; | ||
}, { | ||
createStoreParams: { | ||
gitDbApiParams: import("../adapters/dbApi").GitDbApiParams; | ||
keycloakUserApiParams: import("../adapters/userApi").KeycloakUserApiParams | undefined; | ||
githubPersonalAccessTokenForApiRateLimit: string; | ||
doPerPerformPeriodicalCompilation: boolean; | ||
doPerformCacheInitialization: boolean; | ||
}; | ||
dbApi: import("../ports/DbApi").DbApi; | ||
userApi: import("../ports/UserApi").UserApi; | ||
compileData: import("../ports/CompileData").CompileData; | ||
getWikidataSoftwareOptions: import("../ports/GetWikidataSoftwareOptions").GetWikidataSoftwareOptions; | ||
comptoirDuLibreApi: import("../ports/GetComptoirDuLibre").ComptoirDuLibreApi; | ||
getWikidataSoftware: import("../ports/GetWikidataSoftware").GetWikidataSoftware; | ||
getSoftwareLatestVersion: import("../ports/GetSoftwareLatestVersion").GetSoftwareLatestVersion; | ||
} & { | ||
evtAction: import("evt").NonPostableEvt<{ | ||
sliceName: "readWriteSillData"; | ||
} & { | ||
actionName: "updated"; | ||
} & { | ||
payload: State; | ||
}>; | ||
}, import("redux").Action<string>>, getState: () => { | ||
readWriteSillData: State; | ||
}, extraArgument: { | ||
createStoreParams: { | ||
gitDbApiParams: import("../adapters/dbApi").GitDbApiParams; | ||
keycloakUserApiParams: import("../adapters/userApi").KeycloakUserApiParams | undefined; | ||
githubPersonalAccessTokenForApiRateLimit: string; | ||
doPerPerformPeriodicalCompilation: boolean; | ||
doPerformCacheInitialization: boolean; | ||
}; | ||
dbApi: import("../ports/DbApi").DbApi; | ||
userApi: import("../ports/UserApi").UserApi; | ||
compileData: import("../ports/CompileData").CompileData; | ||
getWikidataSoftwareOptions: import("../ports/GetWikidataSoftwareOptions").GetWikidataSoftwareOptions; | ||
comptoirDuLibreApi: import("../ports/GetComptoirDuLibre").ComptoirDuLibreApi; | ||
getWikidataSoftware: import("../ports/GetWikidataSoftware").GetWikidataSoftware; | ||
getSoftwareLatestVersion: import("../ports/GetSoftwareLatestVersion").GetSoftwareLatestVersion; | ||
} & { | ||
evtAction: import("evt").NonPostableEvt<{ | ||
sliceName: "readWriteSillData"; | ||
} & { | ||
actionName: "updated"; | ||
} & { | ||
payload: State; | ||
}>; | ||
}) => Promise<void>; | ||
updateAgentAbout: (params: { | ||
email: string; | ||
organization: string; | ||
agent: { | ||
email: string; | ||
organization: string; | ||
}; | ||
about: string | undefined; | ||
isPublic: boolean; | ||
}) => (dispatch: import("@reduxjs/toolkit").ThunkDispatch<{ | ||
@@ -960,3 +1070,16 @@ readWriteSillData: State; | ||
}; | ||
aboutAndIsPublicByAgentEmail: ((state: { | ||
readWriteSillData: State; | ||
}) => Record<string, { | ||
isPublic: boolean; | ||
about: string | undefined; | ||
} | undefined>) & import("reselect").OutputSelectorFields<(args_0: State) => Record<string, { | ||
isPublic: boolean; | ||
about: string | undefined; | ||
} | undefined> & { | ||
clearCache: () => void; | ||
}> & { | ||
clearCache: () => void; | ||
}; | ||
}; | ||
export {}; |
@@ -391,20 +391,53 @@ "use strict"; | ||
}, | ||
"getAgentAbout": (params) => (...args) => { | ||
"getAgentIsPublic": (params) => (...args) => { | ||
var _a; | ||
const [, getState] = args; | ||
const { email } = params; | ||
const state = getState()[exports.name]; | ||
const agentRow = state.db.agentRows.find(agentRow => agentRow.email === email); | ||
return agentRow === undefined | ||
? { | ||
"about": undefined, | ||
"isPublic": false | ||
const { isPublic = false } = (_a = exports.selectors.aboutAndIsPublicByAgentEmail(getState())[email]) !== null && _a !== void 0 ? _a : {}; | ||
return isPublic; | ||
}, | ||
"getAgent": (params) => async (...args) => { | ||
var _a, _b, _c; | ||
const [, getState] = args; | ||
const { email } = params; | ||
const state = getState(); | ||
const { agent } = (() => { | ||
const agents = exports.selectors.agents(state); | ||
const agent = agents.find(agent => agent.email === email); | ||
return { agent }; | ||
})(); | ||
const { isPublic = false, about } = (_a = exports.selectors.aboutAndIsPublicByAgentEmail(state)[email]) !== null && _a !== void 0 ? _a : {}; | ||
return { | ||
"email": email, | ||
"organization": (_b = agent === null || agent === void 0 ? void 0 : agent.organization) !== null && _b !== void 0 ? _b : "", | ||
"declarations": (_c = agent === null || agent === void 0 ? void 0 : agent.declarations) !== null && _c !== void 0 ? _c : [], | ||
isPublic, | ||
about | ||
}; | ||
}, | ||
"updateIsAgentProfilePublic": (params) => async (...args) => { | ||
const [dispatch] = args; | ||
const { agent: { email, organization }, isPublic } = params; | ||
await dispatch(localThunks.transaction(async (newDb) => { | ||
const { agentRows } = newDb; | ||
let agentRow = agentRows.find(agentRow => agentRow.email === email); | ||
if (agentRow === undefined) { | ||
agentRow = { | ||
email, | ||
organization, | ||
"isPublic": false, | ||
"about": undefined | ||
}; | ||
agentRows.push(agentRow); | ||
} | ||
: { | ||
"about": agentRow.about, | ||
"isPublic": agentRow.isPublic | ||
agentRow.isPublic = isPublic; | ||
return { | ||
newDb, | ||
"commitMessage": `Making ${email} profile ${isPublic ? "public" : "private"}` | ||
}; | ||
})); | ||
}, | ||
"updateAgentAbout": (params) => async (...args) => { | ||
const [dispatch] = args; | ||
const { email, organization, about, isPublic } = params; | ||
const { agent: { email, organization }, about } = params; | ||
await dispatch(localThunks.transaction(async (newDb) => { | ||
@@ -422,7 +455,6 @@ const { agentRows } = newDb; | ||
} | ||
agentRow.isPublic = isPublic; | ||
agentRow.about = about; | ||
return { | ||
newDb, | ||
"commitMessage": `Updating ${email} profile` | ||
"commitMessage": `Updating ${email} about markdown text` | ||
}; | ||
@@ -682,6 +714,12 @@ })); | ||
], | ||
"organization": agentRow.organization, | ||
"isPublic": agentRow.isPublic | ||
"organization": agentRow.organization | ||
}; | ||
})); | ||
const aboutAndIsPublicByAgentEmail = (0, toolkit_2.createSelector)(sliceState, (state) => Object.fromEntries(state.db.agentRows.map(agentRow => [ | ||
agentRow.email, | ||
{ | ||
"isPublic": agentRow.isPublic, | ||
"about": agentRow.about | ||
} | ||
]))); | ||
const referentCount = (0, toolkit_2.createSelector)(agents, agents => agents | ||
@@ -700,5 +738,6 @@ .filter(agent => agent.declarations.find(declaration => declaration.declarationType === "referent") !== undefined) | ||
referentCount, | ||
compiledDataPublicJson | ||
compiledDataPublicJson, | ||
aboutAndIsPublicByAgentEmail | ||
}; | ||
})(); | ||
//# sourceMappingURL=readWriteSillData.js.map |
{ | ||
"name": "@codegouvfr/sill", | ||
"version": "1.15.2", | ||
"version": "1.16.0", | ||
"description": "The backend of etalab.gouv.fr/sill", | ||
@@ -5,0 +5,0 @@ "repository": { |
@@ -285,3 +285,3 @@ import type { ReturnType } from "tsafe"; | ||
}, Record<"agents", import("../core/usecases/readWriteSillData").Agent[]>>; | ||
updateAgentAbout: import("@trpc/server").BuildProcedure<"mutation", { | ||
updateIsAgentProfilePublic: import("@trpc/server").BuildProcedure<"mutation", { | ||
_config: import("@trpc/server").RootConfig<{ | ||
@@ -297,12 +297,28 @@ ctx: Context; | ||
isPublic: boolean; | ||
about?: string | undefined; | ||
}; | ||
_input_out: { | ||
isPublic: boolean; | ||
}; | ||
_output_in: typeof import("@trpc/server").unsetMarker; | ||
_output_out: typeof import("@trpc/server").unsetMarker; | ||
}, void>; | ||
updateAgentAbout: import("@trpc/server").BuildProcedure<"mutation", { | ||
_config: import("@trpc/server").RootConfig<{ | ||
ctx: Context; | ||
meta: object; | ||
errorShape: import("@trpc/server").DefaultErrorShape; | ||
transformer: typeof superjson; | ||
}>; | ||
_meta: object; | ||
_ctx_out: Context; | ||
_input_in: { | ||
about?: string | undefined; | ||
}; | ||
_input_out: { | ||
about?: string | undefined; | ||
}; | ||
_output_in: typeof import("@trpc/server").unsetMarker; | ||
_output_out: typeof import("@trpc/server").unsetMarker; | ||
}, void>; | ||
getAgentAbout: import("@trpc/server").BuildProcedure<"query", { | ||
getIsAgentProfilePublic: import("@trpc/server").BuildProcedure<"query", { | ||
_config: import("@trpc/server").RootConfig<{ | ||
@@ -325,5 +341,27 @@ ctx: Context; | ||
}, { | ||
about: string | undefined; | ||
isPublic: boolean; | ||
}>; | ||
getAgent: import("@trpc/server").BuildProcedure<"query", { | ||
_config: import("@trpc/server").RootConfig<{ | ||
ctx: Context; | ||
meta: object; | ||
errorShape: import("@trpc/server").DefaultErrorShape; | ||
transformer: typeof superjson; | ||
}>; | ||
_meta: object; | ||
_ctx_out: Context; | ||
_input_in: { | ||
email: string; | ||
}; | ||
_input_out: { | ||
email: string; | ||
}; | ||
_output_in: typeof import("@trpc/server").unsetMarker; | ||
_output_out: typeof import("@trpc/server").unsetMarker; | ||
}, { | ||
agent: import("../core/usecases/readWriteSillData").Agent & { | ||
isPublic: boolean; | ||
about: string | undefined; | ||
}; | ||
}>; | ||
getAllowedEmailRegexp: import("@trpc/server").BuildProcedure<"query", { | ||
@@ -330,0 +368,0 @@ _config: import("@trpc/server").RootConfig<{ |
@@ -228,5 +228,4 @@ "use strict"; | ||
}), | ||
"updateAgentAbout": t.procedure | ||
"updateIsAgentProfilePublic": t.procedure | ||
.input(zod_1.z.object({ | ||
"about": zod_1.z.union([zod_1.z.string(), zod_1.z.literal(undefined)]), | ||
"isPublic": zod_1.z.boolean() | ||
@@ -238,26 +237,55 @@ })) | ||
} | ||
const { about, isPublic } = input; | ||
await coreApi.functions.readWriteSillData.updateAgentAbout({ | ||
"email": user.email, | ||
"organization": user.organization, | ||
about, | ||
const { isPublic } = input; | ||
await coreApi.functions.readWriteSillData.updateIsAgentProfilePublic({ | ||
"agent": { | ||
"email": user.email, | ||
"organization": user.organization | ||
}, | ||
isPublic | ||
}); | ||
}), | ||
"getAgentAbout": t.procedure | ||
"updateAgentAbout": t.procedure | ||
.input(zod_1.z.object({ | ||
"email": zod_1.z.string() | ||
"about": zod_1.z.string().optional() | ||
})) | ||
.query(async ({ ctx: { user }, input }) => { | ||
.mutation(async ({ ctx: { user }, input }) => { | ||
if (user === undefined) { | ||
throw new server_1.TRPCError({ "code": "UNAUTHORIZED" }); | ||
} | ||
const { about } = input; | ||
await coreApi.functions.readWriteSillData.updateAgentAbout({ | ||
"agent": { | ||
"email": user.email, | ||
"organization": user.organization | ||
}, | ||
about | ||
}); | ||
}), | ||
"getIsAgentProfilePublic": t.procedure | ||
.input(zod_1.z.object({ | ||
"email": zod_1.z.string() | ||
})) | ||
.query(async ({ input }) => { | ||
const { email } = input; | ||
const { about, isPublic } = coreApi.functions.readWriteSillData.getAgentAbout({ | ||
const isPublic = coreApi.functions.readWriteSillData.getAgentIsPublic({ | ||
}); | ||
if (!isPublic && user.email !== email) { | ||
return { isPublic }; | ||
}), | ||
"getAgent": t.procedure | ||
.input(zod_1.z.object({ | ||
"email": zod_1.z.string() | ||
})) | ||
.query(async ({ ctx: { user }, input }) => { | ||
const { email } = input; | ||
const isPublic = coreApi.functions.readWriteSillData.getAgentIsPublic({ | ||
}); | ||
if (!isPublic && user === undefined) { | ||
throw new server_1.TRPCError({ "code": "UNAUTHORIZED" }); | ||
} | ||
return { about, isPublic }; | ||
const agent = await coreApi.functions.readWriteSillData.getAgent({ | ||
}); | ||
return { agent }; | ||
}), | ||
@@ -264,0 +292,0 @@ "getAllowedEmailRegexp": t.procedure.query(coreApi.extras.userApi.getAllowedEmailRegexp), |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const child_process_1 = require("child_process"); | ||
const dbApi_1 = require("../core/adapters/dbApi"); | ||
// Script to run that will make codegouvfr/sill-data-test is the same as codegouvfr/sill-data | ||
const tmpDirBasename = "tmp_x3dL4bZdj4dbq2Td"; | ||
const repoUrl = "https://github.com/codegouvfr/sill-data"; | ||
(0, child_process_1.execSync)([ | ||
`rm -rf ${tmpDirBasename}`, | ||
`git clone --depth 1 ${repoUrl} ${tmpDirBasename}`, | ||
`cd ${tmpDirBasename}`, | ||
`git remote set-url origin ${repoUrl}-test`, | ||
`git push -f`, | ||
`cd ..`, | ||
`rm -rf ${tmpDirBasename}`, | ||
`git clone --branch ${dbApi_1.compiledDataBranch} --depth 1 ${repoUrl} ${tmpDirBasename}`, | ||
`cd ${tmpDirBasename}`, | ||
`git remote set-url origin ${repoUrl}-test`, | ||
`git push -f`, | ||
`cd ..`, | ||
`rm -rf ${tmpDirBasename}` | ||
].join(" && sleep 1 && ")); | ||
console.log("https://github.com/codegouvfr/sill-data-test"); | ||
function executeCommand(command) { | ||
console.log(`Executing: ${command}`); | ||
(0, child_process_1.execSync)(command, { stdio: "inherit" }); | ||
} | ||
try { | ||
// Remove the temporary directory if it exists | ||
executeCommand(`rm -rf ${tmpDirBasename}`); | ||
// Clone the entire repo (including all branches and commit history) | ||
executeCommand(`git clone ${repoUrl} ${tmpDirBasename}`); | ||
// Change directory | ||
process.chdir(tmpDirBasename); | ||
// Fetch all branches from origin | ||
executeCommand(`git fetch origin`); | ||
// Change remote URL | ||
executeCommand(`git remote set-url origin ${repoUrl}-test`); | ||
// Push all branches to the new origin | ||
executeCommand(`git push -f --all`); | ||
// Change directory back | ||
process.chdir(".."); | ||
// Remove the temporary directory | ||
executeCommand(`rm -rf ${tmpDirBasename}`); | ||
} | ||
catch (error) { | ||
console.error("An error occurred:", String(error)); | ||
} | ||
//# sourceMappingURL=reset-data-test.js.map |
@@ -86,3 +86,2 @@ import structuredClone from "@ungap/structured-clone"; | ||
declarations: (DeclarationFormData & { softwareName: string })[]; | ||
isPublic: boolean; | ||
}; | ||
@@ -771,5 +770,5 @@ | ||
}, | ||
"getAgentAbout": | ||
"getAgentIsPublic": | ||
(params: { email: string }) => | ||
(...args): { about: string | undefined; isPublic: boolean } => { | ||
(...args): boolean => { | ||
const [, getState] = args; | ||
@@ -779,22 +778,78 @@ | ||
const state = getState()[name]; | ||
const { isPublic = false } = selectors.aboutAndIsPublicByAgentEmail(getState())[email] ?? {}; | ||
const agentRow = state.db.agentRows.find(agentRow => agentRow.email === email); | ||
return isPublic; | ||
}, | ||
"getAgent": | ||
(params: { email: string }) => | ||
async (...args): Promise<Agent & { isPublic: boolean; about: string | undefined }> => { | ||
const [, getState] = args; | ||
return agentRow === undefined | ||
? { | ||
"about": undefined, | ||
"isPublic": false | ||
} | ||
: { | ||
"about": agentRow.about, | ||
"isPublic": agentRow.isPublic | ||
}; | ||
const { email } = params; | ||
const state = getState(); | ||
const { agent } = (() => { | ||
const agents = selectors.agents(state); | ||
const agent = agents.find(agent => agent.email === email); | ||
return { agent }; | ||
})(); | ||
const { isPublic = false, about } = selectors.aboutAndIsPublicByAgentEmail(state)[email] ?? {}; | ||
return { | ||
"email": email, | ||
"organization": agent?.organization ?? "", | ||
"declarations": agent?.declarations ?? [], | ||
isPublic, | ||
about | ||
}; | ||
}, | ||
"updateIsAgentProfilePublic": | ||
(params: { agent: { email: string; organization: string }; isPublic: boolean }) => | ||
async (...args) => { | ||
const [dispatch] = args; | ||
const { | ||
agent: { email, organization }, | ||
isPublic | ||
} = params; | ||
await dispatch( | ||
localThunks.transaction(async newDb => { | ||
const { agentRows } = newDb; | ||
let agentRow = agentRows.find(agentRow => agentRow.email === email); | ||
if (agentRow === undefined) { | ||
agentRow = { | ||
email, | ||
organization, | ||
"isPublic": false, | ||
"about": undefined | ||
}; | ||
agentRows.push(agentRow); | ||
} | ||
agentRow.isPublic = isPublic; | ||
return { | ||
newDb, | ||
"commitMessage": `Making ${email} profile ${isPublic ? "public" : "private"}` | ||
}; | ||
}) | ||
); | ||
}, | ||
"updateAgentAbout": | ||
(params: { email: string; organization: string; about: string | undefined; isPublic: boolean }) => | ||
(params: { agent: { email: string; organization: string }; about: string | undefined }) => | ||
async (...args) => { | ||
const [dispatch] = args; | ||
const { email, organization, about, isPublic } = params; | ||
const { | ||
agent: { email, organization }, | ||
about | ||
} = params; | ||
@@ -818,3 +873,2 @@ await dispatch( | ||
agentRow.isPublic = isPublic; | ||
agentRow.about = about; | ||
@@ -824,3 +878,3 @@ | ||
newDb, | ||
"commitMessage": `Updating ${email} profile` | ||
"commitMessage": `Updating ${email} about markdown text` | ||
}; | ||
@@ -1173,4 +1227,3 @@ }) | ||
], | ||
"organization": agentRow.organization, | ||
"isPublic": agentRow.isPublic | ||
"organization": agentRow.organization | ||
}; | ||
@@ -1180,2 +1233,16 @@ }) | ||
const aboutAndIsPublicByAgentEmail = createSelector( | ||
sliceState, | ||
(state): Record<string, { isPublic: boolean; about: string | undefined } | undefined> => | ||
Object.fromEntries( | ||
state.db.agentRows.map(agentRow => [ | ||
agentRow.email, | ||
{ | ||
"isPublic": agentRow.isPublic, | ||
"about": agentRow.about | ||
} | ||
]) | ||
) | ||
); | ||
const referentCount = createSelector( | ||
@@ -1204,4 +1271,5 @@ agents, | ||
referentCount, | ||
compiledDataPublicJson | ||
compiledDataPublicJson, | ||
aboutAndIsPublicByAgentEmail | ||
}; | ||
})(); |
@@ -273,6 +273,5 @@ import type { ReturnType } from "tsafe"; | ||
}), | ||
"updateAgentAbout": t.procedure | ||
"updateIsAgentProfilePublic": t.procedure | ||
.input( | ||
z.object({ | ||
"about": z.union([z.string(), z.literal(undefined)]), | ||
"isPublic": z.boolean() | ||
@@ -286,18 +285,19 @@ }) | ||
const { about, isPublic } = input; | ||
const { isPublic } = input; | ||
await coreApi.functions.readWriteSillData.updateAgentAbout({ | ||
"email": user.email, | ||
"organization": user.organization, | ||
about, | ||
await coreApi.functions.readWriteSillData.updateIsAgentProfilePublic({ | ||
"agent": { | ||
"email": user.email, | ||
"organization": user.organization | ||
}, | ||
isPublic | ||
}); | ||
}), | ||
"getAgentAbout": t.procedure | ||
"updateAgentAbout": t.procedure | ||
.input( | ||
z.object({ | ||
"email": z.string() | ||
"about": z.string().optional() | ||
}) | ||
) | ||
.query(async ({ ctx: { user }, input }) => { | ||
.mutation(async ({ ctx: { user }, input }) => { | ||
if (user === undefined) { | ||
@@ -307,13 +307,49 @@ throw new TRPCError({ "code": "UNAUTHORIZED" }); | ||
const { about } = input; | ||
await coreApi.functions.readWriteSillData.updateAgentAbout({ | ||
"agent": { | ||
"email": user.email, | ||
"organization": user.organization | ||
}, | ||
about | ||
}); | ||
}), | ||
"getIsAgentProfilePublic": t.procedure | ||
.input( | ||
z.object({ | ||
"email": z.string() | ||
}) | ||
) | ||
.query(async ({ input }) => { | ||
const { email } = input; | ||
const { about, isPublic } = coreApi.functions.readWriteSillData.getAgentAbout({ | ||
const isPublic = coreApi.functions.readWriteSillData.getAgentIsPublic({ | ||
}); | ||
if (!isPublic && user.email !== email) { | ||
return { isPublic }; | ||
}), | ||
"getAgent": t.procedure | ||
.input( | ||
z.object({ | ||
"email": z.string() | ||
}) | ||
) | ||
.query(async ({ ctx: { user }, input }) => { | ||
const { email } = input; | ||
const isPublic = coreApi.functions.readWriteSillData.getAgentIsPublic({ | ||
}); | ||
if (!isPublic && user === undefined) { | ||
throw new TRPCError({ "code": "UNAUTHORIZED" }); | ||
} | ||
return { about, isPublic }; | ||
const agent = await coreApi.functions.readWriteSillData.getAgent({ | ||
}); | ||
return { agent }; | ||
}), | ||
@@ -320,0 +356,0 @@ "getAllowedEmailRegexp": t.procedure.query(coreApi.extras.userApi.getAllowedEmailRegexp), |
import { execSync } from "child_process"; | ||
import { compiledDataBranch } from "../core/adapters/dbApi"; | ||
// Script to run that will make codegouvfr/sill-data-test is the same as codegouvfr/sill-data | ||
const tmpDirBasename = "tmp_x3dL4bZdj4dbq2Td"; | ||
const repoUrl = "https://github.com/codegouvfr/sill-data"; | ||
execSync( | ||
[ | ||
`rm -rf ${tmpDirBasename}`, | ||
`git clone --depth 1 ${repoUrl} ${tmpDirBasename}`, | ||
`cd ${tmpDirBasename}`, | ||
`git remote set-url origin ${repoUrl}-test`, | ||
`git push -f`, | ||
`cd ..`, | ||
`rm -rf ${tmpDirBasename}`, | ||
`git clone --branch ${compiledDataBranch} --depth 1 ${repoUrl} ${tmpDirBasename}`, | ||
`cd ${tmpDirBasename}`, | ||
`git remote set-url origin ${repoUrl}-test`, | ||
`git push -f`, | ||
`cd ..`, | ||
`rm -rf ${tmpDirBasename}` | ||
].join(" && sleep 1 && ") | ||
); | ||
function executeCommand(command: string) { | ||
console.log(`Executing: ${command}`); | ||
execSync(command, { stdio: "inherit" }); | ||
} | ||
console.log("https://github.com/codegouvfr/sill-data-test"); | ||
try { | ||
// Remove the temporary directory if it exists | ||
executeCommand(`rm -rf ${tmpDirBasename}`); | ||
// Clone the entire repo (including all branches and commit history) | ||
executeCommand(`git clone ${repoUrl} ${tmpDirBasename}`); | ||
// Change directory | ||
process.chdir(tmpDirBasename); | ||
// Fetch all branches from origin | ||
executeCommand(`git fetch origin`); | ||
// Change remote URL | ||
executeCommand(`git remote set-url origin ${repoUrl}-test`); | ||
// Push all branches to the new origin | ||
executeCommand(`git push -f --all`); | ||
// Change directory back | ||
process.chdir(".."); | ||
// Remove the temporary directory | ||
executeCommand(`rm -rf ${tmpDirBasename}`); | ||
} catch (error) { | ||
console.error("An error occurred:", String(error)); | ||
} |
Sorry, the diff of this file is not supported yet
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
706741
12953