@embed-ai/sdk 0.1.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/src/client.js ADDED
@@ -0,0 +1,306 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.TimeoutError = exports.ParseError = exports.NetworkError = exports.HttpRequestError = void 0;
7
+ exports.getClient = getClient;
8
+ exports.mbdClient = void 0;
9
+ var _effect = require("effect");
10
+ var _namespace = require("./feed/namespace.js");
11
+ // ============================================================================
12
+ // ERROR TYPES
13
+ // ============================================================================
14
+ /**
15
+ * Network-related errors (connection issues, DNS failures, etc.)
16
+ */
17
+ class NetworkError extends _effect.Data.TaggedError("NetworkError") {}
18
+ /**
19
+ * HTTP response errors (4xx, 5xx status codes)
20
+ */
21
+ exports.NetworkError = NetworkError;
22
+ class HttpRequestError extends _effect.Data.TaggedError("HttpRequestError") {}
23
+ /**
24
+ * JSON parsing errors
25
+ */
26
+ exports.HttpRequestError = HttpRequestError;
27
+ class ParseError extends _effect.Data.TaggedError("ParseError") {}
28
+ /**
29
+ * Timeout errors
30
+ */
31
+ exports.ParseError = ParseError;
32
+ class TimeoutError extends _effect.Data.TaggedError("TimeoutError") {}
33
+ /**
34
+ * Default retry configuration
35
+ */
36
+ exports.TimeoutError = TimeoutError;
37
+ const DEFAULT_RETRY_CONFIG = {
38
+ exponentialBackoff: true,
39
+ initialDelay: 1000,
40
+ maxDelay: 10000,
41
+ maxRetries: 3,
42
+ retryableStatusCodes: [500, 502, 503, 504],
43
+ timeoutMs: 30000
44
+ };
45
+ /**
46
+ * Default configuration
47
+ */
48
+ const DEFAULT_CONFIG = {
49
+ baseUrl: "https://api.mbd.xyz",
50
+ title: "embed_sdk_typescript"
51
+ };
52
+ // ============================================================================
53
+ // HTTP CLIENT IMPLEMENTATION
54
+ // ============================================================================
55
+ /**
56
+ * Effect-based HTTP client for mbd API with proper error handling and retries
57
+ */
58
+ class HttpClient {
59
+ config;
60
+ constructor(config) {
61
+ this.config = {
62
+ baseUrl: config.baseUrl ?? DEFAULT_CONFIG.baseUrl,
63
+ title: config.title ?? DEFAULT_CONFIG.title,
64
+ referer: config.referer ?? "",
65
+ token: config.token,
66
+ retry: {
67
+ ...DEFAULT_RETRY_CONFIG,
68
+ ...config.retry
69
+ }
70
+ };
71
+ }
72
+ /**
73
+ * Create a timeout effect that fails after the specified duration
74
+ */
75
+ createTimeoutEffect(timeoutMs) {
76
+ return (0, _effect.pipe)(_effect.Effect.sleep(`${timeoutMs} millis`), _effect.Effect.flatMap(() => _effect.Effect.fail(new TimeoutError({
77
+ message: `Request timed out after ${timeoutMs}ms`,
78
+ timeoutMs
79
+ }))));
80
+ }
81
+ /**
82
+ * Build URL with query parameters
83
+ */
84
+ buildUrl(endpoint, baseUrl, queryParams) {
85
+ const url = `${baseUrl ?? this.config.baseUrl}${endpoint}`;
86
+ if (!queryParams || Object.keys(queryParams).length === 0) {
87
+ return url;
88
+ }
89
+ const searchParams = new URLSearchParams();
90
+ for (const [key, value] of Object.entries(queryParams)) {
91
+ if (value !== undefined && value !== null) {
92
+ searchParams.append(key, value);
93
+ }
94
+ }
95
+ const queryString = searchParams.toString();
96
+ return queryString ? `${url}?${queryString}` : url;
97
+ }
98
+ /**
99
+ * Perform the actual fetch request wrapped in an Effect
100
+ */
101
+ performFetch(endpoint, method, baseUrl, body, queryParams, useBasicAuth) {
102
+ const url = this.buildUrl(endpoint, baseUrl, queryParams);
103
+ return _effect.Effect.tryPromise({
104
+ try: async () => {
105
+ const requestOptions = {
106
+ method,
107
+ headers: {
108
+ "Authorization": useBasicAuth ? `Basic ${this.config.token}` : `Bearer ${this.config.token}`,
109
+ "Accept": "application/json",
110
+ "HTTP-Referer": this.config.referer,
111
+ "X-Title": this.config.title
112
+ }
113
+ };
114
+ // Add Content-Type and body for POST/PATCH requests
115
+ if (method !== "GET" && body) {
116
+ requestOptions.headers = {
117
+ ...requestOptions.headers,
118
+ "Content-Type": "application/json"
119
+ };
120
+ requestOptions.body = JSON.stringify(body);
121
+ }
122
+ const response = await fetch(url, requestOptions);
123
+ // Check if response is ok
124
+ if (!response.ok) {
125
+ const errorBody = await response.text().catch(() => "");
126
+ throw new HttpRequestError({
127
+ status: response.status,
128
+ statusText: response.statusText,
129
+ url,
130
+ body: errorBody
131
+ });
132
+ }
133
+ // Parse JSON response
134
+ try {
135
+ return await response.json();
136
+ } catch (parseError) {
137
+ throw new ParseError({
138
+ message: "Failed to parse JSON response",
139
+ cause: parseError
140
+ });
141
+ }
142
+ },
143
+ catch: error => {
144
+ // Handle different error types
145
+ if (error instanceof HttpRequestError || error instanceof ParseError) {
146
+ return error;
147
+ }
148
+ // Network or other fetch errors
149
+ return new NetworkError({
150
+ message: error instanceof Error ? error.message : "Unknown network error",
151
+ cause: error
152
+ });
153
+ }
154
+ });
155
+ }
156
+ /**
157
+ * Create a retry schedule based on configuration
158
+ */
159
+ createRetrySchedule() {
160
+ const {
161
+ exponentialBackoff,
162
+ initialDelay,
163
+ maxDelay,
164
+ maxRetries,
165
+ retryableStatusCodes
166
+ } = this.config.retry;
167
+ let baseSchedule;
168
+ if (exponentialBackoff) {
169
+ baseSchedule = (0, _effect.pipe)(_effect.Schedule.exponential(`${initialDelay} millis`), _effect.Schedule.either(_effect.Schedule.spaced(`${maxDelay} millis`)), _effect.Schedule.compose(_effect.Schedule.recurs(maxRetries)));
170
+ } else {
171
+ baseSchedule = (0, _effect.pipe)(_effect.Schedule.spaced(`${initialDelay} millis`), _effect.Schedule.compose(_effect.Schedule.recurs(maxRetries)));
172
+ }
173
+ // Only retry on specific errors
174
+ return (0, _effect.pipe)(baseSchedule, _effect.Schedule.whileInput(error => {
175
+ switch (error._tag) {
176
+ case "NetworkError":
177
+ return true;
178
+ // Always retry network errors
179
+ case "TimeoutError":
180
+ return true;
181
+ // Always retry timeout errors
182
+ case "HttpRequestError":
183
+ return retryableStatusCodes.includes(error.status);
184
+ case "ParseError":
185
+ return false;
186
+ // Don't retry parse errors
187
+ default:
188
+ return false;
189
+ }
190
+ }));
191
+ }
192
+ /**
193
+ * Execute request with timeout and retry logic
194
+ */
195
+ executeRequestWithRetries(endpoint, method, baseUrl, body, queryParams, useBasicAuth) {
196
+ const fetchEffect = this.performFetch(endpoint, method, baseUrl, body, queryParams, useBasicAuth);
197
+ const timeoutEffect = this.createTimeoutEffect(this.config.retry.timeoutMs);
198
+ // Race fetch against timeout
199
+ const requestWithTimeout = _effect.Effect.race(fetchEffect, timeoutEffect);
200
+ // Apply retry logic
201
+ const retrySchedule = this.createRetrySchedule();
202
+ return (0, _effect.pipe)(requestWithTimeout, _effect.Effect.retry(retrySchedule), _effect.Effect.tapError(error => _effect.Effect.logError("HTTP request failed after retries", error)));
203
+ }
204
+ /**
205
+ * Make a POST request to the API with Effect-based error handling and retries
206
+ */
207
+ async post(endpoint, body) {
208
+ const effect = this.executeRequestWithRetries(endpoint, "POST", undefined, body);
209
+ return _effect.Effect.runPromise(effect);
210
+ }
211
+ /**
212
+ * Make a GET request to the API with Effect-based error handling and retries
213
+ */
214
+ async get(endpoint, queryParams) {
215
+ const effect = this.executeRequestWithRetries(endpoint, "GET", undefined, undefined, queryParams);
216
+ return _effect.Effect.runPromise(effect);
217
+ }
218
+ /**
219
+ * Make a PATCH request to the API with Effect-based error handling and retries
220
+ */
221
+ async patch(endpoint, body) {
222
+ const effect = this.executeRequestWithRetries(endpoint, "PATCH", undefined, body);
223
+ return _effect.Effect.runPromise(effect);
224
+ }
225
+ /**
226
+ * Make a request to a custom base URL
227
+ */
228
+ async requestWithCustomBaseUrl(method, baseUrl, endpoint, body, queryParams, useBasicAuth) {
229
+ const effect = this.executeRequestWithRetries(endpoint, method, baseUrl, body, queryParams, useBasicAuth);
230
+ return _effect.Effect.runPromise(effect);
231
+ }
232
+ }
233
+ // ============================================================================
234
+ // MAIN CLIENT
235
+ // ============================================================================
236
+ /**
237
+ * Main Embed API client providing access to personalized feeds and feed management
238
+ *
239
+ * @example
240
+ * ```typescript
241
+ * import { getClient } from '@embed-ai/sdk'
242
+ *
243
+ * const client = getClient('your-api-key')
244
+ *
245
+ * // Get personalized feed
246
+ * const feed = await client.feed.byUserId('16085')
247
+ *
248
+ * // Create a custom feed
249
+ * const customFeed = await client.feed.createConfig({
250
+ * name: 'My Custom Feed',
251
+ * description: 'A feed for my app'
252
+ * })
253
+ * ```
254
+ */
255
+ class mbdClient {
256
+ http;
257
+ feed;
258
+ constructor(token, options) {
259
+ if (!token && !options?.token) {
260
+ throw new Error("Token is required");
261
+ }
262
+ const config = {
263
+ token: token || options?.token || "",
264
+ ...options
265
+ };
266
+ this.http = new HttpClient(config);
267
+ this.feed = new _namespace.FeedNamespace(this.http);
268
+ }
269
+ }
270
+ /**
271
+ * Get a new Embed Client instance
272
+ *
273
+ * @param token - API token required for authentication
274
+ * @param options - Optional client configuration
275
+ * @returns Embed Client instance with namespaced methods
276
+ *
277
+ * @example
278
+ * ```typescript
279
+ * import { getClient } from '@embed-ai/sdk'
280
+ *
281
+ * // Basic usage
282
+ * const client = getClient('your-api-key')
283
+ *
284
+ * // Get personalized feed
285
+ * const feed = await client.feed.byUserId('16085')
286
+ *
287
+ * // Create a custom feed
288
+ * const customFeed = await client.feed.createConfig({
289
+ * name: 'My Custom Feed',
290
+ * description: 'A feed for my app'
291
+ * })
292
+ *
293
+ * // With configuration
294
+ * const client = getClient('your-api-key', {
295
+ * retry: {
296
+ * maxRetries: 3,
297
+ * timeoutMs: 30000
298
+ * }
299
+ * })
300
+ * ```
301
+ */
302
+ exports.mbdClient = mbdClient;
303
+ function getClient(token, options) {
304
+ return new mbdClient(token, options);
305
+ }
306
+ //# sourceMappingURL=client.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.js","names":["_effect","require","_namespace","NetworkError","Data","TaggedError","exports","HttpRequestError","ParseError","TimeoutError","DEFAULT_RETRY_CONFIG","exponentialBackoff","initialDelay","maxDelay","maxRetries","retryableStatusCodes","timeoutMs","DEFAULT_CONFIG","baseUrl","title","HttpClient","config","constructor","referer","token","retry","createTimeoutEffect","pipe","Effect","sleep","flatMap","fail","message","buildUrl","endpoint","queryParams","url","Object","keys","length","searchParams","URLSearchParams","key","value","entries","undefined","append","queryString","toString","performFetch","method","body","useBasicAuth","tryPromise","try","requestOptions","headers","JSON","stringify","response","fetch","ok","errorBody","text","catch","status","statusText","json","parseError","cause","error","Error","createRetrySchedule","baseSchedule","Schedule","exponential","either","spaced","compose","recurs","whileInput","_tag","includes","executeRequestWithRetries","fetchEffect","timeoutEffect","requestWithTimeout","race","retrySchedule","tapError","logError","post","effect","runPromise","get","patch","requestWithCustomBaseUrl","mbdClient","http","feed","options","FeedNamespace","getClient"],"sources":["../../src/client.ts"],"sourcesContent":[null],"mappings":";;;;;;;;AAAA,IAAAA,OAAA,GAAAC,OAAA;AACA,IAAAC,UAAA,GAAAD,OAAA;AAGA;AACA;AACA;AAEA;;;AAGM,MAAOE,YAAa,SAAQC,YAAI,CAACC,WAAW,CAAC,cAAc,CAG/D;AAEF;;;AAAAC,OAAA,CAAAH,YAAA,GAAAA,YAAA;AAGM,MAAOI,gBAAiB,SAAQH,YAAI,CAACC,WAAW,CAAC,kBAAkB,CAKvE;AAEF;;;AAAAC,OAAA,CAAAC,gBAAA,GAAAA,gBAAA;AAGM,MAAOC,UAAW,SAAQJ,YAAI,CAACC,WAAW,CAAC,YAAY,CAG3D;AAEF;;;AAAAC,OAAA,CAAAE,UAAA,GAAAA,UAAA;AAGM,MAAOC,YAAa,SAAQL,YAAI,CAACC,WAAW,CAAC,cAAc,CAG/D;AAyCF;;;AAAAC,OAAA,CAAAG,YAAA,GAAAA,YAAA;AAGA,MAAMC,oBAAoB,GAA0B;EAClDC,kBAAkB,EAAE,IAAI;EACxBC,YAAY,EAAE,IAAI;EAClBC,QAAQ,EAAE,KAAK;EACfC,UAAU,EAAE,CAAC;EACbC,oBAAoB,EAAE,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG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OAAyB;IACnD,IAAI,CAAC5E,KAAK,IAAI,CAAC4E,OAAO,EAAE5E,KAAK,EAAE;MAC7B,MAAM,IAAI+C,KAAK,CAAC,mBAAmB,CAAC;IACtC;IAEA,MAAMlD,MAAM,GAAwC;MAClDG,KAAK,EAAEA,KAAK,IAAI4E,OAAO,EAAE5E,KAAK,IAAI,EAAE;MACpC,GAAG4E;KACJ;IAED,IAAI,CAACF,IAAI,GAAG,IAAI9E,UAAU,CAACC,MAAM,CAAC;IAClC,IAAI,CAAC8E,IAAI,GAAG,IAAIE,wBAAa,CAAC,IAAI,CAACH,IAAI,CAAC;EAC1C;;AAGF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA5F,OAAA,CAAA2F,SAAA,GAAAA,SAAA;AAgCM,SAAUK,SAASA,CAAC9E,KAAc,EAAE4E,OAAyB;EACjE,OAAO,IAAIH,SAAS,CAACzE,KAAK,EAAE4E,OAAO,CAAC;AACtC","ignoreList":[]}
@@ -0,0 +1,6 @@
1
+ import type { ForYou as ForYouParams, ForYouResponse } from "@embed-ai/types";
2
+ import type { IHttpClient } from "../interfaces/index.js";
3
+ export type FeedOptions = Omit<ForYouParams, "wallet_address" | "user_id">;
4
+ export declare function byUserId(httpClient: IHttpClient, userId: string, options?: FeedOptions): Promise<ForYouResponse>;
5
+ export declare function byWalletAddress(httpClient: IHttpClient, walletAddress: string, options?: FeedOptions): Promise<ForYouResponse>;
6
+ //# sourceMappingURL=feed.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"feed.d.ts","sourceRoot":"","sources":["../../../src/feed/feed.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,IAAI,YAAY,EAAqB,cAAc,EAAE,MAAM,iBAAiB,CAAA;AAChG,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAA;AAEzD,MAAM,MAAM,WAAW,GAAG,IAAI,CAAC,YAAY,EAAE,gBAAgB,GAAG,SAAS,CAAC,CAAA;AAE1E,wBAAsB,QAAQ,CAC5B,UAAU,EAAE,WAAW,EACvB,MAAM,EAAE,MAAM,EACd,OAAO,CAAC,EAAE,WAAW,GACpB,OAAO,CAAC,cAAc,CAAC,CAczB;AAED,wBAAsB,eAAe,CACnC,UAAU,EAAE,WAAW,EACvB,aAAa,EAAE,MAAM,EACrB,OAAO,CAAC,EAAE,WAAW,GACpB,OAAO,CAAC,cAAc,CAAC,CAczB"}
@@ -0,0 +1,34 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.byUserId = byUserId;
7
+ exports.byWalletAddress = byWalletAddress;
8
+ async function byUserId(httpClient, userId, options) {
9
+ const top_k = options?.top_k ?? 25;
10
+ const impression_count = options?.impression_count ?? top_k;
11
+ const params = {
12
+ user_id: userId,
13
+ return_metadata: true,
14
+ top_k,
15
+ impression_count,
16
+ ...options
17
+ };
18
+ const response = await httpClient.post("/v2/farcaster/casts/feed/for-you", params);
19
+ return [...response.body];
20
+ }
21
+ async function byWalletAddress(httpClient, walletAddress, options) {
22
+ const top_k = options?.top_k ?? 25;
23
+ const impression_count = options?.impression_count ?? top_k;
24
+ const params = {
25
+ wallet_address: walletAddress,
26
+ return_metadata: true,
27
+ top_k,
28
+ impression_count,
29
+ ...options
30
+ };
31
+ const response = await httpClient.post("/v2/farcaster/casts/feed/for-you", params);
32
+ return [...response.body];
33
+ }
34
+ //# sourceMappingURL=feed.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"feed.js","names":["byUserId","httpClient","userId","options","top_k","impression_count","params","user_id","return_metadata","response","post","body","byWalletAddress","walletAddress","wallet_address"],"sources":["../../../src/feed/feed.ts"],"sourcesContent":[null],"mappings":";;;;;;;AAKO,eAAeA,QAAQA,CAC5BC,UAAuB,EACvBC,MAAc,EACdC,OAAqB;EAErB,MAAMC,KAAK,GAAGD,OAAO,EAAEC,KAAK,IAAI,EAAE;EAClC,MAAMC,gBAAgB,GAAGF,OAAO,EAAEE,gBAAgB,IAAID,KAAK;EAE3D,MAAME,MAAM,GAAiB;IAC3BC,OAAO,EAAEL,MAAM;IACfM,eAAe,EAAE,IAAI;IACrBJ,KAAK;IACLC,gBAAgB;IAChB,GAAGF;GACJ;EAED,MAAMM,QAAQ,GAAG,MAAMR,UAAU,CAACS,IAAI,CAAoB,kCAAkC,EAAEJ,MAAM,CAAC;EACrG,OAAO,CAAC,GAAGG,QAAQ,CAACE,IAAI,CAAC;AAC3B;AAEO,eAAeC,eAAeA,CACnCX,UAAuB,EACvBY,aAAqB,EACrBV,OAAqB;EAErB,MAAMC,KAAK,GAAGD,OAAO,EAAEC,KAAK,IAAI,EAAE;EAClC,MAAMC,gBAAgB,GAAGF,OAAO,EAAEE,gBAAgB,IAAID,KAAK;EAE3D,MAAME,MAAM,GAAiB;IAC3BQ,cAAc,EAAED,aAAa;IAC7BL,eAAe,EAAE,IAAI;IACrBJ,KAAK;IACLC,gBAAgB;IAChB,GAAGF;GACJ;EAED,MAAMM,QAAQ,GAAG,MAAMR,UAAU,CAACS,IAAI,CAAoB,kCAAkC,EAAEJ,MAAM,CAAC;EACrG,OAAO,CAAC,GAAGG,QAAQ,CAACE,IAAI,CAAC;AAC3B","ignoreList":[]}
@@ -0,0 +1,4 @@
1
+ export * from "./feed.js";
2
+ export * from "./management.js";
3
+ export * from "./namespace.js";
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/feed/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAA;AACzB,cAAc,iBAAiB,CAAA;AAC/B,cAAc,gBAAgB,CAAA"}
@@ -0,0 +1,39 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ var _feed = require("./feed.js");
7
+ Object.keys(_feed).forEach(function (key) {
8
+ if (key === "default" || key === "__esModule") return;
9
+ if (key in exports && exports[key] === _feed[key]) return;
10
+ Object.defineProperty(exports, key, {
11
+ enumerable: true,
12
+ get: function () {
13
+ return _feed[key];
14
+ }
15
+ });
16
+ });
17
+ var _management = require("./management.js");
18
+ Object.keys(_management).forEach(function (key) {
19
+ if (key === "default" || key === "__esModule") return;
20
+ if (key in exports && exports[key] === _management[key]) return;
21
+ Object.defineProperty(exports, key, {
22
+ enumerable: true,
23
+ get: function () {
24
+ return _management[key];
25
+ }
26
+ });
27
+ });
28
+ var _namespace = require("./namespace.js");
29
+ Object.keys(_namespace).forEach(function (key) {
30
+ if (key === "default" || key === "__esModule") return;
31
+ if (key in exports && exports[key] === _namespace[key]) return;
32
+ Object.defineProperty(exports, key, {
33
+ enumerable: true,
34
+ get: function () {
35
+ return _namespace[key];
36
+ }
37
+ });
38
+ });
39
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","names":["_feed","require","Object","keys","forEach","key","exports","defineProperty","enumerable","get","_management","_namespace"],"sources":["../../../src/feed/index.ts"],"sourcesContent":[null],"mappings":";;;;;AAAA,IAAAA,KAAA,GAAAC,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAH,KAAA,EAAAI,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAL,KAAA,CAAAK,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAT,KAAA,CAAAK,GAAA;IAAA;EAAA;AAAA;AACA,IAAAK,WAAA,GAAAT,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAO,WAAA,EAAAN,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAK,WAAA,CAAAL,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAC,WAAA,CAAAL,GAAA;IAAA;EAAA;AAAA;AACA,IAAAM,UAAA,GAAAV,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAQ,UAAA,EAAAP,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAM,UAAA,CAAAN,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAE,UAAA,CAAAN,GAAA;IAAA;EAAA;AAAA","ignoreList":[]}
@@ -0,0 +1,7 @@
1
+ import type { CreateFeedOptions, FeedCreateUpdateResponse, FeedGetResponse, ListFeedsResponse, UpdateFeedOptions } from "@embed-ai/types";
2
+ import type { IHttpClient } from "../interfaces/index.js";
3
+ export declare function createConfig(httpClient: IHttpClient, options: CreateFeedOptions): Promise<FeedCreateUpdateResponse>;
4
+ export declare function getConfig(httpClient: IHttpClient, configId: string): Promise<FeedGetResponse>;
5
+ export declare function listConfigs(httpClient: IHttpClient, visibility?: "private" | "public"): Promise<ListFeedsResponse>;
6
+ export declare function updateConfig(httpClient: IHttpClient, options: UpdateFeedOptions): Promise<void>;
7
+ //# sourceMappingURL=management.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"management.d.ts","sourceRoot":"","sources":["../../../src/feed/management.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,iBAAiB,EAEjB,wBAAwB,EACxB,eAAe,EAEf,iBAAiB,EACjB,iBAAiB,EAClB,MAAM,iBAAiB,CAAA;AACxB,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAA;AAIzD,wBAAsB,YAAY,CAChC,UAAU,EAAE,WAAW,EACvB,OAAO,EAAE,iBAAiB,GACzB,OAAO,CAAC,wBAAwB,CAAC,CAsCnC;AAED,wBAAsB,SAAS,CAC7B,UAAU,EAAE,WAAW,EACvB,QAAQ,EAAE,MAAM,GACf,OAAO,CAAC,eAAe,CAAC,CAU1B;AAED,wBAAsB,WAAW,CAC/B,UAAU,EAAE,WAAW,EACvB,UAAU,GAAE,SAAS,GAAG,QAAoB,GAC3C,OAAO,CAAC,iBAAiB,CAAC,CAY5B;AAED,wBAAsB,YAAY,CAChC,UAAU,EAAE,WAAW,EACvB,OAAO,EAAE,iBAAiB,GACzB,OAAO,CAAC,IAAI,CAAC,CA0Bf"}
@@ -0,0 +1,79 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.createConfig = createConfig;
7
+ exports.getConfig = getConfig;
8
+ exports.listConfigs = listConfigs;
9
+ exports.updateConfig = updateConfig;
10
+ const CONSOLE_API_BASE_URL = "https://console-api-us-west-2.mbd.xyz";
11
+ async function createConfig(httpClient, options) {
12
+ const feedConfig = {
13
+ name: options.name,
14
+ description: options.description,
15
+ endpoint: options.endpoint ?? "casts/feed/for-you",
16
+ status: options.status ?? "active",
17
+ visibility: options.visibility ?? "private",
18
+ config: {
19
+ filters: {
20
+ channels: [],
21
+ app_fids: [],
22
+ geo_locations: [],
23
+ remove_geo_locations: [],
24
+ ai_labels: [],
25
+ publication_types: [],
26
+ remove_ai_labels: [],
27
+ author_ids: [],
28
+ remove_author_ids: [],
29
+ embed_domains: [],
30
+ start_timestamp: "days_ago:7"
31
+ },
32
+ return_global_fallback: true,
33
+ scoring: "all",
34
+ ...options.config
35
+ },
36
+ feed_image_url: options.feed_image_url,
37
+ short_name: options.short_name ?? null
38
+ };
39
+ const response = await httpClient.requestWithCustomBaseUrl("POST", CONSOLE_API_BASE_URL, "/api/feed/config", feedConfig, undefined, true // Use Basic auth
40
+ );
41
+ return response.data;
42
+ }
43
+ async function getConfig(httpClient, configId) {
44
+ const response = await httpClient.requestWithCustomBaseUrl("GET", CONSOLE_API_BASE_URL, "/api/feed/config", undefined, {
45
+ config_id: configId
46
+ }, true // Use Basic auth
47
+ );
48
+ return response.data;
49
+ }
50
+ async function listConfigs(httpClient, visibility = "private") {
51
+ const request = {
52
+ visibility
53
+ };
54
+ const response = await httpClient.requestWithCustomBaseUrl("POST", CONSOLE_API_BASE_URL, "/api/feed/configs", request, undefined, true // Use Basic auth
55
+ );
56
+ return [...response.data];
57
+ }
58
+ async function updateConfig(httpClient, options) {
59
+ // First get the current feed configuration
60
+ const currentFeed = await getConfig(httpClient, options.config_id);
61
+ const {
62
+ config_id: _config_id,
63
+ ...updateOptions
64
+ } = options;
65
+ // Merge the current configuration with the updates
66
+ const updatedConfig = {
67
+ ...currentFeed,
68
+ ...updateOptions,
69
+ config: {
70
+ ...currentFeed.config,
71
+ ...updateOptions.config
72
+ }
73
+ };
74
+ await httpClient.requestWithCustomBaseUrl("PATCH", CONSOLE_API_BASE_URL, "/api/feed/config", updatedConfig, undefined, true // Use Basic auth
75
+ );
76
+ // endpoint only returns a success message, not the updated feed data
77
+ // So we don't return anything
78
+ }
79
+ //# sourceMappingURL=management.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"management.js","names":["CONSOLE_API_BASE_URL","createConfig","httpClient","options","feedConfig","name","description","endpoint","status","visibility","config","filters","channels","app_fids","geo_locations","remove_geo_locations","ai_labels","publication_types","remove_ai_labels","author_ids","remove_author_ids","embed_domains","start_timestamp","return_global_fallback","scoring","feed_image_url","short_name","response","requestWithCustomBaseUrl","undefined","data","getConfig","configId","config_id","listConfigs","request","updateConfig","currentFeed","_config_id","updateOptions","updatedConfig"],"sources":["../../../src/feed/management.ts"],"sourcesContent":[null],"mappings":";;;;;;;;;AAWA,MAAMA,oBAAoB,GAAG,uCAAuC;AAE7D,eAAeC,YAAYA,CAChCC,UAAuB,EACvBC,OAA0B;EAE1B,MAAMC,UAAU,GAAsB;IACpCC,IAAI,EAAEF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C,MAAM0B,OAAO,GAAqB;IAAE1B;EAAU,CAAE;EAEhD,MAAMkB,QAAQ,GAAG,MAAMzB,UAAU,CAAC0B,wBAAwB,CACxD,MAAM,EACN5B,oBAAoB,EACpB,mBAAmB,EACnBmC,OAAO,EACPN,SAAS,EACT,IAAI,CAAC;GACN;EACD,OAAO,CAAC,GAAGF,QAAQ,CAACG,IAAI,CAAC;AAC3B;AAEO,eAAeM,YAAYA,CAChClC,UAAuB,EACvBC,OAA0B;EAE1B;EACA,MAAMkC,WAAW,GAAG,MAAMN,SAAS,CAAC7B,UAAU,EAAEC,OAAO,CAAC8B,SAAS,CAAC;EAElE,MAAM;IAAEA,SAAS,EAAEK,UAAU;IAAE,GAAGC;EAAa,CAAE,GAAGpC,OAAO;EAE3D;EACA,MAAMqC,aAAa,GAAsB;IACvC,GAAGH,WAAW;IACd,GAAGE,aAAa;IAChB7B,MAAM,EAAE;MACN,GAAG2B,WAAW,CAAC3B,MAAM;MACrB,GAAG6B,aAAa,CAAC7B;;GAEpB;EAED,MAAMR,UAAU,CAAC0B,wBAAwB,CACvC,OAAO,EACP5B,oBAAoB,EACpB,kBAAkB,EAClBwC,aAAa,EACbX,SAAS,EACT,IAAI,CAAC;GACN;EACD;EACA;AACF","ignoreList":[]}
@@ -0,0 +1,138 @@
1
+ import type { CreateFeedOptions, FeedCreateUpdateResponse, FeedGetResponse, ForYouResponse, ListFeedsResponse, UpdateFeedOptions } from "@embed-ai/types";
2
+ import type { IHttpClient } from "../interfaces/index.js";
3
+ import type { FeedOptions } from "./feed.js";
4
+ /**
5
+ * Feed namespace containing all feed-related operations
6
+ *
7
+ * @example
8
+ * ```typescript
9
+ * const client = getClient('your-api-key')
10
+ *
11
+ * // Get personalized feed
12
+ * const feed = await client.feed.byUserId('16085')
13
+ *
14
+ * // Create a custom feed
15
+ * const customFeed = await client.feed.createConfig({
16
+ * name: 'My Custom Feed',
17
+ * description: 'A feed for my app'
18
+ * })
19
+ * ```
20
+ */
21
+ export declare class FeedNamespace {
22
+ private http;
23
+ constructor(http: IHttpClient);
24
+ /**
25
+ * Get personalized "For You" feed by user ID
26
+ *
27
+ * @param userId - The Farcaster user ID to get personalized feed for
28
+ * @param options - Optional configuration for feed generation
29
+ * @returns Promise<ForYouFeedItem[]> - Array of personalized feed items
30
+ *
31
+ * @example
32
+ * ```typescript
33
+ * const client = getClient("your-api-key")
34
+ * const feed = await client.feed.byUserId("16085", {
35
+ * top_k: 10,
36
+ * return_metadata: true
37
+ * })
38
+ * console.log(feed[0].metadata?.text) // Access cast text
39
+ * console.log(feed[0].metadata?.author.username) // Access author username
40
+ * ```
41
+ */
42
+ byUserId(userId: string, options?: FeedOptions): Promise<ForYouResponse>;
43
+ /**
44
+ * Get personalized "For You" feed by wallet address
45
+ *
46
+ * @param walletAddress - The user's wallet address to get personalized feed for
47
+ * @param options - Optional configuration for feed generation
48
+ * @returns Promise<ForYouFeedItem[]> - Array of personalized feed items
49
+ *
50
+ * @example
51
+ * ```typescript
52
+ * const client = getClient("your-api-key")
53
+ * const feed = await client.feed.byWalletAddress("0x1234...", {
54
+ * top_k: 15,
55
+ * })
56
+ * console.log(feed[0].metadata?.author.username) // Access author username
57
+ * console.log(feed[0].score) // Access recommendation score
58
+ * ```
59
+ */
60
+ byWalletAddress(walletAddress: string, options?: FeedOptions): Promise<ForYouResponse>;
61
+ /**
62
+ * Create a new feed configuration
63
+ *
64
+ * @param options - Feed creation options including name, description, and configuration
65
+ * @returns Promise<FeedConfigurationResponse> - The created feed configuration
66
+ *
67
+ * @example
68
+ * ```typescript
69
+ * const client = getClient("your-api-key")
70
+ * const feed = await client.feed.createConfig({
71
+ * name: "My Custom Feed",
72
+ * description: "A personalized feed for my app",
73
+ * visibility: "private",
74
+ * config: {
75
+ * filters: {
76
+ * ai_labels: ["web3_nft", "web3_defi"],
77
+ * start_timestamp: "days_ago:7"
78
+ * }
79
+ * }
80
+ * })
81
+ * console.log(feed.config_id) // Access the feed ID
82
+ * ```
83
+ */
84
+ createConfig(options: CreateFeedOptions): Promise<FeedCreateUpdateResponse>;
85
+ /**
86
+ * Get a feed configuration by ID
87
+ *
88
+ * @param configId - The feed configuration ID
89
+ * @returns Promise<FeedConfigurationResponse> - The feed configuration details
90
+ *
91
+ * @example
92
+ * ```typescript
93
+ * const client = getClient("your-api-key")
94
+ * const feed = await client.feed.getConfig("feed_123")
95
+ * console.log(feed.name) // Access feed name
96
+ * console.log(feed.config.filters) // Access feed filters
97
+ * ```
98
+ */
99
+ getConfig(configId: string): Promise<FeedGetResponse>;
100
+ /**
101
+ * List all feed configurations for the account
102
+ *
103
+ * @param visibility - Filter by visibility (private/public), defaults to "private"
104
+ * @returns Promise<FeedConfigurationResponse[]> - Array of feed configurations
105
+ *
106
+ * @example
107
+ * ```typescript
108
+ * const client = getClient("your-api-key")
109
+ * const feeds = await client.feed.listConfigs("private")
110
+ * console.log(`Found ${feeds.length} feeds`)
111
+ * feeds.forEach(feed => console.log(feed.name))
112
+ * ```
113
+ */
114
+ listConfigs(visibility?: "private" | "public"): Promise<ListFeedsResponse>;
115
+ /**
116
+ * Update an existing feed configuration
117
+ *
118
+ * @param options - Feed update options, must include config_id
119
+ * @returns Promise<void> - Resolves when the feed is successfully updated
120
+ *
121
+ * @example
122
+ * ```typescript
123
+ * const client = getClient("your-api-key")
124
+ * await client.feed.updateConfig({
125
+ * config_id: "feed_123",
126
+ * name: "Updated Feed Name",
127
+ * config: {
128
+ * filters: {
129
+ * ai_labels: ["web3_nft", "web3_defi", "web3_gaming"]
130
+ * }
131
+ * }
132
+ * })
133
+ * console.log("Feed updated successfully")
134
+ * ```
135
+ */
136
+ updateConfig(options: UpdateFeedOptions): Promise<void>;
137
+ }
138
+ //# sourceMappingURL=namespace.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"namespace.d.ts","sourceRoot":"","sources":["../../../src/feed/namespace.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,iBAAiB,EACjB,wBAAwB,EACxB,eAAe,EACf,cAAc,EACd,iBAAiB,EACjB,iBAAiB,EAClB,MAAM,iBAAiB,CAAA;AACxB,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAA;AAEzD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,WAAW,CAAA;AAG5C;;;;;;;;;;;;;;;;GAgBG;AACH,qBAAa,aAAa;IACZ,OAAO,CAAC,IAAI;gBAAJ,IAAI,EAAE,WAAW;IAMrC;;;;;;;;;;;;;;;;;OAiBG;IACG,QAAQ,CACZ,MAAM,EAAE,MAAM,EACd,OAAO,CAAC,EAAE,WAAW,GACpB,OAAO,CAAC,cAAc,CAAC;IAI1B;;;;;;;;;;;;;;;;OAgBG;IACG,eAAe,CACnB,aAAa,EAAE,MAAM,EACrB,OAAO,CAAC,EAAE,WAAW,GACpB,OAAO,CAAC,cAAc,CAAC;IAQ1B;;;;;;;;;;;;;;;;;;;;;;OAsBG;IACG,YAAY,CAAC,OAAO,EAAE,iBAAiB,GAAG,OAAO,CAAC,wBAAwB,CAAC;IAIjF;;;;;;;;;;;;;OAaG;IACG,SAAS,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,eAAe,CAAC;IAI3D;;;;;;;;;;;;;OAaG;IACG,WAAW,CAAC,UAAU,GAAE,SAAS,GAAG,QAAoB,GAAG,OAAO,CAAC,iBAAiB,CAAC;IAI3F;;;;;;;;;;;;;;;;;;;;OAoBG;IACG,YAAY,CAAC,OAAO,EAAE,iBAAiB,GAAG,OAAO,CAAC,IAAI,CAAC;CAG9D"}