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
@@ -0,0 +1,25 @@
export declare function findCompany(companyId: string, unread?: string): any;
export declare function countUnread(companyId: string): any;
export declare function markRead(id: string, companyId: string): any;
export declare function markAllRead(companyId: string): any;
export declare function findEmployeePreferences(employeeId: string): any;
export declare function upsertEmployeePreferences(employeeId: string, prefs: Array<{
notificationType: string;
channel: string;
enabled: boolean;
}>): Promise<void>;
export declare function findCompanyHistory(companyId: string, opts?: {
channel?: string;
status?: string;
limit?: number;
}): any;
export declare function findRenter(renterId: string): any;
export declare function markRenterRead(id: string, renterId: string): any;
export declare function markAllRenterRead(renterId: string): any;
export declare function findRenterPreferences(renterId: string): any;
export declare function upsertRenterPreferences(renterId: string, prefs: Array<{
notificationType: string;
channel: string;
enabled: boolean;
}>): Promise<void>;
//# sourceMappingURL=notification.repo.d.ts.map
@@ -0,0 +1 @@
{"version":3,"file":"notification.repo.d.ts","sourceRoot":"","sources":["../../../src/modules/notifications/notification.repo.ts"],"names":[],"mappings":"AAKA,wBAAgB,WAAW,CAAC,SAAS,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,OAI7D;AAED,wBAAgB,WAAW,CAAC,SAAS,EAAE,MAAM,OAE5C;AAED,wBAAgB,QAAQ,CAAC,EAAE,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,OAErD;AAED,wBAAgB,WAAW,CAAC,SAAS,EAAE,MAAM,OAE5C;AAED,wBAAgB,uBAAuB,CAAC,UAAU,EAAE,MAAM,OAEzD;AAED,wBAAsB,yBAAyB,CAAC,UAAU,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,CAAC;IAAE,gBAAgB,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,OAAO,CAAA;CAAE,CAAC,iBAQhJ;AAED,wBAAgB,kBAAkB,CAChC,SAAS,EAAE,MAAM,EACjB,IAAI,CAAC,EAAE;IAAE,OAAO,CAAC,EAAE,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAA;CAAE,OAU7D;AAID,wBAAgB,UAAU,CAAC,QAAQ,EAAE,MAAM,OAE1C;AAED,wBAAgB,cAAc,CAAC,EAAE,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAE1D;AAED,wBAAgB,iBAAiB,CAAC,QAAQ,EAAE,MAAM,OAEjD;AAED,wBAAgB,qBAAqB,CAAC,QAAQ,EAAE,MAAM,OAErD;AAED,wBAAsB,uBAAuB,CAAC,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,CAAC;IAAE,gBAAgB,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,OAAO,CAAA;CAAE,CAAC,iBAQ5I"}
@@ -0,0 +1,78 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.findCompany = findCompany;
exports.countUnread = countUnread;
exports.markRead = markRead;
exports.markAllRead = markAllRead;
exports.findEmployeePreferences = findEmployeePreferences;
exports.upsertEmployeePreferences = upsertEmployeePreferences;
exports.findCompanyHistory = findCompanyHistory;
exports.findRenter = findRenter;
exports.markRenterRead = markRenterRead;
exports.markAllRenterRead = markAllRenterRead;
exports.findRenterPreferences = findRenterPreferences;
exports.upsertRenterPreferences = upsertRenterPreferences;
const prisma_1 = require("../../lib/prisma");
// ─── Company notifications ────────────────────────────────────
function findCompany(companyId, unread) {
const where = { companyId, channel: 'IN_APP' };
if (unread === 'true')
where.readAt = null;
return prisma_1.prisma.notification.findMany({ where, orderBy: { createdAt: 'desc' }, take: 50 });
}
function countUnread(companyId) {
return prisma_1.prisma.notification.count({ where: { companyId, channel: 'IN_APP', readAt: null } });
}
function markRead(id, companyId) {
return prisma_1.prisma.notification.updateMany({ where: { id, companyId }, data: { readAt: new Date(), status: 'READ' } });
}
function markAllRead(companyId) {
return prisma_1.prisma.notification.updateMany({ where: { companyId, readAt: null }, data: { readAt: new Date(), status: 'READ' } });
}
function findEmployeePreferences(employeeId) {
return prisma_1.prisma.notificationPreference.findMany({ where: { employeeId } });
}
async function upsertEmployeePreferences(employeeId, prefs) {
for (const pref of prefs) {
await prisma_1.prisma.notificationPreference.upsert({
where: { employeeId_notificationType_channel: { employeeId, notificationType: pref.notificationType, channel: pref.channel } },
create: { employeeId, notificationType: pref.notificationType, channel: pref.channel, enabled: pref.enabled },
update: { enabled: pref.enabled },
});
}
}
function findCompanyHistory(companyId, opts) {
const where = { companyId };
if (opts?.channel)
where.channel = opts.channel;
if (opts?.status)
where.status = opts.status;
return prisma_1.prisma.notification.findMany({
where,
orderBy: { createdAt: 'desc' },
take: opts?.limit ?? 200,
});
}
// ─── Renter notifications ─────────────────────────────────────
function findRenter(renterId) {
return prisma_1.prisma.notification.findMany({ where: { renterId, channel: 'IN_APP' }, orderBy: { createdAt: 'desc' }, take: 50 });
}
function markRenterRead(id, renterId) {
return prisma_1.prisma.notification.updateMany({ where: { id, renterId }, data: { readAt: new Date(), status: 'READ' } });
}
function markAllRenterRead(renterId) {
return prisma_1.prisma.notification.updateMany({ where: { renterId, channel: 'IN_APP', readAt: null }, data: { readAt: new Date(), status: 'READ' } });
}
function findRenterPreferences(renterId) {
return prisma_1.prisma.notificationPreference.findMany({ where: { renterId } });
}
async function upsertRenterPreferences(renterId, prefs) {
for (const pref of prefs) {
await prisma_1.prisma.notificationPreference.upsert({
where: { renterId_notificationType_channel: { renterId, notificationType: pref.notificationType, channel: pref.channel } },
create: { renterId, notificationType: pref.notificationType, channel: pref.channel, enabled: pref.enabled },
update: { enabled: pref.enabled },
});
}
}
//# sourceMappingURL=notification.repo.js.map
@@ -0,0 +1 @@
{"version":3,"file":"notification.repo.js","sourceRoot":"","sources":["../../../src/modules/notifications/notification.repo.ts"],"names":[],"mappings":";;AAKA,kCAIC;AAED,kCAEC;AAED,4BAEC;AAED,kC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AAI,CAAC,OAA8B,EAAE,OAAO,EAAE,IAAI,CAAC,OAAO,EAAE;YACtJ,MAAM,EAAE,EAAE,OAAO,EAAE,IAAI,CAAC,OAAO,EAAE;SAClC,CAAC,CAAA;IACJ,CAAC;AACH,CAAC"}
@@ -0,0 +1,3 @@
declare const router: import("express-serve-static-core").Router;
export default router;
//# sourceMappingURL=notification.routes.d.ts.map
@@ -0,0 +1 @@
{"version":3,"file":"notification.routes.d.ts","sourceRoot":"","sources":["../../../src/modules/notifications/notification.routes.ts"],"names":[],"mappings":"AAUA,QAAA,MAAM,MAAM,4CAAW,CAAA;AA4FvB,eAAe,MAAM,CAAA"}
@@ -0,0 +1,158 @@
"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 requireRenterAuth_1 = require("../../middleware/requireRenterAuth");
const validate_1 = require("../../http/validate");
const respond_1 = require("../../http/respond");
const service = __importStar(require("./notification.service"));
const notification_schemas_1 = require("./notification.schemas");
const router = (0, express_1.Router)();
const companyAuth = [requireCompanyAuth_1.requireCompanyAuth, requireTenant_1.requireTenant, requireSubscription_1.requireSubscription];
// ─── Company notifications ────────────────────────────────────
router.get('/company', ...companyAuth, async (req, res, next) => {
try {
const { unread } = (0, validate_1.parseQuery)(notification_schemas_1.unreadQuerySchema, req);
(0, respond_1.ok)(res, await service.listCompany(req.companyId, unread));
}
catch (err) {
next(err);
}
});
router.get('/unread-count', ...companyAuth, async (req, res, next) => {
try {
(0, respond_1.ok)(res, { unread: await service.countUnread(req.companyId) });
}
catch (err) {
next(err);
}
});
router.post('/company/:id/read', ...companyAuth, async (req, res, next) => {
try {
const { id } = (0, validate_1.parseParams)(notification_schemas_1.idParamSchema, req);
await service.markRead(id, req.companyId);
(0, respond_1.ok)(res, { success: true });
}
catch (err) {
next(err);
}
});
router.post('/company/read-all', ...companyAuth, async (req, res, next) => {
try {
await service.markAllRead(req.companyId);
(0, respond_1.ok)(res, { success: true });
}
catch (err) {
next(err);
}
});
router.get('/company/preferences', ...companyAuth, async (req, res, next) => {
try {
(0, respond_1.ok)(res, await service.getPreferences(req.employee.id));
}
catch (err) {
next(err);
}
});
router.patch('/company/preferences', ...companyAuth, async (req, res, next) => {
try {
const prefs = (0, validate_1.parseBody)(notification_schemas_1.preferencesSchema, req);
await service.setPreferences(req.employee.id, prefs);
(0, respond_1.ok)(res, { success: true });
}
catch (err) {
next(err);
}
});
router.get('/history', ...companyAuth, async (req, res, next) => {
try {
const { channel, status, limit } = (0, validate_1.parseQuery)(notification_schemas_1.historyQuerySchema, req);
(0, respond_1.ok)(res, await service.listCompanyHistory(req.companyId, { channel, status, limit }));
}
catch (err) {
next(err);
}
});
// ─── Renter notifications ─────────────────────────────────────
router.get('/renter', requireRenterAuth_1.requireRenterAuth, async (req, res, next) => {
try {
(0, respond_1.ok)(res, await service.listRenter(req.renterId));
}
catch (err) {
next(err);
}
});
router.post('/renter/:id/read', requireRenterAuth_1.requireRenterAuth, async (req, res, next) => {
try {
const { id } = (0, validate_1.parseParams)(notification_schemas_1.idParamSchema, req);
await service.markRenterRead(id, req.renterId);
(0, respond_1.ok)(res, { success: true });
}
catch (err) {
next(err);
}
});
router.post('/renter/read-all', requireRenterAuth_1.requireRenterAuth, async (req, res, next) => {
try {
await service.markAllRenterRead(req.renterId);
(0, respond_1.ok)(res, { success: true });
}
catch (err) {
next(err);
}
});
router.get('/renter/preferences', requireRenterAuth_1.requireRenterAuth, async (req, res, next) => {
try {
(0, respond_1.ok)(res, await service.getRenterPreferences(req.renterId));
}
catch (err) {
next(err);
}
});
router.patch('/renter/preferences', requireRenterAuth_1.requireRenterAuth, async (req, res, next) => {
try {
const prefs = (0, validate_1.parseBody)(notification_schemas_1.preferencesSchema, req);
await service.setRenterPreferences(req.renterId, prefs);
(0, respond_1.ok)(res, { success: true });
}
catch (err) {
next(err);
}
});
exports.default = router;
//# sourceMappingURL=notification.routes.js.map
@@ -0,0 +1 @@
{"version":3,"file":"notification.routes.js","sourceRoot":"","sources":["../../../src/modules/notifications/notification.routes.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,qCAAgC;AAChC,4EAAwE;AACxE,kEAA8D;AAC9D,8EAA0E;AAC1E,0EAAsE;AACtE,kDAAwE;AACxE,gDAAuC;AACvC,gEAAiD;AACjD,iEAAgH;AAEhH,MAAM,MAAM,GAAG,IAAA,gBAAM,GAAE,CAAA;AAEvB,MAAM,WAAW,GAAG,CAAC,uCAAkB,EAAE,6BAAa,EAAE,yCAAmB,CAAU,CAAA;AAErF,iEAAiE;AAEjE,MAAM,CAAC,GAAG,CAAC,UAAU,EAAE,GAAG,WAAW,EAAE,KAAK,EAAE,GAAG,EAAE,GAAG,EAAE,IAAI,EAAE,EAAE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E,IAAI,EAAE,CAAC,CAAA;IAC5B,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QAAC,IAAI,CAAC,GAAG,CAAC,CAAA;IAAC,CAAC;AAC7B,CAAC,CAAC,CAAA;AAEF,kBAAe,MAAM,CAAA"}
@@ -0,0 +1,55 @@
import { z } from 'zod';
export declare const preferenceItemSchema: z.ZodObject<{
notificationType: z.ZodString;
channel: z.ZodString;
enabled: z.ZodBoolean;
}, "strip", z.ZodTypeAny, {
channel: string;
notificationType: string;
enabled: boolean;
}, {
channel: string;
notificationType: string;
enabled: boolean;
}>;
export declare const preferencesSchema: z.ZodArray<z.ZodObject<{
notificationType: z.ZodString;
channel: z.ZodString;
enabled: z.ZodBoolean;
}, "strip", z.ZodTypeAny, {
channel: string;
notificationType: string;
enabled: boolean;
}, {
channel: string;
notificationType: string;
enabled: boolean;
}>, "many">;
export declare const idParamSchema: z.ZodObject<{
id: z.ZodString;
}, "strip", z.ZodTypeAny, {
id: string;
}, {
id: string;
}>;
export declare const unreadQuerySchema: z.ZodObject<{
unread: z.ZodOptional<z.ZodString>;
}, "strip", z.ZodTypeAny, {
unread?: string | undefined;
}, {
unread?: string | undefined;
}>;
export declare const historyQuerySchema: z.ZodObject<{
channel: z.ZodOptional<z.ZodString>;
status: z.ZodOptional<z.ZodString>;
limit: z.ZodOptional<z.ZodNumber>;
}, "strip", z.ZodTypeAny, {
status?: string | undefined;
limit?: number | undefined;
channel?: string | undefined;
}, {
status?: string | undefined;
limit?: number | undefined;
channel?: string | undefined;
}>;
//# sourceMappingURL=notification.schemas.d.ts.map
@@ -0,0 +1 @@
{"version":3,"file":"notification.schemas.d.ts","sourceRoot":"","sources":["../../../src/modules/notifications/notification.schemas.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAEvB,eAAO,MAAM,oBAAoB;;;;;;;;;;;;EAI/B,CAAA;AAEF,eAAO,MAAM,iBAAiB;;;;;;;;;;;;WAAgC,CAAA;AAE9D,eAAO,MAAM,aAAa;;;;;;EAExB,CAAA;AAEF,eAAO,MAAM,iBAAiB;;;;;;EAE5B,CAAA;AAEF,eAAO,MAAM,kBAAkB;;;;;;;;;;;;EAI7B,CAAA"}
@@ -0,0 +1,22 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.historyQuerySchema = exports.unreadQuerySchema = exports.idParamSchema = exports.preferencesSchema = exports.preferenceItemSchema = void 0;
const zod_1 = require("zod");
exports.preferenceItemSchema = zod_1.z.object({
notificationType: zod_1.z.string(),
channel: zod_1.z.string(),
enabled: zod_1.z.boolean(),
});
exports.preferencesSchema = zod_1.z.array(exports.preferenceItemSchema);
exports.idParamSchema = zod_1.z.object({
id: zod_1.z.string().min(1),
});
exports.unreadQuerySchema = zod_1.z.object({
unread: zod_1.z.string().optional(),
});
exports.historyQuerySchema = zod_1.z.object({
channel: zod_1.z.string().optional(),
status: zod_1.z.string().optional(),
limit: zod_1.z.coerce.number().int().min(1).max(500).optional(),
});
//# sourceMappingURL=notification.schemas.js.map
@@ -0,0 +1 @@
{"version":3,"file":"notification.schemas.js","sourceRoot":"","sources":["../../../src/modules/notifications/notification.schemas.ts"],"names":[],"mappings":";;;AAAA,6BAAuB;AAEV,QAAA,oBAAoB,GAAG,OAAC,CAAC,MAAM,CAAC;IAC3C,gBAAgB,EAAE,OAAC,CAAC,MAAM,EAAE;IAC5B,OAAO,EAAW,OAAC,CAAC,MAAM,EAAE;IAC5B,OAAO,EAAW,OAAC,CAAC,OAAO,EAAE;CAC9B,CAAC,CAAA;AAEW,QAAA,iBAAiB,GAAG,OAAC,CAAC,KAAK,CAAC,4BAAoB,CAAC,CAAA;AAEjD,QAAA,aAAa,GAAG,OAAC,CAAC,MAAM,CAAC;IACpC,EAAE,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;CACtB,CAAC,CAAA;AAEW,QAAA,iBAAiB,GAAG,OAAC,CAAC,MAAM,CAAC;IACxC,MAAM,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;CAC9B,CAAC,CAAA;AAEW,QAAA,kBAAkB,GAAG,OAAC,CAAC,MAAM,CAAC;IACzC,OAAO,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAC9B,MAAM,EAAG,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAC9B,KAAK,EAAI,OAAC,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,QAAQ,EAAE;CAC5D,CAAC,CAAA"}
@@ -0,0 +1,17 @@
export declare const listCompany: (companyId: string, unread?: string) => any;
export declare const listCompanyHistory: (companyId: string, opts?: {
channel?: string;
status?: string;
limit?: number;
}) => any;
export declare const countUnread: (companyId: string) => any;
export declare const markRead: (id: string, companyId: string) => any;
export declare const markAllRead: (companyId: string) => any;
export declare const getPreferences: (employeeId: string) => any;
export declare const setPreferences: (employeeId: string, prefs: any[]) => Promise<void>;
export declare const listRenter: (renterId: string) => any;
export declare const markRenterRead: (id: string, renterId: string) => any;
export declare const markAllRenterRead: (renterId: string) => any;
export declare const getRenterPreferences: (renterId: string) => any;
export declare const setRenterPreferences: (renterId: string, prefs: any[]) => Promise<void>;
//# sourceMappingURL=notification.service.d.ts.map
@@ -0,0 +1 @@
{"version":3,"file":"notification.service.d.ts","sourceRoot":"","sources":["../../../src/modules/notifications/notification.service.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,WAAW,GAAS,WAAW,MAAM,EAAE,SAAS,MAAM,QAAwC,CAAA;AAC3G,eAAO,MAAM,kBAAkB,GAAI,WAAW,MAAM,EAAE,OAAO;IAAE,OAAO,CAAC,EAAE,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAA;CAAE,QAA6C,CAAA;AAC/J,eAAO,MAAM,WAAW,GAAS,WAAW,MAAM,QAAgC,CAAA;AAClF,eAAO,MAAM,QAAQ,GAAY,IAAI,MAAM,EAAE,WAAW,MAAM,QAAiC,CAAA;AAC/F,eAAO,MAAM,WAAW,GAAS,WAAW,MAAM,QAAgC,CAAA;AAClF,eAAO,MAAM,cAAc,GAAM,YAAY,MAAM,QAA6C,CAAA;AAChG,eAAO,MAAM,cAAc,GAAM,YAAY,MAAM,EAAE,OAAO,GAAG,EAAE,kBAAsD,CAAA;AAEvH,eAAO,MAAM,UAAU,GAAc,UAAU,MAAM,QAA8B,CAAA;AACnF,eAAO,MAAM,cAAc,GAAU,IAAI,MAAM,EAAE,UAAU,MAAM,QAAsC,CAAA;AACvG,eAAO,MAAM,iBAAiB,GAAO,UAAU,MAAM,QAAqC,CAAA;AAC1F,eAAO,MAAM,oBAAoB,GAAI,UAAU,MAAM,QAAyC,CAAA;AAC9F,eAAO,MAAM,oBAAoB,GAAI,UAAU,MAAM,EAAE,OAAO,GAAG,EAAE,kBAAkD,CAAA"}
@@ -0,0 +1,62 @@
"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 });
exports.setRenterPreferences = exports.getRenterPreferences = exports.markAllRenterRead = exports.markRenterRead = exports.listRenter = exports.setPreferences = exports.getPreferences = exports.markAllRead = exports.markRead = exports.countUnread = exports.listCompanyHistory = exports.listCompany = void 0;
const repo = __importStar(require("./notification.repo"));
const listCompany = (companyId, unread) => repo.findCompany(companyId, unread);
exports.listCompany = listCompany;
const listCompanyHistory = (companyId, opts) => repo.findCompanyHistory(companyId, opts);
exports.listCompanyHistory = listCompanyHistory;
const countUnread = (companyId) => repo.countUnread(companyId);
exports.countUnread = countUnread;
const markRead = (id, companyId) => repo.markRead(id, companyId);
exports.markRead = markRead;
const markAllRead = (companyId) => repo.markAllRead(companyId);
exports.markAllRead = markAllRead;
const getPreferences = (employeeId) => repo.findEmployeePreferences(employeeId);
exports.getPreferences = getPreferences;
const setPreferences = (employeeId, prefs) => repo.upsertEmployeePreferences(employeeId, prefs);
exports.setPreferences = setPreferences;
const listRenter = (renterId) => repo.findRenter(renterId);
exports.listRenter = listRenter;
const markRenterRead = (id, renterId) => repo.markRenterRead(id, renterId);
exports.markRenterRead = markRenterRead;
const markAllRenterRead = (renterId) => repo.markAllRenterRead(renterId);
exports.markAllRenterRead = markAllRenterRead;
const getRenterPreferences = (renterId) => repo.findRenterPreferences(renterId);
exports.getRenterPreferences = getRenterPreferences;
const setRenterPreferences = (renterId, prefs) => repo.upsertRenterPreferences(renterId, prefs);
exports.setRenterPreferences = setRenterPreferences;
//# sourceMappingURL=notification.service.js.map
@@ -0,0 +1 @@
{"version":3,"file":"notification.service.js","sourceRoot":"","sources":["../../../src/modules/notifications/notification.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,0DAA2C;AAEpC,MAAM,WAAW,GAAQ,C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