@podium/client 4.5.32 → 4.5.34

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 CHANGED
@@ -1,3 +1,17 @@
1
+ ## [4.5.34](https://github.com/podium-lib/client/compare/v4.5.33...v4.5.34) (2023-10-09)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * update type definitions ([d63a621](https://github.com/podium-lib/client/commit/d63a621762909e01acd6d29629c6061a757df146))
7
+
8
+ ## [4.5.33](https://github.com/podium-lib/client/compare/v4.5.32...v4.5.33) (2023-09-19)
9
+
10
+
11
+ ### Bug Fixes
12
+
13
+ * **deps:** update dependency @metrics/client to v2.5.2 ([764886f](https://github.com/podium-lib/client/commit/764886fe374bc364c9b3efd83a35d3fd041e6c43))
14
+
1
15
  ## [4.5.32](https://github.com/podium-lib/client/compare/v4.5.31...v4.5.32) (2023-09-14)
2
16
 
3
17
 
package/README.md CHANGED
@@ -31,12 +31,12 @@ const component = client.register({
31
31
  });
32
32
 
33
33
  const stream = component.stream(new HttpIncoming());
34
- stream.once('beforeStream', res => {
34
+ stream.once('beforeStream', (res) => {
35
35
  console.log(res.headers);
36
36
  console.log(res.css);
37
37
  console.log(res.js);
38
38
  });
39
- stream.on('error', error => {
39
+ stream.on('error', (error) => {
40
40
  console.log(error);
41
41
  });
42
42
  stream.pipe(process.stdout);
@@ -58,13 +58,13 @@ const component = client.register({
58
58
 
59
59
  component
60
60
  .fetch(new HttpIncoming())
61
- .then(res => {
61
+ .then((res) => {
62
62
  console.log(res.content);
63
63
  console.log(res.headers);
64
64
  console.log(res.css);
65
65
  console.log(res.js);
66
66
  })
67
- .catch(error => {
67
+ .catch((error) => {
68
68
  console.log(error);
69
69
  });
70
70
  ```
@@ -299,7 +299,7 @@ When there is a change in state. See the section
299
299
 
300
300
  ```js
301
301
  const client = new Client();
302
- client.on('state', state => {
302
+ client.on('state', (state) => {
303
303
  console.log(state);
304
304
  });
305
305
 
@@ -330,7 +330,7 @@ Emits the new manifest.
330
330
 
331
331
  ```js
332
332
  const client = new Client();
333
- client.on('change', manifest => {
333
+ client.on('change', (manifest) => {
334
334
  console.log(manifest);
335
335
  });
336
336
 
@@ -421,7 +421,7 @@ otherwise `css` will be an empty string.
421
421
 
422
422
  ```js
423
423
  const stream = component.stream();
424
- stream.once('beforeStream', data => {
424
+ stream.once('beforeStream', (data) => {
425
425
  console.log(data.headers);
426
426
  console.log(data.css);
427
427
  console.log(data.js);
@@ -492,10 +492,10 @@ const bar = client.register({
492
492
  });
493
493
 
494
494
  Promise.all([foo.fetch(), bar.fetch()])
495
- .then(res => {
495
+ .then((res) => {
496
496
  console.log(res.content);
497
497
  })
498
- .catch(error => {
498
+ .catch((error) => {
499
499
  console.log(error);
500
500
  });
501
501
  ```
package/client.d.ts ADDED
@@ -0,0 +1,140 @@
1
+ import MetricsClient from '@metrics/client';
2
+ import { HttpIncoming, AssetJs, AssetCss } from '@podium/utils';
3
+ import { IncomingHttpHeaders, OutgoingHttpHeaders } from 'http';
4
+ import { Agent as HttpAgent } from 'http';
5
+ import { Agent as HttpsAgent } from 'https';
6
+
7
+ declare class PodiumClient {
8
+ constructor(options?: PodiumClient.PodiumClientOptions);
9
+
10
+ readonly metrics: MetricsClient;
11
+ readonly state:
12
+ | 'instantiated'
13
+ | 'initializing'
14
+ | 'unstable'
15
+ | 'stable'
16
+ | 'unhealthy';
17
+
18
+ register(
19
+ options: PodiumClient.RegisterOptions,
20
+ ): PodiumClient.PodiumClientResource;
21
+
22
+ /**
23
+ * Refreshes the manifests of all registered resources. Does so by calling the
24
+ * `.refresh()` method on all resources under the hood.
25
+ */
26
+ refreshManifests(): Promise<void>;
27
+ /**
28
+ * This method will refresh a resource by reading its manifest and fallback
29
+ * if defined in the manifest. The method will not call the URI to the content
30
+ * of a component.
31
+ */
32
+ refresh(): Promise<number>;
33
+
34
+ js(): Array<AssetJs>;
35
+ css(): Array<AssetCss>;
36
+ /**
37
+ * @returns An array of all loaded manifests ready to be used by `.load()`
38
+ */
39
+ dump(): PodiumClient.PodletManifest[];
40
+ /**
41
+ * Loads an Array of manifests (provided by `.dump()`) into the proxy. If any of
42
+ * the items in the loaded Array contains a key which is already in the cache, the
43
+ * entry in the cache will be overwritten.
44
+ *
45
+ * If any of the entries in the loaded Array are not compatible with the format
46
+ * which `.dump()` exports, they will not be inserted into the cache.
47
+ *
48
+ * @returns An Array with the keys which were inserted into the cache.
49
+ */
50
+ load(manifests: PodiumClient.PodletManifest[]): string[];
51
+ }
52
+
53
+ declare namespace PodiumClient {
54
+ export type PodletManifest = {
55
+ name: string;
56
+ version: string;
57
+ content: string;
58
+ fallback?: string;
59
+ proxy?: Record<string, string>;
60
+ assets?: {
61
+ js?: string[];
62
+ css?: string[];
63
+ };
64
+ css?: string[];
65
+ js?: string[];
66
+ };
67
+
68
+ type AbsLogger = {
69
+ trace: LogFunction;
70
+ debug: LogFunction;
71
+ info: LogFunction;
72
+ warn: LogFunction;
73
+ error: LogFunction;
74
+ fatal: LogFunction;
75
+ };
76
+
77
+ type LogFunction = (...args: any) => void;
78
+
79
+ export type PodiumClientOptions = {
80
+ name?: string;
81
+ logger?: AbsLogger | Console;
82
+ retries?: number;
83
+ timeout?: number;
84
+ maxAge?: number;
85
+ rejectUnauthorized?: boolean;
86
+ resolveThreshold?: number;
87
+ resolveMax?: number;
88
+ httpAgent?: HttpAgent;
89
+ httpsAgent?: HttpsAgent;
90
+ };
91
+ export interface PodiumClientResourceOptions {
92
+ pathname?: string;
93
+ headers?: OutgoingHttpHeaders;
94
+ query?: any;
95
+ }
96
+
97
+ export interface PodiumClientResponse {
98
+ readonly redirect: PodiumRedirect;
99
+ readonly content: string;
100
+ readonly headers: IncomingHttpHeaders;
101
+ readonly js: Array<AssetJs>;
102
+ readonly css: Array<AssetCss>;
103
+ }
104
+
105
+ export class PodiumClientResource {
106
+ readonly name: string;
107
+
108
+ readonly uri: string;
109
+
110
+ fetch(
111
+ incoming: HttpIncoming,
112
+ options?: PodiumClientResourceOptions,
113
+ ): Promise<PodiumClientResponse>;
114
+
115
+ stream(
116
+ incoming: HttpIncoming,
117
+ options?: PodiumClientResourceOptions,
118
+ ): ReadableStream<PodiumClientResponse>;
119
+
120
+ refresh(): Promise<boolean>;
121
+ }
122
+
123
+ export interface RegisterOptions {
124
+ uri: string;
125
+ name: string;
126
+ retries?: number;
127
+ timeout?: number;
128
+ throwable?: boolean;
129
+ redirectable?: boolean;
130
+ resolveJs?: boolean;
131
+ resolveCss?: boolean;
132
+ }
133
+
134
+ export interface PodiumRedirect {
135
+ readonly statusCode: number;
136
+ readonly location: string;
137
+ }
138
+ }
139
+
140
+ export = PodiumClient;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@podium/client",
3
- "version": "4.5.32",
3
+ "version": "4.5.34",
4
4
  "main": "lib/client.js",
5
5
  "license": "MIT",
6
6
  "keywords": [
@@ -21,12 +21,12 @@
21
21
  "files": [
22
22
  "package.json",
23
23
  "CHANGELOG.md",
24
- "index.d.ts",
24
+ "client.d.ts",
25
25
  "README.md",
26
26
  "LICENSE",
27
27
  "lib"
28
28
  ],
29
- "types": "index.d.ts",
29
+ "types": "client.d.ts",
30
30
  "scripts": {
31
31
  "lint": "eslint .",
32
32
  "lint:fix": "eslint --fix .",
@@ -36,9 +36,9 @@
36
36
  },
37
37
  "dependencies": {
38
38
  "@hapi/boom": "^9.0.0",
39
- "@metrics/client": "2.5.1",
39
+ "@metrics/client": "2.5.2",
40
40
  "@podium/schemas": "4.1.34",
41
- "@podium/utils": "4.4.39",
41
+ "@podium/utils": "4.4.40",
42
42
  "abslog": "2.4.0",
43
43
  "http-cache-semantics": "^4.0.3",
44
44
  "lodash.clonedeep": "^4.5.0",
@@ -67,6 +67,6 @@
67
67
  "is-stream": "2.0.1",
68
68
  "prettier": "2.8.8",
69
69
  "semantic-release": "18.0.1",
70
- "tap": "16.3.8"
70
+ "tap": "16.3.9"
71
71
  }
72
72
  }
package/index.d.ts DELETED
@@ -1,63 +0,0 @@
1
- import { HttpIncoming, AssetJs, AssetCss } from '@podium/utils';
2
- import { IncomingHttpHeaders, OutgoingHttpHeaders } from 'http';
3
-
4
- declare interface PodiumClientResourceOptions {
5
- pathname?: string;
6
- headers?: OutgoingHttpHeaders;
7
- query?: any;
8
- }
9
-
10
- declare interface PodiumClientResponse {
11
- readonly redirect: PodiumRedirect;
12
- readonly content: string;
13
- readonly headers: IncomingHttpHeaders;
14
- readonly js: Array<AssetJs>;
15
- readonly css: Array<AssetCss>;
16
- }
17
-
18
- declare class PodiumClientResource {
19
- readonly name: string;
20
-
21
- readonly uri: string;
22
-
23
- fetch(
24
- incoming: HttpIncoming,
25
- options?: PodiumClientResourceOptions,
26
- ): Promise<PodiumClientResponse>;
27
-
28
- stream(
29
- incoming: HttpIncoming,
30
- options?: PodiumClientResourceOptions,
31
- ): ReadableStream<PodiumClientResponse>;
32
-
33
- refresh(): Promise<boolean>;
34
- }
35
-
36
- declare interface RegisterOptions {
37
- uri: string;
38
- name: string;
39
- retries?: number;
40
- timeout?: number;
41
- throwable?: boolean;
42
- redirectable?: boolean;
43
- resolveJs?: boolean;
44
- resolveCss?: boolean;
45
- }
46
-
47
- declare interface PodiumRedirect {
48
- readonly statusCode: number;
49
- readonly location: string;
50
- }
51
-
52
- export default class PodiumClient {
53
- readonly state:
54
- | 'instantiated'
55
- | 'initializing'
56
- | 'unstable'
57
- | 'stable'
58
- | 'unhealthy';
59
-
60
- register(options: RegisterOptions): PodiumClientResource;
61
-
62
- refreshManifests(): Promise<void>;
63
- }