@convilyn/sdk 0.2.0 → 0.3.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/cli.js CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import { VERSION, AuthError, APIError, guessContentType, Convilyn, JobFailedError, JobTimeoutError, HttpClient, resolveAuth, isGoalEventTerminal, WebSocketError, DEFAULT_BASE_URL, GoalJobFailedError, GoalJobTimeoutError, PlanRequiredError, QuotaExceededError } from './chunk-UJHZKIP6.js';
2
+ import { VERSION, AuthError, APIError, guessContentType, Convilyn, JobFailedError, JobTimeoutError, HttpClient, resolveAuth, isGoalEventTerminal, WebSocketError, DEFAULT_BASE_URL, GoalJobFailedError, GoalJobTimeoutError, PlanRequiredError, QuotaExceededError } from './chunk-IBSN34ZI.js';
3
3
  import { Command, Option } from 'commander';
4
4
  import { statSync, readFileSync, writeFileSync } from 'fs';
5
5
  import { basename, parse, join } from 'path';
package/dist/index.cjs CHANGED
@@ -1,12 +1,18 @@
1
1
  'use strict';
2
2
 
3
3
  // src/errors.ts
4
+ var CONVILYN_ERROR_BRAND = /* @__PURE__ */ Symbol.for("@convilyn/sdk.ConvilynError");
4
5
  var ConvilynError = class extends Error {
6
+ /** @internal brand marker — see {@link isConvilynError} */
7
+ [CONVILYN_ERROR_BRAND] = true;
5
8
  constructor(message) {
6
9
  super(message);
7
10
  this.name = "ConvilynError";
8
11
  }
9
12
  };
13
+ function isConvilynError(err) {
14
+ return typeof err === "object" && err !== null && err[CONVILYN_ERROR_BRAND] === true;
15
+ }
10
16
  var AuthError = class extends ConvilynError {
11
17
  constructor(message) {
12
18
  super(message);
@@ -378,7 +384,7 @@ function resolveAuth(apiKey, options = {}) {
378
384
  }
379
385
 
380
386
  // src/version.ts
381
- var VERSION = "0.2.0";
387
+ var VERSION = "0.3.0";
382
388
 
383
389
  // src/internal/http.ts
384
390
  var DEFAULT_BASE_URL = "https://api.convilyn.corenovus.com";
@@ -1610,6 +1616,9 @@ var Convilyn = class {
1610
1616
  #http;
1611
1617
  constructor(options = {}) {
1612
1618
  const auth = options.auth ?? resolveAuth(options.apiKey);
1619
+ if (options.timeout !== void 0 && options.timeout <= 0) {
1620
+ throw new TypeError(`timeout must be a positive number of seconds (got ${options.timeout})`);
1621
+ }
1613
1622
  this.#http = new HttpClient({
1614
1623
  auth,
1615
1624
  baseUrl: options.baseUrl,
@@ -1641,7 +1650,10 @@ function resolveRetryPolicy(maxRetries, retryPolicy) {
1641
1650
  if (maxRetries == null) {
1642
1651
  return new ExponentialBackoffRetry();
1643
1652
  }
1644
- if (maxRetries <= 0) {
1653
+ if (maxRetries < 0) {
1654
+ throw new TypeError(`maxRetries must be >= 0 (got ${maxRetries})`);
1655
+ }
1656
+ if (maxRetries === 0) {
1645
1657
  return new NoRetry();
1646
1658
  }
1647
1659
  return new ExponentialBackoffRetry({ maxAttempts: maxRetries });
@@ -1671,6 +1683,7 @@ exports.VERSION = VERSION;
1671
1683
  exports.WebSocketError = WebSocketError;
1672
1684
  exports.goalJobNeedsInput = goalJobNeedsInput;
1673
1685
  exports.isConvertJobTerminal = isConvertJobTerminal;
1686
+ exports.isConvilynError = isConvilynError;
1674
1687
  exports.isGoalEventTerminal = isGoalEventTerminal;
1675
1688
  exports.isGoalEventType = isGoalEventType;
1676
1689
  exports.isGoalJobTerminal = isGoalJobTerminal;