@omegup/msync 0.0.18 → 0.0.20
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 +6 -4
- package/index.esm.js +13 -7
- package/index.js +15 -7
- package/package.json +1 -1
package/index.d.ts
CHANGED
|
@@ -479,14 +479,16 @@ declare const $unwind: <T extends doc, K extends s, U extends doc>(k: AsLiteral<
|
|
|
479
479
|
|
|
480
480
|
type Allowed$2<K extends string> = Exclude<K, keyof (TS & ID)>;
|
|
481
481
|
type Patch<V, KK extends StrKey<V>> = ((OPick<V, Allowed$2<KK>> & ID) | (Rec<Allowed$2<KK>, N> & ID)) & TS;
|
|
482
|
-
declare const $simpleMerge: <V extends
|
|
483
|
-
declare const $merge: <V extends
|
|
482
|
+
declare const $simpleMerge: <V extends O>() => <KK extends StrKey<V>, Out extends doc, E = unknown>(out: RWCollection<Out | Replace<Out, Patch<V, KK>>, Out>, keys: ExactKeys<Allowed$2<KK>>) => StreamRunnerParam<OPick<V, Allowed$2<KK>> & ID & E, "out">;
|
|
483
|
+
declare const $merge: <V extends O>() => <KK extends StrKey<V>, Out extends doc>(out: RWCollection<Out | Replace<Out, Patch<V, KK>>, Out>, keys: ExactKeys<Allowed$2<KK>>) => StreamRunnerParam<Delta<OPick<V, Allowed$2<KK>> & ID>, "out">;
|
|
484
484
|
|
|
485
485
|
type ND = {
|
|
486
486
|
readonly deletedAt?: null;
|
|
487
487
|
};
|
|
488
488
|
type Merge<T extends ID> = (T & ND & TS) | Del;
|
|
489
|
-
declare const $
|
|
489
|
+
declare const $insertX: <T extends doc, D extends O>(out: RWCollection<Merge<T>>, expr: Expr<T, D>, map: (x: Expr<T & ND & TS, D>) => Expr<Merge<T>, D>) => StreamRunnerParam<D, "out">;
|
|
490
|
+
declare const $simpleInsert: <T extends doc>(out: RWCollection<Merge<T>>) => StreamRunnerParam<T, "out">;
|
|
491
|
+
declare const $insert: <T extends doc>(out: RWCollection<Merge<T>>) => StreamRunnerParam<Delta<T>, "out">;
|
|
490
492
|
|
|
491
493
|
type DeltaPipe<Q extends O, T extends Q, F extends HKT<O2>, G extends HKT<O3>> = {
|
|
492
494
|
with: <Q2 extends O, V extends Q2>(map: (a: Stream<Q, T, F, G>) => Stream<Q | Q2, V, F, G>) => DeltaPipe<Q | Q2, V, F, G>;
|
|
@@ -653,4 +655,4 @@ declare const enablePreAndPostImages: <T extends doc>(coll: Collection<T>) => Pr
|
|
|
653
655
|
declare const prepare: (testName?: string) => Promise<MongoClient$1>;
|
|
654
656
|
declare const makeCol: <T extends ID>(docs: readonly OptionalUnlessRequiredId<T>[], database: Db, name?: string) => Promise<Collection<T>>;
|
|
655
657
|
|
|
656
|
-
export { $accumulator, $and, $countDict, $entries, $eq, $expr, $getField, $group, $groupId, $groupMerge, $gt, $gtTs, $gte, $gteTs, $ifNull, $in, $keys, $let, $lookup, $lt, $lte, $map, $map1, $match, $matchDelta, $merge, $merge_, $ne, $nin, $nor, $or, $pushDict, $rand, $replaceWith, $set, $simpleMerge, $sum, $unwind, $unwindDelta,
|
|
658
|
+
export { $accumulator, $and, $countDict, $entries, $eq, $expr, $getField, $group, $groupId, $groupMerge, $gt, $gtTs, $gte, $gteTs, $ifNull, $in, $insert, $insertX, $keys, $let, $lookup, $lt, $lte, $map, $map1, $match, $matchDelta, $merge, $merge_, $ne, $nin, $nor, $or, $pushDict, $rand, $replaceWith, $set, $simpleInsert, $simpleMerge, $sum, $unwind, $unwindDelta, type Accumulators, type Arr, type AsLiteral, type Delta, type DeltaAccumulator, type DeltaAccumulators, Expr, type ExprHKT, type Exprs, type ExprsExact, type ExprsExactHKT, type ExprsPart, Field, type ID, type Loose, Machine, type Merge, type MergeArgs, type MergeInto, type MergeMapOArgs, type Model, type N, type NoRaw, type O, type OPick, type OPickD, type RONoRaw, type RORec, type RawStages, type Rec, type Replace, type SnapshotStreamExecutionResult, type StrKey, type Strict, type TS, Type, type WriteonlyCollection, add, and, array, ceil, comp, concat, concatArray, createIndex, ctx, current, dateAdd, dateDiff, dateLt, datePart, dayAndMonthPart, divide, type doc, enablePreAndPostImages, eq, eqTyped, except, exprMapVal, field, fieldF, fieldM, filter, filterDefined, first, firstSure, floor, from, func, gt, gte, inArray, isArray, ite, last, log, lt, lte, makeCol, map1, mapVal, max, maxDate, mergeExact, mergeExact0, mergeExpr, mergeObjects, minDate, monthPart, multiply, ne, nil, noop, type notArr, notNull, now, or, pair, prepare, rand, range, root, set, setField, size, slice, sortArray, staging, startOf, str, sub, subtract, to, toInt, val, weekPart, wrap, year };
|
package/index.esm.js
CHANGED
|
@@ -1079,18 +1079,14 @@ const $merge = () => (out, keys) => $mergeId()(out, keys, assertNotNull$1(root()
|
|
|
1079
1079
|
.expr()));
|
|
1080
1080
|
const assertNotNull$1 = (expr) => expr;
|
|
1081
1081
|
|
|
1082
|
-
const $
|
|
1082
|
+
const $insertX = (out, expr, map) => ({
|
|
1083
1083
|
teardown: c => c({
|
|
1084
1084
|
collection: out,
|
|
1085
1085
|
method: 'updateMany',
|
|
1086
1086
|
params: [{}, [{ $set: { deletedAt: '$$NOW', touchedAt: '$$CLUSTER_TIME' } }]],
|
|
1087
1087
|
}),
|
|
1088
1088
|
raw: () => {
|
|
1089
|
-
const replacer =
|
|
1090
|
-
deletedAt: ['deletedAt', current],
|
|
1091
|
-
_id: ['_id', assertNotNull(root().of('before').of('_id').expr())],
|
|
1092
|
-
touchedAt: ['touchedAt', current],
|
|
1093
|
-
}), mergeObjects(assertNotNull(root().of('after').expr()), field({ deletedAt: ['deletedAt', nil], touchedAt: ['touchedAt', current] })));
|
|
1089
|
+
const replacer = map(mergeObjects(expr, field({ deletedAt: ['deletedAt', nil], touchedAt: ['touchedAt', current] })));
|
|
1094
1090
|
return link()
|
|
1095
1091
|
.with($replaceWith_(replacer))
|
|
1096
1092
|
.with($merge_({
|
|
@@ -1101,6 +1097,12 @@ const $upsert = (out) => ({
|
|
|
1101
1097
|
})).stages;
|
|
1102
1098
|
},
|
|
1103
1099
|
});
|
|
1100
|
+
const $simpleInsert = (out) => $insertX(out, root().expr(), id$1);
|
|
1101
|
+
const $insert = (out) => $insertX(out, assertNotNull(root().of('after').expr()), x => ite(eq(root().of('after').expr())(nil), field({
|
|
1102
|
+
deletedAt: ['deletedAt', current],
|
|
1103
|
+
_id: ['_id', assertNotNull(root().of('before').of('_id').expr())],
|
|
1104
|
+
touchedAt: ['touchedAt', current],
|
|
1105
|
+
}), x));
|
|
1104
1106
|
const assertNotNull = (expr) => expr;
|
|
1105
1107
|
|
|
1106
1108
|
const T = (s) => `Timestamp(${parseInt(`${BigInt(s) / 2n ** 32n}`)}, ${parseInt(`${BigInt(s) % 2n ** 32n}`)})`;
|
|
@@ -1257,6 +1259,8 @@ const executes$1 = (view, input, streamName) => {
|
|
|
1257
1259
|
]).then(ts => next(step2_5(ts), 'handle teardown'));
|
|
1258
1260
|
const step2_5 = ([same, exists]) => async () => {
|
|
1259
1261
|
const handleTeardown = async (last) => {
|
|
1262
|
+
if (!last.data.teardown)
|
|
1263
|
+
return;
|
|
1260
1264
|
const { collection: c, method: m, params: p } = last.data.teardown;
|
|
1261
1265
|
const { collection, method, params } = {
|
|
1262
1266
|
collection: db.collection(c),
|
|
@@ -1411,6 +1415,8 @@ const executes = (view, input, streamName) => {
|
|
|
1411
1415
|
]).then(ts => next(step2_5(ts), 'handle teardown'));
|
|
1412
1416
|
const step2_5 = ([same, exists]) => async () => {
|
|
1413
1417
|
const handleTeardown = async (last) => {
|
|
1418
|
+
if (!last.data.teardown)
|
|
1419
|
+
return;
|
|
1414
1420
|
const { collection: c, method: m, params: p } = last.data.teardown;
|
|
1415
1421
|
const { collection, method, params } = {
|
|
1416
1422
|
collection: db.collection(c),
|
|
@@ -1735,4 +1741,4 @@ const makeCol = async (docs, database, name) => {
|
|
|
1735
1741
|
}
|
|
1736
1742
|
};
|
|
1737
1743
|
|
|
1738
|
-
export { $accumulator, $and, $countDict, $entries, $eq, $expr, $getField, $group, $groupId, $groupMerge, $gt, $gtTs, $gte, $gteTs, $ifNull, $in, $keys, $let, $lookup, $lt, $lte, $map, $map1, $match, $matchDelta, $merge, $merge_, $ne, $nin, $nor, $or, $pushDict, $rand, $replaceWith, $set, $simpleMerge, $sum, $unwind, $unwindDelta,
|
|
1744
|
+
export { $accumulator, $and, $countDict, $entries, $eq, $expr, $getField, $group, $groupId, $groupMerge, $gt, $gtTs, $gte, $gteTs, $ifNull, $in, $insert, $insertX, $keys, $let, $lookup, $lt, $lte, $map, $map1, $match, $matchDelta, $merge, $merge_, $ne, $nin, $nor, $or, $pushDict, $rand, $replaceWith, $set, $simpleInsert, $simpleMerge, $sum, $unwind, $unwindDelta, Field, Machine, add, and, array, ceil, comp, concat$1 as concat, concatArray, createIndex, ctx, current, dateAdd, dateDiff, dateLt, datePart, dayAndMonthPart, divide, enablePreAndPostImages, eq, eqTyped, except, exprMapVal, field, fieldF, fieldM, filter, filterDefined, first$1 as first, firstSure, floor, from, func, gt, gte, inArray, isArray, ite, last, log, lt, lte, makeCol, map1, mapVal, max, maxDate, mergeExact, mergeExact0, mergeExpr, mergeObjects, minDate, monthPart, multiply, ne, nil, noop, notNull, now, or, pair, prepare, rand, range, root, set, setField, size, slice, sortArray, staging, startOf, str, sub, subtract, to, toInt, val, weekPart, wrap, year };
|
package/index.js
CHANGED
|
@@ -1081,18 +1081,14 @@ const $merge = () => (out, keys) => $mergeId()(out, keys, assertNotNull$1(root()
|
|
|
1081
1081
|
.expr()));
|
|
1082
1082
|
const assertNotNull$1 = (expr) => expr;
|
|
1083
1083
|
|
|
1084
|
-
const $
|
|
1084
|
+
const $insertX = (out, expr, map) => ({
|
|
1085
1085
|
teardown: c => c({
|
|
1086
1086
|
collection: out,
|
|
1087
1087
|
method: 'updateMany',
|
|
1088
1088
|
params: [{}, [{ $set: { deletedAt: '$$NOW', touchedAt: '$$CLUSTER_TIME' } }]],
|
|
1089
1089
|
}),
|
|
1090
1090
|
raw: () => {
|
|
1091
|
-
const replacer =
|
|
1092
|
-
deletedAt: ['deletedAt', current],
|
|
1093
|
-
_id: ['_id', assertNotNull(root().of('before').of('_id').expr())],
|
|
1094
|
-
touchedAt: ['touchedAt', current],
|
|
1095
|
-
}), mergeObjects(assertNotNull(root().of('after').expr()), field({ deletedAt: ['deletedAt', nil], touchedAt: ['touchedAt', current] })));
|
|
1091
|
+
const replacer = map(mergeObjects(expr, field({ deletedAt: ['deletedAt', nil], touchedAt: ['touchedAt', current] })));
|
|
1096
1092
|
return link()
|
|
1097
1093
|
.with($replaceWith_(replacer))
|
|
1098
1094
|
.with($merge_({
|
|
@@ -1103,6 +1099,12 @@ const $upsert = (out) => ({
|
|
|
1103
1099
|
})).stages;
|
|
1104
1100
|
},
|
|
1105
1101
|
});
|
|
1102
|
+
const $simpleInsert = (out) => $insertX(out, root().expr(), id$1);
|
|
1103
|
+
const $insert = (out) => $insertX(out, assertNotNull(root().of('after').expr()), x => ite(eq(root().of('after').expr())(nil), field({
|
|
1104
|
+
deletedAt: ['deletedAt', current],
|
|
1105
|
+
_id: ['_id', assertNotNull(root().of('before').of('_id').expr())],
|
|
1106
|
+
touchedAt: ['touchedAt', current],
|
|
1107
|
+
}), x));
|
|
1106
1108
|
const assertNotNull = (expr) => expr;
|
|
1107
1109
|
|
|
1108
1110
|
const T = (s) => `Timestamp(${parseInt(`${BigInt(s) / 2n ** 32n}`)}, ${parseInt(`${BigInt(s) % 2n ** 32n}`)})`;
|
|
@@ -1259,6 +1261,8 @@ const executes$1 = (view, input, streamName) => {
|
|
|
1259
1261
|
]).then(ts => next(step2_5(ts), 'handle teardown'));
|
|
1260
1262
|
const step2_5 = ([same, exists]) => async () => {
|
|
1261
1263
|
const handleTeardown = async (last) => {
|
|
1264
|
+
if (!last.data.teardown)
|
|
1265
|
+
return;
|
|
1262
1266
|
const { collection: c, method: m, params: p } = last.data.teardown;
|
|
1263
1267
|
const { collection, method, params } = {
|
|
1264
1268
|
collection: db.collection(c),
|
|
@@ -1413,6 +1417,8 @@ const executes = (view, input, streamName) => {
|
|
|
1413
1417
|
]).then(ts => next(step2_5(ts), 'handle teardown'));
|
|
1414
1418
|
const step2_5 = ([same, exists]) => async () => {
|
|
1415
1419
|
const handleTeardown = async (last) => {
|
|
1420
|
+
if (!last.data.teardown)
|
|
1421
|
+
return;
|
|
1416
1422
|
const { collection: c, method: m, params: p } = last.data.teardown;
|
|
1417
1423
|
const { collection, method, params } = {
|
|
1418
1424
|
collection: db.collection(c),
|
|
@@ -1753,6 +1759,8 @@ exports.$gte = $gte;
|
|
|
1753
1759
|
exports.$gteTs = $gteTs;
|
|
1754
1760
|
exports.$ifNull = $ifNull;
|
|
1755
1761
|
exports.$in = $in;
|
|
1762
|
+
exports.$insert = $insert;
|
|
1763
|
+
exports.$insertX = $insertX;
|
|
1756
1764
|
exports.$keys = $keys;
|
|
1757
1765
|
exports.$let = $let;
|
|
1758
1766
|
exports.$lookup = $lookup;
|
|
@@ -1772,11 +1780,11 @@ exports.$pushDict = $pushDict;
|
|
|
1772
1780
|
exports.$rand = $rand;
|
|
1773
1781
|
exports.$replaceWith = $replaceWith;
|
|
1774
1782
|
exports.$set = $set;
|
|
1783
|
+
exports.$simpleInsert = $simpleInsert;
|
|
1775
1784
|
exports.$simpleMerge = $simpleMerge;
|
|
1776
1785
|
exports.$sum = $sum;
|
|
1777
1786
|
exports.$unwind = $unwind;
|
|
1778
1787
|
exports.$unwindDelta = $unwindDelta;
|
|
1779
|
-
exports.$upsert = $upsert;
|
|
1780
1788
|
exports.Field = Field;
|
|
1781
1789
|
exports.Machine = Machine;
|
|
1782
1790
|
exports.add = add;
|