@enyo-energy/energy-app-sdk 0.0.163 → 0.0.165
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/dist/cjs/energy-app.cjs +8 -2
- package/dist/cjs/energy-app.d.cts +8 -1
- package/dist/cjs/enyo-energy-app-sdk.d.cts +3 -2
- package/dist/cjs/implementations/appliances/appliance-manager.cjs +15 -2
- package/dist/cjs/implementations/appliances/appliance-manager.d.cts +7 -0
- package/dist/cjs/index.cjs +1 -0
- package/dist/cjs/index.d.cts +1 -0
- package/dist/cjs/types/enyo-fetch.cjs +2 -0
- package/dist/cjs/types/enyo-fetch.d.cts +29 -0
- package/dist/cjs/version.cjs +1 -1
- package/dist/cjs/version.d.cts +1 -1
- package/dist/energy-app.d.ts +8 -1
- package/dist/energy-app.js +8 -2
- package/dist/enyo-energy-app-sdk.d.ts +3 -2
- package/dist/implementations/appliances/appliance-manager.d.ts +7 -0
- package/dist/implementations/appliances/appliance-manager.js +15 -2
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/types/enyo-fetch.d.ts +29 -0
- package/dist/types/enyo-fetch.js +1 -0
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +1 -1
package/dist/cjs/energy-app.cjs
CHANGED
|
@@ -60,8 +60,14 @@ class EnergyApp {
|
|
|
60
60
|
await callback();
|
|
61
61
|
});
|
|
62
62
|
}
|
|
63
|
-
|
|
64
|
-
|
|
63
|
+
/**
|
|
64
|
+
* Returns a `fetch` implementation provided by the runtime.
|
|
65
|
+
* @param options - Optional configuration (e.g. {@link TlsClientOptions} for mutual TLS).
|
|
66
|
+
* When `options.tls` is set the runtime binds a TLS-configured dispatcher to the fetch.
|
|
67
|
+
* @returns A `fetch` function that still passes through the runtime allow-list.
|
|
68
|
+
*/
|
|
69
|
+
useFetch(options) {
|
|
70
|
+
return this.energyAppSdk.useFetch(options);
|
|
65
71
|
}
|
|
66
72
|
useInterval() {
|
|
67
73
|
return this.energyAppSdk.useInterval();
|
|
@@ -37,6 +37,7 @@ import { EnergyAppGridConnectionPoint } from "./packages/energy-app-grid-connect
|
|
|
37
37
|
import { EnergyAppConfigurationManager } from "./packages/energy-app-configuration-manager.cjs";
|
|
38
38
|
import { EnergyAppApplianceEnergyManagerForecast } from "./packages/energy-app-appliance-energy-manager-forecast.cjs";
|
|
39
39
|
import { EnergyAppBattery } from "./packages/energy-app-battery.cjs";
|
|
40
|
+
import { UseFetchOptions } from "./types/enyo-fetch.cjs";
|
|
40
41
|
/**
|
|
41
42
|
* Concrete implementation of {@link EnyoEnergyAppSdk} that delegates every call
|
|
42
43
|
* to the runtime-provided `energyAppSdkInstance` global.
|
|
@@ -68,7 +69,13 @@ export declare class EnergyApp implements EnyoEnergyAppSdk {
|
|
|
68
69
|
updateEnergyAppState(state: EnergyAppStateEnum): void;
|
|
69
70
|
register(callback: (packageName: string, version: number, channel: EnyoPackageChannel, deviceId: string) => void | Promise<void>): void;
|
|
70
71
|
onShutdown(callback: () => void | Promise<void>): void;
|
|
71
|
-
|
|
72
|
+
/**
|
|
73
|
+
* Returns a `fetch` implementation provided by the runtime.
|
|
74
|
+
* @param options - Optional configuration (e.g. {@link TlsClientOptions} for mutual TLS).
|
|
75
|
+
* When `options.tls` is set the runtime binds a TLS-configured dispatcher to the fetch.
|
|
76
|
+
* @returns A `fetch` function that still passes through the runtime allow-list.
|
|
77
|
+
*/
|
|
78
|
+
useFetch(options?: UseFetchOptions): typeof fetch;
|
|
72
79
|
useInterval(): EnergyAppInterval;
|
|
73
80
|
useModbus(): EnergyAppModbus;
|
|
74
81
|
useNetworkDevices(): EnergyAppNetworkDevice;
|
|
@@ -36,6 +36,7 @@ import { EnergyAppGridConnectionPoint } from "./packages/energy-app-grid-connect
|
|
|
36
36
|
import { EnergyAppConfigurationManager } from "./packages/energy-app-configuration-manager.cjs";
|
|
37
37
|
import { EnergyAppApplianceEnergyManagerForecast } from "./packages/energy-app-appliance-energy-manager-forecast.cjs";
|
|
38
38
|
import { EnergyAppBattery } from "./packages/energy-app-battery.cjs";
|
|
39
|
+
import { UseFetchOptions } from "./types/enyo-fetch.cjs";
|
|
39
40
|
export declare enum EnergyAppStateEnum {
|
|
40
41
|
Launching = "launching",
|
|
41
42
|
Running = "running",
|
|
@@ -60,8 +61,8 @@ export interface EnyoEnergyAppSdk {
|
|
|
60
61
|
isSystemOnline: () => boolean;
|
|
61
62
|
/** Register a listener that gets called when the network status changes */
|
|
62
63
|
onNetworkStatusChanged: (listener: (online: boolean) => void | Promise<void>) => string;
|
|
63
|
-
/** Get the fetch API for HTTP requests */
|
|
64
|
-
useFetch: () => typeof fetch;
|
|
64
|
+
/** Get the fetch API for HTTP requests, optionally configured with TLS options */
|
|
65
|
+
useFetch: (options?: UseFetchOptions) => typeof fetch;
|
|
65
66
|
/** Get the interval management API */
|
|
66
67
|
useInterval: () => EnergyAppInterval;
|
|
67
68
|
/** Get the Modbus communication API */
|
|
@@ -96,6 +96,13 @@ class ApplianceManager {
|
|
|
96
96
|
* Note: the merge is one level deep. Nested objects inside a metadata sub-object
|
|
97
97
|
* are replaced, not merged.
|
|
98
98
|
*
|
|
99
|
+
* Update contract: an omitted optional field leaves the stored value unchanged.
|
|
100
|
+
* For the {@link MERGEABLE_METADATA_KEYS} this is enforced by the per-key merge
|
|
101
|
+
* below; for the other optional top-level fields (`availableFeatures`,
|
|
102
|
+
* `cloudPackageId`) the caller-facing {@link createOrUpdateAppliance} drops the
|
|
103
|
+
* key when the value is `undefined` so this spread cannot overwrite it. To clear
|
|
104
|
+
* or replace such a field, pass an explicit value (e.g. an empty array `[]`).
|
|
105
|
+
*
|
|
99
106
|
* @param existing The existing appliance data
|
|
100
107
|
* @param update The partial update data to merge
|
|
101
108
|
* @returns The merged appliance data (without `id`)
|
|
@@ -200,8 +207,14 @@ class ApplianceManager {
|
|
|
200
207
|
inverter: appliance.inverter,
|
|
201
208
|
temperatureSensor: appliance.temperatureSensor,
|
|
202
209
|
airConditioning: appliance.airConditioning,
|
|
203
|
-
|
|
204
|
-
|
|
210
|
+
// Conditionally spread the two optional top-level fields that are NOT
|
|
211
|
+
// covered by MERGEABLE_METADATA_KEYS. If they were always materialized
|
|
212
|
+
// as explicit keys, an omitted (undefined) value would clobber the
|
|
213
|
+
// stored value during mergeApplianceData's `{...existing, ...update}`
|
|
214
|
+
// spread on an update. `!== undefined` keeps an explicit `[]` (clear)
|
|
215
|
+
// while dropping omitted fields so the existing value is preserved.
|
|
216
|
+
...(appliance.cloudPackageId !== undefined && { cloudPackageId: appliance.cloudPackageId }),
|
|
217
|
+
...(appliance.availableFeatures !== undefined && { availableFeatures: appliance.availableFeatures }),
|
|
205
218
|
};
|
|
206
219
|
let applianceData = newApplianceData;
|
|
207
220
|
if (existingApplianceId) {
|
|
@@ -129,6 +129,13 @@ export declare class ApplianceManager {
|
|
|
129
129
|
* Note: the merge is one level deep. Nested objects inside a metadata sub-object
|
|
130
130
|
* are replaced, not merged.
|
|
131
131
|
*
|
|
132
|
+
* Update contract: an omitted optional field leaves the stored value unchanged.
|
|
133
|
+
* For the {@link MERGEABLE_METADATA_KEYS} this is enforced by the per-key merge
|
|
134
|
+
* below; for the other optional top-level fields (`availableFeatures`,
|
|
135
|
+
* `cloudPackageId`) the caller-facing {@link createOrUpdateAppliance} drops the
|
|
136
|
+
* key when the value is `undefined` so this spread cannot overwrite it. To clear
|
|
137
|
+
* or replace such a field, pass an explicit value (e.g. an empty array `[]`).
|
|
138
|
+
*
|
|
132
139
|
* @param existing The existing appliance data
|
|
133
140
|
* @param update The partial update data to merge
|
|
134
141
|
* @returns The merged appliance data (without `id`)
|
package/dist/cjs/index.cjs
CHANGED
|
@@ -102,3 +102,4 @@ __exportStar(require("./implementations/appliance-command-forecast/appliance-com
|
|
|
102
102
|
__exportStar(require("./implementations/energy-manager-diagnostics/energy-manager-diagnostics-validators.cjs"), exports);
|
|
103
103
|
__exportStar(require("./types/enyo-battery-state.cjs"), exports);
|
|
104
104
|
__exportStar(require("./packages/energy-app-battery.cjs"), exports);
|
|
105
|
+
__exportStar(require("./types/enyo-fetch.cjs"), exports);
|
package/dist/cjs/index.d.cts
CHANGED
|
@@ -86,3 +86,4 @@ export * from './implementations/appliance-command-forecast/appliance-command-fo
|
|
|
86
86
|
export * from './implementations/energy-manager-diagnostics/energy-manager-diagnostics-validators.cjs';
|
|
87
87
|
export * from './types/enyo-battery-state.cjs';
|
|
88
88
|
export * from './packages/energy-app-battery.cjs';
|
|
89
|
+
export * from './types/enyo-fetch.cjs';
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* TLS material for an outbound HTTPS connection made through {@link UseFetchOptions}.
|
|
3
|
+
*
|
|
4
|
+
* All certificate/key fields accept PEM as a UTF-8 string or a {@link Buffer}. When passed
|
|
5
|
+
* to `useFetch`, the runtime uses these values to build a TLS-configured dispatcher for the
|
|
6
|
+
* underlying fetch (e.g. for mutual TLS, custom trust anchors, or self-signed servers).
|
|
7
|
+
*/
|
|
8
|
+
export interface TlsClientOptions {
|
|
9
|
+
/** Client cert chain (PEM) presented during the TLS handshake (mutual TLS). */
|
|
10
|
+
cert?: string | Buffer;
|
|
11
|
+
/** Private key (PEM) for the client cert. */
|
|
12
|
+
key?: string | Buffer;
|
|
13
|
+
/** Trusted CA cert(s) (PEM) to validate the server. */
|
|
14
|
+
ca?: string | Buffer | Array<string | Buffer>;
|
|
15
|
+
/** When false, accept self-signed/untrusted server certs. Default true. */
|
|
16
|
+
rejectUnauthorized?: boolean;
|
|
17
|
+
/** Optional SNI / expected server hostname override. */
|
|
18
|
+
servername?: string;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Options accepted by `useFetch` to customize the returned `fetch` implementation.
|
|
22
|
+
*
|
|
23
|
+
* The returned fetch still passes through the runtime's origin allow-list; these options only
|
|
24
|
+
* add behavior (currently: TLS configuration) on top of that.
|
|
25
|
+
*/
|
|
26
|
+
export interface UseFetchOptions {
|
|
27
|
+
/** TLS / mutual-TLS configuration for outbound HTTPS requests. */
|
|
28
|
+
tls?: TlsClientOptions;
|
|
29
|
+
}
|
package/dist/cjs/version.cjs
CHANGED
|
@@ -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 = '0.0.
|
|
12
|
+
exports.SDK_VERSION = '0.0.165';
|
|
13
13
|
/**
|
|
14
14
|
* Gets the current SDK version.
|
|
15
15
|
* @returns The semantic version string of the SDK
|
package/dist/cjs/version.d.cts
CHANGED
package/dist/energy-app.d.ts
CHANGED
|
@@ -37,6 +37,7 @@ import { EnergyAppGridConnectionPoint } from "./packages/energy-app-grid-connect
|
|
|
37
37
|
import { EnergyAppConfigurationManager } from "./packages/energy-app-configuration-manager.js";
|
|
38
38
|
import { EnergyAppApplianceEnergyManagerForecast } from "./packages/energy-app-appliance-energy-manager-forecast.js";
|
|
39
39
|
import { EnergyAppBattery } from "./packages/energy-app-battery.js";
|
|
40
|
+
import { UseFetchOptions } from "./types/enyo-fetch.js";
|
|
40
41
|
/**
|
|
41
42
|
* Concrete implementation of {@link EnyoEnergyAppSdk} that delegates every call
|
|
42
43
|
* to the runtime-provided `energyAppSdkInstance` global.
|
|
@@ -68,7 +69,13 @@ export declare class EnergyApp implements EnyoEnergyAppSdk {
|
|
|
68
69
|
updateEnergyAppState(state: EnergyAppStateEnum): void;
|
|
69
70
|
register(callback: (packageName: string, version: number, channel: EnyoPackageChannel, deviceId: string) => void | Promise<void>): void;
|
|
70
71
|
onShutdown(callback: () => void | Promise<void>): void;
|
|
71
|
-
|
|
72
|
+
/**
|
|
73
|
+
* Returns a `fetch` implementation provided by the runtime.
|
|
74
|
+
* @param options - Optional configuration (e.g. {@link TlsClientOptions} for mutual TLS).
|
|
75
|
+
* When `options.tls` is set the runtime binds a TLS-configured dispatcher to the fetch.
|
|
76
|
+
* @returns A `fetch` function that still passes through the runtime allow-list.
|
|
77
|
+
*/
|
|
78
|
+
useFetch(options?: UseFetchOptions): typeof fetch;
|
|
72
79
|
useInterval(): EnergyAppInterval;
|
|
73
80
|
useModbus(): EnergyAppModbus;
|
|
74
81
|
useNetworkDevices(): EnergyAppNetworkDevice;
|
package/dist/energy-app.js
CHANGED
|
@@ -57,8 +57,14 @@ export class EnergyApp {
|
|
|
57
57
|
await callback();
|
|
58
58
|
});
|
|
59
59
|
}
|
|
60
|
-
|
|
61
|
-
|
|
60
|
+
/**
|
|
61
|
+
* Returns a `fetch` implementation provided by the runtime.
|
|
62
|
+
* @param options - Optional configuration (e.g. {@link TlsClientOptions} for mutual TLS).
|
|
63
|
+
* When `options.tls` is set the runtime binds a TLS-configured dispatcher to the fetch.
|
|
64
|
+
* @returns A `fetch` function that still passes through the runtime allow-list.
|
|
65
|
+
*/
|
|
66
|
+
useFetch(options) {
|
|
67
|
+
return this.energyAppSdk.useFetch(options);
|
|
62
68
|
}
|
|
63
69
|
useInterval() {
|
|
64
70
|
return this.energyAppSdk.useInterval();
|
|
@@ -36,6 +36,7 @@ import { EnergyAppGridConnectionPoint } from "./packages/energy-app-grid-connect
|
|
|
36
36
|
import { EnergyAppConfigurationManager } from "./packages/energy-app-configuration-manager.js";
|
|
37
37
|
import { EnergyAppApplianceEnergyManagerForecast } from "./packages/energy-app-appliance-energy-manager-forecast.js";
|
|
38
38
|
import { EnergyAppBattery } from "./packages/energy-app-battery.js";
|
|
39
|
+
import { UseFetchOptions } from "./types/enyo-fetch.js";
|
|
39
40
|
export declare enum EnergyAppStateEnum {
|
|
40
41
|
Launching = "launching",
|
|
41
42
|
Running = "running",
|
|
@@ -60,8 +61,8 @@ export interface EnyoEnergyAppSdk {
|
|
|
60
61
|
isSystemOnline: () => boolean;
|
|
61
62
|
/** Register a listener that gets called when the network status changes */
|
|
62
63
|
onNetworkStatusChanged: (listener: (online: boolean) => void | Promise<void>) => string;
|
|
63
|
-
/** Get the fetch API for HTTP requests */
|
|
64
|
-
useFetch: () => typeof fetch;
|
|
64
|
+
/** Get the fetch API for HTTP requests, optionally configured with TLS options */
|
|
65
|
+
useFetch: (options?: UseFetchOptions) => typeof fetch;
|
|
65
66
|
/** Get the interval management API */
|
|
66
67
|
useInterval: () => EnergyAppInterval;
|
|
67
68
|
/** Get the Modbus communication API */
|
|
@@ -129,6 +129,13 @@ export declare class ApplianceManager {
|
|
|
129
129
|
* Note: the merge is one level deep. Nested objects inside a metadata sub-object
|
|
130
130
|
* are replaced, not merged.
|
|
131
131
|
*
|
|
132
|
+
* Update contract: an omitted optional field leaves the stored value unchanged.
|
|
133
|
+
* For the {@link MERGEABLE_METADATA_KEYS} this is enforced by the per-key merge
|
|
134
|
+
* below; for the other optional top-level fields (`availableFeatures`,
|
|
135
|
+
* `cloudPackageId`) the caller-facing {@link createOrUpdateAppliance} drops the
|
|
136
|
+
* key when the value is `undefined` so this spread cannot overwrite it. To clear
|
|
137
|
+
* or replace such a field, pass an explicit value (e.g. an empty array `[]`).
|
|
138
|
+
*
|
|
132
139
|
* @param existing The existing appliance data
|
|
133
140
|
* @param update The partial update data to merge
|
|
134
141
|
* @returns The merged appliance data (without `id`)
|
|
@@ -90,6 +90,13 @@ export class ApplianceManager {
|
|
|
90
90
|
* Note: the merge is one level deep. Nested objects inside a metadata sub-object
|
|
91
91
|
* are replaced, not merged.
|
|
92
92
|
*
|
|
93
|
+
* Update contract: an omitted optional field leaves the stored value unchanged.
|
|
94
|
+
* For the {@link MERGEABLE_METADATA_KEYS} this is enforced by the per-key merge
|
|
95
|
+
* below; for the other optional top-level fields (`availableFeatures`,
|
|
96
|
+
* `cloudPackageId`) the caller-facing {@link createOrUpdateAppliance} drops the
|
|
97
|
+
* key when the value is `undefined` so this spread cannot overwrite it. To clear
|
|
98
|
+
* or replace such a field, pass an explicit value (e.g. an empty array `[]`).
|
|
99
|
+
*
|
|
93
100
|
* @param existing The existing appliance data
|
|
94
101
|
* @param update The partial update data to merge
|
|
95
102
|
* @returns The merged appliance data (without `id`)
|
|
@@ -194,8 +201,14 @@ export class ApplianceManager {
|
|
|
194
201
|
inverter: appliance.inverter,
|
|
195
202
|
temperatureSensor: appliance.temperatureSensor,
|
|
196
203
|
airConditioning: appliance.airConditioning,
|
|
197
|
-
|
|
198
|
-
|
|
204
|
+
// Conditionally spread the two optional top-level fields that are NOT
|
|
205
|
+
// covered by MERGEABLE_METADATA_KEYS. If they were always materialized
|
|
206
|
+
// as explicit keys, an omitted (undefined) value would clobber the
|
|
207
|
+
// stored value during mergeApplianceData's `{...existing, ...update}`
|
|
208
|
+
// spread on an update. `!== undefined` keeps an explicit `[]` (clear)
|
|
209
|
+
// while dropping omitted fields so the existing value is preserved.
|
|
210
|
+
...(appliance.cloudPackageId !== undefined && { cloudPackageId: appliance.cloudPackageId }),
|
|
211
|
+
...(appliance.availableFeatures !== undefined && { availableFeatures: appliance.availableFeatures }),
|
|
199
212
|
};
|
|
200
213
|
let applianceData = newApplianceData;
|
|
201
214
|
if (existingApplianceId) {
|
package/dist/index.d.ts
CHANGED
|
@@ -86,3 +86,4 @@ export * from './implementations/appliance-command-forecast/appliance-command-fo
|
|
|
86
86
|
export * from './implementations/energy-manager-diagnostics/energy-manager-diagnostics-validators.js';
|
|
87
87
|
export * from './types/enyo-battery-state.js';
|
|
88
88
|
export * from './packages/energy-app-battery.js';
|
|
89
|
+
export * from './types/enyo-fetch.js';
|
package/dist/index.js
CHANGED
|
@@ -86,3 +86,4 @@ export * from './implementations/appliance-command-forecast/appliance-command-fo
|
|
|
86
86
|
export * from './implementations/energy-manager-diagnostics/energy-manager-diagnostics-validators.js';
|
|
87
87
|
export * from './types/enyo-battery-state.js';
|
|
88
88
|
export * from './packages/energy-app-battery.js';
|
|
89
|
+
export * from './types/enyo-fetch.js';
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* TLS material for an outbound HTTPS connection made through {@link UseFetchOptions}.
|
|
3
|
+
*
|
|
4
|
+
* All certificate/key fields accept PEM as a UTF-8 string or a {@link Buffer}. When passed
|
|
5
|
+
* to `useFetch`, the runtime uses these values to build a TLS-configured dispatcher for the
|
|
6
|
+
* underlying fetch (e.g. for mutual TLS, custom trust anchors, or self-signed servers).
|
|
7
|
+
*/
|
|
8
|
+
export interface TlsClientOptions {
|
|
9
|
+
/** Client cert chain (PEM) presented during the TLS handshake (mutual TLS). */
|
|
10
|
+
cert?: string | Buffer;
|
|
11
|
+
/** Private key (PEM) for the client cert. */
|
|
12
|
+
key?: string | Buffer;
|
|
13
|
+
/** Trusted CA cert(s) (PEM) to validate the server. */
|
|
14
|
+
ca?: string | Buffer | Array<string | Buffer>;
|
|
15
|
+
/** When false, accept self-signed/untrusted server certs. Default true. */
|
|
16
|
+
rejectUnauthorized?: boolean;
|
|
17
|
+
/** Optional SNI / expected server hostname override. */
|
|
18
|
+
servername?: string;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Options accepted by `useFetch` to customize the returned `fetch` implementation.
|
|
22
|
+
*
|
|
23
|
+
* The returned fetch still passes through the runtime's origin allow-list; these options only
|
|
24
|
+
* add behavior (currently: TLS configuration) on top of that.
|
|
25
|
+
*/
|
|
26
|
+
export interface UseFetchOptions {
|
|
27
|
+
/** TLS / mutual-TLS configuration for outbound HTTPS requests. */
|
|
28
|
+
tls?: TlsClientOptions;
|
|
29
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/version.d.ts
CHANGED
package/dist/version.js
CHANGED