osury 0.8.0 → 0.9.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/package.json +1 -1
- package/src/Codegen.res.mjs +4 -22
package/package.json
CHANGED
package/src/Codegen.res.mjs
CHANGED
|
@@ -241,16 +241,6 @@ function hasUnion(_schema) {
|
|
|
241
241
|
};
|
|
242
242
|
}
|
|
243
243
|
|
|
244
|
-
function isRefOnlyUnion(types) {
|
|
245
|
-
return types.every(t => {
|
|
246
|
-
if (typeof t !== "object") {
|
|
247
|
-
return false;
|
|
248
|
-
} else {
|
|
249
|
-
return t._tag === "Ref";
|
|
250
|
-
}
|
|
251
|
-
});
|
|
252
|
-
}
|
|
253
|
-
|
|
254
244
|
function isPrimitiveOnlyUnion(types) {
|
|
255
245
|
return types.every(t => {
|
|
256
246
|
if (typeof t === "object") {
|
|
@@ -577,26 +567,19 @@ function generateTypeDefWithSkipSet(namedSchema, _skipSet, schemasDict, tagsDict
|
|
|
577
567
|
let types = namedSchema.schema;
|
|
578
568
|
if (typeof types === "object" && types._tag === "Union") {
|
|
579
569
|
let types$1 = types._0;
|
|
580
|
-
if (isRefOnlyUnion(types$1)) {
|
|
581
|
-
let variantBody = generateInlineVariantBody(types$1, schemasDict, tagsDict);
|
|
582
|
-
return `@genType
|
|
583
|
-
@tag("_tag")
|
|
584
|
-
@schema
|
|
585
|
-
type ` + typeName + ` = ` + variantBody;
|
|
586
|
-
}
|
|
587
570
|
if (isPrimitiveOnlyUnion(types$1)) {
|
|
588
|
-
let variantBody
|
|
571
|
+
let variantBody = generateVariantBody(types$1);
|
|
589
572
|
return `@genType
|
|
590
573
|
@tag("_tag")
|
|
591
574
|
@unboxed
|
|
592
575
|
@schema
|
|
593
|
-
type ` + typeName + ` = ` + variantBody
|
|
576
|
+
type ` + typeName + ` = ` + variantBody;
|
|
594
577
|
}
|
|
595
|
-
let variantBody$
|
|
578
|
+
let variantBody$1 = generateInlineVariantBody(types$1, schemasDict, tagsDict);
|
|
596
579
|
return `@genType
|
|
597
580
|
@tag("_tag")
|
|
598
581
|
@schema
|
|
599
|
-
type ` + typeName + ` = ` + variantBody$
|
|
582
|
+
type ` + typeName + ` = ` + variantBody$1;
|
|
600
583
|
}
|
|
601
584
|
let typeBody = generateType(namedSchema.schema);
|
|
602
585
|
return `@genType
|
|
@@ -677,7 +660,6 @@ export {
|
|
|
677
660
|
getTagForType,
|
|
678
661
|
generateUnion,
|
|
679
662
|
hasUnion,
|
|
680
|
-
isRefOnlyUnion,
|
|
681
663
|
isPrimitiveOnlyUnion,
|
|
682
664
|
generateInlineRecord,
|
|
683
665
|
generateInlineVariantBody,
|