@snagsolutions/sdk 0.1.0-alpha.10

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 (342) hide show
  1. package/CHANGELOG.md +125 -0
  2. package/LICENSE +201 -0
  3. package/README.md +297 -0
  4. package/_shims/MultipartBody.d.ts +9 -0
  5. package/_shims/MultipartBody.d.ts.map +1 -0
  6. package/_shims/MultipartBody.js +16 -0
  7. package/_shims/MultipartBody.js.map +1 -0
  8. package/_shims/MultipartBody.mjs +12 -0
  9. package/_shims/MultipartBody.mjs.map +1 -0
  10. package/_shims/README.md +46 -0
  11. package/_shims/auto/runtime-bun.d.ts +5 -0
  12. package/_shims/auto/runtime-bun.d.ts.map +1 -0
  13. package/_shims/auto/runtime-bun.js +21 -0
  14. package/_shims/auto/runtime-bun.js.map +1 -0
  15. package/_shims/auto/runtime-bun.mjs +2 -0
  16. package/_shims/auto/runtime-bun.mjs.map +1 -0
  17. package/_shims/auto/runtime-node.d.ts +5 -0
  18. package/_shims/auto/runtime-node.d.ts.map +1 -0
  19. package/_shims/auto/runtime-node.js +21 -0
  20. package/_shims/auto/runtime-node.js.map +1 -0
  21. package/_shims/auto/runtime-node.mjs +2 -0
  22. package/_shims/auto/runtime-node.mjs.map +1 -0
  23. package/_shims/auto/runtime.d.ts +5 -0
  24. package/_shims/auto/runtime.d.ts.map +1 -0
  25. package/_shims/auto/runtime.js +21 -0
  26. package/_shims/auto/runtime.js.map +1 -0
  27. package/_shims/auto/runtime.mjs +2 -0
  28. package/_shims/auto/runtime.mjs.map +1 -0
  29. package/_shims/auto/types-node.d.ts +5 -0
  30. package/_shims/auto/types-node.d.ts.map +1 -0
  31. package/_shims/auto/types-node.js +21 -0
  32. package/_shims/auto/types-node.js.map +1 -0
  33. package/_shims/auto/types-node.mjs +2 -0
  34. package/_shims/auto/types-node.mjs.map +1 -0
  35. package/_shims/auto/types.d.ts +101 -0
  36. package/_shims/auto/types.js +3 -0
  37. package/_shims/auto/types.mjs +3 -0
  38. package/_shims/bun-runtime.d.ts +6 -0
  39. package/_shims/bun-runtime.d.ts.map +1 -0
  40. package/_shims/bun-runtime.js +14 -0
  41. package/_shims/bun-runtime.js.map +1 -0
  42. package/_shims/bun-runtime.mjs +10 -0
  43. package/_shims/bun-runtime.mjs.map +1 -0
  44. package/_shims/index.d.ts +81 -0
  45. package/_shims/index.js +13 -0
  46. package/_shims/index.mjs +7 -0
  47. package/_shims/manual-types.d.ts +12 -0
  48. package/_shims/manual-types.js +3 -0
  49. package/_shims/manual-types.mjs +3 -0
  50. package/_shims/node-runtime.d.ts +3 -0
  51. package/_shims/node-runtime.d.ts.map +1 -0
  52. package/_shims/node-runtime.js +89 -0
  53. package/_shims/node-runtime.js.map +1 -0
  54. package/_shims/node-runtime.mjs +56 -0
  55. package/_shims/node-runtime.mjs.map +1 -0
  56. package/_shims/node-types.d.ts +42 -0
  57. package/_shims/node-types.js +3 -0
  58. package/_shims/node-types.mjs +3 -0
  59. package/_shims/registry.d.ts +37 -0
  60. package/_shims/registry.d.ts.map +1 -0
  61. package/_shims/registry.js +41 -0
  62. package/_shims/registry.js.map +1 -0
  63. package/_shims/registry.mjs +37 -0
  64. package/_shims/registry.mjs.map +1 -0
  65. package/_shims/web-runtime.d.ts +5 -0
  66. package/_shims/web-runtime.d.ts.map +1 -0
  67. package/_shims/web-runtime.js +78 -0
  68. package/_shims/web-runtime.js.map +1 -0
  69. package/_shims/web-runtime.mjs +71 -0
  70. package/_shims/web-runtime.mjs.map +1 -0
  71. package/_shims/web-types.d.ts +83 -0
  72. package/_shims/web-types.js +3 -0
  73. package/_shims/web-types.mjs +3 -0
  74. package/core.d.ts +241 -0
  75. package/core.d.ts.map +1 -0
  76. package/core.js +908 -0
  77. package/core.js.map +1 -0
  78. package/core.mjs +876 -0
  79. package/core.mjs.map +1 -0
  80. package/error.d.ts +47 -0
  81. package/error.d.ts.map +1 -0
  82. package/error.js +113 -0
  83. package/error.js.map +1 -0
  84. package/error.mjs +97 -0
  85. package/error.mjs.map +1 -0
  86. package/index.d.mts +126 -0
  87. package/index.d.ts +126 -0
  88. package/index.d.ts.map +1 -0
  89. package/index.js +141 -0
  90. package/index.js.map +1 -0
  91. package/index.mjs +98 -0
  92. package/index.mjs.map +1 -0
  93. package/internal/qs/formats.d.ts +6 -0
  94. package/internal/qs/formats.d.ts.map +1 -0
  95. package/internal/qs/formats.js +11 -0
  96. package/internal/qs/formats.js.map +1 -0
  97. package/internal/qs/formats.mjs +8 -0
  98. package/internal/qs/formats.mjs.map +1 -0
  99. package/internal/qs/index.d.ts +10 -0
  100. package/internal/qs/index.d.ts.map +1 -0
  101. package/internal/qs/index.js +14 -0
  102. package/internal/qs/index.js.map +1 -0
  103. package/internal/qs/index.mjs +10 -0
  104. package/internal/qs/index.mjs.map +1 -0
  105. package/internal/qs/stringify.d.ts +3 -0
  106. package/internal/qs/stringify.d.ts.map +1 -0
  107. package/internal/qs/stringify.js +280 -0
  108. package/internal/qs/stringify.js.map +1 -0
  109. package/internal/qs/stringify.mjs +276 -0
  110. package/internal/qs/stringify.mjs.map +1 -0
  111. package/internal/qs/types.d.ts +57 -0
  112. package/internal/qs/types.d.ts.map +1 -0
  113. package/internal/qs/types.js +3 -0
  114. package/internal/qs/types.js.map +1 -0
  115. package/internal/qs/types.mjs +2 -0
  116. package/internal/qs/types.mjs.map +1 -0
  117. package/internal/qs/utils.d.ts +14 -0
  118. package/internal/qs/utils.d.ts.map +1 -0
  119. package/internal/qs/utils.js +229 -0
  120. package/internal/qs/utils.js.map +1 -0
  121. package/internal/qs/utils.mjs +217 -0
  122. package/internal/qs/utils.mjs.map +1 -0
  123. package/package.json +103 -0
  124. package/resource.d.ts +6 -0
  125. package/resource.d.ts.map +1 -0
  126. package/resource.js +11 -0
  127. package/resource.js.map +1 -0
  128. package/resource.mjs +7 -0
  129. package/resource.mjs.map +1 -0
  130. package/resources/assets.d.ts +50 -0
  131. package/resources/assets.d.ts.map +1 -0
  132. package/resources/assets.js +17 -0
  133. package/resources/assets.js.map +1 -0
  134. package/resources/assets.mjs +13 -0
  135. package/resources/assets.mjs.map +1 -0
  136. package/resources/auction-bids.d.ts +81 -0
  137. package/resources/auction-bids.d.ts.map +1 -0
  138. package/resources/auction-bids.js +30 -0
  139. package/resources/auction-bids.js.map +1 -0
  140. package/resources/auction-bids.mjs +26 -0
  141. package/resources/auction-bids.mjs.map +1 -0
  142. package/resources/drip/drip.d.ts +14 -0
  143. package/resources/drip/drip.d.ts.map +1 -0
  144. package/resources/drip/drip.js +43 -0
  145. package/resources/drip/drip.js.map +1 -0
  146. package/resources/drip/drip.mjs +16 -0
  147. package/resources/drip/drip.mjs.map +1 -0
  148. package/resources/drip/index.d.ts +4 -0
  149. package/resources/drip/index.d.ts.map +1 -0
  150. package/resources/drip/index.js +11 -0
  151. package/resources/drip/index.js.map +1 -0
  152. package/resources/drip/index.mjs +5 -0
  153. package/resources/drip/index.mjs.map +1 -0
  154. package/resources/drip/quests.d.ts +168 -0
  155. package/resources/drip/quests.d.ts.map +1 -0
  156. package/resources/drip/quests.js +17 -0
  157. package/resources/drip/quests.js.map +1 -0
  158. package/resources/drip/quests.mjs +13 -0
  159. package/resources/drip/quests.mjs.map +1 -0
  160. package/resources/drip/status.d.ts +26 -0
  161. package/resources/drip/status.d.ts.map +1 -0
  162. package/resources/drip/status.js +16 -0
  163. package/resources/drip/status.js.map +1 -0
  164. package/resources/drip/status.mjs +12 -0
  165. package/resources/drip/status.mjs.map +1 -0
  166. package/resources/index.d.ts +7 -0
  167. package/resources/index.d.ts.map +1 -0
  168. package/resources/index.js +17 -0
  169. package/resources/index.js.map +1 -0
  170. package/resources/index.mjs +8 -0
  171. package/resources/index.mjs.map +1 -0
  172. package/resources/loyalty/accounts.d.ts +157 -0
  173. package/resources/loyalty/accounts.d.ts.map +1 -0
  174. package/resources/loyalty/accounts.js +16 -0
  175. package/resources/loyalty/accounts.js.map +1 -0
  176. package/resources/loyalty/accounts.mjs +12 -0
  177. package/resources/loyalty/accounts.mjs.map +1 -0
  178. package/resources/loyalty/badges.d.ts +299 -0
  179. package/resources/loyalty/badges.d.ts.map +1 -0
  180. package/resources/loyalty/badges.js +46 -0
  181. package/resources/loyalty/badges.js.map +1 -0
  182. package/resources/loyalty/badges.mjs +42 -0
  183. package/resources/loyalty/badges.mjs.map +1 -0
  184. package/resources/loyalty/currencies.d.ts +252 -0
  185. package/resources/loyalty/currencies.d.ts.map +1 -0
  186. package/resources/loyalty/currencies.js +21 -0
  187. package/resources/loyalty/currencies.js.map +1 -0
  188. package/resources/loyalty/currencies.mjs +17 -0
  189. package/resources/loyalty/currencies.mjs.map +1 -0
  190. package/resources/loyalty/index.d.ts +9 -0
  191. package/resources/loyalty/index.d.ts.map +1 -0
  192. package/resources/loyalty/index.js +21 -0
  193. package/resources/loyalty/index.js.map +1 -0
  194. package/resources/loyalty/index.mjs +10 -0
  195. package/resources/loyalty/index.mjs.map +1 -0
  196. package/resources/loyalty/loyalty.d.ts +34 -0
  197. package/resources/loyalty/loyalty.d.ts.map +1 -0
  198. package/resources/loyalty/loyalty.js +63 -0
  199. package/resources/loyalty/loyalty.js.map +1 -0
  200. package/resources/loyalty/loyalty.mjs +36 -0
  201. package/resources/loyalty/loyalty.mjs.map +1 -0
  202. package/resources/loyalty/multipliers.d.ts +129 -0
  203. package/resources/loyalty/multipliers.d.ts.map +1 -0
  204. package/resources/loyalty/multipliers.js +34 -0
  205. package/resources/loyalty/multipliers.js.map +1 -0
  206. package/resources/loyalty/multipliers.mjs +30 -0
  207. package/resources/loyalty/multipliers.mjs.map +1 -0
  208. package/resources/loyalty/rule-edits.d.ts +330 -0
  209. package/resources/loyalty/rule-edits.d.ts.map +1 -0
  210. package/resources/loyalty/rule-edits.js +21 -0
  211. package/resources/loyalty/rule-edits.js.map +1 -0
  212. package/resources/loyalty/rule-edits.mjs +17 -0
  213. package/resources/loyalty/rule-edits.mjs.map +1 -0
  214. package/resources/loyalty/rules.d.ts +2430 -0
  215. package/resources/loyalty/rules.d.ts.map +1 -0
  216. package/resources/loyalty/rules.js +46 -0
  217. package/resources/loyalty/rules.js.map +1 -0
  218. package/resources/loyalty/rules.mjs +42 -0
  219. package/resources/loyalty/rules.mjs.map +1 -0
  220. package/resources/loyalty/transaction-entries.d.ts +175 -0
  221. package/resources/loyalty/transaction-entries.d.ts.map +1 -0
  222. package/resources/loyalty/transaction-entries.js +16 -0
  223. package/resources/loyalty/transaction-entries.js.map +1 -0
  224. package/resources/loyalty/transaction-entries.mjs +12 -0
  225. package/resources/loyalty/transaction-entries.mjs.map +1 -0
  226. package/resources/users/index.d.ts +4 -0
  227. package/resources/users/index.d.ts.map +1 -0
  228. package/resources/users/index.js +11 -0
  229. package/resources/users/index.js.map +1 -0
  230. package/resources/users/index.mjs +5 -0
  231. package/resources/users/index.mjs.map +1 -0
  232. package/resources/users/metadatas.d.ts +64 -0
  233. package/resources/users/metadatas.d.ts.map +1 -0
  234. package/resources/users/metadatas.js +16 -0
  235. package/resources/users/metadatas.js.map +1 -0
  236. package/resources/users/metadatas.mjs +12 -0
  237. package/resources/users/metadatas.mjs.map +1 -0
  238. package/resources/users/users.d.ts +14 -0
  239. package/resources/users/users.d.ts.map +1 -0
  240. package/resources/users/users.js +43 -0
  241. package/resources/users/users.js.map +1 -0
  242. package/resources/users/users.mjs +16 -0
  243. package/resources/users/users.mjs.map +1 -0
  244. package/resources/users/wallets.d.ts +193 -0
  245. package/resources/users/wallets.d.ts.map +1 -0
  246. package/resources/users/wallets.js +28 -0
  247. package/resources/users/wallets.js.map +1 -0
  248. package/resources/users/wallets.mjs +24 -0
  249. package/resources/users/wallets.mjs.map +1 -0
  250. package/resources/websites.d.ts +203 -0
  251. package/resources/websites.d.ts.map +1 -0
  252. package/resources/websites.js +22 -0
  253. package/resources/websites.js.map +1 -0
  254. package/resources/websites.mjs +18 -0
  255. package/resources/websites.mjs.map +1 -0
  256. package/shims/node.d.ts +30 -0
  257. package/shims/node.d.ts.map +1 -0
  258. package/shims/node.js +31 -0
  259. package/shims/node.js.map +1 -0
  260. package/shims/node.mjs +5 -0
  261. package/shims/node.mjs.map +1 -0
  262. package/shims/web.d.ts +26 -0
  263. package/shims/web.d.ts.map +1 -0
  264. package/shims/web.js +31 -0
  265. package/shims/web.js.map +1 -0
  266. package/shims/web.mjs +5 -0
  267. package/shims/web.mjs.map +1 -0
  268. package/src/_shims/MultipartBody.ts +9 -0
  269. package/src/_shims/README.md +46 -0
  270. package/src/_shims/auto/runtime-bun.ts +4 -0
  271. package/src/_shims/auto/runtime-node.ts +4 -0
  272. package/src/_shims/auto/runtime.ts +4 -0
  273. package/src/_shims/auto/types-node.ts +4 -0
  274. package/src/_shims/auto/types.d.ts +101 -0
  275. package/src/_shims/auto/types.js +3 -0
  276. package/src/_shims/auto/types.mjs +3 -0
  277. package/src/_shims/bun-runtime.ts +14 -0
  278. package/src/_shims/index.d.ts +81 -0
  279. package/src/_shims/index.js +13 -0
  280. package/src/_shims/index.mjs +7 -0
  281. package/src/_shims/manual-types.d.ts +12 -0
  282. package/src/_shims/manual-types.js +3 -0
  283. package/src/_shims/manual-types.mjs +3 -0
  284. package/src/_shims/node-runtime.ts +81 -0
  285. package/src/_shims/node-types.d.ts +42 -0
  286. package/src/_shims/node-types.js +3 -0
  287. package/src/_shims/node-types.mjs +3 -0
  288. package/src/_shims/registry.ts +67 -0
  289. package/src/_shims/web-runtime.ts +103 -0
  290. package/src/_shims/web-types.d.ts +83 -0
  291. package/src/_shims/web-types.js +3 -0
  292. package/src/_shims/web-types.mjs +3 -0
  293. package/src/core.ts +1201 -0
  294. package/src/error.ts +130 -0
  295. package/src/index.ts +235 -0
  296. package/src/internal/qs/LICENSE.md +13 -0
  297. package/src/internal/qs/README.md +3 -0
  298. package/src/internal/qs/formats.ts +9 -0
  299. package/src/internal/qs/index.ts +13 -0
  300. package/src/internal/qs/stringify.ts +388 -0
  301. package/src/internal/qs/types.ts +71 -0
  302. package/src/internal/qs/utils.ts +265 -0
  303. package/src/lib/.keep +4 -0
  304. package/src/resource.ts +11 -0
  305. package/src/resources/assets.ts +71 -0
  306. package/src/resources/auction-bids.ts +123 -0
  307. package/src/resources/drip/drip.ts +25 -0
  308. package/src/resources/drip/index.ts +5 -0
  309. package/src/resources/drip/quests.ts +210 -0
  310. package/src/resources/drip/status.ts +33 -0
  311. package/src/resources/index.ts +14 -0
  312. package/src/resources/loyalty/accounts.ts +199 -0
  313. package/src/resources/loyalty/badges.ts +435 -0
  314. package/src/resources/loyalty/currencies.ts +321 -0
  315. package/src/resources/loyalty/index.ts +61 -0
  316. package/src/resources/loyalty/loyalty.ts +159 -0
  317. package/src/resources/loyalty/multipliers.ts +238 -0
  318. package/src/resources/loyalty/rule-edits.ts +421 -0
  319. package/src/resources/loyalty/rules.ts +3513 -0
  320. package/src/resources/loyalty/transaction-entries.ts +229 -0
  321. package/src/resources/users/index.ts +12 -0
  322. package/src/resources/users/metadatas.ts +103 -0
  323. package/src/resources/users/users.ts +39 -0
  324. package/src/resources/users/wallets.ts +271 -0
  325. package/src/resources/websites.ts +259 -0
  326. package/src/shims/node.ts +50 -0
  327. package/src/shims/web.ts +50 -0
  328. package/src/tsconfig.json +11 -0
  329. package/src/uploads.ts +255 -0
  330. package/src/version.ts +1 -0
  331. package/uploads.d.ts +75 -0
  332. package/uploads.d.ts.map +1 -0
  333. package/uploads.js +171 -0
  334. package/uploads.js.map +1 -0
  335. package/uploads.mjs +158 -0
  336. package/uploads.mjs.map +1 -0
  337. package/version.d.ts +2 -0
  338. package/version.d.ts.map +1 -0
  339. package/version.js +5 -0
  340. package/version.js.map +1 -0
  341. package/version.mjs +2 -0
  342. package/version.mjs.map +1 -0
