UNPKG

@citrineos/data

Version:

The OCPP data module which includes all persistence layer implementation.

100 lines 3.74 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, OCPP1_6_Namespace } from '@citrineos/base'; import { BeforeCreate, BeforeUpdate, BelongsTo, Column, DataType, ForeignKey, HasMany, Model, Table, } from 'sequelize-typescript'; import { Tenant } from '../Tenant.js'; import { MeterValue } from './MeterValue.js'; import { Transaction } from './Transaction.js'; let StopTransaction = class StopTransaction extends Model { static MODEL_NAME = OCPP1_6_Namespace.StopTransaction; 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) ], StopTransaction.prototype, "stationId", void 0); __decorate([ ForeignKey(() => Transaction), Column({ type: DataType.INTEGER, unique: true, }), __metadata("design:type", Number) ], StopTransaction.prototype, "transactionDatabaseId", void 0); __decorate([ BelongsTo(() => Transaction), __metadata("design:type", Transaction) ], StopTransaction.prototype, "transaction", void 0); __decorate([ Column(DataType.INTEGER), __metadata("design:type", Number) ], StopTransaction.prototype, "meterStop", void 0); __decorate([ Column({ type: DataType.DATE, get() { return this.getDataValue('timestamp')?.toISOString(); }, }), __metadata("design:type", String) ], StopTransaction.prototype, "timestamp", void 0); __decorate([ Column(DataType.STRING), __metadata("design:type", String) ], StopTransaction.prototype, "reason", void 0); __decorate([ HasMany(() => MeterValue), __metadata("design:type", Array) ], StopTransaction.prototype, "meterValues", void 0); __decorate([ Column(DataType.STRING), __metadata("design:type", String) ], StopTransaction.prototype, "idTokenValue", void 0); __decorate([ Column(DataType.STRING), __metadata("design:type", String) ], StopTransaction.prototype, "idTokenType", void 0); __decorate([ ForeignKey(() => Tenant), Column({ type: DataType.INTEGER, allowNull: false, onUpdate: 'CASCADE', onDelete: 'RESTRICT', }), __metadata("design:type", Number) ], StopTransaction.prototype, "tenantId", void 0); __decorate([ BelongsTo(() => Tenant), __metadata("design:type", Object) ], StopTransaction.prototype, "tenant", void 0); __decorate([ BeforeUpdate, BeforeCreate, __metadata("design:type", Function), __metadata("design:paramtypes", [StopTransaction]), __metadata("design:returntype", void 0) ], StopTransaction, "setDefaultTenant", null); StopTransaction = __decorate([ Table, __metadata("design:paramtypes", [Object]) ], StopTransaction); export { StopTransaction }; //# sourceMappingURL=StopTransaction.js.map