@gitbook/api 0.147.0 → 0.148.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
@@ -172,23 +172,24 @@ var require_node = __commonJS({
172
172
 
173
173
  // package.json
174
174
  var name = "@gitbook/api";
175
- var version = "0.147.0";
175
+ var version = "0.148.0";
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
- 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
181
  var ParseError = class extends Error {
185
182
  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;
183
+ super(message), this.name = "ParseError", this.type = options.type, this.field = options.field, this.value = options.value, this.line = options.line;
187
184
  }
188
185
  };
189
186
  function noop(_arg) {
190
187
  }
191
188
  function createParser(callbacks) {
189
+ if (typeof callbacks == "function")
190
+ throw new TypeError(
191
+ "`callbacks` must be an object, got a function instead. Did you mean `{onEvent: fn}`?"
192
+ );
192
193
  const { onEvent = noop, onError = noop, onRetry = noop, onComment } = callbacks;
193
194
  let incompleteLine = "", isFirstChunk = true, id, data = "", eventType = "";
194
195
  function feed(newChunk) {
@@ -254,19 +255,25 @@ function createParser(callbacks) {
254
255
  }), id = void 0, data = "", eventType = "";
255
256
  }
256
257
  function reset(options = {}) {
257
- incompleteLine && options.consume && parseLine(incompleteLine), id = void 0, data = "", eventType = "", incompleteLine = "";
258
+ incompleteLine && options.consume && parseLine(incompleteLine), isFirstChunk = true, id = void 0, data = "", eventType = "", incompleteLine = "";
258
259
  }
259
260
  return { feed, reset };
260
261
  }
261
262
  function splitLines(chunk) {
262
263
  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;
264
+ let incompleteLine = "", searchIndex = 0;
265
+ for (; searchIndex < chunk.length; ) {
266
+ const crIndex = chunk.indexOf("\r", searchIndex), lfIndex = chunk.indexOf(`
267
+ `, searchIndex);
268
+ let lineEnd = -1;
269
+ if (crIndex !== -1 && lfIndex !== -1 ? lineEnd = Math.min(crIndex, lfIndex) : crIndex !== -1 ? crIndex === chunk.length - 1 ? lineEnd = -1 : lineEnd = crIndex : lfIndex !== -1 && (lineEnd = lfIndex), lineEnd === -1) {
270
+ incompleteLine = chunk.slice(searchIndex);
271
+ break;
272
+ } else {
273
+ const line = chunk.slice(searchIndex, lineEnd);
274
+ lines.push(line), searchIndex = lineEnd + 1, chunk[searchIndex - 1] === "\r" && chunk[searchIndex] === `
275
+ ` && searchIndex++;
276
+ }
270
277
  }
271
278
  return [lines, incompleteLine];
272
279
  }
@@ -686,13 +693,6 @@ var SAMLProviderStatus = /* @__PURE__ */ ((SAMLProviderStatus2) => {
686
693
  SAMLProviderStatus2["Pending"] = "pending";
687
694
  return SAMLProviderStatus2;
688
695
  })(SAMLProviderStatus || {});
