@omnifyjp/ts 6.7.3 → 6.7.4
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.
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Port of RequestGenerator.php — generates Store/Update request classes.
|
|
3
3
|
*/
|
|
4
4
|
import { toPascalCase, toSnakeCase, toCamelCase, toFkColumnName } from './naming-helper.js';
|
|
5
|
-
import { toStoreRules, toUpdateRules, formatRules
|
|
5
|
+
import { toStoreRules, toUpdateRules, formatRules } from './type-mapper.js';
|
|
6
6
|
import { baseFile, userFile, resolveModularBasePath, resolveModularBaseNamespace, resolveBaseClass, resolveEditableClass, nestByGroup, nestEditableByGroup } from './types.js';
|
|
7
7
|
/**
|
|
8
8
|
* Resolve the Laravel validation rule type ('integer', 'uuid', or 'string') for
|
|
@@ -57,7 +57,6 @@ function generateBaseRequest(name, schema, reader, config, action) {
|
|
|
57
57
|
const tableName = reader.getTableName(name);
|
|
58
58
|
const modelRouteParam = toCamelCase(name);
|
|
59
59
|
const isUpdate = action === 'Update';
|
|
60
|
-
let needsRuleImport = false;
|
|
61
60
|
const rulesLines = [];
|
|
62
61
|
const attributeKeys = [];
|
|
63
62
|
for (const propName of propertyOrder) {
|
|
@@ -95,8 +94,6 @@ function generateBaseRequest(name, schema, reader, config, action) {
|
|
|
95
94
|
const rules = isUpdate
|
|
96
95
|
? toUpdateRules(colProp, tableName, modelRouteParam)
|
|
97
96
|
: toStoreRules(colProp, tableName);
|
|
98
|
-
if (hasRuleObject(rules))
|
|
99
|
-
needsRuleImport = true;
|
|
100
97
|
rulesLines.push(` '${colName}' => ${formatRules(rules)},`);
|
|
101
98
|
attributeKeys.push(colName);
|
|
102
99
|
}
|
|
@@ -161,8 +158,6 @@ function generateBaseRequest(name, schema, reader, config, action) {
|
|
|
161
158
|
const rules = isUpdate
|
|
162
159
|
? toUpdateRules(prop, tableName, modelRouteParam)
|
|
163
160
|
: toStoreRules(prop, tableName);
|
|
164
|
-
if (hasRuleObject(rules))
|
|
165
|
-
needsRuleImport = true;
|
|
166
161
|
rulesLines.push(` '${snakeName}' => ${formatRules(rules)},`);
|
|
167
162
|
attributeKeys.push(snakeName);
|
|
168
163
|
// Translatable: add locale-nested rules (Astrotomic expects {locale}.{field})
|
|
@@ -184,6 +179,7 @@ function generateBaseRequest(name, schema, reader, config, action) {
|
|
|
184
179
|
const rulesContent = rulesLines.join('\n');
|
|
185
180
|
const localesClass = `${modelLocalesNamespace}\\${modelName}Locales`;
|
|
186
181
|
const attributeKeysList = attributeKeys.map(k => ` '${k}',`).join('\n');
|
|
182
|
+
const needsRuleImport = rulesContent.includes('Rule::');
|
|
187
183
|
const ruleImport = needsRuleImport ? '\nuse Illuminate\\Validation\\Rule;' : '';
|
|
188
184
|
const content = `<?php
|
|
189
185
|
|
|
@@ -27,6 +27,4 @@ export declare function isHiddenByDefault(type: string): boolean;
|
|
|
27
27
|
export declare function needsCast(type: string): boolean;
|
|
28
28
|
/** Get the resource output expression for a property. */
|
|
29
29
|
export declare function toResourceExpression(fieldName: string, type: string): string;
|
|
30
|
-
/** Check if a rules array contains a Rule:: object. */
|
|
31
|
-
export declare function hasRuleObject(rules: Rule[]): boolean;
|
|
32
30
|
export {};
|
package/dist/php/type-mapper.js
CHANGED
|
@@ -351,7 +351,3 @@ export function toResourceExpression(fieldName, type) {
|
|
|
351
351
|
default: return `$this->${fieldName}`;
|
|
352
352
|
}
|
|
353
353
|
}
|
|
354
|
-
/** Check if a rules array contains a Rule:: object. */
|
|
355
|
-
export function hasRuleObject(rules) {
|
|
356
|
-
return rules.some(r => Array.isArray(r) && ['rule_in', 'rule_unique_ignore'].includes(r[0]));
|
|
357
|
-
}
|