diff --git a/apps/client/src/components/ClusterForm.vue b/apps/client/src/components/ClusterForm.vue
index 81f51ebcaf..dac6e0b88f 100644
--- a/apps/client/src/components/ClusterForm.vue
+++ b/apps/client/src/components/ClusterForm.vue
@@ -73,7 +73,7 @@ const clusterToDelete = ref('')
const isDeletingCluster = ref(false)
if (!localCluster.value.zoneId && props.allZones.length) {
- localCluster.value.zoneId = props.allZones[0].id
+ localCluster.value.zoneId = props.allZones[0]!.id
}
const schema = computed(() => {
@@ -113,7 +113,7 @@ function updateKubeconfig(files: FileList) {
snackbarStore.setMessage('Pas de current-context. Choisissez un contexte.')
}
}
- reader.readAsText(files[0])
+ reader.readAsText(files[0]!)
} catch (error) {
// @ts-ignore
kConfigError.value = error?.message
diff --git a/apps/client/src/components/ProjectClustersInfos.vue b/apps/client/src/components/ProjectClustersInfos.vue
index d7af0874ed..ce7277a681 100644
--- a/apps/client/src/components/ProjectClustersInfos.vue
+++ b/apps/client/src/components/ProjectClustersInfos.vue
@@ -34,7 +34,7 @@ onMounted(async () => {
- : {{ zoneStore.zonesById[cluster.zoneId].label }}
+ : {{ zoneStore.zonesById[cluster.zoneId]?.label }}
{
if (!curr.section) curr.section = 'default'
if (curr.section in acc.items) {
- acc.items[curr.section].push(curr as PluginConfigItem)
+ acc.items[curr.section]!.push(curr as PluginConfigItem)
} else {
acc.items[curr.section] = [curr as PluginConfigItem]
acc.sectionNumber++
@@ -55,7 +55,7 @@ const updated = ref({})
function update(data: { value: string, key: string, plugin: string }) {
if (!updated.value[data.plugin]) updated.value[data.plugin] = {}
- updated.value[data.plugin][data.key] = data.value
+ updated.value[data.plugin]![data.key] = data.value
}
function getItemsToShowLength(items: PluginConfigItem[] | (PluginConfigItem & { value: any })[] | undefined, scope: PermissionTarget): number | undefined {
diff --git a/apps/client/src/components/TeamCt.vue b/apps/client/src/components/TeamCt.vue
index d850569e77..381036f2be 100644
--- a/apps/client/src/components/TeamCt.vue
+++ b/apps/client/src/components/TeamCt.vue
@@ -62,7 +62,7 @@ const retrieveUsersToAdd = pDebounce(async (letters: LettersQuery['letters']) =>
if (letters.length < 3) return
// Ne pas relancer de requête à chaque lettre ajoutée si aucun user ne correspond aux premières lettres données
if (lettersNotMatching.value && letters.includes(lettersNotMatching.value) && !usersToAdd.value?.length) return
- usersToAdd.value = await projectStore.projectsBySlug[props.project.slug].Members.getCandidateUsers(letters)
+ usersToAdd.value = await projectStore.projectsBySlug[props.project.slug]?.Members.getCandidateUsers(letters)
// Stockage des lettres qui ne renvoient aucun résultat
if (!usersToAdd.value?.length) {
lettersNotMatching.value = letters
diff --git a/apps/client/src/stores/admin-role.ts b/apps/client/src/stores/admin-role.ts
index fa70004e0f..7bfb6e75be 100644
--- a/apps/client/src/stores/admin-role.ts
+++ b/apps/client/src/stores/admin-role.ts
@@ -12,14 +12,14 @@ export const useAdminRoleStore = defineStore('adminRole', () => {
const countMembersRoles = async () => {
memberCounts.value
- = await apiClient.AdminRoles.adminRoleMemberCounts().then((res: any) =>
+ = await apiClient.AdminRoles.adminRoleMemberCounts().then((res) =>
extractData(res, 200),
)
return memberCounts.value
}
const listRoles = async () => {
- roles.value = await apiClient.AdminRoles.listAdminRoles().then((response: any) =>
+ roles.value = await apiClient.AdminRoles.listAdminRoles().then((response) =>
extractData(response, 200),
)
if (AdminAuthorized.ListRoles(userStore.adminPerms)) {
@@ -31,12 +31,12 @@ export const useAdminRoleStore = defineStore('adminRole', () => {
const createRole = async () => {
roles.value = await apiClient.AdminRoles.createAdminRole({
body: { name: 'Nouveau rôle' },
- }).then((res: any) => extractData(res, 201))
+ }).then((res) => extractData(res, 201))
}
const deleteRole = async (roleId: AdminRole['id']) => {
await apiClient.AdminRoles.deleteAdminRole({ params: { roleId } }).then(
- (res: any) => extractData(res, 204),
+ (res) => extractData(res, 204),
)
await listRoles()
}
@@ -46,7 +46,7 @@ export const useAdminRoleStore = defineStore('adminRole', () => {
) => {
roles.value = await apiClient.AdminRoles.patchAdminRoles({
body,
- }).then((res: any) => extractData(res, 200))
+ }).then((res) => extractData(res, 200))
}
return {
diff --git a/apps/client/src/stores/admin-token.ts b/apps/client/src/stores/admin-token.ts
index 3b76dc2fe8..a6b4d15f07 100644
--- a/apps/client/src/stores/admin-token.ts
+++ b/apps/client/src/stores/admin-token.ts
@@ -7,21 +7,21 @@ export const useAdminTokenStore = defineStore('adminToken', () => {
query: typeof adminTokenContract.listAdminTokens.query._type = {},
) => {
return apiClient.AdminTokens.listAdminTokens({ query }).then(
- (response: any) => extractData(response, 200),
+ (response) => extractData(response, 200),
)
}
const createToken = async (
body: typeof adminTokenContract.createAdminToken.body._type,
) => {
- return apiClient.AdminTokens.createAdminToken({ body }).then((res: any) =>
+ return apiClient.AdminTokens.createAdminToken({ body }).then((res) =>
extractData(res, 201),
)
}
const deleteToken = async (tokenId: AdminToken['id']) => {
await apiClient.AdminTokens.deleteAdminToken({ params: { tokenId } }).then(
- (res: any) => extractData(res, 204),
+ (res) => extractData(res, 204),
)
}
diff --git a/apps/client/src/stores/cluster.ts b/apps/client/src/stores/cluster.ts
index 3f94777f2b..3bd9e26b68 100644
--- a/apps/client/src/stores/cluster.ts
+++ b/apps/client/src/stores/cluster.ts
@@ -13,28 +13,28 @@ export const useClusterStore = defineStore('cluster', () => {
const getClusters = async () => {
clusters.value = await apiClient.Clusters.listClusters().then(
- (response: any) => extractData(response, 200),
+ (response) => extractData(response, 200),
)
return clusters.value
}
const getClusterDetails = async (clusterId: Cluster['id']) =>
apiClient.Clusters.getClusterDetails({ params: { clusterId } }).then(
- (response: any) => extractData(response, 200),
+ (response) => extractData(response, 200),
)
const getClusterUsage = async (clusterId: Cluster['id']) =>
apiClient.Clusters.getClusterUsage({ params: { clusterId } }).then(
- (response: any) => extractData(response, 200),
+ (response) => extractData(response, 200),
)
const getClusterAssociatedEnvironments = (clusterId: Cluster['id']) =>
apiClient.Clusters.getClusterEnvironments({ params: { clusterId } }).then(
- (response: any) => extractData(response, 200),
+ (response) => extractData(response, 200),
)
const addCluster = (cluster: CreateClusterBody) =>
- apiClient.Clusters.createCluster({ body: cluster }).then((response: any) =>
+ apiClient.Clusters.createCluster({ body: cluster }).then((response) =>
extractData(response, 201),
)
@@ -43,12 +43,12 @@ export const useClusterStore = defineStore('cluster', () => {
...body
}: UpdateClusterBody & { id: Cluster['id'] }) =>
apiClient.Clusters.updateCluster({ body, params: { clusterId: id } }).then(
- (response: any) => extractData(response, 200),
+ (response) => extractData(response, 200),
)
const deleteCluster = (clusterId: Cluster['id']) =>
apiClient.Clusters.deleteCluster({ params: { clusterId } }).then(
- (response: any) => extractData(response, 204),
+ (response) => extractData(response, 204),
)
return {
diff --git a/apps/client/src/stores/log.ts b/apps/client/src/stores/log.ts
index 3b1266cc48..ef8dee8453 100644
--- a/apps/client/src/stores/log.ts
+++ b/apps/client/src/stores/log.ts
@@ -10,14 +10,14 @@ export const useLogStore = defineStore('log', () => {
const getAllLogs = async ({ offset, limit }: GetLogsQuery = { offset: 0, limit: 100 }) => {
const res = await apiClient.Logs.getLogs({ query: { offset, limit, clean: false } })
- .then((response: any) => extractData(response, 200))
+ .then((response) => extractData(response, 200))
count.value = res.total
logs.value = res.logs as Log[]
}
const listLogs = async ({ offset, limit, clean, projectId }: GetLogsQuery = { offset: 0, limit: 10 }) => {
return apiClient.Logs.getLogs({ query: { offset, limit, clean, projectId } })
- .then((response: any) => extractData(response, 200))
+ .then((response) => extractData(response, 200))
}
return {
diff --git a/apps/client/src/stores/plugins.ts b/apps/client/src/stores/plugins.ts
index 99dd9f7abd..f70ed31eaa 100644
--- a/apps/client/src/stores/plugins.ts
+++ b/apps/client/src/stores/plugins.ts
@@ -6,10 +6,10 @@ export const usePluginsConfigStore = defineStore('plugins', () => {
const services: ProjectService[] = []
const getPluginsConfig = () => apiClient.SystemPlugin.getPluginsConfig()
- .then((response: any) => extractData(response, 200))
+ .then((response) => extractData(response, 200))
const updatePluginsConfig = (body: PluginsUpdateBody) => apiClient.SystemPlugin.updatePluginsConfig({ body })
- .then((response: any) => extractData(response, 204))
+ .then((response) => extractData(response, 204))
return {
services,
diff --git a/apps/client/src/stores/project.ts b/apps/client/src/stores/project.ts
index 44e59d56a8..57cf003766 100644
--- a/apps/client/src/stores/project.ts
+++ b/apps/client/src/stores/project.ts
@@ -38,7 +38,7 @@ export const useProjectStore = defineStore('project', () => {
const updateStore = async (projectsRecieved: ProjectV2[]) => {
return projectsRecieved.map((project) => {
if (project.slug in projectsBySlug.value) {
- return projectsBySlug.value[project.slug].Commands.updateData(project)
+ return projectsBySlug.value[project.slug]!.Commands.updateData(project)
}
const newProject = new Project(project)
projectsBySlug.value[project.slug] = newProject
@@ -49,13 +49,13 @@ export const useProjectStore = defineStore('project', () => {
const selectFromStore = (slugs: ProjectV2['slug'][]) => {
return slugs
.filter(slug => slug in projectsBySlug.value)
- .map(slug => projectsBySlug.value[slug])
+ .map(slug => projectsBySlug.value[slug]!)
}
const getProject = async (projectId: ProjectV2['id']) => {
const res = await apiClient.Projects.getProject({
params: { projectId },
- }).then((response: any) => extractData(response, 200))
+ }).then((response) => extractData(response, 200))
return (await updateStore([res]))[0]
}
@@ -66,16 +66,17 @@ export const useProjectStore = defineStore('project', () => {
},
) => {
const res = await apiClient.Projects.listProjects({ query }).then(
- (response: any) => extractData(response, 200),
+ (response) => extractData(response, 200),
)
await updateStore(res)
- return selectFromStore(res.map((project: any) => project.slug))
+ const slugs = res.map((project) => project.slug as ProjectV2['slug'])
+ return selectFromStore(slugs)
}
const listMyProjects = pDebounce(async () => {
const res = await apiClient.Projects.listProjects({
query: { filter: 'member', statusNotIn: 'archived' },
- }).then((response: any) => extractData(response, 200))
+ }).then((response) => extractData(response, 200))
for (const storedProject of myProjects.value) {
if (
!res.some((responseProject: any) => responseProject.id === storedProject.id)
@@ -89,14 +90,14 @@ export const useProjectStore = defineStore('project', () => {
const createProject = async (body: CreateProjectBody) => {
const project = await apiClient.Projects.createProject({ body }).then(
- (response: any) => extractData(response, 201),
+ (response) => extractData(response, 201),
)
projectsBySlug.value[project.slug] = new Project(project)
return project
}
const generateProjectsData = () =>
- apiClient.Projects.getProjectsData().then((response: any) =>
+ apiClient.Projects.getProjectsData().then((response) =>
extractData(response, 200),
)
diff --git a/apps/client/src/stores/service-chain.ts b/apps/client/src/stores/service-chain.ts
index 802a594e0d..3932be22ec 100644
--- a/apps/client/src/stores/service-chain.ts
+++ b/apps/client/src/stores/service-chain.ts
@@ -17,7 +17,7 @@ export const useServiceChainStore = defineStore('serviceChain', () => {
const getServiceChainsList = async () => {
serviceChains.value
- = await apiClient.ServiceChains.listServiceChains().then((response: any) =>
+ = await apiClient.ServiceChains.listServiceChains().then((response) =>
extractData(response, 200),
)
return serviceChains.value
@@ -26,14 +26,14 @@ export const useServiceChainStore = defineStore('serviceChain', () => {
const getServiceChainDetails = async (serviceChainId: ServiceChain['id']) =>
apiClient.ServiceChains.getServiceChainDetails({
params: { serviceChainId },
- }).then((response: any) =>
+ }).then((response) =>
ServiceChainDetailsSchema.parse(extractData(response, 200)),
)
const getServiceChainFlows = async (serviceChainId: ServiceChain['id']) =>
apiClient.ServiceChains.getServiceChainFlows({
params: { serviceChainId },
- }).then((response: any) =>
+ }).then((response) =>
ServiceChainFlowsSchema.parse(extractData(response, 200)),
)
diff --git a/apps/client/src/stores/services-monitor.ts b/apps/client/src/stores/services-monitor.ts
index d810ef328b..2534b47e8d 100644
--- a/apps/client/src/stores/services-monitor.ts
+++ b/apps/client/src/stores/services-monitor.ts
@@ -87,7 +87,7 @@ export const useServiceStore = defineStore('serviceMonitor', () => {
services.value = await (displayCause.value
? apiClient.Services.getCompleteServiceHealth()
: apiClient.Services.getServiceHealth())
- .then((res: any) => extractData(res, 200))
+ .then((res) => extractData(res, 200))
callStastus.value = 'ok'
} catch {
callStastus.value = 'error'
@@ -96,7 +96,7 @@ export const useServiceStore = defineStore('serviceMonitor', () => {
const refreshServicesHealth = async () => {
await apiClient.Services.refreshServiceHealth()
- .then((res: any) => extractData(res, 200))
+ .then((res) => extractData(res, 200))
return checkServicesHealth()
}
diff --git a/apps/client/src/stores/stage.ts b/apps/client/src/stores/stage.ts
index de6d3824bf..37583cf723 100644
--- a/apps/client/src/stores/stage.ts
+++ b/apps/client/src/stores/stage.ts
@@ -13,25 +13,25 @@ export const useStageStore = defineStore('stage', () => {
const getAllStages = async () => {
stages.value = await apiClient.Stages.listStages()
- .then((response: any) => extractData(response, 200))
+ .then((response) => extractData(response, 200))
return stages.value
}
const getStageAssociatedEnvironments = (stageId: string) =>
apiClient.Stages.getStageEnvironments({ params: { stageId } })
- .then((response: any) => extractData(response, 200))
+ .then((response) => extractData(response, 200))
const addStage = (body: CreateStageBody) =>
apiClient.Stages.createStage({ body })
- .then((response: any) => extractData(response, 201))
+ .then((response) => extractData(response, 201))
const updateStage = (stageId: string, body: UpdateStageBody) =>
apiClient.Stages.updateStage({ params: { stageId }, body })
- .then((response: any) => extractData(response, 200))
+ .then((response) => extractData(response, 200))
const deleteStage = (stageId: string) =>
apiClient.Stages.deleteStage({ params: { stageId } })
- .then((response: any) => extractData(response, 204))
+ .then((response) => extractData(response, 204))
return {
stages,
diff --git a/apps/client/src/stores/system-settings.ts b/apps/client/src/stores/system-settings.ts
index 8eebac262e..5dd422bf0a 100644
--- a/apps/client/src/stores/system-settings.ts
+++ b/apps/client/src/stores/system-settings.ts
@@ -15,12 +15,12 @@ export const useSystemSettingsStore = defineStore('systemSettings', () => {
const listSystemSettings = async (query: typeof systemSettingsContract.listSystemSettings.query._type = {}) => {
systemSettings.value = await apiClient.SystemSettings.listSystemSettings(query)
- .then((response: any) => extractData(response, 200))
+ .then((response) => extractData(response, 200))
}
const upsertSystemSetting = async (newSystemSetting: UpsertSystemSettingBody) => {
const res = await apiClient.SystemSettings.upsertSystemSetting({ body: newSystemSetting })
- .then((response: any) => extractData(response, 201))
+ .then((response) => extractData(response, 201))
systemSettings.value = systemSettings.value
.toSpliced(systemSettings.value
.findIndex(systemSetting => systemSetting.key === res.key), 1, res)
diff --git a/apps/client/src/stores/token.ts b/apps/client/src/stores/token.ts
index d19b832333..20d1f63209 100644
--- a/apps/client/src/stores/token.ts
+++ b/apps/client/src/stores/token.ts
@@ -8,7 +8,7 @@ import { apiClient, extractData } from '../api/xhr-client.js'
export const useTokenStore = defineStore('token', () => {
const listPersonalAccessTokens = async () => {
return apiClient.PersonalAccessTokens.listPersonalAccessTokens().then(
- (response: any) => extractData(response, 200),
+ (response) => extractData(response, 200),
)
}
@@ -17,7 +17,7 @@ export const useTokenStore = defineStore('token', () => {
) => {
return apiClient.PersonalAccessTokens.createPersonalAccessToken({
body,
- }).then((res: any) => extractData(res, 201))
+ }).then((res) => extractData(res, 201))
}
const deletePersonalAccessToken = async (
@@ -25,7 +25,7 @@ export const useTokenStore = defineStore('token', () => {
) => {
await apiClient.PersonalAccessTokens.deletePersonalAccessToken({
params: { tokenId },
- }).then((res: any) => extractData(res, 204))
+ }).then((res) => extractData(res, 204))
}
return {
diff --git a/apps/client/src/stores/user.ts b/apps/client/src/stores/user.ts
index f860e6d037..baed6e8b81 100644
--- a/apps/client/src/stores/user.ts
+++ b/apps/client/src/stores/user.ts
@@ -27,7 +27,7 @@ export const useUserStore = defineStore('user', () => {
userProfile.value = getUserProfile()
await systemSettingsStore.listSystemSettings().catch(() => undefined)
await apiClient.Users.auth()
- .then((res: any) => apiAuthInfos.value = extractData(res, 200))
+ .then((res) => apiAuthInfos.value = extractData(res, 200))
}
const setIsLoggedIn = async () => {
diff --git a/apps/client/src/stores/users.ts b/apps/client/src/stores/users.ts
index 4bacc644da..bef344176d 100644
--- a/apps/client/src/stores/users.ts
+++ b/apps/client/src/stores/users.ts
@@ -5,15 +5,15 @@ import { apiClient, extractData } from '@/api/xhr-client.js'
export const useUsersStore = defineStore('users', () => {
const listUsers = async (query: typeof userContract.getAllUsers.query._input) =>
apiClient.Users.getAllUsers({ query })
- .then((res: any) => extractData(res, 200))
+ .then((res) => extractData(res, 200))
const listMatchingUsers = async (query: typeof userContract.getMatchingUsers.query._type) =>
apiClient.Users.getMatchingUsers({ query })
- .then((res: any) => extractData(res, 200))
+ .then((res) => extractData(res, 200))
const patchUsers = async (body: typeof userContract.patchUsers.body._type) =>
apiClient.Users.patchUsers({ body })
- .then((res: any) => extractData(res, 200))
+ .then((res) => extractData(res, 200))
return {
listUsers,
diff --git a/apps/client/src/stores/zone.ts b/apps/client/src/stores/zone.ts
index 0c81a3e0f1..3052b5590c 100644
--- a/apps/client/src/stores/zone.ts
+++ b/apps/client/src/stores/zone.ts
@@ -13,21 +13,21 @@ export const useZoneStore = defineStore('zone', () => {
const getAllZones = async () => {
zones.value = await apiClient.Zones.listZones()
- .then((response: any) => extractData(response, 200))
+ .then((response) => extractData(response, 200))
return zones.value
}
const createZone = (body: CreateZoneBody) =>
apiClient.Zones.createZone({ body })
- .then((response: any) => extractData(response, 201))
+ .then((response) => extractData(response, 201))
const updateZone = (zoneId: Zone['id'], data: UpdateZoneBody) =>
apiClient.Zones.updateZone({ body: data, params: { zoneId } })
- .then((response: any) => extractData(response, 200))
+ .then((response) => extractData(response, 200))
const deleteZone = (zoneId: Zone['id']) =>
apiClient.Zones.deleteZone({ params: { zoneId } })
- .then((response: any) => extractData(response, 204))
+ .then((response) => extractData(response, 204))
return {
zones,
diff --git a/apps/client/src/utils/func.ts b/apps/client/src/utils/func.ts
index 159a7c8dcf..93fda83ea2 100644
--- a/apps/client/src/utils/func.ts
+++ b/apps/client/src/utils/func.ts
@@ -82,7 +82,7 @@ export function toKebabCase(value: string) {
*/
export function localeParseFloat(s: string): number {
// Remove thousand separators, and put a point where the decimal separator occurs
- const delocalizedInput = s.replaceAll(THOUSANDS_SEPARATOR, '').replaceAll(DECIMAL_SEPARATOR, '.')
+ const delocalizedInput = s.replaceAll(THOUSANDS_SEPARATOR ?? '', '').replaceAll(DECIMAL_SEPARATOR ?? '.', '.')
// Now it can be parsed
return Number.parseFloat(delocalizedInput)
}
@@ -101,7 +101,8 @@ export function swapItems(items: T[], index: number, direction: -1 | 1): T[]
const reordered = [...items]
const moved = reordered[index]
- reordered[index] = reordered[target]
+ if (!moved) return items
+ reordered[index] = reordered[target]!
reordered[target] = moved
return reordered
}
diff --git a/apps/client/src/utils/project-utils.ts b/apps/client/src/utils/project-utils.ts
index e45746f660..c9c412bae6 100644
--- a/apps/client/src/utils/project-utils.ts
+++ b/apps/client/src/utils/project-utils.ts
@@ -150,7 +150,7 @@ export class Project implements ProjectV2 {
const callback = this.addOperation('update')
try {
const project = await apiClient.Projects.updateProject({ body: data, params: { projectId: this.id } })
- .then((response: any) => extractData(response, 200))
+ .then((response) => extractData(response, 200))
.finally(() => callback())
return this.Commands.updateData(project)
} finally {
@@ -167,7 +167,7 @@ export class Project implements ProjectV2 {
},
refresh: async () => {
const project = await apiClient.Projects.getProject({ params: { projectId: this.id } })
- .then((response: any) => extractData(response, 200))
+ .then((response) => extractData(response, 200))
this.Commands.updateData(project)
await Promise.all([
this.Repositories.list(),
@@ -179,7 +179,7 @@ export class Project implements ProjectV2 {
const callback = this.addOperation('update')
try {
await apiClient.Projects.replayHooksForProject({ params: { projectId: this.id } })
- .then((response: any) => extractData(response, 204))
+ .then((response) => extractData(response, 204))
return this.Commands.refresh()
} finally {
callback()
@@ -189,7 +189,7 @@ export class Project implements ProjectV2 {
const callback = this.addOperation('delete')
try {
await apiClient.Projects.archiveProject({ params: { projectId: this.id } })
- .then((response: any) => extractData(response, 204))
+ .then((response) => extractData(response, 204))
this.status = 'archived'
} catch {
await this.Commands.refresh()
@@ -202,14 +202,14 @@ export class Project implements ProjectV2 {
Members = {
list: async () => {
this.members = await apiClient.ProjectsMembers.listMembers({ params: { projectId: this.id } })
- .then((response: any) => extractData(response, 200))
+ .then((response) => extractData(response, 200))
return this.members
},
create: async (email: string) => {
const callback = this.addOperation('teamManagement')
try {
await apiClient.ProjectsMembers.addMember({ params: { projectId: this.id }, body: { email } })
- .then((response: any) => extractData(response, 201))
+ .then((response) => extractData(response, 201))
return this.Members.list()
} finally { callback() }
},
@@ -217,7 +217,7 @@ export class Project implements ProjectV2 {
const callback = this.addOperation('teamManagement')
try {
await apiClient.ProjectsMembers.removeMember({ params: { projectId: this.id, userId } })
- .then((response: any) => extractData(response, 200))
+ .then((response) => extractData(response, 200))
return this.Members.list()
} finally { callback() }
},
@@ -225,20 +225,20 @@ export class Project implements ProjectV2 {
const callback = this.addOperation('teamManagement')
try {
await apiClient.ProjectsMembers.patchMembers({ params: { projectId: this.id }, body })
- .then((response: any) => extractData(response, 200))
+ .then((response) => extractData(response, 200))
return this.Members.list()
} finally { callback() }
},
getCandidateUsers: async (letters: string) => {
return apiClient.Users.getMatchingUsers({ query: { letters, notInProjectId: this.id } })
- .then((response: any) => extractData(response, 200))
+ .then((response) => extractData(response, 200))
},
}
Deployments = {
list: async () => {
this.deployments.value = await apiClient.Deployments.listDeployments({ params: { projectId: this.id } })
- .then((response: any) => extractData(response, 200))
+ .then((response) => extractData(response, 200))
return this.deployments.value
},
create: async (deploymentData: Omit) => {
@@ -248,7 +248,7 @@ export class Project implements ProjectV2 {
params: { projectId: this.id },
body: { ...deploymentData, projectId: this.id },
})
- .then((response: any) => extractData(response, 201))
+ .then((response) => extractData(response, 201))
} finally { callback() }
},
update: async (id: Deployment['id'], deployment: UpdateDeploymentBody) => {
@@ -258,7 +258,7 @@ export class Project implements ProjectV2 {
params: { projectId: this.id, deploymentId: id },
body: deployment,
})
- .then((response: any) => extractData(response, 200))
+ .then((response) => extractData(response, 200))
} finally { callback() }
},
delete: async (deploymentId: Deployment['id']) => {
@@ -267,7 +267,7 @@ export class Project implements ProjectV2 {
await apiClient.Deployments.deleteDeployment({
params: { projectId: this.id, deploymentId },
})
- .then((response: any) => extractData(response, 204))
+ .then((response) => extractData(response, 204))
} finally { callback() }
},
}
@@ -275,14 +275,14 @@ export class Project implements ProjectV2 {
Environments = {
list: async () => {
this.environments.value = await apiClient.Environments.listEnvironments({ query: { projectId: this.id } })
- .then((response: any) => extractData(response, 200))
+ .then((response) => extractData(response, 200))
return this.environments.value
},
create: async (envData: Omit) => {
const callback = this.addOperation('envManagement')
try {
await apiClient.Environments.createEnvironment({ body: { ...envData, projectId: this.id } })
- .then((response: any) => extractData(response, 201))
+ .then((response) => extractData(response, 201))
return this.Environments.list()
} finally { callback() }
},
@@ -290,7 +290,7 @@ export class Project implements ProjectV2 {
const callback = this.addOperation('envManagement')
try {
await apiClient.Environments.updateEnvironment({ body: environment, params: { environmentId: id } })
- .then((response: any) => extractData(response, 200))
+ .then((response) => extractData(response, 200))
await this.Environments.list()
return this.environments
} finally { callback() }
@@ -299,7 +299,7 @@ export class Project implements ProjectV2 {
const callback = this.addOperation('envManagement')
try {
await apiClient.Environments.deleteEnvironment({ params: { environmentId } })
- .then((response: any) => extractData(response, 204))
+ .then((response) => extractData(response, 204))
await this.Environments.list()
return this.environments
} finally { callback() }
@@ -309,7 +309,7 @@ export class Project implements ProjectV2 {
Repositories = {
list: async () => {
this.repositories.value = await apiClient.Repositories.listRepositories({ query: { projectId: this.id } })
- .then((response: any) => extractData(response, 200))
+ .then((response) => extractData(response, 200))
return this.repositories.value
},
sync: async (repositoryId: Repo['id'], { branchName, syncAllBranches = false }: { branchName?: string, syncAllBranches?: boolean }) => {
@@ -319,14 +319,14 @@ export class Project implements ProjectV2 {
params: { repositoryId },
body: { branchName, syncAllBranches },
})
- .then((response: any) => extractData(response, 204))
+ .then((response) => extractData(response, 204))
} finally { callback() }
},
create: async (repoData: Omit) => {
const callback = this.addOperation('repoManagement')
try {
await apiClient.Repositories.createRepository({ body: { ...repoData, projectId: this.id } })
- .then((response: any) => extractData(response, 201))
+ .then((response) => extractData(response, 201))
return this.Repositories.list()
} finally { callback() }
},
@@ -334,7 +334,7 @@ export class Project implements ProjectV2 {
const callback = this.addOperation('repoManagement')
try {
await apiClient.Repositories.updateRepository({ body: { ...repoData, projectId: this.id }, params: { repositoryId: id } })
- .then((response: any) => extractData(response, 200))
+ .then((response) => extractData(response, 200))
return this.Repositories.list()
} finally { callback() }
},
@@ -342,7 +342,7 @@ export class Project implements ProjectV2 {
const callback = this.addOperation('repoManagement')
try {
await apiClient.Repositories.deleteRepository({ params: { repositoryId } })
- .then((response: any) => extractData(response, 204))
+ .then((response) => extractData(response, 204))
return this.Repositories.list()
} finally { callback() }
},
@@ -351,11 +351,11 @@ export class Project implements ProjectV2 {
Roles = {
countMembers: async () => {
return apiClient.ProjectsRoles.projectRoleMemberCounts({ params: { projectId: this.id } })
- .then((response: any) => extractData(response, 200))
+ .then((response) => extractData(response, 200))
},
list: async () => {
this.roles = await apiClient.ProjectsRoles.listProjectRoles({ params: { projectId: this.id } })
- .then((response: any) => extractData(response, 200))
+ .then((response) => extractData(response, 200))
this.computePerms()
return this.roles
},
@@ -363,14 +363,14 @@ export class Project implements ProjectV2 {
const callback = this.addOperation('roleManagement')
try {
this.roles = await apiClient.ProjectsRoles.patchProjectRoles({ body, params: { projectId: this.id } })
- .then((response: any) => extractData(response, 200))
+ .then((response) => extractData(response, 200))
this.computePerms()
return this.roles
} finally { callback() }
},
create: async (body: typeof projectRoleContract.createProjectRole.body._type) => {
this.roles = await apiClient.ProjectsRoles.createProjectRole({ body, params: { projectId: this.id } })
- .then((response: any) => extractData(response, 201))
+ .then((response) => extractData(response, 201))
this.computePerms()
return this.roles
},
@@ -378,7 +378,7 @@ export class Project implements ProjectV2 {
const callback = this.addOperation('roleManagement')
try {
await apiClient.ProjectsRoles.deleteProjectRole({ params: { projectId: this.id, roleId } })
- .then((response: any) => extractData(response, 204))
+ .then((response) => extractData(response, 204))
this.computePerms()
return this.Roles.list()
} finally { callback() }
@@ -388,18 +388,18 @@ export class Project implements ProjectV2 {
Services = {
getSecrets: async () => {
return apiClient.Projects.getProjectSecrets({ params: { projectId: this.id } })
- .then((response: any) => extractData(response, 200))
+ .then((response) => extractData(response, 200))
},
list: async (permissionTarget: PermissionTarget = 'user') => {
this.services = await apiClient.ProjectServices.getServices({ params: { projectId: this.id }, query: { permissionTarget } })
- .then((response: any) => extractData(response, 200))
+ .then((response) => extractData(response, 200))
return this.services
},
update: async (body: PluginsUpdateBody) => {
const callback = this.addOperation('saveServices')
try {
await apiClient.ProjectServices.updateProjectServices({ params: { projectId: this.id }, body })
- .then((response: any) => extractData(response, 204))
+ .then((response) => extractData(response, 204))
return this.Services.list()
} finally { callback() }
},
@@ -408,7 +408,7 @@ export class Project implements ProjectV2 {
Logs = {
list: async ({ offset, limit, clean }: GetLogsQuery = { offset: 0, limit: 10 }) => {
return apiClient.Logs.getLogs({ query: { offset, limit, clean, projectId: this.id } })
- .then((response: any) => extractData(response, 200))
+ .then((response) => extractData(response, 200))
},
}
}
diff --git a/apps/client/src/views/ProjectDashboard.vue b/apps/client/src/views/ProjectDashboard.vue
index d411ed7e78..93ca32c77e 100644
--- a/apps/client/src/views/ProjectDashboard.vue
+++ b/apps/client/src/views/ProjectDashboard.vue
@@ -137,6 +137,7 @@ const saveProjectState = ref({
const currentRoute = useRoute()
async function refreshMembers() {
+ if (!project.value) return
await project.value.Members.list()
teamId.value = getRandomId('team')
}
@@ -153,7 +154,7 @@ watch(currentRoute, () => {
})
watch(activeTab, (tabIndex) => {
- const tabId = tabTitles[tabIndex].tabId
+ const tabId = tabTitles[tabIndex]?.tabId
if (tabId) {
router.replace({
query: {
@@ -165,6 +166,7 @@ watch(activeTab, (tabIndex) => {
})
async function saveProject() {
+ if (!project.value) return
saveProjectState.value.isProcessing = true
await project.value.Commands.update({
description: project.value.description,
@@ -175,7 +177,7 @@ async function saveProject() {
prodMemory: project.value.prodMemory,
prodCpu: project.value.prodCpu,
prodGpu: project.value.prodGpu,
- }).finally(() => project.value.Commands.refresh())
+ }).finally(() => project.value?.Commands.refresh())
saveProjectState.value.isProcessing = false
}
@@ -203,6 +205,7 @@ async function saveProject() {
"
@update:model-value="
(desc: string | undefined) => {
+ if (!project) return
project.description = desc;
}
"
diff --git a/apps/client/src/views/admin/ListClusters.vue b/apps/client/src/views/admin/ListClusters.vue
index 7074ceee8a..752bf201b0 100644
--- a/apps/client/src/views/admin/ListClusters.vue
+++ b/apps/client/src/views/admin/ListClusters.vue
@@ -136,7 +136,7 @@ const headers = [
diff --git a/apps/client/src/views/admin/ListPlugins.vue b/apps/client/src/views/admin/ListPlugins.vue
index 250e3938ec..41c1004039 100644
--- a/apps/client/src/views/admin/ListPlugins.vue
+++ b/apps/client/src/views/admin/ListPlugins.vue
@@ -55,7 +55,7 @@ onBeforeMount(() => {
function update(data: { value: string, key: string, plugin: string }) {
if (!updated.value[data.plugin]) updated.value[data.plugin] = {}
- updated.value[data.plugin][data.key] = data.value
+ updated.value[data.plugin]![data.key] = data.value
}
const servicesWrapableLength = computed(() => services.value.filter(({ wrapable }) => wrapable).length)
diff --git a/apps/client/src/views/admin/ListProjects.vue b/apps/client/src/views/admin/ListProjects.vue
index 171f4ea557..e218ff0082 100644
--- a/apps/client/src/views/admin/ListProjects.vue
+++ b/apps/client/src/views/admin/ListProjects.vue
@@ -125,7 +125,7 @@ async function validateBulkAction() {
action: selectedAction.value,
projectIds: selectedProjects.value.map(({ id }) => id),
},
- }).then((res: any) => extractData(res, 202))
+ }).then((res) => extractData(res, 202))
selectedProjectIds.value = []
snackbarStore.setMessage('Traitement en cours, en fonction du nombre de projets cela peut prendre plusieurs minutes, veuillez rafraichir dans quelques instants')
}
diff --git a/apps/client/src/views/admin/ListUser.vue b/apps/client/src/views/admin/ListUser.vue
index 6fd88db2d3..c4d0b50ae3 100644
--- a/apps/client/src/views/admin/ListUser.vue
+++ b/apps/client/src/views/admin/ListUser.vue
@@ -203,8 +203,8 @@ onBeforeMount(async () => {
:style="`background-color: ${user.bgColor};`"
>
{{
- user.firstName[0].toUpperCase()
- + user.lastName[0].toUpperCase()
+ (user.firstName[0] ?? '').toUpperCase()
+ + (user.lastName[0] ?? '').toUpperCase()
}}
diff --git a/apps/client/tsconfig.json b/apps/client/tsconfig.json
index 7f8a3442bf..837cf8df83 100644
--- a/apps/client/tsconfig.json
+++ b/apps/client/tsconfig.json
@@ -3,21 +3,14 @@
"@cpn-console/ts-config/tsconfig.base.json"
],
"compilerOptions": {
- "incremental": true,
- // Module
- "target": "ESNext",
-
- "jsx": "preserve",
- "lib": ["DOM", "ESNext"],
- // Base
"baseUrl": "./",
"rootDir": "./src",
+ "jsx": "preserve",
+ "lib": ["DOM", "ESNext"],
"module": "Preserve",
"moduleResolution": "Bundler",
"paths": {
- "@/*": [
- "src/*"
- ]
+ "@/*": ["src/*"]
},
"resolveJsonModule": true,
"types": [
@@ -28,15 +21,6 @@
],
"allowImportingTsExtensions": false,
"allowJs": true,
- "strict": true,
- "strictNullChecks": true,
- "alwaysStrict": true,
- "noFallthroughCasesInSwitch": true,
- "noImplicitAny": true,
- "noPropertyAccessFromIndexSignature": false,
- "noUnusedLocals": true,
- "noUnusedParameters": true,
- "useUnknownInCatchVariables": true,
"declaration": true,
"declarationDir": "./types",
"emitDeclarationOnly": false,
@@ -44,9 +28,7 @@
"outDir": "./dist",
"sourceMap": true,
"esModuleInterop": true,
- "forceConsistentCasingInFileNames": true,
- "isolatedModules": true,
- "skipLibCheck": true
+ "isolatedModules": true
},
"vueCompilerOptions": {},
"include": [
diff --git a/apps/server-nestjs/eslint.config.mjs b/apps/server-nestjs/eslint.config.mjs
index 5a664d2b58..51fc348b8d 100644
--- a/apps/server-nestjs/eslint.config.mjs
+++ b/apps/server-nestjs/eslint.config.mjs
@@ -1,3 +1,11 @@
import eslintConfigBase from '@cpn-console/eslint-config'
+import nestjsTyped from '@darraghor/eslint-plugin-nestjs-typed'
-export default eslintConfigBase
+export default eslintConfigBase.append({
+ plugins: {
+ '@darraghor/nestjs-typed': nestjsTyped,
+ },
+ rules: {
+ '@darraghor/nestjs-typed/sort-module-metadata-arrays': 'error',
+ },
+}).append(nestjsTyped.configs.flatNoSwagger)
diff --git a/apps/server-nestjs/package.json b/apps/server-nestjs/package.json
index 79126d32e2..3fa2d14223 100644
--- a/apps/server-nestjs/package.json
+++ b/apps/server-nestjs/package.json
@@ -85,6 +85,7 @@
"@cpn-console/eslint-config": "workspace:^",
"@cpn-console/test-utils": "workspace:^",
"@cpn-console/ts-config": "workspace:^",
+ "@darraghor/eslint-plugin-nestjs-typed": "catalog:tools",
"@eslint/eslintrc": "catalog:tools",
"@eslint/js": "catalog:tools",
"@faker-js/faker": "catalog:test",
diff --git a/apps/server-nestjs/src/modules/argocd/argocd.module.ts b/apps/server-nestjs/src/modules/argocd/argocd.module.ts
index ad51bf62dd..9dcd832d00 100644
--- a/apps/server-nestjs/src/modules/argocd/argocd.module.ts
+++ b/apps/server-nestjs/src/modules/argocd/argocd.module.ts
@@ -11,7 +11,7 @@ import { ArgoCDService } from './argocd.service'
@Module({
imports: [ConfigurationModule, DatabaseModule, GitlabModule, TerminusModule, VaultModule],
- providers: [ArgoCDHealthService, ArgoCDPluginService, ArgoCDService, ArgoCDDatastoreService],
+ providers: [ArgoCDDatastoreService, ArgoCDHealthService, ArgoCDPluginService, ArgoCDService],
exports: [ArgoCDHealthService, ArgoCDPluginService, ArgoCDService],
})
export class ArgoCDModule {}
diff --git a/apps/server-nestjs/src/modules/environment/environment.module.ts b/apps/server-nestjs/src/modules/environment/environment.module.ts
index a9c4f597d4..a61a690d24 100644
--- a/apps/server-nestjs/src/modules/environment/environment.module.ts
+++ b/apps/server-nestjs/src/modules/environment/environment.module.ts
@@ -11,8 +11,8 @@ import { EnvironmentService } from './environment.service'
controllers: [EnvironmentController],
providers: [
EnvironmentDatastoreService,
- EnvironmentValidationService,
EnvironmentService,
+ EnvironmentValidationService,
],
})
export class EnvironmentModule {}
diff --git a/apps/server-nestjs/src/modules/gitlab/gitlab-client.service.ts b/apps/server-nestjs/src/modules/gitlab/gitlab-client.service.ts
index 53841d8d13..b7a649302e 100644
--- a/apps/server-nestjs/src/modules/gitlab/gitlab-client.service.ts
+++ b/apps/server-nestjs/src/modules/gitlab/gitlab-client.service.ts
@@ -127,11 +127,14 @@ export class GitlabClientService {
async createGroup(path: string) {
this.logger.log(`Creating a GitLab group at path ${path}`)
const created = await this.client.Groups.create(path, path)
- if (this.config.projectRootDir && created.full_path === this.config.projectRootDir) {
- await this.setManagedRootGroupAttributes(created.id)
- }
- if (this.config.projectRootDir && created.full_path === `${this.config.projectRootDir}/${INFRA_GROUP_PATH}`) {
- await this.setManagedInfraGroupAttributes(created.id)
+ const rootDir = this.config.projectRootDir
+ if (rootDir) {
+ if (created.full_path === rootDir) {
+ await this.setManagedRootGroupAttributes(created.id)
+ }
+ if (created.full_path === `${rootDir}/${INFRA_GROUP_PATH}`) {
+ await this.setManagedInfraGroupAttributes(created.id)
+ }
}
return created
}
@@ -340,7 +343,7 @@ export class GitlabClientService {
}
async deleteGroup(group: CondensedGroupSchemaWith<'id' | 'full_path'>): Promise {
- this.logger.verbose(`Deleting GitLab group ${group.full_path} (groupId=${group.id})`)
+ this.logger.verbose(`Deleting GitLab group ${group.full_path} (groupId=${Number(group.id)})`)
await this.client.Groups.remove(group.id)
}
@@ -513,7 +516,7 @@ export class GitlabClientService {
this.logger.debug(`Pagination start (page=${page})`)
while (page !== null) {
- if (options?.maxPages && pagesFetched >= options.maxPages) {
+ if (options?.maxPages != null && pagesFetched >= options.maxPages) {
page = null
continue
}
diff --git a/apps/server-nestjs/src/modules/healthz/healthz.module.ts b/apps/server-nestjs/src/modules/healthz/healthz.module.ts
index 50141664e4..91fa2739b0 100644
--- a/apps/server-nestjs/src/modules/healthz/healthz.module.ts
+++ b/apps/server-nestjs/src/modules/healthz/healthz.module.ts
@@ -15,15 +15,15 @@ import { HealthzService } from './healthz.service'
@Module({
imports: [
- TerminusModule,
- DatabaseModule,
- KeycloakModule,
ConditionalModule.registerWhen(ArgoCDModule, 'USE_ARGOCD'),
ConditionalModule.registerWhen(GitlabModule, 'USE_GITLAB'),
ConditionalModule.registerWhen(NexusModule, 'USE_NEXUS'),
ConditionalModule.registerWhen(RegistryModule, 'USE_HARBOR'),
ConditionalModule.registerWhen(ServiceChainModule, optIn('USE_SERVICE_CHAIN')),
ConditionalModule.registerWhen(VaultModule, 'USE_VAULT'),
+ DatabaseModule,
+ KeycloakModule,
+ TerminusModule,
],
controllers: [HealthzController],
providers: [HealthzService],
diff --git a/apps/server-nestjs/src/modules/infrastructure/auth/keycloak-jwt/keycloak-jwt.module.ts b/apps/server-nestjs/src/modules/infrastructure/auth/keycloak-jwt/keycloak-jwt.module.ts
index 985a16aa0f..ac229c5cd8 100644
--- a/apps/server-nestjs/src/modules/infrastructure/auth/keycloak-jwt/keycloak-jwt.module.ts
+++ b/apps/server-nestjs/src/modules/infrastructure/auth/keycloak-jwt/keycloak-jwt.module.ts
@@ -29,6 +29,6 @@ import { KeycloakJwtService } from './keycloak-jwt.service'
}),
],
providers: [KeycloakJwtService],
- exports: [KeycloakJwtService, JwtModule],
+ exports: [JwtModule, KeycloakJwtService],
})
export class KeycloakJwtModule {}
diff --git a/apps/server-nestjs/src/modules/infrastructure/auth/keycloak-secret-provider/keycloak-secret-provider.module.ts b/apps/server-nestjs/src/modules/infrastructure/auth/keycloak-secret-provider/keycloak-secret-provider.module.ts
index bdc7422816..d18b1093ad 100644
--- a/apps/server-nestjs/src/modules/infrastructure/auth/keycloak-secret-provider/keycloak-secret-provider.module.ts
+++ b/apps/server-nestjs/src/modules/infrastructure/auth/keycloak-secret-provider/keycloak-secret-provider.module.ts
@@ -4,7 +4,7 @@ import { ConfigurationModule } from '../../configuration/configuration.module'
import { KeycloakSecretProviderService } from './keycloak-secret-provider.service'
@Module({
- imports: [ConfigurationModule, CacheModule.register()],
+ imports: [CacheModule.register(), ConfigurationModule],
providers: [KeycloakSecretProviderService],
exports: [KeycloakSecretProviderService],
})
diff --git a/apps/server-nestjs/src/modules/infrastructure/configuration/configuration.service.ts b/apps/server-nestjs/src/modules/infrastructure/configuration/configuration.service.ts
index 67d925fc11..c39e19b8be 100644
--- a/apps/server-nestjs/src/modules/infrastructure/configuration/configuration.service.ts
+++ b/apps/server-nestjs/src/modules/infrastructure/configuration/configuration.service.ts
@@ -13,9 +13,9 @@ export class ConfigurationService {
isDevSetup = process.env.DEV_SETUP === 'true'
// app
- host = process.env.SERVER_HOST ?? 'localhost'
+ host = process.env.SERVER_HOST ?? ''
port = process.env.SERVER_PORT ? Number(process.env.SERVER_PORT) : 0 // dynamically allocate an available ephemeral port
- appVersion = this.isProd ? (process.env.APP_VERSION ?? 'unknown') : 'dev'
+ appVersion = this.isProd ? (process.env.APP_VERSION ?? '') : 'dev'
// db
dbUrl = process.env.DB_URL
@@ -47,7 +47,7 @@ export class ConfigurationService {
contactEmail
= process.env.CONTACT_EMAIL
- ?? 'cloudpinative-relations@interieur.gouv.fr'
+ ?? ''
// argocd
argoNamespace = process.env.ARGO_NAMESPACE ?? 'argocd'
@@ -171,9 +171,7 @@ export class ConfigurationService {
}
NODE_ENV
- = process.env.NODE_ENV === 'test'
- ? 'test'
- : process.env.NODE_ENV === 'development'
- ? 'development'
- : 'production'
+ = process.env.NODE_ENV != null
+ ? process.env.NODE_ENV
+ : 'production'
}
diff --git a/apps/server-nestjs/src/modules/infrastructure/database/database.service.ts b/apps/server-nestjs/src/modules/infrastructure/database/database.service.ts
index 695a2daf5a..8d2fdb66a5 100644
--- a/apps/server-nestjs/src/modules/infrastructure/database/database.service.ts
+++ b/apps/server-nestjs/src/modules/infrastructure/database/database.service.ts
@@ -43,7 +43,7 @@ export class DatabaseService {
if (triesLeft > 0) {
this.loggerService.error(error)
this.loggerService.log(
- `Could not connect to Postgres: ${error.message}`,
+ `Could not connect to Postgres: ${error instanceof Error ? error.message : String(error)}`,
)
this.loggerService.log(`Retrying (${triesLeft} tries left)`)
await setTimeout(this.DELAY_BEFORE_RETRY)
@@ -51,11 +51,11 @@ export class DatabaseService {
}
this.loggerService.log(
- `Could not connect to Postgres: ${error.message}`,
+ `Could not connect to Postgres: ${error instanceof Error ? error.message : String(error)}`,
)
this.loggerService.log('Out of retries')
- error.message = `Out of retries, last error: ${error.message}`
- throw error
+ const outOfRetriesError = new Error(`Out of retries, last error: ${error instanceof Error ? error.message : String(error)}`)
+ throw outOfRetriesError
}
}
diff --git a/apps/server-nestjs/src/modules/infrastructure/infrastructure.module.ts b/apps/server-nestjs/src/modules/infrastructure/infrastructure.module.ts
index e29dae241f..0f9bb288ae 100644
--- a/apps/server-nestjs/src/modules/infrastructure/infrastructure.module.ts
+++ b/apps/server-nestjs/src/modules/infrastructure/infrastructure.module.ts
@@ -8,7 +8,7 @@ import { PermissionModule } from './permission/permission.module'
@Module({
providers: [],
- imports: [AuthModule, DatabaseModule, ConfigurationModule, EventsModule, LoggerModule, PermissionModule],
- exports: [AuthModule, DatabaseModule, ConfigurationModule, EventsModule, LoggerModule, PermissionModule],
+ imports: [AuthModule, ConfigurationModule, DatabaseModule, EventsModule, LoggerModule, PermissionModule],
+ exports: [AuthModule, ConfigurationModule, DatabaseModule, EventsModule, LoggerModule, PermissionModule],
})
export class InfrastructureModule {}
diff --git a/apps/server-nestjs/src/modules/infrastructure/permission/permission.module.ts b/apps/server-nestjs/src/modules/infrastructure/permission/permission.module.ts
index c2f926a351..479df8bbe5 100644
--- a/apps/server-nestjs/src/modules/infrastructure/permission/permission.module.ts
+++ b/apps/server-nestjs/src/modules/infrastructure/permission/permission.module.ts
@@ -3,7 +3,7 @@ import { ProjectPermissionModule } from './project/project.module'
import { UserPermissionModule } from './user/user.module'
@Module({
- imports: [UserPermissionModule, ProjectPermissionModule],
- exports: [UserPermissionModule, ProjectPermissionModule],
+ imports: [ProjectPermissionModule, UserPermissionModule],
+ exports: [ProjectPermissionModule, UserPermissionModule],
})
export class PermissionModule {}
diff --git a/apps/server-nestjs/src/modules/infrastructure/permission/project/project.module.ts b/apps/server-nestjs/src/modules/infrastructure/permission/project/project.module.ts
index 6561dd78dd..401676d4bb 100644
--- a/apps/server-nestjs/src/modules/infrastructure/permission/project/project.module.ts
+++ b/apps/server-nestjs/src/modules/infrastructure/permission/project/project.module.ts
@@ -14,14 +14,14 @@ import { ProjectPermissionService } from './project.service'
providers: [
ProjectGuard,
ProjectPermissionLoaderService,
- ProjectPermissionService,
ProjectPermissionPolicy,
+ ProjectPermissionService,
],
exports: [
ProjectGuard,
ProjectPermissionLoaderService,
- ProjectPermissionService,
ProjectPermissionPolicy,
+ ProjectPermissionService,
],
})
export class ProjectPermissionModule {}
diff --git a/apps/server-nestjs/src/modules/infrastructure/permission/user/user.module.ts b/apps/server-nestjs/src/modules/infrastructure/permission/user/user.module.ts
index 613821ed2a..5ae8805c85 100644
--- a/apps/server-nestjs/src/modules/infrastructure/permission/user/user.module.ts
+++ b/apps/server-nestjs/src/modules/infrastructure/permission/user/user.module.ts
@@ -12,13 +12,13 @@ import { UserPermissionService } from './user.service'
],
providers: [
UserGuard,
- UserPermissionService,
UserPermissionPolicy,
+ UserPermissionService,
],
exports: [
UserGuard,
- UserPermissionService,
UserPermissionPolicy,
+ UserPermissionService,
],
})
export class UserPermissionModule {}
diff --git a/apps/server-nestjs/src/modules/nexus/nexus.module.ts b/apps/server-nestjs/src/modules/nexus/nexus.module.ts
index 14d706232d..37e3e36b02 100644
--- a/apps/server-nestjs/src/modules/nexus/nexus.module.ts
+++ b/apps/server-nestjs/src/modules/nexus/nexus.module.ts
@@ -13,12 +13,12 @@ import { NexusService } from './nexus.service'
@Module({
imports: [ConfigurationModule, DatabaseModule, TerminusModule, VaultModule],
providers: [
+ NexusClientService,
+ NexusDatastoreService,
NexusHealthService,
+ NexusHttpClientService,
NexusPluginService,
NexusService,
- NexusDatastoreService,
- NexusHttpClientService,
- NexusClientService,
],
exports: [NexusClientService, NexusHealthService, NexusPluginService, NexusService],
})
diff --git a/apps/server-nestjs/src/modules/plugin/plugin.module.ts b/apps/server-nestjs/src/modules/plugin/plugin.module.ts
index f2aeee1a67..105f2d0fe7 100644
--- a/apps/server-nestjs/src/modules/plugin/plugin.module.ts
+++ b/apps/server-nestjs/src/modules/plugin/plugin.module.ts
@@ -15,12 +15,12 @@ import { PluginService } from './plugin.service'
imports: [
ConditionalModule.registerWhen(ArgoCDModule, 'USE_ARGOCD'),
ConditionalModule.registerWhen(GitlabModule, 'USE_GITLAB'),
- KeycloakModule,
ConditionalModule.registerWhen(NexusModule, 'USE_NEXUS'),
ConditionalModule.registerWhen(RegistryModule, 'USE_HARBOR'),
ConditionalModule.registerWhen(ServiceChainModule, optIn('USE_SERVICE_CHAIN')),
ConditionalModule.registerWhen(SonarqubeModule, 'USE_SONARQUBE'),
ConditionalModule.registerWhen(VaultModule, 'USE_VAULT'),
+ KeycloakModule,
],
providers: [PluginService],
exports: [PluginService],
diff --git a/apps/server-nestjs/src/modules/project-bulk/project-bulk.module.ts b/apps/server-nestjs/src/modules/project-bulk/project-bulk.module.ts
index fbb1d9bf76..af4501a3ef 100644
--- a/apps/server-nestjs/src/modules/project-bulk/project-bulk.module.ts
+++ b/apps/server-nestjs/src/modules/project-bulk/project-bulk.module.ts
@@ -13,9 +13,9 @@ import { ProjectBulkService } from './project-bulk.service'
AuthModule,
DatabaseModule,
EventsModule,
- UserPermissionModule,
- ProjectModule,
ProjectHooksModule,
+ ProjectModule,
+ UserPermissionModule,
],
controllers: [ProjectBulkController],
providers: [ProjectBulkService],
diff --git a/apps/server-nestjs/src/modules/project-secrets/project-secrets.module.ts b/apps/server-nestjs/src/modules/project-secrets/project-secrets.module.ts
index 1d3e2ef1f0..84c29ffaa2 100644
--- a/apps/server-nestjs/src/modules/project-secrets/project-secrets.module.ts
+++ b/apps/server-nestjs/src/modules/project-secrets/project-secrets.module.ts
@@ -9,7 +9,7 @@ import { ProjectSecretsController } from './project-secrets.controller'
import { ProjectSecretsService } from './project-secrets.service'
@Module({
- imports: [AuthModule, ConfigurationModule, DatabaseModule, ProjectPermissionModule, ConditionalModule.registerWhen(VaultModule, 'USE_VAULT')],
+ imports: [AuthModule, ConditionalModule.registerWhen(VaultModule, 'USE_VAULT'), ConfigurationModule, DatabaseModule, ProjectPermissionModule],
controllers: [ProjectSecretsController],
providers: [ProjectSecretsService],
exports: [ProjectSecretsService],
diff --git a/apps/server-nestjs/src/modules/project-services/project-services.utils.ts b/apps/server-nestjs/src/modules/project-services/project-services.utils.ts
index c5961851e1..4d00c47a59 100644
--- a/apps/server-nestjs/src/modules/project-services/project-services.utils.ts
+++ b/apps/server-nestjs/src/modules/project-services/project-services.utils.ts
@@ -52,10 +52,10 @@ interface ServiceManifestParams {
}
export function populateServiceManifest({ service, data, select, permissionTarget }: ServiceManifestParams): Partial {
- const manifest = structuredClone(service.config)
+ const manifest = structuredClone(service.config) as PluginConfig
const selected: Partial = {}
- for (const [scope] of Object.entries(select).filter(([_scope, bool]) => bool)) {
+ for (const [scope] of Object.entries(select).filter(([_scope, bool]) => bool === true)) {
if (!manifest?.[scope]) continue
selected[scope] = manifest[scope].filter(item => item.permissions[permissionTarget].read || item.permissions[permissionTarget].write).map((item) => {
const row = data[scope]?.find(candidate => candidate.pluginName === service.name && candidate.key === item.key)
@@ -71,6 +71,7 @@ export function populateServiceManifest({ service, data, select, permissionTarge
return selected
}
+interface ServiceUrlResponse { title?: string; description?: string; to: string }
export function normalizeServiceUrls(toResponse: unknown): ServiceUrl[] {
if (Array.isArray(toResponse)) {
return toResponse.map(res => ({ name: res.title ?? '', description: res.description ?? '', to: res.to }))
@@ -80,8 +81,9 @@ export function normalizeServiceUrls(toResponse: unknown): ServiceUrl[] {
return [{ to: toResponse, name: '' }]
}
- if (toResponse) {
- return [{ name: (toResponse as { title?: string }).title ?? '', to: (toResponse as { to: string }).to }]
+ if (toResponse != null && typeof toResponse === 'object') {
+ const resp = toResponse as { title?: string; to: string }
+ return [{ name: resp.title ?? '', to: resp.to }]
}
return []
diff --git a/apps/server-nestjs/src/modules/project/project.module.ts b/apps/server-nestjs/src/modules/project/project.module.ts
index 19e7f0b594..c9117fe7ed 100644
--- a/apps/server-nestjs/src/modules/project/project.module.ts
+++ b/apps/server-nestjs/src/modules/project/project.module.ts
@@ -17,9 +17,9 @@ import { ProjectService } from './project.service'
ConfigurationModule,
DatabaseModule,
EventsModule,
+ LogModule,
ProjectPermissionModule,
UserPermissionModule,
- LogModule,
],
controllers: [ProjectController],
providers: [ProjectService],
diff --git a/apps/server-nestjs/src/modules/project/project.utils.ts b/apps/server-nestjs/src/modules/project/project.utils.ts
index bb50d21fdf..24a020e2a2 100644
--- a/apps/server-nestjs/src/modules/project/project.utils.ts
+++ b/apps/server-nestjs/src/modules/project/project.utils.ts
@@ -132,10 +132,10 @@ export function generateProjectWhereInput(opts: {
const { status, statusIn, statusNotIn, filter = 'member', ...rest } = opts.query
const whereAnd: Prisma.ProjectWhereInput[] = []
- if (rest.id) whereAnd.push({ id: rest.id })
+ if (rest.id != null) whereAnd.push({ id: rest.id })
if (rest.locked !== undefined) whereAnd.push({ locked: rest.locked })
- if (rest.name) whereAnd.push({ name: rest.name })
- if (rest.description) whereAnd.push({ description: { contains: rest.description } })
+ if (rest.name != null) whereAnd.push({ name: rest.name })
+ if (rest.description != null) whereAnd.push({ description: { contains: rest.description } })
const statusWhere = parseEnumWhereFilter({
enumValues: projectStatus,
@@ -148,14 +148,14 @@ export function generateProjectWhereInput(opts: {
if (rest.lastSuccessProvisionningVersion) {
if (rest.lastSuccessProvisionningVersion === 'outdated') {
whereAnd.push({ lastSuccessProvisionningVersion: { not: opts.appVersion } })
- } else if (rest.lastSuccessProvisionningVersion === 'last') {
+ } else if (rest.lastSuccessProvisionningVersion === 'last' && opts.appVersion != null) {
whereAnd.push({ lastSuccessProvisionningVersion: { equals: opts.appVersion } })
} else {
whereAnd.push({ lastSuccessProvisionningVersion: rest.lastSuccessProvisionningVersion })
}
}
- if (rest.search) {
+ if (rest.search != null) {
whereAnd.push({
OR: [
{ name: { contains: rest.search } },
diff --git a/apps/server-nestjs/src/modules/registry/registry.module.ts b/apps/server-nestjs/src/modules/registry/registry.module.ts
index b205b1babb..b461bcde5a 100644
--- a/apps/server-nestjs/src/modules/registry/registry.module.ts
+++ b/apps/server-nestjs/src/modules/registry/registry.module.ts
@@ -12,8 +12,8 @@ import { RegistryPluginService } from './registry-plugin.service'
import { RegistryService } from './registry.service'
@Module({
- imports: [ConfigurationModule, DatabaseModule, TerminusModule, VaultModule, CacheModule.register()],
- providers: [RegistryHealthService, RegistryPluginService, RegistryService, RegistryDatastoreService, RegistryHttpClientService, RegistryClientService],
+ imports: [CacheModule.register(), ConfigurationModule, DatabaseModule, TerminusModule, VaultModule],
+ providers: [RegistryClientService, RegistryDatastoreService, RegistryHealthService, RegistryHttpClientService, RegistryPluginService, RegistryService],
exports: [RegistryHealthService, RegistryPluginService, RegistryService],
})
export class RegistryModule {}
diff --git a/apps/server-nestjs/src/modules/registry/registry.service.ts b/apps/server-nestjs/src/modules/registry/registry.service.ts
index cd675f32da..a88f7c8c8a 100644
--- a/apps/server-nestjs/src/modules/registry/registry.service.ts
+++ b/apps/server-nestjs/src/modules/registry/registry.service.ts
@@ -83,7 +83,7 @@ export class RegistryService {
const created = await this.client.createRobot(
generateRobotPermissions(project, robotName, access),
)
- if (created.status >= 300 || !created.data) {
+ if (created.status != null && (created.status >= 300 || !created.data)) {
throw new Error(`Harbor create robot failed (${created.status})`)
}
return created.data
@@ -103,7 +103,7 @@ export class RegistryService {
'project.slug': project.slug,
'registry.robot.name': robotName,
})
- if (!this.config.projectRootDir) {
+ if (this.config.projectRootDir == null) {
throw new Error('PROJECTS_ROOT_DIR is required')
}
const relativeVaultPath = `REGISTRY/${robotName}`
@@ -122,7 +122,7 @@ export class RegistryService {
'registry.robot.secret.expiring': expiring,
})
- if (vaultRobotSecret?.data?.HOST === this.host && !expiring) {
+ if (vaultRobotSecret && !expiring && vaultRobotSecret.data.HOST === this.host) {
span?.setAttribute('vault.secret.reused', true)
return vaultRobotSecret.data
}
@@ -188,14 +188,14 @@ export class RegistryService {
span?.setAttribute('project.slug', project.slug)
const members = await this.client.getGroupMembers(project.slug)
- if (members.status !== 200 || !members.data) {
+ if (members.status != null && members.status !== 200 || !members.data) {
throw new Error(`Harbor list members failed (${members.status})`)
}
const membersByName = new Map()
for (const member of members.data) {
const name = member?.entity_name
- if (name) membersByName.set(name, member)
+ if (name != null) membersByName.set(name, member)
}
const byGroupName = await this.generateAccessLevelMapping(project)
@@ -322,7 +322,7 @@ export class RegistryService {
this.logger.log(`Handling project upsert for ${project.slug}`)
const quotaConfigRaw = getPluginConfig(project, REGISTRY_CONFIG_KEY_QUOTA_HARD_LIMIT)
const publishConfig = getPluginConfig(project, REGISTRY_CONFIG_KEY_PUBLISH_PROJECT_ROBOT)
- const parsedQuota = quotaConfigRaw ? parseBytes(String(quotaConfigRaw)) : undefined
+ const parsedQuota = quotaConfigRaw != null ? parseBytes(String(quotaConfigRaw)) : undefined
const storageLimitBytes = parsedQuota ?? -1
const publishProjectRobot = specificallyEnabled(publishConfig)
await this.ensureProject(project, { storageLimitBytes, publishProjectRobot })
@@ -483,7 +483,7 @@ function generateRetentionPolicy(
const rawCount = Number(options.harborRuleCount)
let count: number
- if (Number.isFinite(rawCount) && rawCount > 0) {
+ if (rawCount != null && Number.isFinite(rawCount) && rawCount > 0) {
count = rawCount
} else if (template === 'always') {
count = 1
diff --git a/apps/server-nestjs/src/modules/service-chain/service-chain.module.ts b/apps/server-nestjs/src/modules/service-chain/service-chain.module.ts
index 58103a0409..3664aee98c 100644
--- a/apps/server-nestjs/src/modules/service-chain/service-chain.module.ts
+++ b/apps/server-nestjs/src/modules/service-chain/service-chain.module.ts
@@ -21,6 +21,6 @@ import { ServiceChainService } from './service-chain.service'
],
controllers: [ServiceChainController],
providers: [OpenCdsClientService, ServiceChainHealthService, ServiceChainService],
- exports: [ServiceChainService, ServiceChainHealthService],
+ exports: [ServiceChainHealthService, ServiceChainService],
})
export class ServiceChainModule {}
diff --git a/apps/server-nestjs/src/modules/sonarqube/sonarqube.module.ts b/apps/server-nestjs/src/modules/sonarqube/sonarqube.module.ts
index 17499fdda4..f7c44a6780 100644
--- a/apps/server-nestjs/src/modules/sonarqube/sonarqube.module.ts
+++ b/apps/server-nestjs/src/modules/sonarqube/sonarqube.module.ts
@@ -13,10 +13,10 @@ import { SonarqubeService } from './sonarqube.service'
@Module({
imports: [ConfigurationModule, DatabaseModule, TerminusModule, VaultModule],
providers: [
- SonarqubeHealthService,
- SonarqubeHttpClientService,
SonarqubeClientService,
SonarqubeDatastoreService,
+ SonarqubeHealthService,
+ SonarqubeHttpClientService,
SonarqubePluginService,
SonarqubeService,
],
diff --git a/apps/server-nestjs/src/modules/vault/vault.module.ts b/apps/server-nestjs/src/modules/vault/vault.module.ts
index 0b1d8281ea..893c960db2 100644
--- a/apps/server-nestjs/src/modules/vault/vault.module.ts
+++ b/apps/server-nestjs/src/modules/vault/vault.module.ts
@@ -12,12 +12,12 @@ import { VaultService } from './vault.service'
@Module({
imports: [ConfigurationModule, DatabaseModule, TerminusModule],
providers: [
+ VaultClientService,
+ VaultDatastoreService,
VaultHealthService,
VaultHttpClientService,
- VaultClientService,
VaultPluginService,
VaultService,
- VaultDatastoreService,
],
exports: [VaultClientService, VaultHealthService, VaultPluginService, VaultService],
})
diff --git a/apps/server-nestjs/tsconfig.eslint.json b/apps/server-nestjs/tsconfig.eslint.json
new file mode 100644
index 0000000000..5d2d3b5fc8
--- /dev/null
+++ b/apps/server-nestjs/tsconfig.eslint.json
@@ -0,0 +1,19 @@
+{
+ "extends": "./tsconfig.json",
+ "compilerOptions": {
+ "rootDir": "."
+ },
+ "include": [
+ "./**/*.ts",
+ "./**/*.js",
+ "./**/*.cjs",
+ "./**/*.mjs"
+ ],
+ "exclude": [
+ "./node_modules",
+ "./dist",
+ "./types",
+ "./coverage",
+ "./**/*.d.ts"
+ ]
+}
diff --git a/apps/server-nestjs/tsconfig.json b/apps/server-nestjs/tsconfig.json
index 48b6403d6f..e12e44ce8b 100644
--- a/apps/server-nestjs/tsconfig.json
+++ b/apps/server-nestjs/tsconfig.json
@@ -1,25 +1,17 @@
{
+ "extends": [
+ "@cpn-console/ts-config/tsconfig.base.json"
+ ],
"compilerOptions": {
- "incremental": true,
- "target": "ES2023",
+ "baseUrl": ".",
+ "rootDir": ".",
+ "module": "NodeNext",
+ "moduleResolution": "NodeNext",
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
- "baseUrl": "./",
- "module": "nodenext",
- "moduleResolution": "nodenext",
- "resolvePackageJsonExports": true,
- "strictBindCallApply": false,
- "strictNullChecks": true,
- "noFallthroughCasesInSwitch": false,
- "noImplicitAny": false,
- "declaration": true,
+ "declarationDir": "./dist",
"outDir": "./dist",
"removeComments": true,
- "sourceMap": true,
- "allowSyntheticDefaultImports": true,
- "esModuleInterop": true,
- "forceConsistentCasingInFileNames": true,
- "isolatedModules": true,
- "skipLibCheck": true
+ "allowSyntheticDefaultImports": true
}
}
diff --git a/apps/server/src/connect.ts b/apps/server/src/connect.ts
index 31d608a66e..cefb56906f 100644
--- a/apps/server/src/connect.ts
+++ b/apps/server/src/connect.ts
@@ -46,8 +46,7 @@ export async function getConnection(triesLeft = 5): Promise {
}
logger.error({ err }, 'Out of retries connecting to Postgres')
- err.message = `Out of retries connecting to Postgres, last error: ${err.message}`
- throw err
+ throw new Error(`Out of retries connecting to Postgres, last error: ${err instanceof Error ? err.message : String(err)}`)
}
}
diff --git a/apps/server/src/init/db/index.ts b/apps/server/src/init/db/index.ts
index fe37b33281..97829c39b0 100644
--- a/apps/server/src/init/db/index.ts
+++ b/apps/server/src/init/db/index.ts
@@ -16,7 +16,7 @@ export async function initDb(data: Imports) {
const dataStringified = JSON.stringify(data)
const dataParsed = JSON.parse(dataStringified, (key, value) => {
try {
- if (['permissions', 'everyonePerms'].includes(key)) {
+ if (typeof key === 'string' && ['permissions', 'everyonePerms'].includes(key)) {
return BigInt(value.slice(0, value.length - 1))
}
} catch {
@@ -38,7 +38,7 @@ export async function initDb(data: Imports) {
for (const [modelKey, rows] of dataParsed.associations) {
for (const row of rows) {
const idKey = 'id'
- const connectKeys = Object.keys(row).filter(key => key !== idKey)
+ const connectKeys = Object.keys(row).filter((key): key is string => typeof key === 'string' && key !== idKey)
const dataConnects = connectKeys.reduce((acc, curr) => {
acc[curr] = { connect: row[curr] }
return acc
diff --git a/apps/server/src/init/db/utils.ts b/apps/server/src/init/db/utils.ts
index e4b941089f..16b8c2251b 100644
--- a/apps/server/src/init/db/utils.ts
+++ b/apps/server/src/init/db/utils.ts
@@ -49,7 +49,7 @@ function sort() {
|| (relationField.isRequired && !field.isRequired)
) {
const moveRes = moveBefore(ModelsOrder, model, field.type)
- if (moveRes) {
+ if (moveRes !== false) {
hasChanged = true
ModelsOrder = moveRes
}
@@ -72,11 +72,11 @@ sort()
// special case to study
const logUserCase = moveBefore(ModelsOrder, 'User', 'Log')
-if (logUserCase) {
+if (logUserCase !== false) {
ModelsOrder = logUserCase
}
const logProjectCase = moveBefore(ModelsOrder, 'Project', 'Log')
-if (logProjectCase) {
+if (logProjectCase !== false) {
ModelsOrder = logProjectCase
}
diff --git a/apps/server/src/prepare-app.ts b/apps/server/src/prepare-app.ts
index 000734714b..c7c27cd3c3 100644
--- a/apps/server/src/prepare-app.ts
+++ b/apps/server/src/prepare-app.ts
@@ -1,6 +1,3 @@
-import { rm } from 'node:fs/promises'
-import { dirname, resolve } from 'node:path'
-import { fileURLToPath } from 'node:url'
import { logger } from '@cpn-console/logger'
import app from './app.js'
import { getConnection } from './connect.js'
@@ -10,8 +7,9 @@ import { isCI, isDev, isDevSetup, isInt, isProd, isTest, port } from './utils/en
async function initializeDB(path: string) {
logger.info('Starting init DB...')
- const { data } = await import(path)
- await initDb(data)
+ const dataModule = await import(path)
+ const data = dataModule.data ?? dataModule.default
+ await initDb(data as Record)
logger.info('initDb invoked successfully')
}
@@ -24,7 +22,7 @@ export async function startServer(defaultPort: number = (port ? +port : 8080)) {
throw error
}
- initPm()
+ void initPm()
logger.info('Reading init database file')
@@ -41,7 +39,7 @@ export async function startServer(defaultPort: number = (port ? +port : 8080)) {
logger.info(`Successfully deleted '${dataPath}'`)
}
} catch (err) {
- if (err?.code === 'ERR_MODULE_NOT_FOUND' || err?.message?.includes('Failed to load') || err?.message?.includes('Cannot find module')) {
+ if (err instanceof Error && (err.code === 'ERR_MODULE_NOT_FOUND' || /Failed to load|Cannot find module/.test(err.message))) {
logger.info('No initDb file, skipping')
} else {
logger.warn({ err }, 'Init DB failed')
@@ -66,7 +64,7 @@ export async function getPreparedApp() {
throw error
}
- initPm()
+ void initPm()
logger.info('Reading init database file')
@@ -83,7 +81,7 @@ export async function getPreparedApp() {
logger.info(`Successfully deleted '${dataPath}'`)
}
} catch (err) {
- if (err?.code === 'ERR_MODULE_NOT_FOUND' || err?.message?.includes('Failed to load') || err?.message?.includes('Cannot find module')) {
+ if (err instanceof Error && (err.code === 'ERR_MODULE_NOT_FOUND' || /Failed to load|Cannot find module/.test(err.message))) {
logger.info('No initDb file, skipping')
} else {
logger.warn({ err }, 'Init DB failed')
diff --git a/apps/server/src/resources/admin-role/business.ts b/apps/server/src/resources/admin-role/business.ts
index f81fd65b75..370e87a9e7 100644
--- a/apps/server/src/resources/admin-role/business.ts
+++ b/apps/server/src/resources/admin-role/business.ts
@@ -78,8 +78,9 @@ export async function countRolesMembers() {
})
const rolesCounts: Record = Object.fromEntries(roles.map(role => [role.id, 0])) // {role uuid: 0}
for (const { adminRoleIds } of users) {
+ if (!adminRoleIds) continue
for (const roleId of adminRoleIds) {
- rolesCounts[roleId]++
+ rolesCounts[roleId]!++
}
}
return rolesCounts
diff --git a/apps/server/src/resources/admin-role/queries.ts b/apps/server/src/resources/admin-role/queries.ts
index 9c29eb0b36..f12920b6db 100644
--- a/apps/server/src/resources/admin-role/queries.ts
+++ b/apps/server/src/resources/admin-role/queries.ts
@@ -4,9 +4,9 @@ import type {
} from '@prisma/client'
import prisma from '@/prisma.js'
-export const listAdminRoles = () => prisma.adminRole.findMany({ orderBy: { position: 'asc' } })
+export const listAdminRoles = async () => prisma.adminRole.findMany({ orderBy: { position: 'asc' } })
-export function createAdminRole(data: Pick) {
+export async function createAdminRole(data: Pick) {
return prisma.adminRole.create({
data: {
name: data.name,
@@ -17,14 +17,14 @@ export function createAdminRole(data: Pick) {
+export async function updateAdminRole(id: AdminRole['id'], data: Pick) {
return prisma.adminRole.updateMany({
where: { id },
data,
})
}
-export function deleteAdminRole(id: AdminRole['id']) {
+export async function deleteAdminRole(id: AdminRole['id']) {
return prisma.adminRole.delete({
where: {
id,
diff --git a/apps/server/src/resources/cluster/queries.ts b/apps/server/src/resources/cluster/queries.ts
index f66e1fc0bc..7995edb6d5 100644
--- a/apps/server/src/resources/cluster/queries.ts
+++ b/apps/server/src/resources/cluster/queries.ts
@@ -65,21 +65,21 @@ export async function updateProjectClusterHistory(projectId: Project['id'], clus
])
}
-export function getClusterById(id: Cluster['id']) {
+export async function getClusterById(id: Cluster['id']) {
return prisma.cluster.findUnique({
where: { id },
include: { kubeconfig: true },
})
}
-export function getClusterByIdOrThrow(id: Cluster['id']) {
+export async function getClusterByIdOrThrow(id: Cluster['id']) {
return prisma.cluster.findUniqueOrThrow({
where: { id },
include: { kubeconfig: true, zone: true },
})
}
-export function getClusterEnvironments(clusterId: Cluster['id']) {
+export async function getClusterEnvironments(clusterId: Cluster['id']) {
return prisma.environment.findMany({
where: { clusterId },
select: {
@@ -99,7 +99,7 @@ export function getClusterEnvironments(clusterId: Cluster['id']) {
})
}
-export function getClusterDetails(id: Cluster['id']) {
+export async function getClusterDetails(id: Cluster['id']) {
return prisma.cluster.findUniqueOrThrow({
where: { id },
select: {
@@ -125,7 +125,7 @@ export function getClusterDetails(id: Cluster['id']) {
})
}
-export function getClustersByIds(clusterIds: Cluster['id'][]) {
+export async function getClustersByIds(clusterIds: Cluster['id'][]) {
return prisma.cluster.findMany({
where: {
id: { in: clusterIds },
@@ -134,7 +134,7 @@ export function getClustersByIds(clusterIds: Cluster['id'][]) {
})
}
-export function getPublicClusters() {
+export async function getPublicClusters() {
return prisma.cluster.findMany({
where: { privacy: 'public' },
include: { zone: true },
@@ -151,11 +151,11 @@ export async function getClusterNamesByZoneId(zoneId: string) {
return clusterNames.map(({ label }) => label)
}
-export function getClusterByLabel(label: Cluster['label']) {
+export async function getClusterByLabel(label: Cluster['label']) {
return prisma.cluster.findUnique({ where: { label } })
}
-export function getClusterByEnvironmentId(id: Environment['id']) {
+export async function getClusterByEnvironmentId(id: Environment['id']) {
return prisma.cluster.findMany({
where: {
environments: {
@@ -166,7 +166,7 @@ export function getClusterByEnvironmentId(id: Environment['id']) {
})
}
-export function getClustersWithProjectIdAndConfig() {
+export async function getClustersWithProjectIdAndConfig() {
return prisma.cluster.findMany({
select: {
id: true,
@@ -196,7 +196,7 @@ export function getClustersWithProjectIdAndConfig() {
})
}
-export function listClusters(where: Prisma.ClusterWhereInput) {
+export async function listClusters(where: Prisma.ClusterWhereInput) {
return prisma.cluster.findMany({
where,
select: {
@@ -228,7 +228,7 @@ export async function listStagesByClusterId(id: Cluster['id']) {
}))?.stages
}
-export function createCluster(data: Omit, kubeconfig: Pick, zoneId: string) {
+export async function createCluster(data: Omit, kubeconfig: Pick, zoneId: string) {
return prisma.cluster.create({
data: {
...data,
@@ -241,7 +241,7 @@ export function createCluster(data: Omit>, kubeconfig: Pick) {
+export async function updateCluster(id: Cluster['id'], data: Partial>, kubeconfig: Pick) {
return prisma.cluster.update({
where: { id },
data: {
@@ -254,7 +254,7 @@ export function updateCluster(id: Cluster['id'], data: Partial[0]['create']) {
+export async function _createLog(data: Parameters[0]['create']) {
return prisma.log.upsert({
where: {
id: data.id,
diff --git a/apps/server/src/resources/project-member/queries.ts b/apps/server/src/resources/project-member/queries.ts
index a4ceb00df1..ec81474f37 100644
--- a/apps/server/src/resources/project-member/queries.ts
+++ b/apps/server/src/resources/project-member/queries.ts
@@ -6,9 +6,9 @@ import type {
import prisma from '@/prisma.js'
-export const listMembers = (projectId: Project['id']) => prisma.projectMembers.findMany({ where: { projectId }, include: { user: true } })
+export const listMembers = async (projectId: Project['id']) => prisma.projectMembers.findMany({ where: { projectId }, include: { user: true } })
-export function upsertMember(data: Prisma.ProjectMembersUncheckedCreateInput) {
+export async function upsertMember(data: Prisma.ProjectMembersUncheckedCreateInput) {
return prisma.projectMembers.upsert({
where: {
projectId_userId: {
@@ -24,7 +24,7 @@ export function upsertMember(data: Prisma.ProjectMembersUncheckedCreateInput) {
})
}
-export function deleteMember(data: Prisma.ProjectMembersWhereUniqueInput['projectId_userId']) {
+export async function deleteMember(data: Prisma.ProjectMembersWhereUniqueInput['projectId_userId']) {
return prisma.projectMembers.delete({
where: {
projectId_userId: data,
diff --git a/apps/server/src/resources/project-role/business.ts b/apps/server/src/resources/project-role/business.ts
index 52bd8966b3..3ea6b27e00 100644
--- a/apps/server/src/resources/project-role/business.ts
+++ b/apps/server/src/resources/project-role/business.ts
@@ -102,8 +102,9 @@ export async function countRolesMembers(projectId: Project['id']) {
const members = await listMembers(projectId)
const rolesCounts: Record = Object.fromEntries(roles.map(role => [role.id, 0])) // {role uuid: 0}
for (const { roleIds } of members) {
+ if (!roleIds) continue
for (const roleId of roleIds) {
- rolesCounts[roleId]++
+ rolesCounts[roleId]!++
}
}
return rolesCounts
diff --git a/apps/server/src/resources/project-role/queries.ts b/apps/server/src/resources/project-role/queries.ts
index 3e2aa4a0fa..0cd8055d06 100644
--- a/apps/server/src/resources/project-role/queries.ts
+++ b/apps/server/src/resources/project-role/queries.ts
@@ -6,11 +6,11 @@ import type {
import prisma from '@/prisma.js'
-export const getRole = (id: ProjectRole['id']) => prisma.projectRole.findUnique({ where: { id } })
+export const getRole = async (id: ProjectRole['id']) => prisma.projectRole.findUnique({ where: { id } })
-export const listRoles = (projectId: Project['id']) => prisma.projectRole.findMany({ where: { projectId }, orderBy: { position: 'asc' } })
+export const listRoles = async (projectId: Project['id']) => prisma.projectRole.findMany({ where: { projectId }, orderBy: { position: 'asc' } })
-export function createRole(data: Pick) {
+export async function createRole(data: Pick) {
return prisma.projectRole.create({
data: {
name: data.name,
@@ -23,7 +23,7 @@ export function createRole(data: Pick) {
+export async function updateRole(id: ProjectRole['id'], data: Pick) {
return prisma.projectRole.update({
where: { id },
data,
@@ -56,4 +56,4 @@ export async function deleteRole(id: ProjectRole['id']) {
}
}
-export const getProjectRoleById = (id: ProjectRole['id']) => prisma.projectRole.findUnique({ where: { id }, include: { project: true } })
+export const getProjectRoleById = async (id: ProjectRole['id']) => prisma.projectRole.findUnique({ where: { id }, include: { project: true } })
diff --git a/apps/server/src/resources/project-service/business.ts b/apps/server/src/resources/project-service/business.ts
index bce70064ef..5e15b657a4 100644
--- a/apps/server/src/resources/project-service/business.ts
+++ b/apps/server/src/resources/project-service/business.ts
@@ -26,8 +26,8 @@ export type ConfigRecords = {
export function dbToObj(records: Omit[]): PluginsUpdateBody {
const obj: PluginsUpdateBody = {}
for (const record of records) {
- if (!obj[record.pluginName]) obj[record.pluginName] = {}
- obj[record.pluginName][record.key] = record.value
+ const plugin = obj[record.pluginName] ??= {}
+ plugin[record.key] = record.value
}
return obj
}
diff --git a/apps/server/src/resources/project-service/queries.ts b/apps/server/src/resources/project-service/queries.ts
index cf353614b2..3062bb42f8 100644
--- a/apps/server/src/resources/project-service/queries.ts
+++ b/apps/server/src/resources/project-service/queries.ts
@@ -3,7 +3,7 @@ import type { ConfigRecords } from './business.js'
import prisma from '@/prisma.js'
// CONFIG
-export function getProjectStore(projectId: Project['id']) {
+export async function getProjectStore(projectId: Project['id']) {
return prisma.projectPlugin.findMany({
where: { projectId },
select: {
diff --git a/apps/server/src/resources/project/business.ts b/apps/server/src/resources/project/business.ts
index b27f16bf64..41f5f7a5ce 100644
--- a/apps/server/src/resources/project/business.ts
+++ b/apps/server/src/resources/project/business.ts
@@ -1,5 +1,6 @@
import type { projectContract } from '@cpn-console/shared'
import type { Project, User } from '@prisma/client'
+import type { PluginResult } from '@cpn-console/hooks'
import type { UserDetails } from '@/types/index.js'
import type { ErrorResType } from '@/utils/errors.js'
import { servicesInfos } from '@cpn-console/hooks'
@@ -62,10 +63,8 @@ export async function getProjectSecrets(projectId: string) {
return Object.fromEntries(
Object.entries(hookReply.results)
- // @ts-ignore
- .filter(([_key, value]) => Object.keys(value.secrets).length)
- // @ts-ignore
- .map(([key, value]) => [servicesInfos[key]?.title, value.secrets]),
+ .filter(([_key, value]) => value != null && typeof value === 'object' && Object.keys((value as PluginResult).store?.secrets ?? {}).length)
+ .map(([key, value]) => [servicesInfos[key]?.title, (value as PluginResult).store?.secrets ?? {}]),
)
}
@@ -274,19 +273,19 @@ export async function bulkActionProject(data: typeof projectContract.bulkActionP
where: { status: { not: 'archived' } },
})).map(({ id }) => id)
}
- bulkExector(data.projectIds
+ await bulkExector(data.projectIds
.map((projectId) => {
if (data.action === 'archive') {
- return () => archiveProject(projectId, requestor, requestId)
+ return async () => archiveProject(projectId, requestor, requestId)
}
if (data.action === 'lock') {
- return () => updateProject({ locked: true }, projectId, requestor, requestId)
+ return async () => updateProject({ locked: true }, projectId, requestor, requestId)
}
if (data.action === 'unlock') {
- return () => updateProject({ locked: false }, projectId, requestor, requestId)
+ return async () => updateProject({ locked: false }, projectId, requestor, requestId)
}
if (data.action === 'replay') {
- return () => replayHooks({ projectId, userId: requestor.id, requestId })
+ return async () => replayHooks({ projectId, userId: requestor.id, requestId })
}
// should never been called
return async () => {}
@@ -301,6 +300,6 @@ export function chunk(arr: T[], size: number): T[][] {
async function bulkExector(toExecute: Array<() => Promise>) {
const toExecuteChunked = chunk(toExecute, parallelBulkLimit)
for (const chunkToExecute of toExecuteChunked) {
- await Promise.allSettled(chunkToExecute.map(fn => fn()))
+ await Promise.allSettled(chunkToExecute.map(async fn => fn()))
}
}
diff --git a/apps/server/src/resources/project/queries.ts b/apps/server/src/resources/project/queries.ts
index 5957b15478..2c60e2be88 100644
--- a/apps/server/src/resources/project/queries.ts
+++ b/apps/server/src/resources/project/queries.ts
@@ -13,7 +13,7 @@ import { appVersion } from '@/utils/env.js'
import { uuid } from '@/utils/queries-tools.js'
type ProjectUpdate = Partial>
-export function updateProject(id: Project['id'], data: ProjectUpdate) {
+export async function updateProject(id: Project['id'], data: ProjectUpdate) {
return prisma.project.update({
where: { id },
data,
@@ -83,7 +83,7 @@ export async function listProjects({
})
}
-export function getProjectOrThrow(id: Project['id'] | Project['slug']) {
+export async function getProjectOrThrow(id: Project['id'] | Project['slug']) {
return prisma.project.findFirstOrThrow({
where: uuid.test(id)
? { id }
@@ -97,7 +97,7 @@ export function getProjectOrThrow(id: Project['id'] | Project['slug']) {
})
}
-export function getProjectInfosByIdOrThrow(projectId: Project['id']) {
+export async function getProjectInfosByIdOrThrow(projectId: Project['id']) {
return prisma.project.findUniqueOrThrow({
where: {
id: projectId,
@@ -109,7 +109,7 @@ export function getProjectInfosByIdOrThrow(projectId: Project['id']) {
})
}
-export function getProjectMembers(projectId: Project['id']) {
+export async function getProjectMembers(projectId: Project['id']) {
return prisma.projectMembers.findMany({
where: {
projectId,
@@ -118,7 +118,7 @@ export function getProjectMembers(projectId: Project['id']) {
})
}
-export function getProjectById(id: Project['id']) {
+export async function getProjectById(id: Project['id']) {
return prisma.project.findUnique({ where: { id } })
}
@@ -129,21 +129,21 @@ export const baseProjectIncludes = {
owner: true,
} as const
-export function getProjectInfos(id: Project['id']) {
+export async function getProjectInfos(id: Project['id']) {
return prisma.project.findUnique({
where: { id },
include: baseProjectIncludes,
})
}
-export function getProjectInfosOrThrow(id: Project['id']) {
+export async function getProjectInfosOrThrow(id: Project['id']) {
return prisma.project.findUniqueOrThrow({
where: { id },
include: baseProjectIncludes,
})
}
-export function getProjectInfosAndRepos(id: Project['id']) {
+export async function getProjectInfosAndRepos(id: Project['id']) {
return prisma.project.findUniqueOrThrow({
where: { id },
include: {
@@ -153,7 +153,7 @@ export function getProjectInfosAndRepos(id: Project['id']) {
})
}
-export function getSlugs(slugPrefix: string) {
+export async function getSlugs(slugPrefix: string) {
return prisma.project.findMany({
where: {
slug: { startsWith: slugPrefix },
@@ -161,7 +161,7 @@ export function getSlugs(slugPrefix: string) {
})
}
-export function getAllProjectsDataForExport() {
+export async function getAllProjectsDataForExport() {
return prisma.project.findMany({
select: {
name: true,
@@ -182,7 +182,7 @@ export function getAllProjectsDataForExport() {
})
}
-export function getRolesByProjectId(projectId: Project['id']) {
+export async function getRolesByProjectId(projectId: Project['id']) {
return prisma.projectRole.findMany({
where: { projectId },
})
@@ -208,7 +208,7 @@ const clusterInfosSelect = {
},
},
}
-export function getHookProjectInfos(id: Project['id']) {
+export async function getHookProjectInfos(id: Project['id']) {
return prisma.project.findUniqueOrThrow({
where: { id },
include: {
@@ -251,7 +251,7 @@ interface CreateProjectParams {
prodMemory: number
}
-export function initializeProject(params: CreateProjectParams) {
+export async function initializeProject(params: CreateProjectParams) {
return prisma.project.create({
data: {
description: params.description ?? '',
@@ -302,14 +302,14 @@ export function initializeProject(params: CreateProjectParams) {
}
// UPDATE
-export function lockProject(id: Project['id']) {
+export async function lockProject(id: Project['id']) {
return prisma.project.update({
where: { id },
data: { locked: true },
})
}
-export function updateProjectCreated(id: Project['id']) {
+export async function updateProjectCreated(id: Project['id']) {
return prisma.project.update({
where: { id },
data: {
@@ -320,7 +320,7 @@ export function updateProjectCreated(id: Project['id']) {
})
}
-export function updateProjectFailed(id: Project['id']) {
+export async function updateProjectFailed(id: Project['id']) {
return prisma.project.update({
where: { id },
data: { status: ProjectStatus.failed },
@@ -328,7 +328,7 @@ export function updateProjectFailed(id: Project['id']) {
})
}
-export function updateProjectWarning(id: Project['id']) {
+export async function updateProjectWarning(id: Project['id']) {
return prisma.project.update({
where: { id },
data: { status: ProjectStatus.warning },
@@ -336,7 +336,7 @@ export function updateProjectWarning(id: Project['id']) {
})
}
-export function addUserToProject({ project, user }: { project: Project, user: User }) {
+export async function addUserToProject({ project, user }: { project: Project, user: User }) {
return prisma.projectMembers.create({
data: {
userId: user.id,
@@ -345,7 +345,7 @@ export function addUserToProject({ project, user }: { project: Project, user: Us
})
}
-export function removeUserFromProject({ projectId, userId }: { projectId: Project['id'], userId: User['id'] }) {
+export async function removeUserFromProject({ projectId, userId }: { projectId: Project['id'], userId: User['id'] }) {
return prisma.projectMembers.delete({
where: {
projectId_userId: {
diff --git a/apps/server/src/resources/repository/queries.ts b/apps/server/src/resources/repository/queries.ts
index 277e7af602..33d9ec561d 100644
--- a/apps/server/src/resources/repository/queries.ts
+++ b/apps/server/src/resources/repository/queries.ts
@@ -2,11 +2,11 @@ import type { Project, Repository } from '@prisma/client'
import prisma from '@/prisma.js'
// SELECT
-export function getRepositoryById(id: Repository['id']) {
+export async function getRepositoryById(id: Repository['id']) {
return prisma.repository.findUniqueOrThrow({ where: { id } })
}
-export function getProjectRepositories(projectId: Project['id']) {
+export async function getProjectRepositories(projectId: Project['id']) {
return prisma.repository.findMany({ where: { projectId } })
}
@@ -14,7 +14,7 @@ export function getProjectRepositories(projectId: Project['id']) {
type RepositoryCreate = Pick
& Partial>
-export function initializeRepository({ projectId, internalRepoName, externalRepoUrl, isInfra, isPrivate, externalUserName, deployRevision, deployPath, helmValuesFiles }: RepositoryCreate) {
+export async function initializeRepository({ projectId, internalRepoName, externalRepoUrl, isInfra, isPrivate, externalUserName, deployRevision, deployPath, helmValuesFiles }: RepositoryCreate) {
return prisma.repository.create({
data: {
projectId,
@@ -30,7 +30,7 @@ export function initializeRepository({ projectId, internalRepoName, externalRepo
})
}
-export function getHookRepository(id: Repository['id']) {
+export async function getHookRepository(id: Repository['id']) {
return prisma.repository.findUniqueOrThrow({
where: {
id,
@@ -42,7 +42,7 @@ export function getHookRepository(id: Repository['id']) {
}
// UPDATE
-export function updateRepository(id: Repository['id'], infos: Partial) {
+export async function updateRepository(id: Repository['id'], infos: Partial) {
return prisma.repository.update({ where: { id }, data: { ...infos } })
}
@@ -53,10 +53,10 @@ export async function deleteRepository(id: Repository['id']) {
return prisma.repository.delete({ where: { id } })
}
-export function deleteAllRepositoryForProject(id: Project['id']) {
+export async function deleteAllRepositoryForProject(id: Project['id']) {
return prisma.repository.deleteMany({ where: { projectId: id } })
}
-export function _createRepository(data: Parameters[0]['create']) {
+export async function _createRepository(data: Parameters[0]['create']) {
return prisma.repository.upsert({ create: data, update: data, where: { id: data.id } })
}
diff --git a/apps/server/src/resources/service-chain/queries.ts b/apps/server/src/resources/service-chain/queries.ts
index 0207266c8a..b63f967b94 100644
--- a/apps/server/src/resources/service-chain/queries.ts
+++ b/apps/server/src/resources/service-chain/queries.ts
@@ -45,11 +45,11 @@ export async function getServiceChainDetails(
}
export async function retryServiceChain(serviceChainId: ServiceChain['id']) {
- return await getClient().post(`/requests/${serviceChainId}/retry`)
+ return getClient().post(`/requests/${serviceChainId}/retry`)
}
export async function validateServiceChain(validationId: string) {
- return await getClient().post(`/validate/${validationId}`)
+ return getClient().post(`/validate/${validationId}`)
}
export async function getServiceChainFlows(serviceChainId: ServiceChain['id']) {
diff --git a/apps/server/src/resources/stage/queries.ts b/apps/server/src/resources/stage/queries.ts
index 98d526600a..c5d202f936 100644
--- a/apps/server/src/resources/stage/queries.ts
+++ b/apps/server/src/resources/stage/queries.ts
@@ -1,7 +1,7 @@
import type { Cluster, Stage } from '@prisma/client'
import prisma from '@/prisma.js'
-export function listStages() {
+export async function listStages() {
return prisma.stage.findMany({
include: {
clusters: true,
@@ -17,7 +17,7 @@ export async function getAllStageIds() {
})).map(({ id }) => id)
}
-export function getStageById(id: Stage['id']) {
+export async function getStageById(id: Stage['id']) {
return prisma.stage.findUnique({
where: { id },
include: {
@@ -26,7 +26,7 @@ export function getStageById(id: Stage['id']) {
})
}
-export function getStageByIdOrThrow(id: Stage['id']) {
+export async function getStageByIdOrThrow(id: Stage['id']) {
return prisma.stage.findUniqueOrThrow({
where: { id },
include: {
@@ -35,7 +35,7 @@ export function getStageByIdOrThrow(id: Stage['id']) {
})
}
-export function getStageAssociatedEnvironmentById(id: Stage['id']) {
+export async function getStageAssociatedEnvironmentById(id: Stage['id']) {
return prisma.environment.findMany({
where: {
stageId: id,
@@ -58,7 +58,7 @@ export function getStageAssociatedEnvironmentById(id: Stage['id']) {
})
}
-export function getStageAssociatedEnvironmentLengthById(id: Stage['id']) {
+export async function getStageAssociatedEnvironmentLengthById(id: Stage['id']) {
return prisma.environment.count({
where: {
stageId: id,
@@ -66,13 +66,13 @@ export function getStageAssociatedEnvironmentLengthById(id: Stage['id']) {
})
}
-export function getStageByName(name: Stage['name']) {
+export async function getStageByName(name: Stage['name']) {
return prisma.stage.findUnique({
where: { name },
})
}
-export function linkStageToClusters(id: Stage['id'], clusterIds: Cluster['id'][]) {
+export async function linkStageToClusters(id: Stage['id'], clusterIds: Cluster['id'][]) {
return prisma.stage.update({
where: {
id,
@@ -85,7 +85,7 @@ export function linkStageToClusters(id: Stage['id'], clusterIds: Cluster['id'][]
})
}
-export function createStage({ name }: { name: Stage['name'] }) {
+export async function createStage({ name }: { name: Stage['name'] }) {
return prisma.stage.create({
data: {
name,
@@ -93,7 +93,7 @@ export function createStage({ name }: { name: Stage['name'] }) {
})
}
-export function updateStageName(id: Stage['id'], name: Stage['name']) {
+export async function updateStageName(id: Stage['id'], name: Stage['name']) {
return prisma.stage.update({
where: {
id,
@@ -104,7 +104,7 @@ export function updateStageName(id: Stage['id'], name: Stage['name']) {
})
}
-export function deleteStage(id: Stage['id']) {
+export async function deleteStage(id: Stage['id']) {
return prisma.stage.delete({
where: { id },
})
diff --git a/apps/server/src/resources/system/settings/business.ts b/apps/server/src/resources/system/settings/business.ts
index 5e562353b0..2eae92d594 100644
--- a/apps/server/src/resources/system/settings/business.ts
+++ b/apps/server/src/resources/system/settings/business.ts
@@ -4,6 +4,6 @@ import {
upsertSystemSetting as upsertSystemSettingQuery,
} from './queries.js'
-export const getSystemSettings = (key?: string) => getSystemSettingsQuery({ key })
+export const getSystemSettings = async (key?: string) => getSystemSettingsQuery({ key })
-export const upsertSystemSetting = (newSystemSetting: UpsertSystemSettingBody) => upsertSystemSettingQuery(newSystemSetting)
+export const upsertSystemSetting = async (newSystemSetting: UpsertSystemSettingBody) => upsertSystemSettingQuery(newSystemSetting)
diff --git a/apps/server/src/resources/system/settings/queries.ts b/apps/server/src/resources/system/settings/queries.ts
index c64cb3b74c..ffa1f2692a 100644
--- a/apps/server/src/resources/system/settings/queries.ts
+++ b/apps/server/src/resources/system/settings/queries.ts
@@ -1,7 +1,7 @@
import type { Prisma, SystemSetting } from '@prisma/client'
import prisma from '@/prisma.js'
-export function upsertSystemSetting(newSystemSetting: SystemSetting) {
+export async function upsertSystemSetting(newSystemSetting: SystemSetting) {
return prisma.systemSetting.upsert({
create: {
...newSystemSetting,
@@ -15,4 +15,4 @@ export function upsertSystemSetting(newSystemSetting: SystemSetting) {
})
}
-export const getSystemSettings = (where?: Prisma.SystemSettingWhereInput) => prisma.systemSetting.findMany({ where })
+export const getSystemSettings = async (where?: Prisma.SystemSettingWhereInput) => prisma.systemSetting.findMany({ where })
diff --git a/apps/server/src/resources/user/queries.ts b/apps/server/src/resources/user/queries.ts
index 1e33a8128b..4906bfbf87 100644
--- a/apps/server/src/resources/user/queries.ts
+++ b/apps/server/src/resources/user/queries.ts
@@ -4,7 +4,7 @@ import prisma from '@/prisma.js'
type UserCreate = Omit
// SELECT
-export const getUsers = (where?: Prisma.UserWhereInput) => prisma.user.findMany({ where })
+export const getUsers = async (where?: Prisma.UserWhereInput) => prisma.user.findMany({ where })
export async function getUserInfos(id: User['id']) {
return prisma.user.findMany({
@@ -15,24 +15,24 @@ export async function getUserInfos(id: User['id']) {
})
}
-export function getMatchingUsers(where: Prisma.UserWhereInput) {
+export async function getMatchingUsers(where: Prisma.UserWhereInput) {
return prisma.user.findMany({
where,
take: 5,
})
}
-export function getUserById(id: User['id']) {
+export async function getUserById(id: User['id']) {
return prisma.user.findUnique({ where: { id } })
}
-export function getUserOrThrow(id: User['id']) {
+export async function getUserOrThrow(id: User['id']) {
return prisma.user.findUniqueOrThrow({
where: { id },
})
}
-export function getUserByEmail(email: User['email']) {
+export async function getUserByEmail(email: User['email']) {
return prisma.user.findUnique({ where: { email } })
}
@@ -55,6 +55,6 @@ export async function updateUserById({ id, email, firstName, lastName }: UserCre
}
// TECH
-export function _createUser(data: Prisma.UserCreateInput) {
+export async function _createUser(data: Prisma.UserCreateInput) {
return prisma.user.upsert({ where: { id: data.id }, create: data, update: data })
}
diff --git a/apps/server/src/resources/zone/queries.ts b/apps/server/src/resources/zone/queries.ts
index 1390bb153a..1d1f75a085 100644
--- a/apps/server/src/resources/zone/queries.ts
+++ b/apps/server/src/resources/zone/queries.ts
@@ -1,13 +1,13 @@
import type { Cluster, Zone } from '@prisma/client'
import prisma from '@/prisma.js'
-export function getZoneByIdOrThrow(id: Zone['id']) {
+export async function getZoneByIdOrThrow(id: Zone['id']) {
return prisma.zone.findUniqueOrThrow({
where: { id },
})
}
-export function linkZoneToClusters(zoneId: Zone['id'], clusterIds: Cluster['id'][]) {
+export async function linkZoneToClusters(zoneId: Zone['id'], clusterIds: Cluster['id'][]) {
return prisma.zone.update({
where: {
id: zoneId,
diff --git a/apps/server/src/server.spec.ts b/apps/server/src/server.spec.ts
index 5dc093888a..d44dcfc7ea 100644
--- a/apps/server/src/server.spec.ts
+++ b/apps/server/src/server.spec.ts
@@ -15,7 +15,7 @@ vi.mock('./prepare-app.js', () => {
close: vi.fn(async () => {}),
}
return {
- getPreparedApp: () => Promise.resolve(app),
+ getPreparedApp: async () => Promise.resolve(app),
}
})
vi.spyOn(logger, 'warn')
diff --git a/apps/server/src/telemetry.ts b/apps/server/src/telemetry.ts
index 65b59dddab..24ca764b1f 100644
--- a/apps/server/src/telemetry.ts
+++ b/apps/server/src/telemetry.ts
@@ -22,5 +22,5 @@ const sdk = new NodeSDK({
sdk.start()
process.once('beforeExit', () => {
- sdk.shutdown()
+ void sdk.shutdown()
})
diff --git a/apps/server/src/utils/business.ts b/apps/server/src/utils/business.ts
index 10fe3ced2f..22f8ab43ad 100644
--- a/apps/server/src/utils/business.ts
+++ b/apps/server/src/utils/business.ts
@@ -11,11 +11,11 @@ export class Result {
) {}
static succeed(value: T): Success {
- return new Result(true, value) as Success
+ return new Result(true, value)
}
- static fail(message: string): Failure {
- return new Result(false, message) as Failure
+ static fail(message: string): Result {
+ return new Result(false, message)
}
get isSuccess(): boolean {
diff --git a/apps/server/src/utils/controller.ts b/apps/server/src/utils/controller.ts
index 57ab7865af..74a742b8d8 100644
--- a/apps/server/src/utils/controller.ts
+++ b/apps/server/src/utils/controller.ts
@@ -83,7 +83,7 @@ export async function authUser(req: FastifyRequest, projectUnique: ProjectUnique
export async function authUser(req: FastifyRequest, projectUnique?: ProjectUniqueFinder): Promise {
let adminPermissions: bigint = 0n
let tokenId: string | undefined
- const reqUser: UserTrial = req.session.user as unknown as UserTrial
+ const reqUser = req.session.user as UserTrial satisfies UserTrial
let user: UserDetails | undefined
if (req.session.user) {
diff --git a/apps/server/src/utils/hook-wrapper.spec.ts b/apps/server/src/utils/hook-wrapper.spec.ts
index c2f4e3ebcc..b89f68d72b 100644
--- a/apps/server/src/utils/hook-wrapper.spec.ts
+++ b/apps/server/src/utils/hook-wrapper.spec.ts
@@ -1,4 +1,4 @@
-import type { KubeCluster, KubeUser, Project as ProjectPayload, Store } from '@cpn-console/hooks'
+import type { Project as ProjectPayload, Store } from '@cpn-console/hooks'
import type { ProjectInfos, ReposCreds } from './hook-wrapper.ts'
import { describe, expect, it } from 'vitest'
import { transformToHookProject } from './hook-wrapper.ts'
@@ -215,8 +215,8 @@ describe('transformToHookProject', () => {
// Assert sur la transformation des clusters
expect(result.clusters).toEqual([associatedCluster, nonAssociatedCluster].map(({ kubeconfig, ...cluster }) => ({
- user: kubeconfig.user as unknown as KubeUser,
- cluster: kubeconfig.cluster as unknown as KubeCluster,
+ user: kubeconfig.user,
+ cluster: kubeconfig.cluster,
...cluster,
privacy: cluster.privacy,
})))
diff --git a/apps/server/src/utils/hook-wrapper.ts b/apps/server/src/utils/hook-wrapper.ts
index 0df3d89a4b..f7abd77472 100644
--- a/apps/server/src/utils/hook-wrapper.ts
+++ b/apps/server/src/utils/hook-wrapper.ts
@@ -146,17 +146,17 @@ async function manageProjectStatus(projectId: Project['id'], hookReply: HookResu
const cluster = {
upsert: async (clusterId: Cluster['id'], previousZoneId: Cluster['zoneId']) => {
const cluster = await getClusterByIdOrThrow(clusterId)
- const clusterObject = cluster as unknown as ClusterObject
+ const clusterObject = cluster as unknown as ClusterObject satisfies ClusterObject
const store = dbToObj(await getAdminPlugin())
if (cluster.zoneId !== previousZoneId) {
// Upsert on the old zone to remove cluster
const previousClusterObject = {
...cluster,
- } as unknown as ClusterObject
+ } as unknown as ClusterObject satisfies ClusterObject
previousClusterObject.zone = await getZoneByIdOrThrow(previousZoneId)
previousClusterObject.zone.clusterNames = await getClusterNamesByZoneId(previousZoneId)
const hookResult = await hooks.upsertCluster.execute({
- ...cluster.kubeconfig as unknown as Pick,
+ ...cluster.kubeconfig as unknown as Pick satisfies Pick,
...previousClusterObject,
}, store)
if (hookResult.failed) {
@@ -165,18 +165,18 @@ const cluster = {
}
clusterObject.zone.clusterNames = await getClusterNamesByZoneId(cluster.zoneId)
return hooks.upsertCluster.execute({
- ...cluster.kubeconfig as unknown as Pick,
+ ...cluster.kubeconfig as unknown as Pick satisfies Pick,
...clusterObject,
}, store)
},
delete: async (clusterId: Cluster['id']) => {
const cluster = await getClusterByIdOrThrow(clusterId)
- const clusterObject = cluster as unknown as ClusterObject
+ const clusterObject = cluster as unknown as ClusterObject satisfies ClusterObject
const clusterNames = await getClusterNamesByZoneId(cluster.zoneId)
clusterObject.zone.clusterNames = clusterNames.filter(c => c !== cluster.label)
const store = dbToObj(await getAdminPlugin())
return hooks.deleteCluster.execute({
- ...cluster.kubeconfig as unknown as ClusterObject,
+ ...cluster.kubeconfig as unknown as ClusterObject satisfies ClusterObject,
...clusterObject,
}, store)
},
@@ -214,7 +214,7 @@ const projectMember = {
firstName: member.user.firstName,
lastName: member.user.lastName,
email: member.user.email,
- type: member.user.type as 'human' | 'bot' | 'ghost',
+ type: member.user.type,
createdAt: member.user.createdAt.toISOString(),
updatedAt: member.user.updatedAt.toISOString(),
lastLogin: member.user.lastLogin?.toISOString(),
@@ -249,7 +249,7 @@ const projectMember = {
firstName: member.user.firstName,
lastName: member.user.lastName,
email: member.user.email,
- type: member.user.type as 'human' | 'bot' | 'ghost',
+ type: member.user.type,
createdAt: member.user.createdAt.toISOString(),
updatedAt: member.user.updatedAt.toISOString(),
lastLogin: member.user.lastLogin?.toISOString(),
@@ -365,8 +365,8 @@ export const hook = {
function formatClusterInfos({ kubeconfig, ...cluster }: Omit
& { kubeconfig: Kubeconfig, zone: Pick }) {
return {
- user: kubeconfig.user as unknown as KubeUser,
- cluster: kubeconfig.cluster as unknown as KubeCluster,
+ user: kubeconfig.user as unknown as KubeUser satisfies KubeUser,
+ cluster: kubeconfig.cluster as unknown as KubeCluster satisfies KubeCluster,
...cluster,
privacy: cluster.privacy,
}
diff --git a/apps/server/src/utils/proxy.spec.ts b/apps/server/src/utils/proxy.spec.ts
index 7fdc203833..9f32a0cee2 100644
--- a/apps/server/src/utils/proxy.spec.ts
+++ b/apps/server/src/utils/proxy.spec.ts
@@ -97,7 +97,7 @@ describe('test calls with ID passed', () => {
it('calling method with exclusion in progress', async () => {
const proxied = genericProxy(target, { fetchData: ['otherMethod'] })
// Simuler une exécution en cours pour la méthode exclue
- proxied.otherMethod('456')
+ void proxied.otherMethod('456')
// Maintenant, tenter d'appeler fetchData pour le même ID devrait échouer
await expect(proxied.fetchData('456')).rejects.toThrow(
@@ -148,7 +148,7 @@ describe('test calls with ID passed', () => {
// Tentative de définir une nouvelle propriété sur le proxy
const setAttempt = () => {
- proxied.fetchData = () => new Promise(resolve => resolve('illegal'))
+ proxied.fetchData = async () => new Promise(resolve => resolve('illegal'))
}
// Vérification que la tentative de set est rejetée
diff --git a/apps/server/src/utils/proxy.ts b/apps/server/src/utils/proxy.ts
index ef915a7d15..535de60a8a 100644
--- a/apps/server/src/utils/proxy.ts
+++ b/apps/server/src/utils/proxy.ts
@@ -14,13 +14,13 @@ export function genericProxy(proxied: T, excludes: Excludes = {}): T {
get({ methods, tracker }, property: string) {
if (!(property in methods)) return
return async (...args) => {
- const id = args[0] as string
+ const id = args[0] as string | undefined
- if (!id && args.length > 0) {
+ if (id != null && args.length > 0) {
throw new Error('ID is required when args are provided')
}
- if (!id) {
+ if (id == null) {
if (tracker[property] instanceof Promise) {
return tracker[property]
}
@@ -29,37 +29,36 @@ export function genericProxy(proxied: T, excludes: Excludes = {}): T {
tracker[property] = p
p.then(() => {
delete tracker[property]
- })
+ }).catch(() => {})
}
return p
}
- if (!tracker[property]) {
+ if (tracker[property] == null) {
tracker[property] = {}
}
for (const testExclude of excludes[property] ?? []) {
- // @ts-ignore
- if (tracker?.[testExclude]?.[id]?.currentExec) {
+ if (tracker[testExclude]?.[id]?.currentExec) {
throw new Error(`${String(testExclude)} in progress on ${id}, can't ${String(property)}`)
}
}
if (id in tracker[property]) {
- if (args[1]) {
+ if (args[1] != null) {
tracker[property][id].nextArgs = {
...(tracker[property][id].nextArgs ?? {}),
...args[1],
}
}
- if (tracker[property][id].currentExec) {
+ if (tracker[property][id].currentExec != null) {
return new Promise((resolve) => {
- tracker[property][id].currentExec.then(() => {
+ tracker[property][id].currentExec!.then(() => {
resolve(tracker[property][id].currentExec ?? methods[property](id, tracker[property][id].nextArgs))
})
})
}
}
- const p = methods[property](...args)
+ const p = methods[property](...(args as [string, ...unknown[]]))
tracker[property][id] = {
currentExec: p,
nextArgs: undefined,
@@ -67,7 +66,7 @@ export function genericProxy(proxied: T, excludes: Excludes = {}): T {
tracker[property][id].currentExec = p
p.then(() => {
tracker[property][id].currentExec = undefined
- })
+ }).catch(() => {})
return p
}
},
diff --git a/apps/server/tsconfig.eslint.json b/apps/server/tsconfig.eslint.json
new file mode 100644
index 0000000000..96e186b94b
--- /dev/null
+++ b/apps/server/tsconfig.eslint.json
@@ -0,0 +1,19 @@
+{
+ "extends": ["./tsconfig.json"],
+ "compilerOptions": {
+ "rootDir": "."
+ },
+ "include": [
+ "./**/*.ts",
+ "./**/*.js",
+ "./**/*.cjs",
+ "./**/*.mjs"
+ ],
+ "exclude": [
+ "./node_modules",
+ "./dist",
+ "./types",
+ "./coverage",
+ "./**/*.d.ts"
+ ]
+}
diff --git a/apps/server/tsconfig.json b/apps/server/tsconfig.json
index a3397898ca..e40e0fa2ad 100644
--- a/apps/server/tsconfig.json
+++ b/apps/server/tsconfig.json
@@ -8,7 +8,6 @@
"paths": {
"@/*": ["src/*"]
},
- "useUnknownInCatchVariables": false,
"declarationDir": "./types",
"outDir": "./dist",
"plugins": [{ "transform": "typescript-transform-paths" }]
diff --git a/packages/eslintconfig/src/index.js b/packages/eslintconfig/src/index.js
index 79867556e6..ec45ab313d 100644
--- a/packages/eslintconfig/src/index.js
+++ b/packages/eslintconfig/src/index.js
@@ -16,7 +16,15 @@ export default antfu(
'ts/ban-ts-comment': 'off',
},
},
- typescript: true,
+ typescript: {
+ tsconfigPath: 'tsconfig.json',
+ parserOptions: {
+ tsconfigRootDir: process.cwd(),
+ projectService: {
+ allowDefaultProject: ['*.js', '*.cjs', '*.mjs'],
+ },
+ },
+ },
vue: true,
yaml: {
overrides: {
diff --git a/packages/hooks/src/config.ts b/packages/hooks/src/config.ts
index ab1a702bf9..413fd8e881 100644
--- a/packages/hooks/src/config.ts
+++ b/packages/hooks/src/config.ts
@@ -23,7 +23,7 @@ export const editStrippersGenerator = pluginConfig.transform((arg) => {
}
}
- for (const item of arg.global || []) {
+ for (const item of arg.global ?? []) {
if (item.permissions.admin.write) {
const zAny = atomicValidators[item.kind].optional()
global = global.merge(z.object({ [item.key]: zAny }))
diff --git a/packages/hooks/src/hooks/hook.ts b/packages/hooks/src/hooks/hook.ts
index 1377d9abcc..be18ea8363 100644
--- a/packages/hooks/src/hooks/hook.ts
+++ b/packages/hooks/src/hooks/hook.ts
@@ -8,6 +8,7 @@ export type PluginResultStore = Record
export interface PluginResult {
status: { result: 'OK', message?: string } | { result: 'KO' | 'WARNING', message: string }
store?: PluginResultStore
+ executionTime?: Record
[key: string]: any
}
@@ -52,13 +53,13 @@ function generateMessageResume(payload: HookPayload(
const result = settled.status === 'fulfilled'
? handleFulfilledStepResult(settled.value, name, stepName, payload)
: handleRejectedStepResult(settled.reason, name, stepName, payload)
- return { ...result, executionTime: payload.results[name].executionTime }
+ return result
}
export async function executeStep(step: HookStep, payload: HookPayload, stepName: string) {
const names = Object.keys(step)
const fns = names.map(async (name) => {
- if (payload.results[name]?.executionTime) {
- payload.results[name].executionTime[stepName] = Date.now()
+ const existingResult = payload.results[name]
+ if (existingResult !== undefined) {
+ if (existingResult.executionTime !== undefined) {
+ existingResult.executionTime[stepName] = Date.now()
+ } else {
+ existingResult.executionTime = { [stepName]: Date.now() }
+ }
} else {
payload.results[name] = {
status: { result: 'OK' },
executionTime: { [stepName]: Date.now() },
}
}
- const fnResult = await step[name](payload)
- payload.results[name].executionTime[stepName] = Date.now() - payload.results[name].executionTime[stepName]
+ const fnResult = await step[name]!(payload)
+ const resultEntry = payload.results[name]!
+ resultEntry.executionTime = resultEntry.executionTime ?? {}
+ resultEntry.executionTime[stepName] = Date.now() - (resultEntry.executionTime[stepName] ?? 0)
return fnResult
})
const results = await Promise.allSettled(fns)
names.forEach((name, index) => {
- payload.results[name] = handleStepResult(results[index], name, stepName, payload)
+ payload.results[name] = handleStepResult(results[index]!, name, stepName, payload)
})
return payload
}
@@ -164,7 +172,7 @@ export function createHook(unique = false) {
const executeSteps = ['pre', 'main', 'post'] as const
for (const step of executeSteps) {
payload = await executeStep(steps[step], payload, step)
- if (payload.failed) {
+ if (payload.failed === true) {
payload = await executeStep(steps.revert, payload, 'revert')
break
}
diff --git a/packages/hooks/src/index.ts b/packages/hooks/src/index.ts
index ad4af3bca8..6012d503e1 100644
--- a/packages/hooks/src/index.ts
+++ b/packages/hooks/src/index.ts
@@ -63,7 +63,7 @@ function pluginManager(options: PluginManagerOptions): PluginManager {
plugin.monitor.monitorFn = async (instance: Monitor) => instance.lastStatus
}
if (plugin.monitor)
- plugin.monitor.refresh()
+ void plugin.monitor.refresh()
servicesInfos[plugin.infos.name] = {
...plugin.infos,
monitor: plugin.monitor,
diff --git a/packages/hooks/src/services.ts b/packages/hooks/src/services.ts
index dce8693564..39cf9d7149 100644
--- a/packages/hooks/src/services.ts
+++ b/packages/hooks/src/services.ts
@@ -31,10 +31,12 @@ export const services = {
return [...acc, { ...serviceInfos.monitor.lastStatus, name: serviceInfos.title }]
}, [] as Array)
},
- refreshStatus: (): Array> => {
- // @ts-ignore obligé d'ignore TS ne comprend pas l'interet du filter
- return Object.values(servicesInfos)
- .filter(servicesInfos => servicesInfos.monitor)
- .map(serviceInfos => serviceInfos.monitor?.refresh())
+ refreshStatus: async (): Promise => {
+ const results = await Promise.all(
+ Object.values(servicesInfos)
+ .filter(serviceInfos => serviceInfos.monitor)
+ .map(async serviceInfos => serviceInfos.monitor!.refresh()),
+ )
+ return results
},
}
diff --git a/packages/hooks/src/utils/plugin-result-handler.ts b/packages/hooks/src/utils/plugin-result-handler.ts
index a90261aede..1e703ccaef 100644
--- a/packages/hooks/src/utils/plugin-result-handler.ts
+++ b/packages/hooks/src/utils/plugin-result-handler.ts
@@ -8,12 +8,12 @@ export class PluginResultBuilder {
public store: PluginResultStore = {}
constructor(okMessage: string | undefined) {
- if (okMessage) {
+ if (okMessage != null && okMessage !== '') {
this.okMessages.push(okMessage)
}
}
- addExtra(key: string, value: any) {
+ addExtra(key: string, value: unknown) {
this.extras[key] = value
return this
}
diff --git a/packages/hooks/src/utils/utils.ts b/packages/hooks/src/utils/utils.ts
index 65d03954c2..fd8faa10da 100644
--- a/packages/hooks/src/utils/utils.ts
+++ b/packages/hooks/src/utils/utils.ts
@@ -7,7 +7,7 @@ export function objectEntries>(obj: Obj): ([
return Object.entries(obj) as ([keyof Obj, Obj[keyof Obj]])[]
}
export function objectKeys>(obj: Obj): (keyof Obj)[] {
- return Object.keys(obj) as (keyof Obj)[]
+ return Object.keys(obj)
}
export function objectValues>(obj: Obj): (Obj[keyof Obj])[] {
return Object.values(obj) as (Obj[keyof Obj])[]
@@ -21,11 +21,11 @@ export type DeclareModuleGenerator value ? [ENABLED, DEFAULT].includes(value) : true
-export const disabledOrDefaultOrNullish = (value?: string): boolean | undefined => value ? [DISABLED, DEFAULT].includes(value) : true
-export const specificallyDisabled = (value?: string): boolean | undefined => value ? value === DISABLED : undefined
-export const specificallyEnabled = (value?: string): boolean | undefined => value ? value === ENABLED : undefined
-export const defaultOrNullish = (value?: string): boolean | undefined => value ? DEFAULT === value : true
+export const enabledOrDefaultOrNullish = (value?: string): boolean | undefined => value != null && [ENABLED, DEFAULT].includes(value)
+export const disabledOrDefaultOrNullish = (value?: string): boolean | undefined => value != null && [DISABLED, DEFAULT].includes(value)
+export const specificallyDisabled = (value?: string): boolean | undefined => value != null && value === DISABLED
+export const specificallyEnabled = (value?: string): boolean | undefined => value != null && value === ENABLED
+export const defaultOrNullish = (value?: string): boolean | undefined => value != null && DEFAULT === value
export const okStatus = { status: { result: 'OK' } } as const
diff --git a/packages/logger/src/index.ts b/packages/logger/src/index.ts
index cf2a6e2397..d7cf6e8a19 100644
--- a/packages/logger/src/index.ts
+++ b/packages/logger/src/index.ts
@@ -44,6 +44,7 @@ const redact: LoggerOptions['redact'] = {
export function getLoggerOptions(env: Env, level: LogLevel): LoggerOptions {
switch (env) {
case 'development':
+ case 'test':
return {
transport: {
target: 'pino-pretty',
diff --git a/packages/logger/tsconfig.eslint.json b/packages/logger/tsconfig.eslint.json
index 982c60cf77..5d2d3b5fc8 100644
--- a/packages/logger/tsconfig.eslint.json
+++ b/packages/logger/tsconfig.eslint.json
@@ -1,5 +1,8 @@
{
"extends": "./tsconfig.json",
+ "compilerOptions": {
+ "rootDir": "."
+ },
"include": [
"./**/*.ts",
"./**/*.js",
diff --git a/packages/shared/src/schemas/repository.ts b/packages/shared/src/schemas/repository.ts
index 85675b9123..0d5cb16d5c 100644
--- a/packages/shared/src/schemas/repository.ts
+++ b/packages/shared/src/schemas/repository.ts
@@ -41,15 +41,15 @@ export const UpdateRepoFormSchema = RepoFormSchema
.refine(
({ isPrivate, externalToken, externalUserName }) => {
if (isPrivate) {
- if (!externalToken && !externalUserName) return false
- return true
+ if ((externalToken != null && externalToken !== '') || (externalUserName != null && externalUserName !== '')) return true
+ return false
}
return true
},
{ message: missingCredentials, path: ['credentials'] },
)
.refine(({ isStandalone, externalRepoUrl }) => {
- if (!isStandalone && !externalRepoUrl) {
+ if (!isStandalone && (externalRepoUrl == null || externalRepoUrl === '')) {
return false
}
return true
@@ -59,13 +59,13 @@ export const CreateRepoFormSchema = RepoFormSchema
.omit({ id: true, projectId: true })
.refine(({ isPrivate, externalToken, externalUserName }) => {
if (isPrivate) {
- if (!externalToken && !externalUserName) return false
- return true
+ if ((externalToken != null && externalToken !== '') || (externalUserName != null && externalUserName !== '')) return true
+ return false
}
return true
}, { message: missingCredentials, path: ['credentials'] })
.refine(({ isStandalone, externalRepoUrl }) => {
- if (!isStandalone && !externalRepoUrl) {
+ if (!isStandalone && (externalRepoUrl == null || externalRepoUrl === '')) {
return false
}
return true
diff --git a/packages/shared/src/utils/functions.ts b/packages/shared/src/utils/functions.ts
index f38778f36d..43a97376f1 100644
--- a/packages/shared/src/utils/functions.ts
+++ b/packages/shared/src/utils/functions.ts
@@ -108,7 +108,8 @@ function excludeCircular(value: unknown, keys: string[], inPath: WeakSet