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
@@ -9,9 +9,10 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
9
9
  });
10
10
  };
11
11
  import { normalizeClientOptions } from "../../../../BaseClient.mjs";
12
- import { mergeHeaders, mergeOnlyDefinedHeaders } from "../../../../core/headers.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
  /**
17
18
  * Operations to check API health and version.
@@ -34,7 +35,7 @@ export class MetaClient {
34
35
  __healthCheck(requestOptions) {
35
36
  return __awaiter(this, void 0, void 0, function* () {
36
37
  var _a, _b, _c, _d, _e, _f, _g, _h, _j;
37
- 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);
38
+ const _headers = mergeHeaders((_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
38
39
  const _response = yield core.fetcher({
39
40
  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, "health"),
40
41
  method: "GET",
@@ -56,21 +57,7 @@ export class MetaClient {
56
57
  rawResponse: _response.rawResponse,
57
58
  });
58
59
  }
59
- switch (_response.error.reason) {
60
- case "non-json":
61
- throw new errors.CatchAllApiError({
62
- statusCode: _response.error.statusCode,
63
- body: _response.error.rawBody,
64
- rawResponse: _response.rawResponse,
65
- });
66
- case "timeout":
67
- throw new errors.CatchAllApiTimeoutError("Timeout exceeded when calling GET /health.");
68
- case "unknown":
69
- throw new errors.CatchAllApiError({
70
- message: _response.error.errorMessage,
71
- rawResponse: _response.rawResponse,
72
- });
73
- }
60
+ return handleNonStatusCodeError(_response.error, _response.rawResponse, "GET", "/health");
74
61
  });
75
62
  }
76
63
  /**
@@ -87,7 +74,7 @@ export class MetaClient {
87
74
  __getVersion(requestOptions) {
88
75
  return __awaiter(this, void 0, void 0, function* () {
89
76
  var _a, _b, _c, _d, _e, _f, _g, _h, _j;
90
- 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);
77
+ const _headers = mergeHeaders((_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
91
78
  const _response = yield core.fetcher({
92
79
  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, "version"),
93
80
  method: "GET",
@@ -109,27 +96,7 @@ export class MetaClient {
109
96
  rawResponse: _response.rawResponse,
110
97
  });
111
98
  }
112
- switch (_response.error.reason) {
113
- case "non-json":
114
- throw new errors.CatchAllApiError({
115
- statusCode: _response.error.statusCode,
116
- body: _response.error.rawBody,
117
- rawResponse: _response.rawResponse,
118
- });
119
- case "timeout":
120
- throw new errors.CatchAllApiTimeoutError("Timeout exceeded when calling GET /version.");
121
- case "unknown":
122
- throw new errors.CatchAllApiError({
123
- message: _response.error.errorMessage,
124
- rawResponse: _response.rawResponse,
125
- });
126
- }
127
- });
128
- }
129
- _getCustomAuthorizationHeaders() {
130
- return __awaiter(this, void 0, void 0, function* () {
131
- const apiKeyValue = yield core.Supplier.get(this._options.apiKey);
132
- return { "x-api-key": apiKeyValue };
99
+ return handleNonStatusCodeError(_response.error, _response.rawResponse, "GET", "/version");
133
100
  });
134
101
  }
135
102
  }
@@ -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 MonitorsClient {
5
- interface Options extends BaseClientOptions {
6
- }
6
+ type Options = BaseClientOptions;
7
7
  interface RequestOptions extends BaseRequestOptions {
8
8
  }
9
9
  }
@@ -11,13 +11,19 @@ export declare namespace MonitorsClient {
11
11
  * Operations to create, operate and retrieve monitor results.
12
12
  */
