zcatalyst-cli 1.18.0-beta.9 → 1.19.0

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 (148) hide show
  1. package/README.md +11 -6
  2. package/docs/commands/signals/generate/index.toml +19 -0
  3. package/docs/commands/slate/unlink.toml +9 -0
  4. package/docs/endpoints/lib/env.toml +3 -1
  5. package/docs/endpoints/lib/slate.toml +3 -0
  6. package/docs/serve/server/lib/slate/index.toml +14 -0
  7. package/docs/slate-utils.toml +4 -0
  8. package/docs/util_modules/config/lib/slate.toml +4 -0
  9. package/lib/archiver.js +18 -9
  10. package/lib/authentication/login.js +6 -5
  11. package/lib/code-deck.js +5 -6
  12. package/lib/command_needs/auth.js +1 -1
  13. package/lib/command_needs/rc.js +40 -3
  14. package/lib/commands/codelib/install.js +1 -0
  15. package/lib/commands/deploy/index.js +4 -0
  16. package/lib/commands/deploy/slate.js +58 -0
  17. package/lib/commands/event/generate/index.js +8 -2
  18. package/lib/commands/index.js +3 -3
  19. package/lib/commands/init.js +0 -10
  20. package/lib/commands/signals/generate/index.js +214 -0
  21. package/lib/commands/slate/create.js +59 -0
  22. package/lib/commands/slate/link.js +59 -0
  23. package/lib/commands/slate/unlink.js +75 -0
  24. package/lib/commands/zest/generate/index.js +1 -6
  25. package/lib/config-store.js +2 -1
  26. package/lib/deploy/features/index.js +3 -0
  27. package/lib/deploy/features/slate.js +123 -0
  28. package/lib/endpoints/index.js +8 -1
  29. package/lib/endpoints/lib/env.js +2 -1
  30. package/lib/endpoints/lib/sdk.js +2 -2
  31. package/lib/endpoints/lib/slate.js +107 -0
  32. package/lib/event_generate/cache.js +35 -33
  33. package/lib/event_generate/custom.js +15 -19
  34. package/lib/event_generate/datastore.js +60 -56
  35. package/lib/event_generate/filestore.js +51 -47
  36. package/lib/event_generate/github.js +19 -18
  37. package/lib/event_generate/stratus.js +52 -38
  38. package/lib/event_generate/user.js +33 -29
  39. package/lib/event_generate/webapp.js +33 -32
  40. package/lib/fn-utils/lib/common.js +1 -1
  41. package/lib/iac/status/deploy.js +1 -5
  42. package/lib/index.js +1 -1
  43. package/lib/init/features/appsail/index.js +3 -4
  44. package/lib/init/features/index.js +13 -1
  45. package/lib/init/features/project.js +1 -1
  46. package/lib/init/features/slate/index.js +313 -0
  47. package/lib/internal/api.js +1 -1
  48. package/lib/internal/command.js +10 -6
  49. package/lib/port-resolver.js +7 -0
  50. package/lib/prompt/index.js +22 -6
  51. package/lib/prompt/types/file-path.js +10 -7
  52. package/lib/serve/features/index.js +8 -1
  53. package/lib/serve/features/slate.js +47 -0
  54. package/lib/serve/server/index.js +61 -1
  55. package/lib/serve/server/lib/appsail/index.js +1 -1
  56. package/lib/serve/server/lib/master/appsail.js +7 -2
  57. package/lib/serve/server/lib/master/index.js +25 -21
  58. package/lib/serve/server/lib/master/slate.js +45 -0
  59. package/lib/serve/server/lib/master/utils.js +9 -3
  60. package/lib/serve/server/lib/slate/index.js +115 -0
  61. package/lib/serve/server/lib/slate/static-server.js +194 -0
  62. package/lib/serve/server/lib/web_client/server.js +2 -1
  63. package/lib/shell/dependencies/local-function.js +1 -1
  64. package/lib/slate-utils.js +212 -0
  65. package/lib/util_modules/config/index.js +3 -1
  66. package/lib/util_modules/config/lib/slate.js +98 -0
  67. package/lib/util_modules/constants/index.js +7 -1
  68. package/lib/util_modules/constants/lib/cliq-handlers.js +18 -10
  69. package/lib/util_modules/constants/lib/dc-type.js +8 -0
  70. package/lib/util_modules/constants/lib/default.js +4 -0
  71. package/lib/util_modules/constants/lib/file-names.js +7 -1
  72. package/lib/util_modules/constants/lib/folder-names.js +1 -0
  73. package/lib/util_modules/constants/lib/placeholders.js +18 -1
  74. package/lib/util_modules/constants/lib/scopes.js +1 -6
  75. package/lib/util_modules/constants/lib/signals-api-names.js +19 -0
  76. package/lib/util_modules/constants/lib/signals-publishers-type.js +27 -0
  77. package/lib/util_modules/constants/lib/signals-publishers.js +10 -0
  78. package/lib/util_modules/constants/lib/template.js +1 -0
  79. package/lib/util_modules/context-help.js +2 -2
  80. package/lib/util_modules/fs/lib/async.js +14 -3
  81. package/lib/util_modules/fs/lib/sync.js +6 -1
  82. package/lib/util_modules/parser/toml.js +20 -5
  83. package/package.json +3 -3
  84. package/templates/event/integ/cliq/bot/action_handler.json +13 -4
  85. package/templates/event/integ/cliq/bot/call_handler.json +41 -0
  86. package/templates/event/integ/cliq/bot/context_handler.json +11 -3
  87. package/templates/event/integ/cliq/bot/incomingwebhook_handler.json +11 -3
  88. package/templates/event/integ/cliq/bot/mention_handler.json +12 -4
  89. package/templates/event/integ/cliq/bot/message_handler.json +13 -4
  90. package/templates/event/integ/cliq/bot/participation_handler.json +13 -3
  91. package/templates/event/integ/cliq/bot/welcome_handler.json +12 -8
  92. package/templates/event/integ/cliq/command/execution_handler.json +12 -3
  93. package/templates/event/integ/cliq/command/suggestion_handler.json +18 -4
  94. package/templates/event/integ/cliq/{installation → extension}/installation_handler.json +13 -4
  95. package/templates/event/integ/cliq/{installation → extension}/installation_validator.json +13 -5
  96. package/templates/event/integ/cliq/extension/uninstallation_handler.json +37 -0
  97. package/templates/event/integ/cliq/function/button_handler.json +13 -5
  98. package/templates/event/integ/cliq/function/form_change_handler.json +9 -3
  99. package/templates/event/integ/cliq/function/form_handler.json +11 -3
  100. package/templates/event/integ/cliq/function/form_values_handler.json +9 -3
  101. package/templates/event/integ/cliq/function/form_view_handler.json +26 -0
  102. package/templates/event/integ/cliq/function/widget_button_handler.json +14 -5
  103. package/templates/event/integ/cliq/link_preview/action_handler.json +54 -0
  104. package/templates/event/integ/cliq/link_preview/after_send_handler.json +47 -0
  105. package/templates/event/integ/cliq/link_preview/menu_handler.json +47 -0
  106. package/templates/event/integ/cliq/link_preview/preview_handler.json +47 -0
  107. package/templates/event/integ/cliq/messageaction/execution_handler.json +11 -3
  108. package/templates/event/integ/cliq/widget/view_handler.json +12 -4
  109. package/templates/event/signals.json +26 -0
  110. package/templates/init/client/react/react_js/template/src/index.js +3 -3
  111. package/templates/init/client/react/react_ts/template/src/index.tsx +3 -3
  112. package/templates/init/client/react/react_ts/template.json +3 -3
  113. package/templates/init/functions/java/event/sample.java +4 -0
  114. package/templates/init/functions/java/integ/cliq/com/handlers/BotHandler.java +29 -23
  115. package/templates/init/functions/java/integ/cliq/com/handlers/CommandHandler.java +14 -17
  116. package/templates/init/functions/java/integ/cliq/com/handlers/ExtensionHandler.java +41 -0
  117. package/templates/init/functions/java/integ/cliq/com/handlers/FunctionHandler.java +74 -22
  118. package/templates/init/functions/java/integ/cliq/com/handlers/LinkPreviewHandler.java +108 -0
  119. package/templates/init/functions/java/integ/cliq/com/handlers/MessageActionHandler.java +6 -8
  120. package/templates/init/functions/java/integ/cliq/sample.java +10 -0
  121. package/templates/init/functions/node/aio/package.json +1 -1
  122. package/templates/init/functions/node/bio/package.json +1 -1
  123. package/templates/init/functions/node/cron/package.json +1 -1
  124. package/templates/init/functions/node/event/package.json +1 -1
  125. package/templates/init/functions/node/event/sample.js +1 -0
  126. package/templates/init/functions/node/event/types/event.d.ts +7 -0
  127. package/templates/init/functions/node/integ/cliq/handlers/bot-handler.js +4 -0
  128. package/templates/init/functions/node/integ/cliq/handlers/command-handler.js +3 -5
  129. package/templates/init/functions/node/integ/cliq/handlers/{installation-validator.js → extension-handler.js} +20 -3
  130. package/templates/init/functions/node/integ/cliq/handlers/function-handler.js +42 -0
  131. package/templates/init/functions/node/integ/cliq/handlers/link-preview-handler.js +73 -0
  132. package/templates/init/functions/node/integ/cliq/package.json +1 -1
  133. package/templates/init/functions/node/integ/convokraft/package.json +1 -1
  134. package/templates/init/functions/node/job/package.json +1 -1
  135. package/templates/init/functions/python/event/sample.py +9 -5
  136. package/templates/init/functions/python/integ/cliq/handlers/bot_handler.py +13 -3
  137. package/templates/init/functions/python/integ/cliq/handlers/command_handler.py +7 -7
  138. package/templates/init/functions/python/integ/cliq/handlers/extension_handler.py +25 -0
  139. package/templates/init/functions/python/integ/cliq/handlers/function_handler.py +54 -10
  140. package/templates/init/functions/python/integ/cliq/handlers/link_preview_handler.py +76 -0
  141. package/templates/init/functions/python/integ/cliq/handlers/widget_handler.py +10 -9
  142. package/templates/init/functions/python/integ/cliq/sample.py +2 -2
  143. package/templates/init.txt +2 -1
  144. package/templates/init/functions/java/integ/cliq/com/handlers/InstallationHandler.java +0 -20
  145. package/templates/init/functions/java/integ/cliq/com/handlers/InstallationValidator.java +0 -22
  146. package/templates/init/functions/node/integ/cliq/handlers/installation-handler.js +0 -15
  147. package/templates/init/functions/python/integ/cliq/handlers/installation_handler.py +0 -12
  148. package/templates/init/functions/python/integ/cliq/handlers/installation_validator.py +0 -16
