@tomei/media 0.8.9 → 0.8.10

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.
Files changed (119) hide show
  1. package/.commitlintrc.json +22 -22
  2. package/.gitlab-ci.yml +16 -16
  3. package/.husky/commit-msg +15 -15
  4. package/.husky/pre-commit +7 -7
  5. package/.prettierrc +4 -4
  6. package/README.md +93 -93
  7. package/dist/base/base.medias.d.ts +38 -0
  8. package/dist/base/base.medias.js +175 -0
  9. package/dist/base/base.medias.js.map +1 -0
  10. package/dist/base/base.repository.abstract.d.ts +12 -0
  11. package/dist/base/base.repository.abstract.js +22 -0
  12. package/dist/base/base.repository.abstract.js.map +1 -0
  13. package/dist/base/base.repository.interface.d.ts +9 -0
  14. package/dist/base/base.repository.interface.js +3 -0
  15. package/dist/base/base.repository.interface.js.map +1 -0
  16. package/dist/common/common.module.d.ts +2 -0
  17. package/dist/common/common.module.js +23 -0
  18. package/dist/common/common.module.js.map +1 -0
  19. package/dist/common/common.service.d.ts +13 -0
  20. package/dist/common/common.service.js +106 -0
  21. package/dist/common/common.service.js.map +1 -0
  22. package/dist/common/dto/add-field-translation.dto.d.ts +7 -0
  23. package/dist/common/dto/add-field-translation.dto.js +42 -0
  24. package/dist/common/dto/add-field-translation.dto.js.map +1 -0
  25. package/dist/common/dto/get-media.dto.d.ts +5 -0
  26. package/dist/common/dto/get-media.dto.js +29 -0
  27. package/dist/common/dto/get-media.dto.js.map +1 -0
  28. package/dist/database.d.ts +4 -0
  29. package/dist/database.js +16 -0
  30. package/dist/database.js.map +1 -0
  31. package/dist/dto/external-media.dto.d.ts +10 -0
  32. package/dist/dto/external-media.dto.js +70 -0
  33. package/dist/dto/external-media.dto.js.map +1 -0
  34. package/dist/dto/internal-medias.dto.d.ts +12 -0
  35. package/dist/dto/internal-medias.dto.js +87 -0
  36. package/dist/dto/internal-medias.dto.js.map +1 -0
  37. package/dist/entities/medias.entity.d.ts +23 -0
  38. package/dist/entities/medias.entity.js +160 -0
  39. package/dist/entities/medias.entity.js.map +1 -0
  40. package/dist/enum/index.d.ts +2 -0
  41. package/dist/enum/index.js +6 -0
  42. package/dist/enum/index.js.map +1 -0
  43. package/dist/enum/medias.enum.d.ts +5 -0
  44. package/dist/enum/medias.enum.js +10 -0
  45. package/dist/enum/medias.enum.js.map +1 -0
  46. package/dist/helpers/error.d.ts +1 -0
  47. package/dist/helpers/error.js +13 -0
  48. package/dist/helpers/error.js.map +1 -0
  49. package/dist/helpers/index.d.ts +2 -0
  50. package/dist/helpers/index.js +6 -0
  51. package/dist/helpers/index.js.map +1 -0
  52. package/dist/index.d.ts +12 -0
  53. package/dist/index.js +22 -0
  54. package/dist/index.js.map +1 -0
  55. package/dist/interfaces/base.medias-attr.interface.d.ts +20 -0
  56. package/dist/interfaces/base.medias-attr.interface.js +3 -0
  57. package/dist/interfaces/base.medias-attr.interface.js.map +1 -0
  58. package/dist/interfaces/medias.repository.interface.d.ts +3 -0
  59. package/dist/interfaces/medias.repository.interface.js +3 -0
  60. package/dist/interfaces/medias.repository.interface.js.map +1 -0
  61. package/dist/medias.d.ts +65 -0
  62. package/dist/medias.js +564 -0
  63. package/dist/medias.js.map +1 -0
  64. package/dist/medias.repository.d.ts +8 -0
  65. package/dist/medias.repository.js +56 -0
  66. package/dist/medias.repository.js.map +1 -0
  67. package/dist/pipe/append-id.pipe.d.ts +6 -0
  68. package/dist/pipe/append-id.pipe.js +28 -0
  69. package/dist/pipe/append-id.pipe.js.map +1 -0
  70. package/dist/pipe/validate-enum.pipe.d.ts +6 -0
  71. package/dist/pipe/validate-enum.pipe.js +34 -0
  72. package/dist/pipe/validate-enum.pipe.js.map +1 -0
  73. package/dist/pipe/validate-id.pipe.d.ts +6 -0
  74. package/dist/pipe/validate-id.pipe.js +31 -0
  75. package/dist/pipe/validate-id.pipe.js.map +1 -0
  76. package/dist/pipe/validate-search.pipe.d.ts +7 -0
  77. package/dist/pipe/validate-search.pipe.js +46 -0
  78. package/dist/pipe/validate-search.pipe.js.map +1 -0
  79. package/dist/responses/deleted.response.d.ts +3 -0
  80. package/dist/responses/deleted.response.js +21 -0
  81. package/dist/responses/deleted.response.js.map +1 -0
  82. package/dist/responses/pagination.response.d.ts +5 -0
  83. package/dist/responses/pagination.response.js +26 -0
  84. package/dist/responses/pagination.response.js.map +1 -0
  85. package/dist/tsconfig.tsbuildinfo +1 -0
  86. package/eslint.config.mjs +58 -58
  87. package/migration/0001-add-defaultyn-hiddenyn-to-media-table.js +36 -36
  88. package/migration/media-migration.js +82 -82
  89. package/nest-cli.json +18 -18
  90. package/package.json +79 -79
  91. package/sonar-project.properties +12 -12
  92. package/src/base/base.medias.ts +210 -210
  93. package/src/base/base.repository.abstract.ts +28 -28
  94. package/src/base/base.repository.interface.ts +9 -9
  95. package/src/common/common.module.ts +10 -10
  96. package/src/common/common.service.ts +107 -107
  97. package/src/common/dto/add-field-translation.dto.ts +23 -23
  98. package/src/common/dto/get-media.dto.ts +12 -12
  99. package/src/database.ts +16 -16
  100. package/src/dto/external-media.dto.ts +49 -49
  101. package/src/dto/internal-medias.dto.ts +64 -64
  102. package/src/entities/medias.entity.ts +125 -125
  103. package/src/enum/index.ts +3 -3
  104. package/src/enum/medias.enum.ts +5 -5
  105. package/src/helpers/error.ts +12 -12
  106. package/src/helpers/index.ts +3 -3
  107. package/src/index.ts +24 -24
  108. package/src/interfaces/base.medias-attr.interface.ts +21 -21
  109. package/src/interfaces/medias.repository.interface.ts +4 -4
  110. package/src/medias.repository.ts +55 -55
  111. package/src/medias.ts +769 -769
  112. package/src/pipe/append-id.pipe.ts +15 -15
  113. package/src/pipe/validate-enum.pipe.ts +31 -31
  114. package/src/pipe/validate-id.pipe.ts +18 -18
  115. package/src/pipe/validate-search.pipe.ts +44 -44
  116. package/src/responses/deleted.response.ts +6 -6
  117. package/src/responses/pagination.response.ts +10 -10
  118. package/tsconfig.build.json +4 -4
  119. package/tsconfig.json +30 -30