13
13
  export declare class MonitorsClient {
14
- protected readonly _options: MonitorsClient.Options;
14
+ protected readonly _options: NormalizedClientOptionsWithAuth<MonitorsClient.Options>;
15
15
  constructor(options?: MonitorsClient.Options);
16
16
  /**
17
17
  * Create a monitor that runs jobs based on a reference job with a specified schedule.
18
18
  *
19
- * **Warning**: Schedule validation is limited. Invalid schedules may be parsed incorrectly.
20
- * Always test schedules before production use.
19
+ * **Schedule requirements:**
20
+ * - Minimum 24-hour interval between executions
21
+ * - Natural language format (e.g., "every day at 12 PM UTC", "every 48 hours")
22
+ *
23
+ * **Validation:**
24
+ * - Schedules below minimum frequency return error with descriptive message.
25
+ * - Invalid job IDs return 400 Bad Request.
26
+ * - Duplicate monitors (same job already monitored) return error.
21
27
  *
22
28
  * @param {CatchAllApi.CreateMonitorRequestDto} request
23
29
  * @param {MonitorsClient.RequestOptions} requestOptions - Request-specific configuration.
@@ -115,5 +121,4 @@ export declare class MonitorsClient {
115
121
  */
116
122
  listMonitors(requestOptions?: MonitorsClient.RequestOptions): core.HttpResponsePromise<CatchAllApi.ListMonitorsResponseDto>;
117
123
  private __listMonitors;
118
- protected _getCustomAuthorizationHeaders(): Promise<Record<string, string | undefined>>;
119
124
  }
@@ -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,13 +20,19 @@ import * as CatchAllApi from "../../../index.mjs";
19
20
  */
