Skip to content

Commit

Permalink
fix: undo type undo-type-update
Browse files Browse the repository at this point in the history
An update to the TS definition in
jsonata-js#633 is causing issues in
transformers-jsonata since we are using both 1.x and 2.x versions in
there and types do not align anymore. Reverting the change for now. We
overwrite the type of the NodeExpr in mappings anyway, and so this
should be fine for now.
  • Loading branch information
nddery committed Mar 6, 2024
1 parent 13bc01f commit f566d0a
Showing 1 changed file with 51 additions and 41 deletions.
92 changes: 51 additions & 41 deletions jsonata.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,52 +2,62 @@
// Project: https://github.com/jsonata-js/jsonata
// Definitions by: Nick <https://github.com/nick121212> and Michael M. Tiller <https://github.com/xogeny>

declare function jsonata(str: string, options?: jsonata.JsonataOptions): jsonata.Expression;
declare function jsonata(
str: string,
options?: jsonata.JsonataOptions
): jsonata.Expression;
declare namespace jsonata {
interface JsonataOptions {
recover?: boolean;
RegexEngine?: RegExp;
}

interface JsonataOptions {
recover?: boolean,
RegexEngine?: RegExp
}
interface ExprNode {
type: string;
value?: any;
position?: number;
arguments?: ExprNode[];
name?: string;
procedure?: ExprNode;
steps?: ExprNode[];
expressions?: ExprNode[];
stages?: ExprNode[];
lhs?: ExprNode;
rhs?: ExprNode;
}

interface ExprNode {
type: string;
value?: any;
position?: number;
arguments?: ExprNode[];
name?: string;
procedure?: ExprNode;
steps?: ExprNode[];
expressions?: ExprNode[];
stages?: ExprNode[];
lhs?: ExprNode[];
rhs?: ExprNode;
}
interface JsonataError extends Error {
code: string;
position: number;
token: string;
}

interface JsonataError extends Error {
code: string;
position: number;
token: string;
}
interface Environment {
bind(name: string, value: any): void;
lookup(name: string): any;
readonly timestamp: Date;
readonly async: boolean;
}

interface Environment {
bind(name: string, value: any): void;
lookup(name: string): any;
readonly timestamp: Date;
readonly async: boolean;
}

interface Focus {
readonly environment: Environment;
readonly input: any;
}
interface Expression {
evaluate(input: any, bindings?: Record<string, any>): Promise<any>;
evaluate(input: any, bindings: Record<string, any> | undefined, callback: (err: JsonataError, resp: any) => void): void;
assign(name: string, value: any): void;
registerFunction(name: string, implementation: (this: Focus, ...args: any[]) => any, signature?: string): void;
ast(): ExprNode;
}
interface Focus {
readonly environment: Environment;
readonly input: any;
}
interface Expression {
evaluate(input: any, bindings?: Record<string, any>): Promise<any>;
evaluate(
input: any,
bindings: Record<string, any> | undefined,
callback: (err: JsonataError, resp: any) => void
): void;
assign(name: string, value: any): void;
registerFunction(
name: string,
implementation: (this: Focus, ...args: any[]) => any,
signature?: string
): void;
ast(): ExprNode;
}
}

export = jsonata;

0 comments on commit f566d0a

Please sign in to comment.