zcatalyst-cli 1.18.0-beta.10 → 1.18.0-beta.11-slate

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 (100) hide show
  1. package/docs/commands/slate/unlink.toml +9 -0
  2. package/docs/option-filter.toml +5 -0
  3. package/docs/serve/server/lib/slate/index.toml +14 -0
  4. package/docs/slate-utils.toml +4 -0
  5. package/lib/archiver.js +18 -9
  6. package/lib/command_needs/auth.js +1 -1
  7. package/lib/command_needs/rc.js +40 -3
  8. package/lib/commands/deploy/index.js +6 -1
  9. package/lib/commands/deploy/slate.js +58 -0
  10. package/lib/commands/index.js +3 -0
  11. package/lib/commands/init.js +4 -0
  12. package/lib/commands/slate/create.js +60 -0
  13. package/lib/commands/slate/link.js +60 -0
  14. package/lib/commands/slate/unlink.js +74 -0
  15. package/lib/deploy/features/index.js +3 -0
  16. package/lib/deploy/features/slate.js +123 -0
  17. package/lib/endpoints/index.js +8 -1
  18. package/lib/endpoints/lib/slate.js +91 -0
  19. package/lib/fn-utils/lib/common.js +1 -1
  20. package/lib/init/features/appsail/index.js +1 -1
  21. package/lib/init/features/index.js +15 -2
  22. package/lib/init/features/project.js +1 -1
  23. package/lib/init/features/slate/index.js +308 -0
  24. package/lib/internal/api.js +1 -1
  25. package/lib/internal/command.js +9 -5
  26. package/lib/option-filter.js +8 -2
  27. package/lib/port-resolver.js +7 -0
  28. package/lib/prompt/types/file-path.js +8 -5
  29. package/lib/serve/features/index.js +8 -1
  30. package/lib/serve/features/slate.js +47 -0
  31. package/lib/serve/index.js +19 -0
  32. package/lib/serve/server/index.js +61 -1
  33. package/lib/serve/server/lib/appsail/index.js +1 -1
  34. package/lib/serve/server/lib/master/index.js +25 -21
  35. package/lib/serve/server/lib/master/slate.js +45 -0
  36. package/lib/serve/server/lib/master/utils.js +2 -2
  37. package/lib/serve/server/lib/slate/index.js +144 -0
  38. package/lib/serve/server/lib/slate/static-server.js +193 -0
  39. package/lib/slate-utils.js +212 -0
  40. package/lib/util_modules/config/index.js +3 -1
  41. package/lib/util_modules/config/lib/slate.js +94 -0
  42. package/lib/util_modules/constants/lib/cliq-handlers.js +18 -10
  43. package/lib/util_modules/constants/lib/default.js +4 -0
  44. package/lib/util_modules/constants/lib/file-names.js +7 -1
  45. package/lib/util_modules/constants/lib/folder-names.js +1 -0
  46. package/lib/util_modules/constants/lib/scopes.js +3 -1
  47. package/lib/util_modules/context-help.js +2 -2
  48. package/lib/util_modules/fs/lib/async.js +8 -1
  49. package/lib/util_modules/fs/lib/sync.js +6 -1
  50. package/lib/util_modules/parser/toml.js +20 -5
  51. package/package.json +2 -2
  52. package/templates/event/integ/cliq/bot/action_handler.json +13 -4
  53. package/templates/event/integ/cliq/bot/call_handler.json +41 -0
  54. package/templates/event/integ/cliq/bot/context_handler.json +11 -3
  55. package/templates/event/integ/cliq/bot/incomingwebhook_handler.json +11 -3
  56. package/templates/event/integ/cliq/bot/mention_handler.json +12 -4
  57. package/templates/event/integ/cliq/bot/message_handler.json +13 -4
  58. package/templates/event/integ/cliq/bot/participation_handler.json +13 -3
  59. package/templates/event/integ/cliq/bot/welcome_handler.json +12 -8
  60. package/templates/event/integ/cliq/command/execution_handler.json +12 -3
  61. package/templates/event/integ/cliq/command/suggestion_handler.json +18 -4
  62. package/templates/event/integ/cliq/{installation → extension}/installation_handler.json +13 -4
  63. package/templates/event/integ/cliq/{installation → extension}/installation_validator.json +13 -5
  64. package/templates/event/integ/cliq/extension/uninstallation_handler.json +37 -0
  65. package/templates/event/integ/cliq/function/button_handler.json +13 -5
  66. package/templates/event/integ/cliq/function/form_change_handler.json +9 -3
  67. package/templates/event/integ/cliq/function/form_handler.json +11 -3
  68. package/templates/event/integ/cliq/function/form_values_handler.json +9 -3
  69. package/templates/event/integ/cliq/function/form_view_handler.json +26 -0
  70. package/templates/event/integ/cliq/function/widget_button_handler.json +14 -5
  71. package/templates/event/integ/cliq/link_preview/action_handler.json +54 -0
  72. package/templates/event/integ/cliq/link_preview/after_send_handler.json +47 -0
  73. package/templates/event/integ/cliq/link_preview/menu_handler.json +47 -0
  74. package/templates/event/integ/cliq/link_preview/preview_handler.json +47 -0
  75. package/templates/event/integ/cliq/messageaction/execution_handler.json +11 -3
  76. package/templates/event/integ/cliq/widget/view_handler.json +12 -4
  77. package/templates/init/functions/java/integ/cliq/com/handlers/BotHandler.java +29 -23
  78. package/templates/init/functions/java/integ/cliq/com/handlers/CommandHandler.java +14 -17
  79. package/templates/init/functions/java/integ/cliq/com/handlers/ExtensionHandler.java +41 -0
  80. package/templates/init/functions/java/integ/cliq/com/handlers/FunctionHandler.java +74 -22
  81. package/templates/init/functions/java/integ/cliq/com/handlers/LinkPreviewHandler.java +108 -0
  82. package/templates/init/functions/java/integ/cliq/com/handlers/MessageActionHandler.java +6 -8
  83. package/templates/init/functions/java/integ/cliq/sample.java +10 -0
  84. package/templates/init/functions/node/integ/cliq/handlers/bot-handler.js +4 -0
  85. package/templates/init/functions/node/integ/cliq/handlers/command-handler.js +3 -5
  86. package/templates/init/functions/node/integ/cliq/handlers/{installation-validator.js → extension-handler.js} +20 -3
  87. package/templates/init/functions/node/integ/cliq/handlers/function-handler.js +42 -0
  88. package/templates/init/functions/node/integ/cliq/handlers/link-preview-handler.js +73 -0
  89. package/templates/init/functions/python/integ/cliq/handlers/bot_handler.py +13 -3
  90. package/templates/init/functions/python/integ/cliq/handlers/command_handler.py +7 -7
  91. package/templates/init/functions/python/integ/cliq/handlers/extension_handler.py +25 -0
  92. package/templates/init/functions/python/integ/cliq/handlers/function_handler.py +54 -10
  93. package/templates/init/functions/python/integ/cliq/handlers/link_preview_handler.py +76 -0
  94. package/templates/init/functions/python/integ/cliq/handlers/widget_handler.py +10 -9
  95. package/templates/init/functions/python/integ/cliq/sample.py +2 -2
  96. package/templates/init/functions/java/integ/cliq/com/handlers/InstallationHandler.java +0 -20
  97. package/templates/init/functions/java/integ/cliq/com/handlers/InstallationValidator.java +0 -22
  98. package/templates/init/functions/node/integ/cliq/handlers/installation-handler.js +0 -15
  99. package/templates/init/functions/python/integ/cliq/handlers/installation_handler.py +0 -12
  100. package/templates/init/functions/python/integ/cliq/handlers/installation_validator.py +0 -16
