diff --git a/scripts/release_sdks.sh b/scripts/release_sdks.sh index 2cf2c72..2c1aed6 100755 --- a/scripts/release_sdks.sh +++ b/scripts/release_sdks.sh @@ -81,8 +81,29 @@ ts.write_text( re.sub(r'"version": "[^"]+"', f'"version": "{version}"', ts.read_text(), count=1) ) +ts_lock = pathlib.Path("sdk/typescript/package-lock.json") +if ts_lock.exists(): + lock_text = ts_lock.read_text() + lock_text = re.sub( + r'^ "version": "[^"]+"', + f' "version": "{version}"', + lock_text, + count=1, + flags=re.M, + ) + lock_text = re.sub( + r'^( "version": ")[^"]+(")', + rf'\g<1>{version}\2', + lock_text, + count=1, + flags=re.M, + ) + ts_lock.write_text(lock_text) + print(f" pyproject.toml → {version}") print(f" package.json → {version}") +if ts_lock.exists(): + print(f" package-lock.json → {version}") PY echo "→ Building Python wheel + sdist..." diff --git a/sdk/python/pyproject.toml b/sdk/python/pyproject.toml index bdfcdb6..c502e1b 100644 --- a/sdk/python/pyproject.toml +++ b/sdk/python/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "dograh-sdk" -version = "0.1.6" +version = "0.1.7" description = "Typed builder for Dograh voice-AI workflows" readme = "README.md" requires-python = ">=3.10" diff --git a/sdk/python/src/dograh_sdk/_generated_models.py b/sdk/python/src/dograh_sdk/_generated_models.py index 883cc00..6ab3e9a 100644 --- a/sdk/python/src/dograh_sdk/_generated_models.py +++ b/sdk/python/src/dograh_sdk/_generated_models.py @@ -1,6 +1,6 @@ # generated by datamodel-codegen: -# filename: dograh-openapi-EZT8BU.json -# timestamp: 2026-05-31T10:54:36+00:00 +# filename: dograh-openapi-DuffQq.json +# timestamp: 2026-05-31T11:41:57+00:00 from __future__ import annotations diff --git a/sdk/typescript/package-lock.json b/sdk/typescript/package-lock.json index 0cd36cf..fa804ff 100644 --- a/sdk/typescript/package-lock.json +++ b/sdk/typescript/package-lock.json @@ -1,12 +1,12 @@ { "name": "@dograh/sdk", - "version": "0.1.3", + "version": "0.1.7", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@dograh/sdk", - "version": "0.1.3", + "version": "0.1.7", "license": "BSD-2-Clause", "devDependencies": { "openapi-typescript": "^7.13.0", diff --git a/sdk/typescript/package.json b/sdk/typescript/package.json index 6bc8b26..a554f59 100644 --- a/sdk/typescript/package.json +++ b/sdk/typescript/package.json @@ -1,6 +1,6 @@ { "name": "@dograh/sdk", - "version": "0.1.6", + "version": "0.1.7", "description": "Typed builder for Dograh voice-AI workflows", "license": "BSD-2-Clause", "author": "Zansat Technologies Private Limited", diff --git a/sdk/typescript/src/client.ts b/sdk/typescript/src/client.ts index 5c65c01..6565fc8 100644 --- a/sdk/typescript/src/client.ts +++ b/sdk/typescript/src/client.ts @@ -16,19 +16,48 @@ import type { import { ApiError, SpecMismatchError } from "./errors.js"; import { Workflow, type SpecProvider } from "./workflow.js"; +type RuntimeProcess = { + env?: Record; +}; + +export interface DograhFetchInit { + method?: string; + headers?: Record; + body?: string; + signal?: unknown; +} + +export interface DograhFetchResponse { + ok: boolean; + status: number; + statusText: string; + json(): Promise; + text(): Promise; +} + +export type DograhFetch = ( + url: string, + init?: DograhFetchInit, +) => Promise; + +function getRuntimeEnv(name: string): string | undefined { + const runtime = globalThis as typeof globalThis & { process?: RuntimeProcess }; + return runtime.process?.env?.[name]; +} + export interface DograhClientOptions { baseUrl?: string; apiKey?: string; /** Request timeout in ms. */ timeoutMs?: number; /** Optional fetch override for tests / custom transports. */ - fetch?: typeof globalThis.fetch; + fetch?: DograhFetch; } export class DograhClient extends _GeneratedClient implements SpecProvider { readonly baseUrl: string; readonly apiKey: string | undefined; - private readonly fetchImpl: typeof globalThis.fetch; + private readonly fetchImpl: DograhFetch; private readonly timeoutMs: number; private readonly headers: Record; private readonly specCache = new Map(); @@ -38,13 +67,11 @@ export class DograhClient extends _GeneratedClient implements SpecProvider { super(); const rawBase = opts.baseUrl ?? - (typeof process !== "undefined" ? process.env.DOGRAH_API_URL : undefined) ?? + getRuntimeEnv("DOGRAH_API_URL") ?? "http://localhost:8000"; this.baseUrl = rawBase.replace(/\/+$/, ""); - this.apiKey = - opts.apiKey ?? - (typeof process !== "undefined" ? process.env.DOGRAH_API_KEY : undefined); - this.fetchImpl = opts.fetch ?? globalThis.fetch; + this.apiKey = opts.apiKey ?? getRuntimeEnv("DOGRAH_API_KEY"); + this.fetchImpl = opts.fetch ?? (globalThis.fetch as unknown as DograhFetch); this.timeoutMs = opts.timeoutMs ?? 30_000; this.headers = { Accept: "application/json" }; if (this.apiKey) this.headers["X-API-Key"] = this.apiKey; @@ -126,7 +153,7 @@ export class DograhClient extends _GeneratedClient implements SpecProvider { } const hasBody = opts?.json !== undefined; - const init: RequestInit = { + const init: DograhFetchInit = { method, headers: { ...this.headers, @@ -139,7 +166,7 @@ export class DograhClient extends _GeneratedClient implements SpecProvider { const timer = setTimeout(() => controller.abort(), this.timeoutMs); init.signal = controller.signal; - let resp: Response; + let resp: DograhFetchResponse; try { resp = await this.fetchImpl(url, init); } finally { diff --git a/sdk/typescript/src/index.ts b/sdk/typescript/src/index.ts index a529760..9bce491 100644 --- a/sdk/typescript/src/index.ts +++ b/sdk/typescript/src/index.ts @@ -26,7 +26,12 @@ */ export { DograhClient } from "./client.js"; -export type { DograhClientOptions } from "./client.js"; +export type { + DograhClientOptions, + DograhFetch, + DograhFetchInit, + DograhFetchResponse, +} from "./client.js"; export { ApiError, DograhSdkError, diff --git a/sdk/typescript/tsconfig.json b/sdk/typescript/tsconfig.json index 3fb9984..035b54a 100644 --- a/sdk/typescript/tsconfig.json +++ b/sdk/typescript/tsconfig.json @@ -3,7 +3,7 @@ "target": "ES2022", "module": "NodeNext", "moduleResolution": "NodeNext", - "lib": ["ES2022"], + "lib": ["ES2022", "DOM"], "strict": true, "noUncheckedIndexedAccess": true, "declaration": true,