@snagsolutions/sdk 0.1.0-alpha.26 → 0.1.0-alpha.260

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 (341) hide show
  1. package/CHANGELOG.md +140 -153
  2. package/LICENSE +1 -1
  3. package/README.md +15 -23
  4. package/core.d.ts +9 -6
  5. package/core.d.ts.map +1 -1
  6. package/core.js +36 -33
  7. package/core.js.map +1 -1
  8. package/core.mjs +36 -33
  9. package/core.mjs.map +1 -1
  10. package/index.d.mts +15 -9
  11. package/index.d.ts +15 -9
  12. package/index.d.ts.map +1 -1
  13. package/index.js +13 -6
  14. package/index.js.map +1 -1
  15. package/index.mjs +14 -7
  16. package/index.mjs.map +1 -1
  17. package/internal/utils/query.d.ts +2 -0
  18. package/internal/utils/query.d.ts.map +1 -0
  19. package/internal/utils/query.js +33 -0
  20. package/internal/utils/query.js.map +1 -0
  21. package/internal/utils/query.mjs +6 -0
  22. package/internal/utils/query.mjs.map +1 -0
  23. package/package.json +4 -5
  24. package/resource.d.ts +1 -1
  25. package/resource.d.ts.map +1 -1
  26. package/resource.js.map +1 -1
  27. package/resource.mjs.map +1 -1
  28. package/resources/assets.d.ts +16 -2
  29. package/resources/assets.d.ts.map +1 -1
  30. package/resources/assets.js +8 -0
  31. package/resources/assets.js.map +1 -1
  32. package/resources/assets.mjs +8 -0
  33. package/resources/assets.mjs.map +1 -1
  34. package/resources/auctions/auctions.d.ts +341 -0
  35. package/resources/auctions/auctions.d.ts.map +1 -0
  36. package/resources/auctions/auctions.js +72 -0
  37. package/resources/auctions/auctions.js.map +1 -0
  38. package/resources/auctions/auctions.mjs +45 -0
  39. package/resources/auctions/auctions.mjs.map +1 -0
  40. package/resources/auctions/index.d.ts +3 -0
  41. package/resources/auctions/index.d.ts.map +1 -0
  42. package/resources/auctions/index.js +9 -0
  43. package/resources/auctions/index.js.map +1 -0
  44. package/resources/auctions/index.mjs +4 -0
  45. package/resources/auctions/index.mjs.map +1 -0
  46. package/resources/auctions/website-user-attributes/index.d.ts +3 -0
  47. package/resources/auctions/website-user-attributes/index.d.ts.map +1 -0
  48. package/resources/auctions/website-user-attributes/index.js +9 -0
  49. package/resources/auctions/website-user-attributes/index.js.map +1 -0
  50. package/resources/auctions/website-user-attributes/index.mjs +4 -0
  51. package/resources/auctions/website-user-attributes/index.mjs.map +1 -0
  52. package/resources/auctions/website-user-attributes/values.d.ts +126 -0
  53. package/resources/auctions/website-user-attributes/values.d.ts.map +1 -0
  54. package/resources/auctions/website-user-attributes/values.js +49 -0
  55. package/resources/auctions/website-user-attributes/values.js.map +1 -0
  56. package/resources/auctions/website-user-attributes/values.mjs +45 -0
  57. package/resources/auctions/website-user-attributes/values.mjs.map +1 -0
  58. package/resources/auctions/website-user-attributes/website-user-attributes.d.ts +136 -0
  59. package/resources/auctions/website-user-attributes/website-user-attributes.d.ts.map +1 -0
  60. package/resources/auctions/website-user-attributes/website-user-attributes.js +76 -0
  61. package/resources/auctions/website-user-attributes/website-user-attributes.js.map +1 -0
  62. package/resources/auctions/website-user-attributes/website-user-attributes.mjs +49 -0
  63. package/resources/auctions/website-user-attributes/website-user-attributes.mjs.map +1 -0
  64. package/resources/auctions/website-user-attributes.d.ts +2 -0
  65. package/resources/auctions/website-user-attributes.d.ts.map +1 -0
  66. package/resources/auctions/website-user-attributes.js +19 -0
  67. package/resources/auctions/website-user-attributes.js.map +1 -0
  68. package/resources/auctions/website-user-attributes.mjs +3 -0
  69. package/resources/auctions/website-user-attributes.mjs.map +1 -0
  70. package/resources/auctions.d.ts +1 -133
  71. package/resources/auctions.d.ts.map +1 -1
  72. package/resources/auctions.js +15 -22
  73. package/resources/auctions.js.map +1 -1
  74. package/resources/auctions.mjs +1 -20
  75. package/resources/auctions.mjs.map +1 -1
  76. package/resources/auth.d.ts +66 -6
  77. package/resources/auth.d.ts.map +1 -1
  78. package/resources/auth.js +6 -0
  79. package/resources/auth.js.map +1 -1
  80. package/resources/auth.mjs +6 -0
  81. package/resources/auth.mjs.map +1 -1
  82. package/resources/index.d.ts +5 -4
  83. package/resources/index.d.ts.map +1 -1
  84. package/resources/index.js +5 -3
  85. package/resources/index.js.map +1 -1
  86. package/resources/index.mjs +4 -3
  87. package/resources/index.mjs.map +1 -1
  88. package/resources/loyalty/account-streaks.d.ts +96 -0
  89. package/resources/loyalty/account-streaks.d.ts.map +1 -0
  90. package/resources/loyalty/account-streaks.js +24 -0
  91. package/resources/loyalty/account-streaks.js.map +1 -0
  92. package/resources/loyalty/account-streaks.mjs +20 -0
  93. package/resources/loyalty/account-streaks.mjs.map +1 -0
  94. package/resources/loyalty/accounts.d.ts +60 -16
  95. package/resources/loyalty/accounts.d.ts.map +1 -1
  96. package/resources/loyalty/accounts.js +14 -0
  97. package/resources/loyalty/accounts.js.map +1 -1
  98. package/resources/loyalty/accounts.mjs +14 -0
  99. package/resources/loyalty/accounts.mjs.map +1 -1
  100. package/resources/loyalty/badges.d.ts +885 -136
  101. package/resources/loyalty/badges.d.ts.map +1 -1
  102. package/resources/loyalty/badges.js +19 -1
  103. package/resources/loyalty/badges.js.map +1 -1
  104. package/resources/loyalty/badges.mjs +19 -1
  105. package/resources/loyalty/badges.mjs.map +1 -1
  106. package/resources/loyalty/currencies.d.ts +19 -0
  107. package/resources/loyalty/currencies.d.ts.map +1 -1
  108. package/resources/loyalty/currencies.js +19 -0
  109. package/resources/loyalty/currencies.js.map +1 -1
  110. package/resources/loyalty/currencies.mjs +19 -0
  111. package/resources/loyalty/currencies.mjs.map +1 -1
  112. package/resources/loyalty/index.d.ts +3 -3
  113. package/resources/loyalty/index.d.ts.map +1 -1
  114. package/resources/loyalty/index.js +5 -5
  115. package/resources/loyalty/index.js.map +1 -1
  116. package/resources/loyalty/index.mjs +2 -2
  117. package/resources/loyalty/index.mjs.map +1 -1
  118. package/resources/loyalty/loyalty.d.ts +9 -9
  119. package/resources/loyalty/loyalty.d.ts.map +1 -1
  120. package/resources/loyalty/loyalty.js +6 -6
  121. package/resources/loyalty/loyalty.js.map +1 -1
  122. package/resources/loyalty/loyalty.mjs +6 -6
  123. package/resources/loyalty/loyalty.mjs.map +1 -1
  124. package/resources/loyalty/multipliers.d.ts +39 -2
  125. package/resources/loyalty/multipliers.d.ts.map +1 -1
  126. package/resources/loyalty/multipliers.js +23 -0
  127. package/resources/loyalty/multipliers.js.map +1 -1
  128. package/resources/loyalty/multipliers.mjs +23 -0
  129. package/resources/loyalty/multipliers.mjs.map +1 -1
  130. package/resources/loyalty/questions-responses.d.ts +55 -4
  131. package/resources/loyalty/questions-responses.d.ts.map +1 -1
  132. package/resources/loyalty/questions-responses.js +9 -0
  133. package/resources/loyalty/questions-responses.js.map +1 -1
  134. package/resources/loyalty/questions-responses.mjs +9 -0
  135. package/resources/loyalty/questions-responses.mjs.map +1 -1
  136. package/resources/loyalty/questions.d.ts +60 -6
  137. package/resources/loyalty/questions.d.ts.map +1 -1
  138. package/resources/loyalty/questions.js +39 -0
  139. package/resources/loyalty/questions.js.map +1 -1
  140. package/resources/loyalty/questions.mjs +39 -0
  141. package/resources/loyalty/questions.mjs.map +1 -1
  142. package/resources/loyalty/rule-edits.d.ts +2898 -8
  143. package/resources/loyalty/rule-edits.d.ts.map +1 -1
  144. package/resources/loyalty/rule-edits.js +14 -0
  145. package/resources/loyalty/rule-edits.js.map +1 -1
  146. package/resources/loyalty/rule-edits.mjs +14 -0
  147. package/resources/loyalty/rule-edits.mjs.map +1 -1
  148. package/resources/loyalty/rule-groups.d.ts +284 -56
  149. package/resources/loyalty/rule-groups.d.ts.map +1 -1
  150. package/resources/loyalty/rule-groups.js +18 -0
  151. package/resources/loyalty/rule-groups.js.map +1 -1
  152. package/resources/loyalty/rule-groups.mjs +18 -0
  153. package/resources/loyalty/rule-groups.mjs.map +1 -1
  154. package/resources/loyalty/rules.d.ts +2368 -346
  155. package/resources/loyalty/rules.d.ts.map +1 -1
  156. package/resources/loyalty/rules.js +40 -9
  157. package/resources/loyalty/rules.js.map +1 -1
  158. package/resources/loyalty/rules.mjs +40 -9
  159. package/resources/loyalty/rules.mjs.map +1 -1
  160. package/resources/loyalty/transactions/index.d.ts +4 -0
  161. package/resources/loyalty/transactions/index.d.ts.map +1 -0
  162. package/resources/loyalty/transactions/index.js +11 -0
  163. package/resources/loyalty/transactions/index.js.map +1 -0
  164. package/resources/loyalty/transactions/index.mjs +5 -0
  165. package/resources/loyalty/transactions/index.mjs.map +1 -0
  166. package/resources/loyalty/transactions/posts.d.ts +145 -0
  167. package/resources/loyalty/transactions/posts.d.ts.map +1 -0
  168. package/resources/loyalty/transactions/posts.js +32 -0
  169. package/resources/loyalty/transactions/posts.js.map +1 -0
  170. package/resources/loyalty/transactions/posts.mjs +28 -0
  171. package/resources/loyalty/transactions/posts.mjs.map +1 -0
  172. package/resources/loyalty/transactions/rule-statuses.d.ts +121 -0
  173. package/resources/loyalty/transactions/rule-statuses.d.ts.map +1 -0
  174. package/resources/loyalty/transactions/rule-statuses.js +30 -0
  175. package/resources/loyalty/transactions/rule-statuses.js.map +1 -0
  176. package/resources/loyalty/transactions/rule-statuses.mjs +26 -0
  177. package/resources/loyalty/transactions/rule-statuses.mjs.map +1 -0
  178. package/resources/loyalty/transactions/transactions.d.ts +566 -0
  179. package/resources/loyalty/transactions/transactions.d.ts.map +1 -0
  180. package/resources/loyalty/transactions/transactions.js +110 -0
  181. package/resources/loyalty/transactions/transactions.js.map +1 -0
  182. package/resources/loyalty/transactions/transactions.mjs +83 -0
  183. package/resources/loyalty/transactions/transactions.mjs.map +1 -0
  184. package/resources/loyalty/transactions.d.ts +1 -253
  185. package/resources/loyalty/transactions.d.ts.map +1 -1
  186. package/resources/loyalty/transactions.js +15 -18
  187. package/resources/loyalty/transactions.js.map +1 -1
  188. package/resources/loyalty/transactions.mjs +1 -16
  189. package/resources/loyalty/transactions.mjs.map +1 -1
  190. package/resources/minting/allowlist.d.ts +84 -0
  191. package/resources/minting/allowlist.d.ts.map +1 -0
  192. package/resources/minting/allowlist.js +42 -0
  193. package/resources/minting/allowlist.js.map +1 -0
  194. package/resources/minting/allowlist.mjs +38 -0
  195. package/resources/minting/allowlist.mjs.map +1 -0
  196. package/resources/minting/contracts.d.ts +165 -0
  197. package/resources/minting/contracts.d.ts.map +1 -0
  198. package/resources/minting/contracts.js +30 -0
  199. package/resources/minting/contracts.js.map +1 -0
  200. package/resources/minting/contracts.mjs +26 -0
  201. package/resources/minting/contracts.mjs.map +1 -0
  202. package/resources/minting/index.d.ts +5 -0
  203. package/resources/minting/index.d.ts.map +1 -0
  204. package/resources/minting/index.js +13 -0
  205. package/resources/minting/index.js.map +1 -0
  206. package/resources/minting/index.mjs +6 -0
  207. package/resources/minting/index.mjs.map +1 -0
  208. package/resources/minting/minting.d.ts +146 -0
  209. package/resources/minting/minting.d.ts.map +1 -0
  210. package/resources/minting/minting.js +79 -0
  211. package/resources/minting/minting.js.map +1 -0
  212. package/resources/minting/minting.mjs +52 -0
  213. package/resources/minting/minting.mjs.map +1 -0
  214. package/resources/minting/status.d.ts +44 -0
  215. package/resources/minting/status.d.ts.map +1 -0
  216. package/resources/minting/status.js +33 -0
  217. package/resources/minting/status.js.map +1 -0
  218. package/resources/minting/status.mjs +29 -0
  219. package/resources/minting/status.mjs.map +1 -0
  220. package/resources/minting.d.ts +1 -94
  221. package/resources/minting.d.ts.map +1 -1
  222. package/resources/minting.js +15 -11
  223. package/resources/minting.js.map +1 -1
  224. package/resources/minting.mjs +1 -9
  225. package/resources/minting.mjs.map +1 -1
  226. package/resources/referral/referral.d.ts +12 -3
  227. package/resources/referral/referral.d.ts.map +1 -1
  228. package/resources/referral/referral.js +11 -5
  229. package/resources/referral/referral.js.map +1 -1
  230. package/resources/referral/referral.mjs +11 -5
  231. package/resources/referral/referral.mjs.map +1 -1
  232. package/resources/referral/users.d.ts +30 -3
  233. package/resources/referral/users.d.ts.map +1 -1
  234. package/resources/referral/users.js +12 -4
  235. package/resources/referral/users.js.map +1 -1
  236. package/resources/referral/users.mjs +12 -4
  237. package/resources/referral/users.mjs.map +1 -1
  238. package/resources/token-claims.d.ts +162 -0
  239. package/resources/token-claims.d.ts.map +1 -0
  240. package/resources/token-claims.js +46 -0
  241. package/resources/token-claims.js.map +1 -0
  242. package/resources/token-claims.mjs +42 -0
  243. package/resources/token-claims.mjs.map +1 -0
  244. package/resources/users/index.d.ts +1 -1
  245. package/resources/users/index.d.ts.map +1 -1
  246. package/resources/users/index.js.map +1 -1
  247. package/resources/users/index.mjs.map +1 -1
  248. package/resources/users/metadatas.d.ts +40 -3
  249. package/resources/users/metadatas.d.ts.map +1 -1
  250. package/resources/users/metadatas.js.map +1 -1
  251. package/resources/users/metadatas.mjs.map +1 -1
  252. package/resources/users/users.d.ts +203 -36
  253. package/resources/users/users.d.ts.map +1 -1
  254. package/resources/users/users.js +58 -1
  255. package/resources/users/users.js.map +1 -1
  256. package/resources/users/users.mjs +58 -1
  257. package/resources/users/users.mjs.map +1 -1
  258. package/resources/websites/index.d.ts +1 -1
  259. package/resources/websites/index.d.ts.map +1 -1
  260. package/resources/websites/index.js.map +1 -1
  261. package/resources/websites/index.mjs +1 -1
  262. package/resources/websites/index.mjs.map +1 -1
  263. package/resources/websites/website-collections.d.ts +0 -69
  264. package/resources/websites/website-collections.d.ts.map +1 -1
  265. package/resources/websites/website-collections.js +0 -16
  266. package/resources/websites/website-collections.js.map +1 -1
  267. package/resources/websites/website-collections.mjs +0 -16
  268. package/resources/websites/website-collections.mjs.map +1 -1
  269. package/resources/websites/website-user-roles.d.ts +24 -1
  270. package/resources/websites/website-user-roles.d.ts.map +1 -1
  271. package/resources/websites/website-user-roles.js +23 -0
  272. package/resources/websites/website-user-roles.js.map +1 -1
  273. package/resources/websites/website-user-roles.mjs +23 -0
  274. package/resources/websites/website-user-roles.mjs.map +1 -1
  275. package/resources/websites/websites.d.ts +21 -99
  276. package/resources/websites/websites.d.ts.map +1 -1
  277. package/resources/websites/websites.js +9 -1
  278. package/resources/websites/websites.js.map +1 -1
  279. package/resources/websites/websites.mjs +10 -2
  280. package/resources/websites/websites.mjs.map +1 -1
  281. package/src/core.ts +40 -36
  282. package/src/index.ts +84 -6
  283. package/src/internal/utils/query.ts +7 -0
  284. package/src/resource.ts +1 -1
  285. package/src/resources/assets.ts +18 -3
  286. package/src/resources/auctions/auctions.ts +523 -0
  287. package/src/resources/auctions/index.ts +19 -0
  288. package/src/resources/auctions/website-user-attributes/index.ts +18 -0
  289. package/src/resources/auctions/website-user-attributes/values.ts +170 -0
  290. package/src/resources/auctions/website-user-attributes/website-user-attributes.ts +212 -0
  291. package/src/resources/auctions/website-user-attributes.ts +3 -0
  292. package/src/resources/auctions.ts +1 -207
  293. package/src/resources/auth.ts +124 -6
  294. package/src/resources/index.ts +41 -3
  295. package/src/resources/loyalty/account-streaks.ts +128 -0
  296. package/src/resources/loyalty/accounts.ts +65 -18
  297. package/src/resources/loyalty/badges.ts +1058 -146
  298. package/src/resources/loyalty/currencies.ts +19 -0
  299. package/src/resources/loyalty/index.ts +13 -2
  300. package/src/resources/loyalty/loyalty.ts +30 -12
  301. package/src/resources/loyalty/multipliers.ts +43 -4
  302. package/src/resources/loyalty/questions-responses.ts +64 -4
  303. package/src/resources/loyalty/questions.ts +64 -6
  304. package/src/resources/loyalty/rule-edits.ts +4208 -94
  305. package/src/resources/loyalty/rule-groups.ts +473 -64
  306. package/src/resources/loyalty/rules.ts +3706 -403
  307. package/src/resources/loyalty/transactions/index.ts +29 -0
  308. package/src/resources/loyalty/transactions/posts.ts +221 -0
  309. package/src/resources/loyalty/transactions/rule-statuses.ts +179 -0
  310. package/src/resources/loyalty/transactions/transactions.ts +930 -0
  311. package/src/resources/loyalty/transactions.ts +1 -446
  312. package/src/resources/minting/allowlist.ts +116 -0
  313. package/src/resources/minting/contracts.ts +415 -0
  314. package/src/resources/minting/index.ts +29 -0
  315. package/src/resources/minting/minting.ts +285 -0
  316. package/src/resources/minting/status.ts +70 -0
  317. package/src/resources/minting.ts +1 -157
  318. package/src/resources/referral/referral.ts +15 -11
  319. package/src/resources/referral/users.ts +45 -5
  320. package/src/resources/token-claims.ts +311 -0
  321. package/src/resources/users/index.ts +4 -0
  322. package/src/resources/users/metadatas.ts +66 -3
  323. package/src/resources/users/users.ts +277 -39
  324. package/src/resources/websites/index.ts +1 -6
  325. package/src/resources/websites/website-collections.ts +1 -146
  326. package/src/resources/websites/website-user-roles.ts +26 -1
  327. package/src/resources/websites/websites.ts +22 -127
  328. package/src/version.ts +1 -1
  329. package/version.d.ts +1 -1
  330. package/version.d.ts.map +1 -1
  331. package/version.js +1 -1
  332. package/version.js.map +1 -1
  333. package/version.mjs +1 -1
  334. package/version.mjs.map +1 -1
  335. package/resources/loyalty/rule-chains.d.ts +0 -34
  336. package/resources/loyalty/rule-chains.d.ts.map +0 -1
  337. package/resources/loyalty/rule-chains.js +0 -15
  338. package/resources/loyalty/rule-chains.js.map +0 -1
  339. package/resources/loyalty/rule-chains.mjs +0 -11
  340. package/resources/loyalty/rule-chains.mjs.map +0 -1
  341. package/src/resources/loyalty/rule-chains.ts +0 -45
