@embed-ai/sdk 0.1.2 → 0.1.3

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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@embed-ai/sdk",
3
- "version": "0.1.2",
4
- "type": "module",
3
+ "version": "0.1.3",
4
+ "main": "src/index.js",
5
5
  "license": "BSD-3-Clause",
6
6
  "description": "The typescript sdk package for embed AI APIs.",
7
7
  "repository": {
@@ -30,7 +30,7 @@
30
30
  "coverage": "vitest --coverage"
31
31
  },
32
32
  "dependencies": {
33
- "@embed-ai/types": "^0.1.1"
33
+ "@embed-ai/types": "^0.1.2"
34
34
  },
35
35
  "peerDependencies": {
36
36
  "effect": ">=3.0.0"
package/src/client.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  import { FeedNamespace } from "./feed/namespace.js";
2
+ import { SearchNamespace } from "./search/namespace.js";
2
3
  declare const NetworkError_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").Equals<A, {}> extends true ? void : { readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }) => import("effect/Cause").YieldableError & {
3
4
  readonly _tag: "NetworkError";
4
5
  } & Readonly<A>;
@@ -105,7 +106,7 @@ export interface mbdClientConfig {
105
106
  readonly retry?: RetryConfig;
106
107
  }
107
108
  /**
108
- * Main Embed API client providing access to personalized feeds and feed management
109
+ * Main Embed API client providing access to personalized feeds, feed management, and search
109
110
  *
110
111
  * @example
111
112
  * ```typescript
@@ -121,11 +122,18 @@ export interface mbdClientConfig {
121
122
  * name: 'My Custom Feed',
122
123
  * description: 'A feed for my app'
123
124
  * })
125
+ *
126
+ * // Search for similar users
127
+ * const similarUsers = await client.search.users.similar('16085')
128
+ *
129
+ * // Search users by query
130
+ * const users = await client.search.users.byQuery('web3 developers')
124
131
  * ```
125
132
  */
126
133
  export declare class mbdClient {
127
134
  private http;
128
135
  readonly feed: FeedNamespace;
136
+ readonly search: SearchNamespace;
129
137
  constructor(token?: string, options?: mbdClientConfig);
130
138
  }
131
139
  /**
@@ -151,6 +159,12 @@ export declare class mbdClient {
151
159
  * description: 'A feed for my app'
152
160
  * })
153
161
  *
162
+ * // Search for similar users
163
+ * const similarUsers = await client.search.users.similar('16085')
164
+ *
165
+ * // Search users by query
166
+ * const users = await client.search.users.byQuery('web3 developers')
167
+ *
154
168
  * // With configuration
155
169
  * const client = getClient('your-api-key', {
156
170
  * retry: {
package/src/client.js CHANGED
@@ -3,15 +3,14 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.TimeoutError = exports.ParseError = exports.NetworkError = exports.HttpRequestError = void 0;
6
+ exports.mbdClient = exports.TimeoutError = exports.ParseError = exports.HttpRequestError = exports.NetworkError = void 0;
7
7
  exports.getClient = getClient;
8
- exports.mbdClient = void 0;
9
- var _effect = require("effect");
10
- var Data = _interopRequireWildcard(require("effect/Data"));
11
- var Effect = _interopRequireWildcard(require("effect/Effect"));
12
- var Schedule = _interopRequireWildcard(require("effect/Schedule"));
13
- var _namespace = require("./feed/namespace.js");
14
- function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
8
+ const effect_1 = /*#__PURE__*/require("effect");
9
+ const Data = /*#__PURE__*/require("effect/Data");
10
+ const Effect = /*#__PURE__*/require("effect/Effect");
11
+ const Schedule = /*#__PURE__*/require("effect/Schedule");
12
+ const namespace_js_1 = /*#__PURE__*/require("./feed/namespace.js");
13
+ const namespace_js_2 = /*#__PURE__*/require("./search/namespace.js");
15
14
  // ============================================================================
16
15
  // ERROR TYPES
17
16
  // ============================================================================
@@ -19,25 +18,25 @@ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r
19
18
  * Network-related errors (connection issues, DNS failures, etc.)
20
19
  */
21
20
  class NetworkError extends Data.TaggedError("NetworkError") {}
21
+ exports.NetworkError = NetworkError;
22
22
  /**
23
23
  * HTTP response errors (4xx, 5xx status codes)
24
24
  */
25
- exports.NetworkError = NetworkError;
26
25
  class HttpRequestError extends Data.TaggedError("HttpRequestError") {}
26
+ exports.HttpRequestError = HttpRequestError;
27
27
  /**
28
28
  * JSON parsing errors
29
29
  */
30
- exports.HttpRequestError = HttpRequestError;
31
30
  class ParseError extends Data.TaggedError("ParseError") {}
31
+ exports.ParseError = ParseError;
32
32
  /**
33
33
  * Timeout errors
34
34
  */
35
- exports.ParseError = ParseError;
36
35
  class TimeoutError extends Data.TaggedError("TimeoutError") {}
36
+ exports.TimeoutError = TimeoutError;
37
37
  /**
38
38
  * Default retry configuration
39
39
  */
