@curviate/cli 0.46.1 → 0.48.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/CHANGELOG.md +199 -1
- package/README.md +124 -77
- package/dist/{account-O5UX5UAH.js → account-WKQHMM7P.js} +41 -31
- package/dist/{chunk-BGZW6B7G.js → chunk-5I6JJJIV.js} +1 -0
- package/dist/{chunk-76E3O6HY.js → chunk-76SWLAZ6.js} +13 -0
- package/dist/chunk-AYKKXGTR.js +1141 -0
- package/dist/{chunk-TC4ZPUWI.js → chunk-CVMSQ3OF.js} +19 -80
- package/dist/{chunk-HOQ7EUHJ.js → chunk-FDJMAF7D.js} +1 -0
- package/dist/chunk-GQKC6E5K.js +36 -0
- package/dist/{chunk-FXF5FF3W.js → chunk-MKGVNDMJ.js} +10 -2
- package/dist/chunk-NNV2OYEF.js +23 -0
- package/dist/{chunk-UJOTQPL6.js → chunk-OHXYFICP.js} +47 -14
- package/dist/{chunk-2FECYCAC.js → chunk-Q63IIPL2.js} +3 -3
- package/dist/chunk-TSOIZBBU.js +41 -0
- package/dist/{chunk-DGIDAO2H.js → chunk-Y7K4UBFC.js} +1 -1
- package/dist/{chunk-LD6WPZZM.js → chunk-YFXLXION.js} +39 -34
- package/dist/chunk-ZYURL5VK.js +83 -0
- package/dist/cli.js +77 -97
- package/dist/{comment-BKGVJYS2.js → comment-7IQ6ZOJF.js} +30 -25
- package/dist/{company-F2AZTDPK.js → company-RD7RDGSA.js} +58 -53
- package/dist/{config-K4G3VSBA.js → config-EYBNYRGK.js} +13 -5
- package/dist/{connect-TX6PT7NV.js → connect-HVXT67A6.js} +42 -38
- package/dist/core-6XYGUNAY.js +46 -0
- package/dist/{doctor-USTZQ75D.js → doctor-HUXQERLQ.js} +9 -5
- package/dist/document-AUUCGST2.js +27 -0
- package/dist/draft-DFO22K6Q.js +463 -0
- package/dist/examples-64YT5V5K.js +53 -0
- package/dist/{exit-codes-TMAIV7EM.js → exit-codes-AW6KHDDN.js} +1 -1
- package/dist/{feed-ANBPRGFQ.js → feed-JWP6ANPI.js} +15 -11
- package/dist/{group-HFF7LDDQ.js → group-SIQFJEZV.js} +17 -13
- package/dist/{inbox-XQMGW6RT.js → inbox-MMIMCA5O.js} +23 -19
- package/dist/{inboxes-CILMIVVD.js → inboxes-RND3D4C7.js} +18 -14
- package/dist/{job-TOJDDJ2P.js → job-ACFKBLFK.js} +31 -27
- package/dist/{login-OHAHNBRW.js → login-ZOB5KVKQ.js} +10 -5
- package/dist/{message-WCBNBPAJ.js → message-OFK6UVXR.js} +10 -8
- package/dist/{notification-CJ3LEHFL.js → notification-KKGAZU7M.js} +19 -15
- package/dist/{post-OQWJRL4B.js → post-A5SBCFB2.js} +36 -31
- package/dist/{profile-GT6ZD37M.js → profile-4SOOQZ4K.js} +52 -48
- package/dist/{recruiter-ZKWG6QG3.js → recruiter-YN73STDP.js} +125 -122
- package/dist/{sales-nav-WV3YHYD6.js → sales-nav-JXF5RY2K.js} +41 -35
- package/dist/{search-VAZEQ2WJ.js → search-JAL242A2.js} +68 -58
- package/dist/{setup-GGXMHXAF.js → setup-WICWH4JG.js} +14 -9
- package/dist/{webhook-5M47UX6U.js → webhook-UGKVYWBC.js} +40 -42
- package/package.json +2 -2
- package/dist/chunk-KJ24DIAJ.js +0 -60
- package/dist/examples-IJL3A6SZ.js +0 -18
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import {
|
|
3
|
+
ANNOTATIONS,
|
|
4
|
+
ENFORCED,
|
|
5
|
+
MAX_DOCUMENT_BYTES,
|
|
6
|
+
documentSchema,
|
|
7
|
+
parseDocument,
|
|
8
|
+
readFileFlag,
|
|
9
|
+
readStdinCapped,
|
|
10
|
+
renderDocument,
|
|
11
|
+
reportIssues,
|
|
12
|
+
validate
|
|
13
|
+
} from "./chunk-AYKKXGTR.js";
|
|
14
|
+
import "./chunk-FDJMAF7D.js";
|
|
15
|
+
import "./chunk-ZYURL5VK.js";
|
|
16
|
+
export {
|
|
17
|
+
ANNOTATIONS,
|
|
18
|
+
ENFORCED,
|
|
19
|
+
MAX_DOCUMENT_BYTES,
|
|
20
|
+
documentSchema,
|
|
21
|
+
parseDocument,
|
|
22
|
+
readFileFlag,
|
|
23
|
+
readStdinCapped,
|
|
24
|
+
renderDocument,
|
|
25
|
+
reportIssues,
|
|
26
|
+
validate
|
|
27
|
+
};
|
|
@@ -0,0 +1,463 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import {
|
|
3
|
+
AttachError,
|
|
4
|
+
guessContentType,
|
|
5
|
+
readAttachment,
|
|
6
|
+
toAttachmentPayload
|
|
7
|
+
} from "./chunk-5I6JJJIV.js";
|
|
8
|
+
import {
|
|
9
|
+
buildPreviewOutput
|
|
10
|
+
} from "./chunk-TCUYH5GO.js";
|
|
11
|
+
import {
|
|
12
|
+
pageDelayFromFlags,
|
|
13
|
+
readCursorFlag,
|
|
14
|
+
readMaxPagesFlag,
|
|
15
|
+
readableObject,
|
|
16
|
+
readablePage,
|
|
17
|
+
rejectPaginationModifiersWithoutAll,
|
|
18
|
+
renderError,
|
|
19
|
+
renderSuccess,
|
|
20
|
+
renderUnexpectedError,
|
|
21
|
+
resolveEffectiveConfig,
|
|
22
|
+
streamAll,
|
|
23
|
+
writeNdjsonItem
|
|
24
|
+
} from "./chunk-MKGVNDMJ.js";
|
|
25
|
+
import {
|
|
26
|
+
createClient
|
|
27
|
+
} from "./chunk-OHXYFICP.js";
|
|
28
|
+
import {
|
|
29
|
+
GLOBAL_FLAGS,
|
|
30
|
+
READ_SINGLE_FLAGS,
|
|
31
|
+
WRITE_SINGLE_FLAGS,
|
|
32
|
+
readOnly
|
|
33
|
+
} from "./chunk-CVMSQ3OF.js";
|
|
34
|
+
import {
|
|
35
|
+
DESCRIPTIONS
|
|
36
|
+
} from "./chunk-GQKC6E5K.js";
|
|
37
|
+
import {
|
|
38
|
+
resolveTextOrStdin
|
|
39
|
+
} from "./chunk-ZYURL5VK.js";
|
|
40
|
+
|
|
41
|
+
// src/commands/draft.ts
|
|
42
|
+
import { defineCommand } from "citty";
|
|
43
|
+
import { basename } from "path";
|
|
44
|
+
var INLINE_FILE_BYTES = 5 * 1024 * 1024;
|
|
45
|
+
var MAX_IMAGE_BYTES = 5 * 1024 * 1024;
|
|
46
|
+
var INLINE_BODY_BYTES = 9 * 1024 * 1024;
|
|
47
|
+
var LIST_STATUSES = ["draft", "scheduled", "failed", "published"];
|
|
48
|
+
function buildOutputStreams() {
|
|
49
|
+
return {
|
|
50
|
+
stdout: { write: (s) => process.stdout.write(s) },
|
|
51
|
+
stderr: { write: (s) => process.stderr.write(s) }
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
function resolveOutputOpts(flags) {
|
|
55
|
+
return {
|
|
56
|
+
json: (flags.json ?? false) || !process.stdout.isTTY,
|
|
57
|
+
isTTY: process.stdout.isTTY ?? false,
|
|
58
|
+
fields: flags.fields
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
function rejectAllOnNonPaginated(all, out) {
|
|
62
|
+
if (all) {
|
|
63
|
+
out.stderr.write("error: --all is not supported on non-paginated commands.\n");
|
|
64
|
+
process.exit(2);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
async function handleError(err, outOpts, out) {
|
|
68
|
+
const { CurviateError } = await import("@curviate/sdk");
|
|
69
|
+
if (err instanceof CurviateError) {
|
|
70
|
+
const { getExitCode } = await import("./exit-codes-AW6KHDDN.js");
|
|
71
|
+
renderError(err, outOpts, out);
|
|
72
|
+
process.exit(getExitCode(err));
|
|
73
|
+
}
|
|
74
|
+
renderUnexpectedError(err, out);
|
|
75
|
+
process.exit(1);
|
|
76
|
+
}
|
|
77
|
+
function readAccount(flags, out) {
|
|
78
|
+
if (flags.account === void 0) return void 0;
|
|
79
|
+
if (flags.account.trim() === "") {
|
|
80
|
+
out.stderr.write("error: --account was given an empty value. Pass an acc_... id, or omit the flag for a Draft with no account.\n");
|
|
81
|
+
process.exit(2);
|
|
82
|
+
}
|
|
83
|
+
return flags.account;
|
|
84
|
+
}
|
|
85
|
+
function readSchedule(flags, out) {
|
|
86
|
+
if (flags["schedule-at"] !== void 0 && flags.unschedule) {
|
|
87
|
+
out.stderr.write("error: --schedule-at and --unschedule cannot be combined.\n");
|
|
88
|
+
process.exit(2);
|
|
89
|
+
}
|
|
90
|
+
if (flags["schedule-at"] !== void 0) {
|
|
91
|
+
if (flags["schedule-at"].trim() === "") {
|
|
92
|
+
out.stderr.write("error: --schedule-at was given an empty value. Pass an ISO 8601 time with an offset, e.g. 2026-10-12T09:00:00+02:00, or use --unschedule.\n");
|
|
93
|
+
process.exit(2);
|
|
94
|
+
}
|
|
95
|
+
return { scheduled_at: flags["schedule-at"] };
|
|
96
|
+
}
|
|
97
|
+
if (flags.unschedule) return { scheduled_at: null };
|
|
98
|
+
return {};
|
|
99
|
+
}
|
|
100
|
+
function attachPaths(attach) {
|
|
101
|
+
if (!attach) return [];
|
|
102
|
+
return Array.isArray(attach) ? attach : [attach];
|
|
103
|
+
}
|
|
104
|
+
async function loadFiles(paths, out) {
|
|
105
|
+
try {
|
|
106
|
+
return await Promise.all(paths.map(async (path) => ({ path, buf: await readAttachment(path) })));
|
|
107
|
+
} catch (err) {
|
|
108
|
+
if (err instanceof AttachError) {
|
|
109
|
+
out.stderr.write(`error: ${err.message}
|
|
110
|
+
`);
|
|
111
|
+
process.exit(err.exitCode);
|
|
112
|
+
}
|
|
113
|
+
throw err;
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
function refuseOversizeImages(files, out) {
|
|
117
|
+
for (const f of files) {
|
|
118
|
+
if (guessContentType(f.path).startsWith("image/") && f.buf.byteLength > MAX_IMAGE_BYTES) {
|
|
119
|
+
out.stderr.write(
|
|
120
|
+
`error: ${basename(f.path)} is an image over 5 MiB (${f.buf.byteLength} bytes). Images are capped at 5 MiB; resize it. Nothing was sent.
|
|
121
|
+
`
|
|
122
|
+
);
|
|
123
|
+
process.exit(2);
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
function planAttachments(files) {
|
|
128
|
+
let bodyBytes = 0;
|
|
129
|
+
let i = 0;
|
|
130
|
+
for (; i < files.length; i++) {
|
|
131
|
+
const size = files[i].buf.byteLength;
|
|
132
|
+
const encoded = Math.ceil(size / 3) * 4;
|
|
133
|
+
if (size > INLINE_FILE_BYTES || bodyBytes + encoded > INLINE_BODY_BYTES) break;
|
|
134
|
+
bodyBytes += encoded;
|
|
135
|
+
}
|
|
136
|
+
return { inline: files.slice(0, i), upload: files.slice(i) };
|
|
137
|
+
}
|
|
138
|
+
function previewAttachments(files) {
|
|
139
|
+
return files.map((f) => ({ name: basename(f.path), buffer: f.buf }));
|
|
140
|
+
}
|
|
141
|
+
async function uploadAll(client, draftId, files, out) {
|
|
142
|
+
let last;
|
|
143
|
+
for (const f of files) {
|
|
144
|
+
try {
|
|
145
|
+
last = await client.drafts.uploadAttachment(draftId, f.buf, {
|
|
146
|
+
filename: basename(f.path),
|
|
147
|
+
contentType: guessContentType(f.path)
|
|
148
|
+
});
|
|
149
|
+
} catch (err) {
|
|
150
|
+
out.stderr.write(`error: uploading ${basename(f.path)} to draft ${draftId} failed; the Draft exists with the files before it. Fix the cause and add the rest with \`curviate core draft update ${draftId} --attach <file>\`.
|
|
151
|
+
`);
|
|
152
|
+
throw err;
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
return last;
|
|
156
|
+
}
|
|
157
|
+
async function runDraftList(client, flags, out) {
|
|
158
|
+
rejectPaginationModifiersWithoutAll(flags, out);
|
|
159
|
+
const outOpts = resolveOutputOpts(flags);
|
|
160
|
+
const all = flags.all ?? false;
|
|
161
|
+
const maxPages = readMaxPagesFlag(flags, out);
|
|
162
|
+
const cursor = readCursorFlag(flags, out);
|
|
163
|
+
const params = {};
|
|
164
|
+
if (flags.status !== void 0) {
|
|
165
|
+
const status = flags.status.split(",").map((s) => s.trim()).filter(Boolean);
|
|
166
|
+
const bad = status.filter((s) => !LIST_STATUSES.includes(s));
|
|
167
|
+
if (status.length === 0 || bad.length > 0) {
|
|
168
|
+
out.stderr.write(`error: --status takes a comma list of ${LIST_STATUSES.join(", ")}${bad.length ? `. Got: ${bad.join(", ")}` : ""}.
|
|
169
|
+
`);
|
|
170
|
+
process.exit(2);
|
|
171
|
+
}
|
|
172
|
+
params["status"] = status;
|
|
173
|
+
}
|
|
174
|
+
const account = readAccount(flags, out);
|
|
175
|
+
if (account !== void 0) params["account_id"] = account;
|
|
176
|
+
if (flags.from !== void 0) params["from"] = flags.from;
|
|
177
|
+
if (flags.to !== void 0) params["to"] = flags.to;
|
|
178
|
+
if (flags.order !== void 0) {
|
|
179
|
+
if (flags.order !== "asc" && flags.order !== "desc") {
|
|
180
|
+
out.stderr.write("error: --order takes asc or desc.\n");
|
|
181
|
+
process.exit(2);
|
|
182
|
+
}
|
|
183
|
+
params["order"] = flags.order;
|
|
184
|
+
}
|
|
185
|
+
if (flags.limit !== void 0) params["limit"] = parseInt(flags.limit, 10);
|
|
186
|
+
if (cursor) params["cursor"] = cursor;
|
|
187
|
+
try {
|
|
188
|
+
if (all) {
|
|
189
|
+
const fn = (p) => client.drafts.list(p);
|
|
190
|
+
for await (const item of streamAll(fn, params, { maxPages, out, pageDelayMs: pageDelayFromFlags(flags) })) {
|
|
191
|
+
writeNdjsonItem(out, item, outOpts.fields);
|
|
192
|
+
}
|
|
193
|
+
} else {
|
|
194
|
+
const result = await client.drafts.list(params);
|
|
195
|
+
readablePage(result);
|
|
196
|
+
renderSuccess(result, outOpts, out);
|
|
197
|
+
}
|
|
198
|
+
} catch (err) {
|
|
199
|
+
await handleError(err, outOpts, out);
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
async function runDraftGet(client, flags, out) {
|
|
203
|
+
rejectAllOnNonPaginated(flags.all, out);
|
|
204
|
+
const outOpts = resolveOutputOpts(flags);
|
|
205
|
+
try {
|
|
206
|
+
const result = await client.drafts.get(flags.id ?? "");
|
|
207
|
+
readableObject(result);
|
|
208
|
+
renderSuccess(result, outOpts, out);
|
|
209
|
+
} catch (err) {
|
|
210
|
+
await handleError(err, outOpts, out);
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
async function runDraftCreate(client, flags, out, readStdin) {
|
|
214
|
+
const body = {};
|
|
215
|
+
if (flags.unschedule) {
|
|
216
|
+
out.stderr.write("error: --unschedule applies to `curviate core draft update`; a new Draft is unscheduled unless you pass --schedule-at.\n");
|
|
217
|
+
process.exit(2);
|
|
218
|
+
}
|
|
219
|
+
const account = readAccount(flags, out);
|
|
220
|
+
if (account !== void 0) body["account_id"] = account;
|
|
221
|
+
if (flags.text !== void 0) body["text"] = await resolveTextOrStdin(flags.text, out, readStdin);
|
|
222
|
+
Object.assign(body, readSchedule(flags, out));
|
|
223
|
+
const files = await loadFiles(attachPaths(flags.attach), out);
|
|
224
|
+
refuseOversizeImages(files, out);
|
|
225
|
+
const { inline, upload } = planAttachments(files);
|
|
226
|
+
if (inline.length > 0) body["attachments"] = inline.map((f) => toAttachmentPayload(f.path, f.buf));
|
|
227
|
+
const outOpts = resolveOutputOpts(flags);
|
|
228
|
+
if (flags.preview) {
|
|
229
|
+
const preview = buildPreviewOutput({
|
|
230
|
+
method: "drafts.create",
|
|
231
|
+
args: {},
|
|
232
|
+
body: { ...body, attachments: void 0 },
|
|
233
|
+
attachments: previewAttachments(inline)
|
|
234
|
+
});
|
|
235
|
+
out.stdout.write(JSON.stringify({ ...preview, ...upload.length ? { uploads: upload.map((f) => `${basename(f.path)} (${f.buf.byteLength} bytes)`) } : {} }) + "\n");
|
|
236
|
+
return;
|
|
237
|
+
}
|
|
238
|
+
try {
|
|
239
|
+
const created = await client.drafts.create(body);
|
|
240
|
+
const result = upload.length > 0 ? await uploadAll(client, created.id, upload, out) : created;
|
|
241
|
+
renderSuccess(result, outOpts, out);
|
|
242
|
+
} catch (err) {
|
|
243
|
+
await handleError(err, outOpts, out);
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
async function runDraftUpdate(client, flags, out, readStdin) {
|
|
247
|
+
const id = flags.id ?? "";
|
|
248
|
+
const body = {};
|
|
249
|
+
const account = readAccount(flags, out);
|
|
250
|
+
if (account !== void 0) body["account_id"] = account;
|
|
251
|
+
if (flags.text !== void 0) body["text"] = await resolveTextOrStdin(flags.text, out, readStdin);
|
|
252
|
+
Object.assign(body, readSchedule(flags, out));
|
|
253
|
+
const files = await loadFiles(attachPaths(flags.attach), out);
|
|
254
|
+
refuseOversizeImages(files, out);
|
|
255
|
+
const { inline, upload } = planAttachments(files);
|
|
256
|
+
const outOpts = resolveOutputOpts(flags);
|
|
257
|
+
if (flags.preview) {
|
|
258
|
+
const preview = buildPreviewOutput({
|
|
259
|
+
method: "drafts.update",
|
|
260
|
+
args: { id },
|
|
261
|
+
body,
|
|
262
|
+
attachments: previewAttachments(inline)
|
|
263
|
+
});
|
|
264
|
+
out.stdout.write(JSON.stringify({ ...preview, ...upload.length ? { uploads: upload.map((f) => `${basename(f.path)} (${f.buf.byteLength} bytes)`) } : {} }) + "\n");
|
|
265
|
+
return;
|
|
266
|
+
}
|
|
267
|
+
try {
|
|
268
|
+
if (inline.length > 0) {
|
|
269
|
+
const current = await client.drafts.get(id);
|
|
270
|
+
body["attachments"] = [
|
|
271
|
+
...(current.attachments ?? []).map((a) => ({ id: a.id })),
|
|
272
|
+
...inline.map((f) => toAttachmentPayload(f.path, f.buf))
|
|
273
|
+
];
|
|
274
|
+
}
|
|
275
|
+
let result = await client.drafts.update(id, body);
|
|
276
|
+
if (upload.length > 0) result = await uploadAll(client, id, upload, out);
|
|
277
|
+
renderSuccess(result, outOpts, out);
|
|
278
|
+
} catch (err) {
|
|
279
|
+
await handleError(err, outOpts, out);
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
async function runDraftDelete(client, flags, out) {
|
|
283
|
+
const id = flags.id ?? "";
|
|
284
|
+
const outOpts = resolveOutputOpts(flags);
|
|
285
|
+
if (flags.preview) {
|
|
286
|
+
out.stdout.write(JSON.stringify(buildPreviewOutput({ method: "drafts.delete", args: { id }, body: {} })) + "\n");
|
|
287
|
+
return;
|
|
288
|
+
}
|
|
289
|
+
try {
|
|
290
|
+
const result = await client.drafts.delete(id);
|
|
291
|
+
renderSuccess(result, outOpts, out);
|
|
292
|
+
} catch (err) {
|
|
293
|
+
await handleError(err, outOpts, out);
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
async function runDraftPublish(client, flags, out) {
|
|
297
|
+
const id = flags.id ?? "";
|
|
298
|
+
const outOpts = resolveOutputOpts(flags);
|
|
299
|
+
if (flags.preview) {
|
|
300
|
+
out.stdout.write(JSON.stringify(buildPreviewOutput({ method: "drafts.publish", args: { id }, body: {} })) + "\n");
|
|
301
|
+
return;
|
|
302
|
+
}
|
|
303
|
+
try {
|
|
304
|
+
const result = await client.drafts.publish(id);
|
|
305
|
+
renderSuccess(result, outOpts, out);
|
|
306
|
+
} catch (err) {
|
|
307
|
+
await handleError(err, outOpts, out);
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
async function withClient(flags, fn) {
|
|
311
|
+
const cfg = await resolveEffectiveConfig({
|
|
312
|
+
apiKey: flags["api-key"],
|
|
313
|
+
baseUrl: flags["base-url"],
|
|
314
|
+
timeout: flags.timeout,
|
|
315
|
+
profile: flags.profile
|
|
316
|
+
});
|
|
317
|
+
if (!cfg.apiKey) {
|
|
318
|
+
process.stderr.write("error: no API key, run `curviate login` or pass --api-key.\n");
|
|
319
|
+
process.exit(3);
|
|
320
|
+
}
|
|
321
|
+
const client = createClient({ apiKey: cfg.apiKey, baseUrl: cfg.baseUrl, timeout: cfg.timeout });
|
|
322
|
+
await fn(client, flags, buildOutputStreams());
|
|
323
|
+
}
|
|
324
|
+
var ACCOUNT_DESC = "Account the Draft publishes as (acc_...). Never defaulted: omit it for a Draft with no account yet.";
|
|
325
|
+
var SCHEDULE_DESC = "Publish at this time: ISO 8601 with an offset (e.g. 2026-10-12T09:00:00+02:00), passed through unchanged. Between 5 minutes and 365 days ahead, at least 5 minutes from another scheduled Draft on the same account. Needs an account and text.";
|
|
326
|
+
var ATTACH_DESC = "File to attach, repeatable; keeps the order given. Files up to 5 MiB go inline, larger ones upload separately. Up to 20 images (JPEG, PNG, GIF, WEBP, each up to 5 MiB), or one MP4 video, or one PDF (each up to 50 MiB), never mixed.";
|
|
327
|
+
var draftListCommand = defineCommand({
|
|
328
|
+
meta: {
|
|
329
|
+
name: "list",
|
|
330
|
+
description: "List Drafts, newest first. With --status published it lists publish records instead (post id, account, time; never Drafts).",
|
|
331
|
+
examples: [
|
|
332
|
+
"curviate core draft list",
|
|
333
|
+
"curviate core draft list --status scheduled --account acc_YOUR_ACCOUNT_ID --order asc",
|
|
334
|
+
"curviate core draft list --status scheduled,published --from 2026-10-01T00:00:00Z --to 2026-11-01T00:00:00Z"
|
|
335
|
+
]
|
|
336
|
+
},
|
|
337
|
+
args: {
|
|
338
|
+
...readOnly(GLOBAL_FLAGS),
|
|
339
|
+
status: { type: "string", description: "Comma list of draft, scheduled, failed, published (default draft,scheduled,failed)." },
|
|
340
|
+
account: { type: "string", description: "Only this account's items (acc_...), or none for Drafts with no account. Omit for all of yours." },
|
|
341
|
+
from: { type: "string", description: "Only items dated at or after this ISO 8601 time (each item's own date: scheduled_at, failure.failed_at, published_at or updated_at)." },
|
|
342
|
+
to: { type: "string", description: "Only items dated before this ISO 8601 time (exclusive)." },
|
|
343
|
+
order: { type: "string", description: "desc (default) or asc, by the item's own date." }
|
|
344
|
+
},
|
|
345
|
+
async run({ args }) {
|
|
346
|
+
await withClient(args, runDraftList);
|
|
347
|
+
}
|
|
348
|
+
});
|
|
349
|
+
var draftGetCommand = defineCommand({
|
|
350
|
+
meta: {
|
|
351
|
+
name: "get",
|
|
352
|
+
description: "Get one Draft, with a fresh signed link (valid 1 hour) for each attachment.",
|
|
353
|
+
examples: ["curviate core draft get drf_YOUR_DRAFT_ID"]
|
|
354
|
+
},
|
|
355
|
+
args: {
|
|
356
|
+
...readOnly(READ_SINGLE_FLAGS),
|
|
357
|
+
id: { type: "positional", description: "Draft id (drf_...)." }
|
|
358
|
+
},
|
|
359
|
+
async run({ args }) {
|
|
360
|
+
await withClient(args, runDraftGet);
|
|
361
|
+
}
|
|
362
|
+
});
|
|
363
|
+
var draftCreateCommand = defineCommand({
|
|
364
|
+
meta: {
|
|
365
|
+
name: "create",
|
|
366
|
+
description: "Store a Draft. Every part is optional. With --schedule-at (and an account and text) Curviate publishes it at that time. Up to 50 Drafts and 2 GiB of media per account, and per no-account. A retry creates a second Draft.",
|
|
367
|
+
examples: [
|
|
368
|
+
'curviate core draft create "Three things we learned shipping our first agent integration."',
|
|
369
|
+
'curviate core draft create "Launch day." --account acc_YOUR_ACCOUNT_ID --schedule-at 2026-10-12T09:00:00+02:00',
|
|
370
|
+
'curviate core draft create "Demo." --account acc_YOUR_ACCOUNT_ID --attach screenshot.png'
|
|
371
|
+
]
|
|
372
|
+
},
|
|
373
|
+
args: {
|
|
374
|
+
...WRITE_SINGLE_FLAGS,
|
|
375
|
+
text: { type: "positional", required: false, stdinArg: true, description: "Post text (up to 3000 characters). Pass - to read from stdin." },
|
|
376
|
+
account: { type: "string", description: ACCOUNT_DESC },
|
|
377
|
+
"schedule-at": { type: "string", description: SCHEDULE_DESC },
|
|
378
|
+
attach: { type: "string", description: ATTACH_DESC }
|
|
379
|
+
},
|
|
380
|
+
async run({ args }) {
|
|
381
|
+
await withClient(args, runDraftCreate);
|
|
382
|
+
}
|
|
383
|
+
});
|
|
384
|
+
var draftUpdateCommand = defineCommand({
|
|
385
|
+
meta: {
|
|
386
|
+
name: "update",
|
|
387
|
+
description: "Change a Draft: only the parts you pass change. --attach appends files; --schedule-at schedules or reschedules, --unschedule cancels. Any update to a failed Draft clears its failure. A Draft being published answers DRAFT_PUBLISHING: read it again in a few seconds.",
|
|
388
|
+
examples: [
|
|
389
|
+
'curviate core draft update drf_YOUR_DRAFT_ID --text "New wording."',
|
|
390
|
+
"curviate core draft update drf_YOUR_DRAFT_ID --schedule-at 2026-10-12T09:00:00+02:00",
|
|
391
|
+
"curviate core draft update drf_YOUR_DRAFT_ID --unschedule"
|
|
392
|
+
]
|
|
393
|
+
},
|
|
394
|
+
args: {
|
|
395
|
+
...WRITE_SINGLE_FLAGS,
|
|
396
|
+
id: { type: "positional", description: "Draft id (drf_...)." },
|
|
397
|
+
text: { type: "string", stdinArg: true, description: "Replace the text (up to 3000 characters). Pass - to read from stdin." },
|
|
398
|
+
account: { type: "string", description: "Move the Draft to another of your accounts (acc_...)." },
|
|
399
|
+
"schedule-at": { type: "string", description: SCHEDULE_DESC },
|
|
400
|
+
unschedule: { type: "boolean", description: "Cancel the schedule; the Draft stays a Draft." },
|
|
401
|
+
attach: { type: "string", description: ATTACH_DESC }
|
|
402
|
+
},
|
|
403
|
+
async run({ args }) {
|
|
404
|
+
await withClient(args, runDraftUpdate);
|
|
405
|
+
}
|
|
406
|
+
});
|
|
407
|
+
var draftDeleteCommand = defineCommand({
|
|
408
|
+
meta: {
|
|
409
|
+
name: "delete",
|
|
410
|
+
description: "Delete a Draft and its stored media.",
|
|
411
|
+
examples: ["curviate core draft delete drf_YOUR_DRAFT_ID"]
|
|
412
|
+
},
|
|
413
|
+
args: {
|
|
414
|
+
...WRITE_SINGLE_FLAGS,
|
|
415
|
+
id: { type: "positional", description: "Draft id (drf_...)." }
|
|
416
|
+
},
|
|
417
|
+
async run({ args }) {
|
|
418
|
+
await withClient(args, runDraftDelete);
|
|
419
|
+
}
|
|
420
|
+
});
|
|
421
|
+
var draftPublishCommand = defineCommand({
|
|
422
|
+
meta: {
|
|
423
|
+
name: "publish",
|
|
424
|
+
description: "Publish a Draft now, under the same rules and safety limits as `curviate core post create`. Success deletes the Draft and prints the post id; a known failure leaves the Draft unchanged. If the error says the outcome is unknown, the post may be live: check the account's posts before retrying.",
|
|
425
|
+
examples: ["curviate core draft publish drf_YOUR_DRAFT_ID"]
|
|
426
|
+
},
|
|
427
|
+
args: {
|
|
428
|
+
...WRITE_SINGLE_FLAGS,
|
|
429
|
+
id: { type: "positional", description: "Draft id (drf_...)." }
|
|
430
|
+
},
|
|
431
|
+
async run({ args }) {
|
|
432
|
+
await withClient(args, runDraftPublish);
|
|
433
|
+
}
|
|
434
|
+
});
|
|
435
|
+
var draftCommand = defineCommand({
|
|
436
|
+
meta: { name: "draft", description: DESCRIPTIONS.draft },
|
|
437
|
+
subCommands: {
|
|
438
|
+
list: draftListCommand,
|
|
439
|
+
get: draftGetCommand,
|
|
440
|
+
create: draftCreateCommand,
|
|
441
|
+
update: draftUpdateCommand,
|
|
442
|
+
delete: draftDeleteCommand,
|
|
443
|
+
publish: draftPublishCommand
|
|
444
|
+
},
|
|
445
|
+
async run() {
|
|
446
|
+
process.stderr.write(
|
|
447
|
+
'Usage: curviate core draft <subcommand>\n list | get <id> | create ["<text>"] | update <id> | delete <id> | publish <id>\n'
|
|
448
|
+
);
|
|
449
|
+
}
|
|
450
|
+
});
|
|
451
|
+
export {
|
|
452
|
+
INLINE_BODY_BYTES,
|
|
453
|
+
INLINE_FILE_BYTES,
|
|
454
|
+
MAX_IMAGE_BYTES,
|
|
455
|
+
draftCommand,
|
|
456
|
+
planAttachments,
|
|
457
|
+
runDraftCreate,
|
|
458
|
+
runDraftDelete,
|
|
459
|
+
runDraftGet,
|
|
460
|
+
runDraftList,
|
|
461
|
+
runDraftPublish,
|
|
462
|
+
runDraftUpdate
|
|
463
|
+
};
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import {
|
|
3
|
+
EXIT_CODE_MAP
|
|
4
|
+
} from "./chunk-76SWLAZ6.js";
|
|
5
|
+
|
|
6
|
+
// src/lib/examples.ts
|
|
7
|
+
import { renderUsage } from "citty";
|
|
8
|
+
var SECTION_ORDER = ["DOCUMENT", "RULES", "REQUIRES", "OUTPUT", "ERRORS", "SEE ALSO", "EXAMPLES"];
|
|
9
|
+
var exitOf = (code) => EXIT_CODE_MAP[code] ?? 1;
|
|
10
|
+
function renderRules(rules) {
|
|
11
|
+
if (!rules) return [];
|
|
12
|
+
const rows = rules.budget_rows;
|
|
13
|
+
return [
|
|
14
|
+
rules.changes && `Changes: ${rules.changes}`,
|
|
15
|
+
rules.visible_to && `Visible to: ${rules.visible_to}`,
|
|
16
|
+
rows && `Budget rows: ${rows.length ? `${rows.join(", ")} (see \`curviate account get <account_id>\`)` : "none"}`,
|
|
17
|
+
rules.retry && `Retry: ${rules.retry}`,
|
|
18
|
+
rules.undo && `Undo: ${rules.undo}`,
|
|
19
|
+
rules.blast_radius && `Blast radius: ${rules.blast_radius}`,
|
|
20
|
+
...rules.notes ?? []
|
|
21
|
+
].filter((l) => typeof l === "string" && l !== "");
|
|
22
|
+
}
|
|
23
|
+
async function renderSections(cmd) {
|
|
24
|
+
const meta = typeof cmd.meta === "function" ? await cmd.meta() : await cmd.meta;
|
|
25
|
+
const { renderDocument } = meta?.document ? await import("./document-AUUCGST2.js") : { renderDocument: () => [] };
|
|
26
|
+
const body = {
|
|
27
|
+
DOCUMENT: meta?.document ? renderDocument(meta.document) : void 0,
|
|
28
|
+
RULES: renderRules(meta?.rules),
|
|
29
|
+
REQUIRES: meta?.requires,
|
|
30
|
+
OUTPUT: meta?.output,
|
|
31
|
+
ERRORS: meta?.errors && Object.entries(meta.errors).map(([code, when]) => `${code} (exit ${exitOf(code)}): ${when}`),
|
|
32
|
+
"SEE ALSO": meta?.seeAlso,
|
|
33
|
+
EXAMPLES: meta?.examples
|
|
34
|
+
};
|
|
35
|
+
return SECTION_ORDER.filter((t) => body[t]?.length).map((t) => `${t}
|
|
36
|
+
|
|
37
|
+
${body[t].map((l) => ` ${l}`).join("\n")}
|
|
38
|
+
|
|
39
|
+
`).join("");
|
|
40
|
+
}
|
|
41
|
+
async function showHelp(cmd, path) {
|
|
42
|
+
const parent = path.length > 1 ? { meta: { name: path.slice(0, -1).join(" ") } } : void 0;
|
|
43
|
+
const subs = typeof cmd.subCommands === "function" ? await cmd.subCommands() : await cmd.subCommands;
|
|
44
|
+
const listed = subs && Object.fromEntries(
|
|
45
|
+
Object.entries(subs).map(([k, v]) => [k, typeof v === "function" && "description" in v ? { meta: { description: v.description } } : v])
|
|
46
|
+
);
|
|
47
|
+
process.stdout.write(await renderUsage({ ...cmd, subCommands: listed }, parent) + "\n\n" + await renderSections(cmd));
|
|
48
|
+
}
|
|
49
|
+
export {
|
|
50
|
+
SECTION_ORDER,
|
|
51
|
+
renderSections,
|
|
52
|
+
showHelp
|
|
53
|
+
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import {
|
|
3
3
|
requireAccount
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-Q63IIPL2.js";
|
|
5
5
|
import {
|
|
6
6
|
pageDelayFromFlags,
|
|
7
7
|
readCursorFlag,
|
|
@@ -14,15 +14,19 @@ import {
|
|
|
14
14
|
resolveEffectiveConfig,
|
|
15
15
|
streamAll,
|
|
16
16
|
writeNdjsonItem
|
|
17
|
-
} from "./chunk-
|
|
18
|
-
import "./chunk-
|
|
17
|
+
} from "./chunk-MKGVNDMJ.js";
|
|
18
|
+
import "./chunk-76SWLAZ6.js";
|
|
19
19
|
import {
|
|
20
20
|
createClient
|
|
21
|
-
} from "./chunk-
|
|
21
|
+
} from "./chunk-OHXYFICP.js";
|
|
22
22
|
import {
|
|
23
23
|
GLOBAL_FLAGS,
|
|
24
24
|
readOnly
|
|
25
|
-
} from "./chunk-
|
|
25
|
+
} from "./chunk-CVMSQ3OF.js";
|
|
26
|
+
import {
|
|
27
|
+
DESCRIPTIONS
|
|
28
|
+
} from "./chunk-GQKC6E5K.js";
|
|
29
|
+
import "./chunk-ZYURL5VK.js";
|
|
26
30
|
|
|
27
31
|
// src/commands/feed.ts
|
|
28
32
|
import { defineCommand } from "citty";
|
|
@@ -43,7 +47,7 @@ function resolveOutputOpts(flags) {
|
|
|
43
47
|
async function handleSdkError(err, outOpts, out) {
|
|
44
48
|
const { CurviateError } = await import("@curviate/sdk");
|
|
45
49
|
if (err instanceof CurviateError) {
|
|
46
|
-
const { getExitCode } = await import("./exit-codes-
|
|
50
|
+
const { getExitCode } = await import("./exit-codes-AW6KHDDN.js");
|
|
47
51
|
renderError(err, outOpts, out);
|
|
48
52
|
process.exit(getExitCode(err));
|
|
49
53
|
}
|
|
@@ -93,9 +97,9 @@ var feedHomeCommand = defineCommand({
|
|
|
93
97
|
name: "home",
|
|
94
98
|
description: "Read the connected account's LinkedIn home feed as agent-actionable posts. Every post carries its text and created_at. On the default recent sort every engagement count is null (unknown, not zero) and only the author's name resolves; --sort relevant fills engagement and the author's ids.",
|
|
95
99
|
examples: [
|
|
96
|
-
"curviate feed home",
|
|
97
|
-
"curviate feed home --sort relevant",
|
|
98
|
-
"curviate feed home --all --max-pages 3"
|
|
100
|
+
"curviate core feed home",
|
|
101
|
+
"curviate core feed home --sort relevant",
|
|
102
|
+
"curviate core feed home --all --max-pages 3"
|
|
99
103
|
]
|
|
100
104
|
},
|
|
101
105
|
args: FEED_ARGS,
|
|
@@ -118,13 +122,13 @@ var feedHomeCommand = defineCommand({
|
|
|
118
122
|
}
|
|
119
123
|
});
|
|
120
124
|
var feedCommand = defineCommand({
|
|
121
|
-
meta: { name: "feed", description:
|
|
125
|
+
meta: { name: "feed", description: DESCRIPTIONS.feed },
|
|
122
126
|
subCommands: {
|
|
123
127
|
home: feedHomeCommand
|
|
124
128
|
},
|
|
125
129
|
async run() {
|
|
126
130
|
process.stderr.write(
|
|
127
|
-
"Usage: curviate feed <subcommand>\n home [--sort recent|relevant] [--limit] [--cursor] [--all]\n"
|
|
131
|
+
"Usage: curviate core feed <subcommand>\n home [--sort recent|relevant] [--limit] [--cursor] [--all]\n"
|
|
128
132
|
);
|
|
129
133
|
}
|
|
130
134
|
});
|