@compilr-dev/factory 0.1.7 → 0.1.8

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.
Files changed (46) hide show
  1. package/dist/factory/registry.js +2 -0
  2. package/dist/index.d.ts +1 -0
  3. package/dist/index.js +2 -0
  4. package/dist/toolkits/next-prisma/api-routes.d.ts +10 -0
  5. package/dist/toolkits/next-prisma/api-routes.js +155 -0
  6. package/dist/toolkits/next-prisma/config.d.ts +9 -0
  7. package/dist/toolkits/next-prisma/config.js +139 -0
  8. package/dist/toolkits/next-prisma/dashboard.d.ts +9 -0
  9. package/dist/toolkits/next-prisma/dashboard.js +87 -0
  10. package/dist/toolkits/next-prisma/entity-components.d.ts +10 -0
  11. package/dist/toolkits/next-prisma/entity-components.js +217 -0
  12. package/dist/toolkits/next-prisma/entity-pages.d.ts +12 -0
  13. package/dist/toolkits/next-prisma/entity-pages.js +348 -0
  14. package/dist/toolkits/next-prisma/helpers.d.ts +13 -0
  15. package/dist/toolkits/next-prisma/helpers.js +37 -0
  16. package/dist/toolkits/next-prisma/index.d.ts +9 -0
  17. package/dist/toolkits/next-prisma/index.js +57 -0
  18. package/dist/toolkits/next-prisma/layout.d.ts +9 -0
  19. package/dist/toolkits/next-prisma/layout.js +157 -0
  20. package/dist/toolkits/next-prisma/prisma.d.ts +8 -0
  21. package/dist/toolkits/next-prisma/prisma.js +76 -0
  22. package/dist/toolkits/next-prisma/seed.d.ts +9 -0
  23. package/dist/toolkits/next-prisma/seed.js +100 -0
  24. package/dist/toolkits/next-prisma/static.d.ts +8 -0
  25. package/dist/toolkits/next-prisma/static.js +61 -0
  26. package/dist/toolkits/next-prisma/types-gen.d.ts +10 -0
  27. package/dist/toolkits/next-prisma/types-gen.js +62 -0
  28. package/dist/toolkits/react-node/config.d.ts +1 -4
  29. package/dist/toolkits/react-node/config.js +3 -84
  30. package/dist/toolkits/react-node/helpers.d.ts +2 -23
  31. package/dist/toolkits/react-node/helpers.js +2 -67
  32. package/dist/toolkits/react-node/seed.d.ts +4 -3
  33. package/dist/toolkits/react-node/seed.js +4 -111
  34. package/dist/toolkits/react-node/shared.d.ts +2 -3
  35. package/dist/toolkits/react-node/shared.js +2 -115
  36. package/dist/toolkits/shared/color-utils.d.ts +10 -0
  37. package/dist/toolkits/shared/color-utils.js +85 -0
  38. package/dist/toolkits/shared/components.d.ts +12 -0
  39. package/dist/toolkits/shared/components.js +121 -0
  40. package/dist/toolkits/shared/helpers.d.ts +28 -0
  41. package/dist/toolkits/shared/helpers.js +72 -0
  42. package/dist/toolkits/shared/index.d.ts +9 -0
  43. package/dist/toolkits/shared/index.js +9 -0
  44. package/dist/toolkits/shared/seed-data.d.ts +18 -0
  45. package/dist/toolkits/shared/seed-data.js +119 -0
  46. package/package.json +1 -1
@@ -2,120 +2,13 @@
2
2
  * React+Node Toolkit — Seed Data Generator
3
3
  *
4
4
  * Generates realistic mock data based on field semantics.
5
- * Deterministic: same input same output (uses index-based logic, not Math.random).
5
+ * Uses shared generateFieldValue for deterministic values,
6
+ * wraps them in JavaScript array format for in-memory data stores.
6
7
  */
7
8
  import { toCamelCase } from '../../model/naming.js';
8
9
  import { belongsToRels, fkFieldName } from './helpers.js';
