@curviate/cli 0.47.0 → 0.49.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.
Files changed (48) hide show
  1. package/CHANGELOG.md +231 -1
  2. package/README.md +136 -88
  3. package/dist/{account-RFJ63QYL.js → account-2BH2Q6VG.js} +41 -31
  4. package/dist/chunk-3RCW7URJ.js +41 -0
  5. package/dist/{chunk-UJOTQPL6.js → chunk-5ZGTU4VD.js} +47 -14
  6. package/dist/chunk-D2S5OCYU.js +38 -0
  7. package/dist/{chunk-HOQ7EUHJ.js → chunk-FDJMAF7D.js} +1 -0
  8. package/dist/{chunk-ERBYEC5P.js → chunk-JYKYD57J.js} +1 -1
  9. package/dist/chunk-MGB6FE4A.js +58 -0
  10. package/dist/chunk-NNV2OYEF.js +23 -0
  11. package/dist/{chunk-76SWLAZ6.js → chunk-RXWODUWA.js} +43 -1
  12. package/dist/{chunk-V3MVOVQT.js → chunk-SA2QHAXG.js} +8 -1
  13. package/dist/chunk-TEAWYLPO.js +1493 -0
  14. package/dist/{chunk-PD2I5TYC.js → chunk-V7FJWTZW.js} +3 -3
  15. package/dist/{chunk-TC4ZPUWI.js → chunk-Y7MZZRYR.js} +21 -80
  16. package/dist/{chunk-FXYK2GTO.js → chunk-Z7OQSWBD.js} +38 -33
  17. package/dist/chunk-ZYURL5VK.js +83 -0
  18. package/dist/cli.js +79 -98
  19. package/dist/{comment-MCXE7B7V.js → comment-MRDPDA33.js} +29 -24
  20. package/dist/{company-EUUN372H.js → company-2AEHSGHA.js} +57 -52
  21. package/dist/{config-K4G3VSBA.js → config-NRBKHXES.js} +13 -5
  22. package/dist/{connect-2AL7XVJO.js → connect-4XEBV5V3.js} +42 -38
  23. package/dist/core-RGU2SCBN.js +46 -0
  24. package/dist/{doctor-WPYI7X2T.js → doctor-BZ4DA7DV.js} +9 -5
  25. package/dist/document-RKHRWXNT.js +27 -0
  26. package/dist/{draft-G65DVXT7.js → draft-C5N6EOO5.js} +27 -22
  27. package/dist/enrollment-BNQOUKI7.js +472 -0
  28. package/dist/examples-NIMSIXMV.js +53 -0
  29. package/dist/{exit-codes-AW6KHDDN.js → exit-codes-TLMKTLRI.js} +1 -1
  30. package/dist/{feed-HV24WME4.js → feed-DFUU7SUJ.js} +15 -11
  31. package/dist/{group-HADXNVJW.js → group-CSD2OWOZ.js} +17 -13
  32. package/dist/{inbox-G3EE54OB.js → inbox-SNSPWI7J.js} +23 -19
  33. package/dist/{inboxes-237XOBTP.js → inboxes-RIRHPS4H.js} +18 -14
  34. package/dist/{job-LIN6RWD7.js → job-6PNXXZNF.js} +31 -27
  35. package/dist/{login-OHAHNBRW.js → login-Y7JBAHCW.js} +10 -5
  36. package/dist/{message-U2O2JQSW.js → message-2IK4MBBG.js} +10 -8
  37. package/dist/motion-7ATUXO6R.js +946 -0
  38. package/dist/{notification-3VG32LWM.js → notification-VYK5NDEB.js} +19 -15
  39. package/dist/{post-ECDK2KJL.js → post-AN6T2OJF.js} +35 -30
  40. package/dist/{profile-JOHS6SDW.js → profile-UQY64642.js} +46 -42
  41. package/dist/{recruiter-7VXEIXN3.js → recruiter-OY4RN5HH.js} +122 -119
  42. package/dist/{sales-nav-K4BMBH7R.js → sales-nav-KLODLYMW.js} +36 -30
  43. package/dist/{search-C2UYO6PI.js → search-NWP5S6CF.js} +68 -58
  44. package/dist/{setup-GYEZFDEN.js → setup-YPPFLH2N.js} +14 -9
  45. package/dist/{webhook-KCOQOH7D.js → webhook-OHKBL3YS.js} +51 -55
  46. package/package.json +2 -2
  47. package/dist/chunk-KJ24DIAJ.js +0 -60
  48. package/dist/examples-IJL3A6SZ.js +0 -18
