influship 0.2.0 → 0.3.2

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.
Files changed (262) hide show
  1. package/CHANGELOG.md +62 -30
  2. package/LICENSE +1 -1
  3. package/README.md +88 -43
  4. package/client.d.mts +49 -29
  5. package/client.d.mts.map +1 -1
  6. package/client.d.ts +49 -29
  7. package/client.d.ts.map +1 -1
  8. package/client.js +89 -56
  9. package/client.js.map +1 -1
  10. package/client.mjs +89 -56
  11. package/client.mjs.map +1 -1
  12. package/core/api-promise.d.mts +2 -2
  13. package/core/api-promise.d.mts.map +1 -1
  14. package/core/api-promise.d.ts +2 -2
  15. package/core/api-promise.d.ts.map +1 -1
  16. package/core/api-promise.js.map +1 -1
  17. package/core/api-promise.mjs.map +1 -1
  18. package/core/error.d.mts +2 -2
  19. package/core/error.d.mts.map +1 -1
  20. package/core/error.d.ts +2 -2
  21. package/core/error.d.ts.map +1 -1
  22. package/core/error.js +4 -4
  23. package/core/error.js.map +1 -1
  24. package/core/error.mjs +2 -2
  25. package/core/error.mjs.map +1 -1
  26. package/core/pagination.d.mts +75 -0
  27. package/core/pagination.d.mts.map +1 -0
  28. package/core/pagination.d.ts +75 -0
  29. package/core/pagination.d.ts.map +1 -0
  30. package/core/pagination.js +139 -0
  31. package/core/pagination.js.map +1 -0
  32. package/core/pagination.mjs +132 -0
  33. package/core/pagination.mjs.map +1 -0
  34. package/core/resource.d.mts +3 -3
  35. package/core/resource.d.mts.map +1 -1
  36. package/core/resource.d.ts +3 -3
  37. package/core/resource.d.ts.map +1 -1
  38. package/core/resource.js.map +1 -1
  39. package/core/resource.mjs.map +1 -1
  40. package/index.d.mts +4 -3
  41. package/index.d.mts.map +1 -1
  42. package/index.d.ts +4 -3
  43. package/index.d.ts.map +1 -1
  44. package/index.js +6 -4
  45. package/index.js.map +1 -1
  46. package/index.mjs +4 -3
  47. package/index.mjs.map +1 -1
  48. package/internal/parse.d.mts +2 -2
  49. package/internal/parse.d.mts.map +1 -1
  50. package/internal/parse.d.ts +2 -2
  51. package/internal/parse.d.ts.map +1 -1
  52. package/internal/parse.js +5 -0
  53. package/internal/parse.js.map +1 -1
  54. package/internal/parse.mjs +5 -0
  55. package/internal/parse.mjs.map +1 -1
  56. package/internal/shims.js +1 -1
  57. package/internal/shims.js.map +1 -1
  58. package/internal/shims.mjs +1 -1
  59. package/internal/shims.mjs.map +1 -1
  60. package/internal/tslib.js +17 -17
  61. package/internal/uploads.d.mts +4 -4
  62. package/internal/uploads.d.mts.map +1 -1
  63. package/internal/uploads.d.ts +4 -4
  64. package/internal/uploads.d.ts.map +1 -1
  65. package/internal/uploads.js.map +1 -1
  66. package/internal/uploads.mjs.map +1 -1
  67. package/internal/utils/base64.js +2 -2
  68. package/internal/utils/base64.js.map +1 -1
  69. package/internal/utils/base64.mjs +3 -3
  70. package/internal/utils/base64.mjs.map +1 -1
  71. package/internal/utils/log.d.mts +3 -3
  72. package/internal/utils/log.d.mts.map +1 -1
  73. package/internal/utils/log.d.ts +3 -3
  74. package/internal/utils/log.d.ts.map +1 -1
  75. package/internal/utils/log.js.map +1 -1
  76. package/internal/utils/log.mjs.map +1 -1
  77. package/internal/utils/path.js +1 -1
  78. package/internal/utils/path.js.map +1 -1
  79. package/internal/utils/path.mjs +2 -2
  80. package/internal/utils/path.mjs.map +1 -1
  81. package/internal/utils/query.d.mts +2 -0
  82. package/internal/utils/query.d.mts.map +1 -0
  83. package/internal/utils/query.d.ts +2 -0
  84. package/internal/utils/query.d.ts.map +1 -0
  85. package/internal/utils/query.js +10 -0
  86. package/internal/utils/query.js.map +1 -0
  87. package/internal/utils/query.mjs +6 -0
  88. package/internal/utils/query.mjs.map +1 -0
  89. package/internal/utils/values.js +5 -5
  90. package/internal/utils/values.js.map +1 -1
  91. package/internal/utils/values.mjs +6 -6
  92. package/internal/utils/values.mjs.map +1 -1
  93. package/internal/utils.d.mts +1 -0
  94. package/internal/utils.d.ts +1 -0
  95. package/internal/utils.js +1 -0
  96. package/internal/utils.js.map +1 -1
  97. package/internal/utils.mjs +1 -0
  98. package/package.json +24 -3
  99. package/pagination.d.mts +2 -0
  100. package/pagination.d.mts.map +1 -0
  101. package/pagination.d.ts +2 -0
  102. package/pagination.d.ts.map +1 -0
  103. package/pagination.js +6 -0
  104. package/pagination.js.map +1 -0
  105. package/pagination.mjs +2 -0
  106. package/pagination.mjs.map +1 -0
  107. package/resources/creators.d.mts +326 -247
  108. package/resources/creators.d.mts.map +1 -1
  109. package/resources/creators.d.ts +326 -247
  110. package/resources/creators.d.ts.map +1 -1
  111. package/resources/creators.js +80 -63
  112. package/resources/creators.js.map +1 -1
  113. package/resources/creators.mjs +80 -63
  114. package/resources/creators.mjs.map +1 -1
  115. package/resources/health.d.mts +13 -1
  116. package/resources/health.d.mts.map +1 -1
  117. package/resources/health.d.ts +13 -1
  118. package/resources/health.d.ts.map +1 -1
  119. package/resources/health.js +4 -1
  120. package/resources/health.js.map +1 -1
  121. package/resources/health.mjs +4 -1
  122. package/resources/health.mjs.map +1 -1
  123. package/resources/index.d.mts +6 -7
  124. package/resources/index.d.mts.map +1 -1
  125. package/resources/index.d.ts +6 -7
  126. package/resources/index.d.ts.map +1 -1
  127. package/resources/index.js +5 -7
  128. package/resources/index.js.map +1 -1
  129. package/resources/index.mjs +2 -3
  130. package/resources/index.mjs.map +1 -1
  131. package/resources/posts.d.mts +82 -202
  132. package/resources/posts.d.mts.map +1 -1
  133. package/resources/posts.d.ts +82 -202
  134. package/resources/posts.d.ts.map +1 -1
  135. package/resources/posts.js +17 -38
  136. package/resources/posts.js.map +1 -1
  137. package/resources/posts.mjs +17 -38
  138. package/resources/posts.mjs.map +1 -1
  139. package/resources/profiles.d.mts +208 -58
  140. package/resources/profiles.d.mts.map +1 -1
  141. package/resources/profiles.d.ts +208 -58
  142. package/resources/profiles.d.ts.map +1 -1
  143. package/resources/profiles.js +37 -41
  144. package/resources/profiles.js.map +1 -1
  145. package/resources/profiles.mjs +37 -41
  146. package/resources/profiles.mjs.map +1 -1
  147. package/resources/raw/index.d.mts +4 -0
  148. package/resources/raw/index.d.mts.map +1 -0
  149. package/resources/raw/index.d.ts +4 -0
  150. package/resources/raw/index.d.ts.map +1 -0
  151. package/resources/raw/index.js +11 -0
  152. package/resources/raw/index.js.map +1 -0
  153. package/resources/raw/index.mjs +5 -0
  154. package/resources/raw/index.mjs.map +1 -0
  155. package/resources/raw/instagram.d.mts +215 -0
  156. package/resources/raw/instagram.d.mts.map +1 -0
  157. package/resources/raw/instagram.d.ts +215 -0
  158. package/resources/raw/instagram.d.ts.map +1 -0
  159. package/resources/raw/instagram.js +31 -0
  160. package/resources/raw/instagram.js.map +1 -0
  161. package/resources/raw/instagram.mjs +27 -0
  162. package/resources/raw/instagram.mjs.map +1 -0
  163. package/resources/raw/raw.d.mts +14 -0
  164. package/resources/raw/raw.d.mts.map +1 -0
  165. package/resources/raw/raw.d.ts +14 -0
  166. package/resources/raw/raw.d.ts.map +1 -0
  167. package/resources/raw/raw.js +21 -0
  168. package/resources/raw/raw.js.map +1 -0
  169. package/resources/raw/raw.mjs +16 -0
  170. package/resources/raw/raw.mjs.map +1 -0
  171. package/resources/raw/youtube.d.mts +455 -0
  172. package/resources/raw/youtube.d.mts.map +1 -0
  173. package/resources/raw/youtube.d.ts +455 -0
  174. package/resources/raw/youtube.d.ts.map +1 -0
  175. package/resources/raw/youtube.js +61 -0
  176. package/resources/raw/youtube.js.map +1 -0
  177. package/resources/raw/youtube.mjs +57 -0
  178. package/resources/raw/youtube.mjs.map +1 -0
  179. package/resources/raw.d.mts +2 -0
  180. package/resources/raw.d.mts.map +1 -0
  181. package/resources/raw.d.ts +2 -0
  182. package/resources/raw.d.ts.map +1 -0
  183. package/resources/raw.js +6 -0
  184. package/resources/raw.js.map +1 -0
  185. package/resources/raw.mjs +3 -0
  186. package/resources/raw.mjs.map +1 -0
  187. package/resources/search.d.mts +126 -117
  188. package/resources/search.d.mts.map +1 -1
  189. package/resources/search.d.ts +126 -117
  190. package/resources/search.d.ts.map +1 -1
  191. package/resources/search.js +46 -13
  192. package/resources/search.js.map +1 -1
  193. package/resources/search.mjs +46 -13
  194. package/resources/search.mjs.map +1 -1
  195. package/resources/shared.d.mts +55 -0
  196. package/resources/shared.d.mts.map +1 -0
  197. package/resources/shared.d.ts +55 -0
  198. package/resources/shared.d.ts.map +1 -0
  199. package/resources/shared.js +4 -0
  200. package/resources/shared.js.map +1 -0
  201. package/resources/shared.mjs +3 -0
  202. package/resources/shared.mjs.map +1 -0
  203. package/src/client.ts +153 -127
  204. package/src/core/api-promise.ts +4 -4
  205. package/src/core/error.ts +2 -2
  206. package/src/core/pagination.ts +232 -0
  207. package/src/core/resource.ts +3 -3
  208. package/src/index.ts +4 -3
  209. package/src/internal/parse.ts +8 -2
  210. package/src/internal/shims.ts +1 -1
  211. package/src/internal/uploads.ts +5 -5
  212. package/src/internal/utils/base64.ts +3 -3
  213. package/src/internal/utils/log.ts +3 -3
  214. package/src/internal/utils/path.ts +2 -2
  215. package/src/internal/utils/query.ts +7 -0
  216. package/src/internal/utils/values.ts +6 -6
  217. package/src/internal/utils.ts +1 -0
  218. package/src/pagination.ts +2 -0
  219. package/src/resources/creators.ts +369 -271
  220. package/src/resources/health.ts +13 -1
  221. package/src/resources/index.ts +22 -41
  222. package/src/resources/posts.ts +89 -232
  223. package/src/resources/profiles.ts +252 -59
  224. package/src/resources/raw/index.ts +16 -0
  225. package/src/resources/raw/instagram.ts +271 -0
  226. package/src/resources/raw/raw.ts +47 -0
  227. package/src/resources/raw/youtube.ts +585 -0
  228. package/src/resources/raw.ts +3 -0
  229. package/src/resources/search.ts +145 -131
  230. package/src/resources/shared.ts +66 -0
  231. package/src/version.ts +1 -1
  232. package/version.d.mts +1 -1
  233. package/version.d.ts +1 -1
  234. package/version.js +1 -1
  235. package/version.mjs +1 -1
  236. package/resources/brand-safety.d.mts +0 -234
  237. package/resources/brand-safety.d.mts.map +0 -1
  238. package/resources/brand-safety.d.ts +0 -234
  239. package/resources/brand-safety.d.ts.map +0 -1
  240. package/resources/brand-safety.js +0 -75
  241. package/resources/brand-safety.js.map +0 -1
  242. package/resources/brand-safety.mjs +0 -71
  243. package/resources/brand-safety.mjs.map +0 -1
  244. package/resources/lookalike.d.mts +0 -142
  245. package/resources/lookalike.d.mts.map +0 -1
  246. package/resources/lookalike.d.ts +0 -142
  247. package/resources/lookalike.d.ts.map +0 -1
  248. package/resources/lookalike.js +0 -28
  249. package/resources/lookalike.js.map +0 -1
  250. package/resources/lookalike.mjs +0 -24
  251. package/resources/lookalike.mjs.map +0 -1
  252. package/resources/match.d.mts +0 -90
  253. package/resources/match.d.mts.map +0 -1
  254. package/resources/match.d.ts +0 -90
  255. package/resources/match.d.ts.map +0 -1
  256. package/resources/match.js +0 -22
  257. package/resources/match.js.map +0 -1
  258. package/resources/match.mjs +0 -18
  259. package/resources/match.mjs.map +0 -1
  260. package/src/resources/brand-safety.ts +0 -304
  261. package/src/resources/lookalike.ts +0 -186
  262. package/src/resources/match.ts +0 -115
