@fetchbrain.com/sdk 0.5.1 → 0.7.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 +73 -23
- package/dist/index.d.mts +38 -6
- package/dist/index.d.ts +38 -6
- package/dist/index.js +289 -64
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +289 -64
- package/dist/index.mjs.map +1 -1
- package/dist/mock/index.d.mts +1 -1
- package/dist/mock/index.d.ts +1 -1
- package/dist/{types-BMwfPE5J.d.mts → types-CSG4BekA.d.mts} +22 -7
- package/dist/{types-BMwfPE5J.d.ts → types-CSG4BekA.d.ts} +22 -7
- package/package.json +1 -1
package/dist/mock/index.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { R as RawRequest, a as RecallResult,
|
|
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
|
package/dist/mock/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { R as RawRequest, a as RecallResult,
|
|
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
|
|
@@ -9,6 +9,15 @@ type MemoryDepth = "fresh" | "recent" | "standard" | "deep";
|
|
|
9
9
|
interface FetchBrainConfig {
|
|
10
10
|
/** API key for authentication */
|
|
11
11
|
apiKey: string;
|
|
12
|
+
/**
|
|
13
|
+
* Name this scraper so it gets its own memory (otherwise every scraper on
|
|
14
|
+
* your account outside Apify shares one default memory). Same as setting the
|
|
15
|
+
* FETCHBRAIN_SCRAPER_ID env var; a valid option wins, an empty or invalid one
|
|
16
|
+
* falls back to the env var. Lowercase letters, digits, '.', '_' and '-',
|
|
17
|
+
* max 64, starting with a letter or digit. Invalid names are ignored with a
|
|
18
|
+
* warning. On Apify a name overrides the actor id.
|
|
19
|
+
*/
|
|
20
|
+
scraper?: string;
|
|
12
21
|
/** Base URL for API (defaults to production) */
|
|
13
22
|
baseUrl?: string;
|
|
14
23
|
/** How far back the brain recalls: fresh=1h, recent=24h, standard=7d, deep=30d */
|
|
@@ -80,7 +89,7 @@ interface FetchBrainConfig {
|
|
|
80
89
|
* Default: false
|
|
81
90
|
*/
|
|
82
91
|
refreshOnRebuild?: boolean;
|
|
83
|
-
/** Request timeout in ms (default:
|
|
92
|
+
/** Request timeout in ms (default: 1500ms; see DEFAULT_TIMEOUT in client.ts) */
|
|
84
93
|
timeout?: number;
|
|
85
94
|
/** Enable debug logging */
|
|
86
95
|
debug?: boolean;
|
|
@@ -104,12 +113,18 @@ interface FetchBrainConfig {
|
|
|
104
113
|
*/
|
|
105
114
|
telemetry?: TelemetryConfig;
|
|
106
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>[];
|
|
107
122
|
/** Info passed to `onRecalled` when remembered data is delivered in place of a live scrape */
|
|
108
123
|
interface RecalledEvent {
|
|
109
124
|
url: string;
|
|
110
125
|
label?: string;
|
|
111
126
|
userData?: Record<string, unknown>;
|
|
112
|
-
data:
|
|
127
|
+
data: LearnedData;
|
|
113
128
|
}
|
|
114
129
|
/** The raw request the SDK forwards; the API derives identity from a subset. */
|
|
115
130
|
interface RawRequest {
|
|
@@ -133,13 +148,13 @@ interface RecallRequest {
|
|
|
133
148
|
/** Single recall result (matched by ref) */
|
|
134
149
|
interface RecallResultItem {
|
|
135
150
|
ref: string;
|
|
136
|
-
data?:
|
|
151
|
+
data?: LearnedData;
|
|
137
152
|
}
|
|
138
153
|
/** Recall response from the API */
|
|
139
154
|
interface RecallResponse {
|
|
140
155
|
known: {
|
|
141
156
|
ref: string;
|
|
142
|
-
data:
|
|
157
|
+
data: LearnedData;
|
|
143
158
|
}[];
|
|
144
159
|
unknown: string[];
|
|
145
160
|
}
|
|
@@ -147,7 +162,7 @@ interface RecallResponse {
|
|
|
147
162
|
interface LearnRequest {
|
|
148
163
|
entries: {
|
|
149
164
|
request: RawRequest;
|
|
150
|
-
data:
|
|
165
|
+
data: LearnedData;
|
|
151
166
|
}[];
|
|
152
167
|
build?: string;
|
|
153
168
|
}
|
|
@@ -168,7 +183,7 @@ interface StatsResponse {
|
|
|
168
183
|
/** Result of a recall */
|
|
169
184
|
interface RecallResult {
|
|
170
185
|
known: boolean;
|
|
171
|
-
data?:
|
|
186
|
+
data?: LearnedData;
|
|
172
187
|
fallback?: boolean;
|
|
173
188
|
}
|
|
174
189
|
/** Response from a natural-language ask, answered from everything the account has learned */
|
|
@@ -271,4 +286,4 @@ interface TelemetryResponse {
|
|
|
271
286
|
status: "success" | "partial" | "error";
|
|
272
287
|
}
|
|
273
288
|
|
|
274
|
-
export type { AskResponse as A, BatchConfig as B, CircuitState as C, FetchBrainConfig as F,
|
|
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 };
|
|
@@ -9,6 +9,15 @@ type MemoryDepth = "fresh" | "recent" | "standard" | "deep";
|
|
|
9
9
|
interface FetchBrainConfig {
|
|
10
10
|
/** API key for authentication */
|
|
11
11
|
apiKey: string;
|
|
12
|
+
/**
|
|
13
|
+
* Name this scraper so it gets its own memory (otherwise every scraper on
|
|
14
|
+
* your account outside Apify shares one default memory). Same as setting the
|
|
15
|
+
* FETCHBRAIN_SCRAPER_ID env var; a valid option wins, an empty or invalid one
|
|
16
|
+
* falls back to the env var. Lowercase letters, digits, '.', '_' and '-',
|
|
17
|
+
* max 64, starting with a letter or digit. Invalid names are ignored with a
|
|
18
|
+
* warning. On Apify a name overrides the actor id.
|
|
19
|
+
*/
|
|
20
|
+
scraper?: string;
|
|
12
21
|
/** Base URL for API (defaults to production) */
|
|
13
22
|
baseUrl?: string;
|
|
14
23
|
/** How far back the brain recalls: fresh=1h, recent=24h, standard=7d, deep=30d */
|
|
@@ -80,7 +89,7 @@ interface FetchBrainConfig {
|
|
|
80
89
|
* Default: false
|
|
81
90
|
*/
|
|
82
91
|
refreshOnRebuild?: boolean;
|
|
83
|
-
/** Request timeout in ms (default:
|
|
92
|
+
/** Request timeout in ms (default: 1500ms; see DEFAULT_TIMEOUT in client.ts) */
|
|
84
93
|
timeout?: number;
|
|
85
94
|
/** Enable debug logging */
|
|
86
95
|
debug?: boolean;
|
|
@@ -104,12 +113,18 @@ interface FetchBrainConfig {
|
|
|
104
113
|
*/
|
|
105
114
|
telemetry?: TelemetryConfig;
|
|
106
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>[];
|
|
107
122
|
/** Info passed to `onRecalled` when remembered data is delivered in place of a live scrape */
|
|
108
123
|
interface RecalledEvent {
|
|
109
124
|
url: string;
|
|
110
125
|
label?: string;
|
|
111
126
|
userData?: Record<string, unknown>;
|
|
112
|
-
data:
|
|
127
|
+
data: LearnedData;
|
|
113
128
|
}
|
|
114
129
|
/** The raw request the SDK forwards; the API derives identity from a subset. */
|
|
115
130
|
interface RawRequest {
|
|
@@ -133,13 +148,13 @@ interface RecallRequest {
|
|
|
133
148
|
/** Single recall result (matched by ref) */
|
|
134
149
|
interface RecallResultItem {
|
|
135
150
|
ref: string;
|
|
136
|
-
data?:
|
|
151
|
+
data?: LearnedData;
|
|
137
152
|
}
|
|
138
153
|
/** Recall response from the API */
|
|
139
154
|
interface RecallResponse {
|
|
140
155
|
known: {
|
|
141
156
|
ref: string;
|
|
142
|
-
data:
|
|
157
|
+
data: LearnedData;
|
|
143
158
|
}[];
|
|
144
159
|
unknown: string[];
|
|
145
160
|
}
|
|
@@ -147,7 +162,7 @@ interface RecallResponse {
|
|
|
147
162
|
interface LearnRequest {
|
|
148
163
|
entries: {
|
|
149
164
|
request: RawRequest;
|
|
150
|
-
data:
|
|
165
|
+
data: LearnedData;
|
|
151
166
|
}[];
|
|
152
167
|
build?: string;
|
|
153
168
|
}
|
|
@@ -168,7 +183,7 @@ interface StatsResponse {
|
|
|
168
183
|
/** Result of a recall */
|
|
169
184
|
interface RecallResult {
|
|
170
185
|
known: boolean;
|
|
171
|
-
data?:
|
|
186
|
+
data?: LearnedData;
|
|
172
187
|
fallback?: boolean;
|
|
173
188
|
}
|
|
174
189
|
/** Response from a natural-language ask, answered from everything the account has learned */
|
|
@@ -271,4 +286,4 @@ interface TelemetryResponse {
|
|
|
271
286
|
status: "success" | "partial" | "error";
|
|
272
287
|
}
|
|
273
288
|
|
|
274
|
-
export type { AskResponse as A, BatchConfig as B, CircuitState as C, FetchBrainConfig as F,
|
|
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.
|
|
3
|
+
"version": "0.7.0",
|
|
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",
|