@truenas/api-client 2.0.1 → 3.0.1
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/index.cjs +120 -13
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +498 -366
- package/dist/index.d.ts +498 -366
- package/dist/index.js +120 -14
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -2519,7 +2519,6 @@ __export(v26_0_0_exports, {
|
|
|
2519
2519
|
Aclmode: () => Aclmode,
|
|
2520
2520
|
Acltype: () => Acltype,
|
|
2521
2521
|
Advpowermgmt: () => Advpowermgmt,
|
|
2522
|
-
Algorithm: () => Algorithm,
|
|
2523
2522
|
AppContainerDetailsState: () => AppContainerDetailsState,
|
|
2524
2523
|
AppContainerDetailsStateInput: () => AppContainerDetailsStateInput,
|
|
2525
2524
|
Atime: () => Atime,
|
|
@@ -2657,11 +2656,13 @@ var ContainerNICDeviceTypeInput = {
|
|
|
2657
2656
|
};
|
|
2658
2657
|
var ContainerStatusState = {
|
|
2659
2658
|
Running: "RUNNING",
|
|
2660
|
-
Stopped: "STOPPED"
|
|
2659
|
+
Stopped: "STOPPED",
|
|
2660
|
+
Suspended: "SUSPENDED"
|
|
2661
2661
|
};
|
|
2662
2662
|
var ContainerStatusStateInput = {
|
|
2663
2663
|
Running: "RUNNING",
|
|
2664
|
-
Stopped: "STOPPED"
|
|
2664
|
+
Stopped: "STOPPED",
|
|
2665
|
+
Suspended: "SUSPENDED"
|
|
2665
2666
|
};
|
|
2666
2667
|
var Feature2 = {
|
|
2667
2668
|
Apps: "APPS",
|
|
@@ -2741,7 +2742,6 @@ __export(v27_0_0_exports, {
|
|
|
2741
2742
|
Aclmode: () => Aclmode,
|
|
2742
2743
|
Acltype: () => Acltype,
|
|
2743
2744
|
Advpowermgmt: () => Advpowermgmt,
|
|
2744
|
-
Algorithm: () => Algorithm,
|
|
2745
2745
|
AppContainerDetailsState: () => AppContainerDetailsState,
|
|
2746
2746
|
AppContainerDetailsStateInput: () => AppContainerDetailsStateInput,
|
|
2747
2747
|
Atime: () => Atime,
|
|
@@ -2892,14 +2892,23 @@ var apiVersionConfig = {
|
|
|
2892
2892
|
/**
|
|
2893
2893
|
* Maximum supported API version. Systems above it are rejected.
|
|
2894
2894
|
*
|
|
2895
|
-
* NOT derived, deliberately
|
|
2896
|
-
*
|
|
2897
|
-
* `
|
|
2898
|
-
*
|
|
2899
|
-
*
|
|
2900
|
-
*
|
|
2895
|
+
* NOT derived, deliberately — and for a different reason than it used to
|
|
2896
|
+
* lag. It sat at v26.0.0 while types for v27 already shipped, because
|
|
2897
|
+
* `CLIENT_BY_VERSION_KEY` had no `27` and a v27 system would have passed the
|
|
2898
|
+
* range check only to throw on client selection. `TrueNasApiClientV27` now
|
|
2899
|
+
* exists, so this moves up with it.
|
|
2900
|
+
*
|
|
2901
|
+
* What it must not become is `SUPPORTED_API_VERSIONS[length - 1]`, the mirror
|
|
2902
|
+
* of how MIN is derived. MIN is safe to derive because the oldest generated
|
|
2903
|
+
* version always has a client — it is the floor the clients were built from.
|
|
2904
|
+
* The ceiling is not symmetric: generating types for v28 does not write a v28
|
|
2905
|
+
* client, so deriving this would re-create the exact gap described above on
|
|
2906
|
+
* the next regeneration, silently. The real invariant is "the newest version
|
|
2907
|
+
* a client can be built for", which lives in `CLIENT_BY_VERSION_KEY`; a
|
|
2908
|
+
* factory test asserts the two agree, which is the check that keeps this
|
|
2909
|
+
* literal honest without importing the factory here.
|
|
2901
2910
|
*/
|
|
2902
|
-
MAX_SUPPORTED_VERSION: "
|
|
2911
|
+
MAX_SUPPORTED_VERSION: "v27.0.0",
|
|
2903
2912
|
/**
|
|
2904
2913
|
* Fallback version to use when version discovery fails due to CORS/network errors.
|
|
2905
2914
|
* When /api/versions returns HTTP status 0 (CORS block, network down, etc.),
|
|
@@ -3064,6 +3073,10 @@ var AppState = /* @__PURE__ */ ((AppState2) => {
|
|
|
3064
3073
|
AppState2["Stopped"] = "STOPPED";
|
|
3065
3074
|
AppState2["Stopping"] = "STOPPING";
|
|
3066
3075
|
AppState2["Deploying"] = "DEPLOYING";
|
|
3076
|
+
AppState2["Suspended"] = "SUSPENDED";
|
|
3077
|
+
AppState2["Suspending"] = "SUSPENDING";
|
|
3078
|
+
AppState2["Error"] = "ERROR";
|
|
3079
|
+
AppState2["Unknown"] = "UNKNOWN";
|
|
3067
3080
|
return AppState2;
|
|
3068
3081
|
})(AppState || {});
|
|
3069
3082
|
|
|
@@ -3074,7 +3087,10 @@ function toAppState(state) {
|
|
|
3074
3087
|
return "RUNNING" /* Running */;
|
|
3075
3088
|
case "STOPPED":
|
|
3076
3089
|
return "STOPPED" /* Stopped */;
|
|
3090
|
+
// `ABORTING` is v25.10 only: the instance is being forced down, which ends
|
|
3091
|
+
// at `STOPPED` and is what `Stopping` already means.
|
|
3077
3092
|
case "STOPPING":
|
|
3093
|
+
case "ABORTING":
|
|
3078
3094
|
return "STOPPING" /* Stopping */;
|
|
3079
3095
|
// `STARTING` is v25.10 `virt.instance` only, and folding it into `Stopped`
|
|
3080
3096
|
// told callers a container that is coming up is at rest — enough for a UI
|
|
@@ -3083,8 +3099,35 @@ function toAppState(state) {
|
|
|
3083
3099
|
case "STARTING":
|
|
3084
3100
|
case "DEPLOYING":
|
|
3085
3101
|
return "DEPLOYING" /* Deploying */;
|
|
3102
|
+
// v25.10's freezer states are the same idea as v26's `SUSPENDED`: the
|
|
3103
|
+
// processes are paused, not exited. `FROZEN` is that pause completed, so it
|
|
3104
|
+
// and `SUSPENDED` are the same answer.
|
|
3105
|
+
case "SUSPENDED":
|
|
3106
|
+
case "FROZEN":
|
|
3107
|
+
return "SUSPENDED" /* Suspended */;
|
|
3108
|
+
// `FREEZING` is on the way there and not there yet. It used to answer
|
|
3109
|
+
// `Suspended`, defended by analogy with `STARTING` — but `STARTING` maps to
|
|
3110
|
+
// `Deploying`, which is itself an in-progress word, so the analogy ran the
|
|
3111
|
+
// wrong way. Answering `Suspended` tells a caller polling for "the memory
|
|
3112
|
+
// is quiesced" that it is, one poll before it is true: the same false
|
|
3113
|
+
// claim this mapping was rewritten to stop making, one state along.
|
|
3114
|
+
// `ABORTING` had `Stopping` to land on; the freeze path needed its own.
|
|
3115
|
+
case "FREEZING":
|
|
3116
|
+
return "SUSPENDING" /* Suspending */;
|
|
3117
|
+
// `THAWED` is the freezer lifted: the processes are scheduled again, so
|
|
3118
|
+
// this is `RUNNING` reported through the transition rather than a state a
|
|
3119
|
+
// caller should act on differently.
|
|
3120
|
+
case "THAWED":
|
|
3121
|
+
return "RUNNING" /* Running */;
|
|
3122
|
+
case "ERROR":
|
|
3123
|
+
return "ERROR" /* Error */;
|
|
3124
|
+
// `UNKNOWN` is middleware's own word for it, and anything unrecognised is
|
|
3125
|
+
// the same situation: a state this mapping has no word for. Neither is
|
|
3126
|
+
// evidence the container is stopped.
|
|
3127
|
+
case "UNKNOWN":
|
|
3128
|
+
return "UNKNOWN" /* Unknown */;
|
|
3086
3129
|
default:
|
|
3087
|
-
return "
|
|
3130
|
+
return "UNKNOWN" /* Unknown */;
|
|
3088
3131
|
}
|
|
3089
3132
|
}
|
|
3090
3133
|
|
|
@@ -3188,6 +3231,68 @@ function toContainer2(container) {
|
|
|
3188
3231
|
description
|
|
3189
3232
|
};
|
|
3190
3233
|
}
|
|
3234
|
+
var TrueNasApiClientV27 = class extends TrueNasApiClient {
|
|
3235
|
+
/**
|
|
3236
|
+
* Create v27-specific operation mappings
|
|
3237
|
+
*
|
|
3238
|
+
* Operations return Observable<Job | null>:
|
|
3239
|
+
* - Async operations emit Job updates until complete
|
|
3240
|
+
* - Sync operations emit null once
|
|
3241
|
+
*/
|
|
3242
|
+
createOperations() {
|
|
3243
|
+
return {
|
|
3244
|
+
// A polymorphic `.query`, so it goes through the verb rather than
|
|
3245
|
+
// `call`: the directory types the raw method's response as the five-way
|
|
3246
|
+
// union the server may return, and the verb is what fixes it to a list.
|
|
3247
|
+
containerQuery: () => this.api.query("container.query").pipe(
|
|
3248
|
+
map((containers) => containers.map(toContainer3))
|
|
3249
|
+
),
|
|
3250
|
+
// container.start is synchronous in v27 - emit null
|
|
3251
|
+
containerStart: (id) => this.api.call("container.start", [parseInt(id, 10)]).pipe(map(() => null)),
|
|
3252
|
+
// container.stop emits job updates
|
|
3253
|
+
containerStop: (id, options) => this.api.job("container.stop", [
|
|
3254
|
+
parseInt(id, 10),
|
|
3255
|
+
{
|
|
3256
|
+
force: options.force,
|
|
3257
|
+
force_after_timeout: options.force
|
|
3258
|
+
}
|
|
3259
|
+
]),
|
|
3260
|
+
// v27 still has no container.restart - chain stop + start.
|
|
3261
|
+
// Emits Job updates during stop, then null when start completes.
|
|
3262
|
+
containerRestart: (id, options) => {
|
|
3263
|
+
const numericId = parseInt(id, 10);
|
|
3264
|
+
return this.api.job("container.stop", [
|
|
3265
|
+
numericId,
|
|
3266
|
+
{
|
|
3267
|
+
force: options.force,
|
|
3268
|
+
force_after_timeout: options.force
|
|
3269
|
+
}
|
|
3270
|
+
]).pipe(
|
|
3271
|
+
// Collect all job updates to ensure stop fully completes
|
|
3272
|
+
toArray(),
|
|
3273
|
+
// Re-emit job updates, then call start after stop is done
|
|
3274
|
+
switchMap(
|
|
3275
|
+
(jobUpdates) => concat(
|
|
3276
|
+
from(jobUpdates),
|
|
3277
|
+
this.api.call("container.start", [numericId]).pipe(map(() => null))
|
|
3278
|
+
)
|
|
3279
|
+
)
|
|
3280
|
+
);
|
|
3281
|
+
}
|
|
3282
|
+
};
|
|
3283
|
+
}
|
|
3284
|
+
};
|
|
3285
|
+
function toContainer3(container) {
|
|
3286
|
+
const { description } = container;
|
|
3287
|
+
return {
|
|
3288
|
+
id: container.id.toString(),
|
|
3289
|
+
name: container.name,
|
|
3290
|
+
status: toAppState(container.status.state),
|
|
3291
|
+
// Optional in the generated entry, required by `Container`.
|
|
3292
|
+
autostart: container.autostart ?? false,
|
|
3293
|
+
description
|
|
3294
|
+
};
|
|
3295
|
+
}
|
|
3191
3296
|
|
|
3192
3297
|
// src/errors/version-discovery.errors.ts
|
|
3193
3298
|
var VersionDiscoveryError = class extends Error {
|
|
@@ -3557,7 +3662,8 @@ function selectRepresentativeFailure(failures) {
|
|
|
3557
3662
|
}
|
|
3558
3663
|
var CLIENT_BY_VERSION_KEY = {
|
|
3559
3664
|
"25.10": TrueNasApiClientV2510,
|
|
3560
|
-
"26": TrueNasApiClientV26
|
|
3665
|
+
"26": TrueNasApiClientV26,
|
|
3666
|
+
"27": TrueNasApiClientV27
|
|
3561
3667
|
};
|
|
3562
3668
|
function clientVersionKey(version) {
|
|
3563
3669
|
if (version.year <= legacyCutoffYear) {
|
|
@@ -3603,6 +3709,6 @@ function errorMessageOrDefault(error, fallback) {
|
|
|
3603
3709
|
return fallback;
|
|
3604
3710
|
}
|
|
3605
3711
|
|
|
3606
|
-
export { AppState, AuthError, AuthErrorCode, InvalidVersionResponseError, JobState, NoCompatibleVersionsError, SUPPORTED_API_VERSIONS, TrueNasApiClient, TrueNasApiClientV2510, TrueNasApiClientV26, TrueNasAuthMechanism, VersionCompatibility, VersionDiscovery, VersionDiscoveryError, VersionDiscoveryNetworkError, VersionDiscoveryTimeoutError, VersionEndpointNotFoundError, VersionTooNewError, VersionTooOldError, consoleLogger, createTrueNasClient, getApiErrorMessage, isJobFinished, noopLogger, v25_10_0_exports as v25_10_0, v25_10_1_exports as v25_10_1, v25_10_2_exports as v25_10_2, v25_10_3_exports as v25_10_3, v25_10_4_exports as v25_10_4, v25_10_5_exports as v25_10_5, v26_0_0_exports as v26_0_0, v27_0_0_exports as v27_0_0 };
|
|
3712
|
+
export { AppState, AuthError, AuthErrorCode, InvalidVersionResponseError, JobState, NoCompatibleVersionsError, SUPPORTED_API_VERSIONS, TrueNasApiClient, TrueNasApiClientV2510, TrueNasApiClientV26, TrueNasApiClientV27, TrueNasAuthMechanism, VersionCompatibility, VersionDiscovery, VersionDiscoveryError, VersionDiscoveryNetworkError, VersionDiscoveryTimeoutError, VersionEndpointNotFoundError, VersionTooNewError, VersionTooOldError, consoleLogger, createTrueNasClient, getApiErrorMessage, isJobFinished, noopLogger, v25_10_0_exports as v25_10_0, v25_10_1_exports as v25_10_1, v25_10_2_exports as v25_10_2, v25_10_3_exports as v25_10_3, v25_10_4_exports as v25_10_4, v25_10_5_exports as v25_10_5, v26_0_0_exports as v26_0_0, v27_0_0_exports as v27_0_0 };
|
|
3607
3713
|
//# sourceMappingURL=index.js.map
|
|
3608
3714
|
//# sourceMappingURL=index.js.map
|