@famgia/omnify-typescript 0.0.72 → 0.0.74
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/{chunk-6I4O23X6.js → chunk-LHNMWILH.js} +30 -21
- package/dist/chunk-LHNMWILH.js.map +1 -0
- package/dist/index.cjs +29 -20
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +7 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.js +1 -1
- package/dist/plugin.cjs +29 -20
- package/dist/plugin.cjs.map +1 -1
- package/dist/plugin.js +1 -1
- package/package.json +2 -2
- package/dist/chunk-6I4O23X6.js.map +0 -1
package/dist/index.cjs
CHANGED
|
@@ -1519,7 +1519,7 @@ function formatZodSchemasSection(schemaName, zodSchemas, displayNames, excludedF
|
|
|
1519
1519
|
`);
|
|
1520
1520
|
return parts.join("");
|
|
1521
1521
|
}
|
|
1522
|
-
function formatZodModelFile(schemaName,
|
|
1522
|
+
function formatZodModelFile(schemaName, ext = "") {
|
|
1523
1523
|
const lowerName = schemaName.charAt(0).toLowerCase() + schemaName.slice(1);
|
|
1524
1524
|
return `/**
|
|
1525
1525
|
* ${schemaName} Model
|
|
@@ -1530,7 +1530,7 @@ function formatZodModelFile(schemaName, _hasPlaceholders = false) {
|
|
|
1530
1530
|
*/
|
|
1531
1531
|
|
|
1532
1532
|
import { z } from 'zod';
|
|
1533
|
-
import type { ${schemaName} as ${schemaName}Base } from './base/${schemaName}
|
|
1533
|
+
import type { ${schemaName} as ${schemaName}Base } from './base/${schemaName}${ext}';
|
|
1534
1534
|
import {
|
|
1535
1535
|
base${schemaName}Schemas,
|
|
1536
1536
|
base${schemaName}CreateSchema,
|
|
@@ -1539,7 +1539,7 @@ import {
|
|
|
1539
1539
|
get${schemaName}Label,
|
|
1540
1540
|
get${schemaName}FieldLabel,
|
|
1541
1541
|
get${schemaName}FieldPlaceholder,
|
|
1542
|
-
} from './base/${schemaName}
|
|
1542
|
+
} from './base/${schemaName}${ext}';
|
|
1543
1543
|
|
|
1544
1544
|
// ============================================================================
|
|
1545
1545
|
// Types (extend or re-export)
|
|
@@ -1584,9 +1584,14 @@ var DEFAULT_OPTIONS = {
|
|
|
1584
1584
|
strictNullChecks: true,
|
|
1585
1585
|
generateZodSchemas: true,
|
|
1586
1586
|
// Generate Zod schemas by default
|
|
1587
|
-
generateRules: false
|
|
1587
|
+
generateRules: false,
|
|
1588
1588
|
// Legacy Ant Design rules (deprecated, ignored when generateZodSchemas=true)
|
|
1589
|
+
useJsExtension: false
|
|
1590
|
+
// Bundlers (Vite, webpack) don't need .js extension
|
|
1589
1591
|
};
|
|
1592
|
+
function getImportExt(options) {
|
|
1593
|
+
return options.useJsExtension ? ".js" : "";
|
|
1594
|
+
}
|
|
1590
1595
|
function generateBaseHeader() {
|
|
1591
1596
|
return `/**
|
|
1592
1597
|
* Auto-generated TypeScript types from Omnify schemas.
|
|
@@ -1681,8 +1686,9 @@ function generateBaseInterfaceFile(schemaName, schemas, options) {
|
|
|
1681
1686
|
const commonImports = [];
|
|
1682
1687
|
if (dateImports.dateTime) commonImports.push("DateTimeString");
|
|
1683
1688
|
if (dateImports.date) commonImports.push("DateString");
|
|
1689
|
+
const ext = getImportExt(options);
|
|
1684
1690
|
if (commonImports.length > 0) {
|
|
1685
|
-
parts.push(`import type { ${commonImports.join(", ")} } from '../common
|
|
1691
|
+
parts.push(`import type { ${commonImports.join(", ")} } from '../common${ext}';
|
|
1686
1692
|
`);
|
|
1687
1693
|
}
|
|
1688
1694
|
if (iface.enumDependencies && iface.enumDependencies.length > 0) {
|
|
@@ -1691,14 +1697,14 @@ function generateBaseInterfaceFile(schemaName, schemas, options) {
|
|
|
1691
1697
|
options.pluginEnums ? Array.from(options.pluginEnums.keys()) : []
|
|
1692
1698
|
);
|
|
1693
1699
|
for (const enumName of iface.enumDependencies) {
|
|
1694
|
-
const enumPath = pluginEnumNames.has(enumName) ? `${enumPrefix}/plugin/${enumName}
|
|
1700
|
+
const enumPath = pluginEnumNames.has(enumName) ? `${enumPrefix}/plugin/${enumName}${ext}` : `${enumPrefix}/${enumName}${ext}`;
|
|
1695
1701
|
parts.push(`import { ${enumName} } from '${enumPath}';
|
|
1696
1702
|
`);
|
|
1697
1703
|
}
|
|
1698
1704
|
}
|
|
1699
1705
|
if (iface.dependencies && iface.dependencies.length > 0) {
|
|
1700
1706
|
for (const dep of iface.dependencies) {
|
|
1701
|
-
parts.push(`import type { ${dep} } from './${dep}
|
|
1707
|
+
parts.push(`import type { ${dep} } from './${dep}${ext}';
|
|
1702
1708
|
`);
|
|
1703
1709
|
}
|
|
1704
1710
|
parts.push("\n");
|
|
@@ -1752,14 +1758,15 @@ function generateModelFile(schemaName, options) {
|
|
|
1752
1758
|
if (options.generateZodSchemas) {
|
|
1753
1759
|
return {
|
|
1754
1760
|
filePath: `${schemaName}.ts`,
|
|
1755
|
-
content: formatZodModelFile(schemaName),
|
|
1761
|
+
content: formatZodModelFile(schemaName, getImportExt(options)),
|
|
1756
1762
|
types: [schemaName],
|
|
1757
1763
|
overwrite: false
|
|
1758
1764
|
// Never overwrite user models
|
|
1759
1765
|
};
|
|
1760
1766
|
}
|
|
1761
1767
|
const parts = [generateModelHeader(schemaName)];
|
|
1762
|
-
|
|
1768
|
+
const ext = getImportExt(options);
|
|
1769
|
+
parts.push(`import type { ${schemaName} as ${schemaName}Base } from './base/${schemaName}${ext}';
|
|
1763
1770
|
|
|
1764
1771
|
`);
|
|
1765
1772
|
parts.push(`/**
|
|
@@ -1940,8 +1947,9 @@ function generateI18nFile(options) {
|
|
|
1940
1947
|
}
|
|
1941
1948
|
}
|
|
1942
1949
|
const messagesJson = JSON.stringify(mergedMessages, null, 2);
|
|
1950
|
+
const ext = getImportExt(options);
|
|
1943
1951
|
const content = `${generateBaseHeader()}
|
|
1944
|
-
import type { LocaleMap } from './common
|
|
1952
|
+
import type { LocaleMap } from './common${ext}';
|
|
1945
1953
|
|
|
1946
1954
|
/**
|
|
1947
1955
|
* Default locale for this project.
|
|
@@ -2024,9 +2032,10 @@ export function getMessages(locale: string): Record<string, string> {
|
|
|
2024
2032
|
}
|
|
2025
2033
|
function generateIndexFile(schemas, enums, pluginEnums, typeAliases, options) {
|
|
2026
2034
|
const parts = [generateBaseHeader()];
|
|
2035
|
+
const ext = getImportExt(options);
|
|
2027
2036
|
parts.push(`// Common Types
|
|
2028
2037
|
`);
|
|
2029
|
-
parts.push(`export type { LocaleMap, Locale, ValidationRule, DateTimeString, DateString } from './common
|
|
2038
|
+
parts.push(`export type { LocaleMap, Locale, ValidationRule, DateTimeString, DateString } from './common${ext}';
|
|
2030
2039
|
|
|
2031
2040
|
`);
|
|
2032
2041
|
parts.push(`// i18n (Internationalization)
|
|
@@ -2045,7 +2054,7 @@ function generateIndexFile(schemas, enums, pluginEnums, typeAliases, options) {
|
|
|
2045
2054
|
`);
|
|
2046
2055
|
parts.push(` getMessages,
|
|
2047
2056
|
`);
|
|
2048
|
-
parts.push(`} from './i18n
|
|
2057
|
+
parts.push(`} from './i18n${ext}';
|
|
2049
2058
|
|
|
2050
2059
|
`);
|
|
2051
2060
|
const enumPrefix = options.enumImportPrefix ?? "./enum";
|
|
@@ -2065,7 +2074,7 @@ function generateIndexFile(schemas, enums, pluginEnums, typeAliases, options) {
|
|
|
2065
2074
|
`);
|
|
2066
2075
|
parts.push(` get${enumDef.name}Extra,
|
|
2067
2076
|
`);
|
|
2068
|
-
parts.push(`} from '${enumPrefix}/${enumDef.name}
|
|
2077
|
+
parts.push(`} from '${enumPrefix}/${enumDef.name}${ext}';
|
|
2069
2078
|
`);
|
|
2070
2079
|
}
|
|
2071
2080
|
parts.push("\n");
|
|
@@ -2086,7 +2095,7 @@ function generateIndexFile(schemas, enums, pluginEnums, typeAliases, options) {
|
|
|
2086
2095
|
`);
|
|
2087
2096
|
parts.push(` get${enumDef.name}Extra,
|
|
2088
2097
|
`);
|
|
2089
|
-
parts.push(`} from '${enumPrefix}/plugin/${enumDef.name}
|
|
2098
|
+
parts.push(`} from '${enumPrefix}/plugin/${enumDef.name}${ext}';
|
|
2090
2099
|
`);
|
|
2091
2100
|
}
|
|
2092
2101
|
parts.push("\n");
|
|
@@ -2107,7 +2116,7 @@ function generateIndexFile(schemas, enums, pluginEnums, typeAliases, options) {
|
|
|
2107
2116
|
`);
|
|
2108
2117
|
parts.push(` get${alias.name}Extra,
|
|
2109
2118
|
`);
|
|
2110
|
-
parts.push(`} from '${enumPrefix}/${alias.name}
|
|
2119
|
+
parts.push(`} from '${enumPrefix}/${alias.name}${ext}';
|
|
2111
2120
|
`);
|
|
2112
2121
|
}
|
|
2113
2122
|
parts.push("\n");
|
|
@@ -2119,7 +2128,7 @@ function generateIndexFile(schemas, enums, pluginEnums, typeAliases, options) {
|
|
|
2119
2128
|
if (schema.kind === "enum") continue;
|
|
2120
2129
|
if (schema.options?.hidden === true) continue;
|
|
2121
2130
|
const lowerName = schema.name.charAt(0).toLowerCase() + schema.name.slice(1);
|
|
2122
|
-
parts.push(`export type { ${schema.name}, ${schema.name}Create, ${schema.name}Update } from './${schema.name}
|
|
2131
|
+
parts.push(`export type { ${schema.name}, ${schema.name}Create, ${schema.name}Update } from './${schema.name}${ext}';
|
|
2123
2132
|
`);
|
|
2124
2133
|
parts.push(`export {
|
|
2125
2134
|
`);
|
|
@@ -2137,7 +2146,7 @@ function generateIndexFile(schemas, enums, pluginEnums, typeAliases, options) {
|
|
|
2137
2146
|
`);
|
|
2138
2147
|
parts.push(` get${schema.name}FieldPlaceholder,
|
|
2139
2148
|
`);
|
|
2140
|
-
parts.push(`} from './${schema.name}
|
|
2149
|
+
parts.push(`} from './${schema.name}${ext}';
|
|
2141
2150
|
`);
|
|
2142
2151
|
}
|
|
2143
2152
|
} else {
|
|
@@ -2146,9 +2155,9 @@ function generateIndexFile(schemas, enums, pluginEnums, typeAliases, options) {
|
|
|
2146
2155
|
for (const schema of Object.values(schemas)) {
|
|
2147
2156
|
if (schema.kind === "enum") continue;
|
|
2148
2157
|
if (schema.options?.hidden === true) continue;
|
|
2149
|
-
parts.push(`export type { ${schema.name} } from './${schema.name}
|
|
2158
|
+
parts.push(`export type { ${schema.name} } from './${schema.name}${ext}';
|
|
2150
2159
|
`);
|
|
2151
|
-
parts.push(`export type { ${schema.name}Create, ${schema.name}Update } from './base/${schema.name}
|
|
2160
|
+
parts.push(`export type { ${schema.name}Create, ${schema.name}Update } from './base/${schema.name}${ext}';
|
|
2152
2161
|
`);
|
|
2153
2162
|
}
|
|
2154
2163
|
if (options.generateRules) {
|
|
@@ -2166,7 +2175,7 @@ function generateIndexFile(schemas, enums, pluginEnums, typeAliases, options) {
|
|
|
2166
2175
|
`);
|
|
2167
2176
|
parts.push(` get${schema.name}PropertyDisplayName,
|
|
2168
2177
|
`);
|
|
2169
|
-
parts.push(`} from './rules/${schema.name}.rules
|
|
2178
|
+
parts.push(`} from './rules/${schema.name}.rules${ext}';
|
|
2170
2179
|
`);
|
|
2171
2180
|
}
|
|
2172
2181
|
}
|