@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
@@ -43,18 +43,19 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
43
43
  });
44
44
  };
45
45
  Object.defineProperty(exports, "__esModule", { value: true });
46
- exports.DocumentCatalog = void 0;
46
+ exports.DocumentCatalogClient = 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 DocumentCatalog {
52
- constructor(_options = {}) {
53
- this._options = _options;
52
+ class DocumentCatalogClient {
53
+ constructor(options = {}) {
54
+ this._options = (0, BaseClient_js_1.normalizeClientOptionsWithAuth)(options);
54
55
  }
55
56
  /**
56
57
  * @param {Credal.UploadDocumentContentsRequest} request
57
- * @param {DocumentCatalog.RequestOptions} requestOptions - Request-specific configuration.
58
+ * @param {DocumentCatalogClient.RequestOptions} requestOptions - Request-specific configuration.
58
59
  *
59
60
  * @example
60
61
  * await client.documentCatalog.uploadDocumentContents({
@@ -71,7 +72,8 @@ class DocumentCatalog {
71
72
  __uploadDocumentContents(request, requestOptions) {
72
73
  return __awaiter(this, void 0, void 0, function* () {
73
74
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
74
- 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);
75
77
  const _response = yield ((_b = this._options.fetcher) !== null && _b !== void 0 ? _b : core.fetcher)({
76
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"),
77
79
  method: "POST",
@@ -117,7 +119,7 @@ class DocumentCatalog {
117
119
  * 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.
118
120
  *
119
121
  * @param {Credal.UploadFileRequest} request
120
- * @param {DocumentCatalog.RequestOptions} requestOptions - Request-specific configuration.
122
+ * @param {DocumentCatalogClient.RequestOptions} requestOptions - Request-specific configuration.
121
123
  */
122
124
  uploadFile(request, requestOptions) {
123
125
  return core.HttpResponsePromise.fromPromise(this.__uploadFile(request, requestOptions));
@@ -157,7 +159,8 @@ class DocumentCatalog {
157
159
  _request.append("awaitVectorStoreSync", request.awaitVectorStoreSync);
158
160
  }
159
161
  const _maybeEncodedRequest = yield _request.getRequest();
160
- 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);
161
164
  const _response = yield ((_b = this._options.fetcher) !== null && _b !== void 0 ? _b : core.fetcher)({
162
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"),
163
166
  method: "POST",
@@ -203,7 +206,7 @@ class DocumentCatalog {
203
206
  * Sync a document from a source URL. Does not support recursive web search. Reach out to a Credal representative for access.
204
207
  *
205
208
  * @param {Credal.SyncSourceByUrlRequest} request
206
- * @param {DocumentCatalog.RequestOptions} requestOptions - Request-specific configuration.
209
+ * @param {DocumentCatalogClient.RequestOptions} requestOptions - Request-specific configuration.
207
210
  *
208
211
  * @example
209
212
  * await client.documentCatalog.syncSourceByUrl({
@@ -217,7 +220,8 @@ class DocumentCatalog {
217
220
  __syncSourceByUrl(request, requestOptions) {
218
221
  return __awaiter(this, void 0, void 0, function* () {
219
222
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
220
- 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);
221
225
  const _response = yield ((_b = this._options.fetcher) !== null && _b !== void 0 ? _b : core.fetcher)({
222
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"),
223
227
  method: "POST",
@@ -263,7 +267,7 @@ class DocumentCatalog {
263
267
  * Bulk patch metadata for documents, synced natively by Credal or manual API uploads
264
268
  *
265
269
  * @param {Credal.DocumentMetadataPatchRequest} request
266
- * @param {DocumentCatalog.RequestOptions} requestOptions - Request-specific configuration.
270
+ * @param {DocumentCatalogClient.RequestOptions} requestOptions - Request-specific configuration.
267
271
  *
268
272
  * @example
269
273
  * await client.documentCatalog.metadata({
@@ -297,7 +301,8 @@ class DocumentCatalog {
297
301
  __metadata(request, requestOptions) {
298
302
  return __awaiter(this, void 0, void 0, function* () {
299
303
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
300
- 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);
301
306
  const _response = yield ((_b = this._options.fetcher) !== null && _b !== void 0 ? _b : core.fetcher)({
302
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"),
303
308
  method: "PATCH",
@@ -339,17 +344,5 @@ class DocumentCatalog {
339
344
  }
340
345
  });
341
346
  }
342
- _getAuthorizationHeader() {
343
- return __awaiter(this, void 0, void 0, function* () {
344
- var _a;
345
- 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;
346
- if (bearer == null) {
347
- throw new errors.CredalError({
348
- message: "Please specify a bearer by either passing it in to the constructor or initializing a CREDAL_API_KEY environment variable",
349
- });
350
- }
351
- return `Bearer ${bearer}`;
352
- });
353
- }
354
347
  }
355
- exports.DocumentCatalog = DocumentCatalog;
348
+ exports.DocumentCatalogClient = DocumentCatalogClient;
@@ -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 DocumentCollections {
5
+ export declare namespace DocumentCollectionsClient {
5
6
  interface Options extends BaseClientOptions {
6
7
  }
7
8
  interface RequestOptions extends BaseRequestOptions {
8
9
  }
9
10
  }
10
- export declare class DocumentCollections {
11
- protected readonly _options: DocumentCollections.Options;
12
- constructor(_options?: DocumentCollections.Options);
11
+ export declare class DocumentCollectionsClient {
12
+ protected readonly _options: NormalizedClientOptionsWithAuth<DocumentCollectionsClient.Options>;
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.
15
16
  *
16
17
  * @param {Credal.AddDocumentsToCollectionRequest} request
17
- * @param {DocumentCollections.RequestOptions} requestOptions - Request-specific configuration.
18
+ * @param {DocumentCollectionsClient.RequestOptions} requestOptions - Request-specific configuration.
18
19
  *
19
20
  * @example
20
21
  * await client.documentCollections.addDocumentsToCollection({
@@ -30,13 +31,13 @@ export declare class DocumentCollections {
30
31
  * }]
31
32
  * })
32
33
  */
33
- addDocumentsToCollection(request: Credal.AddDocumentsToCollectionRequest, requestOptions?: DocumentCollections.RequestOptions): core.HttpResponsePromise<void>;
34
+ addDocumentsToCollection(request: Credal.AddDocumentsToCollectionRequest, requestOptions?: DocumentCollectionsClient.RequestOptions): core.HttpResponsePromise<void>;
34
35
  private __addDocumentsToCollection;
35
36
  /**
36
37
  * Remove documents from a collection
37
38
  *
38
39
  * @param {Credal.RemoveDocumentsFromCollectionRequest} request
39
- * @param {DocumentCollections.RequestOptions} requestOptions - Request-specific configuration.
40
+ * @param {DocumentCollectionsClient.RequestOptions} requestOptions - Request-specific configuration.
40
41
  *
41
42
  * @example
42
43
  * await client.documentCollections.removeDocumentsFromCollection({
@@ -52,26 +53,26 @@ export declare class DocumentCollections {
52
53
  * }]
53
54
  * })
54
55
  */
55
- removeDocumentsFromCollection(request: Credal.RemoveDocumentsFromCollectionRequest, requestOptions?: DocumentCollections.RequestOptions): core.HttpResponsePromise<void>;
56
+ removeDocumentsFromCollection(request: Credal.RemoveDocumentsFromCollectionRequest, requestOptions?: DocumentCollectionsClient.RequestOptions): core.HttpResponsePromise<void>;
56
57
  private __removeDocumentsFromCollection;
57
58
  /**
58
59
  * List documents in a collection
59
60
  *
60
61
  * @param {Credal.ListDocumentsInCollectionRequest} request
61
- * @param {DocumentCollections.RequestOptions} requestOptions - Request-specific configuration.
62
+ * @param {DocumentCollectionsClient.RequestOptions} requestOptions - Request-specific configuration.
62
63
  *
63
64
  * @example
64
65
  * await client.documentCollections.listDocumentsInCollection({
65
66
  * collectionId: "82e4b12a-6990-45d4-8ebd-85c00e030c24"
66
67
  * })
67
68
  */
68
- listDocumentsInCollection(request: Credal.ListDocumentsInCollectionRequest, requestOptions?: DocumentCollections.RequestOptions): core.HttpResponsePromise<Credal.ListDocumentsInCollectionResponse>;
69
+ listDocumentsInCollection(request: Credal.ListDocumentsInCollectionRequest, requestOptions?: DocumentCollectionsClient.RequestOptions): core.HttpResponsePromise<Credal.ListDocumentsInCollectionResponse>;
69
70
  private __listDocumentsInCollection;
70
71
  /**
71
72
  * Create a new collection. The API key used will be added to the collection for future Requests
72
73
  *
73
74
  * @param {Credal.CreateCollectionRequest} request
74
- * @param {DocumentCollections.RequestOptions} requestOptions - Request-specific configuration.
75
+ * @param {DocumentCollectionsClient.RequestOptions} requestOptions - Request-specific configuration.
75
76
  *
76
77
  * @example
77
78
  * await client.documentCollections.createCollection({
@@ -83,26 +84,26 @@ export declare class DocumentCollections {
83
84
  * }]
84
85
  * })
85
86
  */
86
- createCollection(request: Credal.CreateCollectionRequest, requestOptions?: DocumentCollections.RequestOptions): core.HttpResponsePromise<Credal.CreateCollectionResponse>;
87
+ createCollection(request: Credal.CreateCollectionRequest, requestOptions?: DocumentCollectionsClient.RequestOptions): core.HttpResponsePromise<Credal.CreateCollectionResponse>;
87
88
  private __createCollection;
88
89
  /**
89
90
  * Delete the collection.
90
91
  *
91
92
  * @param {Credal.DeleteCollectionRequest} request
92
- * @param {DocumentCollections.RequestOptions} requestOptions - Request-specific configuration.
93
+ * @param {DocumentCollectionsClient.RequestOptions} requestOptions - Request-specific configuration.
93
94
  *
94
95
  * @example
95
96
  * await client.documentCollections.deleteCollection({
96
97
  * collectionId: "ac20e6ba-0bae-11ef-b25a-efca73df4c3a"
97
98
  * })
98
99
  */
99
- deleteCollection(request: Credal.DeleteCollectionRequest, requestOptions?: DocumentCollections.RequestOptions): core.HttpResponsePromise<Credal.DeleteCollectionResponse>;
100
+ deleteCollection(request: Credal.DeleteCollectionRequest, requestOptions?: DocumentCollectionsClient.RequestOptions): core.HttpResponsePromise<Credal.DeleteCollectionResponse>;
100
101
  private __deleteCollection;
101
102
  /**
102
103
  * Credal lets you easily sync your MongoDB data for use in Collections and Agents. Create a new sync from a MongoDB collection to a Credal collection.
103
104
  *
104
105
  * @param {Credal.CreateMongoCollectionSyncRequest} request
105
- * @param {DocumentCollections.RequestOptions} requestOptions - Request-specific configuration.
106
+ * @param {DocumentCollectionsClient.RequestOptions} requestOptions - Request-specific configuration.
106
107
  *
107
108
  * @example
108
109
  * await client.documentCollections.createMongoCollectionSync({
@@ -125,13 +126,13 @@ export declare class DocumentCollections {
125
126
  * }
126
127
  * })
127
128
  */
128
- createMongoCollectionSync(request: Credal.CreateMongoCollectionSyncRequest, requestOptions?: DocumentCollections.RequestOptions): core.HttpResponsePromise<Credal.MongoCollectionSyncResponse>;
129
+ createMongoCollectionSync(request: Credal.CreateMongoCollectionSyncRequest, requestOptions?: DocumentCollectionsClient.RequestOptions): core.HttpResponsePromise<Credal.MongoCollectionSyncResponse>;
129
130
  private __createMongoCollectionSync;
130
131
  /**
131
132
  * Credal lets you easily sync your MongoDB data for use in Collections and Agents. Update an existing sync from a MongoDB collection to a Credal collection via the `mongoCredentialId`, to disambiguate between multiple potential syncs to a given collection.
132
133
  *
133
134
  * @param {Credal.UpdateMongoCollectionSyncRequest} request
134
- * @param {DocumentCollections.RequestOptions} requestOptions - Request-specific configuration.
135
+ * @param {DocumentCollectionsClient.RequestOptions} requestOptions - Request-specific configuration.
135
136
  *
136
137
  * @example
137
138
  * await client.documentCollections.updateMongoCollectionSync({
@@ -154,7 +155,6 @@ export declare class DocumentCollections {
154
155
  * }
155
156
  * })
156
157
  */
157
- updateMongoCollectionSync(request: Credal.UpdateMongoCollectionSyncRequest, requestOptions?: DocumentCollections.RequestOptions): core.HttpResponsePromise<Credal.MongoCollectionSyncResponse>;
158
+ updateMongoCollectionSync(request: Credal.UpdateMongoCollectionSyncRequest, requestOptions?: DocumentCollectionsClient.RequestOptions): core.HttpResponsePromise<Credal.MongoCollectionSyncResponse>;
158
159
  private __updateMongoCollectionSync;
159
- protected _getAuthorizationHeader(): Promise<string>;
160
160
  }
@@ -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.DocumentCollections = void 0;
46
+ exports.DocumentCollectionsClient = 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 DocumentCollections {
52
- constructor(_options = {}) {
53
- this._options = _options;
52
+ class DocumentCollectionsClient {
53
+ constructor(options = {}) {
54
+ this._options = (0, BaseClient_js_1.normalizeClientOptionsWithAuth)(options);
54
55
  }
55
56
  /**
56
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.
57
58
  *
58
59
  * @param {Credal.AddDocumentsToCollectionRequest} request
59
- * @param {DocumentCollections.RequestOptions} requestOptions - Request-specific configuration.
60
+ * @param {DocumentCollectionsClient.RequestOptions} requestOptions - Request-specific configuration.
60
61
  *
61
62
  * @example
62
63
  * await client.documentCollections.addDocumentsToCollection({
@@ -78,7 +79,8 @@ class DocumentCollections {
78
79
  __addDocumentsToCollection(request, requestOptions) {
79
80
  return __awaiter(this, void 0, void 0, function* () {
80
81
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
81
- 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);
82
84
  const _response = yield ((_b = this._options.fetcher) !== null && _b !== void 0 ? _b : core.fetcher)({
83
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"),
84
86
  method: "POST",
@@ -124,7 +126,7 @@ class DocumentCollections {
124
126
  * Remove documents from a collection
125
127
  *
126
128
  * @param {Credal.RemoveDocumentsFromCollectionRequest} request
127
- * @param {DocumentCollections.RequestOptions} requestOptions - Request-specific configuration.
129
+ * @param {DocumentCollectionsClient.RequestOptions} requestOptions - Request-specific configuration.
128
130
  *
129
131
  * @example
130
132
  * await client.documentCollections.removeDocumentsFromCollection({
@@ -146,7 +148,8 @@ class DocumentCollections {
146
148
  __removeDocumentsFromCollection(request, requestOptions) {
147
149
  return __awaiter(this, void 0, void 0, function* () {
148
150
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
149
- 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);
150
153
  const _response = yield ((_b = this._options.fetcher) !== null && _b !== void 0 ? _b : core.fetcher)({
151
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"),
152
155
  method: "DELETE",
@@ -192,7 +195,7 @@ class DocumentCollections {
192
195
  * List documents in a collection
193
196
  *
194
197
  * @param {Credal.ListDocumentsInCollectionRequest} request
195
- * @param {DocumentCollections.RequestOptions} requestOptions - Request-specific configuration.
198
+ * @param {DocumentCollectionsClient.RequestOptions} requestOptions - Request-specific configuration.
196
199
  *
197
200
  * @example
198
201
  * await client.documentCollections.listDocumentsInCollection({
@@ -208,7 +211,8 @@ class DocumentCollections {
208
211
  const { collectionId } = request;
209
212
  const _queryParams = {};
210
213
  _queryParams.collectionId = collectionId;
211
- 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);
212
216
  const _response = yield ((_b = this._options.fetcher) !== null && _b !== void 0 ? _b : core.fetcher)({
213
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"),
214
218
  method: "GET",
@@ -254,7 +258,7 @@ class DocumentCollections {
254
258
  * Create a new collection. The API key used will be added to the collection for future Requests
255
259
  *
256
260
  * @param {Credal.CreateCollectionRequest} request
257
- * @param {DocumentCollections.RequestOptions} requestOptions - Request-specific configuration.
261
+ * @param {DocumentCollectionsClient.RequestOptions} requestOptions - Request-specific configuration.
258
262
  *
259
263
  * @example
260
264
  * await client.documentCollections.createCollection({
@@ -272,7 +276,8 @@ class DocumentCollections {
272
276
  __createCollection(request, requestOptions) {
273
277
  return __awaiter(this, void 0, void 0, function* () {
274
278
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
275
- 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);
276
281
  const _response = yield ((_b = this._options.fetcher) !== null && _b !== void 0 ? _b : core.fetcher)({
277
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"),
278
283
  method: "POST",
@@ -318,7 +323,7 @@ class DocumentCollections {
318
323
  * Delete the collection.
319
324
  *
320
325
  * @param {Credal.DeleteCollectionRequest} request
321
- * @param {DocumentCollections.RequestOptions} requestOptions - Request-specific configuration.
326
+ * @param {DocumentCollectionsClient.RequestOptions} requestOptions - Request-specific configuration.
322
327
  *
323
328
  * @example
324
329
  * await client.documentCollections.deleteCollection({
@@ -331,7 +336,8 @@ class DocumentCollections {
331
336
  __deleteCollection(request, requestOptions) {
332
337
  return __awaiter(this, void 0, void 0, function* () {
333
338
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
334
- 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);
335
341
  const _response = yield ((_b = this._options.fetcher) !== null && _b !== void 0 ? _b : core.fetcher)({
336
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"),
337
343
  method: "DELETE",
@@ -377,7 +383,7 @@ class DocumentCollections {
377
383
  * Credal lets you easily sync your MongoDB data for use in Collections and Agents. Create a new sync from a MongoDB collection to a Credal collection.
378
384
  *
379
385
  * @param {Credal.CreateMongoCollectionSyncRequest} request
380
- * @param {DocumentCollections.RequestOptions} requestOptions - Request-specific configuration.
386
+ * @param {DocumentCollectionsClient.RequestOptions} requestOptions - Request-specific configuration.
381
387
  *
382
388
  * @example
383
389
  * await client.documentCollections.createMongoCollectionSync({
@@ -406,7 +412,8 @@ class DocumentCollections {
406
412
  __createMongoCollectionSync(request, requestOptions) {
407
413
  return __awaiter(this, void 0, void 0, function* () {
408
414
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
409
- 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);
410
417
  const _response = yield ((_b = this._options.fetcher) !== null && _b !== void 0 ? _b : core.fetcher)({
411
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"),
412
419
  method: "POST",
@@ -452,7 +459,7 @@ class DocumentCollections {
452
459
  * Credal lets you easily sync your MongoDB data for use in Collections and Agents. Update an existing sync from a MongoDB collection to a Credal collection via the `mongoCredentialId`, to disambiguate between multiple potential syncs to a given collection.
453
460
  *
454
461
  * @param {Credal.UpdateMongoCollectionSyncRequest} request
455
- * @param {DocumentCollections.RequestOptions} requestOptions - Request-specific configuration.
462
+ * @param {DocumentCollectionsClient.RequestOptions} requestOptions - Request-specific configuration.
456
463
  *
457
464
  * @example
458
465
  * await client.documentCollections.updateMongoCollectionSync({
@@ -481,7 +488,8 @@ class DocumentCollections {
481
488
  __updateMongoCollectionSync(request, requestOptions) {
482
489
  return __awaiter(this, void 0, void 0, function* () {
483
490
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
484
- 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);
485
493
  const _response = yield ((_b = this._options.fetcher) !== null && _b !== void 0 ? _b : core.fetcher)({
486
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"),
487
495
  method: "POST",
@@ -523,17 +531,5 @@ class DocumentCollections {
523
531
  }
524
532
  });
525
533
  }
526
- _getAuthorizationHeader() {
527
- return __awaiter(this, void 0, void 0, function* () {
528
- var _a;
529
- 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;
530
- if (bearer == null) {
531
- throw new errors.CredalError({
532
- message: "Please specify a bearer by either passing it in to the constructor or initializing a CREDAL_API_KEY environment variable",
533
- });
534
- }
535
- return `Bearer ${bearer}`;
536
- });
537
- }
538
534
  }
539
- exports.DocumentCollections = DocumentCollections;
535
+ exports.DocumentCollectionsClient = DocumentCollectionsClient;
@@ -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 Search {
5
+ export declare namespace SearchClient {
5
6
  interface Options extends BaseClientOptions {
6
7
  }
7
8
  interface RequestOptions extends BaseRequestOptions {
8
9
  }
9
10
  }
10
- export declare class Search {
11
- protected readonly _options: Search.Options;
12
- constructor(_options?: Search.Options);
11
+ export declare class SearchClient {
12
+ protected readonly _options: NormalizedClientOptionsWithAuth<SearchClient.Options>;
13
+ constructor(options?: SearchClient.Options);
13
14
  /**
14
15
  * Search across all documents in a document collection using the document metadata and contents.
15
16
  *
16
17
  * @param {Credal.SearchDocumentCollectionRequest} request
17
- * @param {Search.RequestOptions} requestOptions - Request-specific configuration.
18
+ * @param {SearchClient.RequestOptions} requestOptions - Request-specific configuration.
18
19
  *
19
20
  * @example
20
21
  * await client.search.searchDocumentCollection({
@@ -36,7 +37,6 @@ export declare class Search {
36
37
  * }
37
38
  * })
38
39
  */
39
- searchDocumentCollection(request: Credal.SearchDocumentCollectionRequest, requestOptions?: Search.RequestOptions): core.HttpResponsePromise<Credal.SearchDocumentCollectionResponse>;
40
+ searchDocumentCollection(request: Credal.SearchDocumentCollectionRequest, requestOptions?: SearchClient.RequestOptions): core.HttpResponsePromise<Credal.SearchDocumentCollectionResponse>;
40
41
  private __searchDocumentCollection;
41
- protected _getAuthorizationHeader(): Promise<string>;
42
42
  }
@@ -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.Search = void 0;
46
+ exports.SearchClient = 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 Search {
52
- constructor(_options = {}) {
53
- this._options = _options;
52
+ class SearchClient {
53
+ constructor(options = {}) {
54
+ this._options = (0, BaseClient_js_1.normalizeClientOptionsWithAuth)(options);
54
55
  }
55
56
  /**
56
57
  * Search across all documents in a document collection using the document metadata and contents.
57
58
  *
58
59
  * @param {Credal.SearchDocumentCollectionRequest} request
59
- * @param {Search.RequestOptions} requestOptions - Request-specific configuration.
60
+ * @param {SearchClient.RequestOptions} requestOptions - Request-specific configuration.
60
61
  *
61
62
  * @example
62
63
  * await client.search.searchDocumentCollection({
@@ -84,7 +85,8 @@ class Search {
84
85
  __searchDocumentCollection(request, requestOptions) {
85
86
  return __awaiter(this, void 0, void 0, function* () {
86
87
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
87
- 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);
88
+ const _authRequest = yield this._options.authProvider.getAuthRequest();
89
+ 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);
88
90
  const _response = yield ((_b = this._options.fetcher) !== null && _b !== void 0 ? _b : core.fetcher)({
89
91
  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/search/searchDocumentCollection"),
90
92
  method: "POST",
@@ -129,17 +131,5 @@ class Search {
129
131
  }
130
132
  });
131
133
  }
132
- _getAuthorizationHeader() {
133
- return __awaiter(this, void 0, void 0, function* () {
134
- var _a;
135
- 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;
136
- if (bearer == null) {
137
- throw new errors.CredalError({
138
- message: "Please specify a bearer by either passing it in to the constructor or initializing a CREDAL_API_KEY environment variable",
139
- });
140
- }
141
- return `Bearer ${bearer}`;
142
- });
143
- }
144
134
  }
145
- exports.Search = Search;
135
+ exports.SearchClient = SearchClient;
@@ -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 Users {
5
+ export declare namespace UsersClient {
5
6
  interface Options extends BaseClientOptions {
6
7
  }
7
8
  interface RequestOptions extends BaseRequestOptions {
8
9
  }
9
10
  }
10
- export declare class Users {
11
- protected readonly _options: Users.Options;
12
- constructor(_options?: Users.Options);
11
+ export declare class UsersClient {
12
+ protected readonly _options: NormalizedClientOptionsWithAuth<UsersClient.Options>;
13
+ constructor(options?: UsersClient.Options);
13
14
  /**
14
15
  * Bulk patch metadata for users
15
16
  *
16
17
  * @param {Credal.UserMetadataPatch[]} request
17
- * @param {Users.RequestOptions} requestOptions - Request-specific configuration.
18
+ * @param {UsersClient.RequestOptions} requestOptions - Request-specific configuration.
18
19
  *
19
20
  * @example
20
21
  * await client.users.metadata([{
@@ -31,7 +32,6 @@ export declare class Users {
31
32
  * userEmail: "jack@credal.ai"
32
33
  * }])
33
34
  */
34
- metadata(request: Credal.UserMetadataPatch[], requestOptions?: Users.RequestOptions): core.HttpResponsePromise<void>;
35
+ metadata(request: Credal.UserMetadataPatch[], requestOptions?: UsersClient.RequestOptions): core.HttpResponsePromise<void>;
35
36
  private __metadata;
36
- protected _getAuthorizationHeader(): Promise<string>;
37
37
  }
@@ -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.Users = void 0;
46
+ exports.UsersClient = 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 Users {
52
- constructor(_options = {}) {
53
- this._options = _options;
52
+ class UsersClient {
53
+ constructor(options = {}) {
54
+ this._options = (0, BaseClient_js_1.normalizeClientOptionsWithAuth)(options);
54
55
  }
55
56
  /**
56
57
  * Bulk patch metadata for users
57
58
  *
58
59
  * @param {Credal.UserMetadataPatch[]} request
59
- * @param {Users.RequestOptions} requestOptions - Request-specific configuration.
60
+ * @param {UsersClient.RequestOptions} requestOptions - Request-specific configuration.
60
61
  *
61
62
  * @example
62
63
  * await client.users.metadata([{
@@ -79,7 +80,8 @@ class Users {
79
80
  __metadata(request, requestOptions) {
80
81
  return __awaiter(this, void 0, void 0, function* () {
81
82
  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);
83
+ const _authRequest = yield this._options.authProvider.getAuthRequest();
84
+ 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
85
  const _response = yield ((_b = this._options.fetcher) !== null && _b !== void 0 ? _b : core.fetcher)({
84
86
  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/users/metadata"),
85
87
  method: "PATCH",
@@ -121,17 +123,5 @@ class Users {
121
123
  }
122
124
  });
123
125
  }
124
- _getAuthorizationHeader() {
125
- return __awaiter(this, void 0, void 0, function* () {
126
- var _a;
127
- 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;
128
- if (bearer == null) {
129
- throw new errors.CredalError({
130
- message: "Please specify a bearer by either passing it in to the constructor or initializing a CREDAL_API_KEY environment variable",
131
- });
132
- }
133
- return `Bearer ${bearer}`;
134
- });
135
- }
136
126
  }
137
- exports.Users = Users;
127
+ exports.UsersClient = UsersClient;
@@ -0,0 +1,14 @@
1
+ import * as core from "../core/index.js";
2
+ export declare namespace BearerAuthProvider {
3
+ interface Options {
4
+ apiKey?: core.Supplier<core.BearerToken | undefined>;
5
+ }
6
+ }
7
+ export declare class BearerAuthProvider implements core.AuthProvider {
8
+ private readonly token;
9
+ constructor(options: BearerAuthProvider.Options);
10
+ static canCreate(options: BearerAuthProvider.Options): boolean;
11
+ getAuthRequest(_arg?: {
12
+ endpointMetadata?: core.EndpointMetadata;
13
+ }): Promise<core.AuthRequest>;
14
+ }