9
- const PERSON_NAMES = [
10
- 'Alice Johnson',
11
- 'Bob Smith',
12
- 'Carol Davis',
13
- 'David Lee',
14
- 'Eva Martinez',
15
- 'Frank Wilson',
16
- 'Grace Chen',
17
- 'Henry Brown',
18
- 'Iris Kim',
19
- 'Jack Taylor',
20
- ];
21
- const COMPANY_NAMES = [
22
- 'Acme Corp',
23
- 'TechVista Inc',
24
- 'BlueSky Solutions',
25
- 'Greenfield LLC',
26
- 'Summit Dynamics',
27
- 'Cascade Systems',
28
- 'Meridian Labs',
29
- 'Atlas Ventures',
30
- ];
31
- const PRODUCT_NAMES = [
32
- 'Premium Widget',
33
- 'Standard Package',
34
- 'Enterprise Suite',
35
- 'Starter Kit',
36
- 'Pro Bundle',
37
- 'Deluxe Edition',
38
- 'Basic Plan',
39
- 'Advanced Toolkit',
40
- ];
41
- const DESCRIPTIONS = [
42
- 'A comprehensive solution for modern needs.',
43
- 'Designed for efficiency and reliability.',
44
- 'Built with quality and care.',
45
- 'Perfect for teams of any size.',
46
- 'Streamlined for maximum productivity.',
47
- 'Industry-leading performance.',
48
- 'Trusted by thousands of users.',
49
- 'Next-generation technology.',
50
- ];
51
- const EMAILS = [
52
- 'alice@example.com',
53
- 'bob@example.com',
54
- 'carol@example.com',
55
- 'david@example.com',
56
- 'eva@example.com',
57
- 'frank@example.com',
58
- 'grace@example.com',
59
- 'henry@example.com',
60
- ];
61
- const SEED_COUNT = 8;
62
- function generateFieldValue(field, index, entityName) {
63
- const lowerName = field.name.toLowerCase();
64
- const lowerEntity = entityName.toLowerCase();
65
- switch (field.type) {
66
- case 'string':
67
- if (lowerName.includes('email'))
68
- return `'${EMAILS[index % EMAILS.length]}'`;
69
- if (lowerName.includes('name') || lowerName === 'title') {
70
- if (lowerEntity.includes('customer') ||
71
- lowerEntity.includes('user') ||
72
- lowerEntity.includes('person') ||
73
- lowerEntity.includes('employee')) {
74
- return `'${PERSON_NAMES[index % PERSON_NAMES.length]}'`;
75
- }
76
- if (lowerEntity.includes('company') || lowerEntity.includes('organization')) {
77
- return `'${COMPANY_NAMES[index % COMPANY_NAMES.length]}'`;
78
- }
79
- return `'${PRODUCT_NAMES[index % PRODUCT_NAMES.length]}'`;
80
- }
81
- if (lowerName.includes('description') ||
82
- lowerName.includes('note') ||
83
- lowerName.includes('comment')) {
84
- return `'${DESCRIPTIONS[index % DESCRIPTIONS.length]}'`;
85
- }
86
- if (lowerName.includes('phone'))
87
- return `'555-010${String(index)}'`;
88
- if (lowerName.includes('address'))
89
- return `'${String(100 + index * 10)} Main St'`;
90
- return `'${field.label} ${String(index + 1)}'`;
91
- case 'number':
92
- if (lowerName.includes('price') || lowerName.includes('cost') || lowerName.includes('amount'))
93
- return String(10 + index * 15 + 0.99);
94
- if (lowerName.includes('quantity') || lowerName.includes('count'))
95
- return String(1 + (index % 10));
96
- if (lowerName.includes('age'))
97
- return String(22 + index * 5);
98
- if (lowerName.includes('size') || lowerName.includes('capacity'))
99
- return String(2 + (index % 8));
100
- return String(index + 1);
101
- case 'boolean':
102
- return index % 2 === 0 ? 'true' : 'false';
103
- case 'date': {
104
- const base = new Date('2025-06-15');
105
- base.setDate(base.getDate() + (index * 3 - 10));
106
- return `'${base.toISOString().split('T')[0]}'`;
107
- }
108
- case 'enum': {
109
- const values = field.enumValues ?? [];
110
- if (values.length === 0)
111
- return "''";
112
- return `'${values[index % values.length]}'`;
113
- }
114
- default:
115
- return `'${field.label} ${String(index + 1)}'`;
116
- }
117
- }
118
- /** Generate seed data items for a single entity. */
10
+ import { generateFieldValue, SEED_COUNT } from '../shared/seed-data.js';
11
+ /** Generate seed data items for a single entity (JS array format). */
119
12
  export function generateSeedData(model, entity) {
120
13
  const varName = toCamelCase(entity.pluralName);
121
14
  const rels = belongsToRels(entity);
@@ -1,7 +1,6 @@
1
1
  /**
2
2
  * React+Node Toolkit — Shared Components Generator
3
3
  *
4
- * Generates: ViewToggle.tsx, SearchBar.tsx, FilterBar.tsx
4
+ * Re-exports from the shared components module.
5
5
  */
6
- import type { FactoryFile } from '../types.js';
7
- export declare function generateSharedComponents(): FactoryFile[];
6
+ export { generateSharedComponents } from '../shared/components.js';
@@ -1,119 +1,6 @@
1
1
  /**
2
2
  * React+Node Toolkit — Shared Components Generator
3
3
  *
4
- * Generates: ViewToggle.tsx, SearchBar.tsx, FilterBar.tsx
4
+ * Re-exports from the shared components module.
5
5
  */
6
- export function generateSharedComponents() {
7
- return [generateViewToggle(), generateSearchBar(), generateFilterBar()];
8
- }
9
- function generateViewToggle() {
10
- return {
11
- path: 'src/components/shared/ViewToggle.tsx',
12
- content: `interface ViewToggleProps {
13
- view: 'card' | 'list';
14
- onChange: (view: 'card' | 'list') => void;
15
- }
16
-
17
- export default function ViewToggle({ view, onChange }: ViewToggleProps) {
18
- return (
19
- <div className="flex rounded-lg border border-gray-300 dark:border-gray-600">
20
- <button
21
- onClick={() => onChange('card')}
22
- className={\`px-3 py-1 text-sm \${view === 'card' ? 'bg-primary text-white' : 'text-gray-600 dark:text-gray-300'}\`}
23
- >
24
- Grid
25
- </button>
26
- <button
27
- onClick={() => onChange('list')}
28
- className={\`px-3 py-1 text-sm \${view === 'list' ? 'bg-primary text-white' : 'text-gray-600 dark:text-gray-300'}\`}
29
- >
30
- List
31
- </button>
32
- </div>
33
- );
34
- }
35
- `,
36
- };
37
- }
38
- function generateSearchBar() {
39
- return {
40
- path: 'src/components/shared/SearchBar.tsx',
41
- content: `import { useState, useEffect } from 'react';
42
-
43
- interface SearchBarProps {
44
- onSearch: (query: string) => void;
45
- placeholder?: string;
46
- }
47
-
48
- export default function SearchBar({ onSearch, placeholder = 'Search...' }: SearchBarProps) {
49
- const [value, setValue] = useState('');
50
-
51
- useEffect(() => {
52
- const timer = setTimeout(() => onSearch(value), 300);
53
- return () => clearTimeout(timer);
54
- }, [value, onSearch]);
55
-
56
- return (
57
- <div className="relative">
58
- <input
59
- type="text"
60
- value={value}
61
- onChange={(e) => setValue(e.target.value)}
62
- placeholder={placeholder}
63
- className="w-full rounded-lg border border-gray-300 px-4 py-2 text-sm focus:border-primary focus:outline-none dark:border-gray-600 dark:bg-gray-800 dark:text-white"
64
- />
65
- {value && (
66
- <button
67
- onClick={() => setValue('')}
68
- className="absolute right-3 top-1/2 -translate-y-1/2 text-gray-400 hover:text-gray-600"
69
- >
70
- ×
71
- </button>
72
- )}
73
- </div>
74
- );
75
- }
76
- `,
77
- };
78
- }
79
- function generateFilterBar() {
80
- return {
81
- path: 'src/components/shared/FilterBar.tsx',
82
- content: `interface FilterOption {
83
- label: string;
84
- field: string;
85
- values: string[];
86
- }
87
-
88
- interface FilterBarProps {
89
- filters: FilterOption[];
90
- active: Record<string, string>;
91
- onChange: (field: string, value: string) => void;
92
- }
93
-
94
- export default function FilterBar({ filters, active, onChange }: FilterBarProps) {
95
- if (filters.length === 0) return null;
96
-
97
- return (
98
- <div className="flex flex-wrap gap-2">
99
- {filters.map((filter) => (
100
- <select
101
- key={filter.field}
102
- value={active[filter.field] ?? ''}
103
- onChange={(e) => onChange(filter.field, e.target.value)}
104
- className="rounded-lg border border-gray-300 px-3 py-1 text-sm dark:border-gray-600 dark:bg-gray-800 dark:text-white"
105
- >
106
- <option value="">{filter.label}: All</option>
107
- {filter.values.map((v) => (
108
- <option key={v} value={v}>
109
- {v}
110
- </option>
111
- ))}
112
- </select>
113
- ))}
114
- </div>
115
- );
116
- }
117
- `,
118
- };
119
- }
6
+ export { generateSharedComponents } from '../shared/components.js';
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Shared Color Utilities
3
+ *
4
+ * Hex-to-HSL conversion and Tailwind color shade generation.
5
+ * Used by any toolkit that needs to generate a color palette from a primary color.
6
+ */
7
+ export declare const SHADE_LIGHTNESS: Record<string, number>;
8
+ export declare function hexToHsl(hex: string): [number, number, number];
9
+ export declare function hslToHex(h: number, s: number, l: number): string;
10
+ export declare function generateColorShades(hex: string): string;
@@ -0,0 +1,85 @@
1
+ /**
2
+ * Shared Color Utilities
3
+ *
4
+ * Hex-to-HSL conversion and Tailwind color shade generation.
5
+ * Used by any toolkit that needs to generate a color palette from a primary color.
6
+ */
7
+ export const SHADE_LIGHTNESS = {
8
+ '50': 97,
9
+ '100': 94,
10
+ '200': 86,
11
+ '300': 77,
12
+ '400': 66,
13
+ '500': 55,
14
+ '600': 44,
15
+ '700': 36,
16
+ '800': 27,
17
+ '900': 20,
18
+ '950': 14,
19
+ };
20
+ export function hexToHsl(hex) {
21
+ const raw = hex.replace('#', '');
22
+ const r = parseInt(raw.substring(0, 2), 16) / 255;
23
+ const g = parseInt(raw.substring(2, 4), 16) / 255;
24
+ const b = parseInt(raw.substring(4, 6), 16) / 255;
25
+ const max = Math.max(r, g, b);
26
+ const min = Math.min(r, g, b);
27
+ const l = (max + min) / 2;
28
+ if (max === min)
29
+ return [0, 0, Math.round(l * 100)];
30
+ const d = max - min;
31
+ const s = l > 0.5 ? d / (2 - max - min) : d / (max + min);
32
+ let h = 0;
33
+ if (max === r)
34
+ h = ((g - b) / d + (g < b ? 6 : 0)) / 6;
35
+ else if (max === g)
36
+ h = ((b - r) / d + 2) / 6;
37
+ else
38
+ h = ((r - g) / d + 4) / 6;
39
+ return [Math.round(h * 360), Math.round(s * 100), Math.round(l * 100)];
40
+ }
41
+ export function hslToHex(h, s, l) {
42
+ const sN = s / 100;
43
+ const lN = l / 100;
44
+ const c = (1 - Math.abs(2 * lN - 1)) * sN;
45
+ const x = c * (1 - Math.abs(((h / 60) % 2) - 1));
46
+ const m = lN - c / 2;
47
+ let r = 0, g = 0, b = 0;
48
+ if (h < 60)
49
+ [r, g, b] = [c, x, 0];
50
+ else if (h < 120)
51
+ [r, g, b] = [x, c, 0];
52
+ else if (h < 180)
53
+ [r, g, b] = [0, c, x];
54
+ else if (h < 240)
55
+ [r, g, b] = [0, x, c];
56
+ else if (h < 300)
57
+ [r, g, b] = [x, 0, c];
58
+ else
59
+ [r, g, b] = [c, 0, x];
60
+ const toHex = (v) => Math.round((v + m) * 255)
61
+ .toString(16)
62
+ .padStart(2, '0');
63
+ return `#${toHex(r)}${toHex(g)}${toHex(b)}`;
64
+ }
65
+ export function generateColorShades(hex) {
66
+ const [h, s] = hexToHsl(hex);
67
+ const entries = [];
68
+ for (const [shade, lightness] of Object.entries(SHADE_LIGHTNESS)) {
69
+ entries.push(` ${shade}: '${hslToHex(h, s, lightness)}',`);
70
+ }
71
+ // Find the shade closest to the original for DEFAULT
72
+ const [, , originalL] = hexToHsl(hex);
73
+ let closestShade = '500';
74
+ let closestDiff = Infinity;
75
+ for (const [shade, lightness] of Object.entries(SHADE_LIGHTNESS)) {
76
+ const diff = Math.abs(lightness - originalL);
77
+ if (diff < closestDiff) {
78
+ closestDiff = diff;
79
+ closestShade = shade;
80
+ }
81
+ }
82
+ const defaultHex = hslToHex(h, s, SHADE_LIGHTNESS[closestShade]);
83
+ entries.push(` DEFAULT: '${defaultHex}',`);
84
+ return `{\n${entries.join('\n')}\n }`;
85
+ }
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Shared React Components Generator
3
+ *
4
+ * Generates: ViewToggle.tsx, SearchBar.tsx, FilterBar.tsx
5
+ * These are framework-agnostic React components reusable across toolkits.
6
+ */
7
+ import type { FactoryFile } from '../types.js';
8
+ export declare function generateViewToggle(): FactoryFile;
9
+ export declare function generateSearchBar(): FactoryFile;
10
+ export declare function generateFilterBar(): FactoryFile;
11
+ /** Generate all shared components (ViewToggle, SearchBar, FilterBar). */
12
+ export declare function generateSharedComponents(): FactoryFile[];
@@ -0,0 +1,121 @@
1
+ /**
2
+ * Shared React Components Generator
3
+ *
4
+ * Generates: ViewToggle.tsx, SearchBar.tsx, FilterBar.tsx
5
+ * These are framework-agnostic React components reusable across toolkits.
6
+ */
7
+ export function generateViewToggle() {
8
+ return {
9
+ path: 'src/components/shared/ViewToggle.tsx',
10
+ content: `interface ViewToggleProps {
11
+ view: 'card' | 'list';
12
+ onChange: (view: 'card' | 'list') => void;
13
+ }
14
+
15
+ export default function ViewToggle({ view, onChange }: ViewToggleProps) {
16
+ return (
17
+ <div className="flex rounded-lg border border-gray-300 dark:border-gray-600">
18
+ <button
19
+ onClick={() => onChange('card')}
20
+ className={\`px-3 py-1 text-sm \${view === 'card' ? 'bg-primary text-white' : 'text-gray-600 dark:text-gray-300'}\`}
21
+ >
22
+ Grid
23
+ </button>
24
+ <button
25
+ onClick={() => onChange('list')}
26
+ className={\`px-3 py-1 text-sm \${view === 'list' ? 'bg-primary text-white' : 'text-gray-600 dark:text-gray-300'}\`}
27
+ >
28
+ List
29
+ </button>
30
+ </div>
31
+ );
32
+ }
33
+ `,
34
+ };
35
+ }
36
+ export function generateSearchBar() {
37
+ return {
38
+ path: 'src/components/shared/SearchBar.tsx',
39
+ content: `import { useState, useEffect } from 'react';
40
+
41
+ interface SearchBarProps {
42
+ onSearch: (query: string) => void;
43
+ placeholder?: string;
44
+ }
45
+
46
+ export default function SearchBar({ onSearch, placeholder = 'Search...' }: SearchBarProps) {
47
+ const [value, setValue] = useState('');
48
+
49
+ useEffect(() => {
50
+ const timer = setTimeout(() => onSearch(value), 300);
51
+ return () => clearTimeout(timer);
52
+ }, [value, onSearch]);
53
+
54
+ return (
55
+ <div className="relative">
56
+ <input
57
+ type="text"
58
+ value={value}
59
+ onChange={(e) => setValue(e.target.value)}
60
+ placeholder={placeholder}
61
+ className="w-full rounded-lg border border-gray-300 px-4 py-2 text-sm focus:border-primary focus:outline-none dark:border-gray-600 dark:bg-gray-800 dark:text-white"
62
+ />
63
+ {value && (
64
+ <button
65
+ onClick={() => setValue('')}
66
+ className="absolute right-3 top-1/2 -translate-y-1/2 text-gray-400 hover:text-gray-600"
67
+ >
68
+ ×
69
+ </button>
70
+ )}
71
+ </div>
72
+ );
73
+ }
74
+ `,
75
+ };
76
+ }
77
+ export function generateFilterBar() {
78
+ return {
79
+ path: 'src/components/shared/FilterBar.tsx',
80
+ content: `interface FilterOption {
81
+ label: string;
82
+ field: string;
83
+ values: string[];
84
+ }
85
+
86
+ interface FilterBarProps {
87
+ filters: FilterOption[];
88
+ active: Record<string, string>;
89
+ onChange: (field: string, value: string) => void;
90
+ }
91
+
92
+ export default function FilterBar({ filters, active, onChange }: FilterBarProps) {
93
+ if (filters.length === 0) return null;
94
+
95
+ return (
96
+ <div className="flex flex-wrap gap-2">
97
+ {filters.map((filter) => (
98
+ <select
99
+ key={filter.field}
100
+ value={active[filter.field] ?? ''}
101
+ onChange={(e) => onChange(filter.field, e.target.value)}
102
+ className="rounded-lg border border-gray-300 px-3 py-1 text-sm dark:border-gray-600 dark:bg-gray-800 dark:text-white"
103
+ >
104
+ <option value="">{filter.label}: All</option>
105
+ {filter.values.map((v) => (
106
+ <option key={v} value={v}>
107
+ {v}
108
+ </option>
109
+ ))}
110
+ </select>
111
+ ))}
112
+ </div>
113
+ );
114
+ }
115
+ `,
116
+ };
117
+ }
118
+ /** Generate all shared components (ViewToggle, SearchBar, FilterBar). */
119
+ export function generateSharedComponents() {
120
+ return [generateViewToggle(), generateSearchBar(), generateFilterBar()];
121
+ }
@@ -0,0 +1,28 @@
1
+ /**
2
+ * Shared Toolkit Helpers
3
+ *
4
+ * Utility functions used across toolkit generators.
5
+ * These operate on model types (Entity, Field, Relationship) — no framework coupling.
6
+ */
7
+ import type { Entity, Field, Relationship } from '../../model/types.js';
8
+ /** Indent every line of a multi-line string. */
9
+ export declare function indent(text: string, spaces: number): string;
10
+ /** Map a model FieldType to a TypeScript type string. */
11
+ export declare function tsType(field: Field): string;
12
+ /** Get the FK field name for a belongsTo relationship. */
13
+ export declare function fkFieldName(rel: Relationship): string;
14
+ /** Get belongsTo relationships for an entity. */
15
+ export declare function belongsToRels(entity: Entity): readonly Relationship[];
16
+ /** Get hasMany relationships for an entity. */
17
+ export declare function hasManyRels(entity: Entity): readonly Relationship[];
18
+ /** Generate a route path from entity plural name. */
19
+ export declare function routePath(entity: Entity): string;
20
+ /** Generate an API path from entity plural name. */
21
+ export declare function apiPath(entity: Entity): string;
22
+ /** Map a model FieldType to an HTML input type. */
23
+ export declare function inputType(field: Field): string;
24
+ /** Generate import statement lines. */
25
+ export declare function generateImports(imports: Array<{
26
+ from: string;
27
+ names: string[];
28
+ }>): string;
@@ -0,0 +1,72 @@
1
+ /**
2
+ * Shared Toolkit Helpers
3
+ *
4
+ * Utility functions used across toolkit generators.
5
+ * These operate on model types (Entity, Field, Relationship) — no framework coupling.
6
+ */
7
+ import { toCamelCase, toKebabCase } from '../../model/naming.js';
8
+ /** Indent every line of a multi-line string. */
9
+ export function indent(text, spaces) {
10
+ const pad = ' '.repeat(spaces);
11
+ return text
12
+ .split('\n')
13
+ .map((line) => (line.trim() === '' ? '' : pad + line))
14
+ .join('\n');
15
+ }
16
+ /** Map a model FieldType to a TypeScript type string. */
17
+ export function tsType(field) {
18
+ switch (field.type) {
19
+ case 'string':
20
+ case 'enum':
21
+ return 'string';
22
+ case 'number':
23
+ return 'number';
24
+ case 'boolean':
25
+ return 'boolean';
26
+ case 'date':
27
+ return 'string'; // ISO date string
28
+ default:
29
+ return 'string';
30
+ }
31
+ }
32
+ /** Get the FK field name for a belongsTo relationship. */
33
+ export function fkFieldName(rel) {
34
+ return rel.fieldName ?? toCamelCase(rel.target) + 'Id';
35
+ }
36
+ /** Get belongsTo relationships for an entity. */
37
+ export function belongsToRels(entity) {
38
+ return entity.relationships.filter((r) => r.type === 'belongsTo');
39
+ }
40
+ /** Get hasMany relationships for an entity. */
41
+ export function hasManyRels(entity) {
42
+ return entity.relationships.filter((r) => r.type === 'hasMany');
43
+ }
44
+ /** Generate a route path from entity plural name. */
45
+ export function routePath(entity) {
46
+ return '/' + toKebabCase(entity.pluralName).toLowerCase();
47
+ }
48
+ /** Generate an API path from entity plural name. */
49
+ export function apiPath(entity) {
50
+ return '/api/' + toKebabCase(entity.pluralName).toLowerCase();
51
+ }
52
+ /** Map a model FieldType to an HTML input type. */
53
+ export function inputType(field) {
54
+ switch (field.type) {
55
+ case 'string':
56
+ return 'text';
57
+ case 'number':
58
+ return 'number';
59
+ case 'boolean':
60
+ return 'checkbox';
61
+ case 'date':
62
+ return 'date';
63
+ case 'enum':
64
+ return 'select';
65
+ default:
66
+ return 'text';
67
+ }
68
+ }
69
+ /** Generate import statement lines. */
70
+ export function generateImports(imports) {
71
+ return imports.map((i) => `import { ${i.names.join(', ')} } from '${i.from}';`).join('\n');
72
+ }
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Shared Toolkit Utilities
3
+ *
4
+ * Re-exports from all shared modules for convenience.
5
+ */
6
+ export { indent, tsType, fkFieldName, belongsToRels, hasManyRels, routePath, apiPath, inputType, generateImports, } from './helpers.js';
7
+ export { hexToHsl, hslToHex, generateColorShades, SHADE_LIGHTNESS } from './color-utils.js';
8
+ export { generateViewToggle, generateSearchBar, generateFilterBar, generateSharedComponents, } from './components.js';
9
+ export { generateFieldValue, SEED_COUNT, PERSON_NAMES, COMPANY_NAMES, PRODUCT_NAMES, DESCRIPTIONS, EMAILS, } from './seed-data.js';
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Shared Toolkit Utilities
3
+ *
4
+ * Re-exports from all shared modules for convenience.
5
+ */
6
+ export { indent, tsType, fkFieldName, belongsToRels, hasManyRels, routePath, apiPath, inputType, generateImports, } from './helpers.js';
7
+ export { hexToHsl, hslToHex, generateColorShades, SHADE_LIGHTNESS } from './color-utils.js';
8
+ export { generateViewToggle, generateSearchBar, generateFilterBar, generateSharedComponents, } from './components.js';
9
+ export { generateFieldValue, SEED_COUNT, PERSON_NAMES, COMPANY_NAMES, PRODUCT_NAMES, DESCRIPTIONS, EMAILS, } from './seed-data.js';
@@ -0,0 +1,18 @@
1
+ /**
2
+ * Shared Seed Data Utilities
3
+ *
4
+ * Deterministic mock data generation based on field semantics.
5
+ * Same input → same output (uses index-based logic, not Math.random).
6
+ *
7
+ * Toolkit-specific wrappers (e.g., JS array format, Prisma createMany) import these
8
+ * and format the output for their target framework.
9
+ */
10
+ import type { Field } from '../../model/types.js';
11
+ export declare const PERSON_NAMES: string[];
12
+ export declare const COMPANY_NAMES: string[];
13
+ export declare const PRODUCT_NAMES: string[];
14
+ export declare const DESCRIPTIONS: string[];
15
+ export declare const EMAILS: string[];
16
+ export declare const SEED_COUNT = 8;
17
+ /** Generate a deterministic string value for a single field at a given index. */
18
+ export declare function generateFieldValue(field: Field, index: number, entityName: string): string;