@bizone-ai/json-transform-utils 1.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +81 -0
- package/dist/ParseContext.d.ts +23 -0
- package/dist/ParseContext.d.ts.map +1 -0
- package/dist/ParseContext.js +69 -0
- package/dist/ParseContext.js.map +1 -0
- package/dist/__tests__/functions/functionsParser.test.d.ts +2 -0
- package/dist/__tests__/functions/functionsParser.test.d.ts.map +1 -0
- package/dist/__tests__/functions/functionsParser.test.js +787 -0
- package/dist/__tests__/functions/functionsParser.test.js.map +1 -0
- package/dist/__tests__/jsonpath/jsonpathJoin.test.d.ts +2 -0
- package/dist/__tests__/jsonpath/jsonpathJoin.test.d.ts.map +1 -0
- package/dist/__tests__/jsonpath/jsonpathJoin.test.js +27 -0
- package/dist/__tests__/jsonpath/jsonpathJoin.test.js.map +1 -0
- package/dist/__tests__/parse.test.d.ts +2 -0
- package/dist/__tests__/parse.test.d.ts.map +1 -0
- package/dist/__tests__/parse.test.js +22 -0
- package/dist/__tests__/parse.test.js.map +1 -0
- package/dist/__tests__/utils/convert.test.d.ts +2 -0
- package/dist/__tests__/utils/convert.test.d.ts.map +1 -0
- package/dist/__tests__/utils/convert.test.js +181 -0
- package/dist/__tests__/utils/convert.test.js.map +1 -0
- package/dist/functions/ContextVariablesSchemas.d.ts +3 -0
- package/dist/functions/ContextVariablesSchemas.d.ts.map +1 -0
- package/dist/functions/ContextVariablesSchemas.js +9 -0
- package/dist/functions/ContextVariablesSchemas.js.map +1 -0
- package/dist/functions/definitions.d.ts +4 -0
- package/dist/functions/definitions.d.ts.map +1 -0
- package/dist/functions/definitions.js +2090 -0
- package/dist/functions/definitions.js.map +1 -0
- package/dist/functions/examples/and.json +44 -0
- package/dist/functions/examples/at.json +156 -0
- package/dist/functions/examples/avg.json +78 -0
- package/dist/functions/examples/base64.json +368 -0
- package/dist/functions/examples/boolean.json +236 -0
- package/dist/functions/examples/coalesce.json +58 -0
- package/dist/functions/examples/concat.json +70 -0
- package/dist/functions/examples/contains.json +61 -0
- package/dist/functions/examples/csv.json +116 -0
- package/dist/functions/examples/csvparse.json +97 -0
- package/dist/functions/examples/date.json +389 -0
- package/dist/functions/examples/decimal.json +102 -0
- package/dist/functions/examples/digest.json +125 -0
- package/dist/functions/examples/distinct.json +142 -0
- package/dist/functions/examples/entries.json +88 -0
- package/dist/functions/examples/eval.json +72 -0
- package/dist/functions/examples/every.json +96 -0
- package/dist/functions/examples/filter.json +51 -0
- package/dist/functions/examples/find.json +51 -0
- package/dist/functions/examples/findindex.json +61 -0
- package/dist/functions/examples/flat.json +74 -0
- package/dist/functions/examples/flatten.json +76 -0
- package/dist/functions/examples/form.json +60 -0
- package/dist/functions/examples/formparse.json +62 -0
- package/dist/functions/examples/group.json +208 -0
- package/dist/functions/examples/if.json +294 -0
- package/dist/functions/examples/indexof.json +48 -0
- package/dist/functions/examples/is.json +512 -0
- package/dist/functions/examples/isnull.json +51 -0
- package/dist/functions/examples/join.json +221 -0
- package/dist/functions/examples/jsonparse.json +101 -0
- package/dist/functions/examples/jsonpatch.json +30 -0
- package/dist/functions/examples/jsonpath.json +62 -0
- package/dist/functions/examples/jsonpointer.json +77 -0
- package/dist/functions/examples/jwtparse.json +54 -0
- package/dist/functions/examples/length.json +202 -0
- package/dist/functions/examples/long.json +53 -0
- package/dist/functions/examples/lookup.json +223 -0
- package/dist/functions/examples/lower.json +24 -0
- package/dist/functions/examples/map.json +188 -0
- package/dist/functions/examples/match.json +62 -0
- package/dist/functions/examples/matchall.json +62 -0
- package/dist/functions/examples/math.json +1073 -0
- package/dist/functions/examples/max.json +104 -0
- package/dist/functions/examples/merge.json +173 -0
- package/dist/functions/examples/min.json +104 -0
- package/dist/functions/examples/normalize.json +142 -0
- package/dist/functions/examples/not.json +99 -0
- package/dist/functions/examples/numberformat.json +162 -0
- package/dist/functions/examples/numberparse.json +72 -0
- package/dist/functions/examples/object.json +148 -0
- package/dist/functions/examples/or.json +102 -0
- package/dist/functions/examples/pad.json +102 -0
- package/dist/functions/examples/partition.json +32 -0
- package/dist/functions/examples/range.json +188 -0
- package/dist/functions/examples/raw.json +58 -0
- package/dist/functions/examples/reduce.json +79 -0
- package/dist/functions/examples/repeat.json +59 -0
- package/dist/functions/examples/replace.json +92 -0
- package/dist/functions/examples/reverse.json +94 -0
- package/dist/functions/examples/slice.json +360 -0
- package/dist/functions/examples/some.json +96 -0
- package/dist/functions/examples/sort.json +353 -0
- package/dist/functions/examples/split.json +52 -0
- package/dist/functions/examples/string.json +95 -0
- package/dist/functions/examples/substring.json +82 -0
- package/dist/functions/examples/sum.json +108 -0
- package/dist/functions/examples/switch.json +78 -0
- package/dist/functions/examples/template.json +125 -0
- package/dist/functions/examples/test.json +82 -0
- package/dist/functions/examples/transform.json +58 -0
- package/dist/functions/examples/trim.json +44 -0
- package/dist/functions/examples/unflatten.json +97 -0
- package/dist/functions/examples/upper.json +24 -0
- package/dist/functions/examples/uriparse.json +52 -0
- package/dist/functions/examples/urldecode.json +42 -0
- package/dist/functions/examples/urlencode.json +43 -0
- package/dist/functions/examples/uuid.json +142 -0
- package/dist/functions/examples/value.json +87 -0
- package/dist/functions/examples/wrap.json +122 -0
- package/dist/functions/examples/xml.json +142 -0
- package/dist/functions/examples/xmlparse.json +161 -0
- package/dist/functions/examples/xor.json +166 -0
- package/dist/functions/examples/yaml.json +196 -0
- package/dist/functions/examples/yamlparse.json +150 -0
- package/dist/functions/examples.d.ts +4 -0
- package/dist/functions/examples.d.ts.map +1 -0
- package/dist/functions/examples.js +178 -0
- package/dist/functions/examples.js.map +1 -0
- package/dist/functions/functions.d.ts +3 -0
- package/dist/functions/functions.d.ts.map +1 -0
- package/dist/functions/functions.js +9 -0
- package/dist/functions/functions.js.map +1 -0
- package/dist/functions/functionsParser.d.ts +45 -0
- package/dist/functions/functionsParser.d.ts.map +1 -0
- package/dist/functions/functionsParser.js +207 -0
- package/dist/functions/functionsParser.js.map +1 -0
- package/dist/functions/parseDefinitions.d.ts +4 -0
- package/dist/functions/parseDefinitions.d.ts.map +1 -0
- package/dist/functions/parseDefinitions.js +56 -0
- package/dist/functions/parseDefinitions.js.map +1 -0
- package/dist/functions/types.d.ts +163 -0
- package/dist/functions/types.d.ts.map +1 -0
- package/dist/functions/types.js +93 -0
- package/dist/functions/types.js.map +1 -0
- package/dist/index.d.ts +14 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +36 -0
- package/dist/index.js.map +1 -0
- package/dist/jsonpath/jsonpathFunctions.d.ts +4 -0
- package/dist/jsonpath/jsonpathFunctions.d.ts.map +1 -0
- package/dist/jsonpath/jsonpathFunctions.js +26 -0
- package/dist/jsonpath/jsonpathFunctions.js.map +1 -0
- package/dist/jsonpath/jsonpathJoin.d.ts +3 -0
- package/dist/jsonpath/jsonpathJoin.d.ts.map +1 -0
- package/dist/jsonpath/jsonpathJoin.js +15 -0
- package/dist/jsonpath/jsonpathJoin.js.map +1 -0
- package/dist/parse.d.ts +12 -0
- package/dist/parse.d.ts.map +1 -0
- package/dist/parse.js +522 -0
- package/dist/parse.js.map +1 -0
- package/dist/transformUtils.d.ts +40 -0
- package/dist/transformUtils.d.ts.map +1 -0
- package/dist/transformUtils.js +89 -0
- package/dist/transformUtils.js.map +1 -0
- package/dist/utils/convert.d.ts +3 -0
- package/dist/utils/convert.d.ts.map +1 -0
- package/dist/utils/convert.js +163 -0
- package/dist/utils/convert.js.map +1 -0
- package/package.json +44 -0
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
[
|
|
2
|
+
{
|
|
3
|
+
"name": "primitives with duplicates",
|
|
4
|
+
"given": {
|
|
5
|
+
"input": ["a", "b", "b", "c", "b"],
|
|
6
|
+
"definition": {
|
|
7
|
+
"$$distinct": "$"
|
|
8
|
+
}
|
|
9
|
+
},
|
|
10
|
+
"expect": {
|
|
11
|
+
"equal": ["a", "b", "c"]
|
|
12
|
+
}
|
|
13
|
+
},
|
|
14
|
+
{
|
|
15
|
+
"name": "mixed primitives with duplicates",
|
|
16
|
+
"given": {
|
|
17
|
+
"input": ["a", 1, false, "b", "c", "b", 1, false, false],
|
|
18
|
+
"definition": {
|
|
19
|
+
"$$distinct": "$"
|
|
20
|
+
}
|
|
21
|
+
},
|
|
22
|
+
"expect": {
|
|
23
|
+
"equal": ["a", 1, false, "b", "c"]
|
|
24
|
+
}
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
"name": "primitives with nulls",
|
|
28
|
+
"given": {
|
|
29
|
+
"input": ["a", "a", null, null, "a", null],
|
|
30
|
+
"definition": {
|
|
31
|
+
"$$distinct": "$"
|
|
32
|
+
}
|
|
33
|
+
},
|
|
34
|
+
"expect": {
|
|
35
|
+
"equal": ["a", null]
|
|
36
|
+
}
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
"name": "objects with duplicates",
|
|
40
|
+
"given": {
|
|
41
|
+
"input": [{ "a": 1 }, { "a": 1 }, { "a": 1 }],
|
|
42
|
+
"definition": {
|
|
43
|
+
"$$distinct": "$"
|
|
44
|
+
}
|
|
45
|
+
},
|
|
46
|
+
"expect": {
|
|
47
|
+
"equal": [{ "a": 1 }]
|
|
48
|
+
}
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
"name": "arrays with duplicates",
|
|
52
|
+
"given": {
|
|
53
|
+
"input": [["a", 1], ["a", 2], ["a", 1], ["a", 1]],
|
|
54
|
+
"definition": {
|
|
55
|
+
"$$distinct": "$"
|
|
56
|
+
}
|
|
57
|
+
},
|
|
58
|
+
"expect": {
|
|
59
|
+
"equal": [
|
|
60
|
+
["a", 1],
|
|
61
|
+
["a", 2]
|
|
62
|
+
]
|
|
63
|
+
}
|
|
64
|
+
},
|
|
65
|
+
{
|
|
66
|
+
"name": "objects with duplicates with by",
|
|
67
|
+
"given": {
|
|
68
|
+
"input": [{ "a": 1 }, { "a": 1 }, { "a": 1 }],
|
|
69
|
+
"definition": {
|
|
70
|
+
"$$distinct": "$",
|
|
71
|
+
"by": "##current"
|
|
72
|
+
}
|
|
73
|
+
},
|
|
74
|
+
"expect": {
|
|
75
|
+
"equal": [{ "a": 1 }]
|
|
76
|
+
}
|
|
77
|
+
},
|
|
78
|
+
{
|
|
79
|
+
"name": "arrays with duplicates with by",
|
|
80
|
+
"given": {
|
|
81
|
+
"input": [["a", 1], ["a", 2], ["a", 1], ["a", 1]],
|
|
82
|
+
"definition": {
|
|
83
|
+
"$$distinct": "$",
|
|
84
|
+
"by": "##current"
|
|
85
|
+
}
|
|
86
|
+
},
|
|
87
|
+
"expect": {
|
|
88
|
+
"equal": [
|
|
89
|
+
["a", 1],
|
|
90
|
+
["a", 2]
|
|
91
|
+
]
|
|
92
|
+
}
|
|
93
|
+
},
|
|
94
|
+
{
|
|
95
|
+
"name": "withTransformation by a",
|
|
96
|
+
"given": {
|
|
97
|
+
"input": [{ "a": 1 }, { "a": 1, "b": 1 }, { "a": 1, "b": 2 }, { "a": 2, "b": 1 }],
|
|
98
|
+
"definition": {
|
|
99
|
+
"$$distinct": "$",
|
|
100
|
+
"by": "##current.a"
|
|
101
|
+
}
|
|
102
|
+
},
|
|
103
|
+
"expect": {
|
|
104
|
+
"equal": [{ "a": 1 }, { "a": 2, "b": 1 }]
|
|
105
|
+
}
|
|
106
|
+
},
|
|
107
|
+
{
|
|
108
|
+
"name": "withTransformation by b",
|
|
109
|
+
"given": {
|
|
110
|
+
"input": [{ "a": 1 }, { "a": 1, "b": 1 }, { "a": 1, "b": 2 }, { "a": 2, "b": 1 }],
|
|
111
|
+
"definition": {
|
|
112
|
+
"$$distinct": "$",
|
|
113
|
+
"by": "##current.b"
|
|
114
|
+
}
|
|
115
|
+
},
|
|
116
|
+
"expect": {
|
|
117
|
+
"equal": [{ "a": 1 }, { "a": 1, "b": 1 }, { "a": 1, "b": 2 }]
|
|
118
|
+
}
|
|
119
|
+
},
|
|
120
|
+
{
|
|
121
|
+
"name": "withTransformation without by and same arguments should stay the same",
|
|
122
|
+
"given": {
|
|
123
|
+
"input": [{ "a": 1 }, { "a": 1, "b": 1 }, { "a": 1, "b": 2 }, { "a": 2, "b": 1 }],
|
|
124
|
+
"definition": {
|
|
125
|
+
"$$distinct": "$"
|
|
126
|
+
}
|
|
127
|
+
},
|
|
128
|
+
"expect": {
|
|
129
|
+
"equal": [{ "a": 1 }, { "a": 1, "b": 1 }, { "a": 1, "b": 2 }, { "a": 2, "b": 1 }]
|
|
130
|
+
}
|
|
131
|
+
},
|
|
132
|
+
{
|
|
133
|
+
"name": "inline by a",
|
|
134
|
+
"given": {
|
|
135
|
+
"input": [{ "a": 1 }, { "a": 1, "b": 1 }, { "a": 1, "b": 2 }, { "a": 2, "b": 1 }],
|
|
136
|
+
"definition": "$$distinct(##current.a):$"
|
|
137
|
+
},
|
|
138
|
+
"expect": {
|
|
139
|
+
"equal": [{ "a": 1 }, { "a": 2, "b": 1 }]
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
]
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
[
|
|
2
|
+
{
|
|
3
|
+
"name": "inline - object to entries",
|
|
4
|
+
"given": {
|
|
5
|
+
"input": {
|
|
6
|
+
"a": 1,
|
|
7
|
+
"b": true,
|
|
8
|
+
"c": "C"
|
|
9
|
+
},
|
|
10
|
+
"definition": "$$entries:$"
|
|
11
|
+
},
|
|
12
|
+
"expect": {
|
|
13
|
+
"equal": [
|
|
14
|
+
["a", 1],
|
|
15
|
+
["b", true],
|
|
16
|
+
["c", "C"]
|
|
17
|
+
],
|
|
18
|
+
"ignoreOrder": true
|
|
19
|
+
}
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
"name": "inline - array to entries",
|
|
23
|
+
"given": {
|
|
24
|
+
"input": [1, true, "C"],
|
|
25
|
+
"definition": "$$entries:$"
|
|
26
|
+
},
|
|
27
|
+
"expect": {
|
|
28
|
+
"equal": [
|
|
29
|
+
[0, 1],
|
|
30
|
+
[1, true],
|
|
31
|
+
[2, "C"]
|
|
32
|
+
]
|
|
33
|
+
}
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
"name": "object - object to entries",
|
|
37
|
+
"given": {
|
|
38
|
+
"input": {
|
|
39
|
+
"a": 1,
|
|
40
|
+
"b": true,
|
|
41
|
+
"c": "C"
|
|
42
|
+
},
|
|
43
|
+
"definition": { "$$entries": "$" }
|
|
44
|
+
},
|
|
45
|
+
"expect": {
|
|
46
|
+
"equal": [
|
|
47
|
+
["a", 1],
|
|
48
|
+
["b", true],
|
|
49
|
+
["c", "C"]
|
|
50
|
+
],
|
|
51
|
+
"ignoreOrder": true
|
|
52
|
+
}
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
"name": "object - array to entries",
|
|
56
|
+
"given": {
|
|
57
|
+
"input": [1, true, "C"],
|
|
58
|
+
"definition": { "$$entries": "$" }
|
|
59
|
+
},
|
|
60
|
+
"expect": {
|
|
61
|
+
"equal": [
|
|
62
|
+
[0, 1],
|
|
63
|
+
[1, true],
|
|
64
|
+
[2, "C"]
|
|
65
|
+
]
|
|
66
|
+
}
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
"name": "object - explicit",
|
|
70
|
+
"given": {
|
|
71
|
+
"input": {
|
|
72
|
+
"a": 1,
|
|
73
|
+
"b": true,
|
|
74
|
+
"c": "C"
|
|
75
|
+
},
|
|
76
|
+
"definition": { "$$entries": { "*": "$", "d": 0.5 } }
|
|
77
|
+
},
|
|
78
|
+
"expect": {
|
|
79
|
+
"equal": [
|
|
80
|
+
["a", 1],
|
|
81
|
+
["b", true],
|
|
82
|
+
["c", "C"],
|
|
83
|
+
["d", 0.5]
|
|
84
|
+
],
|
|
85
|
+
"ignoreOrder": true
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
]
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
[
|
|
2
|
+
{
|
|
3
|
+
"name": "inline",
|
|
4
|
+
"given": {
|
|
5
|
+
"input": {
|
|
6
|
+
"a": 42,
|
|
7
|
+
"b": "$.a"
|
|
8
|
+
},
|
|
9
|
+
"definition": "$$eval:$.b"
|
|
10
|
+
},
|
|
11
|
+
"expect": {
|
|
12
|
+
"equal": 42
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
{
|
|
16
|
+
"name": "object - 1",
|
|
17
|
+
"given": {
|
|
18
|
+
"input": [
|
|
19
|
+
{
|
|
20
|
+
"value": 4
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
"value": 2
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
"value": 13.45
|
|
27
|
+
},
|
|
28
|
+
{}
|
|
29
|
+
],
|
|
30
|
+
"definition": {
|
|
31
|
+
"$$eval": {
|
|
32
|
+
"$$join": [
|
|
33
|
+
"\\$",
|
|
34
|
+
"$avg:",
|
|
35
|
+
"\\$",
|
|
36
|
+
"..value"
|
|
37
|
+
]
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
},
|
|
41
|
+
"expect": {
|
|
42
|
+
"equal": 6.483333333333333
|
|
43
|
+
}
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
"name": "object - 2",
|
|
47
|
+
"given": {
|
|
48
|
+
"input": [
|
|
49
|
+
{
|
|
50
|
+
"value": 4
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
"value": 2
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
"value": 13.45
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
"value": null
|
|
60
|
+
}
|
|
61
|
+
],
|
|
62
|
+
"definition": {
|
|
63
|
+
"$$eval": {
|
|
64
|
+
"$$jsonparse": "{\"$$avg\":\"$\", \"by\":\"##current.value\"}"
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
},
|
|
68
|
+
"expect": {
|
|
69
|
+
"equal": 4.8625
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
]
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
[
|
|
2
|
+
{
|
|
3
|
+
"name": "inline - true",
|
|
4
|
+
"given": {
|
|
5
|
+
"input": [
|
|
6
|
+
{
|
|
7
|
+
"active": true
|
|
8
|
+
},
|
|
9
|
+
{
|
|
10
|
+
"active": true
|
|
11
|
+
}
|
|
12
|
+
],
|
|
13
|
+
"definition": "$$every(##current.active):$"
|
|
14
|
+
},
|
|
15
|
+
"expect": {
|
|
16
|
+
"equal": true
|
|
17
|
+
}
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
"name": "inline - false",
|
|
21
|
+
"given": {
|
|
22
|
+
"input": [
|
|
23
|
+
{
|
|
24
|
+
"active": false
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
"active": true
|
|
28
|
+
}
|
|
29
|
+
],
|
|
30
|
+
"definition": "$$every(##current.active):$"
|
|
31
|
+
},
|
|
32
|
+
"expect": {
|
|
33
|
+
"equal": false
|
|
34
|
+
}
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
"name": "object - true",
|
|
38
|
+
"given": {
|
|
39
|
+
"input": [
|
|
40
|
+
{
|
|
41
|
+
"active": true
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
"active": true
|
|
45
|
+
}
|
|
46
|
+
],
|
|
47
|
+
"definition": {
|
|
48
|
+
"$$every": "$",
|
|
49
|
+
"by": "##current.active"
|
|
50
|
+
}
|
|
51
|
+
},
|
|
52
|
+
"expect": {
|
|
53
|
+
"equal": true
|
|
54
|
+
}
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
"name": "object - false",
|
|
58
|
+
"given": {
|
|
59
|
+
"input": [
|
|
60
|
+
{
|
|
61
|
+
"active": false
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
"active": true
|
|
65
|
+
}
|
|
66
|
+
],
|
|
67
|
+
"definition": {
|
|
68
|
+
"$$every": "$",
|
|
69
|
+
"by": "##current.active"
|
|
70
|
+
}
|
|
71
|
+
},
|
|
72
|
+
"expect": {
|
|
73
|
+
"equal": false
|
|
74
|
+
}
|
|
75
|
+
},
|
|
76
|
+
{
|
|
77
|
+
"name": "object - true - alias all",
|
|
78
|
+
"given": {
|
|
79
|
+
"input": [
|
|
80
|
+
{
|
|
81
|
+
"active": true
|
|
82
|
+
},
|
|
83
|
+
{
|
|
84
|
+
"active": true
|
|
85
|
+
}
|
|
86
|
+
],
|
|
87
|
+
"definition": {
|
|
88
|
+
"$$all": "$",
|
|
89
|
+
"by": "##current.active"
|
|
90
|
+
}
|
|
91
|
+
},
|
|
92
|
+
"expect": {
|
|
93
|
+
"equal": true
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
]
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
[
|
|
2
|
+
{
|
|
3
|
+
"name": "truthy values only",
|
|
4
|
+
"given": {
|
|
5
|
+
"input": ["a", true, "false", 0, 1, [], [0]],
|
|
6
|
+
"definition": {
|
|
7
|
+
"$$filter": "$",
|
|
8
|
+
"by": "##current"
|
|
9
|
+
}
|
|
10
|
+
},
|
|
11
|
+
"expect": {
|
|
12
|
+
"equal": ["a", true, "false", 1, [0]]
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
{
|
|
16
|
+
"name": "truthy values only (explicit boolean, non js style)",
|
|
17
|
+
"given": {
|
|
18
|
+
"input": ["a", true, "false", 0, 1, [], [0]],
|
|
19
|
+
"definition": {
|
|
20
|
+
"$$filter": "$",
|
|
21
|
+
"by": "$$boolean:##current"
|
|
22
|
+
}
|
|
23
|
+
},
|
|
24
|
+
"expect": {
|
|
25
|
+
"equal": [true, 1, [0]]
|
|
26
|
+
}
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
"name": "names that starts with a",
|
|
30
|
+
"given": {
|
|
31
|
+
"input": [{ "name": "alice" }, { "name": "ann" }, { "name": "bob" }],
|
|
32
|
+
"definition": {
|
|
33
|
+
"$$filter": "$",
|
|
34
|
+
"by": "$$test(^a):##current.name"
|
|
35
|
+
}
|
|
36
|
+
},
|
|
37
|
+
"expect": {
|
|
38
|
+
"equal": [{ "name": "alice" }, { "name": "ann" }]
|
|
39
|
+
}
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
"name": "inline",
|
|
43
|
+
"given": {
|
|
44
|
+
"input": ["a", true, "false", 0, 1, [], [0]],
|
|
45
|
+
"definition": "$$filter(##current):$"
|
|
46
|
+
},
|
|
47
|
+
"expect": {
|
|
48
|
+
"equal": ["a", true, "false", 1, [0]]
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
]
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
[
|
|
2
|
+
{
|
|
3
|
+
"name": "findTheTruth",
|
|
4
|
+
"given": {
|
|
5
|
+
"input": [0, [], "a"],
|
|
6
|
+
"definition": {
|
|
7
|
+
"$$find": "$",
|
|
8
|
+
"by": "##current"
|
|
9
|
+
}
|
|
10
|
+
},
|
|
11
|
+
"expect": {
|
|
12
|
+
"equal": "a"
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
{
|
|
16
|
+
"name": "findTheTruth explicit boolean",
|
|
17
|
+
"given": {
|
|
18
|
+
"input": ["a", "1", "true"],
|
|
19
|
+
"definition": {
|
|
20
|
+
"$$find": "$",
|
|
21
|
+
"by": "$$boolean:##current"
|
|
22
|
+
}
|
|
23
|
+
},
|
|
24
|
+
"expect": {
|
|
25
|
+
"equal": "true"
|
|
26
|
+
}
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
"name": "nameThatStartsWithB",
|
|
30
|
+
"given": {
|
|
31
|
+
"input": [{ "name": "alice" }, { "name": "ann" }, { "name": "Bob" }],
|
|
32
|
+
"definition": {
|
|
33
|
+
"$$find": "$",
|
|
34
|
+
"by": "$$test('(?i)^b'):##current.name"
|
|
35
|
+
}
|
|
36
|
+
},
|
|
37
|
+
"expect": {
|
|
38
|
+
"equal": { "name": "Bob" }
|
|
39
|
+
}
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
"name": "inline",
|
|
43
|
+
"given": {
|
|
44
|
+
"input": [0, [], "a"],
|
|
45
|
+
"definition": "$$find(##current):$"
|
|
46
|
+
},
|
|
47
|
+
"expect": {
|
|
48
|
+
"equal": "a"
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
]
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
[
|
|
2
|
+
{
|
|
3
|
+
"name": "object - found",
|
|
4
|
+
"given": {
|
|
5
|
+
"input": [0, [], "a"],
|
|
6
|
+
"definition": {
|
|
7
|
+
"$$findindex": "$",
|
|
8
|
+
"by": "##current"
|
|
9
|
+
}
|
|
10
|
+
},
|
|
11
|
+
"expect": {
|
|
12
|
+
"equal": 2
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
{
|
|
16
|
+
"name": "object - explicit boolean",
|
|
17
|
+
"given": {
|
|
18
|
+
"input": ["a", "1", "true"],
|
|
19
|
+
"definition": {
|
|
20
|
+
"$$findindex": "$",
|
|
21
|
+
"by": "$$boolean:##current"
|
|
22
|
+
}
|
|
23
|
+
},
|
|
24
|
+
"expect": {
|
|
25
|
+
"equal": 2
|
|
26
|
+
}
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
"name": "object - not found",
|
|
30
|
+
"given": {
|
|
31
|
+
"input": ["a", "1", "false"],
|
|
32
|
+
"definition": {
|
|
33
|
+
"$$findindex": "$",
|
|
34
|
+
"by": "$$boolean:##current"
|
|
35
|
+
}
|
|
36
|
+
},
|
|
37
|
+
"expect": {
|
|
38
|
+
"equal": -1
|
|
39
|
+
}
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
"name": "inline - found",
|
|
43
|
+
"given": {
|
|
44
|
+
"input": [0, [], "a"],
|
|
45
|
+
"definition": "$$findindex(##current):$"
|
|
46
|
+
},
|
|
47
|
+
"expect": {
|
|
48
|
+
"equal": 2
|
|
49
|
+
}
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
"name": "inline - not found",
|
|
53
|
+
"given": {
|
|
54
|
+
"input": [0, [], "false"],
|
|
55
|
+
"definition": "$$findindex('$$boolean:##current'):$"
|
|
56
|
+
},
|
|
57
|
+
"expect": {
|
|
58
|
+
"equal": -1
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
]
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
[
|
|
2
|
+
{
|
|
3
|
+
"name": "object flat 2 arrays",
|
|
4
|
+
"given": {
|
|
5
|
+
"input": [
|
|
6
|
+
["a", "b", "c"],
|
|
7
|
+
["d", "e", "f"]
|
|
8
|
+
],
|
|
9
|
+
"definition": {
|
|
10
|
+
"$$flat": ["$[0]", "$[1]"]
|
|
11
|
+
}
|
|
12
|
+
},
|
|
13
|
+
"expect": {
|
|
14
|
+
"equal": ["a", "b", "c", "d", "e", "f"]
|
|
15
|
+
}
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
"name": "object flat 1 array",
|
|
19
|
+
"given": {
|
|
20
|
+
"input": [
|
|
21
|
+
["a", "b", "c"],
|
|
22
|
+
["d", "e", "f"]
|
|
23
|
+
],
|
|
24
|
+
"definition": {
|
|
25
|
+
"$$flat": ["$[0]", "$.pointingToNowhere"]
|
|
26
|
+
}
|
|
27
|
+
},
|
|
28
|
+
"expect": {
|
|
29
|
+
"equal": ["a", "b", "c"]
|
|
30
|
+
}
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
"name": "object flat 2 arrays inline",
|
|
34
|
+
"given": {
|
|
35
|
+
"input": [
|
|
36
|
+
["a", "b", "c"],
|
|
37
|
+
["d", "e", "f"]
|
|
38
|
+
],
|
|
39
|
+
"definition": {
|
|
40
|
+
"$$flat": [
|
|
41
|
+
["a", "b", "c"],
|
|
42
|
+
["d", "e", "f"]
|
|
43
|
+
]
|
|
44
|
+
}
|
|
45
|
+
},
|
|
46
|
+
"expect": {
|
|
47
|
+
"equal": ["a", "b", "c", "d", "e", "f"]
|
|
48
|
+
}
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
"name": "object flat 1 array inline",
|
|
52
|
+
"given": {
|
|
53
|
+
"input": ["a", "b", "c"],
|
|
54
|
+
"definition": {
|
|
55
|
+
"$$flat": [["a", "b", "c"], []]
|
|
56
|
+
}
|
|
57
|
+
},
|
|
58
|
+
"expect": {
|
|
59
|
+
"equal": ["a", "b", "c"]
|
|
60
|
+
}
|
|
61
|
+
},
|
|
62
|
+
{
|
|
63
|
+
"name": "object flat 1 array with null",
|
|
64
|
+
"given": {
|
|
65
|
+
"input": ["a", "b", "c"],
|
|
66
|
+
"definition": {
|
|
67
|
+
"$$flat": [["a", "b", "c"], null]
|
|
68
|
+
}
|
|
69
|
+
},
|
|
70
|
+
"expect": {
|
|
71
|
+
"equal": ["a", "b", "c"]
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
]
|