@automate.ax/client 0.1.3

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Zach Sents
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,27 @@
1
+ # `@automate.ax/client`
2
+
3
+ Type-safe client for the complete Automate.ax API contract.
4
+
5
+ ## Install
6
+
7
+ ```bash
8
+ bun add @automate.ax/client
9
+ ```
10
+
11
+ ## API key
12
+
13
+ ```ts
14
+ import { createClient } from "@automate.ax/client"
15
+
16
+ const client = createClient({
17
+ apiKey: process.env.AUTOMATE_AX_API_KEY!,
18
+ })
19
+
20
+ const projects = await client.project.list()
21
+ ```
22
+
23
+ The key is organization-owned and is sent in the `x-api-key` header. It does
24
+ not represent a user session.
25
+
26
+ The client targets `https://automate.ax/api/rpc` by default. Use `url`, `headers`,
27
+ or `fetch` to customize its transport.
@@ -0,0 +1,28 @@
1
+ import type { contract } from "@automate.ax/api-contract";
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 {
16
+ /** Automate.ax API key sent through the `x-api-key` header. */
17
+ apiKey: Credential;
18
+ }
19
+ /**
20
+ * Creates a type-safe client for every procedure in the public API contract.
21
+ *
22
+ * Credential callbacks are evaluated for every request, allowing callers to
23
+ * rotate API keys without recreating the client.
24
+ *
25
+ * @param options - Authentication and transport configuration.
26
+ */
27
+ export declare function createClient(options: ClientOptions): Client;
28
+ export {};
package/dist/index.js ADDED
@@ -0,0 +1,33 @@
1
+ import { createORPCClient } from "@orpc/client";
2
+ import { RPCLink } from "@orpc/client/fetch";
3
+ const DEFAULT_RPC_URL = "https://automate.ax/api/rpc";
4
+ /**
5
+ * Creates a type-safe client for every procedure in the public API contract.
6
+ *
7
+ * Credential callbacks are evaluated for every request, allowing callers to
8
+ * rotate API keys without recreating the client.
9
+ *
10
+ * @param options - Authentication and transport configuration.
11
+ */
12
+ export function createClient(options) {
13
+ const customFetch = options.fetch;
14
+ return createORPCClient(new RPCLink({
15
+ url: options.url ?? DEFAULT_RPC_URL,
16
+ 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"
21
+ ? await options.apiKey()
22
+ : options.apiKey;
23
+ if (!credential) {
24
+ throw new Error("API credentials are unavailable.");
25
+ }
26
+ headers.set("x-api-key", credential);
27
+ return headers;
28
+ },
29
+ ...(customFetch && {
30
+ fetch: (request, init) => customFetch(request, init),
31
+ }),
32
+ }));
33
+ }
package/package.json ADDED
@@ -0,0 +1,61 @@
1
+ {
2
+ "name": "@automate.ax/client",
3
+ "version": "0.1.3",
4
+ "description": "Type-safe client for the Automate.ax API.",
5
+ "license": "MIT",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "https://github.com/zachsents/automate.ax.git",
9
+ "directory": "packages/client"
10
+ },
11
+ "homepage": "https://automate.ax",
12
+ "bugs": {
13
+ "url": "https://github.com/zachsents/automate.ax/issues"
14
+ },
15
+ "type": "module",
16
+ "publishConfig": {
17
+ "access": "public"
18
+ },
19
+ "zshy": {
20
+ "exports": {
21
+ ".": "./src/index.ts"
22
+ },
23
+ "cjs": false
24
+ },
25
+ "dependencies": {
26
+ "@automate.ax/api-contract": "0.1.3",
27
+ "@orpc/client": "1.13.14",
28
+ "@orpc/contract": "1.13.14"
29
+ },
30
+ "devDependencies": {
31
+ "@internal/config": "0.0.0",
32
+ "@types/bun": "latest",
33
+ "zshy": "^0.7.2"
34
+ },
35
+ "scripts": {
36
+ "typecheck": "tsc --noEmit",
37
+ "lint": "oxlint --type-aware",
38
+ "lint:fix": "oxlint --type-aware --fix-suggestions",
39
+ "check": "bun run typecheck && bun run lint",
40
+ "test": "bun test",
41
+ "build": "zshy -p tsconfig.build.json",
42
+ "prepublishOnly": "bun run check && bun run test && bun run build"
43
+ },
44
+ "files": [
45
+ "dist",
46
+ "README.md",
47
+ "LICENSE"
48
+ ],
49
+ "main": "./dist/index.js",
50
+ "module": "./dist/index.js",
51
+ "types": "./dist/index.d.ts",
52
+ "engines": {
53
+ "node": ">=24"
54
+ },
55
+ "exports": {
56
+ ".": {
57
+ "types": "./dist/index.d.ts",
58
+ "default": "./dist/index.js"
59
+ }
60
+ }
61
+ }