create-dovite 2.2.0 → 2.2.2

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.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "create-dovite",
3
- "version": "2.2.0",
4
- "description": "Vite template featuring Tailwind (v4), ShadCN (Canary), and DOMO integration.",
3
+ "version": "2.2.2",
4
+ "description": "Vite template featuring React, Vue, TailwindCSS, ShadCN, and DOMO integration.",
5
5
  "main": "index.js",
6
6
  "bin": {
7
7
  "create-dovite": "index.js"
@@ -9,8 +9,8 @@
9
9
  "files": [
10
10
  "templates/react-js",
11
11
  "templates/react-ts",
12
- "templates/index.jsx",
13
- "templates/index.css",
12
+ "templates/vue-js",
13
+ "templates/vue-ts",
14
14
  "src",
15
15
  "index.js"
16
16
  ],
@@ -21,6 +21,7 @@
21
21
  "shadcn",
22
22
  "domo",
23
23
  "react",
24
+ "vue",
24
25
  "create-vite"
25
26
  ],
26
27
  "author": "Ajay B",
package/src/prompts.js CHANGED
@@ -22,9 +22,8 @@ async function getProjectDetails(initialProjectName) {
22
22
  choices: [
23
23
  { title: "React JavaScript", value: "react-js" },
24
24
  { title: "React TypeScript", value: "react-ts" },
25
- // Vue templates coming soon in a future release
26
- // { title: "Vue JavaScript", value: "vue-js" },
27
- // { title: "Vue TypeScript", value: "vue-ts" },
25
+ { title: "Vue JavaScript", value: "vue-js" },
26
+ { title: "Vue TypeScript", value: "vue-ts" },
28
27
  ],
29
28
  initial: 0,
30
29
  });
