@credal/sdk 0.1.11 → 0.1.13

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 (48) hide show
  1. package/dist/cjs/BaseClient.d.ts +10 -1
  2. package/dist/cjs/BaseClient.js +55 -0
  3. package/dist/cjs/Client.d.ts +18 -17
  4. package/dist/cjs/Client.js +8 -49
  5. package/dist/cjs/api/resources/copilots/client/Client.d.ts +22 -22
  6. package/dist/cjs/api/resources/copilots/client/Client.js +32 -34
  7. package/dist/cjs/api/resources/documentCatalog/client/Client.d.ts +13 -13
  8. package/dist/cjs/api/resources/documentCatalog/client/Client.js +18 -25
  9. package/dist/cjs/api/resources/documentCollections/client/Client.d.ts +19 -19
  10. package/dist/cjs/api/resources/documentCollections/client/Client.js +27 -31
  11. package/dist/cjs/api/resources/search/client/Client.d.ts +7 -7
  12. package/dist/cjs/api/resources/search/client/Client.js +9 -19
  13. package/dist/cjs/api/resources/users/client/Client.d.ts +7 -7
  14. package/dist/cjs/api/resources/users/client/Client.js +9 -19
  15. package/dist/cjs/auth/BearerAuthProvider.d.ts +14 -0
  16. package/dist/cjs/auth/BearerAuthProvider.js +72 -0
  17. package/dist/cjs/auth/index.d.ts +1 -0
  18. package/dist/cjs/auth/index.js +5 -0
  19. package/dist/cjs/core/auth/AuthProvider.d.ts +4 -1
  20. package/dist/cjs/core/auth/BearerToken.d.ts +3 -1
  21. package/dist/cjs/core/auth/BearerToken.js +7 -6
  22. package/dist/cjs/version.d.ts +1 -1
  23. package/dist/cjs/version.js +1 -1
  24. package/dist/esm/BaseClient.d.mts +10 -1
  25. package/dist/esm/BaseClient.mjs +20 -1
  26. package/dist/esm/Client.d.mts +18 -17
  27. package/dist/esm/Client.mjs +13 -21
  28. package/dist/esm/api/resources/copilots/client/Client.d.mts +22 -22
  29. package/dist/esm/api/resources/copilots/client/Client.mjs +31 -33
  30. package/dist/esm/api/resources/documentCatalog/client/Client.d.mts +13 -13
  31. package/dist/esm/api/resources/documentCatalog/client/Client.mjs +16 -23
  32. package/dist/esm/api/resources/documentCollections/client/Client.d.mts +19 -19
  33. package/dist/esm/api/resources/documentCollections/client/Client.mjs +26 -30
  34. package/dist/esm/api/resources/search/client/Client.d.mts +7 -7
  35. package/dist/esm/api/resources/search/client/Client.mjs +8 -18
  36. package/dist/esm/api/resources/users/client/Client.d.mts +7 -7
  37. package/dist/esm/api/resources/users/client/Client.mjs +8 -18
  38. package/dist/esm/auth/BearerAuthProvider.d.mts +14 -0
  39. package/dist/esm/auth/BearerAuthProvider.mjs +35 -0
  40. package/dist/esm/auth/index.d.mts +1 -0
  41. package/dist/esm/auth/index.mjs +1 -0
  42. package/dist/esm/core/auth/AuthProvider.d.mts +4 -1
  43. package/dist/esm/core/auth/BearerToken.d.mts +3 -1
  44. package/dist/esm/core/auth/BearerToken.mjs +7 -6
  45. package/dist/esm/version.d.mts +1 -1
  46. package/dist/esm/version.mjs +1 -1
  47. package/package.json +1 -1
  48. package/reference.md +21 -21
@@ -1,4 +1,4 @@
1
- import type * as core from "./core/index.js";
1
+ import * as core from "./core/index.js";
2
2
  import type * as environments from "./environments.js";
3
3
  export interface BaseClientOptions {
4
4
  environment?: core.Supplier<environments.CredalEnvironment | string>;
@@ -29,3 +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 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>;
@@ -1,3 +1,58 @@
1
1
  "use strict";
2
2
  // This file was auto-generated by Fern from our API Definition.
3
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
4
+ if (k2 === undefined) k2 = k;
5
+ var desc = Object.getOwnPropertyDescriptor(m, k);
6
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
7
+ desc = { enumerable: true, get: function() { return m[k]; } };
8
+ }
9
+ Object.defineProperty(o, k2, desc);
10
+ }) : (function(o, m, k, k2) {
11
+ if (k2 === undefined) k2 = k;
12
+ o[k2] = m[k];
13
+ }));
14
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
15
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
16
+ }) : function(o, v) {
17
+ o["default"] = v;
18
+ });
19
+ var __importStar = (this && this.__importStar) || (function () {
20
+ var ownKeys = function(o) {
21
+ ownKeys = Object.getOwnPropertyNames || function (o) {
22
+ var ar = [];
23
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
24
+ return ar;
25
+ };
26
+ return ownKeys(o);
27
+ };
28
+ return function (mod) {
29
+ if (mod && mod.__esModule) return mod;
30
+ var result = {};
31
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
32
+ __setModuleDefault(result, mod);
33
+ return result;
34
+ };
35
+ })();
3
36
  Object.defineProperty(exports, "__esModule", { value: true });
