@graffy/common 0.15.17 → 0.15.18

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.
Files changed (3) hide show
  1. package/index.cjs +18 -13
  2. package/index.mjs +18 -13
  3. 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.$val = true;
1068
- collection[$key] = isDef($val) ? $val : !isEmpty(item) ? item : isGraph ? null : true;
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
- return [{ $key: args, $ref }];
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
- return { $key: decode$2(node), $ref: decode$1(node.path) };
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.$ref = $ref;
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,9 @@ function decorate(rootGraph, rootQuery) {
1203
1208
  throw Error("decorate.unexpected_graph");
1204
1209
  }
1205
1210
  }
1206
- if (plumGraph[REF])
1207
- graph.$ref = decode$1(plumGraph[REF]);
1211
+ if (plumGraph[REF]) {
1212
+ Object.defineProperty(graph, "$ref", decode$1(plumGraph[REF]));
1213
+ }
1208
1214
  return graph;
1209
1215
  }
1210
1216
  function descend(children, $key) {
@@ -1310,18 +1316,17 @@ function encode(value, { version, isGraph } = {}) {
1310
1316
  }
1311
1317
  const combine = isGraph ? merge : add;
1312
1318
  function makeNode(object, key, ver) {
1313
- var _c;
1319
+ var _b;
1314
1320
  if (!isDef(object))
1315
1321
  return;
1316
1322
  if (typeof object === "object" && object && isEmpty(object))
1317
1323
  return;
1318
- const _a2 = object || {}, { $key, $ver } = _a2, data = __objRest(_a2, ["$key", "$ver"]);
1319
- const _b = data, { $ref, $val, $chi, $put } = _b, props = __objRest(_b, ["$ref", "$val", "$chi", "$put"]);
1324
+ const _a2 = object || {}, { $key, $ver, $ref, $val, $chi, $put } = _a2, props = __objRest(_a2, ["$key", "$ver", "$ref", "$val", "$chi", "$put"]);
1320
1325
  if (isDef($ver))
1321
1326
  ver = $ver;
1322
1327
  if (isPlainObject($key)) {
1323
1328
  const [page, filter] = splitArgs($key);
1324
- if (isGraph && page && !isDef(page.$cursor) && !isEmpty(data)) {
1329
+ if (isGraph && page && !isDef(page.$cursor) && ($ref || $val || $chi || $put || !isEmpty(props))) {
1325
1330
  const node2 = makeNode(__spreadProps(__spreadValues({}, object), { $key: filter || "" }), key, ver);
1326
1331
  node2.prefix = true;
1327
1332
  return node2;
@@ -1399,7 +1404,7 @@ function encode(value, { version, isGraph } = {}) {
1399
1404
  if (isGraph && isDef(putQuery)) {
1400
1405
  node.children = finalize(node.children || [], putQuery, node.version);
1401
1406
  }
1402
- if (((_c = node.children) == null ? void 0 : _c.length) || isDef(node.end) || isDef(node.value) || isDef(node.path)) {
1407
+ if (((_b = node.children) == null ? void 0 : _b.length) || isDef(node.end) || isDef(node.value) || isDef(node.path)) {
1403
1408
  return node;
1404
1409
  }
1405
1410
  }
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.$val = true;
1060
- collection[$key] = isDef($val) ? $val : !isEmpty(item) ? item : isGraph ? null : true;
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
- return [{ $key: args, $ref }];
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
- return { $key: decode$2(node), $ref: decode$1(node.path) };
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.$ref = $ref;
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,9 @@ function decorate(rootGraph, rootQuery) {
1195
1200
  throw Error("decorate.unexpected_graph");
1196
1201
  }
1197
1202
  }
1198
- if (plumGraph[REF])
1199
- graph.$ref = decode$1(plumGraph[REF]);
1203
+ if (plumGraph[REF]) {
1204
+ Object.defineProperty(graph, "$ref", decode$1(plumGraph[REF]));
1205
+ }
1200
1206
  return graph;
1201
1207
  }
1202
1208
  function descend(children, $key) {
@@ -1302,18 +1308,17 @@ function encode(value, { version, isGraph } = {}) {
1302
1308
  }
1303
1309
  const combine = isGraph ? merge : add;
1304
1310
  function makeNode(object, key, ver) {
1305
- var _c;
1311
+ var _b;
1306
1312
  if (!isDef(object))
1307
1313
  return;
1308
1314
  if (typeof object === "object" && object && isEmpty(object))
1309
1315
  return;
1310
- const _a2 = object || {}, { $key, $ver } = _a2, data = __objRest(_a2, ["$key", "$ver"]);
1311
- const _b = data, { $ref, $val, $chi, $put } = _b, props = __objRest(_b, ["$ref", "$val", "$chi", "$put"]);
1316
+ const _a2 = object || {}, { $key, $ver, $ref, $val, $chi, $put } = _a2, props = __objRest(_a2, ["$key", "$ver", "$ref", "$val", "$chi", "$put"]);
1312
1317
  if (isDef($ver))
1313
1318
  ver = $ver;
1314
1319
  if (isPlainObject($key)) {
1315
1320
  const [page, filter] = splitArgs($key);
1316
- if (isGraph && page && !isDef(page.$cursor) && !isEmpty(data)) {
1321
+ if (isGraph && page && !isDef(page.$cursor) && ($ref || $val || $chi || $put || !isEmpty(props))) {
1317
1322
  const node2 = makeNode(__spreadProps(__spreadValues({}, object), { $key: filter || "" }), key, ver);
1318
1323
  node2.prefix = true;
1319
1324
  return node2;
@@ -1391,7 +1396,7 @@ function encode(value, { version, isGraph } = {}) {
1391
1396
  if (isGraph && isDef(putQuery)) {
1392
1397
  node.children = finalize(node.children || [], putQuery, node.version);
1393
1398
  }
1394
- if (((_c = node.children) == null ? void 0 : _c.length) || isDef(node.end) || isDef(node.value) || isDef(node.path)) {
1399
+ if (((_b = node.children) == null ? void 0 : _b.length) || isDef(node.end) || isDef(node.value) || isDef(node.path)) {
1395
1400
  return node;
1396
1401
  }
1397
1402
  }
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.17",
5
+ "version": "0.15.18",
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.17",
22
- "nanoid": "^3.2.0"
22
+ "@graffy/stream": "0.15.18"
23
23
  }
24
24
  }