create-dovite 2.0.1 → 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.
Files changed (37) hide show
  1. package/README.md +20 -16
  2. package/index.js +10 -4
  3. package/package.json +8 -4
  4. package/src/files.js +40 -1
  5. package/src/prompts.js +2 -0
  6. package/src/setup.js +56 -33
  7. package/templates/react-js/public/thumbnail.png +0 -0
  8. package/templates/react-js/src/App.jsx +3 -9
  9. package/templates/react-js/src/pages/index.css +96 -0
  10. package/templates/react-js/src/pages/index.jsx +340 -0
  11. package/templates/react-ts/public/thumbnail.png +0 -0
  12. package/templates/react-ts/src/App.tsx +3 -9
  13. package/templates/react-ts/src/pages/index.css +96 -0
  14. package/templates/react-ts/src/pages/index.tsx +347 -0
  15. package/templates/vue-js/jsconfig.json +7 -0
  16. package/templates/vue-js/public/manifest.json +12 -0
  17. package/templates/vue-js/public/thumbnail.png +0 -0
  18. package/templates/vue-js/src/API/currentUserContext.js +61 -0
  19. package/templates/vue-js/src/API/dataApi.js +238 -0
  20. package/templates/vue-js/src/API/domoAPI.js +311 -0
  21. package/templates/vue-js/src/App.vue +9 -0
  22. package/templates/vue-js/src/index.css +1 -0
  23. package/templates/vue-js/src/main.js +6 -0
  24. package/templates/vue-js/src/pages/index.vue +699 -0
  25. package/templates/vue-js/vite.config.js +40 -0
  26. package/templates/vue-ts/public/manifest.json +12 -0
  27. package/templates/vue-ts/public/thumbnail.png +0 -0
  28. package/templates/vue-ts/src/API/currentUserContext.ts +76 -0
  29. package/templates/vue-ts/src/API/dataApi.ts +284 -0
  30. package/templates/vue-ts/src/API/domoAPI.ts +340 -0
  31. package/templates/vue-ts/src/App.vue +9 -0
  32. package/templates/vue-ts/src/index.css +1 -0
  33. package/templates/vue-ts/src/main.ts +6 -0
  34. package/templates/vue-ts/src/pages/index.vue +706 -0
  35. package/templates/vue-ts/tsconfig.app.json +31 -0
  36. package/templates/vue-ts/tsconfig.json +17 -0
  37. package/templates/vue-ts/vite.config.ts +43 -0