20
21
  export class MonitorsClient {
21
22
  constructor(options = {}) {
22
- this._options = normalizeClientOptions(options);
23
+ this._options = normalizeClientOptionsWithAuth(options);
23
24
  }
24
25
  /**
25
26
  * Create a monitor that runs jobs based on a reference job with a specified schedule.
26
27
  *
27
- * **Warning**: Schedule validation is limited. Invalid schedules may be parsed incorrectly.
28
- * Always test schedules before production use.
28
+ * **Schedule requirements:**
29
+ * - Minimum 24-hour interval between executions
30
+ * - Natural language format (e.g., "every day at 12 PM UTC", "every 48 hours")
31
+ *
32
+ * **Validation:**
33
+ * - Schedules below minimum frequency return error with descriptive message.
34
+ * - Invalid job IDs return 400 Bad Request.
35
+ * - Duplicate monitors (same job already monitored) return error.
29
36
  *
30
37
  * @param {CatchAllApi.CreateMonitorRequestDto} request
31
38
  * @param {MonitorsClient.RequestOptions} requestOptions - Request-specific configuration.
@@ -44,7 +51,8 @@ export class MonitorsClient {
44
51
  __createMonitor(request, requestOptions) {
45
52
  return __awaiter(this, void 0, void 0, function* () {
46
53
  var _a, _b, _c, _d, _e, _f, _g, _h, _j;
47
- 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);
54
+ const _authRequest = yield this._options.authProvider.getAuthRequest();
55
+ 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);
48
56
  const _response = yield core.fetcher({
49
57
  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/monitors/create"),
50
58
  method: "POST",
@@ -74,21 +82,7 @@ export class MonitorsClient {
74
82
  });
75
83
  }
76
84
  }
77
- switch (_response.error.reason) {
78
- case "non-json":
79
- throw new errors.CatchAllApiError({
80
- statusCode: _response.error.statusCode,
81
- body: _response.error.rawBody,
82
- rawResponse: _response.rawResponse,
83
- });
84
- case "timeout":
85
- throw new errors.CatchAllApiTimeoutError("Timeout exceeded when calling POST /catchAll/monitors/create.");
86
- case "unknown":
87
- throw new errors.CatchAllApiError({
88
- message: _response.error.errorMessage,
89
- rawResponse: _response.rawResponse,
90
- });
91
- }
85
+ return handleNonStatusCodeError(_response.error, _response.rawResponse, "POST", "/catchAll/monitors/create");
92
86
  });
93
87
  }
94
88
  /**
@@ -117,7 +111,8 @@ export class MonitorsClient {
117
111
  if (sort != null) {
118
112
  _queryParams.sort = sort;
119
113
  }
120
- 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);
114
+ const _authRequest = yield this._options.authProvider.getAuthRequest();
115
+ 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);
121
116
  const _response = yield core.fetcher({
122
117
  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/monitors/${core.url.encodePathParam(monitorId)}/jobs`),
123
118
  method: "GET",
@@ -146,21 +141,7 @@ export class MonitorsClient {
146
141
  });
147
142
  }
148
143
  }
149
- switch (_response.error.reason) {
150
- case "non-json":
151
- throw new errors.CatchAllApiError({
152
- statusCode: _response.error.statusCode,
153
- body: _response.error.rawBody,
154
- rawResponse: _response.rawResponse,
155
- });
156
- case "timeout":
157
- throw new errors.CatchAllApiTimeoutError("Timeout exceeded when calling GET /catchAll/monitors/{monitor_id}/jobs.");
158
- case "unknown":
159
- throw new errors.CatchAllApiError({
160
- message: _response.error.errorMessage,
161
- rawResponse: _response.rawResponse,
162
- });
163
- }
144
+ return handleNonStatusCodeError(_response.error, _response.rawResponse, "GET", "/catchAll/monitors/{monitor_id}/jobs");
164
145
  });
165
146
  }
166
147
  /**
@@ -185,7 +166,8 @@ export class MonitorsClient {
185
166
  return __awaiter(this, void 0, void 0, function* () {
186
167
  var _a, _b, _c, _d, _e, _f, _g, _h, _j;
187
168
  const { monitor_id: monitorId } = request;
188
- 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);
169
+ const _authRequest = yield this._options.authProvider.getAuthRequest();
170
+ 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);
189
171
  const _response = yield core.fetcher({
190
172
  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/monitors/pull/${core.url.encodePathParam(monitorId)}`),
191
173
  method: "GET",
@@ -214,21 +196,7 @@ export class MonitorsClient {
214
196
  });
215
197
  }
216
198
  }
217
- switch (_response.error.reason) {
218
- case "non-json":
219
- throw new errors.CatchAllApiError({
220
- statusCode: _response.error.statusCode,
221
- body: _response.error.rawBody,
222
- rawResponse: _response.rawResponse,
223
- });
224
- case "timeout":
225
- throw new errors.CatchAllApiTimeoutError("Timeout exceeded when calling GET /catchAll/monitors/pull/{monitor_id}.");
226
- case "unknown":
227
- throw new errors.CatchAllApiError({
228
- message: _response.error.errorMessage,
229
- rawResponse: _response.rawResponse,
230
- });
231
- }
199
+ return handleNonStatusCodeError(_response.error, _response.rawResponse, "GET", "/catchAll/monitors/pull/{monitor_id}");
232
200
  });
233
201
  }
234
202
  /**
@@ -254,7 +222,8 @@ export class MonitorsClient {
254
222
  return __awaiter(this, void 0, void 0, function* () {
255
223
  var _a, _b, _c, _d, _e, _f, _g, _h, _j;
256
224
  const { monitor_id: monitorId } = request;
257
- 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);
225
+ const _authRequest = yield this._options.authProvider.getAuthRequest();
226
+ 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);
258
227
  const _response = yield core.fetcher({
259
228
  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/monitors/${core.url.encodePathParam(monitorId)}/disable`),
260
229
  method: "POST",
@@ -285,21 +254,7 @@ export class MonitorsClient {
285
254
  });
286
255
  }
287
256
  }
288
- switch (_response.error.reason) {
289
- case "non-json":
290
- throw new errors.CatchAllApiError({
291
- statusCode: _response.error.statusCode,
292
- body: _response.error.rawBody,
293
- rawResponse: _response.rawResponse,
294
- });
295
- case "timeout":
296
- throw new errors.CatchAllApiTimeoutError("Timeout exceeded when calling POST /catchAll/monitors/{monitor_id}/disable.");
297
- case "unknown":
298
- throw new errors.CatchAllApiError({
299
- message: _response.error.errorMessage,
300
- rawResponse: _response.rawResponse,
301
- });
302
- }
257
+ return handleNonStatusCodeError(_response.error, _response.rawResponse, "POST", "/catchAll/monitors/{monitor_id}/disable");
303
258
  });
304
259
  }
305
260
  /**
@@ -325,7 +280,8 @@ export class MonitorsClient {
325
280
  return __awaiter(this, void 0, void 0, function* () {
326
281
  var _a, _b, _c, _d, _e, _f, _g, _h, _j;
327
282
  const { monitor_id: monitorId } = request;
328
- 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);
283
+ const _authRequest = yield this._options.authProvider.getAuthRequest();
284
+ 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);
329
285
  const _response = yield core.fetcher({
330
286
  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/monitors/${core.url.encodePathParam(monitorId)}/enable`),
331
287
  method: "POST",
@@ -356,21 +312,7 @@ export class MonitorsClient {
356
312
  });
357
313
  }
358
314
  }
359
- switch (_response.error.reason) {
360
- case "non-json":
361
- throw new errors.CatchAllApiError({
362
- statusCode: _response.error.statusCode,
363
- body: _response.error.rawBody,
364
- rawResponse: _response.rawResponse,
365
- });
366
- case "timeout":
367
- throw new errors.CatchAllApiTimeoutError("Timeout exceeded when calling POST /catchAll/monitors/{monitor_id}/enable.");
368
- case "unknown":
369
- throw new errors.CatchAllApiError({
370
- message: _response.error.errorMessage,
371
- rawResponse: _response.rawResponse,
372
- });
373
- }
315
+ return handleNonStatusCodeError(_response.error, _response.rawResponse, "POST", "/catchAll/monitors/{monitor_id}/enable");
374
316
  });
375
317
  }
376
318
  /**
@@ -390,7 +332,8 @@ export class MonitorsClient {
390
332
  __listMonitors(requestOptions) {
391
333
  return __awaiter(this, void 0, void 0, function* () {
392
334
  var _a, _b, _c, _d, _e, _f, _g, _h, _j;
393
- 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);
335
+ const _authRequest = yield this._options.authProvider.getAuthRequest();
336
+ 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);
394
337
  const _response = yield core.fetcher({
395
338
  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/monitors"),
396
339
  method: "GET",
@@ -419,27 +362,7 @@ export class MonitorsClient {
419
362
  });
420
363
  }
421
364
  }
422
- switch (_response.error.reason) {
423
- case "non-json":
424
- throw new errors.CatchAllApiError({
425
- statusCode: _response.error.statusCode,
426
- body: _response.error.rawBody,
427
- rawResponse: _response.rawResponse,
428
- });
429
- case "timeout":
430
- throw new errors.CatchAllApiTimeoutError("Timeout exceeded when calling GET /catchAll/monitors.");
431
- case "unknown":
432
- throw new errors.CatchAllApiError({
433
- message: _response.error.errorMessage,
434
- rawResponse: _response.rawResponse,
435
- });
436
- }
437
- });
438
- }
439
- _getCustomAuthorizationHeaders() {
440
- return __awaiter(this, void 0, void 0, function* () {
441
- const apiKeyValue = yield core.Supplier.get(this._options.apiKey);
442
- return { "x-api-key": apiKeyValue };
365
+ return handleNonStatusCodeError(_response.error, _response.rawResponse, "GET", "/catchAll/monitors");
443
366
  });
444
367
  }
445
368
  }
@@ -10,12 +10,9 @@ export interface CreateMonitorRequestDto {
10
10
  /** Job ID to use as template for scheduled runs. */
11
11
  reference_job_id: string;
12
12
  /**
13
- * Natural language schedule description. Examples:
14
- * - "every day at 12 PM UTC"
15
- * - "every Monday at 9 AM EST"
16
- * - "every 6 hours"
13
+ * Natural language schedule (e.g. 'every day at 12 AM EST').
17
14
  *
18
- * **Warning**: Schedule validation is limited. Test carefully before production.
15
+ * **Minimum frequency:** Monitors must be scheduled at least 24 hours apart.
19
16
  */
20
17
  schedule: string;
21
18
  /** Optional webhook to receive notifications when jobs complete. */
@@ -3,4 +3,8 @@ export interface ListUserJobsResponseDto {
3
3
  job_id: string;
4
4
  /** The natural language query for this job. */
5
5
  query: string;
6
+ /** Job creation timestamp in ISO 8601 format. */
7
+ created_at: string;
8
+ /** Current processing status of the job. */
9
+ status: string;
6
10
  }
@@ -3,6 +3,8 @@
3
3
  * Extends base citation with tracking information for job_id and timestamps.
4
4
  */
5
5
  export interface MonitorCitation {
6
+ /** Article identifier from News API v3 */
7
+ id: string;
6
8
  /** Article title */
7
9
  title: string;
8
10
  /** URL to the source article */
@@ -1,3 +1,4 @@
1
+ import type * as CatchAllApi from "../index.mjs";
1
2
  export interface MonitorListItemDto {
2
3
  /** Monitor identifier. */
3
4
  monitor_id: string;
@@ -9,8 +10,12 @@ export interface MonitorListItemDto {
9
10
  enabled: boolean;
10
11
  /** Cron expression for monitor schedule. */
11
12
  schedule?: string;
13
+ /** Natural language description of the monitor schedule. */
14
+ schedule_human_readable?: string;
12
15
  /** Timezone for schedule execution. */
13
16
  timezone?: string;
14
17
  /** The date when the monitor was created. */
15
18
  created_at?: string;
19
+ /** Webhook configuration for this monitor (if set). */
20
+ webhook?: CatchAllApi.WebhookDto;
16
21
  }
@@ -8,6 +8,11 @@ export interface PullJobResponseDto {
8
8
  context?: string;
9
9
  /** List of validation criteria applied to filter results. */
10
10
  validators?: string[];
11
+ /**
12
+ * List of extracted field names generated by the enrichment process.
13
+ * These field names appear in the `enrichment` object of each record.
14
+ */
15
+ enrichments?: string[];
11
16
  /** Job status. */
12
17
  status: string;
13
18
  /** Total time taken to process the job. */
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Template string to guide record summary formatting. Use placeholder syntax with brackets to indicate desired fields: [COMPANY], [REVENUE], [DATE], etc.
2
+ * Template string to guide record summary formatting. Use placeholder syntax with brackets to indicate desired fields: [COMPANY], [REVENUE], [TARGET], [AMOUNT], etc.
3
3
  *
4
4
  * When provided, the system generates a `schema_based_summary` field for each record following this template.
5
5
  */
@@ -1,10 +1,8 @@
1
1
  import type * as CatchAllApi from "../index.mjs";
2
2
  /**
3
- * Payload sent to webhook URL when a monitor job completes.
4
- * Content-Type: application/json
3
+ * **First execution:** The initial webhook after monitor creation includes all records from the reference job, providing immediate access to collected data.
5
4
  *
6
- * Note: Citations in webhook payloads include an additional 'id' field
7
- * (string, internal identifier) not present in API GET responses.
5
+ * **Subsequent executions:** Only new records (after deduplication) are included.
8
6
  */
9
7
  export interface WebhookPayload {
10
8
  /** Monitor identifier. */
@@ -0,0 +1,16 @@
1
+ import * as core from "../core/index.mjs";
2
+ export declare namespace HeaderAuthProvider {
3
+ interface AuthOptions {
4
+ apiKey?: core.Supplier<string>;
5
+ }
6
+ interface Options extends AuthOptions {
7
+ }
8
+ }
9
+ export declare class HeaderAuthProvider implements core.AuthProvider {
10
+ private readonly headerValue;
11
+ constructor(options: HeaderAuthProvider.Options);
12
+ static canCreate(options: HeaderAuthProvider.Options): boolean;
13
+ getAuthRequest(_arg?: {
14
+ endpointMetadata?: core.EndpointMetadata;
15
+ }): Promise<core.AuthRequest>;
16
+ }
@@ -0,0 +1,34 @@
1
+ // This file was auto-generated by Fern from our API Definition.
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ import * as core from "../core/index.mjs";
12
+ import * as errors from "../errors/index.mjs";
13
+ export class HeaderAuthProvider {
14
+ constructor(options) {
15
+ this.headerValue = options.apiKey;
16
+ }
17
+ static canCreate(options) {
18
+ return options.apiKey != null;
19
+ }
20
+ getAuthRequest(_arg) {
21
+ return __awaiter(this, void 0, void 0, function* () {
22
+ const apiKey = yield core.Supplier.get(this.headerValue);
23
+ if (apiKey == null) {
24
+ throw new errors.CatchAllApiError({
25
+ message: "Please specify a apiKey by passing it in to the constructor",
26
+ });
27
+ }
28
+ const headerValue = apiKey;
29
+ return {
30
+ headers: { "x-api-key": headerValue },
31
+ };
32
+ });
33
+ }
34
+ }
@@ -0,0 +1 @@
1
+ export { HeaderAuthProvider } from "./HeaderAuthProvider.mjs";
@@ -0,0 +1 @@
1
+ export { HeaderAuthProvider } from "./HeaderAuthProvider.mjs";
@@ -0,0 +1,7 @@
1
+ import type { EndpointMetadata } from "../fetcher/EndpointMetadata.mjs";
2
+ import type { AuthRequest } from "./AuthRequest.mjs";
3
+ export interface AuthProvider {
4
+ getAuthRequest(arg?: {
5
+ endpointMetadata?: EndpointMetadata;
6
+ }): Promise<AuthRequest>;
7
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Request parameters for authentication requests.
3
+ */
4
+ export interface AuthRequest {
5
+ /**
6
+ * The headers to be included in the request.
7
+ */
8
+ headers: Record<string, string>;
9
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,8 @@
1
+ export interface BasicAuth {
2
+ username: string;
3
+ password: string;
4
+ }
5
+ export declare const BasicAuth: {
6
+ toAuthorizationHeader: (basicAuth: BasicAuth | undefined) => string | undefined;
7
+ fromAuthorizationHeader: (header: string) => BasicAuth;
8
+ };
@@ -0,0 +1,24 @@
1
+ import { base64Decode, base64Encode } from "../base64.mjs";
2
+ const BASIC_AUTH_HEADER_PREFIX = /^Basic /i;
3
+ export const BasicAuth = {
4
+ toAuthorizationHeader: (basicAuth) => {
5
+ if (basicAuth == null) {
6
+ return undefined;
7
+ }
8
+ const token = base64Encode(`${basicAuth.username}:${basicAuth.password}`);
9
+ return `Basic ${token}`;
10
+ },
11
+ fromAuthorizationHeader: (header) => {
12
+ const credentials = header.replace(BASIC_AUTH_HEADER_PREFIX, "");
13
+ const decoded = base64Decode(credentials);
14
+ const [username, ...passwordParts] = decoded.split(":");
15
+ const password = passwordParts.length > 0 ? passwordParts.join(":") : undefined;
16
+ if (username == null || password == null) {
17
+ throw new Error("Invalid basic auth");
18
+ }
19
+ return {
20
+ username,
21
+ password,
22
+ };
23
+ },
24
+ };
@@ -0,0 +1,7 @@
1
+ export type BearerToken = string;
2
+ declare function toAuthorizationHeader(token: string | undefined): string | undefined;
3
+ export declare const BearerToken: {
4
+ toAuthorizationHeader: typeof toAuthorizationHeader;
5
+ fromAuthorizationHeader: (header: string) => BearerToken;
6
+ };
7
+ export {};
@@ -0,0 +1,13 @@
1
+ const BEARER_AUTH_HEADER_PREFIX = /^Bearer /i;
2
+ function toAuthorizationHeader(token) {
3
+ if (token == null) {
4
+ return undefined;
5
+ }
6
+ return `Bearer ${token}`;
7
+ }
8
+ export const BearerToken = {
9
+ toAuthorizationHeader: toAuthorizationHeader,
10
+ fromAuthorizationHeader: (header) => {
11
+ return header.replace(BEARER_AUTH_HEADER_PREFIX, "").trim();
12
+ },
13
+ };
@@ -0,0 +1,5 @@
1
+ import type { AuthProvider } from "./AuthProvider.mjs";
2
+ import type { AuthRequest } from "./AuthRequest.mjs";
3
+ export declare class NoOpAuthProvider implements AuthProvider {
4
+ getAuthRequest(): Promise<AuthRequest>;
5
+ }
@@ -0,0 +1,5 @@
1
+ export class NoOpAuthProvider {
2
+ getAuthRequest() {
3
+ return Promise.resolve({ headers: {} });
4
+ }
5
+ }
@@ -0,0 +1,5 @@
1
+ export type { AuthProvider } from "./AuthProvider.mjs";
2
+ export type { AuthRequest } from "./AuthRequest.mjs";
3
+ export { BasicAuth } from "./BasicAuth.mjs";
4
+ export { BearerToken } from "./BearerToken.mjs";
5
+ export { NoOpAuthProvider } from "./NoOpAuthProvider.mjs";
@@ -0,0 +1,3 @@
1
+ export { BasicAuth } from "./BasicAuth.mjs";
2
+ export { BearerToken } from "./BearerToken.mjs";
3
+ export { NoOpAuthProvider } from "./NoOpAuthProvider.mjs";
@@ -0,0 +1,2 @@
1
+ export declare function base64Encode(input: string): string;
2
+ export declare function base64Decode(input: string): string;