mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-17 01:56:46 +00:00
⚡ Remove non-null assertions for Db collections (#3111)
* 📘 Remove unions to `null` * ⚡ Track `Db` initialization state * 🔥 Remove non-null assertions * 👕 Remove lint exceptions * 🔥 Remove leftover assertion
This commit is contained in:
@@ -235,13 +235,11 @@ export class CredentialsHelper extends ICredentialsHelper {
|
||||
}
|
||||
|
||||
const credential = userId
|
||||
? await Db.collections
|
||||
.SharedCredentials!.findOneOrFail({
|
||||
relations: ['credentials'],
|
||||
where: { credentials: { id: nodeCredential.id, type }, user: { id: userId } },
|
||||
})
|
||||
.then((shared) => shared.credentials)
|
||||
: await Db.collections.Credentials!.findOneOrFail({ id: nodeCredential.id, type });
|
||||
? await Db.collections.SharedCredentials.findOneOrFail({
|
||||
relations: ['credentials'],
|
||||
where: { credentials: { id: nodeCredential.id, type }, user: { id: userId } },
|
||||
}).then((shared) => shared.credentials)
|
||||
: await Db.collections.Credentials.findOneOrFail({ id: nodeCredential.id, type });
|
||||
|
||||
if (!credential) {
|
||||
throw new Error(
|
||||
@@ -445,7 +443,7 @@ export class CredentialsHelper extends ICredentialsHelper {
|
||||
type,
|
||||
};
|
||||
|
||||
await Db.collections.Credentials!.update(findQuery, newCredentialsData);
|
||||
await Db.collections.Credentials.update(findQuery, newCredentialsData);
|
||||
}
|
||||
|
||||
getCredentialTestFunction(
|
||||
@@ -721,8 +719,7 @@ export async function getCredentialForUser(
|
||||
credentialId: string,
|
||||
user: User,
|
||||
): Promise<ICredentialsDb | null> {
|
||||
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
||||
const sharedCredential = await Db.collections.SharedCredentials!.findOne({
|
||||
const sharedCredential = await Db.collections.SharedCredentials.findOne({
|
||||
relations: ['credentials'],
|
||||
where: whereClause({
|
||||
user,
|
||||
|
||||
Reference in New Issue
Block a user