@libretexts/cxone-expert-node 1.0.0 → 1.1.0

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 (61) hide show
  1. package/README.md +39 -39
  2. package/dist/cxone-expert-node.cjs.development.js +1511 -0
  3. package/dist/cxone-expert-node.cjs.development.js.map +1 -0
  4. package/dist/cxone-expert-node.cjs.production.min.js +2 -0
  5. package/dist/cxone-expert-node.cjs.production.min.js.map +1 -0
  6. package/dist/cxone-expert-node.esm.js +1505 -0
  7. package/dist/cxone-expert-node.esm.js.map +1 -0
  8. package/dist/index.d.ts +32 -0
  9. package/dist/index.js +8 -0
  10. package/dist/modules/archive.d.ts +18 -0
  11. package/dist/modules/auth.d.ts +8 -0
  12. package/dist/modules/contextMaps.d.ts +10 -0
  13. package/dist/modules/events.d.ts +15 -0
  14. package/dist/modules/files.d.ts +23 -0
  15. package/dist/modules/groups.d.ts +11 -0
  16. package/dist/modules/pages.d.ts +68 -0
  17. package/dist/modules/requests.d.ts +14 -0
  18. package/dist/modules/site.d.ts +22 -0
  19. package/dist/modules/users.d.ts +16 -0
  20. package/dist/types/archive.d.ts +78 -0
  21. package/dist/types/auth.d.ts +11 -0
  22. package/dist/types/contextMaps.d.ts +34 -0
  23. package/dist/types/events.d.ts +68 -0
  24. package/dist/types/files.d.ts +61 -0
  25. package/dist/types/groups.d.ts +57 -0
  26. package/dist/types/index.d.ts +19 -0
  27. package/dist/types/pages.d.ts +735 -0
  28. package/dist/types/requests.d.ts +9 -0
  29. package/dist/types/security.d.ts +57 -0
  30. package/dist/types/site.d.ts +254 -0
  31. package/dist/types/users.d.ts +81 -0
  32. package/dist/utils.d.ts +2 -0
  33. package/license.md +20 -20
  34. package/package.json +12 -5
  35. package/src/index.ts +105 -35
  36. package/src/modules/archive.ts +186 -0
  37. package/src/modules/auth.ts +35 -31
  38. package/src/modules/contextMaps.ts +56 -0
  39. package/src/modules/events.ts +140 -0
  40. package/src/modules/files.ts +291 -0
  41. package/src/modules/groups.ts +79 -0
  42. package/src/modules/pages.ts +1236 -73
  43. package/src/modules/requests.ts +67 -67
  44. package/src/modules/site.ts +266 -0
  45. package/src/modules/users.ts +161 -0
  46. package/src/types/archive.ts +101 -0
  47. package/src/types/auth.ts +13 -13
  48. package/src/types/contextMaps.ts +46 -0
  49. package/src/types/events.ts +91 -0
  50. package/src/types/files.ts +87 -0
  51. package/src/types/groups.ts +74 -0
  52. package/src/types/index.ts +21 -14
  53. package/src/types/pages.ts +856 -171
  54. package/src/types/requests.ts +10 -10
  55. package/src/types/security.ts +60 -47
  56. package/src/types/site.ts +304 -0
  57. package/src/types/users.ts +101 -0
  58. package/src/utils.ts +8 -8
  59. package/.github/workflows/release.yaml +0 -37
  60. package/.releaserc.json +0 -15
  61. package/tsconfig.json +0 -26
