@credal/sdk 0.1.10 → 0.1.11

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 (61) hide show
  1. package/dist/cjs/BaseClient.d.ts +4 -0
  2. package/dist/cjs/Client.js +3 -3
  3. package/dist/cjs/api/resources/copilots/client/Client.js +27 -9
  4. package/dist/cjs/api/resources/documentCatalog/client/Client.js +12 -4
  5. package/dist/cjs/api/resources/documentCollections/client/Client.js +21 -7
  6. package/dist/cjs/api/resources/search/client/Client.js +3 -1
  7. package/dist/cjs/api/resources/users/client/Client.js +3 -1
  8. package/dist/cjs/core/exports.d.ts +1 -0
  9. package/dist/cjs/core/exports.js +1 -0
  10. package/dist/cjs/core/fetcher/Fetcher.d.ts +4 -1
  11. package/dist/cjs/core/fetcher/Fetcher.js +202 -9
  12. package/dist/cjs/core/fetcher/getRequestBody.d.ts +1 -1
  13. package/dist/cjs/core/fetcher/getRequestBody.js +4 -0
  14. package/dist/cjs/core/fetcher/makeRequest.d.ts +1 -1
  15. package/dist/cjs/core/fetcher/makeRequest.js +0 -2
  16. package/dist/cjs/core/fetcher/requestWithRetries.js +0 -9
  17. package/dist/cjs/core/fetcher/signals.d.ts +0 -6
  18. package/dist/cjs/core/fetcher/signals.js +0 -12
  19. package/dist/cjs/core/headers.js +6 -4
  20. package/dist/cjs/core/index.d.ts +1 -0
  21. package/dist/cjs/core/index.js +2 -1
  22. package/dist/cjs/core/logging/exports.d.ts +18 -0
  23. package/dist/cjs/core/logging/exports.js +45 -0
  24. package/dist/cjs/core/logging/index.d.ts +1 -0
  25. package/dist/cjs/core/logging/index.js +17 -0
  26. package/dist/cjs/core/logging/logger.d.ts +126 -0
  27. package/dist/cjs/core/logging/logger.js +144 -0
  28. package/dist/cjs/core/url/join.js +0 -1
  29. package/dist/cjs/version.d.ts +1 -1
  30. package/dist/cjs/version.js +1 -1
  31. package/dist/esm/BaseClient.d.mts +4 -0
  32. package/dist/esm/Client.mjs +3 -3
  33. package/dist/esm/api/resources/copilots/client/Client.mjs +27 -9
  34. package/dist/esm/api/resources/documentCatalog/client/Client.mjs +12 -4
  35. package/dist/esm/api/resources/documentCollections/client/Client.mjs +21 -7
  36. package/dist/esm/api/resources/search/client/Client.mjs +3 -1
  37. package/dist/esm/api/resources/users/client/Client.mjs +3 -1
  38. package/dist/esm/core/exports.d.mts +1 -0
  39. package/dist/esm/core/exports.mjs +1 -0
  40. package/dist/esm/core/fetcher/Fetcher.d.mts +4 -1
  41. package/dist/esm/core/fetcher/Fetcher.mjs +202 -9
  42. package/dist/esm/core/fetcher/getRequestBody.d.mts +1 -1
  43. package/dist/esm/core/fetcher/getRequestBody.mjs +4 -0
  44. package/dist/esm/core/fetcher/makeRequest.d.mts +1 -1
  45. package/dist/esm/core/fetcher/makeRequest.mjs +0 -2
  46. package/dist/esm/core/fetcher/requestWithRetries.mjs +0 -9
  47. package/dist/esm/core/fetcher/signals.d.mts +0 -6
  48. package/dist/esm/core/fetcher/signals.mjs +0 -12
  49. package/dist/esm/core/headers.mjs +6 -4
  50. package/dist/esm/core/index.d.mts +1 -0
  51. package/dist/esm/core/index.mjs +1 -0
  52. package/dist/esm/core/logging/exports.d.mts +18 -0
  53. package/dist/esm/core/logging/exports.mjs +9 -0
  54. package/dist/esm/core/logging/index.d.mts +1 -0
  55. package/dist/esm/core/logging/index.mjs +1 -0
  56. package/dist/esm/core/logging/logger.d.mts +126 -0
  57. package/dist/esm/core/logging/logger.mjs +138 -0
  58. package/dist/esm/core/url/join.mjs +0 -1
  59. package/dist/esm/version.d.mts +1 -1
  60. package/dist/esm/version.mjs +1 -1
  61. package/package.json +3 -2
