@gitbook/api 0.0.0 → 0.2.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
@@ -19,27 +19,106 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
19
19
  // src/index.ts
20
20
  var src_exports = {};
21
21
  __export(src_exports, {
22
+ APIIntegrationScope: () => APIIntegrationScope,
23
+ AnalyticsSearchPeriod: () => AnalyticsSearchPeriod,
24
+ AnalyticsTrafficInterval: () => AnalyticsTrafficInterval,
22
25
  Api: () => Api,
26
+ BillingInterval: () => BillingInterval,
27
+ BillingProduct: () => BillingProduct,
28
+ ChangeRequestStatus: () => ChangeRequestStatus,
29
+ CloudflareHostnameStatus: () => CloudflareHostnameStatus,
30
+ CloudflareHostnameTLSStatus: () => CloudflareHostnameTLSStatus,
31
+ CloudflareHostnameTLSValidationMethod: () => CloudflareHostnameTLSValidationMethod,
32
+ ContentKitIcon: () => ContentKitIcon,
23
33
  ContentType: () => ContentType,
34
+ ContentVisibility: () => ContentVisibility,
24
35
  GITBOOK_DEFAULT_ENDPOINT: () => GITBOOK_DEFAULT_ENDPOINT,
25
36
  GitBookAPI: () => GitBookAPI,
26
37
  HttpClient: () => HttpClient,
38
+ ImportContentSource: () => ImportContentSource,
27
39
  IntegrationCategory: () => IntegrationCategory,
40
+ IntegrationInstallationSpaceSelection: () => IntegrationInstallationSpaceSelection,
28
41
  IntegrationInstallationStatus: () => IntegrationInstallationStatus,
29
42
  IntegrationScope: () => IntegrationScope,
30
- IntegrationVisibility: () => IntegrationVisibility
43
+ IntegrationVisibility: () => IntegrationVisibility,
44
+ MemberRole: () => MemberRole,
45
+ PurgeCDNCacheContextType: () => PurgeCDNCacheContextType
31
46
  });
32
47
  module.exports = __toCommonJS(src_exports);
33
48
 
34
49
  // src/client.ts
50
+ var ContentVisibility = /* @__PURE__ */ ((ContentVisibility2) => {
51
+ ContentVisibility2["Public"] = "public";
52
+ ContentVisibility2["Unlisted"] = "unlisted";
53
+ ContentVisibility2["ShareLink"] = "share-link";
54
+ ContentVisibility2["VisitorAuth"] = "visitor-auth";
55
+ ContentVisibility2["InCollection"] = "in-collection";
56
+ ContentVisibility2["Private"] = "private";
57
+ return ContentVisibility2;
58
+ })(ContentVisibility || {});
59
+ var ImportContentSource = /* @__PURE__ */ ((ImportContentSource2) => {
60
+ ImportContentSource2["Website"] = "website";
61
+ ImportContentSource2["Docx"] = "docx";
62
+ ImportContentSource2["Markdown"] = "markdown";
63
+ ImportContentSource2["Html"] = "html";
64
+ ImportContentSource2["Zip"] = "zip";
65
+ ImportContentSource2["Confluence"] = "confluence";
66
+ ImportContentSource2["GithubWiki"] = "github-wiki";
67
+ ImportContentSource2["DropboxPaper"] = "dropbox-paper";
68
+ ImportContentSource2["Notion"] = "notion";
69
+ ImportContentSource2["Quip"] = "quip";
70
+ ImportContentSource2["GoogleDocs"] = "google-docs";
71
+ ImportContentSource2["OpenApi"] = "open-api";
72
+ return ImportContentSource2;
73
+ })(ImportContentSource || {});
74
+ var MemberRole = /* @__PURE__ */ ((MemberRole2) => {
75
+ MemberRole2["Admin"] = "admin";
76
+ MemberRole2["Create"] = "create";
77
+ MemberRole2["Edit"] = "edit";
78
+ MemberRole2["Review"] = "review";
79
+ MemberRole2["Comment"] = "comment";
80
+ MemberRole2["Read"] = "read";
81
+ return MemberRole2;
82
+ })(MemberRole || {});
83
+ var ChangeRequestStatus = /* @__PURE__ */ ((ChangeRequestStatus2) => {
84
+ ChangeRequestStatus2["Draft"] = "draft";
85
+ ChangeRequestStatus2["Open"] = "open";
86
+ ChangeRequestStatus2["Archived"] = "archived";
87
+ ChangeRequestStatus2["Merged"] = "merged";
88
+ return ChangeRequestStatus2;
89
+ })(ChangeRequestStatus || {});
90
+ var AnalyticsSearchPeriod = /* @__PURE__ */ ((AnalyticsSearchPeriod2) => {
91
+ AnalyticsSearchPeriod2["LastMonth"] = "last_month";
92
+ AnalyticsSearchPeriod2["LastWeek"] = "last_week";
93
+ AnalyticsSearchPeriod2["LastYear"] = "last_year";
94
+ return AnalyticsSearchPeriod2;
95
+ })(AnalyticsSearchPeriod || {});
96
+ var AnalyticsTrafficInterval = /* @__PURE__ */ ((AnalyticsTrafficInterval2) => {
97
+ AnalyticsTrafficInterval2["Daily"] = "daily";
98
+ AnalyticsTrafficInterval2["Weekly"] = "weekly";
99
+ AnalyticsTrafficInterval2["Monthly"] = "monthly";
100
+ return AnalyticsTrafficInterval2;
101
+ })(AnalyticsTrafficInterval || {});
35
102
  var IntegrationScope = /* @__PURE__ */ ((IntegrationScope2) => {
36
- IntegrationScope2["SpaceViews"] = "space:views";
37
- IntegrationScope2["SpaceContent"] = "space:content";
103
+ IntegrationScope2["SpaceViewsRead"] = "space:views:read";
104
+ IntegrationScope2["SpaceContentRead"] = "space:content:read";
105
+ IntegrationScope2["SpaceContentWrite"] = "space:content:write";
106
+ IntegrationScope2["SpaceMetadataRead"] = "space:metadata:read";
107
+ IntegrationScope2["SpaceMetadataWrite"] = "space:metadata:write";
108
+ IntegrationScope2["SpaceScriptInject"] = "space:script:inject";
109
+ IntegrationScope2["SpaceScriptCookies"] = "space:script:cookies";
38
110
  return IntegrationScope2;
39
111
  })(IntegrationScope || {});
