@likewatt/models 1.125.1 → 1.127.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,21 @@
1
+ import { Document } from 'mongoose';
2
+ import { AssistantDeploymentMode } from './enums/AssistantDeploymentMode';
3
+ /** Identifiant du document unique de réglages de l'assistant. */
4
+ export declare const ASSISTANT_SETTINGS_ID = "default";
5
+ export type AssistantSettingsDocument = AssistantSettings & Document;
6
+ export declare class AssistantSettings {
7
+ readonly _id: string;
8
+ deploymentMode: AssistantDeploymentMode;
9
+ dailyQuota: number;
10
+ responderTimeoutSeconds: number;
11
+ updatedBy?: string | null;
12
+ }
13
+ export declare const AssistantSettingsSchema: import("mongoose").Schema<AssistantSettings, import("mongoose").Model<AssistantSettings, any, any, any, Document<unknown, any, AssistantSettings, any, {}> & AssistantSettings & Required<{
14
+ _id: string;
15
+ }> & {
16
+ __v: number;
17
+ }, any>, {}, {}, {}, {}, import("mongoose").DefaultSchemaOptions, AssistantSettings, Document<unknown, {}, import("mongoose").FlatRecord<AssistantSettings>, {}, import("mongoose").ResolveSchemaOptions<import("mongoose").DefaultSchemaOptions>> & import("mongoose").FlatRecord<AssistantSettings> & Required<{
18
+ _id: string;
19
+ }> & {
20
+ __v: number;
21
+ }>;
@@ -0,0 +1,110 @@
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.AssistantSettingsSchema = exports.AssistantSettings = exports.ASSISTANT_SETTINGS_ID = void 0;
13
+ const mongoose_1 = require("@nestjs/mongoose");
14
+ const swagger_1 = require("@nestjs/swagger");
15
+ const class_validator_1 = require("class-validator");
16
+ const AssistantDeploymentMode_1 = require("./enums/AssistantDeploymentMode");
17
+ /** Identifiant du document unique de réglages de l'assistant. */
18
+ exports.ASSISTANT_SETTINGS_ID = 'default';
19
+ const integerValidator = {
20
+ validator: (value) => Number.isInteger(value),
21
+ message: '{PATH} doit être un entier',
22
+ };
23
+ let AssistantSettings = class AssistantSettings {
24
+ };
25
+ exports.AssistantSettings = AssistantSettings;
26
+ __decorate([
27
+ (0, swagger_1.ApiProperty)({
28
+ description: 'Identifiant du document unique de réglages',
29
+ example: exports.ASSISTANT_SETTINGS_ID,
30
+ type: String,
31
+ readOnly: true,
32
+ }),
33
+ (0, mongoose_1.Prop)({ type: String }),
34
+ __metadata("design:type", String)
35
+ ], AssistantSettings.prototype, "_id", void 0);
36
+ __decorate([
37
+ (0, swagger_1.ApiProperty)({
38
+ enum: AssistantDeploymentMode_1.AssistantDeploymentMode,
39
+ example: AssistantDeploymentMode_1.AssistantDeploymentMode.ADMINS,
40
+ default: AssistantDeploymentMode_1.AssistantDeploymentMode.ADMINS,
41
+ }),
42
+ (0, mongoose_1.Prop)({
43
+ type: String,
44
+ enum: Object.values(AssistantDeploymentMode_1.AssistantDeploymentMode),
45
+ default: AssistantDeploymentMode_1.AssistantDeploymentMode.ADMINS,
46
+ }),
47
+ (0, class_validator_1.IsEnum)(AssistantDeploymentMode_1.AssistantDeploymentMode),
48
+ __metadata("design:type", String)
49
+ ], AssistantSettings.prototype, "deploymentMode", void 0);
50
+ __decorate([
51
+ (0, swagger_1.ApiProperty)({
52
+ description: 'Messages acceptés par utilisateur et par jour (heure de Paris)',
53
+ example: 30,
54
+ default: 30,
55
+ minimum: 1,
56
+ maximum: 1000,
57
+ }),
58
+ (0, mongoose_1.Prop)({
59
+ type: Number,
60
+ default: 30,
61
+ min: 1,
62
+ max: 1000,
63
+ validate: integerValidator,
64
+ }),
65
+ (0, class_validator_1.IsInt)(),
66
+ (0, class_validator_1.Min)(1),
67
+ (0, class_validator_1.Max)(1000),
68
+ __metadata("design:type", Number)
69
+ ], AssistantSettings.prototype, "dailyQuota", void 0);
70
+ __decorate([
71
+ (0, swagger_1.ApiProperty)({
72
+ description: "Délai maximal de génération d'une réponse, en secondes",
73
+ example: 10,
74
+ default: 10,
75
+ minimum: 5,
76
+ maximum: 60,
77
+ }),
78
+ (0, mongoose_1.Prop)({
79
+ type: Number,
80
+ default: 10,
81
+ min: 5,
82
+ max: 60,
83
+ validate: integerValidator,
84
+ }),
85
+ (0, class_validator_1.IsInt)(),
86
+ (0, class_validator_1.Min)(5),
87
+ (0, class_validator_1.Max)(60),
88
+ __metadata("design:type", Number)
89
+ ], AssistantSettings.prototype, "responderTimeoutSeconds", void 0);
90
+ __decorate([
91
+ (0, swagger_1.ApiPropertyOptional)({
92
+ description: "Id de l'admin auteur du dernier changement",
93
+ example: '2M61PGSm7lRpqXeaDacbAYOLTYG3',
94
+ nullable: true,
95
+ }),
96
+ (0, mongoose_1.Prop)({ type: String, default: null }),
97
+ (0, class_validator_1.IsOptional)(),
98
+ (0, class_validator_1.IsString)(),
99
+ __metadata("design:type", Object)
100
+ ], AssistantSettings.prototype, "updatedBy", void 0);
101
+ exports.AssistantSettings = AssistantSettings = __decorate([
102
+ (0, mongoose_1.Schema)({
103
+ id: false,
104
+ timestamps: true,
105
+ collection: 'assistantsettings',
106
+ toJSON: { virtuals: true, versionKey: false },
107
+ toObject: { virtuals: true, versionKey: false },
108
+ })
109
+ ], AssistantSettings);
110
+ exports.AssistantSettingsSchema = mongoose_1.SchemaFactory.createForClass(AssistantSettings);
@@ -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) {
@@ -115,6 +115,7 @@ export declare class User {
115
115
  principal: boolean;
116
116
  isWorkspaceAdmin: boolean;
117
117
  publicApi: boolean;
118
+ assistantBeta: boolean;
118
119
  principalUser?: string;
119
120
  workspaceId?: string;
120
121
  type?: string;
package/dist/core/User.js CHANGED
@@ -467,6 +467,16 @@ __decorate([
467
467
  (0, class_validator_1.IsBoolean)(),
468
468
  __metadata("design:type", Boolean)
469
469
  ], User.prototype, "publicApi", void 0);
470
+ __decorate([
471
+ (0, swagger_1.ApiProperty)({
472
+ description: 'Accès bêta à l’Assistant Optiwize (hérité par les utilisateurs enfants)',
473
+ example: false,
474
+ }),
475
+ (0, mongoose_1.Prop)({ type: Boolean, default: false }),
476
+ (0, class_validator_1.IsOptional)(),
477
+ (0, class_validator_1.IsBoolean)(),
478
+ __metadata("design:type", Boolean)
479
+ ], User.prototype, "assistantBeta", void 0);
470
480
  __decorate([
471
481
  (0, swagger_1.ApiProperty)({
472
482
  description: 'Identifiant de l’utilisateur principal (si compte secondaire)',
@@ -0,0 +1,10 @@
1
+ /** Mode de déploiement de l'Assistant Optiwize. */
2
+ export declare enum AssistantDeploymentMode {
3
+ /** Arrêt d'urgence : personne, admins compris. */
4
+ OFF = "off",
5
+ ADMINS = "admins",
6
+ /** Admins et utilisateurs en bêta (propre ou héritée du principal). */
7
+ BETA = "beta",
8
+ /** Tous les utilisateurs connectés. */
9
+ ALL = "all"
10
+ }
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.AssistantDeploymentMode = void 0;
4
+ /** Mode de déploiement de l'Assistant Optiwize. */
5
+ var AssistantDeploymentMode;
6
+ (function (AssistantDeploymentMode) {
7
+ /** Arrêt d'urgence : personne, admins compris. */
8
+ AssistantDeploymentMode["OFF"] = "off";
9
+ AssistantDeploymentMode["ADMINS"] = "admins";
10
+ /** Admins et utilisateurs en bêta (propre ou héritée du principal). */
11
+ AssistantDeploymentMode["BETA"] = "beta";
12
+ /** Tous les utilisateurs connectés. */
13
+ AssistantDeploymentMode["ALL"] = "all";
14
+ })(AssistantDeploymentMode || (exports.AssistantDeploymentMode = AssistantDeploymentMode = {}));
package/dist/index.d.ts CHANGED
@@ -14,6 +14,7 @@ export * from './core/DefaultRate';
14
14
  export * from './core/Leads';
15
15
  export * from './core/Regex';
16
16
  export * from './core/InfoBanner';
17
+ export * from './core/AssistantSettings';
17
18
  export * from './core/KoncileOcrAccess';
18
19
  export * from './core/ResultShare';
19
20
  export * from './core/AuroraAccess';
@@ -43,6 +44,7 @@ export * from './core/enums/FileType';
43
44
  export * from './core/enums/ImageryQuality';
44
45
  export * from './core/enums/RetryHint';
45
46
  export * from './core/enums/BannerSeverity';
47
+ export * from './core/enums/AssistantDeploymentMode';
46
48
  export * from './core/enums/InvoiceRatesOption';
47
49
  export * from './core/enums/InvoicePricingPeriod';
48
50
  export * from './core/enums/InvoiceNetwork';
package/dist/index.js CHANGED
@@ -32,6 +32,7 @@ __exportStar(require("./core/DefaultRate"), exports);
32
32
  __exportStar(require("./core/Leads"), exports);
33
33
  __exportStar(require("./core/Regex"), exports);
34
34
  __exportStar(require("./core/InfoBanner"), exports);
35
+ __exportStar(require("./core/AssistantSettings"), exports);
35
36
  __exportStar(require("./core/KoncileOcrAccess"), exports);
36
37
  __exportStar(require("./core/ResultShare"), exports);
37
38
  __exportStar(require("./core/AuroraAccess"), exports);
@@ -69,6 +70,7 @@ __exportStar(require("./core/enums/FileType"), exports);
69
70
  __exportStar(require("./core/enums/ImageryQuality"), exports);
70
71
  __exportStar(require("./core/enums/RetryHint"), exports);
71
72
  __exportStar(require("./core/enums/BannerSeverity"), exports);
73
+ __exportStar(require("./core/enums/AssistantDeploymentMode"), exports);
72
74
  __exportStar(require("./core/enums/InvoiceRatesOption"), exports);
73
75
  __exportStar(require("./core/enums/InvoicePricingPeriod"), exports);
74
76
  __exportStar(require("./core/enums/InvoiceNetwork"), exports);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@likewatt/models",
3
- "version": "1.125.1",
3
+ "version": "1.127.0",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "scripts": {