kozz-module-maker 0.2.2 → 0.2.4
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/ResourceMap/index.d.ts +1 -1
- package/dist/Instance/Common/UseFns/index.d.ts +1 -1
- package/dist/Instance/Common/index.d.ts +1 -1
- package/dist/Instance/Common/index.js +0 -6
- package/dist/Instance/Common/onEvent/index.js +1 -3
- package/dist/Instance/GeneralModule/index.d.ts +7 -13
- package/dist/Instance/GeneralModule/index.js +2 -1
- package/dist/Message/PayloadCreation/Media.d.ts +1 -2
- package/dist/Message/PayloadCreation/React.d.ts +1 -1
- package/dist/Message/PayloadCreation/Reply.d.ts +1 -1
- package/dist/Message/PayloadCreation/sendMessage.d.ts +1 -1
- package/dist/Message/ProxiedMessage/index.d.ts +7 -15
- package/dist/Message/RoutineCreation/AskResource/index.d.ts +3 -3
- package/dist/Message/RoutineCreation/Reply/WithMedia.d.ts +0 -1
- package/dist/Message/RoutineCreation/reply.d.ts +5 -6
- package/dist/Message/index.d.ts +7 -15
- package/dist/debugIndex.js +10 -10
- package/dist/index.d.ts +1 -1
- package/dist/jsx-runtime/MessageTemplating.d.ts +29 -0
- package/dist/jsx-runtime/index.d.ts +28 -0
- package/dist/util/index.d.ts +4 -5
- package/dist/util/index.js +6 -2
- package/package.json +3 -3
- package/tsconfig.json +11 -3
- package/dist/InlineCommands/index.js.map +0 -1
- package/dist/Instance/Basic/index.d.ts +0 -40
- package/dist/Instance/Basic/index.js +0 -43
- package/dist/Instance/Basic/index.js.map +0 -1
- package/dist/Instance/BasicController/index.d.ts +0 -40
- package/dist/Instance/BasicController/index.js +0 -43
- package/dist/Instance/BasicController/index.js.map +0 -1
- package/dist/Instance/CommandHandler/index.d.ts +0 -20
- package/dist/Instance/CommandHandler/index.js +0 -26
- package/dist/Instance/CommandHandler/index.js.map +0 -1
- package/dist/Instance/Common/ResourceMap/index.js.map +0 -1
- package/dist/Instance/Common/UseFns/index.js.map +0 -1
- package/dist/Instance/Common/index.js.map +0 -1
- package/dist/Instance/Common/onEvent/index.js.map +0 -1
- package/dist/Instance/GeneralHandler/index.d.ts +0 -19
- package/dist/Instance/GeneralHandler/index.js +0 -49
- package/dist/Instance/GeneralHandler/index.js.map +0 -1
- package/dist/Instance/GeneralModule/index.js.map +0 -1
- package/dist/Instance/Handler/index.d.ts +0 -23
- package/dist/Instance/Handler/index.js +0 -26
- package/dist/Instance/Handler/index.js.map +0 -1
- package/dist/Instance/Proxy/index.d.ts +0 -22
- package/dist/Instance/Proxy/index.js +0 -36
- package/dist/Instance/Proxy/index.js.map +0 -1
- package/dist/Instance/index.d.ts +0 -14
- package/dist/Instance/index.js +0 -20
- package/dist/Instance/index.js.map +0 -1
- package/dist/Message/FromTemplate/index.js.map +0 -1
- package/dist/Message/PayloadCreation/Media.js.map +0 -1
- package/dist/Message/PayloadCreation/React.js.map +0 -1
- package/dist/Message/PayloadCreation/Reply.js.map +0 -1
- package/dist/Message/PayloadCreation/ReplyWithSticker.d.ts +0 -0
- package/dist/Message/PayloadCreation/ReplyWithSticker.js +0 -1
- package/dist/Message/PayloadCreation/ReplyWithText.d.ts +0 -2
- package/dist/Message/PayloadCreation/ReplyWithText.js +0 -15
- package/dist/Message/PayloadCreation/deleteMessage.js.map +0 -1
- package/dist/Message/PayloadCreation/index.js.map +0 -1
- package/dist/Message/PayloadCreation/sendMessage.js.map +0 -1
- package/dist/Message/ProxiedMessage/index.js.map +0 -1
- package/dist/Message/RoutineCreation/AskResource/AskResourceApi/index.js.map +0 -1
- package/dist/Message/RoutineCreation/AskResource/index.js.map +0 -1
- package/dist/Message/RoutineCreation/DeleteMessage/index.js.map +0 -1
- package/dist/Message/RoutineCreation/Reply/WithMedia.js.map +0 -1
- package/dist/Message/RoutineCreation/Reply/WithSticke.d.ts +0 -3
- package/dist/Message/RoutineCreation/Reply/WithSticke.js +0 -9
- package/dist/Message/RoutineCreation/Reply/WithSticke.js.map +0 -1
- package/dist/Message/RoutineCreation/Reply/WithSticker.js.map +0 -1
- package/dist/Message/RoutineCreation/Reply/WithTemplate.js.map +0 -1
- package/dist/Message/RoutineCreation/Reply/index.js.map +0 -1
- package/dist/Message/RoutineCreation/SendMessage/index.js.map +0 -1
- package/dist/Message/RoutineCreation/reply.js.map +0 -1
- package/dist/Message/index.js.map +0 -1
- package/dist/Message/kozz-md.parser/index.js.map +0 -1
- package/dist/Message/zap-md.parser/index.d.ts +0 -1
- package/dist/Message/zap-md.parser/index.js +0 -2
- package/dist/MessageTemplate/h.d.ts +0 -3
- package/dist/MessageTemplate/h.js +0 -24
- package/dist/MessageTemplate/h.js.map +0 -1
- package/dist/MessageTemplate/htm.d.ts +0 -1
- package/dist/MessageTemplate/htm.js +0 -10
- package/dist/MessageTemplate/htm.js.map +0 -1
- package/dist/MessageTemplate/renderer.d.ts +0 -13
- package/dist/MessageTemplate/renderer.js +0 -62
- package/dist/MessageTemplate/renderer.js.map +0 -1
- package/dist/MessageTemplate/types.d.ts +0 -12
- package/dist/MessageTemplate/types.js +0 -5
- package/dist/MessageTemplate/types.js.map +0 -1
- package/dist/Schema/index.js.map +0 -1
- package/dist/Socket/Events/Command.d.ts +0 -3
- package/dist/Socket/Events/Command.js +0 -19
- package/dist/Socket/Events/Command.js.map +0 -1
- package/dist/Socket/Events/Emit/ForwardEvent.js.map +0 -1
- package/dist/Socket/Events/Emit/Introduction.js.map +0 -1
- package/dist/Socket/Events/Emit/ProxyRequest.d.ts +0 -0
- package/dist/Socket/Events/Emit/ProxyRequest.js +0 -2
- package/dist/Socket/Events/Emit/ProxyRequest.js.map +0 -1
- package/dist/Socket/Events/Emit/RequestProxy.js.map +0 -1
- package/dist/Socket/Events/Emit/RevokeProxy.js.map +0 -1
- package/dist/Socket/Events/Handle/AskResource.js.map +0 -1
- package/dist/Socket/Events/Handle/Command.js.map +0 -1
- package/dist/Socket/Events/Handle/ProxiedMessage.js.map +0 -1
- package/dist/Socket/Events/Introduction.d.ts +0 -3
- package/dist/Socket/Events/Introduction.js +0 -15
- package/dist/Socket/Events/Introduction.js.map +0 -1
- package/dist/Socket/Events/ProxiedMessage.d.ts +0 -2
- package/dist/Socket/Events/ProxiedMessage.js +0 -10
- package/dist/Socket/Events/ProxiedMessage.js.map +0 -1
- package/dist/Socket/Messages/Command.d.ts +0 -2
- package/dist/Socket/Messages/Command.js +0 -6
- package/dist/Socket/Messages/Command.js.map +0 -1
- package/dist/Socket/Messages/Introduction.d.ts +0 -3
- package/dist/Socket/Messages/Introduction.js +0 -15
- package/dist/Socket/Messages/Introduction.js.map +0 -1
- package/dist/Socket/index.js.map +0 -1
- package/dist/StateMachine/index.js.map +0 -1
- package/dist/Validator/index.js.map +0 -1
- package/dist/debugIndex.js.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/util/index.js.map +0 -1
- package/dist/util.d.ts +0 -8
- package/dist/util.js +0 -36
- package/dist/util.js.map +0 -1
|
@@ -3,12 +3,6 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
Object.defineProperty(exports, "UseFn", {
|
|
7
|
-
enumerable: true,
|
|
8
|
-
get: function () {
|
|
9
|
-
return _UseFns.UseFn;
|
|
10
|
-
}
|
|
11
|
-
});
|
|
12
6
|
Object.defineProperty(exports, "createResourceMap", {
|
|
13
7
|
enumerable: true,
|
|
14
8
|
get: function () {
|
|
@@ -4,8 +4,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.onEvent = void 0;
|
|
7
|
-
var _crypto = _interopRequireDefault(require("crypto"));
|
|
8
|
-
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
9
7
|
const onEvent = (socket, handlerId) => {
|
|
10
8
|
const eventListeners = [];
|
|
11
9
|
const getListenersFromEvent = evName => {
|
|
@@ -19,7 +17,7 @@ const onEvent = (socket, handlerId) => {
|
|
|
19
17
|
listeners: []
|
|
20
18
|
});
|
|
21
19
|
}
|
|
22
|
-
const id =
|
|
20
|
+
const id = Math.floor(Math.random() * 0x100000).toString(16).padStart(6, '0');
|
|
23
21
|
eventListeners.find(listener => listener.name === evName)?.listeners.push({
|
|
24
22
|
id,
|
|
25
23
|
cb: callback
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { Method, TypeString } from '../../Schema';
|
|
2
|
-
import { ProxiedMessageObject } from '../../Message/ProxiedMessage';
|
|
3
|
-
import { Source } from 'kozz-types';
|
|
1
|
+
import type { Method, TypeString } from '../../Schema';
|
|
2
|
+
import { type ProxiedMessageObject } from '../../Message/ProxiedMessage';
|
|
3
|
+
import { type Source } from 'kozz-types';
|
|
4
4
|
export type ControllerInitParams<Methods extends Record<string, TypeString>> = {
|
|
5
5
|
name: string;
|
|
6
6
|
address: string;
|
|
@@ -30,25 +30,19 @@ export declare const createModule: <Methods extends Record<string, TypeString>>(
|
|
|
30
30
|
};
|
|
31
31
|
resources: {
|
|
32
32
|
removeResource: (name: string) => void;
|
|
33
|
-
upsertResource: (name: string, getter: (args:
|
|
33
|
+
upsertResource: (name: string, getter: (args: import("kozz-types").AskResourcePayload["request"]["data"]) => any) => void;
|
|
34
34
|
};
|
|
35
35
|
proxy: {
|
|
36
36
|
revoke: () => void;
|
|
37
37
|
};
|
|
38
38
|
ask: {
|
|
39
39
|
(askArgs: {
|
|
40
|
-
resource: Omit<
|
|
41
|
-
|
|
42
|
-
resource: string;
|
|
43
|
-
data: Record<string, any>;
|
|
44
|
-
}, "id">;
|
|
45
|
-
responder: {
|
|
46
|
-
id: string;
|
|
47
|
-
type: import("kozz-types").EntityType;
|
|
48
|
-
};
|
|
40
|
+
resource: Omit<import("kozz-types").AskResourcePayload["request"], "id">;
|
|
41
|
+
responder: import("kozz-types").AskResourcePayload["responder"];
|
|
49
42
|
}): Promise<import("kozz-types").ProvideResourcePayload>;
|
|
50
43
|
boundary(boundaryId: string, resourceName: string, requestArgs?: Record<string, any>): Promise<import("kozz-types").ProvideResourcePayload>;
|
|
51
44
|
handler(handlerId: string, resourceName: string, requestArgs?: Record<string, any>): Promise<import("kozz-types").ProvideResourcePayload>;
|
|
52
45
|
gateway(resourceName: string, requestArgs?: Record<string, any>): Promise<import("kozz-types").ProvideResourcePayload>;
|
|
53
46
|
};
|
|
47
|
+
socket: import("socket.io-client").Socket<import("@socket.io/component-emitter").DefaultEventsMap, import("@socket.io/component-emitter").DefaultEventsMap>;
|
|
54
48
|
};
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
import { Media } from 'kozz-types';
|
|
1
|
+
import { type Media } from 'kozz-types';
|
|
3
2
|
export type MimeType = 'video/mp4' | 'image/gif' | 'image' | 'video' | 'video/mpeg' | 'audio/webm';
|
|
4
3
|
export declare const loadMediaFromPath: (filePath: string, mimeType: MimeType, stickerTags?: string[]) => Promise<Media>;
|
|
5
4
|
export declare const createMediaFromBuffer: (buffer: Buffer, mimeType: MimeType, fileName?: string, stickerTags?: string[]) => Media;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { MessageReceivedByGateway } from 'kozz-types';
|
|
1
|
+
import type { MessageReceivedByGateway } from 'kozz-types';
|
|
2
2
|
import { Socket } from 'socket.io-client';
|
|
3
3
|
export declare const createReact: (socket: Socket, messagePayload: MessageReceivedByGateway) => (emote: string) => Socket<import("@socket.io/component-emitter").DefaultEventsMap, import("@socket.io/component-emitter").DefaultEventsMap>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Media, MessageReceivedByGateway, SendMessagePayload } from 'kozz-types';
|
|
1
|
+
import type { Media, MessageReceivedByGateway, SendMessagePayload } from 'kozz-types';
|
|
2
2
|
export declare const replyWithText: (messagePayload: MessageReceivedByGateway, string: string) => SendMessagePayload;
|
|
3
3
|
export declare const replyWithSticker: (messagePayload: MessageReceivedByGateway, media: Media) => SendMessagePayload;
|
|
4
4
|
export declare const replyWithMedia: (messagePayload: MessageReceivedByGateway, media: Media, caption?: string) => SendMessagePayload;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { Media, SendMessagePayload } from 'kozz-types';
|
|
1
|
+
import type { Media, SendMessagePayload } from 'kozz-types';
|
|
2
2
|
export declare const createSendMessagePayload: (handlerName: string, contactId: string, boundaryId: string, body: string, media?: Media) => SendMessagePayload;
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
1
|
import { Command, MessageReceivedByGateway, Source } from 'kozz-types';
|
|
3
2
|
import { Socket } from 'socket.io-client';
|
|
4
3
|
export type ProxiedMessageObject = ReturnType<typeof createProxiedMessageOject>;
|
|
@@ -6,15 +5,8 @@ export declare const createProxiedMessageOject: (socket: Socket, source: Source,
|
|
|
6
5
|
revoke: () => void;
|
|
7
6
|
ask: {
|
|
8
7
|
(askArgs: {
|
|
9
|
-
resource: Omit<
|
|
10
|
-
|
|
11
|
-
resource: string;
|
|
12
|
-
data: Record<string, any>;
|
|
13
|
-
}, "id">;
|
|
14
|
-
responder: {
|
|
15
|
-
id: string;
|
|
16
|
-
type: import("kozz-types").EntityType;
|
|
17
|
-
};
|
|
8
|
+
resource: Omit<import("kozz-types").AskResourcePayload["request"], "id">;
|
|
9
|
+
responder: import("kozz-types").AskResourcePayload["responder"];
|
|
18
10
|
}): Promise<import("kozz-types").ProvideResourcePayload>;
|
|
19
11
|
boundary(boundaryId: string, resourceName: string, requestArgs?: Record<string, any>): Promise<import("kozz-types").ProvideResourcePayload>;
|
|
20
12
|
handler(handlerId: string, resourceName: string, requestArgs?: Record<string, any>): Promise<import("kozz-types").ProvideResourcePayload>;
|
|
@@ -32,11 +24,11 @@ export declare const createProxiedMessageOject: (socket: Socket, source: Source,
|
|
|
32
24
|
withSticker: (media: import("kozz-types").Media, tags?: string[]) => void;
|
|
33
25
|
withTemplate: (templateName: string, templateData?: Record<string, any>) => void;
|
|
34
26
|
withMedia: {
|
|
35
|
-
(media: import("kozz-types").Media, caption?: string
|
|
36
|
-
fromPath(path: string, mimeType: import("../PayloadCreation/Media").MimeType, caption?: string
|
|
37
|
-
fromBuffer(buffer: Buffer, mimeType: import("../PayloadCreation/Media").MimeType, caption?: string
|
|
38
|
-
fromB64(b64: string, mimeType: import("../PayloadCreation/Media").MimeType, caption?: string
|
|
39
|
-
fromUrl(url: string, mimeType: import("../PayloadCreation/Media").MimeType, caption?: string
|
|
27
|
+
(media: import("kozz-types").Media, caption?: string): void;
|
|
28
|
+
fromPath(path: string, mimeType: import("../PayloadCreation/Media").MimeType, caption?: string): Promise<void>;
|
|
29
|
+
fromBuffer(buffer: Buffer, mimeType: import("../PayloadCreation/Media").MimeType, caption?: string, fileName?: string): void;
|
|
30
|
+
fromB64(b64: string, mimeType: import("../PayloadCreation/Media").MimeType, caption?: string, fileName?: string): void;
|
|
31
|
+
fromUrl(url: string, mimeType: import("../PayloadCreation/Media").MimeType, caption?: string): void;
|
|
40
32
|
};
|
|
41
33
|
};
|
|
42
34
|
};
|
|
@@ -9,8 +9,8 @@ type AskResourceArgs = {
|
|
|
9
9
|
};
|
|
10
10
|
export declare const createAskResource: (socket: Socket, args: RequestResourceArgs) => {
|
|
11
11
|
(askArgs: AskResourceArgs): Promise<import("kozz-types").ProvideResourcePayload>;
|
|
12
|
-
boundary(boundaryId: string, resourceName: string, requestArgs?: AskResourceArgs[
|
|
13
|
-
handler(handlerId: string, resourceName: string, requestArgs?: AskResourceArgs[
|
|
14
|
-
gateway(resourceName: string, requestArgs?: AskResourceArgs[
|
|
12
|
+
boundary(boundaryId: string, resourceName: string, requestArgs?: AskResourceArgs["resource"]["data"]): Promise<import("kozz-types").ProvideResourcePayload>;
|
|
13
|
+
handler(handlerId: string, resourceName: string, requestArgs?: AskResourceArgs["resource"]["data"]): Promise<import("kozz-types").ProvideResourcePayload>;
|
|
14
|
+
gateway(resourceName: string, requestArgs?: AskResourceArgs["resource"]["data"]): Promise<import("kozz-types").ProvideResourcePayload>;
|
|
15
15
|
};
|
|
16
16
|
export {};
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
1
|
import { MessageReceivedByGateway } from 'kozz-types';
|
|
3
2
|
import { Socket } from 'socket.io-client';
|
|
4
3
|
export declare const createReply: (socket: Socket, messagePayload: MessageReceivedByGateway, templatePath?: string) => {
|
|
@@ -6,10 +5,10 @@ export declare const createReply: (socket: Socket, messagePayload: MessageReceiv
|
|
|
6
5
|
withSticker: (media: import("kozz-types").Media, tags?: string[]) => void;
|
|
7
6
|
withTemplate: (templateName: string, templateData?: Record<string, any>) => void;
|
|
8
7
|
withMedia: {
|
|
9
|
-
(media: import("kozz-types").Media, caption?: string
|
|
10
|
-
fromPath(path: string, mimeType: import("../PayloadCreation/Media").MimeType, caption?: string
|
|
11
|
-
fromBuffer(buffer: Buffer, mimeType: import("../PayloadCreation/Media").MimeType, caption?: string
|
|
12
|
-
fromB64(b64: string, mimeType: import("../PayloadCreation/Media").MimeType, caption?: string
|
|
13
|
-
fromUrl(url: string, mimeType: import("../PayloadCreation/Media").MimeType, caption?: string
|
|
8
|
+
(media: import("kozz-types").Media, caption?: string): void;
|
|
9
|
+
fromPath(path: string, mimeType: import("../PayloadCreation/Media").MimeType, caption?: string): Promise<void>;
|
|
10
|
+
fromBuffer(buffer: Buffer, mimeType: import("../PayloadCreation/Media").MimeType, caption?: string, fileName?: string): void;
|
|
11
|
+
fromB64(b64: string, mimeType: import("../PayloadCreation/Media").MimeType, caption?: string, fileName?: string): void;
|
|
12
|
+
fromUrl(url: string, mimeType: import("../PayloadCreation/Media").MimeType, caption?: string): void;
|
|
14
13
|
};
|
|
15
14
|
};
|
package/dist/Message/index.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
1
|
import { Command, MessageReceivedByGateway } from 'kozz-types';
|
|
3
2
|
import { Socket } from 'socket.io-client';
|
|
4
3
|
export * from './FromTemplate';
|
|
@@ -6,15 +5,8 @@ export type MessageObj = ReturnType<typeof createMessageObject>;
|
|
|
6
5
|
export declare const createMessageObject: (socket: Socket, messagePayload: MessageReceivedByGateway, handlerId: string, templatePath?: string, command?: Command) => {
|
|
7
6
|
ask: {
|
|
8
7
|
(askArgs: {
|
|
9
|
-
resource: Omit<
|
|
10
|
-
|
|
11
|
-
resource: string;
|
|
12
|
-
data: Record<string, any>;
|
|
13
|
-
}, "id">;
|
|
14
|
-
responder: {
|
|
15
|
-
id: string;
|
|
16
|
-
type: import("kozz-types").EntityType;
|
|
17
|
-
};
|
|
8
|
+
resource: Omit<import("kozz-types").AskResourcePayload["request"], "id">;
|
|
9
|
+
responder: import("kozz-types").AskResourcePayload["responder"];
|
|
18
10
|
}): Promise<import("kozz-types").ProvideResourcePayload>;
|
|
19
11
|
boundary(boundaryId: string, resourceName: string, requestArgs?: Record<string, any>): Promise<import("kozz-types").ProvideResourcePayload>;
|
|
20
12
|
handler(handlerId: string, resourceName: string, requestArgs?: Record<string, any>): Promise<import("kozz-types").ProvideResourcePayload>;
|
|
@@ -32,11 +24,11 @@ export declare const createMessageObject: (socket: Socket, messagePayload: Messa
|
|
|
32
24
|
withSticker: (media: import("kozz-types").Media, tags?: string[]) => void;
|
|
33
25
|
withTemplate: (templateName: string, templateData?: Record<string, any>) => void;
|
|
34
26
|
withMedia: {
|
|
35
|
-
(media: import("kozz-types").Media, caption?: string
|
|
36
|
-
fromPath(path: string, mimeType: import("./PayloadCreation/Media").MimeType, caption?: string
|
|
37
|
-
fromBuffer(buffer: Buffer, mimeType: import("./PayloadCreation/Media").MimeType, caption?: string
|
|
38
|
-
fromB64(b64: string, mimeType: import("./PayloadCreation/Media").MimeType, caption?: string
|
|
39
|
-
fromUrl(url: string, mimeType: import("./PayloadCreation/Media").MimeType, caption?: string
|
|
27
|
+
(media: import("kozz-types").Media, caption?: string): void;
|
|
28
|
+
fromPath(path: string, mimeType: import("./PayloadCreation/Media").MimeType, caption?: string): Promise<void>;
|
|
29
|
+
fromBuffer(buffer: Buffer, mimeType: import("./PayloadCreation/Media").MimeType, caption?: string, fileName?: string): void;
|
|
30
|
+
fromB64(b64: string, mimeType: import("./PayloadCreation/Media").MimeType, caption?: string, fileName?: string): void;
|
|
31
|
+
fromUrl(url: string, mimeType: import("./PayloadCreation/Media").MimeType, caption?: string): void;
|
|
40
32
|
};
|
|
41
33
|
};
|
|
42
34
|
};
|
package/dist/debugIndex.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _GeneralModule = require("./Instance/GeneralModule");
|
|
4
|
-
var
|
|
4
|
+
var _ = require(".");
|
|
5
5
|
var _Schema = require("./Schema");
|
|
6
6
|
var _jsxRuntime = require("./jsx-runtime");
|
|
7
7
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
@@ -30,12 +30,12 @@ const ProductView = ({
|
|
|
30
30
|
product
|
|
31
31
|
}) => {
|
|
32
32
|
return (0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
|
|
33
|
-
children: [(0, _jsxRuntime.jsxs)(
|
|
34
|
-
children: [(0, _jsxRuntime.jsx)(
|
|
33
|
+
children: [(0, _jsxRuntime.jsxs)(_.Line, {
|
|
34
|
+
children: [(0, _jsxRuntime.jsx)(_.Bold, {
|
|
35
35
|
children: product.name
|
|
36
36
|
}), " - R$", product.price.toLocaleString('pt-BR')]
|
|
37
|
-
}), (0, _jsxRuntime.jsx)(
|
|
38
|
-
children: (0, _jsxRuntime.jsx)(
|
|
37
|
+
}), (0, _jsxRuntime.jsx)(_.Line, {
|
|
38
|
+
children: (0, _jsxRuntime.jsx)(_.Italic, {
|
|
39
39
|
children: product.description
|
|
40
40
|
})
|
|
41
41
|
})]
|
|
@@ -44,15 +44,15 @@ const ProductView = ({
|
|
|
44
44
|
const TestMessage = ({
|
|
45
45
|
name
|
|
46
46
|
}) => (0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
|
|
47
|
-
children: [(0, _jsxRuntime.jsx)(
|
|
47
|
+
children: [(0, _jsxRuntime.jsx)(_.Line, {
|
|
48
48
|
children: "Test"
|
|
49
|
-
}), (0, _jsxRuntime.jsxs)(
|
|
50
|
-
children: [(0, _jsxRuntime.jsx)(
|
|
49
|
+
}), (0, _jsxRuntime.jsxs)(_.Line, {
|
|
50
|
+
children: [(0, _jsxRuntime.jsx)(_.Bold, {
|
|
51
51
|
children: name
|
|
52
52
|
}), " is a great guy!"]
|
|
53
|
-
}), (0, _jsxRuntime.jsx)(
|
|
53
|
+
}), (0, _jsxRuntime.jsx)(_.ForEach, {
|
|
54
54
|
data: products,
|
|
55
|
-
render: product => (0, _jsxRuntime.jsx)(
|
|
55
|
+
render: product => (0, _jsxRuntime.jsx)(_.List, {
|
|
56
56
|
items: (0, _jsxRuntime.jsx)(ProductView, {
|
|
57
57
|
product: product
|
|
58
58
|
})
|
package/dist/index.d.ts
CHANGED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { type Component } from '.';
|
|
2
|
+
export declare const Bold: Component<{}>;
|
|
3
|
+
export declare const Code: Component<{}>;
|
|
4
|
+
export declare const Line: Component<{}>;
|
|
5
|
+
export declare const Monospace: Component<{}>;
|
|
6
|
+
export declare const Stroke: Component<{}>;
|
|
7
|
+
export declare const Italic: Component<{}>;
|
|
8
|
+
export declare const List: ({ items }: {
|
|
9
|
+
items: string | string[];
|
|
10
|
+
}) => string;
|
|
11
|
+
/**
|
|
12
|
+
* Conditionally renders it's children if the prop 'when' evaluates to true
|
|
13
|
+
* @param param0
|
|
14
|
+
* @returns
|
|
15
|
+
*/
|
|
16
|
+
export declare const Render: Component<{
|
|
17
|
+
when: boolean | (() => boolean);
|
|
18
|
+
}>;
|
|
19
|
+
type ForEachProps<TData> = {
|
|
20
|
+
data: Readonly<TData[]>;
|
|
21
|
+
render: (data: TData, index: number) => Component<any>;
|
|
22
|
+
};
|
|
23
|
+
/**
|
|
24
|
+
* Iterates over an array and renders a component for each item.
|
|
25
|
+
* @param props
|
|
26
|
+
* @returns
|
|
27
|
+
*/
|
|
28
|
+
export declare const ForEach: <TData extends any>(props: ForEachProps<TData>) => string[];
|
|
29
|
+
export {};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
export type Primitive = string | number;
|
|
2
|
+
export type Nullable = null | undefined | boolean;
|
|
3
|
+
export type Child = VNode<any> | Primitive | Nullable | Child[];
|
|
4
|
+
export type Component<P = {}> = (props: P & {
|
|
5
|
+
children?: Child;
|
|
6
|
+
}) => Child;
|
|
7
|
+
export type Type<P = any> = string | symbol | Component<P>;
|
|
8
|
+
export interface VNode<P = any> {
|
|
9
|
+
type: Type<P>;
|
|
10
|
+
props: (P & {
|
|
11
|
+
children?: Child;
|
|
12
|
+
}) | {
|
|
13
|
+
children?: Child;
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
export type IntrinsicRenderer<P = any> = (props: P, children: string) => string;
|
|
17
|
+
export type IntrinsicsMap = Record<string, IntrinsicRenderer<any>>;
|
|
18
|
+
export interface RenderOptions {
|
|
19
|
+
intrinsics?: IntrinsicsMap;
|
|
20
|
+
}
|
|
21
|
+
export declare const Fragment: unique symbol;
|
|
22
|
+
export declare function createElement<P>(type: Type<P>, props: (P & {
|
|
23
|
+
children?: Child;
|
|
24
|
+
}) | null, ...children: Child[]): VNode<P>;
|
|
25
|
+
export declare function jsx<P>(type: Type<P>, props: P | null, key?: string | number): string;
|
|
26
|
+
export declare const jsxs: typeof jsx;
|
|
27
|
+
export declare function jsxDEV<P>(type: Type<P>, props: P | null, key?: string | number, _isStaticChildren?: boolean, _source?: any, _self?: any): VNode<P>;
|
|
28
|
+
export * from './MessageTemplating';
|
package/dist/util/index.d.ts
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
import {
|
|
3
|
-
import { UseFn } from '../Instance/Common';
|
|
1
|
+
import { type Command } from 'kozz-types';
|
|
2
|
+
import { type UseFn } from '../Instance/Common';
|
|
4
3
|
export declare const runUse: (useArr: UseFn[], args: Command) => Command;
|
|
5
4
|
export declare function normalizeString(string: string): string;
|
|
6
5
|
export declare const randomId: () => string;
|
|
7
6
|
export declare const signPayload: <T extends Record<string, any>>(payload: T, signature?: string) => Promise<T & {
|
|
8
|
-
signature: Buffer;
|
|
7
|
+
signature: Buffer & void;
|
|
9
8
|
}> | (T & {
|
|
10
9
|
signature: string;
|
|
11
10
|
});
|
|
@@ -21,5 +20,5 @@ export declare const signInBrowser: <T extends Record<string, any>>(payload: T)
|
|
|
21
20
|
* @returns
|
|
22
21
|
*/
|
|
23
22
|
export declare const signInNodeEnvironment: <T extends Record<string, any>>(payload: T) => Promise<T & {
|
|
24
|
-
signature: Buffer;
|
|
23
|
+
signature: Buffer & void;
|
|
25
24
|
}>;
|
package/dist/util/index.js
CHANGED
|
@@ -48,7 +48,9 @@ const signInBrowser = payload => {
|
|
|
48
48
|
try {
|
|
49
49
|
// @ts-ignore
|
|
50
50
|
return fetch('./keys/privatekey.pem').then(privateKey => privateKey.text()).then(privateKey => {
|
|
51
|
-
const signature = _crypto.default.sign('sha256',
|
|
51
|
+
const signature = _crypto.default.sign('sha256',
|
|
52
|
+
//@ts-ignore
|
|
53
|
+
Buffer.from(JSON.stringify(payload, undefined, ' ')), {
|
|
52
54
|
key: privateKey,
|
|
53
55
|
padding: _crypto.default.constants.RSA_PKCS1_PSS_PADDING
|
|
54
56
|
});
|
|
@@ -74,7 +76,9 @@ const signInNodeEnvironment = async payload => {
|
|
|
74
76
|
} catch (e) {
|
|
75
77
|
throw 'Please generate a keypair using the script "scripts/generate_key_pair.sh" and copy the publickey to the "${project_root}/keys/privatekey.pem". Leve the key names as it is';
|
|
76
78
|
}
|
|
77
|
-
const signature = _crypto.default.sign('sha256',
|
|
79
|
+
const signature = _crypto.default.sign('sha256',
|
|
80
|
+
//@ts-ignore
|
|
81
|
+
Buffer.from(JSON.stringify(payload, undefined, ' ')), {
|
|
78
82
|
key: privateKey,
|
|
79
83
|
padding: _crypto.default.constants.RSA_PKCS1_PSS_PADDING
|
|
80
84
|
});
|
package/package.json
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "kozz-module-maker",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.4",
|
|
4
4
|
"description": "Library to create new module for the Kozz-Bot protocol",
|
|
5
5
|
"main": "./dist",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"scripts": {
|
|
8
8
|
"build": "babel ./src --out-dir ./dist --extensions .ts,.tsx --copy-files",
|
|
9
|
-
"dev": "
|
|
10
|
-
"
|
|
9
|
+
"dev": "npm run build -- --watch & nodemon --watch dist --exec 'npm run dist/debugIndex.js'",
|
|
10
|
+
"publish": "tsc && bun run build && npm publish"
|
|
11
11
|
},
|
|
12
12
|
"peerDependencies": {
|
|
13
13
|
"typescript": "^5.9.2"
|
package/tsconfig.json
CHANGED
|
@@ -7,12 +7,19 @@
|
|
|
7
7
|
"moduleDetection": "force",
|
|
8
8
|
"jsx": "preserve",
|
|
9
9
|
"allowJs": true,
|
|
10
|
+
"declaration": true,
|
|
11
|
+
|
|
12
|
+
"rootDir": "./src",
|
|
13
|
+
"baseUrl": ".",
|
|
14
|
+
"paths": {
|
|
15
|
+
"src/*": ["src/*"]
|
|
16
|
+
},
|
|
10
17
|
|
|
11
18
|
// Bundler mode
|
|
12
19
|
"moduleResolution": "bundler",
|
|
13
|
-
"verbatimModuleSyntax": true,
|
|
14
|
-
"noEmit": true,
|
|
20
|
+
// "verbatimModuleSyntax": true,
|
|
15
21
|
"outDir": "dist",
|
|
22
|
+
"emitDeclarationOnly": true,
|
|
16
23
|
|
|
17
24
|
// Best practices
|
|
18
25
|
"strict": true,
|
|
@@ -25,5 +32,6 @@
|
|
|
25
32
|
"noUnusedLocals": false,
|
|
26
33
|
"noUnusedParameters": false,
|
|
27
34
|
"noPropertyAccessFromIndexSignature": false
|
|
28
|
-
}
|
|
35
|
+
},
|
|
36
|
+
"exclude": ["./scripts/*", "./dist/*"]
|
|
29
37
|
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/InlineCommands/index.ts"],"names":[],"mappings":";;;AAAA;;;;GAIG;AACI,MAAM,cAAc,GAAG,CAC7B,WAAmB,EACnB,OAA4B,EAAE,EAC7B,EAAE;IACH,OAAO,IAAI,WAAW,IAAI,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,EAAE,CAAC;AAClD,CAAC,CAAC;AALW,QAAA,cAAc,kBAKzB;AAEF;;;GAGG;AACI,MAAM,SAAS,GAAG,CAAC,EAAU,EAAE,EAAE,CAAC,IAAA,sBAAc,EAAC,SAAS,EAAE,EAAE,EAAE,EAAE,CAAC,CAAC;AAA9D,QAAA,SAAS,aAAqD;AAE3E;;;;GAIG;AACI,MAAM,kBAAkB,GAAG,CAAC,EAAU,EAAE,EAAE,CAChD,IAAA,sBAAc,EAAC,kBAAkB,EAAE,EAAE,EAAE,EAAE,CAAC,CAAC;AAD/B,QAAA,kBAAkB,sBACa;AAErC,MAAM,WAAW,GAAG,CAAC,SAAmB,EAAE,EAAE,EAAE,CACpD,IAAA,sBAAc,EAAC,aAAa,EAAE;IAC7B,MAAM;CACN,CAAC,CAAC;AAHS,QAAA,WAAW,eAGpB"}
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
type BasicControllerInitParams = {
|
|
2
|
-
name: string;
|
|
3
|
-
address: string;
|
|
4
|
-
templatePath?: string;
|
|
5
|
-
signature?: string;
|
|
6
|
-
};
|
|
7
|
-
/**
|
|
8
|
-
* Creates a basic Handler Controller
|
|
9
|
-
* @param param0
|
|
10
|
-
* @returns
|
|
11
|
-
*/
|
|
12
|
-
export declare const createBasicController: ({ address, name, templatePath, signature, }: BasicControllerInitParams) => {
|
|
13
|
-
sendMessage: {
|
|
14
|
-
(contactId: string, boundaryId: string, body: string): void;
|
|
15
|
-
withMedia(contactId: string, boundaryId: string, caption: string, media: import("kozz-types").Media): void;
|
|
16
|
-
};
|
|
17
|
-
use: (useFn: UseFn) => any;
|
|
18
|
-
removeResource: (name: string) => void;
|
|
19
|
-
upsertResource: (name: string, getter: (args: Record<string, any>) => any) => void;
|
|
20
|
-
listenToBoundary: (boundaryId: string) => {
|
|
21
|
-
when: (eventName: string, callback: (payload: any) => any) => void;
|
|
22
|
-
};
|
|
23
|
-
ask: {
|
|
24
|
-
(askArgs: {
|
|
25
|
-
resource: Omit<{
|
|
26
|
-
id: `${string}/${number}`;
|
|
27
|
-
resource: string;
|
|
28
|
-
data: Record<string, any>;
|
|
29
|
-
}, "id">;
|
|
30
|
-
responder: {
|
|
31
|
-
id: string;
|
|
32
|
-
type: import("kozz-types").Entity;
|
|
33
|
-
};
|
|
34
|
-
}): Promise<import("kozz-types").ProvideResourcePayload>;
|
|
35
|
-
boundary(boundaryId: string, resourceName: string, requestArgs?: Record<string, any>): Promise<import("kozz-types").ProvideResourcePayload>;
|
|
36
|
-
handler(handlerId: string, resourceName: string, requestArgs?: Record<string, any>): Promise<import("kozz-types").ProvideResourcePayload>;
|
|
37
|
-
gateway(resourceName: string, requestArgs?: Record<string, any>): Promise<import("kozz-types").ProvideResourcePayload>;
|
|
38
|
-
};
|
|
39
|
-
};
|
|
40
|
-
export {};
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.createBasicController = void 0;
|
|
4
|
-
const Socket_1 = require("../../Socket");
|
|
5
|
-
const AskResource_1 = require("../../Socket/Events/Handle/AskResource");
|
|
6
|
-
const Common_1 = require("../Common/");
|
|
7
|
-
const AskResource_2 = require("../../Message/RoutineCreation/AskResource");
|
|
8
|
-
const SendMessage_1 = require("../../Message/RoutineCreation/SendMessage");
|
|
9
|
-
const ForwardEvent_1 = require("src/Socket/Events/Emit/ForwardEvent");
|
|
10
|
-
/**
|
|
11
|
-
* Creates a basic Handler Controller
|
|
12
|
-
* @param param0
|
|
13
|
-
* @returns
|
|
14
|
-
*/
|
|
15
|
-
const createBasicController = ({ address, name, templatePath, signature, }) => {
|
|
16
|
-
const { moduleUseFns, use } = (0, Common_1.createUseFns)(() => instance);
|
|
17
|
-
const { socket } = (0, Socket_1.connect)(address, moduleUseFns, templatePath || '', name, {}, [], signature);
|
|
18
|
-
// @ts-ignore
|
|
19
|
-
const { removeResource, resourceMap, upsertResource } = (0, Common_1.createResourceMap)();
|
|
20
|
-
(0, AskResource_1.onAskResource)(socket, resourceMap);
|
|
21
|
-
const ask = (0, AskResource_2.createAskResource)(socket, {
|
|
22
|
-
requester: {
|
|
23
|
-
id: name,
|
|
24
|
-
type: 'Handler',
|
|
25
|
-
},
|
|
26
|
-
});
|
|
27
|
-
/**
|
|
28
|
-
* Routine to send message to any given boundary
|
|
29
|
-
*/
|
|
30
|
-
const sendMessage = (0, SendMessage_1.sendMessageToContact)(socket, name);
|
|
31
|
-
const listenToBoundary = (0, ForwardEvent_1.listenBoundary)(socket, name);
|
|
32
|
-
const instance = {
|
|
33
|
-
sendMessage,
|
|
34
|
-
use,
|
|
35
|
-
removeResource,
|
|
36
|
-
upsertResource,
|
|
37
|
-
listenToBoundary,
|
|
38
|
-
ask,
|
|
39
|
-
};
|
|
40
|
-
return instance;
|
|
41
|
-
};
|
|
42
|
-
exports.createBasicController = createBasicController;
|
|
43
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/Instance/Basic/index.ts"],"names":[],"mappings":";;;AAAA,yCAAuC;AACvC,wEAAuE;AACvE,uCAA6D;AAC7D,2EAA8E;AAC9E,2EAAiF;AACjF,sEAAqE;AASrE;;;;GAIG;AACI,MAAM,qBAAqB,GAAG,CAAC,EACrC,OAAO,EACP,IAAI,EACJ,YAAY,EACZ,SAAS,GACkB,EAAE,EAAE;IAC/B,MAAM,EAAE,YAAY,EAAE,GAAG,EAAE,GAAG,IAAA,qBAAY,EAAC,GAAG,EAAE,CAAC,QAAQ,CAAC,CAAC;IAE3D,MAAM,EAAE,MAAM,EAAE,GAAG,IAAA,gBAAO,EACzB,OAAO,EACP,YAAY,EACZ,YAAY,IAAI,EAAE,EAClB,IAAI,EACJ,EAAE,EACF,EAAE,EACF,SAAS,CACT,CAAC;IACF,aAAa;IACb,MAAM,EAAE,cAAc,EAAE,WAAW,EAAE,cAAc,EAAE,GAAG,IAAA,0BAAiB,GAAE,CAAC;IAC5E,IAAA,2BAAa,EAAC,MAAM,EAAE,WAAW,CAAC,CAAC;IAEnC,MAAM,GAAG,GAAG,IAAA,+BAAiB,EAAC,MAAM,EAAE;QACrC,SAAS,EAAE;YACV,EAAE,EAAE,IAAI;YACR,IAAI,EAAE,SAAS;SACf;KACD,CAAC,CAAC;IAEH;;OAEG;IACH,MAAM,WAAW,GAAG,IAAA,kCAAoB,EAAC,MAAM,EAAE,IAAI,CAAC,CAAC;IAEvD,MAAM,gBAAgB,GAAG,IAAA,6BAAc,EAAC,MAAM,EAAE,IAAI,CAAC,CAAC;IAEtD,MAAM,QAAQ,GAAG;QAChB,WAAW;QACX,GAAG;QACH,cAAc;QACd,cAAc;QACd,gBAAgB;QAChB,GAAG;KACH,CAAC;IAEF,OAAO,QAAQ,CAAC;AACjB,CAAC,CAAC;AA7CW,QAAA,qBAAqB,yBA6ChC"}
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
type BasicControllerInitParams = {
|
|
2
|
-
name: string;
|
|
3
|
-
address: string;
|
|
4
|
-
templatePath?: string;
|
|
5
|
-
signature?: string;
|
|
6
|
-
};
|
|
7
|
-
/**
|
|
8
|
-
* Creates a basic Handler Controller
|
|
9
|
-
* @param param0
|
|
10
|
-
* @returns
|
|
11
|
-
*/
|
|
12
|
-
export declare const createBasicController: ({ address, name, templatePath, signature, }: BasicControllerInitParams) => {
|
|
13
|
-
sendMessage: {
|
|
14
|
-
(contactId: string, boundaryId: string, body: string): void;
|
|
15
|
-
withMedia(contactId: string, boundaryId: string, caption: string, media: import("kozz-types").Media): void;
|
|
16
|
-
};
|
|
17
|
-
use: (useFn: import("../Common/UseFns").UseFn) => any;
|
|
18
|
-
removeResource: (name: string) => void;
|
|
19
|
-
upsertResource: (name: string, getter: (args: Record<string, any>) => any) => void;
|
|
20
|
-
listenToBoundary: (boundaryId: string) => {
|
|
21
|
-
when: (eventName: string, callback: (payload: any) => any) => void;
|
|
22
|
-
};
|
|
23
|
-
ask: {
|
|
24
|
-
(askArgs: {
|
|
25
|
-
resource: Omit<{
|
|
26
|
-
id: `${string}/${number}`;
|
|
27
|
-
resource: string;
|
|
28
|
-
data: Record<string, any>;
|
|
29
|
-
}, "id">;
|
|
30
|
-
responder: {
|
|
31
|
-
id: string;
|
|
32
|
-
type: import("kozz-types").Entity;
|
|
33
|
-
};
|
|
34
|
-
}): Promise<import("kozz-types").ProvideResourcePayload>;
|
|
35
|
-
boundary(boundaryId: string, resourceName: string, requestArgs?: Record<string, any>): Promise<import("kozz-types").ProvideResourcePayload>;
|
|
36
|
-
handler(handlerId: string, resourceName: string, requestArgs?: Record<string, any>): Promise<import("kozz-types").ProvideResourcePayload>;
|
|
37
|
-
gateway(resourceName: string, requestArgs?: Record<string, any>): Promise<import("kozz-types").ProvideResourcePayload>;
|
|
38
|
-
};
|
|
39
|
-
};
|
|
40
|
-
export {};
|