37
+ exports.normalizeClientOptions = normalizeClientOptions;
38
+ exports.normalizeClientOptionsWithAuth = normalizeClientOptionsWithAuth;
39
+ const BearerAuthProvider_js_1 = require("./auth/BearerAuthProvider.js");
40
+ const headers_js_1 = require("./core/headers.js");
41
+ const core = __importStar(require("./core/index.js"));
42
+ function normalizeClientOptions(options) {
43
+ const headers = (0, headers_js_1.mergeHeaders)({
44
+ "X-Fern-Language": "JavaScript",
45
+ "X-Fern-SDK-Name": "@credal/sdk",
46
+ "X-Fern-SDK-Version": "0.1.13",
47
+ "User-Agent": "@credal/sdk/0.1.13",
48
+ "X-Fern-Runtime": core.RUNTIME.type,
49
+ "X-Fern-Runtime-Version": core.RUNTIME.version,
50
+ }, options === null || options === void 0 ? void 0 : options.headers);
51
+ return Object.assign(Object.assign({}, options), { logging: core.logging.createLogger(options === null || options === void 0 ? void 0 : options.logging), headers });
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
+ }
@@ -1,9 +1,10 @@
1
- import { Copilots } from "./api/resources/copilots/client/Client.js";
2
- import { DocumentCatalog } from "./api/resources/documentCatalog/client/Client.js";
3
- import { DocumentCollections } from "./api/resources/documentCollections/client/Client.js";
4
- import { Search } from "./api/resources/search/client/Client.js";
5
- import { Users } from "./api/resources/users/client/Client.js";
1
+ import { CopilotsClient } from "./api/resources/copilots/client/Client.js";
2
+ import { DocumentCatalogClient } from "./api/resources/documentCatalog/client/Client.js";
3
+ import { DocumentCollectionsClient } from "./api/resources/documentCollections/client/Client.js";
4
+ import { SearchClient } from "./api/resources/search/client/Client.js";
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,16 +12,16 @@ export declare namespace CredalClient {
11
12
  }
12
13
  }
13
14
  export declare class CredalClient {
14
- protected readonly _options: CredalClient.Options;
15
- protected _copilots: Copilots | undefined;
16
- protected _documentCatalog: DocumentCatalog | undefined;
17
- protected _documentCollections: DocumentCollections | undefined;
18
- protected _search: Search | undefined;
19
- protected _users: Users | undefined;
20
- constructor(_options?: CredalClient.Options);
21
- get copilots(): Copilots;
22
- get documentCatalog(): DocumentCatalog;
23
- get documentCollections(): DocumentCollections;
24
- get search(): Search;
25
- get users(): Users;
15
+ protected readonly _options: NormalizedClientOptionsWithAuth<CredalClient.Options>;
16
+ protected _copilots: CopilotsClient | undefined;
17
+ protected _documentCatalog: DocumentCatalogClient | undefined;
18
+ protected _documentCollections: DocumentCollectionsClient | undefined;
19
+ protected _search: SearchClient | undefined;
20
+ protected _users: UsersClient | undefined;
21
+ constructor(options?: CredalClient.Options);
22
+ get copilots(): CopilotsClient;
23
+ get documentCatalog(): DocumentCatalogClient;
24
+ get documentCollections(): DocumentCollectionsClient;
25
+ get search(): SearchClient;
26
+ get users(): UsersClient;
26
27
  }
@@ -1,38 +1,5 @@
1
1
  "use strict";
2
2
  // This file was auto-generated by Fern from our API Definition.
