zcatalyst-cli 1.9.1 → 1.11.1

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 (189) hide show
  1. package/README.md +3 -3
  2. package/docs/.DS_Store +0 -0
  3. package/docs/client-utils.toml +5 -0
  4. package/docs/command_needs/auth.toml +5 -0
  5. package/docs/commands/iac/export.toml +4 -0
  6. package/docs/commands/iac/import.toml +4 -0
  7. package/docs/commands/iac/status.toml +4 -0
  8. package/docs/commands/project/use.toml +6 -0
  9. package/docs/iac/status/bundle.toml +4 -0
  10. package/docs/plugin-loader.toml +4 -0
  11. package/docs/serve/server/index.toml +4 -0
  12. package/docs/serve/server/lib/web_client/server.toml +4 -0
  13. package/lib/api-timer.js +81 -0
  14. package/lib/apig-utils.js +17 -14
  15. package/lib/archiver.js +83 -45
  16. package/lib/authentication/login.js +4 -2
  17. package/lib/bin/catalyst.js +0 -1
  18. package/lib/client-utils.js +28 -26
  19. package/lib/client.js +0 -3
  20. package/lib/command_needs/auth.js +12 -3
  21. package/lib/command_needs/rc.js +12 -7
  22. package/lib/commands/apig/status.js +6 -4
  23. package/lib/commands/client/delete.js +3 -4
  24. package/lib/commands/client/setup.js +1 -1
  25. package/lib/commands/deploy.js +3 -1
  26. package/lib/commands/ds/export.js +3 -1
  27. package/lib/commands/ds/import.js +3 -1
  28. package/lib/commands/ds/status.js +145 -149
  29. package/lib/commands/event/generate/index.js +4 -13
  30. package/lib/commands/functions/config.js +1 -1
  31. package/lib/commands/functions/setup.js +1 -1
  32. package/lib/commands/help.js +1 -23
  33. package/lib/commands/iac/export.js +85 -0
  34. package/lib/commands/iac/import.js +210 -0
  35. package/lib/commands/iac/pack.js +129 -0
  36. package/lib/commands/iac/status.js +63 -0
  37. package/lib/commands/index.js +4 -0
  38. package/lib/commands/init.js +34 -27
  39. package/lib/commands/project/list.js +10 -6
  40. package/lib/commands/project/use.js +42 -25
  41. package/lib/commands/pull.js +1 -1
  42. package/lib/commands/serve.js +2 -1
  43. package/lib/deploy/features/functions/index.js +2 -1
  44. package/lib/deploy/index.js +3 -1
  45. package/lib/endpoints/lib/iac.js +134 -0
  46. package/lib/endpoints/lib/sdk.js +2 -2
  47. package/lib/error.js +33 -3
  48. package/lib/errorOut.js +4 -3
  49. package/lib/fn-utils/lib/common.js +37 -16
  50. package/lib/fn-utils/lib/java.js +7 -9
  51. package/lib/fn-utils/lib/node.js +7 -1
  52. package/lib/iac/status/bundle.js +82 -0
  53. package/lib/iac/status/deploy.js +74 -0
  54. package/lib/iac/status/util/index.js +26 -0
  55. package/lib/index.js +8 -14
  56. package/lib/init/dependencies/npm-install.js +2 -9
  57. package/lib/init/features/client/index.js +47 -0
  58. package/lib/init/features/client/initializers/angular.js +106 -0
  59. package/lib/init/features/client/initializers/basic.js +50 -0
  60. package/lib/init/features/client/initializers/lyte.js +61 -0
  61. package/lib/init/features/client/initializers/react.js +77 -0
  62. package/lib/init/features/functions/languages/java.js +2 -5
  63. package/lib/init/features/functions/languages/node.js +5 -6
  64. package/lib/init/features/index.js +18 -6
  65. package/lib/init/features/project.js +72 -34
  66. package/lib/init/util/client.js +96 -0
  67. package/lib/init/util/functions.js +20 -0
  68. package/lib/init/util/project.js +35 -0
  69. package/lib/internal/api.js +6 -9
  70. package/lib/internal/command.js +6 -3
  71. package/lib/internal/config.js +7 -4
  72. package/lib/migration/index.js +10 -6
  73. package/lib/option-filter.js +4 -1
  74. package/lib/optional-import.js +11 -25
  75. package/lib/plugin-loader.js +8 -2
  76. package/lib/port-resolver.js +20 -16
  77. package/lib/prompt/index.js +92 -0
  78. package/lib/prompt/types/file-path.js +95 -0
  79. package/lib/pull/features/client.js +1 -1
  80. package/lib/pull/features/functions/index.js +5 -7
  81. package/lib/pull/index.js +4 -1
  82. package/lib/serve/features/index.js +3 -1
  83. package/lib/serve/index.js +6 -1
  84. package/lib/serve/server/index.js +52 -8
  85. package/lib/serve/server/lib/master.js +24 -12
  86. package/lib/serve/server/lib/web_client/index.js +30 -0
  87. package/lib/serve/server/lib/web_client/server.js +171 -0
  88. package/lib/shell/dependencies/http-functions.js +1 -1
  89. package/lib/shell/index.js +3 -1
  90. package/lib/track.js +3 -1
  91. package/lib/util_modules/char.js +1 -1
  92. package/lib/util_modules/config/lib/apig.js +2 -1
  93. package/lib/util_modules/constants/index.js +5 -1
  94. package/lib/util_modules/constants/lib/file-names.js +2 -1
  95. package/lib/util_modules/constants/lib/iac.js +8 -0
  96. package/lib/util_modules/constants/lib/placeholders.js +1 -0
  97. package/lib/util_modules/constants/lib/plugin.js +28 -0
  98. package/lib/util_modules/constants/lib/regex.js +2 -1
  99. package/lib/util_modules/constants/lib/scopes.js +5 -0
  100. package/lib/util_modules/constants/lib/template.js +11 -1
  101. package/lib/util_modules/constants/lib/urls.js +12 -4
  102. package/lib/util_modules/constants/project.js +6 -0
  103. package/lib/util_modules/{contextHelp.js → context-help.js} +5 -1
  104. package/lib/util_modules/env.js +14 -16
  105. package/lib/util_modules/fs/lib/async.js +29 -22
  106. package/lib/util_modules/fs/utils.js +8 -0
  107. package/lib/util_modules/global-space.js +99 -0
  108. package/lib/util_modules/js.js +6 -0
  109. package/lib/util_modules/option.js +5 -1
  110. package/lib/util_modules/parser/toml.js +5 -1
  111. package/lib/util_modules/project.js +3 -0
  112. package/lib/util_modules/shell.js +9 -8
  113. package/lib/winston.js +1 -1
  114. package/package.json +11 -5
  115. package/templates/.DS_Store +0 -0
  116. package/templates/iacSuccess.html +391 -0
  117. package/templates/init/.DS_Store +0 -0
  118. package/templates/init/client/.DS_Store +0 -0
  119. package/templates/init/client/{client-package.json → basic/client-package.json} +0 -0
  120. package/templates/init/client/{index.html → basic/index.html} +0 -0
  121. package/templates/init/client/{main.css → basic/main.css} +0 -0
  122. package/templates/init/client/{main.js → basic/main.js} +0 -0
  123. package/templates/init/client/lyte/build/build.js +301 -0
  124. package/templates/init/client/lyte/build/scripts/cliDownloadScript.js +54 -0
  125. package/templates/init/client/lyte/client-package.json +5 -0
  126. package/templates/init/client/lyte/components/javascript/welcome-comp.js +13 -0
  127. package/templates/init/client/lyte/components/styles/welcome-comp.css +0 -0
  128. package/templates/init/client/lyte/components/templates/welcome-comp.html +8 -0
  129. package/templates/init/client/lyte/data-store/adapters/.gitkeep +0 -0
  130. package/templates/init/client/lyte/data-store/models/.gitkeep +0 -0
  131. package/templates/init/client/lyte/data-store/serializers/.gitkeep +0 -0
  132. package/templates/init/client/lyte/index.html +17 -0
  133. package/templates/init/client/lyte/package.json +12 -0
  134. package/templates/init/client/lyte/router.js +14 -0
  135. package/templates/init/client/lyte/routes/index.js +54 -0
  136. package/templates/init/client/react/.DS_Store +0 -0
  137. package/templates/init/client/react/react_js/package.json +11 -0
  138. package/templates/init/client/react/react_js/template/README.md +70 -0
  139. package/templates/init/client/react/react_js/template/client-package.json +5 -0
  140. package/templates/init/client/react/react_js/template/gitignore +23 -0
  141. package/templates/init/client/react/react_js/template/public/favicon.ico +0 -0
  142. package/templates/init/client/react/react_js/template/public/index.html +43 -0
  143. package/templates/init/client/react/react_js/template/public/logo192.png +0 -0
  144. package/templates/init/client/react/react_js/template/public/logo512.png +0 -0
  145. package/templates/init/client/react/react_js/template/public/manifest.json +25 -0
  146. package/templates/init/client/react/react_js/template/public/robots.txt +3 -0
  147. package/templates/init/client/react/react_js/template/src/App.css +38 -0
  148. package/templates/init/client/react/react_js/template/src/App.js +25 -0
  149. package/templates/init/client/react/react_js/template/src/App.test.js +8 -0
  150. package/templates/init/client/react/react_js/template/src/index.css +13 -0
  151. package/templates/init/client/react/react_js/template/src/index.js +17 -0
  152. package/templates/init/client/react/react_js/template/src/logo.svg +1 -0
  153. package/templates/init/client/react/react_js/template/src/reportWebVitals.js +13 -0
  154. package/templates/init/client/react/react_js/template/src/setupTests.js +5 -0
  155. package/templates/init/client/react/react_js/template.json +13 -0
  156. package/templates/init/client/react/react_ts/package.json +11 -0
  157. package/templates/init/client/react/react_ts/template/README.md +46 -0
  158. package/templates/init/client/react/react_ts/template/client-package.json +5 -0
  159. package/templates/init/client/react/react_ts/template/gitignore +23 -0
  160. package/templates/init/client/react/react_ts/template/public/favicon.ico +0 -0
  161. package/templates/init/client/react/react_ts/template/public/index.html +43 -0
  162. package/templates/init/client/react/react_ts/template/public/logo192.png +0 -0
  163. package/templates/init/client/react/react_ts/template/public/logo512.png +0 -0
  164. package/templates/init/client/react/react_ts/template/public/manifest.json +25 -0
  165. package/templates/init/client/react/react_ts/template/public/robots.txt +3 -0
  166. package/templates/init/client/react/react_ts/template/src/App.css +38 -0
  167. package/templates/init/client/react/react_ts/template/src/App.test.tsx +9 -0
  168. package/templates/init/client/react/react_ts/template/src/App.tsx +26 -0
  169. package/templates/init/client/react/react_ts/template/src/index.css +13 -0
  170. package/templates/init/client/react/react_ts/template/src/index.tsx +17 -0
  171. package/templates/init/client/react/react_ts/template/src/logo.svg +1 -0
  172. package/templates/init/client/react/react_ts/template/src/reportWebVitals.ts +15 -0
  173. package/templates/init/client/react/react_ts/template/src/setupTests.ts +5 -0
  174. package/templates/init/client/react/react_ts/template.json +18 -0
  175. package/templates/init/functions/java/integ/cliq/com/handlers/BotHandler.java +94 -109
  176. package/templates/init/functions/java/integ/cliq/com/handlers/CommandHandler.java +20 -27
  177. package/templates/init/functions/java/integ/cliq/com/handlers/FunctionHandler.java +143 -112
  178. package/templates/init/functions/java/integ/cliq/com/handlers/InstallationHandler.java +4 -7
  179. package/templates/init/functions/java/integ/cliq/com/handlers/InstallationValidator.java +4 -7
  180. package/templates/init/functions/java/integ/cliq/com/handlers/MessageActionHandler.java +10 -12
  181. package/templates/init/functions/java/integ/cliq/com/handlers/WidgetHandler.java +100 -66
  182. package/templates/init/functions/java/integ/cliq/sample.java +5 -7
  183. package/templates/init/functions/node/integ/cliq/handlers/command-handler.js +0 -1
  184. package/templates/init/functions/node/integ/cliq/handlers/function-handler.js +46 -0
  185. package/templates/init/functions/node/integ/cliq/handlers/widget-handler.js +31 -0
  186. package/templates/web-socket.txt +21 -0
  187. package/lib/init/features/client.js +0 -51
  188. package/lib/prompt.js +0 -49
  189. package/lib/serve/server/lib/client.js +0 -30
