@productcraft/trawl 0.1.3 → 0.2.0

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.
Files changed (2) hide show
  1. package/README.md +17 -3
  2. package/package.json +2 -2
package/README.md CHANGED
@@ -23,7 +23,8 @@ import: `npm install productcraft`.
23
23
  ```ts
24
24
  import { Trawl } from "@productcraft/trawl";
25
25
 
26
- const trawl = new Trawl({ auth: { type: "apiKey", key: process.env.PCFT_KEY! } });
26
+ // Reads PRODUCTCRAFT_API_KEY from the environment
27
+ const trawl = new Trawl();
27
28
 
28
29
  // Submit an extraction job (workspace-scoped).
29
30
  const { data, error } = await trawl.client.POST(
@@ -51,10 +52,23 @@ register a webhook (`POST /v1/workspaces/{workspaceId}/webhooks`) to have
51
52
  the terminal result delivered to you. Job submission is rate-limited per
52
53
  workspace (default 10/min); a `429` carries a `Retry-After` header.
53
54
 
55
+ ## Credentials from the environment
56
+
57
+ Server-side, omit `auth` and the client reads your workspace key from the environment:
58
+
59
+ ```bash
60
+ # .env
61
+ PRODUCTCRAFT_API_KEY=pcft_live_...
62
+ ```
63
+
64
+ - An explicit `auth` always wins over the environment.
65
+ - Hosts are never read from the environment. Override them in code with `baseUrl`.
66
+ - This is a server-only fallback. Never put a key in `NEXT_PUBLIC_*` or any other variable a bundler inlines into browser code.
67
+
54
68
  ## Auth
55
69
 
56
- Pass a workspace API key (`pcft_live_*`) as `{ type: "apiKey", key }`. The
57
- client sets `Authorization: Bearer <key>` on every request.
70
+ Pass a workspace API key (`pcft_live_*`) as `{ type: "apiKey", key }`, or omit
71
+ `auth` to use `PRODUCTCRAFT_API_KEY` (see above). The client sets `Authorization: Bearer <key>` on every request.
58
72
 
59
73
  ## License
60
74
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@productcraft/trawl",
3
- "version": "0.1.3",
3
+ "version": "0.2.0",
4
4
  "description": "AI web-extraction — submit a JSON Schema + natural-language description, get schema-conforming data extracted from the live web and delivered to an HMAC-signed webhook via ProductCraft Trawl. Generated from the production OpenAPI spec.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",
@@ -45,7 +45,7 @@
45
45
  },
46
46
  "dependencies": {
47
47
  "openapi-fetch": "^0.13.0",
48
- "@productcraft/core": "^0.2.1"
48
+ "@productcraft/core": "^0.3.0"
49
49
  },
50
50
  "scripts": {
51
51
  "build": "tsup"