@duvdu-v1/duvdu 1.1.253 → 1.1.255

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.
@@ -72,6 +72,8 @@ const isauthenticated = (req, res, next) => __awaiter(void 0, void 0, void 0, fu
72
72
  en: `Forbidden: User is blocked ${req.loggedUser.isBlocked.reason}`,
73
73
  ar: ` ممنوع: المستخدم محظور ${req.loggedUser.isBlocked.reason}`,
74
74
  }, req.lang));
75
+ if (user.isDeleted)
76
+ return next(new unauthorized_error_1.UnauthorizedError({ en: 'user not found', ar: 'لا يوجد مستخدم' }, req.lang));
75
77
  const role = yield Role_model_1.Roles.findById(user.role);
76
78
  if (!role)
77
79
  return res.status(423).json({ message: 'invalid role' });
@@ -24,6 +24,8 @@ const optionalAuthenticated = (req, res, next) => __awaiter(void 0, void 0, void
24
24
  en: `Forbidden: User is blocked ${req.loggedUser.isBlocked.reason}`,
25
25
  ar: ` ممنوع: المستخدم محظور ${req.loggedUser.isBlocked.reason}`,
26
26
  }, req.lang));
27
+ if (req.loggedUser.isDeleted)
28
+ return next(new unauthorized_error_1.UnauthorizedError({ en: 'user not found', ar: 'لا يوجد مستخدم' }, req.lang));
27
29
  }
