@fetchbrain.com/sdk 0.6.0 → 0.7.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.
@@ -1,4 +1,4 @@
1
- import { R as RawRequest, a as RecallResult, L as LearnResponse, S as StatsResponse, A as AskResponse, F as FetchBrainConfig } from '../types-B1MFygnZ.mjs';
1
+ import { R as RawRequest, a as RecallResult, b as LearnResponse, S as StatsResponse, A as AskResponse, F as FetchBrainConfig } from '../types-CSG4BekA.mjs';
2
2
 
3
3
  /**
4
4
  * Mock FetchBrain for unit testing
@@ -1,4 +1,4 @@
1
- import { R as RawRequest, a as RecallResult, L as LearnResponse, S as StatsResponse, A as AskResponse, F as FetchBrainConfig } from '../types-B1MFygnZ.js';
1
+ import { R as RawRequest, a as RecallResult, b as LearnResponse, S as StatsResponse, A as AskResponse, F as FetchBrainConfig } from '../types-CSG4BekA.js';
2
2
 
3
3
  /**
4
4
  * Mock FetchBrain for unit testing
@@ -89,7 +89,7 @@ interface FetchBrainConfig {
89
89
  * Default: false
90
90
  */
91
91
  refreshOnRebuild?: boolean;
92
- /** Request timeout in ms (default: 500ms for fast degradation) */
92
+ /** Request timeout in ms (default: 1500ms; see DEFAULT_TIMEOUT in client.ts) */
93
93
  timeout?: number;
94
94
  /** Enable debug logging */
95
95
  debug?: boolean;
@@ -113,12 +113,18 @@ interface FetchBrainConfig {
113
113
  */
114
114
  telemetry?: TelemetryConfig;
115
115
  }
116
+ /**
117
+ * What one remembered request holds: the record the page pushed, or every
118
+ * record when the page pushed several (a listing page). Recalled arrays are
119
+ * pushed as-is — Crawlee's pushData accepts both shapes.
120
+ */
121
+ type LearnedData = Record<string, unknown> | Record<string, unknown>[];
116
122
  /** Info passed to `onRecalled` when remembered data is delivered in place of a live scrape */
117
123
  interface RecalledEvent {
118
124
  url: string;
119
125
  label?: string;
120
126
  userData?: Record<string, unknown>;
121
- data: Record<string, unknown>;
127
+ data: LearnedData;
122
128
  }
123
129
  /** The raw request the SDK forwards; the API derives identity from a subset. */
