@nuelink/nuelink-cli 1.6.0 → 1.6.2

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 CHANGED
@@ -1,5 +1,14 @@
1
1
  # Changelog
2
2
 
3
+ ## 1.6.2
4
+
5
+ - Show effective channel names in table output for posts and other resources with channel summaries.
6
+ - Document the post channels response shape and target-versus-collection behavior.
7
+
8
+ ## 1.6.1
9
+
10
+ - Reject HTTP redirects for API requests so mutation bodies and credentials are never forwarded to redirect destinations.
11
+
3
12
  ## 1.6.0
4
13
 
5
14
  - Add collection update, channel assignment, and queue slot management commands.
package/README.md CHANGED
@@ -192,6 +192,8 @@ nuelink-cli automations --brand-id 13493 --per-page 5 --page 1
192
192
  ```
193
193
 
194
194
  This table view is especially useful for quickly scanning automation status, feed type, and feed URL.
195
+ JSON responses also include `loadOldPosts`, `addPostsAsDraft`, and
196
+ `refreshRate` (hours; 1, 6, 12, or 24).
195
197
 
196
198
  Create automation:
197
199
 
@@ -246,7 +248,10 @@ List posts:
246
248
  nuelink-cli posts --brand-id 13493 --collection-id 33273 --per-page 5 --page 1
247
249
  ```
248
250
 
249
- Post list output highlights the post ID, type, status, and publish date.
251
+ Post list output highlights the post ID, type, status, publish date, and
252
+ effective channel names. In JSON mode, each post retains the API's full
253
+ channels array with id, name, status, and type; it lists post-targeted channels
254
+ when configured, otherwise the channels assigned to the collection.
250
255
  Optional filters include `--status`, `--post-type`, `--posting-type`,
251
256
  `--view` (`QUEUE`, `SCHEDULED`, `DRAFT`, or `PUBLISHED`), `--created-from`,
252
257
  `--created-to`, `--sort-by`, and `--sort-order`.
