@gyldendalas/gyldendal-divine-api 0.0.5 → 0.0.7
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/dist/index.cjs +202 -51
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +126 -10
- package/dist/index.d.ts +126 -10
- package/dist/index.js +202 -51
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -103,6 +103,16 @@ var BaseService = class {
|
|
|
103
103
|
const response = await this.callAsync({ url, body, method, headers, timeout });
|
|
104
104
|
return response.json();
|
|
105
105
|
}
|
|
106
|
+
async postAsync({
|
|
107
|
+
url,
|
|
108
|
+
headers,
|
|
109
|
+
body,
|
|
110
|
+
timeout
|
|
111
|
+
}) {
|
|
112
|
+
const method = "POST";
|
|
113
|
+
const response = await this.callAsync({ url, body, method, headers, timeout });
|
|
114
|
+
return response.json();
|
|
115
|
+
}
|
|
106
116
|
async deleteAsync({
|
|
107
117
|
url,
|
|
108
118
|
headers,
|
|
@@ -151,14 +161,14 @@ var TaggingService = class extends base_service_default {
|
|
|
151
161
|
throw new Error(`Unknown environment: ${this.environment}`);
|
|
152
162
|
}
|
|
153
163
|
}
|
|
154
|
-
async
|
|
164
|
+
async getTagsByResource({
|
|
155
165
|
identity,
|
|
156
166
|
resource_type,
|
|
157
167
|
resource_name,
|
|
158
|
-
|
|
168
|
+
tag_name,
|
|
159
169
|
timeout = 3e3
|
|
160
170
|
}) {
|
|
161
|
-
const url = `${this.getUrlPrefix()}/tags/
|
|
171
|
+
const url = `${this.getUrlPrefix()}/tags/by_resource/${identity}${resource_type ? `/${resource_type}` : ""}${resource_name ? `/${resource_name}` : ""}${tag_name ? `/${tag_name}` : ""}`;
|
|
162
172
|
const headers = new Headers();
|
|
163
173
|
return await this.getAsync({ url, headers, timeout });
|
|
164
174
|
}
|
|
@@ -169,13 +179,22 @@ var TaggingService = class extends base_service_default {
|
|
|
169
179
|
tag_name,
|
|
170
180
|
timeout = 3e3
|
|
171
181
|
}) {
|
|
172
|
-
const url = `${this.getUrlPrefix()}/tags/
|
|
182
|
+
const url = `${this.getUrlPrefix()}/tags/by_tag_name/${identity}/${tag_name}${resource_type ? `/${resource_type}` : ""}${resource_name ? `/${resource_name}` : ""}`;
|
|
173
183
|
const headers = new Headers();
|
|
174
184
|
return await this.getAsync({ url, headers, timeout });
|
|
175
185
|
}
|
|
176
186
|
async createTag({
|
|
177
187
|
tag,
|
|
178
188
|
timeout = 3e3
|
|
189
|
+
}) {
|
|
190
|
+
const url = `${this.getUrlPrefix()}/tags`;
|
|
191
|
+
const headers = new Headers();
|
|
192
|
+
headers.append("Content-Type", "application/json");
|
|
193
|
+
return await this.postAsync({ url, headers, body: JSON.stringify(tag), timeout });
|
|
194
|
+
}
|
|
195
|
+
async updateTag({
|
|
196
|
+
tag,
|
|
197
|
+
timeout = 3e3
|
|
179
198
|
}) {
|
|
180
199
|
const url = `${this.getUrlPrefix()}/tags`;
|
|
181
200
|
const headers = new Headers();
|
|
@@ -189,7 +208,7 @@ var TaggingService = class extends base_service_default {
|
|
|
189
208
|
tag_name,
|
|
190
209
|
timeout = 3e3
|
|
191
210
|
}) {
|
|
192
|
-
const url = `${this.getUrlPrefix()}/tags
|
|
211
|
+
const url = `${this.getUrlPrefix()}/tags/${identity}${resource_type ? `/${resource_type}` : ""}${resource_name ? `/${resource_name}` : ""}${tag_name ? `/${tag_name}` : ""}`;
|
|
193
212
|
const headers = new Headers();
|
|
194
213
|
await this.deleteAsync({ url, headers, timeout });
|
|
195
214
|
}
|
|
@@ -233,6 +252,7 @@ var UserSettings = class extends base_service_default {
|
|
|
233
252
|
// src/services/highlevel/tagging/user_folders.ts
|
|
234
253
|
var import_crypto = __toESM(require("crypto"), 1);
|
|
235
254
|
var UserFolders = class extends tagging_service_default {
|
|
255
|
+
hasNoParent = "-";
|
|
236
256
|
identity = void 0;
|
|
237
257
|
async getIdentity() {
|
|
238
258
|
if (this.identity) {
|
|
@@ -246,6 +266,15 @@ var UserFolders = class extends tagging_service_default {
|
|
|
246
266
|
}
|
|
247
267
|
throw new Error("The UserFolders service must be invoked with a valid bearer token");
|
|
248
268
|
}
|
|
269
|
+
/**
|
|
270
|
+
* Create a folder.
|
|
271
|
+
* @param folder_name The name of the folder.
|
|
272
|
+
* @param parent_folder_uuid The UUID of the parent folder. If no parent folder is provided, the folder is created at the root level.
|
|
273
|
+
* @param color The color of the folder.
|
|
274
|
+
* @param timeout The timeout for the request in milliseconds.
|
|
275
|
+
*
|
|
276
|
+
* @return Folder
|
|
277
|
+
**/
|
|
249
278
|
async createFolder({
|
|
250
279
|
folder_name,
|
|
251
280
|
parent_folder_uuid,
|
|
@@ -259,22 +288,31 @@ var UserFolders = class extends tagging_service_default {
|
|
|
259
288
|
identity: await this.getIdentity(),
|
|
260
289
|
resource_type: "myaccount_user_folder",
|
|
261
290
|
resource_name: import_crypto.default.randomUUID(),
|
|
262
|
-
tag_name:
|
|
263
|
-
tag_value:
|
|
291
|
+
tag_name: parent_folder_uuid ?? this.hasNoParent,
|
|
292
|
+
tag_value: Buffer.from(folder_payload).toString("base64")
|
|
264
293
|
},
|
|
265
294
|
timeout
|
|
266
295
|
}
|
|
267
296
|
);
|
|
268
297
|
return { name: folder_name, uuid: tag["resource_name"], parent: parent_folder_uuid };
|
|
269
298
|
}
|
|
299
|
+
/**
|
|
300
|
+
* Update a folder. Only name and color can be changed.
|
|
301
|
+
*
|
|
302
|
+
* @param folder_uuid The UUID of the folder.
|
|
303
|
+
* @param folder_name The new name of the folder.
|
|
304
|
+
* @param color The new color of the folder.
|
|
305
|
+
* @param timeout The timeout for the request in milliseconds.
|
|
306
|
+
*
|
|
307
|
+
* @return Folder
|
|
308
|
+
**/
|
|
270
309
|
async updateFolder({
|
|
271
310
|
folder_uuid,
|
|
272
311
|
folder_name,
|
|
273
312
|
color,
|
|
274
|
-
parent_folder_uuid,
|
|
275
313
|
timeout = 3e3
|
|
276
314
|
}) {
|
|
277
|
-
const tags = await this.
|
|
315
|
+
const tags = await this.getTagsByResource(
|
|
278
316
|
{
|
|
279
317
|
identity: await this.getIdentity(),
|
|
280
318
|
resource_type: "myaccount_user_folder",
|
|
@@ -286,103 +324,144 @@ var UserFolders = class extends tagging_service_default {
|
|
|
286
324
|
throw new Error(`Folder with UUID ${folder_uuid} not found`);
|
|
287
325
|
}
|
|
288
326
|
const tag = tags[0];
|
|
289
|
-
const folder_payload = JSON.parse(Buffer.from(tag["
|
|
327
|
+
const folder_payload = JSON.parse(Buffer.from(tag["tag_value"], "base64").toString());
|
|
290
328
|
const new_folder_name = folder_name ?? folder_payload["folder"];
|
|
291
329
|
const new_color = color ?? folder_payload["color"];
|
|
292
|
-
const new_parent = parent_folder_uuid ?? tag["tag_value"];
|
|
293
330
|
const new_folder_payload = JSON.stringify({ "folder": new_folder_name, "color": new_color });
|
|
294
|
-
await this.
|
|
295
|
-
{
|
|
296
|
-
identity: await this.getIdentity(),
|
|
297
|
-
resource_type: "myaccount_user_folder",
|
|
298
|
-
resource_name: folder_uuid,
|
|
299
|
-
timeout
|
|
300
|
-
}
|
|
301
|
-
);
|
|
302
|
-
await this.createTag(
|
|
331
|
+
await this.updateTag(
|
|
303
332
|
{
|
|
304
333
|
tag: {
|
|
305
334
|
identity: await this.getIdentity(),
|
|
306
335
|
resource_type: "myaccount_user_folder",
|
|
307
336
|
resource_name: folder_uuid,
|
|
308
|
-
tag_name:
|
|
309
|
-
tag_value:
|
|
337
|
+
tag_name: tag["tag_name"],
|
|
338
|
+
tag_value: Buffer.from(new_folder_payload).toString("base64")
|
|
310
339
|
},
|
|
311
340
|
timeout
|
|
312
341
|
}
|
|
313
342
|
);
|
|
314
|
-
|
|
343
|
+
const parent = tag["tag_name"] === this.hasNoParent ? void 0 : tag["tag_name"];
|
|
344
|
+
return { name: new_folder_name, uuid: folder_uuid, parent };
|
|
315
345
|
}
|
|
316
|
-
|
|
317
|
-
|
|
346
|
+
/**
|
|
347
|
+
* List all folders in the user's account.
|
|
348
|
+
*
|
|
349
|
+
* @param timeout The timeout for the request in milliseconds.
|
|
350
|
+
*
|
|
351
|
+
* @return Folder[]
|
|
352
|
+
**/
|
|
353
|
+
async listAllFolders({
|
|
318
354
|
timeout = 3e3
|
|
319
355
|
}) {
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
);
|
|
330
|
-
|
|
331
|
-
tags = await this.getTagsByName(
|
|
356
|
+
const tags = await this.getTagsByResource(
|
|
357
|
+
{
|
|
358
|
+
identity: await this.getIdentity(),
|
|
359
|
+
resource_type: "myaccount_user_folder",
|
|
360
|
+
timeout
|
|
361
|
+
}
|
|
362
|
+
);
|
|
363
|
+
let folders = [];
|
|
364
|
+
for (const tag of tags) {
|
|
365
|
+
const folder_payload = JSON.parse(Buffer.from(tag["tag_value"], "base64").toString());
|
|
366
|
+
folders.push(
|
|
332
367
|
{
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
368
|
+
name: folder_payload["folder"],
|
|
369
|
+
color: folder_payload["color"],
|
|
370
|
+
uuid: tag["resource_name"],
|
|
371
|
+
parent: tag["tag_name"] === this.hasNoParent ? void 0 : tag["tag_name"]
|
|
336
372
|
}
|
|
337
373
|
);
|
|
338
374
|
}
|
|
375
|
+
return folders;
|
|
376
|
+
}
|
|
377
|
+
/**
|
|
378
|
+
* List the next level of folders in the user's account.
|
|
379
|
+
*
|
|
380
|
+
* @param parent_folder_uuid The UUID of the parent folder. If no parent folder is provided, the folder is created at the root level.
|
|
381
|
+
* @param timeout The timeout for the request in milliseconds.
|
|
382
|
+
*
|
|
383
|
+
* @return Folder[]
|
|
384
|
+
**/
|
|
385
|
+
async listNextFolderLevel({
|
|
386
|
+
parent_folder_uuid,
|
|
387
|
+
timeout = 3e3
|
|
388
|
+
}) {
|
|
389
|
+
let tags;
|
|
390
|
+
if (!parent_folder_uuid) {
|
|
391
|
+
parent_folder_uuid = this.hasNoParent;
|
|
392
|
+
}
|
|
393
|
+
tags = await this.getTagsByName(
|
|
394
|
+
{
|
|
395
|
+
identity: await this.getIdentity(),
|
|
396
|
+
resource_type: "myaccount_user_folder",
|
|
397
|
+
tag_name: parent_folder_uuid,
|
|
398
|
+
timeout
|
|
399
|
+
}
|
|
400
|
+
);
|
|
339
401
|
let folders = [];
|
|
340
402
|
for (const tag of tags) {
|
|
341
|
-
const folder_payload = JSON.parse(Buffer.from(tag["
|
|
403
|
+
const folder_payload = JSON.parse(Buffer.from(tag["tag_value"], "base64").toString());
|
|
342
404
|
folders.push(
|
|
343
405
|
{
|
|
344
406
|
name: folder_payload["folder"],
|
|
345
407
|
color: folder_payload["color"],
|
|
346
408
|
uuid: tag["resource_name"],
|
|
347
|
-
parent: tag["
|
|
409
|
+
parent: tag["tag_name"] === this.hasNoParent ? void 0 : tag["tag_name"]
|
|
348
410
|
}
|
|
349
411
|
);
|
|
350
412
|
}
|
|
351
413
|
return folders;
|
|
352
414
|
}
|
|
415
|
+
/**
|
|
416
|
+
* List the content of a folder.
|
|
417
|
+
*
|
|
418
|
+
* @param folder_uuid The UUID of the folder.
|
|
419
|
+
* @param timeout The timeout for the request in milliseconds.
|
|
420
|
+
*
|
|
421
|
+
* @return FolderContent[]
|
|
422
|
+
**/
|
|
353
423
|
async getFolderContent({
|
|
354
424
|
folder_uuid,
|
|
355
425
|
timeout = 3e3
|
|
356
426
|
}) {
|
|
357
|
-
let tags = await this.
|
|
427
|
+
let tags = await this.getTagsByName(
|
|
358
428
|
{
|
|
359
429
|
identity: await this.getIdentity(),
|
|
360
|
-
|
|
430
|
+
tag_name: folder_uuid,
|
|
361
431
|
timeout
|
|
362
432
|
}
|
|
363
433
|
);
|
|
364
434
|
let content = [];
|
|
365
435
|
for (const tag of tags) {
|
|
366
436
|
if (tag["resource_type"] === "myaccount_user_folder") {
|
|
367
|
-
const folder_payload = JSON.parse(Buffer.from(tag["
|
|
437
|
+
const folder_payload = JSON.parse(Buffer.from(tag["tag_value"], "base64").toString());
|
|
368
438
|
content.push({
|
|
369
439
|
name: folder_payload["folder"],
|
|
370
440
|
color: folder_payload["color"],
|
|
371
441
|
uuid: tag["resource_name"],
|
|
372
|
-
parent: tag["
|
|
442
|
+
parent: tag["tag_name"]
|
|
373
443
|
});
|
|
374
444
|
} else {
|
|
375
445
|
content.push(
|
|
376
446
|
{
|
|
377
447
|
type: tag["resource_type"],
|
|
378
448
|
identifier: tag["resource_name"],
|
|
379
|
-
folder_uuid: tag["
|
|
449
|
+
folder_uuid: tag["tag_name"]
|
|
380
450
|
}
|
|
381
451
|
);
|
|
382
452
|
}
|
|
383
453
|
}
|
|
384
454
|
return content;
|
|
385
455
|
}
|
|
456
|
+
/**
|
|
457
|
+
* Add a book to a folder.
|
|
458
|
+
*
|
|
459
|
+
* @param folder_uuid The UUID of the folder.
|
|
460
|
+
* @param isbn The ISBN of the book.
|
|
461
|
+
* @param timeout The timeout for the request in milliseconds.
|
|
462
|
+
*
|
|
463
|
+
* @return FolderContent
|
|
464
|
+
**/
|
|
386
465
|
async addInternetbookToFolder({
|
|
387
466
|
folder_uuid,
|
|
388
467
|
isbn,
|
|
@@ -391,19 +470,49 @@ var UserFolders = class extends tagging_service_default {
|
|
|
391
470
|
return await this.addContentToFolder(
|
|
392
471
|
{
|
|
393
472
|
folder_uuid,
|
|
473
|
+
resource_type: "internetbook",
|
|
394
474
|
resource_name: isbn,
|
|
475
|
+
timeout
|
|
476
|
+
}
|
|
477
|
+
);
|
|
478
|
+
}
|
|
479
|
+
/**
|
|
480
|
+
* Remove a book from a folder.
|
|
481
|
+
*
|
|
482
|
+
* @param folder_uuid The UUID of the folder.
|
|
483
|
+
* @param isbn The ISBN of the book.
|
|
484
|
+
* @param timeout The timeout for the request in milliseconds.
|
|
485
|
+
*
|
|
486
|
+
* @return FolderContent
|
|
487
|
+
**/
|
|
488
|
+
async removeInternetbookFromFolder({
|
|
489
|
+
folder_uuid,
|
|
490
|
+
isbn,
|
|
491
|
+
timeout = 3e3
|
|
492
|
+
}) {
|
|
493
|
+
return await this.removeContentFromFolder(
|
|
494
|
+
{
|
|
495
|
+
folder_uuid,
|
|
395
496
|
resource_type: "internetbook",
|
|
497
|
+
resource_name: isbn,
|
|
396
498
|
timeout
|
|
397
499
|
}
|
|
398
500
|
);
|
|
399
501
|
}
|
|
400
502
|
/**
|
|
401
|
-
|
|
503
|
+
* Create a new folder content element.
|
|
504
|
+
*
|
|
505
|
+
* @param folder_uuid The UUID of the folder.
|
|
506
|
+
* @param resource_name The name of the resource.
|
|
507
|
+
* @param resource_type The type of the resource.
|
|
508
|
+
* @param timeout The timeout for the request in milliseconds.
|
|
509
|
+
*
|
|
510
|
+
* @return FolderContent
|
|
402
511
|
**/
|
|
403
512
|
async addContentToFolder({
|
|
404
513
|
folder_uuid,
|
|
405
|
-
resource_name,
|
|
406
514
|
resource_type,
|
|
515
|
+
resource_name,
|
|
407
516
|
timeout = 3e3
|
|
408
517
|
}) {
|
|
409
518
|
await this.createTag(
|
|
@@ -412,14 +521,49 @@ var UserFolders = class extends tagging_service_default {
|
|
|
412
521
|
identity: await this.getIdentity(),
|
|
413
522
|
resource_type,
|
|
414
523
|
resource_name,
|
|
415
|
-
tag_name:
|
|
416
|
-
tag_value:
|
|
524
|
+
tag_name: folder_uuid,
|
|
525
|
+
tag_value: "MYACCOUNT_USER_FOLDER"
|
|
417
526
|
},
|
|
418
527
|
timeout
|
|
419
528
|
}
|
|
420
529
|
);
|
|
421
530
|
return { type: resource_type, identifier: resource_name, folder_uuid };
|
|
422
531
|
}
|
|
532
|
+
/**
|
|
533
|
+
* Create a new folder content element.
|
|
534
|
+
*
|
|
535
|
+
* @param folder_uuid The UUID of the folder.
|
|
536
|
+
* @param resource_name The name of the resource.
|
|
537
|
+
* @param resource_type The type of the resource.
|
|
538
|
+
* @param timeout The timeout for the request in milliseconds.
|
|
539
|
+
*
|
|
540
|
+
* @return FolderContent
|
|
541
|
+
**/
|
|
542
|
+
async removeContentFromFolder({
|
|
543
|
+
folder_uuid,
|
|
544
|
+
resource_name,
|
|
545
|
+
resource_type,
|
|
546
|
+
timeout = 3e3
|
|
547
|
+
}) {
|
|
548
|
+
await this.deleteTag(
|
|
549
|
+
{
|
|
550
|
+
identity: await this.getIdentity(),
|
|
551
|
+
resource_type,
|
|
552
|
+
resource_name,
|
|
553
|
+
tag_name: folder_uuid,
|
|
554
|
+
timeout
|
|
555
|
+
}
|
|
556
|
+
);
|
|
557
|
+
return { type: resource_type, identifier: resource_name, folder_uuid };
|
|
558
|
+
}
|
|
559
|
+
/**
|
|
560
|
+
* Delete a folder.
|
|
561
|
+
*
|
|
562
|
+
* @param folder_uuid The UUID of the folder.
|
|
563
|
+
* @param timeout The timeout for the request in milliseconds.
|
|
564
|
+
*
|
|
565
|
+
* @return void
|
|
566
|
+
**/
|
|
423
567
|
async deleteFolder({
|
|
424
568
|
folder_uuid,
|
|
425
569
|
timeout = 3e3
|
|
@@ -433,6 +577,13 @@ var UserFolders = class extends tagging_service_default {
|
|
|
433
577
|
}
|
|
434
578
|
);
|
|
435
579
|
}
|
|
580
|
+
/**
|
|
581
|
+
* Delete all folders. Note, this will not delete the content of the folders.
|
|
582
|
+
*
|
|
583
|
+
* @param timeout The timeout for the request in milliseconds.
|
|
584
|
+
*
|
|
585
|
+
* @return void
|
|
586
|
+
**/
|
|
436
587
|
async deleteAllFolders({
|
|
437
588
|
timeout = 3e3
|
|
438
589
|
}) {
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts","../src/services/base_service.ts","../src/services/tagging_service.ts","../src/services/user_settings.ts","../src/services/highlevel/tagging/user_folders.ts"],"sourcesContent":["export * from 'services/tagging_service.js';\nexport * from 'services/user_settings.js';\nexport * from 'services/highlevel/tagging/user_folders.js';\n","class HTTPError extends Error {\n public response: Response;\n \n constructor(message: string, response: Response) {\n super();\n this.message = message;\n this.response = response;\n }\n}\n\nexport class BaseService {\n public bearerToken: string | undefined;\n public apiKey: string | undefined;\n public serviceUrl: string | undefined;\n public environment: string;\n public myAccountId: string;\n public baseDomain: string;\n\n constructor({\n bearerToken = undefined,\n apiKey = undefined,\n serviceUrl = undefined,\n environment = 'production',\n myAccountId = 'SYSTIMEMYACCOUNT',\n baseDomain = 'systime.dk',\n } : {\n bearerToken?: string,\n apiKey?: string,\n serviceUrl?: string,\n environment: string,\n myAccountId: string,\n baseDomain?: string\n }) {\n this.bearerToken = bearerToken;\n this.apiKey = apiKey;\n this.serviceUrl = serviceUrl;\n this.environment = environment;\n this.myAccountId = myAccountId;\n this.baseDomain = baseDomain;\n }\n\n protected discoverUrlPrefix(): string {\n throw new Error('Method not implemented.');\n }\n\n public getUrlPrefix(): string {\n // If the URL has been explicitly set, return it.\n if (this.serviceUrl) {\n return this.serviceUrl;\n }\n return this.discoverUrlPrefix()\n }\n\n public async addAuthHeaders(requestHeaders: Headers): Promise<Headers> {\n if (this.bearerToken) {\n requestHeaders.set('Authorization', `Bearer ${this.bearerToken}`);\n } else if (this.apiKey) {\n requestHeaders.set('x-api-key', this.apiKey);\n }\n return requestHeaders;\n }\n\n async getAsync(\n {\n url,\n headers,\n timeout\n }:\n {\n url: URL | string,\n headers: Headers | undefined | null,\n timeout: number\n }\n ): Promise<object> {\n const method = 'GET';\n const response = await this.callAsync({ url, body: null, method, headers, timeout });\n return response.json();\n }\n\n async putAsync(\n {\n url,\n headers,\n body,\n timeout\n }:\n {\n url: URL | string,\n headers: Headers | undefined | null,\n body: string | null | undefined,\n timeout: number\n }\n ): Promise<object> {\n const method = 'PUT';\n const response = await this.callAsync({ url, body, method, headers, timeout });\n return response.json();\n }\n\n async deleteAsync(\n {\n url,\n headers,\n timeout\n }:\n {\n url: URL | string,\n headers: Headers | undefined | null,\n timeout: number\n }\n ): Promise<object> {\n const method = 'DELETE';\n const response = await this.callAsync({ url, body: null, method, headers, timeout });\n return response.json();\n }\n\n async callAsync(\n {\n url,\n body,\n method,\n headers,\n timeout\n }:\n {\n url: URL | string,\n body: string | null | undefined,\n method: string,\n headers: Headers | undefined | null,\n timeout: number\n }\n ): Promise<Response> {\n if (!headers) {\n headers = new Headers();\n }\n\n headers = await this.addAuthHeaders(headers);\n const response = await fetch(url, {\n\t method: method,\n body: body,\n headers: headers,\n signal: AbortSignal.timeout(timeout)\n });\n\n if (!response.ok) {\n\t\t\t\t\tthrow new HTTPError(`Got ${response.status} while calling ${response.url}`, response);\n }\n return response;\n }\n}\nexport default BaseService;\n","import BaseService from './base_service.js';\n\ninterface Tag {\n identity: string;\n resource_type: string;\n resource_name: string;\n tag_name: string;\n tag_value: string;\n}\n\nexport class TaggingService extends BaseService {\n discoverUrlPrefix(): string {\n switch (this.environment) {\n case 'local':\n return 'http://localhost:4000';\n case 'production':\n return `https://tagging.services.${this.baseDomain}`;\n case 'staging':\n return `https://${this.environment}-tagging.services.${this.baseDomain}`;\n default:\n throw new Error(`Unknown environment: ${this.environment}`);\n }\n };\n\n async getTagsByValue(\n {\n identity,\n resource_type,\n resource_name,\n tag_value,\n timeout = 3000\n }:\n {\n tag_value: string,\n identity: string,\n resource_type?: string,\n resource_name?: string,\n timeout?: number\n }\n ): Promise<Tag[]> {\n const url = `${this.getUrlPrefix()}/tags/by_value/${tag_value}/${identity}${resource_type ? `/${resource_type}` : ''}${resource_name ? `/${resource_name}` : ''}`;\n\n const headers: HeadersInit = new Headers();\n return await this.getAsync({url, headers, timeout}) as Tag[];\n }\n\n async getTagsByName(\n {\n identity,\n resource_type,\n resource_name,\n tag_name,\n timeout = 3000\n }:\n {\n identity: string,\n resource_type?: string,\n resource_name?: string,\n tag_name?: string,\n timeout?: number\n }\n ): Promise<Tag[]> {\n const url = `${this.getUrlPrefix()}/tags/by_name/${identity}${resource_type ? `/${resource_type}` : ''}${resource_name ? `/${resource_name}` : ''}${tag_name ? `/${tag_name}` : ''}`;\n\n const headers: HeadersInit = new Headers();\n return await this.getAsync({url, headers, timeout}) as Tag[];\n }\n\n async createTag(\n {\n tag,\n timeout = 3000\n }:\n {\n tag: Tag,\n timeout?: number\n }\n ): Promise<Tag> {\n const url = `${this.getUrlPrefix()}/tags`;\n const headers: HeadersInit = new Headers();\n\n headers.append('Content-Type', \"application/json\");\n return await this.putAsync({url, headers, body: JSON.stringify(tag), timeout}) as Tag;\n }\n\n async deleteTag(\n {\n identity,\n resource_type,\n resource_name,\n tag_name,\n timeout = 3000\n }:\n {\n identity: string,\n resource_type?: string,\n resource_name?: string,\n tag_name?: string,\n timeout?: number\n }\n ): Promise<void> {\n const url = `${this.getUrlPrefix()}/tags/by_name/${identity}${resource_type ? `/${resource_type}` : ''}${resource_name ? `/${resource_name}` : ''}${tag_name ? `/${tag_name}` : ''}`;\n\n const headers: HeadersInit = new Headers();\n await this.deleteAsync({url, headers, timeout});\n }\n}\n\nexport default TaggingService;\n","import BaseService from './base_service.js';\n\nexport class UserSettings extends BaseService {\n discoverUrlPrefix(): string {\n switch (this.environment) {\n case 'local':\n return 'http://localhost:4000';\n case 'production':\n return `https://user-settings-service.services.${this.baseDomain}`;\n case 'staging':\n return `https://${this.environment}-user-settings-service.services.${this.baseDomain}`;\n default:\n throw new Error(`Unknown environment: ${this.environment}`);\n }\n }\n\n async getSettings(\n {\n isbn,\n timeout = 5000\n }:\n {\n isbn: string,\n timeout?: number\n }\n ): Promise<object> {\n const url = `${this.getUrlPrefix()}/clientsettings/isbn/${isbn}`;\n const headers: HeadersInit = new Headers();\n\n return await this.getAsync({url, headers, timeout});\n }\n\n async setSettings(\n {\n isbn,\n settings,\n timeout = 5000\n }: \n {\n isbn: string,\n settings: object,\n timeout?: number\n }\n ): Promise<object> {\n const url = `${this.getUrlPrefix()}/clientsettings/isbn/${isbn}`;\n const headers: HeadersInit = new Headers();\n\n headers.set('Content-Type', 'application/json');\n return await this.putAsync({url, headers, body: JSON.stringify(settings), timeout});\n }\n}\n\nexport default UserSettings;\n","import crypto from 'crypto';\nimport TaggingService from '../../tagging_service.js';\n\ninterface FolderObject {}\n\ninterface Folder extends FolderObject {\n name: string;\n uuid: string;\n parent?: string;\n}\n\ninterface FolderContent extends FolderObject {\n type: string;\n identifier: string;\n folder_uuid: string;\n}\n\n/**\n * UserFolders is a service that allows users to create folders in their account. It's built on top of the Tagging service.\n * Folders are created with a name and an optional parent folder. If no parent folder is provided, the folder is created at the root level.\n * Folders are created with a unique UUID that can be used to reference the folder in future requests. The folder name is stored as a base64 encoded string.\n**/\nexport class UserFolders extends TaggingService {\n private identity?: string = undefined;\n \n async getIdentity() : Promise<string> {\n if (this.identity) {\n return this.identity;\n }\n\n if (this.bearerToken) {\n const tokenParts = this.bearerToken.split('.');\n const payload = Buffer.from(tokenParts[1], 'base64').toString();\n const payloadObject = JSON.parse(payload);\n // The identity is the keyword user, the user's authns and the ekeysuserid (user) concatenated with an underscore\n // This value is enforced by the Tagging service and this is the only identity\n // that the Service will accept when invoked with a user specific bearer token.\n return `user_${payloadObject.authns}_${payloadObject.user}`;\n }\n\n throw new Error('The UserFolders service must be invoked with a valid bearer token');\n }\n\n async createFolder(\n {\n folder_name,\n parent_folder_uuid,\n color,\n timeout = 3000\n }:\n {\n folder_name: string,\n color: string,\n parent_folder_uuid?: string,\n timeout?: number\n }\n ): Promise<Folder> {\n const folder_payload = JSON.stringify({\"folder\": folder_name, \"color\": color});\n const tag = await this.createTag(\n {\n tag: {\n identity: await this.getIdentity(),\n resource_type: 'myaccount_user_folder',\n resource_name: crypto.randomUUID(),\n tag_name: Buffer.from(folder_payload).toString('base64'),\n tag_value: parent_folder_uuid ?? '-',\n },\n timeout\n }\n );\n return {name: folder_name, uuid: tag['resource_name'], parent: parent_folder_uuid} as Folder;\n }\n\n async updateFolder(\n {\n folder_uuid,\n folder_name,\n color,\n parent_folder_uuid,\n timeout = 3000\n }:\n {\n folder_uuid: string,\n color?: string,\n parent_folder_uuid?: string,\n folder_name?: string,\n timeout?: number\n }\n ): Promise<Folder> {\n const tags = await this.getTagsByName(\n {\n identity: await this.getIdentity(),\n resource_type: 'myaccount_user_folder',\n resource_name: folder_uuid,\n timeout\n }\n );\n\n if (tags.length === 0) {\n throw new Error(`Folder with UUID ${folder_uuid} not found`);\n }\n\n const tag = tags[0];\n const folder_payload = JSON.parse(Buffer.from(tag['tag_name'], 'base64').toString());\n const new_folder_name = folder_name ?? folder_payload['folder'];\n const new_color = color ?? folder_payload['color'];\n const new_parent = parent_folder_uuid ?? tag['tag_value'];\n\n const new_folder_payload = JSON.stringify({\"folder\": new_folder_name, \"color\": new_color});\n\n await this.deleteTag(\n {\n identity: await this.getIdentity(),\n resource_type: 'myaccount_user_folder',\n resource_name: folder_uuid,\n timeout\n }\n );\n\n await this.createTag(\n {\n tag: {\n identity: await this.getIdentity(),\n resource_type: 'myaccount_user_folder',\n resource_name: folder_uuid,\n tag_name: Buffer.from(new_folder_payload).toString('base64'),\n tag_value: tag['tag_value'],\n },\n timeout\n }\n );\n return {name: new_folder_name, uuid: folder_uuid, parent: new_parent ?? '-'} as Folder;\n }\n\n async listFolders(\n {\n parent_folder_uuid,\n timeout = 3000\n }:\n {\n parent_folder_uuid?: string,\n timeout?: number\n }\n ): Promise<Folder[]> {\n let tags;\n if (parent_folder_uuid) {\n tags = await this.getTagsByValue(\n {\n identity: await this.getIdentity(),\n resource_type: 'myaccount_user_folder',\n tag_value: parent_folder_uuid,\n timeout\n }\n );\n } else {\n tags = await this.getTagsByName(\n {\n identity: await this.getIdentity(),\n resource_type: 'myaccount_user_folder',\n timeout\n }\n );\n }\n\n let folders = [];\n\n for (const tag of tags) {\n const folder_payload = JSON.parse(Buffer.from(tag['tag_name'], 'base64').toString());\n folders.push(\n {\n name: folder_payload['folder'],\n color: folder_payload['color'],\n uuid: tag['resource_name'],\n parent: tag['tag_value'] === '-' ? undefined : tag['tag_value']\n } as Folder\n );\n }\n\n return folders;\n }\n\n async getFolderContent(\n {\n folder_uuid,\n timeout = 3000\n }:\n {\n folder_uuid: string,\n timeout?: number\n }\n ): Promise<FolderObject[]> {\n let tags = await this.getTagsByValue(\n {\n identity: await this.getIdentity(),\n tag_value: folder_uuid,\n timeout\n }\n );\n\n let content = [];\n\n for (const tag of tags) {\n if (tag['resource_type'] === 'myaccount_user_folder') {\n const folder_payload = JSON.parse(Buffer.from(tag['tag_name'], 'base64').toString());\n content.push({\n name: folder_payload['folder'],\n color: folder_payload['color'],\n uuid: tag['resource_name'],\n parent: tag['tag_value']\n } as Folder)\n } else {\n content.push(\n {\n type: tag['resource_type'],\n identifier: tag['resource_name'],\n folder_uuid: tag['tag_value']\n } as FolderContent\n );\n }\n }\n\n return content;\n }\n\n async addInternetbookToFolder(\n {\n folder_uuid,\n isbn,\n timeout = 3000\n }:\n {\n folder_uuid: string,\n isbn: string,\n timeout?: number\n }\n ): Promise<FolderContent> {\n return await this.addContentToFolder(\n {\n folder_uuid,\n resource_name: isbn,\n resource_type: 'internetbook',\n timeout\n },\n );\n }\n\n /**\n * This is a generic function for creating folder content elements.\n **/\n async addContentToFolder(\n {\n folder_uuid,\n resource_name,\n resource_type,\n timeout = 3000\n }:\n {\n folder_uuid: string,\n resource_name: string,\n resource_type: string,\n timeout?: number\n }\n ): Promise<FolderContent> {\n await this.createTag(\n {\n tag: {\n identity: await this.getIdentity(),\n resource_type: resource_type,\n resource_name: resource_name,\n tag_name: 'MYACCOUNT_USER_FOLDER',\n tag_value: folder_uuid,\n },\n timeout\n }\n );\n return {type: resource_type, identifier: resource_name, folder_uuid} as FolderContent;\n }\n\n async deleteFolder(\n {\n folder_uuid,\n timeout = 3000\n }:\n {\n folder_uuid: string,\n timeout?: number\n }\n ): Promise<void> {\n await this.deleteTag(\n {\n identity: await this.getIdentity(),\n resource_type: 'myaccount_user_folder',\n resource_name: folder_uuid,\n timeout\n }\n );\n }\n\n async deleteAllFolders(\n {\n timeout = 3000\n }:\n {\n timeout?: number\n }\n ): Promise<void> {\n await this.deleteTag(\n {\n identity: await this.getIdentity(),\n resource_type: 'myaccount_user_folder',\n timeout\n }\n );\n }\n}\n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,UACH,UAAU,MAAM,KAAK,YAAY;AAAA,UACjC;AAAA,UACA;AAAA,UACA,UAAU;AAAA,UACV,WAAW;AAAA,QACb;AAAA,QACA;AAAA,MACF;AAAA,IACF;AACA,WAAO,EAAC,MAAM,eAAe,YAAY,eAAe,YAAW;AAAA,EACrE;AAAA,EAEA,MAAM,aACJ;AAAA,IACE;AAAA,IACA,UAAU;AAAA,EACZ,GAKe;AACf,UAAM,KAAK;AAAA,MACT;AAAA,QACE,UAAU,MAAM,KAAK,YAAY;AAAA,QACjC,eAAe;AAAA,QACf,eAAe;AAAA,QACf;AAAA,MACF;AAAA,IACF;AAAA,EACF;AAAA,EAEA,MAAM,iBACJ;AAAA,IACE,UAAU;AAAA,EACZ,GAIe;AACf,UAAM,KAAK;AAAA,MACT;AAAA,QACE,UAAU,MAAM,KAAK,YAAY;AAAA,QACjC,eAAe;AAAA,QACf;AAAA,MACF;AAAA,IACF;AAAA,EACF;AACF;","names":["crypto"]}
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/services/base_service.ts","../src/services/tagging_service.ts","../src/services/user_settings.ts","../src/services/highlevel/tagging/user_folders.ts"],"sourcesContent":["export * from 'services/tagging_service.js';\nexport * from 'services/user_settings.js';\nexport * from 'services/highlevel/tagging/user_folders.js';\n","class HTTPError extends Error {\n public response: Response;\n \n constructor(message: string, response: Response) {\n super();\n this.message = message;\n this.response = response;\n }\n}\n\nexport class BaseService {\n public bearerToken: string | undefined;\n public apiKey: string | undefined;\n public serviceUrl: string | undefined;\n public environment: string;\n public myAccountId: string;\n public baseDomain: string;\n\n constructor({\n bearerToken = undefined,\n apiKey = undefined,\n serviceUrl = undefined,\n environment = 'production',\n myAccountId = 'SYSTIMEMYACCOUNT',\n baseDomain = 'systime.dk',\n } : {\n bearerToken?: string,\n apiKey?: string,\n serviceUrl?: string,\n environment: string,\n myAccountId: string,\n baseDomain?: string\n }) {\n this.bearerToken = bearerToken;\n this.apiKey = apiKey;\n this.serviceUrl = serviceUrl;\n this.environment = environment;\n this.myAccountId = myAccountId;\n this.baseDomain = baseDomain;\n }\n\n protected discoverUrlPrefix(): string {\n throw new Error('Method not implemented.');\n }\n\n public getUrlPrefix(): string {\n // If the URL has been explicitly set, return it.\n if (this.serviceUrl) {\n return this.serviceUrl;\n }\n return this.discoverUrlPrefix()\n }\n\n public async addAuthHeaders(requestHeaders: Headers): Promise<Headers> {\n if (this.bearerToken) {\n requestHeaders.set('Authorization', `Bearer ${this.bearerToken}`);\n } else if (this.apiKey) {\n requestHeaders.set('x-api-key', this.apiKey);\n }\n return requestHeaders;\n }\n\n async getAsync(\n {\n url,\n headers,\n timeout\n }:\n {\n url: URL | string,\n headers: Headers | undefined | null,\n timeout: number\n }\n ): Promise<object> {\n const method = 'GET';\n const response = await this.callAsync({ url, body: null, method, headers, timeout });\n return response.json();\n }\n\n async putAsync(\n {\n url,\n headers,\n body,\n timeout\n }:\n {\n url: URL | string,\n headers: Headers | undefined | null,\n body: string | null | undefined,\n timeout: number\n }\n ): Promise<object> {\n const method = 'PUT';\n const response = await this.callAsync({ url, body, method, headers, timeout });\n return response.json();\n }\n\n async postAsync(\n {\n url,\n headers,\n body,\n timeout\n }:\n {\n url: URL | string,\n headers: Headers | undefined | null,\n body: string | null | undefined,\n timeout: number\n }\n ): Promise<object> {\n const method = 'POST';\n const response = await this.callAsync({ url, body, method, headers, timeout });\n return response.json();\n }\n\n async deleteAsync(\n {\n url,\n headers,\n timeout\n }:\n {\n url: URL | string,\n headers: Headers | undefined | null,\n timeout: number\n }\n ): Promise<object> {\n const method = 'DELETE';\n const response = await this.callAsync({ url, body: null, method, headers, timeout });\n return response.json();\n }\n\n async callAsync(\n {\n url,\n body,\n method,\n headers,\n timeout\n }:\n {\n url: URL | string,\n body: string | null | undefined,\n method: string,\n headers: Headers | undefined | null,\n timeout: number\n }\n ): Promise<Response> {\n if (!headers) {\n headers = new Headers();\n }\n\n headers = await this.addAuthHeaders(headers);\n const response = await fetch(url, {\n\t method: method,\n body: body,\n headers: headers,\n signal: AbortSignal.timeout(timeout)\n });\n\n if (!response.ok) {\n\t\tthrow new HTTPError(`Got ${response.status} while calling ${response.url}`, response);\n }\n return response;\n }\n}\nexport default BaseService;\n","import BaseService from './base_service.js';\n\ninterface Tag {\n identity: string;\n resource_type: string;\n resource_name: string;\n tag_name: string;\n tag_value: string;\n}\n\nexport class TaggingService extends BaseService {\n discoverUrlPrefix(): string {\n switch (this.environment) {\n case 'local':\n return 'http://localhost:4000';\n case 'production':\n return `https://tagging.services.${this.baseDomain}`;\n case 'staging':\n return `https://${this.environment}-tagging.services.${this.baseDomain}`;\n default:\n throw new Error(`Unknown environment: ${this.environment}`);\n }\n };\n\n async getTagsByResource(\n {\n identity,\n resource_type,\n resource_name,\n tag_name,\n timeout = 3000\n }:\n {\n identity: string,\n tag_name?: string,\n resource_type?: string,\n resource_name?: string,\n timeout?: number\n }\n ): Promise<Tag[]> {\n const url = `${this.getUrlPrefix()}/tags/by_resource/${identity}${resource_type ? `/${resource_type}` : ''}${resource_name ? `/${resource_name}` : ''}${tag_name ? `/${tag_name}` : ''}`;\n\n const headers: HeadersInit = new Headers();\n return await this.getAsync({url, headers, timeout}) as Tag[];\n }\n\n async getTagsByName(\n {\n identity,\n resource_type,\n resource_name,\n tag_name,\n timeout = 3000\n }:\n {\n identity: string,\n tag_name: string,\n resource_type?: string,\n resource_name?: string,\n timeout?: number\n }\n ): Promise<Tag[]> {\n const url = `${this.getUrlPrefix()}/tags/by_tag_name/${identity}/${tag_name}${resource_type ? `/${resource_type}` : ''}${resource_name ? `/${resource_name}` : ''}`;\n\n const headers: HeadersInit = new Headers();\n return await this.getAsync({url, headers, timeout}) as Tag[];\n }\n\n async createTag(\n {\n tag,\n timeout = 3000\n }:\n {\n tag: Tag,\n timeout?: number\n }\n ): Promise<Tag> {\n const url = `${this.getUrlPrefix()}/tags`;\n const headers: HeadersInit = new Headers();\n\n headers.append('Content-Type', \"application/json\");\n return await this.postAsync({url, headers, body: JSON.stringify(tag), timeout}) as Tag;\n }\n\n async updateTag(\n {\n tag,\n timeout = 3000\n }:\n {\n tag: Tag,\n timeout?: number\n }\n ): Promise<Tag> {\n const url = `${this.getUrlPrefix()}/tags`;\n const headers: HeadersInit = new Headers();\n\n headers.append('Content-Type', \"application/json\");\n return await this.putAsync({url, headers, body: JSON.stringify(tag), timeout}) as Tag;\n }\n\n async deleteTag(\n {\n identity,\n resource_type,\n resource_name,\n tag_name,\n timeout = 3000\n }:\n {\n identity: string,\n resource_type?: string,\n resource_name?: string,\n tag_name?: string,\n timeout?: number\n }\n ): Promise<void> {\n const url = `${this.getUrlPrefix()}/tags/${identity}${resource_type ? `/${resource_type}` : ''}${resource_name ? `/${resource_name}` : ''}${tag_name ? `/${tag_name}` : ''}`;\n\n const headers: HeadersInit = new Headers();\n await this.deleteAsync({url, headers, timeout});\n }\n}\n\nexport default TaggingService;\n","import BaseService from './base_service.js';\n\nexport class UserSettings extends BaseService {\n discoverUrlPrefix(): string {\n switch (this.environment) {\n case 'local':\n return 'http://localhost:4000';\n case 'production':\n return `https://user-settings-service.services.${this.baseDomain}`;\n case 'staging':\n return `https://${this.environment}-user-settings-service.services.${this.baseDomain}`;\n default:\n throw new Error(`Unknown environment: ${this.environment}`);\n }\n }\n\n async getSettings(\n {\n isbn,\n timeout = 5000\n }:\n {\n isbn: string,\n timeout?: number\n }\n ): Promise<object> {\n const url = `${this.getUrlPrefix()}/clientsettings/isbn/${isbn}`;\n const headers: HeadersInit = new Headers();\n\n return await this.getAsync({url, headers, timeout});\n }\n\n async setSettings(\n {\n isbn,\n settings,\n timeout = 5000\n }: \n {\n isbn: string,\n settings: object,\n timeout?: number\n }\n ): Promise<object> {\n const url = `${this.getUrlPrefix()}/clientsettings/isbn/${isbn}`;\n const headers: HeadersInit = new Headers();\n\n headers.set('Content-Type', 'application/json');\n return await this.putAsync({url, headers, body: JSON.stringify(settings), timeout});\n }\n}\n\nexport default UserSettings;\n","import crypto from 'crypto';\nimport TaggingService from '../../tagging_service.js';\n\ninterface FolderObject {}\n\ninterface Folder extends FolderObject {\n name: string;\n uuid: string;\n parent?: string;\n}\n\ninterface FolderContent extends FolderObject {\n type: string;\n identifier: string;\n folder_uuid: string;\n}\n\n/**\n * UserFolders is a service that allows users to create folders in their account. It's built on top of the Tagging service.\n * Folders are created with a name and an optional parent folder. If no parent folder is provided, the folder is created at the root level.\n * Folders are created with a unique UUID that can be used to reference the folder in future requests. The folder properties are stored as a base64 encoded JSON string.\n**/\nexport class UserFolders extends TaggingService {\n private readonly hasNoParent: string = '-';\n private identity?: string = undefined;\n\n async getIdentity() : Promise<string> {\n if (this.identity) {\n return this.identity;\n }\n\n if (this.bearerToken) {\n const tokenParts = this.bearerToken.split('.');\n const payload = Buffer.from(tokenParts[1], 'base64').toString();\n const payloadObject = JSON.parse(payload);\n // The identity is the keyword user, the user's authns and the ekeysuserid (user) concatenated with an underscore\n // This value is enforced by the Tagging service and this is the only identity\n // that the Service will accept when invoked with a user specific bearer token.\n return `user_${payloadObject.authns}_${payloadObject.user}`;\n }\n\n throw new Error('The UserFolders service must be invoked with a valid bearer token');\n }\n\n /**\n * Create a folder.\n * @param folder_name The name of the folder.\n * @param parent_folder_uuid The UUID of the parent folder. If no parent folder is provided, the folder is created at the root level.\n * @param color The color of the folder.\n * @param timeout The timeout for the request in milliseconds.\n *\n * @return Folder\n **/\n async createFolder(\n {\n folder_name,\n parent_folder_uuid,\n color,\n timeout = 3000\n }:\n {\n folder_name: string,\n color: string,\n parent_folder_uuid?: string,\n timeout?: number\n }\n ): Promise<Folder> {\n const folder_payload = JSON.stringify({\"folder\": folder_name, \"color\": color});\n const tag = await this.createTag(\n {\n tag: {\n identity: await this.getIdentity(),\n resource_type: 'myaccount_user_folder',\n resource_name: crypto.randomUUID(),\n tag_name: parent_folder_uuid ?? this.hasNoParent,\n tag_value: Buffer.from(folder_payload).toString('base64'),\n },\n timeout\n }\n );\n return {name: folder_name, uuid: tag['resource_name'], parent: parent_folder_uuid} as Folder;\n }\n\n /**\n * Update a folder. Only name and color can be changed.\n *\n * @param folder_uuid The UUID of the folder.\n * @param folder_name The new name of the folder.\n * @param color The new color of the folder.\n * @param timeout The timeout for the request in milliseconds.\n *\n * @return Folder\n **/\n async updateFolder(\n {\n folder_uuid,\n folder_name,\n color,\n timeout = 3000\n }:\n {\n folder_uuid: string,\n folder_name?: string,\n color?: string,\n timeout?: number\n }\n ): Promise<Folder> {\n const tags = await this.getTagsByResource(\n {\n identity: await this.getIdentity(),\n resource_type: 'myaccount_user_folder',\n resource_name: folder_uuid,\n timeout\n }\n );\n\n if (tags.length === 0) {\n throw new Error(`Folder with UUID ${folder_uuid} not found`);\n }\n\n const tag = tags[0];\n const folder_payload = JSON.parse(Buffer.from(tag['tag_value'], 'base64').toString());\n const new_folder_name = folder_name ?? folder_payload['folder'];\n const new_color = color ?? folder_payload['color'];\n\n const new_folder_payload = JSON.stringify({\"folder\": new_folder_name, \"color\": new_color});\n\n await this.updateTag(\n {\n tag: {\n identity: await this.getIdentity(),\n resource_type: 'myaccount_user_folder',\n resource_name: folder_uuid,\n tag_name: tag['tag_name'],\n tag_value: Buffer.from(new_folder_payload).toString('base64'),\n },\n timeout\n }\n );\n\n const parent = tag['tag_name'] === this.hasNoParent ? undefined : tag['tag_name'];\n return {name: new_folder_name, uuid: folder_uuid, parent: parent} as Folder;\n }\n\n /**\n * List all folders in the user's account.\n * \n * @param timeout The timeout for the request in milliseconds.\n *\n * @return Folder[]\n **/\n async listAllFolders(\n {\n timeout = 3000\n }:\n {\n timeout?: number\n }\n ): Promise<Folder[]> {\n const tags = await this.getTagsByResource(\n {\n identity: await this.getIdentity(),\n resource_type: 'myaccount_user_folder',\n timeout\n }\n );\n\n let folders = [];\n\n for (const tag of tags) {\n const folder_payload = JSON.parse(Buffer.from(tag['tag_value'], 'base64').toString());\n folders.push(\n {\n name: folder_payload['folder'],\n color: folder_payload['color'],\n uuid: tag['resource_name'],\n parent: tag['tag_name'] === this.hasNoParent ? undefined : tag['tag_name']\n } as Folder\n );\n }\n\n return folders;\n }\n\n /**\n * List the next level of folders in the user's account.\n *\n * @param parent_folder_uuid The UUID of the parent folder. If no parent folder is provided, the folder is created at the root level.\n * @param timeout The timeout for the request in milliseconds.\n *\n * @return Folder[]\n **/\n async listNextFolderLevel(\n {\n parent_folder_uuid,\n timeout = 3000\n }:\n {\n parent_folder_uuid?: string,\n timeout?: number\n }\n ): Promise<Folder[]> {\n let tags;\n if (!parent_folder_uuid) {\n parent_folder_uuid = this.hasNoParent;\n }\n\n tags = await this.getTagsByName(\n {\n identity: await this.getIdentity(),\n resource_type: 'myaccount_user_folder',\n tag_name: parent_folder_uuid,\n timeout\n }\n );\n\n let folders = [];\n\n for (const tag of tags) {\n const folder_payload = JSON.parse(Buffer.from(tag['tag_value'], 'base64').toString());\n folders.push(\n {\n name: folder_payload['folder'],\n color: folder_payload['color'],\n uuid: tag['resource_name'],\n parent: tag['tag_name'] === this.hasNoParent ? undefined : tag['tag_name']\n } as Folder\n );\n }\n\n return folders;\n }\n\n /**\n * List the content of a folder.\n *\n * @param folder_uuid The UUID of the folder.\n * @param timeout The timeout for the request in milliseconds.\n *\n * @return FolderContent[]\n **/\n async getFolderContent(\n {\n folder_uuid,\n timeout = 3000\n }:\n {\n folder_uuid: string,\n timeout?: number\n }\n ): Promise<FolderObject[]> {\n let tags = await this.getTagsByName(\n {\n identity: await this.getIdentity(),\n tag_name: folder_uuid,\n timeout\n }\n );\n\n let content = [];\n\n for (const tag of tags) {\n if (tag['resource_type'] === 'myaccount_user_folder') {\n const folder_payload = JSON.parse(Buffer.from(tag['tag_value'], 'base64').toString());\n content.push({\n name: folder_payload['folder'],\n color: folder_payload['color'],\n uuid: tag['resource_name'],\n parent: tag['tag_name']\n } as Folder)\n } else {\n content.push(\n {\n type: tag['resource_type'],\n identifier: tag['resource_name'],\n folder_uuid: tag['tag_name']\n } as FolderContent\n );\n }\n }\n\n return content;\n }\n\n /**\n * Add a book to a folder.\n *\n * @param folder_uuid The UUID of the folder.\n * @param isbn The ISBN of the book.\n * @param timeout The timeout for the request in milliseconds.\n *\n * @return FolderContent\n **/\n async addInternetbookToFolder(\n {\n folder_uuid,\n isbn,\n timeout = 3000\n }:\n {\n folder_uuid: string,\n isbn: string,\n timeout?: number\n }\n ): Promise<FolderContent> {\n return await this.addContentToFolder(\n {\n folder_uuid,\n resource_type: 'internetbook',\n resource_name: isbn,\n timeout\n },\n );\n }\n\n /**\n * Remove a book from a folder.\n *\n * @param folder_uuid The UUID of the folder.\n * @param isbn The ISBN of the book.\n * @param timeout The timeout for the request in milliseconds.\n *\n * @return FolderContent\n **/\n async removeInternetbookFromFolder(\n {\n folder_uuid,\n isbn,\n timeout = 3000\n }:\n {\n folder_uuid: string,\n isbn: string,\n timeout?: number\n }\n ): Promise<FolderContent> {\n return await this.removeContentFromFolder(\n {\n folder_uuid,\n resource_type: 'internetbook',\n resource_name: isbn,\n timeout\n },\n );\n }\n\n /**\n * Create a new folder content element.\n *\n * @param folder_uuid The UUID of the folder.\n * @param resource_name The name of the resource.\n * @param resource_type The type of the resource.\n * @param timeout The timeout for the request in milliseconds.\n *\n * @return FolderContent\n **/\n async addContentToFolder(\n {\n folder_uuid,\n resource_type,\n resource_name,\n timeout = 3000\n }:\n {\n folder_uuid: string,\n resource_name: string,\n resource_type: string,\n timeout?: number\n }\n ): Promise<FolderContent> {\n await this.createTag(\n {\n tag: {\n identity: await this.getIdentity(),\n resource_type: resource_type,\n resource_name: resource_name,\n tag_name: folder_uuid,\n tag_value: 'MYACCOUNT_USER_FOLDER'\n },\n timeout\n }\n );\n return {type: resource_type, identifier: resource_name, folder_uuid} as FolderContent;\n }\n\n /**\n * Create a new folder content element.\n *\n * @param folder_uuid The UUID of the folder.\n * @param resource_name The name of the resource.\n * @param resource_type The type of the resource.\n * @param timeout The timeout for the request in milliseconds.\n *\n * @return FolderContent\n **/\n async removeContentFromFolder(\n {\n folder_uuid,\n resource_name,\n resource_type,\n timeout = 3000\n }:\n {\n folder_uuid: string,\n resource_name: string,\n resource_type: string,\n timeout?: number\n }\n ): Promise<FolderContent> {\n await this.deleteTag(\n {\n identity: await this.getIdentity(),\n resource_type: resource_type,\n resource_name: resource_name,\n tag_name: folder_uuid,\n timeout\n }\n );\n return {type: resource_type, identifier: resource_name, folder_uuid} as FolderContent;\n }\n\n /**\n * Delete a folder.\n *\n * @param folder_uuid The UUID of the folder.\n * @param timeout The timeout for the request in milliseconds.\n *\n * @return void\n **/\n async deleteFolder(\n {\n folder_uuid,\n timeout = 3000\n }:\n {\n folder_uuid: string,\n timeout?: number\n }\n ): Promise<void> {\n await this.deleteTag(\n {\n identity: await this.getIdentity(),\n resource_type: 'myaccount_user_folder',\n resource_name: folder_uuid,\n timeout\n }\n );\n }\n\n /**\n * Delete all folders. Note, this will not delete the content of the folders.\n *\n * @param timeout The timeout for the request in milliseconds.\n *\n * @return void\n **/\n async deleteAllFolders(\n {\n timeout = 3000\n }:\n {\n timeout?: number\n }\n ): Promise<void> {\n await this.deleteTag(\n {\n identity: await this.getIdentity(),\n resource_type: 'myaccount_user_folder',\n timeout\n }\n );\n }\n}\n\nexport default UserFolders;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,IAAM,YAAN,cAAwB,MAAM;AAAA,EACrB;AAAA,EAEP,YAAY,SAAiB,UAAoB;AAC/C,UAAM;AACN,SAAK,UAAU;AACf,SAAK,WAAW;AAAA,EAClB;AACF;AAEO,IAAM,cAAN,MAAkB;AAAA,EAChB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EAEP,YAAY;AAAA,IACV,cAAc;AAAA,IACd,SAAS;AAAA,IACT,aAAa;AAAA,IACb,cAAc;AAAA,IACd,cAAc;AAAA,IACd,aAAa;AAAA,EACf,GAOK;AACH,SAAK,cAAc;AACnB,SAAK,SAAS;AACd,SAAK,aAAa;AAClB,SAAK,cAAc;AACnB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