@gitbook/api 0.23.0 → 0.25.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
@@ -40,15 +40,28 @@ export interface EmojiReaction {
40
40
  export declare type EmojiReactions = EmojiReaction[];
41
41
  export interface RequestSpaceTrackPageView {
42
42
  /** Unique identifier of the page. */
43
- pageId: string;
43
+ pageId?: string;
44
44
  /** Analytics info on the GitBook's content visitor. */
45
45
  visitor: {
46
46
  /** GitBook's unique identifier of the visitor. */
47
47
  anonymousId: string;
48
48
  /** The visitors cookies. */
49
49
  cookies: Record<string, string>;
50
- /** User-agent of the visitor. */
50
+ /**
51
+ * IP address of the visitor.
52
+ * If undefined, it'll default to the IP executing the request.
53
+ */
54
+ ip?: string;
55
+ /**
56
+ * User-agent of the visitor.
57
+ * https://developer.mozilla.org/en-US/docs/Web/API/Navigator/userAgent
58
+ */
51
59
  userAgent: string;
60
+ /**
61
+ * Language of the visitor.
62
+ * https://developer.mozilla.org/en-US/docs/Web/API/Navigator/language
63
+ */
64
+ language?: string;
52
65
  };
53
66
  /** The GitBook content's URL visited (including URL params). */
54
67
  url: string;
@@ -971,6 +984,8 @@ export interface Space {
971
984
  * @maxLength 100
972
985
  */
973
986
  title: string;
987
+ /** An emoji for this space. It'll match the emoji shown in the GitBook app. */
988
+ emoji: Emoji;
974
989
  /**
975
990
  * * `public`: Anyone can access the content, and the content is indexed by search engines.
976
991
  * * `unlisted`: Anyone can access the content, and the content is not indexed by search engines
@@ -1006,6 +1021,11 @@ export interface Space {
1006
1021
  * @format uri
1007
1022
  */
1008
1023
  public?: string;
1024
+ /**
1025
+ * URL of the icon of this space, if defined. Deprecated, prefer using emojis for spaces instead of icons.
1026
+ * @deprecated
1027
+ */
1028
+ icon?: URL;
1009
1029
  };
1010
1030
  /** ID of the organization owning this space */
1011
1031
  organization: string;
@@ -1069,6 +1089,8 @@ export interface RevisionPageBase {
1069
1089
  * @maxLength 100
1070
1090
  */
1071
1091
  title: string;
1092
+ /** Emoji of the page, if one has been set. */
1093
+ emoji?: Emoji;
1072
1094
  /** When the page was first created. Only present if page has been edited at least once. */
1073
1095
  createdAt?: Date;
1074
1096
  /** When the page was last edited. Only present if page has been edited at least once. */
@@ -2581,6 +2603,8 @@ export declare type SpaceViewEvent = SpaceEvent & {
2581
2603
  userAgent: string;
2582
2604
  /** IP address of the visitor. */
2583
2605
  ip: string;
2606
+ /** Language of the visitor. */
2607
+ language?: string;
2584
2608
  };
2585
2609
  /** The GitBook content's URL visited (including URL params). */
2586
2610
  url: string;
@@ -4881,6 +4905,24 @@ export declare class Api<SecurityDataType extends unknown> extends HttpClient<Se
4881
4905
  createPageFeedback: (spaceId: string, pageId: string, visitorId: string, data: {
4882
4906
  rating: PageFeedbackRating;
4883
4907
  }, params?: RequestParams) => Promise<HttpResponse<PageFeedback, Error>>;
4908
+ /**
4909
+ * No description
4910
+ *
4911
+ * @tags spaces
4912
+ * @name GetSpacePdf
4913
+ * @summary Generate a URL to export the content of the space as a PDF.
4914
+ * @request GET:/spaces/{spaceId}/pdf
4915
+ * @secure
4916
+ */
4917
+ getSpacePdf: (spaceId: string, query?: {
4918
+ /** Generate a PDF only for the provided page. */
4919
+ only?: boolean;
4920
+ /** ID of a specific page to generate a PDF for. */
4921
+ page?: string;
4922
+ }, params?: RequestParams) => Promise<HttpResponse<{
4923
+ /** Temporary URL to print the content. The URL will work for 1h. */
4924
+ url: URL;
4925
+ }, Error>>;
4884
4926
  };
4885
4927
  collections: {
4886
4928
  /**
package/dist/index.cjs CHANGED
@@ -1216,6 +1216,14 @@ var Api = class extends HttpClient {
1216
1216
  type: "application/json" /* Json */,
1217
1217
  format: "json",
1218
1218
  ...params
1219
+ }),
1220
+ getSpacePdf: (spaceId, query, params = {}) => this.request({
1221
+ path: `/spaces/${spaceId}/pdf`,
1222
+ method: "GET",
1223
+ query,
1224
+ secure: true,
1225
+ format: "json",
1226
+ ...params
1219
1227
  })
1220
1228
  };
