archetecture security fix

This commit is contained in:
root
2026-06-11 03:22:12 -04:00
parent 6def9993da
commit 9483750161
3126 changed files with 177194 additions and 37211 deletions
+3
View File
@@ -0,0 +1,3 @@
declare const router: import("express-serve-static-core").Router;
export default router;
//# sourceMappingURL=team.routes.d.ts.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"team.routes.d.ts","sourceRoot":"","sources":["../../../src/modules/team/team.routes.ts"],"names":[],"mappings":"AAUA,QAAA,MAAM,MAAM,4CAAW,CAAA;AAoDvB,eAAe,MAAM,CAAA"}
+110
View File
@@ -0,0 +1,110 @@
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || (function () {
var ownKeys = function(o) {
ownKeys = Object.getOwnPropertyNames || function (o) {
var ar = [];
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
return ar;
};
return ownKeys(o);
};
return function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
__setModuleDefault(result, mod);
return result;
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
const express_1 = require("express");
const requireCompanyAuth_1 = require("../../middleware/requireCompanyAuth");
const requireTenant_1 = require("../../middleware/requireTenant");
const requireSubscription_1 = require("../../middleware/requireSubscription");
const requireRole_1 = require("../../middleware/requireRole");
const validate_1 = require("../../http/validate");
const respond_1 = require("../../http/respond");
const service = __importStar(require("./team.service"));
const team_schemas_1 = require("./team.schemas");
const router = (0, express_1.Router)();
router.use(requireCompanyAuth_1.requireCompanyAuth, requireTenant_1.requireTenant, requireSubscription_1.requireSubscription);
router.get('/', async (req, res, next) => {
try {
(0, respond_1.ok)(res, await service.getMembers(req.companyId));
}
catch (err) {
next(err);
}
});
router.get('/stats', async (req, res, next) => {
try {
(0, respond_1.ok)(res, await service.getMemberStats(req.companyId));
}
catch (err) {
next(err);
}
});
router.post('/invite', (0, requireRole_1.requireRole)('OWNER'), async (req, res, next) => {
try {
const body = (0, validate_1.parseBody)(team_schemas_1.inviteSchema, req);
(0, respond_1.created)(res, { data: await service.inviteEmployee(req.companyId, req.employee.id, body) });
}
catch (err) {
next(err);
}
});
router.patch('/:id/role', (0, requireRole_1.requireRole)('OWNER'), async (req, res, next) => {
try {
const { id } = (0, validate_1.parseParams)(team_schemas_1.idParamSchema, req);
const { role } = (0, validate_1.parseBody)(team_schemas_1.roleSchema, req);
(0, respond_1.ok)(res, await service.updateEmployeeRole(req.companyId, req.employee.id, req.employee.role, id, { role }));
}
catch (err) {
next(err);
}
});
router.post('/:id/deactivate', (0, requireRole_1.requireRole)('OWNER'), async (req, res, next) => {
try {
const { id } = (0, validate_1.parseParams)(team_schemas_1.idParamSchema, req);
(0, respond_1.ok)(res, await service.deactivateEmployee(req.companyId, req.employee.role, id));
}
catch (err) {
next(err);
}
});
router.post('/:id/reactivate', (0, requireRole_1.requireRole)('OWNER'), async (req, res, next) => {
try {
const { id } = (0, validate_1.parseParams)(team_schemas_1.idParamSchema, req);
(0, respond_1.ok)(res, await service.reactivateEmployee(req.companyId, req.employee.role, id));
}
catch (err) {
next(err);
}
});
router.delete('/:id', (0, requireRole_1.requireRole)('OWNER'), async (req, res, next) => {
try {
const { id } = (0, validate_1.parseParams)(team_schemas_1.idParamSchema, req);
(0, respond_1.ok)(res, await service.removeEmployee(req.companyId, req.employee.role, id));
}
catch (err) {
next(err);
}
});
exports.default = router;
//# sourceMappingURL=team.routes.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"team.routes.js","sourceRoot":"","sources":["../../../src/modules/team/team.routes.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,qCAAgC;AAChC,4EAAwE;AACxE,kEAA8D;AAC9D,8EAA0E;AAC1E,8DAA0D;AAC1D,kDAA4D;AAC5D,gDAAgD;AAChD,wDAAyC;AACzC,iDAAwE;AAExE,MAAM,MAAM,GAAG,IAAA,gBAAM,GAAE,CAAA;AAEvB,MAAM,CAAC,GAAG,CAAC,uCAAkB,EAAE,6BAAa,EAAE,yCAAmB,CAAC,CAAA;AAElE,MAAM,CAAC,GAAG,CAAC,GAAG,EAAE,KAAK,EAAE,GAAG,EAAE,GAAG,EAAE,IAAI,EAAE,EAAE;IACvC,IAAI,CAAC;QACH,IAAA,YAAE,EAAC,GAAG,EAAE,MAAM,OAAO,CAAC,UAAU,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC,CAAA;IAClD,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QAAC,IAAI,CAAC,GAAG,CAAC,CAAA;IAAC,CAAC;AAC7B,CAAC,CAAC,CAAA;AAEF,MAAM,CAAC,GAAG,CAAC,QAAQ,EAAE,KAAK,EAAE,GAAG,EAAE,GAAG,EAAE,IAAI,EAAE,EAAE;IAC5C,IAAI,CAAC;QACH,IAAA,YAAE,EAAC,GAAG,EAAE,MAAM,OAAO,CAAC,cAAc,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC,CAAA;IACtD,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QAAC,IAAI,CAAC,GAAG,CAAC,CAAA;IAAC,CAAC;AAC7B,CAAC,CAAC,CAAA;AAEF,MAAM,CAAC,IAAI,CAAC,SAAS,EAAE,IAAA,yBAAW,EAAC,OAAO,CAAC,EAAE,KAAK,EAAE,GAAG,EAAE,GAAG,EAAE,IAAI,EA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;IAC7E,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QAAC,IAAI,CAAC,GAAG,CAAC,CAAA;IAAC,CAAC;AAC7B,CAAC,CAAC,CAAA;AAEF,kBAAe,MAAM,CAAA"}
+32
View File
@@ -0,0 +1,32 @@
import { z } from 'zod';
export declare const inviteSchema: z.ZodObject<{
firstName: z.ZodString;
lastName: z.ZodString;
email: z.ZodString;
role: z.ZodEnum<["MANAGER", "AGENT"]>;
}, "strip", z.ZodTypeAny, {
firstName: string;
lastName: string;
email: string;
role: "MANAGER" | "AGENT";
}, {
firstName: string;
lastName: string;
email: string;
role: "MANAGER" | "AGENT";
}>;
export declare const roleSchema: z.ZodObject<{
role: z.ZodEnum<["MANAGER", "AGENT"]>;
}, "strip", z.ZodTypeAny, {
role: "MANAGER" | "AGENT";
}, {
role: "MANAGER" | "AGENT";
}>;
export declare const idParamSchema: z.ZodObject<{
id: z.ZodString;
}, "strip", z.ZodTypeAny, {
id: string;
}, {
id: string;
}>;
//# sourceMappingURL=team.schemas.d.ts.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"team.schemas.d.ts","sourceRoot":"","sources":["../../../src/modules/team/team.schemas.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAEvB,eAAO,MAAM,YAAY;;;;;;;;;;;;;;;EAKvB,CAAA;AAEF,eAAO,MAAM,UAAU;;;;;;EAErB,CAAA;AAEF,eAAO,MAAM,aAAa;;;;;;EAExB,CAAA"}
+17
View File
@@ -0,0 +1,17 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.idParamSchema = exports.roleSchema = exports.inviteSchema = void 0;
const zod_1 = require("zod");
exports.inviteSchema = zod_1.z.object({
firstName: zod_1.z.string().min(1).max(64),
lastName: zod_1.z.string().min(1).max(64),
email: zod_1.z.string().email(),
role: zod_1.z.enum(['MANAGER', 'AGENT']),
});
exports.roleSchema = zod_1.z.object({
role: zod_1.z.enum(['MANAGER', 'AGENT']),
});
exports.idParamSchema = zod_1.z.object({
id: zod_1.z.string().min(1),
});
//# sourceMappingURL=team.schemas.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"team.schemas.js","sourceRoot":"","sources":["../../../src/modules/team/team.schemas.ts"],"names":[],"mappings":";;;AAAA,6BAAuB;AAEV,QAAA,YAAY,GAAG,OAAC,CAAC,MAAM,CAAC;IACnC,SAAS,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC;IACpC,QAAQ,EAAG,OAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC;IACpC,KAAK,EAAM,OAAC,CAAC,MAAM,EAAE,CAAC,KAAK,EAAE;IAC7B,IAAI,EAAO,OAAC,CAAC,IAAI,CAAC,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC;CACxC,CAAC,CAAA;AAEW,QAAA,UAAU,GAAG,OAAC,CAAC,MAAM,CAAC;IACjC,IAAI,EAAE,OAAC,CAAC,IAAI,CAAC,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC;CACnC,CAAC,CAAA;AAEW,QAAA,aAAa,GAAG,OAAC,CAAC,MAAM,CAAC;IACpC,EAAE,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;CACtB,CAAC,CAAA"}
+10
View File
@@ -0,0 +1,10 @@
import { inviteEmployee, updateEmployeeRole, deactivateEmployee, reactivateEmployee, removeEmployee } from '../../services/teamService';
export declare function getMembers(companyId: string): Promise<import("../../services/teamService").TeamMember[]>;
export declare function getMemberStats(companyId: string): Promise<{
total: number;
active: number;
pending: number;
inactive: number;
}>;
export { inviteEmployee, updateEmployeeRole, deactivateEmployee, reactivateEmployee, removeEmployee };
//# sourceMappingURL=team.service.d.ts.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"team.service.d.ts","sourceRoot":"","sources":["../../../src/modules/team/team.service.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,cAAc,EACd,kBAAkB,EAClB,kBAAkB,EAClB,kBAAkB,EAClB,cAAc,EACf,MAAM,4BAA4B,CAAA;AAEnC,wBAAsB,UAAU,CAAC,SAAS,EAAE,MAAM,8DAEjD;AAED,wBAAsB,cAAc,CAAC,SAAS,EAAE,MAAM;;;;;GAQrD;AAED,OAAO,EAAE,cAAc,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,cAAc,EAAE,CAAA"}
+24
View File
@@ -0,0 +1,24 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.removeEmployee = exports.reactivateEmployee = exports.deactivateEmployee = exports.updateEmployeeRole = exports.inviteEmployee = void 0;
exports.getMembers = getMembers;
exports.getMemberStats = getMemberStats;
const teamService_1 = require("../../services/teamService");
Object.defineProperty(exports, "inviteEmployee", { enumerable: true, get: function () { return teamService_1.inviteEmployee; } });
Object.defineProperty(exports, "updateEmployeeRole", { enumerable: true, get: function () { return teamService_1.updateEmployeeRole; } });
Object.defineProperty(exports, "deactivateEmployee", { enumerable: true, get: function () { return teamService_1.deactivateEmployee; } });
Object.defineProperty(exports, "reactivateEmployee", { enumerable: true, get: function () { return teamService_1.reactivateEmployee; } });
Object.defineProperty(exports, "removeEmployee", { enumerable: true, get: function () { return teamService_1.removeEmployee; } });
async function getMembers(companyId) {
return (0, teamService_1.listEmployees)(companyId);
}
async function getMemberStats(companyId) {
const members = await (0, teamService_1.listEmployees)(companyId);
return {
total: members.length,
active: members.filter((m) => m.isActive && m.invitationStatus === 'accepted').length,
pending: members.filter((m) => m.invitationStatus === 'pending').length,
inactive: members.filter((m) => !m.isActive && m.invitationStatus === 'accepted').length,
};
}
//# sourceMappingURL=team.service.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"team.service.js","sourceRoot":"","sources":["../../../src/modules/team/team.service.ts"],"names":[],"mappings":";;;AASA,gCAEC;AAED,wCAQC;AArBD,4DAOmC;AAgB1B,+FArBP,4BAAc,OAqBO;AAAE,mGApBvB,gCAAkB,OAoBuB;AAAE,mGAnB3C,gCAAkB,OAmB2C;AAAE,mGAlB/D,gCAAkB,OAkB+D;AAAE,+FAjBnF,4BAAc,OAiBmF;AAd5F,KAAK,UAAU,UAAU,CAAC,SAAiB;IAChD,OAAO,IAAA,2BAAa,EAAC,SAAS,CAAC,CAAA;AACjC,CAAC;AAEM,KAAK,UAAU,cAAc,CAAC,SAAiB;IACpD,MAAM,OAAO,GAAG,MAAM,IAAA,2BAAa,EAAC,SAAS,CAAC,CAAA;IAC9C,OAAO;QACL,KAAK,EAAK,OAAO,CAAC,MAAM;QACxB,MAAM,EAAI,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,QAAQ,IAAI,CAAC,CAAC,gBAAgB,KAAK,UAAU,CAAC,CAAC,MAAM;QACvF,OAAO,EAAG,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,gBAAgB,KAAK,SAAS,CAAC,CAAC,MAAM;QACxE,QAAQ,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,QAAQ,IAAI,CAAC,CAAC,gBAAgB,KAAK,UAAU,CAAC,CAAC,MAAM;KACzF,CAAA;AACH,CAAC"}