Skip to content
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
34 changes: 27 additions & 7 deletions jsonata.d.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,40 @@
// Type definitions for jsonata 1.4
// Type definitions for jsonata 1.7
// 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): jsonata.Expression;
declare namespace jsonata {

interface ExprNode {
type: string;
value: any;
position: number;
type: string;
value: any;
position: number;
}

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 Focus {
readonly environment: Environment;
readonly input: any;
}
interface Expression {
evaluate(input: any, bindings?: { [name: string]: any }, callback?: (err: Error, resp: any) => void): any;
evaluate(input: any, bindings?: Record<string, any>): 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, f: Function, signature?: string): void;
registerFunction(name: string, implementation: (this: Focus, ...args: any[]) => any, signature?: string): void;
ast(): ExprNode;
}
}

export = jsonata;
export = jsonata;