1221
1229
  this.collections = {
@@ -2109,6 +2117,7 @@ var GitBookAPI = class extends Api {
2109
2117
  }
2110
2118
  });
2111
2119
  this.endpoint = endpoint;
2120
+ this.authToken = authToken;
2112
2121
  this.setSecurityData({ authToken });
2113
2122
  }
2114
2123
  async createInstallationClient(integrationName, installationId) {
package/dist/index.d.ts CHANGED
@@ -6,7 +6,14 @@ export declare const GITBOOK_DEFAULT_ENDPOINT = "https://api.gitbook.com";
6
6
  export declare class GitBookAPI extends Api<{
7
7
  authToken?: string;
8
8
  }> {
9
- private endpoint;
9
+ /**
10
+ * Endpoint used by the API client.
11
+ */
12
+ readonly endpoint: string;
13
+ /**
14
+ * Authentication token used by the API client.
15
+ */
16
+ readonly authToken: string | undefined;
10
17
  constructor(options?: {
11
18
  /**
12
19
  * API endpoint to use.
package/dist/index.js CHANGED
@@ -1147,6 +1147,14 @@ var Api = class extends HttpClient {
1147
1147
  type: "application/json" /* Json */,
1148
1148
  format: "json",
1149
1149
  ...params
1150
+ }),
1151
+ getSpacePdf: (spaceId, query, params = {}) => this.request({
1152
+ path: `/spaces/${spaceId}/pdf`,
1153
+ method: "GET",
1154
+ query,
1155
+ secure: true,
1156
+ format: "json",
1157
+ ...params
1150
1158
  })
1151
1159
  };
1152
1160
  this.collections = {
@@ -2040,6 +2048,7 @@ var GitBookAPI = class extends Api {
2040
2048
  }
2041
2049
  });
2042
2050
  this.endpoint = endpoint;
2051
+ this.authToken = authToken;
2043
2052
  this.setSecurityData({ authToken });
2044
2053
  }
2045
2054
  async createInstallationClient(integrationName, installationId) {
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.23.0",
7
+ "version": "0.25.0",
8
8
  "sideEffects": false,
9
9
  "files": [
10
10
  "README.md",
package/spec/openapi.json CHANGED
@@ -463,9 +463,17 @@
463
463
  "type": "string"
464
464
  }
465
465
  },
466
+ "ip": {
467
+ "type": "string",
468
+ "description": "IP address of the visitor.\nIf undefined, it'll default to the IP executing the request.\n"
469
+ },
466
470
  "userAgent": {
467
471
  "type": "string",
468
- "description": "User-agent of the visitor."
472
+ "description": "User-agent of the visitor.\nhttps://developer.mozilla.org/en-US/docs/Web/API/Navigator/userAgent\n"
473
+ },
474
+ "language": {
475
+ "type": "string",
476
+ "description": "Language of the visitor.\nhttps://developer.mozilla.org/en-US/docs/Web/API/Navigator/language\n"
469
477
  }
470
478
  },
471
479
  "required": [
@@ -484,7 +492,6 @@
484
492
  }
485
493
  },
486
494
  "required": [
487
- "pageId",
488
495
  "visitor",
489
496
  "url",
490
497
  "referrer"
@@ -4293,6 +4300,10 @@
4293
4300
  "minLength": 0,
4294
4301
  "maxLength": 100
4295
4302
  },
