@omegup/msync 0.1.3 → 0.1.5
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 +10 -4
- package/index.esm.js +19 -13
- package/index.js +20 -12
- package/package.json +1 -1
package/index.d.ts
CHANGED
|
@@ -187,7 +187,10 @@ type DeltaAccumulator<in out Doc, in out T, in out Ctx = unknown> = {
|
|
|
187
187
|
merge: <D, C = Ctx>(a: Expr<T | N, D, C>, b: Expr<T, D, C>) => Expr<T, D, C>;
|
|
188
188
|
};
|
|
189
189
|
|
|
190
|
-
declare const concat:
|
|
190
|
+
declare const concat: {
|
|
191
|
+
<D, C>(...expr: Expr<string, D, C>[]): Expr<string, D, C>;
|
|
192
|
+
<D, C>(...expr: Expr<string | N, D, C>[]): Expr<string | N, D, C>;
|
|
193
|
+
};
|
|
191
194
|
declare const regex: <D, C>(expr: Expr<string, D, C>, regex: Expr<string, D, C>, options?: Expr<string, D, C>) => Expr<boolean, D, C>;
|
|
192
195
|
declare const str: <D, C>(expr: Expr<unknown, D, C>) => Expr<string, D, C>;
|
|
193
196
|
declare const toInt: <D, C>(expr: Expr<unknown, D, C>) => Expr<number, D, C>;
|
|
@@ -489,6 +492,7 @@ type s = string;
|
|
|
489
492
|
type TOf<TT, K extends string> = doc & Omit<TT, K>;
|
|
490
493
|
declare const $unwind: <TT extends O, K extends s, U extends doc>(k: AsLiteral<K>, dict: RORec<K, "key"> & RORec<"_id", "id">, middle?: string) => DeltaStages<O, TOf<TT, K> & Rec<K, Arr<U>>, TOf<TT, K> & Rec<K, U>>;
|
|
491
494
|
|
|
495
|
+
type OutInputE<T, E, A = T | null> = ID & Rec<'after', A> & E;
|
|
492
496
|
type Allowed$2<K extends string> = Exclude<K, keyof (TS & ID)>;
|
|
493
497
|
type Patch<V, KK extends StrKey<V> = StrKey<V>> = ((OPick<V, Allowed$2<KK>> & ID) | (Rec<Allowed$2<KK>, N> & ID)) & TS;
|
|
494
498
|
type TakeDoc<V, E = ID, KK extends StrKey<V> = StrKey<V>> = OPick<V, Allowed$2<KK>> & E;
|
|
@@ -496,8 +500,10 @@ type ND$1 = {
|
|
|
496
500
|
readonly deletedAt?: null;
|
|
497
501
|
};
|
|
498
502
|
type SafeE$1<E> = Omit<E, `$${string}` | keyof ID>;
|
|
503
|
+
declare const $mergeId: <V extends O>() => <SourcePart extends doc, Out extends doc, E = unknown, EEE extends RORec<string, rawItem> = {}>(out: RWCollection<Out | Replace<Out, Patch<V>>, Out>, keys: ExprsExact<TakeDoc<V, unknown>, SourcePart>, id: Expr<string, OutInputE<TakeDoc<V>, E, null>>, ext: Exact<Omit<SafeE$1<EEE>, keyof (ND$1 & TS)>, IdHKT>, whenNotMatched: "fail" | "discard") => StreamRunnerParam<OutInputE<SourcePart, E>, "out">;
|
|
499
504
|
declare const $simpleMergePart: <V extends O>() => <Source extends doc, Out extends doc, EEE extends RORec<string, rawItem>>(out: RWCollection<Out | Replace<Out, Patch<V>>, Out>, keys: ExprsExact<TakeDoc<V, unknown>, Source>, whenNotMatched: "fail" | "discard", ext: Exact<Omit<SafeE$1<EEE>, keyof (ND$1 & TS)>, IdHKT>) => StreamRunnerParam<Source, "out">;
|
|
500
505
|
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">;
|
|
506
|
+
declare const $mergePart: <V extends O>() => <Out extends doc, SourcePart extends doc, EEE extends RORec<string, rawItem>>(out: RWCollection<Out | Replace<Out, Patch<V>>, Out>, keys: ExprsExact<TakeDoc<V, unknown>, SourcePart>, ext: Exact<Omit<SafeE$1<EEE>, keyof (ND$1 & TS)>, IdHKT>, whenNotMatched?: "fail" | "discard") => StreamRunnerParam<Delta<SourcePart>, "out">;
|
|
501
507
|
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">;
|
|
502
508
|
|
|
503
509
|
type ND = {
|
|
@@ -537,13 +543,13 @@ interface StreamRunnerHKT extends HKT<O2> {
|
|
|
537
543
|
interface StagesHKT extends HKT<O3> {
|
|
538
544
|
readonly out: RORec<'lin', RawStages<I<O3, this>[0], I<O3, this>[1], I<O3, this>[2], unknown, 1>>;
|
|
539
545
|
}
|
|
540
|
-
declare const from: <V extends Model, KK extends StrKey<V>>(view: View<V, Allowed<KK>>, streamName: string,
|
|
546
|
+
declare const from: <V extends Model, KK extends StrKey<V>>(view: View<V, Allowed<KK>>, streamName: string, needs?: Partial<Record<KK, 0 | 1>>) => DeltaPipe<AllowedPick<V, KK>, AllowedPick<V, KK>, StreamRunnerHKT, StagesHKT>;
|
|
541
547
|
|
|
542
548
|
type SingleResult<out Result> = <Result2>(finalInput: RawStages<unknown, Result, Result2>) => Stages<unknown, Result2, unknown>;
|
|
543
549
|
interface SnapshotStreamHKT2 extends HKT<O2> {
|
|
544
550
|
readonly out: SingleResult<I<O2, this>[1]>;
|
|
545
551
|
}
|
|
546
|
-
declare const single: <V extends Model, KK extends StrKey<V>>(view: View<V, Allowed$1<KK>>) => DeltaPipe<AllowedPick$1<V, KK>, AllowedPick$1<V, KK>, SnapshotStreamHKT2, DeltaHKT>;
|
|
552
|
+
declare const single: <V extends Model, KK extends StrKey<V>>(view: View<V, Allowed$1<KK>>, needs?: Partial<Record<KK, 0 | 1>>) => DeltaPipe<AllowedPick$1<V, KK>, AllowedPick$1<V, KK>, SnapshotStreamHKT2, DeltaHKT>;
|
|
547
553
|
|
|
548
554
|
declare const max: <D, C>(...expr: Expr<number, D, C>[]) => Expr<number, D, C>;
|
|
549
555
|
declare const lt: <D, C>(expr_0: Expr<number, D, C>, expr_1: Expr<number, D, C>) => Expr<boolean, D, C>;
|
|
@@ -704,4 +710,4 @@ declare const enablePreAndPostImages: <T extends doc>(coll: Collection<T>) => Pr
|
|
|
704
710
|
declare const prepare: (testName?: string) => Promise<MongoClient$1>;
|
|
705
711
|
declare const makeCol: <T extends ID>(docs: readonly OptionalUnlessRequiredId<T>[], database: Db, name?: string) => Promise<Collection<T>>;
|
|
706
712
|
|
|
707
|
-
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, $merge2, $merge_, $ne, $nin, $nor, $or, $outerLookup, $pushDict, $rand, $reduce, $replaceWith, $set, $simpleInsert, $simpleMerge, $simpleMergePart, $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 };
|
|
713
|
+
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, $merge2, $mergeId, $mergePart, $merge_, $ne, $nin, $nor, $or, $outerLookup, $pushDict, $rand, $reduce, $replaceWith, $set, $simpleInsert, $simpleMerge, $simpleMergePart, $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
|
@@ -1400,7 +1400,12 @@ const $mergeX = (out, keys, f, map, whenNotMatched = 'fail', ext) => {
|
|
|
1400
1400
|
$cond: {
|
|
1401
1401
|
if: {
|
|
1402
1402
|
$eq: [
|
|
1403
|
-
{
|
|
1403
|
+
{
|
|
1404
|
+
$mergeObjects: [
|
|
1405
|
+
'$old',
|
|
1406
|
+
{ deletedAt: { $ifNull: ['$old.deletedAt', null] } },
|
|
1407
|
+
],
|
|
1408
|
+
},
|
|
1404
1409
|
{ $mergeObjects: ['$merged', { touchedAt: '$old.touchedAt' }] },
|
|
1405
1410
|
],
|
|
1406
1411
|
},
|
|
@@ -1436,7 +1441,8 @@ const $mergeId = () => (out, keys, id, ext, whenNotMatched) => {
|
|
|
1436
1441
|
};
|
|
1437
1442
|
const $simpleMergePart = () => (out, keys, whenNotMatched, ext) => $mergeX(out, keys, root(), id$1, whenNotMatched, ext);
|
|
1438
1443
|
const $simpleMerge = () => (out, keys, whenNotMatched = 'fail') => $mergeX(out, keys, root(), id$1, whenNotMatched, {});
|
|
1439
|
-
const $
|
|
1444
|
+
const $mergePart = () => (out, keys, ext, whenNotMatched = 'fail') => $mergeId()(out, keys, assertNotNull$1(root().of('before').of('_id').expr()), ext, whenNotMatched);
|
|
1445
|
+
const $merge = () => (out, keys, whenNotMatched = 'fail') => $mergePart()(out, keys, {}, whenNotMatched);
|
|
1440
1446
|
const assertNotNull$1 = (expr) => expr;
|
|
1441
1447
|
|
|
1442
1448
|
const $insertX = (out, expr, map, ext, extExpr) => {
|
|
@@ -1609,13 +1615,13 @@ const actions = {
|
|
|
1609
1615
|
],
|
|
1610
1616
|
};
|
|
1611
1617
|
|
|
1612
|
-
const getFirstStages = (view) => {
|
|
1618
|
+
const getFirstStages = (view, needs) => {
|
|
1613
1619
|
const { projection, hardMatch: pre, match } = view;
|
|
1614
1620
|
const projectInput = projection && $project_(spread(projection, {
|
|
1615
1621
|
deletedAt: ['deletedAt', 1],
|
|
1616
1622
|
_id: ['_id', 1],
|
|
1617
1623
|
}));
|
|
1618
|
-
const removeNotYetSynchronizedFields = projection && Object.values(mapExactToObject(projection, (_, k) => k.startsWith('_') ? root().of(k).has($exists(true)) : null));
|
|
1624
|
+
const removeNotYetSynchronizedFields = projection && Object.values(mapExactToObject(projection, (_, k) => (needs[k] ?? k.startsWith('_')) ? root().of(k).has($exists(true)) : null));
|
|
1619
1625
|
const hardMatch = removeNotYetSynchronizedFields ? $and(pre, ...removeNotYetSynchronizedFields) : pre;
|
|
1620
1626
|
const firstStages = (lastTS, keepNulls = false) => {
|
|
1621
1627
|
const hardQuery = $and(lastTS
|
|
@@ -1629,9 +1635,9 @@ const getFirstStages = (view) => {
|
|
|
1629
1635
|
};
|
|
1630
1636
|
|
|
1631
1637
|
const streamNames = {};
|
|
1632
|
-
const executes$2 = (view, input, streamName, skip = false, after) => {
|
|
1638
|
+
const executes$2 = (view, input, streamName, skip = false, after, needs = {}) => {
|
|
1633
1639
|
const { collection, projection, match } = view;
|
|
1634
|
-
const { firstStages, hardMatch } = getFirstStages(view);
|
|
1640
|
+
const { firstStages, hardMatch } = getFirstStages(view, needs);
|
|
1635
1641
|
const db = collection.s.db, coll = collection.collectionName;
|
|
1636
1642
|
const hash = crypto$1
|
|
1637
1643
|
.createHash('md5')
|
|
@@ -1820,7 +1826,7 @@ const executes$2 = (view, input, streamName, skip = false, after) => {
|
|
|
1820
1826
|
};
|
|
1821
1827
|
const staging = (view, streamName, skip = false, after) => pipe(input => executes$2(view, input, streamName, skip, after), emptyDelta(), concatDelta, emptyDelta);
|
|
1822
1828
|
|
|
1823
|
-
const executes$1 = (view, input, streamName,
|
|
1829
|
+
const executes$1 = (view, input, streamName, needs) => {
|
|
1824
1830
|
const hash = crypto$1
|
|
1825
1831
|
.createHash('md5')
|
|
1826
1832
|
.update(new Error().stack + '')
|
|
@@ -1830,7 +1836,7 @@ const executes$1 = (view, input, streamName, allowEmtpies) => {
|
|
|
1830
1836
|
else if (streamNames[streamName] != hash)
|
|
1831
1837
|
throw new Error('streamName already used');
|
|
1832
1838
|
const { collection, projection, hardMatch: pre, match } = view;
|
|
1833
|
-
const removeNotYetSynchronizedFields = projection && Object.values(mapExactToObject(projection, (_, k) => k.startsWith('_')
|
|
1839
|
+
const removeNotYetSynchronizedFields = projection && Object.values(mapExactToObject(projection, (_, k) => (needs[k] ?? k.startsWith('_')) ? root().of(k).has($exists(true)) : null));
|
|
1834
1840
|
const hardMatch = removeNotYetSynchronizedFields ? $and(pre, ...removeNotYetSynchronizedFields) : pre;
|
|
1835
1841
|
const job = {};
|
|
1836
1842
|
const db = collection.s.db, coll = collection.collectionName;
|
|
@@ -1941,10 +1947,10 @@ const executes$1 = (view, input, streamName, allowEmtpies) => {
|
|
|
1941
1947
|
};
|
|
1942
1948
|
};
|
|
1943
1949
|
const emptyLin = () => ({ lin: link().stages });
|
|
1944
|
-
const from = (view, streamName,
|
|
1950
|
+
const from = (view, streamName, needs = {}) => pipe(input => executes$1(view, input.lin, streamName, needs), { lin: link().stages }, ({ lin: a }, { lin: b }) => ({ lin: concatStages(a, b) }), emptyLin);
|
|
1945
1951
|
|
|
1946
|
-
const executes = (view, input) => {
|
|
1947
|
-
const { firstStages } = getFirstStages(view);
|
|
1952
|
+
const executes = (view, input, needs) => {
|
|
1953
|
+
const { firstStages } = getFirstStages(view, needs);
|
|
1948
1954
|
const { collection } = view;
|
|
1949
1955
|
return (finalInput) => {
|
|
1950
1956
|
const start = input.raw(root);
|
|
@@ -1956,7 +1962,7 @@ const executes = (view, input) => {
|
|
|
1956
1962
|
});
|
|
1957
1963
|
};
|
|
1958
1964
|
};
|
|
1959
|
-
const single = (view) => pipe(input => executes(view, input), emptyDelta(), concatDelta, emptyDelta);
|
|
1965
|
+
const single = (view, needs = {}) => pipe(input => executes(view, input, needs), emptyDelta(), concatDelta, emptyDelta);
|
|
1960
1966
|
|
|
1961
1967
|
require('dotenv').config();
|
|
1962
1968
|
const uri = process.env['MONGO_URL'];
|
|
@@ -2001,4 +2007,4 @@ const makeCol = async (docs, database, name) => {
|
|
|
2001
2007
|
}
|
|
2002
2008
|
};
|
|
2003
2009
|
|
|
2004
|
-
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, $merge2, $merge_, $ne, $nin, $nor, $or, $outerLookup, $pushDict, $rand, $reduce, $replaceWith, $set, $simpleInsert, $simpleMerge, $simpleMergePart, $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 };
|
|
2010
|
+
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, $merge2, $mergeId, $mergePart, $merge_, $ne, $nin, $nor, $or, $outerLookup, $pushDict, $rand, $reduce, $replaceWith, $set, $simpleInsert, $simpleMerge, $simpleMergePart, $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
|
@@ -1402,7 +1402,12 @@ const $mergeX = (out, keys, f, map, whenNotMatched = 'fail', ext) => {
|
|
|
1402
1402
|
$cond: {
|
|
1403
1403
|
if: {
|
|
1404
1404
|
$eq: [
|
|
1405
|
-
{
|
|
1405
|
+
{
|
|
1406
|
+
$mergeObjects: [
|
|
1407
|
+
'$old',
|
|
1408
|
+
{ deletedAt: { $ifNull: ['$old.deletedAt', null] } },
|
|
1409
|
+
],
|
|
1410
|
+
},
|
|
1406
1411
|
{ $mergeObjects: ['$merged', { touchedAt: '$old.touchedAt' }] },
|
|
1407
1412
|
],
|
|
1408
1413
|
},
|
|
@@ -1438,7 +1443,8 @@ const $mergeId = () => (out, keys, id, ext, whenNotMatched) => {
|
|
|
1438
1443
|
};
|
|
1439
1444
|
const $simpleMergePart = () => (out, keys, whenNotMatched, ext) => $mergeX(out, keys, root(), id$1, whenNotMatched, ext);
|
|
1440
1445
|
const $simpleMerge = () => (out, keys, whenNotMatched = 'fail') => $mergeX(out, keys, root(), id$1, whenNotMatched, {});
|
|
1441
|
-
const $
|
|
1446
|
+
const $mergePart = () => (out, keys, ext, whenNotMatched = 'fail') => $mergeId()(out, keys, assertNotNull$1(root().of('before').of('_id').expr()), ext, whenNotMatched);
|
|
1447
|
+
const $merge = () => (out, keys, whenNotMatched = 'fail') => $mergePart()(out, keys, {}, whenNotMatched);
|
|
1442
1448
|
const assertNotNull$1 = (expr) => expr;
|
|
1443
1449
|
|
|
1444
1450
|
const $insertX = (out, expr, map, ext, extExpr) => {
|
|
@@ -1611,13 +1617,13 @@ const actions = {
|
|
|
1611
1617
|
],
|
|
1612
1618
|
};
|
|
1613
1619
|
|
|
1614
|
-
const getFirstStages = (view) => {
|
|
1620
|
+
const getFirstStages = (view, needs) => {
|
|
1615
1621
|
const { projection, hardMatch: pre, match } = view;
|
|
1616
1622
|
const projectInput = projection && $project_(spread(projection, {
|
|
1617
1623
|
deletedAt: ['deletedAt', 1],
|
|
1618
1624
|
_id: ['_id', 1],
|
|
1619
1625
|
}));
|
|
1620
|
-
const removeNotYetSynchronizedFields = projection && Object.values(mapExactToObject(projection, (_, k) => k.startsWith('_') ? root().of(k).has($exists(true)) : null));
|
|
1626
|
+
const removeNotYetSynchronizedFields = projection && Object.values(mapExactToObject(projection, (_, k) => (needs[k] ?? k.startsWith('_')) ? root().of(k).has($exists(true)) : null));
|
|
1621
1627
|
const hardMatch = removeNotYetSynchronizedFields ? $and(pre, ...removeNotYetSynchronizedFields) : pre;
|
|
1622
1628
|
const firstStages = (lastTS, keepNulls = false) => {
|
|
1623
1629
|
const hardQuery = $and(lastTS
|
|
@@ -1631,9 +1637,9 @@ const getFirstStages = (view) => {
|
|
|
1631
1637
|
};
|
|
1632
1638
|
|
|
1633
1639
|
const streamNames = {};
|
|
1634
|
-
const executes$2 = (view, input, streamName, skip = false, after) => {
|
|
1640
|
+
const executes$2 = (view, input, streamName, skip = false, after, needs = {}) => {
|
|
1635
1641
|
const { collection, projection, match } = view;
|
|
1636
|
-
const { firstStages, hardMatch } = getFirstStages(view);
|
|
1642
|
+
const { firstStages, hardMatch } = getFirstStages(view, needs);
|
|
1637
1643
|
const db = collection.s.db, coll = collection.collectionName;
|
|
1638
1644
|
const hash = crypto$1
|
|
1639
1645
|
.createHash('md5')
|
|
@@ -1822,7 +1828,7 @@ const executes$2 = (view, input, streamName, skip = false, after) => {
|
|
|
1822
1828
|
};
|
|
1823
1829
|
const staging = (view, streamName, skip = false, after) => pipe(input => executes$2(view, input, streamName, skip, after), emptyDelta(), concatDelta, emptyDelta);
|
|
1824
1830
|
|
|
1825
|
-
const executes$1 = (view, input, streamName,
|
|
1831
|
+
const executes$1 = (view, input, streamName, needs) => {
|
|
1826
1832
|
const hash = crypto$1
|
|
1827
1833
|
.createHash('md5')
|
|
1828
1834
|
.update(new Error().stack + '')
|
|
@@ -1832,7 +1838,7 @@ const executes$1 = (view, input, streamName, allowEmtpies) => {
|
|
|
1832
1838
|
else if (streamNames[streamName] != hash)
|
|
1833
1839
|
throw new Error('streamName already used');
|
|
1834
1840
|
const { collection, projection, hardMatch: pre, match } = view;
|
|
1835
|
-
const removeNotYetSynchronizedFields = projection && Object.values(mapExactToObject(projection, (_, k) => k.startsWith('_')
|
|
1841
|
+
const removeNotYetSynchronizedFields = projection && Object.values(mapExactToObject(projection, (_, k) => (needs[k] ?? k.startsWith('_')) ? root().of(k).has($exists(true)) : null));
|
|
1836
1842
|
const hardMatch = removeNotYetSynchronizedFields ? $and(pre, ...removeNotYetSynchronizedFields) : pre;
|
|
1837
1843
|
const job = {};
|
|
1838
1844
|
const db = collection.s.db, coll = collection.collectionName;
|
|
@@ -1943,10 +1949,10 @@ const executes$1 = (view, input, streamName, allowEmtpies) => {
|
|
|
1943
1949
|
};
|
|
1944
1950
|
};
|
|
1945
1951
|
const emptyLin = () => ({ lin: link().stages });
|
|
1946
|
-
const from = (view, streamName,
|
|
1952
|
+
const from = (view, streamName, needs = {}) => pipe(input => executes$1(view, input.lin, streamName, needs), { lin: link().stages }, ({ lin: a }, { lin: b }) => ({ lin: concatStages(a, b) }), emptyLin);
|
|
1947
1953
|
|
|
1948
|
-
const executes = (view, input) => {
|
|
1949
|
-
const { firstStages } = getFirstStages(view);
|
|
1954
|
+
const executes = (view, input, needs) => {
|
|
1955
|
+
const { firstStages } = getFirstStages(view, needs);
|
|
1950
1956
|
const { collection } = view;
|
|
1951
1957
|
return (finalInput) => {
|
|
1952
1958
|
const start = input.raw(root);
|
|
@@ -1958,7 +1964,7 @@ const executes = (view, input) => {
|
|
|
1958
1964
|
});
|
|
1959
1965
|
};
|
|
1960
1966
|
};
|
|
1961
|
-
const single = (view) => pipe(input => executes(view, input), emptyDelta(), concatDelta, emptyDelta);
|
|
1967
|
+
const single = (view, needs = {}) => pipe(input => executes(view, input, needs), emptyDelta(), concatDelta, emptyDelta);
|
|
1962
1968
|
|
|
1963
1969
|
require('dotenv').config();
|
|
1964
1970
|
const uri = process.env['MONGO_URL'];
|
|
@@ -2036,6 +2042,8 @@ exports.$match = $match;
|
|
|
2036
2042
|
exports.$matchDelta = $matchDelta;
|
|
2037
2043
|
exports.$merge = $merge;
|
|
2038
2044
|
exports.$merge2 = $merge2;
|
|
2045
|
+
exports.$mergeId = $mergeId;
|
|
2046
|
+
exports.$mergePart = $mergePart;
|
|
2039
2047
|
exports.$merge_ = $merge_;
|
|
2040
2048
|
exports.$ne = $ne;
|
|
2041
2049
|
exports.$nin = $nin;
|