@displaydev/cli 0.18.0 → 0.20.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/dist/api-client.js +197 -27
- package/dist/main.js +559 -5
- package/dist/mcp-server.js +517 -22
- package/dist/update-notice.js +488 -0
- package/package.json +1 -1
package/dist/api-client.js
CHANGED
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
* HTTP client for the display.dev API.
|
|
3
|
-
* Used by the stdio MCP server to proxy tool calls to the REST API.
|
|
4
|
-
*/ function _assert_this_initialized(self) {
|
|
1
|
+
function _assert_this_initialized(self) {
|
|
5
2
|
if (self === void 0) {
|
|
6
3
|
throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
|
|
7
4
|
}
|
|
@@ -284,6 +281,10 @@ function _ts_generator(thisArg, body) {
|
|
|
284
281
|
};
|
|
285
282
|
}
|
|
286
283
|
}
|
|
284
|
+
/**
|
|
285
|
+
* HTTP client for the display.dev API.
|
|
286
|
+
* Used by the stdio MCP server to proxy tool calls to the REST API.
|
|
287
|
+
*/ import { readLatestVersionFromResponse } from './update-notice.js';
|
|
287
288
|
export var ApiError = /*#__PURE__*/ function(Error1) {
|
|
288
289
|
"use strict";
|
|
289
290
|
_inherits(ApiError, Error1);
|
|
@@ -311,15 +312,44 @@ export var ApiClient = /*#__PURE__*/ function() {
|
|
|
311
312
|
"use strict";
|
|
312
313
|
function ApiClient(config) {
|
|
313
314
|
_class_call_check(this, ApiClient);
|
|
314
|
-
var _config_clientType;
|
|
315
|
+
var _config_clientType, _config_version;
|
|
315
316
|
_define_property(this, "baseUrl", void 0);
|
|
316
317
|
_define_property(this, "apiKey", void 0);
|
|
317
318
|
_define_property(this, "clientType", void 0);
|
|
319
|
+
_define_property(this, "version", void 0);
|
|
318
320
|
this.baseUrl = config.baseUrl.replace(/\/$/, '');
|
|
319
321
|
this.apiKey = config.apiKey;
|
|
320
322
|
this.clientType = (_config_clientType = config.clientType) !== null && _config_clientType !== void 0 ? _config_clientType : 'mcp-stdio';
|
|
323
|
+
this.version = (_config_version = config.version) !== null && _config_version !== void 0 ? _config_version : '';
|
|
321
324
|
}
|
|
322
325
|
_create_class(ApiClient, [
|
|
326
|
+
{
|
|
327
|
+
key: "clientHeaders",
|
|
328
|
+
value: /**
|
|
329
|
+
* Build the request-side header set. Always carries `X-Client-Type`;
|
|
330
|
+
* adds `X-Client-Version` when the client was constructed with one.
|
|
331
|
+
*/ function clientHeaders(extra) {
|
|
332
|
+
var headers = _object_spread({
|
|
333
|
+
'X-Client-Type': this.clientType
|
|
334
|
+
}, this.version ? {
|
|
335
|
+
'X-Client-Version': this.version
|
|
336
|
+
} : {}, extra);
|
|
337
|
+
return headers;
|
|
338
|
+
}
|
|
339
|
+
},
|
|
340
|
+
{
|
|
341
|
+
key: "observeResponse",
|
|
342
|
+
value: /**
|
|
343
|
+
* Read the registry-derived `X-Client-Latest-Version` response header
|
|
344
|
+
* and feed it to the update-notice comparator. Called from every
|
|
345
|
+
* fetch site. No-op when no version is configured (older constructions
|
|
346
|
+
* that didn't pass `version` should not trigger an update prompt).
|
|
347
|
+
*/ function observeResponse(res) {
|
|
348
|
+
if (this.version) {
|
|
349
|
+
readLatestVersionFromResponse(res, this.version);
|
|
350
|
+
}
|
|
351
|
+
}
|
|
352
|
+
},
|
|
323
353
|
{
|
|
324
354
|
key: "publish",
|
|
325
355
|
value: function publish(params) {
|
|
@@ -355,9 +385,7 @@ export var ApiClient = /*#__PURE__*/ function() {
|
|
|
355
385
|
}
|
|
356
386
|
return [
|
|
357
387
|
2,
|
|
358
|
-
this.doFetch('POST', '/v1/public/artifacts', form,
|
|
359
|
-
'X-Client-Type': this.clientType
|
|
360
|
-
})
|
|
388
|
+
this.doFetch('POST', '/v1/public/artifacts', form, this.clientHeaders())
|
|
361
389
|
];
|
|
362
390
|
});
|
|
363
391
|
}).call(this);
|
|
@@ -392,6 +420,141 @@ export var ApiClient = /*#__PURE__*/ function() {
|
|
|
392
420
|
}).call(this);
|
|
393
421
|
}
|
|
394
422
|
},
|
|
423
|
+
{
|
|
424
|
+
key: "addComment",
|
|
425
|
+
value: // ── Comments (feat-comments §3) ──────────────────────────────────────
|
|
426
|
+
// 1:1 with the public REST endpoints under
|
|
427
|
+
// `/v1/artifacts/:shortId/comments` and `/v1/comments/:commentId/...`.
|
|
428
|
+
// KB-page subjects 404 until KB ships.
|
|
429
|
+
function addComment(shortId, params) {
|
|
430
|
+
return _async_to_generator(function() {
|
|
431
|
+
return _ts_generator(this, function(_state) {
|
|
432
|
+
return [
|
|
433
|
+
2,
|
|
434
|
+
this.request('POST', "/v1/artifacts/".concat(shortId, "/comments"), params)
|
|
435
|
+
];
|
|
436
|
+
});
|
|
437
|
+
}).call(this);
|
|
438
|
+
}
|
|
439
|
+
},
|
|
440
|
+
{
|
|
441
|
+
key: "listComments",
|
|
442
|
+
value: function listComments(shortId, params) {
|
|
443
|
+
return _async_to_generator(function() {
|
|
444
|
+
var qs, suffix;
|
|
445
|
+
return _ts_generator(this, function(_state) {
|
|
446
|
+
qs = new URLSearchParams();
|
|
447
|
+
if (params === null || params === void 0 ? void 0 : params.status) {
|
|
448
|
+
qs.set('status', params.status);
|
|
449
|
+
}
|
|
450
|
+
if (params === null || params === void 0 ? void 0 : params.since) {
|
|
451
|
+
qs.set('since', params.since);
|
|
452
|
+
}
|
|
453
|
+
suffix = qs.toString() ? "?".concat(qs.toString()) : '';
|
|
454
|
+
return [
|
|
455
|
+
2,
|
|
456
|
+
this.request('GET', "/v1/artifacts/".concat(shortId, "/comments").concat(suffix))
|
|
457
|
+
];
|
|
458
|
+
});
|
|
459
|
+
}).call(this);
|
|
460
|
+
}
|
|
461
|
+
},
|
|
462
|
+
{
|
|
463
|
+
key: "editComment",
|
|
464
|
+
value: function editComment(commentId, body) {
|
|
465
|
+
return _async_to_generator(function() {
|
|
466
|
+
return _ts_generator(this, function(_state) {
|
|
467
|
+
return [
|
|
468
|
+
2,
|
|
469
|
+
this.request('POST', "/v1/comments/".concat(commentId, "/edit"), {
|
|
470
|
+
body: body
|
|
471
|
+
})
|
|
472
|
+
];
|
|
473
|
+
});
|
|
474
|
+
}).call(this);
|
|
475
|
+
}
|
|
476
|
+
},
|
|
477
|
+
{
|
|
478
|
+
key: "deleteComment",
|
|
479
|
+
value: function deleteComment(commentId) {
|
|
480
|
+
return _async_to_generator(function() {
|
|
481
|
+
return _ts_generator(this, function(_state) {
|
|
482
|
+
switch(_state.label){
|
|
483
|
+
case 0:
|
|
484
|
+
return [
|
|
485
|
+
4,
|
|
486
|
+
this.request('DELETE', "/v1/comments/".concat(commentId))
|
|
487
|
+
];
|
|
488
|
+
case 1:
|
|
489
|
+
_state.sent();
|
|
490
|
+
return [
|
|
491
|
+
2
|
|
492
|
+
];
|
|
493
|
+
}
|
|
494
|
+
});
|
|
495
|
+
}).call(this);
|
|
496
|
+
}
|
|
497
|
+
},
|
|
498
|
+
{
|
|
499
|
+
key: "resolveThread",
|
|
500
|
+
value: function resolveThread(commentId) {
|
|
501
|
+
return _async_to_generator(function() {
|
|
502
|
+
return _ts_generator(this, function(_state) {
|
|
503
|
+
return [
|
|
504
|
+
2,
|
|
505
|
+
this.request('POST', "/v1/comments/".concat(commentId, "/resolve"))
|
|
506
|
+
];
|
|
507
|
+
});
|
|
508
|
+
}).call(this);
|
|
509
|
+
}
|
|
510
|
+
},
|
|
511
|
+
{
|
|
512
|
+
key: "reopenThread",
|
|
513
|
+
value: function reopenThread(commentId) {
|
|
514
|
+
return _async_to_generator(function() {
|
|
515
|
+
return _ts_generator(this, function(_state) {
|
|
516
|
+
return [
|
|
517
|
+
2,
|
|
518
|
+
this.request('POST', "/v1/comments/".concat(commentId, "/reopen"))
|
|
519
|
+
];
|
|
520
|
+
});
|
|
521
|
+
}).call(this);
|
|
522
|
+
}
|
|
523
|
+
},
|
|
524
|
+
{
|
|
525
|
+
key: "watchArtifact",
|
|
526
|
+
value: function watchArtifact(shortId) {
|
|
527
|
+
return _async_to_generator(function() {
|
|
528
|
+
return _ts_generator(this, function(_state) {
|
|
529
|
+
return [
|
|
530
|
+
2,
|
|
531
|
+
this.request('POST', "/v1/artifacts/".concat(shortId, "/watch"))
|
|
532
|
+
];
|
|
533
|
+
});
|
|
534
|
+
}).call(this);
|
|
535
|
+
}
|
|
536
|
+
},
|
|
537
|
+
{
|
|
538
|
+
key: "unwatchArtifact",
|
|
539
|
+
value: function unwatchArtifact(shortId) {
|
|
540
|
+
return _async_to_generator(function() {
|
|
541
|
+
return _ts_generator(this, function(_state) {
|
|
542
|
+
switch(_state.label){
|
|
543
|
+
case 0:
|
|
544
|
+
return [
|
|
545
|
+
4,
|
|
546
|
+
this.request('DELETE', "/v1/artifacts/".concat(shortId, "/watch"))
|
|
547
|
+
];
|
|
548
|
+
case 1:
|
|
549
|
+
_state.sent();
|
|
550
|
+
return [
|
|
551
|
+
2
|
|
552
|
+
];
|
|
553
|
+
}
|
|
554
|
+
});
|
|
555
|
+
}).call(this);
|
|
556
|
+
}
|
|
557
|
+
},
|
|
395
558
|
{
|
|
396
559
|
key: "buildPublishForm",
|
|
397
560
|
value: function buildPublishForm(params) {
|
|
@@ -669,14 +832,14 @@ export var ApiClient = /*#__PURE__*/ function() {
|
|
|
669
832
|
4,
|
|
670
833
|
fetch(url, {
|
|
671
834
|
method: 'GET',
|
|
672
|
-
headers: {
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
}
|
|
835
|
+
headers: this.clientHeaders({
|
|
836
|
+
Authorization: "Bearer ".concat(this.apiKey)
|
|
837
|
+
})
|
|
676
838
|
})
|
|
677
839
|
];
|
|
678
840
|
case 1:
|
|
679
841
|
res = _state.sent();
|
|
842
|
+
this.observeResponse(res);
|
|
680
843
|
if (!!res.ok) return [
|
|
681
844
|
3,
|
|
682
845
|
3
|
|
@@ -826,10 +989,9 @@ export var ApiClient = /*#__PURE__*/ function() {
|
|
|
826
989
|
return [
|
|
827
990
|
4,
|
|
828
991
|
fetch("".concat(this.baseUrl, "/v1/artifacts?limit=1"), {
|
|
829
|
-
headers: {
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
}
|
|
992
|
+
headers: this.clientHeaders({
|
|
993
|
+
Authorization: "Bearer ".concat(apiKey)
|
|
994
|
+
})
|
|
833
995
|
})
|
|
834
996
|
];
|
|
835
997
|
case 1:
|
|
@@ -845,6 +1007,7 @@ export var ApiClient = /*#__PURE__*/ function() {
|
|
|
845
1007
|
'network_error'
|
|
846
1008
|
];
|
|
847
1009
|
case 3:
|
|
1010
|
+
this.observeResponse(res);
|
|
848
1011
|
if (res.ok) {
|
|
849
1012
|
return [
|
|
850
1013
|
2,
|
|
@@ -873,10 +1036,9 @@ export var ApiClient = /*#__PURE__*/ function() {
|
|
|
873
1036
|
return _ts_generator(this, function(_state) {
|
|
874
1037
|
return [
|
|
875
1038
|
2,
|
|
876
|
-
this.doFetch(method, path, body, {
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
})
|
|
1039
|
+
this.doFetch(method, path, body, this.clientHeaders({
|
|
1040
|
+
Authorization: "Bearer ".concat(this.apiKey)
|
|
1041
|
+
}))
|
|
880
1042
|
];
|
|
881
1043
|
});
|
|
882
1044
|
}).call(this);
|
|
@@ -889,9 +1051,7 @@ export var ApiClient = /*#__PURE__*/ function() {
|
|
|
889
1051
|
return _ts_generator(this, function(_state) {
|
|
890
1052
|
return [
|
|
891
1053
|
2,
|
|
892
|
-
this.doFetch(method, path, body,
|
|
893
|
-
'X-Client-Type': this.clientType
|
|
894
|
-
})
|
|
1054
|
+
this.doFetch(method, path, body, this.clientHeaders())
|
|
895
1055
|
];
|
|
896
1056
|
});
|
|
897
1057
|
}).call(this);
|
|
@@ -910,15 +1070,15 @@ export var ApiClient = /*#__PURE__*/ function() {
|
|
|
910
1070
|
4,
|
|
911
1071
|
fetch(url, {
|
|
912
1072
|
method: method,
|
|
913
|
-
headers: {
|
|
914
|
-
'Content-Type': 'application/json'
|
|
915
|
-
|
|
916
|
-
},
|
|
1073
|
+
headers: this.clientHeaders({
|
|
1074
|
+
'Content-Type': 'application/json'
|
|
1075
|
+
}),
|
|
917
1076
|
body: body ? JSON.stringify(body) : undefined
|
|
918
1077
|
})
|
|
919
1078
|
];
|
|
920
1079
|
case 1:
|
|
921
1080
|
res = _state.sent();
|
|
1081
|
+
this.observeResponse(res);
|
|
922
1082
|
return [
|
|
923
1083
|
2,
|
|
924
1084
|
res.json()
|
|
@@ -953,6 +1113,7 @@ export var ApiClient = /*#__PURE__*/ function() {
|
|
|
953
1113
|
];
|
|
954
1114
|
case 1:
|
|
955
1115
|
res = _state.sent();
|
|
1116
|
+
this.observeResponse(res);
|
|
956
1117
|
if (!!res.ok) return [
|
|
957
1118
|
3,
|
|
958
1119
|
3
|
|
@@ -972,6 +1133,15 @@ export var ApiClient = /*#__PURE__*/ function() {
|
|
|
972
1133
|
}
|
|
973
1134
|
throw new ApiError((_parsed_message = parsed.message) !== null && _parsed_message !== void 0 ? _parsed_message : "API error ".concat(res.status), res.status, parsed.details, parsed.reason, parsed.error);
|
|
974
1135
|
case 3:
|
|
1136
|
+
// 204 No Content (and 205 Reset Content) carry no body. Calling
|
|
1137
|
+
// res.json() on them throws SyntaxError; return undefined so void-
|
|
1138
|
+
// typed callers (deleteComment, unwatchArtifact) are satisfied.
|
|
1139
|
+
if (res.status === 204 || res.status === 205) {
|
|
1140
|
+
return [
|
|
1141
|
+
2,
|
|
1142
|
+
undefined
|
|
1143
|
+
];
|
|
1144
|
+
}
|
|
975
1145
|
return [
|
|
976
1146
|
2,
|
|
977
1147
|
res.json()
|