@highlightxyz/cli 0.2.0 → 0.3.1

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 (2) hide show
  1. package/lib/index.js +636 -106
  2. package/package.json +1 -1
package/lib/index.js CHANGED
@@ -2,7 +2,7 @@
2
2
  // package.json
3
3
  var package_default = {
4
4
  name: "@highlightxyz/cli",
5
- version: "0.2.0",
5
+ version: "0.3.1",
6
6
  description: "Official command-line interface for the Highlight API",
7
7
  keywords: [
8
8
  "cli",
@@ -209,6 +209,15 @@ var SaleAccessMode;
209
209
  SaleAccessMode2["Public"] = "PUBLIC";
210
210
  SaleAccessMode2["Gated"] = "GATED";
211
211
  })(SaleAccessMode ||= {});
212
+ var MediaPurpose;
213
+ ((MediaPurpose2) => {
214
+ MediaPurpose2["CollectionLogo"] = "CollectionLogo";
215
+ MediaPurpose2["EditionImage"] = "EditionImage";
216
+ MediaPurpose2["EditionAnimation"] = "EditionAnimation";
217
+ MediaPurpose2["SeriesAssets"] = "SeriesAssets";
218
+ MediaPurpose2["GenerativeCode"] = "GenerativeCode";
219
+ MediaPurpose2["UserAvatar"] = "UserAvatar";
220
+ })(MediaPurpose ||= {});
212
221
  var GateMatchMode;
213
222
  ((GateMatchMode2) => {
214
223
  GateMatchMode2["All"] = "ALL";
@@ -1150,8 +1159,6 @@ class Collection extends HeyApiClient {
1150
1159
  { in: "body", key: "description" },
1151
1160
  { in: "body", key: "contractId" },
1152
1161
  { in: "body", key: "contract" },
1153
- { in: "body", key: "logoMediaId" },
1154
- { in: "body", key: "image" },
1155
1162
  { in: "body", key: "type" },
1156
1163
  { in: "body", key: "royalty" },
1157
1164
  { in: "body", key: "tokenManager" }
@@ -1169,6 +1176,24 @@ class Collection extends HeyApiClient {
1169
1176
  }
1170
1177
  });
1171
1178
  }
