@productcraft/trawl 0.1.2 → 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.
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/dist/index.d.cts CHANGED
@@ -408,7 +408,9 @@ interface components {
408
408
  * "type": "object"
409
409
  * }
410
410
  */
411
- json_schema: Record<string, never>;
411
+ json_schema: {
412
+ [key: string]: unknown;
413
+ };
412
414
  /**
413
415
  * @description Maximum number of agent steps (one LLM call each) before the job stops. Defaults to 20. Multi-source extractions typically need 40+. The server additionally clamps this to an operator ceiling, so a very large value does not guarantee a very long run — `timeout_s` still applies.
414
416
  * @default 20
@@ -528,10 +530,16 @@ interface components {
528
530
  enqueued_at: string;
529
531
  error: string | null;
530
532
  id: string;
531
- json_schema: Record<string, never>;
533
+ /** @description The JSON Schema the job was created with. */
534
+ json_schema: {
535
+ [key: string]: unknown;
536
+ };
532
537
  max_steps: number;
533
538
  model_tier: string;
534
- result: Record<string, never> | null;
539
+ /** @description The extracted data, shaped by `json_schema`. Null until the job succeeds. */
540
+ result: {
541
+ [key: string]: unknown;
542
+ } | null;
535
543
  started_at: string | null;
536
544
  /** @enum {string} */
537
545
  status: "queued" | "running" | "succeeded" | "failed" | "cancelled";
package/dist/index.d.ts CHANGED
@@ -408,7 +408,9 @@ interface components {
408
408
  * "type": "object"
409
409
  * }
410
410
  */
411
- json_schema: Record<string, never>;
411
+ json_schema: {
412
+ [key: string]: unknown;
413
+ };
412
414
  /**
413
415
  * @description Maximum number of agent steps (one LLM call each) before the job stops. Defaults to 20. Multi-source extractions typically need 40+. The server additionally clamps this to an operator ceiling, so a very large value does not guarantee a very long run — `timeout_s` still applies.
414
416
  * @default 20
@@ -528,10 +530,16 @@ interface components {
528
530
  enqueued_at: string;
529
531
  error: string | null;
530
532
  id: string;
531
- json_schema: Record<string, never>;
533
+ /** @description The JSON Schema the job was created with. */
534
+ json_schema: {
535
+ [key: string]: unknown;
536
+ };
532
537
  max_steps: number;
533
538
  model_tier: string;
534
- result: Record<string, never> | null;
539
+ /** @description The extracted data, shaped by `json_schema`. Null until the job succeeds. */
540
+ result: {
541
+ [key: string]: unknown;
542
+ } | null;
535
543
  started_at: string | null;
536
544
  /** @enum {string} */
537
545
  status: "queued" | "running" | "succeeded" | "failed" | "cancelled";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@productcraft/trawl",
3
- "version": "0.1.2",
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"