chore(ui): regen api client

This commit is contained in:
psychedelicious 2023-04-30 13:56:56 +10:00
parent 8c2e4700f9
commit 4150d5306f
13 changed files with 203 additions and 96 deletions

View File

@ -22,15 +22,13 @@ export interface OnCancel {
} }
export class CancelablePromise<T> implements Promise<T> { export class CancelablePromise<T> implements Promise<T> {
readonly [Symbol.toStringTag]!: string; #isResolved: boolean;
#isRejected: boolean;
private _isResolved: boolean; #isCancelled: boolean;
private _isRejected: boolean; readonly #cancelHandlers: (() => void)[];
private _isCancelled: boolean; readonly #promise: Promise<T>;
private readonly _cancelHandlers: (() => void)[]; #resolve?: (value: T | PromiseLike<T>) => void;
private readonly _promise: Promise<T>; #reject?: (reason?: any) => void;
private _resolve?: (value: T | PromiseLike<T>) => void;
private _reject?: (reason?: any) => void;
constructor( constructor(
executor: ( executor: (
@ -39,78 +37,82 @@ export class CancelablePromise<T> implements Promise<T> {
onCancel: OnCancel onCancel: OnCancel
) => void ) => void
) { ) {
this._isResolved = false; this.#isResolved = false;
this._isRejected = false; this.#isRejected = false;
this._isCancelled = false; this.#isCancelled = false;
this._cancelHandlers = []; this.#cancelHandlers = [];
this._promise = new Promise<T>((resolve, reject) => { this.#promise = new Promise<T>((resolve, reject) => {
this._resolve = resolve; this.#resolve = resolve;
this._reject = reject; this.#reject = reject;
const onResolve = (value: T | PromiseLike<T>): void => { const onResolve = (value: T | PromiseLike<T>): void => {
if (this._isResolved || this._isRejected || this._isCancelled) { if (this.#isResolved || this.#isRejected || this.#isCancelled) {
return; return;
} }
this._isResolved = true; this.#isResolved = true;
this._resolve?.(value); this.#resolve?.(value);
}; };
const onReject = (reason?: any): void => { const onReject = (reason?: any): void => {
if (this._isResolved || this._isRejected || this._isCancelled) { if (this.#isResolved || this.#isRejected || this.#isCancelled) {
return; return;
} }
this._isRejected = true; this.#isRejected = true;
this._reject?.(reason); this.#reject?.(reason);
}; };
const onCancel = (cancelHandler: () => void): void => { const onCancel = (cancelHandler: () => void): void => {
if (this._isResolved || this._isRejected || this._isCancelled) { if (this.#isResolved || this.#isRejected || this.#isCancelled) {
return; return;
} }
this._cancelHandlers.push(cancelHandler); this.#cancelHandlers.push(cancelHandler);
}; };
Object.defineProperty(onCancel, 'isResolved', { Object.defineProperty(onCancel, 'isResolved', {
get: (): boolean => this._isResolved, get: (): boolean => this.#isResolved,
}); });
Object.defineProperty(onCancel, 'isRejected', { Object.defineProperty(onCancel, 'isRejected', {
get: (): boolean => this._isRejected, get: (): boolean => this.#isRejected,
}); });
Object.defineProperty(onCancel, 'isCancelled', { Object.defineProperty(onCancel, 'isCancelled', {
get: (): boolean => this._isCancelled, get: (): boolean => this.#isCancelled,
}); });
return executor(onResolve, onReject, onCancel as OnCancel); return executor(onResolve, onReject, onCancel as OnCancel);
}); });
} }
get [Symbol.toStringTag]() {
return "Cancellable Promise";
}
public then<TResult1 = T, TResult2 = never>( public then<TResult1 = T, TResult2 = never>(
onFulfilled?: ((value: T) => TResult1 | PromiseLike<TResult1>) | null, onFulfilled?: ((value: T) => TResult1 | PromiseLike<TResult1>) | null,
onRejected?: ((reason: any) => TResult2 | PromiseLike<TResult2>) | null onRejected?: ((reason: any) => TResult2 | PromiseLike<TResult2>) | null
): Promise<TResult1 | TResult2> { ): Promise<TResult1 | TResult2> {
return this._promise.then(onFulfilled, onRejected); return this.#promise.then(onFulfilled, onRejected);
} }
public catch<TResult = never>( public catch<TResult = never>(
onRejected?: ((reason: any) => TResult | PromiseLike<TResult>) | null onRejected?: ((reason: any) => TResult | PromiseLike<TResult>) | null
): Promise<T | TResult> { ): Promise<T | TResult> {
return this._promise.catch(onRejected); return this.#promise.catch(onRejected);
} }
public finally(onFinally?: (() => void) | null): Promise<T> { public finally(onFinally?: (() => void) | null): Promise<T> {
return this._promise.finally(onFinally); return this.#promise.finally(onFinally);
} }
public cancel(): void { public cancel(): void {
if (this._isResolved || this._isRejected || this._isCancelled) { if (this.#isResolved || this.#isRejected || this.#isCancelled) {
return; return;
} }
this._isCancelled = true; this.#isCancelled = true;
if (this._cancelHandlers.length) { if (this.#cancelHandlers.length) {
try { try {
for (const cancelHandler of this._cancelHandlers) { for (const cancelHandler of this.#cancelHandlers) {
cancelHandler(); cancelHandler();
} }
} catch (error) { } catch (error) {
@ -118,11 +120,11 @@ export class CancelablePromise<T> implements Promise<T> {
return; return;
} }
} }
this._cancelHandlers.length = 0; this.#cancelHandlers.length = 0;
this._reject?.(new CancelError('Request aborted')); this.#reject?.(new CancelError('Request aborted'));
} }
public get isCancelled(): boolean { public get isCancelled(): boolean {
return this._isCancelled; return this.#isCancelled;
} }
} }

