@credal/sdk 0.1.12 → 0.1.14

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 (66) hide show
  1. package/dist/cjs/BaseClient.d.ts +9 -1
  2. package/dist/cjs/BaseClient.js +10 -2
  3. package/dist/cjs/Client.d.ts +2 -1
  4. package/dist/cjs/Client.js +1 -1
  5. package/dist/cjs/api/resources/copilots/client/Client.d.ts +22 -2
  6. package/dist/cjs/api/resources/copilots/client/Client.js +81 -17
  7. package/dist/cjs/api/resources/copilots/client/requests/ExportCopilotsRequest.d.ts +21 -0
  8. package/dist/cjs/api/resources/copilots/client/requests/ExportCopilotsRequest.js +3 -0
  9. package/dist/cjs/api/resources/copilots/client/requests/index.d.ts +1 -0
  10. package/dist/cjs/api/resources/copilots/types/ExportCopilotsResponse.d.ts +9 -0
  11. package/dist/cjs/api/resources/copilots/types/ExportCopilotsResponse.js +3 -0
  12. package/dist/cjs/api/resources/copilots/types/ExportedCopilot.d.ts +24 -0
  13. package/dist/cjs/api/resources/copilots/types/ExportedCopilot.js +3 -0
  14. package/dist/cjs/api/resources/copilots/types/index.d.ts +2 -0
  15. package/dist/cjs/api/resources/copilots/types/index.js +2 -0
  16. package/dist/cjs/api/resources/documentCatalog/client/Client.d.ts +2 -2
  17. package/dist/cjs/api/resources/documentCatalog/client/Client.js +9 -17
  18. package/dist/cjs/api/resources/documentCollections/client/Client.d.ts +2 -2
  19. package/dist/cjs/api/resources/documentCollections/client/Client.js +15 -20
  20. package/dist/cjs/api/resources/search/client/Client.d.ts +2 -2
  21. package/dist/cjs/api/resources/search/client/Client.js +3 -14
  22. package/dist/cjs/api/resources/users/client/Client.d.ts +2 -2
  23. package/dist/cjs/api/resources/users/client/Client.js +3 -14
  24. package/dist/cjs/auth/BearerAuthProvider.d.ts +14 -0
  25. package/dist/cjs/auth/BearerAuthProvider.js +72 -0
  26. package/dist/cjs/auth/index.d.ts +1 -0
  27. package/dist/cjs/auth/index.js +5 -0
  28. package/dist/cjs/core/auth/AuthProvider.d.ts +4 -1
  29. package/dist/cjs/core/auth/BearerToken.d.ts +3 -1
  30. package/dist/cjs/core/auth/BearerToken.js +7 -6
  31. package/dist/cjs/version.d.ts +1 -1
  32. package/dist/cjs/version.js +1 -1
  33. package/dist/esm/BaseClient.d.mts +9 -1
  34. package/dist/esm/BaseClient.mjs +9 -2
  35. package/dist/esm/Client.d.mts +2 -1
  36. package/dist/esm/Client.mjs +2 -2
  37. package/dist/esm/api/resources/copilots/client/Client.d.mts +22 -2
  38. package/dist/esm/api/resources/copilots/client/Client.mjs +83 -19
  39. package/dist/esm/api/resources/copilots/client/requests/ExportCopilotsRequest.d.mts +21 -0
  40. package/dist/esm/api/resources/copilots/client/requests/ExportCopilotsRequest.mjs +2 -0
  41. package/dist/esm/api/resources/copilots/client/requests/index.d.mts +1 -0
  42. package/dist/esm/api/resources/copilots/types/ExportCopilotsResponse.d.mts +9 -0
  43. package/dist/esm/api/resources/copilots/types/ExportCopilotsResponse.mjs +2 -0
  44. package/dist/esm/api/resources/copilots/types/ExportedCopilot.d.mts +24 -0
  45. package/dist/esm/api/resources/copilots/types/ExportedCopilot.mjs +2 -0
  46. package/dist/esm/api/resources/copilots/types/index.d.mts +2 -0
  47. package/dist/esm/api/resources/copilots/types/index.mjs +2 -0
  48. package/dist/esm/api/resources/documentCatalog/client/Client.d.mts +2 -2
  49. package/dist/esm/api/resources/documentCatalog/client/Client.mjs +10 -18
  50. package/dist/esm/api/resources/documentCollections/client/Client.d.mts +2 -2
  51. package/dist/esm/api/resources/documentCollections/client/Client.mjs +17 -22
  52. package/dist/esm/api/resources/search/client/Client.d.mts +2 -2
  53. package/dist/esm/api/resources/search/client/Client.mjs +5 -16
  54. package/dist/esm/api/resources/users/client/Client.d.mts +2 -2
  55. package/dist/esm/api/resources/users/client/Client.mjs +5 -16
  56. package/dist/esm/auth/BearerAuthProvider.d.mts +14 -0
  57. package/dist/esm/auth/BearerAuthProvider.mjs +35 -0
  58. package/dist/esm/auth/index.d.mts +1 -0
  59. package/dist/esm/auth/index.mjs +1 -0
  60. package/dist/esm/core/auth/AuthProvider.d.mts +4 -1
  61. package/dist/esm/core/auth/BearerToken.d.mts +3 -1
  62. package/dist/esm/core/auth/BearerToken.mjs +7 -6
  63. package/dist/esm/version.d.mts +1 -1
  64. package/dist/esm/version.mjs +1 -1
  65. package/package.json +1 -1
  66. package/reference.md +72 -0
