@likewatt/models 1.1.21 → 1.1.22

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.
@@ -12,6 +12,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.ScenarioDefaultValueSchema = exports.ScenarioDefaultValue = void 0;
13
13
  const mongoose_1 = require("@nestjs/mongoose");
14
14
  const swagger_1 = require("@nestjs/swagger");
15
+ const uuid_1 = require("uuid");
15
16
  const class_validator_1 = require("class-validator");
16
17
  const default_ppa_tarif_1 = require("./internal/default-ppa-tarif");
17
18
  const power_cost_config_1 = require("./internal/power-cost-config");
@@ -37,6 +38,16 @@ const financing_type_1 = require("./internal/financing-type");
37
38
  let ScenarioDefaultValue = class ScenarioDefaultValue {
38
39
  };
39
40
  exports.ScenarioDefaultValue = ScenarioDefaultValue;
41
+ __decorate([
42
+ (0, swagger_1.ApiProperty)({
43
+ description: 'Identifiant unique (UUID ou custom string)',
44
+ example: '2M61PGSm7lRpqXeaDacbAYOLTYG3',
45
+ type: String,
46
+ readOnly: true,
47
+ }),
48
+ (0, mongoose_1.Prop)({ type: String }),
49
+ __metadata("design:type", String)
50
+ ], ScenarioDefaultValue.prototype, "_id", void 0);
40
51
  __decorate([
41
52
  (0, swagger_1.ApiProperty)({ type: default_ppa_tarif_1.DefaultPPATarif }),
42
53
  (0, mongoose_1.Prop)({ type: default_ppa_tarif_1.DefaultPPATarif, required: true }),
@@ -228,3 +239,10 @@ exports.ScenarioDefaultValue = ScenarioDefaultValue = __decorate([
228
239
  })
229
240
  ], ScenarioDefaultValue);
230
241
  exports.ScenarioDefaultValueSchema = mongoose_1.SchemaFactory.createForClass(ScenarioDefaultValue);
242
+ // Hook pre-save pour générer automatiquement un UUID si _id n'est pas fourni
243
+ exports.ScenarioDefaultValueSchema.pre('save', function (next) {
244
+ if (!this._id) {
245
+ this._id = (0, uuid_1.v4)();
246
+ }
247
+ next();
248
+ });
@@ -1,4 +1,4 @@
1
- import { Types, Document } from 'mongoose';
1
+ import { Document } from 'mongoose';
2
2
  import { SiteType, Profiles } from './internal/enums';
3
3
  import { EnergyPrice } from './internal/energy-price.model';
4
4
  import { PeakHour } from './internal/peak-hour.model';
@@ -11,7 +11,7 @@ import { ConsumptionIndexes } from './internal/consumption-indexes';
11
11
  import { EnergyPriceTempo } from './internal/energy-price-tempo.model';
12
12
  import { Tarif } from './internal/tarif';
