@unchainedshop/mongodb 3.1.7 → 3.1.11
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/lib/build-db-indexes.d.ts +4 -6
- package/lib/build-db-indexes.d.ts.map +1 -1
- package/lib/build-db-indexes.js.map +1 -1
- package/lib/initDb.d.ts.map +1 -1
- package/lib/initDb.js +5 -3
- package/lib/initDb.js.map +1 -1
- package/lib/insensitive-trimmed-regex-operator.d.ts.map +1 -1
- package/lib/insensitive-trimmed-regex-operator.js +5 -1
- package/lib/insensitive-trimmed-regex-operator.js.map +1 -1
- package/package.json +1 -1
- package/src/build-db-indexes.ts +5 -8
- package/src/initDb.ts +5 -3
- package/src/insensitive-trimmed-regex-operator.test.ts +53 -2
- package/src/insensitive-trimmed-regex-operator.ts +5 -1
- package/lib/documentdb-compat-mode.d.ts +0 -3
- package/lib/documentdb-compat-mode.d.ts.map +0 -1
- package/lib/documentdb-compat-mode.js +0 -6
- package/lib/documentdb-compat-mode.js.map +0 -1
|
@@ -1,9 +1,7 @@
|
|
|
1
|
-
import { Collection, Document, CreateIndexesOptions,
|
|
2
|
-
export type Indexes
|
|
3
|
-
index:
|
|
4
|
-
[key in keyof T]?: IndexDirection;
|
|
5
|
-
};
|
|
1
|
+
import { Collection, Document, CreateIndexesOptions, IndexSpecification } from 'mongodb';
|
|
2
|
+
export type Indexes = Array<{
|
|
3
|
+
index: IndexSpecification;
|
|
6
4
|
options?: CreateIndexesOptions;
|
|
7
5
|
}>;
|
|
8
|
-
export declare const buildDbIndexes: <T extends Document>(collection: Collection<T>, indexes: Indexes
|
|
6
|
+
export declare const buildDbIndexes: <T extends Document>(collection: Collection<T>, indexes: Indexes) => Promise<boolean>;
|
|
9
7
|
//# sourceMappingURL=build-db-indexes.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"build-db-indexes.d.ts","sourceRoot":"","sources":["../src/build-db-indexes.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,oBAAoB,EAAE,
|
|
1
|
+
{"version":3,"file":"build-db-indexes.d.ts","sourceRoot":"","sources":["../src/build-db-indexes.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,oBAAoB,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAKzF,MAAM,MAAM,OAAO,GAAG,KAAK,CAAC;IAC1B,KAAK,EAAE,kBAAkB,CAAC;IAC1B,OAAO,CAAC,EAAE,oBAAoB,CAAC;CAChC,CAAC,CAAC;AAeH,eAAO,MAAM,cAAc,GAAU,CAAC,SAAS,QAAQ,EACrD,YAAY,UAAU,CAAC,CAAC,CAAC,EACzB,SAAS,OAAO,qBAwBjB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"build-db-indexes.js","sourceRoot":"","sources":["../src/build-db-indexes.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAErD,MAAM,MAAM,GAAG,YAAY,CAAC,mBAAmB,CAAC,CAAC;AAOjD,MAAM,YAAY,GAAG,
|
|
1
|
+
{"version":3,"file":"build-db-indexes.js","sourceRoot":"","sources":["../src/build-db-indexes.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAErD,MAAM,MAAM,GAAG,YAAY,CAAC,mBAAmB,CAAC,CAAC;AAOjD,MAAM,YAAY,GAAG,CAAI,UAAyB,EAAE,OAAgB,EAAiC,EAAE,CACrG,OAAO,CAAC,GAAG,CACT,OAAO,CAAC,GAAG,CAAC,KAAK,EAAE,EAAE,KAAK,EAAE,OAAO,EAAE,EAAE,EAAE;IACvC,IAAI,CAAC;QACH,MAAM,UAAU,CAAC,WAAW,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;QAC7C,OAAO,KAAK,CAAC;IACf,CAAC;IAAC,OAAO,CAAM,EAAE,CAAC;QAChB,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;QAChB,OAAO,CAAU,CAAC;IACpB,CAAC;AACH,CAAC,CAAC,CACH,CAAC;AAEJ,MAAM,CAAC,MAAM,cAAc,GAAG,KAAK,EACjC,UAAyB,EACzB,OAAgB,EAChB,EAAE;IACF,IAAI,OAAO,GAAG,IAAI,CAAC;IACnB,MAAM,WAAW,GAAG,CAAC,MAAM,YAAY,CAAI,UAAU,EAAE,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;IAEjF,IAAI,WAAW,CAAC,MAAM,EAAE,CAAC;QACvB,QAAQ;QACR,sDAAsD;QACtD,gBAAgB;QAChB,UAAU;QACV,IAAI;QAEJ,oBAAoB;QACpB,MAAM,aAAa,GAAG,CAAC,MAAM,YAAY,CAAI,UAAU,EAAE,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;QAEnF,IAAI,aAAa,CAAC,MAAM,EAAE,CAAC;YACzB,MAAM,CAAC,KAAK,CAAC,mCAAmC,UAAU,CAAC,cAAc,EAAE,CAAC,CAAC;YAC7E,MAAM,CAAC,KAAK,CAAC,aAAa,CAAC,CAAC;YAC5B,OAAO,GAAG,KAAK,CAAC;QAClB,CAAC;QACD,IAAI;IACN,CAAC;IAED,OAAO,OAAO,CAAC;AACjB,CAAC,CAAC"}
|
package/lib/initDb.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"initDb.d.ts","sourceRoot":"","sources":["../src/initDb.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAe,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"initDb.d.ts","sourceRoot":"","sources":["../src/initDb.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAe,MAAM,SAAS,CAAC;AAe1C,eAAO,MAAM,OAAO,uBA2BnB,CAAC;AAEF,eAAO,MAAM,MAAM,qBAIlB,CAAC;AAEF,QAAA,MAAM,MAAM,QAAa,OAAO,CAAC,EAAE,CAQlC,CAAC;AAEF,OAAO,EAAE,MAAM,EAAE,CAAC"}
|
package/lib/initDb.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { MongoClient } from 'mongodb';
|
|
2
2
|
let zstdEnabled = false;
|
|
3
3
|
let mongod;
|
|
4
|
+
let mongoClient;
|
|
4
5
|
try {
|
|
5
6
|
// eslint-disable-next-line
|
|
6
7
|
// @ts-expect-error
|
|
@@ -37,16 +38,17 @@ export const startDb = async () => {
|
|
|
37
38
|
return `${mongoInstance.getUri()}unchained`;
|
|
38
39
|
};
|
|
39
40
|
export const stopDb = async () => {
|
|
41
|
+
await mongoClient?.close();
|
|
40
42
|
const mongoInstance = await mongod;
|
|
41
43
|
await mongoInstance?.stop();
|
|
42
44
|
};
|
|
43
45
|
const initDb = async () => {
|
|
44
46
|
const url = process.env.MONGO_URL || (await startDb());
|
|
45
|
-
|
|
47
|
+
mongoClient = new MongoClient(url, {
|
|
46
48
|
compressors: zstdEnabled ? 'zstd' : undefined,
|
|
47
49
|
});
|
|
48
|
-
await
|
|
49
|
-
const db =
|
|
50
|
+
await mongoClient.connect();
|
|
51
|
+
const db = mongoClient.db();
|
|
50
52
|
return db;
|
|
51
53
|
};
|
|
52
54
|
export { initDb };
|
package/lib/initDb.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"initDb.js","sourceRoot":"","sources":["../src/initDb.ts"],"names":[],"mappings":"AAAA,OAAO,EAAM,WAAW,EAAE,MAAM,SAAS,CAAC;AAE1C,IAAI,WAAW,GAAG,KAAK,CAAC;AACxB,IAAI,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"initDb.js","sourceRoot":"","sources":["../src/initDb.ts"],"names":[],"mappings":"AAAA,OAAO,EAAM,WAAW,EAAE,MAAM,SAAS,CAAC;AAE1C,IAAI,WAAW,GAAG,KAAK,CAAC;AACxB,IAAI,MAAM,CAAC;AACX,IAAI,WAA+B,CAAC;AAEpC,IAAI,CAAC;IACH,2BAA2B;IAC3B,mBAAmB;IACnB,MAAM,MAAM,CAAC,kBAAkB,CAAC,CAAC;IACjC,WAAW,GAAG,IAAI,CAAC;AACrB,CAAC;AAAC,MAAM,CAAC;IACP,KAAK;AACP,CAAC;AAED,MAAM,CAAC,MAAM,OAAO,GAAG,KAAK,IAAI,EAAE;IAChC,MAAM,EAAE,KAAK,EAAE,GAAG,MAAM,MAAM,CAAC,kBAAkB,CAAC,CAAC;IACnD,MAAM,EAAE,iBAAiB,EAAE,GAAG,MAAM,MAAM,CAAC,uBAAuB,CAAC,CAAC;IACpE,IAAI,CAAC;QACH,MAAM,KAAK,CAAC,GAAG,OAAO,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC;IACtC,CAAC;IAAC,MAAM,CAAC;QACP,KAAK;IACP,CAAC;IACD,MAAM,GAAG,iBAAiB,CAAC,MAAM,CAAC;QAChC,QAAQ,EAAE;YACR,MAAM,EAAE,GAAG,OAAO,CAAC,GAAG,EAAE,MAAM;YAC9B,aAAa,EAAE,YAAY;YAC3B,IAAI,EAAE,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,EAAE,EAAE,CAAC,GAAG,CAAC;SACzC;KACF,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE;QACb,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;QACf,aAAa;QACb,KAAK;IACP,CAAC,CAAC,CAAC;IAEH,MAAM,aAAa,GAAG,MAAM,MAAM,CAAC;IACnC,IAAI,CAAC,aAAa,EAAE,CAAC;QACnB,MAAM,IAAI,KAAK,CACb,8FAA8F,CAC/F,CAAC;IACJ,CAAC;IACD,OAAO,GAAG,aAAa,CAAC,MAAM,EAAE,WAAW,CAAC;AAC9C,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,MAAM,GAAG,KAAK,IAAI,EAAE;IAC/B,MAAM,WAAW,EAAE,KAAK,EAAE,CAAC;IAC3B,MAAM,aAAa,GAAG,MAAM,MAAM,CAAC;IACnC,MAAO,aAAqB,EAAE,IAAI,EAAE,CAAC;AACvC,CAAC,CAAC;AAEF,MAAM,MAAM,GAAG,KAAK,IAAiB,EAAE;IACrC,MAAM,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC,SAAS,IAAI,CAAC,MAAM,OAAO,EAAE,CAAC,CAAC;IACvD,WAAW,GAAG,IAAI,WAAW,CAAC,GAAG,EAAE;QACjC,WAAW,EAAE,WAAW,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,SAAS;KAC9C,CAAC,CAAC;IACH,MAAM,WAAW,CAAC,OAAO,EAAE,CAAC;IAC5B,MAAM,EAAE,GAAG,WAAW,CAAC,EAAE,EAAE,CAAC;IAC5B,OAAO,EAAE,CAAC;AACZ,CAAC,CAAC;AAEF,OAAO,EAAE,MAAM,EAAE,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"insensitive-trimmed-regex-operator.d.ts","sourceRoot":"","sources":["../src/insensitive-trimmed-regex-operator.ts"],"names":[],"mappings":"AAAA,wBAAgB,+BAA+B,CAAC,MAAM,KAAA;;
|
|
1
|
+
{"version":3,"file":"insensitive-trimmed-regex-operator.d.ts","sourceRoot":"","sources":["../src/insensitive-trimmed-regex-operator.ts"],"names":[],"mappings":"AAAA,wBAAgB,+BAA+B,CAAC,MAAM,KAAA;;EAUrD"}
|
|
@@ -2,7 +2,11 @@ export function insensitiveTrimmedRegexOperator(string) {
|
|
|
2
2
|
if (typeof string !== 'string') {
|
|
3
3
|
throw new TypeError('Expected a string');
|
|
4
4
|
}
|
|
5
|
-
const escapped = string.trim().replace(/[
|
|
5
|
+
const escapped = string.trim().replace(/[-/\\^$*+?.()|[\]{}]/g, '\\$&');
|
|
6
|
+
if (escapped.length === 0)
|
|
7
|
+
throw new Error('String is empty after trimming');
|
|
8
|
+
if (escapped.length > 255)
|
|
9
|
+
throw new Error('String exceeds maximum allowed length');
|
|
6
10
|
return { $regex: new RegExp(`^${escapped}$`, 'i') };
|
|
7
11
|
}
|
|
8
12
|
//# sourceMappingURL=insensitive-trimmed-regex-operator.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"insensitive-trimmed-regex-operator.js","sourceRoot":"","sources":["../src/insensitive-trimmed-regex-operator.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,+BAA+B,CAAC,MAAM;IACpD,IAAI,OAAO,MAAM,KAAK,QAAQ,EAAE,CAAC;QAC/B,MAAM,IAAI,SAAS,CAAC,mBAAmB,CAAC,CAAC;IAC3C,CAAC;IACD,MAAM,QAAQ,GAAG,MAAM,CAAC,IAAI,EAAE,CAAC,OAAO,CAAC,
|
|
1
|
+
{"version":3,"file":"insensitive-trimmed-regex-operator.js","sourceRoot":"","sources":["../src/insensitive-trimmed-regex-operator.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,+BAA+B,CAAC,MAAM;IACpD,IAAI,OAAO,MAAM,KAAK,QAAQ,EAAE,CAAC;QAC/B,MAAM,IAAI,SAAS,CAAC,mBAAmB,CAAC,CAAC;IAC3C,CAAC;IACD,MAAM,QAAQ,GAAG,MAAM,CAAC,IAAI,EAAE,CAAC,OAAO,CAAC,uBAAuB,EAAE,MAAM,CAAC,CAAC;IAExE,IAAI,QAAQ,CAAC,MAAM,KAAK,CAAC;QAAE,MAAM,IAAI,KAAK,CAAC,gCAAgC,CAAC,CAAC;IAC7E,IAAI,QAAQ,CAAC,MAAM,GAAG,GAAG;QAAE,MAAM,IAAI,KAAK,CAAC,uCAAuC,CAAC,CAAC;IAEpF,OAAO,EAAE,MAAM,EAAE,IAAI,MAAM,CAAC,IAAI,QAAQ,GAAG,EAAE,GAAG,CAAC,EAAE,CAAC;AACtD,CAAC"}
|
package/package.json
CHANGED
package/src/build-db-indexes.ts
CHANGED
|
@@ -1,17 +1,14 @@
|
|
|
1
|
-
import { Collection, Document, CreateIndexesOptions,
|
|
1
|
+
import { Collection, Document, CreateIndexesOptions, IndexSpecification } from 'mongodb';
|
|
2
2
|
import { createLogger } from '@unchainedshop/logger';
|
|
3
3
|
|
|
4
4
|
const logger = createLogger('unchained:mongodb');
|
|
5
5
|
|
|
6
|
-
export type Indexes
|
|
7
|
-
index:
|
|
6
|
+
export type Indexes = Array<{
|
|
7
|
+
index: IndexSpecification;
|
|
8
8
|
options?: CreateIndexesOptions;
|
|
9
9
|
}>;
|
|
10
10
|
|
|
11
|
-
const buildIndexes = <T>(
|
|
12
|
-
collection: Collection<T>,
|
|
13
|
-
indexes: Indexes<T>,
|
|
14
|
-
): Promise<Array<false | Error>> =>
|
|
11
|
+
const buildIndexes = <T>(collection: Collection<T>, indexes: Indexes): Promise<Array<false | Error>> =>
|
|
15
12
|
Promise.all(
|
|
16
13
|
indexes.map(async ({ index, options }) => {
|
|
17
14
|
try {
|
|
@@ -26,7 +23,7 @@ const buildIndexes = <T>(
|
|
|
26
23
|
|
|
27
24
|
export const buildDbIndexes = async <T extends Document>(
|
|
28
25
|
collection: Collection<T>,
|
|
29
|
-
indexes: Indexes
|
|
26
|
+
indexes: Indexes,
|
|
30
27
|
) => {
|
|
31
28
|
let success = true;
|
|
32
29
|
const buildErrors = (await buildIndexes<T>(collection, indexes)).filter(Boolean);
|
package/src/initDb.ts
CHANGED
|
@@ -2,6 +2,7 @@ import { Db, MongoClient } from 'mongodb';
|
|
|
2
2
|
|
|
3
3
|
let zstdEnabled = false;
|
|
4
4
|
let mongod;
|
|
5
|
+
let mongoClient: MongoClient | null;
|
|
5
6
|
|
|
6
7
|
try {
|
|
7
8
|
// eslint-disable-next-line
|
|
@@ -42,17 +43,18 @@ export const startDb = async () => {
|
|
|
42
43
|
};
|
|
43
44
|
|
|
44
45
|
export const stopDb = async () => {
|
|
46
|
+
await mongoClient?.close();
|
|
45
47
|
const mongoInstance = await mongod;
|
|
46
48
|
await (mongoInstance as any)?.stop();
|
|
47
49
|
};
|
|
48
50
|
|
|
49
51
|
const initDb = async (): Promise<Db> => {
|
|
50
52
|
const url = process.env.MONGO_URL || (await startDb());
|
|
51
|
-
|
|
53
|
+
mongoClient = new MongoClient(url, {
|
|
52
54
|
compressors: zstdEnabled ? 'zstd' : undefined,
|
|
53
55
|
});
|
|
54
|
-
await
|
|
55
|
-
const db =
|
|
56
|
+
await mongoClient.connect();
|
|
57
|
+
const db = mongoClient.db();
|
|
56
58
|
return db;
|
|
57
59
|
};
|
|
58
60
|
|
|
@@ -2,7 +2,9 @@ import { describe, it } from 'node:test';
|
|
|
2
2
|
import assert from 'node:assert';
|
|
3
3
|
import { insensitiveTrimmedRegexOperator } from './insensitive-trimmed-regex-operator.js';
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
/* eslint-disable no-useless-escape */
|
|
6
|
+
|
|
7
|
+
describe('Insensitive Trimmed Regex Operator', () => {
|
|
6
8
|
it('should accept + mails', () => {
|
|
7
9
|
const input = 'test+test@test.com';
|
|
8
10
|
assert.deepStrictEqual(insensitiveTrimmedRegexOperator(input), {
|
|
@@ -13,7 +15,7 @@ describe('Email Regex Operator', () => {
|
|
|
13
15
|
it('should trim mails', () => {
|
|
14
16
|
const input = ' test-two+test@test.com';
|
|
15
17
|
assert.deepStrictEqual(insensitiveTrimmedRegexOperator(input), {
|
|
16
|
-
$regex: /^test
|
|
18
|
+
$regex: /^test\-two\+test@test\.com$/i,
|
|
17
19
|
});
|
|
18
20
|
});
|
|
19
21
|
|
|
@@ -23,4 +25,53 @@ describe('Email Regex Operator', () => {
|
|
|
23
25
|
$regex: /^tesT\+tesT@test\.com$/i,
|
|
24
26
|
});
|
|
25
27
|
});
|
|
28
|
+
|
|
29
|
+
// New tests to verify security improvements
|
|
30
|
+
|
|
31
|
+
it('should escape all regex special characters', () => {
|
|
32
|
+
const input = '.*+?^${}()|[]\\';
|
|
33
|
+
assert.deepStrictEqual(insensitiveTrimmedRegexOperator(input), {
|
|
34
|
+
$regex: /^\.\*\+\?\^\$\{\}\(\)\|\[\]\\$/i,
|
|
35
|
+
});
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
it('should properly escape hyphens', () => {
|
|
39
|
+
const input = 'range-a-z';
|
|
40
|
+
assert.deepStrictEqual(insensitiveTrimmedRegexOperator(input), {
|
|
41
|
+
$regex: /^range\-a\-z$/i,
|
|
42
|
+
});
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
it('should properly escape forward slashes', () => {
|
|
46
|
+
const input = 'path/to/file';
|
|
47
|
+
assert.deepStrictEqual(insensitiveTrimmedRegexOperator(input), {
|
|
48
|
+
$regex: /^path\/to\/file$/i,
|
|
49
|
+
});
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
it('should handle malicious pattern attempts', () => {
|
|
53
|
+
const input = '[a-z]|[0-9]';
|
|
54
|
+
assert.deepStrictEqual(insensitiveTrimmedRegexOperator(input), {
|
|
55
|
+
$regex: /^\[a\-z\]\|\[0\-9\]$/i,
|
|
56
|
+
});
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
it('should reject empty strings after trimming', () => {
|
|
60
|
+
assert.throws(() => {
|
|
61
|
+
insensitiveTrimmedRegexOperator(' ');
|
|
62
|
+
}, /String is empty after trimming/);
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
it('should reject non-string inputs', () => {
|
|
66
|
+
assert.throws(() => {
|
|
67
|
+
insensitiveTrimmedRegexOperator(123);
|
|
68
|
+
}, /Expected a string/);
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
it('should reject strings exceeding maximum length', () => {
|
|
72
|
+
const longString = 'a'.repeat(256);
|
|
73
|
+
assert.throws(() => {
|
|
74
|
+
insensitiveTrimmedRegexOperator(longString);
|
|
75
|
+
}, /String exceeds maximum allowed length/);
|
|
76
|
+
});
|
|
26
77
|
});
|
|
@@ -2,6 +2,10 @@ export function insensitiveTrimmedRegexOperator(string) {
|
|
|
2
2
|
if (typeof string !== 'string') {
|
|
3
3
|
throw new TypeError('Expected a string');
|
|
4
4
|
}
|
|
5
|
-
const escapped = string.trim().replace(/[
|
|
5
|
+
const escapped = string.trim().replace(/[-/\\^$*+?.()|[\]{}]/g, '\\$&');
|
|
6
|
+
|
|
7
|
+
if (escapped.length === 0) throw new Error('String is empty after trimming');
|
|
8
|
+
if (escapped.length > 255) throw new Error('String exceeds maximum allowed length');
|
|
9
|
+
|
|
6
10
|
return { $regex: new RegExp(`^${escapped}$`, 'i') };
|
|
7
11
|
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"documentdb-compat-mode.d.ts","sourceRoot":"","sources":["../src/documentdb-compat-mode.ts"],"names":[],"mappings":"AAAA,wBAAgB,0BAA0B,SAGzC;AAED,eAAO,MAAM,6BAA6B,eAA8D,CAAC"}
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
export function assertDocumentDBCompatMode() {
|
|
2
|
-
if (isDocumentDBCompatModeEnabled())
|
|
3
|
-
throw new Error('Text search is not supported in DocumentDB Compatibility Mode');
|
|
4
|
-
}
|
|
5
|
-
export const isDocumentDBCompatModeEnabled = () => Boolean(process.env.UNCHAINED_DOCUMENTDB_COMPAT_MODE);
|
|
6
|
-
//# sourceMappingURL=documentdb-compat-mode.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"documentdb-compat-mode.js","sourceRoot":"","sources":["../src/documentdb-compat-mode.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,0BAA0B;IACxC,IAAI,6BAA6B,EAAE;QACjC,MAAM,IAAI,KAAK,CAAC,+DAA+D,CAAC,CAAC;AACrF,CAAC;AAED,MAAM,CAAC,MAAM,6BAA6B,GAAG,GAAG,EAAE,CAAC,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,gCAAgC,CAAC,CAAC"}
|