Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: export types from aqua-api #904

Merged
merged 2 commits into from
Sep 18, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 22 additions & 10 deletions api/api-npm/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { ServiceDef, FunctionCallDef } from "@fluencelabs/interfaces";

class AquaFunction {
export class AquaFunction {
funcDef: FunctionCallDef;
script: string;
}

class GeneratedSource {
export class GeneratedSource {
name: string;
tsSource?: string;
jsSource?: string;
Expand Down Expand Up @@ -43,20 +43,26 @@ type CodeString = {
code: string;
};

export type CompileFromStringArgs = CommonArgs & CodeString;
export type CompileFromStringReturnType = Omit<CompilationResult, "funcCall">;

/** Compile aqua code from a string */
export declare function compileFromString(
args: CommonArgs & CodeString,
): Promise<Omit<CompilationResult, "funcCall">>;
args: CompileFromStringArgs,
): Promise<CompileFromStringReturnType>;

type FilePath = {
/** Path to the aqua file to be compiled */
filePath: string;
};

export type CompileFromPathArgs = CommonArgs & FilePath;
export type CompileFromPathReturnType = Omit<CompilationResult, "funcCall">;

/** Compile aqua code from a file */
export declare function compileFromPath(
args: CommonArgs & FilePath,
): Promise<Omit<CompilationResult, "funcCall">>;
args: CompileFromPathArgs,
): Promise<CompileFromPathReturnType>;

type FuncCall = {
/** Function call you want to compile. Example: someFunc("someArg") */
Expand All @@ -65,14 +71,20 @@ type FuncCall = {
data?: Record<string, unknown> | undefined;
};

export type CompileFuncCallFromStringArgs = CommonArgs & CodeString & FuncCall;
export type CompileFuncCallFromStringReturnType = Required<CompilationResult>;

/** Compile aqua function call from a string */
export declare function compileAquaCallFromString(
args: CommonArgs & CodeString & FuncCall,
): Promise<Required<CompilationResult>>;
args: CompileFuncCallFromStringArgs,
): Promise<CompileFuncCallFromStringReturnType>;

export type CompileFuncCallFromPathArgs = CommonArgs & FilePath & FuncCall;
export type CompileFuncCallFromPathReturnType = Required<CompilationResult>;

/** Compile aqua function call from a file */
export declare function compileAquaCallFromPath(
args: CommonArgs & FilePath & FuncCall,
): Promise<Required<CompilationResult>>;
args: CompileFuncCallFromPathArgs,
): Promise<CompileFuncCallFromPathReturnType>;

export {};