From 972398d203ca0a7bc67477713419428d4dc148f8 Mon Sep 17 00:00:00 2001 From: psychedelicious <4822129+psychedelicious@users.noreply.github.com> Date: Sun, 19 May 2024 01:04:58 +1000 Subject: [PATCH] tests(ui): add iterate to test schema --- .../features/nodes/store/util/testUtils.ts | 173 ++++++++++++++++++ 1 file changed, 173 insertions(+) diff --git a/invokeai/frontend/web/src/features/nodes/store/util/testUtils.ts b/invokeai/frontend/web/src/features/nodes/store/util/testUtils.ts index b68ff8bef6..470236a82e 100644 --- a/invokeai/frontend/web/src/features/nodes/store/util/testUtils.ts +++ b/invokeai/frontend/web/src/features/nodes/store/util/testUtils.ts @@ -442,10 +442,78 @@ export const img_resize: InvocationTemplate = { classification: 'stable', }; +const iterate: InvocationTemplate = { + title: 'Iterate', + type: 'iterate', + version: '1.1.0', + tags: [], + description: 'Iterates over a list of items', + outputType: 'iterate_output', + inputs: { + collection: { + name: 'collection', + title: 'Collection', + required: false, + description: 'The list of items to iterate over', + fieldKind: 'input', + input: 'connection', + ui_hidden: false, + ui_type: 'CollectionField', + type: { + name: 'CollectionField', + isCollection: true, + isCollectionOrScalar: false, + }, + }, + }, + outputs: { + item: { + fieldKind: 'output', + name: 'item', + title: 'Collection Item', + description: 'The item being iterated over', + type: { + name: 'CollectionItemField', + isCollection: false, + isCollectionOrScalar: false, + }, + ui_hidden: false, + ui_type: 'CollectionItemField', + }, + index: { + fieldKind: 'output', + name: 'index', + title: 'Index', + description: 'The index of the item', + type: { + name: 'IntegerField', + isCollection: false, + isCollectionOrScalar: false, + }, + ui_hidden: false, + }, + total: { + fieldKind: 'output', + name: 'total', + title: 'Total', + description: 'The total number of items', + type: { + name: 'IntegerField', + isCollection: false, + isCollectionOrScalar: false, + }, + ui_hidden: false, + }, + }, + useCache: true, + classification: 'stable', +}; + export const templates: Templates = { add, sub, collect, + iterate, scheduler, main_model_loader, img_resize, @@ -1410,6 +1478,111 @@ export const schema = { title: 'BoardField', description: 'A board primitive field', }, + IterateInvocation: { + properties: { + id: { + type: 'string', + title: 'Id', + description: 'The id of this instance of an invocation. Must be unique among all instances of invocations.', + field_kind: 'node_attribute', + }, + is_intermediate: { + type: 'boolean', + title: 'Is Intermediate', + description: 'Whether or not this is an intermediate invocation.', + default: false, + field_kind: 'node_attribute', + ui_type: 'IsIntermediate', + }, + use_cache: { + type: 'boolean', + title: 'Use Cache', + description: 'Whether or not to use the cache', + default: true, + field_kind: 'node_attribute', + }, + collection: { + items: {}, + type: 'array', + title: 'Collection', + description: 'The list of items to iterate over', + default: [], + field_kind: 'input', + input: 'any', + orig_default: [], + orig_required: false, + ui_hidden: false, + ui_type: 'CollectionField', + }, + index: { + type: 'integer', + title: 'Index', + description: 'The index, will be provided on executed iterators', + default: 0, + field_kind: 'input', + input: 'any', + orig_default: 0, + orig_required: false, + ui_hidden: true, + }, + type: { + type: 'string', + enum: ['iterate'], + const: 'iterate', + title: 'type', + default: 'iterate', + field_kind: 'node_attribute', + }, + }, + type: 'object', + required: ['type', 'id'], + title: 'IterateInvocation', + description: 'Iterates over a list of items', + classification: 'stable', + version: '1.1.0', + output: { + $ref: '#/components/schemas/IterateInvocationOutput', + }, + class: 'invocation', + }, + IterateInvocationOutput: { + description: 'Used to connect iteration outputs. Will be expanded to a specific output.', + properties: { + item: { + description: 'The item being iterated over', + field_kind: 'output', + title: 'Collection Item', + ui_hidden: false, + ui_type: 'CollectionItemField', + }, + index: { + description: 'The index of the item', + field_kind: 'output', + title: 'Index', + type: 'integer', + ui_hidden: false, + }, + total: { + description: 'The total number of items', + field_kind: 'output', + title: 'Total', + type: 'integer', + ui_hidden: false, + }, + type: { + const: 'iterate_output', + default: 'iterate_output', + enum: ['iterate_output'], + field_kind: 'node_attribute', + title: 'type', + type: 'string', + }, + }, + required: ['item', 'index', 'total', 'type', 'type'], + title: 'IterateInvocationOutput', + type: 'object', + class: 'output', + }, }, }, } as OpenAPIV3_1.Document;