@truenas/api-client 3.0.1 → 3.0.2

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 CHANGED
@@ -3150,7 +3150,29 @@ var TrueNasApiClientV2510 = class extends TrueNasApiClient {
3150
3150
  containerQuery: () => this.api.query("virt.instance.query", [["type", "=", "CONTAINER"]]).pipe(rxjs.map((instances) => instances.map(toContainer))),
3151
3151
  containerStart: (id) => this.api.job("virt.instance.start", [id]),
3152
3152
  containerStop: (id, options) => this.api.job("virt.instance.stop", [id, options]),
3153
- containerRestart: (id, options) => this.api.job("virt.instance.restart", [id, options])
3153
+ containerRestart: (id, options) => this.api.job("virt.instance.restart", [id, options]),
3154
+ // Already a job here — `virt.instance.delete` has been one since
3155
+ // v25.10.0 — so this needs no synthesis, only the id. It takes nothing
3156
+ // else: there is no `force` and no `recursive` on this version.
3157
+ //
3158
+ // Unsupported options are reported rather than dropped. `recursive`
3159
+ // destroys child datasets, snapshots and clones irrecoverably, so a
3160
+ // caller who asked for it and silently did not get it has been told
3161
+ // something false about what just happened to their data. Reporting is
3162
+ // all this layer can do — refusing outright would make `ops.containerDelete`
3163
+ // unusable on v25.10 for the ordinary case, which is the case that works.
3164
+ containerDelete: (id, options) => {
3165
+ const unsupported = ["force", "recursive"].filter(
3166
+ (key) => options?.[key]
3167
+ );
3168
+ if (unsupported.length > 0) {
3169
+ this.logger.warn(
3170
+ "containerDelete: v25.10 has no counterpart for these options and will delete without them",
3171
+ { ignored: unsupported, id, method: "virt.instance.delete" }
3172
+ );
3173
+ }
3174
+ return this.api.job("virt.instance.delete", [id]);
3175
+ }
3154
3176
  };
3155
3177
  }
3156
3178
  };
@@ -3218,7 +3240,26 @@ var TrueNasApiClientV26 = class extends TrueNasApiClient {
3218
3240
  )
3219
3241
  )
3220
3242
  );
3221
- }
3243
+ },
3244
+ // A job since v26.0.0 — middleware made deletion long-running (it stops
3245
+ // the container when asked, tears down the libvirt domain and destroys
3246
+ // the dataset), and the generated directory moved it out of `call`
3247
+ // accordingly. `api.job` is what tracks it; `api.call` would not compile.
3248
+ //
3249
+ // Options pass straight through when given: the unified
3250
+ // `ContainerDeleteOptions` is `force`/`recursive`, exactly what the
3251
+ // generated params take.
3252
+ //
3253
+ // When they are not given the argument is *omitted* rather than passed as
3254
+ // `undefined`. `JSON.stringify` renders a trailing `undefined` array
3255
+ // element as `null`, and middleware declares `options: ContainerDeleteOptions`
3256
+ // with a model default and no `| None` — so `[id, null]` is a validation
3257
+ // error rather than "use the defaults", which is the one thing a caller
3258
+ // passing nothing is asking for.
3259
+ containerDelete: (id, options) => this.api.job(
3260
+ "container.delete",
3261
+ options ? [parseInt(id, 10), options] : [parseInt(id, 10)]
3262
+ )
3222
3263
  };
3223
3264
  }
3224
3265
  };
@@ -3280,7 +3321,26 @@ var TrueNasApiClientV27 = class extends TrueNasApiClient {
3280
3321
  )
3281
3322
  )
3282
3323
  );
3283
- }
3324
+ },
3325
+ // A job since v26.0.0 — middleware made deletion long-running (it stops
3326
+ // the container when asked, tears down the libvirt domain and destroys
3327
+ // the dataset), and the generated directory moved it out of `call`
3328
+ // accordingly. `api.job` is what tracks it; `api.call` would not compile.
3329
+ //
3330
+ // Options pass straight through when given: the unified
3331
+ // `ContainerDeleteOptions` is `force`/`recursive`, exactly what the
3332
+ // generated params take.
3333
+ //
3334
+ // When they are not given the argument is *omitted* rather than passed as
3335
+ // `undefined`. `JSON.stringify` renders a trailing `undefined` array
3336
+ // element as `null`, and middleware declares `options: ContainerDeleteOptions`
3337
+ // with a model default and no `| None` — so `[id, null]` is a validation
3338
+ // error rather than "use the defaults", which is the one thing a caller
3339
+ // passing nothing is asking for.
3340
+ containerDelete: (id, options) => this.api.job(
3341
+ "container.delete",
3342
+ options ? [parseInt(id, 10), options] : [parseInt(id, 10)]
3343
+ )
3284
3344
  };
3285
3345
  }
3286
3346
  };