@@ -29,4 +29,12 @@ export interface BaseRequestOptions {
29
29
  /** Additional headers to include in the request. */
30
30
  headers?: Record<string, string | core.Supplier<string | null | undefined> | null | undefined>;
31
31
  }
32
- export declare function normalizeClientOptions<T extends BaseClientOptions>(options: T): T;
32
+ export type NormalizedClientOptions<T extends BaseClientOptions> = T & {
33
+ logging: core.logging.Logger;
34
+ authProvider?: core.AuthProvider;
35
+ };
36
+ export type NormalizedClientOptionsWithAuth<T extends BaseClientOptions> = NormalizedClientOptions<T> & {
37
+ authProvider: core.AuthProvider;
38
+ };
39
+ export declare function normalizeClientOptions<T extends BaseClientOptions>(options: T): NormalizedClientOptions<T>;
40
+ export declare function normalizeClientOptionsWithAuth<T extends BaseClientOptions>(options: T): NormalizedClientOptionsWithAuth<T>;
@@ -35,16 +35,24 @@ var __importStar = (this && this.__importStar) || (function () {
35
35
  })();
36
36
  Object.defineProperty(exports, "__esModule", { value: true });
37
37
  exports.normalizeClientOptions = normalizeClientOptions;
38
+ exports.normalizeClientOptionsWithAuth = normalizeClientOptionsWithAuth;
39
+ const BearerAuthProvider_js_1 = require("./auth/BearerAuthProvider.js");
38
40
  const headers_js_1 = require("./core/headers.js");
39
41
  const core = __importStar(require("./core/index.js"));
40
42
  function normalizeClientOptions(options) {
41
43
  const headers = (0, headers_js_1.mergeHeaders)({
42
44
  "X-Fern-Language": "JavaScript",
43
45
  "X-Fern-SDK-Name": "@credal/sdk",
44
- "X-Fern-SDK-Version": "0.1.12",
45
- "User-Agent": "@credal/sdk/0.1.12",
46
+ "X-Fern-SDK-Version": "0.1.14",
47
+ "User-Agent": "@credal/sdk/0.1.14",
46
48
  "X-Fern-Runtime": core.RUNTIME.type,
47
49
  "X-Fern-Runtime-Version": core.RUNTIME.version,
48
50
  }, options === null || options === void 0 ? void 0 : options.headers);
49
51
  return Object.assign(Object.assign({}, options), { logging: core.logging.createLogger(options === null || options === void 0 ? void 0 : options.logging), headers });
50
52
  }
53
+ function normalizeClientOptionsWithAuth(options) {
54
+ var _a;
55
+ const normalized = normalizeClientOptions(options);
56
+ (_a = normalized.authProvider) !== null && _a !== void 0 ? _a : (normalized.authProvider = new BearerAuthProvider_js_1.BearerAuthProvider(options));
57
+ return normalized;
58
+ }
@@ -4,6 +4,7 @@ import { DocumentCollectionsClient } from "./api/resources/documentCollections/c
4
4
  import { SearchClient } from "./api/resources/search/client/Client.js";
5
5
  import { UsersClient } from "./api/resources/users/client/Client.js";
6
6
  import type { BaseClientOptions, BaseRequestOptions } from "./BaseClient.js";
7
+ import { type NormalizedClientOptionsWithAuth } from "./BaseClient.js";
7
8
  export declare namespace CredalClient {
8
9
  interface Options extends BaseClientOptions {
9
10
  }
@@ -11,7 +12,7 @@ export declare namespace CredalClient {
11
12
  }
12
13
  }
