@tomei/media 0.10.0 → 0.10.1-test.1

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 (37) hide show
  1. package/.commitlintrc.json +22 -22
  2. package/.gitlab-ci.yml +234 -16
  3. package/.husky/commit-msg +15 -15
  4. package/.husky/pre-commit +7 -7
  5. package/.prettierrc +4 -4
  6. package/.vscode/settings.json +3 -0
  7. package/README.md +93 -93
  8. package/dist/__tests__/common.service.spec.d.ts +1 -0
  9. package/dist/__tests__/common.service.spec.js +160 -0
  10. package/dist/__tests__/common.service.spec.js.map +1 -0
  11. package/dist/__tests__/medias.repository.spec.d.ts +1 -0
  12. package/dist/__tests__/medias.repository.spec.js +140 -0
  13. package/dist/__tests__/medias.repository.spec.js.map +1 -0
  14. package/dist/__tests__/medias.spec.d.ts +1 -0
  15. package/dist/__tests__/medias.spec.js +347 -0
  16. package/dist/__tests__/medias.spec.js.map +1 -0
  17. package/dist/__tests__/pipes.spec.d.ts +1 -0
  18. package/dist/__tests__/pipes.spec.js +130 -0
  19. package/dist/__tests__/pipes.spec.js.map +1 -0
  20. package/dist/medias.d.ts +2 -2
  21. package/dist/medias.js +7 -1
  22. package/dist/medias.js.map +1 -1
  23. package/dist/tsconfig.tsbuildinfo +1 -1
  24. package/eslint.config.mjs +58 -58
  25. package/jest.config.js +26 -0
  26. package/migration/0001-add-defaultyn-hiddenyn-to-media-table.js +36 -36
  27. package/migration/media-migration.js +82 -82
  28. package/nest-cli.json +18 -18
  29. package/package.json +83 -78
  30. package/sonar-project.properties +12 -12
  31. package/src/__tests__/common.service.spec.ts +203 -0
  32. package/src/__tests__/medias.repository.spec.ts +158 -0
  33. package/src/__tests__/medias.spec.ts +468 -0
  34. package/src/__tests__/pipes.spec.ts +154 -0
  35. package/src/medias.ts +11 -3
  36. package/tsconfig.build.json +4 -4
  37. package/tsconfig.json +30 -30
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
+ ];
package/jest.config.js ADDED
@@ -0,0 +1,26 @@
1
+ module.exports = {
2
+ preset: 'ts-jest',
3
+ testEnvironment: 'node',
4
+ roots: ['<rootDir>/src'],
5
+ testMatch: ['**/__tests__/**/*.spec.ts'],
6
+ collectCoverage: true,
7
+ coverageDirectory: 'coverage',
8
+ collectCoverageFrom: [
9
+ 'src/**/*.ts',
10
+ '!src/index.ts',
11
+ '!src/database.ts',
12
+ '!src/**/*.entity.ts',
13
+ '!src/**/*.interface.ts',
14
+ '!src/**/*.dto.ts',
15
+ '!src/**/*.enum.ts',
16
+ '!src/**/*.response.ts',
17
+ '!src/**/*.module.ts',
18
+ '!src/base/base.repository.abstract.ts',
19
+ '!src/helpers/**',
20
+ ],
21
+ coverageThreshold: {
22
+ global: {
23
+ lines: 80,
24
+ },
25
+ },
26
+ };
@@ -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,78 +1,83 @@
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
+ {
2
+ "name": "@tomei/media",
3
+ "version": "0.10.1-test.1",
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 || true",
10
+ "format": "prettier --write \"src/**/*.ts\"",
11
+ "lint": "npx eslint . --fix",
12
+ "test": "jest",
13
+ "test:coverage": "jest --coverage"
14
+ },
15
+ "keywords": [
16
+ "nestjs",
17
+ "tomei",
18
+ "media"
19
+ ],
20
+ "author": "ITD Developer <itd+developers@tomei.com.my>",
21
+ "license": "ISC",
22
+ "repository": {
23
+ "type": "git",
24
+ "url": "https://gitlab.com/tomei-package/media.git"
25
+ },
26
+ "peerDependencies": {
27
+ "@azure/storage-blob": "^12.28.0",
28
+ "@nestjs/common": "^10.4.20",
29
+ "@nestjs/config": "^3.3.0",
30
+ "@nestjs/core": "^10.4.20",
31
+ "@nestjs/platform-express": "^10.4.20",
32
+ "@nestjs/sequelize": "^10.0.1",
33
+ "@nestjs/swagger": "^8.1.1",
34
+ "@tomei/activity-history": "^0.4.4",
35
+ "@tomei/config": "^0.3.22",
36
+ "@tomei/general": "^0.21.10",
37
+ "@tomei/mailer": "^0.6.2",
38
+ "@tomei/sso": "^0.65.0",
39
+ "axios": "^1.12.2",
40
+ "class-transformer": "^0.5.1",
41
+ "class-validator": "^0.14.2",
42
+ "multer": "^1.4.5-lts.2",
43
+ "sequelize": "^6.37.7",
44
+ "sequelize-typescript": "^2.1.6"
45
+ },
46
+ "devDependencies": {
47
+ "@commitlint/config-conventional": "^19.8.1",
48
+ "@eslint/js": "^9.36.0",
49
+ "@types/express": "^5.0.3",
50
+ "@types/jest": "^30.0.0",
51
+ "@types/multer": "^1.4.13",
52
+ "@types/node": "^22.18.8",
53
+ "@types/sequelize": "^4.28.20",
54
+ "@typescript-eslint/eslint-plugin": "^8.45.0",
55
+ "eslint": "^9.36.0",
56
+ "eslint-config-prettier": "^9.1.2",
57
+ "eslint-plugin-import": "^2.32.0",
58
+ "eslint-plugin-prettier": "^5.5.4",
59
+ "globals": "^15.15.0",
60
+ "husky": "^9.1.7",
61
+ "jest": "^30.4.2",
62
+ "lint-staged": "^15.5.2",
63
+ "prettier": "^3.6.2",
64
+ "ts-jest": "^29.4.9",
65
+ "ts-node": "^10.9.2",
66
+ "tsc-watch": "^6.3.1",
67
+ "tsconfig-paths": "^4.2.0",
68
+ "typescript": "^5.9.3",
69
+ "typescript-eslint": "^8.45.0"
70
+ },
71
+ "publishConfig": {
72
+ "access": "public"
73
+ },
74
+ "lint-staged": {
75
+ "*/**/*.{js,ts,tsx}": [
76
+ "npm run lint",
77
+ "npm run eslint",
78
+ "npm run format",
79
+ "npm run build",
80
+ "git add ."
81
+ ]
82
+ }
83
+ }
@@ -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