datastax / astra-db-ts

Typescript client for Astra DB Vector
https://npmjs.com/@datastax/astra-db-ts
Apache License 2.0
13 stars 6 forks source link

Cleanup #17

Closed toptobes closed 6 months ago

toptobes commented 6 months ago

Most likely missed a couple of things (or glossed over minor things), but this is most of it

Removed all traces of Stargate (except for some names)

Changed authHeaderName to just be a constant (or env variable)

Some formatting/linting fixes

Updated axios dependency

Made httpClient accept an optional collectionName to add to the URL to fix the weird URL issues once and ∀

Added my (Kavin's) name to package.json contributors

Tests

[!note] Frankly, I think some of these tests may be unnecessary (or a bit too strict!) as they're testing the API more than the client

Added applicationToken in client options using process.env.APPLICATION_TOKEN so tests could properly authenticate w/ Astra

Set TEST_COLLECTION_NAME to default_keyspace

Removed a handful of tests related to Stargate

Should fail if the number of levels in the doc is > 8

Should fail if the string field value is > 16000

Should fail if the field length is > 48

Should fail if an array field size is > 100

Should fail if a doc contains more than 64 properties

Should fail if the string field value is > 16000

Should fail if a doc contains more than 2000 properties

I think one or two more I forgot

// collections.collection:updateOne:should upsert a doc with upsert flag true in updateOne call
// collections.collection:updateOne:should make _id an ObjectId when upserting with no _id
// collections.collection:updateMany:should upsert with upsert flag set to true when not found
// collections.collection:updateMany:should make _id an ObjectId when upserting with no _id
// collections.collection:findOneAndUpdate:should make _id an ObjectId when upserting with no _id
// collections.collection:deleteMany:findOneAndReplace should make _id an ObjectId when upserting with no _id
// Error: Command "..." failed with the following errors: 
[{"message":"Bad value for '_id' property: empty String not allowed","errorCode":"SHRED_BAD_DOCID_EMPTY_STRING"}]

// Looks like 'setDefaultIdForUpsert' is being called, but the function isn't actually setting a default value

Unfixed fails:

// collections.collection:findOne, findMany & filter:should find & find doc $size 0 test
// Expected values to be strictly equal: 19 !== 1
assert.strictEqual(findRespDocs.length, 1);

// I'm not really sure why it's failing—it looks like the command is being sent correctly??
// '{"find":{"filter":{"tags":{"$size":0}}}}'
// And only one of those docs has an empty array for "tags" as well
// Therefore, I hae no clue why every doc is being returned