@@ -1,15 +1,15 @@
1
- import { Injectable, PipeTransform } from '@nestjs/common';
2
- import * as cuid from 'cuid';
3
-
4
- @Injectable()
5
- export class AppendIdPipe implements PipeTransform {
6
- private readonly idName: string;
7
-
8
- constructor(idName: string) {
9
- this.idName = idName;
10
- }
11
-
12
- transform(value: any) {
13
- return { ...value, [this.idName]: cuid() };
14
- }
15
- }
1
+ import { Injectable, PipeTransform } from '@nestjs/common';
2
+ import * as cuid from 'cuid';
3
+
4
+ @Injectable()
5
+ export class AppendIdPipe implements PipeTransform {
6
+ private readonly idName: string;
7
+
8
+ constructor(idName: string) {
9
+ this.idName = idName;
10
+ }
11
+
12
+ transform(value: any) {
13
+ return { ...value, [this.idName]: cuid() };
14
+ }
15
+ }
@@ -1,31 +1,31 @@
1
- import { BadRequestException, PipeTransform } from '@nestjs/common';
2
- import { isDefined, isEnum } from 'class-validator';
3
-
4
- export class ValidateEnumPipe
5
- implements PipeTransform<string, Promise<any> | string | string[]>
6
- {
7
- constructor(private enumEntity: any) {}
8
-
9
- transform(value: string): Promise<any> | string | string[] {
10
- const validateEnum = (enumValue) => {
11
- if (isDefined(enumValue)) {
12
- if (isEnum(enumValue, this.enumEntity)) {
13
- return this.enumEntity[enumValue];
14
- } else {
15
- const errorMessage = `the value ${enumValue} is not valid. See the acceptable values: ${Object.keys(
16
- this.enumEntity,
17
- ).map((key) => this.enumEntity[key])}`;
18
- throw new BadRequestException(errorMessage);
19
- }
20
- } else {
21
- return value;
22
- }
23
- };
24
-
25
- if (Array.isArray(value)) {
26
- return value.map((item) => validateEnum(item));
27
- } else {
28
- return validateEnum(value);
29
- }
30
- }
31
- }
1
+ import { BadRequestException, PipeTransform } from '@nestjs/common';
2
+ import { isDefined, isEnum } from 'class-validator';
3
+
4
+ export class ValidateEnumPipe
5
+ implements PipeTransform<string, Promise<any> | string | string[]>
6
+ {
7
+ constructor(private enumEntity: any) {}
8
+
9
+ transform(value: string): Promise<any> | string | string[] {
10
+ const validateEnum = (enumValue) => {
11
+ if (isDefined(enumValue)) {
12
+ if (isEnum(enumValue, this.enumEntity)) {
13
+ return this.enumEntity[enumValue];
14
+ } else {
15
+ const errorMessage = `the value ${enumValue} is not valid. See the acceptable values: ${Object.keys(
16
+ this.enumEntity,
17
+ ).map((key) => this.enumEntity[key])}`;
18
+ throw new BadRequestException(errorMessage);
19
+ }
20
+ } else {
21
+ return value;
22
+ }
23
+ };
24
+
25
+ if (Array.isArray(value)) {
26
+ return value.map((item) => validateEnum(item));
27
+ } else {
28
+ return validateEnum(value);
29
+ }
30
+ }
31
+ }
@@ -1,18 +1,18 @@
1
- import { BadRequestException, Injectable, PipeTransform } from '@nestjs/common';
2
- import * as cuid from 'cuid';
3
-
4
- @Injectable()
5
- export class ValidateIdPipe implements PipeTransform {
6
- errorMessage: string;
7
-
8
- constructor(messageOverrides = 'Invalid id.') {
9
- this.errorMessage = messageOverrides;
10
- }
11
-
12
- transform(value: string) {
13
- if (value && !cuid.isCuid(value)) {
14
- throw new BadRequestException(this.errorMessage);
15
- }
16
- return value;
17
- }
18
- }
1
+ import { BadRequestException, Injectable, PipeTransform } from '@nestjs/common';
2
+ import * as cuid from 'cuid';
3
+
4
+ @Injectable()
5
+ export class ValidateIdPipe implements PipeTransform {
6
+ errorMessage: string;
7
+
8
+ constructor(messageOverrides = 'Invalid id.') {
9
+ this.errorMessage = messageOverrides;
10
+ }
11
+
12
+ transform(value: string) {
13
+ if (value && !cuid.isCuid(value)) {
14
+ throw new BadRequestException(this.errorMessage);
15
+ }
16
+ return value;
17
+ }
18
+ }
@@ -1,44 +1,44 @@
1
- import {
2
- BadRequestException,
3
- Injectable,
4
- // Logger,
5
- PipeTransform,
6
- } from '@nestjs/common';
7
-
8
- @Injectable()
9
- export class ValidateSearchPipe implements PipeTransform {
10
- constructor(
11
- private model: any,
12
- private additionalAttributes: string[] = [],
13
- ) {}
14
-
15
- transform(value: string) {
16
- let search = {};
17
-
18
- if (value) {
19
- try {
20
- search = JSON.parse(value);
21
- } catch (err) {
22
- throw new BadRequestException('Bad value for search.');
23
- }
24
- const attributes: string[] = [
25
- ...this.additionalAttributes,
26
- ...Object.keys(this.model.tableAttributes),
27
- ];
28
- const searchAttributes: string[] = Object.keys(search);
29
- const invalidKeys = searchAttributes.filter(
30
- (attr) => !attributes.includes(attr),
31
- );
32
-
33
- if (invalidKeys.length > 0) {
34
- throw new BadRequestException(
35
- `${invalidKeys} ${
36
- invalidKeys.length > 1 ? 'are invalid keys' : 'is an invalid key'
37
- } for search query`,
38
- );
39
- }
40
- }
41
-
42
- return value;
43
- }
44
- }
1
+ import {
2
+ BadRequestException,
3
+ Injectable,
4
+ // Logger,
5
+ PipeTransform,
6
+ } from '@nestjs/common';
7
+
8
+ @Injectable()
9
+ export class ValidateSearchPipe implements PipeTransform {
10
+ constructor(
11
+ private model: any,
12
+ private additionalAttributes: string[] = [],
13
+ ) {}
14
+
15
+ transform(value: string) {
16
+ let search = {};
17
+
18
+ if (value) {
19
+ try {
20
+ search = JSON.parse(value);
21
+ } catch (err) {
22
+ throw new BadRequestException('Bad value for search.');
23
+ }
24
+ const attributes: string[] = [
25
+ ...this.additionalAttributes,
26
+ ...Object.keys(this.model.tableAttributes),
27
+ ];
28
+ const searchAttributes: string[] = Object.keys(search);
29
+ const invalidKeys = searchAttributes.filter(
30
+ (attr) => !attributes.includes(attr),
31
+ );
32
+
33
+ if (invalidKeys.length > 0) {
34
+ throw new BadRequestException(
35
+ `${invalidKeys} ${
36
+ invalidKeys.length > 1 ? 'are invalid keys' : 'is an invalid key'
37
+ } for search query`,
38
+ );
39
+ }
40
+ }
41
+
42
+ return value;
43
+ }
44
+ }
@@ -1,6 +1,6 @@
1
- import { ApiProperty } from '@nestjs/swagger';
2
-
3
- export class DeletedMediasResponse {
4
- @ApiProperty({ example: 'EzCash slot group has been deleted.' })
5
- message: string;
6
- }
1
+ import { ApiProperty } from '@nestjs/swagger';
2
+
3
+ export class DeletedMediasResponse {
4
+ @ApiProperty({ example: 'EzCash slot group has been deleted.' })
5
+ message: string;
6
+ }
@@ -1,10 +1,10 @@
1
- import { ApiProperty } from '@nestjs/swagger';
2
- import { MediasModel } from '../entities/medias.entity';
3
-
4
- export class PaginatedMediasResponse {
5
- @ApiProperty()
6
- count: number;
7
-
8
- @ApiProperty({ isArray: true, type: MediasModel })
9
- rows: MediasModel[];
10
- }
1
+ import { ApiProperty } from '@nestjs/swagger';
2
+ import { MediasModel } from '../entities/medias.entity';
3
+
4
+ export class PaginatedMediasResponse {
5
+ @ApiProperty()
6
+ count: number;
7
+
8
+ @ApiProperty({ isArray: true, type: MediasModel })
9
+ rows: MediasModel[];
10
+ }
@@ -1,4 +1,4 @@
1
- {
2
- "extends": "./tsconfig.json",
3
- "exclude": ["node_modules", "test", "dist", "**/*spec.ts"]
4
- }
1
+ {
2
+ "extends": "./tsconfig.json",
3
+ "exclude": ["node_modules", "test", "dist", "**/*spec.ts"]
4
+ }
package/tsconfig.json CHANGED
@@ -1,31 +1,31 @@
1
- {
2
- "compilerOptions": {
3
- "module": "commonjs",
4
- "declaration": true,
5
- "removeComments": true,
6
- "emitDecoratorMetadata": true,
7
- "experimentalDecorators": true,
8
- "allowSyntheticDefaultImports": true,
9
- "moduleResolution": "node",
10
- "target": "es2017",
11
- "sourceMap": true,
12
- "outDir": "./dist",
13
- "baseUrl": "./",
14
- "incremental": true,
15
- "skipLibCheck": true,
16
- "strictNullChecks": false,
17
- "noImplicitAny": false,
18
- "strictBindCallApply": false,
19
- "forceConsistentCasingInFileNames": false,
20
- "noFallthroughCasesInSwitch": false,
21
- "paths": {
22
- "@app/media": [
23
- "libs/media/src"
24
- ],
25
- "@app/media/*": [
26
- "libs/media/src/*"
27
- ]
28
- }
29
- },
30
- "exclude": ["node_modules", "dist"]
1
+ {
2
+ "compilerOptions": {
3
+ "module": "commonjs",
4
+ "declaration": true,
5
+ "removeComments": true,
6
+ "emitDecoratorMetadata": true,
7
+ "experimentalDecorators": true,
8
+ "allowSyntheticDefaultImports": true,
9
+ "moduleResolution": "node",
10
+ "target": "es2017",
11
+ "sourceMap": true,
12
+ "outDir": "./dist",
13
+ "baseUrl": "./",
14
+ "incremental": true,
15
+ "skipLibCheck": true,
16
+ "strictNullChecks": false,
17
+ "noImplicitAny": false,
18
+ "strictBindCallApply": false,
19
+ "forceConsistentCasingInFileNames": false,
20
+ "noFallthroughCasesInSwitch": false,
21
+ "paths": {
22
+ "@app/media": [
23
+ "libs/media/src"
24
+ ],
25
+ "@app/media/*": [
26
+ "libs/media/src/*"
27
+ ]
28
+ }
29
+ },
30
+ "exclude": ["node_modules", "dist"]
31
31
  }