@enyo-energy/energy-app-sdk 0.0.113 → 0.0.115
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/implementations/retry/backoff.cjs +58 -0
- package/dist/cjs/implementations/retry/backoff.d.cts +19 -0
- package/dist/cjs/implementations/retry/retry-errors.cjs +28 -0
- package/dist/cjs/implementations/retry/retry-errors.d.cts +18 -0
- package/dist/cjs/implementations/retry/retry-manager.cjs +182 -0
- package/dist/cjs/implementations/retry/retry-manager.d.cts +97 -0
- package/dist/cjs/index.cjs +6 -0
- package/dist/cjs/index.d.cts +6 -0
- package/dist/cjs/packages/energy-app-onboarding.d.cts +17 -1
- package/dist/cjs/types/enyo-appliance.cjs +6 -3
- package/dist/cjs/types/enyo-appliance.d.cts +25 -7
- package/dist/cjs/types/enyo-authentication.d.cts +10 -0
- package/dist/cjs/types/enyo-charge.d.cts +5 -0
- package/dist/cjs/types/enyo-data-bus-value.d.cts +6 -4
- package/dist/cjs/types/enyo-onboarding.cjs +15 -1
- package/dist/cjs/types/enyo-onboarding.d.cts +19 -0
- package/dist/cjs/types/enyo-retry-manager.cjs +19 -0
- package/dist/cjs/types/enyo-retry-manager.d.cts +72 -0
- package/dist/cjs/version.cjs +1 -1
- package/dist/cjs/version.d.cts +1 -1
- package/dist/implementations/retry/backoff.d.ts +19 -0
- package/dist/implementations/retry/backoff.js +55 -0
- package/dist/implementations/retry/retry-errors.d.ts +18 -0
- package/dist/implementations/retry/retry-errors.js +24 -0
- package/dist/implementations/retry/retry-manager.d.ts +97 -0
- package/dist/implementations/retry/retry-manager.js +178 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.js +6 -0
- package/dist/packages/energy-app-onboarding.d.ts +17 -1
- package/dist/types/enyo-appliance.d.ts +25 -7
- package/dist/types/enyo-appliance.js +6 -3
- package/dist/types/enyo-authentication.d.ts +10 -0
- package/dist/types/enyo-charge.d.ts +5 -0
- package/dist/types/enyo-data-bus-value.d.ts +6 -4
- package/dist/types/enyo-onboarding.d.ts +19 -0
- package/dist/types/enyo-onboarding.js +14 -0
- package/dist/types/enyo-retry-manager.d.ts +72 -0
- package/dist/types/enyo-retry-manager.js +16 -0
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +6 -3
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
import { EnyoPackageConfigurationTranslatedValue } from "./enyo-settings.js";
|
|
2
2
|
export type EnyoAuthenticationType = 'apiKey' | 'oauth' | 'usernamePassword';
|
|
3
|
+
/**
|
|
4
|
+
* Indicates whether the authentication request should be presented to the user
|
|
5
|
+
* before or after the onboarding guide. When omitted, the host decides the default ordering.
|
|
6
|
+
*/
|
|
7
|
+
export type EnyoAuthenticationOnboardingOrder = 'before-onboarding' | 'after-onboarding';
|
|
3
8
|
/**
|
|
4
9
|
* Represents an additional custom field for authentication forms.
|
|
5
10
|
* Allows developers to add extra input fields beyond the standard username/password or API key.
|
|
@@ -66,6 +71,11 @@ export interface EnyoAuthentication {
|
|
|
66
71
|
oneTimeAuthentication: boolean;
|
|
67
72
|
/** Optional appliance ID. If provided, authentication is for specific appliance. If omitted, authentication is for the whole package */
|
|
68
73
|
applianceId?: string;
|
|
74
|
+
/**
|
|
75
|
+
* Optional ordering hint indicating whether this authentication request should be
|
|
76
|
+
* presented before or after the onboarding guide. When omitted, the host decides the default.
|
|
77
|
+
*/
|
|
78
|
+
onboardingOrder?: EnyoAuthenticationOnboardingOrder;
|
|
69
79
|
}
|
|
70
80
|
export interface EnyoApiKeyAuthenticationResponse {
|
|
71
81
|
apiKey: string;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { EnyoChargeModeEnum } from "./enyo-data-bus-value.js";
|
|
1
2
|
/**
|
|
2
3
|
* Status of a charging session
|
|
3
4
|
*/
|
|
@@ -65,6 +66,10 @@ export interface EnyoCharge {
|
|
|
65
66
|
numberOfPhases: number;
|
|
66
67
|
/** Active charging schedule entries, if smart charging is in use */
|
|
67
68
|
schedule?: EnyoChargeScheduleEntry[];
|
|
69
|
+
/** Charging mode applied to this session (e.g. immediate, cost-optimized, price-limit) */
|
|
70
|
+
chargeMode?: EnyoChargeModeEnum;
|
|
71
|
+
/** Target completion time for the charging session as an ISO 8601 timestamp */
|
|
72
|
+
completeAtIsoTimestamp?: string;
|
|
68
73
|
}
|
|
69
74
|
/**
|
|
70
75
|
* Represents a single entry in a charging schedule.
|
|
@@ -330,7 +330,8 @@ export interface EnyoDataBusApplianceFlexibilityAnnouncementV1 extends EnyoDataB
|
|
|
330
330
|
* changes. At least one of `state` or `status` should be set; both may be
|
|
331
331
|
* provided together if they change in the same event. `errorCodes` carries
|
|
332
332
|
* vendor- or protocol-specific codes that explain a transition into a
|
|
333
|
-
* `faulted` status
|
|
333
|
+
* `warning` or `faulted` status; each entry's `severity` field indicates
|
|
334
|
+
* which.
|
|
334
335
|
*/
|
|
335
336
|
export interface EnyoDataBusApplianceStateUpdateV1 extends EnyoDataBusMessage {
|
|
336
337
|
type: 'message';
|
|
@@ -345,9 +346,10 @@ export interface EnyoDataBusApplianceStateUpdateV1 extends EnyoDataBusMessage {
|
|
|
345
346
|
/**
|
|
346
347
|
* Optional vendor- or protocol-specific error codes that explain the
|
|
347
348
|
* current status. Each entry carries the raw code and may include
|
|
348
|
-
* pre-translated messages for UI display
|
|
349
|
-
*
|
|
350
|
-
*
|
|
349
|
+
* pre-translated messages for UI display, plus an optional `severity`
|
|
350
|
+
* (`'error'` or `'warning'`). Typically populated when transitioning
|
|
351
|
+
* into `warning` or `faulted`; omitted or empty when there is nothing
|
|
352
|
+
* to report.
|
|
351
353
|
*/
|
|
352
354
|
errorCodes?: EnyoApplianceErrorCode[];
|
|
353
355
|
};
|
|
@@ -9,6 +9,19 @@ export interface EnyoOnboardingTranslatedContent {
|
|
|
9
9
|
/** The translated text value */
|
|
10
10
|
value: string;
|
|
11
11
|
}
|
|
12
|
+
/**
|
|
13
|
+
* Enum representing the lifecycle category of an onboarding guide.
|
|
14
|
+
* Used to distinguish guides that perform different roles, e.g. initial
|
|
15
|
+
* configuration of a package vs. adding or reconnecting a single device.
|
|
16
|
+
*/
|
|
17
|
+
export declare enum EnyoOnboardingGuideCategory {
|
|
18
|
+
/** Initial package configuration — shown when EnergyAppStateEnum is 'configuration-required' */
|
|
19
|
+
InitialSetup = "initial-setup",
|
|
20
|
+
/** Guide for adding a new device to an already-configured package */
|
|
21
|
+
AddNewDevice = "add-new-device",
|
|
22
|
+
/** Guide for reconnecting an existing device that has lost its connection */
|
|
23
|
+
ReconnectDevice = "reconnect-device"
|
|
24
|
+
}
|
|
12
25
|
/**
|
|
13
26
|
* Enum representing the type of content an onboarding section displays.
|
|
14
27
|
*/
|
|
@@ -125,6 +138,12 @@ export interface EnyoOnboardingGuide {
|
|
|
125
138
|
description?: EnyoOnboardingTranslatedContent[];
|
|
126
139
|
/** Optional appliance ID if this guide is associated with an appliance */
|
|
127
140
|
applianceId?: string;
|
|
141
|
+
/**
|
|
142
|
+
* Optional lifecycle category for this guide.
|
|
143
|
+
* Allows hosts to render category-specific entry points (e.g. "Add new device" buttons).
|
|
144
|
+
* Defaults to InitialSetup semantics when omitted, for backwards compatibility.
|
|
145
|
+
*/
|
|
146
|
+
category?: EnyoOnboardingGuideCategory;
|
|
128
147
|
/** Ordered array of steps in the onboarding flow */
|
|
129
148
|
steps: EnyoOnboardingStep[];
|
|
130
149
|
}
|
|
@@ -1,3 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Enum representing the lifecycle category of an onboarding guide.
|
|
3
|
+
* Used to distinguish guides that perform different roles, e.g. initial
|
|
4
|
+
* configuration of a package vs. adding or reconnecting a single device.
|
|
5
|
+
*/
|
|
6
|
+
export var EnyoOnboardingGuideCategory;
|
|
7
|
+
(function (EnyoOnboardingGuideCategory) {
|
|
8
|
+
/** Initial package configuration — shown when EnergyAppStateEnum is 'configuration-required' */
|
|
9
|
+
EnyoOnboardingGuideCategory["InitialSetup"] = "initial-setup";
|
|
10
|
+
/** Guide for adding a new device to an already-configured package */
|
|
11
|
+
EnyoOnboardingGuideCategory["AddNewDevice"] = "add-new-device";
|
|
12
|
+
/** Guide for reconnecting an existing device that has lost its connection */
|
|
13
|
+
EnyoOnboardingGuideCategory["ReconnectDevice"] = "reconnect-device";
|
|
14
|
+
})(EnyoOnboardingGuideCategory || (EnyoOnboardingGuideCategory = {}));
|
|
1
15
|
/**
|
|
2
16
|
* Enum representing the type of content an onboarding section displays.
|
|
3
17
|
*/
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Lifecycle state of a single retryable instance tracked by {@link RetryManager}.
|
|
3
|
+
*/
|
|
4
|
+
export declare enum RetryState {
|
|
5
|
+
/** Registered but no attempt has run yet (or the instance was reset). */
|
|
6
|
+
Idle = "idle",
|
|
7
|
+
/** An attempt is currently executing. */
|
|
8
|
+
Running = "running",
|
|
9
|
+
/** The previous attempt failed and the manager is sleeping before the next one. */
|
|
10
|
+
Waiting = "waiting",
|
|
11
|
+
/** The most recent attempt succeeded. */
|
|
12
|
+
Succeeded = "succeeded",
|
|
13
|
+
/** All attempts have been used (or the error was non-retryable). */
|
|
14
|
+
Exhausted = "exhausted"
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Backoff curve used to compute the delay between retry attempts.
|
|
18
|
+
*
|
|
19
|
+
* The same shape covers fixed, linear and exponential strategies so callers
|
|
20
|
+
* configure backoff with plain data instead of constructing strategy classes.
|
|
21
|
+
*/
|
|
22
|
+
export interface BackoffConfig {
|
|
23
|
+
/** Backoff curve. `exponential` is the typical default for network I/O. */
|
|
24
|
+
type: 'fixed' | 'linear' | 'exponential';
|
|
25
|
+
/** Base delay for the first retry, in milliseconds. Must be `>= 0`. */
|
|
26
|
+
initialMs: number;
|
|
27
|
+
/** Optional upper bound (ms) applied after the curve and before jitter. */
|
|
28
|
+
maxMs?: number;
|
|
29
|
+
/** Growth factor for `exponential`. Defaults to `2`. Must be `>= 1`. */
|
|
30
|
+
factor?: number;
|
|
31
|
+
/**
|
|
32
|
+
* Random jitter ratio in `[0, 1]`. `0.2` means the final delay is uniformly
|
|
33
|
+
* distributed in `[delay * 0.8, delay * 1.2]`. Defaults to `0`.
|
|
34
|
+
*/
|
|
35
|
+
jitter?: number;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Per-instance retry policy. Registered with {@link RetryManager.register}.
|
|
39
|
+
*/
|
|
40
|
+
export interface RetryPolicy {
|
|
41
|
+
/** Total attempts allowed including the first call. Use `Infinity` for endless retry. */
|
|
42
|
+
maxAttempts: number;
|
|
43
|
+
/** Backoff curve applied between attempts. */
|
|
44
|
+
backoff: BackoffConfig;
|
|
45
|
+
/**
|
|
46
|
+
* Predicate consulted after each failure. Returning `false` short-circuits
|
|
47
|
+
* to {@link RetryState.Exhausted} without further retries (e.g. for auth or 4xx errors).
|
|
48
|
+
* Defaults to "always retryable".
|
|
49
|
+
*/
|
|
50
|
+
isRetryable?: (error: unknown) => boolean;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Snapshot of a single instance's current retry state.
|
|
54
|
+
*/
|
|
55
|
+
export interface RetryStatus {
|
|
56
|
+
/** Identifier the instance was registered under. */
|
|
57
|
+
id: string;
|
|
58
|
+
/** Current lifecycle state. */
|
|
59
|
+
state: RetryState;
|
|
60
|
+
/** Number of attempts that have started so far in the current cycle. */
|
|
61
|
+
attempts: number;
|
|
62
|
+
/** Error from the most recent failed attempt, if any. */
|
|
63
|
+
lastError?: unknown;
|
|
64
|
+
/** Delay (ms) the manager is sleeping for, set only while `state === Waiting`. */
|
|
65
|
+
nextDelayMs?: number;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Listener invoked on every state transition for any registered instance.
|
|
69
|
+
*
|
|
70
|
+
* @param status Snapshot of the instance immediately after the transition.
|
|
71
|
+
*/
|
|
72
|
+
export type RetryStateListener = (status: RetryStatus) => void;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Lifecycle state of a single retryable instance tracked by {@link RetryManager}.
|
|
3
|
+
*/
|
|
4
|
+
export var RetryState;
|
|
5
|
+
(function (RetryState) {
|
|
6
|
+
/** Registered but no attempt has run yet (or the instance was reset). */
|
|
7
|
+
RetryState["Idle"] = "idle";
|
|
8
|
+
/** An attempt is currently executing. */
|
|
9
|
+
RetryState["Running"] = "running";
|
|
10
|
+
/** The previous attempt failed and the manager is sleeping before the next one. */
|
|
11
|
+
RetryState["Waiting"] = "waiting";
|
|
12
|
+
/** The most recent attempt succeeded. */
|
|
13
|
+
RetryState["Succeeded"] = "succeeded";
|
|
14
|
+
/** All attempts have been used (or the error was non-retryable). */
|
|
15
|
+
RetryState["Exhausted"] = "exhausted";
|
|
16
|
+
})(RetryState || (RetryState = {}));
|
package/dist/version.d.ts
CHANGED
package/dist/version.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@enyo-energy/energy-app-sdk",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.115",
|
|
4
4
|
"description": "enyo Energy App SDK",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -8,7 +8,9 @@
|
|
|
8
8
|
"scripts": {
|
|
9
9
|
"extract-version": "node scripts/extract-version.js",
|
|
10
10
|
"build": "npm run extract-version && duel",
|
|
11
|
-
"prepublishOnly": "npm run extract-version && npm run build"
|
|
11
|
+
"prepublishOnly": "npm run extract-version && npm run build",
|
|
12
|
+
"test": "vitest run",
|
|
13
|
+
"test:watch": "vitest"
|
|
12
14
|
},
|
|
13
15
|
"files": [
|
|
14
16
|
"dist",
|
|
@@ -34,7 +36,8 @@
|
|
|
34
36
|
"@knighted/duel": "^2.1.4",
|
|
35
37
|
"@types/express": "^5.0.3",
|
|
36
38
|
"@types/node": "^24.0.13",
|
|
37
|
-
"typescript": "^5.8.3"
|
|
39
|
+
"typescript": "^5.8.3",
|
|
40
|
+
"vitest": "^2.1.9"
|
|
38
41
|
},
|
|
39
42
|
"dependencies": {},
|
|
40
43
|
"volta": {
|