@@ -7,6 +7,7 @@ import java.util.Arrays;
7
7
  import java.util.Date;
8
8
  import java.util.List;
9
9
  import java.util.Map;
10
+ import java.util.logging.Logger;
10
11
 
11
12
  import org.json.JSONArray;
12
13
  import org.json.JSONObject;
@@ -15,11 +16,12 @@ import com.zc.cliq.enums.ACTION_TYPE;
15
16
  import com.zc.cliq.enums.BANNER_STATUS;
16
17
  import com.zc.cliq.enums.FORM_FIELD_TYPE;
17
18
  import com.zc.cliq.enums.FORM_MODIFICATION_ACTION_TYPE;
18
- import com.zc.cliq.enums.MESSAGE_TYPE;
19
19
  import com.zc.cliq.enums.SLIDE_TYPE;
20
20
  import com.zc.cliq.enums.SYSTEM_API_ACTION;
21
21
  import com.zc.cliq.enums.WIDGET_ELEMENT_TYPE;
22
+ import com.zc.cliq.enums.WIDGET_NAVIGATION;
22
23
  import com.zc.cliq.enums.WIDGET_TYPE;
24
+ import com.zc.cliq.objects.ButtonObject;
23
25
  import com.zc.cliq.objects.CardDetails;
24
26
  import com.zc.cliq.objects.Form;
