@gitbook/api 0.15.0 → 0.17.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/dist/index.js CHANGED
@@ -91,6 +91,16 @@ var TeamMemberRole = /* @__PURE__ */ ((TeamMemberRole2) => {
91
91
  TeamMemberRole2["Member"] = "member";
92
92
  return TeamMemberRole2;
93
93
  })(TeamMemberRole || {});
94
+ var ContentAuditRelationType = /* @__PURE__ */ ((ContentAuditRelationType2) => {
95
+ ContentAuditRelationType2["Contradiction"] = "contradiction";
96
+ ContentAuditRelationType2["Duplicate"] = "duplicate";
97
+ return ContentAuditRelationType2;
98
+ })(ContentAuditRelationType || {});
99
+ var ContentAuditRelationStatus = /* @__PURE__ */ ((ContentAuditRelationStatus2) => {
100
+ ContentAuditRelationStatus2["Pending"] = "pending";
101
+ ContentAuditRelationStatus2["Rejected"] = "rejected";
102
+ return ContentAuditRelationStatus2;
103
+ })(ContentAuditRelationStatus || {});
94
104
  var ChangeRequestStatus = /* @__PURE__ */ ((ChangeRequestStatus2) => {
95
105
  ChangeRequestStatus2["Draft"] = "draft";
96
106
  ChangeRequestStatus2["Open"] = "open";
@@ -117,6 +127,7 @@ var AnalyticsTrafficInterval = /* @__PURE__ */ ((AnalyticsTrafficInterval2) => {
117
127
  })(AnalyticsTrafficInterval || {});
118
128
  var IntegrationScope = /* @__PURE__ */ ((IntegrationScope2) => {
119
129
  IntegrationScope2["EntitiesWrite"] = "entities:write";
130
+ IntegrationScope2["SnippetsRead"] = "snippets:read";
120
131
  IntegrationScope2["CaptureWrite"] = "capture:write";
121
132
  IntegrationScope2["SpaceViewsRead"] = "space:views:read";
122
133
  IntegrationScope2["SpaceContentRead"] = "space:content:read";
@@ -621,11 +632,26 @@ var Api = class extends HttpClient {
621
632
  format: "json",
622
633
  ...params
623
634
  }),
635
+ listPages: (spaceId, params = {}) => this.request({
636
+ path: `/spaces/${spaceId}/content/pages`,
637
+ method: "GET",
638
+ secure: true,
639
+ format: "json",
640
+ ...params
641
+ }),
624
642
  listFiles: (spaceId, query, params = {}) => this.request({
625
643
  path: `/spaces/${spaceId}/content/files`,
626
644
  method: "GET",
627
645
  query,
628
646
  secure: true,
647
+ format: "json",
648
+ ...params
649
+ }),
650
+ getFileById: (spaceId, fileId, params = {}) => this.request({
651
+ path: `/spaces/${spaceId}/content/files/${fileId}`,
652
+ method: "GET",
653
+ secure: true,
654
+ format: "json",
629
655
  ...params
630
656
  }),
631
657
  getPageById: (spaceId, pageId, query, params = {}) => this.request({
@@ -653,6 +679,13 @@ var Api = class extends HttpClient {
653
679
  format: "json",
654
680
  ...params
655
681
  }),
682
+ getDocumentById: (spaceId, documentId, params = {}) => this.request({
683
+ path: `/spaces/${spaceId}/documents/${documentId}`,
684
+ method: "GET",
685
+ secure: true,
686
+ format: "json",
687
+ ...params
688
+ }),
656
689
  createChangeRequest: (spaceId, data, params = {}) => this.request({
657
690
  path: `/spaces/${spaceId}/change-requests`,
658
691
  method: "POST",
@@ -829,11 +862,26 @@ var Api = class extends HttpClient {
829
862
  format: "json",
830
863
  ...params
831
864
  }),
865
+ listPagesInChangeRequest: (spaceId, changeRequestId, params = {}) => this.request({
866
+ path: `/spaces/${spaceId}/change-requests/${changeRequestId}/content/pages`,
867
+ method: "GET",
868
+ secure: true,
869
+ format: "json",
870
+ ...params
871
+ }),
832
872
  listFilesInChangeRequestById: (spaceId, changeRequestId, query, params = {}) => this.request({
833
873
  path: `/spaces/${spaceId}/change-requests/${changeRequestId}/content/files`,
834
874
  method: "GET",
835
875
  query,
836
876
  secure: true,
877
+ format: "json",
878
+ ...params
879
+ }),
880
+ getFileInChangeRequestById: (spaceId, changeRequestId, fileId, params = {}) => this.request({
881
+ path: `/spaces/${spaceId}/change-requests/${changeRequestId}/content/files/${fileId}`,
882
+ method: "GET",
883
+ secure: true,
884
+ format: "json",
837
885
  ...params
838
886
  }),
839
887
  getPageInChangeRequestById: (spaceId, changeRequestId, pageId, query, params = {}) => this.request({
@@ -876,11 +924,26 @@ var Api = class extends HttpClient {
876
924
  format: "json",
877
925
  ...params
878
926
  }),
927
+ listPagesInRevisionById: (spaceId, revisionId, params = {}) => this.request({
928
+ path: `/spaces/${spaceId}/revisions/${revisionId}/pages`,
929
+ method: "GET",
930
+ secure: true,
931
+ format: "json",
932
+ ...params
933
+ }),
879
934
  listFilesInRevisionById: (spaceId, revisionId, query, params = {}) => this.request({
880
935
  path: `/spaces/${spaceId}/revisions/${revisionId}/files`,
881
936
  method: "GET",
882
937
  query,
883
938
  secure: true,
939
+ format: "json",
940
+ ...params
941
+ }),
942
+ getFileInRevisionById: (spaceId, revisionId, fileId, params = {}) => this.request({
943
+ path: `/spaces/${spaceId}/revisions/${revisionId}/files/${fileId}`,
944
+ method: "GET",
945
+ secure: true,
946
+ format: "json",
884
947
  ...params
885
948
  }),
886
949
  getPageInRevisionById: (spaceId, revisionId, pageId, query, params = {}) => this.request({
@@ -1612,6 +1675,13 @@ var Api = class extends HttpClient {
1612
1675
  format: "json",
1613
1676
  ...params
1614
1677
  }),
1678
+ getOrganizationIntegrationStatus: (organizationId, integrationName, params = {}) => this.request({
1679
+ path: `/orgs/${organizationId}/integrations/${integrationName}/installation_status`,
1680
+ method: "GET",
1681
+ secure: true,
1682
+ format: "json",
1683
+ ...params
1684
+ }),
1615
1685
  listOrganizationInstallations: (organizationId, query, params = {}) => this.request({
1616
1686
  path: `/orgs/${organizationId}/installations`,
1617
1687
  method: "GET",
@@ -1730,6 +1800,46 @@ var Api = class extends HttpClient {
1730
1800
  format: "json",
1731
1801
  ...params
1732
1802
  }),
1803
+ listSnippets: (organizationId, query, params = {}) => this.request({
1804
+ path: `/orgs/${organizationId}/snippets`,
1805
+ method: "GET",
1806
+ query,
1807
+ secure: true,
1808
+ format: "json",
1809
+ ...params
1810
+ }),
1811
+ createSnippet: (organizationId, data, params = {}) => this.request({
1812
+ path: `/orgs/${organizationId}/snippets`,
1813
+ method: "POST",
1814
+ body: data,
1815
+ secure: true,
1816
+ type: "application/json" /* Json */,
1817
+ format: "json",
1818
+ ...params
1819
+ }),
1820
+ getSnippet: (organizationId, snippetId, query, params = {}) => this.request({
1821
+ path: `/orgs/${organizationId}/snippets/${snippetId}`,
1822
+ method: "GET",
1823
+ query,
1824
+ secure: true,
1825
+ format: "json",
1826
+ ...params
1827
+ }),
1828
+ deleteSnippet: (organizationId, snippetId, params = {}) => this.request({
1829
+ path: `/orgs/${organizationId}/snippets/${snippetId}`,
1830
+ method: "DELETE",
1831
+ secure: true,
1832
+ ...params
1833
+ }),
1834
+ updateSnippet: (organizationId, snippetId, data, params = {}) => this.request({
1835
+ path: `/orgs/${organizationId}/snippets/${snippetId}`,
1836
+ method: "PUT",
1837
+ body: data,
1838
+ secure: true,
1839
+ type: "application/json" /* Json */,
1840
+ format: "json",
1841
+ ...params
1842
+ }),
1733
1843
  askInOrganization: (organizationId, data, params = {}) => this.request({
1734
1844
  path: `/orgs/${organizationId}/ask`,
1735
1845
  method: "POST",
@@ -1755,6 +1865,14 @@ var Api = class extends HttpClient {
1755
1865
  type: "application/json" /* Json */,
1756
1866
  format: "json",
1757
1867
  ...params
1868
+ }),
1869
+ getContentAuditSourceContentById: (organizationId, sourceId, query, params = {}) => this.request({
1870
+ path: `/orgs/${organizationId}/insights/audit-sources/${sourceId}/content`,
1871
+ method: "GET",
1872
+ query,
1873
+ secure: true,
1874
+ format: "json",
1875
+ ...params
1758
1876
  })
1759
1877
  };
1760
1878
  this.internal = {
@@ -1797,6 +1915,17 @@ var Api = class extends HttpClient {
1797
1915
  }
1798
1916
  };
1799
1917
 
1918
+ // src/GitBookAPIError.ts
1919
+ var GitBookAPIError = class extends Error {
1920
+ constructor(errorMessage, response) {
1921
+ const message = `GitBook API failed with [${response.status}] ${response.url}: ${errorMessage}`;
1922
+ super(message);
1923
+ this.name = "GitBookAPIError";
1924
+ this.response = response;
1925
+ this.code = response.status;
1926
+ }
1927
+ };
1928
+
1800
1929
  // src/index.ts
1801
1930
  var GITBOOK_DEFAULT_ENDPOINT = "https://api.gitbook.com";
1802
1931
  var GitBookAPI = class extends Api {
@@ -1828,13 +1957,8 @@ var GitBookAPI = class extends Api {
1828
1957
  const body = await response.json();
1829
1958
  error = body?.error?.message || error;
1830
1959
  } catch (err) {
1831
- response.headers.forEach((value, key) => {
1832
- error += `${key}:${value} `;
1833
- });
1834
1960
  }
1835
- throw new Error(
1836
- `GitBook API failed with [${response.status}] ${response.url}: ${error}`
1837
- );
1961
+ throw new GitBookAPIError(error, response);
1838
1962
  }
1839
1963
  return response;
1840
1964
  }
@@ -1865,6 +1989,8 @@ export {
1865
1989
  CloudflareHostnameStatus,
1866
1990
  CloudflareHostnameTLSStatus,
1867
1991
  CloudflareHostnameTLSValidationMethod,
1992
+ ContentAuditRelationStatus,
1993
+ ContentAuditRelationType,
1868
1994
  ContentKitIcon,
1869
1995
  ContentType,
1870
1996
  ContentVisibility,
@@ -1876,6 +2002,7 @@ export {
1876
2002
  CustomizationThemeMode,
1877
2003
  GITBOOK_DEFAULT_ENDPOINT,
1878
2004
  GitBookAPI,
2005
+ GitBookAPIError,
1879
2006
  GitSyncOperationState,
1880
2007
  HttpClient,
1881
2008
  ImportContentSource,
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "main": "./dist/index.cjs",
5
5
  "module": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",
7
- "version": "0.15.0",
7
+ "version": "0.17.0",
8
8
  "sideEffects": false,
9
9
  "files": [
10
10
  "README.md",