Skip to content

Commit

Permalink
1.3.0 (#318)
Browse files Browse the repository at this point in the history
* Add AutoAPI L13.2 changes
* Upgrade dependencies
* Implement Property tags
  • Loading branch information
unematiii authored Feb 10, 2023
1 parent df4e7a9 commit 6960570
Show file tree
Hide file tree
Showing 15 changed files with 1,528 additions and 1,062 deletions.
2,499 changes: 1,469 additions & 1,030 deletions package-lock.json

Large diffs are not rendered by default.

32 changes: 16 additions & 16 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@highmobility/auto-api-javascript",
"version": "1.2.2",
"version": "1.3.0",
"description": "Auto API for JavaScript - the parsing library for the Auto API vehicle data model",
"main": "lib/index.js",
"module": "es/index.js",
Expand Down Expand Up @@ -38,33 +38,33 @@
"@tsconfig/node14": "^1.0.3",
"@types/lodash.clonedeep": "^4.5.7",
"@types/lodash.get": "^4.4.7",
"@types/node": "^18.7.1",
"@types/node": "^18.13.0",
"@types/yamljs": "^0.2.31",
"@typescript-eslint/eslint-plugin": "^5.33.0",
"@typescript-eslint/parser": "^5.33.0",
"eslint": "^8.21.0",
"eslint-config-prettier": "^8.5.0",
"@typescript-eslint/eslint-plugin": "^5.51.0",
"@typescript-eslint/parser": "^5.51.0",
"eslint": "^8.33.0",
"eslint-config-prettier": "^8.6.0",
"eslint-import-resolver-alias": "^1.1.2",
"eslint-plugin-import": "^2.26.0",
"eslint-plugin-import": "^2.27.5",
"eslint-plugin-prettier": "^4.2.1",
"husky": "^8.0.1",
"jest": "^28.1.3",
"lint-staged": "^13.0.3",
"husky": "^8.0.3",
"jest": "^29.4.2",
"lint-staged": "^13.1.1",
"npm-run-all": "^4.1.5",
"prettier": "^2.7.1",
"rimraf": "^3.0.2",
"ts-jest": "^28.0.7",
"prettier": "^2.8.4",
"rimraf": "^4.1.2",
"ts-jest": "^29.0.5",
"ts-node": "^10.9.1",
"tsconfig-paths": "^4.1.0",
"typescript": "^4.7.4",
"tsconfig-paths": "^4.1.2",
"typescript": "^4.9.5",
"yamljs": "^0.3.0"
},
"dependencies": {
"abab": "^2.0.6",
"ieee754": "^1.2.1",
"lodash.clonedeep": "^4.5.0",
"lodash.get": "^4.4.2",
"tslib": "^2.4.0"
"tslib": "^2.5.0"
},
"husky": {
"hooks": {
Expand Down
6 changes: 0 additions & 6 deletions scripts/generate-capabilities.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ function createConstructorDeclaration(className: string) {

function createIdentifierDeclaration({ identifier }: Capability) {
return ts.factory.createPropertyDeclaration(
undefined,
[
ts.factory.createModifier(ts.SyntaxKind.StaticKeyword),
ts.factory.createModifier(ts.SyntaxKind.ReadonlyKeyword),
Expand All @@ -86,7 +85,6 @@ function createIdentifierDeclaration({ identifier }: Capability) {

function createNameDeclaration(name: string) {
return ts.factory.createPropertyDeclaration(
undefined,
[
ts.factory.createModifier(ts.SyntaxKind.StaticKeyword),
ts.factory.createModifier(ts.SyntaxKind.ReadonlyKeyword),
Expand All @@ -100,7 +98,6 @@ function createNameDeclaration(name: string) {

function createPropertiesDeclaration() {
return ts.factory.createPropertyDeclaration(
undefined,
[
ts.factory.createModifier(ts.SyntaxKind.StaticKeyword),
ts.factory.createModifier(ts.SyntaxKind.ReadonlyKeyword),
Expand All @@ -118,7 +115,6 @@ function createPropertiesEnumDeclaration(
exportDeclaration = false,
) {
return ts.factory.createEnumDeclaration(
undefined,
exportDeclaration ? [ts.factory.createModifier(ts.SyntaxKind.ExportKeyword)] : undefined,
ts.factory.createIdentifier(token),
properties
Expand All @@ -135,7 +131,6 @@ function createPropertiesEnumDeclaration(

function createCapabilityClassDefinition(className: string, capability: Capability) {
return ts.factory.createClassDeclaration(
undefined,
[ts.factory.createModifier(ts.SyntaxKind.ExportKeyword)],
className,
undefined,
Expand Down Expand Up @@ -163,7 +158,6 @@ function createCapabilityClassDefinition(className: string, capability: Capabili

function createCapabilityClassTypeDefinition(classNames: string[]) {
return ts.factory.createTypeAliasDeclaration(
undefined,
[ts.factory.createModifier(ts.SyntaxKind.ExportKeyword)],
ts.factory.createIdentifier(ClassTypeIdentifier),
undefined,
Expand Down
19 changes: 19 additions & 0 deletions scripts/generate-configuration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ export const getPropertyIdentityKey = (capabilityName: string) => (propertyName:
case 'park_assists':
return 'location';
}
break;

case 'charging':
switch (propertyName) {
Expand All @@ -59,6 +60,7 @@ export const getPropertyIdentityKey = (capabilityName: string) => (propertyName:
case 'reduction_times':
return 'start_stop';
}
break;

case 'chassis_settings':
switch (propertyName) {
Expand All @@ -67,18 +69,21 @@ export const getPropertyIdentityKey = (capabilityName: string) => (propertyName:
case 'minimum_spring_rates':
return 'axle';
}
break;

case 'climate':
switch (propertyName) {
case 'hvac_weekday_starting_times':
return 'weekday';
}
break;

case 'crash':
switch (propertyName) {
case 'incidents':
return 'location';
}
break;

case 'dashboard_lights':
switch (propertyName) {
Expand All @@ -87,6 +92,7 @@ export const getPropertyIdentityKey = (capabilityName: string) => (propertyName:
case 'dashboard_lights':
return 'name';
}
break;

case 'diagnostics':
switch (propertyName) {
Expand All @@ -101,6 +107,7 @@ export const getPropertyIdentityKey = (capabilityName: string) => (propertyName:
case 'wheel_rpms':
return 'location';
}
break;

case 'doors':
switch (propertyName) {
Expand All @@ -109,6 +116,7 @@ export const getPropertyIdentityKey = (capabilityName: string) => (propertyName:
case 'positions':
return 'location';
}
break;

case 'lights':
switch (propertyName) {
Expand All @@ -117,6 +125,7 @@ export const getPropertyIdentityKey = (capabilityName: string) => (propertyName:
case 'reading_lamps':
return 'location';
}
break;

case 'maintenance':
switch (propertyName) {
Expand All @@ -125,6 +134,7 @@ export const getPropertyIdentityKey = (capabilityName: string) => (propertyName:
case 'brakes_service_statuses':
return 'axle';
}
break;

case 'race':
switch (propertyName) {
Expand All @@ -133,13 +143,15 @@ export const getPropertyIdentityKey = (capabilityName: string) => (propertyName:
case 'brake_torque_vectorings':
return 'axle';
}
break;

case 'seats':
switch (propertyName) {
case 'persons_detected':
case 'seatbelts_state':
return 'location';
}
break;

case 'tachograph':
switch (propertyName) {
Expand All @@ -148,6 +160,7 @@ export const getPropertyIdentityKey = (capabilityName: string) => (propertyName:
case 'drivers_time_states':
return 'driver_number';
}
break;

case 'trips':
switch (propertyName) {
Expand All @@ -156,20 +169,26 @@ export const getPropertyIdentityKey = (capabilityName: string) => (propertyName:
case 'thresholds':
return 'type';
}
break;

case 'usage':
switch (propertyName) {
case 'acceleration_durations':
return 'direction';

case 'driving_modes_activation_periods':
case 'driving_modes_energy_consumptions':
return 'driving_mode';
}
break;

case 'windows':
switch (propertyName) {
case 'open_percentages':
case 'positions':
return 'location';
}
break;
}
};

Expand Down
4 changes: 0 additions & 4 deletions scripts/generate-property-components.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ function createConstructorDeclaration({ name }: PropertyComponent) {
],
[
ts.factory.createParameterDeclaration(
undefined,
[
ts.factory.createModifier(ts.SyntaxKind.PublicKeyword),
ts.factory.createModifier(ts.SyntaxKind.ReadonlyKeyword),
Expand All @@ -67,7 +66,6 @@ function createConstructorDeclaration({ name }: PropertyComponent) {

function createDataComponentValueTypeDefinitionOverride() {
return ts.factory.createMethodDeclaration(
undefined,
[ts.factory.createModifier(ts.SyntaxKind.ProtectedKeyword)],
undefined,
ts.factory.createIdentifier('getValueTypeDefinition'),
Expand All @@ -91,7 +89,6 @@ function createDataComponentValueTypeDefinitionOverride() {

function createPropertyComponentClassDefinition(className: string, component: PropertyComponent) {
return ts.factory.createClassDeclaration(
undefined,
[ts.factory.createModifier(ts.SyntaxKind.ExportKeyword)],
className,
undefined,
Expand All @@ -112,7 +109,6 @@ function createPropertyComponentClassDefinition(className: string, component: Pr

function createPropertyComponentNameDeclaration(components: PropertyComponents) {
return ts.factory.createTypeAliasDeclaration(
undefined,
[ts.factory.createModifier(ts.SyntaxKind.ExportKeyword)],
ts.factory.createIdentifier(ComponentNameTypeName),
undefined,
Expand Down
3 changes: 0 additions & 3 deletions scripts/shared/typescript.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ export function createConstructorDeclaration(
parameters: ts.ParameterDeclaration[] = [],
) {
return ts.factory.createConstructorDeclaration(
undefined,
undefined,
parameters,
ts.factory.createBlock(statements, true),
Expand All @@ -14,7 +13,6 @@ export function createConstructorDeclaration(

export function createExportDeclaration(source: string, identifier: string) {
return ts.factory.createExportDeclaration(
undefined,
undefined,
false,
ts.factory.createNamedExports([
Expand All @@ -26,7 +24,6 @@ export function createExportDeclaration(source: string, identifier: string) {

export function createImportDeclaration(source: string, identifier: string) {
return ts.factory.createImportDeclaration(
undefined,
undefined,
ts.factory.createImportClause(
false,
Expand Down
2 changes: 2 additions & 0 deletions src/capabilities/Charging.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ enum Properties {
AcousticLimit = 'acoustic_limit',
AuxiliaryPower = 'auxiliary_power',
BatteryCapacity = 'battery_capacity',
BatteryChargeType = 'battery_charge_type',
BatteryCoolingTemperature = 'battery_cooling_temperature',
BatteryCurrent = 'battery_current',
BatteryCurrentAc = 'battery_current_ac',
Expand Down Expand Up @@ -42,6 +43,7 @@ enum Properties {
CurrentType = 'current_type',
DepartureTimeDisplay = 'departure_time_display',
DepartureTimes = 'departure_times',
DrivingModePhev = 'driving_mode_phev',
EstimatedRange = 'estimated_range',
EstimatedRangeTarget = 'estimated_range_target',
FlapLockStatus = 'flap_lock_status',
Expand Down
1 change: 1 addition & 0 deletions src/capabilities/Diagnostics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ enum Properties {
MileageMeters = 'mileage_meters',
Odometer = 'odometer',
OemTroubleCodeValues = 'oem_trouble_code_values',
PassengerAirbagStatus = 'passenger_airbag_status',
Speed = 'speed',
TirePressureStatuses = 'tire_pressure_statuses',
TirePressures = 'tire_pressures',
Expand Down
1 change: 1 addition & 0 deletions src/capabilities/Race.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { UniversalProperties } from './properties';

enum Properties {
Accelerations = 'accelerations',
AcceleratorDurations = 'accelerator_durations',
AcceleratorPedalIdleSwitch = 'accelerator_pedal_idle_switch',
AcceleratorPedalKickdownSwitch = 'accelerator_pedal_kickdown_switch',
BrakePedalPosition = 'brake_pedal_position',
Expand Down
1 change: 1 addition & 0 deletions src/capabilities/Trips.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { UniversalProperties } from './properties';

enum Properties {
AverageFuelConsumption = 'average_fuel_consumption',
BrakingCount = 'braking_count',
Description = 'description',
Distance = 'distance',
DriverName = 'driver_name',
Expand Down
1 change: 1 addition & 0 deletions src/capabilities/Usage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { Configuration } from '../core/Configuration';
import { UniversalProperties } from './properties';

enum Properties {
AccelerationDurations = 'acceleration_durations',
AccelerationEvaluation = 'acceleration_evaluation',
AverageFuelConsumption = 'average_fuel_consumption',
AverageSpeed = 'average_speed',
Expand Down
2 changes: 1 addition & 1 deletion src/configuration/configuration.json

Large diffs are not rendered by default.

15 changes: 15 additions & 0 deletions src/core/Property.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ export class Property extends Serializable implements NamedEntity {
public constructor(
public readonly definition: Readonly<IProperty>,
public components: Partial<Record<ComponentName, PropertyComponent>> = {},
public tags: Record<string, unknown> = {},
) {
super();
}
Expand Down Expand Up @@ -128,6 +129,20 @@ export class Property extends Serializable implements NamedEntity {
return component;
}

public addTag<T = unknown>(label: string, value: T) {
this.tags[label] = value;
return this;
}

public getTag<T = unknown>(label: string) {
return this.tags[label] as T | undefined;
}

public removeTag(label: string) {
delete this.tags[label];
return this;
}

public isInstanceOf(property: Property) {
const { identityKey, multiple } = property;
if (property instanceof Object.getPrototypeOf(this).constructor) {
Expand Down
2 changes: 1 addition & 1 deletion src/factories/PropertyComponentFactory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export class PropertyComponentFactory {

if (PropertyComponentConstructor) {
const component = new PropertyComponentConstructor(property) as InstanceType<
typeof ClassMap[T]
(typeof ClassMap)[T]
>;

if (initialValue !== undefined) {
Expand Down

0 comments on commit 6960570

Please sign in to comment.