@displaydev/cli 0.6.0 → 0.7.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 +32 -0
- package/dist/api-client.js +228 -4
- package/dist/config.js +220 -0
- package/dist/main-helpers.js +687 -0
- package/dist/main.js +572 -340
- package/dist/mcp-server.js +296 -117
- package/package.json +3 -2
|
@@ -0,0 +1,687 @@
|
|
|
1
|
+
function _assert_this_initialized(self) {
|
|
2
|
+
if (self === void 0) {
|
|
3
|
+
throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
|
|
4
|
+
}
|
|
5
|
+
return self;
|
|
6
|
+
}
|
|
7
|
+
function _async_iterator(iterable) {
|
|
8
|
+
var method, async, sync, retry = 2;
|
|
9
|
+
for("undefined" != typeof Symbol && (async = Symbol.asyncIterator, sync = Symbol.iterator); retry--;){
|
|
10
|
+
if (async && null != (method = iterable[async])) return method.call(iterable);
|
|
11
|
+
if (sync && null != (method = iterable[sync])) return new AsyncFromSyncIterator(method.call(iterable));
|
|
12
|
+
async = "@@asyncIterator", sync = "@@iterator";
|
|
13
|
+
}
|
|
14
|
+
throw new TypeError("Object is not async iterable");
|
|
15
|
+
}
|
|
16
|
+
function AsyncFromSyncIterator(s) {
|
|
17
|
+
function AsyncFromSyncIteratorContinuation(r) {
|
|
18
|
+
if (Object(r) !== r) return Promise.reject(new TypeError(r + " is not an object."));
|
|
19
|
+
var done = r.done;
|
|
20
|
+
return Promise.resolve(r.value).then(function(value) {
|
|
21
|
+
return {
|
|
22
|
+
value: value,
|
|
23
|
+
done: done
|
|
24
|
+
};
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
return AsyncFromSyncIterator = function(s) {
|
|
28
|
+
this.s = s, this.n = s.next;
|
|
29
|
+
}, AsyncFromSyncIterator.prototype = {
|
|
30
|
+
s: null,
|
|
31
|
+
n: null,
|
|
32
|
+
next: function() {
|
|
33
|
+
return AsyncFromSyncIteratorContinuation(this.n.apply(this.s, arguments));
|
|
34
|
+
},
|
|
35
|
+
return: function(value) {
|
|
36
|
+
var ret = this.s.return;
|
|
37
|
+
return void 0 === ret ? Promise.resolve({
|
|
38
|
+
value: value,
|
|
39
|
+
done: !0
|
|
40
|
+
}) : AsyncFromSyncIteratorContinuation(ret.apply(this.s, arguments));
|
|
41
|
+
},
|
|
42
|
+
throw: function(value) {
|
|
43
|
+
var thr = this.s.return;
|
|
44
|
+
return void 0 === thr ? Promise.reject(value) : AsyncFromSyncIteratorContinuation(thr.apply(this.s, arguments));
|
|
45
|
+
}
|
|
46
|
+
}, new AsyncFromSyncIterator(s);
|
|
47
|
+
}
|
|
48
|
+
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
|
|
49
|
+
try {
|
|
50
|
+
var info = gen[key](arg);
|
|
51
|
+
var value = info.value;
|
|
52
|
+
} catch (error) {
|
|
53
|
+
reject(error);
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
if (info.done) {
|
|
57
|
+
resolve(value);
|
|
58
|
+
} else {
|
|
59
|
+
Promise.resolve(value).then(_next, _throw);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
function _async_to_generator(fn) {
|
|
63
|
+
return function() {
|
|
64
|
+
var self = this, args = arguments;
|
|
65
|
+
return new Promise(function(resolve, reject) {
|
|
66
|
+
var gen = fn.apply(self, args);
|
|
67
|
+
function _next(value) {
|
|
68
|
+
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
|
|
69
|
+
}
|
|
70
|
+
function _throw(err) {
|
|
71
|
+
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
|
|
72
|
+
}
|
|
73
|
+
_next(undefined);
|
|
74
|
+
});
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
function _call_super(_this, derived, args) {
|
|
78
|
+
derived = _get_prototype_of(derived);
|
|
79
|
+
return _possible_constructor_return(_this, _is_native_reflect_construct() ? Reflect.construct(derived, args || [], _get_prototype_of(_this).constructor) : derived.apply(_this, args));
|
|
80
|
+
}
|
|
81
|
+
function _class_call_check(instance, Constructor) {
|
|
82
|
+
if (!(instance instanceof Constructor)) {
|
|
83
|
+
throw new TypeError("Cannot call a class as a function");
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
function _construct(Parent, args, Class) {
|
|
87
|
+
if (_is_native_reflect_construct()) {
|
|
88
|
+
_construct = Reflect.construct;
|
|
89
|
+
} else {
|
|
90
|
+
_construct = function construct(Parent, args, Class) {
|
|
91
|
+
var a = [
|
|
92
|
+
null
|
|
93
|
+
];
|
|
94
|
+
a.push.apply(a, args);
|
|
95
|
+
var Constructor = Function.bind.apply(Parent, a);
|
|
96
|
+
var instance = new Constructor();
|
|
97
|
+
if (Class) _set_prototype_of(instance, Class.prototype);
|
|
98
|
+
return instance;
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
return _construct.apply(null, arguments);
|
|
102
|
+
}
|
|
103
|
+
function _define_property(obj, key, value) {
|
|
104
|
+
if (key in obj) {
|
|
105
|
+
Object.defineProperty(obj, key, {
|
|
106
|
+
value: value,
|
|
107
|
+
enumerable: true,
|
|
108
|
+
configurable: true,
|
|
109
|
+
writable: true
|
|
110
|
+
});
|
|
111
|
+
} else {
|
|
112
|
+
obj[key] = value;
|
|
113
|
+
}
|
|
114
|
+
return obj;
|
|
115
|
+
}
|
|
116
|
+
function _get_prototype_of(o) {
|
|
117
|
+
_get_prototype_of = Object.setPrototypeOf ? Object.getPrototypeOf : function getPrototypeOf(o) {
|
|
118
|
+
return o.__proto__ || Object.getPrototypeOf(o);
|
|
119
|
+
};
|
|
120
|
+
return _get_prototype_of(o);
|
|
121
|
+
}
|
|
122
|
+
function _inherits(subClass, superClass) {
|
|
123
|
+
if (typeof superClass !== "function" && superClass !== null) {
|
|
124
|
+
throw new TypeError("Super expression must either be null or a function");
|
|
125
|
+
}
|
|
126
|
+
subClass.prototype = Object.create(superClass && superClass.prototype, {
|
|
127
|
+
constructor: {
|
|
128
|
+
value: subClass,
|
|
129
|
+
writable: true,
|
|
130
|
+
configurable: true
|
|
131
|
+
}
|
|
132
|
+
});
|
|
133
|
+
if (superClass) _set_prototype_of(subClass, superClass);
|
|
134
|
+
}
|
|
135
|
+
function _is_native_function(fn) {
|
|
136
|
+
return Function.toString.call(fn).indexOf("[native code]") !== -1;
|
|
137
|
+
}
|
|
138
|
+
function _possible_constructor_return(self, call) {
|
|
139
|
+
if (call && (_type_of(call) === "object" || typeof call === "function")) {
|
|
140
|
+
return call;
|
|
141
|
+
}
|
|
142
|
+
return _assert_this_initialized(self);
|
|
143
|
+
}
|
|
144
|
+
function _set_prototype_of(o, p) {
|
|
145
|
+
_set_prototype_of = Object.setPrototypeOf || function setPrototypeOf(o, p) {
|
|
146
|
+
o.__proto__ = p;
|
|
147
|
+
return o;
|
|
148
|
+
};
|
|
149
|
+
return _set_prototype_of(o, p);
|
|
150
|
+
}
|
|
151
|
+
function _type_of(obj) {
|
|
152
|
+
"@swc/helpers - typeof";
|
|
153
|
+
return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
|
|
154
|
+
}
|
|
155
|
+
function _wrap_native_super(Class) {
|
|
156
|
+
var _cache = typeof Map === "function" ? new Map() : undefined;
|
|
157
|
+
_wrap_native_super = function wrapNativeSuper(Class) {
|
|
158
|
+
if (Class === null || !_is_native_function(Class)) return Class;
|
|
159
|
+
if (typeof Class !== "function") {
|
|
160
|
+
throw new TypeError("Super expression must either be null or a function");
|
|
161
|
+
}
|
|
162
|
+
if (typeof _cache !== "undefined") {
|
|
163
|
+
if (_cache.has(Class)) return _cache.get(Class);
|
|
164
|
+
_cache.set(Class, Wrapper);
|
|
165
|
+
}
|
|
166
|
+
function Wrapper() {
|
|
167
|
+
return _construct(Class, arguments, _get_prototype_of(this).constructor);
|
|
168
|
+
}
|
|
169
|
+
Wrapper.prototype = Object.create(Class.prototype, {
|
|
170
|
+
constructor: {
|
|
171
|
+
value: Wrapper,
|
|
172
|
+
enumerable: false,
|
|
173
|
+
writable: true,
|
|
174
|
+
configurable: true
|
|
175
|
+
}
|
|
176
|
+
});
|
|
177
|
+
return _set_prototype_of(Wrapper, Class);
|
|
178
|
+
};
|
|
179
|
+
return _wrap_native_super(Class);
|
|
180
|
+
}
|
|
181
|
+
function _is_native_reflect_construct() {
|
|
182
|
+
try {
|
|
183
|
+
var result = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {}));
|
|
184
|
+
} catch (_) {}
|
|
185
|
+
return (_is_native_reflect_construct = function() {
|
|
186
|
+
return !!result;
|
|
187
|
+
})();
|
|
188
|
+
}
|
|
189
|
+
function _ts_generator(thisArg, body) {
|
|
190
|
+
var f, y, t, _ = {
|
|
191
|
+
label: 0,
|
|
192
|
+
sent: function() {
|
|
193
|
+
if (t[0] & 1) throw t[1];
|
|
194
|
+
return t[1];
|
|
195
|
+
},
|
|
196
|
+
trys: [],
|
|
197
|
+
ops: []
|
|
198
|
+
}, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype), d = Object.defineProperty;
|
|
199
|
+
return d(g, "next", {
|
|
200
|
+
value: verb(0)
|
|
201
|
+
}), d(g, "throw", {
|
|
202
|
+
value: verb(1)
|
|
203
|
+
}), d(g, "return", {
|
|
204
|
+
value: verb(2)
|
|
205
|
+
}), typeof Symbol === "function" && d(g, Symbol.iterator, {
|
|
206
|
+
value: function() {
|
|
207
|
+
return this;
|
|
208
|
+
}
|
|
209
|
+
}), g;
|
|
210
|
+
function verb(n) {
|
|
211
|
+
return function(v) {
|
|
212
|
+
return step([
|
|
213
|
+
n,
|
|
214
|
+
v
|
|
215
|
+
]);
|
|
216
|
+
};
|
|
217
|
+
}
|
|
218
|
+
function step(op) {
|
|
219
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
220
|
+
while(g && (g = 0, op[0] && (_ = 0)), _)try {
|
|
221
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
222
|
+
if (y = 0, t) op = [
|
|
223
|
+
op[0] & 2,
|
|
224
|
+
t.value
|
|
225
|
+
];
|
|
226
|
+
switch(op[0]){
|
|
227
|
+
case 0:
|
|
228
|
+
case 1:
|
|
229
|
+
t = op;
|
|
230
|
+
break;
|
|
231
|
+
case 4:
|
|
232
|
+
_.label++;
|
|
233
|
+
return {
|
|
234
|
+
value: op[1],
|
|
235
|
+
done: false
|
|
236
|
+
};
|
|
237
|
+
case 5:
|
|
238
|
+
_.label++;
|
|
239
|
+
y = op[1];
|
|
240
|
+
op = [
|
|
241
|
+
0
|
|
242
|
+
];
|
|
243
|
+
continue;
|
|
244
|
+
case 7:
|
|
245
|
+
op = _.ops.pop();
|
|
246
|
+
_.trys.pop();
|
|
247
|
+
continue;
|
|
248
|
+
default:
|
|
249
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
|
|
250
|
+
_ = 0;
|
|
251
|
+
continue;
|
|
252
|
+
}
|
|
253
|
+
if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
|
|
254
|
+
_.label = op[1];
|
|
255
|
+
break;
|
|
256
|
+
}
|
|
257
|
+
if (op[0] === 6 && _.label < t[1]) {
|
|
258
|
+
_.label = t[1];
|
|
259
|
+
t = op;
|
|
260
|
+
break;
|
|
261
|
+
}
|
|
262
|
+
if (t && _.label < t[2]) {
|
|
263
|
+
_.label = t[2];
|
|
264
|
+
_.ops.push(op);
|
|
265
|
+
break;
|
|
266
|
+
}
|
|
267
|
+
if (t[2]) _.ops.pop();
|
|
268
|
+
_.trys.pop();
|
|
269
|
+
continue;
|
|
270
|
+
}
|
|
271
|
+
op = body.call(thisArg, _);
|
|
272
|
+
} catch (e) {
|
|
273
|
+
op = [
|
|
274
|
+
6,
|
|
275
|
+
e
|
|
276
|
+
];
|
|
277
|
+
y = 0;
|
|
278
|
+
} finally{
|
|
279
|
+
f = t = 0;
|
|
280
|
+
}
|
|
281
|
+
if (op[0] & 5) throw op[1];
|
|
282
|
+
return {
|
|
283
|
+
value: op[0] ? op[1] : void 0,
|
|
284
|
+
done: true
|
|
285
|
+
};
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
import { extname } from 'node:path';
|
|
289
|
+
export var DEFAULT_API_URL = 'https://api.display.dev';
|
|
290
|
+
export var InvalidFlagError = /*#__PURE__*/ function(Error1) {
|
|
291
|
+
"use strict";
|
|
292
|
+
_inherits(InvalidFlagError, Error1);
|
|
293
|
+
function InvalidFlagError(flag, value) {
|
|
294
|
+
_class_call_check(this, InvalidFlagError);
|
|
295
|
+
var _this;
|
|
296
|
+
_this = _call_super(this, InvalidFlagError, [
|
|
297
|
+
"invalid ".concat(flag, ": ").concat(value)
|
|
298
|
+
]), _define_property(_this, "flag", void 0), _define_property(_this, "value", void 0), _this.flag = flag, _this.value = value;
|
|
299
|
+
_this.name = 'InvalidFlagError';
|
|
300
|
+
return _this;
|
|
301
|
+
}
|
|
302
|
+
return InvalidFlagError;
|
|
303
|
+
}(_wrap_native_super(Error));
|
|
304
|
+
export var PublishArgsError = /*#__PURE__*/ function(Error1) {
|
|
305
|
+
"use strict";
|
|
306
|
+
_inherits(PublishArgsError, Error1);
|
|
307
|
+
function PublishArgsError(message) {
|
|
308
|
+
_class_call_check(this, PublishArgsError);
|
|
309
|
+
var _this;
|
|
310
|
+
_this = _call_super(this, PublishArgsError, [
|
|
311
|
+
message
|
|
312
|
+
]);
|
|
313
|
+
_this.name = 'PublishArgsError';
|
|
314
|
+
return _this;
|
|
315
|
+
}
|
|
316
|
+
return PublishArgsError;
|
|
317
|
+
}(_wrap_native_super(Error));
|
|
318
|
+
export var DeviceCodeExpiredError = /*#__PURE__*/ function(Error1) {
|
|
319
|
+
"use strict";
|
|
320
|
+
_inherits(DeviceCodeExpiredError, Error1);
|
|
321
|
+
function DeviceCodeExpiredError() {
|
|
322
|
+
_class_call_check(this, DeviceCodeExpiredError);
|
|
323
|
+
var _this;
|
|
324
|
+
_this = _call_super(this, DeviceCodeExpiredError, [
|
|
325
|
+
'device code expired'
|
|
326
|
+
]);
|
|
327
|
+
_this.name = 'DeviceCodeExpiredError';
|
|
328
|
+
return _this;
|
|
329
|
+
}
|
|
330
|
+
return DeviceCodeExpiredError;
|
|
331
|
+
}(_wrap_native_super(Error));
|
|
332
|
+
export var DeviceCodeDeniedError = /*#__PURE__*/ function(Error1) {
|
|
333
|
+
"use strict";
|
|
334
|
+
_inherits(DeviceCodeDeniedError, Error1);
|
|
335
|
+
function DeviceCodeDeniedError() {
|
|
336
|
+
_class_call_check(this, DeviceCodeDeniedError);
|
|
337
|
+
var _this;
|
|
338
|
+
_this = _call_super(this, DeviceCodeDeniedError, [
|
|
339
|
+
'authentication denied'
|
|
340
|
+
]);
|
|
341
|
+
_this.name = 'DeviceCodeDeniedError';
|
|
342
|
+
return _this;
|
|
343
|
+
}
|
|
344
|
+
return DeviceCodeDeniedError;
|
|
345
|
+
}(_wrap_native_super(Error));
|
|
346
|
+
export var DeviceCodeFailedError = /*#__PURE__*/ function(Error1) {
|
|
347
|
+
"use strict";
|
|
348
|
+
_inherits(DeviceCodeFailedError, Error1);
|
|
349
|
+
function DeviceCodeFailedError(message) {
|
|
350
|
+
_class_call_check(this, DeviceCodeFailedError);
|
|
351
|
+
var _this;
|
|
352
|
+
_this = _call_super(this, DeviceCodeFailedError, [
|
|
353
|
+
message
|
|
354
|
+
]);
|
|
355
|
+
_this.name = 'DeviceCodeFailedError';
|
|
356
|
+
return _this;
|
|
357
|
+
}
|
|
358
|
+
return DeviceCodeFailedError;
|
|
359
|
+
}(_wrap_native_super(Error));
|
|
360
|
+
export function readApiKeyFromTty(input, output) {
|
|
361
|
+
return new Promise(function(resolve, reject) {
|
|
362
|
+
var buffer = '';
|
|
363
|
+
input.setRawMode(true);
|
|
364
|
+
input.resume();
|
|
365
|
+
input.setEncoding('utf8');
|
|
366
|
+
var cleanup = function cleanup() {
|
|
367
|
+
input.setRawMode(false);
|
|
368
|
+
input.pause();
|
|
369
|
+
input.off('data', onData);
|
|
370
|
+
};
|
|
371
|
+
var onData = function onData(ch) {
|
|
372
|
+
if (ch === '\r' || ch === '\n') {
|
|
373
|
+
cleanup();
|
|
374
|
+
output.write('\n');
|
|
375
|
+
resolve(buffer);
|
|
376
|
+
} else if (ch === '\u0003') {
|
|
377
|
+
cleanup();
|
|
378
|
+
output.write('\n');
|
|
379
|
+
reject(new Error('cancelled'));
|
|
380
|
+
} else if (ch === '\u007F' || ch === '\b') {
|
|
381
|
+
if (buffer.length > 0) {
|
|
382
|
+
buffer = buffer.slice(0, -1);
|
|
383
|
+
}
|
|
384
|
+
} else {
|
|
385
|
+
buffer += ch;
|
|
386
|
+
}
|
|
387
|
+
};
|
|
388
|
+
input.on('data', onData);
|
|
389
|
+
});
|
|
390
|
+
}
|
|
391
|
+
export function resolveAuth(env, config) {
|
|
392
|
+
var _ref, _env_DISPLAYDEV_API_URL;
|
|
393
|
+
// Truthy (not nullish) for the key: an empty DISPLAYDEV_API_KEY must fall
|
|
394
|
+
// back to config.token, matching the shipped CLI which treated env as missing.
|
|
395
|
+
var apiKey = env.DISPLAYDEV_API_KEY || (config === null || config === void 0 ? void 0 : config.token);
|
|
396
|
+
if (!apiKey) {
|
|
397
|
+
return null;
|
|
398
|
+
}
|
|
399
|
+
var apiUrl = (_ref = (_env_DISPLAYDEV_API_URL = env.DISPLAYDEV_API_URL) !== null && _env_DISPLAYDEV_API_URL !== void 0 ? _env_DISPLAYDEV_API_URL : config === null || config === void 0 ? void 0 : config.apiUrl) !== null && _ref !== void 0 ? _ref : DEFAULT_API_URL;
|
|
400
|
+
return {
|
|
401
|
+
apiKey: apiKey,
|
|
402
|
+
apiUrl: apiUrl
|
|
403
|
+
};
|
|
404
|
+
}
|
|
405
|
+
export function classifyBrandingError(message) {
|
|
406
|
+
return /paid plan|upgrade/i.test(message) ? 'paid-plan' : 'other';
|
|
407
|
+
}
|
|
408
|
+
/**
|
|
409
|
+
* Parse `dsp export` arguments of the form `<shortId>` or
|
|
410
|
+
* `<shortId>@<version>` (where version is a positive integer). Returns
|
|
411
|
+
* `null` for malformed input so the caller can emit a usage error.
|
|
412
|
+
*/ export function parseShortIdAndVersion(raw) {
|
|
413
|
+
var at = raw.indexOf('@');
|
|
414
|
+
if (at === -1) {
|
|
415
|
+
if (!raw) {
|
|
416
|
+
return null;
|
|
417
|
+
}
|
|
418
|
+
return {
|
|
419
|
+
shortId: raw
|
|
420
|
+
};
|
|
421
|
+
}
|
|
422
|
+
var shortId = raw.slice(0, at);
|
|
423
|
+
var versionStr = raw.slice(at + 1);
|
|
424
|
+
if (!shortId || !/^[1-9]\d*$/.test(versionStr)) {
|
|
425
|
+
return null;
|
|
426
|
+
}
|
|
427
|
+
return {
|
|
428
|
+
shortId: shortId,
|
|
429
|
+
version: parseInt(versionStr, 10)
|
|
430
|
+
};
|
|
431
|
+
}
|
|
432
|
+
/**
|
|
433
|
+
* Drain a readable stream to a UTF-8 string. Used by `dsp publish --id <id> -`
|
|
434
|
+
* so the source bytes pipe in from stdin without a temp file.
|
|
435
|
+
*/ export function readStreamToString(stream) {
|
|
436
|
+
return _async_to_generator(function() {
|
|
437
|
+
var chunks, _iteratorAbruptCompletion, _didIteratorError, _iteratorError, _iterator, _step, _value, chunk, err;
|
|
438
|
+
return _ts_generator(this, function(_state) {
|
|
439
|
+
switch(_state.label){
|
|
440
|
+
case 0:
|
|
441
|
+
chunks = [];
|
|
442
|
+
_iteratorAbruptCompletion = false, _didIteratorError = false;
|
|
443
|
+
_state.label = 1;
|
|
444
|
+
case 1:
|
|
445
|
+
_state.trys.push([
|
|
446
|
+
1,
|
|
447
|
+
6,
|
|
448
|
+
7,
|
|
449
|
+
12
|
|
450
|
+
]);
|
|
451
|
+
_iterator = _async_iterator(stream);
|
|
452
|
+
_state.label = 2;
|
|
453
|
+
case 2:
|
|
454
|
+
return [
|
|
455
|
+
4,
|
|
456
|
+
_iterator.next()
|
|
457
|
+
];
|
|
458
|
+
case 3:
|
|
459
|
+
if (!(_iteratorAbruptCompletion = !(_step = _state.sent()).done)) return [
|
|
460
|
+
3,
|
|
461
|
+
5
|
|
462
|
+
];
|
|
463
|
+
_value = _step.value;
|
|
464
|
+
chunk = _value;
|
|
465
|
+
chunks.push(Buffer.isBuffer(chunk) ? chunk : Buffer.from(chunk));
|
|
466
|
+
_state.label = 4;
|
|
467
|
+
case 4:
|
|
468
|
+
_iteratorAbruptCompletion = false;
|
|
469
|
+
return [
|
|
470
|
+
3,
|
|
471
|
+
2
|
|
472
|
+
];
|
|
473
|
+
case 5:
|
|
474
|
+
return [
|
|
475
|
+
3,
|
|
476
|
+
12
|
|
477
|
+
];
|
|
478
|
+
case 6:
|
|
479
|
+
err = _state.sent();
|
|
480
|
+
_didIteratorError = true;
|
|
481
|
+
_iteratorError = err;
|
|
482
|
+
return [
|
|
483
|
+
3,
|
|
484
|
+
12
|
|
485
|
+
];
|
|
486
|
+
case 7:
|
|
487
|
+
_state.trys.push([
|
|
488
|
+
7,
|
|
489
|
+
,
|
|
490
|
+
10,
|
|
491
|
+
11
|
|
492
|
+
]);
|
|
493
|
+
if (!(_iteratorAbruptCompletion && _iterator.return != null)) return [
|
|
494
|
+
3,
|
|
495
|
+
9
|
|
496
|
+
];
|
|
497
|
+
return [
|
|
498
|
+
4,
|
|
499
|
+
_iterator.return()
|
|
500
|
+
];
|
|
501
|
+
case 8:
|
|
502
|
+
_state.sent();
|
|
503
|
+
_state.label = 9;
|
|
504
|
+
case 9:
|
|
505
|
+
return [
|
|
506
|
+
3,
|
|
507
|
+
11
|
|
508
|
+
];
|
|
509
|
+
case 10:
|
|
510
|
+
if (_didIteratorError) {
|
|
511
|
+
throw _iteratorError;
|
|
512
|
+
}
|
|
513
|
+
return [
|
|
514
|
+
7
|
|
515
|
+
];
|
|
516
|
+
case 11:
|
|
517
|
+
return [
|
|
518
|
+
7
|
|
519
|
+
];
|
|
520
|
+
case 12:
|
|
521
|
+
return [
|
|
522
|
+
2,
|
|
523
|
+
Buffer.concat(chunks).toString('utf-8')
|
|
524
|
+
];
|
|
525
|
+
}
|
|
526
|
+
});
|
|
527
|
+
})();
|
|
528
|
+
}
|
|
529
|
+
var SHOW_BRANDING_VALUES = new Set([
|
|
530
|
+
'show',
|
|
531
|
+
'hide',
|
|
532
|
+
'inherit'
|
|
533
|
+
]);
|
|
534
|
+
export function parseShowBrandingFlag(raw) {
|
|
535
|
+
if (!raw) {
|
|
536
|
+
return undefined;
|
|
537
|
+
}
|
|
538
|
+
var normalized = raw.toLowerCase();
|
|
539
|
+
if (!SHOW_BRANDING_VALUES.has(normalized)) {
|
|
540
|
+
throw new InvalidFlagError('--show-branding', raw);
|
|
541
|
+
}
|
|
542
|
+
return normalized;
|
|
543
|
+
}
|
|
544
|
+
var VISIBILITY_VALUES = new Set([
|
|
545
|
+
'public',
|
|
546
|
+
'company',
|
|
547
|
+
'private'
|
|
548
|
+
]);
|
|
549
|
+
export function validatePublishArgs(opts) {
|
|
550
|
+
var _ref;
|
|
551
|
+
var _opts_shareWith;
|
|
552
|
+
if (!opts.id && !opts.name) {
|
|
553
|
+
throw new PublishArgsError('--name is required for new artifacts. Use --id to update an existing one.');
|
|
554
|
+
}
|
|
555
|
+
if (opts.public && opts.company) {
|
|
556
|
+
throw new PublishArgsError('Use --public or --company, not both.');
|
|
557
|
+
}
|
|
558
|
+
if (opts.visibility !== undefined && !VISIBILITY_VALUES.has(opts.visibility)) {
|
|
559
|
+
throw new PublishArgsError("Invalid --visibility: ".concat(opts.visibility, ". Use public, company, or private."));
|
|
560
|
+
}
|
|
561
|
+
if (opts.visibility !== undefined && (opts.public || opts.company)) {
|
|
562
|
+
throw new PublishArgsError('Use --visibility or --public/--company, not both.');
|
|
563
|
+
}
|
|
564
|
+
if (opts.clearShares && (opts.share.length > 0 || ((_ref = (_opts_shareWith = opts.shareWith) === null || _opts_shareWith === void 0 ? void 0 : _opts_shareWith.length) !== null && _ref !== void 0 ? _ref : 0) > 0)) {
|
|
565
|
+
throw new PublishArgsError('Use --share / --share-with or --clear-shares, not both.');
|
|
566
|
+
}
|
|
567
|
+
if (opts.clearShares && !opts.id) {
|
|
568
|
+
throw new PublishArgsError('--clear-shares only applies when updating (--id).');
|
|
569
|
+
}
|
|
570
|
+
if (!opts.fromStdin) {
|
|
571
|
+
var ext = extname(opts.filePath).toLowerCase();
|
|
572
|
+
if (ext !== '.html' && ext !== '.md') {
|
|
573
|
+
throw new PublishArgsError("Unsupported file type: ".concat(ext, " (expected .html or .md)"));
|
|
574
|
+
}
|
|
575
|
+
}
|
|
576
|
+
if (!opts.authenticated) {
|
|
577
|
+
if (opts.id) {
|
|
578
|
+
throw new PublishArgsError('Updating an artifact (--id) requires auth. Run: dsp login');
|
|
579
|
+
}
|
|
580
|
+
if (opts.public || opts.company) {
|
|
581
|
+
throw new PublishArgsError('--public / --company requires auth. Run: dsp login');
|
|
582
|
+
}
|
|
583
|
+
if (opts.visibility) {
|
|
584
|
+
throw new PublishArgsError('--visibility requires auth. Run: dsp login');
|
|
585
|
+
}
|
|
586
|
+
if (opts.share.length > 0 || opts.shareWith && opts.shareWith.length > 0) {
|
|
587
|
+
throw new PublishArgsError('--share / --share-with requires auth. Run: dsp login');
|
|
588
|
+
}
|
|
589
|
+
if (opts.clearShares) {
|
|
590
|
+
throw new PublishArgsError('--clear-shares requires auth. Run: dsp login');
|
|
591
|
+
}
|
|
592
|
+
if (opts.showBranding) {
|
|
593
|
+
throw new PublishArgsError('--show-branding requires auth. Run: dsp login');
|
|
594
|
+
}
|
|
595
|
+
}
|
|
596
|
+
}
|
|
597
|
+
export function pollDeviceToken(api, deviceCode, clientId, opts) {
|
|
598
|
+
return _async_to_generator(function() {
|
|
599
|
+
var _opts_now, _opts_sleep, now, sleep, interval, tokenResult, unused, err;
|
|
600
|
+
return _ts_generator(this, function(_state) {
|
|
601
|
+
switch(_state.label){
|
|
602
|
+
case 0:
|
|
603
|
+
now = (_opts_now = opts.now) !== null && _opts_now !== void 0 ? _opts_now : function() {
|
|
604
|
+
return Date.now();
|
|
605
|
+
};
|
|
606
|
+
sleep = (_opts_sleep = opts.sleep) !== null && _opts_sleep !== void 0 ? _opts_sleep : function(ms) {
|
|
607
|
+
return new Promise(function(resolve) {
|
|
608
|
+
return setTimeout(resolve, ms);
|
|
609
|
+
});
|
|
610
|
+
};
|
|
611
|
+
interval = opts.intervalMs;
|
|
612
|
+
_state.label = 1;
|
|
613
|
+
case 1:
|
|
614
|
+
if (!true) return [
|
|
615
|
+
3,
|
|
616
|
+
7
|
|
617
|
+
];
|
|
618
|
+
return [
|
|
619
|
+
4,
|
|
620
|
+
sleep(interval)
|
|
621
|
+
];
|
|
622
|
+
case 2:
|
|
623
|
+
_state.sent();
|
|
624
|
+
if (now() >= opts.expiresAt) {
|
|
625
|
+
throw new DeviceCodeExpiredError();
|
|
626
|
+
}
|
|
627
|
+
tokenResult = void 0;
|
|
628
|
+
_state.label = 3;
|
|
629
|
+
case 3:
|
|
630
|
+
_state.trys.push([
|
|
631
|
+
3,
|
|
632
|
+
5,
|
|
633
|
+
,
|
|
634
|
+
6
|
|
635
|
+
]);
|
|
636
|
+
return [
|
|
637
|
+
4,
|
|
638
|
+
api.pollDeviceToken(deviceCode, clientId)
|
|
639
|
+
];
|
|
640
|
+
case 4:
|
|
641
|
+
tokenResult = _state.sent();
|
|
642
|
+
return [
|
|
643
|
+
3,
|
|
644
|
+
6
|
|
645
|
+
];
|
|
646
|
+
case 5:
|
|
647
|
+
unused = _state.sent();
|
|
648
|
+
return [
|
|
649
|
+
3,
|
|
650
|
+
1
|
|
651
|
+
];
|
|
652
|
+
case 6:
|
|
653
|
+
if ('access_token' in tokenResult) {
|
|
654
|
+
return [
|
|
655
|
+
2,
|
|
656
|
+
tokenResult.access_token
|
|
657
|
+
];
|
|
658
|
+
}
|
|
659
|
+
err = tokenResult;
|
|
660
|
+
if (err.error === 'authorization_pending') {
|
|
661
|
+
return [
|
|
662
|
+
3,
|
|
663
|
+
1
|
|
664
|
+
];
|
|
665
|
+
}
|
|
666
|
+
if (err.error === 'slow_down') {
|
|
667
|
+
interval += 5000;
|
|
668
|
+
return [
|
|
669
|
+
3,
|
|
670
|
+
1
|
|
671
|
+
];
|
|
672
|
+
}
|
|
673
|
+
if (err.error === 'expired_token') {
|
|
674
|
+
throw new DeviceCodeExpiredError();
|
|
675
|
+
}
|
|
676
|
+
if (err.error === 'access_denied') {
|
|
677
|
+
throw new DeviceCodeDeniedError();
|
|
678
|
+
}
|
|
679
|
+
throw new DeviceCodeFailedError(err.error_description || err.error || 'Authentication failed');
|
|
680
|
+
case 7:
|
|
681
|
+
return [
|
|
682
|
+
2
|
|
683
|
+
];
|
|
684
|
+
}
|
|
685
|
+
});
|
|
686
|
+
})();
|
|
687
|
+
}
|