@workos/oagen 0.27.0 → 0.28.1
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 +110 -11
- package/dist/cli/index.mjs.map +1 -1
- package/dist/compat/index.mjs +37 -1
- package/dist/compat/index.mjs.map +1 -1
- package/dist/{diff-B9wlNAVX.mjs → diff-DqnHHXvr.mjs} +112 -13
- package/dist/diff-DqnHHXvr.mjs.map +1 -0
- package/dist/index.d.mts +27 -1
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +2 -2
- package/dist/verify/index.mjs +1 -1
- package/package.json +1 -1
- package/dist/diff-B9wlNAVX.mjs.map +0 -1
|
@@ -3747,14 +3747,107 @@ function getEmitter(language) {
|
|
|
3747
3747
|
return emitter;
|
|
3748
3748
|
}
|
|
3749
3749
|
//#endregion
|
|
3750
|
+
//#region src/differ/direction.ts
|
|
3751
|
+
/**
|
|
3752
|
+
* Classify every model in `specs` as request-facing, response-facing, both, or
|
|
3753
|
+
* unknown.
|
|
3754
|
+
*
|
|
3755
|
+
* Pass both the baseline and the candidate spec: a model that was request-facing
|
|
3756
|
+
* in either one keeps its request direction for the whole diff, so a schema that
|
|
3757
|
+
* moves request → response mid-release doesn't get that release's requiredness
|
|
3758
|
+
* changes silently downgraded.
|
|
3759
|
+
*
|
|
3760
|
+
* Models reachable from neither side (unreferenced schemas, or a spec whose
|
|
3761
|
+
* operations weren't supplied) stay `unknown`, which preserves the conservative
|
|
3762
|
+
* pre-direction classification.
|
|
3763
|
+
*/
|
|
3764
|
+
function buildDirectionIndex(...specs) {
|
|
3765
|
+
const models = /* @__PURE__ */ new Map();
|
|
3766
|
+
for (const spec of specs) for (const model of spec.models) if (!models.has(model.name)) models.set(model.name, model);
|
|
3767
|
+
const requestSeeds = [];
|
|
3768
|
+
const responseSeeds = [];
|
|
3769
|
+
for (const spec of specs) for (const service of spec.services) for (const op of service.operations) {
|
|
3770
|
+
if (op.requestBody) requestSeeds.push(op.requestBody);
|
|
3771
|
+
for (const param of [
|
|
3772
|
+
...op.pathParams,
|
|
3773
|
+
...op.queryParams,
|
|
3774
|
+
...op.headerParams,
|
|
3775
|
+
...op.cookieParams ?? []
|
|
3776
|
+
]) requestSeeds.push(param.type);
|
|
3777
|
+
responseSeeds.push(op.response);
|
|
3778
|
+
for (const success of op.successResponses ?? []) responseSeeds.push(success.type);
|
|
3779
|
+
for (const error of op.errors) if (error.type) responseSeeds.push(error.type);
|
|
3780
|
+
}
|
|
3781
|
+
const request = reachableModels(requestSeeds, models);
|
|
3782
|
+
const response = reachableModels(responseSeeds, models);
|
|
3783
|
+
const index = /* @__PURE__ */ new Map();
|
|
3784
|
+
for (const name of models.keys()) {
|
|
3785
|
+
const inRequest = request.has(name);
|
|
3786
|
+
const inResponse = response.has(name);
|
|
3787
|
+
index.set(name, inRequest && inResponse ? "both" : inRequest ? "request" : inResponse ? "response" : "unknown");
|
|
3788
|
+
}
|
|
3789
|
+
return index;
|
|
3790
|
+
}
|
|
3791
|
+
function directionOf(index, modelName) {
|
|
3792
|
+
return index?.get(modelName) ?? "unknown";
|
|
3793
|
+
}
|
|
3794
|
+
/**
|
|
3795
|
+
* Every model name reachable from `seeds`, following model fields (and
|
|
3796
|
+
* discriminated-union variants) transitively.
|
|
3797
|
+
*/
|
|
3798
|
+
function reachableModels(seeds, models) {
|
|
3799
|
+
const found = /* @__PURE__ */ new Set();
|
|
3800
|
+
const queue = [...seeds];
|
|
3801
|
+
while (queue.length > 0) {
|
|
3802
|
+
const ref = queue.pop();
|
|
3803
|
+
switch (ref.kind) {
|
|
3804
|
+
case "model": {
|
|
3805
|
+
if (found.has(ref.name)) break;
|
|
3806
|
+
found.add(ref.name);
|
|
3807
|
+
const model = models.get(ref.name);
|
|
3808
|
+
if (!model) break;
|
|
3809
|
+
for (const field of model.fields) queue.push(field.type);
|
|
3810
|
+
for (const variant of Object.values(model.discriminator?.mapping ?? {})) queue.push({
|
|
3811
|
+
kind: "model",
|
|
3812
|
+
name: variant
|
|
3813
|
+
});
|
|
3814
|
+
break;
|
|
3815
|
+
}
|
|
3816
|
+
case "array":
|
|
3817
|
+
queue.push(ref.items);
|
|
3818
|
+
break;
|
|
3819
|
+
case "nullable":
|
|
3820
|
+
queue.push(ref.inner);
|
|
3821
|
+
break;
|
|
3822
|
+
case "map":
|
|
3823
|
+
queue.push(ref.valueType);
|
|
3824
|
+
break;
|
|
3825
|
+
case "union":
|
|
3826
|
+
queue.push(...ref.variants);
|
|
3827
|
+
break;
|
|
3828
|
+
case "primitive":
|
|
3829
|
+
case "enum":
|
|
3830
|
+
case "literal": break;
|
|
3831
|
+
}
|
|
3832
|
+
}
|
|
3833
|
+
return found;
|
|
3834
|
+
}
|
|
3835
|
+
//#endregion
|
|
3750
3836
|
//#region src/differ/classify.ts
|
|
3751
|
-
function classifyFieldChange(kind, fieldName, isRequired) {
|
|
3837
|
+
function classifyFieldChange(kind, fieldName, isRequired, direction = "unknown") {
|
|
3752
3838
|
switch (kind) {
|
|
3753
|
-
case "field-added":
|
|
3754
|
-
|
|
3755
|
-
|
|
3756
|
-
|
|
3757
|
-
|
|
3839
|
+
case "field-added":
|
|
3840
|
+
if (isRequired && direction === "response") return {
|
|
3841
|
+
kind,
|
|
3842
|
+
fieldName,
|
|
3843
|
+
classification: "additive",
|
|
3844
|
+
details: "required on a response-only model"
|
|
3845
|
+
};
|
|
3846
|
+
return {
|
|
3847
|
+
kind,
|
|
3848
|
+
fieldName,
|
|
3849
|
+
classification: isRequired ? "breaking" : "additive"
|
|
3850
|
+
};
|
|
3758
3851
|
case "field-removed": return {
|
|
3759
3852
|
kind,
|
|
3760
3853
|
fieldName,
|
|
@@ -3819,7 +3912,12 @@ function classifyParamChange(kind, paramName, isRequired) {
|
|
|
3819
3912
|
}
|
|
3820
3913
|
//#endregion
|
|
3821
3914
|
//#region src/differ/models.ts
|
|
3822
|
-
|
|
3915
|
+
/**
|
|
3916
|
+
* `directions` (from `buildDirectionIndex`) lets requiredness changes be judged
|
|
3917
|
+
* against the side of the wire each model is used on. Omit it and every model is
|
|
3918
|
+
* treated as unknown-direction, i.e. the conservative classification.
|
|
3919
|
+
*/
|
|
3920
|
+
function diffModels(oldModels, newModels, directions) {
|
|
3823
3921
|
const changes = [];
|
|
3824
3922
|
const oldByName = new Map(oldModels.map((m) => [m.name, m]));
|
|
3825
3923
|
const newByName = new Map(newModels.map((m) => [m.name, m]));
|
|
@@ -3836,7 +3934,7 @@ function diffModels(oldModels, newModels) {
|
|
|
3836
3934
|
for (const [name, newModel] of newByName) {
|
|
3837
3935
|
const oldModel = oldByName.get(name);
|
|
3838
3936
|
if (!oldModel) continue;
|
|
3839
|
-
const fieldChanges = diffFields(oldModel, newModel);
|
|
3937
|
+
const fieldChanges = diffFields(oldModel, newModel, directionOf(directions, name));
|
|
3840
3938
|
if (fieldChanges.length > 0) {
|
|
3841
3939
|
const hasBreaking = fieldChanges.some((fc) => fc.classification === "breaking");
|
|
3842
3940
|
changes.push({
|
|
@@ -3849,11 +3947,11 @@ function diffModels(oldModels, newModels) {
|
|
|
3849
3947
|
}
|
|
3850
3948
|
return changes;
|
|
3851
3949
|
}
|
|
3852
|
-
function diffFields(oldModel, newModel) {
|
|
3950
|
+
function diffFields(oldModel, newModel, direction = "unknown") {
|
|
3853
3951
|
const changes = [];
|
|
3854
3952
|
const oldByName = new Map(oldModel.fields.map((f) => [f.name, f]));
|
|
3855
3953
|
const newByName = new Map(newModel.fields.map((f) => [f.name, f]));
|
|
3856
|
-
for (const [name, field] of newByName) if (!oldByName.has(name)) changes.push(classifyFieldChange("field-added", name, field.required));
|
|
3954
|
+
for (const [name, field] of newByName) if (!oldByName.has(name)) changes.push(classifyFieldChange("field-added", name, field.required, direction));
|
|
3857
3955
|
for (const [name] of oldByName) if (!newByName.has(name)) changes.push(classifyFieldChange("field-removed", name));
|
|
3858
3956
|
for (const [name, newField] of newByName) {
|
|
3859
3957
|
const oldField = oldByName.get(name);
|
|
@@ -4068,8 +4166,9 @@ function diffServices(oldServices, newServices) {
|
|
|
4068
4166
|
//#endregion
|
|
4069
4167
|
//#region src/differ/diff.ts
|
|
4070
4168
|
function diffSpecs(oldSpec, newSpec) {
|
|
4169
|
+
const directions = buildDirectionIndex(oldSpec, newSpec);
|
|
4071
4170
|
const changes = [
|
|
4072
|
-
...diffModels(oldSpec.models, newSpec.models),
|
|
4171
|
+
...diffModels(oldSpec.models, newSpec.models, directions),
|
|
4073
4172
|
...diffEnums(oldSpec.enums, newSpec.enums),
|
|
4074
4173
|
...diffServices(oldSpec.services, newSpec.services)
|
|
4075
4174
|
];
|
|
@@ -4183,6 +4282,6 @@ function summarize(changes) {
|
|
|
4183
4282
|
};
|
|
4184
4283
|
}
|
|
4185
4284
|
//#endregion
|
|
4186
|
-
export {
|
|
4285
|
+
export { resolveMountTarget as _, registerEmitter as a, integrateGeneratedFiles as c, applyFileHeaders as d, buildEmitterContext as f, deriveMethodName as g, generateFiles as h, getEmitter as i, mapFilesForTargetIntegration as l, generateAllFiles as m, buildDirectionIndex as n, generate as o, collectReferencedNames as p, directionOf as r, MANIFEST_FILENAME as s, diffSpecs as t, treeShakeFiles as u, resolveOperations as v };
|
|
4187
4286
|
|
|
4188
|
-
//# sourceMappingURL=diff-
|
|
4287
|
+
//# sourceMappingURL=diff-DqnHHXvr.mjs.map
|