@graffy/common 0.15.17 → 0.15.19-alpha.2
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/index.cjs +20 -13
- package/index.mjs +20 -13
- package/package.json +3 -3
package/index.cjs
CHANGED
|
@@ -1063,9 +1063,10 @@ function decode(nodes = [], { isGraph } = {}) {
|
|
|
1063
1063
|
const { $key, $val } = item;
|
|
1064
1064
|
delete item.$key;
|
|
1065
1065
|
delete item.$val;
|
|
1066
|
-
if (typeof $val === "object")
|
|
1067
|
-
$val
|
|
1068
|
-
|
|
1066
|
+
if (typeof $val === "object") {
|
|
1067
|
+
Object.defineProperty($val, "$val", { value: true });
|
|
1068
|
+
}
|
|
1069
|
+
collection[$key] = isDef($val) ? $val : !isEmpty(item) || item.$ref || item.$put ? item : isGraph ? null : true;
|
|
1069
1070
|
return collection;
|
|
1070
1071
|
}, allStrs ? {} : []);
|
|
1071
1072
|
}
|
|
@@ -1095,7 +1096,9 @@ function decode(nodes = [], { isGraph } = {}) {
|
|
|
1095
1096
|
throw Error("decode.unencoded_prefix_ref: " + node.path);
|
|
1096
1097
|
}
|
|
1097
1098
|
lastKey.$all = true;
|
|
1098
|
-
|
|
1099
|
+
const linkObject = { $key: args };
|
|
1100
|
+
Object.defineProperty(linkObject, "$ref", { value: $ref });
|
|
1101
|
+
return [linkObject];
|
|
1099
1102
|
}
|
|
1100
1103
|
const children = decodeChildren(node.children);
|
|
1101
1104
|
if (!Array.isArray(children)) {
|
|
@@ -1127,7 +1130,9 @@ function decode(nodes = [], { isGraph } = {}) {
|
|
|
1127
1130
|
return { $key: decode$2({ key: node.key }) };
|
|
1128
1131
|
}
|
|
1129
1132
|
function decodeLinkNode(node) {
|
|
1130
|
-
|
|
1133
|
+
const linkObject = { $key: decode$2(node) };
|
|
1134
|
+
Object.defineProperty(linkObject, "$ref", { value: decode$1(node.path) });
|
|
1135
|
+
return linkObject;
|
|
1131
1136
|
}
|
|
1132
1137
|
return decodeChildren(nodes);
|
|
1133
1138
|
}
|
|
@@ -1156,7 +1161,7 @@ function decorate(rootGraph, rootQuery) {
|
|
|
1156
1161
|
if (range)
|
|
1157
1162
|
targetPlumGraph[PRE] = filter;
|
|
1158
1163
|
graph = construct(targetPlumGraph, range ? __spreadValues({ $key: range }, props) : props);
|
|
1159
|
-
graph
|
|
1164
|
+
Object.defineProperty(graph, "$ref", { value: $ref });
|
|
1160
1165
|
} else if (Array.isArray(query)) {
|
|
1161
1166
|
let pageKey;
|
|
1162
1167
|
graph = query.flatMap((item, i) => {
|
|
@@ -1203,8 +1208,11 @@ function decorate(rootGraph, rootQuery) {
|
|
|
1203
1208
|
throw Error("decorate.unexpected_graph");
|
|
1204
1209
|
}
|
|
1205
1210
|
}
|
|
1206
|
-
if (plumGraph[REF])
|
|
1207
|
-
graph
|
|
1211
|
+
if (plumGraph[REF]) {
|
|
1212
|
+
Object.defineProperty(graph, "$ref", {
|
|
1213
|
+
value: decode$1(plumGraph[REF])
|
|
1214
|
+
});
|
|
1215
|
+
}
|
|
1208
1216
|
return graph;
|
|
1209
1217
|
}
|
|
1210
1218
|
function descend(children, $key) {
|
|
@@ -1310,18 +1318,17 @@ function encode(value, { version, isGraph } = {}) {
|
|
|
1310
1318
|
}
|
|
1311
1319
|
const combine = isGraph ? merge : add;
|
|
1312
1320
|
function makeNode(object, key, ver) {
|
|
1313
|
-
var
|
|
1321
|
+
var _b;
|
|
1314
1322
|
if (!isDef(object))
|
|
1315
1323
|
return;
|
|
1316
1324
|
if (typeof object === "object" && object && isEmpty(object))
|
|
1317
1325
|
return;
|
|
1318
|
-
const _a2 = object || {}, { $key, $ver } = _a2,
|
|
1319
|
-
const _b = data, { $ref, $val, $chi, $put } = _b, props = __objRest(_b, ["$ref", "$val", "$chi", "$put"]);
|
|
1326
|
+
const _a2 = object || {}, { $key, $ver, $ref, $val, $chi, $put } = _a2, props = __objRest(_a2, ["$key", "$ver", "$ref", "$val", "$chi", "$put"]);
|
|
1320
1327
|
if (isDef($ver))
|
|
1321
1328
|
ver = $ver;
|
|
1322
1329
|
if (isPlainObject($key)) {
|
|
1323
1330
|
const [page, filter] = splitArgs($key);
|
|
1324
|
-
if (isGraph && page && !isDef(page.$cursor) && !isEmpty(
|
|
1331
|
+
if (isGraph && page && !isDef(page.$cursor) && ($ref || $val || $chi || $put || !isEmpty(props))) {
|
|
1325
1332
|
const node2 = makeNode(__spreadProps(__spreadValues({}, object), { $key: filter || "" }), key, ver);
|
|
1326
1333
|
node2.prefix = true;
|
|
1327
1334
|
return node2;
|
|
@@ -1399,7 +1406,7 @@ function encode(value, { version, isGraph } = {}) {
|
|
|
1399
1406
|
if (isGraph && isDef(putQuery)) {
|
|
1400
1407
|
node.children = finalize(node.children || [], putQuery, node.version);
|
|
1401
1408
|
}
|
|
1402
|
-
if (((
|
|
1409
|
+
if (((_b = node.children) == null ? void 0 : _b.length) || isDef(node.end) || isDef(node.value) || isDef(node.path)) {
|
|
1403
1410
|
return node;
|
|
1404
1411
|
}
|
|
1405
1412
|
}
|
package/index.mjs
CHANGED
|
@@ -1055,9 +1055,10 @@ function decode(nodes = [], { isGraph } = {}) {
|
|
|
1055
1055
|
const { $key, $val } = item;
|
|
1056
1056
|
delete item.$key;
|
|
1057
1057
|
delete item.$val;
|
|
1058
|
-
if (typeof $val === "object")
|
|
1059
|
-
$val
|
|
1060
|
-
|
|
1058
|
+
if (typeof $val === "object") {
|
|
1059
|
+
Object.defineProperty($val, "$val", { value: true });
|
|
1060
|
+
}
|
|
1061
|
+
collection[$key] = isDef($val) ? $val : !isEmpty(item) || item.$ref || item.$put ? item : isGraph ? null : true;
|
|
1061
1062
|
return collection;
|
|
1062
1063
|
}, allStrs ? {} : []);
|
|
1063
1064
|
}
|
|
@@ -1087,7 +1088,9 @@ function decode(nodes = [], { isGraph } = {}) {
|
|
|
1087
1088
|
throw Error("decode.unencoded_prefix_ref: " + node.path);
|
|
1088
1089
|
}
|
|
1089
1090
|
lastKey.$all = true;
|
|
1090
|
-
|
|
1091
|
+
const linkObject = { $key: args };
|
|
1092
|
+
Object.defineProperty(linkObject, "$ref", { value: $ref });
|
|
1093
|
+
return [linkObject];
|
|
1091
1094
|
}
|
|
1092
1095
|
const children = decodeChildren(node.children);
|
|
1093
1096
|
if (!Array.isArray(children)) {
|
|
@@ -1119,7 +1122,9 @@ function decode(nodes = [], { isGraph } = {}) {
|
|
|
1119
1122
|
return { $key: decode$2({ key: node.key }) };
|
|
1120
1123
|
}
|
|
1121
1124
|
function decodeLinkNode(node) {
|
|
1122
|
-
|
|
1125
|
+
const linkObject = { $key: decode$2(node) };
|
|
1126
|
+
Object.defineProperty(linkObject, "$ref", { value: decode$1(node.path) });
|
|
1127
|
+
return linkObject;
|
|
1123
1128
|
}
|
|
1124
1129
|
return decodeChildren(nodes);
|
|
1125
1130
|
}
|
|
@@ -1148,7 +1153,7 @@ function decorate(rootGraph, rootQuery) {
|
|
|
1148
1153
|
if (range)
|
|
1149
1154
|
targetPlumGraph[PRE] = filter;
|
|
1150
1155
|
graph = construct(targetPlumGraph, range ? __spreadValues({ $key: range }, props) : props);
|
|
1151
|
-
graph
|
|
1156
|
+
Object.defineProperty(graph, "$ref", { value: $ref });
|
|
1152
1157
|
} else if (Array.isArray(query)) {
|
|
1153
1158
|
let pageKey;
|
|
1154
1159
|
graph = query.flatMap((item, i) => {
|
|
@@ -1195,8 +1200,11 @@ function decorate(rootGraph, rootQuery) {
|
|
|
1195
1200
|
throw Error("decorate.unexpected_graph");
|
|
1196
1201
|
}
|
|
1197
1202
|
}
|
|
1198
|
-
if (plumGraph[REF])
|
|
1199
|
-
graph
|
|
1203
|
+
if (plumGraph[REF]) {
|
|
1204
|
+
Object.defineProperty(graph, "$ref", {
|
|
1205
|
+
value: decode$1(plumGraph[REF])
|
|
1206
|
+
});
|
|
1207
|
+
}
|
|
1200
1208
|
return graph;
|
|
1201
1209
|
}
|
|
1202
1210
|
function descend(children, $key) {
|
|
@@ -1302,18 +1310,17 @@ function encode(value, { version, isGraph } = {}) {
|
|
|
1302
1310
|
}
|
|
1303
1311
|
const combine = isGraph ? merge : add;
|
|
1304
1312
|
function makeNode(object, key, ver) {
|
|
1305
|
-
var
|
|
1313
|
+
var _b;
|
|
1306
1314
|
if (!isDef(object))
|
|
1307
1315
|
return;
|
|
1308
1316
|
if (typeof object === "object" && object && isEmpty(object))
|
|
1309
1317
|
return;
|
|
1310
|
-
const _a2 = object || {}, { $key, $ver } = _a2,
|
|
1311
|
-
const _b = data, { $ref, $val, $chi, $put } = _b, props = __objRest(_b, ["$ref", "$val", "$chi", "$put"]);
|
|
1318
|
+
const _a2 = object || {}, { $key, $ver, $ref, $val, $chi, $put } = _a2, props = __objRest(_a2, ["$key", "$ver", "$ref", "$val", "$chi", "$put"]);
|
|
1312
1319
|
if (isDef($ver))
|
|
1313
1320
|
ver = $ver;
|
|
1314
1321
|
if (isPlainObject($key)) {
|
|
1315
1322
|
const [page, filter] = splitArgs($key);
|
|
1316
|
-
if (isGraph && page && !isDef(page.$cursor) && !isEmpty(
|
|
1323
|
+
if (isGraph && page && !isDef(page.$cursor) && ($ref || $val || $chi || $put || !isEmpty(props))) {
|
|
1317
1324
|
const node2 = makeNode(__spreadProps(__spreadValues({}, object), { $key: filter || "" }), key, ver);
|
|
1318
1325
|
node2.prefix = true;
|
|
1319
1326
|
return node2;
|
|
@@ -1391,7 +1398,7 @@ function encode(value, { version, isGraph } = {}) {
|
|
|
1391
1398
|
if (isGraph && isDef(putQuery)) {
|
|
1392
1399
|
node.children = finalize(node.children || [], putQuery, node.version);
|
|
1393
1400
|
}
|
|
1394
|
-
if (((
|
|
1401
|
+
if (((_b = node.children) == null ? void 0 : _b.length) || isDef(node.end) || isDef(node.value) || isDef(node.path)) {
|
|
1395
1402
|
return node;
|
|
1396
1403
|
}
|
|
1397
1404
|
}
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@graffy/common",
|
|
3
3
|
"description": "Common libraries that used by various Graffy modules.",
|
|
4
4
|
"author": "aravind (https://github.com/aravindet)",
|
|
5
|
-
"version": "0.15.
|
|
5
|
+
"version": "0.15.19-alpha.2",
|
|
6
6
|
"main": "./index.cjs",
|
|
7
7
|
"exports": {
|
|
8
8
|
"import": "./index.mjs",
|
|
@@ -17,8 +17,8 @@
|
|
|
17
17
|
"license": "Apache-2.0",
|
|
18
18
|
"dependencies": {
|
|
19
19
|
"lodash": "^4.17.19",
|
|
20
|
+
"nanoid": "^3.2.0",
|
|
20
21
|
"merge-async-iterators": "^0.2.1",
|
|
21
|
-
"@graffy/stream": "0.15.
|
|
22
|
-
"nanoid": "^3.2.0"
|
|
22
|
+
"@graffy/stream": "0.15.19-alpha.2"
|
|
23
23
|
}
|
|
24
24
|
}
|