package/src/core.ts CHANGED
@@ -6,6 +6,7 @@ import {
6
6
  APIConnectionTimeoutError,
7
7
  APIUserAbortError,
8
8
  } from './error';
9
+ import { stringifyQuery } from './internal/utils/query';
9
10
  import {
10
11
  kind as shimsKind,
11
12
  type Readable,
@@ -70,6 +71,12 @@ async function defaultParseResponse<T>(props: APIResponseProps): Promise<T> {
70
71
  const mediaType = contentType?.split(';')[0]?.trim();
71
72
  const isJSON = mediaType?.includes('application/json') || mediaType?.endsWith('+json');
72
73
  if (isJSON) {
74
+ const contentLength = response.headers.get('content-length');
75
+ if (contentLength === '0') {
76
+ // if there is no content we can't do anything
77
+ return undefined as T;
78
+ }
79
+
73
80
  const json = await response.json();
74
81
 
75
82
  debug('response', response.status, response.url, response.headers, json);
@@ -170,6 +177,7 @@ export class APIPromise<T> extends Promise<T> {
170
177
 
171
178
  export abstract class APIClient {
172
179
  baseURL: string;
180
+ #baseURLOverridden: boolean;
173
181
  maxRetries: number;
174
182
  timeout: number;
175
183
  httpAgent: Agent | undefined;
@@ -179,18 +187,21 @@ export abstract class APIClient {
179
187
 
180
188
  constructor({
181
189
  baseURL,
190
+ baseURLOverridden,
182
191
  maxRetries = 2,
183
192
  timeout = 60000, // 1 minute
184
193
  httpAgent,
185
194
  fetch: overriddenFetch,
186
195
  }: {
187
196
  baseURL: string;
197
+ baseURLOverridden: boolean;
188
198
  maxRetries?: number | undefined;
189
199
  timeout: number | undefined;
190
200
  httpAgent: Agent | undefined;
191
201
  fetch: Fetch | undefined;
192
202
  }) {
193
203
  this.baseURL = baseURL;
204
+ this.#baseURLOverridden = baseURLOverridden;
194
205
  this.maxRetries = validatePositiveInteger('maxRetries', maxRetries);
195
206
  this.timeout = validatePositiveInteger('timeout', timeout);
196
207
  this.httpAgent = httpAgent;
@@ -213,7 +224,7 @@ export abstract class APIClient {
213
224
  protected defaultHeaders(opts: FinalRequestOptions): Headers {
214
225
  return {
215
226
  Accept: 'application/json',
216
- 'Content-Type': 'application/json',
227
+ ...(['head', 'get'].includes(opts.method) ? {} : { 'Content-Type': 'application/json' }),
217
228
  'User-Agent': this.getUserAgent(),
218
229
  ...getPlatformHeaders(),
219
230
  ...this.authHeaders(opts),
@@ -295,12 +306,12 @@ export abstract class APIClient {
295
306
  return null;
296
307
  }
297
308
 
298
- buildRequest<Req>(
299
- options: FinalRequestOptions<Req>,
309
+ async buildRequest<Req>(
310
+ inputOptions: FinalRequestOptions<Req>,
300
311
  { retryCount = 0 }: { retryCount?: number } = {},
301
- ): { req: RequestInit; url: string; timeout: number } {
302
- options = { ...options };
303
- const { method, path, query, headers: headers = {} } = options;
312
+ ): Promise<{ req: RequestInit; url: string; timeout: number }> {
313
+ const options = { ...inputOptions };
314
+ const { method, path, query, defaultBaseURL, headers: headers = {} } = options;
304
315
 
305
316
  const body =
306
317
  ArrayBuffer.isView(options.body) || (options.__binaryRequest && typeof options.body === 'string') ?
@@ -310,7 +321,7 @@ export abstract class APIClient {
310
321
  : null;
311
322
  const contentLength = this.calculateContentLength(body);
312
323
 
313
- const url = this.buildURL(path!, query);
324
+ const url = this.buildURL(path!, query, defaultBaseURL);
314
325
  if ('timeout' in options) validatePositiveInteger('timeout', options.timeout);
315
326
  options.timeout = options.timeout ?? this.timeout;
316
327
  const httpAgent = options.httpAgent ?? this.httpAgent ?? getDefaultAgent(url);
@@ -327,8 +338,8 @@ export abstract class APIClient {
327
338
  }
328
339
 
329
340
  if (this.idempotencyHeader && method !== 'get') {
330
- if (!options.idempotencyKey) options.idempotencyKey = this.defaultIdempotencyKey();
331
- headers[this.idempotencyHeader] = options.idempotencyKey;
341
+ if (!inputOptions.idempotencyKey) inputOptions.idempotencyKey = this.defaultIdempotencyKey();
342
+ headers[this.idempotencyHeader] = inputOptions.idempotencyKey;
332
343
  }
333
344
 
334
345
  const reqHeaders = this.buildHeaders({ options, headers, contentLength, retryCount });
@@ -446,7 +457,9 @@ export abstract class APIClient {
446
457
 
447
458
  await this.prepareOptions(options);
448
459
 
449
- const { req, url, timeout } = this.buildRequest(options, { retryCount: maxRetries - retriesRemaining });
460
+ const { req, url, timeout } = await this.buildRequest(options, {
461
+ retryCount: maxRetries - retriesRemaining,
462
+ });
450
463
 
451
464
  await this.prepareRequest(req, { url, options });
452
465
 
@@ -503,39 +516,28 @@ export abstract class APIClient {
503
516
  return new PagePromise<PageClass, Item>(this, request, Page);
504
517
  }
505
518
 
506
- buildURL<Req>(path: string, query: Req | null | undefined): string {
519
+ buildURL<Req>(path: string, query: Req | null | undefined, defaultBaseURL?: string | undefined): string {
520
+ const baseURL = (!this.#baseURLOverridden && defaultBaseURL) || this.baseURL;
507
521
  const url =
508
522
  isAbsoluteURL(path) ?
509
523
  new URL(path)
510
- : new URL(this.baseURL + (this.baseURL.endsWith('/') && path.startsWith('/') ? path.slice(1) : path));
524
+ : new URL(baseURL + (baseURL.endsWith('/') && path.startsWith('/') ? path.slice(1) : path));
511
525
 
512
526
  const defaultQuery = this.defaultQuery();
513
- if (!isEmptyObj(defaultQuery)) {
514
- query = { ...defaultQuery, ...query } as Req;
527
+ const pathQuery = Object.fromEntries(url.searchParams);
528
+ if (!isEmptyObj(defaultQuery) || !isEmptyObj(pathQuery)) {
529
+ query = { ...pathQuery, ...defaultQuery, ...query } as Req;
515
530
  }
516
531
 
517
532
  if (typeof query === 'object' && query && !Array.isArray(query)) {
518
- url.search = this.stringifyQuery(query as Record<string, unknown>);
533
+ url.search = this.stringifyQuery(query);
519
534
  }
520
535
 
521
536
  return url.toString();
522
537
  }
523
538
 
524
- protected stringifyQuery(query: Record<string, unknown>): string {
525
- return Object.entries(query)
526
- .filter(([_, value]) => typeof value !== 'undefined')
527
- .map(([key, value]) => {
528
- if (typeof value === 'string' || typeof value === 'number' || typeof value === 'boolean') {
529
- return `${encodeURIComponent(key)}=${encodeURIComponent(value)}`;
530
- }
531
- if (value === null) {
532
- return `${encodeURIComponent(key)}=`;
533
- }
534
- throw new SnagSolutionsError(
535
- `Cannot stringify type ${typeof value}; Expected string, number, boolean, or null. If you need to pass nested query parameters, you can manually encode them, e.g. { query: { 'foo[key1]': value1, 'foo[key2]': value2 } }, and please open a GitHub issue requesting better support for your use case.`,
536
- );
537
- })
538
- .join('&');
539
+ protected stringifyQuery(query: object | Record<string, unknown>): string {
540
+ return stringifyQuery(query);
539
541
  }
540
542
 
541
543
  async fetchWithTimeout(
@@ -617,9 +619,9 @@ export abstract class APIClient {
617
619
  }
618
620
  }
619
621
 
620
- // If the API asks us to wait a certain amount of time (and it's a reasonable amount),
621
- // just do what it says, but otherwise calculate a default
622
- if (!(timeoutMillis && 0 <= timeoutMillis && timeoutMillis < 60 * 1000)) {
622
+ // If the API asks us to wait a certain amount of time, do what it says.
623
+ // Otherwise calculate a default.
624
+ if (timeoutMillis === undefined) {
623
625
  const maxRetries = options.maxRetries ?? this.maxRetries;
624
626
  timeoutMillis = this.calculateDefaultRetryTimeoutMillis(retriesRemaining, maxRetries);
625
627
  }
@@ -792,6 +794,7 @@ export type RequestOptions<
792
794
  query?: Req | undefined;
793
795
  body?: Req | null | undefined;
794
796
  headers?: Headers | undefined;
797
+ defaultBaseURL?: string | undefined;
795
798
 
796
799
  maxRetries?: number;
797
800
  stream?: boolean | undefined;
@@ -813,6 +816,7 @@ const requestOptionsKeys: KeysEnum<RequestOptions> = {
813
816
  query: true,
814
817
  body: true,
815
818
  headers: true,
819
+ defaultBaseURL: true,
816
820
 
817
821
  maxRetries: true,
818
822
  stream: true,
@@ -1079,21 +1083,21 @@ export const coerceBoolean = (value: unknown): boolean => {
1079
1083
  };
1080
1084
 
1081
1085
  export const maybeCoerceInteger = (value: unknown): number | undefined => {
1082
- if (value === undefined) {
1086
+ if (value == null) {
1083
1087
  return undefined;
1084
1088
  }
1085
1089
  return coerceInteger(value);
1086
1090
  };
1087
1091
 
1088
1092
  export const maybeCoerceFloat = (value: unknown): number | undefined => {
1089
- if (value === undefined) {
1093
+ if (value == null) {
1090
1094
  return undefined;
1091
1095
  }
1092
1096
  return coerceFloat(value);
1093
1097
  };
1094
1098
 
1095
1099
  export const maybeCoerceBoolean = (value: unknown): boolean | undefined => {
1096
- if (value === undefined) {
1100
+ if (value == null) {
1097
1101
  return undefined;
1098
1102
  }
1099
1103
  return coerceBoolean(value);
package/src/index.ts CHANGED
@@ -1,16 +1,50 @@
1
1
  // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
2
 
3
3
  import { type Agent } from './_shims/index';
4
- import * as qs from './internal/qs';
4
+ import { stringifyQuery } from './internal/utils/query';
5
5
  import * as Core from './core';
6
6
  import * as Errors from './error';
7
7
  import * as Uploads from './uploads';
8
8
  import * as API from './resources/index';
9
9
  import { AssetCreateAssetParams, AssetCreateAssetResponse, Assets } from './resources/assets';
10
- import { AuctionListAuctionBidsParams, AuctionListAuctionsResponse, Auctions } from './resources/auctions';
11
- import { Auth, AuthConnectAuthParams, AuthConnectAuthResponse } from './resources/auth';
12
- import { Minting, MintingGetAssetsParams, MintingGetAssetsResponse } from './resources/minting';
10
+ import {
11
+ Auth,
12
+ AuthConnectAuthParams,
13
+ AuthConnectAuthResponse,
14
+ AuthConnectAuthVerifyParams,
15
+ AuthConnectAuthVerifyResponse,
16
+ } from './resources/auth';
17
+ import {
18
+ TokenClaimCheckEligibilityParams,
19
+ TokenClaimCheckEligibilityResponse,
20
+ TokenClaimGetProofParams,
21
+ TokenClaimGetProofResponse,
22
+ TokenClaimListParams,
23
+ TokenClaimListResponse,
24
+ TokenClaimListUsersParams,
25
+ TokenClaimListUsersResponse,
26
+ TokenClaimRetrieveParams,
27
+ TokenClaimRetrieveResponse,
28
+ TokenClaimUpdateClaimParams,
29
+ TokenClaimUpdateClaimResponse,
30
+ TokenClaims,
31
+ } from './resources/token-claims';
32
+ import {
33
+ AuctionGetPageSectionsParams,
34
+ AuctionGetPageSectionsResponse,
35
+ AuctionListAuctionBidsParams,
36
+ AuctionListAuctionBidsResponse,
37
+ AuctionListAuctionsResponse,
38
+ Auctions,
39
+ } from './resources/auctions/auctions';
13
40
  import { Loyalty } from './resources/loyalty/loyalty';
41
+ import {
42
+ Minting,
43
+ MintingGetAssetsParams,
44
+ MintingGetAssetsResponse,
45
+ MintingGetTokenGateStatusParams,
46
+ MintingGetTokenGateStatusResponse,
47
+ } from './resources/minting/minting';
14
48
  import {
15
49
  Referral,
16
50
  ReferralCreateCodeParams,
@@ -21,10 +55,14 @@ import {
21
55
  UserConnectResponse,
22
56
  UserCountParams,
23
57
  UserCountResponse,
58
+ UserCreateDeviceParams,
59
+ UserCreateDeviceResponse,
24
60
  UserDisconnectParams,
25
61
  UserDisconnectResponse,
26
62
  UserListParams,
27
63
  UserListResponse,
64
+ UserVerifyParams,
65
+ UserVerifyResponse,
28
66
  Users,
29
67
  } from './resources/users/users';
30
68
  import {
@@ -54,6 +92,8 @@ export interface ClientOptions {
54
92
  *
55
93
  * Note that request timeouts are retried by default, so in a worst-case scenario you may wait
56
94
  * much longer than this timeout before the promise succeeds or fails.
95
+ *
96
+ * @unit milliseconds
57
97
  */
58
98
  timeout?: number | undefined;
59
99
 
@@ -137,6 +177,7 @@ export class SnagSolutions extends Core.APIClient {
137
177
 
138
178
  super({
139
179
  baseURL: options.baseURL!,
180
+ baseURLOverridden: baseURL ? baseURL !== 'https://admin.snagsolutions.io/' : false,
140
181
  timeout: options.timeout ?? 60000 /* 1 minute */,
141
182
  httpAgent: options.httpAgent,
142
183
  maxRetries: options.maxRetries,
@@ -156,6 +197,14 @@ export class SnagSolutions extends Core.APIClient {
156
197
  minting: API.Minting = new API.Minting(this);
157
198
  referral: API.Referral = new API.Referral(this);
158
199
  websites: API.Websites = new API.Websites(this);
200
+ tokenClaims: API.TokenClaims = new API.TokenClaims(this);
201
+
202
+ /**
203
+ * Check whether the base URL is set to its default.
204
+ */
205
+ #baseURLOverridden(): boolean {
206
+ return this.baseURL !== 'https://admin.snagsolutions.io/';
207
+ }
159
208
 
160
209
  protected override defaultQuery(): Core.DefaultQuery | undefined {
161
210
  return this._options.defaultQuery;
@@ -172,8 +221,8 @@ export class SnagSolutions extends Core.APIClient {
172
221
  return { 'X-API-KEY': this.apiKey };
173
222
  }
174
223
 
175
- protected override stringifyQuery(query: Record<string, unknown>): string {
176
- return qs.stringify(query, { arrayFormat: 'comma' });
224
+ protected override stringifyQuery(query: object | Record<string, unknown>): string {
225
+ return stringifyQuery(query);
177
226
  }
178
227
 
179
228
  static SnagSolutions = this;
@@ -205,6 +254,8 @@ SnagSolutions.Loyalty = Loyalty;
205
254
  SnagSolutions.Minting = Minting;
206
255
  SnagSolutions.Referral = Referral;
207
256
  SnagSolutions.Websites = Websites;
257
+ SnagSolutions.TokenClaims = TokenClaims;
258
+
208
259
  export declare namespace SnagSolutions {
209
260
  export type RequestOptions = Core.RequestOptions;
210
261
 
@@ -217,12 +268,17 @@ export declare namespace SnagSolutions {
217
268
  export {
218
269
  Auth as Auth,
219
270
  type AuthConnectAuthResponse as AuthConnectAuthResponse,
271
+ type AuthConnectAuthVerifyResponse as AuthConnectAuthVerifyResponse,
220
272
  type AuthConnectAuthParams as AuthConnectAuthParams,
273
+ type AuthConnectAuthVerifyParams as AuthConnectAuthVerifyParams,
221
274
  };
222
275
 
223
276
  export {
224
277
  Auctions as Auctions,
278
+ type AuctionGetPageSectionsResponse as AuctionGetPageSectionsResponse,
279
+ type AuctionListAuctionBidsResponse as AuctionListAuctionBidsResponse,
225
280
  type AuctionListAuctionsResponse as AuctionListAuctionsResponse,
281
+ type AuctionGetPageSectionsParams as AuctionGetPageSectionsParams,
226
282
  type AuctionListAuctionBidsParams as AuctionListAuctionBidsParams,
227
283
  };
228
284
 
@@ -231,11 +287,15 @@ export declare namespace SnagSolutions {
231
287
  type UserListResponse as UserListResponse,
232
288
  type UserConnectResponse as UserConnectResponse,
233
289
  type UserCountResponse as UserCountResponse,
290
+ type UserCreateDeviceResponse as UserCreateDeviceResponse,
234
291
  type UserDisconnectResponse as UserDisconnectResponse,
292
+ type UserVerifyResponse as UserVerifyResponse,
235
293
  type UserListParams as UserListParams,
236
294
  type UserConnectParams as UserConnectParams,
237
295
  type UserCountParams as UserCountParams,
296
+ type UserCreateDeviceParams as UserCreateDeviceParams,
238
297
  type UserDisconnectParams as UserDisconnectParams,
298
+ type UserVerifyParams as UserVerifyParams,
239
299
  };
240
300
 
241
301
  export { Loyalty as Loyalty };
@@ -243,7 +303,9 @@ export declare namespace SnagSolutions {
243
303
  export {
244
304
  Minting as Minting,
245
305
  type MintingGetAssetsResponse as MintingGetAssetsResponse,
306
+ type MintingGetTokenGateStatusResponse as MintingGetTokenGateStatusResponse,
246
307
  type MintingGetAssetsParams as MintingGetAssetsParams,
308
+ type MintingGetTokenGateStatusParams as MintingGetTokenGateStatusParams,
247
309
  };
248
310
 
249
311
  export {
@@ -259,6 +321,22 @@ export declare namespace SnagSolutions {
259
321
  type WebsiteCreateParams as WebsiteCreateParams,
260
322
  type WebsiteListParams as WebsiteListParams,
261
323
  };
324
+
325
+ export {
326
+ TokenClaims as TokenClaims,
327
+ type TokenClaimRetrieveResponse as TokenClaimRetrieveResponse,
328
+ type TokenClaimListResponse as TokenClaimListResponse,
329
+ type TokenClaimCheckEligibilityResponse as TokenClaimCheckEligibilityResponse,
330
+ type TokenClaimGetProofResponse as TokenClaimGetProofResponse,
331
+ type TokenClaimListUsersResponse as TokenClaimListUsersResponse,
332
+ type TokenClaimUpdateClaimResponse as TokenClaimUpdateClaimResponse,
333
+ type TokenClaimRetrieveParams as TokenClaimRetrieveParams,
334
+ type TokenClaimListParams as TokenClaimListParams,
335
+ type TokenClaimCheckEligibilityParams as TokenClaimCheckEligibilityParams,
336
+ type TokenClaimGetProofParams as TokenClaimGetProofParams,
337
+ type TokenClaimListUsersParams as TokenClaimListUsersParams,
338
+ type TokenClaimUpdateClaimParams as TokenClaimUpdateClaimParams,
339
+ };
262
340
  }
263
341
 
264
342
  export { toFile, fileFromPath } from './uploads';
@@ -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: 'repeat' });
7
+ }
package/src/resource.ts CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  import type { SnagSolutions } from './index';
4
4
 
5
- export class APIResource {
5
+ export abstract class APIResource {
6
6
  protected _client: SnagSolutions;
7
7
 
8
8
  constructor(client: SnagSolutions) {
@@ -8,6 +8,14 @@ export class Assets extends APIResource {
8
8
  * This endpoint enables you to upload a file to the resource. Returns a presigned
9
9
  * URL and the asset's public URL. Call PUT with the file as the body to upload the
10
10
  * asset using the presigned URL.
11
+ *
12
+ * @example
13
+ * ```ts
14
+ * const response = await client.assets.createAsset({
15
+ * fileName: 'example.png',
16
+ * fileSize: 1024,
17
+ * });
18
+ * ```
11
19
  */
12
20
  createAsset(
13
21
  body: AssetCreateAssetParams,
@@ -35,15 +43,21 @@ export interface AssetCreateAssetResponse {
35
43
 
36
44
  export interface AssetCreateAssetParams {
37
45
  /**
38
- * The name of the file, must match the regex pattern (converted to lowercase)
46
+ * The name of the file, must match the regex pattern (converted to lowercase) and
47
+ * have a valid extension.
39
48
  */
40
49
  fileName: string;
41
50
 
51
+ /**
52
+ * Size of the file in bytes. Uploaded file must match this file size. 1mb for
53
+ * images and 10mb for videos.
54
+ */
55
+ fileSize: number;
56
+
42
57
  /**
43
58
  * The file path, must be a valid enum value.
44
59
  */
45
60
  filePath?:
46
- | 'announcements'
47
61
  | 'images'
48
62
  | 'videos'
49
63
  | 'banners'
@@ -51,7 +65,8 @@ export interface AssetCreateAssetParams {
51
65
  | 'posts'
52
66
  | 'profiles'
53
67
  | 'minting'
54
- | 'loyalty';
68
+ | 'loyalty'
69
+ | 'tokenClaims';
55
70
 
56
71
  /**
57
72
  * UUID of the organization (optional, converted to lowercase)