3
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
4
- if (k2 === undefined) k2 = k;
5
- var desc = Object.getOwnPropertyDescriptor(m, k);
6
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
7
- desc = { enumerable: true, get: function() { return m[k]; } };
8
- }
9
- Object.defineProperty(o, k2, desc);
10
- }) : (function(o, m, k, k2) {
11
- if (k2 === undefined) k2 = k;
12
- o[k2] = m[k];
13
- }));
14
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
15
- Object.defineProperty(o, "default", { enumerable: true, value: v });
16
- }) : function(o, v) {
17
- o["default"] = v;
18
- });
19
- var __importStar = (this && this.__importStar) || (function () {
20
- var ownKeys = function(o) {
21
- ownKeys = Object.getOwnPropertyNames || function (o) {
22
- var ar = [];
23
- for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
24
- return ar;
25
- };
26
- return ownKeys(o);
27
- };
28
- return function (mod) {
29
- if (mod && mod.__esModule) return mod;
30
- var result = {};
31
- if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
32
- __setModuleDefault(result, mod);
33
- return result;
34
- };
35
- })();
36
3
  Object.defineProperty(exports, "__esModule", { value: true });
37
4
  exports.CredalClient = void 0;
38
5
  const Client_js_1 = require("./api/resources/copilots/client/Client.js");
@@ -40,38 +7,30 @@ const Client_js_2 = require("./api/resources/documentCatalog/client/Client.js");
40
7
  const Client_js_3 = require("./api/resources/documentCollections/client/Client.js");
41
8
  const Client_js_4 = require("./api/resources/search/client/Client.js");
42
9
  const Client_js_5 = require("./api/resources/users/client/Client.js");
