@rebasepro/server-mongo 0.12.1-canary.g386667d → 0.12.1-canary.g4e7bcbf
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/db/MongoConditionBuilder.d.ts +4 -4
- package/dist/db/MongoConditionBuilder.d.ts.map +1 -1
- package/dist/index.es.js +3 -3
- package/dist/index.es.js.map +1 -1
- package/dist/{websocket-CBQwCn-Y.js → websocket-74DDOdK0.js} +5 -4
- package/dist/websocket-74DDOdK0.js.map +1 -0
- package/dist/websocket.d.ts.map +1 -1
- package/package.json +5 -5
- package/src/db/MongoConditionBuilder.ts +19 -6
- package/src/websocket.ts +18 -3
- package/dist/websocket-CBQwCn-Y.js.map +0 -1
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
*
|
|
4
4
|
* Translates Rebase filter conditions to MongoDB query operators.
|
|
5
5
|
*/
|
|
6
|
-
import { FilterValues } from "@rebasepro/types";
|
|
6
|
+
import { CollectionConfig, FilterValues } from "@rebasepro/types";
|
|
7
7
|
import { Filter, Document } from "mongodb";
|
|
8
8
|
/**
|
|
9
9
|
* MongoDB Condition Builder
|
|
@@ -23,10 +23,10 @@ export declare class MongoConditionBuilder {
|
|
|
23
23
|
* Build search conditions for text search
|
|
24
24
|
*
|
|
25
25
|
* @param searchString - Text to search for
|
|
26
|
-
* @param properties -
|
|
26
|
+
* @param properties - The collection's properties, searched for string fields
|
|
27
27
|
* @returns Array of MongoDB filter objects for text search
|
|
28
28
|
*/
|
|
29
|
-
static buildSearchConditions(searchString: string, properties:
|
|
29
|
+
static buildSearchConditions(searchString: string, properties: CollectionConfig["properties"]): Filter<Document>[];
|
|
30
30
|
/**
|
|
31
31
|
* Combine multiple conditions with AND operator
|
|
32
32
|
*
|
|
@@ -50,7 +50,7 @@ export declare class MongoConditionBuilder {
|
|
|
50
50
|
static buildQuery<M extends Record<string, any>>(options: {
|
|
51
51
|
filter?: FilterValues<Extract<keyof M, string>>;
|
|
52
52
|
searchString?: string;
|
|
53
|
-
properties?:
|
|
53
|
+
properties?: CollectionConfig["properties"];
|
|
54
54
|
}): Filter<Document>;
|
|
55
55
|
/**
|
|
56
56
|
* Build MongoDB sort options from Rebase options
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MongoConditionBuilder.d.ts","sourceRoot":"","sources":["../../src/db/MongoConditionBuilder.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,YAAY,EAAiB,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"MongoConditionBuilder.d.ts","sourceRoot":"","sources":["../../src/db/MongoConditionBuilder.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,gBAAgB,EAAE,YAAY,EAAiB,MAAM,kBAAkB,CAAC;AACjF,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAsC3C;;;;;GAKG;AACH,qBAAa,qBAAqB;IAC9B;;;;;OAKG;IACH,MAAM,CAAC,qBAAqB,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EACtD,MAAM,EAAE,YAAY,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC,CAAC,GAC/C,MAAM,CAAC,QAAQ,CAAC,EAAE;IAqDrB;;;;;;OAMG;IACH,MAAM,CAAC,qBAAqB,CACxB,YAAY,EAAE,MAAM,EAKpB,UAAU,EAAE,gBAAgB,CAAC,YAAY,CAAC,GAC3C,MAAM,CAAC,QAAQ,CAAC,EAAE;IAkCrB;;;;;OAKG;IACH,MAAM,CAAC,wBAAwB,CAAC,UAAU,EAAE,MAAM,CAAC,QAAQ,CAAC,EAAE,GAAG,MAAM,CAAC,QAAQ,CAAC,GAAG,SAAS;IAM7F;;;;;OAKG;IACH,MAAM,CAAC,uBAAuB,CAAC,UAAU,EAAE,MAAM,CAAC,QAAQ,CAAC,EAAE,GAAG,MAAM,CAAC,QAAQ,CAAC,GAAG,SAAS;IAM5F;;;;;OAKG;IACH,MAAM,CAAC,UAAU,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAAE,OAAO,EAAE;QACtD,MAAM,CAAC,EAAE,YAAY,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC;QAChD,YAAY,CAAC,EAAE,MAAM,CAAC;QACtB,UAAU,CAAC,EAAE,gBAAgB,CAAC,YAAY,CAAC,CAAC;KAC/C,GAAG,MAAM,CAAC,QAAQ,CAAC;IA2BpB;;;;;;OAMG;IACH,MAAM,CAAC,SAAS,CACZ,OAAO,CAAC,EAAE,MAAM,EAChB,KAAK,CAAC,EAAE,KAAK,GAAG,MAAM,GACvB,MAAM,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,SAAS;CAIxC"}
|
package/dist/index.es.js
CHANGED
|
@@ -142,7 +142,7 @@ var MongoConditionBuilder = class {
|
|
|
142
142
|
* Build search conditions for text search
|
|
143
143
|
*
|
|
144
144
|
* @param searchString - Text to search for
|
|
145
|
-
* @param properties -
|
|
145
|
+
* @param properties - The collection's properties, searched for string fields
|
|
146
146
|
* @returns Array of MongoDB filter objects for text search
|
|
147
147
|
*/
|
|
148
148
|
static buildSearchConditions(searchString, properties) {
|
|
@@ -150,7 +150,7 @@ var MongoConditionBuilder = class {
|
|
|
150
150
|
const orConditions = [];
|
|
151
151
|
const escapedSearch = escapeRegExp$1(searchString);
|
|
152
152
|
const searchRegex = new RegExp(escapedSearch, "i");
|
|
153
|
-
for (const [key, prop] of Object.entries(properties)) if (prop?.
|
|
153
|
+
for (const [key, prop] of Object.entries(properties)) if (prop?.type === "string" || typeof prop === "string") orConditions.push({ [key]: { $regex: searchRegex } });
|
|
154
154
|
if (orConditions.length === 0) return [{ $text: { $search: searchString } }];
|
|
155
155
|
return orConditions;
|
|
156
156
|
}
|
|
@@ -2554,7 +2554,7 @@ function createMongoBootstrapper(mongoConfig) {
|
|
|
2554
2554
|
},
|
|
2555
2555
|
mountRoutes() {},
|
|
2556
2556
|
async initializeWebsockets(server, realtimeService, driver, config) {
|
|
2557
|
-
const { createMongoWebSocket } = await import("./websocket-
|
|
2557
|
+
const { createMongoWebSocket } = await import("./websocket-74DDOdK0.js");
|
|
2558
2558
|
createMongoWebSocket(server, realtimeService, driver, config, cachedAdmin);
|
|
2559
2559
|
}
|
|
2560
2560
|
};
|