Skip to content

Commit ca7c18c

Browse files
authored
Minor changes for the 1.2.1 releases (#46)
* minor doc updates * added forgotten export + minor devguide update * update build report * fixed a couple of tests
1 parent 5ef710a commit ca7c18c

File tree

8 files changed

+38
-27
lines changed

8 files changed

+38
-27
lines changed

DEVGUIDE.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
## Running the tests
88
Prerequisites:
99
- A JS package manager (npm, bun, etc.)
10-
- A clean Astra instance with two keyspaces—`default_keyspace` and `other_keyspace`
10+
- A clean AstraDB instance with two keyspaces—`default_keyspace` and `other_keyspace`
1111
- Copy the `.env.example` file and create a new `.env` file following the example template
1212

1313
```shell
@@ -124,5 +124,5 @@ To build it, just run `npm run build`, which does the following:
124124
- Deletes any extraneous `.d.ts` files
125125

126126
## Publishing
127-
I heavily recommend using [np](https://github.com/sindresorhus/np) to publish the package. Running it will involve running `test:all`, and the
127+
I heavily recommend using [np](https://github.com/sindresorhus/np) to publish the package. Running it will involve running `test:prerelease`, and the
128128
versioning step will update the api report + update the version in `src/version.ts`.

etc/astra-db-ts.api.md

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -323,6 +323,13 @@ export class CursorIsStartedError extends DataAPIError {
323323
constructor(message: string);
324324
}
325325

326+
// @public
327+
export interface CustomHttpClientOptions {
328+
client: 'custom';
329+
fetcher: Fetcher;
330+
maxTimeMS?: number;
331+
}
332+
326333
// @public
327334
export class DataAPIClient extends DataAPIClientEventEmitterBase {
328335
[Symbol.asyncDispose]: () => Promise<void>;
@@ -374,8 +381,6 @@ export interface DataAPIErrorDescriptor {
374381
readonly message?: string;
375382
}
376383

377-
// Warning: (ae-forgotten-export) The symbol "CustomHttpClientOptions" needs to be exported by the entry point index.d.ts
378-
//
379384
// @public
380385
export type DataAPIHttpOptions = DefaultHttpClientOptions | FetchHttpClientOptions | CustomHttpClientOptions;
381386

@@ -638,7 +643,7 @@ export interface FetcherRequestInfo {
638643
export interface FetcherResponseInfo {
639644
additionalAttributes?: Record<string, any>;
640645
body?: string;
641-
headers: Record<string, any>;
646+
headers: Record<string, string>;
642647
httpVersion: 1 | 2;
643648
status: number;
644649
statusText: string;

src/api/fetch/fetch-h2.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ export class FetchH2 implements Fetcher {
3737
maxSockets: options?.http1?.maxSockets,
3838
maxFreeSockets: options?.http1?.maxFreeSockets,
3939
},
40-
httpsProtocols: <const>['http1'],
40+
httpsProtocols: ['http1'],
4141
});
4242

4343
this._preferred = (preferHttp2)

src/api/fetch/types.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ export interface FetcherRequestInfo {
7777
}
7878

7979
/**
80-
* Response object from an API call.
80+
* Response object from an API call made by a {@link Fetcher}.
8181
*
8282
* @public
8383
*/
@@ -89,7 +89,7 @@ export interface FetcherResponseInfo {
8989
/**
9090
* The headers of the response.
9191
*/
92-
headers: Record<string, any>,
92+
headers: Record<string, string>,
9393
/**
9494
* The HTTP status code of the response.
9595
*/
@@ -106,8 +106,10 @@ export interface FetcherResponseInfo {
106106
* The status text for the response.
107107
*/
108108
statusText: string,
109-
/**
109+
/**
110110
* Any additional attributes that may be included in the response (for use w/ custom {@link Fetcher} implementations).
111+
*
112+
* This is mainly for any potential logging or debugging information that may be useful for the user.
111113
*/
112114
additionalAttributes?: Record<string, any>,
113115
}

src/client/data-api-client.ts

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -333,7 +333,7 @@ function getDeprecatedPrefersHttp2(opts: DataAPIClientOptions | undefined | null
333333
}
334334

335335
function validateRootOpts(opts: DataAPIClientOptions | undefined | null) {
336-
validateOption('root client options', opts, 'object');
336+
validateOption('DataAPIClientOptions', opts, 'object');
337337

338338
if (!opts) {
339339
return;
@@ -348,32 +348,32 @@ function validateRootOpts(opts: DataAPIClientOptions | undefined | null) {
348348
}
349349

350350
function validateHttpOpts(opts: DataAPIHttpOptions | undefined | null) {
351-
validateOption('http options', opts, 'object');
351+
validateOption('httpOptions', opts, 'object');
352352

353353
if (!opts) {
354354
return;
355355
}
356356

357-
validateOption('client option', opts.client, 'string', false, (client) => {
357+
validateOption('httpOptions.client', opts.client, 'string', false, (client) => {
358358
if (client !== 'fetch' && client !== 'default' && client !== 'custom') {
359-
throw new Error('Invalid httpOptions.client; expected \'fetch\' or \'default\'');
359+
throw new Error('Invalid httpOptions.client; expected \'fetch\', \'default\', \'custom\', or undefined');
360360
}
361361
});
362-
validateOption('maxTimeMS option', opts.maxTimeMS, 'number');
362+
validateOption('httpOptions.maxTimeMS', opts.maxTimeMS, 'number');
363363

364364
if (opts.client === 'default' || opts.client === undefined) {
365-
validateOption('preferHttp2 option', opts.preferHttp2, 'boolean');
365+
validateOption('httpOptions.preferHttp2', opts.preferHttp2, 'boolean');
366366

367-
validateOption('http1 options', opts.http1, 'object', false, (http1) => {
368-
validateOption('http1.keepAlive option', http1.keepAlive, 'boolean');
369-
validateOption('http1.keepAliveMS option', http1.keepAliveMS, 'number');
370-
validateOption('http1.maxSockets option', http1.maxSockets, 'number');
371-
validateOption('http1.maxFreeSockets option', http1.maxFreeSockets, 'number');
367+
validateOption('httpOptions.http1 options', opts.http1, 'object', false, (http1) => {
368+
validateOption('http1.keepAlive', http1.keepAlive, 'boolean');
369+
validateOption('http1.keepAliveMS', http1.keepAliveMS, 'number');
370+
validateOption('http1.maxSockets', http1.maxSockets, 'number');
371+
validateOption('http1.maxFreeSockets', http1.maxFreeSockets, 'number');
372372
});
373373
}
374374

375375
if (opts.client === 'custom') {
376-
validateOption('fetcher option', opts.fetcher, 'object', true, (fetcher) => {
376+
validateOption('httpOptions.fetcher option', opts.fetcher, 'object', true, (fetcher) => {
377377
validateOption('fetcher.fetch option', fetcher.fetch, 'function', true);
378378
validateOption('fetcher.close option', fetcher.close, 'function');
379379
});

src/client/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,5 @@ export {
2424
Http1Options,
2525
DataAPIHttpOptions,
2626
FetchHttpClientOptions,
27+
CustomHttpClientOptions,
2728
} from './types';

tests/integration/data-api/vectorize.test.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ describe('integration.data-api.vectorize', () => {
5959
createVectorizeProvidersTest(db, test, name)
6060

6161
if (i === 0) {
62-
createVectorizeParamTests(db, name);
62+
createVectorizeParamTests(db, test, name);
6363
}
6464

6565
after(async () => {
@@ -121,15 +121,17 @@ async function initVectorTests() {
121121
});
122122
}
123123

124-
function createVectorizeParamTests(db: Db, name: string) {
124+
function createVectorizeParamTests(db: Db, test: VectorizeTest, name: string) {
125125
describe('[vectorize] [dev] $vectorize/vectorize params', () => {
126-
const collection = db.collection(name);
126+
const collection = db.collection(name, {
127+
embeddingApiKey: test.header,
128+
});
127129

128130
before(async function () {
129-
if (!await db.listCollections({ nameOnly: true }).then(cs => cs.every((c) => c !== name))) {
131+
if (!await db.listCollections({ nameOnly: true }).then(cs => cs.some((c) => c === name))) {
130132
this.skip();
131133
}
132-
})
134+
});
133135

134136
beforeEach(async () => {
135137
await collection.deleteAll();

tests/integration/devops/lifecycle.test.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,8 @@ describe('integration.devops.lifecycle', async () => {
6464
assert.strictEqual(dbInfo1.info.keyspace, 'my_namespace');
6565

6666
const dbInfo2 = await admin.dbInfo(asyncDb.id);
67-
assert.deepStrictEqual(dbInfo1.info, dbInfo2.info);
67+
assert.deepStrictEqual(dbInfo1.info.name, dbInfo2.info.name);
68+
assert.deepStrictEqual(dbInfo1.info.keyspaces, dbInfo2.info.keyspaces);
6869
assert.ok(['PENDING', 'INITIALIZING'].includes(dbInfo2.status));
6970
}
7071

0 commit comments

Comments
 (0)