@@ -0,0 +1,41 @@
1
+ //$Id$
2
+ package com.handlers;
3
+
4
+ import com.zc.cliq.enums.EXTENSION_TYPE;
5
+ import com.zc.cliq.enums.STATUS;
6
+ import com.zc.cliq.objects.InstallationResponse;
7
+ import com.zc.cliq.requests.ExtensionHandlerRequest;
8
+
9
+ public class ExtensionHandler implements com.zc.cliq.interfaces.ExtensionHandler{
10
+
11
+ @Override
12
+ public InstallationResponse validateInstallation(ExtensionHandlerRequest req) throws Exception {
13
+ InstallationResponse resp = InstallationResponse.getInstance();
14
+ if (req.getUser().getFirstName().equals("**INVALID_USER**") && req.getAppInfo().getType().equals(EXTENSION_TYPE.UPGRADE)) {
15
+ resp.setStatus(STATUS.FAILURE);
16
+ resp.setTitle("Update not allowed !");
17
+ resp.setMessage("Sorry. Update not allowed for the current app. Please contact admin.");
18
+ } else {
19
+ resp.setStatus(STATUS.SUCCESS);
20
+ }
21
+ return resp;
22
+ }
23
+
24
+ @Override
25
+ public InstallationResponse handleInstallation(ExtensionHandlerRequest req) throws Exception {
26
+ InstallationResponse resp = InstallationResponse.getInstance();
27
+ /*
28
+ * // Logic for installation post handling {
29
+ *
30
+ * }
31
+ */
32
+ resp.setStatus(STATUS.SUCCESS);
33
+ return resp;
34
+ }
35
+
36
+ @Override
37
+ public void handleUninstallation(ExtensionHandlerRequest req) throws Exception {
38
+ // Logic for uninstallation post handling
39
+ }
40
+
41
+ }
@@ -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
+ */
@@ -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
  }
