Skip to content

Commit

Permalink
Minor changes for the 1.2.1 releases (#46)
Browse files Browse the repository at this point in the history
* minor doc updates

* added forgotten export + minor devguide update

* update build report

* fixed a couple of tests
  • Loading branch information
toptobes authored May 31, 2024
1 parent 5ef710a commit ca7c18c
Show file tree
Hide file tree
Showing 8 changed files with 38 additions and 27 deletions.
4 changes: 2 additions & 2 deletions DEVGUIDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
## Running the tests
Prerequisites:
- A JS package manager (npm, bun, etc.)
- A clean Astra instance with two keyspaces—`default_keyspace` and `other_keyspace`
- A clean AstraDB instance with two keyspaces—`default_keyspace` and `other_keyspace`
- Copy the `.env.example` file and create a new `.env` file following the example template

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

## Publishing
I heavily recommend using [np](https://github.com/sindresorhus/np) to publish the package. Running it will involve running `test:all`, and the
I heavily recommend using [np](https://github.com/sindresorhus/np) to publish the package. Running it will involve running `test:prerelease`, and the
versioning step will update the api report + update the version in `src/version.ts`.
11 changes: 8 additions & 3 deletions etc/astra-db-ts.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,13 @@ export class CursorIsStartedError extends DataAPIError {
constructor(message: string);
}

// @public
export interface CustomHttpClientOptions {
client: 'custom';
fetcher: Fetcher;
maxTimeMS?: number;
}

// @public
export class DataAPIClient extends DataAPIClientEventEmitterBase {
[Symbol.asyncDispose]: () => Promise<void>;
Expand Down Expand Up @@ -374,8 +381,6 @@ export interface DataAPIErrorDescriptor {
readonly message?: string;
}

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

Expand Down Expand Up @@ -638,7 +643,7 @@ export interface FetcherRequestInfo {
export interface FetcherResponseInfo {
additionalAttributes?: Record<string, any>;
body?: string;
headers: Record<string, any>;
headers: Record<string, string>;
httpVersion: 1 | 2;
status: number;
statusText: string;
Expand Down
2 changes: 1 addition & 1 deletion src/api/fetch/fetch-h2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export class FetchH2 implements Fetcher {
maxSockets: options?.http1?.maxSockets,
maxFreeSockets: options?.http1?.maxFreeSockets,
},
httpsProtocols: <const>['http1'],
httpsProtocols: ['http1'],
});

this._preferred = (preferHttp2)
Expand Down
8 changes: 5 additions & 3 deletions src/api/fetch/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ export interface FetcherRequestInfo {
}

/**
* Response object from an API call.
* Response object from an API call made by a {@link Fetcher}.
*
* @public
*/
Expand All @@ -89,7 +89,7 @@ export interface FetcherResponseInfo {
/**
* The headers of the response.
*/
headers: Record<string, any>,
headers: Record<string, string>,
/**
* The HTTP status code of the response.
*/
Expand All @@ -106,8 +106,10 @@ export interface FetcherResponseInfo {
* The status text for the response.
*/
statusText: string,
/**
/**
* Any additional attributes that may be included in the response (for use w/ custom {@link Fetcher} implementations).
*
* This is mainly for any potential logging or debugging information that may be useful for the user.
*/
additionalAttributes?: Record<string, any>,
}
Expand Down
24 changes: 12 additions & 12 deletions src/client/data-api-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,7 @@ function getDeprecatedPrefersHttp2(opts: DataAPIClientOptions | undefined | null
}

function validateRootOpts(opts: DataAPIClientOptions | undefined | null) {
validateOption('root client options', opts, 'object');
validateOption('DataAPIClientOptions', opts, 'object');

if (!opts) {
return;
Expand All @@ -348,32 +348,32 @@ function validateRootOpts(opts: DataAPIClientOptions | undefined | null) {
}

function validateHttpOpts(opts: DataAPIHttpOptions | undefined | null) {
validateOption('http options', opts, 'object');
validateOption('httpOptions', opts, 'object');

if (!opts) {
return;
}

validateOption('client option', opts.client, 'string', false, (client) => {
validateOption('httpOptions.client', opts.client, 'string', false, (client) => {
if (client !== 'fetch' && client !== 'default' && client !== 'custom') {
throw new Error('Invalid httpOptions.client; expected \'fetch\' or \'default\'');
throw new Error('Invalid httpOptions.client; expected \'fetch\', \'default\', \'custom\', or undefined');
}
});
validateOption('maxTimeMS option', opts.maxTimeMS, 'number');
validateOption('httpOptions.maxTimeMS', opts.maxTimeMS, 'number');

if (opts.client === 'default' || opts.client === undefined) {
validateOption('preferHttp2 option', opts.preferHttp2, 'boolean');
validateOption('httpOptions.preferHttp2', opts.preferHttp2, 'boolean');

validateOption('http1 options', opts.http1, 'object', false, (http1) => {
validateOption('http1.keepAlive option', http1.keepAlive, 'boolean');
validateOption('http1.keepAliveMS option', http1.keepAliveMS, 'number');
validateOption('http1.maxSockets option', http1.maxSockets, 'number');
validateOption('http1.maxFreeSockets option', http1.maxFreeSockets, 'number');
validateOption('httpOptions.http1 options', opts.http1, 'object', false, (http1) => {
validateOption('http1.keepAlive', http1.keepAlive, 'boolean');
validateOption('http1.keepAliveMS', http1.keepAliveMS, 'number');
validateOption('http1.maxSockets', http1.maxSockets, 'number');
validateOption('http1.maxFreeSockets', http1.maxFreeSockets, 'number');
});
}

if (opts.client === 'custom') {
validateOption('fetcher option', opts.fetcher, 'object', true, (fetcher) => {
validateOption('httpOptions.fetcher option', opts.fetcher, 'object', true, (fetcher) => {
validateOption('fetcher.fetch option', fetcher.fetch, 'function', true);
validateOption('fetcher.close option', fetcher.close, 'function');
});
Expand Down
1 change: 1 addition & 0 deletions src/client/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,5 @@ export {
Http1Options,
DataAPIHttpOptions,
FetchHttpClientOptions,
CustomHttpClientOptions,
} from './types';
12 changes: 7 additions & 5 deletions tests/integration/data-api/vectorize.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ describe('integration.data-api.vectorize', () => {
createVectorizeProvidersTest(db, test, name)

if (i === 0) {
createVectorizeParamTests(db, name);
createVectorizeParamTests(db, test, name);
}

after(async () => {
Expand Down Expand Up @@ -121,15 +121,17 @@ async function initVectorTests() {
});
}

function createVectorizeParamTests(db: Db, name: string) {
function createVectorizeParamTests(db: Db, test: VectorizeTest, name: string) {
describe('[vectorize] [dev] $vectorize/vectorize params', () => {
const collection = db.collection(name);
const collection = db.collection(name, {
embeddingApiKey: test.header,
});

before(async function () {
if (!await db.listCollections({ nameOnly: true }).then(cs => cs.every((c) => c !== name))) {
if (!await db.listCollections({ nameOnly: true }).then(cs => cs.some((c) => c === name))) {
this.skip();
}
})
});

beforeEach(async () => {
await collection.deleteAll();
Expand Down
3 changes: 2 additions & 1 deletion tests/integration/devops/lifecycle.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,8 @@ describe('integration.devops.lifecycle', async () => {
assert.strictEqual(dbInfo1.info.keyspace, 'my_namespace');

const dbInfo2 = await admin.dbInfo(asyncDb.id);
assert.deepStrictEqual(dbInfo1.info, dbInfo2.info);
assert.deepStrictEqual(dbInfo1.info.name, dbInfo2.info.name);
assert.deepStrictEqual(dbInfo1.info.keyspaces, dbInfo2.info.keyspaces);
assert.ok(['PENDING', 'INITIALIZING'].includes(dbInfo2.status));
}

Expand Down

0 comments on commit ca7c18c

Please sign in to comment.