@@ -0,0 +1,7 @@
1
+ {
2
+ "compilerOptions": {
3
+ "paths": {
4
+ "@/*": ["./src/*"]
5
+ }
6
+ }
7
+ }
@@ -0,0 +1,12 @@
1
+ {
2
+ "name": "project-name",
3
+ "version": "0.0.1",
4
+ "size": {
5
+ "width": 3,
6
+ "height": 3
7
+ },
8
+ "mapping": [],
9
+ "collections": [],
10
+ "workflowMapping": [],
11
+ "packagesMapping": []
12
+ }
@@ -0,0 +1,61 @@
1
+ import { ref, provide, inject, onMounted } from "vue";
2
+ import DomoApi from "./domoAPI";
3
+
4
+ // Create a symbol for the injection key
5
+ const UserContextKey = Symbol("UserContext");
6
+
7
+ // Composable to provide user context
8
+ export function useUserProvider() {
9
+ const currentUser = ref("");
10
+ const currentUserId = ref("");
11
+ const avatarKey = ref("");
12
+ const customer = ref("");
13
+ const host = ref("");
14
+
15
+ onMounted(() => {
16
+ let isUserFetched = false;
17
+
18
+ DomoApi.GetCurrentUser().then((data) => {
19
+ if (!isUserFetched) {
20
+ const userId = data?.userId;
21
+ const displayName = data?.displayName;
22
+ const avatar = data?.avatarKey;
23
+ const cust = data?.customer;
24
+ const hostVal = data?.host;
25
+
26
+ currentUser.value = displayName || "";
27
+ currentUserId.value = userId || "";
28
+ avatarKey.value = avatar || "";
29
+ customer.value = cust || "";
30
+ host.value = hostVal || "";
31
+
32
+ isUserFetched = true;
33
+ }
34
+ });
35
+ });
36
+
37
+ const userContext = {
38
+ currentUser,
39
+ currentUserId,
40
+ avatarKey,
41
+ customer,
42
+ host,
43
+ };
44
+
45
+ provide(UserContextKey, userContext);
46
+
47
+ return userContext;
48
+ }
49
+
50
+ // Composable to consume user context
51
+ export function useUserContext() {
52
+ const context = inject(UserContextKey);
53
+ if (!context) {
54
+ throw new Error(
55
+ "useUserContext must be used within a component that calls useUserProvider"
56
+ );
57
+ }
58
+ return context;
59
+ }
60
+
61
+ export { UserContextKey };
@@ -0,0 +1,238 @@
1
+ import domo from "ryuu.js";
2
+ import axios from "axios";
3
+
4
+ export async function fetchAIData(prompt, template, maxWords) {
5
+ try {
6
+ // Validate the required "prompt" parameter
7
+ if (!prompt || typeof prompt !== "string") {
8
+ throw new Error(
9
+ "The 'prompt' parameter is required and must be a string."
10
+ );
11
+ }
12
+
13
+ // Construct the body dynamically, including properties only if they are valid
14
+ const body = {
15
+ input: prompt,
16
+ ...(template &&
17
+ typeof template === "string" && {
18
+ promptTemplate: {
19
+ template,
20
+ },
21
+ }),
22
+ ...(maxWords &&
23
+ !isNaN(maxWords) && {
24
+ parameters: {
25
+ max_words: maxWords.toString(),
26
+ },
27
+ }),
28
+ };
29
+
30
+ // Send the POST request
31
+ const response = await domo.post(`/domo/ai/v1/text/generation`, body);
32
+ console.log("AI Response:", response.output);
33
+
34
+ return response?.output;
35
+ } catch (error) {
36
+ console.error("Error fetching data:", error);
37
+ throw error; // Re-throw the error for better upstream handling
38
+ }
39
+ }
40
+
41
+ export async function fetchData(dataset) {
42
+ try {
43
+ const response = await domo.get(`/data/v1/${dataset}`).then((data) => {
44
+ return data;
45
+ });
46
+ // console.log(response);
47
+ return response;
48
+ } catch (error) {
49
+ console.error("Error fetching data:", error);
50
+ }
51
+ }
52
+
53
+ export async function fetchSqlData(dataset, query) {
54
+ // console.log("Query",query);
55
+
56
+ // Ensure the query is a string
57
+ if (typeof query !== "string") {
58
+ throw new Error("Query must be a string");
59
+ }
60
+
61
+ try {
62
+ // Fetch data from the API
63
+ const apiData = await domo
64
+ .post(`/sql/v1/${dataset}`, query, { contentType: "text/plain" })
65
+ .then((data) => {
66
+ // console.log('Fetched Data:', data);
67
+ return data;
68
+ });
69
+
70
+ // Validate the fetched data
71
+ if (!apiData || !apiData.columns || !apiData.rows) {
72
+ throw new Error("Invalid data received from the API");
73
+ }
74
+
75
+ // Extract and clean column names
76
+ const cleanedColumns = apiData.columns.map((column) => {
77
+ return column
78
+ .replace(/`/g, "")
79
+ .replace(/T1\./g, "")
80
+ .replace(/avg\((.*?)\)/i, "$1")
81
+ .trim();
82
+ });
83
+
84
+ // Map rows to cleaned column names
85
+ const jsonResult = apiData.rows.map((row) => {
86
+ const jsonObject = {};
87
+ cleanedColumns.forEach((cleanedColumn, index) => {
88
+ jsonObject[cleanedColumn] = row[index];
89
+ });
90
+ return jsonObject;
91
+ });
92
+
93
+ // console.log("Mapped SQL DATA",jsonResult);
94
+
95
+ // Return the dynamically created JSON
96
+ return jsonResult;
97
+ } catch (error) {
98
+ console.error("Error fetching or processing data:", error);
99
+ throw error; // Rethrow the error for the caller to handle
100
+ }
101
+ }
102
+
103
+ export async function sendEmail(to, subject, body, attachment) {
104
+ const data = {
105
+ to,
106
+ subject,
107
+ body,
108
+ ...(attachment && { attachment: [attachment] }),
109
+ };
110
+
111
+ if (data) {
112
+ try {
113
+ const response = await domo.post(
114
+ `/domo/workflow/v1/models/email/start`,
115
+ data
116
+ );
117
+ if (response) {
118
+ console.log("response", response);
119
+ }
120
+ } catch (err) {
121
+ console.error("Error sending email:", err);
122
+ }
123
+ }
124
+ }
125
+
126
+ //Dataflow
127
+ export const DataflowsActions = async (action, dataflowId) => {
128
+ const data = {
129
+ action,
130
+ dataflowId,
131
+ result: true,
132
+ };
133
+
134
+ if (data) {
135
+ try {
136
+ const response = await domo.post(
137
+ `/domo/workflow/v1/models/dataflow/start`,
138
+ data
139
+ );
140
+ if (response) {
141
+ console.log("response", response);
142
+ }
143
+ } catch (err) {
144
+ console.error("Error sending email:", err);
145
+ }
146
+ }
147
+ };
148
+ export const generateAccessToken = async (clientId, clientSecret) => {
149
+ const tokenUrl = "https://api.domo.com/oauth/token";
150
+ try {
151
+ const response = await axios.post(
152
+ tokenUrl,
153
+ new URLSearchParams({
154
+ grant_type: "client_credentials",
155
+ scope: "user",
156
+ }).toString(),
157
+ {
158
+ headers: {
159
+ "Content-Type": "application/x-www-form-urlencoded",
160
+ },
161
+ auth: {
162
+ username: clientId,
163
+ password: clientSecret,
164
+ },
165
+ }
166
+ );
167
+ console.log("Response:", response);
168
+
169
+ console.log("Access Token:", response.data.access_token);
170
+
171
+ return response.data.access_token;
172
+ } catch (err) {
173
+ console.error("Error:", err);
174
+ throw err;
175
+ }
176
+ };
177
+
178
+ //List Of Users
179
+ export const fetchUsers = async (accessToken) => {
180
+ const userUrl = `https://api.domo.com/v1/users?limit=500`;
181
+ console.log("accessToken", accessToken);
182
+ try {
183
+ if (!accessToken) {
184
+ console.log("Access token not found");
185
+ return;
186
+ }
187
+ const response = await axios.get(userUrl, {
188
+ headers: {
189
+ Authorization: `Bearer ${accessToken}`,
190
+ },
191
+ });
192
+ console.log("List of users with access token", response.data);
193
+ return response.data;
194
+ } catch (err) {
195
+ console.error("Error fetching User details:", err);
196
+ }
197
+ };
198
+
199
+ //List Of Dataset
200
+ export const fetchDatasets = async (accessToken) => {
201
+ const datasetUrl = `https://api.domo.com/v1/datasets`;
202
+
203
+ try {
204
+ if (!accessToken) {
205
+ await generateAccessToken();
206
+ }
207
+ const response = await axios.get(datasetUrl, {
208
+ headers: {
209
+ Authorization: `Bearer ${accessToken}`,
210
+ },
211
+ });
212
+ // console.log("List of dataset", response.data);
213
+ return response.data;
214
+ } catch (err) {
215
+ console.error("Error fetching dataset details:", err);
216
+ }
217
+ };
218
+
219
+ //Perticaular Dataset Details
220
+ export const fetchDatasetDetails = async (accessToken, datasetId) => {
221
+ const datasetUrl = `https://api.domo.com/v1/datasets/${datasetId}`;
222
+
223
+ try {
224
+ if (!accessToken) {
225
+ await generateAccessToken();
226
+ }
227
+
228
+ const response = await axios.get(datasetUrl, {
229
+ headers: {
230
+ Authorization: `Bearer ${accessToken}`,
231
+ },
232
+ });
233
+ // console.log("data", response.data)
234
+ return response.data;
235
+ } catch (err) {
236
+ console.error("Error fetching dataset details:", err);
237
+ }
238
+ };
@@ -0,0 +1,311 @@
1
+ import domo from "ryuu.js";
2
+ // import Download from "downloadjs";
3
+
4
+ const BASE_URL = "/domo/datastores/v1";
5
+
6
+ const GetCurrentUser = () => {
7
+ return domo
8
+ .get("/domo/environment/v1")
9
+ .then((user) => ({
10
+ ...user,
11
+ displayName: user.userName,
12
+ avatarKey: `/domo/avatars/v2/USER/${user.userId}`,
13
+ }))
14
+ .catch((error) => {
15
+ console.error("Error getting current user:", error);
16
+ throw error;
17
+ });
18
+ };
19
+
20
+ const GetAllUser = () => {
21
+ return domo
22
+ .get(`/domo/users/v1?limit={500}`)
23
+ .then((response) => response)
24
+ .catch((error) => {
25
+ console.error("Error getting All users:", error);
26
+ throw error;
27
+ });
28
+ };
29
+
30
+ const GetUser = (userId) => {
31
+ return domo
32
+ .get(`/domo/users/v1/${userId}?includeDetails=true`)
33
+ .then((user) => ({ ...user, userName: user.displayName }))
34
+ .catch((error) => {
35
+ console.error("Error getting user:", error);
36
+ throw error;
37
+ });
38
+ };
39
+
40
+ const CreateDocument = (collectionName, document) => {
41
+ console.log(document);
42
+ console.log(collectionName);
43
+
44
+ return domo
45
+ .post(`${BASE_URL}/collections/${collectionName}/documents/`, {
46
+ content: document,
47
+ })
48
+ .then((response) => response)
49
+ .catch((error) => {
50
+ console.error("Error creating document:", error);
51
+ throw error;
52
+ });
53
+ };
54
+
55
+ const ListDocuments = (collectionName) => {
56
+ return domo
57
+ .get(`${BASE_URL}/collections/${collectionName}/documents/`)
58
+ .then((response) => response)
59
+ .catch((error) => {
60
+ console.error("Error listing documents:", error);
61
+ throw error;
62
+ });
63
+ };
64
+
65
+ const GetDocument = (collectionName, documentId) => {
66
+ return domo
67
+ .get(`${BASE_URL}/collections/${collectionName}/documents/${documentId}`)
68
+ .then((response) => response)
69
+ .catch((error) => {
70
+ console.error("Error getting document:", error);
71
+ throw error;
72
+ });
73
+ };
74
+
75
+ const UpdateDocument = (collectionName, documentId, document) => {
76
+ return domo
77
+ .put(`${BASE_URL}/collections/${collectionName}/documents/${documentId}`, {
78
+ content: document,
79
+ })
80
+ .then((response) => response)
81
+ .catch((error) => {
82
+ console.error("Error updating document:", error);
83
+ throw error;
84
+ });
85
+ };
86
+ const queryDocumentsWithAggregations = (
87
+ collectionName,
88
+ query = {},
89
+ aggregations = {},
90
+ options = {}
91
+ ) => {
92
+ // Base URL for the query
93
+ let url = `${BASE_URL}/collections/${collectionName}/documents/query?`;
94
+
95
+ // Helper function to format aggregation parameters
96
+ const formatAggregationParams = (params) => {
97
+ return Object.entries(params)
98
+ .map(([property, alias]) => `${property} ${alias}`)
99
+ .join(", ");
100
+ };
101
+
102
+ // Append aggregation parameters to URL
103
+ if (aggregations.groupby) url += `groupby=${aggregations.groupby.join(",")}&`;
104
+ if (aggregations.count) url += `count=${aggregations.count}&`;
105
+ if (aggregations.avg)
106
+ url += `avg=${formatAggregationParams(aggregations.avg)}&`;
107
+ if (aggregations.min)
108
+ url += `min=${formatAggregationParams(aggregations.min)}&`;
109
+ if (aggregations.max)
110
+ url += `max=${formatAggregationParams(aggregations.max)}&`;
111
+ if (aggregations.sum)
112
+ url += `sum=${formatAggregationParams(aggregations.sum)}&`;
113
+ if (aggregations.unwind) url += `unwind=${aggregations.unwind.join(",")}&`;
114
+
115
+ // Append options to the URL
116
+ if (options.orderby) url += `orderby=${options.orderby}&`;
117
+ if (options.limit !== undefined) url += `limit=${options.limit}&`;
118
+ if (options.offset !== undefined) url += `offset=${options.offset}&`;
119
+
120
+ // Remove trailing "&" or "?" from the URL
121
+ url = url.replace(/[&?]$/, "");
122
+
123
+ return domo
124
+ .post(url, query)
125
+ .then((response) => {
126
+ console.log("Query successful:", response);
127
+ return response;
128
+ })
129
+ .catch((error) => {
130
+ console.error("Error querying documents with aggregations:", error);
131
+ throw error;
132
+ });
133
+ };
134
+
135
+ const DeleteDocument = (collectionName, documentId) => {
136
+ return domo
137
+ .delete(`${BASE_URL}/collections/${collectionName}/documents/${documentId}`)
138
+ .then((response) => response.data)
139
+ .catch((error) => {
140
+ console.error("Error deleting document:", error);
141
+ throw error;
142
+ });
143
+ };
144
+
145
+ const QueryDocument = (collectionName, query = {}, options = {}) => {
146
+ // Base URL for querying documents
147
+ let url = `${BASE_URL}/collections/${collectionName}/documents/query?`;
148
+
149
+ // Append optional parameters to the URL
150
+ if (options.limit !== undefined) url += `limit=${options.limit}&`;
151
+ if (options.offset !== undefined) url += `offset=${options.offset}&`;
152
+ if (options.orderby) url += `orderby=${options.orderby}&`;
153
+
154
+ // Remove trailing "&" or "?" from the URL
155
+ url = url.replace(/[&?]$/, "");
156
+
157
+ return domo
158
+ .post(url, query)
159
+ .then((response) => {
160
+ // console.log("Query successful:", response);
161
+ return response;
162
+ })
163
+ .catch((error) => {
164
+ console.error("Error querying documents:", error);
165
+ throw error;
166
+ });
167
+ };
168
+
169
+ // Query documents based on a specific date range
170
+ const queryDocumentsByDate = (collectionName, dateString, options = {}) => {
171
+ const query = {
172
+ createdOn: {
173
+ $lte: { $date: dateString },
174
+ },
175
+ };
176
+ return QueryDocument(collectionName, query, options);
177
+ };
178
+
179
+ const BulkDeleteDocuments = (collectionName, ids) => {
180
+ return domo
181
+ .delete(
182
+ `${BASE_URL}/collections/${collectionName}/documents/bulk?ids=${ids}`
183
+ )
184
+ .then((response) => response)
185
+ .catch((error) => {
186
+ console.error("Error bulk deleting documents:", error);
187
+ throw error;
188
+ });
189
+ };
190
+
191
+ const UploadFile = (file, name, description = "", isPublic = false) => {
192
+ const formData = new FormData();
193
+ formData.append("file", file);
194
+ const url = `/domo/data-files/v1?name=
195
+ ${name}&description=${description}&public=${isPublic}`;
196
+ const options = { contentType: "multipart" };
197
+ return domo
198
+ .post(url, formData, options)
199
+ .then((response) => response)
200
+ .catch((err) => {
201
+ console.log(err);
202
+ throw err;
203
+ });
204
+ };
205
+
206
+ const UploadRevision = (file, fileId) => {
207
+ const formData = new FormData();
208
+ formData.append("file", file);
209
+ const url = `/domo/data-files/v1/${fileId}`;
210
+ const options = { contentType: "multipart" };
211
+ return domo
212
+ .put(url, formData, options)
213
+ .then((response) => response)
214
+ .catch((err) => {
215
+ console.log(err);
216
+ throw err;
217
+ });
218
+ };
219
+
220
+ // const DownloadFile = (fileId, filename, revisionId) => {
221
+ // const options = { responseType: "blob" };
222
+ // const url = `/domo/data-files/v1/${fileId}${
223
+ // revisionId ? `/revisions/${revisionId}` : ""
224
+ // }`;
225
+ // return domo
226
+ // .get(url, options)
227
+ // .then((data) => {
228
+ // Download(data, filename);
229
+ // })
230
+ // .then((response) => response)
231
+ // .catch((err) => {
232
+ // console.log(err);
233
+ // throw err;
234
+ // });
235
+ // };
236
+
237
+ const GetFile = (fileId, revisionId) => {
238
+ const options = { responseType: "blob" };
239
+ const url = `/domo/data-files/v1/${fileId}${
240
+ revisionId ? `/revisions/${revisionId}` : ""
241
+ }`;
242
+ return domo
243
+ .get(url, options)
244
+ .then((data) => data)
245
+ .catch((err) => {
246
+ console.log(err);
247
+ throw err;
248
+ });
249
+ };
250
+
251
+ const ListAllUsers = async (
252
+ includeDetails = false,
253
+ limit = 100,
254
+ offset = 0
255
+ ) => {
256
+ try {
257
+ const response = await domo.get(
258
+ `/domo/users/v1?includeDetails=${includeDetails}&limit=${limit}&offset=${offset}`
259
+ );
260
+ return response;
261
+ } catch (error) {
262
+ console.error("Error listing users:", error);
263
+ throw error;
264
+ }
265
+ };
266
+
267
+ const partialupdateDocument = (collectionName, query, operation) => {
268
+ const requestBody = {
269
+ query: query,
270
+ operation: operation,
271
+ };
272
+
273
+ console.log("Request body:", requestBody);
274
+
275
+ return domo
276
+ .put(
277
+ `${BASE_URL}/collections/${collectionName}/documents/update`,
278
+ requestBody
279
+ )
280
+ .then((response) => {
281
+ console.log("Document updated successfully:", response);
282
+ return response;
283
+ })
284
+ .catch((error) => {
285
+ console.error("Error updating document:", error);
286
+ throw error;
287
+ });
288
+ };
289
+
290
+ const DomoApi = {
291
+ GetCurrentUser,
292
+ GetAllUser,
293
+ GetUser,
294
+ CreateDocument,
295
+ ListDocuments,
296
+ DeleteDocument,
297
+ BulkDeleteDocuments,
298
+ GetDocument,
299
+ UpdateDocument,
300
+ QueryDocument,
301
+ queryDocumentsByDate,
302
+ UploadFile,
303
+ UploadRevision,
304
+ // DownloadFile,
305
+ GetFile,
306
+ queryDocumentsWithAggregations,
307
+ ListAllUsers,
308
+ partialupdateDocument,
309
+ };
310
+
311
+ export default DomoApi;
@@ -0,0 +1,9 @@
1
+ <script setup>
2
+ import DefaultPage from "./pages/index.vue";
3
+ </script>
4
+
5
+ <template>
6
+ <DefaultPage />
7
+ </template>
8
+
9
+ <style scoped></style>
@@ -0,0 +1 @@
1
+ @import "tailwindcss";
@@ -0,0 +1,6 @@
1
+ import { createApp } from "vue";
2
+ import "./style.css";
3
+ import "./index.css";
4
+ import App from "./App.vue";
5
+
6
+ createApp(App).mount("#app");