@likewatt/models 1.0.104 → 1.1.1
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.
- package/README.md +118 -5
- package/dist/core/DefaultRate.d.ts +26 -0
- package/dist/core/DefaultRate.js +67 -0
- package/package.json +10 -2
package/README.md
CHANGED
|
@@ -1,9 +1,122 @@
|
|
|
1
1
|
# @likewatt/models
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
Package privé contenant les modèles TypeScript partagés pour les applications Likewatt.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @likewatt/models
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Description
|
|
12
|
+
|
|
13
|
+
Ce package exporte les modèles de données TypeScript utilisés dans l'écosystème Likewatt, incluant :
|
|
14
|
+
|
|
15
|
+
- **Entités principales** : `Site`, `Scenario`, `User`, `License`, `CollectiveSite`, `Invitation`, `ScenarioDefaultValue`
|
|
16
|
+
- **Entités TypeORM** : `Analysis`, `Optimization`, `WebhookOutput`, historiques (Co2, Enedis, FCR, Okwind, Pvgis, Spot, Tempo)
|
|
17
|
+
- **Modèles internes** : Paramètres énergétiques (batteries, PV, éolien, hydrogène, stockage thermique, etc.)
|
|
18
|
+
- **Types frontend** : Types TypeScript pour l'interface utilisateur
|
|
19
|
+
- **Énumérations** : Types énumérés partagés
|
|
20
|
+
|
|
21
|
+
## Structure
|
|
22
|
+
|
|
23
|
+
- `src/core/` : Entités principales et modèles internes
|
|
24
|
+
- `src/frontend/` : Types TypeScript pour le frontend
|
|
25
|
+
- `dist/` : Build compilé (CommonJS)
|
|
26
|
+
|
|
27
|
+
## Technologies
|
|
28
|
+
|
|
29
|
+
- TypeScript 5.x
|
|
30
|
+
- TypeORM 0.3.x
|
|
31
|
+
- Mongoose 8.x
|
|
32
|
+
- NestJS decorators (Swagger, Mongoose)
|
|
33
|
+
- Class Validator
|
|
34
|
+
|
|
35
|
+
## Scripts disponibles
|
|
36
|
+
|
|
37
|
+
```bash
|
|
38
|
+
npm run build # Compile le projet TypeScript
|
|
39
|
+
npm run format # Formate le code avec Prettier
|
|
40
|
+
npm run lint # Lint et fixe le code avec ESLint
|
|
41
|
+
npm run lint:quick # Lint sans auto-fix
|
|
42
|
+
npm run release # Crée une release automatique (conventional commits)
|
|
43
|
+
npm run release:minor # Crée une release minor
|
|
44
|
+
npm run release:major # Crée une release major
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
## Convention de commit
|
|
48
|
+
|
|
49
|
+
Le projet utilise **Husky** et **Commitlint** pour enforcer les conventions de commit.
|
|
50
|
+
|
|
51
|
+
### Format requis
|
|
52
|
+
|
|
53
|
+
```
|
|
54
|
+
<type>(<scope>): <subject>
|
|
55
|
+
|
|
56
|
+
<body>
|
|
57
|
+
|
|
58
|
+
<footer>
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
### Types autorisés
|
|
62
|
+
|
|
63
|
+
- `feat`: Nouvelle fonctionnalité
|
|
64
|
+
- `fix`: Correction de bug
|
|
65
|
+
- `docs`: Documentation
|
|
66
|
+
- `style`: Formatage, point-virgules manquants, etc.
|
|
67
|
+
- `refactor`: Refactoring du code
|
|
68
|
+
- `perf`: Amélioration des performances
|
|
69
|
+
- `test`: Ajout de tests
|
|
70
|
+
- `build`: Changements du système de build
|
|
71
|
+
- `ci`: Changements CI/CD
|
|
72
|
+
- `chore`: Tâches de maintenance
|
|
73
|
+
- `revert`: Revert d'un commit précédent
|
|
74
|
+
|
|
75
|
+
### Exemples
|
|
76
|
+
|
|
77
|
+
```bash
|
|
78
|
+
feat(user): add authentication endpoint
|
|
79
|
+
fix(scenario): correct energy calculation
|
|
80
|
+
docs(readme): update installation instructions
|
|
81
|
+
refactor(battery): simplify params validation
|
|
82
|
+
ci(pipeline): add automatic versioning
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
### Impact sur le versioning
|
|
86
|
+
|
|
87
|
+
- `feat`: incrémente la version **minor** (1.0.0 → 1.1.0)
|
|
88
|
+
- `fix`: incrémente la version **patch** (1.0.0 → 1.0.1)
|
|
89
|
+
- `BREAKING CHANGE` dans le footer : incrémente la version **major** (1.0.0 → 2.0.0)
|
|
90
|
+
|
|
91
|
+
## Release et versioning
|
|
92
|
+
|
|
93
|
+
Le package utilise `standard-version` pour le versioning sémantique basé sur les commits conventionnels.
|
|
94
|
+
|
|
95
|
+
### Release automatique
|
|
96
|
+
|
|
97
|
+
Chaque push sur la branche `main` déclenche automatiquement :
|
|
98
|
+
1. Installation des dépendances
|
|
99
|
+
2. Build du projet
|
|
100
|
+
3. Analyse des commits pour déterminer le type de version (patch/minor/major)
|
|
101
|
+
4. Génération du CHANGELOG
|
|
102
|
+
5. Publication sur le registry NPM privé
|
|
103
|
+
|
|
104
|
+
### Release manuelle
|
|
105
|
+
|
|
106
|
+
Via Bitbucket Pipelines, possibilité de forcer un type de release :
|
|
107
|
+
- `patch` : Correctifs (1.0.0 → 1.0.1)
|
|
108
|
+
- `minor` : Nouvelles fonctionnalités (1.0.0 → 1.1.0)
|
|
109
|
+
- `major` : Breaking changes (1.0.0 → 2.0.0)
|
|
110
|
+
- `prepatch`, `preminor`, `premajor`, `prerelease` : Versions de pré-release
|
|
111
|
+
|
|
112
|
+
## Configuration
|
|
113
|
+
|
|
114
|
+
- **Compilation** : ES2019, CommonJS, avec decorators experimentaux
|
|
115
|
+
- **Output** : `dist/index.js` (main), `dist/index.d.ts` (types)
|
|
116
|
+
- **Registry** : NPM privé Likewatt
|
|
117
|
+
|
|
118
|
+
## Confidentialité
|
|
119
|
+
|
|
120
|
+
Ce package est privé et ne doit pas être partagé en dehors de Likewatt.
|
|
5
121
|
|
|
6
|
-
# Release
|
|
7
122
|
|
|
8
|
-
This package uses CI/CD to deploy automatic new versions when a commit is pushed to the `main` branch.
|
|
9
|
-
The changelogs is also automatically generated.
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { Document, Types } from 'mongoose';
|
|
2
|
+
import { Tarif } from './internal/tarif';
|
|
3
|
+
import { RestOfTheYearTarifs } from './internal/rest-of-the-years-tarif';
|
|
4
|
+
/**
|
|
5
|
+
* Représente un utilisateur dans le système.
|
|
6
|
+
* - @Schema/timestamps : gère createdAt et updatedAt automatiques
|
|
7
|
+
* - @Prop : schéma Mongoose
|
|
8
|
+
* - @ApiProperty : documentation Swagger
|
|
9
|
+
* - class-validator rules : validation runtime
|
|
10
|
+
*/
|
|
11
|
+
export declare class DefaultRate {
|
|
12
|
+
name?: string;
|
|
13
|
+
rateId: Types.ObjectId;
|
|
14
|
+
rates: Tarif[];
|
|
15
|
+
restOfTheYear: RestOfTheYearTarifs;
|
|
16
|
+
}
|
|
17
|
+
export type DefaultRateDocument = DefaultRate & Document;
|
|
18
|
+
export declare const DefaultRateSchema: import("mongoose").Schema<DefaultRate, import("mongoose").Model<DefaultRate, any, any, any, Document<unknown, any, DefaultRate, any, {}> & DefaultRate & {
|
|
19
|
+
_id: Types.ObjectId;
|
|
20
|
+
} & {
|
|
21
|
+
__v: number;
|
|
22
|
+
}, any>, {}, {}, {}, {}, import("mongoose").DefaultSchemaOptions, DefaultRate, Document<unknown, {}, import("mongoose").FlatRecord<DefaultRate>, {}, import("mongoose").ResolveSchemaOptions<import("mongoose").DefaultSchemaOptions>> & import("mongoose").FlatRecord<DefaultRate> & {
|
|
23
|
+
_id: Types.ObjectId;
|
|
24
|
+
} & {
|
|
25
|
+
__v: number;
|
|
26
|
+
}>;
|
|
@@ -0,0 +1,67 @@
|
|
|
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.DefaultRateSchema = exports.DefaultRate = void 0;
|
|
13
|
+
const mongoose_1 = require("mongoose");
|
|
14
|
+
const swagger_1 = require("@nestjs/swagger");
|
|
15
|
+
const mongoose_2 = require("@nestjs/mongoose");
|
|
16
|
+
const class_validator_1 = require("class-validator");
|
|
17
|
+
const tarif_1 = require("./internal/tarif");
|
|
18
|
+
const rest_of_the_years_tarif_1 = require("./internal/rest-of-the-years-tarif");
|
|
19
|
+
/**
|
|
20
|
+
* Représente un utilisateur dans le système.
|
|
21
|
+
* - @Schema/timestamps : gère createdAt et updatedAt automatiques
|
|
22
|
+
* - @Prop : schéma Mongoose
|
|
23
|
+
* - @ApiProperty : documentation Swagger
|
|
24
|
+
* - class-validator rules : validation runtime
|
|
25
|
+
*/
|
|
26
|
+
let DefaultRate = class DefaultRate {
|
|
27
|
+
};
|
|
28
|
+
exports.DefaultRate = DefaultRate;
|
|
29
|
+
__decorate([
|
|
30
|
+
(0, swagger_1.ApiProperty)({
|
|
31
|
+
description: 'Nom de l’invitation',
|
|
32
|
+
example: 'Tarif par défaut 1',
|
|
33
|
+
type: String,
|
|
34
|
+
}),
|
|
35
|
+
(0, mongoose_2.Prop)(),
|
|
36
|
+
(0, class_validator_1.IsOptional)(),
|
|
37
|
+
(0, class_validator_1.IsString)(),
|
|
38
|
+
__metadata("design:type", String)
|
|
39
|
+
], DefaultRate.prototype, "name", void 0);
|
|
40
|
+
__decorate([
|
|
41
|
+
(0, swagger_1.ApiProperty)({
|
|
42
|
+
description: 'ID du tarif associé',
|
|
43
|
+
example: '2M61PGSm7lRpqXeaDacbAYOLTYG3',
|
|
44
|
+
type: String,
|
|
45
|
+
}),
|
|
46
|
+
(0, mongoose_2.Prop)({ type: mongoose_1.Types.ObjectId, ref: 'Rate' }),
|
|
47
|
+
(0, class_validator_1.IsOptional)(),
|
|
48
|
+
__metadata("design:type", mongoose_1.Types.ObjectId)
|
|
49
|
+
], DefaultRate.prototype, "rateId", void 0);
|
|
50
|
+
__decorate([
|
|
51
|
+
(0, swagger_1.ApiProperty)({ type: [tarif_1.Tarif] }),
|
|
52
|
+
(0, mongoose_2.Prop)({ required: true }),
|
|
53
|
+
(0, class_validator_1.IsArray)(),
|
|
54
|
+
__metadata("design:type", Array)
|
|
55
|
+
], DefaultRate.prototype, "rates", void 0);
|
|
56
|
+
__decorate([
|
|
57
|
+
(0, swagger_1.ApiProperty)({ type: rest_of_the_years_tarif_1.RestOfTheYearTarifs }),
|
|
58
|
+
(0, mongoose_2.Prop)({ required: false }),
|
|
59
|
+
__metadata("design:type", rest_of_the_years_tarif_1.RestOfTheYearTarifs)
|
|
60
|
+
], DefaultRate.prototype, "restOfTheYear", void 0);
|
|
61
|
+
exports.DefaultRate = DefaultRate = __decorate([
|
|
62
|
+
(0, mongoose_2.Schema)({
|
|
63
|
+
id: false,
|
|
64
|
+
timestamps: true,
|
|
65
|
+
})
|
|
66
|
+
], DefaultRate);
|
|
67
|
+
exports.DefaultRateSchema = mongoose_2.SchemaFactory.createForClass(DefaultRate);
|
package/package.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@likewatt/models",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.1.1",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"types": "dist/index.d.ts",
|
|
6
6
|
"scripts": {
|
|
7
7
|
"build": "tsc",
|
|
8
|
-
"prepare": "
|
|
8
|
+
"prepare": "husky",
|
|
9
9
|
"format": "prettier --write \"src/**/*.ts\"",
|
|
10
10
|
"lint": "eslint \"{src,apps,libs,test}/**/*.ts\" --fix",
|
|
11
11
|
"lint:quick": "eslint \"{src,apps,libs,test}/**/*.ts\"",
|
|
@@ -13,11 +13,19 @@
|
|
|
13
13
|
"release:minor": "standard-version --release-as minor",
|
|
14
14
|
"release:major": "standard-version --release-as major"
|
|
15
15
|
},
|
|
16
|
+
"standard-version": {
|
|
17
|
+
"skip": {
|
|
18
|
+
"changelog": false
|
|
19
|
+
}
|
|
20
|
+
},
|
|
16
21
|
"files": [
|
|
17
22
|
"dist"
|
|
18
23
|
],
|
|
19
24
|
"devDependencies": {
|
|
25
|
+
"@commitlint/cli": "^20.1.0",
|
|
26
|
+
"@commitlint/config-conventional": "^20.0.0",
|
|
20
27
|
"@types/node": "^22.15.17",
|
|
28
|
+
"husky": "^9.1.7",
|
|
21
29
|
"standard-version": "^9.5.0",
|
|
22
30
|
"typescript": "^5.0.0"
|
|
23
31
|
},
|