mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-18 02:21:13 +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:
@@ -107,9 +107,9 @@ export async function executeErrorWorkflow(
|
||||
const user = await getWorkflowOwner(workflowErrorData.workflow.id!);
|
||||
|
||||
if (user.globalRole.name === 'owner') {
|
||||
workflowData = await Db.collections.Workflow!.findOne({ id: Number(workflowId) });
|
||||
workflowData = await Db.collections.Workflow.findOne({ id: Number(workflowId) });
|
||||
} else {
|
||||
const sharedWorkflowData = await Db.collections.SharedWorkflow!.findOne({
|
||||
const sharedWorkflowData = await Db.collections.SharedWorkflow.findOne({
|
||||
where: {
|
||||
workflow: { id: workflowId },
|
||||
user,
|
||||
@@ -121,7 +121,7 @@ export async function executeErrorWorkflow(
|
||||
}
|
||||
}
|
||||
} else {
|
||||
workflowData = await Db.collections.Workflow!.findOne({ id: Number(workflowId) });
|
||||
workflowData = await Db.collections.Workflow.findOne({ id: Number(workflowId) });
|
||||
}
|
||||
|
||||
if (workflowData === undefined) {
|
||||
@@ -426,7 +426,7 @@ export async function saveStaticDataById(
|
||||
workflowId: string | number,
|
||||
newStaticData: IDataObject,
|
||||
): Promise<void> {
|
||||
await Db.collections.Workflow!.update(workflowId, {
|
||||
await Db.collections.Workflow.update(workflowId, {
|
||||
staticData: newStaticData,
|
||||
});
|
||||
}
|
||||
@@ -440,7 +440,7 @@ export async function saveStaticDataById(
|
||||
*/
|
||||
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
|
||||
export async function getStaticDataById(workflowId: string | number) {
|
||||
const workflowData = await Db.collections.Workflow!.findOne(workflowId, {
|
||||
const workflowData = await Db.collections.Workflow.findOne(workflowId, {
|
||||
select: ['staticData'],
|
||||
});
|
||||
|
||||
@@ -586,7 +586,7 @@ export function whereClause({
|
||||
* Get the IDs of the workflows that have been shared with the user.
|
||||
*/
|
||||
export async function getSharedWorkflowIds(user: User): Promise<number[]> {
|
||||
const sharedWorkflows = await Db.collections.SharedWorkflow!.find({
|
||||
const sharedWorkflows = await Db.collections.SharedWorkflow.find({
|
||||
relations: ['workflow'],
|
||||
where: whereClause({
|
||||
user,
|
||||
|
||||
Reference in New Issue
Block a user