View File

@ -58,7 +58,9 @@ export type { PasteImageInvocation } from './models/PasteImageInvocation';
export type { PromptOutput } from './models/PromptOutput'; export type { PromptOutput } from './models/PromptOutput';
export type { RandomRangeInvocation } from './models/RandomRangeInvocation'; export type { RandomRangeInvocation } from './models/RandomRangeInvocation';
export type { RangeInvocation } from './models/RangeInvocation'; export type { RangeInvocation } from './models/RangeInvocation';
export type { ResizeLatentsInvocation } from './models/ResizeLatentsInvocation';
export type { RestoreFaceInvocation } from './models/RestoreFaceInvocation'; export type { RestoreFaceInvocation } from './models/RestoreFaceInvocation';
export type { ScaleLatentsInvocation } from './models/ScaleLatentsInvocation';
export type { ShowImageInvocation } from './models/ShowImageInvocation'; export type { ShowImageInvocation } from './models/ShowImageInvocation';
export type { SubtractInvocation } from './models/SubtractInvocation'; export type { SubtractInvocation } from './models/SubtractInvocation';
export type { TextToImageInvocation } from './models/TextToImageInvocation'; export type { TextToImageInvocation } from './models/TextToImageInvocation';
@ -119,7 +121,9 @@ export { $PasteImageInvocation } from './schemas/$PasteImageInvocation';
export { $PromptOutput } from './schemas/$PromptOutput'; export { $PromptOutput } from './schemas/$PromptOutput';
export { $RandomRangeInvocation } from './schemas/$RandomRangeInvocation'; export { $RandomRangeInvocation } from './schemas/$RandomRangeInvocation';
export { $RangeInvocation } from './schemas/$RangeInvocation'; export { $RangeInvocation } from './schemas/$RangeInvocation';
export { $ResizeLatentsInvocation } from './schemas/$ResizeLatentsInvocation';
export { $RestoreFaceInvocation } from './schemas/$RestoreFaceInvocation'; export { $RestoreFaceInvocation } from './schemas/$RestoreFaceInvocation';
export { $ScaleLatentsInvocation } from './schemas/$ScaleLatentsInvocation';
export { $ShowImageInvocation } from './schemas/$ShowImageInvocation'; export { $ShowImageInvocation } from './schemas/$ShowImageInvocation';
export { $SubtractInvocation } from './schemas/$SubtractInvocation'; export { $SubtractInvocation } from './schemas/$SubtractInvocation';
export { $TextToImageInvocation } from './schemas/$TextToImageInvocation'; export { $TextToImageInvocation } from './schemas/$TextToImageInvocation';

