Skip to content

Commit 2f46262

Browse files
authored
Misc 1.4.1 improvements (#68)
* made returnDocument optional * permanent hack, do not revert * made updateDbNamespace (somewhat) immedietly set * vectorize tests warmupErr option * minor linting fix * refactoring of vectorize tests * updated devguide slightly * I think now it works * Fixed some shit * Fixed so the code compiles * SHIT ===> GOLD * just trolling the repo * nix + direnv support * changed flake to shell.nix (flake is overkill atm) * add scripts to path via direnv * organized the scripts dir a bit * LUKASZ SUCKS * ci test * update to devguide to cover nix-shell + direnv support * Errare humanum est. * slghtly updated tsdoc for findOneAnd* returnDocument commands since it is now optional * It's secret! * freemasonry * lol digg
1 parent 10362d8 commit 2f46262

39 files changed

+645
-474
lines changed

.envrc

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# shellcheck shell=bash
2+
if ! has nix_direnv_version || ! nix_direnv_version 3.0.5; then
3+
source_url "https://raw.githubusercontent.com/nix-community/nix-direnv/3.0.5/direnvrc" "sha256-RuwIS+QKFj/T9M2TFXScjBsLR6V3A17YVoEW/Q6AZ1w="
4+
fi
5+
6+
if nix --version &> /dev/null; then
7+
use nix
8+
fi
9+
10+
PATH_add scripts
11+
12+
dotenv_if_exists

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,3 +139,5 @@ tsdoc-metadata.json
139139

140140
vectorize_test_spec.json
141141
etc/test-reports/
142+
143+
.direnv

DEVGUIDE.md

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# DEVGUIDE.md
22

3-
## Contents
3+
## Contents
44
1. [Running the tests](#running-the-tests)
55
1. [Prerequisites](#prerequisites)
66
2. [I can't be bothered to read all of this](#i-cant-be-bothered-to-read-all-of-this)
@@ -12,6 +12,8 @@
1212
2. [Typechecking & Linting](#typechecking--linting)
1313
3. [Building the library](#building-the-library)
1414
4. [Publishing](#publishing)
15+
5. [Miscellaneous](#miscellaneous)
16+
1. [nix-shell + direnv support](#nix-shell--direnv-support)
1517

1618
## Running the tests
1719

@@ -198,6 +200,7 @@ type VectorizeTestSpec = {
198200
parameters?: {
199201
[modelNameRegex: string]: Record<string, string>,
200202
},
203+
warmupErr?: string,
201204
},
202205
}
203206
```
@@ -215,6 +218,8 @@ where:
215218
- optional if not required. `azureOpenAI`, for example, will need this.
216219
- `dimension` is also a mapping of model name regex to their corresponding dimensions, like the `parameters` field.
217220
- optional if not required. `huggingfaceDedicated`, for example, will need this.
221+
- `warmupErr` may be set if the provider errors on a cold start
222+
- if set, the provider will be called in a `while (true)` loop until it stops throwing an error matching this message
218223
219224
This file is .gitignore-d by default and will not be checked into VCS.
220225
@@ -321,3 +326,15 @@ continue on to publish the package using `np --no-tests`.
321326

322327
The versioning step will automatically update the api report + update the version in `src/version.ts`, so you don't
323328
need to worry about that.
329+
330+
## Miscellaneous
331+
332+
### nix-shell + direnv support
333+
334+
This is in no way required, but just for convenience purposes, a `.envrc` file is present that will
335+
- If you have nix, use the `shell.nix` to drop you into a nix-shell w/ `nodejs_20` & `jq`
336+
- Ephemerally add the `scripts/` dir to `PATH`
337+
- Ephemerally source `.env` into your shell
338+
339+
In case you have `direnv` installed, but don't want to use this, you can of course simply do `direnv block` and never
340+
worry about any of this ever again.

etc/astra-db-ts.api.md

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ export class AstraAdmin {
115115
// @public
116116
export class AstraDbAdmin extends DbAdmin {
117117
// @internal
118-
constructor(db: Db, rootOpts: InternalRootClientOpts, adminOpts: AdminSpawnOptions | undefined, dbToken: TokenProvider);
118+
constructor(db: Db, rootOpts: InternalRootClientOpts, adminOpts: AdminSpawnOptions | undefined, dbToken: TokenProvider, endpoint: string);
119119
createNamespace(namespace: string, options?: CreateNamespaceOptions): Promise<void>;
120120
db(): Db;
121121
drop(options?: AdminBlockingOptions): Promise<void>;
@@ -186,7 +186,7 @@ export class Collection<Schema extends SomeDoc = SomeDoc> {
186186
countDocuments(filter: Filter<Schema>, upperBound: number, options?: WithTimeout): Promise<number>;
187187
// @deprecated
188188
deleteAll(options?: WithTimeout): Promise<void>;
189-
deleteMany(filter?: Filter<Schema>, options?: WithTimeout): Promise<DeleteManyResult>;
189+
deleteMany(filter: Filter<Schema>, options?: WithTimeout): Promise<DeleteManyResult>;
190190
deleteOne(filter?: Filter<Schema>, options?: DeleteOneOptions): Promise<DeleteOneResult>;
191191
distinct<Key extends string>(key: Key, filter?: Filter<Schema>): Promise<Flatten<(SomeDoc & ToDotNotation<FoundDoc<Schema>>)[Key]>[]>;
192192
drop(options?: WithTimeout): Promise<boolean>;
@@ -841,7 +841,7 @@ export interface FindOneAndDeleteOptions extends WithTimeout {
841841
export interface FindOneAndReplaceOptions extends WithTimeout {
842842
includeResultMetadata?: boolean;
843843
projection?: Projection;
844-
returnDocument: 'before' | 'after';
844+
returnDocument?: 'before' | 'after';
845845
sort?: Sort;
846846
upsert?: boolean;
847847
// @deprecated
@@ -854,7 +854,7 @@ export interface FindOneAndReplaceOptions extends WithTimeout {
854854
export interface FindOneAndUpdateOptions extends WithTimeout {
855855
includeResultMetadata?: boolean;
856856
projection?: Projection;
857-
returnDocument: 'before' | 'after';
857+
returnDocument?: 'before' | 'after';
858858
sort?: Sort;
859859
upsert?: boolean;
860860
// @deprecated
@@ -954,8 +954,17 @@ export type IndexingOptions<Schema extends SomeDoc> = {
954954
allow?: never;
955955
};
956956

957+
// @public
958+
export interface InsertManyDocumentResponse<Schema extends SomeDoc> {
959+
error?: DataAPIErrorDescriptor;
960+
_id: IdOf<Schema>;
961+
status: 'OK' | 'ERROR' | 'SKIPPED';
962+
}
963+
957964
// @public
958965
export class InsertManyError extends CumulativeDataAPIError {
966+
readonly documentResponses: InsertManyDocumentResponse<SomeDoc>[];
967+
readonly failedCount: number;
959968
name: string;
960969
readonly partialResult: InsertManyResult<SomeDoc>;
961970
}

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
"lint": "eslint src/* tests/*",
4646
"test": "sh scripts/test.sh",
4747
"build": "sh scripts/build.sh",
48-
"version": "sh scripts/version.sh"
48+
"version": "sh scripts/utils/version.sh"
4949
},
5050
"bugs": {
5151
"url": "https://github.com/datastax/astra-ts-client/issues"

scripts/build.sh

100644100755
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
rm -rf ./dist
55

66
# Creates the version file
7-
node scripts/build-version-file.js > src/version.ts
7+
node scripts/utils/build-version-file.js > src/version.ts
88

99
# Transpiles the project
1010
npx tsc --project tsconfig.build.json
@@ -16,13 +16,13 @@ npx tsc-alias -p tsconfig.build.json
1616
npx api-extractor run -c ./api-extractor.jsonc --local && rm -r ./temp
1717

1818
# Uses a more succinct licence notice + removes block comments (the rollup .d.ts file already contains the ts-doc)
19-
find ./dist -type f -name '*.js' -exec node scripts/reduce-comments.js {} \;
19+
find ./dist -type f -name '*.js' -exec node scripts/utils/reduce-comments.js {} \;
2020

2121
# Adds the missing license notice to the rollup .d.ts
22-
node scripts/add-license-bumf.js dist/astra-db-ts.d.ts
22+
node scripts/utils/add-license-bumf.js dist/astra-db-ts.d.ts
2323

2424
# Delete the "empty" files where only types were declared
25-
node scripts/del-empty-dist-files.js
25+
node scripts/utils/del-empty-dist-files.js
2626

2727
# Removes all .d.ts files except the main rollup .d.ts
2828
cd dist || return 1

scripts/start-stargate-4-tests.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@ echo "CLIENT_DB_TOKEN=Cassandra:Y2Fzc2FuZHJh:Y2Fzc2FuZHJh"
66
echo "CLIENT_DB_ENVIRONMENT=dse"
77
echo
88

9-
docker-compose -f scripts/docker-compose-stargate.yml up
9+
docker-compose -f scripts/utils/docker-compose-stargate.yml up
File renamed without changes.

scripts/build-version-file.js renamed to scripts/utils/build-version-file.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,5 @@ console.log([
1414
`// limitations under the License.`,
1515
``,
1616
`export const LIB_NAME = 'astra-db-ts';`,
17-
`export const LIB_VERSION = '${require('../package.json').version}';`,
17+
`export const LIB_VERSION = '${require('../../package.json').version}';`,
1818
].join('\n'));

0 commit comments

Comments
 (0)