@enyo-energy/energy-app-sdk 1.19.0 → 1.20.0

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/README.md CHANGED
@@ -212,8 +212,14 @@ Energy Apps follow a specific lifecycle managed by the enyo system:
212
212
  const energyApp = new EnergyApp();
213
213
 
214
214
  // Register startup callback
215
- energyApp.register((packageName, version) => {
216
- console.log(`${packageName} v${version} started`);
215
+ energyApp.register((packageName, version, channel, deviceId, environment) => {
216
+ console.log(`${packageName} v${version} started on ${deviceId} (${channel}, ${environment})`);
217
+
218
+ // e.g. skip hardware access when running in the developer portal simulation
219
+ if (environment === EnyoEnergyAppEnvironment.DeveloperPortalSimulation) {
220
+ console.log('Running in simulation - using mocked devices');
221
+ }
222
+
217
223
  energyApp.updateEnergyAppState(EnergyAppStateEnum.Running);
218
224
  });
219
225
 
@@ -14,7 +14,7 @@ const version_js_1 = require("./version.cjs");
14
14
  * @example
15
15
  * ```ts
16
16
  * const app = new EnergyApp();
17
- * app.register((packageName, version, channel, deviceId) => {
17
+ * app.register((packageName, version, channel, deviceId, environment) => {
18
18
  * // perform initialization
19
19
  * });
20
20
  * ```
@@ -51,6 +51,12 @@ class EnergyApp {
51
51
  updateEnergyAppState(state) {
52
52
  this.energyAppSdk.updateEnergyAppState(state);
53
53
  }
54
+ /**
55
+ * Registers the package with the enyo system.
56
+ * @param callback - Invoked once the package is initialized with the package name,
57
+ * the installed package version, the {@link EnyoPackageChannel} it was installed from,
58
+ * the id of the device it runs on and the {@link EnyoEnergyAppEnvironment} it is executed in
59
+ */
54
60
  register(callback) {
55
61
  // This registers the package with the enyo system
56
62
  this.energyAppSdk.register(callback);
@@ -19,6 +19,7 @@ import { EnergyAppOnboarding } from "./packages/energy-app-onboarding.cjs";
19
19
  import { EnergyAppOnboardingV2 } from "./packages/energy-app-onboarding-v2.cjs";
20
20
  import { EnergyAppTimeseries } from "./packages/energy-app-timeseries.cjs";
21
21
  import { EnyoPackageChannel } from "./enyo-package-channel.cjs";
22
+ import { EnyoEnergyAppEnvironment } from "./enyo-energy-app-environment.cjs";
22
23
  import { EnergyAppEnergyManager } from "./packages/energy-app-energy-manager.cjs";
23
24
  import { EnergyAppElectricityTariff } from "./packages/energy-app-electricity-tariff.cjs";
24
25
  import { EnergyAppWeatherForecasting } from "./packages/energy-app-weather-forecasting.cjs";
@@ -61,7 +62,7 @@ import { UseFetchOptions } from "./types/enyo-fetch.cjs";
61
62
  * @example
62
63
  * ```ts
63
64
  * const app = new EnergyApp();
64
- * app.register((packageName, version, channel, deviceId) => {
65
+ * app.register((packageName, version, channel, deviceId, environment) => {
65
66
  * // perform initialization
66
67
  * });
67
68
  * ```
@@ -79,7 +80,13 @@ export declare class EnergyApp implements EnyoEnergyAppSdk {
79
80
  */
80
81
  onNetworkStatusChanged(listener: (online: boolean) => void | Promise<void>): string;
81
82
  updateEnergyAppState(state: EnergyAppStateEnum): void;
82
- register(callback: (packageName: string, version: number, channel: EnyoPackageChannel, deviceId: string) => void | Promise<void>): void;
83
+ /**
84
+ * Registers the package with the enyo system.
85
+ * @param callback - Invoked once the package is initialized with the package name,
86
+ * the installed package version, the {@link EnyoPackageChannel} it was installed from,
87
+ * the id of the device it runs on and the {@link EnyoEnergyAppEnvironment} it is executed in
88
+ */
89
+ register(callback: (packageName: string, version: number, channel: EnyoPackageChannel, deviceId: string, environment: EnyoEnergyAppEnvironment) => void | Promise<void>): void;
83
90
  onShutdown(callback: () => void | Promise<void>): void;
84
91
  /**
85
92
  * Returns a `fetch` implementation provided by the runtime.
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.EnyoEnergyAppEnvironment = void 0;
4
+ /**
5
+ * Runtime environment an energy app is executed in.
6
+ *
7
+ * The environment is handed to the callback passed to `register()` so an app can
8
+ * adapt its behaviour, e.g. use verbose logging or mocked hardware access while
9
+ * developing, and skip anything that requires real hardware when it runs inside
10
+ * the developer portal simulation.
11
+ */
12
+ var EnyoEnergyAppEnvironment;
13
+ (function (EnyoEnergyAppEnvironment) {
14
+ /** Running on a real enyo device in development mode (e.g. a developer's test device). */
15
+ EnyoEnergyAppEnvironment["OnDeviceDevelopment"] = "on-device-development";
16
+ /** Running on a real enyo device in production, i.e. at a customer's site. */
17
+ EnyoEnergyAppEnvironment["OnDeviceProduction"] = "on-device-production";
18
+ /** Running inside the developer portal simulation, without real hardware attached. */
19
+ EnyoEnergyAppEnvironment["DeveloperPortalSimulation"] = "developer-portal-simulation";
20
+ })(EnyoEnergyAppEnvironment || (exports.EnyoEnergyAppEnvironment = EnyoEnergyAppEnvironment = {}));
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Runtime environment an energy app is executed in.
3
+ *
4
+ * The environment is handed to the callback passed to `register()` so an app can
5
+ * adapt its behaviour, e.g. use verbose logging or mocked hardware access while
6
+ * developing, and skip anything that requires real hardware when it runs inside
7
+ * the developer portal simulation.
8
+ */
9
+ export declare enum EnyoEnergyAppEnvironment {
10
+ /** Running on a real enyo device in development mode (e.g. a developer's test device). */
11
+ OnDeviceDevelopment = "on-device-development",
12
+ /** Running on a real enyo device in production, i.e. at a customer's site. */
13
+ OnDeviceProduction = "on-device-production",
14
+ /** Running inside the developer portal simulation, without real hardware attached. */
15
+ DeveloperPortalSimulation = "developer-portal-simulation"
16
+ }
@@ -18,6 +18,7 @@ import { EnergyAppOnboarding } from "./packages/energy-app-onboarding.cjs";
18
18
  import { EnergyAppOnboardingV2 } from "./packages/energy-app-onboarding-v2.cjs";
19
19
  import { EnergyAppTimeseries } from "./packages/energy-app-timeseries.cjs";
20
20
  import { EnyoPackageChannel } from "./enyo-package-channel.cjs";
21
+ import { EnyoEnergyAppEnvironment } from "./enyo-energy-app-environment.cjs";
21
22
  import { EnergyAppEnergyManager } from "./packages/energy-app-energy-manager.cjs";
22
23
  import { EnergyAppElectricityTariff } from "./packages/energy-app-electricity-tariff.cjs";
23
24
  import { EnergyAppWeatherForecasting } from "./packages/energy-app-weather-forecasting.cjs";
@@ -62,8 +63,13 @@ export declare enum EnergyAppStateEnum {
62
63
  * network operations, storage, and device communication.
63
64
  */
64
65
  export interface EnyoEnergyAppSdk {
65
- /** Register a callback that gets called when the package is initialized */
66
- register: (callback: (packageName: string, version: number, channel: EnyoPackageChannel, deviceId: string) => void | Promise<void>) => void;
66
+ /**
67
+ * Register a callback that gets called when the package is initialized.
68
+ * The callback receives the package name, its version, the release channel it
69
+ * was installed from, the id of the device it runs on and the
70
+ * {@link EnyoEnergyAppEnvironment} the app is executed in.
71
+ */
72
+ register: (callback: (packageName: string, version: number, channel: EnyoPackageChannel, deviceId: string, environment: EnyoEnergyAppEnvironment) => void | Promise<void>) => void;
67
73
  /** health check - returns the current date to check if alive */
68
74
  healthcheck: () => Date;
69
75
  /** Register a callback that gets called when the system is shutting down */
@@ -37,6 +37,7 @@ __exportStar(require("./implementations/network-devices/network-access-guard.cjs
37
37
  __exportStar(require("./implementations/network-devices/network-device-manager.cjs"), exports);
38
38
  __exportStar(require("./implementations/storage/storage-schedule-handler.cjs"), exports);
39
39
  __exportStar(require("./enyo-package-channel.cjs"), exports);
40
+ __exportStar(require("./enyo-energy-app-environment.cjs"), exports);
40
41
  __exportStar(require("./types/enyo-timeseries.cjs"), exports);
41
42
  __exportStar(require("./types/enyo-energy-manager.cjs"), exports);
42
43
  __exportStar(require("./packages/energy-app-energy-manager.cjs"), exports);
@@ -21,6 +21,7 @@ export * from './implementations/network-devices/network-access-guard.cjs';
21
21
  export * from './implementations/network-devices/network-device-manager.cjs';
22
22
  export * from './implementations/storage/storage-schedule-handler.cjs';
23
23
  export * from './enyo-package-channel.cjs';
24
+ export * from './enyo-energy-app-environment.cjs';
24
25
  export * from './types/enyo-timeseries.cjs';
25
26
  export * from './types/enyo-energy-manager.cjs';
26
27
  export * from './packages/energy-app-energy-manager.cjs';
@@ -9,7 +9,7 @@ exports.getSdkVersion = getSdkVersion;
9
9
  /**
10
10
  * Current version of the enyo Energy App SDK.
11
11
  */
12
- exports.SDK_VERSION = '1.19.0';
12
+ exports.SDK_VERSION = '1.20.0';
13
13
  /**
14
14
  * Gets the current SDK version.
15
15
  * @returns The semantic version string of the SDK
@@ -5,7 +5,7 @@
5
5
  /**
6
6
  * Current version of the enyo Energy App SDK.
7
7
  */
8
- export declare const SDK_VERSION = "1.19.0";
8
+ export declare const SDK_VERSION = "1.20.0";
9
9
  /**
10
10
  * Gets the current SDK version.
11
11
  * @returns The semantic version string of the SDK
@@ -19,6 +19,7 @@ import { EnergyAppOnboarding } from "./packages/energy-app-onboarding.js";
19
19
  import { EnergyAppOnboardingV2 } from "./packages/energy-app-onboarding-v2.js";
20
20
  import { EnergyAppTimeseries } from "./packages/energy-app-timeseries.js";
21
21
  import { EnyoPackageChannel } from "./enyo-package-channel.js";
22
+ import { EnyoEnergyAppEnvironment } from "./enyo-energy-app-environment.js";
22
23
  import { EnergyAppEnergyManager } from "./packages/energy-app-energy-manager.js";
23
24
  import { EnergyAppElectricityTariff } from "./packages/energy-app-electricity-tariff.js";
24
25
  import { EnergyAppWeatherForecasting } from "./packages/energy-app-weather-forecasting.js";
@@ -61,7 +62,7 @@ import { UseFetchOptions } from "./types/enyo-fetch.js";
61
62
  * @example
62
63
  * ```ts
63
64
  * const app = new EnergyApp();
64
- * app.register((packageName, version, channel, deviceId) => {
65
+ * app.register((packageName, version, channel, deviceId, environment) => {
65
66
  * // perform initialization
66
67
  * });
67
68
  * ```
@@ -79,7 +80,13 @@ export declare class EnergyApp implements EnyoEnergyAppSdk {
79
80
  */
80
81
  onNetworkStatusChanged(listener: (online: boolean) => void | Promise<void>): string;
81
82
  updateEnergyAppState(state: EnergyAppStateEnum): void;
82
- register(callback: (packageName: string, version: number, channel: EnyoPackageChannel, deviceId: string) => void | Promise<void>): void;
83
+ /**
84
+ * Registers the package with the enyo system.
85
+ * @param callback - Invoked once the package is initialized with the package name,
86
+ * the installed package version, the {@link EnyoPackageChannel} it was installed from,
87
+ * the id of the device it runs on and the {@link EnyoEnergyAppEnvironment} it is executed in
88
+ */
89
+ register(callback: (packageName: string, version: number, channel: EnyoPackageChannel, deviceId: string, environment: EnyoEnergyAppEnvironment) => void | Promise<void>): void;
83
90
  onShutdown(callback: () => void | Promise<void>): void;
84
91
  /**
85
92
  * Returns a `fetch` implementation provided by the runtime.
@@ -11,7 +11,7 @@ import { getSdkVersion } from "./version.js";
11
11
  * @example
12
12
  * ```ts
13
13
  * const app = new EnergyApp();
14
- * app.register((packageName, version, channel, deviceId) => {
14
+ * app.register((packageName, version, channel, deviceId, environment) => {
15
15
  * // perform initialization
16
16
  * });
17
17
  * ```
@@ -48,6 +48,12 @@ export class EnergyApp {
48
48
  updateEnergyAppState(state) {
49
49
  this.energyAppSdk.updateEnergyAppState(state);
50
50
  }
51
+ /**
52
+ * Registers the package with the enyo system.
53
+ * @param callback - Invoked once the package is initialized with the package name,
54
+ * the installed package version, the {@link EnyoPackageChannel} it was installed from,
55
+ * the id of the device it runs on and the {@link EnyoEnergyAppEnvironment} it is executed in
56
+ */
51
57
  register(callback) {
52
58
  // This registers the package with the enyo system
53
59
  this.energyAppSdk.register(callback);
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Runtime environment an energy app is executed in.
3
+ *
4
+ * The environment is handed to the callback passed to `register()` so an app can
5
+ * adapt its behaviour, e.g. use verbose logging or mocked hardware access while
6
+ * developing, and skip anything that requires real hardware when it runs inside
7
+ * the developer portal simulation.
8
+ */
9
+ export declare enum EnyoEnergyAppEnvironment {
10
+ /** Running on a real enyo device in development mode (e.g. a developer's test device). */
11
+ OnDeviceDevelopment = "on-device-development",
12
+ /** Running on a real enyo device in production, i.e. at a customer's site. */
13
+ OnDeviceProduction = "on-device-production",
14
+ /** Running inside the developer portal simulation, without real hardware attached. */
15
+ DeveloperPortalSimulation = "developer-portal-simulation"
16
+ }
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Runtime environment an energy app is executed in.
3
+ *
4
+ * The environment is handed to the callback passed to `register()` so an app can
5
+ * adapt its behaviour, e.g. use verbose logging or mocked hardware access while
6
+ * developing, and skip anything that requires real hardware when it runs inside
7
+ * the developer portal simulation.
8
+ */
9
+ export var EnyoEnergyAppEnvironment;
10
+ (function (EnyoEnergyAppEnvironment) {
11
+ /** Running on a real enyo device in development mode (e.g. a developer's test device). */
12
+ EnyoEnergyAppEnvironment["OnDeviceDevelopment"] = "on-device-development";
13
+ /** Running on a real enyo device in production, i.e. at a customer's site. */
14
+ EnyoEnergyAppEnvironment["OnDeviceProduction"] = "on-device-production";
15
+ /** Running inside the developer portal simulation, without real hardware attached. */
16
+ EnyoEnergyAppEnvironment["DeveloperPortalSimulation"] = "developer-portal-simulation";
17
+ })(EnyoEnergyAppEnvironment || (EnyoEnergyAppEnvironment = {}));
@@ -18,6 +18,7 @@ import { EnergyAppOnboarding } from "./packages/energy-app-onboarding.js";
18
18
  import { EnergyAppOnboardingV2 } from "./packages/energy-app-onboarding-v2.js";
19
19
  import { EnergyAppTimeseries } from "./packages/energy-app-timeseries.js";
20
20
  import { EnyoPackageChannel } from "./enyo-package-channel.js";
21
+ import { EnyoEnergyAppEnvironment } from "./enyo-energy-app-environment.js";
21
22
  import { EnergyAppEnergyManager } from "./packages/energy-app-energy-manager.js";
22
23
  import { EnergyAppElectricityTariff } from "./packages/energy-app-electricity-tariff.js";
23
24
  import { EnergyAppWeatherForecasting } from "./packages/energy-app-weather-forecasting.js";
@@ -62,8 +63,13 @@ export declare enum EnergyAppStateEnum {
62
63
  * network operations, storage, and device communication.
63
64
  */
64
65
  export interface EnyoEnergyAppSdk {
65
- /** Register a callback that gets called when the package is initialized */
66
- register: (callback: (packageName: string, version: number, channel: EnyoPackageChannel, deviceId: string) => void | Promise<void>) => void;
66
+ /**
67
+ * Register a callback that gets called when the package is initialized.
68
+ * The callback receives the package name, its version, the release channel it
69
+ * was installed from, the id of the device it runs on and the
70
+ * {@link EnyoEnergyAppEnvironment} the app is executed in.
71
+ */
72
+ register: (callback: (packageName: string, version: number, channel: EnyoPackageChannel, deviceId: string, environment: EnyoEnergyAppEnvironment) => void | Promise<void>) => void;
67
73
  /** health check - returns the current date to check if alive */
68
74
  healthcheck: () => Date;
69
75
  /** Register a callback that gets called when the system is shutting down */
package/dist/index.d.ts CHANGED
@@ -21,6 +21,7 @@ export * from './implementations/network-devices/network-access-guard.js';
21
21
  export * from './implementations/network-devices/network-device-manager.js';
22
22
  export * from './implementations/storage/storage-schedule-handler.js';
23
23
  export * from './enyo-package-channel.js';
24
+ export * from './enyo-energy-app-environment.js';
24
25
  export * from './types/enyo-timeseries.js';
25
26
  export * from './types/enyo-energy-manager.js';
26
27
  export * from './packages/energy-app-energy-manager.js';
package/dist/index.js CHANGED
@@ -21,6 +21,7 @@ export * from './implementations/network-devices/network-access-guard.js';
21
21
  export * from './implementations/network-devices/network-device-manager.js';
22
22
  export * from './implementations/storage/storage-schedule-handler.js';
23
23
  export * from './enyo-package-channel.js';
24
+ export * from './enyo-energy-app-environment.js';
24
25
  export * from './types/enyo-timeseries.js';
25
26
  export * from './types/enyo-energy-manager.js';
26
27
  export * from './packages/energy-app-energy-manager.js';
package/dist/version.d.ts CHANGED
@@ -5,7 +5,7 @@
5
5
  /**
6
6
  * Current version of the enyo Energy App SDK.
7
7
  */
8
- export declare const SDK_VERSION = "1.19.0";
8
+ export declare const SDK_VERSION = "1.20.0";
9
9
  /**
10
10
  * Gets the current SDK version.
11
11
  * @returns The semantic version string of the SDK
package/dist/version.js CHANGED
@@ -5,7 +5,7 @@
5
5
  /**
6
6
  * Current version of the enyo Energy App SDK.
7
7
  */
8
- export const SDK_VERSION = '1.19.0';
8
+ export const SDK_VERSION = '1.20.0';
9
9
  /**
10
10
  * Gets the current SDK version.
11
11
  * @returns The semantic version string of the SDK
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@enyo-energy/energy-app-sdk",
3
- "version": "1.19.0",
3
+ "version": "1.20.0",
4
4
  "description": "enyo Energy App SDK",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",