zcatalyst-cli 1.18.0-beta.1 → 1.18.0-beta.11

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 (138) hide show
  1. package/docs/command_needs/rc.toml +8 -8
  2. package/docs/commands/ds/import.toml +5 -5
  3. package/docs/commands/zest/generate/index.toml +4 -0
  4. package/docs/serve/server/lib/appsail/index.toml +22 -1
  5. package/lib/authentication/login.js +8 -4
  6. package/lib/code-deck.js +7 -7
  7. package/lib/command_needs/rc.js +7 -7
  8. package/lib/commands/appsail/add.js +2 -2
  9. package/lib/commands/client/setup.js +1 -1
  10. package/lib/commands/codelib/install.js +6 -2
  11. package/lib/commands/ds/import.js +37 -21
  12. package/lib/commands/event/generate/index.js +14 -2
  13. package/lib/commands/functions/add.js +1 -1
  14. package/lib/commands/functions/setup.js +1 -1
  15. package/lib/commands/iac/export.js +5 -1
  16. package/lib/commands/iac/import.js +4 -1
  17. package/lib/commands/index.js +1 -0
  18. package/lib/commands/init.js +8 -1
  19. package/lib/commands/zest/generate/index.js +304 -0
  20. package/lib/deploy/features/appsail/index.js +25 -10
  21. package/lib/endpoints/index.js +17 -3
  22. package/lib/endpoints/lib/ds-bulk.js +1 -0
  23. package/lib/endpoints/lib/stratus.js +63 -0
  24. package/lib/endpoints/lib/tunnel.js +18 -0
  25. package/lib/endpoints/lib/zest.js +124 -0
  26. package/lib/event_generate/stratus.js +52 -0
  27. package/lib/fn-utils/lib/common.js +6 -1
  28. package/lib/iac/status/deploy.js +1 -5
  29. package/lib/init/features/appsail/index.js +34 -27
  30. package/lib/init/features/project.js +6 -15
  31. package/lib/internal/api.js +14 -6
  32. package/lib/internal/command.js +1 -1
  33. package/lib/prompt/index.js +5 -2
  34. package/lib/prompt/types/file-path.js +1 -1
  35. package/lib/prompt/types/search-box.js +281 -0
  36. package/lib/serve/features/appsail.js +1 -1
  37. package/lib/serve/server/index.js +44 -14
  38. package/lib/serve/server/lib/appsail/index.js +73 -13
  39. package/lib/serve/server/lib/appsail/start.js +9 -1
  40. package/lib/serve/server/lib/java/aio_server/lib/catalyst-cli-java-runtime-1.0.0.jar +0 -0
  41. package/lib/serve/server/lib/java/aio_server/lib/{catalyst-function-sdk-1.0.0.jar → catalyst-function-sdk-1.1.0.jar} +0 -0
  42. package/lib/serve/server/lib/java/aio_server/lib/catalyst-java-runtime-1.0.0.jar +0 -0
  43. package/lib/serve/server/lib/java/index.js +1 -1
  44. package/lib/serve/server/lib/master/appsail.js +3 -3
  45. package/lib/serve/server/lib/master/unknown-req-proxy.js +5 -2
  46. package/lib/serve/server/lib/master/utils.js +27 -15
  47. package/lib/serve/server/lib/node/index.js +1 -1
  48. package/lib/serve/server/lib/node/server/package-lock.json +12 -0
  49. package/lib/serve/server/lib/python/index.js +1 -1
  50. package/lib/shell/dependencies/http-functions.js +1 -1
  51. package/lib/shell/dependencies/invoker/bio/java/lib/{catalyst-function-sdk-1.0.0.jar → catalyst-function-sdk-1.1.0.jar} +0 -0
  52. package/lib/shell/dependencies/invoker/cron/java/JavacronInvoker.java +1 -1
  53. package/lib/shell/dependencies/invoker/cron/java/lib/{catalyst-function-sdk-1.0.0.jar → catalyst-function-sdk-1.1.0.jar} +0 -0
  54. package/lib/shell/dependencies/invoker/event/java/lib/{catalyst-function-sdk-1.0.0.jar → catalyst-function-sdk-1.1.0.jar} +0 -0
  55. package/lib/shell/dependencies/invoker/integ/java/JavaintegInvoker.java +15 -0
  56. package/lib/shell/dependencies/invoker/integ/java/lib/catalyst-function-sdk-1.1.0.jar +0 -0
  57. package/lib/shell/dependencies/invoker/integ/node.mjs +13 -0
  58. package/lib/shell/dependencies/invoker/job/java/JavajobInvoker.java +15 -1
  59. package/lib/shell/dependencies/invoker/job/java/lib/catalyst-function-sdk-1.1.0.jar +0 -0
  60. package/lib/shell/dependencies/local-function.js +24 -23
  61. package/lib/shell/dependencies/tunnel-server.js +52 -23
  62. package/lib/shell/index.js +22 -28
  63. package/lib/util_modules/config/lib/appsail.js +10 -8
  64. package/lib/util_modules/constants/lib/cliq-handlers.js +18 -10
  65. package/lib/util_modules/constants/lib/dc-type.js +8 -0
  66. package/lib/util_modules/constants/lib/event-action.js +1 -0
  67. package/lib/util_modules/constants/lib/event-source.js +1 -0
  68. package/lib/util_modules/constants/lib/placeholders.js +2 -1
  69. package/lib/util_modules/constants/lib/scopes.js +14 -3
  70. package/lib/util_modules/constants/lib/urls.js +8 -0
  71. package/lib/util_modules/fs/lib/async.js +7 -2
  72. package/package.json +4 -2
  73. package/templates/event/integ/cliq/bot/action_handler.json +13 -4
  74. package/templates/event/integ/cliq/bot/call_handler.json +41 -0
  75. package/templates/event/integ/cliq/bot/context_handler.json +11 -3
  76. package/templates/event/integ/cliq/bot/incomingwebhook_handler.json +11 -3
  77. package/templates/event/integ/cliq/bot/mention_handler.json +12 -4
  78. package/templates/event/integ/cliq/bot/message_handler.json +13 -4
  79. package/templates/event/integ/cliq/bot/participation_handler.json +13 -3
  80. package/templates/event/integ/cliq/bot/welcome_handler.json +12 -8
  81. package/templates/event/integ/cliq/command/execution_handler.json +12 -3
  82. package/templates/event/integ/cliq/command/suggestion_handler.json +18 -4
  83. package/templates/event/integ/cliq/{installation → extension}/installation_handler.json +13 -4
  84. package/templates/event/integ/cliq/{installation → extension}/installation_validator.json +13 -5
  85. package/templates/event/integ/cliq/extension/uninstallation_handler.json +37 -0
  86. package/templates/event/integ/cliq/function/button_handler.json +13 -5
  87. package/templates/event/integ/cliq/function/form_change_handler.json +9 -3
  88. package/templates/event/integ/cliq/function/form_handler.json +11 -3
  89. package/templates/event/integ/cliq/function/form_values_handler.json +9 -3
  90. package/templates/event/integ/cliq/function/form_view_handler.json +26 -0
  91. package/templates/event/integ/cliq/function/widget_button_handler.json +14 -5
  92. package/templates/event/integ/cliq/link_preview/action_handler.json +54 -0
  93. package/templates/event/integ/cliq/link_preview/after_send_handler.json +47 -0
  94. package/templates/event/integ/cliq/link_preview/menu_handler.json +47 -0
  95. package/templates/event/integ/cliq/link_preview/preview_handler.json +47 -0
  96. package/templates/event/integ/cliq/messageaction/execution_handler.json +11 -3
  97. package/templates/event/integ/cliq/widget/view_handler.json +12 -4
  98. package/templates/init/client/react/react_js/template/src/index.js +3 -3
  99. package/templates/init/client/react/react_ts/template/src/index.tsx +3 -3
  100. package/templates/init/client/react/react_ts/template.json +3 -3
  101. package/templates/init/functions/java/integ/cliq/com/handlers/BotHandler.java +29 -23
  102. package/templates/init/functions/java/integ/cliq/com/handlers/CommandHandler.java +14 -17
  103. package/templates/init/functions/java/integ/cliq/com/handlers/ExtensionHandler.java +41 -0
  104. package/templates/init/functions/java/integ/cliq/com/handlers/FunctionHandler.java +74 -22
  105. package/templates/init/functions/java/integ/cliq/com/handlers/LinkPreviewHandler.java +108 -0
  106. package/templates/init/functions/java/integ/cliq/com/handlers/MessageActionHandler.java +6 -8
  107. package/templates/init/functions/java/integ/cliq/sample.java +10 -0
  108. package/templates/init/functions/java/job/sample.java +1 -1
  109. package/templates/init/functions/node/aio/sample.js +7 -0
  110. package/templates/init/functions/node/bio/sample.js +5 -0
  111. package/templates/init/functions/node/bio/types/basicio.d.ts +57 -0
  112. package/templates/init/functions/node/cron/sample.js +5 -0
  113. package/templates/init/functions/node/cron/types/cron.d.ts +64 -0
  114. package/templates/init/functions/node/event/sample.js +11 -8
  115. package/templates/init/functions/node/event/types/event.d.ts +82 -0
  116. package/templates/init/functions/node/integ/cliq/handlers/bot-handler.js +4 -0
  117. package/templates/init/functions/node/integ/cliq/handlers/command-handler.js +3 -5
  118. package/templates/init/functions/node/integ/cliq/handlers/{installation-validator.js → extension-handler.js} +20 -3
  119. package/templates/init/functions/node/integ/cliq/handlers/function-handler.js +42 -0
  120. package/templates/init/functions/node/integ/cliq/handlers/link-preview-handler.js +73 -0
  121. package/templates/init/functions/node/job/sample.js +0 -1
  122. package/templates/init/functions/node/job/types/job.d.ts +0 -4
  123. package/templates/init/functions/python/integ/cliq/handlers/bot_handler.py +13 -3
  124. package/templates/init/functions/python/integ/cliq/handlers/command_handler.py +7 -7
  125. package/templates/init/functions/python/integ/cliq/handlers/extension_handler.py +25 -0
  126. package/templates/init/functions/python/integ/cliq/handlers/function_handler.py +54 -10
  127. package/templates/init/functions/python/integ/cliq/handlers/link_preview_handler.py +76 -0
  128. package/templates/init/functions/python/integ/cliq/handlers/widget_handler.py +10 -9
  129. package/templates/init/functions/python/integ/cliq/sample.py +2 -2
  130. package/templates/init/functions/python/job/sample.py +0 -1
  131. package/templates/init.txt +2 -1
  132. package/lib/shell/dependencies/invoker/integ/java/lib/catalyst-function-sdk-1.0.0.jar +0 -0
  133. package/lib/shell/dependencies/invoker/job/java/lib/catalyst-function-sdk-1.0.0.jar +0 -0
  134. package/templates/init/functions/java/integ/cliq/com/handlers/InstallationHandler.java +0 -20
  135. package/templates/init/functions/java/integ/cliq/com/handlers/InstallationValidator.java +0 -22
  136. package/templates/init/functions/node/integ/cliq/handlers/installation-handler.js +0 -15
  137. package/templates/init/functions/python/integ/cliq/handlers/installation_handler.py +0 -12
  138. package/templates/init/functions/python/integ/cliq/handlers/installation_validator.py +0 -16