@@ -1,4 +1,7 @@
1
1
  #!/usr/bin/env node
2
+ import {
3
+ intFlag
4
+ } from "./chunk-NNV2OYEF.js";
2
5
  import {
3
6
  buildPreviewOutput
4
7
  } from "./chunk-TCUYH5GO.js";
@@ -15,22 +18,27 @@ import {
15
18
  resolveEffectiveConfig,
16
19
  streamAll,
17
20
  writeNdjsonItem
18
- } from "./chunk-V3MVOVQT.js";
21
+ } from "./chunk-SA2QHAXG.js";
19
22
  import {
20
23
  createClient
21
- } from "./chunk-UJOTQPL6.js";
24
+ } from "./chunk-5ZGTU4VD.js";
22
25
  import {
23
26
  GLOBAL_FLAGS,
24
27
  READ_SINGLE_FLAGS,
25
28
  WRITE_SINGLE_FLAGS,
26
- defaultReadStdin,
27
- isStdinToken,
28
29
  readOnly
29
- } from "./chunk-TC4ZPUWI.js";
30
+ } from "./chunk-Y7MZZRYR.js";
31
+ import {
32
+ DESCRIPTIONS
33
+ } from "./chunk-D2S5OCYU.js";
34
+ import {
35
+ readFileFlag
36
+ } from "./chunk-TEAWYLPO.js";
37
+ import "./chunk-FDJMAF7D.js";
38
+ import "./chunk-ZYURL5VK.js";
30
39
 
31
40
  // src/commands/webhook.ts
32
41
  import { defineCommand } from "citty";
