@jskit-ai/crud-ui-generator 0.1.2 → 0.1.4
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/package.descriptor.mjs +54 -25
- package/package.json +5 -1
- package/src/server/buildTemplateContext.js +157 -349
- package/src/server/resourceSupport.js +846 -0
- package/src/server/subcommands/addField.js +313 -0
- package/templates/src/pages/admin/ui-generator/EditElement.vue +26 -32
- package/templates/src/pages/admin/ui-generator/ListElement.vue +36 -10
- package/templates/src/pages/admin/ui-generator/NewElement.vue +26 -32
- package/templates/src/pages/admin/ui-generator/ViewElement.vue +4 -3
- package/test/addFieldSubcommand.test.js +194 -0
- package/test/buildTemplateContext.test.js +808 -32
package/package.descriptor.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export default Object.freeze({
|
|
2
2
|
packageVersion: 1,
|
|
3
3
|
packageId: "@jskit-ai/crud-ui-generator",
|
|
4
|
-
version: "0.1.
|
|
4
|
+
version: "0.1.4",
|
|
5
5
|
kind: "generator",
|
|
6
6
|
description: "Generate app-local CRUD UI scaffolds from resource validators.",
|
|
7
7
|
options: {
|
|
@@ -15,9 +15,8 @@ export default Object.freeze({
|
|
|
15
15
|
surface: {
|
|
16
16
|
required: true,
|
|
17
17
|
inputType: "text",
|
|
18
|
-
defaultFromConfig: "surfaceDefaultId",
|
|
19
18
|
promptLabel: "Target surface",
|
|
20
|
-
promptHint: "
|
|
19
|
+
promptHint: "Must match an enabled surface id."
|
|
21
20
|
},
|
|
22
21
|
"resource-file": {
|
|
23
22
|
required: true,
|
|
@@ -26,13 +25,6 @@ export default Object.freeze({
|
|
|
26
25
|
promptLabel: "Resource file",
|
|
27
26
|
promptHint: "Relative path from app root to the resource module."
|
|
28
27
|
},
|
|
29
|
-
"resource-export": {
|
|
30
|
-
required: false,
|
|
31
|
-
inputType: "text",
|
|
32
|
-
defaultValue: "",
|
|
33
|
-
promptLabel: "Resource export",
|
|
34
|
-
promptHint: "Named export in the resource module (defaults to resource-file basename, example: contactResource)."
|
|
35
|
-
},
|
|
36
28
|
operations: {
|
|
37
29
|
required: true,
|
|
38
30
|
inputType: "text",
|
|
@@ -48,18 +40,26 @@ export default Object.freeze({
|
|
|
48
40
|
promptHint: "Optional comma-separated field keys to render (must exist in selected operation schemas)."
|
|
49
41
|
},
|
|
50
42
|
"api-path": {
|
|
51
|
-
required:
|
|
43
|
+
required: false,
|
|
52
44
|
inputType: "text",
|
|
53
|
-
|
|
45
|
+
defaultFromOptionTemplate: "/${option:namespace|kebab}",
|
|
54
46
|
promptLabel: "API path",
|
|
55
|
-
promptHint: "Base API path without trailing id (example: /
|
|
47
|
+
promptHint: "Base API path without trailing id (defaults to /<namespace>, example: /contacts)."
|
|
56
48
|
},
|
|
57
49
|
"route-path": {
|
|
58
|
-
required:
|
|
50
|
+
required: false,
|
|
59
51
|
inputType: "text",
|
|
60
|
-
|
|
52
|
+
defaultFromOptionTemplate: "${option:namespace|kebab}",
|
|
61
53
|
promptLabel: "Route path",
|
|
62
|
-
promptHint: "List route path under the target surface (example:
|
|
54
|
+
promptHint: "List route path under the target surface (defaults to <namespace>, example: contacts)."
|
|
55
|
+
},
|
|
56
|
+
container: {
|
|
57
|
+
required: false,
|
|
58
|
+
inputType: "text",
|
|
59
|
+
defaultValue: "",
|
|
60
|
+
promptLabel: "Container host",
|
|
61
|
+
promptHint:
|
|
62
|
+
"Optional container host slug (example: practice). Routes are generated under this prefix and list menu placement defaults to <container>:sub-pages."
|
|
63
63
|
},
|
|
64
64
|
"id-param": {
|
|
65
65
|
required: false,
|
|
@@ -74,6 +74,13 @@ export default Object.freeze({
|
|
|
74
74
|
defaultValue: "",
|
|
75
75
|
promptLabel: "Page directory prefix",
|
|
76
76
|
promptHint: "Optional subpath under the selected surface pages root (example: crm or ops/team-a)."
|
|
77
|
+
},
|
|
78
|
+
placement: {
|
|
79
|
+
required: false,
|
|
80
|
+
inputType: "text",
|
|
81
|
+
defaultValue: "",
|
|
82
|
+
promptLabel: "Menu placement",
|
|
83
|
+
promptHint: "Optional host:position target (defaults to ShellLayout default outlet)."
|
|
77
84
|
}
|
|
78
85
|
},
|
|
79
86
|
dependsOn: [],
|
|
@@ -90,6 +97,13 @@ export default Object.freeze({
|
|
|
90
97
|
}
|
|
91
98
|
},
|
|
92
99
|
metadata: {
|
|
100
|
+
generatorPrimarySubcommand: "crud",
|
|
101
|
+
generatorSubcommands: {
|
|
102
|
+
field: {
|
|
103
|
+
entrypoint: "src/server/subcommands/addField.js",
|
|
104
|
+
export: "runGeneratorSubcommand"
|
|
105
|
+
}
|
|
106
|
+
},
|
|
93
107
|
apiSummary: {
|
|
94
108
|
surfaces: [
|
|
95
109
|
{
|
|
@@ -106,7 +120,7 @@ export default Object.freeze({
|
|
|
106
120
|
mutations: {
|
|
107
121
|
dependencies: {
|
|
108
122
|
runtime: {
|
|
109
|
-
"@jskit-ai/users-web": "0.1.
|
|
123
|
+
"@jskit-ai/users-web": "0.1.35"
|
|
110
124
|
},
|
|
111
125
|
dev: {}
|
|
112
126
|
},
|
|
@@ -118,7 +132,7 @@ export default Object.freeze({
|
|
|
118
132
|
{
|
|
119
133
|
from: "templates/src/pages/admin/ui-generator/ListElement.vue",
|
|
120
134
|
toSurface: "${option:surface|lower}",
|
|
121
|
-
toSurfacePath: "${option:directory-prefix|pathprefix}${option:route-path|path}/index.vue",
|
|
135
|
+
toSurfacePath: "${option:directory-prefix|pathprefix}${option:container|pathprefix}${option:route-path|path}/index.vue",
|
|
122
136
|
reason: "Install generated list page.",
|
|
123
137
|
category: "ui-generator",
|
|
124
138
|
id: "ui-generator-page-list-${option:namespace|snake}",
|
|
@@ -134,7 +148,8 @@ export default Object.freeze({
|
|
|
134
148
|
{
|
|
135
149
|
from: "templates/src/pages/admin/ui-generator/ViewElement.vue",
|
|
136
150
|
toSurface: "${option:surface|lower}",
|
|
137
|
-
toSurfacePath:
|
|
151
|
+
toSurfacePath:
|
|
152
|
+
"${option:directory-prefix|pathprefix}${option:container|pathprefix}${option:route-path|path}/[${option:id-param|trim}]/index.vue",
|
|
138
153
|
reason: "Install generated view page.",
|
|
139
154
|
category: "ui-generator",
|
|
140
155
|
id: "ui-generator-page-view-${option:namespace|snake}",
|
|
@@ -150,7 +165,7 @@ export default Object.freeze({
|
|
|
150
165
|
{
|
|
151
166
|
from: "templates/src/pages/admin/ui-generator/NewElement.vue",
|
|
152
167
|
toSurface: "${option:surface|lower}",
|
|
153
|
-
toSurfacePath: "${option:directory-prefix|pathprefix}${option:route-path|path}/new.vue",
|
|
168
|
+
toSurfacePath: "${option:directory-prefix|pathprefix}${option:container|pathprefix}${option:route-path|path}/new.vue",
|
|
154
169
|
reason: "Install generated new page.",
|
|
155
170
|
category: "ui-generator",
|
|
156
171
|
id: "ui-generator-page-new-${option:namespace|snake}",
|
|
@@ -166,7 +181,8 @@ export default Object.freeze({
|
|
|
166
181
|
{
|
|
167
182
|
from: "templates/src/pages/admin/ui-generator/EditElement.vue",
|
|
168
183
|
toSurface: "${option:surface|lower}",
|
|
169
|
-
toSurfacePath:
|
|
184
|
+
toSurfacePath:
|
|
185
|
+
"${option:directory-prefix|pathprefix}${option:container|pathprefix}${option:route-path|path}/[${option:id-param|trim}]/edit.vue",
|
|
170
186
|
reason: "Install generated edit page.",
|
|
171
187
|
category: "ui-generator",
|
|
172
188
|
id: "ui-generator-page-edit-${option:namespace|snake}",
|
|
@@ -185,15 +201,28 @@ export default Object.freeze({
|
|
|
185
201
|
op: "append-text",
|
|
186
202
|
file: "src/placement.js",
|
|
187
203
|
position: "bottom",
|
|
188
|
-
skipIfContains:
|
|
204
|
+
skipIfContains:
|
|
205
|
+
"jskit:ui-generator.menu:${option:namespace|kebab}:${option:directory-prefix|path}:${option:container|path}:${option:route-path|path}",
|
|
189
206
|
value:
|
|
190
|
-
"\n// jskit:ui-generator.menu:${option:namespace|kebab}:${option:directory-prefix|path}:${option:route-path|path}\n{\n addPlacement({\n id: \"ui-generator.${option:namespace|kebab}.menu\",\n host: \"
|
|
207
|
+
"\n// jskit:ui-generator.menu:${option:namespace|kebab}:${option:directory-prefix|path}:${option:container|path}:${option:route-path|path}\n{\n addPlacement({\n id: \"ui-generator.${option:namespace|kebab}.menu\",\n host: \"__JSKIT_UI_MENU_PLACEMENT_HOST__\",\n position: \"__JSKIT_UI_MENU_PLACEMENT_POSITION__\",\n surfaces: [\"${option:surface|lower}\"],\n order: 155,\n componentToken: \"__JSKIT_UI_MENU_COMPONENT_TOKEN__\",\n props: {\n label: \"${option:namespace|plural|pascal}\",\n surface: \"${option:surface|lower}\",\n workspaceSuffix: \"/${option:directory-prefix|pathprefix}${option:container|pathprefix}${option:route-path|path}\",\n nonWorkspaceSuffix: \"/${option:directory-prefix|pathprefix}${option:container|pathprefix}${option:route-path|path}\"\n },\n when: ({ auth }) => Boolean(auth?.authenticated)\n });\n}\n",
|
|
191
208
|
reason: "Append generated UI menu placement.",
|
|
192
209
|
category: "ui-generator",
|
|
193
210
|
id: "ui-generator-placement-menu",
|
|
211
|
+
templateContext: {
|
|
212
|
+
entrypoint: "src/server/buildTemplateContext.js",
|
|
213
|
+
export: "buildUiTemplateContext"
|
|
214
|
+
},
|
|
194
215
|
when: {
|
|
195
|
-
|
|
196
|
-
|
|
216
|
+
all: [
|
|
217
|
+
{
|
|
218
|
+
option: "operations",
|
|
219
|
+
in: ["list"]
|
|
220
|
+
},
|
|
221
|
+
{
|
|
222
|
+
option: "route-path",
|
|
223
|
+
notContains: "["
|
|
224
|
+
}
|
|
225
|
+
]
|
|
197
226
|
}
|
|
198
227
|
}
|
|
199
228
|
]
|
package/package.json
CHANGED
|
@@ -1,10 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jskit-ai/crud-ui-generator",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.4",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"test": "node --test"
|
|
7
7
|
},
|
|
8
|
+
"dependencies": {
|
|
9
|
+
"@jskit-ai/crud-core": "0.1.29",
|
|
10
|
+
"@jskit-ai/kernel": "0.1.21"
|
|
11
|
+
},
|
|
8
12
|
"exports": {
|
|
9
13
|
"./server/buildTemplateContext": "./src/server/buildTemplateContext.js"
|
|
10
14
|
}
|