newscatcher-catchall-sdk 0.1.0 → 0.2.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.
Files changed (112) hide show
  1. package/dist/cjs/BaseClient.d.ts +12 -4
  2. package/dist/cjs/BaseClient.js +14 -2
  3. package/dist/cjs/Client.d.ts +3 -3
  4. package/dist/cjs/Client.js +1 -1
  5. package/dist/cjs/api/errors/ForbiddenError.js +5 -1
  6. package/dist/cjs/api/errors/NotFoundError.js +5 -1
  7. package/dist/cjs/api/errors/UnprocessableEntityError.js +5 -1
  8. package/dist/cjs/api/resources/jobs/client/Client.d.ts +5 -7
  9. package/dist/cjs/api/resources/jobs/client/Client.js +16 -74
  10. package/dist/cjs/api/resources/jobs/client/requests/SubmitRequestDto.d.ts +2 -3
  11. package/dist/cjs/api/resources/meta/client/Client.d.ts +3 -4
  12. package/dist/cjs/api/resources/meta/client/Client.js +5 -38
  13. package/dist/cjs/api/resources/monitors/client/Client.d.ts +11 -6
  14. package/dist/cjs/api/resources/monitors/client/Client.js +28 -105
  15. package/dist/cjs/api/resources/monitors/client/requests/CreateMonitorRequestDto.d.ts +2 -5
  16. package/dist/cjs/api/types/ListUserJobsResponseDto.d.ts +4 -0
  17. package/dist/cjs/api/types/MonitorCitation.d.ts +2 -0
  18. package/dist/cjs/api/types/MonitorListItemDto.d.ts +5 -0
  19. package/dist/cjs/api/types/PullJobResponseDto.d.ts +5 -0
  20. package/dist/cjs/api/types/Schema.d.ts +1 -1
  21. package/dist/cjs/api/types/WebhookPayload.d.ts +2 -4
  22. package/dist/cjs/auth/HeaderAuthProvider.d.ts +16 -0
  23. package/dist/cjs/auth/HeaderAuthProvider.js +71 -0
  24. package/dist/cjs/auth/index.d.ts +1 -0
  25. package/dist/cjs/auth/index.js +5 -0
  26. package/dist/cjs/core/auth/AuthProvider.d.ts +7 -0
  27. package/dist/cjs/core/auth/AuthProvider.js +2 -0
  28. package/dist/cjs/core/auth/AuthRequest.d.ts +9 -0
  29. package/dist/cjs/core/auth/AuthRequest.js +2 -0
  30. package/dist/cjs/core/auth/BasicAuth.d.ts +8 -0
  31. package/dist/cjs/core/auth/BasicAuth.js +27 -0
  32. package/dist/cjs/core/auth/BearerToken.d.ts +7 -0
  33. package/dist/cjs/core/auth/BearerToken.js +16 -0
  34. package/dist/cjs/core/auth/NoOpAuthProvider.d.ts +5 -0
  35. package/dist/cjs/core/auth/NoOpAuthProvider.js +9 -0
  36. package/dist/cjs/core/auth/index.d.ts +5 -0
  37. package/dist/cjs/core/auth/index.js +9 -0
  38. package/dist/cjs/core/base64.d.ts +2 -0
  39. package/dist/cjs/core/base64.js +26 -0
  40. package/dist/cjs/core/fetcher/BinaryResponse.d.ts +6 -7
  41. package/dist/cjs/core/fetcher/Fetcher.d.ts +5 -1
  42. package/dist/cjs/core/fetcher/Fetcher.js +2 -1
  43. package/dist/cjs/core/fetcher/getResponseBody.js +18 -4
  44. package/dist/cjs/core/fetcher/signals.d.ts +1 -1
  45. package/dist/cjs/core/index.d.ts +2 -0
  46. package/dist/cjs/core/index.js +2 -0
  47. package/dist/cjs/core/runtime/runtime.js +11 -10
  48. package/dist/cjs/errors/CatchAllApiError.js +5 -1
  49. package/dist/cjs/errors/CatchAllApiTimeoutError.js +5 -1
  50. package/dist/cjs/errors/handleNonStatusCodeError.d.ts +2 -0
  51. package/dist/cjs/errors/handleNonStatusCodeError.js +65 -0
  52. package/dist/cjs/version.d.ts +1 -1
  53. package/dist/cjs/version.js +1 -1
  54. package/dist/esm/BaseClient.d.mts +12 -4
  55. package/dist/esm/BaseClient.mjs +13 -2
  56. package/dist/esm/Client.d.mts +3 -3
  57. package/dist/esm/Client.mjs +2 -2
  58. package/dist/esm/api/errors/ForbiddenError.mjs +5 -1
  59. package/dist/esm/api/errors/NotFoundError.mjs +5 -1
  60. package/dist/esm/api/errors/UnprocessableEntityError.mjs +5 -1
  61. package/dist/esm/api/resources/jobs/client/Client.d.mts +5 -7
  62. package/dist/esm/api/resources/jobs/client/Client.mjs +18 -76
  63. package/dist/esm/api/resources/jobs/client/requests/SubmitRequestDto.d.mts +2 -3
  64. package/dist/esm/api/resources/meta/client/Client.d.mts +3 -4
  65. package/dist/esm/api/resources/meta/client/Client.mjs +6 -39
  66. package/dist/esm/api/resources/monitors/client/Client.d.mts +11 -6
  67. package/dist/esm/api/resources/monitors/client/Client.mjs +30 -107
  68. package/dist/esm/api/resources/monitors/client/requests/CreateMonitorRequestDto.d.mts +2 -5
  69. package/dist/esm/api/types/ListUserJobsResponseDto.d.mts +4 -0
  70. package/dist/esm/api/types/MonitorCitation.d.mts +2 -0
  71. package/dist/esm/api/types/MonitorListItemDto.d.mts +5 -0
  72. package/dist/esm/api/types/PullJobResponseDto.d.mts +5 -0
  73. package/dist/esm/api/types/Schema.d.mts +1 -1
  74. package/dist/esm/api/types/WebhookPayload.d.mts +2 -4
  75. package/dist/esm/auth/HeaderAuthProvider.d.mts +16 -0
  76. package/dist/esm/auth/HeaderAuthProvider.mjs +34 -0
  77. package/dist/esm/auth/index.d.mts +1 -0
  78. package/dist/esm/auth/index.mjs +1 -0
  79. package/dist/esm/core/auth/AuthProvider.d.mts +7 -0
  80. package/dist/esm/core/auth/AuthProvider.mjs +1 -0
  81. package/dist/esm/core/auth/AuthRequest.d.mts +9 -0
  82. package/dist/esm/core/auth/AuthRequest.mjs +1 -0
  83. package/dist/esm/core/auth/BasicAuth.d.mts +8 -0
  84. package/dist/esm/core/auth/BasicAuth.mjs +24 -0
  85. package/dist/esm/core/auth/BearerToken.d.mts +7 -0
  86. package/dist/esm/core/auth/BearerToken.mjs +13 -0
  87. package/dist/esm/core/auth/NoOpAuthProvider.d.mts +5 -0
  88. package/dist/esm/core/auth/NoOpAuthProvider.mjs +5 -0
  89. package/dist/esm/core/auth/index.d.mts +5 -0
  90. package/dist/esm/core/auth/index.mjs +3 -0
  91. package/dist/esm/core/base64.d.mts +2 -0
  92. package/dist/esm/core/base64.mjs +22 -0
  93. package/dist/esm/core/fetcher/BinaryResponse.d.mts +6 -7
  94. package/dist/esm/core/fetcher/Fetcher.d.mts +5 -1
  95. package/dist/esm/core/fetcher/Fetcher.mjs +2 -1
  96. package/dist/esm/core/fetcher/getResponseBody.mjs +18 -4
  97. package/dist/esm/core/fetcher/signals.d.mts +1 -1
  98. package/dist/esm/core/index.d.mts +2 -0
  99. package/dist/esm/core/index.mjs +2 -0
  100. package/dist/esm/core/runtime/runtime.mjs +11 -10
  101. package/dist/esm/errors/CatchAllApiError.mjs +5 -1
  102. package/dist/esm/errors/CatchAllApiTimeoutError.mjs +5 -1
  103. package/dist/esm/errors/handleNonStatusCodeError.d.mts +2 -0
  104. package/dist/esm/errors/handleNonStatusCodeError.mjs +29 -0
  105. package/dist/esm/version.d.mts +1 -1
  106. package/dist/esm/version.mjs +1 -1
  107. package/package.json +5 -2
  108. package/reference.md +10 -5
  109. package/dist/cjs/core/fetcher/ResponseWithBody.d.ts +0 -4
  110. package/dist/cjs/core/fetcher/ResponseWithBody.js +0 -6
  111. package/dist/esm/core/fetcher/ResponseWithBody.d.mts +0 -4
  112. package/dist/esm/core/fetcher/ResponseWithBody.mjs +0 -3
