@syncbridge/common 2.4.0 → 2.5.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 +1 -1
- package/constants.js +1 -1
- package/host-link/host-packages.d.ts +35 -0
- package/host-link/host-packages.js +16 -0
- package/package.json +1 -1
package/constants.d.ts
CHANGED
package/constants.js
CHANGED
|
@@ -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
|