@mikemajesty/microservice-crud 6.0.2 → 6.0.5

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mikemajesty/microservice-crud",
3
- "version": "6.0.2",
3
+ "version": "6.0.5",
4
4
  "description": "Monorepo CLI",
5
5
  "main": "src/cli.js",
6
6
  "scripts": {
@@ -4,10 +4,11 @@ function capitalizeFirstLetter(string) {
4
4
  }
5
5
 
6
6
  const getCoreUsecaseCreateTest = (name) => `import { Test } from '@nestjs/testing';
7
+ import { ZodIssue } from 'zod';
7
8
 
8
9
  import { ILoggerAdapter } from '@/infra/logger';
9
10
  import { I${capitalizeFirstLetter(name)}CreateAdapter } from '@/modules/${name}/adapter';
10
- import { expectZodError, getMockUUID } from '@/utils/tests';
11
+ import { TestUtils } from '@/utils/tests';
11
12
 
12
13
  import { ${capitalizeFirstLetter(name)}Entity } from '../../entity/${name}';
13
14
  import { I${capitalizeFirstLetter(name)}Repository } from '../../repository/${name}';
@@ -45,9 +46,9 @@ describe(${capitalizeFirstLetter(name)}CreateUsecase.name, () => {
45
46
  });
46
47
 
47
48
  test('when no input is specified, should expect an error', async () => {
48
- await expectZodError(
49
+ await TestUtils.expectZodError(
49
50
  () => usecase.execute({}),
50
- (issues) => {
51
+ (issues: ZodIssue[]) => {
51
52
  expect(issues).toEqual([{ message: 'Required', path: ${capitalizeFirstLetter(name)}Entity.nameOf('name') }]);
52
53
  }
53
54
  );
@@ -58,7 +59,7 @@ describe(${capitalizeFirstLetter(name)}CreateUsecase.name, () => {
58
59
  };
59
60
 
60
61
  test('when ${name} created successfully, should expect a ${name}', async () => {
61
- const output: ${capitalizeFirstLetter(name)}CreateOutput = { created: true, id: getMockUUID() };
62
+ const output: ${capitalizeFirstLetter(name)}CreateOutput = { created: true, id: getMockUUID.getMockUUID() };
62
63
  repository.findOne = jest.fn().mockResolvedValue(null);
63
64
  repository.create = jest.fn().mockResolvedValue(output);
64
65
 
@@ -4,10 +4,11 @@ function capitalizeFirstLetter(string) {
4
4
  }
5
5
 
6
6
  const getCoreUsecaseDeleteTest = (name) => `import { Test } from '@nestjs/testing';
7
+ import { ZodIssue } from 'zod';
7
8
 
8
9
  import { I${capitalizeFirstLetter(name)}DeleteAdapter } from '@/modules/${name}/adapter';
9
10
  import { ApiNotFoundException } from '@/utils/exception';
10
- import { expectZodError, getMockUUID } from '@/utils/tests';
11
+ import { TestUtils } from '@/utils/tests';
11
12
 
12
13
  import { ${capitalizeFirstLetter(name)}Entity } from '../../entity/${name}';
13
14
  import { I${capitalizeFirstLetter(name)}Repository } from '../../repository/${name}';
@@ -40,16 +41,16 @@ describe(${capitalizeFirstLetter(name)}DeleteUsecase.name, () => {
40
41
  });
41
42
 
42
43
  test('when no input is specified, should expect an error', async () => {
43
- await expectZodError(
44
+ await TestUtils.expectZodError(
44
45
  () => usecase.execute({}),
45
- (issues) => {
46
+ (issues: ZodIssue[]) => {
46
47
  expect(issues).toEqual([{ message: 'Required', path: ${capitalizeFirstLetter(name)}Entity.nameOf('id') }]);
47
48
  }
48
49
  );
49
50
  });
50
51
 
51
52
  const input: ${capitalizeFirstLetter(name)}DeleteInput = {
52
- id: getMockUUID()
53
+ id: TestUtils.getMockUUID()
53
54
  };
54
55
 
55
56
  test('when ${name} not found, should expect an error', async () => {
@@ -59,7 +60,7 @@ describe(${capitalizeFirstLetter(name)}DeleteUsecase.name, () => {
59
60
  });
60
61
 
61
62
  const ${name} = new ${capitalizeFirstLetter(name)}Entity({
62
- id: getMockUUID(),
63
+ id: TestUtils.getMockUUID(),
63
64
  name: 'dummy'
64
65
  });
65
66
 
@@ -4,10 +4,11 @@ function capitalizeFirstLetter(string) {
4
4
  }
5
5
 
6
6
  const getCoreUsecaseGetByIdTest = (name) => `import { Test } from '@nestjs/testing';
7
+ import { ZodIssue } from 'zod';
7
8
 
8
9
  import { I${capitalizeFirstLetter(name)}GetByIdAdapter } from '@/modules/${name}/adapter';
9
10
  import { ApiNotFoundException } from '@/utils/exception';
10
- import { expectZodError, getMockUUID } from '@/utils/tests';
11
+ import { TestUtils } from '@/utils/tests';
11
12
 
12
13
  import { ${capitalizeFirstLetter(name)}Entity } from '../../entity/${name}';
13
14
  import { I${capitalizeFirstLetter(name)}Repository } from '../../repository/${name}';
@@ -40,16 +41,16 @@ describe(${capitalizeFirstLetter(name)}GetByIdUsecase.name, () => {
40
41
  });
41
42
 
42
43
  test('when no input is specified, should expect an error', async () => {
43
- await expectZodError(
44
+ await TestUtils.expectZodError(
44
45
  () => usecase.execute({}),
45
- (issues) => {
46
+ (issues: ZodIssue[]) => {
46
47
  expect(issues).toEqual([{ message: 'Required', path: ${capitalizeFirstLetter(name)}Entity.nameOf('id') }]);
47
48
  }
48
49
  );
49
50
  });
50
51
 
51
52
  const input: ${capitalizeFirstLetter(name)}GetByIdInput = {
52
- id: getMockUUID()
53
+ id: TestUtils.getMockUUID()
53
54
  };
54
55
 
55
56
  test('when ${name} not found, should expect an error', async () => {
@@ -6,9 +6,10 @@ function capitalizeFirstLetter(string) {
6
6
  }
7
7
 
8
8
  const getCoreUsecaseListTest = (name) => `import { Test } from '@nestjs/testing';
9
+ import { ZodIssue } from 'zod';
9
10
 
10
11
  import { I${capitalizeFirstLetter(name)}ListAdapter } from '@/modules/${name}/adapter';
11
- import { expectZodError, getMockUUID } from '@/utils/tests';
12
+ import { TestUtils } from '@/utils/tests';
12
13
 
13
14
  import { ${capitalizeFirstLetter(name)}Entity } from '../../entity/${name}';
14
15
  import { I${capitalizeFirstLetter(name)}Repository } from '../../repository/${name}';
@@ -41,9 +42,9 @@ describe(${capitalizeFirstLetter(name)}ListUsecase.name, () => {
41
42
  });
42
43
 
43
44
  test('when sort input is specified, should expect an error', async () => {
44
- await expectZodError(
45
+ await TestUtils.expectZodError(
45
46
  () => usecase.execute({ search: null, sort: null, limit: 10, page: 1 }),
46
- (issues) => {
47
+ (issues: ZodIssue[]) => {
47
48
  expect(issues).toEqual([{ message: 'Expected object, received null', path: 'sort' }]);
48
49
  }
49
50
  );
@@ -52,7 +53,7 @@ describe(${capitalizeFirstLetter(name)}ListUsecase.name, () => {
52
53
  const input: ${capitalizeFirstLetter(name)}ListInput = { limit: 1, page: 1, search: {}, sort: { createdAt: -1 } };
53
54
 
54
55
  const ${name} = new ${capitalizeFirstLetter(name)}Entity({
55
- id: getMockUUID(),
56
+ id: TestUtils.getMockUUID(),
56
57
  name: 'dummy',
57
58
  createdAt: new Date(),
58
59
  updatedAt: new Date()
@@ -4,11 +4,12 @@ function capitalizeFirstLetter(string) {
4
4
  }
5
5
 
6
6
  const getCoreUsecaseUpdateTest = (name) => `import { Test } from '@nestjs/testing';
7
+ import { ZodIssue } from 'zod';
7
8
 
8
9
  import { ILoggerAdapter, LoggerModule } from '@/infra/logger';
9
10
  import { I${capitalizeFirstLetter(name)}UpdateAdapter } from '@/modules/${name}/adapter';
10
11
  import { ApiNotFoundException } from '@/utils/exception';
11
- import { expectZodError, getMockUUID } from '@/utils/tests';
12
+ import { TestUtils } from '@/utils/tests';
12
13
 
13
14
  import { ${capitalizeFirstLetter(name)}Entity } from '../../entity/${name}';
14
15
  import { I${capitalizeFirstLetter(name)}Repository } from '../../repository/${name}';
@@ -41,16 +42,16 @@ describe(${capitalizeFirstLetter(name)}UpdateUsecase.name, () => {
41
42
  });
42
43
 
43
44
  test('when no input is specified, should expect an error', async () => {
44
- await expectZodError(
45
+ await TestUtils.expectZodError(
45
46
  () => usecase.execute({}),
46
- (issues) => {
47
+ (issues: ZodIssue[]) => {
47
48
  expect(issues).toEqual([{ message: 'Required', path: ${capitalizeFirstLetter(name)}Entity.nameOf('id') }]);
48
49
  }
49
50
  );
50
51
  });
51
52
 
52
53
  const input: ${capitalizeFirstLetter(name)}UpdateInput = {
53
- id: getMockUUID()
54
+ id: TestUtils.getMockUUID()
54
55
  };
55
56
 
56
57
  test('when ${name} not found, should expect an error', async () => {
@@ -60,7 +61,7 @@ describe(${capitalizeFirstLetter(name)}UpdateUsecase.name, () => {
60
61
  });
61
62
 
62
63
  const ${name}: ${capitalizeFirstLetter(name)}UpdateOutput = new ${capitalizeFirstLetter(name)}Entity({
63
- id: getMockUUID(),
64
+ id: TestUtils.getMockUUID(),
64
65
  name: 'dummy'
65
66
  });
66
67
 
@@ -4,10 +4,11 @@ function capitalizeFirstLetter(string) {
4
4
  }
5
5
 
6
6
  const getCoreUsecaseCreateTest = (name) => `import { Test } from '@nestjs/testing';
7
+ import { ZodIssue } from 'zod';
7
8
 
8
9
  import { ILoggerAdapter } from '@/infra/logger';
9
10
  import { I${capitalizeFirstLetter(name)}CreateAdapter } from '@/modules/${name}/adapter';
10
- import { expectZodError, getMockUUID } from '@/utils/tests';
11
+ import { TestUtils } from '@/utils/tests';
11
12
 
12
13
  import { ${capitalizeFirstLetter(name)}Entity } from '../../entity/${name}';
13
14
  import { I${capitalizeFirstLetter(name)}Repository } from '../../repository/${name}';
@@ -45,9 +46,9 @@ describe(${capitalizeFirstLetter(name)}CreateUsecase.name, () => {
45
46
  });
46
47
 
47
48
  test('when no input is specified, should expect an error', async () => {
48
- await expectZodError(
49
+ await TestUtils.expectZodError(
49
50
  () => usecase.execute({}),
50
- (issues) => {
51
+ (issues: ZodIssue[]) => {
51
52
  expect(issues).toEqual([{ message: 'Required', path: ${capitalizeFirstLetter(name)}Entity.nameOf('name') }]);
52
53
  }
53
54
  );
@@ -58,7 +59,7 @@ describe(${capitalizeFirstLetter(name)}CreateUsecase.name, () => {
58
59
  };
59
60
 
60
61
  test('when ${name} created successfully, should expect a ${name}', async () => {
61
- const output: ${capitalizeFirstLetter(name)}CreateOutput = { created: true, id: getMockUUID() };
62
+ const output: ${capitalizeFirstLetter(name)}CreateOutput = { created: true, id: TestUtils.getMockUUID() };
62
63
  repository.create = jest.fn().mockResolvedValue(output);
63
64
 
64
65
  await expect(usecase.execute(input)).resolves.toEqual(output);
@@ -4,11 +4,12 @@ function capitalizeFirstLetter(string) {
4
4
  }
5
5
 
6
6
  const getCoreUsecaseDeleteTest = (name) => `import { Test } from '@nestjs/testing';
7
+ import { ZodIssue } from 'zod';
7
8
 
8
9
  import { ${capitalizeFirstLetter(name)}DeleteInput, ${capitalizeFirstLetter(name)}DeleteUsecase } from '@/core/${name}/use-cases/${name}-delete';
9
10
  import { I${capitalizeFirstLetter(name)}DeleteAdapter } from '@/modules/${name}/adapter';
10
11
  import { ApiNotFoundException } from '@/utils/exception';
11
- import { expectZodError, getMockUUID } from '@/utils/tests';
12
+ import { TestUtils } from '@/utils/tests';
12
13
 
13
14
  import { I${capitalizeFirstLetter(name)}Repository } from '../../repository/${name}';
14
15
  import { ${capitalizeFirstLetter(name)}Entity } from './../../entity/${name}';
@@ -39,16 +40,16 @@ describe(${capitalizeFirstLetter(name)}DeleteUsecase.name, () => {
39
40
  });
40
41
 
41
42
  test('when no input is specified, should expect an error', async () => {
42
- await expectZodError(
43
+ await TestUtils.expectZodError(
43
44
  () => usecase.execute({}),
44
- (issues) => {
45
+ (issues: ZodIssue[]) => {
45
46
  expect(issues).toEqual([{ message: 'Required', path: ${capitalizeFirstLetter(name)}Entity.nameOf('id') }]);
46
47
  }
47
48
  );
48
49
  });
49
50
 
50
51
  const input: ${capitalizeFirstLetter(name)}DeleteInput = {
51
- id: getMockUUID()
52
+ id: TestUtils.getMockUUID()
52
53
  };
53
54
 
54
55
  test('when ${name} not found, should expect an error', async () => {
@@ -58,7 +59,7 @@ describe(${capitalizeFirstLetter(name)}DeleteUsecase.name, () => {
58
59
  });
59
60
 
60
61
  const ${name} = new ${capitalizeFirstLetter(name)}Entity({
61
- id: getMockUUID(),
62
+ id: TestUtils.getMockUUID(),
62
63
  name: 'dummy'
63
64
  });
64
65
 
@@ -4,10 +4,11 @@ function capitalizeFirstLetter(string) {
4
4
  }
5
5
 
6
6
  const getCoreUsecaseGetByIdTest = (name) => `import { Test } from '@nestjs/testing';
7
+ import { ZodIssue } from 'zod';
7
8
 
8
9
  import { I${capitalizeFirstLetter(name)}GetByIdAdapter } from '@/modules/${name}/adapter';
9
10
  import { ApiNotFoundException } from '@/utils/exception';
10
- import { expectZodError, getMockUUID } from '@/utils/tests';
11
+ import { TestUtils } from '@/utils/tests';
11
12
 
12
13
  import { I${capitalizeFirstLetter(name)}Repository } from '../../repository/${name}';
13
14
  import { ${capitalizeFirstLetter(name)}GetByIdInput, ${capitalizeFirstLetter(name)}GetByIdUsecase } from '../${name}-get-by-id';
@@ -39,16 +40,16 @@ describe(${capitalizeFirstLetter(name)}GetByIdUsecase.name, () => {
39
40
  });
40
41
 
41
42
  test('when no input is specified, should expect an error', async () => {
42
- await expectZodError(
43
+ await TestUtils.expectZodError(
43
44
  () => usecase.execute({}),
44
- (issues) => {
45
+ (issues: ZodIssue[]) => {
45
46
  expect(issues).toEqual([{ message: 'Required', path: ${capitalizeFirstLetter(name)}Entity.nameOf('id') }]);
46
47
  }
47
48
  );
48
49
  });
49
50
 
50
51
  const input: ${capitalizeFirstLetter(name)}GetByIdInput = {
51
- id: getMockUUID()
52
+ id: TestUtils.getMockUUID()
52
53
  };
53
54
 
54
55
  test('when ${name} not found, should expect an error', async () => {
@@ -58,7 +59,7 @@ describe(${capitalizeFirstLetter(name)}GetByIdUsecase.name, () => {
58
59
  });
59
60
 
60
61
  const ${name} = new ${capitalizeFirstLetter(name)}Entity({
61
- id: getMockUUID(),
62
+ id: TestUtils.getMockUUID(),
62
63
  name: 'dummy'
63
64
  });
64
65
 
@@ -6,10 +6,11 @@ function capitalizeFirstLetter(string) {
6
6
  }
7
7
 
8
8
  const getCoreUsecaseListTest = (name) => `import { Test } from '@nestjs/testing';
9
+ import { ZodIssue } from 'zod';
9
10
 
10
11
  import { ${capitalizeFirstLetter(name)}ListInput, ${capitalizeFirstLetter(name)}ListOutput, ${capitalizeFirstLetter(name)}ListUsecase } from '@/core/${name}/use-cases/${name}-list';
11
12
  import { I${capitalizeFirstLetter(name)}ListAdapter } from '@/modules/${name}/adapter';
12
- import { expectZodError, getMockUUID } from '@/utils/tests';
13
+ import { TestUtils } from '@/utils/tests';
13
14
 
14
15
  import { I${capitalizeFirstLetter(name)}Repository } from '../../repository/${name}';
15
16
  import { ${capitalizeFirstLetter(name)}Entity } from './../../entity/${name}';
@@ -40,9 +41,9 @@ describe(${capitalizeFirstLetter(name)}ListUsecase.name, () => {
40
41
  });
41
42
 
42
43
  test('when sort input is specified, should expect an error', async () => {
43
- await expectZodError(
44
+ await TestUtils.expectZodError(
44
45
  () => usecase.execute({ search: null, sort: null, limit: 10, page: 1 }),
45
- (issues) => {
46
+ (issues: ZodIssue[]) => {
46
47
  expect(issues).toEqual([{ message: 'Expected object, received null', path: 'sort' }]);
47
48
  }
48
49
  );
@@ -51,7 +52,7 @@ describe(${capitalizeFirstLetter(name)}ListUsecase.name, () => {
51
52
  const input: ${capitalizeFirstLetter(name)}ListInput = { limit: 1, page: 1, search: {}, sort: { createdAt: -1 } };
52
53
 
53
54
  const ${name} = new ${capitalizeFirstLetter(name)}Entity({
54
- id: getMockUUID(),
55
+ id: TestUtils.getMockUUID(),
55
56
  name: 'dummy',
56
57
  createdAt: new Date(),
57
58
  updatedAt: new Date()
@@ -4,11 +4,12 @@ function capitalizeFirstLetter(string) {
4
4
  }
5
5
 
6
6
  const getCoreUsecaseUpdateTest = (name) => `import { Test } from '@nestjs/testing';
7
+ import { ZodIssue } from 'zod';
7
8
 
8
9
  import { ILoggerAdapter } from '@/infra/logger';
9
10
  import { I${capitalizeFirstLetter(name)}UpdateAdapter } from '@/modules/${name}/adapter';
10
11
  import { ApiNotFoundException } from '@/utils/exception';
11
- import { expectZodError, getMockUUID } from '@/utils/tests';
12
+ import { TestUtils } from '@/utils/tests';
12
13
 
13
14
  import { I${capitalizeFirstLetter(name)}Repository } from '../../repository/${name}';
14
15
  import { ${capitalizeFirstLetter(name)}UpdateInput, ${capitalizeFirstLetter(name)}UpdateUsecase } from '../${name}-update';
@@ -46,16 +47,16 @@ describe(${capitalizeFirstLetter(name)}UpdateUsecase.name, () => {
46
47
  });
47
48
 
48
49
  test('when no input is specified, should expect an error', async () => {
49
- await expectZodError(
50
+ await TestUtils.expectZodError(
50
51
  () => usecase.execute({}),
51
- (issues) => {
52
+ (issues: ZodIssue[]) => {
52
53
  expect(issues).toEqual([{ message: 'Required', path: ${capitalizeFirstLetter(name)}Entity.nameOf('id') }]);
53
54
  }
54
55
  );
55
56
  });
56
57
 
57
58
  const input: ${capitalizeFirstLetter(name)}UpdateInput = {
58
- id: getMockUUID()
59
+ id: TestUtils.getMockUUID()
59
60
  };
60
61
 
61
62
  test('when ${name} not found, should expect an error', async () => {
@@ -65,7 +66,7 @@ describe(${capitalizeFirstLetter(name)}UpdateUsecase.name, () => {
65
66
  });
66
67
 
67
68
  const ${name} = new ${capitalizeFirstLetter(name)}Entity({
68
- id: getMockUUID(),
69
+ id: TestUtils.getMockUUID(),
69
70
  name: 'dummy'
70
71
  });
71
72