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,3 @@
export declare function presentCompany(company: any): any;
export declare function presentBrand(brand: any): any;
//# sourceMappingURL=company.presenter.d.ts.map
@@ -0,0 +1 @@
{"version":3,"file":"company.presenter.d.ts","sourceRoot":"","sources":["../../../src/modules/companies/company.presenter.ts"],"names":[],"mappings":"AAAA,wBAAgB,cAAc,CAAC,OAAO,EAAE,GAAG,OAE1C;AAED,wBAAgB,YAAY,CAAC,KAAK,EAAE,GAAG,OAQtC"}
+18
View File
@@ -0,0 +1,18 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.presentCompany = presentCompany;
exports.presentBrand = presentBrand;
function presentCompany(company) {
return company;
}
function presentBrand(brand) {
if (!brand)
return brand;
const { amanpaySecretKey, amanpayMerchantId, paypalEmail, paypalMerchantId, ...safe } = brand;
return {
...safe,
amanpayConfigured: !!(amanpayMerchantId && amanpaySecretKey),
paypalConfigured: !!(paypalEmail || paypalMerchantId),
};
}
//# sourceMappingURL=company.presenter.js.map
@@ -0,0 +1 @@
{"version":3,"file":"company.presenter.js","sourceRoot":"","sources":["../../../src/modules/companies/company.presenter.ts"],"names":[],"mappings":";;AAAA,wCAEC;AAED,oCAQC;AAZD,SAAgB,cAAc,CAAC,OAAY;IACzC,OAAO,OAAO,CAAA;AAChB,CAAC;AAED,SAAgB,YAAY,CAAC,KAAU;IACrC,IAAI,CAAC,KAAK;QAAE,OAAO,KAAK,CAAA;IACxB,MAAM,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,WAAW,EAAE,gBAAgB,EAAE,GAAG,IAAI,EAAE,GAAG,KAAK,CAAA;IAC7F,OAAO;QACL,GAAG,IAAI;QACP,iBAAiB,EAAE,CAAC,CAAC,CAAC,iBAAiB,IAAI,gBAAgB,CAAC;QAC5D,gBAAgB,EAAG,CAAC,CAAC,CAAC,WAAW,IAAI,gBAAgB,CAAC;KACvD,CAAA;AACH,CAAC"}
+30
View File
@@ -0,0 +1,30 @@
export declare function findCompany(companyId: string): Promise<any>;
export declare function updateCompany(companyId: string, data: any): Promise<any>;
export declare function findBrand(companyId: string): Promise<any>;
export declare function upsertBrand(companyId: string, updateData: any, createData: any): Promise<any>;
export declare function findContractSettings(companyId: string): Promise<any>;
export declare function upsertContractSettings(companyId: string, data: any): Promise<any>;
export declare function findInsurancePolicies(companyId: string): Promise<any>;
export declare function createInsurancePolicy(companyId: string, data: any): Promise<any>;
export declare function updateInsurancePolicy(id: string, companyId: string, data: any): Promise<any>;
export declare function findInsurancePolicyOrThrow(id: string): Promise<any>;
export declare function deleteInsurancePolicy(id: string, companyId: string): Promise<any>;
export declare function findPricingRules(companyId: string): Promise<any>;
export declare function createPricingRule(companyId: string, data: any): Promise<any>;
export declare function updatePricingRule(id: string, companyId: string, data: any): Promise<any>;
export declare function findPricingRuleOrThrow(id: string): Promise<any>;
export declare function deletePricingRule(id: string, companyId: string): Promise<any>;
export declare function findAccountingSettings(companyId: string): Promise<any>;
export declare function upsertAccountingSettings(companyId: string, data: any): Promise<any>;
export declare function findApiKey(companyId: string): Promise<{
apiKeys: any;
}>;
export declare function regenerateApiKey(companyId: string): Promise<{
apiKey: string;
prefix: string;
warning: string;
}>;
export declare function findBrandBySubdomain(subdomain: string, excludeCompanyId: string): Promise<any>;
export declare function findBrandByCustomDomain(customDomain: string, excludeCompanyId: string): Promise<any>;
export declare function clearCustomDomain(companyId: string): Promise<any>;
//# sourceMappingURL=company.repo.d.ts.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"company.repo.d.ts","sourceRoot":"","sources":["../../../src/modules/companies/company.repo.ts"],"names":[],"mappings":"AAGA,wBAAsB,WAAW,CAAC,SAAS,EAAE,MAAM,gBASlD;AAED,wBAAsB,aAAa,CAAC,SAAS,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,gBAE/D;AAED,wBAAsB,SAAS,CAAC,SAAS,EAAE,MAAM,gBAEhD;AAED,wBAAsB,WAAW,CAAC,SAAS,EAAE,MAAM,EAAE,UAAU,EAAE,GAAG,EAAE,UAAU,EAAE,GAAG,gBAMpF;AAED,wBAAsB,oBAAoB,CAAC,SAAS,EAAE,MAAM,gBAE3D;AAED,wBAAsB,sBAAsB,CAAC,SAAS,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,gBAMxE;AAED,wBAAsB,qBAAqB,CAAC,SAAS,EAAE,MAAM,gBAK5D;AAED,wBAAsB,qBAAqB,CAAC,SAAS,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,gBAEvE;AAED,wBAAsB,qBAAqB,CAAC,EAAE,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,gBAEnF;AAED,wBAAsB,0BAA0B,CAAC,EAAE,EAAE,MAAM,gBAE1D;AAED,wBAAsB,qBAAqB,CAAC,EAAE,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,gBAExE;AAED,wBAAsB,gBAAgB,CAAC,SAAS,EAAE,MAAM,gBAKvD;AAED,wBAAsB,iBAAiB,CAAC,SAAS,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,gBAEnE;AAED,wBAAsB,iBAAiB,CAAC,EAAE,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,gBAE/E;AAED,wBAAsB,sBAAsB,CAAC,EAAE,EAAE,MAAM,gBAEtD;AAED,wBAAsB,iBAAiB,CAAC,EAAE,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,gBAEpE;AAED,wBAAsB,sBAAsB,CAAC,SAAS,EAAE,MAAM,gBAE7D;AAED,wBAAsB,wBAAwB,CAAC,SAAS,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,gBAM1E;AAED,wBAAsB,UAAU,CAAC,SAAS,EAAE,MAAM;;GAQjD;AAED,wBAAsB,gBAAgB,CAAC,SAAS,EAAE,MAAM;;;;GAmBvD;AAED,wBAAsB,oBAAoB,CAAC,SAAS,EAAE,MAAM,EAAE,gBAAgB,EAAE,MAAM,gBAErF;AAED,wBAAsB,uBAAuB,CAAC,YAAY,EAAE,MAAM,EAAE,gBAAgB,EAAE,MAAM,gBAE3F;AAED,wBAAsB,iBAAiB,CAAC,SAAS,EAAE,MAAM,gBAKxD"}
+145
View File
@@ -0,0 +1,145 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.findCompany = findCompany;
exports.updateCompany = updateCompany;
exports.findBrand = findBrand;
exports.upsertBrand = upsertBrand;
exports.findContractSettings = findContractSettings;
exports.upsertContractSettings = upsertContractSettings;
exports.findInsurancePolicies = findInsurancePolicies;
exports.createInsurancePolicy = createInsurancePolicy;
exports.updateInsurancePolicy = updateInsurancePolicy;
exports.findInsurancePolicyOrThrow = findInsurancePolicyOrThrow;
exports.deleteInsurancePolicy = deleteInsurancePolicy;
exports.findPricingRules = findPricingRules;
exports.createPricingRule = createPricingRule;
exports.updatePricingRule = updatePricingRule;
exports.findPricingRuleOrThrow = findPricingRuleOrThrow;
exports.deletePricingRule = deletePricingRule;
exports.findAccountingSettings = findAccountingSettings;
exports.upsertAccountingSettings = upsertAccountingSettings;
exports.findApiKey = findApiKey;
exports.regenerateApiKey = regenerateApiKey;
exports.findBrandBySubdomain = findBrandBySubdomain;
exports.findBrandByCustomDomain = findBrandByCustomDomain;
exports.clearCustomDomain = clearCustomDomain;
const prisma_1 = require("../../lib/prisma");
const apiKeys_1 = require("../../security/apiKeys");
async function findCompany(companyId) {
return prisma_1.prisma.company.findUniqueOrThrow({
where: { id: companyId },
include: {
brand: true,
subscription: true,
_count: { select: { vehicles: true, customers: true, reservations: true } },
},
});
}
async function updateCompany(companyId, data) {
return prisma_1.prisma.company.update({ where: { id: companyId }, data });
}
async function findBrand(companyId) {
return prisma_1.prisma.brandSettings.findUnique({ where: { companyId } });
}
async function upsertBrand(companyId, updateData, createData) {
return prisma_1.prisma.brandSettings.upsert({
where: { companyId },
update: updateData,
create: { companyId, ...createData },
});
}
async function findContractSettings(companyId) {
return prisma_1.prisma.contractSettings.findUnique({ where: { companyId } });
}
async function upsertContractSettings(companyId, data) {
return prisma_1.prisma.contractSettings.upsert({
where: { companyId },
update: data,
create: { companyId, ...data },
});
}
async function findInsurancePolicies(companyId) {
return prisma_1.prisma.insurancePolicy.findMany({
where: { companyId },
orderBy: [{ isRequired: 'desc' }, { sortOrder: 'asc' }, { name: 'asc' }],
});
}
async function createInsurancePolicy(companyId, data) {
return prisma_1.prisma.insurancePolicy.create({ data: { companyId, ...data } });
}
async function updateInsurancePolicy(id, companyId, data) {
return prisma_1.prisma.insurancePolicy.updateMany({ where: { id, companyId }, data });
}
async function findInsurancePolicyOrThrow(id) {
return prisma_1.prisma.insurancePolicy.findUniqueOrThrow({ where: { id } });
}
async function deleteInsurancePolicy(id, companyId) {
return prisma_1.prisma.insurancePolicy.deleteMany({ where: { id, companyId } });
}
async function findPricingRules(companyId) {
return prisma_1.prisma.pricingRule.findMany({
where: { companyId },
orderBy: [{ isActive: 'desc' }, { createdAt: 'asc' }],
});
}
async function createPricingRule(companyId, data) {
return prisma_1.prisma.pricingRule.create({ data: { companyId, ...data } });
}
async function updatePricingRule(id, companyId, data) {
return prisma_1.prisma.pricingRule.updateMany({ where: { id, companyId }, data });
}
async function findPricingRuleOrThrow(id) {
return prisma_1.prisma.pricingRule.findUniqueOrThrow({ where: { id } });
}
async function deletePricingRule(id, companyId) {
return prisma_1.prisma.pricingRule.deleteMany({ where: { id, companyId } });
}
async function findAccountingSettings(companyId) {
return prisma_1.prisma.accountingSettings.findUnique({ where: { companyId } });
}
async function upsertAccountingSettings(companyId, data) {
return prisma_1.prisma.accountingSettings.upsert({
where: { companyId },
update: data,
create: { companyId, ...data },
});
}
async function findApiKey(companyId) {
const apiKeys = await prisma_1.prisma.companyApiKey.findMany({
where: { companyId, revokedAt: null },
orderBy: { createdAt: 'desc' },
select: { id: true, name: true, prefix: true, lastUsedAt: true, createdAt: true, revokedAt: true },
});
return { apiKeys };
}
async function regenerateApiKey(companyId) {
const nextKey = (0, apiKeys_1.generateCompanyApiKey)();
await prisma_1.prisma.$transaction(async (tx) => {
await tx.companyApiKey.updateMany({
where: { companyId, revokedAt: null },
data: { revokedAt: new Date() },
});
await tx.companyApiKey.create({
data: {
companyId,
name: 'Default API key',
prefix: nextKey.prefix,
keyHash: nextKey.keyHash,
},
});
});
return { apiKey: nextKey.rawKey, prefix: nextKey.prefix, warning: 'This raw API key is shown once. Store it securely.' };
}
async function findBrandBySubdomain(subdomain, excludeCompanyId) {
return prisma_1.prisma.brandSettings.findFirst({ where: { subdomain, companyId: { not: excludeCompanyId } } });
}
async function findBrandByCustomDomain(customDomain, excludeCompanyId) {
return prisma_1.prisma.brandSettings.findFirst({ where: { customDomain, companyId: { not: excludeCompanyId } } });
}
async function clearCustomDomain(companyId) {
return prisma_1.prisma.brandSettings.updateMany({
where: { companyId },
data: { customDomain: null, customDomainVerified: false, customDomainAddedAt: null },
});
}
//# sourceMappingURL=company.repo.js.map
File diff suppressed because one or more lines are too long
+3
View File
@@ -0,0 +1,3 @@
declare const router: import("express-serve-static-core").Router;
export default router;
//# sourceMappingURL=company.routes.d.ts.map
@@ -0,0 +1 @@
{"version":3,"file":"company.routes.d.ts","sourceRoot":"","sources":["../../../src/modules/companies/company.routes.ts"],"names":[],"mappings":"AAgBA,QAAA,MAAM,MAAM,4CAAW,CAAA;AA4LvB,eAAe,MAAM,CAAA"}
+282
View File
@@ -0,0 +1,282 @@
"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 requireCompanyPolicy_1 = require("../../middleware/requireCompanyPolicy");
const validate_1 = require("../../http/validate");
const respond_1 = require("../../http/respond");
const upload_1 = require("../../http/upload");
const service = __importStar(require("./company.service"));
const company_schemas_1 = require("./company.schemas");
const router = (0, express_1.Router)();
router.use(requireCompanyAuth_1.requireCompanyAuth, requireTenant_1.requireTenant, requireSubscription_1.requireSubscription);
router.get('/me', async (req, res, next) => {
try {
const company = await service.getCompany(req.companyId);
(0, respond_1.ok)(res, company);
}
catch (err) {
next(err);
}
});
router.patch('/me', (0, requireRole_1.requireRole)('OWNER'), async (req, res, next) => {
try {
const body = (0, validate_1.parseBody)(company_schemas_1.companySchema, req);
const company = await service.updateCompany(req.companyId, body);
(0, respond_1.ok)(res, company);
}
catch (err) {
next(err);
}
});
router.get('/me/brand', async (req, res, next) => {
try {
const brand = await service.getBrand(req.companyId);
(0, respond_1.ok)(res, brand);
}
catch (err) {
next(err);
}
});
router.patch('/me/brand', (0, requireRole_1.requireRole)('OWNER'), async (req, res, next) => {
try {
const body = (0, validate_1.parseBody)(company_schemas_1.brandSchema, req);
const brand = await service.updateBrand(req.companyId, body, req.company.name, req.company.slug);
(0, respond_1.ok)(res, brand);
}
catch (err) {
next(err);
}
});
router.post('/me/brand/logo', (0, requireRole_1.requireRole)('OWNER'), upload_1.imageUpload.single('file'), async (req, res, next) => {
try {
(0, upload_1.assertImageFile)(req.file, 'logo');
const brand = await service.uploadLogo(req.companyId, req.company.name, req.company.slug, req.file.buffer);
(0, respond_1.ok)(res, brand);
}
catch (err) {
next(err);
}
});
router.post('/me/brand/hero', (0, requireRole_1.requireRole)('OWNER'), upload_1.imageUpload.single('file'), async (req, res, next) => {
try {
(0, upload_1.assertImageFile)(req.file, 'hero image');
const brand = await service.uploadHeroImage(req.companyId, req.company.name, req.company.slug, req.file.buffer);
(0, respond_1.ok)(res, brand);
}
catch (err) {
next(err);
}
});
router.post('/me/brand/subdomain/check', (0, requireRole_1.requireRole)('OWNER'), async (req, res, next) => {
try {
const { subdomain } = (0, validate_1.parseBody)(company_schemas_1.subdomainSchema, req);
const result = await service.checkSubdomainAvailability(subdomain, req.companyId);
(0, respond_1.ok)(res, result);
}
catch (err) {
next(err);
}
});
router.post('/me/brand/custom-domain', (0, requireRole_1.requireRole)('OWNER'), async (req, res, next) => {
try {
const { customDomain } = (0, validate_1.parseBody)(company_schemas_1.customDomainSchema, req);
const brand = await service.setCustomDomain(req.companyId, req.company.name, req.company.slug, customDomain);
(0, respond_1.ok)(res, brand);
}
catch (err) {
next(err);
}
});
router.get('/me/brand/custom-domain/status', async (req, res, next) => {
try {
const status = await service.getCustomDomainStatus(req.companyId);
(0, respond_1.ok)(res, status);
}
catch (err) {
next(err);
}
});
router.delete('/me/brand/custom-domain', (0, requireRole_1.requireRole)('OWNER'), async (req, res, next) => {
try {
const result = await service.removeCustomDomain(req.companyId);
(0, respond_1.ok)(res, result);
}
catch (err) {
next(err);
}
});
router.get('/me/contract-settings', async (req, res, next) => {
try {
const settings = await service.getContractSettings(req.companyId);
(0, respond_1.ok)(res, settings);
}
catch (err) {
next(err);
}
});
router.patch('/me/contract-settings', (0, requireRole_1.requireRole)('MANAGER'), async (req, res, next) => {
try {
const body = (0, validate_1.parseBody)(company_schemas_1.contractSettingsSchema, req);
const settings = await service.updateContractSettings(req.companyId, body);
(0, respond_1.ok)(res, settings);
}
catch (err) {
next(err);
}
});
router.get('/me/insurance-policies', async (req, res, next) => {
try {
const policies = await service.getInsurancePolicies(req.companyId);
(0, respond_1.ok)(res, policies);
}
catch (err) {
next(err);
}
});
router.post('/me/insurance-policies', (0, requireRole_1.requireRole)('MANAGER'), async (req, res, next) => {
try {
const body = (0, validate_1.parseBody)(company_schemas_1.insurancePolicySchema, req);
const policy = await service.createInsurancePolicy(req.companyId, body);
(0, respond_1.created)(res, policy);
}
catch (err) {
next(err);
}
});
router.patch('/me/insurance-policies/:id', (0, requireRole_1.requireRole)('MANAGER'), async (req, res, next) => {
try {
const { id } = (0, validate_1.parseParams)(company_schemas_1.idParamSchema, req);
const body = (0, validate_1.parseBody)(company_schemas_1.insurancePolicySchema.partial(), req);
const policy = await service.updateInsurancePolicy(id, req.companyId, body);
(0, respond_1.ok)(res, policy);
}
catch (err) {
next(err);
}
});
router.delete('/me/insurance-policies/:id', (0, requireRole_1.requireRole)('MANAGER'), async (req, res, next) => {
try {
const { id } = (0, validate_1.parseParams)(company_schemas_1.idParamSchema, req);
await service.deleteInsurancePolicy(id, req.companyId);
(0, respond_1.ok)(res, { success: true });
}
catch (err) {
next(err);
}
});
router.get('/me/pricing-rules', async (req, res, next) => {
try {
const rules = await service.getPricingRules(req.companyId);
(0, respond_1.ok)(res, rules);
}
catch (err) {
next(err);
}
});
router.post('/me/pricing-rules', (0, requireRole_1.requireRole)('MANAGER'), async (req, res, next) => {
try {
const body = (0, validate_1.parseBody)(company_schemas_1.pricingRuleSchema, req);
const rule = await service.createPricingRule(req.companyId, body);
(0, respond_1.created)(res, rule);
}
catch (err) {
next(err);
}
});
router.patch('/me/pricing-rules/:id', (0, requireRole_1.requireRole)('MANAGER'), async (req, res, next) => {
try {
const { id } = (0, validate_1.parseParams)(company_schemas_1.idParamSchema, req);
const body = (0, validate_1.parseBody)(company_schemas_1.pricingRuleSchema.partial(), req);
const rule = await service.updatePricingRule(id, req.companyId, body);
(0, respond_1.ok)(res, rule);
}
catch (err) {
next(err);
}
});
router.delete('/me/pricing-rules/:id', (0, requireCompanyPolicy_1.requireCompanyPolicy)('deletePricingRule'), async (req, res, next) => {
try {
const { id } = (0, validate_1.parseParams)(company_schemas_1.idParamSchema, req);
await service.deletePricingRule(id, req.companyId);
(0, respond_1.ok)(res, { success: true });
}
catch (err) {
next(err);
}
});
router.get('/me/accounting-settings', async (req, res, next) => {
try {
const settings = await service.getAccountingSettings(req.companyId);
(0, respond_1.ok)(res, settings);
}
catch (err) {
next(err);
}
});
router.patch('/me/accounting-settings', (0, requireCompanyPolicy_1.requireCompanyPolicy)('updateAccountingSettings'), async (req, res, next) => {
try {
const body = (0, validate_1.parseBody)(company_schemas_1.accountingSettingsSchema, req);
const settings = await service.updateAccountingSettings(req.companyId, body);
(0, respond_1.ok)(res, settings);
}
catch (err) {
next(err);
}
});
router.get('/me/api-key', (0, requireCompanyPolicy_1.requireCompanyPolicy)('viewApiKey'), async (req, res, next) => {
try {
const company = await service.getApiKey(req.companyId);
(0, respond_1.ok)(res, company);
}
catch (err) {
next(err);
}
});
router.post('/me/api-key/regenerate', (0, requireCompanyPolicy_1.requireCompanyPolicy)('regenerateApiKey'), async (req, res, next) => {
try {
const company = await service.regenerateApiKey(req.companyId);
(0, respond_1.ok)(res, company);
}
catch (err) {
next(err);
}
});
exports.default = router;
//# sourceMappingURL=company.routes.js.map
File diff suppressed because one or more lines are too long
+893
View File
@@ -0,0 +1,893 @@
import { z } from 'zod';
export declare const companySchema: z.ZodObject<{
name: z.ZodOptional<z.ZodString>;
email: z.ZodOptional<z.ZodString>;
phone: z.ZodOptional<z.ZodString>;
address: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
}, "strip", z.ZodTypeAny, {
name?: string | undefined;
email?: string | undefined;
phone?: string | undefined;
address?: Record<string, unknown> | undefined;
}, {
name?: string | undefined;
email?: string | undefined;
phone?: string | undefined;
address?: Record<string, unknown> | undefined;
}>;
export declare const brandSchema: z.ZodObject<{
displayName: z.ZodOptional<z.ZodString>;
tagline: z.ZodOptional<z.ZodString>;
primaryColor: z.ZodOptional<z.ZodString>;
accentColor: z.ZodOptional<z.ZodString>;
publicEmail: z.ZodOptional<z.ZodString>;
publicPhone: z.ZodOptional<z.ZodString>;
publicAddress: z.ZodOptional<z.ZodString>;
publicCity: z.ZodOptional<z.ZodString>;
publicCountry: z.ZodOptional<z.ZodString>;
websiteUrl: z.ZodOptional<z.ZodString>;
whatsappNumber: z.ZodOptional<z.ZodString>;
defaultLocale: z.ZodOptional<z.ZodString>;
defaultCurrency: z.ZodOptional<z.ZodLiteral<"MAD">>;
amanpayMerchantId: z.ZodOptional<z.ZodString>;
amanpaySecretKey: z.ZodOptional<z.ZodString>;
paypalEmail: z.ZodOptional<z.ZodString>;
paypalMerchantId: z.ZodOptional<z.ZodString>;
isListedOnMarketplace: z.ZodOptional<z.ZodBoolean>;
homePageConfig: z.ZodOptional<z.ZodObject<{
heroTitle: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodNull]>>;
heroDescription: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodNull]>>;
viewOffersLabel: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodNull]>>;
viewPricingLabel: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodNull]>>;
contactCompanyLabel: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodNull]>>;
activeOffersTitle: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodNull]>>;
seeAllOffersLabel: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodNull]>>;
noActiveOffersLabel: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodNull]>>;
publishedVehiclesTitle: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodNull]>>;
viewVehicleLabel: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodNull]>>;
pricingEyebrow: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodNull]>>;
pricingTitle: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodNull]>>;
pricingDescription: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodNull]>>;
showOffers: z.ZodOptional<z.ZodBoolean>;
showVehicles: z.ZodOptional<z.ZodBoolean>;
showPricing: z.ZodOptional<z.ZodBoolean>;
layout: z.ZodOptional<z.ZodObject<{
items: z.ZodArray<z.ZodObject<{
id: z.ZodString;
type: z.ZodEnum<["hero", "offers", "vehicles", "pricing"]>;
x: z.ZodNumber;
y: z.ZodNumber;
w: z.ZodNumber;
h: z.ZodNumber;
}, "strip", z.ZodTypeAny, {
type: "hero" | "vehicles" | "pricing" | "offers";
id: string;
x: number;
y: number;
w: number;
h: number;
}, {
type: "hero" | "vehicles" | "pricing" | "offers";
id: string;
x: number;
y: number;
w: number;
h: number;
}>, "many">;
}, "strip", z.ZodTypeAny, {
items: {
type: "hero" | "vehicles" | "pricing" | "offers";
id: string;
x: number;
y: number;
w: number;
h: number;
}[];
}, {
items: {
type: "hero" | "vehicles" | "pricing" | "offers";
id: string;
x: number;
y: number;
w: number;
h: number;
}[];
}>>;
}, "strip", z.ZodTypeAny, {
heroTitle?: string | null | undefined;
heroDescription?: string | null | undefined;
viewOffersLabel?: string | null | undefined;
viewPricingLabel?: string | null | undefined;
contactCompanyLabel?: string | null | undefined;
activeOffersTitle?: string | null | undefined;
seeAllOffersLabel?: string | null | undefined;
noActiveOffersLabel?: string | null | undefined;
publishedVehiclesTitle?: string | null | undefined;
viewVehicleLabel?: string | null | undefined;
pricingEyebrow?: string | null | undefined;
pricingTitle?: string | null | undefined;
pricingDescription?: string | null | undefined;
showOffers?: boolean | undefined;
showVehicles?: boolean | undefined;
showPricing?: boolean | undefined;
layout?: {
items: {
type: "hero" | "vehicles" | "pricing" | "offers";
id: string;
x: number;
y: number;
w: number;
h: number;
}[];
} | undefined;
}, {
heroTitle?: string | null | undefined;
heroDescription?: string | null | undefined;
viewOffersLabel?: string | null | undefined;
viewPricingLabel?: string | null | undefined;
contactCompanyLabel?: string | null | undefined;
activeOffersTitle?: string | null | undefined;
seeAllOffersLabel?: string | null | undefined;
noActiveOffersLabel?: string | null | undefined;
publishedVehiclesTitle?: string | null | undefined;
viewVehicleLabel?: string | null | undefined;
pricingEyebrow?: string | null | undefined;
pricingTitle?: string | null | undefined;
pricingDescription?: string | null | undefined;
showOffers?: boolean | undefined;
showVehicles?: boolean | undefined;
showPricing?: boolean | undefined;
layout?: {
items: {
type: "hero" | "vehicles" | "pricing" | "offers";
id: string;
x: number;
y: number;
w: number;
h: number;
}[];
} | undefined;
}>>;
menuConfig: z.ZodOptional<z.ZodObject<{
aboutLabel: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodNull]>>;
vehiclesLabel: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodNull]>>;
offersLabel: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodNull]>>;
pricingLabel: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodNull]>>;
blogLabel: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodNull]>>;
contactLabel: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodNull]>>;
bookCarLabel: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodNull]>>;
siteNavigationLabel: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodNull]>>;
showAbout: z.ZodOptional<z.ZodBoolean>;
showVehicles: z.ZodOptional<z.ZodBoolean>;
showOffers: z.ZodOptional<z.ZodBoolean>;
showPricing: z.ZodOptional<z.ZodBoolean>;
showBlog: z.ZodOptional<z.ZodBoolean>;
showContact: z.ZodOptional<z.ZodBoolean>;
pageSections: z.ZodOptional<z.ZodObject<{
home: z.ZodOptional<z.ZodObject<{
hero: z.ZodOptional<z.ZodBoolean>;
offers: z.ZodOptional<z.ZodBoolean>;
vehicles: z.ZodOptional<z.ZodBoolean>;
pricing: z.ZodOptional<z.ZodBoolean>;
}, "strip", z.ZodTypeAny, {
hero?: boolean | undefined;
vehicles?: boolean | undefined;
pricing?: boolean | undefined;
offers?: boolean | undefined;
}, {
hero?: boolean | undefined;
vehicles?: boolean | undefined;
pricing?: boolean | undefined;
offers?: boolean | undefined;
}>>;
about: z.ZodOptional<z.ZodObject<{
hero: z.ZodOptional<z.ZodBoolean>;
highlights: z.ZodOptional<z.ZodBoolean>;
details: z.ZodOptional<z.ZodBoolean>;
}, "strip", z.ZodTypeAny, {
details?: boolean | undefined;
hero?: boolean | undefined;
highlights?: boolean | undefined;
}, {
details?: boolean | undefined;
hero?: boolean | undefined;
highlights?: boolean | undefined;
}>>;
offers: z.ZodOptional<z.ZodObject<{
header: z.ZodOptional<z.ZodBoolean>;
grid: z.ZodOptional<z.ZodBoolean>;
}, "strip", z.ZodTypeAny, {
header?: boolean | undefined;
grid?: boolean | undefined;
}, {
header?: boolean | undefined;
grid?: boolean | undefined;
}>>;
pricing: z.ZodOptional<z.ZodObject<{
hero: z.ZodOptional<z.ZodBoolean>;
plans: z.ZodOptional<z.ZodBoolean>;
payments: z.ZodOptional<z.ZodBoolean>;
faq: z.ZodOptional<z.ZodBoolean>;
}, "strip", z.ZodTypeAny, {
plans?: boolean | undefined;
hero?: boolean | undefined;
payments?: boolean | undefined;
faq?: boolean | undefined;
}, {
plans?: boolean | undefined;
hero?: boolean | undefined;
payments?: boolean | undefined;
faq?: boolean | undefined;
}>>;
vehicles: z.ZodOptional<z.ZodObject<{
header: z.ZodOptional<z.ZodBoolean>;
filters: z.ZodOptional<z.ZodBoolean>;
grid: z.ZodOptional<z.ZodBoolean>;
}, "strip", z.ZodTypeAny, {
header?: boolean | undefined;
grid?: boolean | undefined;
filters?: boolean | undefined;
}, {
header?: boolean | undefined;
grid?: boolean | undefined;
filters?: boolean | undefined;
}>>;
vehicleDetail: z.ZodOptional<z.ZodObject<{
gallery: z.ZodOptional<z.ZodBoolean>;
summary: z.ZodOptional<z.ZodBoolean>;
}, "strip", z.ZodTypeAny, {
summary?: boolean | undefined;
gallery?: boolean | undefined;
}, {
summary?: boolean | undefined;
gallery?: boolean | undefined;
}>>;
blog: z.ZodOptional<z.ZodObject<{
hero: z.ZodOptional<z.ZodBoolean>;
posts: z.ZodOptional<z.ZodBoolean>;
}, "strip", z.ZodTypeAny, {
hero?: boolean | undefined;
posts?: boolean | undefined;
}, {
hero?: boolean | undefined;
posts?: boolean | undefined;
}>>;
contact: z.ZodOptional<z.ZodObject<{
content: z.ZodOptional<z.ZodBoolean>;
}, "strip", z.ZodTypeAny, {
content?: boolean | undefined;
}, {
content?: boolean | undefined;
}>>;
booking: z.ZodOptional<z.ZodObject<{
content: z.ZodOptional<z.ZodBoolean>;
}, "strip", z.ZodTypeAny, {
content?: boolean | undefined;
}, {
content?: boolean | undefined;
}>>;
bookingConfirmation: z.ZodOptional<z.ZodObject<{
hero: z.ZodOptional<z.ZodBoolean>;
summary: z.ZodOptional<z.ZodBoolean>;
actions: z.ZodOptional<z.ZodBoolean>;
}, "strip", z.ZodTypeAny, {
summary?: boolean | undefined;
actions?: boolean | undefined;
hero?: boolean | undefined;
}, {
summary?: boolean | undefined;
actions?: boolean | undefined;
hero?: boolean | undefined;
}>>;
}, "strip", z.ZodTypeAny, {
vehicles?: {
header?: boolean | undefined;
grid?: boolean | undefined;
filters?: boolean | undefined;
} | undefined;
pricing?: {
plans?: boolean | undefined;
hero?: boolean | undefined;
payments?: boolean | undefined;
faq?: boolean | undefined;
} | undefined;
offers?: {
header?: boolean | undefined;
grid?: boolean | undefined;
} | undefined;
home?: {
hero?: boolean | undefined;
vehicles?: boolean | undefined;
pricing?: boolean | undefined;
offers?: boolean | undefined;
} | undefined;
about?: {
details?: boolean | undefined;
hero?: boolean | undefined;
highlights?: boolean | undefined;
} | undefined;
vehicleDetail?: {
summary?: boolean | undefined;
gallery?: boolean | undefined;
} | undefined;
blog?: {
hero?: boolean | undefined;
posts?: boolean | undefined;
} | undefined;
contact?: {
content?: boolean | undefined;
} | undefined;
booking?: {
content?: boolean | undefined;
} | undefined;
bookingConfirmation?: {
summary?: boolean | undefined;
actions?: boolean | undefined;
hero?: boolean | undefined;
} | undefined;
}, {
vehicles?: {
header?: boolean | undefined;
grid?: boolean | undefined;
filters?: boolean | undefined;
} | undefined;
pricing?: {
plans?: boolean | undefined;
hero?: boolean | undefined;
payments?: boolean | undefined;
faq?: boolean | undefined;
} | undefined;
offers?: {
header?: boolean | undefined;
grid?: boolean | undefined;
} | undefined;
home?: {
hero?: boolean | undefined;
vehicles?: boolean | undefined;
pricing?: boolean | undefined;
offers?: boolean | undefined;
} | undefined;
about?: {
details?: boolean | undefined;
hero?: boolean | undefined;
highlights?: boolean | undefined;
} | undefined;
vehicleDetail?: {
summary?: boolean | undefined;
gallery?: boolean | undefined;
} | undefined;
blog?: {
hero?: boolean | undefined;
posts?: boolean | undefined;
} | undefined;
contact?: {
content?: boolean | undefined;
} | undefined;
booking?: {
content?: boolean | undefined;
} | undefined;
bookingConfirmation?: {
summary?: boolean | undefined;
actions?: boolean | undefined;
hero?: boolean | undefined;
} | undefined;
}>>;
}, "strip", z.ZodTypeAny, {
showOffers?: boolean | undefined;
showVehicles?: boolean | undefined;
showPricing?: boolean | undefined;
aboutLabel?: string | null | undefined;
vehiclesLabel?: string | null | undefined;
offersLabel?: string | null | undefined;
pricingLabel?: string | null | undefined;
blogLabel?: string | null | undefined;
contactLabel?: string | null | undefined;
bookCarLabel?: string | null | undefined;
siteNavigationLabel?: string | null | undefined;
showAbout?: boolean | undefined;
showBlog?: boolean | undefined;
showContact?: boolean | undefined;
pageSections?: {
vehicles?: {
header?: boolean | undefined;
grid?: boolean | undefined;
filters?: boolean | undefined;
} | undefined;
pricing?: {
plans?: boolean | undefined;
hero?: boolean | undefined;
payments?: boolean | undefined;
faq?: boolean | undefined;
} | undefined;
offers?: {
header?: boolean | undefined;
grid?: boolean | undefined;
} | undefined;
home?: {
hero?: boolean | undefined;
vehicles?: boolean | undefined;
pricing?: boolean | undefined;
offers?: boolean | undefined;
} | undefined;
about?: {
details?: boolean | undefined;
hero?: boolean | undefined;
highlights?: boolean | undefined;
} | undefined;
vehicleDetail?: {
summary?: boolean | undefined;
gallery?: boolean | undefined;
} | undefined;
blog?: {
hero?: boolean | undefined;
posts?: boolean | undefined;
} | undefined;
contact?: {
content?: boolean | undefined;
} | undefined;
booking?: {
content?: boolean | undefined;
} | undefined;
bookingConfirmation?: {
summary?: boolean | undefined;
actions?: boolean | undefined;
hero?: boolean | undefined;
} | undefined;
} | undefined;
}, {
showOffers?: boolean | undefined;
showVehicles?: boolean | undefined;
showPricing?: boolean | undefined;
aboutLabel?: string | null | undefined;
vehiclesLabel?: string | null | undefined;
offersLabel?: string | null | undefined;
pricingLabel?: string | null | undefined;
blogLabel?: string | null | undefined;
contactLabel?: string | null | undefined;
bookCarLabel?: string | null | undefined;
siteNavigationLabel?: string | null | undefined;
showAbout?: boolean | undefined;
showBlog?: boolean | undefined;
showContact?: boolean | undefined;
pageSections?: {
vehicles?: {
header?: boolean | undefined;
grid?: boolean | undefined;
filters?: boolean | undefined;
} | undefined;
pricing?: {
plans?: boolean | undefined;
hero?: boolean | undefined;
payments?: boolean | undefined;
faq?: boolean | undefined;
} | undefined;
offers?: {
header?: boolean | undefined;
grid?: boolean | undefined;
} | undefined;
home?: {
hero?: boolean | undefined;
vehicles?: boolean | undefined;
pricing?: boolean | undefined;
offers?: boolean | undefined;
} | undefined;
about?: {
details?: boolean | undefined;
hero?: boolean | undefined;
highlights?: boolean | undefined;
} | undefined;
vehicleDetail?: {
summary?: boolean | undefined;
gallery?: boolean | undefined;
} | undefined;
blog?: {
hero?: boolean | undefined;
posts?: boolean | undefined;
} | undefined;
contact?: {
content?: boolean | undefined;
} | undefined;
booking?: {
content?: boolean | undefined;
} | undefined;
bookingConfirmation?: {
summary?: boolean | undefined;
actions?: boolean | undefined;
hero?: boolean | undefined;
} | undefined;
} | undefined;
}>>;
}, "strip", z.ZodTypeAny, {
displayName?: string | undefined;
tagline?: string | undefined;
publicEmail?: string | undefined;
publicPhone?: string | undefined;
publicAddress?: string | undefined;
publicCity?: string | undefined;
publicCountry?: string | undefined;
websiteUrl?: string | undefined;
whatsappNumber?: string | undefined;
defaultLocale?: string | undefined;
defaultCurrency?: "MAD" | undefined;
isListedOnMarketplace?: boolean | undefined;
homePageConfig?: {
heroTitle?: string | null | undefined;
heroDescription?: string | null | undefined;
viewOffersLabel?: string | null | undefined;
viewPricingLabel?: string | null | undefined;
contactCompanyLabel?: string | null | undefined;
activeOffersTitle?: string | null | undefined;
seeAllOffersLabel?: string | null | undefined;
noActiveOffersLabel?: string | null | undefined;
publishedVehiclesTitle?: string | null | undefined;
viewVehicleLabel?: string | null | undefined;
pricingEyebrow?: string | null | undefined;
pricingTitle?: string | null | undefined;
pricingDescription?: string | null | undefined;
showOffers?: boolean | undefined;
showVehicles?: boolean | undefined;
showPricing?: boolean | undefined;
layout?: {
items: {
type: "hero" | "vehicles" | "pricing" | "offers";
id: string;
x: number;
y: number;
w: number;
h: number;
}[];
} | undefined;
} | undefined;
menuConfig?: {
showOffers?: boolean | undefined;
showVehicles?: boolean | undefined;
showPricing?: boolean | undefined;
aboutLabel?: string | null | undefined;
vehiclesLabel?: string | null | undefined;
offersLabel?: string | null | undefined;
pricingLabel?: string | null | undefined;
blogLabel?: string | null | undefined;
contactLabel?: string | null | undefined;
bookCarLabel?: string | null | undefined;
siteNavigationLabel?: string | null | undefined;
showAbout?: boolean | undefined;
showBlog?: boolean | undefined;
showContact?: boolean | undefined;
pageSections?: {
vehicles?: {
header?: boolean | undefined;
grid?: boolean | undefined;
filters?: boolean | undefined;
} | undefined;
pricing?: {
plans?: boolean | undefined;
hero?: boolean | undefined;
payments?: boolean | undefined;
faq?: boolean | undefined;
} | undefined;
offers?: {
header?: boolean | undefined;
grid?: boolean | undefined;
} | undefined;
home?: {
hero?: boolean | undefined;
vehicles?: boolean | undefined;
pricing?: boolean | undefined;
offers?: boolean | undefined;
} | undefined;
about?: {
details?: boolean | undefined;
hero?: boolean | undefined;
highlights?: boolean | undefined;
} | undefined;
vehicleDetail?: {
summary?: boolean | undefined;
gallery?: boolean | undefined;
} | undefined;
blog?: {
hero?: boolean | undefined;
posts?: boolean | undefined;
} | undefined;
contact?: {
content?: boolean | undefined;
} | undefined;
booking?: {
content?: boolean | undefined;
} | undefined;
bookingConfirmation?: {
summary?: boolean | undefined;
actions?: boolean | undefined;
hero?: boolean | undefined;
} | undefined;
} | undefined;
} | undefined;
amanpaySecretKey?: string | undefined;
amanpayMerchantId?: string | undefined;
paypalEmail?: string | undefined;
paypalMerchantId?: string | undefined;
primaryColor?: string | undefined;
accentColor?: string | undefined;
}, {
displayName?: string | undefined;
tagline?: string | undefined;
publicEmail?: string | undefined;
publicPhone?: string | undefined;
publicAddress?: string | undefined;
publicCity?: string | undefined;
publicCountry?: string | undefined;
websiteUrl?: string | undefined;
whatsappNumber?: string | undefined;
defaultLocale?: string | undefined;
defaultCurrency?: "MAD" | undefined;
isListedOnMarketplace?: boolean | undefined;
homePageConfig?: {
heroTitle?: string | null | undefined;
heroDescription?: string | null | undefined;
viewOffersLabel?: string | null | undefined;
viewPricingLabel?: string | null | undefined;
contactCompanyLabel?: string | null | undefined;
activeOffersTitle?: string | null | undefined;
seeAllOffersLabel?: string | null | undefined;
noActiveOffersLabel?: string | null | undefined;
publishedVehiclesTitle?: string | null | undefined;
viewVehicleLabel?: string | null | undefined;
pricingEyebrow?: string | null | undefined;
pricingTitle?: string | null | undefined;
pricingDescription?: string | null | undefined;
showOffers?: boolean | undefined;
showVehicles?: boolean | undefined;
showPricing?: boolean | undefined;
layout?: {
items: {
type: "hero" | "vehicles" | "pricing" | "offers";
id: string;
x: number;
y: number;
w: number;
h: number;
}[];
} | undefined;
} | undefined;
menuConfig?: {
showOffers?: boolean | undefined;
showVehicles?: boolean | undefined;
showPricing?: boolean | undefined;
aboutLabel?: string | null | undefined;
vehiclesLabel?: string | null | undefined;
offersLabel?: string | null | undefined;
pricingLabel?: string | null | undefined;
blogLabel?: string | null | undefined;
contactLabel?: string | null | undefined;
bookCarLabel?: string | null | undefined;
siteNavigationLabel?: string | null | undefined;
showAbout?: boolean | undefined;
showBlog?: boolean | undefined;
showContact?: boolean | undefined;
pageSections?: {
vehicles?: {
header?: boolean | undefined;
grid?: boolean | undefined;
filters?: boolean | undefined;
} | undefined;
pricing?: {
plans?: boolean | undefined;
hero?: boolean | undefined;
payments?: boolean | undefined;
faq?: boolean | undefined;
} | undefined;
offers?: {
header?: boolean | undefined;
grid?: boolean | undefined;
} | undefined;
home?: {
hero?: boolean | undefined;
vehicles?: boolean | undefined;
pricing?: boolean | undefined;
offers?: boolean | undefined;
} | undefined;
about?: {
details?: boolean | undefined;
hero?: boolean | undefined;
highlights?: boolean | undefined;
} | undefined;
vehicleDetail?: {
summary?: boolean | undefined;
gallery?: boolean | undefined;
} | undefined;
blog?: {
hero?: boolean | undefined;
posts?: boolean | undefined;
} | undefined;
contact?: {
content?: boolean | undefined;
} | undefined;
booking?: {
content?: boolean | undefined;
} | undefined;
bookingConfirmation?: {
summary?: boolean | undefined;
actions?: boolean | undefined;
hero?: boolean | undefined;
} | undefined;
} | undefined;
} | undefined;
amanpaySecretKey?: string | undefined;
amanpayMerchantId?: string | undefined;
paypalEmail?: string | undefined;
paypalMerchantId?: string | undefined;
primaryColor?: string | undefined;
accentColor?: string | undefined;
}>;
export declare const contractSettingsSchema: z.ZodObject<{
legalName: z.ZodOptional<z.ZodString>;
registrationNumber: z.ZodOptional<z.ZodString>;
taxId: z.ZodOptional<z.ZodString>;
terms: z.ZodOptional<z.ZodString>;
fuelPolicy: z.ZodOptional<z.ZodString>;
depositPolicy: z.ZodOptional<z.ZodString>;
lateFeePolicy: z.ZodOptional<z.ZodString>;
damagePolicy: z.ZodOptional<z.ZodString>;
contractFooterNote: z.ZodOptional<z.ZodString>;
invoiceFooterNote: z.ZodOptional<z.ZodString>;
signatureRequired: z.ZodOptional<z.ZodBoolean>;
showTax: z.ZodOptional<z.ZodBoolean>;
taxRate: z.ZodOptional<z.ZodNumber>;
taxLabel: z.ZodOptional<z.ZodString>;
fuelPolicyType: z.ZodOptional<z.ZodEnum<["FULL_TO_FULL", "FULL_TO_EMPTY", "SAME_TO_SAME", "PREPAID", "FREE"]>>;
fuelPolicyNote: z.ZodOptional<z.ZodString>;
fuelChargePerLiter: z.ZodOptional<z.ZodNumber>;
fuelShortfallFee: z.ZodOptional<z.ZodNumber>;
lateFeePerHour: z.ZodOptional<z.ZodNumber>;
additionalDriverCharge: z.ZodOptional<z.ZodEnum<["FREE", "PER_DAY", "FLAT"]>>;
additionalDriverDailyRate: z.ZodOptional<z.ZodNumber>;
additionalDriverFlatRate: z.ZodOptional<z.ZodNumber>;
}, "strip", z.ZodTypeAny, {
legalName?: string | undefined;
registrationNumber?: string | undefined;
taxId?: string | undefined;
terms?: string | undefined;
fuelPolicyType?: "FULL_TO_FULL" | "FULL_TO_EMPTY" | "SAME_TO_SAME" | "PREPAID" | "FREE" | undefined;
lateFeePerHour?: number | undefined;
taxRate?: number | undefined;
signatureRequired?: boolean | undefined;
showTax?: boolean | undefined;
fuelPolicy?: string | undefined;
depositPolicy?: string | undefined;
lateFeePolicy?: string | undefined;
damagePolicy?: string | undefined;
contractFooterNote?: string | undefined;
invoiceFooterNote?: string | undefined;
taxLabel?: string | undefined;
fuelPolicyNote?: string | undefined;
fuelChargePerLiter?: number | undefined;
fuelShortfallFee?: number | undefined;
additionalDriverCharge?: "FREE" | "PER_DAY" | "FLAT" | undefined;
additionalDriverDailyRate?: number | undefined;
additionalDriverFlatRate?: number | undefined;
}, {
legalName?: string | undefined;
registrationNumber?: string | undefined;
taxId?: string | undefined;
terms?: string | undefined;
fuelPolicyType?: "FULL_TO_FULL" | "FULL_TO_EMPTY" | "SAME_TO_SAME" | "PREPAID" | "FREE" | undefined;
lateFeePerHour?: number | undefined;
taxRate?: number | undefined;
signatureRequired?: boolean | undefined;
showTax?: boolean | undefined;
fuelPolicy?: string | undefined;
depositPolicy?: string | undefined;
lateFeePolicy?: string | undefined;
damagePolicy?: string | undefined;
contractFooterNote?: string | undefined;
invoiceFooterNote?: string | undefined;
taxLabel?: string | undefined;
fuelPolicyNote?: string | undefined;
fuelChargePerLiter?: number | undefined;
fuelShortfallFee?: number | undefined;
additionalDriverCharge?: "FREE" | "PER_DAY" | "FLAT" | undefined;
additionalDriverDailyRate?: number | undefined;
additionalDriverFlatRate?: number | undefined;
}>;
export declare const insurancePolicySchema: z.ZodObject<{
name: z.ZodString;
description: z.ZodOptional<z.ZodString>;
type: z.ZodEnum<["CDW", "SCDW", "THEFT", "THIRD_PARTY", "FULL", "BASIC", "ROADSIDE", "PERSONAL", "CUSTOM"]>;
chargeType: z.ZodEnum<["PER_DAY", "PER_RENTAL", "PERCENTAGE_OF_RENTAL"]>;
chargeValue: z.ZodNumber;
isRequired: z.ZodDefault<z.ZodBoolean>;
isActive: z.ZodDefault<z.ZodBoolean>;
sortOrder: z.ZodDefault<z.ZodNumber>;
}, "strip", z.ZodTypeAny, {
type: "FULL" | "CDW" | "SCDW" | "THEFT" | "THIRD_PARTY" | "BASIC" | "ROADSIDE" | "PERSONAL" | "CUSTOM";
name: string;
isActive: boolean;
sortOrder: number;
isRequired: boolean;
chargeType: "PER_DAY" | "PER_RENTAL" | "PERCENTAGE_OF_RENTAL";
chargeValue: number;
description?: string | undefined;
}, {
type: "FULL" | "CDW" | "SCDW" | "THEFT" | "THIRD_PARTY" | "BASIC" | "ROADSIDE" | "PERSONAL" | "CUSTOM";
name: string;
chargeType: "PER_DAY" | "PER_RENTAL" | "PERCENTAGE_OF_RENTAL";
chargeValue: number;
description?: string | undefined;
isActive?: boolean | undefined;
sortOrder?: number | undefined;
isRequired?: boolean | undefined;
}>;
export declare const pricingRuleSchema: z.ZodObject<{
name: z.ZodString;
type: z.ZodEnum<["SURCHARGE", "DISCOUNT"]>;
condition: z.ZodEnum<["AGE_LESS_THAN", "AGE_GREATER_THAN", "LICENSE_YEARS_LESS_THAN", "LICENSE_YEARS_GREATER_THAN"]>;
conditionValue: z.ZodNumber;
adjustmentType: z.ZodEnum<["PERCENTAGE", "FLAT_PER_DAY", "FLAT_TOTAL"]>;
adjustmentValue: z.ZodNumber;
isActive: z.ZodDefault<z.ZodBoolean>;
description: z.ZodOptional<z.ZodString>;
}, "strip", z.ZodTypeAny, {
type: "DISCOUNT" | "SURCHARGE";
name: string;
isActive: boolean;
condition: "AGE_LESS_THAN" | "AGE_GREATER_THAN" | "LICENSE_YEARS_LESS_THAN" | "LICENSE_YEARS_GREATER_THAN";
conditionValue: number;
adjustmentType: "PERCENTAGE" | "FLAT_PER_DAY" | "FLAT_TOTAL";
adjustmentValue: number;
description?: string | undefined;
}, {
type: "DISCOUNT" | "SURCHARGE";
name: string;
condition: "AGE_LESS_THAN" | "AGE_GREATER_THAN" | "LICENSE_YEARS_LESS_THAN" | "LICENSE_YEARS_GREATER_THAN";
conditionValue: number;
adjustmentType: "PERCENTAGE" | "FLAT_PER_DAY" | "FLAT_TOTAL";
adjustmentValue: number;
description?: string | undefined;
isActive?: boolean | undefined;
}>;
export declare const accountingSettingsSchema: z.ZodObject<{
reportingPeriod: z.ZodOptional<z.ZodEnum<["WEEKLY", "MONTHLY", "QUARTERLY", "ANNUAL"]>>;
fiscalYearStart: z.ZodOptional<z.ZodNumber>;
currency: z.ZodOptional<z.ZodLiteral<"MAD">>;
accountantEmail: z.ZodOptional<z.ZodString>;
accountantName: z.ZodOptional<z.ZodString>;
autoSendReport: z.ZodOptional<z.ZodBoolean>;
reportFormat: z.ZodOptional<z.ZodEnum<["PDF", "CSV", "BOTH"]>>;
}, "strip", z.ZodTypeAny, {
currency?: "MAD" | undefined;
reportingPeriod?: "MONTHLY" | "ANNUAL" | "WEEKLY" | "QUARTERLY" | undefined;
fiscalYearStart?: number | undefined;
accountantEmail?: string | undefined;
accountantName?: string | undefined;
autoSendReport?: boolean | undefined;
reportFormat?: "CSV" | "PDF" | "BOTH" | undefined;
}, {
currency?: "MAD" | undefined;
reportingPeriod?: "MONTHLY" | "ANNUAL" | "WEEKLY" | "QUARTERLY" | undefined;
fiscalYearStart?: number | undefined;
accountantEmail?: string | undefined;
accountantName?: string | undefined;
autoSendReport?: boolean | undefined;
reportFormat?: "CSV" | "PDF" | "BOTH" | undefined;
}>;
export declare const subdomainSchema: z.ZodObject<{
subdomain: z.ZodString;
}, "strip", z.ZodTypeAny, {
subdomain: string;
}, {
subdomain: string;
}>;
export declare const customDomainSchema: z.ZodObject<{
customDomain: z.ZodString;
}, "strip", z.ZodTypeAny, {
customDomain: string;
}, {
customDomain: string;
}>;
export declare const idParamSchema: z.ZodObject<{
id: z.ZodString;
}, "strip", z.ZodTypeAny, {
id: string;
}, {
id: string;
}>;
//# sourceMappingURL=company.schemas.d.ts.map
@@ -0,0 +1 @@
{"version":3,"file":"company.schemas.d.ts","sourceRoot":"","sources":["../../../src/modules/companies/company.schemas.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAEvB,eAAO,MAAM,aAAa;;;;;;;;;;;;;;;EAKxB,CAAA;AAEF,eAAO,MAAM,WAAW;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAuFtB,CAAA;AAEF,eAAO,MAAM,sBAAsB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAuBjC,CAAA;AAEF,eAAO,MAAM,qBAAqB;;;;;;;;;;;;;;;;;;;;;;;;;;;EAShC,CAAA;AAEF,eAAO,MAAM,iBAAiB;;;;;;;;;;;;;;;;;;;;;;;;;;;EAS5B,CAAA;AAEF,eAAO,MAAM,wBAAwB;;;;;;;;;;;;;;;;;;;;;;;;EAQnC,CAAA;AAEF,eAAO,MAAM,eAAe;;;;;;EAAiD,CAAA;AAC7E,eAAO,MAAM,kBAAkB;;;;;;EAAiD,CAAA;AAChF,eAAO,MAAM,aAAa;;;;;;EAAqC,CAAA"}
+155
View File
@@ -0,0 +1,155 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.idParamSchema = exports.customDomainSchema = exports.subdomainSchema = exports.accountingSettingsSchema = exports.pricingRuleSchema = exports.insurancePolicySchema = exports.contractSettingsSchema = exports.brandSchema = exports.companySchema = void 0;
const zod_1 = require("zod");
exports.companySchema = zod_1.z.object({
name: zod_1.z.string().min(1).optional(),
email: zod_1.z.string().email().optional(),
phone: zod_1.z.string().optional(),
address: zod_1.z.record(zod_1.z.unknown()).optional(),
});
exports.brandSchema = zod_1.z.object({
displayName: zod_1.z.string().min(1).optional(),
tagline: zod_1.z.string().optional(),
primaryColor: zod_1.z.string().optional(),
accentColor: zod_1.z.string().optional(),
publicEmail: zod_1.z.string().email().optional(),
publicPhone: zod_1.z.string().optional(),
publicAddress: zod_1.z.string().optional(),
publicCity: zod_1.z.string().optional(),
publicCountry: zod_1.z.string().optional(),
websiteUrl: zod_1.z.string().url().optional(),
whatsappNumber: zod_1.z.string().optional(),
defaultLocale: zod_1.z.string().optional(),
defaultCurrency: zod_1.z.literal('MAD').optional(),
amanpayMerchantId: zod_1.z.string().optional(),
amanpaySecretKey: zod_1.z.string().optional(),
paypalEmail: zod_1.z.string().email().optional(),
paypalMerchantId: zod_1.z.string().optional(),
isListedOnMarketplace: zod_1.z.boolean().optional(),
homePageConfig: zod_1.z.object({
heroTitle: zod_1.z.union([zod_1.z.string(), zod_1.z.null()]).optional(),
heroDescription: zod_1.z.union([zod_1.z.string(), zod_1.z.null()]).optional(),
viewOffersLabel: zod_1.z.union([zod_1.z.string(), zod_1.z.null()]).optional(),
viewPricingLabel: zod_1.z.union([zod_1.z.string(), zod_1.z.null()]).optional(),
contactCompanyLabel: zod_1.z.union([zod_1.z.string(), zod_1.z.null()]).optional(),
activeOffersTitle: zod_1.z.union([zod_1.z.string(), zod_1.z.null()]).optional(),
seeAllOffersLabel: zod_1.z.union([zod_1.z.string(), zod_1.z.null()]).optional(),
noActiveOffersLabel: zod_1.z.union([zod_1.z.string(), zod_1.z.null()]).optional(),
publishedVehiclesTitle: zod_1.z.union([zod_1.z.string(), zod_1.z.null()]).optional(),
viewVehicleLabel: zod_1.z.union([zod_1.z.string(), zod_1.z.null()]).optional(),
pricingEyebrow: zod_1.z.union([zod_1.z.string(), zod_1.z.null()]).optional(),
pricingTitle: zod_1.z.union([zod_1.z.string(), zod_1.z.null()]).optional(),
pricingDescription: zod_1.z.union([zod_1.z.string(), zod_1.z.null()]).optional(),
showOffers: zod_1.z.boolean().optional(),
showVehicles: zod_1.z.boolean().optional(),
showPricing: zod_1.z.boolean().optional(),
layout: zod_1.z.object({
items: zod_1.z.array(zod_1.z.object({
id: zod_1.z.string().min(1),
type: zod_1.z.enum(['hero', 'offers', 'vehicles', 'pricing']),
x: zod_1.z.number().int().min(1),
y: zod_1.z.number().int().min(1),
w: zod_1.z.number().int().min(1),
h: zod_1.z.number().int().min(1),
})),
}).optional(),
}).optional(),
menuConfig: zod_1.z.object({
aboutLabel: zod_1.z.union([zod_1.z.string(), zod_1.z.null()]).optional(),
vehiclesLabel: zod_1.z.union([zod_1.z.string(), zod_1.z.null()]).optional(),
offersLabel: zod_1.z.union([zod_1.z.string(), zod_1.z.null()]).optional(),
pricingLabel: zod_1.z.union([zod_1.z.string(), zod_1.z.null()]).optional(),
blogLabel: zod_1.z.union([zod_1.z.string(), zod_1.z.null()]).optional(),
contactLabel: zod_1.z.union([zod_1.z.string(), zod_1.z.null()]).optional(),
bookCarLabel: zod_1.z.union([zod_1.z.string(), zod_1.z.null()]).optional(),
siteNavigationLabel: zod_1.z.union([zod_1.z.string(), zod_1.z.null()]).optional(),
showAbout: zod_1.z.boolean().optional(),
showVehicles: zod_1.z.boolean().optional(),
showOffers: zod_1.z.boolean().optional(),
showPricing: zod_1.z.boolean().optional(),
showBlog: zod_1.z.boolean().optional(),
showContact: zod_1.z.boolean().optional(),
pageSections: zod_1.z.object({
home: zod_1.z.object({
hero: zod_1.z.boolean().optional(), offers: zod_1.z.boolean().optional(),
vehicles: zod_1.z.boolean().optional(), pricing: zod_1.z.boolean().optional(),
}).optional(),
about: zod_1.z.object({
hero: zod_1.z.boolean().optional(), highlights: zod_1.z.boolean().optional(), details: zod_1.z.boolean().optional(),
}).optional(),
offers: zod_1.z.object({ header: zod_1.z.boolean().optional(), grid: zod_1.z.boolean().optional() }).optional(),
pricing: zod_1.z.object({
hero: zod_1.z.boolean().optional(), plans: zod_1.z.boolean().optional(),
payments: zod_1.z.boolean().optional(), faq: zod_1.z.boolean().optional(),
}).optional(),
vehicles: zod_1.z.object({
header: zod_1.z.boolean().optional(), filters: zod_1.z.boolean().optional(), grid: zod_1.z.boolean().optional(),
}).optional(),
vehicleDetail: zod_1.z.object({ gallery: zod_1.z.boolean().optional(), summary: zod_1.z.boolean().optional() }).optional(),
blog: zod_1.z.object({ hero: zod_1.z.boolean().optional(), posts: zod_1.z.boolean().optional() }).optional(),
contact: zod_1.z.object({ content: zod_1.z.boolean().optional() }).optional(),
booking: zod_1.z.object({ content: zod_1.z.boolean().optional() }).optional(),
bookingConfirmation: zod_1.z.object({
hero: zod_1.z.boolean().optional(), summary: zod_1.z.boolean().optional(), actions: zod_1.z.boolean().optional(),
}).optional(),
}).optional(),
}).optional(),
});
exports.contractSettingsSchema = zod_1.z.object({
legalName: zod_1.z.string().optional(),
registrationNumber: zod_1.z.string().optional(),
taxId: zod_1.z.string().optional(),
terms: zod_1.z.string().optional(),
fuelPolicy: zod_1.z.string().optional(),
depositPolicy: zod_1.z.string().optional(),
lateFeePolicy: zod_1.z.string().optional(),
damagePolicy: zod_1.z.string().optional(),
contractFooterNote: zod_1.z.string().optional(),
invoiceFooterNote: zod_1.z.string().optional(),
signatureRequired: zod_1.z.boolean().optional(),
showTax: zod_1.z.boolean().optional(),
taxRate: zod_1.z.number().optional(),
taxLabel: zod_1.z.string().optional(),
fuelPolicyType: zod_1.z.enum(['FULL_TO_FULL', 'FULL_TO_EMPTY', 'SAME_TO_SAME', 'PREPAID', 'FREE']).optional(),
fuelPolicyNote: zod_1.z.string().optional(),
fuelChargePerLiter: zod_1.z.number().int().optional(),
fuelShortfallFee: zod_1.z.number().int().optional(),
lateFeePerHour: zod_1.z.number().int().optional(),
additionalDriverCharge: zod_1.z.enum(['FREE', 'PER_DAY', 'FLAT']).optional(),
additionalDriverDailyRate: zod_1.z.number().int().optional(),
additionalDriverFlatRate: zod_1.z.number().int().optional(),
});
exports.insurancePolicySchema = zod_1.z.object({
name: zod_1.z.string().min(1),
description: zod_1.z.string().optional(),
type: zod_1.z.enum(['CDW', 'SCDW', 'THEFT', 'THIRD_PARTY', 'FULL', 'BASIC', 'ROADSIDE', 'PERSONAL', 'CUSTOM']),
chargeType: zod_1.z.enum(['PER_DAY', 'PER_RENTAL', 'PERCENTAGE_OF_RENTAL']),
chargeValue: zod_1.z.number().int().min(0),
isRequired: zod_1.z.boolean().default(false),
isActive: zod_1.z.boolean().default(true),
sortOrder: zod_1.z.number().int().default(0),
});
exports.pricingRuleSchema = zod_1.z.object({
name: zod_1.z.string().min(1),
type: zod_1.z.enum(['SURCHARGE', 'DISCOUNT']),
condition: zod_1.z.enum(['AGE_LESS_THAN', 'AGE_GREATER_THAN', 'LICENSE_YEARS_LESS_THAN', 'LICENSE_YEARS_GREATER_THAN']),
conditionValue: zod_1.z.number().int(),
adjustmentType: zod_1.z.enum(['PERCENTAGE', 'FLAT_PER_DAY', 'FLAT_TOTAL']),
adjustmentValue: zod_1.z.number().int(),
isActive: zod_1.z.boolean().default(true),
description: zod_1.z.string().optional(),
});
exports.accountingSettingsSchema = zod_1.z.object({
reportingPeriod: zod_1.z.enum(['WEEKLY', 'MONTHLY', 'QUARTERLY', 'ANNUAL']).optional(),
fiscalYearStart: zod_1.z.number().int().min(1).max(12).optional(),
currency: zod_1.z.literal('MAD').optional(),
accountantEmail: zod_1.z.string().email().optional(),
accountantName: zod_1.z.string().optional(),
autoSendReport: zod_1.z.boolean().optional(),
reportFormat: zod_1.z.enum(['PDF', 'CSV', 'BOTH']).optional(),
});
exports.subdomainSchema = zod_1.z.object({ subdomain: zod_1.z.string().min(3) });
exports.customDomainSchema = zod_1.z.object({ customDomain: zod_1.z.string().min(3) });
exports.idParamSchema = zod_1.z.object({ id: zod_1.z.string() });
//# sourceMappingURL=company.schemas.js.map
File diff suppressed because one or more lines are too long
+40
View File
@@ -0,0 +1,40 @@
export declare function getCompany(companyId: string): Promise<any>;
export declare function updateCompany(companyId: string, data: any): Promise<any>;
export declare function getBrand(companyId: string): Promise<any>;
export declare function updateBrand(companyId: string, body: any, companyName: string, companySlug: string): Promise<any>;
export declare function uploadLogo(companyId: string, companyName: string, companySlug: string, file: Buffer): Promise<any>;
export declare function uploadHeroImage(companyId: string, companyName: string, companySlug: string, file: Buffer): Promise<any>;
export declare function checkSubdomainAvailability(subdomain: string, companyId: string): Promise<{
available: boolean;
}>;
export declare function setCustomDomain(companyId: string, companyName: string, companySlug: string, customDomain: string): Promise<any>;
export declare function getCustomDomainStatus(companyId: string): Promise<{
customDomain: any;
verified: any;
status: string;
dnsTarget: string;
}>;
export declare function removeCustomDomain(companyId: string): Promise<{
success: boolean;
}>;
export declare function getContractSettings(companyId: string): Promise<any>;
export declare function updateContractSettings(companyId: string, data: any): Promise<any>;
export declare function getInsurancePolicies(companyId: string): Promise<any>;
export declare function createInsurancePolicy(companyId: string, data: any): Promise<any>;
export declare function updateInsurancePolicy(id: string, companyId: string, data: any): Promise<any>;
export declare function deleteInsurancePolicy(id: string, companyId: string): Promise<void>;
export declare function getPricingRules(companyId: string): Promise<any>;
export declare function createPricingRule(companyId: string, data: any): Promise<any>;
export declare function updatePricingRule(id: string, companyId: string, data: any): Promise<any>;
export declare function deletePricingRule(id: string, companyId: string): Promise<void>;
export declare function getAccountingSettings(companyId: string): Promise<any>;
export declare function updateAccountingSettings(companyId: string, data: any): Promise<any>;
export declare function getApiKey(companyId: string): Promise<{
apiKeys: any;
}>;
export declare function regenerateApiKey(companyId: string): Promise<{
apiKey: string;
prefix: string;
warning: string;
}>;
//# sourceMappingURL=company.service.d.ts.map
@@ -0,0 +1 @@
{"version":3,"file":"company.service.d.ts","sourceRoot":"","sources":["../../../src/modules/companies/company.service.ts"],"names":[],"mappings":"AAgBA,wBAAsB,UAAU,CAAC,SAAS,EAAE,MAAM,gBAEjD;AAED,wBAAsB,aAAa,CAAC,SAAS,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,gBAE/D;AAED,wBAAsB,QAAQ,CAAC,SAAS,EAAE,MAAM,gBAE/C;AAED,wBAAsB,WAAW,CAAC,SAAS,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,EAAE,WAAW,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,gBAYvG;AAED,wBAAsB,UAAU,CAAC,SAAS,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,gBAOzG;AAED,wBAAsB,eAAe,CAAC,SAAS,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,gBAO9G;AAED,wBAAsB,0BAA0B,CAAC,SAAS,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM;;GAGpF;AAED,wBAAsB,eAAe,CAAC,SAAS,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,gBAStH;AAED,wBAAsB,qBAAqB,CAAC,SAAS,EAAE,MAAM;;;;;GAS5D;AAED,wBAAsB,kBAAkB,CAAC,SAAS,EAAE,MAAM;;GAGzD;AAED,wBAAsB,mBAAmB,CAAC,SAAS,EAAE,MAAM,gBAE1D;AAED,wBAAsB,sBAAsB,CAAC,SAAS,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,gBAExE;AAED,wBAAsB,oBAAoB,CAAC,SAAS,EAAE,MAAM,gBAE3D;AAED,wBAAsB,qBAAqB,CAAC,SAAS,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,gBAEvE;AAED,wBAAsB,qBAAqB,CAAC,EAAE,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,gBAInF;AAED,wBAAsB,qBAAqB,CAAC,EAAE,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,iBAGxE;AAED,wBAAsB,eAAe,CAAC,SAAS,EAAE,MAAM,gBAEtD;AAED,wBAAsB,iBAAiB,CAAC,SAAS,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,gBAEnE;AAED,wBAAsB,iBAAiB,CAAC,EAAE,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,gBAI/E;AAED,wBAAsB,iBAAiB,CAAC,EAAE,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,iBAGpE;AAED,wBAAsB,qBAAqB,CAAC,SAAS,EAAE,MAAM,gBAE5D;AAED,wBAAsB,wBAAwB,CAAC,SAAS,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,gBAE1E;AAED,wBAAsB,SAAS,CAAC,SAAS,EAAE,MAAM;;GAEhD;AAED,wBAAsB,gBAAgB,CAAC,SAAS,EAAE,MAAM;;;;GAEvD"}
+175
View File
@@ -0,0 +1,175 @@
"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.getCompany = getCompany;
exports.updateCompany = updateCompany;
exports.getBrand = getBrand;
exports.updateBrand = updateBrand;
exports.uploadLogo = uploadLogo;
exports.uploadHeroImage = uploadHeroImage;
exports.checkSubdomainAvailability = checkSubdomainAvailability;
exports.setCustomDomain = setCustomDomain;
exports.getCustomDomainStatus = getCustomDomainStatus;
exports.removeCustomDomain = removeCustomDomain;
exports.getContractSettings = getContractSettings;
exports.updateContractSettings = updateContractSettings;
exports.getInsurancePolicies = getInsurancePolicies;
exports.createInsurancePolicy = createInsurancePolicy;
exports.updateInsurancePolicy = updateInsurancePolicy;
exports.deleteInsurancePolicy = deleteInsurancePolicy;
exports.getPricingRules = getPricingRules;
exports.createPricingRule = createPricingRule;
exports.updatePricingRule = updatePricingRule;
exports.deletePricingRule = deletePricingRule;
exports.getAccountingSettings = getAccountingSettings;
exports.updateAccountingSettings = updateAccountingSettings;
exports.getApiKey = getApiKey;
exports.regenerateApiKey = regenerateApiKey;
const storage_1 = require("../../lib/storage");
const errors_1 = require("../../http/errors");
const company_presenter_1 = require("./company.presenter");
const repo = __importStar(require("./company.repo"));
function buildPaymentMethodsEnabled(input) {
const methods = [];
if (input.amanpayMerchantId && input.amanpaySecretKey)
methods.push('AMANPAY');
if (input.paypalEmail)
methods.push('PAYPAL');
return methods;
}
async function getCompany(companyId) {
return (0, company_presenter_1.presentCompany)(await repo.findCompany(companyId));
}
async function updateCompany(companyId, data) {
return (0, company_presenter_1.presentCompany)(await repo.updateCompany(companyId, data));
}
async function getBrand(companyId) {
return (0, company_presenter_1.presentBrand)(await repo.findBrand(companyId));
}
async function updateBrand(companyId, body, companyName, companySlug) {
const current = await repo.findBrand(companyId);
const paymentMethodsEnabled = buildPaymentMethodsEnabled({
amanpayMerchantId: body.amanpayMerchantId ?? current?.amanpayMerchantId,
amanpaySecretKey: body.amanpaySecretKey ?? current?.amanpaySecretKey,
paypalEmail: body.paypalEmail ?? current?.paypalEmail,
});
return (0, company_presenter_1.presentBrand)(await repo.upsertBrand(companyId, { ...body, paymentMethodsEnabled }, { displayName: body.displayName ?? companyName, subdomain: companySlug, paymentMethodsEnabled, ...body }));
}
async function uploadLogo(companyId, companyName, companySlug, file) {
const url = await (0, storage_1.uploadImage)(file, `companies/${companyId}/brand`, 'logo');
return (0, company_presenter_1.presentBrand)(await repo.upsertBrand(companyId, { logoUrl: url }, { displayName: companyName, subdomain: companySlug, logoUrl: url }));
}
async function uploadHeroImage(companyId, companyName, companySlug, file) {
const url = await (0, storage_1.uploadImage)(file, `companies/${companyId}/brand`, 'hero');
return (0, company_presenter_1.presentBrand)(await repo.upsertBrand(companyId, { heroImageUrl: url }, { displayName: companyName, subdomain: companySlug, heroImageUrl: url }));
}
async function checkSubdomainAvailability(subdomain, companyId) {
const existing = await repo.findBrandBySubdomain(subdomain, companyId);
return { available: !existing };
}
async function setCustomDomain(companyId, companyName, companySlug, customDomain) {
const normalized = customDomain.toLowerCase().trim();
const existing = await repo.findBrandByCustomDomain(normalized, companyId);
if (existing)
throw new errors_1.ConflictError('This custom domain is already in use');
return repo.upsertBrand(companyId, { customDomain: normalized, customDomainVerified: false, customDomainAddedAt: new Date() }, { displayName: companyName, subdomain: companySlug, customDomain: normalized, customDomainVerified: false, customDomainAddedAt: new Date() });
}
async function getCustomDomainStatus(companyId) {
const brand = await repo.findBrand(companyId);
const customDomain = brand?.customDomain ?? null;
return {
customDomain,
verified: brand?.customDomainVerified ?? false,
status: customDomain ? (brand?.customDomainVerified ? 'verified' : 'pending_dns') : 'not_configured',
dnsTarget: process.env.NEXT_PUBLIC_CUSTOM_DOMAIN_TARGET ?? 'cname.vercel-dns.com',
};
}
async function removeCustomDomain(companyId) {
const result = await repo.clearCustomDomain(companyId);
return { success: result.count > 0 };
}
async function getContractSettings(companyId) {
return repo.findContractSettings(companyId);
}
async function updateContractSettings(companyId, data) {
return repo.upsertContractSettings(companyId, data);
}
async function getInsurancePolicies(companyId) {
return repo.findInsurancePolicies(companyId);
}
async function createInsurancePolicy(companyId, data) {
return repo.createInsurancePolicy(companyId, data);
}
async function updateInsurancePolicy(id, companyId, data) {
const result = await repo.updateInsurancePolicy(id, companyId, data);
if (result.count === 0)
throw new errors_1.NotFoundError('Insurance policy not found');
return repo.findInsurancePolicyOrThrow(id);
}
async function deleteInsurancePolicy(id, companyId) {
const result = await repo.deleteInsurancePolicy(id, companyId);
if (result.count === 0)
throw new errors_1.NotFoundError('Insurance policy not found');
}
async function getPricingRules(companyId) {
return repo.findPricingRules(companyId);
}
async function createPricingRule(companyId, data) {
return repo.createPricingRule(companyId, data);
}
async function updatePricingRule(id, companyId, data) {
const result = await repo.updatePricingRule(id, companyId, data);
if (result.count === 0)
throw new errors_1.NotFoundError('Pricing rule not found');
return repo.findPricingRuleOrThrow(id);
}
async function deletePricingRule(id, companyId) {
const result = await repo.deletePricingRule(id, companyId);
if (result.count === 0)
throw new errors_1.NotFoundError('Pricing rule not found');
}
async function getAccountingSettings(companyId) {
return repo.findAccountingSettings(companyId);
}
async function updateAccountingSettings(companyId, data) {
return repo.upsertAccountingSettings(companyId, data);
}
async function getApiKey(companyId) {
return repo.findApiKey(companyId);
}
async function regenerateApiKey(companyId) {
return repo.regenerateApiKey(companyId);
}
//# sourceMappingURL=company.service.js.map
File diff suppressed because one or more lines are too long