@likewatt/models 1.13.0 → 1.14.0
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/dist/core/Leads.d.ts +2 -7
- package/dist/core/Leads.js +24 -8
- package/package.json +1 -1
package/dist/core/Leads.d.ts
CHANGED
|
@@ -18,11 +18,6 @@ export declare const LeadThemeConfigSchema: import("mongoose").Schema<LeadThemeC
|
|
|
18
18
|
export declare class LeadAuthConfig {
|
|
19
19
|
mode: AuthMode;
|
|
20
20
|
apiLogin?: string;
|
|
21
|
-
/**
|
|
22
|
-
* IMPORTANT :
|
|
23
|
-
* - si tu dois réutiliser le secret vers un service externe => chiffrement ou secretRef, PAS un hash
|
|
24
|
-
* - si tu compares localement => hash ok, mais c’est atypique ici
|
|
25
|
-
*/
|
|
26
21
|
apiPasswordEncryptedOrSecretRef?: string;
|
|
27
22
|
apiTokenHash?: string;
|
|
28
23
|
}
|
|
@@ -38,8 +33,8 @@ export declare const LeadAuthConfigSchema: import("mongoose").Schema<LeadAuthCon
|
|
|
38
33
|
export declare class LeadWidgetTenant {
|
|
39
34
|
_id: string;
|
|
40
35
|
tenantId: string;
|
|
41
|
-
|
|
42
|
-
|
|
36
|
+
subdomain: string;
|
|
37
|
+
domain: string;
|
|
43
38
|
auth: LeadAuthConfig;
|
|
44
39
|
defaultScenarioIds: string[];
|
|
45
40
|
theme?: LeadThemeConfig;
|
package/dist/core/Leads.js
CHANGED
|
@@ -13,6 +13,7 @@ exports.LeadWidgetTenantSchema = exports.LeadWidgetTenant = exports.LeadAuthConf
|
|
|
13
13
|
const mongoose_1 = require("@nestjs/mongoose");
|
|
14
14
|
const uuid_1 = require("uuid");
|
|
15
15
|
const LeadsAuthMode_1 = require("./enums/LeadsAuthMode");
|
|
16
|
+
const SUBDOMAIN_REGEX = /^(?!-)[a-z0-9-]{1,63}(?<!-)$/;
|
|
16
17
|
let LeadThemeConfig = class LeadThemeConfig {
|
|
17
18
|
};
|
|
18
19
|
exports.LeadThemeConfig = LeadThemeConfig;
|
|
@@ -25,10 +26,7 @@ __decorate([
|
|
|
25
26
|
__metadata("design:type", String)
|
|
26
27
|
], LeadThemeConfig.prototype, "backgroundImageUrl", void 0);
|
|
27
28
|
__decorate([
|
|
28
|
-
(0, mongoose_1.Prop)({
|
|
29
|
-
type: String,
|
|
30
|
-
match: /^#([0-9a-fA-F]{3}|[0-9a-fA-F]{6})$/,
|
|
31
|
-
}),
|
|
29
|
+
(0, mongoose_1.Prop)({ type: String, match: /^#([0-9a-fA-F]{3}|[0-9a-fA-F]{6})$/ }),
|
|
32
30
|
__metadata("design:type", String)
|
|
33
31
|
], LeadThemeConfig.prototype, "primaryColor", void 0);
|
|
34
32
|
exports.LeadThemeConfig = LeadThemeConfig = __decorate([
|
|
@@ -76,13 +74,25 @@ __decorate([
|
|
|
76
74
|
__metadata("design:type", String)
|
|
77
75
|
], LeadWidgetTenant.prototype, "tenantId", void 0);
|
|
78
76
|
__decorate([
|
|
79
|
-
(0, mongoose_1.Prop)({
|
|
77
|
+
(0, mongoose_1.Prop)({
|
|
78
|
+
type: String,
|
|
79
|
+
required: true,
|
|
80
|
+
lowercase: true,
|
|
81
|
+
trim: true,
|
|
82
|
+
match: SUBDOMAIN_REGEX,
|
|
83
|
+
}),
|
|
80
84
|
__metadata("design:type", String)
|
|
81
|
-
], LeadWidgetTenant.prototype, "
|
|
85
|
+
], LeadWidgetTenant.prototype, "subdomain", void 0);
|
|
82
86
|
__decorate([
|
|
83
|
-
(0, mongoose_1.Prop)({
|
|
87
|
+
(0, mongoose_1.Prop)({
|
|
88
|
+
type: String,
|
|
89
|
+
required: true,
|
|
90
|
+
lowercase: true,
|
|
91
|
+
trim: true,
|
|
92
|
+
default: 'autoconsommation.eu',
|
|
93
|
+
}),
|
|
84
94
|
__metadata("design:type", String)
|
|
85
|
-
], LeadWidgetTenant.prototype, "
|
|
95
|
+
], LeadWidgetTenant.prototype, "domain", void 0);
|
|
86
96
|
__decorate([
|
|
87
97
|
(0, mongoose_1.Prop)({ type: exports.LeadAuthConfigSchema, required: true }),
|
|
88
98
|
__metadata("design:type", LeadAuthConfig)
|
|
@@ -108,3 +118,9 @@ exports.LeadWidgetTenant = LeadWidgetTenant = __decorate([
|
|
|
108
118
|
})
|
|
109
119
|
], LeadWidgetTenant);
|
|
110
120
|
exports.LeadWidgetTenantSchema = mongoose_1.SchemaFactory.createForClass(LeadWidgetTenant);
|
|
121
|
+
// Index composé : un subdomain unique par domaine
|
|
122
|
+
exports.LeadWidgetTenantSchema.index({ domain: 1, subdomain: 1 }, { unique: true });
|
|
123
|
+
// Virtuel : URL publique dérivée
|
|
124
|
+
exports.LeadWidgetTenantSchema.virtual('publicBaseUrl').get(function () {
|
|
125
|
+
return `https://${this.subdomain}.${this.domain}`;
|
|
126
|
+
});
|