@likewatt/models 1.11.2 → 1.13.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,38 +1,56 @@
1
1
  import { Document } from 'mongoose';
2
- /**
3
- * Sous-schéma pour la configuration des Leads
4
- */
5
- export declare class LeadsConfig {
6
- logo?: string;
7
- backgroundImage?: string;
8
- color?: string;
2
+ import { AuthMode } from './enums/LeadsAuthMode';
3
+ export type LeadWidgetTenantDocument = LeadWidgetTenant & Document;
4
+ export declare class LeadThemeConfig {
5
+ logoUrl?: string;
6
+ backgroundImageUrl?: string;
7
+ primaryColor?: string;
9
8
  }
10
- export declare const LeadsConfigSchema: import("mongoose").Schema<LeadsConfig, import("mongoose").Model<LeadsConfig, any, any, any, Document<unknown, any, LeadsConfig, any, {}> & LeadsConfig & {
9
+ export declare const LeadThemeConfigSchema: import("mongoose").Schema<LeadThemeConfig, import("mongoose").Model<LeadThemeConfig, any, any, any, Document<unknown, any, LeadThemeConfig, any, {}> & LeadThemeConfig & {
11
10
  _id: import("mongoose").Types.ObjectId;
12
11
  } & {
13
12
  __v: number;
14
- }, any>, {}, {}, {}, {}, import("mongoose").DefaultSchemaOptions, LeadsConfig, Document<unknown, {}, import("mongoose").FlatRecord<LeadsConfig>, {}, import("mongoose").ResolveSchemaOptions<import("mongoose").DefaultSchemaOptions>> & import("mongoose").FlatRecord<LeadsConfig> & {
13
+ }, any>, {}, {}, {}, {}, import("mongoose").DefaultSchemaOptions, LeadThemeConfig, Document<unknown, {}, import("mongoose").FlatRecord<LeadThemeConfig>, {}, import("mongoose").ResolveSchemaOptions<import("mongoose").DefaultSchemaOptions>> & import("mongoose").FlatRecord<LeadThemeConfig> & {
15
14
  _id: import("mongoose").Types.ObjectId;
16
15
  } & {
17
16
  __v: number;
18
17
  }>;
19
- /**
20
- * Schéma pour les Leads
21
- */
22
- export declare class Leads {
18
+ export declare class LeadAuthConfig {
19
+ mode: AuthMode;
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
+ apiPasswordEncryptedOrSecretRef?: string;
27
+ apiTokenHash?: string;
28
+ }
29
+ export declare const LeadAuthConfigSchema: import("mongoose").Schema<LeadAuthConfig, import("mongoose").Model<LeadAuthConfig, any, any, any, Document<unknown, any, LeadAuthConfig, any, {}> & LeadAuthConfig & {
30
+ _id: import("mongoose").Types.ObjectId;
31
+ } & {
32
+ __v: number;
33
+ }, any>, {}, {}, {}, {}, import("mongoose").DefaultSchemaOptions, LeadAuthConfig, Document<unknown, {}, import("mongoose").FlatRecord<LeadAuthConfig>, {}, import("mongoose").ResolveSchemaOptions<import("mongoose").DefaultSchemaOptions>> & import("mongoose").FlatRecord<LeadAuthConfig> & {
34
+ _id: import("mongoose").Types.ObjectId;
35
+ } & {
36
+ __v: number;
37
+ }>;
38
+ export declare class LeadWidgetTenant {
23
39
  _id: string;
24
- userId: string;
25
- url: string;
26
- defaultScenarios: string[];
27
- config?: LeadsConfig;
40
+ tenantId: string;
41
+ urlOriginal: string;
42
+ urlCanonical: string;
43
+ auth: LeadAuthConfig;
44
+ defaultScenarioIds: string[];
45
+ theme?: LeadThemeConfig;
46
+ isActive: boolean;
28
47
  }
29
- export declare const LeadsSchema: import("mongoose").Schema<Leads, import("mongoose").Model<Leads, any, any, any, Document<unknown, any, Leads, any, {}> & Leads & Required<{
48
+ export declare const LeadWidgetTenantSchema: import("mongoose").Schema<LeadWidgetTenant, import("mongoose").Model<LeadWidgetTenant, any, any, any, Document<unknown, any, LeadWidgetTenant, any, {}> & LeadWidgetTenant & Required<{
30
49
  _id: string;
31
50
  }> & {
32
51
  __v: number;
33
- }, any>, {}, {}, {}, {}, import("mongoose").DefaultSchemaOptions, Leads, Document<unknown, {}, import("mongoose").FlatRecord<Leads>, {}, import("mongoose").ResolveSchemaOptions<import("mongoose").DefaultSchemaOptions>> & import("mongoose").FlatRecord<Leads> & Required<{
52
+ }, any>, {}, {}, {}, {}, import("mongoose").DefaultSchemaOptions, LeadWidgetTenant, Document<unknown, {}, import("mongoose").FlatRecord<LeadWidgetTenant>, {}, import("mongoose").ResolveSchemaOptions<import("mongoose").DefaultSchemaOptions>> & import("mongoose").FlatRecord<LeadWidgetTenant> & Required<{
34
53
  _id: string;
35
54
  }> & {
36
55
  __v: number;
37
56
  }>;
38
- export type LeadsDocument = Leads & Document;
@@ -9,63 +9,59 @@ 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.LeadsSchema = exports.Leads = exports.LeadsConfigSchema = exports.LeadsConfig = void 0;
12
+ exports.LeadWidgetTenantSchema = exports.LeadWidgetTenant = exports.LeadAuthConfigSchema = exports.LeadAuthConfig = exports.LeadThemeConfigSchema = exports.LeadThemeConfig = void 0;
13
13
  const mongoose_1 = require("@nestjs/mongoose");
14
- const swagger_1 = require("@nestjs/swagger");
15
14
  const uuid_1 = require("uuid");
16
- const class_validator_1 = require("class-validator");
17
- /**
18
- * Sous-schéma pour la configuration des Leads
19
- */
20
- let LeadsConfig = class LeadsConfig {
15
+ const LeadsAuthMode_1 = require("./enums/LeadsAuthMode");
16
+ let LeadThemeConfig = class LeadThemeConfig {
21
17
  };
22
- exports.LeadsConfig = LeadsConfig;
18
+ exports.LeadThemeConfig = LeadThemeConfig;
23
19
  __decorate([
24
- (0, swagger_1.ApiPropertyOptional)({
25
- description: 'URL du logo',
26
- example: 'https://example.com/logo.png',
27
- }),
28
- (0, mongoose_1.Prop)({ type: String, required: false }),
29
- (0, class_validator_1.IsString)(),
30
- (0, class_validator_1.IsOptional)(),
20
+ (0, mongoose_1.Prop)({ type: String }),
31
21
  __metadata("design:type", String)
32
- ], LeadsConfig.prototype, "logo", void 0);
22
+ ], LeadThemeConfig.prototype, "logoUrl", void 0);
33
23
  __decorate([
34
- (0, swagger_1.ApiPropertyOptional)({
35
- description: "URL de l'image de fond",
36
- example: 'https://example.com/background.jpg',
37
- }),
38
- (0, mongoose_1.Prop)({ type: String, required: false }),
39
- (0, class_validator_1.IsString)(),
40
- (0, class_validator_1.IsOptional)(),
24
+ (0, mongoose_1.Prop)({ type: String }),
41
25
  __metadata("design:type", String)
42
- ], LeadsConfig.prototype, "backgroundImage", void 0);
26
+ ], LeadThemeConfig.prototype, "backgroundImageUrl", void 0);
43
27
  __decorate([
44
- (0, swagger_1.ApiPropertyOptional)({
45
- description: 'Couleur principale (format hex)',
46
- example: '#3498db',
28
+ (0, mongoose_1.Prop)({
29
+ type: String,
30
+ match: /^#([0-9a-fA-F]{3}|[0-9a-fA-F]{6})$/,
47
31
  }),
48
- (0, mongoose_1.Prop)({ type: String, required: false }),
49
- (0, class_validator_1.IsString)(),
50
- (0, class_validator_1.IsOptional)(),
51
32
  __metadata("design:type", String)
52
- ], LeadsConfig.prototype, "color", void 0);
53
- exports.LeadsConfig = LeadsConfig = __decorate([
33
+ ], LeadThemeConfig.prototype, "primaryColor", void 0);
34
+ exports.LeadThemeConfig = LeadThemeConfig = __decorate([
54
35
  (0, mongoose_1.Schema)({ _id: false })
55
- ], LeadsConfig);
56
- exports.LeadsConfigSchema = mongoose_1.SchemaFactory.createForClass(LeadsConfig);
57
- /**
58
- * Schéma pour les Leads
59
- */
60
- let Leads = class Leads {
36
+ ], LeadThemeConfig);
37
+ exports.LeadThemeConfigSchema = mongoose_1.SchemaFactory.createForClass(LeadThemeConfig);
38
+ let LeadAuthConfig = class LeadAuthConfig {
61
39
  };
62
- exports.Leads = Leads;
40
+ exports.LeadAuthConfig = LeadAuthConfig;
41
+ __decorate([
42
+ (0, mongoose_1.Prop)({ type: String, enum: LeadsAuthMode_1.AuthMode, required: true }),
43
+ __metadata("design:type", String)
44
+ ], LeadAuthConfig.prototype, "mode", void 0);
45
+ __decorate([
46
+ (0, mongoose_1.Prop)({ type: String }),
47
+ __metadata("design:type", String)
48
+ ], LeadAuthConfig.prototype, "apiLogin", void 0);
49
+ __decorate([
50
+ (0, mongoose_1.Prop)({ type: String }),
51
+ __metadata("design:type", String)
52
+ ], LeadAuthConfig.prototype, "apiPasswordEncryptedOrSecretRef", void 0);
53
+ __decorate([
54
+ (0, mongoose_1.Prop)({ type: String }),
55
+ __metadata("design:type", String)
56
+ ], LeadAuthConfig.prototype, "apiTokenHash", void 0);
57
+ exports.LeadAuthConfig = LeadAuthConfig = __decorate([
58
+ (0, mongoose_1.Schema)({ _id: false })
59
+ ], LeadAuthConfig);
60
+ exports.LeadAuthConfigSchema = mongoose_1.SchemaFactory.createForClass(LeadAuthConfig);
61
+ let LeadWidgetTenant = class LeadWidgetTenant {
62
+ };
63
+ exports.LeadWidgetTenant = LeadWidgetTenant;
63
64
  __decorate([
64
- (0, swagger_1.ApiProperty)({
65
- description: 'Identifiant unique (UUID)',
66
- example: '550e8400-e29b-41d4-a716-446655440000',
67
- type: String,
68
- }),
69
65
  (0, mongoose_1.Prop)({
70
66
  type: String,
71
67
  unique: true,
@@ -73,58 +69,42 @@ __decorate([
73
69
  index: true,
74
70
  default: () => (0, uuid_1.v4)(),
75
71
  }),
76
- (0, class_validator_1.IsString)(),
77
72
  __metadata("design:type", String)
78
- ], Leads.prototype, "_id", void 0);
73
+ ], LeadWidgetTenant.prototype, "_id", void 0);
79
74
  __decorate([
80
- (0, swagger_1.ApiProperty)({
81
- description: "Identifiant de l'utilisateur propriétaire",
82
- example: '2M61PGSm7lRpqXeaDacbAYOLTYG3',
83
- }),
84
75
  (0, mongoose_1.Prop)({ type: String, required: true, index: true }),
85
- (0, class_validator_1.IsString)(),
86
76
  __metadata("design:type", String)
87
- ], Leads.prototype, "userId", void 0);
77
+ ], LeadWidgetTenant.prototype, "tenantId", void 0);
88
78
  __decorate([
89
- (0, swagger_1.ApiProperty)({
90
- description: 'URL leads',
91
- example: 'https://likewatt.autoconsommation.eu',
92
- }),
93
79
  (0, mongoose_1.Prop)({ type: String, required: true }),
94
- (0, class_validator_1.IsString)(),
95
80
  __metadata("design:type", String)
96
- ], Leads.prototype, "url", void 0);
81
+ ], LeadWidgetTenant.prototype, "urlOriginal", void 0);
82
+ __decorate([
83
+ (0, mongoose_1.Prop)({ type: String, required: true, unique: true, index: true }),
84
+ __metadata("design:type", String)
85
+ ], LeadWidgetTenant.prototype, "urlCanonical", void 0);
86
+ __decorate([
87
+ (0, mongoose_1.Prop)({ type: exports.LeadAuthConfigSchema, required: true }),
88
+ __metadata("design:type", LeadAuthConfig)
89
+ ], LeadWidgetTenant.prototype, "auth", void 0);
97
90
  __decorate([
98
- (0, swagger_1.ApiProperty)({
99
- description: 'Tableau des identifiants de scénarios par défaut',
100
- example: [
101
- '550e8400-e29b-41d4-a716-446655440001',
102
- '550e8400-e29b-41d4-a716-446655440002',
103
- '550e8400-e29b-41d4-a716-446655440003',
104
- ],
105
- type: [String],
106
- }),
107
91
  (0, mongoose_1.Prop)({ type: [String], default: [] }),
108
- (0, class_validator_1.IsArray)(),
109
- (0, class_validator_1.IsString)({ each: true }),
110
92
  __metadata("design:type", Array)
111
- ], Leads.prototype, "defaultScenarios", void 0);
93
+ ], LeadWidgetTenant.prototype, "defaultScenarioIds", void 0);
112
94
  __decorate([
113
- (0, swagger_1.ApiPropertyOptional)({
114
- description: 'Configuration visuelle des leads',
115
- type: LeadsConfig,
116
- }),
117
- (0, mongoose_1.Prop)({ type: exports.LeadsConfigSchema, required: false }),
118
- (0, class_validator_1.IsObject)(),
119
- (0, class_validator_1.IsOptional)(),
120
- __metadata("design:type", LeadsConfig)
121
- ], Leads.prototype, "config", void 0);
122
- exports.Leads = Leads = __decorate([
95
+ (0, mongoose_1.Prop)({ type: exports.LeadThemeConfigSchema }),
96
+ __metadata("design:type", LeadThemeConfig)
97
+ ], LeadWidgetTenant.prototype, "theme", void 0);
98
+ __decorate([
99
+ (0, mongoose_1.Prop)({ type: Boolean, default: true, index: true }),
100
+ __metadata("design:type", Boolean)
101
+ ], LeadWidgetTenant.prototype, "isActive", void 0);
102
+ exports.LeadWidgetTenant = LeadWidgetTenant = __decorate([
123
103
  (0, mongoose_1.Schema)({
124
104
  id: false,
125
105
  timestamps: true,
126
106
  toJSON: { virtuals: true, versionKey: false },
127
107
  toObject: { virtuals: true, versionKey: false },
128
108
  })
129
- ], Leads);
130
- exports.LeadsSchema = mongoose_1.SchemaFactory.createForClass(Leads);
109
+ ], LeadWidgetTenant);
110
+ exports.LeadWidgetTenantSchema = mongoose_1.SchemaFactory.createForClass(LeadWidgetTenant);
@@ -0,0 +1,4 @@
1
+ export declare enum AuthMode {
2
+ V1_LOGIN_PASSWORD = "v1_login_password",
3
+ V2_TOKEN = "v2_token"
4
+ }
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.AuthMode = void 0;
4
+ var AuthMode;
5
+ (function (AuthMode) {
6
+ AuthMode["V1_LOGIN_PASSWORD"] = "v1_login_password";
7
+ AuthMode["V2_TOKEN"] = "v2_token";
8
+ })(AuthMode || (exports.AuthMode = AuthMode = {}));
package/dist/index.d.ts CHANGED
@@ -27,6 +27,7 @@ export * from './core/internal/enums';
27
27
  export * from './core/enums/BuildingDataStatus';
28
28
  export * from './core/enums/FileType';
29
29
  export * from './core/enums/ImageryQuality';
30
+ export * from './core/enums/LeadsAuthMode';
30
31
  export * from './core/internal/battery-params';
31
32
  export * from './core/internal/bounding-box';
32
33
  export * from './core/internal/building-data';
package/dist/index.js CHANGED
@@ -50,6 +50,7 @@ __exportStar(require("./core/internal/enums"), exports);
50
50
  __exportStar(require("./core/enums/BuildingDataStatus"), exports);
51
51
  __exportStar(require("./core/enums/FileType"), exports);
52
52
  __exportStar(require("./core/enums/ImageryQuality"), exports);
53
+ __exportStar(require("./core/enums/LeadsAuthMode"), exports);
53
54
  // Sub-models
54
55
  __exportStar(require("./core/internal/battery-params"), exports);
55
56
  __exportStar(require("./core/internal/bounding-box"), exports);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@likewatt/models",
3
- "version": "1.11.2",
3
+ "version": "1.13.0",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "scripts": {