@@ -212,9 +212,10 @@ function fetcherImpl(args) {
212
212
  };
213
213
  logger.debug("HTTP request succeeded", metadata);
214
214
  }
215
+ const body = yield (0, getResponseBody_js_1.getResponseBody)(response, args.responseType);
215
216
  return {
216
217
  ok: true,
217
- body: (yield (0, getResponseBody_js_1.getResponseBody)(response, args.responseType)),
218
+ body: body,
218
219
  headers: response.headers,
219
220
  rawResponse: (0, RawResponse_js_1.toRawResponse)(response),
220
221
  };
@@ -12,12 +12,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.getResponseBody = getResponseBody;
13
13
  const json_js_1 = require("../json.js");
14
14
  const BinaryResponse_js_1 = require("./BinaryResponse.js");
15
- const ResponseWithBody_js_1 = require("./ResponseWithBody.js");
16
15
  function getResponseBody(response, responseType) {
17
16
  return __awaiter(this, void 0, void 0, function* () {
18
- if (!(0, ResponseWithBody_js_1.isResponseWithBody)(response)) {
19
- return undefined;
20
- }
21
17
  switch (responseType) {
22
18
  case "binary-response":
23
19
  return (0, BinaryResponse_js_1.getBinaryResponse)(response);
@@ -26,8 +22,26 @@ function getResponseBody(response, responseType) {
26
22
  case "arrayBuffer":
27
23
  return yield response.arrayBuffer();
28
24
  case "sse":
25
+ if (response.body == null) {
26
+ return {
27
+ ok: false,
28
+ error: {
29
+ reason: "body-is-null",
30
+ statusCode: response.status,
31
+ },
32
+ };
33
+ }
29
34
  return response.body;
30
35
  case "streaming":
36
+ if (response.body == null) {
37
+ return {
38
+ ok: false,
39
+ error: {
40
+ reason: "body-is-null",
41
+ statusCode: response.status,
42
+ },
43
+ };
44
+ }
31
45
  return response.body;
32
46
  case "text":
33
47
  return yield response.text();
@@ -1,5 +1,5 @@
1
1
  export declare function getTimeoutSignal(timeoutMs: number): {
2
2
  signal: AbortSignal;
3
- abortId: NodeJS.Timeout;
3
+ abortId: ReturnType<typeof setTimeout>;
4
4
  };
5
5
  export declare function anySignal(...args: AbortSignal[] | [AbortSignal[]]): AbortSignal;
@@ -1,3 +1,5 @@
1
+ export * from "./auth/index.js";
2
+ export * from "./base64.js";
1
3
  export * from "./fetcher/index.js";
2
4
  export * as logging from "./logging/index.js";
3
5
  export * from "./runtime/index.js";
@@ -37,6 +37,8 @@ var __importStar = (this && this.__importStar) || (function () {
37
37
  })();
38
38
  Object.defineProperty(exports, "__esModule", { value: true });
39
39
  exports.url = exports.logging = void 0;
40
+ __exportStar(require("./auth/index.js"), exports);
41
+ __exportStar(require("./base64.js"), exports);
40
42
  __exportStar(require("./fetcher/index.js"), exports);
41
43
  exports.logging = __importStar(require("./logging/index.js"));
42
44
  __exportStar(require("./runtime/index.js"), exports);
@@ -71,6 +71,17 @@ function evaluateRuntime() {
71
71
  version: Bun.version,
72
72
  };
73
73
  }
74
+ /**
75
+ * A constant that indicates whether the environment the code is running is in React-Native.
76
+ * This check should come before Node.js detection since React Native may have a process polyfill.
77
+ * https://github.com/facebook/react-native/blob/main/packages/react-native/Libraries/Core/setUpNavigator.js
78
+ */
79
+ const isReactNative = typeof navigator !== "undefined" && (navigator === null || navigator === void 0 ? void 0 : navigator.product) === "ReactNative";
80
+ if (isReactNative) {
81
+ return {
82
+ type: "react-native",
83
+ };
84
+ }
74
85
  /**
75
86
  * A constant that indicates whether the environment the code is running is Node.JS.
76
87
  */
@@ -86,16 +97,6 @@ function evaluateRuntime() {
86
97
  parsedVersion: Number(process.versions.node.split(".")[0]),
87
98
  };
88
99
  }
89
- /**
90
- * A constant that indicates whether the environment the code is running is in React-Native.
91
- * https://github.com/facebook/react-native/blob/main/packages/react-native/Libraries/Core/setUpNavigator.js
92
- */
93
- const isReactNative = typeof navigator !== "undefined" && (navigator === null || navigator === void 0 ? void 0 : navigator.product) === "ReactNative";
94
- if (isReactNative) {
95
- return {
96
- type: "react-native",
97
- };
98
- }
99
100
  return {
100
101
  type: "unknown",
101
102
  };
@@ -6,7 +6,11 @@ const json_js_1 = require("../core/json.js");
6
6
  class CatchAllApiError extends Error {
7
7
  constructor({ message, statusCode, body, rawResponse, }) {
8
8
  super(buildMessage({ message, statusCode, body }));
9
- Object.setPrototypeOf(this, CatchAllApiError.prototype);
9
+ Object.setPrototypeOf(this, new.target.prototype);
10
+ if (Error.captureStackTrace) {
11
+ Error.captureStackTrace(this, this.constructor);
12
+ }
13
+ this.name = this.constructor.name;
10
14
  this.statusCode = statusCode;
11
15
  this.body = body;
12
16
  this.rawResponse = rawResponse;
@@ -5,7 +5,11 @@ exports.CatchAllApiTimeoutError = void 0;
5
5
  class CatchAllApiTimeoutError extends Error {
6
6
  constructor(message) {
7
7
  super(message);
8
- Object.setPrototypeOf(this, CatchAllApiTimeoutError.prototype);
8
+ Object.setPrototypeOf(this, new.target.prototype);
9
+ if (Error.captureStackTrace) {
10
+ Error.captureStackTrace(this, this.constructor);
11
+ }
12
+ this.name = this.constructor.name;
9
13
  }
10
14
  }
11
15
  exports.CatchAllApiTimeoutError = CatchAllApiTimeoutError;
@@ -0,0 +1,2 @@
1
+ import type * as core from "../core/index.js";
2
+ export declare function handleNonStatusCodeError(error: core.Fetcher.Error, rawResponse: core.RawResponse, method: string, path: string): never;
@@ -0,0 +1,65 @@
1
+ "use strict";
2
+ // This file was auto-generated by Fern from our API Definition.
3
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
4
+ if (k2 === undefined) k2 = k;
5
+ var desc = Object.getOwnPropertyDescriptor(m, k);
6
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
7
+ desc = { enumerable: true, get: function() { return m[k]; } };
8
+ }
9
+ Object.defineProperty(o, k2, desc);
10
+ }) : (function(o, m, k, k2) {
11
+ if (k2 === undefined) k2 = k;
12
+ o[k2] = m[k];
13
+ }));
14
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
15
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
16
+ }) : function(o, v) {
17
+ o["default"] = v;
18
+ });
19
+ var __importStar = (this && this.__importStar) || (function () {
20
+ var ownKeys = function(o) {
21
+ ownKeys = Object.getOwnPropertyNames || function (o) {
22
+ var ar = [];
23
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
24
+ return ar;
25
+ };
26
+ return ownKeys(o);
27
+ };
28
+ return function (mod) {
29
+ if (mod && mod.__esModule) return mod;
30
+ var result = {};
31
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
32
+ __setModuleDefault(result, mod);
33
+ return result;
34
+ };
35
+ })();
36
+ Object.defineProperty(exports, "__esModule", { value: true });
37
+ exports.handleNonStatusCodeError = handleNonStatusCodeError;
38
+ const errors = __importStar(require("./index.js"));
39
+ function handleNonStatusCodeError(error, rawResponse, method, path) {
40
+ switch (error.reason) {
41
+ case "non-json":
42
+ throw new errors.CatchAllApiError({
43
+ statusCode: error.statusCode,
44
+ body: error.rawBody,
45
+ rawResponse: rawResponse,
46
+ });
47
+ case "body-is-null":
48
+ throw new errors.CatchAllApiError({
49
+ statusCode: error.statusCode,
50
+ rawResponse: rawResponse,
51
+ });
52
+ case "timeout":
53
+ throw new errors.CatchAllApiTimeoutError(`Timeout exceeded when calling ${method} ${path}.`);
54
+ case "unknown":
55
+ throw new errors.CatchAllApiError({
56
+ message: error.errorMessage,
57
+ rawResponse: rawResponse,
58
+ });
59
+ default:
60
+ throw new errors.CatchAllApiError({
61
+ message: "Unknown error",
62
+ rawResponse: rawResponse,
63
+ });
64
+ }
65
+ }
@@ -1 +1 @@
1
- export declare const SDK_VERSION = "0.1.0";
1
+ export declare const SDK_VERSION = "0.2.0";
@@ -1,4 +1,4 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.SDK_VERSION = void 0;
4
- exports.SDK_VERSION = "0.1.0";
4
+ exports.SDK_VERSION = "0.2.0";
@@ -1,10 +1,10 @@
1
+ import { HeaderAuthProvider } from "./auth/HeaderAuthProvider.mjs";
1
2
  import * as core from "./core/index.mjs";