View File

@ -25,7 +25,9 @@ import type { ParamIntInvocation } from './ParamIntInvocation';
import type { PasteImageInvocation } from './PasteImageInvocation'; import type { PasteImageInvocation } from './PasteImageInvocation';
import type { RandomRangeInvocation } from './RandomRangeInvocation'; import type { RandomRangeInvocation } from './RandomRangeInvocation';
import type { RangeInvocation } from './RangeInvocation'; import type { RangeInvocation } from './RangeInvocation';
import type { ResizeLatentsInvocation } from './ResizeLatentsInvocation';
import type { RestoreFaceInvocation } from './RestoreFaceInvocation'; import type { RestoreFaceInvocation } from './RestoreFaceInvocation';
import type { ScaleLatentsInvocation } from './ScaleLatentsInvocation';
import type { ShowImageInvocation } from './ShowImageInvocation'; import type { ShowImageInvocation } from './ShowImageInvocation';
import type { SubtractInvocation } from './SubtractInvocation'; import type { SubtractInvocation } from './SubtractInvocation';
import type { TextToImageInvocation } from './TextToImageInvocation'; import type { TextToImageInvocation } from './TextToImageInvocation';
@ -40,7 +42,7 @@ export type Graph = {
/** /**
* The nodes in this graph * The nodes in this graph
*/ */
nodes?: Record<string, (LoadImageInvocation | ShowImageInvocation | CropImageInvocation | PasteImageInvocation | MaskFromAlphaInvocation | BlurInvocation | LerpInvocation | InverseLerpInvocation | NoiseInvocation | TextToLatentsInvocation | LatentsToImageInvocation | AddInvocation | SubtractInvocation | MultiplyInvocation | DivideInvocation | ParamIntInvocation | CvInpaintInvocation | RangeInvocation | RandomRangeInvocation | UpscaleInvocation | RestoreFaceInvocation | TextToImageInvocation | GraphInvocation | IterateInvocation | CollectInvocation | LatentsToLatentsInvocation | ImageToImageInvocation | InpaintInvocation)>; nodes?: Record<string, (LoadImageInvocation | ShowImageInvocation | CropImageInvocation | PasteImageInvocation | MaskFromAlphaInvocation | BlurInvocation | LerpInvocation | InverseLerpInvocation | NoiseInvocation | TextToLatentsInvocation | LatentsToImageInvocation | ResizeLatentsInvocation | ScaleLatentsInvocation | AddInvocation | SubtractInvocation | MultiplyInvocation | DivideInvocation | ParamIntInvocation | CvInpaintInvocation | RangeInvocation | RandomRangeInvocation | UpscaleInvocation | RestoreFaceInvocation | TextToImageInvocation | GraphInvocation | IterateInvocation | CollectInvocation | LatentsToLatentsInvocation | ImageToImageInvocation | InpaintInvocation)>;
/** /**
* The connections between nodes and their fields in this graph * The connections between nodes and their fields in this graph
*/ */

View File

@ -17,10 +17,6 @@ export type LatentsToLatentsInvocation = {
* The prompt to generate an image from * The prompt to generate an image from
*/ */
prompt?: string; prompt?: string;
/**
* The seed to use (-1 for a random seed)
*/
seed?: number;
/** /**
* The noise to use * The noise to use
*/ */
@ -29,14 +25,6 @@ export type LatentsToLatentsInvocation = {
* The number of steps to use to generate the image * The number of steps to use to generate the image
*/ */
steps?: number; steps?: number;
/**
* The width of the resulting image
*/
width?: number;
/**
* The height of the resulting image
*/
height?: number;
/** /**
* The Classifier-Free Guidance, higher values may result in a result closer to the prompt * The Classifier-Free Guidance, higher values may result in a result closer to the prompt
*/ */

View File

@ -0,0 +1,37 @@
/* istanbul ignore file */
/* tslint:disable */
/* eslint-disable */
import type { LatentsField } from './LatentsField';
/**
* Resizes latents to explicit width/height (in pixels). Provided dimensions are floor-divided by 8.
*/
export type ResizeLatentsInvocation = {
/**
* The id of this node. Must be unique among all nodes.
*/
id: string;
type?: 'lresize';
/**
* The latents to resize
*/
latents?: LatentsField;
/**
* The width to resize to (px)
*/
width: number;
/**
* The height to resize to (px)
*/
height: number;
/**
* The interpolation mode
*/
mode?: 'nearest' | 'linear' | 'bilinear' | 'bicubic' | 'trilinear' | 'area' | 'nearest-exact';
/**
* Whether or not to antialias (applied in bilinear and bicubic modes only)
*/
antialias?: boolean;
};

View File

@ -0,0 +1,33 @@
/* istanbul ignore file */
/* tslint:disable */
/* eslint-disable */
import type { LatentsField } from './LatentsField';
/**
* Scales latents by a given factor.
*/
export type ScaleLatentsInvocation = {
/**
* The id of this node. Must be unique among all nodes.
*/
id: string;
type?: 'lscale';
/**
* The latents to scale
*/
latents?: LatentsField;
/**
* The factor by which to scale the latents
*/
scale_factor: number;
/**
* The interpolation mode
*/
mode?: 'nearest' | 'linear' | 'bilinear' | 'bicubic' | 'trilinear' | 'area' | 'nearest-exact';
/**
* Whether or not to antialias (applied in bilinear and bicubic modes only)
*/
antialias?: boolean;
};

View File

@ -17,10 +17,6 @@ export type TextToLatentsInvocation = {
* The prompt to generate an image from * The prompt to generate an image from
*/ */
prompt?: string; prompt?: string;
/**
* The seed to use (-1 for a random seed)
*/
seed?: number;
/** /**
* The noise to use * The noise to use
*/ */
@ -29,14 +25,6 @@ export type TextToLatentsInvocation = {
* The number of steps to use to generate the image * The number of steps to use to generate the image
*/ */
steps?: number; steps?: number;
/**
* The width of the resulting image
*/
width?: number;
/**
* The height of the resulting image
*/
height?: number;
/** /**
* The Classifier-Free Guidance, higher values may result in a result closer to the prompt * The Classifier-Free Guidance, higher values may result in a result closer to the prompt
*/ */

View File

@ -33,6 +33,10 @@ export const $Graph = {
type: 'TextToLatentsInvocation', type: 'TextToLatentsInvocation',
}, { }, {
type: 'LatentsToImageInvocation', type: 'LatentsToImageInvocation',
}, {
type: 'ResizeLatentsInvocation',
}, {
type: 'ScaleLatentsInvocation',
}, { }, {
type: 'AddInvocation', type: 'AddInvocation',
}, { }, {

View File

@ -16,12 +16,6 @@ export const $LatentsToLatentsInvocation = {
type: 'string', type: 'string',
description: `The prompt to generate an image from`, description: `The prompt to generate an image from`,
}, },
seed: {
type: 'number',
description: `The seed to use (-1 for a random seed)`,
maximum: 4294967295,
minimum: -1,
},
noise: { noise: {
type: 'all-of', type: 'all-of',
description: `The noise to use`, description: `The noise to use`,
@ -33,16 +27,6 @@ export const $LatentsToLatentsInvocation = {
type: 'number', type: 'number',
description: `The number of steps to use to generate the image`, description: `The number of steps to use to generate the image`,
}, },
width: {
type: 'number',
description: `The width of the resulting image`,
multipleOf: 64,
},
height: {
type: 'number',
description: `The height of the resulting image`,
multipleOf: 64,
},
cfg_scale: { cfg_scale: {
type: 'number', type: 'number',
description: `The Classifier-Free Guidance, higher values may result in a result closer to the prompt`, description: `The Classifier-Free Guidance, higher values may result in a result closer to the prompt`,

View File

@ -0,0 +1,44 @@
/* istanbul ignore file */
/* tslint:disable */
/* eslint-disable */
export const $ResizeLatentsInvocation = {
description: `Resizes latents to explicit width/height (in pixels). Provided dimensions are floor-divided by 8.`,
properties: {
id: {
type: 'string',
description: `The id of this node. Must be unique among all nodes.`,
isRequired: true,
},
type: {
type: 'Enum',
},
latents: {
type: 'all-of',
description: `The latents to resize`,
contains: [{
type: 'LatentsField',
}],
},
width: {
type: 'number',
description: `The width to resize to (px)`,
isRequired: true,
minimum: 64,
multipleOf: 8,
},
height: {
type: 'number',
description: `The height to resize to (px)`,
isRequired: true,
minimum: 64,
multipleOf: 8,
},
mode: {
type: 'Enum',
},
antialias: {
type: 'boolean',
description: `Whether or not to antialias (applied in bilinear and bicubic modes only)`,
},
},
} as const;

View File

@ -0,0 +1,35 @@
/* istanbul ignore file */
/* tslint:disable */
/* eslint-disable */
export const $ScaleLatentsInvocation = {
description: `Scales latents by a given factor.`,
properties: {
id: {
type: 'string',
description: `The id of this node. Must be unique among all nodes.`,
isRequired: true,
},
type: {
type: 'Enum',
},
latents: {
type: 'all-of',
description: `The latents to scale`,
contains: [{
type: 'LatentsField',
}],
},
scale_factor: {
type: 'number',
description: `The factor by which to scale the latents`,
isRequired: true,
},
mode: {
type: 'Enum',
},
antialias: {
type: 'boolean',
description: `Whether or not to antialias (applied in bilinear and bicubic modes only)`,
},
},
} as const;

View File

@ -16,12 +16,6 @@ export const $TextToLatentsInvocation = {
type: 'string', type: 'string',
description: `The prompt to generate an image from`, description: `The prompt to generate an image from`,
}, },
seed: {
type: 'number',
description: `The seed to use (-1 for a random seed)`,
maximum: 4294967295,
minimum: -1,
},
noise: { noise: {
type: 'all-of', type: 'all-of',
description: `The noise to use`, description: `The noise to use`,
@ -33,16 +27,6 @@ export const $TextToLatentsInvocation = {
type: 'number', type: 'number',
description: `The number of steps to use to generate the image`, description: `The number of steps to use to generate the image`,
}, },
width: {
type: 'number',
description: `The width of the resulting image`,
multipleOf: 64,
},
height: {
type: 'number',
description: `The height of the resulting image`,
multipleOf: 64,
},
cfg_scale: { cfg_scale: {
type: 'number', type: 'number',
description: `The Classifier-Free Guidance, higher values may result in a result closer to the prompt`, description: `The Classifier-Free Guidance, higher values may result in a result closer to the prompt`,

View File

@ -27,7 +27,9 @@ import type { ParamIntInvocation } from '../models/ParamIntInvocation';
import type { PasteImageInvocation } from '../models/PasteImageInvocation'; import type { PasteImageInvocation } from '../models/PasteImageInvocation';
import type { RandomRangeInvocation } from '../models/RandomRangeInvocation'; import type { RandomRangeInvocation } from '../models/RandomRangeInvocation';
import type { RangeInvocation } from '../models/RangeInvocation'; import type { RangeInvocation } from '../models/RangeInvocation';
import type { ResizeLatentsInvocation } from '../models/ResizeLatentsInvocation';
import type { RestoreFaceInvocation } from '../models/RestoreFaceInvocation'; import type { RestoreFaceInvocation } from '../models/RestoreFaceInvocation';
import type { ScaleLatentsInvocation } from '../models/ScaleLatentsInvocation';
import type { ShowImageInvocation } from '../models/ShowImageInvocation'; import type { ShowImageInvocation } from '../models/ShowImageInvocation';
import type { SubtractInvocation } from '../models/SubtractInvocation'; import type { SubtractInvocation } from '../models/SubtractInvocation';
import type { TextToImageInvocation } from '../models/TextToImageInvocation'; import type { TextToImageInvocation } from '../models/TextToImageInvocation';
@ -142,7 +144,7 @@ export class SessionsService {
* The id of the session * The id of the session
*/ */
sessionId: string, sessionId: string,
requestBody: (LoadImageInvocation | ShowImageInvocation | CropImageInvocation | PasteImageInvocation | MaskFromAlphaInvocation | BlurInvocation | LerpInvocation | InverseLerpInvocation | NoiseInvocation | TextToLatentsInvocation | LatentsToImageInvocation | AddInvocation | SubtractInvocation | MultiplyInvocation | DivideInvocation | ParamIntInvocation | CvInpaintInvocation | RangeInvocation | RandomRangeInvocation | UpscaleInvocation | RestoreFaceInvocation | TextToImageInvocation | GraphInvocation | IterateInvocation | CollectInvocation | LatentsToLatentsInvocation | ImageToImageInvocation | InpaintInvocation), requestBody: (LoadImageInvocation | ShowImageInvocation | CropImageInvocation | PasteImageInvocation | MaskFromAlphaInvocation | BlurInvocation | LerpInvocation | InverseLerpInvocation | NoiseInvocation | TextToLatentsInvocation | LatentsToImageInvocation | ResizeLatentsInvocation | ScaleLatentsInvocation | AddInvocation | SubtractInvocation | MultiplyInvocation | DivideInvocation | ParamIntInvocation | CvInpaintInvocation | RangeInvocation | RandomRangeInvocation | UpscaleInvocation | RestoreFaceInvocation | TextToImageInvocation | GraphInvocation | IterateInvocation | CollectInvocation | LatentsToLatentsInvocation | ImageToImageInvocation | InpaintInvocation),
}): CancelablePromise<string> { }): CancelablePromise<string> {
return __request(OpenAPI, { return __request(OpenAPI, {
method: 'POST', method: 'POST',
@ -179,7 +181,7 @@ export class SessionsService {
* The path to the node in the graph * The path to the node in the graph
*/ */
nodePath: string, nodePath: string,
requestBody: (LoadImageInvocation | ShowImageInvocation | CropImageInvocation | PasteImageInvocation | MaskFromAlphaInvocation | BlurInvocation | LerpInvocation | InverseLerpInvocation | NoiseInvocation | TextToLatentsInvocation | LatentsToImageInvocation | AddInvocation | SubtractInvocation | MultiplyInvocation | DivideInvocation | ParamIntInvocation | CvInpaintInvocation | RangeInvocation | RandomRangeInvocation | UpscaleInvocation | RestoreFaceInvocation | TextToImageInvocation | GraphInvocation | IterateInvocation | CollectInvocation | LatentsToLatentsInvocation | ImageToImageInvocation | InpaintInvocation), requestBody: (LoadImageInvocation | ShowImageInvocation | CropImageInvocation | PasteImageInvocation | MaskFromAlphaInvocation | BlurInvocation | LerpInvocation | InverseLerpInvocation | NoiseInvocation | TextToLatentsInvocation | LatentsToImageInvocation | ResizeLatentsInvocation | ScaleLatentsInvocation | AddInvocation | SubtractInvocation | MultiplyInvocation | DivideInvocation | ParamIntInvocation | CvInpaintInvocation | RangeInvocation | RandomRangeInvocation | UpscaleInvocation | RestoreFaceInvocation | TextToImageInvocation | GraphInvocation | IterateInvocation | CollectInvocation | LatentsToLatentsInvocation | ImageToImageInvocation | InpaintInvocation),
}): CancelablePromise<GraphExecutionState> { }): CancelablePromise<GraphExecutionState> {
return __request(OpenAPI, { return __request(OpenAPI, {
method: 'PUT', method: 'PUT',