@omegup/msync 0.0.86 → 0.0.88

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.esm.js CHANGED
@@ -1,5 +1,6 @@
1
- import { SynchronousPromise } from 'synchronous-promise';
2
1
  import crypto$1 from 'crypto';
2
+ import { canonicalize } from 'json-canonicalize';
3
+ import { SynchronousPromise } from 'synchronous-promise';
3
4
  import { UUID, MongoClient } from 'mongodb';
4
5
  import { writeFile } from 'fs/promises';
5
6
 
@@ -1093,14 +1094,17 @@ const $unwind = (k, dict, middle) => {
1093
1094
 
1094
1095
  const $lookupDelta = ({ field1, field2 }, { coll, exec, input }, k1, k2, k, includeNull1, includeNull2) => {
1095
1096
  const omit = omitRORec();
1097
+ const hash = crypto$1.createHash('md5').update(canonicalize(input)).digest('base64url');
1098
+ const ss = (f) => to($ifNull(root().of(f).of(k1).with(field1).expr(), val(hash)));
1096
1099
  return link()
1097
1100
  .with($replaceWithDelta(field(map1(k1, root().expr()))))
1101
+ .with($set_(set()({ bId: ['bId', ss('before')], aId: ['aId', ss('after')] })))
1098
1102
  .with($simpleLookup_({
1099
1103
  coll,
1100
1104
  k: 'a',
1101
1105
  fields: {
1102
1106
  foreign: root().of('before').with(field2),
1103
- local: root().of('after').of(k1).with(field1),
1107
+ local: root().of('aId'),
1104
1108
  },
1105
1109
  vars: {},
1106
1110
  pipeline: link().with(input).with(exec).stages,
@@ -1110,7 +1114,7 @@ const $lookupDelta = ({ field1, field2 }, { coll, exec, input }, k1, k2, k, incl
1110
1114
  k: 'b',
1111
1115
  fields: {
1112
1116
  foreign: root().of('before').with(field2),
1113
- local: root().of('before').of(k1).with(field1),
1117
+ local: root().of('bId'),
1114
1118
  },
1115
1119
  vars: {},
1116
1120
  pipeline: link().with(input).with(exec).stages,
package/index.js CHANGED
@@ -1,7 +1,8 @@
1
1
  'use strict';
2
2
 
3
- var synchronousPromise = require('synchronous-promise');
4
3
  var crypto$1 = require('crypto');
4
+ var jsonCanonicalize = require('json-canonicalize');
5
+ var synchronousPromise = require('synchronous-promise');
5
6
  var mongodb = require('mongodb');
6
7
  var promises = require('fs/promises');
7
8
 
@@ -1095,14 +1096,17 @@ const $unwind = (k, dict, middle) => {
1095
1096
 
1096
1097
  const $lookupDelta = ({ field1, field2 }, { coll, exec, input }, k1, k2, k, includeNull1, includeNull2) => {
1097
1098
  const omit = omitRORec();
1099
+ const hash = crypto$1.createHash('md5').update(jsonCanonicalize.canonicalize(input)).digest('base64url');
1100
+ const ss = (f) => to($ifNull(root().of(f).of(k1).with(field1).expr(), val(hash)));
1098
1101
  return link()
1099
1102
  .with($replaceWithDelta(field(map1(k1, root().expr()))))
1103
+ .with($set_(set()({ bId: ['bId', ss('before')], aId: ['aId', ss('after')] })))
1100
1104
  .with($simpleLookup_({
1101
1105
  coll,
1102
1106
  k: 'a',
1103
1107
  fields: {
1104
1108
  foreign: root().of('before').with(field2),
1105
- local: root().of('after').of(k1).with(field1),
1109
+ local: root().of('aId'),
1106
1110
  },
1107
1111
  vars: {},
1108
1112
  pipeline: link().with(input).with(exec).stages,
@@ -1112,7 +1116,7 @@ const $lookupDelta = ({ field1, field2 }, { coll, exec, input }, k1, k2, k, incl
1112
1116
  k: 'b',
1113
1117
  fields: {
1114
1118
  foreign: root().of('before').with(field2),
1115
- local: root().of('before').of(k1).with(field1),
1119
+ local: root().of('bId'),
1116
1120
  },
1117
1121
  vars: {},
1118
1122
  pipeline: link().with(input).with(exec).stages,
package/package.json CHANGED
@@ -3,10 +3,11 @@
3
3
  "module": "index.esm.js",
4
4
  "typings": "index.d.ts",
5
5
  "name": "@omegup/msync",
6
- "version": "0.0.86",
6
+ "version": "0.0.88",
7
7
  "dependencies": {
8
8
  "dayjs": "^1.11.9",
9
9
  "dotenv": "^16.3.1",
10
+ "json-canonicalize": "^2.0.0",
10
11
  "mongodb": "^6.8.0"
11
12
  }
12
13
  }