@sprucelabs/data-stores 28.2.0 → 28.3.0

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.
@@ -1,7 +1,9 @@
1
1
  import { Database, IndexWithFilter, TestConnect } from '../types/database.types';
2
2
  import { DataStore } from '../types/stores.types';
3
3
  declare const methods: readonly ["assertThrowsWithInvalidConnectionString", "assertThrowsWhenCantConnect", "assertThrowsWithBadDatabaseName", "assertKnowsIfConnectionClosed", "assertCanSortDesc", "assertCanSortAsc", "assertCanSortById", "assertCanQueryWithOr", "assertGeneratesIdDifferentEachTime", "assertInsertingGeneratesId", "assertCanCreateMany", "assertCanCreateWithObjectField", "assertCanCountOnId", "assertCanCount", "assertThrowsWhenUpdatingRecordNotFound", "assertCanUpdate", "assertCanUpdateMany", "assertCanPushOntoArrayValue", "assertCanUpdateWithObjectField", "assertCanUpdateFieldInObjectFieldWithTargettedWhere", "assertCanSaveAndGetNullAndUndefined", "assertCanUpsertOne", "assertCanUpsertNull", "assertCanPushToArrayOnUpsert", "assertCanSyncUniqueIndexesWithFilterExpression", "assertEmptyDatabaseReturnsEmptyArray", "assertFindOneOnEmptyDatabaseReturnsNull", "assertCanLimitResults", "assertCanLimitResultsToZero", "assertCanFindWithBooleanField", "assertCanQueryByGtLtGteLteNe", "assertCanQueryPathWithDotSyntax", "assertCanReturnOnlySelectFields", "assertCanSearchByRegex", "assertCanFindWithNe", "assertCanFindWithIn", "assertCanDeleteRecord", "assertCanDeleteOne", "assertHasNoUniqueIndexToStart", "assertCanCreateUniqueIndex", "assertCanCreateMultiFieldUniqueIndex", "assertCantCreateUniqueIndexTwice", "assertCanDropUniqueIndex", "assertCanDropCompoundUniqueIndex", "assertCantDropUniqueIndexThatDoesntExist", "assertCantDropIndexWhenNoIndexExists", "assertCantDropCompoundUniqueIndexThatDoesntExist", "assertSyncingUniqueIndexsAddsMissingIndexes", "assertSyncingUniqueIndexsSkipsExistingIndexs", "assertSyncingUniqueIndexesRemovesExtraIndexes", "assertSyncingUniqueIndexesIsRaceProof", "assertSyncingIndexesDoesNotAddAndRemove", "assertUniqueIndexBlocksDuplicates", "assertDuplicateKeyThrowsOnInsert", "assertSettingUniqueIndexViolationThrowsSpruceError", "assertCanCreateUniqueIndexOnNestedField", "assertUpsertWithUniqueIndex", "assertNestedFieldIndexUpdates", "assertHasNoIndexToStart", "assertCanCreateIndex", "assertCantCreateSameIndexTwice", "assertCanCreateMultiFieldIndex", "assertCanDropIndex", "assertCanDropCompoundIndex", "assertCantDropCompoundIndexThatDoesNotExist", "assertSyncIndexesSkipsExisting", "assertSyncIndexesRemovesExtraIndexes", "assertSyncIndexesHandlesRaceConditions", "assertSyncIndexesDoesNotRemoveExisting", "assertDuplicateFieldsWithMultipleUniqueIndexesWorkAsExpected", "assertCanSyncIndexesWithoutPartialThenAgainWithProperlyUpdates"];
4
- export type DatabaseAssertionName = (typeof methods)[number];
4
+ type OriginalMethods = (typeof methods)[number];
5
+ type BangMethods = `!${OriginalMethods}`;
6
+ export type DatabaseAssertionName = OriginalMethods | BangMethods;
5
7
  declare const databaseAssertUtil: {
6
8
  collectionName: string;
7
9
  runSuite(connect: TestConnect, tests?: DatabaseAssertionName[]): Promise<void>;
@@ -7,7 +7,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
7
7
  step((generator = generator.apply(thisArg, _arguments || [])).next());
8
8
  });
9
9
  };
10
- import { assertOptions } from '@sprucelabs/schema';
10
+ import { assertOptions, SchemaError } from '@sprucelabs/schema';
11
11
  import { assert } from '@sprucelabs/test-utils';
12
12
  import { errorAssert } from '@sprucelabs/test-utils';
13
13
  import generateId from '../utilities/generateId.js';