28
30
  catch (error) {
29
31
  return next();
@@ -18,6 +18,7 @@ const userSchema = new mongoose_1.Schema({
18
18
  appleId: { type: String, default: null },
19
19
  email: { type: String, unique: true, sparse: true },
20
20
  name: { type: String, default: null },
21
+ isDeleted: { type: Boolean, default: false },
21
22
  phoneNumber: {
22
23
  key: { type: String, default: null },
23
24
  number: { type: String, unique: true, sparse: true },
@@ -23,16 +23,8 @@
23
23
  /// <reference types="mongoose/types/virtuals" />
24
24
  /// <reference types="mongoose/types/inferschematype" />
25
25
  import { Types } from 'mongoose';
26
- import { RequestedDeadlineStatus, SubmitFilesStatus } from './copyright-contract.model';
27
- import { Icategory } from '../types/Category';
28
- import { CYCLES } from '../types/cycles';
26
+ import { IprojectContract } from './projectContract.model';
29
27
  import { Iuser } from '../types/User';
30
- export declare enum UserStatus {
31
- accepted = "accepted",
32
- rejected = "rejected",
33
- pending = "pending",
34
- canceled = "canceled"
35
- }
36
28
  export interface ITeamProject {
37
29
  user: Types.ObjectId | Iuser;
38
30
  cover: string;
@@ -44,75 +36,11 @@ export interface ITeamProject {
44
36
  };
45
37
  address: string;
46
38
  cycle: string;
47
- creatives: [
48
- {
49
- category: Types.ObjectId | Icategory;
50
- users: [
51
- {
52
- user: Types.ObjectId | Iuser;
53
- attachments: string[];
54
- duration: number;
55
- startDate: Date;
56
- workHours: number;
57
- hourPrice: number;
58
- details: string;
59
- deadLine: Date;
60
- totalAmount: number;
61
- status: UserStatus;
62
- contract: Types.ObjectId;
63
- }
64
- ];
65
- }
66
- ];
39
+ contracts: {
40
+ contract: Types.ObjectId | IprojectContract;
41
+ }[];
67
42
  isDeleted: boolean;
68
43
  }
69
44
  export declare const TeamProject: import("mongoose").Model<ITeamProject, {}, {}, {}, import("mongoose").Document<unknown, {}, ITeamProject> & ITeamProject & {
70
45
  _id: Types.ObjectId;
71
46
  }, any>;
72
- export declare enum TeamContractStatus {
73
- canceled = "canceled",
74
- pending = "pending",
75
- waitingForTotalPayment = "waiting-for-total-payment",
76
- ongoing = "ongoing",
77
- completed = "completed",
78
- rejected = "rejected",
79
- complaint = "complaint"
80
- }
81
- export interface ITeamContract {
82
- sp: Types.ObjectId | Iuser;
83
- customer: Types.ObjectId | Iuser;
84
- project: Types.ObjectId | ITeamProject;
85
- category: Types.ObjectId | Icategory;
86
- startDate: Date;
87
- duration: Date;
88
- workHours: number;
89
- hourPrice: number;
90
- deadline: Date;
91
- details: string;
92
- attachments: string[];
93
- totalPrice: number;
94
- actionAt: Date;
95
- rejectedBy?: 'customer' | 'sp';
96
- paymentLink: string;
97
- stageExpiration: number;
98
- status: TeamContractStatus;
99
- cycle: CYCLES;
100
- createdAt: Date;
101
- paymentAmount: number;
102
- totalCheckoutAt: Date;
103
- submitFiles: {
104
- link: string;
105
- notes: string;
106
- status: SubmitFilesStatus;
107
- reason?: string;
108
- dateOfSubmission: Date;
109
- }[];
110
- requestedDeadline: {
111
- deadline: Date;
112
- status: RequestedDeadlineStatus;
113
- user: Types.ObjectId | Iuser;
114
- };
115
- }
116
- export declare const TeamContract: import("mongoose").Model<ITeamContract, {}, {}, {}, import("mongoose").Document<unknown, {}, ITeamContract> & ITeamContract & {
117
- _id: Types.ObjectId;
118
- }, any>;
@@ -1,38 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.TeamContract = exports.TeamContractStatus = exports.TeamProject = exports.UserStatus = void 0;
3
+ exports.TeamProject = void 0;
4
4
  const mongoose_1 = require("mongoose");
5
- const copyright_contract_model_1 = require("./copyright-contract.model");
6
5
  const cycles_1 = require("../types/cycles");
7
6
  const model_names_1 = require("../types/model-names");
8
- var UserStatus;
9
- (function (UserStatus) {
10
- UserStatus["accepted"] = "accepted";
11
- UserStatus["rejected"] = "rejected";
12
- UserStatus["pending"] = "pending";
13
- UserStatus["canceled"] = "canceled";
14
- })(UserStatus || (exports.UserStatus = UserStatus = {}));
15
- const UserSchema = new mongoose_1.Schema({
16
- user: { type: mongoose_1.Schema.Types.ObjectId, ref: model_names_1.MODELS.user },
17
- contract: { type: mongoose_1.Schema.Types.ObjectId, ref: model_names_1.MODELS.user },
18
- attachments: [String],
19
- duration: { type: Number, default: 0 },
20
- startDate: Date,
21
- workHours: { type: Number, default: 0 },
22
- hourPrice: { type: Number, default: 0 },
23
- details: { type: String, default: null },
24
- deadLine: Date,
25
- totalAmount: { type: Number, default: 0 },
26
- status: { type: String, enum: UserStatus, default: UserStatus.pending },
27
- });
28
- const CreativeSchema = new mongoose_1.Schema({
29
- category: {
30
- type: mongoose_1.Schema.Types.ObjectId,
31
- required: true,
32
- ref: model_names_1.MODELS.category,
33
- },
34
- users: [UserSchema],
35
- });
36
7
  exports.TeamProject = (0, mongoose_1.model)(model_names_1.MODELS.teamProject, new mongoose_1.Schema({
37
8
  user: { type: mongoose_1.Schema.Types.ObjectId, ref: model_names_1.MODELS.user },
38
9
  cover: { type: String, default: null },
@@ -40,7 +11,7 @@ exports.TeamProject = (0, mongoose_1.model)(model_names_1.MODELS.teamProject, ne
40
11
  desc: { type: String, default: null },
41
12
  location: { lat: { type: Number, default: null }, lng: { type: Number, default: null } },
42
13
  address: { type: String, default: null },
43
- creatives: [CreativeSchema],
14
+ contracts: [{ contract: { type: mongoose_1.Types.ObjectId, ref: model_names_1.MODELS.projectContract } }],
44
15
  isDeleted: { type: Boolean, default: false },
45
16
  cycle: { type: String, default: cycles_1.CYCLES.teamProject },
46
17
  }, {
@@ -50,64 +21,6 @@ exports.TeamProject = (0, mongoose_1.model)(model_names_1.MODELS.teamProject, ne
50
21
  transform(doc, ret) {
51
22
  if (ret.cover)
52
23
  ret.cover = process.env.BUCKET_HOST + '/' + ret.cover;
53
- if (ret.creatives && ret.creatives.length > 0) {
54
- ret.creatives.forEach((creative) => {
55
- if (creative.users && creative.users.length > 0) {
56
- creative.users.forEach((user) => {
57
- if (user.attachments && user.attachments.length > 0) {
58
- user.attachments = user.attachments.map((attachment) => process.env.BUCKET_HOST + '/' + attachment);
59
- }
60
- });
61
- }
62
- });
63
- }
64
24
  },
65
25
  },
66
26
  }));
67
- // contract
68
- var TeamContractStatus;
69
- (function (TeamContractStatus) {
70
- TeamContractStatus["canceled"] = "canceled";
71
- TeamContractStatus["pending"] = "pending";
72
- TeamContractStatus["waitingForTotalPayment"] = "waiting-for-total-payment";
73
- TeamContractStatus["ongoing"] = "ongoing";
74
- TeamContractStatus["completed"] = "completed";
75
- TeamContractStatus["rejected"] = "rejected";
76
- TeamContractStatus["complaint"] = "complaint";
77
- })(TeamContractStatus || (exports.TeamContractStatus = TeamContractStatus = {}));
78
- exports.TeamContract = (0, mongoose_1.model)(model_names_1.MODELS.teamContract, new mongoose_1.Schema({
79
- sp: { type: mongoose_1.Schema.Types.ObjectId, ref: model_names_1.MODELS.user },
80
- customer: { type: mongoose_1.Schema.Types.ObjectId, ref: model_names_1.MODELS.user },
81
- project: { type: mongoose_1.Schema.Types.ObjectId, ref: model_names_1.MODELS.teamProject },
82
- category: { type: mongoose_1.Schema.Types.ObjectId, ref: model_names_1.MODELS.category },
83
- startDate: Date,
84
- duration: Date,
85
- workHours: { type: Number, default: 0 },
86
- hourPrice: { type: Number, default: 0 },
87
- deadline: Date,
88
- details: { type: String, default: null },
89
- totalPrice: { type: Number, default: 0 },
90
- actionAt: Date,
91
- rejectedBy: { type: String, enum: ['customer', 'sp'] },
92
- paymentLink: { type: String, default: null },
93
- stageExpiration: { type: Number, default: 0 },
94
- status: { type: String, enum: TeamContractStatus, default: TeamContractStatus.pending },
95
- cycle: { type: String, default: cycles_1.CYCLES.teamProject },
96
- paymentAmount: { type: Number, default: 0 },
97
- attachments: [String],
98
- totalCheckoutAt: Date,
99
- submitFiles: [
100
- {
101
- link: { type: String, default: null },
102
- notes: { type: String, default: null },
103
- reason: { type: String, default: null },
104
- dateOfSubmission: { type: Date, default: null },
105
- status: { type: String, enum: copyright_contract_model_1.SubmitFilesStatus, default: copyright_contract_model_1.SubmitFilesStatus.pending },
106
- },
107
- ],
108
- requestedDeadline: {
109
- deadline: { type: Date, default: null },
110
- status: { type: String, enum: copyright_contract_model_1.RequestedDeadlineStatus, default: copyright_contract_model_1.RequestedDeadlineStatus.pending },
111
- user: { type: mongoose_1.Schema.Types.ObjectId, ref: model_names_1.MODELS.user, default: null },
112
- },
113
- }, { timestamps: true, collection: model_names_1.MODELS.teamContract }));
@@ -108,4 +108,5 @@ export interface Iuser {
108
108
  haveInvitation: boolean;
109
109
  faceRecognition: string | null;
110
110
  projectsCount: number;
111
+ isDeleted: boolean;
111
112
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@duvdu-v1/duvdu",
3
- "version": "1.1.253",
3
+ "version": "1.1.255",
4
4
  "main": "./build/index.js",
5
5
  "types": "./build/index.d.ts",
6
6
  "files": [