40
- exports.TimeoutError = TimeoutError;
41
40
  const DEFAULT_RETRY_CONFIG = {
42
41
  exponentialBackoff: true,
43
42
  initialDelay: 1000,
@@ -77,7 +76,7 @@ class HttpClient {
77
76
  * Create a timeout effect that fails after the specified duration
78
77
  */
79
78
  createTimeoutEffect(timeoutMs) {
80
- return (0, _effect.pipe)(Effect.sleep(`${timeoutMs} millis`), Effect.flatMap(() => Effect.fail(new TimeoutError({
79
+ return (0, effect_1.pipe)(Effect.sleep(`${timeoutMs} millis`), Effect.flatMap(() => Effect.fail(new TimeoutError({
81
80
  message: `Request timed out after ${timeoutMs}ms`,
82
81
  timeoutMs
83
82
  }))));
@@ -170,12 +169,12 @@ class HttpClient {
170
169
  } = this.config.retry;
171
170
  let baseSchedule;
172
171
  if (exponentialBackoff) {
173
- baseSchedule = (0, _effect.pipe)(Schedule.exponential(`${initialDelay} millis`), Schedule.either(Schedule.spaced(`${maxDelay} millis`)), Schedule.compose(Schedule.recurs(maxRetries)));
172
+ baseSchedule = (0, effect_1.pipe)(Schedule.exponential(`${initialDelay} millis`), Schedule.either(Schedule.spaced(`${maxDelay} millis`)), Schedule.compose(Schedule.recurs(maxRetries)));
174
173
  } else {
175
- baseSchedule = (0, _effect.pipe)(Schedule.spaced(`${initialDelay} millis`), Schedule.compose(Schedule.recurs(maxRetries)));
174
+ baseSchedule = (0, effect_1.pipe)(Schedule.spaced(`${initialDelay} millis`), Schedule.compose(Schedule.recurs(maxRetries)));
176
175
  }
177
176
  // Only retry on specific errors
178
- return (0, _effect.pipe)(baseSchedule, Schedule.whileInput(error => {
177
+ return (0, effect_1.pipe)(baseSchedule, Schedule.whileInput(error => {
179
178
  switch (error._tag) {
180
179
  case "NetworkError":
181
180
  return true;
@@ -203,7 +202,7 @@ class HttpClient {
203
202
  const requestWithTimeout = Effect.race(fetchEffect, timeoutEffect);
204
203
  // Apply retry logic
205
204
  const retrySchedule = this.createRetrySchedule();
206
- return (0, _effect.pipe)(requestWithTimeout, Effect.retry(retrySchedule), Effect.tapError(error => Effect.logError("HTTP request failed after retries", error)));
205
+ return (0, effect_1.pipe)(requestWithTimeout, Effect.retry(retrySchedule), Effect.tapError(error => Effect.logError("HTTP request failed after retries", error)));
207
206
  }
208
207
  /**
209
208
  * Make a POST request to the API with Effect-based error handling and retries
@@ -238,7 +237,7 @@ class HttpClient {
238
237
  // MAIN CLIENT
239
238
  // ============================================================================
240
239
  /**
241
- * Main Embed API client providing access to personalized feeds and feed management
240
+ * Main Embed API client providing access to personalized feeds, feed management, and search
242
241
  *
243
242
  * @example
244
243
  * ```typescript
@@ -254,11 +253,18 @@ class HttpClient {
254
253
  * name: 'My Custom Feed',
255
254
  * description: 'A feed for my app'
256
255
  * })
256
+ *
257
+ * // Search for similar users
258
+ * const similarUsers = await client.search.users.similar('16085')
259
+ *
260
+ * // Search users by query
261
+ * const users = await client.search.users.byQuery('web3 developers')
257
262
  * ```
258
263
  */
259
264
  class mbdClient {
260
265
  http;
261
266
  feed;
267
+ search;
262
268
  constructor(token, options) {
263
269
  if (!token && !options?.token) {
264
270
  throw new Error("Token is required");
@@ -268,9 +274,11 @@ class mbdClient {
268
274
  ...options
269
275
  };
270
276
  this.http = new HttpClient(config);
271
- this.feed = new _namespace.FeedNamespace(this.http);
277
+ this.feed = new namespace_js_1.FeedNamespace(this.http);
278
+ this.search = new namespace_js_2.SearchNamespace(this.http);
272
279
  }
273
280
  }
281
+ exports.mbdClient = mbdClient;
274
282
  /**
275
283
  * Get a new Embed Client instance
276
284
  *
@@ -294,6 +302,12 @@ class mbdClient {
294
302
  * description: 'A feed for my app'
295
303
  * })
296
304
  *
305
+ * // Search for similar users
306
+ * const similarUsers = await client.search.users.similar('16085')
307
+ *
308
+ * // Search users by query
309
+ * const users = await client.search.users.byQuery('web3 developers')
310
+ *
297
311
  * // With configuration
298
312
  * const client = getClient('your-api-key', {
299
313
  * retry: {
@@ -303,7 +317,6 @@ class mbdClient {
303
317
  * })
304
318
  * ```
305
319
  */
306
- exports.mbdClient = mbdClient;
307
320
  function getClient(token, options) {
308
321
  return new mbdClient(token, options);
309
322
  }
package/src/feed/index.js CHANGED
@@ -1,39 +1,28 @@
1
1
  "use strict";
2
2
 
3
+ var __createBinding = void 0 && (void 0).__createBinding || (Object.create ? function (o, m, k, k2) {
4
+ if (k2 === undefined) k2 = k;
5
+ var desc = Object.getOwnPropertyDescriptor(m, k);
6
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
7
+ desc = {
8
+ enumerable: true,
9
+ get: function () {
10
+ return m[k];
11
+ }
12
+ };
13
+ }
14
+ Object.defineProperty(o, k2, desc);
15
+ } : function (o, m, k, k2) {
16
+ if (k2 === undefined) k2 = k;
17
+ o[k2] = m[k];
18
+ });
19
+ var __exportStar = void 0 && (void 0).__exportStar || function (m, exports) {
20
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
21
+ };
3
22
  Object.defineProperty(exports, "__esModule", {
4
23
  value: true
5
24
  });
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
- });
25
+ __exportStar(require("./feed.js"), exports);
26
+ __exportStar(require("./management.js"), exports);
27
+ __exportStar(require("./namespace.js"), exports);
39
28
  //# sourceMappingURL=index.js.map
@@ -1,4 +1,4 @@
1
- import type { CreateFeedOptions, FeedCreateUpdateResponse, FeedGetResponse, ForYouResponse, ListFeedsResponse, UpdateFeedOptions } from "@embed-ai/types";
1
+ import type { CreateFeedOptions, FeedCreateUpdateResponse, FeedGetResponse, ForYouResponse, ListFeedsResponse } from "@embed-ai/types";
2
2
  import type { IHttpClient } from "../interfaces/index.js";
3
3
  import type { FeedOptions } from "./feed.js";
4
4
  /**
@@ -8,8 +8,8 @@ import type { FeedOptions } from "./feed.js";
8
8
  * ```typescript
9
9
  * const client = getClient('your-api-key')
10
10
  *
11
- * // Get personalized feed
12
- * const feed = await client.feed.byUserId('16085')
11
+ * // Get personalized feed based on the For-You template
12
+ * const feed = await client.feed.byUserId('16085', 'feed_390')
13
13
  *
14
14
  * // Create a custom feed
15
15
  * const customFeed = await client.feed.createConfig({
@@ -32,7 +32,7 @@ export declare class FeedNamespace {
32
32
  * @example
33
33
  * ```typescript
34
34
  * const client = getClient("your-api-key")
35
- * const feed = await client.feed.byUserId("16085", {
35
+ * const feed = await client.feed.byUserId("16085", "feed_390", {
36
36
  * top_k: 10,
37
37
  * return_metadata: true
38
38
  * })
@@ -52,7 +52,7 @@ export declare class FeedNamespace {
52
52
  * @example
53
53
  * ```typescript
54
54
  * const client = getClient("your-api-key")
55
- * const feed = await client.feed.byWalletAddress("0x1234...", {
55
+ * const feed = await client.feed.byWalletAddress("0x1234...", "feed_390", {
56
56
  * top_k: 15,
57
57
  * })
58
58
  * console.log(feed[0].metadata?.author.username) // Access author username
@@ -124,8 +124,7 @@ export declare class FeedNamespace {
124
124
  * @example
125
125
  * ```typescript
126
126
  * const client = getClient("your-api-key")
127
- * await client.feed.updateConfig({
128
- * config_id: "feed_123",
127
+ * await client.feed.updateConfig("feed_123", {
129
128
  * name: "Updated Feed Name",
130
129
  * config: {
131
130
  * filters: {
@@ -136,6 +135,6 @@ export declare class FeedNamespace {
136
135
  * console.log("Feed updated successfully")
137
136
  * ```
138
137
  */
139
- updateConfig(feedId: string, options: UpdateFeedOptions): Promise<void>;
138
+ updateConfig(feedId: string, options: CreateFeedOptions): Promise<void>;
140
139
  }
141
140
  //# sourceMappingURL=namespace.d.ts.map
@@ -4,8 +4,8 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.FeedNamespace = void 0;
7
- var _feed = require("./feed.js");
8
- var _management = require("./management.js");
7
+ const feed_js_1 = /*#__PURE__*/require("./feed.js");
8
+ const management_js_1 = /*#__PURE__*/require("./management.js");
9
9
  /**
10
10
  * Feed namespace containing all feed-related operations
11
11
  *
@@ -13,8 +13,8 @@ var _management = require("./management.js");
13
13
  * ```typescript
14
14
  * const client = getClient('your-api-key')
15
15
  *
16
- * // Get personalized feed
17
- * const feed = await client.feed.byUserId('16085')
16
+ * // Get personalized feed based on the For-You template
17
+ * const feed = await client.feed.byUserId('16085', 'feed_390')
18
18
  *
19
19
  * // Create a custom feed
20
20
  * const customFeed = await client.feed.createConfig({
@@ -42,7 +42,7 @@ class FeedNamespace {
42
42
  * @example
43
43
  * ```typescript
44
44
  * const client = getClient("your-api-key")
45
- * const feed = await client.feed.byUserId("16085", {
45
+ * const feed = await client.feed.byUserId("16085", "feed_390", {
46
46
  * top_k: 10,
47
47
  * return_metadata: true
48
48
  * })
@@ -51,7 +51,7 @@ class FeedNamespace {
51
51
  * ```
52
52
  */
53
53
  async byUserId(userId, feedId, options) {
54
- return (0, _feed.byUserId)(this.http, userId, feedId, options);
54
+ return (0, feed_js_1.byUserId)(this.http, userId, feedId, options);
55
55
  }
56
56
  /**
57
57
  * Get personalized "For You" feed by wallet address
@@ -64,7 +64,7 @@ class FeedNamespace {
64
64
  * @example
65
65
  * ```typescript
66
66
  * const client = getClient("your-api-key")
67
- * const feed = await client.feed.byWalletAddress("0x1234...", {
67
+ * const feed = await client.feed.byWalletAddress("0x1234...", "feed_390", {
68
68
  * top_k: 15,
69
69
  * })
70
70
  * console.log(feed[0].metadata?.author.username) // Access author username
@@ -72,7 +72,7 @@ class FeedNamespace {
72
72
  * ```
73
73
  */
74
74
  async byWalletAddress(walletAddress, feedId, options) {
75
- return (0, _feed.byWalletAddress)(this.http, walletAddress, feedId, options);
75
+ return (0, feed_js_1.byWalletAddress)(this.http, walletAddress, feedId, options);
76
76
  }
77
77
  // ============================================================================
78
78
  // FEED MANAGEMENT METHODS
@@ -101,7 +101,7 @@ class FeedNamespace {
101
101
  * ```
102
102
  */
103
103
  async createConfig(options) {
104
- return (0, _management.createConfig)(this.http, options);
104
+ return (0, management_js_1.createConfig)(this.http, options);
105
105
  }
106
106
  /**
107
107
  * Get a feed configuration by feedId
@@ -118,7 +118,7 @@ class FeedNamespace {
118
118
  * ```
119
119
  */
120
120
  async getConfig(feedId) {
121
- return (0, _management.getConfig)(this.http, feedId);
121
+ return (0, management_js_1.getConfig)(this.http, feedId);
122
122
  }
123
123
  /**
124
124
  * List all feed configurations for the account
@@ -135,7 +135,7 @@ class FeedNamespace {
135
135
  * ```
136
136
  */
137
137
  async listConfigs(visibility = "private") {
138
- return (0, _management.listConfigs)(this.http, visibility);
138
+ return (0, management_js_1.listConfigs)(this.http, visibility);
139
139
  }
140
140
  /**
141
141
  * Update an existing feed configuration
@@ -147,8 +147,7 @@ class FeedNamespace {
147
147
  * @example
148
148
  * ```typescript
149
149
  * const client = getClient("your-api-key")
150
- * await client.feed.updateConfig({
151
- * config_id: "feed_123",
150
+ * await client.feed.updateConfig("feed_123", {
152
151
  * name: "Updated Feed Name",
153
152
  * config: {
154
153
  * filters: {
@@ -160,7 +159,7 @@ class FeedNamespace {
160
159
  * ```
161
160
  */
162
161
  async updateConfig(feedId, options) {
163
- return (0, _management.updateConfig)(this.http, feedId, options);
162
+ return (0, management_js_1.updateConfig)(this.http, feedId, options);
164
163
  }
165
164
  }
166
165
  exports.FeedNamespace = FeedNamespace;
package/src/index.js CHANGED
@@ -3,48 +3,53 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- Object.defineProperty(exports, "FeedNamespace", {
6
+ exports.FeedNamespace = exports.TimeoutError = exports.ParseError = exports.NetworkError = exports.HttpRequestError = exports.mbdClient = exports.getClient = void 0;
7
+ // Export the main client factory function
8
+ var client_js_1 = /*#__PURE__*/require("./client.js");
9
+ Object.defineProperty(exports, "getClient", {
7
10
  enumerable: true,
8
11
  get: function () {
9
- return _namespace.FeedNamespace;
12
+ return client_js_1.getClient;
10
13
  }
11
14
  });
12
- Object.defineProperty(exports, "HttpRequestError", {
15
+ Object.defineProperty(exports, "mbdClient", {
13
16
  enumerable: true,
14
17
  get: function () {
15
- return _client.HttpRequestError;
18
+ return client_js_1.mbdClient;
16
19
  }
17
20
  });
18
- Object.defineProperty(exports, "NetworkError", {
21
+ // Export error types for error handling
22
+ var client_js_2 = /*#__PURE__*/require("./client.js");
23
+ Object.defineProperty(exports, "HttpRequestError", {
19
24
  enumerable: true,
20
25
  get: function () {
21
- return _client.NetworkError;
26
+ return client_js_2.HttpRequestError;
22
27
  }
23
28
  });
24
- Object.defineProperty(exports, "ParseError", {
29
+ Object.defineProperty(exports, "NetworkError", {
25
30
  enumerable: true,
26
31
  get: function () {
27
- return _client.ParseError;
32
+ return client_js_2.NetworkError;
28
33
  }
29
34
  });
30
- Object.defineProperty(exports, "TimeoutError", {
35
+ Object.defineProperty(exports, "ParseError", {
31
36
  enumerable: true,
32
37
  get: function () {
33
- return _client.TimeoutError;
38
+ return client_js_2.ParseError;
34
39
  }
35
40
  });
36
- Object.defineProperty(exports, "getClient", {
41
+ Object.defineProperty(exports, "TimeoutError", {
37
42
  enumerable: true,
38
43
  get: function () {
39
- return _client.getClient;
44
+ return client_js_2.TimeoutError;
40
45
  }
41
46
  });
42
- Object.defineProperty(exports, "mbdClient", {
47
+ // Export feed namespace
48
+ var namespace_js_1 = /*#__PURE__*/require("./feed/namespace.js");
49
+ Object.defineProperty(exports, "FeedNamespace", {
43
50
  enumerable: true,
44
51
  get: function () {
45
- return _client.mbdClient;
52
+ return namespace_js_1.FeedNamespace;
46
53
  }
47
54
  });
48
- var _client = require("./client.js");
49
- var _namespace = require("./feed/namespace.js");
50
55
  //# sourceMappingURL=index.js.map
@@ -1,17 +1,26 @@
1
1
  "use strict";
2
2
 
3
+ var __createBinding = void 0 && (void 0).__createBinding || (Object.create ? function (o, m, k, k2) {
4
+ if (k2 === undefined) k2 = k;
5
+ var desc = Object.getOwnPropertyDescriptor(m, k);
6
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
7
+ desc = {
8
+ enumerable: true,
9
+ get: function () {
10
+ return m[k];
11
+ }
12
+ };
13
+ }
14
+ Object.defineProperty(o, k2, desc);
15
+ } : function (o, m, k, k2) {
16
+ if (k2 === undefined) k2 = k;
17
+ o[k2] = m[k];
18
+ });
19
+ var __exportStar = void 0 && (void 0).__exportStar || function (m, exports) {
20
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
21
+ };
3
22
  Object.defineProperty(exports, "__esModule", {
4
23
  value: true
5
24
  });
6
- var _http = require("./http.js");
7
- Object.keys(_http).forEach(function (key) {
8
- if (key === "default" || key === "__esModule") return;
9
- if (key in exports && exports[key] === _http[key]) return;
10
- Object.defineProperty(exports, key, {
11
- enumerable: true,
12
- get: function () {
13
- return _http[key];
14
- }
15
- });
16
- });
25
+ __exportStar(require("./http.js"), exports);
17
26
  //# sourceMappingURL=index.js.map
@@ -0,0 +1,2 @@
1
+ export { SearchNamespace } from "./namespace.js";
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.SearchNamespace = void 0;
7
+ var namespace_js_1 = /*#__PURE__*/require("./namespace.js");
8
+ Object.defineProperty(exports, "SearchNamespace", {
9
+ enumerable: true,
10
+ get: function () {
11
+ return namespace_js_1.SearchNamespace;
12
+ }
13
+ });
14
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=item.d.ts.map
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ //# sourceMappingURL=item.js.map
@@ -0,0 +1,118 @@
1
+ import type { AllLabels, LabelCategories, UserLabelsResponse, UserSemanticSearchResponse, UserSimilarityResponse, UserTopByLabelResponse } from "@embed-ai/types";
2
+ import type { IHttpClient } from "../interfaces/index.js";
3
+ import type { UserLabelsOptions, UserSemanticSearchOptions, UserSimilarOptions, UserTopByLabelOptions } from "./user.js";
4
+ /**
5
+ * Users namespace containing all user search operations
6
+ *
7
+ * @example
8
+ * ```typescript
9
+ * const client = getClient('your-api-key')
10
+ *
11
+ * // Find similar users
12
+ * const similarUsers = await client.search.users.similar('16085')
13
+ *
14
+ * // Search users by query
15
+ * const users = await client.search.users.byQuery('web3 developers')
16
+ *
17
+ * // Get top users by label
18
+ * const topUsers = await client.search.users.getTopByLabel('science_technology')
19
+ *
20
+ * // Get labels for users
21
+ * const labels = await client.search.users.getLabels(['16085', '239'])
22
+ * ```
23
+ */
24
+ export declare class UsersNamespace {
25
+ private http;
26
+ constructor(http: IHttpClient);
27
+ /**
28
+ * Get similar users for a given user ID
29
+ *
30
+ * @param userId - The user ID (fid) to find similar users for
31
+ * @param options - Optional configuration with top_k parameter (default: 25)
32
+ * @returns Promise<UserSimilarityResponse> - Array of similar users with scores
33
+ *
34
+ * @example
35
+ * ```typescript
36
+ * const client = getClient("your-api-key")
37
+ * const similarUsers = await client.search.users.similar("16085", { top_k: 10 })
38
+ * console.log(similarUsers[0].user_id) // "3"
39
+ * console.log(similarUsers[0].score) // 0.931880295
40
+ * ```
41
+ */
42
+ similar(userId: string, options?: UserSimilarOptions): Promise<UserSimilarityResponse>;
43
+ /**
44
+ * Search for users by semantic query
45
+ *
46
+ * @param query - The text query to search for similar users
47
+ * @param options - Optional configuration with top_k parameter (default: 25)
48
+ * @returns Promise<UserSemanticSearchResponse> - Array of users matching the query with scores
49
+ *
50
+ * @example
51
+ * ```typescript
52
+ * const client = getClient("your-api-key")
53
+ * const users = await client.search.users.byQuery("web3 developers", { top_k: 10 })
54
+ * console.log(users[0].user_id) // "444746"
55
+ * console.log(users[0].score) // 0.697465777
56
+ * ```
57
+ */
58
+ byQuery(query: string, options?: UserSemanticSearchOptions): Promise<UserSemanticSearchResponse>;
59
+ /**
60
+ * Get top users by AI label
61
+ *
62
+ * @param label - The AI label to get top users for
63
+ * @param options - Optional configuration including top_k (default: 100, max: 1000), minimum_activity_count (default: 10), ratio_min (default: 0.75), conf_min (default: 0.6)
64
+ * @returns Promise<UserTopByLabelResponse> - Array of top users for the label with scores, counts, and ratios
65
+ *
66
+ * @example
67
+ * ```typescript
68
+ * const client = getClient("your-api-key")
69
+ * const topUsers = await client.search.users.getTopByLabel("science_technology", {
70
+ * top_k: 50,
71
+ * minimum_activity_count: 20,
72
+ * ratio_min: 0.8,
73
+ * conf_min: 0.7
74
+ * })
75
+ * console.log(topUsers[0].user_id) // "520701"
76
+ * console.log(topUsers[0].score) // 0.9471641778666666
77
+ * console.log(topUsers[0].count) // 12
78
+ * console.log(topUsers[0].ratio) // 1
79
+ * ```
80
+ */
81
+ getTopByLabel(label: AllLabels, options?: UserTopByLabelOptions): Promise<UserTopByLabelResponse>;
82
+ /**
83
+ * Get AI labels for a list of users
84
+ *
85
+ * @param userList - Array of user IDs to get labels for
86
+ * @param labelCategory - The category of labels to retrieve (default: "all")
87
+ * @param options - Optional configuration
88
+ * @returns Promise<UserLabelsResponse> - Array of users with their AI labels
89
+ *
90
+ * @example
91
+ * ```typescript
92
+ * const client = getClient("your-api-key")
93
+ * const userLabels = await client.search.users.getLabels(["16085", "239", "3"], "topics")
94
+ * console.log(userLabels[0].user_id) // "16085"
95
+ * console.log(userLabels[0].ai_labels.topics[0].label) // "arts_culture"
96
+ * console.log(userLabels[0].ai_labels.topics[0].score) // 0.023266956986850353
97
+ * ```
98
+ */
99
+ getLabels(userList: Array<string>, labelCategory?: LabelCategories, options?: UserLabelsOptions): Promise<UserLabelsResponse>;
100
+ }
101
+ /**
102
+ * Search namespace containing all search-related operations
103
+ *
104
+ * @example
105
+ * ```typescript
106
+ * const client = getClient('your-api-key')
107
+ *
108
+ * // Access user search methods
109
+ * const similarUsers = await client.search.users.similar('16085')
110
+ * const searchResults = await client.search.users.byQuery('web3 developers')
111
+ * ```
112
+ */
113
+ export declare class SearchNamespace {
114
+ private http;
115
+ readonly users: UsersNamespace;
116
+ constructor(http: IHttpClient);
117
+ }
118
+ //# sourceMappingURL=namespace.d.ts.map
@@ -0,0 +1,137 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.SearchNamespace = exports.UsersNamespace = void 0;
7
+ const user_js_1 = /*#__PURE__*/require("./user.js");
8
+ /**
9
+ * Users namespace containing all user search operations
10
+ *
11
+ * @example
12
+ * ```typescript
13
+ * const client = getClient('your-api-key')
14
+ *
15
+ * // Find similar users
16
+ * const similarUsers = await client.search.users.similar('16085')
17
+ *
18
+ * // Search users by query
19
+ * const users = await client.search.users.byQuery('web3 developers')
20
+ *
21
+ * // Get top users by label
22
+ * const topUsers = await client.search.users.getTopByLabel('science_technology')
23
+ *
24
+ * // Get labels for users
25
+ * const labels = await client.search.users.getLabels(['16085', '239'])
26
+ * ```
27
+ */
28
+ class UsersNamespace {
29
+ http;
30
+ constructor(http) {
31
+ this.http = http;
32
+ }
33
+ /**
34
+ * Get similar users for a given user ID
35
+ *
36
+ * @param userId - The user ID (fid) to find similar users for
37
+ * @param options - Optional configuration with top_k parameter (default: 25)
38
+ * @returns Promise<UserSimilarityResponse> - Array of similar users with scores
39
+ *
40
+ * @example
41
+ * ```typescript
42
+ * const client = getClient("your-api-key")
43
+ * const similarUsers = await client.search.users.similar("16085", { top_k: 10 })
44
+ * console.log(similarUsers[0].user_id) // "3"
45
+ * console.log(similarUsers[0].score) // 0.931880295
46
+ * ```
47
+ */
48
+ async similar(userId, options) {
49
+ return (0, user_js_1.similar)(this.http, userId, options);
50
+ }
51
+ /**
52
+ * Search for users by semantic query
53
+ *
54
+ * @param query - The text query to search for similar users
55
+ * @param options - Optional configuration with top_k parameter (default: 25)
56
+ * @returns Promise<UserSemanticSearchResponse> - Array of users matching the query with scores
57
+ *
58
+ * @example
59
+ * ```typescript
60
+ * const client = getClient("your-api-key")
61
+ * const users = await client.search.users.byQuery("web3 developers", { top_k: 10 })
62
+ * console.log(users[0].user_id) // "444746"
63
+ * console.log(users[0].score) // 0.697465777
64
+ * ```
65
+ */
66
+ async byQuery(query, options) {
67
+ return (0, user_js_1.byQuery)(this.http, query, options);
68
+ }
69
+ /**
70
+ * Get top users by AI label
71
+ *
72
+ * @param label - The AI label to get top users for
73
+ * @param options - Optional configuration including top_k (default: 100, max: 1000), minimum_activity_count (default: 10), ratio_min (default: 0.75), conf_min (default: 0.6)
74
+ * @returns Promise<UserTopByLabelResponse> - Array of top users for the label with scores, counts, and ratios
75
+ *
76
+ * @example
77
+ * ```typescript
78
+ * const client = getClient("your-api-key")
79
+ * const topUsers = await client.search.users.getTopByLabel("science_technology", {
80
+ * top_k: 50,
81
+ * minimum_activity_count: 20,
82
+ * ratio_min: 0.8,
83
+ * conf_min: 0.7
84
+ * })
85
+ * console.log(topUsers[0].user_id) // "520701"
86
+ * console.log(topUsers[0].score) // 0.9471641778666666
87
+ * console.log(topUsers[0].count) // 12
88
+ * console.log(topUsers[0].ratio) // 1
89
+ * ```
90
+ */
91
+ async getTopByLabel(label, options) {
92
+ return (0, user_js_1.getTopByLabel)(this.http, label, options);
93
+ }
94
+ /**
95
+ * Get AI labels for a list of users
96
+ *
97
+ * @param userList - Array of user IDs to get labels for
98
+ * @param labelCategory - The category of labels to retrieve (default: "all")
99
+ * @param options - Optional configuration
100
+ * @returns Promise<UserLabelsResponse> - Array of users with their AI labels
101
+ *
102
+ * @example
103
+ * ```typescript
104
+ * const client = getClient("your-api-key")
105
+ * const userLabels = await client.search.users.getLabels(["16085", "239", "3"], "topics")
106
+ * console.log(userLabels[0].user_id) // "16085"
107
+ * console.log(userLabels[0].ai_labels.topics[0].label) // "arts_culture"
108
+ * console.log(userLabels[0].ai_labels.topics[0].score) // 0.023266956986850353
109
+ * ```
110
+ */
111
+ async getLabels(userList, labelCategory = "all", options) {
112
+ return (0, user_js_1.getLabels)(this.http, userList, labelCategory, options);
113
+ }
114
+ }
115
+ exports.UsersNamespace = UsersNamespace;
116
+ /**
117
+ * Search namespace containing all search-related operations
118
+ *
119
+ * @example
120
+ * ```typescript
121
+ * const client = getClient('your-api-key')
122
+ *
123
+ * // Access user search methods
124
+ * const similarUsers = await client.search.users.similar('16085')
125
+ * const searchResults = await client.search.users.byQuery('web3 developers')
126
+ * ```
127
+ */
128
+ class SearchNamespace {
129
+ http;
130
+ users;
131
+ constructor(http) {
132
+ this.http = http;
133
+ this.users = new UsersNamespace(this.http);
134
+ }
135
+ }
136
+ exports.SearchNamespace = SearchNamespace;
137
+ //# sourceMappingURL=namespace.js.map
@@ -0,0 +1,80 @@
1
+ import type { AllLabels, LabelCategories, LabelsForUsers, LabelsTopUsers, UserLabelsResponse, UserSemanticSearchResponse, UsersFeedSimilar, UserSimilarityResponse, UsersSemanticSearch, UserTopByLabelResponse } from "@embed-ai/types";
2
+ import type { IHttpClient } from "../interfaces/index.js";
3
+ export type UserSimilarOptions = Omit<UsersFeedSimilar, "user_id">;
4
+ export type UserSemanticSearchOptions = Omit<UsersSemanticSearch, "query">;
5
+ export type UserTopByLabelOptions = Omit<LabelsTopUsers, "label">;
6
+ export type UserLabelsOptions = Omit<LabelsForUsers, "users_list" | "label_category">;
7
+ /**
8
+ * Get similar users for a given user ID
9
+ *
10
+ * @param httpClient - HTTP client instance
11
+ * @param userId - The user ID (fid) to find similar users for
12
+ * @param options - Optional configuration with top_k parameter
13
+ * @returns Promise<UserSimilarityResponse> - Array of similar users with scores
14
+ *
15
+ * @example
16
+ * ```typescript
17
+ * const similarUsers = await client.search.users.similar("16085", { top_k: 10 })
18
+ * console.log(similarUsers[0].user_id) // "3"
19
+ * console.log(similarUsers[0].score) // 0.931880295
20
+ * ```
21
+ */
22
+ export declare function similar(httpClient: IHttpClient, userId: string, options?: UserSimilarOptions): Promise<UserSimilarityResponse>;
23
+ /**
24
+ * Search for users by semantic query
25
+ *
26
+ * @param httpClient - HTTP client instance
27
+ * @param query - The text query to search for similar users
28
+ * @param options - Optional configuration with top_k parameter
29
+ * @returns Promise<UserSemanticSearchResponse> - Array of users matching the query with scores
30
+ *
31
+ * @example
32
+ * ```typescript
33
+ * const users = await client.search.users.byQuery("web3 developers", { top_k: 10 })
34
+ * console.log(users[0].user_id) // "444746"
35
+ * console.log(users[0].score) // 0.697465777
36
+ * ```
37
+ */
38
+ export declare function byQuery(httpClient: IHttpClient, query: string, options?: UserSemanticSearchOptions): Promise<UserSemanticSearchResponse>;
39
+ /**
40
+ * Get top users by AI label
41
+ *
42
+ * @param httpClient - HTTP client instance
43
+ * @param label - The AI label to get top users for
44
+ * @param options - Optional configuration including top_k, minimum_activity_count, ratio_min, conf_min
45
+ * @returns Promise<UserTopByLabelResponse> - Array of top users for the label with scores, counts, and ratios
46
+ *
47
+ * @example
48
+ * ```typescript
49
+ * const topUsers = await client.search.users.getTopByLabel("science_technology", {
50
+ * top_k: 50,
51
+ * minimum_activity_count: 20,
52
+ * ratio_min: 0.8,
53
+ * conf_min: 0.7
54
+ * })
55
+ * console.log(topUsers[0].user_id) // "520701"
56
+ * console.log(topUsers[0].score) // 0.9471641778666666
57
+ * console.log(topUsers[0].count) // 12
58
+ * console.log(topUsers[0].ratio) // 1
59
+ * ```
60
+ */
61
+ export declare function getTopByLabel(httpClient: IHttpClient, label: AllLabels, options?: UserTopByLabelOptions): Promise<UserTopByLabelResponse>;
62
+ /**
63
+ * Get AI labels for a list of users
64
+ *
65
+ * @param httpClient - HTTP client instance
66
+ * @param userList - Array of user IDs to get labels for
67
+ * @param labelCategory - The category of labels to retrieve (default: "all")
68
+ * @param options - Optional configuration
69
+ * @returns Promise<UserLabelsResponse> - Array of users with their AI labels
70
+ *
71
+ * @example
72
+ * ```typescript
73
+ * const userLabels = await client.search.users.getLabels(["16085", "239", "3"], "topics")
74
+ * console.log(userLabels[0].user_id) // "16085"
75
+ * console.log(userLabels[0].ai_labels.topics[0].label) // "arts_culture"
76
+ * console.log(userLabels[0].ai_labels.topics[0].score) // 0.023266956986850353
77
+ * ```
78
+ */
79
+ export declare function getLabels(httpClient: IHttpClient, userList: Array<string>, labelCategory?: LabelCategories, options?: UserLabelsOptions): Promise<UserLabelsResponse>;
80
+ //# sourceMappingURL=user.d.ts.map
@@ -0,0 +1,124 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.similar = similar;
7
+ exports.byQuery = byQuery;
8
+ exports.getTopByLabel = getTopByLabel;
9
+ exports.getLabels = getLabels;
10
+ /**
11
+ * Get similar users for a given user ID
12
+ *
13
+ * @param httpClient - HTTP client instance
14
+ * @param userId - The user ID (fid) to find similar users for
15
+ * @param options - Optional configuration with top_k parameter
16
+ * @returns Promise<UserSimilarityResponse> - Array of similar users with scores
17
+ *
18
+ * @example
19
+ * ```typescript
20
+ * const similarUsers = await client.search.users.similar("16085", { top_k: 10 })
21
+ * console.log(similarUsers[0].user_id) // "3"
22
+ * console.log(similarUsers[0].score) // 0.931880295
23
+ * ```
24
+ */
25
+ async function similar(httpClient, userId, options) {
26
+ const top_k = options?.top_k ?? 25;
27
+ const params = {
28
+ user_id: userId,
29
+ top_k,
30
+ ...options
31
+ };
32
+ const response = await httpClient.post("/v2/farcaster/users/feed/similar", params);
33
+ return response.body;
34
+ }
35
+ /**
36
+ * Search for users by semantic query
37
+ *
38
+ * @param httpClient - HTTP client instance
39
+ * @param query - The text query to search for similar users
40
+ * @param options - Optional configuration with top_k parameter
41
+ * @returns Promise<UserSemanticSearchResponse> - Array of users matching the query with scores
42
+ *
43
+ * @example
44
+ * ```typescript
45
+ * const users = await client.search.users.byQuery("web3 developers", { top_k: 10 })
46
+ * console.log(users[0].user_id) // "444746"
47
+ * console.log(users[0].score) // 0.697465777
48
+ * ```
49
+ */
50
+ async function byQuery(httpClient, query, options) {
51
+ const top_k = options?.top_k ?? 25;
52
+ const params = {
53
+ query,
54
+ top_k,
55
+ ...options
56
+ };
57
+ const response = await httpClient.post("/v2/farcaster/users/search/semantic", params);
58
+ return response.body;
59
+ }
60
+ /**
61
+ * Get top users by AI label
62
+ *
63
+ * @param httpClient - HTTP client instance
64
+ * @param label - The AI label to get top users for
65
+ * @param options - Optional configuration including top_k, minimum_activity_count, ratio_min, conf_min
66
+ * @returns Promise<UserTopByLabelResponse> - Array of top users for the label with scores, counts, and ratios
67
+ *
68
+ * @example
69
+ * ```typescript
70
+ * const topUsers = await client.search.users.getTopByLabel("science_technology", {
71
+ * top_k: 50,
72
+ * minimum_activity_count: 20,
73
+ * ratio_min: 0.8,
74
+ * conf_min: 0.7
75
+ * })
76
+ * console.log(topUsers[0].user_id) // "520701"
77
+ * console.log(topUsers[0].score) // 0.9471641778666666
78
+ * console.log(topUsers[0].count) // 12
79
+ * console.log(topUsers[0].ratio) // 1
80
+ * ```
81
+ */
82
+ async function getTopByLabel(httpClient, label, options) {
83
+ const top_k = options?.top_k ?? 100;
84
+ const minimum_activity_count = options?.minimum_activity_count ?? 10;
85
+ const ratio_min = options?.ratio_min ?? 0.75;
86
+ const conf_min = options?.conf_min ?? 0.6;
87
+ const params = {
88
+ label,
89
+ top_k,
90
+ minimum_activity_count,
91
+ ratio_min,
92
+ conf_min,
93
+ ...options
94
+ };
95
+ const response = await httpClient.post("/v2/farcaster/users/labels/top-users", params);
96
+ return response.body;
97
+ }
98
+ /**
99
+ * Get AI labels for a list of users
100
+ *
101
+ * @param httpClient - HTTP client instance
102
+ * @param userList - Array of user IDs to get labels for
103
+ * @param labelCategory - The category of labels to retrieve (default: "all")
104
+ * @param options - Optional configuration
105
+ * @returns Promise<UserLabelsResponse> - Array of users with their AI labels
106
+ *
107
+ * @example
108
+ * ```typescript
109
+ * const userLabels = await client.search.users.getLabels(["16085", "239", "3"], "topics")
110
+ * console.log(userLabels[0].user_id) // "16085"
111
+ * console.log(userLabels[0].ai_labels.topics[0].label) // "arts_culture"
112
+ * console.log(userLabels[0].ai_labels.topics[0].score) // 0.023266956986850353
113
+ * ```
114
+ */
115
+ async function getLabels(httpClient, userList, labelCategory = "all", options) {
116
+ const params = {
117
+ users_list: userList,
118
+ label_category: labelCategory,
119
+ ...options
120
+ };
121
+ const response = await httpClient.post("/v2/farcaster/users/labels/for-users", params);
122
+ return response.body;
123
+ }
124
+ //# sourceMappingURL=user.js.map