feat(docs): Update operator docs.

This commit is contained in:
SamTolmay 2021-01-22 16:56:22 +02:00
parent 2c9cb61c09
commit a31009cd7e
18 changed files with 500 additions and 26 deletions

View File

@ -210,12 +210,27 @@ menus:
- id: _eq
type: MenuLink
pageId: _eq
- id: _gt
type: MenuLink
pageId: _gt
- id: _gte
type: MenuLink
pageId: _gte
- id: _if
type: MenuLink
pageId: _if
- id: _if_none
type: MenuLink
pageId: _if_none
- id: _log
type: MenuLink
pageId: _log
- id: _lt
type: MenuLink
pageId: _lt
- id: _lte
type: MenuLink
pageId: _lte
- id: _not
type: MenuLink
pageId: _not
@ -225,9 +240,18 @@ menus:
- id: _product
type: MenuLink
pageId: _product
- id: _random
type: MenuLink
pageId: _random
- id: _subtract
type: MenuLink
pageId: _subtract
- id: _sum
type: MenuLink
pageId: _sum
- id: _uuid
type: MenuLink
pageId: _uuid
pages:
- _ref: introduction.yaml
@ -273,11 +297,19 @@ pages:
- _ref: operators/_and.yaml
- _ref: operators/_divide.yaml
- _ref: operators/_eq.yaml
- _ref: operators/_gt.yaml
- _ref: operators/_gte.yaml
- _ref: operators/_if.yaml
- _ref: operators/_if_none.yaml
- _ref: operators/_lt.yaml
- _ref: operators/_lte.yaml
- _ref: operators/_log.yaml
- _ref: operators/_not.yaml
- _ref: operators/_or.yaml
- _ref: operators/_product.yaml
- _ref: operators/_random.yaml
- _ref: operators/_subtract.yaml
- _ref: operators/_sum.yaml
- _ref: operators/_uuid.yaml
- _ref: 404.yaml

View File