112
+ var IntegrationInstallationSpaceSelection = /* @__PURE__ */ ((IntegrationInstallationSpaceSelection2) => {
113
+ IntegrationInstallationSpaceSelection2["All"] = "all";
114
+ IntegrationInstallationSpaceSelection2["Selected"] = "selected";
115
+ return IntegrationInstallationSpaceSelection2;
116
+ })(IntegrationInstallationSpaceSelection || {});
40
117
  var IntegrationCategory = /* @__PURE__ */ ((IntegrationCategory2) => {
41
118
  IntegrationCategory2["Analytics"] = "analytics";
42
119
  IntegrationCategory2["Collaboration"] = "collaboration";
120
+ IntegrationCategory2["Marketing"] = "marketing";
121
+ IntegrationCategory2["Content"] = "content";
43
122
  IntegrationCategory2["Other"] = "other";
44
123
  return IntegrationCategory2;
45
124
  })(IntegrationCategory || {});
@@ -54,6 +133,74 @@ var IntegrationInstallationStatus = /* @__PURE__ */ ((IntegrationInstallationSta
54
133
  IntegrationInstallationStatus2["Paused"] = "paused";
55
134
  return IntegrationInstallationStatus2;
56
135
  })(IntegrationInstallationStatus || {});
136
+ var BillingInterval = /* @__PURE__ */ ((BillingInterval2) => {
137
+ BillingInterval2["Monthly"] = "monthly";
138
+ BillingInterval2["Yearly"] = "yearly";
139
+ return BillingInterval2;
140
+ })(BillingInterval || {});
141
+ var BillingProduct = /* @__PURE__ */ ((BillingProduct2) => {
142
+ BillingProduct2["Free"] = "free";
143
+ BillingProduct2["Plus"] = "plus";
144
+ BillingProduct2["Pro"] = "pro";
145
+ BillingProduct2["Team"] = "team";
146
+ BillingProduct2["Business"] = "business";
147
+ BillingProduct2["Legacy"] = "legacy";
148
+ BillingProduct2["Startup"] = "startup";
149
+ BillingProduct2["Enterprise"] = "enterprise";
150
+ return BillingProduct2;
151
+ })(BillingProduct || {});
152
+ var APIIntegrationScope = /* @__PURE__ */ ((APIIntegrationScope2) => {
153
+ APIIntegrationScope2["IntegrationRead"] = "integration:read";
154
+ APIIntegrationScope2["IntegrationUpdate"] = "integration:update";
155
+ APIIntegrationScope2["IntegrationInstallationRead"] = "integration:installation:read";
156
+ APIIntegrationScope2["IntegrationInstallationUpdate"] = "integration:installation:update";
157
+ return APIIntegrationScope2;
158
+ })(APIIntegrationScope || {});
159
+ var CloudflareHostnameStatus = /* @__PURE__ */ ((CloudflareHostnameStatus2) => {
160
+ CloudflareHostnameStatus2["Pending"] = "pending";
161
+ CloudflareHostnameStatus2["Active"] = "active";
162
+ CloudflareHostnameStatus2["Blocked"] = "blocked";
163
+ CloudflareHostnameStatus2["Moved"] = "moved";
164
+ CloudflareHostnameStatus2["Deleted"] = "deleted";
165
+ return CloudflareHostnameStatus2;
166
+ })(CloudflareHostnameStatus || {});
167
+ var CloudflareHostnameTLSStatus = /* @__PURE__ */ ((CloudflareHostnameTLSStatus2) => {
168
+ CloudflareHostnameTLSStatus2["Initializing"] = "initializing";
169
+ CloudflareHostnameTLSStatus2["PendingValidation"] = "pending_validation";
170
+ CloudflareHostnameTLSStatus2["PendingIssuance"] = "pending_issuance";
171
+ CloudflareHostnameTLSStatus2["PendingDeployment"] = "pending_deployment";
172
+ CloudflareHostnameTLSStatus2["Active"] = "active";
173
+ CloudflareHostnameTLSStatus2["PendingDeletion"] = "pending_deletion";
174
+ CloudflareHostnameTLSStatus2["PendingCleanup"] = "pending_cleanup";
175
+ CloudflareHostnameTLSStatus2["Deleted"] = "deleted";
176
+ return CloudflareHostnameTLSStatus2;
177
+ })(CloudflareHostnameTLSStatus || {});
178
+ var CloudflareHostnameTLSValidationMethod = /* @__PURE__ */ ((CloudflareHostnameTLSValidationMethod2) => {
179
+ CloudflareHostnameTLSValidationMethod2["Http"] = "http";
180
+ CloudflareHostnameTLSValidationMethod2["Txt"] = "txt";
181
+ CloudflareHostnameTLSValidationMethod2["Email"] = "email";
182
+ return CloudflareHostnameTLSValidationMethod2;
183
+ })(CloudflareHostnameTLSValidationMethod || {});
184
+ var PurgeCDNCacheContextType = /* @__PURE__ */ ((PurgeCDNCacheContextType2) => {
185
+ PurgeCDNCacheContextType2["Tags"] = "tags";
186
+ PurgeCDNCacheContextType2["Hosts"] = "hosts";
187
+ return PurgeCDNCacheContextType2;
188
+ })(PurgeCDNCacheContextType || {});
189
+ var ContentKitIcon = /* @__PURE__ */ ((ContentKitIcon2) => {
190
+ ContentKitIcon2["Close"] = "close";
191
+ ContentKitIcon2["Edit"] = "edit";
192
+ ContentKitIcon2["Github"] = "github";
193
+ ContentKitIcon2["Maximize"] = "maximize";
194
+ ContentKitIcon2["Email"] = "email";
195
+ ContentKitIcon2["Settings"] = "settings";
196
+ ContentKitIcon2["Search"] = "search";
197
+ ContentKitIcon2["Delete"] = "delete";
198
+ ContentKitIcon2["Star"] = "star";
199
+ ContentKitIcon2["Warning"] = "warning";
200
+ ContentKitIcon2["Link"] = "link";
201
+ ContentKitIcon2["LinkExternal"] = "link-external";
202
+ return ContentKitIcon2;
203
+ })(ContentKitIcon || {});
57
204
  var ContentType = /* @__PURE__ */ ((ContentType2) => {
58
205
  ContentType2["Json"] = "application/json";
59
206
  ContentType2["FormData"] = "multipart/form-data";
@@ -79,7 +226,10 @@ var HttpClient = class {
79
226
  ["application/json" /* Json */]: (input) => input !== null && (typeof input === "object" || typeof input === "string") ? JSON.stringify(input) : input,
80
227
  ["multipart/form-data" /* FormData */]: (input) => Object.keys(input || {}).reduce((formData, key) => {
81
228
  const property = input[key];
82
- formData.append(key, property instanceof Blob ? property : typeof property === "object" && property !== null ? JSON.stringify(property) : `${property}`);
229
+ formData.append(
230
+ key,
231
+ property instanceof Blob ? property : typeof property === "object" && property !== null ? JSON.stringify(property) : `${property}`
232
+ );
83
233
  return formData;
84
234
  }, new FormData()),
85
235
  ["application/x-www-form-urlencoded" /* UrlEncoded */]: (input) => this.toQueryString(input)
@@ -119,15 +269,18 @@ var HttpClient = class {
119
269
  const queryString = query && this.toQueryString(query);
120
270
  const payloadFormatter = this.contentFormatters[type || "application/json" /* Json */];
121
271
  const responseFormat = format || requestParams.format;
122
- return this.customFetch(`${baseUrl || this.baseUrl || ""}${path}${queryString ? `?${queryString}` : ""}`, {
123
- ...requestParams,
124
- headers: {
125
- ...type && type !== "multipart/form-data" /* FormData */ ? { "Content-Type": type } : {},
126
- ...requestParams.headers || {}
127
- },
128
- signal: cancelToken ? this.createAbortSignal(cancelToken) : void 0,
129
- body: typeof body === "undefined" || body === null ? null : payloadFormatter(body)
130
- }).then(async (response) => {
272
+ return this.customFetch(
273
+ `${baseUrl || this.baseUrl || ""}${path}${queryString ? `?${queryString}` : ""}`,
274
+ {
275
+ ...requestParams,
276
+ headers: {
277
+ ...type && type !== "multipart/form-data" /* FormData */ ? { "Content-Type": type } : {},
278
+ ...requestParams.headers || {}
279
+ },
280
+ signal: cancelToken ? this.createAbortSignal(cancelToken) : void 0,
281
+ body: typeof body === "undefined" || body === null ? null : payloadFormatter(body)
282
+ }
283
+ ).then(async (response) => {
131
284
  const r = response;
132
285
  r.data = null;
133
286
  r.error = null;
@@ -154,7 +307,9 @@ var HttpClient = class {
154
307
  }
155
308
  encodeQueryParam(key, value) {
156
309
  const encodedKey = encodeURIComponent(key);
157
- return `${encodedKey}=${encodeURIComponent(typeof value === "number" ? value : `${value}`)}`;
310
+ return `${encodedKey}=${encodeURIComponent(
311
+ typeof value === "number" ? value : `${value}`
312
+ )}`;
158
313
  }
159
314
  addQueryParam(query, key) {
160
315
  return this.encodeQueryParam(key, query[key]);
@@ -165,8 +320,10 @@ var HttpClient = class {
165
320
  }
166
321
  toQueryString(rawQuery) {
167
322
  const query = rawQuery || {};
168
- const keys = Object.keys(query).filter((key) => typeof query[key] !== "undefined");
169
- return keys.map((key) => Array.isArray(query[key]) ? this.addArrayQueryParam(query, key) : this.addQueryParam(query, key)).join("&");
323
+ const keys = Object.keys(query).filter((key) => "undefined" !== typeof query[key]);
324
+ return keys.map(
325
+ (key) => Array.isArray(query[key]) ? this.addArrayQueryParam(query, key) : this.addQueryParam(query, key)
326
+ ).join("&");
170
327
  }
171
328
  addQueryParams(rawQuery) {
172
329
  const queryString = this.toQueryString(rawQuery);
@@ -188,34 +345,328 @@ var HttpClient = class {
188
345
  var Api = class extends HttpClient {
189
346
  constructor() {
190
347
  super(...arguments);
348
+ this.getApiInformation = (params = {}) => this.request({
349
+ path: `/`,
350
+ method: "GET",
351
+ secure: true,
352
+ format: "json",
353
+ ...params
354
+ });
355
+ this.search = {
356
+ searchContent: (query, params = {}) => this.request({
357
+ path: `/search`,
358
+ method: "GET",
359
+ query,
360
+ secure: true,
361
+ format: "json",
362
+ ...params
363
+ }),
364
+ askQuery: (query, params = {}) => this.request({
365
+ path: `/search/ask`,
366
+ method: "GET",
367
+ query,
368
+ secure: true,
369
+ format: "json",
370
+ ...params
371
+ })
372
+ };
191
373
  this.user = {
192
- getAuthenticated: (params = {}) => this.request({
374
+ getAuthenticatedUser: (params = {}) => this.request({
193
375
  path: `/user`,
194
376
  method: "GET",
195
377
  secure: true,
196
378
  format: "json",
197
379
  ...params
380
+ }),
381
+ listSpacesForAuthenticatedUser: (query, params = {}) => this.request({
382
+ path: `/user/spaces`,
383
+ method: "GET",
384
+ query,
385
+ secure: true,
386
+ format: "json",
387
+ ...params
388
+ })
389
+ };
390
+ this.users = {
391
+ getUserById: (userId, params = {}) => this.request({
392
+ path: `/users/${userId}`,
393
+ method: "GET",
394
+ secure: true,
395
+ format: "json",
396
+ ...params
198
397
  })
199
398
  };
200
399
  this.spaces = {
201
- getSpace: (spaceId, params = {}) => this.request({
400
+ getSpaceById: (spaceId, params = {}) => this.request({
202
401
  path: `/spaces/${spaceId}`,
203
402
  method: "GET",
204
403
  secure: true,
205
404
  format: "json",
206
405
  ...params
207
406
  }),
208
- trackPageView: (spaceId, data, params = {}) => this.request({
209
- path: `/spaces/${spaceId}/views`,
407
+ searchSpaceContent: (spaceId, query, params = {}) => this.request({
408
+ path: `/spaces/${spaceId}/search`,
409
+ method: "GET",
410
+ query,
411
+ secure: true,
412
+ format: "json",
413
+ ...params
414
+ }),
415
+ askQueryInSpace: (spaceId, query, params = {}) => this.request({
416
+ path: `/spaces/${spaceId}/search/ask`,
417
+ method: "GET",
418
+ query,
419
+ secure: true,
420
+ format: "json",
421
+ ...params
422
+ }),
423
+ importGitRepository: (spaceId, data, params = {}) => this.request({
424
+ path: `/spaces/${spaceId}/git/import`,
425
+ method: "POST",
426
+ body: data,
427
+ secure: true,
428
+ type: "application/json" /* Json */,
429
+ ...params
430
+ }),
431
+ exportToGitRepository: (spaceId, data, params = {}) => this.request({
432
+ path: `/spaces/${spaceId}/git/export`,
433
+ method: "POST",
434
+ body: data,
435
+ secure: true,
436
+ type: "application/json" /* Json */,
437
+ ...params
438
+ }),
439
+ getContentAnalyticsForSpaceById: (spaceId, params = {}) => this.request({
440
+ path: `/spaces/${spaceId}/insights/content`,
441
+ method: "GET",
442
+ secure: true,
443
+ format: "json",
444
+ ...params
445
+ }),
446
+ getSearchAnalyticsForSpaceById: (spaceId, query, params = {}) => this.request({
447
+ path: `/spaces/${spaceId}/insights/search`,
448
+ method: "GET",
449
+ query,
450
+ secure: true,
451
+ format: "json",
452
+ ...params
453
+ }),
454
+ getTrafficAnalyticsForSpaceById: (spaceId, query, params = {}) => this.request({
455
+ path: `/spaces/${spaceId}/insights/traffic`,
456
+ method: "GET",
457
+ query,
458
+ secure: true,
459
+ format: "json",
460
+ ...params
461
+ }),
462
+ trackViewInSpaceById: (spaceId, data, params = {}) => this.request({
463
+ path: `/spaces/${spaceId}/insights/track_view`,
464
+ method: "POST",
465
+ body: data,
466
+ secure: true,
467
+ type: "application/json" /* Json */,
468
+ ...params
469
+ }),
470
+ getCurrentRevision: (spaceId, params = {}) => this.request({
471
+ path: `/spaces/${spaceId}/content`,
472
+ method: "GET",
473
+ secure: true,
474
+ format: "json",
475
+ ...params
476
+ }),
477
+ importContent: (spaceId, data, params = {}) => this.request({
478
+ path: `/spaces/${spaceId}/content/import`,
479
+ method: "POST",
480
+ body: data,
481
+ secure: true,
482
+ type: "application/json" /* Json */,
483
+ format: "json",
484
+ ...params
485
+ }),
486
+ listFiles: (spaceId, query, params = {}) => this.request({
487
+ path: `/spaces/${spaceId}/content/files`,
488
+ method: "GET",
489
+ query,
490
+ secure: true,
491
+ ...params
492
+ }),
493
+ getPageById: (spaceId, pageId, query, params = {}) => this.request({
494
+ path: `/spaces/${spaceId}/content/page/${pageId}`,
495
+ method: "GET",
496
+ query,
497
+ secure: true,
498
+ format: "json",
499
+ ...params
500
+ }),
501
+ importContentInPageById: (spaceId, pageId, data, params = {}) => this.request({
502
+ path: `/spaces/${spaceId}/content/page/${pageId}/import`,
503
+ method: "POST",
504
+ body: data,
505
+ secure: true,
506
+ type: "application/json" /* Json */,
507
+ format: "json",
508
+ ...params
509
+ }),
510
+ getPageByPath: (spaceId, pagePath, query, params = {}) => this.request({
511
+ path: `/spaces/${spaceId}/content/path/${pagePath}`,
512
+ method: "GET",
513
+ query,
514
+ secure: true,
515
+ format: "json",
516
+ ...params
517
+ }),
518
+ createChangeRequest: (spaceId, data, params = {}) => this.request({
519
+ path: `/spaces/${spaceId}/change-requests`,
520
+ method: "POST",
521
+ body: data,
522
+ secure: true,
523
+ type: "application/json" /* Json */,
524
+ format: "json",
525
+ ...params
526
+ }),
527
+ mergeChangeRequest: (spaceId, changeRequestId, params = {}) => this.request({
528
+ path: `/spaces/${spaceId}/change-requests/${changeRequestId}/merge`,
529
+ method: "POST",
530
+ secure: true,
531
+ format: "json",
532
+ ...params
533
+ }),
534
+ updateChangeRequest: (spaceId, changeRequestId, params = {}) => this.request({
535
+ path: `/spaces/${spaceId}/change-requests/${changeRequestId}/update`,
536
+ method: "POST",
537
+ secure: true,
538
+ format: "json",
539
+ ...params
540
+ }),
541
+ getRevisionOfChangeRequestById: (spaceId, changeRequestId, params = {}) => this.request({
542
+ path: `/spaces/${spaceId}/change-requests/${changeRequestId}/content`,
543
+ method: "GET",
544
+ secure: true,
545
+ format: "json",
546
+ ...params
547
+ }),
548
+ importContentInChangeRequest: (spaceId, changeRequestId, data, params = {}) => this.request({
549
+ path: `/spaces/${spaceId}/change-requests/${changeRequestId}/content/import`,
550
+ method: "POST",
551
+ body: data,
552
+ secure: true,
553
+ type: "application/json" /* Json */,
554
+ format: "json",
555
+ ...params
556
+ }),
557
+ listFilesInChangeRequestById: (spaceId, changeRequestId, query, params = {}) => this.request({
558
+ path: `/spaces/${spaceId}/change-requests/${changeRequestId}/content/files`,
559
+ method: "GET",
560
+ query,
561
+ secure: true,
562
+ ...params
563
+ }),
564
+ getPageInChangeRequestById: (spaceId, changeRequestId, pageId, query, params = {}) => this.request({
565
+ path: `/spaces/${spaceId}/change-requests/${changeRequestId}/content/page/${pageId}`,
566
+ method: "GET",
567
+ query,
568
+ secure: true,
569
+ format: "json",
570
+ ...params
571
+ }),
572
+ importContentInChangeRequestPageById: (spaceId, changeRequestId, pageId, data, params = {}) => this.request({
573
+ path: `/spaces/${spaceId}/change-requests/${changeRequestId}/content/page/${pageId}/import`,
210
574
  method: "POST",
211
575
  body: data,
212
576
  secure: true,
213
577
  type: "application/json" /* Json */,
578
+ format: "json",
579
+ ...params
580
+ }),
581
+ getPageInChangeRequestByPath: (spaceId, changeRequestId, pagePath, query, params = {}) => this.request({
582
+ path: `/spaces/${spaceId}/change-requests/${changeRequestId}/content/path/${pagePath}`,
583
+ method: "GET",
584
+ query,
585
+ secure: true,
586
+ format: "json",
587
+ ...params
588
+ }),
589
+ getRevisionById: (spaceId, revisionId, params = {}) => this.request({
590
+ path: `/spaces/${spaceId}/revisions/${revisionId}`,
591
+ method: "GET",
592
+ secure: true,
593
+ format: "json",
594
+ ...params
595
+ }),
596
+ listFilesInRevisionById: (spaceId, revisionId, query, params = {}) => this.request({
597
+ path: `/spaces/${spaceId}/revisions/${revisionId}/files`,
598
+ method: "GET",
599
+ query,
600
+ secure: true,
601
+ ...params
602
+ }),
603
+ getPageInRevisionById: (spaceId, revisionId, pageId, query, params = {}) => this.request({
604
+ path: `/spaces/${spaceId}/revisions/${revisionId}/page/${pageId}`,
605
+ method: "GET",
606
+ query,
607
+ secure: true,
608
+ format: "json",
609
+ ...params
610
+ }),
611
+ getPageInRevisionByPath: (spaceId, revisionId, pagePath, query, params = {}) => this.request({
612
+ path: `/spaces/${spaceId}/revisions/${revisionId}/path/${pagePath}`,
613
+ method: "GET",
614
+ query,
615
+ secure: true,
616
+ format: "json",
617
+ ...params
618
+ }),
619
+ listPermissionsAggregateInSpace: (spaceId, query, params = {}) => this.request({
620
+ path: `/spaces/${spaceId}/permissions/aggregate`,
621
+ method: "GET",
622
+ query,
623
+ secure: true,
624
+ format: "json",
625
+ ...params
626
+ })
627
+ };
628
+ this.collections = {
629
+ getCollectionById: (collectionId, params = {}) => this.request({
630
+ path: `/collections/${collectionId}`,
631
+ method: "GET",
632
+ secure: true,
633
+ format: "json",
634
+ ...params
635
+ }),
636
+ listSpacesInCollectionById: (collectionId, query, params = {}) => this.request({
637
+ path: `/collections/${collectionId}/spaces`,
638
+ method: "GET",
639
+ query,
640
+ secure: true,
641
+ format: "json",
642
+ ...params
643
+ }),
644
+ listPermissionsAggregateInCollection: (collectionId, query, params = {}) => this.request({
645
+ path: `/collections/${collectionId}/permissions/aggregate`,
646
+ method: "GET",
647
+ query,
648
+ secure: true,
649
+ format: "json",
214
650
  ...params
215
651
  })
216
652
  };
217
653
  this.integrations = {
218
- publish: (integrationName, data, params = {}) => this.request({
654
+ listIntegrations: (query, params = {}) => this.request({
655
+ path: `/integrations`,
656
+ method: "GET",
657
+ query,
658
+ secure: true,
659
+ format: "json",
660
+ ...params
661
+ }),
662
+ getIntegrationByName: (integrationName, params = {}) => this.request({
663
+ path: `/integrations/${integrationName}`,
664
+ method: "GET",
665
+ secure: true,
666
+ format: "json",
667
+ ...params
668
+ }),
669
+ publishIntegration: (integrationName, data, params = {}) => this.request({
219
670
  path: `/integrations/${integrationName}`,
220
671
  method: "POST",
221
672
  body: data,
@@ -224,19 +675,294 @@ var Api = class extends HttpClient {
224
675
  format: "json",
225
676
  ...params
226
677
  }),
227
- getInstallation: (integrationName, installationId, params = {}) => this.request({
228
- path: `/integrations/${integrationName}/installations/${installationId}`,
678
+ unpublishIntegration: (integrationName, params = {}) => this.request({
679
+ path: `/integrations/${integrationName}`,
680
+ method: "DELETE",
681
+ secure: true,
682
+ ...params
683
+ }),
684
+ listIntegrationInstallations: (integrationName, query, params = {}) => this.request({
685
+ path: `/integrations/${integrationName}/installations`,
686
+ method: "GET",
687
+ query,
688
+ secure: true,
689
+ format: "json",
690
+ ...params
691
+ }),
692
+ listIntegrationSpaceInstallations: (integrationName, query, params = {}) => this.request({
693
+ path: `/integrations/${integrationName}/spaces`,
694
+ method: "GET",
695
+ query,
696
+ secure: true,
697
+ format: "json",
698
+ ...params
699
+ }),
700
+ renderIntegrationUiWithGet: (integrationName, query, params = {}) => this.request({
701
+ path: `/integrations/${integrationName}/render`,
229
702
  method: "GET",
703
+ query,
230
704
  secure: true,
231
705
  format: "json",
232
706
  ...params
233
707
  }),
234
- updateInstallation: (integrationName, installationId, data, params = {}) => this.request({
708
+ renderIntegrationUiWithPost: (integrationName, data, params = {}) => this.request({
709
+ path: `/integrations/${integrationName}/render`,
710
+ method: "POST",
711
+ body: data,
712
+ secure: true,
713
+ type: "application/json" /* Json */,
714
+ format: "json",
715
+ ...params
716
+ }),
717
+ updateIntegrationInstallation: (integrationName, installationId, data, params = {}) => this.request({
235
718
  path: `/integrations/${integrationName}/installations/${installationId}`,
236
719
  method: "PATCH",
237
720
  body: data,
238
721
  secure: true,
239
722
  type: "application/json" /* Json */,
723
+ format: "json",
724
+ ...params
725
+ }),
726
+ createIntegrationInstallationToken: (integrationName, installationId, params = {}) => this.request({
727
+ path: `/integrations/${integrationName}/installations/${installationId}/tokens`,
728
+ method: "POST",
729
+ secure: true,
730
+ format: "json",
731
+ ...params
732
+ }),
733
+ updateIntegrationSpaceInstallation: (integrationName, installationId, spaceId, data, params = {}) => this.request({
734
+ path: `/integrations/${integrationName}/installations/${installationId}/spaces/${spaceId}`,
735
+ method: "PATCH",
736
+ body: data,
737
+ secure: true,
738
+ type: "application/json" /* Json */,
739
+ format: "json",
740
+ ...params
741
+ })
742
+ };
743
+ this.orgs = {
744
+ listOrganizationsForAuthenticatedUser: (query, params = {}) => this.request({
745
+ path: `/orgs`,
746
+ method: "GET",
747
+ query,
748
+ secure: true,
749
+ format: "json",
750
+ ...params
751
+ }),
752
+ listMembersInOrganizationById: (organizationId, query, params = {}) => this.request({
753
+ path: `/orgs/${organizationId}/members`,
754
+ method: "GET",
755
+ query,
756
+ secure: true,
757
+ format: "json",
758
+ ...params
759
+ }),
760
+ getMemberInOrganizationById: (organizationId, userId, params = {}) => this.request({
761
+ path: `/orgs/${organizationId}/members/${userId}`,
762
+ method: "GET",
763
+ secure: true,
764
+ format: "json",
765
+ ...params
766
+ }),
767
+ updateMemberInOrganizationById: (organizationId, userId, data, params = {}) => this.request({
768
+ path: `/orgs/${organizationId}/members/${userId}`,
769
+ method: "PATCH",
770
+ body: data,
771
+ secure: true,
772
+ type: "application/json" /* Json */,
773
+ format: "json",
774
+ ...params
775
+ }),
776
+ removeMemberFromOrganizationById: (organizationId, userId, params = {}) => this.request({
777
+ path: `/orgs/${organizationId}/members/${userId}`,
778
+ method: "DELETE",
779
+ secure: true,
780
+ ...params
781
+ }),
782
+ setUserAsSsoMemberForOrganization: (organizationId, userId, params = {}) => this.request({
783
+ path: `/orgs/${organizationId}/members/${userId}/sso`,
784
+ method: "POST",
785
+ secure: true,
786
+ ...params
787
+ }),
788
+ listSpacesForOrganizationMember: (organizationId, userId, query, params = {}) => this.request({
789
+ path: `/orgs/${organizationId}/members/${userId}/spaces`,
790
+ method: "GET",
791
+ query,
792
+ secure: true,
793
+ format: "json",
794
+ ...params
795
+ }),
796
+ listTeamsInOrganizationById: (organizationId, query, params = {}) => this.request({
797
+ path: `/orgs/${organizationId}/teams`,
798
+ method: "GET",
799
+ query,
800
+ secure: true,
801
+ format: "json",
802
+ ...params
803
+ }),
804
+ createOrganizationTeam: (organizationId, data, params = {}) => this.request({
805
+ path: `/orgs/${organizationId}/teams`,
806
+ method: "PUT",
807
+ body: data,
808
+ secure: true,
809
+ type: "application/json" /* Json */,
810
+ format: "json",
811
+ ...params
812
+ }),
813
+ getTeamInOrganizationById: (organizationId, teamId, params = {}) => this.request({
814
+ path: `/orgs/${organizationId}/teams/${teamId}`,
815
+ method: "GET",
816
+ secure: true,
817
+ format: "json",
818
+ ...params
819
+ }),
820
+ updateTeamInOrganizationById: (organizationId, teamId, data, params = {}) => this.request({
821
+ path: `/orgs/${organizationId}/teams/${teamId}`,
822
+ method: "PATCH",
823
+ body: data,
824
+ secure: true,
825
+ type: "application/json" /* Json */,
826
+ format: "json",
827
+ ...params
828
+ }),
829
+ removeTeamFromOrganizationById: (organizationId, teamId, params = {}) => this.request({
830
+ path: `/orgs/${organizationId}/teams/${teamId}`,
831
+ method: "DELETE",
832
+ secure: true,
833
+ ...params
834
+ }),
835
+ updateMembersInOrganizationTeam: (organizationId, teamId, data, params = {}) => this.request({
836
+ path: `/orgs/${organizationId}/teams/${teamId}/members`,
837
+ method: "PUT",
838
+ body: data,
839
+ secure: true,
840
+ type: "application/json" /* Json */,
841
+ ...params
842
+ }),
843
+ listTeamMembersInOrganizationById: (organizationId, teamId, query, params = {}) => this.request({
844
+ path: `/orgs/${organizationId}/teams/${teamId}/members`,
845
+ method: "GET",
846
+ query,
847
+ secure: true,
848
+ format: "json",
849
+ ...params
850
+ }),
851
+ addMemberToOrganizationTeamById: (organizationId, teamId, userId, params = {}) => this.request({
852
+ path: `/orgs/${organizationId}/teams/${teamId}/members/${userId}`,
853
+ method: "PUT",
854
+ secure: true,
855
+ ...params
856
+ }),
857
+ deleteMemberFromOrganizationTeamById: (organizationId, teamId, userId, params = {}) => this.request({
858
+ path: `/orgs/${organizationId}/teams/${teamId}/members/${userId}`,
859
+ method: "DELETE",
860
+ secure: true,
861
+ ...params
862
+ }),
863
+ inviteUsersToOrganization: (organizationId, data, params = {}) => this.request({
864
+ path: `/orgs/${organizationId}/invites`,
865
+ method: "POST",
866
+ body: data,
867
+ secure: true,
868
+ type: "application/json" /* Json */,
869
+ format: "json",
870
+ ...params
871
+ }),
872
+ joinOrganizationWithInvite: (organizationId, inviteId, params = {}) => this.request({
873
+ path: `/orgs/${organizationId}/invites/${inviteId}`,
874
+ method: "POST",
875
+ secure: true,
876
+ format: "json",
877
+ ...params
878
+ }),
879
+ upgradeOrganizationPlan: (organizationId, data, params = {}) => this.request({
880
+ path: `/orgs/${organizationId}/billing`,
881
+ method: "POST",
882
+ body: data,
883
+ secure: true,
884
+ type: "application/json" /* Json */,
885
+ format: "json",
886
+ ...params
887
+ }),
888
+ getOrganizationBillingPortal: (organizationId, params = {}) => this.request({
889
+ path: `/orgs/${organizationId}/billing`,
890
+ method: "GET",
891
+ secure: true,
892
+ format: "json",
893
+ ...params
894
+ }),
895
+ requestOrganizationUpgrade: (organizationId, params = {}) => this.request({
896
+ path: `/orgs/${organizationId}/request_upgrade`,
897
+ method: "POST",
898
+ secure: true,
899
+ format: "json",
900
+ ...params
901
+ }),
902
+ transferOrganization: (organizationId, data, params = {}) => this.request({
903
+ path: `/orgs/${organizationId}/transfer`,
904
+ method: "POST",
905
+ body: data,
906
+ secure: true,
907
+ type: "application/json" /* Json */,
908
+ format: "json",
909
+ ...params
910
+ }),
911
+ searchOrganizationContent: (organizationId, query, params = {}) => this.request({
912
+ path: `/orgs/${organizationId}/search`,
913
+ method: "GET",
914
+ query,
915
+ secure: true,
916
+ format: "json",
917
+ ...params
918
+ }),
919
+ listSpacesInOrganizationById: (organizationId, query, params = {}) => this.request({
920
+ path: `/orgs/${organizationId}/spaces`,
921
+ method: "GET",
922
+ query,
923
+ secure: true,
924
+ format: "json",
925
+ ...params
926
+ }),
927
+ listCollectionsInOrganizationById: (organizationId, query, params = {}) => this.request({
928
+ path: `/orgs/${organizationId}/collections`,
929
+ method: "GET",
930
+ query,
931
+ secure: true,
932
+ format: "json",
933
+ ...params
934
+ }),
935
+ setupDirectorySync: (organizationId, params = {}) => this.request({
936
+ path: `/orgs/${organizationId}/dsync`,
937
+ method: "POST",
938
+ secure: true,
939
+ format: "json",
940
+ ...params
941
+ }),
942
+ listDirectorySyncGroups: (organizationId, params = {}) => this.request({
943
+ path: `/orgs/${organizationId}/dsync/groups`,
944
+ method: "GET",
945
+ secure: true,
946
+ format: "json",
947
+ ...params
948
+ }),
949
+ syncDirectorySyncGroupsToTeams: (organizationId, data, params = {}) => this.request({
950
+ path: `/orgs/${organizationId}/dsync/teams`,
951
+ method: "POST",
952
+ body: data,
953
+ secure: true,
954
+ type: "application/json" /* Json */,
955
+ format: "json",
956
+ ...params
957
+ })
958
+ };
959
+ this.urls = {
960
+ getContentByUrl: (query, params = {}) => this.request({
961
+ path: `/urls/content`,
962
+ method: "GET",
963
+ query,
964
+ secure: true,
965
+ format: "json",
240
966
  ...params
241
967
  })
242
968
  };
@@ -245,12 +971,6 @@ var Api = class extends HttpClient {
245
971
 
246
972
  // src/index.ts
247
973
  var GITBOOK_DEFAULT_ENDPOINT = "https://api.gitbook.com";
248
- var GitBookAPIError = class extends Error {
249
- constructor(response) {
250
- super(response.error?.error.message || "Unknown error");
251
- this.response = response;
252
- }
253
- };
254
974
  var GitBookAPI = class extends Api {
255
975
  constructor(options = {}) {
256
976
  const { endpoint = GITBOOK_DEFAULT_ENDPOINT, authToken } = options;
@@ -265,32 +985,70 @@ var GitBookAPI = class extends Api {
265
985
  };
266
986
  }
267
987
  return {};
268
- }
269
- });
270
- const request = this.request;
271
- this.request = async (...args) => {
272
- try {
273
- const response = await request(...args);
274
- return response;
275
- } catch (error) {
276
- if (error instanceof Error) {
277
- throw error;
988
+ },
989
+ customFetch: async (input, init) => {
990
+ if ("credentials" in init) {
991
+ delete init.credentials;
992
+ }
993
+ if ("referrerPolicy" in init) {
994
+ delete init.referrerPolicy;
995
+ }
996
+ const response = await fetch(input, init);
997
+ if (!response.ok) {
998
+ let error = response.statusText;
999
+ try {
1000
+ const body = await response.json();
1001
+ error = body?.error?.message || error;
1002
+ } catch (err) {
1003
+ response.headers.forEach((value, key) => {
1004
+ error += `${key}:${value} `;
1005
+ });
1006
+ }
1007
+ throw new Error(
1008
+ `GitBook API failed with [${response.status}] ${response.url}: ${error}`
1009
+ );
278
1010
  }
279
- throw new GitBookAPIError(error);
1011
+ return response;
280
1012
  }
281
- };
1013
+ });
1014
+ this.endpoint = endpoint;
282
1015
  this.setSecurityData({ authToken });
283
1016
  }
1017
+ async createInstallationClient(integrationName, installationId) {
1018
+ const { data: installationToken } = await this.integrations.createIntegrationInstallationToken(
1019
+ integrationName,
1020
+ installationId
1021
+ );
1022
+ return new GitBookAPI({
1023
+ endpoint: this.endpoint,
1024
+ authToken: installationToken.token
1025
+ });
1026
+ }
284
1027
  };
285
1028
  // Annotate the CommonJS export names for ESM import in node:
286
1029
  0 && (module.exports = {
1030
+ APIIntegrationScope,
1031
+ AnalyticsSearchPeriod,
1032
+ AnalyticsTrafficInterval,
287
1033
  Api,
1034
+ BillingInterval,
1035
+ BillingProduct,
1036
+ ChangeRequestStatus,
1037
+ CloudflareHostnameStatus,
1038
+ CloudflareHostnameTLSStatus,
1039
+ CloudflareHostnameTLSValidationMethod,
1040
+ ContentKitIcon,
288
1041
  ContentType,
1042
+ ContentVisibility,
289
1043
  GITBOOK_DEFAULT_ENDPOINT,
290
1044
  GitBookAPI,
291
1045
  HttpClient,
1046
+ ImportContentSource,
292
1047
  IntegrationCategory,
1048
+ IntegrationInstallationSpaceSelection,
293
1049
  IntegrationInstallationStatus,
294
1050
  IntegrationScope,
295
- IntegrationVisibility
1051
+ IntegrationVisibility,
1052
+ MemberRole,
1053
+ PurgeCDNCacheContextType
296
1054
  });