@hailer/cli 1.1.7

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 ADDED
@@ -0,0 +1,136 @@
1
+ # Hailer CLI
2
+
3
+ A Command Line interface to Hailer. It can also be used to programmatically access Hailer.
4
+
5
+ ## Usage as Cli
6
+
7
+ All backend Socket API commands are available in the CLI.
8
+
9
+ Tab completion is available.
10
+
11
+ The result of each command is stored in the `result` variable.
12
+
13
+ Usage:
14
+
15
+ ```sh
16
+ npx @hailer/cli
17
+ ```
18
+
19
+ ### Install
20
+
21
+ ```sh
22
+ npm install -g @hailer/cli
23
+ ```
24
+
25
+ ### Run on Linux or OSX
26
+
27
+ ```sh
28
+ USER=my@email.com HOST=api.hailer.biz hailer-cli
29
+ ```
30
+
31
+ ### Run on Windows
32
+
33
+ ```sh
34
+ set USER=my@email.com
35
+ set HOST=api.hailer.biz
36
+ hailer-cli
37
+ ```
38
+
39
+ ### Example usage
40
+
41
+ Example usage:
42
+
43
+ ```javascript
44
+ await api.wall2.new_post({ subject: 'This is a wall post.', text: 'Look, this is a cool wallpost made from the Cli.' })
45
+ ```
46
+
47
+ ```javascript
48
+ await api.wall2.remove_post(result._id)
49
+ ```
50
+
51
+ ## Programmatic Usage
52
+
53
+ ### Login with username and password
54
+
55
+ This example creates a wall post in Hailer, and then removes it after five seconds, and exits.
56
+
57
+ Create a new nodejs project (`npm init`) or use an existing. Add `hailer-cli` as a dependency, using `npm install @hailer/cli`
58
+
59
+ ```sh
60
+ mkdir my-hailer-app
61
+ cd my-hailer-app
62
+ npm init
63
+ npm install @hailer/cli
64
+ ```
65
+
66
+ Create a new file `run.js` and paste the following code:
67
+
68
+ ```javascript
69
+ const { Client } = require('@hailer/cli');
70
+
71
+ const options = {
72
+ host: 'https://api.hailer.biz',
73
+ username: 'set-this',
74
+ password: 'set-this',
75
+ };
76
+
77
+ Client.create(options).then(async (client) => {
78
+ const post = await client.request('wall2.new_post', [{ subject: 'This is a wall post.', text: 'The content of my post' }]);
79
+
80
+ console.log('Post created:', post);
81
+ client.disconnect();
82
+ });
83
+ ```
84
+
85
+ Set the `username` and `password` parameters to a valid Hailer account.
86
+
87
+ Log in to Hailer using the browser and go to the `Feed` to see the script in action.
88
+
89
+ Start the program:
90
+
91
+ ```sh
92
+ node run.js
93
+ ```
94
+
95
+ Have fun!
96
+
97
+ ### Inside async function
98
+
99
+ ```javascript
100
+ const { Client } = require('@hailer/cli');
101
+
102
+ const options = {
103
+ host: 'https://api.hailer.biz',
104
+ username: 'set-this',
105
+ password: 'set-this',
106
+ };
107
+
108
+ const client = await Client.create(options);
109
+
110
+ const post = await client.request('wall2.new_post', [{ subject: 'This is a wall post.', text: 'The content of my post' }]);
111
+
112
+ console.log('Post created:', post);
113
+ ```
114
+
115
+ ### Login using existing Hailer session key
116
+
117
+ Re-using a Hailer `sessionKey` instead of logging in using username and password.
118
+
119
+ ```javascript
120
+ const { Client } = require('@hailer/cli');
121
+
122
+ const options = {
123
+ host: 'https://api.hailer.biz',
124
+ };
125
+
126
+ Client.create(options).then(async (client) => {
127
+ await client.resume(sessionKey);
128
+ const post = await client.request('wall2.new_post', [{ subject: 'This is a wall post.', text: 'The content of my post' }]);
129
+
130
+ console.log('Post created:', post);
131
+ client.disconnect();
132
+ });
133
+
134
+ ```
135
+
136
+ Set the `sessionKey` parameter which you have acquired by some other means.
package/assets/help.md ADDED
@@ -0,0 +1,54 @@
1
+ Hailer CLI can be used to control [Hailer](https://app.hailer.com) programmatically. There are currently 2 ways of use.
2
+
3
+ The first way is to use this as a pure CLI, simply by typing
4
+
5
+ ```sh
6
+ hailer-cli --user user@example.com --password [the-password]
7
+ ```
8
+
9
+ This will drop you into an interactive console where you can type hailer api commands directly.
10
+
11
+ The other way is to use Hailer CLI is by using programmatically, this way you can implement hailer into your own node packages and create deep integrations with Hailer.
12
+
13
+ To learn more about how to use Hailer CLI programmatically type `hailer-cli --help programmatic`.
14
+
15
+ ## Notable features:
16
+
17
+ - All backend Socket API commands are available in the CLI
18
+ - Tab completion is available.
19
+ - The result of each command is stored in the `result` variable.
20
+
21
+ ## Available Arguments:
22
+
23
+ *--help, -h*: displays this message
24
+
25
+ *--version, -v*: Displays versions of Hailer CLI
26
+
27
+ *--user*: Your email address used to login into hailer
28
+
29
+ *--password*: Your password used to login into hailer, or leave empty for prompt
30
+
31
+ *--host*: Which hailer backend server to use, defaults to *api.hailer.com*
32
+
33
+ ## Environment variables:
34
+
35
+ *HOST*: which Hailer backend to use, defaults to *api.hailer.com*
36
+
37
+ ### Example usage
38
+
39
+ ```javascript
40
+ await api.wall2.new_post({ subject: 'This is a wall post.', text: 'Look, this is a cool wallpost made from the Cli.' })
41
+ ```
42
+
43
+ ```javascript
44
+ await api.wall2.remove_post(result._id)
45
+ ```
46
+
47
+ Upload a file and create wall post with the file:
48
+
49
+ ```javascript
50
+ // fileId = await upload('/Users/akaustel/Downloads/pexels-nsu-mon-4337089.jpeg');
51
+ fileId = await upload('myfile.jpg');
52
+ await api.wall2.new_post({ subject: 'This is a wall post.', text: 'Look, this is a cool wallpost made from the Cli.', files: [fileId] })
53
+ ```
54
+
@@ -0,0 +1,27 @@
1
+ # Hailer CLI
2
+
3
+ A Command Line interface to Hailer.
4
+
5
+ * All backend Socket API commands are available in the CLI.
6
+ * Tab completion is available.
7
+
8
+ The result of each command is stored in the `result` variable.
9
+
10
+ ### Example usage
11
+
12
+ ```javascript
13
+ await api.wall2.new_post({ subject: 'This is a wall post.', text: 'Look, this is a cool wallpost made from the Cli.' })
14
+ ```
15
+
16
+ ```javascript
17
+ await api.wall2.remove_post(result._id)
18
+ ```
19
+
20
+ Upload a file and create wall post with the file:
21
+
22
+ ```javascript
23
+ // fileId = await upload('/Users/akaustel/Downloads/pexels-nsu-mon-4337089.jpeg');
24
+ fileId = await upload('myfile.jpg');
25
+ await api.wall2.new_post({ subject: 'This is a wall post.', text: 'Look, this is a cool wallpost made from the Cli.', files: [fileId] })
26
+ ```
27
+
package/bin/hailer-cli ADDED
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ require('../dist/run.js');
package/dist/run.d.ts ADDED
@@ -0,0 +1 @@
1
+ export {};
package/dist/run.js ADDED
@@ -0,0 +1,213 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __importDefault = (this && this.__importDefault) || function (mod) {
12
+ return (mod && mod.__esModule) ? mod : { "default": mod };
13
+ };
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ const client_1 = require("./src/client");
16
+ const minimist_1 = __importDefault(require("minimist"));
17
+ const marked_terminal_1 = __importDefault(require("marked-terminal"));
18
+ const marked_1 = require("marked");
19
+ const fs_1 = require("fs");
20
+ const path_1 = require("path");
21
+ const colors_1 = __importDefault(require("colors"));
22
+ const repl_1 = require("repl");
23
+ const display_help_1 = require("./src/commands/display-help");
24
+ const minimal_password_prompt_1 = __importDefault(require("minimal-password-prompt"));
25
+ const util_1 = require("./src/util");
26
+ ;
27
+ marked_1.marked.setOptions({
28
+ // Define custom renderer
29
+ renderer: new marked_terminal_1.default({
30
+ width: 100,
31
+ reflowText: true,
32
+ }),
33
+ });
34
+ (() => __awaiter(void 0, void 0, void 0, function* () {
35
+ let username;
36
+ let password;
37
+ let host = 'https://api.hailer.com';
38
+ const parsedArgs = (0, minimist_1.default)(process.argv.slice(2));
39
+ // Displaying help if it's called at any time
40
+ if (parsedArgs.help || parsedArgs.h) {
41
+ (0, display_help_1.displayHelpAndExit)();
42
+ }
43
+ // Command-line arguments overwrite environment variables
44
+ if (typeof parsedArgs.user === 'string') {
45
+ username = parsedArgs.user;
46
+ }
47
+ // Command-line arguments overwrite environment variables
48
+ if (typeof parsedArgs.password === 'string') {
49
+ password = parsedArgs.password;
50
+ }
51
+ if (typeof parsedArgs.host === 'string' || process.env.HOST) {
52
+ host = parsedArgs.host || process.env.HOST;
53
+ }
54
+ const quiet = !!parsedArgs.quiet;
55
+ if (username && !password) {
56
+ if (!quiet) {
57
+ console.log(colors_1.default.green(username), 'logging in to', colors_1.default.yellow(host));
58
+ }
59
+ password = yield (0, minimal_password_prompt_1.default)('enter password: ');
60
+ }
61
+ const client = yield client_1.Client.create({ username, password, host }).catch(error => { console.log('Failed logging in:', error); process.exit(7); });
62
+ let repl;
63
+ let methods = {};
64
+ const _methods = yield client.request('methods', []);
65
+ const root = {
66
+ api: {},
67
+ /** Result from last command */
68
+ result: undefined,
69
+ /** All results as array, newest at [0] */
70
+ history: [],
71
+ /** Last error */
72
+ error: undefined,
73
+ };
74
+ for (const i in _methods) {
75
+ const path = i.split('.');
76
+ let node = root.api;
77
+ while (path.length > 1) {
78
+ if (!node[path[0]]) {
79
+ node[path[0]] = {};
80
+ }
81
+ node = node[path[0]];
82
+ path.shift();
83
+ }
84
+ node[path[0]] = ((j) => {
85
+ return (...args) => __awaiter(void 0, void 0, void 0, function* () {
86
+ try {
87
+ root.result = yield client.request(j, args);
88
+ root.history.unshift(root.result);
89
+ // manually patch the repl context for result to work properly
90
+ repl.context.result = root.result;
91
+ }
92
+ catch (error) {
93
+ root.error = error;
94
+ throw error;
95
+ }
96
+ return root.result;
97
+ });
98
+ })(i);
99
+ // Init help hints
100
+ Object.defineProperty(node[path[0]], "cmd", { value: i });
101
+ Object.defineProperty(node[path[0]], "doc", { value: _methods[i].doc });
102
+ Object.defineProperty(node[path[0]], "args", { value: _methods[i].args });
103
+ }
104
+ ;
105
+ methods = root;
106
+ /** Write to console without messing up the user input */
107
+ const log = (...args) => {
108
+ // clear line
109
+ process.stdout.write('\x1B[2K\r');
110
+ const timeHHMM = colors_1.default.blue('[' + (0, util_1.toISOStringWithTimezone)(new Date()).slice(11, 16) + ']');
111
+ console.log(timeHHMM, ...args
112
+ .map(arg => typeof arg !== 'string' && arg !== undefined ? (0, util_1.inspect)(arg) : arg)
113
+ .filter(arg => arg !== undefined));
114
+ repl === null || repl === void 0 ? void 0 : repl.displayPrompt(true);
115
+ };
116
+ function startRepl() {
117
+ return __awaiter(this, void 0, void 0, function* () {
118
+ const repl = (0, repl_1.start)({
119
+ prompt: 'hailer> ',
120
+ input: process.stdin,
121
+ output: process.stdout,
122
+ terminal: true,
123
+ ignoreUndefined: true,
124
+ writer: (obj) => {
125
+ if (obj === null || obj === void 0 ? void 0 : obj.args) {
126
+ console.log(colors_1.default.yellow(obj.cmd) + '(' + colors_1.default.blue(obj.args || '') + ')', colors_1.default.white(obj.doc || ''));
127
+ return '';
128
+ }
129
+ return (0, util_1.inspect)(obj, { depth: 20, colors: true });
130
+ }
131
+ });
132
+ repl.on('exit', function () {
133
+ console.log("Bye!");
134
+ process.exit(0);
135
+ });
136
+ if (client.sessionKey) {
137
+ const data = yield client.request('v2.core.init', []);
138
+ log('Logged in successfully.');
139
+ repl.displayPrompt(true);
140
+ Object.assign(repl.context, data);
141
+ repl.context.upload = client.uploadFileByName.bind(client);
142
+ }
143
+ for (const i in methods) {
144
+ repl.context[i] = methods[i];
145
+ }
146
+ repl.context.cli = client;
147
+ repl.context.help = () => {
148
+ console.log((0, marked_1.marked)((0, fs_1.readFileSync)((0, path_1.resolve)(process.cwd(), 'assets/usage.md')).toString()));
149
+ function enumerate(node, depth) {
150
+ var _a, _b;
151
+ for (const i in node) {
152
+ if (typeof node[i] === 'object') {
153
+ console.log(' '.repeat(depth) + colors_1.default.yellow(i));
154
+ enumerate(node[i], depth + 1);
155
+ continue;
156
+ }
157
+ console.log(' '.repeat(depth) + colors_1.default.yellow(i) + '(' + colors_1.default.blue(((_a = node[i]) === null || _a === void 0 ? void 0 : _a.args) || '') + ')', colors_1.default.white(((_b = node[i]) === null || _b === void 0 ? void 0 : _b.doc) || ''));
158
+ }
159
+ }
160
+ enumerate(methods.api, 1);
161
+ };
162
+ return repl;
163
+ });
164
+ }
165
+ const event = (event, meta) => {
166
+ log(colors_1.default.green('๏'), colors_1.default.white(event), meta ? colors_1.default.gray(meta) : undefined);
167
+ };
168
+ client.on('disconnect', (reason) => {
169
+ log('disconnected (attempt reconnect automatically)');
170
+ });
171
+ client.on('reconnect', (reason) => {
172
+ log('reconnected');
173
+ });
174
+ client.on('signals', ([signal, meta]) => __awaiter(void 0, void 0, void 0, function* () {
175
+ var _a;
176
+ const info = repl.context;
177
+ switch (signal) {
178
+ case 'wall2.new_post':
179
+ const data = yield client.request('wall2.load_posts', [meta.post_id]);
180
+ if (!data) {
181
+ // no permission to load post, in wrong workspace or permissions missing
182
+ return;
183
+ }
184
+ event('New wallpost (' + colors_1.default.white(info.users[data.uid].firstname + ' ' + info.users[data.uid].lastname) + '/' + colors_1.default.yellow(info.networks[data.cid].name) + '):');
185
+ log(' ', colors_1.default.blue(data.initMessage.subject));
186
+ log(' ', colors_1.default.green(data.initMessage.text));
187
+ break;
188
+ case 'wall2.delete_post':
189
+ event('Removed wallpost:', meta.post_id);
190
+ break;
191
+ case 'wall2.new_comment':
192
+ event('New comment.', meta.post_id);
193
+ break;
194
+ case 'wall2.delete_comment':
195
+ event('Removed comment.', meta.post_id);
196
+ break;
197
+ case 'wall2.edited_comment':
198
+ event('Edited comment.', meta.post_id);
199
+ break;
200
+ case 'activities.created':
201
+ event('New activity', (_a = info.processes) === null || _a === void 0 ? void 0 : _a.find((process) => process._id === meta.processId).name);
202
+ break;
203
+ case 'discussion.sync':
204
+ event('Discussion Sync');
205
+ break;
206
+ default:
207
+ event(signal, meta);
208
+ break;
209
+ }
210
+ }));
211
+ repl = yield startRepl();
212
+ }))();
213
+ //# sourceMappingURL=run.js.map
@@ -0,0 +1 @@
1
+ {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B;gBACvB,KAAK,CAAC,kBAAkB,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC;gBACxC,MAAM;YACV,KAAK,sBAAsB;gBACvB,KAAK,CAAC,iBAAiB,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC;gBACvC,MAAM;YACV,KAAK,oBAAoB;gBACrB,KAAK,CAAC,cAAc,EAAE,MAAA,IAAI,CAAC,SAAS,0CAAE,IAAI,CAAC,CAAC,OAAY,EAAE,EAAE,CAAC,OAAO,CAAC,GAAG,KAAK,IAAI,CAAC,SAAS,EAAE,IAAI,CAAC,CAAC;gBACnG,MAAM;YACV,KAAK,iBAAiB;gBAClB,KAAK,CAAC,iBAAiB,CAAC,CAAC;gBACzB,MAAM;YACV;gBACI,KAAK,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;gBACpB,MAAM;SACb;IACL,CAAC,CAAA,CAAC,CAAC;IAEH,IAAI,GAAG,MAAM,SAAS,EAAE,CAAC;AAC7B,CAAC,CAAA,CAAC,EAAE,CAAC"}
@@ -0,0 +1,72 @@
1
+ /// <reference types="node" />
2
+ /// <reference types="node" />
3
+ import EventEmitter from 'events';
4
+ import { Readable } from 'stream';
5
+ export interface ClientOptions {
6
+ /** Username, i.e. email address used for logging in */
7
+ username?: string;
8
+ /** Password */
9
+ password?: string;
10
+ /** Defaults to api.hailer.com */
11
+ host?: string;
12
+ }
13
+ /**
14
+ * # Hailer Client
15
+ *
16
+ * Connect to Hailer and write your own integrations, bots or scripts.
17
+ *
18
+ * Example usage:
19
+ *
20
+ * const { Client } = require('@hailer/cli');
21
+ *
22
+ * // wrap for await to work
23
+ * (async () => {
24
+ * const options = {
25
+ * host: 'https://api.hailer.biz', // defaults to https://api.hailer.com
26
+ * username: 'set-this',
27
+ * password: 'set-this',
28
+ * };
29
+ *
30
+ * const client = await Client.create(options);
31
+ *
32
+ * const post = await client.request('wall2.new_post', [{ subject: 'This is a wall post.', text: 'The content of my post' }]);
33
+ *
34
+ * console.log('Post created:', post);
35
+ * })();
36
+ */
37
+ export declare class Client extends EventEmitter {
38
+ /** Session key from login. Same as `hlrkey`-header used for HTTP requests */
39
+ sessionKey?: string;
40
+ quiet: boolean;
41
+ host: string;
42
+ username?: string;
43
+ password?: string;
44
+ private requestId;
45
+ private callbacks;
46
+ private socket?;
47
+ private constructor();
48
+ /** Creates Cli instance and logs in if username and password are given */
49
+ static create(options: ClientOptions): Promise<Client>;
50
+ request(
51
+ /** Operator / Endpoint, eg. `login` or `v3.discussion.message.star` */
52
+ op: string,
53
+ /** Arguments */
54
+ args: any[]): Promise<any>;
55
+ /** @deprecated Use async request-function instead */
56
+ requestCallback(
57
+ /** Operator / Endpoint, eg. `login` or `v3.discussion.message.star` */
58
+ op: string,
59
+ /** Arguments */
60
+ args: any[],
61
+ /** Callback function */
62
+ cb: (error: Error | null, data?: any) => void): void;
63
+ resume(sessionKey: string): Promise<void>;
64
+ login(username: string, password: string): Promise<void>;
65
+ /** Connect and attach message listeners, and returns promise which resolves when connected */
66
+ connect(hostname?: string): Promise<true | void>;
67
+ /** Upload file as stream, requires filename given separately */
68
+ uploadFileStream(stream: Readable, filename: string): Promise<string | null>;
69
+ /** Upload local file by name */
70
+ uploadFileByName(file: string): Promise<string | null>;
71
+ disconnect(): void;
72
+ }
@@ -0,0 +1,191 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __importDefault = (this && this.__importDefault) || function (mod) {
12
+ return (mod && mod.__esModule) ? mod : { "default": mod };
13
+ };
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ exports.Client = void 0;
16
+ const fs_1 = require("fs");
17
+ const path_1 = require("path");
18
+ const events_1 = __importDefault(require("events"));
19
+ const socket_io_client_1 = require("socket.io-client");
20
+ const file_upload_1 = require("./commands/file-upload");
21
+ /**
22
+ * # Hailer Client
23
+ *
24
+ * Connect to Hailer and write your own integrations, bots or scripts.
25
+ *
26
+ * Example usage:
27
+ *
28
+ * const { Client } = require('@hailer/cli');
29
+ *
30
+ * // wrap for await to work
31
+ * (async () => {
32
+ * const options = {
33
+ * host: 'https://api.hailer.biz', // defaults to https://api.hailer.com
34
+ * username: 'set-this',
35
+ * password: 'set-this',
36
+ * };
37
+ *
38
+ * const client = await Client.create(options);
39
+ *
40
+ * const post = await client.request('wall2.new_post', [{ subject: 'This is a wall post.', text: 'The content of my post' }]);
41
+ *
42
+ * console.log('Post created:', post);
43
+ * })();
44
+ */
45
+ class Client extends events_1.default {
46
+ constructor() {
47
+ super();
48
+ this.quiet = false;
49
+ this.host = 'api.hailer.com';
50
+ this.requestId = 0;
51
+ this.callbacks = {};
52
+ }
53
+ /** Creates Cli instance and logs in if username and password are given */
54
+ static create(options) {
55
+ return __awaiter(this, void 0, void 0, function* () {
56
+ const instance = new Client();
57
+ instance.host = options.host || 'api.hailer.com';
58
+ yield instance.connect(instance.host);
59
+ if (options.username && options.password) {
60
+ // automatically connect if username and password is given
61
+ yield instance.login(options.username, options.password);
62
+ }
63
+ return instance;
64
+ });
65
+ }
66
+ request(
67
+ /** Operator / Endpoint, eg. `login` or `v3.discussion.message.star` */
68
+ op,
69
+ /** Arguments */
70
+ args) {
71
+ return __awaiter(this, void 0, void 0, function* () {
72
+ return new Promise((resolve, reject) => {
73
+ var _a;
74
+ const id = ++this.requestId;
75
+ this.callbacks[id] = (err, data) => {
76
+ if (err) {
77
+ return reject(data);
78
+ }
79
+ resolve(data);
80
+ };
81
+ ;
82
+ (_a = this.socket) === null || _a === void 0 ? void 0 : _a.emit('rpc-request', { op, args, id });
83
+ });
84
+ });
85
+ }
86
+ ;
87
+ /** @deprecated Use async request-function instead */
88
+ requestCallback(
89
+ /** Operator / Endpoint, eg. `login` or `v3.discussion.message.star` */
90
+ op,
91
+ /** Arguments */
92
+ args,
93
+ /** Callback function */
94
+ cb) {
95
+ var _a;
96
+ const id = ++this.requestId;
97
+ this.callbacks[id] = cb;
98
+ (_a = this.socket) === null || _a === void 0 ? void 0 : _a.emit('rpc-request', { op, args, id });
99
+ }
100
+ resume(sessionKey) {
101
+ return __awaiter(this, void 0, void 0, function* () {
102
+ this.sessionKey = yield this.request('resume', [sessionKey]);
103
+ });
104
+ }
105
+ login(username, password) {
106
+ return __awaiter(this, void 0, void 0, function* () {
107
+ this.sessionKey = yield this.request('login', [username, password]);
108
+ });
109
+ }
110
+ /** Connect and attach message listeners, and returns promise which resolves when connected */
111
+ connect(hostname) {
112
+ return __awaiter(this, void 0, void 0, function* () {
113
+ if (!hostname) {
114
+ hostname = this.host;
115
+ }
116
+ const options = { transports: ['websocket'] };
117
+ if (!hostname.startsWith('http://') &&
118
+ !hostname.startsWith('https://')) {
119
+ hostname = 'https://' + hostname;
120
+ }
121
+ this.socket = (0, socket_io_client_1.io)(hostname, options);
122
+ this.socket.on('rpc-response', (message) => {
123
+ const msg = message.data;
124
+ if (msg.err) {
125
+ msg.ack = msg.err;
126
+ }
127
+ if (msg.sig) {
128
+ if (typeof msg.sig === 'string') {
129
+ this.emit('signals', [msg.sig, msg.meta]);
130
+ return;
131
+ }
132
+ msg.ack = msg.sig;
133
+ }
134
+ if (!this.callbacks[msg.ack]) {
135
+ // ignore unknown message
136
+ return;
137
+ }
138
+ this.callbacks[msg.ack](msg.err ? msg.data : null, msg.data);
139
+ if (!msg.sig) {
140
+ delete this.callbacks[msg.ack];
141
+ }
142
+ });
143
+ this.socket.on('error', (args) => {
144
+ this.emit('error', args);
145
+ });
146
+ this.socket.io.on('reconnect', () => __awaiter(this, void 0, void 0, function* () {
147
+ this.emit('reconnect');
148
+ if (this.sessionKey) {
149
+ yield this.resume(this.sessionKey);
150
+ }
151
+ }));
152
+ this.socket.on('connect', () => {
153
+ this.emit('connect');
154
+ });
155
+ this.socket.on('disconnect', (reason) => {
156
+ this.emit('disconnect', reason);
157
+ });
158
+ return this.socket.connected || new Promise((resolve, reject) => {
159
+ var _a;
160
+ setTimeout(() => {
161
+ var _a;
162
+ if (!((_a = this.socket) === null || _a === void 0 ? void 0 : _a.connected)) {
163
+ reject(new Error('Timeout connecting to: ' + hostname));
164
+ }
165
+ }, 3000);
166
+ (_a = this.socket) === null || _a === void 0 ? void 0 : _a.on('connect', resolve);
167
+ });
168
+ });
169
+ }
170
+ ;
171
+ /** Upload file as stream, requires filename given separately */
172
+ uploadFileStream(stream, filename) {
173
+ return __awaiter(this, void 0, void 0, function* () {
174
+ return yield (0, file_upload_1.upload)(stream, { sessionKey: this.sessionKey, filename, url: this.host });
175
+ });
176
+ }
177
+ /** Upload local file by name */
178
+ uploadFileByName(file) {
179
+ return __awaiter(this, void 0, void 0, function* () {
180
+ const readStream = (0, fs_1.createReadStream)(file);
181
+ return yield (0, file_upload_1.upload)(readStream, { sessionKey: this.sessionKey, filename: (0, path_1.basename)(file), url: this.host });
182
+ });
183
+ }
184
+ disconnect() {
185
+ var _a;
186
+ (_a = this.socket) === null || _a === void 0 ? void 0 : _a.disconnect();
187
+ }
188
+ ;
189
+ }
190
+ exports.Client = Client;
191
+ //# sourceMappingURL=client.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.js","sourceRoot":"","sources":["../../src/client.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AACA,2BAAsC;AACtC,+BAAgC;AAChC,oDAAkC;AAClC,uDAA8C;AAC9C,wDAAgD;AAahD;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,MAAa,MAAO,SAAQ,gBAAY;IAYpC;QACI,KAAK,EAAE,CAAC;QAVZ,UAAK,GAAG,KAAK,CAAC;QACd,SAAI,GAAG,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CAAC;KAAA;IAED,UAAU;;QACN,MAAA,IAAI,CAAC,MAAM,0CAAE,UAAU,EAAE,CAAC;IAC9B,CAAC;IAAA,CAAC;CACL;AAjKD,wBAiKC"}
@@ -0,0 +1 @@
1
+ export declare const displayHelpAndExit: () => never;
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.displayHelpAndExit = void 0;
4
+ const fs_1 = require("fs");
5
+ const marked_1 = require("marked");
6
+ const path_1 = require("path");
7
+ let pkg = {};
8
+ try {
9
+ pkg = require('../../package.json');
10
+ }
11
+ catch (error) {
12
+ pkg = require('../../../package.json');
13
+ }
14
+ const displayHelpAndExit = () => {
15
+ console.log((0, marked_1.marked)('# Hailer CLI ' + pkg.version + '\n\n' + (0, fs_1.readFileSync)((0, path_1.resolve)(process.cwd(), 'assets/help.md')).toString()));
16
+ process.exit(0);
17
+ };
18
+ exports.displayHelpAndExit = displayHelpAndExit;
19
+ //# sourceMappingURL=display-help.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"display-help.js","sourceRoot":"","sources":["../../../src/commands/display-help.ts"],"names":[],"mappings":";;;AAAA,2BAAkC;AAClC,mCAAgC;AAChC,+BAA+B;AAE/B,IAAI,GAAG,GAAG,EAAS,CAAC;AAEpB,IAAI;IACA,GAAG,GAAG,OAAO,CAAC,oBAAoB,CAAC,CAAC;CACvC;AAAC,OAAO,KAAK,EAAE;IACZ,GAAG,GAAG,OAAO,CAAC,uBAAuB,CAAC,CAAC;CAC1C;AAEM,MAAM,kBAAkB,GAAG,GAAG,EAAE;IACnC,OAAO,CAAC,GAAG,CAAC,IAAA,eAAM,EAAC,eAAe,GAAG,GAAG,CAAC,OAAO,GAAG,MAAM,GAAG,IAAA,iBAAY,EAAC,IAAA,cAAO,EAAC,OAAO,CAAC,GAAG,EAAE,EAAE,gBAAgB,CAAC,CAAC,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC;IAChI,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AACpB,CAAC,CAAC;AAHW,QAAA,kBAAkB,sBAG7B"}
@@ -0,0 +1,18 @@
1
+ /// <reference types="node" />
2
+ import { Readable } from 'stream';
3
+ interface UploadOptions {
4
+ sessionKey?: string;
5
+ filename?: string;
6
+ filesize?: number;
7
+ url?: string;
8
+ method?: 'POST';
9
+ headers?: {
10
+ [header: string]: string | number;
11
+ };
12
+ form?: {
13
+ file: string;
14
+ };
15
+ }
16
+ /** Upload a file using read stream, and return file id on successful upload */
17
+ export declare function upload(readStream: Readable, options?: UploadOptions): Promise<string | null>;
18
+ export {};
@@ -0,0 +1,71 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.upload = void 0;
13
+ const https_1 = require("https");
14
+ const http_1 = require("http");
15
+ const url_1 = require("url");
16
+ /** Upload a file using read stream, and return file id on successful upload */
17
+ function upload(readStream, options) {
18
+ var _a;
19
+ return __awaiter(this, void 0, void 0, function* () {
20
+ const filename = (options === null || options === void 0 ? void 0 : options.filename) || 'file.bin';
21
+ // const filesize = options?.filesize;
22
+ const boundary = '----LeckingBoundary12341234';
23
+ const httpOptions = Object.assign({ path: '/upload', method: 'POST', headers: {
24
+ // ... filesize ? { 'content-length': filesize } : null,
25
+ ['content-type']: 'multipart/form-data; boundary=' + boundary,
26
+ hlrkey: (options === null || options === void 0 ? void 0 : options.sessionKey) || '',
27
+ }, form: {
28
+ file: filename
29
+ } }, options);
30
+ const response = yield new Promise((resolve, reject) => {
31
+ const chunks = [];
32
+ const url = new url_1.URL((options === null || options === void 0 ? void 0 : options.url) || 'https://api.hailer.com');
33
+ // decide if we should use http or https
34
+ const request = url.protocol === 'http:' ? http_1.request : https_1.request;
35
+ httpOptions.host = url.hostname;
36
+ httpOptions.port = url.port;
37
+ const req = request(httpOptions, function (res) {
38
+ res.on('data', function (chunk) {
39
+ chunks.push(chunk);
40
+ });
41
+ });
42
+ req.on('close', () => resolve(Buffer.concat(chunks)));
43
+ req.on('error', reject);
44
+ req.write("--" + boundary + "\r\n");
45
+ req.write('Content-Disposition: form-data; name="file"; filename="' + filename + '"\r\n\r\n');
46
+ readStream.pipe(req, { end: false });
47
+ readStream.on('end', () => {
48
+ req.write("--" + boundary + "\r\n");
49
+ req.write('Content-Disposition: form-data; name="button"\r\n\r\n');
50
+ req.write('Submit\r\n');
51
+ req.write("--" + boundary + "--\r\n");
52
+ req.end();
53
+ });
54
+ }).catch((error) => {
55
+ console.log('oh fail....', error);
56
+ });
57
+ if (!Buffer.isBuffer(response)) {
58
+ return 'this went wrong...';
59
+ }
60
+ let fileId = null;
61
+ try {
62
+ fileId = (_a = JSON.parse(response.toString())) === null || _a === void 0 ? void 0 : _a._id;
63
+ }
64
+ catch (error) {
65
+ console.log('Failed getting file id from upload', response.toString());
66
+ }
67
+ return fileId;
68
+ });
69
+ }
70
+ exports.upload = upload;
71
+ //# sourceMappingURL=file-upload.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"file-upload.js","sourceRoot":"","sources":["../../../src/commands/file-upload.ts"],"names":[],"mappings":";;;;;;;;;;;;AACA,iCAAgD;AAChD,+BAA8C;AAE9C,6BAA0B;AAY1B,+EAA+E;AAC/E,SAAsB,MAAM,CAAC,UAAoB,EAAE,OAAuB;;;QACtE,MAAM,QAAQ,GAAG,CAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,QAAQ,KAAI,UAAU,CAAC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use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Client = void 0;
4
+ var client_1 = require("./client");
5
+ Object.defineProperty(exports, "Client", { enumerable: true, get: function () { return client_1.Client; } });
6
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;AAAA,mCAAiD;AAAxC,gGAAA,MAAM,OAAA"}
@@ -0,0 +1,4 @@
1
+ /// <reference types="node" />
2
+ import { InspectOptions } from 'util';
3
+ export declare function inspect(data: any, options?: InspectOptions): string;
4
+ export declare const toISOStringWithTimezone: (date: Date) => string;
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.toISOStringWithTimezone = exports.inspect = void 0;
4
+ const util_1 = require("util");
5
+ function inspect(data, options) {
6
+ return (0, util_1.inspect)(data, options || { colors: true, depth: 10, breakLength: 140 });
7
+ }
8
+ exports.inspect = inspect;
9
+ // https://www.30secondsofcode.org/js/s/to-iso-string-with-timezone 2022-10-24
10
+ const toISOStringWithTimezone = (date) => {
11
+ const tzOffset = -date.getTimezoneOffset();
12
+ const diff = tzOffset >= 0 ? '+' : '-';
13
+ const pad = (n) => `${Math.floor(Math.abs(n))}`.padStart(2, '0');
14
+ return date.getFullYear() +
15
+ '-' + pad(date.getMonth() + 1) +
16
+ '-' + pad(date.getDate()) +
17
+ 'T' + pad(date.getHours()) +
18
+ ':' + pad(date.getMinutes()) +
19
+ ':' + pad(date.getSeconds()) +
20
+ diff + pad(tzOffset / 60) +
21
+ ':' + pad(tzOffset % 60);
22
+ };
23
+ exports.toISOStringWithTimezone = toISOStringWithTimezone;
24
+ //# sourceMappingURL=util.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"util.js","sourceRoot":"","sources":["../../src/util.ts"],"names":[],"mappings":";;;AAAA,+BAA8D;AAE9D,SAAgB,OAAO,CAAC,IAAS,EAAE,OAAwB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ist/src/index.d.ts",
7
+ "scripts": {
8
+ "build": "tsc",
9
+ "start": "tsc && cp -rp assets dist/ && node bin/hailer-cli",
10
+ "test": "echo \"Error: no test specified\" && exit 1",
11
+ "lint": "eslint --ext .ts ."
12
+ },
13
+ "bin": {
14
+ "hailer-cli": "./bin/hailer-cli"
15
+ },
16
+ "repository": {
17
+ "type": "git",
18
+ "url": "git+ssh://git@bitbucket.org/hailer/hailer-cli.git"
19
+ },
20
+ "keywords": [
21
+ "hailer",
22
+ "api",
23
+ "cli"
24
+ ],
25
+ "author": "André Kaustell <andre.kaustell@wishtech.fi>",
26
+ "license": "ISC",
27
+ "homepage": "https://bitbucket.org/hailer/hailer-cli#readme",
28
+ "dependencies": {
29
+ "colors": "1.4.0",
30
+ "marked": "4.0.17",
31
+ "marked-terminal": "5.1.1",
32
+ "minimal-password-prompt": "1.1.0",
33
+ "minimist": "1.2.6",
34
+ "socket.io-client": "4.5.1"
35
+ },
36
+ "devDependencies": {
37
+ "@types/marked": "4.0.3",
38
+ "@types/marked-terminal": "3.1.3",
39
+ "@types/minimist": "1.2.2",
40
+ "@types/node": "16.4.11",
41
+ "@typescript-eslint/eslint-plugin": "5.30.0",
42
+ "@typescript-eslint/parser": "5.30.0",
43
+ "eslint": "8.18.0",
44
+ "eslint-config-prettier": "8.5.0",
45
+ "typescript": "4.7.4"
46
+ }
47
+ }