@@ -100,9 +100,21 @@ const databaseAssertUtil = {
100
100
  const db = yield connectToDabatase(connect);
101
101
  yield db.dropDatabase();
102
102
  yield this.shutdown(db);
103
- if (tests === null || tests === void 0 ? void 0 : tests[0].startsWith('!')) {
104
- //@ts-ignore
105
- tests = methods;
103
+ const hasIgnore = tests === null || tests === void 0 ? void 0 : tests.find((t) => t.startsWith('!'));
104
+ if (hasIgnore && tests) {
105
+ for (const method of tests) {
106
+ if (!method.startsWith('!')) {
107
+ throw new SchemaError({
108
+ code: 'INVALID_PARAMETERS',
109
+ parameters: ['tests'],
110
+ });
111
+ }
112
+ }
113
+ const doesMatch = (m) => {
114
+ return !!tests.find((t) => t.substring(1) === m);
115
+ };
116
+ const filtered = methods.filter((m) => !doesMatch(m));
117
+ tests = filtered;
106
118
  }
107
119
  const toRun = tests !== null && tests !== void 0 ? tests : methods;
108
120
  for (const method of toRun) {
@@ -1,7 +1,9 @@
1
1
  import { Database, IndexWithFilter, TestConnect } from '../types/database.types';
2
2
  import { DataStore } from '../types/stores.types';
3
3
  declare const methods: readonly ["assertThrowsWithInvalidConnectionString", "assertThrowsWhenCantConnect", "assertThrowsWithBadDatabaseName", "assertKnowsIfConnectionClosed", "assertCanSortDesc", "assertCanSortAsc", "assertCanSortById", "assertCanQueryWithOr", "assertGeneratesIdDifferentEachTime", "assertInsertingGeneratesId", "assertCanCreateMany", "assertCanCreateWithObjectField", "assertCanCountOnId", "assertCanCount", "assertThrowsWhenUpdatingRecordNotFound", "assertCanUpdate", "assertCanUpdateMany", "assertCanPushOntoArrayValue", "assertCanUpdateWithObjectField", "assertCanUpdateFieldInObjectFieldWithTargettedWhere", "assertCanSaveAndGetNullAndUndefined", "assertCanUpsertOne", "assertCanUpsertNull", "assertCanPushToArrayOnUpsert", "assertCanSyncUniqueIndexesWithFilterExpression", "assertEmptyDatabaseReturnsEmptyArray", "assertFindOneOnEmptyDatabaseReturnsNull", "assertCanLimitResults", "assertCanLimitResultsToZero", "assertCanFindWithBooleanField", "assertCanQueryByGtLtGteLteNe", "assertCanQueryPathWithDotSyntax", "assertCanReturnOnlySelectFields", "assertCanSearchByRegex", "assertCanFindWithNe", "assertCanFindWithIn", "assertCanDeleteRecord", "assertCanDeleteOne", "assertHasNoUniqueIndexToStart", "assertCanCreateUniqueIndex", "assertCanCreateMultiFieldUniqueIndex", "assertCantCreateUniqueIndexTwice", "assertCanDropUniqueIndex", "assertCanDropCompoundUniqueIndex", "assertCantDropUniqueIndexThatDoesntExist", "assertCantDropIndexWhenNoIndexExists", "assertCantDropCompoundUniqueIndexThatDoesntExist", "assertSyncingUniqueIndexsAddsMissingIndexes", "assertSyncingUniqueIndexsSkipsExistingIndexs", "assertSyncingUniqueIndexesRemovesExtraIndexes", "assertSyncingUniqueIndexesIsRaceProof", "assertSyncingIndexesDoesNotAddAndRemove", "assertUniqueIndexBlocksDuplicates", "assertDuplicateKeyThrowsOnInsert", "assertSettingUniqueIndexViolationThrowsSpruceError", "assertCanCreateUniqueIndexOnNestedField", "assertUpsertWithUniqueIndex", "assertNestedFieldIndexUpdates", "assertHasNoIndexToStart", "assertCanCreateIndex", "assertCantCreateSameIndexTwice", "assertCanCreateMultiFieldIndex", "assertCanDropIndex", "assertCanDropCompoundIndex", "assertCantDropCompoundIndexThatDoesNotExist", "assertSyncIndexesSkipsExisting", "assertSyncIndexesRemovesExtraIndexes", "assertSyncIndexesHandlesRaceConditions", "assertSyncIndexesDoesNotRemoveExisting", "assertDuplicateFieldsWithMultipleUniqueIndexesWorkAsExpected", "assertCanSyncIndexesWithoutPartialThenAgainWithProperlyUpdates"];
4
- export type DatabaseAssertionName = (typeof methods)[number];
4
+ type OriginalMethods = (typeof methods)[number];
5
+ type BangMethods = `!${OriginalMethods}`;
6
+ export type DatabaseAssertionName = OriginalMethods | BangMethods;
5
7
  declare const databaseAssertUtil: {
6
8
  collectionName: string;
7
9
  runSuite(connect: TestConnect, tests?: DatabaseAssertionName[]): Promise<void>;
@@ -95,9 +95,21 @@ const databaseAssertUtil = {
95
95
  const db = await connectToDabatase(connect);
96
96
  await db.dropDatabase();
97
97
  await this.shutdown(db);
98
- if (tests === null || tests === void 0 ? void 0 : tests[0].startsWith('!')) {
99
- //@ts-ignore
100
- tests = methods;
98
+ const hasIgnore = tests === null || tests === void 0 ? void 0 : tests.find((t) => t.startsWith('!'));
99
+ if (hasIgnore && tests) {
100
+ for (const method of tests) {
101
+ if (!method.startsWith('!')) {
102
+ throw new schema_1.SchemaError({
103
+ code: 'INVALID_PARAMETERS',
104
+ parameters: ['tests'],
105
+ });
106
+ }
107
+ }
108
+ const doesMatch = (m) => {
109
+ return !!tests.find((t) => t.substring(1) === m);
110
+ };
111
+ const filtered = methods.filter((m) => !doesMatch(m));
112
+ tests = filtered;
101
113
  }
102
114
  const toRun = tests !== null && tests !== void 0 ? tests : methods;
103
115
  for (const method of toRun) {
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "publishConfig": {
4
4
  "access": "public"
5
5
  },
6
- "version": "28.2.0",
6
+ "version": "28.3.0",
7
7
  "files": [
8
8
  "build/**/*",
9
9
  "!build/__tests__",