@gitbook/api 0.0.0 → 0.1.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`,
210
464
  method: "POST",
211
465
  body: data,
212
466
  secure: true,
213
467
  type: "application/json" /* Json */,
214
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`,
574
+ method: "POST",
575
+ body: data,
576
+ secure: true,
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",
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,286 @@ 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`,
229
686
  method: "GET",
687
+ query,
230
688
  secure: true,
231
689
  format: "json",
232
690
  ...params
233
691
  }),
234
- updateInstallation: (integrationName, installationId, data, params = {}) => this.request({
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`,
702
+ method: "GET",
703
+ query,
704
+ secure: true,
705
+ format: "json",
706
+ ...params
707
+ }),
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
+ listTeamsInOrganizationById: (organizationId, query, params = {}) => this.request({
789
+ path: `/orgs/${organizationId}/teams`,
790
+ method: "GET",
791
+ query,
792
+ secure: true,
793
+ format: "json",
794
+ ...params
795
+ }),
796
+ createOrganizationTeam: (organizationId, data, params = {}) => this.request({
797
+ path: `/orgs/${organizationId}/teams`,
798
+ method: "PUT",
799
+ body: data,
800
+ secure: true,
801
+ type: "application/json" /* Json */,
802
+ format: "json",
803
+ ...params
804
+ }),
805
+ getTeamInOrganizationById: (organizationId, teamId, params = {}) => this.request({
806
+ path: `/orgs/${organizationId}/teams/${teamId}`,
807
+ method: "GET",
808
+ secure: true,
809
+ format: "json",
810
+ ...params
811
+ }),
812
+ updateTeamInOrganizationById: (organizationId, teamId, data, params = {}) => this.request({
813
+ path: `/orgs/${organizationId}/teams/${teamId}`,
814
+ method: "PATCH",
815
+ body: data,
816
+ secure: true,
817
+ type: "application/json" /* Json */,
818
+ format: "json",
819
+ ...params
820
+ }),
821
+ removeTeamFromOrganizationById: (organizationId, teamId, params = {}) => this.request({
822
+ path: `/orgs/${organizationId}/teams/${teamId}`,
823
+ method: "DELETE",
824
+ secure: true,
825
+ ...params
826
+ }),
827
+ updateMembersInOrganizationTeam: (organizationId, teamId, data, params = {}) => this.request({
828
+ path: `/orgs/${organizationId}/teams/${teamId}/members`,
829
+ method: "PUT",
830
+ body: data,
831
+ secure: true,
832
+ type: "application/json" /* Json */,
833
+ ...params
834
+ }),
835
+ listTeamMembersInOrganizationById: (organizationId, teamId, query, params = {}) => this.request({
836
+ path: `/orgs/${organizationId}/teams/${teamId}/members`,
837
+ method: "GET",
838
+ query,
839
+ secure: true,
840
+ format: "json",
841
+ ...params
842
+ }),
843
+ addMemberToOrganizationTeamById: (organizationId, teamId, userId, params = {}) => this.request({
844
+ path: `/orgs/${organizationId}/teams/${teamId}/members/${userId}`,
845
+ method: "PUT",
846
+ secure: true,
847
+ ...params
848
+ }),
849
+ deleteMemberFromOrganizationTeamById: (organizationId, teamId, userId, params = {}) => this.request({
850
+ path: `/orgs/${organizationId}/teams/${teamId}/members/${userId}`,
851
+ method: "DELETE",
852
+ secure: true,
853
+ ...params
854
+ }),
855
+ inviteUsersToOrganization: (organizationId, data, params = {}) => this.request({
856
+ path: `/orgs/${organizationId}/invites`,
857
+ method: "POST",
858
+ body: data,
859
+ secure: true,
860
+ type: "application/json" /* Json */,
861
+ format: "json",
862
+ ...params
863
+ }),
864
+ joinOrganizationWithInvite: (organizationId, inviteId, params = {}) => this.request({
865
+ path: `/orgs/${organizationId}/invites/${inviteId}`,
866
+ method: "POST",
867
+ secure: true,
868
+ format: "json",
869
+ ...params
870
+ }),
871
+ upgradeOrganizationPlan: (organizationId, data, params = {}) => this.request({
872
+ path: `/orgs/${organizationId}/billing`,
873
+ method: "POST",
874
+ body: data,
875
+ secure: true,
876
+ type: "application/json" /* Json */,
877
+ format: "json",
878
+ ...params
879
+ }),
880
+ getOrganizationBillingPortal: (organizationId, params = {}) => this.request({
881
+ path: `/orgs/${organizationId}/billing`,
882
+ method: "GET",
883
+ secure: true,
884
+ format: "json",
885
+ ...params
886
+ }),
887
+ requestOrganizationUpgrade: (organizationId, params = {}) => this.request({
888
+ path: `/orgs/${organizationId}/request_upgrade`,
889
+ method: "POST",
890
+ secure: true,
891
+ format: "json",
892
+ ...params
893
+ }),
894
+ transferOrganization: (organizationId, data, params = {}) => this.request({
895
+ path: `/orgs/${organizationId}/transfer`,
896
+ method: "POST",
897
+ body: data,
898
+ secure: true,
899
+ type: "application/json" /* Json */,
900
+ format: "json",
901
+ ...params
902
+ }),
903
+ searchOrganizationContent: (organizationId, query, params = {}) => this.request({
904
+ path: `/orgs/${organizationId}/search`,
905
+ method: "GET",
906
+ query,
907
+ secure: true,
908
+ format: "json",
909
+ ...params
910
+ }),
911
+ listSpacesInOrganizationById: (organizationId, query, params = {}) => this.request({
912
+ path: `/orgs/${organizationId}/spaces`,
913
+ method: "GET",
914
+ query,
915
+ secure: true,
916
+ format: "json",
917
+ ...params
918
+ }),
919
+ listCollectionsInOrganizationById: (organizationId, query, params = {}) => this.request({
920
+ path: `/orgs/${organizationId}/collections`,
921
+ method: "GET",
922
+ query,
923
+ secure: true,
924
+ format: "json",
925
+ ...params
926
+ }),
927
+ setupDirectorySync: (organizationId, params = {}) => this.request({
928
+ path: `/orgs/${organizationId}/dsync`,
929
+ method: "POST",
930
+ secure: true,
931
+ format: "json",
932
+ ...params
933
+ }),
934
+ listDirectorySyncGroups: (organizationId, params = {}) => this.request({
935
+ path: `/orgs/${organizationId}/dsync/groups`,
936
+ method: "GET",
937
+ secure: true,
938
+ format: "json",
939
+ ...params
940
+ }),
941
+ syncDirectorySyncGroupsToTeams: (organizationId, data, params = {}) => this.request({
942
+ path: `/orgs/${organizationId}/dsync/teams`,
943
+ method: "POST",
944
+ body: data,
945
+ secure: true,
946
+ type: "application/json" /* Json */,
947
+ format: "json",
948
+ ...params
949
+ })
950
+ };
951
+ this.urls = {
952
+ getContentByUrl: (query, params = {}) => this.request({
953
+ path: `/urls/content`,
954
+ method: "GET",
955
+ query,
956
+ secure: true,
957
+ format: "json",
240
958
  ...params
241
959
  })
242
960
  };
