Skip to content

Commit 0865044

Browse files
authored
Soft deprecation of "namespace" terminology (#71)
* added keyspace aliases in src * fixed minor namespace resolution bug * fixed a couple of bugs * namespac3 => namespace * changed namespace => keyspace in tests * updated api-extractor * updated build report * peppered deprecated namespace usages in tests * fixed a bad doc link
1 parent a5d20d0 commit 0865044

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

+1026
-638
lines changed

etc/astra-db-ts.api.md

Lines changed: 79 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -116,13 +116,19 @@ export class AstraAdmin {
116116
export class AstraDbAdmin extends DbAdmin {
117117
// @internal
118118
constructor(db: Db, rootOpts: InternalRootClientOpts, adminOpts: AdminSpawnOptions | undefined, dbToken: TokenProvider, endpoint: string);
119-
createNamespace(namespace: string, options?: CreateNamespaceOptions): Promise<void>;
119+
createKeyspace(keyspace: string, options?: CreateKeyspaceOptions): Promise<void>;
120+
// @deprecated
121+
createNamespace(keyspace: string, options?: CreateNamespaceOptions): Promise<void>;
120122
db(): Db;
121123
drop(options?: AdminBlockingOptions): Promise<void>;
122-
dropNamespace(namespace: string, options?: AdminBlockingOptions): Promise<void>;
124+
dropKeyspace(keyspace: string, options?: AdminBlockingOptions): Promise<void>;
125+
// @deprecated
126+
dropNamespace(keyspace: string, options?: AdminBlockingOptions): Promise<void>;
123127
findEmbeddingProviders(options?: WithTimeout): Promise<FindEmbeddingProvidersResult>;
124128
get id(): string;
125129
info(options?: WithTimeout): Promise<FullDatabaseInfo>;
130+
listKeyspaces(options?: WithTimeout): Promise<string[]>;
131+
// @deprecated
126132
listNamespaces(options?: WithTimeout): Promise<string[]>;
127133
}
128134

@@ -213,6 +219,8 @@ export class Collection<Schema extends SomeDoc = SomeDoc> {
213219
}): Promise<WithId<Schema> | null>;
214220
insertMany(documents: MaybeId<Schema>[], options?: InsertManyOptions): Promise<InsertManyResult<Schema>>;
215221
insertOne(document: MaybeId<Schema>, options?: InsertOneOptions): Promise<InsertOneResult<Schema>>;
222+
readonly keyspace: string;
223+
// @deprecated
216224
readonly namespace: string;
217225
options(options?: WithTimeout): Promise<CollectionOptions<SomeDoc>>;
218226
replaceOne(filter: Filter<Schema>, replacement: NoId<Schema>, options?: ReplaceOneOptions): Promise<ReplaceOneResult<Schema>>;
@@ -223,16 +231,20 @@ export class Collection<Schema extends SomeDoc = SomeDoc> {
223231
// @public
224232
export class CollectionAlreadyExistsError extends DataAPIError {
225233
// @internal
226-
constructor(namespace: string, collectionName: string);
234+
constructor(keyspace: string, collectionName: string);
227235
readonly collectionName: string;
236+
readonly keyspace: string;
237+
// @deprecated
228238
readonly namespace: string;
229239
}
230240

231241
// @public
232242
export class CollectionNotFoundError extends DataAPIError {
233243
// @internal
234-
constructor(namespace: string, collectionName: string);
244+
constructor(keyspace: string, collectionName: string);
235245
readonly collectionName: string;
246+
readonly keyspace: string;
247+
// @deprecated
236248
readonly namespace: string;
237249
}
238250

@@ -244,7 +256,7 @@ export interface CollectionOptions<Schema extends SomeDoc> {
244256
}
245257

246258
// @public
247-
export interface CollectionSpawnOptions extends WithNamespace {
259+
export interface CollectionSpawnOptions extends WithKeyspace {
248260
defaultMaxTimeMS?: number | null;
249261
embeddingApiKey?: string | EmbeddingHeadersProvider | null;
250262
}
@@ -258,6 +270,8 @@ export abstract class CommandEvent {
258270
readonly collection?: string;
259271
readonly command: Record<string, any>;
260272
readonly commandName: string;
273+
readonly keyspace: string;
274+
// @deprecated
261275
readonly namespace: string;
262276
readonly url: string;
263277
}
@@ -315,6 +329,11 @@ export type CreateDatabaseOptions = AdminBlockingOptions & {
315329
};
316330

317331
// @public
332+
export type CreateKeyspaceOptions = AdminBlockingOptions & {
333+
updateDbKeyspace?: boolean;
334+
};
335+
336+
// @public @deprecated
318337
export type CreateNamespaceOptions = AdminBlockingOptions & {
319338
updateDbNamespace?: boolean;
320339
};
@@ -386,10 +405,16 @@ export type DataAPICommandEvents = {
386405
export class DataAPIDbAdmin extends DbAdmin {
387406
// @internal
388407
constructor(db: Db, httpClient: DataAPIHttpClient, adminOpts?: AdminSpawnOptions);
389-
createNamespace(namespace: string, options?: LocalCreateNamespaceOptions): Promise<void>;
408+
createKeyspace(keyspace: string, options?: LocalCreateKeyspaceOptions): Promise<void>;
409+
// @deprecated
410+
createNamespace(keyspace: string, options?: LocalCreateNamespaceOptions): Promise<void>;
390411
db(): Db;
391-
dropNamespace(namespace: string, options?: AdminBlockingOptions): Promise<void>;
412+
dropKeyspace(keyspace: string, options?: AdminBlockingOptions): Promise<void>;
413+
// @deprecated
414+
dropNamespace(keyspace: string, options?: AdminBlockingOptions): Promise<void>;
392415
findEmbeddingProviders(options?: WithTimeout): Promise<FindEmbeddingProvidersResult>;
416+
listKeyspaces(options?: WithTimeout): Promise<string[]>;
417+
// @deprecated
393418
listNamespaces(options?: WithTimeout): Promise<string[]>;
394419
}
395420

@@ -457,7 +482,9 @@ export type DatabaseCloudProviderFilter = DatabaseCloudProvider | 'ALL';
457482
// @public
458483
export interface DatabaseConfig {
459484
cloudProvider?: DatabaseCloudProvider;
485+
keyspace?: string;
460486
name: string;
487+
// @deprecated
461488
namespace?: string;
462489
region: string;
463490
}
@@ -479,7 +506,7 @@ export interface DatabaseInfo {
479506
}
480507

481508
// @public
482-
export type DatabaseStatus = 'ACTIVE' | 'PENDING' | 'PREPARING' | 'PREPARED' | 'INITIALIZING' | 'PARKED' | 'PARKING' | 'UNPARKING' | 'TERMINATED' | 'TERMINATING' | 'RESIZING' | 'ERROR' | 'MAINTENANCE' | 'SUSPENDED' | 'UNKNOWN';
509+
export type DatabaseStatus = 'ACTIVE' | 'ERROR' | 'DECOMMISSIONING' | 'DEGRADED' | 'HIBERNATED' | 'HIBERNATING' | 'INITIALIZING' | 'MAINTENANCE' | 'PARKED' | 'PARKING' | 'PENDING' | 'PREPARED' | 'PREPARING' | 'RESIZING' | 'RESUMING' | 'TERMINATED' | 'TERMINATING' | 'UNKNOWN' | 'UNPARKING' | 'SYNCHRONIZING';
483510

484511
// @public
485512
export type DatabaseStatusFilter = DatabaseStatus | 'ALL' | 'NONTERMINATED';
@@ -539,28 +566,38 @@ export class Db {
539566
environment: Exclude<DataAPIEnvironment, 'astra'>;
540567
}): DataAPIDbAdmin;
541568
collection<Schema extends SomeDoc = SomeDoc>(name: string, options?: CollectionSpawnOptions): Collection<Schema>;
542-
collections(options?: WithNamespace & WithTimeout): Promise<Collection[]>;
569+
collections(options?: WithKeyspace & WithTimeout): Promise<Collection[]>;
543570
command(command: Record<string, any>, options?: RunCommandOptions): Promise<RawDataAPIResponse>;
544571
createCollection<Schema extends SomeDoc = SomeDoc>(collectionName: string, options?: CreateCollectionOptions<Schema>): Promise<Collection<Schema>>;
545572
dropCollection(name: string, options?: DropCollectionOptions): Promise<boolean>;
546573
get id(): string;
547574
info(options?: WithTimeout): Promise<DatabaseInfo>;
575+
get keyspace(): string;
548576
listCollections(options: ListCollectionsOptions & {
549577
nameOnly: true;
550578
}): Promise<string[]>;
551579
listCollections(options?: ListCollectionsOptions & {
552580
nameOnly?: false;
553581
}): Promise<FullCollectionInfo[]>;
582+
// @deprecated
554583
get namespace(): string;
555-
useNamespace(namespace: string): void;
584+
useKeyspace(keyspace: string): void;
585+
// @deprecated
586+
useNamespace(keyspace: string): void;
556587
}
557588

558589
// @public
559590
export abstract class DbAdmin {
560-
abstract createNamespace(namespace: string, options?: CreateNamespaceOptions): Promise<void>;
591+
abstract createKeyspace(keyspace: string, options?: CreateKeyspaceOptions): Promise<void>;
592+
// @deprecated
593+
abstract createNamespace(keyspace: string, options?: CreateNamespaceOptions): Promise<void>;
561594
abstract db(): Db;
562-
abstract dropNamespace(namespace: string, options?: AdminBlockingOptions): Promise<void>;
595+
abstract dropKeyspace(keyspace: string, options?: AdminBlockingOptions): Promise<void>;
596+
// @deprecated
597+
abstract dropNamespace(keyspace: string, options?: AdminBlockingOptions): Promise<void>;
563598
abstract findEmbeddingProviders(options?: WithTimeout): Promise<FindEmbeddingProvidersResult>;
599+
abstract listKeyspaces(): Promise<string[]>;
600+
// @deprecated
564601
abstract listNamespaces(): Promise<string[]>;
565602
}
566603

@@ -575,7 +612,9 @@ export interface DbMetricsInfo {
575612
// @public
576613
export interface DbSpawnOptions {
577614
dataApiPath?: string;
615+
keyspace?: string;
578616
monitorCommands?: boolean;
617+
// @deprecated
579618
namespace?: string;
580619
token?: string | TokenProvider | null;
581620
}
@@ -665,7 +704,7 @@ export class DevOpsUnexpectedStateError extends DevOpsAPIError {
665704
}
666705

667706
// @public
668-
export interface DropCollectionOptions extends WithTimeout, WithNamespace {
707+
export interface DropCollectionOptions extends WithTimeout, WithKeyspace {
669708
}
670709

671710
// @public
@@ -797,7 +836,7 @@ export type FilterOps<Elem> = {
797836
export class FindCursor<T, TRaw extends SomeDoc = SomeDoc> {
798837
[Symbol.asyncIterator](): AsyncGenerator<T, void, void>;
799838
// @internal
800-
constructor(namespace: string, httpClient: DataAPIHttpClient, filter: Filter<SomeDoc>, options?: FindOptions);
839+
constructor(keyspace: string, httpClient: DataAPIHttpClient, filter: Filter<SomeDoc>, options?: FindOptions);
801840
bufferedCount(): number;
802841
clone(): FindCursor<TRaw, TRaw>;
803842
close(): void;
@@ -809,8 +848,10 @@ export class FindCursor<T, TRaw extends SomeDoc = SomeDoc> {
809848
hasNext(): Promise<boolean>;
810849
includeSimilarity(includeSimilarity?: boolean): this;
811850
includeSortVector(includeSortVector?: boolean): this;
851+
get keyspace(): string;
812852
limit(limit: number): this;
813853
map<R>(mapping: (doc: T) => R): FindCursor<R, TRaw>;
854+
// @deprecated
814855
get namespace(): string;
815856
next(): Promise<T | null>;
816857
project<R = any, RRaw extends SomeDoc = SomeDoc>(projection: Projection): FindCursor<R, RRaw>;
@@ -954,17 +995,8 @@ export type IndexingOptions<Schema extends SomeDoc> = {
954995
allow?: never;
955996
};
956997

957-
// @public
958-
export interface InsertManyDocumentResponse<Schema extends SomeDoc> {
959-
error?: DataAPIErrorDescriptor;
960-
_id: IdOf<Schema>;
961-
status: 'OK' | 'ERROR' | 'SKIPPED';
962-
}
963-
964998
// @public
965999
export class InsertManyError extends CumulativeDataAPIError {
966-
readonly documentResponses: InsertManyDocumentResponse<SomeDoc>[];
967-
readonly failedCount: number;
9681000
name: string;
9691001
readonly partialResult: InsertManyResult<SomeDoc>;
9701002
}
@@ -1021,7 +1053,16 @@ export interface InsertOneResult<Schema> {
10211053
export type InternalUpdateResult<Schema extends SomeDoc, N extends number> = (GuaranteedUpdateOptions<N> & UpsertedUpdateOptions<Schema>) | (GuaranteedUpdateOptions<N> & NoUpsertUpdateOptions);
10221054

10231055
// @public
1024-
export interface ListCollectionsOptions extends WithTimeout, WithNamespace {
1056+
export type KeyspaceReplicationOptions = {
1057+
class: 'SimpleStrategy';
1058+
replicationFactor: number;
1059+
} | {
1060+
class: 'NetworkTopologyStrategy';
1061+
[datacenter: string]: number | 'NetworkTopologyStrategy';
1062+
};
1063+
1064+
// @public
1065+
export interface ListCollectionsOptions extends WithTimeout, WithKeyspace {
10251066
nameOnly?: boolean;
10261067
}
10271068

@@ -1034,8 +1075,13 @@ export interface ListDatabasesOptions extends WithTimeout {
10341075
}
10351076

10361077
// @public
1078+
export type LocalCreateKeyspaceOptions = CreateKeyspaceOptions & {
1079+
replication?: KeyspaceReplicationOptions;
1080+
};
1081+
1082+
// @public @deprecated
10371083
export type LocalCreateNamespaceOptions = CreateNamespaceOptions & {
1038-
replication?: NamespaceReplicationOptions;
1084+
replication?: KeyspaceReplicationOptions;
10391085
};
10401086

10411087
// @public
@@ -1049,15 +1095,6 @@ export interface ModifyResult<Schema extends SomeDoc> {
10491095
value: WithId<Schema> | null;
10501096
}
10511097

1052-
// @public
1053-
export type NamespaceReplicationOptions = {
1054-
class: 'SimpleStrategy';
1055-
replicationFactor: number;
1056-
} | {
1057-
class: 'NetworkTopologyStrategy';
1058-
[datacenter: string]: number | 'NetworkTopologyStrategy';
1059-
};
1060-
10611098
// @public
10621099
export interface NoBlockingOptions extends WithTimeout {
10631100
blocking: false;
@@ -1157,6 +1194,8 @@ export type ReplaceOneResult<Schema extends SomeDoc> = InternalUpdateResult<Sche
11571194
// @public
11581195
export interface RunCommandOptions extends WithTimeout {
11591196
collection?: string;
1197+
keyspace?: string | null;
1198+
// @deprecated
11601199
namespace?: string | null;
11611200
}
11621201

@@ -1408,10 +1447,15 @@ export type WithId<T> = NoId<T> & {
14081447
};
14091448

14101449
// @public
1411-
export interface WithNamespace {
1450+
export interface WithKeyspace {
1451+
keyspace?: string;
1452+
// @deprecated
14121453
namespace?: string;
14131454
}
14141455

1456+
// @public @deprecated
1457+
export type WithNamespace = WithKeyspace;
1458+
14151459
// @public
14161460
export interface WithTimeout {
14171461
maxTimeMS?: number;

0 commit comments

Comments
 (0)