@workos/oagen-emitters 0.6.0 → 0.6.1
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-Dws9b6T7.mjs → plugin-CZc7Teko.mjs} +20 -5
- package/dist/plugin-CZc7Teko.mjs.map +1 -0
- package/dist/plugin.mjs +1 -1
- package/package.json +1 -1
- package/src/go/index.ts +15 -1
- package/src/php/resources.ts +9 -4
- package/dist/plugin-Dws9b6T7.mjs.map +0 -1
package/dist/plugin.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { t as workosEmittersPlugin } from "./plugin-
|
|
1
|
+
import { t as workosEmittersPlugin } from "./plugin-CZc7Teko.mjs";
|
|
2
2
|
export { workosEmittersPlugin };
|
package/package.json
CHANGED
package/src/go/index.ts
CHANGED
|
@@ -33,7 +33,21 @@ export const goEmitter: Emitter = {
|
|
|
33
33
|
generateModels(models: Model[], ctx: EmitterContext): GeneratedFile[] {
|
|
34
34
|
// Enrich models by flattening oneOf/allOf+oneOf variant fields from the raw spec
|
|
35
35
|
const enriched = enrichModelsFromSpec(models);
|
|
36
|
-
|
|
36
|
+
// Go has no sum types, so discriminated union base models (e.g. EventSchema)
|
|
37
|
+
// need their base fields preserved. enrichModelsFromSpec clears fields for
|
|
38
|
+
// discriminated models so dispatcher-capable languages can generate sealed
|
|
39
|
+
// classes; restore the original fields here since Go just emits flat structs.
|
|
40
|
+
const originalByName = new Map(models.map((m) => [m.name, m]));
|
|
41
|
+
const goModels = enriched.map((m) => {
|
|
42
|
+
if ((m as any).discriminator && m.fields.length === 0) {
|
|
43
|
+
const original = originalByName.get(m.name);
|
|
44
|
+
if (original && original.fields.length > 0) {
|
|
45
|
+
return { ...m, fields: original.fields };
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
return m;
|
|
49
|
+
});
|
|
50
|
+
return ensureTrailingNewlines(generateModels(goModels, ctx));
|
|
37
51
|
},
|
|
38
52
|
|
|
39
53
|
generateEnums(enums: Enum[], ctx: EmitterContext): GeneratedFile[] {
|
package/src/php/resources.ts
CHANGED
|
@@ -261,12 +261,14 @@ function generateMethod(
|
|
|
261
261
|
}
|
|
262
262
|
|
|
263
263
|
// @param for body fields
|
|
264
|
+
const groupedParamNames = collectGroupedParamNames(op);
|
|
264
265
|
if (plan.hasBody && op.requestBody?.kind === 'model') {
|
|
265
266
|
const bodyModel = modelMap.get(op.requestBody.name);
|
|
266
267
|
if (bodyModel) {
|
|
267
268
|
const bodyParamMap = buildBodyParamMap(op, bodyModel);
|
|
268
269
|
for (const field of bodyModel.fields) {
|
|
269
270
|
if (hiddenParams.has(field.name)) continue;
|
|
271
|
+
if (groupedParamNames.has(field.name)) continue;
|
|
270
272
|
const docType = mapTypeRefForPHPDoc(field.type);
|
|
271
273
|
const phpName = bodyParamMap.get(field.name) ?? fieldName(field.name);
|
|
272
274
|
if (seenDocParams.has(phpName)) continue;
|
|
@@ -280,7 +282,6 @@ function generateMethod(
|
|
|
280
282
|
}
|
|
281
283
|
|
|
282
284
|
// @param for parameter groups (union-typed)
|
|
283
|
-
const groupedParamNames = collectGroupedParamNames(op);
|
|
284
285
|
for (const group of op.parameterGroups ?? []) {
|
|
285
286
|
const phpName = fieldName(group.name);
|
|
286
287
|
if (seenDocParams.has(phpName)) continue;
|
|
@@ -438,7 +439,9 @@ function generateMethod(
|
|
|
438
439
|
if (plan.hasBody) {
|
|
439
440
|
const bodyModel = op.requestBody?.kind === 'model' ? modelMap.get(op.requestBody.name) : null;
|
|
440
441
|
const bodyParamMap = buildBodyParamMap(op, bodyModel ?? null);
|
|
441
|
-
const
|
|
442
|
+
const deleteGroupedParams = collectGroupedParamNames(op);
|
|
443
|
+
const visibleFields =
|
|
444
|
+
bodyModel?.fields.filter((f) => !hiddenParams.has(f.name) && !deleteGroupedParams.has(f.name)) ?? [];
|
|
442
445
|
const hasOptionalFields = visibleFields.some((f) => !f.required);
|
|
443
446
|
if (hasOptionalFields) {
|
|
444
447
|
lines.push(' $body = array_filter([');
|
|
@@ -493,7 +496,9 @@ function generateMethod(
|
|
|
493
496
|
} else if (plan.hasBody) {
|
|
494
497
|
const bodyModel = op.requestBody?.kind === 'model' ? modelMap.get(op.requestBody.name) : null;
|
|
495
498
|
const bodyParamMap = buildBodyParamMap(op, bodyModel ?? null);
|
|
496
|
-
const
|
|
499
|
+
const bodyGroupedParams = collectGroupedParamNames(op);
|
|
500
|
+
const visibleFields =
|
|
501
|
+
bodyModel?.fields.filter((f) => !hiddenParams.has(f.name) && !bodyGroupedParams.has(f.name)) ?? [];
|
|
497
502
|
const hasOptionalFields = visibleFields.some((f) => !f.required);
|
|
498
503
|
if (hasOptionalFields) {
|
|
499
504
|
lines.push(' $body = array_filter([');
|
|
@@ -617,7 +622,6 @@ function buildMethodParams(
|
|
|
617
622
|
const usedNames = new Set<string>();
|
|
618
623
|
const hidden = hiddenParams ?? new Set();
|
|
619
624
|
const groupedParams = collectGroupedParamNames(op);
|
|
620
|
-
|
|
621
625
|
// Path params (always required)
|
|
622
626
|
for (const p of op.pathParams) {
|
|
623
627
|
const phpType = mapTypeRef(p.type, { qualified: true });
|
|
@@ -633,6 +637,7 @@ function buildMethodParams(
|
|
|
633
637
|
if (bodyModel) {
|
|
634
638
|
for (const field of bodyModel.fields) {
|
|
635
639
|
if (hidden.has(field.name)) continue;
|
|
640
|
+
if (groupedParams.has(field.name)) continue;
|
|
636
641
|
const phpType = mapTypeRef(field.type, { qualified: true });
|
|
637
642
|
let phpName = fieldName(field.name);
|
|
638
643
|
if (usedNames.has(phpName)) {
|