UNPKG

@citrineos/data

Version:

The OCPP data module which includes all persistence layer implementation.

127 lines 4.42 kB
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, LocationHours, OCPP2_0_1_Namespace } from '@citrineos/base'; import { BeforeCreate, BeforeUpdate, BelongsTo, Column, DataType, ForeignKey, HasMany, Model, Table, } from 'sequelize-typescript'; import { Tenant } from '../Tenant.js'; import { ChargingStation } from './ChargingStation.js'; /** * Represents a location. * Currently, this data model is internal to CitrineOS. In the future, it will be analogous to an OCPI Location. */ let Location = class Location extends Model { static MODEL_NAME = OCPP2_0_1_Namespace.Location; 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([ Column(DataType.STRING), __metadata("design:type", String) ], Location.prototype, "name", void 0); __decorate([ Column(DataType.STRING), __metadata("design:type", String) ], Location.prototype, "address", void 0); __decorate([ Column(DataType.STRING), __metadata("design:type", String) ], Location.prototype, "city", void 0); __decorate([ Column(DataType.STRING), __metadata("design:type", String) ], Location.prototype, "postalCode", void 0); __decorate([ Column(DataType.STRING), __metadata("design:type", String) ], Location.prototype, "state", void 0); __decorate([ Column(DataType.STRING), __metadata("design:type", String) ], Location.prototype, "country", void 0); __decorate([ Column({ type: DataType.BOOLEAN, defaultValue: true, }), __metadata("design:type", Boolean) ], Location.prototype, "publishUpstream", void 0); __decorate([ Column({ type: DataType.STRING, defaultValue: 'UTC', validate: { isTimezone(value) { try { Intl.DateTimeFormat(undefined, { timeZone: value }); return true; } catch (_ex) { return false; } }, }, }), __metadata("design:type", String) ], Location.prototype, "timeZone", void 0); __decorate([ Column(DataType.STRING), __metadata("design:type", Object) ], Location.prototype, "parkingType", void 0); __decorate([ Column(DataType.JSONB), __metadata("design:type", Object) ], Location.prototype, "facilities", void 0); __decorate([ Column(DataType.JSONB), __metadata("design:type", Object) ], Location.prototype, "openingHours", void 0); __decorate([ Column(DataType.GEOMETRY('POINT')), __metadata("design:type", Object) ], Location.prototype, "coordinates", void 0); __decorate([ HasMany(() => ChargingStation), __metadata("design:type", Array) ], Location.prototype, "chargingPool", void 0); __decorate([ ForeignKey(() => Tenant), Column({ type: DataType.INTEGER, allowNull: false, onUpdate: 'CASCADE', onDelete: 'RESTRICT', }), __metadata("design:type", Number) ], Location.prototype, "tenantId", void 0); __decorate([ BelongsTo(() => Tenant), __metadata("design:type", Object) ], Location.prototype, "tenant", void 0); __decorate([ BeforeUpdate, BeforeCreate, __metadata("design:type", Function), __metadata("design:paramtypes", [Location]), __metadata("design:returntype", void 0) ], Location, "setDefaultTenant", null); Location = __decorate([ Table, __metadata("design:paramtypes", [Object]) ], Location); export { Location }; //# sourceMappingURL=Location.js.map