@sealcode/sealgen 0.19.20 → 0.19.22
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/.xunit +77 -0
- package/@types/forms/controls/table.d.sync-conflict-20260502-145940-GP5D735.ts +39 -0
- package/@types/index.d.sync-conflict-20260502-145557-GP5D735.ts +47 -0
- package/@types/templates/form.test.d.ts +1 -0
- package/lib/add-crud.js +1 -1
- package/lib/add-crud.test.js +32 -0
- package/lib/core-js.d.js +1 -0
- package/lib/page/default-list-filters.js +2 -1
- package/lib/page/stateful-page.js +9 -4
- package/lib/templates/form.js +3 -4
- package/lib/templates/form.test.js +32 -0
- package/lib/templates/jdd-editor.js +20 -1
- package/package.json +2 -1
- package/src/core-js.d.ts +3 -0
- package/src/page/default-list-filters.ts +10 -7
- package/src/page/stateful-page.ts +5 -4
- package/src/templates/form.test.ts +42 -0
- package/src/templates/form.ts +3 -4
- package/src/templates/jdd-editor.ts +20 -1
package/.xunit
ADDED
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
<testsuite name="Mocha Tests" tests="75" failures="0" errors="0" skipped="0" timestamp="Mon, 18 May 2026 09:00:42 GMT" time="365.918">
|
|
2
|
+
<testcase classname="add crud test" name="Generate simple sealious crud" file="/home/kuba/projects/sealcode/superseal/repos/sealgen/lib-instrumented/add-crud.test.js" time="29.991"/>
|
|
3
|
+
<testcase classname="single-reference" name="creates an item list page with working partial string search for text fields" file="/home/kuba/projects/sealcode/superseal/repos/sealgen/lib-instrumented/add-list-route.test.js" time="26.057"/>
|
|
4
|
+
<testcase classname="add route test" name="creates minimal sealious app and adds a simple route that works" file="/home/kuba/projects/sealcode/superseal/repos/sealgen/lib-instrumented/add-route.test.js" time="24.718"/>
|
|
5
|
+
<testcase classname="empty test" name="empty test" file="/home/kuba/projects/sealcode/superseal/repos/sealgen/lib-instrumented/example.test.js" time="0"/>
|
|
6
|
+
<testcase classname="checkboxed-list basic tests" name="sends the values" file="/home/kuba/projects/sealcode/superseal/repos/sealgen/lib-instrumented/forms/controls/checkboxed-list-input.test.js" time="0.532"/>
|
|
7
|
+
<testcase classname="checkboxed-list basic tests" name="renders the label" file="/home/kuba/projects/sealcode/superseal/repos/sealgen/lib-instrumented/forms/controls/checkboxed-list-input.test.js" time="0.481"/>
|
|
8
|
+
<testcase classname="checkboxed-list basic tests" name="groups checkboxes based on the value of the 'group' attribute" file="/home/kuba/projects/sealcode/superseal/repos/sealgen/lib-instrumented/forms/controls/checkboxed-list-input.test.js" time="0.6"/>
|
|
9
|
+
<testcase classname="checkboxed-list basic tests behavior with (non)required" name="allows to send a form when no value is selected and fiels is not required" file="/home/kuba/projects/sealcode/superseal/repos/sealgen/lib-instrumented/forms/controls/checkboxed-list-input.test.js" time="0.482"/>
|
|
10
|
+
<testcase classname="checkboxed-list basic tests behavior with (non)required" name="does not allow to send a form when no value is selected and field IS required" file="/home/kuba/projects/sealcode/superseal/repos/sealgen/lib-instrumented/forms/controls/checkboxed-list-input.test.js" time="0.599"/>
|
|
11
|
+
<testcase classname="checkboxed-list basic tests behavior with (non)required" name="allows to send a form when no value is selected and field IS required" file="/home/kuba/projects/sealcode/superseal/repos/sealgen/lib-instrumented/forms/controls/checkboxed-list-input.test.js" time="0.602"/>
|
|
12
|
+
<testcase classname="file-control basic tests" name="doesn't require image input if it already has old-value" file="/home/kuba/projects/sealcode/superseal/repos/sealgen/lib-instrumented/forms/controls/file.test.js" time="0.506"/>
|
|
13
|
+
<testcase classname="photo-control basic tests" name="sends the old photo if it wasn't changed and it has an initial value" file="/home/kuba/projects/sealcode/superseal/repos/sealgen/lib-instrumented/forms/controls/image.test.js" time="0.443"/>
|
|
14
|
+
<testcase classname="photo-control basic tests" name="doesn't require image input if it already has old-value" file="/home/kuba/projects/sealcode/superseal/repos/sealgen/lib-instrumented/forms/controls/image.test.js" time="0.444"/>
|
|
15
|
+
<testcase classname="single-reference.test" name="creates minimal sealious app and adds form using single-reference field that works" file="/home/kuba/projects/sealcode/superseal/repos/sealgen/lib-instrumented/forms/controls/single-reference.test.js" time="24.635"/>
|
|
16
|
+
<testcase classname="boolean field" name="validation logic" file="/home/kuba/projects/sealcode/superseal/repos/sealgen/lib-instrumented/forms/fields/boolean.test.js" time="0.001"/>
|
|
17
|
+
<testcase classname="boolean field" name="parse function" file="/home/kuba/projects/sealcode/superseal/repos/sealgen/lib-instrumented/forms/fields/boolean.test.js" time="0"/>
|
|
18
|
+
<testcase classname="email field" name="validation logic" file="/home/kuba/projects/sealcode/superseal/repos/sealgen/lib-instrumented/forms/fields/email.test.js" time="0.001"/>
|
|
19
|
+
<testcase classname="email field" name="parse function" file="/home/kuba/projects/sealcode/superseal/repos/sealgen/lib-instrumented/forms/fields/email.test.js" time="0"/>
|
|
20
|
+
<testcase classname="basic field basic tests" name="sends the values" file="/home/kuba/projects/sealcode/superseal/repos/sealgen/lib-instrumented/forms/fields/field.test.js" time="0.3"/>
|
|
21
|
+
<testcase classname="basic field basic tests" name="Doesn't call `isValueValid` and `parse` if the value is empty" file="/home/kuba/projects/sealcode/superseal/repos/sealgen/lib-instrumented/forms/fields/field.test.js" time="0.401"/>
|
|
22
|
+
<testcase classname="basic field basic tests" name="Accepts a form where non-required values are empty" file="/home/kuba/projects/sealcode/superseal/repos/sealgen/lib-instrumented/forms/fields/field.test.js" time="0.484"/>
|
|
23
|
+
<testcase classname="file field" name="should handle as imple upload scenario" file="/home/kuba/projects/sealcode/superseal/repos/sealgen/lib-instrumented/forms/fields/file.test.js" time="0.47"/>
|
|
24
|
+
<testcase classname="number field" name="validation logic" file="/home/kuba/projects/sealcode/superseal/repos/sealgen/lib-instrumented/forms/fields/number.test.js" time="0"/>
|
|
25
|
+
<testcase classname="number field" name="parse function" file="/home/kuba/projects/sealcode/superseal/repos/sealgen/lib-instrumented/forms/fields/number.test.js" time="0"/>
|
|
26
|
+
<testcase classname="pick-from-list field" name="validation logic" file="/home/kuba/projects/sealcode/superseal/repos/sealgen/lib-instrumented/forms/fields/pick-from-list.test.js" time="0"/>
|
|
27
|
+
<testcase classname="regexp field" name="validation logic" file="/home/kuba/projects/sealcode/superseal/repos/sealgen/lib-instrumented/forms/fields/regexp.test.js" time="0"/>
|
|
28
|
+
<testcase classname="regexp field" name="parse function" file="/home/kuba/projects/sealcode/superseal/repos/sealgen/lib-instrumented/forms/fields/regexp.test.js" time="0"/>
|
|
29
|
+
<testcase classname="form test basic tests" name="does not allow to submit an empty form when there's a required field" file="/home/kuba/projects/sealcode/superseal/repos/sealgen/lib-instrumented/forms/form.test.js" time="0.623"/>
|
|
30
|
+
<testcase classname="form test basic tests" name="allows to submit a form when all required fields have a value" file="/home/kuba/projects/sealcode/superseal/repos/sealgen/lib-instrumented/forms/form.test.js" time="0.222"/>
|
|
31
|
+
<testcase classname="form test basic tests" name="does not allow submitting an empty form by circumventing HTML-based validation" file="/home/kuba/projects/sealcode/superseal/repos/sealgen/lib-instrumented/forms/form.test.js" time="0.021"/>
|
|
32
|
+
<testcase classname="form test canAccess tests" name="allows visit when configured when canAccess returns true" file="/home/kuba/projects/sealcode/superseal/repos/sealgen/lib-instrumented/forms/form.test.js" time="0.025"/>
|
|
33
|
+
<testcase classname="form test canAccess tests" name="passes the context to canAccess (false case)" file="/home/kuba/projects/sealcode/superseal/repos/sealgen/lib-instrumented/forms/form.test.js" time="0.029"/>
|
|
34
|
+
<testcase classname="form test canAccess tests" name="passes the context to canAccess (true case)" file="/home/kuba/projects/sealcode/superseal/repos/sealgen/lib-instrumented/forms/form.test.js" time="0.023"/>
|
|
35
|
+
<testcase classname="form test canAccess tests declines access when canAccess returns false" name="prevents the form from rendering" file="/home/kuba/projects/sealcode/superseal/repos/sealgen/lib-instrumented/forms/form.test.js" time="0.021"/>
|
|
36
|
+
<testcase classname="form test canAccess tests declines access when canAccess returns false" name="does not allow submitting of the form through axios" file="/home/kuba/projects/sealcode/superseal/repos/sealgen/lib-instrumented/forms/form.test.js" time="0.009"/>
|
|
37
|
+
<testcase classname="form test validation e2e validation message" name="shows up when incorrect input is given" file="/home/kuba/projects/sealcode/superseal/repos/sealgen/lib-instrumented/forms/form.test.js" time="0.304"/>
|
|
38
|
+
<testcase classname="form test validation e2e validation message" name="doesn't show when correct input is given" file="/home/kuba/projects/sealcode/superseal/repos/sealgen/lib-instrumented/forms/form.test.js" time="0.667"/>
|
|
39
|
+
<testcase classname="form test validation e2e field specific validation message" name="shows up when incorrect input is given" file="/home/kuba/projects/sealcode/superseal/repos/sealgen/lib-instrumented/forms/form.test.js" time="0.275"/>
|
|
40
|
+
<testcase classname="form test validation e2e field specific validation message" name="doesn't show up when correct input is given" file="/home/kuba/projects/sealcode/superseal/repos/sealgen/lib-instrumented/forms/form.test.js" time="0.668"/>
|
|
41
|
+
<testcase classname="form test getInitialValues tests" name="fills the form with values from getInitialValues" file="/home/kuba/projects/sealcode/superseal/repos/sealgen/lib-instrumented/forms/form.test.js" time="0.062"/>
|
|
42
|
+
<testcase classname="multiform test basic tests turbolinks + js enabled" name="checking whether only one submit handler is run" file="/home/kuba/projects/sealcode/superseal/repos/sealgen/lib-instrumented/forms/multiform.test.js" time="0.607"/>
|
|
43
|
+
<testcase classname="multiform test basic tests turbolinks + js enabled" name="checking whether the input in the not submitted form prevails" file="/home/kuba/projects/sealcode/superseal/repos/sealgen/lib-instrumented/forms/multiform.test.js" time="0.007"/>
|
|
44
|
+
<testcase classname="multiform test basic tests turbolinks + js disabled" name="checking whether only one submit handler is run" file="/home/kuba/projects/sealcode/superseal/repos/sealgen/lib-instrumented/forms/multiform.test.js" time="0.588"/>
|
|
45
|
+
<testcase classname="multiform test basic tests turbolinks + js disabled" name="checking whether the input in the not submitted form prevails" file="/home/kuba/projects/sealcode/superseal/repos/sealgen/lib-instrumented/forms/multiform.test.js" time="0.008"/>
|
|
46
|
+
<testcase classname="multiform test canAccess allow access to both forms when both canAccess return true" name="check wether it renders" file="/home/kuba/projects/sealcode/superseal/repos/sealgen/lib-instrumented/forms/multiform.test.js" time="0.498"/>
|
|
47
|
+
<testcase classname="multiform test canAccess allow access to both forms when both canAccess return true" name="check wether you can submit through http (axios)" file="/home/kuba/projects/sealcode/superseal/repos/sealgen/lib-instrumented/forms/multiform.test.js" time="0.007"/>
|
|
48
|
+
<testcase classname="multiform test canAccess deny access to both forms" name="check wether forms didnt render" file="/home/kuba/projects/sealcode/superseal/repos/sealgen/lib-instrumented/forms/multiform.test.js" time="0.778"/>
|
|
49
|
+
<testcase classname="multiform test canAccess deny access to both forms" name="check wether it's possible to submit through http" file="/home/kuba/projects/sealcode/superseal/repos/sealgen/lib-instrumented/forms/multiform.test.js" time="0.007"/>
|
|
50
|
+
<testcase classname="multiform test canAccess allow access to one form, deny to the other" name="check wether form1 renders" file="/home/kuba/projects/sealcode/superseal/repos/sealgen/lib-instrumented/forms/multiform.test.js" time="0.456"/>
|
|
51
|
+
<testcase classname="multiform test canAccess allow access to one form, deny to the other" name="check wether it's possible to submit to form1 through http" file="/home/kuba/projects/sealcode/superseal/repos/sealgen/lib-instrumented/forms/multiform.test.js" time="0.007"/>
|
|
52
|
+
<testcase classname="multiform test canAccess allow access to one form, deny to the other" name="check wether form2 does not render" file="/home/kuba/projects/sealcode/superseal/repos/sealgen/lib-instrumented/forms/multiform.test.js" time="0.347"/>
|
|
53
|
+
<testcase classname="multiform test canAccess allow access to one form, deny to the other" name="check wether it's possible to submit to form2 through http" file="/home/kuba/projects/sealcode/superseal/repos/sealgen/lib-instrumented/forms/multiform.test.js" time="0.005"/>
|
|
54
|
+
<testcase classname="multiform test validation e2e basic tests" name="js enabled" file="/home/kuba/projects/sealcode/superseal/repos/sealgen/lib-instrumented/forms/multiform.test.js" time="1.434"/>
|
|
55
|
+
<testcase classname="multiform test validation e2e basic tests" name="js disabled" file="/home/kuba/projects/sealcode/superseal/repos/sealgen/lib-instrumented/forms/multiform.test.js" time="1.086"/>
|
|
56
|
+
<testcase classname="multiform test validation e2e field specific validation js enabled" name="validation message shows when incorrect input is given" file="/home/kuba/projects/sealcode/superseal/repos/sealgen/lib-instrumented/forms/multiform.test.js" time="0.314"/>
|
|
57
|
+
<testcase classname="multiform test validation e2e field specific validation js enabled" name="validation message doesn't show when correct input is given" file="/home/kuba/projects/sealcode/superseal/repos/sealgen/lib-instrumented/forms/multiform.test.js" time="0.658"/>
|
|
58
|
+
<testcase classname="multiform test validation e2e field specific validation js disabled" name="validation message shows when incorrect input is given" file="/home/kuba/projects/sealcode/superseal/repos/sealgen/lib-instrumented/forms/multiform.test.js" time="0.312"/>
|
|
59
|
+
<testcase classname="multiform test validation e2e field specific validation js disabled" name="validation message doesn't show when correct input is given" file="/home/kuba/projects/sealcode/superseal/repos/sealgen/lib-instrumented/forms/multiform.test.js" time="0.671"/>
|
|
60
|
+
<testcase classname="generate routes" name="handles a url with params" file="/home/kuba/projects/sealcode/superseal/repos/sealgen/lib-instrumented/generate-routes.test.js" time="0.013"/>
|
|
61
|
+
<testcase classname="generate routes" name="handles polish characters in the url" file="/home/kuba/projects/sealcode/superseal/repos/sealgen/lib-instrumented/generate-routes.test.js" time="0"/>
|
|
62
|
+
<testcase classname="generate routes" name="handles a url with params and diacritics" file="/home/kuba/projects/sealcode/superseal/repos/sealgen/lib-instrumented/generate-routes.test.js" time="0.007"/>
|
|
63
|
+
<testcase classname="generate routes" name="sorts routes from most specific first to least specific last, considering directory structure" file="/home/kuba/projects/sealcode/superseal/repos/sealgen/lib-instrumented/generate-routes.test.js" time="0.001"/>
|
|
64
|
+
<testcase classname="mountable-with-fields" name="properly types the getParsedValues method and respects required status" file="/home/kuba/projects/sealcode/superseal/repos/sealgen/lib-instrumented/page/mountable-with-fields.test.js" time="0"/>
|
|
65
|
+
<testcase classname="sealious-list test" name="creates minimal sealious app and adds a simple route that works" file="/home/kuba/projects/sealcode/superseal/repos/sealgen/lib-instrumented/page/sealious-list.test.js" time="26.977"/>
|
|
66
|
+
<testcase classname="stateful page" name="has types that allow for extracting action argument types" file="/home/kuba/projects/sealcode/superseal/repos/sealgen/lib-instrumented/page/stateful-page.test.js" time="0"/>
|
|
67
|
+
<testcase classname="stateful page" name="handles a basic case with action buttons" file="/home/kuba/projects/sealcode/superseal/repos/sealgen/lib-instrumented/page/stateful-page.test.js" time="0"/>
|
|
68
|
+
<testcase classname="register-external CLI commands package.json configuration" name="registers external controllers and verifies package.json is updated" file="/home/kuba/projects/sealcode/superseal/repos/sealgen/lib-instrumented/register-external.test.js" time="18.737"/>
|
|
69
|
+
<testcase classname="register-external CLI commands package.json configuration" name="registers external styles and verifies package.json is updated" file="/home/kuba/projects/sealcode/superseal/repos/sealgen/lib-instrumented/register-external.test.js" time="19.216"/>
|
|
70
|
+
<testcase classname="register-external CLI commands package.json configuration" name="registers both controllers and styles in the same project" file="/home/kuba/projects/sealcode/superseal/repos/sealgen/lib-instrumented/register-external.test.js" time="23.32"/>
|
|
71
|
+
<testcase classname="register-external CLI commands package.json configuration" name="handles duplicate registrations gracefully" file="/home/kuba/projects/sealcode/superseal/repos/sealgen/lib-instrumented/register-external.test.js" time="23.56"/>
|
|
72
|
+
<testcase classname="register-external CLI commands package.json configuration" name="preserves existing sealgen configuration when adding new entries" file="/home/kuba/projects/sealcode/superseal/repos/sealgen/lib-instrumented/register-external.test.js" time="22.742"/>
|
|
73
|
+
<testcase classname="register-external CLI commands build integration" name="registers external controllers and verifies they are included in build" file="/home/kuba/projects/sealcode/superseal/repos/sealgen/lib-instrumented/register-external.test.js" time="24.028"/>
|
|
74
|
+
<testcase classname="register-external CLI commands build integration" name="registers external styles and verifies they are included in build" file="/home/kuba/projects/sealcode/superseal/repos/sealgen/lib-instrumented/register-external.test.js" time="23.41"/>
|
|
75
|
+
<testcase classname="register-external CLI commands build integration" name="registers both external controllers and styles and verifies complete build integration" file="/home/kuba/projects/sealcode/superseal/repos/sealgen/lib-instrumented/register-external.test.js" time="32.706"/>
|
|
76
|
+
<testcase classname="route form test" name="creates minimal sealious app, adds route with form and fills it" file="/home/kuba/projects/sealcode/superseal/repos/sealgen/lib-instrumented/templates/form.test.js" time="23.018"/>
|
|
77
|
+
</testsuite>
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import Router from "@koa/router";
|
|
2
|
+
import { Context } from "koa";
|
|
3
|
+
import { FlatTemplatable } from "tempstream";
|
|
4
|
+
import { FormField } from "../fields/field.js";
|
|
5
|
+
import { Table as TableField } from "../fields/table.js";
|
|
6
|
+
import { Form } from "../form.js";
|
|
7
|
+
import { FormControl, FormControlContext } from "./form-control.js";
|
|
8
|
+
export type TableControlOptions<F extends Record<string, FormField>> = {
|
|
9
|
+
subfield_controls: {
|
|
10
|
+
[field_name in keyof F]: FormControl;
|
|
11
|
+
};
|
|
12
|
+
allow_removing?: boolean;
|
|
13
|
+
label_add?: string;
|
|
14
|
+
label: string;
|
|
15
|
+
label_remove?: string;
|
|
16
|
+
} & ({
|
|
17
|
+
allow_adding: false;
|
|
18
|
+
} | {
|
|
19
|
+
allow_adding: true;
|
|
20
|
+
make_new_row: (ctx: Context) => Promise<{
|
|
21
|
+
[field_name in keyof F]: unknown;
|
|
22
|
+
}>;
|
|
23
|
+
});
|
|
24
|
+
export declare const TABLE_COLUMN_FIELD_INDEX_PLACEHOLDER = "TABLE_ROW_INDEX________________";
|
|
25
|
+
export declare class Table<F extends Record<string, FormField>> extends FormControl {
|
|
26
|
+
table_field: TableField<F>;
|
|
27
|
+
options: TableControlOptions<F>;
|
|
28
|
+
role: "input";
|
|
29
|
+
constructor(table_field: TableField<F>, options: TableControlOptions<F>);
|
|
30
|
+
render(fctx: FormControlContext): Promise<FlatTemplatable>;
|
|
31
|
+
getFrameID(): string;
|
|
32
|
+
getActionURL(field_name: string, action: Record<string, unknown>): string;
|
|
33
|
+
mount(router: Router, form: Form<any, any>): void;
|
|
34
|
+
setAllowRemoving(value: boolean): this;
|
|
35
|
+
setAllowAdding(value: boolean): this;
|
|
36
|
+
setLabel(value: string): this;
|
|
37
|
+
setRemoveLabel(value: string): this;
|
|
38
|
+
setAddLabel(value: string): this;
|
|
39
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
export * as Controls from "./forms/controls/controls.js";
|
|
2
|
+
export * from "./forms/fields/field.js";
|
|
3
|
+
export * as Fields from "./forms/fields/fields.js";
|
|
4
|
+
export * from "./page/mountable.js";
|
|
5
|
+
export * from "./page/page.js";
|
|
6
|
+
export * from "./page/stateful-page.js";
|
|
7
|
+
export * from "./forms/form-types.js";
|
|
8
|
+
export * from "./forms/form.js";
|
|
9
|
+
export * from "./page/props-parser.js";
|
|
10
|
+
export * from "./utils/utils.js";
|
|
11
|
+
export * from "./page/list.js";
|
|
12
|
+
export * from "./page/sealious-list.js";
|
|
13
|
+
export * from "./utils/translate.js";
|
|
14
|
+
export * as sanitize from "./sanitize.js";
|
|
15
|
+
export * from "./forms/multiform.js";
|
|
16
|
+
export * as Components from "./components/components.js";
|
|
17
|
+
export * from "./mount.js";
|
|
18
|
+
export * from "./page/default-list-filters.js";
|
|
19
|
+
export * from "./forms/fields/get-field-for-sealious.js";
|
|
20
|
+
export * from "./forms/controls/form-control.js";
|
|
21
|
+
import { Context } from "koa";
|
|
22
|
+
import { Readable } from "node:stream";
|
|
23
|
+
export interface HTMLOptions {
|
|
24
|
+
morphing?: boolean;
|
|
25
|
+
}
|
|
26
|
+
export interface HTMLHeadOptions {
|
|
27
|
+
ctx: Context;
|
|
28
|
+
title: string | Promise<string | Readable>;
|
|
29
|
+
htmlOptions: Partial<HTMLOptions>;
|
|
30
|
+
metaImage?: string;
|
|
31
|
+
canonicalPath?: string;
|
|
32
|
+
css_clumps: string[];
|
|
33
|
+
description: string;
|
|
34
|
+
}
|
|
35
|
+
export interface HTMLArgs {
|
|
36
|
+
ctx: Context;
|
|
37
|
+
title: string | Promise<string>;
|
|
38
|
+
body: string | Promise<string> | Readable;
|
|
39
|
+
htmlOptions?: Partial<HTMLOptions>;
|
|
40
|
+
makeHead?: (args: HTMLHeadOptions) => string | Promise<string> | Readable | Promise<Readable>;
|
|
41
|
+
metaImage?: string;
|
|
42
|
+
canonicalPath?: string;
|
|
43
|
+
css_clumps?: string[];
|
|
44
|
+
description: string;
|
|
45
|
+
hideNavigation?: boolean;
|
|
46
|
+
}
|
|
47
|
+
export type HTMLFunc = (args: HTMLArgs) => Readable | Promise<Readable>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/lib/add-crud.js
CHANGED
|
@@ -60,7 +60,7 @@ async function addCRUD(params, app_directory = process.cwd()) {
|
|
|
60
60
|
{displayFields.map(({ field, format }) => {
|
|
61
61
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/consistent-type-assertions, @typescript-eslint/no-explicit-any
|
|
62
62
|
const value = item.get(field as any);
|
|
63
|
-
return <td>{format ? format(value, item) : value}</td>;
|
|
63
|
+
return <td data-field-name={field}>{format ? format(value, item) : value}</td>;
|
|
64
64
|
})}
|
|
65
65
|
<td><div class="sealious-list__actions">
|
|
66
66
|
<a href={${edit_action_name}URL(item.id)}>Edit</a>
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { RealAppTest } from "./test_utils/test-on-real-app.js";
|
|
2
|
+
import { getBrowser } from "./utils/browser-creator.js";
|
|
3
|
+
describe("add crud test", () => {
|
|
4
|
+
let page;
|
|
5
|
+
before(async () => {
|
|
6
|
+
const browser = await getBrowser();
|
|
7
|
+
const context = await browser.newContext();
|
|
8
|
+
page = await context.newPage();
|
|
9
|
+
});
|
|
10
|
+
after(async () => {
|
|
11
|
+
await page.close();
|
|
12
|
+
});
|
|
13
|
+
it("Generate simple sealious crud", async function() {
|
|
14
|
+
const test_app = await RealAppTest.init();
|
|
15
|
+
const path = "/sample";
|
|
16
|
+
await test_app.runSealgenCommand(`add-collection --collection_name=sealcode-test`);
|
|
17
|
+
await test_app.runSealgenCommand(`add-crud --url=${path} --collection=sealcode-test`);
|
|
18
|
+
await test_app.start();
|
|
19
|
+
await page.goto(test_app.fullURL(`sample/create/`));
|
|
20
|
+
const contentInput = page.getByLabel("Content");
|
|
21
|
+
await contentInput.focus();
|
|
22
|
+
await contentInput.fill("Hello");
|
|
23
|
+
await page.locator("[type=submit]").click();
|
|
24
|
+
await page.locator('[href="/sample/"]').click();
|
|
25
|
+
const dataFieldNameAttr = await page.getByText("Hello").getAttribute("data-field-name");
|
|
26
|
+
if (dataFieldNameAttr !== "content") {
|
|
27
|
+
throw new Error("Generated td element does not have correct data-field-name attribute");
|
|
28
|
+
}
|
|
29
|
+
await test_app.close();
|
|
30
|
+
}).timeout(100 * 1e3);
|
|
31
|
+
});
|
|
32
|
+
//# sourceMappingURL=add-crud.test.js.map
|
package/lib/core-js.d.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
//# sourceMappingURL=core-js.d.js.map
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import regex_escape from "core-js-pure/features/regexp/escape.js";
|
|
1
2
|
const BooleanListFilter = {
|
|
2
3
|
render: (value, field) => {
|
|
3
4
|
return (
|
|
@@ -38,7 +39,7 @@ const SimpleTextFilter = {
|
|
|
38
39
|
);
|
|
39
40
|
},
|
|
40
41
|
prepareValue: (value) => {
|
|
41
|
-
return { regex: `.*${value}.*` };
|
|
42
|
+
return { regex: `.*${regex_escape(value)}.*` };
|
|
42
43
|
}
|
|
43
44
|
};
|
|
44
45
|
const DefaultListFilters = {
|
|
@@ -5,11 +5,9 @@ import { from_base64, to_base64 } from "../utils/base64.js";
|
|
|
5
5
|
import { Mountable } from "./mountable.js";
|
|
6
6
|
import { isPlainObject } from "is-what";
|
|
7
7
|
class StatefulPage extends Mountable {
|
|
8
|
-
|
|
9
|
-
return { canAccess: true, message: "" };
|
|
10
|
-
}
|
|
11
|
-
constructor() {
|
|
8
|
+
constructor(form_id) {
|
|
12
9
|
super();
|
|
10
|
+
this.form_id = form_id;
|
|
13
11
|
const original_render = this.render.bind(this);
|
|
14
12
|
this.render = async (ctx, state, inputs) => {
|
|
15
13
|
return this.wrapInLayout(
|
|
@@ -23,6 +21,9 @@ class StatefulPage extends Mountable {
|
|
|
23
21
|
);
|
|
24
22
|
};
|
|
25
23
|
}
|
|
24
|
+
async canAccess(_ctx) {
|
|
25
|
+
return { canAccess: true, message: "" };
|
|
26
|
+
}
|
|
26
27
|
async wrapInForm(context, state, content) {
|
|
27
28
|
return tempstream`<form
|
|
28
29
|
action="./"
|
|
@@ -69,6 +70,7 @@ class StatefulPage extends Mountable {
|
|
|
69
70
|
type="submit"
|
|
70
71
|
formaction="${this.makeActionURL(action_description, ...args)}"
|
|
71
72
|
title="${label}"
|
|
73
|
+
${this.form_id ? `form="${this.form_id}"` : ""}
|
|
72
74
|
${disabled ? "disabled" : ""}
|
|
73
75
|
>
|
|
74
76
|
${content}
|
|
@@ -185,6 +187,9 @@ class StatefulPage extends Mountable {
|
|
|
185
187
|
),
|
|
186
188
|
page: this
|
|
187
189
|
});
|
|
190
|
+
console.debug("stateful-page.ts:320");
|
|
191
|
+
console.log("NEW STATUS!!! AFTER ACTION");
|
|
192
|
+
console.dir(new_state, { depth: 7 });
|
|
188
193
|
ctx.body = this.render(ctx, new_state, inputs);
|
|
189
194
|
} else {
|
|
190
195
|
ctx.body = this.render(ctx, state, inputs);
|
package/lib/templates/form.js
CHANGED
|
@@ -5,10 +5,9 @@ const defaults = {
|
|
|
5
5
|
import type {FormDataValue} from "@sealcode/sealgen";`,
|
|
6
6
|
get_fields: `()=>(<const>{ password: new Fields.Password(true) })`,
|
|
7
7
|
get_controls: `
|
|
8
|
-
(fields: ReturnType<typeof getFields>)=>[
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
})]`,
|
|
8
|
+
(fields: ReturnType<typeof getFields>)=>[
|
|
9
|
+
fields.password?.getControl()
|
|
10
|
+
]`,
|
|
12
11
|
validate_method: `async validateValues(
|
|
13
12
|
ctx: Context,
|
|
14
13
|
data: Record<string, FormDataValue>
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { expect } from "@playwright/test";
|
|
2
|
+
import { RealAppTest } from "../test_utils/test-on-real-app.js";
|
|
3
|
+
import { getBrowser } from "../utils/browser-creator.js";
|
|
4
|
+
describe("route form test", () => {
|
|
5
|
+
let page;
|
|
6
|
+
before(async () => {
|
|
7
|
+
const browser = await getBrowser();
|
|
8
|
+
const context = await browser.newContext();
|
|
9
|
+
page = await context.newPage();
|
|
10
|
+
});
|
|
11
|
+
after(async () => {
|
|
12
|
+
await page.close();
|
|
13
|
+
});
|
|
14
|
+
it("creates minimal sealious app, adds route with form and fills it", async function() {
|
|
15
|
+
const test_app = await RealAppTest.init();
|
|
16
|
+
const path = "/form-test/";
|
|
17
|
+
await test_app.runSealgenCommand(`add-route --url=${path} --action=Sample --mode=form`);
|
|
18
|
+
await test_app.start();
|
|
19
|
+
const res = await test_app.httpGET(path);
|
|
20
|
+
if (res.status != 200) {
|
|
21
|
+
throw new Error("url generated by add-route exists but doesn't return 200");
|
|
22
|
+
}
|
|
23
|
+
await page.goto(test_app.fullURL(path));
|
|
24
|
+
const input = page.locator("#password");
|
|
25
|
+
await input.focus();
|
|
26
|
+
await input.fill("abc123");
|
|
27
|
+
await page.locator("[type=submit]").click();
|
|
28
|
+
await expect(page.locator("text=Formularz wype\u0142niony poprawnie")).toBeVisible();
|
|
29
|
+
await test_app.close();
|
|
30
|
+
}).timeout(100 * 1e3);
|
|
31
|
+
});
|
|
32
|
+
//# sourceMappingURL=form.test.js.map
|
|
@@ -53,6 +53,7 @@ import html from "src/back/html.js";
|
|
|
53
53
|
import { registry } from "src/back/jdd-components/registry.js";
|
|
54
54
|
import { makeJDDContext } from "src/back/jdd-context.js";
|
|
55
55
|
import { defaultHead } from "src/back/defaultHead.js";
|
|
56
|
+
import { get_breadcrumbs_from_path } from "src/back/routes/url-tree.js";
|
|
56
57
|
|
|
57
58
|
export const actionName = "${actionName}";
|
|
58
59
|
export const breadcrumbLabel: BreadcrumbLabel = "${actionName}";
|
|
@@ -68,9 +69,27 @@ export default new (class JDDCreatePreviewPage extends EditJDDField<${collection
|
|
|
68
69
|
|
|
69
70
|
async renderPreParameterButtons(ctx: Context) {
|
|
70
71
|
const item = await this.getItem(ctx);
|
|
72
|
+
const breadcrumbs = get_breadcrumbs_from_path(ctx.path);
|
|
73
|
+
const lastIdx = breadcrumbs.length - 2;
|
|
74
|
+
let prev_page = null;
|
|
75
|
+
|
|
76
|
+
for (let i = lastIdx; i > -1; i--) {
|
|
77
|
+
if (breadcrumbs[i]?.actionName) {
|
|
78
|
+
prev_page = breadcrumbs[i];
|
|
79
|
+
break;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
|
|
71
83
|
return (
|
|
72
84
|
<div>
|
|
73
|
-
|
|
85
|
+
{!! prev_page && !!prev_page.url && prev_page.actionName !== undefined ? (
|
|
86
|
+
<a href={prev_page?.url || ""}>
|
|
87
|
+
\u2190 Back to {prev_page.breadcrumbLabel?.(ctx) || prev_page.actionName || ""}
|
|
88
|
+
</a>
|
|
89
|
+
) : (
|
|
90
|
+
""
|
|
91
|
+
)}
|
|
92
|
+
<h1>Edit ${collection_name}: {item.id}</h1>
|
|
74
93
|
</div>
|
|
75
94
|
);
|
|
76
95
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sealcode/sealgen",
|
|
3
|
-
"version": "0.19.
|
|
3
|
+
"version": "0.19.22",
|
|
4
4
|
"description": "Module to automate adding routes and collections to a sealious application",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -66,6 +66,7 @@
|
|
|
66
66
|
"@sealcode/ts-predicates": "^0.4.3",
|
|
67
67
|
"chokidar": "^3.6.0",
|
|
68
68
|
"colord": "^2.9.3",
|
|
69
|
+
"core-js-pure": "^3.49.0",
|
|
69
70
|
"country-codes-list": "^2.0.0",
|
|
70
71
|
"deepmerge": "^4.3.1",
|
|
71
72
|
"esbuild": "^0.20.0",
|
package/src/core-js.d.ts
ADDED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
import type { Context } from "koa";
|
|
3
3
|
import { Field } from "sealious";
|
|
4
4
|
import { FlatTemplatable } from "tempstream";
|
|
5
|
+
import regex_escape from "core-js-pure/features/regexp/escape.js";
|
|
5
6
|
|
|
6
7
|
export type ListFilterRender = (
|
|
7
8
|
value: string,
|
|
@@ -27,12 +28,14 @@ export const BooleanListFilter = {
|
|
|
27
28
|
</option>
|
|
28
29
|
<option
|
|
29
30
|
value=""
|
|
30
|
-
${
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
31
|
+
${(
|
|
32
|
+
value == "null" ||
|
|
33
|
+
value == "" ||
|
|
34
|
+
value == "undefined" ||
|
|
35
|
+
value == undefined
|
|
36
|
+
) ?
|
|
37
|
+
"selected"
|
|
38
|
+
: ""}
|
|
36
39
|
>
|
|
37
40
|
-
|
|
38
41
|
</option>
|
|
@@ -54,7 +57,7 @@ export const SimpleTextFilter = {
|
|
|
54
57
|
</label>`;
|
|
55
58
|
},
|
|
56
59
|
prepareValue: (value: string) => {
|
|
57
|
-
return { regex: `.*${value}.*` };
|
|
60
|
+
return { regex: `.*${regex_escape(value)}.*` };
|
|
58
61
|
},
|
|
59
62
|
};
|
|
60
63
|
|
|
@@ -69,7 +69,7 @@ export abstract class StatefulPage<
|
|
|
69
69
|
return <const>{ canAccess: true, message: "" };
|
|
70
70
|
}
|
|
71
71
|
|
|
72
|
-
constructor() {
|
|
72
|
+
constructor(public form_id?: string) {
|
|
73
73
|
super();
|
|
74
74
|
const original_render = this.render.bind(this) as typeof this.render;
|
|
75
75
|
this.render = async (
|
|
@@ -156,6 +156,7 @@ export abstract class StatefulPage<
|
|
|
156
156
|
type="submit"
|
|
157
157
|
formaction="${this.makeActionURL(action_description, ...args)}"
|
|
158
158
|
title="${label}"
|
|
159
|
+
${this.form_id ? `form="${this.form_id}"` : ""}
|
|
159
160
|
${disabled ? "disabled" : ""}
|
|
160
161
|
>
|
|
161
162
|
${content}
|
|
@@ -231,9 +232,9 @@ export abstract class StatefulPage<
|
|
|
231
232
|
const original_state_string = ctx.$body.state;
|
|
232
233
|
const original_state = await this.deserializeState(
|
|
233
234
|
ctx,
|
|
234
|
-
typeof original_state_string == "string"
|
|
235
|
-
|
|
236
|
-
|
|
235
|
+
typeof original_state_string == "string" ?
|
|
236
|
+
from_base64(original_state_string)
|
|
237
|
+
: "{}"
|
|
237
238
|
);
|
|
238
239
|
|
|
239
240
|
const $body = ctx.$body;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { Locator, Page } from "playwright";
|
|
2
|
+
import { expect } from "@playwright/test";
|
|
3
|
+
import { RealAppTest } from "../test_utils/test-on-real-app.js";
|
|
4
|
+
import { getBrowser } from "../utils/browser-creator.js";
|
|
5
|
+
|
|
6
|
+
describe("route form test", () => {
|
|
7
|
+
let page: Page;
|
|
8
|
+
before(async () => {
|
|
9
|
+
const browser = await getBrowser();
|
|
10
|
+
const context = await browser.newContext();
|
|
11
|
+
page = await context.newPage();
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
after(async () => {
|
|
15
|
+
await page.close();
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
it("creates minimal sealious app, adds route with form and fills it", async function () {
|
|
19
|
+
const test_app = await RealAppTest.init();
|
|
20
|
+
|
|
21
|
+
const path = "/form-test/";
|
|
22
|
+
await test_app.runSealgenCommand(`add-route --url=${path} --action=Sample --mode=form`);
|
|
23
|
+
await test_app.start();
|
|
24
|
+
const res = await test_app.httpGET(path);
|
|
25
|
+
|
|
26
|
+
if (res.status != 200) {
|
|
27
|
+
throw new Error("url generated by add-route exists but doesn't return 200");
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
await page.goto(test_app.fullURL(path));
|
|
31
|
+
|
|
32
|
+
const input: Locator = page.locator("#password");
|
|
33
|
+
|
|
34
|
+
await input.focus();
|
|
35
|
+
await input.fill("abc123");
|
|
36
|
+
await page.locator("[type=submit]").click();
|
|
37
|
+
|
|
38
|
+
await expect(page.locator("text=Formularz wypełniony poprawnie")).toBeVisible();
|
|
39
|
+
|
|
40
|
+
await test_app.close();
|
|
41
|
+
}).timeout(100 * 1000);
|
|
42
|
+
});
|
package/src/templates/form.ts
CHANGED
|
@@ -6,10 +6,9 @@ const defaults = {
|
|
|
6
6
|
import type {FormDataValue} from "@sealcode/sealgen";`,
|
|
7
7
|
get_fields: `()=>(<const>{ password: new Fields.Password(true) })`,
|
|
8
8
|
get_controls: `
|
|
9
|
-
(fields: ReturnType<typeof getFields>)=>[
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
})]`,
|
|
9
|
+
(fields: ReturnType<typeof getFields>)=>[
|
|
10
|
+
fields.password?.getControl()
|
|
11
|
+
]`,
|
|
13
12
|
validate_method: `async validateValues(
|
|
14
13
|
ctx: Context,
|
|
15
14
|
data: Record<string, FormDataValue>
|
|
@@ -63,6 +63,7 @@ import html from "src/back/html.js";
|
|
|
63
63
|
import { registry } from "src/back/jdd-components/registry.js";
|
|
64
64
|
import { makeJDDContext } from "src/back/jdd-context.js";
|
|
65
65
|
import { defaultHead } from "src/back/defaultHead.js";
|
|
66
|
+
import { get_breadcrumbs_from_path } from "src/back/routes/url-tree.js";
|
|
66
67
|
|
|
67
68
|
export const actionName = "${actionName}";
|
|
68
69
|
export const breadcrumbLabel: BreadcrumbLabel = "${actionName}";
|
|
@@ -78,9 +79,27 @@ export default new (class JDDCreatePreviewPage extends EditJDDField<${collection
|
|
|
78
79
|
|
|
79
80
|
async renderPreParameterButtons(ctx: Context) {
|
|
80
81
|
const item = await this.getItem(ctx);
|
|
82
|
+
const breadcrumbs = get_breadcrumbs_from_path(ctx.path);
|
|
83
|
+
const lastIdx = breadcrumbs.length - 2;
|
|
84
|
+
let prev_page = null;
|
|
85
|
+
|
|
86
|
+
for (let i = lastIdx; i > -1; i--) {
|
|
87
|
+
if (breadcrumbs[i]?.actionName) {
|
|
88
|
+
prev_page = breadcrumbs[i];
|
|
89
|
+
break;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
|
|
81
93
|
return (
|
|
82
94
|
<div>
|
|
83
|
-
|
|
95
|
+
{!! prev_page && !!prev_page.url && prev_page.actionName !== undefined ? (
|
|
96
|
+
<a href={prev_page?.url || ""}>
|
|
97
|
+
← Back to {prev_page.breadcrumbLabel?.(ctx) || prev_page.actionName || ""}
|
|
98
|
+
</a>
|
|
99
|
+
) : (
|
|
100
|
+
""
|
|
101
|
+
)}
|
|
102
|
+
<h1>Edit ${collection_name}: {item.id}</h1>
|
|
84
103
|
</div>
|
|
85
104
|
);
|
|
86
105
|
}
|