@syncbridge/common 2.4.0 → 2.6.0

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/constants.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- export declare const version = "2.4.0";
1
+ export declare const version = "2.6.0";
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.4.0';
1
+ export const version = '2.6.0';
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');
@@ -8,7 +8,22 @@ export interface HostPackagesResolveRequest {
8
8
  range?: string;
9
9
  /** What it has: each package's versions installed */
10
10
  installed?: Record<string, string[]>;
11
+ /** What it provides the packages as peers: versions it cannot take not planned */
12
+ host?: HostProvides;
11
13
  }
14
+ /**
15
+ * The npm packages a host provides its registry packages as peers - the
16
+ * SDK's, "@syncbridge/common" and the like - each with its version: a
17
+ * version peering on a newer one than the host has cannot run there, and
18
+ * is not offered to it
19
+ */
20
+ export type HostProvides = Record<string, string>;
21
+ /**
22
+ * The peers of a version the host does not satisfy: each named with the
23
+ * range it asks. Only the peers the host names are judged; any other is
24
+ * left to the host's own check as it installs.
25
+ */
26
+ export declare function unmetPeers(peers: Record<string, string> | undefined, host: HostProvides | undefined): Record<string, string>;
12
27
  /** A package of the plan, to be installed in its turn */
13
28
  export interface HostPackagePlanItem {
14
29
  name: string;
@@ -34,12 +49,26 @@ export interface HostPackageUpdatesRequest {
34
49
  mode: 'check' | 'download';
35
50
  /** "@org/name" -> its newest version installed (check), or the one it installs (download) */
36
51
  packages: Record<string, string>;
52
+ /**
53
+ * check: what it provides the packages as peers - a version peering on
54
+ * more than it has is not offered, but told as held. Not sent (a host
55
+ * before it): offered as before.
56
+ */
57
+ host?: HostProvides;
37
58
  }
38
59
  /** A version offered: what it needs of the registry's packages */
39
60
  export interface HostPackageOffer {
40
61
  version: string;
41
62
  /** Registry packages it depends on: name -> range */
42
63
  dependencies: Record<string, string>;
64
+ /** What it needs of the host: npm package -> range; checked again by the host */
65
+ peerDependencies?: Record<string, string>;
66
+ }
67
+ /** A newer version the host cannot take: what it lacks of what it would need */
68
+ export interface HostPackageHeld {
69
+ version: string;
70
+ /** The peers the host does not satisfy: npm package -> the range asked */
71
+ needs: Record<string, string>;
43
72
  }
44
73
  /** What is newer of a package, or why it was not told */
45
74
  export interface HostPackageUpdate {
@@ -56,6 +85,12 @@ export interface HostPackageUpdate {
56
85
  patch?: HostPackageOffer;
57
86
  /** check: the newest of its major, newer than the one sent */
58
87
  minor?: HostPackageOffer;
88
+ /**
89
+ * check: the newest of its major newer than `minor` (or than the one
90
+ * sent) that the host cannot take - peering on more than it provides:
91
+ * told, waiting for the host's update
92
+ */
93
+ held?: HostPackageHeld;
59
94
  /** check: a newer major's newest - told, never installed without asking */
60
95
  major?: string;
61
96
  /** download: the version sent, its grant in its link; a few minutes good */
@@ -1,3 +1,4 @@
1
+ import semver from 'semver';
1
2
  /*
2
3
  * Packages a host installs from the registry: it asks Console for a plan -
3
4
  * the version of what it wants, the registry packages it needs that it
@@ -7,6 +8,21 @@
7
8
  */
8
9
  /** Where, under Console's API, a host's packages are planned */
9
10
  export const HOST_PACKAGES_PATH = 'host/packages';
11
+ /**
12
+ * The peers of a version the host does not satisfy: each named with the
13
+ * range it asks. Only the peers the host names are judged; any other is
14
+ * left to the host's own check as it installs.
15
+ */
16
+ export function unmetPeers(peers, host) {
17
+ const unmet = {};
18
+ for (const [name, range] of Object.entries(peers || {})) {
19
+ const version = host?.[name];
20
+ if (version &&
21
+ !semver.satisfies(version, range, { includePrerelease: true }))
22
+ unmet[name] = range;
23
+ }
24
+ return unmet;
25
+ }
10
26
  /*
11
27
  * A host's packages' updates: what the registry has newer of each package
12
28
  * it has, asked in one call. To check, its installed versions sent - each
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@syncbridge/common",
3
- "version": "2.4.0",
3
+ "version": "2.6.0",
4
4
  "description": "SyncBridge Common utilities",
5
5
  "author": "Panates Inc",
6
6
  "license": "MIT",
@@ -20,6 +20,7 @@ export const SDK_PACKAGES = [
20
20
  '@syncbridge/syncbuild',
21
21
  '@syncbridge/testing',
22
22
  '@syncbridge/plugin-api',
23
+ '@syncbridge/pnpm-config',
23
24
  ];
24
25
  /** Whether a name is one of the SDK's packages, which come from npm */
25
26
  export const isSdkPackage = (name) => SDK_PACKAGES.includes(name);