@ -17,8 +17,10 @@ _ref:
vars:
pageId: _and
pageTitle: _and
argument_types: array[any]
return_types: boolean
types: |
```
(values: any[]): boolean
```
description: |
The `_and` operator performs a logical `and` over an array of inputs, using javascript [truthy](https://developer.mozilla.org/en-US/docs/Glossary/Truthy) and [falsy](https://developer.mozilla.org/en-US/docs/Glossary/Falsy) rules.

View File

@ -17,10 +17,12 @@ _ref:
vars:
pageId: _divide
pageTitle: _divide
argument_types: array[number]
return_types: number
types: |
```
([numerator: number, denominator: number]): number
```
description: |
The `_divide` operator divides two numbers. It takes an array of two numbers as input and returns a number. Dividing by zero will throw an error.
The `_divide` operator divides two numbers. It takes an array of two numbers as input and returns the first number divided by the second. Dividing by zero will throw an error.
arguments: |
#### array
An array of two numbers.

View File

@ -17,8 +17,10 @@ _ref:
vars:
pageId: _eq
pageTitle: _eq
argument_types: array[any]
return_types: boolean
types: |
```
([value1: any, value2: any]): boolean
```
description: |
The `_eq` operator tests if two values are equal. It takes an array of two values to test.
@ -31,8 +33,8 @@ _ref:
#### Two strings:
```yaml
_eq:
- Hello
- Hello
- "Hello"
- "Hello"
```
Returns: `true`

View File

@ -0,0 +1,63 @@
# Copyright 2020-2021 Lowdefy, Inc
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# http://www.apache.org/licenses/LICENSE-2.0
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
_ref:
path: templates/operators.yaml.njk
vars:
pageId: _gt
pageTitle: _gt
types: |
```
([value1: any, value2: any]): boolean
```
description: |
The `_gt` operator tests if the first value is greater than the second equal. It takes an array of two values to test.
> The `_gt` operator tests using the javascript greater than operator. You can find a description of the algorithm used to compare two values [here](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Less_than).
arguments: |
#### array
An array of two values to compare.
examples: |
#### Two numbers:
```yaml
_gt:
- 4
- 3
```
Returns: `true`
```yaml
_gt:
- 1
- 1
```
Returns: `false`
```yaml
_gt:
- _sum:
- 3
- 4
- 8
```
Returns: `false`
#### Two strings:
```yaml
_gt:
- "a"
- "b"
```
Returns: `false`

View File

@ -0,0 +1,63 @@
# Copyright 2020-2021 Lowdefy, Inc
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# http://www.apache.org/licenses/LICENSE-2.0
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
_ref:
path: templates/operators.yaml.njk
vars:
pageId: _gte
pageTitle: _gte
types: |
```
([value1: any, value2: any]): boolean
```
description: |
The `_gte` operator tests if the first value is greater than or equal to the second equal. It takes an array of two values to test.
> The `_gte` operator tests using the javascript greater than or equal operator. You can find a description of the algorithm used to compare two values [here](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Less_than).
arguments: |
#### array
An array of two values to compare.
examples: |
#### Two numbers:
```yaml
_gte:
- 4
- 3
```
Returns: `true`
```yaml
_gte:
- 1
- 1
```
Returns: `true`
```yaml
_gte:
- _sum:
- 3
- 4
- 8
```
Returns: `false`
#### Two strings:
```yaml
_gte:
- "a"
- "b"
```
Returns: `false`

View File

@ -17,8 +17,10 @@ _ref:
vars:
pageId: _if_none
pageTitle: _if_none
argument_types: array[any]
return_types: boolean
types: |
```
([value: any, replacement: any]): any
```
description: |
The `_if_none` operator replaces the input value with an alternative if the value is of a "none-type" like `null` or `undefined`.
arguments: |
@ -38,16 +40,16 @@ _ref:
```yaml
_if_none:
- null
- Replacement
- "Replacement"
```
Returns: `Replacement`
Returns: `"Replacement"`
```yaml
_if_none:
- _state: does_not_exist # Value in state that does not exist
- Replacement
- "Replacement"
```
Returns: `Replacement`
Returns: `"Replacement"`
```yaml
_if_none:

View File

@ -17,8 +17,10 @@ _ref:
vars:
pageId: _log
pageTitle: _log
argument_types: any
return_types: any
types: |
```
(value: any): any
```
description: |
The `_log` operator logs it input to the console, and returns the value it received. Since it returns the value it received, it can be used to debug without affecting the rest of the configuration.
arguments: |

View File

@ -0,0 +1,63 @@
# Copyright 2020-2021 Lowdefy, Inc
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# http://www.apache.org/licenses/LICENSE-2.0
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
_ref:
path: templates/operators.yaml.njk
vars:
pageId: _lt
pageTitle: _lt
types: |
```
([value1: any, value2: any]): boolean
```
description: |
The `_lt` operator tests if the first value is less than the second equal. It takes an array of two values to test.
> The `_lt` operator tests using the javascript less than operator. You can find a description of the algorithm used to compare two values [here](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Less_than).
arguments: |
#### array
An array of two values to compare.
examples: |
#### Two numbers:
```yaml
_lt:
- 4
- 3
```
Returns: `false`
```yaml
_lt:
- 1
- 1
```
Returns: `false`
```yaml
_lt:
- _sum:
- 3
- 4
- 8
```
Returns: `true`
#### Two strings:
```yaml
_lt:
- "a"
- "b"
```
Returns: `true`

View File

@ -0,0 +1,63 @@
# Copyright 2020-2021 Lowdefy, Inc
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# http://www.apache.org/licenses/LICENSE-2.0
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
_ref:
path: templates/operators.yaml.njk
vars:
pageId: _lte
pageTitle: _lte
types: |
```
([value1: any, value2: any]): boolean
```
description: |
The `_lte` operator tests if the first value is less than or equal to the second equal. It takes an array of two values to test.
> The `_lte` operator tests using the javascript less than or equal to operator. You can find a description of the algorithm used to compare two values [here](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Less_than).
arguments: |
#### array
An array of two values to compare.
examples: |
#### Two numbers:
```yaml
_lte:
- 4
- 3
```
Returns: `false`
```yaml
_lte:
- 1
- 1
```
Returns: `true`
```yaml
_lte:
- _sum:
- 3
- 4
- 8
```
Returns: `true`
#### Two strings:
```yaml
_lte:
- "a"
- "b"
```
Returns: `true`

View File

@ -17,8 +17,10 @@ _ref:
vars:
pageId: _not
pageTitle: _not
argument_types: any
return_types: boolean
types: |
```
(value: any): boolean
```
description: |
The `_not` operator returns the logical negation of the input. If the value is not a boolean, it will be converted to a boolean using javascript [truthy](https://developer.mozilla.org/en-US/docs/Glossary/Truthy) and [falsy](https://developer.mozilla.org/en-US/docs/Glossary/Falsy) rules.
arguments: |

View File

@ -17,8 +17,10 @@ _ref:
vars:
pageId: _or
pageTitle: _or
argument_types: array[any]
return_types: boolean
types: |
```
(values: any[]): boolean
```
description: |
The `_or` operator performs a logical `or` over an array of inputs, using javascript [truthy](https://developer.mozilla.org/en-US/docs/Glossary/Truthy) and [falsy](https://developer.mozilla.org/en-US/docs/Glossary/Falsy) rules.

View File

@ -17,8 +17,10 @@ _ref:
vars:
pageId: _sum
pageTitle: _sum
argument_types: array[any]
return_types: number
types: |
```
(values: any[]): number
```
description: |
The `_sum` operator takes the sum of the values given as input. If a value is not a number, the value is skipped.
arguments: |

View File

@ -0,0 +1,97 @@
# Copyright 2020-2021 Lowdefy, Inc
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# http://www.apache.org/licenses/LICENSE-2.0
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
_ref:
path: templates/operators.yaml.njk
vars:
pageId: _random
pageTitle: _random
types: |
```
(type: string): string | number
(arguments: {type: string, length?: number, max?: number, min?: number}): string | number
```
description: |
The `_random` operator returns a random string or number. The types it accepts are `string`, `integer`, or `float`.
arguments: |
#### string
The type to generate. One of `string`, `integer`, or `float`.
#### object
- `type: string` - The type to generate. One of `string`, `integer`, or `float`.
- `length: string` - The length of the string to generate if type is `string`. Default is `8`.
- `max: number` - The maximum possible number if type is one of `integer` or `float`. Default is `100` if `integer` or `1` if `float`.
- `min: number` - The minimum possible number if type is one of `integer` or `float`. Default is `0`.
examples: |
#### Random string:
```yaml
_random: string
```
Returns: Random string of length 8.
```yaml
_random:
type: string
```
Returns: Random string of length 8.
#### Random integer:
```yaml
_random: integer
```
Returns: Random integer between 0 and 100 inclusive.
```yaml
_random:
type: integer
```
Returns: Random integer between 0 and 100 inclusive.
#### Random float:
```yaml
_random: float
```
Returns: Random float between 0 and 1 inclusive.
```yaml
_random:
type: float
```
Returns: Random float between 0 and 1 inclusive.
#### Random string of length 12:
```yaml
_random:
type: string
length: 12
```
Returns: Random string of length 12.
#### Random integer between 1 and 6 (Dice roll):
```yaml
_random:
type: integer
min: 1
max: 6
```
Returns: Random integer between 1 and 6 inclusive.
#### Random float between 34.2 and 42.89:
```yaml
_random:
type: float
min: 34.2
max: 42.89
```
Returns: Random float between 34.2 and 42.89 inclusive.

View File

@ -0,0 +1,36 @@
# Copyright 2020-2021 Lowdefy, Inc
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# http://www.apache.org/licenses/LICENSE-2.0
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
_ref:
path: templates/operators.yaml.njk
vars:
pageId: _subtract
pageTitle: _subtract
types: |
```
([minuend: number, subtrahend: number]): number
```
description: |
The `_subtract` operator takes an array of two numbers as input and returns the second number subtracted from the first.
arguments: |
#### array
An array of two numbers.
examples: |
#### Subtract a number:
```yaml
_subtract:
- 12
- 4
```
Returns: `8`

View File

@ -17,8 +17,10 @@ _ref:
vars:
pageId: _product
pageTitle: _product
argument_types: array[any]
return_types: number
types: |
```
(values: any[]): number
```
description: |
The `_product` operator takes the product of the values given as input. If a value is not a number, the value is skipped.
arguments: |

View File

@ -0,0 +1,38 @@
# Copyright 2020-2021 Lowdefy, Inc
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# http://www.apache.org/licenses/LICENSE-2.0
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
_ref:
path: templates/operators.yaml.njk
vars:
pageId: _uuid
pageTitle: _uuid
types: |
```
(value: any): string
```
description: |
The `_uuid` operator a version 4 [UUID](https://en.wikipedia.org/wiki/Universally_unique_identifier). A UUID is a random identifier that can be used as an id that is, for practical purposes, unique. It looks like:
```
123e4567-e89b-12d3-a456-426614174000
```
arguments: |
#### any
The `_uuid` operator generates a UUID regardless of input.
examples: |
#### Generate a uuid:
```yaml
_uuid: true
```
Returns: A version 4 UUID.

View File

@ -27,7 +27,8 @@ _ref:
'.markdown-body':
fontSize: 14px
properties:
content: "`[ {{ argument_types }} ] => [ {{ return_types }} ]`"
content:
_var: types
- id: description
type: MarkdownWithHtml
style: