@famgia/omnify-typescript 0.0.1
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-2BXDNKIN.js +477 -0
- package/dist/chunk-2BXDNKIN.js.map +1 -0
- package/dist/index.cjs +522 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +200 -0
- package/dist/index.d.ts +200 -0
- package/dist/index.js +45 -0
- package/dist/index.js.map +1 -0
- package/dist/plugin.cjs +545 -0
- package/dist/plugin.cjs.map +1 -0
- package/dist/plugin.d.cts +57 -0
- package/dist/plugin.d.ts +57 -0
- package/dist/plugin.js +82 -0
- package/dist/plugin.js.map +1 -0
- package/package.json +62 -0
package/dist/plugin.d.ts
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { OmnifyPlugin } from '@famgia/omnify-types';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @famgia/omnify-typescript - Plugin
|
|
5
|
+
*
|
|
6
|
+
* Plugin for generating TypeScript type definitions from Omnify schemas.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```typescript
|
|
10
|
+
* import { defineConfig } from '@famgia/omnify';
|
|
11
|
+
* import typescript from '@famgia/omnify-typescript/plugin';
|
|
12
|
+
*
|
|
13
|
+
* export default defineConfig({
|
|
14
|
+
* plugins: [
|
|
15
|
+
* typescript({
|
|
16
|
+
* typesPath: 'src/types',
|
|
17
|
+
* singleFile: true,
|
|
18
|
+
* }),
|
|
19
|
+
* ],
|
|
20
|
+
* });
|
|
21
|
+
* ```
|
|
22
|
+
*/
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Options for the TypeScript plugin.
|
|
26
|
+
*/
|
|
27
|
+
interface TypeScriptPluginOptions {
|
|
28
|
+
/**
|
|
29
|
+
* Path for TypeScript type files.
|
|
30
|
+
* @default 'types'
|
|
31
|
+
*/
|
|
32
|
+
typesPath?: string;
|
|
33
|
+
/**
|
|
34
|
+
* Generate all types in a single file.
|
|
35
|
+
* @default true
|
|
36
|
+
*/
|
|
37
|
+
singleFile?: boolean;
|
|
38
|
+
/**
|
|
39
|
+
* Generate TypeScript enums from schema enums.
|
|
40
|
+
* @default true
|
|
41
|
+
*/
|
|
42
|
+
generateEnums?: boolean;
|
|
43
|
+
/**
|
|
44
|
+
* Include relationship types in interfaces.
|
|
45
|
+
* @default true
|
|
46
|
+
*/
|
|
47
|
+
generateRelationships?: boolean;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Creates the TypeScript plugin with the specified options.
|
|
51
|
+
*
|
|
52
|
+
* @param options - Plugin configuration options
|
|
53
|
+
* @returns OmnifyPlugin configured for TypeScript generation
|
|
54
|
+
*/
|
|
55
|
+
declare function typescriptPlugin(options?: TypeScriptPluginOptions): OmnifyPlugin;
|
|
56
|
+
|
|
57
|
+
export { type TypeScriptPluginOptions, typescriptPlugin as default, typescriptPlugin };
|
package/dist/plugin.js
ADDED
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import {
|
|
2
|
+
generateTypeScript
|
|
3
|
+
} from "./chunk-2BXDNKIN.js";
|
|
4
|
+
|
|
5
|
+
// src/plugin.ts
|
|
6
|
+
var TYPESCRIPT_CONFIG_SCHEMA = {
|
|
7
|
+
fields: [
|
|
8
|
+
{
|
|
9
|
+
key: "typesPath",
|
|
10
|
+
type: "path",
|
|
11
|
+
label: "Types Output Path",
|
|
12
|
+
description: "Directory for generated TypeScript type files",
|
|
13
|
+
default: "types",
|
|
14
|
+
group: "output"
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
key: "singleFile",
|
|
18
|
+
type: "boolean",
|
|
19
|
+
label: "Single File Output",
|
|
20
|
+
description: "Generate all types in a single file (types.ts) instead of separate files",
|
|
21
|
+
default: true,
|
|
22
|
+
group: "output"
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
key: "generateEnums",
|
|
26
|
+
type: "boolean",
|
|
27
|
+
label: "Generate Enums",
|
|
28
|
+
description: "Generate TypeScript enums from schema enums",
|
|
29
|
+
default: true,
|
|
30
|
+
group: "options"
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
key: "generateRelationships",
|
|
34
|
+
type: "boolean",
|
|
35
|
+
label: "Generate Relationships",
|
|
36
|
+
description: "Include relationship types in interfaces",
|
|
37
|
+
default: true,
|
|
38
|
+
group: "options"
|
|
39
|
+
}
|
|
40
|
+
]
|
|
41
|
+
};
|
|
42
|
+
function resolveOptions(options) {
|
|
43
|
+
return {
|
|
44
|
+
typesPath: options?.typesPath ?? "types",
|
|
45
|
+
singleFile: options?.singleFile ?? true,
|
|
46
|
+
generateEnums: options?.generateEnums ?? true,
|
|
47
|
+
generateRelationships: options?.generateRelationships ?? true
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
function typescriptPlugin(options) {
|
|
51
|
+
const resolved = resolveOptions(options);
|
|
52
|
+
return {
|
|
53
|
+
name: "@famgia/omnify-typescript",
|
|
54
|
+
version: "0.0.1",
|
|
55
|
+
configSchema: TYPESCRIPT_CONFIG_SCHEMA,
|
|
56
|
+
generators: [
|
|
57
|
+
{
|
|
58
|
+
name: "typescript-types",
|
|
59
|
+
description: "Generate TypeScript type definitions",
|
|
60
|
+
generate: async (ctx) => {
|
|
61
|
+
const tsOptions = {
|
|
62
|
+
singleFile: resolved.singleFile
|
|
63
|
+
};
|
|
64
|
+
const files = generateTypeScript(ctx.schemas, tsOptions);
|
|
65
|
+
return files.map((file) => ({
|
|
66
|
+
path: `${resolved.typesPath}/${file.fileName}`,
|
|
67
|
+
content: file.content,
|
|
68
|
+
type: "type",
|
|
69
|
+
metadata: {
|
|
70
|
+
types: file.types
|
|
71
|
+
}
|
|
72
|
+
}));
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
]
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
export {
|
|
79
|
+
typescriptPlugin as default,
|
|
80
|
+
typescriptPlugin
|
|
81
|
+
};
|
|
82
|
+
//# sourceMappingURL=plugin.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/plugin.ts"],"sourcesContent":["/**\n * @famgia/omnify-typescript - Plugin\n *\n * Plugin for generating TypeScript type definitions from Omnify schemas.\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 * typesPath: 'src/types',\n * singleFile: true,\n * }),\n * ],\n * });\n * ```\n */\n\nimport type { OmnifyPlugin, GeneratorOutput, GeneratorContext, PluginConfigSchema } from '@famgia/omnify-types';\nimport type { TypeScriptOptions } from './types.js';\nimport { generateTypeScript } from './generator.js';\n\n/**\n * Configuration schema for TypeScript plugin UI settings\n */\nconst TYPESCRIPT_CONFIG_SCHEMA: PluginConfigSchema = {\n fields: [\n {\n key: 'typesPath',\n type: 'path',\n label: 'Types Output Path',\n description: 'Directory for generated TypeScript type files',\n default: 'types',\n group: 'output',\n },\n {\n key: 'singleFile',\n type: 'boolean',\n label: 'Single File Output',\n description: 'Generate all types in a single file (types.ts) instead of separate files',\n default: true,\n group: 'output',\n },\n {\n key: 'generateEnums',\n type: 'boolean',\n label: 'Generate Enums',\n description: 'Generate TypeScript enums from schema enums',\n default: true,\n group: 'options',\n },\n {\n key: 'generateRelationships',\n type: 'boolean',\n label: 'Generate Relationships',\n description: 'Include relationship types in interfaces',\n default: true,\n group: 'options',\n },\n ],\n};\n\n/**\n * Options for the TypeScript plugin.\n */\nexport interface TypeScriptPluginOptions {\n /**\n * Path for TypeScript type files.\n * @default 'types'\n */\n typesPath?: string;\n\n /**\n * Generate all types in a single file.\n * @default true\n */\n singleFile?: boolean;\n\n /**\n * Generate TypeScript enums from schema enums.\n * @default true\n */\n generateEnums?: boolean;\n\n /**\n * Include relationship types in interfaces.\n * @default true\n */\n generateRelationships?: boolean;\n}\n\n/**\n * Resolved options with defaults applied.\n */\ninterface ResolvedOptions {\n typesPath: string;\n singleFile: boolean;\n generateEnums: boolean;\n generateRelationships: boolean;\n}\n\n/**\n * Resolves options with defaults.\n */\nfunction resolveOptions(options?: TypeScriptPluginOptions): ResolvedOptions {\n return {\n typesPath: options?.typesPath ?? 'types',\n singleFile: options?.singleFile ?? true,\n generateEnums: options?.generateEnums ?? true,\n generateRelationships: options?.generateRelationships ?? true,\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-types',\n description: 'Generate TypeScript type definitions',\n\n generate: async (ctx: GeneratorContext): Promise<GeneratorOutput[]> => {\n const tsOptions: TypeScriptOptions = {\n singleFile: resolved.singleFile,\n };\n\n const files = generateTypeScript(ctx.schemas, tsOptions);\n\n return files.map((file) => ({\n path: `${resolved.typesPath}/${file.fileName}`,\n content: file.content,\n type: 'type' as const,\n metadata: {\n types: file.types,\n },\n }));\n },\n },\n ],\n };\n}\n\n// Named export for flexibility\nexport { typescriptPlugin };\n"],"mappings":";;;;;AA4BA,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,IACA;AAAA,MACE,KAAK;AAAA,MACL,MAAM;AAAA,MACN,OAAO;AAAA,MACP,aAAa;AAAA,MACb,SAAS;AAAA,MACT,OAAO;AAAA,IACT;AAAA,EACF;AACF;AA4CA,SAAS,eAAe,SAAoD;AAC1E,SAAO;AAAA,IACL,WAAW,SAAS,aAAa;AAAA,IACjC,YAAY,SAAS,cAAc;AAAA,IACnC,eAAe,SAAS,iBAAiB;AAAA,IACzC,uBAAuB,SAAS,yBAAyB;AAAA,EAC3D;AACF;AAQe,SAAR,iBAAkC,SAAiD;AACxF,QAAM,WAAW,eAAe,OAAO;AAEvC,SAAO;AAAA,IACL,MAAM;AAAA,IACN,SAAS;AAAA,IACT,cAAc;AAAA,IAEd,YAAY;AAAA,MACV;AAAA,QACE,MAAM;AAAA,QACN,aAAa;AAAA,QAEb,UAAU,OAAO,QAAsD;AACrE,gBAAM,YAA+B;AAAA,YACnC,YAAY,SAAS;AAAA,UACvB;AAEA,gBAAM,QAAQ,mBAAmB,IAAI,SAAS,SAAS;AAEvD,iBAAO,MAAM,IAAI,CAAC,UAAU;AAAA,YAC1B,MAAM,GAAG,SAAS,SAAS,IAAI,KAAK,QAAQ;AAAA,YAC5C,SAAS,KAAK;AAAA,YACd,MAAM;AAAA,YACN,UAAU;AAAA,cACR,OAAO,KAAK;AAAA,YACd;AAAA,UACF,EAAE;AAAA,QACJ;AAAA,MACF;AAAA,IACF;AAAA,EACF;AACF;","names":[]}
|
package/package.json
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@famgia/omnify-typescript",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"description": "TypeScript type definitions generator for Omnify schemas",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./dist/index.cjs",
|
|
7
|
+
"module": "./dist/index.js",
|
|
8
|
+
"types": "./dist/index.d.ts",
|
|
9
|
+
"exports": {
|
|
10
|
+
".": {
|
|
11
|
+
"import": {
|
|
12
|
+
"types": "./dist/index.d.ts",
|
|
13
|
+
"default": "./dist/index.js"
|
|
14
|
+
},
|
|
15
|
+
"require": {
|
|
16
|
+
"types": "./dist/index.d.cts",
|
|
17
|
+
"default": "./dist/index.cjs"
|
|
18
|
+
}
|
|
19
|
+
},
|
|
20
|
+
"./plugin": {
|
|
21
|
+
"import": {
|
|
22
|
+
"types": "./dist/plugin.d.ts",
|
|
23
|
+
"default": "./dist/plugin.js"
|
|
24
|
+
},
|
|
25
|
+
"require": {
|
|
26
|
+
"types": "./dist/plugin.d.cts",
|
|
27
|
+
"default": "./dist/plugin.cjs"
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
},
|
|
31
|
+
"files": [
|
|
32
|
+
"dist"
|
|
33
|
+
],
|
|
34
|
+
"keywords": [
|
|
35
|
+
"omnify",
|
|
36
|
+
"typescript",
|
|
37
|
+
"types",
|
|
38
|
+
"generator",
|
|
39
|
+
"schema"
|
|
40
|
+
],
|
|
41
|
+
"author": "famgia",
|
|
42
|
+
"license": "MIT",
|
|
43
|
+
"repository": {
|
|
44
|
+
"type": "git",
|
|
45
|
+
"url": "https://github.com/ecsol/omnify-ts.git",
|
|
46
|
+
"directory": "packages/typescript-generator"
|
|
47
|
+
},
|
|
48
|
+
"dependencies": {
|
|
49
|
+
"@famgia/omnify-types": "0.0.9"
|
|
50
|
+
},
|
|
51
|
+
"devDependencies": {
|
|
52
|
+
"tsup": "^8.5.1",
|
|
53
|
+
"typescript": "^5.8.3",
|
|
54
|
+
"vitest": "^3.2.4"
|
|
55
|
+
},
|
|
56
|
+
"scripts": {
|
|
57
|
+
"build": "tsup",
|
|
58
|
+
"typecheck": "tsc --noEmit",
|
|
59
|
+
"test": "vitest run --passWithNoTests",
|
|
60
|
+
"test:watch": "vitest"
|
|
61
|
+
}
|
|
62
|
+
}
|