25
27
  import com.zc.cliq.objects.FormAction;
@@ -30,10 +32,11 @@ import com.zc.cliq.objects.FormModificationAction;
30
32
  import com.zc.cliq.objects.FormTarget;
31
33
  import com.zc.cliq.objects.FormValue;
32
34
  import com.zc.cliq.objects.Message;
33
- import com.zc.cliq.objects.MessageBuilder;
34
35
  import com.zc.cliq.objects.Slide;
35
36
  import com.zc.cliq.objects.WidgetButton;
36
37
  import com.zc.cliq.objects.WidgetElement;
38
+ import com.zc.cliq.objects.WidgetFooter;
39
+ import com.zc.cliq.objects.WidgetHeader;
37
40
  import com.zc.cliq.objects.WidgetResponse;
38
41
  import com.zc.cliq.objects.WidgetSection;
39
42
  import com.zc.cliq.requests.ButtonFunctionRequest;
@@ -41,67 +44,61 @@ import com.zc.cliq.requests.FormFunctionRequest;
41
44
  import com.zc.cliq.requests.WidgetFunctionRequest;
42
45
  import com.zc.cliq.util.ZCCliqUtil;
43
46
 
44
- public class FunctionHandler implements com.zc.cliq.interfaces.FunctionHandler
45
- {
47
+ public class FunctionHandler implements com.zc.cliq.interfaces.FunctionHandler {
48
+
49
+ Logger LOGGER = Logger.getLogger(FunctionHandler.class.getName());
46
50
 
47
51
  @Override
48
- public Map<String, Object> buttonFunctionHandler(ButtonFunctionRequest req) throws Exception
49
- {
50
- MessageBuilder msg = MessageBuilder.getInstance("Button function executed");
52
+ public Map<String, Object> buttonFunctionHandler(ButtonFunctionRequest req) throws Exception {
53
+ Message msg = Message.getInstance("Button function executed");
51
54
  return ZCCliqUtil.toMap(msg);
52
55
  }
53
-
56
+
54
57
  @Override
55
- public Map<String, Object> formSubmitHandler(FormFunctionRequest req) throws Exception
56
- {
57
- JSONObject values = req.getForm().getValues();
58
-
58
+ public Map<String, Object> formSubmitHandler(FormFunctionRequest req) throws Exception {
59
+ JSONObject values = req.getForm().getValues();
60
+
59
61
  String type = values.optString("type", null);
60
- if(type != null){
61
- if(type.equals("formtab")){
62
+ if (type != null) {
63
+ if (type.equals("formtab")) {
62
64
  WidgetResponse widgetResp = WidgetResponse.getInstance();
63
65
  widgetResp.setType(WIDGET_TYPE.APPLET);
64
-
66
+
65
67
  WidgetSection titleSection = WidgetSection.getInstance();
66
68
  titleSection.setId("100");
67
-
69
+
68
70
  WidgetElement editedBy = WidgetElement.getInstance(WIDGET_ELEMENT_TYPE.TITLE);
69
71
  editedBy.setText("Edited by " + values.optString("text") + " :wink:");
70
72
  titleSection.addElement(editedBy);
71
-
73
+
72
74
  WidgetElement time = WidgetElement.getInstance(WIDGET_ELEMENT_TYPE.SUBTEXT);
73
75
  SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
74
76
  time.setText("Target:buttons\nTime : " + sdf.format(new Date()));
75
77
  titleSection.addElement(time);
76
-
78
+
77
79
  widgetResp.addSection(titleSection);
78
-
80
+
79
81
  WidgetSection buttonSection = getButtonsSection();
80
82
  widgetResp.addSection(buttonSection);
81
-
83
+
82
84
  return ZCCliqUtil.toMap(widgetResp);
83
- }
84
- else if(type.equals("formsection")){
85
+ } else if (type.equals("formsection")) {
85
86
  WidgetSection section = WidgetSection.getInstance();
86
87
  section.setId("102");
87
88
  section.setType("section");
88
89
  WidgetElement editedBy = WidgetElement.getInstance(WIDGET_ELEMENT_TYPE.TITLE);
89
90
  editedBy.setText("Edited by " + values.optString("text") + " :wink:");
90
91
  section.addElement(editedBy);
91
-
92
+
92
93
  return ZCCliqUtil.toMap(section);
93
- }
94
- else{
94
+ } else {
95
95
  Message msg = Message.getInstance("Applet Button executed successfully");
96
- msg.setType(MESSAGE_TYPE.BANNER);
97
- msg.setStatus(BANNER_STATUS.SUCCESS);
98
-
96
+ msg.setBannerResponse(BANNER_STATUS.SUCCESS);
99
97
  return ZCCliqUtil.toMap(msg);
100
98
  }
101
99
  }
102
- String text = new StringBuilder().append("Hi ").append(values.getString("username"))
103
- .append(", thanks for raising your request. Your request will be processed based on the device availability.").toString();
104
- MessageBuilder msg = MessageBuilder.getInstance(text);
100
+ 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();
101
+ Message msg = Message.getInstance(text);
105
102
  msg.setCard(CardDetails.getInstance("Asset Request"));
106
103
  Slide slide = Slide.getInstance();
107
104
  slide.setType(SLIDE_TYPE.LABEL);
@@ -110,15 +107,14 @@ JSONObject values = req.getForm().getValues();
110
107
  JSONObject obj1 = new JSONObject();
111
108
  obj1.put("Asset Type", values.getJSONObject("asset-type").getString("label"));
112
109
  dataArray.put(obj1);
113
- if(values.getJSONObject("asset-type").getString("value").equals("mobile")){
110
+ if (values.getJSONObject("asset-type").getString("value").equals("mobile")) {
114
111
  JSONObject obj2 = new JSONObject();
115
112
  obj2.put("Preferred OS", values.getJSONObject("mobile-os").getString("label"));
116
113
  dataArray.put(obj2);
117
114
  JSONObject obj3 = new JSONObject();
118
115
  obj3.put("Preferred Device", values.getJSONObject("mobile-list").getString("label"));
119
116
  dataArray.put(obj3);
120
- }
121
- else{
117
+ } else {
122
118
  JSONObject obj2 = new JSONObject();
123
119
  obj2.put("OS/Device Preferred", values.getJSONObject("os-type").getString("label"));
124
120
  dataArray.put(obj2);
@@ -129,15 +125,14 @@ JSONObject values = req.getForm().getValues();
129
125
  }
130
126
 
131
127
  @Override
132
- public FormChangeResponse formChangeHandler(FormFunctionRequest req) throws Exception
133
- {
128
+ public FormChangeResponse formChangeHandler(FormFunctionRequest req) throws Exception {
134
129
  FormChangeResponse resp = FormChangeResponse.getInstance();
135
130
  String target = req.getTarget().getName();
136
131
  JSONObject values = req.getForm().getValues();
137
- String fieldValue = ((JSONObject)values.get("asset-type")).get("value").toString();
138
- if(target.equalsIgnoreCase("asset-type")){
139
-
140
- if(fieldValue.equals("laptop")){
132
+ String fieldValue = ((JSONObject) values.get("asset-type")).get("value").toString();
133
+ if (target.equalsIgnoreCase("asset-type")) {
134
+
135
+ if (fieldValue.equals("laptop")) {
141
136
  FormModificationAction selectBoxAction = FormModificationAction.getInstance();
142
137
  selectBoxAction.setType(FORM_MODIFICATION_ACTION_TYPE.ADD_AFTER);
143
138
  selectBoxAction.setName("asset-type");
@@ -162,20 +157,19 @@ JSONObject values = req.getForm().getValues();
162
157
  OS.addOption(windows);
163
158
  OS.addOption(ubuntu);
164
159
  selectBoxAction.setInput(OS);
165
-
160
+
166
161
  FormModificationAction removeMobileOSAction = FormModificationAction.getInstance();
167
162
  removeMobileOSAction.setType(FORM_MODIFICATION_ACTION_TYPE.REMOVE);
168
163
  removeMobileOSAction.setName("mobile-os");
169
-
164
+
170
165
  FormModificationAction removeMobileListAction = FormModificationAction.getInstance();
171
166
  removeMobileListAction.setType(FORM_MODIFICATION_ACTION_TYPE.REMOVE);
172
167
  removeMobileListAction.setName("mobile-list");
173
-
168
+
174
169
  resp.addAction(selectBoxAction);
175
170
  resp.addAction(removeMobileOSAction);
176
171
  resp.addAction(removeMobileListAction);
177
- }
178
- else if(fieldValue.equals("mobile")){
172
+ } else if (fieldValue.equals("mobile")) {
179
173
  FormModificationAction selectBoxAction = FormModificationAction.getInstance();
180
174
  selectBoxAction.setType(FORM_MODIFICATION_ACTION_TYPE.ADD_AFTER);
181
175
  selectBoxAction.setName("asset-type");
@@ -196,19 +190,18 @@ JSONObject values = req.getForm().getValues();
196
190
  OS.addOption(android);
197
191
  OS.addOption(ios);
198
192
  selectBoxAction.setInput(OS);
199
-
193
+
200
194
  FormModificationAction removeOSTypeAction = FormModificationAction.getInstance();
201
195
  removeOSTypeAction.setType(FORM_MODIFICATION_ACTION_TYPE.REMOVE);
202
196
  removeOSTypeAction.setName("os-type");
203
-
197
+
204
198
  resp.addAction(selectBoxAction);
205
199
  resp.addAction(removeOSTypeAction);
206
200
  }
207
-
208
- }
209
- else if(target.equalsIgnoreCase("mobile-os")){
210
-
211
- if(fieldValue != null){
201
+
202
+ } else if (target.equalsIgnoreCase("mobile-os")) {
203
+
204
+ if (fieldValue != null) {
212
205
  FormModificationAction mobileListAction = FormModificationAction.getInstance();
213
206
  mobileListAction.setType(FORM_MODIFICATION_ACTION_TYPE.ADD_AFTER);
214
207
  mobileListAction.setName("mobile-os");
@@ -219,55 +212,46 @@ JSONObject values = req.getForm().getValues();
219
212
  listInput.setPlaceholder("Choose your preferred mobile device");
220
213
  listInput.setMandatory(true);
221
214
  mobileListAction.setInput(listInput);
222
-
215
+
223
216
  resp.addAction(mobileListAction);
224
- }
225
- else{
217
+ } else {
226
218
  FormModificationAction removeMobileListAction = FormModificationAction.getInstance();
227
219
  removeMobileListAction.setType(FORM_MODIFICATION_ACTION_TYPE.REMOVE);
228
220
  removeMobileListAction.setName("mobile-list");
229
-
230
221
  resp.addAction(removeMobileListAction);
231
222
  }
232
-
233
223
  }
234
224
  return resp;
235
225
  }
236
226
 
237
227
  @Override
238
- public FormDynamicFieldResponse formDynamicFieldHandler(FormFunctionRequest req) throws Exception
239
- {
228
+ public FormDynamicFieldResponse formDynamicFieldHandler(FormFunctionRequest req) throws Exception {
240
229
  FormDynamicFieldResponse resp = FormDynamicFieldResponse.getInstance();
241
230
  FormTarget target = req.getTarget();
242
- String query = target.getQuery();
231
+ String query = target.getQuery();
243
232
  JSONObject values = req.getForm().getValues();
244
- if(target.getName().equals("mobile-list") && !values.get("mobile-os").toString().isEmpty()){
233
+ if (target.getName().equals("mobile-list") && !values.get("mobile-os").toString().isEmpty()) {
245
234
  String device = values.getJSONObject("mobile-os").getString("value");
246
- if(device.equals("android")){
247
- Arrays.stream(new String[]{"One Plus 6T","One Plus 6","Google Pixel 3","Google Pixel 2XL"})
248
- .filter(phone -> phone.contains(query))
249
- .forEach(phone -> resp.addOption(new FormValue(phone, phone.toLowerCase().replace(" ", "_"))));
250
- }
251
- else if(device.equals("ios")){
252
- Arrays.stream(new String[]{"IPhone XR","IPhone XS","IPhone X","Iphone 8 Plus"})
253
- .filter(phone -> phone.contains(query))
254
- .forEach(phone -> resp.addOption(new FormValue(phone, phone.toLowerCase().replace(" ", "_"))));
235
+ if (device.equals("android")) {
236
+ Arrays.stream(new String[] { "One Plus 6T", "One Plus 6", "Google Pixel 3", "Google Pixel 2XL" }).filter(phone -> phone.contains(query)).forEach(phone -> resp.addOption(new FormValue(phone, phone.toLowerCase().replace(" ", "_"))));
237
+ } else if (device.equals("ios")) {
238
+ Arrays.stream(new String[] { "IPhone XR", "IPhone XS", "IPhone X", "Iphone 8 Plus" }).filter(phone -> phone.contains(query)).forEach(phone -> resp.addOption(new FormValue(phone, phone.toLowerCase().replace(" ", "_"))));
255
239
  }
256
240
  }
257
241
  return resp;
258
242
  }
259
243
 
260
244
  @Override
261
- public Map<String, Object> widgetButtonHandler(WidgetFunctionRequest req) throws Exception
262
- {
263
- String id = req.getTarget().getId();
264
- switch(id){
265
- case "tab" : {
266
-
245
+ public Map<String, Object> widgetButtonHandler(WidgetFunctionRequest req) throws Exception {
246
+ ButtonObject target = req.getTarget();
247
+ String id = target.getId();
248
+ switch (id) {
249
+ case "tab": {
250
+
267
251
  WidgetResponse widgetResp = WidgetResponse.getInstance();
268
252
  widgetResp.setType(WIDGET_TYPE.APPLET);
269
-
270
- //Time
253
+
254
+ // Time
271
255
  WidgetElement time = WidgetElement.getInstance(WIDGET_ELEMENT_TYPE.SUBTEXT);
272
256
  SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
273
257
  time.setText("Target:buttons\nTime : " + sdf.format(new Date()));
@@ -275,14 +259,14 @@ JSONObject values = req.getForm().getValues();
275
259
  titleSection.addElement(time);
276
260
  titleSection.setId("100");
277
261
  widgetResp.addSection(titleSection);
278
-
262
+
279
263
  WidgetSection buttonSection = getButtonsSection();
280
-
264
+
281
265
  widgetResp.addSection(buttonSection);
282
266
  return ZCCliqUtil.toMap(widgetResp);
283
267
  }
284
-
285
- case "section" : {
268
+
269
+ case "section": {
286
270
  WidgetSection section = WidgetSection.getInstance();
287
271
  section.setId("102");
288
272
  section.setType("section");
@@ -291,9 +275,9 @@ JSONObject values = req.getForm().getValues();
291
275
  section.addElement(element);
292
276
  return ZCCliqUtil.toMap(section);
293
277
  }
294
-
295
- case "formtab" :
296
- case "formsection" : {
278
+
279
+ case "formtab":
280
+ case "formsection": {
297
281
  Form form = Form.getInstance();
298
282
  form.setTitle("Zylker Annual Marathon");
299
283
  form.setName("a");
@@ -307,67 +291,114 @@ JSONObject values = req.getForm().getValues();
307
291
  input1.setMinLength("0");
308
292
  input1.setMaxLength("25");
309
293
  input1.setMandatory(true);
310
-
294
+
311
295
  FormInput input2 = FormInput.getIntance();
312
296
  input2.setType(FORM_FIELD_TYPE.HIDDEN);
313
297
  input2.setName("type");
314
298
  input2.setValue(id);
315
-
299
+
316
300
  form.addFormInput(input1);
317
301
  form.addFormInput(input2);
318
302
  form.setAction(FormAction.getInstance("appletForm"));// ** ENTER YOUR FORM FUNCTION NAME HERE **
319
303
  return ZCCliqUtil.toMap(form);
320
304
  }
321
-
322
- case "banner" :
323
- default : {
305
+
306
+ case "breadcrumbs":
307
+
308
+ Integer page = Integer.parseInt(target.getLabel().split("Page : ")[1].trim()) + 1;
309
+ WidgetResponse widgetResp = WidgetResponse.getInstance();
310
+ widgetResp.setType(WIDGET_TYPE.APPLET);
311
+ WidgetElement elem = WidgetElement.getInstance(WIDGET_ELEMENT_TYPE.SUBTEXT);
312
+ elem.setText("Page " + page);
313
+ WidgetSection titleSection = WidgetSection.getInstance();
314
+ titleSection.addElement(elem);
315
+ titleSection.setId("12345");
316
+ widgetResp.addSection(titleSection);
317
+
318
+ WidgetButton fistNav = new WidgetButton();
319
+ fistNav.setLabel("Page : " + page);
320
+ fistNav.setType(ACTION_TYPE.INVOKE_FUNCTION);
321
+ fistNav.setName("appletFunction");
322
+ fistNav.setId("breadcrumbs");
323
+
324
+ WidgetButton linkButton = new WidgetButton();
325
+ linkButton.setLabel("Link");
326
+ linkButton.setType(ACTION_TYPE.OPEN_URL);
327
+ linkButton.setUrl("https://www.zoho.com");
328
+
329
+ WidgetButton bannerBtn = new WidgetButton();
330
+ bannerBtn.setLabel("Banner");
331
+ bannerBtn.setType(ACTION_TYPE.INVOKE_FUNCTION);
332
+ bannerBtn.setName("appletFunction");
333
+ bannerBtn.setId("banner");
334
+
335
+ WidgetHeader header = WidgetHeader.getInstance();
336
+ header.setTitle("Header " + page);
337
+ header.setNavigation(WIDGET_NAVIGATION.CONTINUE);
338
+ List<WidgetButton> headerButtons = new ArrayList<WidgetButton>();
339
+ headerButtons.add(fistNav);
340
+ headerButtons.add(bannerBtn);
341
+ headerButtons.add(linkButton);
342
+ header.setButtons(headerButtons);
343
+ widgetResp.setHeader(header);
344
+
345
+ WidgetFooter footer = WidgetFooter.getInstance();
346
+ footer.setText("Footer Text");
347
+ List<WidgetButton> footerButtons = new ArrayList<WidgetButton>();
348
+ footerButtons.add(bannerBtn);
349
+ footerButtons.add(linkButton);
350
+ footer.setButtons(footerButtons);
351
+ widgetResp.setFooter(footer);
352
+
353
+ return ZCCliqUtil.toMap(widgetResp);
354
+
355
+ case "banner":
356
+ default: {
324
357
  Message msg = Message.getInstance("Applet Button executed successfully");
325
- msg.setType(MESSAGE_TYPE.BANNER);
326
- msg.setStatus(BANNER_STATUS.SUCCESS);
358
+ msg.setBannerResponse(BANNER_STATUS.SUCCESS);
327
359
  return ZCCliqUtil.toMap(msg);
328
360
  }
329
361
  }
330
362
  }
331
363
 
332
- private WidgetSection getButtonsSection()
333
- {
364
+ private WidgetSection getButtonsSection() {
334
365
  WidgetSection buttonSection = WidgetSection.getInstance();
335
-
336
- //Buttons - Row1
366
+
367
+ // Buttons - Row1
337
368
  WidgetElement title = WidgetElement.getInstance(WIDGET_ELEMENT_TYPE.TITLE);
338
369
  title.setText("Buttons");
339
-
370
+
340
371
  WidgetElement buttonElement1 = WidgetElement.getInstance(WIDGET_ELEMENT_TYPE.BUTTONS);
341
372
  List<WidgetButton> buttonsList1 = new ArrayList<WidgetButton>();
342
373
  WidgetButton button1 = new WidgetButton();
343
374
  button1.setLabel("Link");
344
375
  button1.setType(ACTION_TYPE.OPEN_URL);
345
376
  button1.setUrl("https://www.zoho.com");
346
-
377
+
347
378
  WidgetButton button2 = new WidgetButton();
348
379
  button2.setLabel("Banner");
349
380
  button2.setType(ACTION_TYPE.INVOKE_FUNCTION);
350
381
  button2.setName("appletFunction");
351
382
  button2.setId("banner");
352
-
383
+
353
384
  WidgetButton button3 = new WidgetButton();
354
385
  button3.setLabel("Open Channel");
355
386
  button3.setType(ACTION_TYPE.SYSTEM_API);
356
387
  button3.setApi(SYSTEM_API_ACTION.JOIN_CHANNEL, "CD_1283959962893705602_14598233");// ** ENTER YOUR CHANNEL ID HERE **
357
-
388
+
358
389
  WidgetButton button4 = new WidgetButton();
359
390
  button4.setLabel("Preview");
360
391
  button4.setType(ACTION_TYPE.PREVIEW_URL);
361
392
  button4.setUrl("https://www.zoho.com/catalyst/features.html");
362
-
393
+
363
394
  buttonsList1.add(button1);
364
395
  buttonsList1.add(button2);
365
396
  buttonsList1.add(button3);
366
397
  buttonsList1.add(button4);
367
-
398
+
368
399
  buttonElement1.setButtons(buttonsList1);
369
-
370
- //Buttons - Row2
400
+
401
+ // Buttons - Row2
371
402
  WidgetElement buttonElement2 = WidgetElement.getInstance(WIDGET_ELEMENT_TYPE.BUTTONS);
372
403
  List<WidgetButton> buttonsList2 = new ArrayList<WidgetButton>();
373
404
  WidgetButton button5 = new WidgetButton();
@@ -375,44 +406,44 @@ JSONObject values = req.getForm().getValues();
375
406
  button5.setType(ACTION_TYPE.INVOKE_FUNCTION);
376
407
  button5.setName("appletFunction");
377
408
  button5.setId("section");
378
-
409
+
379
410
  WidgetButton button6 = new WidgetButton();
380
411
  button6.setLabel("Form Edit Section");
381
412
  button6.setType(ACTION_TYPE.INVOKE_FUNCTION);
382
413
  button6.setName("appletFunction");
383
414
  button6.setId("formsection");
384
-
415
+
385
416
  WidgetButton button7 = new WidgetButton();
386
417
  button7.setLabel("Banner");
387
418
  button7.setType(ACTION_TYPE.INVOKE_FUNCTION);
388
419
  button7.setName("appletFunction");
389
420
  button7.setId("banner");
390
-
421
+
391
422
  WidgetButton button8 = new WidgetButton();
392
423
  button8.setLabel("Edit Whole Tab");
393
424
  button8.setType(ACTION_TYPE.INVOKE_FUNCTION);
394
425
  button8.setName("appletFunction");
395
426
  button8.setId("tab");
396
-
427
+
397
428
  WidgetButton button9 = new WidgetButton();
398
429
  button9.setLabel("Form Edit Tab");
399
430
  button9.setType(ACTION_TYPE.INVOKE_FUNCTION);
400
431
  button9.setName("appletFunction");
401
432
  button9.setId("formtab");
402
-
433
+
403
434
  buttonsList2.add(button5);
404
435
  buttonsList2.add(button6);
405
436
  buttonsList2.add(button7);
406
437
  buttonsList2.add(button8);
407
438
  buttonsList2.add(button9);
408
-
439
+
409
440
  buttonElement2.setButtons(buttonsList2);
410
-
441
+
411
442
  buttonSection.addElement(title);
412
443
  buttonSection.addElement(buttonElement1);
413
444
  buttonSection.addElement(buttonElement2);
414
445
  buttonSection.setId("101");
415
-
446
+
416
447
  return buttonSection;
417
448
  }
418
449
  }
@@ -5,18 +5,15 @@ import com.zc.cliq.enums.STATUS;
5
5
  import com.zc.cliq.objects.InstallationResponse;
6
6
  import com.zc.cliq.requests.InstallationRequest;
7
7
 
8
- public class InstallationHandler implements com.zc.cliq.interfaces.InstallationHandler
9
- {
8
+ public class InstallationHandler implements com.zc.cliq.interfaces.InstallationHandler {
10
9
  @Override
11
- public InstallationResponse handleInstallation(InstallationRequest req) throws Exception
12
- {
10
+ public InstallationResponse handleInstallation(InstallationRequest req) throws Exception {
13
11
  InstallationResponse resp = InstallationResponse.getInstance();
14
12
  /*
15
- // Logic for installation post handling
16
- * {
13
+ * // Logic for installation post handling {
17
14
  *
18
15
  * }
19
- */
16
+ */
20
17
  resp.setStatus(STATUS.SUCCESS);
21
18
  return resp;
22
19
  }
@@ -6,18 +6,15 @@ import com.zc.cliq.enums.STATUS;
6
6
  import com.zc.cliq.objects.InstallationResponse;
7
7
  import com.zc.cliq.requests.InstallationRequest;
8
8
 
9
- public class InstallationValidator implements com.zc.cliq.interfaces.InstallationValidator
10
- {
9
+ public class InstallationValidator implements com.zc.cliq.interfaces.InstallationValidator {
11
10
  @Override
12
- public InstallationResponse validateInstallation(InstallationRequest req) throws Exception
13
- {
11
+ public InstallationResponse validateInstallation(InstallationRequest req) throws Exception {
14
12
  InstallationResponse resp = InstallationResponse.getInstance();
15
- if(req.getUser().getFirstName().equals("**INVALID_USER**") && req.getAppInfo().getType().equals(EXTENSION_TYPE.UPGRADE)){
13
+ if (req.getUser().getFirstName().equals("**INVALID_USER**") && req.getAppInfo().getType().equals(EXTENSION_TYPE.UPGRADE)) {
16
14
  resp.setStatus(STATUS.FAILURE);
17
15
  resp.setTitle("Update not allowed !");
18
16
  resp.setMessage("Sorry. Update not allowed for the current app. Please contact admin.");
19
- }
20
- else{
17
+ } else {
21
18
  resp.setStatus(STATUS.SUCCESS);
22
19
  }
23
20
  return resp;
@@ -3,24 +3,22 @@ package com.handlers;
3
3
 
4
4
  import java.util.Map;
5
5
 
6
- import com.zc.cliq.enums.MESSAGE_TYPE;
7
- import com.zc.cliq.objects.MessageBuilder;
6
+ import com.zc.cliq.enums.RESPONSE_TYPE;
7
+ import com.zc.cliq.objects.Message;
8
8
  import com.zc.cliq.requests.MessageActionHandlerRequest;
9
9
  import com.zc.cliq.util.ZCCliqUtil;
10
10
 
11
- public class MessageActionHandler implements com.zc.cliq.interfaces.MessageActionHandler
12
- {
11
+ public class MessageActionHandler implements com.zc.cliq.interfaces.MessageActionHandler {
13
12
  @Override
14
- public Map<String,Object> executionHandler(MessageActionHandlerRequest req) throws Exception {
15
- MESSAGE_TYPE msgType = req.getMessage().getType();
13
+ public Map<String, Object> executionHandler(MessageActionHandlerRequest req) throws Exception {
14
+ RESPONSE_TYPE msgType = req.getMessage().getType();
16
15
  String firstName = req.getUser() != null ? req.getUser().getFirstName() : "user";
17
-
18
- String text = "Hey " + firstName + ", You have performed an action on a *" + msgType.getType() +
19
- "*. Manipulate the message variable and perform your own action.";
20
-
21
- MessageBuilder resp = MessageBuilder.getInstance();
16
+
17
+ String text = "Hey " + firstName + ", You have performed an action on a *" + msgType.getKey() + "*. Manipulate the message variable and perform your own action.";
18
+
19
+ Message resp = Message.getInstance();
22
20
  resp.setText(text);
23
-
21
+
24
22
  return ZCCliqUtil.toMap(resp);
25
23
  }
26
24