@podium/client 4.5.23 → 5.0.0-next.11

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,8 +1,67 @@
1
+ # [5.0.0-next.11](https://github.com/podium-lib/client/compare/v5.0.0-next.10...v5.0.0-next.11) (2022-09-08)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * Fix inspect method on response object ([#294](https://github.com/podium-lib/client/issues/294)) ([94d1485](https://github.com/podium-lib/client/commit/94d14856ca2280888aa50e9cb7e7f782cd49666a))
7
+
8
+ # [5.0.0-next.10](https://github.com/podium-lib/client/compare/v5.0.0-next.9...v5.0.0-next.10) (2022-09-07)
9
+
10
+
11
+ ### Bug Fixes
12
+
13
+ * Lower log level when throwable is true ([#291](https://github.com/podium-lib/client/issues/291)) ([c0d779b](https://github.com/podium-lib/client/commit/c0d779b3e22b671e5f7c6496c504b38cd9da5125))
14
+
15
+ # [5.0.0-next.9](https://github.com/podium-lib/client/compare/v5.0.0-next.8...v5.0.0-next.9) (2022-05-09)
1
16
  ## [4.5.23](https://github.com/podium-lib/client/compare/v4.5.22...v4.5.23) (2022-09-01)
2
17
 
3
18
 
4
19
  ### Bug Fixes
5
20
 
21
+ * add 'redirect' to 'PodiumClientResponse' interface ([#235](https://github.com/podium-lib/client/issues/235)) ([6670007](https://github.com/podium-lib/client/commit/667000727187402d112c1087a4356492489a4003))
22
+ * **deps:** update dependency @podium/schemas to v4.1.17 ([6d249ed](https://github.com/podium-lib/client/commit/6d249ed8c3718642e78e71be6022feb113635ba8))
23
+ * **deps:** update dependency @podium/schemas to v4.1.18 ([36ca4a1](https://github.com/podium-lib/client/commit/36ca4a1425e227e30fd487a7e60908075628c32b))
24
+ * **deps:** update dependency @podium/schemas to v4.1.19 ([8a7f288](https://github.com/podium-lib/client/commit/8a7f288a57ce2d09d4cace08b836ef6c934a802c))
25
+ * **deps:** update dependency @podium/schemas to v4.1.20 ([b9c7ef4](https://github.com/podium-lib/client/commit/b9c7ef4665eb7aa852e9e3576bf89a0ee45c5fee))
26
+ * **deps:** update dependency @podium/schemas to v4.1.21 ([5a12fbd](https://github.com/podium-lib/client/commit/5a12fbdadd9a0f8ae1b4343ca33267852aa49aa0))
27
+ * **deps:** update dependency @podium/schemas to v4.1.22 ([a6ca70a](https://github.com/podium-lib/client/commit/a6ca70a87fdd264cfbefb0f5ecbe60c871606b00))
28
+ * **deps:** update dependency @podium/schemas to v4.1.23 ([0ad1042](https://github.com/podium-lib/client/commit/0ad104279a9a299737db5bbc5c2e65e43bacbc03))
29
+ * **deps:** update dependency @podium/schemas to v4.1.24 ([4cbad88](https://github.com/podium-lib/client/commit/4cbad88fc1a6b79627d0901e877fa9422292161d))
30
+ * **deps:** update dependency @podium/schemas to v4.1.25 ([8a8caa1](https://github.com/podium-lib/client/commit/8a8caa1c114c49b48a91383d45a75eb157e30140))
31
+ * **deps:** update dependency @podium/schemas to v4.1.26 ([a11d701](https://github.com/podium-lib/client/commit/a11d7019f9faeba1327af6df1b8377ae464c71b2))
32
+ * **deps:** update dependency @podium/schemas to v4.1.27 ([9b1d8d7](https://github.com/podium-lib/client/commit/9b1d8d711b435af1d517dc5d8e924d257cef529b))
33
+ * **deps:** update dependency @podium/schemas to v4.1.28 ([36e5398](https://github.com/podium-lib/client/commit/36e539822af10998a16c332b1303e1c8919f0ab3))
34
+ * **deps:** update dependency @podium/schemas to v4.1.29 ([7664934](https://github.com/podium-lib/client/commit/7664934071f7244a6c0213ea6c0a64153c435ed9))
35
+ * **deps:** update dependency @podium/schemas to v4.1.30 ([1a1c18e](https://github.com/podium-lib/client/commit/1a1c18e63a7a8130fcd450ffd9a03c11967d7416))
36
+ * **deps:** update dependency @podium/schemas to v4.1.31 ([563ebb7](https://github.com/podium-lib/client/commit/563ebb7c731f962250b56ba75d85689ebd92241e))
37
+ * **deps:** update dependency @podium/schemas to v4.1.32 ([fc13291](https://github.com/podium-lib/client/commit/fc13291ca3b6366d878bdd6bfdf10406dff11e74))
38
+ * **deps:** update dependency @podium/utils to v4.4.18 ([0448d3e](https://github.com/podium-lib/client/commit/0448d3ef39bfef8715b4e66ef8dc41a9634cd4cb))
39
+ * **deps:** update dependency @podium/utils to v4.4.19 ([e0c2c34](https://github.com/podium-lib/client/commit/e0c2c349fbf4d2db4efe060c0b883b07d6f0bcd8))
40
+ * **deps:** update dependency @podium/utils to v4.4.20 ([6b9b3f6](https://github.com/podium-lib/client/commit/6b9b3f630d521c189dca3b0acaecc46afe995036))
41
+ * **deps:** update dependency @podium/utils to v4.4.21 ([c007b67](https://github.com/podium-lib/client/commit/c007b67d118f3b88a8f91b915173dadb2b9026d0))
42
+ * **deps:** update dependency @podium/utils to v4.4.22 ([f65fbd0](https://github.com/podium-lib/client/commit/f65fbd00f2fe8256cc6290193dabd346907a1bda))
43
+ * **deps:** update dependency @podium/utils to v4.4.23 ([81200ea](https://github.com/podium-lib/client/commit/81200eabf600006f5c208e984acb4b81b28a725e))
44
+ * **deps:** update dependency @podium/utils to v4.4.24 ([747e73a](https://github.com/podium-lib/client/commit/747e73a7e737734b28520546bd6d449ab05497c8))
45
+ * **deps:** update dependency @podium/utils to v4.4.25 ([8e82542](https://github.com/podium-lib/client/commit/8e8254212ee69a01ba5b35c39aca2a2f558491b9))
46
+ * **deps:** update dependency @podium/utils to v4.4.26 ([9487380](https://github.com/podium-lib/client/commit/948738052a9d34294d52a0651c46b01043fa7852))
47
+ * **deps:** update dependency @podium/utils to v4.4.27 ([556a158](https://github.com/podium-lib/client/commit/556a158d1a341cca6f5e550de5882719b5169ac0))
48
+ * **deps:** update dependency @podium/utils to v4.4.28 ([581bdc6](https://github.com/podium-lib/client/commit/581bdc667d09d2b71e899691109a88b39b2b6847))
49
+ * **deps:** update dependency @podium/utils to v4.4.29 ([f33f1d9](https://github.com/podium-lib/client/commit/f33f1d93c33c7984b413b4781663a80c5dc52237))
50
+ * **deps:** update dependency @podium/utils to v4.4.30 ([954b607](https://github.com/podium-lib/client/commit/954b60788ca1d5677b143a473058e92c7ffcfef1))
51
+ * **deps:** update dependency @podium/utils to v4.4.31 ([0afdb26](https://github.com/podium-lib/client/commit/0afdb2648742e78b25e72bd46b6d345675574993))
52
+ * **deps:** update dependency @podium/utils to v4.4.32 ([798ed3a](https://github.com/podium-lib/client/commit/798ed3a5a89ccc046240f61f7bb85cc21045d0cf))
53
+ * **deps:** update dependency @podium/utils to v4.4.33 ([1136b6f](https://github.com/podium-lib/client/commit/1136b6f76d28229746f91b2fb1d44945c469dfd4))
54
+ * **deps:** update dependency @podium/utils to v4.4.34 ([81967fc](https://github.com/podium-lib/client/commit/81967fce15722ccfaab1ea64a6da475a319c5ab3))
55
+ * **deps:** update dependency @podium/utils to v4.4.35 ([9ba9720](https://github.com/podium-lib/client/commit/9ba9720698f1ce8548e8f76c07636a9f1ad44ac1))
56
+ * **deps:** update dependency @podium/utils to v4.4.36 ([6ca8bee](https://github.com/podium-lib/client/commit/6ca8bee3a3e49cfc10b55116ea8dd359ac3d2ebc))
57
+
58
+
59
+ ### Features
60
+
61
+ * Support mixed protocols ([#228](https://github.com/podium-lib/client/issues/228)) ([f1e42fe](https://github.com/podium-lib/client/commit/f1e42feb298e755b1274e5cf79cf77243457c538))
62
+
63
+ # [5.0.0-next.8](https://github.com/podium-lib/client/compare/v5.0.0-next.7...v5.0.0-next.8) (2021-05-17)
64
+
6
65
  * Lower log level when throwable is true ([#291](https://github.com/podium-lib/client/issues/291)) ([c0d779b](https://github.com/podium-lib/client/commit/c0d779b3e22b671e5f7c6496c504b38cd9da5125))
7
66
 
8
67
  ## [4.5.22](https://github.com/podium-lib/client/compare/v4.5.21...v4.5.22) (2022-03-23)
@@ -164,6 +223,9 @@
164
223
 
165
224
  ### Features
166
225
 
226
+ * Use native streams ([#215](https://github.com/podium-lib/client/issues/215)) ([f949c9c](https://github.com/podium-lib/client/commit/f949c9cc0d66431685138ca2c0367aec622bce78))
227
+
228
+ # [5.0.0-next.7](https://github.com/podium-lib/client/compare/v5.0.0-next.6...v5.0.0-next.7) (2021-05-05)
167
229
  * Support mixed protocols ([#228](https://github.com/podium-lib/client/issues/228)) ([f1e42fe](https://github.com/podium-lib/client/commit/f1e42feb298e755b1274e5cf79cf77243457c538))
168
230
 
169
231
  ## [4.4.33](https://github.com/podium-lib/client/compare/v4.4.32...v4.4.33) (2021-07-16)
@@ -171,6 +233,39 @@
171
233
 
172
234
  ### Bug Fixes
173
235
 
236
+ * **deps:** update dependency @podium/schemas to v4.0.4 ([#136](https://github.com/podium-lib/client/issues/136)) ([9f71f0f](https://github.com/podium-lib/client/commit/9f71f0fe3c579d58c6a3b5376f8d9a0f3165867e)), closes [#142](https://github.com/podium-lib/client/issues/142)
237
+ * **deps:** update dependency @podium/schemas to v4.0.5 ([e9263c9](https://github.com/podium-lib/client/commit/e9263c9c7d7a890bd913249ea29adce9ed786ea3))
238
+ * **deps:** update dependency @podium/schemas to v4.1.10 ([8f12c52](https://github.com/podium-lib/client/commit/8f12c52ed6e3f0e214e66ee4c293e65422a0b9f2))
239
+ * **deps:** update dependency @podium/schemas to v4.1.11 ([4f136aa](https://github.com/podium-lib/client/commit/4f136aa20e99537dc8e4633133325b95a035640f))
240
+ * **deps:** update dependency @podium/schemas to v4.1.14 ([3870a77](https://github.com/podium-lib/client/commit/3870a77ccd7d03f05f051e42c49dfa4b1cd25e14))
241
+ * **deps:** update dependency @podium/schemas to v4.1.15 ([f9eea3f](https://github.com/podium-lib/client/commit/f9eea3faa87047316ace92382780899fc6d1533e))
242
+ * **deps:** update dependency @podium/schemas to v4.1.16 ([2156ae4](https://github.com/podium-lib/client/commit/2156ae49c6832a9d9895bdb4d506b83c5c67205e))
243
+ * **deps:** update dependency @podium/utils to v4.3.1 ([f5483b6](https://github.com/podium-lib/client/commit/f5483b6445baf36e6d1d33daa59da564a42ef33e))
244
+ * **deps:** update dependency @podium/utils to v4.3.3 ([f4ee3a2](https://github.com/podium-lib/client/commit/f4ee3a2d6e821cfd9033deac4ed5661c0eb5fbf8))
245
+ * **deps:** update dependency @podium/utils to v4.4.0 ([f3712b3](https://github.com/podium-lib/client/commit/f3712b3be5e17d0e2956e9e4cae3cf79696a3634))
246
+ * **deps:** update dependency @podium/utils to v4.4.1 ([3f0dddc](https://github.com/podium-lib/client/commit/3f0dddcf3b203d1903dc13fa4522c632459ae48b))
247
+ * **deps:** update dependency @podium/utils to v4.4.13 ([6771733](https://github.com/podium-lib/client/commit/67717335c91b5366c2931cbf8d34e5d62c720678))
248
+ * **deps:** update dependency @podium/utils to v4.4.14 ([cd7ed39](https://github.com/podium-lib/client/commit/cd7ed39fadf12232a6fc67678815dd30c8a076ac))
249
+ * **deps:** update dependency @podium/utils to v4.4.15 ([ce00590](https://github.com/podium-lib/client/commit/ce00590e5c5eb23ca138f4337605b8a84787e01c))
250
+ * **deps:** update dependency @podium/utils to v4.4.16 ([f0bfe5f](https://github.com/podium-lib/client/commit/f0bfe5f24d4fc0a69e36cab7e80b0d8d11415aca))
251
+ * **deps:** update dependency @podium/utils to v4.4.17 ([a57669c](https://github.com/podium-lib/client/commit/a57669c5e26745a04b5e7b453db41049d7aea8c7))
252
+ * Update @podium/schema to version 4.1.9 to fix ajv error ([#188](https://github.com/podium-lib/client/issues/188)) ([1b03065](https://github.com/podium-lib/client/commit/1b0306562a15e0fe496adb22bf9b2aa76ac26436))
253
+
254
+
255
+ ### Features
256
+
257
+ * Convert to ESM ([#206](https://github.com/podium-lib/client/issues/206)) ([d31298f](https://github.com/podium-lib/client/commit/d31298fac7e1b84dc401c5832bce132a68a84943))
258
+
259
+
260
+ ### BREAKING CHANGES
261
+
262
+ * Convert from CommonJS to ESM
263
+
264
+ * fix: Remove outcommented code
265
+
266
+ Co-authored-by: Trygve Lie <trygve.lie@finn.no>
267
+
268
+ # [5.0.0-next.6](https://github.com/podium-lib/client/compare/v5.0.0-next.5...v5.0.0-next.6) (2020-10-06)
174
269
  * **deps:** update dependency @podium/utils to v4.4.24 ([747e73a](https://github.com/podium-lib/client/commit/747e73a7e737734b28520546bd6d449ab05497c8))
175
270
 
176
271
  ## [4.4.32](https://github.com/podium-lib/client/compare/v4.4.31...v4.4.32) (2021-07-16)
@@ -269,6 +364,107 @@
269
364
 
270
365
  ### Bug Fixes
271
366
 
367
+ * emit errors on stream when .resolve method rejects ([#141](https://github.com/podium-lib/client/issues/141)) ([9bc989b](https://github.com/podium-lib/client/commit/9bc989b3f5190a2f19fe66420d54a2c23bbe574a))
368
+
369
+ # [5.0.0-next.5](https://github.com/podium-lib/client/compare/v5.0.0-next.4...v5.0.0-next.5) (2020-07-28)
370
+
371
+
372
+ ### Features
373
+
374
+ * Use ES private properties instead of Symbols and defineProperty for privacy ([#131](https://github.com/podium-lib/client/issues/131)) ([2787a6c](https://github.com/podium-lib/client/commit/2787a6c406f9fb2bb2e85583082b818c2c247b63))
375
+
376
+
377
+ ### BREAKING CHANGES
378
+
379
+ * Due to dropping node 10.x support we use ES private properties instead of Symbols and `.defineProperty()`.
380
+
381
+ We've been using Symbols and `.defineProperty()` to define private properties in classes up until now. This has the downside that they are not true private and in later versions of node.js one would see these Symbols when inspecting an object. What we want is proper private properties.
382
+
383
+ This PR does also add a pretty printer which outputs an object literal or the object so when debugging one can see the getters and setters of the object.
384
+
385
+ Example: printing a object with `console.log()` would previously print the following:
386
+
387
+ ```sh
388
+ PodiumClientResponse {
389
+ [Symbol(podium:client:response:redirect)]: '',
390
+ [Symbol(podium:client:response:content)]: '',
391
+ [Symbol(podium:client:response:headers)]: {},
392
+ [Symbol(podium:client:response:css)]: [],
393
+ [Symbol(podium:client:response:js)]: []
394
+ }
395
+ ```
396
+
397
+ Now the following will be printed:
398
+
399
+ ```sh
400
+ {
401
+ redirect: '',
402
+ content: '',
403
+ headers: {},
404
+ css: [],
405
+ js: []
406
+ }
407
+ ```
408
+
409
+ Co-authored-by: Trygve Lie <trygve.lie@finn.no>
410
+
411
+ # [5.0.0-next.4](https://github.com/podium-lib/client/compare/v5.0.0-next.3...v5.0.0-next.4) (2020-07-16)
412
+
413
+
414
+ ### Features
415
+
416
+ * Remove deprecated 'change' and 'dispose' events ([#129](https://github.com/podium-lib/client/issues/129)) ([449fff1](https://github.com/podium-lib/client/commit/449fff13323d4f7f76fd406dbee1f2532701916b))
417
+
418
+
419
+ ### BREAKING CHANGES
420
+
421
+ * This removes the deprecated `change` and `dispose` events.
422
+
423
+ Resolves: https://github.com/podium-lib/issues/issues/24
424
+
425
+ * chore: lint love
426
+
427
+ Co-authored-by: Trygve Lie <trygve.lie@finn.no>
428
+
429
+ # [5.0.0-next.3](https://github.com/podium-lib/client/compare/v5.0.0-next.2...v5.0.0-next.3) (2020-07-16)
430
+
431
+
432
+ ### Features
433
+
434
+ * Remove .js() and .css() methods ([#128](https://github.com/podium-lib/client/issues/128)) ([db6d306](https://github.com/podium-lib/client/commit/db6d30617160db76d85e8839c7f896ef3dc97b41))
435
+
436
+
437
+ ### BREAKING CHANGES
438
+
439
+ * Remove .js() and .css() methods to retrieve fetched js and css for all podlets. Also removes the `resolveJs` and `resolveCss` arguments when registering a podlet.
440
+
441
+ Resolves: https://github.com/podium-lib/issues/issues/25
442
+
443
+ Co-authored-by: Trygve Lie <trygve.lie@finn.no>
444
+
445
+ # [5.0.0-next.2](https://github.com/podium-lib/client/compare/v5.0.0-next.1...v5.0.0-next.2) (2020-07-12)
446
+
447
+
448
+ ### Features
449
+
450
+ * Drop node 10.x support ([a71c3b0](https://github.com/podium-lib/client/commit/a71c3b08198f9a20de5e6af042d5a78f85c33c4f))
451
+
452
+
453
+ ### BREAKING CHANGES
454
+
455
+ * Only support node 12 and 14.
456
+
457
+ # [5.0.0-next.1](https://github.com/podium-lib/client/compare/v4.4.2...v5.0.0-next.1) (2020-07-12)
458
+
459
+
460
+ ### Features
461
+
462
+ * Make HttpIncoming required first argument to .fetch() and .stream() ([9b80ee7](https://github.com/podium-lib/client/commit/9b80ee715397e780d2df267483b6bc2db32b1c62))
463
+
464
+
465
+ ### BREAKING CHANGES
466
+
467
+ * `HttpIncoming` must now be passed as the first argument to .fetch() and .stream()
272
468
  * **deps:** update dependency @podium/utils to v4.4.17 ([a57669c](https://github.com/podium-lib/client/commit/a57669c5e26745a04b5e7b453db41049d7aea8c7))
273
469
 
274
470
  ## [4.4.18](https://github.com/podium-lib/client/compare/v4.4.17...v4.4.18) (2021-04-27)
package/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # @podium/client
1
+ # @podium/client v5
2
2
 
3
3
  Client for fetching podium component fragments over HTTP.
4
4
 
@@ -0,0 +1,3 @@
1
+ {
2
+ "type": "commonjs"
3
+ }
package/lib/client.js CHANGED
@@ -1,28 +1,15 @@
1
- /* eslint-disable import/order */
2
- /* eslint-disable no-underscore-dangle */
3
- /* eslint-disable prefer-spread */
4
-
5
- 'use strict';
6
-
7
- const EventEmitter = require('events');
8
- const { validate } = require('@podium/schemas');
9
- const Metrics = require('@metrics/client');
10
- const abslog = require('abslog');
11
- const Cache = require('ttl-mem-cache');
12
- const http = require('http');
13
- const https = require('https');
14
- const util = require('util');
15
-
16
- const Resource = require('./resource');
17
- const State = require('./state');
18
- const utils = require('./utils');
19
-
20
- const _resources = Symbol('podium:client:resources');
21
- const _registry = Symbol('podium:client:registry');
22
- const _metrics = Symbol('podium:client:metrics');
23
- const _histogram = Symbol('podium:client:metrics:histogram');
24
- const _options = Symbol('podium:client:options');
25
- const _state = Symbol('podium:client:state');
1
+ import EventEmitter from 'events';
2
+ import {uriStrict as validateUriStrict, name as validateName } from'@podium/schemas';
3
+ import Metrics from '@metrics/client';
4
+ import abslog from 'abslog';
5
+ import Cache from 'ttl-mem-cache';
6
+ import http from 'http';
7
+ import https from 'https';
8
+
9
+ import Resource from './resource.js';
10
+ import State from './state.js';
11
+
12
+ const inspect = Symbol.for('nodejs.util.inspect.custom');
26
13
 
27
14
  const HTTP_AGENT_OPTIONS = {
28
15
  keepAlive: true,
@@ -49,38 +36,24 @@ const TIMEOUT = 1000; // 1 seconds
49
36
 
50
37
  const MAX_AGE = Infinity;
51
38
 
52
- function cssDeprecated() {
53
- if (!cssDeprecated.warned) {
54
- cssDeprecated.warned = true;
55
- process.emitWarning(
56
- 'The client.css() method is deprecated. Use the .css property on the response object of each podlet instead. For further information, please see: https://podium-lib.io/blog/2019/06/14/version-4.0.0#the-fetch-method-now-resolves-with-a-response-object',
57
- 'DeprecationWarning',
58
- );
59
- }
60
- }
61
-
62
- function jsDeprecated() {
63
- if (!jsDeprecated.warned) {
64
- jsDeprecated.warned = true;
65
- process.emitWarning(
66
- 'The client.js() method is deprecated. Use the .js property on the response object of each podlet instead. For further information, please see: https://podium-lib.io/blog/2019/06/14/version-4.0.0#the-fetch-method-now-resolves-with-a-response-object',
67
- 'DeprecationWarning',
68
- );
69
- }
70
- }
71
-
72
- const PodiumClient = class PodiumClient extends EventEmitter {
39
+ export default class PodiumClient extends EventEmitter {
40
+ #resources;
41
+ #registry;
42
+ #metrics;
43
+ #histogram;
44
+ #options;
45
+ #state;
73
46
  constructor(options = {}) {
74
47
  super();
75
48
  const log = abslog(options.logger);
76
49
 
77
- if (validate.name(options.name).error) {
50
+ if (validateName(options.name).error) {
78
51
  throw new Error(
79
52
  `The value, "${options.name}", for the required argument "name" on the Client constructor is not defined or not valid.`,
80
53
  );
81
54
  }
82
55
 
83
- this[_options] = {
56
+ this.#options = {
84
57
  name: '',
85
58
  retries: RETRIES,
86
59
  timeout: TIMEOUT,
@@ -92,44 +65,33 @@ const PodiumClient = class PodiumClient extends EventEmitter {
92
65
  ...options,
93
66
  };
94
67
 
95
- this[_state] = new State({
68
+ this.#state = new State({
96
69
  resolveThreshold: options.resolveThreshold,
97
70
  resolveMax: options.resolveMax,
98
71
  });
99
- this[_state].on('state', state => {
72
+ this.#state.on('state', state => {
100
73
  this.emit('state', state);
101
74
  });
102
75
 
103
- this[_resources] = new Map();
76
+ this.#resources = new Map();
104
77
 
105
- this[_registry] = new Cache({
78
+ this.#registry = new Cache({
106
79
  changefeed: true,
107
80
  ttl: options.maxAge,
108
81
  });
109
- this[_registry].on('error', error => {
82
+ this.#registry.on('error', error => {
110
83
  log.error(
111
84
  'Error emitted by the registry in @podium/client module',
112
85
  error,
113
86
  );
114
87
  });
115
88
 
116
- // TODO; Deprecate the "change" event
117
- this[_registry].on('set', (key, item) => {
118
- /* istanbul ignore next */
119
- if (utils.hasManifestChange(item)) {
120
- this.emit('change', item.newVal);
121
- }
122
-
123
- this[_state].setUnstableState();
124
- });
125
-
126
- // TODO; Deprecate the "dispose" event
127
- this[_registry].on('dispose', key => {
128
- this.emit('dispose', key);
89
+ this.#registry.on('set', () => {
90
+ this.#state.setUnstableState();
129
91
  });
130
92
 
131
- this[_metrics] = new Metrics();
132
- this[_metrics].on('error', error => {
93
+ this.#metrics = new Metrics();
94
+ this.#metrics.on('error', error => {
133
95
  log.error(
134
96
  'Error emitted by metric stream in @podium/client module',
135
97
  error,
@@ -137,7 +99,7 @@ const PodiumClient = class PodiumClient extends EventEmitter {
137
99
  });
138
100
 
139
101
  this[Symbol.iterator] = () => ({
140
- items: Array.from(this[_resources]).map(item => item[1]),
102
+ items: Array.from(this.#resources).map(item => item[1]),
141
103
  next: function next() {
142
104
  return {
143
105
  done: this.items.length === 0,
@@ -146,139 +108,100 @@ const PodiumClient = class PodiumClient extends EventEmitter {
146
108
  },
147
109
  });
148
110
 
149
- this[_histogram] = this[_metrics].histogram({
111
+ this.#histogram = this.#metrics.histogram({
150
112
  name: 'podium_client_refresh_manifests',
151
113
  description: 'Time taken for podium client to refresh manifests',
152
- labels: { name: this[_options].name },
114
+ labels: { name: this.#options.name },
153
115
  buckets: [0.001, 0.01, 0.1, 0.5, 1, 2, 10],
154
116
  });
155
117
  }
156
118
 
157
119
  get registry() {
158
- return this[_registry];
120
+ return this.#registry;
159
121
  }
160
122
 
161
123
  get metrics() {
162
- return this[_metrics];
124
+ return this.#metrics;
163
125
  }
164
126
 
165
127
  get state() {
166
- return this[_state].status;
128
+ return this.#state.status;
167
129
  }
168
130
 
169
131
  register(options = {}) {
170
- if (validate.name(options.name).error)
132
+ if (validateName(options.name).error)
171
133
  throw new Error(
172
134
  `The value, "${options.name}", for the required argument "name" on the .register() method is not defined or not valid.`,
173
135
  );
174
136
 
175
- if (validate.uriStrict(options.uri).error)
137
+ if (validateUriStrict(options.uri).error)
176
138
  throw new Error(
177
139
  `The value, "${options.uri}", for the required argument "uri" on the .register() method is not defined or not valid.`,
178
140
  );
179
141
 
180
- if (this[_resources].has(options.name)) {
142
+ if (this.#resources.has(options.name)) {
181
143
  throw new Error(
182
144
  `Resource with the name "${options.name}" has already been registered.`,
183
145
  );
184
146
  }
185
147
 
186
148
  const resourceOptions = {
187
- rejectUnauthorized: this[_options].rejectUnauthorized,
188
- clientName: this[_options].name,
189
- retries: this[_options].retries,
190
- timeout: this[_options].timeout,
191
- logger: this[_options].logger,
192
- maxAge: this[_options].maxAge,
193
- httpsAgent: this[_options].httpsAgent,
194
- httpAgent: this[_options].httpAgent,
149
+ rejectUnauthorized: this.#options.rejectUnauthorized,
150
+ clientName: this.#options.name,
151
+ retries: this.#options.retries,
152
+ timeout: this.#options.timeout,
153
+ logger: this.#options.logger,
154
+ maxAge: this.#options.maxAge,
155
+ httpsAgent: this.#options.httpsAgent,
156
+ httpAgent: this.#options.httpAgent,
195
157
  ...options,
196
158
  };
197
159
  const resource = new Resource(
198
- this[_registry],
199
- this[_state],
160
+ this.#registry,
161
+ this.#state,
200
162
  resourceOptions,
201
163
  );
202
164
 
203
- resource.metrics.pipe(this[_metrics]);
165
+ resource.metrics.pipe(this.#metrics);
204
166
 
205
167
  Object.defineProperty(this, options.name, {
206
- get: () => this[_resources].get(options.name),
168
+ get: () => this.#resources.get(options.name),
207
169
  set: () => {
208
170
  throw new Error('Cannot set read-only property.');
209
171
  },
210
172
  });
211
173
 
212
- this[_resources].set(options.name, resource);
174
+ this.#resources.set(options.name, resource);
213
175
  return resource;
214
176
  }
215
177
 
216
- js() {
217
- jsDeprecated();
218
-
219
- return [].concat.apply(
220
- [],
221
- Array.from(this[_resources])
222
- .map(item => {
223
- const manifest = this[_registry].get(item[1].name);
224
- if (manifest && manifest.assets) {
225
- return manifest.assets.js;
226
- }
227
- return undefined;
228
- })
229
- .filter(item => item),
230
- );
231
- }
232
-
233
- css() {
234
- cssDeprecated();
235
-
236
- return [].concat.apply(
237
- [],
238
- Array.from(this[_resources])
239
- .map(item => {
240
- const manifest = this[_registry].get(item[1].name);
241
- if (manifest && manifest.assets) {
242
- return manifest.assets.css;
243
- }
244
- return undefined;
245
- })
246
- .filter(item => item),
247
- );
248
- }
249
-
250
178
  dump() {
251
- return this[_registry].dump();
179
+ return this.#registry.dump();
252
180
  }
253
181
 
254
182
  load(dump) {
255
- return this[_registry].load(dump);
183
+ return this.#registry.load(dump);
256
184
  }
257
185
 
258
186
  async refreshManifests() {
259
- const end = this[_histogram].timer();
187
+ const end = this.#histogram.timer();
260
188
 
261
189
  // Don't return this
262
190
  await Promise.all(
263
- Array.from(this[_resources]).map(resource => resource[1].refresh()),
191
+ Array.from(this.#resources).map(resource => resource[1].refresh()),
264
192
  );
265
193
 
266
194
  end();
267
195
  }
268
196
 
269
- get [Symbol.toStringTag]() {
270
- return 'PodiumClient';
197
+ [inspect]() {
198
+ return {
199
+ metrics: this.metrics,
200
+ state: this.state,
201
+ };
271
202
  }
272
203
 
273
- [util.inspect.custom](depth, options) {
274
- return util.inspect(
275
- {
276
- metrics: this.metrics,
277
- state: this.state,
278
- },
279
- depth,
280
- options,
281
- );
204
+ get [Symbol.toStringTag]() {
205
+ return 'PodiumClient';
282
206
  }
283
207
  };
284
- module.exports = PodiumClient;