689
- var AgentTaskStatus = /* @__PURE__ */ ((AgentTaskStatus2) => {
690
- AgentTaskStatus2["Backlog"] = "backlog";
691
- AgentTaskStatus2["Started"] = "started";
692
- AgentTaskStatus2["Completed"] = "completed";
693
- AgentTaskStatus2["Canceled"] = "canceled";
694
- return AgentTaskStatus2;
695
- })(AgentTaskStatus || {});
696
696
  var TranslationStatus = /* @__PURE__ */ ((TranslationStatus2) => {
697
697
  TranslationStatus2["Pending"] = "pending";
698
698
  TranslationStatus2["Running"] = "running";
@@ -1004,6 +1004,16 @@ var GitSyncOperationStage = /* @__PURE__ */ ((GitSyncOperationStage2) => {
1004
1004
  GitSyncOperationStage2["Finalize"] = "finalize";
1005
1005
  return GitSyncOperationStage2;
1006
1006
  })(GitSyncOperationStage || {});
1007
+ var BillingStatus = /* @__PURE__ */ ((BillingStatus2) => {
1008
+ BillingStatus2["Trialing"] = "trialing";
1009
+ BillingStatus2["Active"] = "active";
1010
+ BillingStatus2["PastDue"] = "past_due";
1011
+ BillingStatus2["IncompleteExpired"] = "incomplete_expired";
1012
+ BillingStatus2["Canceled"] = "canceled";
1013
+ BillingStatus2["Unpaid"] = "unpaid";
1014
+ BillingStatus2["Paused"] = "paused";
1015
+ return BillingStatus2;
1016
+ })(BillingStatus || {});
1007
1017
  var APIIntegrationScope = /* @__PURE__ */ ((APIIntegrationScope2) => {
1008
1018
  APIIntegrationScope2["IntegrationRead"] = "integration:read";
1009
1019
  APIIntegrationScope2["IntegrationUpdate"] = "integration:update";
@@ -2923,30 +2933,6 @@ var Api = class extends HttpClient {
2923
2933
  format: "json",
2924
2934
  ...params
2925
2935
  }),
2926
- listAgentTasks: (organizationId, query, params = {}) => this.request({
2927
- path: `/orgs/${organizationId}/agent-tasks`,
2928
- method: "GET",
2929
- query,
2930
- secure: true,
2931
- format: "json",
2932
- ...params
2933
- }),
2934
- getAgentTask: (organizationId, agentTaskId, params = {}) => this.request({
2935
- path: `/orgs/${organizationId}/agent-tasks/${agentTaskId}`,
2936
- method: "GET",
2937
- secure: true,
2938
- format: "json",
2939
- ...params
2940
- }),
2941
- updateAgentTask: (organizationId, agentTaskId, data, params = {}) => this.request({
2942
- path: `/orgs/${organizationId}/agent-tasks/${agentTaskId}`,
2943
- method: "PATCH",
2944
- body: data,
2945
- secure: true,
2946
- type: "application/json" /* Json */,
2947
- format: "json",
2948
- ...params
2949
- }),
2950
2936
  listTranslations: (organizationId, query, params = {}) => this.request({
2951
2937
  path: `/orgs/${organizationId}/translations`,
2952
2938
  method: "GET",
@@ -3803,7 +3789,6 @@ var SAMLPROVIDER_LABEL_MIN_LENGTH = 1;
3803
3789
  var SAMLPROVIDER_ENTITY_ID_MAX_LENGTH = 1024;
3804
3790
  var SAMLPROVIDER_CERTIFICATE_MAX_LENGTH = 1e4;
3805
3791
  var SAMLPROVIDER_STATUS_ENUM = ["active", "pending"];
3806
- var AGENT_TASK_STATUS_ENUM = ["backlog", "started", "completed", "canceled"];
3807
3792
  var TRANSLATION_STATUS_ENUM = ["pending", "running", "completed"];
3808
3793
  var STORAGE_UPLOAD_KIND_ENUM = ["customization_font", "import_file"];
3809
3794
  var FONT_FAMILY_MAX_LENGTH = 50;
@@ -3861,6 +3846,7 @@ var REVISION_SEMANTIC_CHANGE_TYPE_ENUM = ["page_created", "page_edited", "page_d
3861
3846
  var GIT_SYNC_OPERATION_STATE_ENUM = ["running", "failure", "success"];
3862
3847
  var GIT_SYNC_OPERATION_DIRECTION_ENUM = ["export", "import"];
3863
3848
  var GIT_SYNC_OPERATION_STAGE_ENUM = ["repo_fetch", "config_check", "content_process", "finalize"];
3849
+ var BILLING_STATUS_ENUM = ["trialing", "active", "past_due", "incomplete_expired", "canceled", "unpaid", "paused"];
3864
3850
  var APIINTEGRATION_SCOPE_ENUM = ["integration:read", "integration:update", "integration:installation:read", "integration:installation:update"];
3865
3851
  var SITE_ADS_STATUS_ENUM = ["pending", "in-review", "live", "rejected", "disabled"];
3866
3852
  var AIMESSAGE_ROLE_ENUM = ["user", "assistant", "developer"];
@@ -3935,7 +3921,6 @@ var GitBookAPI = class extends Api {
3935
3921
  };
3936
3922
  export {
3937
3923
  AGENT_STATUS_ENUM,
3938
- AGENT_TASK_STATUS_ENUM,
3939
3924
  AIMESSAGE_ROLE_ENUM,
3940
3925
  AIMODEL_ENUM,
3941
3926
  AIMessageRole,
@@ -3944,11 +3929,11 @@ export {
3944
3929
  APIIntegrationScope,
3945
3930
  APITOKEN_LABEL_MAX_LENGTH,
3946
3931
  AgentStatus,
3947
- AgentTaskStatus,
3948
3932
  Api,
3949
3933
  BILLING_INTERVAL_ENUM,
3950
3934
  BILLING_METER_ENUM,
3951
3935
  BILLING_PRODUCT_ENUM,
3936
+ BILLING_STATUS_ENUM,
3952
3937
  BILLING_SWITCH_ACTION_ENUM,
3953
3938
  BILLING_TRIAL_STATUS_ENUM,
3954
3939
  BLOCK_REASON_MAX_LENGTH,
@@ -3957,6 +3942,7 @@ export {
3957
3942
  BillingInterval,
3958
3943
  BillingMeter,
3959
3944
  BillingProduct,
3945
+ BillingStatus,
3960
3946
  BillingSwitchAction,
3961
3947
  BillingTrialStatus,
3962
3948
  BlockSource,
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.147.0",
7
+ "version": "0.148.0",
8
8
  "sideEffects": false,
9
9
  "files": [
10
10
  "README.md",