4303
+ "emoji": {
4304
+ "description": "An emoji for this space. It'll match the emoji shown in the GitBook app.",
4305
+ "$ref": "#/components/schemas/Emoji"
4306
+ },
4296
4307
  "visibility": {
4297
4308
  "$ref": "#/components/schemas/ContentVisibility"
4298
4309
  },
@@ -4328,6 +4339,11 @@
4328
4339
  "type": "string",
4329
4340
  "description": "URL of the public version of the space. Only defined when visibility is \"public\".",
4330
4341
  "format": "uri"
4342
+ },
4343
+ "icon": {
4344
+ "deprecated": true,
4345
+ "description": "URL of the icon of this space, if defined. Deprecated, prefer using emojis for spaces instead of icons.",
4346
+ "$ref": "#/components/schemas/URL"
4331
4347
  }
4332
4348
  },
4333
4349
  "required": [
@@ -4352,6 +4368,7 @@
4352
4368
  "id",
4353
4369
  "type",
4354
4370
  "title",
4371
+ "emoji",
4355
4372
  "organization",
4356
4373
  "visibility",
4357
4374
  "createdAt",
@@ -4568,6 +4585,10 @@
4568
4585
  "type": "string",
4569
4586
  "maxLength": 100
4570
4587
  },
4588
+ "emoji": {
4589
+ "description": "Emoji of the page, if one has been set.",
4590
+ "$ref": "#/components/schemas/Emoji"
4591
+ },
4571
4592
  "createdAt": {
4572
4593
  "description": "When the page was first created. Only present if page has been edited at least once.",
4573
4594
  "$ref": "#/components/schemas/Date"
@@ -8804,6 +8825,10 @@
8804
8825
  "ip": {
8805
8826
  "type": "string",
8806
8827
  "description": "IP address of the visitor."
8828
+ },
8829
+ "language": {
8830
+ "type": "string",
8831
+ "description": "Language of the visitor."
8807
8832
  }
8808
8833
  },
8809
8834
  "required": [
@@ -16801,6 +16826,65 @@
16801
16826
  }
16802
16827
  }
16803
16828
  },
