@rsql/builder
Advanced tools
Comparing version 0.0.1-next.1 to 0.0.1-next.2
{ | ||
"name": "@rsql/builder", | ||
"description": "RSQL builder", | ||
"description": "RSQL High level API", | ||
"repository": "https://github.com/piotr-oles/rsql.git", | ||
"license": "MIT", | ||
"author": "Piotr Oleś <piotrek.oles@gmail.com>", | ||
"version": "0.0.1-next.1", | ||
"version": "0.0.1-next.2", | ||
"sideEffects": false, | ||
"main": "lib/index.js", | ||
"types": "lib/index.d.ts", | ||
"main": "dist/index.js", | ||
"types": "dist/index.d.ts", | ||
"module": "dist/index.esm.js", | ||
"browser": "dist/index.umd.js", | ||
"files": [ | ||
"lib" | ||
"dist" | ||
], | ||
"keywords": [ | ||
"rsql", | ||
"fiql", | ||
"builder" | ||
], | ||
"scripts": { | ||
"clean": "rm -rf ./lib && rm -f tsconfig.tsbuildinfo", | ||
"compile": "tsc -b tsconfig.json", | ||
"dev": "yarn compile --watch --preserveWatchOutput", | ||
"clean": "rm -rf ./lib && rm -f tsconfig.tsbuildinfo && rm -rf ./dist", | ||
"compile": "tsc -b tsconfig.json && rollup -c && dts-bundle --name \"@rsql/builder\" --main lib/index.d.ts --out ../dist/index.d.ts", | ||
"build": "yarn clean && yarn compile" | ||
@@ -24,6 +30,3 @@ }, | ||
"dependencies": { | ||
"@rsql/ast": "0.0.1-next.1", | ||
"@rsql/definitions": "0.0.1-next.1", | ||
"@rsql/emitter": "0.0.1-next.1", | ||
"@rsql/parser": "0.0.1-next.1" | ||
"@rsql/ast": "0.0.1-next.2" | ||
}, | ||
@@ -38,3 +41,3 @@ "jest": { | ||
}, | ||
"gitHead": "bd96ff0ebd8826bd80799027f6755612a206512b" | ||
"gitHead": "1a690bf021f57c9201d1e02d263f170a419f5c6c" | ||
} |
@@ -1,7 +0,7 @@ | ||
<div align="center"> | ||
# @rsql/builder | ||
<h1>@rsql/builder</h1> | ||
<p>High level API for RSQL for Node.js and Browsers</p> | ||
<p>⚠️ WARNING: This package is still in development - API may break compatibility without upgrading major version! ⚠️</p> | ||
API for building RSQL for Node.js and Browsers | ||
⚠️ WARNING: This package is still in development - API may break compatibility without upgrading major version! ⚠️ | ||
[![npm](https://img.shields.io/npm/v/@rsql/builder)](https://www.npmjs.com/package/@rsql/builder) | ||
@@ -14,4 +14,2 @@ [![lerna](https://img.shields.io/badge/maintained%20with-lerna-cc00ff.svg)](https://lerna.js.org/) | ||
</div> | ||
## Installation | ||
@@ -29,28 +27,34 @@ | ||
#### `builder.comparision(selector, operator, value): ComparisionNode` | ||
#### `builder.comparison(selector, operator, value): ComparisonNode` | ||
Creates new `ComparisionNode` - can be used as a base for custom operator factory | ||
Creates new `ComparisonNode` - similar to the `createComparisonNode` from the [`@rsql/ast`](../ast) | ||
but with simpler API (no need to create `SelectorNode` or `ValueNode` and accepts numbers as values) | ||
#### `builder.<operator>(selector, value): ComparisionNode` | ||
#### `builder.<operator>(selector, value): ComparisonNode` | ||
``` | ||
builder.eq(selector, value): ComparisionNode | ||
builder.neq(selector, value): ComparisionNode | ||
builder.le(selector, value): ComparisionNode | ||
builder.lt(selector, value): ComparisionNode | ||
builder.ge(selector, value): ComparisionNode | ||
builder.gt(selector, value): ComparisionNode | ||
builder.eq(selector, value): ComparisonNode | ||
builder.neq(selector, value): ComparisonNode | ||
builder.le(selector, value): ComparisonNode | ||
builder.lt(selector, value): ComparisonNode | ||
builder.ge(selector, value): ComparisonNode | ||
builder.gt(selector, value): ComparisonNode | ||
``` | ||
Creates new `ComparisionNode` with the predefined operator for single value. | ||
Creates new `ComparisonNode` with the predefined operator for single value. | ||
#### `builder.<operator>(selector, values): ComparisionNode` | ||
#### `builder.<operator>(selector, values): ComparisonNode` | ||
``` | ||
builder.in(selector, values): ComparisionNode | ||
builder.out(selector, values): ComparisionNode | ||
builder.in(selector, values): ComparisonNode | ||
builder.out(selector, values): ComparisonNode | ||
``` | ||
Creates new `ComparisionNode` with the predefined operator for multiple values. | ||
Creates new `ComparisonNode` with the predefined operator for multiple values. | ||
#### `builder.logic(expressions, operator): LogicNode` | ||
Creates new `LogicNode` - similar to the `createLogicNode` from the [`@rsql/ast`](../ast) | ||
but with simpler API (accepts one or more expressions) | ||
#### `builder.<operator>(...expressions): LogicNode` | ||
@@ -65,25 +69,4 @@ | ||
#### `builder.emit(ast): string` | ||
Emits RSQL string from the Abstract Syntax Tree. Same as `emit` function from `@rsql/emitter` package. | ||
#### `builder.parse(rsql): ExpressionNode` | ||
Parses RSQL string and returns Abstract Syntax Tree. Same as `parse` function from `@rsql/parser` package. | ||
## Example | ||
```javascript | ||
import builder from "@rsql/builder"; | ||
function createDateRangeQuery(selector, from, to) { | ||
return builder.emit(builder.and(builder.ge(selector, from.toISOString()), builder.le(selector, to.toISOString()))); | ||
} | ||
console.log(createDateRangeQuery("createdAt", new Date("2019-07-10"), new Date("2020-04-29"))); | ||
// createdAt>=2019-07-10T00:00:00.000Z;createAt<=2020-04-29T00:00:00.000Z | ||
``` | ||
## License | ||
MIT |
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
20266
1
7
433
70
+ Added@rsql/ast@0.0.1-next.2(transitive)
- Removed@rsql/definitions@0.0.1-next.1
- Removed@rsql/emitter@0.0.1-next.1
- Removed@rsql/parser@0.0.1-next.1
- Removed@rsql/ast@0.0.1-next.1(transitive)
- Removed@rsql/definitions@0.0.1-next.1(transitive)
- Removed@rsql/emitter@0.0.1-next.1(transitive)
- Removed@rsql/parser@0.0.1-next.1(transitive)
Updated@rsql/ast@0.0.1-next.2