kozz-module-maker 0.2.3 → 0.2.5

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 (125) hide show
  1. package/bun.lock +617 -0
  2. package/dist/InlineCommands/index.d.ts +37 -1
  3. package/dist/InlineCommands/index.js +71 -7
  4. package/dist/Instance/Common/ResourceMap/index.d.ts +1 -1
  5. package/dist/Instance/Common/UseFns/index.d.ts +1 -1
  6. package/dist/Instance/Common/index.d.ts +1 -1
  7. package/dist/Instance/GeneralModule/index.d.ts +7 -13
  8. package/dist/Message/PayloadCreation/Media.d.ts +1 -2
  9. package/dist/Message/PayloadCreation/React.d.ts +1 -1
  10. package/dist/Message/PayloadCreation/Reply.d.ts +1 -1
  11. package/dist/Message/PayloadCreation/sendMessage.d.ts +1 -1
  12. package/dist/Message/ProxiedMessage/index.d.ts +7 -15
  13. package/dist/Message/RoutineCreation/AskResource/index.d.ts +3 -3
  14. package/dist/Message/RoutineCreation/Reply/WithMedia.d.ts +0 -1
  15. package/dist/Message/RoutineCreation/reply.d.ts +5 -6
  16. package/dist/Message/index.d.ts +7 -15
  17. package/dist/index.d.ts +1 -1
  18. package/dist/jsx-runtime/MessageTemplating.d.ts +32 -0
  19. package/dist/jsx-runtime/MessageTemplating.js +18 -9
  20. package/dist/jsx-runtime/index.d.ts +28 -0
  21. package/dist/util/index.d.ts +4 -5
  22. package/package.json +2 -2
  23. package/tsconfig.json +10 -2
  24. package/dist/InlineCommands/index.js.map +0 -1
  25. package/dist/Instance/Basic/index.d.ts +0 -40
  26. package/dist/Instance/Basic/index.js +0 -43
  27. package/dist/Instance/Basic/index.js.map +0 -1
  28. package/dist/Instance/BasicController/index.d.ts +0 -40
  29. package/dist/Instance/BasicController/index.js +0 -43
  30. package/dist/Instance/BasicController/index.js.map +0 -1
  31. package/dist/Instance/CommandHandler/index.d.ts +0 -20
  32. package/dist/Instance/CommandHandler/index.js +0 -26
  33. package/dist/Instance/CommandHandler/index.js.map +0 -1
  34. package/dist/Instance/Common/ResourceMap/index.js.map +0 -1
  35. package/dist/Instance/Common/UseFns/index.js.map +0 -1
  36. package/dist/Instance/Common/index.js.map +0 -1
  37. package/dist/Instance/Common/onEvent/index.js.map +0 -1
  38. package/dist/Instance/GeneralHandler/index.d.ts +0 -19
  39. package/dist/Instance/GeneralHandler/index.js +0 -49
  40. package/dist/Instance/GeneralHandler/index.js.map +0 -1
  41. package/dist/Instance/GeneralModule/index.js.map +0 -1
  42. package/dist/Instance/Handler/index.d.ts +0 -23
  43. package/dist/Instance/Handler/index.js +0 -26
  44. package/dist/Instance/Handler/index.js.map +0 -1
  45. package/dist/Instance/Proxy/index.d.ts +0 -22
  46. package/dist/Instance/Proxy/index.js +0 -36
  47. package/dist/Instance/Proxy/index.js.map +0 -1
  48. package/dist/Instance/index.d.ts +0 -14
  49. package/dist/Instance/index.js +0 -20
  50. package/dist/Instance/index.js.map +0 -1
  51. package/dist/Message/FromTemplate/index.js.map +0 -1
  52. package/dist/Message/PayloadCreation/Media.js.map +0 -1
  53. package/dist/Message/PayloadCreation/React.js.map +0 -1
  54. package/dist/Message/PayloadCreation/Reply.js.map +0 -1
  55. package/dist/Message/PayloadCreation/ReplyWithSticker.d.ts +0 -0
  56. package/dist/Message/PayloadCreation/ReplyWithSticker.js +0 -1
  57. package/dist/Message/PayloadCreation/ReplyWithText.d.ts +0 -2
  58. package/dist/Message/PayloadCreation/ReplyWithText.js +0 -15
  59. package/dist/Message/PayloadCreation/deleteMessage.js.map +0 -1
  60. package/dist/Message/PayloadCreation/index.js.map +0 -1
  61. package/dist/Message/PayloadCreation/sendMessage.js.map +0 -1
  62. package/dist/Message/ProxiedMessage/index.js.map +0 -1
  63. package/dist/Message/RoutineCreation/AskResource/AskResourceApi/index.js.map +0 -1
  64. package/dist/Message/RoutineCreation/AskResource/index.js.map +0 -1
  65. package/dist/Message/RoutineCreation/DeleteMessage/index.js.map +0 -1
  66. package/dist/Message/RoutineCreation/Reply/WithMedia.js.map +0 -1
  67. package/dist/Message/RoutineCreation/Reply/WithSticke.d.ts +0 -3
  68. package/dist/Message/RoutineCreation/Reply/WithSticke.js +0 -9
  69. package/dist/Message/RoutineCreation/Reply/WithSticke.js.map +0 -1
  70. package/dist/Message/RoutineCreation/Reply/WithSticker.js.map +0 -1
  71. package/dist/Message/RoutineCreation/Reply/WithTemplate.js.map +0 -1
  72. package/dist/Message/RoutineCreation/Reply/index.js.map +0 -1
  73. package/dist/Message/RoutineCreation/SendMessage/index.js.map +0 -1
  74. package/dist/Message/RoutineCreation/reply.js.map +0 -1
  75. package/dist/Message/index.js.map +0 -1
  76. package/dist/Message/kozz-md.parser/index.js.map +0 -1
  77. package/dist/Message/zap-md.parser/index.d.ts +0 -1
  78. package/dist/Message/zap-md.parser/index.js +0 -2
  79. package/dist/MessageTemplate/h.d.ts +0 -3
  80. package/dist/MessageTemplate/h.js +0 -24
  81. package/dist/MessageTemplate/h.js.map +0 -1
  82. package/dist/MessageTemplate/htm.d.ts +0 -1
  83. package/dist/MessageTemplate/htm.js +0 -10
  84. package/dist/MessageTemplate/htm.js.map +0 -1
  85. package/dist/MessageTemplate/renderer.d.ts +0 -13
  86. package/dist/MessageTemplate/renderer.js +0 -62
  87. package/dist/MessageTemplate/renderer.js.map +0 -1
  88. package/dist/MessageTemplate/types.d.ts +0 -12
  89. package/dist/MessageTemplate/types.js +0 -5
  90. package/dist/MessageTemplate/types.js.map +0 -1
  91. package/dist/Schema/index.js.map +0 -1
  92. package/dist/Socket/Events/Command.d.ts +0 -3
  93. package/dist/Socket/Events/Command.js +0 -19
  94. package/dist/Socket/Events/Command.js.map +0 -1
  95. package/dist/Socket/Events/Emit/ForwardEvent.js.map +0 -1
  96. package/dist/Socket/Events/Emit/Introduction.js.map +0 -1
  97. package/dist/Socket/Events/Emit/ProxyRequest.d.ts +0 -0
  98. package/dist/Socket/Events/Emit/ProxyRequest.js +0 -2
  99. package/dist/Socket/Events/Emit/ProxyRequest.js.map +0 -1
  100. package/dist/Socket/Events/Emit/RequestProxy.js.map +0 -1
  101. package/dist/Socket/Events/Emit/RevokeProxy.js.map +0 -1
  102. package/dist/Socket/Events/Handle/AskResource.js.map +0 -1
  103. package/dist/Socket/Events/Handle/Command.js.map +0 -1
  104. package/dist/Socket/Events/Handle/ProxiedMessage.js.map +0 -1
  105. package/dist/Socket/Events/Introduction.d.ts +0 -3
  106. package/dist/Socket/Events/Introduction.js +0 -15
  107. package/dist/Socket/Events/Introduction.js.map +0 -1
  108. package/dist/Socket/Events/ProxiedMessage.d.ts +0 -2
  109. package/dist/Socket/Events/ProxiedMessage.js +0 -10
  110. package/dist/Socket/Events/ProxiedMessage.js.map +0 -1
  111. package/dist/Socket/Messages/Command.d.ts +0 -2
  112. package/dist/Socket/Messages/Command.js +0 -6
  113. package/dist/Socket/Messages/Command.js.map +0 -1
  114. package/dist/Socket/Messages/Introduction.d.ts +0 -3
  115. package/dist/Socket/Messages/Introduction.js +0 -15
  116. package/dist/Socket/Messages/Introduction.js.map +0 -1
  117. package/dist/Socket/index.js.map +0 -1
  118. package/dist/StateMachine/index.js.map +0 -1
  119. package/dist/Validator/index.js.map +0 -1
  120. package/dist/debugIndex.js.map +0 -1
  121. package/dist/index.js.map +0 -1
  122. package/dist/util/index.js.map +0 -1
  123. package/dist/util.d.ts +0 -8
  124. package/dist/util.js +0 -36
  125. package/dist/util.js.map +0 -1
