@tailor-platform/erp-kit 0.1.0 → 0.1.2
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/CHANGELOG.md +13 -0
- package/LICENSE +21 -0
- package/README.md +77 -50
- package/dist/cli.js +693 -553
- package/package.json +4 -2
- package/schemas/module/command.yml +1 -0
- package/schemas/module/model.yml +9 -0
- package/schemas/module/query.yml +53 -0
- package/skills/1-module-docs/SKILL.md +4 -0
- package/{rules/module-development → skills/1-module-docs/references}/structure.md +2 -7
- package/skills/2-module-feature-breakdown/SKILL.md +6 -0
- package/{rules/module-development → skills/2-module-feature-breakdown/references}/commands.md +0 -6
- package/{rules/module-development → skills/2-module-feature-breakdown/references}/models.md +0 -5
- package/skills/2-module-feature-breakdown/references/structure.md +22 -0
- package/skills/3-module-doc-review/SKILL.md +6 -0
- package/skills/3-module-doc-review/references/commands.md +54 -0
- package/skills/3-module-doc-review/references/models.md +29 -0
- package/{rules/module-development → skills/3-module-doc-review/references}/testing.md +0 -6
- package/skills/4-module-tdd-implementation/SKILL.md +24 -6
- package/skills/4-module-tdd-implementation/references/commands.md +45 -0
- package/{rules/sdk-best-practices → skills/4-module-tdd-implementation/references}/db-relations.md +0 -5
- package/{rules/module-development → skills/4-module-tdd-implementation/references}/errors.md +0 -5
- package/{rules/module-development → skills/4-module-tdd-implementation/references}/exports.md +0 -5
- package/skills/4-module-tdd-implementation/references/models.md +30 -0
- package/skills/4-module-tdd-implementation/references/structure.md +22 -0
- package/skills/4-module-tdd-implementation/references/testing.md +37 -0
- package/skills/5-module-implementation-review/SKILL.md +8 -0
- package/skills/5-module-implementation-review/references/commands.md +45 -0
- package/skills/5-module-implementation-review/references/errors.md +7 -0
- package/skills/5-module-implementation-review/references/exports.md +8 -0
- package/skills/5-module-implementation-review/references/models.md +30 -0
- package/skills/5-module-implementation-review/references/testing.md +29 -0
- package/skills/app-compose-1-requirement-analysis/SKILL.md +4 -0
- package/{rules/app-compose → skills/app-compose-1-requirement-analysis/references}/structure.md +0 -5
- package/skills/app-compose-2-requirements-breakdown/SKILL.md +7 -0
- package/{rules/app-compose/frontend → skills/app-compose-2-requirements-breakdown/references}/screen-detailview.md +0 -6
- package/{rules/app-compose/frontend → skills/app-compose-2-requirements-breakdown/references}/screen-form.md +0 -6
- package/{rules/app-compose/frontend → skills/app-compose-2-requirements-breakdown/references}/screen-listview.md +0 -6
- package/skills/app-compose-2-requirements-breakdown/references/structure.md +27 -0
- package/skills/app-compose-3-doc-review/SKILL.md +4 -0
- package/skills/app-compose-3-doc-review/references/structure.md +27 -0
- package/skills/app-compose-4-design-mock/SKILL.md +8 -0
- package/{rules/app-compose/frontend → skills/app-compose-4-design-mock/references}/component.md +0 -5
- package/skills/app-compose-4-design-mock/references/screen-detailview.md +106 -0
- package/skills/app-compose-4-design-mock/references/screen-form.md +139 -0
- package/skills/app-compose-4-design-mock/references/screen-listview.md +153 -0
- package/skills/app-compose-4-design-mock/references/structure.md +27 -0
- package/skills/app-compose-5-design-mock-review/SKILL.md +7 -0
- package/skills/app-compose-5-design-mock-review/references/component.md +50 -0
- package/skills/app-compose-5-design-mock-review/references/screen-detailview.md +106 -0
- package/skills/app-compose-5-design-mock-review/references/screen-form.md +139 -0
- package/skills/app-compose-5-design-mock-review/references/screen-listview.md +153 -0
- package/skills/app-compose-6-implementation-spec/SKILL.md +5 -0
- package/{rules/app-compose/backend → skills/app-compose-6-implementation-spec/references}/auth.md +0 -6
- package/skills/app-compose-6-implementation-spec/references/structure.md +27 -0
- package/src/cli.ts +8 -90
- package/src/commands/app/index.ts +74 -0
- package/src/commands/check.test.ts +2 -1
- package/src/commands/check.ts +1 -0
- package/src/commands/init.test.ts +30 -19
- package/src/commands/init.ts +76 -43
- package/src/commands/module/index.ts +85 -0
- package/src/commands/module/list.test.ts +62 -0
- package/src/commands/module/list.ts +64 -0
- package/src/commands/scaffold.test.ts +5 -0
- package/src/commands/scaffold.ts +2 -1
- package/src/commands/sync-check.test.ts +28 -0
- package/src/commands/sync-check.ts +6 -0
- package/src/integration.test.ts +6 -8
- package/src/module.ts +4 -3
- package/src/modules/primitives/docs/models/Currency.md +4 -0
- package/src/modules/primitives/docs/models/ExchangeRate.md +4 -1
- package/src/modules/primitives/docs/models/Unit.md +4 -1
- package/src/modules/primitives/docs/models/UoMCategory.md +2 -0
- package/src/modules/primitives/index.ts +2 -2
- package/src/modules/primitives/module.ts +5 -3
- package/src/modules/primitives/permissions.ts +0 -2
- package/src/modules/primitives/{command → query}/convertAmount.test.ts +2 -19
- package/src/modules/primitives/query/convertAmount.ts +122 -0
- package/src/modules/primitives/{command → query}/convertQuantity.test.ts +2 -13
- package/src/modules/primitives/{command → query}/convertQuantity.ts +4 -6
- package/src/modules/shared/defineQuery.test.ts +28 -0
- package/src/modules/shared/defineQuery.ts +16 -0
- package/src/modules/shared/internal.ts +2 -1
- package/src/modules/shared/types.ts +8 -0
- package/src/modules/user-management/docs/models/AuditEvent.md +2 -0
- package/src/modules/user-management/docs/models/Permission.md +2 -0
- package/src/modules/user-management/docs/models/Role.md +2 -0
- package/src/modules/user-management/docs/models/RolePermission.md +2 -0
- package/src/modules/user-management/docs/models/User.md +2 -0
- package/src/modules/user-management/docs/models/UserRole.md +2 -0
- package/src/schemas.ts +1 -0
- package/rules/app-compose/frontend/auth.md +0 -55
- package/rules/app-compose/frontend/page.md +0 -86
- package/rules/module-development/cross-module-type-injection.md +0 -28
- package/rules/module-development/dependency-modules.md +0 -24
- package/rules/module-development/executors.md +0 -67
- package/rules/module-development/sync-vs-async-operations.md +0 -83
- package/rules/sdk-best-practices/sdk-docs.md +0 -14
- package/src/modules/primitives/command/convertAmount.ts +0 -126
- /package/src/modules/primitives/docs/{commands → queries}/ConvertAmount.md +0 -0
- /package/src/modules/primitives/docs/{commands → queries}/ConvertQuantity.md +0 -0
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
# DetailView Screen Implementation
|
|
2
|
+
|
|
3
|
+
Implementation pattern for screens with `Screen Type: DetailView`.
|
|
4
|
+
Assumes `page.md` and `component.md` rules.
|
|
5
|
+
|
|
6
|
+
## File Structure
|
|
7
|
+
|
|
8
|
+
```
|
|
9
|
+
{screen-path}/[id]/
|
|
10
|
+
├── components/
|
|
11
|
+
│ ├── {screen-name}-detail.tsx # Main content (left column)
|
|
12
|
+
│ └── {screen-name}-actions.tsx # Action sidebar (right column)
|
|
13
|
+
├── edit/
|
|
14
|
+
│ ├── components/
|
|
15
|
+
│ │ └── edit-{screen-name}-form.tsx
|
|
16
|
+
│ └── page.tsx
|
|
17
|
+
└── page.tsx
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
## Layout
|
|
21
|
+
|
|
22
|
+
- Two-column layout: main content on the left, actions on the right.
|
|
23
|
+
|
|
24
|
+
```tsx
|
|
25
|
+
const ResourcePage = () => {
|
|
26
|
+
const { id } = useParams();
|
|
27
|
+
const [{ data, error, fetching }, reexecuteQuery] = useQuery({
|
|
28
|
+
query: ResourceQuery,
|
|
29
|
+
variables: { id: id! },
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
if (fetching) return <Loading />;
|
|
33
|
+
if (error || !data?.resource) return <ErrorFallback ... />;
|
|
34
|
+
|
|
35
|
+
return (
|
|
36
|
+
<Layout columns={2} title="Resource Detail">
|
|
37
|
+
<Layout.Column>
|
|
38
|
+
<ResourceDetail resource={data.resource} />
|
|
39
|
+
</Layout.Column>
|
|
40
|
+
<Layout.Column>
|
|
41
|
+
<ResourceActions resource={data.resource} />
|
|
42
|
+
</Layout.Column>
|
|
43
|
+
</Layout>
|
|
44
|
+
);
|
|
45
|
+
};
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
## Left Column: Detail Component
|
|
49
|
+
|
|
50
|
+
Stack `DescriptionCard` and related tables vertically with `space-y-6`.
|
|
51
|
+
|
|
52
|
+
- `DescriptionCard` (`@tailor-platform/app-shell`): renders key-value fields declaratively.
|
|
53
|
+
- Complex content (tables, timelines): wrap in `<div className="rounded-lg border bg-card p-6">`.
|
|
54
|
+
|
|
55
|
+
### DescriptionCard
|
|
56
|
+
|
|
57
|
+
```tsx
|
|
58
|
+
<DescriptionCard
|
|
59
|
+
data={resource}
|
|
60
|
+
title="Overview"
|
|
61
|
+
columns={3}
|
|
62
|
+
fields={[
|
|
63
|
+
{ key: "name", label: "Name", meta: { copyable: true } },
|
|
64
|
+
{
|
|
65
|
+
key: "status",
|
|
66
|
+
label: "Status",
|
|
67
|
+
type: "badge",
|
|
68
|
+
meta: { badgeVariantMap: { ACTIVE: "success", PENDING: "warning" } },
|
|
69
|
+
},
|
|
70
|
+
{ type: "divider" },
|
|
71
|
+
{
|
|
72
|
+
key: "createdAt",
|
|
73
|
+
label: "Created At",
|
|
74
|
+
type: "date",
|
|
75
|
+
meta: { dateFormat: "medium" },
|
|
76
|
+
},
|
|
77
|
+
]}
|
|
78
|
+
/>
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
Field types: `"text"` (default), `"badge"`, `"money"`, `"date"`, `"link"`, `"address"`, `"reference"`, `"divider"`
|
|
82
|
+
|
|
83
|
+
## Right Column: Actions Component
|
|
84
|
+
|
|
85
|
+
Wrap in a `Card` component. Use `Button variant="ghost"` for each action item.
|
|
86
|
+
|
|
87
|
+
```tsx
|
|
88
|
+
<Card>
|
|
89
|
+
<CardHeader>
|
|
90
|
+
<CardTitle>Actions</CardTitle>
|
|
91
|
+
</CardHeader>
|
|
92
|
+
<CardContent className="space-y-2">
|
|
93
|
+
<Button variant="ghost" className="w-full justify-start gap-2" asChild>
|
|
94
|
+
<Link to="edit">✎ Edit</Link>
|
|
95
|
+
</Button>
|
|
96
|
+
<Button variant="ghost" className="w-full justify-start gap-2" onClick={handler}>
|
|
97
|
+
✓ Approve
|
|
98
|
+
</Button>
|
|
99
|
+
</CardContent>
|
|
100
|
+
</Card>
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
- Navigation: `<Button variant="ghost" asChild><Link to="...">`
|
|
104
|
+
- Mutation: `<Button variant="ghost" onClick={handler}>` with custom resolvers (see `backend/resolvers.md`)
|
|
105
|
+
- Conditional: show/hide based on status
|
|
106
|
+
- Multiple cards: stack with `<div className="space-y-6">`
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
# Form Screen Implementation
|
|
2
|
+
|
|
3
|
+
Implementation pattern for screens with `Screen Type: Form`.
|
|
4
|
+
Assumes `page.md` and `component.md` rules.
|
|
5
|
+
|
|
6
|
+
## File Structure
|
|
7
|
+
|
|
8
|
+
```
|
|
9
|
+
{screen-path}/
|
|
10
|
+
├── components/
|
|
11
|
+
│ └── {screen-name}-form.tsx # Form component with validation
|
|
12
|
+
└── page.tsx
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## Page Component (page.tsx)
|
|
16
|
+
|
|
17
|
+
Form pages delegate mutation logic to the form component.
|
|
18
|
+
|
|
19
|
+
```tsx
|
|
20
|
+
const ScreenNamePage = () => (
|
|
21
|
+
<Layout columns={1} title="Screen Title">
|
|
22
|
+
<Layout.Column>
|
|
23
|
+
<ScreenNameForm />
|
|
24
|
+
</Layout.Column>
|
|
25
|
+
</Layout>
|
|
26
|
+
);
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
For edit forms that need existing data, co-locate data fetching in the page component:
|
|
30
|
+
|
|
31
|
+
```tsx
|
|
32
|
+
const EditPage = () => {
|
|
33
|
+
const { id } = useParams();
|
|
34
|
+
const [{ data, error, fetching }] = useQuery({
|
|
35
|
+
query: ResourceQuery,
|
|
36
|
+
variables: { id: id! },
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
if (fetching) return <Loading />;
|
|
40
|
+
if (error || !data?.resource) return <ErrorFallback ... />;
|
|
41
|
+
|
|
42
|
+
return (
|
|
43
|
+
<Layout columns={1} title="Edit Resource">
|
|
44
|
+
<Layout.Column>
|
|
45
|
+
<EditResourceForm resource={data.resource} />
|
|
46
|
+
</Layout.Column>
|
|
47
|
+
</Layout>
|
|
48
|
+
);
|
|
49
|
+
};
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
## Form Component (components/{screen-name}-form.tsx)
|
|
53
|
+
|
|
54
|
+
### Technology Stack
|
|
55
|
+
|
|
56
|
+
- `react-hook-form` — form state management
|
|
57
|
+
- `zod` + `@hookform/resolvers/zod` — validation
|
|
58
|
+
- `useMutation` (urql) — GraphQL mutation
|
|
59
|
+
- `useNavigate` (@tailor-platform/app-shell) — post-submit navigation
|
|
60
|
+
|
|
61
|
+
### Pattern
|
|
62
|
+
|
|
63
|
+
```tsx
|
|
64
|
+
const formSchema = z.object({
|
|
65
|
+
title: z.string().min(1, "Title is required"),
|
|
66
|
+
description: z.string().optional(),
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
type FormValues = z.infer<typeof formSchema>;
|
|
70
|
+
|
|
71
|
+
export const ScreenNameForm = () => {
|
|
72
|
+
const navigate = useNavigate();
|
|
73
|
+
const [, createResource] = useMutation(CreateMutation);
|
|
74
|
+
|
|
75
|
+
const form = useForm<FormValues>({
|
|
76
|
+
resolver: zodResolver(formSchema),
|
|
77
|
+
defaultValues: { title: "", description: "" },
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
const onSubmit = (values: FormValues) => {
|
|
81
|
+
void createResource({ input: values }).then((result) => {
|
|
82
|
+
if (!result.error) {
|
|
83
|
+
void navigate("..");
|
|
84
|
+
}
|
|
85
|
+
});
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
return (
|
|
89
|
+
<Form {...form}>
|
|
90
|
+
<form onSubmit={(e) => void form.handleSubmit(onSubmit)(e)} className="max-w-md space-y-4">
|
|
91
|
+
<FormField
|
|
92
|
+
control={form.control}
|
|
93
|
+
name="title"
|
|
94
|
+
render={({ field }) => (
|
|
95
|
+
<FormItem>
|
|
96
|
+
<FormLabel>Title</FormLabel>
|
|
97
|
+
<FormControl>
|
|
98
|
+
<Input placeholder="Enter title" {...field} />
|
|
99
|
+
</FormControl>
|
|
100
|
+
<FormMessage />
|
|
101
|
+
</FormItem>
|
|
102
|
+
)}
|
|
103
|
+
/>
|
|
104
|
+
<div className="flex gap-2">
|
|
105
|
+
<Button type="submit">Create</Button>
|
|
106
|
+
<Button type="button" variant="outline" onClick={() => void navigate("..")}>
|
|
107
|
+
Cancel
|
|
108
|
+
</Button>
|
|
109
|
+
</div>
|
|
110
|
+
</form>
|
|
111
|
+
</Form>
|
|
112
|
+
);
|
|
113
|
+
};
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
## Field Type Mapping
|
|
117
|
+
|
|
118
|
+
| Field Type | Component | Zod Schema |
|
|
119
|
+
| ---------- | ------------------------------ | ------------------------------- |
|
|
120
|
+
| Text | `<Input />` | `z.string()` |
|
|
121
|
+
| Textarea | `<textarea className="..." />` | `z.string()` |
|
|
122
|
+
| Dropdown | `<Select />` | `z.string()` or `z.enum([...])` |
|
|
123
|
+
| Date | `<Input type="date" />` | `z.string()` (ISO format) |
|
|
124
|
+
| Number | `<Input type="number" />` | `z.coerce.number()` |
|
|
125
|
+
| Email | `<Input type="email" />` | `z.string().email()` |
|
|
126
|
+
| Checkbox | `<Checkbox />` | `z.boolean()` |
|
|
127
|
+
| Radio | `<RadioGroup />` | `z.enum([...])` |
|
|
128
|
+
|
|
129
|
+
## Validation Mapping
|
|
130
|
+
|
|
131
|
+
- **Required: Yes** → `.min(1, "Field is required")` (string) / `.positive()` (number)
|
|
132
|
+
- **Required: No** → `.optional()`
|
|
133
|
+
|
|
134
|
+
## Key Points
|
|
135
|
+
|
|
136
|
+
- Set `defaultValues` for all fields (empty string, false, etc.)
|
|
137
|
+
- Navigate to `".."` after successful mutation
|
|
138
|
+
- Cancel button must use `type="button"` to prevent form submit
|
|
139
|
+
- For edit forms, accept fragment data as props and pre-fill `defaultValues`
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
# ListView Screen Implementation
|
|
2
|
+
|
|
3
|
+
Implementation pattern for screens with `Screen Type: ListView`.
|
|
4
|
+
Assumes `page.md` and `component.md` rules.
|
|
5
|
+
|
|
6
|
+
## File Structure
|
|
7
|
+
|
|
8
|
+
```
|
|
9
|
+
{screen-path}/
|
|
10
|
+
├── components/
|
|
11
|
+
│ └── {screen-name}-table.tsx # Table component with fragments
|
|
12
|
+
└── page.tsx
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## Page Component (page.tsx)
|
|
16
|
+
|
|
17
|
+
Data fetching and `Layout` must be co-located in the same page component.
|
|
18
|
+
Do NOT split into an inner Content component — `Layout` requires `Layout.Column` as direct children.
|
|
19
|
+
|
|
20
|
+
```tsx
|
|
21
|
+
const ResourcesQuery = graphql(
|
|
22
|
+
`
|
|
23
|
+
query Resources {
|
|
24
|
+
resources {
|
|
25
|
+
...ResourceTable
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
`,
|
|
29
|
+
[ResourceTableFragment],
|
|
30
|
+
);
|
|
31
|
+
|
|
32
|
+
const ResourcesPage = () => {
|
|
33
|
+
const [{ data, error, fetching }, reexecuteQuery] = useQuery({
|
|
34
|
+
query: ResourcesQuery,
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
if (fetching) return <Loading />;
|
|
38
|
+
|
|
39
|
+
if (error || !data) {
|
|
40
|
+
return (
|
|
41
|
+
<ErrorFallback
|
|
42
|
+
title="Failed to load resources"
|
|
43
|
+
message="An error occurred while fetching the list."
|
|
44
|
+
onReset={() => reexecuteQuery({ requestPolicy: "network-only" })}
|
|
45
|
+
/>
|
|
46
|
+
);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
return (
|
|
50
|
+
<Layout
|
|
51
|
+
columns={1}
|
|
52
|
+
title="Resources"
|
|
53
|
+
actions={[
|
|
54
|
+
<Button key="create" asChild>
|
|
55
|
+
<Link to="create">Create</Link>
|
|
56
|
+
</Button>,
|
|
57
|
+
]}
|
|
58
|
+
>
|
|
59
|
+
<Layout.Column>
|
|
60
|
+
<ResourceTable data={data.resources} />
|
|
61
|
+
</Layout.Column>
|
|
62
|
+
</Layout>
|
|
63
|
+
);
|
|
64
|
+
};
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
## Table Component (components/{screen-name}-table.tsx)
|
|
68
|
+
|
|
69
|
+
### Fragment Collocation
|
|
70
|
+
|
|
71
|
+
Define a row fragment and a table fragment wrapping the Connection type.
|
|
72
|
+
|
|
73
|
+
```tsx
|
|
74
|
+
const ResourceRowFragment = graphql(`
|
|
75
|
+
fragment ResourceRow on Resource {
|
|
76
|
+
id
|
|
77
|
+
title
|
|
78
|
+
status
|
|
79
|
+
createdAt
|
|
80
|
+
}
|
|
81
|
+
`);
|
|
82
|
+
|
|
83
|
+
export const ResourceTableFragment = graphql(
|
|
84
|
+
`
|
|
85
|
+
fragment ResourceTable on ResourceConnection {
|
|
86
|
+
edges {
|
|
87
|
+
node {
|
|
88
|
+
...ResourceRow
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
`,
|
|
93
|
+
[ResourceRowFragment],
|
|
94
|
+
);
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
### Row Component
|
|
98
|
+
|
|
99
|
+
```tsx
|
|
100
|
+
const ResourceRow = ({ resource: resourceFragment }: ResourceRowProps) => {
|
|
101
|
+
const resource = readFragment(ResourceRowFragment, resourceFragment);
|
|
102
|
+
return (
|
|
103
|
+
<TableRow>
|
|
104
|
+
<TableCell>{resource.title}</TableCell>
|
|
105
|
+
<TableCell>
|
|
106
|
+
<Badge variant={resource.status === "ACTIVE" ? "default" : "secondary"}>
|
|
107
|
+
{resource.status}
|
|
108
|
+
</Badge>
|
|
109
|
+
</TableCell>
|
|
110
|
+
<TableCell>
|
|
111
|
+
<Button variant="ghost" size="sm" asChild>
|
|
112
|
+
<Link to={resource.id}>View</Link>
|
|
113
|
+
</Button>
|
|
114
|
+
</TableCell>
|
|
115
|
+
</TableRow>
|
|
116
|
+
);
|
|
117
|
+
};
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
### Empty State
|
|
121
|
+
|
|
122
|
+
```tsx
|
|
123
|
+
if (connection.edges.length === 0) {
|
|
124
|
+
return (
|
|
125
|
+
<EmptyState
|
|
126
|
+
title="No resources"
|
|
127
|
+
message="Get started by creating a new resource."
|
|
128
|
+
action={
|
|
129
|
+
<Button asChild>
|
|
130
|
+
<Link to="create">Create</Link>
|
|
131
|
+
</Button>
|
|
132
|
+
}
|
|
133
|
+
/>
|
|
134
|
+
);
|
|
135
|
+
}
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
## Column Property Mapping
|
|
139
|
+
|
|
140
|
+
| Property | Implementation |
|
|
141
|
+
| --------------- | ----------------------------------------------------------- |
|
|
142
|
+
| Hideable: Yes | Column visibility state to toggle show/hide |
|
|
143
|
+
| Sortable: Yes | Sort icon on `<TableHead>` + onClick to toggle query vars |
|
|
144
|
+
| Filterable: Yes | Filter UI above table (`<Select />`) |
|
|
145
|
+
| Searchable: Yes | Search input above table (`<Input placeholder="Search" />`) |
|
|
146
|
+
|
|
147
|
+
## Key Points
|
|
148
|
+
|
|
149
|
+
- Use `<Badge />` for status columns
|
|
150
|
+
- Format dates with `toLocaleDateString()`
|
|
151
|
+
- Use `<EmptyState />` with Create action for empty lists
|
|
152
|
+
- Add a View button per row to navigate to the detail page
|
|
153
|
+
- Iterate data using Connection type `edges.node` pattern
|
|
@@ -120,3 +120,8 @@ After Tier 4, the application specification is complete:
|
|
|
120
120
|
- **Tier 2**: Actors and business workflows
|
|
121
121
|
- **Tier 3**: User stories and screens
|
|
122
122
|
- **Tier 4**: Implementation specifications
|
|
123
|
+
|
|
124
|
+
## References
|
|
125
|
+
|
|
126
|
+
- [Application structure](references/structure.md)
|
|
127
|
+
- [Backend auth](references/auth.md)
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
# Application Directory Structure
|
|
2
|
+
|
|
3
|
+
```
|
|
4
|
+
{app_name}/
|
|
5
|
+
├── backend/
|
|
6
|
+
│ ├── src/
|
|
7
|
+
│ │ ├── modules.ts # Declaring module usage
|
|
8
|
+
│ │ ├── modules/
|
|
9
|
+
│ │ │ └── {module-name}/ # Module-specific directory
|
|
10
|
+
│ │ │ ├── resolvers/ # API Definition to expose graphql apis
|
|
11
|
+
│ │ │ └── executors/ # PubSub Automation (one file per declaration)
|
|
12
|
+
│ │ └── generated/ # Auto-generated code (do not edit)
|
|
13
|
+
│ └── tailor.config.ts # tailor application config
|
|
14
|
+
│
|
|
15
|
+
└── frontend/
|
|
16
|
+
└── src/
|
|
17
|
+
├── pages/ # File-based routing (auto-discovered by Vite plugin)
|
|
18
|
+
│ └── {page-path}/
|
|
19
|
+
│ ├── page.tsx
|
|
20
|
+
│ └── {page-path}/
|
|
21
|
+
│ ├── components/
|
|
22
|
+
│ └── page.tsx
|
|
23
|
+
├── components/
|
|
24
|
+
│ └── ui/ # Generic UI components
|
|
25
|
+
├── graphql/ # gql.tada settings
|
|
26
|
+
└── providers/ # react providers
|
|
27
|
+
```
|
package/src/cli.ts
CHANGED
|
@@ -2,101 +2,20 @@
|
|
|
2
2
|
|
|
3
3
|
import { z } from "zod";
|
|
4
4
|
import { defineCommand, runMain, arg } from "politty";
|
|
5
|
-
import { runCheck } from "./commands/check.js";
|
|
6
|
-
import { runSyncCheck, formatSyncCheckReport } from "./commands/sync-check.js";
|
|
7
|
-
import { runScaffold, ALL_TYPES, isModuleType, type ScaffoldType } from "./commands/scaffold.js";
|
|
8
5
|
import { runInit } from "./commands/init.js";
|
|
9
6
|
import { mockCommand } from "./commands/mock/index.js";
|
|
7
|
+
import { moduleCommand } from "./commands/module/index.js";
|
|
8
|
+
import { appCommand } from "./commands/app/index.js";
|
|
10
9
|
|
|
11
10
|
const cwd = process.cwd();
|
|
12
11
|
|
|
13
|
-
const rootArgs = z.object({
|
|
14
|
-
modulesRoot: arg(z.string().optional(), {
|
|
15
|
-
alias: "m",
|
|
16
|
-
description: "Path to modules directory",
|
|
17
|
-
}),
|
|
18
|
-
appRoot: arg(z.string().optional(), {
|
|
19
|
-
alias: "a",
|
|
20
|
-
description: "Path to app-compose directory (apps/ or examples/)",
|
|
21
|
-
}),
|
|
22
|
-
});
|
|
23
|
-
|
|
24
|
-
function requireRoot(args: { modulesRoot?: string; appRoot?: string }) {
|
|
25
|
-
const paths = { modulesRoot: args.modulesRoot, appRoot: args.appRoot };
|
|
26
|
-
if (!paths.modulesRoot && !paths.appRoot) {
|
|
27
|
-
console.error("At least one of --modules-root or --app-root is required.");
|
|
28
|
-
process.exit(2);
|
|
29
|
-
}
|
|
30
|
-
return paths;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
const checkCommand = defineCommand({
|
|
34
|
-
name: "check",
|
|
35
|
-
description: "Validate docs against schemas",
|
|
36
|
-
args: rootArgs,
|
|
37
|
-
run: async (args) => {
|
|
38
|
-
const paths = requireRoot(args);
|
|
39
|
-
const exitCode = await runCheck(paths, cwd);
|
|
40
|
-
process.exit(exitCode);
|
|
41
|
-
},
|
|
42
|
-
});
|
|
43
|
-
|
|
44
|
-
const syncCheckCommand = defineCommand({
|
|
45
|
-
name: "sync-check",
|
|
46
|
-
description: "Validate source <-> doc correspondence",
|
|
47
|
-
args: rootArgs,
|
|
48
|
-
run: async (args) => {
|
|
49
|
-
const paths = requireRoot(args);
|
|
50
|
-
const result = await runSyncCheck(paths, cwd);
|
|
51
|
-
console.log(formatSyncCheckReport(result));
|
|
52
|
-
process.exit(result.exitCode);
|
|
53
|
-
},
|
|
54
|
-
});
|
|
55
|
-
|
|
56
|
-
const scaffoldCommand = defineCommand({
|
|
57
|
-
name: "scaffold",
|
|
58
|
-
description: "Generate doc file from schema template",
|
|
59
|
-
args: rootArgs.extend({
|
|
60
|
-
type: arg(z.enum(ALL_TYPES as unknown as [string, ...string[]]), {
|
|
61
|
-
positional: true,
|
|
62
|
-
description: `Scaffold type (${ALL_TYPES.join(", ")})`,
|
|
63
|
-
}),
|
|
64
|
-
parent: arg(z.string(), {
|
|
65
|
-
positional: true,
|
|
66
|
-
description: "Parent name (module or app name)",
|
|
67
|
-
}),
|
|
68
|
-
name: arg(z.string().optional(), {
|
|
69
|
-
positional: true,
|
|
70
|
-
description: "Item name (required for most types)",
|
|
71
|
-
}),
|
|
72
|
-
}),
|
|
73
|
-
run: async (args) => {
|
|
74
|
-
const paths = requireRoot(args);
|
|
75
|
-
const root = isModuleType(args.type) ? paths.modulesRoot : paths.appRoot;
|
|
76
|
-
if (!root) {
|
|
77
|
-
console.error(
|
|
78
|
-
`--${isModuleType(args.type) ? "modules-root" : "app-root"} is required for scaffold type "${args.type}".`,
|
|
79
|
-
);
|
|
80
|
-
process.exit(2);
|
|
81
|
-
}
|
|
82
|
-
const exitCode = await runScaffold(
|
|
83
|
-
args.type as ScaffoldType,
|
|
84
|
-
args.parent,
|
|
85
|
-
args.name,
|
|
86
|
-
root,
|
|
87
|
-
cwd,
|
|
88
|
-
);
|
|
89
|
-
process.exit(exitCode);
|
|
90
|
-
},
|
|
91
|
-
});
|
|
92
|
-
|
|
93
12
|
const initCommand = defineCommand({
|
|
94
13
|
name: "init",
|
|
95
|
-
description: "Set up consumer repo
|
|
14
|
+
description: "Set up consumer repo with framework skills",
|
|
96
15
|
args: z.object({
|
|
97
16
|
force: arg(z.boolean().default(false), {
|
|
98
17
|
alias: "f",
|
|
99
|
-
description: "Overwrite existing skills
|
|
18
|
+
description: "Overwrite existing skills",
|
|
100
19
|
}),
|
|
101
20
|
}),
|
|
102
21
|
run: (args) => {
|
|
@@ -107,13 +26,12 @@ const initCommand = defineCommand({
|
|
|
107
26
|
|
|
108
27
|
const main = defineCommand({
|
|
109
28
|
name: "erp-kit",
|
|
110
|
-
description: "
|
|
29
|
+
description: "ERP module framework CLI",
|
|
111
30
|
subCommands: {
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
scaffold: scaffoldCommand,
|
|
115
|
-
init: initCommand,
|
|
31
|
+
module: moduleCommand,
|
|
32
|
+
app: appCommand,
|
|
116
33
|
mock: mockCommand,
|
|
34
|
+
init: initCommand,
|
|
117
35
|
},
|
|
118
36
|
});
|
|
119
37
|
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { defineCommand, arg } from "politty";
|
|
3
|
+
import { runCheck } from "../check.js";
|
|
4
|
+
import { runSyncCheck, formatSyncCheckReport } from "../sync-check.js";
|
|
5
|
+
import { runScaffold, APP_TYPES, type ScaffoldType } from "../scaffold.js";
|
|
6
|
+
|
|
7
|
+
const cwd = process.cwd();
|
|
8
|
+
|
|
9
|
+
const rootArgs = z.object({
|
|
10
|
+
root: arg(z.string(), {
|
|
11
|
+
alias: "r",
|
|
12
|
+
description: "Path to app-compose directory",
|
|
13
|
+
}),
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
const checkCommand = defineCommand({
|
|
17
|
+
name: "check",
|
|
18
|
+
description: "Validate app docs against schemas",
|
|
19
|
+
args: rootArgs,
|
|
20
|
+
run: async (args) => {
|
|
21
|
+
const exitCode = await runCheck({ appRoot: args.root }, cwd);
|
|
22
|
+
process.exit(exitCode);
|
|
23
|
+
},
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
const syncCheckCommand = defineCommand({
|
|
27
|
+
name: "sync-check",
|
|
28
|
+
description: "Validate source <-> doc correspondence",
|
|
29
|
+
args: rootArgs,
|
|
30
|
+
run: async (args) => {
|
|
31
|
+
const result = await runSyncCheck({ appRoot: args.root }, cwd);
|
|
32
|
+
console.log(formatSyncCheckReport(result));
|
|
33
|
+
process.exit(result.exitCode);
|
|
34
|
+
},
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
const scaffoldCommand = defineCommand({
|
|
38
|
+
name: "scaffold",
|
|
39
|
+
description: "Generate app doc from schema template",
|
|
40
|
+
args: rootArgs.extend({
|
|
41
|
+
type: arg(z.enum(APP_TYPES as unknown as [string, ...string[]]), {
|
|
42
|
+
positional: true,
|
|
43
|
+
description: `Scaffold type (${APP_TYPES.join(", ")})`,
|
|
44
|
+
}),
|
|
45
|
+
parent: arg(z.string(), {
|
|
46
|
+
positional: true,
|
|
47
|
+
description: "App name",
|
|
48
|
+
}),
|
|
49
|
+
name: arg(z.string().optional(), {
|
|
50
|
+
positional: true,
|
|
51
|
+
description: "Item name (required for most types)",
|
|
52
|
+
}),
|
|
53
|
+
}),
|
|
54
|
+
run: async (args) => {
|
|
55
|
+
const exitCode = await runScaffold(
|
|
56
|
+
args.type as ScaffoldType,
|
|
57
|
+
args.parent,
|
|
58
|
+
args.name,
|
|
59
|
+
args.root,
|
|
60
|
+
cwd,
|
|
61
|
+
);
|
|
62
|
+
process.exit(exitCode);
|
|
63
|
+
},
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
export const appCommand = defineCommand({
|
|
67
|
+
name: "app",
|
|
68
|
+
description: "App-compose management",
|
|
69
|
+
subCommands: {
|
|
70
|
+
check: checkCommand,
|
|
71
|
+
"sync-check": syncCheckCommand,
|
|
72
|
+
scaffold: scaffoldCommand,
|
|
73
|
+
},
|
|
74
|
+
});
|
|
@@ -8,6 +8,7 @@ describe("buildCheckTargets", () => {
|
|
|
8
8
|
{ glob: "modules/[a-zA-Z]*/docs/features/*.md", schemaKey: "feature" },
|
|
9
9
|
{ glob: "modules/[a-zA-Z]*/docs/commands/*.md", schemaKey: "command" },
|
|
10
10
|
{ glob: "modules/[a-zA-Z]*/docs/models/*.md", schemaKey: "model" },
|
|
11
|
+
{ glob: "modules/[a-zA-Z]*/docs/queries/*.md", schemaKey: "query" },
|
|
11
12
|
{ glob: "modules/[a-zA-Z]*/README.md", schemaKey: "module" },
|
|
12
13
|
]);
|
|
13
14
|
});
|
|
@@ -20,7 +21,7 @@ describe("buildCheckTargets", () => {
|
|
|
20
21
|
|
|
21
22
|
it("generates both when both roots are set", () => {
|
|
22
23
|
const targets = buildCheckTargets({ modulesRoot: "modules", appRoot: "examples" });
|
|
23
|
-
expect(targets).toHaveLength(
|
|
24
|
+
expect(targets).toHaveLength(11);
|
|
24
25
|
});
|
|
25
26
|
|
|
26
27
|
it("returns empty when neither root is set", () => {
|
package/src/commands/check.ts
CHANGED
|
@@ -17,6 +17,7 @@ export function buildCheckTargets(config: {
|
|
|
17
17
|
{ glob: `${m}/[a-zA-Z]*/docs/features/*.md`, schemaKey: "feature" },
|
|
18
18
|
{ glob: `${m}/[a-zA-Z]*/docs/commands/*.md`, schemaKey: "command" },
|
|
19
19
|
{ glob: `${m}/[a-zA-Z]*/docs/models/*.md`, schemaKey: "model" },
|
|
20
|
+
{ glob: `${m}/[a-zA-Z]*/docs/queries/*.md`, schemaKey: "query" },
|
|
20
21
|
{ glob: `${m}/[a-zA-Z]*/README.md`, schemaKey: "module" },
|
|
21
22
|
);
|
|
22
23
|
}
|