@likewatt/models 1.112.0 → 1.114.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.
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { Document } from 'mongoose';
|
|
2
|
+
/**
|
|
3
|
+
* Partage d'un résultat d'optimisation à un tiers, par email (KO-778).
|
|
4
|
+
*
|
|
5
|
+
* Un document par destinataire : un envoi de N destinataires (1..5) produit N
|
|
6
|
+
* documents partageant le même `shareGroupId`. La consultation se fait sur une
|
|
7
|
+
* page publique en lecture seule via `token` (un par destinataire).
|
|
8
|
+
*
|
|
9
|
+
* - `sharedByLabel` est un snapshot (nom figé au partage) : l'historique est une
|
|
10
|
+
* trace, il doit survivre à la suppression/réassignation de l'auteur.
|
|
11
|
+
* - `token` : index UNIQUE + SPARSE — l'anonymisation le met à `null`, et
|
|
12
|
+
* plusieurs `null` violeraient une contrainte unique non-sparse.
|
|
13
|
+
* - `anonymizedAt` : flag dédié pour rendre le job de rétention idempotent
|
|
14
|
+
* (`createdAt < seuil AND anonymizedAt IS NULL`).
|
|
15
|
+
*
|
|
16
|
+
* Validation runtime : portée par les DTO côté micro-database (voir le module
|
|
17
|
+
* `result-share`). Les décorateurs class-validator ici documentent le modèle.
|
|
18
|
+
*/
|
|
19
|
+
export declare class ResultShare {
|
|
20
|
+
_id: string;
|
|
21
|
+
siteId: string;
|
|
22
|
+
scenarioId: string;
|
|
23
|
+
workspaceId: string;
|
|
24
|
+
sharedBy: string;
|
|
25
|
+
sharedByLabel: string;
|
|
26
|
+
email: string;
|
|
27
|
+
message?: string;
|
|
28
|
+
token?: string | null;
|
|
29
|
+
shareGroupId: string;
|
|
30
|
+
viewedAt?: Date | null;
|
|
31
|
+
revokedAt?: Date | null;
|
|
32
|
+
anonymizedAt?: Date | null;
|
|
33
|
+
sendCount: number;
|
|
34
|
+
lastSentAt?: Date;
|
|
35
|
+
createdAt?: Date | string;
|
|
36
|
+
updatedAt?: Date | string;
|
|
37
|
+
}
|
|
38
|
+
export type ResultShareDocument = ResultShare & Document;
|
|
39
|
+
export declare const ResultShareSchema: import("mongoose").Schema<ResultShare, import("mongoose").Model<ResultShare, any, any, any, Document<unknown, any, ResultShare, any, {}> & ResultShare & Required<{
|
|
40
|
+
_id: string;
|
|
41
|
+
}> & {
|
|
42
|
+
__v: number;
|
|
43
|
+
}, any>, {}, {}, {}, {}, import("mongoose").DefaultSchemaOptions, ResultShare, Document<unknown, {}, import("mongoose").FlatRecord<ResultShare>, {}, import("mongoose").ResolveSchemaOptions<import("mongoose").DefaultSchemaOptions>> & import("mongoose").FlatRecord<ResultShare> & Required<{
|
|
44
|
+
_id: string;
|
|
45
|
+
}> & {
|
|
46
|
+
__v: number;
|
|
47
|
+
}>;
|
|
@@ -0,0 +1,212 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.ResultShareSchema = exports.ResultShare = void 0;
|
|
13
|
+
const uuid_1 = require("uuid");
|
|
14
|
+
const swagger_1 = require("@nestjs/swagger");
|
|
15
|
+
const mongoose_1 = require("@nestjs/mongoose");
|
|
16
|
+
const class_validator_1 = require("class-validator");
|
|
17
|
+
/**
|
|
18
|
+
* Partage d'un résultat d'optimisation à un tiers, par email (KO-778).
|
|
19
|
+
*
|
|
20
|
+
* Un document par destinataire : un envoi de N destinataires (1..5) produit N
|
|
21
|
+
* documents partageant le même `shareGroupId`. La consultation se fait sur une
|
|
22
|
+
* page publique en lecture seule via `token` (un par destinataire).
|
|
23
|
+
*
|
|
24
|
+
* - `sharedByLabel` est un snapshot (nom figé au partage) : l'historique est une
|
|
25
|
+
* trace, il doit survivre à la suppression/réassignation de l'auteur.
|
|
26
|
+
* - `token` : index UNIQUE + SPARSE — l'anonymisation le met à `null`, et
|
|
27
|
+
* plusieurs `null` violeraient une contrainte unique non-sparse.
|
|
28
|
+
* - `anonymizedAt` : flag dédié pour rendre le job de rétention idempotent
|
|
29
|
+
* (`createdAt < seuil AND anonymizedAt IS NULL`).
|
|
30
|
+
*
|
|
31
|
+
* Validation runtime : portée par les DTO côté micro-database (voir le module
|
|
32
|
+
* `result-share`). Les décorateurs class-validator ici documentent le modèle.
|
|
33
|
+
*/
|
|
34
|
+
let ResultShare = class ResultShare {
|
|
35
|
+
};
|
|
36
|
+
exports.ResultShare = ResultShare;
|
|
37
|
+
__decorate([
|
|
38
|
+
(0, swagger_1.ApiProperty)({
|
|
39
|
+
description: '_id généré automatiquement (UUID v4)',
|
|
40
|
+
example: '2M61PGSm7lRpqXeaDacbAYOLTYG3',
|
|
41
|
+
}),
|
|
42
|
+
(0, mongoose_1.Prop)({
|
|
43
|
+
type: String,
|
|
44
|
+
required: true,
|
|
45
|
+
default: () => (0, uuid_1.v4)(),
|
|
46
|
+
}),
|
|
47
|
+
__metadata("design:type", String)
|
|
48
|
+
], ResultShare.prototype, "_id", void 0);
|
|
49
|
+
__decorate([
|
|
50
|
+
(0, swagger_1.ApiProperty)({
|
|
51
|
+
description: 'Site partagé (site OU collective_site)',
|
|
52
|
+
example: '2M61PGSm7lRpqXeaDacbAYOLTYG3',
|
|
53
|
+
}),
|
|
54
|
+
(0, mongoose_1.Prop)({ type: String, required: true }),
|
|
55
|
+
(0, class_validator_1.IsString)(),
|
|
56
|
+
__metadata("design:type", String)
|
|
57
|
+
], ResultShare.prototype, "siteId", void 0);
|
|
58
|
+
__decorate([
|
|
59
|
+
(0, swagger_1.ApiProperty)({
|
|
60
|
+
description: 'Scénario optimisé partagé',
|
|
61
|
+
example: '2M61PGSm7lRpqXeaDacbAYOLTYG3',
|
|
62
|
+
}),
|
|
63
|
+
(0, mongoose_1.Prop)({ type: String, required: true }),
|
|
64
|
+
(0, class_validator_1.IsString)(),
|
|
65
|
+
__metadata("design:type", String)
|
|
66
|
+
], ResultShare.prototype, "scenarioId", void 0);
|
|
67
|
+
__decorate([
|
|
68
|
+
(0, swagger_1.ApiProperty)({
|
|
69
|
+
description: 'Workspace propriétaire (scoping)',
|
|
70
|
+
example: '2M61PGSm7lRpqXeaDacbAYOLTYG3',
|
|
71
|
+
}),
|
|
72
|
+
(0, mongoose_1.Prop)({ type: String, required: true }),
|
|
73
|
+
(0, class_validator_1.IsString)(),
|
|
74
|
+
__metadata("design:type", String)
|
|
75
|
+
], ResultShare.prototype, "workspaceId", void 0);
|
|
76
|
+
__decorate([
|
|
77
|
+
(0, swagger_1.ApiProperty)({
|
|
78
|
+
description: "userId de l'auteur du partage (scoping/filtres)",
|
|
79
|
+
example: '2M61PGSm7lRpqXeaDacbAYOLTYG3',
|
|
80
|
+
}),
|
|
81
|
+
(0, mongoose_1.Prop)({ type: String, required: true }),
|
|
82
|
+
(0, class_validator_1.IsString)(),
|
|
83
|
+
__metadata("design:type", String)
|
|
84
|
+
], ResultShare.prototype, "sharedBy", void 0);
|
|
85
|
+
__decorate([
|
|
86
|
+
(0, swagger_1.ApiProperty)({
|
|
87
|
+
description: "« Prénom Nom » de l'auteur, figé au partage (fallback email si nom absent)",
|
|
88
|
+
example: 'Jean Dupont',
|
|
89
|
+
}),
|
|
90
|
+
(0, mongoose_1.Prop)({ type: String, required: true }),
|
|
91
|
+
(0, class_validator_1.IsString)(),
|
|
92
|
+
__metadata("design:type", String)
|
|
93
|
+
], ResultShare.prototype, "sharedByLabel", void 0);
|
|
94
|
+
__decorate([
|
|
95
|
+
(0, swagger_1.ApiProperty)({
|
|
96
|
+
description: 'Email du destinataire (tiers). Remplacé par une valeur anonyme après rétention.',
|
|
97
|
+
example: 'destinataire@email.com',
|
|
98
|
+
}),
|
|
99
|
+
(0, mongoose_1.Prop)({ type: String, required: true, lowercase: true }),
|
|
100
|
+
(0, class_validator_1.IsString)(),
|
|
101
|
+
__metadata("design:type", String)
|
|
102
|
+
], ResultShare.prototype, "email", void 0);
|
|
103
|
+
__decorate([
|
|
104
|
+
(0, swagger_1.ApiPropertyOptional)({
|
|
105
|
+
description: 'Message libre optionnel (≤ 1000 caractères)',
|
|
106
|
+
example: 'Voici les résultats de votre étude.',
|
|
107
|
+
}),
|
|
108
|
+
(0, mongoose_1.Prop)({ type: String, maxlength: 1000 }),
|
|
109
|
+
(0, class_validator_1.IsOptional)(),
|
|
110
|
+
(0, class_validator_1.IsString)(),
|
|
111
|
+
(0, class_validator_1.MaxLength)(1000),
|
|
112
|
+
__metadata("design:type", String)
|
|
113
|
+
], ResultShare.prototype, "message", void 0);
|
|
114
|
+
__decorate([
|
|
115
|
+
(0, swagger_1.ApiPropertyOptional)({
|
|
116
|
+
description: 'Token de consultation publique (crypto.randomBytes(32).base64url). Mis à null après anonymisation.',
|
|
117
|
+
example: 'kJh3...base64url',
|
|
118
|
+
}),
|
|
119
|
+
(0, mongoose_1.Prop)({ type: String }),
|
|
120
|
+
(0, class_validator_1.IsOptional)(),
|
|
121
|
+
(0, class_validator_1.IsString)(),
|
|
122
|
+
__metadata("design:type", Object)
|
|
123
|
+
], ResultShare.prototype, "token", void 0);
|
|
124
|
+
__decorate([
|
|
125
|
+
(0, swagger_1.ApiProperty)({
|
|
126
|
+
description: 'UUID commun à tous les destinataires d’un même envoi',
|
|
127
|
+
example: '2M61PGSm7lRpqXeaDacbAYOLTYG3',
|
|
128
|
+
}),
|
|
129
|
+
(0, mongoose_1.Prop)({ type: String, required: true }),
|
|
130
|
+
(0, class_validator_1.IsString)(),
|
|
131
|
+
__metadata("design:type", String)
|
|
132
|
+
], ResultShare.prototype, "shareGroupId", void 0);
|
|
133
|
+
__decorate([
|
|
134
|
+
(0, swagger_1.ApiPropertyOptional)({
|
|
135
|
+
description: 'Date de première consultation (posée une seule fois)',
|
|
136
|
+
example: '2026-07-24T10:00:00.000Z',
|
|
137
|
+
}),
|
|
138
|
+
(0, mongoose_1.Prop)({ type: Date, default: null }),
|
|
139
|
+
(0, class_validator_1.IsOptional)(),
|
|
140
|
+
(0, class_validator_1.IsDate)(),
|
|
141
|
+
__metadata("design:type", Object)
|
|
142
|
+
], ResultShare.prototype, "viewedAt", void 0);
|
|
143
|
+
__decorate([
|
|
144
|
+
(0, swagger_1.ApiPropertyOptional)({
|
|
145
|
+
description: 'Date de révocation (soft delete ou anonymisation)',
|
|
146
|
+
example: '2026-07-24T10:00:00.000Z',
|
|
147
|
+
}),
|
|
148
|
+
(0, mongoose_1.Prop)({ type: Date, default: null }),
|
|
149
|
+
(0, class_validator_1.IsOptional)(),
|
|
150
|
+
(0, class_validator_1.IsDate)(),
|
|
151
|
+
__metadata("design:type", Object)
|
|
152
|
+
], ResultShare.prototype, "revokedAt", void 0);
|
|
153
|
+
__decorate([
|
|
154
|
+
(0, swagger_1.ApiPropertyOptional)({
|
|
155
|
+
description: 'Date d’anonymisation RGPD (rend le job de rétention idempotent)',
|
|
156
|
+
example: '2027-07-24T04:00:00.000Z',
|
|
157
|
+
}),
|
|
158
|
+
(0, mongoose_1.Prop)({ type: Date, default: null }),
|
|
159
|
+
(0, class_validator_1.IsOptional)(),
|
|
160
|
+
(0, class_validator_1.IsDate)(),
|
|
161
|
+
__metadata("design:type", Object)
|
|
162
|
+
], ResultShare.prototype, "anonymizedAt", void 0);
|
|
163
|
+
__decorate([
|
|
164
|
+
(0, swagger_1.ApiProperty)({
|
|
165
|
+
description: 'Nombre d’envois du mail (init 1, ++ au resend)',
|
|
166
|
+
example: 1,
|
|
167
|
+
}),
|
|
168
|
+
(0, mongoose_1.Prop)({ type: Number, required: true, default: 1 }),
|
|
169
|
+
(0, class_validator_1.IsOptional)(),
|
|
170
|
+
(0, class_validator_1.IsNumber)(),
|
|
171
|
+
(0, class_validator_1.Min)(1),
|
|
172
|
+
__metadata("design:type", Number)
|
|
173
|
+
], ResultShare.prototype, "sendCount", void 0);
|
|
174
|
+
__decorate([
|
|
175
|
+
(0, swagger_1.ApiPropertyOptional)({
|
|
176
|
+
description: 'Date du dernier envoi',
|
|
177
|
+
example: '2026-07-24T10:00:00.000Z',
|
|
178
|
+
}),
|
|
179
|
+
(0, mongoose_1.Prop)({ type: Date }),
|
|
180
|
+
(0, class_validator_1.IsOptional)(),
|
|
181
|
+
(0, class_validator_1.IsDate)(),
|
|
182
|
+
__metadata("design:type", Date)
|
|
183
|
+
], ResultShare.prototype, "lastSentAt", void 0);
|
|
184
|
+
__decorate([
|
|
185
|
+
(0, swagger_1.ApiPropertyOptional)(),
|
|
186
|
+
(0, class_validator_1.IsOptional)(),
|
|
187
|
+
__metadata("design:type", Object)
|
|
188
|
+
], ResultShare.prototype, "createdAt", void 0);
|
|
189
|
+
__decorate([
|
|
190
|
+
(0, swagger_1.ApiPropertyOptional)(),
|
|
191
|
+
(0, class_validator_1.IsOptional)(),
|
|
192
|
+
__metadata("design:type", Object)
|
|
193
|
+
], ResultShare.prototype, "updatedAt", void 0);
|
|
194
|
+
exports.ResultShare = ResultShare = __decorate([
|
|
195
|
+
(0, mongoose_1.Schema)({
|
|
196
|
+
id: false,
|
|
197
|
+
timestamps: true,
|
|
198
|
+
collection: 'resultshares',
|
|
199
|
+
toJSON: { virtuals: true, versionKey: false },
|
|
200
|
+
toObject: { virtuals: true, versionKey: false },
|
|
201
|
+
})
|
|
202
|
+
], ResultShare);
|
|
203
|
+
exports.ResultShareSchema = mongoose_1.SchemaFactory.createForClass(ResultShare);
|
|
204
|
+
// token : unique + sparse (l'anonymisation met token à null → plusieurs null
|
|
205
|
+
// autorisés uniquement en sparse).
|
|
206
|
+
exports.ResultShareSchema.index({ token: 1 }, { unique: true, sparse: true });
|
|
207
|
+
// Historique d'un scénario pour un site donné, scopé au workspace.
|
|
208
|
+
exports.ResultShareSchema.index({ siteId: 1, scenarioId: 1, workspaceId: 1 });
|
|
209
|
+
// Scoping par workspace.
|
|
210
|
+
exports.ResultShareSchema.index({ workspaceId: 1 });
|
|
211
|
+
// Balayage du job de rétention (createdAt < seuil AND anonymizedAt IS NULL).
|
|
212
|
+
exports.ResultShareSchema.index({ createdAt: 1, anonymizedAt: 1 });
|
|
@@ -11,6 +11,7 @@ export declare class BatteryParams {
|
|
|
11
11
|
batteryDegradRate: number;
|
|
12
12
|
batteryLeasingLifespan: number;
|
|
13
13
|
batteryDepreciationDuration: number;
|
|
14
|
+
hybridInverter: boolean;
|
|
14
15
|
}
|
|
15
16
|
export declare const BatteryParamsSchema: import("mongoose").Schema<BatteryParams, import("mongoose").Model<BatteryParams, any, any, any, import("mongoose").Document<unknown, any, BatteryParams, any, {}> & BatteryParams & {
|
|
16
17
|
_id: import("mongoose").Types.ObjectId;
|
|
@@ -75,6 +75,11 @@ __decorate([
|
|
|
75
75
|
(0, class_validator_1.IsNumber)(),
|
|
76
76
|
__metadata("design:type", Number)
|
|
77
77
|
], BatteryParams.prototype, "batteryDepreciationDuration", void 0);
|
|
78
|
+
__decorate([
|
|
79
|
+
(0, mongoose_1.Prop)({ required: true, default: false }),
|
|
80
|
+
(0, class_validator_1.IsBoolean)(),
|
|
81
|
+
__metadata("design:type", Boolean)
|
|
82
|
+
], BatteryParams.prototype, "hybridInverter", void 0);
|
|
78
83
|
exports.BatteryParams = BatteryParams = __decorate([
|
|
79
84
|
(0, mongoose_1.Schema)({ _id: false })
|
|
80
85
|
], BatteryParams);
|
package/dist/index.d.ts
CHANGED
|
@@ -15,6 +15,7 @@ export * from './core/Leads';
|
|
|
15
15
|
export * from './core/Regex';
|
|
16
16
|
export * from './core/InfoBanner';
|
|
17
17
|
export * from './core/KoncileOcrAccess';
|
|
18
|
+
export * from './core/ResultShare';
|
|
18
19
|
export * from './core/TypeORM/analysis';
|
|
19
20
|
export * from './core/TypeORM/AuthAuditLog';
|
|
20
21
|
export * from './core/TypeORM/Co2History';
|
package/dist/index.js
CHANGED
|
@@ -33,6 +33,7 @@ __exportStar(require("./core/Leads"), exports);
|
|
|
33
33
|
__exportStar(require("./core/Regex"), exports);
|
|
34
34
|
__exportStar(require("./core/InfoBanner"), exports);
|
|
35
35
|
__exportStar(require("./core/KoncileOcrAccess"), exports);
|
|
36
|
+
__exportStar(require("./core/ResultShare"), exports);
|
|
36
37
|
// TypeORM entities
|
|
37
38
|
__exportStar(require("./core/TypeORM/analysis"), exports);
|
|
38
39
|
__exportStar(require("./core/TypeORM/AuthAuditLog"), exports);
|