@omegup/msync 0.0.96 → 0.0.98
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.d.ts +2 -2
- package/index.esm.js +7 -6
- package/index.js +7 -6
- package/package.json +1 -1
package/index.d.ts
CHANGED
|
@@ -491,8 +491,8 @@ declare const $unwind: <TT extends O, K extends s, U extends doc>(k: AsLiteral<K
|
|
|
491
491
|
type Allowed$2<K extends string> = Exclude<K, keyof (TS & ID)>;
|
|
492
492
|
type Patch<V, KK extends StrKey<V> = StrKey<V>> = ((OPick<V, Allowed$2<KK>> & ID) | (Rec<Allowed$2<KK>, N> & ID)) & TS;
|
|
493
493
|
type TakeDoc<V, E = ID, KK extends StrKey<V> = StrKey<V>> = OPick<V, Allowed$2<KK>> & E;
|
|
494
|
-
declare const $simpleMerge: <V extends O>() => <Source extends doc, Out extends doc>(out: RWCollection<Out | Replace<Out, Patch<V>>, Out>, keys: ExprsExact<TakeDoc<V, unknown>, Source
|
|
495
|
-
declare const $merge: <V extends O>() => <Out extends doc, SourcePart extends doc>(out: RWCollection<Out | Replace<Out, Patch<V>>, Out>, keys: ExprsExact<TakeDoc<V, unknown>, SourcePart
|
|
494
|
+
declare const $simpleMerge: <V extends O>() => <Source extends doc, Out extends doc>(out: RWCollection<Out | Replace<Out, Patch<V>>, Out>, keys: ExprsExact<TakeDoc<V, unknown>, Source>, whenNotMatched?: "fail" | "discard") => StreamRunnerParam<Source, "out">;
|
|
495
|
+
declare const $merge: <V extends O>() => <Out extends doc, SourcePart extends doc>(out: RWCollection<Out | Replace<Out, Patch<V>>, Out>, keys: ExprsExact<TakeDoc<V, unknown>, SourcePart>, whenNotMatched?: "fail" | "discard") => StreamRunnerParam<Delta<SourcePart>, "out">;
|
|
496
496
|
|
|
497
497
|
type ND = {
|
|
498
498
|
readonly deletedAt?: null;
|
package/index.esm.js
CHANGED
|
@@ -1364,7 +1364,7 @@ const $replaceWith = (expr) => ({
|
|
|
1364
1364
|
lin: $replaceWith_(expr),
|
|
1365
1365
|
});
|
|
1366
1366
|
|
|
1367
|
-
const $mergeX = (out, keys, f, map) => ({
|
|
1367
|
+
const $mergeX = (out, keys, f, map, whenNotMatched = 'fail') => ({
|
|
1368
1368
|
raw: (first) => {
|
|
1369
1369
|
const patch = mapExact(keys, v => sub(v, f));
|
|
1370
1370
|
const or = field(omitPick().backward(spread(patch, {
|
|
@@ -1377,7 +1377,7 @@ const $mergeX = (out, keys, f, map) => ({
|
|
|
1377
1377
|
.with($merge_({
|
|
1378
1378
|
into: out,
|
|
1379
1379
|
on: root().of('_id'),
|
|
1380
|
-
whenNotMatched
|
|
1380
|
+
whenNotMatched,
|
|
1381
1381
|
stages: true,
|
|
1382
1382
|
whenMatched: asStages([
|
|
1383
1383
|
{ $replaceWith: { old: '$$ROOT', merged: { $mergeObjects: ['$$ROOT', '$$new'] } } },
|
|
@@ -1408,17 +1408,17 @@ const $mergeX = (out, keys, f, map) => ({
|
|
|
1408
1408
|
],
|
|
1409
1409
|
}),
|
|
1410
1410
|
});
|
|
1411
|
-
const $mergeId = () => (out, keys, id) => {
|
|
1411
|
+
const $mergeId = () => (out, keys, id, whenNotMatched = 'fail') => {
|
|
1412
1412
|
const omRORec = omitRORec();
|
|
1413
1413
|
return $mergeX(out, keys, root().of('after'), or => {
|
|
1414
1414
|
return ite(eqTyped(root().of('after').expr(), nil), field(omRORec.backward(spread(mapExact(keys, () => nil), {
|
|
1415
1415
|
_id: ['_id', id],
|
|
1416
1416
|
touchedAt: ['touchedAt', current],
|
|
1417
1417
|
}))), or);
|
|
1418
|
-
});
|
|
1418
|
+
}, whenNotMatched);
|
|
1419
1419
|
};
|
|
1420
|
-
const $simpleMerge = () => (out, keys) => $mergeX(out, keys, root(), id$1);
|
|
1421
|
-
const $merge = () => (out, keys) => $mergeId()(out, keys, assertNotNull$1(root().of('before').of('_id').expr()));
|
|
1420
|
+
const $simpleMerge = () => (out, keys, whenNotMatched = 'fail') => $mergeX(out, keys, root(), id$1, whenNotMatched);
|
|
1421
|
+
const $merge = () => (out, keys, whenNotMatched = 'fail') => $mergeId()(out, keys, assertNotNull$1(root().of('before').of('_id').expr()), whenNotMatched);
|
|
1422
1422
|
const assertNotNull$1 = (expr) => expr;
|
|
1423
1423
|
|
|
1424
1424
|
const $insertX = (out, expr, map, ext, extExpr) => {
|
|
@@ -1700,6 +1700,7 @@ const executes$2 = (view, input, streamName, skip = false, after) => {
|
|
|
1700
1700
|
log('teardown done', `db['${snapshotCollection.collectionName}'].drop()`, ...out);
|
|
1701
1701
|
};
|
|
1702
1702
|
if (!same) {
|
|
1703
|
+
log('not same, new data', data);
|
|
1703
1704
|
await handleTeardown(exists ?? { data });
|
|
1704
1705
|
}
|
|
1705
1706
|
await after?.();
|
package/index.js
CHANGED
|
@@ -1366,7 +1366,7 @@ const $replaceWith = (expr) => ({
|
|
|
1366
1366
|
lin: $replaceWith_(expr),
|
|
1367
1367
|
});
|
|
1368
1368
|
|
|
1369
|
-
const $mergeX = (out, keys, f, map) => ({
|
|
1369
|
+
const $mergeX = (out, keys, f, map, whenNotMatched = 'fail') => ({
|
|
1370
1370
|
raw: (first) => {
|
|
1371
1371
|
const patch = mapExact(keys, v => sub(v, f));
|
|
1372
1372
|
const or = field(omitPick().backward(spread(patch, {
|
|
@@ -1379,7 +1379,7 @@ const $mergeX = (out, keys, f, map) => ({
|
|
|
1379
1379
|
.with($merge_({
|
|
1380
1380
|
into: out,
|
|
1381
1381
|
on: root().of('_id'),
|
|
1382
|
-
whenNotMatched
|
|
1382
|
+
whenNotMatched,
|
|
1383
1383
|
stages: true,
|
|
1384
1384
|
whenMatched: asStages([
|
|
1385
1385
|
{ $replaceWith: { old: '$$ROOT', merged: { $mergeObjects: ['$$ROOT', '$$new'] } } },
|
|
@@ -1410,17 +1410,17 @@ const $mergeX = (out, keys, f, map) => ({
|
|
|
1410
1410
|
],
|
|
1411
1411
|
}),
|
|
1412
1412
|
});
|
|
1413
|
-
const $mergeId = () => (out, keys, id) => {
|
|
1413
|
+
const $mergeId = () => (out, keys, id, whenNotMatched = 'fail') => {
|
|
1414
1414
|
const omRORec = omitRORec();
|
|
1415
1415
|
return $mergeX(out, keys, root().of('after'), or => {
|
|
1416
1416
|
return ite(eqTyped(root().of('after').expr(), nil), field(omRORec.backward(spread(mapExact(keys, () => nil), {
|
|
1417
1417
|
_id: ['_id', id],
|
|
1418
1418
|
touchedAt: ['touchedAt', current],
|
|
1419
1419
|
}))), or);
|
|
1420
|
-
});
|
|
1420
|
+
}, whenNotMatched);
|
|
1421
1421
|
};
|
|
1422
|
-
const $simpleMerge = () => (out, keys) => $mergeX(out, keys, root(), id$1);
|
|
1423
|
-
const $merge = () => (out, keys) => $mergeId()(out, keys, assertNotNull$1(root().of('before').of('_id').expr()));
|
|
1422
|
+
const $simpleMerge = () => (out, keys, whenNotMatched = 'fail') => $mergeX(out, keys, root(), id$1, whenNotMatched);
|
|
1423
|
+
const $merge = () => (out, keys, whenNotMatched = 'fail') => $mergeId()(out, keys, assertNotNull$1(root().of('before').of('_id').expr()), whenNotMatched);
|
|
1424
1424
|
const assertNotNull$1 = (expr) => expr;
|
|
1425
1425
|
|
|
1426
1426
|
const $insertX = (out, expr, map, ext, extExpr) => {
|
|
@@ -1702,6 +1702,7 @@ const executes$2 = (view, input, streamName, skip = false, after) => {
|
|
|
1702
1702
|
log('teardown done', `db['${snapshotCollection.collectionName}'].drop()`, ...out);
|
|
1703
1703
|
};
|
|
1704
1704
|
if (!same) {
|
|
1705
|
+
log('not same, new data', data);
|
|
1705
1706
|
await handleTeardown(exists ?? { data });
|
|
1706
1707
|
}
|
|
1707
1708
|
await after?.();
|