13
14
  export declare class CredalClient {
14
- protected readonly _options: CredalClient.Options;
15
+ protected readonly _options: NormalizedClientOptionsWithAuth<CredalClient.Options>;
15
16
  protected _copilots: CopilotsClient | undefined;
16
17
  protected _documentCatalog: DocumentCatalogClient | undefined;
17
18
  protected _documentCollections: DocumentCollectionsClient | undefined;
@@ -10,7 +10,7 @@ const Client_js_5 = require("./api/resources/users/client/Client.js");
10
10
  const BaseClient_js_1 = require("./BaseClient.js");
11
11
  class CredalClient {
12
12
  constructor(options = {}) {
13
- this._options = (0, BaseClient_js_1.normalizeClientOptions)(options);
13
+ this._options = (0, BaseClient_js_1.normalizeClientOptionsWithAuth)(options);
14
14
  }
15
15
  get copilots() {
16
16
  var _a;
@@ -1,4 +1,5 @@
1
1
  import type { BaseClientOptions, BaseRequestOptions } from "../../../../BaseClient.js";
2
+ import { type NormalizedClientOptionsWithAuth } from "../../../../BaseClient.js";
2
3
  import * as core from "../../../../core/index.js";
3
4
  import type * as Credal from "../../../index.js";
4
5
  export declare namespace CopilotsClient {
@@ -8,7 +9,7 @@ export declare namespace CopilotsClient {
8
9
  }
9
10
  }
10
11
  export declare class CopilotsClient {
11
- protected readonly _options: CopilotsClient.Options;
12
+ protected readonly _options: NormalizedClientOptionsWithAuth<CopilotsClient.Options>;
12
13
  constructor(options?: CopilotsClient.Options);
13
14
  /**
14
15
  * Create a new agent. The API key used will be added to the agent for future Requests
@@ -146,5 +147,24 @@ export declare class CopilotsClient {
146
147
  */
147
148
  deleteCopilot(request: Credal.DeleteCopilotRequest, requestOptions?: CopilotsClient.RequestOptions): core.HttpResponsePromise<Credal.DeleteCopilotResponse>;
148
149
  private __deleteCopilot;
149
- protected _getAuthorizationHeader(): Promise<string>;
150
+ /**
151
+ * Export copilot configurations for backup or migration purposes.
152
+ *
153
+ * **IMPORTANT**: This endpoint requires:
154
+ * - Admin privileges
155
+ * - The 'ai-usage-analytics-log.export' scope on the API key
156
+ *
157
+ * Returns all deployed copilots with their full configuration including model settings, tools, and deployment details. Optional date filters can be applied to narrow down results.
158
+ *
159
+ * @param {Credal.ExportCopilotsRequest} request
160
+ * @param {CopilotsClient.RequestOptions} requestOptions - Request-specific configuration.
161
+ *
162
+ * @example
163
+ * await client.copilots.export({
164
+ * agentCreatedFrom: "2024-01-01T00:00:00Z",
165
+ * agentCreatedTo: "2024-12-31T23:59:59Z"
166
+ * })
167
+ */
168
+ export(request?: Credal.ExportCopilotsRequest, requestOptions?: CopilotsClient.RequestOptions): core.HttpResponsePromise<Credal.ExportCopilotsResponse>;
169
+ private __export;
150
170
  }
@@ -51,7 +51,7 @@ const environments = __importStar(require("../../../../environments.js"));
51
51
  const errors = __importStar(require("../../../../errors/index.js"));
52
52
  class CopilotsClient {
53
53
  constructor(options = {}) {
54
- this._options = (0, BaseClient_js_1.normalizeClientOptions)(options);
54
+ this._options = (0, BaseClient_js_1.normalizeClientOptionsWithAuth)(options);
55
55
  }
56
56
  /**
57
57
  * Create a new agent. The API key used will be added to the agent for future Requests
@@ -75,7 +75,8 @@ class CopilotsClient {
75
75
  __createCopilot(request, requestOptions) {
76
76
  return __awaiter(this, void 0, void 0, function* () {
77
77
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
78
- const _headers = (0, headers_js_1.mergeHeaders)((_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, (0, headers_js_1.mergeOnlyDefinedHeaders)({ Authorization: yield this._getAuthorizationHeader() }), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
78
+ const _authRequest = yield this._options.authProvider.getAuthRequest();
79
+ const _headers = (0, headers_js_1.mergeHeaders)(_authRequest.headers, (_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
79
80
  const _response = yield ((_b = this._options.fetcher) !== null && _b !== void 0 ? _b : core.fetcher)({
80
81
  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"),
81
82
  method: "POST",
@@ -135,7 +136,8 @@ class CopilotsClient {
135
136
  __createConversation(request, requestOptions) {
136
137
  return __awaiter(this, void 0, void 0, function* () {
137
138
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
138
- const _headers = (0, headers_js_1.mergeHeaders)((_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, (0, headers_js_1.mergeOnlyDefinedHeaders)({ Authorization: yield this._getAuthorizationHeader() }), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
139
+ const _authRequest = yield this._options.authProvider.getAuthRequest();
140
+ const _headers = (0, headers_js_1.mergeHeaders)(_authRequest.headers, (_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
139
141
  const _response = yield ((_b = this._options.fetcher) !== null && _b !== void 0 ? _b : core.fetcher)({
140
142
  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"),
141
143
  method: "POST",
@@ -199,7 +201,8 @@ class CopilotsClient {
199
201
  __provideMessageFeedback(request, requestOptions) {
200
202
  return __awaiter(this, void 0, void 0, function* () {
201
203
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
202
- const _headers = (0, headers_js_1.mergeHeaders)((_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, (0, headers_js_1.mergeOnlyDefinedHeaders)({ Authorization: yield this._getAuthorizationHeader() }), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
204
+ const _authRequest = yield this._options.authProvider.getAuthRequest();
205
+ const _headers = (0, headers_js_1.mergeHeaders)(_authRequest.headers, (_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
203
206
  const _response = yield ((_b = this._options.fetcher) !== null && _b !== void 0 ? _b : core.fetcher)({
204
207
  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"),
205
208
  method: "POST",
@@ -265,7 +268,8 @@ class CopilotsClient {
265
268
  __sendMessage(request, requestOptions) {
266
269
  return __awaiter(this, void 0, void 0, function* () {
267
270
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
268
- const _headers = (0, headers_js_1.mergeHeaders)((_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, (0, headers_js_1.mergeOnlyDefinedHeaders)({ Authorization: yield this._getAuthorizationHeader() }), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
271
+ const _authRequest = yield this._options.authProvider.getAuthRequest();
272
+ const _headers = (0, headers_js_1.mergeHeaders)(_authRequest.headers, (_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
269
273
  const _response = yield ((_b = this._options.fetcher) !== null && _b !== void 0 ? _b : core.fetcher)({
270
274
  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"),
271
275
  method: "POST",
@@ -316,7 +320,8 @@ class CopilotsClient {
316
320
  __streamMessage(request, requestOptions) {
317
321
  return __awaiter(this, void 0, void 0, function* () {
318
322
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
319
- const _headers = (0, headers_js_1.mergeHeaders)((_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, (0, headers_js_1.mergeOnlyDefinedHeaders)({ Authorization: yield this._getAuthorizationHeader() }), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
323
+ const _authRequest = yield this._options.authProvider.getAuthRequest();
324
+ const _headers = (0, headers_js_1.mergeHeaders)(_authRequest.headers, (_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
320
325
  const _response = yield ((_b = this._options.fetcher) !== null && _b !== void 0 ? _b : core.fetcher)({
321
326
  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"),
322
327
  method: "POST",
@@ -388,7 +393,8 @@ class CopilotsClient {
388
393
  __addCollectionToCopilot(request, requestOptions) {
389
394
  return __awaiter(this, void 0, void 0, function* () {
390
395
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
391
- const _headers = (0, headers_js_1.mergeHeaders)((_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, (0, headers_js_1.mergeOnlyDefinedHeaders)({ Authorization: yield this._getAuthorizationHeader() }), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
396
+ const _authRequest = yield this._options.authProvider.getAuthRequest();
397
+ const _headers = (0, headers_js_1.mergeHeaders)(_authRequest.headers, (_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
392
398
  const _response = yield ((_b = this._options.fetcher) !== null && _b !== void 0 ? _b : core.fetcher)({
393
399
  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"),
394
400
  method: "POST",
@@ -448,7 +454,8 @@ class CopilotsClient {
448
454
  __removeCollectionFromCopilot(request, requestOptions) {
449
455
  return __awaiter(this, void 0, void 0, function* () {
450
456
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
451
- const _headers = (0, headers_js_1.mergeHeaders)((_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, (0, headers_js_1.mergeOnlyDefinedHeaders)({ Authorization: yield this._getAuthorizationHeader() }), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
457
+ const _authRequest = yield this._options.authProvider.getAuthRequest();
458
+ const _headers = (0, headers_js_1.mergeHeaders)(_authRequest.headers, (_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
452
459
  const _response = yield ((_b = this._options.fetcher) !== null && _b !== void 0 ? _b : core.fetcher)({
453
460
  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"),
454
461
  method: "POST",
@@ -516,7 +523,8 @@ class CopilotsClient {
516
523
  __updateConfiguration(request, requestOptions) {
517
524
  return __awaiter(this, void 0, void 0, function* () {
518
525
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
519
- const _headers = (0, headers_js_1.mergeHeaders)((_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, (0, headers_js_1.mergeOnlyDefinedHeaders)({ Authorization: yield this._getAuthorizationHeader() }), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
526
+ const _authRequest = yield this._options.authProvider.getAuthRequest();
527
+ const _headers = (0, headers_js_1.mergeHeaders)(_authRequest.headers, (_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
520
528
  const _response = yield ((_b = this._options.fetcher) !== null && _b !== void 0 ? _b : core.fetcher)({
521
529
  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"),
522
530
  method: "POST",
@@ -573,7 +581,8 @@ class CopilotsClient {
573
581
  __deleteCopilot(request, requestOptions) {
574
582
  return __awaiter(this, void 0, void 0, function* () {
575
583
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
576
- const _headers = (0, headers_js_1.mergeHeaders)((_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, (0, headers_js_1.mergeOnlyDefinedHeaders)({ Authorization: yield this._getAuthorizationHeader() }), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
584
+ const _authRequest = yield this._options.authProvider.getAuthRequest();
585
+ const _headers = (0, headers_js_1.mergeHeaders)(_authRequest.headers, (_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
577
586
  const _response = yield ((_b = this._options.fetcher) !== null && _b !== void 0 ? _b : core.fetcher)({
578
587
  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"),
579
588
  method: "DELETE",
@@ -615,16 +624,71 @@ class CopilotsClient {
615
624
  }
616
625
  });
617
626
  }
618
- _getAuthorizationHeader() {
619
- return __awaiter(this, void 0, void 0, function* () {
620
- var _a;
621
- const bearer = (_a = (yield core.Supplier.get(this._options.apiKey))) !== null && _a !== void 0 ? _a : process === null || process === void 0 ? void 0 : process.env.CREDAL_API_KEY;
622
- if (bearer == null) {
627
+ /**
628
+ * Export copilot configurations for backup or migration purposes.
629
+ *
630
+ * **IMPORTANT**: This endpoint requires:
631
+ * - Admin privileges
632
+ * - The 'ai-usage-analytics-log.export' scope on the API key
633
+ *
634
+ * Returns all deployed copilots with their full configuration including model settings, tools, and deployment details. Optional date filters can be applied to narrow down results.
635
+ *
636
+ * @param {Credal.ExportCopilotsRequest} request
637
+ * @param {CopilotsClient.RequestOptions} requestOptions - Request-specific configuration.
638
+ *
639
+ * @example
640
+ * await client.copilots.export({
641
+ * agentCreatedFrom: "2024-01-01T00:00:00Z",
642
+ * agentCreatedTo: "2024-12-31T23:59:59Z"
643
+ * })
644
+ */
645
+ export(request = {}, requestOptions) {
646
+ return core.HttpResponsePromise.fromPromise(this.__export(request, requestOptions));
647
+ }
648
+ __export() {
649
+ return __awaiter(this, arguments, void 0, function* (request = {}, requestOptions) {
650
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
651
+ const _authRequest = yield this._options.authProvider.getAuthRequest();
652
+ const _headers = (0, headers_js_1.mergeHeaders)(_authRequest.headers, (_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
653
+ const _response = yield ((_b = this._options.fetcher) !== null && _b !== void 0 ? _b : core.fetcher)({
654
+ 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/export"),
655
+ method: "POST",
656
+ headers: _headers,
657
+ contentType: "application/json",
658
+ queryParameters: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.queryParams,
659
+ requestType: "json",
660
+ body: request,
661
+ 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,
662
+ 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,
663
+ abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
664
+ fetchFn: (_k = this._options) === null || _k === void 0 ? void 0 : _k.fetch,
665
+ logging: this._options.logging,
666
+ });
667
+ if (_response.ok) {
668
+ return { data: _response.body, rawResponse: _response.rawResponse };
669
+ }
670
+ if (_response.error.reason === "status-code") {
623
671
  throw new errors.CredalError({
624
- message: "Please specify a bearer by either passing it in to the constructor or initializing a CREDAL_API_KEY environment variable",
672
+ statusCode: _response.error.statusCode,
673
+ body: _response.error.body,
674
+ rawResponse: _response.rawResponse,
625
675
  });
626
676
  }
627
- return `Bearer ${bearer}`;
677
+ switch (_response.error.reason) {
678
+ case "non-json":
679
+ throw new errors.CredalError({
680
+ statusCode: _response.error.statusCode,
681
+ body: _response.error.rawBody,
682
+ rawResponse: _response.rawResponse,
683
+ });
684
+ case "timeout":
685
+ throw new errors.CredalTimeoutError("Timeout exceeded when calling POST /v0/copilots/export.");
686
+ case "unknown":
687
+ throw new errors.CredalError({
688
+ message: _response.error.errorMessage,
689
+ rawResponse: _response.rawResponse,
690
+ });
691
+ }
628
692
  });
629
693
  }
630
694
  }
@@ -0,0 +1,21 @@
1
+ /**
2
+ * @example
3
+ * {
4
+ * agentCreatedFrom: "2024-01-01T00:00:00Z",
5
+ * agentCreatedTo: "2024-12-31T23:59:59Z"
6
+ * }
7
+ */
8
+ export interface ExportCopilotsRequest {
9
+ /** Filter copilots created on or after this datetime (ISO 8601 format). */
10
+ agentCreatedFrom?: string;
11
+ /** Filter copilots created before or on this datetime (ISO 8601 format). */
12
+ agentCreatedTo?: string;
13
+ /** Filter copilot versions created on or after this datetime (ISO 8601 format). */
14
+ versionCreatedFrom?: string;
15
+ /** Filter copilot versions created before or on this datetime (ISO 8601 format). */
16
+ versionCreatedTo?: string;
17
+ /** Maximum number of copilots to return. Must be a positive integer with a maximum value of 1000. Defaults to 100. */
18
+ limit?: number;
19
+ /** Cursor for pagination. Use the cursor returned in the previous response to fetch the next page of results. If not provided, returns the first page. */
20
+ cursor?: string;
21
+ }
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ // This file was auto-generated by Fern from our API Definition.
3
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -2,6 +2,7 @@ export type { AddCollectionToCopilotRequest } from "./AddCollectionToCopilotRequ
2
2
  export type { CreateConversationRequest } from "./CreateConversationRequest.js";
3
3
  export type { CreateCopilotRequest } from "./CreateCopilotRequest.js";
4
4
  export type { DeleteCopilotRequest } from "./DeleteCopilotRequest.js";
5
+ export type { ExportCopilotsRequest } from "./ExportCopilotsRequest.js";
5
6
  export type { ProvideMessageFeedbackRequest } from "./ProvideMessageFeedbackRequest.js";
6
7
  export type { RemoveCollectionFromCopilotRequest } from "./RemoveCollectionFromCopilotRequest.js";
7
8
  export type { SendMessageRequest } from "./SendMessageRequest.js";
@@ -0,0 +1,9 @@
1
+ import type * as Credal from "../../../index.js";
2
+ export interface ExportCopilotsResponse {
3
+ /** List of exported copilots matching the query filters. */
4
+ data: Credal.ExportedCopilot[];
5
+ /** Indicates whether there are more results available for pagination. */
6
+ hasMore: boolean;
7
+ /** Cursor to use for fetching the next page of results. This is a UUID string. If null or not present, there are no more results. */
8
+ nextCursor?: string;
9
+ }
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ // This file was auto-generated by Fern from our API Definition.
3
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,24 @@
1
+ export interface ExportedCopilot {
2
+ /** The unique identifier of the copilot. */
3
+ id: string;
4
+ /** The name of the deployed copilot version. */
5
+ name: string;
6
+ /** The description of the deployed copilot version. */
7
+ description: string;
8
+ /** Model configuration including provider, model name, temperature, and other settings. */
9
+ modelConfiguration?: unknown;
10
+ /** AI endpoint configuration including base URL and authentication details. */
11
+ aiEndpointConfiguration?: unknown;
12
+ /** List of tool configurations available to the copilot. */
13
+ toolConfigurations?: unknown;
14
+ /** Input variable configurations for the copilot. */
15
+ inputs?: unknown;
16
+ /** Deployment settings and configuration. */
17
+ deploymentConfiguration?: unknown;
18
+ /** ISO 8601 timestamp when the copilot was originally created. */
19
+ agentCreatedDatetime: string;
20
+ /** ISO 8601 timestamp when the deployed version was created. */
21
+ versionCreatedDatetime: string;
22
+ /** Indicates if the copilot is currently deployed (always true for export results). */
23
+ isDeployed: boolean;
24
+ }
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ // This file was auto-generated by Fern from our API Definition.
3
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -12,6 +12,8 @@ export * from "./DeleteCopilotResponse.js";
12
12
  export * from "./EndOfMessageChunk.js";
13
13
  export * from "./ErrorChunk.js";
14
14
  export * from "./ErrorChunkData.js";
15
+ export * from "./ExportCopilotsResponse.js";
16
+ export * from "./ExportedCopilot.js";
15
17
  export * from "./FeedbackEnum.js";
16
18
  export * from "./Filter.js";
17
19
  export * from "./FinalChunk.js";
@@ -28,6 +28,8 @@ __exportStar(require("./DeleteCopilotResponse.js"), exports);
28
28
  __exportStar(require("./EndOfMessageChunk.js"), exports);
29
29
  __exportStar(require("./ErrorChunk.js"), exports);
30
30
  __exportStar(require("./ErrorChunkData.js"), exports);
31
+ __exportStar(require("./ExportCopilotsResponse.js"), exports);
32
+ __exportStar(require("./ExportedCopilot.js"), exports);
31
33
  __exportStar(require("./FeedbackEnum.js"), exports);
32
34
  __exportStar(require("./Filter.js"), exports);
33
35
  __exportStar(require("./FinalChunk.js"), exports);
@@ -1,4 +1,5 @@
1
1
  import type { BaseClientOptions, BaseRequestOptions } from "../../../../BaseClient.js";
2
+ import { type NormalizedClientOptionsWithAuth } from "../../../../BaseClient.js";
2
3
  import * as core from "../../../../core/index.js";
3
4
  import type * as Credal from "../../../index.js";
4
5
  export declare namespace DocumentCatalogClient {
@@ -8,7 +9,7 @@ export declare namespace DocumentCatalogClient {
8
9
  }
9
10
  }
10
11
  export declare class DocumentCatalogClient {
11
- protected readonly _options: DocumentCatalogClient.Options;
12
+ protected readonly _options: NormalizedClientOptionsWithAuth<DocumentCatalogClient.Options>;
12
13
  constructor(options?: DocumentCatalogClient.Options);
13
14
  /**
14
15
  * @param {Credal.UploadDocumentContentsRequest} request
@@ -81,5 +82,4 @@ export declare class DocumentCatalogClient {
81
82
  */
82
83
  metadata(request: Credal.DocumentMetadataPatchRequest, requestOptions?: DocumentCatalogClient.RequestOptions): core.HttpResponsePromise<void>;
83
84
  private __metadata;
84
- protected _getAuthorizationHeader(): Promise<string>;
85
85
  }
@@ -51,7 +51,7 @@ const environments = __importStar(require("../../../../environments.js"));
51
51
  const errors = __importStar(require("../../../../errors/index.js"));
52
52
  class DocumentCatalogClient {
53
53
  constructor(options = {}) {
54
- this._options = (0, BaseClient_js_1.normalizeClientOptions)(options);
54
+ this._options = (0, BaseClient_js_1.normalizeClientOptionsWithAuth)(options);
55
55
  }
56
56
  /**
57
57
  * @param {Credal.UploadDocumentContentsRequest} request
@@ -72,7 +72,8 @@ class DocumentCatalogClient {
72
72
  __uploadDocumentContents(request, requestOptions) {
73
73
  return __awaiter(this, void 0, void 0, function* () {
74
74
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
75
- const _headers = (0, headers_js_1.mergeHeaders)((_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, (0, headers_js_1.mergeOnlyDefinedHeaders)({ Authorization: yield this._getAuthorizationHeader() }), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
75
+ const _authRequest = yield this._options.authProvider.getAuthRequest();
76
+ const _headers = (0, headers_js_1.mergeHeaders)(_authRequest.headers, (_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
76
77
  const _response = yield ((_b = this._options.fetcher) !== null && _b !== void 0 ? _b : core.fetcher)({
77
78
  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"),
78
79
  method: "POST",
@@ -158,7 +159,8 @@ class DocumentCatalogClient {
158
159
  _request.append("awaitVectorStoreSync", request.awaitVectorStoreSync);
159
160
  }
160
161
  const _maybeEncodedRequest = yield _request.getRequest();
161
- const _headers = (0, headers_js_1.mergeHeaders)((_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, (0, headers_js_1.mergeOnlyDefinedHeaders)(Object.assign({ Authorization: yield this._getAuthorizationHeader() }, _maybeEncodedRequest.headers)), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
162
+ const _authRequest = yield this._options.authProvider.getAuthRequest();
163
+ const _headers = (0, headers_js_1.mergeHeaders)(_authRequest.headers, (_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, (0, headers_js_1.mergeOnlyDefinedHeaders)(Object.assign({}, _maybeEncodedRequest.headers)), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
162
164
  const _response = yield ((_b = this._options.fetcher) !== null && _b !== void 0 ? _b : core.fetcher)({
163
165
  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/uploadFile"),
164
166
  method: "POST",
@@ -218,7 +220,8 @@ class DocumentCatalogClient {
218
220
  __syncSourceByUrl(request, requestOptions) {
219
221
  return __awaiter(this, void 0, void 0, function* () {
220
222
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
221
- const _headers = (0, headers_js_1.mergeHeaders)((_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, (0, headers_js_1.mergeOnlyDefinedHeaders)({ Authorization: yield this._getAuthorizationHeader() }), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
223
+ const _authRequest = yield this._options.authProvider.getAuthRequest();
224
+ const _headers = (0, headers_js_1.mergeHeaders)(_authRequest.headers, (_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
222
225
  const _response = yield ((_b = this._options.fetcher) !== null && _b !== void 0 ? _b : core.fetcher)({
223
226
  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"),
224
227
  method: "POST",
@@ -298,7 +301,8 @@ class DocumentCatalogClient {
298
301
  __metadata(request, requestOptions) {
299
302
  return __awaiter(this, void 0, void 0, function* () {
300
303
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
301
- const _headers = (0, headers_js_1.mergeHeaders)((_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, (0, headers_js_1.mergeOnlyDefinedHeaders)({ Authorization: yield this._getAuthorizationHeader() }), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
304
+ const _authRequest = yield this._options.authProvider.getAuthRequest();
305
+ const _headers = (0, headers_js_1.mergeHeaders)(_authRequest.headers, (_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
302
306
  const _response = yield ((_b = this._options.fetcher) !== null && _b !== void 0 ? _b : core.fetcher)({
303
307
  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"),
304
308
  method: "PATCH",
@@ -340,17 +344,5 @@ class DocumentCatalogClient {
340
344
  }
341
345
  });
342
346
  }
343
- _getAuthorizationHeader() {
344
- return __awaiter(this, void 0, void 0, function* () {
345
- var _a;
346
- const bearer = (_a = (yield core.Supplier.get(this._options.apiKey))) !== null && _a !== void 0 ? _a : process === null || process === void 0 ? void 0 : process.env.CREDAL_API_KEY;
347
- if (bearer == null) {
348
- throw new errors.CredalError({
349
- message: "Please specify a bearer by either passing it in to the constructor or initializing a CREDAL_API_KEY environment variable",
350
- });
351
- }
352
- return `Bearer ${bearer}`;
353
- });
354
- }
355
347
  }
356
348
  exports.DocumentCatalogClient = DocumentCatalogClient;
@@ -1,4 +1,5 @@
1
1
  import type { BaseClientOptions, BaseRequestOptions } from "../../../../BaseClient.js";
2
+ import { type NormalizedClientOptionsWithAuth } from "../../../../BaseClient.js";
2
3
  import * as core from "../../../../core/index.js";
3
4
  import type * as Credal from "../../../index.js";
4
5
  export declare namespace DocumentCollectionsClient {
@@ -8,7 +9,7 @@ export declare namespace DocumentCollectionsClient {
8
9
  }
9
10
  }
10
11
  export declare class DocumentCollectionsClient {
11
- protected readonly _options: DocumentCollectionsClient.Options;
12
+ protected readonly _options: NormalizedClientOptionsWithAuth<DocumentCollectionsClient.Options>;
12
13
  constructor(options?: DocumentCollectionsClient.Options);
13
14
  /**
14
15
  * Add documents to a document collection. Note that the documents must already exist in the document catalog to use this endpoint. If you want to upload a new document to a collection, use the `uploadDocumentContents` endpoint.
@@ -156,5 +157,4 @@ export declare class DocumentCollectionsClient {
156
157
  */
157
158
  updateMongoCollectionSync(request: Credal.UpdateMongoCollectionSyncRequest, requestOptions?: DocumentCollectionsClient.RequestOptions): core.HttpResponsePromise<Credal.MongoCollectionSyncResponse>;
158
159
  private __updateMongoCollectionSync;
159
- protected _getAuthorizationHeader(): Promise<string>;
160
160
  }
@@ -51,7 +51,7 @@ const environments = __importStar(require("../../../../environments.js"));
51
51
  const errors = __importStar(require("../../../../errors/index.js"));
52
52
  class DocumentCollectionsClient {
53
53
  constructor(options = {}) {
54
- this._options = (0, BaseClient_js_1.normalizeClientOptions)(options);
54
+ this._options = (0, BaseClient_js_1.normalizeClientOptionsWithAuth)(options);
55
55
  }
56
56
  /**
57
57
  * Add documents to a document collection. Note that the documents must already exist in the document catalog to use this endpoint. If you want to upload a new document to a collection, use the `uploadDocumentContents` endpoint.
@@ -79,7 +79,8 @@ class DocumentCollectionsClient {
79
79
  __addDocumentsToCollection(request, requestOptions) {
80
80
  return __awaiter(this, void 0, void 0, function* () {
81
81
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
82
- const _headers = (0, headers_js_1.mergeHeaders)((_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, (0, headers_js_1.mergeOnlyDefinedHeaders)({ Authorization: yield this._getAuthorizationHeader() }), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
82
+ const _authRequest = yield this._options.authProvider.getAuthRequest();
83
+ const _headers = (0, headers_js_1.mergeHeaders)(_authRequest.headers, (_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
83
84
  const _response = yield ((_b = this._options.fetcher) !== null && _b !== void 0 ? _b : core.fetcher)({
84
85
  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/documentCollections/addDocumentsToCollection"),
85
86
  method: "POST",
@@ -147,7 +148,8 @@ class DocumentCollectionsClient {
147
148
  __removeDocumentsFromCollection(request, requestOptions) {
148
149
  return __awaiter(this, void 0, void 0, function* () {
149
150
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
150
- const _headers = (0, headers_js_1.mergeHeaders)((_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, (0, headers_js_1.mergeOnlyDefinedHeaders)({ Authorization: yield this._getAuthorizationHeader() }), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
151
+ const _authRequest = yield this._options.authProvider.getAuthRequest();
152
+ const _headers = (0, headers_js_1.mergeHeaders)(_authRequest.headers, (_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
151
153
  const _response = yield ((_b = this._options.fetcher) !== null && _b !== void 0 ? _b : core.fetcher)({
152
154
  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/documentCollections/removeDocumentsFromCollection"),
153
155
  method: "DELETE",
@@ -209,7 +211,8 @@ class DocumentCollectionsClient {
209
211
  const { collectionId } = request;
210
212
  const _queryParams = {};
211
213
  _queryParams.collectionId = collectionId;
212
- const _headers = (0, headers_js_1.mergeHeaders)((_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, (0, headers_js_1.mergeOnlyDefinedHeaders)({ Authorization: yield this._getAuthorizationHeader() }), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
214
+ const _authRequest = yield this._options.authProvider.getAuthRequest();
215
+ const _headers = (0, headers_js_1.mergeHeaders)(_authRequest.headers, (_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
213
216
  const _response = yield ((_b = this._options.fetcher) !== null && _b !== void 0 ? _b : core.fetcher)({
214
217
  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/documentCollections/listDocumentsInCollection"),
215
218
  method: "GET",
@@ -273,7 +276,8 @@ class DocumentCollectionsClient {
273
276
  __createCollection(request, requestOptions) {
274
277
  return __awaiter(this, void 0, void 0, function* () {
275
278
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
276
- const _headers = (0, headers_js_1.mergeHeaders)((_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, (0, headers_js_1.mergeOnlyDefinedHeaders)({ Authorization: yield this._getAuthorizationHeader() }), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
279
+ const _authRequest = yield this._options.authProvider.getAuthRequest();
280
+ const _headers = (0, headers_js_1.mergeHeaders)(_authRequest.headers, (_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
277
281
  const _response = yield ((_b = this._options.fetcher) !== null && _b !== void 0 ? _b : core.fetcher)({
278
282
  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/documentCollections/createCollection"),
279
283
  method: "POST",
@@ -332,7 +336,8 @@ class DocumentCollectionsClient {
332
336
  __deleteCollection(request, requestOptions) {
333
337
  return __awaiter(this, void 0, void 0, function* () {
334
338
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
335
- const _headers = (0, headers_js_1.mergeHeaders)((_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, (0, headers_js_1.mergeOnlyDefinedHeaders)({ Authorization: yield this._getAuthorizationHeader() }), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
339
+ const _authRequest = yield this._options.authProvider.getAuthRequest();
340
+ const _headers = (0, headers_js_1.mergeHeaders)(_authRequest.headers, (_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
336
341
  const _response = yield ((_b = this._options.fetcher) !== null && _b !== void 0 ? _b : core.fetcher)({
337
342
  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/documentCollections/deleteCollection"),
338
343
  method: "DELETE",
@@ -407,7 +412,8 @@ class DocumentCollectionsClient {
407
412
  __createMongoCollectionSync(request, requestOptions) {
408
413
  return __awaiter(this, void 0, void 0, function* () {
409
414
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
410
- const _headers = (0, headers_js_1.mergeHeaders)((_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, (0, headers_js_1.mergeOnlyDefinedHeaders)({ Authorization: yield this._getAuthorizationHeader() }), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
415
+ const _authRequest = yield this._options.authProvider.getAuthRequest();
416
+ const _headers = (0, headers_js_1.mergeHeaders)(_authRequest.headers, (_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
411
417
  const _response = yield ((_b = this._options.fetcher) !== null && _b !== void 0 ? _b : core.fetcher)({
412
418
  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/documentCollections/mongodb/createMongoSync"),
413
419
  method: "POST",
@@ -482,7 +488,8 @@ class DocumentCollectionsClient {
482
488
  __updateMongoCollectionSync(request, requestOptions) {
483
489
  return __awaiter(this, void 0, void 0, function* () {
484
490
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
485
- const _headers = (0, headers_js_1.mergeHeaders)((_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, (0, headers_js_1.mergeOnlyDefinedHeaders)({ Authorization: yield this._getAuthorizationHeader() }), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
491
+ const _authRequest = yield this._options.authProvider.getAuthRequest();
492
+ const _headers = (0, headers_js_1.mergeHeaders)(_authRequest.headers, (_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
486
493
  const _response = yield ((_b = this._options.fetcher) !== null && _b !== void 0 ? _b : core.fetcher)({
487
494
  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/documentCollections/mongodb/updateMongoSync"),
488
495
  method: "POST",
@@ -524,17 +531,5 @@ class DocumentCollectionsClient {
524
531
  }
525
532
  });
526
533
  }
527
- _getAuthorizationHeader() {
528
- return __awaiter(this, void 0, void 0, function* () {
529
- var _a;
530
- const bearer = (_a = (yield core.Supplier.get(this._options.apiKey))) !== null && _a !== void 0 ? _a : process === null || process === void 0 ? void 0 : process.env.CREDAL_API_KEY;
531
- if (bearer == null) {
532
- throw new errors.CredalError({
533
- message: "Please specify a bearer by either passing it in to the constructor or initializing a CREDAL_API_KEY environment variable",
534
- });
535
- }
536
- return `Bearer ${bearer}`;
537
- });
538
- }
539
534
  }
540
535
  exports.DocumentCollectionsClient = DocumentCollectionsClient;