@nuelink/nuelink-cli 1.3.7 → 1.3.9

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.9",
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",
@@ -30,4 +30,4 @@
30
30
  "bin": {
31
31
  "nuelink-cli": "./src/cli.js"
32
32
  }
33
- }
33
+ }
package/src/commands.js CHANGED
@@ -5,7 +5,7 @@ import chalk from "chalk";
5
5
 
6
6
  import { clearApiKey, maskToken, readConfig, resolveApiKey, CONFIG_FILE, decryptApiKey, saveApiKey } from "./config.js";
7
7
  import { brandPath, collectionPath, nuelinkRequest } from "./http.js";
8
- import { buildPostPayload, parseCsv, VALID_PUBLISH_MODES } from "./postPayload.js";
8
+ import { buildPostPayload, parseCsv, validateRawPostPayload, VALID_PUBLISH_MODES } from "./postPayload.js";
9
9
  import {
10
10
  VALID_AUTOMATION_SUB_TYPES,
11
11
  VALID_AUTOMATION_TYPES,
@@ -19,7 +19,7 @@ import {
19
19
  parsePositiveInteger,
20
20
  splitCsv,
21
21
  validateHttpUrl,
22
- validateMediaFile,
22
+ validateMediaFile,
23
23
  validateQueueSlots,
24
24
  } from "./validation.js";
25
25
 
@@ -138,7 +138,7 @@ async function promptHidden(promptText) {
138
138
  });
139
139
  }
140
140
 
