@tomei/media 0.8.8 → 0.8.9

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 (106) hide show
  1. package/package.json +1 -1
  2. package/src/base/base.medias.ts +210 -210
  3. package/src/base/base.repository.abstract.ts +28 -28
  4. package/src/base/base.repository.interface.ts +9 -9
  5. package/src/common/common.module.ts +10 -10
  6. package/src/common/common.service.ts +107 -107
  7. package/src/common/dto/add-field-translation.dto.ts +23 -23
  8. package/src/common/dto/get-media.dto.ts +12 -12
  9. package/src/database.ts +16 -16
  10. package/src/dto/external-media.dto.ts +49 -49
  11. package/src/dto/internal-medias.dto.ts +64 -64
  12. package/src/entities/medias.entity.ts +125 -125
  13. package/src/enum/index.ts +3 -3
  14. package/src/enum/medias.enum.ts +5 -5
  15. package/src/helpers/error.ts +12 -12
  16. package/src/helpers/index.ts +3 -3
  17. package/src/index.ts +24 -24
  18. package/src/interfaces/base.medias-attr.interface.ts +21 -21
  19. package/src/interfaces/medias.repository.interface.ts +4 -4
  20. package/src/medias.repository.ts +55 -55
  21. package/src/medias.ts +769 -769
  22. package/src/pipe/append-id.pipe.ts +15 -15
  23. package/src/pipe/validate-enum.pipe.ts +31 -31
  24. package/src/pipe/validate-id.pipe.ts +18 -18
  25. package/src/pipe/validate-search.pipe.ts +44 -44
  26. package/src/responses/deleted.response.ts +6 -6
  27. package/src/responses/pagination.response.ts +10 -10
  28. package/dist/base/base.medias.d.ts +0 -38
  29. package/dist/base/base.medias.js +0 -175
  30. package/dist/base/base.medias.js.map +0 -1
  31. package/dist/base/base.repository.abstract.d.ts +0 -12
  32. package/dist/base/base.repository.abstract.js +0 -22
  33. package/dist/base/base.repository.abstract.js.map +0 -1
  34. package/dist/base/base.repository.interface.d.ts +0 -9
  35. package/dist/base/base.repository.interface.js +0 -3
  36. package/dist/base/base.repository.interface.js.map +0 -1
  37. package/dist/common/common.module.d.ts +0 -2
  38. package/dist/common/common.module.js +0 -23
  39. package/dist/common/common.module.js.map +0 -1
  40. package/dist/common/common.service.d.ts +0 -13
  41. package/dist/common/common.service.js +0 -106
  42. package/dist/common/common.service.js.map +0 -1
  43. package/dist/common/dto/add-field-translation.dto.d.ts +0 -7
  44. package/dist/common/dto/add-field-translation.dto.js +0 -42
  45. package/dist/common/dto/add-field-translation.dto.js.map +0 -1
  46. package/dist/common/dto/get-media.dto.d.ts +0 -5
  47. package/dist/common/dto/get-media.dto.js +0 -29
  48. package/dist/common/dto/get-media.dto.js.map +0 -1
  49. package/dist/database.d.ts +0 -4
  50. package/dist/database.js +0 -16
  51. package/dist/database.js.map +0 -1
  52. package/dist/dto/external-media.dto.d.ts +0 -10
  53. package/dist/dto/external-media.dto.js +0 -70
  54. package/dist/dto/external-media.dto.js.map +0 -1
  55. package/dist/dto/internal-medias.dto.d.ts +0 -12
  56. package/dist/dto/internal-medias.dto.js +0 -87
  57. package/dist/dto/internal-medias.dto.js.map +0 -1
  58. package/dist/entities/medias.entity.d.ts +0 -23
  59. package/dist/entities/medias.entity.js +0 -160
  60. package/dist/entities/medias.entity.js.map +0 -1
  61. package/dist/enum/index.d.ts +0 -2
  62. package/dist/enum/index.js +0 -6
  63. package/dist/enum/index.js.map +0 -1
  64. package/dist/enum/medias.enum.d.ts +0 -5
  65. package/dist/enum/medias.enum.js +0 -10
  66. package/dist/enum/medias.enum.js.map +0 -1
  67. package/dist/helpers/error.d.ts +0 -1
  68. package/dist/helpers/error.js +0 -13
  69. package/dist/helpers/error.js.map +0 -1
  70. package/dist/helpers/index.d.ts +0 -2
  71. package/dist/helpers/index.js +0 -6
  72. package/dist/helpers/index.js.map +0 -1
  73. package/dist/index.d.ts +0 -12
  74. package/dist/index.js +0 -22
  75. package/dist/index.js.map +0 -1
  76. package/dist/interfaces/base.medias-attr.interface.d.ts +0 -20
  77. package/dist/interfaces/base.medias-attr.interface.js +0 -3
  78. package/dist/interfaces/base.medias-attr.interface.js.map +0 -1
  79. package/dist/interfaces/medias.repository.interface.d.ts +0 -3
  80. package/dist/interfaces/medias.repository.interface.js +0 -3
  81. package/dist/interfaces/medias.repository.interface.js.map +0 -1
  82. package/dist/medias.d.ts +0 -65
  83. package/dist/medias.js +0 -564
  84. package/dist/medias.js.map +0 -1
  85. package/dist/medias.repository.d.ts +0 -8
  86. package/dist/medias.repository.js +0 -56
  87. package/dist/medias.repository.js.map +0 -1
  88. package/dist/pipe/append-id.pipe.d.ts +0 -6
  89. package/dist/pipe/append-id.pipe.js +0 -28
  90. package/dist/pipe/append-id.pipe.js.map +0 -1
  91. package/dist/pipe/validate-enum.pipe.d.ts +0 -6
  92. package/dist/pipe/validate-enum.pipe.js +0 -34
  93. package/dist/pipe/validate-enum.pipe.js.map +0 -1
  94. package/dist/pipe/validate-id.pipe.d.ts +0 -6
  95. package/dist/pipe/validate-id.pipe.js +0 -31
  96. package/dist/pipe/validate-id.pipe.js.map +0 -1
  97. package/dist/pipe/validate-search.pipe.d.ts +0 -7
  98. package/dist/pipe/validate-search.pipe.js +0 -46
  99. package/dist/pipe/validate-search.pipe.js.map +0 -1
  100. package/dist/responses/deleted.response.d.ts +0 -3
  101. package/dist/responses/deleted.response.js +0 -21
  102. package/dist/responses/deleted.response.js.map +0 -1
  103. package/dist/responses/pagination.response.d.ts +0 -5
  104. package/dist/responses/pagination.response.js +0 -26
  105. package/dist/responses/pagination.response.js.map +0 -1
  106. package/dist/tsconfig.tsbuildinfo +0 -1