package/src/client.ts CHANGED
@@ -11,67 +11,55 @@ import type { APIResponseProps } from './internal/parse';
11
11
  import { getPlatformHeaders } from './internal/detect-platform';
12
12
  import * as Shims from './internal/shims';
13
13
  import * as Opts from './internal/request-options';
14
- import * as qs from './internal/qs';
14
+ import { stringifyQuery } from './internal/utils/query';
15
15
  import { VERSION } from './version';
16
16
  import * as Errors from './core/error';
17
+ import * as Pagination from './core/pagination';
18
+ import {
19
+ AbstractPage,
20
+ type BodyCursorParams,
21
+ BodyCursorResponse,
22
+ type QueryCursorParams,
23
+ QueryCursorResponse,
24
+ } from './core/pagination';
17
25
  import * as Uploads from './core/uploads';
18
26
  import * as API from './resources/index';
19
27
  import { APIPromise } from './core/api-promise';
20
28
  import {
21
- BrandSafety,
22
- BrandSafetyAnalysis,
23
- BrandSafetyAnalyzeCreatorsParams,
24
- BrandSafetyAnalyzeCreatorsResponse,
25
- BrandSafetyAnalyzePostsParams,
26
- BrandSafetyAnalyzePostsResponse,
27
- BrandSafetyAnalyzeProfilesParams,
28
- BrandSafetyAnalyzeProfilesResponse,
29
- BrandSafetyFlag,
30
- BrandSafetyResult,
31
- } from './resources/brand-safety';
32
- import {
33
- Creator,
34
- CreatorAutocomplete,
35
29
  CreatorAutocompleteParams,
36
30
  CreatorAutocompleteResponse,
37
- CreatorListProfilesParams,
38
- CreatorListProfilesResponse,
31
+ CreatorLookalikeParams,
32
+ CreatorLookalikeResponse,
33
+ CreatorLookalikeResponsesBodyCursor,
34
+ CreatorMatchParams,
35
+ CreatorMatchResponse,
39
36
  CreatorRetrieveParams,
40
37
  CreatorRetrieveResponse,
41
38
  Creators,
42
- SocialAccountDetailed,
43
- SocialAccountLite,
44
39
  } from './resources/creators';