2
3
  import type * as environments from "./environments.mjs";
3
- export interface BaseClientOptions {
4
+ export type BaseClientOptions = {
4
5
  environment?: core.Supplier<environments.CatchAllApiEnvironment | string>;
5
6
  /** Specify a custom URL to connect the client to. */
6
7
  baseUrl?: core.Supplier<string>;
7
- apiKey?: core.Supplier<string | undefined>;
8
8
  /** Additional headers to include in requests. */
9
9
  headers?: Record<string, string | core.Supplier<string | null | undefined> | null | undefined>;
10
10
  /** The default maximum time to wait for a response in seconds. */
@@ -15,7 +15,7 @@ export interface BaseClientOptions {
15
15
  fetch?: typeof fetch;
16
16
  /** Configure logging for the client. */
17
17
  logging?: core.logging.LogConfig | core.logging.Logger;
18
- }
18
+ } & HeaderAuthProvider.AuthOptions;
19
19
  export interface BaseRequestOptions {
20
20
  /** The maximum time to wait for a response in seconds. */
21
21
  timeoutInSeconds?: number;
@@ -28,4 +28,12 @@ export interface BaseRequestOptions {
28
28
  /** Additional headers to include in the request. */
29
29
  headers?: Record<string, string | core.Supplier<string | null | undefined> | null | undefined>;
30
30
  }
31
- export declare function normalizeClientOptions<T extends BaseClientOptions>(options: T): T;
31
+ export type NormalizedClientOptions<T extends BaseClientOptions = BaseClientOptions> = T & {
32
+ logging: core.logging.Logger;
33
+ authProvider?: core.AuthProvider;
34
+ };
35
+ export type NormalizedClientOptionsWithAuth<T extends BaseClientOptions = BaseClientOptions> = NormalizedClientOptions<T> & {
36
+ authProvider: core.AuthProvider;
37
+ };
38
+ export declare function normalizeClientOptions<T extends BaseClientOptions = BaseClientOptions>(options: T): NormalizedClientOptions<T>;
39
+ export declare function normalizeClientOptionsWithAuth<T extends BaseClientOptions = BaseClientOptions>(options: T): NormalizedClientOptionsWithAuth<T>;
@@ -1,14 +1,25 @@
1
1
  // This file was auto-generated by Fern from our API Definition.
2
+ import { HeaderAuthProvider } from "./auth/HeaderAuthProvider.mjs";
2
3
  import { mergeHeaders } from "./core/headers.mjs";
3
4
  import * as core from "./core/index.mjs";
4
5
  export function normalizeClientOptions(options) {
5
6
  const headers = mergeHeaders({
6
7
  "X-Fern-Language": "JavaScript",
7
8
  "X-Fern-SDK-Name": "newscatcher-catchall-sdk",
8
- "X-Fern-SDK-Version": "0.1.0",
9
- "User-Agent": "newscatcher-catchall-sdk/0.1.0",
9
+ "X-Fern-SDK-Version": "0.2.0",
10
+ "User-Agent": "newscatcher-catchall-sdk/0.2.0",
10
11
  "X-Fern-Runtime": core.RUNTIME.type,
11
12
  "X-Fern-Runtime-Version": core.RUNTIME.version,
12
13
  }, options === null || options === void 0 ? void 0 : options.headers);
13
14
  return Object.assign(Object.assign({}, options), { logging: core.logging.createLogger(options === null || options === void 0 ? void 0 : options.logging), headers });
14
15
  }
16
+ export function normalizeClientOptionsWithAuth(options) {
17
+ var _a;
18
+ const normalized = normalizeClientOptions(options);
19
+ const normalizedWithNoOpAuthProvider = withNoOpAuthProvider(normalized);
20
+ (_a = normalized.authProvider) !== null && _a !== void 0 ? _a : (normalized.authProvider = new HeaderAuthProvider(normalizedWithNoOpAuthProvider));
21
+ return normalized;
22
+ }
23
+ function withNoOpAuthProvider(options) {
24
+ return Object.assign(Object.assign({}, options), { authProvider: new core.NoOpAuthProvider() });
25
+ }
@@ -2,14 +2,14 @@ import { JobsClient } from "./api/resources/jobs/client/Client.mjs";
2
2
  import { MetaClient } from "./api/resources/meta/client/Client.mjs";
3
3
  import { MonitorsClient } from "./api/resources/monitors/client/Client.mjs";
4
4
  import type { BaseClientOptions, BaseRequestOptions } from "./BaseClient.mjs";
5
+ import { type NormalizedClientOptionsWithAuth } from "./BaseClient.mjs";
5
6
  export declare namespace CatchAllApiClient {
6
- interface Options extends BaseClientOptions {
7
- }
7
+ type Options = BaseClientOptions;
8
8
  interface RequestOptions extends BaseRequestOptions {
9
9
  }
10
10
  }
11
11
  export declare class CatchAllApiClient {
12
- protected readonly _options: CatchAllApiClient.Options;
12
+ protected readonly _options: NormalizedClientOptionsWithAuth<CatchAllApiClient.Options>;
13
13
  protected _jobs: JobsClient | undefined;
14
14
  protected _monitors: MonitorsClient | undefined;
15
15
  protected _meta: MetaClient | undefined;
@@ -2,10 +2,10 @@
2
2
  import { JobsClient } from "./api/resources/jobs/client/Client.mjs";
3
3
  import { MetaClient } from "./api/resources/meta/client/Client.mjs";
4
4
  import { MonitorsClient } from "./api/resources/monitors/client/Client.mjs";
5
- import { normalizeClientOptions } from "./BaseClient.mjs";
5
+ import { normalizeClientOptionsWithAuth } from "./BaseClient.mjs";
6
6
  export class CatchAllApiClient {
7
7
  constructor(options = {}) {
8
- this._options = normalizeClientOptions(options);
8
+ this._options = normalizeClientOptionsWithAuth(options);
9
9
  }
10
10
  get jobs() {
11
11
  var _a;
@@ -8,6 +8,10 @@ export class ForbiddenError extends errors.CatchAllApiError {
8
8
  body: body,
9
9
  rawResponse: rawResponse,
10
10
  });
11
- Object.setPrototypeOf(this, ForbiddenError.prototype);
11
+ Object.setPrototypeOf(this, new.target.prototype);
12
+ if (Error.captureStackTrace) {
13
+ Error.captureStackTrace(this, this.constructor);
14
+ }
15
+ this.name = this.constructor.name;
12
16
  }
13
17
  }
@@ -8,6 +8,10 @@ export class NotFoundError extends errors.CatchAllApiError {
8
8
  body: body,
9
9
  rawResponse: rawResponse,
10
10
  });
11
- Object.setPrototypeOf(this, NotFoundError.prototype);
11
+ Object.setPrototypeOf(this, new.target.prototype);
12
+ if (Error.captureStackTrace) {
13
+ Error.captureStackTrace(this, this.constructor);
14
+ }
15
+ this.name = this.constructor.name;
12
16
  }
