# @echelon-framework/functions-core

Built-in pure functions for computed datasources in Echelon framework.

Part of the **Echelon Framework** — Angular-based, config-driven dashboard & low-code platform.

## Installation

```bash
npm install @echelon-framework/functions-core
```

## Usage

```ts
import { coreFunctions } from '@echelon-framework/functions-core';

provideEchelon({
  functions: [...coreFunctions, ...myCustomFunctions],
});
```

## Available functions

| Function    | Inputs               | Output | Description               |
| ----------- | -------------------- | ------ | ------------------------- |
| `count`     | array                | number | Array length              |
| `filter`    | array, predicate     | array  | Filter items              |
| `search`    | array, query, fields | array  | Text search across fields |
| `paginate`  | array, page, size    | array  | Slice for pagination      |
| `pickById`  | array, id, idField   | object | Find by primary key       |
| `mergeRow`  | array, item, idField | array  | Upsert item in array      |
| `formatPln` | number               | string | Format as PLN currency    |
| `addLp`     | array                | array  | Add sequential `lp` field |
| `sum`       | array, field         | number | Sum numeric field         |

## Custom functions

```ts
import { PureFunction } from '@echelon-framework/runtime';

@PureFunction({
  description: 'Compute dealer rate from spot + margin',
  inputs: [
    { name: 'spot', type: '{bid,ask}' },
    { name: 'marginPips', type: 'number' },
  ],
  output: { type: 'number' },
})
export class ComputeDealerRate {
  static fn(spot: { bid: number; ask: number }, marginPips: number): number {
    return +(spot.ask + marginPips * 0.0001).toFixed(5);
  }
}
```

## License

BUSL-1.1
