@pitcher/cli-scripts 2.20.1 → 2.21.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 CHANGED
@@ -2,6 +2,8 @@
2
2
 
3
3
  > Pitcher CLI Tools provide a suite of command-line utilities to streamline your workflow. For the best experience, we recommend installing the tools globally using `npm install -g @pitcher/cli-scripts`.
4
4
 
5
+ Releases are published to npm automatically: a merge to `main` that bumps `version` in `package.json` publishes that version, and a merge without a bump publishes nothing (`.github/workflows/cli-scripts-publish.yml`; release flow in `CLAUDE.md`).
6
+
5
7
  ## Help
6
8
 
7
9
  ```bash
@@ -223,15 +225,12 @@ p canvases get 01CANVASID... --api-key myapikey
223
225
 
224
226
  ## To run the `shared-links` command:
225
227
 
226
- Create and read share links for canvases or files (returns the `short_url`).
228
+ Create and read share links for canvases (returns the `short_url`).
227
229
 
228
230
  ```bash
229
231
  # Create a share link for a canvas
230
232
  p shared-links create --canvas-id 01CANVASID... --api-key myapikey
231
233
 
232
- # Create a share link for a file
233
- p shared-links create --file-id 01FILEID... --api-key myapikey
234
-
235
234
  # Fetch the existing share link for a canvas
236
235
  p shared-links get --canvas-id 01CANVASID... --api-key myapikey
237
236
  ```
@@ -7,10 +7,8 @@ export interface SharedLinksDeps {
7
7
  }
8
8
  export declare function runSharedLinksCreate(opts: CommonOpts & {
9
9
  canvasId?: string;
10
- fileId?: string;
11
10
  }, deps?: SharedLinksDeps): Promise<Envelope<unknown>>;
12
11
  export declare function runSharedLinksGet(opts: CommonOpts & {
13
12
  canvasId?: string;
14
- fileId?: string;
15
13
  }, deps?: SharedLinksDeps): Promise<Envelope<unknown>>;
16
14
  export declare function createSharedLinksCommand(): Command;
@@ -4,22 +4,17 @@ import { ok, fail } from '../core/envelope.js';
4
4
  import { createCliError } from '../core/errors.js';
5
5
  import { emitEnvelope } from '../core/output.js';
6
6
  import { withAuthFlags } from './withAuth.js';
7
- /** Enforce exactly one of --canvas-id / --file-id. Scope is derived from the target. */
8
- function requireOneTarget(opts) {
9
- if (opts.canvasId && opts.fileId)
10
- throw createCliError('VALIDATION', 'pass exactly one of --canvas-id or --file-id');
11
- if (opts.canvasId)
12
- return 'canvas';
13
- if (opts.fileId)
14
- return 'file';
15
- throw createCliError('VALIDATION', 'pass exactly one of --canvas-id or --file-id');
7
+ /** Only canvases can be shared. */
8
+ function requireCanvasId(opts) {
9
+ if (!opts.canvasId)
10
+ throw createCliError('VALIDATION', '--canvas-id is required');
11
+ return opts.canvasId;
16
12
  }
17
13
  export async function runSharedLinksCreate(opts, deps = {}) {
18
14
  try {
19
- const target = requireOneTarget(opts);
15
+ const canvasId = requireCanvasId(opts);
20
16
  const client = clientFor(opts, deps);
21
- const body = target === 'canvas' ? { canvas_id: opts.canvasId } : { file_id: opts.fileId };
22
- const res = await client.post('/api/v1/shared-links/', body);
17
+ const res = await client.post('/api/v1/shared-links/', { canvas_id: canvasId });
23
18
  return ok(res.data);
24
19
  }
25
20
  catch (e) {
@@ -28,13 +23,10 @@ export async function runSharedLinksCreate(opts, deps = {}) {
28
23
  }
29
24
  export async function runSharedLinksGet(opts, deps = {}) {
30
25
  try {
31
- const target = requireOneTarget(opts);
26
+ const canvasId = requireCanvasId(opts);
32
27
  const client = clientFor(opts, deps);
33
28
  // encodeURIComponent so an id containing `/` or `..` can't retarget the request path
34
- const path = target === 'canvas'
35
- ? `/api/v1/shared-links/canvas/${encodeURIComponent(opts.canvasId)}`
36
- : `/api/v1/shared-links/file/${encodeURIComponent(opts.fileId)}`;
37
- const res = await client.get(path);
29
+ const res = await client.get(`/api/v1/shared-links/canvas/${encodeURIComponent(canvasId)}`);
38
30
  return ok(res.data);
39
31
  }
40
32
  catch (e) {
@@ -42,17 +34,15 @@ export async function runSharedLinksGet(opts, deps = {}) {
42
34
  }
43
35
  }
44
36
  export function createSharedLinksCommand() {
45
- const cmd = new Command('shared-links').description('create and read share links for canvases and files');
37
+ const cmd = new Command('shared-links').description('create and read share links for canvases');
46
38
  withAuthFlags(cmd.command('create'))
47
39
  .option('--canvas-id <id>', 'Canvas to share')
48
- .option('--file-id <id>', 'File to share')
49
40
  .action(async (options, command) => {
50
41
  const globals = command.optsWithGlobals();
51
42
  emitEnvelope(await runSharedLinksCreate({ ...options, quiet: globals.quiet }), globals);
52
43
  });
53
44
  withAuthFlags(cmd.command('get'))
54
45
  .option('--canvas-id <id>', 'Canvas whose link to fetch')
55
- .option('--file-id <id>', 'File whose link to fetch')
56
46
  .action(async (options, command) => {
57
47
  const globals = command.optsWithGlobals();
58
48
  emitEnvelope(await runSharedLinksGet({ ...options, quiet: globals.quiet }), globals);
@@ -4,10 +4,9 @@ export const sharedLinksTools = [
4
4
  {
5
5
  name: 'pitcher_shared_links_create',
6
6
  title: 'Create a shared link',
7
- description: 'Create a share link (short_url) for a canvas or a file. Pass exactly one of canvasId or fileId. Additive.',
7
+ description: 'Create a share link (short_url) for a canvas. Only canvases can be shared. Additive.',
8
8
  inputShape: {
9
- canvasId: z.string().optional().describe('Canvas to share (exactly one of canvasId/fileId is required)'),
10
- fileId: z.string().optional().describe('File to share (exactly one of canvasId/fileId is required)'),
9
+ canvasId: z.string().describe('Canvas to share'),
11
10
  },
12
11
  run: runSharedLinksCreate,
13
12
  readOnly: false,
@@ -16,10 +15,9 @@ export const sharedLinksTools = [
16
15
  {
17
16
  name: 'pitcher_shared_links_get',
18
17
  title: 'Get a shared link',
19
- description: 'Retrieve the existing share link for a canvas or a file. Pass exactly one of canvasId or fileId.',
18
+ description: 'Retrieve the existing share link for a canvas.',
20
19
  inputShape: {
21
- canvasId: z.string().optional().describe('Canvas whose link to fetch (exactly one of canvasId/fileId is required)'),
22
- fileId: z.string().optional().describe('File whose link to fetch (exactly one of canvasId/fileId is required)'),
20
+ canvasId: z.string().describe('Canvas whose link to fetch'),
23
21
  },
24
22
  run: runSharedLinksGet,
25
23
  readOnly: true,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pitcher/cli-scripts",
3
- "version": "2.20.1",
3
+ "version": "2.21.0",
4
4
  "description": "The Pitcher CLI for various tasks in its ecosystem.",
5
5
  "author": "Pitcher AG",
6
6
  "license": "MIT",