43
- const headers_js_1 = require("./core/headers.js");
44
- const core = __importStar(require("./core/index.js"));
10
+ const BaseClient_js_1 = require("./BaseClient.js");
45
11
  class CredalClient {
46
- constructor(_options = {}) {
47
- this._options = Object.assign(Object.assign({}, _options), { logging: core.logging.createLogger(_options === null || _options === void 0 ? void 0 : _options.logging), headers: (0, headers_js_1.mergeHeaders)({
48
- "X-Fern-Language": "JavaScript",
49
- "X-Fern-SDK-Name": "@credal/sdk",
50
- "X-Fern-SDK-Version": "0.1.11",
51
- "User-Agent": "@credal/sdk/0.1.11",
52
- "X-Fern-Runtime": core.RUNTIME.type,
53
- "X-Fern-Runtime-Version": core.RUNTIME.version,
54
- }, _options === null || _options === void 0 ? void 0 : _options.headers) });
12
+ constructor(options = {}) {
13
+ this._options = (0, BaseClient_js_1.normalizeClientOptionsWithAuth)(options);
55
14
  }
56
15
  get copilots() {
57
16
  var _a;
58
- return ((_a = this._copilots) !== null && _a !== void 0 ? _a : (this._copilots = new Client_js_1.Copilots(this._options)));
17
+ return ((_a = this._copilots) !== null && _a !== void 0 ? _a : (this._copilots = new Client_js_1.CopilotsClient(this._options)));
59
18
  }
60
19
  get documentCatalog() {
61
20
  var _a;
62
- return ((_a = this._documentCatalog) !== null && _a !== void 0 ? _a : (this._documentCatalog = new Client_js_2.DocumentCatalog(this._options)));
21
+ return ((_a = this._documentCatalog) !== null && _a !== void 0 ? _a : (this._documentCatalog = new Client_js_2.DocumentCatalogClient(this._options)));
63
22
  }
64
23
  get documentCollections() {
65
24
  var _a;
66
- return ((_a = this._documentCollections) !== null && _a !== void 0 ? _a : (this._documentCollections = new Client_js_3.DocumentCollections(this._options)));
25
+ return ((_a = this._documentCollections) !== null && _a !== void 0 ? _a : (this._documentCollections = new Client_js_3.DocumentCollectionsClient(this._options)));
67
26
  }
68
27
  get search() {
69
28
  var _a;
70
- return ((_a = this._search) !== null && _a !== void 0 ? _a : (this._search = new Client_js_4.Search(this._options)));
29
+ return ((_a = this._search) !== null && _a !== void 0 ? _a : (this._search = new Client_js_4.SearchClient(this._options)));
71
30
  }
72
31
  get users() {
73
32
  var _a;
74
- return ((_a = this._users) !== null && _a !== void 0 ? _a : (this._users = new Client_js_5.Users(this._options)));
33
+ return ((_a = this._users) !== null && _a !== void 0 ? _a : (this._users = new Client_js_5.UsersClient(this._options)));
75
34
  }
76
35
  }
77
36
  exports.CredalClient = CredalClient;
@@ -1,20 +1,21 @@
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
- export declare namespace Copilots {
5
+ export declare namespace CopilotsClient {
5
6
  interface Options extends BaseClientOptions {
6
7
  }
7
8
  interface RequestOptions extends BaseRequestOptions {
8
9
  }
9
10
  }
10
- export declare class Copilots {
11
- protected readonly _options: Copilots.Options;
12
- constructor(_options?: Copilots.Options);
11
+ export declare class CopilotsClient {
12
+ protected readonly _options: NormalizedClientOptionsWithAuth<CopilotsClient.Options>;
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
15
16
  *
16
17
  * @param {Credal.CreateCopilotRequest} request
17
- * @param {Copilots.RequestOptions} requestOptions - Request-specific configuration.
18
+ * @param {CopilotsClient.RequestOptions} requestOptions - Request-specific configuration.
18
19
  *
19
20
  * @example
20
21
  * await client.copilots.createCopilot({
@@ -26,13 +27,13 @@ export declare class Copilots {
26
27
  * }]
27
28
  * })
28
29
  */
29
- createCopilot(request: Credal.CreateCopilotRequest, requestOptions?: Copilots.RequestOptions): core.HttpResponsePromise<Credal.CreateCopilotResponse>;
30
+ createCopilot(request: Credal.CreateCopilotRequest, requestOptions?: CopilotsClient.RequestOptions): core.HttpResponsePromise<Credal.CreateCopilotResponse>;
30
31
  private __createCopilot;
31
32
  /**
32
33
  * OPTIONAL. Create a new conversation with the Agent. The conversation ID can be used in the `sendMessage` endpoint. The `sendMessage` endpoint automatically creates new conversations upon first request, but calling this endpoint can simplify certain use cases where it is helpful for the application to have the conversation ID before the first message is sent.
33
34
  *
34
35
  * @param {Credal.CreateConversationRequest} request
35
- * @param {Copilots.RequestOptions} requestOptions - Request-specific configuration.
36
+ * @param {CopilotsClient.RequestOptions} requestOptions - Request-specific configuration.
36
37
  *
37
38
  * @example
38
39
  * await client.copilots.createConversation({
@@ -40,11 +41,11 @@ export declare class Copilots {
40
41
  * userEmail: "ravin@credal.ai"
41
42
  * })
42
43
  */
43
- createConversation(request: Credal.CreateConversationRequest, requestOptions?: Copilots.RequestOptions): core.HttpResponsePromise<Credal.CreateConversationResponse>;
44
+ createConversation(request: Credal.CreateConversationRequest, requestOptions?: CopilotsClient.RequestOptions): core.HttpResponsePromise<Credal.CreateConversationResponse>;
44
45
  private __createConversation;
45
46
  /**
46
47
  * @param {Credal.ProvideMessageFeedbackRequest} request
47
- * @param {Copilots.RequestOptions} requestOptions - Request-specific configuration.
48
+ * @param {CopilotsClient.RequestOptions} requestOptions - Request-specific configuration.
48
49
  *
49
50
  * @example
50
51
  * await client.copilots.provideMessageFeedback({
@@ -58,11 +59,11 @@ export declare class Copilots {
58
59
  * }
59
60
  * })
60
61
  */
61
- provideMessageFeedback(request: Credal.ProvideMessageFeedbackRequest, requestOptions?: Copilots.RequestOptions): core.HttpResponsePromise<void>;
62
+ provideMessageFeedback(request: Credal.ProvideMessageFeedbackRequest, requestOptions?: CopilotsClient.RequestOptions): core.HttpResponsePromise<void>;
62
63
  private __provideMessageFeedback;
63
64
  /**
64
65
  * @param {Credal.SendMessageRequest} request
65
- * @param {Copilots.RequestOptions} requestOptions - Request-specific configuration.
66
+ * @param {CopilotsClient.RequestOptions} requestOptions - Request-specific configuration.
66
67
  *
67
68
  * @example
68
69
  * await client.copilots.sendMessage({
@@ -78,18 +79,18 @@ export declare class Copilots {
78
79
  * }]
79
80
  * })
80
81
  */
81
- sendMessage(request: Credal.SendMessageRequest, requestOptions?: Copilots.RequestOptions): core.HttpResponsePromise<Credal.SendAgentMessageResponse>;
82
+ sendMessage(request: Credal.SendMessageRequest, requestOptions?: CopilotsClient.RequestOptions): core.HttpResponsePromise<Credal.SendAgentMessageResponse>;
82
83
  private __sendMessage;
83
84
  /**
84
85
  * This endpoint allows you to send a message to a specific agent and get the response back as a streamed set of Server-Sent Events.
85
86
  */
86
- streamMessage(request: Credal.StreamMessageRequest, requestOptions?: Copilots.RequestOptions): core.HttpResponsePromise<core.Stream<Credal.StreamingChunk>>;
87
+ streamMessage(request: Credal.StreamMessageRequest, requestOptions?: CopilotsClient.RequestOptions): core.HttpResponsePromise<core.Stream<Credal.StreamingChunk>>;
87
88
  private __streamMessage;
88
89
  /**
89
90
  * Link a collection with a agent. The API Key used must be added to both the collection and the agent beforehand.
90
91
  *
91
92
  * @param {Credal.AddCollectionToCopilotRequest} request
92
- * @param {Copilots.RequestOptions} requestOptions - Request-specific configuration.
93
+ * @param {CopilotsClient.RequestOptions} requestOptions - Request-specific configuration.
93
94
  *
94
95
  * @example
95
96
  * await client.copilots.addCollectionToCopilot({
@@ -97,13 +98,13 @@ export declare class Copilots {
97
98
  * collectionId: "def1055f-83c5-43d6-b558-f7a38e7b299e"
98
99
  * })
99
100
  */
100
- addCollectionToCopilot(request: Credal.AddCollectionToCopilotRequest, requestOptions?: Copilots.RequestOptions): core.HttpResponsePromise<void>;
101
+ addCollectionToCopilot(request: Credal.AddCollectionToCopilotRequest, requestOptions?: CopilotsClient.RequestOptions): core.HttpResponsePromise<void>;
101
102
  private __addCollectionToCopilot;
102
103
  /**
103
104
  * Unlink a collection with a agent. The API Key used must be added to both the collection and the agent beforehand.
104
105
  *
105
106
  * @param {Credal.RemoveCollectionFromCopilotRequest} request
106
- * @param {Copilots.RequestOptions} requestOptions - Request-specific configuration.
107
+ * @param {CopilotsClient.RequestOptions} requestOptions - Request-specific configuration.
107
108
  *
108
109
  * @example
109
110
  * await client.copilots.removeCollectionFromCopilot({
@@ -111,13 +112,13 @@ export declare class Copilots {
111
112
  * collectionId: "def1055f-83c5-43d6-b558-f7a38e7b299e"
112
113
  * })
113
114
  */
114
- removeCollectionFromCopilot(request: Credal.RemoveCollectionFromCopilotRequest, requestOptions?: Copilots.RequestOptions): core.HttpResponsePromise<void>;
115
+ removeCollectionFromCopilot(request: Credal.RemoveCollectionFromCopilotRequest, requestOptions?: CopilotsClient.RequestOptions): core.HttpResponsePromise<void>;
115
116
  private __removeCollectionFromCopilot;
116
117
  /**
117
118
  * Update the configuration for a agent
118
119
  *
119
120
  * @param {Credal.UpdateConfigurationRequest} request
120
- * @param {Copilots.RequestOptions} requestOptions - Request-specific configuration.
121
+ * @param {CopilotsClient.RequestOptions} requestOptions - Request-specific configuration.
121
122
  *
122
123
  * @example
123
124
  * await client.copilots.updateConfiguration({
@@ -133,18 +134,17 @@ export declare class Copilots {
133
134
  * }
134
135
  * })
135
136
  */
136
- updateConfiguration(request: Credal.UpdateConfigurationRequest, requestOptions?: Copilots.RequestOptions): core.HttpResponsePromise<void>;
137
+ updateConfiguration(request: Credal.UpdateConfigurationRequest, requestOptions?: CopilotsClient.RequestOptions): core.HttpResponsePromise<void>;
137
138
  private __updateConfiguration;
138
139
  /**
139
140
  * @param {Credal.DeleteCopilotRequest} request
140
- * @param {Copilots.RequestOptions} requestOptions - Request-specific configuration.
141
+ * @param {CopilotsClient.RequestOptions} requestOptions - Request-specific configuration.
141
142
  *
142
143
  * @example
143
144
  * await client.copilots.deleteCopilot({
144
145
  * id: "ac20e6ba-0bae-11ef-b25a-efca73df4c3a"
145
146
  * })
146
147
  */
147
- deleteCopilot(request: Credal.DeleteCopilotRequest, requestOptions?: Copilots.RequestOptions): core.HttpResponsePromise<Credal.DeleteCopilotResponse>;
148
+ deleteCopilot(request: Credal.DeleteCopilotRequest, requestOptions?: CopilotsClient.RequestOptions): core.HttpResponsePromise<Credal.DeleteCopilotResponse>;
148
149
  private __deleteCopilot;
149
- protected _getAuthorizationHeader(): Promise<string>;
150
150
  }
@@ -43,20 +43,21 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
43
43
  });