141
- async function resolveLoginApiKey(options, fallbackApiKey) {
141
+ async function resolveLoginApiKey(options, fallbackApiKey) {
142
142
  if (options.apiKey || fallbackApiKey) {
143
143
  return String(options.apiKey || fallbackApiKey).trim();
144
144
  }
@@ -148,8 +148,8 @@ async function resolveLoginApiKey(options, fallbackApiKey) {
148
148
  }
149
149
 
150
150
  return promptHidden("API key: ");
151
- }
152
-
151
+ }
152
+
153
153
  function buildRequestOptions(program) {
154
154
  const options = program.opts();
155
155
 
@@ -196,7 +196,7 @@ function registerCommands(program, runtimeApiKey, cliVersion) {
196
196
  .description("Nuelink CLI for the Public API")
197
197
  .option("-a, --api-key <apiKey>", "Use API key for this invocation only")
198
198
  .option("--auth <apiKey>", "Deprecated alias for --api-key")
199
- .option("--dry-run", "Print the validated request without sending it")
199
+ .option("--dry-run", "Print the validated request without sending it")
200
200
  .option("--json", "Output raw JSON instead of tables for list commands")
201
201
  .option("--quiet", "Suppress non-essential success banners");
202
202
 
@@ -314,7 +314,7 @@ function registerCommands(program, runtimeApiKey, cliVersion) {
314
314
  method: "POST",
315
315
  endpoint: `${brandPath(parsePositiveInteger(options.brandId, "brand-id"))}/collections`,
316
316
  body: {
317
- title: validateMaxLength(options.title, 255, "title"),
317
+ title: validateMaxLength(options.title, 255, "title"),
318
318
  description: validateMaxLength(options.description, 1000, "description"),
319
319
  maxRepublish: parseOptionalNonNegativeInteger(options.maxRepublish, "max-republish"),
320
320
  channels,
@@ -328,9 +328,9 @@ function registerCommands(program, runtimeApiKey, cliVersion) {
328
328
  .description("List automations for a brand")
329
329
  .requiredOption("--brand-id <id>", "Brand ID")
330
330
  .option("--per-page <number>", "Items per page", "25")
331
- .option("--page <number>", "Page number", "1")
332
- .action(withCommandErrorHandling(async (options) => {
333
- await executeRequest(program, runtimeApiKey, {
331
+ .option("--page <number>", "Page number", "1")
332
+ .action(withCommandErrorHandling(async (options) => {
333
+ await executeRequest(program, runtimeApiKey, {
334
334
  endpoint: `${brandPath(parsePositiveInteger(options.brandId, "brand-id"))}/automations`,
335
335
  query: {
336
336
  per_page: parseIntegerInRange(options.perPage, "per-page", 1, 100),
@@ -354,28 +354,28 @@ function registerCommands(program, runtimeApiKey, cliVersion) {
354
354
  .option("--description <text>", "Automation description")
355
355
  .option("--load-old-posts <boolean>", "Import existing feed items: true/false")
356
356
  .option("--add-posts-as-draft <boolean>", "Create imported posts as drafts: true/false")
357
- .option("--refresh-rate <hours>", "Refresh interval (24, 12, 6, or 1 hours)")
358
- .action(withCommandErrorHandling(async (options) => {
359
- await executeRequest(program, runtimeApiKey, {
360
- method: "POST",
361
- endpoint: `${brandPath(parsePositiveInteger(options.brandId, "brand-id"))}/automations`,
362
- body: {
363
- collectionId: parsePositiveInteger(options.collectionId, "collection-id"),
364
- feedUrl: validateHttpUrl(options.feedUrl, "feed-url"),
365
- importAsType: normalizeEnum(options.importAsType, "import-as-type", VALID_IMPORT_AS_TYPES),
366
- subType: normalizeEnum(options.subType, "sub-type", VALID_AUTOMATION_SUB_TYPES),
367
- title: validateMaxLength(options.title, 255, "title"),
368
- type: normalizeEnum(options.type, "type", VALID_AUTOMATION_TYPES),
369
- dynamicTitle: validateMaxLength(options.dynamicTitle, 255, "dynamic-title"),
370
- dynamicBody: validateMaxLength(options.dynamicBody, 255, "dynamic-body"),
371
- description: options.description,
372
- loadOldPosts: parseBooleanStrict(options.loadOldPosts, "load-old-posts"),
373
- addPostsAsDraft: parseBooleanStrict(options.addPostsAsDraft, "add-posts-as-draft"),
374
- refreshRate: options.refreshRate === undefined
375
- ? undefined
376
- : Number(normalizeEnum(options.refreshRate, "refresh-rate", ["24", "12", "6", "1"])),
377
- },
378
- });
357
+ .option("--refresh-rate <hours>", "Refresh interval (24, 12, 6, or 1 hours)")
358
+ .action(withCommandErrorHandling(async (options) => {
359
+ await executeRequest(program, runtimeApiKey, {
360
+ method: "POST",
361
+ endpoint: `${brandPath(parsePositiveInteger(options.brandId, "brand-id"))}/automations`,
362
+ body: {
363
+ collectionId: parsePositiveInteger(options.collectionId, "collection-id"),
364
+ feedUrl: validateHttpUrl(options.feedUrl, "feed-url"),
365
+ importAsType: normalizeEnum(options.importAsType, "import-as-type", VALID_IMPORT_AS_TYPES),
366
+ subType: normalizeEnum(options.subType, "sub-type", VALID_AUTOMATION_SUB_TYPES),
367
+ title: validateMaxLength(options.title, 255, "title"),
368
+ type: normalizeEnum(options.type, "type", VALID_AUTOMATION_TYPES),
369
+ dynamicTitle: validateMaxLength(options.dynamicTitle, 255, "dynamic-title"),
370
+ dynamicBody: validateMaxLength(options.dynamicBody, 255, "dynamic-body"),
371
+ description: options.description,
372
+ loadOldPosts: parseBooleanStrict(options.loadOldPosts, "load-old-posts"),
373
+ addPostsAsDraft: parseBooleanStrict(options.addPostsAsDraft, "add-posts-as-draft"),
374
+ refreshRate: options.refreshRate === undefined
375
+ ? undefined
376
+ : Number(normalizeEnum(options.refreshRate, "refresh-rate", ["24", "12", "6", "1"])),
377
+ },
378
+ });
379
379
  }));
380
380
 
381
381
  program
@@ -419,19 +419,19 @@ function registerCommands(program, runtimeApiKey, cliVersion) {
419
419
  .description("Upload a media file")
420
420
  .requiredOption("--brand-id <id>", "Brand ID")
421
421
  .requiredOption("--file <path>", "Path to local file")
422
- .action(withCommandErrorHandling(async (options) => {
423
- const brandId = parsePositiveInteger(options.brandId, "brand-id");
424
- const fileStat = await stat(options.file);
425
- const { mediaType, size } = validateMediaFile(options.file, fileStat);
426
- const formData = new FormData();
427
- const fileBuffer = await readFile(options.file);
428
- const fileBlob = new Blob([fileBuffer], { type: mediaType });
429
- formData.append("media", fileBlob, path.basename(options.file));
422
+ .action(withCommandErrorHandling(async (options) => {
423
+ const brandId = parsePositiveInteger(options.brandId, "brand-id");
424
+ const fileStat = await stat(options.file);
425
+ const { mediaType, size } = validateMediaFile(options.file, fileStat);
426
+ const formData = new FormData();
427
+ const fileBuffer = await readFile(options.file);
428
+ const fileBlob = new Blob([fileBuffer], { type: mediaType });
429
+ formData.append("media", fileBlob, path.basename(options.file));
430
430
 
431
431
  await executeRequest(program, runtimeApiKey, {
432
432
  method: "POST",
433
433
  endpoint: `${brandPath(brandId)}/media`,
434
- multipart: formData,
434
+ multipart: formData,
435
435
  dryRunBody: {
436
436
  file: path.basename(options.file),
437
437
  size,
@@ -470,7 +470,7 @@ function registerCommands(program, runtimeApiKey, cliVersion) {
470
470
  const payloadText = options.payload === "-"
471
471
  ? await readStdinText()
472
472
  : await readFile(options.payload, "utf8");
473
- const payload = parseJsonString(payloadText, "payload");
473
+ const payload = validateRawPostPayload(parseJsonString(payloadText, "payload"));
474
474
 
475
475
  await executeRequest(program, runtimeApiKey, {
476
476
  method: "POST",
@@ -516,7 +516,7 @@ function registerCommands(program, runtimeApiKey, cliVersion) {
516
516
  .option("--youtube-playlists <json>", "YouTube playlists JSON string")
517
517
  .option("--googlemybusiness-upload-to-photos-section <boolean>", "Upload to Google Business Profile photos: true/false")
518
518
  .action(withCommandErrorHandling(async (options) => {
519
- const payload = buildPostPayload(options);
519
+ const payload = buildPostPayload(options);
520
520
 
521
521
  await executeRequest(program, runtimeApiKey, {
522
522
  method: "POST",
package/src/http.js CHANGED
@@ -37,23 +37,24 @@ function shouldRetryRequest(method, statusCode, attempt) {
37
37
  return method === "GET" && attempt < MAX_GET_RETRIES && (statusCode === 429 || statusCode >= 500);
38
38
  }
39
39
 
40
- function parseRetryAfterMs(headers, attempt) {
40
+ function parseRetryAfterMs(headers, attempt) {
41
41
  const retryAfter = headers.get("retry-after");
42
42
 
43
43
  if (retryAfter) {
44
44
  const seconds = Number(retryAfter);
45
45
 
46
46
  if (!Number.isNaN(seconds)) {
47
- return Math.min(Math.max(seconds * 1000, 0), RETRY_MAX_DELAY_MS);
47
+ return Math.max(seconds * 1000, 0);
48
48
  }
49
49
 
50
50
  const dateDelay = Date.parse(retryAfter) - Date.now();
51
51
  if (!Number.isNaN(dateDelay)) {
52
- return Math.min(Math.max(dateDelay, 0), RETRY_MAX_DELAY_MS);
52
+ return Math.max(dateDelay, 0);
53
53
  }
54
54
  }
55
55
 
56
- return Math.min(RETRY_BASE_DELAY_MS * (attempt + 1), RETRY_MAX_DELAY_MS);
56
+ const exponentialDelay = Math.min(RETRY_BASE_DELAY_MS * (2 ** attempt), RETRY_MAX_DELAY_MS);
57
+ return Math.floor(Math.random() * (exponentialDelay + 1));
57
58
  }
58
59
 
59
60
  async function sleep(ms) {
@@ -137,8 +138,11 @@ async function nuelinkRequest({ apiKey, method = "GET", endpoint, query, body, m
137
138
  if (text) {
138
139
  try {
139
140
  data = JSON.parse(text);
140
- } catch {
141
- data = { raw: text };
141
+ } catch {
142
+ if (response.ok) {
143
+ throw new Error(`Protocol error: expected a JSON response (HTTP ${response.status}).`);
144
+ }
145
+ data = { raw: text };
142
146
  }
143
147
  }
144
148
 
@@ -55,7 +55,7 @@ function mergeMedia(idsCsv, urlsCsv) {
55
55
  return [...idMedia, ...urlMedia];
56
56
  }
57
57
 
58
- function normalizePublishMode(value) {
58
+ function normalizePublishMode(value) {
59
59
  const normalized = String(value ?? "").trim().toUpperCase();
60
60
 
61
61
  if (!VALID_PUBLISH_MODES.includes(normalized)) {
@@ -63,7 +63,69 @@ function normalizePublishMode(value) {
63
63
  }
64
64
 
65
65
  return normalized;
66
- }
66
+ }
67
+
68
+ function validateRawPostPayload(payload) {
69
+ if (!payload || typeof payload !== "object" || Array.isArray(payload)) {
70
+ throw new Error("Invalid payload. Expected a JSON object.");
71
+ }
72
+
73
+ const publishMode = normalizePublishMode(payload.publishMode);
74
+ const scheduledAt = validateScheduledAt(payload.scheduledAt);
75
+ if (publishMode === "SCHEDULE" && !scheduledAt) {
76
+ throw new Error("scheduledAt is required when publishMode is SCHEDULE.");
77
+ }
78
+
79
+ validateOptionalLength(payload.title, 255, "title");
80
+ validateOptionalLength(payload.caption, 3000, "caption");
81
+ validateOptionalLength(payload.alt, 255, "alt");
82
+ if (payload.link !== undefined) {
83
+ validateHttpUrl(payload.link, "link");
84
+ }
85
+
86
+ const poll = payload.poll;
87
+ if (!poll && (!payload.caption || !String(payload.caption).trim())) {
88
+ throw new Error("caption is required when poll is not provided.");
89
+ }
90
+ if (poll !== undefined) {
91
+ if (!poll || typeof poll !== "object" || Array.isArray(poll)) {
92
+ throw new Error("Invalid poll. Expected a JSON object.");
93
+ }
94
+ const options = Array.isArray(poll.options) ? poll.options : [];
95
+ validatePollOptions(options, poll.correctOptionIndex);
96
+ if (!poll.question || options.length < 2 || options.length > 4 || !VALID_POLL_PERIODS.includes(poll.period)) {
97
+ throw new Error("poll requires question, 2 to 4 options, and period (1d, 3d, or 7d).");
98
+ }
99
+ validateOptionalLength(poll.question, 280, "poll-question");
100
+ validateOptionalLength(poll.explanation, 512, "poll-explanation");
101
+ options.forEach((option) => validateOptionalLength(option, 30, "poll-option"));
102
+ }
103
+
104
+ if (payload.media !== undefined) {
105
+ if (!Array.isArray(payload.media)) {
106
+ throw new Error("Invalid media. Expected an array.");
107
+ }
108
+ payload.media.forEach((item, index) => {
109
+ if (!item || typeof item !== "object" || Array.isArray(item)) {
110
+ throw new Error(`Invalid media item at index ${index}.`);
111
+ }
112
+ const hasId = typeof item.id === "string" && item.id.trim().length > 0;
113
+ const hasUrl = typeof item.url === "string" && item.url.trim().length > 0;
114
+ if (hasId === hasUrl) {
115
+ throw new Error(`Invalid media item at index ${index}. Expected exactly one of id or url.`);
116
+ }
117
+ if (hasUrl) {
118
+ validateHttpUrl(item.url, `media[${index}].url`);
119
+ }
120
+ });
121
+ }
122
+
123
+ return {
124
+ ...payload,
125
+ publishMode,
126
+ ...(payload.scheduledAt !== undefined ? { scheduledAt } : {}),
127
+ };
128
+ }
67
129
 
68
130
  function buildPostPayload(options) {
69
131
  const media = mergeMedia(options.mediaIds, options.mediaUrls);
@@ -241,6 +303,7 @@ export {
241
303
  mergeMedia,
242
304
  parseBoolean,
243
305
  parseCsv,
244
- parseNumber,
245
- VALID_PUBLISH_MODES,
246
- };
306
+ parseNumber,
307
+ validateRawPostPayload,
308
+ VALID_PUBLISH_MODES,
309
+ };
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) (?:[01][0-9]|2[0-3]):[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;
@@ -151,7 +151,7 @@ function validateHttpUrl(value, label) {
151
151
  return parsedUrl.toString();
152
152
  }
153
153
 
154
- function validateQueueSlots(queueSlots) {
154
+ function validateQueueSlots(queueSlots) {
155
155
  queueSlots.forEach((slot) => {
156
156
  if (!QUEUE_SLOT_PATTERN.test(slot)) {
157
157
  throw new Error(`Invalid queue slot \"${slot}\". Expected values like Mon 10:10.`);
@@ -159,8 +159,8 @@ function validateQueueSlots(queueSlots) {
159
159
  });
160
160
 
161
161
  return queueSlots;
162
- }
163
-
162
+ }
163
+
164
164
  function validateScheduledAt(value) {
165
165
  if (value === undefined || value === null || value === "" || value === "null") {
166
166
  return null;
@@ -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,21 +236,21 @@ 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,
235
- validateMediaFile,
251
+ validateMediaFile,
236
252
  validatePollOptions,
237
253
  validateScheduledAt,
238
254
  validateQueueSlots,
239
255
  normalizeEnum,
240
- };
256
+ };