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