@gitbook/api 0.26.0 → 0.28.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/client.d.ts CHANGED
@@ -450,6 +450,21 @@ export declare type PublishedContentLookup = {
450
450
  /** Short-lived API token to fetch content related to the space in the context of the URL. */
451
451
  apiToken: string;
452
452
  };
453
+ export interface SpacePointer {
454
+ type: 'space';
455
+ /** Unique identifier for the space */
456
+ space: string;
457
+ }
458
+ export interface CollectionPointer {
459
+ type: 'collection';
460
+ /** Unique identifier for the collection */
461
+ collection: string;
462
+ }
463
+ /** Position at which to insert an item */
464
+ export interface ContentPosition {
465
+ before?: SpacePointer | CollectionPointer;
466
+ after?: SpacePointer | CollectionPointer;
467
+ }
453
468
  export declare type Document = MarkdownDocument | {
454
469
  document: JSONDocument;
455
470
  } | object;
@@ -459,7 +474,11 @@ export interface MarkdownDocument {
459
474
  }
460
475
  export interface JSONDocument {
461
476
  object: 'document';
462
- data: object;
477
+ data: {
478
+ /** The schema version of the document. If undefined, the document is considered to be of the latest schema version. */
479
+ schemaVersion?: number;
480
+ [key: string]: any;
481
+ };
463
482
  nodes: DocumentBlocksTopLevels[];
464
483
  }
465
484
  export declare type DocumentBlock = DocumentBlockParagraph | DocumentBlockHeading | DocumentBlockListOrdered | DocumentBlockListUnordered | DocumentBlockListTasks | DocumentBlockListItem | DocumentBlockDivider | DocumentBlockQuote | DocumentBlockHint | DocumentBlockImages | DocumentBlockImage | DocumentBlockFile | DocumentBlockDrawing | DocumentBlockEmbed | DocumentBlockCode | DocumentBlockCodeLine | DocumentBlockMath | DocumentBlockExpandable | DocumentBlockTabs | DocumentBlockTabsItem | DocumentBlockTable | DocumentBlockSwagger | DocumentBlockContentRef | DocumentBlockIntegration;
@@ -1032,10 +1051,7 @@ export interface Space {
1032
1051
  * @format uri
1033
1052
  */
1034
1053
  public?: string;
1035
- /**
1036
- * URL of the icon of this space, if defined. Deprecated, prefer using emojis for spaces instead of icons.
1037
- * @deprecated
1038
- */
1054
+ /** URL of the icon of this space, if defined. */
1039
1055
  icon?: URL;
1040
1056
  };
1041
1057
  /** ID of the organization owning this space */
@@ -1043,6 +1059,15 @@ export interface Space {
1043
1059
  /** ID of the parent collection. */
1044
1060
  parent?: string;
1045
1061
  gitSync?: GitSyncState;
1062
+ visitorAuth?: {
1063
+ /** Custom backend for Visitor Authentication */
1064
+ backend: 'custom';
1065
+ } | {
1066
+ /** Integration as backend for Visitor Authentication */
1067
+ backend: 'integration';
1068
+ /** Name of integration being used as the backend for Visitor Authentication */
1069
+ integration: string;
1070
+ };
1046
1071
  }
1047
1072
  /**
1048
1073
  * Determines how a Space can be edited.
@@ -1415,6 +1440,10 @@ export interface Organization {
1415
1440
  type: OrganizationType;
1416
1441
  useCase?: OrganizationUseCase;
1417
1442
  communityType?: OrganizationCommunityType;
1443
+ /** The role of a member in an organization, null for guests */
1444
+ defaultRole?: MemberRoleOrGuest;
1445
+ /** The default content for the organization */
1446
+ defaultContent?: OrganizationDefaultContent;
1418
1447
  /** URLs associated with the object */
