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 +5 -4
- package/src/prompts.js +2 -3
- package/templates/vue-js/jsconfig.json +7 -0
- package/templates/vue-js/public/manifest.json +12 -0
- package/templates/vue-js/public/thumbnail.png +0 -0
- package/templates/vue-js/src/API/currentUserContext.js +61 -0
- package/templates/vue-js/src/API/dataApi.js +238 -0
- package/templates/vue-js/src/API/domoAPI.js +311 -0
- package/templates/vue-js/src/App.vue +9 -0
- package/templates/vue-js/src/index.css +1 -0
- package/templates/vue-js/src/main.js +6 -0
- package/templates/vue-js/src/pages/index.vue +699 -0
- package/templates/vue-js/vite.config.js +40 -0
- package/templates/vue-ts/public/manifest.json +12 -0
- package/templates/vue-ts/public/thumbnail.png +0 -0
- package/templates/vue-ts/src/API/currentUserContext.ts +76 -0
- package/templates/vue-ts/src/API/dataApi.ts +284 -0
- package/templates/vue-ts/src/API/domoAPI.ts +340 -0
- package/templates/vue-ts/src/App.vue +9 -0
- package/templates/vue-ts/src/index.css +1 -0
- package/templates/vue-ts/src/main.ts +6 -0
- package/templates/vue-ts/src/pages/index.vue +706 -0
- package/templates/vue-ts/tsconfig.app.json +31 -0
- package/templates/vue-ts/tsconfig.json +17 -0
- package/templates/vue-ts/vite.config.ts +43 -0
|
@@ -0,0 +1,340 @@
|
|
|
1
|
+
import domo from "ryuu.js";
|
|
2
|
+
|
|
3
|
+
const BASE_URL = "/domo/datastores/v1";
|
|
4
|
+
|
|
5
|
+
interface User {
|
|
6
|
+
userId?: string;
|
|
7
|
+
userName?: string;
|
|
8
|
+
displayName?: string;
|
|
9
|
+
avatarKey?: string;
|
|
10
|
+
customer?: string;
|
|
11
|
+
host?: string;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
interface QueryOptions {
|
|
15
|
+
limit?: number;
|
|
16
|
+
offset?: number;
|
|
17
|
+
orderby?: string;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
interface Aggregations {
|
|
21
|
+
groupby?: string[];
|
|
22
|
+
count?: string;
|
|
23
|
+
avg?: Record<string, string>;
|
|
24
|
+
min?: Record<string, string>;
|
|
25
|
+
max?: Record<string, string>;
|
|
26
|
+
sum?: Record<string, string>;
|
|
27
|
+
unwind?: string[];
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
const GetCurrentUser = (): Promise<User> => {
|
|
31
|
+
return domo
|
|
32
|
+
.get("/domo/environment/v1")
|
|
33
|
+
.then((user: any) => ({
|
|
34
|
+
...user,
|
|
35
|
+
displayName: user.userName,
|
|
36
|
+
avatarKey: `/domo/avatars/v2/USER/${user.userId}`,
|
|
37
|
+
}))
|
|
38
|
+
.catch((error: Error) => {
|
|
39
|
+
console.error("Error getting current user:", error);
|
|
40
|
+
throw error;
|
|
41
|
+
});
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
const GetAllUser = (): Promise<User[]> => {
|
|
45
|
+
return domo
|
|
46
|
+
.get(`/domo/users/v1?limit={500}`)
|
|
47
|
+
.then((response: User[]) => response)
|
|
48
|
+
.catch((error: Error) => {
|
|
49
|
+
console.error("Error getting All users:", error);
|
|
50
|
+
throw error;
|
|
51
|
+
});
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
const GetUser = (userId: string): Promise<User> => {
|
|
55
|
+
return domo
|
|
56
|
+
.get(`/domo/users/v1/${userId}?includeDetails=true`)
|
|
57
|
+
.then((user: any) => ({ ...user, userName: user.displayName }))
|
|
58
|
+
.catch((error: Error) => {
|
|
59
|
+
console.error("Error getting user:", error);
|
|
60
|
+
throw error;
|
|
61
|
+
});
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
const CreateDocument = (
|
|
65
|
+
collectionName: string,
|
|
66
|
+
document: any
|
|
67
|
+
): Promise<any> => {
|
|
68
|
+
console.log(document);
|
|
69
|
+
console.log(collectionName);
|
|
70
|
+
|
|
71
|
+
return domo
|
|
72
|
+
.post(`${BASE_URL}/collections/${collectionName}/documents/`, {
|
|
73
|
+
content: document,
|
|
74
|
+
})
|
|
75
|
+
.then((response: any) => response)
|
|
76
|
+
.catch((error: Error) => {
|
|
77
|
+
console.error("Error creating document:", error);
|
|
78
|
+
throw error;
|
|
79
|
+
});
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
const ListDocuments = (collectionName: string): Promise<any[]> => {
|
|
83
|
+
return domo
|
|
84
|
+
.get(`${BASE_URL}/collections/${collectionName}/documents/`)
|
|
85
|
+
.then((response: any[]) => response)
|
|
86
|
+
.catch((error: Error) => {
|
|
87
|
+
console.error("Error listing documents:", error);
|
|
88
|
+
throw error;
|
|
89
|
+
});
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
const GetDocument = (
|
|
93
|
+
collectionName: string,
|
|
94
|
+
documentId: string
|
|
95
|
+
): Promise<any> => {
|
|
96
|
+
return domo
|
|
97
|
+
.get(`${BASE_URL}/collections/${collectionName}/documents/${documentId}`)
|
|
98
|
+
.then((response: any) => response)
|
|
99
|
+
.catch((error: Error) => {
|
|
100
|
+
console.error("Error getting document:", error);
|
|
101
|
+
throw error;
|
|
102
|
+
});
|
|
103
|
+
};
|
|
104
|
+
|
|
105
|
+
const UpdateDocument = (
|
|
106
|
+
collectionName: string,
|
|
107
|
+
documentId: string,
|
|
108
|
+
document: any
|
|
109
|
+
): Promise<any> => {
|
|
110
|
+
return domo
|
|
111
|
+
.put(`${BASE_URL}/collections/${collectionName}/documents/${documentId}`, {
|
|
112
|
+
content: document,
|
|
113
|
+
})
|
|
114
|
+
.then((response: any) => response)
|
|
115
|
+
.catch((error: Error) => {
|
|
116
|
+
console.error("Error updating document:", error);
|
|
117
|
+
throw error;
|
|
118
|
+
});
|
|
119
|
+
};
|
|
120
|
+
|
|
121
|
+
const queryDocumentsWithAggregations = (
|
|
122
|
+
collectionName: string,
|
|
123
|
+
query: Record<string, any> = {},
|
|
124
|
+
aggregations: Aggregations = {},
|
|
125
|
+
options: QueryOptions = {}
|
|
126
|
+
): Promise<any[]> => {
|
|
127
|
+
let url = `${BASE_URL}/collections/${collectionName}/documents/query?`;
|
|
128
|
+
|
|
129
|
+
const formatAggregationParams = (params: Record<string, string>): string => {
|
|
130
|
+
return Object.entries(params)
|
|
131
|
+
.map(([property, alias]) => `${property} ${alias}`)
|
|
132
|
+
.join(", ");
|
|
133
|
+
};
|
|
134
|
+
|
|
135
|
+
if (aggregations.groupby) url += `groupby=${aggregations.groupby.join(",")}&`;
|
|
136
|
+
if (aggregations.count) url += `count=${aggregations.count}&`;
|
|
137
|
+
if (aggregations.avg)
|
|
138
|
+
url += `avg=${formatAggregationParams(aggregations.avg)}&`;
|
|
139
|
+
if (aggregations.min)
|
|
140
|
+
url += `min=${formatAggregationParams(aggregations.min)}&`;
|
|
141
|
+
if (aggregations.max)
|
|
142
|
+
url += `max=${formatAggregationParams(aggregations.max)}&`;
|
|
143
|
+
if (aggregations.sum)
|
|
144
|
+
url += `sum=${formatAggregationParams(aggregations.sum)}&`;
|
|
145
|
+
if (aggregations.unwind) url += `unwind=${aggregations.unwind.join(",")}&`;
|
|
146
|
+
|
|
147
|
+
if (options.orderby) url += `orderby=${options.orderby}&`;
|
|
148
|
+
if (options.limit !== undefined) url += `limit=${options.limit}&`;
|
|
149
|
+
if (options.offset !== undefined) url += `offset=${options.offset}&`;
|
|
150
|
+
|
|
151
|
+
url = url.replace(/[&?]$/, "");
|
|
152
|
+
|
|
153
|
+
return domo
|
|
154
|
+
.post(url, query)
|
|
155
|
+
.then((response: any[]) => {
|
|
156
|
+
console.log("Query successful:", response);
|
|
157
|
+
return response;
|
|
158
|
+
})
|
|
159
|
+
.catch((error: Error) => {
|
|
160
|
+
console.error("Error querying documents with aggregations:", error);
|
|
161
|
+
throw error;
|
|
162
|
+
});
|
|
163
|
+
};
|
|
164
|
+
|
|
165
|
+
const DeleteDocument = (
|
|
166
|
+
collectionName: string,
|
|
167
|
+
documentId: string
|
|
168
|
+
): Promise<any> => {
|
|
169
|
+
return domo
|
|
170
|
+
.delete(`${BASE_URL}/collections/${collectionName}/documents/${documentId}`)
|
|
171
|
+
.then((response: any) => response.data)
|
|
172
|
+
.catch((error: Error) => {
|
|
173
|
+
console.error("Error deleting document:", error);
|
|
174
|
+
throw error;
|
|
175
|
+
});
|
|
176
|
+
};
|
|
177
|
+
|
|
178
|
+
const QueryDocument = (
|
|
179
|
+
collectionName: string,
|
|
180
|
+
query: Record<string, any> = {},
|
|
181
|
+
options: QueryOptions = {}
|
|
182
|
+
): Promise<any[]> => {
|
|
183
|
+
let url = `${BASE_URL}/collections/${collectionName}/documents/query?`;
|
|
184
|
+
|
|
185
|
+
if (options.limit !== undefined) url += `limit=${options.limit}&`;
|
|
186
|
+
if (options.offset !== undefined) url += `offset=${options.offset}&`;
|
|
187
|
+
if (options.orderby) url += `orderby=${options.orderby}&`;
|
|
188
|
+
|
|
189
|
+
url = url.replace(/[&?]$/, "");
|
|
190
|
+
|
|
191
|
+
return domo
|
|
192
|
+
.post(url, query)
|
|
193
|
+
.then((response: any[]) => {
|
|
194
|
+
return response;
|
|
195
|
+
})
|
|
196
|
+
.catch((error: Error) => {
|
|
197
|
+
console.error("Error querying documents:", error);
|
|
198
|
+
throw error;
|
|
199
|
+
});
|
|
200
|
+
};
|
|
201
|
+
|
|
202
|
+
const queryDocumentsByDate = (
|
|
203
|
+
collectionName: string,
|
|
204
|
+
dateString: string,
|
|
205
|
+
options: QueryOptions = {}
|
|
206
|
+
): Promise<any[]> => {
|
|
207
|
+
const query = {
|
|
208
|
+
createdOn: {
|
|
209
|
+
$lte: { $date: dateString },
|
|
210
|
+
},
|
|
211
|
+
};
|
|
212
|
+
return QueryDocument(collectionName, query, options);
|
|
213
|
+
};
|
|
214
|
+
|
|
215
|
+
const BulkDeleteDocuments = (
|
|
216
|
+
collectionName: string,
|
|
217
|
+
ids: string
|
|
218
|
+
): Promise<any> => {
|
|
219
|
+
return domo
|
|
220
|
+
.delete(
|
|
221
|
+
`${BASE_URL}/collections/${collectionName}/documents/bulk?ids=${ids}`
|
|
222
|
+
)
|
|
223
|
+
.then((response: any) => response)
|
|
224
|
+
.catch((error: Error) => {
|
|
225
|
+
console.error("Error bulk deleting documents:", error);
|
|
226
|
+
throw error;
|
|
227
|
+
});
|
|
228
|
+
};
|
|
229
|
+
|
|
230
|
+
const UploadFile = (
|
|
231
|
+
file: File,
|
|
232
|
+
name: string,
|
|
233
|
+
description: string = "",
|
|
234
|
+
isPublic: boolean = false
|
|
235
|
+
): Promise<any> => {
|
|
236
|
+
const formData = new FormData();
|
|
237
|
+
formData.append("file", file);
|
|
238
|
+
const url = `/domo/data-files/v1?name=${name}&description=${description}&public=${isPublic}`;
|
|
239
|
+
const options = { contentType: "multipart" };
|
|
240
|
+
return domo
|
|
241
|
+
.post(url, formData, options)
|
|
242
|
+
.then((response: any) => response)
|
|
243
|
+
.catch((err: Error) => {
|
|
244
|
+
console.log(err);
|
|
245
|
+
throw err;
|
|
246
|
+
});
|
|
247
|
+
};
|
|
248
|
+
|
|
249
|
+
const UploadRevision = (file: File, fileId: string): Promise<any> => {
|
|
250
|
+
const formData = new FormData();
|
|
251
|
+
formData.append("file", file);
|
|
252
|
+
const url = `/domo/data-files/v1/${fileId}`;
|
|
253
|
+
const options = { contentType: "multipart" };
|
|
254
|
+
return domo
|
|
255
|
+
.put(url, formData, options)
|
|
256
|
+
.then((response: any) => response)
|
|
257
|
+
.catch((err: Error) => {
|
|
258
|
+
console.log(err);
|
|
259
|
+
throw err;
|
|
260
|
+
});
|
|
261
|
+
};
|
|
262
|
+
|
|
263
|
+
const GetFile = (fileId: string, revisionId?: string): Promise<Blob> => {
|
|
264
|
+
const options = { responseType: "blob" };
|
|
265
|
+
const url = `/domo/data-files/v1/${fileId}${
|
|
266
|
+
revisionId ? `/revisions/${revisionId}` : ""
|
|
267
|
+
}`;
|
|
268
|
+
return domo
|
|
269
|
+
.get(url, options)
|
|
270
|
+
.then((data: Blob) => data)
|
|
271
|
+
.catch((err: Error) => {
|
|
272
|
+
console.log(err);
|
|
273
|
+
throw err;
|
|
274
|
+
});
|
|
275
|
+
};
|
|
276
|
+
|
|
277
|
+
const ListAllUsers = async (
|
|
278
|
+
includeDetails: boolean = false,
|
|
279
|
+
limit: number = 100,
|
|
280
|
+
offset: number = 0
|
|
281
|
+
): Promise<User[]> => {
|
|
282
|
+
try {
|
|
283
|
+
const response = await domo.get(
|
|
284
|
+
`/domo/users/v1?includeDetails=${includeDetails}&limit=${limit}&offset=${offset}`
|
|
285
|
+
);
|
|
286
|
+
return response;
|
|
287
|
+
} catch (error) {
|
|
288
|
+
console.error("Error listing users:", error);
|
|
289
|
+
throw error;
|
|
290
|
+
}
|
|
291
|
+
};
|
|
292
|
+
|
|
293
|
+
const partialupdateDocument = (
|
|
294
|
+
collectionName: string,
|
|
295
|
+
query: Record<string, any>,
|
|
296
|
+
operation: Record<string, any>
|
|
297
|
+
): Promise<any> => {
|
|
298
|
+
const requestBody = {
|
|
299
|
+
query: query,
|
|
300
|
+
operation: operation,
|
|
301
|
+
};
|
|
302
|
+
|
|
303
|
+
console.log("Request body:", requestBody);
|
|
304
|
+
|
|
305
|
+
return domo
|
|
306
|
+
.put(
|
|
307
|
+
`${BASE_URL}/collections/${collectionName}/documents/update`,
|
|
308
|
+
requestBody
|
|
309
|
+
)
|
|
310
|
+
.then((response: any) => {
|
|
311
|
+
console.log("Document updated successfully:", response);
|
|
312
|
+
return response;
|
|
313
|
+
})
|
|
314
|
+
.catch((error: Error) => {
|
|
315
|
+
console.error("Error updating document:", error);
|
|
316
|
+
throw error;
|
|
317
|
+
});
|
|
318
|
+
};
|
|
319
|
+
|
|
320
|
+
const DomoApi = {
|
|
321
|
+
GetCurrentUser,
|
|
322
|
+
GetAllUser,
|
|
323
|
+
GetUser,
|
|
324
|
+
CreateDocument,
|
|
325
|
+
ListDocuments,
|
|
326
|
+
DeleteDocument,
|
|
327
|
+
BulkDeleteDocuments,
|
|
328
|
+
GetDocument,
|
|
329
|
+
UpdateDocument,
|
|
330
|
+
QueryDocument,
|
|
331
|
+
queryDocumentsByDate,
|
|
332
|
+
UploadFile,
|
|
333
|
+
UploadRevision,
|
|
334
|
+
GetFile,
|
|
335
|
+
queryDocumentsWithAggregations,
|
|
336
|
+
ListAllUsers,
|
|
337
|
+
partialupdateDocument,
|
|
338
|
+
};
|
|
339
|
+
|
|
340
|
+
export default DomoApi;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
@import "tailwindcss";
|