@@ -1,14 +1,14 @@
1
1
  import React from 'react';
2
- import ReactDOM from 'react-dom';
2
+ import ReactDOM, { Container } from 'react-dom/client';
3
3
  import './index.css';
4
4
  import App from './App';
5
5
  import reportWebVitals from './reportWebVitals';
6
6
 
7
- ReactDOM.render(
7
+ const root = ReactDOM.createRoot(document.getElementById('root') as Container);
8
+ root.render(
8
9
  <React.StrictMode>
9
10
  <App />
10
11
  </React.StrictMode>,
11
- document.getElementById('root')
12
12
  );
13
13
 
14
14
  // If you want to start measuring performance in your app, pass a function
@@ -4,9 +4,9 @@
4
4
  "@testing-library/jest-dom": "^5.11.4",
5
5
  "@testing-library/react": "^11.1.0",
6
6
  "@testing-library/user-event": "^12.1.10",
7
- "@types/node": "^12.0.0",
8
- "@types/react": "^17.0.0",
9
- "@types/react-dom": "^17.0.0",
7
+ "@types/node": "latest",
8
+ "@types/react": "latest",
9
+ "@types/react-dom": "latest",
10
10
  "@types/jest": "^26.0.15",
11
11
  "typescript": "^4.1.2",
12
12
  "web-vitals": "^1.0.1"
@@ -24,6 +24,10 @@ public class {{_CLASS_}} implements CatalystEventHandler{
24
24
  ZCProject.initProject();
25
25
  Object eventData = paramEventRequest.getData();
26
26
  LOGGER.log(Level.SEVERE,"Data is "+eventData.toString());
27
+
28
+ Object rawData = paramEventRequest.getRawData();
29
+ LOGGER.log(Level.SEVERE,"Raw Data is "+rawData.toString());
30
+
27
31
  ZCCache.getInstance().putCacheValue("{{_CLASS_}}", "Working", 1l);
28
32
  LOGGER.log(Level.SEVERE,"Project Details "+paramEventRequest.getProjectDetails().toString());
29
33
  }
@@ -23,6 +23,7 @@ import com.zc.cliq.objects.ButtonObject;
23
23
  import com.zc.cliq.objects.CardDetails;
24
24
  import com.zc.cliq.objects.Message;
25
25
  import com.zc.cliq.objects.Slide;
26
+ import com.zc.cliq.requests.BotCallHandlerRequest;
26
27
  import com.zc.cliq.requests.BotContextHandlerRequest;
27
28
  import com.zc.cliq.requests.BotMentionHandlerRequest;
28
29
  import com.zc.cliq.requests.BotMenuActionHandlerRequest;
@@ -30,6 +31,8 @@ import com.zc.cliq.requests.BotMessageHandlerRequest;
30
31
  import com.zc.cliq.requests.BotParticipationHandlerRequest;
31
32
  import com.zc.cliq.requests.BotWebhookHandlerRequest;
32
33
  import com.zc.cliq.requests.BotWelcomeHandlerRequest;
34
+ import com.zc.cliq.responses.CoreResponse;
35
+ import com.zc.cliq.responses.WebhookHandlerResponse;
33
36
  import com.zc.cliq.util.ZCCliqUtil;
34
37
  import com.zc.component.cache.ZCCache;
35
38
 
@@ -37,18 +40,18 @@ public class BotHandler implements com.zc.cliq.interfaces.BotHandler {
37
40
  Logger LOGGER = Logger.getLogger(BotHandler.class.getName());
38
41
 
39
42
  @Override
40
- public Map<String, Object> welcomeHandler(BotWelcomeHandlerRequest req) {
43
+ public Message welcomeHandler(BotWelcomeHandlerRequest req) {
41
44
  String uName = req.getUser() != null ? req.getUser().getFirstName() : "user";
42
45
  String text = "Hello " + uName + ". Thank you for subscribing :smile:";
43
46
  Message msg = Message.getInstance(text);
44
- return ZCCliqUtil.toMap(msg);
47
+ return msg;
45
48
  }
46
49
 
47
50
  @Override
48
- public Map<String, Object> messageHandler(BotMessageHandlerRequest req) {
51
+ public CoreResponse messageHandler(BotMessageHandlerRequest req) throws Exception {
49
52
  try {
50
53
  String message = req.getMessage();
51
- Map<String, Object> resp = new HashMap<String, Object>();
54
+ Message resp = Message.getInstance();
52
55
 
53
56
  String text;
54
57
  if (message == null) {
@@ -60,7 +63,7 @@ public class BotHandler implements com.zc.cliq.interfaces.BotHandler {
60
63
  suggestion.addSuggestion("Not bad");
61
64
  suggestion.addSuggestion("Meh");
62
65
  suggestion.addSuggestion("Worst");
63
- resp.put("suggestions", suggestion);
66
+ resp.setSuggestion(suggestion);
64
67
  } else if (message.equalsIgnoreCase("Good") || message.equalsIgnoreCase("Not bad")) {
65
68
  text = "That's glad to hear :smile:";
66
69
  } else if (message.equalsIgnoreCase("Meh") || message.equalsIgnoreCase("Worst")) {
@@ -90,7 +93,7 @@ public class BotHandler implements com.zc.cliq.interfaces.BotHandler {
90
93
  param3.addSuggestion("NO");
91
94
 
92
95
  context.setParams(param1, param2, param3);
93
- resp.put("context", context);
96
+ resp.setContext(context);
94
97
  } else if (message.equalsIgnoreCase("button")) {
95
98
 
96
99
  Message msg = Message.getInstance("Here's your button");
@@ -104,12 +107,12 @@ public class BotHandler implements com.zc.cliq.interfaces.BotHandler {
104
107
  action.setData(actionData);
105
108
  btnObj.setAction(action);
106
109
  msg.addButton(btnObj);
107
- return ZCCliqUtil.toMap(msg);
110
+ return msg;
108
111
  } else {
109
112
  text = "Sorry, I'm not programmed yet to do this :sad:";
110
113
  }
111
114
 
112
- resp.put("text", text);
115
+ resp.setText(text);
113
116
  return resp;
114
117
 
115
118
  } catch (Exception ex) {
@@ -119,8 +122,8 @@ public class BotHandler implements com.zc.cliq.interfaces.BotHandler {
119
122
  }
120
123
 
121
124
  @Override
122
- public Map<String, Object> contextHandler(BotContextHandlerRequest req) {
123
- Map<String, Object> resp = new HashMap<String, Object>();
125
+ public CoreResponse contextHandler(BotContextHandlerRequest req) throws Exception {
126
+ JSONObject resp = new JSONObject();
124
127
  if (req.getContextId().equals("personal_details")) {
125
128
  Map<String, String> answers = req.getAnswers();
126
129
  StringBuilder str = new StringBuilder();
@@ -140,20 +143,18 @@ public class BotHandler implements com.zc.cliq.interfaces.BotHandler {
140
143
 
141
144
  resp.put("text", "Nice ! I have collected your info: \n" + str.toString());
142
145
  }
143
- return resp;
146
+ return ZCCliqUtil.mapper.readValue(resp.toString(), Message.class);
144
147
  }
145
148
 
146
149
  @Override
147
- public Map<String, Object> mentionHandler(BotMentionHandlerRequest req) {
150
+ public CoreResponse mentionHandler(BotMentionHandlerRequest req) {
148
151
  String text = "Hey *" + req.getUser().getFirstName() + "*, thanks for mentioning me here. I'm from Catalyst city";
149
- Map<String, Object> resp = new HashMap<String, Object>();
150
- resp.put("text", text);
151
- return resp;
152
+ Message msg = Message.getInstance(text);
153
+ return msg;
152
154
  }
153
155
 
154
156
  @Override
155
- public Map<String, Object> menuActionHandler(BotMenuActionHandlerRequest req) {
156
- Map<String, Object> resp = new HashMap<String, Object>();
157
+ public CoreResponse menuActionHandler(BotMenuActionHandlerRequest req) {
157
158
  String text;
158
159
  if (req.getActionName().equals("Say Hi")) {
159
160
  text = "Hi";
@@ -162,12 +163,12 @@ public class BotHandler implements com.zc.cliq.interfaces.BotHandler {
162
163
  } else {
163
164
  text = "Menu action triggered :fist:";
164
165
  }
165
- resp.put("text", text);
166
- return resp;
166
+ Message msg = Message.getInstance(text);
167
+ return msg;
167
168
  }
168
169
 
169
170
  @Override
170
- public Map<String, Object> webhookHandler(BotWebhookHandlerRequest req) throws Exception {
171
+ public WebhookHandlerResponse webhookHandler(BotWebhookHandlerRequest req) throws Exception {
171
172
  // Sample handler class for incoming mails in ZohoMail
172
173
  // Please configure the bot in ZohoMail's outgoing webhooks
173
174
  JSONObject reqBody = req.getBody();
@@ -205,11 +206,11 @@ public class BotHandler implements com.zc.cliq.interfaces.BotHandler {
205
206
 
206
207
  msg.addSlide(gifSlide);
207
208
 
208
- return ZCCliqUtil.toMap(msg);
209
+ return msg;
209
210
  }
210
211
 
211
212
  @Override
212
- public Map<String, Object> participationHandler(BotParticipationHandlerRequest req) throws Exception {
213
+ public CoreResponse participationHandler(BotParticipationHandlerRequest req) throws Exception {
213
214
  String text;
214
215
  if (req.getOperation().equals(CHANNEL_OPERATION.ADDED)) {
215
216
  text = "Hi. Thanks for adding me to the channel :smile:";
@@ -219,6 +220,11 @@ public class BotHandler implements com.zc.cliq.interfaces.BotHandler {
219
220
  text = "I'm too a participant of this chat :wink:";
220
221
  }
221
222
  Message msg = Message.getInstance(text);
222
- return ZCCliqUtil.toMap(msg);
223
+ return msg;
224
+ }
225
+
226
+ @Override
227
+ public void callHandler(BotCallHandlerRequest req) throws Exception {
228
+ // Logic for bot call post handling
223
229
  }
224
230
  }
@@ -2,24 +2,23 @@
2
2
  package com.handlers;
3
3
 
4
4
  import java.util.ArrayList;
5
- import java.util.HashMap;
6
5
  import java.util.List;
7
- import java.util.Map;
6
+
8
7
  import com.zc.cliq.enums.FORM_FIELD_TEXT_FORMAT;
9
8
  import com.zc.cliq.enums.FORM_FIELD_TYPE;
10
9
  import com.zc.cliq.objects.CommandSuggestion;
11
10
  import com.zc.cliq.objects.Form;
12
- import com.zc.cliq.objects.FormActionsObject;
11
+ import com.zc.cliq.objects.FormAction;
13
12
  import com.zc.cliq.objects.FormInput;
14
13
  import com.zc.cliq.objects.FormValue;
14
+ import com.zc.cliq.objects.Message;
15
15
  import com.zc.cliq.requests.CommandHandlerRequest;
16
- import com.zc.cliq.util.ZCCliqUtil;
16
+ import com.zc.cliq.responses.CoreResponse;
17
17
 
18
18
  public class CommandHandler implements com.zc.cliq.interfaces.CommandHandler {
19
19
  @Override
20
- public Map<String, Object> executionHandler(CommandHandlerRequest req) throws Exception {
20
+ public CoreResponse executionHandler(CommandHandlerRequest req) throws Exception {
21
21
 
22
- Map<String, Object> resp = new HashMap<String, Object>();
23
22
  String text;
24
23
  String commandName = req.getName();
25
24
  if (commandName.equals("catalystresource")) {
@@ -42,8 +41,8 @@ public class CommandHandler implements com.zc.cliq.interfaces.CommandHandler {
42
41
  text = "Command executed successfully!";
43
42
  }
44
43
 
45
- resp.put("text", text);
46
- return resp;
44
+ Message msg = Message.getInstance(text);
45
+ return msg;
47
46
  }
48
47
 
49
48
  @Override
@@ -60,7 +59,7 @@ public class CommandHandler implements com.zc.cliq.interfaces.CommandHandler {
60
59
  return suggestionList;
61
60
  }
62
61
 
63
- private static Map<String, Object> getForm() {
62
+ private static Form getForm() {
64
63
  Form form = Form.getInstance();
65
64
  form.setTitle("Asset Request");
66
65
  form.setHint("Raise your asset request");
@@ -68,12 +67,10 @@ public class CommandHandler implements com.zc.cliq.interfaces.CommandHandler {
68
67
  form.setButtonLabel("Raise Request");
69
68
  form.setVersion(1);
70
69
 
71
- FormActionsObject actions = FormActionsObject.getInstance();
72
- actions.setSubmitAction("formFunctionLatest"); // ** ENTER YOUR FORM FUNCTION NAME HERE **
73
-
74
- form.setActions(actions);
70
+ FormAction action = FormAction.getInstance("formFunctionLatest"); // ** ENTER YOUR FORM FUNCTION NAME HERE **
71
+ form.setAction(action);
75
72
 
76
- FormInput username = FormInput.getIntance();
73
+ FormInput username = FormInput.getInstance();
77
74
  username.setType(FORM_FIELD_TYPE.TEXT);
78
75
  username.setName("username");
79
76
  username.setLabel("Name");
@@ -83,7 +80,7 @@ public class CommandHandler implements com.zc.cliq.interfaces.CommandHandler {
83
80
  username.setValue("Harold Finch");
84
81
  form.addFormInput(username);
85
82
 
86
- FormInput email = FormInput.getIntance();
83
+ FormInput email = FormInput.getInstance();
87
84
  email.setType(FORM_FIELD_TYPE.TEXT);
88
85
  email.setFormat(FORM_FIELD_TEXT_FORMAT.EMAIL);
89
86
  email.setName("email");
@@ -94,7 +91,7 @@ public class CommandHandler implements com.zc.cliq.interfaces.CommandHandler {
94
91
  email.setValue("haroldfinch@samaritan.com");
95
92
  form.addFormInput(email);
96
93
 
97
- FormInput assetType = FormInput.getIntance();
94
+ FormInput assetType = FormInput.getInstance();
98
95
  assetType.setType(FORM_FIELD_TYPE.SELECT);
99
96
  assetType.setTriggerOnChange(true);
100
97
  assetType.setName("asset-type");
@@ -106,6 +103,6 @@ public class CommandHandler implements com.zc.cliq.interfaces.CommandHandler {
106
103
  assetType.addOption(new FormValue("Mobile", "mobile"));
107
104
  form.addFormInput(assetType);
108
105
 
109
- return ZCCliqUtil.toMap(form);
106
+ return form;
110
107
  }
111
108
  }
@@ -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
+ }