33
- import { readFileSync } from "fs";
34
42
  function rejectAllOnNonPaginated(all, out) {
35
43
  if (all) {
36
44
  out.stderr.write("error: --all is not supported on non-paginated commands.\n");
@@ -53,7 +61,7 @@ function resolveOutputOpts(flags) {
53
61
  async function handleError(err, outOpts, out) {
54
62
  const { CurviateError } = await import("@curviate/sdk");
55
63
  if (err instanceof CurviateError) {
56
- const { getExitCode } = await import("./exit-codes-AW6KHDDN.js");
64
+ const { getExitCode } = await import("./exit-codes-TLMKTLRI.js");
57
65
  renderError(err, outOpts, out);
58
66
  process.exit(getExitCode(err));
59
67
  }
@@ -62,7 +70,7 @@ async function handleError(err, outOpts, out) {
62
70
  }
63
71
  async function runWebhookCreate(client, flags, out) {
64
72
  if (!flags.source) {
65
- out.stderr.write("error: --source is required (messaging | user | account_status | post).\n");
73
+ out.stderr.write("error: --source is required (messaging | user | account_status | post | motion).\n");
66
74
  process.exit(2);
67
75
  }
68
76
  if (!flags["request-url"]) {
@@ -73,20 +81,15 @@ async function runWebhookCreate(client, flags, out) {
73
81
  source: flags.source,
74
82
  request_url: flags["request-url"]
75
83
  };
76
- if (flags["account-ids"] !== void 0) {
77
- const accountIds = flags["account-ids"].split(",").map((s) => s.trim()).filter(Boolean);
78
- if (accountIds.length === 0) {
79
- out.stderr.write(
80
- "error: --account-ids was given an empty value. Pass acc_... ids, or omit the flag on an account_status webhook to cover every account.\n"
81
- );
84
+ for (const [flag, key, omitted] of [["account-ids", "account_ids", "omit the flag to cover every account you can operate"], ["motion-ids", "motion_ids", "omit the flag for every Motion"]]) {
85
+ if (flags[flag] === void 0) continue;
86
+ const ids = flags[flag].split(",").map((s) => s.trim()).filter(Boolean);
87
+ if (ids.length === 0) {
88
+ out.stderr.write(`error: --${flag} was given an empty value. Pass ids, or ${omitted}.
89
+ `);
82
90
  process.exit(2);
83
91
  }
84
- body["account_ids"] = accountIds;
85
- } else if (flags.source !== "account_status") {
86
- out.stderr.write(
87
- "error: --account-ids is required when --source is messaging, user or post (comma-separated acc_... ids). Only an account_status webhook may omit it.\n"
88
- );
89
- process.exit(2);
92
+ body[key] = ids;
90
93
  }
91
94
  if (flags.name) body["name"] = flags.name;
92
95
  if (flags.enabled !== void 0) body["enabled"] = flags.enabled;
@@ -223,33 +226,12 @@ async function runWebhookDelete(client, flags, out) {
223
226
  function stripTrailingNewlines(s) {
224
227
  return s.replace(/(?:\r?\n)+$/, "");
225
228
  }
226
- async function resolveWebhookBody(raw, out, readStdin = defaultReadStdin) {
229
+ async function resolveWebhookBody(raw, readStdin, others = {}) {
227
230
  if (raw === void 0 || raw === "") {
228
- out.stderr.write(
229
- "error: --body is required: pass the raw webhook body as inline JSON, as a path to a file containing it, or as - to read it from stdin.\n"
230
- );
231
- process.exit(2);
232
- }
233
- if (isStdinToken(raw)) {
234
- const piped = stripTrailingNewlines(await readStdin());
235
- if (!piped) {
236
- out.stderr.write("error: --body -: stdin: empty input\n");
237
- process.exit(2);
238
- }
239
- return piped;
240
- }
241
- if (raw.trimStart().startsWith("{")) return raw;
242
- try {
243
- return stripTrailingNewlines(readFileSync(raw, "utf8"));
244
- } catch (err) {
245
- const reason = err instanceof Error ? err.message : String(err);
246
- out.stderr.write(
247
- `error: --body: could not read ${raw}: ${reason}
248
- --body accepts inline JSON, a path to a file containing the raw body, or - to read it from stdin.
249
- `
250
- );
231
+ process.stderr.write("error: --file is required: a path to the raw webhook body, or - to read it from stdin.\n");
251
232
  process.exit(2);
252
233
  }
234
+ return stripTrailingNewlines(await readFileFlag("file", raw, { readStdin, others }));
253
235
  }
254
236
  async function runWebhookVerify(input, out) {
255
237
  const { constructEvent, WebhookSignatureError } = await import("@curviate/sdk");
@@ -286,17 +268,20 @@ var webhookCreateCommand = defineCommand({
286
268
  description: "Register a new webhook endpoint.",
287
269
  examples: [
288
270
  "curviate webhook create --source messaging --request-url https://example.com/hooks/curviate --account-ids acc_YOUR_ACCOUNT_ID",
271
+ "curviate webhook create --source motion --request-url https://example.com/hooks/curviate --motion-ids mot_YOUR_MOTION_ID",
289
272
  "curviate webhook create --source account_status --request-url https://example.com/hooks/curviate --name status"
290
- ],
291
- requires: [
292
- "--account-ids for --source messaging, user and post; omit it with --source account_status to cover every current and future account."
293
273
  ]
294
274
  },
295
275
  args: {
296
276
  ...WRITE_SINGLE_FLAGS,
297
- source: { type: "string", description: "Event source: messaging | user | account_status | post (scheduled-post results: post.published, post.publish_failed).", required: true },
277
+ source: {
278
+ type: "string",
279
+ description: "Event source: messaging | user | account_status | post (scheduled-post results: post.published, post.publish_failed) | motion (motion.status_changed, enrollment.started, enrollment.accepted, enrollment.replied, enrollment.skipped, enrollment.finished, step.failed, motion.custom_event; opt-in only, named in --events: step.executed, enrollment.seen, enrollment.reassigned).",
280
+ required: true
281
+ },
298
282
  "request-url": { type: "string", description: "HTTPS URL to receive webhook deliveries.", required: true },
299
- "account-ids": { type: "string", description: "Comma-separated account ids to target. Required for messaging, user and post; omit on account_status to cover every current and future account." },
283
+ "account-ids": { type: "string", description: "Comma-separated account ids to target. Omit to cover every account you can operate, now and later." },
284
+ "motion-ids": { type: "string", description: "Comma-separated Motion ids (mot_...): only events of these Motions are delivered, and events that carry no Motion are not. Omit for no filter." },
300
285
  name: { type: "string", description: "Human-readable name (1-100 chars)." },
301
286
  enabled: { type: "boolean", description: "Create as enabled (default: true).", default: true },
302
287
  events: { type: "string", description: "Comma-separated event names to subscribe to." },
@@ -440,6 +425,17 @@ var webhookDeleteCommand = defineCommand({
440
425
  meta: {
441
426
  name: "delete",
442
427
  description: "Permanently remove a webhook subscription.",
428
+ risk: "high",
429
+ rules: {
430
+ changes: "The webhook is deleted: no further event is delivered to its URL.",
431
+ visible_to: "Your endpoint, which stops receiving deliveries. Nothing reaches LinkedIn.",
432
+ budget_rows: [],
433
+ retry: "A retry after success answers RESOURCE_NOT_FOUND; read `curviate webhook list` first.",
434
+ undo: "Cannot be undone. Register a new one with `curviate webhook create`; it gets a new id and secret.",
435
+ blast_radius: "One webhook and every event it would have delivered."
436
+ },
437
+ errors: { RESOURCE_NOT_FOUND: "no webhook with this id." },
438
+ seeAlso: ["curviate webhook list", "curviate webhook create"],
443
439
  examples: [
444
440
  "curviate webhook delete wh_YOUR_WEBHOOK_ID"
445
441
  ]
@@ -470,7 +466,7 @@ var webhookVerifyCommand = defineCommand({
470
466
  name: "verify",
471
467
  description: "Verify a webhook signature offline (no network call). A valid signature prints the parsed event to stdout and exits 0; a mismatch prints a structured error to stdout, a summary to stderr, and exits 2.",
472
468
  examples: [
473
- 'curviate webhook verify --secret "$CURVIATE_WEBHOOK_SECRET" --header "$SIGNATURE_HEADER" --body payload.json'
469
+ 'curviate webhook verify --secret "$CURVIATE_WEBHOOK_SECRET" --header "$SIGNATURE_HEADER" --file payload.json'
474
470
  ]
475
471
  },
476
472
  // Offline: no profile, credential, transport or pagination flag applies.
@@ -486,10 +482,10 @@ var webhookVerifyCommand = defineCommand({
486
482
  description: "The full Curviate-Signature header value from the delivery (t=...,v1=...).",
487
483
  required: true
488
484
  },
489
- body: {
485
+ file: {
490
486
  type: "string",
491
487
  stdinArg: true,
492
- description: "The raw webhook body: inline JSON, a path to a file containing it, or - to read it from stdin.",
488
+ description: "The raw webhook body, byte for byte: a path to a file holding it, or - to read it from stdin.",
493
489
  required: true
494
490
  },
495
491
  "max-age-secs": {
@@ -500,15 +496,15 @@ var webhookVerifyCommand = defineCommand({
500
496
  async run({ args }) {
501
497
  const flags = args;
502
498
  const out = buildOutputStreams();
503
- const rawBody = await resolveWebhookBody(flags.body, out);
499
+ const rawBody = await resolveWebhookBody(flags.file, void 0, flags);
504
500
  const signatureHeader = flags.header ?? "";
505
501
  const secret = flags.secret ?? "";
506
- const replayWindowSecs = flags["max-age-secs"] ? parseInt(flags["max-age-secs"], 10) : void 0;
502
+ const replayWindowSecs = flags["max-age-secs"] === void 0 ? void 0 : intFlag("max-age-secs", flags["max-age-secs"]);
507
503
  await runWebhookVerify({ secret, signatureHeader, rawBody, replayWindowSecs }, out);
508
504
  }
509
505
  });
510
506
  var webhookCommand = defineCommand({
511
- meta: { name: "webhook", description: "Webhook management and signature verification." },
507
+ meta: { name: "webhook", description: DESCRIPTIONS.webhook },
512
508
  subCommands: {
513
509
  create: webhookCreateCommand,
514
510
  list: webhookListCommand,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@curviate/cli",
3
- "version": "0.47.0",
3
+ "version": "0.49.0",
4
4
  "private": false,
5
5
  "description": "Official command-line interface for the Curviate API.",
6
6
  "license": "MIT",
@@ -47,7 +47,7 @@
47
47
  "clean": "rm -rf dist *.tsbuildinfo"
48
48
  },
49
49
  "dependencies": {
50
- "@curviate/sdk": "0.42.0",
50
+ "@curviate/sdk": "0.44.0",
51
51
  "citty": "^0.1.6",
52
52
  "open": "^10.1.0"
53
53
  },
@@ -1,60 +0,0 @@
1
- #!/usr/bin/env node
2
- import {
3
- isStdinToken
4
- } from "./chunk-TC4ZPUWI.js";
5
-
6
- // src/lib/search-filters.ts
7
- import { readFile } from "fs/promises";
8
- async function readStdin() {
9
- const chunks = [];
10
- for await (const chunk of process.stdin) {
11
- chunks.push(Buffer.isBuffer(chunk) ? chunk : Buffer.from(chunk));
12
- }
13
- return Buffer.concat(chunks).toString("utf8");
14
- }
15
- var DEFAULT_FILTER_READERS = {
16
- readFile: (path) => readFile(path, "utf8"),
17
- readStdin
18
- };
19
- async function assembleFilters(flags, readers = DEFAULT_FILTER_READERS) {
20
- let raw;
21
- let source;
22
- if (flags["filters-file"] !== void 0) {
23
- source = `--filters-file ${flags["filters-file"]}`;
24
- try {
25
- raw = await readers.readFile(flags["filters-file"]);
26
- } catch {
27
- return { error: `cannot read ${source}` };
28
- }
29
- } else if (isStdinToken(flags.filters)) {
30
- source = "--filters - (stdin)";
31
- raw = await readers.readStdin();
32
- } else if (flags.filters !== void 0) {
33
- source = "--filters";
34
- raw = flags.filters;
35
- }
36
- if (raw === void 0) return { body: {} };
37
- let parsed;
38
- try {
39
- parsed = JSON.parse(raw);
40
- } catch {
41
- return { error: `${source} is not valid JSON` };
42
- }
43
- if (parsed === null || typeof parsed !== "object" || Array.isArray(parsed)) {
44
- return { error: `${source} must be a JSON object` };
45
- }
46
- return { body: parsed };
47
- }
48
- function splitCsv(value) {
49
- return value.split(",").map((s) => s.trim()).filter((s) => s.length > 0);
50
- }
51
- function splitCsvNumbers(value) {
52
- return splitCsv(value).map((s) => Number(s)).filter((n) => Number.isFinite(n));
53
- }
54
-
55
- export {
56
- DEFAULT_FILTER_READERS,
57
- assembleFilters,
58
- splitCsv,
59
- splitCsvNumbers
60
- };
@@ -1,18 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- // src/lib/examples.ts
4
- import { showUsage } from "citty";
5
- async function showUsageWithExamples(cmd, parent) {
6
- await showUsage(cmd, parent);
7
- const meta = typeof cmd.meta === "function" ? await cmd.meta() : await cmd.meta;
8
- const block = (title, lines = []) => lines.length ? process.stdout.write(`${title}
9
-
10
- ${lines.map((l) => ` ${l}`).join("\n")}
11
-
12
- `) : void 0;
13
- block("REQUIRES", meta?.requires);
14
- block("EXAMPLES", meta?.examples);
15
- }
16
- export {
17
- showUsageWithExamples
18
- };