@@ -14,6 +14,7 @@ import org.json.JSONObject;
14
14
 
15
15
  import com.zc.cliq.enums.ACTION_TYPE;
16
16
  import com.zc.cliq.enums.BANNER_STATUS;
17
+ import com.zc.cliq.enums.FORM_FIELD_TEXT_FORMAT;
17
18
  import com.zc.cliq.enums.FORM_FIELD_TYPE;
18
19
  import com.zc.cliq.enums.FORM_MODIFICATION_ACTION_TYPE;
19
20
  import com.zc.cliq.enums.SLIDE_TYPE;
@@ -25,6 +26,7 @@ import com.zc.cliq.objects.ButtonObject;
25
26
  import com.zc.cliq.objects.CardDetails;
26
27
  import com.zc.cliq.objects.Form;
27
28
  import com.zc.cliq.objects.FormAction;
29
+ import com.zc.cliq.objects.FormActionsObject;
28
30
  import com.zc.cliq.objects.FormChangeResponse;
29
31
  import com.zc.cliq.objects.FormDynamicFieldResponse;
30
32
  import com.zc.cliq.objects.FormInput;
@@ -39,9 +41,14 @@ import com.zc.cliq.objects.WidgetFooter;
39
41
  import com.zc.cliq.objects.WidgetHeader;