@@ -267,7 +272,7 @@ nuelink-cli posts:add-json --brand-id 13493 --collection-id 33273 --payload ./po
267
272
  ```
268
273
 
269
274
  You can also pipe JSON through stdin with `--payload -`.
270
- CLI 1.5.0 preserves contract-nullable fields exactly; the dry-run body matches
275
+ CLI 1.6.0 and later preserves contract-nullable fields exactly; the dry-run body matches
271
276
  the JSON body sent by the request.
272
277
 
273
278
  Example `post.json`:
@@ -432,7 +437,7 @@ npm run check:pack:installed
432
437
 
433
438
  ## Release Checklist
434
439
 
435
- 1. Update version in `package.json`
440
+ 1. Update the version in package.json and package-lock.json, and add a matching entry at the top of CHANGELOG.md
436
441
  2. Run `npm test`
437
442
  3. Run `npm run check:pack`
438
443
  4. Run `npm run check:pack:installed`
package/package.json CHANGED
@@ -1,51 +1,51 @@
1
- {
2
- "name": "@nuelink/nuelink-cli",
3
- "version": "1.6.0",
4
- "description": "The official Nuelink CLI for automating social media workflows from your terminal. Schedule posts, upload media, manage brands, and integrate Nuelink into scripts, CI/CD pipelines, and AI agents.",
5
- "license": "MIT",
6
- "author": "Nuelink",
7
- "repository": {
8
- "type": "git",
9
- "url": "git+https://github.com/kreatinc/nuelink-cli.git"
10
- },
11
- "homepage": "https://github.com/kreatinc/nuelink-cli#readme",
12
- "bugs": {
13
- "url": "https://github.com/kreatinc/nuelink-cli/issues"
14
- },
15
- "type": "module",
16
- "main": "./src/cli.js",
17
- "scripts": {
18
- "test": "node --test test/cli.test.mjs",
19
- "smoke:auth": "node src/cli.js auth:status",
20
- "check:pack": "node scripts/check-pack.mjs",
21
- "check:pack:installed": "node scripts/check-packed-package.mjs"
22
- },
23
- "engines": {
24
- "node": ">=18.17"
25
- },
26
- "files": [
27
- "src",
28
- "test",
29
- "CHANGELOG.md",
30
- "README.md",
31
- "CONTRIBUTING.md",
32
- "SECURITY.md",
33
- "LICENSE"
34
- ],
35
- "publishConfig": {
36
- "access": "public"
37
- },
38
- "keywords": [
39
- "nuelink",
40
- "cli",
41
- "social-media",
42
- "automation"
43
- ],
44
- "dependencies": {
45
- "chalk": "^5.6.2",
46
- "commander": "^13.1.0"
47
- },
48
- "bin": {
49
- "nuelink-cli": "src/cli.js"
50
- }
51
- }
1
+ {
2
+ "name": "@nuelink/nuelink-cli",
3
+ "version": "1.6.2",
4
+ "description": "The official Nuelink CLI for automating social media workflows from your terminal. Schedule posts, upload media, manage brands, and integrate Nuelink into scripts, CI/CD pipelines, and AI agents.",
5
+ "license": "MIT",
6
+ "author": "Nuelink",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "git+https://github.com/kreatinc/nuelink-cli.git"
10
+ },
11
+ "homepage": "https://github.com/kreatinc/nuelink-cli#readme",
12
+ "bugs": {
13
+ "url": "https://github.com/kreatinc/nuelink-cli/issues"
14
+ },
15
+ "type": "module",
16
+ "main": "./src/cli.js",
17
+ "scripts": {
18
+ "test": "node --test test/cli.test.mjs",
19
+ "smoke:auth": "node src/cli.js auth:status",
20
+ "check:pack": "node scripts/check-pack.mjs",
21
+ "check:pack:installed": "node scripts/check-packed-package.mjs"
22
+ },
23
+ "engines": {
24
+ "node": ">=18.17"
25
+ },
26
+ "files": [
27
+ "src",
28
+ "test",
29
+ "CHANGELOG.md",
30
+ "README.md",
31
+ "CONTRIBUTING.md",
32
+ "SECURITY.md",
33
+ "LICENSE"
34
+ ],
35
+ "publishConfig": {
36
+ "access": "public"
37
+ },
38
+ "keywords": [
39
+ "nuelink",
40
+ "cli",
41
+ "social-media",
42
+ "automation"
43
+ ],
44
+ "dependencies": {
45
+ "chalk": "^5.6.2",
46
+ "commander": "^13.1.0"
47
+ },
48
+ "bin": {
49
+ "nuelink-cli": "src/cli.js"
50
+ }
51
+ }
package/src/http.js CHANGED
@@ -185,6 +185,8 @@ async function nuelinkRequest({ apiKey, method = "GET", endpoint, query, body, m
185
185
  const init = {
186
186
  method,
187
187
  headers,
188
+ // API mutations must never replay a body or credentials to a redirect target.
189
+ redirect: "error",
188
190
  };
189
191
 
190
192
  if (multipart) {
package/src/output.js CHANGED
@@ -19,7 +19,11 @@ function formatCell(value, maxLength = 42) {
19
19
  } else if (typeof value === "number" || typeof value === "boolean") {
20
20
  text = String(value);
21
21
  } else if (Array.isArray(value)) {
22
- text = `[${value.map((item) => formatCell(item, 18)).join(", ")}]`;
22
+ if (value.every((item) => item && typeof item === "object" && !Array.isArray(item))) {
23
+ text = value.map((item) => item.name ?? item.id ?? JSON.stringify(item)).join(", ") || "none";
24
+ } else {
25
+ text = "[" + value.map((item) => formatCell(item, 18)).join(", ") + "]";
26
+ }
23
27
  } else {
24
28
  text = JSON.stringify(value);
25
29
  }
@@ -45,6 +49,7 @@ function pickColumns(items) {
45
49
  "queueStatus",
46
50
  "timezone",
47
51
  "collectionId",
52
+ "channels",
48
53
  "postType",
49
54
  "postingType",
50
55
  "postDate",
@@ -53,7 +58,7 @@ function pickColumns(items) {
53
58
  "createdAt",
54
59
  "updatedAt",
55
60
  ];
56
- const excludedKeys = new Set(["body", "caption", "media", "poll", "platforms", "queues", "channels"]);
61
+ const excludedKeys = new Set(["body", "caption", "media", "poll", "platforms", "queues"]);
57
62
  const presentKeys = new Set(items.flatMap((item) => Object.keys(item)));
58
63
 
59
64
  const columns = preferredKeys.filter((key) => presentKeys.has(key) && !excludedKeys.has(key));
@@ -64,17 +69,17 @@ function pickColumns(items) {
64
69
  columns.push(key);
65
70
  }
66
71
 
67
- if (columns.length >= 7) {
72
+ if (columns.length >= 8) {
68
73
  break;
69
74
  }
70
75
  }
71
76
 
72
- if (columns.length >= 7) {
77
+ if (columns.length >= 8) {
73
78
  break;
74
79
  }
75
80
  }
76
81
 
77
- return columns.slice(0, 7);
82
+ return columns.slice(0, 8);
78
83
  }
79
84
 
80
85
  function renderTable(items) {
package/test/cli.test.mjs CHANGED
@@ -3,9 +3,10 @@ import assert from "node:assert/strict";
3
3
  import os from "node:os";
4
4
  import path from "node:path";
5
5
  import { mkdir, mkdtemp, readFile, readdir, writeFile } from "node:fs/promises";
6
- import { spawnSync } from "node:child_process";
6
+ import { spawn, spawnSync } from "node:child_process";
7
7
  import { fileURLToPath } from "node:url";
8
8
  import { pathToFileURL } from "node:url";
9
+ import { createServer } from "node:http";
9
10
 
10
11
  const __filename = fileURLToPath(import.meta.url);
11
12
  const __dirname = path.dirname(__filename);
@@ -43,6 +44,32 @@ function runCli({ args, homeDir, capturePath, withMock = true, input, extraEnv =
43
44
  });
44
45
  }
45
46
 
47
+ function runCliAsync({ args, homeDir, capturePath, withMock = false, extraEnv = {} }) {
48
+ const nodeArgs = withMock
49
+ ? ["--require", mockCjsPath, mainPath, ...args]
50
+ : [mainPath, ...args];
51
+ return new Promise((resolve, reject) => {
52
+ const child = spawn(process.execPath, nodeArgs, {
53
+ cwd: workspaceRoot,
54
+ env: {
55
+ ...process.env,
56
+ HOME: homeDir,
57
+ USERPROFILE: homeDir,
58
+ NUELINK_API_KEY: currentApiKey(),
59
+ NUELINK_MOCK_CAPTURE_PATH: capturePath,
60
+ ...extraEnv,
61
+ },
62
+ stdio: ["ignore", "pipe", "pipe"],
63
+ });
64
+ let stdout = "";
65
+ let stderr = "";
66
+ child.stdout.setEncoding("utf8").on("data", (chunk) => { stdout += chunk; });
67
+ child.stderr.setEncoding("utf8").on("data", (chunk) => { stderr += chunk; });
68
+ child.on("error", reject);
69
+ child.on("close", (status) => resolve({ status, stdout, stderr }));
70
+ });
71
+ }
72
+
46
73
  function assertJsonError(result, code) {
47
74
  assert.equal(result.status, 1, result.stderr);
48
75
  assert.equal(result.stderr, "");
@@ -68,12 +95,68 @@ test("brands command builds pagination query", async () => {
68
95
  const url = new URL(capture.url);
69
96
 
70
97
  assert.equal(capture.method, "GET");
98
+ assert.equal(capture.redirect, "error");
71
99
  assert.equal(url.pathname, "/api/public/v1/brands");
72
100
  assert.equal(url.searchParams.get("per_page"), "2");
73
101
  assert.equal(url.searchParams.get("page"), "3");
74
102
  assert.match(capture.headers.Authorization || capture.headers.authorization, /^Bearer\s+/);
75
103
  });
76
104
 
105
+ test("mutation requests reject cross-origin redirects before forwarding their body", async () => {
106
+ const homeDir = await setupTempHome();
107
+ let forwardedRequests = 0;
108
+ let originalRequest;
109
+ const destination = createServer(() => {
110
+ forwardedRequests += 1;
111
+ });
112
+ const destinationAddress = await new Promise((resolve) => {
113
+ destination.listen(0, "127.0.0.1", () => resolve(destination.address()));
114
+ });
115
+ const origin = createServer((request, response) => {
116
+ let body = "";
117
+ request.setEncoding("utf8");
118
+ request.on("data", (chunk) => { body += chunk; });
119
+ request.on("end", () => {
120
+ originalRequest = {
121
+ method: request.method,
122
+ authorization: request.headers.authorization,
123
+ body,
124
+ };
125
+ response.writeHead(307, { location: `http://127.0.0.1:${destinationAddress.port}/capture` });
126
+ response.end();
127
+ });
128
+ });
129
+
130
+ try {
131
+ const originAddress = await new Promise((resolve) => {
132
+ origin.listen(0, "127.0.0.1", () => resolve(origin.address()));
133
+ });
134
+ const result = await runCliAsync({
135
+ args: ["collections:create", "--brand-id", "13493", "--title", "redirect guard"],
136
+ homeDir,
137
+ capturePath: path.join(homeDir, "capture-redirect-policy.json"),
138
+ withMock: false,
139
+ extraEnv: {
140
+ NUELINK_BASE_URL: `http://127.0.0.1:${originAddress.port}/api/public/v1`,
141
+ NUELINK_ALLOW_INSECURE_HTTP: "1",
142
+ },
143
+ });
144
+
145
+ assert.equal(result.status, 1);
146
+ assert.deepEqual(originalRequest, {
147
+ method: "POST",
148
+ authorization: `Bearer ${currentApiKey()}`,
149
+ body: JSON.stringify({ title: "redirect guard", description: "", channels: [], queues: [] }),
150
+ });
151
+ assert.equal(forwardedRequests, 0);
152
+ } finally {
153
+ await Promise.all([
154
+ new Promise((resolve) => origin.close(resolve)),
155
+ new Promise((resolve) => destination.close(resolve)),
156
+ ]);
157
+ }
158
+ });
159
+
77
160
  test("automations command builds pagination query", async () => {
78
161
  const homeDir = await setupTempHome();
79
162
  const capturePath = path.join(homeDir, "capture-automations.json");
@@ -235,6 +318,36 @@ test("brands command renders table output", async () => {
235
318
  assert.match(result.stdout, /zapier/);
236
319
  });
237
320
 
321
+ test("post list table shows effective channel names", async () => {
322
+ const homeDir = await setupTempHome();
323
+ const capturePath = path.join(homeDir, "capture-post-channels.json");
324
+ const result = runCli({
325
+ args: ["posts", "--brand-id", "42", "--collection-id", "77"],
326
+ homeDir,
327
+ capturePath,
328
+ });
329
+
330
+ assert.equal(result.status, 0, result.stderr);
331
+ assert.match(result.stdout, /\|\s*Channels\s*\|/);
332
+ assert.match(result.stdout, /Product Instagram/);
333
+ });
334
+
335
+ test("post JSON output preserves effective channel summaries", async () => {
336
+ const homeDir = await setupTempHome();
337
+ const capturePath = path.join(homeDir, "capture-post-channels-json.json");
338
+ const result = runCli({
339
+ args: ["--json", "posts", "--brand-id", "42", "--collection-id", "77"],
340
+ homeDir,
341
+ capturePath,
342
+ });
343
+
344
+ assert.equal(result.status, 0, result.stderr);
345
+ const output = JSON.parse(result.stdout);
346
+ assert.deepEqual(output.data[0].channels, [
347
+ { id: 501, name: "Product Instagram", status: "ACTIVE", type: "Instagram" },
348
+ ]);
349
+ });
350
+
238
351
  test("brands command can force json output", async () => {
239
352
  const homeDir = await setupTempHome();
240
353
  const capturePath = path.join(homeDir, "capture-brands-json.json");
@@ -41,6 +41,7 @@ globalThis.fetch = async (input, init = {}) => {
41
41
  requestCount,
42
42
  url: url.toString(),
43
43
  method: init.method || "GET",
44
+ redirect: init.redirect,
44
45
  headers,
45
46
  body: parsedBody,
46
47
  };
@@ -241,6 +242,9 @@ globalThis.fetch = async (input, init = {}) => {
241
242
  postType: "IMAGE",
242
243
  postingType: "SCHEDULE",
243
244
  status: "PUBLISHED",
245
+ channels: [
246
+ { id: 501, name: "Product Instagram", status: "ACTIVE", type: "Instagram" },
247
+ ],
244
248
  postDate: "2026-05-12 14:00:00",
245
249
  createdAt: "2026-05-11T08:59:13.000000Z",
246
250
  updatedAt: "2026-05-12T14:00:53.000000Z",
@@ -41,6 +41,7 @@ globalThis.fetch = async (input, init = {}) => {
41
41
  requestCount,
42
42
  url: url.toString(),
43
43
  method: init.method || "GET",
44
+ redirect: init.redirect,
44
45
  headers,
45
46
  body: parsedBody,
46
47
  };
@@ -241,6 +242,9 @@ globalThis.fetch = async (input, init = {}) => {
241
242
  postType: "IMAGE",
242
243
  postingType: "SCHEDULE",
243
244
  status: "PUBLISHED",
245
+ channels: [
246
+ { id: 501, name: "Product Instagram", status: "ACTIVE", type: "Instagram" },
247
+ ],
244
248
  postDate: "2026-05-12 14:00:00",
245
249
  createdAt: "2026-05-11T08:59:13.000000Z",
246
250
  updatedAt: "2026-05-12T14:00:53.000000Z",