|
@ -18,6 +18,17 @@ function createPreparedStatement(db: DBType) { |
|
|
}, |
|
|
}, |
|
|
}) |
|
|
}) |
|
|
.prepare(), |
|
|
.prepare(), |
|
|
|
|
|
findAllPublic: db.query.client |
|
|
|
|
|
.findMany({ |
|
|
|
|
|
with: { |
|
|
|
|
|
oneTimeLink: true, |
|
|
|
|
|
}, |
|
|
|
|
|
columns: { |
|
|
|
|
|
privateKey: false, |
|
|
|
|
|
preSharedKey: false, |
|
|
|
|
|
}, |
|
|
|
|
|
}) |
|
|
|
|
|
.prepare(), |
|
|
findById: db.query.client |
|
|
findById: db.query.client |
|
|
.findFirst({ where: eq(client.id, sql.placeholder('id')) }) |
|
|
.findFirst({ where: eq(client.id, sql.placeholder('id')) }) |
|
|
.prepare(), |
|
|
.prepare(), |
|
@ -25,6 +36,10 @@ function createPreparedStatement(db: DBType) { |
|
|
.findMany({ |
|
|
.findMany({ |
|
|
where: eq(client.userId, sql.placeholder('userId')), |
|
|
where: eq(client.userId, sql.placeholder('userId')), |
|
|
with: { oneTimeLink: true }, |
|
|
with: { oneTimeLink: true }, |
|
|
|
|
|
columns: { |
|
|
|
|
|
privateKey: false, |
|
|
|
|
|
preSharedKey: false, |
|
|
|
|
|
}, |
|
|
}) |
|
|
}) |
|
|
.prepare(), |
|
|
.prepare(), |
|
|
toggle: db |
|
|
toggle: db |
|
@ -57,6 +72,9 @@ export class ClientService { |
|
|
})); |
|
|
})); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
* Never return values directly from this function. Use {@link getAllPublic} instead. |
|
|
|
|
|
*/ |
|
|
async getAll() { |
|
|
async getAll() { |
|
|
const result = await this.#statements.findAll.execute(); |
|
|
const result = await this.#statements.findAll.execute(); |
|
|
return result.map((row) => ({ |
|
|
return result.map((row) => ({ |
|
@ -66,6 +84,18 @@ export class ClientService { |
|
|
})); |
|
|
})); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
* Returns all clients without sensitive data |
|
|
|
|
|
*/ |
|
|
|
|
|
async getAllPublic() { |
|
|
|
|
|
const result = await this.#statements.findAllPublic.execute(); |
|
|
|
|
|
return result.map((row) => ({ |
|
|
|
|
|
...row, |
|
|
|
|
|
createdAt: new Date(row.createdAt), |
|
|
|
|
|
updatedAt: new Date(row.updatedAt), |
|
|
|
|
|
})); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
get(id: ID) { |
|
|
get(id: ID) { |
|
|
return this.#statements.findById.execute({ id }); |
|
|
return this.#statements.findById.execute({ id }); |
|
|
} |
|
|
} |
|
|