@marktiderman/genesis-forms 0.5.0 → 0.6.0
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/README.md +128 -0
- package/dist/destinations.cjs +55 -3
- package/dist/destinations.cjs.map +1 -1
- package/dist/destinations.d.cts +1 -1
- package/dist/destinations.d.ts +1 -1
- package/dist/destinations.js +55 -3
- package/dist/destinations.js.map +1 -1
- package/dist/{engine-BDq0XJ21.d.cts → engine-CpfOz8FN.d.ts} +10 -3
- package/dist/{engine-Qzp6bX6O.d.ts → engine-DC4YTPdr.d.cts} +10 -3
- package/dist/index.cjs +484 -62
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +29 -7
- package/dist/index.d.ts +29 -7
- package/dist/index.js +461 -63
- package/dist/index.js.map +1 -1
- package/dist/server.cjs +541 -21
- package/dist/server.cjs.map +1 -1
- package/dist/server.d.cts +193 -3
- package/dist/server.d.ts +193 -3
- package/dist/server.js +522 -22
- package/dist/server.js.map +1 -1
- package/dist/testing.cjs +314 -21
- package/dist/testing.cjs.map +1 -1
- package/dist/testing.d.cts +4 -4
- package/dist/testing.d.ts +4 -4
- package/dist/testing.js +314 -21
- package/dist/testing.js.map +1 -1
- package/dist/{types-BhYUbLJ-.d.cts → types-oAckGR_Z.d.cts} +10 -0
- package/dist/{types-BhYUbLJ-.d.ts → types-oAckGR_Z.d.ts} +10 -0
- package/dist/validate-B5WKHbst.d.cts +322 -0
- package/dist/validate-GpTXPwyl.d.ts +322 -0
- package/package.json +1 -1
- package/dist/validate-Bs1lyoOl.d.ts +0 -131
- package/dist/validate-BsZ0YTQS.d.cts +0 -131
package/dist/destinations.d.cts
CHANGED
package/dist/destinations.d.ts
CHANGED
package/dist/destinations.js
CHANGED
|
@@ -434,6 +434,57 @@ function summarizeValue(value, field) {
|
|
|
434
434
|
if (Array.isArray(value)) return value.join(", ");
|
|
435
435
|
return String(value);
|
|
436
436
|
}
|
|
437
|
+
var OPTION_LIMITS = {
|
|
438
|
+
/** Characters in a description. */
|
|
439
|
+
description: 500,
|
|
440
|
+
/** Characters in an image URL. */
|
|
441
|
+
image: 2048,
|
|
442
|
+
/** Attributes on one option. */
|
|
443
|
+
attributes: 20,
|
|
444
|
+
/** Characters in an attribute's name. */
|
|
445
|
+
attributeName: 64,
|
|
446
|
+
/** Characters in one attribute value. */
|
|
447
|
+
attributeValue: 200,
|
|
448
|
+
/** Values in one attribute's list. */
|
|
449
|
+
attributeItems: 50
|
|
450
|
+
};
|
|
451
|
+
function isHttpsUrl(url) {
|
|
452
|
+
return typeof url === "string" && url.length <= OPTION_LIMITS.image && /^https:\/\/[^\s/?#@\\]+(?:[/?#][^\s]*)?$/i.test(url) && // No control characters anywhere (a line break would end a CSV row or an HTML attribute).
|
|
453
|
+
![...url].some((c) => c.charCodeAt(0) < 32 || c.charCodeAt(0) === 127);
|
|
454
|
+
}
|
|
455
|
+
function attributeName(name) {
|
|
456
|
+
return name.trim() !== "" && name.length <= OPTION_LIMITS.attributeName && !(name in Object.prototype);
|
|
457
|
+
}
|
|
458
|
+
function readAttributes(raw) {
|
|
459
|
+
if (!raw || typeof raw !== "object" || Array.isArray(raw)) return void 0;
|
|
460
|
+
const out = {};
|
|
461
|
+
let count = 0;
|
|
462
|
+
for (const name of Object.keys(raw)) {
|
|
463
|
+
if (count >= OPTION_LIMITS.attributes) break;
|
|
464
|
+
if (!attributeName(name)) continue;
|
|
465
|
+
const v = raw[name];
|
|
466
|
+
const fits = (x) => typeof x === "string" && x.length <= OPTION_LIMITS.attributeValue;
|
|
467
|
+
if (fits(v)) out[name] = v;
|
|
468
|
+
else if (Array.isArray(v) && v.length <= OPTION_LIMITS.attributeItems && v.every(fits)) out[name] = [...v];
|
|
469
|
+
else continue;
|
|
470
|
+
count++;
|
|
471
|
+
}
|
|
472
|
+
return count ? out : void 0;
|
|
473
|
+
}
|
|
474
|
+
function readOption(raw) {
|
|
475
|
+
if (!raw || typeof raw !== "object" || Array.isArray(raw)) return null;
|
|
476
|
+
const o = raw;
|
|
477
|
+
if (typeof o.value !== "string") return null;
|
|
478
|
+
const out = { value: o.value };
|
|
479
|
+
if (typeof o.label === "string") out.label = o.label;
|
|
480
|
+
if (typeof o.description === "string" && o.description.trim() && o.description.length <= OPTION_LIMITS.description) {
|
|
481
|
+
out.description = o.description;
|
|
482
|
+
}
|
|
483
|
+
if (isHttpsUrl(o.image)) out.image = o.image;
|
|
484
|
+
const attributes = readAttributes(o.attributes);
|
|
485
|
+
if (attributes) out.attributes = attributes;
|
|
486
|
+
return out;
|
|
487
|
+
}
|
|
437
488
|
var OTHER_MAX_LENGTH = 200;
|
|
438
489
|
function otherOption(field) {
|
|
439
490
|
const other = field.props?.other;
|
|
@@ -451,9 +502,10 @@ var typedOther = (field, value) => isOtherValue(field, value) && value.trim() !=
|
|
|
451
502
|
function choiceOptions(field) {
|
|
452
503
|
const raw = field.props?.options;
|
|
453
504
|
if (!Array.isArray(raw)) return [];
|
|
454
|
-
return raw.flatMap(
|
|
455
|
-
|
|
456
|
-
|
|
505
|
+
return raw.flatMap((o) => {
|
|
506
|
+
const option = readOption(o);
|
|
507
|
+
return option ? [option] : [];
|
|
508
|
+
});
|
|
457
509
|
}
|
|
458
510
|
function optionLabel(field, value) {
|
|
459
511
|
const option = choiceOptions(field).find((o) => o.value === value);
|