@omegup/msync 0.1.34 → 0.1.36
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 -1
- package/index.esm.js +19 -11
- package/index.js +19 -10
- package/package.json +1 -1
package/index.d.ts
CHANGED
|
@@ -236,6 +236,7 @@ declare const concat: {
|
|
|
236
236
|
<D, C>(...expr: Expr<string, D, C>[]): Expr<string, D, C>;
|
|
237
237
|
<D, C>(...expr: Expr<string | N, D, C>[]): Expr<string | N, D, C>;
|
|
238
238
|
};
|
|
239
|
+
declare const padLeft: <D, C>(expr: Expr<string, D, C>, pad: string) => Expr<string, D, C>;
|
|
239
240
|
declare const regex: <D, C>(expr: Expr<string, D, C>, regex: Expr<string, D, C>, options?: Expr<string, D, C>) => Expr<boolean, D, C>;
|
|
240
241
|
declare const str: <D, C>(expr: Expr<unknown, D, C>) => Expr<string, D, C>;
|
|
241
242
|
declare const toInt: <D, C>(expr: Expr<unknown, D, C>) => Expr<number, D, C>;
|
|
@@ -685,5 +686,5 @@ declare const enablePreAndPostImages: <T extends doc>(coll: Collection<T>) => Pr
|
|
|
685
686
|
declare const prepare: (testName?: string) => Promise<MongoClient$1>;
|
|
686
687
|
declare const makeCol: <T extends ID>(docs: readonly OptionalUnlessRequiredId<T>[], database: Db, name?: string) => Promise<Collection<T>>;
|
|
687
688
|
|
|
688
|
-
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, Expr, Field, Machine, Type, add, and, anyElementTrue, array, ceil, comp, concat, concatArray, createIndex, ctx, current, dateAdd, dateDiff, dateLt, datePart, dayAndMonthPart, divide, enablePreAndPostImages, eq, eqTyped, except, exprMapVal, field, fieldF, fieldM, filter, filterDefined, first, firstSure, floor, from, func, getWhenMatched, getWhenMatchedForMerge, gt, gte, inArray, isArray, ite, last, log, lt, lte, makeCol, map1, mapFromPlainDateTime, mapToPlainDateTime, 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 };
|
|
689
|
+
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, Expr, Field, Machine, Type, add, and, anyElementTrue, array, ceil, comp, concat, concatArray, createIndex, ctx, current, dateAdd, dateDiff, dateLt, datePart, dayAndMonthPart, divide, enablePreAndPostImages, eq, eqTyped, except, exprMapVal, field, fieldF, fieldM, filter, filterDefined, first, firstSure, floor, from, func, getWhenMatched, getWhenMatchedForMerge, gt, gte, inArray, isArray, ite, last, log, lt, lte, makeCol, map1, mapFromPlainDateTime, mapToPlainDateTime, mapVal, max, maxDate, mergeExact, mergeExact0, mergeExpr, mergeObjects, minDate, monthPart, multiply, ne, nil, noop, not, notNull, now, or, padLeft, pair, prepare, rand, range, regex, root, set, setField, single, size, slice, sortArray, staging, startOf, str, sub, subtract, to, toInt, val, weekPart, wrap, year };
|
|
689
690
|
export type { Accumulators, Arr, AsLiteral, Delta, DeltaAccumulator, DeltaAccumulators, ExactKeys, ExprHKT, Exprs, ExprsExact, ExprsExactHKT, ExprsPart, ID, Loose, Merge, MergeArgs, MergeInto, MergeMapOArgs, Model, MongoTypeNames, N, NoRaw, NullToOBJ, O, OPick, OPickD, Patch, RONoRaw, RORec, RawStages, Rec, Replace, SnapshotStreamExecutionResult, StrKey, Strict, TS, WriteonlyCollection, doc, jsonPrim, notArr };
|
package/index.esm.js
CHANGED
|
@@ -299,6 +299,18 @@ const $entries = (expr) => func(function (obj) {
|
|
|
299
299
|
const concat$1 = (...expr) => asExpr({
|
|
300
300
|
raw: f => asExprRaw({ $concat: expr.map(e => e.raw(f).get()) }),
|
|
301
301
|
});
|
|
302
|
+
const padLeft = (expr, pad) => asExpr({
|
|
303
|
+
raw: f => asExprRaw({
|
|
304
|
+
$let: {
|
|
305
|
+
vars: {
|
|
306
|
+
x: {
|
|
307
|
+
$concat: [{ $literal: pad }, expr.raw(f).get()],
|
|
308
|
+
},
|
|
309
|
+
},
|
|
310
|
+
in: { $substrCP: ['$$x', { $subtract: [{ $strLenCP: '$$x' }, pad.length] }, pad.length] },
|
|
311
|
+
},
|
|
312
|
+
}),
|
|
313
|
+
});
|
|
302
314
|
const regex = (expr, regex, options) => asExpr({
|
|
303
315
|
raw: f => asExprRaw({
|
|
304
316
|
$regexMatch: {
|
|
@@ -315,10 +327,7 @@ const toInt = (expr) => asExpr({
|
|
|
315
327
|
raw: f => asExprRaw({ $toInt: expr.raw(f).get() }),
|
|
316
328
|
});
|
|
317
329
|
const fieldM = (expr, m) => asExpr({
|
|
318
|
-
raw: (f) => asExprRaw(Object.fromEntries(Object.entries(m).flatMap(([dom, ref]) => expr[ref] ? [[
|
|
319
|
-
dom,
|
|
320
|
-
expr[ref].raw(f).get(),
|
|
321
|
-
]] : []))),
|
|
330
|
+
raw: (f) => asExprRaw(Object.fromEntries(Object.entries(m).flatMap(([dom, ref]) => expr[ref] ? [[dom, expr[ref].raw(f).get()]] : []))),
|
|
322
331
|
});
|
|
323
332
|
const mergeExact = (...[exprsExact1, exprsExact2]) => spread(exprsExact1, exprsExact2);
|
|
324
333
|
const mergeExact0 = (...[exprsExact1, exprsExact2]) => spread0(exprsExact1, exprsExact2);
|
|
@@ -1763,9 +1772,8 @@ const loop = async (db) => {
|
|
|
1763
1772
|
const m = watchers.get(doc.ns);
|
|
1764
1773
|
if (!m)
|
|
1765
1774
|
continue;
|
|
1766
|
-
for (const { cb, keys, rem } of [...m.values()]) {
|
|
1767
|
-
if (!keys ||
|
|
1768
|
-
(doc.op === 'i' ? keys.p.every(k => fields.has(k)) : keys.k.some(k => fields.has(k)))) {
|
|
1775
|
+
for (const { cb, keys, rem, match } of [...m.values()]) {
|
|
1776
|
+
if (!keys || (doc.op === 'i' ? (match ? true : true) : keys.some(k => fields.has(k)))) {
|
|
1769
1777
|
cb(doc);
|
|
1770
1778
|
rem();
|
|
1771
1779
|
}
|
|
@@ -1773,7 +1781,7 @@ const loop = async (db) => {
|
|
|
1773
1781
|
}
|
|
1774
1782
|
}
|
|
1775
1783
|
};
|
|
1776
|
-
const register = (coll, keys, cb) => {
|
|
1784
|
+
const register = (coll, keys, match, cb) => {
|
|
1777
1785
|
const ns = coll.namespace;
|
|
1778
1786
|
let m = watchers.get(ns);
|
|
1779
1787
|
if (!m)
|
|
@@ -1784,7 +1792,7 @@ const register = (coll, keys, cb) => {
|
|
|
1784
1792
|
if (m.size === 0)
|
|
1785
1793
|
watchers.delete(ns);
|
|
1786
1794
|
};
|
|
1787
|
-
m.set(id, { cb, keys
|
|
1795
|
+
m.set(id, { cb, keys, match, rem });
|
|
1788
1796
|
if (!running) {
|
|
1789
1797
|
running = true;
|
|
1790
1798
|
loop(coll.s.db);
|
|
@@ -1799,7 +1807,7 @@ const makeWatchStream = async ({ collection, projection: p, hardMatch: m }, stre
|
|
|
1799
1807
|
.updateMany({ touchedAt: maxTimestamp }, [{ $set: { touchedAt: '$$CLUSTER_TIME' } }]))).then(() => { }));
|
|
1800
1808
|
const projection = { ...(p ? mapExactToObject(p, v => v) : {}), deletedAt: 1 };
|
|
1801
1809
|
let notify = makePromise();
|
|
1802
|
-
register(collection, p ? Object.keys(projection) : null, doc => {
|
|
1810
|
+
register(collection, p ? Object.keys(projection) : null, m, doc => {
|
|
1803
1811
|
log(streamName, 'change detected', doc);
|
|
1804
1812
|
notify.resolve(doc);
|
|
1805
1813
|
});
|
|
@@ -2266,4 +2274,4 @@ const executes = (view, input, needs) => {
|
|
|
2266
2274
|
};
|
|
2267
2275
|
const single = (view, needs = {}) => pipe(input => executes(view, input, needs), emptyDelta(), concatDelta, emptyDelta);
|
|
2268
2276
|
|
|
2269
|
-
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, getWhenMatched, getWhenMatchedForMerge, gt, gte, inArray, isArray, ite, last, log, lt, lte, makeCol, map1, mapFromPlainDateTime, mapToPlainDateTime, 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 };
|
|
2277
|
+
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, getWhenMatched, getWhenMatchedForMerge, gt, gte, inArray, isArray, ite, last, log, lt, lte, makeCol, map1, mapFromPlainDateTime, mapToPlainDateTime, mapVal, max, maxDate, mergeExact, mergeExact0, mergeExpr, mergeObjects, minDate, monthPart, multiply, ne, nil, noop, not, notNull, now, or, padLeft, 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
|
@@ -301,6 +301,18 @@ const $entries = (expr) => func(function (obj) {
|
|
|
301
301
|
const concat$1 = (...expr) => asExpr({
|
|
302
302
|
raw: f => asExprRaw({ $concat: expr.map(e => e.raw(f).get()) }),
|
|
303
303
|
});
|
|
304
|
+
const padLeft = (expr, pad) => asExpr({
|
|
305
|
+
raw: f => asExprRaw({
|
|
306
|
+
$let: {
|
|
307
|
+
vars: {
|
|
308
|
+
x: {
|
|
309
|
+
$concat: [{ $literal: pad }, expr.raw(f).get()],
|
|
310
|
+
},
|
|
311
|
+
},
|
|
312
|
+
in: { $substrCP: ['$$x', { $subtract: [{ $strLenCP: '$$x' }, pad.length] }, pad.length] },
|
|
313
|
+
},
|
|
314
|
+
}),
|
|
315
|
+
});
|
|
304
316
|
const regex = (expr, regex, options) => asExpr({
|
|
305
317
|
raw: f => asExprRaw({
|
|
306
318
|
$regexMatch: {
|
|
@@ -317,10 +329,7 @@ const toInt = (expr) => asExpr({
|
|
|
317
329
|
raw: f => asExprRaw({ $toInt: expr.raw(f).get() }),
|
|
318
330
|
});
|
|
319
331
|
const fieldM = (expr, m) => asExpr({
|
|
320
|
-
raw: (f) => asExprRaw(Object.fromEntries(Object.entries(m).flatMap(([dom, ref]) => expr[ref] ? [[
|
|
321
|
-
dom,
|
|
322
|
-
expr[ref].raw(f).get(),
|
|
323
|
-
]] : []))),
|
|
332
|
+
raw: (f) => asExprRaw(Object.fromEntries(Object.entries(m).flatMap(([dom, ref]) => expr[ref] ? [[dom, expr[ref].raw(f).get()]] : []))),
|
|
324
333
|
});
|
|
325
334
|
const mergeExact = (...[exprsExact1, exprsExact2]) => spread(exprsExact1, exprsExact2);
|
|
326
335
|
const mergeExact0 = (...[exprsExact1, exprsExact2]) => spread0(exprsExact1, exprsExact2);
|
|
@@ -1765,9 +1774,8 @@ const loop = async (db) => {
|
|
|
1765
1774
|
const m = watchers.get(doc.ns);
|
|
1766
1775
|
if (!m)
|
|
1767
1776
|
continue;
|
|
1768
|
-
for (const { cb, keys, rem } of [...m.values()]) {
|
|
1769
|
-
if (!keys ||
|
|
1770
|
-
(doc.op === 'i' ? keys.p.every(k => fields.has(k)) : keys.k.some(k => fields.has(k)))) {
|
|
1777
|
+
for (const { cb, keys, rem, match } of [...m.values()]) {
|
|
1778
|
+
if (!keys || (doc.op === 'i' ? (match ? true : true) : keys.some(k => fields.has(k)))) {
|
|
1771
1779
|
cb(doc);
|
|
1772
1780
|
rem();
|
|
1773
1781
|
}
|
|
@@ -1775,7 +1783,7 @@ const loop = async (db) => {
|
|
|
1775
1783
|
}
|
|
1776
1784
|
}
|
|
1777
1785
|
};
|
|
1778
|
-
const register = (coll, keys, cb) => {
|
|
1786
|
+
const register = (coll, keys, match, cb) => {
|
|
1779
1787
|
const ns = coll.namespace;
|
|
1780
1788
|
let m = watchers.get(ns);
|
|
1781
1789
|
if (!m)
|
|
@@ -1786,7 +1794,7 @@ const register = (coll, keys, cb) => {
|
|
|
1786
1794
|
if (m.size === 0)
|
|
1787
1795
|
watchers.delete(ns);
|
|
1788
1796
|
};
|
|
1789
|
-
m.set(id, { cb, keys
|
|
1797
|
+
m.set(id, { cb, keys, match, rem });
|
|
1790
1798
|
if (!running) {
|
|
1791
1799
|
running = true;
|
|
1792
1800
|
loop(coll.s.db);
|
|
@@ -1801,7 +1809,7 @@ const makeWatchStream = async ({ collection, projection: p, hardMatch: m }, stre
|
|
|
1801
1809
|
.updateMany({ touchedAt: maxTimestamp }, [{ $set: { touchedAt: '$$CLUSTER_TIME' } }]))).then(() => { }));
|
|
1802
1810
|
const projection = { ...(p ? mapExactToObject(p, v => v) : {}), deletedAt: 1 };
|
|
1803
1811
|
let notify = makePromise();
|
|
1804
|
-
register(collection, p ? Object.keys(projection) : null, doc => {
|
|
1812
|
+
register(collection, p ? Object.keys(projection) : null, m, doc => {
|
|
1805
1813
|
log(streamName, 'change detected', doc);
|
|
1806
1814
|
notify.resolve(doc);
|
|
1807
1815
|
});
|
|
@@ -2387,6 +2395,7 @@ exports.not = not;
|
|
|
2387
2395
|
exports.notNull = notNull;
|
|
2388
2396
|
exports.now = now;
|
|
2389
2397
|
exports.or = or;
|
|
2398
|
+
exports.padLeft = padLeft;
|
|
2390
2399
|
exports.pair = pair;
|
|
2391
2400
|
exports.prepare = prepare;
|
|
2392
2401
|
exports.rand = rand;
|