Skip to content

Commit fc26224

Browse files
authored
Deprecated features removal (#74)
* remove deprecated vector/vectorize parameters * remove bulkWrite * remove deleteAll * removed namespace terminology * removed db.collections() * removed client.db(id, region) * update api report
1 parent 263e90d commit fc26224

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+131
-2077
lines changed

etc/astra-db-ts.api.md

Lines changed: 2 additions & 201 deletions
Large diffs are not rendered by default.

src/administration/astra-admin.ts

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,11 @@ import {
2323
} from '@/src/administration/types';
2424
import { AstraDbAdmin } from '@/src/administration/astra-db-admin';
2525
import { DbSpawnOptions, InternalRootClientOpts } from '@/src/client/types';
26-
import { Db, mkDb } from '@/src/db/db';
26+
import { Db } from '@/src/db/db';
2727
import { validateAdminOpts } from '@/src/administration/utils';
2828
import { DEFAULT_DEVOPS_API_ENDPOINTS, DEFAULT_KEYSPACE, HttpMethods } from '@/src/lib/api/constants';
2929
import { DevOpsAPIHttpClient } from '@/src/lib/api/clients/devops-api-http-client';
3030
import { TokenProvider, WithTimeout } from '@/src/lib';
31-
import { resolveKeyspace } from '@/src/lib/utils';
3231

3332
/**
3433
* An administrative class for managing Astra databases, including creating, listing, and deleting databases.
@@ -155,7 +154,19 @@ export class AstraAdmin {
155154
public db(id: string, region: string, options?: DbSpawnOptions): Db;
156155

157156
public db(endpointOrId: string, regionOrOptions?: string | DbSpawnOptions, maybeOptions?: DbSpawnOptions): Db {
158-
return mkDb(this.#defaultOpts, endpointOrId, regionOrOptions, maybeOptions);
157+
const dbOpts = (typeof regionOrOptions === 'string')
158+
? maybeOptions
159+
: regionOrOptions;
160+
161+
if (typeof regionOrOptions === 'string' && (endpointOrId.startsWith('https://') || endpointOrId.startsWith('http://'))) {
162+
throw new Error('Unexpected db() argument: database id can\'t start with "http(s)://". Did you mean to call `.db(endpoint, { keyspace })`?');
163+
}
164+
165+
const endpoint = (typeof regionOrOptions === 'string')
166+
? 'https://' + endpointOrId + '-' + regionOrOptions + '.apps.astra.datastax.com'
167+
: endpointOrId;
168+
169+
return new Db(this.#defaultOpts, endpoint, dbOpts);
159170
}
160171

161172
/**
@@ -369,7 +380,7 @@ export class AstraAdmin {
369380
capacityUnits: 1,
370381
tier: 'serverless',
371382
dbType: 'vector',
372-
keyspace: resolveKeyspace(config) || DEFAULT_KEYSPACE,
383+
keyspace: config.keyspace || DEFAULT_KEYSPACE,
373384
...config,
374385
};
375386

@@ -385,7 +396,7 @@ export class AstraAdmin {
385396
options,
386397
});
387398

388-
const db = mkDb(this.#defaultOpts, resp.headers.location, definition.region, { ...options?.dbOptions, keyspace: definition.keyspace });
399+
const db = this.db(resp.headers.location, definition.region, { ...options?.dbOptions, keyspace: definition.keyspace });
389400
return db.admin(this.#defaultOpts.adminOptions);
390401
}
391402

src/administration/astra-db-admin.ts

Lines changed: 1 addition & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,7 @@
1313
// limitations under the License.
1414
// noinspection ExceptionCaughtLocallyJS
1515

16-
import {
17-
AdminBlockingOptions,
18-
AdminSpawnOptions,
19-
CreateKeyspaceOptions,
20-
CreateNamespaceOptions,
21-
FullDatabaseInfo,
22-
} from '@/src/administration/types';
16+
import { AdminBlockingOptions, AdminSpawnOptions, CreateKeyspaceOptions, FullDatabaseInfo } from '@/src/administration/types';
2317
import { DbAdmin } from '@/src/administration/db-admin';
2418
import { WithTimeout } from '@/src/lib/types';
2519
import { InternalRootClientOpts } from '@/src/client/types';
@@ -198,18 +192,6 @@ export class AstraDbAdmin extends DbAdmin {
198192
return this.info(options).then(i => [i.info.keyspace!, ...i.info.additionalKeyspaces ?? []].filter(Boolean));
199193
}
200194

201-
/**
202-
* Lists the keyspaces in the database.
203-
*
204-
* This is now a deprecated alias for the strictly equivalent {@link AstraDbAdmin.listKeyspaces}, and will be removed
205-
* in an upcoming major version.
206-
*
207-
* @deprecated - Prefer {@link AstraDbAdmin.listKeyspaces} instead.
208-
*/
209-
public override async listNamespaces(options?: WithTimeout): Promise<string[]> {
210-
return this.listKeyspaces(options);
211-
}
212-
213195
/**
214196
* Creates a new, additional, keyspace for this database.
215197
*
@@ -257,20 +239,6 @@ export class AstraDbAdmin extends DbAdmin {
257239
});
258240
}
259241

260-
/**
261-
* Creates a new, additional, keyspace for this database.
262-
*
263-
* This is now a deprecated alias for the strictly equivalent {@link AstraDbAdmin.createKeyspace}, and will be removed
264-
* in an upcoming major version.
265-
*
266-
* https://docs.datastax.com/en/astra-db-serverless/api-reference/client-versions.html#version-1-5
267-
*
268-
* @deprecated - Prefer {@link AstraDbAdmin.createKeyspace} instead.
269-
*/
270-
public override async createNamespace(keyspace: string, options?: CreateNamespaceOptions): Promise<void> {
271-
return this.createKeyspace(keyspace, { ...options, updateDbKeyspace: options?.updateDbNamespace });
272-
}
273-
274242
/**
275243
* Drops a keyspace from this database.
276244
*
@@ -315,20 +283,6 @@ export class AstraDbAdmin extends DbAdmin {
315283
});
316284
}
317285

318-
/**
319-
Drops a keyspace from this database.
320-
*
321-
* This is now a deprecated alias for the strictly equivalent {@link AstraDbAdmin.dropKeyspace}, and will be removed
322-
* in an upcoming major version.
323-
*
324-
* https://docs.datastax.com/en/astra-db-serverless/api-reference/client-versions.html#version-1-5
325-
*
326-
* @deprecated - Prefer {@link AstraDbAdmin.dropKeyspace} instead.
327-
*/
328-
public override async dropNamespace(keyspace: string, options?: AdminBlockingOptions): Promise<void> {
329-
return this.dropKeyspace(keyspace, options);
330-
}
331-
332286
/**
333287
* Drops the database.
334288
*

src/administration/data-api-db-admin.ts

Lines changed: 1 addition & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,7 @@
1313
// limitations under the License.
1414
// noinspection ExceptionCaughtLocallyJS
1515

16-
import {
17-
AdminBlockingOptions,
18-
AdminSpawnOptions,
19-
LocalCreateKeyspaceOptions,
20-
LocalCreateNamespaceOptions,
21-
} from '@/src/administration/types';
16+
import { AdminBlockingOptions, AdminSpawnOptions, LocalCreateKeyspaceOptions } from '@/src/administration/types';
2217
import { DbAdmin } from '@/src/administration/db-admin';
2318
import { WithTimeout } from '@/src/lib/types';
2419
import { validateAdminOpts } from '@/src/administration/utils';
@@ -139,19 +134,6 @@ export class DataAPIDbAdmin extends DbAdmin {
139134
return resp.status!.keyspaces;
140135
}
141136

142-
/**
143-
* Lists the keyspaces in the database.
144-
*
145-
* This is now a deprecated alias for the strictly equivalent {@link DataAPIDbAdmin.listKeyspaces}, and will be removed
146-
* in an upcoming major version.
147-
*
148-
* @deprecated - Prefer {@link DataAPIDbAdmin.listKeyspaces} instead.
149-
*/
150-
public override async listNamespaces(options?: WithTimeout): Promise<string[]> {
151-
const resp = await this.#httpClient.executeCommand({ findNamespaces: {} }, { maxTimeMS: options?.maxTimeMS, keyspace: null });
152-
return resp.status!.namespaces;
153-
}
154-
155137
/**
156138
* Creates a new, additional, keyspace for this database.
157139
*
@@ -195,29 +177,6 @@ export class DataAPIDbAdmin extends DbAdmin {
195177
await this.#httpClient.executeCommand({ createKeyspace: { name: keyspace, options: { replication } } }, { maxTimeMS: options?.maxTimeMS, keyspace: null });
196178
}
197179

198-
/**
199-
* Creates a new, additional, keyspace for this database.
200-
*
201-
* This is now a deprecated alias for the strictly equivalent {@link DataAPIDbAdmin.createKeyspace}, and will be removed
202-
* in an upcoming major version.
203-
*
204-
* https://docs.datastax.com/en/astra-db-serverless/api-reference/client-versions.html#version-1-5
205-
*
206-
* @deprecated - Prefer {@link DataAPIDbAdmin.createKeyspace} instead.
207-
*/
208-
public override async createNamespace(keyspace: string, options?: LocalCreateNamespaceOptions): Promise<void> {
209-
if (options?.updateDbNamespace) {
210-
this.#db.useKeyspace(keyspace);
211-
}
212-
213-
const replication = options?.replication ?? {
214-
class: 'SimpleStrategy',
215-
replicationFactor: 1,
216-
};
217-
218-
await this.#httpClient.executeCommand({ createNamespace: { name: keyspace, options: { replication } } }, { maxTimeMS: options?.maxTimeMS, keyspace: null });
219-
}
220-
221180
/**
222181
* Drops a keyspace from this database.
223182
*
@@ -243,20 +202,6 @@ export class DataAPIDbAdmin extends DbAdmin {
243202
await this.#httpClient.executeCommand({ dropKeyspace: { name: keyspace } }, { maxTimeMS: options?.maxTimeMS, keyspace: null });
244203
}
245204

246-
/**
247-
Drops a keyspace from this database.
248-
*
249-
* This is now a deprecated alias for the strictly equivalent {@link DataAPIDbAdmin.dropKeyspace}, and will be removed
250-
* in an upcoming major version.
251-
*
252-
* https://docs.datastax.com/en/astra-db-serverless/api-reference/client-versions.html#version-1-5
253-
*
254-
* @deprecated - Prefer {@link DataAPIDbAdmin.dropKeyspace} instead.
255-
*/
256-
public override async dropNamespace(keyspace: string, options?: AdminBlockingOptions): Promise<void> {
257-
await this.#httpClient.executeCommand({ dropNamespace: { name: keyspace } }, { maxTimeMS: options?.maxTimeMS, keyspace: null });
258-
}
259-
260205
private get _httpClient() {
261206
return this.#httpClient;
262207
}

src/administration/db-admin.ts

Lines changed: 1 addition & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
// limitations under the License.
1414
// noinspection ExceptionCaughtLocallyJS
1515

16-
import { AdminBlockingOptions, CreateKeyspaceOptions, CreateNamespaceOptions } from '@/src/administration/types';
16+
import { AdminBlockingOptions, CreateKeyspaceOptions } from '@/src/administration/types';
1717
import { FindEmbeddingProvidersResult } from '@/src/administration/types/db-admin/find-embedding-providers';
1818
import { WithTimeout } from '@/src/lib';
1919
import { Db } from '@/src/db';
@@ -82,17 +82,6 @@ export abstract class DbAdmin {
8282
* @returns A promise that resolves to list of all the keyspaces in the database.
8383
*/
8484
abstract listKeyspaces(): Promise<string[]>;
85-
/**
86-
* Retrieves a list of all the keyspaces in the database.
87-
*
88-
* Creates a new, additional, keyspace for this database.
89-
*
90-
* This is now a deprecated alias for the strictly equivalent {@link DbAdmin.listKeyspaces}, and will be removed
91-
* in an upcoming major version.
92-
*
93-
* @deprecated - Prefer {@link DbAdmin.listKeyspaces} instead.
94-
*/
95-
abstract listNamespaces(): Promise<string[]>;
9685
/**
9786
* Creates a new, additional, keyspace for this database.
9887
*
@@ -124,17 +113,6 @@ export abstract class DbAdmin {
124113
* @returns A promise that resolves when the operation completes.
125114
*/
126115
abstract createKeyspace(keyspace: string, options?: CreateKeyspaceOptions): Promise<void>;
127-
/**
128-
* Creates a new, additional, keyspace for this database.
129-
*
130-
* This is now a deprecated alias for the strictly equivalent {@link DbAdmin.createKeyspace}, and will be removed
131-
* in an upcoming major version.
132-
*
133-
* https://docs.datastax.com/en/astra-db-serverless/api-reference/client-versions.html#version-1-5
134-
*
135-
* @deprecated - Prefer {@link DbAdmin.createKeyspace} instead.
136-
*/
137-
abstract createNamespace(keyspace: string, options?: CreateNamespaceOptions): Promise<void>;
138116
/**
139117
* Drops a keyspace from this database.
140118
*
@@ -167,15 +145,4 @@ export abstract class DbAdmin {
167145
* @returns A promise that resolves when the operation completes.
168146
*/
169147
abstract dropKeyspace(keyspace: string, options?: AdminBlockingOptions): Promise<void>;
170-
/**
171-
* Drops a keyspace from this database.
172-
*
173-
* This is now a deprecated alias for the strictly equivalent {@link DbAdmin.dropKeyspace}, and will be removed
174-
* in an upcoming major version.
175-
*
176-
* https://docs.datastax.com/en/astra-db-serverless/api-reference/client-versions.html#version-1-5
177-
*
178-
* @deprecated - Prefer {@link DbAdmin.dropKeyspace} instead.
179-
*/
180-
abstract dropNamespace(keyspace: string, options?: AdminBlockingOptions): Promise<void>;
181148
}

src/administration/types/admin/create-database.ts

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -43,17 +43,6 @@ export interface DatabaseConfig {
4343
* The default keyspace to use for the database.
4444
*/
4545
keyspace?: string,
46-
/**
47-
* The default keyspace to use for the database.
48-
*
49-
* This is now a deprecated alias for the strictly equivalent {@link DatabaseConfig.keyspace}, and will be removed
50-
* in an upcoming major version.
51-
*
52-
* https://docs.datastax.com/en/astra-db-serverless/api-reference/client-versions.html#version-1-5
53-
*
54-
* @deprecated - Prefer {@link DatabaseConfig.keyspace} instead.
55-
*/
56-
namespace?: string,
5746
}
5847

5948
/**

src/administration/types/db-admin/create-keyspace.ts

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -43,15 +43,3 @@ import { AdminBlockingOptions } from '@/src/administration/types';
4343
* @public
4444
*/
4545
export type CreateKeyspaceOptions = AdminBlockingOptions & { updateDbKeyspace?: boolean };
46-
47-
/**
48-
* Represents the common options for creating a keyspace through the `astra-db-ts` client.
49-
*
50-
* This is now a deprecated alias for the strictly equivalent {@link CreateKeyspaceOptions}, and will be removed
51-
* in an upcoming major version.
52-
*
53-
* @deprecated - Prefer {@link CreateKeyspaceOptions} instead.
54-
*
55-
* @public
56-
*/
57-
export type CreateNamespaceOptions = AdminBlockingOptions & { updateDbNamespace?: boolean };

src/administration/types/db-admin/local-create-keyspace.ts

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15-
import { CreateKeyspaceOptions, CreateNamespaceOptions } from '@/src/administration';
15+
import { CreateKeyspaceOptions } from '@/src/administration';
1616

1717
/**
1818
* Represents the options for creating a keyspace on a non-Astra database (i.e. blocking options + keyspace creation options).
@@ -44,18 +44,6 @@ import { CreateKeyspaceOptions, CreateNamespaceOptions } from '@/src/administrat
4444
*/
4545
export type LocalCreateKeyspaceOptions = CreateKeyspaceOptions & { replication?: KeyspaceReplicationOptions };
4646

47-
/**
48-
* Represents the options for creating a keyspace on a non-Astra database (i.e. blocking options + keyspace creation options).
49-
*
50-
* This is now a deprecated alias for the strictly equivalent {@link LocalCreateKeyspaceOptions}, and will be removed
51-
* in an upcoming major version.
52-
*
53-
* @deprecated - Prefer {@link LocalCreateKeyspaceOptions} instead.
54-
*
55-
* @public
56-
*/
57-
export type LocalCreateNamespaceOptions = CreateNamespaceOptions & { replication?: KeyspaceReplicationOptions };
58-
5947
/**
6048
* Represents the replication options for a keyspace.
6149
*

src/administration/types/index.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,13 +48,11 @@ export type {
4848

4949
export type {
5050
CreateKeyspaceOptions,
51-
CreateNamespaceOptions,
5251
} from './db-admin/create-keyspace';
5352

5453
export type {
5554
KeyspaceReplicationOptions,
5655
LocalCreateKeyspaceOptions,
57-
LocalCreateNamespaceOptions,
5856
} from './db-admin/local-create-keyspace';
5957

6058
export type {

0 commit comments

Comments
 (0)