diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 763462f..43fd5a7 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -9,9 +9,7 @@ "postCreateCommand": "yarn install", "customizations": { "vscode": { - "extensions": [ - "esbenp.prettier-vscode" - ] + "extensions": ["esbenp.prettier-vscode"] } } } diff --git a/.gitignore b/.gitignore index d98d51a..2412bb7 100644 --- a/.gitignore +++ b/.gitignore @@ -7,4 +7,5 @@ dist dist-deno /*.tgz .idea/ +.eslintcache diff --git a/.release-please-manifest.json b/.release-please-manifest.json index 64f3cdd..02f17d9 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -1,3 +1,3 @@ { - ".": "0.8.0" + ".": "0.8.1" } diff --git a/CHANGELOG.md b/CHANGELOG.md index 68ba9e6..903d61b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,31 @@ # Changelog +## 0.8.1 (2025-10-07) + +Full Changelog: [v0.8.0...v0.8.1](https://github.com/ContextualAI/contextual-client-node/compare/v0.8.0...v0.8.1) + +### Bug Fixes + +* coerce nullable values to undefined ([0e6f279](https://github.com/ContextualAI/contextual-client-node/commit/0e6f279eac597fca69a580ab8af0a12c015ab644)) + + +### Performance Improvements + +* faster formatting ([20716e5](https://github.com/ContextualAI/contextual-client-node/commit/20716e5908af1f9cc6e3eb60e306ededc8f3d720)) + + +### Chores + +* do not install brew dependencies in ./scripts/bootstrap by default ([2ecd296](https://github.com/ContextualAI/contextual-client-node/commit/2ecd29636b8f21c6138729ef7338f50084410b0e)) +* **internal:** codegen related update ([d6debdf](https://github.com/ContextualAI/contextual-client-node/commit/d6debdfcc774fb8092bd2cabdc036359872d8643)) +* **internal:** codegen related update ([3bc0d6f](https://github.com/ContextualAI/contextual-client-node/commit/3bc0d6fec90af69104f10af5def4be3deeb69507)) +* **internal:** fix incremental formatting in some cases ([2d2c927](https://github.com/ContextualAI/contextual-client-node/commit/2d2c9279de2f4cbfd1edba630aeb30b7395c3481)) +* **internal:** ignore .eslintcache ([1b5df0d](https://github.com/ContextualAI/contextual-client-node/commit/1b5df0db14ec9b5bd5429e4025480d8ba430eda0)) +* **internal:** improve examples ([c251c21](https://github.com/ContextualAI/contextual-client-node/commit/c251c212ee8bff087c7b98f3f5750bf3036ce0cf)) +* **internal:** remove .eslintcache ([352a8df](https://github.com/ContextualAI/contextual-client-node/commit/352a8dfca95b76937b6eeb4e800226afcd7d3337)) +* **internal:** remove deprecated `compilerOptions.baseUrl` from tsconfig.json ([80dc3e8](https://github.com/ContextualAI/contextual-client-node/commit/80dc3e82bb18210f781ebf38500a2310ce10e0e5)) +* **internal:** use npm pack for build uploads ([a1e64cd](https://github.com/ContextualAI/contextual-client-node/commit/a1e64cdb60b8c92692b52914609745edd85a6c43)) + ## 0.8.0 (2025-08-26) Full Changelog: [v0.7.0...v0.8.0](https://github.com/ContextualAI/contextual-client-node/compare/v0.7.0...v0.8.0) diff --git a/package.json b/package.json index 3eeab3d..364138f 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "contextual-client", - "version": "0.8.0", + "version": "0.8.1", "description": "The official TypeScript library for the Contextual AI API", "author": "Contextual AI ", "types": "dist/index.d.ts", diff --git a/release-please-config.json b/release-please-config.json index 624ed99..1ebd0bd 100644 --- a/release-please-config.json +++ b/release-please-config.json @@ -60,8 +60,5 @@ } ], "release-type": "node", - "extra-files": [ - "src/version.ts", - "README.md" - ] + "extra-files": ["src/version.ts", "README.md"] } diff --git a/scripts/bootstrap b/scripts/bootstrap index 0af58e2..f68beda 100755 --- a/scripts/bootstrap +++ b/scripts/bootstrap @@ -4,10 +4,18 @@ set -e cd "$(dirname "$0")/.." -if [ -f "Brewfile" ] && [ "$(uname -s)" = "Darwin" ] && [ "$SKIP_BREW" != "1" ]; then +if [ -f "Brewfile" ] && [ "$(uname -s)" = "Darwin" ] && [ "$SKIP_BREW" != "1" ] && [ -t 0 ]; then brew bundle check >/dev/null 2>&1 || { - echo "==> Installing Homebrew dependencies…" - brew bundle + echo -n "==> Install Homebrew dependencies? (y/N): " + read -r response + case "$response" in + [yY][eE][sS]|[yY]) + brew bundle + ;; + *) + ;; + esac + echo } fi diff --git a/scripts/fast-format b/scripts/fast-format new file mode 100755 index 0000000..8a8e9d5 --- /dev/null +++ b/scripts/fast-format @@ -0,0 +1,40 @@ +#!/usr/bin/env bash + +set -euo pipefail + +echo "Script started with $# arguments" +echo "Arguments: $*" +echo "Script location: $(dirname "$0")" + +cd "$(dirname "$0")/.." +echo "Changed to directory: $(pwd)" + +if [ $# -eq 0 ]; then + echo "Usage: $0 [additional-formatter-args...]" + echo "The file should contain one file path per line" + exit 1 +fi + +FILE_LIST="$1" + +echo "Looking for file: $FILE_LIST" + +if [ ! -f "$FILE_LIST" ]; then + echo "Error: File '$FILE_LIST' not found" + exit 1 +fi + +echo "==> Running eslint --fix" +ESLINT_FILES="$(grep '\.ts$' "$FILE_LIST" || true)" +if ! [ -z "$ESLINT_FILES" ]; then + echo "$ESLINT_FILES" | ESLINT_USE_FLAT_CONFIG="false" xargs ./node_modules/.bin/eslint --cache --fix +fi + +echo "==> Running prettier --write" +# format things eslint didn't +PRETTIER_FILES="$(grep '\.\(js\|json\)$' "$FILE_LIST" || true)" +if ! [ -z "$PRETTIER_FILES" ]; then + echo "$PRETTIER_FILES" | xargs ./node_modules/.bin/prettier \ + --write --cache --cache-strategy metadata --no-error-on-unmatched-pattern \ + '!**/dist' '!**/*.ts' '!**/*.mts' '!**/*.cts' '!**/*.js' '!**/*.mjs' '!**/*.cjs' +fi diff --git a/scripts/utils/upload-artifact.sh b/scripts/utils/upload-artifact.sh index 04daa27..a5a4f63 100755 --- a/scripts/utils/upload-artifact.sh +++ b/scripts/utils/upload-artifact.sh @@ -12,9 +12,11 @@ if [[ "$SIGNED_URL" == "null" ]]; then exit 1 fi -UPLOAD_RESPONSE=$(tar -cz "${BUILD_PATH:-dist}" | curl -v -X PUT \ +TARBALL=$(cd dist && npm pack --silent) + +UPLOAD_RESPONSE=$(curl -v -X PUT \ -H "Content-Type: application/gzip" \ - --data-binary @- "$SIGNED_URL" 2>&1) + --data-binary "@dist/$TARBALL" "$SIGNED_URL" 2>&1) if echo "$UPLOAD_RESPONSE" | grep -q "HTTP/[0-9.]* 200"; then echo -e "\033[32mUploaded build to Stainless storage.\033[0m" diff --git a/src/core.ts b/src/core.ts index 0824fa9..c8a213e 100644 --- a/src/core.ts +++ b/src/core.ts @@ -1088,21 +1088,21 @@ export const coerceBoolean = (value: unknown): boolean => { }; export const maybeCoerceInteger = (value: unknown): number | undefined => { - if (value === undefined) { + if (value == null) { return undefined; } return coerceInteger(value); }; export const maybeCoerceFloat = (value: unknown): number | undefined => { - if (value === undefined) { + if (value == null) { return undefined; } return coerceFloat(value); }; export const maybeCoerceBoolean = (value: unknown): boolean | undefined => { - if (value === undefined) { + if (value == null) { return undefined; } return coerceBoolean(value); diff --git a/src/version.ts b/src/version.ts index 23f967c..b614c75 100644 --- a/src/version.ts +++ b/src/version.ts @@ -1 +1 @@ -export const VERSION = '0.8.0'; // x-release-please-version +export const VERSION = '0.8.1'; // x-release-please-version diff --git a/tests/api-resources/agents/agents.test.ts b/tests/api-resources/agents/agents.test.ts index a70da7c..8ca7a42 100644 --- a/tests/api-resources/agents/agents.test.ts +++ b/tests/api-resources/agents/agents.test.ts @@ -25,9 +25,15 @@ describe('resource agents', () => { name: 'xxx', agent_configs: { filter_and_rerank_config: { - default_metadata_filters: { filters: [], operator: 'AND' }, + default_metadata_filters: { + filters: [{ field: 'field1', operator: 'equals', value: 'value1' }], + operator: 'AND', + }, per_datastore_metadata_filters: { - 'd49609d9-61c3-4a67-b3bd-5196b10da560': { filters: [], operator: 'AND' }, + 'd49609d9-61c3-4a67-b3bd-5196b10da560': { + filters: [{ field: 'field1', operator: 'equals', value: 'value1' }], + operator: 'AND', + }, }, rerank_instructions: 'rerank_instructions', reranker_score_filter_threshold: 0, diff --git a/tests/api-resources/agents/query.test.ts b/tests/api-resources/agents/query.test.ts index 2e541d2..768975c 100644 --- a/tests/api-resources/agents/query.test.ts +++ b/tests/api-resources/agents/query.test.ts @@ -28,7 +28,10 @@ describe('resource query', () => { include_retrieval_content_text: true, retrievals_only: true, conversation_id: '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', - documents_filters: { filters: [], operator: 'AND' }, + documents_filters: { + filters: [{ field: 'field1', operator: 'equals', value: 'value1' }], + operator: 'AND', + }, llm_model_id: 'llm_model_id', override_configuration: { enable_filter: true, diff --git a/tsconfig.build.json b/tsconfig.build.json index 45ed4f2..cfc6888 100644 --- a/tsconfig.build.json +++ b/tsconfig.build.json @@ -5,8 +5,8 @@ "compilerOptions": { "rootDir": "./dist/src", "paths": { - "contextual-client/*": ["dist/src/*"], - "contextual-client": ["dist/src/index.ts"], + "contextual-client/*": ["./dist/src/*"], + "contextual-client": ["./dist/src/index.ts"] }, "noEmit": false, "declaration": true, diff --git a/tsconfig.json b/tsconfig.json index 910517c..5069f47 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -7,11 +7,10 @@ "module": "commonjs", "moduleResolution": "node", "esModuleInterop": true, - "baseUrl": "./", "paths": { - "contextual-client/_shims/auto/*": ["src/_shims/auto/*-node"], - "contextual-client/*": ["src/*"], - "contextual-client": ["src/index.ts"] + "contextual-client/_shims/auto/*": ["./src/_shims/auto/*-node"], + "contextual-client/*": ["./src/*"], + "contextual-client": ["./src/index.ts"] }, "noEmit": true, @@ -32,7 +31,7 @@ "noUncheckedIndexedAccess": true, "noImplicitOverride": true, "noPropertyAccessFromIndexSignature": true, - "isolatedModules": false, + "isolatedModules": false, "skipLibCheck": true }