@dawntech/dwntbots-services 0.0.63 → 0.0.65

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 (83) hide show
  1. package/package.json +4 -4
  2. package/src/lib/blip/BlipBuilder/BlipBotDiff.js +5 -1
  3. package/src/lib/blip/BlipBuilder/BlipBotDiff.js.map +1 -1
  4. package/src/lib/blip/BlipBuilder/BlipBuilder.d.ts +61 -0
  5. package/src/lib/blip/BlipBuilder/BlipBuilder.js +195 -0
  6. package/src/lib/blip/BlipBuilder/BlipBuilder.js.map +1 -0
  7. package/src/lib/blip/BlipBuilder/BlipBuilderSanitize.js +6 -0
  8. package/src/lib/blip/BlipBuilder/BlipBuilderSanitize.js.map +1 -1
  9. package/src/lib/blip/BlipBuilder/BlipBuilderTranspilation.d.ts +30 -0
  10. package/src/lib/blip/BlipBuilder/BlipBuilderTranspilation.js +73 -0
  11. package/src/lib/blip/BlipBuilder/BlipBuilderTranspilation.js.map +1 -0
  12. package/src/lib/blip/BlipBuilder/BlipBuilderTranspile.d.ts +1 -0
  13. package/src/lib/blip/BlipBuilder/BlipBuilderTranspile.js +15 -2
  14. package/src/lib/blip/BlipBuilder/BlipBuilderTranspile.js.map +1 -1
  15. package/src/lib/blip/BlipBuilder/features/CommonFeature.d.ts +18 -0
  16. package/src/lib/blip/BlipBuilder/features/CommonFeature.js +77 -0
  17. package/src/lib/blip/BlipBuilder/features/CommonFeature.js.map +1 -0
  18. package/src/lib/blip/BlipBuilder/features/Feature.d.ts +31 -0
  19. package/src/lib/blip/BlipBuilder/features/Feature.js +45 -0
  20. package/src/lib/blip/BlipBuilder/features/Feature.js.map +1 -0
  21. package/src/lib/blip/BlipBuilder/features/InactivityFeature.d.ts +25 -0
  22. package/src/lib/blip/BlipBuilder/features/InactivityFeature.js +143 -0
  23. package/src/lib/blip/BlipBuilder/features/InactivityFeature.js.map +1 -0
  24. package/src/lib/blip/BlipBuilder/features/LintFeature.d.ts +5 -0
  25. package/src/lib/blip/BlipBuilder/features/LintFeature.js +14 -0
  26. package/src/lib/blip/BlipBuilder/features/LintFeature.js.map +1 -0
  27. package/src/lib/blip/BlipBuilder/features/PositionFeature.d.ts +71 -0
  28. package/src/lib/blip/BlipBuilder/features/PositionFeature.js +143 -0
  29. package/src/lib/blip/BlipBuilder/features/PositionFeature.js.map +1 -0
  30. package/src/lib/blip/BlipBuilder/features/SDKFeature.d.ts +40 -0
  31. package/src/lib/blip/BlipBuilder/features/SDKFeature.js +210 -0
  32. package/src/lib/blip/BlipBuilder/features/SDKFeature.js.map +1 -0
  33. package/src/lib/blip/BlipBuilder/features/TagsFeature.d.ts +20 -0
  34. package/src/lib/blip/BlipBuilder/features/TagsFeature.js +90 -0
  35. package/src/lib/blip/BlipBuilder/features/TagsFeature.js.map +1 -0
  36. package/src/lib/blip/BlipBuilder/features/actions/content.d.ts +4 -0
  37. package/src/lib/blip/BlipBuilder/features/actions/content.js +81 -0
  38. package/src/lib/blip/BlipBuilder/features/actions/content.js.map +1 -0
  39. package/src/lib/blip/BlipBuilder/features/actions/ctwa.d.ts +3 -0
  40. package/src/lib/blip/BlipBuilder/features/actions/ctwa.js +43 -0
  41. package/src/lib/blip/BlipBuilder/features/actions/ctwa.js.map +1 -0
  42. package/src/lib/blip/BlipBuilder/features/actions/entrypoint.d.ts +5 -0
  43. package/src/lib/blip/BlipBuilder/features/actions/entrypoint.js +87 -0
  44. package/src/lib/blip/BlipBuilder/features/actions/entrypoint.js.map +1 -0
  45. package/src/lib/blip/BlipBuilder/features/actions/fallback.d.ts +5 -0
  46. package/src/lib/blip/BlipBuilder/features/actions/fallback.js +79 -0
  47. package/src/lib/blip/BlipBuilder/features/actions/fallback.js.map +1 -0
  48. package/src/lib/blip/BlipBuilder/features/actions/global.d.ts +3 -0
  49. package/src/lib/blip/BlipBuilder/features/actions/global.js +52 -0
  50. package/src/lib/blip/BlipBuilder/features/actions/global.js.map +1 -0
  51. package/src/lib/blip/BlipBuilder/features/actions/onboarding.d.ts +2 -0
  52. package/src/lib/blip/BlipBuilder/features/actions/onboarding.js +27 -0
  53. package/src/lib/blip/BlipBuilder/features/actions/onboarding.js.map +1 -0
  54. package/src/lib/blip/BlipBuilder/features/blocks/debugger.d.ts +2 -0
  55. package/src/lib/blip/BlipBuilder/features/blocks/debugger.js +653 -0
  56. package/src/lib/blip/BlipBuilder/features/blocks/debugger.js.map +1 -0
  57. package/src/lib/blip/BlipBuilder/features/blocks/error.d.ts +3 -0
  58. package/src/lib/blip/BlipBuilder/features/blocks/error.js +234 -0
  59. package/src/lib/blip/BlipBuilder/features/blocks/error.js.map +1 -0
  60. package/src/lib/blip/BlipBuilder/features/blocks/inactivity.d.ts +2 -0
  61. package/src/lib/blip/BlipBuilder/features/blocks/inactivity.js +128 -0
  62. package/src/lib/blip/BlipBuilder/features/blocks/inactivity.js.map +1 -0
  63. package/src/lib/blip/BlipBuilder/features/index.d.ts +6 -0
  64. package/src/lib/blip/BlipBuilder/features/index.js +23 -0
  65. package/src/lib/blip/BlipBuilder/features/index.js.map +1 -0
  66. package/src/lib/blip/BlipBuilder/index.d.ts +3 -0
  67. package/src/lib/blip/BlipBuilder/index.js +3 -2
  68. package/src/lib/blip/BlipBuilder/index.js.map +1 -1
  69. package/src/lib/blip/BlipBuilder/models/commom.d.ts +2 -0
  70. package/src/lib/blip/BlipBuilder/models/commom.js +3 -1
  71. package/src/lib/blip/BlipBuilder/models/commom.js.map +1 -1
  72. package/src/lib/blip/BlipBuilder/models/debug.d.ts +2 -0
  73. package/src/lib/blip/BlipBuilder/models/debug.js +631 -0
  74. package/src/lib/blip/BlipBuilder/models/debug.js.map +1 -0
  75. package/src/lib/blip/BlipService.d.ts +11 -1
  76. package/src/lib/blip/BlipService.js +147 -0
  77. package/src/lib/blip/BlipService.js.map +1 -1
  78. package/src/lib/blip/index.d.ts +1 -0
  79. package/src/lib/blip/index.js +1 -0
  80. package/src/lib/blip/index.js.map +1 -1
  81. package/src/lib/new-relic/NewRelicIngest.d.ts +2 -2
  82. package/src/lib/new-relic/NewRelicIngest.js +2 -2
  83. package/src/lib/new-relic/NewRelicIngest.js.map +1 -1
