@squiz/db-lib 1.2.1-alpha.98 → 1.2.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (37) hide show
  1. package/CHANGELOG.md +80 -0
  2. package/lib/AbstractRepository.d.ts +14 -4
  3. package/lib/index.d.ts +1 -7
  4. package/lib/index.js +1345 -1354
  5. package/lib/index.js.map +4 -4
  6. package/package.json +9 -11
  7. package/src/AbstractRepository.ts +81 -6
  8. package/src/index.ts +1 -10
  9. package/tsconfig.tsbuildinfo +1 -1
  10. package/lib/assertions/assertAssign.d.ts +0 -4
  11. package/lib/assertions/assertAssign.spec.d.ts +0 -1
  12. package/lib/assertions/assertAssignWithDefaultUndefinedValue.d.ts +0 -4
  13. package/lib/assertions/assertAssignWithDefaultUndefinedValue.spec.d.ts +0 -1
  14. package/lib/assertions/assertIsDefined.d.ts +0 -1
  15. package/lib/assertions/assertIsDefined.spec.d.ts +0 -1
  16. package/lib/assertions/assertIsMapOfStringString.d.ts +0 -3
  17. package/lib/assertions/assertIsMapOfStringString.spec.d.ts +0 -1
  18. package/lib/assertions/assertIsNotAnEmptyString.d.ts +0 -1
  19. package/lib/assertions/assertIsNotAnEmptyString.spec.d.ts +0 -1
  20. package/lib/assertions/assertIsObject.d.ts +0 -1
  21. package/lib/assertions/assertIsObject.spec.d.ts +0 -1
  22. package/lib/assertions/assertIsString.d.ts +0 -1
  23. package/lib/assertions/assertIsString.spec.d.ts +0 -1
  24. package/src/assertions/assertAssign.spec.ts +0 -18
  25. package/src/assertions/assertAssign.ts +0 -22
  26. package/src/assertions/assertAssignWithDefaultUndefinedValue.spec.ts +0 -31
  27. package/src/assertions/assertAssignWithDefaultUndefinedValue.ts +0 -17
  28. package/src/assertions/assertIsDefined.spec.ts +0 -19
  29. package/src/assertions/assertIsDefined.ts +0 -7
  30. package/src/assertions/assertIsMapOfStringString.spec.ts +0 -23
  31. package/src/assertions/assertIsMapOfStringString.ts +0 -29
  32. package/src/assertions/assertIsNotAnEmptyString.spec.ts +0 -25
  33. package/src/assertions/assertIsNotAnEmptyString.ts +0 -17
  34. package/src/assertions/assertIsObject.spec.ts +0 -17
  35. package/src/assertions/assertIsObject.ts +0 -11
  36. package/src/assertions/assertIsString.spec.ts +0 -16
  37. package/src/assertions/assertIsString.ts +0 -11
