forked from Chatbot/v3-api
update for the so many errors
This commit is contained in:
1
docker/test.json
Normal file
1
docker/test.json
Normal file
@@ -0,0 +1 @@
|
||||
{"metadata":{"page":1,"per":10,"total":2},"items":[{"isAdmin":false,"id":"A1BFC6D5-04B7-4623-BA03-D597122FDB22","name":"chatbot-v2-dev","username":"chatbot-dev"},{"isAdmin":true,"id":"FD5A2BAB-CC19-4717-94BD-76E9F66249AF","name":"Admin User","username":"alarik"}]}⏎
|
||||
8
nest-cli.json
Normal file
8
nest-cli.json
Normal file
@@ -0,0 +1,8 @@
|
||||
{
|
||||
"$schema": "https://json.schemastore.org/nest-cli",
|
||||
"collection": "@nestjs/schematics",
|
||||
"sourceRoot": "src",
|
||||
"compilerOptions": {
|
||||
"deleteOutDir": true
|
||||
}
|
||||
}
|
||||
13304
package-lock.json
generated
Normal file
13304
package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
@@ -59,6 +59,7 @@
|
||||
"kavenegar": "^1.1.4",
|
||||
"moment-jalaali": "^0.10.4",
|
||||
"mongodb": "^6.18.0",
|
||||
"mongoose": "8.9.5",
|
||||
"multer": "^1.4.5-lts.1",
|
||||
"npm-check-updates": "^17.1.14",
|
||||
"papaparse": "^5.5.1",
|
||||
|
||||
@@ -207,7 +207,9 @@ export class AclService implements OnModuleInit {
|
||||
throw new BadRequestException('Cannot delete a system role');
|
||||
}
|
||||
|
||||
const usersCount = await this.adminModel.countDocuments({ role: roleName });
|
||||
const usersCount = await this.adminModel.countDocuments({
|
||||
role: roleName as Role,
|
||||
});
|
||||
if (usersCount > 0) {
|
||||
throw new BadRequestException(
|
||||
`Cannot delete role while ${usersCount} user(s) are assigned; reassign them first`,
|
||||
@@ -378,12 +380,16 @@ export class AclService implements OnModuleInit {
|
||||
mobile: dto.mobile,
|
||||
name: dto.name,
|
||||
family: dto.family,
|
||||
role: dto.role,
|
||||
role: dto.role as Role,
|
||||
isActive: true,
|
||||
permissionGrants: [],
|
||||
permissionDenies: [],
|
||||
});
|
||||
|
||||
if (!created) {
|
||||
throw new BadRequestException('staff_create_failed');
|
||||
}
|
||||
|
||||
const { password, ...safe } = created.toObject();
|
||||
|
||||
await this.auditLogService.logHttpRequest('acl.staff_created', req || {}, {
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { HttpException, HttpStatus, Injectable, Optional, Inject } from '@nestjs/common';
|
||||
import { InjectModel } from '@nestjs/mongoose';
|
||||
import { FilterQuery, Model, Types } from 'mongoose';
|
||||
import { Model, Types } from 'mongoose';
|
||||
import type { FilterQuery } from 'mongoose';
|
||||
import { BaseResponseDTO } from 'src/common/dto/base-response.dto';
|
||||
import { Role } from 'src/common/types/role.type';
|
||||
import { AdminDocument, AdminModel } from 'src/database/model/admin.model';
|
||||
@@ -151,7 +152,7 @@ export class AdminService {
|
||||
mobile: body.mobile,
|
||||
name: body.name,
|
||||
family: body.family,
|
||||
role: 'expert',
|
||||
role: Role.Expert,
|
||||
username: body.email, // Set username to email
|
||||
});
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { HttpException, HttpStatus, Injectable } from '@nestjs/common';
|
||||
import { InjectModel } from '@nestjs/mongoose';
|
||||
import { FilterQuery, Model, Types, UpdateQuery } from 'mongoose';
|
||||
import { Model, Types } from 'mongoose';
|
||||
import type { FilterQuery, UpdateQuery } from 'mongoose';
|
||||
import { BaseResponseDTO } from 'src/common/dto/base-response.dto';
|
||||
import { TimeHelper } from 'src/common/tools/time-helper';
|
||||
import { Sender } from 'src/common/types/sender.type';
|
||||
|
||||
89
src/business-hours/example-request-body.json
Normal file
89
src/business-hours/example-request-body.json
Normal file
@@ -0,0 +1,89 @@
|
||||
{
|
||||
"timezone": "Asia/Tehran",
|
||||
"globalToggle": true,
|
||||
"weeklyWindows": [
|
||||
{
|
||||
"day": "saturday",
|
||||
"intervals": [
|
||||
{
|
||||
"start": "09:00",
|
||||
"end": "19:30"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"day": "sunday",
|
||||
"intervals": [
|
||||
{
|
||||
"start": "09:00",
|
||||
"end": "19:30"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"day": "monday",
|
||||
"intervals": [
|
||||
{
|
||||
"start": "09:00",
|
||||
"end": "19:30"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"day": "tuesday",
|
||||
"intervals": [
|
||||
{
|
||||
"start": "09:00",
|
||||
"end": "19:30"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"day": "wednesday",
|
||||
"intervals": [
|
||||
{
|
||||
"start": "08:00",
|
||||
"end": "19:00"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"day": "thursday",
|
||||
"intervals": [
|
||||
{
|
||||
"start": "08:00",
|
||||
"end": "12:00"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"day": "friday",
|
||||
"intervals": []
|
||||
}
|
||||
],
|
||||
"exceptions": [
|
||||
{
|
||||
"date": "2025-03-20",
|
||||
"intervals": [],
|
||||
"reason": "Holiday Nowruz"
|
||||
},
|
||||
{
|
||||
"date": "2025-03-21",
|
||||
"intervals": [
|
||||
{
|
||||
"start": "10:00",
|
||||
"end": "14:00"
|
||||
}
|
||||
],
|
||||
"reason": "Special hours"
|
||||
}
|
||||
],
|
||||
"policy": {
|
||||
"onClose": "allow_existing_until_end"
|
||||
},
|
||||
"messageTemplate": {
|
||||
"key": "errors.online_conversation_unavailable",
|
||||
"default": "Online conversation is not available now. Next opening: {{nextOpen}}"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,8 +10,9 @@ export class UsersBaseModel {
|
||||
@Prop()
|
||||
family: string;
|
||||
|
||||
@Prop({ required: true })
|
||||
role: Role;
|
||||
/** System role (`admin`/`expert`/…) or a custom ACL role name. */
|
||||
@Prop({ required: true, type: String })
|
||||
role: Role | string;
|
||||
|
||||
@Prop()
|
||||
fatherName: string;
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { HttpException, HttpStatus, Injectable } from '@nestjs/common';
|
||||
import { InjectModel } from '@nestjs/mongoose';
|
||||
import { FilterQuery, Model } from 'mongoose';
|
||||
import { Model } from 'mongoose';
|
||||
import type { FilterQuery } from 'mongoose';
|
||||
import {
|
||||
BaseResponseDTO,
|
||||
PageMetaDto,
|
||||
|
||||
Reference in New Issue
Block a user