@air/api-rest 0.9.0 → 0.11.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.
- package/README.md +5 -2
- package/dist/index.cjs +281 -0
- package/dist/index.d.cts +470 -6
- package/dist/index.d.ts +470 -6
- package/dist/index.js +278 -0
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Typed REST client for the [Air API SDK](https://github.com/AirLabsTeam/air-api-sdk).
|
|
4
4
|
|
|
5
|
-
This package provides the resource classes (boards, assets, tags, custom fields, uploads, imports, roles) and their TypeScript types. It builds on `@air/api-core` for HTTP transport.
|
|
5
|
+
This package provides the resource classes (boards, showcases, assets, tags, custom fields, discussions, members, uploads, imports, roles) and their TypeScript types. It builds on `@air/api-core` for HTTP transport.
|
|
6
6
|
|
|
7
7
|
## Installation
|
|
8
8
|
|
|
@@ -20,7 +20,10 @@ npm install @air/api-rest
|
|
|
20
20
|
|
|
21
21
|
## What's included
|
|
22
22
|
|
|
23
|
-
- Resource classes: `
|
|
23
|
+
- Resource classes: `Boards`, `Showcases`, `Assets`, `Tags`, `CustomFields`, `Discussions`, `Members`, `Uploads`, `Imports`, `Roles`
|
|
24
|
+
- Discussions: `list`, `get`, `listComments`, `create`, `createComment`, `update`, `updateComment`, `deleteComment`
|
|
25
|
+
- Members: `list`
|
|
26
|
+
- Showcases: `list`, `get`, `create`, `update`, `updateShareLink`, `addAssets`, `removeAsset`, `addBoards`, `removeBoard`, plus a `showcaseId` filter on `assets.list` and `boards.list`
|
|
24
27
|
- Asset CDN link helpers: `listCdnLinks`, `createCdnLink`, and `updateCdnLink`
|
|
25
28
|
- Share links: `listShareLinks`, `createShareLink`, and `updateShareLink` on assets and boards
|
|
26
29
|
- Full TypeScript types for all API request/response shapes
|
package/dist/index.cjs
CHANGED
|
@@ -40,14 +40,17 @@ __export(index_exports, {
|
|
|
40
40
|
ConnectionError: () => import_api_core2.ConnectionError,
|
|
41
41
|
CursorPage: () => import_api_core2.CursorPage,
|
|
42
42
|
CustomFields: () => CustomFields,
|
|
43
|
+
Discussions: () => Discussions,
|
|
43
44
|
Imports: () => Imports,
|
|
44
45
|
InternalServerError: () => import_api_core2.InternalServerError,
|
|
45
46
|
Libraries: () => Libraries,
|
|
47
|
+
Members: () => Members,
|
|
46
48
|
NotFoundError: () => import_api_core2.NotFoundError,
|
|
47
49
|
PagePromise: () => import_api_core2.PagePromise,
|
|
48
50
|
PermissionError: () => import_api_core2.PermissionError,
|
|
49
51
|
RateLimitError: () => import_api_core2.RateLimitError,
|
|
50
52
|
Roles: () => Roles,
|
|
53
|
+
Showcases: () => Showcases,
|
|
51
54
|
Tags: () => Tags,
|
|
52
55
|
TimeoutError: () => import_api_core2.TimeoutError,
|
|
53
56
|
Uploads: () => Uploads,
|
|
@@ -99,6 +102,7 @@ var Assets = class {
|
|
|
99
102
|
limit: params.limit,
|
|
100
103
|
cursor: params.cursor,
|
|
101
104
|
parentBoardId: params.parentBoardId,
|
|
105
|
+
showcaseId: params.showcaseId,
|
|
102
106
|
search: params.search
|
|
103
107
|
};
|
|
104
108
|
if (params.includeNestedAssets !== void 0) {
|
|
@@ -248,6 +252,7 @@ var Boards = class {
|
|
|
248
252
|
cursor: params.cursor,
|
|
249
253
|
name: params.name,
|
|
250
254
|
parentBoardId: params.parentBoardId,
|
|
255
|
+
showcaseId: params.showcaseId,
|
|
251
256
|
libraryId: params.libraryId,
|
|
252
257
|
inGeneralLibrary: params.inGeneralLibrary
|
|
253
258
|
};
|
|
@@ -415,6 +420,118 @@ var CustomFields = class {
|
|
|
415
420
|
}
|
|
416
421
|
};
|
|
417
422
|
|
|
423
|
+
// src/resources/discussions.ts
|
|
424
|
+
var Discussions = class {
|
|
425
|
+
constructor(client) {
|
|
426
|
+
this.client = client;
|
|
427
|
+
}
|
|
428
|
+
/**
|
|
429
|
+
* List discussions on an asset or on the assets currently in a board.
|
|
430
|
+
* Exactly one of `assetId` or `boardId` is required.
|
|
431
|
+
*
|
|
432
|
+
* Pages don't overlap. With the default `lastCommentedAt` sort, a reply
|
|
433
|
+
* between pages can move a discussion, so it may repeat or be skipped. For
|
|
434
|
+
* a stable walk, use `sortBy: "createdAt"` and `sortDirection: "asc"`.
|
|
435
|
+
*/
|
|
436
|
+
list(params) {
|
|
437
|
+
const query = {
|
|
438
|
+
assetId: params.assetId,
|
|
439
|
+
assetVersionId: params.assetVersionId,
|
|
440
|
+
boardId: params.boardId,
|
|
441
|
+
resolved: params.resolved,
|
|
442
|
+
sortBy: params.sortBy,
|
|
443
|
+
sortDirection: params.sortDirection,
|
|
444
|
+
limit: params.limit,
|
|
445
|
+
cursor: params.cursor
|
|
446
|
+
};
|
|
447
|
+
return this.client.requestCursorPage(
|
|
448
|
+
{ method: "GET", path: "/discussions", query },
|
|
449
|
+
query
|
|
450
|
+
);
|
|
451
|
+
}
|
|
452
|
+
/** Get one discussion, including its first 10 comments. A discussion you cannot view is 404. */
|
|
453
|
+
async get(discussionId) {
|
|
454
|
+
return this.client.request({
|
|
455
|
+
method: "GET",
|
|
456
|
+
path: `/discussions/${discussionId}`
|
|
457
|
+
});
|
|
458
|
+
}
|
|
459
|
+
/**
|
|
460
|
+
* List every comment on a discussion, oldest first.
|
|
461
|
+
* `discussion.comments.pagination.cursor` is accepted as `cursor`.
|
|
462
|
+
*/
|
|
463
|
+
listComments(discussionId, params = {}) {
|
|
464
|
+
const query = {
|
|
465
|
+
limit: params.limit,
|
|
466
|
+
cursor: params.cursor
|
|
467
|
+
};
|
|
468
|
+
return this.client.requestCursorPage(
|
|
469
|
+
{ method: "GET", path: `/discussions/${discussionId}/comments`, query },
|
|
470
|
+
query
|
|
471
|
+
);
|
|
472
|
+
}
|
|
473
|
+
/**
|
|
474
|
+
* Start a discussion on an asset version. `assetVersionId` is required.
|
|
475
|
+
* Mention someone with `{{mention:N}}` and a `mentions` entry at that index.
|
|
476
|
+
* On a document or PDF, every annotation needs a `pageNumber`.
|
|
477
|
+
*
|
|
478
|
+
* The body has no board. In a workspace that scopes comments to boards, a
|
|
479
|
+
* discussion with no board needs `asset.canManageDiscussions` at the
|
|
480
|
+
* workspace level, so a board guest gets 403 even when they can comment in
|
|
481
|
+
* their board. A timeout can create a duplicate: list before retrying.
|
|
482
|
+
*/
|
|
483
|
+
async create(params) {
|
|
484
|
+
return this.client.request({
|
|
485
|
+
method: "POST",
|
|
486
|
+
path: "/discussions",
|
|
487
|
+
body: params
|
|
488
|
+
});
|
|
489
|
+
}
|
|
490
|
+
/** Add a comment. The body and mention rules match `create`. */
|
|
491
|
+
async createComment(discussionId, params) {
|
|
492
|
+
return this.client.request({
|
|
493
|
+
method: "POST",
|
|
494
|
+
path: `/discussions/${discussionId}/comments`,
|
|
495
|
+
body: params
|
|
496
|
+
});
|
|
497
|
+
}
|
|
498
|
+
/**
|
|
499
|
+
* Resolve or reopen a discussion. The response is empty, including when the
|
|
500
|
+
* discussion was already in the requested state.
|
|
501
|
+
*/
|
|
502
|
+
async update(discussionId, params) {
|
|
503
|
+
return this.client.request({
|
|
504
|
+
method: "PATCH",
|
|
505
|
+
path: `/discussions/${discussionId}`,
|
|
506
|
+
body: params
|
|
507
|
+
});
|
|
508
|
+
}
|
|
509
|
+
/**
|
|
510
|
+
* Replace a comment's text and mentions. Only the author can edit.
|
|
511
|
+
* The response is empty, and the edit notifies no one. An edit that leaves
|
|
512
|
+
* the text and mentions as they are changes nothing and keeps `updatedAt`.
|
|
513
|
+
* Omitting `mentions`, or sending `null`, when the comment has them is 409.
|
|
514
|
+
* `[]` removes them.
|
|
515
|
+
*/
|
|
516
|
+
async updateComment(discussionId, commentId, params) {
|
|
517
|
+
return this.client.request({
|
|
518
|
+
method: "PATCH",
|
|
519
|
+
path: `/discussions/${discussionId}/comments/${commentId}`,
|
|
520
|
+
body: params
|
|
521
|
+
});
|
|
522
|
+
}
|
|
523
|
+
/**
|
|
524
|
+
* Delete a comment. Only the author can delete. The response is empty.
|
|
525
|
+
* Deleting the last comment deletes the discussion.
|
|
526
|
+
*/
|
|
527
|
+
async deleteComment(discussionId, commentId) {
|
|
528
|
+
return this.client.request({
|
|
529
|
+
method: "DELETE",
|
|
530
|
+
path: `/discussions/${discussionId}/comments/${commentId}`
|
|
531
|
+
});
|
|
532
|
+
}
|
|
533
|
+
};
|
|
534
|
+
|
|
418
535
|
// src/resources/imports.ts
|
|
419
536
|
var Imports = class {
|
|
420
537
|
constructor(client) {
|
|
@@ -479,6 +596,30 @@ var Libraries = class {
|
|
|
479
596
|
}
|
|
480
597
|
};
|
|
481
598
|
|
|
599
|
+
// src/resources/members.ts
|
|
600
|
+
var Members = class {
|
|
601
|
+
constructor(client) {
|
|
602
|
+
this.client = client;
|
|
603
|
+
}
|
|
604
|
+
/**
|
|
605
|
+
* List people in the workspace. Requires `members.read`.
|
|
606
|
+
* `workspace.read` does not grant it.
|
|
607
|
+
*
|
|
608
|
+
* Sort is fixed: `firstJoinedAt` ascending, then `id`.
|
|
609
|
+
* `email` without `type` searches every type. An unknown email is an empty list.
|
|
610
|
+
*/
|
|
611
|
+
list(params = {}) {
|
|
612
|
+
const query = {
|
|
613
|
+
type: params.type,
|
|
614
|
+
email: params.email,
|
|
615
|
+
search: params.search,
|
|
616
|
+
limit: params.limit,
|
|
617
|
+
cursor: params.cursor
|
|
618
|
+
};
|
|
619
|
+
return this.client.requestCursorPage({ method: "GET", path: "/members", query }, query);
|
|
620
|
+
}
|
|
621
|
+
};
|
|
622
|
+
|
|
482
623
|
// src/resources/roles.ts
|
|
483
624
|
var Roles = class {
|
|
484
625
|
constructor(client) {
|
|
@@ -494,6 +635,137 @@ var Roles = class {
|
|
|
494
635
|
}
|
|
495
636
|
};
|
|
496
637
|
|
|
638
|
+
// src/resources/showcases.ts
|
|
639
|
+
var Showcases = class {
|
|
640
|
+
constructor(client) {
|
|
641
|
+
this.client = client;
|
|
642
|
+
}
|
|
643
|
+
/**
|
|
644
|
+
* List the showcases the caller can see.
|
|
645
|
+
*
|
|
646
|
+
* A role that can view every showcase in the workspace sees all of them.
|
|
647
|
+
* Otherwise only the showcases that caller owns are returned. Showcases
|
|
648
|
+
* without a share link are omitted; read those with `get`. Sub-pages are
|
|
649
|
+
* not listed separately.
|
|
650
|
+
*
|
|
651
|
+
* Requires the `showcases.read` and `share_links.read` OAuth scopes.
|
|
652
|
+
*/
|
|
653
|
+
list(params = {}) {
|
|
654
|
+
const query = {
|
|
655
|
+
limit: params.limit,
|
|
656
|
+
cursor: params.cursor,
|
|
657
|
+
search: params.search,
|
|
658
|
+
status: params.status
|
|
659
|
+
};
|
|
660
|
+
return this.client.requestCursorPage(
|
|
661
|
+
{ method: "GET", path: "/showcases", query },
|
|
662
|
+
query
|
|
663
|
+
);
|
|
664
|
+
}
|
|
665
|
+
/**
|
|
666
|
+
* Get a showcase and its share link. `shareLink` is null when the
|
|
667
|
+
* showcase has none.
|
|
668
|
+
*
|
|
669
|
+
* Requires the `showcases.read` and `share_links.read` OAuth scopes.
|
|
670
|
+
*/
|
|
671
|
+
async get(showcaseId) {
|
|
672
|
+
return this.client.request({
|
|
673
|
+
method: "GET",
|
|
674
|
+
path: `/showcases/${showcaseId}`
|
|
675
|
+
});
|
|
676
|
+
}
|
|
677
|
+
/**
|
|
678
|
+
* Create a showcase and its share link in one step. The result includes
|
|
679
|
+
* the link. Create does not take items.
|
|
680
|
+
*
|
|
681
|
+
* Requires the `showcases.write` and `share_links.write` OAuth scopes.
|
|
682
|
+
*/
|
|
683
|
+
async create(params) {
|
|
684
|
+
return this.client.request({
|
|
685
|
+
method: "POST",
|
|
686
|
+
path: "/showcases",
|
|
687
|
+
body: params
|
|
688
|
+
});
|
|
689
|
+
}
|
|
690
|
+
/**
|
|
691
|
+
* Rename a showcase or change its description. Only the fields you send
|
|
692
|
+
* change. Returns no body.
|
|
693
|
+
*
|
|
694
|
+
* Requires the `showcases.write` OAuth scope.
|
|
695
|
+
*/
|
|
696
|
+
async update(showcaseId, params) {
|
|
697
|
+
return this.client.request({
|
|
698
|
+
method: "PATCH",
|
|
699
|
+
path: `/showcases/${showcaseId}`,
|
|
700
|
+
body: params
|
|
701
|
+
});
|
|
702
|
+
}
|
|
703
|
+
/**
|
|
704
|
+
* Change the settings of a showcase's share link. Only the settings you
|
|
705
|
+
* send change. Send `password: null` or `expiresAt: null` to remove them.
|
|
706
|
+
* Returns no body.
|
|
707
|
+
*
|
|
708
|
+
* Requires the `share_links.write` and `showcases.read` OAuth scopes.
|
|
709
|
+
*/
|
|
710
|
+
async updateShareLink(showcaseId, shareLinkId, params) {
|
|
711
|
+
return this.client.request({
|
|
712
|
+
method: "PATCH",
|
|
713
|
+
path: `/showcases/${showcaseId}/share-links/${shareLinkId}`,
|
|
714
|
+
body: params
|
|
715
|
+
});
|
|
716
|
+
}
|
|
717
|
+
/**
|
|
718
|
+
* Add assets to a showcase. Assets already in it are skipped. Returns no
|
|
719
|
+
* body. List them with `assets.list({ showcaseId })`.
|
|
720
|
+
*
|
|
721
|
+
* Requires the `showcases.write` and `assets.read` OAuth scopes.
|
|
722
|
+
*/
|
|
723
|
+
async addAssets(showcaseId, params) {
|
|
724
|
+
return this.client.request({
|
|
725
|
+
method: "POST",
|
|
726
|
+
path: `/showcases/${showcaseId}/assets`,
|
|
727
|
+
body: params
|
|
728
|
+
});
|
|
729
|
+
}
|
|
730
|
+
/**
|
|
731
|
+
* Remove an asset from a showcase. The asset itself is not deleted.
|
|
732
|
+
* Removing an asset that is not in the showcase succeeds. Returns no body.
|
|
733
|
+
*
|
|
734
|
+
* Requires the `showcases.write` OAuth scope.
|
|
735
|
+
*/
|
|
736
|
+
async removeAsset(showcaseId, assetId) {
|
|
737
|
+
return this.client.request({
|
|
738
|
+
method: "DELETE",
|
|
739
|
+
path: `/showcases/${showcaseId}/assets/${assetId}`
|
|
740
|
+
});
|
|
741
|
+
}
|
|
742
|
+
/**
|
|
743
|
+
* Add boards to a showcase. Boards already in it are skipped. Returns no
|
|
744
|
+
* body. List them with `boards.list({ showcaseId })`.
|
|
745
|
+
*
|
|
746
|
+
* Requires the `showcases.write` and `boards.read` OAuth scopes.
|
|
747
|
+
*/
|
|
748
|
+
async addBoards(showcaseId, params) {
|
|
749
|
+
return this.client.request({
|
|
750
|
+
method: "POST",
|
|
751
|
+
path: `/showcases/${showcaseId}/boards`,
|
|
752
|
+
body: params
|
|
753
|
+
});
|
|
754
|
+
}
|
|
755
|
+
/**
|
|
756
|
+
* Remove a board from a showcase. The board itself is not deleted.
|
|
757
|
+
* Removing a board that is not in the showcase succeeds. Returns no body.
|
|
758
|
+
*
|
|
759
|
+
* Requires the `showcases.write` OAuth scope.
|
|
760
|
+
*/
|
|
761
|
+
async removeBoard(showcaseId, boardId) {
|
|
762
|
+
return this.client.request({
|
|
763
|
+
method: "DELETE",
|
|
764
|
+
path: `/showcases/${showcaseId}/boards/${boardId}`
|
|
765
|
+
});
|
|
766
|
+
}
|
|
767
|
+
};
|
|
768
|
+
|
|
497
769
|
// src/resources/tags.ts
|
|
498
770
|
var Tags = class {
|
|
499
771
|
constructor(client) {
|
|
@@ -783,9 +1055,12 @@ var Workspaces = class {
|
|
|
783
1055
|
var AirApi = class extends import_api_core.AirBase {
|
|
784
1056
|
assets;
|
|
785
1057
|
boards;
|
|
1058
|
+
showcases;
|
|
786
1059
|
libraries;
|
|
787
1060
|
tags;
|
|
788
1061
|
customFields;
|
|
1062
|
+
discussions;
|
|
1063
|
+
members;
|
|
789
1064
|
roles;
|
|
790
1065
|
imports;
|
|
791
1066
|
uploads;
|
|
@@ -794,9 +1069,12 @@ var AirApi = class extends import_api_core.AirBase {
|
|
|
794
1069
|
super(options);
|
|
795
1070
|
this.assets = new Assets(this);
|
|
796
1071
|
this.boards = new Boards(this);
|
|
1072
|
+
this.showcases = new Showcases(this);
|
|
797
1073
|
this.libraries = new Libraries(this);
|
|
798
1074
|
this.tags = new Tags(this);
|
|
799
1075
|
this.customFields = new CustomFields(this);
|
|
1076
|
+
this.discussions = new Discussions(this);
|
|
1077
|
+
this.members = new Members(this);
|
|
800
1078
|
this.roles = new Roles(this);
|
|
801
1079
|
this.imports = new Imports(this);
|
|
802
1080
|
this.uploads = new Uploads(this);
|
|
@@ -818,14 +1096,17 @@ var import_api_core2 = require("@air/api-core");
|
|
|
818
1096
|
ConnectionError,
|
|
819
1097
|
CursorPage,
|
|
820
1098
|
CustomFields,
|
|
1099
|
+
Discussions,
|
|
821
1100
|
Imports,
|
|
822
1101
|
InternalServerError,
|
|
823
1102
|
Libraries,
|
|
1103
|
+
Members,
|
|
824
1104
|
NotFoundError,
|
|
825
1105
|
PagePromise,
|
|
826
1106
|
PermissionError,
|
|
827
1107
|
RateLimitError,
|
|
828
1108
|
Roles,
|
|
1109
|
+
Showcases,
|
|
829
1110
|
Tags,
|
|
830
1111
|
TimeoutError,
|
|
831
1112
|
Uploads,
|