kozz-module-maker 0.1.1 → 0.1.3

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.
Files changed (188) hide show
  1. package/dist/Instance/Basic/index.d.ts +40 -0
  2. package/dist/Instance/Basic/index.js +43 -0
  3. package/dist/Instance/Basic/index.js.map +1 -0
  4. package/dist/Instance/BasicController/index.d.ts +40 -0
  5. package/dist/Instance/BasicController/index.js +43 -0
  6. package/dist/Instance/BasicController/index.js.map +1 -0
  7. package/dist/Instance/CommandHandler/index.d.ts +20 -0
  8. package/dist/Instance/CommandHandler/index.js +26 -0
  9. package/dist/Instance/CommandHandler/index.js.map +1 -0
  10. package/dist/Instance/Common/ResourceMap/index.d.ts +12 -0
  11. package/dist/Instance/Common/ResourceMap/index.js +19 -0
  12. package/dist/Instance/Common/ResourceMap/index.js.map +1 -0
  13. package/dist/Instance/Common/UseFns/index.d.ts +10 -0
  14. package/dist/Instance/Common/UseFns/index.js +16 -0
  15. package/dist/Instance/Common/UseFns/index.js.map +1 -0
  16. package/dist/Instance/Common/index.js +10 -0
  17. package/dist/Instance/Common/index.js.map +1 -0
  18. package/dist/Instance/Common/onEvent/index.d.ts +8 -0
  19. package/dist/Instance/Common/onEvent/index.js +87 -0
  20. package/dist/Instance/Common/onEvent/index.js.map +1 -0
  21. package/dist/Instance/GeneralHandler/index.d.ts +19 -0
  22. package/dist/Instance/GeneralHandler/index.js +49 -0
  23. package/dist/Instance/GeneralHandler/index.js.map +1 -0
  24. package/dist/Instance/GeneralModule/index.d.ts +53 -0
  25. package/dist/Instance/GeneralModule/index.js +55 -0
  26. package/dist/Instance/GeneralModule/index.js.map +1 -0
  27. package/dist/Instance/Handler/index.d.ts +23 -0
  28. package/dist/Instance/Handler/index.js +26 -0
  29. package/dist/Instance/Handler/index.js.map +1 -0
  30. package/dist/Instance/Proxy/index.d.ts +22 -0
  31. package/dist/Instance/Proxy/index.js +36 -0
  32. package/dist/Instance/Proxy/index.js.map +1 -0
  33. package/dist/Instance/index.d.ts +14 -0
  34. package/dist/Instance/index.js +20 -0
  35. package/dist/Instance/index.js.map +1 -0
  36. package/dist/Message/FromTemplate/index.d.ts +33 -0
  37. package/dist/Message/FromTemplate/index.js +62 -0
  38. package/dist/Message/FromTemplate/index.js.map +1 -0
  39. package/dist/Message/PayloadCreation/Media.d.ts +7 -0
  40. package/dist/Message/PayloadCreation/Media.js +44 -0
  41. package/dist/Message/PayloadCreation/Media.js.map +1 -0
  42. package/dist/Message/PayloadCreation/React.d.ts +3 -0
  43. package/dist/Message/PayloadCreation/React.js +13 -0
  44. package/dist/Message/PayloadCreation/React.js.map +1 -0
  45. package/dist/Message/PayloadCreation/Reply.d.ts +5 -0
  46. package/dist/Message/PayloadCreation/Reply.js +47 -0
  47. package/dist/Message/PayloadCreation/Reply.js.map +1 -0
  48. package/dist/Message/PayloadCreation/ReplyWithSticker.d.ts +0 -0
  49. package/dist/Message/PayloadCreation/ReplyWithSticker.js +1 -0
  50. package/dist/Message/PayloadCreation/ReplyWithText.d.ts +2 -0
  51. package/dist/Message/PayloadCreation/ReplyWithText.js +15 -0
  52. package/dist/Message/PayloadCreation/index.js +18 -0
  53. package/dist/Message/PayloadCreation/index.js.map +1 -0
  54. package/dist/Message/PayloadCreation/sendMessage.d.ts +2 -0
  55. package/dist/Message/PayloadCreation/sendMessage.js +24 -0
  56. package/dist/Message/PayloadCreation/sendMessage.js.map +1 -0
  57. package/dist/Message/ProxiedMessage/index.d.ts +42 -0
  58. package/dist/Message/ProxiedMessage/index.js +15 -0
  59. package/dist/Message/ProxiedMessage/index.js.map +1 -0
  60. package/dist/Message/RoutineCreation/AskResource/AskResourceApi/index.d.ts +14 -0
  61. package/dist/Message/RoutineCreation/AskResource/AskResourceApi/index.js +28 -0
  62. package/dist/Message/RoutineCreation/AskResource/AskResourceApi/index.js.map +1 -0
  63. package/dist/Message/RoutineCreation/AskResource/index.d.ts +16 -0
  64. package/dist/Message/RoutineCreation/AskResource/index.js +60 -0
  65. package/dist/Message/RoutineCreation/AskResource/index.js.map +1 -0
  66. package/dist/Message/RoutineCreation/Reply/WithMedia.d.ts +11 -0
  67. package/dist/Message/RoutineCreation/Reply/WithMedia.js +34 -0
  68. package/dist/Message/RoutineCreation/Reply/WithMedia.js.map +1 -0
  69. package/dist/Message/RoutineCreation/Reply/WithSticke.d.ts +3 -0
  70. package/dist/Message/RoutineCreation/Reply/WithSticke.js +9 -0
  71. package/dist/Message/RoutineCreation/Reply/WithSticke.js.map +1 -0
  72. package/dist/Message/RoutineCreation/Reply/WithSticker.d.ts +3 -0
  73. package/dist/Message/RoutineCreation/Reply/WithSticker.js +9 -0
  74. package/dist/Message/RoutineCreation/Reply/WithSticker.js.map +1 -0
  75. package/dist/Message/RoutineCreation/Reply/WithTemplate.d.ts +3 -0
  76. package/dist/Message/RoutineCreation/Reply/WithTemplate.js +20 -0
  77. package/dist/Message/RoutineCreation/Reply/WithTemplate.js.map +1 -0
  78. package/dist/Message/RoutineCreation/Reply/index.js +10 -0
  79. package/dist/Message/RoutineCreation/Reply/index.js.map +1 -0
  80. package/dist/Message/RoutineCreation/SendMessage/index.d.ts +10 -0
  81. package/dist/Message/RoutineCreation/SendMessage/index.js +25 -0
  82. package/dist/Message/RoutineCreation/SendMessage/index.js.map +1 -0
  83. package/dist/Message/RoutineCreation/reply.d.ts +15 -0
  84. package/dist/Message/RoutineCreation/reply.js +18 -0
  85. package/dist/Message/RoutineCreation/reply.js.map +1 -0
  86. package/dist/Message/index.d.ts +42 -0
  87. package/dist/Message/index.js +46 -0
  88. package/dist/Message/index.js.map +1 -0
  89. package/dist/Message/kozz-md.parser/index.d.ts +41 -0
  90. package/dist/Message/kozz-md.parser/index.js +122 -0
  91. package/dist/Message/kozz-md.parser/index.js.map +1 -0
  92. package/dist/Message/zap-md.parser/index.d.ts +1 -0
  93. package/dist/Message/zap-md.parser/index.js +2 -0
  94. package/dist/Schema/index.d.ts +37 -0
  95. package/dist/Schema/index.js +21 -0
  96. package/dist/Schema/index.js.map +1 -0
  97. package/dist/Socket/Events/Command.d.ts +3 -0
  98. package/dist/Socket/Events/Command.js +19 -0
  99. package/dist/Socket/Events/Command.js.map +1 -0
  100. package/dist/Socket/Events/Emit/ForwardEvent.d.ts +6 -0
  101. package/dist/Socket/Events/Emit/ForwardEvent.js +21 -0
  102. package/dist/Socket/Events/Emit/ForwardEvent.js.map +1 -0
  103. package/dist/Socket/Events/Emit/Introduction.d.ts +10 -0
  104. package/dist/Socket/Events/Emit/Introduction.js +21 -0
  105. package/dist/Socket/Events/Emit/Introduction.js.map +1 -0
  106. package/dist/Socket/Events/Emit/ProxyRequest.d.ts +0 -0
  107. package/dist/Socket/Events/Emit/ProxyRequest.js +2 -0
  108. package/dist/Socket/Events/Emit/ProxyRequest.js.map +1 -0
  109. package/dist/Socket/Events/Emit/RequestProxy.d.ts +18 -0
  110. package/dist/Socket/Events/Emit/RequestProxy.js +22 -0
  111. package/dist/Socket/Events/Emit/RequestProxy.js.map +1 -0
  112. package/dist/Socket/Events/Emit/RevokeProxy.d.ts +8 -0
  113. package/dist/Socket/Events/Emit/RevokeProxy.js +16 -0
  114. package/dist/Socket/Events/Emit/RevokeProxy.js.map +1 -0
  115. package/dist/Socket/Events/Handle/AskResource.d.ts +8 -0
  116. package/dist/Socket/Events/Handle/AskResource.js +36 -0
  117. package/dist/Socket/Events/Handle/AskResource.js.map +1 -0
  118. package/dist/Socket/Events/Handle/Command.d.ts +14 -0
  119. package/dist/Socket/Events/Handle/Command.js +48 -0
  120. package/dist/Socket/Events/Handle/Command.js.map +1 -0
  121. package/dist/Socket/Events/Handle/ProxiedMessage.d.ts +10 -0
  122. package/dist/Socket/Events/Handle/ProxiedMessage.js +18 -0
  123. package/dist/Socket/Events/Handle/ProxiedMessage.js.map +1 -0
  124. package/dist/Socket/Events/Introduction.d.ts +3 -0
  125. package/dist/Socket/Events/Introduction.js +15 -0
  126. package/dist/Socket/Events/Introduction.js.map +1 -0
  127. package/dist/Socket/Events/ProxiedMessage.d.ts +2 -0
  128. package/dist/Socket/Events/ProxiedMessage.js +10 -0
  129. package/dist/Socket/Events/ProxiedMessage.js.map +1 -0
  130. package/dist/Socket/Messages/Command.d.ts +2 -0
  131. package/dist/Socket/Messages/Command.js +6 -0
  132. package/dist/Socket/Messages/Command.js.map +1 -0
  133. package/dist/Socket/Messages/Introduction.d.ts +3 -0
  134. package/dist/Socket/Messages/Introduction.js +15 -0
  135. package/dist/Socket/Messages/Introduction.js.map +1 -0
  136. package/dist/Socket/index.d.ts +6 -0
  137. package/dist/Socket/index.js +19 -0
  138. package/dist/Socket/index.js.map +1 -0
  139. package/dist/Validator/index.d.ts +16 -0
  140. package/dist/Validator/index.js +55 -0
  141. package/dist/Validator/index.js.map +1 -0
  142. package/dist/debugIndex.d.ts +1 -0
  143. package/dist/debugIndex.js +21 -0
  144. package/dist/debugIndex.js.map +1 -0
  145. package/dist/index.js +19 -0
  146. package/dist/index.js.map +1 -0
  147. package/dist/util/index.d.ts +25 -0
  148. package/dist/util/index.js +81 -0
  149. package/dist/util/index.js.map +1 -0
  150. package/dist/util.d.ts +8 -0
  151. package/dist/util.js +36 -0
  152. package/dist/util.js.map +1 -0
  153. package/package.json +1 -1
  154. package/src/Instance/Common/ResourceMap/index.ts +0 -26
  155. package/src/Instance/Common/UseFns/index.ts +0 -22
  156. package/src/Instance/Common/onEvent/index.ts +0 -105
  157. package/src/Instance/GeneralModule/index.ts +0 -98
  158. package/src/Message/FromTemplate/index.ts +0 -74
  159. package/src/Message/PayloadCreation/Media.ts +0 -62
  160. package/src/Message/PayloadCreation/React.ts +0 -16
  161. package/src/Message/PayloadCreation/Reply.ts +0 -63
  162. package/src/Message/PayloadCreation/sendMessage.ts +0 -27
  163. package/src/Message/ProxiedMessage/index.ts +0 -27
  164. package/src/Message/RoutineCreation/AskResource/AskResourceApi/index.ts +0 -43
  165. package/src/Message/RoutineCreation/AskResource/index.ts +0 -85
  166. package/src/Message/RoutineCreation/Reply/WithMedia.ts +0 -63
  167. package/src/Message/RoutineCreation/Reply/WithSticker.ts +0 -9
  168. package/src/Message/RoutineCreation/Reply/WithTemplate.ts +0 -28
  169. package/src/Message/RoutineCreation/SendMessage/index.ts +0 -64
  170. package/src/Message/RoutineCreation/reply.ts +0 -23
  171. package/src/Message/index.ts +0 -44
  172. package/src/Message/kozz-md.parser/index.ts +0 -138
  173. package/src/Schema/index.ts +0 -102
  174. package/src/Socket/Events/Emit/ForwardEvent.ts +0 -22
  175. package/src/Socket/Events/Emit/Introduction.ts +0 -28
  176. package/src/Socket/Events/Emit/RequestProxy.ts +0 -38
  177. package/src/Socket/Events/Emit/RevokeProxy.ts +0 -15
  178. package/src/Socket/Events/Handle/AskResource.ts +0 -37
  179. package/src/Socket/Events/Handle/Command.ts +0 -68
  180. package/src/Socket/Events/Handle/ProxiedMessage.ts +0 -28
  181. package/src/Socket/index.ts +0 -40
  182. package/src/Validator/index.ts +0 -81
  183. package/src/messages.kozz.md +0 -52
  184. package/src/util/index.ts +0 -89
  185. /package/{src/Instance/Common/index.ts → dist/Instance/Common/index.d.ts} +0 -0
  186. /package/{src/Message/PayloadCreation/index.ts → dist/Message/PayloadCreation/index.d.ts} +0 -0
  187. /package/{src/Message/RoutineCreation/Reply/index.ts → dist/Message/RoutineCreation/Reply/index.d.ts} +0 -0
  188. /package/{src/index.ts → dist/index.d.ts} +0 -0
