mirror of
https://github.com/lowdefy/lowdefy.git
synced 2025-03-19 15:01:06 +08:00
Merge pull request #1122 from lowdefy/build-docs
Change dependancy from js-yaml to yaml.
This commit is contained in:
commit
d72329d614
15
.pnp.cjs
generated
15
.pnp.cjs
generated
@ -3102,9 +3102,9 @@ function $$SETUP_STATE(hydrateRuntimeState, basePath) {
|
||||
["@swc/jest", "virtual:babee6e81435a5d101529cd67f2c6b175f4db37a4ab0b58df15adf73dd11be8917ac14caf44ab4e6882a92c61661055072365b349016e85173e049f006fc2305#npm:0.2.17"],
|
||||
["ajv", "npm:8.9.0"],
|
||||
["jest", "virtual:babee6e81435a5d101529cd67f2c6b175f4db37a4ab0b58df15adf73dd11be8917ac14caf44ab4e6882a92c61661055072365b349016e85173e049f006fc2305#npm:27.5.1"],
|
||||
["js-yaml", "npm:4.1.0"],
|
||||
["json5", "npm:2.2.0"],
|
||||
["uuid", "npm:8.3.2"],
|
||||
["yaml", "npm:2.0.0-10"],
|
||||
["yargs", "npm:17.3.1"]
|
||||
],
|
||||
"linkType": "SOFT",
|
||||
@ -3501,7 +3501,7 @@ function $$SETUP_STATE(hydrateRuntimeState, basePath) {
|
||||
["@swc/core", "npm:1.2.135"],
|
||||
["@swc/jest", "virtual:babee6e81435a5d101529cd67f2c6b175f4db37a4ab0b58df15adf73dd11be8917ac14caf44ab4e6882a92c61661055072365b349016e85173e049f006fc2305#npm:0.2.17"],
|
||||
["jest", "virtual:babee6e81435a5d101529cd67f2c6b175f4db37a4ab0b58df15adf73dd11be8917ac14caf44ab4e6882a92c61661055072365b349016e85173e049f006fc2305#npm:27.5.1"],
|
||||
["js-yaml", "npm:4.1.0"]
|
||||
["yaml", "npm:2.0.0-10"]
|
||||
],
|
||||
"linkType": "SOFT",
|
||||
}]
|
||||
@ -11952,9 +11952,9 @@ function $$SETUP_STATE(hydrateRuntimeState, basePath) {
|
||||
["decompress", "npm:4.2.1"],
|
||||
["decompress-targz", "npm:4.1.1"],
|
||||
["jest", "virtual:babee6e81435a5d101529cd67f2c6b175f4db37a4ab0b58df15adf73dd11be8917ac14caf44ab4e6882a92c61661055072365b349016e85173e049f006fc2305#npm:27.5.1"],
|
||||
["js-yaml", "npm:4.1.0"],
|
||||
["ora", "npm:5.4.1"],
|
||||
["uuid", "npm:8.3.2"]
|
||||
["uuid", "npm:8.3.2"],
|
||||
["yaml", "npm:2.0.0-10"]
|
||||
],
|
||||
"linkType": "SOFT",
|
||||
}]
|
||||
@ -19243,6 +19243,13 @@ function $$SETUP_STATE(hydrateRuntimeState, basePath) {
|
||||
["yaml", "npm:1.10.2"]
|
||||
],
|
||||
"linkType": "HARD",
|
||||
}],
|
||||
["npm:2.0.0-10", {
|
||||
"packageLocation": "./.yarn/cache/yaml-npm-2.0.0-10-334367b768-7a0bac2f80.zip/node_modules/yaml/",
|
||||
"packageDependencies": [
|
||||
["yaml", "npm:2.0.0-10"]
|
||||
],
|
||||
"linkType": "HARD",
|
||||
}]
|
||||
]],
|
||||
["yaml-loader", [
|
||||
|
BIN
.yarn/cache/yaml-npm-2.0.0-10-334367b768-7a0bac2f80.zip
vendored
Normal file
BIN
.yarn/cache/yaml-npm-2.0.0-10-334367b768-7a0bac2f80.zip
vendored
Normal file
Binary file not shown.
@ -50,9 +50,9 @@
|
||||
"@lowdefy/node-utils": "4.0.0-alpha.6",
|
||||
"@lowdefy/nunjucks": "4.0.0-alpha.6",
|
||||
"ajv": "8.9.0",
|
||||
"js-yaml": "4.1.0",
|
||||
"json5": "2.2.0",
|
||||
"uuid": "8.3.2",
|
||||
"yaml": "2.0.0-10",
|
||||
"yargs": "17.3.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
|
@ -17,7 +17,7 @@
|
||||
import { type } from '@lowdefy/helpers';
|
||||
import { getFileExtension, getFileSubExtension } from '@lowdefy/node-utils';
|
||||
import JSON5 from 'json5';
|
||||
import YAML from 'js-yaml';
|
||||
import YAML from 'yaml';
|
||||
|
||||
import parseNunjucks from './parseNunjucks.js';
|
||||
|
||||
@ -31,7 +31,7 @@ function parseRefContent({ content, refDef }) {
|
||||
}
|
||||
|
||||
if (ext === 'yaml' || ext === 'yml') {
|
||||
return YAML.load(content);
|
||||
return YAML.parse(content);
|
||||
}
|
||||
if (ext === 'json') {
|
||||
return JSON5.parse(content);
|
||||
|
@ -97,6 +97,7 @@ async function build(options) {
|
||||
await buildIcons({ components, context });
|
||||
await buildStyles({ components, context });
|
||||
await cleanBuildDirectory({ context });
|
||||
await writeActionImports({ components, context });
|
||||
await writeApp({ components, context });
|
||||
await writeConnections({ components, context });
|
||||
await writeRequests({ components, context });
|
||||
|
@ -47,9 +47,9 @@
|
||||
"commander": "9.0.0",
|
||||
"decompress": "4.2.1",
|
||||
"decompress-targz": "4.1.1",
|
||||
"js-yaml": "4.1.0",
|
||||
"ora": "5.4.1",
|
||||
"uuid": "8.3.2"
|
||||
"uuid": "8.3.2",
|
||||
"yaml": "2.0.0-10"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@jest/globals": "27.5.1",
|
||||
|
@ -17,7 +17,7 @@
|
||||
import path from 'path';
|
||||
import { get, type } from '@lowdefy/helpers';
|
||||
import { readFile } from '@lowdefy/node-utils';
|
||||
import YAML from 'js-yaml';
|
||||
import YAML from 'yaml';
|
||||
|
||||
async function getLowdefyYaml({ configDirectory, command }) {
|
||||
let lowdefyYaml = await readFile(path.resolve(configDirectory, 'lowdefy.yaml'));
|
||||
@ -34,7 +34,7 @@ async function getLowdefyYaml({ configDirectory, command }) {
|
||||
}
|
||||
let lowdefy;
|
||||
try {
|
||||
lowdefy = YAML.load(lowdefyYaml);
|
||||
lowdefy = YAML.parse(lowdefyYaml);
|
||||
} catch (error) {
|
||||
throw new Error(`Could not parse "lowdefy.yaml" file. Received error ${error.message}.`);
|
||||
}
|
||||
|
@ -94,7 +94,7 @@ _ref:
|
||||
events:
|
||||
onInitAsync:
|
||||
- id: set_intercom_user
|
||||
type: JsAction
|
||||
type: JsAction # TODO:
|
||||
params:
|
||||
name: setIntercomUser
|
||||
blocks:
|
||||
@ -203,7 +203,7 @@ _ref:
|
||||
type: Request
|
||||
params: search_products
|
||||
- id: apply_highlight # apply the highlight transformation to the request data.
|
||||
type: JsAction
|
||||
type: JsAction # TODO:
|
||||
params:
|
||||
name: highlightText
|
||||
args:
|
||||
@ -271,7 +271,7 @@ _ref:
|
||||
events:
|
||||
onClick:
|
||||
- id: loop_requests
|
||||
type: JsAction
|
||||
type: JsAction # TODO:
|
||||
params:
|
||||
name: loopRequests
|
||||
args:
|
||||
|
@ -110,7 +110,7 @@ _ref:
|
||||
events:
|
||||
onEnter:
|
||||
- id: get_todos
|
||||
type: JsAction
|
||||
type: JsAction # TODO:
|
||||
params:
|
||||
name: fetchTodos # Trigger the custom JavaScript action.
|
||||
args:
|
||||
|
@ -47,9 +47,9 @@ _ref:
|
||||
title: Generate a CSV
|
||||
color: '#1890ff'
|
||||
events:
|
||||
onClick:
|
||||
- id: generate_csv
|
||||
type: JsAction
|
||||
onClick: []
|
||||
{# - id: generate_csv
|
||||
type: JsAction # TODO:
|
||||
params:
|
||||
name: csvMake
|
||||
args:
|
||||
@ -77,7 +77,7 @@ _ref:
|
||||
- - Username # an array of field definitions
|
||||
- Identifier
|
||||
- FirstName
|
||||
- LastName
|
||||
- LastName #}
|
||||
|
||||
- id: md2
|
||||
type: MarkdownWithCode
|
||||
@ -211,7 +211,7 @@ _ref:
|
||||
events:
|
||||
onClick:
|
||||
- id: generate_csv
|
||||
type: JsAction
|
||||
type: JsAction # TODO:
|
||||
params:
|
||||
name: csvMake
|
||||
args:
|
||||
|
@ -90,13 +90,13 @@ _ref:
|
||||
qty: 2
|
||||
price: 60.667
|
||||
code: X12-49A
|
||||
onClick:
|
||||
- id: generate_pdf
|
||||
type: JsAction
|
||||
onClick: []
|
||||
{# - id: generate_pdf
|
||||
type: JsAction # TODO:
|
||||
params:
|
||||
name: pdfMake
|
||||
args:
|
||||
_ref: howto/generatePdf/inv_template.yaml
|
||||
_ref: howto/generatePdf/inv_template.yaml #}
|
||||
|
||||
- id: md2
|
||||
type: MarkdownWithCode
|
||||
@ -256,7 +256,7 @@ _ref:
|
||||
events:
|
||||
onClick:
|
||||
- id: make_pdf
|
||||
type: JsAction
|
||||
type: JsAction # TODO:
|
||||
params:
|
||||
name: pdfMake
|
||||
args:
|
||||
@ -279,9 +279,9 @@ _ref:
|
||||
title: Download PDF
|
||||
icon: AiOutlinedDownload
|
||||
events:
|
||||
onClick:
|
||||
- id: make_pdf
|
||||
type: JsAction
|
||||
onClick: []
|
||||
{# - id: make_pdf
|
||||
type: JsAction # TODO:
|
||||
params:
|
||||
name: pdfMake
|
||||
args:
|
||||
@ -291,7 +291,7 @@ _ref:
|
||||
fontSize: 10
|
||||
content:
|
||||
- text: This pdf has been generated with Lowdefy and pdfMake.
|
||||
bold: true
|
||||
bold: true #}
|
||||
- id: md4
|
||||
type: MarkdownWithCode
|
||||
properties:
|
||||
@ -370,7 +370,7 @@ _ref:
|
||||
events:
|
||||
onClick:
|
||||
- id: make_pdf
|
||||
type: JsAction
|
||||
type: JsAction # TODO:
|
||||
params:
|
||||
name: pdfMake
|
||||
args:
|
||||
@ -635,13 +635,13 @@ _ref:
|
||||
qty: 2
|
||||
price: 60.667
|
||||
code: X12-49A
|
||||
onClick:
|
||||
- id: generate_pdf
|
||||
type: JsAction
|
||||
onClick: []
|
||||
{# - id: generate_pdf
|
||||
type: JsAction # TODO:
|
||||
params:
|
||||
name: pdfMake
|
||||
args:
|
||||
_ref: howto/generatePdf/inv_template.yaml
|
||||
_ref: howto/generatePdf/inv_template.yaml #}
|
||||
- id: md5
|
||||
type: MarkdownWithCode
|
||||
properties:
|
||||
|
@ -23,36 +23,37 @@ pages:
|
||||
color: '#1890ff'
|
||||
events:
|
||||
onClick:
|
||||
- id: generate_csv
|
||||
type: JsAction
|
||||
params:
|
||||
name: csvMake
|
||||
args:
|
||||
- profiles.csv # csv filename
|
||||
- - Username: booker12 # an array of data, usually a reference
|
||||
Identifier: 9012
|
||||
FirstName: Rachel
|
||||
LastName: Booker
|
||||
- Username: grey07
|
||||
Identifier: 2070
|
||||
FirstName: Laura
|
||||
LastName: Grey
|
||||
- Username: johnson81
|
||||
Identifier: 4081
|
||||
FirstName: Craig
|
||||
LastName: Johnson
|
||||
- Username: jenkins46
|
||||
Identifier: 9346
|
||||
FirstName: Mary
|
||||
LastName: Jenkins
|
||||
- Username: smith79
|
||||
Identifier: 5079
|
||||
FirstName: Jamie
|
||||
LastName: Smith
|
||||
- - Username # an array of field definitions
|
||||
- Identifier
|
||||
- FirstName
|
||||
- LastName
|
||||
[]
|
||||
# - id: generate_csv
|
||||
# type: JsAction # TODO:
|
||||
# params:
|
||||
# name: csvMake
|
||||
# args:
|
||||
# - profiles.csv # csv filename
|
||||
# - - Username: booker12 # an array of data, usually a reference
|
||||
# Identifier: 9012
|
||||
# FirstName: Rachel
|
||||
# LastName: Booker
|
||||
# - Username: grey07
|
||||
# Identifier: 2070
|
||||
# FirstName: Laura
|
||||
# LastName: Grey
|
||||
# - Username: johnson81
|
||||
# Identifier: 4081
|
||||
# FirstName: Craig
|
||||
# LastName: Johnson
|
||||
# - Username: jenkins46
|
||||
# Identifier: 9346
|
||||
# FirstName: Mary
|
||||
# LastName: Jenkins
|
||||
# - Username: smith79
|
||||
# Identifier: 5079
|
||||
# FirstName: Jamie
|
||||
# LastName: Smith
|
||||
# - - Username # an array of field definitions
|
||||
# - Identifier
|
||||
# - FirstName
|
||||
# - LastName
|
||||
footer:
|
||||
blocks:
|
||||
- id: footer
|
||||
|
@ -99,13 +99,14 @@ pages:
|
||||
color: '#1890ff'
|
||||
events:
|
||||
onClick:
|
||||
- id: make_pdf
|
||||
type: JsAction
|
||||
params:
|
||||
name: pdfMake
|
||||
args:
|
||||
_ref:
|
||||
path: inv_template.yaml
|
||||
[]
|
||||
# - id: make_pdf
|
||||
# type: JsAction # TODO:
|
||||
# params:
|
||||
# name: pdfMake
|
||||
# args:
|
||||
# _ref:
|
||||
# path: inv_template.yaml
|
||||
footer:
|
||||
blocks:
|
||||
- id: footer
|
||||
|
@ -97,7 +97,7 @@ _ref:
|
||||
events:
|
||||
onClick:
|
||||
- id: get_normalized_eigenvector
|
||||
type: JsAction
|
||||
type: JsAction # TODO:
|
||||
params:
|
||||
name: getNormalizedEigenvector
|
||||
args:
|
||||
|
@ -25,22 +25,36 @@ _ref:
|
||||
- name: parse
|
||||
types: |
|
||||
```
|
||||
(value: string): any
|
||||
({on: string, options?: object}): object
|
||||
([on: string, options?: object]): object
|
||||
```
|
||||
description: |
|
||||
The `_yaml.parse` method parses a YAML string into an object.
|
||||
arguments: |
|
||||
###### string
|
||||
The string to parse.
|
||||
###### object
|
||||
- `on: string`: String to parse.
|
||||
- `options?: object`: Optional settings. See the [YAML.parse: method here](https://eemeli.org/yaml/#parse-options) for supported settings.
|
||||
|
||||
examples: |
|
||||
###### Parse a YAML string:
|
||||
```yaml
|
||||
_yaml.parse: |
|
||||
key: Value
|
||||
boolean: true
|
||||
array:
|
||||
- 1
|
||||
- 2
|
||||
_yaml.parse:
|
||||
on: |
|
||||
key: Value
|
||||
boolean: true
|
||||
array:
|
||||
- 1
|
||||
- 2
|
||||
```
|
||||
or:
|
||||
```yaml
|
||||
_yaml.parse:
|
||||
- |
|
||||
key: Value
|
||||
boolean: true
|
||||
array:
|
||||
- 1
|
||||
- 2
|
||||
```
|
||||
Returns:
|
||||
```
|
||||
@ -61,17 +75,27 @@ _ref:
|
||||
arguments: |
|
||||
###### object
|
||||
- `on: any`: The object to stringify.
|
||||
- `options: object`: Optional settings. See the [YAML.dump method here](https://www.npmjs.com/package/js-yaml) for supported settings.
|
||||
- `options?: object`: Optional settings. See the [YAML.stringify: method here](https://eemeli.org/yaml/#tostring-options) for supported settings.
|
||||
|
||||
examples: |
|
||||
###### Stringify an object as YAML:
|
||||
```yaml
|
||||
_yaml.stringify:
|
||||
key: Value
|
||||
boolean: true
|
||||
array:
|
||||
- 1
|
||||
- 2
|
||||
on:
|
||||
key: Value
|
||||
boolean: true
|
||||
array:
|
||||
- 1
|
||||
- 2
|
||||
```
|
||||
or:
|
||||
```yaml
|
||||
_yaml.stringify:
|
||||
- key: Value
|
||||
boolean: true
|
||||
array:
|
||||
- 1
|
||||
- 2
|
||||
```
|
||||
Returns (as a string):
|
||||
```text
|
||||
|
@ -75,10 +75,10 @@ events:
|
||||
_var: init_state_values
|
||||
|
||||
onEnterAsync:
|
||||
- id: connect_docsearch
|
||||
type: JsAction
|
||||
{# - id: connect_docsearch
|
||||
type: JsAction # TODO:
|
||||
params:
|
||||
name: connectDocsearch
|
||||
name: connectDocsearch #}
|
||||
- id: post_telemetry
|
||||
type: Request
|
||||
messages:
|
||||
|
6
packages/docs/templates/blog.yaml.njk
vendored
6
packages/docs/templates/blog.yaml.njk
vendored
@ -44,10 +44,10 @@ events:
|
||||
type: string
|
||||
length: 16
|
||||
onEnterAsync:
|
||||
- id: connect_docsearch
|
||||
type: JsAction
|
||||
{# - id: connect_docsearch
|
||||
type: JsAction # TODO:
|
||||
params:
|
||||
name: connectDocsearch
|
||||
name: connectDocsearch #}
|
||||
- id: post_telemetry
|
||||
type: Request
|
||||
messages:
|
||||
|
8
packages/docs/templates/general.yaml.njk
vendored
8
packages/docs/templates/general.yaml.njk
vendored
@ -44,10 +44,10 @@ events:
|
||||
type: string
|
||||
length: 16
|
||||
onEnterAsync:
|
||||
- id: connect_docsearch
|
||||
type: JsAction
|
||||
{# - id: connect_docsearch
|
||||
type: JsAction # TODO:
|
||||
params:
|
||||
name: connectDocsearch
|
||||
name: connectDocsearch #}
|
||||
- id: post_telemetry
|
||||
type: Request
|
||||
messages:
|
||||
@ -121,4 +121,4 @@ areas:
|
||||
layout:
|
||||
contentGutter: 16
|
||||
blocks:
|
||||
_var: content
|
||||
_var: content
|
||||
|
@ -45,7 +45,7 @@
|
||||
"dependencies": {
|
||||
"@lowdefy/helpers": "4.0.0-alpha.6",
|
||||
"@lowdefy/operators": "4.0.0-alpha.6",
|
||||
"js-yaml": "4.1.0"
|
||||
"yaml": "2.0.0-10"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@swc/cli": "0.1.55",
|
||||
|
@ -14,28 +14,31 @@
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
import YAML from 'js-yaml';
|
||||
import { serializer } from '@lowdefy/helpers';
|
||||
import YAML from 'yaml';
|
||||
import { serializer, type } from '@lowdefy/helpers';
|
||||
|
||||
import { runClass } from '@lowdefy/operators';
|
||||
|
||||
function parse(input) {
|
||||
// TODO: consider adding replacer and reviver args supported by yaml package.
|
||||
function parse(input, options) {
|
||||
if (input === 'undefined') return undefined;
|
||||
const loaded = YAML.load(input);
|
||||
if (!type.isString(input)) {
|
||||
throw new Error('requires a string type to parse.');
|
||||
}
|
||||
const loaded = YAML.parse(input, options);
|
||||
return serializer.deserialize(loaded);
|
||||
}
|
||||
|
||||
function stringify(input, options) {
|
||||
return YAML.dump(serializer.serialize(input, { isoStringDates: true }), {
|
||||
sortKeys: true,
|
||||
...options,
|
||||
});
|
||||
if (input === undefined) return '';
|
||||
// TODO: option sortKeys: true, sort keys was supported by js-yaml and not by yaml.
|
||||
return YAML.stringify(serializer.serialize(input, { isoStringDates: true }), options);
|
||||
}
|
||||
|
||||
const functions = { parse, stringify };
|
||||
const meta = {
|
||||
stringify: { namedArgs: ['on', 'options'], validTypes: ['object', 'array'] },
|
||||
parse: { singleArg: true, validTypes: ['string'] },
|
||||
parse: { namedArgs: ['on', 'options'], validTypes: ['object', 'array'] },
|
||||
};
|
||||
|
||||
function _yaml({ params, location, methodName }) {
|
||||
|
@ -17,61 +17,62 @@
|
||||
import yaml from './yaml.js';
|
||||
|
||||
test('_yaml.parse string unquoted', () => {
|
||||
expect(yaml({ params: 'firstName', location: 'locationId', methodName: 'parse' })).toEqual(
|
||||
expect(yaml({ params: ['firstName'], location: 'locationId', methodName: 'parse' })).toEqual(
|
||||
'firstName'
|
||||
);
|
||||
});
|
||||
|
||||
test('_yaml.parse string quoted', () => {
|
||||
expect(yaml({ params: '"firstName"', location: 'locationId', methodName: 'parse' })).toEqual(
|
||||
expect(yaml({ params: ['"firstName"'], location: 'locationId', methodName: 'parse' })).toEqual(
|
||||
'firstName'
|
||||
);
|
||||
});
|
||||
|
||||
test('_yaml.parse number', () => {
|
||||
expect(yaml({ params: '1', location: 'locationId', methodName: 'parse' })).toEqual(1);
|
||||
expect(yaml({ params: ['1'], location: 'locationId', methodName: 'parse' })).toEqual(1);
|
||||
});
|
||||
|
||||
test('_yaml.parse boolean true', () => {
|
||||
expect(yaml({ params: 'true', location: 'locationId', methodName: 'parse' })).toEqual(true);
|
||||
expect(yaml({ params: ['true'], location: 'locationId', methodName: 'parse' })).toEqual(true);
|
||||
});
|
||||
|
||||
test('_yaml.parse boolean false', () => {
|
||||
expect(yaml({ params: 'false', location: 'locationId', methodName: 'parse' })).toEqual(false);
|
||||
expect(yaml({ params: ['false'], location: 'locationId', methodName: 'parse' })).toEqual(false);
|
||||
});
|
||||
|
||||
test('_yaml.parse null', () => {
|
||||
expect(yaml({ params: 'null', location: 'locationId', methodName: 'parse' })).toEqual(null);
|
||||
expect(yaml({ params: ['null'], location: 'locationId', methodName: 'parse' })).toEqual(null);
|
||||
});
|
||||
|
||||
test('_yaml.parse undefined string', () => {
|
||||
expect(yaml({ params: 'undefined', location: 'locationId', methodName: 'parse' })).toEqual(
|
||||
expect(yaml({ params: ['undefined'], location: 'locationId', methodName: 'parse' })).toEqual(
|
||||
undefined
|
||||
);
|
||||
});
|
||||
|
||||
test('_yaml.parse object not allowed', () => {
|
||||
expect(() => yaml({ params: { a: 'b' }, location: 'locationId', methodName: 'parse' }))
|
||||
.toThrowErrorMatchingInlineSnapshot(`
|
||||
"Operator Error: _yaml.parse accepts one of the following types: string.
|
||||
Received: {\\"_yaml.parse\\":{\\"a\\":\\"b\\"}} at locationId."
|
||||
`);
|
||||
expect(() =>
|
||||
yaml({ params: [{ a: 'b' }], location: 'locationId', methodName: 'parse' })
|
||||
).toThrowErrorMatchingInlineSnapshot(
|
||||
`"Operator Error: _yaml.parse - requires a string type to parse. Received: {\\"_yaml.parse\\":[{\\"a\\":\\"b\\"}]} at locationId."`
|
||||
);
|
||||
});
|
||||
|
||||
test('_yaml.parse date not supported', () => {
|
||||
expect(() => yaml({ params: new Date(0), location: 'locationId', methodName: 'parse' }))
|
||||
.toThrowErrorMatchingInlineSnapshot(`
|
||||
"Operator Error: _yaml.parse accepts one of the following types: string.
|
||||
Received: {\\"_yaml.parse\\":\\"1970-01-01T00:00:00.000Z\\"} at locationId."
|
||||
`);
|
||||
expect(() =>
|
||||
yaml({ params: [new Date(0)], location: 'locationId', methodName: 'parse' })
|
||||
).toThrowErrorMatchingInlineSnapshot(
|
||||
`"Operator Error: _yaml.parse - requires a string type to parse. Received: {\\"_yaml.parse\\":[\\"1970-01-01T00:00:00.000Z\\"]} at locationId."`
|
||||
);
|
||||
});
|
||||
|
||||
test('_yaml.parse array', () => {
|
||||
expect(
|
||||
yaml({
|
||||
params: `- a: a1
|
||||
params: [
|
||||
`- a: a1
|
||||
- a: a2`,
|
||||
|
||||
],
|
||||
location: 'locationId',
|
||||
methodName: 'parse',
|
||||
})
|
||||
@ -81,8 +82,10 @@ test('_yaml.parse array', () => {
|
||||
test('_yaml.parse date array', () => {
|
||||
expect(
|
||||
yaml({
|
||||
params: `- _date: "1970-01-01T00:00:00.000Z"
|
||||
params: [
|
||||
`- _date: "1970-01-01T00:00:00.000Z"
|
||||
- _date: "1970-01-01T00:00:00.001Z"`,
|
||||
],
|
||||
location: 'locationId',
|
||||
methodName: 'parse',
|
||||
})
|
||||
@ -92,7 +95,7 @@ test('_yaml.parse date array', () => {
|
||||
test('_yaml.parse date as object', () => {
|
||||
expect(
|
||||
yaml({
|
||||
params: `_date: "1970-01-01T00:00:00.000Z"`,
|
||||
params: [`_date: "1970-01-01T00:00:00.000Z"`],
|
||||
location: 'locationId',
|
||||
methodName: 'parse',
|
||||
})
|
||||
@ -102,8 +105,10 @@ test('_yaml.parse date as object', () => {
|
||||
test('_yaml.parse date object', () => {
|
||||
expect(
|
||||
yaml({
|
||||
params: `a:
|
||||
params: [
|
||||
`a:
|
||||
_date: "1970-01-01T00:00:00.000Z"`,
|
||||
],
|
||||
location: 'locationId',
|
||||
methodName: 'parse',
|
||||
})
|
||||
@ -111,11 +116,11 @@ test('_yaml.parse date object', () => {
|
||||
});
|
||||
|
||||
test('_yaml.parse non string', () => {
|
||||
expect(() => yaml({ params: 123, location: 'locationId', methodName: 'parse' }))
|
||||
.toThrowErrorMatchingInlineSnapshot(`
|
||||
"Operator Error: _yaml.parse accepts one of the following types: string.
|
||||
Received: {\\"_yaml.parse\\":123} at locationId."
|
||||
`);
|
||||
expect(() =>
|
||||
yaml({ params: [123], location: 'locationId', methodName: 'parse' })
|
||||
).toThrowErrorMatchingInlineSnapshot(
|
||||
`"Operator Error: _yaml.parse - requires a string type to parse. Received: {\\"_yaml.parse\\":[123]} at locationId."`
|
||||
);
|
||||
});
|
||||
|
||||
test('_yaml.stringify string', () => {
|
||||
@ -159,7 +164,7 @@ test('_yaml.stringify undefined', () => {
|
||||
test('_yaml.stringify date', () => {
|
||||
expect(yaml({ params: [new Date(0)], location: 'locationId', methodName: 'stringify' }))
|
||||
.toMatchInlineSnapshot(`
|
||||
"_date: '1970-01-01T00:00:00.000Z'
|
||||
"_date: 1970-01-01T00:00:00.000Z
|
||||
"
|
||||
`);
|
||||
});
|
||||
@ -178,8 +183,8 @@ test('_yaml.stringify date array', () => {
|
||||
expect(
|
||||
yaml({ params: [[new Date(0), new Date(1)]], location: 'locationId', methodName: 'stringify' })
|
||||
).toMatchInlineSnapshot(`
|
||||
"- _date: '1970-01-01T00:00:00.000Z'
|
||||
- _date: '1970-01-01T00:00:00.001Z'
|
||||
"- _date: 1970-01-01T00:00:00.000Z
|
||||
- _date: 1970-01-01T00:00:00.001Z
|
||||
"
|
||||
`);
|
||||
});
|
||||
@ -188,55 +193,56 @@ test('_yaml.stringify date object', () => {
|
||||
expect(yaml({ params: [{ a: new Date(0) }], location: 'locationId', methodName: 'stringify' }))
|
||||
.toMatchInlineSnapshot(`
|
||||
"a:
|
||||
_date: '1970-01-01T00:00:00.000Z'
|
||||
_date: 1970-01-01T00:00:00.000Z
|
||||
"
|
||||
`);
|
||||
});
|
||||
|
||||
test('_yaml.stringify date object with options: sortKeys: false', () => {
|
||||
expect(
|
||||
yaml({
|
||||
params: [{ b: new Date(0), a: new Date(0) }, { sortKeys: false }],
|
||||
location: 'locationId',
|
||||
methodName: 'stringify',
|
||||
})
|
||||
).toMatchInlineSnapshot(`
|
||||
"b:
|
||||
_date: '1970-01-01T00:00:00.000Z'
|
||||
a:
|
||||
_date: '1970-01-01T00:00:00.000Z'
|
||||
"
|
||||
`);
|
||||
});
|
||||
// TODO: consider sortKeys implementation.
|
||||
// test('_yaml.stringify date object with options: sortKeys: false', () => {
|
||||
// expect(
|
||||
// yaml({
|
||||
// params: [{ b: new Date(0), a: new Date(0) }, { sortKeys: false }],
|
||||
// location: 'locationId',
|
||||
// methodName: 'stringify',
|
||||
// })
|
||||
// ).toMatchInlineSnapshot(`
|
||||
// "b:
|
||||
// _date: 1970-01-01T00:00:00.000Z
|
||||
// a:
|
||||
// _date: 1970-01-01T00:00:00.000Z
|
||||
// "
|
||||
// `);
|
||||
// });
|
||||
|
||||
test('_yaml.stringify as object with options: sortKeys: false', () => {
|
||||
expect(
|
||||
yaml({
|
||||
params: { on: { b: new Date(0), a: new Date(0) }, options: { sortKeys: false } },
|
||||
location: 'locationId',
|
||||
methodName: 'stringify',
|
||||
})
|
||||
).toMatchInlineSnapshot(`
|
||||
"b:
|
||||
_date: '1970-01-01T00:00:00.000Z'
|
||||
a:
|
||||
_date: '1970-01-01T00:00:00.000Z'
|
||||
"
|
||||
`);
|
||||
});
|
||||
// test('_yaml.stringify as object with options: sortKeys: false', () => {
|
||||
// expect(
|
||||
// yaml({
|
||||
// params: { on: { b: new Date(0), a: new Date(0) }, options: { sortKeys: false } },
|
||||
// location: 'locationId',
|
||||
// methodName: 'stringify',
|
||||
// })
|
||||
// ).toMatchInlineSnapshot(`
|
||||
// "b:
|
||||
// _date: 1970-01-01T00:00:00.000Z
|
||||
// a:
|
||||
// _date: 1970-01-01T00:00:00.000Z
|
||||
// "
|
||||
// `);
|
||||
// });
|
||||
|
||||
test('_yaml.stringify as object with options: sortKeys: true', () => {
|
||||
expect(
|
||||
yaml({
|
||||
params: { on: { b: new Date(0), a: new Date(0) }, options: { sortKeys: true } },
|
||||
location: 'locationId',
|
||||
methodName: 'stringify',
|
||||
})
|
||||
).toMatchInlineSnapshot(`
|
||||
"a:
|
||||
_date: '1970-01-01T00:00:00.000Z'
|
||||
b:
|
||||
_date: '1970-01-01T00:00:00.000Z'
|
||||
"
|
||||
`);
|
||||
});
|
||||
// test('_yaml.stringify as object with options: sortKeys: true', () => {
|
||||
// expect(
|
||||
// yaml({
|
||||
// params: { on: { b: new Date(0), a: new Date(0) }, options: { sortKeys: true } },
|
||||
// location: 'locationId',
|
||||
// methodName: 'stringify',
|
||||
// })
|
||||
// ).toMatchInlineSnapshot(`
|
||||
// "a:
|
||||
// _date: 1970-01-01T00:00:00.000Z
|
||||
// b:
|
||||
// _date: 1970-01-01T00:00:00.000Z
|
||||
// "
|
||||
// `);
|
||||
// });
|
||||
|
@ -17,7 +17,7 @@
|
||||
import path from 'path';
|
||||
import { type } from '@lowdefy/helpers';
|
||||
import { readFile } from '@lowdefy/node-utils';
|
||||
import YAML from 'js-yaml';
|
||||
import YAML from 'yaml';
|
||||
|
||||
async function getLowdefyVersion(context) {
|
||||
let lowdefyYaml = await readFile(path.join(context.directories.config, 'lowdefy.yaml'));
|
||||
@ -29,7 +29,7 @@ async function getLowdefyVersion(context) {
|
||||
}
|
||||
let lowdefy;
|
||||
try {
|
||||
lowdefy = YAML.load(lowdefyYaml);
|
||||
lowdefy = YAML.parse(lowdefyYaml);
|
||||
} catch (error) {
|
||||
throw new Error(`Could not parse "lowdefy.yaml" file. Received error ${error.message}.`);
|
||||
}
|
||||
|
13
yarn.lock
13
yarn.lock
@ -2245,9 +2245,9 @@ __metadata:
|
||||
"@swc/jest": 0.2.17
|
||||
ajv: 8.9.0
|
||||
jest: 27.5.1
|
||||
js-yaml: 4.1.0
|
||||
json5: 2.2.0
|
||||
uuid: 8.3.2
|
||||
yaml: 2.0.0-10
|
||||
yargs: 17.3.1
|
||||
bin:
|
||||
lowdefy-build: ./dist/scripts/run.js
|
||||
@ -2586,7 +2586,7 @@ __metadata:
|
||||
"@swc/core": 1.2.135
|
||||
"@swc/jest": 0.2.17
|
||||
jest: 27.5.1
|
||||
js-yaml: 4.1.0
|
||||
yaml: 2.0.0-10
|
||||
languageName: unknown
|
||||
linkType: soft
|
||||
|
||||
@ -9800,9 +9800,9 @@ __metadata:
|
||||
decompress: 4.2.1
|
||||
decompress-targz: 4.1.1
|
||||
jest: 27.5.1
|
||||
js-yaml: 4.1.0
|
||||
ora: 5.4.1
|
||||
uuid: 8.3.2
|
||||
yaml: 2.0.0-10
|
||||
bin:
|
||||
lowdefy: ./dist/index.js
|
||||
languageName: unknown
|
||||
@ -15860,6 +15860,13 @@ __metadata:
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"yaml@npm:2.0.0-10":
|
||||
version: 2.0.0-10
|
||||
resolution: "yaml@npm:2.0.0-10"
|
||||
checksum: 7a0bac2f80225da6008fb8ab887f43166fb2485cc3e1350185c43499c76841ea0ca9d79b40c0970e08ab3943f25ffb184e709fef7fb8b26d73987ed0452a91cc
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"yaml@npm:^1.10.0, yaml@npm:^1.7.2, yaml@npm:^1.8.3":
|
||||
version: 1.10.2
|
||||
resolution: "yaml@npm:1.10.2"
|
||||
|
Loading…
x
Reference in New Issue
Block a user