45
40
  import { Health, HealthCheckResponse } from './resources/health';
41
+ import { PostListParams, PostListResponse, PostListResponsesQueryCursor, Posts } from './resources/posts';
46
42
  import {
47
- Lookalike,
48
- LookalikeFindSimilarCreatorsParams,
49
- LookalikeFindSimilarCreatorsResponse,
50
- LookalikeSeedBase,
51
- } from './resources/lookalike';
52
- import {
53
- CreatorReferenceByID,
54
- Match,
55
- MatchAnalyzeParams,
56
- MatchAnalyzeResponse,
57
- MatchResult,
58
- } from './resources/match';
59
- import {
60
- AIAnalysis,
61
- CursorPagination,
62
- PostAnalysis,
63
- PostAnalyzeParams,
64
- PostListByCreatorParams,
65
- PostListByCreatorResponse,
66
- Posts,
67
- } from './resources/posts';
68
- import {
69
- CreatorReferenceByHandle,
43
+ ProfileActivity,
44
+ ProfileGetParams,
45
+ ProfileGetResponse,
46
+ ProfileGrowth,
70
47
  ProfileLookupParams,
71
48
  ProfileLookupResponse,
49
+ ProfileMetrics,
50
+ ProfileResponseData,
72
51
  Profiles,
73
52
  } from './resources/profiles';
