@sealcode/sealgen 0.8.52 → 0.8.53
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/array.d.ts +1 -1
- package/@types/forms/controls/checkbox-group.d.ts +1 -1
- package/@types/forms/controls/collapsible-field-group.d.ts +1 -1
- package/@types/forms/controls/derived-frame.d.ts +1 -0
- package/@types/forms/controls/dropdown.d.ts +2 -2
- package/@types/forms/controls/form-field-control.d.ts +1 -1
- package/@types/forms/controls/html.d.ts +1 -1
- package/@types/forms/controls/multiple-files.d.ts +1 -1
- package/@types/forms/controls/number.d.ts +1 -1
- package/@types/forms/controls/simple-input.d.ts +1 -1
- package/@types/forms/controls/tickable.d.ts +1 -1
- package/@types/forms/fields/field.d.ts +6 -6
- package/@types/forms/fields/file.d.ts +1 -1
- package/@types/forms/form.d.ts +7 -7
- package/@types/index.d.ts +1 -0
- package/@types/page/list.d.ts +13 -17
- package/@types/page/mountable-with-fields.d.ts +2 -2
- package/@types/page/props-parser.d.ts +1 -1
- package/@types/page/sealious-list.d.ts +18 -0
- package/@types/utils/utils.d.ts +3 -3
- package/lib/add-collection.js +7 -7
- package/lib/add-route.js +7 -7
- package/lib/add-route.test.js +4 -4
- package/lib/build.js +14 -10
- package/lib/components/components.js +5 -1
- package/lib/components/tabs.js +2 -2
- package/lib/components/toggle-modal.js +2 -2
- package/lib/find-scss-includes.js +3 -3
- package/lib/forms/controls/array.js +5 -5
- package/lib/forms/controls/big-radio-group.js +2 -2
- package/lib/forms/controls/checkboxed-list-input.js +3 -3
- package/lib/forms/controls/collapsible-field-group.js +1 -1
- package/lib/forms/controls/controls.js +5 -1
- package/lib/forms/controls/derived-frame.js +3 -3
- package/lib/forms/controls/derived.js +2 -2
- package/lib/forms/controls/dropdown.js +2 -2
- package/lib/forms/controls/editable-collection-subset.js +3 -3
- package/lib/forms/controls/field-group.js +1 -1
- package/lib/forms/controls/file.js +1 -1
- package/lib/forms/controls/hidden-input.js +1 -1
- package/lib/forms/controls/multiple-files.js +5 -5
- package/lib/forms/controls/multiple-photos.js +1 -1
- package/lib/forms/controls/photo.js +1 -1
- package/lib/forms/controls/simple-input.js +2 -2
- package/lib/forms/controls/tickable.js +3 -3
- package/lib/forms/fields/boolean.js +3 -3
- package/lib/forms/fields/checkboxed-list.js +3 -3
- package/lib/forms/fields/enum-multiple.js +3 -3
- package/lib/forms/fields/enum.js +2 -2
- package/lib/forms/fields/field.js +6 -2
- package/lib/forms/fields/file.js +6 -6
- package/lib/forms/fields/number.js +5 -5
- package/lib/forms/fields/pick-from-list.js +1 -1
- package/lib/forms/fields/regexp.js +2 -2
- package/lib/forms/fields/simple-form-field.js +4 -4
- package/lib/forms/form.js +9 -9
- package/lib/forms/form.test.js +12 -12
- package/lib/forms/multiform.js +5 -5
- package/lib/forms/multiform.test.js +26 -26
- package/lib/generate-collections.js +8 -4
- package/lib/generate-routes.js +12 -8
- package/lib/index.js +6 -1
- package/lib/make-env.js +1 -1
- package/lib/make-hidden-inputs.js +3 -3
- package/lib/page/list.js +66 -53
- package/lib/page/mountable-with-fields.js +2 -2
- package/lib/page/page.js +1 -1
- package/lib/page/sealious-list.js +53 -0
- package/lib/page/stateful-page.js +9 -9
- package/lib/templates/form.js +1 -1
- package/lib/templates/list.js +9 -8
- package/lib/templates/multiform.js +1 -1
- package/lib/templates/page.js +1 -1
- package/lib/templates/route-test.js +1 -1
- package/lib/templates/stateful-page.js +1 -1
- package/lib/test_utils/locator_is_visible.js +1 -1
- package/lib/utils/exec.js +1 -1
- package/lib/utils/import-path.js +2 -2
- package/lib/utils/input-wrapper.js +1 -1
- package/lib/utils/list-collections.js +2 -2
- package/lib/utils/prettier.js +6 -2
- package/lib/utils/question.js +1 -1
- package/lib/utils/render-attributes.js +1 -1
- package/lib/utils/utils.js +5 -1
- package/lib/utils/walk.js +1 -1
- package/package.json +2 -2
- package/src/index.ts +1 -0
- package/src/page/list.ts +70 -67
- package/src/page/sealious-list.ts +76 -0
- package/src/templates/list.ts +7 -6
|
@@ -8,7 +8,7 @@ import { FormDataValue } from "../form";
|
|
|
8
8
|
import { FormControl } from "./controls";
|
|
9
9
|
import { FormControlContext } from "./form-control";
|
|
10
10
|
import { FormFieldControl } from "./form-field-control";
|
|
11
|
-
export
|
|
11
|
+
export type UnboundControlStorage<F extends {
|
|
12
12
|
new (...args: any): FormFieldControl;
|
|
13
13
|
} = {
|
|
14
14
|
new (...args: any): FormFieldControl;
|
|
@@ -3,7 +3,7 @@ import { EnumMultipleField, FormField } from "../fields/field";
|
|
|
3
3
|
import { CheckboxWithValue } from "./checkbox";
|
|
4
4
|
import { FormFieldControl } from "./controls";
|
|
5
5
|
import { FormControlContext } from "./form-control";
|
|
6
|
-
export
|
|
6
|
+
export type DefaultCheckboxOptions = {
|
|
7
7
|
id?: string;
|
|
8
8
|
label?: string;
|
|
9
9
|
hide_errors?: boolean;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { FlatTemplatable } from "tempstream";
|
|
2
2
|
import { FieldGroup } from "./field-group";
|
|
3
3
|
import { FormControl } from "./form-control";
|
|
4
|
-
|
|
4
|
+
type CollapsibleFieldGroupOptions = {
|
|
5
5
|
label?: string;
|
|
6
6
|
classes?: string[];
|
|
7
7
|
openOnStart?: boolean;
|
|
@@ -4,12 +4,12 @@ import { FormField, PickFromListField } from "../fields/field";
|
|
|
4
4
|
import { FormDataValue } from "../form";
|
|
5
5
|
import { FormControlContext } from "./form-control";
|
|
6
6
|
import { SimpleInput } from "./simple-input";
|
|
7
|
-
export
|
|
7
|
+
export type DropdownOptions = {
|
|
8
8
|
label: string;
|
|
9
9
|
autosubmit?: boolean;
|
|
10
10
|
autocomplete?: boolean;
|
|
11
11
|
};
|
|
12
|
-
export
|
|
12
|
+
export type DropdownOption = {
|
|
13
13
|
value: string;
|
|
14
14
|
label: string;
|
|
15
15
|
};
|
|
@@ -2,7 +2,7 @@ import { FlatTemplatable } from "tempstream";
|
|
|
2
2
|
import { FormField } from "../fields/field";
|
|
3
3
|
import { FieldValueType } from "../form";
|
|
4
4
|
import { FormControl, FormControlContext } from "./form-control";
|
|
5
|
-
export
|
|
5
|
+
export type FormFieldsToTypes<FormFields extends readonly FormField[]> = {
|
|
6
6
|
[Index in keyof FormFields]: FormFields[Index] extends FormField ? FieldValueType<FormFields[Index]> : never;
|
|
7
7
|
};
|
|
8
8
|
export declare abstract class FormFieldControl extends FormControl {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { FlatTemplatable } from "tempstream";
|
|
2
2
|
import { FormControl } from "./controls";
|
|
3
3
|
import { FormControlContext } from "./form-control";
|
|
4
|
-
|
|
4
|
+
type Renderer = ((fctx: FormControlContext) => FlatTemplatable) | FlatTemplatable;
|
|
5
5
|
export declare class HTML extends FormControl {
|
|
6
6
|
role: "decoration" | "submit";
|
|
7
7
|
renderer: Renderer;
|
|
@@ -7,7 +7,7 @@ import { FlatTemplatable } from "tempstream";
|
|
|
7
7
|
import { MultipleFiles as MultipleFilesField } from "../fields/multiple-files";
|
|
8
8
|
import { FormFieldControl } from "./form-field-control";
|
|
9
9
|
import { FormControlContext } from "./form-control";
|
|
10
|
-
export
|
|
10
|
+
export type MultipleFilesOptions = {
|
|
11
11
|
label?: string;
|
|
12
12
|
uploadLabel?: string;
|
|
13
13
|
getAdditionalFields: (ctx: Context, file: SealiousFile) => Promise<Record<string, unknown>>;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { NumberField } from "../fields/field";
|
|
2
2
|
import { FormControlContext } from "./form-control";
|
|
3
3
|
import { SimpleInput, SimpleInputOptions } from "./simple-input";
|
|
4
|
-
export
|
|
4
|
+
export type NumberOptions = SimpleInputOptions & Partial<{
|
|
5
5
|
step: number;
|
|
6
6
|
}>;
|
|
7
7
|
export declare class Number extends SimpleInput<number | null> {
|
|
@@ -4,7 +4,7 @@ import { FormField } from "../fields/field";
|
|
|
4
4
|
import { FormDataValue } from "../form";
|
|
5
5
|
import { FormFieldControl } from "./controls";
|
|
6
6
|
import { FormControlContext } from "./form-control";
|
|
7
|
-
export
|
|
7
|
+
export type SimpleInputOptions = {
|
|
8
8
|
id?: string;
|
|
9
9
|
label?: string;
|
|
10
10
|
autocomplete?: boolean;
|
|
@@ -4,7 +4,7 @@ import { FormField } from "../fields/field";
|
|
|
4
4
|
import { FormDataValue } from "../form";
|
|
5
5
|
import { FormFieldControl } from "./controls";
|
|
6
6
|
import { FormControlContext } from "./form-control";
|
|
7
|
-
export
|
|
7
|
+
export type TickableOptions = {
|
|
8
8
|
id?: string;
|
|
9
9
|
name?: string;
|
|
10
10
|
label?: string;
|
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
import { Predicate, predicates } from "@sealcode/ts-predicates";
|
|
2
2
|
import { Context } from "koa";
|
|
3
3
|
import { FormDataValue } from "../form";
|
|
4
|
-
export
|
|
4
|
+
export type FormFieldValidationResponse = {
|
|
5
5
|
valid: boolean;
|
|
6
6
|
message: string;
|
|
7
7
|
};
|
|
8
|
-
export
|
|
9
|
-
export
|
|
10
|
-
export
|
|
11
|
-
export
|
|
8
|
+
export type FormFieldValidationFn<ValueType> = (ctx: Context, value: ValueType, field: FormField<boolean, ValueType>) => Promise<FormFieldValidationResponse>;
|
|
9
|
+
export type FieldParsedValue<T> = T extends FormField<infer R> ? R : never;
|
|
10
|
+
export type GetPredicate<F extends FormField> = F extends FormField<true> ? F["predicate"] : F["predicate"] | typeof predicates.undefined;
|
|
11
|
+
export type FieldsToShape<T extends Record<string, FormField>> = {
|
|
12
12
|
[property in keyof T]: GetPredicate<T[property]>;
|
|
13
13
|
};
|
|
14
14
|
export declare function fieldsToShape<Fields extends Record<string, FormField>>(obj: Fields): FieldsToShape<Fields>;
|
|
15
|
-
export
|
|
15
|
+
export type FieldParseResult<T> = {
|
|
16
16
|
parsable: true;
|
|
17
17
|
error: null;
|
|
18
18
|
parsed_value: T;
|
|
@@ -2,7 +2,7 @@ import { Context } from "koa";
|
|
|
2
2
|
import { File as SealiousFile } from "sealious";
|
|
3
3
|
import { FormDataValue } from "../form";
|
|
4
4
|
import { FieldParseResult, FormField } from "./field";
|
|
5
|
-
export
|
|
5
|
+
export type FileContainer = {
|
|
6
6
|
old: SealiousFile | null;
|
|
7
7
|
new: SealiousFile | null;
|
|
8
8
|
};
|
package/@types/forms/form.d.ts
CHANGED
|
@@ -5,21 +5,21 @@ import Router from "@koa/router";
|
|
|
5
5
|
import { FlatTemplatable } from "tempstream";
|
|
6
6
|
import { FormField } from "./fields/field";
|
|
7
7
|
import { Fields, MountableWithFields, PageErrorMessage } from "../page/mountable-with-fields";
|
|
8
|
-
export
|
|
9
|
-
export
|
|
10
|
-
export
|
|
11
|
-
export
|
|
8
|
+
export type FormDataPrimitive = string | string[] | number | undefined;
|
|
9
|
+
export type FormDataValue = FormDataPrimitive | Record<string, FormDataPrimitive> | SealiousFile;
|
|
10
|
+
export type FieldValueType<F extends FormField> = F extends FormField<infer R> ? R : never;
|
|
11
|
+
export type FormFieldsToValues<F extends Record<string, FormField<boolean, keyof F>>> = {
|
|
12
12
|
[Property in keyof F]: FieldValueType<F[Property]>;
|
|
13
13
|
};
|
|
14
|
-
export
|
|
14
|
+
export type FormMessage = {
|
|
15
15
|
type: "info" | "success" | "error";
|
|
16
16
|
text: string;
|
|
17
17
|
};
|
|
18
|
-
export
|
|
18
|
+
export type FormData<Fieldnames extends string = string> = {
|
|
19
19
|
raw_values: Record<Fieldnames, FormDataValue>;
|
|
20
20
|
messages: FormMessage[];
|
|
21
21
|
};
|
|
22
|
-
export
|
|
22
|
+
export type FormReaction = {
|
|
23
23
|
action: "stay";
|
|
24
24
|
content: FlatTemplatable;
|
|
25
25
|
messages?: FormMessage[];
|
package/@types/index.d.ts
CHANGED
|
@@ -16,6 +16,7 @@ export * from "./forms/form";
|
|
|
16
16
|
export * from "./page/props-parser";
|
|
17
17
|
export * from "./utils/utils";
|
|
18
18
|
export * from "./page/list";
|
|
19
|
+
export * from "./page/sealious-list";
|
|
19
20
|
export * from "./utils/translate";
|
|
20
21
|
export * as sanitize from "./sanitize";
|
|
21
22
|
export * from "./forms/multiform";
|
package/@types/page/list.d.ts
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import { Context } from "koa";
|
|
2
|
-
import { Collection, CollectionItem, ItemList, Context as SealiousContext } from "sealious";
|
|
3
2
|
import { Templatable, FlatTemplatable } from "tempstream";
|
|
4
3
|
import { Page } from "./page";
|
|
5
4
|
import { ShapeToType } from "@sealcode/ts-predicates";
|
|
6
5
|
import { FormControl } from "../forms/controls/controls";
|
|
7
|
-
import { FormField, NumberField } from "../forms/fields/field";
|
|
6
|
+
import { FormField, NumberField, SimpleFormField } from "../forms/fields/field";
|
|
8
7
|
import { FormDataValue } from "..";
|
|
9
8
|
export declare const BasePagePropsShape: {};
|
|
10
|
-
export
|
|
9
|
+
export type BasePageProps = ShapeToType<typeof BasePagePropsShape>;
|
|
11
10
|
export declare const BaseListPageFields: {
|
|
12
11
|
readonly page: NumberField<1, false>;
|
|
13
12
|
readonly itemsPerPage: NumberField<12, false>;
|
|
13
|
+
readonly sort: SimpleFormField<false>;
|
|
14
14
|
};
|
|
15
15
|
export declare abstract class ListPage<ItemType, F extends typeof BaseListPageFields> extends Page<F> {
|
|
16
16
|
abstract getItems(ctx: Context, page: number, itemsPerPage: number, values: Record<string, FormDataValue>): Promise<ItemType[]>;
|
|
@@ -29,19 +29,15 @@ export declare abstract class ListPage<ItemType, F extends typeof BaseListPageFi
|
|
|
29
29
|
renderPagination(ctx: Context, values: Record<string, FormDataValue>): Promise<FlatTemplatable>;
|
|
30
30
|
private renderPageButton;
|
|
31
31
|
getFilterValues(ctx: Context): Promise<Record<string, unknown>>;
|
|
32
|
+
getSort(ctx: Context): Promise<{
|
|
33
|
+
field: string;
|
|
34
|
+
order: "asc" | "desc";
|
|
35
|
+
} | null>;
|
|
36
|
+
makeSortLink(ctx: Context, field: string, order: "asc" | "desc"): string;
|
|
32
37
|
renderFilters(ctx: Context): Promise<FlatTemplatable>;
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
getTotalPages(ctx: Context, itemsPerPage: number): Promise<number>;
|
|
39
|
-
protected addFilter(ctx: Context, list: ItemList<C>): Promise<void>;
|
|
40
|
-
makeQuery(ctx: Context): Promise<ItemList<C>>;
|
|
41
|
-
getItems(ctx: Context, page: number, itemsPerPage: number): Promise<CollectionItem<C>[]>;
|
|
42
|
-
renderItem(_: Context, item: CollectionItem<C>, index: number): Promise<FlatTemplatable>;
|
|
43
|
-
canAccess: (ctx: Context) => Promise<{
|
|
44
|
-
canAccess: boolean;
|
|
45
|
-
message: string;
|
|
46
|
-
}>;
|
|
38
|
+
renderHeading(ctx: Context, field: string, label?: string): FlatTemplatable;
|
|
39
|
+
renderTableHead(ctx: Context, fields: {
|
|
40
|
+
field: string;
|
|
41
|
+
label?: string;
|
|
42
|
+
}[]): FlatTemplatable;
|
|
47
43
|
}
|
|
@@ -5,11 +5,11 @@ import { FormControl, FormControlContext } from "../forms/controls/form-control"
|
|
|
5
5
|
import { FieldsToShape, FormField } from "../forms/fields/field";
|
|
6
6
|
import { FormData, FormDataValue, FormMessage } from "../forms/form";
|
|
7
7
|
import { Mountable } from "./mountable";
|
|
8
|
-
export
|
|
8
|
+
export type PageErrorMessage = {
|
|
9
9
|
type: "access" | "internal";
|
|
10
10
|
message: string;
|
|
11
11
|
};
|
|
12
|
-
export
|
|
12
|
+
export type Fields = Record<string, FormField<boolean, any>>;
|
|
13
13
|
export declare abstract class MountableWithFields<F extends Fields = Fields> extends Mountable {
|
|
14
14
|
fields: F;
|
|
15
15
|
field_names_prefix: string;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Context } from "koa";
|
|
2
2
|
import { FormData, FormDataValue } from "..";
|
|
3
3
|
import { BasePageProps } from "./list";
|
|
4
|
-
export
|
|
4
|
+
export type EncodedProps = Record<string, unknown>;
|
|
5
5
|
export declare abstract class PagePropsParser<PropsType> {
|
|
6
6
|
abstract decode(ctx: Context): Record<string, FormDataValue>;
|
|
7
7
|
abstract encode(props: Record<string, FormData>): EncodedProps;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { Context } from "koa";
|
|
2
|
+
import { BaseListPageFields, ListPage } from "./list";
|
|
3
|
+
import { Collection, CollectionItem, ItemList, Context as SealiousContext } from "sealious";
|
|
4
|
+
import { FlatTemplatable } 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): Promise<CollectionItem<C>[]>;
|
|
13
|
+
renderItem(_: Context, item: CollectionItem<C>, index: number): Promise<FlatTemplatable>;
|
|
14
|
+
canAccess: (ctx: Context) => Promise<{
|
|
15
|
+
canAccess: boolean;
|
|
16
|
+
message: string;
|
|
17
|
+
}>;
|
|
18
|
+
}
|
package/@types/utils/utils.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
export
|
|
2
|
-
export
|
|
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
3
|
export declare function keys<S extends string>(object: Record<S, unknown>): S[];
|
|
4
|
-
export
|
|
4
|
+
export type ExtractTail<T extends any[]> = T extends [infer _, ...infer Tail] ? Tail : never;
|
|
5
5
|
export { sleep } from "./sleep";
|
|
6
6
|
export { naturalNumbers } from "./natural-numbers";
|
|
7
7
|
export { UrlWithNewParams } from "./url-with-new-params";
|
package/lib/add-collection.js
CHANGED
|
@@ -10,22 +10,22 @@ const fs_1 = require("fs");
|
|
|
10
10
|
const question_1 = require("./utils/question");
|
|
11
11
|
const collection_1 = require("./templates/collection");
|
|
12
12
|
const generate_collections_1 = require("./generate-collections");
|
|
13
|
-
const target_locreq = locreq_1.default(process.cwd());
|
|
13
|
+
const target_locreq = (0, locreq_1.default)(process.cwd());
|
|
14
14
|
async function addCollection() {
|
|
15
15
|
const regex_pattern = /^([A-Z_$][a-zA-Z0-9_$]*)$/;
|
|
16
|
-
const collection_name = await question_1.question('What\'s the name of the collection class (e.g. "SecretDocuments", must start with a capital letter): ', (s) => s.length > 3 && regex_pattern.test(s));
|
|
17
|
-
const url = await question_1.question("Enter the url-friendly name for the collection (e.g. secret-documents): ", (s) => !s.includes("/") && !s.includes(" "));
|
|
16
|
+
const collection_name = await (0, question_1.question)('What\'s the name of the collection class (e.g. "SecretDocuments", must start with a capital letter): ', (s) => s.length > 3 && regex_pattern.test(s));
|
|
17
|
+
const url = await (0, question_1.question)("Enter the url-friendly name for the collection (e.g. secret-documents): ", (s) => !s.includes("/") && !s.includes(" "));
|
|
18
18
|
const file_path = target_locreq.resolve(`src/back/collections/${url}.ts`);
|
|
19
|
-
if (fs_1.existsSync(file_path)) {
|
|
19
|
+
if ((0, fs_1.existsSync)(file_path)) {
|
|
20
20
|
// eslint-disable-next-line no-console
|
|
21
21
|
console.error(`ERROR: File ${file_path} already exists.`);
|
|
22
22
|
return;
|
|
23
23
|
}
|
|
24
|
-
await fs_1.promises.mkdir(path_1.resolve(file_path, "../"), { recursive: true });
|
|
25
|
-
await fs_1.promises.writeFile(file_path, collection_1.collectionTemplate(collection_name));
|
|
24
|
+
await fs_1.promises.mkdir((0, path_1.resolve)(file_path, "../"), { recursive: true });
|
|
25
|
+
await fs_1.promises.writeFile(file_path, (0, collection_1.collectionTemplate)(collection_name));
|
|
26
26
|
// eslint-disable-next-line no-console
|
|
27
27
|
console.log(`${file_path} created`);
|
|
28
|
-
await generate_collections_1.generateCollections();
|
|
28
|
+
await (0, generate_collections_1.generateCollections)();
|
|
29
29
|
}
|
|
30
30
|
exports.addCollection = addCollection;
|
|
31
31
|
//# sourceMappingURL=add-collection.js.map
|
package/lib/add-route.js
CHANGED
|
@@ -19,7 +19,7 @@ const prompts = require("prompts");
|
|
|
19
19
|
const post_1 = require("./templates/post");
|
|
20
20
|
const stateful_page_1 = require("./templates/stateful-page");
|
|
21
21
|
async function addRoute(params, app_directory = process.cwd()) {
|
|
22
|
-
const target_locreq = locreq_1.default(app_directory);
|
|
22
|
+
const target_locreq = (0, locreq_1.default)(app_directory);
|
|
23
23
|
prompts.override(params);
|
|
24
24
|
const response = await prompts([
|
|
25
25
|
{
|
|
@@ -50,8 +50,8 @@ async function addRoute(params, app_directory = process.cwd()) {
|
|
|
50
50
|
},
|
|
51
51
|
]);
|
|
52
52
|
const { action, url, mode } = response;
|
|
53
|
-
const file_path = target_locreq.resolve(`src/back/routes/${escape_url_params_1.escape_url_params(url)}.${mode}.ts`);
|
|
54
|
-
const test_file_path = target_locreq.resolve(`src/back/routes/${escape_url_params_1.escape_url_params(url)}.test.ts`);
|
|
53
|
+
const file_path = target_locreq.resolve(`src/back/routes/${(0, escape_url_params_1.escape_url_params)(url)}.${mode}.ts`);
|
|
54
|
+
const test_file_path = target_locreq.resolve(`src/back/routes/${(0, escape_url_params_1.escape_url_params)(url)}.test.ts`);
|
|
55
55
|
const template = {
|
|
56
56
|
page: page_1.pageTemplate,
|
|
57
57
|
form: form_1.formTemplate,
|
|
@@ -64,19 +64,19 @@ async function addRoute(params, app_directory = process.cwd()) {
|
|
|
64
64
|
if (!template) {
|
|
65
65
|
throw new Error(`Could not get template ${mode}`);
|
|
66
66
|
}
|
|
67
|
-
if (fs_1.existsSync(file_path)) {
|
|
67
|
+
if ((0, fs_1.existsSync)(file_path)) {
|
|
68
68
|
// eslint-disable-next-line no-console
|
|
69
69
|
console.error(`ERROR: File ${file_path} already exists.`);
|
|
70
70
|
return;
|
|
71
71
|
}
|
|
72
|
-
await fs_1.promises.mkdir(path_1.resolve(file_path, "../"), { recursive: true });
|
|
72
|
+
await fs_1.promises.mkdir((0, path_1.resolve)(file_path, "../"), { recursive: true });
|
|
73
73
|
await fs_1.promises.writeFile(file_path, await template(action, file_path));
|
|
74
|
-
await fs_1.promises.writeFile(test_file_path, route_test_1.testTemplate(action, file_path));
|
|
74
|
+
await fs_1.promises.writeFile(test_file_path, (0, route_test_1.testTemplate)(action, file_path));
|
|
75
75
|
// eslint-disable-next-line no-console
|
|
76
76
|
console.log(`${file_path} created`);
|
|
77
77
|
// eslint-disable-next-line no-console
|
|
78
78
|
console.log(`${test_file_path} created`);
|
|
79
|
-
await generate_routes_1.generateRoutes();
|
|
79
|
+
await (0, generate_routes_1.generateRoutes)();
|
|
80
80
|
}
|
|
81
81
|
exports.addRoute = addRoute;
|
|
82
82
|
//# sourceMappingURL=add-route.js.map
|
package/lib/add-route.test.js
CHANGED
|
@@ -9,7 +9,7 @@ const util_1 = require("util");
|
|
|
9
9
|
const axios_1 = __importDefault(require("axios"));
|
|
10
10
|
const wait_port_1 = __importDefault(require("wait-port"));
|
|
11
11
|
const get_port_1 = __importDefault(require("get-port"));
|
|
12
|
-
const execAsync = util_1.promisify(child_process_1.exec);
|
|
12
|
+
const execAsync = (0, util_1.promisify)(child_process_1.exec);
|
|
13
13
|
describe("add route test", () => {
|
|
14
14
|
let node_pid = 0;
|
|
15
15
|
const app_path = "/tmp/sealious-minimal";
|
|
@@ -31,17 +31,17 @@ describe("add route test", () => {
|
|
|
31
31
|
console.log("\trunning add-route and building app...");
|
|
32
32
|
await execAsync(`cd ${app_path} && npx sealgen add-route --url=/sample --action=Sample --mode=page && npm run build`);
|
|
33
33
|
console.log("\tstarting the database...(if timeouts here, run 'docker pull mongo:4.4-bionic' to solve)");
|
|
34
|
-
const port = await get_port_1.default();
|
|
34
|
+
const port = await (0, get_port_1.default)();
|
|
35
35
|
await execAsync(`docker run -p ${port}:27017 --name ${container_name} -d mongo:4.4-bionic`);
|
|
36
36
|
console.log("\trunning app and making request to the generated url...");
|
|
37
37
|
const env = { ...process.env, SEALIOUS_MONGO_PORT: port.toString() };
|
|
38
|
-
let app_start = child_process_1.spawn(`node`, [`${app_path}/dist/back/index.js`], {
|
|
38
|
+
let app_start = (0, child_process_1.spawn)(`node`, [`${app_path}/dist/back/index.js`], {
|
|
39
39
|
env,
|
|
40
40
|
});
|
|
41
41
|
if (app_start.pid == undefined)
|
|
42
42
|
throw new Error("node failed to start");
|
|
43
43
|
node_pid = app_start.pid;
|
|
44
|
-
await wait_port_1.default({
|
|
44
|
+
await (0, wait_port_1.default)({
|
|
45
45
|
host: "localhost",
|
|
46
46
|
port: 8080,
|
|
47
47
|
output: "silent",
|
package/lib/build.js
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
3
|
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
5
9
|
}) : (function(o, m, k, k2) {
|
|
6
10
|
if (k2 === undefined) k2 = k;
|
|
7
11
|
o[k2] = m[k];
|
|
@@ -32,10 +36,10 @@ const sleep_1 = require("./utils/sleep");
|
|
|
32
36
|
const generate_collections_1 = require("./generate-collections");
|
|
33
37
|
const generate_routes_1 = require("./generate-routes");
|
|
34
38
|
async function build_ts() {
|
|
35
|
-
await Promise.all([generate_collections_1.generateCollections(), generate_routes_1.generateRoutes()]);
|
|
36
|
-
const entryPoints = (await tiny_glob_1.default("./src/back/**/*.ts")).filter((path) => !path.includes(".#"));
|
|
39
|
+
await Promise.all([(0, generate_collections_1.generateCollections)(), (0, generate_routes_1.generateRoutes)()]);
|
|
40
|
+
const entryPoints = (await (0, tiny_glob_1.default)("./src/back/**/*.ts")).filter((path) => !path.includes(".#"));
|
|
37
41
|
try {
|
|
38
|
-
await esbuild_1.build({
|
|
42
|
+
await (0, esbuild_1.build)({
|
|
39
43
|
entryPoints,
|
|
40
44
|
sourcemap: true,
|
|
41
45
|
outdir: "./dist/back",
|
|
@@ -60,14 +64,14 @@ async function complex_build(watch) {
|
|
|
60
64
|
return;
|
|
61
65
|
if (path.endsWith(".scss") && !path.endsWith("/includes.scss")) {
|
|
62
66
|
// refresh the list of all scss files in includes.scss
|
|
63
|
-
await find_scss_includes_1.generateScssIncludes();
|
|
67
|
+
await (0, find_scss_includes_1.generateScssIncludes)();
|
|
64
68
|
try {
|
|
65
69
|
await scss_build?.rebuild?.();
|
|
66
70
|
console.log(`Built main.scss [on ${path}]`);
|
|
67
71
|
}
|
|
68
72
|
catch (e) {
|
|
69
73
|
console.error(e.message);
|
|
70
|
-
await sleep_1.sleep(200);
|
|
74
|
+
await (0, sleep_1.sleep)(200);
|
|
71
75
|
scss_build
|
|
72
76
|
?.rebuild?.()
|
|
73
77
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
@@ -83,21 +87,21 @@ async function complex_build(watch) {
|
|
|
83
87
|
}
|
|
84
88
|
});
|
|
85
89
|
}
|
|
86
|
-
await find_scss_includes_1.generateScssIncludes();
|
|
87
|
-
scss_build = await esbuild_1.build({
|
|
90
|
+
await (0, find_scss_includes_1.generateScssIncludes)();
|
|
91
|
+
scss_build = await (0, esbuild_1.build)({
|
|
88
92
|
entryPoints: ["./src/main.scss"],
|
|
89
93
|
sourcemap: true,
|
|
90
94
|
outfile: "./public/dist/style.css",
|
|
91
95
|
logLevel: "info",
|
|
92
96
|
incremental: watch,
|
|
93
|
-
plugins: [esbuild_sass_plugin_1.sassPlugin()],
|
|
97
|
+
plugins: [(0, esbuild_sass_plugin_1.sassPlugin)()],
|
|
94
98
|
});
|
|
95
99
|
await build_ts();
|
|
96
100
|
watch && scss_build?.rebuild?.();
|
|
97
101
|
}
|
|
98
102
|
async function buildProject({ watch, }) {
|
|
99
103
|
try {
|
|
100
|
-
await esbuild_1.build({
|
|
104
|
+
await (0, esbuild_1.build)({
|
|
101
105
|
entryPoints: ["./src/front/index.ts"],
|
|
102
106
|
sourcemap: true,
|
|
103
107
|
outfile: "./public/dist/bundle.js",
|
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
3
|
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
5
9
|
}) : (function(o, m, k, k2) {
|
|
6
10
|
if (k2 === undefined) k2 = k;
|
|
7
11
|
o[k2] = m[k];
|
package/lib/components/tabs.js
CHANGED
|
@@ -52,7 +52,7 @@ const style = (hide_tabs_width) => /* HTML */ `<style>
|
|
|
52
52
|
}
|
|
53
53
|
</style>`;
|
|
54
54
|
function tabs(tabs, selected_tab_style = "font-weight: bold;", selected_index = 0, hide_tabs_width = 0) {
|
|
55
|
-
return /* HTML */ tempstream_1.tempstream `${style(hide_tabs_width)}
|
|
55
|
+
return /* HTML */ (0, tempstream_1.tempstream) `${style(hide_tabs_width)}
|
|
56
56
|
${Object.keys(tabs)
|
|
57
57
|
.map((tab_title, index) => {
|
|
58
58
|
const id = name_to_id(tab_title);
|
|
@@ -71,7 +71,7 @@ function tabs(tabs, selected_tab_style = "font-weight: bold;", selected_index =
|
|
|
71
71
|
.join("\n")}
|
|
72
72
|
${Object.entries(tabs).map(([title, content]) => {
|
|
73
73
|
const id = name_to_id(title);
|
|
74
|
-
return /* HTML */ tempstream_1.tempstream `<div class="tab-label tab-label--mobile">
|
|
74
|
+
return /* HTML */ (0, tempstream_1.tempstream) `<div class="tab-label tab-label--mobile">
|
|
75
75
|
${title}
|
|
76
76
|
</div>
|
|
77
77
|
<div class="tab-content tab-content--${id}">${content}</div>
|
|
@@ -5,8 +5,8 @@ const tempstream_1 = require("tempstream");
|
|
|
5
5
|
const utils_1 = require("../utils/utils");
|
|
6
6
|
function toggleModal(options) {
|
|
7
7
|
const { contentWrapped, contentUnwrapped, name } = options;
|
|
8
|
-
const id = utils_1.makeSlug(name);
|
|
9
|
-
return tempstream_1.tempstream /* HTML */ `<style>
|
|
8
|
+
const id = (0, utils_1.makeSlug)(name);
|
|
9
|
+
return (0, tempstream_1.tempstream /* HTML */) `<style>
|
|
10
10
|
.toggle-modal__wrapped {
|
|
11
11
|
display: none;
|
|
12
12
|
}
|
|
@@ -8,14 +8,14 @@ const fs_1 = require("fs");
|
|
|
8
8
|
const locreq_1 = __importDefault(require("locreq"));
|
|
9
9
|
const path_1 = require("path");
|
|
10
10
|
const walk_1 = require("./utils/walk");
|
|
11
|
-
const target_locreq = locreq_1.default(process.cwd());
|
|
11
|
+
const target_locreq = (0, locreq_1.default)(process.cwd());
|
|
12
12
|
async function generateScssIncludes() {
|
|
13
|
-
const files = await Promise.all((await walk_1.walkDir(target_locreq.resolve("src/")))
|
|
13
|
+
const files = await Promise.all((await (0, walk_1.walkDir)(target_locreq.resolve("src/")))
|
|
14
14
|
.filter((f) => f.endsWith(".scss") &&
|
|
15
15
|
!f.endsWith("/main.scss") &&
|
|
16
16
|
!f.endsWith("/includes.scss") &&
|
|
17
17
|
!f.includes(".#"))
|
|
18
|
-
.map((fullpath) => path_1.relative(target_locreq.resolve("src/"), fullpath)));
|
|
18
|
+
.map((fullpath) => (0, path_1.relative)(target_locreq.resolve("src/"), fullpath)));
|
|
19
19
|
await fs_1.promises.writeFile(target_locreq.resolve("src/includes.scss"), `// DO NOT EDIT! This file is generated automaticaly with npx sealgen generate-scss-includes
|
|
20
20
|
|
|
21
21
|
@import "../node_modules/@sealcode/sealgen/src/forms/forms.scss";
|
|
@@ -61,7 +61,7 @@ class StructuredArray extends form_field_control_1.FormFieldControl {
|
|
|
61
61
|
inner_form_id: this.getInnerFormID(),
|
|
62
62
|
field_name: field.name,
|
|
63
63
|
}));
|
|
64
|
-
return tempstream_1.tempstream `${new constructor(field, params).render({
|
|
64
|
+
return (0, tempstream_1.tempstream) `${new constructor(field, params).render({
|
|
65
65
|
...fctx,
|
|
66
66
|
data: { [field.name]: item[field_name] },
|
|
67
67
|
})}${hidden_shadow.render({
|
|
@@ -75,7 +75,7 @@ class StructuredArray extends form_field_control_1.FormFieldControl {
|
|
|
75
75
|
}
|
|
76
76
|
}
|
|
77
77
|
async renderItem(ctx, form_id, item, index) {
|
|
78
|
-
return tempstream_1.tempstream /* HTML */ `<div>
|
|
78
|
+
return (0, tempstream_1.tempstream /* HTML */) `<div>
|
|
79
79
|
${this.item_controls.map((control) => this.renderItemControl(ctx, form_id, control, item, index))}
|
|
80
80
|
<input
|
|
81
81
|
type="submit"
|
|
@@ -92,7 +92,7 @@ class StructuredArray extends form_field_control_1.FormFieldControl {
|
|
|
92
92
|
}
|
|
93
93
|
async _render(ctx, form_id, raw_values) {
|
|
94
94
|
const items = await this.getItems(ctx, raw_values);
|
|
95
|
-
return tempstream_1.tempstream /* HTML */ `<turbo-frame id="${this.getFrameID()}">
|
|
95
|
+
return (0, tempstream_1.tempstream /* HTML */) `<turbo-frame id="${this.getFrameID()}">
|
|
96
96
|
Reverse Single Reference
|
|
97
97
|
${items.map((item, index) => this.renderItem(ctx, form_id, item, index))}
|
|
98
98
|
<form id="${this.getInnerFormID()}" method="POST"></form>
|
|
@@ -120,12 +120,12 @@ class StructuredArray extends form_field_control_1.FormFieldControl {
|
|
|
120
120
|
throw new Error("Missing form_id query param");
|
|
121
121
|
}
|
|
122
122
|
const item = await this.field.sealious_field.collection.getByID(ctx.$context, await this.getTargetItemID(ctx));
|
|
123
|
-
if (!ts_predicates_1.hasShape({ action: ts_predicates_1.predicates.object }, ctx.$body)) {
|
|
123
|
+
if (!(0, ts_predicates_1.hasShape)({ action: ts_predicates_1.predicates.object }, ctx.$body)) {
|
|
124
124
|
throw new Error("Missing action param");
|
|
125
125
|
}
|
|
126
126
|
const field_data = ctx.$body[this.field.name] || { data: [] };
|
|
127
127
|
console.log({ action: field_data });
|
|
128
|
-
if (!ts_predicates_1.hasShape({
|
|
128
|
+
if (!(0, ts_predicates_1.hasShape)({
|
|
129
129
|
data: ts_predicates_1.predicates.array(this.field.sealious_field.value_predicate),
|
|
130
130
|
}, field_data)) {
|
|
131
131
|
throw new Error("missing data atribute in action description");
|
|
@@ -11,10 +11,10 @@ class BigRadioGroup extends form_field_control_1.FormFieldControl {
|
|
|
11
11
|
}
|
|
12
12
|
async render(fctx) {
|
|
13
13
|
const { raw: current_value } = await this.field.getValue(fctx.ctx, fctx.data);
|
|
14
|
-
return tempstream_1.tempstream /* HTML */ `<div class="bigradios">
|
|
14
|
+
return (0, tempstream_1.tempstream /* HTML */) `<div class="bigradios">
|
|
15
15
|
${Object.entries(this.options).map(([key, { description }]) => {
|
|
16
16
|
const id = `${this.field.name}-radio-${key}`;
|
|
17
|
-
return tempstream_1.tempstream /* HTML */ `<input
|
|
17
|
+
return (0, tempstream_1.tempstream /* HTML */) `<input
|
|
18
18
|
type="radio"
|
|
19
19
|
name="${this.field.name}"
|
|
20
20
|
value="${key}"
|
|
@@ -13,7 +13,7 @@ class CheckboxedListInput extends controls_1.FormFieldControl {
|
|
|
13
13
|
}
|
|
14
14
|
async render(fctx) {
|
|
15
15
|
const { parsed: pickedValues } = await this.field.getValue(fctx.ctx, fctx.data);
|
|
16
|
-
if (!ts_predicates_1.is(pickedValues, ts_predicates_1.predicates.array(ts_predicates_1.predicates.string))) {
|
|
16
|
+
if (!(0, ts_predicates_1.is)(pickedValues, ts_predicates_1.predicates.array(ts_predicates_1.predicates.string))) {
|
|
17
17
|
throw new Error("picked values is not an array of strings");
|
|
18
18
|
}
|
|
19
19
|
const [options, isVisible] = await Promise.all([
|
|
@@ -21,8 +21,8 @@ class CheckboxedListInput extends controls_1.FormFieldControl {
|
|
|
21
21
|
this.field.isVisible(fctx.ctx),
|
|
22
22
|
]);
|
|
23
23
|
const { name, required } = this.field;
|
|
24
|
-
return tempstream_1.tempstream /* HTML */ `${isVisible
|
|
25
|
-
? Object.entries(options).map(([value, text]) => input_wrapper_1.inputWrapper([name, input_wrapper_1.getRequiredClass(required)],
|
|
24
|
+
return (0, tempstream_1.tempstream /* HTML */) `${isVisible
|
|
25
|
+
? Object.entries(options).map(([value, text]) => (0, input_wrapper_1.inputWrapper)([name, (0, input_wrapper_1.getRequiredClass)(required)],
|
|
26
26
|
/* HTML */ `
|
|
27
27
|
<input
|
|
28
28
|
type="checkbox"
|
|
@@ -9,7 +9,7 @@ class CollapsibleFieldGroup extends field_group_1.FieldGroup {
|
|
|
9
9
|
this.controls = controls;
|
|
10
10
|
this.options = options;
|
|
11
11
|
if (this.options.groupID == undefined) {
|
|
12
|
-
this.options.groupID = "A" + crypto_1.randomUUID(); // "A" is needed as ids always have to start with a letter
|
|
12
|
+
this.options.groupID = "A" + (0, crypto_1.randomUUID)(); // "A" is needed as ids always have to start with a letter
|
|
13
13
|
}
|
|
14
14
|
this.collapseID = this.options.groupID + "collapse";
|
|
15
15
|
}
|