@norskvideo/ctl-sdk 0.1.50 → 0.1.51

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@norskvideo/ctl-sdk",
3
- "version": "0.1.50",
3
+ "version": "0.1.51",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": {
@@ -171,6 +171,9 @@ export interface ProductServiceOptions {
171
171
  /** Told once a registration is removed, so the host can drop whatever it
172
172
  * holds against the product (role assignments on `product/<name>`). */
173
173
  onRemoved?: (productName: string) => void;
174
+ /** Told after every add, remove and reload that succeeds: the host keeps a
175
+ * view of its products elsewhere (norsk-ctl's discovery entries). */
176
+ onChanged?: () => void;
174
177
  /**
175
178
  * What the daemon asserts when it dials a REGISTERED product's own routes —
176
179
  * the config-screen probe and the product-template fetches (RFC 0003 D7's
@@ -228,6 +231,7 @@ export declare class ProductService {
228
231
  private reachHostFor;
229
232
  private readonly onRolesDeclared?;
230
233
  private readonly onRemoved?;
234
+ private readonly onChanged?;
231
235
  private readonly reservedRoleNames?;
232
236
  /**
233
237
  * Product roles travel bare, so a name means one thing on a host. Two
@@ -248,6 +252,7 @@ export declare class ProductService {
248
252
  * tracked containerId means running. Dev-mode: externally owned, so probe
249
253
  * the dev URL — registered no longer implies running. */
250
254
  isRunning(reg: ProductRegistration): Promise<boolean>;
255
+ private changed;
251
256
  add(spec: ProductSpec, opts?: AddProductOpts): Promise<AddProductResult>;
252
257
  private addSerialised;
253
258
  remove(name: string): Promise<void>;
@@ -76,6 +76,7 @@ export class ProductService {
76
76
  this.onRolesDeclared = opts.onRolesDeclared;
77
77
  this.reservedRoleNames = opts.reservedRoleNames;
78
78
  this.onRemoved = opts.onRemoved;
79
+ this.onChanged = opts.onChanged;
79
80
  this.forgetIdentity = opts.forgetIdentity;
80
81
  this.probeHeadersFor = opts.probeHeadersFor;
81
82
  }
@@ -99,6 +100,7 @@ export class ProductService {
99
100
  }
100
101
  onRolesDeclared;
101
102
  onRemoved;
103
+ onChanged;
102
104
  reservedRoleNames;
103
105
  /**
104
106
  * Product roles travel bare, so a name means one thing on a host. Two
@@ -165,8 +167,12 @@ export class ProductService {
165
167
  return reg.containerId !== undefined;
166
168
  return this.isDevUrlAlive(productBaseUrl(reg));
167
169
  }
170
+ changed(result) {
171
+ this.onChanged?.();
172
+ return result;
173
+ }
168
174
  async add(spec, opts = {}) {
169
- return this.mutations.run(() => this.addSerialised(spec, opts));
175
+ return this.changed(await this.mutations.run(() => this.addSerialised(spec, opts)));
170
176
  }
171
177
  async addSerialised(spec, opts) {
172
178
  const existing = this.store.read();
@@ -373,7 +379,7 @@ export class ProductService {
373
379
  return { registration, warnings };
374
380
  }
375
381
  async remove(name) {
376
- return this.mutations.run(() => this.removeSerialised(name));
382
+ return this.changed(await this.mutations.run(() => this.removeSerialised(name)));
377
383
  }
378
384
  async removeSerialised(name) {
379
385
  const existing = this.store.read();
@@ -400,7 +406,7 @@ export class ProductService {
400
406
  * stood in for. Like restart, the new container id is persisted before the
401
407
  * readiness wait so a timed-out reload leaves a tracked container. */
402
408
  async reload(name) {
403
- return this.mutations.run(() => this.reloadSerialised(name));
409
+ return this.changed(await this.mutations.run(() => this.reloadSerialised(name)));
404
410
  }
405
411
  async reloadSerialised(name) {
406
412
  const target = this.store.read().find((p) => p.name === name);