UNPKG

@citrineos/data

Version:

The OCPP data module which includes all persistence layer implementation.

96 lines 3.64 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, Model, Table, } from 'sequelize-typescript'; import { Transaction } from './Transaction.js'; import { Connector } from '../Location/index.js'; import { Tenant } from '../Tenant.js'; let StartTransaction = class StartTransaction extends Model { static MODEL_NAME = OCPP1_6_Namespace.StartTransaction; 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) ], StartTransaction.prototype, "stationId", void 0); __decorate([ Column(DataType.INTEGER), __metadata("design:type", Number) ], StartTransaction.prototype, "meterStart", void 0); __decorate([ Column({ type: DataType.DATE, get() { return this.getDataValue('timestamp')?.toISOString(); }, }), __metadata("design:type", String) ], StartTransaction.prototype, "timestamp", void 0); __decorate([ Column(DataType.INTEGER), __metadata("design:type", Object) ], StartTransaction.prototype, "reservationId", void 0); __decorate([ ForeignKey(() => Transaction), Column({ type: DataType.INTEGER, unique: true, }), __metadata("design:type", Number) ], StartTransaction.prototype, "transactionDatabaseId", void 0); __decorate([ BelongsTo(() => Transaction), __metadata("design:type", Transaction) ], StartTransaction.prototype, "transaction", void 0); __decorate([ ForeignKey(() => Connector), __metadata("design:type", Number) ], StartTransaction.prototype, "connectorDatabaseId", void 0); __decorate([ BelongsTo(() => Connector), __metadata("design:type", Connector) ], StartTransaction.prototype, "connector", void 0); __decorate([ ForeignKey(() => Tenant), Column({ type: DataType.INTEGER, allowNull: false, onUpdate: 'CASCADE', onDelete: 'RESTRICT', }), __metadata("design:type", Number) ], StartTransaction.prototype, "tenantId", void 0); __decorate([ BelongsTo(() => Tenant), __metadata("design:type", Object) ], StartTransaction.prototype, "tenant", void 0); __decorate([ BeforeUpdate, BeforeCreate, __metadata("design:type", Function), __metadata("design:paramtypes", [StartTransaction]), __metadata("design:returntype", void 0) ], StartTransaction, "setDefaultTenant", null); StartTransaction = __decorate([ Table, __metadata("design:paramtypes", [Object]) ], StartTransaction); export { StartTransaction }; //# sourceMappingURL=StartTransaction.js.map