kozz-module-maker 0.1.8 → 0.1.10
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/dist/Instance/Common/onEvent/index.d.ts +1 -1
- package/dist/Instance/GeneralModule/index.d.ts +1 -1
- package/dist/Message/PayloadCreation/sendMessage.js +1 -0
- package/dist/Message/PayloadCreation/sendMessage.js.map +1 -1
- package/dist/Message/RoutineCreation/SendMessage/index.js +8 -4
- package/dist/Message/RoutineCreation/SendMessage/index.js.map +1 -1
- package/dist/Message/index.js +1 -1
- package/dist/Message/index.js.map +1 -1
- package/dist/Socket/Events/Emit/Introduction.d.ts +1 -1
- package/dist/Socket/Events/Emit/Introduction.js +2 -2
- package/dist/Socket/Events/Emit/Introduction.js.map +1 -1
- package/dist/debugIndex.js +8 -63
- package/dist/debugIndex.js.map +1 -1
- package/dist/util/index.d.ts +1 -1
- package/package.json +4 -3
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Socket } from 'socket.io-client';
|
|
2
2
|
export declare const onEvent: (socket: Socket, handlerId: string) => {
|
|
3
3
|
on: (evName: string, eventSource: string, callback: (ev: any) => any) => {
|
|
4
|
-
eventId:
|
|
4
|
+
eventId: string;
|
|
5
5
|
revoke: () => void;
|
|
6
6
|
};
|
|
7
7
|
tryRunEventListeners: (evName: string, eventPayload: any) => void;
|
|
@@ -20,7 +20,7 @@ export type ControllerInitParams<Methods extends Record<string, TypeString>> = {
|
|
|
20
20
|
export declare const createModule: <Methods extends Record<string, TypeString>>({ name, address, commands, proxy, signature, templatePath, }: ControllerInitParams<Methods>) => {
|
|
21
21
|
use: (useFn: import("../Common").UseFn) => any;
|
|
22
22
|
on: (evName: string, eventSource: string, callback: (ev: any) => any) => {
|
|
23
|
-
eventId:
|
|
23
|
+
eventId: string;
|
|
24
24
|
revoke: () => void;
|
|
25
25
|
};
|
|
26
26
|
sendMessage: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sendMessage.js","sourceRoot":"","sources":["../../../src/Message/PayloadCreation/sendMessage.ts"],"names":[],"mappings":";;;AAEO,MAAM,wBAAwB,GAAG,CACvC,WAAmB,EACnB,SAAiB,EACjB,UAAkB,EAClB,IAAY,EACZ,KAAa,EACQ,EAAE;IACvB,OAAO;QACN,IAAI;QACJ,UAAU,EAAE,UAAU;QACtB,MAAM,EAAE,SAAS;QACjB,OAAO,EAAE;YACR,UAAU,EAAE,WAAW;YACvB,WAAW,EAAE,WAAW;YACxB,EAAE,EAAE,WAAW;YACf,SAAS,EAAE,KAAK;YAChB,SAAS,EAAE,IAAI;YACf,OAAO,EAAE,KAAK;
|
|
1
|
+
{"version":3,"file":"sendMessage.js","sourceRoot":"","sources":["../../../src/Message/PayloadCreation/sendMessage.ts"],"names":[],"mappings":";;;AAEO,MAAM,wBAAwB,GAAG,CACvC,WAAmB,EACnB,SAAiB,EACjB,UAAkB,EAClB,IAAY,EACZ,KAAa,EACQ,EAAE;IACvB,OAAO;QACN,IAAI;QACJ,UAAU,EAAE,UAAU;QACtB,MAAM,EAAE,SAAS;QACjB,OAAO,EAAE;YACR,UAAU,EAAE,WAAW;YACvB,WAAW,EAAE,WAAW;YACxB,EAAE,EAAE,WAAW;YACf,SAAS,EAAE,KAAK;YAChB,SAAS,EAAE,IAAI;YACf,OAAO,EAAE,KAAK;YACd,aAAa,EAAE,IAAI;SACnB;QACD,QAAQ,EAAE,IAAI;QACd,SAAS,EAAE,IAAI,IAAI,EAAE,CAAC,OAAO,EAAE;QAC/B,OAAO,EAAE,SAAS;QAClB,KAAK;KACL,CAAC;AACH,CAAC,CAAC;AAzBW,QAAA,wBAAwB,4BAyBnC"}
|
|
@@ -4,20 +4,24 @@ exports.sendMessageToContact = exports.sendMessageToContactOnRequesterObject = v
|
|
|
4
4
|
const sendMessage_1 = require("../../PayloadCreation/sendMessage");
|
|
5
5
|
const sendMessageToContactOnRequesterObject = (socket, handlerName, boundaryId) => {
|
|
6
6
|
const sendMessage = (contactId, body) => {
|
|
7
|
-
|
|
7
|
+
const payload = (0, sendMessage_1.createSendMessagePayload)(handlerName, contactId, boundaryId, body);
|
|
8
|
+
socket.emit('send_message', payload);
|
|
8
9
|
};
|
|
9
10
|
sendMessage.withMedia = (contactId, caption, media) => {
|
|
10
|
-
|
|
11
|
+
const payload = (0, sendMessage_1.createSendMessagePayload)(handlerName, contactId, boundaryId, caption, media);
|
|
12
|
+
socket.emit('send_message', payload);
|
|
11
13
|
};
|
|
12
14
|
return sendMessage;
|
|
13
15
|
};
|
|
14
16
|
exports.sendMessageToContactOnRequesterObject = sendMessageToContactOnRequesterObject;
|
|
15
17
|
const sendMessageToContact = (socket, handlerName) => {
|
|
16
18
|
const sendMessage = (contactId, boundaryId, body) => {
|
|
17
|
-
|
|
19
|
+
const payload = (0, sendMessage_1.createSendMessagePayload)(handlerName, contactId, boundaryId, body);
|
|
20
|
+
socket.emit('send_message', payload);
|
|
18
21
|
};
|
|
19
22
|
sendMessage.withMedia = (contactId, boundaryId, caption, media) => {
|
|
20
|
-
|
|
23
|
+
const payload = (0, sendMessage_1.createSendMessagePayload)(handlerName, contactId, boundaryId, caption, media);
|
|
24
|
+
socket.emit('send_message', payload);
|
|
21
25
|
};
|
|
22
26
|
return sendMessage;
|
|
23
27
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/Message/RoutineCreation/SendMessage/index.ts"],"names":[],"mappings":";;;AAEA,mEAA6E;AAEtE,MAAM,qCAAqC,GAAG,CACpD,MAAc,EACd,WAAmB,EACnB,UAAkB,EACjB,EAAE;IACH,MAAM,WAAW,GAAG,CAAC,SAAiB,EAAE,IAAY,EAAE,EAAE;QACvD,MAAM,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/Message/RoutineCreation/SendMessage/index.ts"],"names":[],"mappings":";;;AAEA,mEAA6E;AAEtE,MAAM,qCAAqC,GAAG,CACpD,MAAc,EACd,WA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B,wBA+B/B"}
|
package/dist/Message/index.js
CHANGED
|
@@ -25,7 +25,7 @@ const createMessageObject = (socket, messagePayload, handlerId, templatePath, co
|
|
|
25
25
|
* Replies the requester of the command.
|
|
26
26
|
*/
|
|
27
27
|
const reply = (0, reply_1.createReply)(socket, messagePayload, templatePath);
|
|
28
|
-
const sendMessage = (0, SendMessage_1.sendMessageToContactOnRequesterObject)(socket, handlerId, messagePayload.
|
|
28
|
+
const sendMessage = (0, SendMessage_1.sendMessageToContactOnRequesterObject)(socket, handlerId, messagePayload.boundaryId);
|
|
29
29
|
const ask = (0, AskResource_1.createAskResource)(socket, {
|
|
30
30
|
requester: {
|
|
31
31
|
id: handlerId,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/Message/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAEA,mDAAsD;AACtD,+DAAkE;AAClE,+DAAsF;AACtF,mDAAsD;AACtD,iDAA+B;AAIxB,MAAM,mBAAmB,GAAG,CAClC,MAAc,EACd,cAAwC,EACxC,SAAiB,EACjB,YAAqB,EACrB,OAAiB,EAChB,EAAE;IACH;;OAEG;IACH,MAAM,KAAK,GAAG,IAAA,mBAAW,EAAC,MAAM,EAAE,cAAc,EAAE,YAAY,CAAC,CAAC;IAChE,MAAM,WAAW,GAAG,IAAA,mDAAqC,EACxD,MAAM,EACN,SAAS,EACT,cAAc,CAAC,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/Message/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAEA,mDAAsD;AACtD,+DAAkE;AAClE,+DAAsF;AACtF,mDAAsD;AACtD,iDAA+B;AAIxB,MAAM,mBAAmB,GAAG,CAClC,MAAc,EACd,cAAwC,EACxC,SAAiB,EACjB,YAAqB,EACrB,OAAiB,EAChB,EAAE;IACH;;OAEG;IACH,MAAM,KAAK,GAAG,IAAA,mBAAW,EAAC,MAAM,EAAE,cAAc,EAAE,YAAY,CAAC,CAAC;IAChE,MAAM,WAAW,GAAG,IAAA,mDAAqC,EACxD,MAAM,EACN,SAAS,EACT,cAAc,CAAC,UAAU,CACzB,CAAC;IAEF,MAAM,GAAG,GAAG,IAAA,+BAAiB,EAAC,MAAM,EAAE;QACrC,SAAS,EAAE;YACV,EAAE,EAAE,SAAS;YACb,IAAI,EAAE,SAAS;SACf;KACD,CAAC,CAAC;IACH,MAAM,KAAK,GAAG,IAAA,mBAAW,EAAC,MAAM,EAAE,cAAc,CAAC,CAAC;IAElD,OAAO;QACN,GAAG;QACH,WAAW;QACX,KAAK;QACL,UAAU,EAAE,OAAO;QACnB,OAAO,EAAE,cAAc;QACvB,KAAK;KACL,CAAC;AACH,CAAC,CAAC;AAjCW,QAAA,mBAAmB,uBAiC9B"}
|
|
@@ -7,4 +7,4 @@ import { Method, TypeString } from '../../../Schema';
|
|
|
7
7
|
* @param methods
|
|
8
8
|
* @param signature
|
|
9
9
|
*/
|
|
10
|
-
export declare const introduce: <T extends Record<string, Method<Record<string, TypeString>>>>(socket: Socket, handlerName: string, methods: T, signature?: string) => void
|
|
10
|
+
export declare const introduce: <T extends Record<string, Method<Record<string, TypeString>>>>(socket: Socket, handlerName: string, methods: T, signature?: string) => Promise<void>;
|
|
@@ -9,13 +9,13 @@ const util_1 = require("../../../util");
|
|
|
9
9
|
* @param methods
|
|
10
10
|
* @param signature
|
|
11
11
|
*/
|
|
12
|
-
const introduce = (socket, handlerName, methods, signature) => {
|
|
12
|
+
const introduce = async (socket, handlerName, methods, signature) => {
|
|
13
13
|
const payload = {
|
|
14
14
|
methods: Object.keys(methods),
|
|
15
15
|
name: handlerName,
|
|
16
16
|
role: 'handler',
|
|
17
17
|
};
|
|
18
|
-
socket.emit('introduction', (0, util_1.signPayload)(payload, signature));
|
|
18
|
+
socket.emit('introduction', await (0, util_1.signPayload)(payload, signature));
|
|
19
19
|
};
|
|
20
20
|
exports.introduce = introduce;
|
|
21
21
|
//# sourceMappingURL=Introduction.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Introduction.js","sourceRoot":"","sources":["../../../../src/Socket/Events/Emit/Introduction.ts"],"names":[],"mappings":";;;AAGA,wCAA4C;AAE5C;;;;;;GAMG;AACI,MAAM,SAAS,GAAG,
|
|
1
|
+
{"version":3,"file":"Introduction.js","sourceRoot":"","sources":["../../../../src/Socket/Events/Emit/Introduction.ts"],"names":[],"mappings":";;;AAGA,wCAA4C;AAE5C;;;;;;GAMG;AACI,MAAM,SAAS,GAAG,KAAK,EAG7B,MAAc,EACd,WAAmB,EACnB,OAAU,EACV,SAAkB,EACjB,EAAE;IACH,MAAM,OAAO,GAA8C;QAC1D,OAAO,EAAE,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC;QAC7B,IAAI,EAAE,WAAW;QACjB,IAAI,EAAE,SAAS;KACf,CAAC;IAEF,MAAM,CAAC,IAAI,CAAC,cAAc,EAAE,MAAM,IAAA,kBAAW,EAAC,OAAO,EAAE,SAAS,CAAC,CAAC,CAAC;AACpE,CAAC,CAAC;AAfW,QAAA,SAAS,aAepB"}
|
package/dist/debugIndex.js
CHANGED
|
@@ -1,71 +1,16 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const _1 = require(".");
|
|
4
|
-
const StateMachine_1 = require("./StateMachine");
|
|
5
4
|
const defaultGatewayUrl = 'http://127.0.0.1:4521';
|
|
6
|
-
const defaultMethod = (0, _1.createMethod)('default', (requester, { bool }) => {
|
|
7
|
-
console.log(requester);
|
|
8
|
-
requester.reply('hello from kozz-bot');
|
|
9
|
-
});
|
|
10
|
-
const createUserDataGetter = () => {
|
|
11
|
-
const data = {
|
|
12
|
-
name: "",
|
|
13
|
-
maybeName: "",
|
|
14
|
-
};
|
|
15
|
-
return (0, StateMachine_1.createStateMachine)({
|
|
16
|
-
initialState: "greeting",
|
|
17
|
-
states: {
|
|
18
|
-
greeting: {
|
|
19
|
-
onMessage: (requester, stateMachine) => {
|
|
20
|
-
requester.reply("Olá, vamos obter seus dados");
|
|
21
|
-
stateMachine.setState("ask_name");
|
|
22
|
-
}
|
|
23
|
-
},
|
|
24
|
-
ask_name: {
|
|
25
|
-
onMessage: (requester, stateMachine) => {
|
|
26
|
-
requester.reply(`Seu nome é ${requester.message.body}, você confirma?\n - 1: Sim\n -2: Não`);
|
|
27
|
-
data.maybeName = requester.message.body;
|
|
28
|
-
stateMachine.setState("confirm_name");
|
|
29
|
-
},
|
|
30
|
-
onStateEnable: (requester, stateMachine) => {
|
|
31
|
-
requester.reply("Por favor me diga seu nome");
|
|
32
|
-
}
|
|
33
|
-
},
|
|
34
|
-
confirm_name: {
|
|
35
|
-
onMessage: (requester, stateMachine) => {
|
|
36
|
-
if (requester.message.body === "1") {
|
|
37
|
-
data.name = data.maybeName;
|
|
38
|
-
stateMachine.setState("say_bye");
|
|
39
|
-
}
|
|
40
|
-
else if (requester.message.body === "2") {
|
|
41
|
-
stateMachine.setState("ask_name");
|
|
42
|
-
}
|
|
43
|
-
else {
|
|
44
|
-
requester.reply("Não entendi. Responda apenas com um número.");
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
},
|
|
48
|
-
say_bye: {
|
|
49
|
-
onMessage: (requester, stateMachine) => {
|
|
50
|
-
requester.reply(`Já obtive seus dados, ${data.name}, obrigado!`);
|
|
51
|
-
},
|
|
52
|
-
onStateEnable: (requester, stateMachine) => {
|
|
53
|
-
requester.reply("Muito obrigado! Até a proxima");
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
});
|
|
58
|
-
};
|
|
59
5
|
const myModule = (0, _1.createModule)({
|
|
60
|
-
name: '
|
|
6
|
+
name: 'test',
|
|
61
7
|
address: defaultGatewayUrl,
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
myModule.sendMessage("5511947952409@c.us", "Gramonta-Wa", "hello!");
|
|
8
|
+
commands: {
|
|
9
|
+
boundariesToHandle: ['*'],
|
|
10
|
+
methods: {
|
|
11
|
+
...(0, _1.createMethod)('fallback', requester => requester.reply('oops, this method doesnt exist')),
|
|
12
|
+
...(0, _1.createMethod)('default', requester => requester.reply('pong')),
|
|
13
|
+
},
|
|
14
|
+
},
|
|
70
15
|
});
|
|
71
16
|
//# sourceMappingURL=debugIndex.js.map
|
package/dist/debugIndex.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"debugIndex.js","sourceRoot":"","sources":["../src/debugIndex.ts"],"names":[],"mappings":";;AAAA,wBAA+C;
|
|
1
|
+
{"version":3,"file":"debugIndex.js","sourceRoot":"","sources":["../src/debugIndex.ts"],"names":[],"mappings":";;AAAA,wBAA+C;AAE/C,MAAM,iBAAiB,GAAG,uBAAuB,CAAC;AAElD,MAAM,QAAQ,GAAG,IAAA,eAAY,EAAC;IAC7B,IAAI,EAAE,MAAM;IACZ,OAAO,EAAE,iBAAiB;IAC1B,QAAQ,EAAE;QACT,kBAAkB,EAAE,CAAC,GAAG,CAAC;QACzB,OAAO,EAAE;YACR,GAAG,IAAA,eAAY,EAAC,UAAU,EAAE,SAAS,CAAC,EAAE,CACvC,SAAS,CAAC,KAAK,CAAC,gCAAgC,CAAC,CACjD;YACD,GAAG,IAAA,eAAY,EAAC,SAAS,EAAE,SAAS,CAAC,EAAE,CAAC,SAAS,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;SAChE;KACD;CACD,CAAC,CAAC"}
|
package/dist/util/index.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ import { Command } from 'kozz-types';
|
|
|
3
3
|
import { UseFn } from '../Instance/Common';
|
|
4
4
|
export declare const runUse: (useArr: UseFn[], args: Command) => Command;
|
|
5
5
|
export declare function normalizeString(string: string): string;
|
|
6
|
-
export declare const randomId: () =>
|
|
6
|
+
export declare const randomId: () => string;
|
|
7
7
|
export declare const signPayload: <T extends Record<string, any>>(payload: T, signature?: string) => Promise<T & {
|
|
8
8
|
signature: Buffer;
|
|
9
9
|
}> | (T & {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "kozz-module-maker",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.10",
|
|
4
4
|
"description": "Library to create new module for the Kozz-Bot protocol",
|
|
5
5
|
"main": "./dist",
|
|
6
6
|
"license": "MIT",
|
|
@@ -10,12 +10,13 @@
|
|
|
10
10
|
"test": "jest",
|
|
11
11
|
"docs": "typedoc ./src/index.ts",
|
|
12
12
|
"prepare": "husky install",
|
|
13
|
-
"refresh-lib": "./.husky./post-commit"
|
|
13
|
+
"refresh-lib": "./.husky./post-commit",
|
|
14
|
+
"prepublish": "tsc"
|
|
14
15
|
},
|
|
15
16
|
"devDependencies": {
|
|
16
17
|
"@types/jest": "^29.2.5",
|
|
17
18
|
"concurrently": "^7.5.0",
|
|
18
|
-
"kozz-types": "
|
|
19
|
+
"kozz-types": "^0.1.5",
|
|
19
20
|
"nodemon": "^2.0.22",
|
|
20
21
|
"typedoc": "^0.23.21",
|
|
21
22
|
"typescript": "^5.0.4"
|