13
13
  export declare class Site {
14
- readonly _id: Types.ObjectId;
14
+ readonly _id: string;
15
15
  id: string;
16
16
  country: string;
17
17
  energyPrices: EnergyPrice[];
@@ -39,10 +39,10 @@ export declare class Site {
39
39
  startDate: Date;
40
40
  endDate: Date;
41
41
  automaticUpdateError?: string;
42
- scenario?: Types.ObjectId;
42
+ scenario?: string;
43
43
  user: string;
44
44
  profile: Profiles;
45
- collectiveSiteId?: Types.ObjectId;
45
+ collectiveSiteId?: string;
46
46
  folder?: string;
47
47
  initialOwner: string;
48
48
  isExtractingData?: boolean;
@@ -98,11 +98,11 @@ export declare class Site {
98
98
  }
99
99
  export type SiteDocument = Site & Document;
100
100
  export declare const SiteSchema: import("mongoose").Schema<Site, import("mongoose").Model<Site, any, any, any, Document<unknown, any, Site, any, {}> & Site & Required<{
101
- _id: Types.ObjectId;
101
+ _id: string;
102
102
  }> & {
103
103
  __v: number;
104
104
  }, any>, {}, {}, {}, {}, import("mongoose").DefaultSchemaOptions, Site, Document<unknown, {}, import("mongoose").FlatRecord<Site>, {}, import("mongoose").ResolveSchemaOptions<import("mongoose").DefaultSchemaOptions>> & import("mongoose").FlatRecord<Site> & Required<{
105
- _id: Types.ObjectId;
105
+ _id: string;
106
106
  }> & {
107
107
  __v: number;
108
108
  }>;
package/dist/core/Site.js CHANGED
@@ -12,7 +12,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.SiteSchema = exports.Site = void 0;
13
13
  const mongoose_1 = require("@nestjs/mongoose");
14
14
  const swagger_1 = require("@nestjs/swagger");
15
- const mongoose_2 = require("mongoose");
15
+ const uuid_1 = require("uuid");
16
16
  const class_validator_1 = require("class-validator");
17
17
  const enums_1 = require("./internal/enums");
18
18
  const energy_price_model_1 = require("./internal/energy-price.model");
@@ -30,12 +30,13 @@ let Site = class Site {
30
30
  exports.Site = Site;
31
31
  __decorate([
32
32
  (0, swagger_1.ApiProperty)({
33
- description: 'Identifiant unique MongoDB',
33
+ description: 'Identifiant unique (UUID ou custom string)',
34
34
  example: '2M61PGSm7lRpqXeaDacbAYOLTYG3',
35
- type: mongoose_2.Types.ObjectId,
35
+ type: String,
36
36
  readOnly: true,
37
37
  }),
38
- __metadata("design:type", mongoose_2.Types.ObjectId)
38
+ (0, mongoose_1.Prop)({ type: String }),
39
+ __metadata("design:type", String)
39
40
  ], Site.prototype, "_id", void 0);
40
41
  __decorate([
41
42
  (0, swagger_1.ApiProperty)({
@@ -205,9 +206,9 @@ __decorate([
205
206
  ], Site.prototype, "automaticUpdateError", void 0);
206
207
  __decorate([
207
208
  (0, swagger_1.ApiPropertyOptional)(),
208
- (0, mongoose_1.Prop)({ type: mongoose_2.Types.ObjectId, ref: 'Scenario' }),
209
+ (0, mongoose_1.Prop)({ type: String, ref: 'Scenario' }),
209
210
  (0, class_validator_1.IsOptional)(),
210
- __metadata("design:type", mongoose_2.Types.ObjectId)
211
+ __metadata("design:type", String)
211
212
  ], Site.prototype, "scenario", void 0);
212
213
  __decorate([
213
214
  (0, swagger_1.ApiProperty)(),
@@ -223,9 +224,9 @@ __decorate([
223
224
  ], Site.prototype, "profile", void 0);
224
225
  __decorate([
225
226
  (0, swagger_1.ApiPropertyOptional)(),
226
- (0, mongoose_1.Prop)({ type: mongoose_2.Types.ObjectId, ref: 'CollectiveSite' }),
227
+ (0, mongoose_1.Prop)({ type: String, ref: 'CollectiveSite' }),
227
228
  (0, class_validator_1.IsOptional)(),
228
- __metadata("design:type", mongoose_2.Types.ObjectId)
229
+ __metadata("design:type", String)
229
230
  ], Site.prototype, "collectiveSiteId", void 0);
230
231
  __decorate([
231
232
  (0, swagger_1.ApiPropertyOptional)(),
@@ -548,3 +549,10 @@ exports.Site = Site = __decorate([
548
549
  })
549
550
  ], Site);
550
551
  exports.SiteSchema = mongoose_1.SchemaFactory.createForClass(Site);
552
+ // Hook pre-save pour générer automatiquement un UUID si _id n'est pas fourni
553
+ exports.SiteSchema.pre('save', function (next) {
554
+ if (!this._id) {
555
+ this._id = (0, uuid_1.v4)();
556
+ }
557
+ next();
558
+ });
@@ -1,4 +1,4 @@
1
- import { Document, Types } from 'mongoose';
1
+ import { Document } from 'mongoose';
2
2
  import { Folder } from './internal/folder.model';
3
3
  import { ManagerLicenses } from './internal/manager-licenses';
4
4
  /**
@@ -9,11 +9,11 @@ export declare class SiteTag {
9
9
  hasConsumerPlusTag: boolean;
10
10
  }
11
11
  export declare const SiteTagSchema: import("mongoose").Schema<SiteTag, import("mongoose").Model<SiteTag, any, any, any, Document<unknown, any, SiteTag, any, {}> & SiteTag & {
12
- _id: Types.ObjectId;
12
+ _id: import("mongoose").Types.ObjectId;
13
13
  } & {
14
14
  __v: number;
15
15
  }, any>, {}, {}, {}, {}, import("mongoose").DefaultSchemaOptions, SiteTag, Document<unknown, {}, import("mongoose").FlatRecord<SiteTag>, {}, import("mongoose").ResolveSchemaOptions<import("mongoose").DefaultSchemaOptions>> & import("mongoose").FlatRecord<SiteTag> & {
16
- _id: Types.ObjectId;
16
+ _id: import("mongoose").Types.ObjectId;
17
17
  } & {
18
18
  __v: number;
19
19
  }>;
@@ -22,11 +22,11 @@ export declare class Rights {
22
22
  deleteSites: boolean;
23
23
  }
24
24
  export declare const RightsSchema: import("mongoose").Schema<Rights, import("mongoose").Model<Rights, any, any, any, Document<unknown, any, Rights, any, {}> & Rights & {
25
- _id: Types.ObjectId;
25
+ _id: import("mongoose").Types.ObjectId;
26
26
  } & {
27
27
  __v: number;
28
28
  }, any>, {}, {}, {}, {}, import("mongoose").DefaultSchemaOptions, Rights, Document<unknown, {}, import("mongoose").FlatRecord<Rights>, {}, import("mongoose").ResolveSchemaOptions<import("mongoose").DefaultSchemaOptions>> & import("mongoose").FlatRecord<Rights> & {
29
- _id: Types.ObjectId;
29
+ _id: import("mongoose").Types.ObjectId;
30
30
  } & {
31
31
  __v: number;
32
32
  }>;
@@ -35,11 +35,11 @@ export declare class tokenData {
35
35
  resetPasswordExpires: Date;
36
36
  }
37
37
  export declare const tokenDataSchema: import("mongoose").Schema<tokenData, import("mongoose").Model<tokenData, any, any, any, Document<unknown, any, tokenData, any, {}> & tokenData & {
38
- _id: Types.ObjectId;
38
+ _id: import("mongoose").Types.ObjectId;
39
39
  } & {
40
40
  __v: number;
41
41
  }, any>, {}, {}, {}, {}, import("mongoose").DefaultSchemaOptions, tokenData, Document<unknown, {}, import("mongoose").FlatRecord<tokenData>, {}, import("mongoose").ResolveSchemaOptions<import("mongoose").DefaultSchemaOptions>> & import("mongoose").FlatRecord<tokenData> & {
42
- _id: Types.ObjectId;
42
+ _id: import("mongoose").Types.ObjectId;
43
43
  } & {
44
44
  __v: number;
45
45
  }>;
@@ -49,11 +49,11 @@ export declare class WebhookParams {
49
49
  apiKey?: string;
50
50
  }
51
51
  export declare const WebhookParamsSchema: import("mongoose").Schema<WebhookParams, import("mongoose").Model<WebhookParams, any, any, any, Document<unknown, any, WebhookParams, any, {}> & WebhookParams & {
52
- _id: Types.ObjectId;
52
+ _id: import("mongoose").Types.ObjectId;
53
53
  } & {
54
54
  __v: number;
55
55
  }, any>, {}, {}, {}, {}, import("mongoose").DefaultSchemaOptions, WebhookParams, Document<unknown, {}, import("mongoose").FlatRecord<WebhookParams>, {}, import("mongoose").ResolveSchemaOptions<import("mongoose").DefaultSchemaOptions>> & import("mongoose").FlatRecord<WebhookParams> & {
56
- _id: Types.ObjectId;
56
+ _id: import("mongoose").Types.ObjectId;
57
57
  } & {
58
58
  __v: number;
59
59
  }>;
@@ -65,7 +65,7 @@ export declare const WebhookParamsSchema: import("mongoose").Schema<WebhookParam
65
65
  * - class-validator rules : validation runtime
66
66
  */
67
67
  export declare class User {
68
- _id: Types.ObjectId;
68
+ _id: string;
69
69
  email: string;
70
70
  password: string;
71
71
  firstname: string;
@@ -118,11 +118,11 @@ export declare class User {
118
118
  }
119
119
  export type UserDocument = User & Document;
120
120
  export declare const UserSchema: import("mongoose").Schema<User, import("mongoose").Model<User, any, any, any, Document<unknown, any, User, any, {}> & User & Required<{
121
- _id: Types.ObjectId;
121
+ _id: string;
122
122
  }> & {
123
123
  __v: number;
124
124
  }, any>, {}, {}, {}, {}, import("mongoose").DefaultSchemaOptions, User, Document<unknown, {}, import("mongoose").FlatRecord<User>, {}, import("mongoose").ResolveSchemaOptions<import("mongoose").DefaultSchemaOptions>> & import("mongoose").FlatRecord<User> & Required<{
125
- _id: Types.ObjectId;
125
+ _id: string;
126
126
  }> & {
127
127
  __v: number;
128
128
  }>;