@curviate/cli 0.1.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 +22 -0
- package/LICENSE +21 -0
- package/README.md +174 -0
- package/dist/account-YOW2MCZS.js +639 -0
- package/dist/chunk-2NCPJJPC.js +140 -0
- package/dist/chunk-6JNCLLNY.js +195 -0
- package/dist/chunk-BNUTM6KD.js +33 -0
- package/dist/chunk-Q43HZUN3.js +29 -0
- package/dist/chunk-R3VLWLVV.js +23 -0
- package/dist/chunk-SND3NHCT.js +46 -0
- package/dist/chunk-UWO2D4HW.js +34 -0
- package/dist/cli.js +159 -0
- package/dist/company-IKVDW7MX.js +82 -0
- package/dist/config-4JOXBFYX.js +262 -0
- package/dist/connect-HLDHFBGX.js +348 -0
- package/dist/exit-codes-NFIR57ZA.js +57 -0
- package/dist/inbox-JBLYJMV2.js +294 -0
- package/dist/login-VWJEBBFU.js +122 -0
- package/dist/message-IK7VGB63.js +566 -0
- package/dist/post-EAAGVR5D.js +496 -0
- package/dist/profile-WXA3NC7D.js +352 -0
- package/dist/recruiter-TGCV36EH.js +984 -0
- package/dist/sales-nav-XGFO5I6F.js +488 -0
- package/dist/search-LHPTHPWH.js +354 -0
- package/dist/webhook-QM5LGAUF.js +445 -0
- package/package.json +54 -0
|
@@ -0,0 +1,496 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import {
|
|
3
|
+
AttachError,
|
|
4
|
+
readAttachment
|
|
5
|
+
} from "./chunk-Q43HZUN3.js";
|
|
6
|
+
import {
|
|
7
|
+
buildPreviewOutput
|
|
8
|
+
} from "./chunk-R3VLWLVV.js";
|
|
9
|
+
import {
|
|
10
|
+
streamAll
|
|
11
|
+
} from "./chunk-SND3NHCT.js";
|
|
12
|
+
import {
|
|
13
|
+
createClient,
|
|
14
|
+
renderError,
|
|
15
|
+
renderSuccess,
|
|
16
|
+
renderUnexpectedError,
|
|
17
|
+
resolveEffectiveConfig
|
|
18
|
+
} from "./chunk-2NCPJJPC.js";
|
|
19
|
+
import {
|
|
20
|
+
GLOBAL_FLAGS
|
|
21
|
+
} from "./chunk-6JNCLLNY.js";
|
|
22
|
+
|
|
23
|
+
// src/commands/post.ts
|
|
24
|
+
import { defineCommand } from "citty";
|
|
25
|
+
function buildOutputStreams() {
|
|
26
|
+
return {
|
|
27
|
+
stdout: { write: (s) => process.stdout.write(s) },
|
|
28
|
+
stderr: { write: (s) => process.stderr.write(s) }
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
function requireAccount(account, out) {
|
|
32
|
+
if (!account) {
|
|
33
|
+
out.stderr.write("error: --account is required for this command. Set it via --account, CURVIATE_ACCOUNT, or `curviate config set-account`.\n");
|
|
34
|
+
process.exit(2);
|
|
35
|
+
}
|
|
36
|
+
return account;
|
|
37
|
+
}
|
|
38
|
+
function rejectPreviewOnRead(preview, out) {
|
|
39
|
+
if (preview) {
|
|
40
|
+
out.stderr.write("error: --preview is only valid on write commands (mutations). Reads just run.\n");
|
|
41
|
+
process.exit(2);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
function rejectAllOnNonPaginated(all, out) {
|
|
45
|
+
if (all) {
|
|
46
|
+
out.stderr.write("error: --all is not supported on non-paginated commands.\n");
|
|
47
|
+
process.exit(2);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
function resolveOutputOpts(flags) {
|
|
51
|
+
return {
|
|
52
|
+
json: (flags.json ?? false) || !process.stdout.isTTY,
|
|
53
|
+
isTTY: process.stdout.isTTY ?? false,
|
|
54
|
+
fields: flags.fields
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
function buildPaginationParams(flags) {
|
|
58
|
+
const params = {};
|
|
59
|
+
if (flags.limit !== void 0) params["limit"] = parseInt(flags.limit, 10);
|
|
60
|
+
if (flags.cursor) params["cursor"] = flags.cursor;
|
|
61
|
+
return params;
|
|
62
|
+
}
|
|
63
|
+
function normalizeAttachPaths(attach) {
|
|
64
|
+
if (!attach) return [];
|
|
65
|
+
return Array.isArray(attach) ? attach : [attach];
|
|
66
|
+
}
|
|
67
|
+
async function handleSdkError(err, outOpts, out) {
|
|
68
|
+
const { CurviateError } = await import("@curviate/sdk");
|
|
69
|
+
if (err instanceof CurviateError) {
|
|
70
|
+
const { getExitCode } = await import("./exit-codes-NFIR57ZA.js");
|
|
71
|
+
renderError(err, outOpts, out);
|
|
72
|
+
process.exit(getExitCode(err.code));
|
|
73
|
+
}
|
|
74
|
+
renderUnexpectedError(err, out);
|
|
75
|
+
process.exit(1);
|
|
76
|
+
}
|
|
77
|
+
async function runPostList(client, flags, out) {
|
|
78
|
+
rejectPreviewOnRead(flags.preview, out);
|
|
79
|
+
const accountId = requireAccount(flags.account, out);
|
|
80
|
+
const ns = client.account(accountId);
|
|
81
|
+
const outOpts = resolveOutputOpts(flags);
|
|
82
|
+
const all = flags.all ?? false;
|
|
83
|
+
const maxPages = flags["max-pages"] ? parseInt(flags["max-pages"], 10) : 100;
|
|
84
|
+
const params = buildPaginationParams(flags);
|
|
85
|
+
try {
|
|
86
|
+
if (all) {
|
|
87
|
+
const fn = (p) => ns.posts.list(p);
|
|
88
|
+
for await (const item of streamAll(fn, params, {
|
|
89
|
+
maxPages,
|
|
90
|
+
onTruncated: (msg) => out.stderr.write(msg + "\n")
|
|
91
|
+
})) {
|
|
92
|
+
out.stdout.write(JSON.stringify(item) + "\n");
|
|
93
|
+
}
|
|
94
|
+
} else {
|
|
95
|
+
const result = await ns.posts.list(params);
|
|
96
|
+
renderSuccess(result, outOpts, out);
|
|
97
|
+
}
|
|
98
|
+
} catch (err) {
|
|
99
|
+
await handleSdkError(err, outOpts, out);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
async function runPostGet(client, flags, out) {
|
|
103
|
+
rejectPreviewOnRead(flags.preview, out);
|
|
104
|
+
rejectAllOnNonPaginated(flags.all, out);
|
|
105
|
+
const accountId = requireAccount(flags.account, out);
|
|
106
|
+
const postId = flags.postId ?? "";
|
|
107
|
+
const ns = client.account(accountId);
|
|
108
|
+
const outOpts = resolveOutputOpts(flags);
|
|
109
|
+
try {
|
|
110
|
+
const result = await ns.posts.get(postId);
|
|
111
|
+
renderSuccess(result, outOpts, out);
|
|
112
|
+
} catch (err) {
|
|
113
|
+
await handleSdkError(err, outOpts, out);
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
async function runPostCreate(client, flags, out) {
|
|
117
|
+
const accountId = requireAccount(flags.account, out);
|
|
118
|
+
const text = flags.text ?? "";
|
|
119
|
+
const attachPaths = normalizeAttachPaths(flags.attach);
|
|
120
|
+
const thumbPath = flags["video-thumbnail"];
|
|
121
|
+
let attachBuffers = [];
|
|
122
|
+
try {
|
|
123
|
+
attachBuffers = await Promise.all(attachPaths.map((p) => readAttachment(p)));
|
|
124
|
+
} catch (err) {
|
|
125
|
+
if (err instanceof AttachError) {
|
|
126
|
+
out.stderr.write(`error: ${err.message}
|
|
127
|
+
`);
|
|
128
|
+
process.exit(err.exitCode);
|
|
129
|
+
}
|
|
130
|
+
throw err;
|
|
131
|
+
}
|
|
132
|
+
let thumbBuffer;
|
|
133
|
+
if (thumbPath) {
|
|
134
|
+
try {
|
|
135
|
+
thumbBuffer = await readAttachment(thumbPath);
|
|
136
|
+
} catch (err) {
|
|
137
|
+
if (err instanceof AttachError) {
|
|
138
|
+
out.stderr.write(`error: ${err.message}
|
|
139
|
+
`);
|
|
140
|
+
process.exit(err.exitCode);
|
|
141
|
+
}
|
|
142
|
+
throw err;
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
if (flags.preview) {
|
|
146
|
+
const allAttachmentPreviews = attachBuffers.map((buf, i) => ({
|
|
147
|
+
name: attachPaths[i] ? attachPaths[i].split("/").pop() ?? attachPaths[i] : `attachment_${i}`,
|
|
148
|
+
buffer: buf
|
|
149
|
+
}));
|
|
150
|
+
if (thumbBuffer && thumbPath) {
|
|
151
|
+
allAttachmentPreviews.push({
|
|
152
|
+
name: `video_thumbnail:${thumbPath.split("/").pop() ?? thumbPath}`,
|
|
153
|
+
buffer: thumbBuffer
|
|
154
|
+
});
|
|
155
|
+
}
|
|
156
|
+
const preview = buildPreviewOutput({
|
|
157
|
+
method: "posts.create",
|
|
158
|
+
args: {},
|
|
159
|
+
body: { text },
|
|
160
|
+
account: accountId,
|
|
161
|
+
attachments: allAttachmentPreviews
|
|
162
|
+
});
|
|
163
|
+
out.stdout.write(JSON.stringify(preview) + "\n");
|
|
164
|
+
return;
|
|
165
|
+
}
|
|
166
|
+
const body = { text };
|
|
167
|
+
if (attachBuffers.length > 0) {
|
|
168
|
+
body["attachments"] = attachBuffers;
|
|
169
|
+
}
|
|
170
|
+
if (thumbBuffer) {
|
|
171
|
+
body["video_thumbnail"] = thumbBuffer;
|
|
172
|
+
}
|
|
173
|
+
const ns = client.account(accountId);
|
|
174
|
+
const outOpts = resolveOutputOpts(flags);
|
|
175
|
+
try {
|
|
176
|
+
const result = await ns.posts.create(body);
|
|
177
|
+
renderSuccess(result, outOpts, out);
|
|
178
|
+
} catch (err) {
|
|
179
|
+
await handleSdkError(err, outOpts, out);
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
async function runPostComment(client, flags, out) {
|
|
183
|
+
const accountId = requireAccount(flags.account, out);
|
|
184
|
+
const postId = flags.postId ?? "";
|
|
185
|
+
const text = flags.text ?? "";
|
|
186
|
+
const attachPaths = normalizeAttachPaths(flags.attach);
|
|
187
|
+
let attachBuffers = [];
|
|
188
|
+
try {
|
|
189
|
+
attachBuffers = await Promise.all(attachPaths.map((p) => readAttachment(p)));
|
|
190
|
+
} catch (err) {
|
|
191
|
+
if (err instanceof AttachError) {
|
|
192
|
+
out.stderr.write(`error: ${err.message}
|
|
193
|
+
`);
|
|
194
|
+
process.exit(err.exitCode);
|
|
195
|
+
}
|
|
196
|
+
throw err;
|
|
197
|
+
}
|
|
198
|
+
if (flags.preview) {
|
|
199
|
+
const preview = buildPreviewOutput({
|
|
200
|
+
method: "posts.comment",
|
|
201
|
+
args: { post_id: postId },
|
|
202
|
+
body: { text },
|
|
203
|
+
account: accountId,
|
|
204
|
+
attachments: attachBuffers.map((buf, i) => ({
|
|
205
|
+
name: attachPaths[i] ? attachPaths[i].split("/").pop() ?? attachPaths[i] : `attachment_${i}`,
|
|
206
|
+
buffer: buf
|
|
207
|
+
}))
|
|
208
|
+
});
|
|
209
|
+
out.stdout.write(JSON.stringify(preview) + "\n");
|
|
210
|
+
return;
|
|
211
|
+
}
|
|
212
|
+
const body = { text };
|
|
213
|
+
if (attachBuffers.length > 0) {
|
|
214
|
+
body["attachments"] = attachBuffers;
|
|
215
|
+
}
|
|
216
|
+
const ns = client.account(accountId);
|
|
217
|
+
const outOpts = resolveOutputOpts(flags);
|
|
218
|
+
try {
|
|
219
|
+
const result = await ns.posts.comment(postId, body);
|
|
220
|
+
renderSuccess(result, outOpts, out);
|
|
221
|
+
} catch (err) {
|
|
222
|
+
await handleSdkError(err, outOpts, out);
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
async function runPostComments(client, flags, out) {
|
|
226
|
+
rejectPreviewOnRead(flags.preview, out);
|
|
227
|
+
const accountId = requireAccount(flags.account, out);
|
|
228
|
+
const postId = flags.postId ?? "";
|
|
229
|
+
const ns = client.account(accountId);
|
|
230
|
+
const outOpts = resolveOutputOpts(flags);
|
|
231
|
+
const all = flags.all ?? false;
|
|
232
|
+
const maxPages = flags["max-pages"] ? parseInt(flags["max-pages"], 10) : 100;
|
|
233
|
+
const params = buildPaginationParams(flags);
|
|
234
|
+
try {
|
|
235
|
+
if (all) {
|
|
236
|
+
const fn = (p) => ns.posts.listComments(postId, p);
|
|
237
|
+
for await (const item of streamAll(fn, params, {
|
|
238
|
+
maxPages,
|
|
239
|
+
onTruncated: (msg) => out.stderr.write(msg + "\n")
|
|
240
|
+
})) {
|
|
241
|
+
out.stdout.write(JSON.stringify(item) + "\n");
|
|
242
|
+
}
|
|
243
|
+
} else {
|
|
244
|
+
const result = await ns.posts.listComments(postId, params);
|
|
245
|
+
renderSuccess(result, outOpts, out);
|
|
246
|
+
}
|
|
247
|
+
} catch (err) {
|
|
248
|
+
await handleSdkError(err, outOpts, out);
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
async function runPostReact(client, flags, out) {
|
|
252
|
+
const accountId = requireAccount(flags.account, out);
|
|
253
|
+
const postId = flags.postId ?? "";
|
|
254
|
+
const reaction = flags.reaction ?? "";
|
|
255
|
+
if (flags.preview) {
|
|
256
|
+
const preview = buildPreviewOutput({
|
|
257
|
+
method: "posts.react",
|
|
258
|
+
args: { post_id: postId },
|
|
259
|
+
body: { reaction },
|
|
260
|
+
account: accountId
|
|
261
|
+
});
|
|
262
|
+
out.stdout.write(JSON.stringify(preview) + "\n");
|
|
263
|
+
return;
|
|
264
|
+
}
|
|
265
|
+
const ns = client.account(accountId);
|
|
266
|
+
const outOpts = resolveOutputOpts(flags);
|
|
267
|
+
try {
|
|
268
|
+
const result = await ns.posts.react(postId, { reaction });
|
|
269
|
+
renderSuccess(result, outOpts, out);
|
|
270
|
+
} catch (err) {
|
|
271
|
+
await handleSdkError(err, outOpts, out);
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
async function runPostReactions(client, flags, out) {
|
|
275
|
+
rejectPreviewOnRead(flags.preview, out);
|
|
276
|
+
const accountId = requireAccount(flags.account, out);
|
|
277
|
+
const postId = flags.postId ?? "";
|
|
278
|
+
const ns = client.account(accountId);
|
|
279
|
+
const outOpts = resolveOutputOpts(flags);
|
|
280
|
+
const all = flags.all ?? false;
|
|
281
|
+
const maxPages = flags["max-pages"] ? parseInt(flags["max-pages"], 10) : 100;
|
|
282
|
+
const params = buildPaginationParams(flags);
|
|
283
|
+
try {
|
|
284
|
+
if (all) {
|
|
285
|
+
const fn = (p) => ns.posts.listReactions(postId, p);
|
|
286
|
+
for await (const item of streamAll(fn, params, {
|
|
287
|
+
maxPages,
|
|
288
|
+
onTruncated: (msg) => out.stderr.write(msg + "\n")
|
|
289
|
+
})) {
|
|
290
|
+
out.stdout.write(JSON.stringify(item) + "\n");
|
|
291
|
+
}
|
|
292
|
+
} else {
|
|
293
|
+
const result = await ns.posts.listReactions(postId, params);
|
|
294
|
+
renderSuccess(result, outOpts, out);
|
|
295
|
+
}
|
|
296
|
+
} catch (err) {
|
|
297
|
+
await handleSdkError(err, outOpts, out);
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
var postListCommand = defineCommand({
|
|
301
|
+
meta: { name: "list", description: "List posts published by the account." },
|
|
302
|
+
args: { ...GLOBAL_FLAGS },
|
|
303
|
+
async run({ args }) {
|
|
304
|
+
const flags = args;
|
|
305
|
+
const cfg = await resolveEffectiveConfig({
|
|
306
|
+
apiKey: flags["api-key"],
|
|
307
|
+
baseUrl: flags["base-url"],
|
|
308
|
+
timeout: flags.timeout,
|
|
309
|
+
account: flags.account,
|
|
310
|
+
profile: flags.profile
|
|
311
|
+
});
|
|
312
|
+
if (!cfg.apiKey) {
|
|
313
|
+
process.stderr.write("error: no API key \u2014 run `curviate login` or pass --api-key.\n");
|
|
314
|
+
process.exit(3);
|
|
315
|
+
}
|
|
316
|
+
const client = createClient({ apiKey: cfg.apiKey, baseUrl: cfg.baseUrl, timeout: cfg.timeout });
|
|
317
|
+
const out = buildOutputStreams();
|
|
318
|
+
await runPostList(client, { ...flags, account: flags.account ?? cfg.account }, out);
|
|
319
|
+
}
|
|
320
|
+
});
|
|
321
|
+
var postGetCommand = defineCommand({
|
|
322
|
+
meta: { name: "get", description: "Get a post by ID." },
|
|
323
|
+
args: {
|
|
324
|
+
...GLOBAL_FLAGS,
|
|
325
|
+
postId: { type: "positional", description: "Post social_id or URN." }
|
|
326
|
+
},
|
|
327
|
+
async run({ args }) {
|
|
328
|
+
const flags = args;
|
|
329
|
+
const cfg = await resolveEffectiveConfig({
|
|
330
|
+
apiKey: flags["api-key"],
|
|
331
|
+
baseUrl: flags["base-url"],
|
|
332
|
+
timeout: flags.timeout,
|
|
333
|
+
account: flags.account,
|
|
334
|
+
profile: flags.profile
|
|
335
|
+
});
|
|
336
|
+
if (!cfg.apiKey) {
|
|
337
|
+
process.stderr.write("error: no API key \u2014 run `curviate login` or pass --api-key.\n");
|
|
338
|
+
process.exit(3);
|
|
339
|
+
}
|
|
340
|
+
const client = createClient({ apiKey: cfg.apiKey, baseUrl: cfg.baseUrl, timeout: cfg.timeout });
|
|
341
|
+
const out = buildOutputStreams();
|
|
342
|
+
await runPostGet(client, { ...flags, account: flags.account ?? cfg.account }, out);
|
|
343
|
+
}
|
|
344
|
+
});
|
|
345
|
+
var postCreateCommand = defineCommand({
|
|
346
|
+
meta: { name: "create", description: "Create a new post." },
|
|
347
|
+
args: {
|
|
348
|
+
...GLOBAL_FLAGS,
|
|
349
|
+
text: { type: "positional", description: "Post body text." },
|
|
350
|
+
attach: { type: "string", description: "File to attach (repeatable)." },
|
|
351
|
+
"video-thumbnail": { type: "string", description: "Video thumbnail file." }
|
|
352
|
+
},
|
|
353
|
+
async run({ args }) {
|
|
354
|
+
const flags = args;
|
|
355
|
+
const cfg = await resolveEffectiveConfig({
|
|
356
|
+
apiKey: flags["api-key"],
|
|
357
|
+
baseUrl: flags["base-url"],
|
|
358
|
+
timeout: flags.timeout,
|
|
359
|
+
account: flags.account,
|
|
360
|
+
profile: flags.profile
|
|
361
|
+
});
|
|
362
|
+
if (!cfg.apiKey) {
|
|
363
|
+
process.stderr.write("error: no API key \u2014 run `curviate login` or pass --api-key.\n");
|
|
364
|
+
process.exit(3);
|
|
365
|
+
}
|
|
366
|
+
const client = createClient({ apiKey: cfg.apiKey, baseUrl: cfg.baseUrl, timeout: cfg.timeout });
|
|
367
|
+
const out = buildOutputStreams();
|
|
368
|
+
await runPostCreate(client, { ...flags, account: flags.account ?? cfg.account }, out);
|
|
369
|
+
}
|
|
370
|
+
});
|
|
371
|
+
var postCommentCommand = defineCommand({
|
|
372
|
+
meta: { name: "comment", description: "Comment on a post." },
|
|
373
|
+
args: {
|
|
374
|
+
...GLOBAL_FLAGS,
|
|
375
|
+
postId: { type: "positional", description: "Post social_id or URN." },
|
|
376
|
+
text: { type: "positional", description: "Comment text." },
|
|
377
|
+
attach: { type: "string", description: "Image to attach (optional)." }
|
|
378
|
+
},
|
|
379
|
+
async run({ args }) {
|
|
380
|
+
const flags = args;
|
|
381
|
+
const cfg = await resolveEffectiveConfig({
|
|
382
|
+
apiKey: flags["api-key"],
|
|
383
|
+
baseUrl: flags["base-url"],
|
|
384
|
+
timeout: flags.timeout,
|
|
385
|
+
account: flags.account,
|
|
386
|
+
profile: flags.profile
|
|
387
|
+
});
|
|
388
|
+
if (!cfg.apiKey) {
|
|
389
|
+
process.stderr.write("error: no API key \u2014 run `curviate login` or pass --api-key.\n");
|
|
390
|
+
process.exit(3);
|
|
391
|
+
}
|
|
392
|
+
const client = createClient({ apiKey: cfg.apiKey, baseUrl: cfg.baseUrl, timeout: cfg.timeout });
|
|
393
|
+
const out = buildOutputStreams();
|
|
394
|
+
await runPostComment(client, { ...flags, account: flags.account ?? cfg.account }, out);
|
|
395
|
+
}
|
|
396
|
+
});
|
|
397
|
+
var postCommentsCommand = defineCommand({
|
|
398
|
+
meta: { name: "comments", description: "List comments on a post." },
|
|
399
|
+
args: {
|
|
400
|
+
...GLOBAL_FLAGS,
|
|
401
|
+
postId: { type: "positional", description: "Post social_id or URN." }
|
|
402
|
+
},
|
|
403
|
+
async run({ args }) {
|
|
404
|
+
const flags = args;
|
|
405
|
+
const cfg = await resolveEffectiveConfig({
|
|
406
|
+
apiKey: flags["api-key"],
|
|
407
|
+
baseUrl: flags["base-url"],
|
|
408
|
+
timeout: flags.timeout,
|
|
409
|
+
account: flags.account,
|
|
410
|
+
profile: flags.profile
|
|
411
|
+
});
|
|
412
|
+
if (!cfg.apiKey) {
|
|
413
|
+
process.stderr.write("error: no API key \u2014 run `curviate login` or pass --api-key.\n");
|
|
414
|
+
process.exit(3);
|
|
415
|
+
}
|
|
416
|
+
const client = createClient({ apiKey: cfg.apiKey, baseUrl: cfg.baseUrl, timeout: cfg.timeout });
|
|
417
|
+
const out = buildOutputStreams();
|
|
418
|
+
await runPostComments(client, { ...flags, account: flags.account ?? cfg.account }, out);
|
|
419
|
+
}
|
|
420
|
+
});
|
|
421
|
+
var postReactCommand = defineCommand({
|
|
422
|
+
meta: { name: "react", description: "React to a post." },
|
|
423
|
+
args: {
|
|
424
|
+
...GLOBAL_FLAGS,
|
|
425
|
+
postId: { type: "positional", description: "Post social_id or URN." },
|
|
426
|
+
reaction: { type: "string", description: "Reaction type (like | celebrate | support | love | insightful | funny).", required: true }
|
|
427
|
+
},
|
|
428
|
+
async run({ args }) {
|
|
429
|
+
const flags = args;
|
|
430
|
+
const cfg = await resolveEffectiveConfig({
|
|
431
|
+
apiKey: flags["api-key"],
|
|
432
|
+
baseUrl: flags["base-url"],
|
|
433
|
+
timeout: flags.timeout,
|
|
434
|
+
account: flags.account,
|
|
435
|
+
profile: flags.profile
|
|
436
|
+
});
|
|
437
|
+
if (!cfg.apiKey) {
|
|
438
|
+
process.stderr.write("error: no API key \u2014 run `curviate login` or pass --api-key.\n");
|
|
439
|
+
process.exit(3);
|
|
440
|
+
}
|
|
441
|
+
const client = createClient({ apiKey: cfg.apiKey, baseUrl: cfg.baseUrl, timeout: cfg.timeout });
|
|
442
|
+
const out = buildOutputStreams();
|
|
443
|
+
await runPostReact(client, { ...flags, account: flags.account ?? cfg.account }, out);
|
|
444
|
+
}
|
|
445
|
+
});
|
|
446
|
+
var postReactionsCommand = defineCommand({
|
|
447
|
+
meta: { name: "reactions", description: "List reactions on a post." },
|
|
448
|
+
args: {
|
|
449
|
+
...GLOBAL_FLAGS,
|
|
450
|
+
postId: { type: "positional", description: "Post social_id or URN." }
|
|
451
|
+
},
|
|
452
|
+
async run({ args }) {
|
|
453
|
+
const flags = args;
|
|
454
|
+
const cfg = await resolveEffectiveConfig({
|
|
455
|
+
apiKey: flags["api-key"],
|
|
456
|
+
baseUrl: flags["base-url"],
|
|
457
|
+
timeout: flags.timeout,
|
|
458
|
+
account: flags.account,
|
|
459
|
+
profile: flags.profile
|
|
460
|
+
});
|
|
461
|
+
if (!cfg.apiKey) {
|
|
462
|
+
process.stderr.write("error: no API key \u2014 run `curviate login` or pass --api-key.\n");
|
|
463
|
+
process.exit(3);
|
|
464
|
+
}
|
|
465
|
+
const client = createClient({ apiKey: cfg.apiKey, baseUrl: cfg.baseUrl, timeout: cfg.timeout });
|
|
466
|
+
const out = buildOutputStreams();
|
|
467
|
+
await runPostReactions(client, { ...flags, account: flags.account ?? cfg.account }, out);
|
|
468
|
+
}
|
|
469
|
+
});
|
|
470
|
+
var postCommand = defineCommand({
|
|
471
|
+
meta: { name: "post", description: "Create and manage LinkedIn posts." },
|
|
472
|
+
subCommands: {
|
|
473
|
+
list: postListCommand,
|
|
474
|
+
get: postGetCommand,
|
|
475
|
+
create: postCreateCommand,
|
|
476
|
+
comment: postCommentCommand,
|
|
477
|
+
comments: postCommentsCommand,
|
|
478
|
+
react: postReactCommand,
|
|
479
|
+
reactions: postReactionsCommand
|
|
480
|
+
},
|
|
481
|
+
async run() {
|
|
482
|
+
process.stderr.write(
|
|
483
|
+
'Usage: curviate post <subcommand>\n list\n get <post_id>\n create "<text>" [--attach <file>\u2026] [--video-thumbnail <file>]\n comment <post_id> "<text>" [--attach <file>]\n comments <post_id>\n react <post_id> --reaction <r>\n reactions <post_id>\n'
|
|
484
|
+
);
|
|
485
|
+
}
|
|
486
|
+
});
|
|
487
|
+
export {
|
|
488
|
+
postCommand,
|
|
489
|
+
runPostComment,
|
|
490
|
+
runPostComments,
|
|
491
|
+
runPostCreate,
|
|
492
|
+
runPostGet,
|
|
493
|
+
runPostList,
|
|
494
|
+
runPostReact,
|
|
495
|
+
runPostReactions
|
|
496
|
+
};
|