124
130
  interface RawRequest {
@@ -142,13 +148,13 @@ interface RecallRequest {
142
148
  /** Single recall result (matched by ref) */
143
149
  interface RecallResultItem {
144
150
  ref: string;
145
- data?: Record<string, unknown>;
151
+ data?: LearnedData;
146
152
  }
147
153
  /** Recall response from the API */
148
154
  interface RecallResponse {
149
155
  known: {
150
156
  ref: string;
151
- data: Record<string, unknown>;
157
+ data: LearnedData;
152
158
  }[];
153
159
  unknown: string[];
154
160
  }
@@ -156,7 +162,7 @@ interface RecallResponse {
156
162
  interface LearnRequest {
157
163
  entries: {
158
164
  request: RawRequest;
159
- data: Record<string, unknown>;
165
+ data: LearnedData;
160
166
  }[];
161
167
  build?: string;
162
168
  }
@@ -177,7 +183,7 @@ interface StatsResponse {
177
183
  /** Result of a recall */
178
184
  interface RecallResult {
179
185
  known: boolean;
180
- data?: Record<string, unknown>;
186
+ data?: LearnedData;
181
187
  fallback?: boolean;
182
188
  }
183
189
  /** Response from a natural-language ask, answered from everything the account has learned */
@@ -280,4 +286,4 @@ interface TelemetryResponse {
280
286
  status: "success" | "partial" | "error";
281
287
  }
282
288
 
283
- export type { AskResponse as A, BatchConfig as B, CircuitState as C, FetchBrainConfig as F, LearnResponse as L, MemoryDepth as M, RawRequest as R, StatsResponse as S, TelemetryData as T, RecallResult as a, TelemetryConfig as b, CircuitBreakerConfig as c, Logger as d, LogLevel as e, RecallRequest as f, RecallResponse as g, RecallResultItem as h, LearnRequest as i, RecalledEvent as j, TelemetryRequest as k, TelemetryResponse as l };
289
+ export type { AskResponse as A, BatchConfig as B, CircuitState as C, FetchBrainConfig as F, LearnedData as L, MemoryDepth as M, RawRequest as R, StatsResponse as S, TelemetryData as T, RecallResult as a, LearnResponse as b, TelemetryConfig as c, CircuitBreakerConfig as d, Logger as e, LogLevel as f, RecallRequest as g, RecallResponse as h, RecallResultItem as i, LearnRequest as j, RecalledEvent as k, TelemetryRequest as l, TelemetryResponse as m };
@@ -89,7 +89,7 @@ interface FetchBrainConfig {
89
89
  * Default: false
90
90
  */
91
91
  refreshOnRebuild?: boolean;
92
- /** Request timeout in ms (default: 500ms for fast degradation) */
92
+ /** Request timeout in ms (default: 1500ms; see DEFAULT_TIMEOUT in client.ts) */
93
93
  timeout?: number;
94
94
  /** Enable debug logging */
95
95
  debug?: boolean;
@@ -113,12 +113,18 @@ interface FetchBrainConfig {
113
113
  */
114
114
  telemetry?: TelemetryConfig;
115
115
  }
116
+ /**
117
+ * What one remembered request holds: the record the page pushed, or every
118
+ * record when the page pushed several (a listing page). Recalled arrays are
119
+ * pushed as-is — Crawlee's pushData accepts both shapes.
120
+ */
121
+ type LearnedData = Record<string, unknown> | Record<string, unknown>[];
116
122
  /** Info passed to `onRecalled` when remembered data is delivered in place of a live scrape */
117
123
  interface RecalledEvent {
118
124
  url: string;
119
125
  label?: string;
120
126
  userData?: Record<string, unknown>;
121
- data: Record<string, unknown>;
127
+ data: LearnedData;
122
128
  }
123
129
  /** The raw request the SDK forwards; the API derives identity from a subset. */
124
130
  interface RawRequest {
@@ -142,13 +148,13 @@ interface RecallRequest {
142
148
  /** Single recall result (matched by ref) */
143
149
  interface RecallResultItem {
144
150
  ref: string;
145
- data?: Record<string, unknown>;
151
+ data?: LearnedData;
146
152
  }
147
153
  /** Recall response from the API */
148
154
  interface RecallResponse {
149
155
  known: {
150
156
  ref: string;
151
- data: Record<string, unknown>;
157
+ data: LearnedData;
152
158
  }[];
153
159
  unknown: string[];
154
160
  }
@@ -156,7 +162,7 @@ interface RecallResponse {
156
162
  interface LearnRequest {
157
163
  entries: {
158
164
  request: RawRequest;
159
- data: Record<string, unknown>;
165
+ data: LearnedData;
160
166
  }[];
161
167
  build?: string;
162
168
  }
@@ -177,7 +183,7 @@ interface StatsResponse {
177
183
  /** Result of a recall */
178
184
  interface RecallResult {
179
185
  known: boolean;
180
- data?: Record<string, unknown>;
186
+ data?: LearnedData;
181
187
  fallback?: boolean;
182
188
  }
183
189
  /** Response from a natural-language ask, answered from everything the account has learned */
@@ -280,4 +286,4 @@ interface TelemetryResponse {
280
286
  status: "success" | "partial" | "error";
281
287
  }
282
288
 
283
- export type { AskResponse as A, BatchConfig as B, CircuitState as C, FetchBrainConfig as F, LearnResponse as L, MemoryDepth as M, RawRequest as R, StatsResponse as S, TelemetryData as T, RecallResult as a, TelemetryConfig as b, CircuitBreakerConfig as c, Logger as d, LogLevel as e, RecallRequest as f, RecallResponse as g, RecallResultItem as h, LearnRequest as i, RecalledEvent as j, TelemetryRequest as k, TelemetryResponse as l };
289
+ export type { AskResponse as A, BatchConfig as B, CircuitState as C, FetchBrainConfig as F, LearnedData as L, MemoryDepth as M, RawRequest as R, StatsResponse as S, TelemetryData as T, RecallResult as a, LearnResponse as b, TelemetryConfig as c, CircuitBreakerConfig as d, Logger as e, LogLevel as f, RecallRequest as g, RecallResponse as h, RecallResultItem as i, LearnRequest as j, RecalledEvent as k, TelemetryRequest as l, TelemetryResponse as m };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fetchbrain.com/sdk",
3
- "version": "0.6.0",
3
+ "version": "0.7.1",
4
4
  "description": "FetchBrain SDK — make your Crawlee scrapers smarter with every run; recall before you fetch, teach what you learn.",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",
@@ -68,6 +68,7 @@
68
68
  "express": "^4.18.2",
69
69
  "husky": "^9.1.7",
70
70
  "lint-staged": "^16.2.7",
71
+ "playwright": "^1.65.1",
71
72
  "tsup": "^8.0.1",
72
73
  "tsx": "^4.6.2",
73
74
  "typescript": "^5.3.2",