@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,70 @@
|
|
|
1
|
+
[
|
|
2
|
+
{
|
|
3
|
+
"name": "object - 2 arrays",
|
|
4
|
+
"given": {
|
|
5
|
+
"input": [["a", "b", "c"], ["d", "e", "f"]],
|
|
6
|
+
"definition": { "$$concat": ["$[0]", "$[1]"] }
|
|
7
|
+
},
|
|
8
|
+
"expect": {
|
|
9
|
+
"equal": ["a", "b", "c", "d", "e", "f"]
|
|
10
|
+
}
|
|
11
|
+
},
|
|
12
|
+
{
|
|
13
|
+
"name": "object - keep nulls",
|
|
14
|
+
"given": {
|
|
15
|
+
"input": [["a", "b", "c"], ["d", "e", "f"]],
|
|
16
|
+
"definition": {
|
|
17
|
+
"$$concat": [
|
|
18
|
+
["a", null, "c"],
|
|
19
|
+
["d", "e", null]
|
|
20
|
+
]
|
|
21
|
+
}
|
|
22
|
+
},
|
|
23
|
+
"expect": {
|
|
24
|
+
"equal": ["a", null, "c", "d", "e", null]
|
|
25
|
+
}
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
"name": "object - skip nulls",
|
|
29
|
+
"given": {
|
|
30
|
+
"input": null,
|
|
31
|
+
"definition": {
|
|
32
|
+
"$$concat": [
|
|
33
|
+
[
|
|
34
|
+
"a",
|
|
35
|
+
"b",
|
|
36
|
+
"c"
|
|
37
|
+
],
|
|
38
|
+
null
|
|
39
|
+
]
|
|
40
|
+
}
|
|
41
|
+
},
|
|
42
|
+
"expect": {
|
|
43
|
+
"equal": [
|
|
44
|
+
"a",
|
|
45
|
+
"b",
|
|
46
|
+
"c"
|
|
47
|
+
]
|
|
48
|
+
}
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
"name": "object - append non nulls",
|
|
52
|
+
"given": {
|
|
53
|
+
"input": null,
|
|
54
|
+
"definition": { "$$concat": [["a", "b", "c"], "d", ["e"]] }
|
|
55
|
+
},
|
|
56
|
+
"expect": {
|
|
57
|
+
"equal": ["a", "b", "c", "d", "e"]
|
|
58
|
+
}
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
"name": "object - blind concat",
|
|
62
|
+
"given": {
|
|
63
|
+
"input": [["a", "b", "c"], "d", ["e"]],
|
|
64
|
+
"definition": { "$$concat": "$" }
|
|
65
|
+
},
|
|
66
|
+
"expect": {
|
|
67
|
+
"equal": ["a", "b", "c", "d", "e"]
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
]
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
[
|
|
2
|
+
{
|
|
3
|
+
"name": "object - positive",
|
|
4
|
+
"given": {
|
|
5
|
+
"input": [0, [], "a"],
|
|
6
|
+
"definition": {
|
|
7
|
+
"$$contains": "$",
|
|
8
|
+
"that": "a"
|
|
9
|
+
}
|
|
10
|
+
},
|
|
11
|
+
"expect": {
|
|
12
|
+
"equal": true
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
{
|
|
16
|
+
"name": "object - positive (with transformation)",
|
|
17
|
+
"given": {
|
|
18
|
+
"input": "a",
|
|
19
|
+
"definition": {
|
|
20
|
+
"$$contains": ["b", "$"],
|
|
21
|
+
"that": "a"
|
|
22
|
+
}
|
|
23
|
+
},
|
|
24
|
+
"expect": {
|
|
25
|
+
"equal": true
|
|
26
|
+
}
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
"name": "object - negative",
|
|
30
|
+
"given": {
|
|
31
|
+
"input": [0, [], "a"],
|
|
32
|
+
"definition": {
|
|
33
|
+
"$$contains": "$",
|
|
34
|
+
"that": "b"
|
|
35
|
+
}
|
|
36
|
+
},
|
|
37
|
+
"expect": {
|
|
38
|
+
"equal": false
|
|
39
|
+
}
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
"name": "inline - positive",
|
|
43
|
+
"given": {
|
|
44
|
+
"input": [0, [], "a"],
|
|
45
|
+
"definition": "$$contains(a):$"
|
|
46
|
+
},
|
|
47
|
+
"expect": {
|
|
48
|
+
"equal": true
|
|
49
|
+
}
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
"name": "inline - negative",
|
|
53
|
+
"given": {
|
|
54
|
+
"input": [0, [], "a"],
|
|
55
|
+
"definition": "$$contains(b):$"
|
|
56
|
+
},
|
|
57
|
+
"expect": {
|
|
58
|
+
"equal": false
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
]
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
[
|
|
2
|
+
{
|
|
3
|
+
"name": "inline - with headers",
|
|
4
|
+
"given": {
|
|
5
|
+
"input": [
|
|
6
|
+
{ "a": "A", "b": 1 },
|
|
7
|
+
{ "a": "C", "b": 2 }
|
|
8
|
+
],
|
|
9
|
+
"definition": "$$csv:$"
|
|
10
|
+
},
|
|
11
|
+
"expect": {
|
|
12
|
+
"equal": "a,b\nA,1\nC,2\n",
|
|
13
|
+
"format": "csv"
|
|
14
|
+
}
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
"name": "inline - no headers",
|
|
18
|
+
"given": {
|
|
19
|
+
"input": [
|
|
20
|
+
{ "a": "A", "b": 1 },
|
|
21
|
+
{ "a": "C", "b": 2 }
|
|
22
|
+
],
|
|
23
|
+
"definition": "$$csv(true):$"
|
|
24
|
+
},
|
|
25
|
+
"expect": {
|
|
26
|
+
"equal": "A,1\nC,2\n",
|
|
27
|
+
"format": "csv"
|
|
28
|
+
}
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
"name": "object - with headers",
|
|
32
|
+
"given": {
|
|
33
|
+
"input": [
|
|
34
|
+
{ "a": "A", "b": 1 },
|
|
35
|
+
{ "a": "C", "b": 2 }
|
|
36
|
+
],
|
|
37
|
+
"definition": {
|
|
38
|
+
"$$csv": "$"
|
|
39
|
+
}
|
|
40
|
+
},
|
|
41
|
+
"expect": {
|
|
42
|
+
"equal": "a,b\nA,1\nC,2\n",
|
|
43
|
+
"format": "csv"
|
|
44
|
+
}
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
"name": "object - no headers",
|
|
48
|
+
"given": {
|
|
49
|
+
"input": [
|
|
50
|
+
{ "a": "A", "b": 1 },
|
|
51
|
+
{ "a": "C", "b": 2 }
|
|
52
|
+
],
|
|
53
|
+
"definition": {
|
|
54
|
+
"$$csv": "$",
|
|
55
|
+
"no_headers": true
|
|
56
|
+
}
|
|
57
|
+
},
|
|
58
|
+
"expect": {
|
|
59
|
+
"equal": "A,1\nC,2\n",
|
|
60
|
+
"format": "csv"
|
|
61
|
+
}
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
"name": "object - arrays input with names",
|
|
65
|
+
"given": {
|
|
66
|
+
"input": [
|
|
67
|
+
[1, 2],
|
|
68
|
+
[3, 4]
|
|
69
|
+
],
|
|
70
|
+
"definition": {
|
|
71
|
+
"$$csv": "$",
|
|
72
|
+
"names": ["a", "b"]
|
|
73
|
+
}
|
|
74
|
+
},
|
|
75
|
+
"expect": {
|
|
76
|
+
"equal": "a,b\n1,2\n3,4\n",
|
|
77
|
+
"format": "csv"
|
|
78
|
+
}
|
|
79
|
+
},
|
|
80
|
+
{
|
|
81
|
+
"name": "object - arrays input, without names",
|
|
82
|
+
"given": {
|
|
83
|
+
"input": [
|
|
84
|
+
[1, 2],
|
|
85
|
+
[3, 4]
|
|
86
|
+
],
|
|
87
|
+
"definition": {
|
|
88
|
+
"$$csv": "$"
|
|
89
|
+
}
|
|
90
|
+
},
|
|
91
|
+
"expect": {
|
|
92
|
+
"equal": "1,2\n3,4\n",
|
|
93
|
+
"format": "csv"
|
|
94
|
+
}
|
|
95
|
+
},
|
|
96
|
+
{
|
|
97
|
+
"name": "inline - no_headers and force_quote",
|
|
98
|
+
"given": {
|
|
99
|
+
"input": [
|
|
100
|
+
{
|
|
101
|
+
"a": "A",
|
|
102
|
+
"b": 1
|
|
103
|
+
},
|
|
104
|
+
{
|
|
105
|
+
"a": "C",
|
|
106
|
+
"b": 2
|
|
107
|
+
}
|
|
108
|
+
],
|
|
109
|
+
"definition": "$$csv(true, true):$"
|
|
110
|
+
},
|
|
111
|
+
"expect": {
|
|
112
|
+
"equal": "\"A\",\"1\"\n\"C\",\"2\"\n",
|
|
113
|
+
"format": "csv"
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
]
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
[
|
|
2
|
+
{
|
|
3
|
+
"name": "Inline - parse CSV with comma as a value",
|
|
4
|
+
"given": {
|
|
5
|
+
"input": "a\n\",\"",
|
|
6
|
+
"inputFormat": "csv",
|
|
7
|
+
"definition": "$$csvparse:$"
|
|
8
|
+
},
|
|
9
|
+
"expect": {
|
|
10
|
+
"equal": [
|
|
11
|
+
{
|
|
12
|
+
"a": ","
|
|
13
|
+
}
|
|
14
|
+
]
|
|
15
|
+
}
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
"name": "Inline - parse CSV with escaped double quotes",
|
|
19
|
+
"given": {
|
|
20
|
+
"input": "a\n\"\"\"\"",
|
|
21
|
+
"inputFormat": "csv",
|
|
22
|
+
"definition": "$$csvparse:$"
|
|
23
|
+
},
|
|
24
|
+
"expect": {
|
|
25
|
+
"equal": [
|
|
26
|
+
{
|
|
27
|
+
"a": "\""
|
|
28
|
+
}
|
|
29
|
+
]
|
|
30
|
+
}
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
"name": "Inline - parse CSV into array format",
|
|
34
|
+
"given": {
|
|
35
|
+
"input": "1,2\n3,4",
|
|
36
|
+
"inputFormat": "csv",
|
|
37
|
+
"definition": "$$csvparse(true):$"
|
|
38
|
+
},
|
|
39
|
+
"expect": {
|
|
40
|
+
"equal": [
|
|
41
|
+
["1", "2"],
|
|
42
|
+
["3", "4"]
|
|
43
|
+
]
|
|
44
|
+
}
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
"name": "Object - parse CSV with comma as a value",
|
|
48
|
+
"given": {
|
|
49
|
+
"input": "a\n\",\"",
|
|
50
|
+
"inputFormat": "csv",
|
|
51
|
+
"definition": {
|
|
52
|
+
"$$csvparse": "$"
|
|
53
|
+
}
|
|
54
|
+
},
|
|
55
|
+
"expect": {
|
|
56
|
+
"equal": [
|
|
57
|
+
{
|
|
58
|
+
"a": ","
|
|
59
|
+
}
|
|
60
|
+
]
|
|
61
|
+
}
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
"name": "Object - parse CSV with escaped double quotes",
|
|
65
|
+
"given": {
|
|
66
|
+
"input": "a\n\"\"\"\"",
|
|
67
|
+
"inputFormat": "csv",
|
|
68
|
+
"definition": {
|
|
69
|
+
"$$csvparse": "$"
|
|
70
|
+
}
|
|
71
|
+
},
|
|
72
|
+
"expect": {
|
|
73
|
+
"equal": [
|
|
74
|
+
{
|
|
75
|
+
"a": "\""
|
|
76
|
+
}
|
|
77
|
+
]
|
|
78
|
+
}
|
|
79
|
+
},
|
|
80
|
+
{
|
|
81
|
+
"name": "Object - parse CSV with escaped double quotes",
|
|
82
|
+
"given": {
|
|
83
|
+
"input": "1,2\n3,4",
|
|
84
|
+
"inputFormat": "csv",
|
|
85
|
+
"definition": {
|
|
86
|
+
"$$csvparse": "$",
|
|
87
|
+
"no_headers": true
|
|
88
|
+
}
|
|
89
|
+
},
|
|
90
|
+
"expect": {
|
|
91
|
+
"equal": [
|
|
92
|
+
["1", "2"],
|
|
93
|
+
["3", "4"]
|
|
94
|
+
]
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
]
|