@@ -1,125 +1,125 @@
1
- import { ApiProperty } from '@nestjs/swagger';
2
- import { Column, Model, Table, DataType } from 'sequelize-typescript';
3
- import { MediaType } from '../enum';
4
-
5
- @Table({ tableName: 'common_Media', createdAt: false, updatedAt: false })
6
- export class MediasModel extends Model {
7
- @Column({
8
- primaryKey: true,
9
- allowNull: false,
10
- })
11
- @ApiProperty({ type: String, description: 'MediaID' })
12
- MediaId: string;
13
-
14
- @Column({
15
- allowNull: false,
16
- })
17
- @ApiProperty({ type: String, description: 'ObjectID' })
18
- ObjectId: string;
19
-
20
- @Column({
21
- allowNull: false,
22
- })
23
- @ApiProperty({ type: String, description: 'ObjectType' })
24
- ObjectType: string;
25
-
26
- @Column({
27
- allowNull: true,
28
- })
29
- @ApiProperty({ type: String, description: 'title of the media' })
30
- Title: string;
31
-
32
- @Column({
33
- allowNull: true,
34
- })
35
- @ApiProperty({ type: String, description: 'Description of the media' })
36
- Description: string;
37
-
38
- @Column({
39
- allowNull: false,
40
- })
41
- @ApiProperty({
42
- type: String,
43
- description: 'Enum either Photo, Video, Document',
44
- })
45
- Type: MediaType;
46
-
47
- @Column({
48
- allowNull: false,
49
- })
50
- @ApiProperty({ type: String, description: 'isExternal either Y, N' })
51
- IsExternalYN: string;
52
-
53
- @Column({
54
- allowNull: true,
55
- })
56
- @ApiProperty({ type: String, description: 'External surce for the file' })
57
- ExternalSource: string;
58
-
59
- @Column({
60
- allowNull: false,
61
- })
62
- @ApiProperty({ type: String, description: 'isExternal either Y, N' })
63
- IsEncryptedYN: string;
64
-
65
- @Column({
66
- allowNull: true,
67
- })
68
- @ApiProperty({ type: String, description: 'file name without extension' })
69
- FileName: string;
70
-
71
- @Column({
72
- allowNull: true,
73
- })
74
- @ApiProperty({ type: String, description: 'extention of file in jpg etc' })
75
- FileExtension: string;
76
-
77
- @Column({
78
- allowNull: true,
79
- })
80
- @ApiProperty({
81
- type: String,
82
- description: 'location on the media in term of path',
83
- })
84
- FilePath: string;
85
-
86
- @Column({
87
- allowNull: true,
88
- })
89
- @ApiProperty({ type: String, description: 'URl of the media' })
90
- URL: string;
91
-
92
- @ApiProperty({
93
- example: new Date(),
94
- description: 'Timestamp for data creation.',
95
- })
96
- @Column({ type: DataType.DATE, allowNull: false })
97
- CreatedAt: Date;
98
-
99
- @ApiProperty({
100
- example: '138140891dd211b288d34bc7b4312a49',
101
- description: 'The CreatedById for Media.',
102
- })
103
- @Column({ allowNull: false })
104
- CreatedById: string;
105
-
106
- @ApiProperty({
107
- example: new Date(),
108
- description: 'Timestamp for latest data modification',
109
- })
110
- @Column({ type: DataType.DATE, allowNull: true })
111
- UpdatedAt: Date;
112
-
113
- @ApiProperty({
114
- example: '138140891dd211b288d34bc7b4312a49',
115
- description: 'The UpdatedById for Media.',
116
- })
117
- @Column({ allowNull: false })
118
- UpdatedById: string;
119
-
120
- @Column({ allowNull: true })
121
- HiddenYN: string;
122
-
123
- @Column({ allowNull: true })
124
- DefaultYN: string;
125
- }
1
+ import { ApiProperty } from '@nestjs/swagger';
2
+ import { Column, Model, Table, DataType } from 'sequelize-typescript';
3
+ import { MediaType } from '../enum';
4
+
5
+ @Table({ tableName: 'common_Media', createdAt: false, updatedAt: false })
6
+ export class MediasModel extends Model {
7
+ @Column({
8
+ primaryKey: true,
9
+ allowNull: false,
10
+ })
11
+ @ApiProperty({ type: String, description: 'MediaID' })
12
+ MediaId: string;
13
+
14
+ @Column({
15
+ allowNull: false,
16
+ })
17
+ @ApiProperty({ type: String, description: 'ObjectID' })
18
+ ObjectId: string;
19
+
20
+ @Column({
21
+ allowNull: false,
22
+ })
23
+ @ApiProperty({ type: String, description: 'ObjectType' })
24
+ ObjectType: string;
25
+
26
+ @Column({
27
+ allowNull: true,
28
+ })
29
+ @ApiProperty({ type: String, description: 'title of the media' })
30
+ Title: string;
31
+
32
+ @Column({
33
+ allowNull: true,
34
+ })
35
+ @ApiProperty({ type: String, description: 'Description of the media' })
36
+ Description: string;
37
+
38
+ @Column({
39
+ allowNull: false,
40
+ })
41
+ @ApiProperty({
42
+ type: String,
43
+ description: 'Enum either Photo, Video, Document',
44
+ })
45
+ Type: MediaType;
46
+
47
+ @Column({
48
+ allowNull: false,
49
+ })
50
+ @ApiProperty({ type: String, description: 'isExternal either Y, N' })
51
+ IsExternalYN: string;
52
+
53
+ @Column({
54
+ allowNull: true,
55
+ })
56
+ @ApiProperty({ type: String, description: 'External surce for the file' })
57
+ ExternalSource: string;
58
+
59
+ @Column({
60
+ allowNull: false,
61
+ })
62
+ @ApiProperty({ type: String, description: 'isExternal either Y, N' })
63
+ IsEncryptedYN: string;
64
+
65
+ @Column({
66
+ allowNull: true,
67
+ })
68
+ @ApiProperty({ type: String, description: 'file name without extension' })
69
+ FileName: string;
70
+
71
+ @Column({
72
+ allowNull: true,
73
+ })
74
+ @ApiProperty({ type: String, description: 'extention of file in jpg etc' })
75
+ FileExtension: string;
76
+
77
+ @Column({
78
+ allowNull: true,
79
+ })
80
+ @ApiProperty({
81
+ type: String,
82
+ description: 'location on the media in term of path',
83
+ })
84
+ FilePath: string;
85
+
86
+ @Column({
87
+ allowNull: true,
88
+ })
89
+ @ApiProperty({ type: String, description: 'URl of the media' })
90
+ URL: string;
91
+
92
+ @ApiProperty({
93
+ example: new Date(),
94
+ description: 'Timestamp for data creation.',
95
+ })
96
+ @Column({ type: DataType.DATE, allowNull: false })
97
+ CreatedAt: Date;
98
+
99
+ @ApiProperty({
100
+ example: '138140891dd211b288d34bc7b4312a49',
101
+ description: 'The CreatedById for Media.',
102
+ })
103
+ @Column({ allowNull: false })
104
+ CreatedById: string;
105
+
106
+ @ApiProperty({
107
+ example: new Date(),
108
+ description: 'Timestamp for latest data modification',
109
+ })
110
+ @Column({ type: DataType.DATE, allowNull: true })
111
+ UpdatedAt: Date;
112
+
113
+ @ApiProperty({
114
+ example: '138140891dd211b288d34bc7b4312a49',
115
+ description: 'The UpdatedById for Media.',
116
+ })
117
+ @Column({ allowNull: false })
118
+ UpdatedById: string;
119
+
120
+ @Column({ allowNull: true })
121
+ HiddenYN: string;
122
+
123
+ @Column({ allowNull: true })
124
+ DefaultYN: string;
125
+ }
package/src/enum/index.ts CHANGED
@@ -1,3 +1,3 @@
1
- import { MediaType } from './medias.enum';
2
-
3
- export { MediaType };
1
+ import { MediaType } from './medias.enum';
2
+
3
+ export { MediaType };
@@ -1,5 +1,5 @@
1
- export enum MediaType {
2
- Photo = 'Photo',
3
- Video = 'Video',
4
- Document = 'Document',
5
- }
1
+ export enum MediaType {
2
+ Photo = 'Photo',
3
+ Video = 'Video',
4
+ Document = 'Document',
5
+ }
@@ -1,12 +1,12 @@
1
- import { HttpException } from '@nestjs/common';
2
-
3
- export function throwException(err) {
4
- if (err.response) {
5
- throw err;
6
- } else {
7
- throw new HttpException(
8
- 'Something went wrong. Please see application log.',
9
- err.statusCode,
10
- );
11
- }
12
- }
1
+ import { HttpException } from '@nestjs/common';
2
+
3
+ export function throwException(err) {
4
+ if (err.response) {
5
+ throw err;
6
+ } else {
7
+ throw new HttpException(
8
+ 'Something went wrong. Please see application log.',
9
+ err.statusCode,
10
+ );
11
+ }
12
+ }
@@ -1,3 +1,3 @@
1
- import { throwException } from './error';
2
-
3
- export { throwException };
1
+ import { throwException } from './error';
2
+
3
+ export { throwException };
package/src/index.ts CHANGED
@@ -1,24 +1,24 @@
1
- import { MediasRepository } from './medias.repository';
2
- import { MediasModel } from './entities/medias.entity';
3
- import { Medias } from './medias';
4
- import { CommonModule } from './common/common.module';
5
- import { CommonService } from './common/common.service';
6
- import { ExternalMediaDto } from './dto/external-media.dto';
7
- import { InternalMediaDto } from './dto/internal-medias.dto';
8
- import { MediaType } from './enum';
9
- import { IBaseMediasAttr } from './interfaces/base.medias-attr.interface';
10
- import { IMediasRepository } from './interfaces/medias.repository.interface';
11
- import * as MediaDb from './database';
12
- export {
13
- MediasRepository,
14
- MediasModel,
15
- Medias,
16
- CommonModule,
17
- CommonService,
18
- ExternalMediaDto,
19
- InternalMediaDto,
20
- MediaType,
21
- IBaseMediasAttr,
22
- IMediasRepository,
23
- MediaDb,
24
- };
1
+ import { MediasRepository } from './medias.repository';
2
+ import { MediasModel } from './entities/medias.entity';
3
+ import { Medias } from './medias';
4
+ import { CommonModule } from './common/common.module';
5
+ import { CommonService } from './common/common.service';
6
+ import { ExternalMediaDto } from './dto/external-media.dto';
7
+ import { InternalMediaDto } from './dto/internal-medias.dto';
8
+ import { MediaType } from './enum';
9
+ import { IBaseMediasAttr } from './interfaces/base.medias-attr.interface';
10
+ import { IMediasRepository } from './interfaces/medias.repository.interface';
11
+ import * as MediaDb from './database';
12
+ export {
13
+ MediasRepository,
14
+ MediasModel,
15
+ Medias,
16
+ CommonModule,
17
+ CommonService,
18
+ ExternalMediaDto,
19
+ InternalMediaDto,
20
+ MediaType,
21
+ IBaseMediasAttr,
22
+ IMediasRepository,
23
+ MediaDb,
24
+ };
@@ -1,21 +1,21 @@
1
- import { MediaType } from '../enum/medias.enum';
2
-
3
- export interface IBaseMediasAttr {
4
- MediaId: string;
5
- ObjectId: string;
6
- ObjectType: string;
7
- Title: string;
8
- Description: string;
9
- Type: MediaType;
10
- IsExternalYN: string;
11
- ExternalSource: string;
12
- IsEncryptedYN: string;
13
- FileName: string;
14
- FileExtension: string;
15
- FilePath: string;
16
- URL: string;
17
- CreatedAt: Date;
18
- UpdatedAt: Date;
19
- CreatedById: string;
20
- UpdatedById: string;
21
- }
1
+ import { MediaType } from '../enum/medias.enum';
2
+
3
+ export interface IBaseMediasAttr {
4
+ MediaId: string;
5
+ ObjectId: string;
6
+ ObjectType: string;
7
+ Title: string;
8
+ Description: string;
9
+ Type: MediaType;
10
+ IsExternalYN: string;
11
+ ExternalSource: string;
12
+ IsEncryptedYN: string;
13
+ FileName: string;
14
+ FileExtension: string;
15
+ FilePath: string;
16
+ URL: string;
17
+ CreatedAt: Date;
18
+ UpdatedAt: Date;
19
+ CreatedById: string;
20
+ UpdatedById: string;
21
+ }
@@ -1,4 +1,4 @@
1
- import { IBaseRepository } from '../base/base.repository.interface';
2
- import { MediasModel } from '../entities/medias.entity';
3
-
4
- export type IMediasRepository = IBaseRepository<MediasModel>;
1
+ import { IBaseRepository } from '../base/base.repository.interface';
2
+ import { MediasModel } from '../entities/medias.entity';
3
+
4
+ export type IMediasRepository = IBaseRepository<MediasModel>;
@@ -1,55 +1,55 @@
1
- import { MediasModel } from './entities/medias.entity';
2
-
3
- import { RepositoryBase, IRepositoryBase } from '@tomei/general';
4
-
5
- export class MediasRepository
6
- extends RepositoryBase<MediasModel>
7
- implements IRepositoryBase<MediasModel>
8
- {
9
- constructor() {
10
- super(MediasModel);
11
- }
12
-
13
- async findByPk(MediaId: string, transaction: any): Promise<MediasModel> {
14
- try {
15
- const options = {
16
- where: {
17
- MediaId,
18
- },
19
- transaction,
20
- };
21
- const result = await MediasModel.findOne(options);
22
- return result;
23
- } catch (error) {
24
- throw new Error(`An Error occured when fetching : ${error.message}`);
25
- }
26
- }
27
-
28
- async delete(MediaId: string, dbTransaction?: any) {
29
- try {
30
- const options = {
31
- where: {
32
- MediaId,
33
- },
34
- transaction: dbTransaction,
35
- };
36
- await MediasModel.destroy(options);
37
- } catch (error) {
38
- throw new Error(`An Error occured when delete : ${error.message}`);
39
- }
40
- }
41
-
42
- async findAndCountAll(options?: any) {
43
- try {
44
- let medias: any;
45
- if (options) {
46
- medias = await MediasModel.findAndCountAll(options);
47
- } else {
48
- medias = await MediasModel.findAndCountAll();
49
- }
50
- return medias;
51
- } catch (error) {
52
- throw new Error(`An Error occured when retriving : ${error.message}`);
53
- }
54
- }
55
- }
1
+ import { MediasModel } from './entities/medias.entity';
2
+
3
+ import { RepositoryBase, IRepositoryBase } from '@tomei/general';
4
+
5
+ export class MediasRepository
6
+ extends RepositoryBase<MediasModel>
7
+ implements IRepositoryBase<MediasModel>
8
+ {
9
+ constructor() {
10
+ super(MediasModel);
11
+ }
12
+
13
+ async findByPk(MediaId: string, transaction: any): Promise<MediasModel> {
14
+ try {
15
+ const options = {
16
+ where: {
17
+ MediaId,
18
+ },
19
+ transaction,
20
+ };
21
+ const result = await MediasModel.findOne(options);
22
+ return result;
23
+ } catch (error) {
24
+ throw new Error(`An Error occured when fetching : ${error.message}`);
25
+ }
26
+ }
27
+
28
+ async delete(MediaId: string, dbTransaction?: any) {
29
+ try {
30
+ const options = {
31
+ where: {
32
+ MediaId,
33
+ },
34
+ transaction: dbTransaction,
35
+ };
36
+ await MediasModel.destroy(options);
37
+ } catch (error) {
38
+ throw new Error(`An Error occured when delete : ${error.message}`);
39
+ }
40
+ }
41
+
42
+ async findAndCountAll(options?: any) {
43
+ try {
44
+ let medias: any;
45
+ if (options) {
46
+ medias = await MediasModel.findAndCountAll(options);
47
+ } else {
48
+ medias = await MediasModel.findAndCountAll();
49
+ }
50
+ return medias;
51
+ } catch (error) {
52
+ throw new Error(`An Error occured when retriving : ${error.message}`);
53
+ }
54
+ }
55
+ }