@@ -1,19 +0,0 @@
1
- import { assertIsDefined } from './assertIsDefined';
2
-
3
- describe('assertIsDefined', () => {
4
- it('should throw an assertion error if input is undefined', () => {
5
- expect(() => assertIsDefined(undefined)).toThrowErrorMatchingInlineSnapshot(
6
- `"Expected 'val' to be defined, but received undefined"`,
7
- );
8
- });
9
-
10
- it('should throw an assertion error if input is null', () => {
11
- expect(() => assertIsDefined(null)).toThrowErrorMatchingInlineSnapshot(
12
- `"Expected 'val' to be defined, but received null"`,
13
- );
14
- });
15
-
16
- it('should return "void" or undefined if valid', () => {
17
- expect(assertIsDefined(123)).toBeUndefined();
18
- });
19
- });
@@ -1,7 +0,0 @@
1
- import { AssertionError } from 'assert';
2
-
3
- export function assertIsDefined<T>(value: T): asserts value is NonNullable<T> {
4
- if (value === undefined || value === null) {
5
- throw new AssertionError({ message: `Expected 'val' to be defined, but received ${value}` });
6
- }
7
- }
@@ -1,23 +0,0 @@
1
- import { assertIsMapOfStringString } from './assertIsMapOfStringString';
2
-
3
- describe('assertIsMapOfStringString', () => {
4
- it('should not throw if input is an object with only string values', () => {
5
- expect(assertIsMapOfStringString({ prop: 'aa' })).toBeUndefined();
6
- });
7
- it('should not throw if input is an empty object', () => {
8
- expect(assertIsMapOfStringString({})).toBeUndefined();
9
- });
10
-
11
- it("should throw if object property isn't a string", () => {
12
- expect(() => assertIsMapOfStringString({ prop: 123 })).toThrowErrorMatchingInlineSnapshot(
13
- `"property prop is not type of string"`,
14
- );
15
- });
16
-
17
- it('should throw if input is not an object', () => {
18
- expect(() => assertIsMapOfStringString(123)).toThrowErrorMatchingInlineSnapshot(`"value is not a string"`);
19
- expect(() => assertIsMapOfStringString(undefined)).toThrowErrorMatchingInlineSnapshot(
20
- `"value cannot be null or undefined"`,
21
- );
22
- });
23
- });
@@ -1,29 +0,0 @@
1
- import { AssertionError } from 'assert';
2
-
3
- export function assertIsMapOfStringString(value: unknown): asserts value is { [key: string]: string } {
4
- if (!value) {
5
- throw new AssertionError({
6
- actual: value,
7
- expected: 'not null',
8
- message: 'value cannot be null or undefined',
9
- });
10
- }
11
-
12
- if (typeof value !== 'object') {
13
- throw new AssertionError({
14
- actual: value,
15
- expected: 'string',
16
- message: 'value is not a string',
17
- });
18
- }
19
-
20
- for (const [key, propValue] of Object.entries(value)) {
21
- if (typeof propValue !== 'string') {
22
- throw new AssertionError({
23
- actual: typeof propValue,
24
- expected: 'string',
25
- message: `property ${key} is not type of string`,
26
- });
27
- }
28
- }
29
- }
@@ -1,25 +0,0 @@
1
- import { assertIsNotAnEmptyString } from './assertIsNotAnEmptyString';
2
-
3
- describe('assertIsNotAnEmptyString', () => {
4
- it('should throw if input value is not a string', () => {
5
- expect(() => assertIsNotAnEmptyString(null)).toThrowErrorMatchingInlineSnapshot(`"value is not a string"`);
6
- expect(() => assertIsNotAnEmptyString(undefined)).toThrowErrorMatchingInlineSnapshot(`"value is not a string"`);
7
- expect(() => assertIsNotAnEmptyString(132)).toThrowErrorMatchingInlineSnapshot(`"value is not a string"`);
8
- expect(() => assertIsNotAnEmptyString({})).toThrowErrorMatchingInlineSnapshot(`"value is not a string"`);
9
- expect(() => assertIsNotAnEmptyString(['aa'])).toThrowErrorMatchingInlineSnapshot(`"value is not a string"`);
10
- });
11
-
12
- it('should throw if input is empty string', () => {
13
- expect(() => assertIsNotAnEmptyString('')).toThrowErrorMatchingInlineSnapshot(`"string cannot be empty"`);
14
- });
15
-
16
- it('should throw if input is whitespace string', () => {
17
- expect(() => assertIsNotAnEmptyString(' ')).toThrowErrorMatchingInlineSnapshot(`"string cannot be empty"`);
18
- expect(() => assertIsNotAnEmptyString(' ')).toThrowErrorMatchingInlineSnapshot(`"string cannot be empty"`);
19
- });
20
-
21
- it('should not throw if string of length >= 1 is passed in', () => {
22
- expect(assertIsNotAnEmptyString('1')).toBeUndefined();
23
- expect(assertIsNotAnEmptyString('11111')).toBeUndefined();
24
- });
25
- });
@@ -1,17 +0,0 @@
1
- import { AssertionError } from 'assert';
2
-
3
- export function assertIsNotAnEmptyString(val: any): asserts val is string {
4
- if (typeof val !== 'string') {
5
- throw new AssertionError({
6
- actual: typeof val,
7
- expected: 'string',
8
- message: 'value is not a string',
9
- });
10
- }
11
-
12
- if (val.trim().length === 0) {
13
- throw new AssertionError({
14
- message: 'string cannot be empty',
15
- });
16
- }
17
- }
@@ -1,17 +0,0 @@
1
- import { assertIsObject } from './assertIsObject';
2
-
3
- describe('assertIsObject', () => {
4
- it('should not throw if input is an object', () => {
5
- expect(assertIsObject({ hello: 123 })).toBeUndefined();
6
- });
7
-
8
- it("should throw if input isn't an object", () => {
9
- expect(() => assertIsObject(undefined)).toThrowErrorMatchingInlineSnapshot(`"value is not an object"`);
10
- expect(() => assertIsObject(null)).toThrowErrorMatchingInlineSnapshot(`"value is not an object"`);
11
- expect(() => assertIsObject('my string')).toThrowErrorMatchingInlineSnapshot(`"value is not an object"`);
12
- expect(() => assertIsObject(123)).toThrowErrorMatchingInlineSnapshot(`"value is not an object"`);
13
- expect(() => assertIsObject([])).toThrowErrorMatchingInlineSnapshot(`"value is not an object"`);
14
- expect(() => assertIsObject(NaN)).toThrowErrorMatchingInlineSnapshot(`"value is not an object"`);
15
- expect(() => assertIsObject(Infinity)).toThrowErrorMatchingInlineSnapshot(`"value is not an object"`);
16
- });
17
- });
@@ -1,11 +0,0 @@
1
- import { AssertionError } from 'assert';
2
-
3
- export function assertIsObject(val: any): asserts val is object {
4
- if (Object.prototype.toString.call(val) !== '[object Object]') {
5
- throw new AssertionError({
6
- actual: Object.prototype.toString.call(val),
7
- expected: 'object',
8
- message: 'value is not an object',
9
- });
10
- }
11
- }
@@ -1,16 +0,0 @@
1
- import { assertIsString } from './assertIsString';
2
-
3
- describe('assertIsString', () => {
4
- it('should not throw if input is a string', () => {
5
- expect(assertIsString('hello')).toBeUndefined();
6
- });
7
-
8
- it('should not throw if input is not a string', () => {
9
- expect(() => assertIsString(undefined)).toThrowErrorMatchingInlineSnapshot(`"value is not a string"`);
10
- expect(() => assertIsString(null)).toThrowErrorMatchingInlineSnapshot(`"value is not a string"`);
11
- expect(() => assertIsString(123)).toThrowErrorMatchingInlineSnapshot(`"value is not a string"`);
12
- expect(() => assertIsString([])).toThrowErrorMatchingInlineSnapshot(`"value is not a string"`);
13
- expect(() => assertIsString(NaN)).toThrowErrorMatchingInlineSnapshot(`"value is not a string"`);
14
- expect(() => assertIsString(Infinity)).toThrowErrorMatchingInlineSnapshot(`"value is not a string"`);
15
- });
16
- });
@@ -1,11 +0,0 @@
1
- import { AssertionError } from 'assert';
2
-
3
- export function assertIsString(val: any): asserts val is string {
4
- if (typeof val !== 'string') {
5
- throw new AssertionError({
6
- actual: val,
7
- expected: 'string',
8
- message: 'value is not a string',
9
- });
10
- }
11
- }