alchemy 0.74.2 → 0.75.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/bin/alchemy.js +1781 -1746
- package/bin/alchemy.ts +1 -1
- package/bin/commands/create.ts +5 -4
- package/bin/commands/init.ts +109 -65
- package/bin/commands/util.ts +3 -1
- package/bin/constants.ts +2 -2
- package/bin/services/dependencies.ts +4 -4
- package/bin/services/execute-alchemy.ts +5 -3
- package/bin/services/get-package-version.ts +4 -4
- package/bin/services/github-workflow.ts +9 -10
- package/bin/services/package-manager.ts +1 -5
- package/bin/services/template-manager.ts +20 -13
- package/bin/services/vibe-rules.ts +6 -5
- package/bin/trpc.ts +7 -0
- package/bin/types.ts +1 -0
- package/lib/alchemy.d.ts +1 -1
- package/lib/alchemy.d.ts.map +1 -1
- package/lib/alchemy.js +30 -2
- package/lib/alchemy.js.map +1 -1
- package/lib/apply.js +10 -0
- package/lib/apply.js.map +1 -1
- package/lib/auth.js +1 -1
- package/lib/auth.js.map +1 -1
- package/lib/aws/control/types.d.ts.map +1 -1
- package/lib/aws/control/types.js.map +1 -1
- package/lib/clickhouse/api/sdk.gen.d.ts.map +1 -1
- package/lib/clickhouse/api/sdk.gen.js.map +1 -1
- package/lib/cloudflare/account-api-token.d.ts.map +1 -1
- package/lib/cloudflare/account-api-token.js.map +1 -1
- package/lib/cloudflare/astro/astro.js +1 -1
- package/lib/cloudflare/astro/astro.js.map +1 -1
- package/lib/cloudflare/bound.d.ts.map +1 -1
- package/lib/cloudflare/bucket.d.ts +1 -1
- package/lib/cloudflare/bucket.d.ts.map +1 -1
- package/lib/cloudflare/bucket.js +1 -1
- package/lib/cloudflare/bucket.js.map +1 -1
- package/lib/cloudflare/bun-spa/bun-spa.d.ts +1 -1
- package/lib/cloudflare/bun-spa/bun-spa.d.ts.map +1 -1
- package/lib/cloudflare/bun-spa/bun-spa.js +10 -11
- package/lib/cloudflare/bun-spa/bun-spa.js.map +1 -1
- package/lib/cloudflare/bun-spa/get-bun-spa-backend.d.ts +11 -0
- package/lib/cloudflare/bun-spa/get-bun-spa-backend.d.ts.map +1 -0
- package/lib/cloudflare/bun-spa/get-bun-spa-backend.js +26 -0
- package/lib/cloudflare/bun-spa/get-bun-spa-backend.js.map +1 -0
- package/lib/cloudflare/bun-spa/index.d.ts +2 -0
- package/lib/cloudflare/bun-spa/index.d.ts.map +1 -0
- package/lib/cloudflare/bun-spa/index.js +2 -0
- package/lib/cloudflare/bun-spa/index.js.map +1 -0
- package/lib/cloudflare/bundle/internal-worker-bundle.js +1 -1
- package/lib/cloudflare/bundle/internal-worker-bundle.js.map +1 -1
- package/lib/cloudflare/bundle/plugin-hybrid-node-compat.js +1 -1
- package/lib/cloudflare/bundle/plugin-hybrid-node-compat.js.map +1 -1
- package/lib/cloudflare/bundle/plugin-node-compat.js +1 -1
- package/lib/cloudflare/bundle/plugin-node-compat.js.map +1 -1
- package/lib/cloudflare/bundle/plugin-wasm.js +1 -1
- package/lib/cloudflare/bundle/plugin-wasm.js.map +1 -1
- package/lib/cloudflare/cloudflare-env-proxy.d.ts.map +1 -1
- package/lib/cloudflare/cloudflare-env-proxy.js +3 -3
- package/lib/cloudflare/cloudflare-env-proxy.js.map +1 -1
- package/lib/cloudflare/d1-migrations.js +1 -1
- package/lib/cloudflare/d1-migrations.js.map +1 -1
- package/lib/cloudflare/dns-records.js.map +1 -1
- package/lib/cloudflare/kv-namespace.d.ts +5 -0
- package/lib/cloudflare/kv-namespace.d.ts.map +1 -1
- package/lib/cloudflare/kv-namespace.js +44 -19
- package/lib/cloudflare/kv-namespace.js.map +1 -1
- package/lib/cloudflare/miniflare/delete.d.ts.map +1 -1
- package/lib/cloudflare/miniflare/delete.js +3 -0
- package/lib/cloudflare/miniflare/delete.js.map +1 -1
- package/lib/cloudflare/miniflare/miniflare-controller.js +1 -1
- package/lib/cloudflare/miniflare/miniflare-controller.js.map +1 -1
- package/lib/cloudflare/miniflare/miniflare-worker-proxy.d.ts.map +1 -1
- package/lib/cloudflare/miniflare/miniflare-worker-proxy.js +34 -4
- package/lib/cloudflare/miniflare/miniflare-worker-proxy.js.map +1 -1
- package/lib/cloudflare/miniflare/paths.d.ts +0 -1
- package/lib/cloudflare/miniflare/paths.d.ts.map +1 -1
- package/lib/cloudflare/miniflare/paths.js +6 -18
- package/lib/cloudflare/miniflare/paths.js.map +1 -1
- package/lib/cloudflare/next.js +1 -1
- package/lib/cloudflare/next.js.map +1 -1
- package/lib/cloudflare/nuxt/nuxt.js +1 -1
- package/lib/cloudflare/nuxt/nuxt.js.map +1 -1
- package/lib/cloudflare/nuxt/plugin.d.ts.map +1 -1
- package/lib/cloudflare/nuxt/plugin.js +2 -2
- package/lib/cloudflare/nuxt/plugin.js.map +1 -1
- package/lib/cloudflare/react-router/plugin.js +1 -1
- package/lib/cloudflare/react-router/plugin.js.map +1 -1
- package/lib/cloudflare/react-router/react-router.js +1 -1
- package/lib/cloudflare/react-router/react-router.js.map +1 -1
- package/lib/cloudflare/redwood/redwood.js +1 -1
- package/lib/cloudflare/redwood/redwood.js.map +1 -1
- package/lib/cloudflare/sveltekit/sveltekit.js +1 -1
- package/lib/cloudflare/sveltekit/sveltekit.js.map +1 -1
- package/lib/cloudflare/tanstack-start/tanstack-start.js +1 -1
- package/lib/cloudflare/tanstack-start/tanstack-start.js.map +1 -1
- package/lib/cloudflare/tunnel.d.ts.map +1 -1
- package/lib/cloudflare/tunnel.js +25 -1
- package/lib/cloudflare/tunnel.js.map +1 -1
- package/lib/cloudflare/vite/plugin.d.ts.map +1 -1
- package/lib/cloudflare/vite/plugin.js +4 -4
- package/lib/cloudflare/vite/plugin.js.map +1 -1
- package/lib/cloudflare/website.d.ts.map +1 -1
- package/lib/cloudflare/website.js +1 -5
- package/lib/cloudflare/website.js.map +1 -1
- package/lib/cloudflare/worker-assets.d.ts +1 -1
- package/lib/cloudflare/worker-assets.d.ts.map +1 -1
- package/lib/cloudflare/worker-assets.js +1 -1
- package/lib/cloudflare/worker-assets.js.map +1 -1
- package/lib/cloudflare/worker-metadata.d.ts.map +1 -1
- package/lib/cloudflare/worker-metadata.js.map +1 -1
- package/lib/cloudflare/worker-tail.d.ts.map +1 -1
- package/lib/cloudflare/worker-tail.js.map +1 -1
- package/lib/cloudflare/worker.d.ts.map +1 -1
- package/lib/cloudflare/worker.js +1 -1
- package/lib/cloudflare/worker.js.map +1 -1
- package/lib/cloudflare/wrangler.json.js +1 -2
- package/lib/cloudflare/wrangler.json.js.map +1 -1
- package/lib/coinbase/evm-account.d.ts.map +1 -1
- package/lib/coinbase/evm-account.js.map +1 -1
- package/lib/coinbase/evm-smart-account.d.ts.map +1 -1
- package/lib/coinbase/evm-smart-account.js.map +1 -1
- package/lib/coinbase/faucet.js +2 -2
- package/lib/coinbase/faucet.js.map +1 -1
- package/lib/docker/api.d.ts.map +1 -1
- package/lib/docker/api.js +1 -1
- package/lib/docker/api.js.map +1 -1
- package/lib/docker/image.js +1 -1
- package/lib/docker/image.js.map +1 -1
- package/lib/esbuild/bundle.js +1 -1
- package/lib/esbuild/bundle.js.map +1 -1
- package/lib/fs/file.js +1 -1
- package/lib/fs/file.js.map +1 -1
- package/lib/github/secret.d.ts.map +1 -1
- package/lib/github/secret.js.map +1 -1
- package/lib/llms.js +1 -1
- package/lib/llms.js.map +1 -1
- package/lib/neon/api/sdk.gen.d.ts.map +1 -1
- package/lib/neon/api/sdk.gen.js.map +1 -1
- package/lib/os/exec.d.ts.map +1 -1
- package/lib/os/exec.js +1 -1
- package/lib/os/exec.js.map +1 -1
- package/lib/planetscale/api/sdk.gen.d.ts.map +1 -1
- package/lib/planetscale/api/sdk.gen.js.map +1 -1
- package/lib/prisma-postgres/api/sdk.gen.d.ts.map +1 -1
- package/lib/prisma-postgres/api/sdk.gen.js.map +1 -1
- package/lib/scope.d.ts.map +1 -1
- package/lib/scope.js +3 -3
- package/lib/scope.js.map +1 -1
- package/lib/sentry/client-key.js +1 -1
- package/lib/sentry/client-key.js.map +1 -1
- package/lib/state/file-system-state-store.js +1 -1
- package/lib/state/file-system-state-store.js.map +1 -1
- package/lib/state/migrations.js +1 -1
- package/lib/state/migrations.js.map +1 -1
- package/lib/state/sqlite-state-store.js +1 -1
- package/lib/state/sqlite-state-store.js.map +1 -1
- package/lib/stripe/file.d.ts +3 -3
- package/lib/stripe/file.js +3 -3
- package/lib/test/bun.d.ts.map +1 -1
- package/lib/test/bun.js +1 -1
- package/lib/test/bun.js.map +1 -1
- package/lib/test/prune.js +1 -1
- package/lib/test/prune.js.map +1 -1
- package/lib/test/vitest.d.ts.map +1 -1
- package/lib/test/vitest.js +1 -1
- package/lib/test/vitest.js.map +1 -1
- package/lib/util/api/client/client.gen.d.ts +1 -1
- package/lib/util/api/client/client.gen.js +45 -45
- package/lib/util/api/client/types.gen.d.ts +22 -22
- package/lib/util/api/client/utils.gen.d.ts +3 -3
- package/lib/util/api/client/utils.gen.d.ts.map +1 -1
- package/lib/util/api/client/utils.gen.js +34 -34
- package/lib/util/api/client/utils.gen.js.map +1 -1
- package/lib/util/api/core/auth.gen.d.ts +3 -3
- package/lib/util/api/core/auth.gen.js +3 -3
- package/lib/util/api/core/bodySerializer.gen.d.ts +1 -1
- package/lib/util/api/core/bodySerializer.gen.js +3 -3
- package/lib/util/api/core/params.gen.d.ts +3 -3
- package/lib/util/api/core/params.gen.js +7 -7
- package/lib/util/api/core/pathSerializer.gen.d.ts +3 -3
- package/lib/util/api/core/pathSerializer.gen.js +36 -36
- package/lib/util/api/core/serverSentEvents.gen.d.ts +3 -3
- package/lib/util/api/core/serverSentEvents.gen.js +18 -18
- package/lib/util/api/core/types.gen.d.ts +4 -4
- package/lib/util/api/core/utils.gen.d.ts +1 -1
- package/lib/util/api/core/utils.gen.js +17 -17
- package/lib/util/camel-to-snake.d.ts.map +1 -1
- package/lib/util/content-type.js +1 -1
- package/lib/util/content-type.js.map +1 -1
- package/lib/util/find-workspace-root.d.ts +3 -0
- package/lib/util/find-workspace-root.d.ts.map +1 -0
- package/lib/util/find-workspace-root.js +64 -0
- package/lib/util/find-workspace-root.js.map +1 -0
- package/lib/util/idempotent-spawn.d.ts.map +1 -1
- package/lib/util/idempotent-spawn.js +2 -2
- package/lib/util/idempotent-spawn.js.map +1 -1
- package/lib/util/lock.js +1 -1
- package/lib/util/lock.js.map +1 -1
- package/lib/util/peer.d.ts.map +1 -1
- package/lib/util/peer.js.map +1 -1
- package/package.json +6 -1
- package/src/alchemy.ts +60 -4
- package/src/apply.ts +16 -1
- package/src/auth.ts +1 -1
- package/src/aws/control/types.ts +87107 -85281
- package/src/clickhouse/api/sdk.gen.ts +1 -3
- package/src/cloudflare/account-api-token.ts +3 -1
- package/src/cloudflare/astro/astro.ts +1 -1
- package/src/cloudflare/bound.ts +64 -65
- package/src/cloudflare/bucket.ts +4 -7
- package/src/cloudflare/bun-spa/bun-spa.ts +13 -13
- package/src/cloudflare/bun-spa/get-bun-spa-backend.ts +29 -0
- package/src/cloudflare/bun-spa/index.ts +1 -0
- package/src/cloudflare/bundle/internal-worker-bundle.ts +1 -1
- package/src/cloudflare/bundle/plugin-hybrid-node-compat.ts +1 -1
- package/src/cloudflare/bundle/plugin-node-compat.ts +1 -1
- package/src/cloudflare/bundle/plugin-wasm.ts +1 -1
- package/src/cloudflare/cloudflare-env-proxy.ts +2 -4
- package/src/cloudflare/d1-migrations.ts +1 -1
- package/src/cloudflare/dns-records.ts +3 -1
- package/src/cloudflare/kv-namespace.ts +52 -20
- package/src/cloudflare/miniflare/delete.ts +3 -0
- package/src/cloudflare/miniflare/miniflare-controller.ts +1 -1
- package/src/cloudflare/miniflare/miniflare-worker-proxy.ts +39 -4
- package/src/cloudflare/miniflare/paths.ts +6 -26
- package/src/cloudflare/next.ts +1 -1
- package/src/cloudflare/nuxt/nuxt.ts +1 -1
- package/src/cloudflare/nuxt/plugin.ts +1 -4
- package/src/cloudflare/react-router/plugin.ts +1 -1
- package/src/cloudflare/react-router/react-router.ts +1 -1
- package/src/cloudflare/redwood/redwood.ts +1 -1
- package/src/cloudflare/sveltekit/sveltekit.ts +1 -1
- package/src/cloudflare/tanstack-start/tanstack-start.ts +1 -1
- package/src/cloudflare/tunnel.ts +36 -1
- package/src/cloudflare/vite/plugin.ts +2 -4
- package/src/cloudflare/website.ts +1 -6
- package/src/cloudflare/worker-assets.ts +1 -6
- package/src/cloudflare/worker-metadata.ts +5 -3
- package/src/cloudflare/worker-tail.ts +3 -1
- package/src/cloudflare/worker.ts +1 -3
- package/src/cloudflare/wrangler.json.ts +1 -2
- package/src/coinbase/evm-account.ts +3 -1
- package/src/coinbase/evm-smart-account.ts +3 -1
- package/src/coinbase/faucet.ts +2 -2
- package/src/docker/api.ts +4 -2
- package/src/docker/image.ts +1 -1
- package/src/esbuild/bundle.ts +1 -1
- package/src/fs/file.ts +1 -1
- package/src/github/secret.ts +5 -1
- package/src/llms.ts +1 -1
- package/src/neon/api/sdk.gen.ts +1 -3
- package/src/os/exec.ts +4 -2
- package/src/planetscale/api/sdk.gen.ts +1 -3
- package/src/prisma-postgres/api/sdk.gen.ts +1 -3
- package/src/scope.ts +3 -3
- package/src/sentry/client-key.ts +1 -5
- package/src/state/file-system-state-store.ts +1 -1
- package/src/state/migrations.ts +1 -1
- package/src/state/sqlite-state-store.ts +1 -1
- package/src/stripe/file.ts +3 -3
- package/src/test/bun.ts +4 -2
- package/src/test/prune.ts +1 -1
- package/src/test/vitest.ts +4 -2
- package/src/util/api/client/client.gen.ts +49 -49
- package/src/util/api/client/types.gen.ts +43 -43
- package/src/util/api/client/utils.gen.ts +47 -42
- package/src/util/api/core/auth.gen.ts +6 -6
- package/src/util/api/core/bodySerializer.gen.ts +4 -4
- package/src/util/api/core/params.gen.ts +10 -10
- package/src/util/api/core/pathSerializer.gen.ts +39 -39
- package/src/util/api/core/serverSentEvents.gen.ts +22 -22
- package/src/util/api/core/types.gen.ts +12 -12
- package/src/util/api/core/utils.gen.ts +18 -18
- package/src/util/camel-to-snake.ts +12 -10
- package/src/util/content-type.ts +1 -1
- package/{bin/services → src/util}/find-workspace-root.ts +27 -5
- package/src/util/idempotent-spawn.ts +2 -6
- package/src/util/lock.ts +1 -1
- package/src/util/peer.ts +3 -1
- package/templates/astro/alchemy.run.ts +0 -2
- package/templates/astro/astro.config.mjs +3 -3
- package/templates/astro/src/pages/api/hello.ts +16 -13
- package/templates/bun-spa/README.md +94 -0
- package/templates/bun-spa/_env +1 -0
- package/templates/bun-spa/_env.example +1 -0
- package/templates/bun-spa/_gitignore +29 -0
- package/templates/bun-spa/alchemy.run.ts +21 -0
- package/templates/bun-spa/bun-env.d.ts +25 -0
- package/templates/bun-spa/eslint.config.js +26 -0
- package/templates/bun-spa/package.json +30 -0
- package/templates/bun-spa/src/App.css +46 -0
- package/templates/bun-spa/src/App.tsx +53 -0
- package/templates/bun-spa/src/assets/logo.svg +1 -0
- package/templates/bun-spa/src/assets/react.svg +1 -0
- package/templates/bun-spa/src/frontend.tsx +14 -0
- package/templates/bun-spa/src/index.css +69 -0
- package/templates/bun-spa/src/index.html +14 -0
- package/templates/bun-spa/src/worker.ts +51 -0
- package/templates/bun-spa/tsconfig.json +24 -0
- package/templates/hono/alchemy.run.ts +0 -2
- package/templates/hono/src/index.ts +13 -13
- package/templates/nextjs/alchemy.run.ts +1 -3
- package/templates/nextjs/eslint.config.mjs +1 -1
- package/templates/nextjs/next-env.d.ts +1 -1
- package/templates/nextjs/next.config.ts +1 -1
- package/templates/nextjs/open-next.config.ts +1 -1
- package/templates/nextjs/src/app/api/hello/route.ts +2 -2
- package/templates/nextjs/src/app/layout.tsx +1 -1
- package/templates/nextjs/src/app/page.tsx +14 -15
- package/templates/nextjs/types/env.d.ts +4 -4
- package/templates/nuxt/alchemy.run.ts +0 -2
- package/templates/nuxt/server/middleware/auth.ts +1 -1
- package/templates/nuxt/server/middleware/hello.ts +2 -2
- package/templates/react-router/alchemy.run.ts +0 -2
- package/templates/react-router/app/entry.server.tsx +2 -2
- package/templates/react-router/package.json +1 -1
- package/templates/react-router/vite.config.ts +1 -1
- package/templates/react-router/workers/app.ts +2 -2
- package/templates/rwsdk/alchemy.run.ts +6 -4
- package/templates/rwsdk/package.json +1 -1
- package/templates/sveltekit/alchemy.run.ts +0 -2
- package/templates/sveltekit/package.json +1 -1
- package/templates/sveltekit/src/app.d.ts +7 -7
- package/templates/sveltekit/svelte.config.js +4 -4
- package/templates/sveltekit/vite.config.ts +3 -3
- package/templates/tanstack-start/alchemy.run.ts +0 -2
- package/templates/tanstack-start/package.json +1 -1
- package/templates/tanstack-start/src/components/Header.tsx +2 -2
- package/templates/tanstack-start/src/router.tsx +4 -4
- package/templates/tanstack-start/src/routes/__root.tsx +10 -10
- package/templates/tanstack-start/src/routes/api.demo-names.ts +6 -6
- package/templates/tanstack-start/src/routes/demo.start.api-request.tsx +11 -11
- package/templates/tanstack-start/src/routes/demo.start.server-funcs.tsx +30 -30
- package/templates/tanstack-start/src/routes/index.tsx +5 -5
- package/templates/tanstack-start/vite.config.ts +9 -9
- package/templates/typescript/alchemy.run.ts +0 -2
- package/templates/typescript/src/worker.ts +5 -1
- package/templates/vite/alchemy.run.ts +0 -2
- package/templates/vite/eslint.config.js +12 -12
- package/templates/vite/package.json +1 -1
- package/templates/vite/src/App.tsx +7 -7
- package/templates/vite/src/main.tsx +6 -6
- package/templates/vite/src/worker.ts +11 -12
- package/templates/vite/vite.config.ts +2 -2
- package/workers/tunnel-proxy.js +1 -1
- package/lib/cloudflare/miniflare/symlink-miniflare-state.d.ts +0 -2
- package/lib/cloudflare/miniflare/symlink-miniflare-state.d.ts.map +0 -1
- package/lib/cloudflare/miniflare/symlink-miniflare-state.js +0 -18
- package/lib/cloudflare/miniflare/symlink-miniflare-state.js.map +0 -1
- package/src/cloudflare/miniflare/symlink-miniflare-state.ts +0 -18
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
// This file is auto-generated by @hey-api/openapi-ts
|
|
2
2
|
|
|
3
|
-
import { createSseClient } from
|
|
4
|
-
import type { HttpMethod } from
|
|
5
|
-
import { getValidRequestBody } from
|
|
3
|
+
import { createSseClient } from "../core/serverSentEvents.gen";
|
|
4
|
+
import type { HttpMethod } from "../core/types.gen";
|
|
5
|
+
import { getValidRequestBody } from "../core/utils.gen";
|
|
6
6
|
import type {
|
|
7
7
|
Client,
|
|
8
8
|
Config,
|
|
9
9
|
RequestOptions,
|
|
10
10
|
ResolvedRequestOptions,
|
|
11
|
-
} from
|
|
11
|
+
} from "./types.gen";
|
|
12
12
|
import {
|
|
13
13
|
buildUrl,
|
|
14
14
|
createConfig,
|
|
@@ -17,9 +17,9 @@ import {
|
|
|
17
17
|
mergeConfigs,
|
|
18
18
|
mergeHeaders,
|
|
19
19
|
setAuthParams,
|
|
20
|
-
} from
|
|
20
|
+
} from "./utils.gen";
|
|
21
21
|
|
|
22
|
-
type ReqInit = Omit<RequestInit,
|
|
22
|
+
type ReqInit = Omit<RequestInit, "body" | "headers"> & {
|
|
23
23
|
body?: any;
|
|
24
24
|
headers: ReturnType<typeof mergeHeaders>;
|
|
25
25
|
};
|
|
@@ -66,8 +66,8 @@ export const createClient = (config: Config = {}): Client => {
|
|
|
66
66
|
}
|
|
67
67
|
|
|
68
68
|
// remove Content-Type header if body is empty to avoid sending invalid requests
|
|
69
|
-
if (opts.body === undefined || opts.serializedBody ===
|
|
70
|
-
opts.headers.delete(
|
|
69
|
+
if (opts.body === undefined || opts.serializedBody === "") {
|
|
70
|
+
opts.headers.delete("Content-Type");
|
|
71
71
|
}
|
|
72
72
|
|
|
73
73
|
const url = buildUrl(opts);
|
|
@@ -75,11 +75,11 @@ export const createClient = (config: Config = {}): Client => {
|
|
|
75
75
|
return { opts, url };
|
|
76
76
|
};
|
|
77
77
|
|
|
78
|
-
const request: Client[
|
|
78
|
+
const request: Client["request"] = async (options) => {
|
|
79
79
|
// @ts-expect-error
|
|
80
80
|
const { opts, url } = await beforeRequest(options);
|
|
81
81
|
const requestInit: ReqInit = {
|
|
82
|
-
redirect:
|
|
82
|
+
redirect: "follow",
|
|
83
83
|
...opts,
|
|
84
84
|
body: getValidRequestBody(opts),
|
|
85
85
|
};
|
|
@@ -110,33 +110,33 @@ export const createClient = (config: Config = {}): Client => {
|
|
|
110
110
|
|
|
111
111
|
if (response.ok) {
|
|
112
112
|
const parseAs =
|
|
113
|
-
(opts.parseAs ===
|
|
114
|
-
? getParseAs(response.headers.get(
|
|
115
|
-
: opts.parseAs) ??
|
|
113
|
+
(opts.parseAs === "auto"
|
|
114
|
+
? getParseAs(response.headers.get("Content-Type"))
|
|
115
|
+
: opts.parseAs) ?? "json";
|
|
116
116
|
|
|
117
117
|
if (
|
|
118
118
|
response.status === 204 ||
|
|
119
|
-
response.headers.get(
|
|
119
|
+
response.headers.get("Content-Length") === "0"
|
|
120
120
|
) {
|
|
121
121
|
let emptyData: any;
|
|
122
122
|
switch (parseAs) {
|
|
123
|
-
case
|
|
124
|
-
case
|
|
125
|
-
case
|
|
123
|
+
case "arrayBuffer":
|
|
124
|
+
case "blob":
|
|
125
|
+
case "text":
|
|
126
126
|
emptyData = await response[parseAs]();
|
|
127
127
|
break;
|
|
128
|
-
case
|
|
128
|
+
case "formData":
|
|
129
129
|
emptyData = new FormData();
|
|
130
130
|
break;
|
|
131
|
-
case
|
|
131
|
+
case "stream":
|
|
132
132
|
emptyData = response.body;
|
|
133
133
|
break;
|
|
134
|
-
case
|
|
134
|
+
case "json":
|
|
135
135
|
default:
|
|
136
136
|
emptyData = {};
|
|
137
137
|
break;
|
|
138
138
|
}
|
|
139
|
-
return opts.responseStyle ===
|
|
139
|
+
return opts.responseStyle === "data"
|
|
140
140
|
? emptyData
|
|
141
141
|
: {
|
|
142
142
|
data: emptyData,
|
|
@@ -146,15 +146,15 @@ export const createClient = (config: Config = {}): Client => {
|
|
|
146
146
|
|
|
147
147
|
let data: any;
|
|
148
148
|
switch (parseAs) {
|
|
149
|
-
case
|
|
150
|
-
case
|
|
151
|
-
case
|
|
152
|
-
case
|
|
153
|
-
case
|
|
149
|
+
case "arrayBuffer":
|
|
150
|
+
case "blob":
|
|
151
|
+
case "formData":
|
|
152
|
+
case "json":
|
|
153
|
+
case "text":
|
|
154
154
|
data = await response[parseAs]();
|
|
155
155
|
break;
|
|
156
|
-
case
|
|
157
|
-
return opts.responseStyle ===
|
|
156
|
+
case "stream":
|
|
157
|
+
return opts.responseStyle === "data"
|
|
158
158
|
? response.body
|
|
159
159
|
: {
|
|
160
160
|
data: response.body,
|
|
@@ -162,7 +162,7 @@ export const createClient = (config: Config = {}): Client => {
|
|
|
162
162
|
};
|
|
163
163
|
}
|
|
164
164
|
|
|
165
|
-
if (parseAs ===
|
|
165
|
+
if (parseAs === "json") {
|
|
166
166
|
if (opts.responseValidator) {
|
|
167
167
|
await opts.responseValidator(data);
|
|
168
168
|
}
|
|
@@ -172,7 +172,7 @@ export const createClient = (config: Config = {}): Client => {
|
|
|
172
172
|
}
|
|
173
173
|
}
|
|
174
174
|
|
|
175
|
-
return opts.responseStyle ===
|
|
175
|
+
return opts.responseStyle === "data"
|
|
176
176
|
? data
|
|
177
177
|
: {
|
|
178
178
|
data,
|
|
@@ -205,7 +205,7 @@ export const createClient = (config: Config = {}): Client => {
|
|
|
205
205
|
}
|
|
206
206
|
|
|
207
207
|
// TODO: we probably want to return error and improve types
|
|
208
|
-
return opts.responseStyle ===
|
|
208
|
+
return opts.responseStyle === "data"
|
|
209
209
|
? undefined
|
|
210
210
|
: {
|
|
211
211
|
error: finalError,
|
|
@@ -240,29 +240,29 @@ export const createClient = (config: Config = {}): Client => {
|
|
|
240
240
|
|
|
241
241
|
return {
|
|
242
242
|
buildUrl,
|
|
243
|
-
connect: makeMethodFn(
|
|
244
|
-
delete: makeMethodFn(
|
|
245
|
-
get: makeMethodFn(
|
|
243
|
+
connect: makeMethodFn("CONNECT"),
|
|
244
|
+
delete: makeMethodFn("DELETE"),
|
|
245
|
+
get: makeMethodFn("GET"),
|
|
246
246
|
getConfig,
|
|
247
|
-
head: makeMethodFn(
|
|
247
|
+
head: makeMethodFn("HEAD"),
|
|
248
248
|
interceptors,
|
|
249
|
-
options: makeMethodFn(
|
|
250
|
-
patch: makeMethodFn(
|
|
251
|
-
post: makeMethodFn(
|
|
252
|
-
put: makeMethodFn(
|
|
249
|
+
options: makeMethodFn("OPTIONS"),
|
|
250
|
+
patch: makeMethodFn("PATCH"),
|
|
251
|
+
post: makeMethodFn("POST"),
|
|
252
|
+
put: makeMethodFn("PUT"),
|
|
253
253
|
request,
|
|
254
254
|
setConfig,
|
|
255
255
|
sse: {
|
|
256
|
-
connect: makeSseFn(
|
|
257
|
-
delete: makeSseFn(
|
|
258
|
-
get: makeSseFn(
|
|
259
|
-
head: makeSseFn(
|
|
260
|
-
options: makeSseFn(
|
|
261
|
-
patch: makeSseFn(
|
|
262
|
-
post: makeSseFn(
|
|
263
|
-
put: makeSseFn(
|
|
264
|
-
trace: makeSseFn(
|
|
256
|
+
connect: makeSseFn("CONNECT"),
|
|
257
|
+
delete: makeSseFn("DELETE"),
|
|
258
|
+
get: makeSseFn("GET"),
|
|
259
|
+
head: makeSseFn("HEAD"),
|
|
260
|
+
options: makeSseFn("OPTIONS"),
|
|
261
|
+
patch: makeSseFn("PATCH"),
|
|
262
|
+
post: makeSseFn("POST"),
|
|
263
|
+
put: makeSseFn("PUT"),
|
|
264
|
+
trace: makeSseFn("TRACE"),
|
|
265
265
|
},
|
|
266
|
-
trace: makeMethodFn(
|
|
266
|
+
trace: makeMethodFn("TRACE"),
|
|
267
267
|
} as Client;
|
|
268
268
|
};
|
|
@@ -1,25 +1,25 @@
|
|
|
1
1
|
// This file is auto-generated by @hey-api/openapi-ts
|
|
2
2
|
|
|
3
|
-
import type { Auth } from
|
|
3
|
+
import type { Auth } from "../core/auth.gen";
|
|
4
4
|
import type {
|
|
5
5
|
ServerSentEventsOptions,
|
|
6
6
|
ServerSentEventsResult,
|
|
7
|
-
} from
|
|
7
|
+
} from "../core/serverSentEvents.gen";
|
|
8
8
|
import type {
|
|
9
9
|
Client as CoreClient,
|
|
10
10
|
Config as CoreConfig,
|
|
11
|
-
} from
|
|
12
|
-
import type { Middleware } from
|
|
11
|
+
} from "../core/types.gen";
|
|
12
|
+
import type { Middleware } from "./utils.gen";
|
|
13
13
|
|
|
14
|
-
export type ResponseStyle =
|
|
14
|
+
export type ResponseStyle = "data" | "fields";
|
|
15
15
|
|
|
16
16
|
export interface Config<T extends ClientOptions = ClientOptions>
|
|
17
|
-
extends Omit<RequestInit,
|
|
17
|
+
extends Omit<RequestInit, "body" | "headers" | "method">,
|
|
18
18
|
CoreConfig {
|
|
19
19
|
/**
|
|
20
20
|
* Base URL for all requests made by this client.
|
|
21
21
|
*/
|
|
22
|
-
baseUrl?: T[
|
|
22
|
+
baseUrl?: T["baseUrl"];
|
|
23
23
|
/**
|
|
24
24
|
* Fetch API implementation. You can use this option to provide a custom
|
|
25
25
|
* fetch instance.
|
|
@@ -43,13 +43,13 @@ export interface Config<T extends ClientOptions = ClientOptions>
|
|
|
43
43
|
* @default 'auto'
|
|
44
44
|
*/
|
|
45
45
|
parseAs?:
|
|
46
|
-
|
|
|
47
|
-
|
|
|
48
|
-
|
|
|
49
|
-
|
|
|
50
|
-
|
|
|
51
|
-
|
|
|
52
|
-
|
|
|
46
|
+
| "arrayBuffer"
|
|
47
|
+
| "auto"
|
|
48
|
+
| "blob"
|
|
49
|
+
| "formData"
|
|
50
|
+
| "json"
|
|
51
|
+
| "stream"
|
|
52
|
+
| "text";
|
|
53
53
|
/**
|
|
54
54
|
* Should we return only data or multiple fields (data, error, response, etc.)?
|
|
55
55
|
*
|
|
@@ -61,12 +61,12 @@ export interface Config<T extends ClientOptions = ClientOptions>
|
|
|
61
61
|
*
|
|
62
62
|
* @default false
|
|
63
63
|
*/
|
|
64
|
-
throwOnError?: T[
|
|
64
|
+
throwOnError?: T["throwOnError"];
|
|
65
65
|
}
|
|
66
66
|
|
|
67
67
|
export interface RequestOptions<
|
|
68
68
|
TData = unknown,
|
|
69
|
-
TResponseStyle extends ResponseStyle =
|
|
69
|
+
TResponseStyle extends ResponseStyle = "fields",
|
|
70
70
|
ThrowOnError extends boolean = boolean,
|
|
71
71
|
Url extends string = string,
|
|
72
72
|
> extends Config<{
|
|
@@ -75,11 +75,11 @@ export interface RequestOptions<
|
|
|
75
75
|
}>,
|
|
76
76
|
Pick<
|
|
77
77
|
ServerSentEventsOptions<TData>,
|
|
78
|
-
|
|
|
79
|
-
|
|
|
80
|
-
|
|
|
81
|
-
|
|
|
82
|
-
|
|
|
78
|
+
| "onSseError"
|
|
79
|
+
| "onSseEvent"
|
|
80
|
+
| "sseDefaultRetryDelay"
|
|
81
|
+
| "sseMaxRetryAttempts"
|
|
82
|
+
| "sseMaxRetryDelay"
|
|
83
83
|
> {
|
|
84
84
|
/**
|
|
85
85
|
* Any body that you want to add to your request.
|
|
@@ -97,7 +97,7 @@ export interface RequestOptions<
|
|
|
97
97
|
}
|
|
98
98
|
|
|
99
99
|
export interface ResolvedRequestOptions<
|
|
100
|
-
TResponseStyle extends ResponseStyle =
|
|
100
|
+
TResponseStyle extends ResponseStyle = "fields",
|
|
101
101
|
ThrowOnError extends boolean = boolean,
|
|
102
102
|
Url extends string = string,
|
|
103
103
|
> extends RequestOptions<unknown, TResponseStyle, ThrowOnError, Url> {
|
|
@@ -108,10 +108,10 @@ export type RequestResult<
|
|
|
108
108
|
TData = unknown,
|
|
109
109
|
TError = unknown,
|
|
110
110
|
ThrowOnError extends boolean = boolean,
|
|
111
|
-
TResponseStyle extends ResponseStyle =
|
|
111
|
+
TResponseStyle extends ResponseStyle = "fields",
|
|
112
112
|
> = ThrowOnError extends true
|
|
113
113
|
? Promise<
|
|
114
|
-
TResponseStyle extends
|
|
114
|
+
TResponseStyle extends "data"
|
|
115
115
|
? TData extends Record<string, unknown>
|
|
116
116
|
? TData[keyof TData]
|
|
117
117
|
: TData
|
|
@@ -124,7 +124,7 @@ export type RequestResult<
|
|
|
124
124
|
}
|
|
125
125
|
>
|
|
126
126
|
: Promise<
|
|
127
|
-
TResponseStyle extends
|
|
127
|
+
TResponseStyle extends "data"
|
|
128
128
|
?
|
|
129
129
|
| (TData extends Record<string, unknown>
|
|
130
130
|
? TData[keyof TData]
|
|
@@ -159,30 +159,30 @@ type MethodFn = <
|
|
|
159
159
|
TData = unknown,
|
|
160
160
|
TError = unknown,
|
|
161
161
|
ThrowOnError extends boolean = false,
|
|
162
|
-
TResponseStyle extends ResponseStyle =
|
|
162
|
+
TResponseStyle extends ResponseStyle = "fields",
|
|
163
163
|
>(
|
|
164
|
-
options: Omit<RequestOptions<TData, TResponseStyle, ThrowOnError>,
|
|
164
|
+
options: Omit<RequestOptions<TData, TResponseStyle, ThrowOnError>, "method">,
|
|
165
165
|
) => RequestResult<TData, TError, ThrowOnError, TResponseStyle>;
|
|
166
166
|
|
|
167
167
|
type SseFn = <
|
|
168
168
|
TData = unknown,
|
|
169
169
|
TError = unknown,
|
|
170
170
|
ThrowOnError extends boolean = false,
|
|
171
|
-
TResponseStyle extends ResponseStyle =
|
|
171
|
+
TResponseStyle extends ResponseStyle = "fields",
|
|
172
172
|
>(
|
|
173
|
-
options: Omit<RequestOptions<TData, TResponseStyle, ThrowOnError>,
|
|
173
|
+
options: Omit<RequestOptions<TData, TResponseStyle, ThrowOnError>, "method">,
|
|
174
174
|
) => Promise<ServerSentEventsResult<TData, TError>>;
|
|
175
175
|
|
|
176
176
|
type RequestFn = <
|
|
177
177
|
TData = unknown,
|
|
178
178
|
TError = unknown,
|
|
179
179
|
ThrowOnError extends boolean = false,
|
|
180
|
-
TResponseStyle extends ResponseStyle =
|
|
180
|
+
TResponseStyle extends ResponseStyle = "fields",
|
|
181
181
|
>(
|
|
182
|
-
options: Omit<RequestOptions<TData, TResponseStyle, ThrowOnError>,
|
|
182
|
+
options: Omit<RequestOptions<TData, TResponseStyle, ThrowOnError>, "method"> &
|
|
183
183
|
Pick<
|
|
184
184
|
Required<RequestOptions<TData, TResponseStyle, ThrowOnError>>,
|
|
185
|
-
|
|
185
|
+
"method"
|
|
186
186
|
>,
|
|
187
187
|
) => RequestResult<TData, TError, ThrowOnError, TResponseStyle>;
|
|
188
188
|
|
|
@@ -194,7 +194,7 @@ type BuildUrlFn = <
|
|
|
194
194
|
url: string;
|
|
195
195
|
},
|
|
196
196
|
>(
|
|
197
|
-
options: Pick<TData,
|
|
197
|
+
options: Pick<TData, "url"> & Options<TData>,
|
|
198
198
|
) => string;
|
|
199
199
|
|
|
200
200
|
export type Client = CoreClient<
|
|
@@ -233,36 +233,36 @@ export type Options<
|
|
|
233
233
|
TData extends TDataShape = TDataShape,
|
|
234
234
|
ThrowOnError extends boolean = boolean,
|
|
235
235
|
TResponse = unknown,
|
|
236
|
-
TResponseStyle extends ResponseStyle =
|
|
236
|
+
TResponseStyle extends ResponseStyle = "fields",
|
|
237
237
|
> = OmitKeys<
|
|
238
238
|
RequestOptions<TResponse, TResponseStyle, ThrowOnError>,
|
|
239
|
-
|
|
239
|
+
"body" | "path" | "query" | "url"
|
|
240
240
|
> &
|
|
241
|
-
Omit<TData,
|
|
241
|
+
Omit<TData, "url">;
|
|
242
242
|
|
|
243
243
|
export type OptionsLegacyParser<
|
|
244
244
|
TData = unknown,
|
|
245
245
|
ThrowOnError extends boolean = boolean,
|
|
246
|
-
TResponseStyle extends ResponseStyle =
|
|
246
|
+
TResponseStyle extends ResponseStyle = "fields",
|
|
247
247
|
> = TData extends { body?: any }
|
|
248
248
|
? TData extends { headers?: any }
|
|
249
249
|
? OmitKeys<
|
|
250
250
|
RequestOptions<unknown, TResponseStyle, ThrowOnError>,
|
|
251
|
-
|
|
251
|
+
"body" | "headers" | "url"
|
|
252
252
|
> &
|
|
253
253
|
TData
|
|
254
254
|
: OmitKeys<
|
|
255
255
|
RequestOptions<unknown, TResponseStyle, ThrowOnError>,
|
|
256
|
-
|
|
256
|
+
"body" | "url"
|
|
257
257
|
> &
|
|
258
258
|
TData &
|
|
259
|
-
Pick<RequestOptions<unknown, TResponseStyle, ThrowOnError>,
|
|
259
|
+
Pick<RequestOptions<unknown, TResponseStyle, ThrowOnError>, "headers">
|
|
260
260
|
: TData extends { headers?: any }
|
|
261
261
|
? OmitKeys<
|
|
262
262
|
RequestOptions<unknown, TResponseStyle, ThrowOnError>,
|
|
263
|
-
|
|
263
|
+
"headers" | "url"
|
|
264
264
|
> &
|
|
265
265
|
TData &
|
|
266
|
-
Pick<RequestOptions<unknown, TResponseStyle, ThrowOnError>,
|
|
267
|
-
: OmitKeys<RequestOptions<unknown, TResponseStyle, ThrowOnError>,
|
|
266
|
+
Pick<RequestOptions<unknown, TResponseStyle, ThrowOnError>, "body">
|
|
267
|
+
: OmitKeys<RequestOptions<unknown, TResponseStyle, ThrowOnError>, "url"> &
|
|
268
268
|
TData;
|
|
@@ -1,15 +1,20 @@
|
|
|
1
1
|
// This file is auto-generated by @hey-api/openapi-ts
|
|
2
2
|
|
|
3
|
-
import { getAuthToken } from
|
|
4
|
-
import type { QuerySerializerOptions } from
|
|
5
|
-
import { jsonBodySerializer } from
|
|
3
|
+
import { getAuthToken } from "../core/auth.gen";
|
|
4
|
+
import type { QuerySerializerOptions } from "../core/bodySerializer.gen";
|
|
5
|
+
import { jsonBodySerializer } from "../core/bodySerializer.gen";
|
|
6
6
|
import {
|
|
7
7
|
serializeArrayParam,
|
|
8
8
|
serializeObjectParam,
|
|
9
9
|
serializePrimitiveParam,
|
|
10
|
-
} from
|
|
11
|
-
import { getUrl } from
|
|
12
|
-
import type {
|
|
10
|
+
} from "../core/pathSerializer.gen";
|
|
11
|
+
import { getUrl } from "../core/utils.gen";
|
|
12
|
+
import type {
|
|
13
|
+
Client,
|
|
14
|
+
ClientOptions,
|
|
15
|
+
Config,
|
|
16
|
+
RequestOptions,
|
|
17
|
+
} from "./types.gen";
|
|
13
18
|
|
|
14
19
|
export const createQuerySerializer = <T = unknown>({
|
|
15
20
|
allowReserved,
|
|
@@ -18,7 +23,7 @@ export const createQuerySerializer = <T = unknown>({
|
|
|
18
23
|
}: QuerySerializerOptions = {}) => {
|
|
19
24
|
const querySerializer = (queryParams: T) => {
|
|
20
25
|
const search: string[] = [];
|
|
21
|
-
if (queryParams && typeof queryParams ===
|
|
26
|
+
if (queryParams && typeof queryParams === "object") {
|
|
22
27
|
for (const name in queryParams) {
|
|
23
28
|
const value = queryParams[name];
|
|
24
29
|
|
|
@@ -31,17 +36,17 @@ export const createQuerySerializer = <T = unknown>({
|
|
|
31
36
|
allowReserved,
|
|
32
37
|
explode: true,
|
|
33
38
|
name,
|
|
34
|
-
style:
|
|
39
|
+
style: "form",
|
|
35
40
|
value,
|
|
36
41
|
...array,
|
|
37
42
|
});
|
|
38
43
|
if (serializedArray) search.push(serializedArray);
|
|
39
|
-
} else if (typeof value ===
|
|
44
|
+
} else if (typeof value === "object") {
|
|
40
45
|
const serializedObject = serializeObjectParam({
|
|
41
46
|
allowReserved,
|
|
42
47
|
explode: true,
|
|
43
48
|
name,
|
|
44
|
-
style:
|
|
49
|
+
style: "deepObject",
|
|
45
50
|
value: value as Record<string, unknown>,
|
|
46
51
|
...object,
|
|
47
52
|
});
|
|
@@ -56,7 +61,7 @@ export const createQuerySerializer = <T = unknown>({
|
|
|
56
61
|
}
|
|
57
62
|
}
|
|
58
63
|
}
|
|
59
|
-
return search.join(
|
|
64
|
+
return search.join("&");
|
|
60
65
|
};
|
|
61
66
|
return querySerializer;
|
|
62
67
|
};
|
|
@@ -66,47 +71,47 @@ export const createQuerySerializer = <T = unknown>({
|
|
|
66
71
|
*/
|
|
67
72
|
export const getParseAs = (
|
|
68
73
|
contentType: string | null,
|
|
69
|
-
): Exclude<Config[
|
|
74
|
+
): Exclude<Config["parseAs"], "auto"> => {
|
|
70
75
|
if (!contentType) {
|
|
71
76
|
// If no Content-Type header is provided, the best we can do is return the raw response body,
|
|
72
77
|
// which is effectively the same as the 'stream' option.
|
|
73
|
-
return
|
|
78
|
+
return "stream";
|
|
74
79
|
}
|
|
75
80
|
|
|
76
|
-
const cleanContent = contentType.split(
|
|
81
|
+
const cleanContent = contentType.split(";")[0]?.trim();
|
|
77
82
|
|
|
78
83
|
if (!cleanContent) {
|
|
79
84
|
return;
|
|
80
85
|
}
|
|
81
86
|
|
|
82
87
|
if (
|
|
83
|
-
cleanContent.startsWith(
|
|
84
|
-
cleanContent.endsWith(
|
|
88
|
+
cleanContent.startsWith("application/json") ||
|
|
89
|
+
cleanContent.endsWith("+json")
|
|
85
90
|
) {
|
|
86
|
-
return
|
|
91
|
+
return "json";
|
|
87
92
|
}
|
|
88
93
|
|
|
89
|
-
if (cleanContent ===
|
|
90
|
-
return
|
|
94
|
+
if (cleanContent === "multipart/form-data") {
|
|
95
|
+
return "formData";
|
|
91
96
|
}
|
|
92
97
|
|
|
93
98
|
if (
|
|
94
|
-
[
|
|
99
|
+
["application/", "audio/", "image/", "video/"].some((type) =>
|
|
95
100
|
cleanContent.startsWith(type),
|
|
96
101
|
)
|
|
97
102
|
) {
|
|
98
|
-
return
|
|
103
|
+
return "blob";
|
|
99
104
|
}
|
|
100
105
|
|
|
101
|
-
if (cleanContent.startsWith(
|
|
102
|
-
return
|
|
106
|
+
if (cleanContent.startsWith("text/")) {
|
|
107
|
+
return "text";
|
|
103
108
|
}
|
|
104
109
|
|
|
105
110
|
return;
|
|
106
111
|
};
|
|
107
112
|
|
|
108
113
|
const checkForExistence = (
|
|
109
|
-
options: Pick<RequestOptions,
|
|
114
|
+
options: Pick<RequestOptions, "auth" | "query"> & {
|
|
110
115
|
headers: Headers;
|
|
111
116
|
},
|
|
112
117
|
name?: string,
|
|
@@ -117,7 +122,7 @@ const checkForExistence = (
|
|
|
117
122
|
if (
|
|
118
123
|
options.headers.has(name) ||
|
|
119
124
|
options.query?.[name] ||
|
|
120
|
-
options.headers.get(
|
|
125
|
+
options.headers.get("Cookie")?.includes(`${name}=`)
|
|
121
126
|
) {
|
|
122
127
|
return true;
|
|
123
128
|
}
|
|
@@ -127,8 +132,8 @@ const checkForExistence = (
|
|
|
127
132
|
export const setAuthParams = async ({
|
|
128
133
|
security,
|
|
129
134
|
...options
|
|
130
|
-
}: Pick<Required<RequestOptions>,
|
|
131
|
-
Pick<RequestOptions,
|
|
135
|
+
}: Pick<Required<RequestOptions>, "security"> &
|
|
136
|
+
Pick<RequestOptions, "auth" | "query"> & {
|
|
132
137
|
headers: Headers;
|
|
133
138
|
}) => {
|
|
134
139
|
for (const auth of security) {
|
|
@@ -142,19 +147,19 @@ export const setAuthParams = async ({
|
|
|
142
147
|
continue;
|
|
143
148
|
}
|
|
144
149
|
|
|
145
|
-
const name = auth.name ??
|
|
150
|
+
const name = auth.name ?? "Authorization";
|
|
146
151
|
|
|
147
152
|
switch (auth.in) {
|
|
148
|
-
case
|
|
153
|
+
case "query":
|
|
149
154
|
if (!options.query) {
|
|
150
155
|
options.query = {};
|
|
151
156
|
}
|
|
152
157
|
options.query[name] = token;
|
|
153
158
|
break;
|
|
154
|
-
case
|
|
155
|
-
options.headers.append(
|
|
159
|
+
case "cookie":
|
|
160
|
+
options.headers.append("Cookie", `${name}=${token}`);
|
|
156
161
|
break;
|
|
157
|
-
case
|
|
162
|
+
case "header":
|
|
158
163
|
default:
|
|
159
164
|
options.headers.set(name, token);
|
|
160
165
|
break;
|
|
@@ -162,13 +167,13 @@ export const setAuthParams = async ({
|
|
|
162
167
|
}
|
|
163
168
|
};
|
|
164
169
|
|
|
165
|
-
export const buildUrl: Client[
|
|
170
|
+
export const buildUrl: Client["buildUrl"] = (options) =>
|
|
166
171
|
getUrl({
|
|
167
172
|
baseUrl: options.baseUrl as string,
|
|
168
173
|
path: options.path,
|
|
169
174
|
query: options.query,
|
|
170
175
|
querySerializer:
|
|
171
|
-
typeof options.querySerializer ===
|
|
176
|
+
typeof options.querySerializer === "function"
|
|
172
177
|
? options.querySerializer
|
|
173
178
|
: createQuerySerializer(options.querySerializer),
|
|
174
179
|
url: options.url,
|
|
@@ -176,7 +181,7 @@ export const buildUrl: Client['buildUrl'] = (options) =>
|
|
|
176
181
|
|
|
177
182
|
export const mergeConfigs = (a: Config, b: Config): Config => {
|
|
178
183
|
const config = { ...a, ...b };
|
|
179
|
-
if (config.baseUrl?.endsWith(
|
|
184
|
+
if (config.baseUrl?.endsWith("/")) {
|
|
180
185
|
config.baseUrl = config.baseUrl.substring(0, config.baseUrl.length - 1);
|
|
181
186
|
}
|
|
182
187
|
config.headers = mergeHeaders(a.headers, b.headers);
|
|
@@ -192,7 +197,7 @@ const headersEntries = (headers: Headers): Array<[string, string]> => {
|
|
|
192
197
|
};
|
|
193
198
|
|
|
194
199
|
export const mergeHeaders = (
|
|
195
|
-
...headers: Array<Required<Config>[
|
|
200
|
+
...headers: Array<Required<Config>["headers"] | undefined>
|
|
196
201
|
): Headers => {
|
|
197
202
|
const mergedHeaders = new Headers();
|
|
198
203
|
for (const header of headers) {
|
|
@@ -217,7 +222,7 @@ export const mergeHeaders = (
|
|
|
217
222
|
// content value in OpenAPI specification is 'application/json'
|
|
218
223
|
mergedHeaders.set(
|
|
219
224
|
key,
|
|
220
|
-
typeof value ===
|
|
225
|
+
typeof value === "object" ? JSON.stringify(value) : (value as string),
|
|
221
226
|
);
|
|
222
227
|
}
|
|
223
228
|
}
|
|
@@ -263,7 +268,7 @@ class Interceptors<Interceptor> {
|
|
|
263
268
|
}
|
|
264
269
|
|
|
265
270
|
getInterceptorIndex(id: number | Interceptor): number {
|
|
266
|
-
if (typeof id ===
|
|
271
|
+
if (typeof id === "number") {
|
|
267
272
|
return this.fns[id] ? id : -1;
|
|
268
273
|
}
|
|
269
274
|
return this.fns.indexOf(id);
|
|
@@ -308,16 +313,16 @@ const defaultQuerySerializer = createQuerySerializer({
|
|
|
308
313
|
allowReserved: false,
|
|
309
314
|
array: {
|
|
310
315
|
explode: true,
|
|
311
|
-
style:
|
|
316
|
+
style: "form",
|
|
312
317
|
},
|
|
313
318
|
object: {
|
|
314
319
|
explode: true,
|
|
315
|
-
style:
|
|
320
|
+
style: "deepObject",
|
|
316
321
|
},
|
|
317
322
|
});
|
|
318
323
|
|
|
319
324
|
const defaultHeaders = {
|
|
320
|
-
|
|
325
|
+
"Content-Type": "application/json",
|
|
321
326
|
};
|
|
322
327
|
|
|
323
328
|
export const createConfig = <T extends ClientOptions = ClientOptions>(
|
|
@@ -325,7 +330,7 @@ export const createConfig = <T extends ClientOptions = ClientOptions>(
|
|
|
325
330
|
): Config<Omit<ClientOptions, keyof T> & T> => ({
|
|
326
331
|
...jsonBodySerializer,
|
|
327
332
|
headers: defaultHeaders,
|
|
328
|
-
parseAs:
|
|
333
|
+
parseAs: "auto",
|
|
329
334
|
querySerializer: defaultQuerySerializer,
|
|
330
335
|
...override,
|
|
331
336
|
});
|