@workos/oagen 0.18.1 → 0.19.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.
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # oagen
2
2
 
3
- oagen is a framework for building custom SDK generators from OpenAPI 3.x specifications.
3
+ oagen ([**oʊweɪdd͡ʒɛn**](https://ipa-reader.com/?text=o%CA%8Awe%C9%AAdd%CD%A1%CA%92%C9%9Bn)) is a framework for building custom SDK generators from OpenAPI 3.x specifications.
4
4
 
5
5
  Its core job is narrow:
6
6
 
@@ -1435,7 +1435,7 @@ const LIMIT_PARAMS = [
1435
1435
  * Returns null if no pagination pattern is detected.
1436
1436
  */
1437
1437
  function detectPagination(response, queryParams, dataPath) {
1438
- const cursorParam = queryParams.find((p) => CURSOR_PARAMS.includes(p.name));
1438
+ const cursorParam = CURSOR_PARAMS.map((name) => queryParams.find((p) => p.name === name)).find((p) => p !== void 0);
1439
1439
  if (cursorParam) {
1440
1440
  const itemType = response.kind === "array" ? response.items : response;
1441
1441
  return {
@@ -4983,6 +4983,7 @@ function buildEmitterContext(spec, options) {
4983
4983
  overlayLookup: options.overlayLookup,
4984
4984
  resolvedOperations: resolveOperations(spec, options.operationHints, options.mountRules),
4985
4985
  modelHints: options.modelHints,
4986
+ emitterOptions: options.emitterOptions,
4986
4987
  targetDir: options.target,
4987
4988
  priorTargetManifestPaths: options.priorTargetManifestPaths
4988
4989
  };
@@ -5421,8 +5422,9 @@ async function removeEmptyParents(startDir, stopDir) {
5421
5422
  //#endregion
5422
5423
  //#region src/engine/orchestrator.ts
5423
5424
  async function generate(spec, emitter, options) {
5425
+ const outputPrevManifestForCtx = options.noPrune ? null : await readManifest(options.outputDir);
5424
5426
  const targetManifestForCtx = options.target && !options.noPrune ? await readManifest(options.target) : null;
5425
- const priorTargetManifestPaths = targetManifestForCtx ? new Set(targetManifestForCtx.files) : void 0;
5427
+ const priorTargetManifestPaths = targetManifestForCtx ? new Set(targetManifestForCtx.files) : outputPrevManifestForCtx ? new Set(outputPrevManifestForCtx.files) : void 0;
5426
5428
  const { files: withHeaders, header, operations } = generateFiles(spec, emitter, {
5427
5429
  ...options,
5428
5430
  priorTargetManifestPaths
@@ -5434,7 +5436,7 @@ async function generate(spec, emitter, options) {
5434
5436
  }
5435
5437
  return withHeaders;
5436
5438
  }
5437
- const outputPrevManifest = options.noPrune ? null : await readManifest(options.outputDir);
5439
+ const outputPrevManifest = outputPrevManifestForCtx;
5438
5440
  const writeResult = await writeFiles(withHeaders, options.outputDir, {
5439
5441
  language: emitter.language,
5440
5442
  header
@@ -6217,6 +6219,7 @@ async function generateCommand(opts) {
6217
6219
  operationHints: opts.operationHints,
6218
6220
  mountRules: opts.mountRules,
6219
6221
  modelHints: opts.modelHints,
6222
+ emitterOptions: opts.emitterOptions,
6220
6223
  noPrune: opts.prune === false
6221
6224
  });
6222
6225
  if (opts.dryRun) for (const f of files) console.log(f.path);
@@ -9133,6 +9136,7 @@ let configDocUrl;
9133
9136
  let configOperationHints;
9134
9137
  let configMountRules;
9135
9138
  let configModelHints;
9139
+ let configEmitterOptions;
9136
9140
  let configCompat;
9137
9141
  try {
9138
9142
  const config = await loadConfig(explicitConfigPath);
@@ -9146,6 +9150,7 @@ try {
9146
9150
  configOperationHints = config.operationHints;
9147
9151
  configMountRules = config.mountRules;
9148
9152
  configModelHints = config.modelHints;
9153
+ configEmitterOptions = config.emitterOptions;
9149
9154
  configCompat = config.compat;
9150
9155
  }
9151
9156
  } catch (err) {
@@ -9179,7 +9184,8 @@ program.command("generate").description("Run a registered emitter against an Ope
9179
9184
  docUrl: configDocUrl,
9180
9185
  operationHints: configOperationHints,
9181
9186
  mountRules: configMountRules,
9182
- modelHints: configModelHints
9187
+ modelHints: configModelHints,
9188
+ emitterOptions: configEmitterOptions?.[opts.lang]
9183
9189
  }).catch(handleError);
9184
9190
  });
9185
9191
  program.command("diff").description("Compare two OpenAPI specs and output a diff report").requiredOption("--old <path>", "Path to old spec").requiredOption("--new <path>", "Path to new spec").action((opts) => {