@citrineos/data
Version:
The OCPP data module which includes all persistence layer implementation.
169 lines • 6.33 kB
JavaScript
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
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;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
import { DEFAULT_TENANT_ID, Namespace, OCPPVersion } from '@citrineos/base';
import { BeforeCreate, BeforeUpdate, BelongsTo, BelongsToMany, Column, DataType, ForeignKey, HasMany, Model, PrimaryKey, Table, } from 'sequelize-typescript';
import { Tenant } from '../Tenant.js';
import { Transaction } from '../index.js';
import { ChargingStationNetworkProfile } from './ChargingStationNetworkProfile.js';
import { Connector } from './Connector.js';
import { Evse } from './Evse.js';
import { Location } from './Location.js';
import { SetNetworkProfile } from './SetNetworkProfile.js';
import { StatusNotification } from './StatusNotification.js';
/**
* Represents a charging station.
* Currently, this data model is internal to CitrineOS. In the future, it will be analogous to an OCPI ChargingStation.
*/
let ChargingStation = class ChargingStation extends Model {
static MODEL_NAME = Namespace.ChargingStation;
static setDefaultTenant(instance) {
if (instance.tenantId == null) {
instance.tenantId = DEFAULT_TENANT_ID;
}
}
constructor(...args) {
super(...args);
if (this.tenantId == null) {
this.tenantId = DEFAULT_TENANT_ID;
}
}
};
__decorate([
PrimaryKey,
Column(DataType.STRING(36)),
__metadata("design:type", String)
], ChargingStation.prototype, "id", void 0);
__decorate([
Column(DataType.BOOLEAN),
__metadata("design:type", Boolean)
], ChargingStation.prototype, "isOnline", void 0);
__decorate([
Column(DataType.STRING),
__metadata("design:type", Object)
], ChargingStation.prototype, "protocol", void 0);
__decorate([
Column(DataType.STRING(20)),
__metadata("design:type", Object)
], ChargingStation.prototype, "chargePointVendor", void 0);
__decorate([
Column(DataType.STRING(20)),
__metadata("design:type", Object)
], ChargingStation.prototype, "chargePointModel", void 0);
__decorate([
Column(DataType.STRING(25)),
__metadata("design:type", Object)
], ChargingStation.prototype, "chargePointSerialNumber", void 0);
__decorate([
Column(DataType.STRING(25)),
__metadata("design:type", Object)
], ChargingStation.prototype, "chargeBoxSerialNumber", void 0);
__decorate([
Column(DataType.STRING(50)),
__metadata("design:type", Object)
], ChargingStation.prototype, "firmwareVersion", void 0);
__decorate([
Column(DataType.STRING(20)),
__metadata("design:type", Object)
], ChargingStation.prototype, "iccid", void 0);
__decorate([
Column(DataType.STRING(20)),
__metadata("design:type", Object)
], ChargingStation.prototype, "imsi", void 0);
__decorate([
Column(DataType.STRING(25)),
__metadata("design:type", Object)
], ChargingStation.prototype, "meterType", void 0);
__decorate([
Column(DataType.STRING(25)),
__metadata("design:type", Object)
], ChargingStation.prototype, "meterSerialNumber", void 0);
__decorate([
Column(DataType.GEOMETRY('POINT')),
__metadata("design:type", Object)
], ChargingStation.prototype, "coordinates", void 0);
__decorate([
Column(DataType.STRING),
__metadata("design:type", Object)
], ChargingStation.prototype, "floorLevel", void 0);
__decorate([
Column(DataType.JSONB),
__metadata("design:type", Object)
], ChargingStation.prototype, "parkingRestrictions", void 0);
__decorate([
Column(DataType.JSONB),
__metadata("design:type", Object)
], ChargingStation.prototype, "capabilities", void 0);
__decorate([
Column({
type: DataType.BOOLEAN,
defaultValue: true,
}),
__metadata("design:type", Boolean)
], ChargingStation.prototype, "use16StatusNotification0", void 0);
__decorate([
ForeignKey(() => Location),
Column(DataType.INTEGER),
__metadata("design:type", Object)
], ChargingStation.prototype, "locationId", void 0);
__decorate([
HasMany(() => StatusNotification),
__metadata("design:type", Object)
], ChargingStation.prototype, "statusNotifications", void 0);
__decorate([
HasMany(() => Transaction),
__metadata("design:type", Object)
], ChargingStation.prototype, "transactions", void 0);
__decorate([
BelongsTo(() => Location),
__metadata("design:type", Object)
], ChargingStation.prototype, "location", void 0);
__decorate([
BelongsToMany(() => SetNetworkProfile, () => ChargingStationNetworkProfile),
__metadata("design:type", Object)
], ChargingStation.prototype, "networkProfiles", void 0);
__decorate([
HasMany(() => Evse, {
onDelete: 'CASCADE',
}),
__metadata("design:type", Object)
], ChargingStation.prototype, "evses", void 0);
__decorate([
HasMany(() => Connector, {
onDelete: 'CASCADE',
}),
__metadata("design:type", Object)
], ChargingStation.prototype, "connectors", void 0);
__decorate([
ForeignKey(() => Tenant),
Column({
type: DataType.INTEGER,
allowNull: false,
onUpdate: 'CASCADE',
onDelete: 'RESTRICT',
}),
__metadata("design:type", Number)
], ChargingStation.prototype, "tenantId", void 0);
__decorate([
BelongsTo(() => Tenant),
__metadata("design:type", Object)
], ChargingStation.prototype, "tenant", void 0);
__decorate([
BeforeUpdate,
BeforeCreate,
__metadata("design:type", Function),
__metadata("design:paramtypes", [ChargingStation]),
__metadata("design:returntype", void 0)
], ChargingStation, "setDefaultTenant", null);
ChargingStation = __decorate([
Table,
__metadata("design:paramtypes", [Object])
], ChargingStation);
export { ChargingStation };
//# sourceMappingURL=ChargingStation.js.map