@displaydev/cli 0.3.0 → 0.4.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.
@@ -272,26 +272,44 @@ export var ApiClient = /*#__PURE__*/ function() {
272
272
  key: "find",
273
273
  value: function find(params) {
274
274
  return _async_to_generator(function() {
275
- var searchParams, qs;
275
+ var searchParams, qs, res;
276
276
  return _ts_generator(this, function(_state) {
277
- searchParams = new URLSearchParams();
278
- if (params.query) {
279
- searchParams.set('q', params.query);
280
- }
281
- if (params.published_by) {
282
- searchParams.set('published_by', params.published_by);
283
- }
284
- if (params.since) {
285
- searchParams.set('since', params.since);
286
- }
287
- if (params.limit) {
288
- searchParams.set('limit', String(params.limit));
277
+ switch(_state.label){
278
+ case 0:
279
+ searchParams = new URLSearchParams();
280
+ if (params.query) {
281
+ searchParams.set('q', params.query);
282
+ }
283
+ if (params.mine) {
284
+ searchParams.append('author', 'me');
285
+ }
286
+ if (params.published_by) {
287
+ searchParams.set('published_by', params.published_by);
288
+ }
289
+ if (params.since) {
290
+ searchParams.set('since', params.since);
291
+ }
292
+ if (params.sort) {
293
+ searchParams.set('sort', params.sort);
294
+ }
295
+ if (params.dir) {
296
+ searchParams.set('dir', params.dir);
297
+ }
298
+ if (params.limit) {
299
+ searchParams.set('limit', String(params.limit));
300
+ }
301
+ qs = searchParams.toString();
302
+ return [
303
+ 4,
304
+ this.request('GET', "/v1/artifacts".concat(qs ? "?".concat(qs) : ''))
305
+ ];
306
+ case 1:
307
+ res = _state.sent();
308
+ return [
309
+ 2,
310
+ res.data
311
+ ];
289
312
  }
290
- qs = searchParams.toString();
291
- return [
292
- 2,
293
- this.request('GET', "/v1/artifacts".concat(qs ? "?".concat(qs) : ''))
294
- ];
295
313
  });
296
314
  }).call(this);
297
315
  }
package/dist/main.js CHANGED
@@ -367,12 +367,26 @@ program.command('publish <path>').description('Publish an HTML or Markdown file'
367
367
  })();
368
368
  });
369
369
  // --- find ---
370
- program.command('find [query]').description('Search for artifacts').option('--by <email>', 'Filter by publisher email').option('--since <date>', 'Filter by date (ISO format)').action(function(query, opts) {
370
+ program.command('find [query]').description('Search for artifacts').option('--by <email>', 'Filter by publisher email').option('--mine', 'Show only artifacts you published').option('--since <date>', 'Filter by date (ISO format)').option('--sort <col>', 'Sort column: updated_at, view_count, name', 'updated_at').option('--dir <direction>', 'Sort direction: asc or desc').option('--limit <n>', 'Max rows to fetch (1-100)', function(v) {
371
+ return parseInt(v, 10);
372
+ }).action(function(query, opts) {
371
373
  return _async_to_generator(function() {
372
374
  var auth, client, results, _iteratorNormalCompletion, _didIteratorError, _iteratorError, _iterator, _step, a;
373
375
  return _ts_generator(this, function(_state) {
374
376
  switch(_state.label){
375
377
  case 0:
378
+ if (opts.sort && ![
379
+ 'updated_at',
380
+ 'view_count',
381
+ 'name'
382
+ ].includes(opts.sort)) {
383
+ console.error("Invalid --sort: ".concat(opts.sort, ". Use updated_at, view_count, or name."));
384
+ process.exit(1);
385
+ }
386
+ if (opts.dir && opts.dir !== 'asc' && opts.dir !== 'desc') {
387
+ console.error("Invalid --dir: ".concat(opts.dir, ". Use asc or desc."));
388
+ process.exit(1);
389
+ }
376
390
  return [
377
391
  4,
378
392
  resolveAuthOrConfig()
@@ -385,7 +399,11 @@ program.command('find [query]').description('Search for artifacts').option('--by
385
399
  client.find({
386
400
  query: query,
387
401
  published_by: opts.by,
388
- since: opts.since
402
+ mine: opts.mine,
403
+ since: opts.since,
404
+ sort: opts.sort,
405
+ dir: opts.dir,
406
+ limit: opts.limit
389
407
  })
390
408
  ];
391
409
  case 2:
@@ -309,8 +309,18 @@ function registerTools(server, api) {
309
309
  server.tool('find', 'Search for artifacts in the organization', {
310
310
  query: z.string().optional().describe('Search by artifact name'),
311
311
  published_by: z.string().optional().describe('Filter by publisher email'),
312
+ mine: z.boolean().optional().describe('Limit results to your own artifacts'),
312
313
  since: z.string().optional().describe('Filter by updated since ISO date'),
313
- limit: z.number().optional().describe('Max results to return')
314
+ sort: z.enum([
315
+ 'updated_at',
316
+ 'view_count',
317
+ 'name'
318
+ ]).optional().describe('Sort column'),
319
+ dir: z.enum([
320
+ 'asc',
321
+ 'desc'
322
+ ]).optional().describe('Sort direction'),
323
+ limit: z.number().optional().describe('Max results to return (1-100)')
314
324
  }, function(args) {
315
325
  return _async_to_generator(function() {
316
326
  var results;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@displaydev/cli",
3
- "version": "0.3.0",
3
+ "version": "0.4.0",
4
4
  "type": "module",
5
5
  "bin": {
6
6
  "dsp": "dist/main.js"