@nuelink/nuelink-cli 1.3.7 → 1.3.8

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nuelink/nuelink-cli",
3
- "version": "1.3.7",
3
+ "version": "1.3.8",
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
@@ -472,6 +472,10 @@ function registerCommands(program, runtimeApiKey, cliVersion) {
472
472
  : await readFile(options.payload, "utf8");
473
473
  const payload = parseJsonString(payloadText, "payload");
474
474
 
475
+ if (!payload || typeof payload !== "object" || Array.isArray(payload)) {
476
+ throw new Error("Invalid payload. Expected a JSON object.");
477
+ }
478
+
475
479
  await executeRequest(program, runtimeApiKey, {
476
480
  method: "POST",
477
481
  endpoint: `${collectionPath(
package/src/validation.js CHANGED
@@ -1,37 +1,37 @@
1
1
  import path from "node:path";
2
2
 
3
3
  const VALID_AUTOMATION_TYPES = ["FEED"];
4
- const VALID_AUTOMATION_SUB_TYPES = [
5
- "YOUTUBE",
6
- "RSS",
7
- "ATOM",
8
- "MEDIUM",
9
- "SHOPIFY",
10
- "WORDPRESS",
11
- "WOOCOMMERCE",
12
- "ETSY",
13
- "GHOST",
14
- "SUBSTACK",
15
- "ANCHOR",
16
- "TRANSISTOR",
17
- "CAPTIVATE",
18
- "SOUNDCLOUD",
19
- "BLOGGER",
20
- "WIX",
21
- "SQUARESPACEBLOG",
22
- "SQUARESPACESHOP",
23
- "WEEBLY",
24
- "TUMBLR",
25
- "SHOPIFY2",
26
- "WOOCOMMERCE2",
27
- "PRESTASHOP",
28
- "BUZZSPROUT",
29
- "RSSCOM",
30
- "CASTOS",
31
- "PODCASTCO",
32
- ];
33
- const VALID_IMPORT_AS_TYPES = ["LINK", "IMAGE", "VIDEO", "CAROUSEL"];
34
- const VALID_MEDIA_FILTER_TYPES = ["IMAGE", "VIDEO", "GIF", "APPLICATION", "DOCUMENT", "CSV"];
4
+ const VALID_AUTOMATION_SUB_TYPES = [
5
+ "YOUTUBE",
6
+ "RSS",
7
+ "ATOM",
8
+ "MEDIUM",
9
+ "SHOPIFY",
10
+ "WORDPRESS",
11
+ "WOOCOMMERCE",
12
+ "ETSY",
13
+ "GHOST",
14
+ "SUBSTACK",
15
+ "ANCHOR",
16
+ "TRANSISTOR",
17
+ "CAPTIVATE",
18
+ "SOUNDCLOUD",
19
+ "BLOGGER",
20
+ "WIX",
21
+ "SQUARESPACEBLOG",
22
+ "SQUARESPACESHOP",
23
+ "WEEBLY",
24
+ "TUMBLR",
25
+ "SHOPIFY2",
26
+ "WOOCOMMERCE2",
27
+ "PRESTASHOP",
28
+ "BUZZSPROUT",
29
+ "RSSCOM",
30
+ "CASTOS",
31
+ "PODCASTCO",
32
+ ];
33
+ const VALID_IMPORT_AS_TYPES = ["LINK", "IMAGE", "VIDEO", "CAROUSEL"];
34
+ const VALID_MEDIA_FILTER_TYPES = ["IMAGE", "VIDEO", "GIF", "APPLICATION", "DOCUMENT", "CSV"];
35
35
  const SUPPORTED_MEDIA_TYPES = new Map([
36
36
  [".jpg", "image/jpeg"],
37
37
  [".jpeg", "image/jpeg"],
@@ -42,7 +42,7 @@ const SUPPORTED_MEDIA_TYPES = new Map([
42
42
  [".mov", "video/quicktime"],
43
43
  ]);
44
44
  const DEFAULT_MAX_MEDIA_SIZE_BYTES = Number(process.env.NUELINK_MAX_MEDIA_SIZE_BYTES || 100 * 1024 * 1024);
45
- const QUEUE_SLOT_PATTERN = /^(Mon|Tue|Wed|Thu|Fri|Sat|Sun) [0-2][0-9]:[0-5][0-9]$/;
45
+ const QUEUE_SLOT_PATTERN = /^(Mon|Tue|Wed|Thu|Fri|Sat|Sun) [0-2][0-9]:[0-5][0-9]$/;
46
46
  const SQL_DATETIME_PATTERN = /^\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}$/;
47
47
 
48
48
  function splitCsv(value) {
@@ -82,40 +82,40 @@ function parsePositiveInteger(value, label) {
82
82
  return parsed;
83
83
  }
84
84
 
85
- function parseOptionalPositiveInteger(value, label) {
85
+ function parseOptionalPositiveInteger(value, label) {
86
86
  if (value === undefined || value === null || value === "") {
87
87
  return undefined;
88
88
  }
89
89
 
90
90
  return parsePositiveInteger(value, label);
91
- }
92
-
93
- function parseOptionalNonNegativeInteger(value, label) {
94
- if (value === undefined || value === null || value === "") {
95
- return undefined;
96
- }
97
-
98
- const normalized = String(value).trim();
99
- if (!/^\d+$/.test(normalized)) {
100
- throw new Error(`Invalid ${label}. Expected a non-negative integer.`);
101
- }
102
-
103
- const parsed = Number(normalized);
104
- if (!Number.isSafeInteger(parsed)) {
105
- throw new Error(`Invalid ${label}. Expected a non-negative integer.`);
106
- }
107
-
108
- return parsed;
109
- }
110
-
111
- function parseIntegerInRange(value, label, minimum, maximum) {
112
- const parsed = parsePositiveInteger(value, label);
113
- if (parsed < minimum || parsed > maximum) {
114
- throw new Error(`Invalid ${label}. Expected an integer from ${minimum} to ${maximum}.`);
115
- }
116
- return parsed;
117
- }
118
-
91
+ }
92
+
93
+ function parseOptionalNonNegativeInteger(value, label) {
94
+ if (value === undefined || value === null || value === "") {
95
+ return undefined;
96
+ }
97
+
98
+ const normalized = String(value).trim();
99
+ if (!/^\d+$/.test(normalized)) {
100
+ throw new Error(`Invalid ${label}. Expected a non-negative integer.`);
101
+ }
102
+
103
+ const parsed = Number(normalized);
104
+ if (!Number.isSafeInteger(parsed)) {
105
+ throw new Error(`Invalid ${label}. Expected a non-negative integer.`);
106
+ }
107
+
108
+ return parsed;
109
+ }
110
+
111
+ function parseIntegerInRange(value, label, minimum, maximum) {
112
+ const parsed = parsePositiveInteger(value, label);
113
+ if (parsed < minimum || parsed > maximum) {
114
+ throw new Error(`Invalid ${label}. Expected an integer from ${minimum} to ${maximum}.`);
115
+ }
116
+ return parsed;
117
+ }
118
+
119
119
  function parseBooleanStrict(value, label) {
120
120
  if (value === undefined || value === null || value === "") {
121
121
  return undefined;
@@ -168,11 +168,27 @@ function validateScheduledAt(value) {
168
168
 
169
169
  const normalized = String(value).trim();
170
170
 
171
- if (!SQL_DATETIME_PATTERN.test(normalized)) {
172
- throw new Error("Invalid scheduled-at. Expected YYYY-MM-DD HH:mm:ss.");
173
- }
174
-
175
- return normalized;
171
+ if (!SQL_DATETIME_PATTERN.test(normalized)) {
172
+ throw new Error("Invalid scheduled-at. Expected YYYY-MM-DD HH:mm:ss.");
173
+ }
174
+
175
+ const [datePart, timePart] = normalized.split(" ");
176
+ const [year, month, day] = datePart.split("-").map(Number);
177
+ const [hours, minutes, seconds] = timePart.split(":").map(Number);
178
+
179
+ const date = new Date(Date.UTC(year, month - 1, day, hours, minutes, seconds));
180
+ const isValidDate = date.getUTCFullYear() === year
181
+ && date.getUTCMonth() === month - 1
182
+ && date.getUTCDate() === day
183
+ && date.getUTCHours() === hours
184
+ && date.getUTCMinutes() === minutes
185
+ && date.getUTCSeconds() === seconds;
186
+
187
+ if (!isValidDate) {
188
+ throw new Error("Invalid scheduled-at. Expected a real calendar date and time.");
189
+ }
190
+
191
+ return normalized;
176
192
  }
177
193
 
178
194
  function validatePollOptions(options, correctOptionIndex) {
@@ -220,15 +236,15 @@ function validateMediaFile(filePath, fileStat) {
220
236
  }
221
237
 
222
238
  export {
223
- VALID_AUTOMATION_SUB_TYPES,
224
- VALID_AUTOMATION_TYPES,
225
- VALID_IMPORT_AS_TYPES,
226
- VALID_MEDIA_FILTER_TYPES,
227
- parseBooleanStrict,
228
- parseIntegerInRange,
229
- parseJsonString,
230
- parseOptionalNonNegativeInteger,
231
- parseOptionalPositiveInteger,
239
+ VALID_AUTOMATION_SUB_TYPES,
240
+ VALID_AUTOMATION_TYPES,
241
+ VALID_IMPORT_AS_TYPES,
242
+ VALID_MEDIA_FILTER_TYPES,
243
+ parseBooleanStrict,
244
+ parseIntegerInRange,
245
+ parseJsonString,
246
+ parseOptionalNonNegativeInteger,
247
+ parseOptionalPositiveInteger,
232
248
  parsePositiveInteger,
233
249
  splitCsv,
234
250
  validateHttpUrl,
@@ -237,4 +253,4 @@ export {
237
253
  validateScheduledAt,
238
254
  validateQueueSlots,
239
255
  normalizeEnum,
240
- };
256
+ };