40
42
  import com.zc.cliq.objects.WidgetResponse;
41
43
  import com.zc.cliq.objects.WidgetSection;
44
+ import com.zc.cliq.objects.WidgetTarget;
42
45
  import com.zc.cliq.requests.ButtonFunctionRequest;
43
46
  import com.zc.cliq.requests.FormFunctionRequest;
44
47
  import com.zc.cliq.requests.WidgetFunctionRequest;
48
+ import com.zc.cliq.responses.ButtonFunctionResponse;
49
+ import com.zc.cliq.responses.FormChangeHandlerResponse;
50
+ import com.zc.cliq.responses.FormSubmitResponse;
51
+ import com.zc.cliq.responses.WidgetButtonResponse;
45
52
  import com.zc.cliq.util.ZCCliqUtil;
46
53
 
47
54
  public class FunctionHandler implements com.zc.cliq.interfaces.FunctionHandler {
@@ -49,13 +56,13 @@ public class FunctionHandler implements com.zc.cliq.interfaces.FunctionHandler {
49
56
  Logger LOGGER = Logger.getLogger(FunctionHandler.class.getName());
50
57
 
51
58
  @Override
52
- public Map<String, Object> buttonFunctionHandler(ButtonFunctionRequest req) throws Exception {
59
+ public ButtonFunctionResponse buttonFunctionHandler(ButtonFunctionRequest req) throws Exception {
53
60
  Message msg = Message.getInstance("Button function executed");
54
- return ZCCliqUtil.toMap(msg);
61
+ return msg;
55
62
  }
56
63
 
57
64
  @Override
58
- public Map<String, Object> formSubmitHandler(FormFunctionRequest req) throws Exception {
65
+ public FormSubmitResponse formSubmitHandler(FormFunctionRequest req) throws Exception {
59
66
  JSONObject values = req.getForm().getValues();
60
67
 
61
68
  String type = values.optString("type", null);
@@ -81,7 +88,7 @@ public class FunctionHandler implements com.zc.cliq.interfaces.FunctionHandler {
81
88
  WidgetSection buttonSection = getButtonsSection();
82
89
  widgetResp.addSection(buttonSection);
83
90
 
84
- return ZCCliqUtil.toMap(widgetResp);
91
+ return widgetResp;
85
92
  } else if (type.equals("formsection")) {
86
93
  WidgetSection section = WidgetSection.getInstance();
87
94
  section.setId("102");
@@ -90,11 +97,11 @@ public class FunctionHandler implements com.zc.cliq.interfaces.FunctionHandler {
90
97
  editedBy.setText("Edited by " + values.optString("text") + " :wink:");
91
98
  section.addElement(editedBy);
92
99
 
93
- return ZCCliqUtil.toMap(section);
100
+ return section;
94
101
  } else {
95
102
  Message msg = Message.getInstance("Applet Button executed successfully");
96
103
  msg.setBannerResponse(BANNER_STATUS.SUCCESS);
97
- return ZCCliqUtil.toMap(msg);
104
+ return msg;
98
105
  }
99
106
  }
100
107
  String text = new StringBuilder().append("Hi ").append(values.getString("username")).append(", thanks for raising your request. Your request will be processed based on the device availability.").toString();
@@ -121,11 +128,11 @@ public class FunctionHandler implements com.zc.cliq.interfaces.FunctionHandler {
121
128
  }
122
129
  slide.setData(dataArray);
123
130
  msg.addSlide(slide);
124
- return ZCCliqUtil.toMap(msg);
131
+ return msg;
125
132
  }
126
133
 
127
134
  @Override
128
- public FormChangeResponse formChangeHandler(FormFunctionRequest req) throws Exception {
135
+ public FormChangeHandlerResponse formChangeHandler(FormFunctionRequest req) throws Exception {
129
136
  FormChangeResponse resp = FormChangeResponse.getInstance();
130
137
  String target = req.getTarget().getName();
131
138
  JSONObject values = req.getForm().getValues();
@@ -136,7 +143,7 @@ public class FunctionHandler implements com.zc.cliq.interfaces.FunctionHandler {
136
143
  FormModificationAction selectBoxAction = FormModificationAction.getInstance();
137
144
  selectBoxAction.setType(FORM_MODIFICATION_ACTION_TYPE.ADD_AFTER);
138
145
  selectBoxAction.setName("asset-type");
139
- FormInput OS = FormInput.getIntance();
146
+ FormInput OS = FormInput.getInstance();
140
147
  OS.setTriggerOnChange(true);
141
148
  OS.setType(FORM_FIELD_TYPE.SELECT);
142
149
  OS.setName("os-type");
@@ -173,7 +180,7 @@ public class FunctionHandler implements com.zc.cliq.interfaces.FunctionHandler {
173
180
  FormModificationAction selectBoxAction = FormModificationAction.getInstance();
174
181
  selectBoxAction.setType(FORM_MODIFICATION_ACTION_TYPE.ADD_AFTER);
175
182
  selectBoxAction.setName("asset-type");
176
- FormInput OS = FormInput.getIntance();
183
+ FormInput OS = FormInput.getInstance();
177
184
  OS.setTriggerOnChange(true);
178
185
  OS.setType(FORM_FIELD_TYPE.SELECT);
179
186
  OS.setName("mobile-os");
@@ -205,7 +212,7 @@ public class FunctionHandler implements com.zc.cliq.interfaces.FunctionHandler {
205
212
  FormModificationAction mobileListAction = FormModificationAction.getInstance();
206
213
  mobileListAction.setType(FORM_MODIFICATION_ACTION_TYPE.ADD_AFTER);
207
214
  mobileListAction.setName("mobile-os");
208
- FormInput listInput = FormInput.getIntance();
215
+ FormInput listInput = FormInput.getInstance();
209
216
  listInput.setType(FORM_FIELD_TYPE.DYNAMIC_SELECT);
210
217
  listInput.setName("mobile-list");
211
218
  listInput.setLabel("Mobile Device");
@@ -240,10 +247,55 @@ public class FunctionHandler implements com.zc.cliq.interfaces.FunctionHandler {
240
247
  }
241
248
  return resp;
242
249
  }
250
+
251
+ @Override
252
+ public Form formViewHandler(FormFunctionRequest req) throws Exception {
253
+ Form form = Form.getInstance();
254
+ form.setTitle("Asset Request");
255
+ form.setHint("Raise your asset request");
256
+ form.setName("ID");
257
+ form.setButtonLabel("Raise Request");
258
+ form.setVersion(1);
259
+
260
+ FormInput username = FormInput.getInstance();
261
+ username.setType(FORM_FIELD_TYPE.TEXT);
262
+ username.setName("username");
263
+ username.setLabel("Name");
264
+ username.setHint("Please enter your name");
265
+ username.setPlaceholder("John Reese");
266
+ username.setMandatory(true);
267
+ username.setValue("Harold Finch");
268
+ form.addFormInput(username);
269
+
270
+ FormInput email = FormInput.getInstance();
271
+ email.setType(FORM_FIELD_TYPE.TEXT);
272
+ email.setFormat(FORM_FIELD_TEXT_FORMAT.EMAIL);
273
+ email.setName("email");
274
+ email.setLabel("Email");
275
+ email.setHint("Enter your email address");
276
+ email.setPlaceholder("johnreese@poi.com");
277
+ email.setMandatory(true);
278
+ email.setValue("haroldfinch@samaritan.com");
279
+ form.addFormInput(email);
280
+
281
+ FormInput assetType = FormInput.getInstance();
282
+ assetType.setType(FORM_FIELD_TYPE.SELECT);
283
+ assetType.setTriggerOnChange(true);
284
+ assetType.setName("asset-type");
285
+ assetType.setLabel("Asset Type");
286
+ assetType.setHint("Choose your request asset type");
287
+ assetType.setPlaceholder("Mobile");
288
+ assetType.setMandatory(true);
289
+ assetType.addOption(new FormValue("Laptop", "laptop"));
290
+ assetType.addOption(new FormValue("Mobile", "mobile"));
291
+ form.addFormInput(assetType);
292
+
293
+ return form;
294
+ }
243
295
 
244
296
  @Override
245
- public Map<String, Object> widgetButtonHandler(WidgetFunctionRequest req) throws Exception {
246
- ButtonObject target = req.getTarget();
297
+ public WidgetButtonResponse widgetButtonHandler(WidgetFunctionRequest req) throws Exception {
298
+ WidgetTarget target = req.getTarget();
247
299
  String id = target.getId();
248
300
  switch (id) {
249
301
  case "tab": {
@@ -263,7 +315,7 @@ public class FunctionHandler implements com.zc.cliq.interfaces.FunctionHandler {
263
315
  WidgetSection buttonSection = getButtonsSection();
264
316
 
265
317
  widgetResp.addSection(buttonSection);
266
- return ZCCliqUtil.toMap(widgetResp);
318
+ return widgetResp;
267
319
  }
268
320
 
269
321
  case "section": {
@@ -273,7 +325,7 @@ public class FunctionHandler implements com.zc.cliq.interfaces.FunctionHandler {
273
325
  WidgetElement element = WidgetElement.getInstance(WIDGET_ELEMENT_TYPE.TITLE);
274
326
  element.setText("Edited :wink:");
275
327
  section.addElement(element);
276
- return ZCCliqUtil.toMap(section);
328
+ return section;
277
329
  }
278
330
 
279
331
  case "formtab":
@@ -283,16 +335,16 @@ public class FunctionHandler implements com.zc.cliq.interfaces.FunctionHandler {
283
335
  form.setName("a");
284
336
  form.setHint("Register yourself for the Zylker Annual Marathon!");
285
337
  form.setButtonLabel("Submit");
286
- FormInput input1 = FormInput.getIntance();
338
+ FormInput input1 = FormInput.getInstance();
287
339
  input1.setType(FORM_FIELD_TYPE.TEXT);
288
340
  input1.setName("text");
289
341
  input1.setLabel("Name");
290
342
  input1.setPlaceholder("Scott Fischer");
291
- input1.setMinLength("0");
292
- input1.setMaxLength("25");
343
+ input1.setMinLength(0);
344
+ input1.setMaxLength(25);
293
345
  input1.setMandatory(true);
294
346
 
295
- FormInput input2 = FormInput.getIntance();
347
+ FormInput input2 = FormInput.getInstance();
296
348
  input2.setType(FORM_FIELD_TYPE.HIDDEN);
297
349
  input2.setName("type");
298
350
  input2.setValue(id);
@@ -300,7 +352,7 @@ public class FunctionHandler implements com.zc.cliq.interfaces.FunctionHandler {
300
352
  form.addFormInput(input1);
301
353
  form.addFormInput(input2);
302
354
  form.setAction(FormAction.getInstance("appletForm"));// ** ENTER YOUR FORM FUNCTION NAME HERE **
303
- return ZCCliqUtil.toMap(form);
355
+ return form;
304
356
  }
305
357
 
306
358
  case "breadcrumbs":
@@ -350,13 +402,13 @@ public class FunctionHandler implements com.zc.cliq.interfaces.FunctionHandler {
350
402
  footer.setButtons(footerButtons);
351
403
  widgetResp.setFooter(footer);
352
404
 
353
- return ZCCliqUtil.toMap(widgetResp);
405
+ return widgetResp;
354
406
 
355
407
  case "banner":
356
408
  default: {
357
409
  Message msg = Message.getInstance("Applet Button executed successfully");
358
410
  msg.setBannerResponse(BANNER_STATUS.SUCCESS);
359
- return ZCCliqUtil.toMap(msg);
411
+ return msg;
360
412
  }
361
413
  }
362
414
  }
@@ -0,0 +1,108 @@
1
+ //$Id$
2
+ package com.handlers;
3
+
4
+ import java.util.ArrayList;
5
+ import java.util.HashMap;
6
+ import java.util.LinkedList;
7
+ import java.util.List;
8
+
9
+ import com.zc.cliq.enums.BANNER_STATUS;
10
+ import com.zc.cliq.enums.OEMBED_ACTION_TYPE;
11
+ import com.zc.cliq.enums.OEMBED_TYPES;
12
+ import com.zc.cliq.objects.Confirm;
13
+ import com.zc.cliq.objects.OembedActions;
14
+ import com.zc.cliq.objects.OembedFieldData;
15
+ import com.zc.cliq.objects.OembedFields;
16
+ import com.zc.cliq.requests.LinkPreviewHandlerRequest;
17
+ import com.zc.cliq.responses.BannerResponse;
18
+ import com.zc.cliq.responses.CoreResponse;
19
+ import com.zc.cliq.responses.UnfurlResponse;
20
+
21
+ public class LinkPreviewHandler implements com.zc.cliq.interfaces.LinkPreviewHandler {
22
+
23
+ @Override
24
+ public UnfurlResponse previewHandler(LinkPreviewHandlerRequest req) throws Exception {
25
+ UnfurlResponse response = new UnfurlResponse("Release checklist | Zoho Cliq", OEMBED_TYPES.LINK, "https://www.zoho.com/cliq/");
26
+ response.setDescription("Release checklist for Cliq 5.0 (Focused on Enterprise and Intelligence)");
27
+ response.setDynamicActions(true);
28
+
29
+ // Create fields
30
+ List<OembedFieldData> fieldsData = new ArrayList<>();
31
+ fieldsData.add(new OembedFieldData("Created By","Scott fisher"));
32
+ fieldsData.add(new OembedFieldData("Created On", "10 Aug, 2023"));
33
+ fieldsData.add(new OembedFieldData("Last Modified On", "11 Aug, 2023"));
34
+ fieldsData.add(new OembedFieldData("Tags", "#unfurling_via_extensions #images_and_cards #cliq_360 #Cliq_5.0"));
35
+
36
+ OembedFields fields = new OembedFields(null, fieldsData);
37
+ response.setFields(fields);
38
+
39
+ // Create actions
40
+ List<OembedActions> actions = new LinkedList<OembedActions>();
41
+ OembedActions action = new OembedActions(OEMBED_ACTION_TYPE.BUTTON, "Add Comment");
42
+
43
+ Confirm confirm = new Confirm();
44
+ confirm.setTitle("Comment");
45
+ confirm.setDescription("Add your comment to the notes");
46
+ confirm.setInput("Type here...");
47
+ action.setConfirm(confirm);
48
+
49
+ HashMap<String,Object> params = new HashMap<String,Object>();
50
+ params.put("action", "add_comment");
51
+ action.setParams(params);
52
+
53
+ actions.add(action);
54
+
55
+ response.setActions(actions);
56
+ return response;
57
+ }
58
+
59
+ @Override
60
+ public CoreResponse actionHandler(LinkPreviewHandlerRequest req) throws Exception {
61
+ HashMap<String,Object> target = (HashMap<String, Object>) req.getTarget();
62
+ HashMap<String,Object> params = (HashMap<String, Object>) target.get("params");
63
+ String action = (String) params.get("action");
64
+ String text = null;
65
+ if(action.equals("add_comment"))
66
+ {
67
+ text = "Your comment has been added successfully";
68
+ }
69
+ else if(action.equals("delete_note"))
70
+ {
71
+ text = "Release checklist | Zoho Cliq note has been deleted";
72
+ }
73
+ else if(action.equals("mark_as_favorite"))
74
+ {
75
+ text = "Release checklist | Zoho Cliq note has been marked as favorite";
76
+ }
77
+ BannerResponse banner = new BannerResponse(text, BANNER_STATUS.SUCCESS);
78
+ return banner;
79
+
80
+ }
81
+
82
+ @Override
83
+ public List<OembedActions> menuHandler(LinkPreviewHandlerRequest req) throws Exception {
84
+ List<OembedActions> actions = new LinkedList<OembedActions>();
85
+
86
+ OembedActions delete = new OembedActions(OEMBED_ACTION_TYPE.BUTTON,"Delete");
87
+ HashMap<String,Object> deleteParam = new HashMap<String,Object>();
88
+ deleteParam.put("action", "delete_note");
89
+ delete.setParams(deleteParam);
90
+ actions.add(delete);
91
+
92
+ OembedActions favorite = new OembedActions(OEMBED_ACTION_TYPE.BUTTON, "Mark as Favorite");
93
+ HashMap<String,Object> favoriteParams = new HashMap<String,Object>();
94
+ favoriteParams.put("action", "mark_as_favorite");
95
+ favorite.setParams(favoriteParams);
96
+ actions.add(favorite);
97
+
98
+ return actions;
99
+
100
+ }
101
+
102
+ @Override
103
+ public CoreResponse afterSendHandler(LinkPreviewHandlerRequest req) throws Exception {
104
+ BannerResponse banner = new BannerResponse("Release checklist | Zoho Cliq 5.0", BANNER_STATUS.SUCCESS);
105
+ return banner;
106
+ }
107
+
108
+ }
@@ -1,25 +1,23 @@
1
1
  //$Id$
2
2
  package com.handlers;
3
3
 
4
- import java.util.Map;
5
-
6
- import com.zc.cliq.enums.RESPONSE_TYPE;
4
+ import com.zc.cliq.enums.MESSAGE_TYPE;
7
5
  import com.zc.cliq.objects.Message;
8
6
  import com.zc.cliq.requests.MessageActionHandlerRequest;
9
- import com.zc.cliq.util.ZCCliqUtil;
7
+ import com.zc.cliq.responses.CoreResponse;
10
8
 
11
9
  public class MessageActionHandler implements com.zc.cliq.interfaces.MessageActionHandler {
12
10
  @Override
13
- public Map<String, Object> executionHandler(MessageActionHandlerRequest req) throws Exception {
14
- RESPONSE_TYPE msgType = req.getMessage().getType();
11
+ public CoreResponse executionHandler(MessageActionHandlerRequest req) throws Exception {
12
+ MESSAGE_TYPE msgType = req.getMessage().getType();
15
13
  String firstName = req.getUser() != null ? req.getUser().getFirstName() : "user";
16
14
 
17
- String text = "Hey " + firstName + ", You have performed an action on a *" + msgType.getKey() + "*. Manipulate the message variable and perform your own action.";
15
+ String text = "Hey " + firstName + ", You have performed an action on a *" + msgType.getType() + "*. Manipulate the message variable and perform your own action.";
18
16
 
19
17
  Message resp = Message.getInstance();
20
18
  resp.setText(text);
21
19
 
22
- return ZCCliqUtil.toMap(resp);
20
+ return resp;
23
21
  }
24
22
 
25
23
  }
@@ -19,3 +19,13 @@ public class {{_CLASS_}} implements CatalystIntegFunctionHandler {
19
19
  }
20
20
  }
21
21
  }
22
+
23
+ /*
24
+ * Response type supported by these interface:
25
+ * CoreResponse: BannerResponse,Message,PreviewUrlResponse,Form,VoidResponse
26
+ * FormChangeHandlerResponse: FormChangeHandlerResponse, FormError
27
+ * FormSubmitResponse: BannerResponse,Message,PreviewUrlResponse,Form,FormError,WidgetResponse,WidgetSection,VoidResponse
28
+ * WebhookHandlerResponse: Message,WebhookResponse,VoidResponse
29
+ * WidgetButtonResponse: BannerResponse,PreviewUrlResponse,Form,WidgetResponse,WidgetSection,VoidResponse
30
+ * ButtonFunctionResponse: BannerResponse,Message,PreviewUrlResponse,Form,WidgetResponse,WidgetSection,VoidResponse
31
+ */
@@ -23,7 +23,7 @@ public class {{_CLASS_}} implements CatalystJobHandler {
23
23
  }
24
24
  LOGGER.log(Level.SEVERE, "Project Details " + request.getProjectDetails().toString());
25
25
  ZCCache.getInstance().putCacheValue("JobSample", "Working", 1l);
26
- LOGGER.log(Level.SEVERE, "Inserted SucessFully:)");
26
+ LOGGER.log(Level.SEVERE, "Inserted SuccessFully:)");
27
27
  } catch (Exception e) {
28
28
  LOGGER.log(Level.SEVERE, "Exception in Job Function", e);
29
29
  return JOB_STATUS.FAILURE;
@@ -1,5 +1,12 @@
1
1
  'use strict';
2
2
 
3
+ const { IncomingMessage, ServerResponse } = require("http");
4
+
5
+ /**
6
+ *
7
+ * @param {IncomingMessage} req
8
+ * @param {ServerResponse} res
9
+ */
3
10
  module.exports = (req, res) => {
4
11
  var url = req.url;
5
12
 
@@ -1,3 +1,8 @@
1
+ /**
2
+ *
3
+ * @param {import('./types/basicio').Context} context
4
+ * @param {import('./types/basicio').BasicIO} basicIO
5
+ */
1
6
  module.exports = (context, basicIO) => {
2
7
  /*
3
8
  BASICIO FUNCTIONALITIES
@@ -0,0 +1,57 @@
1
+ /**
2
+ * This is a utility file with the type declaration of the BasicIO function parameters
3
+ */
4
+
5
+ /**
6
+ * Type of the BasicIO object. Contains the functional APIs of BasicIO
7
+ */
8
+ export interface BasicIO {
9
+ /**
10
+ * Write to the BasicIO output
11
+ * @param value input string
12
+ * @returns
13
+ */
14
+ write: (value: string) => void;
15
+ /**
16
+ * Set the BasicIO status code
17
+ * @param statusCode status code of BasicIO
18
+ * @returns
19
+ */
20
+ setStatus: (statusCode: number) => void;
21
+ /**
22
+ * Get the input argument values of the BasicIO
23
+ * @param key argument name(key)
24
+ * @returns argument value as string
25
+ */
26
+ getArgument: (key: string) => string;
27
+ /**
28
+ * Get all input arguments
29
+ * @returns all arguments as key value pair
30
+ */
31
+ getAllArguments: () => Record<string, string>;
32
+ }
33
+
34
+ /**
35
+ * Type of the context object of the function
36
+ */
37
+ export interface Context {
38
+ /**
39
+ * Contains catalyst auth headers (for internal use)
40
+ */
41
+ catalystHeaders: Record<string, string>;
42
+ /**
43
+ * To indicate the end of a function execution
44
+ * @returns
45
+ */
46
+ close: () => void;
47
+ /**
48
+ * Fetch the remaining execution time of the function
49
+ * @returns remaining execution time in milliseconds
50
+ */
51
+ getRemainingExecutionTimeMs: () => number;
52
+ /**
53
+ * Fetch the maximum execution time of the function
54
+ * @returns maximum execution time in milliseconds
55
+ */
56
+ getMaxExecutionTimeMs: () => number;
57
+ }
@@ -1,3 +1,8 @@
1
+ /**
2
+ *
3
+ * @param {import('./types/cron').CronDetails} cronDetails
4
+ * @param {import('./types/cron').Context} context
5
+ */
1
6
  module.exports = (cronDetails, context) => {
2
7
  console.log('Hello from {{_MAIN_}}');
3
8
 
@@ -0,0 +1,64 @@
1
+ /**
2
+ * This is a utility file with the type declaration of the Cron function parameters
3
+ */
4
+
5
+ /**
6
+ * Type of Cron Details object. Contains the details of the scheduled cron
7
+ */
8
+ export interface CronDetails {
9
+ /**
10
+ * Get the input param value of the Cron function
11
+ * @returns input param value
12
+ */
13
+ getCronParam: () => string;
14
+ /**
15
+ * Get all input params of the Cron function
16
+ * @returns all input params as key value pairs
17
+ */
18
+ getAllCronParam: () => Record<string, string>;
19
+ /**
20
+ * Get the remaining execution count of the cron job
21
+ * @returns remaining execution count
22
+ */
23
+ getRemainingExecutionCount: () => number;
24
+ /**
25
+ * Get the details of the cron which executed the function
26
+ * @returns cron details
27
+ */
28
+ getCronDetails: () => Record<string, unknown>;
29
+ /**
30
+ * Get the current project details
31
+ * @returns project details
32
+ */
33
+ getProjectDetails: () => Record<string, unknown>;
34
+ }
35
+
36
+ /**
37
+ * Type of the Context object of the Cron function
38
+ */
39
+ export interface Context {
40
+ /**
41
+ * Contains catalyst auth headers (for internal use)
42
+ */
43
+ catalystHeaders: Record<string, string>;
44
+ /**
45
+ * Close the Cron function with success response
46
+ * @returns
47
+ */
48
+ closeWithSuccess: () => void;
49
+ /**
50
+ * Close the Cron function failure response
51
+ * @returns
52
+ */
53
+ closeWithFailure: () => void;
54
+ /**
55
+ * Get the remaining execution time of the Cron function
56
+ * @returns remaining execution time in milliseconds
57
+ */
58
+ getRemainingExecutionTimeMs: () => number;
59
+ /**
60
+ * Get the maximum possible execution time of the Cron function
61
+ * @returns maximum possible execution time in milliseconds
62
+ */
63
+ getMaxExecutionTimeMs: () => number;
64
+ }
@@ -1,20 +1,23 @@
1
+ /**
2
+ *
3
+ * @param {import('./types/event').EventDetails} event
4
+ * @param {import('./types/event').Context} context
5
+ */
1
6
  module.exports = (event, context) => {
2
7
  /*
3
8
  EVENT FUNCTIONALITIES
4
9
  */
5
- // const DATA = event.data; //event data
6
- // const TIME = event.time; //event occured time
10
+ // const DATA = event.getData(); //event data
11
+ // const TIME = event.getTime(); //event occurred time
7
12
 
8
- // const SOURCE_DETAILS = event.getSourceDetails(); //event source details
9
- // const SOURCE_ACTION = SOURCE_DETAILS.action; //(insert | fetch | invoke ...)
10
- // const SOURCE_TYPE = SOURCE_DETAILS.type; //(datastore | cache | queue ...)
11
- // const SOURCE_ENTITY_ID = SOURCE_DETAILS.entityId; //if type is datastore then entity id is tableid
13
+ // const ACTION = event.getAction(); //(insert | fetch | invoke ...)
14
+ // const SOURCE = event.getSource(); //(datastore | cache | queue ...)
15
+ // const SOURCE_ENTITY_ID = event.getSourceEntityId(); //if type is datastore then entity id is tableid
12
16
 
13
- // const SOURCE_BUS_DETAILS = SOURCE_DETAILS.getBusDetails(); //event bus details
17
+ // const SOURCE_BUS_DETAILS = event.getBusDetails(); //event bus details
14
18
  // const SOURCE_BUS_ID = SOURCE_BUS_DETAILS.id; //event bus id
15
19
 
16
20
  // const PROJECT_DETAILS = event.getProjectDetails(); //event project details
17
- // const FUNCTION_DETAILS = event.getFunctionDetails(); //event function details
18
21
 
19
22
  console.log('Hello from {{_MAIN_}}');
20
23
 
@@ -0,0 +1,82 @@
1
+ /**
2
+ * This is a utility file with the type declaration of the Event function parameters
3
+ */
4
+
5
+ /**
6
+ * Type of Event Details object. Contains the details of the triggered Event
7
+ */
8
+ export interface EventDetails {
9
+ /**
10
+ * Event data
11
+ */
12
+ data: Record<string, unknown>;
13
+ /**
14
+ * Time of the event
15
+ */
16
+ time: number;
17
+ /**
18
+ * Get the project details of the event function
19
+ * @returns project details
20
+ */
21
+ getProjectDetails: () => Record<string, unknown>;
22
+ /**
23
+ * Functional API to get the data of the event
24
+ * @returns event data
25
+ */
26
+ getData: () => Record<string, unknown>;
27
+ /**
28
+ * Functional API to get the time of the event
29
+ * @returns event time
30
+ */
31
+ getTime: () => number;
32
+ /**
33
+ * Get the action that triggered the event
34
+ * @returns action
35
+ */
36
+ getAction: () => string;
37
+ /**
38
+ * Get the source of the event
39
+ * @returns event source
40
+ */
41
+ getSource: () => string;
42
+ /**
43
+ * Get the Id of the entity that triggered the event
44
+ * @returns source entity's Id
45
+ */
46
+ getSourceEntityId: () => string;
47
+ /**
48
+ * Get the details of the event bus
49
+ * @returns event bus details
50
+ */
51
+ getEventBusDetails: () => Record<string, unknown>;
52
+ }
53
+
54
+ /**
55
+ * Type of the Context object of the Event function
56
+ */
57
+ export interface Context {
58
+ /**
59
+ * Contains catalyst auth headers (for internal use)
60
+ */
61
+ catalystHeaders: Record<string, string>;
62
+ /**
63
+ * Close the Event function with success response
64
+ * @returns
65
+ */
66
+ closeWithSuccess: () => void;
67
+ /**
68
+ * Close the Event function failure response
69
+ * @returns
70
+ */
71
+ closeWithFailure: () => void;
72
+ /**
73
+ * Get the remaining execution time of the Event function
74
+ * @returns remaining execution time in milliseconds
75
+ */
76
+ getRemainingExecutionTimeMs: () => number;
77
+ /**
78
+ * Get the maximum possible execution time of the Event function
79
+ * @returns maximum possible execution time in milliseconds
80
+ */
81
+ getMaxExecutionTimeMs: () => number;
82
+ }
@@ -180,6 +180,10 @@ botHandler.participationHandler(async (req, res) => {
180
180
  return res;
181
181
  });
182
182
 
183
+ botHandler.callHandler(async (req, res) => {
184
+ // Logic for bot call post handling
185
+ });
186
+
183
187
  function comp(var1, var2) {
184
188
  return var1.toUpperCase() === var2.toUpperCase();
185
189
  }