@@ -245,12 +963,6 @@ var Api = class extends HttpClient {
245
963
 
246
964
  // src/index.ts
247
965
  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
966
  var GitBookAPI = class extends Api {
255
967
  constructor(options = {}) {
256
968
  const { endpoint = GITBOOK_DEFAULT_ENDPOINT, authToken } = options;
@@ -265,32 +977,70 @@ var GitBookAPI = class extends Api {
265
977
  };
266
978
  }
267
979
  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;
980
+ },
981
+ customFetch: async (input, init) => {
982
+ if ("credentials" in init) {
983
+ delete init.credentials;
984
+ }
985
+ if ("referrerPolicy" in init) {
986
+ delete init.referrerPolicy;
987
+ }
988
+ const response = await fetch(input, init);
989
+ if (!response.ok) {
990
+ let error = response.statusText;
991
+ try {
992
+ const body = await response.json();
993
+ error = body?.error?.message || error;
994
+ } catch (err) {
995
+ response.headers.forEach((value, key) => {
996
+ error += `${key}:${value} `;
997
+ });
998
+ }
999
+ throw new Error(
1000
+ `GitBook API failed with [${response.status}] ${response.url}: ${error}`
1001
+ );
278
1002
  }
279
- throw new GitBookAPIError(error);
1003
+ return response;
280
1004
  }
281
- };
1005
+ });
1006
+ this.endpoint = endpoint;
282
1007
  this.setSecurityData({ authToken });
283
1008
  }
1009
+ async createInstallationClient(integrationName, installationId) {
1010
+ const { data: installationToken } = await this.integrations.createIntegrationInstallationToken(
1011
+ integrationName,
1012
+ installationId
1013
+ );
1014
+ return new GitBookAPI({
1015
+ endpoint: this.endpoint,
1016
+ authToken: installationToken.token
1017
+ });
1018
+ }
284
1019
  };
285
1020
  // Annotate the CommonJS export names for ESM import in node:
286
1021
  0 && (module.exports = {
1022
+ APIIntegrationScope,
1023
+ AnalyticsSearchPeriod,
1024
+ AnalyticsTrafficInterval,
287
1025
  Api,
1026
+ BillingInterval,
1027
+ BillingProduct,
1028
+ ChangeRequestStatus,
1029
+ CloudflareHostnameStatus,
1030
+ CloudflareHostnameTLSStatus,
1031
+ CloudflareHostnameTLSValidationMethod,
1032
+ ContentKitIcon,
288
1033
  ContentType,
1034
+ ContentVisibility,
289
1035
  GITBOOK_DEFAULT_ENDPOINT,
290
1036
  GitBookAPI,
291
1037
  HttpClient,
1038
+ ImportContentSource,
292
1039
  IntegrationCategory,
1040
+ IntegrationInstallationSpaceSelection,
293
1041
  IntegrationInstallationStatus,
294
1042
  IntegrationScope,
295
- IntegrationVisibility
1043
+ IntegrationVisibility,
1044
+ MemberRole,
1045
+ PurgeCDNCacheContextType
296
1046
  });