@highlightxyz/cli 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +158 -0
- package/lib/index.js +3694 -0
- package/package.json +50 -0
package/lib/index.js
ADDED
|
@@ -0,0 +1,3694 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// package.json
|
|
3
|
+
var package_default = {
|
|
4
|
+
name: "@highlightxyz/cli",
|
|
5
|
+
version: "0.1.0",
|
|
6
|
+
description: "Official command-line interface for the Highlight API",
|
|
7
|
+
keywords: [
|
|
8
|
+
"cli",
|
|
9
|
+
"ethereum",
|
|
10
|
+
"highlight",
|
|
11
|
+
"nft",
|
|
12
|
+
"web3"
|
|
13
|
+
],
|
|
14
|
+
homepage: "https://highlight.xyz",
|
|
15
|
+
license: "MIT",
|
|
16
|
+
repository: {
|
|
17
|
+
type: "git",
|
|
18
|
+
url: "https://github.com/highlight-xyz/highlight-app.git",
|
|
19
|
+
directory: "packages/cli"
|
|
20
|
+
},
|
|
21
|
+
files: [
|
|
22
|
+
"lib",
|
|
23
|
+
"README.md"
|
|
24
|
+
],
|
|
25
|
+
type: "module",
|
|
26
|
+
bin: {
|
|
27
|
+
hl: "./lib/index.js"
|
|
28
|
+
},
|
|
29
|
+
scripts: {
|
|
30
|
+
build: "bun build ./src/index.ts --outfile ./lib/index.js --target node --format esm",
|
|
31
|
+
"ts-check": "bunx --bun tsgo --noEmit -p tsconfig.json",
|
|
32
|
+
test: "bun test",
|
|
33
|
+
lint: "oxlint ./src",
|
|
34
|
+
"lint:fix": "oxlint --fix --quiet ./src",
|
|
35
|
+
format: 'oxfmt --check --no-error-on-unmatched-pattern "./src/**/*.{js,jsx,ts,tsx,mjs,cjs}"',
|
|
36
|
+
"format:fix": 'oxfmt --write --no-error-on-unmatched-pattern "./src/**/*.{js,jsx,ts,tsx,mjs,cjs}"',
|
|
37
|
+
prepublishOnly: "bun run build"
|
|
38
|
+
},
|
|
39
|
+
dependencies: {
|
|
40
|
+
"@highlightxyz/sdk": "*"
|
|
41
|
+
},
|
|
42
|
+
devDependencies: {
|
|
43
|
+
"@types/bun": "^1.3.9",
|
|
44
|
+
"@types/node": "^25.3.2"
|
|
45
|
+
},
|
|
46
|
+
engines: {
|
|
47
|
+
node: ">=20"
|
|
48
|
+
},
|
|
49
|
+
publishConfig: {
|
|
50
|
+
access: "public"
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
// src/args.ts
|
|
55
|
+
import { parseArgs } from "node:util";
|
|
56
|
+
|
|
57
|
+
// src/errors.ts
|
|
58
|
+
class CliError extends Error {
|
|
59
|
+
exitCode;
|
|
60
|
+
constructor(message, exitCode = 1) {
|
|
61
|
+
super(message);
|
|
62
|
+
this.name = "CliError";
|
|
63
|
+
this.exitCode = exitCode;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
var isRecord = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
67
|
+
var errorMessage = (error) => {
|
|
68
|
+
if (typeof error === "string" && error.length > 0) {
|
|
69
|
+
return error;
|
|
70
|
+
}
|
|
71
|
+
if (isRecord(error)) {
|
|
72
|
+
for (const key of ["message", "error", "name"]) {
|
|
73
|
+
const value = error[key];
|
|
74
|
+
if (typeof value === "string" && value.length > 0) {
|
|
75
|
+
return value;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
return JSON.stringify(error);
|
|
79
|
+
}
|
|
80
|
+
return "Unknown API error";
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
class ApiError extends CliError {
|
|
84
|
+
status;
|
|
85
|
+
details;
|
|
86
|
+
constructor(error, status) {
|
|
87
|
+
super(status ? `Highlight API returned ${status}: ${errorMessage(error)}` : errorMessage(error));
|
|
88
|
+
this.name = "ApiError";
|
|
89
|
+
this.status = status;
|
|
90
|
+
this.details = error;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
var unwrap = (result) => {
|
|
94
|
+
if (result.data !== undefined) {
|
|
95
|
+
return result.data;
|
|
96
|
+
}
|
|
97
|
+
throw new ApiError(result.error, result.response?.status);
|
|
98
|
+
};
|
|
99
|
+
var toErrorMessage = (error) => error instanceof Error ? error.message : String(error);
|
|
100
|
+
|
|
101
|
+
// src/args.ts
|
|
102
|
+
var optionValue = (args, index, option) => {
|
|
103
|
+
const inline = args[index]?.match(new RegExp(`^${option}=(.+)$`))?.[1];
|
|
104
|
+
if (inline !== undefined) {
|
|
105
|
+
return [inline, index];
|
|
106
|
+
}
|
|
107
|
+
const value = args[index + 1];
|
|
108
|
+
if (!value || value.startsWith("-")) {
|
|
109
|
+
throw new CliError(`${option} requires a value`, 2);
|
|
110
|
+
}
|
|
111
|
+
return [value, index + 1];
|
|
112
|
+
};
|
|
113
|
+
var extractGlobalOptions = (args) => {
|
|
114
|
+
const global = {
|
|
115
|
+
help: false,
|
|
116
|
+
json: false,
|
|
117
|
+
version: false
|
|
118
|
+
};
|
|
119
|
+
const remaining = [];
|
|
120
|
+
for (let index = 0;index < args.length; index += 1) {
|
|
121
|
+
const argument = args[index];
|
|
122
|
+
if (argument === "--json") {
|
|
123
|
+
global.json = true;
|
|
124
|
+
} else if (argument === "--help" || argument === "-h") {
|
|
125
|
+
global.help = true;
|
|
126
|
+
} else if (argument === "--version" || argument === "-v") {
|
|
127
|
+
global.version = true;
|
|
128
|
+
} else if (argument === "--profile" || argument.startsWith("--profile=")) {
|
|
129
|
+
const [value, consumedIndex] = optionValue(args, index, "--profile");
|
|
130
|
+
global.profile = value;
|
|
131
|
+
index = consumedIndex;
|
|
132
|
+
} else if (argument === "--api-url" || argument.startsWith("--api-url=")) {
|
|
133
|
+
const [value, consumedIndex] = optionValue(args, index, "--api-url");
|
|
134
|
+
global.apiUrl = value;
|
|
135
|
+
index = consumedIndex;
|
|
136
|
+
} else {
|
|
137
|
+
remaining.push(argument);
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
return { args: remaining, global };
|
|
141
|
+
};
|
|
142
|
+
var parseCommandArgs = (args, config) => {
|
|
143
|
+
try {
|
|
144
|
+
return parseArgs({
|
|
145
|
+
allowPositionals: true,
|
|
146
|
+
args,
|
|
147
|
+
options: config.options,
|
|
148
|
+
strict: true
|
|
149
|
+
});
|
|
150
|
+
} catch (error) {
|
|
151
|
+
throw new CliError(toErrorMessage(error), 2);
|
|
152
|
+
}
|
|
153
|
+
};
|
|
154
|
+
var requiredPositional = (positionals, index, label) => {
|
|
155
|
+
const value = positionals[index];
|
|
156
|
+
if (!value) {
|
|
157
|
+
throw new CliError(`Missing required argument: ${label}`, 2);
|
|
158
|
+
}
|
|
159
|
+
return value;
|
|
160
|
+
};
|
|
161
|
+
var assertNoExtraPositionals = (positionals, expected) => {
|
|
162
|
+
if (positionals.length > expected) {
|
|
163
|
+
throw new CliError(`Unexpected argument: ${positionals[expected]}`, 2);
|
|
164
|
+
}
|
|
165
|
+
};
|
|
166
|
+
var positiveInteger = (value, label) => {
|
|
167
|
+
if (value === undefined)
|
|
168
|
+
return;
|
|
169
|
+
const parsed = Number(value);
|
|
170
|
+
if (!Number.isInteger(parsed) || parsed <= 0) {
|
|
171
|
+
throw new CliError(`${label} must be a positive integer`, 2);
|
|
172
|
+
}
|
|
173
|
+
return parsed;
|
|
174
|
+
};
|
|
175
|
+
var positiveNumber = (value, label) => {
|
|
176
|
+
if (value === undefined)
|
|
177
|
+
return;
|
|
178
|
+
const parsed = Number(value);
|
|
179
|
+
if (!Number.isFinite(parsed) || parsed <= 0) {
|
|
180
|
+
throw new CliError(`${label} must be a positive number`, 2);
|
|
181
|
+
}
|
|
182
|
+
return parsed;
|
|
183
|
+
};
|
|
184
|
+
|
|
185
|
+
// ../sdk/src/v1/gen/types.gen.ts
|
|
186
|
+
var CollectionType;
|
|
187
|
+
((CollectionType2) => {
|
|
188
|
+
CollectionType2["OpenEdition"] = "OpenEdition";
|
|
189
|
+
CollectionType2["LimitedEdition"] = "LimitedEdition";
|
|
190
|
+
CollectionType2["OneOfOne"] = "OneOfOne";
|
|
191
|
+
CollectionType2["Series"] = "Series";
|
|
192
|
+
CollectionType2["GenerativeSeries"] = "GenerativeSeries";
|
|
193
|
+
})(CollectionType ||= {});
|
|
194
|
+
var ContractStandard;
|
|
195
|
+
((ContractStandard2) => {
|
|
196
|
+
ContractStandard2["Erc721"] = "ERC721";
|
|
197
|
+
ContractStandard2["Erc1155"] = "ERC1155";
|
|
198
|
+
})(ContractStandard ||= {});
|
|
199
|
+
var SaleType;
|
|
200
|
+
((SaleType2) => {
|
|
201
|
+
SaleType2["FixedPrice"] = "FIXED_PRICE";
|
|
202
|
+
SaleType2["DutchAuction"] = "DUTCH_AUCTION";
|
|
203
|
+
SaleType2["RankedAuction"] = "RANKED_AUCTION";
|
|
204
|
+
SaleType2["EnglishAuction"] = "ENGLISH_AUCTION";
|
|
205
|
+
SaleType2["Custom"] = "CUSTOM";
|
|
206
|
+
})(SaleType ||= {});
|
|
207
|
+
var SaleAccessMode;
|
|
208
|
+
((SaleAccessMode2) => {
|
|
209
|
+
SaleAccessMode2["Public"] = "PUBLIC";
|
|
210
|
+
SaleAccessMode2["Gated"] = "GATED";
|
|
211
|
+
})(SaleAccessMode ||= {});
|
|
212
|
+
var GateMatchMode;
|
|
213
|
+
((GateMatchMode2) => {
|
|
214
|
+
GateMatchMode2["All"] = "ALL";
|
|
215
|
+
GateMatchMode2["Any"] = "ANY";
|
|
216
|
+
})(GateMatchMode ||= {});
|
|
217
|
+
// ../sdk/src/v1/gen/core/bodySerializer.gen.ts
|
|
218
|
+
var jsonBodySerializer = {
|
|
219
|
+
bodySerializer: (body) => JSON.stringify(body, (_key, value) => typeof value === "bigint" ? value.toString() : value)
|
|
220
|
+
};
|
|
221
|
+
// ../sdk/src/v1/gen/core/params.gen.ts
|
|
222
|
+
var extraPrefixesMap = {
|
|
223
|
+
$body_: "body",
|
|
224
|
+
$headers_: "headers",
|
|
225
|
+
$path_: "path",
|
|
226
|
+
$query_: "query"
|
|
227
|
+
};
|
|
228
|
+
var extraPrefixes = Object.entries(extraPrefixesMap);
|
|
229
|
+
var buildKeyMap = (fields, map) => {
|
|
230
|
+
if (!map) {
|
|
231
|
+
map = new Map;
|
|
232
|
+
}
|
|
233
|
+
for (const config of fields) {
|
|
234
|
+
if ("in" in config) {
|
|
235
|
+
if (config.key) {
|
|
236
|
+
map.set(config.key, {
|
|
237
|
+
in: config.in,
|
|
238
|
+
map: config.map
|
|
239
|
+
});
|
|
240
|
+
}
|
|
241
|
+
} else if ("key" in config) {
|
|
242
|
+
map.set(config.key, {
|
|
243
|
+
map: config.map
|
|
244
|
+
});
|
|
245
|
+
} else if (config.args) {
|
|
246
|
+
buildKeyMap(config.args, map);
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
return map;
|
|
250
|
+
};
|
|
251
|
+
var stripEmptySlots = (params) => {
|
|
252
|
+
for (const [slot, value] of Object.entries(params)) {
|
|
253
|
+
if (value && typeof value === "object" && !Array.isArray(value) && !Object.keys(value).length) {
|
|
254
|
+
delete params[slot];
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
};
|
|
258
|
+
var buildClientParams = (args, fields) => {
|
|
259
|
+
const params = {
|
|
260
|
+
body: {},
|
|
261
|
+
headers: {},
|
|
262
|
+
path: {},
|
|
263
|
+
query: {}
|
|
264
|
+
};
|
|
265
|
+
const map = buildKeyMap(fields);
|
|
266
|
+
let config;
|
|
267
|
+
for (const [index, arg] of args.entries()) {
|
|
268
|
+
if (fields[index]) {
|
|
269
|
+
config = fields[index];
|
|
270
|
+
}
|
|
271
|
+
if (!config) {
|
|
272
|
+
continue;
|
|
273
|
+
}
|
|
274
|
+
if ("in" in config) {
|
|
275
|
+
if (config.key) {
|
|
276
|
+
const field = map.get(config.key);
|
|
277
|
+
const name = field.map || config.key;
|
|
278
|
+
if (field.in) {
|
|
279
|
+
params[field.in][name] = arg;
|
|
280
|
+
}
|
|
281
|
+
} else {
|
|
282
|
+
params.body = arg;
|
|
283
|
+
}
|
|
284
|
+
} else {
|
|
285
|
+
for (const [key, value] of Object.entries(arg ?? {})) {
|
|
286
|
+
const field = map.get(key);
|
|
287
|
+
if (field) {
|
|
288
|
+
if (field.in) {
|
|
289
|
+
const name = field.map || key;
|
|
290
|
+
params[field.in][name] = value;
|
|
291
|
+
} else {
|
|
292
|
+
params[field.map] = value;
|
|
293
|
+
}
|
|
294
|
+
} else {
|
|
295
|
+
const extra = extraPrefixes.find(([prefix]) => key.startsWith(prefix));
|
|
296
|
+
if (extra) {
|
|
297
|
+
const [prefix, slot] = extra;
|
|
298
|
+
params[slot][key.slice(prefix.length)] = value;
|
|
299
|
+
} else if ("allowExtra" in config && config.allowExtra) {
|
|
300
|
+
for (const [slot, allowed] of Object.entries(config.allowExtra)) {
|
|
301
|
+
if (allowed) {
|
|
302
|
+
params[slot][key] = value;
|
|
303
|
+
break;
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
stripEmptySlots(params);
|
|
312
|
+
return params;
|
|
313
|
+
};
|
|
314
|
+
// ../sdk/src/v1/gen/core/serverSentEvents.gen.ts
|
|
315
|
+
var createSseClient = ({
|
|
316
|
+
onRequest,
|
|
317
|
+
onSseError,
|
|
318
|
+
onSseEvent,
|
|
319
|
+
responseTransformer,
|
|
320
|
+
responseValidator,
|
|
321
|
+
sseDefaultRetryDelay,
|
|
322
|
+
sseMaxRetryAttempts,
|
|
323
|
+
sseMaxRetryDelay,
|
|
324
|
+
sseSleepFn,
|
|
325
|
+
url,
|
|
326
|
+
...options
|
|
327
|
+
}) => {
|
|
328
|
+
let lastEventId;
|
|
329
|
+
const sleep = sseSleepFn ?? ((ms) => new Promise((resolve) => setTimeout(resolve, ms)));
|
|
330
|
+
const createStream = async function* () {
|
|
331
|
+
let retryDelay = sseDefaultRetryDelay ?? 3000;
|
|
332
|
+
let attempt = 0;
|
|
333
|
+
const signal = options.signal ?? new AbortController().signal;
|
|
334
|
+
while (true) {
|
|
335
|
+
if (signal.aborted)
|
|
336
|
+
break;
|
|
337
|
+
attempt++;
|
|
338
|
+
const headers = options.headers instanceof Headers ? options.headers : new Headers(options.headers);
|
|
339
|
+
if (lastEventId !== undefined) {
|
|
340
|
+
headers.set("Last-Event-ID", lastEventId);
|
|
341
|
+
}
|
|
342
|
+
try {
|
|
343
|
+
const requestInit = {
|
|
344
|
+
redirect: "follow",
|
|
345
|
+
...options,
|
|
346
|
+
body: options.serializedBody,
|
|
347
|
+
headers,
|
|
348
|
+
signal
|
|
349
|
+
};
|
|
350
|
+
let request = new Request(url, requestInit);
|
|
351
|
+
if (onRequest) {
|
|
352
|
+
request = await onRequest(url, requestInit);
|
|
353
|
+
}
|
|
354
|
+
const _fetch = options.fetch ?? globalThis.fetch;
|
|
355
|
+
const response = await _fetch(request);
|
|
356
|
+
if (!response.ok)
|
|
357
|
+
throw new Error(`SSE failed: ${response.status} ${response.statusText}`);
|
|
358
|
+
if (!response.body)
|
|
359
|
+
throw new Error("No body in SSE response");
|
|
360
|
+
const reader = response.body.pipeThrough(new TextDecoderStream).getReader();
|
|
361
|
+
let buffer = "";
|
|
362
|
+
const abortHandler = () => {
|
|
363
|
+
try {
|
|
364
|
+
reader.cancel();
|
|
365
|
+
} catch {}
|
|
366
|
+
};
|
|
367
|
+
signal.addEventListener("abort", abortHandler);
|
|
368
|
+
try {
|
|
369
|
+
while (true) {
|
|
370
|
+
const { done, value } = await reader.read();
|
|
371
|
+
if (done)
|
|
372
|
+
break;
|
|
373
|
+
buffer += value;
|
|
374
|
+
buffer = buffer.replace(/\r\n/g, `
|
|
375
|
+
`).replace(/\r/g, `
|
|
376
|
+
`);
|
|
377
|
+
const chunks = buffer.split(`
|
|
378
|
+
|
|
379
|
+
`);
|
|
380
|
+
buffer = chunks.pop() ?? "";
|
|
381
|
+
for (const chunk of chunks) {
|
|
382
|
+
const lines = chunk.split(`
|
|
383
|
+
`);
|
|
384
|
+
const dataLines = [];
|
|
385
|
+
let eventName;
|
|
386
|
+
for (const line of lines) {
|
|
387
|
+
if (line.startsWith("data:")) {
|
|
388
|
+
dataLines.push(line.replace(/^data:\s*/, ""));
|
|
389
|
+
} else if (line.startsWith("event:")) {
|
|
390
|
+
eventName = line.replace(/^event:\s*/, "");
|
|
391
|
+
} else if (line.startsWith("id:")) {
|
|
392
|
+
lastEventId = line.replace(/^id:\s*/, "");
|
|
393
|
+
} else if (line.startsWith("retry:")) {
|
|
394
|
+
const parsed = Number.parseInt(line.replace(/^retry:\s*/, ""), 10);
|
|
395
|
+
if (!Number.isNaN(parsed)) {
|
|
396
|
+
retryDelay = parsed;
|
|
397
|
+
}
|
|
398
|
+
}
|
|
399
|
+
}
|
|
400
|
+
let data;
|
|
401
|
+
let parsedJson = false;
|
|
402
|
+
if (dataLines.length) {
|
|
403
|
+
const rawData = dataLines.join(`
|
|
404
|
+
`);
|
|
405
|
+
try {
|
|
406
|
+
data = JSON.parse(rawData);
|
|
407
|
+
parsedJson = true;
|
|
408
|
+
} catch {
|
|
409
|
+
data = rawData;
|
|
410
|
+
}
|
|
411
|
+
}
|
|
412
|
+
if (parsedJson) {
|
|
413
|
+
if (responseValidator) {
|
|
414
|
+
await responseValidator(data);
|
|
415
|
+
}
|
|
416
|
+
if (responseTransformer) {
|
|
417
|
+
data = await responseTransformer(data);
|
|
418
|
+
}
|
|
419
|
+
}
|
|
420
|
+
onSseEvent?.({
|
|
421
|
+
data,
|
|
422
|
+
event: eventName,
|
|
423
|
+
id: lastEventId,
|
|
424
|
+
retry: retryDelay
|
|
425
|
+
});
|
|
426
|
+
if (dataLines.length) {
|
|
427
|
+
yield data;
|
|
428
|
+
}
|
|
429
|
+
}
|
|
430
|
+
}
|
|
431
|
+
} finally {
|
|
432
|
+
signal.removeEventListener("abort", abortHandler);
|
|
433
|
+
reader.releaseLock();
|
|
434
|
+
}
|
|
435
|
+
break;
|
|
436
|
+
} catch (error) {
|
|
437
|
+
onSseError?.(error);
|
|
438
|
+
if (sseMaxRetryAttempts !== undefined && attempt >= sseMaxRetryAttempts) {
|
|
439
|
+
break;
|
|
440
|
+
}
|
|
441
|
+
const backoff = Math.min(retryDelay * 2 ** (attempt - 1), sseMaxRetryDelay ?? 30000);
|
|
442
|
+
await sleep(backoff);
|
|
443
|
+
}
|
|
444
|
+
}
|
|
445
|
+
};
|
|
446
|
+
const stream = createStream();
|
|
447
|
+
return { stream };
|
|
448
|
+
};
|
|
449
|
+
|
|
450
|
+
// ../sdk/src/v1/gen/core/pathSerializer.gen.ts
|
|
451
|
+
var separatorArrayExplode = (style) => {
|
|
452
|
+
switch (style) {
|
|
453
|
+
case "label":
|
|
454
|
+
return ".";
|
|
455
|
+
case "matrix":
|
|
456
|
+
return ";";
|
|
457
|
+
case "simple":
|
|
458
|
+
return ",";
|
|
459
|
+
default:
|
|
460
|
+
return "&";
|
|
461
|
+
}
|
|
462
|
+
};
|
|
463
|
+
var separatorArrayNoExplode = (style) => {
|
|
464
|
+
switch (style) {
|
|
465
|
+
case "form":
|
|
466
|
+
return ",";
|
|
467
|
+
case "pipeDelimited":
|
|
468
|
+
return "|";
|
|
469
|
+
case "spaceDelimited":
|
|
470
|
+
return "%20";
|
|
471
|
+
default:
|
|
472
|
+
return ",";
|
|
473
|
+
}
|
|
474
|
+
};
|
|
475
|
+
var separatorObjectExplode = (style) => {
|
|
476
|
+
switch (style) {
|
|
477
|
+
case "label":
|
|
478
|
+
return ".";
|
|
479
|
+
case "matrix":
|
|
480
|
+
return ";";
|
|
481
|
+
case "simple":
|
|
482
|
+
return ",";
|
|
483
|
+
default:
|
|
484
|
+
return "&";
|
|
485
|
+
}
|
|
486
|
+
};
|
|
487
|
+
var serializeArrayParam = ({
|
|
488
|
+
allowReserved,
|
|
489
|
+
explode,
|
|
490
|
+
name,
|
|
491
|
+
style,
|
|
492
|
+
value
|
|
493
|
+
}) => {
|
|
494
|
+
if (!explode) {
|
|
495
|
+
const joinedValues2 = (allowReserved ? value : value.map((v) => encodeURIComponent(v))).join(separatorArrayNoExplode(style));
|
|
496
|
+
switch (style) {
|
|
497
|
+
case "label":
|
|
498
|
+
return `.${joinedValues2}`;
|
|
499
|
+
case "matrix":
|
|
500
|
+
return `;${name}=${joinedValues2}`;
|
|
501
|
+
case "simple":
|
|
502
|
+
return joinedValues2;
|
|
503
|
+
default:
|
|
504
|
+
return `${name}=${joinedValues2}`;
|
|
505
|
+
}
|
|
506
|
+
}
|
|
507
|
+
const separator = separatorArrayExplode(style);
|
|
508
|
+
const joinedValues = value.map((v) => {
|
|
509
|
+
if (style === "label" || style === "simple") {
|
|
510
|
+
return allowReserved ? v : encodeURIComponent(v);
|
|
511
|
+
}
|
|
512
|
+
return serializePrimitiveParam({
|
|
513
|
+
allowReserved,
|
|
514
|
+
name,
|
|
515
|
+
value: v
|
|
516
|
+
});
|
|
517
|
+
}).join(separator);
|
|
518
|
+
return style === "label" || style === "matrix" ? separator + joinedValues : joinedValues;
|
|
519
|
+
};
|
|
520
|
+
var serializePrimitiveParam = ({
|
|
521
|
+
allowReserved,
|
|
522
|
+
name,
|
|
523
|
+
value
|
|
524
|
+
}) => {
|
|
525
|
+
if (value === undefined || value === null) {
|
|
526
|
+
return "";
|
|
527
|
+
}
|
|
528
|
+
if (typeof value === "object") {
|
|
529
|
+
throw new Error("Deeply-nested arrays/objects aren’t supported. Provide your own `querySerializer()` to handle these.");
|
|
530
|
+
}
|
|
531
|
+
return `${name}=${allowReserved ? value : encodeURIComponent(value)}`;
|
|
532
|
+
};
|
|
533
|
+
var serializeObjectParam = ({
|
|
534
|
+
allowReserved,
|
|
535
|
+
explode,
|
|
536
|
+
name,
|
|
537
|
+
style,
|
|
538
|
+
value,
|
|
539
|
+
valueOnly
|
|
540
|
+
}) => {
|
|
541
|
+
if (value instanceof Date) {
|
|
542
|
+
return valueOnly ? value.toISOString() : `${name}=${value.toISOString()}`;
|
|
543
|
+
}
|
|
544
|
+
if (style !== "deepObject" && !explode) {
|
|
545
|
+
let values = [];
|
|
546
|
+
Object.entries(value).forEach(([key, v]) => {
|
|
547
|
+
values = [...values, key, allowReserved ? v : encodeURIComponent(v)];
|
|
548
|
+
});
|
|
549
|
+
const joinedValues2 = values.join(",");
|
|
550
|
+
switch (style) {
|
|
551
|
+
case "form":
|
|
552
|
+
return `${name}=${joinedValues2}`;
|
|
553
|
+
case "label":
|
|
554
|
+
return `.${joinedValues2}`;
|
|
555
|
+
case "matrix":
|
|
556
|
+
return `;${name}=${joinedValues2}`;
|
|
557
|
+
default:
|
|
558
|
+
return joinedValues2;
|
|
559
|
+
}
|
|
560
|
+
}
|
|
561
|
+
const separator = separatorObjectExplode(style);
|
|
562
|
+
const joinedValues = Object.entries(value).map(([key, v]) => serializePrimitiveParam({
|
|
563
|
+
allowReserved,
|
|
564
|
+
name: style === "deepObject" ? `${name}[${key}]` : key,
|
|
565
|
+
value: v
|
|
566
|
+
})).join(separator);
|
|
567
|
+
return style === "label" || style === "matrix" ? separator + joinedValues : joinedValues;
|
|
568
|
+
};
|
|
569
|
+
|
|
570
|
+
// ../sdk/src/v1/gen/core/utils.gen.ts
|
|
571
|
+
var PATH_PARAM_RE = /\{[^{}]+\}/g;
|
|
572
|
+
var defaultPathSerializer = ({ path, url: _url }) => {
|
|
573
|
+
let url = _url;
|
|
574
|
+
const matches = _url.match(PATH_PARAM_RE);
|
|
575
|
+
if (matches) {
|
|
576
|
+
for (const match of matches) {
|
|
577
|
+
let explode = false;
|
|
578
|
+
let name = match.substring(1, match.length - 1);
|
|
579
|
+
let style = "simple";
|
|
580
|
+
if (name.endsWith("*")) {
|
|
581
|
+
explode = true;
|
|
582
|
+
name = name.substring(0, name.length - 1);
|
|
583
|
+
}
|
|
584
|
+
if (name.startsWith(".")) {
|
|
585
|
+
name = name.substring(1);
|
|
586
|
+
style = "label";
|
|
587
|
+
} else if (name.startsWith(";")) {
|
|
588
|
+
name = name.substring(1);
|
|
589
|
+
style = "matrix";
|
|
590
|
+
}
|
|
591
|
+
const value = path[name];
|
|
592
|
+
if (value === undefined || value === null) {
|
|
593
|
+
continue;
|
|
594
|
+
}
|
|
595
|
+
if (Array.isArray(value)) {
|
|
596
|
+
url = url.replace(match, serializeArrayParam({ explode, name, style, value }));
|
|
597
|
+
continue;
|
|
598
|
+
}
|
|
599
|
+
if (typeof value === "object") {
|
|
600
|
+
url = url.replace(match, serializeObjectParam({
|
|
601
|
+
explode,
|
|
602
|
+
name,
|
|
603
|
+
style,
|
|
604
|
+
value,
|
|
605
|
+
valueOnly: true
|
|
606
|
+
}));
|
|
607
|
+
continue;
|
|
608
|
+
}
|
|
609
|
+
if (style === "matrix") {
|
|
610
|
+
url = url.replace(match, `;${serializePrimitiveParam({
|
|
611
|
+
name,
|
|
612
|
+
value
|
|
613
|
+
})}`);
|
|
614
|
+
continue;
|
|
615
|
+
}
|
|
616
|
+
const replaceValue = encodeURIComponent(style === "label" ? `.${value}` : value);
|
|
617
|
+
url = url.replace(match, replaceValue);
|
|
618
|
+
}
|
|
619
|
+
}
|
|
620
|
+
return url;
|
|
621
|
+
};
|
|
622
|
+
var getUrl = ({
|
|
623
|
+
baseUrl,
|
|
624
|
+
path,
|
|
625
|
+
query,
|
|
626
|
+
querySerializer,
|
|
627
|
+
url: _url
|
|
628
|
+
}) => {
|
|
629
|
+
const pathUrl = _url.startsWith("/") ? _url : `/${_url}`;
|
|
630
|
+
let url = (baseUrl ?? "") + pathUrl;
|
|
631
|
+
if (path) {
|
|
632
|
+
url = defaultPathSerializer({ path, url });
|
|
633
|
+
}
|
|
634
|
+
let search = query ? querySerializer(query) : "";
|
|
635
|
+
if (search.startsWith("?")) {
|
|
636
|
+
search = search.substring(1);
|
|
637
|
+
}
|
|
638
|
+
if (search) {
|
|
639
|
+
url += `?${search}`;
|
|
640
|
+
}
|
|
641
|
+
return url;
|
|
642
|
+
};
|
|
643
|
+
function getValidRequestBody(options) {
|
|
644
|
+
const hasBody = options.body !== undefined;
|
|
645
|
+
const isSerializedBody = hasBody && options.bodySerializer;
|
|
646
|
+
if (isSerializedBody) {
|
|
647
|
+
if ("serializedBody" in options) {
|
|
648
|
+
const hasSerializedBody = options.serializedBody !== undefined && options.serializedBody !== "";
|
|
649
|
+
return hasSerializedBody ? options.serializedBody : null;
|
|
650
|
+
}
|
|
651
|
+
return options.body !== "" ? options.body : null;
|
|
652
|
+
}
|
|
653
|
+
if (hasBody) {
|
|
654
|
+
return options.body;
|
|
655
|
+
}
|
|
656
|
+
return;
|
|
657
|
+
}
|
|
658
|
+
|
|
659
|
+
// ../sdk/src/v1/gen/core/auth.gen.ts
|
|
660
|
+
var getAuthToken = async (auth, callback) => {
|
|
661
|
+
const token = typeof callback === "function" ? await callback(auth) : callback;
|
|
662
|
+
if (!token) {
|
|
663
|
+
return;
|
|
664
|
+
}
|
|
665
|
+
if (auth.scheme === "bearer") {
|
|
666
|
+
return `Bearer ${token}`;
|
|
667
|
+
}
|
|
668
|
+
if (auth.scheme === "basic") {
|
|
669
|
+
return `Basic ${btoa(token)}`;
|
|
670
|
+
}
|
|
671
|
+
return token;
|
|
672
|
+
};
|
|
673
|
+
|
|
674
|
+
// ../sdk/src/v1/gen/client/utils.gen.ts
|
|
675
|
+
var createQuerySerializer = ({
|
|
676
|
+
parameters = {},
|
|
677
|
+
...args
|
|
678
|
+
} = {}) => {
|
|
679
|
+
const querySerializer = (queryParams) => {
|
|
680
|
+
const search = [];
|
|
681
|
+
if (queryParams && typeof queryParams === "object") {
|
|
682
|
+
for (const name in queryParams) {
|
|
683
|
+
const value = queryParams[name];
|
|
684
|
+
if (value === undefined || value === null) {
|
|
685
|
+
continue;
|
|
686
|
+
}
|
|
687
|
+
const options = parameters[name] || args;
|
|
688
|
+
if (Array.isArray(value)) {
|
|
689
|
+
const serializedArray = serializeArrayParam({
|
|
690
|
+
allowReserved: options.allowReserved,
|
|
691
|
+
explode: true,
|
|
692
|
+
name,
|
|
693
|
+
style: "form",
|
|
694
|
+
value,
|
|
695
|
+
...options.array
|
|
696
|
+
});
|
|
697
|
+
if (serializedArray)
|
|
698
|
+
search.push(serializedArray);
|
|
699
|
+
} else if (typeof value === "object") {
|
|
700
|
+
const serializedObject = serializeObjectParam({
|
|
701
|
+
allowReserved: options.allowReserved,
|
|
702
|
+
explode: true,
|
|
703
|
+
name,
|
|
704
|
+
style: "deepObject",
|
|
705
|
+
value,
|
|
706
|
+
...options.object
|
|
707
|
+
});
|
|
708
|
+
if (serializedObject)
|
|
709
|
+
search.push(serializedObject);
|
|
710
|
+
} else {
|
|
711
|
+
const serializedPrimitive = serializePrimitiveParam({
|
|
712
|
+
allowReserved: options.allowReserved,
|
|
713
|
+
name,
|
|
714
|
+
value
|
|
715
|
+
});
|
|
716
|
+
if (serializedPrimitive)
|
|
717
|
+
search.push(serializedPrimitive);
|
|
718
|
+
}
|
|
719
|
+
}
|
|
720
|
+
}
|
|
721
|
+
return search.join("&");
|
|
722
|
+
};
|
|
723
|
+
return querySerializer;
|
|
724
|
+
};
|
|
725
|
+
var getParseAs = (contentType) => {
|
|
726
|
+
if (!contentType) {
|
|
727
|
+
return "stream";
|
|
728
|
+
}
|
|
729
|
+
const cleanContent = contentType.split(";")[0]?.trim();
|
|
730
|
+
if (!cleanContent) {
|
|
731
|
+
return;
|
|
732
|
+
}
|
|
733
|
+
if (cleanContent.startsWith("application/json") || cleanContent.endsWith("+json")) {
|
|
734
|
+
return "json";
|
|
735
|
+
}
|
|
736
|
+
if (cleanContent === "multipart/form-data") {
|
|
737
|
+
return "formData";
|
|
738
|
+
}
|
|
739
|
+
if (["application/", "audio/", "image/", "video/"].some((type) => cleanContent.startsWith(type))) {
|
|
740
|
+
return "blob";
|
|
741
|
+
}
|
|
742
|
+
if (cleanContent.startsWith("text/")) {
|
|
743
|
+
return "text";
|
|
744
|
+
}
|
|
745
|
+
return;
|
|
746
|
+
};
|
|
747
|
+
var checkForExistence = (options, name) => {
|
|
748
|
+
if (!name) {
|
|
749
|
+
return false;
|
|
750
|
+
}
|
|
751
|
+
if (options.headers.has(name) || options.query?.[name] || options.headers.get("Cookie")?.includes(`${name}=`)) {
|
|
752
|
+
return true;
|
|
753
|
+
}
|
|
754
|
+
return false;
|
|
755
|
+
};
|
|
756
|
+
var setAuthParams = async ({
|
|
757
|
+
security,
|
|
758
|
+
...options
|
|
759
|
+
}) => {
|
|
760
|
+
for (const auth of security) {
|
|
761
|
+
if (checkForExistence(options, auth.name)) {
|
|
762
|
+
continue;
|
|
763
|
+
}
|
|
764
|
+
const token = await getAuthToken(auth, options.auth);
|
|
765
|
+
if (!token) {
|
|
766
|
+
continue;
|
|
767
|
+
}
|
|
768
|
+
const name = auth.name ?? "Authorization";
|
|
769
|
+
switch (auth.in) {
|
|
770
|
+
case "query":
|
|
771
|
+
if (!options.query) {
|
|
772
|
+
options.query = {};
|
|
773
|
+
}
|
|
774
|
+
options.query[name] = token;
|
|
775
|
+
break;
|
|
776
|
+
case "cookie":
|
|
777
|
+
options.headers.append("Cookie", `${name}=${token}`);
|
|
778
|
+
break;
|
|
779
|
+
case "header":
|
|
780
|
+
default:
|
|
781
|
+
options.headers.set(name, token);
|
|
782
|
+
break;
|
|
783
|
+
}
|
|
784
|
+
}
|
|
785
|
+
};
|
|
786
|
+
var buildUrl = (options) => getUrl({
|
|
787
|
+
baseUrl: options.baseUrl,
|
|
788
|
+
path: options.path,
|
|
789
|
+
query: options.query,
|
|
790
|
+
querySerializer: typeof options.querySerializer === "function" ? options.querySerializer : createQuerySerializer(options.querySerializer),
|
|
791
|
+
url: options.url
|
|
792
|
+
});
|
|
793
|
+
var mergeConfigs = (a, b) => {
|
|
794
|
+
const config = { ...a, ...b };
|
|
795
|
+
if (config.baseUrl?.endsWith("/")) {
|
|
796
|
+
config.baseUrl = config.baseUrl.substring(0, config.baseUrl.length - 1);
|
|
797
|
+
}
|
|
798
|
+
config.headers = mergeHeaders(a.headers, b.headers);
|
|
799
|
+
return config;
|
|
800
|
+
};
|
|
801
|
+
var headersEntries = (headers) => {
|
|
802
|
+
const entries = [];
|
|
803
|
+
headers.forEach((value, key) => {
|
|
804
|
+
entries.push([key, value]);
|
|
805
|
+
});
|
|
806
|
+
return entries;
|
|
807
|
+
};
|
|
808
|
+
var mergeHeaders = (...headers) => {
|
|
809
|
+
const mergedHeaders = new Headers;
|
|
810
|
+
for (const header of headers) {
|
|
811
|
+
if (!header) {
|
|
812
|
+
continue;
|
|
813
|
+
}
|
|
814
|
+
const iterator = header instanceof Headers ? headersEntries(header) : Object.entries(header);
|
|
815
|
+
for (const [key, value] of iterator) {
|
|
816
|
+
if (value === null) {
|
|
817
|
+
mergedHeaders.delete(key);
|
|
818
|
+
} else if (Array.isArray(value)) {
|
|
819
|
+
for (const v of value) {
|
|
820
|
+
mergedHeaders.append(key, v);
|
|
821
|
+
}
|
|
822
|
+
} else if (value !== undefined) {
|
|
823
|
+
mergedHeaders.set(key, typeof value === "object" ? JSON.stringify(value) : value);
|
|
824
|
+
}
|
|
825
|
+
}
|
|
826
|
+
}
|
|
827
|
+
return mergedHeaders;
|
|
828
|
+
};
|
|
829
|
+
|
|
830
|
+
class Interceptors {
|
|
831
|
+
fns = [];
|
|
832
|
+
clear() {
|
|
833
|
+
this.fns = [];
|
|
834
|
+
}
|
|
835
|
+
eject(id) {
|
|
836
|
+
const index = this.getInterceptorIndex(id);
|
|
837
|
+
if (this.fns[index]) {
|
|
838
|
+
this.fns[index] = null;
|
|
839
|
+
}
|
|
840
|
+
}
|
|
841
|
+
exists(id) {
|
|
842
|
+
const index = this.getInterceptorIndex(id);
|
|
843
|
+
return Boolean(this.fns[index]);
|
|
844
|
+
}
|
|
845
|
+
getInterceptorIndex(id) {
|
|
846
|
+
if (typeof id === "number") {
|
|
847
|
+
return this.fns[id] ? id : -1;
|
|
848
|
+
}
|
|
849
|
+
return this.fns.indexOf(id);
|
|
850
|
+
}
|
|
851
|
+
update(id, fn) {
|
|
852
|
+
const index = this.getInterceptorIndex(id);
|
|
853
|
+
if (this.fns[index]) {
|
|
854
|
+
this.fns[index] = fn;
|
|
855
|
+
return id;
|
|
856
|
+
}
|
|
857
|
+
return false;
|
|
858
|
+
}
|
|
859
|
+
use(fn) {
|
|
860
|
+
this.fns.push(fn);
|
|
861
|
+
return this.fns.length - 1;
|
|
862
|
+
}
|
|
863
|
+
}
|
|
864
|
+
var createInterceptors = () => ({
|
|
865
|
+
error: new Interceptors,
|
|
866
|
+
request: new Interceptors,
|
|
867
|
+
response: new Interceptors
|
|
868
|
+
});
|
|
869
|
+
var defaultQuerySerializer = createQuerySerializer({
|
|
870
|
+
allowReserved: false,
|
|
871
|
+
array: {
|
|
872
|
+
explode: true,
|
|
873
|
+
style: "form"
|
|
874
|
+
},
|
|
875
|
+
object: {
|
|
876
|
+
explode: true,
|
|
877
|
+
style: "deepObject"
|
|
878
|
+
}
|
|
879
|
+
});
|
|
880
|
+
var defaultHeaders = {
|
|
881
|
+
"Content-Type": "application/json"
|
|
882
|
+
};
|
|
883
|
+
var createConfig = (override = {}) => ({
|
|
884
|
+
...jsonBodySerializer,
|
|
885
|
+
headers: defaultHeaders,
|
|
886
|
+
parseAs: "auto",
|
|
887
|
+
querySerializer: defaultQuerySerializer,
|
|
888
|
+
...override
|
|
889
|
+
});
|
|
890
|
+
|
|
891
|
+
// ../sdk/src/v1/gen/client/client.gen.ts
|
|
892
|
+
var createClient = (config = {}) => {
|
|
893
|
+
let _config = mergeConfigs(createConfig(), config);
|
|
894
|
+
const getConfig = () => ({ ..._config });
|
|
895
|
+
const setConfig = (config2) => {
|
|
896
|
+
_config = mergeConfigs(_config, config2);
|
|
897
|
+
return getConfig();
|
|
898
|
+
};
|
|
899
|
+
const interceptors = createInterceptors();
|
|
900
|
+
const beforeRequest = async (options) => {
|
|
901
|
+
const opts = {
|
|
902
|
+
..._config,
|
|
903
|
+
...options,
|
|
904
|
+
fetch: options.fetch ?? _config.fetch ?? globalThis.fetch,
|
|
905
|
+
headers: mergeHeaders(_config.headers, options.headers),
|
|
906
|
+
serializedBody: undefined
|
|
907
|
+
};
|
|
908
|
+
if (opts.security) {
|
|
909
|
+
await setAuthParams({
|
|
910
|
+
...opts,
|
|
911
|
+
security: opts.security
|
|
912
|
+
});
|
|
913
|
+
}
|
|
914
|
+
if (opts.requestValidator) {
|
|
915
|
+
await opts.requestValidator(opts);
|
|
916
|
+
}
|
|
917
|
+
if (opts.body !== undefined && opts.bodySerializer) {
|
|
918
|
+
opts.serializedBody = opts.bodySerializer(opts.body);
|
|
919
|
+
}
|
|
920
|
+
if (opts.body === undefined || opts.serializedBody === "") {
|
|
921
|
+
opts.headers.delete("Content-Type");
|
|
922
|
+
}
|
|
923
|
+
const url = buildUrl(opts);
|
|
924
|
+
return { opts, url };
|
|
925
|
+
};
|
|
926
|
+
const request = async (options) => {
|
|
927
|
+
const { opts, url } = await beforeRequest(options);
|
|
928
|
+
const requestInit = {
|
|
929
|
+
redirect: "follow",
|
|
930
|
+
...opts,
|
|
931
|
+
body: getValidRequestBody(opts)
|
|
932
|
+
};
|
|
933
|
+
let request2 = new Request(url, requestInit);
|
|
934
|
+
for (const fn of interceptors.request.fns) {
|
|
935
|
+
if (fn) {
|
|
936
|
+
request2 = await fn(request2, opts);
|
|
937
|
+
}
|
|
938
|
+
}
|
|
939
|
+
const _fetch = opts.fetch;
|
|
940
|
+
let response;
|
|
941
|
+
try {
|
|
942
|
+
response = await _fetch(request2);
|
|
943
|
+
} catch (error2) {
|
|
944
|
+
let finalError2 = error2;
|
|
945
|
+
for (const fn of interceptors.error.fns) {
|
|
946
|
+
if (fn) {
|
|
947
|
+
finalError2 = await fn(error2, undefined, request2, opts);
|
|
948
|
+
}
|
|
949
|
+
}
|
|
950
|
+
finalError2 = finalError2 || {};
|
|
951
|
+
if (opts.throwOnError) {
|
|
952
|
+
throw finalError2;
|
|
953
|
+
}
|
|
954
|
+
return opts.responseStyle === "data" ? undefined : {
|
|
955
|
+
error: finalError2,
|
|
956
|
+
request: request2,
|
|
957
|
+
response: undefined
|
|
958
|
+
};
|
|
959
|
+
}
|
|
960
|
+
for (const fn of interceptors.response.fns) {
|
|
961
|
+
if (fn) {
|
|
962
|
+
response = await fn(response, request2, opts);
|
|
963
|
+
}
|
|
964
|
+
}
|
|
965
|
+
const result = {
|
|
966
|
+
request: request2,
|
|
967
|
+
response
|
|
968
|
+
};
|
|
969
|
+
if (response.ok) {
|
|
970
|
+
const parseAs = (opts.parseAs === "auto" ? getParseAs(response.headers.get("Content-Type")) : opts.parseAs) ?? "json";
|
|
971
|
+
if (response.status === 204 || response.headers.get("Content-Length") === "0") {
|
|
972
|
+
let emptyData;
|
|
973
|
+
switch (parseAs) {
|
|
974
|
+
case "arrayBuffer":
|
|
975
|
+
case "blob":
|
|
976
|
+
case "text":
|
|
977
|
+
emptyData = await response[parseAs]();
|
|
978
|
+
break;
|
|
979
|
+
case "formData":
|
|
980
|
+
emptyData = new FormData;
|
|
981
|
+
break;
|
|
982
|
+
case "stream":
|
|
983
|
+
emptyData = response.body;
|
|
984
|
+
break;
|
|
985
|
+
case "json":
|
|
986
|
+
default:
|
|
987
|
+
emptyData = {};
|
|
988
|
+
break;
|
|
989
|
+
}
|
|
990
|
+
return opts.responseStyle === "data" ? emptyData : {
|
|
991
|
+
data: emptyData,
|
|
992
|
+
...result
|
|
993
|
+
};
|
|
994
|
+
}
|
|
995
|
+
let data;
|
|
996
|
+
switch (parseAs) {
|
|
997
|
+
case "arrayBuffer":
|
|
998
|
+
case "blob":
|
|
999
|
+
case "formData":
|
|
1000
|
+
case "text":
|
|
1001
|
+
data = await response[parseAs]();
|
|
1002
|
+
break;
|
|
1003
|
+
case "json": {
|
|
1004
|
+
const text = await response.text();
|
|
1005
|
+
data = text ? JSON.parse(text) : {};
|
|
1006
|
+
break;
|
|
1007
|
+
}
|
|
1008
|
+
case "stream":
|
|
1009
|
+
return opts.responseStyle === "data" ? response.body : {
|
|
1010
|
+
data: response.body,
|
|
1011
|
+
...result
|
|
1012
|
+
};
|
|
1013
|
+
}
|
|
1014
|
+
if (parseAs === "json") {
|
|
1015
|
+
if (opts.responseValidator) {
|
|
1016
|
+
await opts.responseValidator(data);
|
|
1017
|
+
}
|
|
1018
|
+
if (opts.responseTransformer) {
|
|
1019
|
+
data = await opts.responseTransformer(data);
|
|
1020
|
+
}
|
|
1021
|
+
}
|
|
1022
|
+
return opts.responseStyle === "data" ? data : {
|
|
1023
|
+
data,
|
|
1024
|
+
...result
|
|
1025
|
+
};
|
|
1026
|
+
}
|
|
1027
|
+
const textError = await response.text();
|
|
1028
|
+
let jsonError;
|
|
1029
|
+
try {
|
|
1030
|
+
jsonError = JSON.parse(textError);
|
|
1031
|
+
} catch {}
|
|
1032
|
+
const error = jsonError ?? textError;
|
|
1033
|
+
let finalError = error;
|
|
1034
|
+
for (const fn of interceptors.error.fns) {
|
|
1035
|
+
if (fn) {
|
|
1036
|
+
finalError = await fn(error, response, request2, opts);
|
|
1037
|
+
}
|
|
1038
|
+
}
|
|
1039
|
+
finalError = finalError || {};
|
|
1040
|
+
if (opts.throwOnError) {
|
|
1041
|
+
throw finalError;
|
|
1042
|
+
}
|
|
1043
|
+
return opts.responseStyle === "data" ? undefined : {
|
|
1044
|
+
error: finalError,
|
|
1045
|
+
...result
|
|
1046
|
+
};
|
|
1047
|
+
};
|
|
1048
|
+
const makeMethodFn = (method) => (options) => request({ ...options, method });
|
|
1049
|
+
const makeSseFn = (method) => async (options) => {
|
|
1050
|
+
const { opts, url } = await beforeRequest(options);
|
|
1051
|
+
return createSseClient({
|
|
1052
|
+
...opts,
|
|
1053
|
+
body: opts.body,
|
|
1054
|
+
headers: opts.headers,
|
|
1055
|
+
method,
|
|
1056
|
+
onRequest: async (url2, init) => {
|
|
1057
|
+
let request2 = new Request(url2, init);
|
|
1058
|
+
for (const fn of interceptors.request.fns) {
|
|
1059
|
+
if (fn) {
|
|
1060
|
+
request2 = await fn(request2, opts);
|
|
1061
|
+
}
|
|
1062
|
+
}
|
|
1063
|
+
return request2;
|
|
1064
|
+
},
|
|
1065
|
+
serializedBody: getValidRequestBody(opts),
|
|
1066
|
+
url
|
|
1067
|
+
});
|
|
1068
|
+
};
|
|
1069
|
+
return {
|
|
1070
|
+
buildUrl,
|
|
1071
|
+
connect: makeMethodFn("CONNECT"),
|
|
1072
|
+
delete: makeMethodFn("DELETE"),
|
|
1073
|
+
get: makeMethodFn("GET"),
|
|
1074
|
+
getConfig,
|
|
1075
|
+
head: makeMethodFn("HEAD"),
|
|
1076
|
+
interceptors,
|
|
1077
|
+
options: makeMethodFn("OPTIONS"),
|
|
1078
|
+
patch: makeMethodFn("PATCH"),
|
|
1079
|
+
post: makeMethodFn("POST"),
|
|
1080
|
+
put: makeMethodFn("PUT"),
|
|
1081
|
+
request,
|
|
1082
|
+
setConfig,
|
|
1083
|
+
sse: {
|
|
1084
|
+
connect: makeSseFn("CONNECT"),
|
|
1085
|
+
delete: makeSseFn("DELETE"),
|
|
1086
|
+
get: makeSseFn("GET"),
|
|
1087
|
+
head: makeSseFn("HEAD"),
|
|
1088
|
+
options: makeSseFn("OPTIONS"),
|
|
1089
|
+
patch: makeSseFn("PATCH"),
|
|
1090
|
+
post: makeSseFn("POST"),
|
|
1091
|
+
put: makeSseFn("PUT"),
|
|
1092
|
+
trace: makeSseFn("TRACE")
|
|
1093
|
+
},
|
|
1094
|
+
trace: makeMethodFn("TRACE")
|
|
1095
|
+
};
|
|
1096
|
+
};
|
|
1097
|
+
// ../sdk/src/v1/gen/client.gen.ts
|
|
1098
|
+
var client = createClient(createConfig());
|
|
1099
|
+
|
|
1100
|
+
// ../sdk/src/v1/gen/sdk.gen.ts
|
|
1101
|
+
class HeyApiClient {
|
|
1102
|
+
client;
|
|
1103
|
+
constructor(args) {
|
|
1104
|
+
this.client = args?.client ?? client;
|
|
1105
|
+
}
|
|
1106
|
+
}
|
|
1107
|
+
|
|
1108
|
+
class HeyApiRegistry {
|
|
1109
|
+
defaultKey = "default";
|
|
1110
|
+
instances = new Map;
|
|
1111
|
+
get(key) {
|
|
1112
|
+
const instance = this.instances.get(key ?? this.defaultKey);
|
|
1113
|
+
if (!instance) {
|
|
1114
|
+
throw new Error(`No SDK client found. Create one with "new HighlightClient()" to fix this error.`);
|
|
1115
|
+
}
|
|
1116
|
+
return instance;
|
|
1117
|
+
}
|
|
1118
|
+
set(value, key) {
|
|
1119
|
+
this.instances.set(key ?? this.defaultKey, value);
|
|
1120
|
+
}
|
|
1121
|
+
}
|
|
1122
|
+
|
|
1123
|
+
class Collection extends HeyApiClient {
|
|
1124
|
+
list(parameters, options) {
|
|
1125
|
+
const params = buildClientParams([parameters], [
|
|
1126
|
+
{
|
|
1127
|
+
args: [
|
|
1128
|
+
{ in: "query", key: "page" },
|
|
1129
|
+
{ in: "query", key: "limit" },
|
|
1130
|
+
{ in: "query", key: "sortBy" },
|
|
1131
|
+
{ in: "query", key: "sortDirection" },
|
|
1132
|
+
{ in: "query", key: "status" },
|
|
1133
|
+
{ in: "query", key: "blockchains" },
|
|
1134
|
+
{ in: "query", key: "testnet" },
|
|
1135
|
+
{ in: "query", key: "types" }
|
|
1136
|
+
]
|
|
1137
|
+
}
|
|
1138
|
+
]);
|
|
1139
|
+
return (options?.client ?? this.client).get({
|
|
1140
|
+
url: "/collection",
|
|
1141
|
+
...options,
|
|
1142
|
+
...params
|
|
1143
|
+
});
|
|
1144
|
+
}
|
|
1145
|
+
create(parameters, options) {
|
|
1146
|
+
const params = buildClientParams([parameters], [
|
|
1147
|
+
{
|
|
1148
|
+
args: [
|
|
1149
|
+
{ in: "body", key: "name" },
|
|
1150
|
+
{ in: "body", key: "description" },
|
|
1151
|
+
{ in: "body", key: "contractId" },
|
|
1152
|
+
{ in: "body", key: "contract" },
|
|
1153
|
+
{ in: "body", key: "logoMediaId" },
|
|
1154
|
+
{ in: "body", key: "image" },
|
|
1155
|
+
{ in: "body", key: "type" },
|
|
1156
|
+
{ in: "body", key: "royalty" },
|
|
1157
|
+
{ in: "body", key: "tokenManager" }
|
|
1158
|
+
]
|
|
1159
|
+
}
|
|
1160
|
+
]);
|
|
1161
|
+
return (options?.client ?? this.client).post({
|
|
1162
|
+
url: "/collection",
|
|
1163
|
+
...options,
|
|
1164
|
+
...params,
|
|
1165
|
+
headers: {
|
|
1166
|
+
"Content-Type": "application/json",
|
|
1167
|
+
...options?.headers,
|
|
1168
|
+
...params.headers
|
|
1169
|
+
}
|
|
1170
|
+
});
|
|
1171
|
+
}
|
|
1172
|
+
trending(parameters, options) {
|
|
1173
|
+
const params = buildClientParams([parameters], [
|
|
1174
|
+
{
|
|
1175
|
+
args: [
|
|
1176
|
+
{ in: "query", key: "window" },
|
|
1177
|
+
{ in: "query", key: "chainId" },
|
|
1178
|
+
{ in: "query", key: "limit" }
|
|
1179
|
+
]
|
|
1180
|
+
}
|
|
1181
|
+
]);
|
|
1182
|
+
return (options?.client ?? this.client).get({
|
|
1183
|
+
url: "/collection/trending",
|
|
1184
|
+
...options,
|
|
1185
|
+
...params
|
|
1186
|
+
});
|
|
1187
|
+
}
|
|
1188
|
+
featured(parameters, options) {
|
|
1189
|
+
const params = buildClientParams([parameters], [
|
|
1190
|
+
{
|
|
1191
|
+
args: [
|
|
1192
|
+
{ in: "query", key: "limit" },
|
|
1193
|
+
{ in: "query", key: "cursor" }
|
|
1194
|
+
]
|
|
1195
|
+
}
|
|
1196
|
+
]);
|
|
1197
|
+
return (options?.client ?? this.client).get({
|
|
1198
|
+
url: "/collection/featured",
|
|
1199
|
+
...options,
|
|
1200
|
+
...params
|
|
1201
|
+
});
|
|
1202
|
+
}
|
|
1203
|
+
get(parameters, options) {
|
|
1204
|
+
const params = buildClientParams([parameters], [{ args: [{ in: "path", key: "highlightId" }] }]);
|
|
1205
|
+
return (options?.client ?? this.client).get({
|
|
1206
|
+
url: "/collection/{highlightId}",
|
|
1207
|
+
...options,
|
|
1208
|
+
...params
|
|
1209
|
+
});
|
|
1210
|
+
}
|
|
1211
|
+
listPreviews(parameters, options) {
|
|
1212
|
+
const params = buildClientParams([parameters], [
|
|
1213
|
+
{
|
|
1214
|
+
args: [
|
|
1215
|
+
{ in: "path", key: "highlightId" },
|
|
1216
|
+
{ in: "query", key: "limit" }
|
|
1217
|
+
]
|
|
1218
|
+
}
|
|
1219
|
+
]);
|
|
1220
|
+
return (options?.client ?? this.client).get({
|
|
1221
|
+
url: "/collection/{highlightId}/previews",
|
|
1222
|
+
...options,
|
|
1223
|
+
...params
|
|
1224
|
+
});
|
|
1225
|
+
}
|
|
1226
|
+
finalizeBaseUri(parameters, options) {
|
|
1227
|
+
const params = buildClientParams([parameters], [{ args: [{ in: "path", key: "highlightId" }] }]);
|
|
1228
|
+
return (options?.client ?? this.client).post({
|
|
1229
|
+
url: "/collection/{highlightId}/finalize-base-uri",
|
|
1230
|
+
...options,
|
|
1231
|
+
...params
|
|
1232
|
+
});
|
|
1233
|
+
}
|
|
1234
|
+
updateGenerativeDetails(parameters, options) {
|
|
1235
|
+
const params = buildClientParams([parameters], [
|
|
1236
|
+
{
|
|
1237
|
+
args: [
|
|
1238
|
+
{ in: "path", key: "highlightId" },
|
|
1239
|
+
{ in: "body", key: "generative" }
|
|
1240
|
+
]
|
|
1241
|
+
}
|
|
1242
|
+
]);
|
|
1243
|
+
return (options?.client ?? this.client).patch({
|
|
1244
|
+
url: "/collection/{highlightId}/details/generative",
|
|
1245
|
+
...options,
|
|
1246
|
+
...params,
|
|
1247
|
+
headers: {
|
|
1248
|
+
"Content-Type": "application/json",
|
|
1249
|
+
...options?.headers,
|
|
1250
|
+
...params.headers
|
|
1251
|
+
}
|
|
1252
|
+
});
|
|
1253
|
+
}
|
|
1254
|
+
updateSeriesDetails(parameters, options) {
|
|
1255
|
+
const params = buildClientParams([parameters], [
|
|
1256
|
+
{
|
|
1257
|
+
args: [
|
|
1258
|
+
{ in: "path", key: "highlightId" },
|
|
1259
|
+
{ in: "body", key: "series" }
|
|
1260
|
+
]
|
|
1261
|
+
}
|
|
1262
|
+
]);
|
|
1263
|
+
return (options?.client ?? this.client).patch({
|
|
1264
|
+
url: "/collection/{highlightId}/details/series",
|
|
1265
|
+
...options,
|
|
1266
|
+
...params,
|
|
1267
|
+
headers: {
|
|
1268
|
+
"Content-Type": "application/json",
|
|
1269
|
+
...options?.headers,
|
|
1270
|
+
...params.headers
|
|
1271
|
+
}
|
|
1272
|
+
});
|
|
1273
|
+
}
|
|
1274
|
+
updateEditionDetails(parameters, options) {
|
|
1275
|
+
const params = buildClientParams([parameters], [
|
|
1276
|
+
{
|
|
1277
|
+
args: [
|
|
1278
|
+
{ in: "path", key: "highlightId" },
|
|
1279
|
+
{ in: "body", key: "edition" }
|
|
1280
|
+
]
|
|
1281
|
+
}
|
|
1282
|
+
]);
|
|
1283
|
+
return (options?.client ?? this.client).patch({
|
|
1284
|
+
url: "/collection/{highlightId}/details/edition",
|
|
1285
|
+
...options,
|
|
1286
|
+
...params,
|
|
1287
|
+
headers: {
|
|
1288
|
+
"Content-Type": "application/json",
|
|
1289
|
+
...options?.headers,
|
|
1290
|
+
...params.headers
|
|
1291
|
+
}
|
|
1292
|
+
});
|
|
1293
|
+
}
|
|
1294
|
+
getSales(parameters, options) {
|
|
1295
|
+
const params = buildClientParams([parameters], [{ args: [{ in: "path", key: "highlightId" }] }]);
|
|
1296
|
+
return (options?.client ?? this.client).get({
|
|
1297
|
+
url: "/collection/{highlightId}/sales",
|
|
1298
|
+
...options,
|
|
1299
|
+
...params
|
|
1300
|
+
});
|
|
1301
|
+
}
|
|
1302
|
+
addSale(parameters, options) {
|
|
1303
|
+
const params = buildClientParams([parameters], [
|
|
1304
|
+
{
|
|
1305
|
+
args: [
|
|
1306
|
+
{ in: "path", key: "highlightId" },
|
|
1307
|
+
{ in: "body", key: "name" },
|
|
1308
|
+
{ in: "body", key: "type" },
|
|
1309
|
+
{ in: "body", key: "startAt" },
|
|
1310
|
+
{ in: "body", key: "endAt" },
|
|
1311
|
+
{ in: "body", key: "price" },
|
|
1312
|
+
{ in: "body", key: "currency" },
|
|
1313
|
+
{ in: "body", key: "maxPerTransaction" },
|
|
1314
|
+
{ in: "body", key: "maxPerWallet" },
|
|
1315
|
+
{ in: "body", key: "maxTotal" },
|
|
1316
|
+
{ in: "body", key: "paymentRecipient" },
|
|
1317
|
+
{ in: "body", key: "accessMode" },
|
|
1318
|
+
{ in: "body", key: "gateId" },
|
|
1319
|
+
{ in: "body", key: "gasSponsored" },
|
|
1320
|
+
{ in: "body", key: "mechanicId" },
|
|
1321
|
+
{ in: "body", key: "typeConfig" },
|
|
1322
|
+
{ in: "body", key: "collectorMessage" },
|
|
1323
|
+
{ in: "body", key: "customMintFee" }
|
|
1324
|
+
]
|
|
1325
|
+
}
|
|
1326
|
+
]);
|
|
1327
|
+
return (options?.client ?? this.client).post({
|
|
1328
|
+
url: "/collection/{highlightId}/sales",
|
|
1329
|
+
...options,
|
|
1330
|
+
...params,
|
|
1331
|
+
headers: {
|
|
1332
|
+
"Content-Type": "application/json",
|
|
1333
|
+
...options?.headers,
|
|
1334
|
+
...params.headers
|
|
1335
|
+
}
|
|
1336
|
+
});
|
|
1337
|
+
}
|
|
1338
|
+
deleteSale(parameters, options) {
|
|
1339
|
+
const params = buildClientParams([parameters], [
|
|
1340
|
+
{
|
|
1341
|
+
args: [
|
|
1342
|
+
{ in: "path", key: "highlightId" },
|
|
1343
|
+
{ in: "path", key: "saleId" }
|
|
1344
|
+
]
|
|
1345
|
+
}
|
|
1346
|
+
]);
|
|
1347
|
+
return (options?.client ?? this.client).delete({
|
|
1348
|
+
url: "/collection/{highlightId}/sales/{saleId}",
|
|
1349
|
+
...options,
|
|
1350
|
+
...params
|
|
1351
|
+
});
|
|
1352
|
+
}
|
|
1353
|
+
updateSale(parameters, options) {
|
|
1354
|
+
const params = buildClientParams([parameters], [
|
|
1355
|
+
{
|
|
1356
|
+
args: [
|
|
1357
|
+
{ in: "path", key: "highlightId" },
|
|
1358
|
+
{ in: "path", key: "saleId" },
|
|
1359
|
+
{ in: "body", key: "name" },
|
|
1360
|
+
{ in: "body", key: "startAt" },
|
|
1361
|
+
{ in: "body", key: "endAt" },
|
|
1362
|
+
{ in: "body", key: "price" },
|
|
1363
|
+
{ in: "body", key: "currency" },
|
|
1364
|
+
{ in: "body", key: "maxPerTransaction" },
|
|
1365
|
+
{ in: "body", key: "maxPerWallet" },
|
|
1366
|
+
{ in: "body", key: "maxTotal" },
|
|
1367
|
+
{ in: "body", key: "paymentRecipient" },
|
|
1368
|
+
{ in: "body", key: "paused" },
|
|
1369
|
+
{ in: "body", key: "collectorMessage" },
|
|
1370
|
+
{ in: "body", key: "customMintFee" }
|
|
1371
|
+
]
|
|
1372
|
+
}
|
|
1373
|
+
]);
|
|
1374
|
+
return (options?.client ?? this.client).patch({
|
|
1375
|
+
url: "/collection/{highlightId}/sales/{saleId}",
|
|
1376
|
+
...options,
|
|
1377
|
+
...params,
|
|
1378
|
+
headers: {
|
|
1379
|
+
"Content-Type": "application/json",
|
|
1380
|
+
...options?.headers,
|
|
1381
|
+
...params.headers
|
|
1382
|
+
}
|
|
1383
|
+
});
|
|
1384
|
+
}
|
|
1385
|
+
claimSale(parameters, options) {
|
|
1386
|
+
const params = buildClientParams([parameters], [
|
|
1387
|
+
{
|
|
1388
|
+
args: [
|
|
1389
|
+
{ in: "path", key: "highlightId" },
|
|
1390
|
+
{ in: "body", key: "saleId" },
|
|
1391
|
+
{ in: "body", key: "amount" },
|
|
1392
|
+
{ in: "body", key: "tokenIds" }
|
|
1393
|
+
]
|
|
1394
|
+
}
|
|
1395
|
+
]);
|
|
1396
|
+
return (options?.client ?? this.client).post({
|
|
1397
|
+
url: "/collection/{highlightId}/sales/claim",
|
|
1398
|
+
...options,
|
|
1399
|
+
...params,
|
|
1400
|
+
headers: {
|
|
1401
|
+
"Content-Type": "application/json",
|
|
1402
|
+
...options?.headers,
|
|
1403
|
+
...params.headers
|
|
1404
|
+
}
|
|
1405
|
+
});
|
|
1406
|
+
}
|
|
1407
|
+
bidSale(parameters, options) {
|
|
1408
|
+
const params = buildClientParams([parameters], [
|
|
1409
|
+
{
|
|
1410
|
+
args: [
|
|
1411
|
+
{ in: "path", key: "highlightId" },
|
|
1412
|
+
{ in: "body", key: "saleId" },
|
|
1413
|
+
{ in: "body", key: "bidAmount" },
|
|
1414
|
+
{ in: "body", key: "bidId" },
|
|
1415
|
+
{ in: "body", key: "preferredNftRecipient" }
|
|
1416
|
+
]
|
|
1417
|
+
}
|
|
1418
|
+
]);
|
|
1419
|
+
return (options?.client ?? this.client).post({
|
|
1420
|
+
url: "/collection/{highlightId}/sales/bid",
|
|
1421
|
+
...options,
|
|
1422
|
+
...params,
|
|
1423
|
+
headers: {
|
|
1424
|
+
"Content-Type": "application/json",
|
|
1425
|
+
...options?.headers,
|
|
1426
|
+
...params.headers
|
|
1427
|
+
}
|
|
1428
|
+
});
|
|
1429
|
+
}
|
|
1430
|
+
reclaimBid(parameters, options) {
|
|
1431
|
+
const params = buildClientParams([parameters], [
|
|
1432
|
+
{
|
|
1433
|
+
args: [
|
|
1434
|
+
{ in: "path", key: "highlightId" },
|
|
1435
|
+
{ in: "body", key: "saleId" },
|
|
1436
|
+
{ in: "body", key: "bidId" }
|
|
1437
|
+
]
|
|
1438
|
+
}
|
|
1439
|
+
]);
|
|
1440
|
+
return (options?.client ?? this.client).post({
|
|
1441
|
+
url: "/collection/{highlightId}/sales/reclaim",
|
|
1442
|
+
...options,
|
|
1443
|
+
...params,
|
|
1444
|
+
headers: {
|
|
1445
|
+
"Content-Type": "application/json",
|
|
1446
|
+
...options?.headers,
|
|
1447
|
+
...params.headers
|
|
1448
|
+
}
|
|
1449
|
+
});
|
|
1450
|
+
}
|
|
1451
|
+
claimAuctionEarnings(parameters, options) {
|
|
1452
|
+
const params = buildClientParams([parameters], [
|
|
1453
|
+
{
|
|
1454
|
+
args: [
|
|
1455
|
+
{ in: "path", key: "highlightId" },
|
|
1456
|
+
{ in: "body", key: "saleId" }
|
|
1457
|
+
]
|
|
1458
|
+
}
|
|
1459
|
+
]);
|
|
1460
|
+
return (options?.client ?? this.client).post({
|
|
1461
|
+
url: "/collection/{highlightId}/sales/earnings",
|
|
1462
|
+
...options,
|
|
1463
|
+
...params,
|
|
1464
|
+
headers: {
|
|
1465
|
+
"Content-Type": "application/json",
|
|
1466
|
+
...options?.headers,
|
|
1467
|
+
...params.headers
|
|
1468
|
+
}
|
|
1469
|
+
});
|
|
1470
|
+
}
|
|
1471
|
+
rankedAuctionStandings(parameters, options) {
|
|
1472
|
+
const params = buildClientParams([parameters], [
|
|
1473
|
+
{
|
|
1474
|
+
args: [
|
|
1475
|
+
{ in: "path", key: "highlightId" },
|
|
1476
|
+
{ in: "path", key: "saleId" }
|
|
1477
|
+
]
|
|
1478
|
+
}
|
|
1479
|
+
]);
|
|
1480
|
+
return (options?.client ?? this.client).get({
|
|
1481
|
+
url: "/collection/{highlightId}/sales/{saleId}/standings",
|
|
1482
|
+
...options,
|
|
1483
|
+
...params
|
|
1484
|
+
});
|
|
1485
|
+
}
|
|
1486
|
+
fulfillEnglishAuction(parameters, options) {
|
|
1487
|
+
const params = buildClientParams([parameters], [
|
|
1488
|
+
{
|
|
1489
|
+
args: [
|
|
1490
|
+
{ in: "path", key: "highlightId" },
|
|
1491
|
+
{ in: "body", key: "saleId" }
|
|
1492
|
+
]
|
|
1493
|
+
}
|
|
1494
|
+
]);
|
|
1495
|
+
return (options?.client ?? this.client).post({
|
|
1496
|
+
url: "/collection/{highlightId}/sales/auction/fulfill",
|
|
1497
|
+
...options,
|
|
1498
|
+
...params,
|
|
1499
|
+
headers: {
|
|
1500
|
+
"Content-Type": "application/json",
|
|
1501
|
+
...options?.headers,
|
|
1502
|
+
...params.headers
|
|
1503
|
+
}
|
|
1504
|
+
});
|
|
1505
|
+
}
|
|
1506
|
+
cancelEnglishAuction(parameters, options) {
|
|
1507
|
+
const params = buildClientParams([parameters], [
|
|
1508
|
+
{
|
|
1509
|
+
args: [
|
|
1510
|
+
{ in: "path", key: "highlightId" },
|
|
1511
|
+
{ in: "body", key: "saleId" }
|
|
1512
|
+
]
|
|
1513
|
+
}
|
|
1514
|
+
]);
|
|
1515
|
+
return (options?.client ?? this.client).post({
|
|
1516
|
+
url: "/collection/{highlightId}/sales/auction/cancel",
|
|
1517
|
+
...options,
|
|
1518
|
+
...params,
|
|
1519
|
+
headers: {
|
|
1520
|
+
"Content-Type": "application/json",
|
|
1521
|
+
...options?.headers,
|
|
1522
|
+
...params.headers
|
|
1523
|
+
}
|
|
1524
|
+
});
|
|
1525
|
+
}
|
|
1526
|
+
englishAuctionStanding(parameters, options) {
|
|
1527
|
+
const params = buildClientParams([parameters], [
|
|
1528
|
+
{
|
|
1529
|
+
args: [
|
|
1530
|
+
{ in: "path", key: "highlightId" },
|
|
1531
|
+
{ in: "path", key: "saleId" }
|
|
1532
|
+
]
|
|
1533
|
+
}
|
|
1534
|
+
]);
|
|
1535
|
+
return (options?.client ?? this.client).get({
|
|
1536
|
+
url: "/collection/{highlightId}/sales/{saleId}/auction",
|
|
1537
|
+
...options,
|
|
1538
|
+
...params
|
|
1539
|
+
});
|
|
1540
|
+
}
|
|
1541
|
+
englishAuctionBids(parameters, options) {
|
|
1542
|
+
const params = buildClientParams([parameters], [
|
|
1543
|
+
{
|
|
1544
|
+
args: [
|
|
1545
|
+
{ in: "path", key: "highlightId" },
|
|
1546
|
+
{ in: "path", key: "saleId" }
|
|
1547
|
+
]
|
|
1548
|
+
}
|
|
1549
|
+
]);
|
|
1550
|
+
return (options?.client ?? this.client).get({
|
|
1551
|
+
url: "/collection/{highlightId}/sales/{saleId}/auction/bids",
|
|
1552
|
+
...options,
|
|
1553
|
+
...params
|
|
1554
|
+
});
|
|
1555
|
+
}
|
|
1556
|
+
deploy(parameters, options) {
|
|
1557
|
+
const params = buildClientParams([parameters], [{ args: [{ in: "path", key: "highlightId" }] }]);
|
|
1558
|
+
return (options?.client ?? this.client).post({
|
|
1559
|
+
url: "/collection/{highlightId}/deploy",
|
|
1560
|
+
...options,
|
|
1561
|
+
...params
|
|
1562
|
+
});
|
|
1563
|
+
}
|
|
1564
|
+
deployStatus(parameters, options) {
|
|
1565
|
+
const params = buildClientParams([parameters], [{ args: [{ in: "path", key: "highlightId" }] }]);
|
|
1566
|
+
return (options?.client ?? this.client).get({
|
|
1567
|
+
url: "/collection/{highlightId}/deploy/status",
|
|
1568
|
+
...options,
|
|
1569
|
+
...params
|
|
1570
|
+
});
|
|
1571
|
+
}
|
|
1572
|
+
deployCancel(parameters, options) {
|
|
1573
|
+
const params = buildClientParams([parameters], [{ args: [{ in: "path", key: "highlightId" }] }]);
|
|
1574
|
+
return (options?.client ?? this.client).post({
|
|
1575
|
+
url: "/collection/{highlightId}/deploy/cancel",
|
|
1576
|
+
...options,
|
|
1577
|
+
...params
|
|
1578
|
+
});
|
|
1579
|
+
}
|
|
1580
|
+
}
|
|
1581
|
+
|
|
1582
|
+
class Token extends HeyApiClient {
|
|
1583
|
+
list(parameters, options) {
|
|
1584
|
+
const params = buildClientParams([parameters], [
|
|
1585
|
+
{
|
|
1586
|
+
args: [
|
|
1587
|
+
{ in: "path", key: "highlightId" },
|
|
1588
|
+
{ in: "query", key: "page" },
|
|
1589
|
+
{ in: "query", key: "limit" },
|
|
1590
|
+
{ in: "query", key: "sort" },
|
|
1591
|
+
{ in: "query", key: "order" },
|
|
1592
|
+
{ in: "query", key: "ownerAddress" },
|
|
1593
|
+
{ in: "query", key: "search" },
|
|
1594
|
+
{ in: "query", key: "attributes" }
|
|
1595
|
+
]
|
|
1596
|
+
}
|
|
1597
|
+
]);
|
|
1598
|
+
return (options?.client ?? this.client).get({
|
|
1599
|
+
url: "/collection/{highlightId}/tokens",
|
|
1600
|
+
...options,
|
|
1601
|
+
...params
|
|
1602
|
+
});
|
|
1603
|
+
}
|
|
1604
|
+
attributeFacets(parameters, options) {
|
|
1605
|
+
const params = buildClientParams([parameters], [{ args: [{ in: "path", key: "highlightId" }] }]);
|
|
1606
|
+
return (options?.client ?? this.client).get({
|
|
1607
|
+
url: "/collection/{highlightId}/tokens/attributes",
|
|
1608
|
+
...options,
|
|
1609
|
+
...params
|
|
1610
|
+
});
|
|
1611
|
+
}
|
|
1612
|
+
get(parameters, options) {
|
|
1613
|
+
const params = buildClientParams([parameters], [
|
|
1614
|
+
{
|
|
1615
|
+
args: [
|
|
1616
|
+
{ in: "path", key: "highlightId" },
|
|
1617
|
+
{ in: "path", key: "tokenId" }
|
|
1618
|
+
]
|
|
1619
|
+
}
|
|
1620
|
+
]);
|
|
1621
|
+
return (options?.client ?? this.client).get({
|
|
1622
|
+
url: "/collection/{highlightId}/tokens/{tokenId}",
|
|
1623
|
+
...options,
|
|
1624
|
+
...params
|
|
1625
|
+
});
|
|
1626
|
+
}
|
|
1627
|
+
listOwners(parameters, options) {
|
|
1628
|
+
const params = buildClientParams([parameters], [
|
|
1629
|
+
{
|
|
1630
|
+
args: [
|
|
1631
|
+
{ in: "path", key: "highlightId" },
|
|
1632
|
+
{ in: "path", key: "tokenId" }
|
|
1633
|
+
]
|
|
1634
|
+
}
|
|
1635
|
+
]);
|
|
1636
|
+
return (options?.client ?? this.client).get({
|
|
1637
|
+
url: "/collection/{highlightId}/tokens/{tokenId}/owners",
|
|
1638
|
+
...options,
|
|
1639
|
+
...params
|
|
1640
|
+
});
|
|
1641
|
+
}
|
|
1642
|
+
redriveReveals(parameters, options) {
|
|
1643
|
+
const params = buildClientParams([parameters], [{ args: [{ in: "path", key: "highlightId" }] }]);
|
|
1644
|
+
return (options?.client ?? this.client).post({
|
|
1645
|
+
url: "/collection/{highlightId}/tokens/redrive-reveals",
|
|
1646
|
+
...options,
|
|
1647
|
+
...params
|
|
1648
|
+
});
|
|
1649
|
+
}
|
|
1650
|
+
}
|
|
1651
|
+
|
|
1652
|
+
class Config extends HeyApiClient {
|
|
1653
|
+
chains(options) {
|
|
1654
|
+
return (options?.client ?? this.client).get({
|
|
1655
|
+
url: "/config/chains",
|
|
1656
|
+
...options
|
|
1657
|
+
});
|
|
1658
|
+
}
|
|
1659
|
+
systemContract(parameters, options) {
|
|
1660
|
+
const params = buildClientParams([parameters], [
|
|
1661
|
+
{
|
|
1662
|
+
args: [
|
|
1663
|
+
{ in: "query", key: "chainId" },
|
|
1664
|
+
{ in: "query", key: "type" }
|
|
1665
|
+
]
|
|
1666
|
+
}
|
|
1667
|
+
]);
|
|
1668
|
+
return (options?.client ?? this.client).get({
|
|
1669
|
+
url: "/config/system-contract",
|
|
1670
|
+
...options,
|
|
1671
|
+
...params
|
|
1672
|
+
});
|
|
1673
|
+
}
|
|
1674
|
+
}
|
|
1675
|
+
|
|
1676
|
+
class Contract extends HeyApiClient {
|
|
1677
|
+
list(parameters, options) {
|
|
1678
|
+
const params = buildClientParams([parameters], [
|
|
1679
|
+
{
|
|
1680
|
+
args: [
|
|
1681
|
+
{ in: "query", key: "limit" },
|
|
1682
|
+
{ in: "query", key: "cursor" }
|
|
1683
|
+
]
|
|
1684
|
+
}
|
|
1685
|
+
]);
|
|
1686
|
+
return (options?.client ?? this.client).get({
|
|
1687
|
+
url: "/contract",
|
|
1688
|
+
...options,
|
|
1689
|
+
...params
|
|
1690
|
+
});
|
|
1691
|
+
}
|
|
1692
|
+
get(parameters, options) {
|
|
1693
|
+
const params = buildClientParams([parameters], [{ args: [{ in: "path", key: "contractId" }] }]);
|
|
1694
|
+
return (options?.client ?? this.client).get({
|
|
1695
|
+
url: "/contract/{contractId}",
|
|
1696
|
+
...options,
|
|
1697
|
+
...params
|
|
1698
|
+
});
|
|
1699
|
+
}
|
|
1700
|
+
}
|
|
1701
|
+
|
|
1702
|
+
class Gate extends HeyApiClient {
|
|
1703
|
+
list(options) {
|
|
1704
|
+
return (options?.client ?? this.client).get({
|
|
1705
|
+
url: "/gate",
|
|
1706
|
+
...options
|
|
1707
|
+
});
|
|
1708
|
+
}
|
|
1709
|
+
create(parameters, options) {
|
|
1710
|
+
const params = buildClientParams([parameters], [
|
|
1711
|
+
{
|
|
1712
|
+
args: [
|
|
1713
|
+
{ in: "body", key: "name" },
|
|
1714
|
+
{ in: "body", key: "matchMode" },
|
|
1715
|
+
{ in: "body", key: "conditions" }
|
|
1716
|
+
]
|
|
1717
|
+
}
|
|
1718
|
+
]);
|
|
1719
|
+
return (options?.client ?? this.client).post({
|
|
1720
|
+
url: "/gate",
|
|
1721
|
+
...options,
|
|
1722
|
+
...params,
|
|
1723
|
+
headers: {
|
|
1724
|
+
"Content-Type": "application/json",
|
|
1725
|
+
...options?.headers,
|
|
1726
|
+
...params.headers
|
|
1727
|
+
}
|
|
1728
|
+
});
|
|
1729
|
+
}
|
|
1730
|
+
remove(parameters, options) {
|
|
1731
|
+
const params = buildClientParams([parameters], [{ args: [{ in: "path", key: "gateId" }] }]);
|
|
1732
|
+
return (options?.client ?? this.client).delete({
|
|
1733
|
+
url: "/gate/{gateId}",
|
|
1734
|
+
...options,
|
|
1735
|
+
...params
|
|
1736
|
+
});
|
|
1737
|
+
}
|
|
1738
|
+
get(parameters, options) {
|
|
1739
|
+
const params = buildClientParams([parameters], [{ args: [{ in: "path", key: "gateId" }] }]);
|
|
1740
|
+
return (options?.client ?? this.client).get({
|
|
1741
|
+
url: "/gate/{gateId}",
|
|
1742
|
+
...options,
|
|
1743
|
+
...params
|
|
1744
|
+
});
|
|
1745
|
+
}
|
|
1746
|
+
update(parameters, options) {
|
|
1747
|
+
const params = buildClientParams([parameters], [
|
|
1748
|
+
{
|
|
1749
|
+
args: [
|
|
1750
|
+
{ in: "path", key: "gateId" },
|
|
1751
|
+
{ in: "body", key: "name" },
|
|
1752
|
+
{ in: "body", key: "matchMode" },
|
|
1753
|
+
{ in: "body", key: "conditions" }
|
|
1754
|
+
]
|
|
1755
|
+
}
|
|
1756
|
+
]);
|
|
1757
|
+
return (options?.client ?? this.client).patch({
|
|
1758
|
+
url: "/gate/{gateId}",
|
|
1759
|
+
...options,
|
|
1760
|
+
...params,
|
|
1761
|
+
headers: {
|
|
1762
|
+
"Content-Type": "application/json",
|
|
1763
|
+
...options?.headers,
|
|
1764
|
+
...params.headers
|
|
1765
|
+
}
|
|
1766
|
+
});
|
|
1767
|
+
}
|
|
1768
|
+
previewCollection(parameters, options) {
|
|
1769
|
+
const params = buildClientParams([parameters], [
|
|
1770
|
+
{
|
|
1771
|
+
args: [
|
|
1772
|
+
{ in: "path", key: "chainId" },
|
|
1773
|
+
{ in: "path", key: "address" }
|
|
1774
|
+
]
|
|
1775
|
+
}
|
|
1776
|
+
]);
|
|
1777
|
+
return (options?.client ?? this.client).get({
|
|
1778
|
+
url: "/gate/preview/collection/{chainId}/{address}",
|
|
1779
|
+
...options,
|
|
1780
|
+
...params
|
|
1781
|
+
});
|
|
1782
|
+
}
|
|
1783
|
+
previewAttributes(parameters, options) {
|
|
1784
|
+
const params = buildClientParams([parameters], [
|
|
1785
|
+
{
|
|
1786
|
+
args: [
|
|
1787
|
+
{ in: "path", key: "chainId" },
|
|
1788
|
+
{ in: "path", key: "address" }
|
|
1789
|
+
]
|
|
1790
|
+
}
|
|
1791
|
+
]);
|
|
1792
|
+
return (options?.client ?? this.client).get({
|
|
1793
|
+
url: "/gate/preview/collection/{chainId}/{address}/attributes",
|
|
1794
|
+
...options,
|
|
1795
|
+
...params
|
|
1796
|
+
});
|
|
1797
|
+
}
|
|
1798
|
+
previewTokens(parameters, options) {
|
|
1799
|
+
const params = buildClientParams([parameters], [
|
|
1800
|
+
{
|
|
1801
|
+
args: [
|
|
1802
|
+
{ in: "path", key: "chainId" },
|
|
1803
|
+
{ in: "path", key: "address" },
|
|
1804
|
+
{ in: "query", key: "cursor" },
|
|
1805
|
+
{ in: "query", key: "limit" }
|
|
1806
|
+
]
|
|
1807
|
+
}
|
|
1808
|
+
]);
|
|
1809
|
+
return (options?.client ?? this.client).get({
|
|
1810
|
+
url: "/gate/preview/collection/{chainId}/{address}/tokens",
|
|
1811
|
+
...options,
|
|
1812
|
+
...params
|
|
1813
|
+
});
|
|
1814
|
+
}
|
|
1815
|
+
previewToken(parameters, options) {
|
|
1816
|
+
const params = buildClientParams([parameters], [
|
|
1817
|
+
{
|
|
1818
|
+
args: [
|
|
1819
|
+
{ in: "path", key: "chainId" },
|
|
1820
|
+
{ in: "path", key: "address" },
|
|
1821
|
+
{ in: "path", key: "tokenId" }
|
|
1822
|
+
]
|
|
1823
|
+
}
|
|
1824
|
+
]);
|
|
1825
|
+
return (options?.client ?? this.client).get({
|
|
1826
|
+
url: "/gate/preview/collection/{chainId}/{address}/token/{tokenId}",
|
|
1827
|
+
...options,
|
|
1828
|
+
...params
|
|
1829
|
+
});
|
|
1830
|
+
}
|
|
1831
|
+
previewCurrency(parameters, options) {
|
|
1832
|
+
const params = buildClientParams([parameters], [
|
|
1833
|
+
{
|
|
1834
|
+
args: [
|
|
1835
|
+
{ in: "path", key: "chainId" },
|
|
1836
|
+
{ in: "query", key: "contractAddress" }
|
|
1837
|
+
]
|
|
1838
|
+
}
|
|
1839
|
+
]);
|
|
1840
|
+
return (options?.client ?? this.client).get({
|
|
1841
|
+
url: "/gate/preview/currency/{chainId}",
|
|
1842
|
+
...options,
|
|
1843
|
+
...params
|
|
1844
|
+
});
|
|
1845
|
+
}
|
|
1846
|
+
previewFarcaster(parameters, options) {
|
|
1847
|
+
const params = buildClientParams([parameters], [{ args: [{ in: "query", key: "query" }] }]);
|
|
1848
|
+
return (options?.client ?? this.client).get({
|
|
1849
|
+
url: "/gate/preview/farcaster/user",
|
|
1850
|
+
...options,
|
|
1851
|
+
...params
|
|
1852
|
+
});
|
|
1853
|
+
}
|
|
1854
|
+
}
|
|
1855
|
+
|
|
1856
|
+
class Mechanic extends HeyApiClient {
|
|
1857
|
+
list(parameters, options) {
|
|
1858
|
+
const params = buildClientParams([parameters], [
|
|
1859
|
+
{
|
|
1860
|
+
args: [
|
|
1861
|
+
{ in: "query", key: "builtIn" },
|
|
1862
|
+
{ in: "query", key: "type" }
|
|
1863
|
+
]
|
|
1864
|
+
}
|
|
1865
|
+
]);
|
|
1866
|
+
return (options?.client ?? this.client).get({
|
|
1867
|
+
url: "/mechanic",
|
|
1868
|
+
...options,
|
|
1869
|
+
...params
|
|
1870
|
+
});
|
|
1871
|
+
}
|
|
1872
|
+
create(parameters, options) {
|
|
1873
|
+
const params = buildClientParams([parameters], [
|
|
1874
|
+
{
|
|
1875
|
+
args: [
|
|
1876
|
+
{ in: "body", key: "slug" },
|
|
1877
|
+
{ in: "body", key: "name" },
|
|
1878
|
+
{ in: "body", key: "description" },
|
|
1879
|
+
{ in: "body", key: "configSchema" },
|
|
1880
|
+
{ in: "body", key: "encodingAbi" }
|
|
1881
|
+
]
|
|
1882
|
+
}
|
|
1883
|
+
]);
|
|
1884
|
+
return (options?.client ?? this.client).post({
|
|
1885
|
+
url: "/mechanic",
|
|
1886
|
+
...options,
|
|
1887
|
+
...params,
|
|
1888
|
+
headers: {
|
|
1889
|
+
"Content-Type": "application/json",
|
|
1890
|
+
...options?.headers,
|
|
1891
|
+
...params.headers
|
|
1892
|
+
}
|
|
1893
|
+
});
|
|
1894
|
+
}
|
|
1895
|
+
get(parameters, options) {
|
|
1896
|
+
const params = buildClientParams([parameters], [{ args: [{ in: "path", key: "mechanicId" }] }]);
|
|
1897
|
+
return (options?.client ?? this.client).get({
|
|
1898
|
+
url: "/mechanic/{mechanicId}",
|
|
1899
|
+
...options,
|
|
1900
|
+
...params
|
|
1901
|
+
});
|
|
1902
|
+
}
|
|
1903
|
+
update(parameters, options) {
|
|
1904
|
+
const params = buildClientParams([parameters], [
|
|
1905
|
+
{
|
|
1906
|
+
args: [
|
|
1907
|
+
{ in: "path", key: "mechanicId" },
|
|
1908
|
+
{ in: "body", key: "name" },
|
|
1909
|
+
{ in: "body", key: "description" },
|
|
1910
|
+
{ in: "body", key: "configSchema" },
|
|
1911
|
+
{ in: "body", key: "encodingAbi" }
|
|
1912
|
+
]
|
|
1913
|
+
}
|
|
1914
|
+
]);
|
|
1915
|
+
return (options?.client ?? this.client).patch({
|
|
1916
|
+
url: "/mechanic/{mechanicId}",
|
|
1917
|
+
...options,
|
|
1918
|
+
...params,
|
|
1919
|
+
headers: {
|
|
1920
|
+
"Content-Type": "application/json",
|
|
1921
|
+
...options?.headers,
|
|
1922
|
+
...params.headers
|
|
1923
|
+
}
|
|
1924
|
+
});
|
|
1925
|
+
}
|
|
1926
|
+
removeDeployment(parameters, options) {
|
|
1927
|
+
const params = buildClientParams([parameters], [
|
|
1928
|
+
{
|
|
1929
|
+
args: [
|
|
1930
|
+
{ in: "path", key: "mechanicId" },
|
|
1931
|
+
{ in: "body", key: "chainId" }
|
|
1932
|
+
]
|
|
1933
|
+
}
|
|
1934
|
+
]);
|
|
1935
|
+
return (options?.client ?? this.client).delete({
|
|
1936
|
+
url: "/mechanic/{mechanicId}/deployment",
|
|
1937
|
+
...options,
|
|
1938
|
+
...params,
|
|
1939
|
+
headers: {
|
|
1940
|
+
"Content-Type": "application/json",
|
|
1941
|
+
...options?.headers,
|
|
1942
|
+
...params.headers
|
|
1943
|
+
}
|
|
1944
|
+
});
|
|
1945
|
+
}
|
|
1946
|
+
addDeployment(parameters, options) {
|
|
1947
|
+
const params = buildClientParams([parameters], [
|
|
1948
|
+
{
|
|
1949
|
+
args: [
|
|
1950
|
+
{ in: "path", key: "mechanicId" },
|
|
1951
|
+
{ in: "body", key: "chainId" },
|
|
1952
|
+
{ in: "body", key: "address" }
|
|
1953
|
+
]
|
|
1954
|
+
}
|
|
1955
|
+
]);
|
|
1956
|
+
return (options?.client ?? this.client).post({
|
|
1957
|
+
url: "/mechanic/{mechanicId}/deployment",
|
|
1958
|
+
...options,
|
|
1959
|
+
...params,
|
|
1960
|
+
headers: {
|
|
1961
|
+
"Content-Type": "application/json",
|
|
1962
|
+
...options?.headers,
|
|
1963
|
+
...params.headers
|
|
1964
|
+
}
|
|
1965
|
+
});
|
|
1966
|
+
}
|
|
1967
|
+
}
|
|
1968
|
+
|
|
1969
|
+
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) {
|
|
2002
|
+
const params = buildClientParams([parameters], [{ args: [{ in: "path", key: "mediaId" }] }]);
|
|
2003
|
+
return (options?.client ?? this.client).post({
|
|
2004
|
+
url: "/media/{mediaId}/process",
|
|
2005
|
+
...options,
|
|
2006
|
+
...params
|
|
2007
|
+
});
|
|
2008
|
+
}
|
|
2009
|
+
listChildren(parameters, options) {
|
|
2010
|
+
const params = buildClientParams([parameters], [
|
|
2011
|
+
{
|
|
2012
|
+
args: [
|
|
2013
|
+
{ in: "path", key: "mediaId" },
|
|
2014
|
+
{ in: "query", key: "cursor" },
|
|
2015
|
+
{ in: "query", key: "limit" }
|
|
2016
|
+
]
|
|
2017
|
+
}
|
|
2018
|
+
]);
|
|
2019
|
+
return (options?.client ?? this.client).get({
|
|
2020
|
+
url: "/media/{mediaId}/children",
|
|
2021
|
+
...options,
|
|
2022
|
+
...params
|
|
2023
|
+
});
|
|
2024
|
+
}
|
|
2025
|
+
delete(parameters, options) {
|
|
2026
|
+
const params = buildClientParams([parameters], [{ args: [{ in: "path", key: "mediaId" }] }]);
|
|
2027
|
+
return (options?.client ?? this.client).delete({
|
|
2028
|
+
url: "/media/{mediaId}",
|
|
2029
|
+
...options,
|
|
2030
|
+
...params
|
|
2031
|
+
});
|
|
2032
|
+
}
|
|
2033
|
+
get(parameters, options) {
|
|
2034
|
+
const params = buildClientParams([parameters], [{ args: [{ in: "path", key: "mediaId" }] }]);
|
|
2035
|
+
return (options?.client ?? this.client).get({
|
|
2036
|
+
url: "/media/{mediaId}",
|
|
2037
|
+
...options,
|
|
2038
|
+
...params
|
|
2039
|
+
});
|
|
2040
|
+
}
|
|
2041
|
+
publish(parameters, options) {
|
|
2042
|
+
const params = buildClientParams([parameters], [{ args: [{ in: "path", key: "mediaId" }] }]);
|
|
2043
|
+
return (options?.client ?? this.client).post({
|
|
2044
|
+
url: "/media/{mediaId}/publish",
|
|
2045
|
+
...options,
|
|
2046
|
+
...params
|
|
2047
|
+
});
|
|
2048
|
+
}
|
|
2049
|
+
getChild(parameters, options) {
|
|
2050
|
+
const params = buildClientParams([parameters], [
|
|
2051
|
+
{
|
|
2052
|
+
args: [
|
|
2053
|
+
{ in: "path", key: "mediaId" },
|
|
2054
|
+
{ in: "path", key: "path" }
|
|
2055
|
+
]
|
|
2056
|
+
}
|
|
2057
|
+
]);
|
|
2058
|
+
return (options?.client ?? this.client).get({
|
|
2059
|
+
url: "/media/{mediaId}/children/{path}",
|
|
2060
|
+
...options,
|
|
2061
|
+
...params
|
|
2062
|
+
});
|
|
2063
|
+
}
|
|
2064
|
+
}
|
|
2065
|
+
|
|
2066
|
+
class Tx extends HeyApiClient {
|
|
2067
|
+
status(parameters, options) {
|
|
2068
|
+
const params = buildClientParams([parameters], [
|
|
2069
|
+
{
|
|
2070
|
+
args: [
|
|
2071
|
+
{ in: "path", key: "chainId" },
|
|
2072
|
+
{ in: "path", key: "txHash" }
|
|
2073
|
+
]
|
|
2074
|
+
}
|
|
2075
|
+
]);
|
|
2076
|
+
return (options?.client ?? this.client).get({
|
|
2077
|
+
url: "/tx/{chainId}/{txHash}",
|
|
2078
|
+
...options,
|
|
2079
|
+
...params
|
|
2080
|
+
});
|
|
2081
|
+
}
|
|
2082
|
+
submit(parameters, options) {
|
|
2083
|
+
const params = buildClientParams([parameters], [
|
|
2084
|
+
{
|
|
2085
|
+
args: [
|
|
2086
|
+
{ in: "path", key: "chainId" },
|
|
2087
|
+
{ in: "path", key: "txHash" }
|
|
2088
|
+
]
|
|
2089
|
+
}
|
|
2090
|
+
]);
|
|
2091
|
+
return (options?.client ?? this.client).post({
|
|
2092
|
+
url: "/tx/{chainId}/{txHash}",
|
|
2093
|
+
...options,
|
|
2094
|
+
...params
|
|
2095
|
+
});
|
|
2096
|
+
}
|
|
2097
|
+
}
|
|
2098
|
+
|
|
2099
|
+
class Siwe extends HeyApiClient {
|
|
2100
|
+
nonce(options) {
|
|
2101
|
+
return (options?.client ?? this.client).post({ url: "/user/signin/siwe/nonce", ...options });
|
|
2102
|
+
}
|
|
2103
|
+
}
|
|
2104
|
+
|
|
2105
|
+
class User extends HeyApiClient {
|
|
2106
|
+
signin(parameters, options) {
|
|
2107
|
+
const params = buildClientParams([parameters], [{ args: [{ key: "body", map: "body" }] }]);
|
|
2108
|
+
return (options?.client ?? this.client).post({
|
|
2109
|
+
url: "/user/signin",
|
|
2110
|
+
...options,
|
|
2111
|
+
...params,
|
|
2112
|
+
headers: {
|
|
2113
|
+
"Content-Type": "application/json",
|
|
2114
|
+
...options?.headers,
|
|
2115
|
+
...params.headers
|
|
2116
|
+
}
|
|
2117
|
+
});
|
|
2118
|
+
}
|
|
2119
|
+
_siwe;
|
|
2120
|
+
get siwe() {
|
|
2121
|
+
return this._siwe ??= new Siwe({ client: this.client });
|
|
2122
|
+
}
|
|
2123
|
+
}
|
|
2124
|
+
|
|
2125
|
+
class ApiKey extends HeyApiClient {
|
|
2126
|
+
list(options) {
|
|
2127
|
+
return (options?.client ?? this.client).get({ url: "/user/api-keys", ...options });
|
|
2128
|
+
}
|
|
2129
|
+
create(parameters, options) {
|
|
2130
|
+
const params = buildClientParams([parameters], [
|
|
2131
|
+
{
|
|
2132
|
+
args: [
|
|
2133
|
+
{ in: "body", key: "name" },
|
|
2134
|
+
{ in: "body", key: "expiresAt" }
|
|
2135
|
+
]
|
|
2136
|
+
}
|
|
2137
|
+
]);
|
|
2138
|
+
return (options?.client ?? this.client).post({
|
|
2139
|
+
url: "/user/api-keys",
|
|
2140
|
+
...options,
|
|
2141
|
+
...params,
|
|
2142
|
+
headers: {
|
|
2143
|
+
"Content-Type": "application/json",
|
|
2144
|
+
...options?.headers,
|
|
2145
|
+
...params.headers
|
|
2146
|
+
}
|
|
2147
|
+
});
|
|
2148
|
+
}
|
|
2149
|
+
revoke(parameters, options) {
|
|
2150
|
+
const params = buildClientParams([parameters], [{ args: [{ in: "path", key: "apiKeyId" }] }]);
|
|
2151
|
+
return (options?.client ?? this.client).delete({
|
|
2152
|
+
url: "/user/api-keys/{apiKeyId}",
|
|
2153
|
+
...options,
|
|
2154
|
+
...params
|
|
2155
|
+
});
|
|
2156
|
+
}
|
|
2157
|
+
}
|
|
2158
|
+
|
|
2159
|
+
class Health extends HeyApiClient {
|
|
2160
|
+
get(options) {
|
|
2161
|
+
return (options?.client ?? this.client).get({
|
|
2162
|
+
url: "/health",
|
|
2163
|
+
...options
|
|
2164
|
+
});
|
|
2165
|
+
}
|
|
2166
|
+
}
|
|
2167
|
+
|
|
2168
|
+
class HighlightClient extends HeyApiClient {
|
|
2169
|
+
static __registry = new HeyApiRegistry;
|
|
2170
|
+
constructor(args) {
|
|
2171
|
+
super(args);
|
|
2172
|
+
HighlightClient.__registry.set(this, args?.key);
|
|
2173
|
+
}
|
|
2174
|
+
postIndexerChainsByChainIdActivate(parameters, options) {
|
|
2175
|
+
const params = buildClientParams([parameters], [{ args: [{ in: "path", key: "chainId" }] }]);
|
|
2176
|
+
return (options?.client ?? this.client).post({
|
|
2177
|
+
url: "/indexer/chains/{chainId}/activate",
|
|
2178
|
+
...options,
|
|
2179
|
+
...params
|
|
2180
|
+
});
|
|
2181
|
+
}
|
|
2182
|
+
postIndexerChainsByChainIdReset(parameters, options) {
|
|
2183
|
+
const params = buildClientParams([parameters], [
|
|
2184
|
+
{
|
|
2185
|
+
args: [
|
|
2186
|
+
{ in: "path", key: "chainId" },
|
|
2187
|
+
{ in: "body", key: "blockNumber" }
|
|
2188
|
+
]
|
|
2189
|
+
}
|
|
2190
|
+
]);
|
|
2191
|
+
return (options?.client ?? this.client).post({
|
|
2192
|
+
url: "/indexer/chains/{chainId}/reset",
|
|
2193
|
+
...options,
|
|
2194
|
+
...params,
|
|
2195
|
+
headers: {
|
|
2196
|
+
"Content-Type": "application/json",
|
|
2197
|
+
...options?.headers,
|
|
2198
|
+
...params.headers
|
|
2199
|
+
}
|
|
2200
|
+
});
|
|
2201
|
+
}
|
|
2202
|
+
postIndexerChainsByChainIdPoll(parameters, options) {
|
|
2203
|
+
const params = buildClientParams([parameters], [{ args: [{ in: "path", key: "chainId" }] }]);
|
|
2204
|
+
return (options?.client ?? this.client).post({
|
|
2205
|
+
url: "/indexer/chains/{chainId}/poll",
|
|
2206
|
+
...options,
|
|
2207
|
+
...params
|
|
2208
|
+
});
|
|
2209
|
+
}
|
|
2210
|
+
_collection;
|
|
2211
|
+
get collection() {
|
|
2212
|
+
return this._collection ??= new Collection({ client: this.client });
|
|
2213
|
+
}
|
|
2214
|
+
_token;
|
|
2215
|
+
get token() {
|
|
2216
|
+
return this._token ??= new Token({ client: this.client });
|
|
2217
|
+
}
|
|
2218
|
+
_config;
|
|
2219
|
+
get config() {
|
|
2220
|
+
return this._config ??= new Config({ client: this.client });
|
|
2221
|
+
}
|
|
2222
|
+
_contract;
|
|
2223
|
+
get contract() {
|
|
2224
|
+
return this._contract ??= new Contract({ client: this.client });
|
|
2225
|
+
}
|
|
2226
|
+
_gate;
|
|
2227
|
+
get gate() {
|
|
2228
|
+
return this._gate ??= new Gate({ client: this.client });
|
|
2229
|
+
}
|
|
2230
|
+
_mechanic;
|
|
2231
|
+
get mechanic() {
|
|
2232
|
+
return this._mechanic ??= new Mechanic({ client: this.client });
|
|
2233
|
+
}
|
|
2234
|
+
_media;
|
|
2235
|
+
get media() {
|
|
2236
|
+
return this._media ??= new Media({ client: this.client });
|
|
2237
|
+
}
|
|
2238
|
+
_tx;
|
|
2239
|
+
get tx() {
|
|
2240
|
+
return this._tx ??= new Tx({ client: this.client });
|
|
2241
|
+
}
|
|
2242
|
+
_user;
|
|
2243
|
+
get user() {
|
|
2244
|
+
return this._user ??= new User({ client: this.client });
|
|
2245
|
+
}
|
|
2246
|
+
_apiKey;
|
|
2247
|
+
get apiKey() {
|
|
2248
|
+
return this._apiKey ??= new ApiKey({ client: this.client });
|
|
2249
|
+
}
|
|
2250
|
+
_health;
|
|
2251
|
+
get health() {
|
|
2252
|
+
return this._health ??= new Health({ client: this.client });
|
|
2253
|
+
}
|
|
2254
|
+
}
|
|
2255
|
+
|
|
2256
|
+
// ../sdk/src/client.ts
|
|
2257
|
+
function createHighlightClient(config) {
|
|
2258
|
+
const resolvedConfig = {
|
|
2259
|
+
...config,
|
|
2260
|
+
auth: config?.auth ?? config?.apiKey,
|
|
2261
|
+
security: config?.security ?? (config?.auth || config?.apiKey ? [{ type: "http", scheme: "bearer" }] : undefined)
|
|
2262
|
+
};
|
|
2263
|
+
const client2 = createClient(resolvedConfig);
|
|
2264
|
+
return new HighlightClient({ client: client2 });
|
|
2265
|
+
}
|
|
2266
|
+
// ../sdk/src/v1/media.ts
|
|
2267
|
+
var DEFAULT_PREFERENCE = [
|
|
2268
|
+
"Archive" /* Archive */,
|
|
2269
|
+
"Origin" /* Origin */,
|
|
2270
|
+
"Mirror" /* Mirror */
|
|
2271
|
+
];
|
|
2272
|
+
var pickLocation = (media, preference) => {
|
|
2273
|
+
for (const role of preference) {
|
|
2274
|
+
const location = media.locations.find((l) => l.role === role && l.status === "Succeeded" /* Succeeded */ && l.url !== null);
|
|
2275
|
+
if (location)
|
|
2276
|
+
return location;
|
|
2277
|
+
}
|
|
2278
|
+
return null;
|
|
2279
|
+
};
|
|
2280
|
+
var resolveMediaUrl = (media, options) => {
|
|
2281
|
+
if (!media)
|
|
2282
|
+
return null;
|
|
2283
|
+
const preference = options?.prefer ? Array.isArray(options.prefer) ? options.prefer : [options.prefer] : DEFAULT_PREFERENCE;
|
|
2284
|
+
return pickLocation(media, preference)?.url ?? null;
|
|
2285
|
+
};
|
|
2286
|
+
// src/config.ts
|
|
2287
|
+
import { chmod, mkdir, readFile, rename, writeFile } from "node:fs/promises";
|
|
2288
|
+
import path from "node:path";
|
|
2289
|
+
var DEFAULT_API_URL = "https://api.highlightv2.xyz";
|
|
2290
|
+
var CONFIG_VERSION = 1;
|
|
2291
|
+
var defaultConfig = () => ({
|
|
2292
|
+
currentProfile: "default",
|
|
2293
|
+
profiles: {},
|
|
2294
|
+
version: CONFIG_VERSION
|
|
2295
|
+
});
|
|
2296
|
+
var isRecord2 = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
2297
|
+
var isProfile = (value) => {
|
|
2298
|
+
if (!isRecord2(value))
|
|
2299
|
+
return false;
|
|
2300
|
+
return (value.apiKey === undefined || typeof value.apiKey === "string") && (value.apiUrl === undefined || typeof value.apiUrl === "string");
|
|
2301
|
+
};
|
|
2302
|
+
var parseConfig = (value, configPath) => {
|
|
2303
|
+
if (!isRecord2(value) || value.version !== CONFIG_VERSION || typeof value.currentProfile !== "string" || !isRecord2(value.profiles)) {
|
|
2304
|
+
throw new CliError(`Invalid Highlight CLI config at ${configPath}. Move it aside and run "hl auth login" again.`);
|
|
2305
|
+
}
|
|
2306
|
+
const profiles = {};
|
|
2307
|
+
for (const [name, profile] of Object.entries(value.profiles)) {
|
|
2308
|
+
if (!isProfile(profile)) {
|
|
2309
|
+
throw new CliError(`Invalid Highlight CLI config at ${configPath}. Move it aside and run "hl auth login" again.`);
|
|
2310
|
+
}
|
|
2311
|
+
profiles[name] = profile;
|
|
2312
|
+
}
|
|
2313
|
+
return {
|
|
2314
|
+
currentProfile: value.currentProfile,
|
|
2315
|
+
profiles,
|
|
2316
|
+
version: CONFIG_VERSION
|
|
2317
|
+
};
|
|
2318
|
+
};
|
|
2319
|
+
var isFileNotFound = (error) => isRecord2(error) && ("code" in error) && error.code === "ENOENT";
|
|
2320
|
+
var configPathFor = (runtime) => {
|
|
2321
|
+
const explicitDirectory = runtime.env.HIGHLIGHT_CONFIG_DIR;
|
|
2322
|
+
if (explicitDirectory) {
|
|
2323
|
+
return path.join(explicitDirectory, "config.json");
|
|
2324
|
+
}
|
|
2325
|
+
if (process.platform === "win32" && runtime.env.APPDATA) {
|
|
2326
|
+
return path.join(runtime.env.APPDATA, "Highlight", "config.json");
|
|
2327
|
+
}
|
|
2328
|
+
const configHome = runtime.env.XDG_CONFIG_HOME ?? path.join(runtime.homeDir, ".config");
|
|
2329
|
+
return path.join(configHome, "highlight", "config.json");
|
|
2330
|
+
};
|
|
2331
|
+
var loadConfig = async (runtime) => {
|
|
2332
|
+
const configPath = configPathFor(runtime);
|
|
2333
|
+
try {
|
|
2334
|
+
const contents = await readFile(configPath, "utf8");
|
|
2335
|
+
let parsed;
|
|
2336
|
+
try {
|
|
2337
|
+
parsed = JSON.parse(contents);
|
|
2338
|
+
} catch {
|
|
2339
|
+
throw new CliError(`Highlight CLI config is not valid JSON: ${configPath}`);
|
|
2340
|
+
}
|
|
2341
|
+
return parseConfig(parsed, configPath);
|
|
2342
|
+
} catch (error) {
|
|
2343
|
+
if (isFileNotFound(error)) {
|
|
2344
|
+
return defaultConfig();
|
|
2345
|
+
}
|
|
2346
|
+
throw error;
|
|
2347
|
+
}
|
|
2348
|
+
};
|
|
2349
|
+
var saveConfig = async (runtime, config) => {
|
|
2350
|
+
const configPath = configPathFor(runtime);
|
|
2351
|
+
const directory = path.dirname(configPath);
|
|
2352
|
+
const temporaryPath = `${configPath}.${process.pid}.tmp`;
|
|
2353
|
+
await mkdir(directory, { mode: 448, recursive: true });
|
|
2354
|
+
await writeFile(temporaryPath, `${JSON.stringify(config, null, 2)}
|
|
2355
|
+
`, { mode: 384 });
|
|
2356
|
+
await rename(temporaryPath, configPath);
|
|
2357
|
+
await chmod(configPath, 384);
|
|
2358
|
+
};
|
|
2359
|
+
var profileNameFor = (config, requested) => requested ?? config.currentProfile;
|
|
2360
|
+
var profileFor = (config, profileName) => config.profiles[profileName] ?? {};
|
|
2361
|
+
var updateProfile = (config, profileName, update) => ({
|
|
2362
|
+
...config,
|
|
2363
|
+
currentProfile: profileName,
|
|
2364
|
+
profiles: {
|
|
2365
|
+
...config.profiles,
|
|
2366
|
+
[profileName]: {
|
|
2367
|
+
...profileFor(config, profileName),
|
|
2368
|
+
...update
|
|
2369
|
+
}
|
|
2370
|
+
}
|
|
2371
|
+
});
|
|
2372
|
+
var clearProfileKey = (config, profileName) => {
|
|
2373
|
+
const profile = profileFor(config, profileName);
|
|
2374
|
+
const { apiKey: _apiKey, ...profileWithoutKey } = profile;
|
|
2375
|
+
return {
|
|
2376
|
+
...config,
|
|
2377
|
+
profiles: {
|
|
2378
|
+
...config.profiles,
|
|
2379
|
+
[profileName]: profileWithoutKey
|
|
2380
|
+
}
|
|
2381
|
+
};
|
|
2382
|
+
};
|
|
2383
|
+
|
|
2384
|
+
// src/output.ts
|
|
2385
|
+
var cell = (value) => value === null || value === undefined || value === "" ? "—" : String(value);
|
|
2386
|
+
var printJson = (runtime, value) => {
|
|
2387
|
+
runtime.stdout(JSON.stringify(value, null, 2));
|
|
2388
|
+
};
|
|
2389
|
+
var printTable = (runtime, headers, rows) => {
|
|
2390
|
+
const stringRows = rows.map((row) => row.map(cell));
|
|
2391
|
+
const widths = headers.map((header, index) => Math.max(header.length, ...stringRows.map((row) => row[index]?.length ?? 0)));
|
|
2392
|
+
const render = (row) => row.map((value, index) => value.padEnd(widths[index] ?? value.length)).join(" ").trimEnd();
|
|
2393
|
+
runtime.stdout(render(headers));
|
|
2394
|
+
runtime.stdout(render(widths.map((width) => "-".repeat(width))));
|
|
2395
|
+
for (const row of stringRows) {
|
|
2396
|
+
runtime.stdout(render(row));
|
|
2397
|
+
}
|
|
2398
|
+
};
|
|
2399
|
+
var printCollectionList = (runtime, result) => {
|
|
2400
|
+
printTable(runtime, ["ID", "NAME", "TYPE", "STATUS", "CHAIN", "CONTRACT"], result.items.map((collection) => [
|
|
2401
|
+
collection.highlightId,
|
|
2402
|
+
collection.name,
|
|
2403
|
+
collection.type,
|
|
2404
|
+
collection.status,
|
|
2405
|
+
collection.contract.chainId,
|
|
2406
|
+
collection.contract.address
|
|
2407
|
+
]));
|
|
2408
|
+
runtime.stdout(`Page ${result.pageInfo.page}/${Math.max(result.pageInfo.totalPages, 1)} · ${result.pageInfo.totalCount} total`);
|
|
2409
|
+
};
|
|
2410
|
+
var printCollection = (runtime, collection) => {
|
|
2411
|
+
runtime.stdout(`${collection.name} (${collection.highlightId})`);
|
|
2412
|
+
runtime.stdout(`Type: ${collection.type}`);
|
|
2413
|
+
runtime.stdout(`Status: ${collection.status}`);
|
|
2414
|
+
runtime.stdout(`Chain: ${collection.contract.chainId}`);
|
|
2415
|
+
runtime.stdout(`Contract: ${collection.contract.address ?? "not deployed"}`);
|
|
2416
|
+
if (collection.description)
|
|
2417
|
+
runtime.stdout(`Description: ${collection.description}`);
|
|
2418
|
+
};
|
|
2419
|
+
var printDeployStatus = (runtime, status) => {
|
|
2420
|
+
runtime.stdout(`Deployment ${status.deploymentId}: ${status.status}`);
|
|
2421
|
+
runtime.stdout(`Current step: ${status.currentStep}`);
|
|
2422
|
+
if (status.txHash)
|
|
2423
|
+
runtime.stdout(`Transaction: ${status.txHash}`);
|
|
2424
|
+
if (status.error)
|
|
2425
|
+
runtime.stdout(`Error: ${status.error}`);
|
|
2426
|
+
if (status.currentStep === "AwaitTransaction" && status.contractConfig) {
|
|
2427
|
+
runtime.stdout("Wallet signature required. Transaction payload:");
|
|
2428
|
+
runtime.stdout(JSON.stringify(status.contractConfig, null, 2));
|
|
2429
|
+
}
|
|
2430
|
+
};
|
|
2431
|
+
var printMedia = (runtime, media2, resolvedUrl) => {
|
|
2432
|
+
runtime.stdout(`Media ${media2.id}: ${media2.status}`);
|
|
2433
|
+
runtime.stdout(`File: ${media2.fileName}`);
|
|
2434
|
+
runtime.stdout(`Kind: ${media2.kind}`);
|
|
2435
|
+
if (resolvedUrl)
|
|
2436
|
+
runtime.stdout(`URL: ${resolvedUrl}`);
|
|
2437
|
+
};
|
|
2438
|
+
|
|
2439
|
+
// src/sdk.ts
|
|
2440
|
+
var createPublicClientContext = async (runtime, global) => {
|
|
2441
|
+
const config = await loadConfig(runtime);
|
|
2442
|
+
const profileName = profileNameFor(config, global.profile);
|
|
2443
|
+
const profile = profileFor(config, profileName);
|
|
2444
|
+
const environmentKey = runtime.env.HIGHLIGHT_API_KEY;
|
|
2445
|
+
const apiKey = environmentKey ?? profile.apiKey;
|
|
2446
|
+
const apiUrl = global.apiUrl ?? runtime.env.HIGHLIGHT_API_URL ?? profile.apiUrl ?? DEFAULT_API_URL;
|
|
2447
|
+
const client3 = createHighlightClient({
|
|
2448
|
+
apiKey,
|
|
2449
|
+
baseUrl: apiUrl,
|
|
2450
|
+
fetch: runtime.fetch
|
|
2451
|
+
});
|
|
2452
|
+
return {
|
|
2453
|
+
apiKey,
|
|
2454
|
+
apiUrl,
|
|
2455
|
+
client: client3,
|
|
2456
|
+
config,
|
|
2457
|
+
credentialSource: apiKey ? environmentKey ? "environment" : "profile" : undefined,
|
|
2458
|
+
profileName
|
|
2459
|
+
};
|
|
2460
|
+
};
|
|
2461
|
+
var createClientContext = async (runtime, global) => {
|
|
2462
|
+
const context = await createPublicClientContext(runtime, global);
|
|
2463
|
+
if (!context.apiKey || !context.credentialSource) {
|
|
2464
|
+
throw new CliError(`Not authenticated for profile "${context.profileName}". Run "hl auth login" or set HIGHLIGHT_API_KEY.`);
|
|
2465
|
+
}
|
|
2466
|
+
return {
|
|
2467
|
+
...context,
|
|
2468
|
+
apiKey: context.apiKey,
|
|
2469
|
+
credentialSource: context.credentialSource
|
|
2470
|
+
};
|
|
2471
|
+
};
|
|
2472
|
+
|
|
2473
|
+
// src/commands/auth.ts
|
|
2474
|
+
var validateApiUrl = (value) => {
|
|
2475
|
+
let url;
|
|
2476
|
+
try {
|
|
2477
|
+
url = new URL(value);
|
|
2478
|
+
} catch {
|
|
2479
|
+
throw new CliError(`Invalid API URL: ${value}`, 2);
|
|
2480
|
+
}
|
|
2481
|
+
if (url.protocol !== "https:" && url.protocol !== "http:") {
|
|
2482
|
+
throw new CliError("API URL must use http or https", 2);
|
|
2483
|
+
}
|
|
2484
|
+
return url.toString().replace(/\/$/, "");
|
|
2485
|
+
};
|
|
2486
|
+
var login = async (args, global, runtime) => {
|
|
2487
|
+
const parsed = parseCommandArgs(args, {
|
|
2488
|
+
options: {
|
|
2489
|
+
"api-key": { type: "string" },
|
|
2490
|
+
"api-key-stdin": { type: "boolean" }
|
|
2491
|
+
}
|
|
2492
|
+
});
|
|
2493
|
+
assertNoExtraPositionals(parsed.positionals, 0);
|
|
2494
|
+
if (parsed.values["api-key"] && parsed.values["api-key-stdin"]) {
|
|
2495
|
+
throw new CliError("Use either --api-key or --api-key-stdin, not both", 2);
|
|
2496
|
+
}
|
|
2497
|
+
let apiKey = parsed.values["api-key"] ?? runtime.env.HIGHLIGHT_API_KEY;
|
|
2498
|
+
if (parsed.values["api-key-stdin"]) {
|
|
2499
|
+
apiKey = (await runtime.readStdin()).trim();
|
|
2500
|
+
} else if (!apiKey) {
|
|
2501
|
+
apiKey = (await runtime.promptSecret("Highlight API key: ")).trim();
|
|
2502
|
+
}
|
|
2503
|
+
if (!apiKey) {
|
|
2504
|
+
throw new CliError("An API key is required", 2);
|
|
2505
|
+
}
|
|
2506
|
+
if (!apiKey.startsWith("hl_live_")) {
|
|
2507
|
+
throw new CliError('Highlight API keys must start with "hl_live_"', 2);
|
|
2508
|
+
}
|
|
2509
|
+
const config = await loadConfig(runtime);
|
|
2510
|
+
const profileName = profileNameFor(config, global.profile);
|
|
2511
|
+
const profile = profileFor(config, profileName);
|
|
2512
|
+
const apiUrl = validateApiUrl(global.apiUrl ?? runtime.env.HIGHLIGHT_API_URL ?? profile.apiUrl ?? DEFAULT_API_URL);
|
|
2513
|
+
const client3 = createHighlightClient({
|
|
2514
|
+
apiKey,
|
|
2515
|
+
baseUrl: apiUrl,
|
|
2516
|
+
fetch: runtime.fetch
|
|
2517
|
+
});
|
|
2518
|
+
const keys = unwrap(await client3.apiKey.list());
|
|
2519
|
+
const activeKey = keys.find((key) => key.last4 === apiKey.slice(-4) && !key.revokedAt);
|
|
2520
|
+
await saveConfig(runtime, updateProfile(config, profileName, { apiKey, apiUrl }));
|
|
2521
|
+
const result = {
|
|
2522
|
+
apiKey: activeKey ? {
|
|
2523
|
+
expiresAt: activeKey.expiresAt,
|
|
2524
|
+
id: activeKey.id,
|
|
2525
|
+
last4: activeKey.last4,
|
|
2526
|
+
name: activeKey.name
|
|
2527
|
+
} : { last4: apiKey.slice(-4) },
|
|
2528
|
+
apiUrl,
|
|
2529
|
+
authenticated: true,
|
|
2530
|
+
profile: profileName
|
|
2531
|
+
};
|
|
2532
|
+
if (global.json) {
|
|
2533
|
+
printJson(runtime, result);
|
|
2534
|
+
} else {
|
|
2535
|
+
runtime.stdout(`Authenticated profile "${profileName}" with API key …${apiKey.slice(-4)}.`);
|
|
2536
|
+
runtime.stdout(`API: ${apiUrl}`);
|
|
2537
|
+
}
|
|
2538
|
+
};
|
|
2539
|
+
var status = async (args, global, runtime) => {
|
|
2540
|
+
const parsed = parseCommandArgs(args, { options: {} });
|
|
2541
|
+
assertNoExtraPositionals(parsed.positionals, 0);
|
|
2542
|
+
const context = await createClientContext(runtime, global);
|
|
2543
|
+
const keys = unwrap(await context.client.apiKey.list());
|
|
2544
|
+
const activeKey = keys.find((key) => key.last4 === context.apiKey.slice(-4) && key.revokedAt === null);
|
|
2545
|
+
const result = {
|
|
2546
|
+
apiKey: activeKey ? {
|
|
2547
|
+
expiresAt: activeKey.expiresAt,
|
|
2548
|
+
id: activeKey.id,
|
|
2549
|
+
last4: activeKey.last4,
|
|
2550
|
+
name: activeKey.name
|
|
2551
|
+
} : { last4: context.apiKey.slice(-4) },
|
|
2552
|
+
apiUrl: context.apiUrl,
|
|
2553
|
+
authenticated: true,
|
|
2554
|
+
credentialSource: context.credentialSource,
|
|
2555
|
+
profile: context.profileName
|
|
2556
|
+
};
|
|
2557
|
+
if (global.json) {
|
|
2558
|
+
printJson(runtime, result);
|
|
2559
|
+
} else {
|
|
2560
|
+
runtime.stdout(`Authenticated profile "${context.profileName}" with ${context.credentialSource} API key …${context.apiKey.slice(-4)}.`);
|
|
2561
|
+
runtime.stdout(`API: ${context.apiUrl}`);
|
|
2562
|
+
}
|
|
2563
|
+
};
|
|
2564
|
+
var logout = async (args, global, runtime) => {
|
|
2565
|
+
const parsed = parseCommandArgs(args, { options: {} });
|
|
2566
|
+
assertNoExtraPositionals(parsed.positionals, 0);
|
|
2567
|
+
const config = await loadConfig(runtime);
|
|
2568
|
+
const profileName = profileNameFor(config, global.profile);
|
|
2569
|
+
const hadStoredKey = Boolean(profileFor(config, profileName).apiKey);
|
|
2570
|
+
await saveConfig(runtime, clearProfileKey(config, profileName));
|
|
2571
|
+
const result = {
|
|
2572
|
+
authenticated: Boolean(runtime.env.HIGHLIGHT_API_KEY),
|
|
2573
|
+
environmentOverride: Boolean(runtime.env.HIGHLIGHT_API_KEY),
|
|
2574
|
+
profile: profileName,
|
|
2575
|
+
removed: hadStoredKey
|
|
2576
|
+
};
|
|
2577
|
+
if (global.json) {
|
|
2578
|
+
printJson(runtime, result);
|
|
2579
|
+
} else if (runtime.env.HIGHLIGHT_API_KEY) {
|
|
2580
|
+
runtime.stdout(`Removed the stored key for profile "${profileName}". HIGHLIGHT_API_KEY is still set in this environment.`);
|
|
2581
|
+
} else if (hadStoredKey) {
|
|
2582
|
+
runtime.stdout(`Logged out profile "${profileName}".`);
|
|
2583
|
+
} else {
|
|
2584
|
+
runtime.stdout(`Profile "${profileName}" had no stored API key.`);
|
|
2585
|
+
}
|
|
2586
|
+
};
|
|
2587
|
+
|
|
2588
|
+
// src/commands/chains.ts
|
|
2589
|
+
var SYSTEM_CONTRACT_TYPES = [
|
|
2590
|
+
"CollectionFactory",
|
|
2591
|
+
"MintManager",
|
|
2592
|
+
"AuctionManager",
|
|
2593
|
+
"PermissionsRegistry",
|
|
2594
|
+
"EditionsMetadataRenderer",
|
|
2595
|
+
"NonTransferableTokenManager",
|
|
2596
|
+
"ConsensualNonTransferableTokenManager",
|
|
2597
|
+
"ConsensualNonTransferableTokenManager2",
|
|
2598
|
+
"GenerativeSeriesImplementation",
|
|
2599
|
+
"SeriesImplementation",
|
|
2600
|
+
"MultipleEditionsImplementation",
|
|
2601
|
+
"MultipleEditionsDFSImplementation",
|
|
2602
|
+
"SingleEditionImplementation",
|
|
2603
|
+
"SingleEditionDFSImplementation",
|
|
2604
|
+
"MinimalForwarder",
|
|
2605
|
+
"Observability",
|
|
2606
|
+
"RandomSeriesImplementation",
|
|
2607
|
+
"MintFeeOracle",
|
|
2608
|
+
"GengineObservability",
|
|
2609
|
+
"ReferralManager",
|
|
2610
|
+
"RazorWorksImplementation",
|
|
2611
|
+
"EditionsDFS1155Implementation",
|
|
2612
|
+
"ObservabilityV2",
|
|
2613
|
+
"BitstreamSeedManager"
|
|
2614
|
+
];
|
|
2615
|
+
var list = async (args, global, runtime) => {
|
|
2616
|
+
const parsed = parseCommandArgs(args, {
|
|
2617
|
+
options: {
|
|
2618
|
+
mainnet: { type: "boolean" },
|
|
2619
|
+
testnet: { type: "boolean" }
|
|
2620
|
+
}
|
|
2621
|
+
});
|
|
2622
|
+
assertNoExtraPositionals(parsed.positionals, 0);
|
|
2623
|
+
if (parsed.values.mainnet && parsed.values.testnet) {
|
|
2624
|
+
throw new CliError("Use either --mainnet or --testnet, not both", 2);
|
|
2625
|
+
}
|
|
2626
|
+
const context = await createPublicClientContext(runtime, global);
|
|
2627
|
+
const result = unwrap(await context.client.config.chains());
|
|
2628
|
+
const chains = result.chains.filter((chain) => (!parsed.values.mainnet || !chain.testnet) && (!parsed.values.testnet || chain.testnet));
|
|
2629
|
+
if (global.json) {
|
|
2630
|
+
printJson(runtime, { chains });
|
|
2631
|
+
return;
|
|
2632
|
+
}
|
|
2633
|
+
printTable(runtime, ["CHAIN", "NAME", "NETWORK", "TESTNET", "MINT FEE", "CURRENCIES"], chains.map((chain) => [
|
|
2634
|
+
chain.chainId,
|
|
2635
|
+
chain.name,
|
|
2636
|
+
chain.network,
|
|
2637
|
+
chain.testnet ? "yes" : "no",
|
|
2638
|
+
chain.mintFee,
|
|
2639
|
+
chain.supportedCurrencies.map((currency) => currency.symbol).join(", ")
|
|
2640
|
+
]));
|
|
2641
|
+
};
|
|
2642
|
+
var systemContract = async (args, global, runtime) => {
|
|
2643
|
+
const parsed = parseCommandArgs(args, { options: {} });
|
|
2644
|
+
const chainIdValue = requiredPositional(parsed.positionals, 0, "chain-id");
|
|
2645
|
+
const typeValue = requiredPositional(parsed.positionals, 1, "contract-type");
|
|
2646
|
+
assertNoExtraPositionals(parsed.positionals, 2);
|
|
2647
|
+
const chainId = positiveInteger(chainIdValue, "chain-id");
|
|
2648
|
+
if (!chainId)
|
|
2649
|
+
throw new CliError("chain-id is required", 2);
|
|
2650
|
+
if (!SYSTEM_CONTRACT_TYPES.includes(typeValue)) {
|
|
2651
|
+
throw new CliError(`Unknown system contract type: ${typeValue}`, 2);
|
|
2652
|
+
}
|
|
2653
|
+
const context = await createPublicClientContext(runtime, global);
|
|
2654
|
+
const result = unwrap(await context.client.config.systemContract({
|
|
2655
|
+
chainId,
|
|
2656
|
+
type: typeValue
|
|
2657
|
+
}));
|
|
2658
|
+
if (global.json)
|
|
2659
|
+
printJson(runtime, result);
|
|
2660
|
+
else
|
|
2661
|
+
runtime.stdout(`${result.type} on ${result.chainId}: ${result.address}`);
|
|
2662
|
+
};
|
|
2663
|
+
|
|
2664
|
+
// src/json-input.ts
|
|
2665
|
+
import { readFile as readFile2 } from "node:fs/promises";
|
|
2666
|
+
import path2 from "node:path";
|
|
2667
|
+
var isRecord3 = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
2668
|
+
var isOptionalString = (value) => value === undefined || typeof value === "string";
|
|
2669
|
+
var isOptionalNullableString = (value) => value === undefined || value === null || typeof value === "string";
|
|
2670
|
+
var readJsonInput = async (inputPath, runtime) => {
|
|
2671
|
+
const contents = inputPath === "-" ? await runtime.readStdin() : await readFile2(path2.resolve(runtime.cwd, inputPath), "utf8");
|
|
2672
|
+
try {
|
|
2673
|
+
return JSON.parse(contents);
|
|
2674
|
+
} catch {
|
|
2675
|
+
throw new CliError(`Input is not valid JSON: ${inputPath}`, 2);
|
|
2676
|
+
}
|
|
2677
|
+
};
|
|
2678
|
+
var readTypedJsonInput = async (inputPath, runtime, validator, expected) => {
|
|
2679
|
+
const value = await readJsonInput(inputPath, runtime);
|
|
2680
|
+
if (!validator(value)) {
|
|
2681
|
+
throw new CliError(`Input must be ${expected}.`, 2);
|
|
2682
|
+
}
|
|
2683
|
+
return value;
|
|
2684
|
+
};
|
|
2685
|
+
var requiredInputPath = (inputPath) => {
|
|
2686
|
+
if (!inputPath) {
|
|
2687
|
+
throw new CliError('Missing required option: --input <path> (use "-" for stdin)', 2);
|
|
2688
|
+
}
|
|
2689
|
+
return inputPath;
|
|
2690
|
+
};
|
|
2691
|
+
|
|
2692
|
+
// src/commands/collections.ts
|
|
2693
|
+
var isCollectionCreateInput = (value) => {
|
|
2694
|
+
if (!isRecord3(value))
|
|
2695
|
+
return false;
|
|
2696
|
+
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)) {
|
|
2697
|
+
return false;
|
|
2698
|
+
}
|
|
2699
|
+
if (value.contract !== undefined) {
|
|
2700
|
+
if (!isRecord3(value.contract) || !Number.isInteger(value.contract.chainId) || typeof value.contract.name !== "string" || typeof value.contract.symbol !== "string" || !Object.values(ContractStandard).includes(value.contract.standard)) {
|
|
2701
|
+
return false;
|
|
2702
|
+
}
|
|
2703
|
+
}
|
|
2704
|
+
if (value.royalty !== undefined) {
|
|
2705
|
+
if (!isRecord3(value.royalty) || typeof value.royalty.address !== "string" || typeof value.royalty.amount !== "number") {
|
|
2706
|
+
return false;
|
|
2707
|
+
}
|
|
2708
|
+
}
|
|
2709
|
+
return true;
|
|
2710
|
+
};
|
|
2711
|
+
var list2 = async (args, global, runtime) => {
|
|
2712
|
+
const parsed = parseCommandArgs(args, {
|
|
2713
|
+
options: {
|
|
2714
|
+
chain: { type: "string", multiple: true },
|
|
2715
|
+
limit: { type: "string" },
|
|
2716
|
+
page: { type: "string" },
|
|
2717
|
+
"sort-by": { type: "string" },
|
|
2718
|
+
"sort-direction": { type: "string" },
|
|
2719
|
+
status: { type: "string" },
|
|
2720
|
+
testnet: { type: "boolean" },
|
|
2721
|
+
type: { type: "string", multiple: true }
|
|
2722
|
+
}
|
|
2723
|
+
});
|
|
2724
|
+
assertNoExtraPositionals(parsed.positionals, 0);
|
|
2725
|
+
const statuses = ["Draft", "InProgress", "Live", "Migrated", "Disabled"];
|
|
2726
|
+
const status2 = parsed.values.status;
|
|
2727
|
+
if (status2 && !statuses.includes(status2)) {
|
|
2728
|
+
throw new CliError(`Invalid status: ${status2}`, 2);
|
|
2729
|
+
}
|
|
2730
|
+
const sortByValues = ["CREATED_DATE", "NAME"];
|
|
2731
|
+
const sortBy = parsed.values["sort-by"];
|
|
2732
|
+
if (sortBy && !sortByValues.includes(sortBy)) {
|
|
2733
|
+
throw new CliError(`Invalid sort order: ${sortBy}`, 2);
|
|
2734
|
+
}
|
|
2735
|
+
const directions = ["ASC", "DESC"];
|
|
2736
|
+
const sortDirection = parsed.values["sort-direction"];
|
|
2737
|
+
if (sortDirection && !directions.includes(sortDirection)) {
|
|
2738
|
+
throw new CliError(`Invalid sort direction: ${sortDirection}`, 2);
|
|
2739
|
+
}
|
|
2740
|
+
const types = parsed.values.type;
|
|
2741
|
+
if (types?.some((type) => !Object.values(CollectionType).includes(type))) {
|
|
2742
|
+
throw new CliError(`Invalid collection type: ${types.join(", ")}`, 2);
|
|
2743
|
+
}
|
|
2744
|
+
const blockchains = parsed.values.chain?.map((chainId) => {
|
|
2745
|
+
const value = positiveInteger(chainId, "--chain");
|
|
2746
|
+
if (value === undefined)
|
|
2747
|
+
throw new CliError("--chain requires a value", 2);
|
|
2748
|
+
return value;
|
|
2749
|
+
});
|
|
2750
|
+
const context = await createClientContext(runtime, global);
|
|
2751
|
+
const result = unwrap(await context.client.collection.list({
|
|
2752
|
+
blockchains,
|
|
2753
|
+
limit: positiveInteger(parsed.values.limit, "--limit"),
|
|
2754
|
+
page: positiveInteger(parsed.values.page, "--page"),
|
|
2755
|
+
sortBy,
|
|
2756
|
+
sortDirection,
|
|
2757
|
+
status: status2,
|
|
2758
|
+
testnet: parsed.values.testnet,
|
|
2759
|
+
types
|
|
2760
|
+
}));
|
|
2761
|
+
if (global.json)
|
|
2762
|
+
printJson(runtime, result);
|
|
2763
|
+
else
|
|
2764
|
+
printCollectionList(runtime, result);
|
|
2765
|
+
};
|
|
2766
|
+
var get = async (args, global, runtime) => {
|
|
2767
|
+
const parsed = parseCommandArgs(args, { options: {} });
|
|
2768
|
+
const highlightId = requiredPositional(parsed.positionals, 0, "highlight-id");
|
|
2769
|
+
assertNoExtraPositionals(parsed.positionals, 1);
|
|
2770
|
+
const context = await createClientContext(runtime, global);
|
|
2771
|
+
const result = unwrap(await context.client.collection.get({ highlightId }));
|
|
2772
|
+
if (global.json)
|
|
2773
|
+
printJson(runtime, result);
|
|
2774
|
+
else
|
|
2775
|
+
printCollection(runtime, result);
|
|
2776
|
+
};
|
|
2777
|
+
var create = async (args, global, runtime) => {
|
|
2778
|
+
const parsed = parseCommandArgs(args, {
|
|
2779
|
+
options: {
|
|
2780
|
+
input: { type: "string", short: "i" }
|
|
2781
|
+
}
|
|
2782
|
+
});
|
|
2783
|
+
assertNoExtraPositionals(parsed.positionals, 0);
|
|
2784
|
+
const inputPath = requiredInputPath(parsed.values.input);
|
|
2785
|
+
const input = await readTypedJsonInput(inputPath, runtime, isCollectionCreateInput, "a collection.create object containing name, description, logoMediaId, image, type, and valid contract details");
|
|
2786
|
+
const context = await createClientContext(runtime, global);
|
|
2787
|
+
const collection = unwrap(await context.client.collection.create(input));
|
|
2788
|
+
if (global.json) {
|
|
2789
|
+
printJson(runtime, collection);
|
|
2790
|
+
} else {
|
|
2791
|
+
runtime.stdout(`Created ${collection.name} (${collection.highlightId}) in Draft.`);
|
|
2792
|
+
runtime.stdout(`Type: ${collection.type}`);
|
|
2793
|
+
runtime.stdout(`Chain: ${collection.contract.chainId}`);
|
|
2794
|
+
}
|
|
2795
|
+
};
|
|
2796
|
+
var waitForDeployment = async (context, highlightId, timeoutSeconds, pollIntervalSeconds, runtime) => {
|
|
2797
|
+
const deadline = runtime.now() + timeoutSeconds * 1000;
|
|
2798
|
+
while (true) {
|
|
2799
|
+
const status2 = unwrap(await context.client.collection.deployStatus({ highlightId }));
|
|
2800
|
+
if (status2.status === "Completed" || status2.status === "Failed" || status2.currentStep === "AwaitTransaction") {
|
|
2801
|
+
return status2;
|
|
2802
|
+
}
|
|
2803
|
+
if (runtime.now() >= deadline) {
|
|
2804
|
+
throw new CliError(`Timed out waiting for deployment ${status2.deploymentId}`);
|
|
2805
|
+
}
|
|
2806
|
+
await runtime.sleep(pollIntervalSeconds * 1000);
|
|
2807
|
+
}
|
|
2808
|
+
};
|
|
2809
|
+
var deploy = async (args, global, runtime) => {
|
|
2810
|
+
const parsed = parseCommandArgs(args, {
|
|
2811
|
+
options: {
|
|
2812
|
+
"poll-interval": { type: "string" },
|
|
2813
|
+
timeout: { type: "string" },
|
|
2814
|
+
wait: { type: "boolean" }
|
|
2815
|
+
}
|
|
2816
|
+
});
|
|
2817
|
+
const highlightId = requiredPositional(parsed.positionals, 0, "highlight-id");
|
|
2818
|
+
assertNoExtraPositionals(parsed.positionals, 1);
|
|
2819
|
+
const context = await createClientContext(runtime, global);
|
|
2820
|
+
let status2 = unwrap(await context.client.collection.deploy({ highlightId }));
|
|
2821
|
+
if (parsed.values.wait) {
|
|
2822
|
+
status2 = await waitForDeployment(context, highlightId, positiveNumber(parsed.values.timeout, "--timeout") ?? 300, positiveNumber(parsed.values["poll-interval"], "--poll-interval") ?? 2, runtime);
|
|
2823
|
+
}
|
|
2824
|
+
if (global.json)
|
|
2825
|
+
printJson(runtime, status2);
|
|
2826
|
+
else
|
|
2827
|
+
printDeployStatus(runtime, status2);
|
|
2828
|
+
if (status2.status === "Failed") {
|
|
2829
|
+
throw new CliError(status2.error ?? "Deployment failed");
|
|
2830
|
+
}
|
|
2831
|
+
};
|
|
2832
|
+
var deployStatus = async (args, global, runtime) => {
|
|
2833
|
+
const parsed = parseCommandArgs(args, { options: {} });
|
|
2834
|
+
const highlightId = requiredPositional(parsed.positionals, 0, "highlight-id");
|
|
2835
|
+
assertNoExtraPositionals(parsed.positionals, 1);
|
|
2836
|
+
const context = await createClientContext(runtime, global);
|
|
2837
|
+
const status2 = unwrap(await context.client.collection.deployStatus({ highlightId }));
|
|
2838
|
+
if (global.json)
|
|
2839
|
+
printJson(runtime, status2);
|
|
2840
|
+
else
|
|
2841
|
+
printDeployStatus(runtime, status2);
|
|
2842
|
+
};
|
|
2843
|
+
var deployCancel = async (args, global, runtime) => {
|
|
2844
|
+
const parsed = parseCommandArgs(args, { options: {} });
|
|
2845
|
+
const highlightId = requiredPositional(parsed.positionals, 0, "highlight-id");
|
|
2846
|
+
assertNoExtraPositionals(parsed.positionals, 1);
|
|
2847
|
+
const context = await createClientContext(runtime, global);
|
|
2848
|
+
const status2 = unwrap(await context.client.collection.deployCancel({ highlightId }));
|
|
2849
|
+
if (global.json)
|
|
2850
|
+
printJson(runtime, status2);
|
|
2851
|
+
else
|
|
2852
|
+
runtime.stdout(`Cancelled deployment for ${status2.highlightId}.`);
|
|
2853
|
+
};
|
|
2854
|
+
|
|
2855
|
+
// src/commands/contracts.ts
|
|
2856
|
+
var list3 = async (args, global, runtime) => {
|
|
2857
|
+
const parsed = parseCommandArgs(args, {
|
|
2858
|
+
options: {
|
|
2859
|
+
cursor: { type: "string" },
|
|
2860
|
+
limit: { type: "string" }
|
|
2861
|
+
}
|
|
2862
|
+
});
|
|
2863
|
+
assertNoExtraPositionals(parsed.positionals, 0);
|
|
2864
|
+
const context = await createClientContext(runtime, global);
|
|
2865
|
+
const result = unwrap(await context.client.contract.list({
|
|
2866
|
+
cursor: parsed.values.cursor,
|
|
2867
|
+
limit: positiveInteger(parsed.values.limit, "--limit")
|
|
2868
|
+
}));
|
|
2869
|
+
if (global.json) {
|
|
2870
|
+
printJson(runtime, result);
|
|
2871
|
+
return;
|
|
2872
|
+
}
|
|
2873
|
+
printTable(runtime, ["ID", "NAME", "SYMBOL", "STANDARD", "TYPE", "CHAIN", "STATUS", "ADDRESS"], result.items.map((contract) => [
|
|
2874
|
+
contract.id,
|
|
2875
|
+
contract.name,
|
|
2876
|
+
contract.symbol,
|
|
2877
|
+
contract.standard,
|
|
2878
|
+
contract.type,
|
|
2879
|
+
contract.chainId,
|
|
2880
|
+
contract.status,
|
|
2881
|
+
contract.address
|
|
2882
|
+
]));
|
|
2883
|
+
if (result.pageInfo.hasNextPage && result.pageInfo.endCursor) {
|
|
2884
|
+
runtime.stdout(`Next cursor: ${result.pageInfo.endCursor}`);
|
|
2885
|
+
}
|
|
2886
|
+
};
|
|
2887
|
+
var get2 = async (args, global, runtime) => {
|
|
2888
|
+
const parsed = parseCommandArgs(args, { options: {} });
|
|
2889
|
+
const contractId = requiredPositional(parsed.positionals, 0, "contract-id");
|
|
2890
|
+
assertNoExtraPositionals(parsed.positionals, 1);
|
|
2891
|
+
const context = await createClientContext(runtime, global);
|
|
2892
|
+
const contract = unwrap(await context.client.contract.get({ contractId }));
|
|
2893
|
+
if (global.json) {
|
|
2894
|
+
printJson(runtime, contract);
|
|
2895
|
+
return;
|
|
2896
|
+
}
|
|
2897
|
+
runtime.stdout(`${contract.name} (${contract.id})`);
|
|
2898
|
+
runtime.stdout(`Symbol: ${contract.symbol}`);
|
|
2899
|
+
runtime.stdout(`Type: ${contract.type} / ${contract.standard}`);
|
|
2900
|
+
runtime.stdout(`Chain: ${contract.chainId}`);
|
|
2901
|
+
runtime.stdout(`Status: ${contract.status}`);
|
|
2902
|
+
runtime.stdout(`Address: ${contract.address ?? "not deployed"}`);
|
|
2903
|
+
};
|
|
2904
|
+
|
|
2905
|
+
// src/commands/gates.ts
|
|
2906
|
+
var isOptionalMatchMode = (value) => value === undefined || Object.values(GateMatchMode).includes(value);
|
|
2907
|
+
var isGateCondition = (value) => {
|
|
2908
|
+
if (!isRecord3(value) || !isRecord3(value.config))
|
|
2909
|
+
return false;
|
|
2910
|
+
const config = value.config;
|
|
2911
|
+
switch (value.type) {
|
|
2912
|
+
case "ALLOWLIST":
|
|
2913
|
+
return Array.isArray(config.addresses) && config.addresses.every((address) => typeof address === "string");
|
|
2914
|
+
case "TOKEN_OWNERSHIP":
|
|
2915
|
+
return typeof config.contractAddress === "string" && Number.isInteger(config.chainId) && (config.minAmount === undefined || Number.isInteger(config.minAmount));
|
|
2916
|
+
case "SPECIFIC_TOKEN":
|
|
2917
|
+
return typeof config.contractAddress === "string" && Number.isInteger(config.chainId) && typeof config.tokenId === "string";
|
|
2918
|
+
case "TOKEN_ATTRIBUTE":
|
|
2919
|
+
return typeof config.contractAddress === "string" && Number.isInteger(config.chainId) && typeof config.traitType === "string" && typeof config.traitValue === "string";
|
|
2920
|
+
case "CURRENCY_BALANCE":
|
|
2921
|
+
return Number.isInteger(config.chainId) && isOptionalString(config.contractAddress) && typeof config.minBalance === "string";
|
|
2922
|
+
case "FARCASTER_FOLLOW":
|
|
2923
|
+
return Number.isInteger(config.fid) && isOptionalString(config.username) && isOptionalString(config.displayName) && isOptionalString(config.pfpUrl);
|
|
2924
|
+
default:
|
|
2925
|
+
return false;
|
|
2926
|
+
}
|
|
2927
|
+
};
|
|
2928
|
+
var isGateCreateInput = (value) => isRecord3(value) && typeof value.name === "string" && isOptionalMatchMode(value.matchMode) && Array.isArray(value.conditions) && value.conditions.every(isGateCondition);
|
|
2929
|
+
var isGateUpdateInput = (value) => isRecord3(value) && ["name", "matchMode", "conditions"].some((field) => (field in value)) && isOptionalString(value.name) && isOptionalMatchMode(value.matchMode) && (value.conditions === undefined || Array.isArray(value.conditions) && value.conditions.every(isGateCondition));
|
|
2930
|
+
var printGate = (runtime, gate) => {
|
|
2931
|
+
runtime.stdout(`${gate.name} (${gate.id})`);
|
|
2932
|
+
runtime.stdout(`Match: ${gate.matchMode}`);
|
|
2933
|
+
runtime.stdout(`Conditions: ${gate.conditions.map((condition) => condition.type).join(", ")}`);
|
|
2934
|
+
};
|
|
2935
|
+
var list4 = async (args, global, runtime) => {
|
|
2936
|
+
const parsed = parseCommandArgs(args, { options: {} });
|
|
2937
|
+
assertNoExtraPositionals(parsed.positionals, 0);
|
|
2938
|
+
const context = await createClientContext(runtime, global);
|
|
2939
|
+
const gates = unwrap(await context.client.gate.list());
|
|
2940
|
+
if (global.json) {
|
|
2941
|
+
printJson(runtime, gates);
|
|
2942
|
+
return;
|
|
2943
|
+
}
|
|
2944
|
+
printTable(runtime, ["ID", "NAME", "MATCH", "CONDITIONS"], gates.map((gate) => [gate.id, gate.name, gate.matchMode, gate.conditions.length]));
|
|
2945
|
+
};
|
|
2946
|
+
var get3 = async (args, global, runtime) => {
|
|
2947
|
+
const parsed = parseCommandArgs(args, { options: {} });
|
|
2948
|
+
const gateId = requiredPositional(parsed.positionals, 0, "gate-id");
|
|
2949
|
+
assertNoExtraPositionals(parsed.positionals, 1);
|
|
2950
|
+
const context = await createClientContext(runtime, global);
|
|
2951
|
+
const gate = unwrap(await context.client.gate.get({ gateId }));
|
|
2952
|
+
if (global.json)
|
|
2953
|
+
printJson(runtime, gate);
|
|
2954
|
+
else
|
|
2955
|
+
printGate(runtime, gate);
|
|
2956
|
+
};
|
|
2957
|
+
var create2 = async (args, global, runtime) => {
|
|
2958
|
+
const parsed = parseCommandArgs(args, {
|
|
2959
|
+
options: {
|
|
2960
|
+
input: { type: "string", short: "i" }
|
|
2961
|
+
}
|
|
2962
|
+
});
|
|
2963
|
+
assertNoExtraPositionals(parsed.positionals, 0);
|
|
2964
|
+
const input = await readTypedJsonInput(requiredInputPath(parsed.values.input), runtime, isGateCreateInput, "a gate.create body with a name and valid conditions");
|
|
2965
|
+
const context = await createClientContext(runtime, global);
|
|
2966
|
+
const gate = unwrap(await context.client.gate.create(input));
|
|
2967
|
+
if (global.json)
|
|
2968
|
+
printJson(runtime, gate);
|
|
2969
|
+
else {
|
|
2970
|
+
runtime.stdout(`Created gate ${gate.name} (${gate.id}).`);
|
|
2971
|
+
runtime.stdout(`${gate.conditions.length} condition(s), matching ${gate.matchMode}.`);
|
|
2972
|
+
}
|
|
2973
|
+
};
|
|
2974
|
+
var update = async (args, global, runtime) => {
|
|
2975
|
+
const parsed = parseCommandArgs(args, {
|
|
2976
|
+
options: {
|
|
2977
|
+
input: { type: "string", short: "i" }
|
|
2978
|
+
}
|
|
2979
|
+
});
|
|
2980
|
+
const gateId = requiredPositional(parsed.positionals, 0, "gate-id");
|
|
2981
|
+
assertNoExtraPositionals(parsed.positionals, 1);
|
|
2982
|
+
const input = await readTypedJsonInput(requiredInputPath(parsed.values.input), runtime, isGateUpdateInput, "a non-empty gate.update body");
|
|
2983
|
+
const context = await createClientContext(runtime, global);
|
|
2984
|
+
const gate = unwrap(await context.client.gate.update({ gateId, ...input }));
|
|
2985
|
+
if (global.json)
|
|
2986
|
+
printJson(runtime, gate);
|
|
2987
|
+
else
|
|
2988
|
+
runtime.stdout(`Updated gate ${gate.name} (${gate.id}).`);
|
|
2989
|
+
};
|
|
2990
|
+
var remove = async (args, global, runtime) => {
|
|
2991
|
+
const parsed = parseCommandArgs(args, { options: {} });
|
|
2992
|
+
const gateId = requiredPositional(parsed.positionals, 0, "gate-id");
|
|
2993
|
+
assertNoExtraPositionals(parsed.positionals, 1);
|
|
2994
|
+
const context = await createClientContext(runtime, global);
|
|
2995
|
+
const result = unwrap(await context.client.gate.remove({ gateId }));
|
|
2996
|
+
if (global.json)
|
|
2997
|
+
printJson(runtime, { gateId, ...result });
|
|
2998
|
+
else
|
|
2999
|
+
runtime.stdout(`Deleted gate ${gateId}.`);
|
|
3000
|
+
};
|
|
3001
|
+
|
|
3002
|
+
// src/commands/media.ts
|
|
3003
|
+
import { readFile as readFile3, stat } from "node:fs/promises";
|
|
3004
|
+
import path3 from "node:path";
|
|
3005
|
+
var MIME_TYPES = {
|
|
3006
|
+
".css": "text/css",
|
|
3007
|
+
".gif": "image/gif",
|
|
3008
|
+
".html": "text/html",
|
|
3009
|
+
".jpeg": "image/jpeg",
|
|
3010
|
+
".jpg": "image/jpeg",
|
|
3011
|
+
".js": "text/javascript",
|
|
3012
|
+
".json": "application/json",
|
|
3013
|
+
".mp3": "audio/mpeg",
|
|
3014
|
+
".mp4": "video/mp4",
|
|
3015
|
+
".png": "image/png",
|
|
3016
|
+
".svg": "image/svg+xml",
|
|
3017
|
+
".webm": "video/webm",
|
|
3018
|
+
".webp": "image/webp",
|
|
3019
|
+
".zip": "application/zip"
|
|
3020
|
+
};
|
|
3021
|
+
var mimeTypeFor = (filePath) => MIME_TYPES[path3.extname(filePath).toLowerCase()] ?? "application/octet-stream";
|
|
3022
|
+
var parseResponseError = async (response) => {
|
|
3023
|
+
const text = await response.text();
|
|
3024
|
+
if (!text)
|
|
3025
|
+
return response.statusText;
|
|
3026
|
+
try {
|
|
3027
|
+
return JSON.parse(text);
|
|
3028
|
+
} catch {
|
|
3029
|
+
return text;
|
|
3030
|
+
}
|
|
3031
|
+
};
|
|
3032
|
+
var waitUntilReady = async (mediaId, initial, timeoutSeconds, pollIntervalSeconds, runtime, getMedia) => {
|
|
3033
|
+
const deadline = runtime.now() + timeoutSeconds * 1000;
|
|
3034
|
+
let media2 = initial;
|
|
3035
|
+
while (media2.status !== "Ready" && media2.status !== "Failed") {
|
|
3036
|
+
if (runtime.now() >= deadline) {
|
|
3037
|
+
throw new CliError(`Timed out waiting for media ${mediaId} to become ready`);
|
|
3038
|
+
}
|
|
3039
|
+
await runtime.sleep(pollIntervalSeconds * 1000);
|
|
3040
|
+
media2 = await getMedia();
|
|
3041
|
+
}
|
|
3042
|
+
if (media2.status === "Failed") {
|
|
3043
|
+
throw new CliError(`Media processing failed for ${mediaId}`);
|
|
3044
|
+
}
|
|
3045
|
+
return media2;
|
|
3046
|
+
};
|
|
3047
|
+
var upload = async (args, global, runtime) => {
|
|
3048
|
+
const parsed = parseCommandArgs(args, {
|
|
3049
|
+
options: {
|
|
3050
|
+
kind: { type: "string" },
|
|
3051
|
+
"mime-type": { type: "string" },
|
|
3052
|
+
"no-wait": { type: "boolean" },
|
|
3053
|
+
"poll-interval": { type: "string" },
|
|
3054
|
+
scope: { type: "string" },
|
|
3055
|
+
timeout: { type: "string" }
|
|
3056
|
+
}
|
|
3057
|
+
});
|
|
3058
|
+
const inputPath = requiredPositional(parsed.positionals, 0, "file");
|
|
3059
|
+
assertNoExtraPositionals(parsed.positionals, 1);
|
|
3060
|
+
const absolutePath = path3.resolve(runtime.cwd, inputPath);
|
|
3061
|
+
const fileStat = await stat(absolutePath);
|
|
3062
|
+
if (!fileStat.isFile()) {
|
|
3063
|
+
throw new CliError(`Media input must be a file: ${inputPath}`, 2);
|
|
3064
|
+
}
|
|
3065
|
+
const kindValue = parsed.values.kind?.toLowerCase() ?? "file";
|
|
3066
|
+
const kind = kindValue === "file" ? "File" /* File */ : kindValue === "directory" ? "Directory" /* Directory */ : undefined;
|
|
3067
|
+
if (!kind) {
|
|
3068
|
+
throw new CliError('--kind must be either "file" or "directory"', 2);
|
|
3069
|
+
}
|
|
3070
|
+
if (kind === "Directory" /* Directory */ && path3.extname(absolutePath).toLowerCase() !== ".zip") {
|
|
3071
|
+
throw new CliError("Directory media must be uploaded as a .zip file", 2);
|
|
3072
|
+
}
|
|
3073
|
+
const scopeValue = parsed.values.scope?.toLowerCase() ?? "collection";
|
|
3074
|
+
const scope = scopeValue === "collection" ? "Collection" /* Collection */ : scopeValue === "user" ? "User" /* User */ : undefined;
|
|
3075
|
+
if (!scope) {
|
|
3076
|
+
throw new CliError('--scope must be either "collection" or "user"', 2);
|
|
3077
|
+
}
|
|
3078
|
+
const context = await createClientContext(runtime, global);
|
|
3079
|
+
const session = unwrap(await context.client.media.createUploadSession({
|
|
3080
|
+
fileName: path3.basename(absolutePath),
|
|
3081
|
+
fileSize: fileStat.size,
|
|
3082
|
+
kind,
|
|
3083
|
+
mimeType: parsed.values["mime-type"] ?? mimeTypeFor(absolutePath),
|
|
3084
|
+
scope
|
|
3085
|
+
}));
|
|
3086
|
+
const headers = new Headers(session.upload.headers);
|
|
3087
|
+
if (!headers.has("authorization")) {
|
|
3088
|
+
headers.set("authorization", `Bearer ${context.apiKey}`);
|
|
3089
|
+
}
|
|
3090
|
+
const response = await runtime.fetch(session.upload.url, {
|
|
3091
|
+
body: await readFile3(absolutePath),
|
|
3092
|
+
headers,
|
|
3093
|
+
method: session.upload.method
|
|
3094
|
+
});
|
|
3095
|
+
if (!response.ok) {
|
|
3096
|
+
throw new ApiError(await parseResponseError(response), response.status);
|
|
3097
|
+
}
|
|
3098
|
+
let media2 = unwrap(await context.client.media.get({ mediaId: session.media.id }));
|
|
3099
|
+
if (!parsed.values["no-wait"]) {
|
|
3100
|
+
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 })));
|
|
3101
|
+
}
|
|
3102
|
+
const result = {
|
|
3103
|
+
media: media2,
|
|
3104
|
+
url: resolveMediaUrl(media2)
|
|
3105
|
+
};
|
|
3106
|
+
if (global.json)
|
|
3107
|
+
printJson(runtime, result);
|
|
3108
|
+
else
|
|
3109
|
+
printMedia(runtime, media2, result.url);
|
|
3110
|
+
};
|
|
3111
|
+
var get4 = async (args, global, runtime) => {
|
|
3112
|
+
const parsed = parseCommandArgs(args, { options: {} });
|
|
3113
|
+
const mediaId = requiredPositional(parsed.positionals, 0, "media-id");
|
|
3114
|
+
assertNoExtraPositionals(parsed.positionals, 1);
|
|
3115
|
+
const context = await createClientContext(runtime, global);
|
|
3116
|
+
const media2 = unwrap(await context.client.media.get({ mediaId }));
|
|
3117
|
+
const result = { media: media2, url: resolveMediaUrl(media2) };
|
|
3118
|
+
if (global.json)
|
|
3119
|
+
printJson(runtime, result);
|
|
3120
|
+
else
|
|
3121
|
+
printMedia(runtime, media2, result.url);
|
|
3122
|
+
};
|
|
3123
|
+
var publish = async (args, global, runtime) => {
|
|
3124
|
+
const parsed = parseCommandArgs(args, { options: {} });
|
|
3125
|
+
const mediaId = requiredPositional(parsed.positionals, 0, "media-id");
|
|
3126
|
+
assertNoExtraPositionals(parsed.positionals, 1);
|
|
3127
|
+
const context = await createClientContext(runtime, global);
|
|
3128
|
+
const media2 = unwrap(await context.client.media.publish({ mediaId }));
|
|
3129
|
+
const result = { media: media2, url: resolveMediaUrl(media2) };
|
|
3130
|
+
if (global.json)
|
|
3131
|
+
printJson(runtime, result);
|
|
3132
|
+
else
|
|
3133
|
+
printMedia(runtime, media2, result.url);
|
|
3134
|
+
};
|
|
3135
|
+
|
|
3136
|
+
// src/commands/sales.ts
|
|
3137
|
+
var isOptionalNumber = (value) => value === undefined || typeof value === "number" && Number.isFinite(value);
|
|
3138
|
+
var isOptionalBoolean = (value) => value === undefined || typeof value === "boolean";
|
|
3139
|
+
var isSaleCreateInput = (value) => {
|
|
3140
|
+
if (!isRecord3(value))
|
|
3141
|
+
return false;
|
|
3142
|
+
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);
|
|
3143
|
+
};
|
|
3144
|
+
var SALE_UPDATE_FIELDS = [
|
|
3145
|
+
"name",
|
|
3146
|
+
"startAt",
|
|
3147
|
+
"endAt",
|
|
3148
|
+
"price",
|
|
3149
|
+
"currency",
|
|
3150
|
+
"maxPerTransaction",
|
|
3151
|
+
"maxPerWallet",
|
|
3152
|
+
"maxTotal",
|
|
3153
|
+
"paymentRecipient",
|
|
3154
|
+
"paused",
|
|
3155
|
+
"collectorMessage",
|
|
3156
|
+
"customMintFee"
|
|
3157
|
+
];
|
|
3158
|
+
var isSaleUpdateInput = (value) => {
|
|
3159
|
+
if (!isRecord3(value) || !SALE_UPDATE_FIELDS.some((field) => (field in value)))
|
|
3160
|
+
return false;
|
|
3161
|
+
return isOptionalNullableString(value.name) && isOptionalString(value.startAt) && isOptionalNullableString(value.endAt) && isOptionalString(value.price) && isOptionalString(value.currency) && isOptionalNumber(value.maxPerTransaction) && isOptionalNumber(value.maxPerWallet) && isOptionalNumber(value.maxTotal) && isOptionalString(value.paymentRecipient) && isOptionalBoolean(value.paused) && isOptionalNullableString(value.collectorMessage) && isOptionalNullableString(value.customMintFee);
|
|
3162
|
+
};
|
|
3163
|
+
var list5 = async (args, global, runtime) => {
|
|
3164
|
+
const parsed = parseCommandArgs(args, { options: {} });
|
|
3165
|
+
const highlightId = requiredPositional(parsed.positionals, 0, "highlight-id");
|
|
3166
|
+
assertNoExtraPositionals(parsed.positionals, 1);
|
|
3167
|
+
const context = await createClientContext(runtime, global);
|
|
3168
|
+
const sales = unwrap(await context.client.collection.getSales({ highlightId }));
|
|
3169
|
+
if (global.json) {
|
|
3170
|
+
printJson(runtime, sales);
|
|
3171
|
+
return;
|
|
3172
|
+
}
|
|
3173
|
+
printTable(runtime, ["ID", "NAME", "TYPE", "ACCESS", "STATUS", "LIFECYCLE", "PRICE", "CURRENCY"], sales.map((sale) => [
|
|
3174
|
+
sale.id,
|
|
3175
|
+
sale.name,
|
|
3176
|
+
sale.type,
|
|
3177
|
+
sale.accessMode,
|
|
3178
|
+
sale.status,
|
|
3179
|
+
sale.lifecycle,
|
|
3180
|
+
sale.price,
|
|
3181
|
+
sale.currency.symbol
|
|
3182
|
+
]));
|
|
3183
|
+
};
|
|
3184
|
+
var create3 = async (args, global, runtime) => {
|
|
3185
|
+
const parsed = parseCommandArgs(args, {
|
|
3186
|
+
options: {
|
|
3187
|
+
input: { type: "string", short: "i" }
|
|
3188
|
+
}
|
|
3189
|
+
});
|
|
3190
|
+
const highlightId = requiredPositional(parsed.positionals, 0, "highlight-id");
|
|
3191
|
+
assertNoExtraPositionals(parsed.positionals, 1);
|
|
3192
|
+
const input = await readTypedJsonInput(requiredInputPath(parsed.values.input), runtime, isSaleCreateInput, "a collection.addSale body with type, schedule, price, limits, currency, and paymentRecipient");
|
|
3193
|
+
const context = await createClientContext(runtime, global);
|
|
3194
|
+
const result = unwrap(await context.client.collection.addSale({
|
|
3195
|
+
highlightId,
|
|
3196
|
+
...input
|
|
3197
|
+
}));
|
|
3198
|
+
if (global.json) {
|
|
3199
|
+
printJson(runtime, result);
|
|
3200
|
+
return;
|
|
3201
|
+
}
|
|
3202
|
+
runtime.stdout(`Created sale ${result.saleId}: ${result.status}.`);
|
|
3203
|
+
if (result.contractExecution) {
|
|
3204
|
+
runtime.stdout("Wallet signature required. Transaction payload:");
|
|
3205
|
+
runtime.stdout(JSON.stringify(result.contractExecution, null, 2));
|
|
3206
|
+
}
|
|
3207
|
+
};
|
|
3208
|
+
var update2 = async (args, global, runtime) => {
|
|
3209
|
+
const parsed = parseCommandArgs(args, {
|
|
3210
|
+
options: {
|
|
3211
|
+
input: { type: "string", short: "i" }
|
|
3212
|
+
}
|
|
3213
|
+
});
|
|
3214
|
+
const highlightId = requiredPositional(parsed.positionals, 0, "highlight-id");
|
|
3215
|
+
const saleId = requiredPositional(parsed.positionals, 1, "sale-id");
|
|
3216
|
+
assertNoExtraPositionals(parsed.positionals, 2);
|
|
3217
|
+
const input = await readTypedJsonInput(requiredInputPath(parsed.values.input), runtime, isSaleUpdateInput, "a non-empty collection.updateSale body");
|
|
3218
|
+
const context = await createClientContext(runtime, global);
|
|
3219
|
+
const result = unwrap(await context.client.collection.updateSale({
|
|
3220
|
+
highlightId,
|
|
3221
|
+
saleId,
|
|
3222
|
+
...input
|
|
3223
|
+
}));
|
|
3224
|
+
if (global.json) {
|
|
3225
|
+
printJson(runtime, result);
|
|
3226
|
+
return;
|
|
3227
|
+
}
|
|
3228
|
+
runtime.stdout(`Updated sale ${result.saleId} at ${result.updatedAt}.`);
|
|
3229
|
+
if (result.contractExecution) {
|
|
3230
|
+
runtime.stdout("Wallet signature required. Transaction payload:");
|
|
3231
|
+
runtime.stdout(JSON.stringify(result.contractExecution, null, 2));
|
|
3232
|
+
}
|
|
3233
|
+
};
|
|
3234
|
+
var remove2 = async (args, global, runtime) => {
|
|
3235
|
+
const parsed = parseCommandArgs(args, { options: {} });
|
|
3236
|
+
const highlightId = requiredPositional(parsed.positionals, 0, "highlight-id");
|
|
3237
|
+
const saleId = requiredPositional(parsed.positionals, 1, "sale-id");
|
|
3238
|
+
assertNoExtraPositionals(parsed.positionals, 2);
|
|
3239
|
+
const context = await createClientContext(runtime, global);
|
|
3240
|
+
unwrap(await context.client.collection.deleteSale({ highlightId, saleId }));
|
|
3241
|
+
if (global.json)
|
|
3242
|
+
printJson(runtime, { deleted: true, highlightId, saleId });
|
|
3243
|
+
else
|
|
3244
|
+
runtime.stdout(`Deleted sale ${saleId}.`);
|
|
3245
|
+
};
|
|
3246
|
+
|
|
3247
|
+
// src/commands/tokens.ts
|
|
3248
|
+
var list6 = async (args, global, runtime) => {
|
|
3249
|
+
const parsed = parseCommandArgs(args, {
|
|
3250
|
+
options: {
|
|
3251
|
+
attributes: { type: "string" },
|
|
3252
|
+
limit: { type: "string" },
|
|
3253
|
+
order: { type: "string" },
|
|
3254
|
+
owner: { type: "string" },
|
|
3255
|
+
page: { type: "string" },
|
|
3256
|
+
search: { type: "string" },
|
|
3257
|
+
sort: { type: "string" }
|
|
3258
|
+
}
|
|
3259
|
+
});
|
|
3260
|
+
const highlightId = requiredPositional(parsed.positionals, 0, "highlight-id");
|
|
3261
|
+
assertNoExtraPositionals(parsed.positionals, 1);
|
|
3262
|
+
const sorts = ["tokenId", "name", "mintedAt", "createdAt"];
|
|
3263
|
+
const sort = parsed.values.sort;
|
|
3264
|
+
if (sort && !sorts.includes(sort)) {
|
|
3265
|
+
throw new CliError(`Invalid token sort: ${sort}`, 2);
|
|
3266
|
+
}
|
|
3267
|
+
const orders = ["asc", "desc"];
|
|
3268
|
+
const order = parsed.values.order;
|
|
3269
|
+
if (order && !orders.includes(order)) {
|
|
3270
|
+
throw new CliError(`Invalid token order: ${order}`, 2);
|
|
3271
|
+
}
|
|
3272
|
+
if (parsed.values.attributes) {
|
|
3273
|
+
try {
|
|
3274
|
+
JSON.parse(parsed.values.attributes);
|
|
3275
|
+
} catch {
|
|
3276
|
+
throw new CliError("--attributes must be a JSON-encoded trait filter array", 2);
|
|
3277
|
+
}
|
|
3278
|
+
}
|
|
3279
|
+
const context = await createPublicClientContext(runtime, global);
|
|
3280
|
+
const result = unwrap(await context.client.token.list({
|
|
3281
|
+
attributes: parsed.values.attributes,
|
|
3282
|
+
highlightId,
|
|
3283
|
+
limit: positiveInteger(parsed.values.limit, "--limit"),
|
|
3284
|
+
order,
|
|
3285
|
+
ownerAddress: parsed.values.owner,
|
|
3286
|
+
page: positiveInteger(parsed.values.page, "--page"),
|
|
3287
|
+
search: parsed.values.search,
|
|
3288
|
+
sort
|
|
3289
|
+
}));
|
|
3290
|
+
if (global.json) {
|
|
3291
|
+
printJson(runtime, result);
|
|
3292
|
+
return;
|
|
3293
|
+
}
|
|
3294
|
+
printTable(runtime, ["TOKEN", "NAME", "STATUS", "MINTED", "IMAGE"], result.items.map((token) => [
|
|
3295
|
+
token.tokenId,
|
|
3296
|
+
token.name,
|
|
3297
|
+
token.status,
|
|
3298
|
+
token.mintedAt,
|
|
3299
|
+
resolveMediaUrl(token.imageMedia)
|
|
3300
|
+
]));
|
|
3301
|
+
runtime.stdout(`Page ${result.pageInfo.page}/${Math.max(result.pageInfo.totalPages, 1)} · ${result.pageInfo.totalCount} total`);
|
|
3302
|
+
};
|
|
3303
|
+
var get5 = async (args, global, runtime) => {
|
|
3304
|
+
const parsed = parseCommandArgs(args, { options: {} });
|
|
3305
|
+
const highlightId = requiredPositional(parsed.positionals, 0, "highlight-id");
|
|
3306
|
+
const tokenId = requiredPositional(parsed.positionals, 1, "token-id");
|
|
3307
|
+
assertNoExtraPositionals(parsed.positionals, 2);
|
|
3308
|
+
const context = await createPublicClientContext(runtime, global);
|
|
3309
|
+
const token = unwrap(await context.client.token.get({ highlightId, tokenId }));
|
|
3310
|
+
if (global.json) {
|
|
3311
|
+
printJson(runtime, token);
|
|
3312
|
+
return;
|
|
3313
|
+
}
|
|
3314
|
+
runtime.stdout(`${token.name ?? `Token ${token.tokenId}`} (${token.tokenId})`);
|
|
3315
|
+
runtime.stdout(`Status: ${token.status}`);
|
|
3316
|
+
runtime.stdout(`Image: ${resolveMediaUrl(token.imageMedia) ?? "unavailable"}`);
|
|
3317
|
+
runtime.stdout(`Animation: ${resolveMediaUrl(token.animationMedia) ?? "unavailable"}`);
|
|
3318
|
+
if (token.description)
|
|
3319
|
+
runtime.stdout(`Description: ${token.description}`);
|
|
3320
|
+
};
|
|
3321
|
+
var owners = async (args, global, runtime) => {
|
|
3322
|
+
const parsed = parseCommandArgs(args, { options: {} });
|
|
3323
|
+
const highlightId = requiredPositional(parsed.positionals, 0, "highlight-id");
|
|
3324
|
+
const tokenId = requiredPositional(parsed.positionals, 1, "token-id");
|
|
3325
|
+
assertNoExtraPositionals(parsed.positionals, 2);
|
|
3326
|
+
const context = await createPublicClientContext(runtime, global);
|
|
3327
|
+
const result = unwrap(await context.client.token.listOwners({ highlightId, tokenId }));
|
|
3328
|
+
if (global.json) {
|
|
3329
|
+
printJson(runtime, result);
|
|
3330
|
+
return;
|
|
3331
|
+
}
|
|
3332
|
+
printTable(runtime, ["OWNER", "BALANCE", "FIRST ACQUIRED"], result.owners.map((owner) => [owner.ownerAddress, owner.balance, owner.firstAcquiredAt]));
|
|
3333
|
+
};
|
|
3334
|
+
var facets = async (args, global, runtime) => {
|
|
3335
|
+
const parsed = parseCommandArgs(args, { options: {} });
|
|
3336
|
+
const highlightId = requiredPositional(parsed.positionals, 0, "highlight-id");
|
|
3337
|
+
assertNoExtraPositionals(parsed.positionals, 1);
|
|
3338
|
+
const context = await createPublicClientContext(runtime, global);
|
|
3339
|
+
const result = unwrap(await context.client.token.attributeFacets({ highlightId }));
|
|
3340
|
+
if (global.json) {
|
|
3341
|
+
printJson(runtime, result);
|
|
3342
|
+
return;
|
|
3343
|
+
}
|
|
3344
|
+
printTable(runtime, ["TRAIT", "VALUE", "COUNT"], result.facets.flatMap((facet) => facet.values.map((value) => [facet.traitType, value.value, value.count])));
|
|
3345
|
+
};
|
|
3346
|
+
var redrive = async (args, global, runtime) => {
|
|
3347
|
+
const parsed = parseCommandArgs(args, { options: {} });
|
|
3348
|
+
const highlightId = requiredPositional(parsed.positionals, 0, "highlight-id");
|
|
3349
|
+
assertNoExtraPositionals(parsed.positionals, 1);
|
|
3350
|
+
const context = await createClientContext(runtime, global);
|
|
3351
|
+
const result = unwrap(await context.client.token.redriveReveals({ highlightId }));
|
|
3352
|
+
if (global.json) {
|
|
3353
|
+
printJson(runtime, result);
|
|
3354
|
+
return;
|
|
3355
|
+
}
|
|
3356
|
+
runtime.stdout(`Scheduled ${result.scheduled}/${result.candidates} reveal candidates (${result.failed} failed).`);
|
|
3357
|
+
};
|
|
3358
|
+
|
|
3359
|
+
// src/runtime.ts
|
|
3360
|
+
import { homedir } from "node:os";
|
|
3361
|
+
import { createInterface } from "node:readline/promises";
|
|
3362
|
+
import { Writable } from "node:stream";
|
|
3363
|
+
var readStdin = async () => {
|
|
3364
|
+
const chunks = [];
|
|
3365
|
+
for await (const chunk of process.stdin) {
|
|
3366
|
+
chunks.push(Buffer.isBuffer(chunk) ? chunk : Buffer.from(String(chunk)));
|
|
3367
|
+
}
|
|
3368
|
+
return Buffer.concat(chunks).toString("utf8");
|
|
3369
|
+
};
|
|
3370
|
+
var promptSecret = async (prompt) => {
|
|
3371
|
+
let muted = false;
|
|
3372
|
+
const output = new Writable({
|
|
3373
|
+
write(chunk, _encoding, callback) {
|
|
3374
|
+
if (!muted)
|
|
3375
|
+
process.stderr.write(chunk);
|
|
3376
|
+
callback();
|
|
3377
|
+
}
|
|
3378
|
+
});
|
|
3379
|
+
const readline = createInterface({
|
|
3380
|
+
input: process.stdin,
|
|
3381
|
+
output,
|
|
3382
|
+
terminal: true
|
|
3383
|
+
});
|
|
3384
|
+
try {
|
|
3385
|
+
process.stderr.write(prompt);
|
|
3386
|
+
muted = true;
|
|
3387
|
+
return await readline.question("");
|
|
3388
|
+
} finally {
|
|
3389
|
+
readline.close();
|
|
3390
|
+
process.stderr.write(`
|
|
3391
|
+
`);
|
|
3392
|
+
}
|
|
3393
|
+
};
|
|
3394
|
+
var defaults = {
|
|
3395
|
+
cwd: process.cwd(),
|
|
3396
|
+
env: process.env,
|
|
3397
|
+
fetch: globalThis.fetch,
|
|
3398
|
+
homeDir: homedir(),
|
|
3399
|
+
now: () => Date.now(),
|
|
3400
|
+
promptSecret,
|
|
3401
|
+
readStdin,
|
|
3402
|
+
sleep: (milliseconds) => new Promise((resolve) => setTimeout(resolve, milliseconds)),
|
|
3403
|
+
stderr: (message) => process.stderr.write(`${message}
|
|
3404
|
+
`),
|
|
3405
|
+
stdout: (message) => process.stdout.write(`${message}
|
|
3406
|
+
`)
|
|
3407
|
+
};
|
|
3408
|
+
var createRuntime = (overrides = {}) => ({
|
|
3409
|
+
...defaults,
|
|
3410
|
+
...overrides
|
|
3411
|
+
});
|
|
3412
|
+
|
|
3413
|
+
// src/cli.ts
|
|
3414
|
+
var MAIN_HELP = `Highlight CLI
|
|
3415
|
+
|
|
3416
|
+
Usage:
|
|
3417
|
+
hl [global options] <command>
|
|
3418
|
+
|
|
3419
|
+
Commands:
|
|
3420
|
+
auth login Save and verify an API key
|
|
3421
|
+
auth status Verify the active credentials
|
|
3422
|
+
auth logout Remove a saved API key
|
|
3423
|
+
collections list List your collections
|
|
3424
|
+
collections get <highlight-id> Get a collection
|
|
3425
|
+
collections create --input <file> Create a draft from JSON
|
|
3426
|
+
collections deploy <id> Start a deployment
|
|
3427
|
+
collections deploy-status <id> Get deployment status
|
|
3428
|
+
collections deploy-cancel <id> Cancel a deployment
|
|
3429
|
+
sales list <collection-id> List collection sales
|
|
3430
|
+
sales create <id> --input <file> Create a sale
|
|
3431
|
+
sales update <id> <sale-id> Update a sale
|
|
3432
|
+
sales delete <id> <sale-id> Delete a draft sale
|
|
3433
|
+
gates list|get|create|update|delete Manage reusable access gates
|
|
3434
|
+
contracts list|get Inspect your contracts
|
|
3435
|
+
tokens list|get|owners|facets Inspect minted tokens
|
|
3436
|
+
tokens redrive <collection-id> Re-drive stuck token reveals
|
|
3437
|
+
chains list List supported chains
|
|
3438
|
+
chains system-contract <id> <type> Resolve a system contract
|
|
3439
|
+
media upload <file> Upload and process media
|
|
3440
|
+
media get <media-id> Get media details
|
|
3441
|
+
media publish <media-id> Publish media to the archive
|
|
3442
|
+
|
|
3443
|
+
Aliases:
|
|
3444
|
+
hl create ... hl collections create ...
|
|
3445
|
+
hl deploy ... hl collections deploy ...
|
|
3446
|
+
|
|
3447
|
+
Global options:
|
|
3448
|
+
--api-url <url> Override the Highlight API URL
|
|
3449
|
+
--profile <name> Use a named credential profile
|
|
3450
|
+
--json Print machine-readable JSON
|
|
3451
|
+
-h, --help Show help
|
|
3452
|
+
-v, --version Show version
|
|
3453
|
+
|
|
3454
|
+
Environment:
|
|
3455
|
+
HIGHLIGHT_API_KEY Override the saved API key
|
|
3456
|
+
HIGHLIGHT_API_URL Override the API URL
|
|
3457
|
+
HIGHLIGHT_CONFIG_DIR Override the config directory`;
|
|
3458
|
+
var AUTH_HELP = `Usage:
|
|
3459
|
+
hl auth login [--api-key <key> | --api-key-stdin]
|
|
3460
|
+
hl auth status
|
|
3461
|
+
hl auth logout
|
|
3462
|
+
|
|
3463
|
+
API keys are saved in a mode-0600 config file. HIGHLIGHT_API_KEY always takes
|
|
3464
|
+
precedence over saved credentials.`;
|
|
3465
|
+
var COLLECTIONS_HELP = `Usage:
|
|
3466
|
+
hl collections list [options]
|
|
3467
|
+
hl collections get <highlight-id>
|
|
3468
|
+
hl collections create --input <file|->
|
|
3469
|
+
hl collections deploy <highlight-id> [--wait]
|
|
3470
|
+
hl collections deploy-status <highlight-id>
|
|
3471
|
+
hl collections deploy-cancel <highlight-id>
|
|
3472
|
+
|
|
3473
|
+
List options:
|
|
3474
|
+
--page <number> Page number
|
|
3475
|
+
--limit <number> Page size
|
|
3476
|
+
--status <status> Draft, InProgress, Live, Migrated, Disabled
|
|
3477
|
+
--chain <chain-id> Filter by chain; repeatable
|
|
3478
|
+
--type <type> Filter by collection type; repeatable
|
|
3479
|
+
--testnet Return testnet collections
|
|
3480
|
+
--sort-by <CREATED_DATE|NAME>
|
|
3481
|
+
--sort-direction <ASC|DESC>
|
|
3482
|
+
|
|
3483
|
+
Deploy options:
|
|
3484
|
+
--wait Poll until completion or wallet action
|
|
3485
|
+
--timeout <seconds> Wait timeout (default: 300)
|
|
3486
|
+
--poll-interval <seconds> Poll interval (default: 2)`;
|
|
3487
|
+
var MEDIA_HELP = `Usage:
|
|
3488
|
+
hl media upload <file> [options]
|
|
3489
|
+
hl media get <media-id>
|
|
3490
|
+
hl media publish <media-id>
|
|
3491
|
+
|
|
3492
|
+
Upload options:
|
|
3493
|
+
--kind <file|directory> Directory inputs must be .zip files
|
|
3494
|
+
--scope <collection|user> Media scope (default: collection)
|
|
3495
|
+
--mime-type <type> Override inferred MIME type
|
|
3496
|
+
--no-wait Return before processing is ready
|
|
3497
|
+
--timeout <seconds> Wait timeout (default: 300)
|
|
3498
|
+
--poll-interval <seconds> Poll interval (default: 2)`;
|
|
3499
|
+
var SALES_HELP = `Usage:
|
|
3500
|
+
hl sales list <highlight-id>
|
|
3501
|
+
hl sales create <highlight-id> --input <file|->
|
|
3502
|
+
hl sales update <highlight-id> <sale-id> --input <file|->
|
|
3503
|
+
hl sales delete <highlight-id> <sale-id>
|
|
3504
|
+
|
|
3505
|
+
Create and update inputs use the SDK collection.addSale and
|
|
3506
|
+
collection.updateSale body shapes. Sale compatibility is validated by the API.`;
|
|
3507
|
+
var GATES_HELP = `Usage:
|
|
3508
|
+
hl gates list
|
|
3509
|
+
hl gates get <gate-id>
|
|
3510
|
+
hl gates create --input <file|->
|
|
3511
|
+
hl gates update <gate-id> --input <file|->
|
|
3512
|
+
hl gates delete <gate-id>
|
|
3513
|
+
|
|
3514
|
+
Create and update inputs use the SDK gate.create and gate.update body shapes.`;
|
|
3515
|
+
var CONTRACTS_HELP = `Usage:
|
|
3516
|
+
hl contracts list [--limit <number>] [--cursor <cursor>]
|
|
3517
|
+
hl contracts get <contract-id>`;
|
|
3518
|
+
var TOKENS_HELP = `Usage:
|
|
3519
|
+
hl tokens list <highlight-id> [options]
|
|
3520
|
+
hl tokens get <highlight-id> <token-id>
|
|
3521
|
+
hl tokens owners <highlight-id> <token-id>
|
|
3522
|
+
hl tokens facets <highlight-id>
|
|
3523
|
+
hl tokens redrive <highlight-id>
|
|
3524
|
+
|
|
3525
|
+
List options:
|
|
3526
|
+
--page <number>
|
|
3527
|
+
--limit <number>
|
|
3528
|
+
--sort <tokenId|name|mintedAt|createdAt>
|
|
3529
|
+
--order <asc|desc>
|
|
3530
|
+
--owner <address>
|
|
3531
|
+
--search <text>
|
|
3532
|
+
--attributes <json> Trait filters as a JSON-encoded array`;
|
|
3533
|
+
var CHAINS_HELP = `Usage:
|
|
3534
|
+
hl chains list [--mainnet | --testnet]
|
|
3535
|
+
hl chains system-contract <chain-id> <contract-type>`;
|
|
3536
|
+
var helpFor = (args) => {
|
|
3537
|
+
switch (args[0]) {
|
|
3538
|
+
case "auth":
|
|
3539
|
+
return AUTH_HELP;
|
|
3540
|
+
case "collection":
|
|
3541
|
+
case "collections":
|
|
3542
|
+
case "create":
|
|
3543
|
+
case "deploy":
|
|
3544
|
+
return COLLECTIONS_HELP;
|
|
3545
|
+
case "media":
|
|
3546
|
+
return MEDIA_HELP;
|
|
3547
|
+
case "sales":
|
|
3548
|
+
return SALES_HELP;
|
|
3549
|
+
case "gates":
|
|
3550
|
+
return GATES_HELP;
|
|
3551
|
+
case "contracts":
|
|
3552
|
+
return CONTRACTS_HELP;
|
|
3553
|
+
case "tokens":
|
|
3554
|
+
return TOKENS_HELP;
|
|
3555
|
+
case "chains":
|
|
3556
|
+
return CHAINS_HELP;
|
|
3557
|
+
default:
|
|
3558
|
+
return MAIN_HELP;
|
|
3559
|
+
}
|
|
3560
|
+
};
|
|
3561
|
+
var runCommand = async (args, global, runtime) => {
|
|
3562
|
+
const [command, subcommand, ...rest] = args;
|
|
3563
|
+
if (command === "auth") {
|
|
3564
|
+
if (subcommand === "login")
|
|
3565
|
+
return login(rest, global, runtime);
|
|
3566
|
+
if (subcommand === "status")
|
|
3567
|
+
return status(rest, global, runtime);
|
|
3568
|
+
if (subcommand === "logout")
|
|
3569
|
+
return logout(rest, global, runtime);
|
|
3570
|
+
throw new CliError(`Unknown auth command: ${subcommand ?? "(missing)"}`, 2);
|
|
3571
|
+
}
|
|
3572
|
+
if (command === "collections" || command === "collection") {
|
|
3573
|
+
if (subcommand === "list")
|
|
3574
|
+
return list2(rest, global, runtime);
|
|
3575
|
+
if (subcommand === "get")
|
|
3576
|
+
return get(rest, global, runtime);
|
|
3577
|
+
if (subcommand === "create")
|
|
3578
|
+
return create(rest, global, runtime);
|
|
3579
|
+
if (subcommand === "deploy")
|
|
3580
|
+
return deploy(rest, global, runtime);
|
|
3581
|
+
if (subcommand === "deploy-status")
|
|
3582
|
+
return deployStatus(rest, global, runtime);
|
|
3583
|
+
if (subcommand === "deploy-cancel")
|
|
3584
|
+
return deployCancel(rest, global, runtime);
|
|
3585
|
+
throw new CliError(`Unknown collections command: ${subcommand ?? "(missing)"}`, 2);
|
|
3586
|
+
}
|
|
3587
|
+
if (command === "media") {
|
|
3588
|
+
if (subcommand === "upload")
|
|
3589
|
+
return upload(rest, global, runtime);
|
|
3590
|
+
if (subcommand === "get")
|
|
3591
|
+
return get4(rest, global, runtime);
|
|
3592
|
+
if (subcommand === "publish")
|
|
3593
|
+
return publish(rest, global, runtime);
|
|
3594
|
+
throw new CliError(`Unknown media command: ${subcommand ?? "(missing)"}`, 2);
|
|
3595
|
+
}
|
|
3596
|
+
if (command === "sales") {
|
|
3597
|
+
if (subcommand === "list")
|
|
3598
|
+
return list5(rest, global, runtime);
|
|
3599
|
+
if (subcommand === "create")
|
|
3600
|
+
return create3(rest, global, runtime);
|
|
3601
|
+
if (subcommand === "update")
|
|
3602
|
+
return update2(rest, global, runtime);
|
|
3603
|
+
if (subcommand === "delete")
|
|
3604
|
+
return remove2(rest, global, runtime);
|
|
3605
|
+
throw new CliError(`Unknown sales command: ${subcommand ?? "(missing)"}`, 2);
|
|
3606
|
+
}
|
|
3607
|
+
if (command === "gates") {
|
|
3608
|
+
if (subcommand === "list")
|
|
3609
|
+
return list4(rest, global, runtime);
|
|
3610
|
+
if (subcommand === "get")
|
|
3611
|
+
return get3(rest, global, runtime);
|
|
3612
|
+
if (subcommand === "create")
|
|
3613
|
+
return create2(rest, global, runtime);
|
|
3614
|
+
if (subcommand === "update")
|
|
3615
|
+
return update(rest, global, runtime);
|
|
3616
|
+
if (subcommand === "delete")
|
|
3617
|
+
return remove(rest, global, runtime);
|
|
3618
|
+
throw new CliError(`Unknown gates command: ${subcommand ?? "(missing)"}`, 2);
|
|
3619
|
+
}
|
|
3620
|
+
if (command === "contracts") {
|
|
3621
|
+
if (subcommand === "list")
|
|
3622
|
+
return list3(rest, global, runtime);
|
|
3623
|
+
if (subcommand === "get")
|
|
3624
|
+
return get2(rest, global, runtime);
|
|
3625
|
+
throw new CliError(`Unknown contracts command: ${subcommand ?? "(missing)"}`, 2);
|
|
3626
|
+
}
|
|
3627
|
+
if (command === "tokens") {
|
|
3628
|
+
if (subcommand === "list")
|
|
3629
|
+
return list6(rest, global, runtime);
|
|
3630
|
+
if (subcommand === "get")
|
|
3631
|
+
return get5(rest, global, runtime);
|
|
3632
|
+
if (subcommand === "owners")
|
|
3633
|
+
return owners(rest, global, runtime);
|
|
3634
|
+
if (subcommand === "facets")
|
|
3635
|
+
return facets(rest, global, runtime);
|
|
3636
|
+
if (subcommand === "redrive")
|
|
3637
|
+
return redrive(rest, global, runtime);
|
|
3638
|
+
throw new CliError(`Unknown tokens command: ${subcommand ?? "(missing)"}`, 2);
|
|
3639
|
+
}
|
|
3640
|
+
if (command === "chains") {
|
|
3641
|
+
if (subcommand === "list")
|
|
3642
|
+
return list(rest, global, runtime);
|
|
3643
|
+
if (subcommand === "system-contract")
|
|
3644
|
+
return systemContract(rest, global, runtime);
|
|
3645
|
+
throw new CliError(`Unknown chains command: ${subcommand ?? "(missing)"}`, 2);
|
|
3646
|
+
}
|
|
3647
|
+
if (command === "create") {
|
|
3648
|
+
return create(args.slice(1), global, runtime);
|
|
3649
|
+
}
|
|
3650
|
+
if (command === "deploy") {
|
|
3651
|
+
return deploy(args.slice(1), global, runtime);
|
|
3652
|
+
}
|
|
3653
|
+
throw new CliError(`Unknown command: ${command ?? "(missing)"}`, 2);
|
|
3654
|
+
};
|
|
3655
|
+
var runCli = async (argv, runtimeOverrides = {}) => {
|
|
3656
|
+
const runtime = createRuntime(runtimeOverrides);
|
|
3657
|
+
let extracted;
|
|
3658
|
+
try {
|
|
3659
|
+
extracted = extractGlobalOptions(argv);
|
|
3660
|
+
} catch (error) {
|
|
3661
|
+
runtime.stderr(`Error: ${toErrorMessage(error)}`);
|
|
3662
|
+
return error instanceof CliError ? error.exitCode : 1;
|
|
3663
|
+
}
|
|
3664
|
+
const { args, global } = extracted;
|
|
3665
|
+
if (global.version) {
|
|
3666
|
+
runtime.stdout(package_default.version);
|
|
3667
|
+
return 0;
|
|
3668
|
+
}
|
|
3669
|
+
if (global.help || args.length === 0) {
|
|
3670
|
+
runtime.stdout(helpFor(args));
|
|
3671
|
+
return 0;
|
|
3672
|
+
}
|
|
3673
|
+
try {
|
|
3674
|
+
await runCommand(args, global, runtime);
|
|
3675
|
+
return 0;
|
|
3676
|
+
} catch (error) {
|
|
3677
|
+
if (global.json) {
|
|
3678
|
+
const payload = {
|
|
3679
|
+
error: toErrorMessage(error)
|
|
3680
|
+
};
|
|
3681
|
+
if (error instanceof ApiError) {
|
|
3682
|
+
payload.details = error.details;
|
|
3683
|
+
payload.status = error.status;
|
|
3684
|
+
}
|
|
3685
|
+
runtime.stderr(JSON.stringify(payload, null, 2));
|
|
3686
|
+
} else {
|
|
3687
|
+
runtime.stderr(`Error: ${toErrorMessage(error)}`);
|
|
3688
|
+
}
|
|
3689
|
+
return error instanceof CliError ? error.exitCode : 1;
|
|
3690
|
+
}
|
|
3691
|
+
};
|
|
3692
|
+
|
|
3693
|
+
// src/index.ts
|
|
3694
|
+
process.exitCode = await runCli(process.argv.slice(2));
|