@dialecte/cli 0.0.3 → 0.1.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/dist/cli.js +12 -1
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -610,9 +610,20 @@ function refsOf(b) {
|
|
|
610
610
|
}
|
|
611
611
|
var attrValue = (d) => {
|
|
612
612
|
if (d?.fixed) return d.fixed;
|
|
613
|
-
const enums = d?.
|
|
613
|
+
const enums = enumerated(d?.type)?.filter((v) => v !== "");
|
|
614
614
|
return enums?.length ? enums[0] : "x";
|
|
615
615
|
};
|
|
616
|
+
function enumerated(datatype) {
|
|
617
|
+
if (datatype === void 0 || holdsQualifiedNames(datatype)) return void 0;
|
|
618
|
+
if (datatype.facets?.enumeration !== void 0) return datatype.facets.enumeration;
|
|
619
|
+
const members = (datatype.union ?? []).flatMap((member) => enumerated(member) ?? []);
|
|
620
|
+
return members.length > 0 ? [...new Set(members)] : void 0;
|
|
621
|
+
}
|
|
622
|
+
function holdsQualifiedNames(datatype) {
|
|
623
|
+
if (datatype.builtin === "QName" || datatype.builtin === "NOTATION") return true;
|
|
624
|
+
if (datatype.list !== void 0) return holdsQualifiedNames(datatype.list);
|
|
625
|
+
return (datatype.union ?? []).some(holdsQualifiedNames);
|
|
626
|
+
}
|
|
616
627
|
function genSurface(b) {
|
|
617
628
|
const r = refsOf(b);
|
|
618
629
|
const lines = [
|