@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.
@@ -0,0 +1,200 @@
1
+ import { PropertyDefinition, SchemaCollection, LoadedSchema } from '@famgia/omnify-types';
2
+
3
+ /**
4
+ * @famgia/omnify-laravel - TypeScript Types
5
+ *
6
+ * Types for TypeScript code generation.
7
+ */
8
+ /**
9
+ * Generated TypeScript file.
10
+ */
11
+ interface TypeScriptFile {
12
+ /** File name */
13
+ readonly fileName: string;
14
+ /** Full file content */
15
+ readonly content: string;
16
+ /** Types defined in this file */
17
+ readonly types: readonly string[];
18
+ }
19
+ /**
20
+ * TypeScript generation options.
21
+ */
22
+ interface TypeScriptOptions {
23
+ /** Output directory for TypeScript files */
24
+ readonly outputDir?: string | undefined;
25
+ /** Whether to generate a single file or multiple files */
26
+ readonly singleFile?: boolean | undefined;
27
+ /** File name for single file output */
28
+ readonly fileName?: string | undefined;
29
+ /** Whether to export as default */
30
+ readonly exportDefault?: boolean | undefined;
31
+ /** Whether to include readonly modifiers */
32
+ readonly readonly?: boolean | undefined;
33
+ /** Whether to use strict null checks compatible types */
34
+ readonly strictNullChecks?: boolean | undefined;
35
+ }
36
+ /**
37
+ * TypeScript property definition.
38
+ */
39
+ interface TSProperty {
40
+ /** Property name */
41
+ readonly name: string;
42
+ /** TypeScript type */
43
+ readonly type: string;
44
+ /** Whether the property is optional */
45
+ readonly optional: boolean;
46
+ /** Whether the property is readonly */
47
+ readonly readonly: boolean;
48
+ /** JSDoc comment */
49
+ readonly comment?: string | undefined;
50
+ }
51
+ /**
52
+ * TypeScript interface definition.
53
+ */
54
+ interface TSInterface {
55
+ /** Interface name */
56
+ readonly name: string;
57
+ /** Properties */
58
+ readonly properties: readonly TSProperty[];
59
+ /** Extended interfaces */
60
+ readonly extends?: readonly string[] | undefined;
61
+ /** JSDoc comment */
62
+ readonly comment?: string | undefined;
63
+ }
64
+ /**
65
+ * TypeScript enum definition.
66
+ */
67
+ interface TSEnum {
68
+ /** Enum name */
69
+ readonly name: string;
70
+ /** Enum values */
71
+ readonly values: readonly TSEnumValue[];
72
+ /** JSDoc comment */
73
+ readonly comment?: string | undefined;
74
+ }
75
+ /**
76
+ * TypeScript enum value.
77
+ */
78
+ interface TSEnumValue {
79
+ /** Value name */
80
+ readonly name: string;
81
+ /** Value (string or number) */
82
+ readonly value: string | number;
83
+ }
84
+ /**
85
+ * TypeScript type alias definition.
86
+ */
87
+ interface TSTypeAlias {
88
+ /** Type name */
89
+ readonly name: string;
90
+ /** Type definition */
91
+ readonly type: string;
92
+ /** JSDoc comment */
93
+ readonly comment?: string | undefined;
94
+ }
95
+
96
+ /**
97
+ * @famgia/omnify-laravel - TypeScript Interface Generator
98
+ *
99
+ * Generates TypeScript interfaces from schemas.
100
+ */
101
+
102
+ /**
103
+ * Converts property name to TypeScript property name.
104
+ * Preserves camelCase.
105
+ */
106
+ declare function toPropertyName(name: string): string;
107
+ /**
108
+ * Converts schema name to TypeScript interface name.
109
+ * Preserves PascalCase.
110
+ */
111
+ declare function toInterfaceName(schemaName: string): string;
112
+ /**
113
+ * Gets TypeScript type for a property.
114
+ */
115
+ declare function getPropertyType(property: PropertyDefinition, _allSchemas: SchemaCollection): string;
116
+ /**
117
+ * Converts a property to TypeScript property definition (legacy - returns single property).
118
+ */
119
+ declare function propertyToTSProperty(propertyName: string, property: PropertyDefinition, allSchemas: SchemaCollection, options?: TypeScriptOptions): TSProperty;
120
+ /**
121
+ * Generates TypeScript interface from schema.
122
+ */
123
+ declare function schemaToInterface(schema: LoadedSchema, allSchemas: SchemaCollection, options?: TypeScriptOptions): TSInterface;
124
+ /**
125
+ * Formats a TypeScript property.
126
+ */
127
+ declare function formatProperty(property: TSProperty): string;
128
+ /**
129
+ * Formats a TypeScript interface.
130
+ */
131
+ declare function formatInterface(iface: TSInterface): string;
132
+ /**
133
+ * Generates interfaces for all schemas.
134
+ * Note: File interface is now generated from File.yaml schema (use ensureFileSchema() to auto-create it).
135
+ */
136
+ declare function generateInterfaces(schemas: SchemaCollection, options?: TypeScriptOptions): TSInterface[];
137
+
138
+ /**
139
+ * @famgia/omnify-laravel - TypeScript Enum Generator
140
+ *
141
+ * Generates TypeScript enums from schema enum definitions.
142
+ */
143
+
144
+ /**
145
+ * Converts enum value to valid TypeScript enum member name.
146
+ */
147
+ declare function toEnumMemberName(value: string): string;
148
+ /**
149
+ * Converts schema name to TypeScript enum name.
150
+ */
151
+ declare function toEnumName(schemaName: string): string;
152
+ /**
153
+ * Generates TypeScript enum from schema enum.
154
+ */
155
+ declare function schemaToEnum(schema: LoadedSchema): TSEnum | null;
156
+ /**
157
+ * Generates enums for all enum schemas.
158
+ */
159
+ declare function generateEnums(schemas: SchemaCollection): TSEnum[];
160
+ /**
161
+ * Formats a TypeScript enum.
162
+ */
163
+ declare function formatEnum(enumDef: TSEnum): string;
164
+ /**
165
+ * Generates a union type alias as an alternative to enum.
166
+ */
167
+ declare function enumToUnionType(enumDef: TSEnum): TSTypeAlias;
168
+ /**
169
+ * Formats a TypeScript type alias.
170
+ */
171
+ declare function formatTypeAlias(alias: TSTypeAlias): string;
172
+ /**
173
+ * Extracts inline enums from properties for type generation.
174
+ */
175
+ declare function extractInlineEnums(schemas: SchemaCollection): TSTypeAlias[];
176
+
177
+ /**
178
+ * @famgia/omnify-laravel - TypeScript Generator
179
+ *
180
+ * Main TypeScript code generator combining interfaces, enums, and types.
181
+ */
182
+
183
+ /**
184
+ * Generates all TypeScript code as a single file.
185
+ */
186
+ declare function generateTypeScriptFile(schemas: SchemaCollection, options?: TypeScriptOptions): TypeScriptFile;
187
+ /**
188
+ * Generates TypeScript code as multiple files.
189
+ */
190
+ declare function generateTypeScriptFiles(schemas: SchemaCollection, options?: TypeScriptOptions): TypeScriptFile[];
191
+ /**
192
+ * Generates TypeScript types with configurable output.
193
+ */
194
+ declare function generateTypeScript(schemas: SchemaCollection, options?: TypeScriptOptions): TypeScriptFile[];
195
+ /**
196
+ * Gets output path for a TypeScript file.
197
+ */
198
+ declare function getTypeScriptPath(file: TypeScriptFile, outputDir?: string): string;
199
+
200
+ export { type TSEnum, type TSEnumValue, type TSInterface, type TSProperty, type TSTypeAlias, type TypeScriptFile, type TypeScriptOptions, enumToUnionType, extractInlineEnums, formatEnum, formatInterface, formatProperty, formatTypeAlias, generateEnums, generateInterfaces, generateTypeScript, generateTypeScriptFile, generateTypeScriptFiles, getPropertyType, getTypeScriptPath, propertyToTSProperty, schemaToEnum, schemaToInterface, toEnumMemberName, toEnumName, toInterfaceName, toPropertyName };
@@ -0,0 +1,200 @@
1
+ import { PropertyDefinition, SchemaCollection, LoadedSchema } from '@famgia/omnify-types';
2
+
3
+ /**
4
+ * @famgia/omnify-laravel - TypeScript Types
5
+ *
6
+ * Types for TypeScript code generation.
7
+ */
8
+ /**
9
+ * Generated TypeScript file.
10
+ */
11
+ interface TypeScriptFile {
12
+ /** File name */
13
+ readonly fileName: string;
14
+ /** Full file content */
15
+ readonly content: string;
16
+ /** Types defined in this file */
17
+ readonly types: readonly string[];
18
+ }
19
+ /**
20
+ * TypeScript generation options.
21
+ */
22
+ interface TypeScriptOptions {
23
+ /** Output directory for TypeScript files */
24
+ readonly outputDir?: string | undefined;
25
+ /** Whether to generate a single file or multiple files */
26
+ readonly singleFile?: boolean | undefined;
27
+ /** File name for single file output */
28
+ readonly fileName?: string | undefined;
29
+ /** Whether to export as default */
30
+ readonly exportDefault?: boolean | undefined;
31
+ /** Whether to include readonly modifiers */
32
+ readonly readonly?: boolean | undefined;
33
+ /** Whether to use strict null checks compatible types */
34
+ readonly strictNullChecks?: boolean | undefined;
35
+ }
36
+ /**
37
+ * TypeScript property definition.
38
+ */
39
+ interface TSProperty {
40
+ /** Property name */
41
+ readonly name: string;
42
+ /** TypeScript type */
43
+ readonly type: string;
44
+ /** Whether the property is optional */
45
+ readonly optional: boolean;
46
+ /** Whether the property is readonly */
47
+ readonly readonly: boolean;
48
+ /** JSDoc comment */
49
+ readonly comment?: string | undefined;
50
+ }
51
+ /**
52
+ * TypeScript interface definition.
53
+ */
54
+ interface TSInterface {
55
+ /** Interface name */
56
+ readonly name: string;
57
+ /** Properties */
58
+ readonly properties: readonly TSProperty[];
59
+ /** Extended interfaces */
60
+ readonly extends?: readonly string[] | undefined;
61
+ /** JSDoc comment */
62
+ readonly comment?: string | undefined;
63
+ }
64
+ /**
65
+ * TypeScript enum definition.
66
+ */
67
+ interface TSEnum {
68
+ /** Enum name */
69
+ readonly name: string;
70
+ /** Enum values */
71
+ readonly values: readonly TSEnumValue[];
72
+ /** JSDoc comment */
73
+ readonly comment?: string | undefined;
74
+ }
75
+ /**
76
+ * TypeScript enum value.
77
+ */
78
+ interface TSEnumValue {
79
+ /** Value name */
80
+ readonly name: string;
81
+ /** Value (string or number) */
82
+ readonly value: string | number;
83
+ }
84
+ /**
85
+ * TypeScript type alias definition.
86
+ */
87
+ interface TSTypeAlias {
88
+ /** Type name */
89
+ readonly name: string;
90
+ /** Type definition */
91
+ readonly type: string;
92
+ /** JSDoc comment */
93
+ readonly comment?: string | undefined;
94
+ }
95
+
96
+ /**
97
+ * @famgia/omnify-laravel - TypeScript Interface Generator
98
+ *
99
+ * Generates TypeScript interfaces from schemas.
100
+ */
101
+
102
+ /**
103
+ * Converts property name to TypeScript property name.
104
+ * Preserves camelCase.
105
+ */
106
+ declare function toPropertyName(name: string): string;
107
+ /**
108
+ * Converts schema name to TypeScript interface name.
109
+ * Preserves PascalCase.
110
+ */
111
+ declare function toInterfaceName(schemaName: string): string;
112
+ /**
113
+ * Gets TypeScript type for a property.
114
+ */
115
+ declare function getPropertyType(property: PropertyDefinition, _allSchemas: SchemaCollection): string;
116
+ /**
117
+ * Converts a property to TypeScript property definition (legacy - returns single property).
118
+ */
119
+ declare function propertyToTSProperty(propertyName: string, property: PropertyDefinition, allSchemas: SchemaCollection, options?: TypeScriptOptions): TSProperty;
120
+ /**
121
+ * Generates TypeScript interface from schema.
122
+ */
123
+ declare function schemaToInterface(schema: LoadedSchema, allSchemas: SchemaCollection, options?: TypeScriptOptions): TSInterface;
124
+ /**
125
+ * Formats a TypeScript property.
126
+ */
127
+ declare function formatProperty(property: TSProperty): string;
128
+ /**
129
+ * Formats a TypeScript interface.
130
+ */
131
+ declare function formatInterface(iface: TSInterface): string;
132
+ /**
133
+ * Generates interfaces for all schemas.
134
+ * Note: File interface is now generated from File.yaml schema (use ensureFileSchema() to auto-create it).
135
+ */
136
+ declare function generateInterfaces(schemas: SchemaCollection, options?: TypeScriptOptions): TSInterface[];
137
+
138
+ /**
139
+ * @famgia/omnify-laravel - TypeScript Enum Generator
140
+ *
141
+ * Generates TypeScript enums from schema enum definitions.
142
+ */
143
+
144
+ /**
145
+ * Converts enum value to valid TypeScript enum member name.
146
+ */
147
+ declare function toEnumMemberName(value: string): string;
148
+ /**
149
+ * Converts schema name to TypeScript enum name.
150
+ */
151
+ declare function toEnumName(schemaName: string): string;
152
+ /**
153
+ * Generates TypeScript enum from schema enum.
154
+ */
155
+ declare function schemaToEnum(schema: LoadedSchema): TSEnum | null;
156
+ /**
157
+ * Generates enums for all enum schemas.
158
+ */
159
+ declare function generateEnums(schemas: SchemaCollection): TSEnum[];
160
+ /**
161
+ * Formats a TypeScript enum.
162
+ */
163
+ declare function formatEnum(enumDef: TSEnum): string;
164
+ /**
165
+ * Generates a union type alias as an alternative to enum.
166
+ */
167
+ declare function enumToUnionType(enumDef: TSEnum): TSTypeAlias;
168
+ /**
169
+ * Formats a TypeScript type alias.
170
+ */
171
+ declare function formatTypeAlias(alias: TSTypeAlias): string;
172
+ /**
173
+ * Extracts inline enums from properties for type generation.
174
+ */
175
+ declare function extractInlineEnums(schemas: SchemaCollection): TSTypeAlias[];
176
+
177
+ /**
178
+ * @famgia/omnify-laravel - TypeScript Generator
179
+ *
180
+ * Main TypeScript code generator combining interfaces, enums, and types.
181
+ */
182
+
183
+ /**
184
+ * Generates all TypeScript code as a single file.
185
+ */
186
+ declare function generateTypeScriptFile(schemas: SchemaCollection, options?: TypeScriptOptions): TypeScriptFile;
187
+ /**
188
+ * Generates TypeScript code as multiple files.
189
+ */
190
+ declare function generateTypeScriptFiles(schemas: SchemaCollection, options?: TypeScriptOptions): TypeScriptFile[];
191
+ /**
192
+ * Generates TypeScript types with configurable output.
193
+ */
194
+ declare function generateTypeScript(schemas: SchemaCollection, options?: TypeScriptOptions): TypeScriptFile[];
195
+ /**
196
+ * Gets output path for a TypeScript file.
197
+ */
198
+ declare function getTypeScriptPath(file: TypeScriptFile, outputDir?: string): string;
199
+
200
+ export { type TSEnum, type TSEnumValue, type TSInterface, type TSProperty, type TSTypeAlias, type TypeScriptFile, type TypeScriptOptions, enumToUnionType, extractInlineEnums, formatEnum, formatInterface, formatProperty, formatTypeAlias, generateEnums, generateInterfaces, generateTypeScript, generateTypeScriptFile, generateTypeScriptFiles, getPropertyType, getTypeScriptPath, propertyToTSProperty, schemaToEnum, schemaToInterface, toEnumMemberName, toEnumName, toInterfaceName, toPropertyName };
package/dist/index.js ADDED
@@ -0,0 +1,45 @@
1
+ import {
2
+ enumToUnionType,
3
+ extractInlineEnums,
4
+ formatEnum,
5
+ formatInterface,
6
+ formatProperty,
7
+ formatTypeAlias,
8
+ generateEnums,
9
+ generateInterfaces,
10
+ generateTypeScript,
11
+ generateTypeScriptFile,
12
+ generateTypeScriptFiles,
13
+ getPropertyType,
14
+ getTypeScriptPath,
15
+ propertyToTSProperty,
16
+ schemaToEnum,
17
+ schemaToInterface,
18
+ toEnumMemberName,
19
+ toEnumName,
20
+ toInterfaceName,
21
+ toPropertyName
22
+ } from "./chunk-2BXDNKIN.js";
23
+ export {
24
+ enumToUnionType,
25
+ extractInlineEnums,
26
+ formatEnum,
27
+ formatInterface,
28
+ formatProperty,
29
+ formatTypeAlias,
30
+ generateEnums,
31
+ generateInterfaces,
32
+ generateTypeScript,
33
+ generateTypeScriptFile,
34
+ generateTypeScriptFiles,
35
+ getPropertyType,
36
+ getTypeScriptPath,
37
+ propertyToTSProperty,
38
+ schemaToEnum,
39
+ schemaToInterface,
40
+ toEnumMemberName,
41
+ toEnumName,
42
+ toInterfaceName,
43
+ toPropertyName
44
+ };
45
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}