@akanjs/cli 3.1.1-rc.12 → 3.1.1-rc.14
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/.build-stamp +1 -1
- package/{CodeAgent-eaazb526.js → CodeAgent-gtwn7tmb.js} +2 -2
- package/{CodeTui-e7nh3rv9.js → CodeTui-v941fqdh.js} +1 -1
- package/akanCode.js +2 -2
- package/{code.command-at39gpkg.js → code.command-dyet4xn6.js} +4 -4
- package/{context.command-d35ppstw.js → context.command-79gxczm4.js} +2 -2
- package/{context.runner-azvkkzdr.js → context.runner-ejag7mhr.js} +1 -1
- package/guidelines/queryRule/queryRule.instruction.md +4 -0
- package/{index-qsz6w3d6.js → index-41d3zx66.js} +3 -3
- package/{index-8wd5r2xv.js → index-jjd97ya6.js} +1 -1
- package/{index-trvk51ht.js → index-jtydvvq7.js} +1 -1
- package/{index-7yzcaymm.js → index-pc9ps0hx.js} +1 -2
- package/index.js +3 -3
- package/package.json +2 -2
- package/templates/__scalar/__model__/__model__.constant.ts +3 -5
- package/templates/__scalar/__model__/__model__.dictionary.ts +6 -5
- package/templates/__scalar/__model__/__model__.document.ts +3 -3
- package/templates/app/akan.config.ts +2 -3
- package/templates/app/env/env.client.ts +2 -4
- package/templates/app/env/env.client.type.ts +2 -3
- package/templates/app/env/env.server.ts +2 -3
- package/templates/app/lib/___appName__/__appName__.dictionary.ts +1 -2
- package/templates/app/lib/___appName__/__appName__.service.ts +3 -3
- package/templates/app/lib/___appName__/__appName__.signal.ts +5 -5
- package/templates/app/lib/___appName__/__appName__.store.ts +4 -6
- package/templates/app/lib/option.ts +2 -3
- package/templates/app/main.ts +2 -4
- package/templates/app/page/_index.tsx +3 -3
- package/templates/app/page/_layout.tsx +13 -10
- package/templates/appSample/lib/__scalar/workHistory/workHistory.constant.ts +1 -5
- package/templates/appSample/lib/__scalar/workHistory/workHistory.dictionary.ts +1 -1
- package/templates/appSample/lib/_noti/noti.signal.ts +1 -1
- package/templates/appSample/lib/task/Task.Template.tsx +2 -1
- package/templates/appSample/lib/task/Task.Unit.tsx +3 -2
- package/templates/appSample/lib/task/Task.Util.tsx +16 -4
- package/templates/appSample/lib/task/task.constant.ts +1 -5
- package/templates/appSample/lib/task/task.dictionary.ts +2 -8
- package/templates/appSample/lib/task/task.document.ts +1 -1
- package/templates/appSample/page/task/_index.tsx +2 -1
- package/templates/appSample/page/task/new.tsx +2 -1
- package/templates/appSample/ui/QuantityControl.tsx +5 -9
- package/templates/biomeForm.ts +144 -0
- package/templates/crudPages/[__model__Id]/edit/page.tsx +3 -3
- package/templates/crudPages/[__model__Id]/page.tsx +5 -5
- package/templates/crudPages/new/page.tsx +4 -3
- package/templates/crudPages/page.tsx +3 -3
- package/templates/crudSinglePage/page.tsx +9 -5
- package/templates/libRoot/akan.config.ts +2 -3
- package/templates/libRoot/lib/___libName__/__libName__.dictionary.ts +1 -2
- package/templates/libRoot/lib/___libName__/__libName__.service.ts +5 -4
- package/templates/libRoot/lib/___libName__/__libName__.signal.ts +6 -5
- package/templates/libRoot/lib/___libName__/__libName__.store.ts +5 -6
- package/templates/libRoot/lib/option.ts +1 -2
- package/templates/module/__Model__.Template.tsx +11 -10
- package/templates/module/__Model__.Unit.tsx +18 -5
- package/templates/module/__Model__.Util.tsx +9 -7
- package/templates/module/__Model__.View.tsx +9 -6
- package/templates/module/__Model__.Zone.tsx +25 -17
- package/templates/module/__model__.constant.ts +8 -9
- package/templates/module/__model__.dictionary.ts +16 -17
- package/templates/module/__model__.document.ts +6 -8
- package/templates/module/__model__.service.ts +3 -3
- package/templates/module/__model__.signal.ts +11 -10
- package/templates/module/__model__.store.ts +3 -5
- package/templates/service/__model__.dictionary.ts +6 -5
- package/templates/service/__model__.service.ts +3 -3
- package/templates/service/__model__.signal.ts +5 -4
- package/templates/service/__model__.store.ts +3 -5
- package/templates/workspaceRoot/.vscode/settings.json.template +21 -21
- package/{workspace.command-j1680trm.js → workspace.command-097hv6n1.js} +2 -2
|
@@ -14,10 +14,7 @@ import type { TaskFilter } from "./task.document";
|
|
|
14
14
|
// Registered by akan sync into dict.ts barrel.
|
|
15
15
|
|
|
16
16
|
export const dictionary = modelDictionary(["en", "ko"])
|
|
17
|
-
.of((t) =>
|
|
18
|
-
t(["Task", "할 일"])
|
|
19
|
-
.desc(["A unit of work to be completed", "완료해야 할 작업 단위"]),
|
|
20
|
-
)
|
|
17
|
+
.of((t) => t(["Task", "할 일"]).desc(["A unit of work to be completed", "완료해야 할 작업 단위"]))
|
|
21
18
|
.model<Task>((t) => ({
|
|
22
19
|
title: t(["Title", "제목"]).desc(["Task title", "할 일 제목"]),
|
|
23
20
|
content: t(["Content", "내용"]).desc(["Detailed task description", "상세 작업 설명"]),
|
|
@@ -43,10 +40,7 @@ export const dictionary = modelDictionary(["en", "ko"])
|
|
|
43
40
|
completed: t(["Completed", "완료"]),
|
|
44
41
|
}))
|
|
45
42
|
.error({
|
|
46
|
-
cannotStartFromNonTodo: [
|
|
47
|
-
"Task can only start from todo status",
|
|
48
|
-
"할 일 상태에서만 시작할 수 있습니다",
|
|
49
|
-
],
|
|
43
|
+
cannotStartFromNonTodo: ["Task can only start from todo status", "할 일 상태에서만 시작할 수 있습니다"],
|
|
50
44
|
cannotCompleteFromNonInProgress: [
|
|
51
45
|
"Task can only complete from in-progress status",
|
|
52
46
|
"진행 중 상태에서만 완료할 수 있습니다",
|
|
@@ -4,8 +4,8 @@ export default function getContent(scanInfo: AppInfo | LibInfo | null, dict: { a
|
|
|
4
4
|
return `import { dayjs } from "akanjs/base";
|
|
5
5
|
import { by, from, into } from "akanjs/document";
|
|
6
6
|
|
|
7
|
-
import { Err } from "../dict";
|
|
8
7
|
import * as cnst from "../cnst";
|
|
8
|
+
import { Err } from "../dict";
|
|
9
9
|
|
|
10
10
|
// ===== task.document.ts =====
|
|
11
11
|
// Convention: <module>.document.ts — the database query and persistence layer.
|
|
@@ -21,16 +21,11 @@ interface QuantityControlProps {
|
|
|
21
21
|
max?: number;
|
|
22
22
|
}
|
|
23
23
|
|
|
24
|
-
export const QuantityControl = ({
|
|
25
|
-
className,
|
|
26
|
-
value,
|
|
27
|
-
onChange,
|
|
28
|
-
min = 0,
|
|
29
|
-
max = 99,
|
|
30
|
-
}: QuantityControlProps) => {
|
|
24
|
+
export const QuantityControl = ({ className, value, onChange, min = 0, max = 99 }: QuantityControlProps) => {
|
|
31
25
|
return (
|
|
32
26
|
<div className={cn("inline-flex items-center gap-1", className)}>
|
|
33
|
-
<button
|
|
27
|
+
<button
|
|
28
|
+
type="button"
|
|
34
29
|
className={jellyButtonRecipe({ variant: "default", size: "icon" }, "size-7")}
|
|
35
30
|
disabled={value <= min}
|
|
36
31
|
onClick={() => onChange(Math.max(min, value - 1))}
|
|
@@ -38,7 +33,8 @@ export const QuantityControl = ({
|
|
|
38
33
|
−
|
|
39
34
|
</button>
|
|
40
35
|
<span className="w-8 text-center font-medium tabular-nums">{value}</span>
|
|
41
|
-
<button
|
|
36
|
+
<button
|
|
37
|
+
type="button"
|
|
42
38
|
className={jellyButtonRecipe({ variant: "default", size: "icon" }, "size-7")}
|
|
43
39
|
disabled={value >= max}
|
|
44
40
|
onClick={() => onChange(Math.min(max, value + 1))}
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
import { compareExportNames } from "./facetIndex";
|
|
2
|
+
|
|
3
|
+
export interface JsxElement {
|
|
4
|
+
tag: string;
|
|
5
|
+
attrs: JsxAttr[];
|
|
6
|
+
}
|
|
7
|
+
export type JsxAttr = string | { name: string; param: string; body: JsxElement };
|
|
8
|
+
|
|
9
|
+
//? A scaffold is written before `bun install`, when no Biome can format it, so these break lines where Biome would.
|
|
10
|
+
export class BiomeForm {
|
|
11
|
+
static readonly lineWidth = 120;
|
|
12
|
+
|
|
13
|
+
//? Biome counts a Hangul syllable as two columns, as Bun.stringWidth does.
|
|
14
|
+
static fits(line: string) {
|
|
15
|
+
return Bun.stringWidth(line) <= BiomeForm.lineWidth;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
static sorted(specifiers: string[]) {
|
|
19
|
+
return specifiers.toSorted((a, b) => compareExportNames(a.replace(/^type /, ""), b.replace(/^type /, "")));
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
//? Biome never breaks an import of one specifier, however long.
|
|
23
|
+
static importFrom(specifiers: string[], source: string, { typeOnly = false }: { typeOnly?: boolean } = {}) {
|
|
24
|
+
const keyword = typeOnly ? "import type" : "import";
|
|
25
|
+
const names = BiomeForm.sorted(specifiers);
|
|
26
|
+
const flat = `${keyword} { ${names.join(", ")} } from "${source}";`;
|
|
27
|
+
if (names.length === 1 || BiomeForm.fits(flat)) return flat;
|
|
28
|
+
return `${keyword} {\n${names.map((name) => ` ${name},`).join("\n")}\n} from "${source}";`;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
//? A multi-line argument comes indented as it reads hugged, relative to the indent the call starts at.
|
|
32
|
+
static callArgs(indent: string, head: string, args: string[], tail = "") {
|
|
33
|
+
const leading = args.slice(0, -1);
|
|
34
|
+
const lastLines = (args.at(-1) ?? "").split("\n");
|
|
35
|
+
if (lastLines.length === 1) {
|
|
36
|
+
const flat = `${indent}${head}(${args.join(", ")})${tail}`;
|
|
37
|
+
if (BiomeForm.fits(flat)) return flat;
|
|
38
|
+
} else {
|
|
39
|
+
const opening = `${indent}${head}(${[...leading, lastLines[0]].join(", ")}`;
|
|
40
|
+
const closing = `${lastLines.at(-1)})${tail}`;
|
|
41
|
+
if (BiomeForm.fits(opening) && BiomeForm.fits(`${indent}${closing}`))
|
|
42
|
+
return [
|
|
43
|
+
opening,
|
|
44
|
+
...lastLines.slice(1, -1).map((line) => BiomeForm.#indented(line, indent)),
|
|
45
|
+
`${indent}${closing}`,
|
|
46
|
+
].join("\n");
|
|
47
|
+
}
|
|
48
|
+
const broken = args.map((arg) =>
|
|
49
|
+
`${arg},`
|
|
50
|
+
.split("\n")
|
|
51
|
+
.map((line) => BiomeForm.#indented(line, `${indent} `))
|
|
52
|
+
.join("\n"),
|
|
53
|
+
);
|
|
54
|
+
return `${indent}${head}(\n${broken.join("\n")}\n${indent})${tail}`;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
//? Biome breaks after `=` only when the right side cannot break before the line ends.
|
|
58
|
+
static assign(indent: string, target: string, head: string, args: string[], tail = "") {
|
|
59
|
+
const call = BiomeForm.callArgs(indent, `${target} = ${head}`, args, tail);
|
|
60
|
+
if (!call.includes("\n") || (args.length > 0 && BiomeForm.fits(`${indent}${target} = ${head}(`))) return call;
|
|
61
|
+
return `${indent}${target} =\n${BiomeForm.callArgs(`${indent} `, head, args, tail)}`;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
//? A broken type argument list takes no trailing comma.
|
|
65
|
+
static typeArgs(indent: string, head: string, args: string[], tail = "") {
|
|
66
|
+
const flat = `${indent}${head}<${args.join(", ")}>${tail}`;
|
|
67
|
+
if (BiomeForm.fits(flat)) return flat;
|
|
68
|
+
return `${indent}${head}<\n${args.map((arg) => `${indent} ${arg}`).join(",\n")}\n${indent}>${tail}`;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
//? JSX text that does not fit ends its line with an explicit `{" "}`, since a line break there would drop the space.
|
|
72
|
+
static jsxSpaced(indent: string, first: string, second: string) {
|
|
73
|
+
const flat = `${indent}${first} ${second}`;
|
|
74
|
+
if (BiomeForm.fits(flat)) return flat;
|
|
75
|
+
return `${indent}${first}{" "}\n${indent}${second}`;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
static wrap(indent: string, open: string, child: string, close: string) {
|
|
79
|
+
const flat = `${indent}${open}${child}${close}`;
|
|
80
|
+
if (BiomeForm.fits(flat)) return flat;
|
|
81
|
+
return `${indent}${open}\n${indent} ${child}\n${indent}${close}`;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
static element(element: JsxElement, indent: string, { before = "", after = "" } = {}): string {
|
|
85
|
+
const flat = `${indent}${before}${BiomeForm.#flat(element)}${after}`;
|
|
86
|
+
if (BiomeForm.fits(flat)) return flat;
|
|
87
|
+
const attrs = element.attrs.map((attr) => BiomeForm.#attr(attr, `${indent} `));
|
|
88
|
+
return `${indent}${before}<${element.tag}\n${attrs.join("\n")}\n${indent}/>${after}`;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
static openingTag(element: JsxElement, indent: string) {
|
|
92
|
+
const flat = `${indent}<${element.tag} ${element.attrs.map((attr) => BiomeForm.#flatAttr(attr)).join(" ")}>`;
|
|
93
|
+
if (BiomeForm.fits(flat)) return flat;
|
|
94
|
+
const attrs = element.attrs.map((attr) => BiomeForm.#attr(attr, `${indent} `));
|
|
95
|
+
return `${indent}<${element.tag}\n${attrs.join("\n")}\n${indent}>`;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
static returnElement(element: JsxElement, indent: string) {
|
|
99
|
+
const flat = `${indent}return ${BiomeForm.#flat(element)};`;
|
|
100
|
+
if (BiomeForm.fits(flat)) return flat;
|
|
101
|
+
return `${indent}return (\n${BiomeForm.element(element, `${indent} `)}\n${indent});`;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
static dictionaryOf(label: readonly [string, string], desc: readonly [string, string]) {
|
|
105
|
+
const body = `t(${BiomeForm.#pair(label)}).desc(${BiomeForm.#pair(desc)})`;
|
|
106
|
+
if (BiomeForm.fits(` .of((t) => ${body})`)) return ` .of((t) => ${body})`;
|
|
107
|
+
if (BiomeForm.fits(` ${body},`)) return ` .of((t) =>\n ${body},\n )`;
|
|
108
|
+
const descLines = desc.map((text) => ` ${JSON.stringify(text)},`).join("\n");
|
|
109
|
+
if (BiomeForm.fits(` t(${BiomeForm.#pair(label)}).desc([`))
|
|
110
|
+
return ` .of((t) =>\n t(${BiomeForm.#pair(label)}).desc([\n${descLines}\n ]),\n )`;
|
|
111
|
+
const labelLines = label.map((text) => ` ${JSON.stringify(text)},`).join("\n");
|
|
112
|
+
return ` .of((t) =>\n t([\n${labelLines}\n ]).desc([\n${descLines}\n ]),\n )`;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
static dictionarySlice(key: string, label: readonly [string, string]) {
|
|
116
|
+
const head = ` ${key}: fn(${BiomeForm.#pair(label)}).arg(`;
|
|
117
|
+
if (BiomeForm.fits(`${head}(t) => ({})),`)) return `${head}(t) => ({})),`;
|
|
118
|
+
if (BiomeForm.fits(head)) return `${head}\n (t) => ({}),\n ),`;
|
|
119
|
+
const labelLines = label.map((text) => ` ${JSON.stringify(text)},`).join("\n");
|
|
120
|
+
return ` ${key}: fn([\n${labelLines}\n ]).arg((t) => ({})),`;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
static #pair(pair: readonly [string, string]) {
|
|
124
|
+
return `[${pair.map((text) => JSON.stringify(text)).join(", ")}]`;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
static #indented(line: string, indent: string) {
|
|
128
|
+
return line ? `${indent}${line}` : line;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
static #flat({ tag, attrs }: JsxElement): string {
|
|
132
|
+
return `<${[tag, ...attrs.map((attr) => BiomeForm.#flatAttr(attr))].join(" ")} />`;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
static #flatAttr(attr: JsxAttr): string {
|
|
136
|
+
return typeof attr === "string" ? attr : `${attr.name}={(${attr.param}) => ${BiomeForm.#flat(attr.body)}}`;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
static #attr(attr: JsxAttr, indent: string): string {
|
|
140
|
+
const flat = `${indent}${BiomeForm.#flatAttr(attr)}`;
|
|
141
|
+
if (typeof attr === "string" || BiomeForm.fits(flat)) return flat;
|
|
142
|
+
return `${indent}${attr.name}={(${attr.param}) => (\n${BiomeForm.element(attr.body, `${indent} `)}\n${indent})}`;
|
|
143
|
+
}
|
|
144
|
+
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { AppInfo, LibInfo } from "akanjs";
|
|
2
|
+
import { BiomeForm } from "../../../biomeForm";
|
|
2
3
|
|
|
3
4
|
interface Dict {
|
|
4
5
|
Model: string;
|
|
@@ -9,8 +10,7 @@ interface Dict {
|
|
|
9
10
|
export default function getContent(scanInfo: AppInfo | LibInfo | null, dict: Dict) {
|
|
10
11
|
return {
|
|
11
12
|
filename: "_index.tsx",
|
|
12
|
-
content:
|
|
13
|
-
import { ${dict.Model}, fetch, usePage } from "${dict.clientPath}";
|
|
13
|
+
content: `${BiomeForm.importFrom([dict.Model, "fetch", "usePage"], dict.clientPath)}
|
|
14
14
|
import { ID } from "akanjs/base";
|
|
15
15
|
import { page } from "akanjs/client";
|
|
16
16
|
import { Load } from "akanjs/ui";
|
|
@@ -20,7 +20,7 @@ export default page()
|
|
|
20
20
|
.config({ transition: "none" })
|
|
21
21
|
.render(({ ${dict.model}Id }) => {
|
|
22
22
|
const { l } = usePage();
|
|
23
|
-
const { ${dict.model}Edit }
|
|
23
|
+
${BiomeForm.assign(" ", `const { ${dict.model}Edit }`, `fetch.edit${dict.Model}`, [`${dict.model}Id`], ";")}
|
|
24
24
|
return (
|
|
25
25
|
<div className="container">
|
|
26
26
|
<div className="m-4 mt-8 flex justify-between">
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { AppInfo, LibInfo } from "akanjs";
|
|
2
|
+
import { BiomeForm } from "../../biomeForm";
|
|
2
3
|
|
|
3
4
|
interface Dict {
|
|
4
5
|
Model: string;
|
|
@@ -9,8 +10,7 @@ interface Dict {
|
|
|
9
10
|
export default function getContent(scanInfo: AppInfo | LibInfo | null, dict: Dict) {
|
|
10
11
|
return {
|
|
11
12
|
filename: "_index.tsx",
|
|
12
|
-
content:
|
|
13
|
-
import { ${dict.Model}, fetch, usePage } from "${dict.clientPath}";
|
|
13
|
+
content: `${BiomeForm.importFrom([dict.Model, "fetch", "usePage"], dict.clientPath)}
|
|
14
14
|
import { ID } from "akanjs/base";
|
|
15
15
|
import { page } from "akanjs/client";
|
|
16
16
|
import { buttonRecipe, Link } from "akanjs/ui";
|
|
@@ -28,12 +28,12 @@ export default page()
|
|
|
28
28
|
))
|
|
29
29
|
.render(({ ${dict.model}Id }) => {
|
|
30
30
|
const { l } = usePage();
|
|
31
|
-
const { ${dict.model}View }
|
|
31
|
+
${BiomeForm.assign(" ", `const { ${dict.model}View }`, `fetch.view${dict.Model}`, [`${dict.model}Id`], ";")}
|
|
32
32
|
return (
|
|
33
33
|
<div className="container flex flex-col gap-4">
|
|
34
34
|
<div className="flex items-center gap-4 font-bold text-lg">
|
|
35
|
-
|
|
36
|
-
|
|
35
|
+
${BiomeForm.element({ tag: `${dict.Model}.Zone.View`, attrs: [`view={${dict.model}View}`] }, " ")}
|
|
36
|
+
${BiomeForm.openingTag({ tag: "Link", attrs: ["className={buttonRecipe()}", `href={\`/${dict.model}/\${${dict.model}Id}/edit\`}`] }, " ")}
|
|
37
37
|
{l("base.updateModel", { model: l("${dict.model}.modelName") })}
|
|
38
38
|
</Link>
|
|
39
39
|
</div>
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { AppInfo, LibInfo } from "akanjs";
|
|
2
|
+
import { BiomeForm } from "../../biomeForm";
|
|
2
3
|
|
|
3
4
|
interface Dict {
|
|
4
5
|
Model: string;
|
|
@@ -7,10 +8,10 @@ interface Dict {
|
|
|
7
8
|
clientPath: string;
|
|
8
9
|
}
|
|
9
10
|
export default function getContent(scanInfo: AppInfo | LibInfo | null, dict: Dict) {
|
|
11
|
+
const form = ` const ${dict.model}Form: Partial<cnst.${dict.Model}> =`;
|
|
10
12
|
return {
|
|
11
13
|
filename: "_index.tsx",
|
|
12
|
-
content:
|
|
13
|
-
import { type cnst, fetch, usePage, ${dict.Model} } from "${dict.clientPath}";
|
|
14
|
+
content: `${BiomeForm.importFrom(["type cnst", "fetch", "usePage", dict.Model], dict.clientPath)}
|
|
14
15
|
import { page } from "akanjs/client";
|
|
15
16
|
import { Load } from "akanjs/ui";
|
|
16
17
|
|
|
@@ -18,7 +19,7 @@ export default page()
|
|
|
18
19
|
.config({ transition: "none" })
|
|
19
20
|
.render(() => {
|
|
20
21
|
const { l } = usePage();
|
|
21
|
-
|
|
22
|
+
${BiomeForm.fits(`${form} {};`) ? `${form} {};` : `${form}\n {};`}
|
|
22
23
|
return (
|
|
23
24
|
<div className="container">
|
|
24
25
|
<div className="m-4 mt-8 flex justify-between">
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { AppInfo, LibInfo } from "akanjs";
|
|
2
|
+
import { BiomeForm } from "../biomeForm";
|
|
2
3
|
|
|
3
4
|
interface Dict {
|
|
4
5
|
Model: string;
|
|
@@ -9,8 +10,7 @@ interface Dict {
|
|
|
9
10
|
export default function getContent(scanInfo: AppInfo | LibInfo | null, dict: Dict) {
|
|
10
11
|
return {
|
|
11
12
|
filename: "_index.tsx",
|
|
12
|
-
content:
|
|
13
|
-
import { ${dict.Model}, fetch, usePage } from "${dict.clientPath}";
|
|
13
|
+
content: `${BiomeForm.importFrom([dict.Model, "fetch", "usePage"], dict.clientPath)}
|
|
14
14
|
import { page } from "akanjs/client";
|
|
15
15
|
import { buttonRecipe, Link } from "akanjs/ui";
|
|
16
16
|
|
|
@@ -18,7 +18,7 @@ export default page()
|
|
|
18
18
|
.config({ transition: "none" })
|
|
19
19
|
.render(() => {
|
|
20
20
|
const { l } = usePage();
|
|
21
|
-
const { ${dict.model}InitInPublic }
|
|
21
|
+
${BiomeForm.assign(" ", `const { ${dict.model}InitInPublic }`, `fetch.init${dict.Model}InPublic`, [], ";")}
|
|
22
22
|
return (
|
|
23
23
|
<div className="container flex flex-col gap-4">
|
|
24
24
|
<div className="mt-5 h-full w-full px-5">
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { AppInfo, LibInfo } from "akanjs";
|
|
2
|
+
import { BiomeForm } from "../biomeForm";
|
|
2
3
|
|
|
3
4
|
interface Dict {
|
|
4
5
|
Model: string;
|
|
@@ -9,8 +10,7 @@ interface Dict {
|
|
|
9
10
|
export default function getContent(scanInfo: AppInfo | LibInfo | null, dict: Dict) {
|
|
10
11
|
return {
|
|
11
12
|
filename: "_index.tsx",
|
|
12
|
-
content:
|
|
13
|
-
import { ${dict.Model}, fetch, usePage } from "${dict.clientPath}";
|
|
13
|
+
content: `${BiomeForm.importFrom([dict.Model, "fetch", "usePage"], dict.clientPath)}
|
|
14
14
|
import { page } from "akanjs/client";
|
|
15
15
|
import { buttonRecipe, Model } from "akanjs/ui";
|
|
16
16
|
|
|
@@ -18,13 +18,17 @@ export default page()
|
|
|
18
18
|
.config({ transition: "none" })
|
|
19
19
|
.render(() => {
|
|
20
20
|
const { l } = usePage();
|
|
21
|
-
const { ${dict.model}InitInPublic }
|
|
21
|
+
${BiomeForm.assign(" ", `const { ${dict.model}InitInPublic }`, `fetch.init${dict.Model}InPublic`, [], ";")}
|
|
22
22
|
return (
|
|
23
23
|
<>
|
|
24
24
|
<div className="flex animate-fadeIn items-center gap-4 px-4 pt-4">
|
|
25
|
-
<div className="font-bold text-lg md:text-4xl">{l("${dict.model}.modelName")}</div>
|
|
25
|
+
${BiomeForm.wrap(" ", '<div className="font-bold text-lg md:text-4xl">', `{l("${dict.model}.modelName")}`, "</div>")}
|
|
26
26
|
<Model.New
|
|
27
|
-
trigger={
|
|
27
|
+
trigger={
|
|
28
|
+
<button type="button" className={buttonRecipe({ size: "sm", variant: "ghost" })}>
|
|
29
|
+
{l("base.new")}
|
|
30
|
+
</button>
|
|
31
|
+
}
|
|
28
32
|
slice={fetch.slice.${dict.model}InPublic}
|
|
29
33
|
renderTitle="id"
|
|
30
34
|
>
|
|
@@ -2,11 +2,10 @@ interface Dict {
|
|
|
2
2
|
libName: string;
|
|
3
3
|
}
|
|
4
4
|
export default function getContent(scanInfo: null, dict: Dict) {
|
|
5
|
-
return `
|
|
6
|
-
import type { LibConfig } from "akanjs";
|
|
5
|
+
return `import type { LibConfig } from "akanjs";
|
|
7
6
|
|
|
8
7
|
const config: LibConfig = {};
|
|
9
8
|
|
|
10
9
|
export default config;
|
|
11
|
-
|
|
10
|
+
`;
|
|
12
11
|
}
|
|
@@ -3,8 +3,7 @@ interface Dict {
|
|
|
3
3
|
LibName: string;
|
|
4
4
|
}
|
|
5
5
|
export default function getContent(scanInfo: null, dict: Dict) {
|
|
6
|
-
return `
|
|
7
|
-
import { serviceDictionary } from "akanjs/dictionary";
|
|
6
|
+
return `import { serviceDictionary } from "akanjs/dictionary";
|
|
8
7
|
|
|
9
8
|
import type { ${dict.LibName}Endpoint } from "./${dict.libName}.signal";
|
|
10
9
|
|
|
@@ -1,13 +1,14 @@
|
|
|
1
|
+
import { BiomeForm } from "../../../biomeForm";
|
|
2
|
+
|
|
1
3
|
interface Dict {
|
|
2
4
|
libName: string;
|
|
3
5
|
LibName: string;
|
|
4
6
|
}
|
|
5
7
|
export default function getContent(scanInfo: null, dict: Dict) {
|
|
6
|
-
return `
|
|
7
|
-
import { serve } from "akanjs/service";
|
|
8
|
+
return `import { serve } from "akanjs/service";
|
|
8
9
|
|
|
9
10
|
// import type * as srv from "../srv";
|
|
10
11
|
|
|
11
|
-
export class ${dict.LibName}Service extends serve
|
|
12
|
-
|
|
12
|
+
${BiomeForm.callArgs("", `export class ${dict.LibName}Service extends serve`, [`"${dict.libName}" as const`, '{ serverMode: "batch" }', "() => ({})"], " {}")}
|
|
13
|
+
`;
|
|
13
14
|
}
|
|
@@ -1,15 +1,16 @@
|
|
|
1
|
+
import { BiomeForm } from "../../../biomeForm";
|
|
2
|
+
|
|
1
3
|
interface Dict {
|
|
2
4
|
libName: string;
|
|
3
5
|
LibName: string;
|
|
4
6
|
}
|
|
5
7
|
export default function getContent(scanInfo: null, dict: Dict) {
|
|
6
|
-
return `
|
|
7
|
-
import { endpoint, internal } from "akanjs/signal";
|
|
8
|
+
return `import { endpoint, internal } from "akanjs/signal";
|
|
8
9
|
|
|
9
10
|
import * as srv from "../srv";
|
|
10
11
|
|
|
11
|
-
export class ${dict.LibName}Internal extends internal
|
|
12
|
+
${BiomeForm.callArgs("", `export class ${dict.LibName}Internal extends internal`, [`srv.${dict.libName}`, "() => ({})"], " {}")}
|
|
12
13
|
|
|
13
|
-
export class ${dict.LibName}Endpoint extends endpoint
|
|
14
|
-
|
|
14
|
+
${BiomeForm.callArgs("", `export class ${dict.LibName}Endpoint extends endpoint`, [`srv.${dict.libName}`, "() => ({})"], " {}")}
|
|
15
|
+
`;
|
|
15
16
|
}
|
|
@@ -1,15 +1,14 @@
|
|
|
1
|
+
import { BiomeForm } from "../../../biomeForm";
|
|
2
|
+
|
|
1
3
|
interface Dict {
|
|
2
4
|
libName: string;
|
|
3
5
|
LibName: string;
|
|
4
6
|
}
|
|
5
7
|
export default function getContent(scanInfo: null, dict: Dict) {
|
|
6
|
-
return `
|
|
7
|
-
import { store } from "akanjs/store";
|
|
8
|
+
return `import { store } from "akanjs/store";
|
|
8
9
|
|
|
9
|
-
export class ${dict.LibName}Store extends store
|
|
10
|
-
// state
|
|
11
|
-
})) {
|
|
10
|
+
${BiomeForm.callArgs("", `export class ${dict.LibName}Store extends store`, [`"${dict.libName}" as const`, "() => ({\n // state\n})"], " {")}
|
|
12
11
|
// action
|
|
13
12
|
}
|
|
14
|
-
|
|
13
|
+
`;
|
|
15
14
|
}
|
|
@@ -4,8 +4,7 @@ interface Dict {
|
|
|
4
4
|
[key: string]: string;
|
|
5
5
|
}
|
|
6
6
|
export default function getContent(scanInfo: AppInfo | LibInfo | null, dict: Dict = {}) {
|
|
7
|
-
return `
|
|
8
|
-
import { AkanOption } from "akanjs/server";
|
|
7
|
+
return `import { AkanOption } from "akanjs/server";
|
|
9
8
|
|
|
10
9
|
import type { LibOptions } from "./srv";
|
|
11
10
|
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { AppInfo, LibInfo } from "akanjs";
|
|
2
|
+
import { BiomeForm } from "../biomeForm";
|
|
2
3
|
|
|
3
4
|
interface Dict {
|
|
4
5
|
Model: string;
|
|
@@ -7,12 +8,16 @@ interface Dict {
|
|
|
7
8
|
sysType: string;
|
|
8
9
|
}
|
|
9
10
|
export default function getContent(scanInfo: AppInfo | LibInfo | null, dict: Dict) {
|
|
11
|
+
const { Model, model } = dict;
|
|
12
|
+
const field = {
|
|
13
|
+
tag: "Field.Text",
|
|
14
|
+
attrs: [`label={l("${model}.name")}`, `value={${model}Form.name}`, `onChange={st.do.setNameOn${Model}}`],
|
|
15
|
+
};
|
|
10
16
|
return {
|
|
11
|
-
filename: `${
|
|
12
|
-
content: `
|
|
13
|
-
"
|
|
17
|
+
filename: `${Model}.Template.tsx`,
|
|
18
|
+
content: `"use client";
|
|
19
|
+
${BiomeForm.importFrom(["st", "usePage"], `@${dict.sysType}s/${dict.sysName}/client`)}
|
|
14
20
|
import { Field, Layout } from "akanjs/ui";
|
|
15
|
-
import { st, usePage } from "@${dict.sysType}s/${dict.sysName}/client";
|
|
16
21
|
|
|
17
22
|
interface GeneralProps {
|
|
18
23
|
className?: string;
|
|
@@ -20,14 +25,10 @@ interface GeneralProps {
|
|
|
20
25
|
|
|
21
26
|
export const General = ({ className }: GeneralProps) => {
|
|
22
27
|
const { l } = usePage();
|
|
23
|
-
const ${
|
|
28
|
+
${BiomeForm.assign(" ", `const ${model}Form`, `st.use.${model}Form`, [], ";")}
|
|
24
29
|
return (
|
|
25
30
|
<Layout.Template className={className}>
|
|
26
|
-
|
|
27
|
-
label={l("${dict.model}.name")}
|
|
28
|
-
value={${dict.model}Form.name}
|
|
29
|
-
onChange={st.do.setNameOn${dict.Model}}
|
|
30
|
-
/>
|
|
31
|
+
${BiomeForm.element(field, " ")}
|
|
31
32
|
</Layout.Template>
|
|
32
33
|
);
|
|
33
34
|
};
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { AppInfo, LibInfo } from "akanjs";
|
|
2
|
+
import { BiomeForm } from "../biomeForm";
|
|
2
3
|
|
|
3
4
|
interface Dict {
|
|
4
5
|
Model: string;
|
|
@@ -7,18 +8,30 @@ interface Dict {
|
|
|
7
8
|
sysType: string;
|
|
8
9
|
}
|
|
9
10
|
export default function getContent(scanInfo: AppInfo | LibInfo | null, dict: Dict) {
|
|
11
|
+
const { Model, model } = dict;
|
|
12
|
+
const propsType = [`"${model}"`, `cnst.Light${Model}`];
|
|
13
|
+
const flatSignature = BiomeForm.typeArgs(
|
|
14
|
+
"",
|
|
15
|
+
`export const Card = ({ ${model}, href }: ModelProps`,
|
|
16
|
+
propsType,
|
|
17
|
+
") => {",
|
|
18
|
+
);
|
|
19
|
+
const signature = flatSignature.includes("\n")
|
|
20
|
+
? `export const Card = ({\n ${model},\n href,\n${BiomeForm.typeArgs("", "}: ModelProps", propsType, ") => {")}`
|
|
21
|
+
: flatSignature;
|
|
10
22
|
return {
|
|
11
|
-
filename: `${
|
|
12
|
-
content: `
|
|
23
|
+
filename: `${Model}.Unit.tsx`,
|
|
24
|
+
content: `${BiomeForm.importFrom(["type cnst", "usePage"], `@${dict.sysType}s/${dict.sysName}/client`)}
|
|
13
25
|
import type { ModelProps } from "akanjs/client";
|
|
14
|
-
import { cnst, usePage } from "@${dict.sysType}s/${dict.sysName}/client";
|
|
15
26
|
import { Link } from "akanjs/ui";
|
|
16
27
|
|
|
17
|
-
|
|
28
|
+
${signature}
|
|
18
29
|
const { l } = usePage();
|
|
19
30
|
return (
|
|
20
31
|
<Link href={href} className="w-full">
|
|
21
|
-
<div>
|
|
32
|
+
<div>
|
|
33
|
+
${BiomeForm.jsxSpaced(" ", `{l("${model}.name")}:`, `{${model}.name}`)}
|
|
34
|
+
</div>
|
|
22
35
|
</Link>
|
|
23
36
|
);
|
|
24
37
|
};
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { AppInfo, LibInfo } from "akanjs";
|
|
2
|
+
import { BiomeForm } from "../biomeForm";
|
|
2
3
|
|
|
3
4
|
interface Dict {
|
|
4
5
|
Model: string;
|
|
@@ -7,21 +8,22 @@ interface Dict {
|
|
|
7
8
|
sysType: string;
|
|
8
9
|
}
|
|
9
10
|
export default function getContent(scanInfo: AppInfo | LibInfo | null, dict: Dict) {
|
|
11
|
+
const { Model, model } = dict;
|
|
12
|
+
const remove = { tag: "Model.Remove", attrs: [`modelId={${model}Id}`, `slice={fetch.slice.${model}}`] };
|
|
10
13
|
return {
|
|
11
|
-
filename: `${
|
|
12
|
-
content: `
|
|
13
|
-
"
|
|
14
|
+
filename: `${Model}.Util.tsx`,
|
|
15
|
+
content: `"use client";
|
|
16
|
+
${BiomeForm.importFrom(["fetch", "usePage"], `@${dict.sysType}s/${dict.sysName}/client`)}
|
|
14
17
|
import { Model } from "akanjs/ui";
|
|
15
|
-
import { fetch, usePage } from "@${dict.sysType}s/${dict.sysName}/client";
|
|
16
18
|
import { BiTrash } from "react-icons/bi";
|
|
17
19
|
|
|
18
20
|
interface RemoveProps {
|
|
19
|
-
${
|
|
21
|
+
${model}Id: string;
|
|
20
22
|
}
|
|
21
|
-
export const Remove = ({ ${
|
|
23
|
+
export const Remove = ({ ${model}Id }: RemoveProps) => {
|
|
22
24
|
const { l } = usePage();
|
|
23
25
|
return (
|
|
24
|
-
|
|
26
|
+
${BiomeForm.openingTag(remove, " ")}
|
|
25
27
|
<BiTrash /> {l("base.remove")}
|
|
26
28
|
</Model.Remove>
|
|
27
29
|
);
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { AppInfo, LibInfo } from "akanjs";
|
|
2
|
+
import { BiomeForm } from "../biomeForm";
|
|
2
3
|
|
|
3
4
|
interface Dict {
|
|
4
5
|
Model: string;
|
|
@@ -7,21 +8,23 @@ interface Dict {
|
|
|
7
8
|
sysType: string;
|
|
8
9
|
}
|
|
9
10
|
export default function getContent(scanInfo: AppInfo | LibInfo | null, dict: Dict) {
|
|
11
|
+
const { Model, model } = dict;
|
|
10
12
|
return {
|
|
11
|
-
filename: `${
|
|
12
|
-
content: `
|
|
13
|
+
filename: `${Model}.View.tsx`,
|
|
14
|
+
content: `${BiomeForm.importFrom(["type cnst", "usePage"], `@${dict.sysType}s/${dict.sysName}/client`)}
|
|
13
15
|
import { cn } from "akanjs/client";
|
|
14
|
-
import { cnst, usePage } from "@${dict.sysType}s/${dict.sysName}/client";
|
|
15
16
|
|
|
16
17
|
interface GeneralProps {
|
|
17
18
|
className?: string;
|
|
18
|
-
${
|
|
19
|
+
${model}: cnst.${Model};
|
|
19
20
|
}
|
|
20
|
-
export const General = ({ className, ${
|
|
21
|
+
export const General = ({ className, ${model} }: GeneralProps) => {
|
|
21
22
|
const { l } = usePage();
|
|
22
23
|
return (
|
|
23
24
|
<div className={cn("w-full", className)}>
|
|
24
|
-
<div>
|
|
25
|
+
<div>
|
|
26
|
+
${BiomeForm.jsxSpaced(" ", `{l("${model}.name")}:`, `{${model}.name}`)}
|
|
27
|
+
</div>
|
|
25
28
|
</div>
|
|
26
29
|
);
|
|
27
30
|
};
|