@blinkdotnew/cli 0.3.6 → 0.3.7

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/dist/cli.js CHANGED
@@ -197,7 +197,12 @@ async function resourcesRequest(path, opts = {}) {
197
197
  const errText = await res.text();
198
198
  let errMsg = `HTTP ${res.status}`;
199
199
  try {
200
- errMsg = JSON.parse(errText).error ?? errMsg;
200
+ const parsed = JSON.parse(errText);
201
+ const err = parsed.error;
202
+ if (typeof err === "string") errMsg = err;
203
+ else if (err?.message) errMsg = err.message;
204
+ else if (parsed.message) errMsg = parsed.message;
205
+ else if (err) errMsg = JSON.stringify(err);
201
206
  } catch {
202
207
  }
203
208
  throw new Error(errMsg);
@@ -1391,7 +1396,7 @@ async function liExec(method, httpMethod, params, agentId) {
1391
1396
  return result.data;
1392
1397
  }
1393
1398
  async function getPersonId(agentId) {
1394
- const data = await liExec("v2/userinfo", "GET", {}, agentId);
1399
+ const data = await liExec("userinfo", "GET", {}, agentId);
1395
1400
  const id = data?.sub ?? data?.id;
1396
1401
  if (!id) throw new Error("Could not resolve LinkedIn person ID");
1397
1402
  return id;
@@ -1436,7 +1441,7 @@ Examples:
1436
1441
  const agentId = requireAgentId(opts.agent);
1437
1442
  const data = await withSpinner(
1438
1443
  "Fetching LinkedIn profile...",
1439
- () => liExec("v2/userinfo", "GET", {}, agentId)
1444
+ () => liExec("userinfo", "GET", {}, agentId)
1440
1445
  );
1441
1446
  if (isJsonMode()) return printJson(data);
1442
1447
  const name = data?.name ?? [data?.given_name, data?.family_name].filter(Boolean).join(" ");
@@ -1515,7 +1520,7 @@ Examples:
1515
1520
  const encoded = encodeURIComponent(postUrn);
1516
1521
  const data = await withSpinner(
1517
1522
  "Liking post...",
1518
- () => liExec(`v2/socialActions/${encoded}/likes`, "POST", {
1523
+ () => liExec(`socialActions/${encoded}/likes`, "POST", {
1519
1524
  actor: `urn:li:person:${personId}`
1520
1525
  }, agentId)
1521
1526
  );
@@ -1537,7 +1542,7 @@ Examples:
1537
1542
  const encodedPerson = encodeURIComponent(`urn:li:person:${personId}`);
1538
1543
  await withSpinner(
1539
1544
  "Unliking post...",
1540
- () => liExec(`v2/socialActions/${encodedPost}/likes/${encodedPerson}`, "DELETE", {}, agentId)
1545
+ () => liExec(`socialActions/${encodedPost}/likes/${encodedPerson}`, "DELETE", {}, agentId)
1541
1546
  );
1542
1547
  if (isJsonMode()) return printJson({ unliked: true });
1543
1548
  console.log(chalk7.green("\u2713 Post unliked"));
@@ -1558,7 +1563,7 @@ Examples:
1558
1563
  const encoded = encodeURIComponent(postUrn);
1559
1564
  const data = await withSpinner(
1560
1565
  "Adding comment...",
1561
- () => liExec(`v2/socialActions/${encoded}/comments`, "POST", {
1566
+ () => liExec(`socialActions/${encoded}/comments`, "POST", {
1562
1567
  actor: `urn:li:person:${personId}`,
1563
1568
  message: { text }
1564
1569
  }, agentId)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@blinkdotnew/cli",
3
- "version": "0.3.6",
3
+ "version": "0.3.7",
4
4
  "description": "Blink platform CLI — deploy apps, manage databases, generate AI content",
5
5
  "bin": {
6
6
  "blink": "dist/cli.js"
@@ -34,7 +34,7 @@ async function liExec(
34
34
  }
35
35
 
36
36
  async function getPersonId(agentId: string): Promise<string> {
37
- const data = await liExec('v2/userinfo', 'GET', {}, agentId)
37
+ const data = await liExec('userinfo', 'GET', {}, agentId)
38
38
  const id = data?.sub ?? data?.id
39
39
  if (!id) throw new Error('Could not resolve LinkedIn person ID')
40
40
  return id
@@ -87,7 +87,7 @@ Examples:
87
87
  requireToken()
88
88
  const agentId = requireAgentId(opts.agent)
89
89
  const data = await withSpinner('Fetching LinkedIn profile...', () =>
90
- liExec('v2/userinfo', 'GET', {}, agentId)
90
+ liExec('userinfo', 'GET', {}, agentId)
91
91
  )
92
92
  if (isJsonMode()) return printJson(data)
93
93
  const name = data?.name ?? [data?.given_name, data?.family_name].filter(Boolean).join(' ')
@@ -180,7 +180,7 @@ Examples:
180
180
  )
181
181
  const encoded = encodeURIComponent(postUrn)
182
182
  const data = await withSpinner('Liking post...', () =>
183
- liExec(`v2/socialActions/${encoded}/likes`, 'POST', {
183
+ liExec(`socialActions/${encoded}/likes`, 'POST', {
184
184
  actor: `urn:li:person:${personId}`,
185
185
  }, agentId)
186
186
  )
@@ -206,7 +206,7 @@ Examples:
206
206
  const encodedPost = encodeURIComponent(postUrn)
207
207
  const encodedPerson = encodeURIComponent(`urn:li:person:${personId}`)
208
208
  await withSpinner('Unliking post...', () =>
209
- liExec(`v2/socialActions/${encodedPost}/likes/${encodedPerson}`, 'DELETE', {}, agentId)
209
+ liExec(`socialActions/${encodedPost}/likes/${encodedPerson}`, 'DELETE', {}, agentId)
210
210
  )
211
211
  if (isJsonMode()) return printJson({ unliked: true })
212
212
  console.log(chalk.green('✓ Post unliked'))
@@ -231,7 +231,7 @@ Examples:
231
231
  )
232
232
  const encoded = encodeURIComponent(postUrn)
233
233
  const data = await withSpinner('Adding comment...', () =>
234
- liExec(`v2/socialActions/${encoded}/comments`, 'POST', {
234
+ liExec(`socialActions/${encoded}/comments`, 'POST', {
235
235
  actor: `urn:li:person:${personId}`,
236
236
  message: { text },
237
237
  }, agentId)
@@ -35,7 +35,14 @@ export async function resourcesRequest(path: string, opts: RequestOptions = {})
35
35
  if (!res.ok) {
36
36
  const errText = await res.text()
37
37
  let errMsg = `HTTP ${res.status}`
38
- try { errMsg = JSON.parse(errText).error ?? errMsg } catch { /* use default */ }
38
+ try {
39
+ const parsed = JSON.parse(errText)
40
+ const err = parsed.error
41
+ if (typeof err === 'string') errMsg = err
42
+ else if (err?.message) errMsg = err.message
43
+ else if (parsed.message) errMsg = parsed.message
44
+ else if (err) errMsg = JSON.stringify(err)
45
+ } catch { /* use default */ }
39
46
  throw new Error(errMsg)
40
47
  }
41
48
  const ct = res.headers.get('content-type') ?? ''