@famgia/omnify-typescript 0.0.71 → 0.0.73
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-LHNMWILH.js +2221 -0
- package/dist/chunk-LHNMWILH.js.map +1 -0
- package/dist/{chunk-6I4O23X6.js → chunk-NFJACF72.js} +19 -11
- package/dist/chunk-NFJACF72.js.map +1 -0
- package/dist/index.cjs +18 -10
- 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 +18 -10
- 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.
|