clientlinker-flow-pkghandler 4.1.7 → 5.0.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/README.md CHANGED
@@ -24,17 +24,17 @@ npm i clientlinker-flow-pkghandler --save
24
24
  # Usage
25
25
 
26
26
  ```javascript
27
- var clientlinker = require('clientlinker');
27
+ var { clientlinker } = require('clientlinker');
28
28
  var linker = clientlinker({
29
29
  flows: ['pkghandler'],
30
30
  clients: {
31
31
  client: {
32
- pkghandler: 'clientlinker-flow-confighandler-test/lib/methods'
32
+ pkghandler: 'clientlinker-flow-confighandler-test/dist/lib/methods'
33
33
  }
34
34
  }
35
35
  });
36
36
 
37
- linker.flow('pkghandler', require('clientlinker-flow-pkghandler'));
37
+ linker.flow('pkghandler', require('clientlinker-flow-pkghandler').pkghandlerFlow);
38
38
 
39
39
  // use
40
40
  linker.run('client.method', null, {id: 13})
@@ -42,6 +42,13 @@ linker.run('client.method', null, {id: 13})
42
42
  ```
43
43
 
44
44
 
45
+ # Upgrade
46
+
47
+ ## 5.x
48
+
49
+ * The package entry no longer exports the installer function directly; it is now the named export `pkghandlerFlow`.
50
+ * Deep imports moved from `flow/*` to `dist/flow/*`; `dist/flow/pkghandler` exports `pkghandler` and `initClient` instead of a callable module.
51
+
45
52
  [npm-image]: https://img.shields.io/npm/v/clientlinker-flow-pkghandler.svg
46
53
  [downloads-image]: https://img.shields.io/npm/dm/clientlinker-flow-pkghandler.svg
47
54
  [npm-url]: https://www.npmjs.org/package/clientlinker-flow-pkghandler
