@betterstart/cli 0.1.0
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-46UVIUJF.js +223 -0
- package/dist/chunk-46UVIUJF.js.map +1 -0
- package/dist/chunk-GEH43BA4.js +179 -0
- package/dist/chunk-GEH43BA4.js.map +1 -0
- package/dist/chunk-PWRI4LKM.js +260 -0
- package/dist/chunk-PWRI4LKM.js.map +1 -0
- package/dist/chunk-WY6BC55D.js +357 -0
- package/dist/chunk-WY6BC55D.js.map +1 -0
- package/dist/cli.d.ts +10 -0
- package/dist/cli.js +472 -0
- package/dist/cli.js.map +1 -0
- package/dist/config/index.d.ts +178 -0
- package/dist/config/index.js +58 -0
- package/dist/config/index.js.map +1 -0
- package/dist/core/index.d.ts +415 -0
- package/dist/core/index.js +906 -0
- package/dist/core/index.js.map +1 -0
- package/dist/import-resolver-BJOCLFnH.d.ts +38 -0
- package/dist/index.d.ts +264 -0
- package/dist/index.js +11375 -0
- package/dist/index.js.map +1 -0
- package/dist/logger-awLb347n.d.ts +81 -0
- package/dist/plugins/index.d.ts +213 -0
- package/dist/plugins/index.js +365 -0
- package/dist/plugins/index.js.map +1 -0
- package/dist/types-BouTOvVr.d.ts +331 -0
- package/dist/types-ByX_gl6y.d.ts +232 -0
- package/package.json +82 -0
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
export { I as ImportResolver } from '../import-resolver-BJOCLFnH.js';
|
|
2
|
+
import { U as UserConfig, B as BetterstartConfig, R as ResolvedPaths, a as ResolvedConfig, I as ImportPaths, P as Preset } from '../types-BouTOvVr.js';
|
|
3
|
+
export { k as BetterstartPlugin, C as CustomGenerator, c as DatabaseConfig, D as DatabaseProvider, l as DeepPartial, F as FieldTypeHandler, p as GenerateOptions, i as GeneratedFile, G as GeneratorConfig, f as GeneratorName, n as GeneratorOptions, o as InitOptions, O as OutputPaths, j as PluginCommand, h as PluginContext, g as PluginHooks, b as ProjectPaths, m as ProjectType, q as RemoveOptions, e as UIConfig, d as UIFramework } from '../types-BouTOvVr.js';
|
|
4
|
+
import '../logger-awLb347n.js';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Configuration loader for @betterstart/cli
|
|
8
|
+
* Handles loading, merging, and resolving configuration
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Supported configuration file names (in priority order)
|
|
13
|
+
*/
|
|
14
|
+
declare const CONFIG_FILE_NAMES: string[];
|
|
15
|
+
/**
|
|
16
|
+
* Find the configuration file in a directory
|
|
17
|
+
* @param cwd - Directory to search in
|
|
18
|
+
* @returns Path to the config file or undefined if not found
|
|
19
|
+
*/
|
|
20
|
+
declare function findConfigFile(cwd: string): string | undefined;
|
|
21
|
+
/**
|
|
22
|
+
* Load configuration from a file
|
|
23
|
+
* @param configPath - Path to the configuration file
|
|
24
|
+
* @returns The loaded configuration
|
|
25
|
+
*/
|
|
26
|
+
declare function loadConfigFile(configPath: string): Promise<UserConfig>;
|
|
27
|
+
/**
|
|
28
|
+
* Load configuration from a directory
|
|
29
|
+
* Automatically finds and loads the config file, or uses defaults
|
|
30
|
+
*
|
|
31
|
+
* @param cwd - Directory to load config from (defaults to process.cwd())
|
|
32
|
+
* @param presetName - Optional preset name to use as base
|
|
33
|
+
* @returns The loaded and merged configuration
|
|
34
|
+
*/
|
|
35
|
+
declare function loadConfig(cwd?: string, presetName?: string): Promise<BetterstartConfig>;
|
|
36
|
+
/**
|
|
37
|
+
* Find the project root directory
|
|
38
|
+
* Looks for common root indicators (package.json, pnpm-workspace.yaml, turbo.json)
|
|
39
|
+
*
|
|
40
|
+
* @param startDir - Directory to start searching from
|
|
41
|
+
* @returns The project root directory
|
|
42
|
+
*/
|
|
43
|
+
declare function findProjectRoot(startDir: string): string;
|
|
44
|
+
/**
|
|
45
|
+
* Resolve configuration paths to absolute paths
|
|
46
|
+
*
|
|
47
|
+
* @param config - The configuration to resolve
|
|
48
|
+
* @param projectRoot - The project root directory
|
|
49
|
+
* @returns Configuration with resolved absolute paths
|
|
50
|
+
*/
|
|
51
|
+
declare function resolvePaths(config: BetterstartConfig, projectRoot: string): ResolvedPaths;
|
|
52
|
+
/**
|
|
53
|
+
* Fully resolve configuration including paths
|
|
54
|
+
*
|
|
55
|
+
* @param config - The configuration to resolve
|
|
56
|
+
* @param projectRoot - The project root directory (optional, auto-detected if not provided)
|
|
57
|
+
* @returns Fully resolved configuration
|
|
58
|
+
*/
|
|
59
|
+
declare function resolveConfig(config: BetterstartConfig, projectRoot?: string): ResolvedConfig;
|
|
60
|
+
/**
|
|
61
|
+
* Helper function for defining configuration in betterstart.config.ts
|
|
62
|
+
* Provides type checking and autocomplete
|
|
63
|
+
*
|
|
64
|
+
* @example
|
|
65
|
+
* ```ts
|
|
66
|
+
* // betterstart.config.ts
|
|
67
|
+
* import { defineConfig } from '@betterstart/cli'
|
|
68
|
+
*
|
|
69
|
+
* export default defineConfig({
|
|
70
|
+
* paths: {
|
|
71
|
+
* app: 'apps/web',
|
|
72
|
+
* database: 'packages/database'
|
|
73
|
+
* }
|
|
74
|
+
* })
|
|
75
|
+
* ```
|
|
76
|
+
*/
|
|
77
|
+
declare function defineConfig(config: UserConfig): UserConfig;
|
|
78
|
+
/**
|
|
79
|
+
* Validate a configuration
|
|
80
|
+
* @param config - The configuration to validate
|
|
81
|
+
* @returns Array of validation errors (empty if valid)
|
|
82
|
+
*/
|
|
83
|
+
declare function validateConfig(config: BetterstartConfig): string[];
|
|
84
|
+
/**
|
|
85
|
+
* Check if resolved paths exist and are accessible
|
|
86
|
+
* @param paths - The resolved paths to check
|
|
87
|
+
* @returns Object with path existence status
|
|
88
|
+
*/
|
|
89
|
+
declare function checkPaths(paths: ResolvedPaths): Record<keyof ResolvedPaths, boolean>;
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* Project presets for common project structures
|
|
93
|
+
* Each preset provides default configuration for a specific project type
|
|
94
|
+
*/
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* Default output paths
|
|
98
|
+
*/
|
|
99
|
+
declare const DEFAULT_OUTPUT_PATHS: {
|
|
100
|
+
actions: string;
|
|
101
|
+
hooks: string;
|
|
102
|
+
components: string;
|
|
103
|
+
pages: string;
|
|
104
|
+
emails: string;
|
|
105
|
+
};
|
|
106
|
+
/**
|
|
107
|
+
* Default database configuration
|
|
108
|
+
*/
|
|
109
|
+
declare const DEFAULT_DATABASE_CONFIG: {
|
|
110
|
+
provider: "drizzle";
|
|
111
|
+
schemaFile: string;
|
|
112
|
+
migrationsDir: string;
|
|
113
|
+
autoMigrate: boolean;
|
|
114
|
+
};
|
|
115
|
+
/**
|
|
116
|
+
* Default UI configuration
|
|
117
|
+
*/
|
|
118
|
+
declare const DEFAULT_UI_CONFIG: {
|
|
119
|
+
framework: "shadcn";
|
|
120
|
+
components: {
|
|
121
|
+
path: string;
|
|
122
|
+
adminPath: string;
|
|
123
|
+
};
|
|
124
|
+
};
|
|
125
|
+
/**
|
|
126
|
+
* Monorepo import paths (for @betterstart/* packages)
|
|
127
|
+
*/
|
|
128
|
+
declare const MONOREPO_IMPORT_PATHS: ImportPaths;
|
|
129
|
+
/**
|
|
130
|
+
* Standalone import paths (for @/ alias in single Next.js apps)
|
|
131
|
+
*/
|
|
132
|
+
declare const STANDALONE_IMPORT_PATHS: ImportPaths;
|
|
133
|
+
/**
|
|
134
|
+
* Default generator configuration
|
|
135
|
+
*/
|
|
136
|
+
declare const DEFAULT_GENERATOR_CONFIG: {
|
|
137
|
+
core: string[];
|
|
138
|
+
optional: string[];
|
|
139
|
+
};
|
|
140
|
+
/**
|
|
141
|
+
* Next.js monorepo preset (Turborepo/pnpm style)
|
|
142
|
+
* Similar to the current betterstart structure
|
|
143
|
+
*/
|
|
144
|
+
declare const nextjsMonorepoPreset: Preset;
|
|
145
|
+
/**
|
|
146
|
+
* Standalone Next.js preset
|
|
147
|
+
* For single Next.js apps without monorepo structure
|
|
148
|
+
*/
|
|
149
|
+
declare const nextjsStandalonePreset: Preset;
|
|
150
|
+
/**
|
|
151
|
+
* Custom/minimal preset
|
|
152
|
+
* Provides minimal defaults, user must configure paths
|
|
153
|
+
*/
|
|
154
|
+
declare const customPreset: Preset;
|
|
155
|
+
/**
|
|
156
|
+
* All available presets
|
|
157
|
+
*/
|
|
158
|
+
declare const presets: Record<string, Preset>;
|
|
159
|
+
/**
|
|
160
|
+
* Get a preset by name
|
|
161
|
+
*/
|
|
162
|
+
declare function getPreset(name: string): Preset | undefined;
|
|
163
|
+
/**
|
|
164
|
+
* Get all preset names
|
|
165
|
+
*/
|
|
166
|
+
declare function getPresetNames(): string[];
|
|
167
|
+
/**
|
|
168
|
+
* Auto-detect the best preset for a project
|
|
169
|
+
* @param cwd - The project root directory
|
|
170
|
+
* @returns The detected preset or 'custom' if none match
|
|
171
|
+
*/
|
|
172
|
+
declare function detectPreset(cwd: string): Preset;
|
|
173
|
+
/**
|
|
174
|
+
* Get the default configuration based on project detection
|
|
175
|
+
*/
|
|
176
|
+
declare function getDefaultConfig(cwd: string): UserConfig;
|
|
177
|
+
|
|
178
|
+
export { BetterstartConfig, CONFIG_FILE_NAMES, DEFAULT_DATABASE_CONFIG, DEFAULT_GENERATOR_CONFIG, DEFAULT_OUTPUT_PATHS, DEFAULT_UI_CONFIG, ImportPaths, MONOREPO_IMPORT_PATHS, Preset, ResolvedConfig, ResolvedPaths, STANDALONE_IMPORT_PATHS, UserConfig, checkPaths, customPreset, defineConfig, detectPreset, findConfigFile, findProjectRoot, getDefaultConfig, getPreset, getPresetNames, loadConfig, loadConfigFile, nextjsMonorepoPreset, nextjsStandalonePreset, presets, resolveConfig, resolvePaths, validateConfig };
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import {
|
|
2
|
+
CONFIG_FILE_NAMES,
|
|
3
|
+
checkPaths,
|
|
4
|
+
defineConfig,
|
|
5
|
+
findConfigFile,
|
|
6
|
+
findProjectRoot,
|
|
7
|
+
loadConfig,
|
|
8
|
+
loadConfigFile,
|
|
9
|
+
resolveConfig,
|
|
10
|
+
resolvePaths,
|
|
11
|
+
validateConfig
|
|
12
|
+
} from "../chunk-46UVIUJF.js";
|
|
13
|
+
import {
|
|
14
|
+
DEFAULT_DATABASE_CONFIG,
|
|
15
|
+
DEFAULT_GENERATOR_CONFIG,
|
|
16
|
+
DEFAULT_OUTPUT_PATHS,
|
|
17
|
+
DEFAULT_UI_CONFIG,
|
|
18
|
+
ImportResolver,
|
|
19
|
+
MONOREPO_IMPORT_PATHS,
|
|
20
|
+
STANDALONE_IMPORT_PATHS,
|
|
21
|
+
customPreset,
|
|
22
|
+
detectPreset,
|
|
23
|
+
getDefaultConfig,
|
|
24
|
+
getPreset,
|
|
25
|
+
getPresetNames,
|
|
26
|
+
nextjsMonorepoPreset,
|
|
27
|
+
nextjsStandalonePreset,
|
|
28
|
+
presets
|
|
29
|
+
} from "../chunk-PWRI4LKM.js";
|
|
30
|
+
import "../chunk-WY6BC55D.js";
|
|
31
|
+
export {
|
|
32
|
+
CONFIG_FILE_NAMES,
|
|
33
|
+
DEFAULT_DATABASE_CONFIG,
|
|
34
|
+
DEFAULT_GENERATOR_CONFIG,
|
|
35
|
+
DEFAULT_OUTPUT_PATHS,
|
|
36
|
+
DEFAULT_UI_CONFIG,
|
|
37
|
+
ImportResolver,
|
|
38
|
+
MONOREPO_IMPORT_PATHS,
|
|
39
|
+
STANDALONE_IMPORT_PATHS,
|
|
40
|
+
checkPaths,
|
|
41
|
+
customPreset,
|
|
42
|
+
defineConfig,
|
|
43
|
+
detectPreset,
|
|
44
|
+
findConfigFile,
|
|
45
|
+
findProjectRoot,
|
|
46
|
+
getDefaultConfig,
|
|
47
|
+
getPreset,
|
|
48
|
+
getPresetNames,
|
|
49
|
+
loadConfig,
|
|
50
|
+
loadConfigFile,
|
|
51
|
+
nextjsMonorepoPreset,
|
|
52
|
+
nextjsStandalonePreset,
|
|
53
|
+
presets,
|
|
54
|
+
resolveConfig,
|
|
55
|
+
resolvePaths,
|
|
56
|
+
validateConfig
|
|
57
|
+
};
|
|
58
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -0,0 +1,415 @@
|
|
|
1
|
+
import { a as SchemaField, b as FieldType, F as FormSchema, i as FormField } from '../types-ByX_gl6y.js';
|
|
2
|
+
export { b as LogEntry, L as LogLevel, a as Logger, e as createBufferedLogger, c as createConsoleLogger, d as createSilentLogger, g as getLogger, l as logger, r as resetLogger, s as setLogger } from '../logger-awLb347n.js';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Centralized constants for the codegen package
|
|
6
|
+
* These replace magic strings scattered throughout generators
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* All supported field types for schema definitions
|
|
10
|
+
*/
|
|
11
|
+
declare const FIELD_TYPES: {
|
|
12
|
+
readonly STRING: "string";
|
|
13
|
+
readonly NUMBER: "number";
|
|
14
|
+
readonly BOOLEAN: "boolean";
|
|
15
|
+
readonly TEXT: "text";
|
|
16
|
+
readonly DECIMAL: "decimal";
|
|
17
|
+
readonly VARCHAR: "varchar";
|
|
18
|
+
readonly SERIAL: "serial";
|
|
19
|
+
readonly DATE: "date";
|
|
20
|
+
readonly TIMESTAMP: "timestamp";
|
|
21
|
+
readonly TIME: "time";
|
|
22
|
+
readonly MARKDOWN: "markdown";
|
|
23
|
+
readonly IMAGE: "image";
|
|
24
|
+
readonly VIDEO: "video";
|
|
25
|
+
readonly MEDIA: "media";
|
|
26
|
+
readonly ICON: "icon";
|
|
27
|
+
readonly GROUP: "group";
|
|
28
|
+
readonly TABS: "tabs";
|
|
29
|
+
readonly LIST: "list";
|
|
30
|
+
readonly SEPARATOR: "separator";
|
|
31
|
+
readonly SELECT: "select";
|
|
32
|
+
readonly RELATIONSHIP: "relationship";
|
|
33
|
+
readonly CURRICULUM: "curriculum";
|
|
34
|
+
};
|
|
35
|
+
/**
|
|
36
|
+
* Field types that contain nested fields
|
|
37
|
+
*/
|
|
38
|
+
declare const NESTED_FIELD_TYPES: readonly ["group", "tabs", "list"];
|
|
39
|
+
/**
|
|
40
|
+
* Field types that represent rich text content
|
|
41
|
+
*/
|
|
42
|
+
declare const RICH_TEXT_FIELD_TYPES: readonly ["markdown", "text"];
|
|
43
|
+
/**
|
|
44
|
+
* Field types that are stored as long text in the database
|
|
45
|
+
*/
|
|
46
|
+
declare const LONG_TEXT_FIELD_TYPES: readonly ["text", "markdown", "list", "media", "video", "curriculum"];
|
|
47
|
+
/**
|
|
48
|
+
* All supported column types for admin tables
|
|
49
|
+
*/
|
|
50
|
+
declare const COLUMN_TYPES: {
|
|
51
|
+
readonly TEXT: "text";
|
|
52
|
+
readonly BADGE: "badge";
|
|
53
|
+
readonly DATE: "date";
|
|
54
|
+
readonly CUSTOM: "custom";
|
|
55
|
+
readonly AVATAR: "avatar";
|
|
56
|
+
readonly LINK: "link";
|
|
57
|
+
readonly IMAGE: "image";
|
|
58
|
+
readonly EMAIL: "email";
|
|
59
|
+
readonly NUMBER: "number";
|
|
60
|
+
readonly BOOLEAN: "boolean";
|
|
61
|
+
};
|
|
62
|
+
/**
|
|
63
|
+
* All supported form field types
|
|
64
|
+
*/
|
|
65
|
+
declare const FORM_FIELD_TYPES: {
|
|
66
|
+
readonly TEXT: "text";
|
|
67
|
+
readonly TEXTAREA: "textarea";
|
|
68
|
+
readonly EMAIL: "email";
|
|
69
|
+
readonly PHONE: "phone";
|
|
70
|
+
readonly NUMBER: "number";
|
|
71
|
+
readonly URL: "url";
|
|
72
|
+
readonly DATE: "date";
|
|
73
|
+
readonly SELECT: "select";
|
|
74
|
+
readonly RADIO: "radio";
|
|
75
|
+
readonly CHECKBOX: "checkbox";
|
|
76
|
+
readonly MULTISELECT: "multiselect";
|
|
77
|
+
readonly FILE: "file";
|
|
78
|
+
readonly UPLOAD: "upload";
|
|
79
|
+
readonly GROUP: "group";
|
|
80
|
+
readonly TIMEZONE: "timezone";
|
|
81
|
+
readonly LIST: "list";
|
|
82
|
+
};
|
|
83
|
+
/**
|
|
84
|
+
* Fields that are automatically added to schemas
|
|
85
|
+
*/
|
|
86
|
+
declare const AUTO_FIELDS: {
|
|
87
|
+
readonly ID: "id";
|
|
88
|
+
readonly CREATED_AT: "createdAt";
|
|
89
|
+
readonly UPDATED_AT: "updatedAt";
|
|
90
|
+
readonly PUBLISHED: "published";
|
|
91
|
+
readonly SLUG: "slug";
|
|
92
|
+
};
|
|
93
|
+
/**
|
|
94
|
+
* Fields automatically added for form submissions
|
|
95
|
+
*/
|
|
96
|
+
declare const FORM_SUBMISSION_FIELDS: {
|
|
97
|
+
readonly SUBMITTED_AT: "submittedAt";
|
|
98
|
+
readonly IP_ADDRESS: "ipAddress";
|
|
99
|
+
readonly USER_AGENT: "userAgent";
|
|
100
|
+
};
|
|
101
|
+
/**
|
|
102
|
+
* Default Drizzle column configurations
|
|
103
|
+
*/
|
|
104
|
+
declare const DRIZZLE_DEFAULTS: {
|
|
105
|
+
readonly VARCHAR_LENGTH: 255;
|
|
106
|
+
readonly DECIMAL_PRECISION: 10;
|
|
107
|
+
readonly DECIMAL_SCALE: 2;
|
|
108
|
+
};
|
|
109
|
+
/**
|
|
110
|
+
* Core generators that are always included
|
|
111
|
+
*/
|
|
112
|
+
declare const CORE_GENERATORS: readonly ["database", "actions", "hooks", "columns", "table", "page", "page-content", "form", "create-page", "edit-page", "navigation"];
|
|
113
|
+
/**
|
|
114
|
+
* Optional generators that can be enabled via config
|
|
115
|
+
*/
|
|
116
|
+
declare const OPTIONAL_GENERATORS: readonly [];
|
|
117
|
+
declare const FILE_EXTENSIONS: {
|
|
118
|
+
readonly TYPESCRIPT: ".ts";
|
|
119
|
+
readonly TSX: ".tsx";
|
|
120
|
+
readonly JSON: ".json";
|
|
121
|
+
readonly SQL: ".sql";
|
|
122
|
+
};
|
|
123
|
+
type FieldTypeValue = (typeof FIELD_TYPES)[keyof typeof FIELD_TYPES];
|
|
124
|
+
type ColumnTypeValue = (typeof COLUMN_TYPES)[keyof typeof COLUMN_TYPES];
|
|
125
|
+
type FormFieldTypeValue = (typeof FORM_FIELD_TYPES)[keyof typeof FORM_FIELD_TYPES];
|
|
126
|
+
/**
|
|
127
|
+
* Check if a value is a valid field type
|
|
128
|
+
*/
|
|
129
|
+
declare function isFieldType(value: string): value is FieldTypeValue;
|
|
130
|
+
/**
|
|
131
|
+
* Check if a field type contains nested fields
|
|
132
|
+
*/
|
|
133
|
+
declare function isNestedFieldType(type: string): boolean;
|
|
134
|
+
/**
|
|
135
|
+
* Check if a field type is stored as long text
|
|
136
|
+
*/
|
|
137
|
+
declare function isLongTextFieldType(type: string): boolean;
|
|
138
|
+
|
|
139
|
+
/**
|
|
140
|
+
* Custom error classes for the codegen package
|
|
141
|
+
* Provides structured errors with codes and context for better debugging
|
|
142
|
+
*/
|
|
143
|
+
/**
|
|
144
|
+
* Base error class for all codegen errors
|
|
145
|
+
*/
|
|
146
|
+
declare class CodegenError extends Error {
|
|
147
|
+
readonly code: string;
|
|
148
|
+
readonly context?: unknown;
|
|
149
|
+
constructor(message: string, code: string, context?: unknown);
|
|
150
|
+
/**
|
|
151
|
+
* Format error for display
|
|
152
|
+
*/
|
|
153
|
+
toString(): string;
|
|
154
|
+
}
|
|
155
|
+
/**
|
|
156
|
+
* Error thrown when schema validation fails
|
|
157
|
+
*/
|
|
158
|
+
declare class SchemaValidationError extends CodegenError {
|
|
159
|
+
readonly validationErrors: string[];
|
|
160
|
+
constructor(message: string, validationErrors: string[], context?: unknown);
|
|
161
|
+
toString(): string;
|
|
162
|
+
}
|
|
163
|
+
/**
|
|
164
|
+
* Error thrown when configuration is invalid or missing
|
|
165
|
+
*/
|
|
166
|
+
declare class ConfigurationError extends CodegenError {
|
|
167
|
+
constructor(message: string, context?: unknown);
|
|
168
|
+
}
|
|
169
|
+
/**
|
|
170
|
+
* Error thrown during code generation
|
|
171
|
+
*/
|
|
172
|
+
declare class GeneratorError extends CodegenError {
|
|
173
|
+
readonly generatorName: string;
|
|
174
|
+
constructor(message: string, generatorName: string, context?: unknown);
|
|
175
|
+
toString(): string;
|
|
176
|
+
}
|
|
177
|
+
/**
|
|
178
|
+
* Error thrown when a plugin fails
|
|
179
|
+
*/
|
|
180
|
+
declare class PluginError extends CodegenError {
|
|
181
|
+
readonly pluginName: string;
|
|
182
|
+
constructor(message: string, pluginName: string, context?: unknown);
|
|
183
|
+
toString(): string;
|
|
184
|
+
}
|
|
185
|
+
/**
|
|
186
|
+
* Error thrown when a file operation fails
|
|
187
|
+
*/
|
|
188
|
+
declare class FileOperationError extends CodegenError {
|
|
189
|
+
readonly filePath: string;
|
|
190
|
+
readonly operation: 'read' | 'write' | 'delete' | 'create';
|
|
191
|
+
constructor(message: string, filePath: string, operation: 'read' | 'write' | 'delete' | 'create', context?: unknown);
|
|
192
|
+
toString(): string;
|
|
193
|
+
}
|
|
194
|
+
/**
|
|
195
|
+
* Error thrown when a required field is missing
|
|
196
|
+
*/
|
|
197
|
+
declare class MissingFieldError extends CodegenError {
|
|
198
|
+
readonly fieldName: string;
|
|
199
|
+
readonly schemaName: string;
|
|
200
|
+
constructor(fieldName: string, schemaName: string, context?: unknown);
|
|
201
|
+
}
|
|
202
|
+
/**
|
|
203
|
+
* Error thrown when a field type is not supported
|
|
204
|
+
*/
|
|
205
|
+
declare class UnsupportedFieldTypeError extends CodegenError {
|
|
206
|
+
readonly fieldType: string;
|
|
207
|
+
readonly fieldName: string;
|
|
208
|
+
constructor(fieldType: string, fieldName: string, context?: unknown);
|
|
209
|
+
}
|
|
210
|
+
declare const ERROR_CODES: {
|
|
211
|
+
readonly SCHEMA_VALIDATION_ERROR: "SCHEMA_VALIDATION_ERROR";
|
|
212
|
+
readonly CONFIGURATION_ERROR: "CONFIGURATION_ERROR";
|
|
213
|
+
readonly GENERATOR_ERROR: "GENERATOR_ERROR";
|
|
214
|
+
readonly PLUGIN_ERROR: "PLUGIN_ERROR";
|
|
215
|
+
readonly FILE_OPERATION_ERROR: "FILE_OPERATION_ERROR";
|
|
216
|
+
readonly MISSING_FIELD_ERROR: "MISSING_FIELD_ERROR";
|
|
217
|
+
readonly UNSUPPORTED_FIELD_TYPE_ERROR: "UNSUPPORTED_FIELD_TYPE_ERROR";
|
|
218
|
+
};
|
|
219
|
+
/**
|
|
220
|
+
* Check if an error is a CodegenError
|
|
221
|
+
*/
|
|
222
|
+
declare function isCodegenError(error: unknown): error is CodegenError;
|
|
223
|
+
/**
|
|
224
|
+
* Wrap an unknown error in a CodegenError
|
|
225
|
+
*/
|
|
226
|
+
declare function wrapError(error: unknown, code: string, message?: string): CodegenError;
|
|
227
|
+
|
|
228
|
+
/**
|
|
229
|
+
* Field helper utilities for the codegen package
|
|
230
|
+
* Consolidates duplicated field-checking functions from actions.ts, form.ts, etc.
|
|
231
|
+
*/
|
|
232
|
+
|
|
233
|
+
/**
|
|
234
|
+
* Options for walking the field tree
|
|
235
|
+
*/
|
|
236
|
+
interface WalkFieldsOptions {
|
|
237
|
+
/** Include fields inside list items */
|
|
238
|
+
includeLists?: boolean;
|
|
239
|
+
/** Include fields inside groups */
|
|
240
|
+
includeGroups?: boolean;
|
|
241
|
+
/** Include fields inside tabs */
|
|
242
|
+
includeTabs?: boolean;
|
|
243
|
+
}
|
|
244
|
+
/**
|
|
245
|
+
* Walk through all fields in a schema, including nested ones
|
|
246
|
+
* @param fields - The fields to walk
|
|
247
|
+
* @param callback - Called for each field with depth and parent info
|
|
248
|
+
* @param options - Control which nested structures to traverse
|
|
249
|
+
*/
|
|
250
|
+
declare function walkFields(fields: SchemaField[], callback: (field: SchemaField, depth: number, parent?: SchemaField) => void, options?: WalkFieldsOptions): void;
|
|
251
|
+
/**
|
|
252
|
+
* Check if any field in the tree matches a specific type
|
|
253
|
+
* Replaces the many checkForFieldType() functions
|
|
254
|
+
*/
|
|
255
|
+
declare function hasFieldType(fields: SchemaField[], type: FieldType | string, options?: WalkFieldsOptions): boolean;
|
|
256
|
+
/**
|
|
257
|
+
* Check if any field in the tree matches any of the given types
|
|
258
|
+
*/
|
|
259
|
+
declare function hasAnyFieldType(fields: SchemaField[], types: (FieldType | string)[], options?: WalkFieldsOptions): boolean;
|
|
260
|
+
/**
|
|
261
|
+
* Check if any field uses icons (either icon type or hasIcon property)
|
|
262
|
+
* Replaces checkForIconUsage() from form.ts
|
|
263
|
+
*/
|
|
264
|
+
declare function hasIconUsage(fields: SchemaField[], options?: WalkFieldsOptions): boolean;
|
|
265
|
+
/**
|
|
266
|
+
* Check if any field is a relationship field
|
|
267
|
+
* Replaces checkForRelationshipField() from form.ts
|
|
268
|
+
*/
|
|
269
|
+
declare function hasRelationshipField(fields: SchemaField[], options?: WalkFieldsOptions): boolean;
|
|
270
|
+
/**
|
|
271
|
+
* Check if any field is a markdown field
|
|
272
|
+
* Replaces checkForMarkdownField() from form.ts
|
|
273
|
+
*/
|
|
274
|
+
declare function hasMarkdownField(fields: SchemaField[], options?: WalkFieldsOptions): boolean;
|
|
275
|
+
/**
|
|
276
|
+
* Check if any field is a textarea/text field
|
|
277
|
+
* Replaces checkForTextareaField() from form.ts
|
|
278
|
+
*/
|
|
279
|
+
declare function hasTextareaField(fields: SchemaField[], options?: WalkFieldsOptions): boolean;
|
|
280
|
+
/**
|
|
281
|
+
* Collect all fields of a specific type
|
|
282
|
+
*/
|
|
283
|
+
declare function collectFieldsByType(fields: SchemaField[], type: FieldType | string, options?: WalkFieldsOptions): SchemaField[];
|
|
284
|
+
/**
|
|
285
|
+
* Get all many-to-many relationship fields
|
|
286
|
+
* Replaces getManyToManyFields() from actions.ts and database.ts
|
|
287
|
+
*/
|
|
288
|
+
declare function getManyToManyFields(fields: SchemaField[]): SchemaField[];
|
|
289
|
+
/**
|
|
290
|
+
* Get all relationship fields (excluding many-to-many)
|
|
291
|
+
* Replaces _getNestedRelationshipFields() from actions.ts
|
|
292
|
+
*/
|
|
293
|
+
declare function getNestedRelationshipFields(fields: SchemaField[], options?: WalkFieldsOptions): SchemaField[];
|
|
294
|
+
/**
|
|
295
|
+
* Collect relationship fields from top-level and groups only (not lists)
|
|
296
|
+
* Used for form imports where list relationships use different handling
|
|
297
|
+
*/
|
|
298
|
+
declare function collectRelationshipFieldsTopLevel(fields: SchemaField[]): SchemaField[];
|
|
299
|
+
/**
|
|
300
|
+
* Collect ALL relationship fields including those in lists
|
|
301
|
+
* Used for data hooks
|
|
302
|
+
*/
|
|
303
|
+
declare function collectAllRelationshipFields(fields: SchemaField[]): SchemaField[];
|
|
304
|
+
/**
|
|
305
|
+
* Get list fields that have nested fields (not just items)
|
|
306
|
+
*/
|
|
307
|
+
declare function getListFieldsWithNestedFields(fields: SchemaField[]): SchemaField[];
|
|
308
|
+
/**
|
|
309
|
+
* Get nested list fields (list fields inside list fields)
|
|
310
|
+
*/
|
|
311
|
+
declare function getNestedListFields(fields: SchemaField[]): {
|
|
312
|
+
parent: SchemaField;
|
|
313
|
+
nested: SchemaField;
|
|
314
|
+
}[];
|
|
315
|
+
/**
|
|
316
|
+
* Ensure fields have an ID field - automatically injects one if not present
|
|
317
|
+
*/
|
|
318
|
+
declare function ensureIdField(fields: SchemaField[]): SchemaField[];
|
|
319
|
+
/**
|
|
320
|
+
* Flatten group and tabs fields into individual fields for database operations
|
|
321
|
+
* Automatically ensures an ID field exists
|
|
322
|
+
*/
|
|
323
|
+
declare function flattenFields(fields: SchemaField[]): SchemaField[];
|
|
324
|
+
/**
|
|
325
|
+
* Get all fields from a form schema (including from steps)
|
|
326
|
+
* Replaces getAllFields() from email-template.ts and form-generator.ts
|
|
327
|
+
*/
|
|
328
|
+
declare function getAllFormFields(schema: FormSchema): FormField[];
|
|
329
|
+
/**
|
|
330
|
+
* Check if a form schema is multi-step
|
|
331
|
+
*/
|
|
332
|
+
declare function isMultiStepForm(schema: FormSchema): boolean;
|
|
333
|
+
/**
|
|
334
|
+
* Result of analyzing all field types in a schema
|
|
335
|
+
*/
|
|
336
|
+
interface FieldAnalysis {
|
|
337
|
+
hasBoolean: boolean;
|
|
338
|
+
hasImage: boolean;
|
|
339
|
+
hasVideo: boolean;
|
|
340
|
+
hasMedia: boolean;
|
|
341
|
+
hasDate: boolean;
|
|
342
|
+
hasList: boolean;
|
|
343
|
+
hasNestedList: boolean;
|
|
344
|
+
hasSelect: boolean;
|
|
345
|
+
hasMarkdown: boolean;
|
|
346
|
+
hasTextarea: boolean;
|
|
347
|
+
hasSeparator: boolean;
|
|
348
|
+
hasIcon: boolean;
|
|
349
|
+
hasRelationship: boolean;
|
|
350
|
+
hasManyToMany: boolean;
|
|
351
|
+
fieldTypes: Set<string>;
|
|
352
|
+
}
|
|
353
|
+
/**
|
|
354
|
+
* Analyze all field types in a schema
|
|
355
|
+
* Returns a comprehensive analysis that can be used to determine imports, etc.
|
|
356
|
+
*/
|
|
357
|
+
declare function analyzeFields(fields: SchemaField[]): FieldAnalysis;
|
|
358
|
+
|
|
359
|
+
/**
|
|
360
|
+
* Type mapping utilities for the codegen package
|
|
361
|
+
* Consolidates type mapping functions from form.ts, database.ts, actions.ts, form-generator.ts
|
|
362
|
+
*/
|
|
363
|
+
|
|
364
|
+
/**
|
|
365
|
+
* Map a schema field type to Drizzle ORM column type
|
|
366
|
+
* @param field - The schema field
|
|
367
|
+
* @param requiredImports - Set to track which Drizzle imports are needed
|
|
368
|
+
* @returns The Drizzle column type expression
|
|
369
|
+
*/
|
|
370
|
+
declare function toDrizzleType(field: SchemaField, requiredImports: Set<string>): string;
|
|
371
|
+
/**
|
|
372
|
+
* Map a schema field type to Zod validation schema
|
|
373
|
+
* @param field - The schema field
|
|
374
|
+
* @returns The Zod schema expression as a string
|
|
375
|
+
*/
|
|
376
|
+
declare function toZodType(field: SchemaField): string;
|
|
377
|
+
/**
|
|
378
|
+
* Map a schema field type to TypeScript type
|
|
379
|
+
* @param field - The schema field
|
|
380
|
+
* @param mode - 'input' for form input types, 'output' for database output types
|
|
381
|
+
* @returns The TypeScript type as a string
|
|
382
|
+
*/
|
|
383
|
+
declare function toTypeScriptType(field: SchemaField, mode?: 'input' | 'output'): string;
|
|
384
|
+
/**
|
|
385
|
+
* Map a schema field type to HTML form input type
|
|
386
|
+
* @param field - The schema field
|
|
387
|
+
* @returns The form input type (checkbox, textarea, number, date, etc.)
|
|
388
|
+
*/
|
|
389
|
+
declare function toFormFieldType(field: SchemaField): string;
|
|
390
|
+
/**
|
|
391
|
+
* Map a form field type to Drizzle ORM column type
|
|
392
|
+
* @param field - The form field
|
|
393
|
+
* @param requiredImports - Set to track which Drizzle imports are needed
|
|
394
|
+
* @returns The Drizzle column type expression
|
|
395
|
+
*/
|
|
396
|
+
declare function formFieldToDrizzleType(field: FormField, requiredImports: Set<string>): string;
|
|
397
|
+
interface FormFieldZodOptions {
|
|
398
|
+
/** Treat field as optional even if required (for conditional fields) */
|
|
399
|
+
treatAsOptional?: boolean;
|
|
400
|
+
}
|
|
401
|
+
/**
|
|
402
|
+
* Map a form field type to Zod validation schema
|
|
403
|
+
* @param field - The form field
|
|
404
|
+
* @param options - Options for generating the zod type
|
|
405
|
+
* @returns The Zod schema expression as a string
|
|
406
|
+
*/
|
|
407
|
+
declare function formFieldToZodType(field: FormField, options?: FormFieldZodOptions): string;
|
|
408
|
+
/**
|
|
409
|
+
* Map a schema field type to SQL column type
|
|
410
|
+
* @param field - The schema field
|
|
411
|
+
* @returns The SQL column type
|
|
412
|
+
*/
|
|
413
|
+
declare function toSQLType(field: SchemaField): string;
|
|
414
|
+
|
|
415
|
+
export { AUTO_FIELDS, COLUMN_TYPES, CORE_GENERATORS, CodegenError, type ColumnTypeValue, ConfigurationError, DRIZZLE_DEFAULTS, ERROR_CODES, FIELD_TYPES, FILE_EXTENSIONS, FORM_FIELD_TYPES, FORM_SUBMISSION_FIELDS, type FieldAnalysis, type FieldTypeValue, FileOperationError, type FormFieldTypeValue, type FormFieldZodOptions, GeneratorError, LONG_TEXT_FIELD_TYPES, MissingFieldError, NESTED_FIELD_TYPES, OPTIONAL_GENERATORS, PluginError, RICH_TEXT_FIELD_TYPES, SchemaValidationError, UnsupportedFieldTypeError, type WalkFieldsOptions, analyzeFields, collectAllRelationshipFields, collectFieldsByType, collectRelationshipFieldsTopLevel, ensureIdField, flattenFields, formFieldToDrizzleType, formFieldToZodType, getAllFormFields, getListFieldsWithNestedFields, getManyToManyFields, getNestedListFields, getNestedRelationshipFields, hasAnyFieldType, hasFieldType, hasIconUsage, hasMarkdownField, hasRelationshipField, hasTextareaField, isCodegenError, isFieldType, isLongTextFieldType, isMultiStepForm, isNestedFieldType, toDrizzleType, toFormFieldType, toSQLType, toTypeScriptType, toZodType, walkFields, wrapError };
|