@gitbook/api 0.25.0 → 0.27.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
@@ -17,11 +17,11 @@ export interface List {
17
17
  export declare type URL = string;
18
18
  /** @pattern ^#(?:[0-9a-fA-F]{3}){1,2}$ */
19
19
  export declare type Color = string;
20
- /** @format date */
21
- export declare type Date = string;
20
+ /** @format date-time */
21
+ export declare type Timestamp = string;
22
22
  /**
23
23
  * Unicode codepoint or character of the emoji
24
- * @maxLength 20
24
+ * @maxLength 50
25
25
  * @example "🎉"
26
26
  */
27
27
  export declare type Emoji = string;
@@ -34,7 +34,7 @@ export interface EmojiReaction {
34
34
  /** The users who reacted with this emoji */
35
35
  users: {
36
36
  user: User;
37
- reactedAt: Date;
37
+ reactedAt: Timestamp;
38
38
  }[];
39
39
  }
40
40
  export declare type EmojiReactions = EmojiReaction[];
@@ -151,6 +151,8 @@ export interface RequestImportGitRepository {
151
151
  repoCommitURL?: string;
152
152
  /** Path to a root directory for the project in the repository. */
153
153
  repoProjectDirectory?: string;
154
+ /** The timestamp of the event that triggered this import. It ensures that Git sync import and export operations are executed in the same order on GitBook and on the remote repository. */
155
+ timestamp?: Timestamp;
154
156
  force?: boolean;
155
157
  /** If true, the import will generate a revision without updating the space primary content. */
156
158
  standalone?: boolean;
@@ -172,6 +174,8 @@ export interface RequestExportToGitRepository {
172
174
  repoCommitURL?: string;
173
175
  /** Path to a root directory for the project in the repository. */
174
176
  repoProjectDirectory?: string;
177
+ /** The timestamp of the event that triggered this export. It ensures that Git sync import and export operations are executed in the same order on GitBook and on the remote repository. */
178
+ timestamp?: Timestamp;
175
179
  force?: boolean;
176
180
  /** Optional metadata to store on the space about the Git provider */
177
181
  gitInfo?: RequestUpdateSpaceGitInfo;
@@ -282,7 +286,7 @@ export interface UserAPIToken {
282
286
  /** The API token name. */
283
287
  label: string;
284
288
  /** The API token creation date. */
285
- createdAt: Date;
289
+ createdAt: Timestamp;
286
290
  }
287
291
  /** The API token details, including the token itself. */
288
292
  export declare type UserAPITokenExtended = UserAPIToken & {
@@ -314,7 +318,7 @@ export declare enum ContentVisibility {
314
318
  }
315
319
  /** Contributor towards content. */
316
320
  export interface UserContributor {
317
- updatedAt: Date;
321
+ updatedAt: Timestamp;
318
322
  count: number;
319
323
  user: User;
320
324
  }
@@ -357,9 +361,9 @@ export declare type Comment = {
357
361
  /** The user who posted the comment. */
358
362
  postedBy: User;
359
363
  /** When the comment was posted. */
360
- postedAt: Date;
364
+ postedAt: Timestamp;
361
365
  /** Date when the comment was edited, if it has been edited. */
362
- editedAt?: Date;
366
+ editedAt?: Timestamp;
363
367
  /** Any emoji reactions to the comment. */
364
368
  reactions: EmojiReactions;
365
369
  /** The number of replies to this comment. */
@@ -401,7 +405,7 @@ export declare type Comment = {
401
405
  /** Status of the comment. */
402
406
  status: 'resolved';
403
407
  /** If the comment has been resolved, the date at which it was resolved. If this field is not defined, the comment is not resolved. */
404
- resolvedAt: Date;
408
+ resolvedAt: Timestamp;
405
409
  /** If the comment has been resolved, the user who resolved it. If this field is not defined, the comment is not resolved. */
406
410
  resolvedBy: User;
407
411
  } | {
@@ -414,9 +418,9 @@ export interface CommentReply {
414
418
  /** Unique identifier for the reply. */
415
419
  id: string;
416
420
  postedBy: User;
417
- postedAt: Date;
421
+ postedAt: Timestamp;
418
422
  /** Date when the reply was edited, if it has been edited. */
419
- editedAt?: Date;
423
+ editedAt?: Timestamp;
420
424
  reactions: EmojiReactions;
421
425
  body: Document;
422
426
  /** URLs associated with the object */
@@ -938,7 +942,7 @@ export interface DocumentBlockDivider {
938
942
  isVoid: true;
939
943
  data: object;
940
944
  }
941
- export declare type ContentRef = ContentRefFile | ContentRefURL | ContentRefPage | ContentRefAnchor | ContentRefUser | ContentRefCollection | ContentRefSpace;
945
+ export declare type ContentRef = ContentRefFile | ContentRefURL | ContentRefPage | ContentRefAnchor | ContentRefUser | ContentRefCollection | ContentRefSpace | ContentRefSnippet;
942
946
  export interface ContentRefURL {
943
947
  kind: 'url';
944
948
  url: string;
@@ -973,17 +977,18 @@ export interface ContentRefSpace {
973
977
  kind: 'space';
974
978
  space: string;
975
979
  }
980
+ export interface ContentRefSnippet {
981
+ kind: 'snippet';
982
+ snippet: string;
983
+ organization: string;
984
+ }
976
985
  export interface Space {
977
986
  /** Type of Object, always equals to "space" */
978
987
  object: 'space';
979
988
  /** Unique identifier for the space */
980
989
  id: string;
981
- /**
982
- * Title of the space
983
- * @minLength 0
984
- * @maxLength 100
985
- */
986
- title: string;
990
+ /** Title of the space */
991
+ title: SpaceTitle;
987
992
  /** An emoji for this space. It'll match the emoji shown in the GitBook app. */
988
993
  emoji: Emoji;
989
994
  /**
@@ -996,9 +1001,15 @@ export interface Space {
996
1001
  * * `private`: Authorized members can access the content.
997
1002
  */
998
1003
  visibility: ContentVisibility;
999
- createdAt: Date;
1000
- updatedAt: Date;
1001
- deletedAt?: Date;
1004
+ createdAt: Timestamp;
1005
+ updatedAt: Timestamp;
1006
+ deletedAt?: Timestamp;
1007
+ /**
1008
+ * Determines how a Space can be edited.
1009
+ * * `live`: Users can directly edit the space
1010
+ * * `locked`: All edits are locked for this space.
1011
+ */
1012
+ editMode?: SpaceEditMode;
1002
1013
  /** URLs associated with the object */
1003
1014
  urls: {
1004
1015
  /**
@@ -1021,10 +1032,7 @@ export interface Space {
1021
1032
  * @format uri
1022
1033
  */
1023
1034
  public?: string;
1024
- /**
1025
- * URL of the icon of this space, if defined. Deprecated, prefer using emojis for spaces instead of icons.
1026
- * @deprecated
1027
- */
1035
+ /** URL of the icon of this space, if defined. */
1028
1036
  icon?: URL;
1029
1037
  };
1030
1038
  /** ID of the organization owning this space */
@@ -1032,7 +1040,31 @@ export interface Space {
1032
1040
  /** ID of the parent collection. */
1033
1041
  parent?: string;
1034
1042
  gitSync?: GitSyncState;
1043
+ visitorAuth?: {
1044
+ /** Custom backend for Visitor Authentication */
1045
+ backend: 'custom';
1046
+ } | {
1047
+ /** Integration as backend for Visitor Authentication */
1048
+ backend: 'integration';
1049
+ /** Name of integration being used as the backend for Visitor Authentication */
1050
+ integration: string;
1051
+ };
1052
+ }
1053
+ /**
1054
+ * Determines how a Space can be edited.
1055
+ * * `live`: Users can directly edit the space
1056
+ * * `locked`: All edits are locked for this space.
1057
+ */
1058
+ export declare enum SpaceEditMode {
1059
+ Live = "live",
1060
+ Locked = "locked"
1035
1061
  }
1062
+ /**
1063
+ * Title of the space
1064
+ * @minLength 1
1065
+ * @maxLength 50
1066
+ */
1067
+ export declare type SpaceTitle = string;
1036
1068
  export interface RevisionBase {
1037
1069
  /** Type of Object, always equals to "revision" */
1038
1070
  object: 'revision';
@@ -1042,6 +1074,8 @@ export interface RevisionBase {
1042
1074
  parents: string[];
1043
1075
  pages: RevisionPage[];
1044
1076
  files: RevisionFile[];
1077
+ /** When the revision was created. */
1078
+ createdAt: Timestamp;
1045
1079
  /** Metadata about a potential associated git commit. */
1046
1080
  git?: GitSyncCommit;
1047
1081
  urls: {
@@ -1092,9 +1126,9 @@ export interface RevisionPageBase {
1092
1126
  /** Emoji of the page, if one has been set. */
1093
1127
  emoji?: Emoji;
1094
1128
  /** When the page was first created. Only present if page has been edited at least once. */
1095
- createdAt?: Date;
1129
+ createdAt?: Timestamp;
1096
1130
  /** When the page was last edited. Only present if page has been edited at least once. */
1097
- updatedAt?: Date;
1131
+ updatedAt?: Timestamp;
1098
1132
  }
1099
1133
  export declare type RevisionPageDocument = RevisionPageBase & Document & {
1100
1134
  /** @deprecated */
@@ -1333,7 +1367,7 @@ export interface GitSyncState {
1333
1367
  /** The URL to the repository tree, used when rendering public content. */
1334
1368
  url?: string;
1335
1369
  /** When the Git provider details were last updated */
1336
- updatedAt?: Date;
1370
+ updatedAt?: Timestamp;
1337
1371
  }
1338
1372
  export interface GitSyncOperation {
1339
1373
  /**
@@ -1342,9 +1376,9 @@ export interface GitSyncOperation {
1342
1376
  * * `success`: The operation was successful
1343
1377
  */
1344
1378
  state: GitSyncOperationState;
1345
- startedAt: Date;
1379
+ startedAt?: Timestamp;
1346
1380
  /** Date when the operation was successful (when state is `success`) */
1347
- completedAt?: Date;
1381
+ completedAt?: Timestamp;
1348
1382
  /** Error details, defined if state is `failure`. */
1349
1383
  error?: string;
1350
1384
  }
@@ -1471,9 +1505,9 @@ export interface OrganizationMember {
1471
1505
  /** Whatever the membership of this user is disabled and prevent them from accessing content. */
1472
1506
  disabled: boolean;
1473
1507
  /** Date at which the user joined the organization. */
1474
- joinedAt: Date;
1508
+ joinedAt: Timestamp;
1475
1509
  /** Date at which the user was last seen active in the organization. */
1476
- lastSeenAt?: Date;
1510
+ lastSeenAt?: Timestamp;
1477
1511
  /** Whether the user can login with SSO. */
1478
1512
  sso: boolean;
1479
1513
  spaces: number;
@@ -1491,7 +1525,7 @@ export interface OrganizationTeam {
1491
1525
  /** Count of spaces this team has access to. */
1492
1526
  spaces: number;
1493
1527
  /** Date at which the team was created. */
1494
- createdAt: Date;
1528
+ createdAt: Timestamp;
1495
1529
  }
1496
1530
  /**
1497
1531
  * Title of the team
@@ -1635,6 +1669,8 @@ export interface UpdateCaptureSchema {
1635
1669
  export declare type Snippet = Document & {
1636
1670
  /** Unique identifier for the snippet */
1637
1671
  id: string;
1672
+ /** ID of the organization owning this snippet */
1673
+ organization: string;
1638
1674
  /** @format date-time */
1639
1675
  createdAt: string;
1640
1676
  /**
@@ -1691,7 +1727,7 @@ export interface ContentAuditRelation {
1691
1727
  /** The status of the relation */
1692
1728
  status: ContentAuditRelationStatus;
1693
1729
  /** The date at which the relation was created */
1694
- createdAt: Date;
1730
+ createdAt: Timestamp;
1695
1731
  }
1696
1732
  /** The type of the relation between the sources */
1697
1733
  export declare enum ContentAuditRelationType {
@@ -1730,8 +1766,8 @@ export interface ChangeRequest {
1730
1766
  */
1731
1767
  subject: string;
1732
1768
  createdBy: User;
1733
- createdAt: Date;
1734
- updatedAt: Date;
1769
+ createdAt: Timestamp;
1770
+ updatedAt: Timestamp;
1735
1771
  /** URLs associated with the object */
1736
1772
  urls: {
1737
1773
  /**
@@ -1761,8 +1797,8 @@ export interface ChangeRequestReview {
1761
1797
  /** The status of the review. */
1762
1798
  status: ChangeRequestReviewStatus;
1763
1799
  comment?: Comment;
1764
- createdAt: Date;
1765
- updatedAt: Date;
1800
+ createdAt: Timestamp;
1801
+ updatedAt: Timestamp;
1766
1802
  }
1767
1803
  /** Status of a change request review. */
1768
1804
  export declare enum ChangeRequestReviewStatus {
@@ -1776,7 +1812,7 @@ export declare type ChangeRequestRequestedReviewer = {
1776
1812
  revision: string;
1777
1813
  /** The user who made the request. */
1778
1814
  requestedBy: User;
1779
- createdAt: Date;
1815
+ createdAt: Timestamp;
1780
1816
  } & ({
1781
1817
  kind: 'user';
1782
1818
  /** The user who was requested to review. */
@@ -2155,7 +2191,8 @@ export declare enum IntegrationScope {
2155
2191
  SpaceMetadataWrite = "space:metadata:write",
2156
2192
  SpaceScriptInject = "space:script:inject",
2157
2193
  SpaceScriptCookies = "space:script:cookies",
2158
- SpaceGitSync = "space:git:sync"
2194
+ SpaceGitSync = "space:git:sync",
2195
+ SpaceVisitorAuth = "space:visitor:auth"
2159
2196
  }
2160
2197
  /** Categories for which the integration is listed in the marketplace */
2161
2198
  export declare type IntegrationCategories = IntegrationCategory[];
@@ -2205,7 +2242,7 @@ export interface IntegrationEvent {
2205
2242
  integrationId: string;
2206
2243
  /** Unique ID of the integration installation. */
2207
2244
  installationId?: string;
2208
- createdAt: Date;
2245
+ createdAt: Timestamp;
2209
2246
  /** Any event that can be received from GitBook. */
2210
2247
  payload: Event;
2211
2248
  /** Status of the event. */
@@ -2214,7 +2251,7 @@ export interface IntegrationEvent {
2214
2251
  export interface IntegrationEventLog {
2215
2252
  /** The message of the log entry. */
2216
2253
  message?: string;
2217
- timestamp?: Date;
2254
+ timestamp?: Timestamp;
2218
2255
  /** The level of the log entry. */
2219
2256
  level?: 'debug' | 'info' | 'warn' | 'error';
2220
2257
  }
@@ -2284,8 +2321,8 @@ export interface IntegrationInstallation {
2284
2321
  spaces: number;
2285
2322
  /** Configuration of the integration at the account level */
2286
2323
  configuration: IntegrationInstallationConfiguration;
2287
- createdAt: Date;
2288
- updatedAt: Date;
2324
+ createdAt: Timestamp;
2325
+ updatedAt: Timestamp;
2289
2326
  /** URLs associated with the object */
2290
2327
  urls: {
2291
2328
  /**
@@ -2539,7 +2576,7 @@ export declare type EntityPropertySchema = {
2539
2576
  };
2540
2577
  });
2541
2578
  /** Any event that can be received from GitBook. */
2542
- export declare type Event = InstallationSetupEvent | SpaceInstallationSetupEvent | SpaceInstallationDeletedEvent | SpaceViewEvent | SpaceContentUpdatedEvent | SpaceGitSyncCompletedEvent | SpaceGitSyncStartedEvent | SpaceVisibilityUpdatedEvent | FetchEvent | FetchPublishedScriptEvent | UIRenderEvent;
2579
+ export declare type Event = InstallationSetupEvent | SpaceInstallationSetupEvent | SpaceInstallationDeletedEvent | SpaceViewEvent | SpaceContentUpdatedEvent | SpaceGitSyncCompletedEvent | SpaceGitSyncStartedEvent | SpaceVisibilityUpdatedEvent | FetchEvent | FetchPublishedScriptEvent | FetchVisitorAuthenticationEvent | UIRenderEvent;
2543
2580
  /** Common properties for all events. */
2544
2581
  export interface BaseEvent {
2545
2582
  /** Unique identifier for the event. */
@@ -2680,6 +2717,11 @@ export declare type FetchEvent = BaseEvent & {
2680
2717
  export declare type FetchPublishedScriptEvent = SpaceEvent & {
2681
2718
  type: 'fetch_published_script';
2682
2719
  };
2720
+ /** Common properties for all events related to visitor authentication from an installation */
2721
+ export declare type FetchVisitorAuthenticationEvent = SpaceEvent & {
2722
+ type: 'fetch_visitor_authentication';
2723
+ location?: string;
2724
+ };
2683
2725
  /** Event generated when rendering a UI */
2684
2726
  export declare type UIRenderEvent = (SpaceEvent | InstallationEvent) & {
2685
2727
  auth?: {
@@ -2741,8 +2783,8 @@ export interface BillingInvoicePreview {
2741
2783
  lines: {
2742
2784
  description: string;
2743
2785
  amount: number;
2744
- periodStart: Date;
2745
- periodEnd: Date;
2786
+ periodStart: Timestamp;
2787
+ periodEnd: Timestamp;
2746
2788
  }[];
2747
2789
  }
2748
2790
  export declare enum APIIntegrationScope {
@@ -2848,7 +2890,7 @@ export interface UserImpersonationInfo {
2848
2890
  }
2849
2891
  /** All the permissions of a user */
2850
2892
  export interface UserPermissions {
2851
- updatedAt: Date;
2893
+ updatedAt: Timestamp;
2852
2894
  searchKey: string;
2853
2895
  organizations: Record<string, {
2854
2896
  /** The role of a member in an organization, null for guests */
@@ -3441,8 +3483,8 @@ export interface CustomField {
3441
3483
  type: CustomFieldType;
3442
3484
  placeholder: CustomFieldPlaceholder;
3443
3485
  options?: CustomFieldOptions;
3444
- createdAt: Date;
3445
- updatedAt: Date;
3486
+ createdAt: Timestamp;
3487
+ updatedAt: Timestamp;
3446
3488
  /** URLs associated with the object */
3447
3489
  urls: {
3448
3490
  /**
@@ -3629,7 +3671,7 @@ export interface PageFeedback {
3629
3671
  object: 'page-feedback';
3630
3672
  visitorId: string;
3631
3673
  rating: PageFeedbackRating;
3632
- createdAt: Date;
3674
+ createdAt: Timestamp;
3633
3675
  /** ID of the revision when the rating was created */
3634
3676
  revision: string;
3635
3677
  /** URLs associated with the object */
@@ -3837,6 +3879,14 @@ export declare class Api<SecurityDataType extends unknown> extends HttpClient<Se
3837
3879
  * @secure
3838
3880
  */
3839
3881
  updateSpaceById: (spaceId: string, data: {
3882
+ /**
3883
+ * Determines how a Space can be edited.
3884
+ * * `live`: Users can directly edit the space
3885
+ * * `locked`: All edits are locked for this space.
3886
+ */
3887
+ editMode?: SpaceEditMode;
3888
+ /** Title of the space */
3889
+ title?: SpaceTitle;
3840
3890
  /**
3841
3891
  * * `public`: Anyone can access the content, and the content is indexed by search engines.
3842
3892
  * * `unlisted`: Anyone can access the content, and the content is not indexed by search engines
@@ -3847,7 +3897,17 @@ export declare class Api<SecurityDataType extends unknown> extends HttpClient<Se
3847
3897
  * * `private`: Authorized members can access the content.
3848
3898
  */
3849
3899
  visibility?: ContentVisibility;
3850
- }, params?: RequestParams) => Promise<HttpResponse<Space, Error>>;
3900
+ /** The integration property, if set, is ignored. */
3901
+ visitorAuth?: any;
3902
+ } & ({
3903
+ /** Unicode codepoint or character of the emoji */
3904
+ emoji: Emoji;
3905
+ } | {
3906
+ icon: URL;
3907
+ } | {
3908
+ emoji?: null;
3909
+ icon?: null;
3910
+ }), params?: RequestParams) => Promise<HttpResponse<Space, Error>>;
3851
3911
  /**
3852
3912
  * No description
3853
3913
  *
@@ -6386,6 +6446,8 @@ export declare class Api<SecurityDataType extends unknown> extends HttpClient<Se
6386
6446
  spaceId?: string;
6387
6447
  /** If specified, only locations under the given pageId will be returned. You must specify a spaceId too. If pageId is not specified, GitBook will suggest pages at the top level. */
6388
6448
  pageId?: string;
6449
+ /** If specified, only locations matching the search query will be returned. */
6450
+ search?: string;
6389
6451
  }, params?: RequestParams) => Promise<HttpResponse<List & {
6390
6452
  items: {
6391
6453
  /** If defined and true, this location was suggested by GitBook AI. */
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") {
@@ -63,10 +63,15 @@ __export(src_exports, {
63
63
  RevisionPageLayoutPreset: () => RevisionPageLayoutPreset,
64
64
  RevisionPageType: () => RevisionPageType,
65
65
  RevisionSemanticChangeType: () => RevisionSemanticChangeType,
66
+ SpaceEditMode: () => SpaceEditMode,
66
67
  TeamMemberRole: () => TeamMemberRole
67
68
  });
68
69
  module.exports = __toCommonJS(src_exports);
69
70
 
71
+ // package.json
72
+ var name = "@gitbook/api";
73
+ var version = "0.27.0";
74
+
70
75
  // src/client.ts
71
76
  var ContentVisibility = /* @__PURE__ */ ((ContentVisibility2) => {
72
77
  ContentVisibility2["Public"] = "public";
@@ -77,6 +82,11 @@ var ContentVisibility = /* @__PURE__ */ ((ContentVisibility2) => {
77
82
  ContentVisibility2["Private"] = "private";
78
83
  return ContentVisibility2;
79
84
  })(ContentVisibility || {});
85
+ var SpaceEditMode = /* @__PURE__ */ ((SpaceEditMode2) => {
86
+ SpaceEditMode2["Live"] = "live";
87
+ SpaceEditMode2["Locked"] = "locked";
88
+ return SpaceEditMode2;
89
+ })(SpaceEditMode || {});
80
90
  var RevisionPageLayoutOptionsCoverSize = /* @__PURE__ */ ((RevisionPageLayoutOptionsCoverSize2) => {
81
91
  RevisionPageLayoutOptionsCoverSize2["Hero"] = "hero";
82
92
  RevisionPageLayoutOptionsCoverSize2["Full"] = "full";
@@ -206,6 +216,7 @@ var IntegrationScope = /* @__PURE__ */ ((IntegrationScope2) => {
206
216
  IntegrationScope2["SpaceScriptInject"] = "space:script:inject";
207
217
  IntegrationScope2["SpaceScriptCookies"] = "space:script:cookies";
208
218
  IntegrationScope2["SpaceGitSync"] = "space:git:sync";
219
+ IntegrationScope2["SpaceVisitorAuth"] = "space:visitor:auth";
209
220
  return IntegrationScope2;
210
221
  })(IntegrationScope || {});
211
222
  var IntegrationInstallationSpaceSelection = /* @__PURE__ */ ((IntegrationInstallationSpaceSelection2) => {
@@ -2083,14 +2094,19 @@ var GitBookAPIError = class extends Error {
2083
2094
  var GITBOOK_DEFAULT_ENDPOINT = "https://api.gitbook.com";
2084
2095
  var GitBookAPI = class extends Api {
2085
2096
  constructor(options = {}) {
2086
- const { endpoint = GITBOOK_DEFAULT_ENDPOINT, authToken } = options;
2097
+ const {
2098
+ endpoint = GITBOOK_DEFAULT_ENDPOINT,
2099
+ authToken,
2100
+ userAgent = `${name}/${version}`
2101
+ } = options;
2087
2102
  super({
2088
2103
  baseUrl: `${endpoint}/v1`,
2089
2104
  securityWorker: (securityData) => {
2090
2105
  if (securityData.authToken) {
2091
2106
  return {
2092
2107
  headers: {
2093
- Authorization: `Bearer ${securityData.authToken}`
2108
+ Authorization: `Bearer ${securityData.authToken}`,
2109
+ "User-Agent": userAgent
2094
2110
  }
2095
2111
  };
2096
2112
  }
@@ -2117,6 +2133,7 @@ var GitBookAPI = class extends Api {
2117
2133
  }
2118
2134
  });
2119
2135
  this.endpoint = endpoint;
2136
+ this.userAgent = userAgent;
2120
2137
  this.authToken = authToken;
2121
2138
  this.setSecurityData({ authToken });
2122
2139
  }
@@ -2127,6 +2144,7 @@ var GitBookAPI = class extends Api {
2127
2144
  );
2128
2145
  return new GitBookAPI({
2129
2146
  endpoint: this.endpoint,
2147
+ userAgent: this.userAgent,
2130
2148
  authToken: installationToken.token
2131
2149
  });
2132
2150
  }
@@ -2177,5 +2195,6 @@ var GitBookAPI = class extends Api {
2177
2195
  RevisionPageLayoutPreset,
2178
2196
  RevisionPageType,
2179
2197
  RevisionSemanticChangeType,
2198
+ SpaceEditMode,
2180
2199
  TeamMemberRole
2181
2200
  });
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.27.0";
4
+
1
5
  // src/client.ts
2
6
  var ContentVisibility = /* @__PURE__ */ ((ContentVisibility2) => {
3
7
  ContentVisibility2["Public"] = "public";
@@ -8,6 +12,11 @@ var ContentVisibility = /* @__PURE__ */ ((ContentVisibility2) => {
8
12
  ContentVisibility2["Private"] = "private";
9
13
  return ContentVisibility2;
10
14
  })(ContentVisibility || {});
15
+ var SpaceEditMode = /* @__PURE__ */ ((SpaceEditMode2) => {
16
+ SpaceEditMode2["Live"] = "live";
17
+ SpaceEditMode2["Locked"] = "locked";
18
+ return SpaceEditMode2;
19
+ })(SpaceEditMode || {});
11
20
  var RevisionPageLayoutOptionsCoverSize = /* @__PURE__ */ ((RevisionPageLayoutOptionsCoverSize2) => {
12
21
  RevisionPageLayoutOptionsCoverSize2["Hero"] = "hero";
13
22
  RevisionPageLayoutOptionsCoverSize2["Full"] = "full";
@@ -137,6 +146,7 @@ var IntegrationScope = /* @__PURE__ */ ((IntegrationScope2) => {
137
146
  IntegrationScope2["SpaceScriptInject"] = "space:script:inject";
138
147
  IntegrationScope2["SpaceScriptCookies"] = "space:script:cookies";
139
148
  IntegrationScope2["SpaceGitSync"] = "space:git:sync";
149
+ IntegrationScope2["SpaceVisitorAuth"] = "space:visitor:auth";
140
150
  return IntegrationScope2;
141
151
  })(IntegrationScope || {});
142
152
  var IntegrationInstallationSpaceSelection = /* @__PURE__ */ ((IntegrationInstallationSpaceSelection2) => {
@@ -2014,14 +2024,19 @@ var GitBookAPIError = class extends Error {
2014
2024
  var GITBOOK_DEFAULT_ENDPOINT = "https://api.gitbook.com";
2015
2025
  var GitBookAPI = class extends Api {
2016
2026
  constructor(options = {}) {
2017
- const { endpoint = GITBOOK_DEFAULT_ENDPOINT, authToken } = options;
2027
+ const {
2028
+ endpoint = GITBOOK_DEFAULT_ENDPOINT,
2029
+ authToken,
2030
+ userAgent = `${name}/${version}`
2031
+ } = options;
2018
2032
  super({
2019
2033
  baseUrl: `${endpoint}/v1`,
2020
2034
  securityWorker: (securityData) => {
2021
2035
  if (securityData.authToken) {
2022
2036
  return {
2023
2037
  headers: {
2024
- Authorization: `Bearer ${securityData.authToken}`
2038
+ Authorization: `Bearer ${securityData.authToken}`,
2039
+ "User-Agent": userAgent
2025
2040
  }
2026
2041
  };
2027
2042
  }
@@ -2048,6 +2063,7 @@ var GitBookAPI = class extends Api {
2048
2063
  }
2049
2064
  });
2050
2065
  this.endpoint = endpoint;
2066
+ this.userAgent = userAgent;
2051
2067
  this.authToken = authToken;
2052
2068
  this.setSecurityData({ authToken });
2053
2069
  }
@@ -2058,6 +2074,7 @@ var GitBookAPI = class extends Api {
2058
2074
  );
2059
2075
  return new GitBookAPI({
2060
2076
  endpoint: this.endpoint,
2077
+ userAgent: this.userAgent,
2061
2078
  authToken: installationToken.token
2062
2079
  });
2063
2080
  }
@@ -2107,5 +2124,6 @@ export {
2107
2124
  RevisionPageLayoutPreset,
2108
2125
  RevisionPageType,
2109
2126
  RevisionSemanticChangeType,
2127
+ SpaceEditMode,
2110
2128
  TeamMemberRole
2111
2129
  };
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.25.0",
7
+ "version": "0.27.0",
8
8
  "sideEffects": false,
9
9
  "files": [
10
10
  "README.md",