@likewatt/models 1.125.1 → 1.126.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.
@@ -1,4 +1,27 @@
1
1
  import { Document } from 'mongoose';
2
+ /**
3
+ * Signal anti-fraude posé sur un consentement (voir `ConsentAntiFraudService`,
4
+ * gateway). Un consentement peut en cumuler plusieurs. Seuls les contrôles
5
+ * NON bloquants produisent un flag (N1-b désactivé, N2 doublon) : les blocages
6
+ * durs (N0 jetable, N1-a adresse identique, N1-b activé) empêchent la création,
7
+ * donc n'écrivent rien.
8
+ */
9
+ export declare class ConsentFraudFlag {
10
+ level: 'N1' | 'N2';
11
+ code: string;
12
+ reason?: string;
13
+ detail?: Record<string, unknown>;
14
+ createdAt: Date;
15
+ }
16
+ export declare const ConsentFraudFlagSchema: import("mongoose").Schema<ConsentFraudFlag, import("mongoose").Model<ConsentFraudFlag, any, any, any, Document<unknown, any, ConsentFraudFlag, any, {}> & ConsentFraudFlag & {
17
+ _id: import("mongoose").Types.ObjectId;
18
+ } & {
19
+ __v: number;
20
+ }, any>, {}, {}, {}, {}, import("mongoose").DefaultSchemaOptions, ConsentFraudFlag, Document<unknown, {}, import("mongoose").FlatRecord<ConsentFraudFlag>, {}, import("mongoose").ResolveSchemaOptions<import("mongoose").DefaultSchemaOptions>> & import("mongoose").FlatRecord<ConsentFraudFlag> & {
21
+ _id: import("mongoose").Types.ObjectId;
22
+ } & {
23
+ __v: number;
24
+ }>;
2
25
  /**
3
26
  * Représente un utilisateur dans le système.
4
27
  * - @Schema/timestamps : gère createdAt et updatedAt automatiques
@@ -30,6 +53,11 @@ export declare class Consent {
30
53
  dateConsentCheck?: Date;
31
54
  pdlNotCovered?: boolean;
32
55
  flagReason?: string;
56
+ fraudFlags?: ConsentFraudFlag[];
57
+ fraudReviewStatus?: 'pending' | 'legit' | 'fraud';
58
+ fraudReviewNote?: string;
59
+ fraudReviewedBy?: string;
60
+ fraudReviewedAt?: Date;
33
61
  }
34
62
  export type ConsentDocument = Consent & Document;
35
63
  export declare const ConsentSchema: import("mongoose").Schema<Consent, import("mongoose").Model<Consent, any, any, any, Document<unknown, any, Consent, any, {}> & Consent & Required<{
@@ -9,11 +9,62 @@ var __metadata = (this && this.__metadata) || function (k, v) {
9
9
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
10
  };
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.ConsentSchema = exports.Consent = void 0;
12
+ exports.ConsentSchema = exports.Consent = exports.ConsentFraudFlagSchema = exports.ConsentFraudFlag = void 0;
13
13
  const swagger_1 = require("@nestjs/swagger");
14
14
  const mongoose_1 = require("@nestjs/mongoose");
15
15
  const class_validator_1 = require("class-validator");
16
16
  const uuid_1 = require("uuid");
17
+ /**
18
+ * Signal anti-fraude posé sur un consentement (voir `ConsentAntiFraudService`,
19
+ * gateway). Un consentement peut en cumuler plusieurs. Seuls les contrôles
20
+ * NON bloquants produisent un flag (N1-b désactivé, N2 doublon) : les blocages
21
+ * durs (N0 jetable, N1-a adresse identique, N1-b activé) empêchent la création,
22
+ * donc n'écrivent rien.
23
+ */
24
+ let ConsentFraudFlag = class ConsentFraudFlag {
25
+ };
26
+ exports.ConsentFraudFlag = ConsentFraudFlag;
27
+ __decorate([
28
+ (0, swagger_1.ApiProperty)({ description: 'Niveau anti-fraude', enum: ['N1', 'N2'] }),
29
+ (0, mongoose_1.Prop)({ type: String, enum: ['N1', 'N2'], required: true }),
30
+ (0, class_validator_1.IsIn)(['N1', 'N2']),
31
+ __metadata("design:type", String)
32
+ ], ConsentFraudFlag.prototype, "level", void 0);
33
+ __decorate([
34
+ (0, swagger_1.ApiProperty)({
35
+ description: 'Code machine du signal (filtrable en admin)',
36
+ example: 'N2_DUPLICATE_PDL',
37
+ }),
38
+ (0, mongoose_1.Prop)({ type: String, required: true }),
39
+ (0, class_validator_1.IsString)(),
40
+ __metadata("design:type", String)
41
+ ], ConsentFraudFlag.prototype, "code", void 0);
42
+ __decorate([
43
+ (0, swagger_1.ApiPropertyOptional)({ description: 'Motif lisible (suivi admin)' }),
44
+ (0, mongoose_1.Prop)({ type: String, required: false }),
45
+ (0, class_validator_1.IsOptional)(),
46
+ (0, class_validator_1.IsString)(),
47
+ __metadata("design:type", String)
48
+ ], ConsentFraudFlag.prototype, "reason", void 0);
49
+ __decorate([
50
+ (0, swagger_1.ApiPropertyOptional)({
51
+ description: 'Contexte structuré (ex. consentements en conflit pour N2)',
52
+ }),
53
+ (0, mongoose_1.Prop)({ type: Object, required: false }),
54
+ (0, class_validator_1.IsOptional)(),
55
+ (0, class_validator_1.IsObject)(),
56
+ __metadata("design:type", Object)
57
+ ], ConsentFraudFlag.prototype, "detail", void 0);
58
+ __decorate([
59
+ (0, swagger_1.ApiProperty)({ description: 'Date de pose du signal' }),
60
+ (0, mongoose_1.Prop)({ type: Date, required: true }),
61
+ (0, class_validator_1.IsDate)(),
62
+ __metadata("design:type", Date)
63
+ ], ConsentFraudFlag.prototype, "createdAt", void 0);
64
+ exports.ConsentFraudFlag = ConsentFraudFlag = __decorate([
65
+ (0, mongoose_1.Schema)({ _id: false })
66
+ ], ConsentFraudFlag);
67
+ exports.ConsentFraudFlagSchema = mongoose_1.SchemaFactory.createForClass(ConsentFraudFlag);
17
68
  /**
18
69
  * Représente un utilisateur dans le système.
19
70
  * - @Schema/timestamps : gère createdAt et updatedAt automatiques
@@ -238,6 +289,52 @@ __decorate([
238
289
  (0, class_validator_1.IsString)(),
239
290
  __metadata("design:type", String)
240
291
  ], Consent.prototype, "flagReason", void 0);
292
+ __decorate([
293
+ (0, swagger_1.ApiPropertyOptional)({
294
+ description: 'Signaux anti-fraude non bloquants (N1 désactivé, N2 doublon PDL)',
295
+ type: [ConsentFraudFlag],
296
+ }),
297
+ (0, mongoose_1.Prop)({ type: [exports.ConsentFraudFlagSchema], default: [] }),
298
+ (0, class_validator_1.IsOptional)(),
299
+ (0, class_validator_1.IsArray)(),
300
+ __metadata("design:type", Array)
301
+ ], Consent.prototype, "fraudFlags", void 0);
302
+ __decorate([
303
+ (0, swagger_1.ApiPropertyOptional)({
304
+ description: 'Statut de traitement admin des signaux anti-fraude',
305
+ enum: ['pending', 'legit', 'fraud'],
306
+ }),
307
+ (0, mongoose_1.Prop)({
308
+ type: String,
309
+ enum: ['pending', 'legit', 'fraud'],
310
+ required: false,
311
+ index: true,
312
+ }),
313
+ (0, class_validator_1.IsOptional)(),
314
+ (0, class_validator_1.IsIn)(['pending', 'legit', 'fraud']),
315
+ __metadata("design:type", String)
316
+ ], Consent.prototype, "fraudReviewStatus", void 0);
317
+ __decorate([
318
+ (0, swagger_1.ApiPropertyOptional)({ description: 'Note de traitement admin' }),
319
+ (0, mongoose_1.Prop)({ type: String, required: false }),
320
+ (0, class_validator_1.IsOptional)(),
321
+ (0, class_validator_1.IsString)(),
322
+ __metadata("design:type", String)
323
+ ], Consent.prototype, "fraudReviewNote", void 0);
324
+ __decorate([
325
+ (0, swagger_1.ApiPropertyOptional)({ description: 'Admin ayant statué (userId)' }),
326
+ (0, mongoose_1.Prop)({ type: String, required: false }),
327
+ (0, class_validator_1.IsOptional)(),
328
+ (0, class_validator_1.IsString)(),
329
+ __metadata("design:type", String)
330
+ ], Consent.prototype, "fraudReviewedBy", void 0);
331
+ __decorate([
332
+ (0, swagger_1.ApiPropertyOptional)({ description: 'Date du traitement admin' }),
333
+ (0, mongoose_1.Prop)({ type: Date, required: false }),
334
+ (0, class_validator_1.IsOptional)(),
335
+ (0, class_validator_1.IsDate)(),
336
+ __metadata("design:type", Date)
337
+ ], Consent.prototype, "fraudReviewedAt", void 0);
241
338
  exports.Consent = Consent = __decorate([
242
339
  (0, mongoose_1.Schema)({
243
340
  id: false,
@@ -249,6 +346,8 @@ exports.Consent = Consent = __decorate([
249
346
  exports.ConsentSchema = mongoose_1.SchemaFactory.createForClass(Consent);
250
347
  // Index pour la requête de couverture anti-fraude (workspace + PDL couvert)
251
348
  exports.ConsentSchema.index({ workspaceId: 1, pdls: 1 });
349
+ // Index pour la console admin de suivi anti-fraude (statut + récence)
350
+ exports.ConsentSchema.index({ fraudReviewStatus: 1, createdAt: -1 });
252
351
  // Hook pre-save pour générer automatiquement un UUID si _id n'est pas fourni
253
352
  exports.ConsentSchema.pre('save', function (next) {
254
353
  if (!this._id) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@likewatt/models",
3
- "version": "1.125.1",
3
+ "version": "1.126.0",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "scripts": {