@sealcode/sealgen 0.19.25 → 0.19.28
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/dropdown.d.ts +6 -6
- package/@types/forms/controls/single-reference.d.ts +9 -6
- package/@types/forms/fields/field.d.ts +2 -2
- package/@types/forms/fields/pick-from-list.d.ts +2 -2
- package/@types/forms/fields/simple-form-field.d.ts +1 -1
- package/@types/forms/multiform.d.ts +4 -3
- package/@types/page/stateful-page.d.ts +1 -1
- package/@types/src/add-collection.d.ts +1 -0
- package/@types/src/add-crud.d.ts +3 -0
- package/@types/src/add-crud.test.d.ts +1 -0
- package/@types/src/add-jdd-component.d.ts +1 -0
- package/@types/src/add-list-route.test.d.ts +1 -0
- package/@types/src/add-route.d.ts +3 -0
- package/@types/src/add-route.test.d.ts +1 -0
- package/@types/src/build.d.ts +3 -0
- package/@types/src/builders/backend-ts-builder.d.ts +7 -0
- package/@types/src/builders/builder.d.ts +11 -0
- package/@types/src/builders/colors-builder.d.ts +10 -0
- package/@types/src/builders/css-builder.d.ts +19 -0
- package/@types/src/builders/fonts-builder.d.ts +7 -0
- package/@types/src/builders/frontend-ts-builder.d.ts +11 -0
- package/@types/src/cli.d.ts +2 -0
- package/@types/src/components/components.d.ts +2 -0
- package/@types/src/components/tabs.d.ts +2 -0
- package/@types/src/components/toggle-modal.d.ts +6 -0
- package/@types/src/controllers/password-generate-button.stimulus.d.ts +5 -0
- package/@types/src/controllers/sealgen-table.stimulus.d.ts +13 -0
- package/@types/src/embeddable-file-extensions.d.ts +1 -0
- package/@types/src/esbuild-plugins/load-assets.d.ts +5 -0
- package/@types/src/esbuild-plugins/rewrite-asset-imports.d.ts +5 -0
- package/@types/src/example.test.d.ts +1 -0
- package/@types/src/forms/controls/array.d.ts +33 -0
- package/@types/src/forms/controls/autocomplete.d.ts +22 -0
- package/@types/src/forms/controls/big-radio-group.d.ts +14 -0
- package/@types/src/forms/controls/checkbox-group.d.ts +21 -0
- package/@types/src/forms/controls/checkbox.d.ts +17 -0
- package/@types/src/forms/controls/checkboxed-list-input.d.ts +21 -0
- package/@types/src/forms/controls/checkboxed-list-input.test.d.ts +1 -0
- package/@types/src/forms/controls/collapsible-checkbox-group.d.ts +11 -0
- package/@types/src/forms/controls/collapsible-field-group.d.ts +21 -0
- package/@types/src/forms/controls/controls.d.ts +32 -0
- package/@types/src/forms/controls/derived-frame.d.ts +19 -0
- package/@types/src/forms/controls/derived.d.ts +13 -0
- package/@types/src/forms/controls/dropdown.d.ts +30 -0
- package/@types/src/forms/controls/editable-collection-subset.d.ts +20 -0
- package/@types/src/forms/controls/field-group.d.ts +23 -0
- package/@types/src/forms/controls/file.d.ts +12 -0
- package/@types/src/forms/controls/file.test.d.ts +1 -0
- package/@types/src/forms/controls/form-control.d.ts +23 -0
- package/@types/src/forms/controls/form-field-control.d.ts +13 -0
- package/@types/src/forms/controls/form-header.d.ts +8 -0
- package/@types/src/forms/controls/form-paragraph.d.ts +7 -0
- package/@types/src/forms/controls/frame.d.ts +17 -0
- package/@types/src/forms/controls/hidden-input.d.ts +9 -0
- package/@types/src/forms/controls/html.d.ts +11 -0
- package/@types/src/forms/controls/hybrid.d.ts +10 -0
- package/@types/src/forms/controls/image.d.ts +19 -0
- package/@types/src/forms/controls/image.test.d.ts +1 -0
- package/@types/src/forms/controls/multiple-files.d.ts +42 -0
- package/@types/src/forms/controls/multiple-images.d.ts +19 -0
- package/@types/src/forms/controls/number.d.ts +13 -0
- package/@types/src/forms/controls/password-with-generator.d.ts +6 -0
- package/@types/src/forms/controls/radio.d.ts +16 -0
- package/@types/src/forms/controls/simple-input.d.ts +35 -0
- package/@types/src/forms/controls/single-reference.d.ts +14 -0
- package/@types/src/forms/controls/single-reference.test.d.ts +1 -0
- package/@types/{forms/controls/table.d.sync-conflict-20260502-145940-GP5D735.ts → src/forms/controls/table.d.ts} +2 -0
- package/@types/src/forms/controls/textarea.d.ts +25 -0
- package/@types/src/forms/controls/tickable.d.ts +25 -0
- package/@types/src/forms/fields/boolean.d.ts +22 -0
- package/@types/src/forms/fields/boolean.test.d.ts +1 -0
- package/@types/src/forms/fields/checkboxed-list.d.ts +23 -0
- package/@types/src/forms/fields/collection-field.d.ts +22 -0
- package/@types/src/forms/fields/color.d.ts +4 -0
- package/@types/src/forms/fields/coordinates.d.ts +14 -0
- package/@types/src/forms/fields/date.d.ts +13 -0
- package/@types/src/forms/fields/datetime.d.ts +14 -0
- package/@types/src/forms/fields/deep-reverse-single-reference-list.d.ts +20 -0
- package/@types/src/forms/fields/deep-reverse-single-reference-table.d.ts +16 -0
- package/@types/src/forms/fields/email.d.ts +10 -0
- package/@types/src/forms/fields/email.test.d.ts +1 -0
- package/@types/src/forms/fields/enum-multiple-sealious.d.ts +16 -0
- package/@types/src/forms/fields/existing-sealious-value.d.ts +6 -0
- package/@types/src/forms/fields/field.d.ts +85 -0
- package/@types/src/forms/fields/field.test.d.ts +1 -0
- package/@types/src/forms/fields/fields.d.ts +34 -0
- package/@types/src/forms/fields/file.d.ts +25 -0
- package/@types/src/forms/fields/file.test.d.ts +1 -0
- package/@types/src/forms/fields/float.d.ts +4 -0
- package/@types/src/forms/fields/get-field-for-sealious.d.ts +33 -0
- package/@types/src/forms/fields/html.d.ts +6 -0
- package/@types/src/forms/fields/hybrid.d.ts +11 -0
- package/@types/src/forms/fields/image.d.ts +5 -0
- package/@types/src/forms/fields/int.d.ts +6 -0
- package/@types/src/forms/fields/item-draft.d.ts +20 -0
- package/@types/src/forms/fields/json.d.ts +13 -0
- package/@types/src/forms/fields/markdown.d.ts +6 -0
- package/@types/src/forms/fields/multiple-files.d.ts +16 -0
- package/@types/src/forms/fields/number.d.ts +25 -0
- package/@types/src/forms/fields/number.test.d.ts +1 -0
- package/@types/src/forms/fields/password.d.ts +10 -0
- package/@types/src/forms/fields/phone-number-with-country-code.d.ts +13 -0
- package/@types/src/forms/fields/phone-number.d.ts +17 -0
- package/@types/src/forms/fields/pick-from-list-sealious.d.ts +11 -0
- package/@types/src/forms/fields/pick-from-list.d.ts +15 -0
- package/@types/src/forms/fields/pick-from-list.test.d.ts +1 -0
- package/@types/src/forms/fields/proxy-field.d.ts +15 -0
- package/@types/src/forms/fields/regexp.d.ts +21 -0
- package/@types/src/forms/fields/regexp.test.d.ts +1 -0
- package/@types/src/forms/fields/simple-form-field.d.ts +31 -0
- package/@types/src/forms/fields/single-reference.d.ts +19 -0
- package/@types/src/forms/fields/structured-array.d.ts +23 -0
- package/@types/src/forms/fields/table.d.ts +16 -0
- package/@types/src/forms/fields/text.d.ts +6 -0
- package/@types/src/forms/fields/url.d.ts +6 -0
- package/@types/src/forms/form-types.d.ts +28 -0
- package/@types/src/forms/form.d.ts +34 -0
- package/@types/src/forms/form.test.d.ts +6 -0
- package/@types/src/forms/multiform.d.ts +23 -0
- package/@types/src/forms/multiform.test.d.ts +1 -0
- package/@types/src/generate-collections.d.ts +2 -0
- package/@types/src/generate-components.d.ts +1 -0
- package/@types/src/generate-routes.d.ts +5 -0
- package/@types/src/generate-routes.test.d.ts +1 -0
- package/@types/src/generate-stimulus.d.ts +1 -0
- package/@types/src/get-fonts.d.ts +2 -0
- package/@types/{index.d.sync-conflict-20260502-145557-GP5D735.ts → src/index.d.ts} +1 -0
- package/@types/src/make-env.d.ts +1 -0
- package/@types/src/make-hidden-inputs.d.ts +5 -0
- package/@types/src/mount.d.ts +6 -0
- package/@types/src/notifier.d.ts +2 -0
- package/@types/src/page/access-control.d.ts +6 -0
- package/@types/src/page/default-list-filters.d.ts +18 -0
- package/@types/src/page/list.d.ts +49 -0
- package/@types/src/page/mountable-with-fields.d.ts +49 -0
- package/@types/src/page/mountable-with-fields.test.d.ts +1 -0
- package/@types/src/page/mountable.d.ts +10 -0
- package/@types/src/page/page.d.ts +18 -0
- package/@types/src/page/props-parser.d.ts +15 -0
- package/@types/src/page/sealious-list.d.ts +20 -0
- package/@types/src/page/sealious-list.test.d.ts +1 -0
- package/@types/src/page/stateful-page.d.ts +63 -0
- package/@types/src/page/stateful-page.test.d.ts +1 -0
- package/@types/src/register-external.d.ts +2 -0
- package/@types/src/register-external.test.d.ts +1 -0
- package/@types/src/run.d.ts +1 -0
- package/@types/src/sanitize.d.ts +1 -0
- package/@types/src/target-locreq.d.ts +4 -0
- package/@types/src/templates/collection.d.ts +1 -0
- package/@types/src/templates/form.d.ts +14 -0
- package/@types/src/templates/form.test.d.ts +1 -0
- package/@types/src/templates/jdd-component.d.ts +1 -0
- package/@types/src/templates/jdd-editor.d.ts +1 -0
- package/@types/src/templates/list.d.ts +1 -0
- package/@types/src/templates/long-running-process.d.ts +1 -0
- package/@types/src/templates/multiform.d.ts +1 -0
- package/@types/src/templates/page.d.ts +1 -0
- package/@types/src/templates/post.d.ts +1 -0
- package/@types/src/templates/redirect.d.ts +1 -0
- package/@types/src/templates/route-test.d.ts +1 -0
- package/@types/src/templates/shared/collection-create-form.d.ts +1 -0
- package/@types/src/templates/shared/collection-edit-form.d.ts +1 -0
- package/@types/src/templates/shared/collection-list.d.ts +16 -0
- package/@types/src/templates/shared/item-delete.d.ts +1 -0
- package/@types/src/templates/shared/shared-crud-form-fields.d.ts +1 -0
- package/@types/src/templates/stateful-page.d.ts +1 -0
- package/@types/src/templates/stimulus-controller.d.ts +1 -0
- package/@types/src/templates/templates.d.ts +1 -0
- package/@types/src/test_utils/exec_async.d.ts +1 -0
- package/@types/src/test_utils/locator_is_visible.d.ts +2 -0
- package/@types/src/test_utils/test-on-real-app.d.ts +26 -0
- package/@types/src/utils/assert-throws.d.ts +1 -0
- package/@types/src/utils/base64.d.ts +2 -0
- package/@types/src/utils/browser-creator.d.ts +1 -0
- package/@types/src/utils/escape-url-params.d.ts +2 -0
- package/@types/src/utils/exec.d.ts +5 -0
- package/@types/src/utils/extract-fields-from-collection.d.ts +14 -0
- package/@types/src/utils/format-external-url.d.ts +1 -0
- package/@types/src/utils/import-path.d.ts +2 -0
- package/@types/src/utils/input-wrapper.d.ts +5 -0
- package/@types/src/utils/list-collections.d.ts +1 -0
- package/@types/src/utils/make-slug.d.ts +1 -0
- package/@types/src/utils/module-dirname.d.ts +1 -0
- package/@types/src/utils/natural-numbers.d.ts +1 -0
- package/@types/src/utils/prettier.d.ts +3 -0
- package/@types/src/utils/question.d.ts +1 -0
- package/@types/src/utils/render-attributes.d.ts +1 -0
- package/@types/src/utils/sleep.d.ts +1 -0
- package/@types/src/utils/translate.d.ts +4 -0
- package/@types/src/utils/url-with-new-params.d.ts +2 -0
- package/@types/src/utils/utils.d.ts +17 -0
- package/@types/src/utils/walk.d.ts +1 -0
- package/@types/src/utils/with-fallback.d.ts +2 -0
- package/@types/src/utils/wrap-attributes.d.ts +3 -0
- package/@types/src/utils/write-file.d.ts +1 -0
- package/lib/add-crud.test.js +1 -1
- package/lib/add-route.js +1 -3
- package/lib/builders/backend-ts-builder.js +1 -1
- package/lib/builders/colors-builder.js +4 -5
- package/lib/forms/controls/file.js +1 -1
- package/lib/forms/controls/multiple-files.js +6 -5
- package/lib/forms/controls/single-reference.js +4 -1
- package/lib/forms/fields/file.js +5 -5
- package/lib/forms/fields/image.js +1 -3
- package/lib/forms/fields/phone-number-with-country-code.js +0 -1
- package/lib/forms/fields/simple-form-field.js +1 -1
- package/lib/forms/fields/structured-array.js +1 -2
- package/lib/get-fonts.js +5 -1
- package/lib/page/mountable-with-fields.js +1 -2
- package/lib/page/mountable-with-fields.test.js +1 -1
- package/lib/page/sealious-list.js +3 -1
- package/package.json +3 -3
- package/src/add-route.ts +6 -8
- package/src/build.ts +1 -2
- package/src/builders/colors-builder.ts +11 -12
- package/src/cli.ts +4 -5
- package/src/controllers/sealgen-table.stimulus.ts +3 -3
- package/src/forms/controls/dropdown.ts +15 -13
- package/src/forms/controls/file.ts +1 -1
- package/src/forms/controls/multiple-files.ts +9 -12
- package/src/forms/controls/number.ts +8 -8
- package/src/forms/controls/single-reference.ts +25 -12
- package/src/forms/controls/table.ts +2 -2
- package/src/forms/controls/textarea.ts +4 -3
- package/src/forms/controls/tickable.ts +2 -2
- package/src/forms/fields/deep-reverse-single-reference-list.ts +2 -5
- package/src/forms/fields/deep-reverse-single-reference-table.ts +16 -14
- package/src/forms/fields/field.ts +4 -4
- package/src/forms/fields/file.ts +27 -21
- package/src/forms/fields/image.ts +1 -5
- package/src/forms/fields/phone-number-with-country-code.ts +1 -2
- package/src/forms/fields/pick-from-list.ts +2 -2
- package/src/forms/fields/simple-form-field.ts +3 -3
- package/src/forms/fields/structured-array.ts +2 -3
- package/src/forms/fields/table.ts +4 -7
- package/src/forms/multiform.ts +9 -6
- package/src/generate-routes.ts +3 -3
- package/src/get-fonts.ts +7 -3
- package/src/notifier.ts +1 -2
- package/src/page/list.ts +4 -4
- package/src/page/mountable-with-fields.test.ts +1 -1
- package/src/page/mountable-with-fields.ts +4 -4
- package/src/page/sealious-list.ts +17 -8
- package/src/page/stateful-page.ts +3 -3
- package/src/templates/jdd-editor.ts +1 -1
- package/src/test_utils/test-on-real-app.ts +5 -5
- package/tsconfig.json +3 -0
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import Router from "@koa/router";
|
|
2
|
+
import { Context } from "koa";
|
|
3
|
+
import { FlatTemplatable } from "tempstream";
|
|
4
|
+
import { Fields, MountableWithFields } from "../page/mountable-with-fields.js";
|
|
5
|
+
import type { FormDataValue, FormMessage } from "./form-types.js";
|
|
6
|
+
import { Form } from "./form.js";
|
|
7
|
+
export declare class Multiform extends MountableWithFields {
|
|
8
|
+
getControls: () => never[];
|
|
9
|
+
name: string;
|
|
10
|
+
forms: Record<string, Form<Fields, unknown>>;
|
|
11
|
+
init(path: string, router: Router): void;
|
|
12
|
+
extractRawValues(ctx: Context): Promise<Record<string, FormDataValue>>;
|
|
13
|
+
canAccess(): Promise<{
|
|
14
|
+
canAccess: boolean;
|
|
15
|
+
message: string;
|
|
16
|
+
}>;
|
|
17
|
+
getSubformsToRender(ctx: Context): Array<readonly [string, Form<any, unknown>]>;
|
|
18
|
+
renderSubform(ctx: Context, sub_form_name: string, show_field_errors: boolean): Promise<FlatTemplatable>;
|
|
19
|
+
getSubformRawValues(ctx: Context, sub_form_name: string): Promise<Record<string, FormDataValue>>;
|
|
20
|
+
render(ctx: Context, messages: FormMessage[], prerenderedForms: Record<string, FlatTemplatable | undefined> | undefined, show_field_errors: boolean): Promise<FlatTemplatable>;
|
|
21
|
+
makeBottomScript(): string;
|
|
22
|
+
mount(router: Router, path: string): void;
|
|
23
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function generateComponents(): Promise<void>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function generateStimulusControllers(controller_dirs: string[]): Promise<void>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function makeEnv(): Promise<void>;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { Context } from "koa";
|
|
2
|
+
import { FlatTemplatable } from "tempstream";
|
|
3
|
+
import { FormField } from "./forms/fields/field.js";
|
|
4
|
+
import { FormDataValue } from "./forms/form-types.js";
|
|
5
|
+
export declare function makeHiddenInputs(ctx: Context, fields: Record<string, FormField>, values: Record<string, FormDataValue>, fields_to_skip: string[]): FlatTemplatable;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import Router from "@koa/router";
|
|
2
|
+
import { FileManager } from "@sealcode/file-manager";
|
|
3
|
+
import { Mountable } from "./page/mountable.js";
|
|
4
|
+
export declare function mount(router: Router, url: string | {
|
|
5
|
+
rawURL: string;
|
|
6
|
+
}, mountable: Mountable, use_dummy_app?: boolean, file_manager?: FileManager | undefined): void;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { Context } from "koa";
|
|
2
|
+
import { Field } from "sealious";
|
|
3
|
+
import { FlatTemplatable } from "tempstream";
|
|
4
|
+
export type ListFilterRender = (value: string, field: Field<any>, ctx: Context) => FlatTemplatable;
|
|
5
|
+
export type DefaultListFilter = {
|
|
6
|
+
render: ListFilterRender;
|
|
7
|
+
prepareValue?: (filter_value: unknown) => unknown;
|
|
8
|
+
};
|
|
9
|
+
export declare const BooleanListFilter: {
|
|
10
|
+
render: (value: string, field: Field<any>) => string;
|
|
11
|
+
};
|
|
12
|
+
export declare const SimpleTextFilter: {
|
|
13
|
+
render: (value: string, field: Field<any>) => string;
|
|
14
|
+
prepareValue: (value: string) => {
|
|
15
|
+
regex: string;
|
|
16
|
+
};
|
|
17
|
+
};
|
|
18
|
+
export declare const DefaultListFilters: Record<"boolean" | "text" | "fallback", DefaultListFilter>;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { ShapeToType } from "@sealcode/ts-predicates";
|
|
2
|
+
import { Context } from "koa";
|
|
3
|
+
import { FlatTemplatable, Templatable } from "tempstream";
|
|
4
|
+
import { FormControl } from "../forms/controls/controls.js";
|
|
5
|
+
import { FormField } from "../forms/fields/field.js";
|
|
6
|
+
import { NumberField } from "../forms/fields/number.js";
|
|
7
|
+
import { TextBasedSimpleField } from "../forms/fields/simple-form-field.js";
|
|
8
|
+
import { FormDataValue } from "../forms/form-types.js";
|
|
9
|
+
import { Page } from "./page.js";
|
|
10
|
+
import Router from "@koa/router";
|
|
11
|
+
export declare const BasePagePropsShape: {};
|
|
12
|
+
export type BasePageProps = ShapeToType<typeof BasePagePropsShape>;
|
|
13
|
+
export declare const DEFAULT_ITEMS_PER_PAGE = 12;
|
|
14
|
+
export declare const BaseListPageFields: {
|
|
15
|
+
readonly page: NumberField<1, false>;
|
|
16
|
+
readonly itemsPerPage: NumberField<12, false>;
|
|
17
|
+
readonly sort: TextBasedSimpleField<false, import("../forms/controls/simple-input.js").SimpleInput<import("../forms/controls/simple-input.js").SimpleInputOptions>>;
|
|
18
|
+
};
|
|
19
|
+
export type ListSort = {
|
|
20
|
+
field: string;
|
|
21
|
+
order: "asc" | "desc";
|
|
22
|
+
};
|
|
23
|
+
export declare abstract class ListPage<ItemType, F extends typeof BaseListPageFields> extends Page<F> {
|
|
24
|
+
abstract getItems(ctx: Context, page: number, itemsPerPage: number | null, values: Record<string, FormDataValue>): Promise<ItemType[]>;
|
|
25
|
+
abstract getTotalPages(ctx: Context, itemsPerPage: number, values: Record<string, FormDataValue>): Promise<number>;
|
|
26
|
+
abstract renderItem(ctx: Context, item: ItemType, index: number): Promise<FlatTemplatable>;
|
|
27
|
+
filterFields: Record<string, FormField>;
|
|
28
|
+
filterControls: FormControl[];
|
|
29
|
+
init(path: string, router: Router): void;
|
|
30
|
+
renderListContainer(_: Context, content: Templatable): FlatTemplatable;
|
|
31
|
+
getPaginationConfig(ctx: Context): Promise<{
|
|
32
|
+
page: number;
|
|
33
|
+
itemsPerPage: number | null;
|
|
34
|
+
}>;
|
|
35
|
+
renderItems(ctx: Context, values?: Record<string, FormDataValue>, items?: ItemType[]): Promise<FlatTemplatable>;
|
|
36
|
+
renderPagination(ctx: Context, values: Record<string, FormDataValue>): Promise<FlatTemplatable>;
|
|
37
|
+
private renderPageButton;
|
|
38
|
+
getFilterValues(ctx: Context): Promise<Record<string, unknown>>;
|
|
39
|
+
getSort(ctx: Context): Promise<ListSort | null>;
|
|
40
|
+
makeSortLink(ctx: Context, field: string, order: "asc" | "desc" | null): string;
|
|
41
|
+
renderFilters(ctx: Context): Promise<FlatTemplatable>;
|
|
42
|
+
renderHeading(ctx: Context, field: string, label?: string): Promise<FlatTemplatable>;
|
|
43
|
+
getDefaultSort(_: Context): ListSort | null;
|
|
44
|
+
renderTableHead(ctx: Context, fields: {
|
|
45
|
+
field: string;
|
|
46
|
+
label?: string;
|
|
47
|
+
}[]): FlatTemplatable;
|
|
48
|
+
render(ctx: Context): Promise<FlatTemplatable>;
|
|
49
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { ShapeToType } from "@sealcode/ts-predicates";
|
|
2
|
+
import { Context } from "koa";
|
|
3
|
+
import { FlatTemplatable } from "tempstream";
|
|
4
|
+
import { FieldMessages, FormControl, FormControlContext } from "../forms/controls/form-control.js";
|
|
5
|
+
import type { FieldsToShape, FormField } from "../forms/fields/field.js";
|
|
6
|
+
import type { FormDataValue, FormMessage, FormData } from "../forms/form-types.js";
|
|
7
|
+
import { Mountable } from "./mountable.js";
|
|
8
|
+
import Router from "@koa/router";
|
|
9
|
+
export type PageErrorMessage = {
|
|
10
|
+
type: "access" | "internal";
|
|
11
|
+
message: string;
|
|
12
|
+
};
|
|
13
|
+
export type Fields = Record<string, FormField<boolean, any>>;
|
|
14
|
+
type Resolved<T> = T extends Promise<infer X> ? X : never;
|
|
15
|
+
type ParsedValue<T extends FormField> = Resolved<ReturnType<T["getParsedValue"]>>["parsed"];
|
|
16
|
+
export declare abstract class MountableWithFields<F extends Fields = Fields> extends Mountable {
|
|
17
|
+
getFields: () => F;
|
|
18
|
+
fields: F;
|
|
19
|
+
initialized: boolean;
|
|
20
|
+
field_names_prefix: string;
|
|
21
|
+
form_id: string;
|
|
22
|
+
abstract getControls: (fields: F) => FormControl[];
|
|
23
|
+
controls: FormControl[];
|
|
24
|
+
constructor();
|
|
25
|
+
/** most routes should be setup using .mount(), but mount runs before
|
|
26
|
+
initialization so we don't yet have controls, app, etc ready for dynamic
|
|
27
|
+
routes **/
|
|
28
|
+
init(path: string, router: Router): void;
|
|
29
|
+
makeFormControlContext(ctx: Context, data: FormData, validate: boolean, field_name_prefix?: string, form_id?: string): FormControlContext;
|
|
30
|
+
validateValues(_ctx: Context, _data: Record<string, FormDataValue>): Promise<{
|
|
31
|
+
valid: boolean;
|
|
32
|
+
error: string;
|
|
33
|
+
}>;
|
|
34
|
+
getInitialValues(_ctx: Context): Promise<Record<string, FormDataValue>>;
|
|
35
|
+
validate(ctx: Context, values: Record<string, FormDataValue>): Promise<{
|
|
36
|
+
valid: boolean;
|
|
37
|
+
field_errors: FieldMessages;
|
|
38
|
+
form_messages: FormMessage[];
|
|
39
|
+
}>;
|
|
40
|
+
renderControls(fctx: FormControlContext): FlatTemplatable;
|
|
41
|
+
renderError(_: Context, error: PageErrorMessage): Promise<FlatTemplatable>;
|
|
42
|
+
renderMessages(_: Context, data: FormData<keyof Fields>): FlatTemplatable;
|
|
43
|
+
abstract extractRawValues(ctx: Context): Promise<Record<string, FormDataValue>>;
|
|
44
|
+
getParsedValues(ctx: Context): Promise<{
|
|
45
|
+
[field in keyof F]: F[field] extends FormField<true> ? Exclude<ParsedValue<F[field]>, null> : ParsedValue<F[field]>;
|
|
46
|
+
}>;
|
|
47
|
+
getDatabaseValues(ctx: Context): Promise<ShapeToType<FieldsToShape<F>>>;
|
|
48
|
+
}
|
|
49
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import Router from "@koa/router";
|
|
2
|
+
import { Context } from "koa";
|
|
3
|
+
export declare abstract class Mountable {
|
|
4
|
+
init(_path: string, _router: Router): void;
|
|
5
|
+
abstract mount(router: Router, path: string): void;
|
|
6
|
+
abstract canAccess(ctx: Context): Promise<{
|
|
7
|
+
canAccess: boolean;
|
|
8
|
+
message: string;
|
|
9
|
+
}>;
|
|
10
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import Router from "@koa/router";
|
|
2
|
+
import { Context } from "koa";
|
|
3
|
+
import { FlatTemplatable } from "tempstream";
|
|
4
|
+
import type { FormDataValue } from "../forms/form-types.js";
|
|
5
|
+
import { Fields, MountableWithFields, PageErrorMessage } from "./mountable-with-fields.js";
|
|
6
|
+
import { PagePropsParser } from "./props-parser.js";
|
|
7
|
+
export declare abstract class Page<F extends Fields = Record<string, never>> extends MountableWithFields<F> {
|
|
8
|
+
propsParser: PagePropsParser<Record<keyof Fields, unknown>>;
|
|
9
|
+
getControls: () => never[];
|
|
10
|
+
mount(router: Router, path: string): void;
|
|
11
|
+
canAccess(_: Context): Promise<{
|
|
12
|
+
canAccess: boolean;
|
|
13
|
+
message: string;
|
|
14
|
+
}>;
|
|
15
|
+
renderError(_: Context, error: PageErrorMessage): Promise<FlatTemplatable>;
|
|
16
|
+
abstract render(ctx: Context): Promise<FlatTemplatable>;
|
|
17
|
+
extractRawValues(ctx: Context): Promise<Record<string, FormDataValue>>;
|
|
18
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { Context } from "koa";
|
|
2
|
+
import { FormDataValue } from "../forms/form-types.js";
|
|
3
|
+
import type { BasePageProps } from "./list.js";
|
|
4
|
+
export type EncodedProps = Record<string, unknown>;
|
|
5
|
+
export declare abstract class PagePropsParser<PropsType> {
|
|
6
|
+
abstract decode(ctx: Context): Record<string, FormDataValue>;
|
|
7
|
+
abstract encode(props: Record<string, FormData>): EncodedProps;
|
|
8
|
+
abstract getHTMLInputName(prop_name: string): string;
|
|
9
|
+
overwriteProp(ctx: Context, new_props: Partial<PropsType>): EncodedProps;
|
|
10
|
+
}
|
|
11
|
+
export declare class AllQueryParams<PropsType extends BasePageProps> extends PagePropsParser<PropsType> {
|
|
12
|
+
decode(ctx: Context): Record<string, FormDataValue>;
|
|
13
|
+
encode(props: PropsType): Record<string, unknown>;
|
|
14
|
+
getHTMLInputName(prop_name: string): string;
|
|
15
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { Context } from "koa";
|
|
2
|
+
import { BaseListPageFields, ListPage } from "./list.js";
|
|
3
|
+
import { Collection, CollectionItem, ItemList, Context as SealiousContext } from "sealious";
|
|
4
|
+
import { FlatTemplatable, Templatable } from "tempstream";
|
|
5
|
+
export declare abstract class SealiousItemListPage<C extends Collection, F extends typeof BaseListPageFields> extends ListPage<CollectionItem<C>, F> {
|
|
6
|
+
collection: C;
|
|
7
|
+
constructor(collection: C);
|
|
8
|
+
getContextForList(ctx: Context): Promise<SealiousContext>;
|
|
9
|
+
getTotalPages(ctx: Context, itemsPerPage: number): Promise<number>;
|
|
10
|
+
protected addFilter(ctx: Context, list: ItemList<C>): Promise<void>;
|
|
11
|
+
makeQuery(ctx: Context): Promise<ItemList<C>>;
|
|
12
|
+
getItems(ctx: Context, page: number, itemsPerPage: number | null): Promise<CollectionItem<C>[]>;
|
|
13
|
+
getFilterValues(ctx: Context): Promise<Record<string, string | undefined>>;
|
|
14
|
+
renderListContainer(_: Context, content: Templatable): FlatTemplatable;
|
|
15
|
+
renderItem(_: Context, item: CollectionItem<C>, _index: number): Promise<FlatTemplatable>;
|
|
16
|
+
canAccess: (ctx: Context) => Promise<{
|
|
17
|
+
canAccess: boolean;
|
|
18
|
+
message: string;
|
|
19
|
+
}>;
|
|
20
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import Router from "@koa/router";
|
|
2
|
+
import { Context } from "koa";
|
|
3
|
+
import { Templatable } from "tempstream";
|
|
4
|
+
import { Mountable } from "./mountable.js";
|
|
5
|
+
export type StatefulPageActionDescription<ActionName> = {
|
|
6
|
+
action: ActionName;
|
|
7
|
+
label?: string;
|
|
8
|
+
content?: string;
|
|
9
|
+
disabled?: boolean;
|
|
10
|
+
} | ActionName;
|
|
11
|
+
export type StateAndMetadata<State, Actions> = {
|
|
12
|
+
state: State;
|
|
13
|
+
inputs: Record<string, string>;
|
|
14
|
+
action: keyof Actions;
|
|
15
|
+
action_args: string;
|
|
16
|
+
} | {
|
|
17
|
+
state: State;
|
|
18
|
+
inputs: Record<string, string>;
|
|
19
|
+
action: null;
|
|
20
|
+
action_args: null;
|
|
21
|
+
$: Record<string, unknown>;
|
|
22
|
+
};
|
|
23
|
+
export type StatefulPageActionArgument<State extends Record<string, unknown>, Args extends unknown[] = unknown[]> = {
|
|
24
|
+
ctx: Context;
|
|
25
|
+
state: State;
|
|
26
|
+
inputs: Record<string, string>;
|
|
27
|
+
args: Args;
|
|
28
|
+
page: StatefulPage<any, any>;
|
|
29
|
+
};
|
|
30
|
+
export type StatefulPageAction<State extends Record<string, unknown>, Args extends unknown[] = unknown[]> = (obj: StatefulPageActionArgument<State, Args>) => State | Promise<State>;
|
|
31
|
+
export type ExtractStatefulPageActionArgs<X> = X extends StatefulPageAction<any, infer Args> ? Args : never;
|
|
32
|
+
export declare abstract class StatefulPage<State extends Record<string, unknown>, Actions extends Record<string, StatefulPageAction<State>>> extends Mountable {
|
|
33
|
+
form_id?: string | undefined;
|
|
34
|
+
abstract actions: Actions;
|
|
35
|
+
abstract getInitialState(ctx: Context): State | Promise<State>;
|
|
36
|
+
abstract render(ctx: Context, state: State, inputs: Record<string, string>): Templatable | Promise<Templatable>;
|
|
37
|
+
canAccess(_ctx: Context): Promise<{
|
|
38
|
+
canAccess: boolean;
|
|
39
|
+
message: string;
|
|
40
|
+
}>;
|
|
41
|
+
constructor(form_id?: string | undefined);
|
|
42
|
+
abstract wrapInLayout(ctx: Context, content: Templatable, state: State): Templatable;
|
|
43
|
+
wrapInForm(context: Context, state: State, content: Templatable): Promise<Templatable>;
|
|
44
|
+
extractActionAndLabel<ActionName extends keyof Actions>(action_description: StatefulPageActionDescription<ActionName>): {
|
|
45
|
+
action: string;
|
|
46
|
+
label: string;
|
|
47
|
+
content: string;
|
|
48
|
+
disabled: boolean;
|
|
49
|
+
};
|
|
50
|
+
makeActionURL<ActionName extends keyof Actions>(action_description: StatefulPageActionDescription<ActionName>, ...args: ExtractStatefulPageActionArgs<Actions[ActionName]>): string;
|
|
51
|
+
makeActionButton<ActionName extends keyof Actions>(_state: State, action_description: StatefulPageActionDescription<ActionName>, ...args: ExtractStatefulPageActionArgs<Actions[ActionName]>): string;
|
|
52
|
+
makeActionCallback<ActionName extends keyof Actions>(action_description: {
|
|
53
|
+
action: ActionName;
|
|
54
|
+
label?: string;
|
|
55
|
+
} | ActionName, ...args: ExtractStatefulPageActionArgs<Actions[ActionName]>): string;
|
|
56
|
+
rerender(): string;
|
|
57
|
+
preprocessState(values: State): Promise<State>;
|
|
58
|
+
preprocessOverrides(_context: Context, _state: State, values: Record<string, unknown>): Promise<Record<string, unknown>>;
|
|
59
|
+
serializeState(_context: Context, state: State): Promise<string>;
|
|
60
|
+
deserializeState(_context: Context, s: string): Promise<State>;
|
|
61
|
+
extractState(ctx: Context): Promise<StateAndMetadata<State, Actions>>;
|
|
62
|
+
mount(router: Router, path: string): void;
|
|
63
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function attribute(raw: string | number): string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function collectionTemplate(collection_name: string, fields_string?: string): string;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
declare const defaults: {
|
|
2
|
+
postimport: string;
|
|
3
|
+
get_fields: string;
|
|
4
|
+
get_controls: string;
|
|
5
|
+
validate_method: string;
|
|
6
|
+
onsubmit: string;
|
|
7
|
+
can_access: string;
|
|
8
|
+
render: string;
|
|
9
|
+
get_initial_values: string;
|
|
10
|
+
other_methods: string;
|
|
11
|
+
success_message: string;
|
|
12
|
+
};
|
|
13
|
+
export declare function formTemplate(action_name: string, _params?: Partial<typeof defaults>): Promise<string>;
|
|
14
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function jddComponentTemplate(component_name: string): Promise<string>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function jddEditorTemplate(actionName: string): Promise<string>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const listTemplate: (action_name: string, newfilefullpath: string) => Promise<string>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function LongRunningProcessTemplate(action_name: string): Promise<string>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function multiformTemplate(action_name: string): Promise<string>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function pageTemplate(action_name: string): Promise<string>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function postTemplate(action_name: string): Promise<string>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function redirectTemplate(action_name: string): Promise<string>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function testTemplate(action_name: string): Promise<string>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function createItemFormTemplate(create_action_name: string, newfilefullpath: string, collection_name: string, list_action: string): Promise<string>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function editItemFormTemplate(edit_action_name: string, newfilefullpath: string, collection_name: string, list_action: string): Promise<string>;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export declare function makeDefaultFilterFields(collection_fields: {
|
|
2
|
+
name: string;
|
|
3
|
+
type: string;
|
|
4
|
+
}[]): string;
|
|
5
|
+
export declare function makeDefaultDisplayFields(collection_fields: {
|
|
6
|
+
name: string;
|
|
7
|
+
type: string;
|
|
8
|
+
}[]): string;
|
|
9
|
+
declare const default_hooks: {
|
|
10
|
+
pre_header_html: string;
|
|
11
|
+
post_header_html: string;
|
|
12
|
+
post_import_js: string;
|
|
13
|
+
render_item: (collection_name: string) => string;
|
|
14
|
+
};
|
|
15
|
+
export declare function collectionListTemplate(collection_name: string, action_name: string, _: string, _hooks?: Partial<typeof default_hooks>): Promise<string>;
|
|
16
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function itemDeleteTemplate(delete_action_name: string, collection_name: string, list_action_name: string): Promise<string>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function sharedCrudFormFields(collection_name: string): Promise<string>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function statefulPageTemplate(action_name: string): Promise<string>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function jddComponentTemplate(controller_name: string): string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const Templates: Record<string, (action: string, params: any) => Promise<string>>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const execAsync: (cmd: string) => Promise<void>;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import EventEmitter from "events";
|
|
2
|
+
export declare const callSealgenBin: () => string;
|
|
3
|
+
export declare class RealAppTest {
|
|
4
|
+
node_pid: number;
|
|
5
|
+
app_port: number;
|
|
6
|
+
mongo_port: number;
|
|
7
|
+
app_path: string;
|
|
8
|
+
container_name: string;
|
|
9
|
+
emitter: EventEmitter<[never]>;
|
|
10
|
+
static init(): Promise<RealAppTest>;
|
|
11
|
+
start(): Promise<void>;
|
|
12
|
+
close(): Promise<void>;
|
|
13
|
+
runSealgenCommand(command: string): Promise<void>;
|
|
14
|
+
build(): Promise<void>;
|
|
15
|
+
throwIfItKillsTheApp<T>(cb: () => Promise<T>): Promise<T>;
|
|
16
|
+
httpGET(path: string): Promise<{
|
|
17
|
+
status: number;
|
|
18
|
+
response: string;
|
|
19
|
+
}>;
|
|
20
|
+
httpPOST(path: string, body: Record<string, unknown>): Promise<{
|
|
21
|
+
status: number;
|
|
22
|
+
response: string;
|
|
23
|
+
}>;
|
|
24
|
+
addFile(target_path: string, content: string): Promise<void>;
|
|
25
|
+
fullURL(path: string): string;
|
|
26
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function assertThrowsAsync(fn: () => Promise<unknown>, error_handler?: (e: unknown) => Promise<void> | void): Promise<void>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export function getBrowser(): Promise<any>;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { FormField } from "../forms/fields/field.js";
|
|
2
|
+
export type ExtractedFieldInfo = {
|
|
3
|
+
name: string;
|
|
4
|
+
type: string;
|
|
5
|
+
target: string | null;
|
|
6
|
+
referencing_collection: string | null;
|
|
7
|
+
referencing_field: string | null;
|
|
8
|
+
intermediary_field_that_points_there: string | null;
|
|
9
|
+
is_required: boolean;
|
|
10
|
+
};
|
|
11
|
+
export type ExtractedFieldInfoWithFormField = ExtractedFieldInfo & {
|
|
12
|
+
form_field: FormField;
|
|
13
|
+
};
|
|
14
|
+
export default function extract_fields_from_collection(collection_name: string): Promise<ExtractedFieldInfoWithFormField[]>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function formatExternalURL(url: string): string;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { FlatTemplatable } from "tempstream";
|
|
2
|
+
import { FormField } from "../index.js";
|
|
3
|
+
export declare function getRequiredClass(isRequired: boolean): string;
|
|
4
|
+
export declare function inputWrapper(type: string, modifiers: string[], input: FlatTemplatable): Promise<string>;
|
|
5
|
+
export declare function autoWrapInput(field: FormField, input: FlatTemplatable): Promise<string>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function listCollections(): Promise<string[]>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function makeSlug(t: string): string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function module_dirname(module_url: string): string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function naturalNumbers(min: number, max: number): Generator<number, void, unknown>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function question(text: string, validator: (answer: string) => boolean): Promise<string>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function renderAttributes(attrs: Record<string, string | boolean>): string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function sleep(time: number): Promise<unknown>;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export type Awaited<T> = T extends Promise<infer U> ? U : T;
|
|
2
|
+
export type UnwrapArray<T> = T extends Array<infer U> ? U : T;
|
|
3
|
+
export declare function keys<S extends string>(object: Record<S, unknown>): S[];
|
|
4
|
+
export type ExtractTail<T extends any[]> = T extends [infer _, ...infer Tail] ? Tail : never;
|
|
5
|
+
export { sleep } from "./sleep.js";
|
|
6
|
+
export { naturalNumbers } from "./natural-numbers.js";
|
|
7
|
+
export { UrlWithNewParams } from "./url-with-new-params.js";
|
|
8
|
+
export { exec } from "./exec.js";
|
|
9
|
+
export { importPath, curryImportPath } from "./import-path.js";
|
|
10
|
+
export { listCollections } from "./list-collections.js";
|
|
11
|
+
export { walkDir } from "./walk.js";
|
|
12
|
+
export { assertThrowsAsync } from "./assert-throws.js";
|
|
13
|
+
export * from "./make-slug.js";
|
|
14
|
+
export * from "./render-attributes.js";
|
|
15
|
+
export * from "./format-external-url.js";
|
|
16
|
+
export * from "./base64.js";
|
|
17
|
+
export * from "./with-fallback.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function walkDir(dir: string): Promise<string[]>;
|