@omnifyjp/ts 6.7.9 → 6.7.11

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.js CHANGED
@@ -251,7 +251,8 @@ program
251
251
  let phpOverwritten = 0;
252
252
  let phpSkipped = 0;
253
253
  let phpSkippedSibling = 0;
254
- let phpShadowed = 0;
254
+ let phpShadowedOutOfSync = 0;
255
+ let phpShadowedAtRisk = 0;
255
256
  const skippedSiblingExamples = [];
256
257
  const writtenPaths = [];
257
258
  for (const file of phpFiles) {
@@ -271,9 +272,17 @@ program
271
272
  // the base generates. #171 — a redeclared $fillable shadows the
272
273
  // parent's, so every property added afterwards is stripped on mass
273
274
  // assignment with no error anywhere.
274
- for (const hint of evaluateShadowingConflicts(existing, file.conflicts ?? [])) {
275
- phpShadowed++;
276
- console.warn(`[omnify-ts] ${relative(configDir, filePath)}: ${hint}`);
275
+ const shadowResults = evaluateShadowingConflicts(existing, file.conflicts ?? []);
276
+ if (shadowResults.length > 0) {
277
+ if (shadowResults.some((r) => r.drift === 'out-of-sync')) {
278
+ phpShadowedOutOfSync++;
279
+ }
280
+ else {
281
+ phpShadowedAtRisk++;
282
+ }
283
+ for (const result of shadowResults) {
284
+ console.warn(`[omnify-ts] ${relative(configDir, filePath)}: ${result.message}`);
285
+ }
277
286
  }
278
287
  continue;
279
288
  }
@@ -322,9 +331,15 @@ program
322
331
  console.log(` ${phpCreated} files created (user-editable)`);
323
332
  if (phpSkipped > 0)
324
333
  console.log(` ${phpSkipped} files skipped (already exist)`);
325
- if (phpShadowed > 0) {
326
- console.warn(` ${phpShadowed} editable file(s) shadow a generated property — ` +
327
- `schema changes will NOT reach them until that is fixed (see warnings above).`);
334
+ if (phpShadowedOutOfSync > 0 || phpShadowedAtRisk > 0) {
335
+ const summaryParts = [];
336
+ if (phpShadowedOutOfSync > 0) {
337
+ summaryParts.push(`${phpShadowedOutOfSync} editable file(s) already out of sync with the base`);
338
+ }
339
+ if (phpShadowedAtRisk > 0) {
340
+ summaryParts.push(`${phpShadowedAtRisk} shadow a generated property and will drift on the next schema change`);
341
+ }
342
+ console.warn(` ${summaryParts.join(', ')} (see warnings above).`);
328
343
  }
329
344
  if (phpSkippedSibling > 0) {
330
345
  console.log(` ${phpSkippedSibling} user-editable stub(s) skipped (project sibling with same name found in subfolder)`);
@@ -11,7 +11,13 @@ export declare function shadowingPropertyConflicts(baseClass: string, baseArrayV
11
11
  */
12
12
  export declare function parseRedeclaredStringArray(source: string, prop: string): string[] | null;
13
13
  export declare function formatShadowingDrift(baseValues: readonly string[], childValues: string[] | null): string;
14
+ export type ShadowingDrift = 'out-of-sync' | 'extra-only' | 'in-sync' | 'unknown';
15
+ export type ShadowingConflictResult = {
16
+ property: ShadowingEloquentProperty;
17
+ message: string;
18
+ drift: ShadowingDrift;
19
+ };
14
20
  /**
15
21
  * Evaluate shadowing conflicts for a skipped user-editable model file.
16
22
  */
17
- export declare function evaluateShadowingConflicts(existingRaw: string, conflicts: readonly ShadowingPropertyConflict[]): string[];
23
+ export declare function evaluateShadowingConflicts(existingRaw: string, conflicts: readonly ShadowingPropertyConflict[]): ShadowingConflictResult[];
@@ -92,12 +92,31 @@ export function formatShadowingDrift(baseValues, childValues) {
92
92
  }
93
93
  return parts.join('; ') + '.';
94
94
  }
95
+ function classifyShadowingDrift(baseValues, childValues) {
96
+ if (!baseValues || baseValues.length === 0) {
97
+ return 'unknown';
98
+ }
99
+ if (childValues === null) {
100
+ return 'unknown';
101
+ }
102
+ const baseSet = new Set(baseValues);
103
+ const childSet = new Set(childValues);
104
+ const missing = baseValues.filter((v) => !childSet.has(v));
105
+ const extra = childValues.filter((v) => !baseSet.has(v));
106
+ if (missing.length === 0 && extra.length === 0) {
107
+ return 'in-sync';
108
+ }
109
+ if (missing.length > 0) {
110
+ return 'out-of-sync';
111
+ }
112
+ return 'extra-only';
113
+ }
95
114
  /**
96
115
  * Evaluate shadowing conflicts for a skipped user-editable model file.
97
116
  */
98
117
  export function evaluateShadowingConflicts(existingRaw, conflicts) {
99
118
  const stripped = stripPhpComments(existingRaw);
100
- const warnings = [];
119
+ const results = [];
101
120
  for (const conflict of conflicts) {
102
121
  if (hasIntentionalShadowMarker(existingRaw, conflict.property)) {
103
122
  continue;
@@ -106,14 +125,18 @@ export function evaluateShadowingConflicts(existingRaw, conflicts) {
106
125
  continue;
107
126
  }
108
127
  let message = conflict.hint;
109
- if (conflict.baseValues && conflict.baseValues.length > 0) {
110
- const childValues = parseRedeclaredStringArray(existingRaw, conflict.property);
111
- const drift = formatShadowingDrift(conflict.baseValues, childValues);
112
- if (drift) {
113
- message += ` ${drift}`;
128
+ const baseValues = conflict.baseValues && conflict.baseValues.length > 0 ? conflict.baseValues : undefined;
129
+ const childValues = baseValues
130
+ ? parseRedeclaredStringArray(existingRaw, conflict.property)
131
+ : null;
132
+ const drift = classifyShadowingDrift(baseValues, childValues);
133
+ if (baseValues) {
134
+ const driftText = formatShadowingDrift(baseValues, childValues);
135
+ if (driftText) {
136
+ message += ` ${driftText}`;
114
137
  }
115
138
  }
116
- warnings.push(message);
139
+ results.push({ property: conflict.property, message, drift });
117
140
  }
118
- return warnings;
141
+ return results;
119
142
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@omnifyjp/ts",
3
- "version": "6.7.9",
3
+ "version": "6.7.11",
4
4
  "description": "TypeScript model type generator from Omnify schemas.json",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",