74
- import { Search, SearchFindCreatorsParams, SearchFindCreatorsResponse, SearchItem } from './resources/search';
53
+ import {
54
+ MatchInfo,
55
+ Search,
56
+ SearchCreateParams,
57
+ SearchCreateResponse,
58
+ SearchRetrieveParams,
59
+ SearchRetrieveResponse,
60
+ SearchRetrieveResponsesQueryCursor,
61
+ } from './resources/search';
62
+ import { Raw } from './resources/raw/raw';
75
63
  import { type Fetch } from './internal/builtin-types';
76
64
  import { HeadersLike, NullableHeaders, buildHeaders } from './internal/headers';
77
65
  import { FinalRequestOptions, RequestOptions } from './internal/request-options';
@@ -87,14 +75,14 @@ import { isEmptyObj } from './internal/utils/values';
87
75
 
88
76
  export interface ClientOptions {
89
77
  /**
90
- * API key for authentication
78
+ * Defaults to process.env['INFLUSHIP_API_KEY'].
91
79
  */
92
80
  apiKey?: string | undefined;
93
81
 
94
82
  /**
95
83
  * Override the default base URL for the API, e.g., "https://api.example.com/v2/"
96
84
  *
97
- * Defaults to process.env['INFLUSHIP_API_BASE_URL'].
85
+ * Defaults to process.env['INFLUSHIP_BASE_URL'].
98
86
  */
99
87
  baseURL?: string | null | undefined;
100
88
 
@@ -148,7 +136,7 @@ export interface ClientOptions {
148
136
  /**
149
137
  * Set the log level.
150
138
  *
151
- * Defaults to process.env['INFLUSHIP_API_LOG'] or 'warn' if it isn't set.
139
+ * Defaults to process.env['INFLUSHIP_LOG'] or 'warn' if it isn't set.
152
140
  */
153
141
  logLevel?: LogLevel | undefined;
154
142
 
@@ -161,9 +149,9 @@ export interface ClientOptions {
161
149
  }
162
150
 
163
151
  /**
164
- * API Client for interfacing with the Influship API API.
152
+ * API Client for interfacing with the Influship API.
165
153
  */
166
- export class InflushipAPI {
154
+ export class Influship {
167
155
  apiKey: string;
168
156
 
169
157
  baseURL: string;
@@ -179,10 +167,10 @@ export class InflushipAPI {
179
167
  private _options: ClientOptions;
180
168
 
181
169
  /**
182
- * API Client for interfacing with the Influship API API.
170
+ * API Client for interfacing with the Influship API.
183
171
  *
184
172
  * @param {string | undefined} [opts.apiKey=process.env['INFLUSHIP_API_KEY'] ?? undefined]
185
- * @param {string} [opts.baseURL=process.env['INFLUSHIP_API_BASE_URL'] ?? https://api.influship.com] - Override the default base URL for the API.
173
+ * @param {string} [opts.baseURL=process.env['INFLUSHIP_BASE_URL'] ?? https://api.influship.com] - Override the default base URL for the API.
186
174
  * @param {number} [opts.timeout=1 minute] - The maximum amount of time (in milliseconds) the client will wait for a response before timing out.
187
175
  * @param {MergedRequestInit} [opts.fetchOptions] - Additional `RequestInit` options to be passed to `fetch` calls.
188
176
  * @param {Fetch} [opts.fetch] - Specify a custom `fetch` function implementation.
@@ -191,13 +179,13 @@ export class InflushipAPI {
191
179
  * @param {Record<string, string | undefined>} opts.defaultQuery - Default query parameters to include with every request to the API.
192
180
  */
193
181
  constructor({
194
- baseURL = readEnv('INFLUSHIP_API_BASE_URL'),
182
+ baseURL = readEnv('INFLUSHIP_BASE_URL'),
195
183
  apiKey = readEnv('INFLUSHIP_API_KEY'),
196
184
  ...opts
197
185
  }: ClientOptions = {}) {
198
186
  if (apiKey === undefined) {
199
- throw new Errors.InflushipAPIError(
200
- "The INFLUSHIP_API_KEY environment variable is missing or empty; either provide it, or instantiate the InflushipAPI client with an apiKey option, like new InflushipAPI({ apiKey: 'My API Key' }).",
187
+ throw new Errors.InflushipError(
188
+ "The INFLUSHIP_API_KEY environment variable is missing or empty; either provide it, or instantiate the Influship client with an apiKey option, like new Influship({ apiKey: 'My API Key' }).",
201
189
  );
202
190
  }
203
191
 
@@ -208,14 +196,14 @@ export class InflushipAPI {
208
196
  };
209
197
 
210
198
  this.baseURL = options.baseURL!;
211
- this.timeout = options.timeout ?? InflushipAPI.DEFAULT_TIMEOUT /* 1 minute */;
199
+ this.timeout = options.timeout ?? Influship.DEFAULT_TIMEOUT /* 1 minute */;
212
200
  this.logger = options.logger ?? console;
213
201
  const defaultLogLevel = 'warn';
214
202
  // Set default logLevel early so that we can log a warning in parseLogLevel.
215
203
  this.logLevel = defaultLogLevel;
216
204
  this.logLevel =
217
205
  parseLogLevel(options.logLevel, 'ClientOptions.logLevel', this) ??
218
- parseLogLevel(readEnv('INFLUSHIP_API_LOG'), "process.env['INFLUSHIP_API_LOG']", this) ??
206
+ parseLogLevel(readEnv('INFLUSHIP_LOG'), "process.env['INFLUSHIP_LOG']", this) ??
219
207
  defaultLogLevel;
220
208
  this.fetchOptions = options.fetchOptions;
221
209
  this.maxRetries = options.maxRetries ?? 2;
@@ -265,8 +253,8 @@ export class InflushipAPI {
265
253
  return buildHeaders([{ 'X-API-Key': this.apiKey }]);
266
254
  }
267
255
 
268
- protected stringifyQuery(query: Record<string, unknown>): string {
269
- return qs.stringify(query, { arrayFormat: 'comma' });
256
+ protected stringifyQuery(query: object | Record<string, unknown>): string {
257
+ return stringifyQuery(query);
270
258
  }
271
259
 
272
260
  private getUserAgent(): string {
@@ -298,12 +286,13 @@ export class InflushipAPI {
298
286
  : new URL(baseURL + (baseURL.endsWith('/') && path.startsWith('/') ? path.slice(1) : path));
299
287
 
300
288
  const defaultQuery = this.defaultQuery();
301
- if (!isEmptyObj(defaultQuery)) {
302
- query = { ...defaultQuery, ...query };
289
+ const pathQuery = Object.fromEntries(url.searchParams);
290
+ if (!isEmptyObj(defaultQuery) || !isEmptyObj(pathQuery)) {
291
+ query = { ...pathQuery, ...defaultQuery, ...query };
303
292
  }
304
293
 
305
294
  if (typeof query === 'object' && query && !Array.isArray(query)) {
306
- url.search = this.stringifyQuery(query as Record<string, unknown>);
295
+ url.search = this.stringifyQuery(query);
307
296
  }
308
297
 
309
298
  return url.toString();
@@ -487,7 +476,7 @@ export class InflushipAPI {
487
476
  loggerFor(this).info(`${responseInfo} - ${retryMessage}`);
488
477
 
489
478
  const errText = await response.text().catch((err: any) => castToError(err).message);
490
- const errJSON = safeJSON(errText);
479
+ const errJSON = safeJSON(errText) as any;
491
480
  const errMessage = errJSON ? undefined : errText;
492
481
 
493
482
  loggerFor(this).debug(
@@ -521,6 +510,30 @@ export class InflushipAPI {
521
510
  return { response, options, controller, requestLogID, retryOfRequestLogID, startTime };
522
511
  }
523
512
 
513
+ getAPIList<Item, PageClass extends Pagination.AbstractPage<Item> = Pagination.AbstractPage<Item>>(
514
+ path: string,
515
+ Page: new (...args: any[]) => PageClass,
516
+ opts?: PromiseOrValue<RequestOptions>,
517
+ ): Pagination.PagePromise<PageClass, Item> {
518
+ return this.requestAPIList(
519
+ Page,
520
+ opts && 'then' in opts ?
521
+ opts.then((opts) => ({ method: 'get', path, ...opts }))
522
+ : { method: 'get', path, ...opts },
523
+ );
524
+ }
525
+
526
+ requestAPIList<
527
+ Item = unknown,
528
+ PageClass extends Pagination.AbstractPage<Item> = Pagination.AbstractPage<Item>,
529
+ >(
530
+ Page: new (...args: ConstructorParameters<typeof Pagination.AbstractPage>) => PageClass,
531
+ options: PromiseOrValue<FinalRequestOptions>,
532
+ ): Pagination.PagePromise<PageClass, Item> {
533
+ const request = this.makeRequest(options, null, undefined);
534
+ return new Pagination.PagePromise<PageClass, Item>(this as any as Influship, request, Page);
535
+ }
536
+
524
537
  async fetchWithTimeout(
525
538
  url: RequestInfo,
526
539
  init: RequestInit | undefined,
@@ -528,9 +541,10 @@ export class InflushipAPI {
528
541
  controller: AbortController,
529
542
  ): Promise<Response> {
530
543
  const { signal, method, ...options } = init || {};
531
- if (signal) signal.addEventListener('abort', () => controller.abort());
544
+ const abort = this._makeAbort(controller);
545
+ if (signal) signal.addEventListener('abort', abort, { once: true });
532
546
 
533
- const timeout = setTimeout(() => controller.abort(), ms);
547
+ const timeout = setTimeout(abort, ms);
534
548
 
535
549
  const isReadableBody =
536
550
  ((globalThis as any).ReadableStream && options.body instanceof (globalThis as any).ReadableStream) ||
@@ -607,9 +621,9 @@ export class InflushipAPI {
607
621
  }
608
622
  }
609
623
 
610
- // If the API asks us to wait a certain amount of time (and it's a reasonable amount),
611
- // just do what it says, but otherwise calculate a default
612
- if (!(timeoutMillis && 0 <= timeoutMillis && timeoutMillis < 60 * 1000)) {
624
+ // If the API asks us to wait a certain amount of time, just do what it
625
+ // says, but otherwise calculate a default
626
+ if (timeoutMillis === undefined) {
613
627
  const maxRetries = options.maxRetries ?? this.maxRetries;
614
628
  timeoutMillis = this.calculateDefaultRetryTimeoutMillis(retriesRemaining, maxRetries);
615
629
  }
@@ -697,6 +711,12 @@ export class InflushipAPI {
697
711
  return headers.values;
698
712
  }
699
713
 
714
+ private _makeAbort(controller: AbortController) {
715
+ // note: we can't just inline this method inside `fetchWithTimeout()` because then the closure
716
+ // would capture all request options, and cause a memory leak.
717
+ return () => controller.abort();
718
+ }
719
+
700
720
  private buildBody({ options: { body, headers: rawHeaders } }: { options: FinalRequestOptions }): {
701
721
  bodyHeaders: HeadersLike;
702
722
  body: BodyInit | undefined;
@@ -729,15 +749,23 @@ export class InflushipAPI {
729
749
  (Symbol.iterator in body && 'next' in body && typeof body.next === 'function'))
730
750
  ) {
731
751
  return { bodyHeaders: undefined, body: Shims.ReadableStreamFrom(body as AsyncIterable<Uint8Array>) };
752
+ } else if (
753
+ typeof body === 'object' &&
754
+ headers.values.get('content-type') === 'application/x-www-form-urlencoded'
755
+ ) {
756
+ return {
757
+ bodyHeaders: { 'content-type': 'application/x-www-form-urlencoded' },
758
+ body: this.stringifyQuery(body),
759
+ };
732
760
  } else {
733
761
  return this.#encoder({ body, headers });
734
762
  }
735
763
  }
736
764
 
737
- static InflushipAPI = this;
765
+ static Influship = this;
738
766
  static DEFAULT_TIMEOUT = 60000; // 1 minute
739
767
 
740
- static InflushipAPIError = Errors.InflushipAPIError;
768
+ static InflushipError = Errors.InflushipError;
741
769
  static APIError = Errors.APIError;
742
770
  static APIConnectionError = Errors.APIConnectionError;
743
771
  static APIConnectionTimeoutError = Errors.APIConnectionTimeoutError;
@@ -753,93 +781,91 @@ export class InflushipAPI {
753
781
 
754
782
  static toFile = Uploads.toFile;
755
783
 
784
+ /**
785
+ * API health and status endpoints
786
+ */
756
787
  health: API.Health = new API.Health(this);
757
- search: API.Search = new API.Search(this);
788
+ /**
789
+ * Retrieve creator profiles and discover new creators through search, autocomplete, and lookalike matching. Creators are cross-platform entities that may have profiles on multiple social networks.
790
+ */
758
791
  creators: API.Creators = new API.Creators(this);
792
+ /**
793
+ * AI-powered semantic search to find creators using natural language queries. Understands intent and context to match creators based on content themes, audience, and style.
794
+ */
795
+ search: API.Search = new API.Search(this);
796
+ /**
797
+ * Access individual social media profiles with detailed metrics, growth data, and activity information. Profiles are platform-specific accounts linked to creators.
798
+ */
759
799
  profiles: API.Profiles = new API.Profiles(this);
760
- lookalike: API.Lookalike = new API.Lookalike(this);
800
+ /**
801
+ * Retrieve and analyze social media posts with engagement metrics, media content, and performance data.
802
+ */
761
803
  posts: API.Posts = new API.Posts(this);
762
- match: API.Match = new API.Match(this);
763
- brandSafety: API.BrandSafety = new API.BrandSafety(this);
804
+ raw: API.Raw = new API.Raw(this);
764
805
  }
765
806
 
766
- InflushipAPI.Health = Health;
767
- InflushipAPI.Search = Search;
768
- InflushipAPI.Creators = Creators;
769
- InflushipAPI.Profiles = Profiles;
770
- InflushipAPI.Lookalike = Lookalike;
771
- InflushipAPI.Posts = Posts;
772
- InflushipAPI.Match = Match;
773
- InflushipAPI.BrandSafety = BrandSafety;
807
+ Influship.Health = Health;
808
+ Influship.Creators = Creators;
809
+ Influship.Search = Search;
810
+ Influship.Profiles = Profiles;
811
+ Influship.Posts = Posts;
812
+ Influship.Raw = Raw;
774
813
 
775
- export declare namespace InflushipAPI {
814
+ export declare namespace Influship {
776
815
  export type RequestOptions = Opts.RequestOptions;
777
816
 
778
- export { Health as Health, type HealthCheckResponse as HealthCheckResponse };
817
+ export import QueryCursor = Pagination.QueryCursor;
818
+ export { type QueryCursorParams as QueryCursorParams, type QueryCursorResponse as QueryCursorResponse };
779
819
 
780
- export {
781
- Search as Search,
782
- type SearchItem as SearchItem,
783
- type SearchFindCreatorsResponse as SearchFindCreatorsResponse,
784
- type SearchFindCreatorsParams as SearchFindCreatorsParams,
785
- };
820
+ export import BodyCursor = Pagination.BodyCursor;
821
+ export { type BodyCursorParams as BodyCursorParams, type BodyCursorResponse as BodyCursorResponse };
822
+
823
+ export { Health as Health, type HealthCheckResponse as HealthCheckResponse };
786
824
 
787
825
  export {
788
826
  Creators as Creators,
789
- type Creator as Creator,
790
- type CreatorAutocomplete as CreatorAutocomplete,
791
- type SocialAccountDetailed as SocialAccountDetailed,
792
- type SocialAccountLite as SocialAccountLite,
793
827
  type CreatorRetrieveResponse as CreatorRetrieveResponse,
794
828
  type CreatorAutocompleteResponse as CreatorAutocompleteResponse,
795
- type CreatorListProfilesResponse as CreatorListProfilesResponse,
829
+ type CreatorLookalikeResponse as CreatorLookalikeResponse,
830
+ type CreatorMatchResponse as CreatorMatchResponse,
831
+ type CreatorLookalikeResponsesBodyCursor as CreatorLookalikeResponsesBodyCursor,
796
832
  type CreatorRetrieveParams as CreatorRetrieveParams,
797
833
  type CreatorAutocompleteParams as CreatorAutocompleteParams,
798
- type CreatorListProfilesParams as CreatorListProfilesParams,
834
+ type CreatorLookalikeParams as CreatorLookalikeParams,
835
+ type CreatorMatchParams as CreatorMatchParams,
799
836
  };
800
837
 
801
838
  export {
802
- Profiles as Profiles,
803
- type CreatorReferenceByHandle as CreatorReferenceByHandle,
804
- type ProfileLookupResponse as ProfileLookupResponse,
805
- type ProfileLookupParams as ProfileLookupParams,
839
+ Search as Search,
840
+ type MatchInfo as MatchInfo,
841
+ type SearchCreateResponse as SearchCreateResponse,
842
+ type SearchRetrieveResponse as SearchRetrieveResponse,
843
+ type SearchRetrieveResponsesQueryCursor as SearchRetrieveResponsesQueryCursor,
844
+ type SearchCreateParams as SearchCreateParams,
845
+ type SearchRetrieveParams as SearchRetrieveParams,
806
846
  };
807
847
 
808
848
  export {
809
- Lookalike as Lookalike,
810
- type LookalikeSeedBase as LookalikeSeedBase,
811
- type LookalikeFindSimilarCreatorsResponse as LookalikeFindSimilarCreatorsResponse,
812
- type LookalikeFindSimilarCreatorsParams as LookalikeFindSimilarCreatorsParams,
849
+ Profiles as Profiles,
850
+ type ProfileActivity as ProfileActivity,
851
+ type ProfileGrowth as ProfileGrowth,
852
+ type ProfileMetrics as ProfileMetrics,
853
+ type ProfileResponseData as ProfileResponseData,
854
+ type ProfileGetResponse as ProfileGetResponse,
855
+ type ProfileLookupResponse as ProfileLookupResponse,
856
+ type ProfileGetParams as ProfileGetParams,
857
+ type ProfileLookupParams as ProfileLookupParams,
813
858
  };
814
859
 
815
860
  export {
816
861
  Posts as Posts,
817
- type AIAnalysis as AIAnalysis,
818
- type CursorPagination as CursorPagination,
819
- type PostAnalysis as PostAnalysis,
820
- type PostListByCreatorResponse as PostListByCreatorResponse,
821
- type PostAnalyzeParams as PostAnalyzeParams,
822
- type PostListByCreatorParams as PostListByCreatorParams,
862
+ type PostListResponse as PostListResponse,
863
+ type PostListResponsesQueryCursor as PostListResponsesQueryCursor,
864
+ type PostListParams as PostListParams,
823
865
  };
824
866
 
825
- export {
826
- Match as Match,
827
- type CreatorReferenceByID as CreatorReferenceByID,
828
- type MatchResult as MatchResult,
829
- type MatchAnalyzeResponse as MatchAnalyzeResponse,
830
- type MatchAnalyzeParams as MatchAnalyzeParams,
831
- };
867
+ export { Raw as Raw };
832
868
 
833
- export {
834
- BrandSafety as BrandSafety,
835
- type BrandSafetyAnalysis as BrandSafetyAnalysis,
836
- type BrandSafetyFlag as BrandSafetyFlag,
837
- type BrandSafetyResult as BrandSafetyResult,
838
- type BrandSafetyAnalyzeCreatorsResponse as BrandSafetyAnalyzeCreatorsResponse,
839
- type BrandSafetyAnalyzePostsResponse as BrandSafetyAnalyzePostsResponse,
840
- type BrandSafetyAnalyzeProfilesResponse as BrandSafetyAnalyzeProfilesResponse,
841
- type BrandSafetyAnalyzeCreatorsParams as BrandSafetyAnalyzeCreatorsParams,
842
- type BrandSafetyAnalyzePostsParams as BrandSafetyAnalyzePostsParams,
843
- type BrandSafetyAnalyzeProfilesParams as BrandSafetyAnalyzeProfilesParams,
844
- };
869
+ export type CreatorBasic = API.CreatorBasic;
870
+ export type ProfileSummary = API.ProfileSummary;
845
871
  }
@@ -1,6 +1,6 @@
1
1
  // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
2
 
3
- import { type InflushipAPI } from '../client';
3
+ import { type Influship } from '../client';
4
4
 
5
5
  import { type PromiseOrValue } from '../internal/types';
6
6
  import { APIResponseProps, defaultParseResponse } from '../internal/parse';
@@ -11,13 +11,13 @@ import { APIResponseProps, defaultParseResponse } from '../internal/parse';
11
11
  */
12
12
  export class APIPromise<T> extends Promise<T> {
13
13
  private parsedPromise: Promise<T> | undefined;
14
- #client: InflushipAPI;
14
+ #client: Influship;
15
15
 
16
16
  constructor(
17
- client: InflushipAPI,
17
+ client: Influship,
18
18
  private responsePromise: Promise<APIResponseProps>,
19
19
  private parseResponse: (
20
- client: InflushipAPI,
20
+ client: Influship,
21
21
  props: APIResponseProps,
22
22
  ) => PromiseOrValue<T> = defaultParseResponse,
23
23
  ) {
package/src/core/error.ts CHANGED
@@ -2,13 +2,13 @@
2
2
 
3
3
  import { castToError } from '../internal/errors';
4
4
 
5
- export class InflushipAPIError extends Error {}
5
+ export class InflushipError extends Error {}
6
6
 
7
7
  export class APIError<
8
8
  TStatus extends number | undefined = number | undefined,
9
9
  THeaders extends Headers | undefined = Headers | undefined,
10
10
  TError extends Object | undefined = Object | undefined,
11
- > extends InflushipAPIError {
11
+ > extends InflushipError {
12
12
  /** HTTP status for the response that caused the error */
13
13
  readonly status: TStatus;
14
14
  /** HTTP headers for the response that caused the error */