@thisisagile/easy-mongo 14.2.8 → 14.2.10
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/dist/Lucene.d.ts +14 -1
- package/dist/Lucene.js +11 -1
- package/dist/Lucene.js.map +1 -1
- package/package.json +3 -3
- package/src/Lucene.ts +22 -9
package/dist/Lucene.d.ts
CHANGED
|
@@ -4,13 +4,26 @@ type FuzzyOptions = {
|
|
|
4
4
|
prefixLength: number;
|
|
5
5
|
maxExpansions: number;
|
|
6
6
|
};
|
|
7
|
+
type Clause = Record<string, (path: string) => object | undefined>;
|
|
8
|
+
type Compound = {
|
|
9
|
+
must?: OneOrMore<Clause>;
|
|
10
|
+
mustNot?: OneOrMore<Clause>;
|
|
11
|
+
should?: OneOrMore<Clause>;
|
|
12
|
+
filter?: OneOrMore<Clause>;
|
|
13
|
+
};
|
|
7
14
|
export declare const lucene: {
|
|
8
15
|
operations: {
|
|
16
|
+
clause: (cl: Clause) => any;
|
|
17
|
+
search: (cmp: Partial<Compound>) => {
|
|
18
|
+
$search: {
|
|
19
|
+
compound: any;
|
|
20
|
+
};
|
|
21
|
+
};
|
|
9
22
|
text: (value?: OneOrMore<unknown>, fuzzy?: Partial<FuzzyOptions>) => (path: string) => import("@thisisagile/easy").Optional<{
|
|
10
23
|
text: {
|
|
11
24
|
fuzzy?: Partial<FuzzyOptions> | undefined;
|
|
12
25
|
path: string;
|
|
13
|
-
query: {}
|
|
26
|
+
query: {};
|
|
14
27
|
};
|
|
15
28
|
}>;
|
|
16
29
|
lt: (value: unknown) => (path: string) => import("@thisisagile/easy").Optional<{
|
package/dist/Lucene.js
CHANGED
|
@@ -5,10 +5,20 @@ const easy_1 = require("@thisisagile/easy");
|
|
|
5
5
|
const Utils_1 = require("./Utils");
|
|
6
6
|
exports.lucene = {
|
|
7
7
|
operations: {
|
|
8
|
+
clause: (cl) => Object.entries(cl).reduce((res, [k, v]) => v(k), {}),
|
|
9
|
+
search: (cmp) => ({
|
|
10
|
+
$search: {
|
|
11
|
+
compound: Object.entries(cmp).reduce((cp, [k, v]) => ({
|
|
12
|
+
...cp,
|
|
13
|
+
[k]: (0, easy_1.isArray)(v) ? (0, easy_1.toArray)(v).map(i => exports.lucene.operations.clause(i)) : exports.lucene.operations.clause(v)
|
|
14
|
+
}), {})
|
|
15
|
+
}
|
|
16
|
+
}),
|
|
8
17
|
text: (value, fuzzy) => (path) => (0, easy_1.ifDefined)(value, v => ({
|
|
9
18
|
text: {
|
|
10
19
|
path,
|
|
11
|
-
query:
|
|
20
|
+
query: v,
|
|
21
|
+
...(0, easy_1.ifDefined)(fuzzy, { fuzzy })
|
|
12
22
|
}
|
|
13
23
|
})),
|
|
14
24
|
lt: (value) => (path) => (0, easy_1.ifDefined)(value, lt => ({ range: { path, lt } })),
|
package/dist/Lucene.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Lucene.js","sourceRoot":"","sources":["../src/Lucene.ts"],"names":[],"mappings":";;;AAAA,
|
|
1
|
+
{"version":3,"file":"Lucene.js","sourceRoot":"","sources":["../src/Lucene.ts"],"names":[],"mappings":";;;AAAA,4CAAyE;AACzE,mCAAoC;AAiBvB,QAAA,MAAM,GAAG;IAClB,UAAU,EAAE;QACR,MAAM,EAAE,CAAC,EAAU,EAAE,EAAE,CAAC,MAAM,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,EAAS,CAAC;QACnF,MAAM,EAAE,CAAC,GAAsB,EAAE,EAAE,CAAC,CAAC;YACjC,OAAO,EAAE;gBACL,QAAQ,EAAE,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;oBAClD,G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EAAC,CAAC,CAAC;QACvF,GAAG,EAAE,CAAC,KAAc,EAAE,EAAE,CAAC,CAAC,IAAY,EAAE,EAAE,CAAC,IAAA,gBAAS,EAAC,KAAK,EAAE,GAAG,CAAC,EAAE,CAAC,CAAC,EAAC,KAAK,EAAE,EAAC,IAAI,EAAE,GAAG,EAAC,EAAC,CAAC,CAAC;QAC1F,KAAK,EAAE,CAAC,IAAa,EAAE,EAAE,CAAC,cAAM,CAAC,UAAU,CAAC,GAAG,CAAC,IAAA,mBAAW,EAAC,IAAI,CAAC,CAAC;QAClE,MAAM,EAAE,CAAC,IAAa,EAAE,EAAE,CAAC,cAAM,CAAC,UAAU,CAAC,EAAE,CAAC,IAAA,mBAAW,EAAC,IAAI,CAAC,CAAC;QAClE,OAAO,EAAE,CAAC,KAAc,EAAE,MAAe,EAAE,EAAE,CAAC,CAAC,IAAY,EAAE,EAAE,CAAC,CAAC;YAC7D,KAAK,EAAE;gBACH,IAAI;gBACJ,GAAG,EAAE,IAAA,mBAAW,EAAC,KAAK,CAAC;gBACvB,EAAE,EAAE,IAAA,mBAAW,EAAC,MAAM,CAAC;aAC1B;SACJ,CAAC;KACL;CACJ,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@thisisagile/easy-mongo",
|
|
3
|
-
"version": "14.2.
|
|
3
|
+
"version": "14.2.10",
|
|
4
4
|
"description": "Add support for MongoDB",
|
|
5
5
|
"author": "Sander Hoogendoorn",
|
|
6
6
|
"license": "MIT",
|
|
@@ -31,10 +31,10 @@
|
|
|
31
31
|
"access": "public"
|
|
32
32
|
},
|
|
33
33
|
"devDependencies": {
|
|
34
|
-
"@thisisagile/easy-test": "14.2.
|
|
34
|
+
"@thisisagile/easy-test": "14.2.10"
|
|
35
35
|
},
|
|
36
36
|
"dependencies": {
|
|
37
|
-
"@thisisagile/easy": "^14.2.
|
|
37
|
+
"@thisisagile/easy": "^14.2.10",
|
|
38
38
|
"mongodb": "^5.6.0"
|
|
39
39
|
}
|
|
40
40
|
}
|
package/src/Lucene.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {ifDefined, OneOrMore, toArray} from "@thisisagile/easy";
|
|
1
|
+
import {ifDefined, isArray, OneOrMore, toArray} from "@thisisagile/easy";
|
|
2
2
|
import {toMongoType} from "./Utils";
|
|
3
3
|
|
|
4
4
|
type FuzzyOptions = {
|
|
@@ -7,17 +7,31 @@ type FuzzyOptions = {
|
|
|
7
7
|
maxExpansions: number
|
|
8
8
|
}
|
|
9
9
|
|
|
10
|
+
type Clause = Record<string, (path: string) => object | undefined>;
|
|
11
|
+
|
|
12
|
+
type Compound = {
|
|
13
|
+
must?: OneOrMore<Clause>,
|
|
14
|
+
mustNot?: OneOrMore<Clause>,
|
|
15
|
+
should?: OneOrMore<Clause>,
|
|
16
|
+
filter?: OneOrMore<Clause>
|
|
17
|
+
}
|
|
18
|
+
|
|
10
19
|
export const lucene = {
|
|
11
|
-
// operators: {
|
|
12
|
-
// must:
|
|
13
|
-
// should:
|
|
14
|
-
// filter:
|
|
15
|
-
// },
|
|
16
20
|
operations: {
|
|
21
|
+
clause: (cl: Clause) => Object.entries(cl).reduce((res, [k, v]) => v(k), {} as any),
|
|
22
|
+
search: (cmp: Partial<Compound>) => ({
|
|
23
|
+
$search: {
|
|
24
|
+
compound: Object.entries(cmp).reduce((cp, [k, v]) => ({
|
|
25
|
+
...cp,
|
|
26
|
+
[k]: isArray(v) ? toArray(v).map(i => lucene.operations.clause(i)) : lucene.operations.clause(v)
|
|
27
|
+
}), {} as any)
|
|
28
|
+
}
|
|
29
|
+
}),
|
|
17
30
|
text: (value?: OneOrMore<unknown>, fuzzy?: Partial<FuzzyOptions>) => (path: string) => ifDefined(value, v => ({
|
|
18
31
|
text: {
|
|
19
32
|
path,
|
|
20
|
-
query:
|
|
33
|
+
query: v,
|
|
34
|
+
...ifDefined(fuzzy, {fuzzy})
|
|
21
35
|
}
|
|
22
36
|
})),
|
|
23
37
|
lt: (value: unknown) => (path: string) => ifDefined(value, lt => ({range: {path, lt}})),
|
|
@@ -34,5 +48,4 @@ export const lucene = {
|
|
|
34
48
|
}
|
|
35
49
|
}),
|
|
36
50
|
}
|
|
37
|
-
|
|
38
|
-
}
|
|
51
|
+
};
|