@nuelink/nuelink-cli 1.6.6 → 1.7.1

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,15 @@
1
1
  # Changelog
2
2
 
3
+ ## 1.7.1
4
+
5
+ - Add the `posts:create --ai-generated <boolean>` option and `aiGenerated` support for JSON post payloads.
6
+
7
+ ## 1.7.0
8
+
9
+ - Add `posts:create --googlemybusiness-post <json>` support for Google Business Profile STANDARD, EVENT, and OFFER post settings.
10
+ - Validate Google Business event dates, times, required fields, and offer details before previewing or sending requests.
11
+ - Document Google Business Profile request fields and include the supported payload in the Postman collection.
12
+
3
13
  ## 1.6.6
4
14
 
5
15
  - Reject polls with missing or empty options before requests and dry-run previews; every poll requires a question, 2 to 4 options, and a supported period.
package/README.md CHANGED
@@ -290,6 +290,7 @@ Example `post.json`:
290
290
  {
291
291
  "title": "CLI Post Title",
292
292
  "caption": "Post body from CLI",
293
+ "aiGenerated": true,
293
294
  "publishMode": "DRAFT"
294
295
  }
295
296
  ```
@@ -305,6 +306,7 @@ nuelink-cli posts:create \
305
306
  --alt "is this fine" \
306
307
  --link "https://nuelink.com" \
307
308
  --auto-thread-text true \
309
+ --ai-generated true \
308
310
  --publish-mode DRAFT \
309
311
  --post-as-story true \
310
312
  --comment "this is a comment" \
@@ -331,10 +333,33 @@ nuelink-cli posts:create \
331
333
  --dry-run
332
334
  ```
333
335
 
336
+ Pass the nested Google Business Profile post data as JSON with
337
+ `--googlemybusiness-post`. The JSON object must include `type`, which accepts
338
+ `STANDARD`, `EVENT`, or `OFFER`; the fields map directly under
339
+ `platforms.googlemybusiness`.
340
+ Both `EVENT` and `OFFER` require an `event` with a title (up to 58 characters),
341
+ start and end dates (`YYYY-MM-DD`), and start and end times (`HH:mm:ss`).
342
+ `offer` may include a coupon code (up to 58 characters), a redemption URL, and
343
+ terms (up to 1000 characters).
344
+
345
+ ```bash
346
+ nuelink-cli posts:create \
347
+ --brand-id 13493 \
348
+ --collection-id 33273 \
349
+ --caption "Holiday promotion" \
350
+ --publish-mode DRAFT \
351
+ --googlemybusiness-post '{"type":"OFFER","event":{"title":"Holiday offer","startDate":"2099-12-30","startTime":"09:00:00","endDate":"2099-12-31","endTime":"18:00:00"},"offer":{"couponCode":"SAVE20","redeemOnlineUrl":"https://example.com/offer","termsConditions":"One per customer."}}' \
352
+ --dry-run
353
+ ```
354
+
334
355
  `--comment-delay` is measured in minutes after publishing and must be a positive
335
356
  integer (minimum `1`). Provide it together with `--comment`; the JSON/API field
336
357
  is `comment.delay` and uses the same minutes unit.
337
358
 
359
+ Use `--ai-generated true` when the post content was generated by AI. The CLI maps
360
+ it to the API's top-level `aiGenerated` boolean; omitting the option uses the API
361
+ default of `false`. JSON payloads can set `aiGenerated` directly.
362
+
338
363
  Review each mutation preview, then repeat the same command without `--dry-run`
339
364
  only when you intend to send it. `--dry-run` is supported for mutations; GET
340
365
  commands reject it instead of silently suppressing the read. Before executing a
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nuelink/nuelink-cli",
3
- "version": "1.6.6",
3
+ "version": "1.7.1",
4
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
5
  "license": "MIT",
6
6
  "author": "Nuelink",
