Skip to content

Commit 3ef9a24

Browse files
committed
Removed logSkippedOptions since properly typed client + python doesnt do it
1 parent 9f7f1c7 commit 3ef9a24

File tree

17 files changed

+11
-135
lines changed

17 files changed

+11
-135
lines changed

src/api/data-api-http-client.ts

Lines changed: 1 addition & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -29,17 +29,7 @@ export class DataApiHttpClient extends HttpClient {
2929
public collection?: string;
3030
public namespace?: string;
3131

32-
public async executeCommand(command: Record<string, any>, options?: BaseOptions & { collection?: string, namespace?: string }, optionsToRetain?: Set<string>) {
33-
const commandName = Object.keys(command)[0];
34-
35-
if (optionsToRetain) {
36-
const [options, dirty] = cleanupOptions(command, commandName, optionsToRetain, this.logSkippedOptions);
37-
38-
if (dirty) {
39-
command = { [commandName]: { ...command[commandName], options } };
40-
}
41-
}
42-
32+
public async executeCommand(command: Record<string, any>, options?: BaseOptions & { collection?: string, namespace?: string }) {
4333
const response = await this._requestDataApi({
4434
url: this.baseUrl,
4535
timeout: options?.maxTimeMS,
@@ -104,29 +94,6 @@ export class DataApiHttpClient extends HttpClient {
10494
}
10595
}
10696

107-
function cleanupOptions(data: Record<string, any>, commandName: string, optionsToRetain: Set<string>, logSkippedOptions: boolean) {
108-
const command = data[commandName];
109-
110-
if (!command.options) {
111-
return [undefined, false];
112-
}
113-
114-
const options = { ...command.options };
115-
let dirty = false;
116-
117-
Object.keys(options).forEach((key) => {
118-
if (!optionsToRetain.has(key)) {
119-
if (logSkippedOptions) {
120-
logger.warn(`'${commandName}' does not support option '${key}'`);
121-
}
122-
delete options[key];
123-
dirty = true;
124-
}
125-
});
126-
127-
return [options, dirty];
128-
}
129-
13097
export function replacer(this: any, key: string, value: any): any {
13198
if (typeof value === 'bigint') {
13299
return Number(value);

src/api/http-client.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ import { Caller } from '@/src/client';
2626

2727
export class HttpClient {
2828
public readonly baseUrl: string;
29-
public readonly logSkippedOptions: boolean;
3029
public readonly userAgent: string;
3130
public requestStrategy: HTTPRequestStrategy;
3231
#applicationToken: string;
@@ -47,7 +46,6 @@ export class HttpClient {
4746
this.#applicationToken = options.applicationToken;
4847

4948
this.baseUrl = options.baseUrl;
50-
this.logSkippedOptions = options.logSkippedOptions ?? false;
5149

5250
this.requestStrategy =
5351
(options.requestStrategy)
@@ -79,7 +77,6 @@ export class HttpClient {
7977
const clone = new cls({
8078
baseUrl: this.baseUrl,
8179
applicationToken: this.#applicationToken,
82-
logSkippedOptions: this.logSkippedOptions,
8380
requestStrategy: this.requestStrategy,
8481
userAgent: this.userAgent,
8582
});

src/api/types.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ export interface HTTPClientOptions {
2626
useHttp2?: boolean;
2727
requestStrategy?: HTTPRequestStrategy;
2828
userAgent?: string;
29-
logSkippedOptions?: boolean;
3029
}
3130

3231
export interface RawDataApiResponse {

src/client/types.ts

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -153,22 +153,6 @@ export interface DbSpawnOptions {
153153
* @defaultValue true
154154
*/
155155
useHttp2?: boolean,
156-
/**
157-
* Whether to log skipped options (logs as 'warn')
158-
*
159-
* Logs when a command is executed with options that are not supported by the client
160-
*
161-
* Defaults to `false`.
162-
*
163-
* @example
164-
* ```typescript
165-
* // Logs a warning 'findOne' does not support option 'unknownOption'
166-
* await findOne({}, { unknownOption: 'value' });
167-
* ```
168-
*
169-
* @defaultValue false
170-
*/
171-
logSkippedOptions?: boolean,
172156
/**
173157
* The path to the Data API, which is going to be `api/json/v1` for all Astra instances. However, it may vary
174158
* if you're using a different Data API-compatible endpoint.

src/data-api/collection.ts

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -43,19 +43,15 @@ import {
4343
FindOneAndDeleteOptions,
4444
FindOneAndReplaceCommand,
4545
FindOneAndReplaceOptions,
46-
findOneAndReplaceOptionsKeys,
4746
FindOneAndUpdateCommand,
4847
FindOneAndUpdateOptions,
49-
findOneAndUpdateOptionsKeys,
5048
FindOneCommand,
5149
FindOneOptions,
52-
findOneOptionsKeys,
5350
FindOptions,
5451
Flatten,
5552
FoundDoc,
5653
IdOf,
5754
InsertManyCommand,
58-
insertManyOptionKeys,
5955
InsertManyOptions,
6056
InsertManyResult,
6157
InsertOneCommand,
@@ -73,7 +69,6 @@ import {
7369
UpdateManyOptions,
7470
UpdateManyResult,
7571
UpdateOneCommand,
76-
updateOneOptionKeys,
7772
UpdateOneOptions,
7873
UpdateOneResult,
7974
WithId,
@@ -373,7 +368,7 @@ export class Collection<Schema extends SomeDoc = SomeDoc> {
373368
command.updateOne.sort = options.sort;
374369
}
375370

376-
const resp = await this._httpClient.executeCommand(command, options, updateOneOptionKeys);
371+
const resp = await this._httpClient.executeCommand(command, options);
377372

378373
const commonResult = {
379374
modifiedCount: resp.status?.modifiedCount,
@@ -555,7 +550,7 @@ export class Collection<Schema extends SomeDoc = SomeDoc> {
555550
command.findOneAndReplace.sort = options.sort;
556551
}
557552

558-
const resp = await this._httpClient.executeCommand(command, options, findOneAndReplaceOptionsKeys);
553+
const resp = await this._httpClient.executeCommand(command, options);
559554

560555
const commonResult = {
561556
modifiedCount: resp.status?.modifiedCount,
@@ -937,7 +932,7 @@ export class Collection<Schema extends SomeDoc = SomeDoc> {
937932
command.findOne.projection = options.projection;
938933
}
939934

940-
const resp = await this._httpClient.executeCommand(command, options, findOneOptionsKeys);
935+
const resp = await this._httpClient.executeCommand(command, options);
941936
return resp.data?.document;
942937
}
943938

@@ -1114,7 +1109,7 @@ export class Collection<Schema extends SomeDoc = SomeDoc> {
11141109
command.findOneAndReplace.projection = options.projection;
11151110
}
11161111

1117-
const resp = await this._httpClient.executeCommand(command, options, findOneAndReplaceOptionsKeys);
1112+
const resp = await this._httpClient.executeCommand(command, options);
11181113
const document = resp.data?.document;
11191114

11201115
return (options.includeResultMetadata)
@@ -1329,7 +1324,7 @@ export class Collection<Schema extends SomeDoc = SomeDoc> {
13291324
command.findOneAndUpdate.projection = options.projection;
13301325
}
13311326

1332-
const resp = await this._httpClient.executeCommand(command, options, findOneAndUpdateOptionsKeys);
1327+
const resp = await this._httpClient.executeCommand(command, options);
13331328
const document = resp.data?.document;
13341329

13351330
return (options.includeResultMetadata)
@@ -1572,7 +1567,7 @@ const insertMany = async <Schema>(httpClient: DataApiHttpClient, documents: unkn
15721567
}
15731568
}
15741569

1575-
const resp = await httpClient.executeCommand(command, {}, insertManyOptionKeys);
1570+
const resp = await httpClient.executeCommand(command, {});
15761571
return resp.status?.insertedIds ?? [];
15771572
}
15781573

src/data-api/cursor.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ import {
1616
Filter,
1717
FindOptions,
1818
InternalFindOptions,
19-
internalFindOptionsKeys,
2019
InternalGetMoreCommand,
2120
ProjectionOption,
2221
SortOption,
@@ -500,7 +499,7 @@ export class FindCursor<T, TRaw extends SomeDoc = SomeDoc> {
500499
command.find.options = options;
501500
}
502501

503-
const resp = await this._httpClient.executeCommand(command, {}, internalFindOptionsKeys);
502+
const resp = await this._httpClient.executeCommand(command, {});
504503

505504
this._nextPageState = resp.data!.nextPageState || null;
506505
this._buffer = resp.data!.documents as TRaw[];

src/data-api/db.ts

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,10 @@ import {
1919
CollectionName,
2020
CreateCollectionCommand,
2121
CreateCollectionOptions,
22-
createCollectionOptionsKeys,
2322
FullCollectionInfo,
24-
listCollectionOptionsKeys,
2523
ListCollectionsCommand,
2624
ListCollectionsOptions,
27-
WithNamespace
25+
WithNamespace,
2826
} from '@/src/data-api/types';
2927
import { DatabaseInfo } from '@/src/devops/types/admin/database-info';
3028
import { AstraDbAdmin, mkDbAdmin } from '@/src/devops/astra-db-admin';
@@ -132,7 +130,6 @@ export class Db implements Disposable {
132130
applicationToken: dbOpts.token,
133131
baseApiPath: dbOpts?.dataApiPath || DEFAULT_DATA_API_PATH,
134132
caller: options.caller,
135-
logSkippedOptions: dbOpts.logSkippedOptions,
136133
useHttp2: dbOpts.useHttp2,
137134
}),
138135
enumerable: false,
@@ -313,7 +310,7 @@ export class Db implements Disposable {
313310
},
314311
};
315312

316-
await this._httpClient.executeCommand(command, options, createCollectionOptionsKeys);
313+
await this._httpClient.executeCommand(command, options);
317314

318315
return this.collection(collectionName, options);
319316
}
@@ -405,7 +402,7 @@ export class Db implements Disposable {
405402
},
406403
}
407404

408-
const resp = await this._httpClient.executeCommand(command, options, listCollectionOptionsKeys);
405+
const resp = await this._httpClient.executeCommand(command, options);
409406

410407
return (options?.nameOnly !== false)
411408
? resp.status!.collections.map((name: string) => ({ name }))

src/data-api/types/collections/create-collection.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,3 @@ export interface CreateCollectionCommand {
3535
* @see Db.createCollection
3636
*/
3737
export interface CreateCollectionOptions<Schema extends SomeDoc> extends BaseOptions, CollectionOptions<Schema>, WithNamespace {}
38-
39-
/** @internal */
40-
export const createCollectionOptionsKeys = new Set(['vector', 'indexing', 'defaultId']);

src/data-api/types/collections/list-collection.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,3 @@ export interface FullCollectionInfo {
8989
*/
9090
options: CollectionOptions<SomeDoc>,
9191
}
92-
93-
/** @internal */
94-
export const listCollectionOptionsKeys = new Set(['explain']);

src/data-api/types/find/find-one-replace.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,3 @@ export interface FindOneAndReplaceOptions<Schema extends SomeDoc> extends BaseOp
133133
*/
134134
includeResultMetadata?: boolean,
135135
}
136-
137-
/** @internal */
138-
export const findOneAndReplaceOptionsKeys = new Set(['upsert', 'returnDocument', 'sort', 'projection']);

0 commit comments

Comments
 (0)