@syncbridge/common 2.2.0 → 2.3.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/app-factory.js CHANGED
@@ -266,7 +266,13 @@ export var AppFactory;
266
266
  }
267
267
  });
268
268
  }
269
- function _patchValues(ctx, instance, target, valPath, newValues, newVariables, oldValues, oldVariables) {
269
+ /**
270
+ * A running element's values, patched with a new profile's: its hot-plug
271
+ * settings alone - those of a hot-plug group all of them. A list - of
272
+ * values or of groups - is replaced whole, never merged into an object.
273
+ * The paths changed are kept for its 'values-updated' event.
274
+ */
275
+ function _patchValues(ctx, instance, target, valPath, newValues, newVariables, oldValues, oldVariables, hot = false) {
270
276
  if (oldValues)
271
277
  Object.assign(target, oldValues);
272
278
  const updatedValues = ctx.valueUpdates?.get(instance) || [];
@@ -274,17 +280,20 @@ export var AppFactory;
274
280
  if (newVariables) {
275
281
  for (const [varKey, varMeta] of Object.entries(newVariables)) {
276
282
  const keyPath = valPath ? valPath + '.' + varKey : varKey;
277
- /** Update only hotplug variables */
278
- if (varMeta?.hotPlug !== true)
283
+ /** Update only hotplug variables, and all of a hotplug group */
284
+ if (!hot && varMeta?.hotPlug !== true)
279
285
  continue;
280
- if (varMeta.type === 'nested') {
286
+ if (varMeta.type === 'nested' && !varMeta.isArray) {
281
287
  target[varKey] = {};
282
- _patchValues(ctx, instance, target[varKey], keyPath, newValues[varKey], newVariables[varKey]?.variables || {}, oldValues?.[varKey], oldVariables?.[varKey]?.variables);
288
+ _patchValues(ctx, instance, target[varKey], keyPath, newValues?.[varKey], newVariables[varKey]?.variables || {}, oldValues?.[varKey], oldVariables?.[varKey]?.variables, true);
283
289
  continue;
284
290
  }
285
- if (!equal(target[varKey], newValues[varKey])) {
291
+ const value = newValues?.[varKey];
292
+ if (!equal(target[varKey], value)) {
286
293
  updatedValues.push(keyPath);
287
- target[varKey] = newValues[varKey];
294
+ /* Its own copy: the profile's left as it is */
295
+ target[varKey] =
296
+ value && typeof value === 'object' ? clone(value) : value;
288
297
  }
289
298
  }
290
299
  }
package/constants.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- export declare const version = "2.2.0";
1
+ export declare const version = "2.3.1";
2
2
  export declare const CLASS_METADATA: unique symbol;
3
3
  export declare const CLASS_TYPE: unique symbol;
4
4
  export declare const VARIABLE_CONTAINER: unique symbol;
package/constants.js CHANGED
@@ -1,4 +1,4 @@
1
- export const version = '2.2.0';
1
+ export const version = '2.3.1';
2
2
  export const CLASS_METADATA = Symbol.for('CLASS_METADATA');
3
3
  export const CLASS_TYPE = Symbol.for('CLASS_TYPE');
4
4
  export const VARIABLE_CONTAINER = Symbol.for('VARIABLE_CONTAINER');
@@ -23,3 +23,47 @@ export interface HostPackagePlanItem {
23
23
  export interface HostPackagesResolveResponse {
24
24
  items: HostPackagePlanItem[];
25
25
  }
26
+ /** Where, under Console's API, a host's packages' updates are asked */
27
+ export declare const HOST_PACKAGE_UPDATES_PATH = "host/packages/updates";
28
+ /** What a host asks of its packages' updates */
29
+ export interface HostPackageUpdatesRequest {
30
+ /**
31
+ * check: what is newer of the versions it has; download: grants to read
32
+ * the versions it installs
33
+ */
34
+ mode: 'check' | 'download';
35
+ /** "@org/name" -> its newest version installed (check), or the one it installs (download) */
36
+ packages: Record<string, string>;
37
+ }
38
+ /** A version offered: what it needs of the registry's packages */
39
+ export interface HostPackageOffer {
40
+ version: string;
41
+ /** Registry packages it depends on: name -> range */
42
+ dependencies: Record<string, string>;
43
+ }
44
+ /** What is newer of a package, or why it was not told */
45
+ export interface HostPackageUpdate {
46
+ name: string;
47
+ /** The version sent */
48
+ version: string;
49
+ /**
50
+ * NOT_FOUND: not in the registry, or (download) no such version;
51
+ * NO_ACCESS: the host's workspace may not use it; SUSPENDED (download):
52
+ * the version is suspended
53
+ */
54
+ problem?: 'NOT_FOUND' | 'NO_ACCESS' | 'SUSPENDED';
55
+ /** check: the newest of its minor, newer than the one sent (a fix) */
56
+ patch?: HostPackageOffer;
57
+ /** check: the newest of its major, newer than the one sent */
58
+ minor?: HostPackageOffer;
59
+ /** check: a newer major's newest - told, never installed without asking */
60
+ major?: string;
61
+ /** download: the version sent, its grant in its link; a few minutes good */
62
+ download?: HostPackagePlanItem & {
63
+ dependencies: Record<string, string>;
64
+ };
65
+ }
66
+ /** Each package sent, answered */
67
+ export interface HostPackageUpdatesResponse {
68
+ items: HostPackageUpdate[];
69
+ }
@@ -7,3 +7,15 @@
7
7
  */
8
8
  /** Where, under Console's API, a host's packages are planned */
9
9
  export const HOST_PACKAGES_PATH = 'host/packages';
10
+ /*
11
+ * A host's packages' updates: what the registry has newer of each package
12
+ * it has, asked in one call. To check, its installed versions sent - each
13
+ * answered the newest of its minor (a fix), of its major (fixes and
14
+ * features) and a newer major, told apart; nothing signed. To install, the
15
+ * very versions it takes sent - each answered with a short-lived grant to
16
+ * read it: read by it without its access asked again, unless that version,
17
+ * its package or the host's workspace is suspended, or the access ended,
18
+ * since.
19
+ */
20
+ /** Where, under Console's API, a host's packages' updates are asked */
21
+ export const HOST_PACKAGE_UPDATES_PATH = 'host/packages/updates';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@syncbridge/common",
3
- "version": "2.2.0",
3
+ "version": "2.3.1",
4
4
  "description": "SyncBridge Common utilities",
5
5
  "author": "Panates Inc",
6
6
  "license": "MIT",