@sealcode/sealgen 0.4.2 → 0.5.0
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/@types/forms/controls/checkboxed-list-input.d.ts +2 -2
- package/@types/forms/controls/dropdown.d.ts +2 -2
- package/@types/forms/controls/editable-collection-subset.d.ts +2 -2
- package/@types/forms/controls/form-control.d.ts +2 -2
- package/@types/forms/controls/form-field-control.d.ts +2 -2
- package/@types/forms/controls/form-header.d.ts +4 -4
- package/@types/forms/controls/simple-input.d.ts +4 -2
- package/@types/forms/fields/checkboxed-list.d.ts +7 -7
- package/@types/forms/fields/collection-field.d.ts +3 -3
- package/@types/forms/fields/field.d.ts +6 -6
- package/@types/forms/fields/number.d.ts +3 -3
- package/@types/forms/fields/pick-from-list.d.ts +7 -7
- package/@types/forms/fields/simple-form-field.d.ts +2 -2
- package/@types/forms/form.d.ts +9 -9
- package/@types/index.d.ts +2 -2
- package/@types/make-hidden-inputs.d.ts +4 -3
- package/@types/page/access-control.d.ts +2 -2
- package/@types/page/list.d.ts +14 -14
- package/@types/page/mountable.d.ts +8 -8
- package/@types/page/page.d.ts +5 -5
- package/@types/page/props-parser.d.ts +4 -4
- package/@types/utils/translate.d.ts +2 -2
- package/@types/utils/url-with-new-params.d.ts +2 -2
- package/lib/forms/controls/checkboxed-list-input.js.map +1 -1
- package/lib/forms/controls/dropdown.js.map +1 -1
- package/lib/forms/controls/editable-collection-subset.js.map +1 -1
- package/lib/forms/controls/form-header.js.map +1 -1
- package/lib/forms/controls/simple-input.js +3 -1
- package/lib/forms/controls/simple-input.js.map +1 -1
- package/lib/forms/fields/checkboxed-list.js.map +1 -1
- package/lib/forms/fields/collection-field.js.map +1 -1
- package/lib/forms/fields/field.js.map +1 -1
- package/lib/forms/fields/number.js.map +1 -1
- package/lib/forms/fields/pick-from-list.js.map +1 -1
- package/lib/forms/fields/simple-form-field.js.map +1 -1
- package/lib/forms/form.js.map +1 -1
- package/lib/generate-routes.js +2 -2
- package/lib/index.js +15 -2
- package/lib/index.js.map +1 -1
- package/lib/make-hidden-inputs.js.map +1 -1
- package/lib/page/access-control.js.map +1 -1
- package/lib/page/list.js.map +1 -1
- package/lib/page/mountable.js.map +1 -1
- package/lib/page/page.js.map +1 -1
- package/lib/page/props-parser.js.map +1 -1
- package/lib/templates/form.js +9 -16
- package/lib/templates/form.js.map +1 -1
- package/lib/templates/list.js +4 -4
- package/lib/templates/list.js.map +1 -1
- package/lib/templates/page.js +3 -3
- package/lib/utils/translate.js.map +1 -1
- package/lib/utils/url-with-new-params.js.map +1 -1
- package/package.json +1 -1
- package/src/forms/controls/checkboxed-list-input.ts +2 -2
- package/src/forms/controls/dropdown.ts +2 -2
- package/src/forms/controls/editable-collection-subset.ts +2 -2
- package/src/forms/controls/form-control.ts +2 -2
- package/src/forms/controls/form-field-control.ts +2 -2
- package/src/forms/controls/form-header.ts +3 -3
- package/src/forms/controls/simple-input.ts +6 -5
- package/src/forms/fields/checkboxed-list.ts +5 -5
- package/src/forms/fields/collection-field.ts +3 -3
- package/src/forms/fields/field.ts +6 -6
- package/src/forms/fields/number.ts +3 -3
- package/src/forms/fields/pick-from-list.ts +5 -5
- package/src/forms/fields/simple-form-field.ts +2 -2
- package/src/forms/form.ts +9 -9
- package/src/generate-routes.ts +2 -2
- package/src/index.ts +2 -2
- package/src/make-hidden-inputs.ts +4 -3
- package/src/page/access-control.ts +2 -2
- package/src/page/list.ts +14 -23
- package/src/page/mountable.ts +9 -9
- package/src/page/page.ts +5 -5
- package/src/page/props-parser.ts +4 -7
- package/src/templates/form.ts +9 -16
- package/src/templates/list.ts +4 -4
- package/src/templates/page.ts +3 -3
- package/src/utils/translate.ts +2 -2
- package/src/utils/url-with-new-params.ts +2 -2
package/lib/generate-routes.js
CHANGED
|
@@ -35,7 +35,7 @@ async function generateRoutes() {
|
|
|
35
35
|
})));
|
|
36
36
|
await fs_1.promises.writeFile(target_locreq.resolve("src/back/routes/routes.ts"), `// DO NOT EDIT! This file is generated automaticaly with npm run generate-routes
|
|
37
37
|
|
|
38
|
-
import Koa, {
|
|
38
|
+
import Koa, { Context } from "koa";
|
|
39
39
|
import Router from "@koa/router";
|
|
40
40
|
import { Middlewares } from "sealious";
|
|
41
41
|
import { Mountable } from "@sealcode/sealgen";
|
|
@@ -48,7 +48,7 @@ ${files
|
|
|
48
48
|
.map(({ actionName, url }) => `export const ${actionName}URL = "${url}";`)
|
|
49
49
|
.join("\n")}
|
|
50
50
|
|
|
51
|
-
async function handleHtmlPromise(ctx:
|
|
51
|
+
async function handleHtmlPromise(ctx: Context, next: Koa.Next) {
|
|
52
52
|
await next();
|
|
53
53
|
if (ctx.body instanceof Promise) {
|
|
54
54
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
package/lib/index.js
CHANGED
|
@@ -6,12 +6,25 @@ var __createBinding = (this && this.__createBinding) || (Object.create ? (functi
|
|
|
6
6
|
if (k2 === undefined) k2 = k;
|
|
7
7
|
o[k2] = m[k];
|
|
8
8
|
}));
|
|
9
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
10
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
11
|
+
}) : function(o, v) {
|
|
12
|
+
o["default"] = v;
|
|
13
|
+
});
|
|
14
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
15
|
+
if (mod && mod.__esModule) return mod;
|
|
16
|
+
var result = {};
|
|
17
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
18
|
+
__setModuleDefault(result, mod);
|
|
19
|
+
return result;
|
|
20
|
+
};
|
|
9
21
|
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
10
22
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
11
23
|
};
|
|
12
24
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
-
|
|
14
|
-
|
|
25
|
+
exports.Fields = exports.Controls = void 0;
|
|
26
|
+
exports.Controls = __importStar(require("./forms/controls/controls"));
|
|
27
|
+
exports.Fields = __importStar(require("./forms/fields/field"));
|
|
15
28
|
__exportStar(require("./page/mountable"), exports);
|
|
16
29
|
__exportStar(require("./page/page"), exports);
|
|
17
30
|
__exportStar(require("./forms/form"), exports);
|
package/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAWA,sEAAsD;AACtD,+DAA+C;AAC/C,mDAAiC;AACjC,8CAA4B;AAC5B,+CAA6B;AAC7B,sDAAoC;AACpC,gDAA8B;AAC9B,8CAA4B;AAC5B,oDAAkC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"make-hidden-inputs.js","sourceRoot":"","sources":["../src/make-hidden-inputs.ts"],"names":[],"mappings":";;;AACA,2CAAyD;
|
|
1
|
+
{"version":3,"file":"make-hidden-inputs.js","sourceRoot":"","sources":["../src/make-hidden-inputs.ts"],"names":[],"mappings":";;;AACA,2CAAyD;AAIzD,SAAgB,gBAAgB,CAC/B,GAAY,EACZ,MAAiC,EACjC,MAAqC,EACrC,cAAwB;IAExB,OAAO,uBAAU,CAAA,GAAG,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC;SACxC,MAAM,CAAC,CAAC,CAAC,GAAG,CAAC,EAAE,EAAE,CAAC,CAAC,cAAc,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC;SAChD,GAAG,CACH,CAAC,CAAC,GAAG,EAAE,KAAK,CAAC,EAAE,EAAE,CAAC,uBAAU,CAAA,UAAU,CAAC;;YAE9B,GAAG;aACF,KAAK;SACZ,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;SACrB,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;MAClC,CACH,EAAE,CAAC;AACN,CAAC;AAjBD,4CAiBC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"access-control.js","sourceRoot":"","sources":["../../src/page/access-control.ts"],"names":[],"mappings":";;;AAGA,SAAgB,YAAY,CAAC,MAAkB,EAAE,UAAsB;IACtE,OAAO,KAAK,WAAW,
|
|
1
|
+
{"version":3,"file":"access-control.js","sourceRoot":"","sources":["../../src/page/access-control.ts"],"names":[],"mappings":";;;AAGA,SAAgB,YAAY,CAAC,MAAkB,EAAE,UAAsB;IACtE,OAAO,KAAK,WAAW,GAAY;QAClC,MAAM,MAAM,GAAG,UAAU,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;QAC5C,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;QAChD,IAAI,CAAC,MAAM,EAAE;YACZ,GAAG,CAAC,MAAM,GAAG,GAAG,CAAC;YACjB,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,OAAO,EAAE,aAAa,EAAE,CAAC;SACpD;QACD,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE;YACpB,GAAG,CAAC,MAAM,GAAG,GAAG,CAAC;YACjB,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,CAAC;SACpD;QACD,OAAO,EAAE,SAAS,EAAE,IAAI,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC;IACzC,CAAC,CAAC;AACH,CAAC;AAdD,oCAcC"}
|
package/lib/page/list.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"list.js","sourceRoot":"","sources":["../../src/page/list.ts"],"names":[],"mappings":";;;AAGA,2CAAsE;AACtE,qDAAgD;AAChD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CAAC,SAAS,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;QACjC,MAAM,EAAE,KAAK,EAAE,GAAG,MAAM,KAAK,CAAC,KAAK,EAAE,CAAC;QACtC,OAAO,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,GAAG,YAAY,CAAC,CAAC;IAC/C,CAAC;IAES,KAAK,CAAC,SAAS,CAAC,GAAY,EAAE,IAAiB;QACxD,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,eAAe,CAAC,GAAG,CAAC,CAAC;QAChD,IAAI,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,MAAM,EAAE;YAChC,IAAI,CAAC,MAAM,CAAC,OAAiC,CAAC,CAAC;SAC/C;IACF,CAAC;IAED,KAAK,CAAC,QAAQ,CACb,GAAY,EACZ,IAAY,EACZ,YAAoB;QAEpB,MAAM,KAAK,GAAG,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;QACjD,MAAM,IAAI,CAAC,SAAS,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;QACjC,MAAM,EAAE,KAAK,EAAE,GAAG,MAAM,KAAK;aAC3B,QAAQ,CAAC,EAAE,KAAK,EAAE,YAAY,EAAE,IAAI,EAAE,CAAC;aACvC,KAAK,EAAE,CAAC;QACV,OAAO,KAAK,CAAC;IACd,CAAC;IAED,KAAK,CAAC,UAAU,CACf,CAAU,EACV,IAAuB;QAEvB,OAAO,QAAQ,IAAI,CAAC,EAAE,QAAQ,CAAC;IAChC,CAAC;CAGD;AA3CD,oDA2CC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mountable.js","sourceRoot":"","sources":["../../src/page/mountable.ts"],"names":[],"mappings":";;;AAGA,
|
|
1
|
+
{"version":3,"file":"mountable.js","sourceRoot":"","sources":["../../src/page/mountable.ts"],"names":[],"mappings":";;;AAGA,2CAAyD;AAQzD,MAAsB,SAAS;IAG9B;QACC,IAAI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AM,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;QACnC,CAAC,CAAC,CAAC;IACJ,CAAC;IAED,6DAA6D;IAC7D,KAAK,CAAC,SAAS,CAAC,
|
|
1
|
+
{"version":3,"file":"page.js","sourceRoot":"","sources":["../../src/page/page.ts"],"names":[],"mappings":";;;AAGA,2CAAsE;AACtE,0BAAoC;AAEpC,2CAAkE;AAGlE,MAAsB,IAEpB,SAAQ,qBAAY;IAFtB;;QAGC,gBAAW,GACV,IAAI,kBAAc,EAAE,CAAC;QACtB,aAAQ,GAAG,EAAE,CAAC;IAyBf,CAAC;IAvBA,KAAK,CAAC,MAAc,EAAE,IAAY;QACjC,MAAM,CAAC,GAAG,CAAC,IAAI,EAAE,KAAK,EAAE,GAAG,EAAE,EAAE;YAC9B,GAAG,CAAC,IAAI,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;QACnC,CAAC,CAAC,CAAC;IACJ,CAAC;IAED,6DAA6D;IAC7D,KAAK,CAAC,SAAS,CAAC,CAAU;QACzB,OAAO,EAAE,SAAS,EAAE,IAAI,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC;IACzC,CAAC;IAED,KAAK,CAAC,WAAW,CAChB,CAAU,EACV,KAAuB;QAEvB,OAAO,uBAAU,CAAA,UAAU,CAAC,QAAQ,KAAK,CAAC,OAAO,QAAQ,CAAC;IAC3D,CAAC;IAID,gBAAgB,CAAC,GAAY;QAC5B,OAAO,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;IACrC,CAAC;CACD;AA9BD,oBA8BC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"props-parser.js","sourceRoot":"","sources":["../../src/page/props-parser.ts"],"names":[],"mappings":";;;;;;AACA,kDAA0B;AAM1B,+EAA+E;AAC/E,8EAA8E;AAC9E,qDAAqD;AAErD,MAAsB,eAAe;IAKpC,aAAa,
|
|
1
|
+
{"version":3,"file":"props-parser.js","sourceRoot":"","sources":["../../src/page/props-parser.ts"],"names":[],"mappings":";;;;;;AACA,kDAA0B;AAM1B,+EAA+E;AAC/E,8EAA8E;AAC9E,qDAAqD;AAErD,MAAsB,eAAe;IAKpC,aAAa,CAAC,GAAY,EAAE,SAA6B;QACxD,MAAM,MAAM,GAAG,EAAE,CAAC;QAClB,eAAK,CAAC,SAAS,CAAC,MAAM,EAAE,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE,SAAS,CAAC,CAAC;QACrD,OAAO,MAAM,CAAC;IACf,CAAC;CACD;AAVD,0CAUC;AAED,MAAa,cAEX,SAAQ,eAA0B;IACnC,MAAM,CAAC,GAAY;QAClB,OAAO,GAAG,CAAC,KAAK,CAAC;IAClB,CAAC;IAED,MAAM,CAAC,KAAgB;QACtB,OAAO,KAAK,CAAC;IACd,CAAC;IAED,gBAAgB,CAAC,SAAiB;QACjC,OAAO,SAAS,CAAC;IAClB,CAAC;CACD;AAdD,wCAcC"}
|
package/lib/templates/form.js
CHANGED
|
@@ -4,23 +4,16 @@ exports.formTemplate = void 0;
|
|
|
4
4
|
const import_path_1 = require("../utils/import-path");
|
|
5
5
|
async function formTemplate(action_name, newfilefullpath) {
|
|
6
6
|
const rel = import_path_1.curryImportPath(newfilefullpath);
|
|
7
|
-
return `import {
|
|
8
|
-
import {
|
|
9
|
-
CollectionField,
|
|
10
|
-
Form,
|
|
11
|
-
FormData,
|
|
12
|
-
FormDataValue,
|
|
13
|
-
SimpleFormField,
|
|
14
|
-
SimpleInput,
|
|
15
|
-
} from "@sealcode/sealgen";
|
|
7
|
+
return `import { Context } from "koa";
|
|
8
|
+
import { Form, FormData, FormDataValue, Fields, Controls } from "@sealcode/sealgen";
|
|
16
9
|
import html from "../html";
|
|
17
10
|
import { Users } from "${rel("src/back/collections/collections")}";
|
|
18
11
|
|
|
19
12
|
export const actionName = "${action_name}";
|
|
20
13
|
|
|
21
14
|
const fields = {
|
|
22
|
-
email: new CollectionField(true, Users.fields.email),
|
|
23
|
-
password: new SimpleFormField(true),
|
|
15
|
+
email: new Fields.CollectionField(true, Users.fields.email),
|
|
16
|
+
password: new Fields.SimpleFormField(true),
|
|
24
17
|
};
|
|
25
18
|
|
|
26
19
|
export default new (class ${action_name}Form extends Form<typeof fields> {
|
|
@@ -28,12 +21,12 @@ export default new (class ${action_name}Form extends Form<typeof fields> {
|
|
|
28
21
|
fields = fields;
|
|
29
22
|
|
|
30
23
|
controls = [
|
|
31
|
-
new SimpleInput(fields.email, { label: "Email:", type: "email" }),
|
|
32
|
-
new SimpleInput(fields.password, { label: "Password:", type: "password" }),
|
|
24
|
+
new Controls.SimpleInput(fields.email, { label: "Email:", type: "email" }),
|
|
25
|
+
new Controls.SimpleInput(fields.password, { label: "Password:", type: "password" }),
|
|
33
26
|
];
|
|
34
27
|
|
|
35
28
|
async validateValues(
|
|
36
|
-
ctx:
|
|
29
|
+
ctx: Context,
|
|
37
30
|
data: Record<string, FormDataValue>
|
|
38
31
|
): Promise<{ valid: boolean; error: string }> {
|
|
39
32
|
// just an example
|
|
@@ -47,7 +40,7 @@ export default new (class ${action_name}Form extends Form<typeof fields> {
|
|
|
47
40
|
}
|
|
48
41
|
|
|
49
42
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
50
|
-
async canAccess(_:
|
|
43
|
+
async canAccess(_: Context) {
|
|
51
44
|
return { canAccess: true, message: "" };
|
|
52
45
|
}
|
|
53
46
|
|
|
@@ -56,7 +49,7 @@ export default new (class ${action_name}Form extends Form<typeof fields> {
|
|
|
56
49
|
return;
|
|
57
50
|
}
|
|
58
51
|
|
|
59
|
-
async render(ctx:
|
|
52
|
+
async render(ctx: Context, data: FormData) {
|
|
60
53
|
return html(ctx, "${action_name}", await super.render(ctx, data));
|
|
61
54
|
}
|
|
62
55
|
})();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"form.js","sourceRoot":"","sources":["../../src/templates/form.ts"],"names":[],"mappings":";;;AAAA,sDAAuD;AAEhD,KAAK,UAAU,YAAY,CACjC,WAAmB,EACnB,eAAuB;IAEvB,MAAM,GAAG,GAAG,6BAAe,CAAC,eAAe,CAAC,CAAC;IAC7C,OAAO
|
|
1
|
+
{"version":3,"file":"form.js","sourceRoot":"","sources":["../../src/templates/form.ts"],"names":[],"mappings":";;;AAAA,sDAAuD;AAEhD,KAAK,UAAU,YAAY,CACjC,WAAmB,EACnB,eAAuB;IAEvB,MAAM,GAAG,GAAG,6BAAe,CAAC,eAAe,CAAC,CAAC;IAC7C,OAAO;;;yBAGiB,GAAG,CAAC,kCAAkC,CAAC;;6BAEnC,WAAW;;;;;;;4BAOZ,WAAW;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;sBAkCjB,WAAW;;;CAGhC,CAAC;AACF,CAAC;AAvDD,oCAuDC"}
|
package/lib/templates/list.js
CHANGED
|
@@ -17,11 +17,11 @@ const listTemplate = async (action_name, newfilefullpath) => {
|
|
|
17
17
|
const collection = response.collection;
|
|
18
18
|
const uppercase_collection = collection[0].toLocaleUpperCase() + collection.slice(1);
|
|
19
19
|
const rel = import_path_1.curryImportPath(newfilefullpath);
|
|
20
|
-
return `import {
|
|
20
|
+
return `import { Context } from "koa";
|
|
21
21
|
import { CollectionItem } from "sealious";
|
|
22
22
|
import { tempstream } from "tempstream";
|
|
23
23
|
import { ${uppercase_collection} } from "${rel("src/back/collections/collections")}";
|
|
24
|
-
import
|
|
24
|
+
import { ${uppercase_collection} } from "${rel("src/back/html.ts")}";
|
|
25
25
|
import { SealiousItemListPage, BaseListPageFields } from "@sealcode/sealgen";
|
|
26
26
|
|
|
27
27
|
export const actionName = "${action_name}";
|
|
@@ -37,7 +37,7 @@ export default new (class ${action_name}Page extends SealiousItemListPage<
|
|
|
37
37
|
filterFields = filterFields;
|
|
38
38
|
filterControls = [];
|
|
39
39
|
|
|
40
|
-
async render(ctx:
|
|
40
|
+
async render(ctx: Context) {
|
|
41
41
|
return html(
|
|
42
42
|
ctx,
|
|
43
43
|
"${uppercase_collection}",
|
|
@@ -58,7 +58,7 @@ export default new (class ${action_name}Page extends SealiousItemListPage<
|
|
|
58
58
|
);
|
|
59
59
|
}
|
|
60
60
|
|
|
61
|
-
async renderItem(_:
|
|
61
|
+
async renderItem(_: Context, item: CollectionItem<typeof ${uppercase_collection}>) {
|
|
62
62
|
return tempstream\`<tr><td>\${item.id}</td>\${Object.keys(${uppercase_collection}.fields).map(
|
|
63
63
|
(fieldname: keyof typeof ${uppercase_collection}["fields"]) =>
|
|
64
64
|
tempstream\`<td>\${item.get(fieldname)}</td>\`
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"list.js","sourceRoot":"","sources":["../../src/templates/list.ts"],"names":[],"mappings":";;;AAAA,sDAAuD;AACvD,mCAAoC;AACpC,gEAA4D;AAErD,MAAM,YAAY,GAAG,KAAK,EAChC,WAAmB,EACnB,eAAuB,EACL,EAAE;IACpB,MAAM,QAAQ,GAAG,MAAM,OAAO,CAAC;QAC9B,IAAI,EAAE,cAAc;QACpB,IAAI,EAAE,YAAY;QAClB,OAAO,EAAE,gDAAgD;QACzD,OAAO,EAAE,CACR,MAAM,kCAAe,EAAE,CACvB,CAAC,GAAG,CAAC,CAAC,UAAU,EAAE,EAAE,CAAC,CAAC;YACtB,KAAK,EAAE,UAAU;YACjB,KAAK,EAAE,UAAU;SACjB,CAAC,CAAC;KACH,CAAC,CAAC;IACH,MAAM,UAAU,GAAG,QAAQ,CAAC,UAAoB,CAAC;IACjD,MAAM,oBAAoB,GACzB,UAAU,CAAC,CAAC,CAAC,CAAC,iBAAiB,EAAE,GAAG,UAAU,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;IACzD,MAAM,GAAG,GAAG,6BAAe,CAAC,eAAe,CAAC,CAAC;IAC7C,OAAO;;;WAGG,oBAAoB,YAAY,GAAG,CAC5C,kCAAkC,CAClC
|
|
1
|
+
{"version":3,"file":"list.js","sourceRoot":"","sources":["../../src/templates/list.ts"],"names":[],"mappings":";;;AAAA,sDAAuD;AACvD,mCAAoC;AACpC,gEAA4D;AAErD,MAAM,YAAY,GAAG,KAAK,EAChC,WAAmB,EACnB,eAAuB,EACL,EAAE;IACpB,MAAM,QAAQ,GAAG,MAAM,OAAO,CAAC;QAC9B,IAAI,EAAE,cAAc;QACpB,IAAI,EAAE,YAAY;QAClB,OAAO,EAAE,gDAAgD;QACzD,OAAO,EAAE,CACR,MAAM,kCAAe,EAAE,CACvB,CAAC,GAAG,CAAC,CAAC,UAAU,EAAE,EAAE,CAAC,CAAC;YACtB,KAAK,EAAE,UAAU;YACjB,KAAK,EAAE,UAAU;SACjB,CAAC,CAAC;KACH,CAAC,CAAC;IACH,MAAM,UAAU,GAAG,QAAQ,CAAC,UAAoB,CAAC;IACjD,MAAM,oBAAoB,GACzB,UAAU,CAAC,CAAC,CAAC,CAAC,iBAAiB,EAAE,GAAG,UAAU,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;IACzD,MAAM,GAAG,GAAG,6BAAe,CAAC,eAAe,CAAC,CAAC;IAC7C,OAAO;;;WAGG,oBAAoB,YAAY,GAAG,CAC5C,kCAAkC,CAClC;WACS,oBAAoB,YAAY,GAAG,CAAC,kBAAkB,CAAC;;;6BAGrC,WAAW;;;;4BAIZ,WAAW;UAC7B,oBAAoB;;;;;;;;;;;MAWxB,oBAAoB;;UAEhB,oBAAoB;;;;uBAIP,oBAAoB;;;;;;;;;;;;4DAYiB,oBAAoB;8DAClB,oBAAoB;8BACpD,oBAAoB;;;;KAI7C,oBAAoB;CACxB,CAAC;AACF,CAAC,CAAC;AAtEW,QAAA,YAAY,gBAsEvB"}
|
package/lib/templates/page.js
CHANGED
|
@@ -4,7 +4,7 @@ exports.pageTemplate = void 0;
|
|
|
4
4
|
const import_path_1 = require("../utils/import-path");
|
|
5
5
|
async function pageTemplate(action_name, newfilefullpath) {
|
|
6
6
|
const rel = import_path_1.curryImportPath(newfilefullpath);
|
|
7
|
-
return `import {
|
|
7
|
+
return `import { Context } from "koa";
|
|
8
8
|
import { tempstream } from "tempstream";
|
|
9
9
|
import { Page } from "@sealcode/sealgen";
|
|
10
10
|
import html from "${rel("src/back/html")}";
|
|
@@ -13,11 +13,11 @@ export const actionName = "${action_name}";
|
|
|
13
13
|
|
|
14
14
|
export default new (class ${action_name}Page extends Page {
|
|
15
15
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
16
|
-
async canAccess(_:
|
|
16
|
+
async canAccess(_: Context) {
|
|
17
17
|
return { canAccess: true, message: "" };
|
|
18
18
|
}
|
|
19
19
|
|
|
20
|
-
async render(ctx:
|
|
20
|
+
async render(ctx: Context) {
|
|
21
21
|
return html(ctx, "${action_name}", tempstream/* HTML */ \`<div></div>\`);
|
|
22
22
|
}
|
|
23
23
|
})();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"translate.js","sourceRoot":"","sources":["../../src/utils/translate.ts"],"names":[],"mappings":";;;AAGA,SAAgB,CAAC,CAChB,
|
|
1
|
+
{"version":3,"file":"translate.js","sourceRoot":"","sources":["../../src/utils/translate.ts"],"names":[],"mappings":";;;AAGA,SAAgB,CAAC,CAChB,GAAY,EACZ,GAAW,EACX,KAAY,EACZ,mBAAgC;IAEhC,OAAO,UAAU,CAAC,0BAA0B,GAAG,CAAC,OAAO,CAAC,GAAG,EAAE,KAAK,CAAC;KAC/D,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC,GAAG,EAAE,KAAK,EAAE,mBAAmB,CAAC;GACrD,CAAC;AACJ,CAAC;AATD,cASC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"url-with-new-params.js","sourceRoot":"","sources":["../../src/utils/url-with-new-params.ts"],"names":[],"mappings":";;;;;;AACA,4CAAoB;AAEpB,SAAgB,gBAAgB,CAC/B,
|
|
1
|
+
{"version":3,"file":"url-with-new-params.js","sourceRoot":"","sources":["../../src/utils/url-with-new-params.ts"],"names":[],"mappings":";;;;;;AACA,4CAAoB;AAEpB,SAAgB,gBAAgB,CAC/B,GAAY,EACZ,YAAqC;IAErC,OAAO,GAAG,GAAG,CAAC,IAAI,IAAI,YAAE,CAAC,SAAS,CAAC,YAAY,CAAC,EAAE,CAAC;AACpD,CAAC;AALD,4CAKC"}
|
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { is, predicates } from "@sealcode/ts-predicates";
|
|
2
|
-
import {
|
|
2
|
+
import { Context } from "koa";
|
|
3
3
|
import { tempstream } from "tempstream";
|
|
4
4
|
import { ChekboxedListField } from "../fields/field";
|
|
5
5
|
import { FormDataValue } from "../form";
|
|
@@ -13,7 +13,7 @@ export class CheckboxedListInput extends FormFieldControl {
|
|
|
13
13
|
super([field]);
|
|
14
14
|
}
|
|
15
15
|
|
|
16
|
-
async render(ctx:
|
|
16
|
+
async render(ctx: Context, data: Record<string, FormDataValue>) {
|
|
17
17
|
const { parsed: pickedValues } = await this.field.getValue(ctx, data);
|
|
18
18
|
if (!is(pickedValues, predicates.array(predicates.string))) {
|
|
19
19
|
throw new Error("picked values is not an array of strings");
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Context } from "koa";
|
|
2
2
|
import { tempstream } from "tempstream";
|
|
3
3
|
import { FormField, PickFromListField } from "../fields/field";
|
|
4
4
|
import { FormDataValue } from "../form";
|
|
@@ -21,7 +21,7 @@ export class Dropdown extends FormFieldControl {
|
|
|
21
21
|
}
|
|
22
22
|
|
|
23
23
|
async render<Fields extends Record<string, FormField>>(
|
|
24
|
-
ctx:
|
|
24
|
+
ctx: Context,
|
|
25
25
|
data: Record<string, FormDataValue>
|
|
26
26
|
) {
|
|
27
27
|
const { parsed: picked_value } = await this.field.getValue(ctx, data);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Context } from "koa";
|
|
2
2
|
import { FlatTemplatable, tempstream } from "tempstream";
|
|
3
3
|
import { PickFromListField } from "../fields/field";
|
|
4
4
|
import { FormDataValue } from "../form";
|
|
@@ -22,7 +22,7 @@ export class EditableCollectionSubset extends FormFieldControl {
|
|
|
22
22
|
}
|
|
23
23
|
|
|
24
24
|
async render(
|
|
25
|
-
ctx:
|
|
25
|
+
ctx: Context,
|
|
26
26
|
data: Record<string, FormDataValue>
|
|
27
27
|
): Promise<FlatTemplatable> {
|
|
28
28
|
const { parsed: values } = await this.field.getValue(ctx, data);
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Context } from "koa";
|
|
2
2
|
import { FlatTemplatable } from "tempstream";
|
|
3
3
|
import { FormDataValue, FormMessage } from "../form";
|
|
4
4
|
|
|
5
5
|
export abstract class FormControl {
|
|
6
6
|
abstract render(
|
|
7
|
-
ctx:
|
|
7
|
+
ctx: Context,
|
|
8
8
|
data: Record<string, FormDataValue>,
|
|
9
9
|
messages: FormMessage[]
|
|
10
10
|
): FlatTemplatable | Promise<FlatTemplatable>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Context } from "koa";
|
|
2
2
|
import { FlatTemplatable } from "tempstream";
|
|
3
3
|
import { FormField } from "../fields/field";
|
|
4
4
|
import { FieldValueType, FormDataValue } from "../form";
|
|
@@ -17,7 +17,7 @@ export abstract class FormFieldControl extends FormControl {
|
|
|
17
17
|
}
|
|
18
18
|
|
|
19
19
|
abstract render(
|
|
20
|
-
ctx:
|
|
20
|
+
ctx: Context,
|
|
21
21
|
data: Record<string, FormDataValue>
|
|
22
22
|
): FlatTemplatable | Promise<FlatTemplatable>;
|
|
23
23
|
}
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Context } from "koa";
|
|
2
2
|
import { FormControl } from "./controls";
|
|
3
3
|
|
|
4
4
|
export class FormHeader extends FormControl {
|
|
5
5
|
role = <const>"decoration";
|
|
6
6
|
constructor(
|
|
7
7
|
public text: string,
|
|
8
|
-
public isVisible: (ctx:
|
|
8
|
+
public isVisible: (ctx: Context) => Promise<boolean> = async () => true
|
|
9
9
|
) {
|
|
10
10
|
super();
|
|
11
11
|
}
|
|
12
|
-
async render(ctx:
|
|
12
|
+
async render(ctx: Context) {
|
|
13
13
|
const isVsbl = await this.isVisible(ctx);
|
|
14
14
|
return isVsbl ? `<h2>${this.text}</h2>` : "";
|
|
15
15
|
}
|
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Context } from "koa";
|
|
2
2
|
import { FormField } from "../fields/field";
|
|
3
|
-
import { NumberField } from "../fields/number";
|
|
4
|
-
import { SimpleFormField } from "../fields/simple-form-field";
|
|
5
3
|
import { FormDataValue } from "../form";
|
|
6
4
|
import { FormFieldControl } from "./controls";
|
|
7
5
|
|
|
@@ -12,6 +10,7 @@ export class SimpleInput extends FormFieldControl {
|
|
|
12
10
|
id?: string;
|
|
13
11
|
label?: string;
|
|
14
12
|
autocomplete?: boolean;
|
|
13
|
+
hide_errors?: boolean;
|
|
15
14
|
type?:
|
|
16
15
|
| "color"
|
|
17
16
|
| "date"
|
|
@@ -36,7 +35,7 @@ export class SimpleInput extends FormFieldControl {
|
|
|
36
35
|
}
|
|
37
36
|
|
|
38
37
|
async render<Fields extends Record<string, FormField>>(
|
|
39
|
-
ctx:
|
|
38
|
+
ctx: Context,
|
|
40
39
|
data: Record<string, FormDataValue>
|
|
41
40
|
) {
|
|
42
41
|
const id = this.options.id || this.field.name;
|
|
@@ -70,7 +69,9 @@ export class SimpleInput extends FormFieldControl {
|
|
|
70
69
|
${!this.options.autocomplete ? `autocomplete="off"` : ""}
|
|
71
70
|
${this.options.step ? `step="${this.options.step}"` : ""}
|
|
72
71
|
/>
|
|
73
|
-
${~valid
|
|
72
|
+
${~valid && !this.options.hide_errors
|
|
73
|
+
? `<div class="input__error">${message}</div>`
|
|
74
|
+
: ""}
|
|
74
75
|
</div>`;
|
|
75
76
|
}
|
|
76
77
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { is, predicates } from "@sealcode/ts-predicates";
|
|
2
|
-
import {
|
|
2
|
+
import { Context } from "koa";
|
|
3
3
|
import { FormDataValue } from "../form";
|
|
4
4
|
import {
|
|
5
5
|
FieldParseResult,
|
|
@@ -11,16 +11,16 @@ export class ChekboxedListField extends FormField<Record<string, "on">> {
|
|
|
11
11
|
constructor(
|
|
12
12
|
public required: boolean = false,
|
|
13
13
|
public generateOptions: (
|
|
14
|
-
ctx:
|
|
14
|
+
ctx: Context
|
|
15
15
|
) => Promise<Record<string, string> | { [i: string]: string }>,
|
|
16
|
-
public isVisible: (ctx:
|
|
16
|
+
public isVisible: (ctx: Context) => Promise<boolean> = () =>
|
|
17
17
|
Promise.resolve(true)
|
|
18
18
|
) {
|
|
19
19
|
super(required);
|
|
20
20
|
}
|
|
21
21
|
|
|
22
22
|
public async isValueValid(
|
|
23
|
-
_:
|
|
23
|
+
_: Context,
|
|
24
24
|
value: unknown
|
|
25
25
|
): Promise<FormFieldValidationResponse> {
|
|
26
26
|
if (is(value, predicates.string)) {
|
|
@@ -33,7 +33,7 @@ export class ChekboxedListField extends FormField<Record<string, "on">> {
|
|
|
33
33
|
}
|
|
34
34
|
|
|
35
35
|
async parse(
|
|
36
|
-
_:
|
|
36
|
+
_: Context,
|
|
37
37
|
raw_value: FormDataValue
|
|
38
38
|
): Promise<FieldParseResult<Record<string, "on">>> {
|
|
39
39
|
if (is(raw_value, predicates.object)) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Context } from "koa";
|
|
2
2
|
import { Depromisify, Field, FieldOutput } from "sealious";
|
|
3
3
|
import { FormDataValue } from "../form";
|
|
4
4
|
|
|
@@ -16,7 +16,7 @@ export class CollectionField<F extends Field> extends FormField<
|
|
|
16
16
|
}
|
|
17
17
|
|
|
18
18
|
async parse(
|
|
19
|
-
ctx:
|
|
19
|
+
ctx: Context,
|
|
20
20
|
raw_value: FormDataValue
|
|
21
21
|
): Promise<FieldParseResult<FieldOutput<F>>> {
|
|
22
22
|
const encoded_value = (await this.sealiousField.encode(
|
|
@@ -37,7 +37,7 @@ export class CollectionField<F extends Field> extends FormField<
|
|
|
37
37
|
}
|
|
38
38
|
|
|
39
39
|
public async isValueValid(
|
|
40
|
-
ctx:
|
|
40
|
+
ctx: Context,
|
|
41
41
|
value: FieldOutput<F>
|
|
42
42
|
): Promise<FormFieldValidationResponse> {
|
|
43
43
|
const { valid, reason } = await this.sealiousField.checkValue(
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Context } from "koa";
|
|
2
2
|
import { t } from "../../utils/translate";
|
|
3
3
|
import { FormDataValue } from "../form";
|
|
4
4
|
|
|
5
5
|
export type FormFieldValidationResponse = { valid: boolean; message: string };
|
|
6
6
|
|
|
7
7
|
export type FormFieldValidationFn<ValueType> = (
|
|
8
|
-
ctx:
|
|
8
|
+
ctx: Context,
|
|
9
9
|
value: ValueType,
|
|
10
10
|
field: FormField<ValueType>
|
|
11
11
|
) => Promise<FormFieldValidationResponse>;
|
|
@@ -29,7 +29,7 @@ export abstract class FormField<ParsedValue extends unknown = unknown> {
|
|
|
29
29
|
}
|
|
30
30
|
|
|
31
31
|
public async _validate(
|
|
32
|
-
ctx:
|
|
32
|
+
ctx: Context,
|
|
33
33
|
value: ParsedValue
|
|
34
34
|
): Promise<FormFieldValidationResponse> {
|
|
35
35
|
if (
|
|
@@ -53,19 +53,19 @@ export abstract class FormField<ParsedValue extends unknown = unknown> {
|
|
|
53
53
|
public abstract getEmptyValue(): ParsedValue;
|
|
54
54
|
|
|
55
55
|
public async isValueValid(
|
|
56
|
-
ctx:
|
|
56
|
+
ctx: Context,
|
|
57
57
|
value: ParsedValue
|
|
58
58
|
): Promise<FormFieldValidationResponse> {
|
|
59
59
|
return { valid: true, message: "" };
|
|
60
60
|
}
|
|
61
61
|
|
|
62
62
|
abstract parse(
|
|
63
|
-
ctx:
|
|
63
|
+
ctx: Context,
|
|
64
64
|
raw_value: FormDataValue
|
|
65
65
|
): Promise<FieldParseResult<ParsedValue>>;
|
|
66
66
|
|
|
67
67
|
async getValue(
|
|
68
|
-
ctx:
|
|
68
|
+
ctx: Context,
|
|
69
69
|
all_form_values: Record<string, FormDataValue>
|
|
70
70
|
): Promise<{
|
|
71
71
|
valid: boolean;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { is, predicates } from "@sealcode/ts-predicates";
|
|
2
|
-
import {
|
|
2
|
+
import { Context } from "koa";
|
|
3
3
|
import { FormDataValue } from "../form";
|
|
4
4
|
import { FieldParseResult, FormField } from "./field";
|
|
5
5
|
|
|
@@ -10,7 +10,7 @@ export class NumberField<
|
|
|
10
10
|
super(required);
|
|
11
11
|
}
|
|
12
12
|
|
|
13
|
-
public async isValueValid(_:
|
|
13
|
+
public async isValueValid(_: Context, value: unknown) {
|
|
14
14
|
if (
|
|
15
15
|
(is(value, predicates.string) &&
|
|
16
16
|
!isNaN(parseFloat(value)) &&
|
|
@@ -24,7 +24,7 @@ export class NumberField<
|
|
|
24
24
|
}
|
|
25
25
|
|
|
26
26
|
async parse(
|
|
27
|
-
_:
|
|
27
|
+
_: Context,
|
|
28
28
|
value: FormDataValue
|
|
29
29
|
): Promise<FieldParseResult<number>> {
|
|
30
30
|
if (
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { is, predicates } from "@sealcode/ts-predicates";
|
|
2
|
-
import {
|
|
2
|
+
import { Context } from "koa";
|
|
3
3
|
import { FormFieldValidationResponse } from "./field";
|
|
4
4
|
import { SimpleFormField } from "./simple-form-field";
|
|
5
5
|
|
|
@@ -7,10 +7,10 @@ export class PickFromListField extends SimpleFormField {
|
|
|
7
7
|
constructor(
|
|
8
8
|
public required: boolean = false,
|
|
9
9
|
public generateOptions: (
|
|
10
|
-
ctx:
|
|
10
|
+
ctx: Context
|
|
11
11
|
) => Promise<Record<string, string> | { [i: string]: string }>,
|
|
12
12
|
public customValidation: (
|
|
13
|
-
ctx:
|
|
13
|
+
ctx: Context,
|
|
14
14
|
value: unknown,
|
|
15
15
|
instance: PickFromListField
|
|
16
16
|
) => Promise<FormFieldValidationResponse> = (ctx, value, instance) =>
|
|
@@ -20,14 +20,14 @@ export class PickFromListField extends SimpleFormField {
|
|
|
20
20
|
}
|
|
21
21
|
|
|
22
22
|
public isValueValid(
|
|
23
|
-
ctx:
|
|
23
|
+
ctx: Context,
|
|
24
24
|
value: string
|
|
25
25
|
): Promise<FormFieldValidationResponse> {
|
|
26
26
|
return this.customValidation(ctx, value, this);
|
|
27
27
|
}
|
|
28
28
|
|
|
29
29
|
async valueInList(
|
|
30
|
-
ctx:
|
|
30
|
+
ctx: Context,
|
|
31
31
|
value: unknown
|
|
32
32
|
): Promise<FormFieldValidationResponse> {
|
|
33
33
|
const options = await this.generateOptions(ctx);
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { FieldParseResult, FormField } from "./field";
|
|
2
2
|
import { FormDataValue } from "../form";
|
|
3
|
-
import {
|
|
3
|
+
import { Context } from "koa";
|
|
4
4
|
|
|
5
5
|
export class SimpleFormField extends FormField<string | null> {
|
|
6
6
|
async parse(
|
|
7
|
-
_:
|
|
7
|
+
_: Context,
|
|
8
8
|
raw_value: FormDataValue
|
|
9
9
|
): Promise<FieldParseResult<string>> {
|
|
10
10
|
return {
|