@gitbook/api 0.88.0 → 0.88.1

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
@@ -172,129 +172,103 @@ var require_node = __commonJS({
172
172
 
173
173
  // package.json
174
174
  var name = "@gitbook/api";
175
- var version = "0.88.0";
175
+ var version = "0.88.1";
176
176
 
177
177
  // src/client.ts
178
178
  var import_event_iterator = __toESM(require_node(), 1);
179
179
 
180
180
  // ../../node_modules/eventsource-parser/dist/index.js
181
- function createParser(onParse) {
182
- let isFirstChunk;
183
- let buffer;
184
- let startingPosition;
185
- let startingFieldLength;
186
- let eventId;
187
- let eventName;
188
- let data;
189
- reset();
190
- return {
191
- feed,
192
- reset
193
- };
194
- function reset() {
195
- isFirstChunk = true;
196
- buffer = "";
197
- startingPosition = 0;
198
- startingFieldLength = -1;
199
- eventId = void 0;
200
- eventName = void 0;
201
- data = "";
181
+ var __defProp2 = Object.defineProperty;
182
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
183
+ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key != "symbol" ? key + "" : key, value);
184
+ var ParseError = class extends Error {
185
+ constructor(message, options) {
186
+ 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;
202
187
  }
203
- function feed(chunk) {
204
- buffer = buffer ? buffer + chunk : chunk;
205
- if (isFirstChunk && hasBom(buffer)) {
206
- buffer = buffer.slice(BOM.length);
207
- }
208
- isFirstChunk = false;
209
- const length = buffer.length;
210
- let position = 0;
211
- let discardTrailingNewline = false;
212
- while (position < length) {
213
- if (discardTrailingNewline) {
214
- if (buffer[position] === "\n") {
215
- ++position;
216
- }
217
- discardTrailingNewline = false;
218
- }
219
- let lineLength = -1;
220
- let fieldLength = startingFieldLength;
221
- let character;
222
- for (let index = startingPosition; lineLength < 0 && index < length; ++index) {
223
- character = buffer[index];
224
- if (character === ":" && fieldLength < 0) {
225
- fieldLength = index - position;
226
- } else if (character === "\r") {
227
- discardTrailingNewline = true;
228
- lineLength = index - position;
229
- } else if (character === "\n") {
230
- lineLength = index - position;
231
- }
232
- }
233
- if (lineLength < 0) {
234
- startingPosition = length - position;
235
- startingFieldLength = fieldLength;
236
- break;
237
- } else {
238
- startingPosition = 0;
239
- startingFieldLength = -1;
240
- }
241
- parseEventStreamLine(buffer, position, fieldLength, lineLength);
242
- position += lineLength + 1;
243
- }
244
- if (position === length) {
245
- buffer = "";
246
- } else if (position > 0) {
247
- buffer = buffer.slice(position);
248
- }
188
+ };
189
+ function noop(_arg) {
190
+ }
191
+ function createParser(callbacks) {
192
+ const { onEvent = noop, onError = noop, onRetry = noop, onComment } = callbacks;
193
+ let incompleteLine = "", isFirstChunk = true, id, data = "", eventType = "";
194
+ function feed(newChunk) {
195
+ const chunk = isFirstChunk ? newChunk.replace(/^\xEF\xBB\xBF/, "") : newChunk, [complete, incomplete] = splitLines(`${incompleteLine}${chunk}`);
196
+ for (const line of complete)
197
+ parseLine(line);
198
+ incompleteLine = incomplete, isFirstChunk = false;
249
199
  }
250
- function parseEventStreamLine(lineBuffer, index, fieldLength, lineLength) {
251
- if (lineLength === 0) {
252
- if (data.length > 0) {
253
- onParse({
254
- type: "event",
255
- id: eventId,
256
- event: eventName || void 0,
257
- data: data.slice(0, -1)
258
- });
259
- data = "";
260
- eventId = void 0;
261
- }
262
- eventName = void 0;
200
+ function parseLine(line) {
201
+ if (line === "") {
202
+ dispatchEvent();
263
203
  return;
264
204
  }
265
- const noValue = fieldLength < 0;
266
- const field = lineBuffer.slice(index, index + (noValue ? lineLength : fieldLength));
267
- let step = 0;
268
- if (noValue) {
269
- step = lineLength;
270
- } else if (lineBuffer[index + fieldLength + 1] === " ") {
271
- step = fieldLength + 2;
272
- } else {
273
- step = fieldLength + 1;
205
+ if (line.startsWith(":")) {
206
+ onComment && onComment(line.slice(line.startsWith(": ") ? 2 : 1));
207
+ return;
274
208
  }
275
- const position = index + step;
276
- const valueLength = lineLength - step;
277
- const value = lineBuffer.slice(position, position + valueLength).toString();
278
- if (field === "data") {
279
- data += value ? "".concat(value, "\n") : "\n";
280
- } else if (field === "event") {
281
- eventName = value;
282
- } else if (field === "id" && !value.includes("\0")) {
283
- eventId = value;
284
- } else if (field === "retry") {
285
- const retry = parseInt(value, 10);
286
- if (!Number.isNaN(retry)) {
287
- onParse({
288
- type: "reconnect-interval",
289
- value: retry
290
- });
291
- }
209
+ const fieldSeparatorIndex = line.indexOf(":");
210
+ if (fieldSeparatorIndex !== -1) {
211
+ const field = line.slice(0, fieldSeparatorIndex), offset = line[fieldSeparatorIndex + 1] === " " ? 2 : 1, value = line.slice(fieldSeparatorIndex + offset);
212
+ processField(field, value, line);
213
+ return;
214
+ }
215
+ processField(line, "", line);
216
+ }
217
+ function processField(field, value, line) {
218
+ switch (field) {
219
+ case "event":
220
+ eventType = value;
221
+ break;
222
+ case "data":
223
+ data = `${data}${value}
224
+ `;
225
+ break;
226
+ case "id":
227
+ id = value.includes("\0") ? void 0 : value;
228
+ break;
229
+ case "retry":
230
+ /^\d+$/.test(value) ? onRetry(parseInt(value, 10)) : onError(
231
+ new ParseError(`Invalid \`retry\` value: "${value}"`, {
232
+ type: "invalid-retry",
233
+ value,
234
+ line
235
+ })
236
+ );
237
+ break;
238
+ default:
239
+ onError(
240
+ new ParseError(
241
+ `Unknown field "${field.length > 20 ? `${field.slice(0, 20)}\u2026` : field}"`,
242
+ { type: "unknown-field", field, value, line }
243
+ )
244
+ );
245
+ break;
292
246
  }
293
247
  }
248
+ function dispatchEvent() {
249
+ data.length > 0 && onEvent({
250
+ id,
251
+ event: eventType || void 0,
252
+ data: data.endsWith(`
253
+ `) ? data.slice(0, -1) : data
254
+ }), id = void 0, data = "", eventType = "";
255
+ }
256
+ function reset(options = {}) {
257
+ incompleteLine && options.consume && parseLine(incompleteLine), id = void 0, data = "", eventType = "", incompleteLine = "";
258
+ }
259
+ return { feed, reset };
294
260
  }
295
- var BOM = [239, 187, 191];
296
- function hasBom(buffer) {
297
- return BOM.every((charCode, index) => buffer.charCodeAt(index) === charCode);
261
+ function splitLines(chunk) {
262
+ const lines = [];
263
+ let incompleteLine = "";
264
+ const totalLength = chunk.length;
265
+ for (let i = 0; i < totalLength; i++) {
266
+ const char = chunk[i];
267
+ char === "\r" && chunk[i + 1] === `
268
+ ` ? (lines.push(incompleteLine), incompleteLine = "", i++) : char === "\r" || char === `
269
+ ` ? (lines.push(incompleteLine), incompleteLine = "") : incompleteLine += char;
270
+ }
271
+ return [lines, incompleteLine];
298
272
  }
299
273
 
300
274
  // src/client.ts
@@ -1030,14 +1004,22 @@ var HttpClient = class {
1030
1004
  reader.cancel();
1031
1005
  queue.stop();
1032
1006
  };
1033
- const parser = createParser((event) => {
1034
- if (event.type === "event") {
1035
- if (event.data === "done") {
1007
+ const parser = createParser({
1008
+ onEvent: (event) => {
1009
+ if (event.event === "done") {
1036
1010
  stop();
1011
+ } else if (event.event === "error") {
1012
+ const data = JSON.parse(event.data);
1013
+ reader.cancel();
1014
+ queue.fail(new Error(data.error.message));
1037
1015
  } else {
1038
1016
  const data = JSON.parse(event.data);
1039
1017
  queue.push(data);
1040
1018
  }
1019
+ },
1020
+ onError: (error) => {
1021
+ reader.cancel();
1022
+ queue.fail(error);
1041
1023
  }
1042
1024
  });
1043
1025
  const decoder = new TextDecoder();
@@ -2623,21 +2605,6 @@ var Api = class extends HttpClient {
2623
2605
  format: "json",
2624
2606
  ...params
2625
2607
  }),
2626
- listOrgExperimentalFeatures: (organizationId, params = {}) => this.request({
2627
- path: `/orgs/${organizationId}/experiments`,
2628
- method: "GET",
2629
- secure: true,
2630
- format: "json",
2631
- ...params
2632
- }),
2633
- updateOrgExperimentalFeatures: (organizationId, data, params = {}) => this.request({
2634
- path: `/orgs/${organizationId}/experiments`,
2635
- method: "POST",
2636
- body: data,
2637
- secure: true,
2638
- type: "application/json" /* Json */,
2639
- ...params
2640
- }),
2641
2608
  listSamlProvidersInOrganizationById: (organizationId, query, params = {}) => this.request({
2642
2609
  path: `/orgs/${organizationId}/saml`,
2643
2610
  method: "GET",
@@ -3159,6 +3126,12 @@ var Api = class extends HttpClient {
3159
3126
  format: "json",
3160
3127
  ...params
3161
3128
  }),
3129
+ deleteSiteSpaceCustomizationById: (organizationId, siteId, siteSpaceId, params = {}) => this.request({
3130
+ path: `/orgs/${organizationId}/sites/${siteId}/site-spaces/${siteSpaceId}/customization`,
3131
+ method: "DELETE",
3132
+ secure: true,
3133
+ ...params
3134
+ }),
3162
3135
  getSiteSpaceRawCustomizationById: (organizationId, siteId, siteSpaceId, params = {}) => this.request({
3163
3136
  path: `/orgs/${organizationId}/sites/${siteId}/site-spaces/${siteSpaceId}/customization/raw`,
3164
3137
  method: "GET",
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "main": "./dist/index.cjs",
5
5
  "module": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",
7
- "version": "0.88.0",
7
+ "version": "0.88.1",
8
8
  "sideEffects": false,
9
9
  "files": [
10
10
  "README.md",
@@ -13,7 +13,7 @@
13
13
  ],
14
14
  "dependencies": {
15
15
  "event-iterator": "^2.0.0",
16
- "eventsource-parser": "^1.1.1"
16
+ "eventsource-parser": "^3.0.0"
17
17
  },
18
18
  "devDependencies": {
19
19
  "swagger-typescript-api": "^13.0.3",
package/spec/openapi.json CHANGED
@@ -9981,81 +9981,6 @@
9981
9981
  }
9982
9982
  }
9983
9983
  },
9984
- "/orgs/{organizationId}/experiments": {
9985
- "get": {
9986
- "operationId": "listOrgExperimentalFeatures",
9987
- "summary": "List experiemental features for the given organization.",
9988
- "tags": [
9989
- "organizations"
9990
- ],
9991
- "security": [
9992
- {
9993
- "user": []
9994
- }
9995
- ],
9996
- "parameters": [
9997
- {
9998
- "$ref": "#/components/parameters/organizationId"
9999
- }
10000
- ],
10001
- "responses": {
10002
- "200": {
10003
- "description": "OK",
10004
- "content": {
10005
- "application/json": {
10006
- "schema": {
10007
- "type": "array",
10008
- "items": {
10009
- "$ref": "#/components/schemas/OrganizationExperimentalFeature"
10010
- }
10011
- }
10012
- }
10013
- }
10014
- },
10015
- "default": {
10016
- "$ref": "#/components/responses/UnexpectedError"
10017
- }
10018
- }
10019
- },
10020
- "post": {
10021
- "operationId": "updateOrgExperimentalFeatures",
10022
- "summary": "Toggle on or off experimental features.",
10023
- "tags": [
10024
- "organizations"
10025
- ],
10026
- "security": [
10027
- {
10028
- "user": []
10029
- }
10030
- ],
10031
- "parameters": [
10032
- {
10033
- "$ref": "#/components/parameters/organizationId"
10034
- }
10035
- ],
10036
- "requestBody": {
10037
- "required": true,
10038
- "content": {
10039
- "application/json": {
10040
- "schema": {
10041
- "type": "object",
10042
- "additionalProperties": {
10043
- "type": "boolean"
10044
- }
10045
- }
10046
- }
10047
- }
10048
- },
10049
- "responses": {
10050
- "204": {
10051
- "description": "OK"
10052
- },
10053
- "default": {
10054
- "$ref": "#/components/responses/UnexpectedError"
10055
- }
10056
- }
10057
- }
10058
- },
10059
9984
  "/orgs/{organizationId}/saml": {
10060
9985
  "get": {
10061
9986
  "operationId": "listSAMLProvidersInOrganizationById",
@@ -13237,6 +13162,21 @@
13237
13162
  "type": "string",
13238
13163
  "description": "ID of the site-space to be used as the default in this section."
13239
13164
  },
13165
+ "condition": {
13166
+ "description": "Conditional expression used to evaluate whether the site section should be shown to the site's visitor (should evaluate to a boolean). If not set, the condition will remain unchanged. If set to null, the condition will be removed.",
13167
+ "oneOf": [
13168
+ {
13169
+ "$ref": "#/components/schemas/Condition"
13170
+ },
13171
+ {
13172
+ "type": "string",
13173
+ "nullable": true,
13174
+ "enum": [
13175
+ null
13176
+ ]
13177
+ }
13178
+ ]
13179
+ },
13240
13180
  "icon": {
13241
13181
  "oneOf": [
13242
13182
  {
@@ -13561,6 +13501,21 @@
13561
13501
  "properties": {
13562
13502
  "path": {
13563
13503
  "$ref": "#/components/schemas/SiteSpacePath"
13504
+ },
13505
+ "condition": {
13506
+ "description": "Conditional expression used to evaluate whether the site space should be shown to the site's visitor (should evaluate to a boolean). If not set, the condition will remain unchanged. If set to null, the condition will be removed.",
13507
+ "oneOf": [
13508
+ {
13509
+ "$ref": "#/components/schemas/Condition"
13510
+ },
13511
+ {
13512
+ "type": "string",
13513
+ "nullable": true,
13514
+ "enum": [
13515
+ null
13516
+ ]
13517
+ }
13518
+ ]
13564
13519
  }
13565
13520
  }
13566
13521
  }
@@ -14163,6 +14118,40 @@
14163
14118
  "$ref": "#/components/responses/UnexpectedError"
14164
14119
  }
14165
14120
  }
14121
+ },
14122
+ "delete": {
14123
+ "operationId": "deleteSiteSpaceCustomizationById",
14124
+ "summary": "Removes the customization configuration for a site space.",
14125
+ "tags": [
14126
+ "sites"
14127
+ ],
14128
+ "security": [
14129
+ {
14130
+ "user": []
14131
+ }
14132
+ ],
14133
+ "parameters": [
14134
+ {
14135
+ "$ref": "#/components/parameters/organizationId"
14136
+ },
14137
+ {
14138
+ "$ref": "#/components/parameters/siteId"
14139
+ },
14140
+ {
14141
+ "$ref": "#/components/parameters/siteSpaceId"
14142
+ }
14143
+ ],
14144
+ "responses": {
14145
+ "205": {
14146
+ "description": "Site space customization removed"
14147
+ },
14148
+ "400": {
14149
+ "$ref": "#/components/responses/BadRequestError"
14150
+ },
14151
+ "default": {
14152
+ "$ref": "#/components/responses/UnexpectedError"
14153
+ }
14154
+ }
14166
14155
  }
14167
14156
  },
14168
14157
  "/orgs/{organizationId}/sites/{siteId}/site-spaces/{siteSpaceId}/customization/raw": {
@@ -14196,19 +14185,7 @@
14196
14185
  "schema": {
14197
14186
  "allOf": [
14198
14187
  {
14199
- "$ref": "#/components/schemas/SiteCustomizationSettings"
14200
- },
14201
- {
14202
- "type": "object",
14203
- "properties": {
14204
- "hasOverrides": {
14205
- "type": "boolean",
14206
- "description": "Indicates whether the site customization settings have been overridden."
14207
- }
14208
- },
14209
- "required": [
14210
- "hasOverrides"
14211
- ]
14188
+ "$ref": "#/components/schemas/SiteSpaceCustomizationSettings"
14212
14189
  }
14213
14190
  ]
14214
14191
  }
@@ -15505,6 +15482,11 @@
15505
15482
  "enum": [
15506
15483
  "rejected"
15507
15484
  ]
15485
+ },
15486
+ "reason": {
15487
+ "type": "string",
15488
+ "description": "Reason for the rejection",
15489
+ "maxLength": 512
15508
15490
  }
15509
15491
  }
15510
15492
  },
@@ -16449,6 +16431,27 @@
16449
16431
  "type"
16450
16432
  ]
16451
16433
  },
16434
+ "DocumentMarkKeyboard": {
16435
+ "type": "object",
16436
+ "properties": {
16437
+ "object": {
16438
+ "type": "string",
16439
+ "enum": [
16440
+ "mark"
16441
+ ]
16442
+ },
16443
+ "type": {
16444
+ "type": "string",
16445
+ "enum": [
16446
+ "keyboard"
16447
+ ]
16448
+ }
16449
+ },
16450
+ "required": [
16451
+ "object",
16452
+ "type"
16453
+ ]
16454
+ },
16452
16455
  "DocumentMarkStrikethrough": {
16453
16456
  "type": "object",
16454
16457
  "properties": {
@@ -16536,6 +16539,9 @@
16536
16539
  {
16537
16540
  "$ref": "#/components/schemas/DocumentMarkCode"
16538
16541
  },
16542
+ {
16543
+ "$ref": "#/components/schemas/DocumentMarkKeyboard"
16544
+ },
16539
16545
  {
16540
16546
  "$ref": "#/components/schemas/DocumentMarkStrikethrough"
16541
16547
  },
@@ -28133,6 +28139,10 @@
28133
28139
  "enum": [
28134
28140
  "rejected"
28135
28141
  ]
28142
+ },
28143
+ "reason": {
28144
+ "type": "string",
28145
+ "description": "Reason for the rejection"
28136
28146
  }
28137
28147
  }
28138
28148
  },
@@ -28318,6 +28328,11 @@
28318
28328
  "minLength": 1,
28319
28329
  "maxLength": 100
28320
28330
  },
28331
+ "Condition": {
28332
+ "type": "string",
28333
+ "minLength": 1,
28334
+ "maxLength": 1024
28335
+ },
28321
28336
  "SiteSpacePath": {
28322
28337
  "type": "string",
28323
28338
  "description": "Path to the space on the site",
@@ -28355,6 +28370,10 @@
28355
28370
  "type": "boolean",
28356
28371
  "description": "Whether this is the default space for the site"
28357
28372
  },
28373
+ "condition": {
28374
+ "description": "Conditional expression used to evaluate whether the site space should be shown to the site's visitor.",
28375
+ "$ref": "#/components/schemas/Condition"
28376
+ },
28358
28377
  "hasAdvancedCustomizationFeature": {
28359
28378
  "type": "boolean",
28360
28379
  "description": "Whether the space has advanced customization feature enabled"
@@ -28407,6 +28426,10 @@
28407
28426
  "path": {
28408
28427
  "$ref": "#/components/schemas/SiteSectionPath"
28409
28428
  },
28429
+ "condition": {
28430
+ "description": "Conditional expression used to evaluate whether the site section should be shown to the site's visitor.",
28431
+ "$ref": "#/components/schemas/Condition"
28432
+ },
28410
28433
  "siteSpaces": {
28411
28434
  "type": "array",
28412
28435
  "items": {
@@ -29204,37 +29227,6 @@
29204
29227
  }
29205
29228
  }
29206
29229
  },
29207
- "OrganizationExperimentalFeature": {
29208
- "type": "object",
29209
- "properties": {
29210
- "id": {
29211
- "type": "string"
29212
- },
29213
- "title": {
29214
- "type": "string"
29215
- },
29216
- "description": {
29217
- "type": "string"
29218
- },
29219
- "enabled": {
29220
- "type": "boolean"
29221
- },
29222
- "stage": {
29223
- "type": "string",
29224
- "enum": [
29225
- "alpha",
29226
- "beta"
29227
- ]
29228
- }
29229
- },
29230
- "required": [
29231
- "id",
29232
- "title",
29233
- "description",
29234
- "enabled",
29235
- "stage"
29236
- ]
29237
- },
29238
29230
  "SAMLProviderLabel": {
29239
29231
  "type": "string",
29240
29232
  "minLength": 1,
@@ -30592,6 +30584,25 @@
30592
30584
  }
30593
30585
  ]
30594
30586
  },
30587
+ "SiteSpaceCustomizationSettings": {
30588
+ "allOf": [
30589
+ {
30590
+ "$ref": "#/components/schemas/SiteCustomizationSettings"
30591
+ },
30592
+ {
30593
+ "type": "object",
30594
+ "properties": {
30595
+ "hasOverrides": {
30596
+ "type": "boolean",
30597
+ "description": "Indicates whether the site customization settings have been overridden."
30598
+ }
30599
+ },
30600
+ "required": [
30601
+ "hasOverrides"
30602
+ ]
30603
+ }
30604
+ ]
30605
+ },
30595
30606
  "SiteSectionPointer": {
30596
30607
  "type": "object",
30597
30608
  "properties": {
@@ -34899,24 +34910,6 @@
34899
34910
  "organization"
34900
34911
  ]
34901
34912
  },
34902
- "OrganizationExperimentalFeaturesChannel": {
34903
- "type": "object",
34904
- "properties": {
34905
- "channel": {
34906
- "type": "string",
34907
- "enum": [
34908
- "organization-experimental-features"
34909
- ]
34910
- },
34911
- "organization": {
34912
- "type": "string"
34913
- }
34914
- },
34915
- "required": [
34916
- "channel",
34917
- "organization"
34918
- ]
34919
- },
34920
34913
  "OrganizationAIIndexationChannel": {
34921
34914
  "type": "object",
34922
34915
  "description": "Channel for messages everytime a space is indexed by the AI in an organization",
@@ -35572,9 +35565,6 @@
35572
35565
  {
35573
35566
  "$ref": "#/components/schemas/OrganizationSitesChannel"
35574
35567
  },
35575
- {
35576
- "$ref": "#/components/schemas/OrganizationExperimentalFeaturesChannel"
35577
- },
35578
35568
  {
35579
35569
  "$ref": "#/components/schemas/OrganizationAIIndexationChannel"
35580
35570
  },