@tomei/media 0.8.10 → 0.10.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.
- package/.commitlintrc.json +22 -22
- package/.gitlab-ci.yml +16 -16
- package/.husky/commit-msg +15 -15
- package/.husky/pre-commit +7 -7
- package/.prettierrc +4 -4
- package/README.md +93 -93
- package/dist/base/base.medias.js +2 -2
- package/dist/base/base.medias.js.map +1 -1
- package/dist/common/common.service.js +2 -2
- package/dist/common/common.service.js.map +1 -1
- package/dist/medias.js +8 -8
- package/dist/medias.js.map +1 -1
- package/dist/medias.repository.js.map +1 -1
- package/dist/pipe/append-id.pipe.js +2 -2
- package/dist/pipe/append-id.pipe.js.map +1 -1
- package/dist/pipe/validate-id.pipe.js +2 -2
- package/dist/pipe/validate-id.pipe.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/eslint.config.mjs +58 -58
- package/migration/0001-add-defaultyn-hiddenyn-to-media-table.js +36 -36
- package/migration/media-migration.js +82 -82
- package/nest-cli.json +18 -18
- package/package.json +78 -79
- package/sonar-project.properties +12 -12
- package/src/base/base.medias.ts +2 -2
- package/src/common/common.service.ts +2 -2
- package/src/medias.repository.ts +9 -3
- package/src/medias.ts +8 -8
- package/src/pipe/append-id.pipe.ts +2 -2
- package/src/pipe/validate-id.pipe.ts +2 -2
- package/tsconfig.build.json +4 -4
- package/tsconfig.json +30 -30
package/src/medias.ts
CHANGED
|
@@ -10,7 +10,7 @@ import { IBaseMediasAttr } from './interfaces/base.medias-attr.interface';
|
|
|
10
10
|
import { Readable } from 'stream';
|
|
11
11
|
import { InternalMediaDto } from './dto/internal-medias.dto';
|
|
12
12
|
import { ExternalMediaDto } from './dto/external-media.dto';
|
|
13
|
-
import
|
|
13
|
+
import { createId } from '@paralleldrive/cuid2';
|
|
14
14
|
import { Op } from 'sequelize';
|
|
15
15
|
import { ActionEnum, Activity } from '@tomei/activity-history';
|
|
16
16
|
import { MediasRepository } from './medias.repository';
|
|
@@ -74,7 +74,7 @@ export class Medias extends BaseMedias {
|
|
|
74
74
|
|
|
75
75
|
if (media) {
|
|
76
76
|
const activity = new Activity();
|
|
77
|
-
activity.ActivityId =
|
|
77
|
+
activity.ActivityId = createId();
|
|
78
78
|
activity.Action = ActionEnum.CREATE;
|
|
79
79
|
activity.Description = 'Add New Media';
|
|
80
80
|
activity.EntityType = 'Media';
|
|
@@ -113,7 +113,7 @@ export class Medias extends BaseMedias {
|
|
|
113
113
|
}
|
|
114
114
|
if (media) {
|
|
115
115
|
const activity = new Activity();
|
|
116
|
-
activity.ActivityId =
|
|
116
|
+
activity.ActivityId = createId();
|
|
117
117
|
activity.Action = ActionEnum.UPDATE;
|
|
118
118
|
activity.Description = 'Update Media';
|
|
119
119
|
activity.EntityType = 'Media';
|
|
@@ -382,7 +382,7 @@ export class Medias extends BaseMedias {
|
|
|
382
382
|
try {
|
|
383
383
|
fileBuffer = await this.getFileFromLocal(this.FilePath);
|
|
384
384
|
} catch (error) {
|
|
385
|
-
if (error.includes('ENOENT')) {
|
|
385
|
+
if (error instanceof Error && error.message.includes('ENOENT')) {
|
|
386
386
|
console.warn(
|
|
387
387
|
`Local file missing: ${this.FilePath}, fetching from Azure.`,
|
|
388
388
|
);
|
|
@@ -421,7 +421,7 @@ export class Medias extends BaseMedias {
|
|
|
421
421
|
file.iv = await this.getFileFromLocal(this.getIvPath());
|
|
422
422
|
}
|
|
423
423
|
} catch (error) {
|
|
424
|
-
if (error.includes('ENOENT')) {
|
|
424
|
+
if (error instanceof Error && error.message.includes('ENOENT')) {
|
|
425
425
|
console.warn(
|
|
426
426
|
`IV file missing: ${this.getIvPath()}, fetching from Azure.`,
|
|
427
427
|
);
|
|
@@ -551,7 +551,7 @@ export class Medias extends BaseMedias {
|
|
|
551
551
|
}
|
|
552
552
|
}
|
|
553
553
|
const activity = new Activity();
|
|
554
|
-
activity.ActivityId =
|
|
554
|
+
activity.ActivityId = createId();
|
|
555
555
|
activity.Action = ActionEnum.DELETE;
|
|
556
556
|
activity.Description = 'Deleted media (ID: ${this.MediaId})';
|
|
557
557
|
activity.EntityType = 'Media';
|
|
@@ -574,7 +574,7 @@ export class Medias extends BaseMedias {
|
|
|
574
574
|
try {
|
|
575
575
|
const mediaAttr: IBaseMediasAttr = {
|
|
576
576
|
...createMediaDto,
|
|
577
|
-
MediaId:
|
|
577
|
+
MediaId: createId(),
|
|
578
578
|
IsExternalYN: 'N',
|
|
579
579
|
ExternalSource: '',
|
|
580
580
|
URL: '',
|
|
@@ -601,7 +601,7 @@ export class Medias extends BaseMedias {
|
|
|
601
601
|
async postExternal(createMediaDto: ExternalMediaDto, loginUser: LoginUser) {
|
|
602
602
|
const mediaAttr: IBaseMediasAttr = {
|
|
603
603
|
...createMediaDto,
|
|
604
|
-
MediaId:
|
|
604
|
+
MediaId: createId(),
|
|
605
605
|
IsExternalYN: 'Y',
|
|
606
606
|
CreatedAt: new Date(),
|
|
607
607
|
UpdatedAt: new Date(),
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Injectable, PipeTransform } from '@nestjs/common';
|
|
2
|
-
import
|
|
2
|
+
import { createId } from '@paralleldrive/cuid2';
|
|
3
3
|
|
|
4
4
|
@Injectable()
|
|
5
5
|
export class AppendIdPipe implements PipeTransform {
|
|
@@ -10,6 +10,6 @@ export class AppendIdPipe implements PipeTransform {
|
|
|
10
10
|
}
|
|
11
11
|
|
|
12
12
|
transform(value: any) {
|
|
13
|
-
return { ...value, [this.idName]:
|
|
13
|
+
return { ...value, [this.idName]: createId() };
|
|
14
14
|
}
|
|
15
15
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { BadRequestException, Injectable, PipeTransform } from '@nestjs/common';
|
|
2
|
-
import
|
|
2
|
+
import { isCuid } from '@paralleldrive/cuid2';
|
|
3
3
|
|
|
4
4
|
@Injectable()
|
|
5
5
|
export class ValidateIdPipe implements PipeTransform {
|
|
@@ -10,7 +10,7 @@ export class ValidateIdPipe implements PipeTransform {
|
|
|
10
10
|
}
|
|
11
11
|
|
|
12
12
|
transform(value: string) {
|
|
13
|
-
if (value && !
|
|
13
|
+
if (value && !isCuid(value)) {
|
|
14
14
|
throw new BadRequestException(this.errorMessage);
|
|
15
15
|
}
|
|
16
16
|
return value;
|
package/tsconfig.build.json
CHANGED
|
@@ -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
|
}
|