@@ -0,0 +1,259 @@
1
+ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
+
3
+ import { APIResource } from '../resource';
4
+ import { isRequestOptions } from '../core';
5
+ import * as Core from '../core';
6
+
7
+ export class Websites extends APIResource {
8
+ /**
9
+ * Creates a new website
10
+ */
11
+ create(body: WebsiteCreateParams, options?: Core.RequestOptions): Core.APIPromise<WebsiteCreateResponse> {
12
+ return this._client.post('/api/websites', { body, ...options });
13
+ }
14
+
15
+ /**
16
+ * Returns a list of websites. Includes optional query parameters for filtering and
17
+ * pagination.
18
+ */
19
+ list(query?: WebsiteListParams, options?: Core.RequestOptions): Core.APIPromise<WebsiteListResponse>;
20
+ list(options?: Core.RequestOptions): Core.APIPromise<WebsiteListResponse>;
21
+ list(
22
+ query: WebsiteListParams | Core.RequestOptions = {},
23
+ options?: Core.RequestOptions,
24
+ ): Core.APIPromise<WebsiteListResponse> {
25
+ if (isRequestOptions(query)) {
26
+ return this.list({}, query);
27
+ }
28
+ return this._client.get('/api/websites', { query, ...options });
29
+ }
30
+ }
31
+
32
+ /**
33
+ * Schema representing a website
34
+ */
35
+ export interface WebsiteCreateResponse {
36
+ /**
37
+ * Website ID
38
+ */
39
+ id: string;
40
+
41
+ /**
42
+ * Counts of related entities
43
+ */
44
+ _count: WebsiteCreateResponse._Count;
45
+
46
+ /**
47
+ * Collections associated with the website
48
+ */
49
+ collections: Array<WebsiteCreateResponse.Collection>;
50
+
51
+ /**
52
+ * Website name
53
+ */
54
+ name: string;
55
+
56
+ /**
57
+ * Date when terms were signed
58
+ */
59
+ termsSignedAt: string | null;
60
+ }
61
+
62
+ export namespace WebsiteCreateResponse {
63
+ /**
64
+ * Counts of related entities
65
+ */
66
+ export interface _Count {
67
+ /**
68
+ * Count of minting contract assets
69
+ */
70
+ mintingContractAssets: number;
71
+ }
72
+
73
+ /**
74
+ * Schema representing a collection
75
+ */
76
+ export interface Collection {
77
+ /**
78
+ * Collection ID
79
+ */
80
+ id: string;
81
+
82
+ /**
83
+ * URL of the collection image
84
+ */
85
+ imageUrl: string | null;
86
+
87
+ /**
88
+ * Collection name
89
+ */
90
+ name: string;
91
+
92
+ /**
93
+ * Royalty fee percentage
94
+ */
95
+ royaltyFee: number;
96
+
97
+ /**
98
+ * Address to receive royalty fees
99
+ */
100
+ royaltyFeeAddress: string;
101
+ }
102
+ }
103
+
104
+ /**
105
+ * Response schema for fetching websites
106
+ */
107
+ export interface WebsiteListResponse {
108
+ /**
109
+ * Array of websites
110
+ */
111
+ data: Array<WebsiteListResponse.Data>;
112
+
113
+ /**
114
+ * Indicates if more pages are available
115
+ */
116
+ hasNextPage: boolean;
117
+ }
118
+
119
+ export namespace WebsiteListResponse {
120
+ /**
121
+ * Schema representing a website
122
+ */
123
+ export interface Data {
124
+ /**
125
+ * Website ID
126
+ */
127
+ id: string;
128
+
129
+ /**
130
+ * Counts of related entities
131
+ */
132
+ _count: Data._Count;
133
+
134
+ /**
135
+ * Collections associated with the website
136
+ */
137
+ collections: Array<Data.Collection>;
138
+
139
+ /**
140
+ * Website name
141
+ */
142
+ name: string;
143
+
144
+ /**
145
+ * Date when terms were signed
146
+ */
147
+ termsSignedAt: string | null;
148
+ }
149
+
150
+ export namespace Data {
151
+ /**
152
+ * Counts of related entities
153
+ */
154
+ export interface _Count {
155
+ /**
156
+ * Count of minting contract assets
157
+ */
158
+ mintingContractAssets: number;
159
+ }
160
+
161
+ /**
162
+ * Schema representing a collection
163
+ */
164
+ export interface Collection {
165
+ /**
166
+ * Collection ID
167
+ */
168
+ id: string;
169
+
170
+ /**
171
+ * URL of the collection image
172
+ */
173
+ imageUrl: string | null;
174
+
175
+ /**
176
+ * Collection name
177
+ */
178
+ name: string;
179
+
180
+ /**
181
+ * Royalty fee percentage
182
+ */
183
+ royaltyFee: number;
184
+
185
+ /**
186
+ * Address to receive royalty fees
187
+ */
188
+ royaltyFeeAddress: string;
189
+ }
190
+ }
191
+ }
192
+
193
+ export interface WebsiteCreateParams {
194
+ /**
195
+ * Name of the website
196
+ */
197
+ name: string;
198
+
199
+ /**
200
+ * Discord URL of the website account
201
+ */
202
+ discordUrl?: string;
203
+
204
+ /**
205
+ * Home URL of the official website
206
+ */
207
+ homeUrl?: string;
208
+
209
+ /**
210
+ * Instagram username of the website account
211
+ */
212
+ instagramUsername?: string;
213
+
214
+ /**
215
+ * Organization ID for which this website is being created
216
+ */
217
+ organizationId?: string;
218
+
219
+ /**
220
+ * Telegram URL of the website account
221
+ */
222
+ telegramUrl?: string;
223
+
224
+ /**
225
+ * Twitter username of the website account
226
+ */
227
+ twitterUsername?: string;
228
+ }
229
+
230
+ export interface WebsiteListParams {
231
+ /**
232
+ * Number of items to return
233
+ */
234
+ limit?: number;
235
+
236
+ /**
237
+ * Filter by name
238
+ */
239
+ name?: string;
240
+
241
+ /**
242
+ * Filter by organization ID
243
+ */
244
+ organizationId?: string;
245
+
246
+ /**
247
+ * Pagination cursor, start after this ID
248
+ */
249
+ startingAfter?: string;
250
+ }
251
+
252
+ export declare namespace Websites {
253
+ export {
254
+ type WebsiteCreateResponse as WebsiteCreateResponse,
255
+ type WebsiteListResponse as WebsiteListResponse,
256
+ type WebsiteCreateParams as WebsiteCreateParams,
257
+ type WebsiteListParams as WebsiteListParams,
258
+ };
259
+ }
@@ -0,0 +1,50 @@
1
+ // @ts-ignore
2
+ import * as types from '../_shims/node-types';
3
+ import { setShims } from '../_shims/registry';
4
+ import { getRuntime } from '../_shims/node-runtime';
5
+ setShims(getRuntime());
6
+
7
+ declare module '../_shims/manual-types' {
8
+ export namespace manual {
9
+ // @ts-ignore
10
+ export type Agent = types.Agent;
11
+ // @ts-ignore
12
+ export import fetch = types.fetch;
13
+ // @ts-ignore
14
+ export type Request = types.Request;
15
+ // @ts-ignore
16
+ export type RequestInfo = types.RequestInfo;
17
+ // @ts-ignore
18
+ export type RequestInit = types.RequestInit;
19
+ // @ts-ignore
20
+ export type Response = types.Response;
21
+ // @ts-ignore
22
+ export type ResponseInit = types.ResponseInit;
23
+ // @ts-ignore
24
+ export type ResponseType = types.ResponseType;
25
+ // @ts-ignore
26
+ export type BodyInit = types.BodyInit;
27
+ // @ts-ignore
28
+ export type Headers = types.Headers;
29
+ // @ts-ignore
30
+ export type HeadersInit = types.HeadersInit;
31
+ // @ts-ignore
32
+ export type BlobPropertyBag = types.BlobPropertyBag;
33
+ // @ts-ignore
34
+ export type FilePropertyBag = types.FilePropertyBag;
35
+ // @ts-ignore
36
+ export type FileFromPathOptions = types.FileFromPathOptions;
37
+ // @ts-ignore
38
+ export import FormData = types.FormData;
39
+ // @ts-ignore
40
+ export import File = types.File;
41
+ // @ts-ignore
42
+ export import Blob = types.Blob;
43
+ // @ts-ignore
44
+ export type Readable = types.Readable;
45
+ // @ts-ignore
46
+ export type FsReadStream = types.FsReadStream;
47
+ // @ts-ignore
48
+ export import ReadableStream = types.ReadableStream;
49
+ }
50
+ }
@@ -0,0 +1,50 @@
1
+ // @ts-ignore
2
+ import * as types from '../_shims/web-types';
3
+ import { setShims } from '../_shims/registry';
4
+ import { getRuntime } from '../_shims/web-runtime';
5
+ setShims(getRuntime({ manuallyImported: true }));
6
+
7
+ declare module '../_shims/manual-types' {
8
+ export namespace manual {
9
+ // @ts-ignore
10
+ export type Agent = types.Agent;
11
+ // @ts-ignore
12
+ export import fetch = types.fetch;
13
+ // @ts-ignore
14
+ export type Request = types.Request;
15
+ // @ts-ignore
16
+ export type RequestInfo = types.RequestInfo;
17
+ // @ts-ignore
18
+ export type RequestInit = types.RequestInit;
19
+ // @ts-ignore
20
+ export type Response = types.Response;
21
+ // @ts-ignore
22
+ export type ResponseInit = types.ResponseInit;
23
+ // @ts-ignore
24
+ export type ResponseType = types.ResponseType;
25
+ // @ts-ignore
26
+ export type BodyInit = types.BodyInit;
27
+ // @ts-ignore
28
+ export type Headers = types.Headers;
29
+ // @ts-ignore
30
+ export type HeadersInit = types.HeadersInit;
31
+ // @ts-ignore
32
+ export type BlobPropertyBag = types.BlobPropertyBag;
33
+ // @ts-ignore
34
+ export type FilePropertyBag = types.FilePropertyBag;
35
+ // @ts-ignore
36
+ export type FileFromPathOptions = types.FileFromPathOptions;
37
+ // @ts-ignore
38
+ export import FormData = types.FormData;
39
+ // @ts-ignore
40
+ export import File = types.File;
41
+ // @ts-ignore
42
+ export import Blob = types.Blob;
43
+ // @ts-ignore
44
+ export type Readable = types.Readable;
45
+ // @ts-ignore
46
+ export type FsReadStream = types.FsReadStream;
47
+ // @ts-ignore
48
+ export import ReadableStream = types.ReadableStream;
49
+ }
50
+ }
@@ -0,0 +1,11 @@
1
+ {
2
+ // this config is included in the published src directory to prevent TS errors
3
+ // from appearing when users go to source, and VSCode opens the source .ts file
4
+ // via declaration maps
5
+ "include": ["index.ts"],
6
+ "compilerOptions": {
7
+ "target": "es2015",
8
+ "lib": ["DOM"],
9
+ "moduleResolution": "node"
10
+ }
11
+ }
package/src/uploads.ts ADDED
@@ -0,0 +1,255 @@
1
+ import { type RequestOptions } from './core';
2
+ import {
3
+ FormData,
4
+ File,
5
+ type Blob,
6
+ type FilePropertyBag,
7
+ getMultipartRequestOptions,
8
+ type FsReadStream,
9
+ isFsReadStream,
10
+ } from './_shims/index';
11
+ import { MultipartBody } from './_shims/MultipartBody';
12
+ export { fileFromPath } from './_shims/index';
13
+
14
+ type BlobLikePart = string | ArrayBuffer | ArrayBufferView | BlobLike | Uint8Array | DataView;
15
+ export type BlobPart = string | ArrayBuffer | ArrayBufferView | Blob | Uint8Array | DataView;
16
+
17
+ /**
18
+ * Typically, this is a native "File" class.
19
+ *
20
+ * We provide the {@link toFile} utility to convert a variety of objects
21
+ * into the File class.
22
+ *
23
+ * For convenience, you can also pass a fetch Response, or in Node,
24
+ * the result of fs.createReadStream().
25
+ */
26
+ export type Uploadable = FileLike | ResponseLike | FsReadStream;
27
+
28
+ /**
29
+ * Intended to match web.Blob, node.Blob, node-fetch.Blob, etc.
30
+ */
31
+ export interface BlobLike {
32
+ /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Blob/size) */
33
+ readonly size: number;
34
+ /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Blob/type) */
35
+ readonly type: string;
36
+ /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Blob/text) */
37
+ text(): Promise<string>;
38
+ /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Blob/slice) */
39
+ slice(start?: number, end?: number): BlobLike;
40
+ // unfortunately @types/node-fetch@^2.6.4 doesn't type the arrayBuffer method
41
+ }
42
+
43
+ /**
44
+ * Intended to match web.File, node.File, node-fetch.File, etc.
45
+ */
46
+ export interface FileLike extends BlobLike {
47
+ /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/File/lastModified) */
48
+ readonly lastModified: number;
49
+ /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/File/name) */
50
+ readonly name: string;
51
+ }
52
+
53
+ /**
54
+ * Intended to match web.Response, node.Response, node-fetch.Response, etc.
55
+ */
56
+ export interface ResponseLike {
57
+ url: string;
58
+ blob(): Promise<BlobLike>;
59
+ }
60
+
61
+ export const isResponseLike = (value: any): value is ResponseLike =>
62
+ value != null &&
63
+ typeof value === 'object' &&
64
+ typeof value.url === 'string' &&
65
+ typeof value.blob === 'function';
66
+
67
+ export const isFileLike = (value: any): value is FileLike =>
68
+ value != null &&
69
+ typeof value === 'object' &&
70
+ typeof value.name === 'string' &&
71
+ typeof value.lastModified === 'number' &&
72
+ isBlobLike(value);
73
+
74
+ /**
75
+ * The BlobLike type omits arrayBuffer() because @types/node-fetch@^2.6.4 lacks it; but this check
76
+ * adds the arrayBuffer() method type because it is available and used at runtime
77
+ */
78
+ export const isBlobLike = (value: any): value is BlobLike & { arrayBuffer(): Promise<ArrayBuffer> } =>
79
+ value != null &&
80
+ typeof value === 'object' &&
81
+ typeof value.size === 'number' &&
82
+ typeof value.type === 'string' &&
83
+ typeof value.text === 'function' &&
84
+ typeof value.slice === 'function' &&
85
+ typeof value.arrayBuffer === 'function';
86
+
87
+ export const isUploadable = (value: any): value is Uploadable => {
88
+ return isFileLike(value) || isResponseLike(value) || isFsReadStream(value);
89
+ };
90
+
91
+ export type ToFileInput = Uploadable | Exclude<BlobLikePart, string> | AsyncIterable<BlobLikePart>;
92
+
93
+ /**
94
+ * Helper for creating a {@link File} to pass to an SDK upload method from a variety of different data formats
95
+ * @param value the raw content of the file. Can be an {@link Uploadable}, {@link BlobLikePart}, or {@link AsyncIterable} of {@link BlobLikePart}s
96
+ * @param {string=} name the name of the file. If omitted, toFile will try to determine a file name from bits if possible
97
+ * @param {Object=} options additional properties
98
+ * @param {string=} options.type the MIME type of the content
99
+ * @param {number=} options.lastModified the last modified timestamp
100
+ * @returns a {@link File} with the given properties
101
+ */
102
+ export async function toFile(
103
+ value: ToFileInput | PromiseLike<ToFileInput>,
104
+ name?: string | null | undefined,
105
+ options?: FilePropertyBag | undefined,
106
+ ): Promise<FileLike> {
107
+ // If it's a promise, resolve it.
108
+ value = await value;
109
+
110
+ // If we've been given a `File` we don't need to do anything
111
+ if (isFileLike(value)) {
112
+ return value;
113
+ }
114
+
115
+ if (isResponseLike(value)) {
116
+ const blob = await value.blob();
117
+ name ||= new URL(value.url).pathname.split(/[\\/]/).pop() ?? 'unknown_file';
118
+
119
+ // we need to convert the `Blob` into an array buffer because the `Blob` class
120
+ // that `node-fetch` defines is incompatible with the web standard which results
121
+ // in `new File` interpreting it as a string instead of binary data.
122
+ const data = isBlobLike(blob) ? [(await blob.arrayBuffer()) as any] : [blob];
123
+
124
+ return new File(data, name, options);
125
+ }
126
+
127
+ const bits = await getBytes(value);
128
+
129
+ name ||= getName(value) ?? 'unknown_file';
130
+
131
+ if (!options?.type) {
132
+ const type = (bits[0] as any)?.type;
133
+ if (typeof type === 'string') {
134
+ options = { ...options, type };
135
+ }
136
+ }
137
+
138
+ return new File(bits, name, options);
139
+ }
140
+
141
+ async function getBytes(value: ToFileInput): Promise<Array<BlobPart>> {
142
+ let parts: Array<BlobPart> = [];
143
+ if (
144
+ typeof value === 'string' ||
145
+ ArrayBuffer.isView(value) || // includes Uint8Array, Buffer, etc.
146
+ value instanceof ArrayBuffer
147
+ ) {
148
+ parts.push(value);
149
+ } else if (isBlobLike(value)) {
150
+ parts.push(await value.arrayBuffer());
151
+ } else if (
152
+ isAsyncIterableIterator(value) // includes Readable, ReadableStream, etc.
153
+ ) {
154
+ for await (const chunk of value) {
155
+ parts.push(chunk as BlobPart); // TODO, consider validating?
156
+ }
157
+ } else {
158
+ throw new Error(
159
+ `Unexpected data type: ${typeof value}; constructor: ${value?.constructor
160
+ ?.name}; props: ${propsForError(value)}`,
161
+ );
162
+ }
163
+
164
+ return parts;
165
+ }
166
+
167
+ function propsForError(value: any): string {
168
+ const props = Object.getOwnPropertyNames(value);
169
+ return `[${props.map((p) => `"${p}"`).join(', ')}]`;
170
+ }
171
+
172
+ function getName(value: any): string | undefined {
173
+ return (
174
+ getStringFromMaybeBuffer(value.name) ||
175
+ getStringFromMaybeBuffer(value.filename) ||
176
+ // For fs.ReadStream
177
+ getStringFromMaybeBuffer(value.path)?.split(/[\\/]/).pop()
178
+ );
179
+ }
180
+
181
+ const getStringFromMaybeBuffer = (x: string | Buffer | unknown): string | undefined => {
182
+ if (typeof x === 'string') return x;
183
+ if (typeof Buffer !== 'undefined' && x instanceof Buffer) return String(x);
184
+ return undefined;
185
+ };
186
+
187
+ const isAsyncIterableIterator = (value: any): value is AsyncIterableIterator<unknown> =>
188
+ value != null && typeof value === 'object' && typeof value[Symbol.asyncIterator] === 'function';
189
+
190
+ export const isMultipartBody = (body: any): body is MultipartBody =>
191
+ body && typeof body === 'object' && body.body && body[Symbol.toStringTag] === 'MultipartBody';
192
+
193
+ /**
194
+ * Returns a multipart/form-data request if any part of the given request body contains a File / Blob value.
195
+ * Otherwise returns the request as is.
196
+ */
197
+ export const maybeMultipartFormRequestOptions = async <T = Record<string, unknown>>(
198
+ opts: RequestOptions<T>,
199
+ ): Promise<RequestOptions<T | MultipartBody>> => {
200
+ if (!hasUploadableValue(opts.body)) return opts;
201
+
202
+ const form = await createForm(opts.body);
203
+ return getMultipartRequestOptions(form, opts);
204
+ };
205
+
206
+ export const multipartFormRequestOptions = async <T = Record<string, unknown>>(
207
+ opts: RequestOptions<T>,
208
+ ): Promise<RequestOptions<T | MultipartBody>> => {
209
+ const form = await createForm(opts.body);
210
+ return getMultipartRequestOptions(form, opts);
211
+ };
212
+
213
+ export const createForm = async <T = Record<string, unknown>>(body: T | undefined): Promise<FormData> => {
214
+ const form = new FormData();
215
+ await Promise.all(Object.entries(body || {}).map(([key, value]) => addFormValue(form, key, value)));
216
+ return form;
217
+ };
218
+
219
+ const hasUploadableValue = (value: unknown): boolean => {
220
+ if (isUploadable(value)) return true;
221
+ if (Array.isArray(value)) return value.some(hasUploadableValue);
222
+ if (value && typeof value === 'object') {
223
+ for (const k in value) {
224
+ if (hasUploadableValue((value as any)[k])) return true;
225
+ }
226
+ }
227
+ return false;
228
+ };
229
+
230
+ const addFormValue = async (form: FormData, key: string, value: unknown): Promise<void> => {
231
+ if (value === undefined) return;
232
+ if (value == null) {
233
+ throw new TypeError(
234
+ `Received null for "${key}"; to pass null in FormData, you must use the string 'null'`,
235
+ );
236
+ }
237
+
238
+ // TODO: make nested formats configurable
239
+ if (typeof value === 'string' || typeof value === 'number' || typeof value === 'boolean') {
240
+ form.append(key, String(value));
241
+ } else if (isUploadable(value)) {
242
+ const file = await toFile(value);
243
+ form.append(key, file as File);
244
+ } else if (Array.isArray(value)) {
245
+ await Promise.all(value.map((entry) => addFormValue(form, key + '[]', entry)));
246
+ } else if (typeof value === 'object') {
247
+ await Promise.all(
248
+ Object.entries(value).map(([name, prop]) => addFormValue(form, `${key}[${name}]`, prop)),
249
+ );
250
+ } else {
251
+ throw new TypeError(
252
+ `Invalid value given to form, expected a string, number, boolean, object, Array, File or Blob but got ${value} instead`,
253
+ );
254
+ }
255
+ };
package/src/version.ts ADDED
@@ -0,0 +1 @@
1
+ export const VERSION = '0.1.0-alpha.10'; // x-release-please-version
package/uploads.d.ts ADDED
@@ -0,0 +1,75 @@
1
+ import { type RequestOptions } from "./core.js";
2
+ import { FormData, type Blob, type FilePropertyBag, type FsReadStream } from "./_shims/index.js";
3
+ import { MultipartBody } from "./_shims/MultipartBody.js";
4
+ export { fileFromPath } from "./_shims/index.js";
5
+ type BlobLikePart = string | ArrayBuffer | ArrayBufferView | BlobLike | Uint8Array | DataView;
6
+ export type BlobPart = string | ArrayBuffer | ArrayBufferView | Blob | Uint8Array | DataView;
7
+ /**
8
+ * Typically, this is a native "File" class.
9
+ *
10
+ * We provide the {@link toFile} utility to convert a variety of objects
11
+ * into the File class.
12
+ *
13
+ * For convenience, you can also pass a fetch Response, or in Node,
14
+ * the result of fs.createReadStream().
15
+ */
16
+ export type Uploadable = FileLike | ResponseLike | FsReadStream;
17
+ /**
18
+ * Intended to match web.Blob, node.Blob, node-fetch.Blob, etc.
19
+ */
20
+ export interface BlobLike {
21
+ /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Blob/size) */
22
+ readonly size: number;
23
+ /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Blob/type) */
24
+ readonly type: string;
25
+ /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Blob/text) */
26
+ text(): Promise<string>;
27
+ /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Blob/slice) */
28
+ slice(start?: number, end?: number): BlobLike;
29
+ }
30
+ /**
31
+ * Intended to match web.File, node.File, node-fetch.File, etc.
32
+ */
33
+ export interface FileLike extends BlobLike {
34
+ /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/File/lastModified) */
35
+ readonly lastModified: number;
36
+ /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/File/name) */
37
+ readonly name: string;
38
+ }
39
+ /**
40
+ * Intended to match web.Response, node.Response, node-fetch.Response, etc.
41
+ */
42
+ export interface ResponseLike {
43
+ url: string;
44
+ blob(): Promise<BlobLike>;
45
+ }
46
+ export declare const isResponseLike: (value: any) => value is ResponseLike;
47
+ export declare const isFileLike: (value: any) => value is FileLike;
48
+ /**
49
+ * The BlobLike type omits arrayBuffer() because @types/node-fetch@^2.6.4 lacks it; but this check
50
+ * adds the arrayBuffer() method type because it is available and used at runtime
51
+ */
52
+ export declare const isBlobLike: (value: any) => value is BlobLike & {
53
+ arrayBuffer(): Promise<ArrayBuffer>;
54
+ };
55
+ export declare const isUploadable: (value: any) => value is Uploadable;
56
+ export type ToFileInput = Uploadable | Exclude<BlobLikePart, string> | AsyncIterable<BlobLikePart>;
57
+ /**
58
+ * Helper for creating a {@link File} to pass to an SDK upload method from a variety of different data formats
59
+ * @param value the raw content of the file. Can be an {@link Uploadable}, {@link BlobLikePart}, or {@link AsyncIterable} of {@link BlobLikePart}s
60
+ * @param {string=} name the name of the file. If omitted, toFile will try to determine a file name from bits if possible
61
+ * @param {Object=} options additional properties
62
+ * @param {string=} options.type the MIME type of the content
63
+ * @param {number=} options.lastModified the last modified timestamp
64
+ * @returns a {@link File} with the given properties
65
+ */
66
+ export declare function toFile(value: ToFileInput | PromiseLike<ToFileInput>, name?: string | null | undefined, options?: FilePropertyBag | undefined): Promise<FileLike>;
67
+ export declare const isMultipartBody: (body: any) => body is MultipartBody;
68
+ /**
69
+ * Returns a multipart/form-data request if any part of the given request body contains a File / Blob value.
70
+ * Otherwise returns the request as is.
71
+ */
72
+ export declare const maybeMultipartFormRequestOptions: <T = Record<string, unknown>>(opts: RequestOptions<T>) => Promise<RequestOptions<MultipartBody | T>>;
73
+ export declare const multipartFormRequestOptions: <T = Record<string, unknown>>(opts: RequestOptions<T>) => Promise<RequestOptions<MultipartBody | T>>;
74
+ export declare const createForm: <T = Record<string, unknown>>(body: T | undefined) => Promise<FormData>;
75
+ //# sourceMappingURL=uploads.d.ts.map