@famgia/omnify-typescript 0.0.98 → 0.0.100
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/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/plugin.cjs +5 -5
- package/dist/plugin.cjs.map +1 -1
- package/dist/plugin.js +5 -5
- package/dist/plugin.js.map +1 -1
- package/package.json +2 -2
- package/stubs/form-validation.ts.stub +3 -1
- package/stubs/rules/index.ts.stub +3 -0
- package/stubs/rules/kana.ts.stub +3 -0
- package/stubs/use-form-mutation.ts.stub +3 -1
- package/stubs/zod-i18n.ts.stub +3 -1
package/dist/plugin.js
CHANGED
|
@@ -112,8 +112,8 @@ function typescriptPlugin(options) {
|
|
|
112
112
|
path: `${resolved.stubsPath}/${output}`,
|
|
113
113
|
content,
|
|
114
114
|
type: "other",
|
|
115
|
-
skipIfExists:
|
|
116
|
-
//
|
|
115
|
+
skipIfExists: false
|
|
116
|
+
// Always overwrite - library files should stay in sync
|
|
117
117
|
});
|
|
118
118
|
}
|
|
119
119
|
}
|
|
@@ -122,21 +122,21 @@ function typescriptPlugin(options) {
|
|
|
122
122
|
content: `export { CompoundField, type FieldConfig } from './CompoundField';
|
|
123
123
|
`,
|
|
124
124
|
type: "other",
|
|
125
|
-
skipIfExists:
|
|
125
|
+
skipIfExists: false
|
|
126
126
|
});
|
|
127
127
|
outputs.push({
|
|
128
128
|
path: `${resolved.stubsPath}/hooks/index.ts`,
|
|
129
129
|
content: `export { useFormMutation } from './use-form-mutation';
|
|
130
130
|
`,
|
|
131
131
|
type: "other",
|
|
132
|
-
skipIfExists:
|
|
132
|
+
skipIfExists: false
|
|
133
133
|
});
|
|
134
134
|
outputs.push({
|
|
135
135
|
path: `${resolved.stubsPath}/lib/index.ts`,
|
|
136
136
|
content: `export { zodRule, requiredRule } from './form-validation';
|
|
137
137
|
`,
|
|
138
138
|
type: "other",
|
|
139
|
-
skipIfExists:
|
|
139
|
+
skipIfExists: false
|
|
140
140
|
});
|
|
141
141
|
return outputs;
|
|
142
142
|
}
|
package/dist/plugin.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/plugin.ts"],"sourcesContent":["/**\n * @famgia/omnify-typescript - Plugin\n *\n * Plugin for generating TypeScript type definitions and Zod schemas from Omnify schemas.\n *\n * Output structure:\n * - types/schemas/base/[SchemaName].ts - Auto-generated base interfaces + Zod schemas, always overwritten\n * - types/schemas/enum/[EnumName].ts - Auto-generated enums/type aliases, always overwritten\n * - types/schemas/[SchemaName].ts - Extends base, user can customize, never overwritten\n * - types/schemas/index.ts - Re-exports, always overwritten\n *\n * @example\n * ```typescript\n * import { defineConfig } from '@famgia/omnify';\n * import typescript from '@famgia/omnify-typescript/plugin';\n *\n * export default defineConfig({\n * plugins: [\n * typescript({\n * modelsPath: 'types/schemas', // default\n * generateZodSchemas: true, // default\n * }),\n * ],\n * });\n * ```\n */\n\nimport type { OmnifyPlugin, GeneratorOutput, GeneratorContext, PluginConfigSchema } from '@famgia/omnify-types';\nimport { generateTypeScript } from './generator.js';\nimport fs from 'fs';\nimport path from 'path';\nimport { fileURLToPath } from 'url';\n\nconst __filename = fileURLToPath(import.meta.url);\nconst __dirname = path.dirname(__filename);\n\n/**\n * Configuration schema for TypeScript plugin UI settings\n */\nconst TYPESCRIPT_CONFIG_SCHEMA: PluginConfigSchema = {\n fields: [\n {\n key: 'modelsPath',\n type: 'path',\n label: 'Schemas Output Path',\n description: 'Directory for generated TypeScript types and Zod schemas',\n default: 'types/schemas',\n group: 'output',\n },\n {\n key: 'generateZodSchemas',\n type: 'boolean',\n label: 'Generate Zod Schemas',\n description: 'Generate Zod schemas alongside TypeScript types for form validation',\n default: true,\n group: 'output',\n },\n {\n key: 'stubsPath',\n type: 'path',\n label: 'React Stubs Path',\n description: 'Directory for React utility stubs (hooks, components). Leave empty to disable.',\n default: 'omnify',\n group: 'output',\n },\n ],\n};\n\n/**\n * Options for the TypeScript plugin.\n */\nexport interface TypeScriptPluginOptions {\n /**\n * Path for TypeScript model files.\n * @default 'types/schemas'\n */\n modelsPath?: string;\n /**\n * Generate Zod schemas alongside TypeScript types.\n * @default true\n */\n generateZodSchemas?: boolean;\n /**\n * Path for React utility stubs (hooks, components, lib).\n * Set to false to disable stub generation.\n * @default 'omnify'\n */\n stubsPath?: string | false;\n}\n\n/**\n * Resolved options with defaults applied.\n */\ninterface ResolvedOptions {\n modelsPath: string;\n generateZodSchemas: boolean;\n stubsPath: string | false;\n}\n\n/**\n * Resolves options with defaults.\n */\nfunction resolveOptions(options?: TypeScriptPluginOptions): ResolvedOptions {\n return {\n modelsPath: options?.modelsPath ?? 'types/schemas',\n generateZodSchemas: options?.generateZodSchemas ?? true,\n stubsPath: options?.stubsPath ?? 'omnify',\n };\n}\n\n/**\n * Stub file definitions for React utilities.\n */\nconst STUB_FILES = [\n {\n stub: 'CompoundField.tsx.stub',\n output: 'components/CompoundField.tsx',\n },\n {\n stub: 'use-form-mutation.ts.stub',\n output: 'hooks/use-form-mutation.ts',\n },\n {\n stub: 'form-validation.ts.stub',\n output: 'lib/form-validation.ts',\n },\n];\n\n/**\n * Creates the TypeScript plugin with the specified options.\n *\n * @param options - Plugin configuration options\n * @returns OmnifyPlugin configured for TypeScript generation\n */\nexport default function typescriptPlugin(options?: TypeScriptPluginOptions): OmnifyPlugin {\n const resolved = resolveOptions(options);\n\n return {\n name: '@famgia/omnify-typescript',\n version: '0.0.1',\n configSchema: TYPESCRIPT_CONFIG_SCHEMA,\n\n generators: [\n {\n name: 'typescript-models',\n description: 'Generate TypeScript model definitions',\n\n generate: async (ctx: GeneratorContext): Promise<GeneratorOutput[]> => {\n const files = generateTypeScript(ctx.schemas, {\n generateZodSchemas: resolved.generateZodSchemas,\n localeConfig: ctx.localeConfig,\n customTypes: ctx.customTypes,\n pluginEnums: ctx.pluginEnums,\n });\n\n return files.map((file) => {\n // Determine output path based on category\n let outputPath: string;\n if (file.category === 'enum') {\n // Enum files go to ../enum/ folder (sibling to schemas)\n const enumPath = resolved.modelsPath.replace(/\\/schemas\\/?$/, '/enum');\n outputPath = `${enumPath}/${file.filePath}`;\n } else {\n outputPath = `${resolved.modelsPath}/${file.filePath}`;\n }\n\n return {\n path: outputPath,\n content: file.content,\n type: 'type' as const,\n skipIfExists: !file.overwrite, // Invert: overwrite=true means skipIfExists=false\n metadata: {\n types: file.types,\n },\n };\n });\n },\n },\n {\n name: 'typescript-stubs',\n description: 'Generate React utility stubs (hooks, components)',\n\n generate: async (): Promise<GeneratorOutput[]> => {\n // Skip if stubs disabled\n if (resolved.stubsPath === false) {\n return [];\n }\n\n const outputs: GeneratorOutput[] = [];\n const stubsDir = path.join(__dirname, '..', 'stubs');\n\n for (const { stub, output } of STUB_FILES) {\n const stubPath = path.join(stubsDir, stub);\n if (fs.existsSync(stubPath)) {\n const content = fs.readFileSync(stubPath, 'utf-8');\n outputs.push({\n path: `${resolved.stubsPath}/${output}`,\n content,\n type: 'other' as const,\n skipIfExists:
|
|
1
|
+
{"version":3,"sources":["../src/plugin.ts"],"sourcesContent":["/**\n * @famgia/omnify-typescript - Plugin\n *\n * Plugin for generating TypeScript type definitions and Zod schemas from Omnify schemas.\n *\n * Output structure:\n * - types/schemas/base/[SchemaName].ts - Auto-generated base interfaces + Zod schemas, always overwritten\n * - types/schemas/enum/[EnumName].ts - Auto-generated enums/type aliases, always overwritten\n * - types/schemas/[SchemaName].ts - Extends base, user can customize, never overwritten\n * - types/schemas/index.ts - Re-exports, always overwritten\n *\n * @example\n * ```typescript\n * import { defineConfig } from '@famgia/omnify';\n * import typescript from '@famgia/omnify-typescript/plugin';\n *\n * export default defineConfig({\n * plugins: [\n * typescript({\n * modelsPath: 'types/schemas', // default\n * generateZodSchemas: true, // default\n * }),\n * ],\n * });\n * ```\n */\n\nimport type { OmnifyPlugin, GeneratorOutput, GeneratorContext, PluginConfigSchema } from '@famgia/omnify-types';\nimport { generateTypeScript } from './generator.js';\nimport fs from 'fs';\nimport path from 'path';\nimport { fileURLToPath } from 'url';\n\nconst __filename = fileURLToPath(import.meta.url);\nconst __dirname = path.dirname(__filename);\n\n/**\n * Configuration schema for TypeScript plugin UI settings\n */\nconst TYPESCRIPT_CONFIG_SCHEMA: PluginConfigSchema = {\n fields: [\n {\n key: 'modelsPath',\n type: 'path',\n label: 'Schemas Output Path',\n description: 'Directory for generated TypeScript types and Zod schemas',\n default: 'types/schemas',\n group: 'output',\n },\n {\n key: 'generateZodSchemas',\n type: 'boolean',\n label: 'Generate Zod Schemas',\n description: 'Generate Zod schemas alongside TypeScript types for form validation',\n default: true,\n group: 'output',\n },\n {\n key: 'stubsPath',\n type: 'path',\n label: 'React Stubs Path',\n description: 'Directory for React utility stubs (hooks, components). Leave empty to disable.',\n default: 'omnify',\n group: 'output',\n },\n ],\n};\n\n/**\n * Options for the TypeScript plugin.\n */\nexport interface TypeScriptPluginOptions {\n /**\n * Path for TypeScript model files.\n * @default 'types/schemas'\n */\n modelsPath?: string;\n /**\n * Generate Zod schemas alongside TypeScript types.\n * @default true\n */\n generateZodSchemas?: boolean;\n /**\n * Path for React utility stubs (hooks, components, lib).\n * Set to false to disable stub generation.\n * @default 'omnify'\n */\n stubsPath?: string | false;\n}\n\n/**\n * Resolved options with defaults applied.\n */\ninterface ResolvedOptions {\n modelsPath: string;\n generateZodSchemas: boolean;\n stubsPath: string | false;\n}\n\n/**\n * Resolves options with defaults.\n */\nfunction resolveOptions(options?: TypeScriptPluginOptions): ResolvedOptions {\n return {\n modelsPath: options?.modelsPath ?? 'types/schemas',\n generateZodSchemas: options?.generateZodSchemas ?? true,\n stubsPath: options?.stubsPath ?? 'omnify',\n };\n}\n\n/**\n * Stub file definitions for React utilities.\n */\nconst STUB_FILES = [\n {\n stub: 'CompoundField.tsx.stub',\n output: 'components/CompoundField.tsx',\n },\n {\n stub: 'use-form-mutation.ts.stub',\n output: 'hooks/use-form-mutation.ts',\n },\n {\n stub: 'form-validation.ts.stub',\n output: 'lib/form-validation.ts',\n },\n];\n\n/**\n * Creates the TypeScript plugin with the specified options.\n *\n * @param options - Plugin configuration options\n * @returns OmnifyPlugin configured for TypeScript generation\n */\nexport default function typescriptPlugin(options?: TypeScriptPluginOptions): OmnifyPlugin {\n const resolved = resolveOptions(options);\n\n return {\n name: '@famgia/omnify-typescript',\n version: '0.0.1',\n configSchema: TYPESCRIPT_CONFIG_SCHEMA,\n\n generators: [\n {\n name: 'typescript-models',\n description: 'Generate TypeScript model definitions',\n\n generate: async (ctx: GeneratorContext): Promise<GeneratorOutput[]> => {\n const files = generateTypeScript(ctx.schemas, {\n generateZodSchemas: resolved.generateZodSchemas,\n localeConfig: ctx.localeConfig,\n customTypes: ctx.customTypes,\n pluginEnums: ctx.pluginEnums,\n });\n\n return files.map((file) => {\n // Determine output path based on category\n let outputPath: string;\n if (file.category === 'enum') {\n // Enum files go to ../enum/ folder (sibling to schemas)\n const enumPath = resolved.modelsPath.replace(/\\/schemas\\/?$/, '/enum');\n outputPath = `${enumPath}/${file.filePath}`;\n } else {\n outputPath = `${resolved.modelsPath}/${file.filePath}`;\n }\n\n return {\n path: outputPath,\n content: file.content,\n type: 'type' as const,\n skipIfExists: !file.overwrite, // Invert: overwrite=true means skipIfExists=false\n metadata: {\n types: file.types,\n },\n };\n });\n },\n },\n {\n name: 'typescript-stubs',\n description: 'Generate React utility stubs (hooks, components)',\n\n generate: async (): Promise<GeneratorOutput[]> => {\n // Skip if stubs disabled\n if (resolved.stubsPath === false) {\n return [];\n }\n\n const outputs: GeneratorOutput[] = [];\n const stubsDir = path.join(__dirname, '..', 'stubs');\n\n for (const { stub, output } of STUB_FILES) {\n const stubPath = path.join(stubsDir, stub);\n if (fs.existsSync(stubPath)) {\n const content = fs.readFileSync(stubPath, 'utf-8');\n outputs.push({\n path: `${resolved.stubsPath}/${output}`,\n content,\n type: 'other' as const,\n skipIfExists: false, // Always overwrite - library files should stay in sync\n });\n }\n }\n\n // Generate index files\n outputs.push({\n path: `${resolved.stubsPath}/components/index.ts`,\n content: `export { CompoundField, type FieldConfig } from './CompoundField';\\n`,\n type: 'other' as const,\n skipIfExists: false,\n });\n\n outputs.push({\n path: `${resolved.stubsPath}/hooks/index.ts`,\n content: `export { useFormMutation } from './use-form-mutation';\\n`,\n type: 'other' as const,\n skipIfExists: false,\n });\n\n outputs.push({\n path: `${resolved.stubsPath}/lib/index.ts`,\n content: `export { zodRule, requiredRule } from './form-validation';\\n`,\n type: 'other' as const,\n skipIfExists: false,\n });\n\n return outputs;\n },\n },\n ],\n };\n}\n\n// Named export for flexibility\nexport { typescriptPlugin };\n"],"mappings":";;;;;AA6BA,OAAO,QAAQ;AACf,OAAO,UAAU;AACjB,SAAS,qBAAqB;AAE9B,IAAM,aAAa,cAAc,YAAY,GAAG;AAChD,IAAM,YAAY,KAAK,QAAQ,UAAU;AAKzC,IAAM,2BAA+C;AAAA,EACnD,QAAQ;AAAA,IACN;AAAA,MACE,KAAK;AAAA,MACL,MAAM;AAAA,MACN,OAAO;AAAA,MACP,aAAa;AAAA,MACb,SAAS;AAAA,MACT,OAAO;AAAA,IACT;AAAA,IACA;AAAA,MACE,KAAK;AAAA,MACL,MAAM;AAAA,MACN,OAAO;AAAA,MACP,aAAa;AAAA,MACb,SAAS;AAAA,MACT,OAAO;AAAA,IACT;AAAA,IACA;AAAA,MACE,KAAK;AAAA,MACL,MAAM;AAAA,MACN,OAAO;AAAA,MACP,aAAa;AAAA,MACb,SAAS;AAAA,MACT,OAAO;AAAA,IACT;AAAA,EACF;AACF;AAoCA,SAAS,eAAe,SAAoD;AAC1E,SAAO;AAAA,IACL,YAAY,SAAS,cAAc;AAAA,IACnC,oBAAoB,SAAS,sBAAsB;AAAA,IACnD,WAAW,SAAS,aAAa;AAAA,EACnC;AACF;AAKA,IAAM,aAAa;AAAA,EACjB;AAAA,IACE,MAAM;AAAA,IACN,QAAQ;A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BAAM,WAAW,KAAK,KAAK,UAAU,IAAI;AACzC,gBAAI,GAAG,WAAW,QAAQ,GAAG;AAC3B,oBAAM,UAAU,GAAG,aAAa,UAAU,OAAO;AACjD,sBAAQ,KAAK;AAAA,gBACX,MAAM,GAAG,SAAS,SAAS,IAAI,MAAM;AAAA,gBACrC;AAAA,gBACA,MAAM;AAAA,gBACN,cAAc;AAAA;AAAA,cAChB,CAAC;AAAA,YACH;AAAA,UACF;AAGA,kBAAQ,KAAK;AAAA,YACX,MAAM,GAAG,SAAS,SAAS;AAAA,YAC3B,SAAS;AAAA;AAAA,YACT,MAAM;AAAA,YACN,cAAc;AAAA,UAChB,CAAC;AAED,kBAAQ,KAAK;AAAA,YACX,MAAM,GAAG,SAAS,SAAS;AAAA,YAC3B,SAAS;AAAA;AAAA,YACT,MAAM;AAAA,YACN,cAAc;AAAA,UAChB,CAAC;AAED,kBAAQ,KAAK;AAAA,YACX,MAAM,GAAG,SAAS,SAAS;AAAA,YAC3B,SAAS;AAAA;AAAA,YACT,MAAM;AAAA,YACN,cAAc;AAAA,UAChB,CAAC;AAED,iBAAO;AAAA,QACT;AAAA,MACF;AAAA,IACF;AAAA,EACF;AACF;","names":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@famgia/omnify-typescript",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.100",
|
|
4
4
|
"description": "TypeScript type definitions generator for Omnify schemas",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.cjs",
|
|
@@ -48,7 +48,7 @@
|
|
|
48
48
|
"directory": "packages/typescript-generator"
|
|
49
49
|
},
|
|
50
50
|
"dependencies": {
|
|
51
|
-
"@famgia/omnify-types": "0.0.
|
|
51
|
+
"@famgia/omnify-types": "0.0.110"
|
|
52
52
|
},
|
|
53
53
|
"peerDependencies": {
|
|
54
54
|
"zod": "^3.0.0"
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Form validation utilities for Ant Design + Zod
|
|
3
|
-
*
|
|
3
|
+
*
|
|
4
|
+
* ⚠️ AUTO-GENERATED by Omnify - DO NOT EDIT
|
|
5
|
+
* This file is overwritten on every `npx omnify generate`
|
|
4
6
|
*/
|
|
5
7
|
|
|
6
8
|
import type { RuleObject } from 'antd/es/form';
|
package/stubs/rules/kana.ts.stub
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Japanese Kana Validation Rules
|
|
3
3
|
*
|
|
4
|
+
* ⚠️ AUTO-GENERATED by Omnify - DO NOT EDIT
|
|
5
|
+
* This file is overwritten on every `npx omnify generate`
|
|
6
|
+
*
|
|
4
7
|
* Provides configurable validation for Japanese character input:
|
|
5
8
|
* - 全角カタカナ (Full-width Katakana) - default
|
|
6
9
|
* - 半角カタカナ (Half-width Katakana)
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* useFormMutation - Form mutation with auto Laravel error handling
|
|
3
|
-
*
|
|
3
|
+
*
|
|
4
|
+
* ⚠️ AUTO-GENERATED by Omnify - DO NOT EDIT
|
|
5
|
+
* This file is overwritten on every `npx omnify generate`
|
|
4
6
|
*
|
|
5
7
|
* @example
|
|
6
8
|
* const mutation = useFormMutation({
|
package/stubs/zod-i18n.ts.stub
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Zod i18n - Localization for Zod validation messages
|
|
3
|
-
*
|
|
3
|
+
*
|
|
4
|
+
* ⚠️ AUTO-GENERATED by Omnify - DO NOT EDIT
|
|
5
|
+
* This file is overwritten on every `npx omnify generate`
|
|
4
6
|
*/
|
|
5
7
|
|
|
6
8
|
import { getMessage, defaultLocale } from '../schemas/i18n';
|