16829
+ "/spaces/{spaceId}/pdf": {
16830
+ "get": {
16831
+ "operationId": "getSpacePDF",
16832
+ "summary": "Generate a URL to export the content of the space as a PDF.",
16833
+ "tags": [
16834
+ "spaces"
16835
+ ],
16836
+ "security": [
16837
+ {
16838
+ "user": []
16839
+ }
16840
+ ],
16841
+ "parameters": [
16842
+ {
16843
+ "$ref": "#/components/parameters/spaceId"
16844
+ },
16845
+ {
16846
+ "in": "query",
16847
+ "name": "only",
16848
+ "description": "Generate a PDF only for the provided page.",
16849
+ "schema": {
16850
+ "type": "boolean"
16851
+ }
16852
+ },
16853
+ {
16854
+ "in": "query",
16855
+ "name": "page",
16856
+ "description": "ID of a specific page to generate a PDF for.",
16857
+ "schema": {
16858
+ "type": "string"
16859
+ }
16860
+ }
16861
+ ],
16862
+ "responses": {
16863
+ "200": {
16864
+ "description": "URL of the PDF",
16865
+ "content": {
16866
+ "application/json": {
16867
+ "schema": {
16868
+ "type": "object",
16869
+ "properties": {
16870
+ "url": {
16871
+ "description": "Temporary URL to print the content. The URL will work for 1h.",
16872
+ "$ref": "#/components/schemas/URL"
16873
+ }
16874
+ },
16875
+ "required": [
16876
+ "url"
16877
+ ]
16878
+ }
16879
+ }
16880
+ }
16881
+ },
16882
+ "default": {
16883
+ "$ref": "#/components/responses/UnexpectedError"
16884
+ }
16885
+ }
16886
+ }
16887
+ },
16804
16888
  "/collections/{collectionId}": {
16805
16889
  "get": {
16806
16890
  "operationId": "getCollectionById",
package/spec/openapi.yaml CHANGED
@@ -337,9 +337,21 @@ components:
337
337
  description: The visitors cookies.
338
338
  additionalProperties:
339
339
  type: string
340
+ ip:
341
+ type: string
342
+ description: |
343
+ IP address of the visitor.
344
+ If undefined, it'll default to the IP executing the request.
340
345
  userAgent:
341
346
  type: string
342
- description: User-agent of the visitor.
347
+ description: |
348
+ User-agent of the visitor.
349
+ https://developer.mozilla.org/en-US/docs/Web/API/Navigator/userAgent
350
+ language:
351
+ type: string
352
+ description: |
353
+ Language of the visitor.
354
+ https://developer.mozilla.org/en-US/docs/Web/API/Navigator/language
343
355
  required:
344
356
  - anonymousId
345
357
  - cookies
@@ -351,7 +363,6 @@ components:
351
363
  type: string
352
364
  description: The URL of referrer that linked to the page.
353
365
  required:
354
- - pageId
355
366
  - visitor
356
367
  - url
357
368
  - referrer
@@ -2800,6 +2811,9 @@ components:
2800
2811
  description: Title of the space
2801
2812
  minLength: 0
2802
2813
  maxLength: 100
2814
+ emoji:
2815
+ description: An emoji for this space. It'll match the emoji shown in the GitBook app.
2816
+ $ref: "#/components/schemas/Emoji"
2803
2817
  visibility:
2804
2818
  $ref: "#/components/schemas/ContentVisibility"
2805
2819
  createdAt:
@@ -2828,6 +2842,10 @@ components:
2828
2842
  type: string
2829
2843
  description: URL of the public version of the space. Only defined when visibility is "public".
2830
2844
  format: uri
2845
+ icon:
2846
+ deprecated: true
2847
+ description: URL of the icon of this space, if defined. Deprecated, prefer using emojis for spaces instead of icons.
2848
+ $ref: "#/components/schemas/URL"
2831
2849
  required:
2832
2850
  - app
2833
2851
  - location
@@ -2844,6 +2862,7 @@ components:
2844
2862
  - id
2845
2863
  - type
2846
2864
  - title
2865
+ - emoji
2847
2866
  - organization
2848
2867
  - visibility
2849
2868
  - createdAt
@@ -2976,6 +2995,9 @@ components:
2976
2995
  description: Title of the page
2977
2996
  type: string
2978
2997
  maxLength: 100
2998
+ emoji:
2999
+ description: Emoji of the page, if one has been set.
3000
+ $ref: "#/components/schemas/Emoji"
2979
3001
  createdAt:
2980
3002
  description: When the page was first created. Only present if page has been edited at least once.
2981
3003
  $ref: "#/components/schemas/Date"
@@ -5842,6 +5864,9 @@ components:
5842
5864
  ip:
5843
5865
  type: string
5844
5866
  description: IP address of the visitor.
5867
+ language:
5868
+ type: string
5869
+ description: Language of the visitor.
5845
5870
  required:
5846
5871
  - anonymousId
5847
5872
  - cookies
@@ -10600,6 +10625,41 @@ paths:
10600
10625
  $ref: "#/components/schemas/PageFeedback"
10601
10626
  default:
10602
10627
  $ref: "#/components/responses/UnexpectedError"
10628
+ "/spaces/{spaceId}/pdf":
10629
+ get:
10630
+ operationId: getSpacePDF
10631
+ summary: Generate a URL to export the content of the space as a PDF.
10632
+ tags:
10633
+ - spaces
10634
+ security:
10635
+ - user: []
10636
+ parameters:
10637
+ - $ref: "#/components/parameters/spaceId"
10638
+ - in: query
10639
+ name: only
10640
+ description: Generate a PDF only for the provided page.
10641
+ schema:
10642
+ type: boolean
10643
+ - in: query
10644
+ name: page
10645
+ description: ID of a specific page to generate a PDF for.
10646
+ schema:
10647
+ type: string
10648
+ responses:
10649
+ "200":
10650
+ description: URL of the PDF
10651
+ content:
10652
+ application/json:
10653
+ schema:
10654
+ type: object
10655
+ properties:
10656
+ url:
10657
+ description: Temporary URL to print the content. The URL will work for 1h.
10658
+ $ref: "#/components/schemas/URL"
10659
+ required:
10660
+ - url
10661
+ default:
10662
+ $ref: "#/components/responses/UnexpectedError"
10603
10663
  "/collections/{collectionId}":
10604
10664
  get:
10605
10665
  operationId: getCollectionById