@workos/oagen-emitters 0.14.2 → 0.14.3

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/plugin.mjs CHANGED
@@ -1,2 +1,2 @@
1
- import { t as workosEmittersPlugin } from "./plugin-BbSmT2kj.mjs";
1
+ import { t as workosEmittersPlugin } from "./plugin-D0qLBiGv.mjs";
2
2
  export { workosEmittersPlugin };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@workos/oagen-emitters",
3
- "version": "0.14.2",
3
+ "version": "0.14.3",
4
4
  "description": "WorkOS' oagen emitters",
5
5
  "license": "MIT",
6
6
  "author": "WorkOS",
@@ -146,6 +146,22 @@ export function generateModelFixture(
146
146
  }
147
147
  }
148
148
 
149
+ if (model.discriminator) {
150
+ const [firstValue, variantName] = Object.entries(model.discriminator.mapping)[0];
151
+ fixture[model.discriminator.property] = firstValue;
152
+ const variantModel = modelMap.get(variantName);
153
+ if (variantModel) {
154
+ for (const field of variantModel.fields) {
155
+ if (!(field.name in fixture)) {
156
+ fixture[field.name] =
157
+ field.example !== undefined
158
+ ? field.example
159
+ : generateFieldValue(field.type, field.name, model.name, modelMap, enumMap);
160
+ }
161
+ }
162
+ }
163
+ }
164
+
149
165
  return fixture;
150
166
  }
151
167
 
@@ -165,6 +165,23 @@ export function generateModelFixture(
165
165
  }
166
166
  }
167
167
 
168
+ if (model.discriminator) {
169
+ const [firstValue, variantName] = Object.entries(model.discriminator.mapping)[0];
170
+ fixture[wireFieldName(model.discriminator.property)] = firstValue;
171
+ const variantModel = modelMap.get(variantName);
172
+ if (variantModel) {
173
+ for (const field of variantModel.fields) {
174
+ const wireName = wireFieldName(field.name);
175
+ if (!(wireName in fixture)) {
176
+ fixture[wireName] =
177
+ field.example !== undefined
178
+ ? field.example
179
+ : generateFieldValue(field.type, field.name, model.name, modelMap, enumMap);
180
+ }
181
+ }
182
+ }
183
+ }
184
+
168
185
  return fixture;
169
186
  }
170
187
 
package/src/node/index.ts CHANGED
@@ -195,6 +195,11 @@ function markPriorManifestAutogen(
195
195
  if (!surface.files.has(relPath)) continue;
196
196
  if (surface.protectedFiles.has(relPath)) continue;
197
197
 
198
+ if (/\/fixtures\/[^/]+\.json$/.test(relPath)) {
199
+ surface.autogenFiles.add(relPath);
200
+ continue;
201
+ }
202
+
198
203
  try {
199
204
  const text = fs.readFileSync(path.join(root, relPath), 'utf8');
200
205
  if (/auto-generated by oagen/i.test(text.slice(0, 400))) {
@@ -123,6 +123,22 @@ export function generateModelFixture(
123
123
  }
124
124
  }
125
125
 
126
+ if (model.discriminator) {
127
+ const [firstValue, variantName] = Object.entries(model.discriminator.mapping)[0];
128
+ fixture[model.discriminator.property] = firstValue;
129
+ const variantModel = modelMap.get(variantName);
130
+ if (variantModel) {
131
+ for (const field of variantModel.fields) {
132
+ if (!(field.name in fixture)) {
133
+ fixture[field.name] =
134
+ field.example !== undefined
135
+ ? field.example
136
+ : generateFieldValue(field.type, field.name, model.name, modelMap, enumMap);
137
+ }
138
+ }
139
+ }
140
+ }
141
+
126
142
  return fixture;
127
143
  }
128
144
 
@@ -49,6 +49,22 @@ export function generateModelFixture(
49
49
  fromExample !== undefined ? fromExample : exampleFor(field.type, modelMap, enumMap, visiting, field.name);
50
50
  }
51
51
 
52
+ if (model.discriminator) {
53
+ const [firstValue, variantName] = Object.entries(model.discriminator.mapping)[0];
54
+ result[model.discriminator.property] = firstValue;
55
+ const variantModel = modelMap.get(variantName);
56
+ if (variantModel) {
57
+ for (const field of variantModel.fields) {
58
+ if (!(field.name in result)) {
59
+ if (!field.required) continue;
60
+ const fromExample = exampleFromSpec(field.example, field.type, enumMap);
61
+ result[field.name] =
62
+ fromExample !== undefined ? fromExample : exampleFor(field.type, modelMap, enumMap, visiting, field.name);
63
+ }
64
+ }
65
+ }
66
+ }
67
+
52
68
  visiting.delete(model.name);
53
69
  return result;
54
70
  }