@@ -0,0 +1,126 @@
1
+ export declare const LogLevel: {
2
+ readonly Debug: "debug";
3
+ readonly Info: "info";
4
+ readonly Warn: "warn";
5
+ readonly Error: "error";
6
+ };
7
+ export type LogLevel = (typeof LogLevel)[keyof typeof LogLevel];
8
+ export interface ILogger {
9
+ /**
10
+ * Logs a debug message.
11
+ * @param message - The message to log
12
+ * @param args - Additional arguments to log
13
+ */
14
+ debug(message: string, ...args: unknown[]): void;
15
+ /**
16
+ * Logs an info message.
17
+ * @param message - The message to log
18
+ * @param args - Additional arguments to log
19
+ */
20
+ info(message: string, ...args: unknown[]): void;
21
+ /**
22
+ * Logs a warning message.
23
+ * @param message - The message to log
24
+ * @param args - Additional arguments to log
25
+ */
26
+ warn(message: string, ...args: unknown[]): void;
27
+ /**
28
+ * Logs an error message.
29
+ * @param message - The message to log
30
+ * @param args - Additional arguments to log
31
+ */
32
+ error(message: string, ...args: unknown[]): void;
33
+ }
34
+ /**
35
+ * Configuration for logger initialization.
36
+ */
37
+ export interface LogConfig {
38
+ /**
39
+ * Minimum log level to output.
40
+ * @default LogLevel.Info
41
+ */
42
+ level?: LogLevel;
43
+ /**
44
+ * Logger implementation to use.
45
+ * @default new ConsoleLogger()
46
+ */
47
+ logger?: ILogger;
48
+ /**
49
+ * Whether logging should be silenced.
50
+ * @default true
51
+ */
52
+ silent?: boolean;
53
+ }
54
+ /**
55
+ * Default console-based logger implementation.
56
+ */
57
+ export declare class ConsoleLogger implements ILogger {
58
+ debug(message: string, ...args: unknown[]): void;
59
+ info(message: string, ...args: unknown[]): void;
60
+ warn(message: string, ...args: unknown[]): void;
61
+ error(message: string, ...args: unknown[]): void;
62
+ }
63
+ /**
64
+ * Logger class that provides level-based logging functionality.
65
+ */
66
+ export declare class Logger {
67
+ private readonly level;
68
+ private readonly logger;
69
+ private readonly silent;
70
+ /**
71
+ * Creates a new logger instance.
72
+ * @param config - Logger configuration
73
+ */
74
+ constructor(config: Required<LogConfig>);
75
+ /**
76
+ * Checks if a log level should be output based on configuration.
77
+ * @param level - The log level to check
78
+ * @returns True if the level should be logged
79
+ */
80
+ shouldLog(level: LogLevel): boolean;
81
+ /**
82
+ * Checks if debug logging is enabled.
83
+ * @returns True if debug logs should be output
84
+ */
85
+ isDebug(): boolean;
86
+ /**
87
+ * Logs a debug message if debug logging is enabled.
88
+ * @param message - The message to log
89
+ * @param args - Additional arguments to log
90
+ */
91
+ debug(message: string, ...args: unknown[]): void;
92
+ /**
93
+ * Checks if info logging is enabled.
94
+ * @returns True if info logs should be output
95
+ */
96
+ isInfo(): boolean;
97
+ /**
98
+ * Logs an info message if info logging is enabled.
99
+ * @param message - The message to log
100
+ * @param args - Additional arguments to log
101
+ */
102
+ info(message: string, ...args: unknown[]): void;
103
+ /**
104
+ * Checks if warning logging is enabled.
105
+ * @returns True if warning logs should be output
106
+ */
107
+ isWarn(): boolean;
108
+ /**
109
+ * Logs a warning message if warning logging is enabled.
110
+ * @param message - The message to log
111
+ * @param args - Additional arguments to log
112
+ */
113
+ warn(message: string, ...args: unknown[]): void;
114
+ /**
115
+ * Checks if error logging is enabled.
116
+ * @returns True if error logs should be output
117
+ */
118
+ isError(): boolean;
119
+ /**
120
+ * Logs an error message if error logging is enabled.
121
+ * @param message - The message to log
122
+ * @param args - Additional arguments to log
123
+ */
124
+ error(message: string, ...args: unknown[]): void;
125
+ }
126
+ export declare function createLogger(config?: LogConfig | Logger): Logger;
@@ -0,0 +1,144 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Logger = exports.ConsoleLogger = exports.LogLevel = void 0;
4
+ exports.createLogger = createLogger;
5
+ exports.LogLevel = {
6
+ Debug: "debug",
7
+ Info: "info",
8
+ Warn: "warn",
9
+ Error: "error",
10
+ };
11
+ const logLevelMap = {
12
+ [exports.LogLevel.Debug]: 1,
13
+ [exports.LogLevel.Info]: 2,
14
+ [exports.LogLevel.Warn]: 3,
15
+ [exports.LogLevel.Error]: 4,
16
+ };
17
+ /**
18
+ * Default console-based logger implementation.
19
+ */
20
+ class ConsoleLogger {
21
+ debug(message, ...args) {
22
+ console.debug(message, ...args);
23
+ }
24
+ info(message, ...args) {
25
+ console.info(message, ...args);
26
+ }
27
+ warn(message, ...args) {
28
+ console.warn(message, ...args);
29
+ }
30
+ error(message, ...args) {
31
+ console.error(message, ...args);
32
+ }
33
+ }
34
+ exports.ConsoleLogger = ConsoleLogger;
35
+ /**
36
+ * Logger class that provides level-based logging functionality.
37
+ */
38
+ class Logger {
39
+ /**
40
+ * Creates a new logger instance.
41
+ * @param config - Logger configuration
42
+ */
43
+ constructor(config) {
44
+ this.level = logLevelMap[config.level];
45
+ this.logger = config.logger;
46
+ this.silent = config.silent;
47
+ }
48
+ /**
49
+ * Checks if a log level should be output based on configuration.
50
+ * @param level - The log level to check
51
+ * @returns True if the level should be logged
52
+ */
53
+ shouldLog(level) {
54
+ return !this.silent && this.level <= logLevelMap[level];
55
+ }
56
+ /**
57
+ * Checks if debug logging is enabled.
58
+ * @returns True if debug logs should be output
59
+ */
60
+ isDebug() {
61
+ return this.shouldLog(exports.LogLevel.Debug);
62
+ }
63
+ /**
64
+ * Logs a debug message if debug logging is enabled.
65
+ * @param message - The message to log
66
+ * @param args - Additional arguments to log
67
+ */
68
+ debug(message, ...args) {
69
+ if (this.isDebug()) {
70
+ this.logger.debug(message, ...args);
71
+ }
72
+ }
73
+ /**
74
+ * Checks if info logging is enabled.
75
+ * @returns True if info logs should be output
76
+ */
77
+ isInfo() {
78
+ return this.shouldLog(exports.LogLevel.Info);
79
+ }
80
+ /**
81
+ * Logs an info message if info logging is enabled.
82
+ * @param message - The message to log
83
+ * @param args - Additional arguments to log
84
+ */
85
+ info(message, ...args) {
86
+ if (this.isInfo()) {
87
+ this.logger.info(message, ...args);
88
+ }
89
+ }
90
+ /**
91
+ * Checks if warning logging is enabled.
92
+ * @returns True if warning logs should be output
93
+ */
94
+ isWarn() {
95
+ return this.shouldLog(exports.LogLevel.Warn);
96
+ }
97
+ /**
98
+ * Logs a warning message if warning logging is enabled.
99
+ * @param message - The message to log
100
+ * @param args - Additional arguments to log
101
+ */
102
+ warn(message, ...args) {
103
+ if (this.isWarn()) {
104
+ this.logger.warn(message, ...args);
105
+ }
106
+ }
107
+ /**
108
+ * Checks if error logging is enabled.
109
+ * @returns True if error logs should be output
110
+ */
111
+ isError() {
112
+ return this.shouldLog(exports.LogLevel.Error);
113
+ }
114
+ /**
115
+ * Logs an error message if error logging is enabled.
116
+ * @param message - The message to log
117
+ * @param args - Additional arguments to log
118
+ */
119
+ error(message, ...args) {
120
+ if (this.isError()) {
121
+ this.logger.error(message, ...args);
122
+ }
123
+ }
124
+ }
125
+ exports.Logger = Logger;
126
+ function createLogger(config) {
127
+ var _a, _b, _c;
128
+ if (config == null) {
129
+ return defaultLogger;
130
+ }
131
+ if (config instanceof Logger) {
132
+ return config;
133
+ }
134
+ config = config !== null && config !== void 0 ? config : {};
135
+ (_a = config.level) !== null && _a !== void 0 ? _a : (config.level = exports.LogLevel.Info);
136
+ (_b = config.logger) !== null && _b !== void 0 ? _b : (config.logger = new ConsoleLogger());
137
+ (_c = config.silent) !== null && _c !== void 0 ? _c : (config.silent = true);
138
+ return new Logger(config);
139
+ }
140
+ const defaultLogger = new Logger({
141
+ level: exports.LogLevel.Info,
142
+ logger: new ConsoleLogger(),
143
+ silent: true,
144
+ });
@@ -14,7 +14,6 @@ function join(base, ...segments) {
14
14
  url = new URL(base);
15
15
  }
