@amplifyup/sdk 0.1.62 → 0.1.63

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/dist/index.js CHANGED
@@ -421,6 +421,21 @@ function isPortableImageShape(value) {
421
421
  if (!value || typeof value !== "object" || Array.isArray(value)) return false;
422
422
  return "url" in value;
423
423
  }
424
+ function isEntryRefItem(value) {
425
+ if (!value || typeof value !== "object" || Array.isArray(value)) return false;
426
+ const rec = value;
427
+ return typeof rec.id === "string" && rec.id.trim().length > 0 || typeof rec._id === "string" && rec._id.trim().length > 0 || typeof rec.docId === "string" && rec.docId.trim().length > 0;
428
+ }
429
+ function isRepeaterArray(value) {
430
+ if (!Array.isArray(value) || value.length === 0) return false;
431
+ const sample = value.find((item) => item != null);
432
+ if (sample === void 0) return false;
433
+ if (typeof sample !== "object" || Array.isArray(sample)) return false;
434
+ if (isPortableImageShape(sample)) return false;
435
+ if (isEntryRefItem(sample)) return false;
436
+ if (sample.$$typeof) return false;
437
+ return true;
438
+ }
424
439
  function joinPath(prefix, key) {
425
440
  return prefix ? `${prefix}.${key}` : key;
426
441
  }
@@ -437,9 +452,21 @@ function toFieldEnvelopes(source, prefix = "") {
437
452
  for (const [key, raw] of Object.entries(input)) {
438
453
  const path = joinPath(prefix, key);
439
454
  if (isFieldEnvelope(raw)) {
455
+ const inner = raw.value;
456
+ if (isRepeaterArray(inner)) {
457
+ out[key] = {
458
+ value: envelopeRepeaterItems(inner, raw.name || path),
459
+ name: raw.name || path
460
+ };
461
+ continue;
462
+ }
440
463
  out[key] = { value: raw.value ?? null, name: raw.name || path };
441
464
  continue;
442
465
  }
466
+ if (isRepeaterArray(raw)) {
467
+ out[key] = { value: envelopeRepeaterItems(raw, path), name: path };
468
+ continue;
469
+ }
443
470
  if (raw && typeof raw === "object" && !Array.isArray(raw) && !isPortableImageShape(raw) && !raw.$$typeof) {
444
471
  out[key] = toFieldEnvelopes(raw, path);
445
472
  continue;
@@ -448,6 +475,16 @@ function toFieldEnvelopes(source, prefix = "") {
448
475
  }
449
476
  return brandFields(out);
450
477
  }
478
+ function envelopeRepeaterItems(items, prefix) {
479
+ return items.map((item, i) => {
480
+ const path = joinPath(prefix, String(i));
481
+ if (isBrandedFields(item)) return item;
482
+ if (item && typeof item === "object" && !Array.isArray(item)) {
483
+ return toFieldEnvelopes(item, path);
484
+ }
485
+ return toFieldEnvelopes({}, path);
486
+ });
487
+ }
451
488
  function attachFieldEnvelopes(props) {
452
489
  const raw = props && typeof props === "object" ? { ...props } : {};
453
490
  if (isBrandedFields(raw.fields)) return raw;