@workos/oagen 0.21.0 → 0.22.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/dist/cli/index.mjs +229 -34
- package/dist/cli/index.mjs.map +1 -1
- package/dist/{diff-CBFCoTCw.mjs → diff-Dobf9PHC.mjs} +205 -33
- package/dist/diff-Dobf9PHC.mjs.map +1 -0
- package/dist/index.d.mts +148 -1
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +242 -4
- package/dist/index.mjs.map +1 -1
- package/dist/scripts/smoke/baseline.mjs +25 -2
- package/dist/scripts/smoke/baseline.mjs.map +1 -1
- package/dist/smoke.mjs +25 -2
- package/dist/smoke.mjs.map +1 -1
- package/dist/verify/index.mjs +1 -1
- package/package.json +1 -1
- package/dist/diff-CBFCoTCw.mjs.map +0 -1
package/dist/index.d.mts
CHANGED
|
@@ -574,5 +574,152 @@ interface OagenConfig {
|
|
|
574
574
|
emitterOptions?: Record<string, Record<string, unknown>>;
|
|
575
575
|
}
|
|
576
576
|
//#endregion
|
|
577
|
-
|
|
577
|
+
//#region src/snippets/example-builder.d.ts
|
|
578
|
+
/**
|
|
579
|
+
* Builds illustrative example values for IR types. Used by snippet emitters
|
|
580
|
+
* to produce realistic argument values in call-site samples.
|
|
581
|
+
*
|
|
582
|
+
* Values prefer, in order:
|
|
583
|
+
* 1. An explicit `example` carried on the field/param.
|
|
584
|
+
* 2. The `default` from the schema.
|
|
585
|
+
* 3. The first enum value, when the type is an enum.
|
|
586
|
+
* 4. A type-driven default (e.g. `"string_example"`, `1`, `true`).
|
|
587
|
+
*
|
|
588
|
+
* Recursion through models/arrays/maps is depth-limited; cyclic models
|
|
589
|
+
* collapse to a placeholder object rather than blowing the stack.
|
|
590
|
+
*/
|
|
591
|
+
interface ExampleBuilder {
|
|
592
|
+
/** Build an example value for a single type reference (no field metadata). */
|
|
593
|
+
forType(type: TypeRef): unknown;
|
|
594
|
+
/** Build an example value for a field, honoring its `example`/`default`. */
|
|
595
|
+
forField(field: Field): unknown;
|
|
596
|
+
/** Build an example object from a model, keyed by field wire name. */
|
|
597
|
+
forModel(model: Model | string): Record<string, unknown>;
|
|
598
|
+
}
|
|
599
|
+
declare function createExampleBuilder(spec: ApiSpec): ExampleBuilder;
|
|
600
|
+
//#endregion
|
|
601
|
+
//#region src/snippets/types.d.ts
|
|
602
|
+
/**
|
|
603
|
+
* A call-site code sample for one SDK operation.
|
|
604
|
+
*
|
|
605
|
+
* Snippet emitters produce these instead of full SDK source files. Consumers
|
|
606
|
+
* (REST API docs builds, partner integrations, etc.) decide where to write
|
|
607
|
+
* them based on their own layout conventions — see
|
|
608
|
+
* {@link snippetResultsToFiles} for a default file-per-snippet layout.
|
|
609
|
+
*/
|
|
610
|
+
interface SnippetResult {
|
|
611
|
+
/** Language key (e.g. 'ruby', 'node'). Matches the underlying SDK emitter. */
|
|
612
|
+
language: string;
|
|
613
|
+
/** File extension without the leading dot (e.g. 'rb', 'js', 'cs'). */
|
|
614
|
+
fileExtension: string;
|
|
615
|
+
/** Stable identifier for the operation: `${mountTarget}.${methodName}`. */
|
|
616
|
+
operationId: string;
|
|
617
|
+
/** PascalCase mount target the method lives on (e.g. 'Organizations'). */
|
|
618
|
+
mountTarget: string;
|
|
619
|
+
/** snake_case method name as resolved by oagen (e.g. 'create_organization'). */
|
|
620
|
+
methodName: string;
|
|
621
|
+
/** The rendered snippet, ending in a trailing newline. */
|
|
622
|
+
content: string;
|
|
623
|
+
}
|
|
624
|
+
/**
|
|
625
|
+
* A snippet emitter renders one call-site example per resolved SDK operation
|
|
626
|
+
* in a specific language. Unlike the full {@link Emitter} contract, snippet
|
|
627
|
+
* emitters don't generate models, enums, or clients — only short, runnable
|
|
628
|
+
* call samples.
|
|
629
|
+
*
|
|
630
|
+
* Implementations typically reuse the corresponding full emitter's naming
|
|
631
|
+
* helpers (e.g. `src/<lang>/naming.ts`) so generated snippets stay in
|
|
632
|
+
* lockstep with the SDK they document. Framework primitives like
|
|
633
|
+
* {@link collectSnippetArgs} live in `@workos/oagen` so emitter authors
|
|
634
|
+
* don't have to reimplement the required-only / hidden-param / split-wrapper
|
|
635
|
+
* logic per language.
|
|
636
|
+
*/
|
|
637
|
+
interface SnippetEmitter {
|
|
638
|
+
/** Language key (must match the full emitter's `language`). */
|
|
639
|
+
language: string;
|
|
640
|
+
/** File extension without the leading dot. */
|
|
641
|
+
fileExtension: string;
|
|
642
|
+
/**
|
|
643
|
+
* Render a single resolved operation as a complete, runnable snippet.
|
|
644
|
+
*
|
|
645
|
+
* Return `null` to skip — e.g. for URL-builder operations that don't make
|
|
646
|
+
* an HTTP call, or other shapes the language SDK doesn't expose.
|
|
647
|
+
*/
|
|
648
|
+
renderOperation(resolved: ResolvedOperation, ctx: EmitterContext, examples: ExampleBuilder): string | null;
|
|
649
|
+
}
|
|
650
|
+
//#endregion
|
|
651
|
+
//#region src/snippets/runner.d.ts
|
|
652
|
+
/**
|
|
653
|
+
* Run one or more snippet emitters over every resolved operation in the spec.
|
|
654
|
+
*
|
|
655
|
+
* Iteration order matches `ctx.resolvedOperations`. For each operation the
|
|
656
|
+
* runner asks every emitter to render once; emitters that return `null`
|
|
657
|
+
* contribute nothing for that op (the URL-builder / unsupported case).
|
|
658
|
+
*
|
|
659
|
+
* Returns a flat list of {@link SnippetResult}. Consumers map these to
|
|
660
|
+
* file paths according to their own layout — see
|
|
661
|
+
* {@link snippetResultsToFiles} for a convenience that writes
|
|
662
|
+
* `<outputDir>/<language>/<methodName>-request.<ext>`.
|
|
663
|
+
*/
|
|
664
|
+
declare function runSnippetEmitters(emitters: SnippetEmitter[], ctx: EmitterContext): SnippetResult[];
|
|
665
|
+
/**
|
|
666
|
+
* Convenience: turn snippet results into oagen-style {@link GeneratedFile}s
|
|
667
|
+
* under `<outputDir>/<language>/<methodName>-request.<extension>`.
|
|
668
|
+
*
|
|
669
|
+
* Useful for consumers wired into the standard oagen file-writing pipeline.
|
|
670
|
+
* Docs builds that already have their own per-tag file layout (e.g.
|
|
671
|
+
* `content/reference/{tag}/_code/...`) typically skip this helper and route
|
|
672
|
+
* `SnippetResult.operationId` / `mountTarget` through their own mapping.
|
|
673
|
+
*/
|
|
674
|
+
declare function snippetResultsToFiles(results: SnippetResult[], outputDir?: string): GeneratedFile[];
|
|
675
|
+
//#endregion
|
|
676
|
+
//#region src/snippets/shared.d.ts
|
|
677
|
+
/**
|
|
678
|
+
* One argument resolved for a call-site snippet. The {@link wireName} stays
|
|
679
|
+
* in the spec's casing so each language emitter can apply its own
|
|
680
|
+
* field/param casing rules (snake_case for Python/Ruby/PHP, PascalCase for
|
|
681
|
+
* Go/.NET, etc.).
|
|
682
|
+
*
|
|
683
|
+
* Path and query params carry their {@link Parameter} so emitters can pick
|
|
684
|
+
* language-specific safe names; body args carry their {@link Field} so
|
|
685
|
+
* emitters can read field-level metadata (deprecated, type details).
|
|
686
|
+
*/
|
|
687
|
+
interface SnippetArg {
|
|
688
|
+
/** 'path' | 'body' | 'query' — used by emitters to pick a casing rule. */
|
|
689
|
+
source: 'path' | 'body' | 'query';
|
|
690
|
+
/** Spec wire name (e.g. `domain_data`, `client_id`). */
|
|
691
|
+
wireName: string;
|
|
692
|
+
/** Pre-computed illustrative value (string, number, array, object, ...). */
|
|
693
|
+
value: unknown;
|
|
694
|
+
/** Original parameter for path/query args, null for body fields. */
|
|
695
|
+
parameter: Parameter | null;
|
|
696
|
+
/** Original field for body args, null for path/query params. */
|
|
697
|
+
field: Field | null;
|
|
698
|
+
}
|
|
699
|
+
/**
|
|
700
|
+
* Resolve the set of required arguments for a snippet. Body fields are
|
|
701
|
+
* expanded from the request body model; defaults / inferFromClient fields
|
|
702
|
+
* are filtered out (they're injected by the SDK, not the caller).
|
|
703
|
+
*
|
|
704
|
+
* Iteration order: path params, then required body fields, then required
|
|
705
|
+
* query params. Wire-name collisions between body and path are reported in
|
|
706
|
+
* {@link collisionNames} so the emitter can rename whichever side it
|
|
707
|
+
* prefers (e.g. prefix body field with `body_`).
|
|
708
|
+
*/
|
|
709
|
+
interface CollectedArgs {
|
|
710
|
+
args: SnippetArg[];
|
|
711
|
+
/** Body field wire names that also appear as path params. */
|
|
712
|
+
collisionNames: Set<string>;
|
|
713
|
+
}
|
|
714
|
+
declare function collectSnippetArgs(resolved: ResolvedOperation, ctx: EmitterContext, examples: ExampleBuilder): CollectedArgs;
|
|
715
|
+
/**
|
|
716
|
+
* Build the arg list for a single split (wrapper) variant. The wrapper's
|
|
717
|
+
* `exposedParams` is the contract; fields are looked up on the variant model
|
|
718
|
+
* by exact name and then snake-case-normalized name. Optional status comes
|
|
719
|
+
* from `wrapper.optionalParams` first, then from the field's `required` flag.
|
|
720
|
+
*/
|
|
721
|
+
declare function collectWrapperArgs(wrapper: ResolvedWrapper, ctx: EmitterContext, examples: ExampleBuilder): SnippetArg[];
|
|
722
|
+
declare function hiddenParamSet(resolved: ResolvedOperation): Set<string>;
|
|
723
|
+
//#endregion
|
|
724
|
+
export { ACRONYM_SET, type AiAgentEnvVar, type ApiSpec, type ArrayType, type AuthScheme, type BackoffStrategy, type Change, type CollectedArgs, CommandError, ConfigError, ConfigLoadError, ConfigVersionMismatchError, type DeepPartial, type DiffReport, type Emitter, type EmitterContext, type Enum, type EnumAdded, type EnumModified, type EnumRef, type EnumRemoved, type EnumValue, type EnumValueChange, type ErrorPolicy, type ErrorResponse, type ExampleBuilder, ExtractorError, type Field, type FieldChange, type FormatCommand, type GeneratedFile, type HttpMethod, type IdempotencyPolicy, InternalError, type LiteralType, type LogEvent, type LoggingPolicy, type MapType, type Model, type ModelAdded, type ModelModified, type ModelRef, type ModelRemoved, type NullableType, type OagenConfig, OagenError, type OpenApiDocument, type Operation, type OperationAdded, type OperationHint, type OperationModified, type OperationPlan, type OperationRemoved, type OperationsMap, type OperationsMapEntry, type PaginationMeta, type PaginationPolicy, type ParamChange, type Parameter, type ParameterGroup, type ParameterGroupVariant, type ParseOptions, type PrimitiveType, RegistryError, type RequestGuardPolicy, type ResolvedOperation, type ResolvedWrapper, type RetryPolicy, type SdkBehavior, type SecurityRequirement, type ServerEntry, type Service, type ServiceAdded, type ServiceRemoved, type SnippetArg, type SnippetEmitter, type SnippetResult, SpecParseError, type SplitHint, type SuccessResponse, type TelemetryPolicy, type TimeoutPolicy, type TypeParam, type TypeRef, type UnionType, type UserAgentPolicy, applyFileHeaders, assertNever, assignModelsToServices, buildEmitterContext, cleanSchemaName, collectEnumRefs, collectFieldDependencies, collectModelRefs, collectReferencedNames, collectRequestBodyModels, collectSnippetArgs, collectWrapperArgs, createExampleBuilder, defaultSdkBehavior, deriveMethodName, diffSpecs, generate, generateAllFiles, generateFiles, getEmitter, hiddenParamSet, integrateGeneratedFiles, mapFilesForTargetIntegration, mapTypeRef, mergeSdkBehavior, parseSpec, planOperation, registerEmitter, resolveOperations, runSnippetEmitters, snippetResultsToFiles, stripBackendPrefixes, toCamelCase, toKebabCase, toPascalCase, toSnakeCase, toUpperSnakeCase, treeShakeFiles, walkTypeRef };
|
|
578
725
|
//# sourceMappingURL=index.d.mts.map
|
package/dist/index.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.mts","names":[],"sources":["../src/ir/operation-hints.ts","../src/errors.ts","../src/engine/types.ts","../src/differ/types.ts","../src/parser/parse.ts","../src/engine/orchestrator.ts","../src/engine/generate-files.ts","../src/engine/writer.ts","../src/engine/integrate.ts","../src/engine/registry.ts","../src/differ/diff.ts","../src/utils/naming.ts","../src/engine/operation-plan.ts","../src/cli/config-loader.ts"],"mappings":";;;;UAeiB,aAAA;EAAA;EAEf,IAAA;;EAEA,OAAA;EAFA;EAIA,KAAA,GAAQ,SAAA;EAAR;EAEA,QAAA,GAAW,MAAA;EAAX;EAEA,eAAA;EAAA;;;;AAUF;;EAHE,UAAA;AAAA;AAAA,UAGe,SAAA;EAIf;EAFA,IAAA;EAIW;EAFX,aAAA;EAMA;EAJA,QAAA,GAAW,MAAA;EAUG;EARd,eAAA;EAee;EAbf,aAAA;;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A,CAAU,OAAA,EAAS,OAAA,EAAS,OAAA,EAAS,OAAA,GAAU,UAAA;;;cCuDlD,WAAA,EAAW,GAAA;AAAA,iBAER,YAAA,CAAa,CAAA,UAAW,QAAA,GAAW,GAAA;AAAA,iBAanC,WAAA,CAAY,CAAA,UAAW,QAAA,GAAW,GAAA;AAAA,iBAelC,WAAA,CAAY,CAAA;AAAA,iBAMZ,WAAA,CAAY,CAAA;AAAA,iBAMZ,gBAAA,CAAiB,CAAA;AAAA,iBAiBjB,oBAAA,CAAqB,IAAA;AAAA,iBAqErB,eAAA,CAAgB,IAAA;;;UCzLf,aAAA;EACf,SAAA,EAAW,SAAA;EACX,QAAA;EACA,OAAA;EACA,gBAAA;EACA,mBAAA;EACA,WAAA;EACA,iBAAA;EZWA;;EYRA,sBAAA;EACA,eAAA;EZWA;;;EYPA,eAAA;EACA,cAAA;EACA,OAAA;AAAA;AAAA,iBAGc,aAAA,CAAc,EAAA,EAAI,SAAA,GAAY,aAAA;;;UCb7B,WAAA;EACf,QAAA,GAAW,OAAA;EACX,UAAA,GAAa,SAAA;EbOb;EaLA,MAAA,GAAS,YAAA;EbOD;EaLR,cAAA;EbOW;EaLX,YAAA,GAAe,MAAA;Ebcf;;;AAGF;;;EaVE,oBAAA,IAAwB,EAAA;EbYxB;;;;;;EaLA,mBAAA,IAAuB,IAAA;EbmBT;;EahBd,MAAA;EbuBgC;;;;;;;;;;;EaXhC,aAAA,IAAiB,IAAA,EAAM,eAAA,KAAoB,eAAA;EbiB3C;;;;;EaXA,cAAA,GAAiB,MAAA,SAAe,aAAA;EbmBhC;;;;AAKF;;EajBE,UAAA,GAAa,MAAA;EbuBG;;;;;;;;;;;AAoFlB;Ea9FE,UAAA,GAAa,MAAA;;;;;EAKb,cAAA,GAAiB,MAAA,SAAe,MAAA;AAAA"}
|
|
1
|
+
{"version":3,"file":"index.d.mts","names":[],"sources":["../src/ir/operation-hints.ts","../src/errors.ts","../src/engine/types.ts","../src/differ/types.ts","../src/parser/parse.ts","../src/engine/orchestrator.ts","../src/engine/generate-files.ts","../src/engine/writer.ts","../src/engine/integrate.ts","../src/engine/registry.ts","../src/differ/diff.ts","../src/utils/naming.ts","../src/engine/operation-plan.ts","../src/cli/config-loader.ts","../src/snippets/example-builder.ts","../src/snippets/types.ts","../src/snippets/runner.ts","../src/snippets/shared.ts"],"mappings":";;;;UAeiB,aAAA;EAAA;EAEf,IAAA;;EAEA,OAAA;EAFA;EAIA,KAAA,GAAQ,SAAA;EAAR;EAEA,QAAA,GAAW,MAAA;EAAX;EAEA,eAAA;EAAA;;;;AAUF;;EAHE,UAAA;AAAA;AAAA,UAGe,SAAA;EAIf;EAFA,IAAA;EAIW;EAFX,aAAA;EAMA;EAJA,QAAA,GAAW,MAAA;EAUG;EARd,eAAA;EAee;EAbf,aAAA;;;;;;EAMA,cAAA;AAAA;AAAA,UAOe,iBAAA;EAEJ;EAAX,SAAA,EAAW,SAAA;EAEF;EAAT,OAAA,EAAS,OAAA;EAIT;EAFA,UAAA;EAIW;EAFX,OAAA;EAIU;EAFV,QAAA,GAAW,eAAA;EAMX;EAJA,QAAA,EAAU,MAAA;EAIA;EAFV,eAAA;EAK8B;EAH9B,UAAA;AAAA;AAAA,UAGe,eAAA;EAIf;EAFA,IAAA;EAIU;EAFV,aAAA;EAMA;EAJA,QAAA,EAAU,MAAA;EAQV;EANA,eAAA;EAMiB;EAJjB,aAAA;EAgF8B;EA9E9B,cAAA;EA8E+D;EA5E/D,iBAAA;AAAA;;;;;AA2JF;;;;;;;iBA/EgB,gBAAA,CAAiB,EAAA,EAAI,SAAA,EAAW,QAAA,EAAU,OAAA;;;;;;;;;iBA+E1C,iBAAA,CACd,IAAA,EAAM,OAAA,EACN,KAAA,GAAQ,MAAA,SAAe,aAAA,GACvB,UAAA,GAAa,MAAA,mBACZ,iBAAA;;;;;;AA3OH;;;;cCPa,UAAA,SAAmB,KAAA;EAAA,SACrB,IAAA;cAEG,OAAA,UAAiB,IAAA;AAAA;;cASlB,Y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;EiBff,QAAA;;EAEA,KAAA;EjBeA;EiBbA,SAAA,EAAW,SAAA;EjBiBX;EiBfA,KAAA,EAAO,KAAA;AAAA;;;;;AjBgCT;;;;;;UiBnBiB,aAAA;EACf,IAAA,EAAM,UAAA;EjB8BU;EiB5BhB,cAAA,EAAgB,GAAA;AAAA;AAAA,iBAGF,kBAAA,CACd,QAAA,EAAU,iBAAA,EACV,GAAA,EAAK,cAAA,EACL,QAAA,EAAU,cAAA,GACT,aAAA;;;;;;;iBA2Da,kBAAA,CACd,OAAA,EAAS,eAAA,EACT,GAAA,EAAK,cAAA,EACL,QAAA,EAAU,cAAA,GACT,UAAA;AAAA,iBAuBa,cAAA,CAAe,QAAA,EAAU,iBAAA,GAAoB,GAAA"}
|
package/dist/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { A as walkTypeRef, C as assertNever, D as collectModelRefs, E as collectFieldDependencies, O as collectRequestBodyModels, S as SpecParseError, T as collectEnumRefs, _ as ConfigVersionMismatchError, a as singularize, b as OagenError, c as stripListItemMarkers, d as toPascalCase, f as toSnakeCase, g as ConfigLoadError, h as ConfigError, k as mapTypeRef, l as toCamelCase, m as CommandError, n as ACRONYM_SET, o as splitWords, p as toUpperSnakeCase, r as cleanSchemaName, s as stripBackendPrefixes, u as toKebabCase, v as ExtractorError, w as assignModelsToServices, x as RegistryError, y as InternalError } from "./tree-sitter-DcUvm0KA.mjs";
|
|
2
|
-
import { c as treeShakeFiles, d as collectReferencedNames, f as generateAllFiles, h as resolveOperations, i as generate, l as applyFileHeaders, m as deriveMethodName, n as getEmitter, o as integrateGeneratedFiles, p as generateFiles, r as registerEmitter, s as mapFilesForTargetIntegration, t as diffSpecs, u as buildEmitterContext } from "./diff-
|
|
2
|
+
import { c as treeShakeFiles, d as collectReferencedNames, f as generateAllFiles, h as resolveOperations, i as generate, l as applyFileHeaders, m as deriveMethodName, n as getEmitter, o as integrateGeneratedFiles, p as generateFiles, r as registerEmitter, s as mapFilesForTargetIntegration, t as diffSpecs, u as buildEmitterContext } from "./diff-Dobf9PHC.mjs";
|
|
3
3
|
import { readFile } from "node:fs/promises";
|
|
4
4
|
import { resolve } from "node:path";
|
|
5
5
|
import { pathToFileURL } from "node:url";
|
|
@@ -185,7 +185,7 @@ function qualifyInlineModelName(baseName, parentName) {
|
|
|
185
185
|
function extractInlineModelsFromSchemas(schemas) {
|
|
186
186
|
if (!schemas) return [];
|
|
187
187
|
const inlineModels = [];
|
|
188
|
-
for (const [schemaName, schema] of Object.entries(schemas)) extractInlineModelsFromProperties(schema, inlineModels,
|
|
188
|
+
for (const [schemaName, schema] of Object.entries(schemas)) extractInlineModelsFromProperties(schema, inlineModels, resolveSchemaName(schemaName));
|
|
189
189
|
return inlineModels;
|
|
190
190
|
}
|
|
191
191
|
function extractInlineModelsFromProperties(schema, results, parentName) {
|
|
@@ -2369,6 +2369,27 @@ function collapseJsonSuffixModels(models, services) {
|
|
|
2369
2369
|
rewriteModelRefs(normalizedModels, services, jsonModel.name, baseModel.name);
|
|
2370
2370
|
console.warn(`[oagen] Merged "${jsonModel.name}" into "${baseModel.name}" (${jsonModel.fields.length} fields, superset)`);
|
|
2371
2371
|
}
|
|
2372
|
+
for (const { jsonModel, baseModel } of mergeCandidates) {
|
|
2373
|
+
const jsonPrefix = jsonModel.name;
|
|
2374
|
+
const basePrefix = baseModel.name;
|
|
2375
|
+
for (const model of normalizedModels) {
|
|
2376
|
+
if (toRemove.has(model.name)) continue;
|
|
2377
|
+
if (model.name.length <= jsonPrefix.length) continue;
|
|
2378
|
+
if (!model.name.startsWith(jsonPrefix)) continue;
|
|
2379
|
+
const newName = basePrefix + model.name.slice(jsonPrefix.length);
|
|
2380
|
+
const existing = byName.get(newName);
|
|
2381
|
+
if (existing && !toRemove.has(existing.name)) {
|
|
2382
|
+
toRemove.add(model.name);
|
|
2383
|
+
rewriteModelRefs(normalizedModels, services, model.name, newName);
|
|
2384
|
+
console.warn(`[oagen] Collapsed child "${model.name}" into existing "${newName}"`);
|
|
2385
|
+
} else {
|
|
2386
|
+
rewriteModelRefs(normalizedModels, services, model.name, newName);
|
|
2387
|
+
model.name = newName;
|
|
2388
|
+
byName.set(newName, model);
|
|
2389
|
+
console.warn(`[oagen] Renamed child "${jsonPrefix}…" → "${newName}"`);
|
|
2390
|
+
}
|
|
2391
|
+
}
|
|
2392
|
+
}
|
|
2372
2393
|
return normalizedModels.filter((m) => !toRemove.has(m.name));
|
|
2373
2394
|
}
|
|
2374
2395
|
//#endregion
|
|
@@ -2421,8 +2442,10 @@ async function parseSpec(specPath, options) {
|
|
|
2421
2442
|
if (!version.startsWith("3.")) throw new SpecParseError(`Unsupported OpenAPI version: ${version}. oagen requires OpenAPI 3.x`, `Update the spec to OpenAPI 3.0 or 3.1. If you are using Swagger 2.x, convert it first with \`npx swagger2openapi ${specPath}\`.`);
|
|
2422
2443
|
const { models, enums } = extractSchemas(spec.components?.schemas, { schemaNameTransform: options?.schemaNameTransform });
|
|
2423
2444
|
const { services, inlineModels } = extractOperations(spec.paths, options?.operationIdTransform, spec.components?.schemas);
|
|
2445
|
+
const responseNormalizedModels = mergeInlineResponseModels(models, inlineModels);
|
|
2446
|
+
const fieldInlineModels = extractInlineModelsFromSchemas(spec.components?.schemas);
|
|
2424
2447
|
clearSchemaNameTransform();
|
|
2425
|
-
const finalModels = collapseJsonSuffixModels(mergeFieldInlineModels(
|
|
2448
|
+
const finalModels = collapseJsonSuffixModels(mergeFieldInlineModels(responseNormalizedModels, fieldInlineModels), services);
|
|
2426
2449
|
collectInlineEnumsFromModels(finalModels, enums);
|
|
2427
2450
|
collectInlineEnumsFromOperations(services, enums);
|
|
2428
2451
|
const auth = extractAuthSchemes(spec.components?.securitySchemes);
|
|
@@ -2507,6 +2530,221 @@ function extractModelName(ref) {
|
|
|
2507
2530
|
}
|
|
2508
2531
|
}
|
|
2509
2532
|
//#endregion
|
|
2510
|
-
|
|
2533
|
+
//#region src/snippets/example-builder.ts
|
|
2534
|
+
const MAX_DEPTH = 6;
|
|
2535
|
+
function createExampleBuilder(spec) {
|
|
2536
|
+
const modelsByName = /* @__PURE__ */ new Map();
|
|
2537
|
+
for (const m of spec.models) modelsByName.set(m.name, m);
|
|
2538
|
+
const enumsByName = /* @__PURE__ */ new Map();
|
|
2539
|
+
for (const e of spec.enums) enumsByName.set(e.name, e);
|
|
2540
|
+
function buildForType(type, depth) {
|
|
2541
|
+
if (depth > MAX_DEPTH) return null;
|
|
2542
|
+
switch (type.kind) {
|
|
2543
|
+
case "primitive": return primitiveExample(type.type, type.format);
|
|
2544
|
+
case "literal": return type.value;
|
|
2545
|
+
case "enum":
|
|
2546
|
+
if (type.values && type.values.length > 0) return type.values[0];
|
|
2547
|
+
return enumsByName.get(type.name)?.values[0]?.value ?? null;
|
|
2548
|
+
case "array": return [buildForType(type.items, depth + 1)];
|
|
2549
|
+
case "nullable": return buildForType(type.inner, depth);
|
|
2550
|
+
case "union": {
|
|
2551
|
+
const first = type.variants[0];
|
|
2552
|
+
return first ? buildForType(first, depth) : null;
|
|
2553
|
+
}
|
|
2554
|
+
case "map": {
|
|
2555
|
+
const key = "key";
|
|
2556
|
+
const value = buildForType(type.valueType, depth + 1);
|
|
2557
|
+
return { [key]: value };
|
|
2558
|
+
}
|
|
2559
|
+
case "model": return buildForModel(type.name, depth + 1);
|
|
2560
|
+
default: return null;
|
|
2561
|
+
}
|
|
2562
|
+
}
|
|
2563
|
+
function buildForModel(nameOrModel, depth) {
|
|
2564
|
+
if (depth > MAX_DEPTH) return {};
|
|
2565
|
+
const model = typeof nameOrModel === "string" ? modelsByName.get(nameOrModel) : nameOrModel;
|
|
2566
|
+
if (!model) return {};
|
|
2567
|
+
const result = {};
|
|
2568
|
+
for (const field of model.fields) {
|
|
2569
|
+
if (field.deprecated || field.readOnly) continue;
|
|
2570
|
+
result[field.name] = buildForField(field, depth);
|
|
2571
|
+
}
|
|
2572
|
+
return result;
|
|
2573
|
+
}
|
|
2574
|
+
function buildForField(field, depth) {
|
|
2575
|
+
if (field.example !== void 0) return field.example;
|
|
2576
|
+
if (field.default !== void 0) return field.default;
|
|
2577
|
+
return buildForType(field.type, depth);
|
|
2578
|
+
}
|
|
2579
|
+
return {
|
|
2580
|
+
forType: (type) => buildForType(type, 0),
|
|
2581
|
+
forField: (field) => buildForField(field, 0),
|
|
2582
|
+
forModel: (model) => buildForModel(model, 0)
|
|
2583
|
+
};
|
|
2584
|
+
}
|
|
2585
|
+
function primitiveExample(type, format) {
|
|
2586
|
+
switch (type) {
|
|
2587
|
+
case "string":
|
|
2588
|
+
if (format === "date-time") return "2026-01-15T12:00:00.000Z";
|
|
2589
|
+
if (format === "date") return "2026-01-15";
|
|
2590
|
+
if (format === "email") return "user@example.com";
|
|
2591
|
+
if (format === "uri" || format === "url") return "https://example.com";
|
|
2592
|
+
if (format === "uuid") return "00000000-0000-0000-0000-000000000000";
|
|
2593
|
+
return "string_example";
|
|
2594
|
+
case "integer":
|
|
2595
|
+
case "number": return 1;
|
|
2596
|
+
case "boolean": return true;
|
|
2597
|
+
default: return null;
|
|
2598
|
+
}
|
|
2599
|
+
}
|
|
2600
|
+
//#endregion
|
|
2601
|
+
//#region src/snippets/runner.ts
|
|
2602
|
+
/**
|
|
2603
|
+
* Run one or more snippet emitters over every resolved operation in the spec.
|
|
2604
|
+
*
|
|
2605
|
+
* Iteration order matches `ctx.resolvedOperations`. For each operation the
|
|
2606
|
+
* runner asks every emitter to render once; emitters that return `null`
|
|
2607
|
+
* contribute nothing for that op (the URL-builder / unsupported case).
|
|
2608
|
+
*
|
|
2609
|
+
* Returns a flat list of {@link SnippetResult}. Consumers map these to
|
|
2610
|
+
* file paths according to their own layout — see
|
|
2611
|
+
* {@link snippetResultsToFiles} for a convenience that writes
|
|
2612
|
+
* `<outputDir>/<language>/<methodName>-request.<ext>`.
|
|
2613
|
+
*/
|
|
2614
|
+
function runSnippetEmitters(emitters, ctx) {
|
|
2615
|
+
const resolved = ctx.resolvedOperations;
|
|
2616
|
+
if (!resolved || resolved.length === 0) return [];
|
|
2617
|
+
const examples = createExampleBuilder(ctx.spec);
|
|
2618
|
+
const results = [];
|
|
2619
|
+
for (const op of resolved) for (const emitter of emitters) {
|
|
2620
|
+
const content = emitter.renderOperation(op, ctx, examples);
|
|
2621
|
+
if (content === null) continue;
|
|
2622
|
+
results.push({
|
|
2623
|
+
language: emitter.language,
|
|
2624
|
+
fileExtension: emitter.fileExtension,
|
|
2625
|
+
operationId: operationIdFor(op),
|
|
2626
|
+
mountTarget: op.mountOn,
|
|
2627
|
+
methodName: op.methodName,
|
|
2628
|
+
content: ensureTrailingNewline(content)
|
|
2629
|
+
});
|
|
2630
|
+
}
|
|
2631
|
+
return results;
|
|
2632
|
+
}
|
|
2633
|
+
/**
|
|
2634
|
+
* Convenience: turn snippet results into oagen-style {@link GeneratedFile}s
|
|
2635
|
+
* under `<outputDir>/<language>/<methodName>-request.<extension>`.
|
|
2636
|
+
*
|
|
2637
|
+
* Useful for consumers wired into the standard oagen file-writing pipeline.
|
|
2638
|
+
* Docs builds that already have their own per-tag file layout (e.g.
|
|
2639
|
+
* `content/reference/{tag}/_code/...`) typically skip this helper and route
|
|
2640
|
+
* `SnippetResult.operationId` / `mountTarget` through their own mapping.
|
|
2641
|
+
*/
|
|
2642
|
+
function snippetResultsToFiles(results, outputDir = "snippets") {
|
|
2643
|
+
return results.map((r) => ({
|
|
2644
|
+
path: `${outputDir}/${r.language}/${r.methodName}-request.${r.fileExtension}`,
|
|
2645
|
+
content: r.content,
|
|
2646
|
+
overwriteExisting: true,
|
|
2647
|
+
integrateTarget: false
|
|
2648
|
+
}));
|
|
2649
|
+
}
|
|
2650
|
+
function operationIdFor(op) {
|
|
2651
|
+
return `${op.mountOn}.${op.methodName}`;
|
|
2652
|
+
}
|
|
2653
|
+
function ensureTrailingNewline(s) {
|
|
2654
|
+
return s.endsWith("\n") ? s : `${s}\n`;
|
|
2655
|
+
}
|
|
2656
|
+
//#endregion
|
|
2657
|
+
//#region src/snippets/shared.ts
|
|
2658
|
+
function collectSnippetArgs(resolved, ctx, examples) {
|
|
2659
|
+
const op = resolved.operation;
|
|
2660
|
+
const hidden = hiddenParamSet(resolved);
|
|
2661
|
+
const args = [];
|
|
2662
|
+
const pathWireNames = /* @__PURE__ */ new Set();
|
|
2663
|
+
for (const p of op.pathParams) {
|
|
2664
|
+
if (!p.required) continue;
|
|
2665
|
+
if (hidden.has(p.name)) continue;
|
|
2666
|
+
pathWireNames.add(p.name);
|
|
2667
|
+
args.push({
|
|
2668
|
+
source: "path",
|
|
2669
|
+
wireName: p.name,
|
|
2670
|
+
value: exampleForParam(p, examples),
|
|
2671
|
+
parameter: p,
|
|
2672
|
+
field: null
|
|
2673
|
+
});
|
|
2674
|
+
}
|
|
2675
|
+
const collisionNames = /* @__PURE__ */ new Set();
|
|
2676
|
+
if (op.requestBody?.kind === "model") {
|
|
2677
|
+
const bodyModel = findModel(ctx, op.requestBody.name);
|
|
2678
|
+
if (bodyModel) for (const f of bodyModel.fields) {
|
|
2679
|
+
if (!f.required || f.deprecated) continue;
|
|
2680
|
+
if (hidden.has(f.name)) continue;
|
|
2681
|
+
if (pathWireNames.has(f.name)) collisionNames.add(f.name);
|
|
2682
|
+
args.push({
|
|
2683
|
+
source: "body",
|
|
2684
|
+
wireName: f.name,
|
|
2685
|
+
value: exampleForField(f, examples),
|
|
2686
|
+
parameter: null,
|
|
2687
|
+
field: f
|
|
2688
|
+
});
|
|
2689
|
+
}
|
|
2690
|
+
}
|
|
2691
|
+
for (const q of op.queryParams) {
|
|
2692
|
+
if (!q.required) continue;
|
|
2693
|
+
if (hidden.has(q.name)) continue;
|
|
2694
|
+
args.push({
|
|
2695
|
+
source: "query",
|
|
2696
|
+
wireName: q.name,
|
|
2697
|
+
value: exampleForParam(q, examples),
|
|
2698
|
+
parameter: q,
|
|
2699
|
+
field: null
|
|
2700
|
+
});
|
|
2701
|
+
}
|
|
2702
|
+
return {
|
|
2703
|
+
args,
|
|
2704
|
+
collisionNames
|
|
2705
|
+
};
|
|
2706
|
+
}
|
|
2707
|
+
/**
|
|
2708
|
+
* Build the arg list for a single split (wrapper) variant. The wrapper's
|
|
2709
|
+
* `exposedParams` is the contract; fields are looked up on the variant model
|
|
2710
|
+
* by exact name and then snake-case-normalized name. Optional status comes
|
|
2711
|
+
* from `wrapper.optionalParams` first, then from the field's `required` flag.
|
|
2712
|
+
*/
|
|
2713
|
+
function collectWrapperArgs(wrapper, ctx, examples) {
|
|
2714
|
+
const variantFields = ctx.spec.models.find((m) => m.name === wrapper.targetVariant)?.fields ?? [];
|
|
2715
|
+
const optionalSet = new Set(wrapper.optionalParams);
|
|
2716
|
+
const args = [];
|
|
2717
|
+
for (const paramName of wrapper.exposedParams) {
|
|
2718
|
+
const field = variantFields.find((f) => f.name === paramName || toSnakeCase(f.name) === toSnakeCase(paramName)) ?? null;
|
|
2719
|
+
if (optionalSet.has(paramName) ? true : field ? !field.required : false) continue;
|
|
2720
|
+
args.push({
|
|
2721
|
+
source: "body",
|
|
2722
|
+
wireName: paramName,
|
|
2723
|
+
value: field ? examples.forField(field) : "string_example",
|
|
2724
|
+
parameter: null,
|
|
2725
|
+
field
|
|
2726
|
+
});
|
|
2727
|
+
}
|
|
2728
|
+
return args;
|
|
2729
|
+
}
|
|
2730
|
+
function hiddenParamSet(resolved) {
|
|
2731
|
+
const hidden = /* @__PURE__ */ new Set();
|
|
2732
|
+
for (const k of Object.keys(resolved.defaults)) hidden.add(k);
|
|
2733
|
+
for (const k of resolved.inferFromClient) hidden.add(k);
|
|
2734
|
+
return hidden;
|
|
2735
|
+
}
|
|
2736
|
+
function findModel(ctx, name) {
|
|
2737
|
+
return ctx.spec.models.find((m) => m.name === name);
|
|
2738
|
+
}
|
|
2739
|
+
function exampleForParam(p, examples) {
|
|
2740
|
+
if (p.example !== void 0) return p.example;
|
|
2741
|
+
if (p.default !== void 0) return p.default;
|
|
2742
|
+
return examples.forType(p.type);
|
|
2743
|
+
}
|
|
2744
|
+
function exampleForField(f, examples) {
|
|
2745
|
+
return examples.forField(f);
|
|
2746
|
+
}
|
|
2747
|
+
//#endregion
|
|
2748
|
+
export { ACRONYM_SET, CommandError, ConfigError, ConfigLoadError, ConfigVersionMismatchError, ExtractorError, InternalError, OagenError, RegistryError, SpecParseError, applyFileHeaders, assertNever, assignModelsToServices, buildEmitterContext, cleanSchemaName, collectEnumRefs, collectFieldDependencies, collectModelRefs, collectReferencedNames, collectRequestBodyModels, collectSnippetArgs, collectWrapperArgs, createExampleBuilder, defaultSdkBehavior, deriveMethodName, diffSpecs, generate, generateAllFiles, generateFiles, getEmitter, hiddenParamSet, integrateGeneratedFiles, mapFilesForTargetIntegration, mapTypeRef, mergeSdkBehavior, parseSpec, planOperation, registerEmitter, resolveOperations, runSnippetEmitters, snippetResultsToFiles, stripBackendPrefixes, toCamelCase, toKebabCase, toPascalCase, toSnakeCase, toUpperSnakeCase, treeShakeFiles, walkTypeRef };
|
|
2511
2749
|
|
|
2512
2750
|
//# sourceMappingURL=index.mjs.map
|