@automate.ax/client 0.2.0 → 0.3.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 CHANGED
@@ -11,9 +11,9 @@ bun add @automate.ax/client
11
11
  ## API key
12
12
 
13
13
  ```ts
14
- import { createClient } from "@automate.ax/client"
14
+ import { createAutomateClient } from "@automate.ax/client"
15
15
 
16
- const client = createClient({
16
+ const client = createAutomateClient({
17
17
  apiKey: process.env.AUTOMATE_AX_API_KEY!,
18
18
  })
19
19
 
@@ -23,5 +23,4 @@ const projects = await client.project.list()
23
23
  The key is organization-owned and is sent in the `x-api-key` header. It does
24
24
  not represent a user session.
25
25
 
26
- The client targets `https://automate.ax/api/rpc` by default. Use `url`, `headers`,
27
- or `fetch` to customize its transport.
26
+ The client targets `https://automate.ax/api/rpc`.
package/dist/index.d.ts CHANGED
@@ -1,20 +1,9 @@
1
1
  import type { contract } from "@automate.ax/api-contract";
2
2
  import type { ContractRouterClient } from "@orpc/contract";
3
- export type Client = ContractRouterClient<typeof contract>;
4
- export type Credential = string | (() => Promise<string | null | undefined> | string | null | undefined);
5
- export type Fetch = (request: Request, init?: RequestInit) => Promise<Response>;
6
- type HeadersInit = ConstructorParameters<typeof Headers>[0];
7
- interface ClientBaseOptions {
8
- /** Overrides the default `https://automate.ax/api/rpc` endpoint. */
9
- url?: URL | string;
10
- /** Adds request headers before the authentication header is applied. */
11
- headers?: HeadersInit | (() => HeadersInit | Promise<HeadersInit>);
12
- /** Overrides the global Fetch implementation used for requests. */
13
- fetch?: Fetch;
14
- }
15
- export interface ClientOptions extends ClientBaseOptions {
3
+ export type AutomateClient = ContractRouterClient<typeof contract>;
4
+ export interface AutomateClientOptions {
16
5
  /** Automate.ax API key sent through the `x-api-key` header. */
17
- apiKey: Credential;
6
+ apiKey: string | (() => Promise<string | null | undefined> | string | null | undefined);
18
7
  }
19
8
  /**
20
9
  * Creates a type-safe client for every procedure in the public API contract.
@@ -22,7 +11,6 @@ export interface ClientOptions extends ClientBaseOptions {
22
11
  * Credential callbacks are evaluated for every request, allowing callers to
23
12
  * rotate API keys without recreating the client.
24
13
  *
25
- * @param options - Authentication and transport configuration.
14
+ * @param options - API authentication options.
26
15
  */
27
- export declare function createClient(options: ClientOptions): Client;
28
- export {};
16
+ export declare function createAutomateClient(options: AutomateClientOptions): AutomateClient;
package/dist/index.js CHANGED
@@ -1,33 +1,25 @@
1
1
  import { createORPCClient } from "@orpc/client";
2
2
  import { RPCLink } from "@orpc/client/fetch";
3
- const DEFAULT_RPC_URL = "https://automate.ax/api/rpc";
3
+ const RPC_URL = "https://automate.ax/api/rpc";
4
4
  /**
5
5
  * Creates a type-safe client for every procedure in the public API contract.
6
6
  *
7
7
  * Credential callbacks are evaluated for every request, allowing callers to
8
8
  * rotate API keys without recreating the client.
9
9
  *
10
- * @param options - Authentication and transport configuration.
10
+ * @param options - API authentication options.
11
11
  */
12
- export function createClient(options) {
13
- const customFetch = options.fetch;
12
+ export function createAutomateClient(options) {
14
13
  return createORPCClient(new RPCLink({
15
- url: options.url ?? DEFAULT_RPC_URL,
14
+ url: RPC_URL,
16
15
  headers: async () => {
17
- const headers = new Headers(typeof options.headers === "function"
18
- ? await options.headers()
19
- : options.headers);
20
- const credential = typeof options.apiKey === "function"
16
+ const headers = new Headers();
17
+ const apiKey = typeof options.apiKey === "function"
21
18
  ? await options.apiKey()
22
19
  : options.apiKey;
23
- if (!credential) {
24
- throw new Error("API credentials are unavailable.");
25
- }
26
- headers.set("x-api-key", credential);
20
+ if (apiKey)
21
+ headers.set("x-api-key", apiKey);
27
22
  return headers;
28
23
  },
29
- ...(customFetch && {
30
- fetch: (request, init) => customFetch(request, init),
31
- }),
32
24
  }));
33
25
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@automate.ax/client",
3
- "version": "0.2.0",
3
+ "version": "0.3.1",
4
4
  "description": "Type-safe client for the Automate.ax API.",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -37,7 +37,7 @@
37
37
  "lint": "oxlint --type-aware",
38
38
  "lint:fix": "oxlint --type-aware --fix-suggestions",
39
39
  "check": "bun run typecheck && bun run lint",
40
- "test": "bun test",
40
+ "test": "bun test --pass-with-no-tests",
41
41
  "build": "zshy -p tsconfig.build.json",
42
42
  "prepublishOnly": "bun run check && bun run test && bun run build"
43
43
  },