@tstdl/base 0.84.29 → 0.84.31
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.
|
@@ -64,22 +64,23 @@ class MongoEntityRepository extends import_database.EntityRepository {
|
|
|
64
64
|
await this.initialize();
|
|
65
65
|
}
|
|
66
66
|
async initialize() {
|
|
67
|
-
const indexes = this.indexes;
|
|
67
|
+
const indexes = this.indexes?.map((index) => ({ index, normalizedIndex: normalizeIndex(index) }));
|
|
68
68
|
if ((0, import_type_guards.isUndefined)(indexes)) {
|
|
69
69
|
return;
|
|
70
70
|
}
|
|
71
71
|
const existingRawIndexes = await this.collection.indexes();
|
|
72
72
|
const existingIndexes = existingRawIndexes.map(normalizeIndex).filter((index) => index.name != "_id_");
|
|
73
|
-
const unwantedIndexes = existingIndexes.filter((existingIndex) => !indexes.some((
|
|
74
|
-
const requiredIndexes = indexes.filter((
|
|
73
|
+
const unwantedIndexes = existingIndexes.filter((existingIndex) => !indexes.some(({ normalizedIndex }) => (0, import_equals.equals)(existingIndex, normalizedIndex, { deep: true, sortArray: false })));
|
|
74
|
+
const requiredIndexes = indexes.filter(({ normalizedIndex: wantedNormalizedIndex }) => !existingIndexes.some((index) => (0, import_equals.equals)(wantedNormalizedIndex, index, { deep: true, sortArray: false })));
|
|
75
75
|
for (const unwantedIndex of unwantedIndexes) {
|
|
76
76
|
this.logger.warn(`dropping index ${unwantedIndex.name}`);
|
|
77
77
|
await this.collection.dropIndex(unwantedIndex.name);
|
|
78
78
|
}
|
|
79
79
|
if (requiredIndexes.length > 0) {
|
|
80
|
-
const
|
|
80
|
+
const indexexToCreate = requiredIndexes.map(({ index }) => index);
|
|
81
|
+
const indexNames = indexexToCreate.map((index) => index.name ?? (0, import_throw._throw)(new Error("index name missing")));
|
|
81
82
|
this.logger.warn(`creating indexes ${indexNames.join(", ")}`);
|
|
82
|
-
await this.baseRepository.createIndexes(
|
|
83
|
+
await this.baseRepository.createIndexes(indexexToCreate);
|
|
83
84
|
}
|
|
84
85
|
}
|
|
85
86
|
async load(id) {
|
|
@@ -286,9 +287,9 @@ class MongoEntityRepository extends import_database.EntityRepository {
|
|
|
286
287
|
}
|
|
287
288
|
}
|
|
288
289
|
function normalizeIndex(index) {
|
|
289
|
-
const { name: providedName, v, background, ns, ...indexRest } = index;
|
|
290
|
+
const { name: providedName, unique, v, background, ns, ...indexRest } = index;
|
|
290
291
|
const name = providedName ?? (0, import_object.objectKeys)(index.key).join("_");
|
|
291
|
-
return { name, ...indexRest };
|
|
292
|
+
return (0, import_object.filterUndefinedFromRecord)({ name, unique: unique == true ? true : void 0, ...indexRest });
|
|
292
293
|
}
|
|
293
294
|
function convertOptions(options, mappingMap) {
|
|
294
295
|
if (options == void 0) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tstdl/base",
|
|
3
|
-
"version": "0.84.
|
|
3
|
+
"version": "0.84.31",
|
|
4
4
|
"author": "Patrick Hein",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
"build": "tsc && tsc-alias",
|
|
11
11
|
"build:watch": "concurrently --raw --kill-others npm:tsc:watch npm:tsc-alias:watch",
|
|
12
12
|
"build:production": "rm -rf dist && npm run build && npm run build:production:cjs && npm run build:production:copy-files",
|
|
13
|
-
"build:production:cjs": "esbuild `find dist \\( -name '*.js' -o -name '*.jsx' \\)` --outdir=dist --allow-overwrite --format=cjs",
|
|
13
|
+
"build:production:cjs": "esbuild `find dist \\( -name '*.js' -o -name '*.jsx' \\)` --outdir=dist --allow-overwrite --target=es2022 --format=cjs",
|
|
14
14
|
"build:production:copy-files": "cp package.json .eslintrc.json tsconfig.server.json dist/ && cp tsconfig.base.json dist/tsconfig.json && sed -i 's/\"type\": \"module\",/\"type\": \"commonjs\",/g' dist/package.json",
|
|
15
15
|
"build:docs": "typedoc",
|
|
16
16
|
"build:docs-watch": "typedoc --watch",
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
"@typescript-eslint/parser": "5.59",
|
|
38
38
|
"concurrently": "8.2",
|
|
39
39
|
"esbuild": "0.18",
|
|
40
|
-
"eslint": "8.
|
|
40
|
+
"eslint": "8.43",
|
|
41
41
|
"eslint-import-resolver-typescript": "3.5",
|
|
42
42
|
"eslint-plugin-import": "2.27",
|
|
43
43
|
"tsc-alias": "1.8",
|