poe-code 3.0.287 → 3.0.289

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "poe-code",
3
- "version": "3.0.287",
3
+ "version": "3.0.289",
4
4
  "description": "CLI tool to configure Poe API for developer workflows.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -55,6 +55,11 @@ export async function runGenerateCli(argv = process.argv, services = {
55
55
  if (result.diagnostics.length > 0) {
56
56
  services.stderr.write(formatDiagnostics(result.diagnostics));
57
57
  }
58
+ const diagnosticsFailed = hasErrorDiagnostics(result.diagnostics);
59
+ if (!parsed.check && !parsed.diff && diagnosticsFailed) {
60
+ services.stderr.write("OpenAPI diagnostics failed for toolcraft.yml.\n");
61
+ return 1;
62
+ }
58
63
  if (parsed.diff) {
59
64
  if (!result.drifted) {
60
65
  services.stdout.write(`OpenAPI output is up to date (${result.specSha}).\n`);
@@ -68,7 +73,7 @@ export async function runGenerateCli(argv = process.argv, services = {
68
73
  services.stderr.write(`OpenAPI output is out of date for ${parsed.outputDir}. Run the generator without --check to update it.\n`);
69
74
  return 1;
70
75
  }
71
- if (hasErrorDiagnostics(result.diagnostics)) {
76
+ if (diagnosticsFailed) {
72
77
  services.stderr.write("OpenAPI diagnostics failed for toolcraft.yml.\n");
73
78
  return 1;
74
79
  }
@@ -116,7 +121,7 @@ export async function syncGeneratedClient(options, services) {
116
121
  const updatedFiles = collectUpdatedFiles(currentFiles, desiredFiles);
117
122
  const deletedFiles = collectDeletedFiles(currentFiles, desiredFiles);
118
123
  const drifted = updatedFiles.length > 0 || deletedFiles.length > 0;
119
- if (!options.check && !options.diff && drifted) {
124
+ if (!options.check && !options.diff && drifted && !hasErrorDiagnostics(diagnostics)) {
120
125
  try {
121
126
  await writeGeneratedFiles(services.fs, outputDir, updatedFiles);
122
127
  await deleteGeneratedFiles(services.fs, outputDir, deletedFiles);
@@ -1230,7 +1230,12 @@ function resolveEquivalentCompositionSchema(document, schema, operationId, conte
1230
1230
  const { anyOf: _anyOf, oneOf: _oneOf, ...wrapper } = schema;
1231
1231
  void _anyOf;
1232
1232
  void _oneOf;
1233
- return { ...wrapper, ...createSchemaFromEquivalentShape(firstShape) };
1233
+ const enumValues = collectEquivalentCompositionEnumValues(resolved);
1234
+ return {
1235
+ ...wrapper,
1236
+ ...createSchemaFromEquivalentShape(firstShape),
1237
+ ...(enumValues === undefined ? {} : { enum: enumValues })
1238
+ };
1234
1239
  }
1235
1240
  function getEquivalentSchemaShape(schema) {
1236
1241
  if (getCompositionKeyword(schema) !== undefined || Array.isArray(schema.type)) {
@@ -1250,6 +1255,20 @@ function createSchemaFromEquivalentShape(shape) {
1250
1255
  }
1251
1256
  return { type: "array", items: createSchemaFromEquivalentShape(shape.slice("array:".length)) };
1252
1257
  }
1258
+ function collectEquivalentCompositionEnumValues(schemas) {
1259
+ if (schemas.some((schema) => schema.enum === undefined)) {
1260
+ return undefined;
1261
+ }
1262
+ const values = [];
1263
+ for (const schema of schemas) {
1264
+ for (const value of schema.enum ?? []) {
1265
+ if (!values.some((existing) => Object.is(existing, value))) {
1266
+ values.push(value);
1267
+ }
1268
+ }
1269
+ }
1270
+ return values.length === 0 ? undefined : values;
1271
+ }
1253
1272
  function normalizeNullableTypeArray(schema) {
1254
1273
  if (!Array.isArray(schema.type)) {
1255
1274
  return schema;