diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index cff688f..6e657fa 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,12 +1,14 @@ name: CI on: push: - branches-ignore: - - 'generated' - - 'codegen/**' - - 'integrated/**' - - 'stl-preview-head/**' - - 'stl-preview-base/**' + branches: + - '**' + - '!integrated/**' + - '!stl-preview-head/**' + - '!stl-preview-base/**' + - '!generated' + - '!codegen/**' + - 'codegen/stl/**' pull_request: branches-ignore: - 'stl-preview-head/**' @@ -17,12 +19,12 @@ jobs: timeout-minutes: 10 name: lint runs-on: ${{ github.repository == 'stainless-sdks/zeroentropy-node' && 'depot-ubuntu-24.04' || 'ubuntu-latest' }} - if: github.event_name == 'push' || github.event.pull_request.head.repo.fork + if: (github.event_name == 'push' || github.event.pull_request.head.repo.fork) && (github.event_name != 'push' || github.event.head_commit.message != 'codegen metadata') steps: - - uses: actions/checkout@v6 + - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 - name: Set up Node - uses: actions/setup-node@v4 + uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0 with: node-version: '18' @@ -36,15 +38,15 @@ jobs: timeout-minutes: 5 name: build runs-on: ${{ github.repository == 'stainless-sdks/zeroentropy-node' && 'depot-ubuntu-24.04' || 'ubuntu-latest' }} - if: github.event_name == 'push' || github.event.pull_request.head.repo.fork + if: (github.event_name == 'push' || github.event.pull_request.head.repo.fork) && (github.event_name != 'push' || github.event.head_commit.message != 'codegen metadata') permissions: contents: read id-token: write steps: - - uses: actions/checkout@v6 + - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 - name: Set up Node - uses: actions/setup-node@v4 + uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0 with: node-version: '18' @@ -59,7 +61,7 @@ jobs: github.repository == 'stainless-sdks/zeroentropy-node' && !startsWith(github.ref, 'refs/heads/stl/') id: github-oidc - uses: actions/github-script@v8 + uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0 with: script: core.setOutput('github_token', await core.getIDToken()); @@ -78,10 +80,10 @@ jobs: runs-on: ${{ github.repository == 'stainless-sdks/zeroentropy-node' && 'depot-ubuntu-24.04' || 'ubuntu-latest' }} if: github.event_name == 'push' || github.event.pull_request.head.repo.fork steps: - - uses: actions/checkout@v6 + - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 - name: Set up Node - uses: actions/setup-node@v4 + uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0 with: node-version: '20' diff --git a/.github/workflows/publish-npm.yml b/.github/workflows/publish-npm.yml index 692b89c..326ca1e 100644 --- a/.github/workflows/publish-npm.yml +++ b/.github/workflows/publish-npm.yml @@ -14,10 +14,10 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v6 + - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 - name: Set up Node - uses: actions/setup-node@v3 + uses: actions/setup-node@3235b876344d2a9aa001b8d1453c930bba69e610 # v3.9.1 with: node-version: '20' diff --git a/.github/workflows/release-doctor.yml b/.github/workflows/release-doctor.yml index 55f70f7..3e93a56 100644 --- a/.github/workflows/release-doctor.yml +++ b/.github/workflows/release-doctor.yml @@ -12,7 +12,7 @@ jobs: if: github.repository == 'zeroentropy-ai/zeroentropy-node' && (github.event_name == 'push' || github.event_name == 'workflow_dispatch' || startsWith(github.head_ref, 'release-please') || github.head_ref == 'next') steps: - - uses: actions/checkout@v6 + - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 - name: Check release environment run: | diff --git a/.gitignore b/.gitignore index 2412bb7..c85fe68 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ .prism.log +.stdy.log node_modules yarn-error.log codegen.log diff --git a/.release-please-manifest.json b/.release-please-manifest.json index 931fce1..acba45e 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -1,3 +1,3 @@ { - ".": "0.1.0-alpha.10" + ".": "0.1.0-alpha.11" } diff --git a/.stats.yml b/.stats.yml index a9365b5..8a4fe5a 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 15 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/zeroentropy%2Fzeroentropy-5ff1b24060b908d169910a7366213eeb423b52d14b03cc16902923eb0ffac71a.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/zeroentropy/zeroentropy-6d6fee8f2524057cf8e4329638eb7c97e2befc3054e867c6ab0931bea37bc6ec.yml openapi_spec_hash: fc50a1765bfbfe9a3da7ea9001e479d4 config_hash: e56152e1ee1a9273241d925702077e49 diff --git a/CHANGELOG.md b/CHANGELOG.md index da14712..7ea1491 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,35 @@ # Changelog +## 0.1.0-alpha.11 (2026-05-13) + +Full Changelog: [v0.1.0-alpha.10...v0.1.0-alpha.11](https://github.com/zeroentropy-ai/zeroentropy-node/compare/v0.1.0-alpha.10...v0.1.0-alpha.11) + +### Features + +* support setting headers via env ([421be8a](https://github.com/zeroentropy-ai/zeroentropy-node/commit/421be8a2da546cdb6360033153bd5bb0ec36285e)) + + +### Chores + +* **ci:** skip lint on metadata-only changes ([ad14cb8](https://github.com/zeroentropy-ai/zeroentropy-node/commit/ad14cb8b44632f6e9d114b4dee381260241e1eb3)) +* **internal:** codegen related update ([8aae49f](https://github.com/zeroentropy-ai/zeroentropy-node/commit/8aae49f6fe4d41f4d72069b9c855cf0b9290384f)) +* **internal:** more robust bootstrap script ([7eeb4ae](https://github.com/zeroentropy-ai/zeroentropy-node/commit/7eeb4ae68489d5abadf34bbe78a355d4f4897fb6)) +* **internal:** tweak CI branches ([c0e7952](https://github.com/zeroentropy-ai/zeroentropy-node/commit/c0e79524e59cab23ca892fcbdc075923ecd2fb55)) +* **internal:** update gitignore ([56c5654](https://github.com/zeroentropy-ai/zeroentropy-node/commit/56c5654b5d377df0b833fce219b73945d487ee80)) +* **internal:** update multipart form array serialization ([3fcd1df](https://github.com/zeroentropy-ai/zeroentropy-node/commit/3fcd1dfb6f1cf01d0804fb1571ad9b213e68d942)) +* **tests:** bump steady to v0.19.4 ([9e94e5c](https://github.com/zeroentropy-ai/zeroentropy-node/commit/9e94e5c8849deafdaa92e0c5ffd7e19e4efae853)) +* **tests:** bump steady to v0.19.5 ([181566c](https://github.com/zeroentropy-ai/zeroentropy-node/commit/181566c7a3bac0b4c9855c374cbdde0071096833)) +* **tests:** bump steady to v0.19.6 ([291bdf2](https://github.com/zeroentropy-ai/zeroentropy-node/commit/291bdf21202c4e333a08baeffb9d4a31a3a640b5)) +* **tests:** bump steady to v0.19.7 ([124fb21](https://github.com/zeroentropy-ai/zeroentropy-node/commit/124fb21e2a3393814369f270a5b8f807a009b8ec)) +* **tests:** bump steady to v0.20.1 ([bfc164c](https://github.com/zeroentropy-ai/zeroentropy-node/commit/bfc164cc8ba80b93aef0fc90d551bd0b4b38359f)) +* **tests:** bump steady to v0.20.2 ([3131593](https://github.com/zeroentropy-ai/zeroentropy-node/commit/3131593c25c3fdb300e1032d738b32df7b6b5786)) +* **tests:** bump steady to v0.22.1 ([bf20a55](https://github.com/zeroentropy-ai/zeroentropy-node/commit/bf20a558f88afc5ac0dcc350bc40010089e43ce8)) + + +### Refactors + +* **tests:** switch from prism to steady ([3aa529e](https://github.com/zeroentropy-ai/zeroentropy-node/commit/3aa529ec81bb884439e6e603ddf4e6437496ce8c)) + ## 0.1.0-alpha.10 (2026-03-07) Full Changelog: [v0.1.0-alpha.9...v0.1.0-alpha.10](https://github.com/zeroentropy-ai/zeroentropy-node/compare/v0.1.0-alpha.9...v0.1.0-alpha.10) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 858bf6c..3ee8ec1 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -65,7 +65,7 @@ $ pnpm link --global zeroentropy ## Running tests -Most tests require you to [set up a mock server](https://github.com/stoplightio/prism) against the OpenAPI spec to run the tests. +Most tests require you to [set up a mock server](https://github.com/dgellow/steady) against the OpenAPI spec to run the tests. ```sh $ ./scripts/mock diff --git a/package.json b/package.json index 7c580b3..a5747ca 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "zeroentropy", - "version": "0.1.0-alpha.10", + "version": "0.1.0-alpha.11", "description": "The official TypeScript library for the ZeroEntropy API", "author": "ZeroEntropy ", "types": "dist/index.d.ts", diff --git a/scripts/bootstrap b/scripts/bootstrap index f68beda..28b5985 100755 --- a/scripts/bootstrap +++ b/scripts/bootstrap @@ -4,7 +4,7 @@ set -e cd "$(dirname "$0")/.." -if [ -f "Brewfile" ] && [ "$(uname -s)" = "Darwin" ] && [ "$SKIP_BREW" != "1" ] && [ -t 0 ]; then +if [ -f "Brewfile" ] && [ "$(uname -s)" = "Darwin" ] && [ "${SKIP_BREW:-}" != "1" ] && [ -t 0 ]; then brew bundle check >/dev/null 2>&1 || { echo -n "==> Install Homebrew dependencies? (y/N): " read -r response diff --git a/scripts/mock b/scripts/mock index bcf3b39..feebe5e 100755 --- a/scripts/mock +++ b/scripts/mock @@ -19,34 +19,34 @@ fi echo "==> Starting mock server with URL ${URL}" -# Run prism mock on the given spec +# Run steady mock on the given spec if [ "$1" == "--daemon" ]; then # Pre-install the package so the download doesn't eat into the startup timeout - npm exec --package=@stainless-api/prism-cli@5.15.0 -- prism --version + npm exec --package=@stdy/cli@0.22.1 -- steady --version - npm exec --package=@stainless-api/prism-cli@5.15.0 -- prism mock "$URL" &> .prism.log & + npm exec --package=@stdy/cli@0.22.1 -- steady --host 127.0.0.1 -p 4010 --validator-query-array-format=comma --validator-form-array-format=comma --validator-query-object-format=brackets --validator-form-object-format=brackets "$URL" &> .stdy.log & - # Wait for server to come online (max 30s) + # Wait for server to come online via health endpoint (max 30s) echo -n "Waiting for server" attempts=0 - while ! grep -q "✖ fatal\|Prism is listening" ".prism.log" ; do + while ! curl --silent --fail "http://127.0.0.1:4010/_x-steady/health" >/dev/null 2>&1; do + if ! kill -0 $! 2>/dev/null; then + echo + cat .stdy.log + exit 1 + fi attempts=$((attempts + 1)) if [ "$attempts" -ge 300 ]; then echo - echo "Timed out waiting for Prism server to start" - cat .prism.log + echo "Timed out waiting for Steady server to start" + cat .stdy.log exit 1 fi echo -n "." sleep 0.1 done - if grep -q "✖ fatal" ".prism.log"; then - cat .prism.log - exit 1 - fi - echo else - npm exec --package=@stainless-api/prism-cli@5.15.0 -- prism mock "$URL" + npm exec --package=@stdy/cli@0.22.1 -- steady --host 127.0.0.1 -p 4010 --validator-query-array-format=comma --validator-form-array-format=comma --validator-query-object-format=brackets --validator-form-object-format=brackets "$URL" fi diff --git a/scripts/test b/scripts/test index 7bce051..19b8d0c 100755 --- a/scripts/test +++ b/scripts/test @@ -9,8 +9,8 @@ GREEN='\033[0;32m' YELLOW='\033[0;33m' NC='\033[0m' # No Color -function prism_is_running() { - curl --silent "http://localhost:4010" >/dev/null 2>&1 +function steady_is_running() { + curl --silent "http://127.0.0.1:4010/_x-steady/health" >/dev/null 2>&1 } kill_server_on_port() { @@ -25,7 +25,7 @@ function is_overriding_api_base_url() { [ -n "$TEST_API_BASE_URL" ] } -if ! is_overriding_api_base_url && ! prism_is_running ; then +if ! is_overriding_api_base_url && ! steady_is_running ; then # When we exit this script, make sure to kill the background mock server process trap 'kill_server_on_port 4010' EXIT @@ -36,19 +36,19 @@ fi if is_overriding_api_base_url ; then echo -e "${GREEN}✔ Running tests against ${TEST_API_BASE_URL}${NC}" echo -elif ! prism_is_running ; then - echo -e "${RED}ERROR:${NC} The test suite will not run without a mock Prism server" +elif ! steady_is_running ; then + echo -e "${RED}ERROR:${NC} The test suite will not run without a mock Steady server" echo -e "running against your OpenAPI spec." echo echo -e "To run the server, pass in the path or url of your OpenAPI" - echo -e "spec to the prism command:" + echo -e "spec to the steady command:" echo - echo -e " \$ ${YELLOW}npm exec --package=@stainless-api/prism-cli@5.15.0 -- prism mock path/to/your.openapi.yml${NC}" + echo -e " \$ ${YELLOW}npm exec --package=@stdy/cli@0.22.1 -- steady path/to/your.openapi.yml --host 127.0.0.1 -p 4010 --validator-query-array-format=comma --validator-form-array-format=comma --validator-query-object-format=brackets --validator-form-object-format=brackets${NC}" echo exit 1 else - echo -e "${GREEN}✔ Mock prism server is running with your OpenAPI spec${NC}" + echo -e "${GREEN}✔ Mock steady server is running with your OpenAPI spec${NC}" echo fi diff --git a/src/core.ts b/src/core.ts index ba418e9..0fc283d 100644 --- a/src/core.ts +++ b/src/core.ts @@ -1054,10 +1054,10 @@ export const ensurePresent = (value: T | null | undefined): T => { */ export const readEnv = (env: string): string | undefined => { if (typeof process !== 'undefined') { - return process.env?.[env]?.trim() ?? undefined; + return process.env?.[env]?.trim() || undefined; } if (typeof Deno !== 'undefined') { - return Deno.env?.get?.(env)?.trim(); + return Deno.env?.get?.(env)?.trim() || undefined; } return undefined; }; diff --git a/src/index.ts b/src/index.ts index ca23f19..a3381f4 100644 --- a/src/index.ts +++ b/src/index.ts @@ -161,6 +161,18 @@ export class ZeroEntropy extends Core.APIClient { fetch: options.fetch, }); + const customHeadersEnv = Core.readEnv('ZEROENTROPY_CUSTOM_HEADERS'); + if (customHeadersEnv) { + const parsed: Record = {}; + for (const line of customHeadersEnv.split('\n')) { + const colon = line.indexOf(':'); + if (colon >= 0) { + parsed[line.substring(0, colon).trim()] = line.substring(colon + 1).trim(); + } + } + options.defaultHeaders = { ...parsed, ...options.defaultHeaders }; + } + this._options = options; this.apiKey = apiKey; diff --git a/src/version.ts b/src/version.ts index 5ed52cd..51a202a 100644 --- a/src/version.ts +++ b/src/version.ts @@ -1 +1 @@ -export const VERSION = '0.1.0-alpha.10'; // x-release-please-version +export const VERSION = '0.1.0-alpha.11'; // x-release-please-version