@omegup/msync 0.1.4 → 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 +2 -2
- package/index.esm.js +10 -10
- package/index.js +10 -10
- package/package.json +1 -1
package/index.d.ts
CHANGED
|
@@ -543,13 +543,13 @@ interface StreamRunnerHKT extends HKT<O2> {
|
|
|
543
543
|
interface StagesHKT extends HKT<O3> {
|
|
544
544
|
readonly out: RORec<'lin', RawStages<I<O3, this>[0], I<O3, this>[1], I<O3, this>[2], unknown, 1>>;
|
|
545
545
|
}
|
|
546
|
-
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>;
|
|
547
547
|
|
|
548
548
|
type SingleResult<out Result> = <Result2>(finalInput: RawStages<unknown, Result, Result2>) => Stages<unknown, Result2, unknown>;
|
|
549
549
|
interface SnapshotStreamHKT2 extends HKT<O2> {
|
|
550
550
|
readonly out: SingleResult<I<O2, this>[1]>;
|
|
551
551
|
}
|
|
552
|
-
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>;
|
|
553
553
|
|
|
554
554
|
declare const max: <D, C>(...expr: Expr<number, D, C>[]) => Expr<number, D, C>;
|
|
555
555
|
declare const lt: <D, C>(expr_0: Expr<number, D, C>, expr_1: Expr<number, D, C>) => Expr<boolean, D, C>;
|
package/index.esm.js
CHANGED
|
@@ -1615,13 +1615,13 @@ const actions = {
|
|
|
1615
1615
|
],
|
|
1616
1616
|
};
|
|
1617
1617
|
|
|
1618
|
-
const getFirstStages = (view) => {
|
|
1618
|
+
const getFirstStages = (view, needs) => {
|
|
1619
1619
|
const { projection, hardMatch: pre, match } = view;
|
|
1620
1620
|
const projectInput = projection && $project_(spread(projection, {
|
|
1621
1621
|
deletedAt: ['deletedAt', 1],
|
|
1622
1622
|
_id: ['_id', 1],
|
|
1623
1623
|
}));
|
|
1624
|
-
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));
|
|
1625
1625
|
const hardMatch = removeNotYetSynchronizedFields ? $and(pre, ...removeNotYetSynchronizedFields) : pre;
|
|
1626
1626
|
const firstStages = (lastTS, keepNulls = false) => {
|
|
1627
1627
|
const hardQuery = $and(lastTS
|
|
@@ -1635,9 +1635,9 @@ const getFirstStages = (view) => {
|
|
|
1635
1635
|
};
|
|
1636
1636
|
|
|
1637
1637
|
const streamNames = {};
|
|
1638
|
-
const executes$2 = (view, input, streamName, skip = false, after) => {
|
|
1638
|
+
const executes$2 = (view, input, streamName, skip = false, after, needs = {}) => {
|
|
1639
1639
|
const { collection, projection, match } = view;
|
|
1640
|
-
const { firstStages, hardMatch } = getFirstStages(view);
|
|
1640
|
+
const { firstStages, hardMatch } = getFirstStages(view, needs);
|
|
1641
1641
|
const db = collection.s.db, coll = collection.collectionName;
|
|
1642
1642
|
const hash = crypto$1
|
|
1643
1643
|
.createHash('md5')
|
|
@@ -1826,7 +1826,7 @@ const executes$2 = (view, input, streamName, skip = false, after) => {
|
|
|
1826
1826
|
};
|
|
1827
1827
|
const staging = (view, streamName, skip = false, after) => pipe(input => executes$2(view, input, streamName, skip, after), emptyDelta(), concatDelta, emptyDelta);
|
|
1828
1828
|
|
|
1829
|
-
const executes$1 = (view, input, streamName,
|
|
1829
|
+
const executes$1 = (view, input, streamName, needs) => {
|
|
1830
1830
|
const hash = crypto$1
|
|
1831
1831
|
.createHash('md5')
|
|
1832
1832
|
.update(new Error().stack + '')
|
|
@@ -1836,7 +1836,7 @@ const executes$1 = (view, input, streamName, allowEmtpies) => {
|
|
|
1836
1836
|
else if (streamNames[streamName] != hash)
|
|
1837
1837
|
throw new Error('streamName already used');
|
|
1838
1838
|
const { collection, projection, hardMatch: pre, match } = view;
|
|
1839
|
-
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));
|
|
1840
1840
|
const hardMatch = removeNotYetSynchronizedFields ? $and(pre, ...removeNotYetSynchronizedFields) : pre;
|
|
1841
1841
|
const job = {};
|
|
1842
1842
|
const db = collection.s.db, coll = collection.collectionName;
|
|
@@ -1947,10 +1947,10 @@ const executes$1 = (view, input, streamName, allowEmtpies) => {
|
|
|
1947
1947
|
};
|
|
1948
1948
|
};
|
|
1949
1949
|
const emptyLin = () => ({ lin: link().stages });
|
|
1950
|
-
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);
|
|
1951
1951
|
|
|
1952
|
-
const executes = (view, input) => {
|
|
1953
|
-
const { firstStages } = getFirstStages(view);
|
|
1952
|
+
const executes = (view, input, needs) => {
|
|
1953
|
+
const { firstStages } = getFirstStages(view, needs);
|
|
1954
1954
|
const { collection } = view;
|
|
1955
1955
|
return (finalInput) => {
|
|
1956
1956
|
const start = input.raw(root);
|
|
@@ -1962,7 +1962,7 @@ const executes = (view, input) => {
|
|
|
1962
1962
|
});
|
|
1963
1963
|
};
|
|
1964
1964
|
};
|
|
1965
|
-
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);
|
|
1966
1966
|
|
|
1967
1967
|
require('dotenv').config();
|
|
1968
1968
|
const uri = process.env['MONGO_URL'];
|
package/index.js
CHANGED
|
@@ -1617,13 +1617,13 @@ const actions = {
|
|
|
1617
1617
|
],
|
|
1618
1618
|
};
|
|
1619
1619
|
|
|
1620
|
-
const getFirstStages = (view) => {
|
|
1620
|
+
const getFirstStages = (view, needs) => {
|
|
1621
1621
|
const { projection, hardMatch: pre, match } = view;
|
|
1622
1622
|
const projectInput = projection && $project_(spread(projection, {
|
|
1623
1623
|
deletedAt: ['deletedAt', 1],
|
|
1624
1624
|
_id: ['_id', 1],
|
|
1625
1625
|
}));
|
|
1626
|
-
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));
|
|
1627
1627
|
const hardMatch = removeNotYetSynchronizedFields ? $and(pre, ...removeNotYetSynchronizedFields) : pre;
|
|
1628
1628
|
const firstStages = (lastTS, keepNulls = false) => {
|
|
1629
1629
|
const hardQuery = $and(lastTS
|
|
@@ -1637,9 +1637,9 @@ const getFirstStages = (view) => {
|
|
|
1637
1637
|
};
|
|
1638
1638
|
|
|
1639
1639
|
const streamNames = {};
|
|
1640
|
-
const executes$2 = (view, input, streamName, skip = false, after) => {
|
|
1640
|
+
const executes$2 = (view, input, streamName, skip = false, after, needs = {}) => {
|
|
1641
1641
|
const { collection, projection, match } = view;
|
|
1642
|
-
const { firstStages, hardMatch } = getFirstStages(view);
|
|
1642
|
+
const { firstStages, hardMatch } = getFirstStages(view, needs);
|
|
1643
1643
|
const db = collection.s.db, coll = collection.collectionName;
|
|
1644
1644
|
const hash = crypto$1
|
|
1645
1645
|
.createHash('md5')
|
|
@@ -1828,7 +1828,7 @@ const executes$2 = (view, input, streamName, skip = false, after) => {
|
|
|
1828
1828
|
};
|
|
1829
1829
|
const staging = (view, streamName, skip = false, after) => pipe(input => executes$2(view, input, streamName, skip, after), emptyDelta(), concatDelta, emptyDelta);
|
|
1830
1830
|
|
|
1831
|
-
const executes$1 = (view, input, streamName,
|
|
1831
|
+
const executes$1 = (view, input, streamName, needs) => {
|
|
1832
1832
|
const hash = crypto$1
|
|
1833
1833
|
.createHash('md5')
|
|
1834
1834
|
.update(new Error().stack + '')
|
|
@@ -1838,7 +1838,7 @@ const executes$1 = (view, input, streamName, allowEmtpies) => {
|
|
|
1838
1838
|
else if (streamNames[streamName] != hash)
|
|
1839
1839
|
throw new Error('streamName already used');
|
|
1840
1840
|
const { collection, projection, hardMatch: pre, match } = view;
|
|
1841
|
-
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));
|
|
1842
1842
|
const hardMatch = removeNotYetSynchronizedFields ? $and(pre, ...removeNotYetSynchronizedFields) : pre;
|
|
1843
1843
|
const job = {};
|
|
1844
1844
|
const db = collection.s.db, coll = collection.collectionName;
|
|
@@ -1949,10 +1949,10 @@ const executes$1 = (view, input, streamName, allowEmtpies) => {
|
|
|
1949
1949
|
};
|
|
1950
1950
|
};
|
|
1951
1951
|
const emptyLin = () => ({ lin: link().stages });
|
|
1952
|
-
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);
|
|
1953
1953
|
|
|
1954
|
-
const executes = (view, input) => {
|
|
1955
|
-
const { firstStages } = getFirstStages(view);
|
|
1954
|
+
const executes = (view, input, needs) => {
|
|
1955
|
+
const { firstStages } = getFirstStages(view, needs);
|
|
1956
1956
|
const { collection } = view;
|
|
1957
1957
|
return (finalInput) => {
|
|
1958
1958
|
const start = input.raw(root);
|
|
@@ -1964,7 +1964,7 @@ const executes = (view, input) => {
|
|
|
1964
1964
|
});
|
|
1965
1965
|
};
|
|
1966
1966
|
};
|
|
1967
|
-
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);
|
|
1968
1968
|
|
|
1969
1969
|
require('dotenv').config();
|
|
1970
1970
|
const uri = process.env['MONGO_URL'];
|