feat(ui): add UI-level nodes denylist

This simply hides nodes from the workflow editor. The nodes will still work if an API request is made with them. For example, you could hide `iterate` nodes from the workflow editor, but if the Linear UI makes use of those nodes, they will still function.

- Update `AppConfig` with optional property `nodesDenylist: string[]`
- If provided, nodes are filtered out by `type` in the workflow editor
This commit is contained in:
psychedelicious 2023-09-06 11:56:53 +10:00 committed by Kent Keirsey
parent dc771d9645
commit 7254a6a517
4 changed files with 13 additions and 4 deletions

View File

@ -9,13 +9,16 @@ import { startAppListening } from '..';
export const addReceivedOpenAPISchemaListener = () => {
startAppListening({
actionCreator: receivedOpenAPISchema.fulfilled,
effect: (action, { dispatch }) => {
effect: (action, { dispatch, getState }) => {
const log = logger('system');
const schemaJSON = action.payload;
log.debug({ schemaJSON }, 'Received OpenAPI schema');
const nodeTemplates = parseSchema(schemaJSON);
const nodeTemplates = parseSchema(
schemaJSON,
getState().config.nodesDenylist
);
log.debug(
{ nodeTemplates: parseify(nodeTemplates) },

View File

@ -50,6 +50,7 @@ export type AppConfig = {
disabledFeatures: AppFeature[];
disabledSDFeatures: SDFeature[];
canRestoreDeletedImagesFromBin: boolean;
nodesDenylist: string[];
sd: {
defaultModel?: string;
disabledControlNetModels: string[];

View File

@ -60,11 +60,15 @@ const isNotInDenylist = (schema: InvocationSchemaObject) =>
!invocationDenylist.includes(schema.properties.type.default);
export const parseSchema = (
openAPI: OpenAPIV3.Document
openAPI: OpenAPIV3.Document,
nodesDenylistExtra: string[] = []
): Record<string, InvocationTemplate> => {
const filteredSchemas = Object.values(openAPI.components?.schemas ?? {})
.filter(isInvocationSchemaObject)
.filter(isNotInDenylist);
.filter(isNotInDenylist)
.filter(
(schema) => !nodesDenylistExtra.includes(schema.properties.type.default)
);
const invocations = filteredSchemas.reduce<
Record<string, InvocationTemplate>

View File

@ -15,6 +15,7 @@ export const initialConfigState: AppConfig = {
'perlinNoise',
'noiseThreshold',
],
nodesDenylist: [],
canRestoreDeletedImagesFromBin: true,
sd: {
disabledControlNetModels: [],