@workos/oagen 0.18.0 → 0.18.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 +150 -39
- package/dist/cli/index.mjs.map +1 -1
- package/dist/{diff-DLqJSVYR.mjs → diff-JU1bdT5_.mjs} +107 -17
- package/dist/{diff-DLqJSVYR.mjs.map → diff-JU1bdT5_.mjs.map} +1 -1
- package/dist/index.d.mts +33 -2
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +45 -24
- package/dist/index.mjs.map +1 -1
- package/dist/scripts/smoke/baseline.mjs +44 -23
- package/dist/scripts/smoke/baseline.mjs.map +1 -1
- package/dist/smoke.mjs +44 -23
- package/dist/smoke.mjs.map +1 -1
- package/dist/verify/index.mjs +1 -1
- package/package.json +1 -1
|
@@ -2955,6 +2955,11 @@ function classifyFieldChange(kind, fieldName, isRequired) {
|
|
|
2955
2955
|
fieldName,
|
|
2956
2956
|
classification: "breaking"
|
|
2957
2957
|
};
|
|
2958
|
+
case "field-format-changed": return {
|
|
2959
|
+
kind,
|
|
2960
|
+
fieldName,
|
|
2961
|
+
classification: "additive"
|
|
2962
|
+
};
|
|
2958
2963
|
case "field-required-changed": return {
|
|
2959
2964
|
kind,
|
|
2960
2965
|
fieldName,
|
|
@@ -2985,11 +2990,21 @@ function classifyParamChange(kind, paramName, isRequired) {
|
|
|
2985
2990
|
paramName,
|
|
2986
2991
|
classification: "breaking"
|
|
2987
2992
|
};
|
|
2993
|
+
case "param-format-changed": return {
|
|
2994
|
+
kind,
|
|
2995
|
+
paramName,
|
|
2996
|
+
classification: "additive"
|
|
2997
|
+
};
|
|
2988
2998
|
case "param-required-changed": return {
|
|
2989
2999
|
kind,
|
|
2990
3000
|
paramName,
|
|
2991
3001
|
classification: isRequired ? "breaking" : "additive"
|
|
2992
3002
|
};
|
|
3003
|
+
case "param-default-changed": return {
|
|
3004
|
+
kind,
|
|
3005
|
+
paramName,
|
|
3006
|
+
classification: "breaking"
|
|
3007
|
+
};
|
|
2993
3008
|
}
|
|
2994
3009
|
}
|
|
2995
3010
|
//#endregion
|
|
@@ -3033,7 +3048,11 @@ function diffFields(oldModel, newModel) {
|
|
|
3033
3048
|
for (const [name, newField] of newByName) {
|
|
3034
3049
|
const oldField = oldByName.get(name);
|
|
3035
3050
|
if (!oldField) continue;
|
|
3036
|
-
if (!typeRefsEqual(oldField.type, newField.type)) changes.push({
|
|
3051
|
+
if (!typeRefsEqual(oldField.type, newField.type)) if (primitivesDifferOnlyByFormat(oldField.type, newField.type)) changes.push({
|
|
3052
|
+
...classifyFieldChange("field-format-changed", name),
|
|
3053
|
+
details: formatChangeDetails(oldField.type, newField.type)
|
|
3054
|
+
});
|
|
3055
|
+
else changes.push({
|
|
3037
3056
|
kind: "field-type-changed",
|
|
3038
3057
|
fieldName: name,
|
|
3039
3058
|
classification: "breaking",
|
|
@@ -3044,6 +3063,23 @@ function diffFields(oldModel, newModel) {
|
|
|
3044
3063
|
}
|
|
3045
3064
|
return changes;
|
|
3046
3065
|
}
|
|
3066
|
+
/**
|
|
3067
|
+
* True when both refs are primitives with the same base `type` but different
|
|
3068
|
+
* `format`. Used to downgrade format-only diffs from breaking type changes to
|
|
3069
|
+
* additive `field-format-changed` / `param-format-changed` events: the wire
|
|
3070
|
+
* base type is unchanged, so the diff is a hint to language emitters rather
|
|
3071
|
+
* than a source-level break.
|
|
3072
|
+
*/
|
|
3073
|
+
function primitivesDifferOnlyByFormat(a, b) {
|
|
3074
|
+
if (a.kind !== "primitive" || b.kind !== "primitive") return false;
|
|
3075
|
+
if (a.type !== b.type) return false;
|
|
3076
|
+
return (a.format ?? "") !== (b.format ?? "");
|
|
3077
|
+
}
|
|
3078
|
+
function formatChangeDetails(a, b) {
|
|
3079
|
+
const oldFmt = a.kind === "primitive" ? a.format : void 0;
|
|
3080
|
+
const newFmt = b.kind === "primitive" ? b.format : void 0;
|
|
3081
|
+
return `format ${oldFmt ?? "<unset>"} → ${newFmt ?? "<unset>"}`;
|
|
3082
|
+
}
|
|
3047
3083
|
function typeRefsEqual(a, b) {
|
|
3048
3084
|
if (a.kind !== b.kind) return false;
|
|
3049
3085
|
switch (a.kind) {
|
|
@@ -3145,28 +3181,57 @@ function classifyErrorsChange(oldErrors, newErrors) {
|
|
|
3145
3181
|
}
|
|
3146
3182
|
function diffParams(oldOp, newOp) {
|
|
3147
3183
|
const changes = [];
|
|
3184
|
+
const tagged = (loc, params) => params.map((p) => ({
|
|
3185
|
+
p,
|
|
3186
|
+
loc
|
|
3187
|
+
}));
|
|
3148
3188
|
const allOldParams = [
|
|
3149
|
-
...oldOp.pathParams,
|
|
3150
|
-
...oldOp.queryParams,
|
|
3151
|
-
...oldOp.headerParams
|
|
3189
|
+
...tagged("path", oldOp.pathParams),
|
|
3190
|
+
...tagged("query", oldOp.queryParams),
|
|
3191
|
+
...tagged("header", oldOp.headerParams)
|
|
3152
3192
|
];
|
|
3153
3193
|
const allNewParams = [
|
|
3154
|
-
...newOp.pathParams,
|
|
3155
|
-
...newOp.queryParams,
|
|
3156
|
-
...newOp.headerParams
|
|
3194
|
+
...tagged("path", newOp.pathParams),
|
|
3195
|
+
...tagged("query", newOp.queryParams),
|
|
3196
|
+
...tagged("header", newOp.headerParams)
|
|
3157
3197
|
];
|
|
3158
|
-
const oldByName = new Map(allOldParams.map((
|
|
3159
|
-
const newByName = new Map(allNewParams.map((
|
|
3160
|
-
for (const [name,
|
|
3198
|
+
const oldByName = new Map(allOldParams.map((e) => [e.p.name, e]));
|
|
3199
|
+
const newByName = new Map(allNewParams.map((e) => [e.p.name, e]));
|
|
3200
|
+
for (const [name, entry] of newByName) if (!oldByName.has(name)) changes.push(classifyParamChange("param-added", name, entry.p.required));
|
|
3161
3201
|
for (const [name] of oldByName) if (!newByName.has(name)) changes.push(classifyParamChange("param-removed", name));
|
|
3162
|
-
for (const [name,
|
|
3163
|
-
const
|
|
3164
|
-
if (!
|
|
3165
|
-
if (!typeRefsEqual(
|
|
3166
|
-
|
|
3202
|
+
for (const [name, newEntry] of newByName) {
|
|
3203
|
+
const oldEntry = oldByName.get(name);
|
|
3204
|
+
if (!oldEntry) continue;
|
|
3205
|
+
if (!typeRefsEqual(oldEntry.p.type, newEntry.p.type)) if (primitivesDifferOnlyByFormat(oldEntry.p.type, newEntry.p.type)) {
|
|
3206
|
+
const change = classifyParamChange("param-format-changed", name);
|
|
3207
|
+
change.details = formatChangeDetails(oldEntry.p.type, newEntry.p.type);
|
|
3208
|
+
changes.push(change);
|
|
3209
|
+
} else changes.push(classifyParamChange("param-type-changed", name));
|
|
3210
|
+
if (oldEntry.p.required !== newEntry.p.required) changes.push(classifyParamChange("param-required-changed", name, newEntry.p.required));
|
|
3211
|
+
const oldDefault = serializeDefault(oldEntry.p.default);
|
|
3212
|
+
const newDefault = serializeDefault(newEntry.p.default);
|
|
3213
|
+
if (oldDefault !== newDefault) {
|
|
3214
|
+
const change = classifyParamChange("param-default-changed", name);
|
|
3215
|
+
change.oldDefault = oldDefault;
|
|
3216
|
+
change.newDefault = newDefault;
|
|
3217
|
+
change.paramLocation = newEntry.loc;
|
|
3218
|
+
change.details = `default ${oldDefault ?? "<unset>"} → ${newDefault ?? "<unset>"}`;
|
|
3219
|
+
changes.push(change);
|
|
3220
|
+
}
|
|
3167
3221
|
}
|
|
3168
3222
|
return changes;
|
|
3169
3223
|
}
|
|
3224
|
+
function serializeDefault(value) {
|
|
3225
|
+
if (value === void 0) return null;
|
|
3226
|
+
if (value === null) return "null";
|
|
3227
|
+
if (typeof value === "string") return value;
|
|
3228
|
+
if (typeof value === "number" || typeof value === "boolean") return String(value);
|
|
3229
|
+
try {
|
|
3230
|
+
return JSON.stringify(value);
|
|
3231
|
+
} catch {
|
|
3232
|
+
return String(value);
|
|
3233
|
+
}
|
|
3234
|
+
}
|
|
3170
3235
|
//#endregion
|
|
3171
3236
|
//#region src/differ/services.ts
|
|
3172
3237
|
function diffServices(oldServices, newServices) {
|
|
@@ -3198,13 +3263,38 @@ function diffSpecs(oldSpec, newSpec) {
|
|
|
3198
3263
|
...diffEnums(oldSpec.enums, newSpec.enums),
|
|
3199
3264
|
...diffServices(oldSpec.services, newSpec.services)
|
|
3200
3265
|
];
|
|
3266
|
+
const behaviorChanges = collectBehaviorChanges(changes);
|
|
3201
3267
|
return {
|
|
3202
3268
|
oldVersion: oldSpec.version,
|
|
3203
3269
|
newVersion: newSpec.version,
|
|
3204
3270
|
changes,
|
|
3205
|
-
|
|
3271
|
+
behaviorChanges,
|
|
3272
|
+
summary: {
|
|
3273
|
+
...summarize(changes),
|
|
3274
|
+
behaviorChanges: behaviorChanges.length
|
|
3275
|
+
}
|
|
3206
3276
|
};
|
|
3207
3277
|
}
|
|
3278
|
+
function collectBehaviorChanges(changes) {
|
|
3279
|
+
const out = [];
|
|
3280
|
+
for (const c of changes) {
|
|
3281
|
+
if (c.kind !== "operation-modified") continue;
|
|
3282
|
+
for (const pc of c.paramChanges) {
|
|
3283
|
+
if (pc.kind !== "param-default-changed") continue;
|
|
3284
|
+
out.push({
|
|
3285
|
+
kind: "param-default-changed",
|
|
3286
|
+
serviceName: c.serviceName,
|
|
3287
|
+
operationName: c.operationName,
|
|
3288
|
+
paramName: pc.paramName,
|
|
3289
|
+
paramLocation: pc.paramLocation ?? "query",
|
|
3290
|
+
oldDefault: pc.oldDefault ?? null,
|
|
3291
|
+
newDefault: pc.newDefault ?? null,
|
|
3292
|
+
classification: "breaking"
|
|
3293
|
+
});
|
|
3294
|
+
}
|
|
3295
|
+
}
|
|
3296
|
+
return out;
|
|
3297
|
+
}
|
|
3208
3298
|
function diffEnums(oldEnums, newEnums) {
|
|
3209
3299
|
const changes = [];
|
|
3210
3300
|
const oldByName = new Map(oldEnums.map((e) => [e.name, e]));
|
|
@@ -3285,4 +3375,4 @@ function summarize(changes) {
|
|
|
3285
3375
|
//#endregion
|
|
3286
3376
|
export { MANIFEST_FILENAME as a, treeShakeFiles as c, collectReferencedNames as d, generateAllFiles as f, resolveOperations as h, generate as i, applyFileHeaders as l, deriveMethodName as m, getEmitter as n, integrateGeneratedFiles as o, generateFiles as p, registerEmitter as r, mapFilesForTargetIntegration as s, diffSpecs as t, buildEmitterContext as u };
|
|
3287
3377
|
|
|
3288
|
-
//# sourceMappingURL=diff-
|
|
3378
|
+
//# sourceMappingURL=diff-JU1bdT5_.mjs.map
|