@@ -0,0 +1,631 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.debugBlock = void 0;
4
+ exports.debugBlock = {
5
+ $contentActions: [
6
+ {
7
+ action: {
8
+ $id: "4d8fb2e1-6c5f-49eb-b428-a913c4dd41f7",
9
+ $typeOfContent: "text",
10
+ type: "SendMessage",
11
+ settings: {
12
+ id: "55911c1f-24bb-4371-840c-cb6d5a531074",
13
+ type: "text/plain",
14
+ content: "{{message}}",
15
+ metadata: {},
16
+ },
17
+ $cardContent: {
18
+ document: {
19
+ id: "55911c1f-24bb-4371-840c-cb6d5a531074",
20
+ type: "text/plain",
21
+ content: "{{message}}",
22
+ },
23
+ editable: true,
24
+ deletable: true,
25
+ position: "left",
26
+ },
27
+ },
28
+ },
29
+ {
30
+ input: {
31
+ bypass: false,
32
+ conditions: [
33
+ {
34
+ values: [],
35
+ source: "context",
36
+ comparison: "exists",
37
+ variable: "commands@ENABLED",
38
+ },
39
+ {
40
+ values: [],
41
+ source: "context",
42
+ comparison: "notExists",
43
+ variable: "commands@GOTO",
44
+ },
45
+ {
46
+ values: [],
47
+ source: "context",
48
+ comparison: "notExists",
49
+ variable: "commands@REDIRECT",
50
+ },
51
+ ],
52
+ $cardContent: {
53
+ document: {
54
+ id: "0273a986-94ed-4b60-89f8-7ccb83b366c5",
55
+ type: "text/plain",
56
+ textContent: "Entrada do usuƔrio",
57
+ content: "Entrada do usuƔrio",
58
+ },
59
+ editable: false,
60
+ deletable: true,
61
+ position: "right",
62
+ },
63
+ expiration: "0:10",
64
+ },
65
+ },
66
+ {
67
+ action: {
68
+ $id: "4bbab46e-9d25-4393-bfa1-1cc73d96fcf7",
69
+ $typeOfContent: "text",
70
+ type: "SendMessage",
71
+ conditions: [
72
+ {
73
+ values: [],
74
+ source: "input",
75
+ comparison: "notExists",
76
+ },
77
+ ],
78
+ settings: {
79
+ id: "663d9e86-942f-4250-984f-04e68a5350c3",
80
+ type: "text/plain",
81
+ content: "Timeout exceeded. Redirecting to onboarding.",
82
+ metadata: {
83
+ "#stateName": "{{state.name}}",
84
+ "#stateId": "{{state.id}}",
85
+ "#messageId": "{{input.message@id}}",
86
+ "#previousStateId": "{{state.previous.id}}",
87
+ "#previousStateName": "{{state.previous.name}}",
88
+ },
89
+ },
90
+ $cardContent: {
91
+ document: {
92
+ id: "663d9e86-942f-4250-984f-04e68a5350c3",
93
+ type: "text/plain",
94
+ content: "Timeout exceeded. Redirecting to onboarding.",
95
+ },
96
+ editable: true,
97
+ deletable: true,
98
+ position: "left",
99
+ },
100
+ },
101
+ },
102
+ ],
103
+ $conditionOutputs: [
104
+ {
105
+ stateId: "731c9a46-dc70-4c84-9cc6-763e49710d8e",
106
+ typeOfStateId: "state",
107
+ $id: "46940940-dd0b-40d9-9012-4d61abda10fe",
108
+ conditions: [
109
+ {
110
+ source: "input",
111
+ comparison: "exists",
112
+ values: [],
113
+ variable: "commands@GOTO",
114
+ },
115
+ {
116
+ values: [],
117
+ comparison: "exists",
118
+ source: "context",
119
+ variable: "commands@ENABLED",
120
+ },
121
+ {
122
+ values: [],
123
+ source: "context",
124
+ comparison: "notExists",
125
+ variable: "commands@GOTO",
126
+ },
127
+ ],
128
+ },
129
+ {
130
+ stateId: "{{commands@GOTO.data}}",
131
+ typeOfStateId: "variable",
132
+ $id: "1893834e-7be2-4dc1-b90c-0067eb452b1a",
133
+ conditions: [
134
+ {
135
+ source: "input",
136
+ comparison: "exists",
137
+ values: [],
138
+ variable: "commands@GOTO",
139
+ },
140
+ {
141
+ values: [],
142
+ source: "context",
143
+ comparison: "exists",
144
+ variable: "commands@GOTO",
145
+ },
146
+ {
147
+ values: [],
148
+ source: "context",
149
+ comparison: "exists",
150
+ variable: "commands@GOTO.data",
151
+ },
152
+ ],
153
+ },
154
+ ],
155
+ $enteringCustomActions: [
156
+ {
157
+ $id: "d24db3ee-0962-4622-a775-52666ed001eb",
158
+ $typeOfContent: "",
159
+ type: "ExecuteScript",
160
+ $title: "Process commands",
161
+ settings: {
162
+ function: "run",
163
+ source: '\nfunction getContactData(contactId, contactData) {\n let payload = {}\n try {\n payload = JSON.parse(contactData);\n } catch (err) {}\n payload["identity"] = contactId;\n return payload;\n}\n\nconst HELP_MESSAGE = `Commands:\n\nšŸ”¹ goto {block_id}: jump to block block_id.\nāž”ļø Example: <b>goto onboarding</b>\n\nšŸ”¹ redirect {service_name}: redirect to service service_name.\nāž”ļø Example: <b>redirect main</b>\n\nšŸ”¹ print {type}[contact | context | services]: print contact, context or services.\nāž”ļø Example: <b>print contact; print context; print services</b>\n<b>Print service caveats:</b>\nContext size can lead to reduced responses, thus you can use take and skip parameters\nāž”ļø Example: <b>print context {skip} {take}</b>\n\nšŸ”¹ set {type}[contact | context] {key} {value}: set key to value on contact or context. \nāž”ļø Example: <b>set context a 1</b>\n<b>Set contact caveats:</b>\nWhen key is json defined the command will produce a set contact but the value <b>must be JSON string</b>\nāž”ļø Example: <b>set contact {"name":"test"}</b>\nWhen key is a contact property the command will produce a merge contact. \nāž”ļø Example: <b>set contact name test; set contact extras.key 1</b>\n\nšŸ”¹ get {type}[context] {key}: get variavble key from context.\nāž”ļø Example: <b>get context a</b>\n\nšŸ”¹ merge {type}[contact] json {value}: merge value on contact. Value <b>must be JSON string</b>\nāž”ļø Example: <b>merge contact json {"name":"test"}</b>\n\nšŸ”¹ delete {type}[context] {key}: delete key on context. \nāž”ļø Example: <b>delete context a</b>\n`;\n\nfunction decodeCommand(command, context) {\n const cmd = { \n definition: command.join(" "),\n args: command,\n id: null,\n data: null,\n priority: 0,\n message: null\n };\n\n let type = String(command[0]).toUpperCase();\n let subtype = String(command[1] || "").toUpperCase();\n let key = String(command[2] || "");\n let value = String(command[3] || "");\n\n let data = {};\n const identity = context["identity"];\n\n switch(type) {\n case "#DEBUG":\n cmd["id"] = "DEBUG";\n cmd["data"] = command[1];\n break;\n case "SET":\n if (subtype == "CONTACT") {\n cmd["id"] = "MERGE_CONTACT";\n if (key.toUpperCase() == "JSON") {\n cmd["id"] = "SET_CONTACT";\n data = getContactData(identity, value);\n } else if (key.startsWith("extras.")) {\n const subkey = key.split("extras.")[1];\n data = {extras: {}};\n data["extras"][subkey] = value;\n } else {\n data[key] = value;\n }\n data["identity"] = identity;\n cmd["data"] = data;\n } else if (subtype == "CONTEXT") {\n cmd["id"] = "SET_CONTEXT";\n cmd["data"] = { "identity": identity, "key": key, "value": value };\n }\n cmd["priority"] = 1;\n break;\n case "GET":\n if (subtype == "CONTEXT") {\n cmd["id"] = "GET_CONTEXT";\n cmd["data"] = { "identity": identity, "key": key };\n }\n cmd["priority"] = 2;\n break;\n case "MERGE":\n if (subtype == "CONTACT" && key.toUpperCase() == "JSON") {\n cmd["id"] = "MERGE_CONTACT";\n data = getContactData(identity, value);\n cmd["data"] = data;\n }\n cmd["priority"] = 3;\n break;\n case "DELETE":\n if (subtype == "CONTEXT") {\n cmd["id"] = "DELETE_CONTEXT";\n cmd["data"] = { "identity": identity, "key": key };\n } \n cmd["priority"] = 4;\n break;\n case "HELP":\n cmd["id"] = "HELP";\n cmd["message"] = HELP_MESSAGE;\n cmd["priority"] = 5;\n break;\n case "PRINT":\n if (subtype == "CONTEXT") {\n cmd["id"] = "PRINT_CONTEXT";\n cmd["data"] = {"take": key || 200, "skip": value || 0 };\n } else if (subtype == "CONTACT") {\n cmd["id"] = "PRINT_CONTACT";\n } else if (subtype == "SERVICES") {\n cmd["id"] = "PRINT_SERVICES";\n }\n cmd["priority"] = 6;\n break;\n case "REDIRECT":\n cmd["id"] = "REDIRECT";\n cmd["data"] = command[1];\n cmd["priority"] = 7;\n break;\n case "GOTO":\n cmd["id"] = "GOTO";\n cmd["data"] = command[1];\n cmd["message"] = `šŸ” Jumping to block ${cmd["data"]}`;\n cmd["priority"] = 8;\n break;\n case "CLOSE":\n cmd["id"] = "CLOSE";\n break; \n }\n\n return cmd;\n}\n\nfunction decodeArgs(command) {\n const [command, json] = command.split(/[\\t ]+json[\\t ]+/i);\n const args = command.split(/[\\t ]+/);\n if (json) {\n args.push("json", json);\n }\n return args\n .map(chunk => chunk.trim())\n .filter(chunk => chunk.length > 0);\n}\n\nfunction parseCommands(inputContent, context) {\n let commands;\n \n commands = String(inputContent || "")\n .split(/[;\\n]/)\n .map(decodeArgs)\n .filter(cmd => cmd.length > 0);\n\n commands = commands\n .map(cmd => decodeCommand(cmd, context))\n .filter(cmd => cmd.id !== null);\n\n if (commands.some(cmd => ["PRINT_SERVICES", "REDIRECT"].includes(cmd["id"]))) {\n commands.push({id: "GET_SERVICES"});\n }\n\n if (commands.some(cmd => cmd["id"] == "CLOSE") && !commands.some(cmd => cmd["id"] == "GOTO")) {\n commands.push({id: "GOTO", data: "onboarding", message: "šŸ” Jumping to block onboarding", priority: 8});\n }\n \n commands = commands\n .reduce(function (acc, cmd) {\n acc[cmd.id] = cmd;\n return acc;\n }, {});\n\n return commands\n}\n\nfunction run(input, contactId, secret, commands) {\n secret = secret || "123";\n \n const session = JSON.parse(commands || "{}").DEBUG;\n\n const context = {identity: contactId};\n commands = parseCommands(input, context);\n\n commands["DEBUG"] = commands["DEBUG"] || session;\n commands["ENABLED"] = commands.DEBUG && commands.DEBUG.data == secret;\n\n return JSON.stringify(commands);\n}',
164
+ inputVariables: [
165
+ "input.content",
166
+ "contact.identity",
167
+ "config.debugSecret",
168
+ "commands",
169
+ ],
170
+ outputVariable: "commands",
171
+ LocalTimeZoneEnabled: false,
172
+ },
173
+ conditions: [],
174
+ },
175
+ {
176
+ $id: "d8df88c1-3ff4-48a9-ad5e-0867984d1487",
177
+ $typeOfContent: "",
178
+ type: "ProcessCommand",
179
+ $title: "Set Contact when SET_CONTACT exists",
180
+ settings: {
181
+ to: "postmaster@msging.net",
182
+ method: "set",
183
+ resource: "{{commands@SET_CONTACT.data}}",
184
+ type: "application/vnd.lime.contact+json",
185
+ uri: "/contacts",
186
+ variable: "setContactCommandResponse",
187
+ },
188
+ conditions: [
189
+ {
190
+ values: [],
191
+ source: "context",
192
+ comparison: "exists",
193
+ variable: "commands@SET_CONTACT",
194
+ },
195
+ ],
196
+ },
197
+ {
198
+ $id: "5ad3d211-0240-4489-83ed-af614c129b33",
199
+ $typeOfContent: "",
200
+ type: "ExecuteScript",
201
+ $title: "Process commands when SET_CONTACT exists",
202
+ settings: {
203
+ function: "run",
204
+ source: 'function getCommandError(response) {\n let message = JSON.stringify(response);\n if (response.status === "failure" && response.reason && response.reason.description) {\n message = response.reason.description;\n } else if (response.reduced) {\n message = "Reduced";\n }\n\n return message;\n}\n\nfunction run(commands, commandReponse) {\n\ttry {\n\t\tcommands = JSON.parse(commands);\n\t} catch(err) {\n\t\tcommands = {};\n\t}\n\n let message = `āš™ļø Contact set to ${JSON.stringify(commands.SET_CONTACT.data)}.`;\n\n try {\n const response = JSON.parse(commandReponse);\n if (response.status !== "success") {\n throw new Error(getCommandError(response));\n } \n } catch (err) {\n message = `āŒ set contact: ${err.message}`;\n }\n\n commands.SET_CONTACT.message = message;\n\n\treturn JSON.stringify(commands); \n}\n',
205
+ inputVariables: ["commands", "setContactCommandResponse"],
206
+ outputVariable: "commands",
207
+ LocalTimeZoneEnabled: false,
208
+ },
209
+ conditions: [
210
+ {
211
+ values: [],
212
+ source: "context",
213
+ comparison: "exists",
214
+ variable: "commands@SET_CONTACT",
215
+ },
216
+ ],
217
+ continueOnError: true,
218
+ },
219
+ {
220
+ $id: "a00082d5-c648-4d7e-b6ef-0e4afba5370a",
221
+ $typeOfContent: "",
222
+ type: "ProcessCommand",
223
+ $title: "Merge Contact when MERGE_CONTACT exists",
224
+ settings: {
225
+ to: "postmaster@msging.net",
226
+ method: "merge",
227
+ resource: "{{commands@MERGE_CONTACT.data}}",
228
+ type: "application/vnd.lime.contact+json",
229
+ uri: "/contacts",
230
+ variable: "mergeContactCommandResponse",
231
+ },
232
+ conditions: [
233
+ {
234
+ values: [],
235
+ source: "context",
236
+ variable: "commands@MERGE_CONTACT",
237
+ comparison: "exists",
238
+ },
239
+ ],
240
+ },
241
+ {
242
+ $id: "d9221ef7-8fbc-4d17-a7e2-eb5397574a55",
243
+ $typeOfContent: "",
244
+ type: "ExecuteScript",
245
+ $title: "Process command when MERGE_CONTACT exists",
246
+ settings: {
247
+ function: "run",
248
+ source: 'function getCommandError(response) {\n let message = JSON.stringify(response);\n if (response.status === "failure" && response.reason && response.reason.description) {\n message = response.reason.description;\n } else if (response.reduced) {\n message = "Reduced";\n }\n\n return message;\n}\n\nfunction run(commands, commandReponse) {\n\ttry {\n\t\tcommands = JSON.parse(commands);\n\t} catch(err) {\n\t\tcommands = {};\n\t}\n\n let message = `āš™ļø Contact got merged with ${JSON.stringify(commands.MERGE_CONTACT.data)}.`;\n try {\n const response = JSON.parse(commandReponse);\n if (response.status !== "success") {\n throw new Error(getCommandError(response));\n } \n } catch (err) {\n message = `āŒ merge contact: ${err.message}`;\n }\n\n commands.MERGE_CONTACT.message = message;\n\n\treturn JSON.stringify(commands); \n}\n',
249
+ inputVariables: ["commands", "mergeContactCommandResponse"],
250
+ outputVariable: "commands",
251
+ LocalTimeZoneEnabled: false,
252
+ },
253
+ conditions: [
254
+ {
255
+ values: [],
256
+ source: "context",
257
+ comparison: "exists",
258
+ variable: "commands@MERGE_CONTACT",
259
+ },
260
+ ],
261
+ continueOnError: true,
262
+ },
263
+ {
264
+ $id: "a9635237-40a6-4f6e-bf08-aa431a53c2a2",
265
+ $typeOfContent: "",
266
+ type: "ProcessCommand",
267
+ $title: "Set Context Variable when SET_CONTEXT exists",
268
+ settings: {
269
+ to: "postmaster@msging.net",
270
+ method: "set",
271
+ resource: "{{commands@SET_CONTEXT.data.value}}",
272
+ type: "text/plain",
273
+ uri: "/contexts/{{contact.identity}}/{{commands@SET_CONTEXT.data.key}}",
274
+ variable: "setContextCommandResponse",
275
+ },
276
+ conditions: [
277
+ {
278
+ values: [],
279
+ source: "context",
280
+ comparison: "exists",
281
+ variable: "commands@SET_CONTEXT",
282
+ },
283
+ ],
284
+ },
285
+ {
286
+ $id: "ac55004f-3a3c-423b-b891-772312cdcf53",
287
+ $typeOfContent: "",
288
+ type: "ExecuteScript",
289
+ $title: "Process commands when SET_CONTEXT exists",
290
+ settings: {
291
+ function: "run",
292
+ source: 'function getCommandError(response) {\n let message = JSON.stringify(response);\n if (response.status === "failure" && response.reason && response.reason.description) {\n message = response.reason.description;\n } else if (response.reduced) {\n message = "Reduced";\n }\n\n return message;\n}\n\nfunction run(commands, commandReponse) {\n\ttry {\n\t\tcommands = JSON.parse(commands);\n\t} catch(err) {\n\t\tcommands = {};\n\t}\n\n let message = `āš™ļø Context variable <b>${commands.SET_CONTEXT.data.key}</b> set to <b>${commands.SET_CONTEXT.data.value}</b>.`;\n\n try {\n const response = JSON.parse(commandReponse);\n if (response.status !== "success") {\n throw new Error(getCommandError(response));\n } \n } catch (err) {\n message = `āŒ set context: ${err.message}`;\n }\n\n commands.SET_CONTEXT.message = message;\n\n\treturn JSON.stringify(commands); \n}\n',
293
+ inputVariables: ["commands", "setContextCommandResponse"],
294
+ outputVariable: "commands",
295
+ LocalTimeZoneEnabled: false,
296
+ },
297
+ conditions: [
298
+ {
299
+ values: [],
300
+ source: "context",
301
+ comparison: "exists",
302
+ variable: "commands@SET_CONTEXT",
303
+ },
304
+ ],
305
+ continueOnError: true,
306
+ },
307
+ {
308
+ $id: "884e97ac-65a7-433f-80ab-f4d24ea1cb23",
309
+ $typeOfContent: "",
310
+ type: "ProcessCommand",
311
+ $title: "Get Context Variable when GET_CONTEXT exists",
312
+ settings: {
313
+ to: "postmaster@msging.net",
314
+ method: "get",
315
+ uri: "/contexts/{{contact.identity}}/{{commands@GET_CONTEXT.data.key}}",
316
+ variable: "getContextCommandResponse",
317
+ from: "{{application.identity}}",
318
+ },
319
+ conditions: [
320
+ {
321
+ values: [],
322
+ source: "context",
323
+ comparison: "exists",
324
+ variable: "commands@GET_CONTEXT",
325
+ },
326
+ ],
327
+ },
328
+ {
329
+ $id: "e7c6abd9-cc66-458d-920d-df30f64a8681",
330
+ $typeOfContent: "",
331
+ type: "ExecuteScript",
332
+ $title: "Process commands when GET_CONTEXT exists",
333
+ settings: {
334
+ function: "run",
335
+ source: 'function getCommandError(response) {\n let message = JSON.stringify(response);\n if (response.status === "failure" && response.reason && response.reason.description) {\n message = response.reason.description;\n } else if (response.reduced) {\n message = "Reduced";\n }\n\n return message;\n}\n\nfunction run(commands, commandReponse) {\n\ttry {\n\t\tcommands = JSON.parse(commands);\n\t} catch(err) {\n\t\tcommands = {};\n\t}\n\n let message = null;\n\n try {\n const response = JSON.parse(commandReponse);\n if (response.status !== "success") {\n throw new Error(getCommandError(response));\n } else {\n const value = response.resource;\n message = `āš™ļø Context variable <b>${commands.GET_CONTEXT.data.key}</b>: <b>${value}</b>.`;\n }\n } catch (err) {\n message = `āŒ get context: ${err.message}`;\n }\n\n commands.GET_CONTEXT.message = message;\n\n\treturn JSON.stringify(commands); \n}\n',
336
+ inputVariables: ["commands", "getContextCommandResponse"],
337
+ outputVariable: "commands",
338
+ LocalTimeZoneEnabled: false,
339
+ },
340
+ conditions: [
341
+ {
342
+ values: [],
343
+ source: "context",
344
+ comparison: "exists",
345
+ variable: "commands@GET_CONTEXT",
346
+ },
347
+ ],
348
+ continueOnError: true,
349
+ },
350
+ {
351
+ $id: "313eaaa5-651b-4639-af86-3f81202f33c7",
352
+ $typeOfContent: "",
353
+ type: "ProcessCommand",
354
+ $title: "Delete Context Variable when DELETE_CONTEXT exists",
355
+ settings: {
356
+ to: "postmaster@msging.net",
357
+ method: "delete",
358
+ uri: "/contexts/{{contact.identity}}/{{commands@DELETE_CONTEXT.data.key}}",
359
+ variable: "deleteContextCommandResponse",
360
+ },
361
+ conditions: [
362
+ {
363
+ values: [],
364
+ source: "context",
365
+ comparison: "exists",
366
+ variable: "commands@DELETE_CONTEXT",
367
+ },
368
+ ],
369
+ },
370
+ {
371
+ $id: "ff4ee09d-0693-4dea-a975-fe9e6f8d4be0",
372
+ $typeOfContent: "",
373
+ type: "ExecuteScript",
374
+ $title: "Process commands when DELETE_CONTEXT exists",
375
+ settings: {
376
+ function: "run",
377
+ source: 'function getCommandError(response) {\n let message = JSON.stringify(response);\n if (response.status === "failure" && response.reason && response.reason.description) {\n message = response.reason.description;\n } else if (response.reduced) {\n message = "Reduced";\n }\n\n return message;\n}\n\nfunction run(commands, commandReponse) {\n\ttry {\n\t\tcommands = JSON.parse(commands);\n\t} catch(err) {\n\t\tcommands = {};\n\t}\n\n let message = `āš™ļø Context variable <b>${commands.DELETE_CONTEXT.data.key}</b> deleted.`;\n\n try {\n const response = JSON.parse(commandReponse);\n if (response.status !== "success") {\n throw new Error(getCommandError(response));\n } \n } catch (err) {\n message = `āŒ delete context: ${err.message}`;\n }\n\n commands.DELETE_CONTEXT.message = message;\n\n\treturn JSON.stringify(commands); \n}\n',
378
+ inputVariables: ["commands", "deleteContextCommandResponse"],
379
+ outputVariable: "commands",
380
+ LocalTimeZoneEnabled: false,
381
+ },
382
+ conditions: [
383
+ {
384
+ values: [],
385
+ source: "context",
386
+ comparison: "exists",
387
+ variable: "commands@DELETE_CONTEXT",
388
+ },
389
+ ],
390
+ continueOnError: true,
391
+ },
392
+ {
393
+ $id: "2b581fe9-3a05-4fb8-ba30-dcd5f5d0bfa8",
394
+ $typeOfContent: "",
395
+ type: "ProcessCommand",
396
+ $title: "Get All Context when PRINT_CONTEXT exists",
397
+ settings: {
398
+ to: "postmaster@msging.net",
399
+ method: "get",
400
+ uri: "/contexts/{{contact.identity}}?withContextValues=true&$skip={{commands@PRINT_CONTEXT.data.skip}}&$take={{commands@PRINT_CONTEXT.data.take}}",
401
+ variable: "getAllContextCommandResponse",
402
+ },
403
+ conditions: [
404
+ {
405
+ values: [],
406
+ source: "context",
407
+ comparison: "exists",
408
+ variable: "commands@PRINT_CONTEXT",
409
+ },
410
+ ],
411
+ },
412
+ {
413
+ $id: "46abc774-db18-441d-8b53-699aa8b12df4",
414
+ $typeOfContent: "",
415
+ type: "ExecuteScript",
416
+ $title: "Process commands when PRINT_CONTEXT exists",
417
+ settings: {
418
+ function: "run",
419
+ source: 'const MAX_STR_LEN = 500;\n\nfunction printObject(data, level) {\n\treturn Object\n .keys(data)\n .map(function(key) {\n const value = data[key];\n let msg = new Array(level).fill("-").join("") + " ";\n if (["string", "boolean", "number"].includes(typeof value)) {\n let val = String(value);\n if (val.length >= MAX_STR_LEN) {\n val = val.slice(0, MAX_STR_LEN) + "...";\n }\n msg += `<b>${key}:</b> ${val}`;\n } else {\n msg += `<b>${key}:</b>\\n${printObject(value, level + 1)}`;\n }\n return msg;\n })\n .join("\\n");\n}\n\nfunction getCommandError(response) {\n let message = JSON.stringify(response);\n if (response.status === "failure" && response.reason && response.reason.description) {\n message = response.reason.description;\n } else if (response.reduced) {\n message = "Reduced";\n }\n\n return message;\n}\n\nfunction run(commands, commandReponse) {\n const EXCLUDE_VARIABLES = [/commands/i, /message/i, /.*commandresponse/i, /.*stateid@.*/i]; \n\tlet message = null;\n\n\ttry {\n\t\tcommands = JSON.parse(commands);\n\t} catch(err) {\n\t\tcommands = {};\n\t}\n\n try {\n const response = JSON.parse(commandReponse);\n if (response.status !== "success") {\n throw new Error(getCommandError(response));\n } else {\n\t\t\tconst context = response.resource.items.reduce(function (acc, item) {\n\t\t\t\tif (!EXCLUDE_VARIABLES.some(exp => exp.test(item.name))) {\n\t\t\t\t\tacc[item.name] = item.value;\n\t\t\t\t}\n\t\t\t\treturn acc;\n\t\t\t}, {});\n\t\t\tif (Object.keys(context).length > 0) {\n\t\t\t\tmessage = printObject(context, 1);\n\t\t\t} else {\n\t\t\t\tmessage = "No variable found yet, try it again.";\n\t\t\t}\n\t\t\tmessage = `šŸ“‹ CONTEXT\\n${message}`;\n\t\t}\n } catch (err) {\n message = `āŒ print context: ${err.message}`;\n }\n\n commands.PRINT_CONTEXT.message = message;\n\n\treturn JSON.stringify(commands); \n}\n',
420
+ inputVariables: ["commands", "getAllContextCommandResponse"],
421
+ outputVariable: "commands",
422
+ LocalTimeZoneEnabled: false,
423
+ },
424
+ conditions: [
425
+ {
426
+ values: [],
427
+ source: "context",
428
+ comparison: "exists",
429
+ variable: "commands@PRINT_CONTEXT",
430
+ },
431
+ ],
432
+ continueOnError: true,
433
+ },
434
+ {
435
+ $id: "ec13b725-6b3e-401c-9398-f155d7b5247b",
436
+ $typeOfContent: "",
437
+ type: "ProcessCommand",
438
+ $title: "Get Contact when PRINT_CONTACT exists",
439
+ settings: {
440
+ to: "postmaster@msging.net",
441
+ method: "get",
442
+ uri: "/contacts/{{contact.identity}}",
443
+ variable: "getContactCommandResponse",
444
+ },
445
+ conditions: [
446
+ {
447
+ values: [],
448
+ source: "context",
449
+ comparison: "exists",
450
+ variable: "commands@PRINT_CONTACT",
451
+ },
452
+ ],
453
+ },
454
+ {
455
+ $id: "d80827cb-85fc-408a-b06d-67a0710f7c4e",
456
+ $typeOfContent: "",
457
+ type: "ExecuteScript",
458
+ $title: "Process command when PRINT_CONTACT exists",
459
+ settings: {
460
+ function: "run",
461
+ source: 'const MAX_STR_LEN = 500;\n\nfunction printObject(data, level) {\n\treturn Object\n .keys(data)\n .map(function(key) {\n const value = data[key];\n let msg = new Array(level).fill("-").join("") + " ";\n if (["string", "boolean", "number"].includes(typeof value)) {\n let val = String(value);\n if (val.length >= MAX_STR_LEN) {\n val = val.slice(0, MAX_STR_LEN) + "...";\n }\n msg += `<b>${key}:</b> ${val}`;\n } else {\n msg += `<b>${key}:</b>\\n${printObject(value, level + 1)}`;\n }\n return msg;\n })\n .join("\\n");\n}\n\nfunction getCommandError(response) {\n let message = JSON.stringify(response);\n if (response.status === "failure" && response.reason && response.reason.description) {\n message = response.reason.description;\n } else if (response.reduced) {\n message = "Reduced";\n }\n\n return message;\n} \n\nfunction run(commands, commandReponse) {\n\tlet message = null;\n\n\ttry {\n\t\tcommands = JSON.parse(commands);\n\t} catch(err) {\n\t\tcommands = {};\n\t}\n\n try {\n const response = JSON.parse(commandReponse);\n if (response.status === "success" && response.resource) {\n contact = response.resource;\n message = printObject(contact, 1);\n } else {\n throw new Error(getCommandError(response));\n } \n\t} catch (err) {\n\t\tmessage = `āŒ print contact: ${err.message}`;\n\t}\n\n\tcommands.PRINT_CONTACT.message = `šŸ“– Contact\\n${message}`;\n\n\treturn JSON.stringify(commands); \n}\n',
462
+ inputVariables: ["commands", "getContactCommandResponse"],
463
+ outputVariable: "commands",
464
+ LocalTimeZoneEnabled: false,
465
+ },
466
+ conditions: [
467
+ {
468
+ values: [],
469
+ source: "context",
470
+ comparison: "exists",
471
+ variable: "commands@PRINT_CONTACT",
472
+ },
473
+ ],
474
+ continueOnError: true,
475
+ },
476
+ {
477
+ $id: "9d405be6-4793-4dfd-8a81-b5f9742a5cf2",
478
+ $typeOfContent: "",
479
+ type: "ProcessCommand",
480
+ $title: "Get Services when GET_SERVICES exists",
481
+ settings: {
482
+ to: "postmaster@msging.net",
483
+ method: "get",
484
+ uri: "lime://start.master.hosting@msging.net/configuration",
485
+ variable: "getServicesCommandResponse",
486
+ },
487
+ conditions: [
488
+ {
489
+ values: [],
490
+ source: "context",
491
+ comparison: "exists",
492
+ variable: "commands@GET_SERVICES",
493
+ },
494
+ ],
495
+ },
496
+ {
497
+ $id: "35876104-681b-4552-b7f4-fff8b1cf3b50",
498
+ $typeOfContent: "",
499
+ type: "ExecuteScript",
500
+ $title: "Process command when PRINT_SERVICES exists",
501
+ settings: {
502
+ function: "run",
503
+ source: 'function run(commands, commandReponse) {\n\tlet message = "šŸ“‘ Services\\n";\n\n\ttry {\n\t\tcommands = JSON.parse(commands);\n\t} catch(err) {\n\t\tcommands = {};\n\t}\n\n try {\n const response = JSON.parse(commandReponse);\n if (response.status === "success" && response.resource && response.resource.Application) {\n const configuration = JSON.parse(response.resource.Application);\n const services = configuration.settings.children;\n\n message += Array.from(services)\n .map(child => `${child.isDefault ? "+" : "-"} <b>${child.service}:</b> ${child.shortName} <i>${child.longName}</i>`)\n .join("\\n");\n } else {\n throw new Error(getCommandError(response));\n } \n\t} catch (err) {\n\t\tmessage = `āŒ print services: ${err.message}`;\n\t}\n\n\tcommands.PRINT_SERVICES.message = message;\n\n\treturn JSON.stringify(commands); \n}\n',
504
+ inputVariables: ["commands", "getServicesCommandResponse"],
505
+ outputVariable: "commands",
506
+ LocalTimeZoneEnabled: false,
507
+ },
508
+ conditions: [
509
+ {
510
+ values: [],
511
+ source: "context",
512
+ comparison: "exists",
513
+ variable: "commands@PRINT_SERVICES",
514
+ },
515
+ ],
516
+ continueOnError: true,
517
+ },
518
+ {
519
+ $id: "0f43ed55-4182-4234-add1-f484297372ee",
520
+ $typeOfContent: "",
521
+ type: "ExecuteScript",
522
+ $title: "Process command when REDIRECT exists",
523
+ settings: {
524
+ function: "run",
525
+ source: 'function getCommandError(response) {\n let message = JSON.stringify(response);\n if (response.status === "failure" && response.reason && response.reason.description) {\n message = response.reason.description;\n } else if (response.reduced) {\n message = "Reduced";\n }\n\n return message;\n}\n \n\nfunction run(commands, commandReponse) {\n\tlet message = null;\n\n\ttry {\n\t\tcommands = JSON.parse(commands);\n\t} catch(err) {\n\t\tcommands = {};\n\t}\n\n try {\n const response = JSON.parse(commandReponse);\n if (response.status === "success" && response.resource && response.resource.Application) {\n const configuration = JSON.parse(response.resource.Application);\n const services = Array.from(configuration.settings.children).map(child => child.service);\n const service = services.find(service => String(service).toUpperCase() == String(commands.REDIRECT.data).toUpperCase());\n if (!service) {\n throw new Error(`service <b>${commands.REDIRECT.data}</b> does not exists.`);\n } else {\n commands.REDIRECT.data = service;\n message = `šŸ” Redirecting to service ${service}`;\n }\n } else {\n\t\t throw new Error(getCommandError(response));\n\t } \n\t} catch (err) {\n\t\tmessage = `āŒ redirect: ${err.message}`;\n commands.REDIRECT.data = undefined;\n\n\t}\n\n\tcommands.REDIRECT.message = message;\n\n\treturn JSON.stringify(commands); \n}\n',
526
+ inputVariables: ["commands", "getServicesCommandResponse"],
527
+ outputVariable: "commands",
528
+ LocalTimeZoneEnabled: false,
529
+ },
530
+ conditions: [
531
+ {
532
+ values: [],
533
+ source: "context",
534
+ comparison: "exists",
535
+ variable: "commands@REDIRECT",
536
+ },
537
+ ],
538
+ continueOnError: true,
539
+ },
540
+ {
541
+ $id: "00eb4cc3-e787-4e3c-bdf6-47037eeb4a90",
542
+ $typeOfContent: "",
543
+ type: "ExecuteScript",
544
+ $title: "Process message",
545
+ settings: {
546
+ function: "run",
547
+ source: '\nfunction run(commands, botId) {\n let message = "Desculpe, nĆ£o entendi!";\n\ttry {\n\t\tcommands = JSON.parse(commands)\n\t} catch(err) {\n\t\tcommands = {};\n\t}\n\n if (!commands.ENABLED) {\n return message;\n } else {\n message = `āš ļø <b>DEBUG MODE</b> āš ļø\\n current bot: <b>${botId}</b>\\n\\n`;\n }\n\n let messages = Object.keys(commands)\n .filter(id => Boolean(commands[id]["message"]))\n .sort((idA, idB) => commands[idA]["priority"] > commands[idB]["priority"])\n .map(id => commands[id]["message"])\n\n if (messages.length === 0) {\n message += "No command found, try <b>help</b> for the list of available commands."\n } else {\n messages = messages.join("\\n");\n if (messages.length < 3500) {\n message += messages;\n } else {\n message += "Message too long. Please run fewer commands or with more specific parameters."\n }\n }\n\n if (!(commands.GOTO || commands.REDIRECT)) {\n message += "\\n\\nTo exit DEBUG mode you must use <b>close</b> or <b>goto</b> commands.";\n message += "\\nāž”ļø Example: <b>goto onboarding</b> or <b>close</b>";\n }\n\n\treturn message; \n}\n\n',
548
+ inputVariables: ["commands", "application.identifier"],
549
+ outputVariable: "message",
550
+ LocalTimeZoneEnabled: false,
551
+ },
552
+ conditions: [],
553
+ },
554
+ ],
555
+ $leavingCustomActions: [
556
+ {
557
+ $id: "0aa01d08-c523-4869-bdf9-4fc9cd48574b",
558
+ $typeOfContent: "",
559
+ type: "ExecuteScript",
560
+ $title: "Reset commands when no input or GOTO or REDIRECT",
561
+ settings: {
562
+ function: "run",
563
+ source: '\nfunction run(commands, input) {\n\tcommands = JSON.parse(commands);\n\tif (!input || commands.GOTO || commands.REDIRECT || !commands.ENABLED) {\n\t\tcommands["DEBUG"] = undefined;\n\t}\n\treturn JSON.stringify(commands);\n}',
564
+ inputVariables: ["commands", "input.content"],
565
+ outputVariable: "commands",
566
+ LocalTimeZoneEnabled: false,
567
+ },
568
+ conditions: [],
569
+ },
570
+ {
571
+ $id: "79826d8b-f1e7-408d-9bf6-2bcf8cd24cc0",
572
+ $typeOfContent: "",
573
+ type: "Redirect",
574
+ $title: "Redirect when REDIRECT exists",
575
+ settings: { address: "{{commands@REDIRECT.data}}" },
576
+ conditions: [
577
+ {
578
+ values: [],
579
+ source: "context",
580
+ comparison: "exists",
581
+ variable: "commands@REDIRECT",
582
+ },
583
+ {
584
+ values: [],
585
+ source: "context",
586
+ comparison: "exists",
587
+ variable: "commands@REDIRECT.data",
588
+ },
589
+ ],
590
+ },
591
+ {
592
+ $id: "f8ad824e-4557-4067-b3b4-787a889b160d",
593
+ $typeOfContent: "",
594
+ type: "ExecuteScript",
595
+ $title: "Process commands when REDIRECT",
596
+ settings: {
597
+ function: "run",
598
+ source: '\nfunction run(commands) {\n\ttry {\n\t\tcommands = JSON.parse(commands);\n\t} catch(err) {\n\t\tcommands = {};\n\t}\n\n\tcommands.GOTO = { data: "onboarding" };\n\t\n\treturn JSON.stringify(commands);\n}',
599
+ inputVariables: ["commands"],
600
+ outputVariable: "commands",
601
+ LocalTimeZoneEnabled: false,
602
+ },
603
+ conditions: [
604
+ {
605
+ values: [],
606
+ source: "context",
607
+ comparison: "exists",
608
+ variable: "commands@REDIRECT",
609
+ },
610
+ {
611
+ values: [],
612
+ source: "context",
613
+ comparison: "exists",
614
+ variable: "commands@REDIRECT.data",
615
+ },
616
+ ],
617
+ continueOnError: true,
618
+ },
619
+ ],
620
+ $inputSuggestions: [],
621
+ $defaultOutput: {
622
+ stateId: "onboarding",
623
+ typeOfStateId: "state",
624
+ },
625
+ $tags: [],
626
+ id: "debug:46-dc70-4c84-9cc6-763e49710d8e",
627
+ root: false,
628
+ $title: "#DEBUG by Dawntech",
629
+ $position: { top: "94px", left: "1299px" },
630
+ };
631
+ //# sourceMappingURL=debug.js.map