@@ -0,0 +1,347 @@
1
+ import { useState } from "react";
2
+ import { Button } from "../components/ui/button";
3
+ import { FiBook, FiPackage, FiGithub, FiExternalLink } from "react-icons/fi";
4
+ import "./index.css";
5
+
6
+ // Vite Logo SVG
7
+ const ViteLogo = () => (
8
+ <svg
9
+ className="logo-icon logo-vite"
10
+ viewBox="0 0 410 404"
11
+ fill="none"
12
+ xmlns="http://www.w3.org/2000/svg"
13
+ >
14
+ <path
15
+ d="M399.641 59.5246L215.643 388.545C211.844 395.338 202.084 395.378 198.228 388.618L10.5817 59.5563C6.38087 52.1896 12.6802 43.2665 21.0281 44.7586L205.223 77.6824C206.398 77.8924 207.601 77.8904 208.776 77.6763L389.119 44.8058C397.439 43.2894 403.768 52.1434 399.641 59.5246Z"
16
+ fill="url(#paint0_linear)"
17
+ />
18
+ <path
19
+ d="M292.965 1.5744L156.801 28.2552C154.563 28.6937 152.906 30.5903 152.771 32.8664L144.395 174.33C144.198 177.662 147.258 180.248 150.51 179.498L188.42 170.749C191.967 169.931 195.172 173.055 194.443 176.622L183.18 231.775C182.422 235.487 185.907 238.661 189.532 237.56L212.947 230.446C216.577 229.344 220.065 232.527 219.297 236.242L201.398 322.875C200.278 328.294 207.486 331.249 210.492 326.603L212.5 323.5L323.454 102.072C325.312 98.3645 322.108 94.137 318.036 94.9228L279.014 102.454C275.347 103.161 272.227 99.746 273.262 96.1583L298.731 7.86689C299.767 4.27314 296.636 0.855181 292.965 1.5744Z"
20
+ fill="url(#paint1_linear)"
21
+ />
22
+ <defs>
23
+ <linearGradient
24
+ id="paint0_linear"
25
+ x1="6.00017"
26
+ y1="32.9999"
27
+ x2="235"
28
+ y2="344"
29
+ gradientUnits="userSpaceOnUse"
30
+ >
31
+ <stop stopColor="#41D1FF" />
32
+ <stop offset="1" stopColor="#BD34FE" />
33
+ </linearGradient>
34
+ <linearGradient
35
+ id="paint1_linear"
36
+ x1="194.651"
37
+ y1="8.81818"
38
+ x2="236.076"
39
+ y2="292.989"
40
+ gradientUnits="userSpaceOnUse"
41
+ >
42
+ <stop stopColor="#FFBD4F" />
43
+ <stop offset="1" stopColor="#FF980E" />
44
+ </linearGradient>
45
+ </defs>
46
+ </svg>
47
+ );
48
+
49
+ // React Logo SVG
50
+ const ReactLogo = () => (
51
+ <svg
52
+ className="logo-icon logo-react"
53
+ viewBox="-11.5 -10.23174 23 20.46348"
54
+ xmlns="http://www.w3.org/2000/svg"
55
+ >
56
+ <circle cx="0" cy="0" r="2.05" fill="#61dafb" />
57
+ <g stroke="#61dafb" strokeWidth="1" fill="none">
58
+ <ellipse rx="11" ry="4.2" />
59
+ <ellipse rx="11" ry="4.2" transform="rotate(60)" />
60
+ <ellipse rx="11" ry="4.2" transform="rotate(120)" />
61
+ </g>
62
+ </svg>
63
+ );
64
+
65
+ // Domo Logo SVG
66
+ const DomoLogo = () => (
67
+ <svg
68
+ className="logo-icon logo-domo"
69
+ viewBox="0 0 100 100"
70
+ fill="none"
71
+ xmlns="http://www.w3.org/2000/svg"
72
+ >
73
+ <rect width="100" height="100" rx="16" fill="url(#domoGradient)" />
74
+ <text
75
+ x="50"
76
+ y="65"
77
+ textAnchor="middle"
78
+ fill="white"
79
+ fontSize="36"
80
+ fontWeight="bold"
81
+ fontFamily="Arial, sans-serif"
82
+ >
83
+ DOMO
84
+ </text>
85
+ {/* <circle cx="72" cy="35" r="8" fill="white" opacity="0.8" /> */}
86
+ <defs>
87
+ <linearGradient
88
+ id="domoGradient"
89
+ x1="0"
90
+ y1="0"
91
+ x2="100"
92
+ y2="100"
93
+ gradientUnits="userSpaceOnUse"
94
+ >
95
+ <stop stopColor="#00B5E2" />
96
+ <stop offset="1" stopColor="#0072BC" />
97
+ </linearGradient>
98
+ </defs>
99
+ </svg>
100
+ );
101
+
102
+ // Tailwind Logo SVG
103
+ const TailwindLogo = () => (
104
+ <svg
105
+ className="logo-icon logo-tailwind"
106
+ viewBox="0 0 54 33"
107
+ fill="none"
108
+ xmlns="http://www.w3.org/2000/svg"
109
+ >
110
+ <g clipPath="url(#tailwindClip)">
111
+ <path
112
+ fillRule="evenodd"
113
+ clipRule="evenodd"
114
+ d="M27 0C19.8 0 15.3 3.6 13.5 10.8C16.2 7.2 19.35 5.85 22.95 6.75C25.004 7.263 26.472 8.754 28.097 10.403C30.744 13.09 33.808 16.2 40.5 16.2C47.7 16.2 52.2 12.6 54 5.4C51.3 9 48.15 10.35 44.55 9.45C42.496 8.937 41.028 7.446 39.403 5.797C36.756 3.11 33.692 0 27 0ZM13.5 16.2C6.3 16.2 1.8 19.8 0 27C2.7 23.4 5.85 22.05 9.45 22.95C11.504 23.464 12.972 24.954 14.597 26.603C17.244 29.29 20.308 32.4 27 32.4C34.2 32.4 38.7 28.8 40.5 21.6C37.8 25.2 34.65 26.55 31.05 25.65C28.996 25.137 27.528 23.646 25.903 21.997C23.256 19.31 20.192 16.2 13.5 16.2Z"
115
+ fill="url(#tailwindGradient)"
116
+ />
117
+ </g>
118
+ <defs>
119
+ <linearGradient
120
+ id="tailwindGradient"
121
+ x1="0"
122
+ y1="16.2"
123
+ x2="54"
124
+ y2="16.2"
125
+ gradientUnits="userSpaceOnUse"
126
+ >
127
+ <stop stopColor="#06B6D4" />
128
+ <stop offset="1" stopColor="#22D3EE" />
129
+ </linearGradient>
130
+ <clipPath id="tailwindClip">
131
+ <rect width="54" height="33" fill="white" />
132
+ </clipPath>
133
+ </defs>
134
+ </svg>
135
+ );
136
+
137
+ // Shadcn Logo SVG
138
+ const ShadcnLogo = () => (
139
+ <svg
140
+ className="logo-icon logo-shadcn"
141
+ viewBox="0 0 256 256"
142
+ fill="none"
143
+ xmlns="http://www.w3.org/2000/svg"
144
+ >
145
+ <rect width="256" height="256" rx="60" fill="currentColor" />
146
+ <line
147
+ x1="208"
148
+ y1="128"
149
+ x2="128"
150
+ y2="208"
151
+ stroke="url(#shadcnGradient)"
152
+ strokeWidth="24"
153
+ strokeLinecap="round"
154
+ />
155
+ <line
156
+ x1="192"
157
+ y1="40"
158
+ x2="40"
159
+ y2="192"
160
+ stroke="url(#shadcnGradient)"
161
+ strokeWidth="24"
162
+ strokeLinecap="round"
163
+ />
164
+ <defs>
165
+ <linearGradient
166
+ id="shadcnGradient"
167
+ x1="40"
168
+ y1="40"
169
+ x2="208"
170
+ y2="208"
171
+ gradientUnits="userSpaceOnUse"
172
+ >
173
+ <stop stopColor="#fff" />
174
+ <stop offset="1" stopColor="#a1a1aa" />
175
+ </linearGradient>
176
+ </defs>
177
+ </svg>
178
+ );
179
+
180
+ interface DocLink {
181
+ title: string;
182
+ url: string;
183
+ description: string;
184
+ Icon: React.ComponentType<{ className?: string }>;
185
+ }
186
+
187
+ const DefaultPage = () => {
188
+ const [count, setCount] = useState(0);
189
+
190
+ const docLinks: DocLink[] = [
191
+ {
192
+ title: "DOMO APIs",
193
+ url: "https://developer.domo.com/portal/8ba9aedad3679-ap-is",
194
+ description: "Explore the API documentation",
195
+ Icon: FiBook,
196
+ },
197
+ {
198
+ title: "Domo Starter Kit",
199
+ url: "https://developer.domo.com/portal/u8w475o2245yp-starter-kits",
200
+ description: "Get started quickly",
201
+ Icon: FiPackage,
202
+ },
203
+ {
204
+ title: "GitHub Repository",
205
+ url: "https://github.com/Ajay-Balu/create-dovite",
206
+ description: "View source code",
207
+ Icon: FiGithub,
208
+ },
209
+ ];
210
+
211
+ return (
212
+ <div className="landing-page h-screen w-screen flex flex-col overflow-hidden">
213
+ {/* Main Content Area */}
214
+ <div className="flex-1 flex items-center justify-center gap-16 px-8 py-8 max-w-[1400px] mx-auto w-full max-lg:flex-col max-lg:gap-8 max-lg:overflow-y-auto">
215
+ {/* Left Side - Hero Section */}
216
+ <div className="flex-1 flex flex-col items-center justify-center text-center gap-4">
217
+ {/* Logo Container */}
218
+ <div className="flex justify-center items-center gap-2 flex-wrap mb-2">
219
+ <a
220
+ href="https://vitejs.dev"
221
+ target="_blank"
222
+ rel="noopener noreferrer"
223
+ className="inline-flex transition-transform duration-300 hover:scale-115"
224
+ >
225
+ <ViteLogo />
226
+ </a>
227
+ <span className="text-2xl font-light text-zinc-500/50 mx-1">+</span>
228
+ <a
229
+ href="https://react.dev"
230
+ target="_blank"
231
+ rel="noopener noreferrer"
232
+ className="inline-flex transition-transform duration-300 hover:scale-115"
233
+ >
234
+ <ReactLogo />
235
+ </a>
236
+ <span className="text-2xl font-light text-zinc-500/50 mx-1">+</span>
237
+ <a
238
+ href="https://www.domo.com"
239
+ target="_blank"
240
+ rel="noopener noreferrer"
241
+ className="inline-flex transition-transform duration-300 hover:scale-115"
242
+ >
243
+ <DomoLogo />
244
+ </a>
245
+ <span className="text-2xl font-light text-zinc-500/50 mx-1">+</span>
246
+ <a
247
+ href="https://tailwindcss.com"
248
+ target="_blank"
249
+ rel="noopener noreferrer"
250
+ className="inline-flex transition-transform duration-300 hover:scale-115"
251
+ >
252
+ <TailwindLogo />
253
+ </a>
254
+ <span className="text-2xl font-light text-zinc-500/50 mx-1">+</span>
255
+ <a
256
+ href="https://ui.shadcn.com"
257
+ target="_blank"
258
+ rel="noopener noreferrer"
259
+ className="inline-flex transition-transform duration-300 hover:scale-115"
260
+ >
261
+ <ShadcnLogo />
262
+ </a>
263
+ </div>
264
+
265
+ {/* Title */}
266
+ <h1 className="text-5xl font-extrabold tracking-tight m-0 leading-tight max-md:text-4xl max-sm:text-3xl">
267
+ <span className="gradient-text">Dovite</span>
268
+ </h1>
269
+ <p className="text-base text-zinc-400 m-0 font-medium">
270
+ Vite + React + DOMO + Tailwind + Shadcn/UI
271
+ </p>
272
+ <p className="text-sm text-zinc-500 m-0 max-w-[400px]">
273
+ Build beautiful DOMO apps with modern web technologies
274
+ </p>
275
+
276
+ {/* Interactive Demo Section */}
277
+ <div className="mt-6">
278
+ <div className="px-8 py-6 bg-white/3 border border-white/8 rounded-2xl backdrop-blur-lg">
279
+ <Button
280
+ onClick={() => setCount((count) => count + 1)}
281
+ className="text-sm px-5 py-2.5 transition-all duration-300 hover:-translate-y-0.5 hover:shadow-xl"
282
+ >
283
+ Count is {count}
284
+ </Button>
285
+ <p className="mt-4 text-zinc-500 text-xs">
286
+ Edit{" "}
287
+ <code className="bg-zinc-500/15 px-1.5 py-0.5 rounded text-zinc-400 font-mono text-[0.8em]">
288
+ src/pages/index.tsx
289
+ </code>{" "}
290
+ and save to test HMR
291
+ </p>
292
+ </div>
293
+ </div>
294
+ </div>
295
+
296
+ {/* Right Side - Documentation Links */}
297
+ <div className="w-80 flex flex-col gap-4 p-6 bg-white/2 border border-white/6 rounded-2xl backdrop-blur-lg max-lg:w-full max-lg:max-w-[400px]">
298
+ <h2 className="text-xs font-semibold text-zinc-400 uppercase tracking-widest m-0 pb-3 border-b border-white/6">
299
+ Resources
300
+ </h2>
301
+ <div className="flex flex-col gap-2">
302
+ {docLinks.map((link, index) => (
303
+ <a
304
+ key={index}
305
+ href={link.url}
306
+ target="_blank"
307
+ rel="noopener noreferrer"
308
+ className="group flex items-center gap-3 px-4 py-3.5 bg-white/2 border border-white/4 rounded-xl no-underline text-inherit transition-all duration-250 hover:bg-white/6 hover:border-cyan-500/30 hover:translate-x-1"
309
+ >
310
+ <link.Icon className="text-xl text-cyan-500 shrink-0" />
311
+ <div className="flex-1 flex flex-col gap-0.5 min-w-0">
312
+ <span className="text-sm font-semibold text-zinc-100">
313
+ {link.title}
314
+ </span>
315
+ <span className="text-xs text-zinc-500">
316
+ {link.description}
317
+ </span>
318
+ </div>
319
+ <FiExternalLink className="text-sm text-zinc-600 shrink-0 transition-all duration-250 group-hover:text-cyan-500 group-hover:translate-x-0.5 group-hover:-translate-y-0.5" />
320
+ </a>
321
+ ))}
322
+ </div>
323
+ <p className="text-xs text-zinc-600 text-center m-0 pt-2">
324
+ Click on the logos to learn more
325
+ </p>
326
+ </div>
327
+ </div>
328
+
329
+ {/* Footer */}
330
+ <footer className="px-8 py-4 text-center border-t border-white/6 bg-black/20">
331
+ <p className="m-0 text-zinc-600 text-xs">
332
+ Built with <span className="text-red-500">❤</span> using{" "}
333
+ <a
334
+ href="https://github.com/Ajay-Balu/create-dovite"
335
+ target="_blank"
336
+ rel="noopener noreferrer"
337
+ className="text-cyan-500 no-underline font-medium transition-colors duration-300 hover:text-purple-500"
338
+ >
339
+ create-dovite
340
+ </a>
341
+ </p>
342
+ </footer>
343
+ </div>
344
+ );
345
+ };
346
+
347
+ export default DefaultPage;
@@ -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
+ };