@gitbook/api 0.26.0 → 0.27.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/client.d.ts CHANGED
@@ -1032,10 +1032,7 @@ export interface Space {
1032
1032
  * @format uri
1033
1033
  */
1034
1034
  public?: string;
1035
- /**
1036
- * URL of the icon of this space, if defined. Deprecated, prefer using emojis for spaces instead of icons.
1037
- * @deprecated
1038
- */
1035
+ /** URL of the icon of this space, if defined. */
1039
1036
  icon?: URL;
1040
1037
  };
1041
1038
  /** ID of the organization owning this space */
@@ -1043,6 +1040,15 @@ export interface Space {
1043
1040
  /** ID of the parent collection. */
1044
1041
  parent?: string;
1045
1042
  gitSync?: GitSyncState;
1043
+ visitorAuth?: {
1044
+ /** Custom backend for Visitor Authentication */
1045
+ backend: 'custom';
1046
+ } | {
1047
+ /** Integration as backend for Visitor Authentication */
1048
+ backend: 'integration';
1049
+ /** Name of integration being used as the backend for Visitor Authentication */
1050
+ integration: string;
1051
+ };
1046
1052
  }
1047
1053
  /**
1048
1054
  * Determines how a Space can be edited.
@@ -3891,7 +3897,17 @@ export declare class Api<SecurityDataType extends unknown> extends HttpClient<Se
3891
3897
  * * `private`: Authorized members can access the content.
3892
3898
  */
3893
3899
  visibility?: ContentVisibility;