44
44
  };
45
45
  Object.defineProperty(exports, "__esModule", { value: true });
46
- exports.Copilots = void 0;
46
+ exports.CopilotsClient = void 0;
47
+ const BaseClient_js_1 = require("../../../../BaseClient.js");
47
48
  const headers_js_1 = require("../../../../core/headers.js");
48
49
  const core = __importStar(require("../../../../core/index.js"));
49
50
  const environments = __importStar(require("../../../../environments.js"));
50
51
  const errors = __importStar(require("../../../../errors/index.js"));
51
- class Copilots {
52
- constructor(_options = {}) {
53
- this._options = _options;
52
+ class CopilotsClient {
53
+ constructor(options = {}) {
54
+ this._options = (0, BaseClient_js_1.normalizeClientOptionsWithAuth)(options);
54
55
  }
55
56
  /**
56
57
  * Create a new agent. The API key used will be added to the agent for future Requests
57
58
  *
58
59
  * @param {Credal.CreateCopilotRequest} request
59
- * @param {Copilots.RequestOptions} requestOptions - Request-specific configuration.
60
+ * @param {CopilotsClient.RequestOptions} requestOptions - Request-specific configuration.
60
61
  *
61
62
  * @example
62
63
  * await client.copilots.createCopilot({
@@ -74,7 +75,8 @@ class Copilots {
74
75
  __createCopilot(request, requestOptions) {
75
76
  return __awaiter(this, void 0, void 0, function* () {
76
77
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
77
- 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);
78
80
  const _response = yield ((_b = this._options.fetcher) !== null && _b !== void 0 ? _b : core.fetcher)({
79
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"),
80
82
  method: "POST",
@@ -120,7 +122,7 @@ class Copilots {
120
122
  * OPTIONAL. Create a new conversation with the Agent. The conversation ID can be used in the `sendMessage` endpoint. The `sendMessage` endpoint automatically creates new conversations upon first request, but calling this endpoint can simplify certain use cases where it is helpful for the application to have the conversation ID before the first message is sent.
121
123
  *
122
124
  * @param {Credal.CreateConversationRequest} request
123
- * @param {Copilots.RequestOptions} requestOptions - Request-specific configuration.
125
+ * @param {CopilotsClient.RequestOptions} requestOptions - Request-specific configuration.
124
126
  *
125
127
  * @example
126
128
  * await client.copilots.createConversation({
@@ -134,7 +136,8 @@ class Copilots {
134
136
  __createConversation(request, requestOptions) {
135
137
  return __awaiter(this, void 0, void 0, function* () {
136
138
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
137
- 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);
138
141
  const _response = yield ((_b = this._options.fetcher) !== null && _b !== void 0 ? _b : core.fetcher)({
139
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"),
140
143
  method: "POST",
@@ -178,7 +181,7 @@ class Copilots {
178
181
  }
179
182
  /**
180
183
  * @param {Credal.ProvideMessageFeedbackRequest} request
181
- * @param {Copilots.RequestOptions} requestOptions - Request-specific configuration.
184
+ * @param {CopilotsClient.RequestOptions} requestOptions - Request-specific configuration.
182
185
  *
183
186
  * @example
184
187
  * await client.copilots.provideMessageFeedback({
@@ -198,7 +201,8 @@ class Copilots {
198
201
  __provideMessageFeedback(request, requestOptions) {
199
202
  return __awaiter(this, void 0, void 0, function* () {
200
203
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
201
- 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);
202
206
  const _response = yield ((_b = this._options.fetcher) !== null && _b !== void 0 ? _b : core.fetcher)({
203
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"),
204
208
  method: "POST",
@@ -242,7 +246,7 @@ class Copilots {
242
246
  }
243
247
  /**
244
248
  * @param {Credal.SendMessageRequest} request
245
- * @param {Copilots.RequestOptions} requestOptions - Request-specific configuration.
249
+ * @param {CopilotsClient.RequestOptions} requestOptions - Request-specific configuration.
246
250
  *
247
251
  * @example
248
252
  * await client.copilots.sendMessage({
@@ -264,7 +268,8 @@ class Copilots {
264
268
  __sendMessage(request, requestOptions) {
265
269
  return __awaiter(this, void 0, void 0, function* () {
266
270
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
267
- 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);
268
273
  const _response = yield ((_b = this._options.fetcher) !== null && _b !== void 0 ? _b : core.fetcher)({
269
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"),
270
275
  method: "POST",
@@ -315,7 +320,8 @@ class Copilots {
315
320
  __streamMessage(request, requestOptions) {
316
321
  return __awaiter(this, void 0, void 0, function* () {
317
322
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
318
- 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);
319
325
  const _response = yield ((_b = this._options.fetcher) !== null && _b !== void 0 ? _b : core.fetcher)({
320
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"),
321
327
  method: "POST",
@@ -373,7 +379,7 @@ class Copilots {
373
379
  * Link a collection with a agent. The API Key used must be added to both the collection and the agent beforehand.
374
380
  *
375
381
  * @param {Credal.AddCollectionToCopilotRequest} request
376
- * @param {Copilots.RequestOptions} requestOptions - Request-specific configuration.
382
+ * @param {CopilotsClient.RequestOptions} requestOptions - Request-specific configuration.
377
383
  *
378
384
  * @example
379
385
  * await client.copilots.addCollectionToCopilot({
@@ -387,7 +393,8 @@ class Copilots {
387
393
  __addCollectionToCopilot(request, requestOptions) {
388
394
  return __awaiter(this, void 0, void 0, function* () {
389
395
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
390
- 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);
391
398
  const _response = yield ((_b = this._options.fetcher) !== null && _b !== void 0 ? _b : core.fetcher)({
392
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"),
393
400
  method: "POST",
@@ -433,7 +440,7 @@ class Copilots {
433
440
  * Unlink a collection with a agent. The API Key used must be added to both the collection and the agent beforehand.
434
441
  *
435
442
  * @param {Credal.RemoveCollectionFromCopilotRequest} request
436
- * @param {Copilots.RequestOptions} requestOptions - Request-specific configuration.
443
+ * @param {CopilotsClient.RequestOptions} requestOptions - Request-specific configuration.
437
444
  *
438
445
  * @example
439
446
  * await client.copilots.removeCollectionFromCopilot({
@@ -447,7 +454,8 @@ class Copilots {
447
454
  __removeCollectionFromCopilot(request, requestOptions) {
448
455
  return __awaiter(this, void 0, void 0, function* () {
449
456
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
450
- 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);
451
459
  const _response = yield ((_b = this._options.fetcher) !== null && _b !== void 0 ? _b : core.fetcher)({
452
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"),
453
461
  method: "POST",
@@ -493,7 +501,7 @@ class Copilots {
493
501
  * Update the configuration for a agent
494
502
  *
495
503
  * @param {Credal.UpdateConfigurationRequest} request
496
- * @param {Copilots.RequestOptions} requestOptions - Request-specific configuration.
504
+ * @param {CopilotsClient.RequestOptions} requestOptions - Request-specific configuration.
497
505
  *
498
506
  * @example
499
507
  * await client.copilots.updateConfiguration({
@@ -515,7 +523,8 @@ class Copilots {
515
523
  __updateConfiguration(request, requestOptions) {
516
524
  return __awaiter(this, void 0, void 0, function* () {
517
525
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
518
- 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);
519
528
  const _response = yield ((_b = this._options.fetcher) !== null && _b !== void 0 ? _b : core.fetcher)({
520
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"),
521
530
  method: "POST",
@@ -559,7 +568,7 @@ class Copilots {
559
568
  }
560
569
  /**
561
570
  * @param {Credal.DeleteCopilotRequest} request
562
- * @param {Copilots.RequestOptions} requestOptions - Request-specific configuration.
571
+ * @param {CopilotsClient.RequestOptions} requestOptions - Request-specific configuration.
563
572
  *
564
573
  * @example
565
574
  * await client.copilots.deleteCopilot({
@@ -572,7 +581,8 @@ class Copilots {
572
581
  __deleteCopilot(request, requestOptions) {
573
582
  return __awaiter(this, void 0, void 0, function* () {
574
583
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
575
- 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);
576
586
  const _response = yield ((_b = this._options.fetcher) !== null && _b !== void 0 ? _b : core.fetcher)({
577
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"),
578
588
  method: "DELETE",
@@ -614,17 +624,5 @@ class Copilots {
614
624
  }
615
625
  });
616
626
  }
617
- _getAuthorizationHeader() {
618
- return __awaiter(this, void 0, void 0, function* () {
619
- var _a;
620
- 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;
621
- if (bearer == null) {
622
- throw new errors.CredalError({
623
- message: "Please specify a bearer by either passing it in to the constructor or initializing a CREDAL_API_KEY environment variable",
624
- });
625
- }
626
- return `Bearer ${bearer}`;
627
- });
628
- }
629
627
  }
630
- exports.Copilots = Copilots;
628
+ exports.CopilotsClient = CopilotsClient;
@@ -1,18 +1,19 @@
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
- export declare namespace DocumentCatalog {
5
+ export declare namespace DocumentCatalogClient {
5
6
  interface Options extends BaseClientOptions {
6
7
  }
7
8
  interface RequestOptions extends BaseRequestOptions {
8
9
  }
9
10
  }
10
- export declare class DocumentCatalog {
11
- protected readonly _options: DocumentCatalog.Options;
12
- constructor(_options?: DocumentCatalog.Options);
11
+ export declare class DocumentCatalogClient {
12
+ protected readonly _options: NormalizedClientOptionsWithAuth<DocumentCatalogClient.Options>;
13
+ constructor(options?: DocumentCatalogClient.Options);
13
14
  /**
14
15
  * @param {Credal.UploadDocumentContentsRequest} request
15
- * @param {DocumentCatalog.RequestOptions} requestOptions - Request-specific configuration.
16
+ * @param {DocumentCatalogClient.RequestOptions} requestOptions - Request-specific configuration.
16
17
  *
17
18
  * @example
18
19
  * await client.documentCatalog.uploadDocumentContents({
@@ -23,21 +24,21 @@ export declare class DocumentCatalog {
23
24
  * uploadAsUserEmail: "jack@credal.ai"
24
25
  * })
25
26
  */
26
- uploadDocumentContents(request: Credal.UploadDocumentContentsRequest, requestOptions?: DocumentCatalog.RequestOptions): core.HttpResponsePromise<Credal.UploadDocumentResponse>;
27
+ uploadDocumentContents(request: Credal.UploadDocumentContentsRequest, requestOptions?: DocumentCatalogClient.RequestOptions): core.HttpResponsePromise<Credal.UploadDocumentResponse>;
27
28
  private __uploadDocumentContents;
28
29
  /**
29
30
  * Upload a file (PDF, Word, Excel, CSV, PowerPoint) to Credal. Unlike uploadDocumentContents which requires pre-parsed text, this endpoint accepts actual file uploads and automatically parses them using Credal's parsing service.
30
31
  *
31
32
  * @param {Credal.UploadFileRequest} request
32
- * @param {DocumentCatalog.RequestOptions} requestOptions - Request-specific configuration.
33
+ * @param {DocumentCatalogClient.RequestOptions} requestOptions - Request-specific configuration.
33
34
  */
34
- uploadFile(request: Credal.UploadFileRequest, requestOptions?: DocumentCatalog.RequestOptions): core.HttpResponsePromise<Credal.UploadDocumentResponse>;
35
+ uploadFile(request: Credal.UploadFileRequest, requestOptions?: DocumentCatalogClient.RequestOptions): core.HttpResponsePromise<Credal.UploadDocumentResponse>;
35
36
  private __uploadFile;
36
37
  /**
37
38
  * Sync a document from a source URL. Does not support recursive web search. Reach out to a Credal representative for access.
38
39
  *
39
40
  * @param {Credal.SyncSourceByUrlRequest} request
40
- * @param {DocumentCatalog.RequestOptions} requestOptions - Request-specific configuration.
41
+ * @param {DocumentCatalogClient.RequestOptions} requestOptions - Request-specific configuration.
41
42
  *
42
43
  * @example
43
44
  * await client.documentCatalog.syncSourceByUrl({
@@ -45,13 +46,13 @@ export declare class DocumentCatalog {
45
46
  * uploadAsUserEmail: "ria@credal.ai"
46
47
  * })
47
48
  */
48
- syncSourceByUrl(request: Credal.SyncSourceByUrlRequest, requestOptions?: DocumentCatalog.RequestOptions): core.HttpResponsePromise<Credal.SyncSourceByUrlResponse>;
49
+ syncSourceByUrl(request: Credal.SyncSourceByUrlRequest, requestOptions?: DocumentCatalogClient.RequestOptions): core.HttpResponsePromise<Credal.SyncSourceByUrlResponse>;
49
50
  private __syncSourceByUrl;
50
51
  /**
51
52
  * Bulk patch metadata for documents, synced natively by Credal or manual API uploads
52
53
  *
53
54
  * @param {Credal.DocumentMetadataPatchRequest} request
54
- * @param {DocumentCatalog.RequestOptions} requestOptions - Request-specific configuration.
55
+ * @param {DocumentCatalogClient.RequestOptions} requestOptions - Request-specific configuration.
55
56
  *
56
57
  * @example
57
58
  * await client.documentCatalog.metadata({
@@ -79,7 +80,6 @@ export declare class DocumentCatalog {
79
80
  * uploadAsUserEmail: "ben@credal.ai"
80
81
  * })
81
82
  */
82
- metadata(request: Credal.DocumentMetadataPatchRequest, requestOptions?: DocumentCatalog.RequestOptions): core.HttpResponsePromise<void>;
83
+ metadata(request: Credal.DocumentMetadataPatchRequest, requestOptions?: DocumentCatalogClient.RequestOptions): core.HttpResponsePromise<void>;
83
84
  private __metadata;
84
- protected _getAuthorizationHeader(): Promise<string>;
85
85
  }