@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,18 +1,19 @@
1
1
  import type { BaseClientOptions, BaseRequestOptions } from "../../../../BaseClient.mjs";
2
+ import { type NormalizedClientOptionsWithAuth } from "../../../../BaseClient.mjs";
2
3
  import * as core from "../../../../core/index.mjs";
3
4
  import type * as Credal from "../../../index.mjs";
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
  }
@@ -8,17 +8,18 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
8
8
  step((generator = generator.apply(thisArg, _arguments || [])).next());
9
9
  });
10
10
  };
11
+ import { normalizeClientOptionsWithAuth } from "../../../../BaseClient.mjs";
11
12
  import { mergeHeaders, mergeOnlyDefinedHeaders } from "../../../../core/headers.mjs";
12
13
  import * as core from "../../../../core/index.mjs";
13
14
  import * as environments from "../../../../environments.mjs";
14
15
  import * as errors from "../../../../errors/index.mjs";
15
- export class DocumentCatalog {
16
- constructor(_options = {}) {
17
- this._options = _options;
16
+ export class DocumentCatalogClient {
17
+ constructor(options = {}) {
18
+ this._options = normalizeClientOptionsWithAuth(options);
18
19
  }
19
20
  /**
20
21
  * @param {Credal.UploadDocumentContentsRequest} request
21
- * @param {DocumentCatalog.RequestOptions} requestOptions - Request-specific configuration.
22
+ * @param {DocumentCatalogClient.RequestOptions} requestOptions - Request-specific configuration.
22
23
  *
23
24
  * @example
24
25
  * await client.documentCatalog.uploadDocumentContents({
@@ -35,7 +36,8 @@ export class DocumentCatalog {
35
36
  __uploadDocumentContents(request, requestOptions) {
36
37
  return __awaiter(this, void 0, void 0, function* () {
37
38
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
38
- const _headers = mergeHeaders((_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, mergeOnlyDefinedHeaders({ Authorization: yield this._getAuthorizationHeader() }), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
39
+ const _authRequest = yield this._options.authProvider.getAuthRequest();
40
+ const _headers = mergeHeaders(_authRequest.headers, (_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
39
41
  const _response = yield ((_b = this._options.fetcher) !== null && _b !== void 0 ? _b : core.fetcher)({
40
42
  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"),
41
43
  method: "POST",
@@ -81,7 +83,7 @@ export class DocumentCatalog {
81
83
  * 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.
82
84
  *
83
85
  * @param {Credal.UploadFileRequest} request
84
- * @param {DocumentCatalog.RequestOptions} requestOptions - Request-specific configuration.
86
+ * @param {DocumentCatalogClient.RequestOptions} requestOptions - Request-specific configuration.
85
87
  */
86
88
  uploadFile(request, requestOptions) {
87
89
  return core.HttpResponsePromise.fromPromise(this.__uploadFile(request, requestOptions));
@@ -121,7 +123,8 @@ export class DocumentCatalog {
121
123
  _request.append("awaitVectorStoreSync", request.awaitVectorStoreSync);
122
124
  }
123
125
  const _maybeEncodedRequest = yield _request.getRequest();
124
- const _headers = mergeHeaders((_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, mergeOnlyDefinedHeaders(Object.assign({ Authorization: yield this._getAuthorizationHeader() }, _maybeEncodedRequest.headers)), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
126
+ const _authRequest = yield this._options.authProvider.getAuthRequest();
127
+ const _headers = mergeHeaders(_authRequest.headers, (_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, mergeOnlyDefinedHeaders(Object.assign({}, _maybeEncodedRequest.headers)), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
125
128
  const _response = yield ((_b = this._options.fetcher) !== null && _b !== void 0 ? _b : core.fetcher)({
126
129
  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"),
127
130
  method: "POST",
@@ -167,7 +170,7 @@ export class DocumentCatalog {
167
170
  * Sync a document from a source URL. Does not support recursive web search. Reach out to a Credal representative for access.
168
171
  *
169
172
  * @param {Credal.SyncSourceByUrlRequest} request
170
- * @param {DocumentCatalog.RequestOptions} requestOptions - Request-specific configuration.
173
+ * @param {DocumentCatalogClient.RequestOptions} requestOptions - Request-specific configuration.
171
174
  *
172
175
  * @example
173
176
  * await client.documentCatalog.syncSourceByUrl({
@@ -181,7 +184,8 @@ export class DocumentCatalog {
181
184
  __syncSourceByUrl(request, requestOptions) {
182
185
  return __awaiter(this, void 0, void 0, function* () {
183
186
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
184
- const _headers = mergeHeaders((_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, mergeOnlyDefinedHeaders({ Authorization: yield this._getAuthorizationHeader() }), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
187
+ const _authRequest = yield this._options.authProvider.getAuthRequest();
188
+ const _headers = mergeHeaders(_authRequest.headers, (_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
185
189
  const _response = yield ((_b = this._options.fetcher) !== null && _b !== void 0 ? _b : core.fetcher)({
186
190
  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"),
187
191
  method: "POST",
@@ -227,7 +231,7 @@ export class DocumentCatalog {
227
231
  * Bulk patch metadata for documents, synced natively by Credal or manual API uploads
228
232
  *
229
233
  * @param {Credal.DocumentMetadataPatchRequest} request
230
- * @param {DocumentCatalog.RequestOptions} requestOptions - Request-specific configuration.
234
+ * @param {DocumentCatalogClient.RequestOptions} requestOptions - Request-specific configuration.
231
235
  *
232
236
  * @example
233
237
  * await client.documentCatalog.metadata({
@@ -261,7 +265,8 @@ export class DocumentCatalog {
261
265
  __metadata(request, requestOptions) {
262
266
  return __awaiter(this, void 0, void 0, function* () {
263
267
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
264
- const _headers = mergeHeaders((_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, mergeOnlyDefinedHeaders({ Authorization: yield this._getAuthorizationHeader() }), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
268
+ const _authRequest = yield this._options.authProvider.getAuthRequest();
269
+ const _headers = mergeHeaders(_authRequest.headers, (_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
265
270
  const _response = yield ((_b = this._options.fetcher) !== null && _b !== void 0 ? _b : core.fetcher)({
266
271
  url: core.url.join((_d = (_c = (yield core.Supplier.get(this._options.baseUrl))) !== null && _c !== void 0 ? _c : (yield core.Supplier.get(this._options.environment))) !== null && _d !== void 0 ? _d : environments.CredalEnvironment.Production, "/v0/catalog/metadata"),
267
272
  method: "PATCH",
@@ -303,16 +308,4 @@ export class DocumentCatalog {
303
308
  }
304
309
  });
305
310
  }
306
- _getAuthorizationHeader() {
307
- return __awaiter(this, void 0, void 0, function* () {
308
- var _a;
309
- 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;
310
- if (bearer == null) {
311
- throw new errors.CredalError({
312
- message: "Please specify a bearer by either passing it in to the constructor or initializing a CREDAL_API_KEY environment variable",
313
- });
314
- }
315
- return `Bearer ${bearer}`;
316
- });
317
- }
318
311
  }
@@ -1,20 +1,21 @@
1
1
  import type { BaseClientOptions, BaseRequestOptions } from "../../../../BaseClient.mjs";
2
+ import { type NormalizedClientOptionsWithAuth } from "../../../../BaseClient.mjs";
2
3
  import * as core from "../../../../core/index.mjs";
3
4
  import type * as Credal from "../../../index.mjs";
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
  }
@@ -8,19 +8,20 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
8
8
  step((generator = generator.apply(thisArg, _arguments || [])).next());
9
9
  });
10
10
  };
11
- import { mergeHeaders, mergeOnlyDefinedHeaders } from "../../../../core/headers.mjs";
11
+ import { normalizeClientOptionsWithAuth } from "../../../../BaseClient.mjs";
12
+ import { mergeHeaders } from "../../../../core/headers.mjs";
12
13
  import * as core from "../../../../core/index.mjs";
13
14
  import * as environments from "../../../../environments.mjs";
14
15
  import * as errors from "../../../../errors/index.mjs";
15
- export class DocumentCollections {
16
- constructor(_options = {}) {
17
- this._options = _options;
16
+ export class DocumentCollectionsClient {
17
+ constructor(options = {}) {
18
+ this._options = normalizeClientOptionsWithAuth(options);
18
19
  }
19
20
  /**
20
21
  * 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.
21
22
  *
22
23
  * @param {Credal.AddDocumentsToCollectionRequest} request
23
- * @param {DocumentCollections.RequestOptions} requestOptions - Request-specific configuration.
24
+ * @param {DocumentCollectionsClient.RequestOptions} requestOptions - Request-specific configuration.
24
25
  *
25
26
  * @example
26
27
  * await client.documentCollections.addDocumentsToCollection({
@@ -42,7 +43,8 @@ export class DocumentCollections {
42
43
  __addDocumentsToCollection(request, requestOptions) {
43
44
  return __awaiter(this, void 0, void 0, function* () {
44
45
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
45
- const _headers = mergeHeaders((_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, mergeOnlyDefinedHeaders({ Authorization: yield this._getAuthorizationHeader() }), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
46
+ const _authRequest = yield this._options.authProvider.getAuthRequest();
47
+ const _headers = mergeHeaders(_authRequest.headers, (_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
46
48
  const _response = yield ((_b = this._options.fetcher) !== null && _b !== void 0 ? _b : core.fetcher)({
47
49
  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"),
48
50
  method: "POST",
@@ -88,7 +90,7 @@ export class DocumentCollections {
88
90
  * Remove documents from a collection
89
91
  *
90
92
  * @param {Credal.RemoveDocumentsFromCollectionRequest} request
91
- * @param {DocumentCollections.RequestOptions} requestOptions - Request-specific configuration.
93
+ * @param {DocumentCollectionsClient.RequestOptions} requestOptions - Request-specific configuration.
92
94
  *
93
95
  * @example
94
96
  * await client.documentCollections.removeDocumentsFromCollection({
@@ -110,7 +112,8 @@ export class DocumentCollections {
110
112
  __removeDocumentsFromCollection(request, requestOptions) {
111
113
  return __awaiter(this, void 0, void 0, function* () {
112
114
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
113
- const _headers = mergeHeaders((_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, mergeOnlyDefinedHeaders({ Authorization: yield this._getAuthorizationHeader() }), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
115
+ const _authRequest = yield this._options.authProvider.getAuthRequest();
116
+ const _headers = mergeHeaders(_authRequest.headers, (_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
114
117
  const _response = yield ((_b = this._options.fetcher) !== null && _b !== void 0 ? _b : core.fetcher)({
115
118
  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"),
116
119
  method: "DELETE",
@@ -156,7 +159,7 @@ export class DocumentCollections {
156
159
  * List documents in a collection
157
160
  *
158
161
  * @param {Credal.ListDocumentsInCollectionRequest} request
159
- * @param {DocumentCollections.RequestOptions} requestOptions - Request-specific configuration.
162
+ * @param {DocumentCollectionsClient.RequestOptions} requestOptions - Request-specific configuration.
160
163
  *
161
164
  * @example
162
165
  * await client.documentCollections.listDocumentsInCollection({
@@ -172,7 +175,8 @@ export class DocumentCollections {
172
175
  const { collectionId } = request;
173
176
  const _queryParams = {};
174
177
  _queryParams.collectionId = collectionId;
175
- const _headers = mergeHeaders((_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, mergeOnlyDefinedHeaders({ Authorization: yield this._getAuthorizationHeader() }), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
178
+ const _authRequest = yield this._options.authProvider.getAuthRequest();
179
+ const _headers = mergeHeaders(_authRequest.headers, (_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
176
180
  const _response = yield ((_b = this._options.fetcher) !== null && _b !== void 0 ? _b : core.fetcher)({
177
181
  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"),
178
182
  method: "GET",
@@ -218,7 +222,7 @@ export class DocumentCollections {
218
222
  * Create a new collection. The API key used will be added to the collection for future Requests
219
223
  *
220
224
  * @param {Credal.CreateCollectionRequest} request
221
- * @param {DocumentCollections.RequestOptions} requestOptions - Request-specific configuration.
225
+ * @param {DocumentCollectionsClient.RequestOptions} requestOptions - Request-specific configuration.
222
226
  *
223
227
  * @example
224
228
  * await client.documentCollections.createCollection({
@@ -236,7 +240,8 @@ export class DocumentCollections {
236
240
  __createCollection(request, requestOptions) {
237
241
  return __awaiter(this, void 0, void 0, function* () {
238
242
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
239
- const _headers = mergeHeaders((_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, mergeOnlyDefinedHeaders({ Authorization: yield this._getAuthorizationHeader() }), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
243
+ const _authRequest = yield this._options.authProvider.getAuthRequest();
244
+ const _headers = mergeHeaders(_authRequest.headers, (_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
240
245
  const _response = yield ((_b = this._options.fetcher) !== null && _b !== void 0 ? _b : core.fetcher)({
241
246
  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"),
242
247
  method: "POST",
@@ -282,7 +287,7 @@ export class DocumentCollections {
282
287
  * Delete the collection.
283
288
  *
284
289
  * @param {Credal.DeleteCollectionRequest} request
285
- * @param {DocumentCollections.RequestOptions} requestOptions - Request-specific configuration.
290
+ * @param {DocumentCollectionsClient.RequestOptions} requestOptions - Request-specific configuration.
286
291
  *
287
292
  * @example
288
293
  * await client.documentCollections.deleteCollection({
@@ -295,7 +300,8 @@ export class DocumentCollections {
295
300
  __deleteCollection(request, requestOptions) {
296
301
  return __awaiter(this, void 0, void 0, function* () {
297
302
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
298
- const _headers = mergeHeaders((_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, mergeOnlyDefinedHeaders({ Authorization: yield this._getAuthorizationHeader() }), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
303
+ const _authRequest = yield this._options.authProvider.getAuthRequest();
304
+ const _headers = mergeHeaders(_authRequest.headers, (_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
299
305
  const _response = yield ((_b = this._options.fetcher) !== null && _b !== void 0 ? _b : core.fetcher)({
300
306
  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"),
301
307
  method: "DELETE",
@@ -341,7 +347,7 @@ export class DocumentCollections {
341
347
  * 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.
342
348
  *
343
349
  * @param {Credal.CreateMongoCollectionSyncRequest} request
344
- * @param {DocumentCollections.RequestOptions} requestOptions - Request-specific configuration.
350
+ * @param {DocumentCollectionsClient.RequestOptions} requestOptions - Request-specific configuration.
345
351
  *
346
352
  * @example
347
353
  * await client.documentCollections.createMongoCollectionSync({
@@ -370,7 +376,8 @@ export class DocumentCollections {
370
376
  __createMongoCollectionSync(request, requestOptions) {
371
377
  return __awaiter(this, void 0, void 0, function* () {
372
378
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
373
- const _headers = mergeHeaders((_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, mergeOnlyDefinedHeaders({ Authorization: yield this._getAuthorizationHeader() }), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
379
+ const _authRequest = yield this._options.authProvider.getAuthRequest();
380
+ const _headers = mergeHeaders(_authRequest.headers, (_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
374
381
  const _response = yield ((_b = this._options.fetcher) !== null && _b !== void 0 ? _b : core.fetcher)({
375
382
  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"),
376
383
  method: "POST",
@@ -416,7 +423,7 @@ export class DocumentCollections {
416
423
  * 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.
417
424
  *
418
425
  * @param {Credal.UpdateMongoCollectionSyncRequest} request
419
- * @param {DocumentCollections.RequestOptions} requestOptions - Request-specific configuration.
426
+ * @param {DocumentCollectionsClient.RequestOptions} requestOptions - Request-specific configuration.
420
427
  *
421
428
  * @example
422
429
  * await client.documentCollections.updateMongoCollectionSync({
@@ -445,7 +452,8 @@ export class DocumentCollections {
445
452
  __updateMongoCollectionSync(request, requestOptions) {
446
453
  return __awaiter(this, void 0, void 0, function* () {
447
454
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
448
- const _headers = mergeHeaders((_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, mergeOnlyDefinedHeaders({ Authorization: yield this._getAuthorizationHeader() }), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
455
+ const _authRequest = yield this._options.authProvider.getAuthRequest();
456
+ const _headers = mergeHeaders(_authRequest.headers, (_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
449
457
  const _response = yield ((_b = this._options.fetcher) !== null && _b !== void 0 ? _b : core.fetcher)({
450
458
  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"),
451
459
  method: "POST",
@@ -487,16 +495,4 @@ export class DocumentCollections {
487
495
  }
488
496
  });
489
497
  }
490
- _getAuthorizationHeader() {
491
- return __awaiter(this, void 0, void 0, function* () {
492
- var _a;
493
- 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;
494
- if (bearer == null) {
495
- throw new errors.CredalError({
496
- message: "Please specify a bearer by either passing it in to the constructor or initializing a CREDAL_API_KEY environment variable",
497
- });
498
- }
499
- return `Bearer ${bearer}`;
500
- });
501
- }
502
498
  }
@@ -1,20 +1,21 @@
1
1
  import type { BaseClientOptions, BaseRequestOptions } from "../../../../BaseClient.mjs";
2
+ import { type NormalizedClientOptionsWithAuth } from "../../../../BaseClient.mjs";
2
3
  import * as core from "../../../../core/index.mjs";
3
4
  import type * as Credal from "../../../index.mjs";
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
  }
@@ -8,19 +8,20 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
8
8
  step((generator = generator.apply(thisArg, _arguments || [])).next());
9
9
  });
10
10
  };
11
- import { mergeHeaders, mergeOnlyDefinedHeaders } from "../../../../core/headers.mjs";
11
+ import { normalizeClientOptionsWithAuth } from "../../../../BaseClient.mjs";
12
+ import { mergeHeaders } from "../../../../core/headers.mjs";
12
13
  import * as core from "../../../../core/index.mjs";
13
14
  import * as environments from "../../../../environments.mjs";
14
15
  import * as errors from "../../../../errors/index.mjs";
15
- export class Search {
16
- constructor(_options = {}) {
17
- this._options = _options;
16
+ export class SearchClient {
17
+ constructor(options = {}) {
18
+ this._options = normalizeClientOptionsWithAuth(options);
18
19
  }
19
20
  /**
20
21
  * Search across all documents in a document collection using the document metadata and contents.
21
22
  *
22
23
  * @param {Credal.SearchDocumentCollectionRequest} request
23
- * @param {Search.RequestOptions} requestOptions - Request-specific configuration.
24
+ * @param {SearchClient.RequestOptions} requestOptions - Request-specific configuration.
24
25
  *
25
26
  * @example
26
27
  * await client.search.searchDocumentCollection({
@@ -48,7 +49,8 @@ export class Search {
48
49
  __searchDocumentCollection(request, requestOptions) {
49
50
  return __awaiter(this, void 0, void 0, function* () {
50
51
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
51
- const _headers = mergeHeaders((_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, mergeOnlyDefinedHeaders({ Authorization: yield this._getAuthorizationHeader() }), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
52
+ const _authRequest = yield this._options.authProvider.getAuthRequest();
53
+ const _headers = mergeHeaders(_authRequest.headers, (_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
52
54
  const _response = yield ((_b = this._options.fetcher) !== null && _b !== void 0 ? _b : core.fetcher)({
53
55
  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"),
54
56
  method: "POST",
@@ -93,16 +95,4 @@ export class Search {
93
95
  }
94
96
  });
95
97
  }
96
- _getAuthorizationHeader() {
97
- return __awaiter(this, void 0, void 0, function* () {
98
- var _a;
99
- 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;
100
- if (bearer == null) {
101
- throw new errors.CredalError({
102
- message: "Please specify a bearer by either passing it in to the constructor or initializing a CREDAL_API_KEY environment variable",
103
- });
104
- }
105
- return `Bearer ${bearer}`;
106
- });
107
- }
108
98
  }
@@ -1,20 +1,21 @@
1
1
  import type { BaseClientOptions, BaseRequestOptions } from "../../../../BaseClient.mjs";
2
+ import { type NormalizedClientOptionsWithAuth } from "../../../../BaseClient.mjs";
2
3
  import * as core from "../../../../core/index.mjs";
3
4
  import type * as Credal from "../../../index.mjs";
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
  }