1179
+ discover(parameters, options) {
1180
+ const params = buildClientParams([parameters], [
1181
+ {
1182
+ args: [
1183
+ { in: "query", key: "type" },
1184
+ { in: "query", key: "chainId" },
1185
+ { in: "query", key: "sort" },
1186
+ { in: "query", key: "limit" },
1187
+ { in: "query", key: "offset" }
1188
+ ]
1189
+ }
1190
+ ]);
1191
+ return (options?.client ?? this.client).get({
1192
+ url: "/collection/discover",
1193
+ ...options,
1194
+ ...params
1195
+ });
1196
+ }
1172
1197
  trending(parameters, options) {
1173
1198
  const params = buildClientParams([parameters], [
1174
1199
  {
@@ -1223,14 +1248,58 @@ class Collection extends HeyApiClient {
1223
1248
  ...params
1224
1249
  });
1225
1250
  }
1226
- finalizeBaseUri(parameters, options) {
1251
+ archiveBaseUri(parameters, options) {
1227
1252
  const params = buildClientParams([parameters], [{ args: [{ in: "path", key: "highlightId" }] }]);
1228
1253
  return (options?.client ?? this.client).post({
1229
- url: "/collection/{highlightId}/finalize-base-uri",
1254
+ url: "/collection/{highlightId}/archive-base-uri",
1230
1255
  ...options,
1231
1256
  ...params
1232
1257
  });
1233
1258
  }
1259
+ createMediaUploadSession(parameters, options) {
1260
+ const params = buildClientParams([parameters], [
1261
+ {
1262
+ args: [
1263
+ { in: "path", key: "highlightId" },
1264
+ { in: "body", key: "purpose" },
1265
+ { in: "body", key: "fileName" },
1266
+ { in: "body", key: "mimeType" },
1267
+ { in: "body", key: "fileSize" },
1268
+ { in: "body", key: "contentHash" }
1269
+ ]
1270
+ }
1271
+ ]);
1272
+ return (options?.client ?? this.client).post({
1273
+ url: "/collection/{highlightId}/media/upload-session",
1274
+ ...options,
1275
+ ...params,
1276
+ headers: {
1277
+ "Content-Type": "application/json",
1278
+ ...options?.headers,
1279
+ ...params.headers
1280
+ }
1281
+ });
1282
+ }
1283
+ updateMetadata(parameters, options) {
1284
+ const params = buildClientParams([parameters], [
1285
+ {
1286
+ args: [
1287
+ { in: "path", key: "highlightId" },
1288
+ { key: "collectionUpdateMetadataInput", map: "body" }
1289
+ ]
1290
+ }
1291
+ ]);
1292
+ return (options?.client ?? this.client).patch({
1293
+ url: "/collection/{highlightId}/metadata",
1294
+ ...options,
1295
+ ...params,
1296
+ headers: {
1297
+ "Content-Type": "application/json",
1298
+ ...options?.headers,
1299
+ ...params.headers
1300
+ }
1301
+ });
1302
+ }
1234
1303
  updateGenerativeDetails(parameters, options) {
1235
1304
  const params = buildClientParams([parameters], [
1236
1305
  {
@@ -1316,7 +1385,6 @@ class Collection extends HeyApiClient {
1316
1385
  { in: "body", key: "paymentRecipient" },
1317
1386
  { in: "body", key: "accessMode" },
1318
1387
  { in: "body", key: "gateId" },
1319
- { in: "body", key: "gasSponsored" },
1320
1388
  { in: "body", key: "mechanicId" },
1321
1389
  { in: "body", key: "typeConfig" },
1322
1390
  { in: "body", key: "collectorMessage" },
@@ -1553,6 +1621,41 @@ class Collection extends HeyApiClient {
1553
1621
  ...params
1554
1622
  });
1555
1623
  }
1624
+ dutchAuctionStanding(parameters, options) {
1625
+ const params = buildClientParams([parameters], [
1626
+ {
1627
+ args: [
1628
+ { in: "path", key: "highlightId" },
1629
+ { in: "path", key: "saleId" }
1630
+ ]
1631
+ }
1632
+ ]);
1633
+ return (options?.client ?? this.client).get({
1634
+ url: "/collection/{highlightId}/sales/{saleId}/dutch",
1635
+ ...options,
1636
+ ...params
1637
+ });
1638
+ }
1639
+ claimDutchRebate(parameters, options) {
1640
+ const params = buildClientParams([parameters], [
1641
+ {
1642
+ args: [
1643
+ { in: "path", key: "highlightId" },
1644
+ { in: "body", key: "saleId" }
1645
+ ]
1646
+ }
1647
+ ]);
1648
+ return (options?.client ?? this.client).post({
1649
+ url: "/collection/{highlightId}/sales/dutch/rebate",
1650
+ ...options,
1651
+ ...params,
1652
+ headers: {
1653
+ "Content-Type": "application/json",
1654
+ ...options?.headers,
1655
+ ...params.headers
1656
+ }
1657
+ });
1658
+ }
1556
1659
  deploy(parameters, options) {
1557
1660
  const params = buildClientParams([parameters], [{ args: [{ in: "path", key: "highlightId" }] }]);
1558
1661
  return (options?.client ?? this.client).post({
@@ -1656,6 +1759,12 @@ class Config extends HeyApiClient {
1656
1759
  ...options
1657
1760
  });
1658
1761
  }
1762
+ mediaHosts(options) {
1763
+ return (options?.client ?? this.client).get({
1764
+ url: "/config/media-hosts",
1765
+ ...options
1766
+ });
1767
+ }
1659
1768
  systemContract(parameters, options) {
1660
1769
  const params = buildClientParams([parameters], [
1661
1770
  {
@@ -1967,41 +2076,10 @@ class Mechanic extends HeyApiClient {
1967
2076
  }
1968
2077
 
1969
2078
  class Media extends HeyApiClient {
1970
- createUploadSession(parameters, options) {
1971
- const params = buildClientParams([parameters], [
1972
- {
1973
- args: [
1974
- { in: "body", key: "kind" },
1975
- { in: "body", key: "scope" },
1976
- { in: "body", key: "fileName" },
1977
- { in: "body", key: "mimeType" },
1978
- { in: "body", key: "fileSize" }
1979
- ]
1980
- }
1981
- ]);
1982
- return (options?.client ?? this.client).post({
1983
- url: "/media/upload-session",
1984
- ...options,
1985
- ...params,
1986
- headers: {
1987
- "Content-Type": "application/json",
1988
- ...options?.headers,
1989
- ...params.headers
1990
- }
1991
- });
1992
- }
1993
- upload(parameters, options) {
1994
- const params = buildClientParams([parameters], [{ args: [{ in: "path", key: "mediaId" }] }]);
1995
- return (options?.client ?? this.client).put({
1996
- url: "/media/{mediaId}/upload",
1997
- ...options,
1998
- ...params
1999
- });
2000
- }
2001
- process(parameters, options) {
2079
+ finalizeUpload(parameters, options) {
2002
2080
  const params = buildClientParams([parameters], [{ args: [{ in: "path", key: "mediaId" }] }]);
2003
2081
  return (options?.client ?? this.client).post({
2004
- url: "/media/{mediaId}/process",
2082
+ url: "/media/{mediaId}/finalize",
2005
2083
  ...options,
2006
2084
  ...params
2007
2085
  });
@@ -2096,6 +2174,55 @@ class Tx extends HeyApiClient {
2096
2174
  }
2097
2175
  }
2098
2176
 
2177
+ class Siwe extends HeyApiClient {
2178
+ nonce(options) {
2179
+ return (options?.client ?? this.client).post({ url: "/user/signin/siwe/nonce", ...options });
2180
+ }
2181
+ }
2182
+
2183
+ class User extends HeyApiClient {
2184
+ createMediaUploadSession(parameters, options) {
2185
+ const params = buildClientParams([parameters], [
2186
+ {
2187
+ args: [
2188
+ { in: "body", key: "purpose" },
2189
+ { in: "body", key: "fileName" },
2190
+ { in: "body", key: "mimeType" },
2191
+ { in: "body", key: "fileSize" },
2192
+ { in: "body", key: "contentHash" }
2193
+ ]
2194
+ }
2195
+ ]);
2196
+ return (options?.client ?? this.client).post({
2197
+ url: "/user/media/upload-session",
2198
+ ...options,
2199
+ ...params,
2200
+ headers: {
2201
+ "Content-Type": "application/json",
2202
+ ...options?.headers,
2203
+ ...params.headers
2204
+ }
2205
+ });
2206
+ }
2207
+ signin(parameters, options) {
2208
+ const params = buildClientParams([parameters], [{ args: [{ key: "body", map: "body" }] }]);
2209
+ return (options?.client ?? this.client).post({
2210
+ url: "/user/signin",
2211
+ ...options,
2212
+ ...params,
2213
+ headers: {
2214
+ "Content-Type": "application/json",
2215
+ ...options?.headers,
2216
+ ...params.headers
2217
+ }
2218
+ });
2219
+ }
2220
+ _siwe;
2221
+ get siwe() {
2222
+ return this._siwe ??= new Siwe({ client: this.client });
2223
+ }
2224
+ }
2225
+
2099
2226
  class Profile extends HeyApiClient {
2100
2227
  get(options) {
2101
2228
  return (options?.client ?? this.client).get({ url: "/user/profile", ...options });
@@ -2122,6 +2249,31 @@ class Profile extends HeyApiClient {
2122
2249
  }
2123
2250
  });
2124
2251
  }
2252
+ artists(parameters, options) {
2253
+ const params = buildClientParams([parameters], [
2254
+ {
2255
+ args: [
2256
+ { in: "query", key: "search" },
2257
+ { in: "query", key: "sort" },
2258
+ { in: "query", key: "limit" },
2259
+ { in: "query", key: "offset" }
2260
+ ]
2261
+ }
2262
+ ]);
2263
+ return (options?.client ?? this.client).get({
2264
+ url: "/user/artists",
2265
+ ...options,
2266
+ ...params
2267
+ });
2268
+ }
2269
+ artistSpotlight(parameters, options) {
2270
+ const params = buildClientParams([parameters], [{ args: [{ in: "query", key: "surface" }] }]);
2271
+ return (options?.client ?? this.client).get({
2272
+ url: "/user/artists/spotlight",
2273
+ ...options,
2274
+ ...params
2275
+ });
2276
+ }
2125
2277
  public(parameters, options) {
2126
2278
  const params = buildClientParams([parameters], [{ args: [{ in: "path", key: "walletAddress" }] }]);
2127
2279
  return (options?.client ?? this.client).get({
@@ -2152,32 +2304,6 @@ class Profile extends HeyApiClient {
2152
2304
  }
2153
2305
  }
2154
2306
 
2155
- class Siwe extends HeyApiClient {
2156
- nonce(options) {
2157
- return (options?.client ?? this.client).post({ url: "/user/signin/siwe/nonce", ...options });
2158
- }
2159
- }
2160
-
2161
- class User extends HeyApiClient {
2162
- signin(parameters, options) {
2163
- const params = buildClientParams([parameters], [{ args: [{ key: "body", map: "body" }] }]);
2164
- return (options?.client ?? this.client).post({
2165
- url: "/user/signin",
2166
- ...options,
2167
- ...params,
2168
- headers: {
2169
- "Content-Type": "application/json",
2170
- ...options?.headers,
2171
- ...params.headers
2172
- }
2173
- });
2174
- }
2175
- _siwe;
2176
- get siwe() {
2177
- return this._siwe ??= new Siwe({ client: this.client });
2178
- }
2179
- }
2180
-
2181
2307
  class ApiKey extends HeyApiClient {
2182
2308
  list(options) {
2183
2309
  return (options?.client ?? this.client).get({ url: "/user/api-keys", ...options });
@@ -2227,6 +2353,9 @@ class HighlightClient extends HeyApiClient {
2227
2353
  super(args);
2228
2354
  HighlightClient.__registry.set(this, args?.key);
2229
2355
  }
2356
+ getIndexerStatus(options) {
2357
+ return (options?.client ?? this.client).get({ url: "/indexer/status", ...options });
2358
+ }
2230
2359
  postIndexerChainsByChainIdActivate(parameters, options) {
2231
2360
  const params = buildClientParams([parameters], [{ args: [{ in: "path", key: "chainId" }] }]);
2232
2361
  return (options?.client ?? this.client).post({
@@ -2255,14 +2384,6 @@ class HighlightClient extends HeyApiClient {
2255
2384
  }
2256
2385
  });
2257
2386
  }
2258
- postIndexerChainsByChainIdPoll(parameters, options) {
2259
- const params = buildClientParams([parameters], [{ args: [{ in: "path", key: "chainId" }] }]);
2260
- return (options?.client ?? this.client).post({
2261
- url: "/indexer/chains/{chainId}/poll",
2262
- ...options,
2263
- ...params
2264
- });
2265
- }
2266
2387
  _collection;
2267
2388
  get collection() {
2268
2389
  return this._collection ??= new Collection({ client: this.client });
@@ -2295,14 +2416,14 @@ class HighlightClient extends HeyApiClient {
2295
2416
  get tx() {
2296
2417
  return this._tx ??= new Tx({ client: this.client });
2297
2418
  }
2298
- _profile;
2299
- get profile() {
2300
- return this._profile ??= new Profile({ client: this.client });
2301
- }
2302
2419
  _user;
2303
2420
  get user() {
2304
2421
  return this._user ??= new User({ client: this.client });
2305
2422
  }
2423
+ _profile;
2424
+ get profile() {
2425
+ return this._profile ??= new Profile({ client: this.client });
2426
+ }
2306
2427
  _apiKey;
2307
2428
  get apiKey() {
2308
2429
  return this._apiKey ??= new ApiKey({ client: this.client });
@@ -2323,7 +2444,406 @@ function createHighlightClient(config) {
2323
2444
  const client2 = createClient(resolvedConfig);
2324
2445
  return new HighlightClient({ client: client2 });
2325
2446
  }
2447
+ // ../../node_modules/@noble/hashes/esm/utils.js
2448
+ /*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */
2449
+ function isBytes(a) {
2450
+ return a instanceof Uint8Array || ArrayBuffer.isView(a) && a.constructor.name === "Uint8Array";
2451
+ }
2452
+ function abytes(b, ...lengths) {
2453
+ if (!isBytes(b))
2454
+ throw new Error("Uint8Array expected");
2455
+ if (lengths.length > 0 && !lengths.includes(b.length))
2456
+ throw new Error("Uint8Array expected of length " + lengths + ", got length=" + b.length);
2457
+ }
2458
+ function aexists(instance, checkFinished = true) {
2459
+ if (instance.destroyed)
2460
+ throw new Error("Hash instance has been destroyed");
2461
+ if (checkFinished && instance.finished)
2462
+ throw new Error("Hash#digest() has already been called");
2463
+ }
2464
+ function aoutput(out, instance) {
2465
+ abytes(out);
2466
+ const min = instance.outputLen;
2467
+ if (out.length < min) {
2468
+ throw new Error("digestInto() expects output buffer of length at least " + min);
2469
+ }
2470
+ }
2471
+ function clean(...arrays) {
2472
+ for (let i = 0;i < arrays.length; i++) {
2473
+ arrays[i].fill(0);
2474
+ }
2475
+ }
2476
+ function createView(arr) {
2477
+ return new DataView(arr.buffer, arr.byteOffset, arr.byteLength);
2478
+ }
2479
+ function rotr(word, shift) {
2480
+ return word << 32 - shift | word >>> shift;
2481
+ }
2482
+ var hasHexBuiltin = /* @__PURE__ */ (() => typeof Uint8Array.from([]).toHex === "function" && typeof Uint8Array.fromHex === "function")();
2483
+ var hexes = /* @__PURE__ */ Array.from({ length: 256 }, (_, i) => i.toString(16).padStart(2, "0"));
2484
+ function bytesToHex(bytes) {
2485
+ abytes(bytes);
2486
+ if (hasHexBuiltin)
2487
+ return bytes.toHex();
2488
+ let hex = "";
2489
+ for (let i = 0;i < bytes.length; i++) {
2490
+ hex += hexes[bytes[i]];
2491
+ }
2492
+ return hex;
2493
+ }
2494
+ function utf8ToBytes(str) {
2495
+ if (typeof str !== "string")
2496
+ throw new Error("string expected");
2497
+ return new Uint8Array(new TextEncoder().encode(str));
2498
+ }
2499
+ function toBytes(data) {
2500
+ if (typeof data === "string")
2501
+ data = utf8ToBytes(data);
2502
+ abytes(data);
2503
+ return data;
2504
+ }
2505
+ class Hash {
2506
+ }
2507
+ function createHasher(hashCons) {
2508
+ const hashC = (msg) => hashCons().update(toBytes(msg)).digest();
2509
+ const tmp = hashCons();
2510
+ hashC.outputLen = tmp.outputLen;
2511
+ hashC.blockLen = tmp.blockLen;
2512
+ hashC.create = () => hashCons();
2513
+ return hashC;
2514
+ }
2515
+
2516
+ // ../../node_modules/@noble/hashes/esm/_md.js
2517
+ function setBigUint64(view, byteOffset, value, isLE) {
2518
+ if (typeof view.setBigUint64 === "function")
2519
+ return view.setBigUint64(byteOffset, value, isLE);
2520
+ const _32n = BigInt(32);
2521
+ const _u32_max = BigInt(4294967295);
2522
+ const wh = Number(value >> _32n & _u32_max);
2523
+ const wl = Number(value & _u32_max);
2524
+ const h = isLE ? 4 : 0;
2525
+ const l = isLE ? 0 : 4;
2526
+ view.setUint32(byteOffset + h, wh, isLE);
2527
+ view.setUint32(byteOffset + l, wl, isLE);
2528
+ }
2529
+ function Chi(a, b, c) {
2530
+ return a & b ^ ~a & c;
2531
+ }
2532
+ function Maj(a, b, c) {
2533
+ return a & b ^ a & c ^ b & c;
2534
+ }
2535
+
2536
+ class HashMD extends Hash {
2537
+ constructor(blockLen, outputLen, padOffset, isLE) {
2538
+ super();
2539
+ this.finished = false;
2540
+ this.length = 0;
2541
+ this.pos = 0;
2542
+ this.destroyed = false;
2543
+ this.blockLen = blockLen;
2544
+ this.outputLen = outputLen;
2545
+ this.padOffset = padOffset;
2546
+ this.isLE = isLE;
2547
+ this.buffer = new Uint8Array(blockLen);
2548
+ this.view = createView(this.buffer);
2549
+ }
2550
+ update(data) {
2551
+ aexists(this);
2552
+ data = toBytes(data);
2553
+ abytes(data);
2554
+ const { view, buffer, blockLen } = this;
2555
+ const len = data.length;
2556
+ for (let pos = 0;pos < len; ) {
2557
+ const take = Math.min(blockLen - this.pos, len - pos);
2558
+ if (take === blockLen) {
2559
+ const dataView = createView(data);
2560
+ for (;blockLen <= len - pos; pos += blockLen)
2561
+ this.process(dataView, pos);
2562
+ continue;
2563
+ }
2564
+ buffer.set(data.subarray(pos, pos + take), this.pos);
2565
+ this.pos += take;
2566
+ pos += take;
2567
+ if (this.pos === blockLen) {
2568
+ this.process(view, 0);
2569
+ this.pos = 0;
2570
+ }
2571
+ }
2572
+ this.length += data.length;
2573
+ this.roundClean();
2574
+ return this;
2575
+ }
2576
+ digestInto(out) {
2577
+ aexists(this);
2578
+ aoutput(out, this);
2579
+ this.finished = true;
2580
+ const { buffer, view, blockLen, isLE } = this;
2581
+ let { pos } = this;
2582
+ buffer[pos++] = 128;
2583
+ clean(this.buffer.subarray(pos));
2584
+ if (this.padOffset > blockLen - pos) {
2585
+ this.process(view, 0);
2586
+ pos = 0;
2587
+ }
2588
+ for (let i = pos;i < blockLen; i++)
2589
+ buffer[i] = 0;
2590
+ setBigUint64(view, blockLen - 8, BigInt(this.length * 8), isLE);
2591
+ this.process(view, 0);
2592
+ const oview = createView(out);
2593
+ const len = this.outputLen;
2594
+ if (len % 4)
2595
+ throw new Error("_sha2: outputLen should be aligned to 32bit");
2596
+ const outLen = len / 4;
2597
+ const state = this.get();
2598
+ if (outLen > state.length)
2599
+ throw new Error("_sha2: outputLen bigger than state");
2600
+ for (let i = 0;i < outLen; i++)
2601
+ oview.setUint32(4 * i, state[i], isLE);
2602
+ }
2603
+ digest() {
2604
+ const { buffer, outputLen } = this;
2605
+ this.digestInto(buffer);
2606
+ const res = buffer.slice(0, outputLen);
2607
+ this.destroy();
2608
+ return res;
2609
+ }
2610
+ _cloneInto(to) {
2611
+ to || (to = new this.constructor);
2612
+ to.set(...this.get());
2613
+ const { blockLen, buffer, length, finished, destroyed, pos } = this;
2614
+ to.destroyed = destroyed;
2615
+ to.finished = finished;
2616
+ to.length = length;
2617
+ to.pos = pos;
2618
+ if (length % blockLen)
2619
+ to.buffer.set(buffer);
2620
+ return to;
2621
+ }
2622
+ clone() {
2623
+ return this._cloneInto();
2624
+ }
2625
+ }
2626
+ var SHA256_IV = /* @__PURE__ */ Uint32Array.from([
2627
+ 1779033703,
2628
+ 3144134277,
2629
+ 1013904242,
2630
+ 2773480762,
2631
+ 1359893119,
2632
+ 2600822924,
2633
+ 528734635,
2634
+ 1541459225
2635
+ ]);
2636
+
2637
+ // ../../node_modules/@noble/hashes/esm/sha2.js
2638
+ var SHA256_K = /* @__PURE__ */ Uint32Array.from([
2639
+ 1116352408,
2640
+ 1899447441,
2641
+ 3049323471,
2642
+ 3921009573,
2643
+ 961987163,
2644
+ 1508970993,
2645
+ 2453635748,
2646
+ 2870763221,
2647
+ 3624381080,
2648
+ 310598401,
2649
+ 607225278,
2650
+ 1426881987,
2651
+ 1925078388,
2652
+ 2162078206,
2653
+ 2614888103,
2654
+ 3248222580,
2655
+ 3835390401,
2656
+ 4022224774,
2657
+ 264347078,
2658
+ 604807628,
2659
+ 770255983,
2660
+ 1249150122,
2661
+ 1555081692,
2662
+ 1996064986,
2663
+ 2554220882,
2664
+ 2821834349,
2665
+ 2952996808,
2666
+ 3210313671,
2667
+ 3336571891,
2668
+ 3584528711,
2669
+ 113926993,
2670
+ 338241895,
2671
+ 666307205,
2672
+ 773529912,
2673
+ 1294757372,
2674
+ 1396182291,
2675
+ 1695183700,
2676
+ 1986661051,
2677
+ 2177026350,
2678
+ 2456956037,
2679
+ 2730485921,
2680
+ 2820302411,
2681
+ 3259730800,
2682
+ 3345764771,
2683
+ 3516065817,
2684
+ 3600352804,
2685
+ 4094571909,
2686
+ 275423344,
2687
+ 430227734,
2688
+ 506948616,
2689
+ 659060556,
2690
+ 883997877,
2691
+ 958139571,
2692
+ 1322822218,
2693
+ 1537002063,
2694
+ 1747873779,
2695
+ 1955562222,
2696
+ 2024104815,
2697
+ 2227730452,
2698
+ 2361852424,
2699
+ 2428436474,
2700
+ 2756734187,
2701
+ 3204031479,
2702
+ 3329325298
2703
+ ]);
2704
+ var SHA256_W = /* @__PURE__ */ new Uint32Array(64);
2705
+
2706
+ class SHA256 extends HashMD {
2707
+ constructor(outputLen = 32) {
2708
+ super(64, outputLen, 8, false);
2709
+ this.A = SHA256_IV[0] | 0;
2710
+ this.B = SHA256_IV[1] | 0;
2711
+ this.C = SHA256_IV[2] | 0;
2712
+ this.D = SHA256_IV[3] | 0;
2713
+ this.E = SHA256_IV[4] | 0;
2714
+ this.F = SHA256_IV[5] | 0;
2715
+ this.G = SHA256_IV[6] | 0;
2716
+ this.H = SHA256_IV[7] | 0;
2717
+ }
2718
+ get() {
2719
+ const { A, B, C, D, E, F, G, H } = this;
2720
+ return [A, B, C, D, E, F, G, H];
2721
+ }
2722
+ set(A, B, C, D, E, F, G, H) {
2723
+ this.A = A | 0;
2724
+ this.B = B | 0;
2725
+ this.C = C | 0;
2726
+ this.D = D | 0;
2727
+ this.E = E | 0;
2728
+ this.F = F | 0;
2729
+ this.G = G | 0;
2730
+ this.H = H | 0;
2731
+ }
2732
+ process(view, offset) {
2733
+ for (let i = 0;i < 16; i++, offset += 4)
2734
+ SHA256_W[i] = view.getUint32(offset, false);
2735
+ for (let i = 16;i < 64; i++) {
2736
+ const W15 = SHA256_W[i - 15];
2737
+ const W2 = SHA256_W[i - 2];
2738
+ const s0 = rotr(W15, 7) ^ rotr(W15, 18) ^ W15 >>> 3;
2739
+ const s1 = rotr(W2, 17) ^ rotr(W2, 19) ^ W2 >>> 10;
2740
+ SHA256_W[i] = s1 + SHA256_W[i - 7] + s0 + SHA256_W[i - 16] | 0;
2741
+ }
2742
+ let { A, B, C, D, E, F, G, H } = this;
2743
+ for (let i = 0;i < 64; i++) {
2744
+ const sigma1 = rotr(E, 6) ^ rotr(E, 11) ^ rotr(E, 25);
2745
+ const T1 = H + sigma1 + Chi(E, F, G) + SHA256_K[i] + SHA256_W[i] | 0;
2746
+ const sigma0 = rotr(A, 2) ^ rotr(A, 13) ^ rotr(A, 22);
2747
+ const T2 = sigma0 + Maj(A, B, C) | 0;
2748
+ H = G;
2749
+ G = F;
2750
+ F = E;
2751
+ E = D + T1 | 0;
2752
+ D = C;
2753
+ C = B;
2754
+ B = A;
2755
+ A = T1 + T2 | 0;
2756
+ }
2757
+ A = A + this.A | 0;
2758
+ B = B + this.B | 0;
2759
+ C = C + this.C | 0;
2760
+ D = D + this.D | 0;
2761
+ E = E + this.E | 0;
2762
+ F = F + this.F | 0;
2763
+ G = G + this.G | 0;
2764
+ H = H + this.H | 0;
2765
+ this.set(A, B, C, D, E, F, G, H);
2766
+ }
2767
+ roundClean() {
2768
+ clean(SHA256_W);
2769
+ }
2770
+ destroy() {
2771
+ this.set(0, 0, 0, 0, 0, 0, 0, 0);
2772
+ clean(this.buffer);
2773
+ }
2774
+ }
2775
+ var sha256 = /* @__PURE__ */ createHasher(() => new SHA256);
2776
+
2326
2777
  // ../sdk/src/v1/media.ts
2778
+ var isReadableStream = (source) => ("getReader" in source);
2779
+ var sha256MediaContent = async (source, options) => {
2780
+ const hasher = sha256.create();
2781
+ let bytesHashed = 0;
2782
+ const update = (chunk) => {
2783
+ if (options?.signal?.aborted) {
2784
+ throw new DOMException("Hashing aborted.", "AbortError");
2785
+ }
2786
+ hasher.update(chunk);
2787
+ bytesHashed += chunk.byteLength;
2788
+ options?.onProgress?.(bytesHashed);
2789
+ };
2790
+ if (isReadableStream(source)) {
2791
+ const reader = source.getReader();
2792
+ try {
2793
+ while (true) {
2794
+ const result = await reader.read();
2795
+ if (result.done)
2796
+ break;
2797
+ update(result.value);
2798
+ }
2799
+ } finally {
2800
+ reader.releaseLock();
2801
+ }
2802
+ } else {
2803
+ for await (const chunk of source)
2804
+ update(chunk);
2805
+ }
2806
+ return `sha256:${bytesToHex(hasher.digest())}`;
2807
+ };
2808
+ var SUPPORTED_IMAGE_CONTENT_TYPES = new Set([
2809
+ "image/avif",
2810
+ "image/gif",
2811
+ "image/heic",
2812
+ "image/heif",
2813
+ "image/jpeg",
2814
+ "image/jpg",
2815
+ "image/png",
2816
+ "image/webp"
2817
+ ]);
2818
+ var DEFAULT_MEDIA_DELIVERY_HOSTS = {
2819
+ assets: "https://assets.highlight.xyz",
2820
+ metadata: "https://metadata.highlight.xyz",
2821
+ legacyAssets: "https://highlight-creator-assets.highlight.xyz",
2822
+ arweaveGateway: "https://arweave.net",
2823
+ ipfsGateway: "https://ipfs.io"
2824
+ };
2825
+ var LEGACY_REFERENCE = /^main\//;
2826
+ var mediaUrl = (media, location, hosts = DEFAULT_MEDIA_DELIVERY_HOSTS) => {
2827
+ switch (location.provider) {
2828
+ case "R2" /* R2 */: {
2829
+ if (LEGACY_REFERENCE.test(location.reference)) {
2830
+ return `${hosts.legacyAssets}/${location.reference}`;
2831
+ }
2832
+ if (media.parentId && media.path) {
2833
+ return `${hosts.assets}/${media.parentId}/${media.path}`;
2834
+ }
2835
+ return media.kind === "Directory" /* Directory */ ? `${hosts.assets}/${media.id}/` : `${hosts.assets}/${media.id}`;
2836
+ }
2837
+ case "Arweave" /* Arweave */:
2838
+ return `${hosts.arweaveGateway}/${location.reference}`;
2839
+ case "IPFS" /* Ipfs */:
2840
+ return `${hosts.ipfsGateway}/ipfs/${location.reference.replace(/^ipfs:\/\//, "").replace(/^\//, "")}`;
2841
+ case "External" /* External */:
2842
+ return location.reference;
2843
+ default:
2844
+ return null;
2845
+ }
2846
+ };
2327
2847
  var DEFAULT_PREFERENCE = [
2328
2848
  "Archive" /* Archive */,
2329
2849
  "Origin" /* Origin */,
@@ -2331,7 +2851,7 @@ var DEFAULT_PREFERENCE = [
2331
2851
  ];
2332
2852
  var pickLocation = (media, preference) => {
2333
2853
  for (const role of preference) {
2334
- const location = media.locations.find((l) => l.role === role && l.status === "Succeeded" /* Succeeded */ && l.url !== null);
2854
+ const location = media.locations.find((l) => l.role === role && l.status === "Succeeded" /* Succeeded */);
2335
2855
  if (location)
2336
2856
  return location;
2337
2857
  }
@@ -2341,7 +2861,8 @@ var resolveMediaUrl = (media, options) => {
2341
2861
  if (!media)
2342
2862
  return null;
2343
2863
  const preference = options?.prefer ? Array.isArray(options.prefer) ? options.prefer : [options.prefer] : DEFAULT_PREFERENCE;
2344
- return pickLocation(media, preference)?.url ?? null;
2864
+ const location = pickLocation(media, preference);
2865
+ return location ? mediaUrl(media, location, options?.hosts) : null;
2345
2866
  };
2346
2867
  // src/config.ts
2347
2868
  import { chmod, mkdir, readFile, rename, writeFile } from "node:fs/promises";
@@ -2753,7 +3274,7 @@ var requiredInputPath = (inputPath) => {
2753
3274
  var isCollectionCreateInput = (value) => {
2754
3275
  if (!isRecord3(value))
2755
3276
  return false;
2756
- if (typeof value.name !== "string" || typeof value.description !== "string" || typeof value.logoMediaId !== "string" || typeof value.image !== "string" || !Object.values(CollectionType).includes(value.type) || !isOptionalString(value.contractId) || !isOptionalString(value.tokenManager)) {
3277
+ if (typeof value.name !== "string" || !isOptionalString(value.description) || !Object.values(CollectionType).includes(value.type) || !isOptionalString(value.contractId) || !isOptionalString(value.tokenManager)) {
2757
3278
  return false;
2758
3279
  }
2759
3280
  if (value.contract !== undefined) {
@@ -2842,7 +3363,7 @@ var create = async (args, global, runtime) => {
2842
3363
  });
2843
3364
  assertNoExtraPositionals(parsed.positionals, 0);
2844
3365
  const inputPath = requiredInputPath(parsed.values.input);
2845
- const input = await readTypedJsonInput(inputPath, runtime, isCollectionCreateInput, "a collection.create object containing name, description, logoMediaId, image, type, and valid contract details");
3366
+ const input = await readTypedJsonInput(inputPath, runtime, isCollectionCreateInput, "a collection.create object containing name, description, logoMediaId, type, and valid contract details");
2846
3367
  const context = await createClientContext(runtime, global);
2847
3368
  const collection = unwrap(await context.client.collection.create(input));
2848
3369
  if (global.json) {
@@ -3060,8 +3581,10 @@ var remove = async (args, global, runtime) => {
3060
3581
  };
3061
3582
 
3062
3583
  // src/commands/media.ts
3063
- import { readFile as readFile3, stat } from "node:fs/promises";
3584
+ import { createReadStream } from "node:fs";
3585
+ import { stat } from "node:fs/promises";
3064
3586
  import path3 from "node:path";
3587
+ import { Readable } from "node:stream";
3065
3588
  var MIME_TYPES = {
3066
3589
  ".css": "text/css",
3067
3590
  ".gif": "image/gif",
@@ -3107,11 +3630,11 @@ var waitUntilReady = async (mediaId, initial, timeoutSeconds, pollIntervalSecond
3107
3630
  var upload = async (args, global, runtime) => {
3108
3631
  const parsed = parseCommandArgs(args, {
3109
3632
  options: {
3110
- kind: { type: "string" },
3633
+ collection: { type: "string" },
3111
3634
  "mime-type": { type: "string" },
3112
3635
  "no-wait": { type: "boolean" },
3113
3636
  "poll-interval": { type: "string" },
3114
- scope: { type: "string" },
3637
+ purpose: { type: "string" },
3115
3638
  timeout: { type: "string" }
3116
3639
  }
3117
3640
  });
@@ -3122,40 +3645,45 @@ var upload = async (args, global, runtime) => {
3122
3645
  if (!fileStat.isFile()) {
3123
3646
  throw new CliError(`Media input must be a file: ${inputPath}`, 2);
3124
3647
  }
3125
- const kindValue = parsed.values.kind?.toLowerCase() ?? "file";
3126
- const kind = kindValue === "file" ? "File" /* File */ : kindValue === "directory" ? "Directory" /* Directory */ : undefined;
3127
- if (!kind) {
3128
- throw new CliError('--kind must be either "file" or "directory"', 2);
3648
+ const purposes = Object.values(MediaPurpose);
3649
+ const purpose = purposes.find((value) => value === parsed.values.purpose);
3650
+ if (!purpose) {
3651
+ throw new CliError(`--purpose must be one of: ${purposes.join(", ")}`, 2);
3129
3652
  }
3130
- if (kind === "Directory" /* Directory */ && path3.extname(absolutePath).toLowerCase() !== ".zip") {
3131
- throw new CliError("Directory media must be uploaded as a .zip file", 2);
3653
+ const collectionId = parsed.values.collection;
3654
+ const needsCollection = purpose !== "UserAvatar" /* UserAvatar */;
3655
+ if (needsCollection && !collectionId) {
3656
+ throw new CliError(`--collection is required for ${purpose} uploads`, 2);
3132
3657
  }
3133
- const scopeValue = parsed.values.scope?.toLowerCase() ?? "collection";
3134
- const scope = scopeValue === "collection" ? "Collection" /* Collection */ : scopeValue === "user" ? "User" /* User */ : undefined;
3135
- if (!scope) {
3136
- throw new CliError('--scope must be either "collection" or "user"', 2);
3658
+ if (!needsCollection && collectionId) {
3659
+ throw new CliError(`--collection is not valid for ${purpose} uploads`, 2);
3137
3660
  }
3661
+ const contentHash = await sha256MediaContent(createReadStream(absolutePath));
3138
3662
  const context = await createClientContext(runtime, global);
3139
- const session = unwrap(await context.client.media.createUploadSession({
3663
+ const body = {
3140
3664
  fileName: path3.basename(absolutePath),
3141
3665
  fileSize: fileStat.size,
3142
- kind,
3143
3666
  mimeType: parsed.values["mime-type"] ?? mimeTypeFor(absolutePath),
3144
- scope
3145
- }));
3667
+ purpose,
3668
+ contentHash
3669
+ };
3670
+ const session = unwrap(collectionId ? await context.client.collection.createMediaUploadSession({
3671
+ highlightId: collectionId,
3672
+ ...body
3673
+ }) : await context.client.user.createMediaUploadSession(body));
3146
3674
  const headers = new Headers(session.upload.headers);
3147
- if (!headers.has("authorization")) {
3148
- headers.set("authorization", `Bearer ${context.apiKey}`);
3149
- }
3150
3675
  const response = await runtime.fetch(session.upload.url, {
3151
- body: await readFile3(absolutePath),
3676
+ body: Readable.toWeb(createReadStream(absolutePath)),
3677
+ duplex: "half",
3152
3678
  headers,
3153
3679
  method: session.upload.method
3154
3680
  });
3155
3681
  if (!response.ok) {
3156
3682
  throw new ApiError(await parseResponseError(response), response.status);
3157
3683
  }
3158
- let media2 = unwrap(await context.client.media.get({ mediaId: session.media.id }));
3684
+ let media2 = unwrap(await context.client.media.finalizeUpload({
3685
+ mediaId: session.uploadMediaId
3686
+ }));
3159
3687
  if (!parsed.values["no-wait"]) {
3160
3688
  media2 = await waitUntilReady(media2.id, media2, positiveNumber(parsed.values.timeout, "--timeout") ?? 300, positiveNumber(parsed.values["poll-interval"], "--poll-interval") ?? 2, runtime, async () => unwrap(await context.client.media.get({ mediaId: media2.id })));
3161
3689
  }
@@ -3199,7 +3727,7 @@ var isOptionalBoolean = (value) => value === undefined || typeof value === "bool
3199
3727
  var isSaleCreateInput = (value) => {
3200
3728
  if (!isRecord3(value))
3201
3729
  return false;
3202
- return Object.values(SaleType).includes(value.type) && typeof value.startAt === "string" && typeof value.price === "string" && typeof value.currency === "string" && typeof value.maxPerTransaction === "number" && Number.isFinite(value.maxPerTransaction) && typeof value.maxPerWallet === "number" && Number.isFinite(value.maxPerWallet) && typeof value.maxTotal === "number" && Number.isFinite(value.maxTotal) && typeof value.paymentRecipient === "string" && isOptionalNullableString(value.name) && isOptionalNullableString(value.endAt) && (value.accessMode === undefined || Object.values(SaleAccessMode).includes(value.accessMode)) && isOptionalNullableString(value.gateId) && isOptionalBoolean(value.gasSponsored) && isOptionalNullableString(value.mechanicId) && isOptionalNullableString(value.collectorMessage) && isOptionalNullableString(value.customMintFee);
3730
+ return Object.values(SaleType).includes(value.type) && typeof value.startAt === "string" && typeof value.price === "string" && typeof value.currency === "string" && typeof value.maxPerTransaction === "number" && Number.isFinite(value.maxPerTransaction) && typeof value.maxPerWallet === "number" && Number.isFinite(value.maxPerWallet) && typeof value.maxTotal === "number" && Number.isFinite(value.maxTotal) && typeof value.paymentRecipient === "string" && isOptionalNullableString(value.name) && isOptionalNullableString(value.endAt) && (value.accessMode === undefined || Object.values(SaleAccessMode).includes(value.accessMode)) && isOptionalNullableString(value.gateId) && isOptionalNullableString(value.mechanicId) && isOptionalNullableString(value.collectorMessage) && isOptionalNullableString(value.customMintFee);
3203
3731
  };
3204
3732
  var SALE_UPDATE_FIELDS = [
3205
3733
  "name",
@@ -3550,8 +4078,10 @@ var MEDIA_HELP = `Usage:
3550
4078
  hl media publish <media-id>
3551
4079
 
3552
4080
  Upload options:
3553
- --kind <file|directory> Directory inputs must be .zip files
3554
- --scope <collection|user> Media scope (default: collection)
4081
+ --purpose <purpose> Required. CollectionLogo, EditionImage,
4082
+ EditionAnimation, SeriesAssets,
4083
+ GenerativeCode, or UserAvatar
4084
+ --collection <highlight-id> Required for every purpose except UserAvatar
3555
4085
  --mime-type <type> Override inferred MIME type
3556
4086
  --no-wait Return before processing is ready
3557
4087
  --timeout <seconds> Wait timeout (default: 300)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@highlightxyz/cli",
3
- "version": "0.2.0",
3
+ "version": "0.3.1",
4
4
  "description": "Official command-line interface for the Highlight API",
5
5
  "keywords": [
6
6
  "cli",