mirror of
https://github.com/SyncrowIOT/backend.git
synced 2025-07-11 15:48:09 +00:00
Merge branch 'dev' into real-time-devices
This commit is contained in:
75
.env.example
Normal file
75
.env.example
Normal file
@ -0,0 +1,75 @@
|
||||
ACCESS_KEY=
|
||||
|
||||
AZURE_POSTGRESQL_DATABASE=
|
||||
|
||||
AZURE_POSTGRESQL_HOST=
|
||||
|
||||
AZURE_POSTGRESQL_PASSWORD=
|
||||
|
||||
AZURE_POSTGRESQL_PORT=
|
||||
|
||||
AZURE_POSTGRESQL_SSL=
|
||||
|
||||
AZURE_POSTGRESQL_SYNC=
|
||||
|
||||
AZURE_POSTGRESQL_USER=
|
||||
|
||||
AZURE_REDIS_CONNECTIONSTRING=
|
||||
|
||||
BASE_URL=
|
||||
|
||||
DB_SYNC=
|
||||
|
||||
DOCKER_REGISTRY_SERVER_PASSWORD=
|
||||
|
||||
DOCKER_REGISTRY_SERVER_URL=
|
||||
|
||||
DOCKER_REGISTRY_SERVER_USERNAME=
|
||||
|
||||
DOPPLER_CONFIG=
|
||||
|
||||
DOPPLER_ENVIRONMENT=
|
||||
|
||||
DOPPLER_PROJECT=
|
||||
|
||||
JWT_EXPIRE_TIME=
|
||||
|
||||
JWT_EXPIRE_TIME_REFRESH=
|
||||
|
||||
JWT_SECRET=
|
||||
|
||||
JWT_SECRET_REFRESH=
|
||||
|
||||
SECRET_KEY=
|
||||
|
||||
SMTP_HOST=
|
||||
|
||||
SMTP_PASSWORD=
|
||||
|
||||
SMTP_PORT=
|
||||
|
||||
SMTP_SECURE=
|
||||
|
||||
SMTP_USER=
|
||||
|
||||
WEBSITES_ENABLE_APP_SERVICE_STORAGE=
|
||||
|
||||
PORT=
|
||||
|
||||
SUPER_ADMIN_EMAIL=
|
||||
|
||||
SUPER_ADMIN_PASSWORD=
|
||||
|
||||
TUYA_ACCESS_ID=
|
||||
|
||||
TUYA_ACCESS_KEY=
|
||||
|
||||
ONESIGNAL_APP_ID=
|
||||
|
||||
ONESIGNAL_API_KEY=
|
||||
|
||||
TRUN_ON_TUYA_SOCKET=
|
||||
|
||||
TUYA_EU_URL=
|
||||
|
||||
MONGODB_URI=
|
61
.github/workflows/dev_syncrow(dev).yml
vendored
61
.github/workflows/dev_syncrow(dev).yml
vendored
@ -1,61 +0,0 @@
|
||||
name: Backend deployment to Azure App Service
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- dev
|
||||
workflow_dispatch:
|
||||
|
||||
env:
|
||||
AZURE_WEB_APP_NAME: 'syncrow'
|
||||
AZURE_WEB_APP_SLOT_NAME: 'dev'
|
||||
ACR_REGISTRY: 'syncrow.azurecr.io'
|
||||
IMAGE_NAME: 'backend'
|
||||
IMAGE_TAG: '${{ github.sha }}' # Use commit SHA for unique tagging
|
||||
|
||||
jobs:
|
||||
build_and_deploy:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- name: Set up Node.js
|
||||
uses: actions/setup-node@v3
|
||||
with:
|
||||
node-version: '20'
|
||||
|
||||
- name: Clear npm cache and install dependencies
|
||||
run: |
|
||||
npm cache clean --force
|
||||
npm install
|
||||
|
||||
- name: Build project
|
||||
run: npm run build
|
||||
|
||||
- name: Log in to Azure
|
||||
uses: azure/login@v1
|
||||
with:
|
||||
creds: ${{ secrets.AZURE_CREDENTIALS }}
|
||||
|
||||
- name: Log in to Azure Container Registry
|
||||
run: az acr login --name ${{ env.ACR_REGISTRY }}
|
||||
|
||||
- name: List build output
|
||||
run: ls -R dist/
|
||||
|
||||
- name: Build and push Docker image
|
||||
run: |
|
||||
docker build . -t ${{ env.ACR_REGISTRY }}/${{ env.IMAGE_NAME }}:${{ env.IMAGE_TAG }}
|
||||
docker push ${{ env.ACR_REGISTRY }}/${{ env.IMAGE_NAME }}:${{ env.IMAGE_TAG }}
|
||||
|
||||
- name: Set Web App with Docker container
|
||||
run: |
|
||||
az webapp config container set \
|
||||
--name ${{ env.AZURE_WEB_APP_NAME }} \
|
||||
--resource-group backend \
|
||||
--docker-custom-image-name ${{ env.ACR_REGISTRY }}/${{ env.IMAGE_NAME }}:${{ env.IMAGE_TAG }} \
|
||||
--docker-registry-server-url https://${{ env.ACR_REGISTRY }}
|
||||
|
||||
- name: Restart Web App
|
||||
run: az webapp restart --name ${{ env.AZURE_WEB_APP_NAME }} --resource-group backend
|
51
.github/workflows/dev_syncrow(test).yml
vendored
Normal file
51
.github/workflows/dev_syncrow(test).yml
vendored
Normal file
@ -0,0 +1,51 @@
|
||||
# Docs for the Azure Web Apps Deploy action: https://github.com/Azure/webapps-deploy
|
||||
# More GitHub Actions for Azure: https://github.com/Azure/actions
|
||||
|
||||
name: Build and deploy container app to Azure Web App - syncrow(test)
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- dev
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: 'ubuntu-latest'
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v2
|
||||
|
||||
- name: Log in to registry
|
||||
uses: docker/login-action@v2
|
||||
with:
|
||||
registry: https://syncrow.azurecr.io/
|
||||
username: ${{ secrets.AzureAppService_ContainerUsername_e7578d2a094946609a4506f293c7c645 }}
|
||||
password: ${{ secrets.AzureAppService_ContainerPassword_3cfcef3755ed46eda766dfc7059dcf5e }}
|
||||
|
||||
- name: Build and push container image to registry
|
||||
uses: docker/build-push-action@v3
|
||||
with:
|
||||
push: true
|
||||
tags: syncrow.azurecr.io/${{ secrets.AzureAppService_ContainerUsername_e7578d2a094946609a4506f293c7c645 }}/backend:${{ github.sha }}
|
||||
file: ./Dockerfile
|
||||
|
||||
deploy:
|
||||
runs-on: ubuntu-latest
|
||||
needs: build
|
||||
environment:
|
||||
name: 'test'
|
||||
url: ${{ steps.deploy-to-webapp.outputs.webapp-url }}
|
||||
|
||||
steps:
|
||||
- name: Deploy to Azure Web App
|
||||
id: deploy-to-webapp
|
||||
uses: azure/webapps-deploy@v2
|
||||
with:
|
||||
app-name: 'syncrow'
|
||||
slot-name: 'test'
|
||||
publish-profile: ${{ secrets.AzureAppService_PublishProfile_cfa029d9d3a84172a06cfe47c05c18ca }}
|
||||
images: 'syncrow.azurecr.io/${{ secrets.AzureAppService_ContainerUsername_e7578d2a094946609a4506f293c7c645 }}/backend:${{ github.sha }}'
|
2
.github/workflows/main_syncrow(staging).yml
vendored
2
.github/workflows/main_syncrow(staging).yml
vendored
@ -52,4 +52,4 @@ jobs:
|
||||
--name ${{ env.AZURE_WEB_APP_NAME }} \
|
||||
--resource-group backend \
|
||||
--docker-custom-image-name ${{ env.ACR_REGISTRY }}/${{ env.IMAGE_NAME }}:${{ env.IMAGE_TAG }} \
|
||||
--docker-registry-server-url https://${{ env.ACR_REGISTRY }}
|
||||
--docker-registry-server-url https://${{ env.ACR_REGISTRY }}
|
||||
|
@ -1,4 +1,5 @@
|
||||
{
|
||||
"singleQuote": true,
|
||||
"trailingComma": "all"
|
||||
"trailingComma": "all",
|
||||
"endOfLine": "auto"
|
||||
}
|
@ -1,24 +1,15 @@
|
||||
module.exports = {
|
||||
moduleFileExtensions: [
|
||||
"js",
|
||||
"json",
|
||||
"ts"
|
||||
],
|
||||
rootDir: ".",
|
||||
testRegex: ".*\\.spec\\.ts$",
|
||||
moduleFileExtensions: ['js', 'json', 'ts'],
|
||||
rootDir: '.',
|
||||
testRegex: '.*\\.spec\\.ts$',
|
||||
transform: {
|
||||
"^.+\\.(t|j)s$": "ts-jest"
|
||||
'^.+\\.(t|j)s$': 'ts-jest',
|
||||
},
|
||||
collectCoverageFrom: [
|
||||
"**/*.(t|j)s"
|
||||
],
|
||||
coverageDirectory: "./coverage",
|
||||
testEnvironment: "node",
|
||||
roots: [
|
||||
"<rootDir>/src/",
|
||||
"<rootDir>/libs/"
|
||||
],
|
||||
collectCoverageFrom: ['**/*.(t|j)s'],
|
||||
coverageDirectory: './coverage',
|
||||
testEnvironment: 'node',
|
||||
roots: ['<rootDir>/src/', '<rootDir>/libs/'],
|
||||
moduleNameMapper: {
|
||||
"^@app/common(|/.*)$": "<rootDir>/libs/common/src/$1"
|
||||
}
|
||||
'^@app/common(|/.*)$': '<rootDir>/libs/common/src/$1',
|
||||
},
|
||||
};
|
||||
|
@ -7,6 +7,7 @@ export default registerAs(
|
||||
SMTP_PORT: parseInt(process.env.SMTP_PORT),
|
||||
SMTP_SECURE: process.env.SMTP_SECURE === 'true',
|
||||
SMTP_USER: process.env.SMTP_USER,
|
||||
SMTP_SENDER: process.env.SMTP_SENDER,
|
||||
SMTP_PASSWORD: process.env.SMTP_PASSWORD,
|
||||
}),
|
||||
);
|
||||
|
@ -79,7 +79,6 @@ export const allCountries = [
|
||||
'Iran',
|
||||
'Iraq',
|
||||
'Ireland',
|
||||
'Israel',
|
||||
'Italy',
|
||||
'Jamaica',
|
||||
'Japan',
|
||||
|
@ -4,18 +4,18 @@ import { TypeOrmModule } from '@nestjs/typeorm';
|
||||
import { SnakeNamingStrategy } from './strategies';
|
||||
import { UserEntity } from '../modules/user/entities/user.entity';
|
||||
import { UserSessionEntity } from '../modules/session/entities/session.entity';
|
||||
import { UserOtpEntity } from '../modules/user-otp/entities';
|
||||
import { UserOtpEntity } from '../modules/user/entities';
|
||||
import { ProductEntity } from '../modules/product/entities';
|
||||
import { DeviceEntity } from '../modules/device/entities';
|
||||
import { PermissionTypeEntity } from '../modules/permission/entities';
|
||||
import { SpaceEntity } from '../modules/space/entities';
|
||||
import { SpaceTypeEntity } from '../modules/space-type/entities';
|
||||
import { UserSpaceEntity } from '../modules/user-space/entities';
|
||||
import { DeviceUserPermissionEntity } from '../modules/device-user-permission/entities';
|
||||
import { UserRoleEntity } from '../modules/user-role/entities';
|
||||
import { SpaceTypeEntity } from '../modules/space/entities';
|
||||
import { UserSpaceEntity } from '../modules/user/entities';
|
||||
import { DeviceUserPermissionEntity } from '../modules/device/entities';
|
||||
import { UserRoleEntity } from '../modules/user/entities';
|
||||
import { RoleTypeEntity } from '../modules/role-type/entities';
|
||||
import { UserNotificationEntity } from '../modules/user-notification/entities';
|
||||
import { DeviceNotificationEntity } from '../modules/device-notification/entities';
|
||||
import { UserNotificationEntity } from '../modules/user/entities';
|
||||
import { DeviceNotificationEntity } from '../modules/device/entities';
|
||||
import { RegionEntity } from '../modules/region/entities';
|
||||
import { TimeZoneEntity } from '../modules/timezone/entities';
|
||||
|
||||
|
@ -0,0 +1,114 @@
|
||||
import { SnakeNamingStrategy } from './snack-naming.strategy';
|
||||
import { snakeCase } from 'typeorm/util/StringUtils';
|
||||
|
||||
describe('SnakeNamingStrategy', () => {
|
||||
let strategy: SnakeNamingStrategy;
|
||||
|
||||
beforeEach(() => {
|
||||
strategy = new SnakeNamingStrategy();
|
||||
});
|
||||
|
||||
it('should be defined', () => {
|
||||
expect(strategy).toBeDefined();
|
||||
});
|
||||
|
||||
describe('tableName', () => {
|
||||
it('should use customName if provided', () => {
|
||||
const className = 'User';
|
||||
const customName = 'users_table';
|
||||
expect(strategy.tableName(className, customName)).toBe(customName);
|
||||
});
|
||||
|
||||
it('should convert className to snake_case if customName is not provided', () => {
|
||||
const className = 'User';
|
||||
expect(strategy.tableName(className, '')).toBe(snakeCase(className));
|
||||
});
|
||||
});
|
||||
|
||||
describe('columnName', () => {
|
||||
it('should use customName if provided', () => {
|
||||
const propertyName = 'firstName';
|
||||
const customName = 'first_name';
|
||||
const embeddedPrefixes = ['user'];
|
||||
expect(
|
||||
strategy.columnName(propertyName, customName, embeddedPrefixes),
|
||||
).toBe(snakeCase(embeddedPrefixes.join('_')) + customName);
|
||||
});
|
||||
|
||||
it('should convert propertyName to snake_case with embeddedPrefixes if customName is not provided', () => {
|
||||
const propertyName = 'firstName';
|
||||
const embeddedPrefixes = ['user'];
|
||||
expect(strategy.columnName(propertyName, '', embeddedPrefixes)).toBe(
|
||||
snakeCase(embeddedPrefixes.join('_')) + snakeCase(propertyName),
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
describe('relationName', () => {
|
||||
it('should convert propertyName to snake_case', () => {
|
||||
const propertyName = 'profilePicture';
|
||||
expect(strategy.relationName(propertyName)).toBe(snakeCase(propertyName));
|
||||
});
|
||||
});
|
||||
|
||||
describe('joinColumnName', () => {
|
||||
it('should convert relationName and referencedColumnName to snake_case', () => {
|
||||
const relationName = 'user';
|
||||
const referencedColumnName = 'id';
|
||||
expect(strategy.joinColumnName(relationName, referencedColumnName)).toBe(
|
||||
snakeCase(`${relationName}_${referencedColumnName}`),
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
describe('joinTableName', () => {
|
||||
it('should convert table names and property name to snake_case', () => {
|
||||
const firstTableName = 'users';
|
||||
const secondTableName = 'roles';
|
||||
const firstPropertyName = 'userRoles';
|
||||
expect(
|
||||
strategy.joinTableName(
|
||||
firstTableName,
|
||||
secondTableName,
|
||||
firstPropertyName,
|
||||
),
|
||||
).toBe(
|
||||
snakeCase(
|
||||
`${firstTableName}_${firstPropertyName.replaceAll(/\./gi, '_')}_${secondTableName}`,
|
||||
),
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
describe('joinTableColumnName', () => {
|
||||
it('should use columnName if provided', () => {
|
||||
const tableName = 'user_roles';
|
||||
const propertyName = 'user';
|
||||
const columnName = 'role';
|
||||
expect(
|
||||
strategy.joinTableColumnName(tableName, propertyName, columnName),
|
||||
).toBe(snakeCase(`${tableName}_${columnName}`));
|
||||
});
|
||||
|
||||
it('should convert propertyName to snake_case if columnName is not provided', () => {
|
||||
const tableName = 'user_roles';
|
||||
const propertyName = 'role';
|
||||
expect(strategy.joinTableColumnName(tableName, propertyName)).toBe(
|
||||
snakeCase(`${tableName}_${propertyName}`),
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
describe('classTableInheritanceParentColumnName', () => {
|
||||
it('should convert parentTableName and parentTableIdPropertyName to snake_case', () => {
|
||||
const parentTableName = 'users';
|
||||
const parentTableIdPropertyName = 'id';
|
||||
expect(
|
||||
strategy.classTableInheritanceParentColumnName(
|
||||
parentTableName,
|
||||
parentTableIdPropertyName,
|
||||
),
|
||||
).toBe(snakeCase(`${parentTableName}_${parentTableIdPropertyName}`));
|
||||
});
|
||||
});
|
||||
});
|
86
libs/common/src/helper/camelCaseConverter.spec.ts
Normal file
86
libs/common/src/helper/camelCaseConverter.spec.ts
Normal file
@ -0,0 +1,86 @@
|
||||
import { convertKeysToCamelCase } from './camelCaseConverter';
|
||||
|
||||
describe('convertKeysToCamelCase', () => {
|
||||
it('should return the same value if not an object or array', () => {
|
||||
expect(convertKeysToCamelCase(null)).toBeNull();
|
||||
expect(convertKeysToCamelCase(undefined)).toBeUndefined();
|
||||
expect(convertKeysToCamelCase(123)).toBe(123);
|
||||
expect(convertKeysToCamelCase('string')).toBe('string');
|
||||
expect(convertKeysToCamelCase(true)).toBe(true);
|
||||
expect(convertKeysToCamelCase(false)).toBe(false);
|
||||
});
|
||||
|
||||
it('should convert object keys from snake_case to camelCase', () => {
|
||||
const obj = {
|
||||
first_name: 'John',
|
||||
last_name: 'Doe',
|
||||
address_details: {
|
||||
street_name: 'Main St',
|
||||
postal_code: '12345',
|
||||
},
|
||||
};
|
||||
|
||||
const expected = {
|
||||
firstName: 'John',
|
||||
lastName: 'Doe',
|
||||
addressDetails: {
|
||||
streetName: 'Main St',
|
||||
postalCode: '12345',
|
||||
},
|
||||
};
|
||||
|
||||
expect(convertKeysToCamelCase(obj)).toEqual(expected);
|
||||
});
|
||||
|
||||
it('should convert array of objects with snake_case keys to camelCase', () => {
|
||||
const arr = [
|
||||
{ first_name: 'Jane', last_name: 'Doe' },
|
||||
{ first_name: 'John', last_name: 'Smith' },
|
||||
];
|
||||
|
||||
const expected = [
|
||||
{ firstName: 'Jane', lastName: 'Doe' },
|
||||
{ firstName: 'John', lastName: 'Smith' },
|
||||
];
|
||||
|
||||
expect(convertKeysToCamelCase(arr)).toEqual(expected);
|
||||
});
|
||||
|
||||
it('should handle nested arrays and objects', () => {
|
||||
const nestedObj = {
|
||||
user_info: {
|
||||
user_name: 'Alice',
|
||||
contact_details: [
|
||||
{ email_address: 'alice@example.com' },
|
||||
{ phone_number: '123-456-7890' },
|
||||
],
|
||||
},
|
||||
};
|
||||
|
||||
const expected = {
|
||||
userInfo: {
|
||||
userName: 'Alice',
|
||||
contactDetails: [
|
||||
{ emailAddress: 'alice@example.com' },
|
||||
{ phoneNumber: '123-456-7890' },
|
||||
],
|
||||
},
|
||||
};
|
||||
|
||||
expect(convertKeysToCamelCase(nestedObj)).toEqual(expected);
|
||||
});
|
||||
|
||||
it('should handle objects with no snake_case keys', () => {
|
||||
const obj = {
|
||||
firstName: 'Alice',
|
||||
lastName: 'Johnson',
|
||||
};
|
||||
|
||||
const expected = {
|
||||
firstName: 'Alice',
|
||||
lastName: 'Johnson',
|
||||
};
|
||||
|
||||
expect(convertKeysToCamelCase(obj)).toEqual(expected);
|
||||
});
|
||||
});
|
@ -7,8 +7,8 @@ import { TuyaWebSocketService } from './services/tuya.web.socket.service';
|
||||
|
||||
import { OneSignalService } from './services/onesignal.service';
|
||||
import { DeviceMessagesService } from './services/device.messages.service';
|
||||
import { DeviceNotificationRepositoryModule } from '../modules/device-notification/device.notification.module';
|
||||
import { DeviceNotificationRepository } from '../modules/device-notification/repositories';
|
||||
import { DeviceRepositoryModule } from '../modules/device/device.repository.module';
|
||||
import { DeviceNotificationRepository } from '../modules/device/repositories';
|
||||
import { DeviceStatusFirebaseModule } from '../firebase/devices-status/devices-status.module';
|
||||
|
||||
@Global()
|
||||
@ -26,7 +26,7 @@ import { DeviceStatusFirebaseModule } from '../firebase/devices-status/devices-s
|
||||
controllers: [],
|
||||
imports: [
|
||||
SpaceRepositoryModule,
|
||||
DeviceNotificationRepositoryModule,
|
||||
DeviceRepositoryModule,
|
||||
DeviceStatusFirebaseModule,
|
||||
],
|
||||
})
|
||||
|
@ -1,5 +1,5 @@
|
||||
import { Injectable } from '@nestjs/common';
|
||||
import { DeviceNotificationRepository } from '@app/common/modules/device-notification/repositories';
|
||||
import { DeviceNotificationRepository } from '@app/common/modules/device/repositories';
|
||||
import { OneSignalService } from './onesignal.service';
|
||||
|
||||
@Injectable()
|
||||
|
99
libs/common/src/helper/services/helper.hash.service.spec.ts
Normal file
99
libs/common/src/helper/services/helper.hash.service.spec.ts
Normal file
@ -0,0 +1,99 @@
|
||||
import { HelperHashService } from './helper.hash.service';
|
||||
import { enc, SHA256 } from 'crypto-js';
|
||||
describe('HelperHashService', () => {
|
||||
let service: HelperHashService;
|
||||
const secretKey = '12345678901234567890123456789012';
|
||||
const iv = '1234567890123456';
|
||||
const password = 'password123';
|
||||
let salt: string;
|
||||
let hashedPassword: string;
|
||||
|
||||
beforeEach(() => {
|
||||
service = new HelperHashService();
|
||||
salt = service.randomSalt(10);
|
||||
hashedPassword = service.bcrypt(password, salt);
|
||||
});
|
||||
|
||||
it('should be defined', () => {
|
||||
expect(service).toBeDefined();
|
||||
});
|
||||
|
||||
describe('randomSalt', () => {
|
||||
it('should generate a salt of the specified length', () => {
|
||||
expect(service.randomSalt(10)).toHaveLength(29);
|
||||
});
|
||||
});
|
||||
|
||||
describe('bcrypt', () => {
|
||||
it('should hash the password with the given salt', () => {
|
||||
expect(service.bcrypt(password, salt)).toBe(hashedPassword);
|
||||
});
|
||||
});
|
||||
|
||||
describe('bcryptCompare', () => {
|
||||
it('should return true for correct password comparison', () => {
|
||||
expect(service.bcryptCompare(password, hashedPassword)).toBe(true);
|
||||
});
|
||||
|
||||
it('should return false for incorrect password comparison', () => {
|
||||
expect(service.bcryptCompare('wrongpassword', hashedPassword)).toBe(
|
||||
false,
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
describe('sha256', () => {
|
||||
it('should hash a string using SHA256', () => {
|
||||
const hash = SHA256(password).toString(enc.Hex);
|
||||
expect(service.sha256(password)).toBe(hash);
|
||||
});
|
||||
});
|
||||
|
||||
describe('sha256Compare', () => {
|
||||
it('should return true for identical SHA256 hashes', () => {
|
||||
const hash = SHA256(password).toString(enc.Hex);
|
||||
expect(service.sha256Compare(hash, hash)).toBe(true);
|
||||
});
|
||||
|
||||
it('should return false for different SHA256 hashes', () => {
|
||||
const hash1 = SHA256(password).toString(enc.Hex);
|
||||
const hash2 = SHA256('anotherpassword').toString(enc.Hex);
|
||||
expect(service.sha256Compare(hash1, hash2)).toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
describe('encryptPassword', () => {
|
||||
it('should encrypt a password with the given secret key', () => {
|
||||
const encrypted = service.encryptPassword(password, secretKey);
|
||||
const decrypted = service.decryptPassword(encrypted, secretKey);
|
||||
expect(decrypted).toBe('trx8g6gi');
|
||||
});
|
||||
});
|
||||
|
||||
describe('decryptPassword', () => {
|
||||
it('should decrypt an encrypted password with the given secret key', () => {
|
||||
const encrypted = service.encryptPassword(password, secretKey);
|
||||
const decrypted = service.decryptPassword(encrypted, secretKey);
|
||||
expect(decrypted).toBe('trx8g6gi');
|
||||
});
|
||||
});
|
||||
|
||||
describe('aes256Encrypt', () => {
|
||||
it('should encrypt data with AES-256 and return the ciphertext', () => {
|
||||
const data = { key: 'value' };
|
||||
const encrypted = service.aes256Encrypt(data, secretKey, iv);
|
||||
expect(encrypted).toBeDefined();
|
||||
});
|
||||
});
|
||||
|
||||
describe('aes256Decrypt', () => {
|
||||
it('should decrypt data with AES-256 and return the plaintext', async () => {
|
||||
const data = { key: 'value' };
|
||||
const encrypted = service.aes256Encrypt(data, secretKey, iv);
|
||||
const decrypted = service.aes256Decrypt(encrypted, secretKey, iv);
|
||||
expect(decrypted).toBeDefined();
|
||||
expect(() => JSON.parse(decrypted)).not.toThrow();
|
||||
expect(JSON.parse(decrypted)).toEqual(data);
|
||||
});
|
||||
});
|
||||
});
|
54
libs/common/src/helper/snakeCaseConverter.spec.ts
Normal file
54
libs/common/src/helper/snakeCaseConverter.spec.ts
Normal file
@ -0,0 +1,54 @@
|
||||
import { convertKeysToSnakeCase } from './snakeCaseConverter';
|
||||
|
||||
describe('convertKeysToSnakeCase', () => {
|
||||
it('should convert single level object keys to snake case', () => {
|
||||
const input = { camelCase: 'value', anotherKey: 'anotherValue' };
|
||||
const expected = { camel_case: 'value', another_key: 'anotherValue' };
|
||||
expect(convertKeysToSnakeCase(input)).toEqual(expected);
|
||||
});
|
||||
|
||||
it('should convert nested object keys to snake case', () => {
|
||||
const input = {
|
||||
camelCaseKey: 'value',
|
||||
nestedObject: {
|
||||
nestedCamelCase: 'nestedValue',
|
||||
arrayOfObjects: [
|
||||
{ arrayCamelCase: 'arrayValue' },
|
||||
{ anotherCamelCase: 'anotherValue' },
|
||||
],
|
||||
},
|
||||
};
|
||||
const expected = {
|
||||
camel_case_key: 'value',
|
||||
nested_object: {
|
||||
nested_camel_case: 'nestedValue',
|
||||
array_of_objects: [
|
||||
{ array_camel_case: 'arrayValue' },
|
||||
{ another_camel_case: 'anotherValue' },
|
||||
],
|
||||
},
|
||||
};
|
||||
expect(convertKeysToSnakeCase(input)).toEqual(expected);
|
||||
});
|
||||
|
||||
it('should handle arrays of objects', () => {
|
||||
const input = [{ camelCaseItem: 'value' }, { anotherItem: 'anotherValue' }];
|
||||
const expected = [
|
||||
{ camel_case_item: 'value' },
|
||||
{ another_item: 'anotherValue' },
|
||||
];
|
||||
expect(convertKeysToSnakeCase(input)).toEqual(expected);
|
||||
});
|
||||
|
||||
it('should handle empty objects and arrays', () => {
|
||||
expect(convertKeysToSnakeCase({})).toEqual({});
|
||||
expect(convertKeysToSnakeCase([])).toEqual([]);
|
||||
});
|
||||
|
||||
it('should handle primitive values without modification', () => {
|
||||
expect(convertKeysToSnakeCase('string')).toEqual('string');
|
||||
expect(convertKeysToSnakeCase(123)).toEqual(123);
|
||||
expect(convertKeysToSnakeCase(null)).toEqual(null);
|
||||
expect(convertKeysToSnakeCase(undefined)).toEqual(undefined);
|
||||
});
|
||||
});
|
@ -1,10 +0,0 @@
|
||||
import { Module } from '@nestjs/common';
|
||||
import { TypeOrmModule } from '@nestjs/typeorm';
|
||||
import { DeviceNotificationEntity } from './entities';
|
||||
@Module({
|
||||
providers: [],
|
||||
exports: [],
|
||||
controllers: [],
|
||||
imports: [TypeOrmModule.forFeature([DeviceNotificationEntity])],
|
||||
})
|
||||
export class DeviceNotificationRepositoryModule {}
|
@ -1,15 +0,0 @@
|
||||
import { IsNotEmpty, IsString } from 'class-validator';
|
||||
|
||||
export class DeviceNotificationDto {
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
public uuid: string;
|
||||
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
public userUuid: string;
|
||||
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
public deviceUuid: string;
|
||||
}
|
@ -1 +0,0 @@
|
||||
export * from './device.notification.dto';
|
@ -1,33 +0,0 @@
|
||||
import { Column, Entity, ManyToOne, Unique } from 'typeorm';
|
||||
import { AbstractEntity } from '../../abstract/entities/abstract.entity';
|
||||
import { DeviceNotificationDto } from '../dtos';
|
||||
import { DeviceEntity } from '../../device/entities';
|
||||
import { UserEntity } from '../../user/entities';
|
||||
|
||||
@Entity({ name: 'device-notification' })
|
||||
@Unique(['userUuid', 'deviceUuid'])
|
||||
export class DeviceNotificationEntity extends AbstractEntity<DeviceNotificationDto> {
|
||||
@Column({
|
||||
nullable: false,
|
||||
})
|
||||
public userUuid: string;
|
||||
|
||||
@Column({
|
||||
nullable: false,
|
||||
})
|
||||
deviceUuid: string;
|
||||
|
||||
@ManyToOne(() => DeviceEntity, (device) => device.permission, {
|
||||
nullable: false,
|
||||
})
|
||||
device: DeviceEntity;
|
||||
|
||||
@ManyToOne(() => UserEntity, (user) => user.userPermission, {
|
||||
nullable: false,
|
||||
})
|
||||
user: UserEntity;
|
||||
constructor(partial: Partial<DeviceNotificationEntity>) {
|
||||
super();
|
||||
Object.assign(this, partial);
|
||||
}
|
||||
}
|
@ -1 +0,0 @@
|
||||
export * from './device.notification.entity';
|
@ -1,10 +0,0 @@
|
||||
import { DataSource, Repository } from 'typeorm';
|
||||
import { Injectable } from '@nestjs/common';
|
||||
import { DeviceNotificationEntity } from '../entities';
|
||||
|
||||
@Injectable()
|
||||
export class DeviceNotificationRepository extends Repository<DeviceNotificationEntity> {
|
||||
constructor(private dataSource: DataSource) {
|
||||
super(DeviceNotificationEntity, dataSource.createEntityManager());
|
||||
}
|
||||
}
|
@ -1 +0,0 @@
|
||||
export * from './device.notification.repository';
|
@ -1,10 +0,0 @@
|
||||
import { Module } from '@nestjs/common';
|
||||
import { TypeOrmModule } from '@nestjs/typeorm';
|
||||
import { DeviceUserPermissionEntity } from './entities';
|
||||
@Module({
|
||||
providers: [],
|
||||
exports: [],
|
||||
controllers: [],
|
||||
imports: [TypeOrmModule.forFeature([DeviceUserPermissionEntity])],
|
||||
})
|
||||
export class DeviceUserPermissionRepositoryModule {}
|
@ -1,19 +0,0 @@
|
||||
import { IsNotEmpty, IsString } from 'class-validator';
|
||||
|
||||
export class DeviceUserPermissionDto {
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
public uuid: string;
|
||||
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
public userUuid: string;
|
||||
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
public deviceUuid: string;
|
||||
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
public permissionTypeUuid: string;
|
||||
}
|
@ -1 +0,0 @@
|
||||
export * from './device.user.permission.dto';
|
@ -1,43 +0,0 @@
|
||||
import { Column, Entity, ManyToOne, Unique } from 'typeorm';
|
||||
import { AbstractEntity } from '../../abstract/entities/abstract.entity';
|
||||
import { DeviceUserPermissionDto } from '../dtos';
|
||||
import { PermissionTypeEntity } from '../../permission/entities';
|
||||
import { DeviceEntity } from '../../device/entities';
|
||||
import { UserEntity } from '../../user/entities';
|
||||
|
||||
@Entity({ name: 'device-user-permission' })
|
||||
@Unique(['userUuid', 'deviceUuid'])
|
||||
export class DeviceUserPermissionEntity extends AbstractEntity<DeviceUserPermissionDto> {
|
||||
@Column({
|
||||
nullable: false,
|
||||
})
|
||||
public userUuid: string;
|
||||
|
||||
@Column({
|
||||
nullable: false,
|
||||
})
|
||||
deviceUuid: string;
|
||||
|
||||
@ManyToOne(() => DeviceEntity, (device) => device.permission, {
|
||||
nullable: false,
|
||||
})
|
||||
device: DeviceEntity;
|
||||
|
||||
@ManyToOne(
|
||||
() => PermissionTypeEntity,
|
||||
(permissionType) => permissionType.permission,
|
||||
{
|
||||
nullable: false,
|
||||
},
|
||||
)
|
||||
permissionType: PermissionTypeEntity;
|
||||
|
||||
@ManyToOne(() => UserEntity, (user) => user.userPermission, {
|
||||
nullable: false,
|
||||
})
|
||||
user: UserEntity;
|
||||
constructor(partial: Partial<DeviceUserPermissionEntity>) {
|
||||
super();
|
||||
Object.assign(this, partial);
|
||||
}
|
||||
}
|
@ -1 +0,0 @@
|
||||
export * from './device.user.permission.entity';
|
@ -1,10 +0,0 @@
|
||||
import { DataSource, Repository } from 'typeorm';
|
||||
import { Injectable } from '@nestjs/common';
|
||||
import { DeviceUserPermissionEntity } from '../entities';
|
||||
|
||||
@Injectable()
|
||||
export class DeviceUserPermissionRepository extends Repository<DeviceUserPermissionEntity> {
|
||||
constructor(private dataSource: DataSource) {
|
||||
super(DeviceUserPermissionEntity, dataSource.createEntityManager());
|
||||
}
|
||||
}
|
@ -1 +0,0 @@
|
||||
export * from './device.user.permission.repository';
|
@ -1,11 +1,21 @@
|
||||
import { Module } from '@nestjs/common';
|
||||
import { TypeOrmModule } from '@nestjs/typeorm';
|
||||
import { DeviceEntity } from './entities';
|
||||
import {
|
||||
DeviceEntity,
|
||||
DeviceNotificationEntity,
|
||||
DeviceUserPermissionEntity,
|
||||
} from './entities';
|
||||
|
||||
@Module({
|
||||
providers: [],
|
||||
exports: [],
|
||||
controllers: [],
|
||||
imports: [TypeOrmModule.forFeature([DeviceEntity])],
|
||||
imports: [
|
||||
TypeOrmModule.forFeature([
|
||||
DeviceEntity,
|
||||
DeviceNotificationEntity,
|
||||
DeviceUserPermissionEntity,
|
||||
]),
|
||||
],
|
||||
})
|
||||
export class DeviceRepositoryModule {}
|
||||
|
@ -21,3 +21,35 @@ export class DeviceDto {
|
||||
@IsNotEmpty()
|
||||
productUuid: string;
|
||||
}
|
||||
|
||||
export class DeviceUserPermissionDto {
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
public uuid: string;
|
||||
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
public userUuid: string;
|
||||
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
public deviceUuid: string;
|
||||
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
public permissionTypeUuid: string;
|
||||
}
|
||||
|
||||
export class DeviceNotificationDto {
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
public uuid: string;
|
||||
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
public userUuid: string;
|
||||
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
public deviceUuid: string;
|
||||
}
|
||||
|
@ -1,11 +1,11 @@
|
||||
import { Column, Entity, ManyToOne, OneToMany, Unique, Index } from 'typeorm';
|
||||
import { AbstractEntity } from '../../abstract/entities/abstract.entity';
|
||||
import { DeviceDto } from '../dtos/device.dto';
|
||||
import { DeviceDto, DeviceUserPermissionDto } from '../dtos/device.dto';
|
||||
import { SpaceEntity } from '../../space/entities';
|
||||
import { ProductEntity } from '../../product/entities';
|
||||
import { DeviceUserPermissionEntity } from '../../device-user-permission/entities';
|
||||
import { DeviceNotificationEntity } from '../../device-notification/entities';
|
||||
import { UserEntity } from '../../user/entities';
|
||||
import { DeviceNotificationDto } from '../dtos';
|
||||
import { PermissionTypeEntity } from '../../permission/entities';
|
||||
|
||||
@Entity({ name: 'device' })
|
||||
@Unique(['deviceTuyaUuid'])
|
||||
@ -60,3 +60,68 @@ export class DeviceEntity extends AbstractEntity<DeviceDto> {
|
||||
Object.assign(this, partial);
|
||||
}
|
||||
}
|
||||
|
||||
@Entity({ name: 'device-notification' })
|
||||
@Unique(['userUuid', 'deviceUuid'])
|
||||
export class DeviceNotificationEntity extends AbstractEntity<DeviceNotificationDto> {
|
||||
@Column({
|
||||
nullable: false,
|
||||
})
|
||||
public userUuid: string;
|
||||
|
||||
@Column({
|
||||
nullable: false,
|
||||
})
|
||||
deviceUuid: string;
|
||||
|
||||
@ManyToOne(() => DeviceEntity, (device) => device.permission, {
|
||||
nullable: false,
|
||||
})
|
||||
device: DeviceEntity;
|
||||
|
||||
@ManyToOne(() => UserEntity, (user) => user.userPermission, {
|
||||
nullable: false,
|
||||
})
|
||||
user: UserEntity;
|
||||
constructor(partial: Partial<DeviceNotificationEntity>) {
|
||||
super();
|
||||
Object.assign(this, partial);
|
||||
}
|
||||
}
|
||||
|
||||
@Entity({ name: 'device-user-permission' })
|
||||
@Unique(['userUuid', 'deviceUuid'])
|
||||
export class DeviceUserPermissionEntity extends AbstractEntity<DeviceUserPermissionDto> {
|
||||
@Column({
|
||||
nullable: false,
|
||||
})
|
||||
public userUuid: string;
|
||||
|
||||
@Column({
|
||||
nullable: false,
|
||||
})
|
||||
deviceUuid: string;
|
||||
|
||||
@ManyToOne(() => DeviceEntity, (device) => device.permission, {
|
||||
nullable: false,
|
||||
})
|
||||
device: DeviceEntity;
|
||||
|
||||
@ManyToOne(
|
||||
() => PermissionTypeEntity,
|
||||
(permissionType) => permissionType.permission,
|
||||
{
|
||||
nullable: false,
|
||||
},
|
||||
)
|
||||
permissionType: PermissionTypeEntity;
|
||||
|
||||
@ManyToOne(() => UserEntity, (user) => user.userPermission, {
|
||||
nullable: false,
|
||||
})
|
||||
user: UserEntity;
|
||||
constructor(partial: Partial<DeviceUserPermissionEntity>) {
|
||||
super();
|
||||
Object.assign(this, partial);
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,10 @@
|
||||
import { DataSource, Repository } from 'typeorm';
|
||||
import { Injectable } from '@nestjs/common';
|
||||
import { DeviceEntity } from '../entities';
|
||||
import {
|
||||
DeviceEntity,
|
||||
DeviceNotificationEntity,
|
||||
DeviceUserPermissionEntity,
|
||||
} from '../entities';
|
||||
|
||||
@Injectable()
|
||||
export class DeviceRepository extends Repository<DeviceEntity> {
|
||||
@ -8,3 +12,15 @@ export class DeviceRepository extends Repository<DeviceEntity> {
|
||||
super(DeviceEntity, dataSource.createEntityManager());
|
||||
}
|
||||
}
|
||||
@Injectable()
|
||||
export class DeviceNotificationRepository extends Repository<DeviceNotificationEntity> {
|
||||
constructor(private dataSource: DataSource) {
|
||||
super(DeviceNotificationEntity, dataSource.createEntityManager());
|
||||
}
|
||||
}
|
||||
@Injectable()
|
||||
export class DeviceUserPermissionRepository extends Repository<DeviceUserPermissionEntity> {
|
||||
constructor(private dataSource: DataSource) {
|
||||
super(DeviceUserPermissionEntity, dataSource.createEntityManager());
|
||||
}
|
||||
}
|
||||
|
@ -2,7 +2,7 @@ import { Column, Entity, OneToMany } from 'typeorm';
|
||||
import { AbstractEntity } from '../../abstract/entities/abstract.entity';
|
||||
import { PermissionType } from '@app/common/constants/permission-type.enum';
|
||||
import { PermissionTypeDto } from '../dtos/permission.dto';
|
||||
import { DeviceUserPermissionEntity } from '../../device-user-permission/entities';
|
||||
import { DeviceUserPermissionEntity } from '../../device/entities';
|
||||
|
||||
@Entity({ name: 'permission-type' })
|
||||
export class PermissionTypeEntity extends AbstractEntity<PermissionTypeDto> {
|
||||
|
@ -2,7 +2,7 @@ import { Column, Entity, OneToMany, Unique } from 'typeorm';
|
||||
import { AbstractEntity } from '../../abstract/entities/abstract.entity';
|
||||
import { RoleTypeDto } from '../dtos/role.type.dto';
|
||||
import { RoleType } from '@app/common/constants/role.type.enum';
|
||||
import { UserRoleEntity } from '../../user-role/entities';
|
||||
import { UserRoleEntity } from '../../user/entities';
|
||||
|
||||
@Entity({ name: 'role-type' })
|
||||
@Unique(['type'])
|
||||
|
@ -1 +0,0 @@
|
||||
export * from './space.type.dto';
|
@ -1,11 +0,0 @@
|
||||
import { IsNotEmpty, IsString } from 'class-validator';
|
||||
|
||||
export class SpaceTypeDto {
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
public uuid: string;
|
||||
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
public type: string;
|
||||
}
|
@ -1 +0,0 @@
|
||||
export * from './space.type.entity';
|
@ -1,26 +0,0 @@
|
||||
import { Column, Entity, OneToMany } from 'typeorm';
|
||||
import { SpaceTypeDto } from '../dtos';
|
||||
import { AbstractEntity } from '../../abstract/entities/abstract.entity';
|
||||
import { SpaceEntity } from '../../space/entities';
|
||||
|
||||
@Entity({ name: 'space-type' })
|
||||
export class SpaceTypeEntity extends AbstractEntity<SpaceTypeDto> {
|
||||
@Column({
|
||||
type: 'uuid',
|
||||
default: () => 'gen_random_uuid()', // Use gen_random_uuid() for default value
|
||||
nullable: false,
|
||||
})
|
||||
public uuid: string;
|
||||
|
||||
@Column({
|
||||
nullable: false,
|
||||
})
|
||||
type: string;
|
||||
|
||||
@OneToMany(() => SpaceEntity, (space) => space.spaceType)
|
||||
spaces: SpaceEntity[];
|
||||
constructor(partial: Partial<SpaceTypeEntity>) {
|
||||
super();
|
||||
Object.assign(this, partial);
|
||||
}
|
||||
}
|
@ -1 +0,0 @@
|
||||
export * from './space.type.repository';
|
@ -1,10 +0,0 @@
|
||||
import { DataSource, Repository } from 'typeorm';
|
||||
import { Injectable } from '@nestjs/common';
|
||||
import { SpaceTypeEntity } from '../entities/space.type.entity';
|
||||
|
||||
@Injectable()
|
||||
export class SpaceTypeRepository extends Repository<SpaceTypeEntity> {
|
||||
constructor(private dataSource: DataSource) {
|
||||
super(SpaceTypeEntity, dataSource.createEntityManager());
|
||||
}
|
||||
}
|
@ -1,11 +0,0 @@
|
||||
import { Module } from '@nestjs/common';
|
||||
import { TypeOrmModule } from '@nestjs/typeorm';
|
||||
import { SpaceTypeEntity } from './entities/space.type.entity';
|
||||
|
||||
@Module({
|
||||
providers: [],
|
||||
exports: [],
|
||||
controllers: [],
|
||||
imports: [TypeOrmModule.forFeature([SpaceTypeEntity])],
|
||||
})
|
||||
export class SpaceTypeRepositoryModule {}
|
@ -21,3 +21,13 @@ export class SpaceDto {
|
||||
@IsNotEmpty()
|
||||
public invitationCode: string;
|
||||
}
|
||||
|
||||
export class SpaceTypeDto {
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
public uuid: string;
|
||||
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
public type: string;
|
||||
}
|
||||
|
@ -1,16 +1,37 @@
|
||||
import { Column, Entity, ManyToOne, OneToMany, Unique } from 'typeorm';
|
||||
import { SpaceDto } from '../dtos';
|
||||
import { SpaceDto, SpaceTypeDto } from '../dtos';
|
||||
import { AbstractEntity } from '../../abstract/entities/abstract.entity';
|
||||
import { SpaceTypeEntity } from '../../space-type/entities';
|
||||
import { UserSpaceEntity } from '../../user-space/entities';
|
||||
import { UserSpaceEntity } from '../../user/entities';
|
||||
import { DeviceEntity } from '../../device/entities';
|
||||
|
||||
@Entity({ name: 'space-type' })
|
||||
export class SpaceTypeEntity extends AbstractEntity<SpaceTypeDto> {
|
||||
@Column({
|
||||
type: 'uuid',
|
||||
default: () => 'gen_random_uuid()',
|
||||
nullable: false,
|
||||
})
|
||||
public uuid: string;
|
||||
|
||||
@Column({
|
||||
nullable: false,
|
||||
})
|
||||
type: string;
|
||||
|
||||
@OneToMany(() => SpaceEntity, (space) => space.spaceType)
|
||||
spaces: SpaceEntity[];
|
||||
constructor(partial: Partial<SpaceTypeEntity>) {
|
||||
super();
|
||||
Object.assign(this, partial);
|
||||
}
|
||||
}
|
||||
|
||||
@Entity({ name: 'space' })
|
||||
@Unique(['invitationCode'])
|
||||
export class SpaceEntity extends AbstractEntity<SpaceDto> {
|
||||
@Column({
|
||||
type: 'uuid',
|
||||
default: () => 'gen_random_uuid()', // Use gen_random_uuid() for default value
|
||||
default: () => 'gen_random_uuid()',
|
||||
nullable: false,
|
||||
})
|
||||
public uuid: string;
|
||||
|
@ -1,6 +1,6 @@
|
||||
import { DataSource, Repository } from 'typeorm';
|
||||
import { Injectable } from '@nestjs/common';
|
||||
import { SpaceEntity } from '../entities/space.entity';
|
||||
import { SpaceEntity, SpaceTypeEntity } from '../entities';
|
||||
|
||||
@Injectable()
|
||||
export class SpaceRepository extends Repository<SpaceEntity> {
|
||||
@ -8,3 +8,10 @@ export class SpaceRepository extends Repository<SpaceEntity> {
|
||||
super(SpaceEntity, dataSource.createEntityManager());
|
||||
}
|
||||
}
|
||||
|
||||
@Injectable()
|
||||
export class SpaceTypeRepository extends Repository<SpaceTypeEntity> {
|
||||
constructor(private dataSource: DataSource) {
|
||||
super(SpaceTypeEntity, dataSource.createEntityManager());
|
||||
}
|
||||
}
|
||||
|
@ -1,11 +1,11 @@
|
||||
import { Module } from '@nestjs/common';
|
||||
import { TypeOrmModule } from '@nestjs/typeorm';
|
||||
import { SpaceEntity } from './entities/space.entity';
|
||||
import { SpaceEntity, SpaceTypeEntity } from './entities';
|
||||
|
||||
@Module({
|
||||
providers: [],
|
||||
exports: [],
|
||||
controllers: [],
|
||||
imports: [TypeOrmModule.forFeature([SpaceEntity])],
|
||||
imports: [TypeOrmModule.forFeature([SpaceEntity, SpaceTypeEntity])],
|
||||
})
|
||||
export class SpaceRepositoryModule {}
|
||||
|
@ -1 +0,0 @@
|
||||
export * from './user.notification.dto';
|
@ -1,19 +0,0 @@
|
||||
import { IsBoolean, IsNotEmpty, IsString } from 'class-validator';
|
||||
|
||||
export class UserNotificationDto {
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
public uuid: string;
|
||||
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
public userUuid: string;
|
||||
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
public subscriptionUuid: string;
|
||||
|
||||
@IsBoolean()
|
||||
@IsNotEmpty()
|
||||
public active: boolean;
|
||||
}
|
@ -1 +0,0 @@
|
||||
export * from './user.notification.entity';
|
@ -1,27 +0,0 @@
|
||||
import { Column, Entity, ManyToOne, Unique } from 'typeorm';
|
||||
import { AbstractEntity } from '../../abstract/entities/abstract.entity';
|
||||
import { UserNotificationDto } from '../dtos';
|
||||
import { UserEntity } from '../../user/entities';
|
||||
|
||||
@Entity({ name: 'user-notification' })
|
||||
@Unique(['user', 'subscriptionUuid'])
|
||||
export class UserNotificationEntity extends AbstractEntity<UserNotificationDto> {
|
||||
@ManyToOne(() => UserEntity, (user) => user.roles, {
|
||||
nullable: false,
|
||||
})
|
||||
user: UserEntity;
|
||||
@Column({
|
||||
nullable: false,
|
||||
})
|
||||
subscriptionUuid: string;
|
||||
|
||||
@Column({
|
||||
nullable: false,
|
||||
default: true,
|
||||
})
|
||||
active: boolean;
|
||||
constructor(partial: Partial<UserNotificationEntity>) {
|
||||
super();
|
||||
Object.assign(this, partial);
|
||||
}
|
||||
}
|
@ -1 +0,0 @@
|
||||
export * from './user.notification.repository';
|
@ -1,10 +0,0 @@
|
||||
import { DataSource, Repository } from 'typeorm';
|
||||
import { Injectable } from '@nestjs/common';
|
||||
import { UserNotificationEntity } from '../entities';
|
||||
|
||||
@Injectable()
|
||||
export class UserNotificationRepository extends Repository<UserNotificationEntity> {
|
||||
constructor(private dataSource: DataSource) {
|
||||
super(UserNotificationEntity, dataSource.createEntityManager());
|
||||
}
|
||||
}
|
@ -1,10 +0,0 @@
|
||||
import { Module } from '@nestjs/common';
|
||||
import { TypeOrmModule } from '@nestjs/typeorm';
|
||||
import { UserNotificationEntity } from './entities';
|
||||
@Module({
|
||||
providers: [],
|
||||
exports: [],
|
||||
controllers: [],
|
||||
imports: [TypeOrmModule.forFeature([UserNotificationEntity])],
|
||||
})
|
||||
export class UserNotificationRepositoryModule {}
|
@ -1 +0,0 @@
|
||||
export * from './user-otp.dto';
|
@ -1,19 +0,0 @@
|
||||
import { IsNotEmpty, IsString } from 'class-validator';
|
||||
|
||||
export class UserOtpDto {
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
public uuid: string;
|
||||
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
public email: string;
|
||||
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
public otpCode: string;
|
||||
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
public expiryTime: string;
|
||||
}
|
@ -1 +0,0 @@
|
||||
export * from './user-otp.entity';
|
@ -1,34 +0,0 @@
|
||||
import { Column, Entity } from 'typeorm';
|
||||
import { AbstractEntity } from '../../abstract/entities/abstract.entity';
|
||||
import { UserOtpDto } from '../dtos';
|
||||
import { OtpType } from '../../../../src/constants/otp-type.enum';
|
||||
|
||||
@Entity({ name: 'user-otp' })
|
||||
export class UserOtpEntity extends AbstractEntity<UserOtpDto> {
|
||||
@Column({
|
||||
type: 'uuid',
|
||||
default: () => 'gen_random_uuid()',
|
||||
nullable: false,
|
||||
})
|
||||
public uuid: string;
|
||||
|
||||
@Column({ nullable: false })
|
||||
email: string;
|
||||
|
||||
@Column({ nullable: false })
|
||||
otpCode: string;
|
||||
|
||||
@Column({ nullable: false })
|
||||
expiryTime: Date;
|
||||
|
||||
@Column({
|
||||
type: 'enum',
|
||||
enum: Object.values(OtpType),
|
||||
})
|
||||
type: OtpType;
|
||||
|
||||
constructor(partial: Partial<UserOtpEntity>) {
|
||||
super();
|
||||
Object.assign(this, partial);
|
||||
}
|
||||
}
|
@ -1,10 +0,0 @@
|
||||
import { DataSource, Repository } from 'typeorm';
|
||||
import { Injectable } from '@nestjs/common';
|
||||
import { UserOtpEntity } from '../entities';
|
||||
|
||||
@Injectable()
|
||||
export class UserOtpRepository extends Repository<UserOtpEntity> {
|
||||
constructor(private dataSource: DataSource) {
|
||||
super(UserOtpEntity, dataSource.createEntityManager());
|
||||
}
|
||||
}
|
@ -1,11 +0,0 @@
|
||||
import { Module } from '@nestjs/common';
|
||||
import { TypeOrmModule } from '@nestjs/typeorm';
|
||||
import { UserOtpEntity } from './entities';
|
||||
|
||||
@Module({
|
||||
providers: [],
|
||||
exports: [],
|
||||
controllers: [],
|
||||
imports: [TypeOrmModule.forFeature([UserOtpEntity])],
|
||||
})
|
||||
export class UserOtpRepositoryModule {}
|
@ -1 +0,0 @@
|
||||
export * from './user.role.dto';
|
@ -1,15 +0,0 @@
|
||||
import { IsNotEmpty, IsString } from 'class-validator';
|
||||
|
||||
export class UserRoleDto {
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
public uuid: string;
|
||||
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
public userUuid: string;
|
||||
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
public roleTypeUuid: string;
|
||||
}
|
@ -1 +0,0 @@
|
||||
export * from './user.role.entity';
|
@ -1,24 +0,0 @@
|
||||
import { Entity, ManyToOne, Unique } from 'typeorm';
|
||||
import { AbstractEntity } from '../../abstract/entities/abstract.entity';
|
||||
import { UserRoleDto } from '../dtos';
|
||||
import { UserEntity } from '../../user/entities';
|
||||
import { RoleTypeEntity } from '../../role-type/entities';
|
||||
|
||||
@Entity({ name: 'user-role' })
|
||||
@Unique(['user', 'roleType'])
|
||||
export class UserRoleEntity extends AbstractEntity<UserRoleDto> {
|
||||
@ManyToOne(() => UserEntity, (user) => user.roles, {
|
||||
nullable: false,
|
||||
})
|
||||
user: UserEntity;
|
||||
|
||||
@ManyToOne(() => RoleTypeEntity, (roleType) => roleType.roles, {
|
||||
nullable: false,
|
||||
})
|
||||
roleType: RoleTypeEntity;
|
||||
|
||||
constructor(partial: Partial<UserRoleEntity>) {
|
||||
super();
|
||||
Object.assign(this, partial);
|
||||
}
|
||||
}
|
@ -1 +0,0 @@
|
||||
export * from './user.role.repository';
|
@ -1,10 +0,0 @@
|
||||
import { DataSource, Repository } from 'typeorm';
|
||||
import { Injectable } from '@nestjs/common';
|
||||
import { UserRoleEntity } from '../entities';
|
||||
|
||||
@Injectable()
|
||||
export class UserRoleRepository extends Repository<UserRoleEntity> {
|
||||
constructor(private dataSource: DataSource) {
|
||||
super(UserRoleEntity, dataSource.createEntityManager());
|
||||
}
|
||||
}
|
@ -1,10 +0,0 @@
|
||||
import { Module } from '@nestjs/common';
|
||||
import { TypeOrmModule } from '@nestjs/typeorm';
|
||||
import { UserRoleEntity } from './entities';
|
||||
@Module({
|
||||
providers: [],
|
||||
exports: [],
|
||||
controllers: [],
|
||||
imports: [TypeOrmModule.forFeature([UserRoleEntity])],
|
||||
})
|
||||
export class UserRoleRepositoryModule {}
|
@ -1 +0,0 @@
|
||||
export * from './user.space.dto';
|
@ -1,15 +0,0 @@
|
||||
import { IsNotEmpty, IsString } from 'class-validator';
|
||||
|
||||
export class UserSpaceDto {
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
public uuid: string;
|
||||
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
public spaceUuid: string;
|
||||
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
public userUuid: string;
|
||||
}
|
@ -1 +0,0 @@
|
||||
export * from './user.space.entity';
|
@ -1,29 +0,0 @@
|
||||
import { Column, Entity, ManyToOne, Unique } from 'typeorm';
|
||||
import { UserSpaceDto } from '../dtos';
|
||||
import { AbstractEntity } from '../../abstract/entities/abstract.entity';
|
||||
import { SpaceEntity } from '../../space/entities';
|
||||
import { UserEntity } from '../../user/entities';
|
||||
|
||||
@Entity({ name: 'user-space' })
|
||||
@Unique(['user', 'space'])
|
||||
export class UserSpaceEntity extends AbstractEntity<UserSpaceDto> {
|
||||
@Column({
|
||||
type: 'uuid',
|
||||
default: () => 'gen_random_uuid()', // Use gen_random_uuid() for default value
|
||||
nullable: false,
|
||||
})
|
||||
public uuid: string;
|
||||
|
||||
@ManyToOne(() => UserEntity, (user) => user.userSpaces, { nullable: false })
|
||||
user: UserEntity;
|
||||
|
||||
@ManyToOne(() => SpaceEntity, (space) => space.userSpaces, {
|
||||
nullable: false,
|
||||
})
|
||||
space: SpaceEntity;
|
||||
|
||||
constructor(partial: Partial<UserSpaceEntity>) {
|
||||
super();
|
||||
Object.assign(this, partial);
|
||||
}
|
||||
}
|
@ -1 +0,0 @@
|
||||
export * from './user.space.repository';
|
@ -1,10 +0,0 @@
|
||||
import { DataSource, Repository } from 'typeorm';
|
||||
import { Injectable } from '@nestjs/common';
|
||||
import { UserSpaceEntity } from '../entities/user.space.entity';
|
||||
|
||||
@Injectable()
|
||||
export class UserSpaceRepository extends Repository<UserSpaceEntity> {
|
||||
constructor(private dataSource: DataSource) {
|
||||
super(UserSpaceEntity, dataSource.createEntityManager());
|
||||
}
|
||||
}
|
@ -1,11 +0,0 @@
|
||||
import { Module } from '@nestjs/common';
|
||||
import { TypeOrmModule } from '@nestjs/typeorm';
|
||||
import { UserSpaceEntity } from './entities/user.space.entity';
|
||||
|
||||
@Module({
|
||||
providers: [],
|
||||
exports: [],
|
||||
controllers: [],
|
||||
imports: [TypeOrmModule.forFeature([UserSpaceEntity])],
|
||||
})
|
||||
export class UserSpaceRepositoryModule {}
|
@ -1,4 +1,4 @@
|
||||
import { IsNotEmpty, IsString } from 'class-validator';
|
||||
import { IsBoolean, IsNotEmpty, IsString } from 'class-validator';
|
||||
|
||||
export class UserDto {
|
||||
@IsString()
|
||||
@ -21,3 +21,67 @@ export class UserDto {
|
||||
@IsNotEmpty()
|
||||
public lastName: string;
|
||||
}
|
||||
|
||||
export class UserNotificationDto {
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
public uuid: string;
|
||||
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
public userUuid: string;
|
||||
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
public subscriptionUuid: string;
|
||||
|
||||
@IsBoolean()
|
||||
@IsNotEmpty()
|
||||
public active: boolean;
|
||||
}
|
||||
|
||||
export class UserOtpDto {
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
public uuid: string;
|
||||
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
public email: string;
|
||||
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
public otpCode: string;
|
||||
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
public expiryTime: string;
|
||||
}
|
||||
|
||||
export class UserRoleDto {
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
public uuid: string;
|
||||
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
public userUuid: string;
|
||||
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
public roleTypeUuid: string;
|
||||
}
|
||||
|
||||
export class UserSpaceDto {
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
public uuid: string;
|
||||
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
public spaceUuid: string;
|
||||
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
public userUuid: string;
|
||||
}
|
||||
|
@ -1,15 +1,23 @@
|
||||
import { DeviceUserPermissionEntity } from '../../device-user-permission/entities/device.user.permission.entity';
|
||||
import { Column, Entity, ManyToOne, OneToMany } from 'typeorm';
|
||||
import { UserDto } from '../dtos';
|
||||
import { Column, Entity, ManyToOne, OneToMany, Unique } from 'typeorm';
|
||||
import {
|
||||
UserDto,
|
||||
UserNotificationDto,
|
||||
UserOtpDto,
|
||||
UserRoleDto,
|
||||
UserSpaceDto,
|
||||
} from '../dtos';
|
||||
import { AbstractEntity } from '../../abstract/entities/abstract.entity';
|
||||
import { UserSpaceEntity } from '../../user-space/entities';
|
||||
import { UserRoleEntity } from '../../user-role/entities';
|
||||
import { DeviceNotificationEntity } from '../../device-notification/entities';
|
||||
import { UserNotificationEntity } from '../../user-notification/entities';
|
||||
import { DeviceEntity } from '../../device/entities';
|
||||
import {
|
||||
DeviceEntity,
|
||||
DeviceNotificationEntity,
|
||||
DeviceUserPermissionEntity,
|
||||
} from '../../device/entities';
|
||||
import { defaultProfilePicture } from '@app/common/constants/default.profile.picture';
|
||||
import { RegionEntity } from '../../region/entities';
|
||||
import { TimeZoneEntity } from '../../timezone/entities';
|
||||
import { OtpType } from '../../../../src/constants/otp-type.enum';
|
||||
import { RoleTypeEntity } from '../../role-type/entities';
|
||||
import { SpaceEntity } from '../../space/entities';
|
||||
|
||||
@Entity({ name: 'user' })
|
||||
export class UserEntity extends AbstractEntity<UserDto> {
|
||||
@ -99,3 +107,99 @@ export class UserEntity extends AbstractEntity<UserDto> {
|
||||
Object.assign(this, partial);
|
||||
}
|
||||
}
|
||||
|
||||
@Entity({ name: 'user-notification' })
|
||||
@Unique(['user', 'subscriptionUuid'])
|
||||
export class UserNotificationEntity extends AbstractEntity<UserNotificationDto> {
|
||||
@ManyToOne(() => UserEntity, (user) => user.roles, {
|
||||
nullable: false,
|
||||
})
|
||||
user: UserEntity;
|
||||
@Column({
|
||||
nullable: false,
|
||||
})
|
||||
subscriptionUuid: string;
|
||||
|
||||
@Column({
|
||||
nullable: false,
|
||||
default: true,
|
||||
})
|
||||
active: boolean;
|
||||
constructor(partial: Partial<UserNotificationEntity>) {
|
||||
super();
|
||||
Object.assign(this, partial);
|
||||
}
|
||||
}
|
||||
|
||||
@Entity({ name: 'user-otp' })
|
||||
export class UserOtpEntity extends AbstractEntity<UserOtpDto> {
|
||||
@Column({
|
||||
type: 'uuid',
|
||||
default: () => 'gen_random_uuid()',
|
||||
nullable: false,
|
||||
})
|
||||
public uuid: string;
|
||||
|
||||
@Column({ nullable: false })
|
||||
email: string;
|
||||
|
||||
@Column({ nullable: false })
|
||||
otpCode: string;
|
||||
|
||||
@Column({ nullable: false })
|
||||
expiryTime: Date;
|
||||
|
||||
@Column({
|
||||
type: 'enum',
|
||||
enum: Object.values(OtpType),
|
||||
})
|
||||
type: OtpType;
|
||||
|
||||
constructor(partial: Partial<UserOtpEntity>) {
|
||||
super();
|
||||
Object.assign(this, partial);
|
||||
}
|
||||
}
|
||||
|
||||
@Entity({ name: 'user-role' })
|
||||
@Unique(['user', 'roleType'])
|
||||
export class UserRoleEntity extends AbstractEntity<UserRoleDto> {
|
||||
@ManyToOne(() => UserEntity, (user) => user.roles, {
|
||||
nullable: false,
|
||||
})
|
||||
user: UserEntity;
|
||||
|
||||
@ManyToOne(() => RoleTypeEntity, (roleType) => roleType.roles, {
|
||||
nullable: false,
|
||||
})
|
||||
roleType: RoleTypeEntity;
|
||||
|
||||
constructor(partial: Partial<UserRoleEntity>) {
|
||||
super();
|
||||
Object.assign(this, partial);
|
||||
}
|
||||
}
|
||||
|
||||
@Entity({ name: 'user-space' })
|
||||
@Unique(['user', 'space'])
|
||||
export class UserSpaceEntity extends AbstractEntity<UserSpaceDto> {
|
||||
@Column({
|
||||
type: 'uuid',
|
||||
default: () => 'gen_random_uuid()', // Use gen_random_uuid() for default value
|
||||
nullable: false,
|
||||
})
|
||||
public uuid: string;
|
||||
|
||||
@ManyToOne(() => UserEntity, (user) => user.userSpaces, { nullable: false })
|
||||
user: UserEntity;
|
||||
|
||||
@ManyToOne(() => SpaceEntity, (space) => space.userSpaces, {
|
||||
nullable: false,
|
||||
})
|
||||
space: SpaceEntity;
|
||||
|
||||
constructor(partial: Partial<UserSpaceEntity>) {
|
||||
super();
|
||||
Object.assign(this, partial);
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,12 @@
|
||||
import { DataSource, Repository } from 'typeorm';
|
||||
import { Injectable } from '@nestjs/common';
|
||||
import { UserEntity } from '../entities/user.entity';
|
||||
import {
|
||||
UserEntity,
|
||||
UserNotificationEntity,
|
||||
UserOtpEntity,
|
||||
UserRoleEntity,
|
||||
UserSpaceEntity,
|
||||
} from '../entities/';
|
||||
|
||||
@Injectable()
|
||||
export class UserRepository extends Repository<UserEntity> {
|
||||
@ -8,3 +14,31 @@ export class UserRepository extends Repository<UserEntity> {
|
||||
super(UserEntity, dataSource.createEntityManager());
|
||||
}
|
||||
}
|
||||
|
||||
@Injectable()
|
||||
export class UserNotificationRepository extends Repository<UserNotificationEntity> {
|
||||
constructor(private dataSource: DataSource) {
|
||||
super(UserNotificationEntity, dataSource.createEntityManager());
|
||||
}
|
||||
}
|
||||
|
||||
@Injectable()
|
||||
export class UserOtpRepository extends Repository<UserOtpEntity> {
|
||||
constructor(private dataSource: DataSource) {
|
||||
super(UserOtpEntity, dataSource.createEntityManager());
|
||||
}
|
||||
}
|
||||
|
||||
@Injectable()
|
||||
export class UserRoleRepository extends Repository<UserRoleEntity> {
|
||||
constructor(private dataSource: DataSource) {
|
||||
super(UserRoleEntity, dataSource.createEntityManager());
|
||||
}
|
||||
}
|
||||
|
||||
@Injectable()
|
||||
export class UserSpaceRepository extends Repository<UserSpaceEntity> {
|
||||
constructor(private dataSource: DataSource) {
|
||||
super(UserSpaceEntity, dataSource.createEntityManager());
|
||||
}
|
||||
}
|
||||
|
@ -1,11 +1,25 @@
|
||||
import { Module } from '@nestjs/common';
|
||||
import { TypeOrmModule } from '@nestjs/typeorm';
|
||||
import { UserEntity } from './entities/user.entity';
|
||||
import {
|
||||
UserEntity,
|
||||
UserNotificationEntity,
|
||||
UserOtpEntity,
|
||||
UserRoleEntity,
|
||||
UserSpaceEntity,
|
||||
} from './entities';
|
||||
|
||||
@Module({
|
||||
providers: [],
|
||||
exports: [],
|
||||
controllers: [],
|
||||
imports: [TypeOrmModule.forFeature([UserEntity])],
|
||||
imports: [
|
||||
TypeOrmModule.forFeature([
|
||||
UserEntity,
|
||||
UserNotificationEntity,
|
||||
UserOtpEntity,
|
||||
UserRoleEntity,
|
||||
UserSpaceEntity,
|
||||
]),
|
||||
],
|
||||
})
|
||||
export class UserRepositoryModule {}
|
||||
|
@ -7,13 +7,12 @@ import { ConfigModule } from '@nestjs/config';
|
||||
import { RoleTypeRepositoryModule } from '../modules/role-type/role.type.repository.module';
|
||||
import { RoleTypeRepository } from '../modules/role-type/repositories';
|
||||
import { RoleTypeSeeder } from './services/role.type.seeder';
|
||||
import { SpaceTypeRepository } from '../modules/space-type/repositories';
|
||||
import { SpaceTypeRepository } from '../modules/space/repositories';
|
||||
import { SpaceTypeSeeder } from './services/space.type.seeder';
|
||||
import { SpaceTypeRepositoryModule } from '../modules/space-type/space.type.repository.module';
|
||||
import { SpaceRepositoryModule } from '../modules/space/space.repository.module';
|
||||
import { SuperAdminSeeder } from './services/supper.admin.seeder';
|
||||
import { UserRepository } from '../modules/user/repositories';
|
||||
import { UserRoleRepository } from '../modules/user-role/repositories';
|
||||
import { UserRoleRepositoryModule } from '../modules/user-role/user.role.repository.module';
|
||||
import { UserRoleRepository } from '../modules/user/repositories';
|
||||
import { UserRepositoryModule } from '../modules/user/user.repository.module';
|
||||
import { RegionSeeder } from './services/regions.seeder';
|
||||
import { RegionRepository } from '../modules/region/repositories';
|
||||
@ -44,8 +43,7 @@ import { TimeZoneRepository } from '../modules/timezone/repositories';
|
||||
PermissionTypeRepositoryModule,
|
||||
RoleTypeRepositoryModule,
|
||||
UserRepositoryModule,
|
||||
UserRoleRepositoryModule,
|
||||
SpaceTypeRepositoryModule,
|
||||
SpaceRepositoryModule,
|
||||
],
|
||||
})
|
||||
export class SeederModule {}
|
||||
|
@ -1,6 +1,6 @@
|
||||
import { Injectable } from '@nestjs/common';
|
||||
import { SpaceType } from '../../constants/space-type.enum';
|
||||
import { SpaceTypeRepository } from '../../modules/space-type/repositories';
|
||||
import { SpaceTypeRepository } from '../../modules/space/repositories';
|
||||
|
||||
@Injectable()
|
||||
export class SpaceTypeSeeder {
|
||||
|
@ -1,7 +1,7 @@
|
||||
import { Injectable } from '@nestjs/common';
|
||||
import { UserRepository } from '@app/common/modules/user/repositories';
|
||||
import { RoleType } from '@app/common/constants/role.type.enum';
|
||||
import { UserRoleRepository } from '@app/common/modules/user-role/repositories';
|
||||
import { UserRoleRepository } from '@app/common/modules/user/repositories';
|
||||
import { RoleTypeRepository } from '@app/common/modules/role-type/repositories';
|
||||
import { ConfigService } from '@nestjs/config';
|
||||
import { HelperHashService } from '../../helper/services';
|
||||
|
@ -10,6 +10,7 @@ export class EmailService {
|
||||
this.smtpConfig = {
|
||||
host: this.configService.get<string>('email-config.SMTP_HOST'),
|
||||
port: this.configService.get<number>('email-config.SMTP_PORT'),
|
||||
sender: this.configService.get<string>('email-config.SMTP_SENDER'),
|
||||
secure: this.configService.get<boolean>('email-config.SMTP_SECURE'), // true for 465, false for other ports
|
||||
auth: {
|
||||
user: this.configService.get<string>('email-config.SMTP_USER'),
|
||||
@ -26,7 +27,7 @@ export class EmailService {
|
||||
const transporter = nodemailer.createTransport(this.smtpConfig);
|
||||
|
||||
const mailOptions = {
|
||||
from: this.smtpConfig.auth.user,
|
||||
from: this.smtpConfig.sender,
|
||||
to: email,
|
||||
subject,
|
||||
text: message,
|
||||
|
118
libs/common/src/util/types.spec.ts
Normal file
118
libs/common/src/util/types.spec.ts
Normal file
@ -0,0 +1,118 @@
|
||||
import {
|
||||
Constructor,
|
||||
Plain,
|
||||
Optional,
|
||||
Nullable,
|
||||
Path,
|
||||
PathValue,
|
||||
KeyOfType,
|
||||
} from './types';
|
||||
|
||||
interface TestInterface {
|
||||
user: {
|
||||
profile: {
|
||||
name: string;
|
||||
age: number;
|
||||
};
|
||||
settings: {
|
||||
theme: string;
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
interface SampleEntity {
|
||||
id: number;
|
||||
name: string;
|
||||
tags: string[];
|
||||
}
|
||||
|
||||
class TestClass {
|
||||
constructor(
|
||||
public name: string,
|
||||
public age: number,
|
||||
) {}
|
||||
}
|
||||
|
||||
describe('TypeScript Utility Types', () => {
|
||||
it('should validate Constructor type', () => {
|
||||
type ValidConstructorTest = Constructor<TestClass, [string, number]>;
|
||||
const instance: ValidConstructorTest = TestClass;
|
||||
expect(instance).toBeDefined();
|
||||
});
|
||||
|
||||
it('should validate Plain type', () => {
|
||||
type PlainNumberTest = Plain<number>;
|
||||
type PlainStringTest = Plain<string>;
|
||||
type PlainObjectTest = Plain<{ name: string; age: number }>;
|
||||
const num: PlainNumberTest = 42;
|
||||
const str: PlainStringTest = 'hello';
|
||||
const obj: PlainObjectTest = { name: 'John', age: 30 };
|
||||
|
||||
expect(num).toBe(42);
|
||||
expect(str).toBe('hello');
|
||||
expect(obj).toEqual({ name: 'John', age: 30 });
|
||||
});
|
||||
|
||||
it('should validate Optional type', () => {
|
||||
type OptionalNumberTest = Optional<number>;
|
||||
type OptionalObjectTest = Optional<{ name: string }>;
|
||||
|
||||
const num: OptionalNumberTest = undefined;
|
||||
const obj: OptionalObjectTest = { name: 'Jane' };
|
||||
const objUndefined: OptionalObjectTest = undefined;
|
||||
|
||||
expect(num).toBeUndefined();
|
||||
expect(obj).toEqual({ name: 'Jane' });
|
||||
expect(objUndefined).toBeUndefined();
|
||||
});
|
||||
|
||||
it('should validate Nullable type', () => {
|
||||
type NullableNumberTest = Nullable<number>;
|
||||
type NullableObjectTest = Nullable<{ name: string }>;
|
||||
|
||||
const num: NullableNumberTest = null;
|
||||
const obj: NullableObjectTest = { name: 'Jack' };
|
||||
const objNull: NullableObjectTest = null;
|
||||
|
||||
expect(num).toBeNull();
|
||||
expect(obj).toEqual({ name: 'Jack' });
|
||||
expect(objNull).toBeNull();
|
||||
});
|
||||
|
||||
it('should validate Path type', () => {
|
||||
type PathTest = Path<TestInterface>;
|
||||
const path1: PathTest = 'user.profile.name';
|
||||
const path2: PathTest = 'user.settings.theme';
|
||||
|
||||
expect(path1).toBe('user.profile.name');
|
||||
expect(path2).toBe('user.settings.theme');
|
||||
});
|
||||
|
||||
it('should validate PathValue type', () => {
|
||||
type NameTypeTest = PathValue<TestInterface, 'user.profile.name'>;
|
||||
type AgeTypeTest = PathValue<TestInterface, 'user.profile.age'>;
|
||||
type ThemeTypeTest = PathValue<TestInterface, 'user.settings.theme'>;
|
||||
|
||||
const name: NameTypeTest = 'Alice';
|
||||
const age: AgeTypeTest = 25;
|
||||
const theme: ThemeTypeTest = 'dark';
|
||||
|
||||
expect(name).toBe('Alice');
|
||||
expect(age).toBe(25);
|
||||
expect(theme).toBe('dark');
|
||||
});
|
||||
|
||||
it('should validate KeyOfType type', () => {
|
||||
type StringKeysTest = KeyOfType<SampleEntity, string>;
|
||||
type NumberKeysTest = KeyOfType<SampleEntity, number>;
|
||||
type ArrayKeysTest = KeyOfType<SampleEntity, string[]>;
|
||||
|
||||
const stringKey: StringKeysTest = 'name';
|
||||
const numberKey: NumberKeysTest = 'id';
|
||||
const arrayKey: ArrayKeysTest = 'tags';
|
||||
|
||||
expect(stringKey).toBe('name');
|
||||
expect(numberKey).toBe('id');
|
||||
expect(arrayKey).toBe('tags');
|
||||
});
|
||||
});
|
14
package-lock.json
generated
14
package-lock.json
generated
@ -43,6 +43,8 @@
|
||||
"@nestjs/cli": "^10.3.2",
|
||||
"@nestjs/schematics": "^10.0.0",
|
||||
"@nestjs/testing": "^10.0.0",
|
||||
"@types/bcryptjs": "^2.4.6",
|
||||
"@types/crypto-js": "^4.2.2",
|
||||
"@types/express": "^4.17.17",
|
||||
"@types/jest": "^29.5.2",
|
||||
"@types/node": "^20.3.1",
|
||||
@ -2892,6 +2894,12 @@
|
||||
"@babel/types": "^7.20.7"
|
||||
}
|
||||
},
|
||||
"node_modules/@types/bcryptjs": {
|
||||
"version": "2.4.6",
|
||||
"resolved": "https://registry.npmjs.org/@types/bcryptjs/-/bcryptjs-2.4.6.tgz",
|
||||
"integrity": "sha512-9xlo6R2qDs5uixm0bcIqCeMCE6HiQsIyel9KQySStiyqNl2tnj2mP3DX1Nf56MD6KMenNNlBBsy3LJ7gUEQPXQ==",
|
||||
"dev": true
|
||||
},
|
||||
"node_modules/@types/body-parser": {
|
||||
"version": "1.19.5",
|
||||
"resolved": "https://registry.npmjs.org/@types/body-parser/-/body-parser-1.19.5.tgz",
|
||||
@ -2917,6 +2925,12 @@
|
||||
"integrity": "sha512-he+DHOWReW0nghN24E1WUqM0efK4kI9oTqDm6XmK8ZPe2djZ90BSNdGnIyCLzCPw7/pogPlGbzI2wHGGmi4O/Q==",
|
||||
"dev": true
|
||||
},
|
||||
"node_modules/@types/crypto-js": {
|
||||
"version": "4.2.2",
|
||||
"resolved": "https://registry.npmjs.org/@types/crypto-js/-/crypto-js-4.2.2.tgz",
|
||||
"integrity": "sha512-sDOLlVbHhXpAUAL0YHDUUwDZf3iN4Bwi4W6a0W0b+QcAezUbRtH4FVb+9J4h+XFPW7l/gQ9F8qC7P+Ec4k8QVQ==",
|
||||
"dev": true
|
||||
},
|
||||
"node_modules/@types/eslint": {
|
||||
"version": "8.56.4",
|
||||
"resolved": "https://registry.npmjs.org/@types/eslint/-/eslint-8.56.4.tgz",
|
||||
|
12
package.json
12
package.json
@ -6,12 +6,12 @@
|
||||
"private": true,
|
||||
"license": "UNLICENSED",
|
||||
"scripts": {
|
||||
"build": "npx nest build",
|
||||
"build": "npm run test && npx nest build",
|
||||
"format": "prettier --write \"apps/**/*.ts\" \"libs/**/*.ts\"",
|
||||
"start": "node dist/main",
|
||||
"start:dev": "npx nest start --watch",
|
||||
"start:debug": "npx nest start --debug --watch",
|
||||
"start:prod": "node dist/main",
|
||||
"start": "npm run test && node dist/main",
|
||||
"start:dev": "npm run test && npx nest start --watch",
|
||||
"start:debug": "npm run test && npx nest start --debug --watch",
|
||||
"start:prod": "npm run test && node dist/main",
|
||||
"lint": "eslint \"{src,apps,libs,test}/**/*.ts\" --fix",
|
||||
"test": "jest --config jest.config.js",
|
||||
"test:watch": "jest --watch --config jest.config.js",
|
||||
@ -54,6 +54,8 @@
|
||||
"@nestjs/cli": "^10.3.2",
|
||||
"@nestjs/schematics": "^10.0.0",
|
||||
"@nestjs/testing": "^10.0.0",
|
||||
"@types/bcryptjs": "^2.4.6",
|
||||
"@types/crypto-js": "^4.2.2",
|
||||
"@types/express": "^4.17.17",
|
||||
"@types/jest": "^29.5.2",
|
||||
"@types/node": "^20.3.1",
|
||||
|
@ -57,4 +57,4 @@ import { TimeZoneModule } from './timezone/timezone.module';
|
||||
},
|
||||
],
|
||||
})
|
||||
export class AuthModule {}
|
||||
export class AppModule {}
|
||||
|
@ -2,14 +2,16 @@ import { Module } from '@nestjs/common';
|
||||
import { AuthenticationController } from './controllers/authentication.controller';
|
||||
import { AuthenticationService } from './services/authentication.service';
|
||||
import { ConfigModule } from '@nestjs/config';
|
||||
import { UserRepositoryModule } from '../../libs/common/src/modules/user/user.repository.module';
|
||||
import { UserRepositoryModule } from '@app/common/modules/user/user.repository.module';
|
||||
import { CommonModule } from '../../libs/common/src';
|
||||
import { UserAuthController } from './controllers';
|
||||
import { UserAuthService } from './services';
|
||||
import { UserRepository } from '../../libs/common/src/modules/user/repositories';
|
||||
import { UserSessionRepository } from '../../libs/common/src/modules/session/repositories/session.repository';
|
||||
import { UserOtpRepository } from '../../libs/common/src/modules/user-otp/repositories/user-otp.repository';
|
||||
import { UserRoleRepository } from '@app/common/modules/user-role/repositories';
|
||||
import { UserRepository } from '@app/common/modules/user/repositories';
|
||||
import { UserSessionRepository } from '@app/common/modules/session/repositories/session.repository';
|
||||
import {
|
||||
UserRoleRepository,
|
||||
UserOtpRepository,
|
||||
} from '@app/common/modules/user/repositories';
|
||||
import { RoleTypeRepository } from '@app/common/modules/role-type/repositories';
|
||||
|
||||
@Module({
|
||||
|
@ -9,7 +9,7 @@ import { ApiTags } from '@nestjs/swagger';
|
||||
@ApiTags('Tuya Auth')
|
||||
export class AuthenticationController {
|
||||
constructor(private readonly authenticationService: AuthenticationService) {}
|
||||
@Post('auth1')
|
||||
@Post('auth2')
|
||||
async Authentication() {
|
||||
return await this.authenticationService.main();
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
import { RoleTypeRepository } from './../../../libs/common/src/modules/role-type/repositories/role.type.repository';
|
||||
import { UserRoleRepository } from './../../../libs/common/src/modules/user-role/repositories/user.role.repository';
|
||||
import { UserRoleRepository } from './../../../libs/common/src/modules/user/repositories/user.repository';
|
||||
import { UserRepository } from '../../../libs/common/src/modules/user/repositories';
|
||||
import {
|
||||
BadRequestException,
|
||||
@ -12,7 +12,7 @@ import { HelperHashService } from '../../../libs/common/src/helper/services';
|
||||
import { UserLoginDto } from '../dtos/user-login.dto';
|
||||
import { AuthService } from '../../../libs/common/src/auth/services/auth.service';
|
||||
import { UserSessionRepository } from '../../../libs/common/src/modules/session/repositories/session.repository';
|
||||
import { UserOtpRepository } from '../../../libs/common/src/modules/user-otp/repositories/user-otp.repository';
|
||||
import { UserOtpRepository } from '../../../libs/common/src/modules/user/repositories/user.repository';
|
||||
import { ForgetPasswordDto, UserOtpDto, VerifyOtpDto } from '../dtos';
|
||||
import { EmailService } from '../../../libs/common/src/util/email.service';
|
||||
import { OtpType } from '../../../libs/common/src/constants/otp-type.enum';
|
||||
|
@ -43,3 +43,8 @@ export interface AutomationResponseData {
|
||||
conditions: Condition[];
|
||||
[key: string]: any; // Allow additional properties
|
||||
}
|
||||
export interface AutomationDetailsResult {
|
||||
id: string;
|
||||
name: string;
|
||||
type: string;
|
||||
}
|
||||
|
@ -17,6 +17,7 @@ import { convertKeysToSnakeCase } from '@app/common/helper/snakeCaseConverter';
|
||||
import { DeviceService } from 'src/device/services';
|
||||
import {
|
||||
AddAutomationInterface,
|
||||
AutomationDetailsResult,
|
||||
AutomationResponseData,
|
||||
DeleteAutomationInterface,
|
||||
GetAutomationByUnitInterface,
|
||||
@ -186,6 +187,38 @@ export class AutomationService {
|
||||
}
|
||||
}
|
||||
}
|
||||
async getTapToRunSceneDetailsTuya(
|
||||
sceneId: string,
|
||||
): Promise<AutomationDetailsResult> {
|
||||
try {
|
||||
const path = `/v2.0/cloud/scene/rule/${sceneId}`;
|
||||
const response = await this.tuya.request({
|
||||
method: 'GET',
|
||||
path,
|
||||
});
|
||||
|
||||
if (!response.success) {
|
||||
throw new HttpException(response.msg, HttpStatus.BAD_REQUEST);
|
||||
}
|
||||
const camelCaseResponse = convertKeysToCamelCase(response);
|
||||
const { id, name, type } = camelCaseResponse.result;
|
||||
|
||||
return {
|
||||
id,
|
||||
name,
|
||||
type,
|
||||
} as AutomationDetailsResult;
|
||||
} catch (err) {
|
||||
if (err instanceof BadRequestException) {
|
||||
throw err; // Re-throw BadRequestException
|
||||
} else {
|
||||
throw new HttpException(
|
||||
'Scene not found for Tuya',
|
||||
HttpStatus.NOT_FOUND,
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
async getAutomationDetails(automationId: string, withSpaceId = false) {
|
||||
try {
|
||||
const path = `/v2.0/cloud/scene/rule/${automationId}`;
|
||||
@ -215,6 +248,18 @@ export class AutomationService {
|
||||
if (device) {
|
||||
action.entityId = device.uuid;
|
||||
}
|
||||
} else if (
|
||||
action.actionExecutor !== 'device_issue' &&
|
||||
action.actionExecutor !== 'delay'
|
||||
) {
|
||||
const sceneDetails = await this.getTapToRunSceneDetailsTuya(
|
||||
action.entityId,
|
||||
);
|
||||
|
||||
if (sceneDetails.id) {
|
||||
action.name = sceneDetails.name;
|
||||
action.type = sceneDetails.type;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -4,21 +4,13 @@ import { BuildingController } from './controllers/building.controller';
|
||||
import { ConfigModule } from '@nestjs/config';
|
||||
import { SpaceRepositoryModule } from '@app/common/modules/space/space.repository.module';
|
||||
import { SpaceRepository } from '@app/common/modules/space/repositories';
|
||||
import { SpaceTypeRepositoryModule } from '@app/common/modules/space-type/space.type.repository.module';
|
||||
import { SpaceTypeRepository } from '@app/common/modules/space-type/repositories';
|
||||
import { UserSpaceRepositoryModule } from '@app/common/modules/user-space/user.space.repository.module';
|
||||
import { UserSpaceRepository } from '@app/common/modules/user-space/repositories';
|
||||
import { SpaceTypeRepository } from '@app/common/modules/space/repositories';
|
||||
import { UserSpaceRepository } from '@app/common/modules/user/repositories';
|
||||
import { UserRepository } from '@app/common/modules/user/repositories';
|
||||
import { UserRepositoryModule } from '@app/common/modules/user/user.repository.module';
|
||||
|
||||
@Module({
|
||||
imports: [
|
||||
ConfigModule,
|
||||
SpaceRepositoryModule,
|
||||
SpaceTypeRepositoryModule,
|
||||
UserSpaceRepositoryModule,
|
||||
UserRepositoryModule,
|
||||
],
|
||||
imports: [ConfigModule, SpaceRepositoryModule, UserRepositoryModule],
|
||||
controllers: [BuildingController],
|
||||
providers: [
|
||||
BuildingService,
|
||||
|
@ -1,5 +1,5 @@
|
||||
import { GetBuildingChildDto } from '../dtos/get.building.dto';
|
||||
import { SpaceTypeRepository } from '../../../libs/common/src/modules/space-type/repositories/space.type.repository';
|
||||
import { SpaceTypeRepository } from '../../../libs/common/src/modules/space/repositories/space.repository';
|
||||
import {
|
||||
Injectable,
|
||||
HttpException,
|
||||
@ -17,7 +17,7 @@ import {
|
||||
} from '../interface/building.interface';
|
||||
import { SpaceEntity } from '@app/common/modules/space/entities';
|
||||
import { UpdateBuildingNameDto } from '../dtos/update.building.dto';
|
||||
import { UserSpaceRepository } from '@app/common/modules/user-space/repositories';
|
||||
import { UserSpaceRepository } from '@app/common/modules/user/repositories';
|
||||
|
||||
@Injectable()
|
||||
export class BuildingService {
|
||||
|
@ -4,22 +4,14 @@ import { CommunityController } from './controllers/community.controller';
|
||||
import { ConfigModule } from '@nestjs/config';
|
||||
import { SpaceRepositoryModule } from '@app/common/modules/space/space.repository.module';
|
||||
import { SpaceRepository } from '@app/common/modules/space/repositories';
|
||||
import { SpaceTypeRepositoryModule } from '@app/common/modules/space-type/space.type.repository.module';
|
||||
import { SpaceTypeRepository } from '@app/common/modules/space-type/repositories';
|
||||
import { UserSpaceRepositoryModule } from '@app/common/modules/user-space/user.space.repository.module';
|
||||
import { UserSpaceRepository } from '@app/common/modules/user-space/repositories';
|
||||
import { SpaceTypeRepository } from '@app/common/modules/space/repositories';
|
||||
import { UserSpaceRepository } from '@app/common/modules/user/repositories';
|
||||
import { UserRepositoryModule } from '@app/common/modules/user/user.repository.module';
|
||||
import { UserRepository } from '@app/common/modules/user/repositories';
|
||||
import { SpacePermissionService } from '@app/common/helper/services';
|
||||
|
||||
@Module({
|
||||
imports: [
|
||||
ConfigModule,
|
||||
SpaceRepositoryModule,
|
||||
SpaceTypeRepositoryModule,
|
||||
UserSpaceRepositoryModule,
|
||||
UserRepositoryModule,
|
||||
],
|
||||
imports: [ConfigModule, SpaceRepositoryModule, UserRepositoryModule],
|
||||
controllers: [CommunityController],
|
||||
providers: [
|
||||
CommunityService,
|
||||
|
@ -1,5 +1,5 @@
|
||||
import { GetCommunityChildDto } from './../dtos/get.community.dto';
|
||||
import { SpaceTypeRepository } from './../../../libs/common/src/modules/space-type/repositories/space.type.repository';
|
||||
import { SpaceTypeRepository } from './../../../libs/common/src/modules/space/repositories/space.repository';
|
||||
import {
|
||||
Injectable,
|
||||
HttpException,
|
||||
@ -16,7 +16,7 @@ import {
|
||||
} from '../interface/community.interface';
|
||||
import { SpaceEntity } from '@app/common/modules/space/entities';
|
||||
import { UpdateCommunityNameDto } from '../dtos/update.community.dto';
|
||||
import { UserSpaceRepository } from '@app/common/modules/user-space/repositories';
|
||||
import { UserSpaceRepository } from '@app/common/modules/user/repositories';
|
||||
|
||||
@Injectable()
|
||||
export class CommunityService {
|
||||
|
@ -2,11 +2,11 @@ import { Module } from '@nestjs/common';
|
||||
import { ConfigModule } from '@nestjs/config';
|
||||
import { DeviceMessagesSubscriptionController } from './controllers';
|
||||
import { DeviceMessagesSubscriptionService } from './services';
|
||||
import { DeviceNotificationRepositoryModule } from '@app/common/modules/device-notification/device.notification.module';
|
||||
import { DeviceNotificationRepository } from '@app/common/modules/device-notification/repositories';
|
||||
import { DeviceRepositoryModule } from '@app/common/modules/device/device.repository.module';
|
||||
import { DeviceNotificationRepository } from '@app/common/modules/device/repositories';
|
||||
|
||||
@Module({
|
||||
imports: [ConfigModule, DeviceNotificationRepositoryModule],
|
||||
imports: [ConfigModule, DeviceRepositoryModule],
|
||||
controllers: [DeviceMessagesSubscriptionController],
|
||||
providers: [DeviceNotificationRepository, DeviceMessagesSubscriptionService],
|
||||
exports: [DeviceMessagesSubscriptionService],
|
||||
|
@ -1,6 +1,6 @@
|
||||
import { HttpException, HttpStatus, Injectable } from '@nestjs/common';
|
||||
import { DeviceMessagesAddDto } from '../dtos/device-messages.dto';
|
||||
import { DeviceNotificationRepository } from '@app/common/modules/device-notification/repositories';
|
||||
import { DeviceNotificationRepository } from '@app/common/modules/device/repositories';
|
||||
|
||||
@Injectable()
|
||||
export class DeviceMessagesSubscriptionService {
|
||||
|
@ -8,7 +8,7 @@ import { DeviceRepositoryModule } from '@app/common/modules/device';
|
||||
import { DeviceRepository } from '@app/common/modules/device/repositories';
|
||||
import { PermissionTypeRepository } from '@app/common/modules/permission/repositories';
|
||||
import { SpaceRepository } from '@app/common/modules/space/repositories';
|
||||
import { DeviceUserPermissionRepository } from '@app/common/modules/device-user-permission/repositories';
|
||||
import { DeviceUserPermissionRepository } from '@app/common/modules/device/repositories';
|
||||
import { UserRepository } from '@app/common/modules/user/repositories';
|
||||
import { DeviceStatusFirebaseModule } from '@app/common/firebase/devices-status/devices-status.module';
|
||||
@Module({
|
||||
|
@ -4,21 +4,13 @@ import { FloorController } from './controllers/floor.controller';
|
||||
import { ConfigModule } from '@nestjs/config';
|
||||
import { SpaceRepositoryModule } from '@app/common/modules/space/space.repository.module';
|
||||
import { SpaceRepository } from '@app/common/modules/space/repositories';
|
||||
import { SpaceTypeRepositoryModule } from '@app/common/modules/space-type/space.type.repository.module';
|
||||
import { SpaceTypeRepository } from '@app/common/modules/space-type/repositories';
|
||||
import { UserSpaceRepositoryModule } from '@app/common/modules/user-space/user.space.repository.module';
|
||||
import { UserSpaceRepository } from '@app/common/modules/user-space/repositories';
|
||||
import { SpaceTypeRepository } from '@app/common/modules/space/repositories';
|
||||
import { UserSpaceRepository } from '@app/common/modules/user/repositories';
|
||||
import { UserRepositoryModule } from '@app/common/modules/user/user.repository.module';
|
||||
import { UserRepository } from '@app/common/modules/user/repositories';
|
||||
|
||||
@Module({
|
||||
imports: [
|
||||
ConfigModule,
|
||||
SpaceRepositoryModule,
|
||||
SpaceTypeRepositoryModule,
|
||||
UserSpaceRepositoryModule,
|
||||
UserRepositoryModule,
|
||||
],
|
||||
imports: [ConfigModule, SpaceRepositoryModule, UserRepositoryModule],
|
||||
controllers: [FloorController],
|
||||
providers: [
|
||||
FloorService,
|
||||
|
@ -1,5 +1,5 @@
|
||||
import { GetFloorChildDto } from '../dtos/get.floor.dto';
|
||||
import { SpaceTypeRepository } from '../../../libs/common/src/modules/space-type/repositories/space.type.repository';
|
||||
import { SpaceTypeRepository } from '../../../libs/common/src/modules/space/repositories/space.repository';
|
||||
import {
|
||||
Injectable,
|
||||
HttpException,
|
||||
@ -17,7 +17,7 @@ import {
|
||||
} from '../interface/floor.interface';
|
||||
import { SpaceEntity } from '@app/common/modules/space/entities';
|
||||
import { UpdateFloorNameDto } from '../dtos/update.floor.dto';
|
||||
import { UserSpaceRepository } from '@app/common/modules/user-space/repositories';
|
||||
import { UserSpaceRepository } from '@app/common/modules/user/repositories';
|
||||
|
||||
@Injectable()
|
||||
export class FloorService {
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user