@devpad/api 2.0.2 → 2.0.3
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.d.ts +6 -6
- package/dist/index.js +345 -103
- package/dist/{media.d-R87HGuRp.d.ts → media.d-CQ56ckoR.d.ts} +1 -1
- package/dist/schema/blog.d.ts +4 -607
- package/dist/schema/blog.js +10 -81
- package/dist/schema/index.d.ts +4 -4
- package/dist/schema/index.js +1 -81
- package/dist/schema/media.d.ts +5 -6
- package/dist/schema/media.js +1 -97
- package/dist/{schema.d-BceDyQED.d.ts → schema.d-DALWdx-o.d.ts} +1 -522
- package/dist/{types.d-UV8B6hPN.d.ts → types.d-B1VbnHQT.d.ts} +3 -3
- package/dist/{types.d-CoHRMrYJ.d.ts → types.d-Bj4FU9Op.d.ts} +1 -1
- package/dist/{types.d-1hBObc_N.d.ts → types.d-DLE9TSql.d.ts} +1 -1
- package/package.json +2 -2
- package/dist/chunk-FOO5XXY5.js +0 -318
- /package/dist/{chunk-WTGVONUB.js → chunk-INGCIUMX.js} +0 -0
package/dist/index.js
CHANGED
|
@@ -6,9 +6,7 @@ import {
|
|
|
6
6
|
upsert_milestone,
|
|
7
7
|
upsert_project,
|
|
8
8
|
upsert_todo
|
|
9
|
-
} from "./chunk-
|
|
10
|
-
import "./chunk-5X36WMYQ.js";
|
|
11
|
-
import "./chunk-FOO5XXY5.js";
|
|
9
|
+
} from "./chunk-INGCIUMX.js";
|
|
12
10
|
|
|
13
11
|
// src/errors.ts
|
|
14
12
|
var ApiError = class _ApiError extends Error {
|
|
@@ -201,7 +199,9 @@ var ApiClient = class {
|
|
|
201
199
|
this.credentials = options.credentials;
|
|
202
200
|
this.default_headers = options.default_headers ?? {};
|
|
203
201
|
this.custom_fetch = options.custom_fetch;
|
|
204
|
-
this.request_history = new ArrayBufferedQueue(
|
|
202
|
+
this.request_history = new ArrayBufferedQueue(
|
|
203
|
+
options.max_history_size ?? 5
|
|
204
|
+
);
|
|
205
205
|
this.debug = options.debug ?? false;
|
|
206
206
|
}
|
|
207
207
|
buildUrl(path, query) {
|
|
@@ -223,7 +223,10 @@ var ApiClient = class {
|
|
|
223
223
|
const startTime = Date.now();
|
|
224
224
|
const timestamp = (/* @__PURE__ */ new Date()).toISOString();
|
|
225
225
|
if (this.debug) {
|
|
226
|
-
console.log(
|
|
226
|
+
console.log(
|
|
227
|
+
`[DEBUG][${this.category}] ${method} ${path} [${requestId}]`,
|
|
228
|
+
{ body, query }
|
|
229
|
+
);
|
|
227
230
|
}
|
|
228
231
|
const request_headers = {
|
|
229
232
|
"Content-Type": "application/json",
|
|
@@ -263,12 +266,15 @@ var ApiClient = class {
|
|
|
263
266
|
historyEntry.duration = duration;
|
|
264
267
|
if (!response.ok) {
|
|
265
268
|
if (this.debug) {
|
|
266
|
-
console.log(
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
269
|
+
console.log(
|
|
270
|
+
`[ERROR][${this.category}] ${method} ${path} [${requestId}] failed`,
|
|
271
|
+
{
|
|
272
|
+
status: response.status,
|
|
273
|
+
duration: `${duration}ms`,
|
|
274
|
+
body,
|
|
275
|
+
query
|
|
276
|
+
}
|
|
277
|
+
);
|
|
272
278
|
}
|
|
273
279
|
try {
|
|
274
280
|
handleHttpResponse(response);
|
|
@@ -297,22 +303,28 @@ var ApiClient = class {
|
|
|
297
303
|
}
|
|
298
304
|
}
|
|
299
305
|
if (this.debug) {
|
|
300
|
-
console.log(
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
306
|
+
console.log(
|
|
307
|
+
`[INFO][${this.category}] ${method} ${path} [${requestId}] completed`,
|
|
308
|
+
{
|
|
309
|
+
status: response.status,
|
|
310
|
+
duration: `${duration}ms`
|
|
311
|
+
}
|
|
312
|
+
);
|
|
304
313
|
}
|
|
305
314
|
return result;
|
|
306
315
|
} catch (error) {
|
|
307
316
|
const duration = Date.now() - startTime;
|
|
308
317
|
if (this.debug) {
|
|
309
|
-
console.log(
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
318
|
+
console.log(
|
|
319
|
+
`[ERROR][${this.category}] ${method} ${path} [${requestId}] failed`,
|
|
320
|
+
{
|
|
321
|
+
url,
|
|
322
|
+
duration: `${duration}ms`,
|
|
323
|
+
error: error instanceof Error ? error.message : String(error),
|
|
324
|
+
body,
|
|
325
|
+
query
|
|
326
|
+
}
|
|
327
|
+
);
|
|
316
328
|
}
|
|
317
329
|
if (error instanceof ApiError || error instanceof AuthenticationError) {
|
|
318
330
|
throw error;
|
|
@@ -381,12 +393,26 @@ var ApiClient2 = class {
|
|
|
381
393
|
* Auth namespace with Result-wrapped operations
|
|
382
394
|
*/
|
|
383
395
|
this.auth = {
|
|
384
|
-
session: () => wrap(
|
|
396
|
+
session: () => wrap(
|
|
397
|
+
() => this.clients.auth_root.get("/auth/session")
|
|
398
|
+
),
|
|
385
399
|
keys: {
|
|
386
400
|
list: () => wrap(() => this.clients.auth.get("/keys")),
|
|
387
|
-
create: (name) => wrap(
|
|
388
|
-
|
|
389
|
-
|
|
401
|
+
create: (name) => wrap(
|
|
402
|
+
() => this.clients.auth.post("/keys", {
|
|
403
|
+
body: name ? { name } : {}
|
|
404
|
+
})
|
|
405
|
+
),
|
|
406
|
+
revoke: (key_id) => wrap(
|
|
407
|
+
() => this.clients.auth.delete(
|
|
408
|
+
`/keys/${key_id}`
|
|
409
|
+
)
|
|
410
|
+
),
|
|
411
|
+
remove: (key_id) => wrap(
|
|
412
|
+
() => this.clients.auth.delete(
|
|
413
|
+
`/keys/${key_id}`
|
|
414
|
+
)
|
|
415
|
+
)
|
|
390
416
|
}
|
|
391
417
|
};
|
|
392
418
|
/**
|
|
@@ -396,7 +422,11 @@ var ApiClient2 = class {
|
|
|
396
422
|
/**
|
|
397
423
|
* List projects with optional filtering
|
|
398
424
|
*/
|
|
399
|
-
list: (filters) => wrap(
|
|
425
|
+
list: (filters) => wrap(
|
|
426
|
+
() => this.clients.projects.get(
|
|
427
|
+
filters?.private === false ? "/projects/public" : "/projects"
|
|
428
|
+
)
|
|
429
|
+
),
|
|
400
430
|
/**
|
|
401
431
|
* Get project map
|
|
402
432
|
*/
|
|
@@ -414,25 +444,35 @@ var ApiClient2 = class {
|
|
|
414
444
|
/**
|
|
415
445
|
* Get project by ID
|
|
416
446
|
*/
|
|
417
|
-
find: (id) => wrap(
|
|
447
|
+
find: (id) => wrap(
|
|
448
|
+
() => this.clients.projects.get("/projects", { query: { id } })
|
|
449
|
+
),
|
|
418
450
|
/**
|
|
419
451
|
* Get project by name
|
|
420
452
|
*/
|
|
421
|
-
getByName: (name) => wrap(
|
|
453
|
+
getByName: (name) => wrap(
|
|
454
|
+
() => this.clients.projects.get("/projects", { query: { name } })
|
|
455
|
+
),
|
|
422
456
|
/**
|
|
423
457
|
* Get project by ID (throws if not found)
|
|
424
458
|
*/
|
|
425
|
-
getById: (id) => wrap(
|
|
459
|
+
getById: (id) => wrap(
|
|
460
|
+
() => this.clients.projects.get("/projects", { query: { id } })
|
|
461
|
+
),
|
|
426
462
|
/**
|
|
427
463
|
* Create a new project
|
|
428
464
|
*/
|
|
429
|
-
create: (data) => wrap(
|
|
465
|
+
create: (data) => wrap(
|
|
466
|
+
() => this.clients.projects.patch("/projects", { body: data })
|
|
467
|
+
),
|
|
430
468
|
/**
|
|
431
469
|
* Update an existing project
|
|
432
470
|
*/
|
|
433
471
|
update: async (idOrData, changes) => wrap(async () => {
|
|
434
472
|
if (typeof idOrData === "object" && idOrData.id) {
|
|
435
|
-
return this.clients.projects.patch("/projects", {
|
|
473
|
+
return this.clients.projects.patch("/projects", {
|
|
474
|
+
body: idOrData
|
|
475
|
+
});
|
|
436
476
|
}
|
|
437
477
|
const id = idOrData;
|
|
438
478
|
if (!changes) {
|
|
@@ -460,7 +500,9 @@ var ApiClient2 = class {
|
|
|
460
500
|
current_version: project.current_version,
|
|
461
501
|
...changes
|
|
462
502
|
};
|
|
463
|
-
return this.clients.projects.patch("/projects", {
|
|
503
|
+
return this.clients.projects.patch("/projects", {
|
|
504
|
+
body: updateData
|
|
505
|
+
});
|
|
464
506
|
}),
|
|
465
507
|
/**
|
|
466
508
|
* Project configuration operations
|
|
@@ -469,11 +511,19 @@ var ApiClient2 = class {
|
|
|
469
511
|
/**
|
|
470
512
|
* Get project configuration
|
|
471
513
|
*/
|
|
472
|
-
load: (project_id) => wrap(
|
|
514
|
+
load: (project_id) => wrap(
|
|
515
|
+
() => this.clients.projects.get("/projects/config", {
|
|
516
|
+
query: { project_id }
|
|
517
|
+
})
|
|
518
|
+
),
|
|
473
519
|
/**
|
|
474
520
|
* Save project configuration
|
|
475
521
|
*/
|
|
476
|
-
save: (request) => wrap(
|
|
522
|
+
save: (request) => wrap(
|
|
523
|
+
() => this.clients.projects.patch("/projects/save_config", {
|
|
524
|
+
body: request
|
|
525
|
+
})
|
|
526
|
+
)
|
|
477
527
|
},
|
|
478
528
|
/**
|
|
479
529
|
* Scanning operations
|
|
@@ -483,10 +533,13 @@ var ApiClient2 = class {
|
|
|
483
533
|
* Initiate a repository scan (returns stream)
|
|
484
534
|
*/
|
|
485
535
|
initiate: async (project_id) => {
|
|
486
|
-
const response = await fetch(
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
536
|
+
const response = await fetch(
|
|
537
|
+
`${this.clients.projects.url()}/projects/scan?project_id=${project_id}`,
|
|
538
|
+
{
|
|
539
|
+
method: "POST",
|
|
540
|
+
headers: this.clients.projects.headers()
|
|
541
|
+
}
|
|
542
|
+
);
|
|
490
543
|
if (!response.body) {
|
|
491
544
|
throw new Error("No response body");
|
|
492
545
|
}
|
|
@@ -496,28 +549,47 @@ var ApiClient2 = class {
|
|
|
496
549
|
/**
|
|
497
550
|
* Get pending scan updates for a project
|
|
498
551
|
*/
|
|
499
|
-
updates: (project_id) => wrap(
|
|
552
|
+
updates: (project_id) => wrap(
|
|
553
|
+
() => this.clients.projects.get("/projects/updates", { query: { project_id } }).then((response) => response.updates)
|
|
554
|
+
),
|
|
500
555
|
/**
|
|
501
556
|
* Process scan results
|
|
502
557
|
*/
|
|
503
|
-
update: (project_id, data) => wrap(
|
|
558
|
+
update: (project_id, data) => wrap(
|
|
559
|
+
() => this.clients.projects.post("/projects/scan_status", {
|
|
560
|
+
query: { project_id },
|
|
561
|
+
body: data
|
|
562
|
+
})
|
|
563
|
+
)
|
|
504
564
|
},
|
|
505
565
|
/**
|
|
506
566
|
* Get project history
|
|
507
567
|
*/
|
|
508
|
-
history: (project_id) => wrap(
|
|
568
|
+
history: (project_id) => wrap(
|
|
569
|
+
() => this.clients.projects.get(`/projects/${project_id}/history`)
|
|
570
|
+
),
|
|
509
571
|
/**
|
|
510
572
|
* Legacy methods (keeping for compatibility)
|
|
511
573
|
*/
|
|
512
|
-
upsert: (data) => wrap(
|
|
574
|
+
upsert: (data) => wrap(
|
|
575
|
+
() => this.clients.projects.patch("/projects", { body: data })
|
|
576
|
+
),
|
|
513
577
|
/**
|
|
514
578
|
* Fetch project specification from GitHub
|
|
515
579
|
*/
|
|
516
|
-
specification: (project_id) => wrap(
|
|
580
|
+
specification: (project_id) => wrap(
|
|
581
|
+
() => this.clients.projects.get("/projects/fetch_spec", {
|
|
582
|
+
query: { project_id }
|
|
583
|
+
})
|
|
584
|
+
),
|
|
517
585
|
/**
|
|
518
586
|
* Delete project (soft delete)
|
|
519
587
|
*/
|
|
520
|
-
deleteProject: (project) => wrap(
|
|
588
|
+
deleteProject: (project) => wrap(
|
|
589
|
+
() => this.clients.projects.patch("/projects", {
|
|
590
|
+
body: { ...project, deleted: true }
|
|
591
|
+
})
|
|
592
|
+
)
|
|
521
593
|
};
|
|
522
594
|
/**
|
|
523
595
|
* Milestones namespace with Result-wrapped operations
|
|
@@ -530,7 +602,11 @@ var ApiClient2 = class {
|
|
|
530
602
|
/**
|
|
531
603
|
* Get milestones by project ID
|
|
532
604
|
*/
|
|
533
|
-
getByProject: (project_id) => wrap(
|
|
605
|
+
getByProject: (project_id) => wrap(
|
|
606
|
+
() => this.clients.milestones.get(
|
|
607
|
+
`/projects/${project_id}/milestones`
|
|
608
|
+
)
|
|
609
|
+
),
|
|
534
610
|
/**
|
|
535
611
|
* Get milestone by ID
|
|
536
612
|
*/
|
|
@@ -544,7 +620,9 @@ var ApiClient2 = class {
|
|
|
544
620
|
/**
|
|
545
621
|
* Create new milestone
|
|
546
622
|
*/
|
|
547
|
-
create: (data) => wrap(
|
|
623
|
+
create: (data) => wrap(
|
|
624
|
+
() => this.clients.milestones.post("/milestones", { body: data })
|
|
625
|
+
),
|
|
548
626
|
/**
|
|
549
627
|
* Update milestone
|
|
550
628
|
*/
|
|
@@ -561,12 +639,18 @@ var ApiClient2 = class {
|
|
|
561
639
|
target_time: data.target_time ?? milestone.target_time,
|
|
562
640
|
target_version: data.target_version ?? milestone.target_version
|
|
563
641
|
};
|
|
564
|
-
return this.clients.milestones.patch(`/milestones/${id}`, {
|
|
642
|
+
return this.clients.milestones.patch(`/milestones/${id}`, {
|
|
643
|
+
body: updateData
|
|
644
|
+
});
|
|
565
645
|
}),
|
|
566
646
|
/**
|
|
567
647
|
* Delete milestone (soft delete)
|
|
568
648
|
*/
|
|
569
|
-
delete: (id) => wrap(
|
|
649
|
+
delete: (id) => wrap(
|
|
650
|
+
() => this.clients.milestones.delete(
|
|
651
|
+
`/milestones/${id}`
|
|
652
|
+
)
|
|
653
|
+
),
|
|
570
654
|
/**
|
|
571
655
|
* Get goals for a milestone
|
|
572
656
|
*/
|
|
@@ -603,12 +687,18 @@ var ApiClient2 = class {
|
|
|
603
687
|
description: data.description ?? goal.description,
|
|
604
688
|
target_time: data.target_time ?? goal.target_time
|
|
605
689
|
};
|
|
606
|
-
return this.clients.goals.patch(`/goals/${id}`, {
|
|
690
|
+
return this.clients.goals.patch(`/goals/${id}`, {
|
|
691
|
+
body: updateData
|
|
692
|
+
});
|
|
607
693
|
}),
|
|
608
694
|
/**
|
|
609
695
|
* Delete goal (soft delete)
|
|
610
696
|
*/
|
|
611
|
-
delete: (id) => wrap(
|
|
697
|
+
delete: (id) => wrap(
|
|
698
|
+
() => this.clients.goals.delete(
|
|
699
|
+
`/goals/${id}`
|
|
700
|
+
)
|
|
701
|
+
)
|
|
612
702
|
};
|
|
613
703
|
/**
|
|
614
704
|
* Tasks namespace with Result-wrapped operations
|
|
@@ -621,7 +711,10 @@ var ApiClient2 = class {
|
|
|
621
711
|
const query = {};
|
|
622
712
|
if (filters?.project_id) query.project = filters.project_id;
|
|
623
713
|
if (filters?.tag_id) query.tag = filters.tag_id;
|
|
624
|
-
return this.clients.tasks.get(
|
|
714
|
+
return this.clients.tasks.get(
|
|
715
|
+
"/tasks",
|
|
716
|
+
Object.keys(query).length > 0 ? { query } : {}
|
|
717
|
+
);
|
|
625
718
|
}),
|
|
626
719
|
/**
|
|
627
720
|
* Get task by ID
|
|
@@ -630,11 +723,17 @@ var ApiClient2 = class {
|
|
|
630
723
|
/**
|
|
631
724
|
* Get tasks by project ID
|
|
632
725
|
*/
|
|
633
|
-
getByProject: (project_id) => wrap(
|
|
726
|
+
getByProject: (project_id) => wrap(
|
|
727
|
+
() => this.clients.tasks.get(`/tasks`, {
|
|
728
|
+
query: { project: project_id }
|
|
729
|
+
})
|
|
730
|
+
),
|
|
634
731
|
/**
|
|
635
732
|
* Create a new task
|
|
636
733
|
*/
|
|
637
|
-
create: (data) => wrap(
|
|
734
|
+
create: (data) => wrap(
|
|
735
|
+
() => this.clients.tasks.patch("/tasks", { body: data })
|
|
736
|
+
),
|
|
638
737
|
/**
|
|
639
738
|
* Update an existing task
|
|
640
739
|
*/
|
|
@@ -657,20 +756,30 @@ var ApiClient2 = class {
|
|
|
657
756
|
project_id: task.task.project_id,
|
|
658
757
|
...changes
|
|
659
758
|
};
|
|
660
|
-
return this.clients.tasks.patch("/tasks", {
|
|
759
|
+
return this.clients.tasks.patch("/tasks", {
|
|
760
|
+
body: updateData
|
|
761
|
+
});
|
|
661
762
|
}),
|
|
662
763
|
/**
|
|
663
764
|
* Upsert task (create or update)
|
|
664
765
|
*/
|
|
665
|
-
upsert: (data) => wrap(
|
|
766
|
+
upsert: (data) => wrap(
|
|
767
|
+
() => this.clients.tasks.patch("/tasks", { body: data })
|
|
768
|
+
),
|
|
666
769
|
/**
|
|
667
770
|
* Save tags for tasks
|
|
668
771
|
*/
|
|
669
|
-
saveTags: (data) => wrap(
|
|
772
|
+
saveTags: (data) => wrap(
|
|
773
|
+
() => this.clients.tasks.patch("/tasks/save_tags", { body: data })
|
|
774
|
+
),
|
|
670
775
|
/**
|
|
671
776
|
* Delete task (soft delete)
|
|
672
777
|
*/
|
|
673
|
-
deleteTask: (task) => wrap(
|
|
778
|
+
deleteTask: (task) => wrap(
|
|
779
|
+
() => this.clients.tasks.patch("/tasks", {
|
|
780
|
+
body: { ...task.task, deleted: true }
|
|
781
|
+
})
|
|
782
|
+
),
|
|
674
783
|
/**
|
|
675
784
|
* Task history operations
|
|
676
785
|
*/
|
|
@@ -678,7 +787,9 @@ var ApiClient2 = class {
|
|
|
678
787
|
/**
|
|
679
788
|
* Get task history by task ID
|
|
680
789
|
*/
|
|
681
|
-
get: (task_id) => wrap(
|
|
790
|
+
get: (task_id) => wrap(
|
|
791
|
+
() => this.clients.tasks.get(`/tasks/history/${task_id}`)
|
|
792
|
+
)
|
|
682
793
|
}
|
|
683
794
|
};
|
|
684
795
|
/**
|
|
@@ -701,7 +812,9 @@ var ApiClient2 = class {
|
|
|
701
812
|
/**
|
|
702
813
|
* List branches for a GitHub repository
|
|
703
814
|
*/
|
|
704
|
-
branches: (owner, repo) => wrap(
|
|
815
|
+
branches: (owner, repo) => wrap(
|
|
816
|
+
() => this.clients.github.get(`/repos/${owner}/${repo}/branches`)
|
|
817
|
+
)
|
|
705
818
|
};
|
|
706
819
|
this.blog = {
|
|
707
820
|
posts: {
|
|
@@ -711,83 +824,183 @@ var ApiClient2 = class {
|
|
|
711
824
|
if (params?.tag) query.tag = params.tag;
|
|
712
825
|
if (params?.project) query.project = params.project;
|
|
713
826
|
if (params?.status) query.status = params.status;
|
|
714
|
-
if (params?.archived !== void 0)
|
|
827
|
+
if (params?.archived !== void 0)
|
|
828
|
+
query.archived = String(params.archived);
|
|
715
829
|
if (params?.limit) query.limit = String(params.limit);
|
|
716
|
-
if (params?.offset !== void 0)
|
|
830
|
+
if (params?.offset !== void 0)
|
|
831
|
+
query.offset = String(params.offset);
|
|
717
832
|
if (params?.sort) query.sort = params.sort;
|
|
718
|
-
return this.clients.blog.get(
|
|
833
|
+
return this.clients.blog.get(
|
|
834
|
+
"/blog/posts",
|
|
835
|
+
Object.keys(query).length ? { query } : {}
|
|
836
|
+
);
|
|
719
837
|
}),
|
|
720
838
|
getBySlug: (slug) => wrap(() => this.clients.blog.get(`/blog/posts/${slug}`)),
|
|
721
839
|
create: (data) => wrap(() => this.clients.blog.post("/blog/posts", { body: data })),
|
|
722
|
-
update: (uuid, data) => wrap(
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
840
|
+
update: (uuid, data) => wrap(
|
|
841
|
+
() => this.clients.blog.put(`/blog/posts/${uuid}`, { body: data })
|
|
842
|
+
),
|
|
843
|
+
delete: (uuid) => wrap(
|
|
844
|
+
() => this.clients.blog.delete(`/blog/posts/${uuid}`)
|
|
845
|
+
),
|
|
846
|
+
versions: (uuid) => wrap(
|
|
847
|
+
() => this.clients.blog.get(
|
|
848
|
+
`/blog/posts/${uuid}/versions`
|
|
849
|
+
)
|
|
850
|
+
),
|
|
851
|
+
version: (uuid, hash) => wrap(
|
|
852
|
+
() => this.clients.blog.get(
|
|
853
|
+
`/blog/posts/${uuid}/version/${hash}`
|
|
854
|
+
)
|
|
855
|
+
),
|
|
856
|
+
restore: (uuid, hash) => wrap(
|
|
857
|
+
() => this.clients.blog.post(`/blog/posts/${uuid}/restore/${hash}`)
|
|
858
|
+
)
|
|
727
859
|
},
|
|
728
860
|
tags: {
|
|
729
|
-
list: () => wrap(
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
861
|
+
list: () => wrap(
|
|
862
|
+
() => this.clients.blog.get("/blog/tags")
|
|
863
|
+
),
|
|
864
|
+
getForPost: (uuid) => wrap(
|
|
865
|
+
() => this.clients.blog.get(
|
|
866
|
+
`/blog/tags/posts/${uuid}/tags`
|
|
867
|
+
)
|
|
868
|
+
),
|
|
869
|
+
setForPost: (uuid, tags) => wrap(
|
|
870
|
+
() => this.clients.blog.put(
|
|
871
|
+
`/blog/tags/posts/${uuid}/tags`,
|
|
872
|
+
{ body: { tags } }
|
|
873
|
+
)
|
|
874
|
+
),
|
|
875
|
+
addToPost: (uuid, tags) => wrap(
|
|
876
|
+
() => this.clients.blog.post(
|
|
877
|
+
`/blog/tags/posts/${uuid}/tags`,
|
|
878
|
+
{ body: { tags } }
|
|
879
|
+
)
|
|
880
|
+
),
|
|
881
|
+
removeFromPost: (uuid, tag) => wrap(
|
|
882
|
+
() => this.clients.blog.delete(
|
|
883
|
+
`/blog/tags/posts/${uuid}/tags/${tag}`
|
|
884
|
+
)
|
|
885
|
+
)
|
|
734
886
|
},
|
|
735
887
|
categories: {
|
|
736
|
-
tree: () => wrap(
|
|
737
|
-
|
|
738
|
-
|
|
888
|
+
tree: () => wrap(
|
|
889
|
+
() => this.clients.blog.get("/blog/categories")
|
|
890
|
+
),
|
|
891
|
+
create: (data) => wrap(
|
|
892
|
+
() => this.clients.blog.post("/blog/categories", { body: data })
|
|
893
|
+
),
|
|
894
|
+
update: (name, data) => wrap(
|
|
895
|
+
() => this.clients.blog.put(`/blog/categories/${name}`, {
|
|
896
|
+
body: data
|
|
897
|
+
})
|
|
898
|
+
),
|
|
739
899
|
delete: (name) => wrap(() => this.clients.blog.delete(`/blog/categories/${name}`))
|
|
740
900
|
},
|
|
741
901
|
tokens: {
|
|
742
|
-
list: () => wrap(
|
|
743
|
-
|
|
744
|
-
|
|
902
|
+
list: () => wrap(
|
|
903
|
+
() => this.clients.blog.get("/blog/tokens")
|
|
904
|
+
),
|
|
905
|
+
create: (data) => wrap(
|
|
906
|
+
() => this.clients.blog.post("/blog/tokens", { body: data })
|
|
907
|
+
),
|
|
908
|
+
update: (id, data) => wrap(
|
|
909
|
+
() => this.clients.blog.put(`/blog/tokens/${id}`, {
|
|
910
|
+
body: data
|
|
911
|
+
})
|
|
912
|
+
),
|
|
745
913
|
delete: (id) => wrap(() => this.clients.blog.delete(`/blog/tokens/${id}`))
|
|
746
914
|
}
|
|
747
915
|
};
|
|
748
916
|
this.media = {
|
|
749
917
|
profiles: {
|
|
750
918
|
list: () => wrap(async () => {
|
|
751
|
-
const res = await this.clients.media.get(
|
|
919
|
+
const res = await this.clients.media.get(
|
|
920
|
+
"/profiles"
|
|
921
|
+
);
|
|
752
922
|
return res.profiles;
|
|
753
923
|
}),
|
|
754
|
-
create: (data) => wrap(
|
|
924
|
+
create: (data) => wrap(
|
|
925
|
+
() => this.clients.media.post("/profiles", { body: data })
|
|
926
|
+
),
|
|
755
927
|
get: (id) => wrap(() => this.clients.media.get(`/profiles/${id}`)),
|
|
756
|
-
update: (id, data) => wrap(
|
|
757
|
-
|
|
928
|
+
update: (id, data) => wrap(
|
|
929
|
+
() => this.clients.media.patch(`/profiles/${id}`, { body: data })
|
|
930
|
+
),
|
|
931
|
+
delete: (id) => wrap(
|
|
932
|
+
() => this.clients.media.delete(`/profiles/${id}`)
|
|
933
|
+
),
|
|
758
934
|
filters: {
|
|
759
935
|
list: (profile_id) => wrap(async () => {
|
|
760
936
|
const res = await this.clients.media.get(`/profiles/${profile_id}/filters`);
|
|
761
937
|
return res.filters;
|
|
762
938
|
}),
|
|
763
|
-
add: (profile_id, data) => wrap(
|
|
764
|
-
|
|
939
|
+
add: (profile_id, data) => wrap(
|
|
940
|
+
() => this.clients.media.post(
|
|
941
|
+
`/profiles/${profile_id}/filters`,
|
|
942
|
+
{ body: data }
|
|
943
|
+
)
|
|
944
|
+
),
|
|
945
|
+
remove: (profile_id, filter_id) => wrap(
|
|
946
|
+
() => this.clients.media.delete(
|
|
947
|
+
`/profiles/${profile_id}/filters/${filter_id}`
|
|
948
|
+
)
|
|
949
|
+
)
|
|
765
950
|
},
|
|
766
951
|
timeline: (slug, params) => wrap(() => {
|
|
767
952
|
const query = {};
|
|
768
953
|
if (params?.limit) query.limit = String(params.limit);
|
|
769
954
|
if (params?.before) query.before = params.before;
|
|
770
|
-
return this.clients.media.get(
|
|
955
|
+
return this.clients.media.get(
|
|
956
|
+
`/profiles/${slug}/timeline`,
|
|
957
|
+
Object.keys(query).length ? { query } : {}
|
|
958
|
+
);
|
|
771
959
|
})
|
|
772
960
|
},
|
|
773
961
|
connections: {
|
|
774
962
|
list: (profile_id, options) => wrap(async () => {
|
|
775
963
|
const query = { profile_id };
|
|
776
964
|
if (options?.include_settings) query.include_settings = "true";
|
|
777
|
-
const res = await this.clients.media.get(
|
|
965
|
+
const res = await this.clients.media.get(
|
|
966
|
+
"/connections",
|
|
967
|
+
{ query }
|
|
968
|
+
);
|
|
778
969
|
return res.accounts;
|
|
779
970
|
}),
|
|
780
|
-
create: (data) => wrap(
|
|
781
|
-
|
|
782
|
-
|
|
971
|
+
create: (data) => wrap(
|
|
972
|
+
() => this.clients.media.post("/connections", { body: data })
|
|
973
|
+
),
|
|
974
|
+
delete: (account_id) => wrap(
|
|
975
|
+
() => this.clients.media.delete(
|
|
976
|
+
`/connections/${account_id}`
|
|
977
|
+
)
|
|
978
|
+
),
|
|
979
|
+
refresh: (account_id) => wrap(
|
|
980
|
+
() => this.clients.media.post(`/connections/${account_id}/refresh`)
|
|
981
|
+
),
|
|
783
982
|
refreshAll: () => wrap(() => this.clients.media.post("/connections/refresh-all")),
|
|
784
|
-
updateStatus: (account_id, is_active) => wrap(
|
|
983
|
+
updateStatus: (account_id, is_active) => wrap(
|
|
984
|
+
() => this.clients.media.patch(`/connections/${account_id}`, {
|
|
985
|
+
body: { is_active }
|
|
986
|
+
})
|
|
987
|
+
),
|
|
785
988
|
settings: {
|
|
786
|
-
get: (account_id) => wrap(
|
|
787
|
-
|
|
989
|
+
get: (account_id) => wrap(
|
|
990
|
+
() => this.clients.media.get(
|
|
991
|
+
`/connections/${account_id}/settings`
|
|
992
|
+
)
|
|
993
|
+
),
|
|
994
|
+
update: (account_id, settings) => wrap(
|
|
995
|
+
() => this.clients.media.put(`/connections/${account_id}/settings`, {
|
|
996
|
+
body: { settings }
|
|
997
|
+
})
|
|
998
|
+
)
|
|
788
999
|
},
|
|
789
1000
|
repos: (account_id) => wrap(async () => {
|
|
790
|
-
const res = await this.clients.media.get(
|
|
1001
|
+
const res = await this.clients.media.get(
|
|
1002
|
+
`/connections/${account_id}/repos`
|
|
1003
|
+
);
|
|
791
1004
|
return res.repos;
|
|
792
1005
|
}),
|
|
793
1006
|
subreddits: (account_id) => wrap(async () => {
|
|
@@ -796,18 +1009,37 @@ var ApiClient2 = class {
|
|
|
796
1009
|
})
|
|
797
1010
|
},
|
|
798
1011
|
credentials: {
|
|
799
|
-
check: (platform, profile_id) => wrap(
|
|
800
|
-
|
|
801
|
-
|
|
1012
|
+
check: (platform, profile_id) => wrap(
|
|
1013
|
+
() => this.clients.media.get(`/credentials/${platform}`, { query: { profile_id } })
|
|
1014
|
+
),
|
|
1015
|
+
save: (platform, data) => wrap(
|
|
1016
|
+
() => this.clients.media.post(
|
|
1017
|
+
`/credentials/${platform}`,
|
|
1018
|
+
{ body: data }
|
|
1019
|
+
)
|
|
1020
|
+
),
|
|
1021
|
+
delete: (platform, profile_id) => wrap(
|
|
1022
|
+
() => this.clients.media.delete(
|
|
1023
|
+
`/credentials/${platform}`,
|
|
1024
|
+
{ query: { profile_id } }
|
|
1025
|
+
)
|
|
1026
|
+
)
|
|
802
1027
|
},
|
|
803
1028
|
timeline: {
|
|
804
1029
|
get: (user_id, params) => wrap(() => {
|
|
805
1030
|
const query = {};
|
|
806
1031
|
if (params?.from) query.from = params.from;
|
|
807
1032
|
if (params?.to) query.to = params.to;
|
|
808
|
-
return this.clients.media.get(
|
|
1033
|
+
return this.clients.media.get(
|
|
1034
|
+
`/timeline/${user_id}`,
|
|
1035
|
+
Object.keys(query).length ? { query } : {}
|
|
1036
|
+
);
|
|
809
1037
|
}),
|
|
810
|
-
getRaw: (user_id, platform, account_id) => wrap(
|
|
1038
|
+
getRaw: (user_id, platform, account_id) => wrap(
|
|
1039
|
+
() => this.clients.media.get(`/timeline/${user_id}/raw/${platform}`, {
|
|
1040
|
+
query: { account_id }
|
|
1041
|
+
})
|
|
1042
|
+
)
|
|
811
1043
|
}
|
|
812
1044
|
};
|
|
813
1045
|
/**
|
|
@@ -821,7 +1053,9 @@ var ApiClient2 = class {
|
|
|
821
1053
|
/**
|
|
822
1054
|
* Update user preferences
|
|
823
1055
|
*/
|
|
824
|
-
preferences: (data) => wrap(
|
|
1056
|
+
preferences: (data) => wrap(
|
|
1057
|
+
() => this.clients.auth.patch("/user/preferences", { body: data })
|
|
1058
|
+
)
|
|
825
1059
|
};
|
|
826
1060
|
const base_url = options.base_url || "http://localhost:4321/api/v1";
|
|
827
1061
|
this._api_key = options.api_key ?? "";
|
|
@@ -838,7 +1072,11 @@ var ApiClient2 = class {
|
|
|
838
1072
|
const auth_base_url = base_url.replace(/\/v1\/?$/, "");
|
|
839
1073
|
this.clients = {
|
|
840
1074
|
auth: new ApiClient({ ...clientOptions, category: "auth" }),
|
|
841
|
-
auth_root: new ApiClient({
|
|
1075
|
+
auth_root: new ApiClient({
|
|
1076
|
+
...clientOptions,
|
|
1077
|
+
base_url: auth_base_url,
|
|
1078
|
+
category: "auth"
|
|
1079
|
+
}),
|
|
842
1080
|
projects: new ApiClient({ ...clientOptions, category: "projects" }),
|
|
843
1081
|
tasks: new ApiClient({ ...clientOptions, category: "tasks" }),
|
|
844
1082
|
milestones: new ApiClient({ ...clientOptions, category: "milestones" }),
|
|
@@ -916,7 +1154,9 @@ var tools = {
|
|
|
916
1154
|
name: "devpad_projects_get",
|
|
917
1155
|
description: "Get project by ID or name",
|
|
918
1156
|
inputSchema: project_by_id_or_name,
|
|
919
|
-
execute: async (client, input) => unwrap(
|
|
1157
|
+
execute: async (client, input) => unwrap(
|
|
1158
|
+
input.id ? await client.projects.getById(input.id) : await client.projects.getByName(input.name)
|
|
1159
|
+
)
|
|
920
1160
|
},
|
|
921
1161
|
devpad_projects_upsert: {
|
|
922
1162
|
name: "devpad_projects_upsert",
|
|
@@ -966,7 +1206,9 @@ var tools = {
|
|
|
966
1206
|
name: "devpad_milestones_list",
|
|
967
1207
|
description: "List milestones for authenticated user or by project",
|
|
968
1208
|
inputSchema: milestone_filters,
|
|
969
|
-
execute: async (client, input) => unwrap(
|
|
1209
|
+
execute: async (client, input) => unwrap(
|
|
1210
|
+
input.project_id ? await client.milestones.getByProject(input.project_id) : await client.milestones.list()
|
|
1211
|
+
)
|
|
970
1212
|
},
|
|
971
1213
|
devpad_milestones_get: {
|
|
972
1214
|
name: "devpad_milestones_get",
|