@sealcode/sealgen 0.19.20 → 0.19.21

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 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 &#x27;group&#x27; 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&#x27;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&#x27;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&#x27;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&#x27;t call &#x60;isValueValid&#x60; and &#x60;parse&#x60; 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&#x27;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&#x27;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&#x27;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&#x27;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&#x27;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&#x27;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&#x27;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&#x27;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
@@ -0,0 +1 @@
1
+ //# sourceMappingURL=core-js.d.js.map
@@ -1,3 +1,7 @@
1
+ import regex_escape from "core-js-pure/features/regexp/escape.js";
2
+ console.warn(regex_escape);
3
+ const string = "jedna baba ;) drugiej babie ;)";
4
+ console.warn(regex_escape(string), new RegExp(regex_escape(string)));
1
5
  const BooleanListFilter = {
2
6
  render: (value, field) => {
3
7
  return (
@@ -38,7 +42,7 @@ const SimpleTextFilter = {
38
42
  );
39
43
  },
40
44
  prepareValue: (value) => {
41
- return { regex: `.*${value}.*` };
45
+ return { regex: `.*${regex_escape(value)}.*` };
42
46
  }
43
47
  };
44
48
  const DefaultListFilters = {
@@ -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>)=>[new Controls.SimpleInput(fields.password, {
9
- label: "Password:",
10
- type: "password",
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
- <h1>Edit ${collection_name}: {item.id}</h1>{" "}
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.20",
3
+ "version": "0.19.21",
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",
@@ -0,0 +1,3 @@
1
+ declare module "core-js-pure/features/regexp/escape.js" {
2
+ export default function regexEscape(input: string): string;
3
+ }
@@ -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
- ${value == "null" ||
31
- value == "" ||
32
- value == "undefined" ||
33
- value == undefined
34
- ? "selected"
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
 
@@ -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
+ });
@@ -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>)=>[new Controls.SimpleInput(fields.password, {
10
- label: "Password:",
11
- type: "password",
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
- <h1>Edit ${collection_name}: {item.id}</h1>{" "}
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
  }