13
17
  }
@@ -8,6 +8,10 @@ export class UnprocessableEntityError extends errors.CatchAllApiError {
8
8
  body: body,
9
9
  rawResponse: rawResponse,
10
10
  });
11
- Object.setPrototypeOf(this, UnprocessableEntityError.prototype);
11
+ Object.setPrototypeOf(this, new.target.prototype);
12
+ if (Error.captureStackTrace) {
13
+ Error.captureStackTrace(this, this.constructor);
14
+ }
15
+ this.name = this.constructor.name;
12
16
  }
13
17
  }
@@ -1,9 +1,9 @@
1
1
  import type { BaseClientOptions, BaseRequestOptions } from "../../../../BaseClient.mjs";
2
+ import { type NormalizedClientOptionsWithAuth } from "../../../../BaseClient.mjs";
2
3
  import * as core from "../../../../core/index.mjs";
3
4
  import * as CatchAllApi from "../../../index.mjs";
4
5
  export declare namespace JobsClient {
5
- interface Options extends BaseClientOptions {
6
- }
6
+ type Options = BaseClientOptions;
7
7
  interface RequestOptions extends BaseRequestOptions {
8
8
  }
9
9
  }
@@ -11,7 +11,7 @@ export declare namespace JobsClient {
11
11
  * Operations to create, monitor, and retrieve job results.
12
12
  */
13
13
  export declare class JobsClient {
14
- protected readonly _options: JobsClient.Options;
14
+ protected readonly _options: NormalizedClientOptionsWithAuth<JobsClient.Options>;
15
15
  constructor(options?: JobsClient.Options);
16
16
  /**
17
17
  * Submit a natural language query to create a new processing job.
@@ -24,9 +24,8 @@ export declare class JobsClient {
24
24
  *
25
25
  * @example
26
26
  * await client.jobs.createJob({
27
- * query: "Tech company earnings this quarter",
28
- * schema: "Company [NAME] earned [REVENUE] in [QUARTER]",
29
- * context: "Focus on revenue and profit margins"
27
+ * query: "AI company acquisitions",
28
+ * context: "Focus on deal size and acquiring company details"
30
29
  * })
31
30
  */
32
31
  createJob(request: CatchAllApi.SubmitRequestDto, requestOptions?: JobsClient.RequestOptions): core.HttpResponsePromise<CatchAllApi.SubmitResponseBody>;
@@ -73,5 +72,4 @@ export declare class JobsClient {
73
72
  */
74
73
  getJobResults(request: CatchAllApi.GetJobResultsRequest, requestOptions?: JobsClient.RequestOptions): core.HttpResponsePromise<CatchAllApi.PullJobResponseDto>;
75
74
  private __getJobResults;
76
- protected _getCustomAuthorizationHeaders(): Promise<Record<string, string | undefined>>;
77
75
  }
@@ -8,10 +8,11 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
8
8
  step((generator = generator.apply(thisArg, _arguments || [])).next());
9
9
  });
