@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/eslint.config.mjs CHANGED
@@ -1,58 +1,58 @@
1
- import eslintPlugin from "@typescript-eslint/eslint-plugin";
2
- import parser from "@typescript-eslint/parser";
3
- import importPlugin from 'eslint-plugin-import'
4
- import path from 'path';
5
- import { fileURLToPath } from 'url';
6
-
7
- const __filename = fileURLToPath(import.meta.url);
8
- const __dirname = path.dirname(__filename);
9
-
10
- export default [
11
- {
12
- languageOptions: {
13
- parser: parser,
14
- ecmaVersion: "latest", // Allows modern ECMAScript features
15
- sourceType: "module", // Allows for the use of imports
16
- parserOptions: {
17
- tsconfigRootDir: __dirname,
18
- project: './tsconfig.json'
19
- },
20
- },
21
- plugins: {
22
- "@typescript-eslint": eslintPlugin,
23
- import: importPlugin
24
- },
25
- rules: {
26
- "no-console": "off",
27
- "@typescript-eslint/no-explicit-any": "off",
28
- "@typescript-eslint/no-var-requires": "off",
29
- "@typescript-eslint/explicit-module-boundary-types": "off",
30
- "import/prefer-default-export": "off",
31
- "@typescript-eslint/no-unused-vars": "warn",
32
- "no-useless-catch": "off",
33
- "@typescript-eslint/no-non-null-assertion": "off",
34
- "@typescript-eslint/no-empty-function": "off",
35
- "@typescript-eslint/no-empty-interface": "off",
36
- "@typescript-eslint/no-inferrable-types": "off",
37
- "@typescript-eslint/no-namespace": "off",
38
- "@typescript-eslint/no-use-before-define": "off",
39
- "@typescript-eslint/no-unsafe-assignment": "off",
40
- "@typescript-eslint/no-unsafe-call": "off",
41
- "@typescript-eslint/no-unsafe-member-access": "off",
42
- "@typescript-eslint/no-unsafe-return": "off",
43
- "@typescript-eslint/restrict-template-expressions": "off",
44
- "no-useless-escape": "off",
45
- "import/no-relative-parent-imports": "error", // Enforce relative imports only
46
- "import/no-absolute-path": "error", // Block absolute imports outside aliases
47
- "import/no-unresolved": ["error", { commonjs: true }],
48
- },
49
- settings: {
50
- "import/resolver": {
51
- typescript: {
52
- alwaysTryTypes: true,
53
- }
54
- }
55
- },
56
- ignores: ["node_modules", "dist/**/*", "eslint.config.mjs"],
57
- },
58
- ];
1
+ import eslintPlugin from "@typescript-eslint/eslint-plugin";
2
+ import parser from "@typescript-eslint/parser";
3
+ import importPlugin from 'eslint-plugin-import'
4
+ import path from 'path';
5
+ import { fileURLToPath } from 'url';
6
+
7
+ const __filename = fileURLToPath(import.meta.url);
8
+ const __dirname = path.dirname(__filename);
9
+
10
+ export default [
11
+ {
12
+ languageOptions: {
13
+ parser: parser,
14
+ ecmaVersion: "latest", // Allows modern ECMAScript features
15
+ sourceType: "module", // Allows for the use of imports
16
+ parserOptions: {
17
+ tsconfigRootDir: __dirname,
18
+ project: './tsconfig.json'
19
+ },
20
+ },
21
+ plugins: {
22
+ "@typescript-eslint": eslintPlugin,
23
+ import: importPlugin
24
+ },
25
+ rules: {
26
+ "no-console": "off",
27
+ "@typescript-eslint/no-explicit-any": "off",
28
+ "@typescript-eslint/no-var-requires": "off",
29
+ "@typescript-eslint/explicit-module-boundary-types": "off",
30
+ "import/prefer-default-export": "off",
31
+ "@typescript-eslint/no-unused-vars": "warn",
32
+ "no-useless-catch": "off",
33
+ "@typescript-eslint/no-non-null-assertion": "off",
34
+ "@typescript-eslint/no-empty-function": "off",
35
+ "@typescript-eslint/no-empty-interface": "off",
36
+ "@typescript-eslint/no-inferrable-types": "off",
37
+ "@typescript-eslint/no-namespace": "off",
38
+ "@typescript-eslint/no-use-before-define": "off",
39
+ "@typescript-eslint/no-unsafe-assignment": "off",
40
+ "@typescript-eslint/no-unsafe-call": "off",
41
+ "@typescript-eslint/no-unsafe-member-access": "off",
42
+ "@typescript-eslint/no-unsafe-return": "off",
43
+ "@typescript-eslint/restrict-template-expressions": "off",
44
+ "no-useless-escape": "off",
45
+ "import/no-relative-parent-imports": "error", // Enforce relative imports only
46
+ "import/no-absolute-path": "error", // Block absolute imports outside aliases
47
+ "import/no-unresolved": ["error", { commonjs: true }],
48
+ },
49
+ settings: {
50
+ "import/resolver": {
51
+ typescript: {
52
+ alwaysTryTypes: true,
53
+ }
54
+ }
55
+ },
56
+ ignores: ["node_modules", "dist/**/*", "eslint.config.mjs"],
57
+ },
58
+ ];
@@ -1,36 +1,36 @@
1
- 'use strict';
2
-
3
- module.exports = {
4
- async up(queryInterface, Sequelize) {
5
- const table = await queryInterface.describeTable('common_Media');
6
-
7
- if (!table.hasOwnProperty('DefaultYN')) {
8
- queryInterface.addColumn('common_Media', 'DefaultYN', {
9
- type: Sequelize.ENUM(['Y', 'N']),
10
- allowNull: true,
11
- defaultValue: 'N',
12
- });
13
- }
14
-
15
- if (!table.hasOwnProperty('HiddenYN')) {
16
- queryInterface.addColumn('common_Media', 'HiddenYN', {
17
- type: Sequelize.ENUM(['Y', 'N']),
18
- allowNull: true,
19
- defaultValue: 'N',
20
- });
21
- }
22
- },
23
-
24
- down(queryInterface) {
25
- return queryInterface.sequelize.transaction((t) => {
26
- return Promise.all([
27
- queryInterface.removeColumn('common_Media', 'DefaultYN', {
28
- transaction: t,
29
- }),
30
- queryInterface.removeColumn('common_Media', 'HiddenYN', {
31
- transaction: t,
32
- }),
33
- ]);
34
- });
35
- },
36
- };
1
+ 'use strict';
2
+
3
+ module.exports = {
4
+ async up(queryInterface, Sequelize) {
5
+ const table = await queryInterface.describeTable('common_Media');
6
+
7
+ if (!table.hasOwnProperty('DefaultYN')) {
8
+ queryInterface.addColumn('common_Media', 'DefaultYN', {
9
+ type: Sequelize.ENUM(['Y', 'N']),
10
+ allowNull: true,
11
+ defaultValue: 'N',
12
+ });
13
+ }
14
+
15
+ if (!table.hasOwnProperty('HiddenYN')) {
16
+ queryInterface.addColumn('common_Media', 'HiddenYN', {
17
+ type: Sequelize.ENUM(['Y', 'N']),
18
+ allowNull: true,
19
+ defaultValue: 'N',
20
+ });
21
+ }
22
+ },
23
+
24
+ down(queryInterface) {
25
+ return queryInterface.sequelize.transaction((t) => {
26
+ return Promise.all([
27
+ queryInterface.removeColumn('common_Media', 'DefaultYN', {
28
+ transaction: t,
29
+ }),
30
+ queryInterface.removeColumn('common_Media', 'HiddenYN', {
31
+ transaction: t,
32
+ }),
33
+ ]);
34
+ });
35
+ },
36
+ };
@@ -1,83 +1,83 @@
1
- 'use strict';
2
-
3
- module.exports = {
4
- async up(queryInterface, Sequelize) {
5
- await queryInterface.createTable('common_Media', {
6
- MediaId: {
7
- type: Sequelize.STRING(30),
8
- primaryKey: true,
9
- allowNull: false,
10
- },
11
- ObjectId: {
12
- type: Sequelize.STRING(30),
13
- allowNull: false,
14
- },
15
- ObjectType: {
16
- type: Sequelize.STRING(200),
17
- allowNull: false,
18
- },
19
- Title: {
20
- type: Sequelize.STRING(200),
21
- allowNull: false,
22
- },
23
- Description: {
24
- type: Sequelize.TEXT,
25
- allowNull: true,
26
- },
27
- Type: {
28
- type: Sequelize.ENUM(['Photo', 'Video', 'Document']),
29
- allowNull: false,
30
- },
31
- IsExternalYN: {
32
- type: Sequelize.ENUM(['Y', 'N']),
33
- allowNull: false,
34
- },
35
- ExternalSource: {
36
- type: Sequelize.STRING(200),
37
- allowNull: true,
38
- },
39
- IsEncryptedYN: {
40
- type: Sequelize.ENUM(['Y', 'N']),
41
- allowNull: false,
42
- },
43
- FileName: {
44
- type: Sequelize.STRING(200),
45
- allowNull: true,
46
- },
47
- FileExtension: {
48
- type: Sequelize.STRING(10),
49
- allowNull: true,
50
- },
51
- FilePath: {
52
- type: Sequelize.STRING(200),
53
- allowNull: true,
54
- },
55
- URL: {
56
- type: Sequelize.STRING(200),
57
- allowNull: true,
58
- },
59
- CreatedAt: {
60
- allowNull: false,
61
- defaultValue: new Date(),
62
- type: Sequelize.DATE,
63
- },
64
- CreatedById: {
65
- allowNull: false,
66
- type: Sequelize.STRING,
67
- },
68
- UpdatedAt: {
69
- allowNull: false,
70
- defaultValue: new Date(),
71
- type: Sequelize.DATE,
72
- },
73
- UpdatedById: {
74
- allowNull: false,
75
- type: Sequelize.STRING,
76
- },
77
- });
78
- },
79
-
80
- async down(queryInterface) {
81
- await queryInterface.dropTable('common_Media');
82
- },
1
+ 'use strict';
2
+
3
+ module.exports = {
4
+ async up(queryInterface, Sequelize) {
5
+ await queryInterface.createTable('common_Media', {
6
+ MediaId: {
7
+ type: Sequelize.STRING(30),
8
+ primaryKey: true,
9
+ allowNull: false,
10
+ },
11
+ ObjectId: {
12
+ type: Sequelize.STRING(30),
13
+ allowNull: false,
14
+ },
15
+ ObjectType: {
16
+ type: Sequelize.STRING(200),
17
+ allowNull: false,
18
+ },
19
+ Title: {
20
+ type: Sequelize.STRING(200),
21
+ allowNull: false,
22
+ },
23
+ Description: {
24
+ type: Sequelize.TEXT,
25
+ allowNull: true,
26
+ },
27
+ Type: {
28
+ type: Sequelize.ENUM(['Photo', 'Video', 'Document']),
29
+ allowNull: false,
30
+ },
31
+ IsExternalYN: {
32
+ type: Sequelize.ENUM(['Y', 'N']),
33
+ allowNull: false,
34
+ },
35
+ ExternalSource: {
36
+ type: Sequelize.STRING(200),
37
+ allowNull: true,
38
+ },
39
+ IsEncryptedYN: {
40
+ type: Sequelize.ENUM(['Y', 'N']),
41
+ allowNull: false,
42
+ },
43
+ FileName: {
44
+ type: Sequelize.STRING(200),
45
+ allowNull: true,
46
+ },
47
+ FileExtension: {
48
+ type: Sequelize.STRING(10),
49
+ allowNull: true,
50
+ },
51
+ FilePath: {
52
+ type: Sequelize.STRING(200),
53
+ allowNull: true,
54
+ },
55
+ URL: {
56
+ type: Sequelize.STRING(200),
57
+ allowNull: true,
58
+ },
59
+ CreatedAt: {
60
+ allowNull: false,
61
+ defaultValue: new Date(),
62
+ type: Sequelize.DATE,
63
+ },
64
+ CreatedById: {
65
+ allowNull: false,
66
+ type: Sequelize.STRING,
67
+ },
68
+ UpdatedAt: {
69
+ allowNull: false,
70
+ defaultValue: new Date(),
71
+ type: Sequelize.DATE,
72
+ },
73
+ UpdatedById: {
74
+ allowNull: false,
75
+ type: Sequelize.STRING,
76
+ },
77
+ });
78
+ },
79
+
80
+ async down(queryInterface) {
81
+ await queryInterface.dropTable('common_Media');
82
+ },
83
83
  };
package/nest-cli.json CHANGED
@@ -1,19 +1,19 @@
1
- {
2
- "language": "ts",
3
- "collection": "@nestjs/schematics",
4
- "sourceRoot": "src",
5
- "projects": {
6
- "media": {
7
- "type": "library",
8
- "root": "libs/media",
9
- "entryFile": "index",
10
- "sourceRoot": "libs/media/src",
11
- "compilerOptions": {
12
- "tsConfigPath": "libs/media/tsconfig.lib.json"
13
- }
14
- }
15
- },
16
- "compilerOptions": {
17
- "webpack": true
18
- }
1
+ {
2
+ "language": "ts",
3
+ "collection": "@nestjs/schematics",
4
+ "sourceRoot": "src",
5
+ "projects": {
6
+ "media": {
7
+ "type": "library",
8
+ "root": "libs/media",
9
+ "entryFile": "index",
10
+ "sourceRoot": "libs/media/src",
11
+ "compilerOptions": {
12
+ "tsConfigPath": "libs/media/tsconfig.lib.json"
13
+ }
14
+ }
15
+ },
16
+ "compilerOptions": {
17
+ "webpack": true
18
+ }
19
19
  }
package/package.json CHANGED
@@ -1,79 +1,78 @@
1
- {
2
- "name": "@tomei/media",
3
- "version": "0.8.10",
4
- "description": "NestJS package for media module",
5
- "main": "dist/index.js",
6
- "scripts": {
7
- "start:dev": "tsc -w",
8
- "build": "tsc",
9
- "prepare": "husky install",
10
- "format": "prettier --write \"src/**/*.ts\"",
11
- "lint": "npx eslint . --fix"
12
- },
13
- "keywords": [
14
- "nestjs",
15
- "tomei",
16
- "media"
17
- ],
18
- "author": "ITD Developer <itd+developers@tomei.com.my>",
19
- "license": "ISC",
20
- "repository": {
21
- "type": "git",
22
- "url": "https://gitlab.com/tomei-package/media.git"
23
- },
24
- "peerDependencies": {
25
- "@azure/storage-blob": "^12.26.0",
26
- "@nestjs/common": "^10.4.15",
27
- "@nestjs/config": "^3.3.0",
28
- "@nestjs/core": "^10.4.15",
29
- "@nestjs/platform-express": "^10.4.15",
30
- "@nestjs/sequelize": "^10.0.1",
31
- "@nestjs/swagger": "^8.1.0",
32
- "@tomei/activity-history": "^0.4.1",
33
- "@tomei/config": "^0.3.21",
34
- "@tomei/general": "^0.21.7",
35
- "@tomei/mailer": "^0.5.21",
36
- "@tomei/sso": "^0.60.4",
37
- "axios": "^1.7.9",
38
- "class-transformer": "^0.5.1",
39
- "class-validator": "^0.14.1",
40
- "cuid": "^3.0.0",
41
- "multer": "^1.4.5-lts.1",
42
- "sequelize": "^6.37.5",
43
- "sequelize-typescript": "^2.1.6"
44
- },
45
- "devDependencies": {
46
- "@commitlint/config-conventional": "^19.6.0",
47
- "@eslint/js": "^9.17.0",
48
- "@types/express": "^5.0.0",
49
- "@types/multer": "^1.4.12",
50
- "@types/node": "^22.10.5",
51
- "@types/sequelize": "^4.28.20",
52
- "@typescript-eslint/eslint-plugin": "^8.19.0",
53
- "eslint": "^9.17.0",
54
- "eslint-config-prettier": "^9.1.0",
55
- "eslint-plugin-import": "^2.31.0",
56
- "eslint-plugin-prettier": "^5.2.1",
57
- "globals": "^15.14.0",
58
- "husky": "^9.1.7",
59
- "lint-staged": "^15.3.0",
60
- "prettier": "^3.4.2",
61
- "ts-node": "^10.9.2",
62
- "tsc-watch": "^6.2.1",
63
- "tsconfig-paths": "^4.2.0",
64
- "typescript": "^5.7.2",
65
- "typescript-eslint": "^8.19.0"
66
- },
67
- "publishConfig": {
68
- "access": "public"
69
- },
70
- "lint-staged": {
71
- "*/**/*.{js,ts,tsx}": [
72
- "npm run lint",
73
- "npm run eslint",
74
- "npm run format",
75
- "npm run build",
76
- "git add ."
77
- ]
78
- }
79
- }
1
+ {
2
+ "name": "@tomei/media",
3
+ "version": "0.10.0",
4
+ "description": "NestJS package for media module",
5
+ "main": "dist/index.js",
6
+ "scripts": {
7
+ "start:dev": "tsc -w",
8
+ "build": "tsc",
9
+ "prepare": "husky install",
10
+ "format": "prettier --write \"src/**/*.ts\"",
11
+ "lint": "npx eslint . --fix"
12
+ },
13
+ "keywords": [
14
+ "nestjs",
15
+ "tomei",
16
+ "media"
17
+ ],
18
+ "author": "ITD Developer <itd+developers@tomei.com.my>",
19
+ "license": "ISC",
20
+ "repository": {
21
+ "type": "git",
22
+ "url": "https://gitlab.com/tomei-package/media.git"
23
+ },
24
+ "peerDependencies": {
25
+ "@azure/storage-blob": "^12.28.0",
26
+ "@nestjs/common": "^10.4.20",
27
+ "@nestjs/config": "^3.3.0",
28
+ "@nestjs/core": "^10.4.20",
29
+ "@nestjs/platform-express": "^10.4.20",
30
+ "@nestjs/sequelize": "^10.0.1",
31
+ "@nestjs/swagger": "^8.1.1",
32
+ "@tomei/activity-history": "^0.4.4",
33
+ "@tomei/config": "^0.3.22",
34
+ "@tomei/general": "^0.21.10",
35
+ "@tomei/mailer": "^0.6.2",
36
+ "@tomei/sso": "^0.65.0",
37
+ "axios": "^1.12.2",
38
+ "class-transformer": "^0.5.1",
39
+ "class-validator": "^0.14.2",
40
+ "multer": "^1.4.5-lts.2",
41
+ "sequelize": "^6.37.7",
42
+ "sequelize-typescript": "^2.1.6"
43
+ },
44
+ "devDependencies": {
45
+ "@commitlint/config-conventional": "^19.8.1",
46
+ "@eslint/js": "^9.36.0",
47
+ "@types/express": "^5.0.3",
48
+ "@types/multer": "^1.4.13",
49
+ "@types/node": "^22.18.8",
50
+ "@types/sequelize": "^4.28.20",
51
+ "@typescript-eslint/eslint-plugin": "^8.45.0",
52
+ "eslint": "^9.36.0",
53
+ "eslint-config-prettier": "^9.1.2",
54
+ "eslint-plugin-import": "^2.32.0",
55
+ "eslint-plugin-prettier": "^5.5.4",
56
+ "globals": "^15.15.0",
57
+ "husky": "^9.1.7",
58
+ "lint-staged": "^15.5.2",
59
+ "prettier": "^3.6.2",
60
+ "ts-node": "^10.9.2",
61
+ "tsc-watch": "^6.3.1",
62
+ "tsconfig-paths": "^4.2.0",
63
+ "typescript": "^5.9.3",
64
+ "typescript-eslint": "^8.45.0"
65
+ },
66
+ "publishConfig": {
67
+ "access": "public"
68
+ },
69
+ "lint-staged": {
70
+ "*/**/*.{js,ts,tsx}": [
71
+ "npm run lint",
72
+ "npm run eslint",
73
+ "npm run format",
74
+ "npm run build",
75
+ "git add ."
76
+ ]
77
+ }
78
+ }
@@ -1,13 +1,13 @@
1
- sonar.projectKey=all-tomei-projects_media
2
- sonar.organization=all-tomei-projects
3
-
4
- # This is the name and version displayed in the SonarCloud UI.
5
- #sonar.projectName=Media
6
- #sonar.projectVersion=1.0
7
-
8
-
9
- # Path is relative to the sonar-project.properties file. Replace "\" by "/" on Windows.
10
- #sonar.sources=.
11
-
12
- # Encoding of the source code. Default is default system encoding
1
+ sonar.projectKey=all-tomei-projects_media
2
+ sonar.organization=all-tomei-projects
3
+
4
+ # This is the name and version displayed in the SonarCloud UI.
5
+ #sonar.projectName=Media
6
+ #sonar.projectVersion=1.0
7
+
8
+
9
+ # Path is relative to the sonar-project.properties file. Replace "\" by "/" on Windows.
10
+ #sonar.sources=.
11
+
12
+ # Encoding of the source code. Default is default system encoding
13
13
  #sonar.sourceEncoding=UTF-8
@@ -1,5 +1,5 @@
1
1
  import { MediaType } from '../enum/medias.enum';
2
- import * as cuid from 'cuid';
2
+ import { createId } from '@paralleldrive/cuid2';
3
3
  import { BadRequestException } from '@nestjs/common';
4
4
  import { MediasModel } from '../entities/medias.entity';
5
5
  import { IBaseMediasAttr } from '../interfaces/base.medias-attr.interface';
@@ -36,7 +36,7 @@ export abstract class BaseMedias extends ObjectBase {
36
36
  }
37
37
 
38
38
  init(media: IBaseMediasAttr) {
39
- this.MediaId = media.MediaId ? media.MediaId : cuid();
39
+ this.MediaId = media.MediaId ? media.MediaId : createId();
40
40
  this.ObjectId = media.ObjectId;
41
41
  this.ObjectType = media.ObjectType;
42
42
  this.Title = media.Title;
@@ -5,7 +5,7 @@ import {
5
5
  } from '@nestjs/common';
6
6
  import { ConfigService } from '@nestjs/config';
7
7
  import axios from 'axios';
8
- import * as cuid from 'cuid';
8
+ import { createId } from '@paralleldrive/cuid2';
9
9
  import { omit, omitBy, keys, pick } from 'lodash';
10
10
  import { AddFieldTranslationDto } from './dto/add-field-translation.dto';
11
11
  import { GetMediaDto } from './dto/get-media.dto';
@@ -61,7 +61,7 @@ export class CommonService {
61
61
  EntityValueAfter: JSON.stringify(filteredRecord),
62
62
  PerformedById: record.PerformedById,
63
63
  PerformedAt: record.PerformedAt || Date.now(),
64
- EntityId: record.EntityId ? record.EntityId : cuid(),
64
+ EntityId: record.EntityId ? record.EntityId : createId(),
65
65
  };
66
66
 
67
67
  try {
@@ -21,7 +21,9 @@ export class MediasRepository
21
21
  const result = await MediasModel.findOne(options);
22
22
  return result;
23
23
  } catch (error) {
24
- throw new Error(`An Error occured when fetching : ${error.message}`);
24
+ throw new Error(
25
+ `An Error occured when fetching : ${(error as Error).message}`,
26
+ );
25
27
  }
26
28
  }
27
29
 
@@ -35,7 +37,9 @@ export class MediasRepository
35
37
  };
36
38
  await MediasModel.destroy(options);
37
39
  } catch (error) {
38
- throw new Error(`An Error occured when delete : ${error.message}`);
40
+ throw new Error(
41
+ `An Error occured when delete : ${(error as Error).message}`,
42
+ );
39
43
  }
40
44
  }
41
45
 
@@ -49,7 +53,9 @@ export class MediasRepository
49
53
  }
50
54
  return medias;
51
55
  } catch (error) {
52
- throw new Error(`An Error occured when retriving : ${error.message}`);
56
+ throw new Error(
57
+ `An Error occured when retriving : ${(error as Error).message}`,
58
+ );
53
59
  }
54
60
  }
55
61
  }