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
@@ -0,0 +1,232 @@
1
+ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
+
3
+ import { InflushipError } from './error';
4
+ import { FinalRequestOptions } from '../internal/request-options';
5
+ import { defaultParseResponse } from '../internal/parse';
6
+ import { type Influship } from '../client';
7
+ import { APIPromise } from './api-promise';
8
+ import { type APIResponseProps } from '../internal/parse';
9
+ import { maybeObj } from '../internal/utils/values';
10
+
11
+ export type PageRequestOptions = Pick<FinalRequestOptions, 'query' | 'headers' | 'body' | 'path' | 'method'>;
12
+
13
+ export abstract class AbstractPage<Item> implements AsyncIterable<Item> {
14
+ #client: Influship;
15
+ protected options: FinalRequestOptions;
16
+
17
+ protected response: Response;
18
+ protected body: unknown;
19
+
20
+ constructor(client: Influship, response: Response, body: unknown, options: FinalRequestOptions) {
21
+ this.#client = client;
22
+ this.options = options;
23
+ this.response = response;
24
+ this.body = body;
25
+ }
26
+
27
+ abstract nextPageRequestOptions(): PageRequestOptions | null;
28
+
29
+ abstract getPaginatedItems(): Item[];
30
+
31
+ hasNextPage(): boolean {
32
+ const items = this.getPaginatedItems();
33
+ if (!items.length) return false;
34
+ return this.nextPageRequestOptions() != null;
35
+ }
36
+
37
+ async getNextPage(): Promise<this> {
38
+ const nextOptions = this.nextPageRequestOptions();
39
+ if (!nextOptions) {
40
+ throw new InflushipError(
41
+ 'No next page expected; please check `.hasNextPage()` before calling `.getNextPage()`.',
42
+ );
43
+ }
44
+
45
+ return await this.#client.requestAPIList(this.constructor as any, nextOptions);
46
+ }
47
+
48
+ async *iterPages(): AsyncGenerator<this> {
49
+ let page: this = this;
50
+ yield page;
51
+ while (page.hasNextPage()) {
52
+ page = await page.getNextPage();
53
+ yield page;
54
+ }
55
+ }
56
+
57
+ async *[Symbol.asyncIterator](): AsyncGenerator<Item> {
58
+ for await (const page of this.iterPages()) {
59
+ for (const item of page.getPaginatedItems()) {
60
+ yield item;
61
+ }
62
+ }
63
+ }
64
+ }
65
+
66
+ /**
67
+ * This subclass of Promise will resolve to an instantiated Page once the request completes.
68
+ *
69
+ * It also implements AsyncIterable to allow auto-paginating iteration on an unawaited list call, eg:
70
+ *
71
+ * for await (const item of client.items.list()) {
72
+ * console.log(item)
73
+ * }
74
+ */
75
+ export class PagePromise<
76
+ PageClass extends AbstractPage<Item>,
77
+ Item = ReturnType<PageClass['getPaginatedItems']>[number],
78
+ >
79
+ extends APIPromise<PageClass>
80
+ implements AsyncIterable<Item>
81
+ {
82
+ constructor(
83
+ client: Influship,
84
+ request: Promise<APIResponseProps>,
85
+ Page: new (...args: ConstructorParameters<typeof AbstractPage>) => PageClass,
86
+ ) {
87
+ super(
88
+ client,
89
+ request,
90
+ async (client, props) =>
91
+ new Page(client, props.response, await defaultParseResponse(client, props), props.options),
92
+ );
93
+ }
94
+
95
+ /**
96
+ * Allow auto-paginating iteration on an unawaited list call, eg:
97
+ *
98
+ * for await (const item of client.items.list()) {
99
+ * console.log(item)
100
+ * }
101
+ */
102
+ async *[Symbol.asyncIterator](): AsyncGenerator<Item> {
103
+ const page = await this;
104
+ for await (const item of page) {
105
+ yield item;
106
+ }
107
+ }
108
+ }
109
+
110
+ export interface QueryCursorResponse<Item> {
111
+ next_cursor: string | null;
112
+
113
+ has_more: boolean;
114
+
115
+ data: Array<Item>;
116
+ }
117
+
118
+ export interface QueryCursorParams {
119
+ cursor?: string;
120
+
121
+ limit?: number;
122
+ }
123
+
124
+ export class QueryCursor<Item> extends AbstractPage<Item> implements QueryCursorResponse<Item> {
125
+ next_cursor: string | null;
126
+
127
+ has_more: boolean;
128
+
129
+ data: Array<Item>;
130
+
131
+ constructor(
132
+ client: Influship,
133
+ response: Response,
134
+ body: QueryCursorResponse<Item>,
135
+ options: FinalRequestOptions,
136
+ ) {
137
+ super(client, response, body, options);
138
+
139
+ this.next_cursor = body.next_cursor || null;
140
+ this.has_more = body.has_more || false;
141
+ this.data = body.data || [];
142
+ }
143
+
144
+ getPaginatedItems(): Item[] {
145
+ return this.data ?? [];
146
+ }
147
+
148
+ override hasNextPage(): boolean {
149
+ if (this.has_more === false) {
150
+ return false;
151
+ }
152
+
153
+ return super.hasNextPage();
154
+ }
155
+
156
+ nextPageRequestOptions(): PageRequestOptions | null {
157
+ const cursor = this.next_cursor;
158
+ if (!cursor) {
159
+ return null;
160
+ }
161
+
162
+ return {
163
+ ...this.options,
164
+ query: {
165
+ ...maybeObj(this.options.query),
166
+ cursor,
167
+ },
168
+ };
169
+ }
170
+ }
171
+
172
+ export interface BodyCursorResponse<Item> {
173
+ next_cursor: string | null;
174
+
175
+ has_more: boolean;
176
+
177
+ data: Array<Item>;
178
+ }
179
+
180
+ export interface BodyCursorParams {
181
+ cursor?: string;
182
+
183
+ limit?: number;
184
+ }
185
+
186
+ export class BodyCursor<Item> extends AbstractPage<Item> implements BodyCursorResponse<Item> {
187
+ next_cursor: string | null;
188
+
189
+ has_more: boolean;
190
+
191
+ data: Array<Item>;
192
+
193
+ constructor(
194
+ client: Influship,
195
+ response: Response,
196
+ body: BodyCursorResponse<Item>,
197
+ options: FinalRequestOptions,
198
+ ) {
199
+ super(client, response, body, options);
200
+
201
+ this.next_cursor = body.next_cursor || null;
202
+ this.has_more = body.has_more || false;
203
+ this.data = body.data || [];
204
+ }
205
+
206
+ getPaginatedItems(): Item[] {
207
+ return this.data ?? [];
208
+ }
209
+
210
+ override hasNextPage(): boolean {
211
+ if (this.has_more === false) {
212
+ return false;
213
+ }
214
+
215
+ return super.hasNextPage();
216
+ }
217
+
218
+ nextPageRequestOptions(): PageRequestOptions | null {
219
+ const cursor = this.next_cursor;
220
+ if (!cursor) {
221
+ return null;
222
+ }
223
+
224
+ return {
225
+ ...this.options,
226
+ body: {
227
+ ...maybeObj(this.options.body),
228
+ cursor,
229
+ },
230
+ };
231
+ }
232
+ }
@@ -1,11 +1,11 @@
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
  export abstract class APIResource {
6
- protected _client: InflushipAPI;
6
+ protected _client: Influship;
7
7
 
8
- constructor(client: InflushipAPI) {
8
+ constructor(client: Influship) {
9
9
  this._client = client;
10
10
  }
11
11
  }
package/src/index.ts CHANGED
@@ -1,12 +1,13 @@
1
1
  // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
2
 
3
- export { InflushipAPI as default } from './client';
3
+ export { Influship as default } from './client';
4
4
 
5
5
  export { type Uploadable, toFile } from './core/uploads';
6
6
  export { APIPromise } from './core/api-promise';
7
- export { InflushipAPI, type ClientOptions } from './client';
7
+ export { Influship, type ClientOptions } from './client';
8
+ export { PagePromise } from './core/pagination';
8
9
  export {
9
- InflushipAPIError,
10
+ InflushipError,
10
11
  APIError,
11
12
  APIConnectionError,
12
13
  APIConnectionTimeoutError,
@@ -1,7 +1,7 @@
1
1
  // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
2
 
3
3
  import type { FinalRequestOptions } from './request-options';
4
- import { type InflushipAPI } from '../client';
4
+ import { type Influship } from '../client';
5
5
  import { formatRequestDetails, loggerFor } from './utils/log';
6
6
 
7
7
  export type APIResponseProps = {
@@ -13,7 +13,7 @@ export type APIResponseProps = {
13
13
  startTime: number;
14
14
  };
15
15
 
16
- export async function defaultParseResponse<T>(client: InflushipAPI, props: APIResponseProps): Promise<T> {
16
+ export async function defaultParseResponse<T>(client: Influship, props: APIResponseProps): Promise<T> {
17
17
  const { response, requestLogID, retryOfRequestLogID, startTime } = props;
18
18
  const body = await (async () => {
19
19
  // fetch refuses to read the body when the status code is 204.
@@ -29,6 +29,12 @@ export async function defaultParseResponse<T>(client: InflushipAPI, props: APIRe
29
29
  const mediaType = contentType?.split(';')[0]?.trim();
30
30
  const isJSON = mediaType?.includes('application/json') || mediaType?.endsWith('+json');
31
31
  if (isJSON) {
32
+ const contentLength = response.headers.get('content-length');
33
+ if (contentLength === '0') {
34
+ // if there is no content we can't do anything
35
+ return undefined as T;
36
+ }
37
+
32
38
  const json = await response.json();
33
39
  return json as T;
34
40
  }
@@ -16,7 +16,7 @@ export function getDefaultFetch(): Fetch {
16
16
  }
17
17
 
18
18
  throw new Error(
19
- '`fetch` is not defined as a global; Either pass `fetch` to the client, `new InflushipAPI({ fetch })` or polyfill the global, `globalThis.fetch = fetch`',
19
+ '`fetch` is not defined as a global; Either pass `fetch` to the client, `new Influship({ fetch })` or polyfill the global, `globalThis.fetch = fetch`',
20
20
  );
21
21
  }
22
22
 
@@ -1,6 +1,6 @@
1
1
  import { type RequestOptions } from './request-options';
2
2
  import type { FilePropertyBag, Fetch } from './builtin-types';
3
- import type { InflushipAPI } from '../client';
3
+ import type { Influship } from '../client';
4
4
  import { ReadableStreamFrom } from './shims';
5
5
 
6
6
  export type BlobPart = string | ArrayBuffer | ArrayBufferView | Blob | DataView;
@@ -74,7 +74,7 @@ export const isAsyncIterable = (value: any): value is AsyncIterable<any> =>
74
74
  */
75
75
  export const maybeMultipartFormRequestOptions = async (
76
76
  opts: RequestOptions,
77
- fetch: InflushipAPI | Fetch,
77
+ fetch: Influship | Fetch,
78
78
  ): Promise<RequestOptions> => {
79
79
  if (!hasUploadableValue(opts.body)) return opts;
80
80
 
@@ -85,7 +85,7 @@ type MultipartFormRequestOptions = Omit<RequestOptions, 'body'> & { body: unknow
85
85
 
86
86
  export const multipartFormRequestOptions = async (
87
87
  opts: MultipartFormRequestOptions,
88
- fetch: InflushipAPI | Fetch,
88
+ fetch: Influship | Fetch,
89
89
  ): Promise<RequestOptions> => {
90
90
  return { ...opts, body: await createForm(opts.body, fetch) };
91
91
  };
@@ -98,7 +98,7 @@ const supportsFormDataMap = /* @__PURE__ */ new WeakMap<Fetch, Promise<boolean>>
98
98
  * This function detects if the fetch function provided supports the global FormData object to avoid
99
99
  * confusing error messages later on.
100
100
  */
101
- function supportsFormData(fetchObject: InflushipAPI | Fetch): Promise<boolean> {
101
+ function supportsFormData(fetchObject: Influship | Fetch): Promise<boolean> {
102
102
  const fetch: Fetch = typeof fetchObject === 'function' ? fetchObject : (fetchObject as any).fetch;
103
103
  const cached = supportsFormDataMap.get(fetch);
104
104
  if (cached) return cached;
@@ -124,7 +124,7 @@ function supportsFormData(fetchObject: InflushipAPI | Fetch): Promise<boolean> {
124
124
 
125
125
  export const createForm = async <T = Record<string, unknown>>(
126
126
  body: T | undefined,
127
- fetch: InflushipAPI | Fetch,
127
+ fetch: Influship | Fetch,
128
128
  ): Promise<FormData> => {
129
129
  if (!(await supportsFormData(fetch))) {
130
130
  throw new TypeError(
@@ -1,6 +1,6 @@
1
1
  // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
2
 
3
- import { InflushipAPIError } from '../../core/error';
3
+ import { InflushipError } from '../../core/error';
4
4
  import { encodeUTF8 } from './bytes';
5
5
 
6
6
  export const toBase64 = (data: string | Uint8Array | null | undefined): string => {
@@ -18,7 +18,7 @@ export const toBase64 = (data: string | Uint8Array | null | undefined): string =
18
18
  return btoa(String.fromCharCode.apply(null, data as any));
19
19
  }
20
20
 
21
- throw new InflushipAPIError('Cannot generate base64 string; Expected `Buffer` or `btoa` to be defined');
21
+ throw new InflushipError('Cannot generate base64 string; Expected `Buffer` or `btoa` to be defined');
22
22
  };
23
23
 
24
24
  export const fromBase64 = (str: string): Uint8Array => {
@@ -36,5 +36,5 @@ export const fromBase64 = (str: string): Uint8Array => {
36
36
  return buf;
37
37
  }
38
38
 
39
- throw new InflushipAPIError('Cannot decode base64 string; Expected `Buffer` or `atob` to be defined');
39
+ throw new InflushipError('Cannot decode base64 string; Expected `Buffer` or `atob` to be defined');
40
40
  };
@@ -1,7 +1,7 @@
1
1
  // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
2
 
3
3
  import { hasOwn } from './values';
4
- import { type InflushipAPI } from '../../client';
4
+ import { type Influship } from '../../client';
5
5
  import { RequestOptions } from '../request-options';
6
6
 
7
7
  type LogFn = (message: string, ...rest: unknown[]) => void;
@@ -24,7 +24,7 @@ const levelNumbers = {
24
24
  export const parseLogLevel = (
25
25
  maybeLevel: string | undefined,
26
26
  sourceName: string,
27
- client: InflushipAPI,
27
+ client: Influship,
28
28
  ): LogLevel | undefined => {
29
29
  if (!maybeLevel) {
30
30
  return undefined;
@@ -60,7 +60,7 @@ const noopLogger = {
60
60
 
61
61
  let cachedLoggers = /* @__PURE__ */ new WeakMap<Logger, [LogLevel, Logger]>();
62
62
 
63
- export function loggerFor(client: InflushipAPI): Logger {
63
+ export function loggerFor(client: Influship): Logger {
64
64
  const logger = client.logger;
65
65
  const logLevel = client.logLevel ?? 'off';
66
66
  if (!logger) {
@@ -1,4 +1,4 @@
1
- import { InflushipAPIError } from '../../core/error';
1
+ import { InflushipError } from '../../core/error';
2
2
 
3
3
  /**
4
4
  * Percent-encode everything that isn't safe to have in a path without encoding safe chars.
@@ -72,7 +72,7 @@ export const createPathTagFunction = (pathEncoder = encodeURIPath) =>
72
72
  return acc + spaces + arrows;
73
73
  }, '');
74
74
 
75
- throw new InflushipAPIError(
75
+ throw new InflushipError(
76
76
  `Path parameters result in path with invalid segments:\n${invalidSegments
77
77
  .map((e) => e.error)
78
78
  .join('\n')}\n${path}\n${underline}`,
@@ -0,0 +1,7 @@
1
+ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
+
3
+ import * as qs from '../qs/stringify';
4
+
5
+ export function stringifyQuery(query: object | Record<string, unknown>) {
6
+ return qs.stringify(query, { arrayFormat: 'comma' });
7
+ }
@@ -1,6 +1,6 @@
1
1
  // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
2
 
3
- import { InflushipAPIError } from '../../core/error';
3
+ import { InflushipError } from '../../core/error';
4
4
 
5
5
  // https://url.spec.whatwg.org/#url-scheme-string
6
6
  const startsWithSchemeRegexp = /^[a-z][a-z0-9+.-]*:/i;
@@ -39,7 +39,7 @@ export function isObj(obj: unknown): obj is Record<string, unknown> {
39
39
 
40
40
  export const ensurePresent = <T>(value: T | null | undefined): T => {
41
41
  if (value == null) {
42
- throw new InflushipAPIError(`Expected a value to be given but received ${value} instead.`);
42
+ throw new InflushipError(`Expected a value to be given but received ${value} instead.`);
43
43
  }
44
44
 
45
45
  return value;
@@ -47,10 +47,10 @@ export const ensurePresent = <T>(value: T | null | undefined): T => {
47
47
 
48
48
  export const validatePositiveInteger = (name: string, n: unknown): number => {
49
49
  if (typeof n !== 'number' || !Number.isInteger(n)) {
50
- throw new InflushipAPIError(`${name} must be an integer`);
50
+ throw new InflushipError(`${name} must be an integer`);
51
51
  }
52
52
  if (n < 0) {
53
- throw new InflushipAPIError(`${name} must be a positive integer`);
53
+ throw new InflushipError(`${name} must be a positive integer`);
54
54
  }
55
55
  return n;
56
56
  };
@@ -59,14 +59,14 @@ export const coerceInteger = (value: unknown): number => {
59
59
  if (typeof value === 'number') return Math.round(value);
60
60
  if (typeof value === 'string') return parseInt(value, 10);
61
61
 
62
- throw new InflushipAPIError(`Could not coerce ${value} (type: ${typeof value}) into a number`);
62
+ throw new InflushipError(`Could not coerce ${value} (type: ${typeof value}) into a number`);
63
63
  };
64
64
 
65
65
  export const coerceFloat = (value: unknown): number => {
66
66
  if (typeof value === 'number') return value;
67
67
  if (typeof value === 'string') return parseFloat(value);
68
68
 
69
- throw new InflushipAPIError(`Could not coerce ${value} (type: ${typeof value}) into a number`);
69
+ throw new InflushipError(`Could not coerce ${value} (type: ${typeof value}) into a number`);
70
70
  };
71
71
 
72
72
  export const coerceBoolean = (value: unknown): boolean => {
@@ -6,3 +6,4 @@ export * from './utils/env';
6
6
  export * from './utils/log';
7
7
  export * from './utils/uuid';
8
8
  export * from './utils/sleep';
9
+ export * from './utils/query';
@@ -0,0 +1,2 @@
1
+ /** @deprecated Import from ./core/pagination instead */
2
+ export * from './core/pagination';