3894
- }, params?: RequestParams) => Promise<HttpResponse<Space, Error>>;
3900
+ /** The integration property, if set, is ignored. */
3901
+ visitorAuth?: any;
3902
+ } & ({
3903
+ /** Unicode codepoint or character of the emoji */
3904
+ emoji: Emoji;
3905
+ } | {
3906
+ icon: URL;
3907
+ } | {
3908
+ emoji?: null;
3909
+ icon?: null;
3910
+ }), params?: RequestParams) => Promise<HttpResponse<Space, Error>>;
3895
3911
  /**
3896
3912
  * No description
3897
3913
  *
package/dist/index.cjs CHANGED
@@ -3,8 +3,8 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
3
  var __getOwnPropNames = Object.getOwnPropertyNames;
4
4
  var __hasOwnProp = Object.prototype.hasOwnProperty;
5
5
  var __export = (target, all) => {
6
- for (var name in all)
7
- __defProp(target, name, { get: all[name], enumerable: true });
6
+ for (var name2 in all)
7
+ __defProp(target, name2, { get: all[name2], enumerable: true });
8
8
  };
9
9
  var __copyProps = (to, from, except, desc) => {
10
10
  if (from && typeof from === "object" || typeof from === "function") {
@@ -68,6 +68,10 @@ __export(src_exports, {
68
68
  });
69
69
  module.exports = __toCommonJS(src_exports);
70
70
 
71
+ // package.json
72
+ var name = "@gitbook/api";
73
+ var version = "0.27.0";
74
+
71
75
  // src/client.ts
72
76
  var ContentVisibility = /* @__PURE__ */ ((ContentVisibility2) => {
73
77
  ContentVisibility2["Public"] = "public";
@@ -2090,14 +2094,19 @@ var GitBookAPIError = class extends Error {
2090
2094
  var GITBOOK_DEFAULT_ENDPOINT = "https://api.gitbook.com";
2091
2095
  var GitBookAPI = class extends Api {
2092
2096
  constructor(options = {}) {
2093
- const { endpoint = GITBOOK_DEFAULT_ENDPOINT, authToken } = options;
2097
+ const {
2098
+ endpoint = GITBOOK_DEFAULT_ENDPOINT,
2099
+ authToken,
2100
+ userAgent = `${name}/${version}`
2101
+ } = options;
2094
2102
  super({
2095
2103
  baseUrl: `${endpoint}/v1`,
2096
2104
  securityWorker: (securityData) => {
2097
2105
  if (securityData.authToken) {
2098
2106
  return {
2099
2107
  headers: {
2100
- Authorization: `Bearer ${securityData.authToken}`
2108
+ Authorization: `Bearer ${securityData.authToken}`,
2109
+ "User-Agent": userAgent
2101
2110
  }
2102
2111
  };
2103
2112
  }
@@ -2124,6 +2133,7 @@ var GitBookAPI = class extends Api {
2124
2133
  }
2125
2134
  });
2126
2135
  this.endpoint = endpoint;
2136
+ this.userAgent = userAgent;
2127
2137
  this.authToken = authToken;
2128
2138
  this.setSecurityData({ authToken });
2129
2139
  }
@@ -2134,6 +2144,7 @@ var GitBookAPI = class extends Api {
2134
2144
  );
2135
2145
  return new GitBookAPI({
2136
2146
  endpoint: this.endpoint,
2147
+ userAgent: this.userAgent,
2137
2148
  authToken: installationToken.token
2138
2149
  });
2139
2150
  }
package/dist/index.d.ts CHANGED
@@ -14,12 +14,21 @@ export declare class GitBookAPI extends Api<{
14
14
  * Authentication token used by the API client.
15
15
  */
16
16
  readonly authToken: string | undefined;
17
+ /**
18
+ * User agent used by the API client.
19
+ */
20
+ readonly userAgent: string;
17
21
  constructor(options?: {
18
22
  /**
19
23
  * API endpoint to use.
20
24
  * @default "https://api.gitbook.com"
21
25
  */
22
26
  endpoint?: string;
27
+ /**
28
+ * User agent to use.
29
+ * It'll default to the package name and version.
30
+ */
31
+ userAgent?: string;
23
32
  /**
24
33
  * Authentication token to use.
25
34
  */
package/dist/index.js CHANGED
@@ -1,3 +1,7 @@
1
+ // package.json
2
+ var name = "@gitbook/api";
3
+ var version = "0.27.0";
4
+
1
5
  // src/client.ts
2
6
  var ContentVisibility = /* @__PURE__ */ ((ContentVisibility2) => {
3
7
  ContentVisibility2["Public"] = "public";
@@ -2020,14 +2024,19 @@ var GitBookAPIError = class extends Error {
2020
2024
  var GITBOOK_DEFAULT_ENDPOINT = "https://api.gitbook.com";
2021
2025
  var GitBookAPI = class extends Api {
2022
2026
  constructor(options = {}) {
2023
- const { endpoint = GITBOOK_DEFAULT_ENDPOINT, authToken } = options;
2027
+ const {
2028
+ endpoint = GITBOOK_DEFAULT_ENDPOINT,
2029
+ authToken,
2030
+ userAgent = `${name}/${version}`
2031
+ } = options;
2024
2032
  super({
2025
2033
  baseUrl: `${endpoint}/v1`,
2026
2034
  securityWorker: (securityData) => {
2027
2035
  if (securityData.authToken) {
2028
2036
  return {
2029
2037
  headers: {
2030
- Authorization: `Bearer ${securityData.authToken}`
2038
+ Authorization: `Bearer ${securityData.authToken}`,
2039
+ "User-Agent": userAgent
2031
2040
  }
2032
2041
  };
2033
2042
  }
@@ -2054,6 +2063,7 @@ var GitBookAPI = class extends Api {
2054
2063
  }
2055
2064
  });
2056
2065
  this.endpoint = endpoint;
2066
+ this.userAgent = userAgent;
2057
2067
  this.authToken = authToken;
2058
2068
  this.setSecurityData({ authToken });
2059
2069
  }
@@ -2064,6 +2074,7 @@ var GitBookAPI = class extends Api {
2064
2074
  );
2065
2075
  return new GitBookAPI({
2066
2076
  endpoint: this.endpoint,
2077
+ userAgent: this.userAgent,
2067
2078
  authToken: installationToken.token
2068
2079
  });
2069
2080
  }
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.26.0",
7
+ "version": "0.27.0",
8
8
  "sideEffects": false,
9
9
  "files": [
10
10
  "README.md",
package/spec/openapi.json CHANGED
@@ -4374,8 +4374,7 @@
4374
4374
  "format": "uri"
4375
4375
  },
4376
4376
  "icon": {
4377
- "deprecated": true,
4378
- "description": "URL of the icon of this space, if defined. Deprecated, prefer using emojis for spaces instead of icons.",
4377
+ "description": "URL of the icon of this space, if defined.",
4379
4378
  "$ref": "#/components/schemas/URL"
4380
4379
  }
4381
4380
  },
@@ -4394,6 +4393,45 @@
4394
4393
  },
4395
4394
  "gitSync": {
4396
4395
  "$ref": "#/components/schemas/GitSyncState"
4396
+ },
4397
+ "visitorAuth": {
4398
+ "oneOf": [
4399
+ {
4400
+ "type": "object",
4401
+ "properties": {
4402
+ "backend": {
4403
+ "type": "string",
4404
+ "description": "Custom backend for Visitor Authentication",
4405
+ "enum": [
4406
+ "custom"
4407
+ ]
4408
+ }
4409
+ },
4410
+ "required": [
4411
+ "backend"
4412
+ ]
4413
+ },
4414
+ {
4415
+ "type": "object",
4416
+ "properties": {
4417
+ "backend": {
4418
+ "type": "string",
4419
+ "description": "Integration as backend for Visitor Authentication",
4420
+ "enum": [
4421
+ "integration"
4422
+ ]
4423
+ },
4424
+ "integration": {
4425
+ "type": "string",
4426
+ "description": "Name of integration being used as the backend for Visitor Authentication"
4427
+ }
4428
+ },
4429
+ "required": [
4430
+ "backend",
4431
+ "integration"
4432
+ ]
4433
+ }
4434
+ ]
4397
4435
  }
4398
4436
  },
4399
4437
  "required": [
@@ -13198,18 +13236,71 @@
13198
13236
  "content": {
13199
13237
  "application/json": {
13200
13238
  "schema": {
13201
- "type": "object",
13202
- "properties": {
13203
- "editMode": {
13204
- "$ref": "#/components/schemas/SpaceEditMode"
13205
- },
13206
- "title": {
13207
- "$ref": "#/components/schemas/SpaceTitle"
13239
+ "allOf": [
13240
+ {
13241
+ "type": "object",
13242
+ "properties": {
13243
+ "editMode": {
13244
+ "$ref": "#/components/schemas/SpaceEditMode"
13245
+ },
13246
+ "title": {
13247
+ "$ref": "#/components/schemas/SpaceTitle"
13248
+ },
13249
+ "visibility": {
13250
+ "$ref": "#/components/schemas/ContentVisibility"
13251
+ },
13252
+ "visitorAuth": {
13253
+ "$ref": "#/components/schemas/Space/properties/visitorAuth",
13254
+ "description": "The integration property, if set, is ignored."
13255
+ }
13256
+ }
13208
13257
  },
13209
- "visibility": {
13210
- "$ref": "#/components/schemas/ContentVisibility"
13258
+ {
13259
+ "oneOf": [
13260
+ {
13261
+ "type": "object",
13262
+ "properties": {
13263
+ "emoji": {
13264
+ "$ref": "#/components/schemas/Emoji"
13265
+ }
13266
+ },
13267
+ "required": [
13268
+ "emoji"
13269
+ ]
13270
+ },
13271
+ {
13272
+ "type": "object",
13273
+ "properties": {
13274
+ "icon": {
13275
+ "$ref": "#/components/schemas/URL"
13276
+ }
13277
+ },
13278
+ "required": [
13279
+ "icon"
13280
+ ]
13281
+ },
13282
+ {
13283
+ "type": "object",
13284
+ "properties": {
13285
+ "emoji": {
13286
+ "type": "string",
13287
+ "nullable": true,
13288
+ "enum": [
13289
+ null
13290
+ ]
13291
+ },
13292
+ "icon": {
13293
+ "type": "string",
13294
+ "nullable": true,
13295
+ "enum": [
13296
+ null
13297
+ ]
13298
+ }
13299
+ }
13300
+ }
13301
+ ]
13211
13302
  }
13212
- }
13303
+ ]
13213
13304
  }
13214
13305
  }
13215
13306
  }
package/spec/openapi.yaml CHANGED
@@ -2866,8 +2866,7 @@ components:
2866
2866
  description: URL of the public version of the space. Only defined when visibility is "public".
2867
2867
  format: uri
2868
2868
  icon:
2869
- deprecated: true
2870
- description: URL of the icon of this space, if defined. Deprecated, prefer using emojis for spaces instead of icons.
2869
+ description: URL of the icon of this space, if defined.
2871
2870
  $ref: "#/components/schemas/URL"
2872
2871
  required:
2873
2872
  - app
@@ -2880,6 +2879,30 @@ components:
2880
2879
  description: ID of the parent collection.
2881
2880
  gitSync:
2882
2881
  $ref: "#/components/schemas/GitSyncState"
2882
+ visitorAuth:
2883
+ oneOf:
2884
+ - type: object
2885
+ properties:
2886
+ backend:
2887
+ type: string
2888
+ description: Custom backend for Visitor Authentication
2889
+ enum:
2890
+ - custom
2891
+ required:
2892
+ - backend
2893
+ - type: object
2894
+ properties:
2895
+ backend:
2896
+ type: string
2897
+ description: Integration as backend for Visitor Authentication
2898
+ enum:
2899
+ - integration
2900
+ integration:
2901
+ type: string
2902
+ description: Name of integration being used as the backend for Visitor Authentication
2903
+ required:
2904
+ - backend
2905
+ - integration
2883
2906
  required:
2884
2907
  - object
2885
2908
  - id
@@ -8670,14 +8693,43 @@ paths:
8670
8693
  content:
8671
8694
  application/json:
8672
8695
  schema:
8673
- type: object
8674
- properties:
8675
- editMode:
8676
- $ref: "#/components/schemas/SpaceEditMode"
8677
- title:
8678
- $ref: "#/components/schemas/SpaceTitle"
8679
- visibility:
8680
- $ref: "#/components/schemas/ContentVisibility"
8696
+ allOf:
8697
+ - type: object
8698
+ properties:
8699
+ editMode:
8700
+ $ref: "#/components/schemas/SpaceEditMode"
8701
+ title:
8702
+ $ref: "#/components/schemas/SpaceTitle"
8703
+ visibility:
8704
+ $ref: "#/components/schemas/ContentVisibility"
8705
+ visitorAuth:
8706
+ $ref: "#/components/schemas/Space/properties/visitorAuth"
8707
+ description: The integration property, if set, is ignored.
8708
+ - oneOf:
8709
+ - type: object
8710
+ properties:
8711
+ emoji:
8712
+ $ref: "#/components/schemas/Emoji"
8713
+ required:
8714
+ - emoji
8715
+ - type: object
8716
+ properties:
8717
+ icon:
8718
+ $ref: "#/components/schemas/URL"
8719
+ required:
8720
+ - icon
8721
+ - type: object
8722
+ properties:
8723
+ emoji:
8724
+ type: string
8725
+ nullable: true
8726
+ enum:
8727
+ - null
8728
+ icon:
8729
+ type: string
8730
+ nullable: true
8731
+ enum:
8732
+ - null
8681
8733
  responses:
8682
8734
  "200":
8683
8735
  description: The space has been updated