mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-17 10:02:05 +00:00
fix: Remove variable:read as a valid API key scope and make variable:update selectable in the UI (no-changelog) (#15356)
Co-authored-by: Ricardo Espinoza <ricardo@n8n.io>
This commit is contained in:
@@ -3,10 +3,34 @@ import { VariablesRepository } from '@n8n/db';
|
||||
import { Container } from '@n8n/di';
|
||||
import { randomString } from 'n8n-workflow';
|
||||
|
||||
import { VariablesService } from '@/environments.ee/variables/variables.service.ee';
|
||||
|
||||
export async function createVariable(key = randomString(5), value = randomString(5)) {
|
||||
return await Container.get(VariablesRepository).save({ id: generateNanoId(), key, value });
|
||||
const result = await Container.get(VariablesRepository).save({
|
||||
id: generateNanoId(),
|
||||
key,
|
||||
value,
|
||||
});
|
||||
await Container.get(VariablesService).updateCache();
|
||||
return result;
|
||||
}
|
||||
|
||||
export async function getVariableOrFail(id: string) {
|
||||
export async function getVariableByIdOrFail(id: string) {
|
||||
return await Container.get(VariablesRepository).findOneOrFail({ where: { id } });
|
||||
}
|
||||
|
||||
export async function getVariableByKey(key: string) {
|
||||
return await Container.get(VariablesRepository).findOne({
|
||||
where: {
|
||||
key,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
export async function getVariableById(id: string) {
|
||||
return await Container.get(VariablesRepository).findOne({
|
||||
where: {
|
||||
id,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user