@displaydev/cli 0.8.1 → 0.10.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 +19 -7
- package/dist/main.js +6 -2
- package/dist/mcp-server.js +144 -19
- package/package.json +1 -1
package/dist/api-client.js
CHANGED
|
@@ -561,17 +561,29 @@ export var ApiClient = /*#__PURE__*/ function() {
|
|
|
561
561
|
{
|
|
562
562
|
key: "exportSource",
|
|
563
563
|
value: /**
|
|
564
|
-
* Fetch the
|
|
565
|
-
* the
|
|
566
|
-
*
|
|
567
|
-
*
|
|
568
|
-
|
|
564
|
+
* Fetch the source bytes of an artifact. `format: 'original'` returns
|
|
565
|
+
* the publisher's upload (markdown for `.md`, HTML for `.html`).
|
|
566
|
+
* `format: 'markdown'` returns markdown regardless — `.md` is unchanged,
|
|
567
|
+
* `.html` is converted server-side via Workers AI (cached).
|
|
568
|
+
*
|
|
569
|
+
* Returns the body plus the response's Content-Type. Throws `ApiError`
|
|
570
|
+
* on non-2xx (CLI maps 404 to a clean message + exit 4).
|
|
571
|
+
*/ function exportSource(shortId, version, format) {
|
|
569
572
|
return _async_to_generator(function() {
|
|
570
|
-
var _res_headers_get, qs, url, res, _parsed_message, text, parsed, arrayBuffer;
|
|
573
|
+
var _res_headers_get, params, qs, url, res, _parsed_message, text, parsed, arrayBuffer;
|
|
571
574
|
return _ts_generator(this, function(_state) {
|
|
572
575
|
switch(_state.label){
|
|
573
576
|
case 0:
|
|
574
|
-
|
|
577
|
+
params = [];
|
|
578
|
+
if (version !== undefined) {
|
|
579
|
+
params.push("v=".concat(version));
|
|
580
|
+
}
|
|
581
|
+
// `original` is the API default — omit so smoke tests / network
|
|
582
|
+
// logs aren't littered with redundant query params.
|
|
583
|
+
if (format !== undefined && format !== 'original') {
|
|
584
|
+
params.push("format=".concat(format));
|
|
585
|
+
}
|
|
586
|
+
qs = params.length > 0 ? "?".concat(params.join('&')) : '';
|
|
575
587
|
url = "".concat(this.baseUrl, "/v1/artifacts/").concat(shortId, "/source").concat(qs);
|
|
576
588
|
return [
|
|
577
589
|
4,
|
package/dist/main.js
CHANGED
|
@@ -781,7 +781,7 @@ program.command('get <shortId>').description('Get artifact details').option('--i
|
|
|
781
781
|
})();
|
|
782
782
|
});
|
|
783
783
|
// --- export ---
|
|
784
|
-
program.command('export <shortId>').description('Print the published source bytes to stdout. Pin a version with @<n>.').action(function(shortIdArg) {
|
|
784
|
+
program.command('export <shortId>').description('Print the published source bytes to stdout. Pin a version with @<n>.').option('--format <format>', 'Representation: "original" (default — bytes as uploaded) or "markdown" (.html artifacts are converted via Workers AI).', 'original').action(function(shortIdArg, opts) {
|
|
785
785
|
return _async_to_generator(function() {
|
|
786
786
|
var parsed, auth, client, result, err, msg;
|
|
787
787
|
return _ts_generator(this, function(_state) {
|
|
@@ -792,6 +792,10 @@ program.command('export <shortId>').description('Print the published source byte
|
|
|
792
792
|
console.error('Invalid argument. Expected <shortId> or <shortId>@<version> (version must be a positive integer).');
|
|
793
793
|
process.exit(2);
|
|
794
794
|
}
|
|
795
|
+
if (opts.format !== 'original' && opts.format !== 'markdown') {
|
|
796
|
+
console.error('Invalid --format. Expected "original" or "markdown".');
|
|
797
|
+
process.exit(2);
|
|
798
|
+
}
|
|
795
799
|
return [
|
|
796
800
|
4,
|
|
797
801
|
resolveAuthOrConfig()
|
|
@@ -809,7 +813,7 @@ program.command('export <shortId>').description('Print the published source byte
|
|
|
809
813
|
]);
|
|
810
814
|
return [
|
|
811
815
|
4,
|
|
812
|
-
client.exportSource(parsed.shortId, parsed.version)
|
|
816
|
+
client.exportSource(parsed.shortId, parsed.version, opts.format)
|
|
813
817
|
];
|
|
814
818
|
case 3:
|
|
815
819
|
result = _state.sent();
|
package/dist/mcp-server.js
CHANGED
|
@@ -693,17 +693,77 @@ export function registerTools(server, api) {
|
|
|
693
693
|
});
|
|
694
694
|
})();
|
|
695
695
|
});
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
696
|
+
server.tool('share', 'Change an artifact\'s visibility and/or add/remove individual shared-with emails without republishing.', {
|
|
697
|
+
short_id: z.string().describe('Short ID of the artifact (8 chars).'),
|
|
698
|
+
visibility: z.enum([
|
|
699
|
+
'public',
|
|
700
|
+
'company',
|
|
701
|
+
'private'
|
|
702
|
+
]).optional().describe('Change the visibility level. Omit to keep current. "private" requires the Pro plan.'),
|
|
703
|
+
add_users: z.array(z.string()).optional().describe('Emails to add to sharedWith (idempotent).'),
|
|
704
|
+
remove_users: z.array(z.string()).optional().describe('Emails to remove from sharedWith (idempotent).')
|
|
705
|
+
}, function(args) {
|
|
706
|
+
return _async_to_generator(function() {
|
|
707
|
+
var result, err;
|
|
708
|
+
return _ts_generator(this, function(_state) {
|
|
709
|
+
switch(_state.label){
|
|
710
|
+
case 0:
|
|
711
|
+
if (args.visibility === undefined && !args.add_users && !args.remove_users) {
|
|
712
|
+
return [
|
|
713
|
+
2,
|
|
714
|
+
{
|
|
715
|
+
content: [
|
|
716
|
+
{
|
|
717
|
+
type: 'text',
|
|
718
|
+
text: JSON.stringify({
|
|
719
|
+
error: 'invalid_input',
|
|
720
|
+
message: 'Provide at least one of visibility, add_users, or remove_users'
|
|
721
|
+
})
|
|
722
|
+
}
|
|
723
|
+
],
|
|
724
|
+
isError: true
|
|
725
|
+
}
|
|
726
|
+
];
|
|
727
|
+
}
|
|
728
|
+
_state.label = 1;
|
|
729
|
+
case 1:
|
|
730
|
+
_state.trys.push([
|
|
731
|
+
1,
|
|
732
|
+
3,
|
|
733
|
+
,
|
|
734
|
+
4
|
|
735
|
+
]);
|
|
736
|
+
return [
|
|
737
|
+
4,
|
|
738
|
+
api.share(args.short_id, {
|
|
739
|
+
visibility: args.visibility,
|
|
740
|
+
addUsers: args.add_users,
|
|
741
|
+
removeUsers: args.remove_users
|
|
742
|
+
})
|
|
743
|
+
];
|
|
744
|
+
case 2:
|
|
745
|
+
result = _state.sent();
|
|
746
|
+
return [
|
|
747
|
+
2,
|
|
748
|
+
okResponse(result)
|
|
749
|
+
];
|
|
750
|
+
case 3:
|
|
751
|
+
err = _state.sent();
|
|
752
|
+
return [
|
|
753
|
+
2,
|
|
754
|
+
errorResponse(err)
|
|
755
|
+
];
|
|
756
|
+
case 4:
|
|
757
|
+
return [
|
|
758
|
+
2
|
|
759
|
+
];
|
|
760
|
+
}
|
|
761
|
+
});
|
|
762
|
+
})();
|
|
763
|
+
});
|
|
764
|
+
server.tool('rename', 'Rename a published artifact. The URL slug updates to match; existing URLs still resolve because routing uses the shortId.', {
|
|
765
|
+
short_id: z.string().describe('The 8-character shortId returned at publish.'),
|
|
766
|
+
name: z.string().describe('New display name. 1–200 characters.')
|
|
707
767
|
}, function(args) {
|
|
708
768
|
return _async_to_generator(function() {
|
|
709
769
|
var result, err;
|
|
@@ -718,13 +778,73 @@ export function registerTools(server, api) {
|
|
|
718
778
|
]);
|
|
719
779
|
return [
|
|
720
780
|
4,
|
|
721
|
-
api.
|
|
781
|
+
api.renameArtifact(args.short_id, args.name)
|
|
722
782
|
];
|
|
723
783
|
case 1:
|
|
724
784
|
result = _state.sent();
|
|
725
785
|
return [
|
|
726
786
|
2,
|
|
727
|
-
okResponse(
|
|
787
|
+
okResponse({
|
|
788
|
+
url: result.url,
|
|
789
|
+
shortId: result.shortId,
|
|
790
|
+
name: result.name
|
|
791
|
+
})
|
|
792
|
+
];
|
|
793
|
+
case 2:
|
|
794
|
+
err = _state.sent();
|
|
795
|
+
return [
|
|
796
|
+
2,
|
|
797
|
+
errorResponse(err)
|
|
798
|
+
];
|
|
799
|
+
case 3:
|
|
800
|
+
return [
|
|
801
|
+
2
|
|
802
|
+
];
|
|
803
|
+
}
|
|
804
|
+
});
|
|
805
|
+
})();
|
|
806
|
+
});
|
|
807
|
+
server.tool('export', 'Retrieve the source bytes of a published artifact. `format: "original"` returns the publisher\'s upload (markdown for .md, HTML for .html). `format: "markdown"` always returns markdown — `.md` is unchanged, `.html` is converted via Workers AI (cached).', {
|
|
808
|
+
short_id: z.string().describe('Short ID of the artifact (8 chars).'),
|
|
809
|
+
version: z.number().int().min(1).optional().describe('Pinned version number. Omit for current.'),
|
|
810
|
+
format: z.enum([
|
|
811
|
+
'original',
|
|
812
|
+
'markdown'
|
|
813
|
+
]).default('original').describe('Representation requested. Default "original".')
|
|
814
|
+
}, function(args) {
|
|
815
|
+
return _async_to_generator(function() {
|
|
816
|
+
var result, err;
|
|
817
|
+
return _ts_generator(this, function(_state) {
|
|
818
|
+
switch(_state.label){
|
|
819
|
+
case 0:
|
|
820
|
+
_state.trys.push([
|
|
821
|
+
0,
|
|
822
|
+
2,
|
|
823
|
+
,
|
|
824
|
+
3
|
|
825
|
+
]);
|
|
826
|
+
return [
|
|
827
|
+
4,
|
|
828
|
+
api.exportSource(args.short_id, args.version, args.format)
|
|
829
|
+
];
|
|
830
|
+
case 1:
|
|
831
|
+
result = _state.sent();
|
|
832
|
+
return [
|
|
833
|
+
2,
|
|
834
|
+
{
|
|
835
|
+
content: [
|
|
836
|
+
{
|
|
837
|
+
type: 'text',
|
|
838
|
+
text: result.data.toString('utf-8')
|
|
839
|
+
}
|
|
840
|
+
],
|
|
841
|
+
_meta: {
|
|
842
|
+
shortId: args.short_id,
|
|
843
|
+
version: args.version,
|
|
844
|
+
contentType: result.contentType,
|
|
845
|
+
sizeBytes: result.data.length
|
|
846
|
+
}
|
|
847
|
+
}
|
|
728
848
|
];
|
|
729
849
|
case 2:
|
|
730
850
|
err = _state.sent();
|
|
@@ -740,11 +860,16 @@ export function registerTools(server, api) {
|
|
|
740
860
|
});
|
|
741
861
|
})();
|
|
742
862
|
});
|
|
743
|
-
//
|
|
744
|
-
//
|
|
745
|
-
//
|
|
746
|
-
server.tool('
|
|
747
|
-
|
|
863
|
+
// Metadata-only: does NOT bump the artifact version. Use the `publish`
|
|
864
|
+
// tool (with `show_branding`) when you're changing content at the same
|
|
865
|
+
// time so both writes happen in one transaction.
|
|
866
|
+
server.tool('branding', 'Override display.dev branding for an existing artifact without re-publishing. Paid tiers only (free-tier orgs must keep inherit).', {
|
|
867
|
+
short_id: z.string().describe('Artifact shortId'),
|
|
868
|
+
show_branding: z.enum([
|
|
869
|
+
'show',
|
|
870
|
+
'hide',
|
|
871
|
+
'inherit'
|
|
872
|
+
]).describe('show = force branding on; hide = force off; inherit = follow org default')
|
|
748
873
|
}, function(args) {
|
|
749
874
|
return _async_to_generator(function() {
|
|
750
875
|
var result, err;
|
|
@@ -759,7 +884,7 @@ export function registerTools(server, api) {
|
|
|
759
884
|
]);
|
|
760
885
|
return [
|
|
761
886
|
4,
|
|
762
|
-
api.
|
|
887
|
+
api.setArtifactBranding(args.short_id, args.show_branding)
|
|
763
888
|
];
|
|
764
889
|
case 1:
|
|
765
890
|
result = _state.sent();
|