@workos/oagen 0.17.2 → 0.18.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.
@@ -937,13 +937,16 @@ function deriveInlineVariantMapping(variants, discriminatorProperty, contextName
937
937
  return mapping;
938
938
  }
939
939
  function extractEnum(name, schema) {
940
+ const values = (schema.enum ?? []).map((v) => ({
941
+ name: toUpperSnakeCase(String(v)),
942
+ value: typeof v === "number" ? v : String(v),
943
+ description: void 0
944
+ }));
945
+ const rawDefault = schema.default;
940
946
  return {
941
947
  name,
942
- values: (schema.enum ?? []).map((v) => ({
943
- name: toUpperSnakeCase(String(v)),
944
- value: typeof v === "number" ? v : String(v),
945
- description: void 0
946
- }))
948
+ values,
949
+ default: rawDefault !== void 0 && values.some((v) => v.value === rawDefault) ? rawDefault : void 0
947
950
  };
948
951
  }
949
952
  function extractModel(name, schema, schemas) {
@@ -4511,6 +4514,7 @@ async function writeFiles(files, outputDir, options) {
4511
4514
  const header = options?.header ?? "";
4512
4515
  for (const file of sorted) {
4513
4516
  const fullPath = path$1.join(outputDir, file.path);
4517
+ await renameMismatchedCasing(fullPath);
4514
4518
  let existingContent = null;
4515
4519
  try {
4516
4520
  existingContent = await fs.readFile(fullPath, "utf-8");
@@ -4583,6 +4587,30 @@ async function writeFiles(files, outputDir, options) {
4583
4587
  }
4584
4588
  return result;
4585
4589
  }
4590
+ /**
4591
+ * If a sibling exists with the same name except for letter case, rename it to
4592
+ * the requested casing. Uses a two-step rename via a temporary unique name so
4593
+ * case-insensitive filesystems (APFS on macOS, NTFS on Windows) actually
4594
+ * update the entry — `rename('Foo', 'FOO')` is a no-op on those systems.
4595
+ */
4596
+ async function renameMismatchedCasing(fullPath) {
4597
+ const dir = path$1.dirname(fullPath);
4598
+ const target = path$1.basename(fullPath);
4599
+ let entries;
4600
+ try {
4601
+ entries = await fs.readdir(dir);
4602
+ } catch {
4603
+ return;
4604
+ }
4605
+ if (entries.includes(target)) return;
4606
+ const targetLower = target.toLowerCase();
4607
+ const mismatch = entries.find((e) => e.toLowerCase() === targetLower);
4608
+ if (!mismatch) return;
4609
+ const oldPath = path$1.join(dir, mismatch);
4610
+ const tempPath = path$1.join(dir, `.oagen-case-${process.pid}-${Date.now()}-${target}`);
4611
+ await fs.rename(oldPath, tempPath);
4612
+ await fs.rename(tempPath, fullPath);
4613
+ }
4586
4614
  /** Comprehensive fallback when no adapter is available. */
4587
4615
  function isDefaultTestFile(filePath) {
4588
4616
  return /\.(spec|test)\.[jt]sx?$/.test(filePath) || filePath.endsWith("_test.go") || filePath.endsWith("_test.rb") || filePath.endsWith("_spec.rb") || /(?:^|\/)test_.*\.py$/.test(filePath) || filePath.endsWith("_test.py") || filePath.endsWith("Test.php") || filePath.endsWith("_test.rs") || /(?:^|\/)tests\/.*\.rs$/.test(filePath);