@workos/oagen-emitters 0.14.2 → 0.14.4
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 +14 -0
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +1 -1
- package/dist/{plugin-BbSmT2kj.mjs → plugin-BGVaMGqe.mjs} +67 -21
- package/dist/plugin-BGVaMGqe.mjs.map +1 -0
- package/dist/plugin.mjs +1 -1
- package/package.json +4 -4
- package/src/go/fixtures.ts +16 -0
- package/src/node/discriminated-models.ts +12 -28
- package/src/node/fixtures.ts +17 -0
- package/src/node/index.ts +5 -0
- package/src/python/fixtures.ts +16 -0
- package/src/ruby/rbi.ts +12 -6
- package/src/rust/fixtures.ts +16 -0
- package/dist/plugin-BbSmT2kj.mjs.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [0.14.4](https://github.com/workos/oagen-emitters/compare/v0.14.3...v0.14.4) (2026-05-26)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Bug Fixes
|
|
7
|
+
|
|
8
|
+
* **ruby:** avoid double-wrapping T.nilable and skip T.untyped ([#127](https://github.com/workos/oagen-emitters/issues/127)) ([e42083f](https://github.com/workos/oagen-emitters/commit/e42083f77773f3ae96b750577db36cde01b65f4f))
|
|
9
|
+
|
|
10
|
+
## [0.14.3](https://github.com/workos/oagen-emitters/compare/v0.14.2...v0.14.3) (2026-05-22)
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
### Bug Fixes
|
|
14
|
+
|
|
15
|
+
* include discriminator fields in generated fixtures ([#125](https://github.com/workos/oagen-emitters/issues/125)) ([6a3633e](https://github.com/workos/oagen-emitters/commit/6a3633e0e3f0497146bf89fc31a5dabc1152cce1))
|
|
16
|
+
|
|
3
17
|
## [0.14.2](https://github.com/workos/oagen-emitters/compare/v0.14.1...v0.14.2) (2026-05-22)
|
|
4
18
|
|
|
5
19
|
|
package/dist/index.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.mts","names":[],"sources":["../src/node/index.ts","../src/python/index.ts","../src/php/index.ts","../src/go/index.ts","../src/dotnet/index.ts","../src/kotlin/index.ts","../src/ruby/index.ts","../src/rust/index.ts"],"mappings":";;;;;
|
|
1
|
+
{"version":3,"file":"index.d.mts","names":[],"sources":["../src/node/index.ts","../src/python/index.ts","../src/php/index.ts","../src/go/index.ts","../src/dotnet/index.ts","../src/kotlin/index.ts","../src/ruby/index.ts","../src/rust/index.ts"],"mappings":";;;;;cA4da,WAAA,EAAa,OA4GzB;;;cCjiBY,aAAA,EAAe,OA+D3B;;;cC5CY,UAAA,EAAY,OA4DxB;;;cCzFY,SAAA,EAAW,OAyEvB;;;cCnCY,aAAA,EAAe,OAiR3B;;;cCrTY,aAAA,EAAe,OA6E3B;;;cCxDY,WAAA,EAAa,OAmEzB;;;cC5DY,WAAA,EAAa,OA2DzB"}
|
package/dist/index.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { _ as pythonEmitter, a as rustExtractor, c as pythonExtractor, d as rustEmitter, f as rubyEmitter, g as phpEmitter, h as goEmitter, i as kotlinExtractor, l as rubyExtractor, m as dotnetEmitter, n as elixirExtractor, o as goExtractor, p as kotlinEmitter, r as dotnetExtractor, s as phpExtractor, t as workosEmittersPlugin, u as nodeExtractor, v as nodeEmitter } from "./plugin-
|
|
1
|
+
import { _ as pythonEmitter, a as rustExtractor, c as pythonExtractor, d as rustEmitter, f as rubyEmitter, g as phpEmitter, h as goEmitter, i as kotlinExtractor, l as rubyExtractor, m as dotnetEmitter, n as elixirExtractor, o as goExtractor, p as kotlinEmitter, r as dotnetExtractor, s as phpExtractor, t as workosEmittersPlugin, u as nodeExtractor, v as nodeEmitter } from "./plugin-BGVaMGqe.mjs";
|
|
2
2
|
export { dotnetEmitter, dotnetExtractor, elixirExtractor, goEmitter, goExtractor, kotlinEmitter, kotlinExtractor, nodeEmitter, nodeExtractor, phpEmitter, phpExtractor, pythonEmitter, pythonExtractor, rubyEmitter, rubyExtractor, rustEmitter, rustExtractor, workosEmittersPlugin };
|
|
@@ -5925,6 +5925,15 @@ function generateModelFixture$5(model, modelMap, enumMap) {
|
|
|
5925
5925
|
if (field.example !== void 0) fixture[wireName] = field.example;
|
|
5926
5926
|
else fixture[wireName] = generateFieldValue$4(field.type, field.name, model.name, modelMap, enumMap);
|
|
5927
5927
|
}
|
|
5928
|
+
if (model.discriminator) {
|
|
5929
|
+
const [firstValue, variantName] = Object.entries(model.discriminator.mapping)[0];
|
|
5930
|
+
fixture[wireFieldName(model.discriminator.property)] = firstValue;
|
|
5931
|
+
const variantModel = modelMap.get(variantName);
|
|
5932
|
+
if (variantModel) for (const field of variantModel.fields) {
|
|
5933
|
+
const wireName = wireFieldName(field.name);
|
|
5934
|
+
if (!(wireName in fixture)) fixture[wireName] = field.example !== void 0 ? field.example : generateFieldValue$4(field.type, field.name, model.name, modelMap, enumMap);
|
|
5935
|
+
}
|
|
5936
|
+
}
|
|
5928
5937
|
return fixture;
|
|
5929
5938
|
}
|
|
5930
5939
|
function generateFieldValue$4(ref, fName, modelName, modelMap, enumMap) {
|
|
@@ -7758,13 +7767,13 @@ function detectDiscriminatedShape(modelName, rawSchemas) {
|
|
|
7758
7767
|
return {
|
|
7759
7768
|
nameSuffix: variantNameSuffix(discValue),
|
|
7760
7769
|
discriminatorValue: discValue,
|
|
7761
|
-
fields: variantFields(fv, discProp, modelName
|
|
7770
|
+
fields: variantFields(fv, discProp, modelName)
|
|
7762
7771
|
};
|
|
7763
7772
|
}).filter((v) => v !== null);
|
|
7764
7773
|
if (variants.length !== flattenedVariants.length) return null;
|
|
7765
7774
|
return {
|
|
7766
7775
|
modelName,
|
|
7767
|
-
baseFields: baseObject ? collectObjectFields(baseObject, modelName
|
|
7776
|
+
baseFields: baseObject ? collectObjectFields(baseObject, modelName) : [],
|
|
7768
7777
|
discriminatorProperty: discProp,
|
|
7769
7778
|
discriminatorPropertyDomain: toCamelCase(discProp),
|
|
7770
7779
|
variants
|
|
@@ -7775,8 +7784,8 @@ function mergeBase(prev, next) {
|
|
|
7775
7784
|
return {
|
|
7776
7785
|
type: "object",
|
|
7777
7786
|
properties: {
|
|
7778
|
-
...prev.properties
|
|
7779
|
-
...next.properties
|
|
7787
|
+
...prev.properties,
|
|
7788
|
+
...next.properties
|
|
7780
7789
|
},
|
|
7781
7790
|
required: [...new Set([...prev.required ?? [], ...next.required ?? []])]
|
|
7782
7791
|
};
|
|
@@ -7902,29 +7911,29 @@ function readConstString(schema) {
|
|
|
7902
7911
|
function variantNameSuffix(constValue) {
|
|
7903
7912
|
return toPascalCase(constValue);
|
|
7904
7913
|
}
|
|
7905
|
-
function collectObjectFields(schema, parentName
|
|
7914
|
+
function collectObjectFields(schema, parentName) {
|
|
7906
7915
|
const props = schema.properties ?? {};
|
|
7907
7916
|
const required = new Set(schema.required ?? []);
|
|
7908
7917
|
const fields = [];
|
|
7909
|
-
for (const [name, propSchema] of Object.entries(props)) fields.push(buildField(name, propSchema, required.has(name), parentName
|
|
7918
|
+
for (const [name, propSchema] of Object.entries(props)) fields.push(buildField(name, propSchema, required.has(name), parentName));
|
|
7910
7919
|
return fields;
|
|
7911
7920
|
}
|
|
7912
|
-
function variantFields(fv, discriminatorProperty, parentName
|
|
7921
|
+
function variantFields(fv, discriminatorProperty, parentName) {
|
|
7913
7922
|
const fields = [];
|
|
7914
7923
|
for (const [name, propSchema] of fv.alwaysProperties) {
|
|
7915
7924
|
if (name === discriminatorProperty) continue;
|
|
7916
|
-
fields.push(buildField(name, propSchema, fv.required.has(name), parentName
|
|
7925
|
+
fields.push(buildField(name, propSchema, fv.required.has(name), parentName));
|
|
7917
7926
|
}
|
|
7918
7927
|
for (const [name, propSchema] of fv.optionalProperties) {
|
|
7919
7928
|
if (name === discriminatorProperty) continue;
|
|
7920
|
-
fields.push(buildField(name, propSchema, false, parentName
|
|
7929
|
+
fields.push(buildField(name, propSchema, false, parentName));
|
|
7921
7930
|
}
|
|
7922
7931
|
return fields;
|
|
7923
7932
|
}
|
|
7924
|
-
function buildField(rawName, schema, required, parentName
|
|
7933
|
+
function buildField(rawName, schema, required, parentName) {
|
|
7925
7934
|
const modelDeps = /* @__PURE__ */ new Set();
|
|
7926
|
-
const domainType = rawSchemaToTS(schema, parentName, rawName, false, modelDeps
|
|
7927
|
-
const wireType = rawSchemaToTS(schema, parentName, rawName, true, modelDeps
|
|
7935
|
+
const domainType = rawSchemaToTS(schema, parentName, rawName, false, modelDeps);
|
|
7936
|
+
const wireType = rawSchemaToTS(schema, parentName, rawName, true, modelDeps);
|
|
7928
7937
|
return {
|
|
7929
7938
|
name: rawName,
|
|
7930
7939
|
description: schema.description,
|
|
@@ -7947,7 +7956,7 @@ function typeOf(schema) {
|
|
|
7947
7956
|
function isNullable(schema) {
|
|
7948
7957
|
return Array.isArray(schema.type) && schema.type.includes("null");
|
|
7949
7958
|
}
|
|
7950
|
-
function rawSchemaToTS(schema, parentName, fieldName, isWire, modelDeps
|
|
7959
|
+
function rawSchemaToTS(schema, parentName, fieldName, isWire, modelDeps) {
|
|
7951
7960
|
if (schema.$ref) {
|
|
7952
7961
|
const refName = schema.$ref.split("/").pop();
|
|
7953
7962
|
modelDeps.add(refName);
|
|
@@ -7962,7 +7971,7 @@ function rawSchemaToTS(schema, parentName, fieldName, isWire, modelDeps, rawSche
|
|
|
7962
7971
|
if (baseType === "string") core = !isWire && schema.format === "date-time" ? "Date" : "string";
|
|
7963
7972
|
else if (baseType === "integer" || baseType === "number") core = "number";
|
|
7964
7973
|
else if (baseType === "boolean") core = "boolean";
|
|
7965
|
-
else if (baseType === "array" && schema.items) core = `${parenthesizeUnion(rawSchemaToTS(schema.items, parentName, singularize$3(fieldName), isWire, modelDeps
|
|
7974
|
+
else if (baseType === "array" && schema.items) core = `${parenthesizeUnion(rawSchemaToTS(schema.items, parentName, singularize$3(fieldName), isWire, modelDeps))}[]`;
|
|
7966
7975
|
else if (baseType === "object" && schema.properties) {
|
|
7967
7976
|
const synthName = `${parentName}_${singularize$3(fieldName)}`;
|
|
7968
7977
|
modelDeps.add(synthName);
|
|
@@ -8362,6 +8371,10 @@ function markPriorManifestAutogen(surface, root, priorManifestPaths) {
|
|
|
8362
8371
|
if (!relPath.startsWith("src/")) continue;
|
|
8363
8372
|
if (!surface.files.has(relPath)) continue;
|
|
8364
8373
|
if (surface.protectedFiles.has(relPath)) continue;
|
|
8374
|
+
if (/\/fixtures\/[^/]+\.json$/.test(relPath)) {
|
|
8375
|
+
surface.autogenFiles.add(relPath);
|
|
8376
|
+
continue;
|
|
8377
|
+
}
|
|
8365
8378
|
try {
|
|
8366
8379
|
const text = fs$1.readFileSync(path$1.join(root, relPath), "utf8");
|
|
8367
8380
|
if (/auto-generated by oagen/i.test(text.slice(0, 400))) {
|
|
@@ -11459,6 +11472,14 @@ function generateModelFixture$4(model, modelMap, enumMap) {
|
|
|
11459
11472
|
if (field.example !== void 0) fixture[wireName] = field.example;
|
|
11460
11473
|
else fixture[wireName] = generateFieldValue$3(field.type, field.name, model.name, modelMap, enumMap);
|
|
11461
11474
|
}
|
|
11475
|
+
if (model.discriminator) {
|
|
11476
|
+
const [firstValue, variantName] = Object.entries(model.discriminator.mapping)[0];
|
|
11477
|
+
fixture[model.discriminator.property] = firstValue;
|
|
11478
|
+
const variantModel = modelMap.get(variantName);
|
|
11479
|
+
if (variantModel) {
|
|
11480
|
+
for (const field of variantModel.fields) if (!(field.name in fixture)) fixture[field.name] = field.example !== void 0 ? field.example : generateFieldValue$3(field.type, field.name, model.name, modelMap, enumMap);
|
|
11481
|
+
}
|
|
11482
|
+
}
|
|
11462
11483
|
return fixture;
|
|
11463
11484
|
}
|
|
11464
11485
|
function generateFieldValue$3(ref, fieldName, modelName, modelMap, enumMap) {
|
|
@@ -16471,6 +16492,14 @@ function generateModelFixture$2(model, modelMap, enumMap) {
|
|
|
16471
16492
|
if (field.example !== void 0) fixture[wireName] = field.example;
|
|
16472
16493
|
else fixture[wireName] = generateFieldValue$1(field.type, field.name, model.name, modelMap, enumMap);
|
|
16473
16494
|
}
|
|
16495
|
+
if (model.discriminator) {
|
|
16496
|
+
const [firstValue, variantName] = Object.entries(model.discriminator.mapping)[0];
|
|
16497
|
+
fixture[model.discriminator.property] = firstValue;
|
|
16498
|
+
const variantModel = modelMap.get(variantName);
|
|
16499
|
+
if (variantModel) {
|
|
16500
|
+
for (const field of variantModel.fields) if (!(field.name in fixture)) fixture[field.name] = field.example !== void 0 ? field.example : generateFieldValue$1(field.type, field.name, model.name, modelMap, enumMap);
|
|
16501
|
+
}
|
|
16502
|
+
}
|
|
16474
16503
|
return fixture;
|
|
16475
16504
|
}
|
|
16476
16505
|
function generateFieldValue$1(ref, fName, modelName, modelMap, enumMap) {
|
|
@@ -24933,7 +24962,7 @@ function mapSorbetType(ref) {
|
|
|
24933
24962
|
if (unique.length === 1) return unique[0];
|
|
24934
24963
|
return `T.any(${unique.join(", ")})`;
|
|
24935
24964
|
},
|
|
24936
|
-
nullable: (_ref, inner) =>
|
|
24965
|
+
nullable: (_ref, inner) => wrapNilable(inner),
|
|
24937
24966
|
literal: (r) => typeof r.value === "string" ? "String" : r.value === null ? "NilClass" : typeof r.value === "number" ? Number.isInteger(r.value) ? "Integer" : "Float" : "T::Boolean",
|
|
24938
24967
|
map: (_ref, value) => `T::Hash[String, ${value}]`
|
|
24939
24968
|
});
|
|
@@ -24961,7 +24990,7 @@ function generateRbiFiles(spec, ctx) {
|
|
|
24961
24990
|
const fname = fieldName$1(f.name);
|
|
24962
24991
|
if (seenFieldNames.has(fname)) continue;
|
|
24963
24992
|
seenFieldNames.add(fname);
|
|
24964
|
-
const sorbetType = f.required ? mapSorbetType(f.type) :
|
|
24993
|
+
const sorbetType = f.required ? mapSorbetType(f.type) : wrapNilable(mapSorbetType(f.type));
|
|
24965
24994
|
lines.push(` sig { returns(${sorbetType}) }`);
|
|
24966
24995
|
lines.push(` def ${fname}; end`);
|
|
24967
24996
|
lines.push("");
|
|
@@ -25068,7 +25097,7 @@ function generateRbiFiles(spec, ctx) {
|
|
|
25068
25097
|
const n = fieldName$1(f.name);
|
|
25069
25098
|
if (seen.has(n)) continue;
|
|
25070
25099
|
seen.add(n);
|
|
25071
|
-
sigParams.push(`${n}:
|
|
25100
|
+
sigParams.push(`${n}: ${wrapNilable(mapSorbetType(f.type))}`);
|
|
25072
25101
|
}
|
|
25073
25102
|
for (const q of queryParams) {
|
|
25074
25103
|
if (hiddenParams.has(q.name)) continue;
|
|
@@ -25076,14 +25105,14 @@ function generateRbiFiles(spec, ctx) {
|
|
|
25076
25105
|
const n = safeParamName(q.name);
|
|
25077
25106
|
if (seen.has(n)) continue;
|
|
25078
25107
|
seen.add(n);
|
|
25079
|
-
sigParams.push(`${n}:
|
|
25108
|
+
sigParams.push(`${n}: ${wrapNilable(mapSorbetType(q.type))}`);
|
|
25080
25109
|
}
|
|
25081
25110
|
for (const group of parameterGroups) {
|
|
25082
25111
|
if (!group.optional) continue;
|
|
25083
25112
|
const n = fieldName$1(group.name);
|
|
25084
25113
|
if (seen.has(n)) continue;
|
|
25085
25114
|
seen.add(n);
|
|
25086
|
-
sigParams.push(`${n}:
|
|
25115
|
+
sigParams.push(`${n}: ${wrapNilable(groupSorbetType(group))}`);
|
|
25087
25116
|
}
|
|
25088
25117
|
sigParams.push("request_options: T::Hash[Symbol, T.untyped]");
|
|
25089
25118
|
const retType = mapSorbetReturnType(op.response, listWrapperModels, modelNames);
|
|
@@ -25137,12 +25166,17 @@ function unwrapNilable(type) {
|
|
|
25137
25166
|
const match = type.match(/^T\.nilable\((.+)\)$/);
|
|
25138
25167
|
return match ? match[1] : type;
|
|
25139
25168
|
}
|
|
25169
|
+
/** Wrap a type in T.nilable(), skipping T.untyped (which already includes nil) and avoiding double-wrapping. */
|
|
25170
|
+
function wrapNilable(type) {
|
|
25171
|
+
if (type === "T.untyped") return type;
|
|
25172
|
+
return `T.nilable(${unwrapNilable(type)})`;
|
|
25173
|
+
}
|
|
25140
25174
|
/** Map a response TypeRef to a Sorbet return type. */
|
|
25141
25175
|
function mapSorbetReturnType(ref, listWrapperModels, modelNames) {
|
|
25142
25176
|
if (ref.kind === "model" && listWrapperModels.has(ref.name)) return "WorkOS::Types::ListStruct";
|
|
25143
25177
|
if (ref.kind === "model" && modelNames.has(ref.name)) return `WorkOS::${className(ref.name)}`;
|
|
25144
25178
|
if (ref.kind === "array" && ref.items.kind === "model" && modelNames.has(ref.items.name)) return `T::Array[WorkOS::${className(ref.items.name)}]`;
|
|
25145
|
-
if (ref.kind === "nullable") return
|
|
25179
|
+
if (ref.kind === "nullable") return wrapNilable(mapSorbetReturnType(ref.inner, listWrapperModels, modelNames));
|
|
25146
25180
|
if (ref.kind === "primitive" && ref.type === "unknown") return "NilClass";
|
|
25147
25181
|
return mapSorbetType(ref);
|
|
25148
25182
|
}
|
|
@@ -26852,6 +26886,18 @@ function generateModelFixture(model, modelMap, enumMap, visiting) {
|
|
|
26852
26886
|
const fromExample = exampleFromSpec(field.example, field.type, enumMap);
|
|
26853
26887
|
result[field.name] = fromExample !== void 0 ? fromExample : exampleFor(field.type, modelMap, enumMap, visiting, field.name);
|
|
26854
26888
|
}
|
|
26889
|
+
if (model.discriminator) {
|
|
26890
|
+
const [firstValue, variantName] = Object.entries(model.discriminator.mapping)[0];
|
|
26891
|
+
result[model.discriminator.property] = firstValue;
|
|
26892
|
+
const variantModel = modelMap.get(variantName);
|
|
26893
|
+
if (variantModel) {
|
|
26894
|
+
for (const field of variantModel.fields) if (!(field.name in result)) {
|
|
26895
|
+
if (!field.required) continue;
|
|
26896
|
+
const fromExample = exampleFromSpec(field.example, field.type, enumMap);
|
|
26897
|
+
result[field.name] = fromExample !== void 0 ? fromExample : exampleFor(field.type, modelMap, enumMap, visiting, field.name);
|
|
26898
|
+
}
|
|
26899
|
+
}
|
|
26900
|
+
}
|
|
26855
26901
|
visiting.delete(model.name);
|
|
26856
26902
|
return result;
|
|
26857
26903
|
}
|
|
@@ -27604,4 +27650,4 @@ const workosEmittersPlugin = {
|
|
|
27604
27650
|
//#endregion
|
|
27605
27651
|
export { pythonEmitter as _, rustExtractor as a, pythonExtractor as c, rustEmitter as d, rubyEmitter as f, phpEmitter as g, goEmitter as h, kotlinExtractor as i, rubyExtractor as l, dotnetEmitter as m, elixirExtractor as n, goExtractor as o, kotlinEmitter as p, dotnetExtractor as r, phpExtractor as s, workosEmittersPlugin as t, nodeExtractor as u, nodeEmitter as v };
|
|
27606
27652
|
|
|
27607
|
-
//# sourceMappingURL=plugin-
|
|
27653
|
+
//# sourceMappingURL=plugin-BGVaMGqe.mjs.map
|