1419
1448
  urls: {
1420
1449
  /**
@@ -1549,6 +1578,8 @@ export interface OrganizationTeamMember {
1549
1578
  organization: OrganizationMember;
1550
1579
  team: TeamMember;
1551
1580
  }
1581
+ /** The default content for the organization */
1582
+ export declare type OrganizationDefaultContent = SpacePointer | CollectionPointer;
1552
1583
  export interface Capture {
1553
1584
  /** Unique identifier for the capture */
1554
1585
  id: string;
@@ -2007,8 +2038,7 @@ export interface AnalyticsContentPages {
2007
2038
  }
2008
2039
  /** Page entry in the content analytics. */
2009
2040
  export interface AnalyticsContentPage {
2010
- page: string;
2011
- title: string;
2041
+ page: RevisionPageDocument;
2012
2042
  pageViews: number;
2013
2043
  feedbacks?: {
2014
2044
  /** Score based on each rating (+1 for 'good', -0.5 for 'ok', -2 for 'bad'). */
@@ -2388,8 +2418,19 @@ export interface IntegrationEnvironment {
2388
2418
  spaceInstallation?: IntegrationSpaceInstallation;
2389
2419
  /** Secrets stored on the integration and passed at runtime. */
2390
2420
  secrets: IntegrationSecrets;
2391
- /** Secret that can be used to verify the authenticity of incoming HTTP requests to the integration. */
2421
+ /**
2422
+ * Secret that can be used to verify the authenticity of incoming HTTP requests to the integration.
2423
+ * @deprecated
2424
+ */
2392
2425
  signingSecret?: string;
2426
+ signingSecrets: {
2427
+ /** Secret that can be used to verify the authenticity of incoming HTTP requests to the integration. */
2428
+ integration: string;
2429
+ /** Secret that can be used to verify the authenticity of incoming HTTP requests to the installation. */
2430
+ installation?: string;
2431
+ /** Secret that can be used to verify the authenticity of incoming HTTP requests to the space installation. */
2432
+ spaceInstallation?: string;
2433
+ };
2393
2434
  /** URL of the HTTP API */
2394
2435
  apiEndpoint: string;
2395
2436
  apiTokens: {
@@ -3891,7 +3932,17 @@ export declare class Api<SecurityDataType extends unknown> extends HttpClient<Se
3891
3932
  * * `private`: Authorized members can access the content.
3892
3933
  */
3893
3934
  visibility?: ContentVisibility;
3894
- }, params?: RequestParams) => Promise<HttpResponse<Space, Error>>;
3935
+ /** The integration property, if set, is ignored. */
3936
+ visitorAuth?: any;
3937
+ } & ({
3938
+ /** Unicode codepoint or character of the emoji */
3939
+ emoji: Emoji;
3940
+ } | {
3941
+ icon: URL;
3942
+ } | {
3943
+ emoji?: null;
3944
+ icon?: null;
3945
+ }), params?: RequestParams) => Promise<HttpResponse<Space, Error>>;
3895
3946
  /**
3896
3947
  * No description
3897
3948
  *
@@ -3932,6 +3983,64 @@ export declare class Api<SecurityDataType extends unknown> extends HttpClient<Se
3932
3983
  * @secure
3933
3984
  */
3934
3985
  restoreSpace: (spaceId: string, params?: RequestParams) => Promise<HttpResponse<Space, Error>>;
3986
+ /**
3987
+ * No description
3988
+ *
3989
+ * @tags spaces
3990
+ * @name MoveSpace
3991
+ * @summary Move a space to a new position.
3992
+ * @request POST:/spaces/{spaceId}/move
3993
+ * @secure
3994
+ */
3995
+ moveSpace: (spaceId: string, data: {
3996
+ /** The unique id of the parent collection */
3997
+ parent?: string | null;
3998
+ /** Where to move the space. By default, it will be moved at the end. */
3999
+ position?: ContentPosition;
4000
+ }, params?: RequestParams) => Promise<HttpResponse<Space, Error | {
4001
+ error: {
4002
+ /** @format int32 */
4003
+ code: 400;
4004
+ message: string;
4005
+ };
4006
+ } | {
4007
+ error: {
4008
+ /** @format int32 */
4009
+ code: 404;
4010
+ message: string;
4011
+ };
4012
+ } | {
4013
+ error: {
4014
+ /** @format int32 */
4015
+ code: 409;
4016
+ message: string;
4017
+ };
4018
+ }>>;
4019
+ /**
4020
+ * No description
4021
+ *
4022
+ * @tags spaces
4023
+ * @name TransferSpace
4024
+ * @summary Transfer a space to another organization, collection or both.
4025
+ * @request POST:/spaces/{spaceId}/transfer
4026
+ * @secure
4027
+ */
4028
+ transferSpace: (spaceId: string, data: {
4029
+ /** The unique id of the target organization */
4030
+ organization: string;
4031
+ }, params?: RequestParams) => Promise<HttpResponse<Space, Error | {
4032
+ error: {
4033
+ /** @format int32 */
4034
+ code: 404;
4035
+ message: string;
4036
+ };
4037
+ } | {
4038
+ error: {
4039
+ /** @format int32 */
4040
+ code: 409;
4041
+ message: string;
4042
+ };
4043
+ }>>;
3935
4044
  /**
3936
4045
  * No description
3937
4046
  *
@@ -5031,6 +5140,64 @@ export declare class Api<SecurityDataType extends unknown> extends HttpClient<Se
5031
5140
  }, params?: RequestParams) => Promise<HttpResponse<List & {
5032
5141
  items: Space[];
5033
5142
  }, Error>>;
5143
+ /**
5144
+ * No description
5145
+ *
5146
+ * @tags collections
5147
+ * @name MoveCollection
5148
+ * @summary Move a collection to a new position.
5149
+ * @request POST:/collections/{collectionId}/move
5150
+ * @secure
5151
+ */
5152
+ moveCollection: (collectionId: string, data: {
5153
+ /** The unique id of the parent collection */
5154
+ parent?: string | null;
5155
+ /** Where to move the collection. By default, it will be moved at the end. */
5156
+ position?: ContentPosition;
5157
+ }, params?: RequestParams) => Promise<HttpResponse<Collection, Error | {
5158
+ error: {
5159
+ /** @format int32 */
5160
+ code: 400;
5161
+ message: string;
5162
+ };
5163
+ } | {
5164
+ error: {
5165
+ /** @format int32 */
5166
+ code: 404;
5167
+ message: string;
5168
+ };
5169
+ } | {
5170
+ error: {
5171
+ /** @format int32 */
5172
+ code: 409;
5173
+ message: string;
5174
+ };
5175
+ }>>;
5176
+ /**
5177
+ * No description
5178
+ *
5179
+ * @tags collections
5180
+ * @name TransferCollection
5181
+ * @summary Transfer a collection to another organization.
5182
+ * @request POST:/collections/{collectionId}/transfer
5183
+ * @secure
5184
+ */
5185
+ transferCollection: (collectionId: string, data: {
5186
+ /** The unique id of the target organization */
5187
+ organization: string;
5188
+ }, params?: RequestParams) => Promise<HttpResponse<Collection, Error | {
5189
+ error: {
5190
+ /** @format int32 */
5191
+ code: 404;
5192
+ message: string;
5193
+ };
5194
+ } | {
5195
+ error: {
5196
+ /** @format int32 */
5197
+ code: 409;
5198
+ message: string;
5199
+ };
5200
+ }>>;
5034
5201
  /**
5035
5202
  * No description
5036
5203
  *
@@ -5546,6 +5713,29 @@ export declare class Api<SecurityDataType extends unknown> extends HttpClient<Se
5546
5713
  message: string;
5547
5714
  };
5548
5715
  }>>;
5716
+ /**
5717
+ * No description
5718
+ *
5719
+ * @tags organizations
5720
+ * @name UpdateOrganizationById
5721
+ * @summary Update an organization by its ID
5722
+ * @request PATCH:/orgs/{organizationId}
5723
+ * @secure
5724
+ */
5725
+ updateOrganizationById: (organizationId: string, data: {
5726
+ /** Name of the organization */
5727
+ title?: OrganizationTitle;
5728
+ emailDomains?: OrganizationEmailDomains;
5729
+ /** The role of a member in an organization, null for guests */
5730
+ defaultRole?: MemberRoleOrGuest;
5731
+ defaultContent?: OrganizationDefaultContent | null;
5732
+ }, params?: RequestParams) => Promise<HttpResponse<Organization, Error | {
5733
+ error: {
5734
+ /** @format int32 */
5735
+ code: 400;
5736
+ message: string;
5737
+ };
5738
+ }>>;
5549
5739
  /**
5550
5740
  * @description Lists members for the specified organization.
5551
5741
  *
package/dist/index.cjs CHANGED
@@ -3,8 +3,8 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
3
  var __getOwnPropNames = Object.getOwnPropertyNames;
4
4
  var __hasOwnProp = Object.prototype.hasOwnProperty;
5
5
  var __export = (target, all) => {
6
- for (var name in all)
7
- __defProp(target, name, { get: all[name], enumerable: true });
6
+ for (var name2 in all)
7
+ __defProp(target, name2, { get: all[name2], enumerable: true });
8
8
  };
9
9
  var __copyProps = (to, from, except, desc) => {
10
10
  if (from && typeof from === "object" || typeof from === "function") {
@@ -68,6 +68,10 @@ __export(src_exports, {
68
68
  });
69
69
  module.exports = __toCommonJS(src_exports);
70
70
 
71
+ // package.json
72
+ var name = "@gitbook/api";
73
+ var version = "0.28.0";
74
+
71
75
  // src/client.ts
72
76
  var ContentVisibility = /* @__PURE__ */ ((ContentVisibility2) => {
73
77
  ContentVisibility2["Public"] = "public";
@@ -626,6 +630,24 @@ var Api = class extends HttpClient {
626
630
  format: "json",
627
631
  ...params
628
632
  }),
633
+ moveSpace: (spaceId, data, params = {}) => this.request({
634
+ path: `/spaces/${spaceId}/move`,
635
+ method: "POST",
636
+ body: data,
637
+ secure: true,
638
+ type: "application/json" /* Json */,
639
+ format: "json",
640
+ ...params
641
+ }),
642
+ transferSpace: (spaceId, data, params = {}) => this.request({
643
+ path: `/spaces/${spaceId}/transfer`,
644
+ method: "POST",
645
+ body: data,
646
+ secure: true,
647
+ type: "application/json" /* Json */,
648
+ format: "json",
649
+ ...params
650
+ }),
629
651
  searchSpaceContent: (spaceId, query, params = {}) => this.request({
630
652
  path: `/spaces/${spaceId}/search`,
631
653
  method: "GET",
@@ -1264,6 +1286,24 @@ var Api = class extends HttpClient {
1264
1286
  format: "json",
1265
1287
  ...params
1266
1288
  }),
1289
+ moveCollection: (collectionId, data, params = {}) => this.request({
1290
+ path: `/collections/${collectionId}/move`,
1291
+ method: "POST",
1292
+ body: data,
1293
+ secure: true,
1294
+ type: "application/json" /* Json */,
1295
+ format: "json",
1296
+ ...params
1297
+ }),
1298
+ transferCollection: (collectionId, data, params = {}) => this.request({
1299
+ path: `/collections/${collectionId}/transfer`,
1300
+ method: "POST",
1301
+ body: data,
1302
+ secure: true,
1303
+ type: "application/json" /* Json */,
1304
+ format: "json",
1305
+ ...params
1306
+ }),
1267
1307
  listPermissionsAggregateInCollection: (collectionId, query, params = {}) => this.request({
1268
1308
  path: `/collections/${collectionId}/permissions/aggregate`,
1269
1309
  method: "GET",
@@ -1515,6 +1555,15 @@ var Api = class extends HttpClient {
1515
1555
  secure: true,
1516
1556
  ...params
1517
1557
  }),
1558
+ updateOrganizationById: (organizationId, data, params = {}) => this.request({
1559
+ path: `/orgs/${organizationId}`,
1560
+ method: "PATCH",
1561
+ body: data,
1562
+ secure: true,
1563
+ type: "application/json" /* Json */,
1564
+ format: "json",
1565
+ ...params
1566
+ }),
1518
1567
  listMembersInOrganizationById: (organizationId, query, params = {}) => this.request({
1519
1568
  path: `/orgs/${organizationId}/members`,
1520
1569
  method: "GET",
@@ -2090,14 +2139,19 @@ var GitBookAPIError = class extends Error {
2090
2139
  var GITBOOK_DEFAULT_ENDPOINT = "https://api.gitbook.com";
2091
2140
  var GitBookAPI = class extends Api {
2092
2141
  constructor(options = {}) {
2093
- const { endpoint = GITBOOK_DEFAULT_ENDPOINT, authToken } = options;
2142
+ const {
2143
+ endpoint = GITBOOK_DEFAULT_ENDPOINT,
2144
+ authToken,
2145
+ userAgent = `${name}/${version}`
2146
+ } = options;
2094
2147
  super({
2095
2148
  baseUrl: `${endpoint}/v1`,
2096
2149
  securityWorker: (securityData) => {
2097
2150
  if (securityData.authToken) {
2098
2151
  return {
2099
2152
  headers: {
2100
- Authorization: `Bearer ${securityData.authToken}`
2153
+ Authorization: `Bearer ${securityData.authToken}`,
2154
+ "User-Agent": userAgent
2101
2155
  }
2102
2156
  };
2103
2157
  }
@@ -2124,6 +2178,7 @@ var GitBookAPI = class extends Api {
2124
2178
  }
2125
2179
  });
2126
2180
  this.endpoint = endpoint;
2181
+ this.userAgent = userAgent;
2127
2182
  this.authToken = authToken;
2128
2183
  this.setSecurityData({ authToken });
2129
2184
  }
@@ -2134,6 +2189,7 @@ var GitBookAPI = class extends Api {
2134
2189
  );
2135
2190
  return new GitBookAPI({
2136
2191
  endpoint: this.endpoint,
2192
+ userAgent: this.userAgent,
2137
2193
  authToken: installationToken.token
2138
2194
  });
2139
2195
  }
package/dist/index.d.ts CHANGED
@@ -14,12 +14,21 @@ export declare class GitBookAPI extends Api<{
14
14
  * Authentication token used by the API client.
15
15
  */
16
16
  readonly authToken: string | undefined;
17
+ /**
18
+ * User agent used by the API client.
19
+ */
20
+ readonly userAgent: string;
17
21
  constructor(options?: {
18
22
  /**
19
23
  * API endpoint to use.
20
24
  * @default "https://api.gitbook.com"
21
25
  */
22
26
  endpoint?: string;
27
+ /**
28
+ * User agent to use.
29
+ * It'll default to the package name and version.
30
+ */
31
+ userAgent?: string;
23
32
  /**
24
33
  * Authentication token to use.
25
34
  */
package/dist/index.js CHANGED
@@ -1,3 +1,7 @@
1
+ // package.json
2
+ var name = "@gitbook/api";
3
+ var version = "0.28.0";
4
+
1
5
  // src/client.ts
2
6
  var ContentVisibility = /* @__PURE__ */ ((ContentVisibility2) => {
3
7
  ContentVisibility2["Public"] = "public";
@@ -556,6 +560,24 @@ var Api = class extends HttpClient {
556
560
  format: "json",
557
561
  ...params
558
562
  }),
563
+ moveSpace: (spaceId, data, params = {}) => this.request({
564
+ path: `/spaces/${spaceId}/move`,
565
+ method: "POST",
566
+ body: data,
567
+ secure: true,
568
+ type: "application/json" /* Json */,
569
+ format: "json",
570
+ ...params
571
+ }),
572
+ transferSpace: (spaceId, data, params = {}) => this.request({
573
+ path: `/spaces/${spaceId}/transfer`,
574
+ method: "POST",
575
+ body: data,
576
+ secure: true,
577
+ type: "application/json" /* Json */,
578
+ format: "json",
579
+ ...params
580
+ }),
559
581
  searchSpaceContent: (spaceId, query, params = {}) => this.request({
560
582
  path: `/spaces/${spaceId}/search`,
561
583
  method: "GET",
@@ -1194,6 +1216,24 @@ var Api = class extends HttpClient {
1194
1216
  format: "json",
1195
1217
  ...params
1196
1218
  }),
1219
+ moveCollection: (collectionId, data, params = {}) => this.request({
1220
+ path: `/collections/${collectionId}/move`,
1221
+ method: "POST",
1222
+ body: data,
1223
+ secure: true,
1224
+ type: "application/json" /* Json */,
1225
+ format: "json",
1226
+ ...params
1227
+ }),
1228
+ transferCollection: (collectionId, data, params = {}) => this.request({
1229
+ path: `/collections/${collectionId}/transfer`,
1230
+ method: "POST",
1231
+ body: data,
1232
+ secure: true,
1233
+ type: "application/json" /* Json */,
1234
+ format: "json",
1235
+ ...params
1236
+ }),
1197
1237
  listPermissionsAggregateInCollection: (collectionId, query, params = {}) => this.request({
1198
1238
  path: `/collections/${collectionId}/permissions/aggregate`,
1199
1239
  method: "GET",
@@ -1445,6 +1485,15 @@ var Api = class extends HttpClient {
1445
1485
  secure: true,
1446
1486
  ...params
1447
1487
  }),
1488
+ updateOrganizationById: (organizationId, data, params = {}) => this.request({
1489
+ path: `/orgs/${organizationId}`,
1490
+ method: "PATCH",
1491
+ body: data,
1492
+ secure: true,
1493
+ type: "application/json" /* Json */,
1494
+ format: "json",
1495
+ ...params
1496
+ }),
1448
1497
  listMembersInOrganizationById: (organizationId, query, params = {}) => this.request({
1449
1498
  path: `/orgs/${organizationId}/members`,
1450
1499
  method: "GET",
@@ -2020,14 +2069,19 @@ var GitBookAPIError = class extends Error {
2020
2069
  var GITBOOK_DEFAULT_ENDPOINT = "https://api.gitbook.com";
2021
2070
  var GitBookAPI = class extends Api {
2022
2071
  constructor(options = {}) {
2023
- const { endpoint = GITBOOK_DEFAULT_ENDPOINT, authToken } = options;
2072
+ const {
2073
+ endpoint = GITBOOK_DEFAULT_ENDPOINT,
2074
+ authToken,
2075
+ userAgent = `${name}/${version}`
2076
+ } = options;
2024
2077
  super({
2025
2078
  baseUrl: `${endpoint}/v1`,
2026
2079
  securityWorker: (securityData) => {
2027
2080
  if (securityData.authToken) {
2028
2081
  return {
2029
2082
  headers: {
2030
- Authorization: `Bearer ${securityData.authToken}`
2083
+ Authorization: `Bearer ${securityData.authToken}`,
2084
+ "User-Agent": userAgent
2031
2085
  }
2032
2086
  };
2033
2087
  }
@@ -2054,6 +2108,7 @@ var GitBookAPI = class extends Api {
2054
2108
  }
2055
2109
  });
2056
2110
  this.endpoint = endpoint;
2111
+ this.userAgent = userAgent;
2057
2112
  this.authToken = authToken;
2058
2113
  this.setSecurityData({ authToken });
2059
2114
  }
@@ -2064,6 +2119,7 @@ var GitBookAPI = class extends Api {
2064
2119
  );
2065
2120
  return new GitBookAPI({
2066
2121
  endpoint: this.endpoint,
2122
+ userAgent: this.userAgent,
2067
2123
  authToken: installationToken.token
2068
2124
  });
2069
2125
  }
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.26.0",
7
+ "version": "0.28.0",
8
8
  "sideEffects": false,
9
9
  "files": [
10
10
  "README.md",