@luvio/graphql 0.140.1
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/dist/luvioGraphql.js +60 -0
- package/dist/luvioGraphql.mjs +58 -0
- package/dist/types/fields.d.ts +3 -0
- package/dist/types/main.d.ts +3 -0
- package/dist/types/types.d.ts +1 -0
- package/package.json +58 -0
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
function serializeFieldArguments(argumentNodes, variables) {
|
|
4
|
+
const mutableArgumentNodes = Object.assign([], argumentNodes);
|
|
5
|
+
return `args__(${mutableArgumentNodes
|
|
6
|
+
.sort((a, b) => {
|
|
7
|
+
const aName = a.name.value.toUpperCase();
|
|
8
|
+
const bName = b.name.value.toUpperCase();
|
|
9
|
+
return aName < bName ? -1 : aName > bName ? 1 : 0;
|
|
10
|
+
})
|
|
11
|
+
.map((node) => serializeArgNode(node, variables))
|
|
12
|
+
.join('::')})`;
|
|
13
|
+
}
|
|
14
|
+
function serializeArgNode(argumentNode, variables) {
|
|
15
|
+
const argName = argumentNode.name.value;
|
|
16
|
+
return `${argName}:${serializeValueNode(argumentNode.value, variables)}`;
|
|
17
|
+
}
|
|
18
|
+
function serializeValueNode(valueNode, variables) {
|
|
19
|
+
switch (valueNode.kind) {
|
|
20
|
+
case 'BooleanValue':
|
|
21
|
+
return valueNode.value + '';
|
|
22
|
+
case 'IntValue':
|
|
23
|
+
case 'FloatValue':
|
|
24
|
+
case 'EnumValue':
|
|
25
|
+
case 'StringValue':
|
|
26
|
+
return valueNode.value;
|
|
27
|
+
case 'ListValue': {
|
|
28
|
+
const mutableValueNodeList = Object.assign([], valueNode.values);
|
|
29
|
+
return mutableValueNodeList
|
|
30
|
+
.sort((a, b) => {
|
|
31
|
+
const aVal = serializeValueNode(a, variables).toUpperCase();
|
|
32
|
+
const bVal = serializeValueNode(b, variables).toUpperCase();
|
|
33
|
+
return aVal < bVal ? -1 : aVal > bVal ? 1 : 0;
|
|
34
|
+
})
|
|
35
|
+
.map((val, i) => `${serializeValueNode(val, variables)}[${i}]`)
|
|
36
|
+
.join(',');
|
|
37
|
+
}
|
|
38
|
+
case 'Variable': {
|
|
39
|
+
const variableValue = variables[valueNode.name.value];
|
|
40
|
+
return typeof variableValue === 'string'
|
|
41
|
+
? variableValue
|
|
42
|
+
: JSON.stringify(variableValue);
|
|
43
|
+
}
|
|
44
|
+
case 'NullValue':
|
|
45
|
+
return 'null';
|
|
46
|
+
case 'ObjectValue': {
|
|
47
|
+
const mutableFieldNodeList = Object.assign([], valueNode.fields);
|
|
48
|
+
return mutableFieldNodeList
|
|
49
|
+
.sort((a, b) => {
|
|
50
|
+
const aName = a.name.value.toUpperCase();
|
|
51
|
+
const bName = b.name.value.toUpperCase();
|
|
52
|
+
return aName < bName ? -1 : aName > bName ? 1 : 0;
|
|
53
|
+
})
|
|
54
|
+
.map((field) => field.name.value + ':' + serializeValueNode(field.value, variables))
|
|
55
|
+
.join(',');
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
exports.serializeFieldArguments = serializeFieldArguments;
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
function serializeFieldArguments(argumentNodes, variables) {
|
|
2
|
+
const mutableArgumentNodes = Object.assign([], argumentNodes);
|
|
3
|
+
return `args__(${mutableArgumentNodes
|
|
4
|
+
.sort((a, b) => {
|
|
5
|
+
const aName = a.name.value.toUpperCase();
|
|
6
|
+
const bName = b.name.value.toUpperCase();
|
|
7
|
+
return aName < bName ? -1 : aName > bName ? 1 : 0;
|
|
8
|
+
})
|
|
9
|
+
.map((node) => serializeArgNode(node, variables))
|
|
10
|
+
.join('::')})`;
|
|
11
|
+
}
|
|
12
|
+
function serializeArgNode(argumentNode, variables) {
|
|
13
|
+
const argName = argumentNode.name.value;
|
|
14
|
+
return `${argName}:${serializeValueNode(argumentNode.value, variables)}`;
|
|
15
|
+
}
|
|
16
|
+
function serializeValueNode(valueNode, variables) {
|
|
17
|
+
switch (valueNode.kind) {
|
|
18
|
+
case 'BooleanValue':
|
|
19
|
+
return valueNode.value + '';
|
|
20
|
+
case 'IntValue':
|
|
21
|
+
case 'FloatValue':
|
|
22
|
+
case 'EnumValue':
|
|
23
|
+
case 'StringValue':
|
|
24
|
+
return valueNode.value;
|
|
25
|
+
case 'ListValue': {
|
|
26
|
+
const mutableValueNodeList = Object.assign([], valueNode.values);
|
|
27
|
+
return mutableValueNodeList
|
|
28
|
+
.sort((a, b) => {
|
|
29
|
+
const aVal = serializeValueNode(a, variables).toUpperCase();
|
|
30
|
+
const bVal = serializeValueNode(b, variables).toUpperCase();
|
|
31
|
+
return aVal < bVal ? -1 : aVal > bVal ? 1 : 0;
|
|
32
|
+
})
|
|
33
|
+
.map((val, i) => `${serializeValueNode(val, variables)}[${i}]`)
|
|
34
|
+
.join(',');
|
|
35
|
+
}
|
|
36
|
+
case 'Variable': {
|
|
37
|
+
const variableValue = variables[valueNode.name.value];
|
|
38
|
+
return typeof variableValue === 'string'
|
|
39
|
+
? variableValue
|
|
40
|
+
: JSON.stringify(variableValue);
|
|
41
|
+
}
|
|
42
|
+
case 'NullValue':
|
|
43
|
+
return 'null';
|
|
44
|
+
case 'ObjectValue': {
|
|
45
|
+
const mutableFieldNodeList = Object.assign([], valueNode.fields);
|
|
46
|
+
return mutableFieldNodeList
|
|
47
|
+
.sort((a, b) => {
|
|
48
|
+
const aName = a.name.value.toUpperCase();
|
|
49
|
+
const bName = b.name.value.toUpperCase();
|
|
50
|
+
return aName < bName ? -1 : aName > bName ? 1 : 0;
|
|
51
|
+
})
|
|
52
|
+
.map((field) => field.name.value + ':' + serializeValueNode(field.value, variables))
|
|
53
|
+
.join(',');
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
export { serializeFieldArguments };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type GraphQLVariables = Record<string, any>;
|
package/package.json
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@luvio/graphql",
|
|
3
|
+
"version": "0.140.1",
|
|
4
|
+
"description": "GraphQL utilities for Luvio GraphQL adapter support",
|
|
5
|
+
"repository": {
|
|
6
|
+
"type": "git",
|
|
7
|
+
"url": "https://github.com/salesforce-experience-platform-emu/luvio.git",
|
|
8
|
+
"directory": "packages/@luvio/graphql"
|
|
9
|
+
},
|
|
10
|
+
"license": "MIT",
|
|
11
|
+
"exports": {
|
|
12
|
+
"require": "./dist/luvioGraphql.js",
|
|
13
|
+
"import": "./dist/luvioGraphql.mjs"
|
|
14
|
+
},
|
|
15
|
+
"main": "./dist/luvioGraphql.js",
|
|
16
|
+
"module": "./dist/luvioGraphql.mjs",
|
|
17
|
+
"types": "dist/types/main.d.ts",
|
|
18
|
+
"files": [
|
|
19
|
+
"dist/"
|
|
20
|
+
],
|
|
21
|
+
"scripts": {
|
|
22
|
+
"build": "rollup --bundleConfigAsCjs --config rollup.config.js",
|
|
23
|
+
"clean": "rm -rf dist",
|
|
24
|
+
"parse": "node ./scripts/cli.mjs",
|
|
25
|
+
"test": "jest",
|
|
26
|
+
"test:debug": "node --inspect-brk ../../../node_modules/.bin/jest --runInBand",
|
|
27
|
+
"test:size": "luvioBundlesize"
|
|
28
|
+
},
|
|
29
|
+
"dependencies": {
|
|
30
|
+
"@luvio/engine": "^0.139.6",
|
|
31
|
+
"@luvio/graphql-parser": "^0.139.6"
|
|
32
|
+
},
|
|
33
|
+
"volta": {
|
|
34
|
+
"extends": "../../../package.json"
|
|
35
|
+
},
|
|
36
|
+
"publishConfig": {
|
|
37
|
+
"access": "public"
|
|
38
|
+
},
|
|
39
|
+
"luvioBundlesize": [
|
|
40
|
+
{
|
|
41
|
+
"path": "./dist/luvioGraphql.js",
|
|
42
|
+
"maxSize": {
|
|
43
|
+
"none": "10 kB",
|
|
44
|
+
"min": "10 kB",
|
|
45
|
+
"compressed": "5 kB"
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
],
|
|
49
|
+
"nx": {
|
|
50
|
+
"targets": {
|
|
51
|
+
"build": {
|
|
52
|
+
"outputs": [
|
|
53
|
+
"packages/@luvio/graphql/dist"
|
|
54
|
+
]
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
}
|