16
16
  catch (_a) {
17
- // Fallback to path joining if URL is malformed
18
17
  return joinPath(base, ...segments);
19
18
  }
20
19
  const lastSegment = segments[segments.length - 1];
@@ -1 +1 @@
1
- export declare const SDK_VERSION = "0.1.10";
1
+ export declare const SDK_VERSION = "0.1.11";
@@ -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.10";
4
+ exports.SDK_VERSION = "0.1.11";
@@ -11,7 +11,11 @@ export interface BaseClientOptions {
11
11
  timeoutInSeconds?: number;
12
12
  /** The default number of times to retry the request. Defaults to 2. */
13
13
  maxRetries?: number;
14
+ /** Provide a custom fetch implementation. Useful for platforms that don't have a built-in fetch or need a custom implementation. */
15
+ fetch?: typeof fetch;
14
16
  fetcher?: core.FetchFunction;
17
+ /** Configure logging for the client. */
18
+ logging?: core.logging.LogConfig | core.logging.Logger;
15
19
  }
16
20
  export interface BaseRequestOptions {
17
21
  /** The maximum time to wait for a response in seconds. */
@@ -8,11 +8,11 @@ import { mergeHeaders } from "./core/headers.mjs";
8
8
  import * as core from "./core/index.mjs";
9
9
  export class CredalClient {
10
10
  constructor(_options = {}) {
11
- this._options = Object.assign(Object.assign({}, _options), { headers: mergeHeaders({
11
+ this._options = Object.assign(Object.assign({}, _options), { logging: core.logging.createLogger(_options === null || _options === void 0 ? void 0 : _options.logging), headers: mergeHeaders({
12
12
  "X-Fern-Language": "JavaScript",
13
13
  "X-Fern-SDK-Name": "@credal/sdk",
14
- "X-Fern-SDK-Version": "0.1.10",
15
- "User-Agent": "@credal/sdk/0.1.10",
14
+ "X-Fern-SDK-Version": "0.1.11",
15
+ "User-Agent": "@credal/sdk/0.1.11",
16
16
  "X-Fern-Runtime": core.RUNTIME.type,
17
17
  "X-Fern-Runtime-Version": core.RUNTIME.version,
18
18
  }, _options === null || _options === void 0 ? void 0 : _options.headers) });
@@ -37,7 +37,7 @@ export class Copilots {
37
37
  }
38
38
  __createCopilot(request, requestOptions) {
39
39
  return __awaiter(this, void 0, void 0, function* () {
40
- var _a, _b, _c, _d, _e, _f, _g, _h, _j;
40
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
41
41
  const _headers = mergeHeaders((_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, mergeOnlyDefinedHeaders({ Authorization: yield this._getAuthorizationHeader() }), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
42
42
  const _response = yield ((_b = this._options.fetcher) !== null && _b !== void 0 ? _b : core.fetcher)({
43
43
  url: core.url.join((_d = (_c = (yield core.Supplier.get(this._options.baseUrl))) !== null && _c !== void 0 ? _c : (yield core.Supplier.get(this._options.environment))) !== null && _d !== void 0 ? _d : environments.CredalEnvironment.Production, "/v0/copilots/createCopilot"),
@@ -50,6 +50,8 @@ export class Copilots {
50
50
  timeoutMs: ((_g = (_e = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) !== null && _e !== void 0 ? _e : (_f = this._options) === null || _f === void 0 ? void 0 : _f.timeoutInSeconds) !== null && _g !== void 0 ? _g : 60) * 1000,
51
51
  maxRetries: (_h = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.maxRetries) !== null && _h !== void 0 ? _h : (_j = this._options) === null || _j === void 0 ? void 0 : _j.maxRetries,
52
52
  abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
53
+ fetchFn: (_k = this._options) === null || _k === void 0 ? void 0 : _k.fetch,
54
+ logging: this._options.logging,
53
55
  });
54
56
  if (_response.ok) {
55
57
  return { data: _response.body, rawResponse: _response.rawResponse };
@@ -95,7 +97,7 @@ export class Copilots {
95
97
  }
96
98
  __createConversation(request, requestOptions) {
97
99
  return __awaiter(this, void 0, void 0, function* () {
98
- var _a, _b, _c, _d, _e, _f, _g, _h, _j;
100
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
99
101
  const _headers = mergeHeaders((_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, mergeOnlyDefinedHeaders({ Authorization: yield this._getAuthorizationHeader() }), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
100
102
  const _response = yield ((_b = this._options.fetcher) !== null && _b !== void 0 ? _b : core.fetcher)({
101
103
  url: core.url.join((_d = (_c = (yield core.Supplier.get(this._options.baseUrl))) !== null && _c !== void 0 ? _c : (yield core.Supplier.get(this._options.environment))) !== null && _d !== void 0 ? _d : environments.CredalEnvironment.Production, "/v0/copilots/createConversation"),
@@ -108,6 +110,8 @@ export class Copilots {
108
110
  timeoutMs: ((_g = (_e = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) !== null && _e !== void 0 ? _e : (_f = this._options) === null || _f === void 0 ? void 0 : _f.timeoutInSeconds) !== null && _g !== void 0 ? _g : 60) * 1000,
109
111
  maxRetries: (_h = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.maxRetries) !== null && _h !== void 0 ? _h : (_j = this._options) === null || _j === void 0 ? void 0 : _j.maxRetries,
110
112
  abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
113
+ fetchFn: (_k = this._options) === null || _k === void 0 ? void 0 : _k.fetch,
114
+ logging: this._options.logging,
111
115
  });
112
116
  if (_response.ok) {
113
117
  return { data: _response.body, rawResponse: _response.rawResponse };
@@ -157,7 +161,7 @@ export class Copilots {
157
161
  }
158
162
  __provideMessageFeedback(request, requestOptions) {
159
163
  return __awaiter(this, void 0, void 0, function* () {
160
- var _a, _b, _c, _d, _e, _f, _g, _h, _j;
164
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
161
165
  const _headers = mergeHeaders((_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, mergeOnlyDefinedHeaders({ Authorization: yield this._getAuthorizationHeader() }), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
162
166
  const _response = yield ((_b = this._options.fetcher) !== null && _b !== void 0 ? _b : core.fetcher)({
163
167
  url: core.url.join((_d = (_c = (yield core.Supplier.get(this._options.baseUrl))) !== null && _c !== void 0 ? _c : (yield core.Supplier.get(this._options.environment))) !== null && _d !== void 0 ? _d : environments.CredalEnvironment.Production, "/v0/copilots/provideMessageFeedback"),
@@ -170,6 +174,8 @@ export class Copilots {
170
174
  timeoutMs: ((_g = (_e = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) !== null && _e !== void 0 ? _e : (_f = this._options) === null || _f === void 0 ? void 0 : _f.timeoutInSeconds) !== null && _g !== void 0 ? _g : 60) * 1000,
171
175
  maxRetries: (_h = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.maxRetries) !== null && _h !== void 0 ? _h : (_j = this._options) === null || _j === void 0 ? void 0 : _j.maxRetries,
172
176
  abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
177
+ fetchFn: (_k = this._options) === null || _k === void 0 ? void 0 : _k.fetch,
178
+ logging: this._options.logging,
173
179
  });
174
180
  if (_response.ok) {
175
181
  return { data: undefined, rawResponse: _response.rawResponse };
@@ -221,7 +227,7 @@ export class Copilots {
221
227
  }
222
228
  __sendMessage(request, requestOptions) {
223
229
  return __awaiter(this, void 0, void 0, function* () {
224
- var _a, _b, _c, _d, _e, _f, _g, _h, _j;
230
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
225
231
  const _headers = mergeHeaders((_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, mergeOnlyDefinedHeaders({ Authorization: yield this._getAuthorizationHeader() }), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
226
232
  const _response = yield ((_b = this._options.fetcher) !== null && _b !== void 0 ? _b : core.fetcher)({
227
233
  url: core.url.join((_d = (_c = (yield core.Supplier.get(this._options.baseUrl))) !== null && _c !== void 0 ? _c : (yield core.Supplier.get(this._options.environment))) !== null && _d !== void 0 ? _d : environments.CredalEnvironment.Production, "/v0/copilots/sendMessage"),
@@ -234,6 +240,8 @@ export class Copilots {
234
240
  timeoutMs: ((_g = (_e = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) !== null && _e !== void 0 ? _e : (_f = this._options) === null || _f === void 0 ? void 0 : _f.timeoutInSeconds) !== null && _g !== void 0 ? _g : 60) * 1000,
235
241
  maxRetries: (_h = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.maxRetries) !== null && _h !== void 0 ? _h : (_j = this._options) === null || _j === void 0 ? void 0 : _j.maxRetries,
236
242
  abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
243
+ fetchFn: (_k = this._options) === null || _k === void 0 ? void 0 : _k.fetch,
244
+ logging: this._options.logging,
237
245
  });
238
246
  if (_response.ok) {
239
247
  return { data: _response.body, rawResponse: _response.rawResponse };
@@ -270,7 +278,7 @@ export class Copilots {
270
278
  }
271
279
  __streamMessage(request, requestOptions) {
272
280
  return __awaiter(this, void 0, void 0, function* () {
273
- var _a, _b, _c, _d, _e, _f, _g, _h, _j;
281
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
274
282
  const _headers = mergeHeaders((_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, mergeOnlyDefinedHeaders({ Authorization: yield this._getAuthorizationHeader() }), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
275
283
  const _response = yield ((_b = this._options.fetcher) !== null && _b !== void 0 ? _b : core.fetcher)({
276
284
  url: core.url.join((_d = (_c = (yield core.Supplier.get(this._options.baseUrl))) !== null && _c !== void 0 ? _c : (yield core.Supplier.get(this._options.environment))) !== null && _d !== void 0 ? _d : environments.CredalEnvironment.Production, "/v0/copilots/streamMessage"),
@@ -284,6 +292,8 @@ export class Copilots {
284
292
  timeoutMs: ((_g = (_e = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) !== null && _e !== void 0 ? _e : (_f = this._options) === null || _f === void 0 ? void 0 : _f.timeoutInSeconds) !== null && _g !== void 0 ? _g : 60) * 1000,
285
293
  maxRetries: (_h = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.maxRetries) !== null && _h !== void 0 ? _h : (_j = this._options) === null || _j === void 0 ? void 0 : _j.maxRetries,
286
294
  abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
295
+ fetchFn: (_k = this._options) === null || _k === void 0 ? void 0 : _k.fetch,
296
+ logging: this._options.logging,
287
297
  });
288
298
  if (_response.ok) {
289
299
  return {
@@ -340,7 +350,7 @@ export class Copilots {
340
350
  }
341
351
  __addCollectionToCopilot(request, requestOptions) {
342
352
  return __awaiter(this, void 0, void 0, function* () {
343
- var _a, _b, _c, _d, _e, _f, _g, _h, _j;
353
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
344
354
  const _headers = mergeHeaders((_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, mergeOnlyDefinedHeaders({ Authorization: yield this._getAuthorizationHeader() }), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
345
355
  const _response = yield ((_b = this._options.fetcher) !== null && _b !== void 0 ? _b : core.fetcher)({
346
356
  url: core.url.join((_d = (_c = (yield core.Supplier.get(this._options.baseUrl))) !== null && _c !== void 0 ? _c : (yield core.Supplier.get(this._options.environment))) !== null && _d !== void 0 ? _d : environments.CredalEnvironment.Production, "/v0/copilots/addCollectionToCopilot"),
@@ -353,6 +363,8 @@ export class Copilots {
353
363
  timeoutMs: ((_g = (_e = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) !== null && _e !== void 0 ? _e : (_f = this._options) === null || _f === void 0 ? void 0 : _f.timeoutInSeconds) !== null && _g !== void 0 ? _g : 60) * 1000,
354
364
  maxRetries: (_h = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.maxRetries) !== null && _h !== void 0 ? _h : (_j = this._options) === null || _j === void 0 ? void 0 : _j.maxRetries,
355
365
  abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
366
+ fetchFn: (_k = this._options) === null || _k === void 0 ? void 0 : _k.fetch,
367
+ logging: this._options.logging,
356
368
  });
357
369
  if (_response.ok) {
358
370
  return { data: undefined, rawResponse: _response.rawResponse };
@@ -398,7 +410,7 @@ export class Copilots {
398
410
  }
399
411
  __removeCollectionFromCopilot(request, requestOptions) {
400
412
  return __awaiter(this, void 0, void 0, function* () {
401
- var _a, _b, _c, _d, _e, _f, _g, _h, _j;
413
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
402
414
  const _headers = mergeHeaders((_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, mergeOnlyDefinedHeaders({ Authorization: yield this._getAuthorizationHeader() }), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
403
415
  const _response = yield ((_b = this._options.fetcher) !== null && _b !== void 0 ? _b : core.fetcher)({
404
416
  url: core.url.join((_d = (_c = (yield core.Supplier.get(this._options.baseUrl))) !== null && _c !== void 0 ? _c : (yield core.Supplier.get(this._options.environment))) !== null && _d !== void 0 ? _d : environments.CredalEnvironment.Production, "/v0/copilots/removeCollectionFromCopilot"),
@@ -411,6 +423,8 @@ export class Copilots {
411
423
  timeoutMs: ((_g = (_e = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) !== null && _e !== void 0 ? _e : (_f = this._options) === null || _f === void 0 ? void 0 : _f.timeoutInSeconds) !== null && _g !== void 0 ? _g : 60) * 1000,
412
424
  maxRetries: (_h = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.maxRetries) !== null && _h !== void 0 ? _h : (_j = this._options) === null || _j === void 0 ? void 0 : _j.maxRetries,
413
425
  abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
426
+ fetchFn: (_k = this._options) === null || _k === void 0 ? void 0 : _k.fetch,
427
+ logging: this._options.logging,
414
428
  });
415
429
  if (_response.ok) {
416
430
  return { data: undefined, rawResponse: _response.rawResponse };
@@ -464,7 +478,7 @@ export class Copilots {
464
478
  }
465
479
  __updateConfiguration(request, requestOptions) {
466
480
  return __awaiter(this, void 0, void 0, function* () {
467
- var _a, _b, _c, _d, _e, _f, _g, _h, _j;
481
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
468
482
  const _headers = mergeHeaders((_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, mergeOnlyDefinedHeaders({ Authorization: yield this._getAuthorizationHeader() }), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
469
483
  const _response = yield ((_b = this._options.fetcher) !== null && _b !== void 0 ? _b : core.fetcher)({
470
484
  url: core.url.join((_d = (_c = (yield core.Supplier.get(this._options.baseUrl))) !== null && _c !== void 0 ? _c : (yield core.Supplier.get(this._options.environment))) !== null && _d !== void 0 ? _d : environments.CredalEnvironment.Production, "/v0/copilots/updateConfiguration"),
@@ -477,6 +491,8 @@ export class Copilots {
477
491
  timeoutMs: ((_g = (_e = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) !== null && _e !== void 0 ? _e : (_f = this._options) === null || _f === void 0 ? void 0 : _f.timeoutInSeconds) !== null && _g !== void 0 ? _g : 60) * 1000,
478
492
  maxRetries: (_h = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.maxRetries) !== null && _h !== void 0 ? _h : (_j = this._options) === null || _j === void 0 ? void 0 : _j.maxRetries,
479
493
  abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
494
+ fetchFn: (_k = this._options) === null || _k === void 0 ? void 0 : _k.fetch,
495
+ logging: this._options.logging,
480
496
  });
481
497
  if (_response.ok) {
482
498
  return { data: undefined, rawResponse: _response.rawResponse };
@@ -519,7 +535,7 @@ export class Copilots {
519
535
  }
520
536
  __deleteCopilot(request, requestOptions) {
521
537
  return __awaiter(this, void 0, void 0, function* () {
522
- var _a, _b, _c, _d, _e, _f, _g, _h, _j;
538
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
523
539
  const _headers = mergeHeaders((_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, mergeOnlyDefinedHeaders({ Authorization: yield this._getAuthorizationHeader() }), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
524
540
  const _response = yield ((_b = this._options.fetcher) !== null && _b !== void 0 ? _b : core.fetcher)({
525
541
  url: core.url.join((_d = (_c = (yield core.Supplier.get(this._options.baseUrl))) !== null && _c !== void 0 ? _c : (yield core.Supplier.get(this._options.environment))) !== null && _d !== void 0 ? _d : environments.CredalEnvironment.Production, "/v0/copilots/deleteCopilot"),
@@ -532,6 +548,8 @@ export class Copilots {
532
548
  timeoutMs: ((_g = (_e = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) !== null && _e !== void 0 ? _e : (_f = this._options) === null || _f === void 0 ? void 0 : _f.timeoutInSeconds) !== null && _g !== void 0 ? _g : 60) * 1000,
533
549
  maxRetries: (_h = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.maxRetries) !== null && _h !== void 0 ? _h : (_j = this._options) === null || _j === void 0 ? void 0 : _j.maxRetries,
534
550
  abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
551
+ fetchFn: (_k = this._options) === null || _k === void 0 ? void 0 : _k.fetch,
552
+ logging: this._options.logging,
535
553
  });
536
554
  if (_response.ok) {
537
555
  return { data: _response.body, rawResponse: _response.rawResponse };
@@ -34,7 +34,7 @@ export class DocumentCatalog {
34
34
  }
35
35
  __uploadDocumentContents(request, requestOptions) {
36
36
  return __awaiter(this, void 0, void 0, function* () {
37
- var _a, _b, _c, _d, _e, _f, _g, _h, _j;
37
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
38
38
  const _headers = mergeHeaders((_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, mergeOnlyDefinedHeaders({ Authorization: yield this._getAuthorizationHeader() }), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
39
39
  const _response = yield ((_b = this._options.fetcher) !== null && _b !== void 0 ? _b : core.fetcher)({
40
40
  url: core.url.join((_d = (_c = (yield core.Supplier.get(this._options.baseUrl))) !== null && _c !== void 0 ? _c : (yield core.Supplier.get(this._options.environment))) !== null && _d !== void 0 ? _d : environments.CredalEnvironment.Production, "/v0/catalog/uploadDocumentContents"),
@@ -47,6 +47,8 @@ export class DocumentCatalog {
47
47
  timeoutMs: ((_g = (_e = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) !== null && _e !== void 0 ? _e : (_f = this._options) === null || _f === void 0 ? void 0 : _f.timeoutInSeconds) !== null && _g !== void 0 ? _g : 60) * 1000,
48
48
  maxRetries: (_h = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.maxRetries) !== null && _h !== void 0 ? _h : (_j = this._options) === null || _j === void 0 ? void 0 : _j.maxRetries,
49
49
  abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
50
+ fetchFn: (_k = this._options) === null || _k === void 0 ? void 0 : _k.fetch,
51
+ logging: this._options.logging,
50
52
  });
51
53
  if (_response.ok) {
52
54
  return { data: _response.body, rawResponse: _response.rawResponse };
@@ -86,7 +88,7 @@ export class DocumentCatalog {
86
88
  }
87
89
  __uploadFile(request, requestOptions) {
88
90
  return __awaiter(this, void 0, void 0, function* () {
89
- var _a, _b, _c, _d, _e, _f, _g, _h, _j;
91
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
90
92
  const _request = yield core.newFormData();
91
93
  yield _request.appendFile("file", request.file);
92
94
  if (request.documentName != null) {
@@ -131,6 +133,8 @@ export class DocumentCatalog {
131
133
  timeoutMs: ((_g = (_e = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) !== null && _e !== void 0 ? _e : (_f = this._options) === null || _f === void 0 ? void 0 : _f.timeoutInSeconds) !== null && _g !== void 0 ? _g : 60) * 1000,
132
134
  maxRetries: (_h = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.maxRetries) !== null && _h !== void 0 ? _h : (_j = this._options) === null || _j === void 0 ? void 0 : _j.maxRetries,
133
135
  abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
136
+ fetchFn: (_k = this._options) === null || _k === void 0 ? void 0 : _k.fetch,
137
+ logging: this._options.logging,
134
138
  });
135
139
  if (_response.ok) {
136
140
  return { data: _response.body, rawResponse: _response.rawResponse };
@@ -176,7 +180,7 @@ export class DocumentCatalog {
176
180
  }
177
181
  __syncSourceByUrl(request, requestOptions) {
178
182
  return __awaiter(this, void 0, void 0, function* () {
179
- var _a, _b, _c, _d, _e, _f, _g, _h, _j;
183
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
180
184
  const _headers = mergeHeaders((_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, mergeOnlyDefinedHeaders({ Authorization: yield this._getAuthorizationHeader() }), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
181
185
  const _response = yield ((_b = this._options.fetcher) !== null && _b !== void 0 ? _b : core.fetcher)({
182
186
  url: core.url.join((_d = (_c = (yield core.Supplier.get(this._options.baseUrl))) !== null && _c !== void 0 ? _c : (yield core.Supplier.get(this._options.environment))) !== null && _d !== void 0 ? _d : environments.CredalEnvironment.Production, "/v0/catalog/syncSourceByUrl"),
@@ -189,6 +193,8 @@ export class DocumentCatalog {
189
193
  timeoutMs: ((_g = (_e = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) !== null && _e !== void 0 ? _e : (_f = this._options) === null || _f === void 0 ? void 0 : _f.timeoutInSeconds) !== null && _g !== void 0 ? _g : 60) * 1000,
190
194
  maxRetries: (_h = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.maxRetries) !== null && _h !== void 0 ? _h : (_j = this._options) === null || _j === void 0 ? void 0 : _j.maxRetries,
191
195
  abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
196
+ fetchFn: (_k = this._options) === null || _k === void 0 ? void 0 : _k.fetch,
197
+ logging: this._options.logging,
192
198
  });
193
199
  if (_response.ok) {
194
200
  return { data: _response.body, rawResponse: _response.rawResponse };
@@ -254,7 +260,7 @@ export class DocumentCatalog {
254
260
  }
255
261
  __metadata(request, requestOptions) {
256
262
  return __awaiter(this, void 0, void 0, function* () {
257
- var _a, _b, _c, _d, _e, _f, _g, _h, _j;
263
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
258
264
  const _headers = mergeHeaders((_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, mergeOnlyDefinedHeaders({ Authorization: yield this._getAuthorizationHeader() }), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
259
265
  const _response = yield ((_b = this._options.fetcher) !== null && _b !== void 0 ? _b : core.fetcher)({
260
266
  url: core.url.join((_d = (_c = (yield core.Supplier.get(this._options.baseUrl))) !== null && _c !== void 0 ? _c : (yield core.Supplier.get(this._options.environment))) !== null && _d !== void 0 ? _d : environments.CredalEnvironment.Production, "/v0/catalog/metadata"),
@@ -267,6 +273,8 @@ export class DocumentCatalog {
267
273
  timeoutMs: ((_g = (_e = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) !== null && _e !== void 0 ? _e : (_f = this._options) === null || _f === void 0 ? void 0 : _f.timeoutInSeconds) !== null && _g !== void 0 ? _g : 60) * 1000,
268
274
  maxRetries: (_h = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.maxRetries) !== null && _h !== void 0 ? _h : (_j = this._options) === null || _j === void 0 ? void 0 : _j.maxRetries,
269
275
  abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
276
+ fetchFn: (_k = this._options) === null || _k === void 0 ? void 0 : _k.fetch,
277
+ logging: this._options.logging,
270
278
  });
271
279
  if (_response.ok) {
272
280
  return { data: undefined, rawResponse: _response.rawResponse };