@@ -51,8 +51,8 @@ command.suggestionHandler(async (req, res) => {
51
51
  suggestion3.imageurl = 'https://www.zohowebstatic.com/sites/default/files/styles/product-home-page/public/catalyst-icon.png';
52
52
 
53
53
  res.push(suggestion1,suggestion2,suggestion3);
54
- return res;
55
54
  }
55
+ return res;
56
56
  });
57
57
 
58
58
  function getForm() {
@@ -63,10 +63,8 @@ function getForm() {
63
63
  form.button_label = 'Raise Request';
64
64
  form.version = 1;
65
65
 
66
- const actions = form.newFormActionsObject();
67
- actions.submit = actions.newFormAction('formFunctionLatest');// ** ENTER YOUR FORM FUNCTION NAME HERE **
68
-
69
- form.actions = actions;
66
+ const action = form.newFormAction('formFunctionLatest');// ** ENTER YOUR FORM FUNCTION NAME HERE **
67
+ form.action = action;
70
68
 
71
69
  const userName = form.newFormInput();
72
70
  userName.type = 'text';
@@ -1,8 +1,8 @@
1
- 'use strict'
1
+ 'use strict';
2
2
  import Cliq from 'zcatalyst-integ-cliq';
3
- const installationValidator = Cliq.installationValidator();
3
+ const extensionHandler = Cliq.extensionHandler();
4
4
 
5
- installationValidator.validateInstallation(async (req, res) => {
5
+ extensionHandler.validateInstallation(async (req, res) => {
6
6
  if(comp(req.user.first_name, '**INVALID_USER**') && comp(req.app_info.type, 'upgrade')) {
7
7
  res.status = 400;
8
8
  res.title = 'Update not allowed !';
@@ -13,6 +13,23 @@ installationValidator.validateInstallation(async (req, res) => {
13
13
  return res;
14
14
  });
15
15
 
16
+ extensionHandler.handleInstallation(async (req, res) => {
17
+ /*
18
+ // Logic for installation post handling
19
+ *{
20
+ *
21
+ *}
22
+ */
23
+
24
+ res.status = 200;
25
+ return res;
26
+ });
27
+
28
+ extensionHandler.handleUninstallation(async (req, res) => {
29
+
30
+ // Logic for uninstallation post handling
31
+ });
32
+
16
33
  function comp(var1, var2) {
17
34
  return var1.toUpperCase() === var2.toUpperCase();
18
35
  }
@@ -218,6 +218,48 @@ functionHandler.formDynamicFieldHandler(async (req, res) => {
218
218
  return res;
219
219
  });
220
220
 
221
+ functionHandler.formViewHandler(async (req, res) => {
222
+ res.title = 'Asset Request';
223
+ res.hint = 'Raise your asset request';
224
+ res.name = 'ID';
225
+ res.button_label = 'Raise Request';
226
+ res.version = 1;
227
+
228
+ const userName = res.newFormInput();
229
+ userName.type = 'text';
230
+ userName.name = 'username';
231
+ userName.label = 'Name';
232
+ userName.hint = 'Please enter your name';
233
+ userName.placeholder = 'John Reese';
234
+ userName.mandatory = true;
235
+ userName.value = 'Harold Finch';
236
+ res.addInputs(userName);
237
+
238
+ const email = res.newFormInput();
239
+ email.type = 'text';
240
+ email.format = 'email';
241
+ email.name = 'email';
242
+ email.label = 'Email';
243
+ email.hint = 'Enter your email address';
244
+ email.placeholder = "johnreese@poi.com";
245
+ email.mandatory = true;
246
+ email.value = "haroldfinch@samaritan.com";
247
+
248
+ const assetType = res.newFormInput();
249
+ assetType.type = 'select';
250
+ assetType.trigger_on_change = true;
251
+ assetType.name = 'asset-type';
252
+ assetType.label = "Asset Type";
253
+ assetType.hint = "Choose your request asset type";
254
+ assetType.placeholder = "Mobile";
255
+ assetType.mandatory = true;
256
+ assetType.addOption(assetType.newFormValue('Laptop', 'laptop'));
257
+ assetType.addOption(assetType.newFormValue('Mobile', 'mobile'));
258
+
259
+ res.addInputs(email, assetType);
260
+ return res;
261
+ });
262
+
221
263
  functionHandler.widgetButtonHandler(async (req, res) => {
222
264
  const id = req.target.id;
223
265
  switch(id) {
@@ -0,0 +1,73 @@
1
+ 'use strict';
2
+ import Cliq from 'zcatalyst-integ-cliq';
3
+ const linkPreviewHandler = Cliq.linkPreviewHandler();
4
+
5
+ linkPreviewHandler.previewHandler(async (req, res) => {
6
+ res.title = 'Release checklist | Zoho Cliq';
7
+ res.type = 'link';
8
+ res.provider_url = 'https://www.zoho.com/cliq/';
9
+ res.description = 'Release checklist for Cliq 5.0 (Focused on Enterprise and Intelligence)';
10
+ res.dynamic_actions = true;
11
+
12
+ let fields = res.newOembedFields();
13
+ let fieldsData = [];
14
+ fieldsData.push(fields.newOembedFieldData('Created By','Scott fisher'));
15
+ fieldsData.push(fields.newOembedFieldData('Created On', '10 Aug, 2023'));
16
+ fieldsData.push(fields.newOembedFieldData('Last Modified On', '11 Aug, 2023'));
17
+ fieldsData.push(fields.newOembedFieldData('Tags', '#unfurling_via_extensions #images_and_cards #cliq_360 #Cliq_5.0'));
18
+ fields.data = fieldsData;
19
+ res.fields = fields;
20
+
21
+ let actions = [];
22
+ const action = res.newOembedActions();
23
+ action.type = 'button';
24
+ action.label = 'Add Comment';
25
+ const confirm = action.newConfirm();
26
+ confirm.title = 'Comment';
27
+ confirm.description = 'Add your comment to the notes';
28
+ confirm.input = 'Type here...';
29
+ action.confirm = confirm;
30
+ let params = {'action': 'add_comment'};
31
+ action.params = params;
32
+ actions.push(action);
33
+ res.actions = actions;
34
+
35
+ return res;
36
+ });
37
+
38
+ linkPreviewHandler.actionHandler(async (req, res) => {
39
+ const action = req.target.params.action;
40
+ let text;
41
+ if(action === "add_comment")
42
+ {
43
+ text = "Your comment has been added successfully";
44
+ }
45
+ else if(action === "delete_note")
46
+ {
47
+ text = "Release checklist | Zoho Cliq note has been deleted";
48
+ }
49
+ else if(action === "mark_as_favorite")
50
+ {
51
+ text = "Release checklist | Zoho Cliq note has been marked as favorite";
52
+ }
53
+ return res.newBanner(text,'success');
54
+ });
55
+
56
+ linkPreviewHandler.menuHandler(async (req, res) => {
57
+
58
+ let action1 = linkPreviewHandler.newOembedActions('button');
59
+ action1.label = 'Delete';
60
+ action1.params = {'action': 'delete_note'};
61
+ res.push(action1);
62
+
63
+ let action2 = linkPreviewHandler.newOembedActions('button');
64
+ action2.label = 'Mark as Favorite';
65
+ action2.params = {'action': 'mark_as_favorite'};
66
+ res.push(action2);
67
+
68
+ return res;
69
+ });
70
+
71
+ linkPreviewHandler.afterSendHandler(async (req, res) => {
72
+ return res.newBanner('Release checklist | Zoho Cliq 5.0','success');
73
+ });
@@ -1,4 +1,6 @@
1
1
  import json
2
+ import logging
3
+
2
4
  from zcatalyst_cliq.bot_handler import (
3
5
  welcome_handler,
4
6
  message_handler,
@@ -7,6 +9,7 @@ from zcatalyst_cliq.bot_handler import (
7
9
  menu_action_handler,
8
10
  webhook_handler,
9
11
  participation_handler,
12
+ call_handler,
10
13
  BotWelcomeHandlerRequest,
11
14
  BotMessageHandlerRequest,
12
15
  BotContextHandlerRequest,
@@ -14,10 +17,12 @@ from zcatalyst_cliq.bot_handler import (
14
17
  BotMenuActionHandlerRequest,
15
18
  BotParticipationHandlerRequest,
16
19
  BotWebHookHandlerRequest,
17
- HandlerResponse
20
+ HandlerResponse,
21
+ BotCallHandlerRequest
18
22
  )
19
- from zcatalyst_sdk.catalyst_app import CatalystApp
20
- import logging
23
+ from zcatalyst_cliq.response_types import VoidResponse
24
+ from zcatalyst_sdk import CatalystApp
25
+
21
26
 
22
27
  @welcome_handler
23
28
  def welcome_handler_fn(req: BotWelcomeHandlerRequest, res: HandlerResponse, *args):
@@ -172,3 +177,8 @@ def webhook_fn(req: BotWebHookHandlerRequest, res: HandlerResponse, *args):
172
177
  res.add_slides(gif_slide)
173
178
 
174
179
  return res
180
+
181
+ @call_handler
182
+ def call(req: BotCallHandlerRequest, res:VoidResponse):
183
+ # Logic for bot call post handling
184
+ return res