clientlinker-flow-pkghandler 4.1.8 → 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 +10 -3
- package/dist/flow/index.d.ts +2 -0
- package/dist/flow/index.js +9 -0
- package/dist/flow/methods.d.ts +2 -0
- package/dist/flow/methods.js +9 -0
- package/dist/flow/pkghandler.d.ts +9 -0
- package/dist/flow/pkghandler.js +33 -0
- package/package.json +13 -9
- package/flow/index.js +0 -7
- package/flow/methods.js +0 -5
- package/flow/pkghandler.js +0 -29
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,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,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,10 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "clientlinker-flow-pkghandler",
|
|
3
|
-
"version": "
|
|
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
|
-
"
|
|
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"
|
|
8
12
|
},
|
|
9
13
|
"keywords": [
|
|
10
14
|
"clientlinker",
|
|
@@ -17,11 +21,11 @@
|
|
|
17
21
|
"debug": "^4.3.1"
|
|
18
22
|
},
|
|
19
23
|
"devDependencies": {
|
|
20
|
-
"
|
|
21
|
-
"
|
|
22
|
-
"
|
|
23
|
-
"
|
|
24
|
-
"
|
|
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"
|
|
25
29
|
},
|
|
26
30
|
"repository": {
|
|
27
31
|
"type": "git",
|
|
@@ -31,5 +35,5 @@
|
|
|
31
35
|
"url": "https://github.com/iGdea/node-clientlinker/issues"
|
|
32
36
|
},
|
|
33
37
|
"homepage": "https://github.com/iGdea/node-clientlinker/tree/master/packages/clientlinker-flow-pkghandler",
|
|
34
|
-
"gitHead": "
|
|
38
|
+
"gitHead": "f243a5c6c8d90cd764a7536c42d54c48a34403b2"
|
|
35
39
|
}
|
package/flow/index.js
DELETED
package/flow/methods.js
DELETED
package/flow/pkghandler.js
DELETED
|
@@ -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
|
-
}
|