@nymphjs/client-node 1.0.0-alpha.2 → 1.0.0-alpha.20

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
@@ -3,6 +3,84 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ # [1.0.0-alpha.20](https://github.com/sciactive/nymphjs/compare/v1.0.0-alpha.19...v1.0.0-alpha.20) (2021-11-24)
7
+
8
+ **Note:** Version bump only for package @nymphjs/client-node
9
+
10
+ # [1.0.0-alpha.19](https://github.com/sciactive/nymphjs/compare/v1.0.0-alpha.18...v1.0.0-alpha.19) (2021-11-18)
11
+
12
+ ### Features
13
+
14
+ - update smui and other packages to latest versions ([2465340](https://github.com/sciactive/nymphjs/commit/24653400d887bc04c41c3c4ee0c73ce2f2289e0d))
15
+
16
+ # [1.0.0-alpha.18](https://github.com/sciactive/nymphjs/compare/v1.0.0-alpha.17...v1.0.0-alpha.18) (2021-11-09)
17
+
18
+ **Note:** Version bump only for package @nymphjs/client-node
19
+
20
+ # [1.0.0-alpha.17](https://github.com/sciactive/nymphjs/compare/v1.0.0-alpha.16...v1.0.0-alpha.17) (2021-10-14)
21
+
22
+ **Note:** Version bump only for package @nymphjs/client-node
23
+
24
+ # [1.0.0-alpha.16](https://github.com/sciactive/nymphjs/compare/v1.0.0-alpha.15...v1.0.0-alpha.16) (2021-10-14)
25
+
26
+ ### Bug Fixes
27
+
28
+ - don't ignore built files in npm packages ([7d688db](https://github.com/sciactive/nymphjs/commit/7d688dbec362f1f71fb451a1d0dbcaecc15d99fc))
29
+
30
+ # [1.0.0-alpha.15](https://github.com/sciactive/nymphjs/compare/v1.0.0-alpha.14...v1.0.0-alpha.15) (2021-10-14)
31
+
32
+ **Note:** Version bump only for package @nymphjs/client-node
33
+
34
+ # [1.0.0-alpha.14](https://github.com/sciactive/nymphjs/compare/v1.0.0-alpha.13...v1.0.0-alpha.14) (2021-10-14)
35
+
36
+ **Note:** Version bump only for package @nymphjs/client-node
37
+
38
+ # [1.0.0-alpha.13](https://github.com/sciactive/nymphjs/compare/v1.0.0-alpha.12...v1.0.0-alpha.13) (2021-10-14)
39
+
40
+ **Note:** Version bump only for package @nymphjs/client-node
41
+
42
+ # [1.0.0-alpha.12](https://github.com/sciactive/nymphjs/compare/v1.0.0-alpha.11...v1.0.0-alpha.12) (2021-10-13)
43
+
44
+ **Note:** Version bump only for package @nymphjs/client-node
45
+
46
+ # [1.0.0-alpha.11](https://github.com/sciactive/nymphjs/compare/v1.0.0-alpha.10...v1.0.0-alpha.11) (2021-10-13)
47
+
48
+ **Note:** Version bump only for package @nymphjs/client-node
49
+
50
+ # [1.0.0-alpha.10](https://github.com/sciactive/nymphjs/compare/v1.0.0-alpha.9...v1.0.0-alpha.10) (2021-10-12)
51
+
52
+ **Note:** Version bump only for package @nymphjs/client-node
53
+
54
+ # [1.0.0-alpha.9](https://github.com/sciactive/nymphjs/compare/v1.0.0-alpha.8...v1.0.0-alpha.9) (2021-10-12)
55
+
56
+ **Note:** Version bump only for package @nymphjs/client-node
57
+
58
+ # [1.0.0-alpha.8](https://github.com/sciactive/nymphjs/compare/v1.0.0-alpha.7...v1.0.0-alpha.8) (2021-10-12)
59
+
60
+ **Note:** Version bump only for package @nymphjs/client-node
61
+
62
+ # [1.0.0-alpha.7](https://github.com/sciactive/nymphjs/compare/v1.0.0-alpha.6...v1.0.0-alpha.7) (2021-10-05)
63
+
64
+ **Note:** Version bump only for package @nymphjs/client-node
65
+
66
+ # [1.0.0-alpha.6](https://github.com/sciactive/nymphjs/compare/v1.0.0-alpha.5...v1.0.0-alpha.6) (2021-10-05)
67
+
68
+ **Note:** Version bump only for package @nymphjs/client-node
69
+
70
+ # [1.0.0-alpha.5](https://github.com/sciactive/nymphjs/compare/v1.0.0-alpha.4...v1.0.0-alpha.5) (2021-09-30)
71
+
72
+ **Note:** Version bump only for package @nymphjs/client-node
73
+
74
+ # [1.0.0-alpha.4](https://github.com/sciactive/nymphjs/compare/v1.0.0-alpha.3...v1.0.0-alpha.4) (2021-09-27)
75
+
76
+ **Note:** Version bump only for package @nymphjs/client-node
77
+
78
+ # [1.0.0-alpha.3](https://github.com/sciactive/nymphjs/compare/v1.0.0-alpha.2...v1.0.0-alpha.3) (2021-09-22)
79
+
80
+ ### Features
81
+
82
+ - allow multiple instances of Nymph Client ([81eacd7](https://github.com/sciactive/nymphjs/commit/81eacd7caff6f3c209d7d6dbfdac0414a1857c6d))
83
+
6
84
  # [1.0.0-alpha.2](https://github.com/sciactive/nymphjs/compare/v1.0.0-alpha.1...v1.0.0-alpha.2) (2021-09-21)
7
85
 
8
86
  **Note:** Version bump only for package @nymphjs/client-node
package/README.md CHANGED
@@ -12,23 +12,25 @@ npm install --save @nymphjs/client-node
12
12
 
13
13
  This package is the Nymph client for Node.js. You can find CJS in `dist`, or TS source in `src`. There is also a **[browser client](https://github.com/sciactive/nymphjs/packages/client)**.
14
14
 
15
- This package provides fetch and WebSocket ponyfills to Nymph, handles Tilmeld auth tokens, and sets up `Nymph.init` to also call `PubSub.init` with your configs if you provide a `pubsubUrl`.
15
+ This package provides fetch and WebSocket ponyfills to Nymph and handles Tilmeld auth tokens.
16
16
 
17
17
  ## Usage
18
18
 
19
19
  To use, require it instead of `@nymphjs/client`:
20
20
 
21
- ```js
22
- const { Nymph } = require('@nymphjs/client-node');
21
+ ```ts
22
+ const { Nymph, PubSub } = require('@nymphjs/client-node');
23
23
  ```
24
24
 
25
- Then provide the options to Nymph.init:
25
+ Then set up Nymph and PubSub like normal:
26
26
 
27
- ```js
28
- Nymph.init({
27
+ ```ts
28
+ const nymphOptions = {
29
29
  restUrl: 'https://yournymphrestserver/path/to/your/endpoint',
30
30
  pubsubUrl: 'wss://yournymphpubsubserver',
31
- });
31
+ };
32
+ const nymph = new Nymph(nymphOptions);
33
+ const pubsub = new PubSub(nymphOptions, nymph);
32
34
  ```
33
35
 
34
36
  # License
package/dist/index.d.ts CHANGED
@@ -1,4 +1,8 @@
1
- import * as NymphClient from '@nymphjs/client';
2
- declare const Nymph: typeof NymphClient.Nymph;
3
- export { Nymph };
4
- export default Nymph;
1
+ import { Nymph, PubSub, NymphOptions } from '@nymphjs/client';
2
+ declare class NodeNymph extends Nymph {
3
+ constructor(nymphOptions: NymphOptions);
4
+ }
5
+ declare class NodePubSub extends PubSub {
6
+ constructor(nymphOptions: NymphOptions, nymph: Nymph);
7
+ }
8
+ export { NodeNymph as Nymph, NodePubSub as PubSub };
package/dist/index.js CHANGED
@@ -1,53 +1,37 @@
1
1
  "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
5
- }) : (function(o, m, k, k2) {
6
- if (k2 === undefined) k2 = k;
7
- o[k2] = m[k];
8
- }));
9
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
10
- Object.defineProperty(o, "default", { enumerable: true, value: v });
11
- }) : function(o, v) {
12
- o["default"] = v;
13
- });
14
- var __importStar = (this && this.__importStar) || function (mod) {
15
- if (mod && mod.__esModule) return mod;
16
- var result = {};
17
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
18
- __setModuleDefault(result, mod);
19
- return result;
20
- };
21
2
  var __importDefault = (this && this.__importDefault) || function (mod) {
22
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
23
4
  };
24
5
  Object.defineProperty(exports, "__esModule", { value: true });
25
- exports.Nymph = void 0;
6
+ exports.PubSub = exports.Nymph = void 0;
26
7
  const websocket_1 = require("websocket");
27
8
  const node_fetch_1 = __importDefault(require("node-fetch"));
28
- const NymphClient = __importStar(require("@nymphjs/client"));
29
- const { Nymph, PubSub } = NymphClient;
30
- exports.Nymph = Nymph;
31
- const _init = Nymph.init;
32
- Nymph.init = (nymphOptions) => {
33
- _init.call(Nymph, Object.assign({ fetch: node_fetch_1.default }, nymphOptions));
34
- if (nymphOptions.pubsubUrl) {
35
- PubSub.init(Object.assign({ WebSocket: websocket_1.w3cwebsocket }, nymphOptions));
36
- }
37
- };
38
- let authToken = null;
39
- Nymph.on('request', (_url, options) => {
40
- if (authToken) {
41
- options.headers['X-TILMELDAUTH'] = authToken;
9
+ const client_1 = require("@nymphjs/client");
10
+ class NodeNymph extends client_1.Nymph {
11
+ constructor(nymphOptions) {
12
+ super(Object.assign({ fetch: node_fetch_1.default }, nymphOptions));
13
+ let authToken = null;
14
+ this.on('request', (_url, options) => {
15
+ if (authToken) {
16
+ options.headers['X-TILMELDAUTH'] =
17
+ authToken;
18
+ }
19
+ });
20
+ this.on('response', (response) => {
21
+ if (response.headers.has('X-TILMELDAUTH')) {
22
+ authToken = response.headers.get('X-TILMELDAUTH');
23
+ if (authToken === '') {
24
+ authToken = null;
25
+ }
26
+ }
27
+ });
42
28
  }
43
- });
44
- Nymph.on('response', (response) => {
45
- if (response.headers.has('X-TILMELDAUTH')) {
46
- authToken = response.headers.get('X-TILMELDAUTH');
47
- if (authToken === '') {
48
- authToken = null;
49
- }
29
+ }
30
+ exports.Nymph = NodeNymph;
31
+ class NodePubSub extends client_1.PubSub {
32
+ constructor(nymphOptions, nymph) {
33
+ super(Object.assign({ WebSocket: websocket_1.w3cwebsocket }, nymphOptions), nymph);
50
34
  }
51
- });
52
- exports.default = Nymph;
35
+ }
36
+ exports.PubSub = NodePubSub;
53
37
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AACA,yCAAyC;AACzC,4DAA+B;AAC/B,6DAA+C;AAG/C,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,WAAW,CAAC;AAiC7B,sBAAK;AA9Bd,MAAM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I,SAAS,EAAE;gBACZ,OAAO,CAAC,OAAkC,CAAC,eAAe,CAAC;oBAC1D,SAAS,CAAC;aACb;QACH,CAAC,CAAC,CAAC;QACH,IAAI,CAAC,EAAE,CAAC,UAAU,EAAE,CAAC,QAAkB,EAAE,EAAE;YACzC,IAAI,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,eAAe,CAAC,EAAE;gBACzC,SAAS,GAAG,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,eAAe,CAAC,CAAC;gBAClD,IAAI,SAAS,KAAK,EAAE,EAAE;oBACpB,SAAS,GAAG,IAAI,CAAC;iBAClB;aACF;QACH,CAAC,CAAC,CAAC;IACL,CAAC;CACF;AAcqB,0BAAK;AAZ3B,MAAM,UAAW,SAAQ,eAAM;IAC7B,YAAY,YAA0B,EAAE,KAAY;QAClD,KAAK,iBAED,SAAS,EAAE,wBAAuC,IAC/C,YAAY,GAEjB,KAAK,CACN,CAAC;IACJ,CAAC;CACF;AAE0C,4BAAM"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nymphjs/client-node",
3
- "version": "1.0.0-alpha.2",
3
+ "version": "1.0.0-alpha.20",
4
4
  "description": "NymphJS - Node Client",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -30,18 +30,18 @@
30
30
  },
31
31
  "license": "Apache-2.0",
32
32
  "dependencies": {
33
- "@nymphjs/client": "^1.0.0-alpha.2",
33
+ "@nymphjs/client": "^1.0.0-alpha.20",
34
34
  "node-fetch": "^2.6.1",
35
35
  "websocket": "^1.0.34"
36
36
  },
37
37
  "devDependencies": {
38
38
  "@tsconfig/recommended": "^1.0.1",
39
- "@types/jest": "^27.0.1",
39
+ "@types/jest": "^27.0.2",
40
40
  "@types/node-fetch": "^2.5.12",
41
41
  "@types/websocket": "^1.0.4",
42
- "jest": "^27.0.6",
43
- "ts-jest": "^27.0.5",
44
- "typescript": "^4.3.5"
42
+ "jest": "^27.3.1",
43
+ "ts-jest": "^27.0.7",
44
+ "typescript": "^4.5.2"
45
45
  },
46
- "gitHead": "9596354bffaa484f3002f3063f0963f6261040be"
46
+ "gitHead": "4191b5824ea6ef71557f2357a30069d5d4e98a89"
47
47
  }
package/src/index.ts CHANGED
@@ -1,41 +1,45 @@
1
1
  // Nymph expects fetch and WebSocket.
2
2
  import { w3cwebsocket } from 'websocket';
3
3
  import fetch from 'node-fetch';
4
- import * as NymphClient from '@nymphjs/client';
5
- import { NymphOptions } from '@nymphjs/client';
6
-
7
- const { Nymph, PubSub } = NymphClient;
4
+ import { Nymph, PubSub, NymphOptions } from '@nymphjs/client';
8
5
 
9
6
  // Make a shortcut for PubSub init.
10
- const _init = Nymph.init;
11
- Nymph.init = (nymphOptions: NymphOptions) => {
12
- _init.call(Nymph, {
13
- fetch: fetch as any as WindowOrWorkerGlobalScope['fetch'],
14
- ...nymphOptions,
15
- });
16
- if (nymphOptions.pubsubUrl) {
17
- PubSub.init({
18
- WebSocket: w3cwebsocket as any as typeof WebSocket,
7
+ class NodeNymph extends Nymph {
8
+ constructor(nymphOptions: NymphOptions) {
9
+ super({
10
+ fetch: fetch as any as WindowOrWorkerGlobalScope['fetch'],
19
11
  ...nymphOptions,
20
12
  });
21
- }
22
- };
23
13
 
24
- // Save the Tilmeld auth token and send it in the header.
25
- let authToken: string | null = null;
26
- Nymph.on('request', (_url: string, options: RequestInit) => {
27
- if (authToken) {
28
- (options.headers as Record<string, string>)['X-TILMELDAUTH'] = authToken;
14
+ // Save the Tilmeld auth token and send it in the header.
15
+ let authToken: string | null = null;
16
+ this.on('request', (_url: string, options: RequestInit) => {
17
+ if (authToken) {
18
+ (options.headers as Record<string, string>)['X-TILMELDAUTH'] =
19
+ authToken;
20
+ }
21
+ });
22
+ this.on('response', (response: Response) => {
23
+ if (response.headers.has('X-TILMELDAUTH')) {
24
+ authToken = response.headers.get('X-TILMELDAUTH');
25
+ if (authToken === '') {
26
+ authToken = null;
27
+ }
28
+ }
29
+ });
29
30
  }
30
- });
31
- Nymph.on('response', (response: Response) => {
32
- if (response.headers.has('X-TILMELDAUTH')) {
33
- authToken = response.headers.get('X-TILMELDAUTH');
34
- if (authToken === '') {
35
- authToken = null;
36
- }
31
+ }
32
+
33
+ class NodePubSub extends PubSub {
34
+ constructor(nymphOptions: NymphOptions, nymph: Nymph) {
35
+ super(
36
+ {
37
+ WebSocket: w3cwebsocket as any as typeof WebSocket,
38
+ ...nymphOptions,
39
+ },
40
+ nymph
41
+ );
37
42
  }
38
- });
43
+ }
39
44
 
40
- export { Nymph };
41
- export default Nymph;
45
+ export { NodeNymph as Nymph, NodePubSub as PubSub };