@podium/client 5.2.5-beta.4 → 5.2.6
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/CHANGELOG.md +2 -9
- package/lib/resolver.content.js +5 -10
- package/lib/resolver.fallback.js +4 -10
- package/lib/resolver.js +8 -10
- package/lib/resolver.manifest.js +11 -13
- package/package.json +2 -4
- package/types/resolver.content.d.ts +2 -2
- package/types/resolver.d.ts +0 -5
- package/types/resolver.fallback.d.ts +2 -2
- package/types/resolver.manifest.d.ts +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,16 +1,9 @@
|
|
|
1
|
-
## [5.2.
|
|
1
|
+
## [5.2.6](https://github.com/podium-lib/client/compare/v5.2.5...v5.2.6) (2025-01-16)
|
|
2
2
|
|
|
3
3
|
|
|
4
4
|
### Bug Fixes
|
|
5
5
|
|
|
6
|
-
*
|
|
7
|
-
|
|
8
|
-
## [5.2.5-beta.3](https://github.com/podium-lib/client/compare/v5.2.5-beta.2...v5.2.5-beta.3) (2025-01-13)
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
### Bug Fixes
|
|
12
|
-
|
|
13
|
-
* correctly build asset urls from link headers ([#446](https://github.com/podium-lib/client/issues/446)) ([89f9e0b](https://github.com/podium-lib/client/commit/89f9e0b44f87c45c1459dce7e53db4fa7fc85d17))
|
|
6
|
+
* **deps:** update dependency undici to v6.21.1 ([#453](https://github.com/podium-lib/client/issues/453)) ([2cf54ca](https://github.com/podium-lib/client/commit/2cf54cac312cf6cbb91da0e0f636433f2de7d892))
|
|
14
7
|
|
|
15
8
|
## [5.2.5](https://github.com/podium-lib/client/compare/v5.2.4...v5.2.5) (2024-11-27)
|
|
16
9
|
|
package/lib/resolver.content.js
CHANGED
|
@@ -6,9 +6,9 @@ import { Boom, badGateway } from '@hapi/boom';
|
|
|
6
6
|
import { join, dirname } from 'path';
|
|
7
7
|
import { fileURLToPath } from 'url';
|
|
8
8
|
import fs from 'fs';
|
|
9
|
-
import HttpClient from '@podium/http-client';
|
|
10
9
|
import * as utils from './utils.js';
|
|
11
10
|
import Response from './response.js';
|
|
11
|
+
import HTTP from './http.js';
|
|
12
12
|
import { parseLinkHeaders, filterAssets } from './utils.js';
|
|
13
13
|
import { AssetJs, AssetCss } from '@podium/utils';
|
|
14
14
|
|
|
@@ -25,7 +25,7 @@ const UA_STRING = `${pkg.name} ${pkg.version}`;
|
|
|
25
25
|
/**
|
|
26
26
|
* @typedef {object} PodletClientContentResolverOptions
|
|
27
27
|
* @property {string} clientName
|
|
28
|
-
* @property {import('
|
|
28
|
+
* @property {import('./http.js').default} [http]
|
|
29
29
|
* @property {import('abslog').AbstractLoggerOptions} [logger]
|
|
30
30
|
*/
|
|
31
31
|
|
|
@@ -41,9 +41,9 @@ export default class PodletClientContentResolver {
|
|
|
41
41
|
*/
|
|
42
42
|
// @ts-expect-error Deliberate default empty options for better error messages
|
|
43
43
|
constructor(options = {}) {
|
|
44
|
+
this.#http = options.http || new HTTP();
|
|
44
45
|
const name = options.clientName;
|
|
45
46
|
this.#log = abslog(options.logger);
|
|
46
|
-
this.#http = options.http || new HttpClient({ logger: options.logger });
|
|
47
47
|
this.#metrics = new Metrics();
|
|
48
48
|
this.#histogram = this.#metrics.histogram({
|
|
49
49
|
name: 'podium_client_resolver_content_resolve',
|
|
@@ -62,7 +62,6 @@ export default class PodletClientContentResolver {
|
|
|
62
62
|
error,
|
|
63
63
|
);
|
|
64
64
|
});
|
|
65
|
-
this.#http.metrics.pipe(this.#metrics);
|
|
66
65
|
}
|
|
67
66
|
|
|
68
67
|
get metrics() {
|
|
@@ -154,16 +153,11 @@ export default class PodletClientContentResolver {
|
|
|
154
153
|
);
|
|
155
154
|
|
|
156
155
|
try {
|
|
157
|
-
const url = new URL(uri);
|
|
158
156
|
const {
|
|
159
157
|
statusCode,
|
|
160
158
|
headers: hdrs,
|
|
161
159
|
body,
|
|
162
|
-
} = await this.#http.request(
|
|
163
|
-
origin: url.origin,
|
|
164
|
-
path: url.pathname,
|
|
165
|
-
...reqOptions,
|
|
166
|
-
});
|
|
160
|
+
} = await this.#http.request(uri, reqOptions);
|
|
167
161
|
|
|
168
162
|
const parsedAssetObjects = parseLinkHeaders(
|
|
169
163
|
hdrs.link,
|
|
@@ -261,6 +255,7 @@ export default class PodletClientContentResolver {
|
|
|
261
255
|
if (outgoing.redirectable && statusCode >= 300) {
|
|
262
256
|
outgoing.redirect = {
|
|
263
257
|
statusCode,
|
|
258
|
+
// @ts-expect-error TODO: look into what happens if the podlet returns more than one location header
|
|
264
259
|
location: hdrs && hdrs.location,
|
|
265
260
|
};
|
|
266
261
|
}
|
package/lib/resolver.fallback.js
CHANGED
|
@@ -3,9 +3,9 @@ import Metrics from '@metrics/client';
|
|
|
3
3
|
import { join, dirname } from 'path';
|
|
4
4
|
import { fileURLToPath } from 'url';
|
|
5
5
|
import fs from 'fs';
|
|
6
|
+
import HTTP from './http.js';
|
|
6
7
|
import { parseLinkHeaders, filterAssets } from './utils.js';
|
|
7
8
|
import { AssetJs, AssetCss } from '@podium/utils';
|
|
8
|
-
import HttpClient from '@podium/http-client';
|
|
9
9
|
|
|
10
10
|
const currentDirectory = dirname(fileURLToPath(import.meta.url));
|
|
11
11
|
|
|
@@ -20,7 +20,7 @@ const UA_STRING = `${pkg.name} ${pkg.version}`;
|
|
|
20
20
|
/**
|
|
21
21
|
* @typedef {object} PodletClientFallbackResolverOptions
|
|
22
22
|
* @property {string} clientName
|
|
23
|
-
* @property {import('
|
|
23
|
+
* @property {import('./http.js').default} [http]
|
|
24
24
|
* @property {import('abslog').AbstractLoggerOptions} [logger]
|
|
25
25
|
*/
|
|
26
26
|
|
|
@@ -36,9 +36,9 @@ export default class PodletClientFallbackResolver {
|
|
|
36
36
|
*/
|
|
37
37
|
// @ts-expect-error Deliberate default empty options for better error messages
|
|
38
38
|
constructor(options = {}) {
|
|
39
|
+
this.#http = options.http || new HTTP();
|
|
39
40
|
const name = options.clientName;
|
|
40
41
|
this.#log = abslog(options.logger);
|
|
41
|
-
this.#http = options.http || new HttpClient({ logger: options.logger });
|
|
42
42
|
this.#metrics = new Metrics();
|
|
43
43
|
this.#histogram = this.#metrics.histogram({
|
|
44
44
|
name: 'podium_client_resolver_fallback_resolve',
|
|
@@ -57,7 +57,6 @@ export default class PodletClientFallbackResolver {
|
|
|
57
57
|
error,
|
|
58
58
|
);
|
|
59
59
|
});
|
|
60
|
-
this.#http.metrics.pipe(this.#metrics);
|
|
61
60
|
}
|
|
62
61
|
|
|
63
62
|
get metrics() {
|
|
@@ -115,16 +114,11 @@ export default class PodletClientFallbackResolver {
|
|
|
115
114
|
this.#log.debug(
|
|
116
115
|
`start reading fallback content from remote resource - resource: ${outgoing.name} - url: ${outgoing.fallbackUri}`,
|
|
117
116
|
);
|
|
118
|
-
const url = new URL(outgoing.fallbackUri);
|
|
119
117
|
const {
|
|
120
118
|
statusCode,
|
|
121
119
|
body,
|
|
122
120
|
headers: resHeaders,
|
|
123
|
-
} = await this.#http.request(
|
|
124
|
-
origin: url.origin,
|
|
125
|
-
path: url.pathname,
|
|
126
|
-
...reqOptions,
|
|
127
|
-
});
|
|
121
|
+
} = await this.#http.request(outgoing.fallbackUri, reqOptions);
|
|
128
122
|
|
|
129
123
|
const parsedAssetObjects = parseLinkHeaders(
|
|
130
124
|
resHeaders.link,
|
package/lib/resolver.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import Metrics from '@metrics/client';
|
|
2
2
|
import abslog from 'abslog';
|
|
3
3
|
import assert from 'assert';
|
|
4
|
-
import
|
|
4
|
+
import HTTP from './http.js';
|
|
5
5
|
import Manifest from './resolver.manifest.js';
|
|
6
6
|
import Fallback from './resolver.fallback.js';
|
|
7
7
|
import Content from './resolver.content.js';
|
|
@@ -9,7 +9,6 @@ import Cache from './resolver.cache.js';
|
|
|
9
9
|
|
|
10
10
|
/**
|
|
11
11
|
* @typedef {object} PodletClientResolverOptions
|
|
12
|
-
* @property {string} name - the name of the resource
|
|
13
12
|
* @property {string} clientName
|
|
14
13
|
* @property {import('abslog').AbstractLoggerOptions} [logger]
|
|
15
14
|
* @property {boolean} [earlyHints]
|
|
@@ -35,18 +34,18 @@ export default class PodletClientResolver {
|
|
|
35
34
|
);
|
|
36
35
|
|
|
37
36
|
const log = abslog(options.logger);
|
|
38
|
-
const
|
|
39
|
-
clientName: options.name,
|
|
40
|
-
logger: options.logger,
|
|
41
|
-
});
|
|
37
|
+
const http = new HTTP();
|
|
42
38
|
this.#cache = new Cache(registry, options);
|
|
43
39
|
this.#manifest = new Manifest({
|
|
44
40
|
clientName: options.clientName,
|
|
45
41
|
logger: options.logger,
|
|
46
|
-
http
|
|
42
|
+
http,
|
|
43
|
+
});
|
|
44
|
+
this.#fallback = new Fallback({ ...options, http });
|
|
45
|
+
this.#content = new Content({
|
|
46
|
+
...options,
|
|
47
|
+
http,
|
|
47
48
|
});
|
|
48
|
-
this.#fallback = new Fallback({ ...options, http: httpClient });
|
|
49
|
-
this.#content = new Content({ ...options, http: httpClient });
|
|
50
49
|
this.#metrics = new Metrics();
|
|
51
50
|
|
|
52
51
|
this.#metrics.on('error', (error) => {
|
|
@@ -56,7 +55,6 @@ export default class PodletClientResolver {
|
|
|
56
55
|
);
|
|
57
56
|
});
|
|
58
57
|
|
|
59
|
-
httpClient.metrics.pipe(this.#metrics);
|
|
60
58
|
this.#content.metrics.pipe(this.#metrics);
|
|
61
59
|
this.#fallback.metrics.pipe(this.#metrics);
|
|
62
60
|
this.#manifest.metrics.pipe(this.#metrics);
|
package/lib/resolver.manifest.js
CHANGED
|
@@ -6,7 +6,7 @@ import * as utils from '@podium/utils';
|
|
|
6
6
|
import { join, dirname } from 'path';
|
|
7
7
|
import { fileURLToPath } from 'url';
|
|
8
8
|
import fs from 'fs';
|
|
9
|
-
import
|
|
9
|
+
import HTTP from './http.js';
|
|
10
10
|
|
|
11
11
|
const currentDirectory = dirname(fileURLToPath(import.meta.url));
|
|
12
12
|
|
|
@@ -22,7 +22,7 @@ const UA_STRING = `${pkg.name} ${pkg.version}`;
|
|
|
22
22
|
* @typedef {object} PodletClientManifestResolverOptions
|
|
23
23
|
* @property {string} clientName
|
|
24
24
|
* @property {import('abslog').AbstractLoggerOptions} [logger]
|
|
25
|
-
* @property {import('
|
|
25
|
+
* @property {import('./http.js').default} [http]
|
|
26
26
|
*/
|
|
27
27
|
|
|
28
28
|
export default class PodletClientManifestResolver {
|
|
@@ -37,9 +37,9 @@ export default class PodletClientManifestResolver {
|
|
|
37
37
|
*/
|
|
38
38
|
// @ts-expect-error Deliberate default empty options for better error messages
|
|
39
39
|
constructor(options = {}) {
|
|
40
|
+
this.#http = options.http || new HTTP();
|
|
40
41
|
const name = options.clientName;
|
|
41
42
|
this.#log = abslog(options.logger);
|
|
42
|
-
this.#http = options.http || new HttpClient({ logger: this.#log });
|
|
43
43
|
this.#metrics = new Metrics();
|
|
44
44
|
this.#histogram = this.#metrics.histogram({
|
|
45
45
|
name: 'podium_client_resolver_manifest_resolve',
|
|
@@ -58,7 +58,6 @@ export default class PodletClientManifestResolver {
|
|
|
58
58
|
error,
|
|
59
59
|
);
|
|
60
60
|
});
|
|
61
|
-
this.#http.metrics.pipe(this.#metrics);
|
|
62
61
|
}
|
|
63
62
|
|
|
64
63
|
get metrics() {
|
|
@@ -98,12 +97,10 @@ export default class PodletClientManifestResolver {
|
|
|
98
97
|
);
|
|
99
98
|
|
|
100
99
|
try {
|
|
101
|
-
const
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
...reqOptions,
|
|
106
|
-
});
|
|
100
|
+
const response = await this.#http.request(
|
|
101
|
+
outgoing.manifestUri,
|
|
102
|
+
reqOptions,
|
|
103
|
+
);
|
|
107
104
|
const { statusCode, headers: hdrs, body } = response;
|
|
108
105
|
|
|
109
106
|
// Remote responds but with an http error code
|
|
@@ -123,10 +120,11 @@ export default class PodletClientManifestResolver {
|
|
|
123
120
|
await body.text();
|
|
124
121
|
return outgoing;
|
|
125
122
|
}
|
|
126
|
-
|
|
127
|
-
const schema = await body.json();
|
|
123
|
+
|
|
128
124
|
const manifest = validateManifest(
|
|
129
|
-
/** @type {import("@podium/schemas").PodletManifestSchema} */
|
|
125
|
+
/** @type {import("@podium/schemas").PodletManifestSchema} */ (
|
|
126
|
+
await body.json()
|
|
127
|
+
),
|
|
130
128
|
);
|
|
131
129
|
|
|
132
130
|
// Manifest validation error
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@podium/client",
|
|
3
|
-
"version": "5.2.
|
|
3
|
+
"version": "5.2.6",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"keywords": [
|
|
@@ -39,15 +39,13 @@
|
|
|
39
39
|
"dependencies": {
|
|
40
40
|
"@hapi/boom": "10.0.1",
|
|
41
41
|
"@metrics/client": "2.5.4",
|
|
42
|
-
"@podium/http-client": "1.0.0-beta.9",
|
|
43
42
|
"@podium/schemas": "5.1.0",
|
|
44
43
|
"@podium/utils": "5.4.0",
|
|
45
44
|
"abslog": "2.4.4",
|
|
46
45
|
"http-cache-semantics": "^4.0.3",
|
|
47
46
|
"lodash.clonedeep": "^4.5.0",
|
|
48
|
-
"opossum": "^8.3.0",
|
|
49
47
|
"ttl-mem-cache": "4.1.0",
|
|
50
|
-
"undici": "6.21.
|
|
48
|
+
"undici": "6.21.1"
|
|
51
49
|
},
|
|
52
50
|
"devDependencies": {
|
|
53
51
|
"@podium/eslint-config": "1.0.5",
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @typedef {object} PodletClientContentResolverOptions
|
|
3
3
|
* @property {string} clientName
|
|
4
|
-
* @property {import('
|
|
4
|
+
* @property {import('./http.js').default} [http]
|
|
5
5
|
* @property {import('abslog').AbstractLoggerOptions} [logger]
|
|
6
6
|
*/
|
|
7
7
|
export default class PodletClientContentResolver {
|
|
@@ -23,7 +23,7 @@ export default class PodletClientContentResolver {
|
|
|
23
23
|
}
|
|
24
24
|
export type PodletClientContentResolverOptions = {
|
|
25
25
|
clientName: string;
|
|
26
|
-
http?:
|
|
26
|
+
http?: import("./http.js").default;
|
|
27
27
|
logger?: import("abslog").AbstractLoggerOptions;
|
|
28
28
|
};
|
|
29
29
|
import Metrics from '@metrics/client';
|
package/types/resolver.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @typedef {object} PodletClientResolverOptions
|
|
3
|
-
* @property {string} name - the name of the resource
|
|
4
3
|
* @property {string} clientName
|
|
5
4
|
* @property {import('abslog').AbstractLoggerOptions} [logger]
|
|
6
5
|
* @property {boolean} [earlyHints]
|
|
@@ -31,10 +30,6 @@ export default class PodletClientResolver {
|
|
|
31
30
|
#private;
|
|
32
31
|
}
|
|
33
32
|
export type PodletClientResolverOptions = {
|
|
34
|
-
/**
|
|
35
|
-
* - the name of the resource
|
|
36
|
-
*/
|
|
37
|
-
name: string;
|
|
38
33
|
clientName: string;
|
|
39
34
|
logger?: import("abslog").AbstractLoggerOptions;
|
|
40
35
|
earlyHints?: boolean;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @typedef {object} PodletClientFallbackResolverOptions
|
|
3
3
|
* @property {string} clientName
|
|
4
|
-
* @property {import('
|
|
4
|
+
* @property {import('./http.js').default} [http]
|
|
5
5
|
* @property {import('abslog').AbstractLoggerOptions} [logger]
|
|
6
6
|
*/
|
|
7
7
|
export default class PodletClientFallbackResolver {
|
|
@@ -23,7 +23,7 @@ export default class PodletClientFallbackResolver {
|
|
|
23
23
|
}
|
|
24
24
|
export type PodletClientFallbackResolverOptions = {
|
|
25
25
|
clientName: string;
|
|
26
|
-
http?:
|
|
26
|
+
http?: import("./http.js").default;
|
|
27
27
|
logger?: import("abslog").AbstractLoggerOptions;
|
|
28
28
|
};
|
|
29
29
|
import Metrics from '@metrics/client';
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* @typedef {object} PodletClientManifestResolverOptions
|
|
3
3
|
* @property {string} clientName
|
|
4
4
|
* @property {import('abslog').AbstractLoggerOptions} [logger]
|
|
5
|
-
* @property {import('
|
|
5
|
+
* @property {import('./http.js').default} [http]
|
|
6
6
|
*/
|
|
7
7
|
export default class PodletClientManifestResolver {
|
|
8
8
|
/**
|
|
@@ -22,6 +22,6 @@ export default class PodletClientManifestResolver {
|
|
|
22
22
|
export type PodletClientManifestResolverOptions = {
|
|
23
23
|
clientName: string;
|
|
24
24
|
logger?: import("abslog").AbstractLoggerOptions;
|
|
25
|
-
http?:
|
|
25
|
+
http?: import("./http.js").default;
|
|
26
26
|
};
|
|
27
27
|
import Metrics from '@metrics/client';
|