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.
- package/CHANGELOG.md +62 -30
- package/LICENSE +1 -1
- package/README.md +88 -43
- package/client.d.mts +49 -29
- package/client.d.mts.map +1 -1
- package/client.d.ts +49 -29
- package/client.d.ts.map +1 -1
- package/client.js +89 -56
- package/client.js.map +1 -1
- package/client.mjs +89 -56
- package/client.mjs.map +1 -1
- package/core/api-promise.d.mts +2 -2
- package/core/api-promise.d.mts.map +1 -1
- package/core/api-promise.d.ts +2 -2
- package/core/api-promise.d.ts.map +1 -1
- package/core/api-promise.js.map +1 -1
- package/core/api-promise.mjs.map +1 -1
- package/core/error.d.mts +2 -2
- package/core/error.d.mts.map +1 -1
- package/core/error.d.ts +2 -2
- package/core/error.d.ts.map +1 -1
- package/core/error.js +4 -4
- package/core/error.js.map +1 -1
- package/core/error.mjs +2 -2
- package/core/error.mjs.map +1 -1
- package/core/pagination.d.mts +75 -0
- package/core/pagination.d.mts.map +1 -0
- package/core/pagination.d.ts +75 -0
- package/core/pagination.d.ts.map +1 -0
- package/core/pagination.js +139 -0
- package/core/pagination.js.map +1 -0
- package/core/pagination.mjs +132 -0
- package/core/pagination.mjs.map +1 -0
- package/core/resource.d.mts +3 -3
- package/core/resource.d.mts.map +1 -1
- package/core/resource.d.ts +3 -3
- package/core/resource.d.ts.map +1 -1
- package/core/resource.js.map +1 -1
- package/core/resource.mjs.map +1 -1
- package/index.d.mts +4 -3
- package/index.d.mts.map +1 -1
- package/index.d.ts +4 -3
- package/index.d.ts.map +1 -1
- package/index.js +6 -4
- package/index.js.map +1 -1
- package/index.mjs +4 -3
- package/index.mjs.map +1 -1
- package/internal/parse.d.mts +2 -2
- package/internal/parse.d.mts.map +1 -1
- package/internal/parse.d.ts +2 -2
- package/internal/parse.d.ts.map +1 -1
- package/internal/parse.js +5 -0
- package/internal/parse.js.map +1 -1
- package/internal/parse.mjs +5 -0
- package/internal/parse.mjs.map +1 -1
- package/internal/shims.js +1 -1
- package/internal/shims.js.map +1 -1
- package/internal/shims.mjs +1 -1
- package/internal/shims.mjs.map +1 -1
- package/internal/tslib.js +17 -17
- package/internal/uploads.d.mts +4 -4
- package/internal/uploads.d.mts.map +1 -1
- package/internal/uploads.d.ts +4 -4
- package/internal/uploads.d.ts.map +1 -1
- package/internal/uploads.js.map +1 -1
- package/internal/uploads.mjs.map +1 -1
- package/internal/utils/base64.js +2 -2
- package/internal/utils/base64.js.map +1 -1
- package/internal/utils/base64.mjs +3 -3
- package/internal/utils/base64.mjs.map +1 -1
- package/internal/utils/log.d.mts +3 -3
- package/internal/utils/log.d.mts.map +1 -1
- package/internal/utils/log.d.ts +3 -3
- package/internal/utils/log.d.ts.map +1 -1
- package/internal/utils/log.js.map +1 -1
- package/internal/utils/log.mjs.map +1 -1
- package/internal/utils/path.js +1 -1
- package/internal/utils/path.js.map +1 -1
- package/internal/utils/path.mjs +2 -2
- package/internal/utils/path.mjs.map +1 -1
- package/internal/utils/query.d.mts +2 -0
- package/internal/utils/query.d.mts.map +1 -0
- package/internal/utils/query.d.ts +2 -0
- package/internal/utils/query.d.ts.map +1 -0
- package/internal/utils/query.js +10 -0
- package/internal/utils/query.js.map +1 -0
- package/internal/utils/query.mjs +6 -0
- package/internal/utils/query.mjs.map +1 -0
- package/internal/utils/values.js +5 -5
- package/internal/utils/values.js.map +1 -1
- package/internal/utils/values.mjs +6 -6
- package/internal/utils/values.mjs.map +1 -1
- package/internal/utils.d.mts +1 -0
- package/internal/utils.d.ts +1 -0
- package/internal/utils.js +1 -0
- package/internal/utils.js.map +1 -1
- package/internal/utils.mjs +1 -0
- package/package.json +24 -3
- package/pagination.d.mts +2 -0
- package/pagination.d.mts.map +1 -0
- package/pagination.d.ts +2 -0
- package/pagination.d.ts.map +1 -0
- package/pagination.js +6 -0
- package/pagination.js.map +1 -0
- package/pagination.mjs +2 -0
- package/pagination.mjs.map +1 -0
- package/resources/creators.d.mts +326 -247
- package/resources/creators.d.mts.map +1 -1
- package/resources/creators.d.ts +326 -247
- package/resources/creators.d.ts.map +1 -1
- package/resources/creators.js +80 -63
- package/resources/creators.js.map +1 -1
- package/resources/creators.mjs +80 -63
- package/resources/creators.mjs.map +1 -1
- package/resources/health.d.mts +13 -1
- package/resources/health.d.mts.map +1 -1
- package/resources/health.d.ts +13 -1
- package/resources/health.d.ts.map +1 -1
- package/resources/health.js +4 -1
- package/resources/health.js.map +1 -1
- package/resources/health.mjs +4 -1
- package/resources/health.mjs.map +1 -1
- package/resources/index.d.mts +6 -7
- package/resources/index.d.mts.map +1 -1
- package/resources/index.d.ts +6 -7
- package/resources/index.d.ts.map +1 -1
- package/resources/index.js +5 -7
- package/resources/index.js.map +1 -1
- package/resources/index.mjs +2 -3
- package/resources/index.mjs.map +1 -1
- package/resources/posts.d.mts +82 -202
- package/resources/posts.d.mts.map +1 -1
- package/resources/posts.d.ts +82 -202
- package/resources/posts.d.ts.map +1 -1
- package/resources/posts.js +17 -38
- package/resources/posts.js.map +1 -1
- package/resources/posts.mjs +17 -38
- package/resources/posts.mjs.map +1 -1
- package/resources/profiles.d.mts +208 -58
- package/resources/profiles.d.mts.map +1 -1
- package/resources/profiles.d.ts +208 -58
- package/resources/profiles.d.ts.map +1 -1
- package/resources/profiles.js +37 -41
- package/resources/profiles.js.map +1 -1
- package/resources/profiles.mjs +37 -41
- package/resources/profiles.mjs.map +1 -1
- package/resources/raw/index.d.mts +4 -0
- package/resources/raw/index.d.mts.map +1 -0
- package/resources/raw/index.d.ts +4 -0
- package/resources/raw/index.d.ts.map +1 -0
- package/resources/raw/index.js +11 -0
- package/resources/raw/index.js.map +1 -0
- package/resources/raw/index.mjs +5 -0
- package/resources/raw/index.mjs.map +1 -0
- package/resources/raw/instagram.d.mts +215 -0
- package/resources/raw/instagram.d.mts.map +1 -0
- package/resources/raw/instagram.d.ts +215 -0
- package/resources/raw/instagram.d.ts.map +1 -0
- package/resources/raw/instagram.js +31 -0
- package/resources/raw/instagram.js.map +1 -0
- package/resources/raw/instagram.mjs +27 -0
- package/resources/raw/instagram.mjs.map +1 -0
- package/resources/raw/raw.d.mts +14 -0
- package/resources/raw/raw.d.mts.map +1 -0
- package/resources/raw/raw.d.ts +14 -0
- package/resources/raw/raw.d.ts.map +1 -0
- package/resources/raw/raw.js +21 -0
- package/resources/raw/raw.js.map +1 -0
- package/resources/raw/raw.mjs +16 -0
- package/resources/raw/raw.mjs.map +1 -0
- package/resources/raw/youtube.d.mts +455 -0
- package/resources/raw/youtube.d.mts.map +1 -0
- package/resources/raw/youtube.d.ts +455 -0
- package/resources/raw/youtube.d.ts.map +1 -0
- package/resources/raw/youtube.js +61 -0
- package/resources/raw/youtube.js.map +1 -0
- package/resources/raw/youtube.mjs +57 -0
- package/resources/raw/youtube.mjs.map +1 -0
- package/resources/raw.d.mts +2 -0
- package/resources/raw.d.mts.map +1 -0
- package/resources/raw.d.ts +2 -0
- package/resources/raw.d.ts.map +1 -0
- package/resources/raw.js +6 -0
- package/resources/raw.js.map +1 -0
- package/resources/raw.mjs +3 -0
- package/resources/raw.mjs.map +1 -0
- package/resources/search.d.mts +126 -117
- package/resources/search.d.mts.map +1 -1
- package/resources/search.d.ts +126 -117
- package/resources/search.d.ts.map +1 -1
- package/resources/search.js +46 -13
- package/resources/search.js.map +1 -1
- package/resources/search.mjs +46 -13
- package/resources/search.mjs.map +1 -1
- package/resources/shared.d.mts +55 -0
- package/resources/shared.d.mts.map +1 -0
- package/resources/shared.d.ts +55 -0
- package/resources/shared.d.ts.map +1 -0
- package/resources/shared.js +4 -0
- package/resources/shared.js.map +1 -0
- package/resources/shared.mjs +3 -0
- package/resources/shared.mjs.map +1 -0
- package/src/client.ts +153 -127
- package/src/core/api-promise.ts +4 -4
- package/src/core/error.ts +2 -2
- package/src/core/pagination.ts +232 -0
- package/src/core/resource.ts +3 -3
- package/src/index.ts +4 -3
- package/src/internal/parse.ts +8 -2
- package/src/internal/shims.ts +1 -1
- package/src/internal/uploads.ts +5 -5
- package/src/internal/utils/base64.ts +3 -3
- package/src/internal/utils/log.ts +3 -3
- package/src/internal/utils/path.ts +2 -2
- package/src/internal/utils/query.ts +7 -0
- package/src/internal/utils/values.ts +6 -6
- package/src/internal/utils.ts +1 -0
- package/src/pagination.ts +2 -0
- package/src/resources/creators.ts +369 -271
- package/src/resources/health.ts +13 -1
- package/src/resources/index.ts +22 -41
- package/src/resources/posts.ts +89 -232
- package/src/resources/profiles.ts +252 -59
- package/src/resources/raw/index.ts +16 -0
- package/src/resources/raw/instagram.ts +271 -0
- package/src/resources/raw/raw.ts +47 -0
- package/src/resources/raw/youtube.ts +585 -0
- package/src/resources/raw.ts +3 -0
- package/src/resources/search.ts +145 -131
- package/src/resources/shared.ts +66 -0
- package/src/version.ts +1 -1
- package/version.d.mts +1 -1
- package/version.d.ts +1 -1
- package/version.js +1 -1
- package/version.mjs +1 -1
- package/resources/brand-safety.d.mts +0 -234
- package/resources/brand-safety.d.mts.map +0 -1
- package/resources/brand-safety.d.ts +0 -234
- package/resources/brand-safety.d.ts.map +0 -1
- package/resources/brand-safety.js +0 -75
- package/resources/brand-safety.js.map +0 -1
- package/resources/brand-safety.mjs +0 -71
- package/resources/brand-safety.mjs.map +0 -1
- package/resources/lookalike.d.mts +0 -142
- package/resources/lookalike.d.mts.map +0 -1
- package/resources/lookalike.d.ts +0 -142
- package/resources/lookalike.d.ts.map +0 -1
- package/resources/lookalike.js +0 -28
- package/resources/lookalike.js.map +0 -1
- package/resources/lookalike.mjs +0 -24
- package/resources/lookalike.mjs.map +0 -1
- package/resources/match.d.mts +0 -90
- package/resources/match.d.mts.map +0 -1
- package/resources/match.d.ts +0 -90
- package/resources/match.d.ts.map +0 -1
- package/resources/match.js +0 -22
- package/resources/match.js.map +0 -1
- package/resources/match.mjs +0 -18
- package/resources/match.mjs.map +0 -1
- package/src/resources/brand-safety.ts +0 -304
- package/src/resources/lookalike.ts +0 -186
- 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
|
|
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
|
-
|
|
38
|
-
|
|
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
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
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 {
|
|
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
|
-
*
|
|
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['
|
|
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['
|
|
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
|
|
152
|
+
* API Client for interfacing with the Influship API.
|
|
165
153
|
*/
|
|
166
|
-
export class
|
|
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
|
|
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['
|
|
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('
|
|
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.
|
|
200
|
-
"The INFLUSHIP_API_KEY environment variable is missing or empty; either provide it, or instantiate the
|
|
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 ??
|
|
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('
|
|
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
|
|
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
|
-
|
|
302
|
-
|
|
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
|
|
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
|
-
|
|
544
|
+
const abort = this._makeAbort(controller);
|
|
545
|
+
if (signal) signal.addEventListener('abort', abort, { once: true });
|
|
532
546
|
|
|
533
|
-
const timeout = setTimeout(
|
|
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
|
|
611
|
-
//
|
|
612
|
-
if (
|
|
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
|
|
765
|
+
static Influship = this;
|
|
738
766
|
static DEFAULT_TIMEOUT = 60000; // 1 minute
|
|
739
767
|
|
|
740
|
-
static
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
763
|
-
brandSafety: API.BrandSafety = new API.BrandSafety(this);
|
|
804
|
+
raw: API.Raw = new API.Raw(this);
|
|
764
805
|
}
|
|
765
806
|
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
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
|
|
814
|
+
export declare namespace Influship {
|
|
776
815
|
export type RequestOptions = Opts.RequestOptions;
|
|
777
816
|
|
|
778
|
-
export
|
|
817
|
+
export import QueryCursor = Pagination.QueryCursor;
|
|
818
|
+
export { type QueryCursorParams as QueryCursorParams, type QueryCursorResponse as QueryCursorResponse };
|
|
779
819
|
|
|
780
|
-
export
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
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
|
|
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
|
|
834
|
+
type CreatorLookalikeParams as CreatorLookalikeParams,
|
|
835
|
+
type CreatorMatchParams as CreatorMatchParams,
|
|
799
836
|
};
|
|
800
837
|
|
|
801
838
|
export {
|
|
802
|
-
|
|
803
|
-
type
|
|
804
|
-
type
|
|
805
|
-
type
|
|
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
|
-
|
|
810
|
-
type
|
|
811
|
-
type
|
|
812
|
-
type
|
|
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
|
|
818
|
-
type
|
|
819
|
-
type
|
|
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
|
-
|
|
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
|
}
|
package/src/core/api-promise.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
2
2
|
|
|
3
|
-
import { type
|
|
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:
|
|
14
|
+
#client: Influship;
|
|
15
15
|
|
|
16
16
|
constructor(
|
|
17
|
-
client:
|
|
17
|
+
client: Influship,
|
|
18
18
|
private responsePromise: Promise<APIResponseProps>,
|
|
19
19
|
private parseResponse: (
|
|
20
|
-
client:
|
|
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
|
|
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
|
|
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 */
|