@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.d.cts
CHANGED
|
@@ -82,6 +82,13 @@ interface TypeScriptOptions {
|
|
|
82
82
|
* These are generated alongside schema enums in the enum/ folder.
|
|
83
83
|
*/
|
|
84
84
|
readonly pluginEnums?: ReadonlyMap<string, PluginEnumDefinition> | undefined;
|
|
85
|
+
/**
|
|
86
|
+
* Whether to add .js extension to import paths.
|
|
87
|
+
* Set to true for native ESM (moduleResolution: node16/nodenext).
|
|
88
|
+
* Set to false when using bundlers (Vite, webpack, etc.) that handle module resolution.
|
|
89
|
+
* @default false
|
|
90
|
+
*/
|
|
91
|
+
readonly useJsExtension?: boolean | undefined;
|
|
85
92
|
}
|
|
86
93
|
/**
|
|
87
94
|
* TypeScript property definition.
|
package/dist/index.d.ts
CHANGED
|
@@ -82,6 +82,13 @@ interface TypeScriptOptions {
|
|
|
82
82
|
* These are generated alongside schema enums in the enum/ folder.
|
|
83
83
|
*/
|
|
84
84
|
readonly pluginEnums?: ReadonlyMap<string, PluginEnumDefinition> | undefined;
|
|
85
|
+
/**
|
|
86
|
+
* Whether to add .js extension to import paths.
|
|
87
|
+
* Set to true for native ESM (moduleResolution: node16/nodenext).
|
|
88
|
+
* Set to false when using bundlers (Vite, webpack, etc.) that handle module resolution.
|
|
89
|
+
* @default false
|
|
90
|
+
*/
|
|
91
|
+
readonly useJsExtension?: boolean | undefined;
|
|
85
92
|
}
|
|
86
93
|
/**
|
|
87
94
|
* TypeScript property definition.
|
package/dist/index.js
CHANGED
package/dist/plugin.cjs
CHANGED
|
@@ -1479,7 +1479,7 @@ function formatZodSchemasSection(schemaName, zodSchemas, displayNames, excludedF
|
|
|
1479
1479
|
`);
|
|
1480
1480
|
return parts.join("");
|
|
1481
1481
|
}
|
|
1482
|
-
function formatZodModelFile(schemaName,
|
|
1482
|
+
function formatZodModelFile(schemaName, ext = "") {
|
|
1483
1483
|
const lowerName = schemaName.charAt(0).toLowerCase() + schemaName.slice(1);
|
|
1484
1484
|
return `/**
|
|
1485
1485
|
* ${schemaName} Model
|
|
@@ -1490,7 +1490,7 @@ function formatZodModelFile(schemaName, _hasPlaceholders = false) {
|
|
|
1490
1490
|
*/
|
|
1491
1491
|
|
|
1492
1492
|
import { z } from 'zod';
|
|
1493
|
-
import type { ${schemaName} as ${schemaName}Base } from './base/${schemaName}
|
|
1493
|
+
import type { ${schemaName} as ${schemaName}Base } from './base/${schemaName}${ext}';
|
|
1494
1494
|
import {
|
|
1495
1495
|
base${schemaName}Schemas,
|
|
1496
1496
|
base${schemaName}CreateSchema,
|
|
@@ -1499,7 +1499,7 @@ import {
|
|
|
1499
1499
|
get${schemaName}Label,
|
|
1500
1500
|
get${schemaName}FieldLabel,
|
|
1501
1501
|
get${schemaName}FieldPlaceholder,
|
|
1502
|
-
} from './base/${schemaName}
|
|
1502
|
+
} from './base/${schemaName}${ext}';
|
|
1503
1503
|
|
|
1504
1504
|
// ============================================================================
|
|
1505
1505
|
// Types (extend or re-export)
|
|
@@ -1544,9 +1544,14 @@ var DEFAULT_OPTIONS = {
|
|
|
1544
1544
|
strictNullChecks: true,
|
|
1545
1545
|
generateZodSchemas: true,
|
|
1546
1546
|
// Generate Zod schemas by default
|
|
1547
|
-
generateRules: false
|
|
1547
|
+
generateRules: false,
|
|
1548
1548
|
// Legacy Ant Design rules (deprecated, ignored when generateZodSchemas=true)
|
|
1549
|
+
useJsExtension: false
|
|
1550
|
+
// Bundlers (Vite, webpack) don't need .js extension
|
|
1549
1551
|
};
|
|
1552
|
+
function getImportExt(options) {
|
|
1553
|
+
return options.useJsExtension ? ".js" : "";
|
|
1554
|
+
}
|
|
1550
1555
|
function generateBaseHeader() {
|
|
1551
1556
|
return `/**
|
|
1552
1557
|
* Auto-generated TypeScript types from Omnify schemas.
|
|
@@ -1641,8 +1646,9 @@ function generateBaseInterfaceFile(schemaName, schemas, options) {
|
|
|
1641
1646
|
const commonImports = [];
|
|
1642
1647
|
if (dateImports.dateTime) commonImports.push("DateTimeString");
|
|
1643
1648
|
if (dateImports.date) commonImports.push("DateString");
|
|
1649
|
+
const ext = getImportExt(options);
|
|
1644
1650
|
if (commonImports.length > 0) {
|
|
1645
|
-
parts.push(`import type { ${commonImports.join(", ")} } from '../common
|
|
1651
|
+
parts.push(`import type { ${commonImports.join(", ")} } from '../common${ext}';
|
|
1646
1652
|
`);
|
|
1647
1653
|
}
|
|
1648
1654
|
if (iface.enumDependencies && iface.enumDependencies.length > 0) {
|
|
@@ -1651,14 +1657,14 @@ function generateBaseInterfaceFile(schemaName, schemas, options) {
|
|
|
1651
1657
|
options.pluginEnums ? Array.from(options.pluginEnums.keys()) : []
|
|
1652
1658
|
);
|
|
1653
1659
|
for (const enumName of iface.enumDependencies) {
|
|
1654
|
-
const enumPath = pluginEnumNames.has(enumName) ? `${enumPrefix}/plugin/${enumName}
|
|
1660
|
+
const enumPath = pluginEnumNames.has(enumName) ? `${enumPrefix}/plugin/${enumName}${ext}` : `${enumPrefix}/${enumName}${ext}`;
|
|
1655
1661
|
parts.push(`import { ${enumName} } from '${enumPath}';
|
|
1656
1662
|
`);
|
|
1657
1663
|
}
|
|
1658
1664
|
}
|
|
1659
1665
|
if (iface.dependencies && iface.dependencies.length > 0) {
|
|
1660
1666
|
for (const dep of iface.dependencies) {
|
|
1661
|
-
parts.push(`import type { ${dep} } from './${dep}
|
|
1667
|
+
parts.push(`import type { ${dep} } from './${dep}${ext}';
|
|
1662
1668
|
`);
|
|
1663
1669
|
}
|
|
1664
1670
|
parts.push("\n");
|
|
@@ -1712,14 +1718,15 @@ function generateModelFile(schemaName, options) {
|
|
|
1712
1718
|
if (options.generateZodSchemas) {
|
|
1713
1719
|
return {
|
|
1714
1720
|
filePath: `${schemaName}.ts`,
|
|
1715
|
-
content: formatZodModelFile(schemaName),
|
|
1721
|
+
content: formatZodModelFile(schemaName, getImportExt(options)),
|
|
1716
1722
|
types: [schemaName],
|
|
1717
1723
|
overwrite: false
|
|
1718
1724
|
// Never overwrite user models
|
|
1719
1725
|
};
|
|
1720
1726
|
}
|
|
1721
1727
|
const parts = [generateModelHeader(schemaName)];
|
|
1722
|
-
|
|
1728
|
+
const ext = getImportExt(options);
|
|
1729
|
+
parts.push(`import type { ${schemaName} as ${schemaName}Base } from './base/${schemaName}${ext}';
|
|
1723
1730
|
|
|
1724
1731
|
`);
|
|
1725
1732
|
parts.push(`/**
|
|
@@ -1900,8 +1907,9 @@ function generateI18nFile(options) {
|
|
|
1900
1907
|
}
|
|
1901
1908
|
}
|
|
1902
1909
|
const messagesJson = JSON.stringify(mergedMessages, null, 2);
|
|
1910
|
+
const ext = getImportExt(options);
|
|
1903
1911
|
const content = `${generateBaseHeader()}
|
|
1904
|
-
import type { LocaleMap } from './common
|
|
1912
|
+
import type { LocaleMap } from './common${ext}';
|
|
1905
1913
|
|
|
1906
1914
|
/**
|
|
1907
1915
|
* Default locale for this project.
|
|
@@ -1984,9 +1992,10 @@ export function getMessages(locale: string): Record<string, string> {
|
|
|
1984
1992
|
}
|
|
1985
1993
|
function generateIndexFile(schemas, enums, pluginEnums, typeAliases, options) {
|
|
1986
1994
|
const parts = [generateBaseHeader()];
|
|
1995
|
+
const ext = getImportExt(options);
|
|
1987
1996
|
parts.push(`// Common Types
|
|
1988
1997
|
`);
|
|
1989
|
-
parts.push(`export type { LocaleMap, Locale, ValidationRule, DateTimeString, DateString } from './common
|
|
1998
|
+
parts.push(`export type { LocaleMap, Locale, ValidationRule, DateTimeString, DateString } from './common${ext}';
|
|
1990
1999
|
|
|
1991
2000
|
`);
|
|
1992
2001
|
parts.push(`// i18n (Internationalization)
|
|
@@ -2005,7 +2014,7 @@ function generateIndexFile(schemas, enums, pluginEnums, typeAliases, options) {
|
|
|
2005
2014
|
`);
|
|
2006
2015
|
parts.push(` getMessages,
|
|
2007
2016
|
`);
|
|
2008
|
-
parts.push(`} from './i18n
|
|
2017
|
+
parts.push(`} from './i18n${ext}';
|
|
2009
2018
|
|
|
2010
2019
|
`);
|
|
2011
2020
|
const enumPrefix = options.enumImportPrefix ?? "./enum";
|
|
@@ -2025,7 +2034,7 @@ function generateIndexFile(schemas, enums, pluginEnums, typeAliases, options) {
|
|
|
2025
2034
|
`);
|
|
2026
2035
|
parts.push(` get${enumDef.name}Extra,
|
|
2027
2036
|
`);
|
|
2028
|
-
parts.push(`} from '${enumPrefix}/${enumDef.name}
|
|
2037
|
+
parts.push(`} from '${enumPrefix}/${enumDef.name}${ext}';
|
|
2029
2038
|
`);
|
|
2030
2039
|
}
|
|
2031
2040
|
parts.push("\n");
|
|
@@ -2046,7 +2055,7 @@ function generateIndexFile(schemas, enums, pluginEnums, typeAliases, options) {
|
|
|
2046
2055
|
`);
|
|
2047
2056
|
parts.push(` get${enumDef.name}Extra,
|
|
2048
2057
|
`);
|
|
2049
|
-
parts.push(`} from '${enumPrefix}/plugin/${enumDef.name}
|
|
2058
|
+
parts.push(`} from '${enumPrefix}/plugin/${enumDef.name}${ext}';
|
|
2050
2059
|
`);
|
|
2051
2060
|
}
|
|
2052
2061
|
parts.push("\n");
|
|
@@ -2067,7 +2076,7 @@ function generateIndexFile(schemas, enums, pluginEnums, typeAliases, options) {
|
|
|
2067
2076
|
`);
|
|
2068
2077
|
parts.push(` get${alias.name}Extra,
|
|
2069
2078
|
`);
|
|
2070
|
-
parts.push(`} from '${enumPrefix}/${alias.name}
|
|
2079
|
+
parts.push(`} from '${enumPrefix}/${alias.name}${ext}';
|
|
2071
2080
|
`);
|
|
2072
2081
|
}
|
|
2073
2082
|
parts.push("\n");
|
|
@@ -2079,7 +2088,7 @@ function generateIndexFile(schemas, enums, pluginEnums, typeAliases, options) {
|
|
|
2079
2088
|
if (schema.kind === "enum") continue;
|
|
2080
2089
|
if (schema.options?.hidden === true) continue;
|
|
2081
2090
|
const lowerName = schema.name.charAt(0).toLowerCase() + schema.name.slice(1);
|
|
2082
|
-
parts.push(`export type { ${schema.name}, ${schema.name}Create, ${schema.name}Update } from './${schema.name}
|
|
2091
|
+
parts.push(`export type { ${schema.name}, ${schema.name}Create, ${schema.name}Update } from './${schema.name}${ext}';
|
|
2083
2092
|
`);
|
|
2084
2093
|
parts.push(`export {
|
|
2085
2094
|
`);
|
|
@@ -2097,7 +2106,7 @@ function generateIndexFile(schemas, enums, pluginEnums, typeAliases, options) {
|
|
|
2097
2106
|
`);
|
|
2098
2107
|
parts.push(` get${schema.name}FieldPlaceholder,
|
|
2099
2108
|
`);
|
|
2100
|
-
parts.push(`} from './${schema.name}
|
|
2109
|
+
parts.push(`} from './${schema.name}${ext}';
|
|
2101
2110
|
`);
|
|
2102
2111
|
}
|
|
2103
2112
|
} else {
|
|
@@ -2106,9 +2115,9 @@ function generateIndexFile(schemas, enums, pluginEnums, typeAliases, options) {
|
|
|
2106
2115
|
for (const schema of Object.values(schemas)) {
|
|
2107
2116
|
if (schema.kind === "enum") continue;
|
|
2108
2117
|
if (schema.options?.hidden === true) continue;
|
|
2109
|
-
parts.push(`export type { ${schema.name} } from './${schema.name}
|
|
2118
|
+
parts.push(`export type { ${schema.name} } from './${schema.name}${ext}';
|
|
2110
2119
|
`);
|
|
2111
|
-
parts.push(`export type { ${schema.name}Create, ${schema.name}Update } from './base/${schema.name}
|
|
2120
|
+
parts.push(`export type { ${schema.name}Create, ${schema.name}Update } from './base/${schema.name}${ext}';
|
|
2112
2121
|
`);
|
|
2113
2122
|
}
|
|
2114
2123
|
if (options.generateRules) {
|
|
@@ -2126,7 +2135,7 @@ function generateIndexFile(schemas, enums, pluginEnums, typeAliases, options) {
|
|
|
2126
2135
|
`);
|
|
2127
2136
|
parts.push(` get${schema.name}PropertyDisplayName,
|
|
2128
2137
|
`);
|
|
2129
|
-
parts.push(`} from './rules/${schema.name}.rules
|
|
2138
|
+
parts.push(`} from './rules/${schema.name}.rules${ext}';
|
|
2130
2139
|
`);
|
|
2131
2140
|
}
|
|
2132
2141
|
}
|