@sprucelabs/data-stores 26.4.89 → 27.0.0
Sign up to get free protection for your applications and to get access to all the features.
- package/build/.spruce/errors/dataStores/databaseNotConnected.schema.js +5 -5
- package/build/.spruce/errors/dataStores/duplicateKey.schema.js +1 -1
- package/build/.spruce/errors/dataStores/duplicateRecord.schema.js +9 -9
- package/build/.spruce/errors/dataStores/failedToLoadStore.schema.js +3 -3
- package/build/.spruce/errors/dataStores/failedToLoadStores.schema.js +5 -3
- package/build/.spruce/errors/dataStores/indexExists.schema.js +5 -5
- package/build/.spruce/errors/dataStores/indexNotFound.schema.js +5 -5
- package/build/.spruce/errors/dataStores/invalidConnectionStringScheme.schema.js +3 -3
- package/build/.spruce/errors/dataStores/invalidDatabaseName.schema.js +3 -3
- package/build/.spruce/errors/dataStores/invalidDbConnectionString.schema.js +1 -1
- package/build/.spruce/errors/dataStores/invalidFakeQueryResponse.schema.js +5 -5
- package/build/.spruce/errors/dataStores/invalidStore.schema copy.js +5 -5
- package/build/.spruce/errors/dataStores/invalidStore.schema.js +1 -1
- package/build/.spruce/errors/dataStores/invalidStoreName.schema.js +5 -5
- package/build/.spruce/errors/dataStores/mongoIdMappingError.schema.js +1 -1
- package/build/.spruce/errors/dataStores/notImplemented.schema.js +1 -1
- package/build/.spruce/errors/dataStores/queryNotFaked.schema.js +5 -5
- package/build/.spruce/errors/dataStores/record-not-found-query.schema.js +1 -1
- package/build/.spruce/errors/dataStores/recordNotFound.schema.js +5 -5
- package/build/.spruce/errors/dataStores/scrambleNotConfigured.schema.js +1 -1
- package/build/.spruce/errors/dataStores/unableToConnectToDb.schema.js +1 -1
- package/build/.spruce/errors/dataStores/unknownDatabaseError.schema.js +3 -3
- package/build/.spruce/errors/dataStores/unknownError.schema.js +1 -1
- package/build/.spruce/errors/dataStores/unknownStoreError.schema.js +5 -5
- package/build/.spruce/errors/errors.types.d.ts +53 -56
- package/build/.spruce/errors/errors.types.js +0 -2
- package/build/.spruce/errors/options.types.d.ts +2 -2
- package/build/.spruce/schemas/fields/fields.types.d.ts +1 -1
- package/build/cursors/BatchArrayCursor.d.ts +2 -2
- package/build/databases/MongoDatabase.js +3 -1
- package/build/databases/NeDbDatabase.js +9 -3
- package/build/databases/mongo.types.d.ts +89 -135
- package/build/databases/mongo.types.js +0 -1
- package/build/errors/SpruceError.d.ts +1 -1
- package/build/errors/SpruceError.js +6 -2
- package/build/errors/failedToLoadStores.builder.js +1 -1
- package/build/errors/mongoIdMappingError.builder.js +0 -2
- package/build/errors/scrambleNotConfigured.builder.js +0 -2
- package/build/esm/.spruce/errors/errors.types.d.ts +53 -56
- package/build/esm/.spruce/errors/errors.types.js +0 -2
- package/build/esm/.spruce/errors/options.types.d.ts +2 -2
- package/build/esm/cursors/BatchArrayCursor.d.ts +2 -2
- package/build/esm/databases/MongoDatabase.js +3 -1
- package/build/esm/databases/NeDbDatabase.js +9 -3
- package/build/esm/databases/mongo.types.d.ts +89 -135
- package/build/esm/databases/mongo.types.js +0 -1
- package/build/esm/errors/SpruceError.d.ts +1 -1
- package/build/esm/errors/SpruceError.js +6 -2
- package/build/esm/errors/failedToLoadStores.builder.js +1 -1
- package/build/esm/errors/mongoIdMappingError.builder.js +0 -2
- package/build/esm/errors/scrambleNotConfigured.builder.js +0 -2
- package/build/esm/loaders/StoreLoader.d.ts +1 -1
- package/build/esm/plugins/DatabaseFieldMapperPlugin.js +3 -1
- package/build/esm/stores/AbstractStore.js +4 -2
- package/build/esm/tests/AbstractDatabaseTest.js +3 -1
- package/build/esm/tests/databaseAssertUtil.js +66 -20
- package/build/esm/types/query.types.d.ts +4 -4
- package/build/esm/types/query.types.js +0 -1
- package/build/loaders/StoreLoader.d.ts +1 -1
- package/build/plugins/DatabaseFieldMapperPlugin.js +3 -1
- package/build/stores/AbstractStore.js +4 -2
- package/build/tests/AbstractDatabaseTest.js +3 -1
- package/build/tests/databaseAssertUtil.js +66 -20
- package/build/types/query.types.d.ts +4 -4
- package/build/types/query.types.js +0 -1
- package/package.json +17 -29
@@ -427,7 +427,9 @@ const databaseAssertUtil = {
|
|
427
427
|
$push: { names: 'second' },
|
428
428
|
});
|
429
429
|
assert.isEqualDeep(updated.names, ['first', 'second']);
|
430
|
-
const matched = yield db.findOne(this.collectionName, {
|
430
|
+
const matched = yield db.findOne(this.collectionName, {
|
431
|
+
id: updated.id,
|
432
|
+
});
|
431
433
|
assert.isTruthy(matched);
|
432
434
|
assert.isEqualDeep(matched.names, ['first', 'second']);
|
433
435
|
yield this.shutdown(db);
|
@@ -450,7 +452,9 @@ const databaseAssertUtil = {
|
|
450
452
|
catch (_a) {
|
451
453
|
assert.fail('createOne() tried to create a record with an object field. Make sure the target field handles objects!');
|
452
454
|
}
|
453
|
-
const matched = yield db.findOne(this.collectionName, {
|
455
|
+
const matched = yield db.findOne(this.collectionName, {
|
456
|
+
id: created.id,
|
457
|
+
});
|
454
458
|
assert.isEqualDeep(matched, Object.assign(Object.assign({}, created), { id: matched.id }));
|
455
459
|
yield this.shutdown(db);
|
456
460
|
});
|
@@ -473,7 +477,9 @@ const databaseAssertUtil = {
|
|
473
477
|
yield db.updateOne(this.collectionName, { id: created.id }, {
|
474
478
|
target,
|
475
479
|
});
|
476
|
-
const matched = yield db.findOne(this.collectionName, {
|
480
|
+
const matched = yield db.findOne(this.collectionName, {
|
481
|
+
id: created.id,
|
482
|
+
});
|
477
483
|
assert.isEqualDeep(matched.target, target);
|
478
484
|
yield this.shutdown(db);
|
479
485
|
});
|
@@ -493,7 +499,9 @@ const databaseAssertUtil = {
|
|
493
499
|
yield db.updateOne(this.collectionName, { id: created.id }, {
|
494
500
|
'target.organizationId': 'oy oy',
|
495
501
|
});
|
496
|
-
const matched = yield db.findOne(this.collectionName, {
|
502
|
+
const matched = yield db.findOne(this.collectionName, {
|
503
|
+
id: created.id,
|
504
|
+
});
|
497
505
|
assert.isEqualDeep(matched.target, Object.assign(Object.assign({}, target), { organizationId: 'oy oy' }));
|
498
506
|
yield this.shutdown(db);
|
499
507
|
});
|
@@ -824,12 +832,21 @@ const databaseAssertUtil = {
|
|
824
832
|
assertCanDropCompoundUniqueIndex(connect) {
|
825
833
|
return __awaiter(this, void 0, void 0, function* () {
|
826
834
|
const db = yield connectToDabatase(connect);
|
827
|
-
yield db.createUniqueIndex(this.collectionName, [
|
835
|
+
yield db.createUniqueIndex(this.collectionName, [
|
836
|
+
'someField',
|
837
|
+
'otherField',
|
838
|
+
]);
|
828
839
|
yield db.dropIndex(this.collectionName, ['someField', 'otherField']);
|
829
840
|
let indexes = yield db.getUniqueIndexes(this.collectionName);
|
830
841
|
assert.isLength(indexes, 0);
|
831
|
-
yield db.createUniqueIndex(this.collectionName, [
|
832
|
-
|
842
|
+
yield db.createUniqueIndex(this.collectionName, [
|
843
|
+
'someField',
|
844
|
+
'someField2',
|
845
|
+
]);
|
846
|
+
yield db.createUniqueIndex(this.collectionName, [
|
847
|
+
'someField',
|
848
|
+
'someField3',
|
849
|
+
]);
|
833
850
|
yield db.dropIndex(this.collectionName, ['someField', 'someField3']);
|
834
851
|
indexes = yield db.getUniqueIndexes(this.collectionName);
|
835
852
|
assert.isLength(indexes, 1);
|
@@ -1422,7 +1439,10 @@ const databaseAssertUtil = {
|
|
1422
1439
|
db.dropIndex = () => {
|
1423
1440
|
throw new Error('Should not have been called');
|
1424
1441
|
};
|
1425
|
-
yield db.syncIndexes(this.collectionName, [
|
1442
|
+
yield db.syncIndexes(this.collectionName, [
|
1443
|
+
['someField'],
|
1444
|
+
['otherField'],
|
1445
|
+
]);
|
1426
1446
|
yield this.shutdown(db);
|
1427
1447
|
});
|
1428
1448
|
},
|
@@ -1462,7 +1482,10 @@ const databaseAssertUtil = {
|
|
1462
1482
|
assertCantDropCompoundIndexThatDoesNotExist(connect) {
|
1463
1483
|
return __awaiter(this, void 0, void 0, function* () {
|
1464
1484
|
const db = yield connectToDabatase(connect);
|
1465
|
-
yield db.createIndex(this.collectionName, [
|
1485
|
+
yield db.createIndex(this.collectionName, [
|
1486
|
+
'someField',
|
1487
|
+
'someOtherField',
|
1488
|
+
]);
|
1466
1489
|
const err = yield assert.doesThrowAsync(() => db.dropIndex(this.collectionName, ['uniqueField', 'someOtherField']));
|
1467
1490
|
errorAssert.assertError(err, 'INDEX_NOT_FOUND', {
|
1468
1491
|
collectionName: this.collectionName,
|
@@ -1545,7 +1568,10 @@ const databaseAssertUtil = {
|
|
1545
1568
|
indexes = yield this._getFilteredIndexes(db);
|
1546
1569
|
assert.isLength(indexes, 2);
|
1547
1570
|
assert.isEqual(indexes[1][0].toLowerCase(), 'uniqueField2'.toLowerCase());
|
1548
|
-
yield db.createIndex(this.collectionName, [
|
1571
|
+
yield db.createIndex(this.collectionName, [
|
1572
|
+
'uniqueField3',
|
1573
|
+
'uniqueField4',
|
1574
|
+
]);
|
1549
1575
|
indexes = yield this._getFilteredIndexes(db);
|
1550
1576
|
assert.isLength(indexes, 3);
|
1551
1577
|
assert.isEqual(indexes[2][0].toLowerCase(), 'uniqueField3'.toLowerCase());
|
@@ -1618,16 +1644,36 @@ const databaseAssertUtil = {
|
|
1618
1644
|
return __awaiter(this, void 0, void 0, function* () {
|
1619
1645
|
const db = yield connectToDabatase(connect);
|
1620
1646
|
const syncs = [
|
1621
|
-
db.syncIndexes(this.collectionName, [
|
1622
|
-
|
1623
|
-
|
1624
|
-
db.syncIndexes(this.collectionName, [
|
1625
|
-
|
1626
|
-
|
1627
|
-
db.syncIndexes(this.collectionName, [
|
1628
|
-
|
1629
|
-
|
1630
|
-
db.syncIndexes(this.collectionName, [
|
1647
|
+
db.syncIndexes(this.collectionName, [
|
1648
|
+
['otherField', 'otherField2'],
|
1649
|
+
]),
|
1650
|
+
db.syncIndexes(this.collectionName, [
|
1651
|
+
['otherField', 'otherField2'],
|
1652
|
+
]),
|
1653
|
+
db.syncIndexes(this.collectionName, [
|
1654
|
+
['otherField', 'otherField2'],
|
1655
|
+
]),
|
1656
|
+
db.syncIndexes(this.collectionName, [
|
1657
|
+
['otherField', 'otherField2'],
|
1658
|
+
]),
|
1659
|
+
db.syncIndexes(this.collectionName, [
|
1660
|
+
['otherField', 'otherField2'],
|
1661
|
+
]),
|
1662
|
+
db.syncIndexes(this.collectionName, [
|
1663
|
+
['otherField', 'otherField2'],
|
1664
|
+
]),
|
1665
|
+
db.syncIndexes(this.collectionName, [
|
1666
|
+
['otherField', 'otherField2'],
|
1667
|
+
]),
|
1668
|
+
db.syncIndexes(this.collectionName, [
|
1669
|
+
['otherField', 'otherField2'],
|
1670
|
+
]),
|
1671
|
+
db.syncIndexes(this.collectionName, [
|
1672
|
+
['otherField', 'otherField2'],
|
1673
|
+
]),
|
1674
|
+
db.syncIndexes(this.collectionName, [
|
1675
|
+
['otherField', 'otherField2'],
|
1676
|
+
]),
|
1631
1677
|
];
|
1632
1678
|
yield Promise.all(syncs);
|
1633
1679
|
yield this.shutdown(db);
|
@@ -18,13 +18,13 @@ export interface QueryOptions {
|
|
18
18
|
}
|
19
19
|
export type FlattenAndPathKeys<O extends Obj, T extends Obj = PathKeys<O>> = Flatten<T>;
|
20
20
|
export type Flatten<T extends Obj> = Pick<T, NonObjectKeysOf<T>> & UnionToIntersection<ObjectValuesOf<T>>;
|
21
|
-
export type PathKeys<Query extends Obj,
|
22
|
-
[K in Extract<keyof Query, string> as `${
|
21
|
+
export type PathKeys<Query extends Obj, Prefix extends string = ''> = {
|
22
|
+
[K in Extract<keyof Query, string> as `${Prefix}${K}`]: Query[K] extends Obj ? PathKeys<Query[K], `${K}.`> : Query[K];
|
23
23
|
};
|
24
24
|
type UnionToIntersection<U> = (U extends any ? (k: U) => void : never) extends (k: infer I) => void ? I : never;
|
25
25
|
type ValuesOf<T> = T[keyof T];
|
26
|
-
type ObjectValuesOf<T> = Exclude<Extract<ValuesOf<T>, object>,
|
26
|
+
type ObjectValuesOf<T> = Exclude<Extract<ValuesOf<T>, object>, any[]>;
|
27
27
|
type NonObjectKeysOf<T> = {
|
28
|
-
[K in keyof T]: T[K] extends
|
28
|
+
[K in keyof T]: T[K] extends any[] ? K : T[K] extends Obj ? never : K;
|
29
29
|
}[keyof T];
|
30
30
|
export {};
|
@@ -1,5 +1,5 @@
|
|
1
1
|
import AbstractSpruceError from '@sprucelabs/error';
|
2
|
-
import { FailedToLoadStoreErrorOptions } from
|
2
|
+
import { FailedToLoadStoreErrorOptions } from './../.spruce/errors/options.types';
|
3
3
|
import StoreFactory from '../factories/StoreFactory';
|
4
4
|
import { Database } from '../types/database.types';
|
5
5
|
type StoreLoadError = AbstractSpruceError<FailedToLoadStoreErrorOptions>;
|
@@ -15,7 +15,9 @@ class DatabaseFieldMapperPlugin {
|
|
15
15
|
}
|
16
16
|
async prepareRecord(record) {
|
17
17
|
return {
|
18
|
-
newValues: this.mapper.mapFrom(record, {
|
18
|
+
newValues: this.mapper.mapFrom(record, {
|
19
|
+
shouldThrowOnUnmapped: false,
|
20
|
+
}),
|
19
21
|
};
|
20
22
|
}
|
21
23
|
async willUpdateOne(query, updates) {
|
@@ -47,7 +47,9 @@ const error_utility_1 = __importDefault(require("../utilities/error.utility"));
|
|
47
47
|
class AbstractStore extends AbstractMutexer_1.default {
|
48
48
|
constructor(db, collectionName) {
|
49
49
|
super();
|
50
|
-
this.primaryFieldNames = [
|
50
|
+
this.primaryFieldNames = [
|
51
|
+
'id',
|
52
|
+
];
|
51
53
|
this.shouldMapLowerCaseToCamelCase = false;
|
52
54
|
this.plugins = [];
|
53
55
|
this.db = db;
|
@@ -97,7 +99,7 @@ class AbstractStore extends AbstractMutexer_1.default {
|
|
97
99
|
try {
|
98
100
|
//@ts-ignore
|
99
101
|
values.forEach((v) => (0, schema_1.validateSchemaValues)(this.createSchema, v));
|
100
|
-
const cleanedValues = await Promise.all(values.map(async (v) =>
|
102
|
+
const cleanedValues = await Promise.all(values.map(async (v) => this.willCreate ? this.willCreate(v) : v));
|
101
103
|
const toSave = cleanedValues.map((v) => this.normalizeBeforeCreate(v));
|
102
104
|
const records = await this.db.create(this.collectionName, toSave);
|
103
105
|
return Promise.all(records.map(async (record) => this.prepareAndNormalizeRecord(record, options)));
|
@@ -26,7 +26,9 @@ class AbstractDatabaseTest extends test_utils_1.default {
|
|
26
26
|
static async connectToDatabase() {
|
27
27
|
if (!this.db) {
|
28
28
|
const { dbFixture, db } = await this.DatabaseConnection();
|
29
|
-
this.DB_NAME = this.shouldUseInMemoryDatabase
|
29
|
+
this.DB_NAME = this.shouldUseInMemoryDatabase
|
30
|
+
? ''
|
31
|
+
: dbFixture.getDbName();
|
30
32
|
this.db = db;
|
31
33
|
}
|
32
34
|
return this.db;
|
@@ -386,7 +386,9 @@ const databaseAssertUtil = {
|
|
386
386
|
$push: { names: 'second' },
|
387
387
|
});
|
388
388
|
test_utils_1.assert.isEqualDeep(updated.names, ['first', 'second']);
|
389
|
-
const matched = await db.findOne(this.collectionName, {
|
389
|
+
const matched = await db.findOne(this.collectionName, {
|
390
|
+
id: updated.id,
|
391
|
+
});
|
390
392
|
test_utils_1.assert.isTruthy(matched);
|
391
393
|
test_utils_1.assert.isEqualDeep(matched.names, ['first', 'second']);
|
392
394
|
await this.shutdown(db);
|
@@ -407,7 +409,9 @@ const databaseAssertUtil = {
|
|
407
409
|
catch (_a) {
|
408
410
|
test_utils_1.assert.fail('createOne() tried to create a record with an object field. Make sure the target field handles objects!');
|
409
411
|
}
|
410
|
-
const matched = await db.findOne(this.collectionName, {
|
412
|
+
const matched = await db.findOne(this.collectionName, {
|
413
|
+
id: created.id,
|
414
|
+
});
|
411
415
|
test_utils_1.assert.isEqualDeep(matched, Object.assign(Object.assign({}, created), { id: matched.id }));
|
412
416
|
await this.shutdown(db);
|
413
417
|
},
|
@@ -428,7 +432,9 @@ const databaseAssertUtil = {
|
|
428
432
|
await db.updateOne(this.collectionName, { id: created.id }, {
|
429
433
|
target,
|
430
434
|
});
|
431
|
-
const matched = await db.findOne(this.collectionName, {
|
435
|
+
const matched = await db.findOne(this.collectionName, {
|
436
|
+
id: created.id,
|
437
|
+
});
|
432
438
|
test_utils_1.assert.isEqualDeep(matched.target, target);
|
433
439
|
await this.shutdown(db);
|
434
440
|
},
|
@@ -446,7 +452,9 @@ const databaseAssertUtil = {
|
|
446
452
|
await db.updateOne(this.collectionName, { id: created.id }, {
|
447
453
|
'target.organizationId': 'oy oy',
|
448
454
|
});
|
449
|
-
const matched = await db.findOne(this.collectionName, {
|
455
|
+
const matched = await db.findOne(this.collectionName, {
|
456
|
+
id: created.id,
|
457
|
+
});
|
450
458
|
test_utils_1.assert.isEqualDeep(matched.target, Object.assign(Object.assign({}, target), { organizationId: 'oy oy' }));
|
451
459
|
await this.shutdown(db);
|
452
460
|
},
|
@@ -745,12 +753,21 @@ const databaseAssertUtil = {
|
|
745
753
|
},
|
746
754
|
async assertCanDropCompoundUniqueIndex(connect) {
|
747
755
|
const db = await connectToDabatase(connect);
|
748
|
-
await db.createUniqueIndex(this.collectionName, [
|
756
|
+
await db.createUniqueIndex(this.collectionName, [
|
757
|
+
'someField',
|
758
|
+
'otherField',
|
759
|
+
]);
|
749
760
|
await db.dropIndex(this.collectionName, ['someField', 'otherField']);
|
750
761
|
let indexes = await db.getUniqueIndexes(this.collectionName);
|
751
762
|
test_utils_1.assert.isLength(indexes, 0);
|
752
|
-
await db.createUniqueIndex(this.collectionName, [
|
753
|
-
|
763
|
+
await db.createUniqueIndex(this.collectionName, [
|
764
|
+
'someField',
|
765
|
+
'someField2',
|
766
|
+
]);
|
767
|
+
await db.createUniqueIndex(this.collectionName, [
|
768
|
+
'someField',
|
769
|
+
'someField3',
|
770
|
+
]);
|
754
771
|
await db.dropIndex(this.collectionName, ['someField', 'someField3']);
|
755
772
|
indexes = await db.getUniqueIndexes(this.collectionName);
|
756
773
|
test_utils_1.assert.isLength(indexes, 1);
|
@@ -1299,7 +1316,10 @@ const databaseAssertUtil = {
|
|
1299
1316
|
db.dropIndex = () => {
|
1300
1317
|
throw new Error('Should not have been called');
|
1301
1318
|
};
|
1302
|
-
await db.syncIndexes(this.collectionName, [
|
1319
|
+
await db.syncIndexes(this.collectionName, [
|
1320
|
+
['someField'],
|
1321
|
+
['otherField'],
|
1322
|
+
]);
|
1303
1323
|
await this.shutdown(db);
|
1304
1324
|
},
|
1305
1325
|
async assertSyncIndexesRemovesExtraIndexes(connect) {
|
@@ -1333,7 +1353,10 @@ const databaseAssertUtil = {
|
|
1333
1353
|
},
|
1334
1354
|
async assertCantDropCompoundIndexThatDoesNotExist(connect) {
|
1335
1355
|
const db = await connectToDabatase(connect);
|
1336
|
-
await db.createIndex(this.collectionName, [
|
1356
|
+
await db.createIndex(this.collectionName, [
|
1357
|
+
'someField',
|
1358
|
+
'someOtherField',
|
1359
|
+
]);
|
1337
1360
|
const err = await test_utils_1.assert.doesThrowAsync(() => db.dropIndex(this.collectionName, ['uniqueField', 'someOtherField']));
|
1338
1361
|
test_utils_2.errorAssert.assertError(err, 'INDEX_NOT_FOUND', {
|
1339
1362
|
collectionName: this.collectionName,
|
@@ -1406,7 +1429,10 @@ const databaseAssertUtil = {
|
|
1406
1429
|
indexes = await this._getFilteredIndexes(db);
|
1407
1430
|
test_utils_1.assert.isLength(indexes, 2);
|
1408
1431
|
test_utils_1.assert.isEqual(indexes[1][0].toLowerCase(), 'uniqueField2'.toLowerCase());
|
1409
|
-
await db.createIndex(this.collectionName, [
|
1432
|
+
await db.createIndex(this.collectionName, [
|
1433
|
+
'uniqueField3',
|
1434
|
+
'uniqueField4',
|
1435
|
+
]);
|
1410
1436
|
indexes = await this._getFilteredIndexes(db);
|
1411
1437
|
test_utils_1.assert.isLength(indexes, 3);
|
1412
1438
|
test_utils_1.assert.isEqual(indexes[2][0].toLowerCase(), 'uniqueField3'.toLowerCase());
|
@@ -1471,16 +1497,36 @@ const databaseAssertUtil = {
|
|
1471
1497
|
async assertSyncIndexesHandlesRaceConditions(connect) {
|
1472
1498
|
const db = await connectToDabatase(connect);
|
1473
1499
|
const syncs = [
|
1474
|
-
db.syncIndexes(this.collectionName, [
|
1475
|
-
|
1476
|
-
|
1477
|
-
db.syncIndexes(this.collectionName, [
|
1478
|
-
|
1479
|
-
|
1480
|
-
db.syncIndexes(this.collectionName, [
|
1481
|
-
|
1482
|
-
|
1483
|
-
db.syncIndexes(this.collectionName, [
|
1500
|
+
db.syncIndexes(this.collectionName, [
|
1501
|
+
['otherField', 'otherField2'],
|
1502
|
+
]),
|
1503
|
+
db.syncIndexes(this.collectionName, [
|
1504
|
+
['otherField', 'otherField2'],
|
1505
|
+
]),
|
1506
|
+
db.syncIndexes(this.collectionName, [
|
1507
|
+
['otherField', 'otherField2'],
|
1508
|
+
]),
|
1509
|
+
db.syncIndexes(this.collectionName, [
|
1510
|
+
['otherField', 'otherField2'],
|
1511
|
+
]),
|
1512
|
+
db.syncIndexes(this.collectionName, [
|
1513
|
+
['otherField', 'otherField2'],
|
1514
|
+
]),
|
1515
|
+
db.syncIndexes(this.collectionName, [
|
1516
|
+
['otherField', 'otherField2'],
|
1517
|
+
]),
|
1518
|
+
db.syncIndexes(this.collectionName, [
|
1519
|
+
['otherField', 'otherField2'],
|
1520
|
+
]),
|
1521
|
+
db.syncIndexes(this.collectionName, [
|
1522
|
+
['otherField', 'otherField2'],
|
1523
|
+
]),
|
1524
|
+
db.syncIndexes(this.collectionName, [
|
1525
|
+
['otherField', 'otherField2'],
|
1526
|
+
]),
|
1527
|
+
db.syncIndexes(this.collectionName, [
|
1528
|
+
['otherField', 'otherField2'],
|
1529
|
+
]),
|
1484
1530
|
];
|
1485
1531
|
await Promise.all(syncs);
|
1486
1532
|
await this.shutdown(db);
|
@@ -18,13 +18,13 @@ export interface QueryOptions {
|
|
18
18
|
}
|
19
19
|
export type FlattenAndPathKeys<O extends Obj, T extends Obj = PathKeys<O>> = Flatten<T>;
|
20
20
|
export type Flatten<T extends Obj> = Pick<T, NonObjectKeysOf<T>> & UnionToIntersection<ObjectValuesOf<T>>;
|
21
|
-
export type PathKeys<Query extends Obj,
|
22
|
-
[K in Extract<keyof Query, string> as `${
|
21
|
+
export type PathKeys<Query extends Obj, Prefix extends string = ''> = {
|
22
|
+
[K in Extract<keyof Query, string> as `${Prefix}${K}`]: Query[K] extends Obj ? PathKeys<Query[K], `${K}.`> : Query[K];
|
23
23
|
};
|
24
24
|
type UnionToIntersection<U> = (U extends any ? (k: U) => void : never) extends (k: infer I) => void ? I : never;
|
25
25
|
type ValuesOf<T> = T[keyof T];
|
26
|
-
type ObjectValuesOf<T> = Exclude<Extract<ValuesOf<T>, object>,
|
26
|
+
type ObjectValuesOf<T> = Exclude<Extract<ValuesOf<T>, object>, any[]>;
|
27
27
|
type NonObjectKeysOf<T> = {
|
28
|
-
[K in keyof T]: T[K] extends
|
28
|
+
[K in keyof T]: T[K] extends any[] ? K : T[K] extends Obj ? never : K;
|
29
29
|
}[keyof T];
|
30
30
|
export {};
|
package/package.json
CHANGED
@@ -3,7 +3,7 @@
|
|
3
3
|
"publishConfig": {
|
4
4
|
"access": "public"
|
5
5
|
},
|
6
|
-
"version": "
|
6
|
+
"version": "27.0.0",
|
7
7
|
"files": [
|
8
8
|
"build/**/*",
|
9
9
|
"!build/__tests__",
|
@@ -48,10 +48,10 @@
|
|
48
48
|
"clean.build": "rm -rf build/",
|
49
49
|
"clean.dependencies": "rm -rf node_modules/ package-lock.json yarn.lock",
|
50
50
|
"clean.dist": "rm -rf build/__tests__ build/esm/__tests__",
|
51
|
-
"fix.lint": "eslint --fix --cache
|
51
|
+
"fix.lint": "eslint --fix --cache",
|
52
52
|
"health": "yarn boot --health",
|
53
53
|
"health.local": "yarn boot.local --health",
|
54
|
-
"lint": "eslint --cache
|
54
|
+
"lint": "eslint --cache",
|
55
55
|
"lint.tsc": "tsc -p . --noEmit",
|
56
56
|
"post.watch.build": "yarn build.copy-files && yarn build.resolve-paths",
|
57
57
|
"rebuild": "yarn clean.all && yarn && yarn build.dev",
|
@@ -68,38 +68,37 @@
|
|
68
68
|
"upgrade.packages.test": "yarn upgrade.packages.all && yarn lint && yarn build.dev && yarn test"
|
69
69
|
},
|
70
70
|
"dependencies": {
|
71
|
-
"@sprucelabs/error": "^
|
72
|
-
"@sprucelabs/globby": "^
|
73
|
-
"@sprucelabs/schema": "^
|
74
|
-
"@sprucelabs/spruce-skill-utils": "^
|
71
|
+
"@sprucelabs/error": "^6.0.1",
|
72
|
+
"@sprucelabs/globby": "^2.0.1",
|
73
|
+
"@sprucelabs/schema": "^30.0.0",
|
74
|
+
"@sprucelabs/spruce-skill-utils": "^31.0.0",
|
75
75
|
"just-clone": "^6.2.0",
|
76
76
|
"lodash": "^4.17.21",
|
77
77
|
"mongodb": "^6.5.0",
|
78
78
|
"nedb": "^1.8.0"
|
79
79
|
},
|
80
80
|
"devDependencies": {
|
81
|
-
"@sprucelabs/esm-postbuild": "^
|
81
|
+
"@sprucelabs/esm-postbuild": "^6.0.1",
|
82
82
|
"@sprucelabs/jest-json-reporter": "^7.0.207",
|
83
|
-
"@sprucelabs/
|
84
|
-
"@sprucelabs/
|
85
|
-
"@sprucelabs/
|
86
|
-
"@sprucelabs/test": "^
|
87
|
-
"@sprucelabs/test-utils": "^4.0.157",
|
83
|
+
"@sprucelabs/resolve-path-aliases": "^2.0.3",
|
84
|
+
"@sprucelabs/semantic-release": "^5.0.1",
|
85
|
+
"@sprucelabs/test": "^9.0.2",
|
86
|
+
"@sprucelabs/test-utils": "^5.0.1",
|
88
87
|
"@types/lodash": "^4.17.0",
|
89
88
|
"@types/nedb": "^1.8.16",
|
90
|
-
"@types/node": "^20.12.
|
89
|
+
"@types/node": "^20.12.7",
|
91
90
|
"chokidar-cli": "^3.0.0",
|
92
91
|
"concurrently": "^8.2.2",
|
93
92
|
"dotenv": "^16.4.5",
|
94
|
-
"eslint": "^
|
95
|
-
"eslint-config-spruce": "^
|
93
|
+
"eslint": "^9.0.0",
|
94
|
+
"eslint-config-spruce": "^11.2.5",
|
96
95
|
"jest": "^29.7.0",
|
97
96
|
"jest-circus": "^29.7.0",
|
98
97
|
"prettier": "^3.2.5",
|
99
98
|
"ts-node": "^10.9.2",
|
100
99
|
"tsc-watch": "^6.2.0",
|
101
100
|
"tsconfig-paths": "^4.2.0",
|
102
|
-
"typescript": "^5.4.
|
101
|
+
"typescript": "^5.4.5"
|
103
102
|
},
|
104
103
|
"engines": {
|
105
104
|
"node": ">=12",
|
@@ -121,17 +120,6 @@
|
|
121
120
|
],
|
122
121
|
"moduleNameMapper": {
|
123
122
|
"^#spruce/(.*)$": "<rootDir>/build/.spruce/$1"
|
124
|
-
}
|
125
|
-
"reporters": [
|
126
|
-
"default",
|
127
|
-
[
|
128
|
-
"@sprucelabs/jest-sheets-reporter",
|
129
|
-
{
|
130
|
-
"sheetId": "1DoWM7mYgGDa-PJXptLomrZmbIBZiuxS1YiAsRXU2Gm0",
|
131
|
-
"worksheetId": 843037832,
|
132
|
-
"testMap": {}
|
133
|
-
}
|
134
|
-
]
|
135
|
-
]
|
123
|
+
}
|
136
124
|
}
|
137
125
|
}
|