@omegup/msync 0.0.75 → 0.0.77
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 +12 -7
- package/index.esm.js +35 -24
- package/index.js +36 -23
- package/package.json +1 -1
package/index.d.ts
CHANGED
|
@@ -106,9 +106,10 @@ type Stream<out Q extends O, in out T extends Q, in out F extends HKT<[O, O]>, i
|
|
|
106
106
|
type TS = {
|
|
107
107
|
readonly touchedAt: Timestamp;
|
|
108
108
|
};
|
|
109
|
-
type
|
|
109
|
+
type DDel = {
|
|
110
110
|
readonly deletedAt: Timestamp;
|
|
111
|
-
} & ID & TS
|
|
111
|
+
} & ID & TS;
|
|
112
|
+
type Del = O<DDel>;
|
|
112
113
|
type D = O<{
|
|
113
114
|
readonly deletedAt?: Timestamp | null | undefined;
|
|
114
115
|
} & ID>;
|
|
@@ -493,10 +494,12 @@ declare const $merge: <V extends O>() => <Out extends doc, SourcePart extends do
|
|
|
493
494
|
type ND = {
|
|
494
495
|
readonly deletedAt?: null;
|
|
495
496
|
};
|
|
496
|
-
type
|
|
497
|
-
|
|
498
|
-
declare const $
|
|
499
|
-
declare const $
|
|
497
|
+
type SafeE<E> = Omit<E, `$${string}` | keyof ID>;
|
|
498
|
+
type Merge<T extends doc, E> = Omit<SafeE<E>, keyof (ND & TS)> & ((T & ND & TS) | Del);
|
|
499
|
+
declare const $insertX: <T extends doc, D extends O, EEE>(out: RWCollection<Merge<T, EEE>>, expr: Expr<T, D>, map: (x: Expr<T & ND & TS & Omit<SafeE<EEE>, keyof (ND & TS)>, D>) => Expr<Merge<T, EEE>, D>, ext: ExprsExact<Omit<SafeE<EEE>, keyof (ND & TS)>, unknown>) => StreamRunnerParam<D, "out">;
|
|
500
|
+
declare const $simpleInsert: <T extends doc>(out: RWCollection<Merge<T, {}>>) => StreamRunnerParam<T, "out">;
|
|
501
|
+
declare const $insertPart: <T extends doc, EEE>(out: RWCollection<Merge<T, EEE>>, ext: ExprsExact<Omit<SafeE<EEE>, keyof (ND & TS)>, unknown>) => StreamRunnerParam<Delta<T>, "out">;
|
|
502
|
+
declare const $insert: <T extends doc>(out: RWCollection<Merge<T, {}>>) => StreamRunnerParam<Delta<T>, "out">;
|
|
500
503
|
|
|
501
504
|
declare const $group_: <V extends O>() => <ID, T extends O, C = unknown>(id: Expr<ID, T, C>, args: Accumulators<T, V, C>) => RawStages<O, T, Rec<"_id", ID> & V, C, 1>;
|
|
502
505
|
|
|
@@ -581,6 +584,8 @@ declare const last: <T, D, C>(expr: Expr<Arr<T>, D, C>) => Expr<T | null, D, C>;
|
|
|
581
584
|
type NullToOBJ<N extends null> = N extends null ? O : N;
|
|
582
585
|
declare const mergeObjects: <T1, T2, D, C = unknown, N extends null = never>(exprs_0: Expr<T1 | N, D, C>, exprs_1: Expr<T2, D, C>) => Expr<(T1 | NullToOBJ<N>) & T2, D, C>;
|
|
583
586
|
declare const anyElementTrue: <D, C = unknown>(expr: Expr<Arr<boolean>, D, C>) => Expr<boolean, D, C>;
|
|
587
|
+
type Reduce<T, V> = RORec<'value', V> & RORec<'this', T>;
|
|
588
|
+
declare const $reduce: <T, V, D, C>(input: Expr<Arr<T>, D, C>, initialValue: Expr<V, D, C>, inExpr: Expr<V, D, C & Reduce<T, V>>) => Expr<V, D, C>;
|
|
584
589
|
declare const slice: <T, D, C>(array: Expr<Arr<T>, D, C>, start: Expr<number, D, C>, end: Expr<number, D, C>) => Expr<Arr<T>, D, C>;
|
|
585
590
|
declare const except: <T, D, C>(a: Expr<Arr<T>, D, C>, b: Expr<Arr<T>, D, C>) => Expr<Arr<T>, D, C>;
|
|
586
591
|
|
|
@@ -690,4 +695,4 @@ declare const enablePreAndPostImages: <T extends doc>(coll: Collection<T>) => Pr
|
|
|
690
695
|
declare const prepare: (testName?: string) => Promise<MongoClient$1>;
|
|
691
696
|
declare const makeCol: <T extends ID>(docs: readonly OptionalUnlessRequiredId<T>[], database: Db, name?: string) => Promise<Collection<T>>;
|
|
692
697
|
|
|
693
|
-
export { $accumulator, $and, $countDict, $entries, $eq, $exists, $expr, $getField, $group, $groupId, $groupMerge, $group_, $gt, $gtTs, $gte, $gteTs, $ifNull, $in, $insert, $insertX, $keys, $let, $lookup, $lt, $lte, $map, $map0, $map1, $match, $matchDelta, $merge, $merge_, $ne, $nin, $nor, $or, $outerLookup, $pushDict, $rand, $replaceWith, $set, $simpleInsert, $simpleMerge, $sum, $type, $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 MongoTypeNames, type N, type NoRaw, type NullToOBJ, 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, anyElementTrue, 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, not, type notArr, notNull, now, or, pair, prepare, rand, range, regex, root, set, setField, single, size, slice, sortArray, staging, startOf, str, sub, subtract, to, toInt, val, weekPart, wrap, year };
|
|
698
|
+
export { $accumulator, $and, $countDict, $entries, $eq, $exists, $expr, $getField, $group, $groupId, $groupMerge, $group_, $gt, $gtTs, $gte, $gteTs, $ifNull, $in, $insert, $insertPart, $insertX, $keys, $let, $lookup, $lt, $lte, $map, $map0, $map1, $match, $matchDelta, $merge, $merge_, $ne, $nin, $nor, $or, $outerLookup, $pushDict, $rand, $reduce, $replaceWith, $set, $simpleInsert, $simpleMerge, $sum, $type, $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 MongoTypeNames, type N, type NoRaw, type NullToOBJ, 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, anyElementTrue, 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, not, type notArr, notNull, now, or, pair, prepare, rand, range, regex, root, set, setField, single, size, slice, sortArray, staging, startOf, str, sub, subtract, to, toInt, val, weekPart, wrap, year };
|
package/index.esm.js
CHANGED
|
@@ -339,6 +339,7 @@ const assertEqual = () => ({
|
|
|
339
339
|
});
|
|
340
340
|
const omitRORec = () => assertEqual();
|
|
341
341
|
const omitPick = () => assertEqual();
|
|
342
|
+
const translateOmit = () => assertEqual();
|
|
342
343
|
|
|
343
344
|
const asStages = (x) => x;
|
|
344
345
|
const concatStages = (part1, part2) => asStages([...part1, ...part2]);
|
|
@@ -414,7 +415,7 @@ const mergeObjects = (...exprs) => asExpr({
|
|
|
414
415
|
const anyElementTrue = (expr) => asExpr({
|
|
415
416
|
raw: f => asExprRaw({ $anyElementTrue: expr.raw(f).get() }),
|
|
416
417
|
});
|
|
417
|
-
const reduce = (input, initialValue, inExpr) => asExpr({
|
|
418
|
+
const $reduce = (input, initialValue, inExpr) => asExpr({
|
|
418
419
|
raw: f => asExprRaw({
|
|
419
420
|
$reduce: {
|
|
420
421
|
input: input.raw(f).get(),
|
|
@@ -442,7 +443,7 @@ const except = (a, b) => {
|
|
|
442
443
|
return $let({
|
|
443
444
|
res: [
|
|
444
445
|
'res',
|
|
445
|
-
reduce(a, field({ out: ['out', array()], except: ['except', b] }), $let({
|
|
446
|
+
$reduce(a, field({ out: ['out', array()], except: ['except', b] }), $let({
|
|
446
447
|
indexInExcept: ['indexInExcept', indexOfArray(except, curr)],
|
|
447
448
|
}, ite(gte(indexInExcept, val(0)), field({
|
|
448
449
|
out: ['out', out],
|
|
@@ -1378,30 +1379,40 @@ const $simpleMerge = () => (out, keys) => $mergeX(out, keys, root(), id$1);
|
|
|
1378
1379
|
const $merge = () => (out, keys) => $mergeId()(out, keys, assertNotNull$1(root().of('before').of('_id').expr()));
|
|
1379
1380
|
const assertNotNull$1 = (expr) => expr;
|
|
1380
1381
|
|
|
1381
|
-
const $insertX = (out, expr, map) =>
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
|
|
1382
|
+
const $insertX = (out, expr, map, ext) => {
|
|
1383
|
+
const filter = mapExactToObject(ext, v => ({ $eq: v }));
|
|
1384
|
+
return {
|
|
1385
|
+
teardown: c => c({
|
|
1386
|
+
collection: out,
|
|
1387
|
+
method: 'updateMany',
|
|
1388
|
+
params: [
|
|
1389
|
+
filter,
|
|
1390
|
+
[{ $set: { deletedAt: '$$NOW', touchedAt: '$$CLUSTER_TIME' } }],
|
|
1391
|
+
],
|
|
1392
|
+
}),
|
|
1393
|
+
raw: () => {
|
|
1394
|
+
const replacer = map(mergeObjects(expr, field(mergeExpr(ext, {
|
|
1395
|
+
deletedAt: ['deletedAt', nil],
|
|
1396
|
+
touchedAt: ['touchedAt', current],
|
|
1397
|
+
}))));
|
|
1398
|
+
return link()
|
|
1399
|
+
.with($replaceWith_(replacer))
|
|
1400
|
+
.with($merge_({
|
|
1401
|
+
into: out,
|
|
1402
|
+
on: root().of('_id'),
|
|
1403
|
+
whenMatched: 'merge',
|
|
1404
|
+
whenNotMatched: 'insert',
|
|
1405
|
+
})).stages;
|
|
1406
|
+
},
|
|
1407
|
+
};
|
|
1408
|
+
};
|
|
1409
|
+
const $simpleInsert = (out) => $insertX(out, root().expr(), id$1, {});
|
|
1410
|
+
const $insertPart = (out, ext) => $insertX(out, assertNotNull(root().of('after').expr()), x => ite(eq(root().of('after').expr())(nil), field(mergeExpr(translateOmit().forward(ext), {
|
|
1401
1411
|
deletedAt: ['deletedAt', current],
|
|
1402
1412
|
_id: ['_id', assertNotNull(root().of('before').of('_id').expr())],
|
|
1403
1413
|
touchedAt: ['touchedAt', current],
|
|
1404
|
-
}), x));
|
|
1414
|
+
})), x), ext);
|
|
1415
|
+
const $insert = (out) => $insertPart(out, {});
|
|
1405
1416
|
const assertNotNull = (expr) => expr;
|
|
1406
1417
|
|
|
1407
1418
|
const T = (s) => `Timestamp(${parseInt(`${BigInt(s) / 2n ** 32n}`)}, ${parseInt(`${BigInt(s) % 2n ** 32n}`)})`;
|
|
@@ -1899,4 +1910,4 @@ const makeCol = async (docs, database, name) => {
|
|
|
1899
1910
|
}
|
|
1900
1911
|
};
|
|
1901
1912
|
|
|
1902
|
-
export { $accumulator, $and, $countDict, $entries, $eq, $exists, $expr, $getField, $group, $groupId, $groupMerge, $group_, $gt, $gtTs, $gte, $gteTs, $ifNull, $in, $insert, $insertX, $keys, $let, $lookup, $lt, $lte, $map, $map0, $map1, $match, $matchDelta, $merge, $merge_, $ne, $nin, $nor, $or, $outerLookup, $pushDict, $rand, $replaceWith, $set, $simpleInsert, $simpleMerge, $sum, $type, $unwind, $unwindDelta, Field, Machine, add, and, anyElementTrue, 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, not, notNull, now, or, pair, prepare, rand, range, regex, root, set, setField, single, size, slice, sortArray, staging, startOf, str, sub, subtract, to, toInt, val, weekPart, wrap, year };
|
|
1913
|
+
export { $accumulator, $and, $countDict, $entries, $eq, $exists, $expr, $getField, $group, $groupId, $groupMerge, $group_, $gt, $gtTs, $gte, $gteTs, $ifNull, $in, $insert, $insertPart, $insertX, $keys, $let, $lookup, $lt, $lte, $map, $map0, $map1, $match, $matchDelta, $merge, $merge_, $ne, $nin, $nor, $or, $outerLookup, $pushDict, $rand, $reduce, $replaceWith, $set, $simpleInsert, $simpleMerge, $sum, $type, $unwind, $unwindDelta, Field, Machine, add, and, anyElementTrue, 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, not, notNull, now, or, pair, prepare, rand, range, regex, root, set, setField, single, size, slice, sortArray, staging, startOf, str, sub, subtract, to, toInt, val, weekPart, wrap, year };
|
package/index.js
CHANGED
|
@@ -341,6 +341,7 @@ const assertEqual = () => ({
|
|
|
341
341
|
});
|
|
342
342
|
const omitRORec = () => assertEqual();
|
|
343
343
|
const omitPick = () => assertEqual();
|
|
344
|
+
const translateOmit = () => assertEqual();
|
|
344
345
|
|
|
345
346
|
const asStages = (x) => x;
|
|
346
347
|
const concatStages = (part1, part2) => asStages([...part1, ...part2]);
|
|
@@ -416,7 +417,7 @@ const mergeObjects = (...exprs) => asExpr({
|
|
|
416
417
|
const anyElementTrue = (expr) => asExpr({
|
|
417
418
|
raw: f => asExprRaw({ $anyElementTrue: expr.raw(f).get() }),
|
|
418
419
|
});
|
|
419
|
-
const reduce = (input, initialValue, inExpr) => asExpr({
|
|
420
|
+
const $reduce = (input, initialValue, inExpr) => asExpr({
|
|
420
421
|
raw: f => asExprRaw({
|
|
421
422
|
$reduce: {
|
|
422
423
|
input: input.raw(f).get(),
|
|
@@ -444,7 +445,7 @@ const except = (a, b) => {
|
|
|
444
445
|
return $let({
|
|
445
446
|
res: [
|
|
446
447
|
'res',
|
|
447
|
-
reduce(a, field({ out: ['out', array()], except: ['except', b] }), $let({
|
|
448
|
+
$reduce(a, field({ out: ['out', array()], except: ['except', b] }), $let({
|
|
448
449
|
indexInExcept: ['indexInExcept', indexOfArray(except, curr)],
|
|
449
450
|
}, ite(gte(indexInExcept, val(0)), field({
|
|
450
451
|
out: ['out', out],
|
|
@@ -1380,30 +1381,40 @@ const $simpleMerge = () => (out, keys) => $mergeX(out, keys, root(), id$1);
|
|
|
1380
1381
|
const $merge = () => (out, keys) => $mergeId()(out, keys, assertNotNull$1(root().of('before').of('_id').expr()));
|
|
1381
1382
|
const assertNotNull$1 = (expr) => expr;
|
|
1382
1383
|
|
|
1383
|
-
const $insertX = (out, expr, map) =>
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
|
|
1401
|
-
|
|
1402
|
-
|
|
1384
|
+
const $insertX = (out, expr, map, ext) => {
|
|
1385
|
+
const filter = mapExactToObject(ext, v => ({ $eq: v }));
|
|
1386
|
+
return {
|
|
1387
|
+
teardown: c => c({
|
|
1388
|
+
collection: out,
|
|
1389
|
+
method: 'updateMany',
|
|
1390
|
+
params: [
|
|
1391
|
+
filter,
|
|
1392
|
+
[{ $set: { deletedAt: '$$NOW', touchedAt: '$$CLUSTER_TIME' } }],
|
|
1393
|
+
],
|
|
1394
|
+
}),
|
|
1395
|
+
raw: () => {
|
|
1396
|
+
const replacer = map(mergeObjects(expr, field(mergeExpr(ext, {
|
|
1397
|
+
deletedAt: ['deletedAt', nil],
|
|
1398
|
+
touchedAt: ['touchedAt', current],
|
|
1399
|
+
}))));
|
|
1400
|
+
return link()
|
|
1401
|
+
.with($replaceWith_(replacer))
|
|
1402
|
+
.with($merge_({
|
|
1403
|
+
into: out,
|
|
1404
|
+
on: root().of('_id'),
|
|
1405
|
+
whenMatched: 'merge',
|
|
1406
|
+
whenNotMatched: 'insert',
|
|
1407
|
+
})).stages;
|
|
1408
|
+
},
|
|
1409
|
+
};
|
|
1410
|
+
};
|
|
1411
|
+
const $simpleInsert = (out) => $insertX(out, root().expr(), id$1, {});
|
|
1412
|
+
const $insertPart = (out, ext) => $insertX(out, assertNotNull(root().of('after').expr()), x => ite(eq(root().of('after').expr())(nil), field(mergeExpr(translateOmit().forward(ext), {
|
|
1403
1413
|
deletedAt: ['deletedAt', current],
|
|
1404
1414
|
_id: ['_id', assertNotNull(root().of('before').of('_id').expr())],
|
|
1405
1415
|
touchedAt: ['touchedAt', current],
|
|
1406
|
-
}), x));
|
|
1416
|
+
})), x), ext);
|
|
1417
|
+
const $insert = (out) => $insertPart(out, {});
|
|
1407
1418
|
const assertNotNull = (expr) => expr;
|
|
1408
1419
|
|
|
1409
1420
|
const T = (s) => `Timestamp(${parseInt(`${BigInt(s) / 2n ** 32n}`)}, ${parseInt(`${BigInt(s) % 2n ** 32n}`)})`;
|
|
@@ -1920,6 +1931,7 @@ exports.$gteTs = $gteTs;
|
|
|
1920
1931
|
exports.$ifNull = $ifNull;
|
|
1921
1932
|
exports.$in = $in;
|
|
1922
1933
|
exports.$insert = $insert;
|
|
1934
|
+
exports.$insertPart = $insertPart;
|
|
1923
1935
|
exports.$insertX = $insertX;
|
|
1924
1936
|
exports.$keys = $keys;
|
|
1925
1937
|
exports.$let = $let;
|
|
@@ -1940,6 +1952,7 @@ exports.$or = $or;
|
|
|
1940
1952
|
exports.$outerLookup = $outerLookup;
|
|
1941
1953
|
exports.$pushDict = $pushDict;
|
|
1942
1954
|
exports.$rand = $rand;
|
|
1955
|
+
exports.$reduce = $reduce;
|
|
1943
1956
|
exports.$replaceWith = $replaceWith;
|
|
1944
1957
|
exports.$set = $set;
|
|
1945
1958
|
exports.$simpleInsert = $simpleInsert;
|