@@ -3,7 +3,7 @@
3
3
  * @param commandName
4
4
  * @param data
5
5
  */
6
- export declare const generalCommand: (commandName: string, data?: Record<string, any>) => string;
6
+ export declare const inlineCommand: (commandName: string, data?: Record<string, any>) => string;
7
7
  /**
8
8
  * Tags someone in the message. The tag will be visible for everyone
9
9
  * @param id
@@ -15,4 +15,40 @@ export declare const tagMember: (id: string) => string;
15
15
  * @returns
16
16
  */
17
17
  export declare const invisibleTagMember: (id: string) => string;
18
+ /**
19
+ * Invisibly tag everyone
20
+ * @param except
21
+ * @returns
22
+ */
18
23
  export declare const tagEveryone: (except?: string[]) => string;
24
+ /**
25
+ * Formats text as bold.
26
+ * @param text The text to be formatted as bold
27
+ */
28
+ export declare const bold: (text: string) => string;
29
+ /**
30
+ * Formats text as inline code.
31
+ * @param text The text to be formatted as code
32
+ */
33
+ export declare const code: (text: string) => string;
34
+ /**
35
+ * Formats text as monospace.
36
+ * @param text The text to be formatted as monospace
37
+ */
38
+ export declare const monospace: (text: string) => string;
39
+ /**
40
+ * Formats text with stroke effect.
41
+ * @param text The text to be formatted with stroke
42
+ */
43
+ export declare const stroke: (text: string) => string;
44
+ /**
45
+ * Formats text as italic.
46
+ * @param text The text to be formatted as italic
47
+ */
48
+ export declare const italic: (text: string) => string;
49
+ /**
50
+ * Creates a list item.
51
+ * @param text The content of the list item
52
+ */
53
+ export declare const listItem: (text: string) => string;
54
+ export declare const paragraph: (text: string) => string;
@@ -3,13 +3,13 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.tagMember = exports.tagEveryone = exports.invisibleTagMember = exports.generalCommand = void 0;
6
+ exports.tagMember = exports.tagEveryone = exports.stroke = exports.paragraph = exports.monospace = exports.listItem = exports.italic = exports.invisibleTagMember = exports.inlineCommand = exports.code = exports.bold = void 0;
7
7
  /**
8
8
  * Creates an inline command with unespecified name and payload data.
9
9
  * @param commandName
10
10
  * @param data
11
11
  */