@@ -0,0 +1,2 @@
1
+ import type { Flow } from 'clientlinker';
2
+ export declare function pkghandlerFlow(flow: Flow): void;
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.pkghandlerFlow = pkghandlerFlow;
4
+ const pkghandler_1 = require("./pkghandler");
5
+ const methods_1 = require("./methods");
6
+ function pkghandlerFlow(flow) {
7
+ flow.run = pkghandler_1.pkghandler;
8
+ flow.methods = methods_1.methods;
9
+ }
@@ -0,0 +1,2 @@
1
+ import type { Client } from 'clientlinker';
2
+ export declare function methods(client: Client): string[] | undefined;
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.methods = methods;
4
+ const pkghandler_1 = require("./pkghandler");
5
+ function methods(client) {
6
+ const mod = (0, pkghandler_1.initClient)(client);
7
+ if (mod)
8
+ return Object.keys(mod);
9
+ }
@@ -0,0 +1,9 @@
1
+ import type { Client, ClientRuntime, FlowRuntime } from 'clientlinker';
2
+ type PkgModule = Record<string, (query: unknown, body: unknown, options: unknown) => unknown>;
3
+ type PkgClient = Client & {
4
+ pkghandlerModule?: PkgModule;
5
+ pkghandlerModuleLoaded?: boolean;
6
+ };
7
+ export declare function pkghandler(runtime: ClientRuntime, callback: FlowRuntime): unknown;
8
+ export declare function initClient(client: PkgClient): PkgModule | undefined;
9
+ export {};
@@ -0,0 +1,33 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.pkghandler = pkghandler;
7
+ exports.initClient = initClient;
8
+ const debug_1 = __importDefault(require("debug"));
9
+ const debug = (0, debug_1.default)('clientlinker-flow-pkghandler');
10
+ function pkghandler(runtime, callback) {
11
+ const client = runtime.client;
12
+ const mod = initClient(client);
13
+ if (!mod)
14
+ return callback.next();
15
+ const handler = mod[runtime.method];
16
+ if (handler) {
17
+ return handler(runtime.query, runtime.body, runtime.options);
18
+ }
19
+ else {
20
+ debug('pkg no handler:%s', runtime.method);
21
+ return callback.next();
22
+ }
23
+ }
24
+ function initClient(client) {
25
+ const options = client.options;
26
+ if (!options.pkghandler)
27
+ return;
28
+ if (!client.pkghandlerModuleLoaded) {
29
+ client.pkghandlerModule = require(options.pkghandler);
30
+ client.pkghandlerModuleLoaded = true;
31
+ }
32
+ return client.pkghandlerModule;
33
+ }
package/package.json CHANGED
@@ -1,12 +1,14 @@
1
1
  {
2
2
  "name": "clientlinker-flow-pkghandler",
3
- "version": "4.1.7",
3
+ "version": "5.0.0",
4
4
  "description": "Pkghandler flow for clientlinker",
5
- "main": "flow/index.js",
5
+ "main": "dist/flow/index.js",
6
+ "types": "dist/flow/index.d.ts",
6
7
  "scripts": {
7
- "test": "cross-env DEBUG=clientlinker-flow-pkghandler* mocha test/test_*",
8
- "test-cov": "istanbul cover _mocha -- test/test_* --reporter dot",
9
- "test-ci": "istanbul cover _mocha --report lcovonly -- test/test_* --reporter dot"
8
+ "build": "tsc -p tsconfig.json",
9
+ "prepare": "npm run build",
10
+ "pretest": "npm run build",
11
+ "test": "cross-env DEBUG=clientlinker-flow-pkghandler* jest"
10
12
  },
11
13
  "keywords": [
12
14
  "clientlinker",
@@ -19,20 +21,19 @@
19
21
  "debug": "^4.3.1"
20
22
  },
21
23
  "devDependencies": {
22
- "clientlinker": "^13.1.3",
23
- "clientlinker-flow-confighandler-test": "^3.1.2",
24
- "cross-env": "^7.0.3",
25
- "expect.js": "^0.3.1",
26
- "istanbul": "^0.4.5",
27
- "mocha": "^8.4.0"
24
+ "@types/debug": "^4.1.13",
25
+ "@types/node": "^20.19.43",
26
+ "clientlinker": "^14.0.0",
27
+ "clientlinker-flow-confighandler-test": "^4.0.0",
28
+ "cross-env": "^7.0.3"
28
29
  },
29
30
  "repository": {
30
31
  "type": "git",
31
- "url": "git@github.com:Bacra/node-clientlinker.git"
32
+ "url": "git@github.com:iGdea/node-clientlinker.git"
32
33
  },
33
34
  "bugs": {
34
- "url": "https://github.com/igdea/node-clientlinker/issues"
35
+ "url": "https://github.com/iGdea/node-clientlinker/issues"
35
36
  },
36
- "homepage": "https://github.com/igdea/node-clientlinker/tree/master/packages/clientlinker-flow-pkghandler",
37
- "gitHead": "262dd9e196105768d064d68aa8960d0764edf8b8"
37
+ "homepage": "https://github.com/iGdea/node-clientlinker/tree/master/packages/clientlinker-flow-pkghandler",
38
+ "gitHead": "f243a5c6c8d90cd764a7536c42d54c48a34403b2"
38
39
  }
package/flow/index.js DELETED
@@ -1,7 +0,0 @@
1
- const pkghandler = require('./pkghandler');
2
- const methods = require('./methods');
3
-
4
- module.exports = function(flow) {
5
- flow.run = pkghandler;
6
- flow.methods = methods;
7
- };
package/flow/methods.js DELETED
@@ -1,5 +0,0 @@
1
- const pkghandler = require('./pkghandler');
2
- module.exports = function methods(client) {
3
- const mod = pkghandler.initClient(client);
4
- if (mod) return Object.keys(mod);
5
- };
@@ -1,29 +0,0 @@
1
- const debug = require('debug')('clientlinker-flow-pkghandler');
2
-
3
- exports = module.exports = function pkghandler(runtime, callback) {
4
- const client = runtime.client;
5
- const mod = initClient(client);
6
-
7
- if (!mod) return callback.next();
8
- const handler = mod[runtime.method];
9
-
10
- if (handler) {
11
- return handler(runtime.query, runtime.body, runtime.options);
12
- } else {
13
- debug('pkg no handler:%s', runtime.method);
14
- return callback.next();
15
- }
16
- };
17
-
18
- exports.initClient = initClient;
19
- function initClient(client) {
20
- const options = client.options;
21
- if (!options.pkghandler) return;
22
-
23
- if (!client.pkghandlerModuleLoaded) {
24
- client.pkghandlerModule = require(options.pkghandler);
25
- client.pkghandlerModuleLoaded = true;
26
- }
27
-
28
- return client.pkghandlerModule;
29
- }