@@ -0,0 +1,1505 @@
1
+ import axios from 'axios';
2
+ import { createHmac } from 'crypto';
3
+
4
+ function getTld(globals, tld) {
5
+ if (!tld && !globals.tld) {
6
+ throw new Error('TLD is required');
7
+ }
8
+ return tld != null ? tld : globals.tld;
9
+ }
10
+
11
+ const API_BASE_URL = '/@api/deki';
12
+ class Requests {
13
+ constructor(tld, authObject, format = 'json') {
14
+ this.axiosInstance = axios.create();
15
+ this.format = 'json';
16
+ if (!tld) {
17
+ throw new Error('TLD is required');
18
+ }
19
+ if (!authObject) {
20
+ throw new Error('Auth object is required');
21
+ }
22
+ const parsedTLD = tld.endsWith('/') ? tld.slice(0, tld.length - 1) : `${tld}`;
23
+ this.format = format;
24
+ this.axiosInstance = axios.create({
25
+ baseURL: `${parsedTLD}${API_BASE_URL}`,
26
+ headers: {
27
+ 'Content-Type': 'application/json',
28
+ 'X-Requested-With': 'XMLHttpRequest',
29
+ ...authObject
30
+ }
31
+ });
32
+ }
33
+ getFormatParam() {
34
+ return {
35
+ 'dream.out.format': this.format
36
+ };
37
+ }
38
+ async get(url, config) {
39
+ return await this.axiosInstance.get(url, {
40
+ ...config,
41
+ params: {
42
+ ...(config == null ? void 0 : config.params),
43
+ ...this.getFormatParam()
44
+ }
45
+ });
46
+ }
47
+ async post(url, data, config) {
48
+ return await this.axiosInstance.post(url, data, {
49
+ ...config
50
+ });
51
+ }
52
+ async put(url, data, config) {
53
+ return await this.axiosInstance.put(url, data, {
54
+ ...config
55
+ });
56
+ }
57
+ async patch(url, data, config) {
58
+ return await this.axiosInstance.patch(url, data, {
59
+ ...config
60
+ });
61
+ }
62
+ async del(url, config) {
63
+ return await this.axiosInstance.delete(url, {
64
+ ...config
65
+ });
66
+ }
67
+ async head(url, config) {
68
+ return await this.axiosInstance.head(url, {
69
+ ...config
70
+ });
71
+ }
72
+ }
73
+
74
+ class Pages {
75
+ constructor(args, auth) {
76
+ this.globals = args;
77
+ this._auth = auth;
78
+ }
79
+ parsePageId(id) {
80
+ if (typeof id === "number") {
81
+ return id.toString();
82
+ }
83
+ if (id === "home") {
84
+ return id;
85
+ }
86
+ return `=${encodeURIComponent(encodeURIComponent(id))}`;
87
+ }
88
+ parseFileName(name) {
89
+ return `=${encodeURIComponent(encodeURIComponent(name))}`;
90
+ }
91
+ parseKey(name) {
92
+ return `${encodeURIComponent(encodeURIComponent(name))}`;
93
+ }
94
+ async getPages(funcArgs, reqArgs) {
95
+ const tld = getTld(this.globals, funcArgs.tld);
96
+ const requests = new Requests(tld, funcArgs.auth);
97
+ const res = await requests.get(`/pages`, {
98
+ params: {
99
+ ...reqArgs
100
+ }
101
+ });
102
+ return res.data;
103
+ }
104
+ async getPage(id, funcArgs, reqArgs) {
105
+ const pageId = this.parsePageId(id);
106
+ const tld = getTld(this.globals, funcArgs.tld);
107
+ const requests = new Requests(tld, funcArgs.auth);
108
+ const res = await requests.get(`/pages/${pageId}`, {
109
+ params: {
110
+ ...reqArgs
111
+ }
112
+ });
113
+ return res.data;
114
+ }
115
+ async getPageContents(id, funcArgs, reqArgs) {
116
+ const pageId = this.parsePageId(id);
117
+ const tld = getTld(this.globals, funcArgs.tld);
118
+ const requests = new Requests(tld, funcArgs.auth);
119
+ const res = await requests.get(`/pages/${pageId}/contents`, {
120
+ params: {
121
+ ...reqArgs
122
+ }
123
+ });
124
+ return res.data;
125
+ }
126
+ async getPageContentsExplain(id, funcArgs, reqArgs) {
127
+ const pageId = this.parsePageId(id);
128
+ const tld = getTld(this.globals, funcArgs.tld);
129
+ const requests = new Requests(tld, funcArgs.auth);
130
+ const res = await requests.get(`/pages/${pageId}/contents/explain`, {
131
+ params: {
132
+ ...reqArgs
133
+ }
134
+ });
135
+ return res.data;
136
+ }
137
+ async getPageDiff(id, funcArgs, reqArgs) {
138
+ const pageId = this.parsePageId(id);
139
+ const tld = getTld(this.globals, funcArgs.tld);
140
+ const requests = new Requests(tld, funcArgs.auth);
141
+ const res = await requests.get(`/pages/${pageId}/diff`, {
142
+ params: {
143
+ ...reqArgs
144
+ }
145
+ });
146
+ return res.data;
147
+ }
148
+ async getPageExplain(id, funcArgs, reqArgs) {
149
+ const pageId = this.parsePageId(id);
150
+ const tld = getTld(this.globals, funcArgs.tld);
151
+ const requests = new Requests(tld, funcArgs.auth);
152
+ const res = await requests.get(`/pages/${pageId}/explain`, {
153
+ params: {
154
+ ...reqArgs
155
+ }
156
+ });
157
+ return res.data;
158
+ }
159
+ async getPageExportToken(id, token, funcArgs, reqArgs) {
160
+ const pageId = this.parsePageId(id);
161
+ const tld = getTld(this.globals, funcArgs.tld);
162
+ const requests = new Requests(tld, funcArgs.auth);
163
+ const res = await requests.get(`/pages/${pageId}/export/${token}`, {
164
+ params: {
165
+ ...reqArgs
166
+ },
167
+ responseType: "stream"
168
+ });
169
+ return res.data;
170
+ }
171
+ async getPageExportTokenFilename(id, token, filename, funcArgs, reqArgs) {
172
+ const pageId = this.parsePageId(id);
173
+ const filenameId = this.parseFileName(filename);
174
+ const tld = getTld(this.globals, funcArgs.tld);
175
+ const requests = new Requests(tld, funcArgs.auth);
176
+ const res = await requests.get(`/pages/${pageId}/export/${token}/${filenameId}`, {
177
+ params: {
178
+ ...reqArgs
179
+ },
180
+ responseType: "stream"
181
+ });
182
+ return res.data;
183
+ }
184
+ async getPageFilesSubpages(id, funcArgs, reqArgs) {
185
+ const pageId = this.parsePageId(id);
186
+ const tld = getTld(this.globals, funcArgs.tld);
187
+ const requests = new Requests(tld, funcArgs.auth);
188
+ const res = await requests.get(`/pages/${pageId}/explain`, {
189
+ params: {
190
+ ...reqArgs
191
+ }
192
+ });
193
+ return res.data;
194
+ }
195
+ async getPageFiles(id, funcArgs, reqArgs) {
196
+ const pageId = this.parsePageId(id);
197
+ const tld = getTld(this.globals, funcArgs.tld);
198
+ const requests = new Requests(tld, funcArgs.auth);
199
+ const res = await requests.get(`/pages/${pageId}/explain`, {
200
+ params: {
201
+ ...reqArgs
202
+ }
203
+ });
204
+ return res.data;
205
+ }
206
+ async getPageFile(id, filename, funcArgs, reqArgs) {
207
+ const pageId = this.parsePageId(id);
208
+ const filenameId = this.parseFileName(filename);
209
+ const tld = getTld(this.globals, funcArgs.tld);
210
+ const requests = new Requests(tld, funcArgs.auth);
211
+ const res = await requests.get(`/pages/${pageId}/files/${filenameId}`, {
212
+ params: {
213
+ ...reqArgs
214
+ },
215
+ responseType: "stream"
216
+ });
217
+ return res.data;
218
+ }
219
+ async getPageFileDescription(id, filename, funcArgs, reqArgs) {
220
+ const pageId = this.parsePageId(id);
221
+ const filenameId = this.parseFileName(filename);
222
+ const tld = getTld(this.globals, funcArgs.tld);
223
+ const requests = new Requests(tld, funcArgs.auth);
224
+ const res = await requests.get(`/pages/${pageId}/files/${filenameId}/description`, {
225
+ params: {
226
+ ...reqArgs
227
+ },
228
+ responseType: "stream"
229
+ });
230
+ return res.data;
231
+ }
232
+ async getPageFileInfo(id, filename, funcArgs, reqArgs) {
233
+ const pageId = this.parsePageId(id);
234
+ const filenameId = this.parseFileName(filename);
235
+ const tld = getTld(this.globals, funcArgs.tld);
236
+ const requests = new Requests(tld, funcArgs.auth);
237
+ const res = await requests.get(`/pages/${pageId}/files/${filenameId}/info`, {
238
+ params: {
239
+ ...reqArgs
240
+ }
241
+ });
242
+ return res.data;
243
+ }
244
+ async getPageFileRevisions(id, filename, funcArgs, reqArgs) {
245
+ const pageId = this.parsePageId(id);
246
+ const filenameId = this.parseFileName(filename);
247
+ const tld = getTld(this.globals, funcArgs.tld);
248
+ const requests = new Requests(tld, funcArgs.auth);
249
+ const res = await requests.get(`/pages/${pageId}/files/${filenameId}/revisions`, {
250
+ params: {
251
+ ...reqArgs
252
+ }
253
+ });
254
+ return res.data;
255
+ }
256
+ async getPageFind(id, funcArgs, reqArgs) {
257
+ const pageId = this.parsePageId(id);
258
+ const tld = getTld(this.globals, funcArgs.tld);
259
+ const requests = new Requests(tld, funcArgs.auth);
260
+ const res = await requests.get(`/pages/${pageId}/find`, {
261
+ params: {
262
+ ...reqArgs
263
+ }
264
+ });
265
+ return res.data;
266
+ }
267
+ async getPageInfo(id, funcArgs, reqArgs) {
268
+ const pageId = this.parsePageId(id);
269
+ const tld = getTld(this.globals, funcArgs.tld);
270
+ const requests = new Requests(tld, funcArgs.auth);
271
+ const res = await requests.get(`/pages/${pageId}/info`, {
272
+ params: {
273
+ ...reqArgs
274
+ }
275
+ });
276
+ return res.data;
277
+ }
278
+ async getPageLinks(id, funcArgs, reqArgs) {
279
+ const pageId = this.parsePageId(id);
280
+ const tld = getTld(this.globals, funcArgs.tld);
281
+ const requests = new Requests(tld, funcArgs.auth);
282
+ const res = await requests.get(`/pages/${pageId}/links`, {
283
+ params: {
284
+ ...reqArgs
285
+ }
286
+ });
287
+ return res.data;
288
+ }
289
+ async getPagePDF(id, funcArgs, reqArgs) {
290
+ const pageId = this.parsePageId(id);
291
+ const tld = getTld(this.globals, funcArgs.tld);
292
+ const requests = new Requests(tld, funcArgs.auth);
293
+ const res = await requests.get(`/pages/${pageId}/pdf`, {
294
+ params: {
295
+ ...reqArgs
296
+ },
297
+ responseType: "stream"
298
+ });
299
+ return res.data;
300
+ }
301
+ async getPagePDFFilename(id, filename, funcArgs, reqArgs) {
302
+ const pageId = this.parsePageId(id);
303
+ const filenameId = this.parseFileName(filename);
304
+ const tld = getTld(this.globals, funcArgs.tld);
305
+ const requests = new Requests(tld, funcArgs.auth);
306
+ const res = await requests.get(`/pages/${pageId}/pdf/${filenameId}`, {
307
+ params: {
308
+ ...reqArgs
309
+ },
310
+ responseType: "stream"
311
+ });
312
+ return res.data;
313
+ }
314
+ async getPageProperties(id, funcArgs, reqArgs) {
315
+ const pageId = this.parsePageId(id);
316
+ const tld = getTld(this.globals, funcArgs.tld);
317
+ const requests = new Requests(tld, funcArgs.auth);
318
+ const res = await requests.get(`/pages/${pageId}/properties`, {
319
+ params: {
320
+ ...reqArgs
321
+ }
322
+ });
323
+ return res.data;
324
+ }
325
+ async getPagePropertiesKey(id, key, funcArgs, reqArgs) {
326
+ const pageId = this.parsePageId(id);
327
+ const keyId = this.parseKey(key);
328
+ const tld = getTld(this.globals, funcArgs.tld);
329
+ const requests = new Requests(tld, funcArgs.auth);
330
+ const res = await requests.get(`/pages/${pageId}/properties/${keyId}`, {
331
+ params: {
332
+ ...reqArgs
333
+ }
334
+ });
335
+ return res.data;
336
+ }
337
+ async getPagePropertiesKeyInfo(id, key, funcArgs, reqArgs) {
338
+ const pageId = this.parsePageId(id);
339
+ const keyId = this.parseKey(key);
340
+ const tld = getTld(this.globals, funcArgs.tld);
341
+ const requests = new Requests(tld, funcArgs.auth);
342
+ const res = await requests.get(`/pages/${pageId}/properties/${keyId}/info`, {
343
+ params: {
344
+ ...reqArgs
345
+ }
346
+ });
347
+ return res.data;
348
+ }
349
+ async getPageRatings(id, funcArgs, reqArgs) {
350
+ const pageId = this.parsePageId(id);
351
+ const tld = getTld(this.globals, funcArgs.tld);
352
+ const requests = new Requests(tld, funcArgs.auth);
353
+ const res = await requests.get(`/pages/${pageId}/ratings`, {
354
+ params: {
355
+ ...reqArgs
356
+ }
357
+ });
358
+ return res.data;
359
+ }
360
+ async getPageRevisions(id, funcArgs, reqArgs) {
361
+ const pageId = this.parsePageId(id);
362
+ const tld = getTld(this.globals, funcArgs.tld);
363
+ const requests = new Requests(tld, funcArgs.auth);
364
+ const res = await requests.get(`/pages/${pageId}/revisions`, {
365
+ params: {
366
+ ...reqArgs
367
+ }
368
+ });
369
+ return res.data;
370
+ }
371
+ async getPageSubpages(id, funcArgs, reqArgs) {
372
+ const pageId = this.parsePageId(id);
373
+ const tld = getTld(this.globals, funcArgs.tld);
374
+ const requests = new Requests(tld, funcArgs.auth);
375
+ const res = await requests.get(`/pages/${pageId}/subpages`, {
376
+ params: {
377
+ ...reqArgs
378
+ }
379
+ });
380
+ return res.data;
381
+ }
382
+ async getPageTags(id, funcArgs, reqArgs) {
383
+ const pageId = this.parsePageId(id);
384
+ const tld = getTld(this.globals, funcArgs.tld);
385
+ const requests = new Requests(tld, funcArgs.auth);
386
+ const res = await requests.get(`/pages/${pageId}/tags`, {
387
+ params: {
388
+ ...reqArgs
389
+ }
390
+ });
391
+ return res.data;
392
+ }
393
+ async getPageTree(id, funcArgs, reqArgs) {
394
+ const pageId = this.parsePageId(id);
395
+ const tld = getTld(this.globals, funcArgs.tld);
396
+ const requests = new Requests(tld, funcArgs.auth);
397
+ const res = await requests.get(`/pages/${pageId}/tree`, {
398
+ params: {
399
+ ...reqArgs
400
+ }
401
+ });
402
+ return res.data;
403
+ }
404
+ async getPageBook(id, funcArgs, reqArgs) {
405
+ const pageId = this.parsePageId(id);
406
+ const tld = getTld(this.globals, funcArgs.tld);
407
+ const requests = new Requests(tld, funcArgs.auth);
408
+ const res = await requests.get(`/pages/book`, {
409
+ params: {
410
+ ...reqArgs
411
+ },
412
+ responseType: "stream"
413
+ });
414
+ return res.data;
415
+ }
416
+ async getPageBookFilename(id, filename, funcArgs, reqArgs) {
417
+ const pageId = this.parsePageId(id);
418
+ const filenameId = this.parseFileName(filename);
419
+ const tld = getTld(this.globals, funcArgs.tld);
420
+ const requests = new Requests(tld, funcArgs.auth);
421
+ const res = await requests.get(`/pages/book/${filename}`, {
422
+ params: {
423
+ ...reqArgs
424
+ },
425
+ responseType: "stream"
426
+ });
427
+ return res.data;
428
+ }
429
+ async getPagesCsv(funcArgs, reqArgs) {
430
+ const tld = getTld(this.globals, funcArgs.tld);
431
+ const requests = new Requests(tld, funcArgs.auth);
432
+ const res = await requests.get(`/pages/csv`, {
433
+ params: {
434
+ ...reqArgs
435
+ },
436
+ responseType: "stream"
437
+ });
438
+ return res.data;
439
+ }
440
+ async getPagesPopular(id, funcArgs, reqArgs) {
441
+ const pageId = this.parsePageId(id);
442
+ const tld = getTld(this.globals, funcArgs.tld);
443
+ const requests = new Requests(tld, funcArgs.auth);
444
+ const res = await requests.get(`/pages/popular`, {
445
+ params: {
446
+ ...reqArgs
447
+ }
448
+ });
449
+ return res.data;
450
+ }
451
+ async postPageContents(id, funcArgs, content, reqArgs) {
452
+ const pageId = this.parsePageId(id);
453
+ const tld = getTld(this.globals, funcArgs.tld);
454
+ const requests = new Requests(tld, funcArgs.auth);
455
+ const res = await requests.post(`/pages/${pageId}/contents`, content != null ? content : "", {
456
+ headers: {
457
+ "Content-Type": "text/plain"
458
+ },
459
+ params: {
460
+ ...reqArgs
461
+ }
462
+ });
463
+ return res.data;
464
+ }
465
+ async putPageUnorder(id, funcArgs) {
466
+ const pageId = this.parsePageId(id);
467
+ const tld = getTld(this.globals, funcArgs.tld);
468
+ const requests = new Requests(tld, funcArgs.auth);
469
+ const res = await requests.put(`/pages/${pageId}/unorder`, "");
470
+ return res.data;
471
+ }
472
+ async delPageDelete(id, funcArgs, reqArgs) {
473
+ const pageId = this.parsePageId(id);
474
+ const tld = getTld(this.globals, funcArgs.tld);
475
+ const requests = new Requests(tld, funcArgs.auth);
476
+ const res = await requests.del(`/pages/${pageId}`, {
477
+ params: {
478
+ ...reqArgs
479
+ }
480
+ });
481
+ return res.data;
482
+ }
483
+ async delPageAllowed(id, funcArgs, reqArgs) {
484
+ const pageId = this.parsePageId(id);
485
+ const tld = getTld(this.globals, funcArgs.tld);
486
+ const requests = new Requests(tld, funcArgs.auth);
487
+ const res = await requests.del(`/pages/${pageId}/allowed`, {
488
+ params: {
489
+ ...reqArgs
490
+ }
491
+ });
492
+ return res.data;
493
+ }
494
+ async postPageCopied(id, funcArgs, reqArgs) {
495
+ const pageId = this.parsePageId(id);
496
+ const tld = getTld(this.globals, funcArgs.tld);
497
+ const requests = new Requests(tld, funcArgs.auth);
498
+ const res = await requests.post(`/pages/${pageId}/copy`, "", {
499
+ params: {
500
+ ...reqArgs
501
+ }
502
+ });
503
+ return res.data;
504
+ }
505
+ async postPageExport(id, funcArgs) {
506
+ const pageId = this.parsePageId(id);
507
+ const tld = getTld(this.globals, funcArgs.tld);
508
+ const requests = new Requests(tld, funcArgs.auth);
509
+ const res = await requests.post(`/pages/${pageId}/export`, "");
510
+ return res.data;
511
+ }
512
+ async delPageFileName(id, filename, funcArgs, reqArgs) {
513
+ const pageId = this.parsePageId(id);
514
+ const filenameId = this.parseFileName(filename);
515
+ const tld = getTld(this.globals, funcArgs.tld);
516
+ const requests = new Requests(tld, funcArgs.auth);
517
+ const res = await requests.del(`/pages/${pageId}/files/${filenameId}`, {
518
+ params: {
519
+ ...reqArgs
520
+ }
521
+ });
522
+ return res.data;
523
+ }
524
+ async headPageFileName(id, filename, funcArgs, reqArgs) {
525
+ const pageId = this.parsePageId(id);
526
+ const filenameId = this.parseFileName(filename);
527
+ const tld = getTld(this.globals, funcArgs.tld);
528
+ const requests = new Requests(tld, funcArgs.auth);
529
+ const res = await requests.head(`/pages/${pageId}/files/${filenameId}`, {
530
+ params: {
531
+ ...reqArgs
532
+ }
533
+ });
534
+ return res.data;
535
+ }
536
+ async putPageFileName(id, filename, file, funcArgs, reqArgs) {
537
+ const pageId = this.parsePageId(id);
538
+ const filenameId = this.parseFileName(filename);
539
+ const tld = getTld(this.globals, funcArgs.tld);
540
+ const requests = new Requests(tld, funcArgs.auth);
541
+ const res = await requests.put(`/pages/${pageId}/files/${filenameId}`, file, {
542
+ headers: {
543
+ "Content-Type": "application/octet-stream"
544
+ },
545
+ params: {
546
+ ...reqArgs
547
+ }
548
+ });
549
+ return res.data;
550
+ }
551
+ async delPageFileNameDescription(id, filename, funcArgs, reqArgs) {
552
+ const pageId = this.parsePageId(id);
553
+ const filenameId = this.parseFileName(filename);
554
+ const tld = getTld(this.globals, funcArgs.tld);
555
+ const requests = new Requests(tld, funcArgs.auth);
556
+ const res = await requests.del(`/pages/${pageId}/files/${filenameId}/description`, {
557
+ params: {
558
+ ...reqArgs
559
+ }
560
+ });
561
+ return res.data;
562
+ }
563
+ async putPageFileNameDescription(id, filename, funcArgs, reqArgs) {
564
+ const pageId = this.parsePageId(id);
565
+ const filenameId = this.parseFileName(filename);
566
+ const tld = getTld(this.globals, funcArgs.tld);
567
+ const requests = new Requests(tld, funcArgs.auth);
568
+ const res = await requests.put(`/pages/${pageId}/files/${filenameId}/description`, {
569
+ params: {
570
+ ...reqArgs
571
+ }
572
+ });
573
+ return res.data;
574
+ }
575
+ async putPageFileNamePropertiesKey(id, filename, key, funcArgs, reqArgs) {
576
+ const pageId = this.parsePageId(id);
577
+ const filenameId = this.parseFileName(filename);
578
+ const keyId = this.parseKey(key);
579
+ const tld = getTld(this.globals, funcArgs.tld);
580
+ const requests = new Requests(tld, funcArgs.auth);
581
+ const res = await requests.put(`/pages/${pageId}/files/${filenameId}/properties/${keyId}`, "", {
582
+ params: {
583
+ ...reqArgs
584
+ }
585
+ });
586
+ return res.data;
587
+ }
588
+ async putPageImport(id, funcArgs, reqArgs) {
589
+ const pageId = this.parsePageId(id);
590
+ const tld = getTld(this.globals, funcArgs.tld);
591
+ const requests = new Requests(tld, funcArgs.auth);
592
+ const res = await requests.put(`/pages/${pageId}/import`, "", {
593
+ params: {
594
+ ...reqArgs
595
+ }
596
+ });
597
+ return res.data;
598
+ }
599
+ async putPageMove(id, funcArgs, reqArgs) {
600
+ const pageId = this.parsePageId(id);
601
+ const tld = getTld(this.globals, funcArgs.tld);
602
+ const requests = new Requests(tld, funcArgs.auth);
603
+ const res = await requests.put(`/pages/${pageId}/move`, "", {
604
+ params: {
605
+ ...reqArgs
606
+ }
607
+ });
608
+ return res.data;
609
+ }
610
+ async putPageOrder(id, funcArgs, reqArgs) {
611
+ const pageId = this.parsePageId(id);
612
+ const tld = getTld(this.globals, funcArgs.tld);
613
+ const requests = new Requests(tld, funcArgs.auth);
614
+ const res = await requests.put(`/pages/${pageId}/order`, "", {
615
+ params: {
616
+ ...reqArgs
617
+ }
618
+ });
619
+ return res.data;
620
+ }
621
+ async postPageProperties(id, funcArgs, reqArgs) {
622
+ const pageId = this.parsePageId(id);
623
+ const tld = getTld(this.globals, funcArgs.tld);
624
+ const requests = new Requests(tld, funcArgs.auth);
625
+ const res = await requests.post(`/pages/${pageId}/properties`, "", {
626
+ params: {
627
+ ...reqArgs
628
+ }
629
+ });
630
+ return res.data;
631
+ }
632
+ async putPageProperties(id, funcArgs, reqArgs) {
633
+ const pageId = this.parsePageId(id);
634
+ const tld = getTld(this.globals, funcArgs.tld);
635
+ const requests = new Requests(tld, funcArgs.auth);
636
+ const res = await requests.put(`/pages/${pageId}/properties`, "", {
637
+ params: {
638
+ ...reqArgs
639
+ }
640
+ });
641
+ return res.data;
642
+ }
643
+ async deletePagePropertiesKey(id, key, funcArgs, reqArgs) {
644
+ const pageId = this.parsePageId(id);
645
+ const keyId = this.parseKey(key);
646
+ const tld = getTld(this.globals, funcArgs.tld);
647
+ const requests = new Requests(tld, funcArgs.auth);
648
+ const res = await requests.del(`/pages/${pageId}/properties/${keyId}`, {
649
+ params: {
650
+ ...reqArgs
651
+ }
652
+ });
653
+ return res.data;
654
+ }
655
+ async putPagePropertiesKey(id, key, funcArgs, reqArgs) {
656
+ const pageId = this.parsePageId(id);
657
+ const keyId = this.parseKey(key);
658
+ const tld = getTld(this.globals, funcArgs.tld);
659
+ const requests = new Requests(tld, funcArgs.auth);
660
+ const res = await requests.put(`/pages/${pageId}/properties/${keyId}`, "", {
661
+ params: {
662
+ ...reqArgs
663
+ }
664
+ });
665
+ return res.data;
666
+ }
667
+ async postPageRatings(id, funcArgs, reqArgs) {
668
+ const pageId = this.parsePageId(id);
669
+ const tld = getTld(this.globals, funcArgs.tld);
670
+ const requests = new Requests(tld, funcArgs.auth);
671
+ const res = await requests.post(`/pages/${pageId}/ratings`, "", {
672
+ params: {
673
+ ...reqArgs
674
+ }
675
+ });
676
+ return res.data;
677
+ }
678
+ async postPageRevert(id, funcArgs, reqArgs) {
679
+ const pageId = this.parsePageId(id);
680
+ const tld = getTld(this.globals, funcArgs.tld);
681
+ const requests = new Requests(tld, funcArgs.auth);
682
+ const res = await requests.post(`/pages/${pageId}/revert`, "", {
683
+ params: {
684
+ ...reqArgs
685
+ }
686
+ });
687
+ return res.data;
688
+ }
689
+ async deletePageSecurity(id, funcArgs, reqArgs) {
690
+ const pageId = this.parsePageId(id);
691
+ const tld = getTld(this.globals, funcArgs.tld);
692
+ const requests = new Requests(tld, funcArgs.auth);
693
+ const res = await requests.del(`/pages/${pageId}/security`, {
694
+ params: {
695
+ ...reqArgs
696
+ }
697
+ });
698
+ return res.data;
699
+ }
700
+ async postPageSecurity(id, funcArgs, content, reqArgs) {
701
+ const pageId = this.parsePageId(id);
702
+ const tld = getTld(this.globals, funcArgs.tld);
703
+ const requests = new Requests(tld, funcArgs.auth);
704
+ const res = await requests.post(`/pages/${pageId}/security`, content, {
705
+ params: {
706
+ ...reqArgs
707
+ }
708
+ });
709
+ return res.data;
710
+ }
711
+ async putPageSecurity(id, funcArgs, content, reqArgs) {
712
+ const pageId = this.parsePageId(id);
713
+ const tld = getTld(this.globals, funcArgs.tld);
714
+ const requests = new Requests(tld, funcArgs.auth);
715
+ const res = await requests.put(`/pages/${pageId}/security`, content, {
716
+ params: {
717
+ ...reqArgs
718
+ }
719
+ });
720
+ return res.data;
721
+ }
722
+ async putPageTags(id, funcArgs, content, reqArgs) {
723
+ const pageId = this.parsePageId(id);
724
+ const tld = getTld(this.globals, funcArgs.tld);
725
+ const requests = new Requests(tld, funcArgs.auth);
726
+ const res = await requests.put(`/pages/${pageId}/tags`, content, {
727
+ params: {
728
+ ...reqArgs
729
+ }
730
+ });
731
+ return res.data;
732
+ }
733
+ }
734
+
735
+ class Auth {
736
+ constructor() {
737
+ this.token = null;
738
+ }
739
+ BrowserToken({
740
+ key
741
+ }) {
742
+ this.token = key;
743
+ return this;
744
+ }
745
+ ServerToken({
746
+ key,
747
+ secret,
748
+ user
749
+ }) {
750
+ if (!key || !secret || !user) {
751
+ throw new Error("Missing required parameters: key, secret, user");
752
+ }
753
+ const epoch = Math.floor(Date.now() / 1000);
754
+ const hmac = createHmac('sha256', secret);
755
+ hmac.update(`${key}${epoch}=${user}`);
756
+ const hash = hmac.digest('hex');
757
+ this.token = `${key}_${epoch}_=${user}_${hash}`;
758
+ return this;
759
+ }
760
+ getToken() {
761
+ return this.token;
762
+ }
763
+ getHeader() {
764
+ return {
765
+ 'X-Deki-Token': this.token
766
+ };
767
+ }
768
+ }
769
+
770
+ class Groups {
771
+ constructor(args, auth) {
772
+ this.globals = args;
773
+ this._auth = auth;
774
+ }
775
+ parseGroupId(id) {
776
+ if (typeof id === "number") {
777
+ return id.toString();
778
+ }
779
+ return `=${encodeURIComponent(id)}`;
780
+ }
781
+ async getGroups(funcArgs, reqArgs) {
782
+ const tld = getTld(this.globals, funcArgs.tld);
783
+ const requests = new Requests(tld, funcArgs.auth);
784
+ const res = await requests.get(`/groups`, {
785
+ params: {
786
+ ...reqArgs
787
+ }
788
+ });
789
+ return res.data;
790
+ }
791
+ async getGroup(id, funcArgs, reqArgs) {
792
+ const groupId = this.parseGroupId(id);
793
+ const tld = getTld(this.globals, funcArgs.tld);
794
+ const requests = new Requests(tld, funcArgs.auth);
795
+ const res = await requests.get(`/groups/${groupId}`, {
796
+ params: {
797
+ ...reqArgs
798
+ }
799
+ });
800
+ return res.data;
801
+ }
802
+ async getGroupUser(id, funcArgs, reqArgs) {
803
+ const groupId = this.parseGroupId(id);
804
+ const tld = getTld(this.globals, funcArgs.tld);
805
+ const requests = new Requests(tld, funcArgs.auth);
806
+ const res = await requests.get(`/groups/${groupId}/users`, {
807
+ params: {
808
+ ...reqArgs
809
+ }
810
+ });
811
+ return res.data;
812
+ }
813
+ }
814
+
815
+ class Events {
816
+ constructor(args, auth) {
817
+ this.globals = args;
818
+ this._auth = auth;
819
+ }
820
+ parsePageId(id) {
821
+ if (typeof id === "number") {
822
+ return id.toString();
823
+ }
824
+ return `=${encodeURIComponent(encodeURIComponent(id))}`;
825
+ }
826
+ parseUserId(id) {
827
+ if (typeof id === "number") {
828
+ return id.toString();
829
+ }
830
+ return `=${encodeURIComponent(encodeURIComponent(id))}`;
831
+ }
832
+ async getPageHierarchyById(id, funcArgs, reqArgs) {
833
+ const pageId = this.parsePageId(id);
834
+ const tld = getTld(this.globals, funcArgs.tld);
835
+ const requests = new Requests(tld, funcArgs.auth);
836
+ const res = await requests.get(`events/page-hierarchy/${pageId}`, {
837
+ params: {
838
+ ...reqArgs
839
+ }
840
+ });
841
+ return res.data;
842
+ }
843
+ async getPageHierarchyDetailById(id, detailId, funcArgs, reqArgs) {
844
+ const pageId = this.parsePageId(id);
845
+ const tld = getTld(this.globals, funcArgs.tld);
846
+ const requests = new Requests(tld, funcArgs.auth);
847
+ const res = await requests.get(`events/page-hierarchy/${pageId}/${detailId}`, {
848
+ params: {
849
+ ...reqArgs
850
+ }
851
+ });
852
+ return res.data;
853
+ }
854
+ async getEventPage(id, funcArgs, reqArgs) {
855
+ const pageId = this.parsePageId(id);
856
+ const tld = getTld(this.globals, funcArgs.tld);
857
+ const requests = new Requests(tld, funcArgs.auth);
858
+ const res = await requests.get(`events/page/${pageId}`, {
859
+ params: {
860
+ ...reqArgs
861
+ }
862
+ });
863
+ return res.data;
864
+ }
865
+ async getEventPageDetail(id, detailId, funcArgs, reqArgs) {
866
+ const pageId = this.parsePageId(id);
867
+ const tld = getTld(this.globals, funcArgs.tld);
868
+ const requests = new Requests(tld, funcArgs.auth);
869
+ const res = await requests.get(`/events/page/${pageId}/${detailId}`, {
870
+ params: {
871
+ ...reqArgs
872
+ }
873
+ });
874
+ return res.data;
875
+ }
876
+ async getEventUserPage(userId, funcArgs, reqArgs) {
877
+ const tld = getTld(this.globals, funcArgs.tld);
878
+ const requests = new Requests(tld, funcArgs.auth);
879
+ const res = await requests.get(`/events/user-page/${this.parseUserId(userId)}`, {
880
+ params: {
881
+ ...reqArgs
882
+ }
883
+ });
884
+ return res.data;
885
+ }
886
+ async getEventUserDetailPage(userId, detailId, funcArgs, reqArgs) {
887
+ const tld = getTld(this.globals, funcArgs.tld);
888
+ const requests = new Requests(tld, funcArgs.auth);
889
+ const res = await requests.get(`/events/user-page/${this.parseUserId(userId)}/${detailId}`, {
890
+ params: {
891
+ ...reqArgs
892
+ }
893
+ });
894
+ return res.data;
895
+ }
896
+ }
897
+
898
+ class Archive {
899
+ constructor(args, auth) {
900
+ this.globals = args;
901
+ this._auth = auth;
902
+ }
903
+ parseFileName(name) {
904
+ return `=${encodeURIComponent(encodeURIComponent(name))}`;
905
+ }
906
+ async getArchive(funcArgs, reqArgs) {
907
+ const tld = getTld(this.globals, funcArgs.tld);
908
+ const requests = new Requests(tld, funcArgs.auth);
909
+ const res = await requests.get(`/archive`, {
910
+ params: {
911
+ ...reqArgs
912
+ }
913
+ });
914
+ return res.data;
915
+ }
916
+ async getArchiveFiles(funcArgs, reqArgs) {
917
+ const tld = getTld(this.globals, funcArgs.tld);
918
+ const requests = new Requests(tld, funcArgs.auth);
919
+ const res = await requests.get(`/archive/files`, {
920
+ params: {
921
+ ...reqArgs
922
+ }
923
+ });
924
+ return res.data;
925
+ }
926
+ async getArchiveFile(fileId, funcArgs, reqArgs) {
927
+ const tld = getTld(this.globals, funcArgs.tld);
928
+ const requests = new Requests(tld, funcArgs.auth);
929
+ const res = await requests.get(`/archive/files/${fileId}`, {
930
+ params: {
931
+ ...reqArgs
932
+ },
933
+ responseType: "stream"
934
+ });
935
+ return res.data;
936
+ }
937
+ async getArchiveFileByName(fileId, fileName, funcArgs, reqArgs) {
938
+ const tld = getTld(this.globals, funcArgs.tld);
939
+ const parseFileName = this.parseFileName(fileName);
940
+ const requests = new Requests(tld, funcArgs.auth);
941
+ const res = await requests.get(`/archive/files/${fileId}/${parseFileName}`, {
942
+ params: {
943
+ ...reqArgs
944
+ },
945
+ responseType: "stream"
946
+ });
947
+ return res.data;
948
+ }
949
+ async getArchiveFileInfo(fileId, funcArgs, reqArgs) {
950
+ const tld = getTld(this.globals, funcArgs.tld);
951
+ const requests = new Requests(tld, funcArgs.auth);
952
+ const res = await requests.get(`/archive/files/${fileId}/info`, {
953
+ params: {
954
+ ...reqArgs
955
+ }
956
+ });
957
+ return res.data;
958
+ }
959
+ async getArchivePages(funcArgs, reqArgs) {
960
+ const tld = getTld(this.globals, funcArgs.tld);
961
+ const requests = new Requests(tld, funcArgs.auth);
962
+ const res = await requests.get(`/archive/pages`, {
963
+ params: {
964
+ ...reqArgs
965
+ }
966
+ });
967
+ return res.data;
968
+ }
969
+ async getArchivePage(pageId, funcArgs, reqArgs) {
970
+ const tld = getTld(this.globals, funcArgs.tld);
971
+ const requests = new Requests(tld, funcArgs.auth);
972
+ const res = await requests.get(`/archive/page/${pageId}`, {
973
+ params: {
974
+ ...reqArgs
975
+ }
976
+ });
977
+ return res.data;
978
+ }
979
+ async getArchivePageContents(pageId, funcArgs, reqArgs) {
980
+ const tld = getTld(this.globals, funcArgs.tld);
981
+ const requests = new Requests(tld, funcArgs.auth);
982
+ const res = await requests.get(`/archive/page/${pageId}/contents`, {
983
+ params: {
984
+ ...reqArgs
985
+ }
986
+ });
987
+ return res.data;
988
+ }
989
+ async getArchivePageInfo(pageId, funcArgs, reqArgs) {
990
+ const tld = getTld(this.globals, funcArgs.tld);
991
+ const requests = new Requests(tld, funcArgs.auth);
992
+ const res = await requests.get(`/archive/page/${pageId}/info`, {
993
+ params: {
994
+ ...reqArgs
995
+ }
996
+ });
997
+ return res.data;
998
+ }
999
+ async getArchivePageSubPages(pageId, funcArgs, reqArgs) {
1000
+ const tld = getTld(this.globals, funcArgs.tld);
1001
+ const requests = new Requests(tld, funcArgs.auth);
1002
+ const res = await requests.get(`/archive/page/${pageId}/subpages`, {
1003
+ params: {
1004
+ ...reqArgs
1005
+ }
1006
+ });
1007
+ return res.data;
1008
+ }
1009
+ }
1010
+
1011
+ class Site {
1012
+ constructor(args, auth) {
1013
+ this.globals = args;
1014
+ this._auth = auth;
1015
+ }
1016
+ parsePageId(id) {
1017
+ if (typeof id === "number") {
1018
+ return id.toString();
1019
+ }
1020
+ return `=${encodeURIComponent(encodeURIComponent(id))}`;
1021
+ }
1022
+ parseKey(key) {
1023
+ return encodeURIComponent(encodeURIComponent(key));
1024
+ }
1025
+ async getSiteActivity(funcArgs, reqArgs) {
1026
+ const tld = getTld(this.globals, funcArgs.tld);
1027
+ const requests = new Requests(tld, funcArgs.auth);
1028
+ const res = await requests.get(`/site/activity`, {
1029
+ params: {
1030
+ ...reqArgs
1031
+ }
1032
+ });
1033
+ return res.data;
1034
+ }
1035
+ async getSiteExportGroups(funcArgs) {
1036
+ const tld = getTld(this.globals, funcArgs.tld);
1037
+ const requests = new Requests(tld, funcArgs.auth);
1038
+ const res = await requests.get(`/site/export/groups`);
1039
+ return res.data;
1040
+ }
1041
+ async getSiteExportUsers(funcArgs) {
1042
+ const tld = getTld(this.globals, funcArgs.tld);
1043
+ const requests = new Requests(tld, funcArgs.auth);
1044
+ const res = await requests.get(`/site/export/users`);
1045
+ return res.data;
1046
+ }
1047
+ async getSiteSubPagesTags(id, funcArgs, reqArgs) {
1048
+ const pageId = this.parsePageId(id);
1049
+ const tld = getTld(this.globals, funcArgs.tld);
1050
+ const requests = new Requests(tld, funcArgs.auth);
1051
+ const res = await requests.get(`/site/nav/${pageId}/children`, {
1052
+ params: {
1053
+ ...reqArgs
1054
+ }
1055
+ });
1056
+ return res.data;
1057
+ }
1058
+ async getSiteFullNavTreeTags(id, funcArgs, reqArgs) {
1059
+ const pageId = this.parsePageId(id);
1060
+ const tld = getTld(this.globals, funcArgs.tld);
1061
+ const requests = new Requests(tld, funcArgs.auth);
1062
+ const res = await requests.get(`/site/nav/${pageId}/full`, {
1063
+ params: {
1064
+ ...reqArgs
1065
+ }
1066
+ });
1067
+ return res.data;
1068
+ }
1069
+ async getSiteOperations(funcArgs, reqArgs) {
1070
+ const tld = getTld(this.globals, funcArgs.tld);
1071
+ const requests = new Requests(tld, funcArgs.auth);
1072
+ const res = await requests.get(`/site/operations`, {
1073
+ params: {
1074
+ ...reqArgs
1075
+ }
1076
+ });
1077
+ return res.data;
1078
+ }
1079
+ async getSiteProperties(funcArgs, reqArgs) {
1080
+ const tld = getTld(this.globals, funcArgs.tld);
1081
+ const requests = new Requests(tld, funcArgs.auth);
1082
+ const res = await requests.get(`/site/properties`, {
1083
+ params: {
1084
+ ...reqArgs
1085
+ }
1086
+ });
1087
+ return res.data;
1088
+ }
1089
+ async GetSiteKeyProperties(identifier, funcArgs, reqArgs) {
1090
+ const key = this.parseKey(identifier);
1091
+ const tld = getTld(this.globals, funcArgs.tld);
1092
+ const requests = new Requests(tld, funcArgs.auth);
1093
+ const res = await requests.get(`/site/properties/${key}`, {
1094
+ params: {
1095
+ ...reqArgs
1096
+ }
1097
+ });
1098
+ return res.data;
1099
+ }
1100
+ async GetSiteKeyPropertiesInfo(identifier, funcArgs, reqArgs) {
1101
+ const key = this.parseKey(identifier);
1102
+ const tld = getTld(this.globals, funcArgs.tld);
1103
+ const requests = new Requests(tld, funcArgs.auth);
1104
+ const res = await requests.get(`/site/properties/${key}/info`, {
1105
+ params: {
1106
+ ...reqArgs
1107
+ }
1108
+ });
1109
+ return res.data;
1110
+ }
1111
+ async GetSiteQuery(funcArgs, reqArgs) {
1112
+ const tld = getTld(this.globals, funcArgs.tld);
1113
+ const requests = new Requests(tld, funcArgs.auth);
1114
+ const res = await requests.get(`/site/query`, {
1115
+ params: {
1116
+ ...reqArgs
1117
+ }
1118
+ });
1119
+ return res.data;
1120
+ }
1121
+ async GetSiteStatus(funcArgs) {
1122
+ const tld = getTld(this.globals, funcArgs.tld);
1123
+ const requests = new Requests(tld, funcArgs.auth);
1124
+ const res = await requests.get(`/site/status`);
1125
+ return res.data;
1126
+ }
1127
+ async GetSiteTags(funcArgs, reqArgs) {
1128
+ const tld = getTld(this.globals, funcArgs.tld);
1129
+ const requests = new Requests(tld, funcArgs.auth);
1130
+ const res = await requests.get(`/site/tags`, {
1131
+ params: {
1132
+ ...reqArgs
1133
+ }
1134
+ });
1135
+ return res.data;
1136
+ }
1137
+ async GetSiteTag(funcArgs, reqArgs) {
1138
+ const tld = getTld(this.globals, funcArgs.tld);
1139
+ const requests = new Requests(tld, funcArgs.auth);
1140
+ const res = await requests.get(`/site/tag`, {
1141
+ params: {
1142
+ ...reqArgs
1143
+ }
1144
+ });
1145
+ return res.data;
1146
+ }
1147
+ }
1148
+
1149
+ class contextMaps {
1150
+ constructor(args, auth) {
1151
+ this.globals = args;
1152
+ this._auth = auth;
1153
+ }
1154
+ parseFileName(name) {
1155
+ return `=${encodeURIComponent(encodeURIComponent(name))}`;
1156
+ }
1157
+ async getContextMaps(funcArgs, reqArgs) {
1158
+ const tld = getTld(this.globals, funcArgs.tld);
1159
+ const requests = new Requests(tld, funcArgs.auth);
1160
+ const res = await requests.get(`/contextmaps`, {
1161
+ params: {
1162
+ ...reqArgs
1163
+ }
1164
+ });
1165
+ return res.data;
1166
+ }
1167
+ async getContextMapsById(language, id, funcArgs, reqArgs) {
1168
+ const tld = getTld(this.globals, funcArgs.tld);
1169
+ const requests = new Requests(tld, funcArgs.auth);
1170
+ const res = await requests.get(`/contextmaps/${language}/${id}`, {
1171
+ params: {
1172
+ ...reqArgs
1173
+ }
1174
+ });
1175
+ return res.data;
1176
+ }
1177
+ }
1178
+
1179
+ class Users {
1180
+ constructor(args, auth) {
1181
+ this.globals = args;
1182
+ this._auth = auth;
1183
+ }
1184
+ parseUserId(id) {
1185
+ if (typeof id === "number") {
1186
+ return id.toString();
1187
+ }
1188
+ return `=${encodeURIComponent(encodeURIComponent(id))}`;
1189
+ }
1190
+ parseKey(key) {
1191
+ return encodeURIComponent(encodeURIComponent(key));
1192
+ }
1193
+ async getUsers(funcArgs, reqArgs) {
1194
+ const tld = getTld(this.globals, funcArgs.tld);
1195
+ const requests = new Requests(tld, funcArgs.auth);
1196
+ const res = await requests.get(`/users`, {
1197
+ params: {
1198
+ ...reqArgs
1199
+ }
1200
+ });
1201
+ return res.data;
1202
+ }
1203
+ async getUser(id, funcArgs, reqArgs) {
1204
+ const userId = this.parseUserId(id);
1205
+ const tld = getTld(this.globals, funcArgs.tld);
1206
+ const requests = new Requests(tld, funcArgs.auth);
1207
+ const res = await requests.get(`/users/${userId}`, {
1208
+ params: {
1209
+ ...reqArgs
1210
+ }
1211
+ });
1212
+ return res.data;
1213
+ }
1214
+ async getUserMetrics(id, funcArgs, reqArgs) {
1215
+ const userId = this.parseUserId(id);
1216
+ const tld = getTld(this.globals, funcArgs.tld);
1217
+ const requests = new Requests(tld, funcArgs.auth);
1218
+ const res = await requests.get(`/users/${userId}/metrics`, {
1219
+ params: {
1220
+ ...reqArgs
1221
+ }
1222
+ });
1223
+ return res.data;
1224
+ }
1225
+ async getUserProperties(id, funcArgs, reqArgs) {
1226
+ const userId = this.parseUserId(id);
1227
+ const tld = getTld(this.globals, funcArgs.tld);
1228
+ const requests = new Requests(tld, funcArgs.auth);
1229
+ const res = await requests.get(`/users/${userId}/properties`, {
1230
+ params: {
1231
+ ...reqArgs
1232
+ }
1233
+ });
1234
+ return res.data;
1235
+ }
1236
+ async getUserPropertiesKey(id, identifier, funcArgs, reqArgs) {
1237
+ const userId = this.parseUserId(id);
1238
+ const key = this.parseKey(identifier);
1239
+ const tld = getTld(this.globals, funcArgs.tld);
1240
+ const requests = new Requests(tld, funcArgs.auth);
1241
+ const res = await requests.get(`/users/${userId}/properties/${key}`, {
1242
+ params: {
1243
+ ...reqArgs
1244
+ }
1245
+ });
1246
+ return res.data;
1247
+ }
1248
+ async getUserPropertiesKeyInfo(id, identifier, funcArgs, reqArgs) {
1249
+ const userId = this.parseUserId(id);
1250
+ const key = this.parseKey(identifier);
1251
+ const tld = getTld(this.globals, funcArgs.tld);
1252
+ const requests = new Requests(tld, funcArgs.auth);
1253
+ const res = await requests.get(`/users/${userId}/properties/${key}/info`, {
1254
+ params: {
1255
+ ...reqArgs
1256
+ }
1257
+ });
1258
+ return res.data;
1259
+ }
1260
+ async getUsersSearch(funcArgs, reqArgs) {
1261
+ const tld = getTld(this.globals, funcArgs.tld);
1262
+ const requests = new Requests(tld, funcArgs.auth);
1263
+ const res = await requests.get(`/users/search`, {
1264
+ params: {
1265
+ ...reqArgs
1266
+ }
1267
+ });
1268
+ return res.data;
1269
+ }
1270
+ }
1271
+
1272
+ class Files {
1273
+ constructor(args, auth) {
1274
+ this.globals = args;
1275
+ this._auth = auth;
1276
+ }
1277
+ parseFileId(id) {
1278
+ if (typeof id === "number") {
1279
+ return id.toString();
1280
+ }
1281
+ return `=${encodeURIComponent(encodeURIComponent(id))}`;
1282
+ }
1283
+ parseFileName(name) {
1284
+ return `=${encodeURIComponent(encodeURIComponent(name))}`;
1285
+ }
1286
+ parseKey(key) {
1287
+ return encodeURIComponent(encodeURIComponent(key));
1288
+ }
1289
+ async getFile(id, funcArgs, reqArgs) {
1290
+ const fileId = this.parseFileId(id);
1291
+ const tld = getTld(this.globals, funcArgs.tld);
1292
+ const requests = new Requests(tld, funcArgs.auth);
1293
+ const res = await requests.get(`files/${fileId}`, {
1294
+ params: {
1295
+ ...reqArgs
1296
+ },
1297
+ responseType: "stream"
1298
+ });
1299
+ return res.data;
1300
+ }
1301
+ async getFileName(id, filename, funcArgs, reqArgs) {
1302
+ const fileId = this.parseFileId(id);
1303
+ const filenameId = this.parseFileName(filename);
1304
+ const tld = getTld(this.globals, funcArgs.tld);
1305
+ const requests = new Requests(tld, funcArgs.auth);
1306
+ const res = await requests.get(`files/${fileId}/${filenameId}`, {
1307
+ params: {
1308
+ ...reqArgs
1309
+ },
1310
+ responseType: "stream"
1311
+ });
1312
+ return res.data;
1313
+ }
1314
+ async getFileDescription(id, funcArgs, reqArgs) {
1315
+ const fileId = this.parseFileId(id);
1316
+ const tld = getTld(this.globals, funcArgs.tld);
1317
+ const requests = new Requests(tld, funcArgs.auth);
1318
+ const res = await requests.get(`files/${fileId}/description`, {
1319
+ params: {
1320
+ ...reqArgs
1321
+ },
1322
+ responseType: "stream"
1323
+ });
1324
+ return res.data;
1325
+ }
1326
+ async getFileInfo(id, funcArgs, reqArgs) {
1327
+ const fileId = this.parseFileId(id);
1328
+ const tld = getTld(this.globals, funcArgs.tld);
1329
+ const requests = new Requests(tld, funcArgs.auth);
1330
+ const res = await requests.get(`files/${fileId}/info`, {
1331
+ params: {
1332
+ ...reqArgs
1333
+ }
1334
+ });
1335
+ return res.data;
1336
+ }
1337
+ async getFileRevisions(id, funcArgs, reqArgs) {
1338
+ const fileId = this.parseFileId(id);
1339
+ const tld = getTld(this.globals, funcArgs.tld);
1340
+ const requests = new Requests(tld, funcArgs.auth);
1341
+ const res = await requests.get(`files/${fileId}/revisions`, {
1342
+ params: {
1343
+ ...reqArgs
1344
+ }
1345
+ });
1346
+ return res.data;
1347
+ }
1348
+ async deleteFile(id, funcArgs, reqArgs) {
1349
+ const fileId = this.parseFileId(id);
1350
+ const tld = getTld(this.globals, funcArgs.tld);
1351
+ const requests = new Requests(tld, funcArgs.auth);
1352
+ const res = await requests.del(`files/${fileId}`, {
1353
+ params: {
1354
+ ...reqArgs
1355
+ }
1356
+ });
1357
+ return res.data;
1358
+ }
1359
+ async headFile(id, funcArgs, reqArgs) {
1360
+ const fileId = this.parseFileId(id);
1361
+ const tld = getTld(this.globals, funcArgs.tld);
1362
+ const requests = new Requests(tld, funcArgs.auth);
1363
+ const res = await requests.head(`files/${fileId}`, {
1364
+ params: {
1365
+ ...reqArgs
1366
+ }
1367
+ });
1368
+ return res.data;
1369
+ }
1370
+ async putFile(id, funcArgs, reqArgs) {
1371
+ const fileId = this.parseFileId(id);
1372
+ const tld = getTld(this.globals, funcArgs.tld);
1373
+ const requests = new Requests(tld, funcArgs.auth);
1374
+ const res = await requests.put(`files/${fileId}`, "", {
1375
+ params: {
1376
+ ...reqArgs
1377
+ }
1378
+ });
1379
+ return res.data;
1380
+ }
1381
+ async deleteFileName(id, filename, funcArgs, reqArgs) {
1382
+ const fileId = this.parseFileId(id);
1383
+ const filenameId = this.parseFileName(filename);
1384
+ const tld = getTld(this.globals, funcArgs.tld);
1385
+ const requests = new Requests(tld, funcArgs.auth);
1386
+ const res = await requests.del(`files/${fileId}/${filenameId}`, {
1387
+ params: {
1388
+ ...reqArgs
1389
+ }
1390
+ });
1391
+ return res.data;
1392
+ }
1393
+ async headFileName(id, filename, funcArgs, reqArgs) {
1394
+ const fileId = this.parseFileId(id);
1395
+ const filenameId = this.parseFileName(filename);
1396
+ const tld = getTld(this.globals, funcArgs.tld);
1397
+ const requests = new Requests(tld, funcArgs.auth);
1398
+ const res = await requests.head(`files/${fileId}/${filenameId}`, {
1399
+ params: {
1400
+ ...reqArgs
1401
+ }
1402
+ });
1403
+ return res.data;
1404
+ }
1405
+ async putFileName(id, filename, funcArgs, reqArgs) {
1406
+ const fileId = this.parseFileId(id);
1407
+ const filenameId = this.parseFileName(filename);
1408
+ const tld = getTld(this.globals, funcArgs.tld);
1409
+ const requests = new Requests(tld, funcArgs.auth);
1410
+ const res = await requests.put(`files/${fileId}/${filenameId}`, "", {
1411
+ params: {
1412
+ ...reqArgs
1413
+ }
1414
+ });
1415
+ return res.data;
1416
+ }
1417
+ async postFileCopy(id, funcArgs, reqArgs) {
1418
+ const fileId = this.parseFileId(id);
1419
+ const tld = getTld(this.globals, funcArgs.tld);
1420
+ const requests = new Requests(tld, funcArgs.auth);
1421
+ const res = await requests.post(`files/${fileId}/copy`, "", {
1422
+ params: {
1423
+ ...reqArgs
1424
+ }
1425
+ });
1426
+ return res.data;
1427
+ }
1428
+ async delDescriptionFile(id, funcArgs, reqArgs) {
1429
+ const fileId = this.parseFileId(id);
1430
+ const tld = getTld(this.globals, funcArgs.tld);
1431
+ const requests = new Requests(tld, funcArgs.auth);
1432
+ const res = await requests.del(`files/${fileId}/description`, {
1433
+ params: {
1434
+ ...reqArgs
1435
+ }
1436
+ });
1437
+ return res.data;
1438
+ }
1439
+ }
1440
+
1441
+ class Expert {
1442
+ constructor(tld) {
1443
+ this.globals = {};
1444
+ if (tld) {
1445
+ this.globals.tld = tld;
1446
+ }
1447
+ }
1448
+ get pages() {
1449
+ if (!this._pages) {
1450
+ this._pages = new Pages(this.globals);
1451
+ }
1452
+ return this._pages;
1453
+ }
1454
+ get auth() {
1455
+ if (!this._auth) {
1456
+ this._auth = new Auth();
1457
+ }
1458
+ return this._auth;
1459
+ }
1460
+ get site() {
1461
+ if (!this._site) {
1462
+ this._site = new Site(this.globals);
1463
+ }
1464
+ return this._site;
1465
+ }
1466
+ get archive() {
1467
+ if (!this._archive) {
1468
+ this._archive = new Archive(this.globals);
1469
+ }
1470
+ return this._archive;
1471
+ }
1472
+ get groups() {
1473
+ if (!this._groups) {
1474
+ this._groups = new Groups(this.globals);
1475
+ }
1476
+ return this._groups;
1477
+ }
1478
+ get events() {
1479
+ if (!this._events) {
1480
+ this._events = new Events(this.globals);
1481
+ }
1482
+ return this._events;
1483
+ }
1484
+ get contextMaps() {
1485
+ if (!this._contextMaps) {
1486
+ this._contextMaps = new contextMaps(this.globals);
1487
+ }
1488
+ return this._contextMaps;
1489
+ }
1490
+ get users() {
1491
+ if (!this._users) {
1492
+ this._users = new Users(this.globals);
1493
+ }
1494
+ return this._users;
1495
+ }
1496
+ get files() {
1497
+ if (!this._files) {
1498
+ this._files = new Files(this.globals);
1499
+ }
1500
+ return this._files;
1501
+ }
1502
+ }
1503
+
1504
+ export default Expert;
1505
+ //# sourceMappingURL=cxone-expert-node.esm.js.map