12
- const generalCommand = (commandName, data = {}) => {
12
+ const inlineCommand = (commandName, data = {}) => {
13
13
  return `%${commandName}:${JSON.stringify(data)}`;
14
14
  };
15
15
 
@@ -17,8 +17,8 @@ const generalCommand = (commandName, data = {}) => {
17
17
  * Tags someone in the message. The tag will be visible for everyone
18
18
  * @param id
19
19
  */
20
- exports.generalCommand = generalCommand;
21
- const tagMember = id => generalCommand('mention', {
20
+ exports.inlineCommand = inlineCommand;
21
+ const tagMember = id => inlineCommand('mention', {
22
22
  id
23
23
  });
24
24
 
@@ -28,11 +28,75 @@ const tagMember = id => generalCommand('mention', {
28
28
  * @returns
29
29
  */
30
30
  exports.tagMember = tagMember;
31
- const invisibleTagMember = id => generalCommand('invisiblemention', {
31
+ const invisibleTagMember = id => inlineCommand('invisiblemention', {
32
32
  id
33
33
  });
34
+
35
+ /**
36
+ * Invisibly tag everyone
37
+ * @param except
38
+ * @returns
39
+ */
34
40
  exports.invisibleTagMember = invisibleTagMember;
35
- const tagEveryone = (except = []) => generalCommand('tageveryone', {
41
+ const tagEveryone = (except = []) => inlineCommand('tageveryone', {
36
42
  except
37
43
  });
38
- exports.tagEveryone = tagEveryone;
44
+
45
+ /**
46
+ * Formats text as bold.
47
+ * @param text The text to be formatted as bold
48
+ */
49
+ exports.tagEveryone = tagEveryone;
50
+ const bold = text => inlineCommand('bold', {
51
+ text
52
+ });
53
+
54
+ /**
55
+ * Formats text as inline code.
56
+ * @param text The text to be formatted as code
57
+ */
58
+ exports.bold = bold;
59
+ const code = text => inlineCommand('code', {
60
+ text
61
+ });
62
+
63
+ /**
64
+ * Formats text as monospace.
65
+ * @param text The text to be formatted as monospace
66
+ */
67
+ exports.code = code;
68
+ const monospace = text => inlineCommand('monospace', {
69
+ text
70
+ });
71
+
72
+ /**
73
+ * Formats text with stroke effect.
74
+ * @param text The text to be formatted with stroke
75
+ */
76
+ exports.monospace = monospace;
77
+ const stroke = text => inlineCommand('stroke', {
78
+ text
79
+ });
80
+
81
+ /**
82
+ * Formats text as italic.
83
+ * @param text The text to be formatted as italic
84
+ */
85
+ exports.stroke = stroke;
86
+ const italic = text => inlineCommand('italic', {
87
+ text
88
+ });
89
+
90
+ /**
91
+ * Creates a list item.
92
+ * @param text The content of the list item
93
+ */
94
+ exports.italic = italic;
95
+ const listItem = text => inlineCommand('listItem', {
96
+ text
97
+ });
98
+ exports.listItem = listItem;
99
+ const paragraph = text => inlineCommand('paragraph', {
100
+ text
101
+ });
102
+ exports.paragraph = paragraph;
@@ -1,4 +1,4 @@
1
- import { AskResourcePayload } from 'kozz-types';
1
+ import { type AskResourcePayload } from 'kozz-types';
2
2
  type ResourceName = string;
3
3
  type ResourceGetter = (args: AskResourcePayload['request']['data']) => any;
4
4
  export type ResourceMap = {
@@ -1,4 +1,4 @@
1
- import { Command } from 'kozz-types';
1
+ import { type Command } from 'kozz-types';
2
2
  type HandlerOrProxy = any;
3
3
  type HandleOrProxyGetter = () => HandlerOrProxy;
4
4
  export type UseFn = (args: Command) => Command;
@@ -1,3 +1,3 @@
1
1
  export { createResourceMap } from './ResourceMap';
2
- export { UseFn, createUseFns } from './UseFns';
2
+ export { type UseFn, createUseFns } from './UseFns';
3
3
  export { onEvent } from './onEvent';
@@ -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: Record<string, any>) => any) => void;
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
- id: `${string}/${number}`;
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
- /// <reference types="node" />
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
- id: `${string}/${number}`;
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 | 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;
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['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>;
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 { Media, MessageReceivedByGateway } from 'kozz-types/dist';
3
2
  import { Socket } from 'socket.io-client';
4
3
  import { MimeType } from '../../PayloadCreation/Media';
@@ -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 | 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;
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
  };
@@ -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
- id: `${string}/${number}`;
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 | 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;
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/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
1
  export * from './Instance/GeneralModule';
2
2
  export * from './Schema';
3
3
  export * from './StateMachine';
4
- export * from './MessageTemplate/renderer';
4
+ export * from './jsx-runtime';
@@ -0,0 +1,32 @@
1
+ import { type Component } from '.';
2
+ export declare const createTemplatingComponent: (command: (text: string) => string) => Component<{}>;
3
+ export declare const Bold: Component<{}>;
4
+ export declare const Code: Component<{}>;
5
+ export declare const Monospace: Component<{}>;
6
+ export declare const Stroke: Component<{}>;
7
+ export declare const Italic: Component<{}>;
8
+ export declare const ListItem: Component<{}>;
9
+ export declare const Paragraph: Component<{}>;
10
+ export declare const Line: Component<{}>;
11
+ export declare const List: ({ items }: {
12
+ items: string | string[];
13
+ }) => string;
14
+ /**
15
+ * Conditionally renders it's children if the prop 'when' evaluates to true
16
+ * @param param0
17
+ * @returns
18
+ */
19
+ export declare const Render: Component<{
20
+ when: boolean | (() => boolean);
21
+ }>;
22
+ type ForEachProps<TData> = {
23
+ data: Readonly<TData[]>;
24
+ render: (data: TData, index: number) => Component<any>;
25
+ };
26
+ /**
27
+ * Iterates over an array and renders a component for each item.
28
+ * @param props
29
+ * @returns
30
+ */
31
+ export declare const ForEach: <TData extends any>(props: ForEachProps<TData>) => string[];
32
+ export {};
@@ -3,18 +3,27 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.Stroke = exports.Render = exports.Monospace = exports.List = exports.Line = exports.Italic = exports.ForEach = exports.Code = exports.Bold = void 0;
7
- const createTemplatingComponent = markup => ({
6
+ exports.createTemplatingComponent = exports.Stroke = exports.Render = exports.Paragraph = exports.Monospace = exports.ListItem = exports.List = exports.Line = exports.Italic = exports.ForEach = exports.Code = exports.Bold = void 0;
7
+ var _InlineCommands = require("src/InlineCommands");
8
+ const createTemplatingComponent = command => ({
8
9
  children
9
10
  }) => {
10
- return typeof children === 'string' ? `${markup}${children}${markup}` : Array.isArray(children) ? `${markup}${children.join('')}${markup}` : children?.toString();
11
+ return typeof children === 'string' ? `${command(children)}` : Array.isArray(children) ? `${command(children.join(''))}` : children?.toString();
11
12
  };
12
- const Bold = exports.Bold = createTemplatingComponent('*');
13
- const Code = exports.Code = createTemplatingComponent('```');
14
- const Line = exports.Line = createTemplatingComponent('');
15
- const Monospace = exports.Monospace = createTemplatingComponent('`');
16
- const Stroke = exports.Stroke = createTemplatingComponent('~');
17
- const Italic = exports.Italic = createTemplatingComponent('_');
13
+ exports.createTemplatingComponent = createTemplatingComponent;
14
+ const Bold = exports.Bold = createTemplatingComponent(_InlineCommands.bold);
15
+ const Code = exports.Code = createTemplatingComponent(_InlineCommands.code);
16
+ const Monospace = exports.Monospace = createTemplatingComponent(_InlineCommands.monospace);
17
+ const Stroke = exports.Stroke = createTemplatingComponent(_InlineCommands.stroke);
18
+ const Italic = exports.Italic = createTemplatingComponent(_InlineCommands.italic);
19
+ const ListItem = exports.ListItem = createTemplatingComponent(_InlineCommands.listItem);
20
+ const Paragraph = exports.Paragraph = createTemplatingComponent(_InlineCommands.paragraph);
21
+ const Line = ({
22
+ children
23
+ }) => {
24
+ return typeof children === 'string' ? children : Array.isArray(children) ? `${children.join('')}` : children?.toString();
25
+ };
26
+ exports.Line = Line;
18
27
  const List = ({
19
28
  items
20
29
  }) => {
@@ -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';
@@ -1,11 +1,10 @@
1
- /// <reference types="node" />
2
- import { Command } from 'kozz-types';
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/package.json CHANGED
@@ -1,13 +1,13 @@
1
1
  {
2
2
  "name": "kozz-module-maker",
3
- "version": "0.2.3",
3
+ "version": "0.2.5",
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
9
  "dev": "npm run build -- --watch & nodemon --watch dist --exec 'npm run dist/debugIndex.js'",
10
- "publish": "tsc && bun run build && bun publish"
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
20
  // "verbatimModuleSyntax": true,
14
- "noEmit": 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"}