@workos/oagen-emitters 0.7.1 → 0.7.2
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/.release-please-manifest.json +1 -1
- package/CHANGELOG.md +7 -0
- package/dist/index.mjs +1 -1
- package/dist/{plugin-h8Onp2Ma.mjs → plugin-CGPujyaL.mjs} +37 -3
- package/dist/plugin-CGPujyaL.mjs.map +1 -0
- package/dist/plugin.mjs +1 -1
- package/package.json +1 -1
- package/src/php/models.ts +37 -2
- package/dist/plugin-h8Onp2Ma.mjs.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [0.7.2](https://github.com/workos/oagen-emitters/compare/v0.7.1...v0.7.2) (2026-05-01)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Bug Fixes
|
|
7
|
+
|
|
8
|
+
* **php:** wrap degenerate-union models in fromArray/toArray ([#72](https://github.com/workos/oagen-emitters/issues/72)) ([053d34a](https://github.com/workos/oagen-emitters/commit/053d34adcbbecbed6793c54c4fd48a03aef97f21))
|
|
9
|
+
|
|
3
10
|
## [0.7.1](https://github.com/workos/oagen-emitters/compare/v0.7.0...v0.7.1) (2026-05-01)
|
|
4
11
|
|
|
5
12
|
|
package/dist/index.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { _ as nodeEmitter, a as rustExtractor, c as pythonExtractor, d as rubyEmitter, f as kotlinEmitter, g as pythonEmitter, h as phpEmitter, i as kotlinExtractor, l as rubyExtractor, m as goEmitter, n as elixirExtractor, o as goExtractor, p as dotnetEmitter, r as dotnetExtractor, s as phpExtractor, t as workosEmittersPlugin, u as nodeExtractor } from "./plugin-
|
|
1
|
+
import { _ as nodeEmitter, a as rustExtractor, c as pythonExtractor, d as rubyEmitter, f as kotlinEmitter, g as pythonEmitter, h as phpEmitter, i as kotlinExtractor, l as rubyExtractor, m as goEmitter, n as elixirExtractor, o as goExtractor, p as dotnetEmitter, r as dotnetExtractor, s as phpExtractor, t as workosEmittersPlugin, u as nodeExtractor } from "./plugin-CGPujyaL.mjs";
|
|
2
2
|
export { dotnetEmitter, dotnetExtractor, elixirExtractor, goEmitter, goExtractor, kotlinEmitter, kotlinExtractor, nodeEmitter, nodeExtractor, phpEmitter, phpExtractor, pythonEmitter, pythonExtractor, rubyEmitter, rubyExtractor, rustExtractor, workosEmittersPlugin };
|
|
@@ -10624,6 +10624,28 @@ function generateModels$4(models, ctx) {
|
|
|
10624
10624
|
return files;
|
|
10625
10625
|
}
|
|
10626
10626
|
/**
|
|
10627
|
+
* Resolve a degenerate union to a single TypeRef when possible.
|
|
10628
|
+
* - allOf: PHP collapses to the first variant (mirrors `mapTypeRef`).
|
|
10629
|
+
* - oneOf/anyOf where every variant has the same generated PHP type: collapse
|
|
10630
|
+
* to that variant (e.g. discriminated unions whose branches the IR pinned to
|
|
10631
|
+
* one model name).
|
|
10632
|
+
* Returns null when the union is genuinely polymorphic.
|
|
10633
|
+
*/
|
|
10634
|
+
function resolveDegenerateUnion(ref) {
|
|
10635
|
+
if (ref.kind !== "union") return null;
|
|
10636
|
+
if (ref.compositionKind === "allOf") return ref.variants[0] ?? null;
|
|
10637
|
+
if (ref.variants.length === 0) return null;
|
|
10638
|
+
const signature = (v) => {
|
|
10639
|
+
if (v.kind === "model") return `model:${v.name}`;
|
|
10640
|
+
if (v.kind === "enum") return `enum:${v.name}`;
|
|
10641
|
+
return `kind:${v.kind}`;
|
|
10642
|
+
};
|
|
10643
|
+
const first = ref.variants[0];
|
|
10644
|
+
const firstSig = signature(first);
|
|
10645
|
+
for (const v of ref.variants) if (signature(v) !== firstSig) return null;
|
|
10646
|
+
return first;
|
|
10647
|
+
}
|
|
10648
|
+
/**
|
|
10627
10649
|
* Generate the fromArray accessor expression for a field.
|
|
10628
10650
|
*/
|
|
10629
10651
|
function generateFromArrayAccessor(ref, wireName, required) {
|
|
@@ -10654,7 +10676,11 @@ function generateFromArrayValue(ref, accessor) {
|
|
|
10654
10676
|
if (ref.items.kind === "primitive" && ref.items.format === "date-time") return `array_map(fn ($item) => new \\DateTimeImmutable($item), ${accessor})`;
|
|
10655
10677
|
return accessor;
|
|
10656
10678
|
case "nullable": return generateFromArrayValue(ref.inner, accessor);
|
|
10657
|
-
case "union":
|
|
10679
|
+
case "union": {
|
|
10680
|
+
const resolved = resolveDegenerateUnion(ref);
|
|
10681
|
+
if (resolved) return generateFromArrayValue(resolved, accessor);
|
|
10682
|
+
return accessor;
|
|
10683
|
+
}
|
|
10658
10684
|
case "map": return accessor;
|
|
10659
10685
|
case "literal": return accessor;
|
|
10660
10686
|
}
|
|
@@ -10676,6 +10702,10 @@ function isComplexType(ref) {
|
|
|
10676
10702
|
case "enum": return true;
|
|
10677
10703
|
case "array": return isComplexType(ref.items);
|
|
10678
10704
|
case "nullable": return isComplexType(ref.inner);
|
|
10705
|
+
case "union": {
|
|
10706
|
+
const resolved = resolveDegenerateUnion(ref);
|
|
10707
|
+
return resolved ? isComplexType(resolved) : false;
|
|
10708
|
+
}
|
|
10679
10709
|
default: return false;
|
|
10680
10710
|
}
|
|
10681
10711
|
}
|
|
@@ -10697,7 +10727,11 @@ function generateToArrayValue(ref, accessor, nullable = false) {
|
|
|
10697
10727
|
return accessor;
|
|
10698
10728
|
case "nullable": return generateToArrayValue(ref.inner, accessor, true);
|
|
10699
10729
|
case "map": return accessor;
|
|
10700
|
-
case "union":
|
|
10730
|
+
case "union": {
|
|
10731
|
+
const resolved = resolveDegenerateUnion(ref);
|
|
10732
|
+
if (resolved) return generateToArrayValue(resolved, accessor, nullable);
|
|
10733
|
+
return accessor;
|
|
10734
|
+
}
|
|
10701
10735
|
case "literal": return accessor;
|
|
10702
10736
|
}
|
|
10703
10737
|
}
|
|
@@ -21975,4 +22009,4 @@ const workosEmittersPlugin = {
|
|
|
21975
22009
|
//#endregion
|
|
21976
22010
|
export { nodeEmitter as _, rustExtractor as a, pythonExtractor as c, rubyEmitter as d, kotlinEmitter as f, pythonEmitter as g, phpEmitter as h, kotlinExtractor as i, rubyExtractor as l, goEmitter as m, elixirExtractor as n, goExtractor as o, dotnetEmitter as p, dotnetExtractor as r, phpExtractor as s, workosEmittersPlugin as t, nodeExtractor as u };
|
|
21977
22011
|
|
|
21978
|
-
//# sourceMappingURL=plugin-
|
|
22012
|
+
//# sourceMappingURL=plugin-CGPujyaL.mjs.map
|