@gitbook/api 0.88.0 → 0.89.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.cjs CHANGED
@@ -243,14 +243,17 @@ __export(src_exports, {
243
243
  RevisionSemanticChangeType: () => RevisionSemanticChangeType,
244
244
  SiteAdsStatus: () => SiteAdsStatus,
245
245
  SiteAdsTopic: () => SiteAdsTopic,
246
+ SiteInsightsAdPlacement: () => SiteInsightsAdPlacement,
246
247
  SiteInsightsEventType: () => SiteInsightsEventType,
247
248
  SiteInsightsLinkPosition: () => SiteInsightsLinkPosition,
248
249
  SiteInsightsQueryOperator: () => SiteInsightsQueryOperator,
249
250
  SiteInsightsQueryRange: () => SiteInsightsQueryRange,
251
+ SiteInsightsTrademarkPlacement: () => SiteInsightsTrademarkPlacement,
250
252
  SiteInsightsVisitorBot: () => SiteInsightsVisitorBot,
251
253
  SiteInsightsVisitorBrowser: () => SiteInsightsVisitorBrowser,
252
254
  SiteInsightsVisitorDevice: () => SiteInsightsVisitorDevice,
253
255
  SiteInsightsVisitorOS: () => SiteInsightsVisitorOS,
256
+ SiteToMigrateFeature: () => SiteToMigrateFeature,
254
257
  SiteType: () => SiteType,
255
258
  SiteVisibility: () => SiteVisibility,
256
259
  SpaceBlockReason: () => SpaceBlockReason,
@@ -261,129 +264,103 @@ module.exports = __toCommonJS(src_exports);
261
264
 
262
265
  // package.json
263
266
  var name = "@gitbook/api";
264
- var version = "0.88.0";
267
+ var version = "0.89.0";
265
268
 
266
269
  // src/client.ts
267
270
  var import_event_iterator = __toESM(require_node(), 1);
268
271
 
269
272
  // ../../node_modules/eventsource-parser/dist/index.js
270
- function createParser(onParse) {
271
- let isFirstChunk;
272
- let buffer;
273
- let startingPosition;
274
- let startingFieldLength;
275
- let eventId;
276
- let eventName;
277
- let data;
278
- reset();
279
- return {
280
- feed,
281
- reset
282
- };
283
- function reset() {
284
- isFirstChunk = true;
285
- buffer = "";
286
- startingPosition = 0;
287
- startingFieldLength = -1;
288
- eventId = void 0;
289
- eventName = void 0;
290
- data = "";
273
+ var __defProp2 = Object.defineProperty;
274
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
275
+ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key != "symbol" ? key + "" : key, value);
276
+ var ParseError = class extends Error {
277
+ constructor(message, options) {
278
+ super(message), __publicField(this, "type"), __publicField(this, "field"), __publicField(this, "value"), __publicField(this, "line"), this.name = "ParseError", this.type = options.type, this.field = options.field, this.value = options.value, this.line = options.line;
291
279
  }
292
- function feed(chunk) {
293
- buffer = buffer ? buffer + chunk : chunk;
294
- if (isFirstChunk && hasBom(buffer)) {
295
- buffer = buffer.slice(BOM.length);
296
- }
297
- isFirstChunk = false;
298
- const length = buffer.length;
299
- let position = 0;
300
- let discardTrailingNewline = false;
301
- while (position < length) {
302
- if (discardTrailingNewline) {
303
- if (buffer[position] === "\n") {
304
- ++position;
305
- }
306
- discardTrailingNewline = false;
307
- }
308
- let lineLength = -1;
309
- let fieldLength = startingFieldLength;
310
- let character;
311
- for (let index = startingPosition; lineLength < 0 && index < length; ++index) {
312
- character = buffer[index];
313
- if (character === ":" && fieldLength < 0) {
314
- fieldLength = index - position;
315
- } else if (character === "\r") {
316
- discardTrailingNewline = true;
317
- lineLength = index - position;
318
- } else if (character === "\n") {
319
- lineLength = index - position;
320
- }
321
- }
322
- if (lineLength < 0) {
323
- startingPosition = length - position;
324
- startingFieldLength = fieldLength;
325
- break;
326
- } else {
327
- startingPosition = 0;
328
- startingFieldLength = -1;
329
- }
330
- parseEventStreamLine(buffer, position, fieldLength, lineLength);
331
- position += lineLength + 1;
332
- }
333
- if (position === length) {
334
- buffer = "";
335
- } else if (position > 0) {
336
- buffer = buffer.slice(position);
337
- }
280
+ };
281
+ function noop(_arg) {
282
+ }
283
+ function createParser(callbacks) {
284
+ const { onEvent = noop, onError = noop, onRetry = noop, onComment } = callbacks;
285
+ let incompleteLine = "", isFirstChunk = true, id, data = "", eventType = "";
286
+ function feed(newChunk) {
287
+ const chunk = isFirstChunk ? newChunk.replace(/^\xEF\xBB\xBF/, "") : newChunk, [complete, incomplete] = splitLines(`${incompleteLine}${chunk}`);
288
+ for (const line of complete)
289
+ parseLine(line);
290
+ incompleteLine = incomplete, isFirstChunk = false;
338
291
  }
339
- function parseEventStreamLine(lineBuffer, index, fieldLength, lineLength) {
340
- if (lineLength === 0) {
341
- if (data.length > 0) {
342
- onParse({
343
- type: "event",
344
- id: eventId,
345
- event: eventName || void 0,
346
- data: data.slice(0, -1)
347
- });
348
- data = "";
349
- eventId = void 0;
350
- }
351
- eventName = void 0;
292
+ function parseLine(line) {
293
+ if (line === "") {
294
+ dispatchEvent();
352
295
  return;
353
296
  }
354
- const noValue = fieldLength < 0;
355
- const field = lineBuffer.slice(index, index + (noValue ? lineLength : fieldLength));
356
- let step = 0;
357
- if (noValue) {
358
- step = lineLength;
359
- } else if (lineBuffer[index + fieldLength + 1] === " ") {
360
- step = fieldLength + 2;
361
- } else {
362
- step = fieldLength + 1;
297
+ if (line.startsWith(":")) {
298
+ onComment && onComment(line.slice(line.startsWith(": ") ? 2 : 1));
299
+ return;
363
300
  }
364
- const position = index + step;
365
- const valueLength = lineLength - step;
366
- const value = lineBuffer.slice(position, position + valueLength).toString();
367
- if (field === "data") {
368
- data += value ? "".concat(value, "\n") : "\n";
369
- } else if (field === "event") {
370
- eventName = value;
371
- } else if (field === "id" && !value.includes("\0")) {
372
- eventId = value;
373
- } else if (field === "retry") {
374
- const retry = parseInt(value, 10);
375
- if (!Number.isNaN(retry)) {
376
- onParse({
377
- type: "reconnect-interval",
378
- value: retry
379
- });
380
- }
301
+ const fieldSeparatorIndex = line.indexOf(":");
302
+ if (fieldSeparatorIndex !== -1) {
303
+ const field = line.slice(0, fieldSeparatorIndex), offset = line[fieldSeparatorIndex + 1] === " " ? 2 : 1, value = line.slice(fieldSeparatorIndex + offset);
304
+ processField(field, value, line);
305
+ return;
306
+ }
307
+ processField(line, "", line);
308
+ }
309
+ function processField(field, value, line) {
310
+ switch (field) {
311
+ case "event":
312
+ eventType = value;
313
+ break;
314
+ case "data":
315
+ data = `${data}${value}
316
+ `;
317
+ break;
318
+ case "id":
319
+ id = value.includes("\0") ? void 0 : value;
320
+ break;
321
+ case "retry":
322
+ /^\d+$/.test(value) ? onRetry(parseInt(value, 10)) : onError(
323
+ new ParseError(`Invalid \`retry\` value: "${value}"`, {
324
+ type: "invalid-retry",
325
+ value,
326
+ line
327
+ })
328
+ );
329
+ break;
330
+ default:
331
+ onError(
332
+ new ParseError(
333
+ `Unknown field "${field.length > 20 ? `${field.slice(0, 20)}\u2026` : field}"`,
334
+ { type: "unknown-field", field, value, line }
335
+ )
336
+ );
337
+ break;
381
338
  }
382
339
  }
340
+ function dispatchEvent() {
341
+ data.length > 0 && onEvent({
342
+ id,
343
+ event: eventType || void 0,
344
+ data: data.endsWith(`
345
+ `) ? data.slice(0, -1) : data
346
+ }), id = void 0, data = "", eventType = "";
347
+ }
348
+ function reset(options = {}) {
349
+ incompleteLine && options.consume && parseLine(incompleteLine), id = void 0, data = "", eventType = "", incompleteLine = "";
350
+ }
351
+ return { feed, reset };
383
352
  }
384
- var BOM = [239, 187, 191];
385
- function hasBom(buffer) {
386
- return BOM.every((charCode, index) => buffer.charCodeAt(index) === charCode);
353
+ function splitLines(chunk) {
354
+ const lines = [];
355
+ let incompleteLine = "";
356
+ const totalLength = chunk.length;
357
+ for (let i = 0; i < totalLength; i++) {
358
+ const char = chunk[i];
359
+ char === "\r" && chunk[i + 1] === `
360
+ ` ? (lines.push(incompleteLine), incompleteLine = "", i++) : char === "\r" || char === `
361
+ ` ? (lines.push(incompleteLine), incompleteLine = "") : incompleteLine += char;
362
+ }
363
+ return [lines, incompleteLine];
387
364
  }
388
365
 
389
366
  // src/client.ts
@@ -732,6 +709,25 @@ var BillingInterval = /* @__PURE__ */ ((BillingInterval2) => {
732
709
  BillingInterval2["Yearly"] = "yearly";
733
710
  return BillingInterval2;
734
711
  })(BillingInterval || {});
712
+ var SiteToMigrateFeature = /* @__PURE__ */ ((SiteToMigrateFeature2) => {
713
+ SiteToMigrateFeature2["Sections"] = "sections";
714
+ SiteToMigrateFeature2["VisitorAuth"] = "visitor-auth";
715
+ SiteToMigrateFeature2["Redirects"] = "redirects";
716
+ SiteToMigrateFeature2["CustomHostname"] = "custom-hostname";
717
+ SiteToMigrateFeature2["AISearch"] = "AI-search";
718
+ SiteToMigrateFeature2["PDFExport"] = "PDF-export";
719
+ SiteToMigrateFeature2["PageRatings"] = "page-ratings";
720
+ SiteToMigrateFeature2["CustomLogo"] = "custom-logo";
721
+ SiteToMigrateFeature2["CustomThemePreset"] = "custom-theme-preset";
722
+ SiteToMigrateFeature2["CustomFonts"] = "custom-fonts";
723
+ SiteToMigrateFeature2["CustomIcons"] = "custom-icons";
724
+ SiteToMigrateFeature2["CustomFooterLogo"] = "custom-footer-logo";
725
+ SiteToMigrateFeature2["CustomFooterCopyright"] = "custom-footer-copyright";
726
+ SiteToMigrateFeature2["CustomFooterLinks"] = "custom-footer-links";
727
+ SiteToMigrateFeature2["Unlisted"] = "unlisted";
728
+ SiteToMigrateFeature2["ShareLinks"] = "share-links";
729
+ return SiteToMigrateFeature2;
730
+ })(SiteToMigrateFeature || {});
735
731
  var CustomizationIconsStyle = /* @__PURE__ */ ((CustomizationIconsStyle2) => {
736
732
  CustomizationIconsStyle2["Regular"] = "regular";
737
733
  CustomizationIconsStyle2["Solid"] = "solid";
@@ -758,16 +754,30 @@ var SiteInsightsLinkPosition = /* @__PURE__ */ ((SiteInsightsLinkPosition2) => {
758
754
  SiteInsightsLinkPosition2["Content"] = "content";
759
755
  return SiteInsightsLinkPosition2;
760
756
  })(SiteInsightsLinkPosition || {});
757
+ var SiteInsightsTrademarkPlacement = /* @__PURE__ */ ((SiteInsightsTrademarkPlacement2) => {
758
+ SiteInsightsTrademarkPlacement2["Sidebar"] = "sidebar";
759
+ SiteInsightsTrademarkPlacement2["Ad"] = "ad";
760
+ SiteInsightsTrademarkPlacement2["Footer"] = "footer";
761
+ return SiteInsightsTrademarkPlacement2;
762
+ })(SiteInsightsTrademarkPlacement || {});
763
+ var SiteInsightsAdPlacement = /* @__PURE__ */ ((SiteInsightsAdPlacement2) => {
764
+ SiteInsightsAdPlacement2["Aside"] = "aside";
765
+ return SiteInsightsAdPlacement2;
766
+ })(SiteInsightsAdPlacement || {});
761
767
  var SiteInsightsEventType = /* @__PURE__ */ ((SiteInsightsEventType2) => {
762
768
  SiteInsightsEventType2["PageView"] = "page_view";
763
769
  SiteInsightsEventType2["SearchOpen"] = "search_open";
764
770
  SiteInsightsEventType2["SearchTypeQuery"] = "search_type_query";
765
771
  SiteInsightsEventType2["SearchOpenResult"] = "search_open_result";
766
772
  SiteInsightsEventType2["PagePostFeedback"] = "page_post_feedback";
773
+ SiteInsightsEventType2["PagePostFeedbackComment"] = "page_post_feedback_comment";
767
774
  SiteInsightsEventType2["AskQuestion"] = "ask_question";
768
775
  SiteInsightsEventType2["LinkClick"] = "link_click";
769
776
  SiteInsightsEventType2["ApiClientOpen"] = "api_client_open";
770
777
  SiteInsightsEventType2["ApiClientRequest"] = "api_client_request";
778
+ SiteInsightsEventType2["AdClick"] = "ad_click";
779
+ SiteInsightsEventType2["AdDisplay"] = "ad_display";
780
+ SiteInsightsEventType2["TrademarkClick"] = "trademark_click";
771
781
  return SiteInsightsEventType2;
772
782
  })(SiteInsightsEventType || {});
773
783
  var SiteInsightsVisitorBrowser = /* @__PURE__ */ ((SiteInsightsVisitorBrowser2) => {
@@ -1119,14 +1129,22 @@ var HttpClient = class {
1119
1129
  reader.cancel();
1120
1130
  queue.stop();
1121
1131
  };
1122
- const parser = createParser((event) => {
1123
- if (event.type === "event") {
1124
- if (event.data === "done") {
1132
+ const parser = createParser({
1133
+ onEvent: (event) => {
1134
+ if (event.event === "done") {
1125
1135
  stop();
1136
+ } else if (event.event === "error") {
1137
+ const data = JSON.parse(event.data);
1138
+ reader.cancel();
1139
+ queue.fail(new Error(data.error.message));
1126
1140
  } else {
1127
1141
  const data = JSON.parse(event.data);
1128
1142
  queue.push(data);
1129
1143
  }
1144
+ },
1145
+ onError: (error) => {
1146
+ reader.cancel();
1147
+ queue.fail(error);
1130
1148
  }
1131
1149
  });
1132
1150
  const decoder = new TextDecoder();
@@ -1387,6 +1405,12 @@ var Api = class extends HttpClient {
1387
1405
  secure: true,
1388
1406
  ...params
1389
1407
  }),
1408
+ removeUserFromSpace: (spaceId, userId, params = {}) => this.request({
1409
+ path: `/spaces/${spaceId}/permissions/users/${userId}`,
1410
+ method: "DELETE",
1411
+ secure: true,
1412
+ ...params
1413
+ }),
1390
1414
  getCurrentRevision: (spaceId, query, params = {}) => this.request({
1391
1415
  path: `/spaces/${spaceId}/content`,
1392
1416
  method: "GET",
@@ -2103,6 +2127,18 @@ var Api = class extends HttpClient {
2103
2127
  type: "application/json" /* Json */,
2104
2128
  ...params
2105
2129
  }),
2130
+ removeTeamFromCollection: (collectionId, teamId, params = {}) => this.request({
2131
+ path: `/collections/${collectionId}/permissions/teams/${teamId}`,
2132
+ method: "DELETE",
2133
+ secure: true,
2134
+ ...params
2135
+ }),
2136
+ removeUserFromCollection: (collectionId, userId, params = {}) => this.request({
2137
+ path: `/collections/${collectionId}/permissions/users/${userId}`,
2138
+ method: "DELETE",
2139
+ secure: true,
2140
+ ...params
2141
+ }),
2106
2142
  listPermissionsAggregateInCollection: (collectionId, query, params = {}) => this.request({
2107
2143
  path: `/collections/${collectionId}/permissions/aggregate`,
2108
2144
  method: "GET",
@@ -2578,6 +2614,29 @@ var Api = class extends HttpClient {
2578
2614
  format: "json",
2579
2615
  ...params
2580
2616
  }),
2617
+ migrateOrganizationPlan: (organizationId, query, params = {}) => this.request({
2618
+ path: `/orgs/${organizationId}/billing/migrate`,
2619
+ method: "POST",
2620
+ query,
2621
+ secure: true,
2622
+ ...params
2623
+ }),
2624
+ previewMigrateOrganizationPlan: (organizationId, query, params = {}) => this.request({
2625
+ path: `/orgs/${organizationId}/billing/migrate`,
2626
+ method: "GET",
2627
+ query,
2628
+ secure: true,
2629
+ format: "json",
2630
+ ...params
2631
+ }),
2632
+ listSitesToMigrate: (organizationId, query, params = {}) => this.request({
2633
+ path: `/orgs/${organizationId}/billing/migrate/sites`,
2634
+ method: "GET",
2635
+ query,
2636
+ secure: true,
2637
+ format: "json",
2638
+ ...params
2639
+ }),
2581
2640
  getOrganizationBillingPortal: (organizationId, params = {}) => this.request({
2582
2641
  path: `/orgs/${organizationId}/billing/portal`,
2583
2642
  method: "GET",
@@ -2712,21 +2771,6 @@ var Api = class extends HttpClient {
2712
2771
  format: "json",
2713
2772
  ...params
2714
2773
  }),
2715
- listOrgExperimentalFeatures: (organizationId, params = {}) => this.request({
2716
- path: `/orgs/${organizationId}/experiments`,
2717
- method: "GET",
2718
- secure: true,
2719
- format: "json",
2720
- ...params
2721
- }),
2722
- updateOrgExperimentalFeatures: (organizationId, data, params = {}) => this.request({
2723
- path: `/orgs/${organizationId}/experiments`,
2724
- method: "POST",
2725
- body: data,
2726
- secure: true,
2727
- type: "application/json" /* Json */,
2728
- ...params
2729
- }),
2730
2774
  listSamlProvidersInOrganizationById: (organizationId, query, params = {}) => this.request({
2731
2775
  path: `/orgs/${organizationId}/saml`,
2732
2776
  method: "GET",
@@ -3165,6 +3209,30 @@ var Api = class extends HttpClient {
3165
3209
  format: "json",
3166
3210
  ...params
3167
3211
  }),
3212
+ addSectionGroupToSite: (organizationId, siteId, data, params = {}) => this.request({
3213
+ path: `/orgs/${organizationId}/sites/${siteId}/section-groups`,
3214
+ method: "POST",
3215
+ body: data,
3216
+ secure: true,
3217
+ type: "application/json" /* Json */,
3218
+ format: "json",
3219
+ ...params
3220
+ }),
3221
+ updateSiteSectionGroupById: (organizationId, siteId, siteSectionGroupId, data, params = {}) => this.request({
3222
+ path: `/orgs/${organizationId}/sites/${siteId}/section-groups/${siteSectionGroupId}`,
3223
+ method: "PATCH",
3224
+ body: data,
3225
+ secure: true,
3226
+ type: "application/json" /* Json */,
3227
+ format: "json",
3228
+ ...params
3229
+ }),
3230
+ deleteSiteSectionGroupById: (organizationId, siteId, siteSectionGroupId, params = {}) => this.request({
3231
+ path: `/orgs/${organizationId}/sites/${siteId}/section-groups/${siteSectionGroupId}`,
3232
+ method: "DELETE",
3233
+ secure: true,
3234
+ ...params
3235
+ }),
3168
3236
  addSectionToSite: (organizationId, siteId, data, params = {}) => this.request({
3169
3237
  path: `/orgs/${organizationId}/sites/${siteId}/sections`,
3170
3238
  method: "POST",
@@ -3248,6 +3316,12 @@ var Api = class extends HttpClient {
3248
3316
  format: "json",
3249
3317
  ...params
3250
3318
  }),
3319
+ deleteSiteSpaceCustomizationById: (organizationId, siteId, siteSpaceId, params = {}) => this.request({
3320
+ path: `/orgs/${organizationId}/sites/${siteId}/site-spaces/${siteSpaceId}/customization`,
3321
+ method: "DELETE",
3322
+ secure: true,
3323
+ ...params
3324
+ }),
3251
3325
  getSiteSpaceRawCustomizationById: (organizationId, siteId, siteSpaceId, params = {}) => this.request({
3252
3326
  path: `/orgs/${organizationId}/sites/${siteId}/site-spaces/${siteSpaceId}/customization/raw`,
3253
3327
  method: "GET",
@@ -3626,14 +3700,17 @@ var GitBookAPI = class extends Api {
3626
3700
  RevisionSemanticChangeType,
3627
3701
  SiteAdsStatus,
3628
3702
  SiteAdsTopic,
3703
+ SiteInsightsAdPlacement,
3629
3704
  SiteInsightsEventType,
3630
3705
  SiteInsightsLinkPosition,
3631
3706
  SiteInsightsQueryOperator,
3632
3707
  SiteInsightsQueryRange,
3708
+ SiteInsightsTrademarkPlacement,
3633
3709
  SiteInsightsVisitorBot,
3634
3710
  SiteInsightsVisitorBrowser,
3635
3711
  SiteInsightsVisitorDevice,
3636
3712
  SiteInsightsVisitorOS,
3713
+ SiteToMigrateFeature,
3637
3714
  SiteType,
3638
3715
  SiteVisibility,
3639
3716
  SpaceBlockReason,