1 /*
2  * SessionProjectTemplate.hpp
3  *
4  * Copyright (C) 2021 by RStudio, PBC
5  *
6  * Unless you have received this program directly from RStudio pursuant
7  * to the terms of a commercial license agreement with RStudio, then
8  * this program is licensed to you under the terms of version 3 of the
9  * GNU Affero General Public License. This program is distributed WITHOUT
10  * ANY EXPRESS OR IMPLIED WARRANTY, INCLUDING THOSE OF NON-INFRINGEMENT,
11  * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Please refer to the
12  * AGPL (http://www.gnu.org/licenses/agpl-3.0.txt) for more details.
13  *
14  */
15 
16 #ifndef SESSION_PROJECT_TEMPLATE_HPP
17 #define SESSION_PROJECT_TEMPLATE_HPP
18 
19 #include <core/Base64.hpp>
20 #include <core/FileSerializer.hpp>
21 #include <core/StringUtils.hpp>
22 #include <shared_core/json/Json.hpp>
23 #include <core/json/JsonRpc.hpp>
24 #include <core/text/CsvParser.hpp>
25 
26 #include <boost/system/error_code.hpp>
27 
28 namespace rstudio {
29 namespace core {
30    class Error;
31 }
32 }
33 
34 namespace rstudio {
35 namespace session {
36 namespace modules {
37 namespace projects {
38 namespace templates {
39 
40 #define kProjectTemplateWidgetTypeCheckBoxInput "checkboxinput"
41 #define kProjectTemplateWidgetTypeSelectInput   "selectinput"
42 #define kProjectTemplateWidgetTypeTextInput     "textinput"
43 #define kProjectTemplateWidgetTypeFileInput     "fileinput"
44 
45 struct ProjectTemplateWidgetDescription
46 {
47    // COPYING: copyable members
48 
49    std::string parameter;
50    std::string type;
51    std::string label;
52    std::string defaultValue;
53    std::string position;
54    std::vector<std::string> fields;
55 
56    core::json::Value toJson() const;
57 };
58 
59 core::Error fromJson(
60       const core::json::Object& object,
61       ProjectTemplateWidgetDescription* pDescription);
62 
63 struct ProjectTemplateDescription
64 {
65    // COPYING: copyable members
66 
67    std::string package;
68    std::string binding;
69    std::string title;
70    std::string subtitle;
71    std::string caption;
72    std::string icon;
73    std::vector<std::string> openFiles;
74    std::vector<ProjectTemplateWidgetDescription> widgets;
75 
76    core::json::Value toJson() const;
77 };
78 
79 core::Error fromJson(
80       const core::json::Object&,
81       ProjectTemplateDescription* pDescription);
82 
83 core::Error initialize();
84 
85 } // end namespace templates
86 } // end namespace projects
87 } // end namespace modules
88 } // end namespace session
89 } // end namespace rstudio
90 
91 #endif /* SESSION_PROJECT_TEMPLATE_HPP */
92