n8n-nodes-steyi-ss 1.0.1 → 1.0.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.
@@ -163,14 +163,6 @@ async function executeRowOperation(operation, itemIndex) {
163
163
  catch (error) {
164
164
  // If we can't get columns, continue without column type info
165
165
  }
166
- // Helper function to check if a string looks like comma-separated emails
167
- const looksLikeEmailList = (str) => {
168
- if (typeof str !== 'string')
169
- return false;
170
- const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
171
- const parts = str.split(',').map(p => p.trim());
172
- return parts.length > 1 && parts.every(part => emailRegex.test(part));
173
- };
174
166
  const cells = (cellsData.cell || []).map((cell) => {
175
167
  let columnId;
176
168
  if (cell.columnInputMethod === 'id') {
@@ -193,129 +185,33 @@ async function executeRowOperation(operation, itemIndex) {
193
185
  }
194
186
  }
195
187
  // Handle MULTI_CONTACT_LIST and MULTI_PICKLIST columns with objectValue
196
- // Also handle if value looks like comma-separated emails (fallback for when column type isn't detected)
197
- if (columnType === 'MULTI_CONTACT_LIST' || columnType === 'MULTI_PICKLIST' ||
198
- (columnType === undefined && typeof cellValue === 'string' && looksLikeEmailList(cellValue))) {
199
- // Try to parse the value as JSON if it's a string
200
- let parsedValue;
188
+ // User must provide a JSON block that will be used directly
189
+ if (columnType === 'MULTI_CONTACT_LIST' || columnType === 'MULTI_PICKLIST') {
190
+ // Parse the value as JSON
191
+ let objectValue;
201
192
  try {
202
193
  if (typeof cellValue === 'string') {
203
- parsedValue = JSON.parse(cellValue);
194
+ objectValue = JSON.parse(cellValue);
204
195
  }
205
196
  else {
206
- parsedValue = cellValue;
197
+ objectValue = cellValue;
207
198
  }
208
199
  }
209
200
  catch (error) {
210
- // If parsing fails, treat as regular value (comma-separated string)
211
- parsedValue = cellValue;
212
- }
213
- // If it's already in the correct MULTI_CONTACT format, use it directly
214
- if (parsedValue && typeof parsedValue === 'object' && parsedValue.objectType === 'MULTI_CONTACT' && parsedValue.values) {
215
- return {
216
- columnId: colIdNum,
217
- objectValue: parsedValue,
218
- strict: false,
219
- };
201
+ throw new Error(`Invalid JSON for ${columnType} column (Column ID: ${colIdNum}). ` +
202
+ `Please provide a valid JSON object. Error: ${error instanceof Error ? error.message : String(error)}`);
220
203
  }
221
- // If it's an array of contacts (old format), wrap it in MULTI_CONTACT structure
222
- if (parsedValue && Array.isArray(parsedValue) && parsedValue.length > 0) {
223
- return {
224
- columnId: colIdNum,
225
- objectValue: {
226
- objectType: 'MULTI_CONTACT',
227
- values: parsedValue.map((contact) => {
228
- if (typeof contact === 'string') {
229
- return { email: contact.trim() };
230
- }
231
- if (contact.objectType === 'CONTACT') {
232
- // Remove objectType from contact objects
233
- const contactObj = { email: contact.email || contact };
234
- if (contact.name && contact.name !== contact.email) {
235
- contactObj.name = contact.name;
236
- }
237
- return contactObj;
238
- }
239
- return contact;
240
- }),
241
- },
242
- strict: false,
243
- };
244
- }
245
- // Otherwise, format it properly based on column type
246
- // If columnType is undefined but value looks like emails, treat as MULTI_CONTACT_LIST
247
- if (columnType === 'MULTI_CONTACT_LIST' ||
248
- (columnType === undefined && typeof cellValue === 'string' && looksLikeEmailList(cellValue))) {
249
- // Format for MULTI_CONTACT_LIST
250
- let contacts = [];
251
- if (Array.isArray(parsedValue)) {
252
- contacts = parsedValue;
253
- }
254
- else if (typeof parsedValue === 'string') {
255
- // Try to parse as JSON array first
256
- try {
257
- contacts = JSON.parse(parsedValue);
258
- }
259
- catch {
260
- // If JSON parsing fails, check if it's comma-separated
261
- if (parsedValue.includes(',')) {
262
- // Split by comma and trim each email
263
- contacts = parsedValue.split(',').map((email) => email.trim());
264
- }
265
- else {
266
- // If it's a single email, wrap it
267
- contacts = [parsedValue.trim()];
268
- }
269
- }
270
- }
271
- // For MULTI_CONTACT_LIST, objectValue should be an object with objectType and values array
272
- return {
273
- columnId: colIdNum,
274
- objectValue: {
275
- objectType: 'MULTI_CONTACT',
276
- values: contacts.map((contact) => {
277
- if (typeof contact === 'string') {
278
- // For comma-separated emails, return only email field
279
- return {
280
- email: contact.trim(),
281
- };
282
- }
283
- // For object format, include email and optionally name
284
- const contactObj = {
285
- email: contact.email || contact,
286
- };
287
- // Only include name if it's different from email
288
- if (contact.name && contact.name !== contact.email) {
289
- contactObj.name = contact.name;
290
- }
291
- return contactObj;
292
- }),
293
- },
294
- strict: false,
295
- };
296
- }
297
- else if (columnType === 'MULTI_PICKLIST') {
298
- // Format for MULTI_PICKLIST
299
- let options = [];
300
- if (Array.isArray(parsedValue)) {
301
- options = parsedValue;
302
- }
303
- else if (typeof parsedValue === 'string') {
304
- try {
305
- options = JSON.parse(parsedValue);
306
- }
307
- catch {
308
- options = parsedValue.split(',').map((s) => s.trim());
309
- }
310
- }
311
- return {
312
- columnId: colIdNum,
313
- objectValue: {
314
- objectType: 'MULTI_PICKLIST',
315
- values: options,
316
- },
317
- };
204
+ // Validate that it's an object
205
+ if (typeof objectValue !== 'object' || objectValue === null) {
206
+ throw new Error(`Invalid objectValue for ${columnType} column (Column ID: ${colIdNum}). ` +
207
+ `Expected a JSON object, got ${typeof objectValue}.`);
318
208
  }
209
+ // Use the parsed JSON directly as objectValue
210
+ return {
211
+ columnId: colIdNum,
212
+ objectValue: objectValue,
213
+ strict: false,
214
+ };
319
215
  }
320
216
  // For regular columns, use value (use cleaned cellValue)
321
217
  return {
@@ -575,14 +471,6 @@ async function executeRowOperation(operation, itemIndex) {
575
471
  catch (error) {
576
472
  // If we can't get columns, continue without column type info
577
473
  }
578
- // Helper function to check if a string looks like comma-separated emails
579
- const looksLikeEmailList = (str) => {
580
- if (typeof str !== 'string')
581
- return false;
582
- const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
583
- const parts = str.split(',').map(p => p.trim());
584
- return parts.length > 1 && parts.every(part => emailRegex.test(part));
585
- };
586
474
  const cells = (cellsData.cell || []).map((cell) => {
587
475
  let columnId;
588
476
  if (cell.columnInputMethod === 'id') {
@@ -605,129 +493,33 @@ async function executeRowOperation(operation, itemIndex) {
605
493
  }
606
494
  }
607
495
  // Handle MULTI_CONTACT_LIST and MULTI_PICKLIST columns with objectValue
608
- // Also handle if value looks like comma-separated emails (fallback for when column type isn't detected)
609
- if (columnType === 'MULTI_CONTACT_LIST' || columnType === 'MULTI_PICKLIST' ||
610
- (columnType === undefined && typeof cellValue === 'string' && looksLikeEmailList(cellValue))) {
611
- // Try to parse the value as JSON if it's a string
612
- let parsedValue;
496
+ // User must provide a JSON block that will be used directly
497
+ if (columnType === 'MULTI_CONTACT_LIST' || columnType === 'MULTI_PICKLIST') {
498
+ // Parse the value as JSON
499
+ let objectValue;
613
500
  try {
614
501
  if (typeof cellValue === 'string') {
615
- parsedValue = JSON.parse(cellValue);
502
+ objectValue = JSON.parse(cellValue);
616
503
  }
617
504
  else {
618
- parsedValue = cellValue;
505
+ objectValue = cellValue;
619
506
  }
620
507
  }
621
508
  catch (error) {
622
- // If parsing fails, treat as regular value (comma-separated string)
623
- parsedValue = cellValue;
624
- }
625
- // If it's already in the correct MULTI_CONTACT format, use it directly
626
- if (parsedValue && typeof parsedValue === 'object' && parsedValue.objectType === 'MULTI_CONTACT' && parsedValue.values) {
627
- return {
628
- columnId: colIdNum,
629
- objectValue: parsedValue,
630
- strict: false,
631
- };
509
+ throw new Error(`Invalid JSON for ${columnType} column (Column ID: ${colIdNum}). ` +
510
+ `Please provide a valid JSON object. Error: ${error instanceof Error ? error.message : String(error)}`);
632
511
  }
633
- // If it's an array of contacts (old format), wrap it in MULTI_CONTACT structure
634
- if (parsedValue && Array.isArray(parsedValue) && parsedValue.length > 0) {
635
- return {
636
- columnId: colIdNum,
637
- objectValue: {
638
- objectType: 'MULTI_CONTACT',
639
- values: parsedValue.map((contact) => {
640
- if (typeof contact === 'string') {
641
- return { email: contact.trim() };
642
- }
643
- if (contact.objectType === 'CONTACT') {
644
- // Remove objectType from contact objects
645
- const contactObj = { email: contact.email || contact };
646
- if (contact.name && contact.name !== contact.email) {
647
- contactObj.name = contact.name;
648
- }
649
- return contactObj;
650
- }
651
- return contact;
652
- }),
653
- },
654
- strict: false,
655
- };
656
- }
657
- // Otherwise, format it properly based on column type
658
- // If columnType is undefined but value looks like emails, treat as MULTI_CONTACT_LIST
659
- if (columnType === 'MULTI_CONTACT_LIST' ||
660
- (columnType === undefined && typeof cellValue === 'string' && looksLikeEmailList(cellValue))) {
661
- // Format for MULTI_CONTACT_LIST
662
- let contacts = [];
663
- if (Array.isArray(parsedValue)) {
664
- contacts = parsedValue;
665
- }
666
- else if (typeof parsedValue === 'string') {
667
- // Try to parse as JSON array first
668
- try {
669
- contacts = JSON.parse(parsedValue);
670
- }
671
- catch {
672
- // If JSON parsing fails, check if it's comma-separated
673
- if (parsedValue.includes(',')) {
674
- // Split by comma and trim each email
675
- contacts = parsedValue.split(',').map((email) => email.trim());
676
- }
677
- else {
678
- // If it's a single email, wrap it
679
- contacts = [parsedValue.trim()];
680
- }
681
- }
682
- }
683
- // For MULTI_CONTACT_LIST, objectValue should be an object with objectType and values array
684
- return {
685
- columnId: colIdNum,
686
- objectValue: {
687
- objectType: 'MULTI_CONTACT',
688
- values: contacts.map((contact) => {
689
- if (typeof contact === 'string') {
690
- // For comma-separated emails, return only email field
691
- return {
692
- email: contact.trim(),
693
- };
694
- }
695
- // For object format, include email and optionally name
696
- const contactObj = {
697
- email: contact.email || contact,
698
- };
699
- // Only include name if it's different from email
700
- if (contact.name && contact.name !== contact.email) {
701
- contactObj.name = contact.name;
702
- }
703
- return contactObj;
704
- }),
705
- },
706
- strict: false,
707
- };
708
- }
709
- else if (columnType === 'MULTI_PICKLIST') {
710
- // Format for MULTI_PICKLIST
711
- let options = [];
712
- if (Array.isArray(parsedValue)) {
713
- options = parsedValue;
714
- }
715
- else if (typeof parsedValue === 'string') {
716
- try {
717
- options = JSON.parse(parsedValue);
718
- }
719
- catch {
720
- options = parsedValue.split(',').map((s) => s.trim());
721
- }
722
- }
723
- return {
724
- columnId: colIdNum,
725
- objectValue: {
726
- objectType: 'MULTI_PICKLIST',
727
- values: options,
728
- },
729
- };
512
+ // Validate that it's an object
513
+ if (typeof objectValue !== 'object' || objectValue === null) {
514
+ throw new Error(`Invalid objectValue for ${columnType} column (Column ID: ${colIdNum}). ` +
515
+ `Expected a JSON object, got ${typeof objectValue}.`);
730
516
  }
517
+ // Use the parsed JSON directly as objectValue
518
+ return {
519
+ columnId: colIdNum,
520
+ objectValue: objectValue,
521
+ strict: false,
522
+ };
731
523
  }
732
524
  // For regular columns, use value (use cleaned cellValue)
733
525
  return {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "n8n-nodes-steyi-ss",
3
- "version": "1.0.1",
3
+ "version": "1.0.2",
4
4
  "description": "n8n node for Smartsheet API integration",
5
5
  "keywords": [
6
6
  "n8n-node-package",