@omegup/msync 0.1.39 → 0.1.41
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 +13 -8
- package/index.esm.js +48 -31
- package/index.js +50 -31
- package/package.json +1 -1
- package/lib/accumulators/index.d.ts +0 -10
- package/lib/aggregate/$merge.d.ts +0 -37
- package/lib/aggregate/$upsert.d.ts +0 -19
- package/lib/aggregate/group/$group-merge.d.ts +0 -12
- package/lib/aggregate/group/index.d.ts +0 -2
- package/lib/aggregate/group/utils/sub-group.d.ts +0 -6
- package/lib/aggregate/group/utils/sub-merge.d.ts +0 -20
- package/lib/aggregate/index.d.ts +0 -9
- package/lib/aggregate/lookup/$lookup-delta.d.ts +0 -10
- package/lib/aggregate/lookup/$lookup-raw.d.ts +0 -9
- package/lib/aggregate/lookup/index.d.ts +0 -12
- package/lib/aggregate/match/$match-delta.d.ts +0 -3
- package/lib/aggregate/match/$match.d.ts +0 -3
- package/lib/aggregate/match/index.d.ts +0 -2
- package/lib/aggregate/mongo-stages.d.ts +0 -13
- package/lib/aggregate/out.d.ts +0 -37
- package/lib/aggregate/prefix.d.ts +0 -33
- package/lib/aggregate/raws.d.ts +0 -17
- package/lib/aggregate/set/$replace-with-each.d.ts +0 -13
- package/lib/aggregate/set/$set-delta.d.ts +0 -5
- package/lib/aggregate/set/$set.d.ts +0 -6
- package/lib/aggregate/set/index.d.ts +0 -1
- package/lib/aggregate/unwind/$unwind-delta.d.ts +0 -5
- package/lib/aggregate/unwind/index.d.ts +0 -6
- package/lib/boot/boot-simpl.d.ts +0 -14
- package/lib/boot/boot-utils.d.ts +0 -27
- package/lib/boot/boot.d.ts +0 -16
- package/lib/boot/first-stages.d.ts +0 -13
- package/lib/boot/index.d.ts +0 -3
- package/lib/boot/single.d.ts +0 -11
- package/lib/expression/arith.d.ts +0 -32
- package/lib/expression/array.d.ts +0 -30
- package/lib/expression/concat.d.ts +0 -36
- package/lib/expression/date.d.ts +0 -22
- package/lib/expression/expr-base.d.ts +0 -5
- package/lib/expression/index.d.ts +0 -7
- package/lib/expression/logic.d.ts +0 -23
- package/lib/expression/range.d.ts +0 -11
- package/lib/expression/val.d.ts +0 -25
- package/lib/field/field.d.ts +0 -25
- package/lib/field/index.d.ts +0 -1
- package/lib/machine.d.ts +0 -9
- package/lib/predicate/$eq.d.ts +0 -24
- package/lib/predicate/$expr.d.ts +0 -3
- package/lib/predicate/$in.d.ts +0 -2
- package/lib/predicate/index.d.ts +0 -3
- package/lib/predicate/utils.d.ts +0 -5
- package/lib/query/index.d.ts +0 -1
- package/lib/query/logic.d.ts +0 -11
- package/lib/stream/aggregate.d.ts +0 -7
- package/lib/types/accumulator.d.ts +0 -30
- package/lib/types/aggregate.d.ts +0 -9
- package/lib/types/expr.d.ts +0 -27
- package/lib/types/extern.d.ts +0 -3
- package/lib/types/index.d.ts +0 -8
- package/lib/types/lookup.d.ts +0 -19
- package/lib/types/machine.d.ts +0 -17
- package/lib/types/predicate.d.ts +0 -11
- package/lib/types/query.d.ts +0 -12
- package/lib/types/stream.d.ts +0 -71
- package/lib/update/index.d.ts +0 -1
- package/lib/update/updater.d.ts +0 -19
- package/lib/utils/before.d.ts +0 -3
- package/lib/utils/coll.d.ts +0 -5
- package/lib/utils/db-indexes.d.ts +0 -7
- package/lib/utils/guard.d.ts +0 -19
- package/lib/utils/index.d.ts +0 -4
- package/lib/utils/json.d.ts +0 -9
- package/lib/utils/log.d.ts +0 -1
- package/lib/utils/map-object.d.ts +0 -41
- package/lib/utils/merge/combiners.d.ts +0 -6
- package/lib/utils/merge/index.d.ts +0 -2
- package/lib/utils/merge/merge.d.ts +0 -10
- package/lib/utils/merge/next-winner.d.ts +0 -3
- package/lib/utils/merge/types.d.ts +0 -19
- package/lib/utils/merge/utils.d.ts +0 -4
- package/lib/utils/tear-down.d.ts +0 -2
- package/lib/watch.d.ts +0 -30
- package/test/mongodb.d.ts +0 -9
- package/test/uri.d.ts +0 -1
- package/types/class.d.ts +0 -1
- package/types/extern.d.ts +0 -3
- package/types/global-aug.d.ts +0 -48
- package/types/global.d.ts +0 -2
- package/types/hkt.d.ts +0 -56
- package/types/index.d.ts +0 -6
- package/types/json.d.ts +0 -54
- package/types/mongo.d.ts +0 -24
- package/types/view.d.ts +0 -35
package/index.d.ts
CHANGED
|
@@ -353,10 +353,21 @@ declare const $rand: Expr<string, unknown, unknown>;
|
|
|
353
353
|
declare const $sum: <D extends O, C = unknown>(expr: Expr<number | N, D, C>) => DeltaAccumulator<D, number, C>;
|
|
354
354
|
declare const $accumulator: <D, T, Ctx, A extends readonly unknown[]>(init: () => NoRaw<T>, accumulateArgs: AppMap<ExprHKT<Part<D>, Ctx>, A>, accumulate: (a: NoRaw<T>, ...args: NoRaw<A>) => NoRaw<T>, merge: (...args: NoRaw<[T | N, T]>) => NoRaw<T>) => DeltaAccumulator<D, T, Ctx>;
|
|
355
355
|
declare const $countDict: <D extends O, C = unknown>(expr: Expr<string, D, C>) => DeltaAccumulator<D, Rec<string, number>, C>;
|
|
356
|
+
declare const $countDictArray: <D extends O, C = unknown>(expr: Expr<Arr<string>, D, C>) => DeltaAccumulator<D, Rec<string, number>, C>;
|
|
356
357
|
declare const $pushDict: <D extends O, V, C = unknown>(key: Expr<string, D, C>, value: Expr<V, D, C>) => DeltaAccumulator<D, Rec<string, Rec<"0" | "1", Arr<V>>>, C>;
|
|
357
358
|
declare const $keys: <D extends O, C = unknown>(expr: Expr<Rec<string, number>, D, C>) => Expr<Arr<string>, D, C>;
|
|
358
359
|
declare const $entries: <D extends O, V, C = unknown>(expr: Expr<Rec<string, Rec<"1" | "0", Arr<V>>>, D, C>) => Expr<Arr<Rec<"k", string> & Rec<"v", V>>, D, C>;
|
|
359
360
|
|
|
361
|
+
type DeltaPipe<Q extends O, T extends Q, F extends HKT<O2>, G extends HKT<O3>> = {
|
|
362
|
+
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>;
|
|
363
|
+
then: <Q2 extends O, V extends Q2>(next: App<G, [Q2 | T, T, V]>) => DeltaPipe<Q | Q2, V, F, G>;
|
|
364
|
+
get: () => App<F, [Q, T]>;
|
|
365
|
+
};
|
|
366
|
+
declare const emptyDelta: <T extends O>() => {
|
|
367
|
+
delta: RawStages<Delta<T>, Delta<T>, Delta<T>, unknown, number>;
|
|
368
|
+
raw: <F extends HKT<O>>() => RawStages<App<F, T>, App<F, T>, App<F, T>, unknown, number>;
|
|
369
|
+
};
|
|
370
|
+
|
|
360
371
|
type MergeInto<T extends O, Out extends O, E = unknown> = {
|
|
361
372
|
whenNotMatched: 'insert';
|
|
362
373
|
into: RWCollection<T, Out> & E;
|
|
@@ -506,12 +517,6 @@ declare const map1: <K extends string, Im>(k: AsLiteral<K>, to: Im) => { readonl
|
|
|
506
517
|
|
|
507
518
|
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>;
|
|
508
519
|
|
|
509
|
-
type DeltaPipe<Q extends O, T extends Q, F extends HKT<O2>, G extends HKT<O3>> = {
|
|
510
|
-
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>;
|
|
511
|
-
then: <Q2 extends O, V extends Q2>(next: App<G, [Q2 | T, T, V]>) => DeltaPipe<Q | Q2, V, F, G>;
|
|
512
|
-
get: () => App<F, [Q, T]>;
|
|
513
|
-
};
|
|
514
|
-
|
|
515
520
|
type AllowedPick$1<V extends Model, K extends StrKey<V>> = OPickD<V, Allowed$1<K>>;
|
|
516
521
|
type Allowed$1<K> = Exclude<K, 'deletedAt' | '_id'>;
|
|
517
522
|
|
|
@@ -673,7 +678,7 @@ declare const $gte: <T extends Numeric>(operand: rawItem & number) => Predicate<
|
|
|
673
678
|
declare const $lte: <T extends Numeric>(operand: rawItem & number) => Predicate<number>;
|
|
674
679
|
type MongoTypes = {
|
|
675
680
|
number: number;
|
|
676
|
-
array:
|
|
681
|
+
array: Arr<rawItem>;
|
|
677
682
|
string: string;
|
|
678
683
|
object: RawObj;
|
|
679
684
|
[i: number]: unknown;
|
|
@@ -700,5 +705,5 @@ declare const enablePreAndPostImages: <T extends doc>(coll: Collection<T>) => Pr
|
|
|
700
705
|
declare const prepare: (testName?: string) => Promise<MongoClient$1>;
|
|
701
706
|
declare const makeCol: <T extends ID>(docs: readonly OptionalUnlessRequiredId<T>[], database: Db, name?: string) => Promise<Collection<T>>;
|
|
702
707
|
|
|
703
|
-
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, $substr, $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 };
|
|
708
|
+
export { $accumulator, $and, $countDict, $countDictArray, $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, $substr, $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, emptyDelta, 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 };
|
|
704
709
|
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
|
@@ -249,6 +249,23 @@ const $countDict = (expr) => $accumulator(function () {
|
|
|
249
249
|
return y ? (a[k] = y) : delete a[k], a;
|
|
250
250
|
}, a || {});
|
|
251
251
|
});
|
|
252
|
+
const $countDictArray = (expr) => $accumulator(function () {
|
|
253
|
+
return {};
|
|
254
|
+
}, [sub(expr, root().of('v')), root().of('old').expr()], function (a, keys, old) {
|
|
255
|
+
keys.forEach(k => {
|
|
256
|
+
const y = (a[k] || 0) + (old ? -1 : 1);
|
|
257
|
+
if (y)
|
|
258
|
+
a[k] = y;
|
|
259
|
+
else
|
|
260
|
+
delete a[k];
|
|
261
|
+
});
|
|
262
|
+
return a;
|
|
263
|
+
}, function (a, b) {
|
|
264
|
+
return Object.keys(b).reduce((a, k) => {
|
|
265
|
+
let y = (a[k] || 0) + b[k];
|
|
266
|
+
return y ? (a[k] = y) : delete a[k], a;
|
|
267
|
+
}, a || {});
|
|
268
|
+
});
|
|
252
269
|
const $pushDict = (key, value) => $accumulator(function () {
|
|
253
270
|
return {};
|
|
254
271
|
}, [
|
|
@@ -296,7 +313,35 @@ const $entries = (expr) => func(function (obj) {
|
|
|
296
313
|
return Object.entries({ ...obj }).flatMap(([k, v]) => v[0].map(v => ({ k, v })));
|
|
297
314
|
}, expr);
|
|
298
315
|
|
|
299
|
-
const
|
|
316
|
+
const asStages = (x) => x;
|
|
317
|
+
const concatStages = (part1, part2) => asStages([...part1, ...part2]);
|
|
318
|
+
const concatDelta = (part1, part2) => ({
|
|
319
|
+
delta: concatStages(part1.delta, part2.delta),
|
|
320
|
+
raw: f => concatStages(part1.raw(f), part2.raw(f)),
|
|
321
|
+
});
|
|
322
|
+
const pipe = (stream, s, concat, empty) => {
|
|
323
|
+
const acc = {
|
|
324
|
+
with: (map) => pipe(map(i => stream(concat(s, i))), empty(), concat, empty),
|
|
325
|
+
then: (next) => pipe(stream, concat(s, next), concat, empty),
|
|
326
|
+
get: () => stream(s),
|
|
327
|
+
};
|
|
328
|
+
return acc;
|
|
329
|
+
};
|
|
330
|
+
const concat$1 = (stages) => ({
|
|
331
|
+
with: extra => concat$1(concatStages(stages, extra)),
|
|
332
|
+
stages,
|
|
333
|
+
});
|
|
334
|
+
const link = () => ({
|
|
335
|
+
with: extra => concat$1(extra),
|
|
336
|
+
stages: asStages([]),
|
|
337
|
+
});
|
|
338
|
+
const emptyDelta = () => ({
|
|
339
|
+
delta: link().stages,
|
|
340
|
+
raw: () => link().stages,
|
|
341
|
+
});
|
|
342
|
+
const concatTStages = ({ coll, exec, input }, stages) => ({ coll, input, exec: concatStages(exec, stages) });
|
|
343
|
+
|
|
344
|
+
const concat = (...expr) => asExpr({
|
|
300
345
|
raw: f => asExprRaw({ $concat: expr.map(e => e.raw(f).get()) }),
|
|
301
346
|
});
|
|
302
347
|
const $substr = (expr, start, length) => asExpr({
|
|
@@ -357,34 +402,6 @@ const omitRORec = () => assertEqual();
|
|
|
357
402
|
const omitPick = () => assertEqual();
|
|
358
403
|
const translateOmit = () => assertEqual();
|
|
359
404
|
|
|
360
|
-
const asStages = (x) => x;
|
|
361
|
-
const concatStages = (part1, part2) => asStages([...part1, ...part2]);
|
|
362
|
-
const concatDelta = (part1, part2) => ({
|
|
363
|
-
delta: concatStages(part1.delta, part2.delta),
|
|
364
|
-
raw: f => concatStages(part1.raw(f), part2.raw(f)),
|
|
365
|
-
});
|
|
366
|
-
const pipe = (stream, s, concat, empty) => {
|
|
367
|
-
const acc = {
|
|
368
|
-
with: (map) => pipe(map(i => stream(concat(s, i))), empty(), concat, empty),
|
|
369
|
-
then: (next) => pipe(stream, concat(s, next), concat, empty),
|
|
370
|
-
get: () => stream(s),
|
|
371
|
-
};
|
|
372
|
-
return acc;
|
|
373
|
-
};
|
|
374
|
-
const concat = (stages) => ({
|
|
375
|
-
with: extra => concat(concatStages(stages, extra)),
|
|
376
|
-
stages,
|
|
377
|
-
});
|
|
378
|
-
const link = () => ({
|
|
379
|
-
with: extra => concat(extra),
|
|
380
|
-
stages: asStages([]),
|
|
381
|
-
});
|
|
382
|
-
const emptyDelta = () => ({
|
|
383
|
-
delta: link().stages,
|
|
384
|
-
raw: () => link().stages,
|
|
385
|
-
});
|
|
386
|
-
const concatTStages = ({ coll, exec, input }, stages) => ({ coll, input, exec: concatStages(exec, stages) });
|
|
387
|
-
|
|
388
405
|
const size = (expr) => asExpr({
|
|
389
406
|
raw: f => asExprRaw({ $size: expr.raw(f).get() }),
|
|
390
407
|
});
|
|
@@ -941,7 +958,7 @@ const subMerge = (args, out, gid, extra, idPrefix, first) => {
|
|
|
941
958
|
const gidPath = root().of(gid).expr();
|
|
942
959
|
const mapId = (k, v) => map1(k, v);
|
|
943
960
|
const F1 = {
|
|
944
|
-
_id: ['_id', to(idPrefix ? concat
|
|
961
|
+
_id: ['_id', to(idPrefix ? concat(val(idPrefix), $rand) : $rand)],
|
|
945
962
|
touchedAt: ['touchedAt', to(current)],
|
|
946
963
|
};
|
|
947
964
|
const F2 = mapId(gid, to(gidPath));
|
|
@@ -2280,4 +2297,4 @@ const executes = (view, input, needs) => {
|
|
|
2280
2297
|
};
|
|
2281
2298
|
const single = (view, needs = {}) => pipe(input => executes(view, input, needs), emptyDelta(), concatDelta, emptyDelta);
|
|
2282
2299
|
|
|
2283
|
-
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, $substr, $sum, $type, $unwind, $unwindDelta, Field, Machine, add, and, anyElementTrue, array, ceil, comp, concat
|
|
2300
|
+
export { $accumulator, $and, $countDict, $countDictArray, $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, $substr, $sum, $type, $unwind, $unwindDelta, Field, Machine, add, and, anyElementTrue, array, ceil, comp, concat, concatArray, createIndex, ctx, current, dateAdd, dateDiff, dateLt, datePart, dayAndMonthPart, divide, emptyDelta, 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
|
@@ -251,6 +251,23 @@ const $countDict = (expr) => $accumulator(function () {
|
|
|
251
251
|
return y ? (a[k] = y) : delete a[k], a;
|
|
252
252
|
}, a || {});
|
|
253
253
|
});
|
|
254
|
+
const $countDictArray = (expr) => $accumulator(function () {
|
|
255
|
+
return {};
|
|
256
|
+
}, [sub(expr, root().of('v')), root().of('old').expr()], function (a, keys, old) {
|
|
257
|
+
keys.forEach(k => {
|
|
258
|
+
const y = (a[k] || 0) + (old ? -1 : 1);
|
|
259
|
+
if (y)
|
|
260
|
+
a[k] = y;
|
|
261
|
+
else
|
|
262
|
+
delete a[k];
|
|
263
|
+
});
|
|
264
|
+
return a;
|
|
265
|
+
}, function (a, b) {
|
|
266
|
+
return Object.keys(b).reduce((a, k) => {
|
|
267
|
+
let y = (a[k] || 0) + b[k];
|
|
268
|
+
return y ? (a[k] = y) : delete a[k], a;
|
|
269
|
+
}, a || {});
|
|
270
|
+
});
|
|
254
271
|
const $pushDict = (key, value) => $accumulator(function () {
|
|
255
272
|
return {};
|
|
256
273
|
}, [
|
|
@@ -298,7 +315,35 @@ const $entries = (expr) => func(function (obj) {
|
|
|
298
315
|
return Object.entries({ ...obj }).flatMap(([k, v]) => v[0].map(v => ({ k, v })));
|
|
299
316
|
}, expr);
|
|
300
317
|
|
|
301
|
-
const
|
|
318
|
+
const asStages = (x) => x;
|
|
319
|
+
const concatStages = (part1, part2) => asStages([...part1, ...part2]);
|
|
320
|
+
const concatDelta = (part1, part2) => ({
|
|
321
|
+
delta: concatStages(part1.delta, part2.delta),
|
|
322
|
+
raw: f => concatStages(part1.raw(f), part2.raw(f)),
|
|
323
|
+
});
|
|
324
|
+
const pipe = (stream, s, concat, empty) => {
|
|
325
|
+
const acc = {
|
|
326
|
+
with: (map) => pipe(map(i => stream(concat(s, i))), empty(), concat, empty),
|
|
327
|
+
then: (next) => pipe(stream, concat(s, next), concat, empty),
|
|
328
|
+
get: () => stream(s),
|
|
329
|
+
};
|
|
330
|
+
return acc;
|
|
331
|
+
};
|
|
332
|
+
const concat$1 = (stages) => ({
|
|
333
|
+
with: extra => concat$1(concatStages(stages, extra)),
|
|
334
|
+
stages,
|
|
335
|
+
});
|
|
336
|
+
const link = () => ({
|
|
337
|
+
with: extra => concat$1(extra),
|
|
338
|
+
stages: asStages([]),
|
|
339
|
+
});
|
|
340
|
+
const emptyDelta = () => ({
|
|
341
|
+
delta: link().stages,
|
|
342
|
+
raw: () => link().stages,
|
|
343
|
+
});
|
|
344
|
+
const concatTStages = ({ coll, exec, input }, stages) => ({ coll, input, exec: concatStages(exec, stages) });
|
|
345
|
+
|
|
346
|
+
const concat = (...expr) => asExpr({
|
|
302
347
|
raw: f => asExprRaw({ $concat: expr.map(e => e.raw(f).get()) }),
|
|
303
348
|
});
|
|
304
349
|
const $substr = (expr, start, length) => asExpr({
|
|
@@ -359,34 +404,6 @@ const omitRORec = () => assertEqual();
|
|
|
359
404
|
const omitPick = () => assertEqual();
|
|
360
405
|
const translateOmit = () => assertEqual();
|
|
361
406
|
|
|
362
|
-
const asStages = (x) => x;
|
|
363
|
-
const concatStages = (part1, part2) => asStages([...part1, ...part2]);
|
|
364
|
-
const concatDelta = (part1, part2) => ({
|
|
365
|
-
delta: concatStages(part1.delta, part2.delta),
|
|
366
|
-
raw: f => concatStages(part1.raw(f), part2.raw(f)),
|
|
367
|
-
});
|
|
368
|
-
const pipe = (stream, s, concat, empty) => {
|
|
369
|
-
const acc = {
|
|
370
|
-
with: (map) => pipe(map(i => stream(concat(s, i))), empty(), concat, empty),
|
|
371
|
-
then: (next) => pipe(stream, concat(s, next), concat, empty),
|
|
372
|
-
get: () => stream(s),
|
|
373
|
-
};
|
|
374
|
-
return acc;
|
|
375
|
-
};
|
|
376
|
-
const concat = (stages) => ({
|
|
377
|
-
with: extra => concat(concatStages(stages, extra)),
|
|
378
|
-
stages,
|
|
379
|
-
});
|
|
380
|
-
const link = () => ({
|
|
381
|
-
with: extra => concat(extra),
|
|
382
|
-
stages: asStages([]),
|
|
383
|
-
});
|
|
384
|
-
const emptyDelta = () => ({
|
|
385
|
-
delta: link().stages,
|
|
386
|
-
raw: () => link().stages,
|
|
387
|
-
});
|
|
388
|
-
const concatTStages = ({ coll, exec, input }, stages) => ({ coll, input, exec: concatStages(exec, stages) });
|
|
389
|
-
|
|
390
407
|
const size = (expr) => asExpr({
|
|
391
408
|
raw: f => asExprRaw({ $size: expr.raw(f).get() }),
|
|
392
409
|
});
|
|
@@ -943,7 +960,7 @@ const subMerge = (args, out, gid, extra, idPrefix, first) => {
|
|
|
943
960
|
const gidPath = root().of(gid).expr();
|
|
944
961
|
const mapId = (k, v) => map1(k, v);
|
|
945
962
|
const F1 = {
|
|
946
|
-
_id: ['_id', to(idPrefix ? concat
|
|
963
|
+
_id: ['_id', to(idPrefix ? concat(val(idPrefix), $rand) : $rand)],
|
|
947
964
|
touchedAt: ['touchedAt', to(current)],
|
|
948
965
|
};
|
|
949
966
|
const F2 = mapId(gid, to(gidPath));
|
|
@@ -2285,6 +2302,7 @@ const single = (view, needs = {}) => pipe(input => executes(view, input, needs),
|
|
|
2285
2302
|
exports.$accumulator = $accumulator;
|
|
2286
2303
|
exports.$and = $and;
|
|
2287
2304
|
exports.$countDict = $countDict;
|
|
2305
|
+
exports.$countDictArray = $countDictArray;
|
|
2288
2306
|
exports.$entries = $entries;
|
|
2289
2307
|
exports.$eq = $eq;
|
|
2290
2308
|
exports.$exists = $exists;
|
|
@@ -2344,7 +2362,7 @@ exports.anyElementTrue = anyElementTrue;
|
|
|
2344
2362
|
exports.array = array;
|
|
2345
2363
|
exports.ceil = ceil;
|
|
2346
2364
|
exports.comp = comp;
|
|
2347
|
-
exports.concat = concat
|
|
2365
|
+
exports.concat = concat;
|
|
2348
2366
|
exports.concatArray = concatArray;
|
|
2349
2367
|
exports.createIndex = createIndex;
|
|
2350
2368
|
exports.ctx = ctx;
|
|
@@ -2355,6 +2373,7 @@ exports.dateLt = dateLt;
|
|
|
2355
2373
|
exports.datePart = datePart;
|
|
2356
2374
|
exports.dayAndMonthPart = dayAndMonthPart;
|
|
2357
2375
|
exports.divide = divide;
|
|
2376
|
+
exports.emptyDelta = emptyDelta;
|
|
2358
2377
|
exports.enablePreAndPostImages = enablePreAndPostImages;
|
|
2359
2378
|
exports.eq = eq;
|
|
2360
2379
|
exports.eqTyped = eqTyped;
|
package/package.json
CHANGED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import type { AppMap, Arr, N, O, Rec } from '../../types';
|
|
2
|
-
import type { ExprHKT } from '../expression/concat';
|
|
3
|
-
import { type NoRaw } from '../expression/val';
|
|
4
|
-
import type { DeltaAccumulator, Expr, Part } from '../types';
|
|
5
|
-
export declare const $sum: <D extends O, C = unknown>(expr: Expr<number | N, D, C>) => DeltaAccumulator<D, number, C>;
|
|
6
|
-
export declare const $accumulator: <D, T, Ctx, A extends readonly unknown[]>(init: () => NoRaw<T>, accumulateArgs: AppMap<ExprHKT<Part<D>, Ctx>, A>, accumulate: (a: NoRaw<T>, ...args: NoRaw<A>) => NoRaw<T>, merge: (...args: NoRaw<[T | N, T]>) => NoRaw<T>) => DeltaAccumulator<D, T, Ctx>;
|
|
7
|
-
export declare const $countDict: <D extends O, C = unknown>(expr: Expr<string, D, C>) => DeltaAccumulator<D, Rec<string, number>, C>;
|
|
8
|
-
export declare const $pushDict: <D extends O, V, C = unknown>(key: Expr<string, D, C>, value: Expr<V, D, C>) => DeltaAccumulator<D, Rec<string, Rec<"0" | "1", Arr<V>>>, C>;
|
|
9
|
-
export declare const $keys: <D extends O, C = unknown>(expr: Expr<Rec<string, number>, D, C>) => Expr<Arr<string>, D, C>;
|
|
10
|
-
export declare const $entries: <D extends O, V, C = unknown>(expr: Expr<Rec<string, Rec<"1" | "0", Arr<V>>>, D, C>) => Expr<Arr<Rec<"k", string> & Rec<"v", V>>, D, C>;
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import type { IdHKT, OPick, RWCollection, Timestamp } from '../../types';
|
|
2
|
-
import type { doc, ID, N, O, rawItem, Rec, Replace, RORec, StrKey } from '../../types/json';
|
|
3
|
-
import { type ExprsExact } from '../expression/concat';
|
|
4
|
-
import type { Delta, Expr, IsDeleted, Model, RawStages, StreamRunnerParam, TS } from '../types';
|
|
5
|
-
import { type Exact } from '../utils/map-object';
|
|
6
|
-
type OutInputE<T, E, A = T | null> = ID & Rec<'after', A> & E;
|
|
7
|
-
type Allowed<K extends string> = Exclude<K, keyof (TS & ID)>;
|
|
8
|
-
export type Patch<V, KK extends StrKey<V> = StrKey<V>> = ((OPick<V, Allowed<KK>> & ID) | (Rec<Allowed<KK>, N> & ID)) & TS;
|
|
9
|
-
type TakeDoc<V, E = ID, KK extends StrKey<V> = StrKey<V>> = OPick<V, Allowed<KK>> & E;
|
|
10
|
-
type ND = {
|
|
11
|
-
readonly deletedAt?: null;
|
|
12
|
-
};
|
|
13
|
-
type SafeE<E> = Omit<E, `$${string}` | keyof ID>;
|
|
14
|
-
type Args<P, Out> = [added: Expr<P, unknown, {
|
|
15
|
-
new: P;
|
|
16
|
-
}>, old: Expr<Out, Out>];
|
|
17
|
-
type Result<P> = Expr<P, unknown, {
|
|
18
|
-
new: P;
|
|
19
|
-
}>;
|
|
20
|
-
type Update<P, Out> = (...args: Args<P, Out>) => Result<P>;
|
|
21
|
-
type UpdateF<P, Out> = <K extends keyof IsDeleted>(...args: Args<Replace<P, RORec<K, Timestamp>>, Out>) => Result<Replace<P, RORec<K, Timestamp>>>;
|
|
22
|
-
export declare const getWhenMatchedForMerge: <Out extends Model, P extends Model, K extends keyof IsDeleted>(whenNotMatched: "discard" | "fail" | "insert", update: Update<Replace<P, RORec<K, Timestamp>>, Out>) => RawStages<O, Out, Out | Replace<Out, P>, RORec<"new", Replace<P, RORec<K, Timestamp>>>>;
|
|
23
|
-
export declare const getWhenMatched: <Out extends Model, P extends Model, K extends keyof IsDeleted>(whenNotMatched: "discard" | "fail" | "insert") => RawStages<O, Rec<"old" | "merged", Out | Replace<Out, P>>, Out | Replace<Out, P>>;
|
|
24
|
-
type MergeCollection<V extends O, Out extends Model> = {
|
|
25
|
-
coll: RWCollection<Out | Replace<Out, Patch<V>> | Replace<Patch<V>, IsDeleted>, Out>;
|
|
26
|
-
whenNotMatched: 'discard';
|
|
27
|
-
} | {
|
|
28
|
-
coll: RWCollection<Out | Replace<Out, Patch<V>>, Out>;
|
|
29
|
-
whenNotMatched: 'fail';
|
|
30
|
-
};
|
|
31
|
-
type MergeUpdate<V, Out> = UpdateF<((OPick<V, Allowed<StrKey<V>>> & ID) | (Rec<Allowed<StrKey<V>>, N> & ID)) & TS, Out>;
|
|
32
|
-
export declare const $mergeId: <V extends O>() => <SourcePart extends doc, Out extends Model, E = unknown, EEE extends RORec<string, rawItem> = {}>(out: MergeCollection<V, Out>, keys: ExprsExact<TakeDoc<V, unknown>, SourcePart>, id: Expr<string, OutInputE<TakeDoc<V>, E, null>>, ext: Exact<Omit<SafeE<EEE>, keyof (ND & TS)>, IdHKT>, update?: MergeUpdate<V, Out>) => StreamRunnerParam<OutInputE<SourcePart, E>, "out">;
|
|
33
|
-
export declare const $simpleMergePart: <V extends O>() => <Source extends doc, Out extends Model, EEE extends RORec<string, rawItem>>(out: MergeCollection<V, Out>, keys: ExprsExact<TakeDoc<V, unknown>, Source>, ext: Exact<Omit<SafeE<EEE>, keyof (ND & TS)>, IdHKT>, update?: MergeUpdate<V, Out>) => StreamRunnerParam<Source, "out">;
|
|
34
|
-
export declare const $simpleMerge: <V extends O>() => <Source extends doc, Out extends Model>(out: RWCollection<Out | Replace<Out, Patch<V>> | Replace<Patch<V>, IsDeleted>, Out>, keys: ExprsExact<TakeDoc<V, unknown>, Source>, whenNotMatched?: "fail" | "discard", update?: MergeUpdate<V, Out>) => StreamRunnerParam<Source, "out">;
|
|
35
|
-
export declare const $mergePart: <V extends O>() => <Out extends Model, 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<EEE>, keyof (ND & TS)>, IdHKT>, update?: MergeUpdate<V, Out>) => StreamRunnerParam<Delta<SourcePart>, "out">;
|
|
36
|
-
export declare const $merge: <V extends O>() => <Out extends Model, SourcePart extends doc>(out: RWCollection<Out | Replace<Out, Patch<V>>, Out>, keys: ExprsExact<TakeDoc<V, unknown>, SourcePart>, update?: MergeUpdate<V, Out>) => StreamRunnerParam<Delta<SourcePart>, "out">;
|
|
37
|
-
export {};
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import type { IdHKT, Replace, RWCollection } from '../../types';
|
|
2
|
-
import type { ID, O, RORec, doc, rawItem } from '../../types/json';
|
|
3
|
-
import { type ExprsExact } from '../expression/concat';
|
|
4
|
-
import type { Del, Delta, Expr, StreamRunnerParam, TS } from '../types';
|
|
5
|
-
import { type Exact } from '../utils/map-object';
|
|
6
|
-
type ND = {
|
|
7
|
-
readonly deletedAt?: null;
|
|
8
|
-
};
|
|
9
|
-
type SafeE<E> = Omit<E, `$${string}` | keyof ID>;
|
|
10
|
-
export type Merge<T extends doc, E> = Omit<SafeE<E>, keyof (ND & TS)> & ((T & ND & TS) | Del);
|
|
11
|
-
type ExprP<P> = Expr<P, unknown, {
|
|
12
|
-
new: P;
|
|
13
|
-
}>;
|
|
14
|
-
type Update<P, Out> = (added: ExprP<P>, old: Expr<Out, Out>) => ExprP<P>;
|
|
15
|
-
export declare const $insertX: <T extends doc, D extends O, EEE extends RORec<string, rawItem>>(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: Exact<Omit<SafeE<EEE>, keyof (ND & TS)>, IdHKT>, extExpr: ExprsExact<Omit<SafeE<EEE>, keyof (ND & TS)>, unknown>, update?: Update<Replace<Merge<T, EEE>, {}>, Merge<T, EEE>>) => StreamRunnerParam<D, "out">;
|
|
16
|
-
export declare const $simpleInsert: <T extends doc>(out: RWCollection<Merge<T, {}>>) => StreamRunnerParam<T, "out">;
|
|
17
|
-
export declare const $insertPart: <T extends doc, EEE extends RORec<string, rawItem>>(out: RWCollection<Merge<T, EEE>>, ext: Exact<Omit<SafeE<EEE>, keyof (ND & TS)>, IdHKT>) => StreamRunnerParam<Delta<T>, "out">;
|
|
18
|
-
export declare const $insert: <T extends doc>(out: RWCollection<Merge<T, {}>>) => StreamRunnerParam<Delta<T>, "out">;
|
|
19
|
-
export {};
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import type { RWCollection, WriteonlyCollection } from '../../../types';
|
|
2
|
-
import type { AsLiteral, ID, O, Rec, doc, notArr } from '../../../types/json';
|
|
3
|
-
import { type ExprsExact } from '../../expression/concat';
|
|
4
|
-
import type { Delta, DeltaAccumulators, Expr, StreamRunnerParam, TS } from '../../types';
|
|
5
|
-
import type { MergeInto } from '../out';
|
|
6
|
-
import { type Extra, type IdAndTsKeys, type Loose, type MergedInput, type Strict, type V_Grp } from './utils/sub-merge';
|
|
7
|
-
type Denied<GID = never> = keyof (TS & ID) | GID;
|
|
8
|
-
type GI<GG> = Exclude<GG, keyof TS>;
|
|
9
|
-
export declare const $groupMerge: <T extends O, Grp extends notArr, V extends O, GG extends string, EE = {}, Out extends Loose<Grp, V, GG> = Loose<Grp, V, GG>>(id: Expr<Grp, T>, args: DeltaAccumulators<T, O & Omit<V, Denied<GI<GG>>>>, out: MergeInto<Strict<Grp, V, GG, EE>, Out, WriteonlyCollection<MergedInput<Out, V, Grp, GG, EE>>>, gid: AsLiteral<GI<GG>>, extra: ExprsExact<Extra<EE, V, GG>, V_Grp<V, GG, Grp>>, idPrefix?: string) => StreamRunnerParam<Delta<T>, "out">;
|
|
10
|
-
export declare const $groupId: <T extends O, V extends O, EE = {}, Out extends Loose<string, V, "_id"> = Loose<string, V, "_id">>(id: Expr<string, T>, args: DeltaAccumulators<T, O & Omit<V, Denied>>, out: RWCollection<MergedInput<Out, V, string, "_id", EE>, Out>, extra: ExprsExact<Omit<EE, IdAndTsKeys | keyof Omit<V, IdAndTsKeys>>, doc & Omit<V, IdAndTsKeys>>) => StreamRunnerParam<Delta<T>, "out">;
|
|
11
|
-
export declare const $group: <T extends O, Grp extends notArr, V extends O, EE = {}, Out extends Loose<Grp, V, "_grp"> = Loose<Grp, V, "_grp">>(id: Expr<Grp, T>, args: DeltaAccumulators<T, O & Omit<V, Denied<"_grp">>>, out: RWCollection<MergedInput<Out, V, Grp, "_grp", EE> | Strict<Grp, V, "_grp", EE>, Out>, extra: ExprsExact<Omit<EE, IdAndTsKeys | "_grp" | Exclude<keyof V, IdAndTsKeys | "_grp">>, Rec<"_grp", Grp> & Omit<V, IdAndTsKeys | "_grp">>, idPrefix?: string) => StreamRunnerParam<Delta<T>, "out">;
|
|
12
|
-
export {};
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import type { O, RORec, Rec } from '../../../../types';
|
|
2
|
-
import { type ExprsExact } from '../../../expression/concat';
|
|
3
|
-
import type { Delta, Expr, RawStages } from '../../../types';
|
|
4
|
-
import type { DeltaAccumulators } from '../../../types/accumulator';
|
|
5
|
-
export type WithItem<V, Grp> = Rec<'_id', Grp> & Rec<'item', O<V>>;
|
|
6
|
-
export declare const subGroup: <T extends O, Grp, V extends O, GID extends string>(id: Expr<Grp, T>, args: DeltaAccumulators<T, V>, addGrp: <D extends Rec<"_id", Grp>>(src: ExprsExact<V, D>) => ExprsExact<RORec<GID, Grp> & V, D>) => RawStages<unknown, Delta<T>, Rec<GID, Grp> & V>;
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import type { AsLiteral, ID, O, Rec, Replace, WriteonlyCollection, notArr } from '../../../../types';
|
|
2
|
-
import { type ExprsExact } from '../../../expression/concat';
|
|
3
|
-
import type { Model, RawStages, TS } from '../../../types';
|
|
4
|
-
import type { DeltaAccumulators } from '../../../types/accumulator';
|
|
5
|
-
import { type MergeInto } from '../../out';
|
|
6
|
-
type GI<GG> = Exclude<GG, keyof TS>;
|
|
7
|
-
export type IdAndTsKeys = keyof (TS & ID);
|
|
8
|
-
type V<VV, GG extends string> = Omit<VV, IdAndTsKeys | GI<GG>>;
|
|
9
|
-
export type Prepare<Grp, GG extends string> = TS & ID & Rec<GI<GG>, Grp>;
|
|
10
|
-
type Par<T> = {
|
|
11
|
-
[P in keyof T]?: T[P] | null;
|
|
12
|
-
};
|
|
13
|
-
export type Loose<Grp, VV, GG extends string> = Prepare<Grp, GG> & Par<V<VV, GG>>;
|
|
14
|
-
export type Strict<Grp, VV, GG extends string, EE> = Prepare<Grp, GG> & V<VV, GG> & Omit<EE, IdAndTsKeys | GI<GG> | keyof V<VV, GG>>;
|
|
15
|
-
export type V_Grp<VV, GG extends string, Grp> = Rec<GI<GG>, Grp> & V<VV, GG>;
|
|
16
|
-
export type Extra<EE, VV, GG extends string> = Omit<EE, IdAndTsKeys | GI<GG> | keyof V<VV, GG>>;
|
|
17
|
-
type OrReplace<T, V> = T | Replace<T, V>;
|
|
18
|
-
export type MergedInput<Out, VV, Grp, GG extends string, EE> = OrReplace<Replace<Replace<Out, V<VV, GG>>, Extra<EE, VV, GG>> & Model, TS & ID & V_Grp<VV, GG, Grp> & Extra<EE, VV, GG>>;
|
|
19
|
-
export declare const subMerge: <T extends O, Grp extends notArr, VV extends O, GG extends string, EE = {}, Out extends Loose<Grp, VV, GG> = Loose<Grp, VV, GG>>(args: DeltaAccumulators<T, V<VV, GG>>, out: MergeInto<Strict<Grp, VV, GG, EE>, Out, WriteonlyCollection<MergedInput<Out, VV, Grp, GG, EE>>>, gid: AsLiteral<GI<GG>>, extra: ExprsExact<Extra<EE, VV, GG>, V_Grp<VV, GG, Grp>>, idPrefix: string, first: boolean) => RawStages<unknown, V_Grp<VV, GG, Grp>, "out">;
|
|
20
|
-
export {};
|
package/lib/aggregate/index.d.ts
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import type { Arr, AsLiteral, ID, N, O, Rec, doc, rawItem } from '../../../types';
|
|
2
|
-
import { Field } from '../../field';
|
|
3
|
-
import type { BA, Before, Delta, RawStages, TStages, UBefore } from '../../types';
|
|
4
|
-
type s = string;
|
|
5
|
-
type Both<K1 extends s, LE, KK2 extends s, RE, N1 extends null = never, N2 extends null = never> = Delta<Rec<K1, LE | N1> & Rec<Exclude<KK2, BA | K1>, RE | N2> & ID>;
|
|
6
|
-
export declare const $lookupDelta: <LQ extends O, LE extends LQ & doc, RQ extends O, RE extends RQ & doc, BRB extends UBefore<RQ>, RS extends UBefore<RQ>, S extends rawItem, K1 extends s, KK2 extends s, N1 extends null = never, N2 extends null = never>({ field1, field2 }: {
|
|
7
|
-
field1: Field<LQ, S | N | Arr<S>>;
|
|
8
|
-
field2: Field<RQ, S | N | Arr<S>>;
|
|
9
|
-
}, { coll, exec, input }: TStages<RS, UBefore<RQ>, BRB, Before<RE>>, k1: AsLiteral<K1>, k2: AsLiteral<Exclude<KK2, BA | K1>>, k: ([N1] extends [never] ? K1 : never) | ([N2] extends [never] ? Exclude<KK2, BA | K1> : never) | false, includeNull1?: N1, includeNull2?: N2) => RawStages<unknown, Delta<LE>, Both<K1, LE, KK2, RE, N1, N2>>;
|
|
10
|
-
export {};
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import type { App, Arr, AsLiteral, HKT, ID, O, Rec } from '../../../types';
|
|
2
|
-
import { type Field } from '../../field';
|
|
3
|
-
import type { Before, RawStages, TStages, UBefore } from '../../types';
|
|
4
|
-
type s = string;
|
|
5
|
-
export declare const $lookupRaw: <LQ extends O, LE extends LQ & ID, RQ extends O, RE extends RQ & ID, BRB extends Before<RQ>, RS extends UBefore<RQ>, S, As extends s, Null extends null = never>({ field1, field2 }: {
|
|
6
|
-
field1: Field<LQ, S | Arr<S>>;
|
|
7
|
-
field2: Field<RQ, S | Arr<S>>;
|
|
8
|
-
}, { coll, exec, input }: TStages<RS, Before<RQ>, BRB, Before<RE>>, k2: AsLiteral<As>, k: "left", includeNull?: Null) => <F extends HKT<O, O>>(f: <T extends O>() => Field<App<F, T>, T>) => RawStages<App<F, LQ>, App<F, LE>, App<F, LE & Rec<As, RE> & ID>>;
|
|
9
|
-
export {};
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { type AsLiteral, type O, type RORec, type doc, type notArr, type Arr } from '../../../types';
|
|
2
|
-
import { type Field } from '../../field';
|
|
3
|
-
import type { SnapshotStream, SnapshotStreamExecutionResult } from '../../types/stream';
|
|
4
|
-
type Params<As extends string, LQ extends O, RQ extends O, RE extends RQ, S extends notArr> = {
|
|
5
|
-
localField: Field<LQ, S | Arr<S>>;
|
|
6
|
-
foreignField: Field<RQ, S | Arr<S>>;
|
|
7
|
-
from: SnapshotStreamExecutionResult<RQ, RE>;
|
|
8
|
-
as: AsLiteral<As>;
|
|
9
|
-
};
|
|
10
|
-
export declare const $lookup: <As extends string, LQ extends doc, RQ extends O, RE extends RQ & doc, S extends notArr>(p: Params<As, LQ, RQ, RE, S>) => <LE extends LQ>(l: SnapshotStream<LQ, LE>) => SnapshotStream<LQ, LE & RORec<As, RE>>;
|
|
11
|
-
export declare const $outerLookup: <As extends string, LQ extends doc, RQ extends O, RE extends RQ & doc, S extends notArr>(p: Params<As, LQ, RQ, RE, S>) => <LE extends LQ>(l: SnapshotStream<LQ, LE>) => SnapshotStream<LQ, LE & RORec<As, RE | null>>;
|
|
12
|
-
export {};
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import type { Arr, O, Rec } from '../../types';
|
|
2
|
-
import type { Accumulators, Expr, LookupArgs, Query, RawStages } from '../types';
|
|
3
|
-
import type { Updater } from '../update/updater';
|
|
4
|
-
export * from './raws';
|
|
5
|
-
type s = string;
|
|
6
|
-
export declare const $match_: <Q, T extends Q & O, C = unknown>(query?: Query<T, C>) => RawStages<O<T>, T, T, C>;
|
|
7
|
-
export declare const $set_: <Q, T extends Q & O, V extends Q & O, C = unknown>(updater: Updater<T, T, V, C>) => RawStages<O<Q>, T, V, C, 1>;
|
|
8
|
-
export declare const $replaceWith_: <T extends O, V extends O, C = unknown>(expr: Expr<V, T, C>) => RawStages<O, T, V, C, 1>;
|
|
9
|
-
export declare const $unwind_: <T extends O, K extends s, U, Null extends null = never>(k: K, includeNull?: Null) => RawStages<O<T>, T & Rec<K, Arr<U>>, T & Rec<K, Null | U>>;
|
|
10
|
-
export 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>;
|
|
11
|
-
export declare const $documents_: <T extends O, C>(docs: Expr<Arr<T>, unknown, C>) => RawStages<unknown, null, T, C, 1>;
|
|
12
|
-
export declare const $project_: <T extends O, K extends import("../..").StrKey<T>>(projection: import("../utils").ExactKeys<K>) => RawStages<T, T, T, unknown, 1>;
|
|
13
|
-
export declare const $simpleLookup_: <T extends O, U extends O, R, K extends s, Ctx, C = unknown, S = string>(args: LookupArgs<T, U, R, K, Ctx, C, S>) => RawStages<O<T>, T, T & Rec<K, Arr<U>>, C, 1>;
|
package/lib/aggregate/out.d.ts
DELETED
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import type { O, RWCollection, ReadonlyCollection, Replace, jsonItem } from '../../types';
|
|
2
|
-
import type { ExprsExact } from '../expression/concat';
|
|
3
|
-
import { type Field } from '../field';
|
|
4
|
-
import type { RawStages } from '../types';
|
|
5
|
-
export type MergeInto<T extends O, Out extends O, E = unknown> = {
|
|
6
|
-
whenNotMatched: 'insert';
|
|
7
|
-
into: RWCollection<T, Out> & E;
|
|
8
|
-
} | {
|
|
9
|
-
whenNotMatched: 'discard' | 'fail';
|
|
10
|
-
into: ReadonlyCollection<Out> & E;
|
|
11
|
-
};
|
|
12
|
-
export type MergeArgs<T extends O, Out extends O, Ctx, In extends O> = {
|
|
13
|
-
on: Field<T, jsonItem> & Field<Out, jsonItem>;
|
|
14
|
-
} & MergeInto<T, Out> & (({
|
|
15
|
-
stages?: never;
|
|
16
|
-
} & ({
|
|
17
|
-
whenMatched: 'keepExisting' | 'fail';
|
|
18
|
-
} | {
|
|
19
|
-
whenMatched: 'replace';
|
|
20
|
-
into: RWCollection<T, Out>;
|
|
21
|
-
} | {
|
|
22
|
-
whenMatched: 'merge';
|
|
23
|
-
into: RWCollection<Replace<Out, T>, Out>;
|
|
24
|
-
})) | {
|
|
25
|
-
stages: true;
|
|
26
|
-
into: RWCollection<In, Out>;
|
|
27
|
-
whenMatched: RawStages<unknown, Out, In, {
|
|
28
|
-
new: T;
|
|
29
|
-
}>;
|
|
30
|
-
} | {
|
|
31
|
-
stages: 'ctx';
|
|
32
|
-
vars: ExprsExact<Ctx, T>;
|
|
33
|
-
into: RWCollection<In, Out>;
|
|
34
|
-
whenMatched: RawStages<unknown, Out, In, Ctx>;
|
|
35
|
-
});
|
|
36
|
-
export declare const $merge_: <T extends O, Out extends O = T, Ctx = unknown, In extends O = Out>({ into, on, whenNotMatched, ...notMatched }: MergeArgs<T, Out, Ctx, In>) => RawStages<unknown, T, "out", unknown, number>;
|
|
37
|
-
export declare const $merge2: <T extends O, Out extends O = T, Ctx = unknown, In extends O = Out>(args: MergeArgs<T, Out, Ctx, In>) => RawStages<unknown, T, "out", unknown, number>;
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import type { App, HKT, O2, O3, O, RawObj } from '../../types';
|
|
2
|
-
import type { Delta, DeltaStages, FRawStages, RawStages, Stream, TStages } from '../types';
|
|
3
|
-
import type { Equal } from '../utils/guard';
|
|
4
|
-
type n = number;
|
|
5
|
-
export declare const asStages: <Q, T extends Q, V extends Q, C = unknown, M extends n = number>(x: readonly RawObj[]) => RawStages<Q, T, V, C, M>;
|
|
6
|
-
export declare const same: <T extends Dom, V extends Dom, F extends HKT<Dom, Q>, Dom = unknown, Q = unknown, C = unknown, M extends n = number>(_: Equal<Dom, T, V>) => RawStages<Q, App<F, T>, App<F, V>, C, M>;
|
|
7
|
-
export declare const concatStages: <Q, T extends Q, V extends Q, W extends Q, C, M extends n = number>(part1: RawStages<Q, T, V, C, M>, part2: RawStages<Q, V, W, C, M>) => RawStages<Q, T, W, C, M>;
|
|
8
|
-
export declare const concatFStages: <Q, T extends Q & O, V extends Q & O, W extends Q & O, C, M extends n = number>(part1: FRawStages<Q, T, V, C, M>, part2: FRawStages<Q, V, W, C, M>) => FRawStages<Q, T, W, C, M>;
|
|
9
|
-
export declare const concatDelta: <Q extends O, T extends Q, V extends Q, W extends Q>(part1: DeltaStages<Q, T, V>, part2: DeltaStages<Q, V, W>) => DeltaStages<Q, T, W>;
|
|
10
|
-
export type Concat<out Q, in T extends Q, out V extends Q, in out C, in out M extends n = n> = {
|
|
11
|
-
with: <Q2, W extends Q2>(extra: RawStages<Q | Q2, V, W, C, M>) => Concat<Q | Q2, T, W, C, M>;
|
|
12
|
-
stages: RawStages<Q, T, V, C, M>;
|
|
13
|
-
};
|
|
14
|
-
type FConcat<out Q, in T extends Q & O, out V extends Q & O, in out C, in out M extends n = n> = {
|
|
15
|
-
with: <Q2, W extends Q2 & O>(extra: FRawStages<Q | Q2, V, W, C, M>) => FConcat<Q | Q2, T, W, C, M>;
|
|
16
|
-
stages: FRawStages<Q, T, V, C, M>;
|
|
17
|
-
};
|
|
18
|
-
export type DeltaPipe<Q extends O, T extends Q, F extends HKT<O2>, G extends HKT<O3>> = {
|
|
19
|
-
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>;
|
|
20
|
-
then: <Q2 extends O, V extends Q2>(next: App<G, [Q2 | T, T, V]>) => DeltaPipe<Q | Q2, V, F, G>;
|
|
21
|
-
get: () => App<F, [Q, T]>;
|
|
22
|
-
};
|
|
23
|
-
export declare const pipe: <Q extends O, S extends Q, T extends Q, F extends HKT<O2>, G extends HKT<O3>>(stream: Stream<Q, S, F, G>, s: App<G, [Q, S, T]>, concat: <Q_1 extends O, T_1 extends Q_1, V extends Q_1, W extends Q_1>(part1: App<G, [Q_1, T_1, V]>, part2: App<G, [Q_1, V, W]>) => App<G, [Q_1, T_1, W]>, empty: <T_2 extends Q>() => App<G, [Q, T_2, T_2]>) => DeltaPipe<Q, T, F, G>;
|
|
24
|
-
type Link = <T, C = unknown, M extends n = n>() => Concat<T, T, T, C, M>;
|
|
25
|
-
type FLink = <T extends O, C = unknown, M extends n = n>() => FConcat<T, T, T, C, M>;
|
|
26
|
-
export declare const link: Link;
|
|
27
|
-
export declare const flink: FLink;
|
|
28
|
-
export declare const emptyDelta: <T extends O>() => {
|
|
29
|
-
delta: RawStages<Delta<T>, Delta<T>, Delta<T>, unknown, number>;
|
|
30
|
-
raw: <F extends HKT<O>>() => RawStages<App<F, T>, App<F, T>, App<F, T>, unknown, number>;
|
|
31
|
-
};
|
|
32
|
-
export declare const concatTStages: <S, Q, B extends Q, T extends Q, V extends Q>({ coll, exec, input }: TStages<S, Q, B, T>, stages: RawStages<Q, T, V>) => TStages<S, Q, B, V>;
|
|
33
|
-
export {};
|
package/lib/aggregate/raws.d.ts
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import type { App, Arr, ConstHKT, HKT, O, Rec, StrKey, rawItem } from '../../types';
|
|
2
|
-
import type { ExprsExact } from '../expression/concat';
|
|
3
|
-
import { type Field } from '../field';
|
|
4
|
-
import type { Accumulators, Expr, FRawStages, LookupArgs, Query, RawStages } from '../types';
|
|
5
|
-
import type { Updater } from '../update/updater';
|
|
6
|
-
import { type ExactKeys } from '../utils/map-object';
|
|
7
|
-
type s = string;
|
|
8
|
-
export declare const $match1: <T extends O, C = unknown>(query?: Query<T, C>) => FRawStages<T, T, T, C>;
|
|
9
|
-
export declare const $set1: <Q, T extends Q & O, V extends Q & O, C = unknown>(updater: Updater<T, T, V, C>) => FRawStages<Q, T, V, C, 1>;
|
|
10
|
-
export declare const $project1: <T extends O, K extends StrKey<T>>(projection: ExactKeys<K>) => RawStages<T, T, T, unknown, 1>;
|
|
11
|
-
export declare const $replaceWith1: <T extends O, V extends O, C = unknown>(expr: Expr<V, T, C>) => FRawStages<O, T, V, C, 1>;
|
|
12
|
-
export declare const $unwind1: <T extends O, K extends s, R, Null extends null = never>(k: K, includeNull?: Null) => FRawStages<T, T & Rec<K, Arr<R>>, T & Rec<K, R | Null>>;
|
|
13
|
-
export declare const $group1: <T extends O, ID, V extends O, C>(id: Expr<ID, T, C>, args: Accumulators<T, V, C>) => <F extends HKT<O, O>>(f: <T_1 extends O>() => Field<App<F, T_1>, T_1>) => RawStages<O, App<F, T>, Rec<"_id", ID> & V, C, 1>;
|
|
14
|
-
export declare const $documents1: <Q extends O, T extends Q & O, C>(docs: Expr<Arr<T>, unknown, C>) => <F extends HKT<O, O>>(f: <T_1 extends O>() => Field<App<F, T_1>, T_1>) => RawStages<unknown, null, App<F, T>, C, 1>;
|
|
15
|
-
export declare const rawVars: <T, Ctx, C, V extends O>(vars: ExprsExact<Ctx, T, C>, f: Field<V, T, unknown>) => import("../utils/map-object").ExactPart1<Ctx, ConstHKT<rawItem, unknown>>;
|
|
16
|
-
export declare const $simpleLookup1: <T extends O, U extends O, R, K extends s, Ctx, C = unknown, S = string>(args: LookupArgs<T, U, R, K, Ctx, C, S>) => FRawStages<T, T, T & Rec<K, Arr<U>>, C, 1>;
|
|
17
|
-
export {};
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import type { ConstHKT, HKT, I, N, O, RORec, Rec, jsonItem } from '../../../types';
|
|
2
|
-
import type { BA, Delta, Expr, FRawStages, RawStages } from '../../types';
|
|
3
|
-
import { type Updater } from '../../update/updater';
|
|
4
|
-
import { type MapK } from '../../utils/map-object';
|
|
5
|
-
export interface ParDeltaHKT<K extends BA, T extends jsonItem, E> extends HKT<jsonItem> {
|
|
6
|
-
readonly out: RORec<K, I<jsonItem, this>> & Delta<T> & E;
|
|
7
|
-
}
|
|
8
|
-
type Delta2<T extends jsonItem, BA2 extends string> = Delta<T> & Partial<RORec<BA2, T | null>>;
|
|
9
|
-
export declare const $setEach1: <T extends jsonItem, V extends jsonItem, BA2 extends string, E = unknown, C = unknown>(updater: (k: BA) => Updater<Delta<T> & Partial<RORec<BA2, T | null>> & E, T | N, V | null, C>, dict: MapK<BA2, ConstHKT<BA>>) => FRawStages<unknown, Delta2<T, BA2> & E, Rec<BA2, V | null> & Omit<Delta<T> & E, BA2>, C, 1>;
|
|
10
|
-
export declare const $setEach: <T extends O, V extends jsonItem, BA2 extends string, E = unknown, C = unknown>(updater: (k: BA) => Updater<Delta<T> & E, T | N, V | null, C>, dict: MapK<BA2, ConstHKT<BA>>) => RawStages<unknown, Delta2<T, BA2> & E, Rec<BA2, V | null> & Omit<Delta<T> & E, BA2>, C, 1>;
|
|
11
|
-
export declare const $replaceWithEach1: <T extends O, V extends jsonItem, E = unknown>(t: <K extends BA>(field: K) => Expr<V | null, Delta<T> & E>) => RawStages<unknown, Delta<T> & E, Delta<V> & Omit<E, BA>>;
|
|
12
|
-
export declare const $replaceWithEach: <T extends O, V extends jsonItem, E = unknown>(expr: <K extends BA>(field: K) => Expr<V | null, Rec<K, T> & Delta<T> & E>) => RawStages<unknown, Delta<T> & E, Delta<V> & Omit<E, BA>>;
|
|
13
|
-
export {};
|