package/src/commands.js CHANGED
@@ -882,6 +882,7 @@ function registerCommands(program, runtimeApiKey, cliVersion) {
882
882
  .option("--alt <text>", "Alt text")
883
883
  .option("--link <url>", "Post link")
884
884
  .option("--auto-thread-text <boolean>", "Automatically thread text: true/false (defaults to true)")
885
+ .option("--ai-generated <boolean>", "Mark the post as AI-generated: true/false (defaults to false)")
885
886
  .option("--publish-mode <mode>", `Publish mode (${VALID_PUBLISH_MODES.join(", ")})`, "DRAFT")
886
887
  .option("--scheduled-at <value>", "Publish datetime (YYYY-MM-DD HH:mm:ss) or null")
887
888
  .option("--post-as-story <boolean>", "Post as story: true/false")
@@ -906,6 +907,7 @@ function registerCommands(program, runtimeApiKey, cliVersion) {
906
907
  .option("--youtube-tags <tags>", "Comma-separated YouTube tags")
907
908
  .option("--youtube-playlists <json>", "YouTube playlists JSON string")
908
909
  .option("--googlemybusiness-upload-to-photos-section <boolean>", "Upload to Google Business Profile photos: true/false")
910
+ .option("--googlemybusiness-post <json>", "Google Business Profile post settings JSON (type, event, and offer)")
909
911
  .action(withCommandErrorHandling(program, async (options) => {
910
912
  if (options.comment === undefined && options.commentDelay !== undefined) {
911
913
  throw new Error("comment and comment-delay must be provided together.");
@@ -67,6 +67,129 @@ function normalizePublishMode(value) {
67
67
  return normalized;
68
68
  }
69
69
 
70
+ function validateGoogleBusinessPostOptions(value, label = "googlemybusiness-post", requireType = false) {
71
+ if (!value || typeof value !== "object" || Array.isArray(value)) {
72
+ throw new Error(`Invalid ${label}. Expected a JSON object.`);
73
+ }
74
+
75
+ const allowedKeys = ["type", "event", "offer"];
76
+ const unexpectedKey = Object.keys(value).find((key) => !allowedKeys.includes(key));
77
+ if (unexpectedKey) {
78
+ throw new Error(`Invalid ${label}. Unexpected field "${unexpectedKey}".`);
79
+ }
80
+
81
+ const validTypes = ["STANDARD", "OFFER", "EVENT"];
82
+ if (requireType && (value.type === undefined || value.type === null)) {
83
+ throw new Error(`Invalid ${label}. type is required.`);
84
+ }
85
+ if (value.type !== undefined && value.type !== null && !validTypes.includes(value.type)) {
86
+ throw new Error(`Invalid ${label}. type must be one of: ${validTypes.join(", ")}, or null.`);
87
+ }
88
+
89
+ if (
90
+ ((value.event !== undefined && value.event !== null) || (value.offer !== undefined && value.offer !== null)) &&
91
+ (value.type === undefined || value.type === null)
92
+ ) {
93
+ throw new Error(`Invalid ${label}. A non-null type is required when event or offer is provided.`);
94
+ }
95
+
96
+ const requiresEvent = value.type === "OFFER" || value.type === "EVENT";
97
+ if (requiresEvent && (value.event === undefined || value.event === null)) {
98
+ throw new Error(`Invalid ${label}. event is required when type is ${value.type}.`);
99
+ }
100
+ if (value.event !== undefined && value.event !== null) {
101
+ const event = value.event;
102
+ const eventLabel = `${label}.event`;
103
+ if (!event || typeof event !== "object" || Array.isArray(event)) {
104
+ throw new Error(`Invalid ${eventLabel}. Expected a JSON object or null.`);
105
+ }
106
+
107
+ const eventFields = ["title", "startDate", "startTime", "endDate", "endTime"];
108
+ const unexpectedEventField = Object.keys(event).find((key) => !eventFields.includes(key));
109
+ if (unexpectedEventField) {
110
+ throw new Error(`Invalid ${eventLabel}. Unexpected field "${unexpectedEventField}".`);
111
+ }
112
+
113
+ for (const field of eventFields) {
114
+ const fieldValue = event[field];
115
+ const fieldLabel = `${eventLabel}.${field}`;
116
+ if (requiresEvent && (fieldValue === undefined || fieldValue === null || String(fieldValue).trim() === "")) {
117
+ throw new Error(`Invalid ${fieldLabel}. This field is required when type is ${value.type}.`);
118
+ }
119
+ if (fieldValue === undefined || fieldValue === null) continue;
120
+ if (typeof fieldValue !== "string") {
121
+ throw new Error(`Invalid ${fieldLabel}. Expected a string or null.`);
122
+ }
123
+ if (field === "title") {
124
+ validateOptionalLength(fieldValue, 58, fieldLabel);
125
+ } else if (field === "startDate" || field === "endDate") {
126
+ if (!/^\d{4}-\d{2}-\d{2}$/.test(fieldValue)) {
127
+ throw new Error(`Invalid ${fieldLabel}. Expected YYYY-MM-DD.`);
128
+ }
129
+ const date = new Date(`${fieldValue}T00:00:00.000Z`);
130
+ if (Number.isNaN(date.getTime()) || date.toISOString().slice(0, 10) !== fieldValue) {
131
+ throw new Error(`Invalid ${fieldLabel}. Expected a real calendar date in YYYY-MM-DD format.`);
132
+ }
133
+ } else if (!/^([01]\d|2[0-3]):[0-5]\d:[0-5]\d$/.test(fieldValue)) {
134
+ throw new Error(`Invalid ${fieldLabel}. Expected HH:mm:ss.`);
135
+ }
136
+ }
137
+ }
138
+
139
+ if (value.offer !== undefined && value.offer !== null) {
140
+ const offer = value.offer;
141
+ const offerLabel = `${label}.offer`;
142
+ if (!offer || typeof offer !== "object" || Array.isArray(offer)) {
143
+ throw new Error(`Invalid ${offerLabel}. Expected a JSON object or null.`);
144
+ }
145
+ const offerFields = ["couponCode", "redeemOnlineUrl", "termsConditions"];
146
+ const unexpectedOfferField = Object.keys(offer).find((key) => !offerFields.includes(key));
147
+ if (unexpectedOfferField) {
148
+ throw new Error(`Invalid ${offerLabel}. Unexpected field "${unexpectedOfferField}".`);
149
+ }
150
+ for (const field of ["couponCode", "termsConditions"]) {
151
+ const fieldValue = offer[field];
152
+ if (fieldValue !== undefined && fieldValue !== null) {
153
+ if (typeof fieldValue !== "string") {
154
+ throw new Error(`Invalid ${offerLabel}.${field}. Expected a string or null.`);
155
+ }
156
+ validateOptionalLength(fieldValue, field === "couponCode" ? 58 : 1000, `${offerLabel}.${field}`);
157
+ }
158
+ }
159
+ if (offer.redeemOnlineUrl !== undefined && offer.redeemOnlineUrl !== null) {
160
+ if (typeof offer.redeemOnlineUrl !== "string") {
161
+ throw new Error(`Invalid ${offerLabel}.redeemOnlineUrl. Expected a string or null.`);
162
+ }
163
+ validateHttpUrl(offer.redeemOnlineUrl, `${offerLabel}.redeemOnlineUrl`);
164
+ }
165
+ }
166
+
167
+ return value;
168
+ }
169
+
170
+ function validateGoogleBusinessOptions(value, label = "platforms.googlemybusiness") {
171
+ if (value === undefined || value === null) return;
172
+ if (typeof value !== "object" || Array.isArray(value)) {
173
+ throw new Error(`Invalid ${label}. Expected a JSON object or null.`);
174
+ }
175
+ if (
176
+ value.uploadToPhotosSection !== undefined &&
177
+ value.uploadToPhotosSection !== null &&
178
+ typeof value.uploadToPhotosSection !== "boolean"
179
+ ) {
180
+ throw new Error(`Invalid ${label}.uploadToPhotosSection. Expected a boolean or null.`);
181
+ }
182
+ const postOptions = {};
183
+ for (const field of ["type", "event", "offer"]) {
184
+ if (Object.prototype.hasOwnProperty.call(value, field)) {
185
+ postOptions[field] = value[field];
186
+ }
187
+ }
188
+ if (Object.keys(postOptions).length > 0) {
189
+ validateGoogleBusinessPostOptions(postOptions, label);
190
+ }
191
+ }
192
+
70
193
  function validateRawPostPayload(payload) {
71
194
  if (!payload || typeof payload !== "object" || Array.isArray(payload)) {
72
195
  throw new Error("Invalid payload. Expected a JSON object.");
@@ -84,9 +207,18 @@ function validateRawPostPayload(payload) {
84
207
  if (payload.autoThreadText !== undefined && payload.autoThreadText !== null && typeof payload.autoThreadText !== "boolean") {
85
208
  throw new Error("Invalid autoThreadText. Expected a boolean or null.");
86
209
  }
210
+ if (payload.aiGenerated !== undefined && payload.aiGenerated !== null && typeof payload.aiGenerated !== "boolean") {
211
+ throw new Error("Invalid aiGenerated. Expected a boolean or null.");
212
+ }
87
213
  if (payload.link !== undefined && payload.link !== null) {
88
214
  validateHttpUrl(payload.link, "link");
89
215
  }
216
+ if (payload.platforms !== undefined && payload.platforms !== null) {
217
+ if (typeof payload.platforms !== "object" || Array.isArray(payload.platforms)) {
218
+ throw new Error("Invalid platforms. Expected a JSON object or null.");
219
+ }
220
+ validateGoogleBusinessOptions(payload.platforms.googlemybusiness);
221
+ }
90
222
 
91
223
  const poll = payload.poll;
92
224
  const caption = !poll
@@ -144,6 +276,7 @@ function buildPostPayload(options) {
144
276
  const publishMode = normalizePublishMode(options.publishMode);
145
277
  const scheduledAt = validateScheduledAt(options.scheduledAt);
146
278
  const autoThreadText = parseBooleanStrict(options.autoThreadText, "auto-thread-text") ?? true;
279
+ const aiGenerated = parseBooleanStrict(options.aiGenerated, "ai-generated");
147
280
 
148
281
  if (publishMode === "SCHEDULE" && !scheduledAt) {
149
282
  throw new Error("scheduledAt is required when publishMode is SCHEDULE.");
@@ -256,6 +389,13 @@ function buildPostPayload(options) {
256
389
  : {}),
257
390
  ...(youtubePlaylists ? { playlists: youtubePlaylists } : {}),
258
391
  };
392
+ const googleBusinessPost = options.googlemybusinessPost === undefined
393
+ ? undefined
394
+ : validateGoogleBusinessPostOptions(
395
+ parseJsonString(options.googlemybusinessPost, "googlemybusiness-post"),
396
+ "googlemybusiness-post",
397
+ true,
398
+ );
259
399
  const googlemybusiness = {
260
400
  ...(parseBooleanStrict(
261
401
  options.googlemybusinessUploadToPhotosSection,
@@ -268,6 +408,7 @@ function buildPostPayload(options) {
268
408
  ),
269
409
  }
270
410
  : {}),
411
+ ...(googleBusinessPost !== undefined ? googleBusinessPost : {}),
271
412
  };
272
413
 
273
414
  const hasPoll = Object.keys(poll).length > 0;
@@ -291,6 +432,7 @@ function buildPostPayload(options) {
291
432
  publishMode,
292
433
  scheduledAt,
293
434
  autoThreadText,
435
+ ...(aiGenerated !== undefined ? { aiGenerated } : {}),
294
436
  ...(parseBooleanStrict(options.postAsStory, "post-as-story") !== undefined
295
437
  ? { postAsStory: parseBooleanStrict(options.postAsStory, "post-as-story") }
296
438
  : {}),
package/test/cli.test.mjs CHANGED
@@ -778,6 +778,23 @@ test("posts:add-json preserves nullable contract fields for dry-run and request
778
778
  poll: null,
779
779
  publishMode: "DRAFT",
780
780
  },
781
+ {
782
+ caption: "Google Business event draft",
783
+ publishMode: "DRAFT",
784
+ platforms: {
785
+ googlemybusiness: {
786
+ uploadToPhotosSection: true,
787
+ type: "EVENT",
788
+ event: {
789
+ title: "Store opening",
790
+ startDate: "2099-12-30",
791
+ startTime: "09:00:00",
792
+ endDate: "2099-12-31",
793
+ endTime: "18:00:00",
794
+ },
795
+ },
796
+ },
797
+ },
781
798
  ];
782
799
 
783
800
  for (const [index, payload] of payloads.entries()) {
@@ -859,6 +876,74 @@ test("posts:add-json rejects invalid autoThreadText values", async () => {
859
876
  assert.match(result.stderr, /Invalid autoThreadText/);
860
877
  });
861
878
 
879
+ test("posts:add-json rejects non-boolean aiGenerated values", async () => {
880
+ const homeDir = await setupTempHome();
881
+
882
+ const result = runCli({
883
+ args: ["posts:add-json", "--brand-id", "10", "--collection-id", "20", "--payload", "-"],
884
+ homeDir,
885
+ capturePath: path.join(homeDir, "capture-posts-invalid-ai-generated.json"),
886
+ input: JSON.stringify({ caption: "post", publishMode: "DRAFT", aiGenerated: "true" }),
887
+ });
888
+
889
+ assert.equal(result.status, 1);
890
+ assert.match(result.stderr, /Invalid aiGenerated/);
891
+ });
892
+
893
+ test("posts:add-json rejects invalid Google Business post fields", async () => {
894
+ const homeDir = await setupTempHome();
895
+ const invalidGoogleBusinessOptions = [
896
+ { type: "UNKNOWN" },
897
+ { type: "EVENT" },
898
+ {
899
+ type: "EVENT",
900
+ event: {
901
+ title: " ",
902
+ startDate: "2099-12-30",
903
+ startTime: "10:00:00",
904
+ endDate: "2099-12-31",
905
+ endTime: "11:00:00",
906
+ },
907
+ },
908
+ {
909
+ type: "EVENT",
910
+ event: {
911
+ title: "Event",
912
+ startDate: "2026-02-30",
913
+ startTime: "10:00:00",
914
+ endDate: "2026-03-01",
915
+ endTime: "11:00:00",
916
+ },
917
+ },
918
+ { type: "STANDARD", event: { unexpected: true } },
919
+ { event: { title: "Event" } },
920
+ { offer: { couponCode: "SAVE20" } },
921
+ {
922
+ type: "OFFER",
923
+ event: {
924
+ title: "Offer",
925
+ startDate: "2099-12-30",
926
+ startTime: "10:00:00",
927
+ endDate: "2099-12-31",
928
+ endTime: "11:00:00",
929
+ },
930
+ offer: { redeemOnlineUrl: "not a url" },
931
+ },
932
+ ];
933
+
934
+ for (const [index, googleBusinessOptions] of invalidGoogleBusinessOptions.entries()) {
935
+ const result = runCli({
936
+ args: ["posts:add-json", "--brand-id", "10", "--collection-id", "20", "--payload", "-"],
937
+ homeDir,
938
+ capturePath: path.join(homeDir, `capture-invalid-gmb-post-${index}.json`),
939
+ input: JSON.stringify({ caption: "Google Business post", publishMode: "DRAFT", platforms: { googlemybusiness: googleBusinessOptions } }),
940
+ });
941
+ assert.equal(result.status, 1, result.stderr);
942
+ assert.match(result.stderr, /googlemybusiness|Google Business/i);
943
+ await assert.rejects(readFile(path.join(homeDir, `capture-invalid-gmb-post-${index}.json`), "utf8"));
944
+ }
945
+ });
946
+
862
947
  test("dry-run prints validated request without sending", async () => {
863
948
  const homeDir = await setupTempHome();
864
949
  const capturePath = path.join(homeDir, "capture-dry-run.json");
@@ -956,6 +1041,21 @@ test("new public API management commands build the documented requests", async (
956
1041
  test("posts:create builds full payload from options", async () => {
957
1042
  const homeDir = await setupTempHome();
958
1043
  const capturePath = path.join(homeDir, "capture-posts-create.json");
1044
+ const googleBusinessPost = {
1045
+ type: "OFFER",
1046
+ event: {
1047
+ title: "Holiday offer",
1048
+ startDate: "2099-12-30",
1049
+ startTime: "09:00:00",
1050
+ endDate: "2099-12-31",
1051
+ endTime: "18:00:00",
1052
+ },
1053
+ offer: {
1054
+ couponCode: "SAVE20",
1055
+ redeemOnlineUrl: "https://example.com/offer",
1056
+ termsConditions: "One per customer.",
1057
+ },
1058
+ };
959
1059
 
960
1060
  const result = runCli({
961
1061
  args: [
@@ -974,6 +1074,8 @@ test("posts:create builds full payload from options", async () => {
974
1074
  "https://nuelink.com",
975
1075
  "--auto-thread-text",
976
1076
  "true",
1077
+ "--ai-generated",
1078
+ "true",
977
1079
  "--publish-mode",
978
1080
  "DRAFT",
979
1081
  "--post-as-story",
@@ -1020,6 +1122,8 @@ test("posts:create builds full payload from options", async () => {
1020
1122
  '[{"channelId":1,"playlistIds":["1","2"]}]',
1021
1123
  "--googlemybusiness-upload-to-photos-section",
1022
1124
  "true",
1125
+ "--googlemybusiness-post",
1126
+ JSON.stringify(googleBusinessPost),
1023
1127
  ],
1024
1128
  homeDir,
1025
1129
  capturePath,
@@ -1032,6 +1136,7 @@ test("posts:create builds full payload from options", async () => {
1032
1136
  assert.equal(capture.body.title, "title here");
1033
1137
  assert.equal(capture.body.caption, "body here");
1034
1138
  assert.equal(capture.body.autoThreadText, true);
1139
+ assert.equal(capture.body.aiGenerated, true);
1035
1140
  assert.equal(capture.body.postAsStory, true);
1036
1141
  assert.equal(capture.body.comment.delay, 30);
1037
1142
  assert.deepEqual(capture.body.media, [
@@ -1048,6 +1153,56 @@ test("posts:create builds full payload from options", async () => {
1048
1153
  { channelId: 1, playlistIds: ["1", "2"] },
1049
1154
  ]);
1050
1155
  assert.equal(capture.body.platforms.googlemybusiness.uploadToPhotosSection, true);
1156
+ assert.deepEqual(capture.body.platforms.googlemybusiness, {
1157
+ uploadToPhotosSection: true,
1158
+ ...googleBusinessPost,
1159
+ });
1160
+ });
1161
+
1162
+ test("posts:create preserves an explicit false ai-generated value", async () => {
1163
+ const homeDir = await setupTempHome();
1164
+ const capturePath = path.join(homeDir, "capture-ai-generated-false.json");
1165
+ const result = runCli({
1166
+ args: [
1167
+ "posts:create",
1168
+ "--brand-id", "10",
1169
+ "--collection-id", "20",
1170
+ "--caption", "Post body",
1171
+ "--publish-mode", "DRAFT",
1172
+ "--ai-generated", "false",
1173
+ ],
1174
+ homeDir,
1175
+ capturePath,
1176
+ });
1177
+
1178
+ assert.equal(result.status, 0, result.stderr);
1179
+ const capture = JSON.parse(await readFile(capturePath, "utf8"));
1180
+ assert.equal(capture.body.aiGenerated, false);
1181
+ });
1182
+
1183
+ test("posts:create requires a Google Business Profile type in its post JSON option", async () => {
1184
+ const homeDir = await setupTempHome();
1185
+ const capturePath = path.join(homeDir, "capture-gmb-post-without-type.json");
1186
+ const result = runCli({
1187
+ args: [
1188
+ "--dry-run",
1189
+ "posts:create",
1190
+ "--brand-id",
1191
+ "10",
1192
+ "--collection-id",
1193
+ "20",
1194
+ "--caption",
1195
+ "Google Business post",
1196
+ "--googlemybusiness-post",
1197
+ JSON.stringify({ event: { title: "Event" } }),
1198
+ ],
1199
+ homeDir,
1200
+ capturePath,
1201
+ });
1202
+
1203
+ assert.equal(result.status, 1);
1204
+ assert.match(result.stderr, /type is required/i);
1205
+ await assert.rejects(readFile(capturePath, "utf8"));
1051
1206
  });
1052
1207
 
1053
1208
  test("posts:create rejects missing, empty, or out-of-range poll options before preview or request", async () => {