@curviate/cli 0.32.0 → 0.34.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 +264 -1
- package/README.md +13 -1
- package/dist/{account-JDSZC633.js → account-463D5EVY.js} +90 -47
- package/dist/{chunk-JRKM4OV2.js → chunk-6W7364S3.js} +1 -1
- package/dist/{chunk-KQXYEQAD.js → chunk-7JU4IXXG.js} +172 -8
- package/dist/{chunk-5EJDQ47B.js → chunk-BN7L7WSY.js} +16 -16
- package/dist/chunk-DCZR4M7G.js +327 -0
- package/dist/{chunk-V3PB4HSF.js → chunk-MNDXMGPX.js} +68 -24
- package/dist/chunk-TCUYH5GO.js +34 -0
- package/dist/{chunk-SKJNLN37.js → chunk-XDQHNUEU.js} +86 -2
- package/dist/{chunk-LJR4LJG6.js → chunk-XP2LN6F6.js} +53 -0
- package/dist/{chunk-EIEF2KFH.js → chunk-XZJQQJBE.js} +6 -4
- package/dist/{chunk-6P52Q2GK.js → chunk-ZJ7D3NFS.js} +5 -4
- package/dist/cli.js +104 -37
- package/dist/{comment-YOFNFQUE.js → comment-G6RB2PBZ.js} +32 -26
- package/dist/{company-6PKHDK6L.js → company-OWND3W3L.js} +53 -35
- package/dist/{config-FUHT23SX.js → config-RUBXWFQ3.js} +74 -29
- package/dist/{connect-DG2AVGVL.js → connect-3E7EC5ZM.js} +35 -32
- package/dist/{doctor-FK7B6754.js → doctor-Z6OSCGKT.js} +22 -16
- package/dist/{exit-codes-AAFTOAXF.js → exit-codes-YSFFFWMS.js} +1 -1
- package/dist/{feed-HXBKXKAQ.js → feed-VDTFIMKN.js} +18 -17
- package/dist/{group-UYX3KTX3.js → group-KDJHY2IM.js} +21 -18
- package/dist/{inbox-EVE2ZTHC.js → inbox-DQLX2LR7.js} +39 -23
- package/dist/{inboxes-JBB34WMQ.js → inboxes-WMNHOPY7.js} +18 -17
- package/dist/{job-GXUZANYN.js → job-ESKS2LDJ.js} +44 -30
- package/dist/{login-3OAUY7TG.js → login-YTVPIN27.js} +15 -3
- package/dist/{message-34AGROW2.js → message-5W2R3YHS.js} +7 -9
- package/dist/{notification-SKKZS2C5.js → notification-IGNUH2GR.js} +20 -19
- package/dist/{post-FIW522Q6.js → post-NLI76K74.js} +34 -26
- package/dist/{profile-SX6JOYMD.js → profile-TBKKIICM.js} +71 -90
- package/dist/{recruiter-H7ROBEVC.js → recruiter-AEJRHIX5.js} +42 -29
- package/dist/{sales-nav-7KCK562X.js → sales-nav-SW6WJVMD.js} +43 -29
- package/dist/{search-PASMDQEH.js → search-CS6VN5AG.js} +58 -44
- package/dist/{setup-YV5PVIU5.js → setup-ANHJZJ2S.js} +12 -8
- package/dist/{webhook-GPLFPC6N.js → webhook-NGMRJMQ5.js} +25 -22
- package/package.json +2 -2
- package/dist/chunk-LKF5MZIP.js +0 -90
- package/dist/chunk-PKSKQ3LN.js +0 -68
- package/dist/chunk-R3VLWLVV.js +0 -23
- package/dist/chunk-TD2ZIXFR.js +0 -67
- package/dist/chunk-TQJ77SL4.js +0 -147
|
@@ -1,11 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import {
|
|
3
3
|
resolveMemberOrMeProviderId
|
|
4
|
-
} from "./chunk-
|
|
5
|
-
import {
|
|
6
|
-
pageDelayFromFlags,
|
|
7
|
-
streamAll
|
|
8
|
-
} from "./chunk-LKF5MZIP.js";
|
|
4
|
+
} from "./chunk-ZJ7D3NFS.js";
|
|
9
5
|
import {
|
|
10
6
|
AttachError,
|
|
11
7
|
describeAttachment,
|
|
@@ -13,29 +9,32 @@ import {
|
|
|
13
9
|
toAttachmentPayload
|
|
14
10
|
} from "./chunk-BGZW6B7G.js";
|
|
15
11
|
import "./chunk-UEAX6KUB.js";
|
|
16
|
-
import {
|
|
17
|
-
buildPreviewOutput
|
|
18
|
-
} from "./chunk-R3VLWLVV.js";
|
|
19
12
|
import {
|
|
20
13
|
requireAccount
|
|
21
|
-
} from "./chunk-
|
|
14
|
+
} from "./chunk-MNDXMGPX.js";
|
|
22
15
|
import {
|
|
16
|
+
buildPreviewOutput
|
|
17
|
+
} from "./chunk-TCUYH5GO.js";
|
|
18
|
+
import {
|
|
19
|
+
pageDelayFromFlags,
|
|
20
|
+
readablePage,
|
|
21
|
+
rejectPaginationModifiersWithoutAll,
|
|
23
22
|
renderError,
|
|
24
23
|
renderSuccess,
|
|
25
|
-
renderUnexpectedError
|
|
26
|
-
|
|
24
|
+
renderUnexpectedError,
|
|
25
|
+
resolveEffectiveConfig,
|
|
26
|
+
streamAll,
|
|
27
|
+
writeNdjsonItem
|
|
28
|
+
} from "./chunk-7JU4IXXG.js";
|
|
29
|
+
import "./chunk-XZJQQJBE.js";
|
|
27
30
|
import {
|
|
28
|
-
createClient
|
|
29
|
-
|
|
30
|
-
} from "./chunk-TD2ZIXFR.js";
|
|
31
|
-
import "./chunk-PKSKQ3LN.js";
|
|
32
|
-
import "./chunk-EIEF2KFH.js";
|
|
33
|
-
import "./chunk-TQJ77SL4.js";
|
|
31
|
+
createClient
|
|
32
|
+
} from "./chunk-DCZR4M7G.js";
|
|
34
33
|
import {
|
|
35
34
|
GLOBAL_FLAGS,
|
|
36
35
|
WRITE_SINGLE_FLAGS,
|
|
37
36
|
resolveTextOrStdin
|
|
38
|
-
} from "./chunk-
|
|
37
|
+
} from "./chunk-XDQHNUEU.js";
|
|
39
38
|
|
|
40
39
|
// src/commands/comment.ts
|
|
41
40
|
import { defineCommand } from "citty";
|
|
@@ -69,16 +68,15 @@ function buildListQuery(flags) {
|
|
|
69
68
|
async function handleSdkError(err, outOpts, out) {
|
|
70
69
|
const { CurviateError } = await import("@curviate/sdk");
|
|
71
70
|
if (err instanceof CurviateError) {
|
|
72
|
-
const { getExitCode } = await import("./exit-codes-
|
|
71
|
+
const { getExitCode } = await import("./exit-codes-YSFFFWMS.js");
|
|
73
72
|
renderError(err, outOpts, out);
|
|
74
|
-
process.exit(getExitCode(err
|
|
73
|
+
process.exit(getExitCode(err));
|
|
75
74
|
}
|
|
76
75
|
renderUnexpectedError(err, out);
|
|
77
76
|
process.exit(1);
|
|
78
77
|
}
|
|
79
78
|
function normalizeAttachPaths(attach) {
|
|
80
|
-
|
|
81
|
-
return Array.isArray(attach) ? attach : [attach];
|
|
79
|
+
return attach ? [attach] : [];
|
|
82
80
|
}
|
|
83
81
|
function assertReaction(reaction, out) {
|
|
84
82
|
if (!REACTIONS.includes(reaction)) {
|
|
@@ -91,6 +89,7 @@ function assertReaction(reaction, out) {
|
|
|
91
89
|
}
|
|
92
90
|
async function runCommentList(client, flags, out) {
|
|
93
91
|
rejectPreviewOnRead(flags.preview, out);
|
|
92
|
+
rejectPaginationModifiersWithoutAll(flags, out);
|
|
94
93
|
const accountId = await requireAccount(client, flags, out);
|
|
95
94
|
const postId = flags.postId ?? "";
|
|
96
95
|
const ns = client.account(accountId);
|
|
@@ -106,10 +105,11 @@ async function runCommentList(client, flags, out) {
|
|
|
106
105
|
out,
|
|
107
106
|
pageDelayMs: pageDelayFromFlags(flags)
|
|
108
107
|
})) {
|
|
109
|
-
out
|
|
108
|
+
writeNdjsonItem(out, item, outOpts.fields);
|
|
110
109
|
}
|
|
111
110
|
} else {
|
|
112
111
|
const result = await ns.posts.listComments(postId, params);
|
|
112
|
+
readablePage(result);
|
|
113
113
|
renderSuccess(result, outOpts, out);
|
|
114
114
|
}
|
|
115
115
|
} catch (err) {
|
|
@@ -118,6 +118,7 @@ async function runCommentList(client, flags, out) {
|
|
|
118
118
|
}
|
|
119
119
|
async function runCommentReplies(client, flags, out) {
|
|
120
120
|
rejectPreviewOnRead(flags.preview, out);
|
|
121
|
+
rejectPaginationModifiersWithoutAll(flags, out);
|
|
121
122
|
const accountId = await requireAccount(client, flags, out);
|
|
122
123
|
const postId = flags.postId ?? "";
|
|
123
124
|
const commentId = flags.commentId ?? "";
|
|
@@ -134,10 +135,11 @@ async function runCommentReplies(client, flags, out) {
|
|
|
134
135
|
out,
|
|
135
136
|
pageDelayMs: pageDelayFromFlags(flags)
|
|
136
137
|
})) {
|
|
137
|
-
out
|
|
138
|
+
writeNdjsonItem(out, item, outOpts.fields);
|
|
138
139
|
}
|
|
139
140
|
} else {
|
|
140
141
|
const result = await ns.comments.listReplies(postId, commentId, params);
|
|
142
|
+
readablePage(result);
|
|
141
143
|
renderSuccess(result, outOpts, out);
|
|
142
144
|
}
|
|
143
145
|
} catch (err) {
|
|
@@ -146,6 +148,7 @@ async function runCommentReplies(client, flags, out) {
|
|
|
146
148
|
}
|
|
147
149
|
async function runCommentReactions(client, flags, out) {
|
|
148
150
|
rejectPreviewOnRead(flags.preview, out);
|
|
151
|
+
rejectPaginationModifiersWithoutAll(flags, out);
|
|
149
152
|
const accountId = await requireAccount(client, flags, out);
|
|
150
153
|
const postId = flags.postId ?? "";
|
|
151
154
|
const commentId = flags.commentId ?? "";
|
|
@@ -162,10 +165,11 @@ async function runCommentReactions(client, flags, out) {
|
|
|
162
165
|
out,
|
|
163
166
|
pageDelayMs: pageDelayFromFlags(flags)
|
|
164
167
|
})) {
|
|
165
|
-
out
|
|
168
|
+
writeNdjsonItem(out, item, outOpts.fields);
|
|
166
169
|
}
|
|
167
170
|
} else {
|
|
168
171
|
const result = await ns.comments.listReactions(postId, commentId, params);
|
|
172
|
+
readablePage(result);
|
|
169
173
|
renderSuccess(result, outOpts, out);
|
|
170
174
|
}
|
|
171
175
|
} catch (err) {
|
|
@@ -174,6 +178,7 @@ async function runCommentReactions(client, flags, out) {
|
|
|
174
178
|
}
|
|
175
179
|
async function runCommentUser(client, flags, out) {
|
|
176
180
|
rejectPreviewOnRead(flags.preview, out);
|
|
181
|
+
rejectPaginationModifiersWithoutAll(flags, out);
|
|
177
182
|
const accountId = await requireAccount(client, flags, out);
|
|
178
183
|
const ns = client.account(accountId);
|
|
179
184
|
const outOpts = resolveOutputOpts(flags);
|
|
@@ -195,10 +200,11 @@ async function runCommentUser(client, flags, out) {
|
|
|
195
200
|
out,
|
|
196
201
|
pageDelayMs: pageDelayFromFlags(flags)
|
|
197
202
|
})) {
|
|
198
|
-
out
|
|
203
|
+
writeNdjsonItem(out, item, outOpts.fields);
|
|
199
204
|
}
|
|
200
205
|
} else {
|
|
201
206
|
const result = await ns.comments.listUserComments(userId, params);
|
|
207
|
+
readablePage(result);
|
|
202
208
|
renderSuccess(result, outOpts, out);
|
|
203
209
|
}
|
|
204
210
|
} catch (err) {
|
|
@@ -7,14 +7,10 @@ import {
|
|
|
7
7
|
slimSearchJobs,
|
|
8
8
|
slimSearchPeople,
|
|
9
9
|
slimSearchPosts
|
|
10
|
-
} from "./chunk-
|
|
11
|
-
import {
|
|
12
|
-
pageDelayFromFlags,
|
|
13
|
-
streamAll
|
|
14
|
-
} from "./chunk-LKF5MZIP.js";
|
|
10
|
+
} from "./chunk-XP2LN6F6.js";
|
|
15
11
|
import {
|
|
16
12
|
sentAsNotice
|
|
17
|
-
} from "./chunk-
|
|
13
|
+
} from "./chunk-BN7L7WSY.js";
|
|
18
14
|
import "./chunk-UWO2D4HW.js";
|
|
19
15
|
import "./chunk-HOQ7EUHJ.js";
|
|
20
16
|
import {
|
|
@@ -25,29 +21,34 @@ import {
|
|
|
25
21
|
import {
|
|
26
22
|
resolveIdentifier
|
|
27
23
|
} from "./chunk-UEAX6KUB.js";
|
|
28
|
-
import {
|
|
29
|
-
buildPreviewOutput
|
|
30
|
-
} from "./chunk-R3VLWLVV.js";
|
|
31
24
|
import {
|
|
32
25
|
requireAccount
|
|
33
|
-
} from "./chunk-
|
|
26
|
+
} from "./chunk-MNDXMGPX.js";
|
|
27
|
+
import {
|
|
28
|
+
buildPreviewOutput
|
|
29
|
+
} from "./chunk-TCUYH5GO.js";
|
|
34
30
|
import {
|
|
31
|
+
pageDelayFromFlags,
|
|
32
|
+
readableId,
|
|
33
|
+
readablePage,
|
|
34
|
+
rejectPaginationModifiersWithoutAll,
|
|
35
35
|
renderError,
|
|
36
36
|
renderSuccess,
|
|
37
|
-
renderUnexpectedError
|
|
38
|
-
|
|
37
|
+
renderUnexpectedError,
|
|
38
|
+
resolveEffectiveConfig,
|
|
39
|
+
streamAll,
|
|
40
|
+
writeNdjsonItem
|
|
41
|
+
} from "./chunk-7JU4IXXG.js";
|
|
42
|
+
import "./chunk-XZJQQJBE.js";
|
|
39
43
|
import {
|
|
40
|
-
createClient
|
|
41
|
-
|
|
42
|
-
} from "./chunk-TD2ZIXFR.js";
|
|
43
|
-
import "./chunk-PKSKQ3LN.js";
|
|
44
|
-
import "./chunk-EIEF2KFH.js";
|
|
45
|
-
import "./chunk-TQJ77SL4.js";
|
|
44
|
+
createClient
|
|
45
|
+
} from "./chunk-DCZR4M7G.js";
|
|
46
46
|
import {
|
|
47
47
|
GLOBAL_FLAGS,
|
|
48
|
+
NON_STREAM_FLAGS,
|
|
48
49
|
WRITE_FLAGS,
|
|
49
50
|
resolveTextOrStdin
|
|
50
|
-
} from "./chunk-
|
|
51
|
+
} from "./chunk-XDQHNUEU.js";
|
|
51
52
|
|
|
52
53
|
// src/commands/company.ts
|
|
53
54
|
import { defineCommand } from "citty";
|
|
@@ -82,15 +83,14 @@ function normalizeAttachPaths(attach) {
|
|
|
82
83
|
async function resolveCompanyId(ns, raw) {
|
|
83
84
|
const normalized = resolveIdentifier(raw);
|
|
84
85
|
if (/^\d+$/.test(normalized)) return normalized;
|
|
85
|
-
|
|
86
|
-
return String(company.id);
|
|
86
|
+
return readableId(await ns.companies.get(normalized));
|
|
87
87
|
}
|
|
88
88
|
async function handleSdkError(err, outOpts, out) {
|
|
89
89
|
const { CurviateError } = await import("@curviate/sdk");
|
|
90
90
|
if (err instanceof CurviateError) {
|
|
91
|
-
const { getExitCode } = await import("./exit-codes-
|
|
91
|
+
const { getExitCode } = await import("./exit-codes-YSFFFWMS.js");
|
|
92
92
|
renderError(err, outOpts, out);
|
|
93
|
-
process.exit(getExitCode(err
|
|
93
|
+
process.exit(getExitCode(err));
|
|
94
94
|
}
|
|
95
95
|
renderUnexpectedError(err, out);
|
|
96
96
|
process.exit(1);
|
|
@@ -118,6 +118,7 @@ async function runCompanyGet(client, flags, out) {
|
|
|
118
118
|
}
|
|
119
119
|
async function runCompanyEmployees(client, flags, out) {
|
|
120
120
|
rejectPreviewOnRead(flags.preview, out);
|
|
121
|
+
rejectPaginationModifiersWithoutAll(flags, out);
|
|
121
122
|
const accountId = await requireAccount(client, flags, out);
|
|
122
123
|
const ns = client.account(accountId);
|
|
123
124
|
const outOpts = resolveOutputOpts(flags);
|
|
@@ -136,11 +137,12 @@ async function runCompanyEmployees(client, flags, out) {
|
|
|
136
137
|
out,
|
|
137
138
|
pageDelayMs: pageDelayFromFlags(flags)
|
|
138
139
|
})) {
|
|
139
|
-
out
|
|
140
|
+
writeNdjsonItem(out, item, outOpts.fields);
|
|
140
141
|
}
|
|
141
142
|
return;
|
|
142
143
|
}
|
|
143
144
|
const result = await ns.companies.employees(identifier, params);
|
|
145
|
+
readablePage(result);
|
|
144
146
|
renderSuccess(result, { ...outOpts, slim: slimSearchPeople }, out);
|
|
145
147
|
} catch (err) {
|
|
146
148
|
await handleSdkError(err, outOpts, out);
|
|
@@ -148,6 +150,7 @@ async function runCompanyEmployees(client, flags, out) {
|
|
|
148
150
|
}
|
|
149
151
|
async function runCompanyPosts(client, flags, out) {
|
|
150
152
|
rejectPreviewOnRead(flags.preview, out);
|
|
153
|
+
rejectPaginationModifiersWithoutAll(flags, out);
|
|
151
154
|
const accountId = await requireAccount(client, flags, out);
|
|
152
155
|
const ns = client.account(accountId);
|
|
153
156
|
const outOpts = resolveOutputOpts(flags);
|
|
@@ -164,11 +167,12 @@ async function runCompanyPosts(client, flags, out) {
|
|
|
164
167
|
out,
|
|
165
168
|
pageDelayMs: pageDelayFromFlags(flags)
|
|
166
169
|
})) {
|
|
167
|
-
out
|
|
170
|
+
writeNdjsonItem(out, item, outOpts.fields);
|
|
168
171
|
}
|
|
169
172
|
return;
|
|
170
173
|
}
|
|
171
174
|
const result = await ns.companies.posts(identifier, params);
|
|
175
|
+
readablePage(result);
|
|
172
176
|
renderSuccess(result, { ...outOpts, slim: slimSearchPosts }, out);
|
|
173
177
|
} catch (err) {
|
|
174
178
|
await handleSdkError(err, outOpts, out);
|
|
@@ -176,6 +180,7 @@ async function runCompanyPosts(client, flags, out) {
|
|
|
176
180
|
}
|
|
177
181
|
async function runCompanyJobs(client, flags, out) {
|
|
178
182
|
rejectPreviewOnRead(flags.preview, out);
|
|
183
|
+
rejectPaginationModifiersWithoutAll(flags, out);
|
|
179
184
|
const accountId = await requireAccount(client, flags, out);
|
|
180
185
|
const ns = client.account(accountId);
|
|
181
186
|
const outOpts = resolveOutputOpts(flags);
|
|
@@ -193,11 +198,12 @@ async function runCompanyJobs(client, flags, out) {
|
|
|
193
198
|
out,
|
|
194
199
|
pageDelayMs: pageDelayFromFlags(flags)
|
|
195
200
|
})) {
|
|
196
|
-
out
|
|
201
|
+
writeNdjsonItem(out, item, outOpts.fields);
|
|
197
202
|
}
|
|
198
203
|
return;
|
|
199
204
|
}
|
|
200
205
|
const result = await ns.companies.jobs(identifier, params);
|
|
206
|
+
readablePage(result);
|
|
201
207
|
renderSuccess(result, { ...outOpts, slim: slimSearchJobs }, out);
|
|
202
208
|
} catch (err) {
|
|
203
209
|
await handleSdkError(err, outOpts, out);
|
|
@@ -205,6 +211,7 @@ async function runCompanyJobs(client, flags, out) {
|
|
|
205
211
|
}
|
|
206
212
|
async function runCompanyInvitableFollowers(client, flags, out) {
|
|
207
213
|
rejectPreviewOnRead(flags.preview, out);
|
|
214
|
+
rejectPaginationModifiersWithoutAll(flags, out);
|
|
208
215
|
const accountId = await requireAccount(client, flags, out);
|
|
209
216
|
const ns = client.account(accountId);
|
|
210
217
|
const outOpts = resolveOutputOpts(flags);
|
|
@@ -221,11 +228,12 @@ async function runCompanyInvitableFollowers(client, flags, out) {
|
|
|
221
228
|
out,
|
|
222
229
|
pageDelayMs: pageDelayFromFlags(flags)
|
|
223
230
|
})) {
|
|
224
|
-
out
|
|
231
|
+
writeNdjsonItem(out, reencodeInviteTokenItem(item), outOpts.fields);
|
|
225
232
|
}
|
|
226
233
|
return;
|
|
227
234
|
}
|
|
228
235
|
const result = await ns.companies.invitableFollowers(identifier, params);
|
|
236
|
+
readablePage(result);
|
|
229
237
|
const safeResult = reencodeInvitableFollowers(result);
|
|
230
238
|
renderSuccess(safeResult, { ...outOpts, slim: slimCompanyInvitableFollowers }, out);
|
|
231
239
|
} catch (err) {
|
|
@@ -263,6 +271,7 @@ async function runCompanyFollowInvite(client, flags, out) {
|
|
|
263
271
|
}
|
|
264
272
|
async function runCompanyManaged(client, flags, out) {
|
|
265
273
|
rejectPreviewOnRead(flags.preview, out);
|
|
274
|
+
rejectPaginationModifiersWithoutAll(flags, out);
|
|
266
275
|
const accountId = await requireAccount(client, flags, out);
|
|
267
276
|
const ns = client.account(accountId);
|
|
268
277
|
const outOpts = resolveOutputOpts(flags);
|
|
@@ -278,11 +287,12 @@ async function runCompanyManaged(client, flags, out) {
|
|
|
278
287
|
out,
|
|
279
288
|
pageDelayMs: pageDelayFromFlags(flags)
|
|
280
289
|
})) {
|
|
281
|
-
out
|
|
290
|
+
writeNdjsonItem(out, item, outOpts.fields);
|
|
282
291
|
}
|
|
283
292
|
return;
|
|
284
293
|
}
|
|
285
294
|
const result = await ns.companies.managed(params);
|
|
295
|
+
readablePage(result);
|
|
286
296
|
renderSuccess(result, outOpts, out);
|
|
287
297
|
} catch (err) {
|
|
288
298
|
await handleSdkError(err, outOpts, out);
|
|
@@ -290,6 +300,7 @@ async function runCompanyManaged(client, flags, out) {
|
|
|
290
300
|
}
|
|
291
301
|
async function runCompanyFollowers(client, flags, out) {
|
|
292
302
|
rejectPreviewOnRead(flags.preview, out);
|
|
303
|
+
rejectPaginationModifiersWithoutAll(flags, out);
|
|
293
304
|
const accountId = await requireAccount(client, flags, out);
|
|
294
305
|
const ns = client.account(accountId);
|
|
295
306
|
const outOpts = resolveOutputOpts(flags);
|
|
@@ -306,11 +317,12 @@ async function runCompanyFollowers(client, flags, out) {
|
|
|
306
317
|
out,
|
|
307
318
|
pageDelayMs: pageDelayFromFlags(flags)
|
|
308
319
|
})) {
|
|
309
|
-
out
|
|
320
|
+
writeNdjsonItem(out, item, outOpts.fields);
|
|
310
321
|
}
|
|
311
322
|
return;
|
|
312
323
|
}
|
|
313
324
|
const result = await ns.companies.followers(identifier, params);
|
|
325
|
+
readablePage(result);
|
|
314
326
|
renderSuccess(result, outOpts, out);
|
|
315
327
|
} catch (err) {
|
|
316
328
|
await handleSdkError(err, outOpts, out);
|
|
@@ -318,6 +330,7 @@ async function runCompanyFollowers(client, flags, out) {
|
|
|
318
330
|
}
|
|
319
331
|
async function runCompanyChats(client, flags, out) {
|
|
320
332
|
rejectPreviewOnRead(flags.preview, out);
|
|
333
|
+
rejectPaginationModifiersWithoutAll(flags, out);
|
|
321
334
|
const accountId = await requireAccount(client, flags, out);
|
|
322
335
|
const ns = client.account(accountId);
|
|
323
336
|
const outOpts = resolveOutputOpts(flags);
|
|
@@ -334,11 +347,12 @@ async function runCompanyChats(client, flags, out) {
|
|
|
334
347
|
out,
|
|
335
348
|
pageDelayMs: pageDelayFromFlags(flags)
|
|
336
349
|
})) {
|
|
337
|
-
out
|
|
350
|
+
writeNdjsonItem(out, item, outOpts.fields);
|
|
338
351
|
}
|
|
339
352
|
return;
|
|
340
353
|
}
|
|
341
354
|
const result = await ns.companies.chats(identifier, params);
|
|
355
|
+
readablePage(result);
|
|
342
356
|
renderSuccess(result, outOpts, out);
|
|
343
357
|
} catch (err) {
|
|
344
358
|
await handleSdkError(err, outOpts, out);
|
|
@@ -364,6 +378,7 @@ async function runCompanyChat(client, flags, out) {
|
|
|
364
378
|
}
|
|
365
379
|
async function runCompanyMessages(client, flags, out) {
|
|
366
380
|
rejectPreviewOnRead(flags.preview, out);
|
|
381
|
+
rejectPaginationModifiersWithoutAll(flags, out);
|
|
367
382
|
const accountId = await requireAccount(client, flags, out);
|
|
368
383
|
const ns = client.account(accountId);
|
|
369
384
|
const outOpts = resolveOutputOpts(flags);
|
|
@@ -381,11 +396,12 @@ async function runCompanyMessages(client, flags, out) {
|
|
|
381
396
|
out,
|
|
382
397
|
pageDelayMs: pageDelayFromFlags(flags)
|
|
383
398
|
})) {
|
|
384
|
-
out
|
|
399
|
+
writeNdjsonItem(out, item, outOpts.fields);
|
|
385
400
|
}
|
|
386
401
|
return;
|
|
387
402
|
}
|
|
388
403
|
const result = await ns.companies.messages(identifier, chatId, params);
|
|
404
|
+
readablePage(result);
|
|
389
405
|
renderSuccess(result, outOpts, out);
|
|
390
406
|
} catch (err) {
|
|
391
407
|
await handleSdkError(err, outOpts, out);
|
|
@@ -412,6 +428,7 @@ async function runCompanyMessage(client, flags, out) {
|
|
|
412
428
|
}
|
|
413
429
|
async function runCompanySearchChats(client, flags, out) {
|
|
414
430
|
rejectPreviewOnRead(flags.preview, out);
|
|
431
|
+
rejectPaginationModifiersWithoutAll(flags, out);
|
|
415
432
|
const accountId = await requireAccount(client, flags, out);
|
|
416
433
|
const ns = client.account(accountId);
|
|
417
434
|
const outOpts = resolveOutputOpts(flags);
|
|
@@ -431,11 +448,12 @@ async function runCompanySearchChats(client, flags, out) {
|
|
|
431
448
|
out,
|
|
432
449
|
pageDelayMs: pageDelayFromFlags(flags)
|
|
433
450
|
})) {
|
|
434
|
-
out
|
|
451
|
+
writeNdjsonItem(out, item, outOpts.fields);
|
|
435
452
|
}
|
|
436
453
|
return;
|
|
437
454
|
}
|
|
438
455
|
const result = await ns.companies.searchChats(identifier, params);
|
|
456
|
+
readablePage(result);
|
|
439
457
|
renderSuccess(result, outOpts, out);
|
|
440
458
|
} catch (err) {
|
|
441
459
|
await handleSdkError(err, outOpts, out);
|
|
@@ -702,7 +720,7 @@ var companyChatCommand = defineCommand({
|
|
|
702
720
|
description: "Retrieve one conversation from a company page's admin inbox. Admin-gated."
|
|
703
721
|
},
|
|
704
722
|
args: {
|
|
705
|
-
...
|
|
723
|
+
...NON_STREAM_FLAGS,
|
|
706
724
|
id: { type: "positional", description: "Company identifier (URL, slug, or numeric id), a slug/URL is resolved to the numeric id first." },
|
|
707
725
|
chatId: { type: "positional", description: "The 2-... chat id from `company chats`, passed through verbatim." }
|
|
708
726
|
},
|
|
@@ -758,7 +776,7 @@ var companyMessageCommand = defineCommand({
|
|
|
758
776
|
description: "Retrieve one message from a company-inbox conversation. Admin-gated. See also: `company reply` (send)."
|
|
759
777
|
},
|
|
760
778
|
args: {
|
|
761
|
-
...
|
|
779
|
+
...NON_STREAM_FLAGS,
|
|
762
780
|
id: { type: "positional", description: "Company identifier (URL, slug, or numeric id), a slug/URL is resolved to the numeric id first." },
|
|
763
781
|
chatId: { type: "positional", description: "The 2-... chat id from `company chats`, passed through verbatim." },
|
|
764
782
|
messageId: { type: "positional", description: "The message id from `company messages`, passed through verbatim." }
|
|
@@ -847,7 +865,7 @@ var companyReplyCommand = defineCommand({
|
|
|
847
865
|
var companyCommand = defineCommand({
|
|
848
866
|
meta: { name: "company", description: "Fetch a company profile by URL, slug, or numeric id, and its sub-resources." },
|
|
849
867
|
args: {
|
|
850
|
-
...
|
|
868
|
+
...NON_STREAM_FLAGS,
|
|
851
869
|
id: { type: "positional", description: "Company identifier (URL, slug, or native id)." },
|
|
852
870
|
sections: { type: "string", description: "Not supported on company commands; a usage error (exit 2) if supplied." }
|
|
853
871
|
},
|
|
@@ -1,23 +1,33 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import {
|
|
3
|
+
PROFILE_FIELD_TYPES,
|
|
4
|
+
assertStructure,
|
|
5
|
+
baseUrlProblem,
|
|
3
6
|
getConfigPath,
|
|
7
|
+
isPlainObject,
|
|
4
8
|
readConfig,
|
|
9
|
+
readConfigFile,
|
|
5
10
|
removeProfile,
|
|
6
11
|
renameProfile,
|
|
7
12
|
setActiveProfile,
|
|
8
|
-
updateProfileField
|
|
9
|
-
|
|
13
|
+
updateProfileField,
|
|
14
|
+
withoutUserinfo
|
|
15
|
+
} from "./chunk-DCZR4M7G.js";
|
|
10
16
|
import {
|
|
11
17
|
GLOBAL_FLAGS
|
|
12
|
-
} from "./chunk-
|
|
18
|
+
} from "./chunk-XDQHNUEU.js";
|
|
13
19
|
|
|
14
20
|
// src/commands/config.ts
|
|
15
21
|
import { defineCommand } from "citty";
|
|
16
|
-
|
|
22
|
+
|
|
23
|
+
// src/lib/config-display.ts
|
|
24
|
+
function redactKeyForDisplay(key) {
|
|
17
25
|
if (!key) return "<unset>";
|
|
18
|
-
if (key.length
|
|
19
|
-
return
|
|
26
|
+
if (key.length < 16) return "\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022";
|
|
27
|
+
return "\u2022\u2022\u2022\u2022" + key.slice(-4);
|
|
20
28
|
}
|
|
29
|
+
|
|
30
|
+
// src/commands/config.ts
|
|
21
31
|
var configCommand = defineCommand({
|
|
22
32
|
meta: {
|
|
23
33
|
name: "config",
|
|
@@ -26,39 +36,66 @@ var configCommand = defineCommand({
|
|
|
26
36
|
subCommands: {
|
|
27
37
|
list: defineCommand({
|
|
28
38
|
meta: { name: "list", description: "List all profiles (keys redacted)." },
|
|
29
|
-
args: {
|
|
39
|
+
args: { json: GLOBAL_FLAGS.json },
|
|
30
40
|
async run({ args }) {
|
|
31
|
-
const
|
|
32
|
-
if (!
|
|
41
|
+
const file = await readConfigFile();
|
|
42
|
+
if (!file) {
|
|
33
43
|
process.stderr.write("No config file found. Run `curviate login` to create one.\n");
|
|
34
44
|
return;
|
|
35
45
|
}
|
|
46
|
+
if (file.unparseable) assertStructure(file, false);
|
|
47
|
+
const INVALID = "<invalid>";
|
|
48
|
+
const root = isPlainObject(file.root) ? file.root : void 0;
|
|
49
|
+
const rawActive = root?.["active"];
|
|
50
|
+
const active = rawActive === void 0 || rawActive === null ? void 0 : typeof rawActive === "string" ? rawActive : INVALID;
|
|
51
|
+
const rawProfiles = root === void 0 ? INVALID : root["profiles"] ?? {};
|
|
52
|
+
const profiles = isPlainObject(rawProfiles) ? rawProfiles : void 0;
|
|
53
|
+
const display = (profile) => {
|
|
54
|
+
if (!isPlainObject(profile)) return INVALID;
|
|
55
|
+
const out = {};
|
|
56
|
+
for (const [field, want] of Object.entries(PROFILE_FIELD_TYPES)) {
|
|
57
|
+
const value = profile[field];
|
|
58
|
+
if (typeof value !== want) {
|
|
59
|
+
if (value !== void 0 && value !== null) out[field] = INVALID;
|
|
60
|
+
} else {
|
|
61
|
+
out[field] = field === "apiKey" ? redactKeyForDisplay(value) : field === "baseUrl" ? withoutUserinfo(value) : value;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
if (out["apiKey"] === void 0) out["apiKey"] = redactKeyForDisplay(void 0);
|
|
65
|
+
return out;
|
|
66
|
+
};
|
|
36
67
|
const json = args.json ?? !process.stdout.isTTY;
|
|
68
|
+
const entries = Object.entries(profiles ?? {}).filter(([, profile]) => profile !== void 0 && profile !== null);
|
|
37
69
|
if (json) {
|
|
38
|
-
const
|
|
39
|
-
for (const [name, profile] of
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
...profile,
|
|
43
|
-
apiKey: redactKey(profile.apiKey),
|
|
44
|
-
...name === cfg.active ? { active: true } : {}
|
|
45
|
-
};
|
|
70
|
+
const shown = /* @__PURE__ */ Object.create(null);
|
|
71
|
+
for (const [name, profile] of entries) {
|
|
72
|
+
const d = display(profile);
|
|
73
|
+
shown[name] = typeof d === "string" ? d : { ...d, ...name === active ? { active: true } : {} };
|
|
46
74
|
}
|
|
47
|
-
process.stdout.write(
|
|
75
|
+
process.stdout.write(
|
|
76
|
+
JSON.stringify({ ...active !== void 0 ? { active } : {}, profiles: profiles ? shown : INVALID }) + "\n"
|
|
77
|
+
);
|
|
48
78
|
} else {
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
process.stdout.write(`${name}${marker}
|
|
79
|
+
if (active === INVALID) process.stdout.write(`active: ${INVALID}
|
|
80
|
+
`);
|
|
81
|
+
if (!profiles) process.stdout.write(`profiles: ${INVALID}
|
|
53
82
|
`);
|
|
54
|
-
|
|
83
|
+
for (const [name, profile] of entries) {
|
|
84
|
+
const marker = name === active ? " (active)" : "";
|
|
85
|
+
process.stdout.write(`${name}${marker}
|
|
55
86
|
`);
|
|
56
|
-
|
|
87
|
+
const d = display(profile);
|
|
88
|
+
if (typeof d === "string") {
|
|
89
|
+
process.stdout.write(` ${d}
|
|
57
90
|
`);
|
|
58
|
-
|
|
91
|
+
continue;
|
|
92
|
+
}
|
|
93
|
+
process.stdout.write(` apiKey: ${d["apiKey"]}
|
|
59
94
|
`);
|
|
60
|
-
|
|
95
|
+
for (const field of ["account", "baseUrl", "timeout"]) {
|
|
96
|
+
if (d[field]) process.stdout.write(` ${field}: ${d[field]}
|
|
61
97
|
`);
|
|
98
|
+
}
|
|
62
99
|
}
|
|
63
100
|
}
|
|
64
101
|
}
|
|
@@ -117,7 +154,8 @@ var configCommand = defineCommand({
|
|
|
117
154
|
description: "Set the default account on a profile."
|
|
118
155
|
},
|
|
119
156
|
args: {
|
|
120
|
-
|
|
157
|
+
profile: GLOBAL_FLAGS.profile,
|
|
158
|
+
json: GLOBAL_FLAGS.json,
|
|
121
159
|
account: {
|
|
122
160
|
type: "positional",
|
|
123
161
|
description: "Account id to set as default."
|
|
@@ -150,7 +188,8 @@ var configCommand = defineCommand({
|
|
|
150
188
|
description: "Set or clear the base URL on a profile."
|
|
151
189
|
},
|
|
152
190
|
args: {
|
|
153
|
-
|
|
191
|
+
profile: GLOBAL_FLAGS.profile,
|
|
192
|
+
json: GLOBAL_FLAGS.json,
|
|
154
193
|
url: {
|
|
155
194
|
type: "positional",
|
|
156
195
|
description: 'Base URL to set, or "" to clear.',
|
|
@@ -171,6 +210,12 @@ var configCommand = defineCommand({
|
|
|
171
210
|
const profileName = args.profile ?? cfg.active;
|
|
172
211
|
const reset = args.reset;
|
|
173
212
|
const url = reset ? void 0 : args.url ?? "";
|
|
213
|
+
const badUrl = url ? baseUrlProblem(url) : null;
|
|
214
|
+
if (badUrl) {
|
|
215
|
+
process.stderr.write(`error: ${badUrl}
|
|
216
|
+
`);
|
|
217
|
+
process.exit(2);
|
|
218
|
+
}
|
|
174
219
|
try {
|
|
175
220
|
await updateProfileField(
|
|
176
221
|
profileName,
|
|
@@ -203,7 +248,7 @@ var configCommand = defineCommand({
|
|
|
203
248
|
description: "Remove the config file (or a single profile)."
|
|
204
249
|
},
|
|
205
250
|
args: {
|
|
206
|
-
|
|
251
|
+
json: GLOBAL_FLAGS.json,
|
|
207
252
|
profile: {
|
|
208
253
|
type: "string",
|
|
209
254
|
description: "Remove only this profile instead of the whole file."
|