From b477977a9377a4a0afa72697f5e2a79ef5b20b7e Mon Sep 17 00:00:00 2001 From: Liam Griffiths Date: Tue, 2 Apr 2024 10:01:37 -0500 Subject: [PATCH 1/6] Update formatting (`prettier --write`) --- src/Mailbox.ts | 14 +- src/Nodes.ts | 542 ++++++++++++++++++++++++++++++++----------- src/OpenAPI.ts | 598 ++++++++++++++++++++++++------------------------ src/Platform.ts | 13 +- src/index.ts | 12 +- 5 files changed, 731 insertions(+), 448 deletions(-) diff --git a/src/Mailbox.ts b/src/Mailbox.ts index 911d720..bd27f44 100644 --- a/src/Mailbox.ts +++ b/src/Mailbox.ts @@ -11,7 +11,7 @@ import { Node } from "substrate/Node"; */ /** @private */ -class SubstrateEvent extends Event {}; +class SubstrateEvent extends Event {} /** @private Event that reprepresents a new server response. */ export class RequestCompleted extends SubstrateEvent { @@ -47,19 +47,23 @@ export class Mailbox extends EventTarget { // When we receive an event, we'll resolve this Promise resolve(e.value.getNodeResponse(node)); // Then we'll remove the event listeners to make sure there these references in the promise go away - this.removeEventListener(RequestCompleted.type, handleRequestCompleted); + this.removeEventListener( + RequestCompleted.type, + handleRequestCompleted, + ); // We'll move this reference over to the results list - if (this.pending.length) this.resolved.push(this.pending.pop() as Promise); + if (this.pending.length) + this.resolved.push(this.pending.pop() as Promise); // Finally we'll start up a new listener waitForResponse(); - } + }, }; // We attach the above listener to this Mailbox this.addEventListener(RequestCompleted.type, handleRequestCompleted); }); this.pending.push(p); - } + }; waitForResponse(); } diff --git a/src/Nodes.ts b/src/Nodes.ts index 40773a0..ae45229 100644 --- a/src/Nodes.ts +++ b/src/Nodes.ts @@ -1,272 +1,415 @@ /** -* ꩜ Substrate -* @generated file -* 20240315.20240321 -*/ + * ꩜ Substrate + * @generated file + * 20240315.20240321 + */ import * as OpenAPI from "substrate/OpenAPI"; -import { Node } from "substrate/Node" -import { Trace, Future, FutureString, FutureNumber, FutureArray, FutureObject, FutureAnyObject } from "substrate/Future"; +import { Node } from "substrate/Node"; +import { + Trace, + Future, + FutureString, + FutureNumber, + FutureArray, + FutureObject, + FutureAnyObject, +} from "substrate/Future"; // Type that extends some other type T (recursively) and expands it to also accept our // Future types too. -// +// // For example, if a `string` is found it will be changed to `string | FutureString`. -// +// // There may still be some edge cases here, so this will also allow for any `Future` when it makes sense. -type AlsoAcceptFutures = - T extends (infer U)[] - ? U extends string ? FutureString[] : U extends number ? FutureNumber[] : Future[] - : T extends object - ? { [P in keyof T]: AlsoAcceptFutures | (T[P] extends string ? FutureString : T[P] extends number ? FutureNumber : Future) | T[P] } - : T; - +type AlsoAcceptFutures = T extends (infer U)[] + ? U extends string + ? FutureString[] + : U extends number + ? FutureNumber[] + : Future[] + : T extends object + ? { + [P in keyof T]: + | AlsoAcceptFutures + | (T[P] extends string + ? FutureString + : T[P] extends number + ? FutureNumber + : Future) + | T[P]; + } + : T; /** (Optional) JSON response. */ class JsonObject extends FutureAnyObject { /** Returns the result for `JsonObject` once it's node has been run. */ - override async result(): Promise { return super.result() as Promise; } + override async result(): Promise { + return super.result() as Promise; + } } /** Generated embeddings. */ class Embeddings extends FutureArray { - override at(index: number) { return new EmbeddingsItem(this.directive.next(index)) } + override at(index: number) { + return new EmbeddingsItem(this.directive.next(index)); + } /** Returns the result for `Embeddings` once it's node has been run. */ - override async result(): Promise { return super.result() as Promise; } + override async result(): Promise { + return super.result() as Promise; + } } /** TODO: FillMaskOut description */ class FillMaskOut extends FutureObject { /** Base 64-encoded JPEG image bytes, or a hosted image url if `store` is provided. */ - get image_uri() { return new FutureString(this.directive.next('image_uri')) } + get image_uri() { + return new FutureString(this.directive.next("image_uri")); + } /** Returns the result for `FillMaskOut` once it's node has been run. */ - override async result(): Promise { return super.result() as Promise; } + override async result(): Promise { + return super.result() as Promise; + } } /** TODO: GenerateTextOut description */ class GenerateTextOut extends FutureObject { /** (Optional) Text response. */ - get text() { return new FutureString(this.directive.next('text')) } + get text() { + return new FutureString(this.directive.next("text")); + } /** (Optional) JSON response. */ - get json_object() { return new JsonObject(this.directive.next('json_object')) } + get json_object() { + return new JsonObject(this.directive.next("json_object")); + } /** Returns the result for `GenerateTextOut` once it's node has been run. */ - override async result(): Promise { return super.result() as Promise; } + override async result(): Promise { + return super.result() as Promise; + } } /** TODO: ControlledGenerateImageOut description */ class ControlledGenerateImageOut extends FutureObject { /** Base 64-encoded JPEG image bytes, or a hosted image url if `store` is provided. */ - get image_uri() { return new FutureString(this.directive.next('image_uri')) } + get image_uri() { + return new FutureString(this.directive.next("image_uri")); + } /** The random noise seed used for generation. */ - get seed() { return new Seed(this.directive.next('seed')) } + get seed() { + return new Seed(this.directive.next("seed")); + } /** Returns the result for `ControlledGenerateImageOut` once it's node has been run. */ - override async result(): Promise { return super.result() as Promise; } + override async result(): Promise { + return super.result() as Promise; + } } /** TODO: DetectSegmentsOut description */ class DetectSegmentsOut extends FutureObject { /** Detected segments in 'mask image' format. Base 64-encoded JPEG image bytes, or a hosted image url if `store` is provided. */ - get mask_image_uri() { return new FutureString(this.directive.next('mask_image_uri')) } + get mask_image_uri() { + return new FutureString(this.directive.next("mask_image_uri")); + } /** Returns the result for `DetectSegmentsOut` once it's node has been run. */ - override async result(): Promise { return super.result() as Promise; } + override async result(): Promise { + return super.result() as Promise; + } } /** TODO: TranscribeMediaOut description */ class TranscribeMediaOut extends FutureObject { /** Transcribed text. */ - get text() { return new FutureString(this.directive.next('text')) } + get text() { + return new FutureString(this.directive.next("text")); + } /** (Optional) Transcribed segments, if `segment` is enabled. */ - get segments() { return new Segments(this.directive.next('segments')) } + get segments() { + return new Segments(this.directive.next("segments")); + } /** (Optional) Chapter markers, if `suggest_chapters` is enabled. */ - get chapters() { return new Chapters(this.directive.next('chapters')) } + get chapters() { + return new Chapters(this.directive.next("chapters")); + } /** Returns the result for `TranscribeMediaOut` once it's node has been run. */ - override async result(): Promise { return super.result() as Promise; } + override async result(): Promise { + return super.result() as Promise; + } } /** TODO: MultiGenerateTextOut description */ class MultiGenerateTextOut extends FutureObject { /** TODO: Choices description */ - get choices() { return new Choices(this.directive.next('choices')) } + get choices() { + return new Choices(this.directive.next("choices")); + } /** Returns the result for `MultiGenerateTextOut` once it's node has been run. */ - override async result(): Promise { return super.result() as Promise; } + override async result(): Promise { + return super.result() as Promise; + } } /** Choices Array Item */ class ChoicesItem extends FutureAnyObject { /** Returns the result for `ChoicesItem` once it's node has been run. */ - override async result(): Promise { return super.result() as Promise; } + override async result(): Promise { + return super.result() as Promise; + } } /** TODO: EmbedImageOut description */ class EmbedImageOut extends FutureObject { /** Generated embedding. */ - get embedding() { return new Embedding(this.directive.next('embedding')) } + get embedding() { + return new Embedding(this.directive.next("embedding")); + } /** Returns the result for `EmbedImageOut` once it's node has been run. */ - override async result(): Promise { return super.result() as Promise; } + override async result(): Promise { + return super.result() as Promise; + } } /** TODO: GenerateImageOut description */ class GenerateImageOut extends FutureObject { /** Base 64-encoded JPEG image bytes, or a hosted image url if `store` is provided. */ - get image_uri() { return new FutureString(this.directive.next('image_uri')) } + get image_uri() { + return new FutureString(this.directive.next("image_uri")); + } /** The random noise seed used for generation. */ - get seed() { return new Seed(this.directive.next('seed')) } + get seed() { + return new Seed(this.directive.next("seed")); + } /** Returns the result for `GenerateImageOut` once it's node has been run. */ - override async result(): Promise { return super.result() as Promise; } + override async result(): Promise { + return super.result() as Promise; + } } /** TODO: MultiEmbedTextOut description */ class MultiEmbedTextOut extends FutureObject { /** Generated embeddings. */ - get embeddings() { return new Embeddings(this.directive.next('embeddings')) } + get embeddings() { + return new Embeddings(this.directive.next("embeddings")); + } /** Returns the result for `MultiEmbedTextOut` once it's node has been run. */ - override async result(): Promise { return super.result() as Promise; } + override async result(): Promise { + return super.result() as Promise; + } } /** TODO: MultiGenerateImageOut description */ class MultiGenerateImageOut extends FutureObject { /** TODO: Outputs description */ - get outputs() { return new Outputs(this.directive.next('outputs')) } + get outputs() { + return new Outputs(this.directive.next("outputs")); + } /** Returns the result for `MultiGenerateImageOut` once it's node has been run. */ - override async result(): Promise { return super.result() as Promise; } + override async result(): Promise { + return super.result() as Promise; + } } /** (Optional) Transcribed segments, if `segment` is enabled. */ class Segments extends FutureArray { - override at(index: number) { return new SegmentsItem(this.directive.next(index)) } + override at(index: number) { + return new SegmentsItem(this.directive.next(index)); + } /** Returns the result for `Segments` once it's node has been run. */ - override async result(): Promise { return super.result() as Promise; } + override async result(): Promise { + return super.result() as Promise; + } } /** Embeddings Array Item */ class EmbeddingsItem extends FutureAnyObject { /** Returns the result for `EmbeddingsItem` once it's node has been run. */ - override async result(): Promise { return super.result() as Promise; } + override async result(): Promise { + return super.result() as Promise; + } } /** TODO: MultiEmbedImageOut description */ class MultiEmbedImageOut extends FutureObject { /** Generated embeddings. */ - get embeddings() { return new Embeddings(this.directive.next('embeddings')) } + get embeddings() { + return new Embeddings(this.directive.next("embeddings")); + } /** Returns the result for `MultiEmbedImageOut` once it's node has been run. */ - override async result(): Promise { return super.result() as Promise; } + override async result(): Promise { + return super.result() as Promise; + } } /** Segments Array Item */ class SegmentsItem extends FutureAnyObject { /** Returns the result for `SegmentsItem` once it's node has been run. */ - override async result(): Promise { return super.result() as Promise; } + override async result(): Promise { + return super.result() as Promise; + } } /** TODO: UpscaleImageOut description */ class UpscaleImageOut extends FutureObject { /** Base 64-encoded JPEG image bytes, or a hosted image url if `store` is provided. */ - get image_uri() { return new FutureString(this.directive.next('image_uri')) } + get image_uri() { + return new FutureString(this.directive.next("image_uri")); + } /** Returns the result for `UpscaleImageOut` once it's node has been run. */ - override async result(): Promise { return super.result() as Promise; } + override async result(): Promise { + return super.result() as Promise; + } } /** TODO: GenerateTextVisionOut description */ class GenerateTextVisionOut extends FutureObject { /** Text response. */ - get text() { return new FutureString(this.directive.next('text')) } + get text() { + return new FutureString(this.directive.next("text")); + } /** Returns the result for `GenerateTextVisionOut` once it's node has been run. */ - override async result(): Promise { return super.result() as Promise; } + override async result(): Promise { + return super.result() as Promise; + } } /** TODO: Outputs description */ class Outputs extends FutureArray { - override at(index: number) { return new OutputsItem(this.directive.next(index)) } + override at(index: number) { + return new OutputsItem(this.directive.next(index)); + } /** Returns the result for `Outputs` once it's node has been run. */ - override async result(): Promise { return super.result() as Promise; } + override async result(): Promise { + return super.result() as Promise; + } } /** TODO: Choices description */ class Choices extends FutureArray { - override at(index: number) { return new ChoicesItem(this.directive.next(index)) } + override at(index: number) { + return new ChoicesItem(this.directive.next(index)); + } /** Returns the result for `Choices` once it's node has been run. */ - override async result(): Promise { return super.result() as Promise; } + override async result(): Promise { + return super.result() as Promise; + } } /** TODO: GenerateSpeechOut description */ class GenerateSpeechOut extends FutureObject { /** Base 64-encoded WAV audio bytes, or a hosted audio url if `store` is provided. */ - get audio_uri() { return new FutureString(this.directive.next('audio_uri')) } + get audio_uri() { + return new FutureString(this.directive.next("audio_uri")); + } /** Returns the result for `GenerateSpeechOut` once it's node has been run. */ - override async result(): Promise { return super.result() as Promise; } + override async result(): Promise { + return super.result() as Promise; + } } /** The random noise seed used for generation. */ class Seed extends FutureAnyObject { /** Returns the result for `Seed` once it's node has been run. */ - override async result(): Promise { return super.result() as Promise; } + override async result(): Promise { + return super.result() as Promise; + } } /** Generated embedding. */ class Embedding extends FutureAnyObject { /** Returns the result for `Embedding` once it's node has been run. */ - override async result(): Promise { return super.result() as Promise; } + override async result(): Promise { + return super.result() as Promise; + } } /** TODO: MultiControlledGenerateImageOut description */ class MultiControlledGenerateImageOut extends FutureObject { /** TODO: Outputs description */ - get outputs() { return new Outputs(this.directive.next('outputs')) } + get outputs() { + return new Outputs(this.directive.next("outputs")); + } /** Returns the result for `MultiControlledGenerateImageOut` once it's node has been run. */ - override async result(): Promise { return super.result() as Promise; } + override async result(): Promise { + return super.result() as Promise; + } } /** TODO: GenerativeEditImageOut description */ class GenerativeEditImageOut extends FutureObject { /** Base 64-encoded JPEG image bytes, or a hosted image url if `store` is provided. */ - get image_uri() { return new FutureString(this.directive.next('image_uri')) } + get image_uri() { + return new FutureString(this.directive.next("image_uri")); + } /** The random noise seed used for generation. */ - get seed() { return new Seed(this.directive.next('seed')) } + get seed() { + return new Seed(this.directive.next("seed")); + } /** Returns the result for `GenerativeEditImageOut` once it's node has been run. */ - override async result(): Promise { return super.result() as Promise; } + override async result(): Promise { + return super.result() as Promise; + } } /** (Optional) Chapter markers, if `suggest_chapters` is enabled. */ class Chapters extends FutureArray { - override at(index: number) { return new ChaptersItem(this.directive.next(index)) } + override at(index: number) { + return new ChaptersItem(this.directive.next(index)); + } /** Returns the result for `Chapters` once it's node has been run. */ - override async result(): Promise { return super.result() as Promise; } + override async result(): Promise { + return super.result() as Promise; + } } /** TODO: MultiGenerativeEditImageOut description */ class MultiGenerativeEditImageOut extends FutureObject { /** TODO: Outputs description */ - get outputs() { return new Outputs(this.directive.next('outputs')) } + get outputs() { + return new Outputs(this.directive.next("outputs")); + } /** Returns the result for `MultiGenerativeEditImageOut` once it's node has been run. */ - override async result(): Promise { return super.result() as Promise; } + override async result(): Promise { + return super.result() as Promise; + } } /** TODO: EmbedTextOut description */ class EmbedTextOut extends FutureObject { /** Generated embedding. */ - get embedding() { return new Embedding(this.directive.next('embedding')) } + get embedding() { + return new Embedding(this.directive.next("embedding")); + } /** Returns the result for `EmbedTextOut` once it's node has been run. */ - override async result(): Promise { return super.result() as Promise; } + override async result(): Promise { + return super.result() as Promise; + } } /** Outputs Array Item */ class OutputsItem extends FutureAnyObject { /** Returns the result for `OutputsItem` once it's node has been run. */ - override async result(): Promise { return super.result() as Promise; } + override async result(): Promise { + return super.result() as Promise; + } } /** TODO: RemoveBackgroundOut description */ class RemoveBackgroundOut extends FutureObject { /** Base 64-encoded JPEG image bytes, or a hosted image url if `store` is provided. */ - get image_uri() { return new FutureString(this.directive.next('image_uri')) } + get image_uri() { + return new FutureString(this.directive.next("image_uri")); + } /** Returns the result for `RemoveBackgroundOut` once it's node has been run. */ - override async result(): Promise { return super.result() as Promise; } + override async result(): Promise { + return super.result() as Promise; + } } /** Chapters Array Item */ class ChaptersItem extends FutureAnyObject { /** Returns the result for `ChaptersItem` once it's node has been run. */ - override async result(): Promise { return super.result() as Promise; } + override async result(): Promise { + return super.result() as Promise; + } } /** @@ -282,7 +425,9 @@ export class GenerateText extends Node { * * https://substrate.run/library#GenerateText */ - constructor(args: AlsoAcceptFutures) { + constructor( + args: AlsoAcceptFutures, + ) { super(args); } @@ -293,8 +438,12 @@ export class GenerateText extends Node { * * https://substrate.run/library#GenerateText */ - override async result(): Promise { - return super.result() as Promise; + override async result(): Promise< + OpenAPI.components["schemas"]["GenerateTextOut"] + > { + return super.result() as Promise< + OpenAPI.components["schemas"]["GenerateTextOut"] + >; } /** @@ -322,7 +471,11 @@ export class MultiGenerateText extends Node { * * https://substrate.run/library#MultiGenerateText */ - constructor(args: AlsoAcceptFutures) { + constructor( + args: AlsoAcceptFutures< + OpenAPI.components["schemas"]["MultiGenerateTextIn"] + >, + ) { super(args); } @@ -333,8 +486,12 @@ export class MultiGenerateText extends Node { * * https://substrate.run/library#MultiGenerateText */ - override async result(): Promise { - return super.result() as Promise; + override async result(): Promise< + OpenAPI.components["schemas"]["MultiGenerateTextOut"] + > { + return super.result() as Promise< + OpenAPI.components["schemas"]["MultiGenerateTextOut"] + >; } /** @@ -362,7 +519,11 @@ export class GenerateTextVision extends Node { * * https://substrate.run/library#GenerateTextVision */ - constructor(args: AlsoAcceptFutures) { + constructor( + args: AlsoAcceptFutures< + OpenAPI.components["schemas"]["GenerateTextVisionIn"] + >, + ) { super(args); } @@ -373,8 +534,12 @@ export class GenerateTextVision extends Node { * * https://substrate.run/library#GenerateTextVision */ - override async result(): Promise { - return super.result() as Promise; + override async result(): Promise< + OpenAPI.components["schemas"]["GenerateTextVisionOut"] + > { + return super.result() as Promise< + OpenAPI.components["schemas"]["GenerateTextVisionOut"] + >; } /** @@ -402,7 +567,9 @@ export class GenerateImage extends Node { * * https://substrate.run/library#GenerateImage */ - constructor(args: AlsoAcceptFutures) { + constructor( + args: AlsoAcceptFutures, + ) { super(args); } @@ -413,8 +580,12 @@ export class GenerateImage extends Node { * * https://substrate.run/library#GenerateImage */ - override async result(): Promise { - return super.result() as Promise; + override async result(): Promise< + OpenAPI.components["schemas"]["GenerateImageOut"] + > { + return super.result() as Promise< + OpenAPI.components["schemas"]["GenerateImageOut"] + >; } /** @@ -442,7 +613,11 @@ export class MultiGenerateImage extends Node { * * https://substrate.run/library#MultiGenerateImage */ - constructor(args: AlsoAcceptFutures) { + constructor( + args: AlsoAcceptFutures< + OpenAPI.components["schemas"]["MultiGenerateImageIn"] + >, + ) { super(args); } @@ -453,8 +628,12 @@ export class MultiGenerateImage extends Node { * * https://substrate.run/library#MultiGenerateImage */ - override async result(): Promise { - return super.result() as Promise; + override async result(): Promise< + OpenAPI.components["schemas"]["MultiGenerateImageOut"] + > { + return super.result() as Promise< + OpenAPI.components["schemas"]["MultiGenerateImageOut"] + >; } /** @@ -482,7 +661,11 @@ export class ControlledGenerateImage extends Node { * * https://substrate.run/library#ControlledGenerateImage */ - constructor(args: AlsoAcceptFutures) { + constructor( + args: AlsoAcceptFutures< + OpenAPI.components["schemas"]["ControlledGenerateImageIn"] + >, + ) { super(args); } @@ -493,8 +676,12 @@ export class ControlledGenerateImage extends Node { * * https://substrate.run/library#ControlledGenerateImage */ - override async result(): Promise { - return super.result() as Promise; + override async result(): Promise< + OpenAPI.components["schemas"]["ControlledGenerateImageOut"] + > { + return super.result() as Promise< + OpenAPI.components["schemas"]["ControlledGenerateImageOut"] + >; } /** @@ -522,7 +709,11 @@ export class MultiControlledGenerateImage extends Node { * * https://substrate.run/library#MultiControlledGenerateImage */ - constructor(args: AlsoAcceptFutures) { + constructor( + args: AlsoAcceptFutures< + OpenAPI.components["schemas"]["MultiControlledGenerateImageIn"] + >, + ) { super(args); } @@ -533,8 +724,12 @@ export class MultiControlledGenerateImage extends Node { * * https://substrate.run/library#MultiControlledGenerateImage */ - override async result(): Promise { - return super.result() as Promise; + override async result(): Promise< + OpenAPI.components["schemas"]["MultiControlledGenerateImageOut"] + > { + return super.result() as Promise< + OpenAPI.components["schemas"]["MultiControlledGenerateImageOut"] + >; } /** @@ -562,7 +757,11 @@ export class GenerativeEditImage extends Node { * * https://substrate.run/library#GenerativeEditImage */ - constructor(args: AlsoAcceptFutures) { + constructor( + args: AlsoAcceptFutures< + OpenAPI.components["schemas"]["GenerativeEditImageIn"] + >, + ) { super(args); } @@ -573,8 +772,12 @@ export class GenerativeEditImage extends Node { * * https://substrate.run/library#GenerativeEditImage */ - override async result(): Promise { - return super.result() as Promise; + override async result(): Promise< + OpenAPI.components["schemas"]["GenerativeEditImageOut"] + > { + return super.result() as Promise< + OpenAPI.components["schemas"]["GenerativeEditImageOut"] + >; } /** @@ -602,7 +805,11 @@ export class MultiGenerativeEditImage extends Node { * * https://substrate.run/library#MultiGenerativeEditImage */ - constructor(args: AlsoAcceptFutures) { + constructor( + args: AlsoAcceptFutures< + OpenAPI.components["schemas"]["MultiGenerativeEditImageIn"] + >, + ) { super(args); } @@ -613,8 +820,12 @@ export class MultiGenerativeEditImage extends Node { * * https://substrate.run/library#MultiGenerativeEditImage */ - override async result(): Promise { - return super.result() as Promise; + override async result(): Promise< + OpenAPI.components["schemas"]["MultiGenerativeEditImageOut"] + > { + return super.result() as Promise< + OpenAPI.components["schemas"]["MultiGenerativeEditImageOut"] + >; } /** @@ -642,7 +853,9 @@ export class FillMask extends Node { * * https://substrate.run/library#FillMask */ - constructor(args: AlsoAcceptFutures) { + constructor( + args: AlsoAcceptFutures, + ) { super(args); } @@ -653,8 +866,12 @@ export class FillMask extends Node { * * https://substrate.run/library#FillMask */ - override async result(): Promise { - return super.result() as Promise; + override async result(): Promise< + OpenAPI.components["schemas"]["FillMaskOut"] + > { + return super.result() as Promise< + OpenAPI.components["schemas"]["FillMaskOut"] + >; } /** @@ -682,7 +899,9 @@ export class UpscaleImage extends Node { * * https://substrate.run/library#UpscaleImage */ - constructor(args: AlsoAcceptFutures) { + constructor( + args: AlsoAcceptFutures, + ) { super(args); } @@ -693,8 +912,12 @@ export class UpscaleImage extends Node { * * https://substrate.run/library#UpscaleImage */ - override async result(): Promise { - return super.result() as Promise; + override async result(): Promise< + OpenAPI.components["schemas"]["UpscaleImageOut"] + > { + return super.result() as Promise< + OpenAPI.components["schemas"]["UpscaleImageOut"] + >; } /** @@ -722,7 +945,11 @@ export class RemoveBackground extends Node { * * https://substrate.run/library#RemoveBackground */ - constructor(args: AlsoAcceptFutures) { + constructor( + args: AlsoAcceptFutures< + OpenAPI.components["schemas"]["RemoveBackgroundIn"] + >, + ) { super(args); } @@ -733,8 +960,12 @@ export class RemoveBackground extends Node { * * https://substrate.run/library#RemoveBackground */ - override async result(): Promise { - return super.result() as Promise; + override async result(): Promise< + OpenAPI.components["schemas"]["RemoveBackgroundOut"] + > { + return super.result() as Promise< + OpenAPI.components["schemas"]["RemoveBackgroundOut"] + >; } /** @@ -762,7 +993,9 @@ export class DetectSegments extends Node { * * https://substrate.run/library#DetectSegments */ - constructor(args: AlsoAcceptFutures) { + constructor( + args: AlsoAcceptFutures, + ) { super(args); } @@ -773,8 +1006,12 @@ export class DetectSegments extends Node { * * https://substrate.run/library#DetectSegments */ - override async result(): Promise { - return super.result() as Promise; + override async result(): Promise< + OpenAPI.components["schemas"]["DetectSegmentsOut"] + > { + return super.result() as Promise< + OpenAPI.components["schemas"]["DetectSegmentsOut"] + >; } /** @@ -802,7 +1039,9 @@ export class TranscribeMedia extends Node { * * https://substrate.run/library#TranscribeMedia */ - constructor(args: AlsoAcceptFutures) { + constructor( + args: AlsoAcceptFutures, + ) { super(args); } @@ -813,8 +1052,12 @@ export class TranscribeMedia extends Node { * * https://substrate.run/library#TranscribeMedia */ - override async result(): Promise { - return super.result() as Promise; + override async result(): Promise< + OpenAPI.components["schemas"]["TranscribeMediaOut"] + > { + return super.result() as Promise< + OpenAPI.components["schemas"]["TranscribeMediaOut"] + >; } /** @@ -842,7 +1085,9 @@ export class GenerateSpeech extends Node { * * https://substrate.run/library#GenerateSpeech */ - constructor(args: AlsoAcceptFutures) { + constructor( + args: AlsoAcceptFutures, + ) { super(args); } @@ -853,8 +1098,12 @@ export class GenerateSpeech extends Node { * * https://substrate.run/library#GenerateSpeech */ - override async result(): Promise { - return super.result() as Promise; + override async result(): Promise< + OpenAPI.components["schemas"]["GenerateSpeechOut"] + > { + return super.result() as Promise< + OpenAPI.components["schemas"]["GenerateSpeechOut"] + >; } /** @@ -882,7 +1131,9 @@ export class EmbedText extends Node { * * https://substrate.run/library#EmbedText */ - constructor(args: AlsoAcceptFutures) { + constructor( + args: AlsoAcceptFutures, + ) { super(args); } @@ -893,8 +1144,12 @@ export class EmbedText extends Node { * * https://substrate.run/library#EmbedText */ - override async result(): Promise { - return super.result() as Promise; + override async result(): Promise< + OpenAPI.components["schemas"]["EmbedTextOut"] + > { + return super.result() as Promise< + OpenAPI.components["schemas"]["EmbedTextOut"] + >; } /** @@ -922,7 +1177,9 @@ export class MultiEmbedText extends Node { * * https://substrate.run/library#MultiEmbedText */ - constructor(args: AlsoAcceptFutures) { + constructor( + args: AlsoAcceptFutures, + ) { super(args); } @@ -933,8 +1190,12 @@ export class MultiEmbedText extends Node { * * https://substrate.run/library#MultiEmbedText */ - override async result(): Promise { - return super.result() as Promise; + override async result(): Promise< + OpenAPI.components["schemas"]["MultiEmbedTextOut"] + > { + return super.result() as Promise< + OpenAPI.components["schemas"]["MultiEmbedTextOut"] + >; } /** @@ -962,7 +1223,9 @@ export class EmbedImage extends Node { * * https://substrate.run/library#EmbedImage */ - constructor(args: AlsoAcceptFutures) { + constructor( + args: AlsoAcceptFutures, + ) { super(args); } @@ -973,8 +1236,12 @@ export class EmbedImage extends Node { * * https://substrate.run/library#EmbedImage */ - override async result(): Promise { - return super.result() as Promise; + override async result(): Promise< + OpenAPI.components["schemas"]["EmbedImageOut"] + > { + return super.result() as Promise< + OpenAPI.components["schemas"]["EmbedImageOut"] + >; } /** @@ -1002,7 +1269,9 @@ export class MultiEmbedImage extends Node { * * https://substrate.run/library#MultiEmbedImage */ - constructor(args: AlsoAcceptFutures) { + constructor( + args: AlsoAcceptFutures, + ) { super(args); } @@ -1013,8 +1282,12 @@ export class MultiEmbedImage extends Node { * * https://substrate.run/library#MultiEmbedImage */ - override async result(): Promise { - return super.result() as Promise; + override async result(): Promise< + OpenAPI.components["schemas"]["MultiEmbedImageOut"] + > { + return super.result() as Promise< + OpenAPI.components["schemas"]["MultiEmbedImageOut"] + >; } /** @@ -1028,4 +1301,3 @@ export class MultiEmbedImage extends Node { return new MultiEmbedImageOut(new Trace([], this)); } } - diff --git a/src/OpenAPI.ts b/src/OpenAPI.ts index 59f59f7..0c615a9 100644 --- a/src/OpenAPI.ts +++ b/src/OpenAPI.ts @@ -3,7 +3,6 @@ * Do not make direct changes to the file. */ - export interface paths { "/GenerateText": { /** @@ -290,11 +289,11 @@ export interface components { /** MultiGenerateTextOut */ MultiGenerateTextOut: { choices: { - /** @description Text response. */ - text?: string; - /** @description JSON response. */ - json_object?: Record; - }[]; + /** @description Text response. */ + text?: string; + /** @description JSON response. */ + json_object?: Record; + }[]; }; /** GenerateTextVisionIn */ GenerateTextVisionIn: { @@ -394,11 +393,11 @@ export interface components { /** MultiGenerateImageOut */ MultiGenerateImageOut: { outputs: { - /** @description Base 64-encoded JPEG image bytes, or a hosted image url if `store` is provided. */ - image_uri: string; - /** @description The random noise seed used for generation. */ - seed: number; - }[]; + /** @description Base 64-encoded JPEG image bytes, or a hosted image url if `store` is provided. */ + image_uri: string; + /** @description The random noise seed used for generation. */ + seed: number; + }[]; }; /** ControlledGenerateImageIn */ ControlledGenerateImageIn: { @@ -482,11 +481,11 @@ export interface components { /** MultiControlledGenerateImageOut */ MultiControlledGenerateImageOut: { outputs: { - /** @description Base 64-encoded JPEG image bytes, or a hosted image url if `store` is provided. */ - image_uri: string; - /** @description The random noise seed used for generation. */ - seed: number; - }[]; + /** @description Base 64-encoded JPEG image bytes, or a hosted image url if `store` is provided. */ + image_uri: string; + /** @description The random noise seed used for generation. */ + seed: number; + }[]; }; /** GenerativeEditImageIn */ GenerativeEditImageIn: { @@ -580,11 +579,11 @@ export interface components { /** MultiGenerativeEditImageOut */ MultiGenerativeEditImageOut: { outputs: { - /** @description Base 64-encoded JPEG image bytes, or a hosted image url if `store` is provided. */ - image_uri: string; - /** @description The random noise seed used for generation. */ - seed: number; - }[]; + /** @description Base 64-encoded JPEG image bytes, or a hosted image url if `store` is provided. */ + image_uri: string; + /** @description The random noise seed used for generation. */ + seed: number; + }[]; }; /** BoundingBox */ BoundingBox: { @@ -682,34 +681,34 @@ export interface components { image_uri: string; /** @description Point prompts, to detect a segment under the point. One of `point_prompt` or `box_prompt` must be set. */ point_prompts?: { - /** @description X position. */ - x: number; - /** @description Y position. */ - y: number; - }[]; + /** @description X position. */ + x: number; + /** @description Y position. */ + y: number; + }[]; /** @description Box prompts, to detect a segment within the bounding box. One of `point_prompt` or `box_prompt` must be set. */ box_prompts?: { - /** - * Format: float - * @description Top left corner x. - */ - x1: number; - /** - * Format: float - * @description Top left corner y. - */ - y1: number; - /** - * Format: float - * @description Bottom right corner x. - */ - x2: number; - /** - * Format: float - * @description Bottom right corner y. - */ - y2: number; - }[]; + /** + * Format: float + * @description Top left corner x. + */ + x1: number; + /** + * Format: float + * @description Top left corner y. + */ + y1: number; + /** + * Format: float + * @description Bottom right corner x. + */ + x2: number; + /** + * Format: float + * @description Bottom right corner y. + */ + y2: number; + }[]; /** * @description Selected model. * @default segment-anything @@ -791,21 +790,21 @@ export interface components { speaker?: string; /** @description Aligned words, if `align` is enabled. */ words?: { - /** @description Text of word. */ - word: string; - /** - * Format: float - * @description Start time of word, in seconds. - */ - start?: number; - /** - * Format: float - * @description End time of word, in seconds. - */ - end?: number; - /** @description ID of speaker, if `diarize` is enabled. */ - speaker?: string; - }[]; + /** @description Text of word. */ + word: string; + /** + * Format: float + * @description Start time of word, in seconds. + */ + start?: number; + /** + * Format: float + * @description End time of word, in seconds. + */ + end?: number; + /** @description ID of speaker, if `diarize` is enabled. */ + speaker?: string; + }[]; }; /** ChapterMarker */ ChapterMarker: { @@ -823,48 +822,48 @@ export interface components { text: string; /** @description Transcribed segments, if `segment` is enabled. */ segments?: { - /** @description Text of segment. */ - text: string; + /** @description Text of segment. */ + text: string; + /** + * Format: float + * @description Start time of segment, in seconds. + */ + start: number; + /** + * Format: float + * @description End time of segment, in seconds. + */ + end: number; + /** @description ID of speaker, if `diarize` is enabled. */ + speaker?: string; + /** @description Aligned words, if `align` is enabled. */ + words?: { + /** @description Text of word. */ + word: string; /** * Format: float - * @description Start time of segment, in seconds. + * @description Start time of word, in seconds. */ - start: number; + start?: number; /** * Format: float - * @description End time of segment, in seconds. + * @description End time of word, in seconds. */ - end: number; + end?: number; /** @description ID of speaker, if `diarize` is enabled. */ speaker?: string; - /** @description Aligned words, if `align` is enabled. */ - words?: { - /** @description Text of word. */ - word: string; - /** - * Format: float - * @description Start time of word, in seconds. - */ - start?: number; - /** - * Format: float - * @description End time of word, in seconds. - */ - end?: number; - /** @description ID of speaker, if `diarize` is enabled. */ - speaker?: string; - }[]; }[]; + }[]; /** @description Chapter markers, if `suggest_chapters` is enabled. */ chapters?: { - /** @description Chapter title. */ - title: string; - /** - * Format: float - * @description Start time of chapter, in seconds. - */ - start: number; - }[]; + /** @description Chapter title. */ + title: string; + /** + * Format: float + * @description Start time of chapter, in seconds. + */ + start: number; + }[]; }; /** GenerateSpeechIn */ GenerateSpeechIn: { @@ -937,13 +936,13 @@ export interface components { MultiEmbedTextIn: { /** @description Items to embed. */ items: { - /** @description Text to embed. */ - text: string; - /** @description Metadata that can be used to query the vector store. Ignored if `store` is unset. */ - metadata?: Record; - /** @description Vector store document ID. Ignored if `store` is unset. */ - document_id?: string; - }[]; + /** @description Text to embed. */ + text: string; + /** @description Metadata that can be used to query the vector store. Ignored if `store` is unset. */ + metadata?: Record; + /** @description Vector store document ID. Ignored if `store` is unset. */ + document_id?: string; + }[]; /** * @description Selected model. * @default jina-v2 @@ -959,13 +958,13 @@ export interface components { MultiEmbedTextOut: { /** @description Generated embeddings. */ embeddings: { - /** @description Embedding vector. */ - vector: string; - /** @description Vector store document ID. */ - document_id?: string; - /** @description Vector store document metadata. */ - metadata?: Record; - }[]; + /** @description Embedding vector. */ + vector: string; + /** @description Vector store document ID. */ + document_id?: string; + /** @description Vector store document metadata. */ + metadata?: Record; + }[]; }; /** EmbedImageIn */ EmbedImageIn: { @@ -1004,11 +1003,11 @@ export interface components { MultiEmbedImageIn: { /** @description Items to embed. */ items: { - /** @description Image to embed. */ - image_uri: string; - /** @description Vector store document ID. Ignored if `store` is unset. */ - document_id?: string; - }[]; + /** @description Image to embed. */ + image_uri: string; + /** @description Vector store document ID. Ignored if `store` is unset. */ + document_id?: string; + }[]; /** @description [Vector store](/docs/vector-stores) identifier. */ store?: string; /** @@ -1022,13 +1021,13 @@ export interface components { MultiEmbedImageOut: { /** @description Generated embeddings. */ embeddings: { - /** @description Embedding vector. */ - vector: string; - /** @description Vector store document ID. */ - document_id?: string; - /** @description Vector store document metadata. */ - metadata?: Record; - }[]; + /** @description Embedding vector. */ + vector: string; + /** @description Vector store document ID. */ + document_id?: string; + /** @description Vector store document metadata. */ + metadata?: Record; + }[]; }; /** * VectorStoreParams @@ -1097,13 +1096,13 @@ export interface components { GetVectorsResponse: { /** @description Retrieved vectors. */ vectors: { - /** @description Document ID. */ - id: string; - /** @description Embedding vector. */ - vector: number[]; - /** @description Document metadata. */ - metadata: Record; - }[]; + /** @description Document ID. */ + id: string; + /** @description Embedding vector. */ + vector: number[]; + /** @description Document metadata. */ + metadata: Record; + }[]; }; /** VectorUpdateCountResponse */ VectorUpdateCountResponse: { @@ -1133,13 +1132,13 @@ export interface components { model: "jina-v2" | "clip"; /** @description Vectors to upsert. */ vectors: { - /** @description Document ID. */ - id: string; - /** @description Embedding vector. */ - vector?: number[]; - /** @description Document metadata. */ - metadata?: Record; - }[]; + /** @description Document ID. */ + id: string; + /** @description Embedding vector. */ + vector?: number[]; + /** @description Document metadata. */ + metadata?: Record; + }[]; }; /** DeleteVectorsParams */ DeleteVectorsParams: { @@ -1211,18 +1210,18 @@ export interface components { QueryVectorStoreResponse: { /** @description Query results. */ results: { - /** @description Document ID. */ - id: string; - /** - * Format: float - * @description Similarity score. - */ - distance: number; - /** @description Embedding vector. */ - vector?: number[]; - /** @description Document metadata. */ - metadata?: Record; - }[][]; + /** @description Document ID. */ + id: string; + /** + * Format: float + * @description Similarity score. + */ + distance: number; + /** @description Embedding vector. */ + vector?: number[]; + /** @description Document metadata. */ + metadata?: Record; + }[][]; /** @description Vector store name. */ name?: string; /** @@ -1249,7 +1248,6 @@ export type $defs = Record; export type external = Record; export interface operations { - /** * GenerateText * @description Generate text using a language model. @@ -1352,11 +1350,11 @@ export interface operations { content: { "application/json": { choices: { - /** @description Text response. */ - text?: string; - /** @description JSON response. */ - json_object?: Record; - }[]; + /** @description Text response. */ + text?: string; + /** @description JSON response. */ + json_object?: Record; + }[]; }; }; }; @@ -1501,11 +1499,11 @@ export interface operations { content: { "application/json": { outputs: { - /** @description Base 64-encoded JPEG image bytes, or a hosted image url if `store` is provided. */ - image_uri: string; - /** @description The random noise seed used for generation. */ - seed: number; - }[]; + /** @description Base 64-encoded JPEG image bytes, or a hosted image url if `store` is provided. */ + image_uri: string; + /** @description The random noise seed used for generation. */ + seed: number; + }[]; }; }; }; @@ -1619,11 +1617,11 @@ export interface operations { content: { "application/json": { outputs: { - /** @description Base 64-encoded JPEG image bytes, or a hosted image url if `store` is provided. */ - image_uri: string; - /** @description The random noise seed used for generation. */ - seed: number; - }[]; + /** @description Base 64-encoded JPEG image bytes, or a hosted image url if `store` is provided. */ + image_uri: string; + /** @description The random noise seed used for generation. */ + seed: number; + }[]; }; }; }; @@ -1747,11 +1745,11 @@ export interface operations { content: { "application/json": { outputs: { - /** @description Base 64-encoded JPEG image bytes, or a hosted image url if `store` is provided. */ - image_uri: string; - /** @description The random noise seed used for generation. */ - seed: number; - }[]; + /** @description Base 64-encoded JPEG image bytes, or a hosted image url if `store` is provided. */ + image_uri: string; + /** @description The random noise seed used for generation. */ + seed: number; + }[]; }; }; }; @@ -1874,34 +1872,34 @@ export interface operations { image_uri: string; /** @description Point prompts, to detect a segment under the point. One of `point_prompt` or `box_prompt` must be set. */ point_prompts?: { - /** @description X position. */ - x: number; - /** @description Y position. */ - y: number; - }[]; + /** @description X position. */ + x: number; + /** @description Y position. */ + y: number; + }[]; /** @description Box prompts, to detect a segment within the bounding box. One of `point_prompt` or `box_prompt` must be set. */ box_prompts?: { - /** - * Format: float - * @description Top left corner x. - */ - x1: number; - /** - * Format: float - * @description Top left corner y. - */ - y1: number; - /** - * Format: float - * @description Bottom right corner x. - */ - x2: number; - /** - * Format: float - * @description Bottom right corner y. - */ - y2: number; - }[]; + /** + * Format: float + * @description Top left corner x. + */ + x1: number; + /** + * Format: float + * @description Top left corner y. + */ + y1: number; + /** + * Format: float + * @description Bottom right corner x. + */ + x2: number; + /** + * Format: float + * @description Bottom right corner y. + */ + y2: number; + }[]; /** * @description Selected model. * @default segment-anything @@ -1974,48 +1972,48 @@ export interface operations { text: string; /** @description Transcribed segments, if `segment` is enabled. */ segments?: { - /** @description Text of segment. */ - text: string; + /** @description Text of segment. */ + text: string; + /** + * Format: float + * @description Start time of segment, in seconds. + */ + start: number; + /** + * Format: float + * @description End time of segment, in seconds. + */ + end: number; + /** @description ID of speaker, if `diarize` is enabled. */ + speaker?: string; + /** @description Aligned words, if `align` is enabled. */ + words?: { + /** @description Text of word. */ + word: string; /** * Format: float - * @description Start time of segment, in seconds. + * @description Start time of word, in seconds. */ - start: number; + start?: number; /** * Format: float - * @description End time of segment, in seconds. + * @description End time of word, in seconds. */ - end: number; + end?: number; /** @description ID of speaker, if `diarize` is enabled. */ speaker?: string; - /** @description Aligned words, if `align` is enabled. */ - words?: { - /** @description Text of word. */ - word: string; - /** - * Format: float - * @description Start time of word, in seconds. - */ - start?: number; - /** - * Format: float - * @description End time of word, in seconds. - */ - end?: number; - /** @description ID of speaker, if `diarize` is enabled. */ - speaker?: string; - }[]; }[]; + }[]; /** @description Chapter markers, if `suggest_chapters` is enabled. */ chapters?: { - /** @description Chapter title. */ - title: string; - /** - * Format: float - * @description Start time of chapter, in seconds. - */ - start: number; - }[]; + /** @description Chapter title. */ + title: string; + /** + * Format: float + * @description Start time of chapter, in seconds. + */ + start: number; + }[]; }; }; }; @@ -2111,13 +2109,13 @@ export interface operations { undefined?: { /** @description Items to embed. */ items: { - /** @description Text to embed. */ - text: string; - /** @description Metadata that can be used to query the vector store. Ignored if `store` is unset. */ - metadata?: Record; - /** @description Vector store document ID. Ignored if `store` is unset. */ - document_id?: string; - }[]; + /** @description Text to embed. */ + text: string; + /** @description Metadata that can be used to query the vector store. Ignored if `store` is unset. */ + metadata?: Record; + /** @description Vector store document ID. Ignored if `store` is unset. */ + document_id?: string; + }[]; /** * @description Selected model. * @default jina-v2 @@ -2138,13 +2136,13 @@ export interface operations { "application/json": { /** @description Generated embeddings. */ embeddings: { - /** @description Embedding vector. */ - vector: string; - /** @description Vector store document ID. */ - document_id?: string; - /** @description Vector store document metadata. */ - metadata?: Record; - }[]; + /** @description Embedding vector. */ + vector: string; + /** @description Vector store document ID. */ + document_id?: string; + /** @description Vector store document metadata. */ + metadata?: Record; + }[]; }; }; }; @@ -2202,11 +2200,11 @@ export interface operations { undefined?: { /** @description Items to embed. */ items: { - /** @description Image to embed. */ - image_uri: string; - /** @description Vector store document ID. Ignored if `store` is unset. */ - document_id?: string; - }[]; + /** @description Image to embed. */ + image_uri: string; + /** @description Vector store document ID. Ignored if `store` is unset. */ + document_id?: string; + }[]; /** @description [Vector store](/docs/vector-stores) identifier. */ store?: string; /** @@ -2225,13 +2223,13 @@ export interface operations { "application/json": { /** @description Generated embeddings. */ embeddings: { - /** @description Embedding vector. */ - vector: string; - /** @description Vector store document ID. */ - document_id?: string; - /** @description Vector store document metadata. */ - metadata?: Record; - }[]; + /** @description Embedding vector. */ + vector: string; + /** @description Vector store document ID. */ + document_id?: string; + /** @description Vector store document metadata. */ + metadata?: Record; + }[]; }; }; }; @@ -2313,31 +2311,31 @@ export interface operations { /** @description List of vector stores. */ 200: { content: { - "application/json": ({ - /** @description Vector store name. */ - name: string; - /** - * @description Selected embedding model - * @enum {string} - */ - model: "jina-v2" | "clip"; - /** - * @description The max number of connections per layer for the index. - * @default 16 - */ - m?: number; - /** - * @description The size of the dynamic candidate list for constructing the index graph. - * @default 64 - */ - ef_construction?: number; - /** - * @description The distance metric to construct the index with. - * @default inner - * @enum {string} - */ - metric?: "cosine" | "l2" | "inner"; - })[]; + "application/json": { + /** @description Vector store name. */ + name: string; + /** + * @description Selected embedding model + * @enum {string} + */ + model: "jina-v2" | "clip"; + /** + * @description The max number of connections per layer for the index. + * @default 16 + */ + m?: number; + /** + * @description The size of the dynamic candidate list for constructing the index graph. + * @default 64 + */ + ef_construction?: number; + /** + * @description The distance metric to construct the index with. + * @default inner + * @enum {string} + */ + metric?: "cosine" | "l2" | "inner"; + }[]; }; }; }; @@ -2422,18 +2420,18 @@ export interface operations { "application/json": { /** @description Query results. */ results: { - /** @description Document ID. */ - id: string; - /** - * Format: float - * @description Similarity score. - */ - distance: number; - /** @description Embedding vector. */ - vector?: number[]; - /** @description Document metadata. */ - metadata?: Record; - }[][]; + /** @description Document ID. */ + id: string; + /** + * Format: float + * @description Similarity score. + */ + distance: number; + /** @description Embedding vector. */ + vector?: number[]; + /** @description Document metadata. */ + metadata?: Record; + }[][]; /** @description Vector store name. */ name?: string; /** @@ -2478,13 +2476,13 @@ export interface operations { "application/json": { /** @description Retrieved vectors. */ vectors: { - /** @description Document ID. */ - id: string; - /** @description Embedding vector. */ - vector: number[]; - /** @description Document metadata. */ - metadata: Record; - }[]; + /** @description Document ID. */ + id: string; + /** @description Embedding vector. */ + vector: number[]; + /** @description Document metadata. */ + metadata: Record; + }[]; }; }; }; @@ -2507,13 +2505,13 @@ export interface operations { model: "jina-v2" | "clip"; /** @description Vectors to upsert. */ vectors: { - /** @description Document ID. */ - id: string; - /** @description Embedding vector. */ - vector?: number[]; - /** @description Document metadata. */ - metadata?: Record; - }[]; + /** @description Document ID. */ + id: string; + /** @description Embedding vector. */ + vector?: number[]; + /** @description Document metadata. */ + metadata?: Record; + }[]; }; }; }; diff --git a/src/Platform.ts b/src/Platform.ts index 9b2294f..68ac165 100644 --- a/src/Platform.ts +++ b/src/Platform.ts @@ -25,7 +25,13 @@ type Browser = "ie" | "edge" | "chrome" | "firefox" | "safari"; type PlatformProperties = { os: PlatformName; arch: Arch; - runtime: "node" | "deno" | "edge" | "workerd" | `browser:${Browser}` | "unknown"; + runtime: + | "node" + | "deno" + | "edge" + | "workerd" + | `browser:${Browser}` + | "unknown"; runtimeVersion: string; }; @@ -64,7 +70,10 @@ export const getPlatformProperties = (): PlatformProperties => { } // https://developers.cloudflare.com/workers/runtime-apis/web-standards/#navigatoruseragent - if (typeof navigator !== undefined && navigator.userAgent === "Cloudflare-Workers") { + if ( + typeof navigator !== undefined && + navigator.userAgent === "Cloudflare-Workers" + ) { return { os: "Unknown", arch: "unknown", diff --git a/src/index.ts b/src/index.ts index 90abd3c..08350b3 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,8 +1,8 @@ /** -* ꩜ Substrate TypeScript SDK -* @generated file -* 20240315.20240321 -*/ + * ꩜ Substrate TypeScript SDK + * @generated file + * 20240315.20240321 + */ export { SubstrateError } from "substrate/Error"; export { @@ -25,9 +25,9 @@ export { MultiEmbedText, EmbedImage, MultiEmbedImage, - } from "substrate/Nodes"; +} from "substrate/Nodes"; export { sb } from "substrate/sb"; export { Substrate }; import { Substrate } from "substrate/Substrate"; -export default Substrate; \ No newline at end of file +export default Substrate; From a7a1ba7750545f0c4f46e3e3cc3ccc7d55fd6450 Mon Sep 17 00:00:00 2001 From: Liam Griffiths Date: Tue, 2 Apr 2024 10:03:18 -0500 Subject: [PATCH 2/6] Update rest of files (prettier) --- DEVELOPMENT.md | 44 +++++++++++++++++++----------------- Makefile | 4 ++++ bin/update-version.ts | 1 - examples/re-running-nodes.ts | 7 +++--- examples/single.ts | 1 - examples/string-concat.ts | 4 +++- tsconfig.json | 44 ++++++++++++++++++------------------ 7 files changed, 56 insertions(+), 49 deletions(-) diff --git a/DEVELOPMENT.md b/DEVELOPMENT.md index 7424944..ebe8ce1 100644 --- a/DEVELOPMENT.md +++ b/DEVELOPMENT.md @@ -83,12 +83,12 @@ This project uses a few tools to help with building and packaging it up: `typesc Their respective configuration files work together to produce the the library and this section contains a few highlights to help better understand how it works. -* Compiled and bundled up code lives in `dist/` (set in `tsconfig.json` "outDir") -* We're targeting ES2022 as our output language, which is supprted by Node 18+ (see `tsconfig.json` "target") -* We're building both ESM (.js) and CJS (.cjs) compatible artifacts (see `tsup.config.ts` "formats") -* During build we're generating TypeScript declaration files and making them available to package consumers (see `tsup.config.ts` "dts") -* Our package uses conditional exports so that the consumer will automatically get the right ESM or CJS based on how they import (see `package.json` "exports") -* When we publish the package to NPM we're only including the `dist/`, `src/` and "default files", eg. `README`, `LICENCE` (see `package.json` "files") +- Compiled and bundled up code lives in `dist/` (set in `tsconfig.json` "outDir") +- We're targeting ES2022 as our output language, which is supprted by Node 18+ (see `tsconfig.json` "target") +- We're building both ESM (.js) and CJS (.cjs) compatible artifacts (see `tsup.config.ts` "formats") +- During build we're generating TypeScript declaration files and making them available to package consumers (see `tsup.config.ts` "dts") +- Our package uses conditional exports so that the consumer will automatically get the right ESM or CJS based on how they import (see `package.json` "exports") +- When we publish the package to NPM we're only including the `dist/`, `src/` and "default files", eg. `README`, `LICENCE` (see `package.json` "files") ## Versioning @@ -99,35 +99,37 @@ incorporate information about the API version and SDK version. We update version The version string looks like the following: ```js - `${major}${version}.${minor}.${patch}` +`${major}${version}.${minor}.${patch}`; ``` -* `major` is set manually and is the MAJOR version of the SDK code -* `version` is a date string (`yyyymmdd`) we use as the API Version (from our OpenAPI schema) -* `minor` is set manually and is the MINOR version of the SDK code -* `patch` is set manually and is the PATCH version of the SDK code +- `major` is set manually and is the MAJOR version of the SDK code +- `version` is a date string (`yyyymmdd`) we use as the API Version (from our OpenAPI schema) +- `minor` is set manually and is the MINOR version of the SDK code +- `patch` is set manually and is the PATCH version of the SDK code The version of the SDK should be updated in branches being merged into `main` according to the semantic versioning scheme: -* MAJOR version when you make incompatible API changes -* MINOR version when you add functionality in a backward compatible manner -* PATCH version when you make backward compatible bug fixes +- MAJOR version when you make incompatible API changes +- MINOR version when you add functionality in a backward compatible manner +- PATCH version when you make backward compatible bug fixes ### Updating The Package Version After making changes, you should: -* Make sure to bump the `SDK_VERSION` in the `bin/update-version.ts` script -* Then run `make update-version` to ensure the `package.json` and `src/version.ts` are set correctly. + +- Make sure to bump the `SDK_VERSION` in the `bin/update-version.ts` script +- Then run `make update-version` to ensure the `package.json` and `src/version.ts` are set correctly. **NOTE:** The `make update-version` task will run after every `make sync-codegen` too! ## Releasing **Prerequisites**: -* Have an [npmjs.com](https://www.npmjs.com/) account and it must be a member of our organization -* Have an GitHub account and it must be a member of our organization with write permissions on the repo -* The changes that are currently in the branch are the one you would like to release (typically `main`) -* The `version` field in the `package.json` is the one you would like to use for the release already + +- Have an [npmjs.com](https://www.npmjs.com/) account and it must be a member of our organization +- Have an GitHub account and it must be a member of our organization with write permissions on the repo +- The changes that are currently in the branch are the one you would like to release (typically `main`) +- The `version` field in the `package.json` is the one you would like to use for the release already **Production Releases**: @@ -139,7 +141,7 @@ that we'd like to publish. 2. Publish to NPM & push tag to GitHub: `make publish` 3. Create new Release on GitHub (using the web UI). Add release notes, mentions, etc. -**Non-Production Releases** +**Non-Production Releases** The previous workflow assumes that the tag being published should be marked as `latest` for the NPM [distribution tag](https://docs.npmjs.com/adding-dist-tags-to-packages). If you would like to mark a release as diff --git a/Makefile b/Makefile index 92f6472..e8ee0bd 100644 --- a/Makefile +++ b/Makefile @@ -30,6 +30,10 @@ sync-codegen: ensure typecheck: ensure npx tsc -noEmit +.PHONY: format-check +typecheck: ensure + npx tsc -noEmit + .PHONY: build build: ensure npx tsup diff --git a/bin/update-version.ts b/bin/update-version.ts index 417ec57..f618571 100755 --- a/bin/update-version.ts +++ b/bin/update-version.ts @@ -24,4 +24,3 @@ try { } catch (error) { console.error("Error reading or parsing openapi.json:", error); } - diff --git a/examples/re-running-nodes.ts b/examples/re-running-nodes.ts index 5be9e17..6de80ea 100755 --- a/examples/re-running-nodes.ts +++ b/examples/re-running-nodes.ts @@ -15,7 +15,8 @@ const SUBSTRATE_API_KEY = process.env["SUBSTRATE_API_KEY"]; const substrate = new Substrate({ apiKey: SUBSTRATE_API_KEY }); const a = new GenerateText({ - prompt: "in very few words describe an incredible moment in sports history, be extremely concise", + prompt: + "in very few words describe an incredible moment in sports history, be extremely concise", }); a.result().then((result) => { @@ -40,7 +41,7 @@ console.log("[3]", await f1); // when we access it's result again, we will get the same // value we had in `f1` let f2 = a.future.text.result(); -console.log("[4]", "await f1 === await f2 =", await f1 === await f2); // true +console.log("[4]", "await f1 === await f2 =", (await f1) === (await f2)); // true // now let's run the node again await substrate.run(a); @@ -51,7 +52,7 @@ console.log("[5]", "Running node a second time!"); // and it should be different than the first let f3 = a.future.text.result(); console.log("[6]", await f3); -console.log("[7]", "await f1 !== await f3 =", await f1 !== await f3); // true +console.log("[7]", "await f1 !== await f3 =", (await f1) !== (await f3)); // true // if we look back at the previous results we should see // that the first two are still the same, but the third diff --git a/examples/single.ts b/examples/single.ts index 800642b..23c5913 100755 --- a/examples/single.ts +++ b/examples/single.ts @@ -11,7 +11,6 @@ const a = new GenerateText({ "in very few words describe an incredible historcal technical achievement", }); - substrate.run(a); console.log(await a.future.text.result()); diff --git a/examples/string-concat.ts b/examples/string-concat.ts index 27f8761..5935df3 100755 --- a/examples/string-concat.ts +++ b/examples/string-concat.ts @@ -9,7 +9,9 @@ const substrate = new Substrate({ baseUrl: "https://api-staging.substrate.run", }); -const a = new GenerateText({ prompt: "name a random capital city: , " }); +const a = new GenerateText({ + prompt: "name a random capital city: , ", +}); const concatenated = sb.concat("tell me about visiting ", a.future.text); diff --git a/tsconfig.json b/tsconfig.json index c1df0d9..6ad86d4 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -3,36 +3,36 @@ /* Visit https://aka.ms/tsconfig to read more about this file */ /* Language and Environment */ - "target": "es2022", /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */ + "target": "es2022" /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */, // "lib": [], /* Specify a set of bundled library declaration files that describe the target runtime environment. */ /* Modules */ - "module": "es2022", /* Specify what module code is generated. */ - "moduleResolution": "bundler", /* Specify how TypeScript looks up a file from a given module specifier. */ + "module": "es2022" /* Specify what module code is generated. */, + "moduleResolution": "bundler" /* Specify how TypeScript looks up a file from a given module specifier. */, // "customConditions": [], /* Conditions to set in addition to the resolver-specific defaults when resolving imports. */ /* Emit */ - "declaration": true, /* Generate .d.ts files from TypeScript and JavaScript files in your project. */ - "outDir": "./dist", /* Specify an output folder for all emitted files. */ + "declaration": true /* Generate .d.ts files from TypeScript and JavaScript files in your project. */, + "outDir": "./dist" /* Specify an output folder for all emitted files. */, /* Interop Constraints */ - "forceConsistentCasingInFileNames": true, /* Ensure that casing is correct in imports. */ + "forceConsistentCasingInFileNames": true /* Ensure that casing is correct in imports. */, /* Type Checking */ - "strict": true, /* Enable all strict type-checking options. */ - "strictNullChecks": true, /* When type checking, take into account 'null' and 'undefined'. */ - "strictPropertyInitialization": false, /* Check for class properties that are declared but not set in the constructor. */ - "strictFunctionTypes": true, /* When assigning functions, check to ensure parameters and the return values are subtype-compatible. */ - "strictBindCallApply": true, /* Check that the arguments for 'bind', 'call', and 'apply' methods match the original function. */ - "alwaysStrict": true, /* Ensure 'use strict' is always emitted. */ - "noImplicitAny": true, /* Enable error reporting for expressions and declarations with an implied 'any' type. */ - "noImplicitReturns": true, /* Enable error reporting for codepaths that do not explicitly return in a function. */ - "noUnusedLocals": true, /* Enable error reporting when local variables aren't read. */ - "noImplicitOverride": true, /* Ensure overriding members in derived classes are marked with an override modifier. */ - "noImplicitThis": true, /* Enable error reporting when 'this' is given the type 'any'. */ - "noUncheckedIndexedAccess": true, /* Add 'undefined' to a type when accessed using an index. */ - "noPropertyAccessFromIndexSignature": true, /* Enforces using indexed accessors for keys declared using an indexed type. */ - "noFallthroughCasesInSwitch": true, /* Enable error reporting for fallthrough cases in switch statements. */ + "strict": true /* Enable all strict type-checking options. */, + "strictNullChecks": true /* When type checking, take into account 'null' and 'undefined'. */, + "strictPropertyInitialization": false /* Check for class properties that are declared but not set in the constructor. */, + "strictFunctionTypes": true /* When assigning functions, check to ensure parameters and the return values are subtype-compatible. */, + "strictBindCallApply": true /* Check that the arguments for 'bind', 'call', and 'apply' methods match the original function. */, + "alwaysStrict": true /* Ensure 'use strict' is always emitted. */, + "noImplicitAny": true /* Enable error reporting for expressions and declarations with an implied 'any' type. */, + "noImplicitReturns": true /* Enable error reporting for codepaths that do not explicitly return in a function. */, + "noUnusedLocals": true /* Enable error reporting when local variables aren't read. */, + "noImplicitOverride": true /* Ensure overriding members in derived classes are marked with an override modifier. */, + "noImplicitThis": true /* Enable error reporting when 'this' is given the type 'any'. */, + "noUncheckedIndexedAccess": true /* Add 'undefined' to a type when accessed using an index. */, + "noPropertyAccessFromIndexSignature": true /* Enforces using indexed accessors for keys declared using an indexed type. */, + "noFallthroughCasesInSwitch": true /* Enable error reporting for fallthrough cases in switch statements. */, // "exactOptionalPropertyTypes": true, /* Interpret optional property types as written, rather than adding 'undefined'. */ // "noUnusedParameters": true, /* Raise an error when a function parameter isn't read. */ // "allowUnusedLabels": true, /* Disable error reporting for unused labels. */ @@ -40,7 +40,7 @@ // "useUnknownInCatchVariables": true, /* Default catch clause variables as 'unknown' instead of 'any'. */ /* Completeness */ - "skipLibCheck": true, /* Skip type checking all .d.ts files. */ + "skipLibCheck": true /* Skip type checking all .d.ts files. */, // "skipDefaultLibCheck": true, /* Skip type checking .d.ts files that are included with TypeScript. */ /* Internal-use: package paths */ @@ -52,6 +52,6 @@ /* Internal-use: running example scripts */ "ts-node": { - "esm": true, + "esm": true } } From 4ddc7444545e84e6107b7d3de0af48340dd70bab Mon Sep 17 00:00:00 2001 From: Liam Griffiths Date: Tue, 2 Apr 2024 10:03:57 -0500 Subject: [PATCH 3/6] Update Makefile (add tasks for prettier) --- Makefile | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index e8ee0bd..44821ca 100644 --- a/Makefile +++ b/Makefile @@ -32,7 +32,11 @@ typecheck: ensure .PHONY: format-check typecheck: ensure - npx tsc -noEmit + npx prettier . --check + +.PHONY: format-write +typecheck: ensure + npx prettier . --write .PHONY: build build: ensure From c31bd95354f09e5ccb9278cfd6333f333555d752 Mon Sep 17 00:00:00 2001 From: Liam Griffiths Date: Tue, 2 Apr 2024 10:05:43 -0500 Subject: [PATCH 4/6] Add format-check step in CI --- .github/workflows/node.js.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/node.js.yml b/.github/workflows/node.js.yml index 5ff8efa..0729b35 100644 --- a/.github/workflows/node.js.yml +++ b/.github/workflows/node.js.yml @@ -27,5 +27,6 @@ jobs: node-version: ${{ matrix.node-version }} cache: 'npm' - run: npm ci + - run: make format-check - run: make build - run: make test From db64d52ea91ecb05ae7fcea68cf9a1d6fb37dba0 Mon Sep 17 00:00:00 2001 From: Liam Griffiths Date: Tue, 2 Apr 2024 10:08:41 -0500 Subject: [PATCH 5/6] Update Makefile, add comments --- .github/workflows/node.js.yml | 2 +- Makefile | 10 +++------- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/.github/workflows/node.js.yml b/.github/workflows/node.js.yml index 0729b35..b35caee 100644 --- a/.github/workflows/node.js.yml +++ b/.github/workflows/node.js.yml @@ -28,5 +28,5 @@ jobs: cache: 'npm' - run: npm ci - run: make format-check - - run: make build + - run: make build # also ensures typechecking passes - run: make test diff --git a/Makefile b/Makefile index 44821ca..75906d0 100644 --- a/Makefile +++ b/Makefile @@ -26,16 +26,12 @@ sync-codegen: ensure bin/sync-codegen.ts make update-version -.PHONY: typecheck -typecheck: ensure - npx tsc -noEmit - .PHONY: format-check -typecheck: ensure +format-check: ensure npx prettier . --check -.PHONY: format-write -typecheck: ensure +.PHONY: format-fix +format-fix: ensure npx prettier . --write .PHONY: build From 50d7eb81437eb408924b6e0647b334a654f6af9b Mon Sep 17 00:00:00 2001 From: Liam Griffiths Date: Tue, 2 Apr 2024 10:09:51 -0500 Subject: [PATCH 6/6] updates gha formatting --- .github/workflows/node.js.yml | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/.github/workflows/node.js.yml b/.github/workflows/node.js.yml index b35caee..d081157 100644 --- a/.github/workflows/node.js.yml +++ b/.github/workflows/node.js.yml @@ -5,13 +5,12 @@ name: Node.js CI on: push: - branches: [ "main" ] + branches: ["main"] pull_request: - branches: [ "main" ] + branches: ["main"] jobs: build: - runs-on: ubuntu-latest strategy: @@ -20,13 +19,13 @@ jobs: # See supported Node.js release schedule at https://nodejs.org/en/about/releases/ steps: - - uses: actions/checkout@v3 - - name: Use Node.js ${{ matrix.node-version }} - uses: actions/setup-node@v3 - with: - node-version: ${{ matrix.node-version }} - cache: 'npm' - - run: npm ci - - run: make format-check - - run: make build # also ensures typechecking passes - - run: make test + - uses: actions/checkout@v3 + - name: Use Node.js ${{ matrix.node-version }} + uses: actions/setup-node@v3 + with: + node-version: ${{ matrix.node-version }} + cache: "npm" + - run: npm ci + - run: make format-check + - run: make build # also ensures typechecking passes + - run: make test