10
10
  };
11
- import { normalizeClientOptions } from "../../../../BaseClient.mjs";
12
- import { mergeHeaders, mergeOnlyDefinedHeaders } from "../../../../core/headers.mjs";
11
+ import { normalizeClientOptionsWithAuth } from "../../../../BaseClient.mjs";
12
+ import { mergeHeaders } from "../../../../core/headers.mjs";
13
13
  import * as core from "../../../../core/index.mjs";
14
14
  import * as environments from "../../../../environments.mjs";
15
+ import { handleNonStatusCodeError } from "../../../../errors/handleNonStatusCodeError.mjs";
15
16
  import * as errors from "../../../../errors/index.mjs";
16
17
  import * as CatchAllApi from "../../../index.mjs";
17
18
  /**
@@ -19,7 +20,7 @@ import * as CatchAllApi from "../../../index.mjs";
19
20
  */
20
21
  export class JobsClient {
21
22
  constructor(options = {}) {
22
- this._options = normalizeClientOptions(options);
23
+ this._options = normalizeClientOptionsWithAuth(options);
23
24
  }
24
25
  /**
25
26
  * Submit a natural language query to create a new processing job.
@@ -32,9 +33,8 @@ export class JobsClient {
32
33
  *
33
34
  * @example
34
35
  * await client.jobs.createJob({
35
- * query: "Tech company earnings this quarter",
36
- * schema: "Company [NAME] earned [REVENUE] in [QUARTER]",
37
- * context: "Focus on revenue and profit margins"
36
+ * query: "AI company acquisitions",
37
+ * context: "Focus on deal size and acquiring company details"
38
38
  * })
39
39
  */
40
40
  createJob(request, requestOptions) {
@@ -43,7 +43,8 @@ export class JobsClient {
43
43
  __createJob(request, requestOptions) {
44
44
  return __awaiter(this, void 0, void 0, function* () {
45
45
  var _a, _b, _c, _d, _e, _f, _g, _h, _j;
46
- const _headers = mergeHeaders((_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, mergeOnlyDefinedHeaders(Object.assign({}, (yield this._getCustomAuthorizationHeaders()))), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
46
+ const _authRequest = yield this._options.authProvider.getAuthRequest();
47
+ const _headers = mergeHeaders(_authRequest.headers, (_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
47
48
  const _response = yield core.fetcher({
48
49
  url: core.url.join((_c = (_b = (yield core.Supplier.get(this._options.baseUrl))) !== null && _b !== void 0 ? _b : (yield core.Supplier.get(this._options.environment))) !== null && _c !== void 0 ? _c : environments.CatchAllApiEnvironment.Default, "catchAll/submit"),
49
50
  method: "POST",
@@ -75,21 +76,7 @@ export class JobsClient {
75
76
  });
76
77
  }
77
78
  }
78
- switch (_response.error.reason) {
79
- case "non-json":
80
- throw new errors.CatchAllApiError({
81
- statusCode: _response.error.statusCode,
82
- body: _response.error.rawBody,
83
- rawResponse: _response.rawResponse,
84
- });
85
- case "timeout":
86
- throw new errors.CatchAllApiTimeoutError("Timeout exceeded when calling POST /catchAll/submit.");
87
- case "unknown":
88
- throw new errors.CatchAllApiError({
89
- message: _response.error.errorMessage,
90
- rawResponse: _response.rawResponse,
91
- });
92
- }
79
+ return handleNonStatusCodeError(_response.error, _response.rawResponse, "POST", "/catchAll/submit");
93
80
  });
94
81
  }
95
82
  /**
@@ -113,7 +100,8 @@ export class JobsClient {
113
100
  return __awaiter(this, void 0, void 0, function* () {
114
101
  var _a, _b, _c, _d, _e, _f, _g, _h, _j;
115
102
  const { job_id: jobId } = request;
116
- const _headers = mergeHeaders((_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, mergeOnlyDefinedHeaders(Object.assign({}, (yield this._getCustomAuthorizationHeaders()))), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
103
+ const _authRequest = yield this._options.authProvider.getAuthRequest();
104
+ const _headers = mergeHeaders(_authRequest.headers, (_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
117
105
  const _response = yield core.fetcher({
118
106
  url: core.url.join((_c = (_b = (yield core.Supplier.get(this._options.baseUrl))) !== null && _b !== void 0 ? _b : (yield core.Supplier.get(this._options.environment))) !== null && _c !== void 0 ? _c : environments.CatchAllApiEnvironment.Default, `catchAll/status/${core.url.encodePathParam(jobId)}`),
119
107
  method: "GET",
@@ -142,21 +130,7 @@ export class JobsClient {
142
130
  });
143
131
  }
144
132
  }
145
- switch (_response.error.reason) {
146
- case "non-json":
147
- throw new errors.CatchAllApiError({
148
- statusCode: _response.error.statusCode,
149
- body: _response.error.rawBody,
150
- rawResponse: _response.rawResponse,
151
- });
152
- case "timeout":
153
- throw new errors.CatchAllApiTimeoutError("Timeout exceeded when calling GET /catchAll/status/{job_id}.");
154
- case "unknown":
155
- throw new errors.CatchAllApiError({
156
- message: _response.error.errorMessage,
157
- rawResponse: _response.rawResponse,
158
- });
159
- }
133
+ return handleNonStatusCodeError(_response.error, _response.rawResponse, "GET", "/catchAll/status/{job_id}");
160
134
  });
161
135
  }
162
136
  /**
@@ -173,7 +147,8 @@ export class JobsClient {
173
147
  __getUserJobs(requestOptions) {
174
148
  return __awaiter(this, void 0, void 0, function* () {
175
149
  var _a, _b, _c, _d, _e, _f, _g, _h, _j;
176
- const _headers = mergeHeaders((_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, mergeOnlyDefinedHeaders(Object.assign({}, (yield this._getCustomAuthorizationHeaders()))), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
150
+ const _authRequest = yield this._options.authProvider.getAuthRequest();
151
+ const _headers = mergeHeaders(_authRequest.headers, (_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
177
152
  const _response = yield core.fetcher({
178
153
  url: core.url.join((_c = (_b = (yield core.Supplier.get(this._options.baseUrl))) !== null && _b !== void 0 ? _b : (yield core.Supplier.get(this._options.environment))) !== null && _c !== void 0 ? _c : environments.CatchAllApiEnvironment.Default, "catchAll/jobs/user"),
179
154
  method: "GET",
@@ -198,21 +173,7 @@ export class JobsClient {
198
173
  rawResponse: _response.rawResponse,
199
174
  });
200
175
  }
201
- switch (_response.error.reason) {
202
- case "non-json":
203
- throw new errors.CatchAllApiError({
204
- statusCode: _response.error.statusCode,
205
- body: _response.error.rawBody,
206
- rawResponse: _response.rawResponse,
207
- });
208
- case "timeout":
209
- throw new errors.CatchAllApiTimeoutError("Timeout exceeded when calling GET /catchAll/jobs/user.");
210
- case "unknown":
211
- throw new errors.CatchAllApiError({
212
- message: _response.error.errorMessage,
213
- rawResponse: _response.rawResponse,
214
- });
215
- }
176
+ return handleNonStatusCodeError(_response.error, _response.rawResponse, "GET", "/catchAll/jobs/user");
216
177
  });
217
178
  }
218
179
  /**
@@ -243,7 +204,8 @@ export class JobsClient {
243
204
  if (pageSize != null) {
244
205
  _queryParams.page_size = pageSize.toString();
245
206
  }
246
- const _headers = mergeHeaders((_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, mergeOnlyDefinedHeaders(Object.assign({}, (yield this._getCustomAuthorizationHeaders()))), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
207
+ const _authRequest = yield this._options.authProvider.getAuthRequest();
208
+ const _headers = mergeHeaders(_authRequest.headers, (_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
247
209
  const _response = yield core.fetcher({
248
210
  url: core.url.join((_c = (_b = (yield core.Supplier.get(this._options.baseUrl))) !== null && _b !== void 0 ? _b : (yield core.Supplier.get(this._options.environment))) !== null && _c !== void 0 ? _c : environments.CatchAllApiEnvironment.Default, `catchAll/pull/${core.url.encodePathParam(jobId)}`),
249
211
  method: "GET",
@@ -272,27 +234,7 @@ export class JobsClient {
272
234
  });
273
235
  }
274
236
  }
275
- switch (_response.error.reason) {
276
- case "non-json":
277
- throw new errors.CatchAllApiError({
278
- statusCode: _response.error.statusCode,
279
- body: _response.error.rawBody,
280
- rawResponse: _response.rawResponse,
281
- });
282
- case "timeout":
283
- throw new errors.CatchAllApiTimeoutError("Timeout exceeded when calling GET /catchAll/pull/{job_id}.");
284
- case "unknown":
285
- throw new errors.CatchAllApiError({
286
- message: _response.error.errorMessage,
287
- rawResponse: _response.rawResponse,
288
- });
289
- }
290
- });
291
- }
292
- _getCustomAuthorizationHeaders() {
293
- return __awaiter(this, void 0, void 0, function* () {
294
- const apiKeyValue = yield core.Supplier.get(this._options.apiKey);
295
- return { "x-api-key": apiKeyValue };
237
+ return handleNonStatusCodeError(_response.error, _response.rawResponse, "GET", "/catchAll/pull/{job_id}");
296
238
  });
297
239
  }
298
240
  }
@@ -2,9 +2,8 @@ import type * as CatchAllApi from "../../../../index.mjs";
2
2
  /**
3
3
  * @example
4
4
  * {
5
- * query: "Tech company earnings this quarter",
6
- * schema: "Company [NAME] earned [REVENUE] in [QUARTER]",
7
- * context: "Focus on revenue and profit margins"
5
+ * query: "AI company acquisitions",
6
+ * context: "Focus on deal size and acquiring company details"
8
7
  * }
9
8
  */
10
9
  export interface SubmitRequestDto {
@@ -1,9 +1,9 @@
1
1
  import type { BaseClientOptions, BaseRequestOptions } from "../../../../BaseClient.mjs";
2
+ import { type NormalizedClientOptions } from "../../../../BaseClient.mjs";
2
3
  import * as core from "../../../../core/index.mjs";
3
4
  import type * as CatchAllApi from "../../../index.mjs";
4
5
  export declare namespace MetaClient {
5
- interface Options extends BaseClientOptions {
6
- }
6
+ type Options = BaseClientOptions;
7
7
  interface RequestOptions extends BaseRequestOptions {
8
8
  }
9
9
  }
@@ -11,7 +11,7 @@ export declare namespace MetaClient {
11
11
  * Operations to check API health and version.
12
12
  */
13
13
  export declare class MetaClient {
14
- protected readonly _options: MetaClient.Options;
14
+ protected readonly _options: NormalizedClientOptions<MetaClient.Options>;
15
15
  constructor(options?: MetaClient.Options);
16
16
  /**
17
17
  * Check API availability.
@@ -33,5 +33,4 @@ export declare class MetaClient {
33
33
  */
34
34
  getVersion(requestOptions?: MetaClient.RequestOptions): core.HttpResponsePromise<CatchAllApi.GetVersionResponse>;
35
35
  private __getVersion;
36
- protected _getCustomAuthorizationHeaders(): Promise<Record<string, string | undefined>>;
37
36
  }