@open-mercato/core 0.6.1-develop.3276.1.1fcd145078 → 0.6.1-develop.3278.1.a4d26475e4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.turbo/turbo-build.log +2 -2
- package/dist/generated/entities/domain_mapping/index.js +31 -0
- package/dist/generated/entities/domain_mapping/index.js.map +7 -0
- package/dist/generated/entities.ids.generated.js +2 -1
- package/dist/generated/entities.ids.generated.js.map +2 -2
- package/dist/generated/entity-fields-registry.js +16 -0
- package/dist/generated/entity-fields-registry.js.map +2 -2
- package/dist/helpers/integration/salesUi.js +18 -17
- package/dist/helpers/integration/salesUi.js.map +2 -2
- package/dist/modules/customer_accounts/acl.js +2 -1
- package/dist/modules/customer_accounts/acl.js.map +2 -2
- package/dist/modules/customer_accounts/api/admin/domain-mappings/[id]/health-check.js +110 -0
- package/dist/modules/customer_accounts/api/admin/domain-mappings/[id]/health-check.js.map +7 -0
- package/dist/modules/customer_accounts/api/admin/domain-mappings/[id]/verify.js +114 -0
- package/dist/modules/customer_accounts/api/admin/domain-mappings/[id]/verify.js.map +7 -0
- package/dist/modules/customer_accounts/api/admin/domain-mappings.js +271 -0
- package/dist/modules/customer_accounts/api/admin/domain-mappings.js.map +7 -0
- package/dist/modules/customer_accounts/api/domain-check.js +70 -0
- package/dist/modules/customer_accounts/api/domain-check.js.map +7 -0
- package/dist/modules/customer_accounts/api/domain-resolve/all.js +128 -0
- package/dist/modules/customer_accounts/api/domain-resolve/all.js.map +7 -0
- package/dist/modules/customer_accounts/api/domain-resolve.js +84 -0
- package/dist/modules/customer_accounts/api/domain-resolve.js.map +7 -0
- package/dist/modules/customer_accounts/api/login.js +14 -3
- package/dist/modules/customer_accounts/api/login.js.map +2 -2
- package/dist/modules/customer_accounts/api/magic-link/request.js +14 -3
- package/dist/modules/customer_accounts/api/magic-link/request.js.map +2 -2
- package/dist/modules/customer_accounts/api/password/reset-request.js +14 -3
- package/dist/modules/customer_accounts/api/password/reset-request.js.map +2 -2
- package/dist/modules/customer_accounts/api/signup.js +32 -5
- package/dist/modules/customer_accounts/api/signup.js.map +2 -2
- package/dist/modules/customer_accounts/backend/customer_accounts/settings/domain/components/Actions.js +48 -0
- package/dist/modules/customer_accounts/backend/customer_accounts/settings/domain/components/Actions.js.map +7 -0
- package/dist/modules/customer_accounts/backend/customer_accounts/settings/domain/components/Diagnostics.js +43 -0
- package/dist/modules/customer_accounts/backend/customer_accounts/settings/domain/components/Diagnostics.js.map +7 -0
- package/dist/modules/customer_accounts/backend/customer_accounts/settings/domain/components/DnsConfig.js +53 -0
- package/dist/modules/customer_accounts/backend/customer_accounts/settings/domain/components/DnsConfig.js.map +7 -0
- package/dist/modules/customer_accounts/backend/customer_accounts/settings/domain/components/DomainPanel.js +69 -0
- package/dist/modules/customer_accounts/backend/customer_accounts/settings/domain/components/DomainPanel.js.map +7 -0
- package/dist/modules/customer_accounts/backend/customer_accounts/settings/domain/components/OrgSwitcher.js +31 -0
- package/dist/modules/customer_accounts/backend/customer_accounts/settings/domain/components/OrgSwitcher.js.map +7 -0
- package/dist/modules/customer_accounts/backend/customer_accounts/settings/domain/components/RegisterDialog.js +147 -0
- package/dist/modules/customer_accounts/backend/customer_accounts/settings/domain/components/RegisterDialog.js.map +7 -0
- package/dist/modules/customer_accounts/backend/customer_accounts/settings/domain/components/StatusBadgeSection.js +39 -0
- package/dist/modules/customer_accounts/backend/customer_accounts/settings/domain/components/StatusBadgeSection.js.map +7 -0
- package/dist/modules/customer_accounts/backend/customer_accounts/settings/domain/components/Stepper.js +60 -0
- package/dist/modules/customer_accounts/backend/customer_accounts/settings/domain/components/Stepper.js.map +7 -0
- package/dist/modules/customer_accounts/backend/customer_accounts/settings/domain/components/domainStatusMap.js +11 -0
- package/dist/modules/customer_accounts/backend/customer_accounts/settings/domain/components/domainStatusMap.js.map +7 -0
- package/dist/modules/customer_accounts/backend/customer_accounts/settings/domain/components/types.js +1 -0
- package/dist/modules/customer_accounts/backend/customer_accounts/settings/domain/components/types.js.map +7 -0
- package/dist/modules/customer_accounts/backend/customer_accounts/settings/domain/page.js +361 -0
- package/dist/modules/customer_accounts/backend/customer_accounts/settings/domain/page.js.map +7 -0
- package/dist/modules/customer_accounts/backend/customer_accounts/settings/domain/page.meta.js +28 -0
- package/dist/modules/customer_accounts/backend/customer_accounts/settings/domain/page.meta.js.map +7 -0
- package/dist/modules/customer_accounts/data/enrichers.js +78 -12
- package/dist/modules/customer_accounts/data/enrichers.js.map +2 -2
- package/dist/modules/customer_accounts/data/entities.js +85 -2
- package/dist/modules/customer_accounts/data/entities.js.map +2 -2
- package/dist/modules/customer_accounts/data/guards.js +130 -0
- package/dist/modules/customer_accounts/data/guards.js.map +7 -0
- package/dist/modules/customer_accounts/data/validators.js +19 -0
- package/dist/modules/customer_accounts/data/validators.js.map +2 -2
- package/dist/modules/customer_accounts/di.js +23 -1
- package/dist/modules/customer_accounts/di.js.map +2 -2
- package/dist/modules/customer_accounts/events.js +9 -2
- package/dist/modules/customer_accounts/events.js.map +2 -2
- package/dist/modules/customer_accounts/lib/customerAuthServer.js +27 -7
- package/dist/modules/customer_accounts/lib/customerAuthServer.js.map +2 -2
- package/dist/modules/customer_accounts/lib/customerUrl.js +48 -0
- package/dist/modules/customer_accounts/lib/customerUrl.js.map +7 -0
- package/dist/modules/customer_accounts/lib/hostname.js +55 -0
- package/dist/modules/customer_accounts/lib/hostname.js.map +7 -0
- package/dist/modules/customer_accounts/lib/platformDomains.js +7 -0
- package/dist/modules/customer_accounts/lib/platformDomains.js.map +7 -0
- package/dist/modules/customer_accounts/lib/proxyRanges.js +71 -0
- package/dist/modules/customer_accounts/lib/proxyRanges.js.map +7 -0
- package/dist/modules/customer_accounts/lib/rateLimiter.js +7 -0
- package/dist/modules/customer_accounts/lib/rateLimiter.js.map +2 -2
- package/dist/modules/customer_accounts/lib/resolveTenantContext.js +63 -0
- package/dist/modules/customer_accounts/lib/resolveTenantContext.js.map +7 -0
- package/dist/modules/customer_accounts/lib/secretCompare.js +13 -0
- package/dist/modules/customer_accounts/lib/secretCompare.js.map +7 -0
- package/dist/modules/customer_accounts/migrations/Migration20260430120000_customer_accounts.js +37 -0
- package/dist/modules/customer_accounts/migrations/Migration20260430120000_customer_accounts.js.map +7 -0
- package/dist/modules/customer_accounts/notifications.client.js +76 -0
- package/dist/modules/customer_accounts/notifications.client.js.map +2 -2
- package/dist/modules/customer_accounts/notifications.js +76 -0
- package/dist/modules/customer_accounts/notifications.js.map +2 -2
- package/dist/modules/customer_accounts/services/domainMappingService.js +497 -0
- package/dist/modules/customer_accounts/services/domainMappingService.js.map +7 -0
- package/dist/modules/customer_accounts/setup.js +48 -1
- package/dist/modules/customer_accounts/setup.js.map +2 -2
- package/dist/modules/customer_accounts/subscribers/invalidateDomainCache.js +29 -0
- package/dist/modules/customer_accounts/subscribers/invalidateDomainCache.js.map +7 -0
- package/dist/modules/customer_accounts/subscribers/notifyDomainActivated.js +29 -0
- package/dist/modules/customer_accounts/subscribers/notifyDomainActivated.js.map +7 -0
- package/dist/modules/customer_accounts/subscribers/notifyDomainDnsFailed.js +30 -0
- package/dist/modules/customer_accounts/subscribers/notifyDomainDnsFailed.js.map +7 -0
- package/dist/modules/customer_accounts/subscribers/notifyDomainTlsFailed.js +31 -0
- package/dist/modules/customer_accounts/subscribers/notifyDomainTlsFailed.js.map +7 -0
- package/dist/modules/customer_accounts/subscribers/notifyDomainVerified.js +29 -0
- package/dist/modules/customer_accounts/subscribers/notifyDomainVerified.js.map +7 -0
- package/dist/modules/customer_accounts/workers/domainTlsRetryWorker.js +67 -0
- package/dist/modules/customer_accounts/workers/domainTlsRetryWorker.js.map +7 -0
- package/dist/modules/customer_accounts/workers/domainVerificationWorker.js +34 -0
- package/dist/modules/customer_accounts/workers/domainVerificationWorker.js.map +7 -0
- package/dist/modules/customers/api/companies/route.js +4 -9
- package/dist/modules/customers/api/companies/route.js.map +2 -2
- package/dist/modules/customers/api/deals/route.js +4 -9
- package/dist/modules/customers/api/deals/route.js.map +2 -2
- package/dist/modules/customers/api/people/route.js +4 -9
- package/dist/modules/customers/api/people/route.js.map +2 -2
- package/dist/modules/customers/api/utils.js +0 -12
- package/dist/modules/customers/api/utils.js.map +2 -2
- package/dist/modules/customers/backend/customers/companies/page.js +361 -284
- package/dist/modules/customers/backend/customers/companies/page.js.map +2 -2
- package/dist/modules/customers/backend/customers/deals/page.js +378 -473
- package/dist/modules/customers/backend/customers/deals/page.js.map +2 -2
- package/dist/modules/customers/backend/customers/people/page.js +368 -286
- package/dist/modules/customers/backend/customers/people/page.js.map +2 -2
- package/dist/modules/customers/components/detail/assignableStaff.js +15 -1
- package/dist/modules/customers/components/detail/assignableStaff.js.map +2 -2
- package/dist/modules/customers/widgets/injection/ai-assistant-trigger/widget.client.js +188 -36
- package/dist/modules/customers/widgets/injection/ai-assistant-trigger/widget.client.js.map +2 -2
- package/dist/modules/customers/widgets/injection/ai-assistant-trigger/widget.js +2 -2
- package/dist/modules/customers/widgets/injection/ai-assistant-trigger/widget.js.map +2 -2
- package/dist/modules/customers/widgets/injection-table.js +6 -0
- package/dist/modules/customers/widgets/injection-table.js.map +2 -2
- package/dist/modules/perspectives/services/perspectiveService.js +16 -2
- package/dist/modules/perspectives/services/perspectiveService.js.map +2 -2
- package/dist/modules/portal/frontend/[orgSlug]/portal/login/page.js +1 -0
- package/dist/modules/portal/frontend/[orgSlug]/portal/login/page.js.map +2 -2
- package/dist/modules/query_index/lib/engine.js +31 -8
- package/dist/modules/query_index/lib/engine.js.map +2 -2
- package/generated/entities/domain_mapping/index.ts +14 -0
- package/generated/entities.ids.generated.ts +2 -1
- package/generated/entity-fields-registry.ts +16 -0
- package/package.json +5 -5
- package/src/helpers/integration/salesUi.ts +27 -23
- package/src/modules/customer_accounts/acl.ts +1 -0
- package/src/modules/customer_accounts/api/admin/domain-mappings/[id]/health-check.ts +119 -0
- package/src/modules/customer_accounts/api/admin/domain-mappings/[id]/verify.ts +123 -0
- package/src/modules/customer_accounts/api/admin/domain-mappings.ts +303 -0
- package/src/modules/customer_accounts/api/domain-check.ts +83 -0
- package/src/modules/customer_accounts/api/domain-resolve/all.ts +139 -0
- package/src/modules/customer_accounts/api/domain-resolve.ts +91 -0
- package/src/modules/customer_accounts/api/login.ts +14 -3
- package/src/modules/customer_accounts/api/magic-link/request.ts +14 -3
- package/src/modules/customer_accounts/api/password/reset-request.ts +15 -3
- package/src/modules/customer_accounts/api/signup.ts +36 -5
- package/src/modules/customer_accounts/backend/customer_accounts/settings/domain/components/Actions.tsx +70 -0
- package/src/modules/customer_accounts/backend/customer_accounts/settings/domain/components/Diagnostics.tsx +66 -0
- package/src/modules/customer_accounts/backend/customer_accounts/settings/domain/components/DnsConfig.tsx +78 -0
- package/src/modules/customer_accounts/backend/customer_accounts/settings/domain/components/DomainPanel.tsx +90 -0
- package/src/modules/customer_accounts/backend/customer_accounts/settings/domain/components/OrgSwitcher.tsx +43 -0
- package/src/modules/customer_accounts/backend/customer_accounts/settings/domain/components/RegisterDialog.tsx +178 -0
- package/src/modules/customer_accounts/backend/customer_accounts/settings/domain/components/StatusBadgeSection.tsx +56 -0
- package/src/modules/customer_accounts/backend/customer_accounts/settings/domain/components/Stepper.tsx +69 -0
- package/src/modules/customer_accounts/backend/customer_accounts/settings/domain/components/domainStatusMap.ts +10 -0
- package/src/modules/customer_accounts/backend/customer_accounts/settings/domain/components/types.ts +31 -0
- package/src/modules/customer_accounts/backend/customer_accounts/settings/domain/page.meta.ts +26 -0
- package/src/modules/customer_accounts/backend/customer_accounts/settings/domain/page.tsx +411 -0
- package/src/modules/customer_accounts/data/enrichers.ts +95 -12
- package/src/modules/customer_accounts/data/entities.ts +80 -1
- package/src/modules/customer_accounts/data/guards.ts +155 -0
- package/src/modules/customer_accounts/data/validators.ts +26 -0
- package/src/modules/customer_accounts/di.ts +35 -1
- package/src/modules/customer_accounts/events.ts +8 -1
- package/src/modules/customer_accounts/i18n/de.json +78 -0
- package/src/modules/customer_accounts/i18n/en.json +78 -0
- package/src/modules/customer_accounts/i18n/es.json +78 -0
- package/src/modules/customer_accounts/i18n/pl.json +78 -0
- package/src/modules/customer_accounts/lib/customerAuthServer.ts +44 -8
- package/src/modules/customer_accounts/lib/customerUrl.ts +72 -0
- package/src/modules/customer_accounts/lib/hostname.ts +76 -0
- package/src/modules/customer_accounts/lib/platformDomains.ts +14 -0
- package/src/modules/customer_accounts/lib/proxyRanges.ts +85 -0
- package/src/modules/customer_accounts/lib/rateLimiter.ts +10 -0
- package/src/modules/customer_accounts/lib/resolveTenantContext.ts +96 -0
- package/src/modules/customer_accounts/lib/secretCompare.ts +20 -0
- package/src/modules/customer_accounts/migrations/.snapshot-open-mercato.json +341 -0
- package/src/modules/customer_accounts/migrations/Migration20260430120000_customer_accounts.ts +38 -0
- package/src/modules/customer_accounts/notifications.client.ts +76 -0
- package/src/modules/customer_accounts/notifications.ts +76 -0
- package/src/modules/customer_accounts/services/domainMappingService.ts +632 -0
- package/src/modules/customer_accounts/setup.ts +81 -1
- package/src/modules/customer_accounts/subscribers/invalidateDomainCache.ts +35 -0
- package/src/modules/customer_accounts/subscribers/notifyDomainActivated.ts +32 -0
- package/src/modules/customer_accounts/subscribers/notifyDomainDnsFailed.ts +33 -0
- package/src/modules/customer_accounts/subscribers/notifyDomainTlsFailed.ts +34 -0
- package/src/modules/customer_accounts/subscribers/notifyDomainVerified.ts +32 -0
- package/src/modules/customer_accounts/workers/domainTlsRetryWorker.ts +84 -0
- package/src/modules/customer_accounts/workers/domainVerificationWorker.ts +45 -0
- package/src/modules/customers/api/companies/route.ts +4 -9
- package/src/modules/customers/api/deals/route.ts +4 -9
- package/src/modules/customers/api/people/route.ts +4 -9
- package/src/modules/customers/api/utils.ts +0 -14
- package/src/modules/customers/backend/customers/companies/page.tsx +321 -237
- package/src/modules/customers/backend/customers/deals/page.tsx +321 -455
- package/src/modules/customers/backend/customers/people/page.tsx +331 -240
- package/src/modules/customers/components/detail/assignableStaff.ts +21 -0
- package/src/modules/customers/i18n/de.json +31 -0
- package/src/modules/customers/i18n/en.json +31 -0
- package/src/modules/customers/i18n/es.json +31 -0
- package/src/modules/customers/i18n/pl.json +31 -0
- package/src/modules/customers/widgets/injection/ai-assistant-trigger/widget.client.tsx +197 -40
- package/src/modules/customers/widgets/injection/ai-assistant-trigger/widget.ts +13 -7
- package/src/modules/customers/widgets/injection-table.ts +6 -0
- package/src/modules/perspectives/services/perspectiveService.ts +30 -2
- package/src/modules/portal/frontend/[orgSlug]/portal/login/page.tsx +1 -0
- package/src/modules/query_index/lib/engine.ts +46 -8
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { findWithDecryption } from "@open-mercato/shared/lib/encryption/find";
|
|
2
|
+
import { CustomerUser, DomainMapping } from "./entities.js";
|
|
2
3
|
const PERSON_FALLBACK = { _customer_accounts: { hasAccount: false } };
|
|
3
4
|
const COMPANY_FALLBACK = { _customer_accounts: { userCount: 0 } };
|
|
4
5
|
const personAccountStatusEnricher = {
|
|
@@ -16,11 +17,17 @@ const personAccountStatusEnricher = {
|
|
|
16
17
|
if (records.length === 0) return records;
|
|
17
18
|
const em = context.em.fork();
|
|
18
19
|
const recordIds = records.map((r) => r.id);
|
|
19
|
-
const users = await
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
20
|
+
const users = await findWithDecryption(
|
|
21
|
+
em,
|
|
22
|
+
CustomerUser,
|
|
23
|
+
{
|
|
24
|
+
personEntityId: { $in: recordIds },
|
|
25
|
+
tenantId: context.tenantId,
|
|
26
|
+
deletedAt: null
|
|
27
|
+
},
|
|
28
|
+
void 0,
|
|
29
|
+
{ tenantId: context.tenantId, organizationId: context.organizationId }
|
|
30
|
+
);
|
|
24
31
|
const userByPersonId = /* @__PURE__ */ new Map();
|
|
25
32
|
for (const user of users) {
|
|
26
33
|
if (user.personEntityId) {
|
|
@@ -59,11 +66,17 @@ const companyUserCountEnricher = {
|
|
|
59
66
|
if (records.length === 0) return records;
|
|
60
67
|
const em = context.em.fork();
|
|
61
68
|
const recordIds = records.map((r) => r.id);
|
|
62
|
-
const users = await
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
69
|
+
const users = await findWithDecryption(
|
|
70
|
+
em,
|
|
71
|
+
CustomerUser,
|
|
72
|
+
{
|
|
73
|
+
customerEntityId: { $in: recordIds },
|
|
74
|
+
tenantId: context.tenantId,
|
|
75
|
+
deletedAt: null
|
|
76
|
+
},
|
|
77
|
+
void 0,
|
|
78
|
+
{ tenantId: context.tenantId, organizationId: context.organizationId }
|
|
79
|
+
);
|
|
67
80
|
const countByCompanyId = /* @__PURE__ */ new Map();
|
|
68
81
|
for (const user of users) {
|
|
69
82
|
if (user.customerEntityId) {
|
|
@@ -78,7 +91,60 @@ const companyUserCountEnricher = {
|
|
|
78
91
|
}));
|
|
79
92
|
}
|
|
80
93
|
};
|
|
81
|
-
const
|
|
94
|
+
const ORG_DOMAIN_FALLBACK = { _customDomain: null };
|
|
95
|
+
const ACTIVE_DOMAIN_PRIORITY = {
|
|
96
|
+
active: 0,
|
|
97
|
+
verified: 1,
|
|
98
|
+
pending: 2,
|
|
99
|
+
tls_failed: 3,
|
|
100
|
+
dns_failed: 4
|
|
101
|
+
};
|
|
102
|
+
function pickPrimaryDomain(records) {
|
|
103
|
+
if (records.length === 0) return null;
|
|
104
|
+
return records.slice().sort(
|
|
105
|
+
(a, b) => (ACTIVE_DOMAIN_PRIORITY[a.status] ?? 99) - (ACTIVE_DOMAIN_PRIORITY[b.status] ?? 99) || (b.createdAt?.getTime?.() ?? 0) - (a.createdAt?.getTime?.() ?? 0)
|
|
106
|
+
)[0];
|
|
107
|
+
}
|
|
108
|
+
const organizationCustomDomainEnricher = {
|
|
109
|
+
id: "customer_accounts.domain-status:directory:organization",
|
|
110
|
+
targetEntity: "directory:organization",
|
|
111
|
+
features: ["customer_accounts.domain.manage"],
|
|
112
|
+
priority: 10,
|
|
113
|
+
timeout: 1e3,
|
|
114
|
+
critical: false,
|
|
115
|
+
fallback: ORG_DOMAIN_FALLBACK,
|
|
116
|
+
async enrichOne(record, context) {
|
|
117
|
+
return (await this.enrichMany([record], context))[0];
|
|
118
|
+
},
|
|
119
|
+
async enrichMany(records, context) {
|
|
120
|
+
if (records.length === 0) return records;
|
|
121
|
+
const em = context.em.fork();
|
|
122
|
+
const recordIds = records.map((r) => r.id);
|
|
123
|
+
const domains = await em.find(DomainMapping, {
|
|
124
|
+
organizationId: { $in: recordIds },
|
|
125
|
+
tenantId: context.tenantId
|
|
126
|
+
});
|
|
127
|
+
const byOrg = /* @__PURE__ */ new Map();
|
|
128
|
+
for (const d of domains) {
|
|
129
|
+
const list = byOrg.get(d.organizationId) ?? [];
|
|
130
|
+
list.push(d);
|
|
131
|
+
byOrg.set(d.organizationId, list);
|
|
132
|
+
}
|
|
133
|
+
return records.map((record) => {
|
|
134
|
+
const matches = byOrg.get(record.id) ?? [];
|
|
135
|
+
const primary = pickPrimaryDomain(matches);
|
|
136
|
+
return {
|
|
137
|
+
...record,
|
|
138
|
+
_customDomain: primary ? { hostname: primary.hostname, status: primary.status } : null
|
|
139
|
+
};
|
|
140
|
+
});
|
|
141
|
+
}
|
|
142
|
+
};
|
|
143
|
+
const enrichers = [
|
|
144
|
+
personAccountStatusEnricher,
|
|
145
|
+
companyUserCountEnricher,
|
|
146
|
+
organizationCustomDomainEnricher
|
|
147
|
+
];
|
|
82
148
|
export {
|
|
83
149
|
enrichers
|
|
84
150
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/modules/customer_accounts/data/enrichers.ts"],
|
|
4
|
-
"sourcesContent": ["import type { ResponseEnricher, EnricherContext } from '@open-mercato/shared/lib/crud/response-enricher'\nimport type { EntityManager } from '@mikro-orm/postgresql'\nimport { CustomerUser } from './entities'\n\ntype EntityRecord = Record<string, unknown> & { id: string }\ntype EnricherScope = EnricherContext & { em: EntityManager }\n\ntype PersonAccountEnrichment = {\n _customer_accounts: {\n hasAccount: boolean\n userId?: string\n isActive?: boolean\n lastLoginAt?: string | null\n }\n}\n\ntype CompanyUserCountEnrichment = {\n _customer_accounts: {\n userCount: number\n }\n}\n\nconst PERSON_FALLBACK = { _customer_accounts: { hasAccount: false } }\nconst COMPANY_FALLBACK = { _customer_accounts: { userCount: 0 } }\n\nconst personAccountStatusEnricher: ResponseEnricher<EntityRecord, PersonAccountEnrichment> = {\n id: 'customer_accounts.person-account-status',\n targetEntity: 'customers.person',\n features: ['customer_accounts.view'],\n priority: 10,\n timeout: 2000,\n critical: false,\n fallback: PERSON_FALLBACK,\n\n async enrichOne(record, context: EnricherScope) {\n return (await this.enrichMany!([record], context))[0]\n },\n\n async enrichMany(records, context: EnricherScope) {\n if (records.length === 0) return records as (EntityRecord & PersonAccountEnrichment)[]\n\n const em = context.em.fork()\n const recordIds = records.map((r) => r.id)\n\n const users = await em
|
|
5
|
-
"mappings": "AAEA,SAAS,
|
|
4
|
+
"sourcesContent": ["import type { ResponseEnricher, EnricherContext } from '@open-mercato/shared/lib/crud/response-enricher'\nimport type { EntityManager } from '@mikro-orm/postgresql'\nimport { findWithDecryption } from '@open-mercato/shared/lib/encryption/find'\nimport { CustomerUser, DomainMapping, type DomainStatus } from './entities'\n\ntype EntityRecord = Record<string, unknown> & { id: string }\ntype EnricherScope = EnricherContext & { em: EntityManager }\n\ntype PersonAccountEnrichment = {\n _customer_accounts: {\n hasAccount: boolean\n userId?: string\n isActive?: boolean\n lastLoginAt?: string | null\n }\n}\n\ntype CompanyUserCountEnrichment = {\n _customer_accounts: {\n userCount: number\n }\n}\n\nconst PERSON_FALLBACK = { _customer_accounts: { hasAccount: false } }\nconst COMPANY_FALLBACK = { _customer_accounts: { userCount: 0 } }\n\nconst personAccountStatusEnricher: ResponseEnricher<EntityRecord, PersonAccountEnrichment> = {\n id: 'customer_accounts.person-account-status',\n targetEntity: 'customers.person',\n features: ['customer_accounts.view'],\n priority: 10,\n timeout: 2000,\n critical: false,\n fallback: PERSON_FALLBACK,\n\n async enrichOne(record, context: EnricherScope) {\n return (await this.enrichMany!([record], context))[0]\n },\n\n async enrichMany(records, context: EnricherScope) {\n if (records.length === 0) return records as (EntityRecord & PersonAccountEnrichment)[]\n\n const em = context.em.fork()\n const recordIds = records.map((r) => r.id)\n\n const users = await findWithDecryption(\n em,\n CustomerUser,\n {\n personEntityId: { $in: recordIds },\n tenantId: context.tenantId,\n deletedAt: null,\n },\n undefined,\n { tenantId: context.tenantId, organizationId: context.organizationId },\n )\n\n const userByPersonId = new Map<string, CustomerUser>()\n for (const user of users) {\n if (user.personEntityId) {\n userByPersonId.set(user.personEntityId, user)\n }\n }\n\n return records.map((record) => {\n const user = userByPersonId.get(record.id)\n if (!user) {\n return { ...record, _customer_accounts: { hasAccount: false } }\n }\n return {\n ...record,\n _customer_accounts: {\n hasAccount: true,\n userId: user.id,\n isActive: user.isActive,\n lastLoginAt: user.lastLoginAt?.toISOString() ?? null,\n },\n }\n })\n },\n}\n\nconst companyUserCountEnricher: ResponseEnricher<EntityRecord, CompanyUserCountEnrichment> = {\n id: 'customer_accounts.company-user-count',\n targetEntity: 'customers.company',\n features: ['customer_accounts.view'],\n priority: 10,\n timeout: 2000,\n critical: false,\n fallback: COMPANY_FALLBACK,\n\n async enrichOne(record, context: EnricherScope) {\n return (await this.enrichMany!([record], context))[0]\n },\n\n async enrichMany(records, context: EnricherScope) {\n if (records.length === 0) return records as (EntityRecord & CompanyUserCountEnrichment)[]\n\n const em = context.em.fork()\n const recordIds = records.map((r) => r.id)\n\n const users = await findWithDecryption(\n em,\n CustomerUser,\n {\n customerEntityId: { $in: recordIds },\n tenantId: context.tenantId,\n deletedAt: null,\n },\n undefined,\n { tenantId: context.tenantId, organizationId: context.organizationId },\n )\n\n const countByCompanyId = new Map<string, number>()\n for (const user of users) {\n if (user.customerEntityId) {\n countByCompanyId.set(user.customerEntityId, (countByCompanyId.get(user.customerEntityId) ?? 0) + 1)\n }\n }\n\n return records.map((record) => ({\n ...record,\n _customer_accounts: {\n userCount: countByCompanyId.get(record.id) ?? 0,\n },\n }))\n },\n}\n\ntype OrgCustomDomainEnrichment = {\n _customDomain: { hostname: string; status: DomainStatus } | null\n}\n\nconst ORG_DOMAIN_FALLBACK: OrgCustomDomainEnrichment = { _customDomain: null }\n\nconst ACTIVE_DOMAIN_PRIORITY: Record<DomainStatus, number> = {\n active: 0,\n verified: 1,\n pending: 2,\n tls_failed: 3,\n dns_failed: 4,\n}\n\nfunction pickPrimaryDomain(records: DomainMapping[]): DomainMapping | null {\n if (records.length === 0) return null\n return records\n .slice()\n .sort(\n (a, b) =>\n (ACTIVE_DOMAIN_PRIORITY[a.status] ?? 99) - (ACTIVE_DOMAIN_PRIORITY[b.status] ?? 99) ||\n (b.createdAt?.getTime?.() ?? 0) - (a.createdAt?.getTime?.() ?? 0),\n )[0]\n}\n\nconst organizationCustomDomainEnricher: ResponseEnricher<EntityRecord, OrgCustomDomainEnrichment> = {\n id: 'customer_accounts.domain-status:directory:organization',\n targetEntity: 'directory:organization',\n features: ['customer_accounts.domain.manage'],\n priority: 10,\n timeout: 1_000,\n critical: false,\n fallback: ORG_DOMAIN_FALLBACK,\n\n async enrichOne(record, context: EnricherScope) {\n return (await this.enrichMany!([record], context))[0]\n },\n\n async enrichMany(records, context: EnricherScope) {\n if (records.length === 0) return records as (EntityRecord & OrgCustomDomainEnrichment)[]\n\n const em = context.em.fork()\n const recordIds = records.map((r) => r.id)\n const domains = await em.find(DomainMapping, {\n organizationId: { $in: recordIds },\n tenantId: context.tenantId,\n } as never)\n\n const byOrg = new Map<string, DomainMapping[]>()\n for (const d of domains) {\n const list = byOrg.get(d.organizationId) ?? []\n list.push(d)\n byOrg.set(d.organizationId, list)\n }\n\n return records.map((record) => {\n const matches = byOrg.get(record.id) ?? []\n const primary = pickPrimaryDomain(matches)\n return {\n ...record,\n _customDomain: primary ? { hostname: primary.hostname, status: primary.status } : null,\n }\n })\n },\n}\n\nexport const en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AI;AAAA,IAClC;AAEA,WAAO,QAAQ,IAAI,CAAC,WAAW;AAC7B,YAAM,UAAU,MAAM,IAAI,OAAO,EAAE,KAAK,CAAC;AACzC,YAAM,UAAU,kBAAkB,OAAO;AACzC,aAAO;AAAA,QACL,GAAG;AAAA,QACH,eAAe,UAAU,EAAE,UAAU,QAAQ,UAAU,QAAQ,QAAQ,OAAO,IAAI;AAAA,MACpF;AAAA,IACF,CAAC;AAAA,EACH;AACF;AAEO,MAAM,YAAgC;AAAA,EAC3C;AAAA,EACA;AAAA,EACA;AACF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -8,7 +8,15 @@ var __decorateClass = (decorators, target, key, kind) => {
|
|
|
8
8
|
if (kind && result) __defProp(target, key, result);
|
|
9
9
|
return result;
|
|
10
10
|
};
|
|
11
|
-
import { Entity, Index, ManyToOne, PrimaryKey, Property, Unique } from "@mikro-orm/decorators/legacy";
|
|
11
|
+
import { Check, Entity, Enum, Index, ManyToOne, PrimaryKey, Property, Unique } from "@mikro-orm/decorators/legacy";
|
|
12
|
+
const DOMAIN_PROVIDERS = ["traefik"];
|
|
13
|
+
const DOMAIN_STATUSES = [
|
|
14
|
+
"pending",
|
|
15
|
+
"verified",
|
|
16
|
+
"active",
|
|
17
|
+
"dns_failed",
|
|
18
|
+
"tls_failed"
|
|
19
|
+
];
|
|
12
20
|
let CustomerUser = class {
|
|
13
21
|
constructor() {
|
|
14
22
|
this.failedLoginAttempts = 0;
|
|
@@ -366,6 +374,78 @@ CustomerUserInvitation = __decorateClass([
|
|
|
366
374
|
Index({ properties: ["token"], name: "customer_user_invitations_token_idx" }),
|
|
367
375
|
Index({ properties: ["tenantId", "emailHash"], name: "customer_user_invitations_tenant_email_hash_idx" })
|
|
368
376
|
], CustomerUserInvitation);
|
|
377
|
+
let DomainMapping = class {
|
|
378
|
+
constructor() {
|
|
379
|
+
this.provider = "traefik";
|
|
380
|
+
this.status = "pending";
|
|
381
|
+
this.tlsRetryCount = 0;
|
|
382
|
+
this.createdAt = /* @__PURE__ */ new Date();
|
|
383
|
+
}
|
|
384
|
+
};
|
|
385
|
+
__decorateClass([
|
|
386
|
+
PrimaryKey({ type: "uuid", defaultRaw: "gen_random_uuid()" })
|
|
387
|
+
], DomainMapping.prototype, "id", 2);
|
|
388
|
+
__decorateClass([
|
|
389
|
+
Property({ type: "text" })
|
|
390
|
+
], DomainMapping.prototype, "hostname", 2);
|
|
391
|
+
__decorateClass([
|
|
392
|
+
Property({ name: "tenant_id", type: "uuid" })
|
|
393
|
+
], DomainMapping.prototype, "tenantId", 2);
|
|
394
|
+
__decorateClass([
|
|
395
|
+
Property({ name: "organization_id", type: "uuid" })
|
|
396
|
+
], DomainMapping.prototype, "organizationId", 2);
|
|
397
|
+
__decorateClass([
|
|
398
|
+
ManyToOne(() => DomainMapping, { fieldName: "replaces_domain_id", nullable: true })
|
|
399
|
+
], DomainMapping.prototype, "replacesDomain", 2);
|
|
400
|
+
__decorateClass([
|
|
401
|
+
Enum({ items: () => DOMAIN_PROVIDERS, type: "text", name: "provider" })
|
|
402
|
+
], DomainMapping.prototype, "provider", 2);
|
|
403
|
+
__decorateClass([
|
|
404
|
+
Enum({ items: () => DOMAIN_STATUSES, type: "text", name: "status" })
|
|
405
|
+
], DomainMapping.prototype, "status", 2);
|
|
406
|
+
__decorateClass([
|
|
407
|
+
Property({ name: "verified_at", type: Date, nullable: true })
|
|
408
|
+
], DomainMapping.prototype, "verifiedAt", 2);
|
|
409
|
+
__decorateClass([
|
|
410
|
+
Property({ name: "last_dns_check_at", type: Date, nullable: true })
|
|
411
|
+
], DomainMapping.prototype, "lastDnsCheckAt", 2);
|
|
412
|
+
__decorateClass([
|
|
413
|
+
Property({ name: "dns_failure_reason", type: "text", nullable: true, length: 500 })
|
|
414
|
+
], DomainMapping.prototype, "dnsFailureReason", 2);
|
|
415
|
+
__decorateClass([
|
|
416
|
+
Property({ name: "tls_failure_reason", type: "text", nullable: true, length: 500 })
|
|
417
|
+
], DomainMapping.prototype, "tlsFailureReason", 2);
|
|
418
|
+
__decorateClass([
|
|
419
|
+
Property({ name: "tls_retry_count", type: "int", default: 0 })
|
|
420
|
+
], DomainMapping.prototype, "tlsRetryCount", 2);
|
|
421
|
+
__decorateClass([
|
|
422
|
+
Property({ name: "created_at", type: Date, onCreate: () => /* @__PURE__ */ new Date() })
|
|
423
|
+
], DomainMapping.prototype, "createdAt", 2);
|
|
424
|
+
__decorateClass([
|
|
425
|
+
Property({ name: "updated_at", type: Date, onUpdate: () => /* @__PURE__ */ new Date(), nullable: true })
|
|
426
|
+
], DomainMapping.prototype, "updatedAt", 2);
|
|
427
|
+
DomainMapping = __decorateClass([
|
|
428
|
+
Entity({ tableName: "domain_mappings" }),
|
|
429
|
+
Unique({ properties: ["hostname"], name: "domain_mappings_hostname_unique" }),
|
|
430
|
+
Index({ properties: ["organizationId"], name: "domain_mappings_organization_id_idx" }),
|
|
431
|
+
Index({ properties: ["tenantId"], name: "domain_mappings_tenant_id_idx" }),
|
|
432
|
+
Unique({
|
|
433
|
+
name: "domain_mappings_replaces_domain_id_unique",
|
|
434
|
+
expression: `create unique index "domain_mappings_replaces_domain_id_unique" on "domain_mappings" ("replaces_domain_id") where "replaces_domain_id" is not null`
|
|
435
|
+
}),
|
|
436
|
+
Index({
|
|
437
|
+
name: "domain_mappings_pending_verification_idx",
|
|
438
|
+
expression: `create index "domain_mappings_pending_verification_idx" on "domain_mappings" ("status", "last_dns_check_at") where "status" in ('pending', 'dns_failed')`
|
|
439
|
+
}),
|
|
440
|
+
Index({
|
|
441
|
+
name: "domain_mappings_pending_tls_idx",
|
|
442
|
+
expression: `create index "domain_mappings_pending_tls_idx" on "domain_mappings" ("status", "updated_at") where "status" in ('verified', 'tls_failed')`
|
|
443
|
+
}),
|
|
444
|
+
Check({
|
|
445
|
+
name: "domain_mappings_hostname_normalized_chk",
|
|
446
|
+
expression: `"hostname" = lower("hostname") and "hostname" not like '%.'`
|
|
447
|
+
})
|
|
448
|
+
], DomainMapping);
|
|
369
449
|
export {
|
|
370
450
|
CustomerRole,
|
|
371
451
|
CustomerRoleAcl,
|
|
@@ -375,6 +455,9 @@ export {
|
|
|
375
455
|
CustomerUserInvitation,
|
|
376
456
|
CustomerUserPasswordReset,
|
|
377
457
|
CustomerUserRole,
|
|
378
|
-
CustomerUserSession
|
|
458
|
+
CustomerUserSession,
|
|
459
|
+
DOMAIN_PROVIDERS,
|
|
460
|
+
DOMAIN_STATUSES,
|
|
461
|
+
DomainMapping
|
|
379
462
|
};
|
|
380
463
|
//# sourceMappingURL=entities.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/modules/customer_accounts/data/entities.ts"],
|
|
4
|
-
"sourcesContent": ["import { Entity, Index, ManyToOne, PrimaryKey, Property, Unique } from '@mikro-orm/decorators/legacy'\n\n@Entity({ tableName: 'customer_users' })\n@Unique({ properties: ['tenantId', 'emailHash'], name: 'customer_users_tenant_email_hash_uniq' })\nexport class CustomerUser {\n @PrimaryKey({ type: 'uuid', defaultRaw: 'gen_random_uuid()' })\n id!: string\n\n @Property({ name: 'tenant_id', type: 'uuid' })\n tenantId!: string\n\n @Property({ name: 'organization_id', type: 'uuid' })\n organizationId!: string\n\n @Property({ type: 'text' })\n email!: string\n\n @Property({ name: 'email_hash', type: 'text' })\n @Index({ name: 'customer_users_email_hash_idx' })\n emailHash!: string\n\n @Property({ name: 'password_hash', type: 'text', nullable: true })\n passwordHash?: string | null\n\n @Property({ name: 'display_name', type: 'text' })\n displayName!: string\n\n @Property({ name: 'email_verified_at', type: Date, nullable: true })\n emailVerifiedAt?: Date | null\n\n @Property({ name: 'failed_login_attempts', type: 'int', default: 0 })\n failedLoginAttempts: number = 0\n\n @Property({ name: 'locked_until', type: Date, nullable: true })\n lockedUntil?: Date | null\n\n @Property({ name: 'last_login_at', type: Date, nullable: true })\n lastLoginAt?: Date | null\n\n @Property({ name: 'sessions_revoked_at', type: Date, nullable: true })\n sessionsRevokedAt?: Date | null\n\n @Property({ name: 'person_entity_id', type: 'uuid', nullable: true })\n @Index({ name: 'customer_users_person_entity_idx' })\n personEntityId?: string | null\n\n @Property({ name: 'customer_entity_id', type: 'uuid', nullable: true })\n @Index({ name: 'customer_users_customer_entity_idx' })\n customerEntityId?: string | null\n\n @Property({ name: 'is_active', type: 'boolean', default: true })\n isActive: boolean = true\n\n @Property({ name: 'created_at', type: Date, onCreate: () => new Date() })\n createdAt: Date = new Date()\n\n @Property({ name: 'updated_at', type: Date, onUpdate: () => new Date(), nullable: true })\n updatedAt?: Date\n\n @Property({ name: 'deleted_at', type: Date, nullable: true })\n deletedAt?: Date | null\n}\n\n@Entity({ tableName: 'customer_roles' })\n@Unique({ properties: ['tenantId', 'slug'], name: 'customer_roles_tenant_slug_uniq' })\nexport class CustomerRole {\n @PrimaryKey({ type: 'uuid', defaultRaw: 'gen_random_uuid()' })\n id!: string\n\n @Property({ name: 'tenant_id', type: 'uuid' })\n tenantId!: string\n\n @Property({ name: 'organization_id', type: 'uuid' })\n organizationId!: string\n\n @Property({ type: 'text' })\n name!: string\n\n @Property({ type: 'text' })\n slug!: string\n\n @Property({ type: 'text', nullable: true })\n description?: string | null\n\n @Property({ name: 'is_default', type: 'boolean', default: false })\n isDefault: boolean = false\n\n @Property({ name: 'is_system', type: 'boolean', default: false })\n isSystem: boolean = false\n\n @Property({ name: 'customer_assignable', type: 'boolean', default: false })\n customerAssignable: boolean = false\n\n @Property({ name: 'created_at', type: Date, onCreate: () => new Date() })\n createdAt: Date = new Date()\n\n @Property({ name: 'updated_at', type: Date, onUpdate: () => new Date(), nullable: true })\n updatedAt?: Date\n\n @Property({ name: 'deleted_at', type: Date, nullable: true })\n deletedAt?: Date | null\n}\n\n@Entity({ tableName: 'customer_role_acls' })\n@Unique({ properties: ['role', 'tenantId'], name: 'customer_role_acls_role_tenant_uniq' })\nexport class CustomerRoleAcl {\n @PrimaryKey({ type: 'uuid', defaultRaw: 'gen_random_uuid()' })\n id!: string\n\n @ManyToOne(() => CustomerRole)\n role!: CustomerRole\n\n @Property({ name: 'tenant_id', type: 'uuid' })\n tenantId!: string\n\n @Property({ name: 'features_json', type: 'json', nullable: true })\n featuresJson?: string[] | null\n\n @Property({ name: 'is_portal_admin', type: 'boolean', default: false })\n isPortalAdmin: boolean = false\n\n @Property({ name: 'created_at', type: Date, onCreate: () => new Date() })\n createdAt: Date = new Date()\n\n @Property({ name: 'updated_at', type: Date, onUpdate: () => new Date(), nullable: true })\n updatedAt?: Date\n\n @Property({ name: 'deleted_at', type: Date, nullable: true })\n deletedAt?: Date | null\n}\n\n@Entity({ tableName: 'customer_user_roles' })\n@Unique({ properties: ['user', 'role'], name: 'customer_user_roles_user_role_uniq' })\nexport class CustomerUserRole {\n @PrimaryKey({ type: 'uuid', defaultRaw: 'gen_random_uuid()' })\n id!: string\n\n @ManyToOne(() => CustomerUser)\n user!: CustomerUser\n\n @ManyToOne(() => CustomerRole)\n role!: CustomerRole\n\n @Property({ name: 'created_at', type: Date, onCreate: () => new Date() })\n createdAt: Date = new Date()\n\n @Property({ name: 'deleted_at', type: Date, nullable: true })\n deletedAt?: Date | null\n}\n\n@Entity({ tableName: 'customer_user_acls' })\n@Unique({ properties: ['user', 'tenantId'], name: 'customer_user_acls_user_tenant_uniq' })\nexport class CustomerUserAcl {\n @PrimaryKey({ type: 'uuid', defaultRaw: 'gen_random_uuid()' })\n id!: string\n\n @ManyToOne(() => CustomerUser)\n user!: CustomerUser\n\n @Property({ name: 'tenant_id', type: 'uuid' })\n tenantId!: string\n\n @Property({ name: 'features_json', type: 'json', nullable: true })\n featuresJson?: string[] | null\n\n @Property({ name: 'is_portal_admin', type: 'boolean', default: false })\n isPortalAdmin: boolean = false\n\n @Property({ name: 'created_at', type: Date, onCreate: () => new Date() })\n createdAt: Date = new Date()\n\n @Property({ name: 'updated_at', type: Date, onUpdate: () => new Date(), nullable: true })\n updatedAt?: Date\n\n @Property({ name: 'deleted_at', type: Date, nullable: true })\n deletedAt?: Date | null\n}\n\n@Entity({ tableName: 'customer_user_sessions' })\n@Index({ properties: ['tokenHash'], name: 'customer_user_sessions_token_hash_idx' })\nexport class CustomerUserSession {\n @PrimaryKey({ type: 'uuid', defaultRaw: 'gen_random_uuid()' })\n id!: string\n\n @ManyToOne(() => CustomerUser)\n user!: CustomerUser\n\n @Property({ name: 'token_hash', type: 'text' })\n tokenHash!: string\n\n @Property({ name: 'ip_address', type: 'text', nullable: true })\n ipAddress?: string | null\n\n @Property({ name: 'user_agent', type: 'text', nullable: true })\n userAgent?: string | null\n\n @Property({ name: 'expires_at', type: Date })\n expiresAt!: Date\n\n @Property({ name: 'last_used_at', type: Date, nullable: true })\n lastUsedAt?: Date | null\n\n @Property({ name: 'created_at', type: Date, onCreate: () => new Date() })\n createdAt: Date = new Date()\n\n @Property({ name: 'deleted_at', type: Date, nullable: true })\n deletedAt?: Date | null\n}\n\n@Entity({ tableName: 'customer_user_email_verifications' })\n@Index({ properties: ['token'], name: 'customer_user_email_verifications_token_idx' })\nexport class CustomerUserEmailVerification {\n @PrimaryKey({ type: 'uuid', defaultRaw: 'gen_random_uuid()' })\n id!: string\n\n @ManyToOne(() => CustomerUser)\n user!: CustomerUser\n\n @Property({ type: 'text' })\n token!: string\n\n @Property({ type: 'text', default: 'email_verification' })\n purpose: string = 'email_verification'\n\n @Property({ name: 'expires_at', type: Date })\n expiresAt!: Date\n\n @Property({ name: 'used_at', type: Date, nullable: true })\n usedAt?: Date | null\n\n @Property({ name: 'created_at', type: Date, onCreate: () => new Date() })\n createdAt: Date = new Date()\n}\n\n@Entity({ tableName: 'customer_user_password_resets' })\n@Index({ properties: ['token'], name: 'customer_user_password_resets_token_idx' })\nexport class CustomerUserPasswordReset {\n @PrimaryKey({ type: 'uuid', defaultRaw: 'gen_random_uuid()' })\n id!: string\n\n @ManyToOne(() => CustomerUser)\n user!: CustomerUser\n\n @Property({ type: 'text' })\n token!: string\n\n @Property({ name: 'expires_at', type: Date })\n expiresAt!: Date\n\n @Property({ name: 'used_at', type: Date, nullable: true })\n usedAt?: Date | null\n\n @Property({ name: 'created_at', type: Date, onCreate: () => new Date() })\n createdAt: Date = new Date()\n}\n\n@Entity({ tableName: 'customer_user_invitations' })\n@Index({ properties: ['token'], name: 'customer_user_invitations_token_idx' })\n@Index({ properties: ['tenantId', 'emailHash'], name: 'customer_user_invitations_tenant_email_hash_idx' })\nexport class CustomerUserInvitation {\n @PrimaryKey({ type: 'uuid', defaultRaw: 'gen_random_uuid()' })\n id!: string\n\n @Property({ name: 'tenant_id', type: 'uuid' })\n tenantId!: string\n\n @Property({ name: 'organization_id', type: 'uuid' })\n organizationId!: string\n\n @Property({ type: 'text' })\n email!: string\n\n @Property({ name: 'email_hash', type: 'text' })\n emailHash!: string\n\n @Property({ type: 'text' })\n token!: string\n\n @Property({ name: 'customer_entity_id', type: 'uuid', nullable: true })\n customerEntityId?: string | null\n\n @Property({ name: 'role_ids_json', type: 'json', nullable: true })\n roleIdsJson?: string[] | null\n\n @Property({ name: 'invited_by_user_id', type: 'uuid', nullable: true })\n invitedByUserId?: string | null\n\n @Property({ name: 'invited_by_customer_user_id', type: 'uuid', nullable: true })\n invitedByCustomerUserId?: string | null\n\n @Property({ name: 'display_name', type: 'text', nullable: true })\n displayName?: string | null\n\n @Property({ name: 'expires_at', type: Date })\n expiresAt!: Date\n\n @Property({ name: 'accepted_at', type: Date, nullable: true })\n acceptedAt?: Date | null\n\n @Property({ name: 'cancelled_at', type: Date, nullable: true })\n cancelledAt?: Date | null\n\n @Property({ name: 'created_at', type: Date, onCreate: () => new Date() })\n createdAt: Date = new Date()\n}\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;AAAA,SAAS,QAAQ,OAAO,WAAW,YAAY,UAAU,cAAc;AAIhE,IAAM,eAAN,MAAmB;AAAA,EAAnB;AA2BL,+BAA8B;AAoB9B,oBAAoB;AAGpB,qBAAkB,oBAAI,KAAK;AAAA;AAO7B;AAvDE;AAAA,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jD,MAAM,EAAE,YAAY,CAAC,OAAO,GAAG,MAAM,sCAAsC,CAAC;AAAA,EAC5E,MAAM,EAAE,YAAY,CAAC,YAAY,WAAW,GAAG,MAAM,kDAAkD,CAAC;AAAA,GAC5F;",
|
|
4
|
+
"sourcesContent": ["import { Check, Entity, Enum, Index, ManyToOne, PrimaryKey, Property, Unique } from '@mikro-orm/decorators/legacy'\n\nexport type DomainProvider = 'traefik'\nexport type DomainStatus = 'pending' | 'verified' | 'active' | 'dns_failed' | 'tls_failed'\n\nexport const DOMAIN_PROVIDERS: readonly DomainProvider[] = ['traefik'] as const\nexport const DOMAIN_STATUSES: readonly DomainStatus[] = [\n 'pending',\n 'verified',\n 'active',\n 'dns_failed',\n 'tls_failed',\n] as const\n\n@Entity({ tableName: 'customer_users' })\n@Unique({ properties: ['tenantId', 'emailHash'], name: 'customer_users_tenant_email_hash_uniq' })\nexport class CustomerUser {\n @PrimaryKey({ type: 'uuid', defaultRaw: 'gen_random_uuid()' })\n id!: string\n\n @Property({ name: 'tenant_id', type: 'uuid' })\n tenantId!: string\n\n @Property({ name: 'organization_id', type: 'uuid' })\n organizationId!: string\n\n @Property({ type: 'text' })\n email!: string\n\n @Property({ name: 'email_hash', type: 'text' })\n @Index({ name: 'customer_users_email_hash_idx' })\n emailHash!: string\n\n @Property({ name: 'password_hash', type: 'text', nullable: true })\n passwordHash?: string | null\n\n @Property({ name: 'display_name', type: 'text' })\n displayName!: string\n\n @Property({ name: 'email_verified_at', type: Date, nullable: true })\n emailVerifiedAt?: Date | null\n\n @Property({ name: 'failed_login_attempts', type: 'int', default: 0 })\n failedLoginAttempts: number = 0\n\n @Property({ name: 'locked_until', type: Date, nullable: true })\n lockedUntil?: Date | null\n\n @Property({ name: 'last_login_at', type: Date, nullable: true })\n lastLoginAt?: Date | null\n\n @Property({ name: 'sessions_revoked_at', type: Date, nullable: true })\n sessionsRevokedAt?: Date | null\n\n @Property({ name: 'person_entity_id', type: 'uuid', nullable: true })\n @Index({ name: 'customer_users_person_entity_idx' })\n personEntityId?: string | null\n\n @Property({ name: 'customer_entity_id', type: 'uuid', nullable: true })\n @Index({ name: 'customer_users_customer_entity_idx' })\n customerEntityId?: string | null\n\n @Property({ name: 'is_active', type: 'boolean', default: true })\n isActive: boolean = true\n\n @Property({ name: 'created_at', type: Date, onCreate: () => new Date() })\n createdAt: Date = new Date()\n\n @Property({ name: 'updated_at', type: Date, onUpdate: () => new Date(), nullable: true })\n updatedAt?: Date\n\n @Property({ name: 'deleted_at', type: Date, nullable: true })\n deletedAt?: Date | null\n}\n\n@Entity({ tableName: 'customer_roles' })\n@Unique({ properties: ['tenantId', 'slug'], name: 'customer_roles_tenant_slug_uniq' })\nexport class CustomerRole {\n @PrimaryKey({ type: 'uuid', defaultRaw: 'gen_random_uuid()' })\n id!: string\n\n @Property({ name: 'tenant_id', type: 'uuid' })\n tenantId!: string\n\n @Property({ name: 'organization_id', type: 'uuid' })\n organizationId!: string\n\n @Property({ type: 'text' })\n name!: string\n\n @Property({ type: 'text' })\n slug!: string\n\n @Property({ type: 'text', nullable: true })\n description?: string | null\n\n @Property({ name: 'is_default', type: 'boolean', default: false })\n isDefault: boolean = false\n\n @Property({ name: 'is_system', type: 'boolean', default: false })\n isSystem: boolean = false\n\n @Property({ name: 'customer_assignable', type: 'boolean', default: false })\n customerAssignable: boolean = false\n\n @Property({ name: 'created_at', type: Date, onCreate: () => new Date() })\n createdAt: Date = new Date()\n\n @Property({ name: 'updated_at', type: Date, onUpdate: () => new Date(), nullable: true })\n updatedAt?: Date\n\n @Property({ name: 'deleted_at', type: Date, nullable: true })\n deletedAt?: Date | null\n}\n\n@Entity({ tableName: 'customer_role_acls' })\n@Unique({ properties: ['role', 'tenantId'], name: 'customer_role_acls_role_tenant_uniq' })\nexport class CustomerRoleAcl {\n @PrimaryKey({ type: 'uuid', defaultRaw: 'gen_random_uuid()' })\n id!: string\n\n @ManyToOne(() => CustomerRole)\n role!: CustomerRole\n\n @Property({ name: 'tenant_id', type: 'uuid' })\n tenantId!: string\n\n @Property({ name: 'features_json', type: 'json', nullable: true })\n featuresJson?: string[] | null\n\n @Property({ name: 'is_portal_admin', type: 'boolean', default: false })\n isPortalAdmin: boolean = false\n\n @Property({ name: 'created_at', type: Date, onCreate: () => new Date() })\n createdAt: Date = new Date()\n\n @Property({ name: 'updated_at', type: Date, onUpdate: () => new Date(), nullable: true })\n updatedAt?: Date\n\n @Property({ name: 'deleted_at', type: Date, nullable: true })\n deletedAt?: Date | null\n}\n\n@Entity({ tableName: 'customer_user_roles' })\n@Unique({ properties: ['user', 'role'], name: 'customer_user_roles_user_role_uniq' })\nexport class CustomerUserRole {\n @PrimaryKey({ type: 'uuid', defaultRaw: 'gen_random_uuid()' })\n id!: string\n\n @ManyToOne(() => CustomerUser)\n user!: CustomerUser\n\n @ManyToOne(() => CustomerRole)\n role!: CustomerRole\n\n @Property({ name: 'created_at', type: Date, onCreate: () => new Date() })\n createdAt: Date = new Date()\n\n @Property({ name: 'deleted_at', type: Date, nullable: true })\n deletedAt?: Date | null\n}\n\n@Entity({ tableName: 'customer_user_acls' })\n@Unique({ properties: ['user', 'tenantId'], name: 'customer_user_acls_user_tenant_uniq' })\nexport class CustomerUserAcl {\n @PrimaryKey({ type: 'uuid', defaultRaw: 'gen_random_uuid()' })\n id!: string\n\n @ManyToOne(() => CustomerUser)\n user!: CustomerUser\n\n @Property({ name: 'tenant_id', type: 'uuid' })\n tenantId!: string\n\n @Property({ name: 'features_json', type: 'json', nullable: true })\n featuresJson?: string[] | null\n\n @Property({ name: 'is_portal_admin', type: 'boolean', default: false })\n isPortalAdmin: boolean = false\n\n @Property({ name: 'created_at', type: Date, onCreate: () => new Date() })\n createdAt: Date = new Date()\n\n @Property({ name: 'updated_at', type: Date, onUpdate: () => new Date(), nullable: true })\n updatedAt?: Date\n\n @Property({ name: 'deleted_at', type: Date, nullable: true })\n deletedAt?: Date | null\n}\n\n@Entity({ tableName: 'customer_user_sessions' })\n@Index({ properties: ['tokenHash'], name: 'customer_user_sessions_token_hash_idx' })\nexport class CustomerUserSession {\n @PrimaryKey({ type: 'uuid', defaultRaw: 'gen_random_uuid()' })\n id!: string\n\n @ManyToOne(() => CustomerUser)\n user!: CustomerUser\n\n @Property({ name: 'token_hash', type: 'text' })\n tokenHash!: string\n\n @Property({ name: 'ip_address', type: 'text', nullable: true })\n ipAddress?: string | null\n\n @Property({ name: 'user_agent', type: 'text', nullable: true })\n userAgent?: string | null\n\n @Property({ name: 'expires_at', type: Date })\n expiresAt!: Date\n\n @Property({ name: 'last_used_at', type: Date, nullable: true })\n lastUsedAt?: Date | null\n\n @Property({ name: 'created_at', type: Date, onCreate: () => new Date() })\n createdAt: Date = new Date()\n\n @Property({ name: 'deleted_at', type: Date, nullable: true })\n deletedAt?: Date | null\n}\n\n@Entity({ tableName: 'customer_user_email_verifications' })\n@Index({ properties: ['token'], name: 'customer_user_email_verifications_token_idx' })\nexport class CustomerUserEmailVerification {\n @PrimaryKey({ type: 'uuid', defaultRaw: 'gen_random_uuid()' })\n id!: string\n\n @ManyToOne(() => CustomerUser)\n user!: CustomerUser\n\n @Property({ type: 'text' })\n token!: string\n\n @Property({ type: 'text', default: 'email_verification' })\n purpose: string = 'email_verification'\n\n @Property({ name: 'expires_at', type: Date })\n expiresAt!: Date\n\n @Property({ name: 'used_at', type: Date, nullable: true })\n usedAt?: Date | null\n\n @Property({ name: 'created_at', type: Date, onCreate: () => new Date() })\n createdAt: Date = new Date()\n}\n\n@Entity({ tableName: 'customer_user_password_resets' })\n@Index({ properties: ['token'], name: 'customer_user_password_resets_token_idx' })\nexport class CustomerUserPasswordReset {\n @PrimaryKey({ type: 'uuid', defaultRaw: 'gen_random_uuid()' })\n id!: string\n\n @ManyToOne(() => CustomerUser)\n user!: CustomerUser\n\n @Property({ type: 'text' })\n token!: string\n\n @Property({ name: 'expires_at', type: Date })\n expiresAt!: Date\n\n @Property({ name: 'used_at', type: Date, nullable: true })\n usedAt?: Date | null\n\n @Property({ name: 'created_at', type: Date, onCreate: () => new Date() })\n createdAt: Date = new Date()\n}\n\n@Entity({ tableName: 'customer_user_invitations' })\n@Index({ properties: ['token'], name: 'customer_user_invitations_token_idx' })\n@Index({ properties: ['tenantId', 'emailHash'], name: 'customer_user_invitations_tenant_email_hash_idx' })\nexport class CustomerUserInvitation {\n @PrimaryKey({ type: 'uuid', defaultRaw: 'gen_random_uuid()' })\n id!: string\n\n @Property({ name: 'tenant_id', type: 'uuid' })\n tenantId!: string\n\n @Property({ name: 'organization_id', type: 'uuid' })\n organizationId!: string\n\n @Property({ type: 'text' })\n email!: string\n\n @Property({ name: 'email_hash', type: 'text' })\n emailHash!: string\n\n @Property({ type: 'text' })\n token!: string\n\n @Property({ name: 'customer_entity_id', type: 'uuid', nullable: true })\n customerEntityId?: string | null\n\n @Property({ name: 'role_ids_json', type: 'json', nullable: true })\n roleIdsJson?: string[] | null\n\n @Property({ name: 'invited_by_user_id', type: 'uuid', nullable: true })\n invitedByUserId?: string | null\n\n @Property({ name: 'invited_by_customer_user_id', type: 'uuid', nullable: true })\n invitedByCustomerUserId?: string | null\n\n @Property({ name: 'display_name', type: 'text', nullable: true })\n displayName?: string | null\n\n @Property({ name: 'expires_at', type: Date })\n expiresAt!: Date\n\n @Property({ name: 'accepted_at', type: Date, nullable: true })\n acceptedAt?: Date | null\n\n @Property({ name: 'cancelled_at', type: Date, nullable: true })\n cancelledAt?: Date | null\n\n @Property({ name: 'created_at', type: Date, onCreate: () => new Date() })\n createdAt: Date = new Date()\n}\n\n@Entity({ tableName: 'domain_mappings' })\n@Unique({ properties: ['hostname'], name: 'domain_mappings_hostname_unique' })\n@Index({ properties: ['organizationId'], name: 'domain_mappings_organization_id_idx' })\n@Index({ properties: ['tenantId'], name: 'domain_mappings_tenant_id_idx' })\n@Unique({\n name: 'domain_mappings_replaces_domain_id_unique',\n expression:\n `create unique index \"domain_mappings_replaces_domain_id_unique\" on \"domain_mappings\" (\"replaces_domain_id\") where \"replaces_domain_id\" is not null`,\n})\n@Index({\n name: 'domain_mappings_pending_verification_idx',\n expression:\n `create index \"domain_mappings_pending_verification_idx\" on \"domain_mappings\" (\"status\", \"last_dns_check_at\") where \"status\" in ('pending', 'dns_failed')`,\n})\n@Index({\n name: 'domain_mappings_pending_tls_idx',\n expression:\n `create index \"domain_mappings_pending_tls_idx\" on \"domain_mappings\" (\"status\", \"updated_at\") where \"status\" in ('verified', 'tls_failed')`,\n})\n@Check({\n name: 'domain_mappings_hostname_normalized_chk',\n expression: `\"hostname\" = lower(\"hostname\") and \"hostname\" not like '%.'`,\n})\nexport class DomainMapping {\n @PrimaryKey({ type: 'uuid', defaultRaw: 'gen_random_uuid()' })\n id!: string\n\n @Property({ type: 'text' })\n hostname!: string\n\n @Property({ name: 'tenant_id', type: 'uuid' })\n tenantId!: string\n\n @Property({ name: 'organization_id', type: 'uuid' })\n organizationId!: string\n\n @ManyToOne(() => DomainMapping, { fieldName: 'replaces_domain_id', nullable: true })\n replacesDomain?: DomainMapping | null\n\n @Enum({ items: () => DOMAIN_PROVIDERS as unknown as string[], type: 'text', name: 'provider' })\n provider: DomainProvider = 'traefik'\n\n @Enum({ items: () => DOMAIN_STATUSES as unknown as string[], type: 'text', name: 'status' })\n status: DomainStatus = 'pending'\n\n @Property({ name: 'verified_at', type: Date, nullable: true })\n verifiedAt?: Date | null\n\n @Property({ name: 'last_dns_check_at', type: Date, nullable: true })\n lastDnsCheckAt?: Date | null\n\n @Property({ name: 'dns_failure_reason', type: 'text', nullable: true, length: 500 })\n dnsFailureReason?: string | null\n\n @Property({ name: 'tls_failure_reason', type: 'text', nullable: true, length: 500 })\n tlsFailureReason?: string | null\n\n @Property({ name: 'tls_retry_count', type: 'int', default: 0 })\n tlsRetryCount: number = 0\n\n @Property({ name: 'created_at', type: Date, onCreate: () => new Date() })\n createdAt: Date = new Date()\n\n @Property({ name: 'updated_at', type: Date, onUpdate: () => new Date(), nullable: true })\n updatedAt?: Date | null\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;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AAA,GACY;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
import { createRequestContainer } from "@open-mercato/shared/lib/di/container";
|
|
2
|
+
import { tryNormalizeHostname } from "@open-mercato/core/modules/customer_accounts/lib/hostname";
|
|
3
|
+
const DOMAIN_MAPPING_ENTITY = "customer_accounts.domain_mapping";
|
|
4
|
+
const MAX_DOMAINS_PER_ORG = 2;
|
|
5
|
+
function readHostnameField(payload) {
|
|
6
|
+
if (!payload || typeof payload !== "object") return null;
|
|
7
|
+
const raw = payload.hostname;
|
|
8
|
+
return typeof raw === "string" ? raw : null;
|
|
9
|
+
}
|
|
10
|
+
function readOrgIdField(payload) {
|
|
11
|
+
if (!payload || typeof payload !== "object") return null;
|
|
12
|
+
const raw = payload.organizationId ?? payload.organization_id;
|
|
13
|
+
return typeof raw === "string" ? raw : null;
|
|
14
|
+
}
|
|
15
|
+
const hostnameFormatGuard = {
|
|
16
|
+
id: "customer_accounts.domain_mapping.hostname-format",
|
|
17
|
+
targetEntity: DOMAIN_MAPPING_ENTITY,
|
|
18
|
+
operations: ["create"],
|
|
19
|
+
priority: 10,
|
|
20
|
+
async validate(input) {
|
|
21
|
+
const raw = readHostnameField(input.mutationPayload);
|
|
22
|
+
if (!raw) {
|
|
23
|
+
return { ok: false, status: 422, message: "Hostname is required" };
|
|
24
|
+
}
|
|
25
|
+
const normalized = tryNormalizeHostname(raw);
|
|
26
|
+
if (!normalized) {
|
|
27
|
+
return {
|
|
28
|
+
ok: false,
|
|
29
|
+
status: 422,
|
|
30
|
+
message: "Hostname is not a valid DNS name (must be at least two labels, ASCII or IDN)"
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
return {
|
|
34
|
+
ok: true,
|
|
35
|
+
modifiedPayload: { hostname: normalized }
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
const hostnameUniqueGuard = {
|
|
40
|
+
id: "customer_accounts.domain_mapping.hostname-unique",
|
|
41
|
+
targetEntity: DOMAIN_MAPPING_ENTITY,
|
|
42
|
+
operations: ["create"],
|
|
43
|
+
priority: 20,
|
|
44
|
+
async validate(input) {
|
|
45
|
+
const raw = readHostnameField(input.mutationPayload);
|
|
46
|
+
if (!raw) return { ok: true };
|
|
47
|
+
const hostname = tryNormalizeHostname(raw);
|
|
48
|
+
if (!hostname) return { ok: true };
|
|
49
|
+
const container = await createRequestContainer();
|
|
50
|
+
let service = null;
|
|
51
|
+
try {
|
|
52
|
+
service = container.resolve("domainMappingService");
|
|
53
|
+
} catch {
|
|
54
|
+
return { ok: true };
|
|
55
|
+
}
|
|
56
|
+
const existing = await service.resolveByHostname(hostname);
|
|
57
|
+
if (!existing) return { ok: true };
|
|
58
|
+
const sameOrg = existing.organizationId === readOrgIdField(input.mutationPayload);
|
|
59
|
+
if (existing.tenantId !== input.tenantId || !sameOrg) {
|
|
60
|
+
return {
|
|
61
|
+
ok: false,
|
|
62
|
+
status: 409,
|
|
63
|
+
message: "This domain is not available. Please choose a different hostname."
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
return { ok: true };
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
const orgLimitGuard = {
|
|
70
|
+
id: "customer_accounts.domain_mapping.org-limit",
|
|
71
|
+
targetEntity: DOMAIN_MAPPING_ENTITY,
|
|
72
|
+
operations: ["create"],
|
|
73
|
+
priority: 30,
|
|
74
|
+
async validate(input) {
|
|
75
|
+
const orgId = readOrgIdField(input.mutationPayload) ?? input.organizationId;
|
|
76
|
+
if (!orgId) {
|
|
77
|
+
return { ok: false, status: 422, message: "Organization is required" };
|
|
78
|
+
}
|
|
79
|
+
const container = await createRequestContainer();
|
|
80
|
+
let service = null;
|
|
81
|
+
try {
|
|
82
|
+
service = container.resolve("domainMappingService");
|
|
83
|
+
} catch {
|
|
84
|
+
return { ok: true };
|
|
85
|
+
}
|
|
86
|
+
const existing = await service.findByOrganization(orgId, { tenantId: input.tenantId });
|
|
87
|
+
if (existing.length >= MAX_DOMAINS_PER_ORG) {
|
|
88
|
+
return {
|
|
89
|
+
ok: false,
|
|
90
|
+
status: 409,
|
|
91
|
+
message: `Each organization can have at most ${MAX_DOMAINS_PER_ORG} custom domains (one active and one pending replacement). Remove an existing domain or finish the swap first.`
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
return { ok: true };
|
|
95
|
+
}
|
|
96
|
+
};
|
|
97
|
+
const recordScopeGuard = {
|
|
98
|
+
id: "customer_accounts.domain_mapping.record-scope",
|
|
99
|
+
targetEntity: DOMAIN_MAPPING_ENTITY,
|
|
100
|
+
operations: ["update", "delete"],
|
|
101
|
+
priority: 10,
|
|
102
|
+
async validate(input) {
|
|
103
|
+
const resourceId = input.resourceId;
|
|
104
|
+
if (!resourceId) {
|
|
105
|
+
return { ok: false, status: 422, message: "Domain mapping id is required" };
|
|
106
|
+
}
|
|
107
|
+
const container = await createRequestContainer();
|
|
108
|
+
let service = null;
|
|
109
|
+
try {
|
|
110
|
+
service = container.resolve("domainMappingService");
|
|
111
|
+
} catch {
|
|
112
|
+
return { ok: true };
|
|
113
|
+
}
|
|
114
|
+
const record = await service.findById(resourceId, { tenantId: input.tenantId });
|
|
115
|
+
if (!record) {
|
|
116
|
+
return { ok: false, status: 404, message: "Domain mapping not found" };
|
|
117
|
+
}
|
|
118
|
+
return { ok: true };
|
|
119
|
+
}
|
|
120
|
+
};
|
|
121
|
+
const guards = [
|
|
122
|
+
hostnameFormatGuard,
|
|
123
|
+
hostnameUniqueGuard,
|
|
124
|
+
orgLimitGuard,
|
|
125
|
+
recordScopeGuard
|
|
126
|
+
];
|
|
127
|
+
export {
|
|
128
|
+
guards
|
|
129
|
+
};
|
|
130
|
+
//# sourceMappingURL=guards.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../src/modules/customer_accounts/data/guards.ts"],
|
|
4
|
+
"sourcesContent": ["import type { MutationGuard } from '@open-mercato/shared/lib/crud/mutation-guard-registry'\nimport { createRequestContainer } from '@open-mercato/shared/lib/di/container'\nimport { tryNormalizeHostname } from '@open-mercato/core/modules/customer_accounts/lib/hostname'\nimport type { DomainMappingService } from '@open-mercato/core/modules/customer_accounts/services/domainMappingService'\n\nconst DOMAIN_MAPPING_ENTITY = 'customer_accounts.domain_mapping'\nconst MAX_DOMAINS_PER_ORG = 2\n\nfunction readHostnameField(payload: Record<string, unknown> | null | undefined): string | null {\n if (!payload || typeof payload !== 'object') return null\n const raw = (payload as Record<string, unknown>).hostname\n return typeof raw === 'string' ? raw : null\n}\n\nfunction readOrgIdField(payload: Record<string, unknown> | null | undefined): string | null {\n if (!payload || typeof payload !== 'object') return null\n const raw = (payload as Record<string, unknown>).organizationId ?? (payload as Record<string, unknown>).organization_id\n return typeof raw === 'string' ? raw : null\n}\n\nconst hostnameFormatGuard: MutationGuard = {\n id: 'customer_accounts.domain_mapping.hostname-format',\n targetEntity: DOMAIN_MAPPING_ENTITY,\n operations: ['create'],\n priority: 10,\n\n async validate(input) {\n const raw = readHostnameField(input.mutationPayload)\n if (!raw) {\n return { ok: false, status: 422, message: 'Hostname is required' }\n }\n const normalized = tryNormalizeHostname(raw)\n if (!normalized) {\n return {\n ok: false,\n status: 422,\n message: 'Hostname is not a valid DNS name (must be at least two labels, ASCII or IDN)',\n }\n }\n return {\n ok: true,\n modifiedPayload: { hostname: normalized },\n }\n },\n}\n\nconst hostnameUniqueGuard: MutationGuard = {\n id: 'customer_accounts.domain_mapping.hostname-unique',\n targetEntity: DOMAIN_MAPPING_ENTITY,\n operations: ['create'],\n priority: 20,\n\n async validate(input) {\n const raw = readHostnameField(input.mutationPayload)\n if (!raw) return { ok: true }\n const hostname = tryNormalizeHostname(raw)\n if (!hostname) return { ok: true }\n\n const container = await createRequestContainer()\n let service: DomainMappingService | null = null\n try {\n service = container.resolve('domainMappingService') as DomainMappingService\n } catch {\n return { ok: true }\n }\n\n const existing = await service.resolveByHostname(hostname)\n if (!existing) return { ok: true }\n\n // Intentionally tenant-agnostic message: do not disclose whether the\n // collision is intra-tenant or cross-tenant. Distinguishing them would\n // let any caller probe deployment-wide hostname registration.\n const sameOrg = existing.organizationId === readOrgIdField(input.mutationPayload)\n if (existing.tenantId !== input.tenantId || !sameOrg) {\n return {\n ok: false,\n status: 409,\n message: 'This domain is not available. Please choose a different hostname.',\n }\n }\n return { ok: true }\n },\n}\n\nconst orgLimitGuard: MutationGuard = {\n id: 'customer_accounts.domain_mapping.org-limit',\n targetEntity: DOMAIN_MAPPING_ENTITY,\n operations: ['create'],\n priority: 30,\n\n async validate(input) {\n const orgId = readOrgIdField(input.mutationPayload) ?? input.organizationId\n if (!orgId) {\n return { ok: false, status: 422, message: 'Organization is required' }\n }\n\n const container = await createRequestContainer()\n let service: DomainMappingService | null = null\n try {\n service = container.resolve('domainMappingService') as DomainMappingService\n } catch {\n return { ok: true }\n }\n\n const existing = await service.findByOrganization(orgId, { tenantId: input.tenantId })\n if (existing.length >= MAX_DOMAINS_PER_ORG) {\n return {\n ok: false,\n status: 409,\n message: `Each organization can have at most ${MAX_DOMAINS_PER_ORG} custom domains (one active and one pending replacement). Remove an existing domain or finish the swap first.`,\n }\n }\n return { ok: true }\n },\n}\n\n// Mirrors the in-progress-lock pattern used by other modules' update/delete\n// guards: ensure the target record exists and belongs to the caller's tenant\n// before any destructive or lifecycle-changing mutation runs. Verification\n// and health-check endpoints invoke this via operation: 'update' since they\n// transition the record's lifecycle status.\nconst recordScopeGuard: MutationGuard = {\n id: 'customer_accounts.domain_mapping.record-scope',\n targetEntity: DOMAIN_MAPPING_ENTITY,\n operations: ['update', 'delete'],\n priority: 10,\n\n async validate(input) {\n const resourceId = input.resourceId\n if (!resourceId) {\n return { ok: false, status: 422, message: 'Domain mapping id is required' }\n }\n\n const container = await createRequestContainer()\n let service: DomainMappingService | null = null\n try {\n service = container.resolve('domainMappingService') as DomainMappingService\n } catch {\n return { ok: true }\n }\n\n const record = await service.findById(resourceId, { tenantId: input.tenantId })\n if (!record) {\n return { ok: false, status: 404, message: 'Domain mapping not found' }\n }\n return { ok: true }\n },\n}\n\nexport const guards: MutationGuard[] = [\n hostnameFormatGuard,\n hostnameUniqueGuard,\n orgLimitGuard,\n recordScopeGuard,\n]\n"],
|
|
5
|
+
"mappings": "AACA,SAAS,8BAA8B;AACvC,SAAS,4BAA4B;AAGrC,MAAM,wBAAwB;AAC9B,MAAM,sBAAsB;AAE5B,SAAS,kBAAkB,SAAoE;AAC7F,MAAI,CAAC,WAAW,OAAO,YAAY,SAAU,QAAO;AACpD,QAAM,MAAO,QAAoC;AACjD,SAAO,OAAO,QAAQ,WAAW,MAAM;AACzC;AAEA,SAAS,eAAe,SAAoE;AAC1F,MAAI,CAAC,WAAW,OAAO,YAAY,SAAU,QAAO;AACpD,QAAM,MAAO,QAAoC,kBAAmB,QAAoC;AACxG,SAAO,OAAO,QAAQ,WAAW,MAAM;AACzC;AAEA,MAAM,sBAAqC;AAAA,EACzC,IAAI;AAAA,EACJ,cAAc;AAAA,EACd,YAAY,CAAC,QAAQ;AAAA,EACrB,UAAU;AAAA,EAEV,MAAM,SAAS,OAAO;AACpB,UAAM,MAAM,kBAAkB,MAAM,eAAe;AACnD,QAAI,CAAC,KAAK;AACR,aAAO,EAAE,IAAI,OAAO,QAAQ,KAAK,SAAS,uBAAuB;AAAA,IACnE;AACA,UAAM,aAAa,qBAAqB,GAAG;AAC3C,QAAI,CAAC,YAAY;AACf,aAAO;AAAA,QACL,IAAI;AAAA,QACJ,QAAQ;AAAA,QACR,SAAS;AAAA,MACX;AAAA,IACF;AACA,WAAO;AAAA,MACL,IAAI;AAAA,MACJ,iBAAiB,EAAE,UAAU,WAAW;AAAA,IAC1C;AAAA,EACF;AACF;AAEA,MAAM,sBAAqC;AAAA,EACzC,IAAI;AAAA,EACJ,cAAc;AAAA,EACd,YAAY,CAAC,QAAQ;AAAA,EACrB,UAAU;AAAA,EAEV,MAAM,SAAS,OAAO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I;AAAA,QACJ,QAAQ;AAAA,QACR,SAAS,sCAAsC,mBAAmB;AAAA,MACpE;AAAA,IACF;AACA,WAAO,EAAE,IAAI,KAAK;AAAA,EACpB;AACF;AAOA,MAAM,mBAAkC;AAAA,EACtC,IAAI;AAAA,EACJ,cAAc;AAAA,EACd,YAAY,CAAC,UAAU,QAAQ;AAAA,EAC/B,UAAU;AAAA,EAEV,MAAM,SAAS,OAAO;AACpB,UAAM,aAAa,MAAM;AACzB,QAAI,CAAC,YAAY;AACf,aAAO,EAAE,IAAI,OAAO,QAAQ,KAAK,SAAS,gCAAgC;AAAA,IAC5E;AAEA,UAAM,YAAY,MAAM,uBAAuB;AAC/C,QAAI,UAAuC;AAC3C,QAAI;AACF,gBAAU,UAAU,QAAQ,sBAAsB;AAAA,IACpD,QAAQ;AACN,aAAO,EAAE,IAAI,KAAK;AAAA,IACpB;AAEA,UAAM,SAAS,MAAM,QAAQ,SAAS,YAAY,EAAE,UAAU,MAAM,SAAS,CAAC;AAC9E,QAAI,CAAC,QAAQ;AACX,aAAO,EAAE,IAAI,OAAO,QAAQ,KAAK,SAAS,2BAA2B;AAAA,IACvE;AACA,WAAO,EAAE,IAAI,KAAK;AAAA,EACpB;AACF;AAEO,MAAM,SAA0B;AAAA,EACrC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
+
import { normalizeHostname } from "@open-mercato/core/modules/customer_accounts/lib/hostname";
|
|
2
3
|
const emailField = z.string().email().max(255);
|
|
3
4
|
const passwordField = z.string().min(8).max(128);
|
|
4
5
|
const displayNameField = z.string().min(1).max(255);
|
|
@@ -88,6 +89,22 @@ const adminUpdateUserSchema = z.object({
|
|
|
88
89
|
const adminResetPasswordSchema = z.object({
|
|
89
90
|
newPassword: passwordField
|
|
90
91
|
});
|
|
92
|
+
const hostnameSchema = z.string().min(1, "Hostname is required").max(512, "Hostname is too long").transform((value, ctx) => {
|
|
93
|
+
try {
|
|
94
|
+
return normalizeHostname(value);
|
|
95
|
+
} catch (err) {
|
|
96
|
+
ctx.addIssue({
|
|
97
|
+
code: z.ZodIssueCode.custom,
|
|
98
|
+
message: err instanceof Error ? err.message : "Invalid hostname"
|
|
99
|
+
});
|
|
100
|
+
return z.NEVER;
|
|
101
|
+
}
|
|
102
|
+
});
|
|
103
|
+
const registerDomainSchema = z.object({
|
|
104
|
+
hostname: hostnameSchema,
|
|
105
|
+
organizationId: z.string().uuid(),
|
|
106
|
+
replacesDomainId: z.string().uuid().optional()
|
|
107
|
+
});
|
|
91
108
|
export {
|
|
92
109
|
adminCreateUserSchema,
|
|
93
110
|
adminResetPasswordSchema,
|
|
@@ -95,6 +112,7 @@ export {
|
|
|
95
112
|
assignRolesSchema,
|
|
96
113
|
createRoleSchema,
|
|
97
114
|
emailVerifySchema,
|
|
115
|
+
hostnameSchema,
|
|
98
116
|
invitationAcceptSchema,
|
|
99
117
|
inviteUserSchema,
|
|
100
118
|
loginSchema,
|
|
@@ -104,6 +122,7 @@ export {
|
|
|
104
122
|
passwordResetConfirmSchema,
|
|
105
123
|
passwordResetRequestSchema,
|
|
106
124
|
profileUpdateSchema,
|
|
125
|
+
registerDomainSchema,
|
|
107
126
|
signupSchema,
|
|
108
127
|
updateRoleAclSchema,
|
|
109
128
|
updateRoleSchema
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/modules/customer_accounts/data/validators.ts"],
|
|
4
|
-
"sourcesContent": ["import { z } from 'zod'\n\nconst emailField = z.string().email().max(255)\nconst passwordField = z.string().min(8).max(128)\nconst displayNameField = z.string().min(1).max(255)\n\nexport const signupSchema = z.object({\n email: emailField,\n password: passwordField,\n displayName: displayNameField,\n tenantId: z.string().uuid().optional(),\n organizationId: z.string().uuid().optional(),\n})\n\nexport const loginSchema = z.object({\n email: emailField,\n password: z.string().min(1).max(128),\n tenantId: z.string().uuid().optional(),\n})\n\nexport const emailVerifySchema = z.object({\n token: z.string().min(1).max(512),\n})\n\nexport const passwordResetRequestSchema = z.object({\n email: emailField,\n tenantId: z.string().uuid().optional(),\n})\n\nexport const passwordResetConfirmSchema = z.object({\n token: z.string().min(1).max(512),\n password: passwordField,\n})\n\nexport const magicLinkRequestSchema = z.object({\n email: emailField,\n tenantId: z.string().uuid().optional(),\n})\n\nexport const magicLinkVerifySchema = z.object({\n token: z.string().min(1).max(512),\n})\n\nexport const invitationAcceptSchema = z.object({\n token: z.string().min(1).max(512),\n password: passwordField,\n displayName: displayNameField,\n})\n\nexport const profileUpdateSchema = z.object({\n displayName: displayNameField.optional(),\n})\n\nexport const passwordChangeSchema = z.object({\n currentPassword: z.string().min(1).max(128),\n newPassword: passwordField,\n})\n\nexport const createRoleSchema = z.object({\n name: z.string().min(1).max(255),\n slug: z.string().min(1).max(255).regex(/^[a-z0-9_-]+$/),\n description: z.string().max(1000).optional(),\n isDefault: z.boolean().optional(),\n customerAssignable: z.boolean().optional(),\n})\n\nexport const updateRoleSchema = z.object({\n name: z.string().min(1).max(255).optional(),\n description: z.string().max(1000).optional(),\n isDefault: z.boolean().optional(),\n customerAssignable: z.boolean().optional(),\n})\n\nexport const updateRoleAclSchema = z.object({\n features: z.array(z.string().min(1).max(255)),\n isPortalAdmin: z.boolean().optional(),\n})\n\nexport const inviteUserSchema = z.object({\n email: emailField,\n customerEntityId: z.string().uuid().optional(),\n roleIds: z.array(z.string().uuid()).min(1),\n displayName: displayNameField.optional(),\n})\n\nexport const assignRolesSchema = z.object({\n roleIds: z.array(z.string().uuid()).min(1),\n})\n\nexport const adminCreateUserSchema = z.object({\n email: emailField,\n password: passwordField,\n displayName: displayNameField,\n roleIds: z.array(z.string().uuid()).optional(),\n customerEntityId: z.string().uuid().optional(),\n})\n\nexport const adminUpdateUserSchema = z.object({\n displayName: displayNameField.optional(),\n isActive: z.boolean().optional(),\n lockedUntil: z.string().datetime().nullable().optional(),\n personEntityId: z.string().uuid().nullable().optional(),\n customerEntityId: z.string().uuid().nullable().optional(),\n roleIds: z.array(z.string().uuid()).optional(),\n})\n\nexport const adminResetPasswordSchema = z.object({\n newPassword: passwordField,\n})\n\nexport type AdminCreateUserInput = z.infer<typeof adminCreateUserSchema>\nexport type AdminResetPasswordInput = z.infer<typeof adminResetPasswordSchema>\nexport type SignupInput = z.infer<typeof signupSchema>\nexport type LoginInput = z.infer<typeof loginSchema>\nexport type EmailVerifyInput = z.infer<typeof emailVerifySchema>\nexport type PasswordResetRequestInput = z.infer<typeof passwordResetRequestSchema>\nexport type PasswordResetConfirmInput = z.infer<typeof passwordResetConfirmSchema>\nexport type MagicLinkRequestInput = z.infer<typeof magicLinkRequestSchema>\nexport type MagicLinkVerifyInput = z.infer<typeof magicLinkVerifySchema>\nexport type InvitationAcceptInput = z.infer<typeof invitationAcceptSchema>\nexport type ProfileUpdateInput = z.infer<typeof profileUpdateSchema>\nexport type PasswordChangeInput = z.infer<typeof passwordChangeSchema>\nexport type CreateRoleInput = z.infer<typeof createRoleSchema>\nexport type UpdateRoleInput = z.infer<typeof updateRoleSchema>\nexport type UpdateRoleAclInput = z.infer<typeof updateRoleAclSchema>\nexport type InviteUserInput = z.infer<typeof inviteUserSchema>\nexport type AssignRolesInput = z.infer<typeof assignRolesSchema>\nexport type AdminUpdateUserInput = z.infer<typeof adminUpdateUserSchema>\n"],
|
|
5
|
-
"mappings": "AAAA,SAAS,SAAS;
|
|
4
|
+
"sourcesContent": ["import { z } from 'zod'\nimport { normalizeHostname } from '@open-mercato/core/modules/customer_accounts/lib/hostname'\n\nconst emailField = z.string().email().max(255)\nconst passwordField = z.string().min(8).max(128)\nconst displayNameField = z.string().min(1).max(255)\n\nexport const signupSchema = z.object({\n email: emailField,\n password: passwordField,\n displayName: displayNameField,\n tenantId: z.string().uuid().optional(),\n organizationId: z.string().uuid().optional(),\n})\n\nexport const loginSchema = z.object({\n email: emailField,\n password: z.string().min(1).max(128),\n tenantId: z.string().uuid().optional(),\n})\n\nexport const emailVerifySchema = z.object({\n token: z.string().min(1).max(512),\n})\n\nexport const passwordResetRequestSchema = z.object({\n email: emailField,\n tenantId: z.string().uuid().optional(),\n})\n\nexport const passwordResetConfirmSchema = z.object({\n token: z.string().min(1).max(512),\n password: passwordField,\n})\n\nexport const magicLinkRequestSchema = z.object({\n email: emailField,\n tenantId: z.string().uuid().optional(),\n})\n\nexport const magicLinkVerifySchema = z.object({\n token: z.string().min(1).max(512),\n})\n\nexport const invitationAcceptSchema = z.object({\n token: z.string().min(1).max(512),\n password: passwordField,\n displayName: displayNameField,\n})\n\nexport const profileUpdateSchema = z.object({\n displayName: displayNameField.optional(),\n})\n\nexport const passwordChangeSchema = z.object({\n currentPassword: z.string().min(1).max(128),\n newPassword: passwordField,\n})\n\nexport const createRoleSchema = z.object({\n name: z.string().min(1).max(255),\n slug: z.string().min(1).max(255).regex(/^[a-z0-9_-]+$/),\n description: z.string().max(1000).optional(),\n isDefault: z.boolean().optional(),\n customerAssignable: z.boolean().optional(),\n})\n\nexport const updateRoleSchema = z.object({\n name: z.string().min(1).max(255).optional(),\n description: z.string().max(1000).optional(),\n isDefault: z.boolean().optional(),\n customerAssignable: z.boolean().optional(),\n})\n\nexport const updateRoleAclSchema = z.object({\n features: z.array(z.string().min(1).max(255)),\n isPortalAdmin: z.boolean().optional(),\n})\n\nexport const inviteUserSchema = z.object({\n email: emailField,\n customerEntityId: z.string().uuid().optional(),\n roleIds: z.array(z.string().uuid()).min(1),\n displayName: displayNameField.optional(),\n})\n\nexport const assignRolesSchema = z.object({\n roleIds: z.array(z.string().uuid()).min(1),\n})\n\nexport const adminCreateUserSchema = z.object({\n email: emailField,\n password: passwordField,\n displayName: displayNameField,\n roleIds: z.array(z.string().uuid()).optional(),\n customerEntityId: z.string().uuid().optional(),\n})\n\nexport const adminUpdateUserSchema = z.object({\n displayName: displayNameField.optional(),\n isActive: z.boolean().optional(),\n lockedUntil: z.string().datetime().nullable().optional(),\n personEntityId: z.string().uuid().nullable().optional(),\n customerEntityId: z.string().uuid().nullable().optional(),\n roleIds: z.array(z.string().uuid()).optional(),\n})\n\nexport const adminResetPasswordSchema = z.object({\n newPassword: passwordField,\n})\n\nexport type AdminCreateUserInput = z.infer<typeof adminCreateUserSchema>\nexport type AdminResetPasswordInput = z.infer<typeof adminResetPasswordSchema>\nexport type SignupInput = z.infer<typeof signupSchema>\nexport type LoginInput = z.infer<typeof loginSchema>\nexport type EmailVerifyInput = z.infer<typeof emailVerifySchema>\nexport type PasswordResetRequestInput = z.infer<typeof passwordResetRequestSchema>\nexport type PasswordResetConfirmInput = z.infer<typeof passwordResetConfirmSchema>\nexport type MagicLinkRequestInput = z.infer<typeof magicLinkRequestSchema>\nexport type MagicLinkVerifyInput = z.infer<typeof magicLinkVerifySchema>\nexport type InvitationAcceptInput = z.infer<typeof invitationAcceptSchema>\nexport type ProfileUpdateInput = z.infer<typeof profileUpdateSchema>\nexport type PasswordChangeInput = z.infer<typeof passwordChangeSchema>\nexport type CreateRoleInput = z.infer<typeof createRoleSchema>\nexport type UpdateRoleInput = z.infer<typeof updateRoleSchema>\nexport type UpdateRoleAclInput = z.infer<typeof updateRoleAclSchema>\nexport type InviteUserInput = z.infer<typeof inviteUserSchema>\nexport type AssignRolesInput = z.infer<typeof assignRolesSchema>\nexport type AdminUpdateUserInput = z.infer<typeof adminUpdateUserSchema>\n\n// Custom domain mapping\nexport const hostnameSchema = z\n .string()\n .min(1, 'Hostname is required')\n .max(512, 'Hostname is too long')\n .transform((value, ctx) => {\n try {\n return normalizeHostname(value)\n } catch (err) {\n ctx.addIssue({\n code: z.ZodIssueCode.custom,\n message: err instanceof Error ? err.message : 'Invalid hostname',\n })\n return z.NEVER\n }\n })\n\nexport const registerDomainSchema = z.object({\n hostname: hostnameSchema,\n organizationId: z.string().uuid(),\n replacesDomainId: z.string().uuid().optional(),\n})\n\nexport type RegisterDomainInput = z.infer<typeof registerDomainSchema>\n"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