Skip to content

Commit

Permalink
Merge value formatter (#197)
Browse files Browse the repository at this point in the history
* use value formatter for calculating values

* validate $user dialect

* 2.6.75
  • Loading branch information
kbarbounakis authored Jan 22, 2025
1 parent dbd71e2 commit 3fd67df
Show file tree
Hide file tree
Showing 13 changed files with 2,161 additions and 44 deletions.
2 changes: 1 addition & 1 deletion .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"plugin:node/recommended"
],
"parserOptions": {
"ecmaVersion": 2015,
"ecmaVersion": 2018,
"sourceType": "module"
},
"env": {
Expand Down
44 changes: 44 additions & 0 deletions ValueFormatter.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import { DataModelBase } from "@themost/common";
import { AsyncSeriesEventEmitter } from '@themost/events';
import { DataContext } from "./types";
import { DataModel } from './data-model';

export declare interface ResolvingVariable {
name: string;
model?: DataModelBase;
context?: DataContext;
target?: any;
value?: any;
}


/**
* Class responsible for formatting values within a given data context.
*/
export declare class ValueFormatter {

readonly resolvingVariable: AsyncSeriesEventEmitter<ResolvingVariable>;
/**
* Creates an instance of ValueFormatter.
* @param context - The data context in which the formatter operates.
*/
constructor(context: DataContext, model?: DataModel, target?: any);

/**
* Formats the given value according to the rules defined in the data context.
* @param value - The value to be formatted.
* @returns The formatted value.
*/
format(value: unknown): any;

static register(name: string, definition: { [k: string]: (...value: any[]) => Promise<any> }): void;
}

export declare class ValueDialect {
/**
* Creates an instance of ValueDialect.
* @param context - The data context in which the dialect operates.
*/
constructor(context: DataContext, model: DataModel, target: any);

}
Loading

0 comments on commit 3fd67df

Please sign in to comment.