@jskit-ai/crud-server-generator 0.1.119 → 0.1.121
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
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export default Object.freeze({
|
|
2
2
|
packageVersion: 1,
|
|
3
3
|
packageId: "@jskit-ai/crud-server-generator",
|
|
4
|
-
version: "0.1.
|
|
4
|
+
version: "0.1.121",
|
|
5
5
|
kind: "generator",
|
|
6
6
|
description: "CRUD server generator with routes, actions, and persistence scaffolding.",
|
|
7
7
|
options: {
|
|
@@ -160,14 +160,14 @@ export default Object.freeze({
|
|
|
160
160
|
mutations: {
|
|
161
161
|
dependencies: {
|
|
162
162
|
runtime: {
|
|
163
|
-
"@jskit-ai/auth-core": "0.1.
|
|
164
|
-
"@jskit-ai/crud-core": "0.1.
|
|
165
|
-
"@jskit-ai/database-runtime": "0.1.
|
|
166
|
-
"@jskit-ai/http-runtime": "0.1.
|
|
167
|
-
"@jskit-ai/json-rest-api-core": "0.1.
|
|
168
|
-
"@jskit-ai/kernel": "0.1.
|
|
169
|
-
"@jskit-ai/realtime": "0.1.
|
|
170
|
-
"@jskit-ai/resource-crud-core": "0.1.
|
|
163
|
+
"@jskit-ai/auth-core": "0.1.112",
|
|
164
|
+
"@jskit-ai/crud-core": "0.1.121",
|
|
165
|
+
"@jskit-ai/database-runtime": "0.1.113",
|
|
166
|
+
"@jskit-ai/http-runtime": "0.1.112",
|
|
167
|
+
"@jskit-ai/json-rest-api-core": "0.1.58",
|
|
168
|
+
"@jskit-ai/kernel": "0.1.114",
|
|
169
|
+
"@jskit-ai/realtime": "0.1.112",
|
|
170
|
+
"@jskit-ai/resource-crud-core": "0.1.58",
|
|
171
171
|
"@local/${option:namespace|kebab}": "file:packages/${option:namespace|kebab}"
|
|
172
172
|
},
|
|
173
173
|
dev: {}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jskit-ai/crud-server-generator",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.121",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"test": "node --test"
|
|
@@ -13,12 +13,12 @@
|
|
|
13
13
|
},
|
|
14
14
|
"dependencies": {
|
|
15
15
|
"@babel/parser": "^7.29.2",
|
|
16
|
-
"@jskit-ai/crud-core": "0.1.
|
|
17
|
-
"@jskit-ai/database-runtime": "0.1.
|
|
18
|
-
"@jskit-ai/http-runtime": "0.1.
|
|
19
|
-
"@jskit-ai/json-rest-api-core": "0.1.
|
|
20
|
-
"@jskit-ai/kernel": "0.1.
|
|
21
|
-
"@jskit-ai/resource-crud-core": "0.1.
|
|
16
|
+
"@jskit-ai/crud-core": "0.1.121",
|
|
17
|
+
"@jskit-ai/database-runtime": "0.1.113",
|
|
18
|
+
"@jskit-ai/http-runtime": "0.1.112",
|
|
19
|
+
"@jskit-ai/json-rest-api-core": "0.1.58",
|
|
20
|
+
"@jskit-ai/kernel": "0.1.114",
|
|
21
|
+
"@jskit-ai/resource-crud-core": "0.1.58",
|
|
22
22
|
"recast": "^0.23.11"
|
|
23
23
|
}
|
|
24
24
|
}
|
|
@@ -86,10 +86,10 @@ function resolveInternalRouteOption(options = {}) {
|
|
|
86
86
|
if (!Object.prototype.hasOwnProperty.call(options, "internal")) {
|
|
87
87
|
return false;
|
|
88
88
|
}
|
|
89
|
-
if (options.internal ===
|
|
89
|
+
if (options.internal === undefined || options.internal === true) {
|
|
90
90
|
return true;
|
|
91
91
|
}
|
|
92
|
-
if (options.internal === false) {
|
|
92
|
+
if (options.internal === "" || options.internal == null || options.internal === false) {
|
|
93
93
|
return false;
|
|
94
94
|
}
|
|
95
95
|
return normalizeBoolean(options.internal);
|
|
@@ -1736,6 +1736,11 @@ function renderRouteParamsValidatorLine(operation = "", { surfaceRequiresWorkspa
|
|
|
1736
1736
|
return " params: recordRouteParamsValidator,";
|
|
1737
1737
|
}
|
|
1738
1738
|
|
|
1739
|
+
function renderOptionalTemplateLine(line = "") {
|
|
1740
|
+
const renderedLine = String(line || "").trimEnd();
|
|
1741
|
+
return renderedLine ? `\n${renderedLine}` : "";
|
|
1742
|
+
}
|
|
1743
|
+
|
|
1739
1744
|
function renderRouteInputLines(operation = "", { surfaceRequiresWorkspace = true } = {}) {
|
|
1740
1745
|
const normalizedOperation = normalizeCrudOperation(operation, "CRUD route input operation");
|
|
1741
1746
|
const lines = [];
|
|
@@ -1926,26 +1931,36 @@ function buildReplacementsFromSnapshot({
|
|
|
1926
1931
|
__JSKIT_CRUD_ROUTE_WORKSPACE_SUPPORT_IMPORTS__: renderRouteWorkspaceSupportImports({
|
|
1927
1932
|
surfaceRequiresWorkspace
|
|
1928
1933
|
}),
|
|
1929
|
-
__JSKIT_CRUD_ROUTE_INTERNAL_LINE__: routeInternal === true ? " internal: true," : "",
|
|
1934
|
+
__JSKIT_CRUD_ROUTE_INTERNAL_LINE__: routeInternal === true ? "\n internal: true," : "",
|
|
1930
1935
|
__JSKIT_CRUD_ROUTE_CONTRACTS_RESOURCE_ARGS__: surfaceRequiresWorkspace ? ",\n routeParamsValidator" : "",
|
|
1931
1936
|
__JSKIT_CRUD_ROUTE_VALIDATOR_CONSTANTS__: renderRouteValidatorConstants({
|
|
1932
1937
|
surfaceRequiresWorkspace
|
|
1933
1938
|
}),
|
|
1934
|
-
__JSKIT_CRUD_LIST_ROUTE_PARAMS_VALIDATOR_LINE__:
|
|
1935
|
-
|
|
1936
|
-
|
|
1937
|
-
|
|
1938
|
-
|
|
1939
|
-
|
|
1940
|
-
|
|
1941
|
-
|
|
1942
|
-
|
|
1943
|
-
|
|
1944
|
-
|
|
1945
|
-
|
|
1946
|
-
|
|
1947
|
-
|
|
1948
|
-
|
|
1939
|
+
__JSKIT_CRUD_LIST_ROUTE_PARAMS_VALIDATOR_LINE__: renderOptionalTemplateLine(
|
|
1940
|
+
renderRouteParamsValidatorLine("list", {
|
|
1941
|
+
surfaceRequiresWorkspace
|
|
1942
|
+
})
|
|
1943
|
+
),
|
|
1944
|
+
__JSKIT_CRUD_VIEW_ROUTE_PARAMS_VALIDATOR_LINE__: renderOptionalTemplateLine(
|
|
1945
|
+
renderRouteParamsValidatorLine("view", {
|
|
1946
|
+
surfaceRequiresWorkspace
|
|
1947
|
+
})
|
|
1948
|
+
),
|
|
1949
|
+
__JSKIT_CRUD_CREATE_ROUTE_PARAMS_VALIDATOR_LINE__: renderOptionalTemplateLine(
|
|
1950
|
+
renderRouteParamsValidatorLine("create", {
|
|
1951
|
+
surfaceRequiresWorkspace
|
|
1952
|
+
})
|
|
1953
|
+
),
|
|
1954
|
+
__JSKIT_CRUD_UPDATE_ROUTE_PARAMS_VALIDATOR_LINE__: renderOptionalTemplateLine(
|
|
1955
|
+
renderRouteParamsValidatorLine("update", {
|
|
1956
|
+
surfaceRequiresWorkspace
|
|
1957
|
+
})
|
|
1958
|
+
),
|
|
1959
|
+
__JSKIT_CRUD_DELETE_ROUTE_PARAMS_VALIDATOR_LINE__: renderOptionalTemplateLine(
|
|
1960
|
+
renderRouteParamsValidatorLine("delete", {
|
|
1961
|
+
surfaceRequiresWorkspace
|
|
1962
|
+
})
|
|
1963
|
+
),
|
|
1949
1964
|
__JSKIT_CRUD_LIST_ROUTE_INPUT_LINES__: renderRouteInputLines("list", {
|
|
1950
1965
|
surfaceRequiresWorkspace
|
|
1951
1966
|
}),
|
|
@@ -37,15 +37,13 @@ function registerRoutes(
|
|
|
37
37
|
routeBase,
|
|
38
38
|
{
|
|
39
39
|
auth: "required",
|
|
40
|
-
surface: normalizedRouteSurface,
|
|
41
|
-
__JSKIT_CRUD_ROUTE_INTERNAL_LINE__
|
|
40
|
+
surface: normalizedRouteSurface,__JSKIT_CRUD_ROUTE_INTERNAL_LINE__
|
|
42
41
|
visibility: checkRouteVisibility(routeOwnershipFilter),
|
|
43
42
|
meta: {
|
|
44
43
|
tags: ["crud"],
|
|
45
44
|
summary: "List records."
|
|
46
45
|
},
|
|
47
|
-
...listRouteContract,
|
|
48
|
-
__JSKIT_CRUD_LIST_ROUTE_PARAMS_VALIDATOR_LINE__
|
|
46
|
+
...listRouteContract,__JSKIT_CRUD_LIST_ROUTE_PARAMS_VALIDATOR_LINE__
|
|
49
47
|
},
|
|
50
48
|
async function (request, reply) {
|
|
51
49
|
const listInput = {
|
|
@@ -64,15 +62,13 @@ __JSKIT_CRUD_LIST_ROUTE_INPUT_LINES__
|
|
|
64
62
|
`${routeBase}/:recordId`,
|
|
65
63
|
{
|
|
66
64
|
auth: "required",
|
|
67
|
-
surface: normalizedRouteSurface,
|
|
68
|
-
__JSKIT_CRUD_ROUTE_INTERNAL_LINE__
|
|
65
|
+
surface: normalizedRouteSurface,__JSKIT_CRUD_ROUTE_INTERNAL_LINE__
|
|
69
66
|
visibility: checkRouteVisibility(routeOwnershipFilter),
|
|
70
67
|
meta: {
|
|
71
68
|
tags: ["crud"],
|
|
72
69
|
summary: "View a record."
|
|
73
70
|
},
|
|
74
|
-
...viewRouteContract,
|
|
75
|
-
__JSKIT_CRUD_VIEW_ROUTE_PARAMS_VALIDATOR_LINE__
|
|
71
|
+
...viewRouteContract,__JSKIT_CRUD_VIEW_ROUTE_PARAMS_VALIDATOR_LINE__
|
|
76
72
|
},
|
|
77
73
|
async function (request, reply) {
|
|
78
74
|
const response = await request.executeAction({
|
|
@@ -90,15 +86,13 @@ __JSKIT_CRUD_VIEW_ROUTE_INPUT_LINES__
|
|
|
90
86
|
routeBase,
|
|
91
87
|
{
|
|
92
88
|
auth: "required",
|
|
93
|
-
surface: normalizedRouteSurface,
|
|
94
|
-
__JSKIT_CRUD_ROUTE_INTERNAL_LINE__
|
|
89
|
+
surface: normalizedRouteSurface,__JSKIT_CRUD_ROUTE_INTERNAL_LINE__
|
|
95
90
|
visibility: checkRouteVisibility(routeOwnershipFilter),
|
|
96
91
|
meta: {
|
|
97
92
|
tags: ["crud"],
|
|
98
93
|
summary: "Create a record."
|
|
99
94
|
},
|
|
100
|
-
...createRouteContract,
|
|
101
|
-
__JSKIT_CRUD_CREATE_ROUTE_PARAMS_VALIDATOR_LINE__
|
|
95
|
+
...createRouteContract,__JSKIT_CRUD_CREATE_ROUTE_PARAMS_VALIDATOR_LINE__
|
|
102
96
|
},
|
|
103
97
|
async function (request, reply) {
|
|
104
98
|
const response = await request.executeAction({
|
|
@@ -116,15 +110,13 @@ __JSKIT_CRUD_CREATE_ROUTE_INPUT_LINES__
|
|
|
116
110
|
`${routeBase}/:recordId`,
|
|
117
111
|
{
|
|
118
112
|
auth: "required",
|
|
119
|
-
surface: normalizedRouteSurface,
|
|
120
|
-
__JSKIT_CRUD_ROUTE_INTERNAL_LINE__
|
|
113
|
+
surface: normalizedRouteSurface,__JSKIT_CRUD_ROUTE_INTERNAL_LINE__
|
|
121
114
|
visibility: checkRouteVisibility(routeOwnershipFilter),
|
|
122
115
|
meta: {
|
|
123
116
|
tags: ["crud"],
|
|
124
117
|
summary: "Update a record."
|
|
125
118
|
},
|
|
126
|
-
...updateRouteContract,
|
|
127
|
-
__JSKIT_CRUD_UPDATE_ROUTE_PARAMS_VALIDATOR_LINE__
|
|
119
|
+
...updateRouteContract,__JSKIT_CRUD_UPDATE_ROUTE_PARAMS_VALIDATOR_LINE__
|
|
128
120
|
},
|
|
129
121
|
async function (request, reply) {
|
|
130
122
|
const response = await request.executeAction({
|
|
@@ -142,15 +134,13 @@ __JSKIT_CRUD_UPDATE_ROUTE_INPUT_LINES__
|
|
|
142
134
|
`${routeBase}/:recordId`,
|
|
143
135
|
{
|
|
144
136
|
auth: "required",
|
|
145
|
-
surface: normalizedRouteSurface,
|
|
146
|
-
__JSKIT_CRUD_ROUTE_INTERNAL_LINE__
|
|
137
|
+
surface: normalizedRouteSurface,__JSKIT_CRUD_ROUTE_INTERNAL_LINE__
|
|
147
138
|
visibility: checkRouteVisibility(routeOwnershipFilter),
|
|
148
139
|
meta: {
|
|
149
140
|
tags: ["crud"],
|
|
150
141
|
summary: "Delete a record."
|
|
151
142
|
},
|
|
152
|
-
...deleteRouteContract,
|
|
153
|
-
__JSKIT_CRUD_DELETE_ROUTE_PARAMS_VALIDATOR_LINE__
|
|
143
|
+
...deleteRouteContract,__JSKIT_CRUD_DELETE_ROUTE_PARAMS_VALIDATOR_LINE__
|
|
154
144
|
},
|
|
155
145
|
async function (request, reply) {
|
|
156
146
|
const response = await request.executeAction({
|
|
@@ -256,7 +256,8 @@ test("buildReplacementsFromSnapshot renders an internal route line only when req
|
|
|
256
256
|
});
|
|
257
257
|
|
|
258
258
|
assert.equal(publicReplacements.__JSKIT_CRUD_ROUTE_INTERNAL_LINE__, "");
|
|
259
|
-
assert.equal(internalReplacements.__JSKIT_CRUD_ROUTE_INTERNAL_LINE__, " internal: true,");
|
|
259
|
+
assert.equal(internalReplacements.__JSKIT_CRUD_ROUTE_INTERNAL_LINE__, "\n internal: true,");
|
|
260
|
+
assert.equal(publicReplacements.__JSKIT_CRUD_LIST_ROUTE_PARAMS_VALIDATOR_LINE__, "\n params: routeParamsValidator,");
|
|
260
261
|
});
|
|
261
262
|
|
|
262
263
|
test("resolveInternalRouteOption rejects invalid internal flag values instead of silently generating public routes", () => {
|
|
@@ -266,8 +267,12 @@ test("resolveInternalRouteOption rejects invalid internal flag values instead of
|
|
|
266
267
|
);
|
|
267
268
|
});
|
|
268
269
|
|
|
269
|
-
test("resolveInternalRouteOption
|
|
270
|
-
assert.equal(__testables.resolveInternalRouteOption({
|
|
270
|
+
test("resolveInternalRouteOption does not confuse descriptor defaults with explicit internal flags", () => {
|
|
271
|
+
assert.equal(__testables.resolveInternalRouteOption({}), false);
|
|
272
|
+
assert.equal(__testables.resolveInternalRouteOption({ internal: "" }), false);
|
|
273
|
+
assert.equal(__testables.resolveInternalRouteOption({ internal: false }), false);
|
|
274
|
+
assert.equal(__testables.resolveInternalRouteOption({ internal: undefined }), true);
|
|
275
|
+
assert.equal(__testables.resolveInternalRouteOption({ internal: true }), true);
|
|
271
276
|
assert.equal(__testables.resolveInternalRouteOption({ internal: "true" }), true);
|
|
272
277
|
assert.equal(__testables.resolveInternalRouteOption({ internal: "false" }), false);
|
|
273
278
|
});
|
|
@@ -326,7 +331,7 @@ test("buildReplacementsFromSnapshot builds deterministic template replacement pa
|
|
|
326
331
|
assert.match(replacements.__JSKIT_CRUD_LIST_ACTION_INPUT__, /workspaceSlugParamsValidator,/);
|
|
327
332
|
assert.equal(
|
|
328
333
|
replacements.__JSKIT_CRUD_VIEW_ROUTE_PARAMS_VALIDATOR_LINE__,
|
|
329
|
-
" params: recordRouteParamsValidator,"
|
|
334
|
+
"\n params: recordRouteParamsValidator,"
|
|
330
335
|
);
|
|
331
336
|
assert.match(
|
|
332
337
|
replacements.__JSKIT_CRUD_ROUTE_VALIDATOR_CONSTANTS__,
|
|
@@ -402,7 +407,7 @@ test("buildReplacementsFromSnapshot omits named permissions and role grants when
|
|
|
402
407
|
assert.equal(replacements.__JSKIT_CRUD_LIST_ROUTE_PARAMS_VALIDATOR_LINE__, "");
|
|
403
408
|
assert.equal(
|
|
404
409
|
replacements.__JSKIT_CRUD_VIEW_ROUTE_PARAMS_VALIDATOR_LINE__,
|
|
405
|
-
" params: recordRouteParamsValidator,"
|
|
410
|
+
"\n params: recordRouteParamsValidator,"
|
|
406
411
|
);
|
|
407
412
|
assert.equal(
|
|
408
413
|
replacements.__JSKIT_CRUD_VIEW_ROUTE_INPUT_LINES__,
|
|
@@ -1057,6 +1062,9 @@ test("crud actions and routes templates derive cursor validation and route contr
|
|
|
1057
1062
|
assert.match(registerRoutesTemplateSource, /createCrudJsonApiRouteContracts/);
|
|
1058
1063
|
assert.match(registerRoutesTemplateSource, /const \{\s+listRouteContract,\s+viewRouteContract,\s+createRouteContract,\s+updateRouteContract,\s+deleteRouteContract,\s+recordRouteParamsValidator\s+\} = createCrudJsonApiRouteContracts\(\{/s);
|
|
1059
1064
|
assert.match(registerRoutesTemplateSource, /resource__JSKIT_CRUD_ROUTE_CONTRACTS_RESOURCE_ARGS__/);
|
|
1065
|
+
assert.match(registerRoutesTemplateSource, /surface: normalizedRouteSurface,__JSKIT_CRUD_ROUTE_INTERNAL_LINE__\n visibility:/);
|
|
1066
|
+
assert.match(registerRoutesTemplateSource, /\.\.\.listRouteContract,__JSKIT_CRUD_LIST_ROUTE_PARAMS_VALIDATOR_LINE__\n \},/);
|
|
1067
|
+
assert.doesNotMatch(registerRoutesTemplateSource, /surface: normalizedRouteSurface,\n__JSKIT_CRUD_ROUTE_INTERNAL_LINE__/);
|
|
1060
1068
|
assert.doesNotMatch(registerRoutesTemplateSource, /wrapResponse/);
|
|
1061
1069
|
assert.match(registerRoutesTemplateSource, /reply\.code\(204\)\.send\(response\);/);
|
|
1062
1070
|
assert.doesNotMatch(registerRoutesTemplateSource, /withStandardErrorResponses/);
|