@sports-alliance/sports-lib 7.0.8 → 7.0.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/esm/index.js +12034 -152
- package/package.json +2 -2
- package/lib/esm/activities/activity-parsing-options.js +0 -19
- package/lib/esm/activities/activity.interface.js +0 -1
- package/lib/esm/activities/activity.js +0 -281
- package/lib/esm/activities/activity.json.interface.js +0 -1
- package/lib/esm/activities/activity.spec.js +0 -348
- package/lib/esm/activities/activity.types.js +0 -1046
- package/lib/esm/activities/activityt-types.spec.js +0 -16
- package/lib/esm/activities/devices/device.interface.js +0 -1
- package/lib/esm/activities/devices/device.js +0 -26
- package/lib/esm/activities/devices/device.json.interface.js +0 -1
- package/lib/esm/constants/constants.js +0 -8
- package/lib/esm/creators/creator.interface.js +0 -1
- package/lib/esm/creators/creator.js +0 -37
- package/lib/esm/creators/creator.json.interface.js +0 -1
- package/lib/esm/creators/creator.spec.js +0 -25
- package/lib/esm/data/data-active-lap.js +0 -4
- package/lib/esm/data/data-active-lengths.js +0 -4
- package/lib/esm/data/data-aerobic-training-effect.js +0 -8
- package/lib/esm/data/data-anaerobic-training-effect.js +0 -8
- package/lib/esm/data/data-stance-time-balance-left.js +0 -4
- package/lib/esm/data/data-stance-time-balance-right.js +0 -4
- package/lib/esm/data/data-stance-time-balance.js +0 -3
- package/lib/esm/data/data-store.spec.js +0 -78
- package/lib/esm/data/data-total-cycles.js +0 -4
- package/lib/esm/data/data.absolute-pressure.js +0 -5
- package/lib/esm/data/data.accumulated-power.js +0 -8
- package/lib/esm/data/data.activity-types.js +0 -7
- package/lib/esm/data/data.air-power-avg.js +0 -4
- package/lib/esm/data/data.air-power-max.js +0 -4
- package/lib/esm/data/data.air-power-min.js +0 -4
- package/lib/esm/data/data.air-power.js +0 -8
- package/lib/esm/data/data.alti-baro-profile.js +0 -4
- package/lib/esm/data/data.altitude-avg.js +0 -4
- package/lib/esm/data/data.altitude-gps.js +0 -5
- package/lib/esm/data/data.altitude-max.js +0 -4
- package/lib/esm/data/data.altitude-min.js +0 -4
- package/lib/esm/data/data.altitude-smooth.js +0 -4
- package/lib/esm/data/data.altitude.js +0 -8
- package/lib/esm/data/data.array.js +0 -13
- package/lib/esm/data/data.ascent-time.js +0 -4
- package/lib/esm/data/data.ascent.js +0 -4
- package/lib/esm/data/data.auto-lap-distance.js +0 -5
- package/lib/esm/data/data.auto-lap-duration.js +0 -4
- package/lib/esm/data/data.auto-lap-used.js +0 -7
- package/lib/esm/data/data.auto-pause-used.js +0 -7
- package/lib/esm/data/data.avg-stride-length.js +0 -4
- package/lib/esm/data/data.balance.js +0 -6
- package/lib/esm/data/data.bare.js +0 -4
- package/lib/esm/data/data.battery-charge.js +0 -8
- package/lib/esm/data/data.battery-consumption.js +0 -8
- package/lib/esm/data/data.battery-current.js +0 -8
- package/lib/esm/data/data.battery-life-estimation.js +0 -4
- package/lib/esm/data/data.battery-voltage.js +0 -8
- package/lib/esm/data/data.bike-pod-used.js +0 -7
- package/lib/esm/data/data.boolean.js +0 -9
- package/lib/esm/data/data.cadence-avg.js +0 -4
- package/lib/esm/data/data.cadence-max.js +0 -4
- package/lib/esm/data/data.cadence-min.js +0 -4
- package/lib/esm/data/data.cadence.js +0 -8
- package/lib/esm/data/data.cycling-dynamics.js +0 -3
- package/lib/esm/data/data.cycling-position.js +0 -37
- package/lib/esm/data/data.cycling-seated-time.js +0 -5
- package/lib/esm/data/data.cycling-standing-time.js +0 -5
- package/lib/esm/data/data.descent-time.js +0 -4
- package/lib/esm/data/data.descent.js +0 -4
- package/lib/esm/data/data.description.js +0 -4
- package/lib/esm/data/data.device-location.js +0 -4
- package/lib/esm/data/data.device-names.js +0 -7
- package/lib/esm/data/data.distance.js +0 -15
- package/lib/esm/data/data.duration.js +0 -56
- package/lib/esm/data/data.ehpe.js +0 -5
- package/lib/esm/data/data.enabled-navigation-systems.js +0 -4
- package/lib/esm/data/data.end-altitude.js +0 -4
- package/lib/esm/data/data.end-position.js +0 -4
- package/lib/esm/data/data.energy.js +0 -8
- package/lib/esm/data/data.epoc.js +0 -5
- package/lib/esm/data/data.event.js +0 -3
- package/lib/esm/data/data.evpe.js +0 -4
- package/lib/esm/data/data.feeling.js +0 -15
- package/lib/esm/data/data.foot-pod-used.js +0 -7
- package/lib/esm/data/data.form-power.js +0 -4
- package/lib/esm/data/data.fused-altitude.js +0 -7
- package/lib/esm/data/data.fused-location.js +0 -7
- package/lib/esm/data/data.gnss-distance.js +0 -4
- package/lib/esm/data/data.grade-adjusted-pace-avg.js +0 -15
- package/lib/esm/data/data.grade-adjusted-pace-max.js +0 -15
- package/lib/esm/data/data.grade-adjusted-pace-min.js +0 -15
- package/lib/esm/data/data.grade-adjusted-pace.js +0 -25
- package/lib/esm/data/data.grade-adjusted-speed-avg.js +0 -46
- package/lib/esm/data/data.grade-adjusted-speed-max.js +0 -46
- package/lib/esm/data/data.grade-adjusted-speed-min.js +0 -46
- package/lib/esm/data/data.grade-adjusted-speed.js +0 -78
- package/lib/esm/data/data.grade-smooth.js +0 -7
- package/lib/esm/data/data.grade.js +0 -7
- package/lib/esm/data/data.ground-time.js +0 -8
- package/lib/esm/data/data.heart-rate-avg.js +0 -4
- package/lib/esm/data/data.heart-rate-max.js +0 -4
- package/lib/esm/data/data.heart-rate-min.js +0 -4
- package/lib/esm/data/data.heart-rate-used.js +0 -7
- package/lib/esm/data/data.heart-rate-zone-five-duration.js +0 -4
- package/lib/esm/data/data.heart-rate-zone-four-duration.js +0 -4
- package/lib/esm/data/data.heart-rate-zone-one-duration.js +0 -4
- package/lib/esm/data/data.heart-rate-zone-three-duration.js +0 -4
- package/lib/esm/data/data.heart-rate-zone-two-duration.js +0 -4
- package/lib/esm/data/data.heart-rate.js +0 -8
- package/lib/esm/data/data.ibi.js +0 -8
- package/lib/esm/data/data.interface.js +0 -5
- package/lib/esm/data/data.js +0 -62
- package/lib/esm/data/data.json.interface.js +0 -1
- package/lib/esm/data/data.latitude-degrees.js +0 -5
- package/lib/esm/data/data.left-balance.js +0 -4
- package/lib/esm/data/data.leg-stiffness.js +0 -16
- package/lib/esm/data/data.longitude-degrees.js +0 -5
- package/lib/esm/data/data.moving-time.js +0 -4
- package/lib/esm/data/data.number-of-satellites.js +0 -7
- package/lib/esm/data/data.number-of.samples.js +0 -4
- package/lib/esm/data/data.number.js +0 -13
- package/lib/esm/data/data.pace-avg.js +0 -8
- package/lib/esm/data/data.pace-max.js +0 -8
- package/lib/esm/data/data.pace-min.js +0 -8
- package/lib/esm/data/data.pace.js +0 -46
- package/lib/esm/data/data.pause.js +0 -4
- package/lib/esm/data/data.peak-epoc.js +0 -7
- package/lib/esm/data/data.peak-training-effect.js +0 -4
- package/lib/esm/data/data.percent.js +0 -4
- package/lib/esm/data/data.pool-length.js +0 -5
- package/lib/esm/data/data.position.interface.js +0 -1
- package/lib/esm/data/data.position.js +0 -18
- package/lib/esm/data/data.power-avg.js +0 -4
- package/lib/esm/data/data.power-down.js +0 -4
- package/lib/esm/data/data.power-intensity-factor.js +0 -5
- package/lib/esm/data/data.power-left.js +0 -4
- package/lib/esm/data/data.power-max.js +0 -4
- package/lib/esm/data/data.power-min.js +0 -4
- package/lib/esm/data/data.power-normalized.js +0 -4
- package/lib/esm/data/data.power-pedal-smoothness-left.js +0 -4
- package/lib/esm/data/data.power-pedal-smoothness-right.js +0 -4
- package/lib/esm/data/data.power-pod-used.js +0 -7
- package/lib/esm/data/data.power-right.js +0 -4
- package/lib/esm/data/data.power-torque-effectiveness-left.js +0 -4
- package/lib/esm/data/data.power-torque-effectiveness-right.js +0 -4
- package/lib/esm/data/data.power-training-stress-score.js +0 -5
- package/lib/esm/data/data.power-up.js +0 -4
- package/lib/esm/data/data.power-work.js +0 -5
- package/lib/esm/data/data.power-zone-five-duration.js +0 -4
- package/lib/esm/data/data.power-zone-four-duration.js +0 -4
- package/lib/esm/data/data.power-zone-one-duration.js +0 -4
- package/lib/esm/data/data.power-zone-three-duration.js +0 -4
- package/lib/esm/data/data.power-zone-two-duration.js +0 -4
- package/lib/esm/data/data.power.js +0 -8
- package/lib/esm/data/data.recovery-time.js +0 -7
- package/lib/esm/data/data.rider-position-change-event.js +0 -8
- package/lib/esm/data/data.right-balance.js +0 -4
- package/lib/esm/data/data.rpe.js +0 -23
- package/lib/esm/data/data.satellite-5-best-snr.js +0 -4
- package/lib/esm/data/data.sea-level-pressure.js +0 -5
- package/lib/esm/data/data.spec.js +0 -25
- package/lib/esm/data/data.speed-avg.js +0 -46
- package/lib/esm/data/data.speed-max.js +0 -46
- package/lib/esm/data/data.speed-min.js +0 -46
- package/lib/esm/data/data.speed-zone-five-duration.js +0 -4
- package/lib/esm/data/data.speed-zone-four-duration.js +0 -4
- package/lib/esm/data/data.speed-zone-one-duration.js +0 -4
- package/lib/esm/data/data.speed-zone-three-duration.js +0 -4
- package/lib/esm/data/data.speed-zone-two-duration.js +0 -4
- package/lib/esm/data/data.speed.js +0 -88
- package/lib/esm/data/data.sport-profile-name.js +0 -4
- package/lib/esm/data/data.stance-time.js +0 -5
- package/lib/esm/data/data.start-altitude.js +0 -4
- package/lib/esm/data/data.start-event.js +0 -4
- package/lib/esm/data/data.start-position.js +0 -4
- package/lib/esm/data/data.step-length.js +0 -4
- package/lib/esm/data/data.steps-old.js +0 -4
- package/lib/esm/data/data.steps.js +0 -4
- package/lib/esm/data/data.stop-all-event.js +0 -4
- package/lib/esm/data/data.stop-event.js +0 -4
- package/lib/esm/data/data.store.export.spec.js +0 -66
- package/lib/esm/data/data.store.js +0 -1213
- package/lib/esm/data/data.string.js +0 -13
- package/lib/esm/data/data.stryd-altitude.js +0 -4
- package/lib/esm/data/data.stryd-distance.js +0 -4
- package/lib/esm/data/data.stryd-speed.js +0 -4
- package/lib/esm/data/data.swim-pace-avg.js +0 -8
- package/lib/esm/data/data.swim-pace-max.js +0 -8
- package/lib/esm/data/data.swim-pace-min.js +0 -8
- package/lib/esm/data/data.swim-pace.js +0 -19
- package/lib/esm/data/data.swolf-25m.js +0 -4
- package/lib/esm/data/data.swolf-50m.js +0 -4
- package/lib/esm/data/data.target-distance.js +0 -4
- package/lib/esm/data/data.target-heart-rate-zone.js +0 -4
- package/lib/esm/data/data.target-power-zone.js +0 -4
- package/lib/esm/data/data.target-speed-zone.js +0 -4
- package/lib/esm/data/data.target-time.js +0 -4
- package/lib/esm/data/data.temperature-avg.js +0 -4
- package/lib/esm/data/data.temperature-max.js +0 -4
- package/lib/esm/data/data.temperature-min.js +0 -4
- package/lib/esm/data/data.temperature.js +0 -8
- package/lib/esm/data/data.time.js +0 -6
- package/lib/esm/data/data.timer-time.js +0 -4
- package/lib/esm/data/data.vertical-oscillation.js +0 -5
- package/lib/esm/data/data.vertical-ratio.js +0 -5
- package/lib/esm/data/data.vertical-speed-avg.js +0 -53
- package/lib/esm/data/data.vertical-speed-max.js +0 -53
- package/lib/esm/data/data.vertical-speed-min.js +0 -53
- package/lib/esm/data/data.vertical-speed.js +0 -103
- package/lib/esm/data/data.vo2-max.js +0 -7
- package/lib/esm/data/ibi/data.ibi.filters.js +0 -52
- package/lib/esm/data/ibi/data.ibi.js +0 -98
- package/lib/esm/data/ibi/data.ibi.spec.js +0 -66
- package/lib/esm/duration/duration.class.abstract.js +0 -36
- package/lib/esm/duration/duration.class.interface.js +0 -1
- package/lib/esm/errors/duration-exceeded-event-lib.error.js +0 -9
- package/lib/esm/errors/empty-event-sports-libs.error.js +0 -9
- package/lib/esm/errors/event-lib.error.js +0 -8
- package/lib/esm/errors/lib.error.js +0 -6
- package/lib/esm/errors/parsing-event-lib.error.js +0 -9
- package/lib/esm/events/adapters/exporters/exporter.gpx.js +0 -75
- package/lib/esm/events/adapters/exporters/exporter.interface.js +0 -1
- package/lib/esm/events/adapters/exporters/exporter.json.js +0 -20
- package/lib/esm/events/adapters/file-type.enum.js +0 -7
- package/lib/esm/events/adapters/importers/fit/importer.fit.ant-plus.device.names.js +0 -25
- package/lib/esm/events/adapters/importers/fit/importer.fit.coros.device.names.js +0 -5
- package/lib/esm/events/adapters/importers/fit/importer.fit.development.device.names.js +0 -4
- package/lib/esm/events/adapters/importers/fit/importer.fit.garmin.device.names.js +0 -462
- package/lib/esm/events/adapters/importers/fit/importer.fit.garmin.profile.data.js +0 -877
- package/lib/esm/events/adapters/importers/fit/importer.fit.garmin.profile.mapper.js +0 -106
- package/lib/esm/events/adapters/importers/fit/importer.fit.garmin.profile.mapper.spec.js +0 -32
- package/lib/esm/events/adapters/importers/fit/importer.fit.hammerhead.device.names.js +0 -4
- package/lib/esm/events/adapters/importers/fit/importer.fit.integration.spec.js +0 -44
- package/lib/esm/events/adapters/importers/fit/importer.fit.js +0 -978
- package/lib/esm/events/adapters/importers/fit/importer.fit.lezyne.device.names.js +0 -3
- package/lib/esm/events/adapters/importers/fit/importer.fit.magellan.device.names.js +0 -5
- package/lib/esm/events/adapters/importers/fit/importer.fit.mapper.js +0 -231
- package/lib/esm/events/adapters/importers/fit/importer.fit.saris.device.names.js +0 -3
- package/lib/esm/events/adapters/importers/fit/importer.fit.spec.js +0 -326
- package/lib/esm/events/adapters/importers/fit/importer.fit.srm.device.names.js +0 -7
- package/lib/esm/events/adapters/importers/fit/importer.fit.suunto.device.names.js +0 -16
- package/lib/esm/events/adapters/importers/fit/importer.fit.wahoo.device.names.js +0 -10
- package/lib/esm/events/adapters/importers/gpx/gx-parser.js +0 -36
- package/lib/esm/events/adapters/importers/gpx/importer.gpx.integration.spec.js +0 -44
- package/lib/esm/events/adapters/importers/gpx/importer.gpx.js +0 -102
- package/lib/esm/events/adapters/importers/gpx/importer.gpx.mapper.js +0 -142
- package/lib/esm/events/adapters/importers/gpx/importer.gpx.spec.js +0 -71
- package/lib/esm/events/adapters/importers/json/importer.json.js +0 -160
- package/lib/esm/events/adapters/importers/sample-info.interface.js +0 -1
- package/lib/esm/events/adapters/importers/suunto/importer.suunto.activity.ids.js +0 -85
- package/lib/esm/events/adapters/importers/suunto/importer.suunto.device.names.js +0 -26
- package/lib/esm/events/adapters/importers/suunto/importer.suunto.integration.spec.js +0 -44
- package/lib/esm/events/adapters/importers/suunto/importer.suunto.json.js +0 -717
- package/lib/esm/events/adapters/importers/suunto/importer.suunto.sml.js +0 -125
- package/lib/esm/events/adapters/importers/tcx/importer.tcx.integration.spec.js +0 -46
- package/lib/esm/events/adapters/importers/tcx/importer.tcx.js +0 -442
- package/lib/esm/events/adapters/importers/tcx/importer.tcx.mapper.js +0 -91
- package/lib/esm/events/adapters/importers/tcx/utils.tcx.js +0 -36
- package/lib/esm/events/event.interface.js +0 -1
- package/lib/esm/events/event.js +0 -123
- package/lib/esm/events/event.json.interface.js +0 -1
- package/lib/esm/events/event.spec.js +0 -51
- package/lib/esm/events/utilities/activity.utilities.js +0 -1841
- package/lib/esm/events/utilities/activity.utilities.spec.js +0 -373
- package/lib/esm/events/utilities/event.utilities.js +0 -57
- package/lib/esm/events/utilities/grade-calculator/grade-calculator.js +0 -121
- package/lib/esm/events/utilities/grade-calculator/grade-calculator.spec.js +0 -93
- package/lib/esm/events/utilities/grade-calculator/low-pass-filter.js +0 -86
- package/lib/esm/events/utilities/helpers.js +0 -162
- package/lib/esm/geodesy/adapters/adapter.interface.js +0 -1
- package/lib/esm/geodesy/adapters/geolib.adapter.js +0 -28
- package/lib/esm/id/id.abstract.class.js +0 -9
- package/lib/esm/id/id.class.interface.js +0 -1
- package/lib/esm/id/id.class.spec.js +0 -13
- package/lib/esm/intensity-zones/intensity-zones.interface.js +0 -1
- package/lib/esm/intensity-zones/intensity-zones.js +0 -29
- package/lib/esm/intensity-zones/intensity-zones.json.interface.js +0 -1
- package/lib/esm/intensity-zones/intensity-zones.spec.js +0 -30
- package/lib/esm/laps/lap.interface.js +0 -1
- package/lib/esm/laps/lap.js +0 -29
- package/lib/esm/laps/lap.json.interface.js +0 -1
- package/lib/esm/laps/lap.types.js +0 -52
- package/lib/esm/meta-data/event-meta-data.interface.js +0 -6
- package/lib/esm/meta-data/meta-data.js +0 -57
- package/lib/esm/meta-data/meta-data.json.interface.js +0 -1
- package/lib/esm/privacy/privacy.class.interface.js +0 -5
- package/lib/esm/serializable/serializable.class.interface.js +0 -1
- package/lib/esm/service-tokens/oauth1-service-token.interface.js +0 -1
- package/lib/esm/service-tokens/oauth2-service-token.interface.js +0 -1
- package/lib/esm/specs/activities-parsing.integration.spec.js +0 -1847
- package/lib/esm/specs/activity-duration-stream.integration.spec.js +0 -57
- package/lib/esm/specs/fixtures/streams/strava/rides/3171472783.json +0 -52534
- package/lib/esm/specs/fixtures/streams/strava/rides/3171487458.json +0 -78818
- package/lib/esm/specs/fixtures/streams/strava/rides/343080886.json +0 -105090
- package/lib/esm/specs/fixtures/streams/strava/rides/5910143591.json +0 -110711
- package/lib/esm/specs/fixtures/streams/strava/runs/2451375851.json +0 -74846
- package/lib/esm/specs/fixtures/streams/strava/runs/2709634581.json +0 -66817
- package/lib/esm/specs/fixtures/streams/strava/runs/3156040843.json +0 -17594
- package/lib/esm/specs/fixtures/streams/strava/runs/3182900697.json +0 -17322
- package/lib/esm/specs/fixtures/streams/strava/runs/3183465494.json +0 -20463
- package/lib/esm/specs/fixtures/streams/strava/runs/3183490558.json +0 -58202
- package/lib/esm/specs/spec-utils.js +0 -159
- package/lib/esm/specs/strava-streams-compliance.spec.js +0 -951
- package/lib/esm/stats/stats.class.abstract.js +0 -32
- package/lib/esm/stats/stats.class.interface.js +0 -1
- package/lib/esm/stats/stats.json.interface.js +0 -1
- package/lib/esm/streams/compressed.stream.interface.js +0 -12
- package/lib/esm/streams/ibi-stream.js +0 -43
- package/lib/esm/streams/low-pass.stream.filter.js +0 -9
- package/lib/esm/streams/stream.filter.interface.js +0 -1
- package/lib/esm/streams/stream.interface.js +0 -1
- package/lib/esm/streams/stream.js +0 -72
- package/lib/esm/streams/stream.spec.js +0 -168
- package/lib/esm/tiles/tile.settings.interface.js +0 -41
- package/lib/esm/users/settings/dashboard/user.dashboard.settings.interface.js +0 -13
- package/lib/esm/users/settings/user.app.settings.interface.js +0 -5
- package/lib/esm/users/settings/user.chart.settings.interface.js +0 -23
- package/lib/esm/users/settings/user.map.settings.interface.js +0 -22
- package/lib/esm/users/settings/user.my-tracks.settings.interface.js +0 -1
- package/lib/esm/users/settings/user.settings.interface.js +0 -1
- package/lib/esm/users/settings/user.stats-settings.interface.js +0 -1
- package/lib/esm/users/settings/user.summaries.settings.interface.js +0 -1
- package/lib/esm/users/settings/user.unit.settings.interface.js +0 -73
- package/lib/esm/users/user.account.privileges.interface.js +0 -1
- package/lib/esm/users/user.export-to-csv.settings.interface.js +0 -1
- package/lib/esm/users/user.interface.js +0 -1
- package/lib/esm/users/user.js +0 -38
- package/lib/esm/users/user.service.meta.interface.js +0 -1
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
-
});
|
|
9
|
-
};
|
|
10
|
-
import * as fs from 'fs';
|
|
11
|
-
import * as path from 'path';
|
|
12
|
-
import { DOMParser } from '@xmldom/xmldom';
|
|
13
|
-
import { EventImporterGPX } from './importer.gpx';
|
|
14
|
-
describe('EventImporterGPX Integration', () => {
|
|
15
|
-
// Go up 5 levels from src/events/adapters/importers/gpx -> sports-lib root
|
|
16
|
-
const samplesDir = path.resolve(__dirname, '../../../../../samples/gpx');
|
|
17
|
-
it('should parse all sample gpx files', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
18
|
-
if (!fs.existsSync(samplesDir)) {
|
|
19
|
-
console.warn(`Samples directory not found at ${samplesDir}. Skipping integration tests.`);
|
|
20
|
-
return;
|
|
21
|
-
}
|
|
22
|
-
const files = fs.readdirSync(samplesDir).filter(f => f.endsWith('.gpx'));
|
|
23
|
-
if (files.length === 0) {
|
|
24
|
-
console.warn('No .gpx files found in samples directory.');
|
|
25
|
-
return;
|
|
26
|
-
}
|
|
27
|
-
console.log(`Found ${files.length} .gpx files to test:`, files);
|
|
28
|
-
for (const file of files) {
|
|
29
|
-
const filePath = path.join(samplesDir, file);
|
|
30
|
-
const fileString = fs.readFileSync(filePath, 'utf-8');
|
|
31
|
-
try {
|
|
32
|
-
// Pass DOMParser constructor as 2nd argument
|
|
33
|
-
const event = yield EventImporterGPX.getFromString(fileString, DOMParser, undefined, file);
|
|
34
|
-
expect(event).toBeDefined();
|
|
35
|
-
expect(event.getActivities().length).toBeGreaterThan(0);
|
|
36
|
-
console.log(`✅ Successfully parsed ${file}`);
|
|
37
|
-
}
|
|
38
|
-
catch (error) {
|
|
39
|
-
console.error(`❌ Failed to parse ${file}:`, error);
|
|
40
|
-
throw error;
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
}));
|
|
44
|
-
});
|
|
@@ -1,102 +0,0 @@
|
|
|
1
|
-
import { Activity } from '../../../../activities/activity';
|
|
2
|
-
import { Creator } from '../../../../creators/creator';
|
|
3
|
-
import { Event } from '../../../event';
|
|
4
|
-
import { ActivityTypes, StravaGPXTypes } from '../../../../activities/activity.types';
|
|
5
|
-
import { GPXSampleMapper } from './importer.gpx.mapper';
|
|
6
|
-
import { isNumberOrString } from '../../../utilities/helpers';
|
|
7
|
-
import { EventUtilities } from '../../../utilities/event.utilities';
|
|
8
|
-
import { GXParser } from './gx-parser';
|
|
9
|
-
import { DataDuration } from '../../../../data/data.duration';
|
|
10
|
-
import { DataTimerTime } from '../../../../data/data.timer-time';
|
|
11
|
-
import { FileType } from '../../file-type.enum';
|
|
12
|
-
import { ActivityParsingOptions } from '../../../../activities/activity-parsing-options';
|
|
13
|
-
import { EmptyEventLibError } from '../../../../errors/empty-event-sports-libs.error';
|
|
14
|
-
export class EventImporterGPX {
|
|
15
|
-
static getFromString(gpx, domParser, options = ActivityParsingOptions.DEFAULT, name = 'New Event') {
|
|
16
|
-
return new Promise((resolve, reject) => {
|
|
17
|
-
// debugger
|
|
18
|
-
const parsedGPX = new GXParser(gpx, domParser);
|
|
19
|
-
const track = parsedGPX.trk || parsedGPX.rte;
|
|
20
|
-
if (!(track === null || track === void 0 ? void 0 : track.length)) {
|
|
21
|
-
reject(new EmptyEventLibError());
|
|
22
|
-
}
|
|
23
|
-
const activities = track.reduce((activities, trackOrRoute) => {
|
|
24
|
-
var _a, _b;
|
|
25
|
-
// Get the samples
|
|
26
|
-
let samples = [];
|
|
27
|
-
let isActivity = false;
|
|
28
|
-
if (trackOrRoute.trkseg) {
|
|
29
|
-
samples = trackOrRoute.trkseg.reduce((trkptArray, trkseg) => {
|
|
30
|
-
if (!trkseg.trkpt) {
|
|
31
|
-
return trkptArray;
|
|
32
|
-
}
|
|
33
|
-
return trkptArray.concat(trkseg.trkpt);
|
|
34
|
-
}, []);
|
|
35
|
-
// Determine if it's a route. The samples will most probably be missing the time
|
|
36
|
-
isActivity = !!((_a = samples[0]) === null || _a === void 0 ? void 0 : _a.time);
|
|
37
|
-
}
|
|
38
|
-
else if (trackOrRoute.rtept) {
|
|
39
|
-
samples = trackOrRoute.rtept;
|
|
40
|
-
}
|
|
41
|
-
// Sort the points if its only an activity
|
|
42
|
-
if (isActivity) {
|
|
43
|
-
// Filter samples having time data only for upcoming sort
|
|
44
|
-
samples = samples.filter(sample => {
|
|
45
|
-
return !!sample.time;
|
|
46
|
-
});
|
|
47
|
-
// Sort samples !
|
|
48
|
-
samples.sort((sampleA, sampleB) => {
|
|
49
|
-
return +new Date(sampleA.time[0]) - +new Date(sampleB.time[0]);
|
|
50
|
-
});
|
|
51
|
-
}
|
|
52
|
-
// Create an activity. Set the dates depending on route etc
|
|
53
|
-
const startDate = new Date(isActivity ? samples[0].time[0] : new Date());
|
|
54
|
-
// @todo for routes add a separate parser
|
|
55
|
-
const endDate = isActivity
|
|
56
|
-
? new Date(samples[samples.length - 1].time[0])
|
|
57
|
-
: new Date(startDate.getTime() + (samples.length > 0 ? samples.length - 1 : 0) * 1000);
|
|
58
|
-
let activityType = isActivity ? ActivityTypes.unknown : ActivityTypes.route;
|
|
59
|
-
if (trackOrRoute.type && ActivityTypes[trackOrRoute.type]) {
|
|
60
|
-
activityType = ActivityTypes[trackOrRoute.type];
|
|
61
|
-
}
|
|
62
|
-
else if (trackOrRoute.type && trackOrRoute.type[0] && parsedGPX.creator.match(/StravaGPX/gi) !== null) {
|
|
63
|
-
const stravaGpxTypeId = parseInt(trackOrRoute.type[0], 10);
|
|
64
|
-
const typeFound = StravaGPXTypes.map.get(stravaGpxTypeId);
|
|
65
|
-
if (typeFound) {
|
|
66
|
-
activityType = typeFound;
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
const activityName = ((_b = trackOrRoute.name) === null || _b === void 0 ? void 0 : _b[0]) || '';
|
|
70
|
-
const activity = new Activity(startDate, endDate, activityType, new Creator(parsedGPX.creator, undefined, parsedGPX.version), options, activityName);
|
|
71
|
-
// Setup sample info which could be use when getting sample values
|
|
72
|
-
const hasPowerMeter = samples.findIndex(sample => { var _a; return (_a = sample.extensions) === null || _a === void 0 ? void 0 : _a.find((ext) => { var _a; return (_a = ext.power) === null || _a === void 0 ? void 0 : _a.length; }); }) !== -1;
|
|
73
|
-
const samplesInfo = { hasPowerMeter: hasPowerMeter };
|
|
74
|
-
// Match
|
|
75
|
-
GPXSampleMapper.forEach(sampleMapping => {
|
|
76
|
-
const subjectSamples = (samples.filter((sample) => isNumberOrString(sampleMapping.getSampleValue(sample, samplesInfo))));
|
|
77
|
-
if (subjectSamples.length) {
|
|
78
|
-
activity.addStream(activity.createStream(sampleMapping.dataType));
|
|
79
|
-
subjectSamples.forEach((subjectSample, index) => {
|
|
80
|
-
activity.addDataToStream(sampleMapping.dataType, isActivity ? new Date(subjectSample.time[0]) : new Date(activity.startDate.getTime() + index * 1000), sampleMapping.getSampleValue(subjectSample, samplesInfo));
|
|
81
|
-
});
|
|
82
|
-
}
|
|
83
|
-
});
|
|
84
|
-
// Compute moving time, timer time and elapsed time
|
|
85
|
-
const elapsedTime = (activity.endDate.getTime() - activity.startDate.getTime()) / 1000;
|
|
86
|
-
const timerTime = elapsedTime;
|
|
87
|
-
// Apply stats
|
|
88
|
-
activity.addStat(new DataDuration(elapsedTime));
|
|
89
|
-
activity.addStat(new DataTimerTime(timerTime));
|
|
90
|
-
activities.push(activity);
|
|
91
|
-
return activities;
|
|
92
|
-
}, []);
|
|
93
|
-
const event = new Event(name, activities[0].startDate, activities[activities.length - 1].endDate, FileType.GPX);
|
|
94
|
-
activities.forEach(activity => {
|
|
95
|
-
event.addActivity(activity);
|
|
96
|
-
});
|
|
97
|
-
// generate global stats
|
|
98
|
-
EventUtilities.generateStatsForAll(event);
|
|
99
|
-
resolve(event);
|
|
100
|
-
});
|
|
101
|
-
}
|
|
102
|
-
}
|
|
@@ -1,142 +0,0 @@
|
|
|
1
|
-
import { DataLatitudeDegrees } from '../../../../data/data.latitude-degrees';
|
|
2
|
-
import { DataAltitude } from '../../../../data/data.altitude';
|
|
3
|
-
import { DataHeartRate } from '../../../../data/data.heart-rate';
|
|
4
|
-
import { DataCadence } from '../../../../data/data.cadence';
|
|
5
|
-
import { DataTemperature } from '../../../../data/data.temperature';
|
|
6
|
-
import { DataDistance } from '../../../../data/data.distance';
|
|
7
|
-
import { DataSeaLevelPressure } from '../../../../data/data.sea-level-pressure';
|
|
8
|
-
import { DataSpeed } from '../../../../data/data.speed';
|
|
9
|
-
import { DataVerticalSpeed } from '../../../../data/data.vertical-speed';
|
|
10
|
-
import { DataPower } from '../../../../data/data.power';
|
|
11
|
-
import { DataLongitudeDegrees } from '../../../../data/data.longitude-degrees';
|
|
12
|
-
import { isNumberOrString } from '../../../utilities/helpers';
|
|
13
|
-
export const GPXSampleMapper = [
|
|
14
|
-
{
|
|
15
|
-
dataType: DataLatitudeDegrees.type,
|
|
16
|
-
getSampleValue: sample => Number(sample.lat)
|
|
17
|
-
},
|
|
18
|
-
{
|
|
19
|
-
dataType: DataLongitudeDegrees.type,
|
|
20
|
-
getSampleValue: sample => Number(sample.lon)
|
|
21
|
-
},
|
|
22
|
-
{
|
|
23
|
-
dataType: DataAltitude.type,
|
|
24
|
-
getSampleValue: sample => (sample.ele ? Number(sample.ele[0]) : null)
|
|
25
|
-
},
|
|
26
|
-
{
|
|
27
|
-
dataType: DataHeartRate.type,
|
|
28
|
-
getSampleValue: sample => {
|
|
29
|
-
// debugger;
|
|
30
|
-
if (!sample.extensions || !sample.extensions.length) {
|
|
31
|
-
return null;
|
|
32
|
-
}
|
|
33
|
-
if (sample.extensions[0].heartrate && isNumberOrString(sample.extensions[0].heartrate[0])) {
|
|
34
|
-
return Number(sample.extensions[0].heartrate[0]);
|
|
35
|
-
}
|
|
36
|
-
if (sample.extensions[0].TrackPointExtension &&
|
|
37
|
-
sample.extensions[0].TrackPointExtension[0] &&
|
|
38
|
-
sample.extensions[0].TrackPointExtension[0].hr) {
|
|
39
|
-
return Number(sample.extensions[0].TrackPointExtension[0].hr[0]);
|
|
40
|
-
}
|
|
41
|
-
return null;
|
|
42
|
-
}
|
|
43
|
-
},
|
|
44
|
-
{
|
|
45
|
-
dataType: DataCadence.type,
|
|
46
|
-
getSampleValue: sample => {
|
|
47
|
-
// debugger;
|
|
48
|
-
if (!sample.extensions || !sample.extensions.length) {
|
|
49
|
-
return null;
|
|
50
|
-
}
|
|
51
|
-
if (sample.extensions[0].cadence && isNumberOrString(sample.extensions[0].cadence[0])) {
|
|
52
|
-
return Number(sample.extensions[0].cadence[0]);
|
|
53
|
-
}
|
|
54
|
-
if (sample.extensions[0].TrackPointExtension &&
|
|
55
|
-
sample.extensions[0].TrackPointExtension[0] &&
|
|
56
|
-
sample.extensions[0].TrackPointExtension[0].cad) {
|
|
57
|
-
return Number(sample.extensions[0].TrackPointExtension[0].cad[0]);
|
|
58
|
-
}
|
|
59
|
-
return null;
|
|
60
|
-
}
|
|
61
|
-
},
|
|
62
|
-
{
|
|
63
|
-
dataType: DataTemperature.type,
|
|
64
|
-
getSampleValue: sample => {
|
|
65
|
-
// debugger;
|
|
66
|
-
if (!sample.extensions || !sample.extensions.length) {
|
|
67
|
-
return null;
|
|
68
|
-
}
|
|
69
|
-
if (sample.extensions[0].temp && isNumberOrString(sample.extensions[0].temp[0])) {
|
|
70
|
-
return Number(sample.extensions[0].temp[0]);
|
|
71
|
-
}
|
|
72
|
-
if (sample.extensions[0].TrackPointExtension &&
|
|
73
|
-
sample.extensions[0].TrackPointExtension[0] &&
|
|
74
|
-
sample.extensions[0].TrackPointExtension[0].atemp) {
|
|
75
|
-
return Number(sample.extensions[0].TrackPointExtension[0].atemp[0]);
|
|
76
|
-
}
|
|
77
|
-
return null;
|
|
78
|
-
}
|
|
79
|
-
},
|
|
80
|
-
{
|
|
81
|
-
dataType: DataDistance.type,
|
|
82
|
-
getSampleValue: sample => {
|
|
83
|
-
if (!sample.extensions || !sample.extensions.length) {
|
|
84
|
-
return null;
|
|
85
|
-
}
|
|
86
|
-
if (sample.extensions[0].distance && isNumberOrString(sample.extensions[0].distance[0])) {
|
|
87
|
-
return Number(sample.extensions[0].distance[0]);
|
|
88
|
-
}
|
|
89
|
-
return null;
|
|
90
|
-
}
|
|
91
|
-
},
|
|
92
|
-
{
|
|
93
|
-
dataType: DataSeaLevelPressure.type,
|
|
94
|
-
getSampleValue: sample => {
|
|
95
|
-
if (!sample.extensions || !sample.extensions.length) {
|
|
96
|
-
return null;
|
|
97
|
-
}
|
|
98
|
-
if (sample.extensions[0].seaLevelPressure && isNumberOrString(sample.extensions[0].seaLevelPressure[0])) {
|
|
99
|
-
return Number(sample.extensions[0].seaLevelPressure[0]);
|
|
100
|
-
}
|
|
101
|
-
return null;
|
|
102
|
-
}
|
|
103
|
-
},
|
|
104
|
-
{
|
|
105
|
-
dataType: DataSpeed.type,
|
|
106
|
-
getSampleValue: sample => {
|
|
107
|
-
if (!sample.extensions || !sample.extensions.length) {
|
|
108
|
-
return null;
|
|
109
|
-
}
|
|
110
|
-
if (sample.extensions[0].speed && isNumberOrString(sample.extensions[0].speed[0])) {
|
|
111
|
-
return Number(sample.extensions[0].speed[0]);
|
|
112
|
-
}
|
|
113
|
-
return null;
|
|
114
|
-
}
|
|
115
|
-
},
|
|
116
|
-
{
|
|
117
|
-
dataType: DataVerticalSpeed.type,
|
|
118
|
-
getSampleValue: sample => {
|
|
119
|
-
if (!sample.extensions || !sample.extensions.length) {
|
|
120
|
-
return null;
|
|
121
|
-
}
|
|
122
|
-
if (sample.extensions[0].verticalSpeed && isNumberOrString(sample.extensions[0].verticalSpeed[0])) {
|
|
123
|
-
return Number(sample.extensions[0].verticalSpeed[0]);
|
|
124
|
-
}
|
|
125
|
-
return null;
|
|
126
|
-
}
|
|
127
|
-
},
|
|
128
|
-
{
|
|
129
|
-
dataType: DataPower.type,
|
|
130
|
-
getSampleValue: (sample, sampleInfo) => {
|
|
131
|
-
var _a;
|
|
132
|
-
let watts = null;
|
|
133
|
-
if (((_a = sample.extensions) === null || _a === void 0 ? void 0 : _a.length) && sample.extensions[0].power && isNumberOrString(sample.extensions[0].power[0])) {
|
|
134
|
-
watts = Number(sample.extensions[0].power[0]);
|
|
135
|
-
}
|
|
136
|
-
// Ensure power stream compliance when in some cases power sample field could be missing even if others samples have it
|
|
137
|
-
// Just set watts to 0 when this happen
|
|
138
|
-
// Case example: ride file "7555261629.gpx" from integration tests
|
|
139
|
-
return (sampleInfo === null || sampleInfo === void 0 ? void 0 : sampleInfo.hasPowerMeter) ? watts || 0 : null;
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
];
|
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
-
});
|
|
9
|
-
};
|
|
10
|
-
import { EventImporterGPX } from './importer.gpx';
|
|
11
|
-
import xmldom from '@xmldom/xmldom';
|
|
12
|
-
describe('importer.gpx', () => {
|
|
13
|
-
it('parses gpx without name', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
14
|
-
const gpxString = `<?xml version="1.0" encoding="UTF-8"?>
|
|
15
|
-
<gpx creator="Garmin Connect" version="1.1"
|
|
16
|
-
xsi:schemaLocation="http://www.topografix.com/GPX/1/1 http://www.topografix.com/GPX/11.xsd"
|
|
17
|
-
xmlns:ns3="http://www.garmin.com/xmlschemas/TrackPointExtension/v1"
|
|
18
|
-
xmlns="http://www.topografix.com/GPX/1/1"
|
|
19
|
-
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:ns2="http://www.garmin.com/xmlschemas/GpxExtensions/v3">
|
|
20
|
-
<metadata>
|
|
21
|
-
<link href="connect.garmin.com">
|
|
22
|
-
<text>Garmin Connect</text>
|
|
23
|
-
</link>
|
|
24
|
-
<time>2019-09-29T13:58:25.000Z</time>
|
|
25
|
-
</metadata>
|
|
26
|
-
<trk>
|
|
27
|
-
<type>road_biking</type>
|
|
28
|
-
</trk>
|
|
29
|
-
</gpx> `;
|
|
30
|
-
const result = yield EventImporterGPX.getFromString(gpxString, xmldom.DOMParser);
|
|
31
|
-
expect(result.getFirstActivity().name).toEqual('');
|
|
32
|
-
}));
|
|
33
|
-
it('parses gpx with name', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
34
|
-
const gpxString = `<?xml version="1.0" encoding="UTF-8"?>
|
|
35
|
-
<gpx creator="Garmin Connect" version="1.1"
|
|
36
|
-
xsi:schemaLocation="http://www.topografix.com/GPX/1/1 http://www.topografix.com/GPX/11.xsd"
|
|
37
|
-
xmlns:ns3="http://www.garmin.com/xmlschemas/TrackPointExtension/v1"
|
|
38
|
-
xmlns="http://www.topografix.com/GPX/1/1"
|
|
39
|
-
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:ns2="http://www.garmin.com/xmlschemas/GpxExtensions/v3">
|
|
40
|
-
<metadata>
|
|
41
|
-
<link href="connect.garmin.com">
|
|
42
|
-
<text>Garmin Connect</text>
|
|
43
|
-
</link>
|
|
44
|
-
<time>2019-09-29T13:58:25.000Z</time>
|
|
45
|
-
</metadata>
|
|
46
|
-
<trk>
|
|
47
|
-
<name>Meylan Road Cycling</name>
|
|
48
|
-
<type>road_biking</type>
|
|
49
|
-
</trk>
|
|
50
|
-
</gpx> `;
|
|
51
|
-
const result = yield EventImporterGPX.getFromString(gpxString, xmldom.DOMParser);
|
|
52
|
-
expect(result.getFirstActivity().name).toEqual('Meylan Road Cycling');
|
|
53
|
-
}));
|
|
54
|
-
it('parses route.gpx from samples', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
55
|
-
const fs = yield import('fs');
|
|
56
|
-
const path = yield import('path');
|
|
57
|
-
const samplesDir = path.resolve(__dirname, '../../../../../samples/gpx');
|
|
58
|
-
const filePath = path.join(samplesDir, 'route.gpx');
|
|
59
|
-
const fileString = fs.readFileSync(filePath, 'utf-8');
|
|
60
|
-
const result = yield EventImporterGPX.getFromString(fileString, xmldom.DOMParser);
|
|
61
|
-
expect(result.getActivities().length).toBeGreaterThan(0);
|
|
62
|
-
const activity = result.getFirstActivity();
|
|
63
|
-
expect(activity.type).toEqual('Route');
|
|
64
|
-
const distance = activity.getStat('Distance');
|
|
65
|
-
expect(distance).toBeDefined();
|
|
66
|
-
expect(distance.getValue()).toBeGreaterThan(0);
|
|
67
|
-
// Check if the number of samples matches the number of points in the GPX
|
|
68
|
-
const latStream = activity.getStream('Latitude');
|
|
69
|
-
expect(latStream.getData().length).toBe(2987); // I counted 2987 rtept earlier
|
|
70
|
-
}));
|
|
71
|
-
});
|
|
@@ -1,160 +0,0 @@
|
|
|
1
|
-
import { Event } from '../../../event';
|
|
2
|
-
import { Activity } from '../../../../activities/activity';
|
|
3
|
-
import { Lap } from '../../../../laps/lap';
|
|
4
|
-
import { Creator } from '../../../../creators/creator';
|
|
5
|
-
import { IntensityZones } from '../../../../intensity-zones/intensity-zones';
|
|
6
|
-
import { DynamicDataLoader } from '../../../../data/data.store';
|
|
7
|
-
import { LapTypes } from '../../../../laps/lap.types';
|
|
8
|
-
import { ActivityTypes } from '../../../../activities/activity.types';
|
|
9
|
-
import { Stream } from '../../../../streams/stream';
|
|
10
|
-
import { DataIBI } from '../../../../data/data.ibi';
|
|
11
|
-
import { IBIStream } from '../../../../streams/ibi-stream';
|
|
12
|
-
import { Device } from '../../../../activities/devices/device';
|
|
13
|
-
import { DataTime } from '../../../../data/data.time';
|
|
14
|
-
export class EventImporterJSON {
|
|
15
|
-
static getEventFromJSON(json) {
|
|
16
|
-
const event = new Event(json.name, new Date(json.startDate), new Date(json.endDate), json.srcFileType, json.privacy, json.description || undefined, json.isMerge || false);
|
|
17
|
-
Object.keys(json.stats).forEach((statName) => {
|
|
18
|
-
event.addStat(DynamicDataLoader.getDataInstanceFromDataType(statName, json.stats[statName]));
|
|
19
|
-
});
|
|
20
|
-
return event;
|
|
21
|
-
}
|
|
22
|
-
static getCreatorFromJSON(json) {
|
|
23
|
-
const creator = new Creator(json.name || 'Unknown Device');
|
|
24
|
-
if (json.hwInfo) {
|
|
25
|
-
creator.hwInfo = json.hwInfo;
|
|
26
|
-
}
|
|
27
|
-
if (json.swInfo) {
|
|
28
|
-
creator.swInfo = json.swInfo;
|
|
29
|
-
}
|
|
30
|
-
if (json.serialNumber) {
|
|
31
|
-
creator.serialNumber = json.serialNumber;
|
|
32
|
-
}
|
|
33
|
-
if (json.manufacturer) {
|
|
34
|
-
creator.manufacturer = json.manufacturer;
|
|
35
|
-
}
|
|
36
|
-
if (json.isRecognized) {
|
|
37
|
-
creator.isRecognized = json.isRecognized;
|
|
38
|
-
}
|
|
39
|
-
if (json.productId) {
|
|
40
|
-
creator.productId = json.productId;
|
|
41
|
-
}
|
|
42
|
-
if (json.devices && json.devices.length) {
|
|
43
|
-
json.devices.forEach(jsonDevice => creator.devices.push(this.getDeviceFromJSON(jsonDevice)));
|
|
44
|
-
}
|
|
45
|
-
return creator;
|
|
46
|
-
}
|
|
47
|
-
static getDeviceFromJSON(json) {
|
|
48
|
-
const device = new Device(json.type);
|
|
49
|
-
if (json.index) {
|
|
50
|
-
device.index = json.index;
|
|
51
|
-
}
|
|
52
|
-
if (json.name) {
|
|
53
|
-
device.name = json.name;
|
|
54
|
-
}
|
|
55
|
-
if (json.batteryStatus) {
|
|
56
|
-
device.batteryStatus = json.batteryStatus;
|
|
57
|
-
}
|
|
58
|
-
if (json.batteryLevel) {
|
|
59
|
-
device.batteryLevel = json.batteryLevel;
|
|
60
|
-
}
|
|
61
|
-
if (json.batteryVoltage) {
|
|
62
|
-
device.batteryVoltage = json.batteryVoltage;
|
|
63
|
-
}
|
|
64
|
-
if (json.manufacturer) {
|
|
65
|
-
device.manufacturer = json.manufacturer;
|
|
66
|
-
}
|
|
67
|
-
if (json.serialNumber) {
|
|
68
|
-
device.serialNumber = json.serialNumber;
|
|
69
|
-
}
|
|
70
|
-
if (json.product) {
|
|
71
|
-
device.product = json.product;
|
|
72
|
-
}
|
|
73
|
-
if (json.swInfo) {
|
|
74
|
-
device.swInfo = json.swInfo;
|
|
75
|
-
}
|
|
76
|
-
if (json.hwInfo) {
|
|
77
|
-
device.hwInfo = json.hwInfo;
|
|
78
|
-
}
|
|
79
|
-
if (json.antDeviceNumber) {
|
|
80
|
-
device.antDeviceNumber = json.antDeviceNumber;
|
|
81
|
-
}
|
|
82
|
-
if (json.antTransmissionType) {
|
|
83
|
-
device.antTransmissionType = json.antTransmissionType;
|
|
84
|
-
}
|
|
85
|
-
if (json.antNetwork) {
|
|
86
|
-
device.antNetwork = json.antNetwork;
|
|
87
|
-
}
|
|
88
|
-
if (json.sourceType) {
|
|
89
|
-
device.sourceType = json.sourceType;
|
|
90
|
-
}
|
|
91
|
-
if (json.cumOperatingTime) {
|
|
92
|
-
device.cumOperatingTime = json.cumOperatingTime;
|
|
93
|
-
}
|
|
94
|
-
return device;
|
|
95
|
-
}
|
|
96
|
-
static getLapFromJSON(json, lapIndex) {
|
|
97
|
-
const lap = new Lap(new Date(json.startDate), new Date(json.endDate), lapIndex + 1, LapTypes[json.type]);
|
|
98
|
-
Object.keys(json.stats).forEach((statName) => {
|
|
99
|
-
lap.addStat(DynamicDataLoader.getDataInstanceFromDataType(statName, json.stats[statName]));
|
|
100
|
-
});
|
|
101
|
-
return lap;
|
|
102
|
-
}
|
|
103
|
-
static getStreamFromJSON(json) {
|
|
104
|
-
if (json.type === DataIBI.type) {
|
|
105
|
-
return new IBIStream(json.data);
|
|
106
|
-
}
|
|
107
|
-
return new Stream(json.type, json.data);
|
|
108
|
-
}
|
|
109
|
-
static getIntensityZonesFromJSON(json) {
|
|
110
|
-
const zones = new IntensityZones(json.type);
|
|
111
|
-
zones.zone1Duration = json.zone1Duration;
|
|
112
|
-
zones.zone2Duration = json.zone2Duration;
|
|
113
|
-
zones.zone2LowerLimit = json.zone2LowerLimit;
|
|
114
|
-
zones.zone3Duration = json.zone3Duration;
|
|
115
|
-
zones.zone3LowerLimit = json.zone3LowerLimit;
|
|
116
|
-
zones.zone4Duration = json.zone4Duration;
|
|
117
|
-
zones.zone4LowerLimit = json.zone4LowerLimit;
|
|
118
|
-
zones.zone5Duration = json.zone5Duration;
|
|
119
|
-
zones.zone5LowerLimit = json.zone5LowerLimit;
|
|
120
|
-
return zones;
|
|
121
|
-
}
|
|
122
|
-
static getActivityEventFromJSON(json) {
|
|
123
|
-
return (DynamicDataLoader.getDataInstanceFromDataType(Object.keys(json)[0], Object.values(json)[0]));
|
|
124
|
-
}
|
|
125
|
-
static getActivityFromJSON(json) {
|
|
126
|
-
const activity = new Activity(new Date(json.startDate), new Date(json.endDate), ActivityTypes[json.type], EventImporterJSON.getCreatorFromJSON(json.creator));
|
|
127
|
-
Object.keys(json.stats).forEach((statName) => {
|
|
128
|
-
activity.addStat(DynamicDataLoader.getDataInstanceFromDataType(statName, json.stats[statName]));
|
|
129
|
-
});
|
|
130
|
-
json.laps.forEach((lapJSON, index) => {
|
|
131
|
-
activity.addLap(EventImporterJSON.getLapFromJSON(lapJSON, index));
|
|
132
|
-
});
|
|
133
|
-
if (Array.isArray(json.streams)) {
|
|
134
|
-
json.streams.forEach((streamJson) => {
|
|
135
|
-
if (streamJson.type === DataTime.type) {
|
|
136
|
-
return;
|
|
137
|
-
}
|
|
138
|
-
activity.addStream(EventImporterJSON.getStreamFromJSON(streamJson));
|
|
139
|
-
});
|
|
140
|
-
}
|
|
141
|
-
else {
|
|
142
|
-
Object.keys(json.streams).forEach(streamKey => {
|
|
143
|
-
const streamJson = {
|
|
144
|
-
type: streamKey,
|
|
145
|
-
data: json.streams[streamKey]
|
|
146
|
-
};
|
|
147
|
-
activity.addStream(EventImporterJSON.getStreamFromJSON(streamJson));
|
|
148
|
-
});
|
|
149
|
-
}
|
|
150
|
-
json.intensityZones.forEach(intensityZonesJSON => {
|
|
151
|
-
activity.intensityZones.push(EventImporterJSON.getIntensityZonesFromJSON(intensityZonesJSON));
|
|
152
|
-
});
|
|
153
|
-
if (json.events) {
|
|
154
|
-
json.events.forEach(activityEvent => {
|
|
155
|
-
activity.addEvent(this.getActivityEventFromJSON(activityEvent));
|
|
156
|
-
});
|
|
157
|
-
}
|
|
158
|
-
return activity;
|
|
159
|
-
}
|
|
160
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,85 +0,0 @@
|
|
|
1
|
-
export var ImporterSuuntoActivityIds;
|
|
2
|
-
(function (ImporterSuuntoActivityIds) {
|
|
3
|
-
ImporterSuuntoActivityIds[ImporterSuuntoActivityIds["Not specified sport"] = 1] = "Not specified sport";
|
|
4
|
-
ImporterSuuntoActivityIds[ImporterSuuntoActivityIds["Multisport"] = 2] = "Multisport";
|
|
5
|
-
ImporterSuuntoActivityIds[ImporterSuuntoActivityIds["Run"] = 3] = "Run";
|
|
6
|
-
ImporterSuuntoActivityIds[ImporterSuuntoActivityIds["Cycling"] = 4] = "Cycling";
|
|
7
|
-
ImporterSuuntoActivityIds[ImporterSuuntoActivityIds["MountainBiking"] = 5] = "MountainBiking";
|
|
8
|
-
ImporterSuuntoActivityIds[ImporterSuuntoActivityIds["Swimming"] = 6] = "Swimming";
|
|
9
|
-
ImporterSuuntoActivityIds[ImporterSuuntoActivityIds["Skating"] = 8] = "Skating";
|
|
10
|
-
ImporterSuuntoActivityIds[ImporterSuuntoActivityIds["Aerobics"] = 9] = "Aerobics";
|
|
11
|
-
ImporterSuuntoActivityIds[ImporterSuuntoActivityIds["YogaPilates"] = 10] = "YogaPilates";
|
|
12
|
-
ImporterSuuntoActivityIds[ImporterSuuntoActivityIds["Trekking"] = 11] = "Trekking";
|
|
13
|
-
ImporterSuuntoActivityIds[ImporterSuuntoActivityIds["Walking"] = 12] = "Walking";
|
|
14
|
-
ImporterSuuntoActivityIds[ImporterSuuntoActivityIds["Sailing"] = 13] = "Sailing";
|
|
15
|
-
ImporterSuuntoActivityIds[ImporterSuuntoActivityIds["Kayaking"] = 14] = "Kayaking";
|
|
16
|
-
ImporterSuuntoActivityIds[ImporterSuuntoActivityIds["Rowing"] = 15] = "Rowing";
|
|
17
|
-
ImporterSuuntoActivityIds[ImporterSuuntoActivityIds["Climbing"] = 16] = "Climbing";
|
|
18
|
-
ImporterSuuntoActivityIds[ImporterSuuntoActivityIds["Indoorcycling"] = 17] = "Indoorcycling";
|
|
19
|
-
ImporterSuuntoActivityIds[ImporterSuuntoActivityIds["Circuit training"] = 18] = "Circuit training";
|
|
20
|
-
ImporterSuuntoActivityIds[ImporterSuuntoActivityIds["Triathlon"] = 19] = "Triathlon";
|
|
21
|
-
ImporterSuuntoActivityIds[ImporterSuuntoActivityIds["Alpine skiing"] = 20] = "Alpine skiing";
|
|
22
|
-
ImporterSuuntoActivityIds[ImporterSuuntoActivityIds["Snowboarding"] = 21] = "Snowboarding";
|
|
23
|
-
ImporterSuuntoActivityIds[ImporterSuuntoActivityIds["Crosscountry skiing"] = 22] = "Crosscountry skiing";
|
|
24
|
-
ImporterSuuntoActivityIds[ImporterSuuntoActivityIds["Weight training"] = 23] = "Weight training";
|
|
25
|
-
ImporterSuuntoActivityIds[ImporterSuuntoActivityIds["Basketball"] = 24] = "Basketball";
|
|
26
|
-
ImporterSuuntoActivityIds[ImporterSuuntoActivityIds["Soccer"] = 25] = "Soccer";
|
|
27
|
-
ImporterSuuntoActivityIds[ImporterSuuntoActivityIds["Ice Hockey"] = 26] = "Ice Hockey";
|
|
28
|
-
ImporterSuuntoActivityIds[ImporterSuuntoActivityIds["Volleyball"] = 27] = "Volleyball";
|
|
29
|
-
ImporterSuuntoActivityIds[ImporterSuuntoActivityIds["Football"] = 28] = "Football";
|
|
30
|
-
ImporterSuuntoActivityIds[ImporterSuuntoActivityIds["Softball"] = 29] = "Softball";
|
|
31
|
-
ImporterSuuntoActivityIds[ImporterSuuntoActivityIds["Cheerleading"] = 30] = "Cheerleading";
|
|
32
|
-
ImporterSuuntoActivityIds[ImporterSuuntoActivityIds["Baseball"] = 31] = "Baseball";
|
|
33
|
-
ImporterSuuntoActivityIds[ImporterSuuntoActivityIds["Tennis"] = 33] = "Tennis";
|
|
34
|
-
ImporterSuuntoActivityIds[ImporterSuuntoActivityIds["Badminton"] = 34] = "Badminton";
|
|
35
|
-
ImporterSuuntoActivityIds[ImporterSuuntoActivityIds["Table tennis"] = 35] = "Table tennis";
|
|
36
|
-
ImporterSuuntoActivityIds[ImporterSuuntoActivityIds["Racquet ball"] = 36] = "Racquet ball";
|
|
37
|
-
ImporterSuuntoActivityIds[ImporterSuuntoActivityIds["Squash"] = 37] = "Squash";
|
|
38
|
-
ImporterSuuntoActivityIds[ImporterSuuntoActivityIds["Combat sport"] = 38] = "Combat sport";
|
|
39
|
-
ImporterSuuntoActivityIds[ImporterSuuntoActivityIds["Boxing"] = 39] = "Boxing";
|
|
40
|
-
ImporterSuuntoActivityIds[ImporterSuuntoActivityIds["Floorball"] = 40] = "Floorball";
|
|
41
|
-
ImporterSuuntoActivityIds[ImporterSuuntoActivityIds["Scuba diving"] = 51] = "Scuba diving";
|
|
42
|
-
ImporterSuuntoActivityIds[ImporterSuuntoActivityIds["Free diving"] = 52] = "Free diving";
|
|
43
|
-
ImporterSuuntoActivityIds[ImporterSuuntoActivityIds["Snorkeling"] = 53] = "Snorkeling";
|
|
44
|
-
ImporterSuuntoActivityIds[ImporterSuuntoActivityIds["Surfing"] = 54] = "Surfing";
|
|
45
|
-
ImporterSuuntoActivityIds[ImporterSuuntoActivityIds["Swimrun"] = 55] = "Swimrun";
|
|
46
|
-
ImporterSuuntoActivityIds[ImporterSuuntoActivityIds["Duathlon"] = 56] = "Duathlon";
|
|
47
|
-
ImporterSuuntoActivityIds[ImporterSuuntoActivityIds["Aquathlon"] = 57] = "Aquathlon";
|
|
48
|
-
ImporterSuuntoActivityIds[ImporterSuuntoActivityIds["Adventure Racing"] = 61] = "Adventure Racing";
|
|
49
|
-
ImporterSuuntoActivityIds[ImporterSuuntoActivityIds["Bowling"] = 62] = "Bowling";
|
|
50
|
-
ImporterSuuntoActivityIds[ImporterSuuntoActivityIds["Cricket"] = 63] = "Cricket";
|
|
51
|
-
ImporterSuuntoActivityIds[ImporterSuuntoActivityIds["Crosstrainer"] = 64] = "Crosstrainer";
|
|
52
|
-
ImporterSuuntoActivityIds[ImporterSuuntoActivityIds["Dancing"] = 65] = "Dancing";
|
|
53
|
-
ImporterSuuntoActivityIds[ImporterSuuntoActivityIds["Golf"] = 66] = "Golf";
|
|
54
|
-
ImporterSuuntoActivityIds[ImporterSuuntoActivityIds["Gymnastics"] = 67] = "Gymnastics";
|
|
55
|
-
ImporterSuuntoActivityIds[ImporterSuuntoActivityIds["Handball"] = 68] = "Handball";
|
|
56
|
-
ImporterSuuntoActivityIds[ImporterSuuntoActivityIds["Horseback riding"] = 69] = "Horseback riding";
|
|
57
|
-
ImporterSuuntoActivityIds[ImporterSuuntoActivityIds["Ice Skating"] = 70] = "Ice Skating";
|
|
58
|
-
ImporterSuuntoActivityIds[ImporterSuuntoActivityIds["Indoor Rowing"] = 71] = "Indoor Rowing";
|
|
59
|
-
ImporterSuuntoActivityIds[ImporterSuuntoActivityIds["Canoeing"] = 72] = "Canoeing";
|
|
60
|
-
ImporterSuuntoActivityIds[ImporterSuuntoActivityIds["Motorsports"] = 73] = "Motorsports";
|
|
61
|
-
ImporterSuuntoActivityIds[ImporterSuuntoActivityIds["Mountaineering"] = 74] = "Mountaineering";
|
|
62
|
-
ImporterSuuntoActivityIds[ImporterSuuntoActivityIds["Orienteering"] = 75] = "Orienteering";
|
|
63
|
-
ImporterSuuntoActivityIds[ImporterSuuntoActivityIds["Rugby"] = 76] = "Rugby";
|
|
64
|
-
ImporterSuuntoActivityIds[ImporterSuuntoActivityIds["Ski Touring"] = 78] = "Ski Touring";
|
|
65
|
-
ImporterSuuntoActivityIds[ImporterSuuntoActivityIds["Stretching"] = 79] = "Stretching";
|
|
66
|
-
ImporterSuuntoActivityIds[ImporterSuuntoActivityIds["Telemark skiing"] = 80] = "Telemark skiing";
|
|
67
|
-
ImporterSuuntoActivityIds[ImporterSuuntoActivityIds["Track and Field"] = 81] = "Track and Field";
|
|
68
|
-
ImporterSuuntoActivityIds[ImporterSuuntoActivityIds["Trail Running"] = 82] = "Trail Running";
|
|
69
|
-
ImporterSuuntoActivityIds[ImporterSuuntoActivityIds["Open water swimming"] = 83] = "Open water swimming";
|
|
70
|
-
ImporterSuuntoActivityIds[ImporterSuuntoActivityIds["Nordic walking"] = 84] = "Nordic walking";
|
|
71
|
-
ImporterSuuntoActivityIds[ImporterSuuntoActivityIds["Snow shoeing"] = 85] = "Snow shoeing";
|
|
72
|
-
ImporterSuuntoActivityIds[ImporterSuuntoActivityIds["Windsurfing/Surfing"] = 86] = "Windsurfing/Surfing";
|
|
73
|
-
ImporterSuuntoActivityIds[ImporterSuuntoActivityIds["Kettlebell"] = 87] = "Kettlebell";
|
|
74
|
-
ImporterSuuntoActivityIds[ImporterSuuntoActivityIds["Roller skiing"] = 88] = "Roller skiing";
|
|
75
|
-
ImporterSuuntoActivityIds[ImporterSuuntoActivityIds["Standup paddling (SUP)"] = 89] = "Standup paddling (SUP)";
|
|
76
|
-
ImporterSuuntoActivityIds[ImporterSuuntoActivityIds["Cross fit"] = 90] = "Cross fit";
|
|
77
|
-
ImporterSuuntoActivityIds[ImporterSuuntoActivityIds["Kitesurfing/Kiting"] = 91] = "Kitesurfing/Kiting";
|
|
78
|
-
ImporterSuuntoActivityIds[ImporterSuuntoActivityIds["Paragliding"] = 92] = "Paragliding";
|
|
79
|
-
ImporterSuuntoActivityIds[ImporterSuuntoActivityIds["Treadmill"] = 93] = "Treadmill";
|
|
80
|
-
ImporterSuuntoActivityIds[ImporterSuuntoActivityIds["Frisbee"] = 94] = "Frisbee";
|
|
81
|
-
ImporterSuuntoActivityIds[ImporterSuuntoActivityIds["Indoor training"] = 95] = "Indoor training";
|
|
82
|
-
ImporterSuuntoActivityIds[ImporterSuuntoActivityIds["Hiking"] = 96] = "Hiking";
|
|
83
|
-
ImporterSuuntoActivityIds[ImporterSuuntoActivityIds["Fishing"] = 97] = "Fishing";
|
|
84
|
-
ImporterSuuntoActivityIds[ImporterSuuntoActivityIds["Hunting"] = 98] = "Hunting";
|
|
85
|
-
})(ImporterSuuntoActivityIds || (ImporterSuuntoActivityIds = {}));
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
export const ImporterSuuntoDeviceNames = {
|
|
2
|
-
Athens: '0',
|
|
3
|
-
Paris: '1',
|
|
4
|
-
Berlin: '2',
|
|
5
|
-
Tokyo: '3',
|
|
6
|
-
Rome: '4',
|
|
7
|
-
Monza: '5',
|
|
8
|
-
Moscow: '6',
|
|
9
|
-
Kyoto: '7',
|
|
10
|
-
Lisbon: '8',
|
|
11
|
-
Ibiza: '9',
|
|
12
|
-
IbizaC: '9',
|
|
13
|
-
Lima: '9 Baroless',
|
|
14
|
-
Amsterdam: 'Spartan Ultra',
|
|
15
|
-
Brighton: 'Spartan Sport',
|
|
16
|
-
Cairo: 'Spartan WHR',
|
|
17
|
-
Forssa: 'Spartan Trainer',
|
|
18
|
-
Gdansk: 'Spartan WHR Baro',
|
|
19
|
-
'Spartan Sport Wrist HR Baro': 'Spartan WHR Baro',
|
|
20
|
-
Helsinki: '3 Fitness',
|
|
21
|
-
Ambit2: 'Ambit2',
|
|
22
|
-
'Ambit3 Sport': 'Ambit3 Sport',
|
|
23
|
-
'Ambit3 Peak': 'Ambit3 Peak',
|
|
24
|
-
'Ambit3 Run': 'Ambit3 Run',
|
|
25
|
-
'Ambit3 Vertical': 'Ambit3 Vertical'
|
|
26
|
-
};
|