@@ -0,0 +1,60 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createAskResource = void 0;
4
+ const AskResourceApi_1 = require("./AskResourceApi");
5
+ const createAskResource = (socket, args) => {
6
+ const ask = async (askArgs) => {
7
+ const response = await (0, AskResourceApi_1.ask)(socket, {
8
+ request: askArgs.resource,
9
+ responder: askArgs.responder,
10
+ requester: args.requester,
11
+ timestamp: new Date().getTime(),
12
+ });
13
+ return response;
14
+ };
15
+ ask.boundary = (boundaryId, resourceName, requestArgs = {}) => {
16
+ return (0, AskResourceApi_1.ask)(socket, {
17
+ request: {
18
+ resource: resourceName,
19
+ data: requestArgs,
20
+ },
21
+ requester: args.requester,
22
+ timestamp: new Date().getTime(),
23
+ responder: {
24
+ id: boundaryId,
25
+ type: 'Boundary',
26
+ },
27
+ });
28
+ };
29
+ ask.handler = (handlerId, resourceName, requestArgs = {}) => {
30
+ return (0, AskResourceApi_1.ask)(socket, {
31
+ request: {
32
+ resource: resourceName,
33
+ data: requestArgs,
34
+ },
35
+ requester: args.requester,
36
+ timestamp: new Date().getTime(),
37
+ responder: {
38
+ id: handlerId,
39
+ type: 'Handler',
40
+ },
41
+ });
42
+ };
43
+ ask.gateway = (resourceName, requestArgs = {}) => {
44
+ return (0, AskResourceApi_1.ask)(socket, {
45
+ request: {
46
+ resource: resourceName,
47
+ data: requestArgs,
48
+ },
49
+ requester: args.requester,
50
+ timestamp: new Date().getTime(),
51
+ responder: {
52
+ id: 'Gateway',
53
+ type: 'Gateway',
54
+ },
55
+ });
56
+ };
57
+ return ask;
58
+ };
59
+ exports.createAskResource = createAskResource;
60
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/Message/RoutineCreation/AskResource/index.ts"],"names":[],"mappings":";;;AAEA,qDAAwD;AAWjD,MAAM,iBAAiB,GAAG,CAChC,MAAc,EACd,IAAyB,EACxB,EAAE;IACH,MAAM,GAAG,GAAG,KAAK,EAAE,OAAwB,EAAE,EAAE;QAC9C,MAAM,QAAQ,GAAG,MAAM,IAAA,oBAAa,EAAC,MAAM,EAAE;YAC5C,OAAO,EAAE,OAAO,CAAC,QAAQ;YACzB,SAAS,EAAE,OAAO,CAAC,SAAS;YAC5B,SAAS,EAAE,IAAI,CAAC,SAAS;YACzB,SAAS,EAAE,IAAI,IAAI,EAAE,CAAC,OAAO,EAAE;SAC/B,CAAC,CAAC;QACH,OAAO,QAAQ,CAAC;IACjB,CAAC,CAAC;IAEF,GAAG,CAAC,QAAQ,GAAG,CACd,UAAkB,EAClB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11 @@
1
+ /// <reference types="node" />
2
+ import { Media, MessageReceivedByGateway } from 'kozz-types/dist';
3
+ import { Socket } from 'socket.io-client';
4
+ import { MimeType } from '../../PayloadCreation/Media';
5
+ export declare const withMedia: (socket: Socket, messagePayload: MessageReceivedByGateway) => {
6
+ (media: Media, caption?: string): void;
7
+ fromPath(path: string, mimeType: MimeType, caption?: string): Promise<void>;
8
+ fromBuffer(buffer: Buffer, mimeType: MimeType, caption?: string, fileName?: string): void;
9
+ fromB64(b64: string, mimeType: MimeType, caption?: string, fileName?: string): void;
10
+ fromUrl(url: string, mimeType: MimeType, caption?: string): void;
11
+ };
@@ -0,0 +1,34 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.withMedia = void 0;
4
+ const PayloadCreation_1 = require("../../PayloadCreation");
5
+ const Media_1 = require("../../PayloadCreation/Media");
6
+ const withMedia = (socket, messagePayload) => {
7
+ /**
8
+ * Replies with a media
9
+ * @param {Media} media
10
+ * @param {string} caption
11
+ */
12
+ const replyMedia = (media, caption) => {
13
+ socket.emit('reply_with_media', (0, PayloadCreation_1.replyWithMedia)(messagePayload, media, caption));
14
+ };
15
+ replyMedia.fromPath = async (path, mimeType, caption) => {
16
+ const media = await (0, Media_1.loadMediaFromPath)(path, mimeType);
17
+ replyMedia(media, caption);
18
+ };
19
+ replyMedia.fromBuffer = (buffer, mimeType, caption, fileName) => {
20
+ const media = (0, Media_1.createMediaFromBuffer)(buffer, mimeType, fileName);
21
+ replyMedia(media, caption);
22
+ };
23
+ replyMedia.fromB64 = (b64, mimeType, caption, fileName) => {
24
+ const media = (0, Media_1.createMediaFromB64)(b64, mimeType, fileName);
25
+ replyMedia(media, caption);
26
+ };
27
+ replyMedia.fromUrl = (url, mimeType, caption) => {
28
+ const media = (0, Media_1.createMediaFromUrl)(url, mimeType);
29
+ replyMedia(media, caption);
30
+ };
31
+ return replyMedia;
32
+ };
33
+ exports.withMedia = withMedia;
34
+ //# sourceMappingURL=With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1E,MAAM,KAAK,GAAG,IAAA,0BAAkB,EAAC,GAAG,EAAE,QAAQ,CAAC,CAAC;QAChD,UAAU,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;IAC5B,CAAC,CAAC;IAEF,OAAO,UAAU,CAAC;AACnB,CAAC,CAAC;AAnDW,QAAA,SAAS,aAmDpB"}
@@ -0,0 +1,3 @@
1
+ import { Media, Command } from 'kozz-types/dist';
2
+ import { Socket } from 'socket.io-client';
3
+ export declare const withSticker: (socket: Socket, command: Command) => (media: Media) => void;
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.withSticker = void 0;
4
+ const PayloadCreation_1 = require("../../../Message/PayloadCreation");
5
+ const withSticker = (socket, command) => (media) => {
6
+ socket.emit('reply_with_sticker', (0, PayloadCreation_1.replyWithSticker)(command, media));
7
+ };
8
+ exports.withSticker = withSticker;
9
+ //# sourceMappingURL=WithSticke.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"WithSticke.js","sourceRoot":"","sources":["../../../../src/Message/RoutineCreation/Reply/WithSticke.ts"],"names":[],"mappings":";;;AAEA,sEAAoE;AAE7D,MAAM,WAAW,GACvB,CAAC,MAAc,EAAE,OAAgB,EAAE,EAAE,CAAC,CAAC,KAAY,EAAE,EAAE;IACtD,MAAM,CAAC,IAAI,CAAC,oBAAoB,EAAE,IAAA,kCAAgB,EAAC,OAAO,EAAE,KAAK,CAAC,CAAC,CAAC;AACrE,CAAC,CAAC;AAHU,QAAA,WAAW,eAGrB"}
@@ -0,0 +1,3 @@
1
+ import { Media, MessageReceivedByGateway } from 'kozz-types/dist';
2
+ import { Socket } from 'socket.io-client';
3
+ export declare const withSticker: (socket: Socket, messagePayload: MessageReceivedByGateway) => (media: Media) => void;
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.withSticker = void 0;
4
+ const PayloadCreation_1 = require("../../PayloadCreation");
5
+ const withSticker = (socket, messagePayload) => (media) => {
6
+ socket.emit('reply_with_sticker', (0, PayloadCreation_1.replyWithSticker)(messagePayload, media));
7
+ };
8
+ exports.withSticker = withSticker;
9
+ //# sourceMappingURL=WithSticker.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"WithSticker.js","sourceRoot":"","sources":["../../../../src/Message/RoutineCreation/Reply/WithSticker.ts"],"names":[],"mappings":";;;AAEA,2DAAyD;AAElD,MAAM,WAAW,GACvB,CAAC,MAAc,EAAE,cAAwC,EAAE,EAAE,CAC7D,CAAC,KAAY,EAAE,EAAE;IAChB,MAAM,CAAC,IAAI,CAAC,oBAAoB,EAAE,IAAA,kCAAgB,EAAC,cAAc,EAAE,KAAK,CAAC,CAAC,CAAC;AAC5E,CAAC,CAAC;AAJU,QAAA,WAAW,eAIrB"}
@@ -0,0 +1,3 @@
1
+ import { MessageReceivedByGateway } from 'kozz-types/dist';
2
+ import { Socket } from 'socket.io-client';
3
+ export declare const withTemplate: (socket: Socket, messagePayload: MessageReceivedByGateway, templatePath?: string) => (templateName: string, templateData?: Record<string, any>) => void;
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.withTemplate = void 0;
4
+ const FromTemplate_1 = require("../../FromTemplate");
5
+ const PayloadCreation_1 = require("../../PayloadCreation");
6
+ const withTemplate = (socket, messagePayload, templatePath) => (templateName, templateData = {}) => {
7
+ if (!templatePath) {
8
+ throw 'Trying to reply with template but no template path was provided';
9
+ }
10
+ (0, FromTemplate_1.loadTemplates)(templatePath)
11
+ .getTextFromTemplate(templateName, templateData)
12
+ .then(textResponse => {
13
+ if (!textResponse) {
14
+ throw `Error while trying to reply from template ${templateName}, could not find it's template in ${templatePath}`;
15
+ }
16
+ socket.emit('reply_with_text', (0, PayloadCreation_1.replyWithText)(messagePayload, textResponse));
17
+ });
18
+ };
19
+ exports.withTemplate = withTemplate;
20
+ //# sourceMappingURL=WithTemplate.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"WithTemplate.js","sourceRoot":"","sources":["../../../../src/Message/RoutineCreation/Reply/WithTemplate.ts"],"names":[],"mappings":";;;AAEA,qDAAmD;AACnD,2DAAsD;AAE/C,MAAM,YAAY,GACxB,CACC,MAAc,EACd,cAAwC,EACxC,YAAqB,EACpB,EAAE,CACJ,CAAC,YAAoB,EAAE,eAAoC,EAAE,EAAE,EAAE;IAChE,IAAI,CAAC,YAAY,EAAE;QAClB,MAAM,iEAAiE,CAAC;KACxE;IAED,IAAA,4BAAa,EAAC,YAAY,CAAC;SACzB,mBAAmB,CAAC,YAAY,EAAE,YAAY,CAAC;SAC/C,IAAI,CAAC,YAAY,CAAC,EAAE;QACpB,IAAI,CAAC,YAAY,EAAE;YAClB,MAAM,6CAA6C,YAAY,qCAAqC,YAAY,EAAE,CAAC;SACnH;QACD,MAAM,CAAC,IAAI,CACV,iBAAiB,EACjB,IAAA,+BAAa,EAAC,cAAc,EAAE,YAAY,CAAC,CAC3C,CAAC;IACH,CAAC,CAAC,CAAC;AACL,CAAC,CAAC;AAtBU,QAAA,YAAY,gBAsBtB"}
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.withMedia = exports.withSticker = exports.withTemplate = void 0;
4
+ var WithTemplate_1 = require("./WithTemplate");
5
+ Object.defineProperty(exports, "withTemplate", { enumerable: true, get: function () { return WithTemplate_1.withTemplate; } });
6
+ var WithSticker_1 = require("./WithSticker");
7
+ Object.defineProperty(exports, "withSticker", { enumerable: true, get: function () { return WithSticker_1.withSticker; } });
8
+ var WithMedia_1 = require("./WithMedia");
9
+ Object.defineProperty(exports, "withMedia", { enumerable: true, get: function () { return WithMedia_1.withMedia; } });
10
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/Message/RoutineCreation/Reply/index.ts"],"names":[],"mappings":";;;AAAA,+CAA8C;AAArC,4GAAA,YAAY,OAAA;AACrB,6CAA4C;AAAnC,0GAAA,WAAW,OAAA;AACpB,yCAAwC;AAA/B,sGAAA,SAAS,OAAA"}
@@ -0,0 +1,10 @@
1
+ import { Media } from 'kozz-types';
2
+ import { Socket } from 'socket.io-client';
3
+ export declare const sendMessageToContactOnRequesterObject: (socket: Socket, handlerName: string, boundaryId: string) => {
4
+ (contactId: string, body: string): void;
5
+ withMedia(contactId: string, caption: string, media: Media): void;
6
+ };
7
+ export declare const sendMessageToContact: (socket: Socket, handlerName: string) => {
8
+ (contactId: string, boundaryId: string, body: string): void;
9
+ withMedia(contactId: string, boundaryId: string, caption: string, media: Media): void;
10
+ };
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.sendMessageToContact = exports.sendMessageToContactOnRequesterObject = void 0;
4
+ const sendMessage_1 = require("../../PayloadCreation/sendMessage");
5
+ const sendMessageToContactOnRequesterObject = (socket, handlerName, boundaryId) => {
6
+ const sendMessage = (contactId, body) => {
7
+ socket.emit('send_message', (0, sendMessage_1.createSendMessagePayload)(handlerName, contactId, boundaryId, body));
8
+ };
9
+ sendMessage.withMedia = (contactId, caption, media) => {
10
+ socket.emit('send_message', (0, sendMessage_1.createSendMessagePayload)(handlerName, contactId, boundaryId, caption, media));
11
+ };
12
+ return sendMessage;
13
+ };
14
+ exports.sendMessageToContactOnRequesterObject = sendMessageToContactOnRequesterObject;
15
+ const sendMessageToContact = (socket, handlerName) => {
16
+ const sendMessage = (contactId, boundaryId, body) => {
17
+ socket.emit('send_message', (0, sendMessage_1.createSendMessagePayload)(handlerName, contactId, boundaryId, body));
18
+ };
19
+ sendMessage.withMedia = (contactId, boundaryId, caption, media) => {
20
+ socket.emit('send_message', (0, sendMessage_1.createSendMessagePayload)(handlerName, contactId, boundaryId, caption, media));
21
+ };
22
+ return sendMessage;
23
+ };
24
+ exports.sendMessageToContact = sendMessageToContact;
25
+ //# sourceMappingURL=index.js.map
@@ -0,0 +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,CAAC,IAAI,CACV,cAAc,EACd,IAAA,sCAAwB,EAAC,WAAW,EAAE,SAAS,EAAE,UAAU,EAAE,IAAI,CAAC,CAClE,CAAC;IACH,CAAC,CAAC;IAEF,WAAW,CAAC,SAAS,GAAG,CACvB,SAAiB,EACjB,OAAe,EACf,KAAY,EACX,EAAE;QACH,MAAM,CAAC,IAAI,CACV,cAAc,EACd,IAAA,sCAAwB,EACvB,WAAW,EACX,SAAS,EACT,UAAU,EACV,OAAO,EACP,KAAK,CACL,CACD,CAAC;IACH,CAAC,CAAC;IAEF,OAAO,WAAW,CAAC;AACpB,CAAC,CAAC;AA9BW,QAAA,qCAAqC,yCA8BhD;AAEK,MAAM,oBAAoB,GAAG,CAAC,MAAc,EAAE,WAAmB,EAAE,EAAE;IAC3E,MAAM,WAAW,GAAG,CAAC,SAAiB,EAAE,UAAkB,EAAE,IAAY,EAAE,EAAE;QAC3E,MAAM,CAAC,IAAI,CACV,cAAc,EACd,IAAA,sCAAwB,EAAC,WAAW,EAAE,SAAS,EAAE,UAAU,EAAE,IAAI,CAAC,CAClE,CAAC;IACH,CAAC,CAAC;IAEF,WAAW,CAAC,SAAS,GAAG,CACvB,SAAiB,EACjB,UAAkB,EAClB,OAAe,EACf,KAAY,EACX,EAAE;QACH,MAAM,CAAC,IAAI,CACV,cAAc,EACd,IAAA,sCAAwB,EACvB,WAAW,EACX,SAAS,EACT,UAAU,EACV,OAAO,EACP,KAAK,CACL,CACD,CAAC;IACH,CAAC,CAAC;IAEF,OAAO,WAAW,CAAC;AACpB,CAAC,CAAC;AA3BW,QAAA,oBAAoB,wBA2B/B"}
@@ -0,0 +1,15 @@
1
+ /// <reference types="node" />
2
+ import { MessageReceivedByGateway } from 'kozz-types';
3
+ import { Socket } from 'socket.io-client';
4
+ export declare const createReply: (socket: Socket, messagePayload: MessageReceivedByGateway, templatePath?: string) => {
5
+ (text: string): void;
6
+ withSticker: (media: import("kozz-types").Media) => void;
7
+ withTemplate: (templateName: string, templateData?: Record<string, any>) => void;
8
+ withMedia: {
9
+ (media: import("kozz-types").Media, caption?: string | undefined): void;
10
+ fromPath(path: string, mimeType: import("../PayloadCreation/Media").MimeType, caption?: string | undefined): Promise<void>;
11
+ fromBuffer(buffer: Buffer, mimeType: import("../PayloadCreation/Media").MimeType, caption?: string | undefined, fileName?: string | undefined): void;
12
+ fromB64(b64: string, mimeType: import("../PayloadCreation/Media").MimeType, caption?: string | undefined, fileName?: string | undefined): void;
13
+ fromUrl(url: string, mimeType: import("../PayloadCreation/Media").MimeType, caption?: string | undefined): void;
14
+ };
15
+ };
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createReply = void 0;
4
+ const PayloadCreation_1 = require("../PayloadCreation");
5
+ const WithMedia_1 = require("./Reply/WithMedia");
6
+ const WithSticker_1 = require("./Reply/WithSticker");
7
+ const WithTemplate_1 = require("./Reply/WithTemplate");
8
+ const createReply = (socket, messagePayload, templatePath) => {
9
+ const reply = (text) => {
10
+ socket.emit('reply_with_text', (0, PayloadCreation_1.replyWithText)(messagePayload, text));
11
+ };
12
+ reply.withSticker = (0, WithSticker_1.withSticker)(socket, messagePayload);
13
+ reply.withTemplate = (0, WithTemplate_1.withTemplate)(socket, messagePayload, templatePath);
14
+ reply.withMedia = (0, WithMedia_1.withMedia)(socket, messagePayload);
15
+ return reply;
16
+ };
17
+ exports.createReply = createReply;
18
+ //# sourceMappingURL=reply.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"reply.js","sourceRoot":"","sources":["../../../src/Message/RoutineCreation/reply.ts"],"names":[],"mappings":";;;AAEA,wDAAmD;AAEnD,iDAA8C;AAC9C,qDAAkD;AAClD,uDAAoD;AAE7C,MAAM,WAAW,GAAG,CAC1B,MAAc,EACd,cAAwC,EACxC,YAAqB,EACpB,EAAE;IACH,MAAM,KAAK,GAAG,CAAC,IAAY,EAAE,EAAE;QAC9B,MAAM,CAAC,IAAI,CAAC,iBAAiB,EAAE,IAAA,+BAAa,EAAC,cAAc,EAAE,IAAI,CAAC,CAAC,CAAC;IACrE,CAAC,CAAC;IAEF,KAAK,CAAC,WAAW,GAAG,IAAA,yBAAW,EAAC,MAAM,EAAE,cAAc,CAAC,CAAC;IACxD,KAAK,CAAC,YAAY,GAAG,IAAA,2BAAY,EAAC,MAAM,EAAE,cAAc,EAAE,YAAY,CAAC,CAAC;IACxE,KAAK,CAAC,SAAS,GAAG,IAAA,qBAAS,EAAC,MAAM,EAAE,cAAc,CAAC,CAAC;IAEpD,OAAO,KAAK,CAAC;AACd,CAAC,CAAC;AAdW,QAAA,WAAW,eActB"}
@@ -0,0 +1,42 @@
1
+ /// <reference types="node" />
2
+ import { Command, MessageReceivedByGateway } from 'kozz-types';
3
+ import { Socket } from 'socket.io-client';
4
+ export * from './FromTemplate';
5
+ export type MessageObj = ReturnType<typeof createMessageObject>;
6
+ export declare const createMessageObject: (socket: Socket, messagePayload: MessageReceivedByGateway, handlerId: string, templatePath?: string, command?: Command) => {
7
+ ask: {
8
+ (askArgs: {
9
+ resource: Omit<{
10
+ id: `${string}/${number}`;
11
+ resource: string;
12
+ data: Record<string, any>;
13
+ }, "id">;
14
+ responder: {
15
+ id: string;
16
+ type: import("kozz-types").Entity;
17
+ };
18
+ }): Promise<import("kozz-types").ProvideResourcePayload>;
19
+ boundary(boundaryId: string, resourceName: string, requestArgs?: Record<string, any>): Promise<import("kozz-types").ProvideResourcePayload>;
20
+ handler(handlerId: string, resourceName: string, requestArgs?: Record<string, any>): Promise<import("kozz-types").ProvideResourcePayload>;
21
+ gateway(resourceName: string, requestArgs?: Record<string, any>): Promise<import("kozz-types").ProvideResourcePayload>;
22
+ };
23
+ sendMessage: {
24
+ (contactId: string, body: string): void;
25
+ withMedia(contactId: string, caption: string, media: import("kozz-types").Media): void;
26
+ };
27
+ react: (emote: string) => Socket<import("@socket.io/component-emitter").DefaultEventsMap, import("@socket.io/component-emitter").DefaultEventsMap>;
28
+ rawCommand: Command | undefined;
29
+ message: MessageReceivedByGateway;
30
+ reply: {
31
+ (text: string): void;
32
+ withSticker: (media: import("kozz-types").Media) => void;
33
+ withTemplate: (templateName: string, templateData?: Record<string, any>) => void;
34
+ withMedia: {
35
+ (media: import("kozz-types").Media, caption?: string | undefined): void;
36
+ fromPath(path: string, mimeType: import("./PayloadCreation/Media").MimeType, caption?: string | undefined): Promise<void>;
37
+ fromBuffer(buffer: Buffer, mimeType: import("./PayloadCreation/Media").MimeType, caption?: string | undefined, fileName?: string | undefined): void;
38
+ fromB64(b64: string, mimeType: import("./PayloadCreation/Media").MimeType, caption?: string | undefined, fileName?: string | undefined): void;
39
+ fromUrl(url: string, mimeType: import("./PayloadCreation/Media").MimeType, caption?: string | undefined): void;
40
+ };
41
+ };
42
+ };
@@ -0,0 +1,46 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ exports.createMessageObject = void 0;
18
+ const reply_1 = require("./RoutineCreation/reply");
19
+ const AskResource_1 = require("./RoutineCreation/AskResource");
20
+ const SendMessage_1 = require("./RoutineCreation/SendMessage");
21
+ const React_1 = require("./PayloadCreation/React");
22
+ __exportStar(require("./FromTemplate"), exports);
23
+ const createMessageObject = (socket, messagePayload, handlerId, templatePath, command) => {
24
+ /**
25
+ * Replies the requester of the command.
26
+ */
27
+ const reply = (0, reply_1.createReply)(socket, messagePayload, templatePath);
28
+ const sendMessage = (0, SendMessage_1.sendMessageToContactOnRequesterObject)(socket, handlerId, messagePayload.from);
29
+ const ask = (0, AskResource_1.createAskResource)(socket, {
30
+ requester: {
31
+ id: handlerId,
32
+ type: 'Handler',
33
+ },
34
+ });
35
+ const react = (0, React_1.createReact)(socket, messagePayload);
36
+ return {
37
+ ask,
38
+ sendMessage,
39
+ react,
40
+ rawCommand: command,
41
+ message: messagePayload,
42
+ reply,
43
+ };
44
+ };
45
+ exports.createMessageObject = createMessageObject;
46
+ //# sourceMappingURL=index.js.map
@@ -0,0 +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,IAAI,CACnB,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"}
@@ -0,0 +1,41 @@
1
+ import * as A from 'arcsecond';
2
+ type TemplateData = {
3
+ [key: string]: unknown;
4
+ };
5
+ declare const parseDocument: (documentInString: string, data: TemplateData) => A.Ok<{
6
+ messageName: string;
7
+ messageBody: {
8
+ line: ({
9
+ readonly style: "paragraph";
10
+ readonly text: string;
11
+ } | {
12
+ readonly style: "italic";
13
+ readonly text: string;
14
+ } | {
15
+ readonly style: "stroke";
16
+ readonly text: string;
17
+ } | {
18
+ readonly style: "bold";
19
+ readonly text: string;
20
+ } | {
21
+ readonly style: "boldAndItalic";
22
+ readonly text: string;
23
+ } | {
24
+ readonly style: "code";
25
+ readonly text: string;
26
+ } | {
27
+ text: string;
28
+ style: "template";
29
+ } | {
30
+ readonly style: "normal";
31
+ readonly text: string;
32
+ } | {
33
+ readonly style: "listItem";
34
+ readonly text: string;
35
+ } | {
36
+ readonly style: "lineBreak";
37
+ readonly text: "";
38
+ })[];
39
+ }[];
40
+ }[], any>;
41
+ export default parseDocument;
@@ -0,0 +1,122 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ Object.defineProperty(exports, "__esModule", { value: true });
26
+ const A = __importStar(require("arcsecond"));
27
+ // _________________
28
+ // Utility functions
29
+ // -----------------
30
+ const anything = A.regex(/^.*/);
31
+ const exceptChars = (chars) => new RegExp(`^[^${chars}\n]+`);
32
+ const betweenStrings = (stringLeft, stringRight, identifier) => A.sequenceOf([
33
+ A.str(stringLeft),
34
+ A.regex(exceptChars(stringRight)),
35
+ A.str(stringRight),
36
+ ]).map(x => ({
37
+ style: identifier,
38
+ text: x[1],
39
+ }));
40
+ let injectableData = {};
41
+ // _________________
42
+ // Parser itself ...
43
+ // -----------------
44
+ const paragraph = A.sequenceOf([A.str('#'), A.whitespace, anything]).map(x => ({
45
+ style: 'paragraph',
46
+ text: x[2],
47
+ }));
48
+ const italic = betweenStrings('_', '_', 'italic');
49
+ const stroke = betweenStrings('~', '~', 'stroke');
50
+ const bold = betweenStrings('**', '**', 'bold');
51
+ const boldAndItalic = betweenStrings('**_', '_**', 'boldAndItalic');
52
+ const code = betweenStrings('`', '`', 'code');
53
+ const template = betweenStrings('{{', '}}', 'template').map(x => ({
54
+ ...x,
55
+ text: `${injectableData[x.text]}`,
56
+ }));
57
+ const normalText = A.regex(exceptChars('`~_*{>')).map(x => ({
58
+ style: 'normal',
59
+ text: x,
60
+ }));
61
+ const listItem = A.sequenceOf([A.str('-'), A.whitespace, anything]).map(x => ({
62
+ style: 'listItem',
63
+ text: x[2],
64
+ }));
65
+ const lineBreak = A.str('<br>').map(() => ({
66
+ style: 'lineBreak',
67
+ text: '',
68
+ }));
69
+ const textLine = A.sequenceOf([
70
+ A.many(A.whitespace),
71
+ A.many1(A.choice([
72
+ paragraph,
73
+ stroke,
74
+ listItem,
75
+ boldAndItalic,
76
+ bold,
77
+ italic,
78
+ code,
79
+ template,
80
+ lineBreak,
81
+ normalText,
82
+ ])),
83
+ A.many(A.str('\n')),
84
+ ]).map(x => ({
85
+ line: x[1],
86
+ }));
87
+ const messageDeclaration = A.sequenceOf([
88
+ A.str('>'),
89
+ A.whitespace,
90
+ A.str('@'),
91
+ anything,
92
+ ]).map(x => x[3]);
93
+ const messageEnd = A.sequenceOf([
94
+ A.str('>'),
95
+ A.whitespace,
96
+ A.str('---'),
97
+ A.many(A.str('-')),
98
+ A.many(A.str('\n')),
99
+ ]);
100
+ const message = A.sequenceOf([
101
+ A.many(A.str('\n')),
102
+ messageDeclaration,
103
+ A.many1(textLine),
104
+ A.many(A.str('\n')),
105
+ messageEnd,
106
+ ]).map(x => ({
107
+ messageName: x[1],
108
+ messageBody: x[2],
109
+ }));
110
+ const document = A.many(message);
111
+ const parseDocument = (documentInString, data) => {
112
+ injectableData = data;
113
+ const result = document.run(documentInString);
114
+ if (result.isError) {
115
+ throw result.error;
116
+ }
117
+ else {
118
+ return result;
119
+ }
120
+ };
121
+ exports.default = parseDocument;
122
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/Message/kozz-md.parser/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA,6CAA+B;AAE/B,oBAAoB;AACpB,oBAAoB;AACpB,oBAAoB;AAEpB,MAAM,QAAQ,GAAG,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;AAEhC,MAAM,WAAW,GAAG,CAAC,KAAa,EAAE,EAAE,CAAC,IAAI,MAAM,CAAC,MAAM,KAAK,MAAM,CAAC,CAAC;AAEr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QAAQ,CAAC,GAAG,CAAC,gBAAgB,CAAC,CAAC;IAC9C,IAAI,MAAM,CAAC,OAAO,EAAE;QACnB,MAAM,MAAM,CAAC,KAAK,CAAC;KACnB;SAAM;QACN,OAAO,MAAM,CAAC;KACd;AACF,CAAC,CAAC;AAEF,kBAAe,aAAa,CAAC"}
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,37 @@
1
+ import { MessageObj } from '../Message';
2
+ export type PrimaryTypeString = 'string' | 'number' | 'boolean';
3
+ export type ArrayTypeString = `${PrimaryTypeString}[]` | `${PrimaryTypeString}[]?`;
4
+ export type OptionalTypeString = `${ArrayTypeString}?` | `${PrimaryTypeString}?`;
5
+ export type TypeString = PrimaryTypeString | ArrayTypeString | OptionalTypeString;
6
+ export type StringTypeVariants = 'string' | 'string[]' | 'string[]?' | 'string?';
7
+ export type NumberTypeVariants = 'number' | 'number[]' | 'number[]?' | 'number?';
8
+ export type BooleanTypeVariants = 'boolean' | 'boolean[]' | 'boolean[]?' | 'boolean?';
9
+ type ToPrimary<T extends TypeString> = T extends StringTypeVariants ? string : T extends NumberTypeVariants ? number : T extends BooleanTypeVariants ? boolean : never;
10
+ type ToArray<T extends ArrayTypeString> = T extends ArrayTypeString ? ToPrimary<T>[] : ToPrimary<T>;
11
+ type ToOptional<T extends OptionalTypeString> = T extends ArrayTypeString ? ToArray<T> | undefined : T extends OptionalTypeString ? ToPrimary<T> | undefined : T extends PrimaryTypeString ? ToPrimary<T> : never;
12
+ type TypeFromString<T extends TypeString> = T extends OptionalTypeString ? ToOptional<T> : T extends ArrayTypeString ? ToArray<T> : T extends PrimaryTypeString ? ToPrimary<T> : never;
13
+ export type MethodCreator = <const T extends {
14
+ [key: string]: TypeString;
15
+ }, const Name extends string>(name: Name, callback: (requester: MessageObj, args: {
16
+ [key in keyof T]: TypeFromString<T[key]>;
17
+ }) => any, args?: T) => MethodMap<Name, T>;
18
+ /**
19
+ * Creates a command that can be inserted in any command Handler
20
+ * @param name
21
+ * @param callback
22
+ * @param args
23
+ * @returns
24
+ */
25
+ export declare const createMethod: MethodCreator;
26
+ export type Method<T extends {
27
+ [key: string]: TypeString;
28
+ }> = {
29
+ readonly args: T;
30
+ readonly func: (message: MessageObj, args: any) => any;
31
+ };
32
+ export type MethodMap<Name extends string, T extends {
33
+ [key: string]: TypeString;
34
+ }> = {
35
+ [key in `${Name}`]: Method<T>;
36
+ };
37
+ export {};
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createMethod = void 0;
4
+ /**
5
+ * Creates a command that can be inserted in any command Handler
6
+ * @param name
7
+ * @param callback
8
+ * @param args
9
+ * @returns
10
+ */
11
+ //@ts-ignore
12
+ const createMethod = (name, callback, args = {}) => {
13
+ return {
14
+ [name]: {
15
+ args,
16
+ func: callback,
17
+ },
18
+ };
19
+ };
20
+ exports.createMethod = createMethod;
21
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/Schema/index.ts"],"names":[],"mappings":";;;AA0EA;;;;;;GAMG;AACH,YAAY;AACL,MAAM,YAAY,GAAkB,CAAC,IAAI,EAAE,QAAQ,EAAE,IAAI,GAAG,EAAE,EAAE,EAAE;IACxE,OAAO;QACN,CAAC,IAAI,CAAC,EAAE;YACP,IAAI;YACJ,IAAI,EAAE,QAAQ;SACL;KACV,CAAC;AACH,CAAC,CAAC;AAPW,QAAA,YAAY,gBAOvB"}
@@ -0,0 +1,3 @@
1
+ import { Socket } from 'socket.io-client';
2
+ import { Method, UseFn } from '../..';
3
+ export declare const onCommand: <T extends Record<string, Method<Record<string, any>>>>(socket: Socket, methods: T, moduleUseFns: UseFn[], templatePath: string) => void;