@sealcode/sealgen 0.12.0 → 0.12.3
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/dist/notifier.js +1 -1
- package/package.json +2 -2
- package/src/notifier.ts +1 -1
- package/.madgerc +0 -7
- package/coverage/.tmp/coverage-15.json +0 -1
- package/coverage/.tmp/coverage-16.json +0 -1
- package/coverage/.tmp/coverage-17.json +0 -1
- package/coverage/.tmp/coverage-18.json +0 -1
- package/coverage/.tmp/coverage-19.json +0 -1
- package/coverage/.tmp/coverage-20.json +0 -1
- package/coverage/.tmp/coverage-21.json +0 -1
- package/coverage/.tmp/coverage-22.json +0 -1
- package/coverage/.tmp/coverage-23.json +0 -1
- package/coverage/.tmp/coverage-24.json +0 -1
- package/coverage/.tmp/coverage-25.json +0 -1
- package/coverage/.tmp/coverage-26.json +0 -1
- package/lib/add-collection.js +0 -24
- package/lib/add-jdd-component.js +0 -27
- package/lib/add-route.js +0 -65
- package/lib/add-route.test.js +0 -60
- package/lib/build.js +0 -187
- package/lib/cli.js +0 -35
- package/lib/components/components.js +0 -3
- package/lib/components/tabs.js +0 -88
- package/lib/components/toggle-modal.js +0 -46
- package/lib/example.test.js +0 -5
- package/lib/find-css-includes.js +0 -23
- package/lib/forms/controls/array.js +0 -140
- package/lib/forms/controls/autocomplete.js +0 -23
- package/lib/forms/controls/big-radio-group.js +0 -34
- package/lib/forms/controls/checkbox-group.js +0 -29
- package/lib/forms/controls/checkbox.js +0 -24
- package/lib/forms/controls/checkboxed-list-input.js +0 -35
- package/lib/forms/controls/collapsible-checkbox-group.js +0 -13
- package/lib/forms/controls/collapsible-field-group.js +0 -78
- package/lib/forms/controls/controls.js +0 -31
- package/lib/forms/controls/derived-frame.js +0 -52
- package/lib/forms/controls/derived.js +0 -77
- package/lib/forms/controls/dropdown.js +0 -55
- package/lib/forms/controls/editable-collection-subset.js +0 -68
- package/lib/forms/controls/field-group.js +0 -53
- package/lib/forms/controls/file.js +0 -35
- package/lib/forms/controls/form-control.js +0 -14
- package/lib/forms/controls/form-field-control.js +0 -9
- package/lib/forms/controls/form-header.js +0 -14
- package/lib/forms/controls/form-paragraph.js +0 -12
- package/lib/forms/controls/frame.js +0 -25
- package/lib/forms/controls/hidden-input.js +0 -14
- package/lib/forms/controls/html.js +0 -23
- package/lib/forms/controls/multiple-files.js +0 -160
- package/lib/forms/controls/multiple-photos.js +0 -33
- package/lib/forms/controls/number.js +0 -25
- package/lib/forms/controls/photo.js +0 -57
- package/lib/forms/controls/radio.js +0 -25
- package/lib/forms/controls/reverse-single-reference.js +0 -47
- package/lib/forms/controls/simple-input.js +0 -78
- package/lib/forms/controls/textarea.js +0 -33
- package/lib/forms/controls/tickable.js +0 -75
- package/lib/forms/fields/boolean.js +0 -51
- package/lib/forms/fields/boolean.test.js +0 -32
- package/lib/forms/fields/checkboxed-list.js +0 -40
- package/lib/forms/fields/collection-field.js +0 -29
- package/lib/forms/fields/email.js +0 -11
- package/lib/forms/fields/email.test.js +0 -20
- package/lib/forms/fields/enum-multiple.js +0 -47
- package/lib/forms/fields/enum-multiple.test.js +0 -27
- package/lib/forms/fields/enum.js +0 -39
- package/lib/forms/fields/enum.test.js +0 -21
- package/lib/forms/fields/existing-sealious-value.js +0 -16
- package/lib/forms/fields/field.js +0 -81
- package/lib/forms/fields/file.js +0 -53
- package/lib/forms/fields/multiple-files.js +0 -15
- package/lib/forms/fields/number.js +0 -45
- package/lib/forms/fields/number.test.js +0 -30
- package/lib/forms/fields/pick-from-list.js +0 -31
- package/lib/forms/fields/pick-from-list.test.js +0 -17
- package/lib/forms/fields/proxy-field.js +0 -20
- package/lib/forms/fields/regexp.js +0 -40
- package/lib/forms/fields/regexp.test.js +0 -21
- package/lib/forms/fields/reverse-single-reference.js +0 -14
- package/lib/forms/fields/simple-form-field.js +0 -20
- package/lib/forms/fields/structured-array.js +0 -18
- package/lib/forms/form.js +0 -176
- package/lib/forms/form.test.js +0 -1
- package/lib/forms/multiform.js +0 -174
- package/lib/forms/multiform.test.js +0 -426
- package/lib/generate-collections.js +0 -52
- package/lib/generate-components.js +0 -33
- package/lib/generate-routes.js +0 -75
- package/lib/index.js +0 -17
- package/lib/make-env.js +0 -14
- package/lib/make-hidden-inputs.js +0 -14
- package/lib/mount.js +0 -70
- package/lib/notifier.js +0 -19
- package/lib/page/access-control.js +0 -16
- package/lib/page/default-list-filters.js +0 -40
- package/lib/page/list.js +0 -183
- package/lib/page/mountable-with-fields.js +0 -85
- package/lib/page/mountable.js +0 -5
- package/lib/page/page.js +0 -26
- package/lib/page/props-parser.js +0 -23
- package/lib/page/sealious-list.js +0 -59
- package/lib/page/stateful-page.js +0 -97
- package/lib/remove-named-imports.js +0 -47
- package/lib/run.js +0 -2
- package/lib/sanitize.js +0 -10
- package/lib/src/add-collection.js +0 -24
- package/lib/src/add-jdd-component.js +0 -27
- package/lib/src/add-route.js +0 -65
- package/lib/src/add-route.test.js +0 -72
- package/lib/src/build.js +0 -142
- package/lib/src/cli.js +0 -37
- package/lib/src/components/components.js +0 -3
- package/lib/src/components/tabs.js +0 -88
- package/lib/src/components/toggle-modal.js +0 -46
- package/lib/src/example.test.js +0 -5
- package/lib/src/find-css-includes.js +0 -23
- package/lib/src/forms/controls/array.js +0 -141
- package/lib/src/forms/controls/autocomplete.js +0 -23
- package/lib/src/forms/controls/big-radio-group.js +0 -34
- package/lib/src/forms/controls/checkbox-group.js +0 -30
- package/lib/src/forms/controls/checkbox.js +0 -24
- package/lib/src/forms/controls/checkboxed-list-input.js +0 -35
- package/lib/src/forms/controls/collapsible-checkbox-group.js +0 -13
- package/lib/src/forms/controls/collapsible-field-group.js +0 -78
- package/lib/src/forms/controls/controls.js +0 -31
- package/lib/src/forms/controls/derived-frame.js +0 -52
- package/lib/src/forms/controls/derived.js +0 -77
- package/lib/src/forms/controls/dropdown.js +0 -55
- package/lib/src/forms/controls/editable-collection-subset.js +0 -68
- package/lib/src/forms/controls/field-group.js +0 -53
- package/lib/src/forms/controls/file.js +0 -35
- package/lib/src/forms/controls/form-control.js +0 -14
- package/lib/src/forms/controls/form-field-control.js +0 -9
- package/lib/src/forms/controls/form-header.js +0 -14
- package/lib/src/forms/controls/form-paragraph.js +0 -12
- package/lib/src/forms/controls/frame.js +0 -25
- package/lib/src/forms/controls/hidden-input.js +0 -14
- package/lib/src/forms/controls/html.js +0 -23
- package/lib/src/forms/controls/multiple-files.js +0 -160
- package/lib/src/forms/controls/multiple-photos.js +0 -33
- package/lib/src/forms/controls/number.js +0 -25
- package/lib/src/forms/controls/photo.js +0 -57
- package/lib/src/forms/controls/radio.js +0 -25
- package/lib/src/forms/controls/reverse-single-reference.js +0 -47
- package/lib/src/forms/controls/simple-input.js +0 -78
- package/lib/src/forms/controls/textarea.js +0 -33
- package/lib/src/forms/controls/tickable.js +0 -75
- package/lib/src/forms/fields/boolean.js +0 -51
- package/lib/src/forms/fields/boolean.test.js +0 -33
- package/lib/src/forms/fields/checkboxed-list.js +0 -40
- package/lib/src/forms/fields/collection-field.js +0 -29
- package/lib/src/forms/fields/email.js +0 -11
- package/lib/src/forms/fields/email.test.js +0 -20
- package/lib/src/forms/fields/enum-multiple.js +0 -47
- package/lib/src/forms/fields/enum-multiple.test.js +0 -27
- package/lib/src/forms/fields/enum.js +0 -39
- package/lib/src/forms/fields/enum.test.js +0 -21
- package/lib/src/forms/fields/existing-sealious-value.js +0 -16
- package/lib/src/forms/fields/field.js +0 -66
- package/lib/src/forms/fields/fields.js +0 -16
- package/lib/src/forms/fields/file.js +0 -53
- package/lib/src/forms/fields/multiple-files.js +0 -15
- package/lib/src/forms/fields/number.js +0 -45
- package/lib/src/forms/fields/number.test.js +0 -31
- package/lib/src/forms/fields/pick-from-list.js +0 -31
- package/lib/src/forms/fields/pick-from-list.test.js +0 -17
- package/lib/src/forms/fields/proxy-field.js +0 -20
- package/lib/src/forms/fields/regexp.js +0 -40
- package/lib/src/forms/fields/regexp.test.js +0 -21
- package/lib/src/forms/fields/reverse-single-reference.js +0 -14
- package/lib/src/forms/fields/simple-form-field.js +0 -19
- package/lib/src/forms/fields/structured-array.js +0 -18
- package/lib/src/forms/form-types.js +0 -2
- package/lib/src/forms/form.js +0 -176
- package/lib/src/forms/form.test.js +0 -271
- package/lib/src/forms/multiform.js +0 -174
- package/lib/src/forms/multiform.test.js +0 -430
- package/lib/src/generate-collections.js +0 -52
- package/lib/src/generate-components.js +0 -33
- package/lib/src/generate-routes.js +0 -75
- package/lib/src/hehe.test.js +0 -7
- package/lib/src/index.js +0 -19
- package/lib/src/make-env.js +0 -14
- package/lib/src/make-hidden-inputs.js +0 -14
- package/lib/src/mount.js +0 -70
- package/lib/src/notifier.js +0 -19
- package/lib/src/page/access-control.js +0 -16
- package/lib/src/page/default-list-filters.js +0 -40
- package/lib/src/page/list.js +0 -184
- package/lib/src/page/mountable-with-fields.js +0 -85
- package/lib/src/page/mountable.js +0 -5
- package/lib/src/page/page.js +0 -26
- package/lib/src/page/props-parser.js +0 -23
- package/lib/src/page/sealious-list.js +0 -59
- package/lib/src/page/stateful-page.js +0 -97
- package/lib/src/run.js +0 -2
- package/lib/src/sample-index.js +0 -3
- package/lib/src/sample-lib.js +0 -6
- package/lib/src/sanitize.js +0 -10
- package/lib/src/templates/collection.js +0 -12
- package/lib/src/templates/form.js +0 -57
- package/lib/src/templates/jdd-component.js +0 -39
- package/lib/src/templates/list.js +0 -139
- package/lib/src/templates/long-running-process.js +0 -60
- package/lib/src/templates/multiform.js +0 -55
- package/lib/src/templates/page.js +0 -23
- package/lib/src/templates/post.js +0 -22
- package/lib/src/templates/redirect.js +0 -23
- package/lib/src/templates/route-test.js +0 -54
- package/lib/src/templates/stateful-page.js +0 -66
- package/lib/src/templates/templates.js +0 -21
- package/lib/src/test_utils/locator_is_visible.js +0 -11
- package/lib/src/utils/assert-throws.js +0 -17
- package/lib/src/utils/base64.js +0 -7
- package/lib/src/utils/browser-creator.js +0 -10
- package/lib/src/utils/escape-url-params.js +0 -14
- package/lib/src/utils/exec.js +0 -22
- package/lib/src/utils/extract-fields-from-collection.js +0 -26
- package/lib/src/utils/format-external-url.js +0 -11
- package/lib/src/utils/import-path.js +0 -16
- package/lib/src/utils/input-wrapper.js +0 -15
- package/lib/src/utils/list-collections.js +0 -13
- package/lib/src/utils/make-slug.js +0 -6
- package/lib/src/utils/natural-numbers.js +0 -6
- package/lib/src/utils/prettier.js +0 -10
- package/lib/src/utils/question.js +0 -19
- package/lib/src/utils/render-attributes.js +0 -19
- package/lib/src/utils/sleep.js +0 -4
- package/lib/src/utils/translate.js +0 -6
- package/lib/src/utils/url-with-new-params.js +0 -5
- package/lib/src/utils/utils.js +0 -16
- package/lib/src/utils/walk.js +0 -23
- package/lib/src/vitest.config.js +0 -20
- package/lib/templates/collection.js +0 -12
- package/lib/templates/form.js +0 -57
- package/lib/templates/jdd-component.js +0 -39
- package/lib/templates/list.js +0 -139
- package/lib/templates/long-running-process.js +0 -60
- package/lib/templates/multiform.js +0 -55
- package/lib/templates/page.js +0 -23
- package/lib/templates/post.js +0 -22
- package/lib/templates/redirect.js +0 -23
- package/lib/templates/route-test.js +0 -54
- package/lib/templates/stateful-page.js +0 -66
- package/lib/templates/templates.js +0 -21
- package/lib/test_utils/locator_is_visible.js +0 -11
- package/lib/utils/assert-throws.js +0 -17
- package/lib/utils/base64.js +0 -7
- package/lib/utils/browser-creator.js +0 -10
- package/lib/utils/escape-url-params.js +0 -14
- package/lib/utils/exec.js +0 -22
- package/lib/utils/extract-fields-from-collection.js +0 -26
- package/lib/utils/format-external-url.js +0 -11
- package/lib/utils/import-path.js +0 -16
- package/lib/utils/input-wrapper.js +0 -15
- package/lib/utils/list-collections.js +0 -13
- package/lib/utils/make-slug.js +0 -6
- package/lib/utils/natural-numbers.js +0 -6
- package/lib/utils/prettier.js +0 -10
- package/lib/utils/question.js +0 -19
- package/lib/utils/render-attributes.js +0 -19
- package/lib/utils/sleep.js +0 -4
- package/lib/utils/translate.js +0 -6
- package/lib/utils/url-with-new-params.js +0 -5
- package/lib/utils/utils.js +0 -16
- package/lib/utils/walk.js +0 -23
- package/lib/vitest.config.js +0 -22
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { formTemplate } from "./form.js";
|
|
2
|
-
import { jddComponentTemplate } from "./jdd-component.js";
|
|
3
|
-
import { listTemplate } from "./list.js";
|
|
4
|
-
import { LongRunningProcessTemplate } from "./long-running-process.js";
|
|
5
|
-
import { multiformTemplate } from "./multiform.js";
|
|
6
|
-
import { pageTemplate } from "./page.js";
|
|
7
|
-
import { postTemplate } from "./post.js";
|
|
8
|
-
import { redirectTemplate } from "./redirect.js";
|
|
9
|
-
import { statefulPageTemplate } from "./stateful-page.js";
|
|
10
|
-
export const Templates = {
|
|
11
|
-
page: pageTemplate,
|
|
12
|
-
form: formTemplate,
|
|
13
|
-
list: listTemplate,
|
|
14
|
-
multiform: multiformTemplate,
|
|
15
|
-
redirect: redirectTemplate,
|
|
16
|
-
post: postTemplate,
|
|
17
|
-
sreact: statefulPageTemplate,
|
|
18
|
-
lpr: LongRunningProcessTemplate,
|
|
19
|
-
jdd: jddComponentTemplate,
|
|
20
|
-
};
|
|
21
|
-
//# sourceMappingURL=templates.js.map
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { sleep } from "../utils/sleep.js";
|
|
2
|
-
export async function locator_is_visible(locator, timeout = 500) {
|
|
3
|
-
let exists = false;
|
|
4
|
-
while (timeout > 0 && !exists) {
|
|
5
|
-
await sleep(50);
|
|
6
|
-
timeout -= 50;
|
|
7
|
-
exists = await locator.isVisible();
|
|
8
|
-
}
|
|
9
|
-
return exists;
|
|
10
|
-
}
|
|
11
|
-
//# sourceMappingURL=locator_is_visible.js.map
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import assert from "assert";
|
|
2
|
-
export async function assertThrowsAsync(fn, error_handler) {
|
|
3
|
-
let error = null;
|
|
4
|
-
try {
|
|
5
|
-
await fn();
|
|
6
|
-
}
|
|
7
|
-
catch (e) {
|
|
8
|
-
error = e;
|
|
9
|
-
}
|
|
10
|
-
finally {
|
|
11
|
-
assert.notStrictEqual(error, null, "It didn't throw");
|
|
12
|
-
if (error_handler) {
|
|
13
|
-
await error_handler(error);
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
//# sourceMappingURL=assert-throws.js.map
|
package/lib/src/utils/base64.js
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { firefox } from "playwright";
|
|
2
|
-
let browser_promise = null;
|
|
3
|
-
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
|
|
4
|
-
export async function getBrowser() {
|
|
5
|
-
if (!browser_promise)
|
|
6
|
-
browser_promise = firefox.launch();
|
|
7
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
|
|
8
|
-
return browser_promise;
|
|
9
|
-
}
|
|
10
|
-
//# sourceMappingURL=browser-creator.js.map
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
export function escape_url_params(url) {
|
|
2
|
-
return url
|
|
3
|
-
.split("/")
|
|
4
|
-
.map((e) => (e.startsWith(":") ? `[${e.slice(1)}]` : e))
|
|
5
|
-
.filter((e) => e != "")
|
|
6
|
-
.join("/");
|
|
7
|
-
}
|
|
8
|
-
export function unescape_url_params(url) {
|
|
9
|
-
return url
|
|
10
|
-
.split("/")
|
|
11
|
-
.map((e) => (e.startsWith("[") ? `:${e.slice(1, e.length - 1)}` : e))
|
|
12
|
-
.join("/");
|
|
13
|
-
}
|
|
14
|
-
//# sourceMappingURL=escape-url-params.js.map
|
package/lib/src/utils/exec.js
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
/* eslint-disable no-console */
|
|
2
|
-
import { spawn } from "child_process";
|
|
3
|
-
export async function exec(program, args) {
|
|
4
|
-
return new Promise((resolve, reject) => {
|
|
5
|
-
let stdout = "";
|
|
6
|
-
let stderr = "";
|
|
7
|
-
const process = spawn(program, args);
|
|
8
|
-
process.stdout.on("data", (data) => (stdout += data.toString()));
|
|
9
|
-
process.stderr.on("data", (data) => (stderr += data.toString()));
|
|
10
|
-
process.on("close", (exitCode) => {
|
|
11
|
-
if (exitCode === 0) {
|
|
12
|
-
resolve({ stdout, stderr, exitCode });
|
|
13
|
-
}
|
|
14
|
-
else {
|
|
15
|
-
console.error([program, ...args].join(" "));
|
|
16
|
-
console.error(stderr);
|
|
17
|
-
reject({ stdout, stderr, exitCode });
|
|
18
|
-
}
|
|
19
|
-
});
|
|
20
|
-
});
|
|
21
|
-
}
|
|
22
|
-
//# sourceMappingURL=exec.js.map
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import _locreq from "locreq";
|
|
2
|
-
import { curryImportPath, exec } from "./utils.js";
|
|
3
|
-
const target_locreq = _locreq(process.cwd());
|
|
4
|
-
import { promises as fs } from "fs";
|
|
5
|
-
export default async function extract_fields_from_collection(collection_name) {
|
|
6
|
-
const rel = curryImportPath(target_locreq.resolve("dist/back"));
|
|
7
|
-
const extractor_code = `import {default as Collection} from "${rel(`./back/collections/${collection_name}.js`)}";
|
|
8
|
-
const c = new Collection();
|
|
9
|
-
const fields = [];
|
|
10
|
-
for (const field_name in c.fields){
|
|
11
|
-
const field = c.fields[field_name];
|
|
12
|
-
let type = field.typeName;
|
|
13
|
-
if(["derived-value", "cached-value"].includes(type)){
|
|
14
|
-
type = field.virtual_field.typeName
|
|
15
|
-
}
|
|
16
|
-
fields.push({name: field_name, type})
|
|
17
|
-
}
|
|
18
|
-
console.log(JSON.stringify(fields));
|
|
19
|
-
`;
|
|
20
|
-
const extractor_code_path = target_locreq.resolve("dist/back/___extract_fields.js");
|
|
21
|
-
await fs.writeFile(extractor_code_path, extractor_code);
|
|
22
|
-
const { stdout } = await exec("node", [extractor_code_path]);
|
|
23
|
-
await fs.unlink(extractor_code_path);
|
|
24
|
-
return JSON.parse(stdout);
|
|
25
|
-
}
|
|
26
|
-
//# sourceMappingURL=extract-fields-from-collection.js.map
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
// this is not an ultra-safe parser. It's meant to help parse urls that users
|
|
2
|
-
// have entered in a simple input file withour validation
|
|
3
|
-
export function formatExternalURL(url) {
|
|
4
|
-
const trimmed = url.trim();
|
|
5
|
-
if (!trimmed.toLowerCase().startsWith("https://") ||
|
|
6
|
-
!trimmed.toLowerCase().startsWith("https://")) {
|
|
7
|
-
return `http://${trimmed}`;
|
|
8
|
-
}
|
|
9
|
-
return trimmed;
|
|
10
|
-
}
|
|
11
|
-
//# sourceMappingURL=format-external-url.js.map
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { relative, dirname } from "path";
|
|
2
|
-
import _locreq from "locreq";
|
|
3
|
-
const target_locreq = _locreq(process.cwd());
|
|
4
|
-
export function importPath(project_module_path, project_target_path) {
|
|
5
|
-
let result = relative(dirname(target_locreq.resolve(project_module_path)), target_locreq.resolve(project_target_path).replace(/.tsx?$/, ".js"));
|
|
6
|
-
if (result[0] != ".") {
|
|
7
|
-
result = "./" + result;
|
|
8
|
-
}
|
|
9
|
-
return result;
|
|
10
|
-
}
|
|
11
|
-
export function curryImportPath(project_module_path) {
|
|
12
|
-
return function (project_target_path) {
|
|
13
|
-
return importPath(project_module_path, project_target_path);
|
|
14
|
-
};
|
|
15
|
-
}
|
|
16
|
-
//# sourceMappingURL=import-path.js.map
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { tempstream } from "tempstream";
|
|
2
|
-
export function getRequiredClass(isRequired) {
|
|
3
|
-
return isRequired ? "required" : "";
|
|
4
|
-
}
|
|
5
|
-
function getModifierClasses(modifiers) {
|
|
6
|
-
return modifiers.map((m) => "form-input__wrapper--" + m).join(" ");
|
|
7
|
-
}
|
|
8
|
-
export function inputWrapper(modifiers, input) {
|
|
9
|
-
return tempstream /* HTML */ `<div
|
|
10
|
-
class="form-input form-input__wrapper ${getModifierClasses(modifiers)}"
|
|
11
|
-
>
|
|
12
|
-
${input}
|
|
13
|
-
</div>`;
|
|
14
|
-
}
|
|
15
|
-
//# sourceMappingURL=input-wrapper.js.map
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import _locreq from "locreq";
|
|
2
|
-
import { walkDir } from "./walk.js";
|
|
3
|
-
const target_locreq = _locreq(process.cwd());
|
|
4
|
-
export async function listCollections() {
|
|
5
|
-
const files = await walkDir(target_locreq.resolve("src/back/collections"));
|
|
6
|
-
return files
|
|
7
|
-
.filter((f) => f.endsWith(".ts") &&
|
|
8
|
-
!f.endsWith(".test.ts") &&
|
|
9
|
-
!f.endsWith("collections.ts"))
|
|
10
|
-
.map((f) => f.replace(/.ts$/, "").split("/").at(-1) || "")
|
|
11
|
-
.filter((e) => e !== "");
|
|
12
|
-
}
|
|
13
|
-
//# sourceMappingURL=list-collections.js.map
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import * as prettier from "prettier";
|
|
2
|
-
import _locreq from "locreq";
|
|
3
|
-
const target_locreq = _locreq(process.cwd());
|
|
4
|
-
export async function getPrettierConfig() {
|
|
5
|
-
return {
|
|
6
|
-
...(await prettier.resolveConfig(target_locreq.resolve("src/back/routes"))),
|
|
7
|
-
parser: "typescript",
|
|
8
|
-
};
|
|
9
|
-
}
|
|
10
|
-
//# sourceMappingURL=prettier.js.map
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { createInterface } from "readline";
|
|
2
|
-
export async function question(text, validator) {
|
|
3
|
-
const rl = createInterface({
|
|
4
|
-
input: process.stdin,
|
|
5
|
-
output: process.stdout,
|
|
6
|
-
});
|
|
7
|
-
let answer = "";
|
|
8
|
-
while (answer == "" || !validator(answer)) {
|
|
9
|
-
// eslint-disable-next-line no-await-in-loop
|
|
10
|
-
answer = await new Promise((resolve) => rl.question(text, resolve));
|
|
11
|
-
if (!validator(answer)) {
|
|
12
|
-
// eslint-disable-next-line no-console
|
|
13
|
-
console.log("Try again");
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
rl.close();
|
|
17
|
-
return answer;
|
|
18
|
-
}
|
|
19
|
-
//# sourceMappingURL=question.js.map
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { attribute } from "../sanitize.js";
|
|
2
|
-
export function renderAttributes(attrs) {
|
|
3
|
-
return Object.entries(attrs)
|
|
4
|
-
.map(([key, value]) => {
|
|
5
|
-
if (typeof value === "boolean") {
|
|
6
|
-
if (value) {
|
|
7
|
-
return key;
|
|
8
|
-
}
|
|
9
|
-
else {
|
|
10
|
-
return "";
|
|
11
|
-
}
|
|
12
|
-
}
|
|
13
|
-
else {
|
|
14
|
-
return `${key}="${attribute(value)}"`;
|
|
15
|
-
}
|
|
16
|
-
})
|
|
17
|
-
.join(" ");
|
|
18
|
-
}
|
|
19
|
-
//# sourceMappingURL=render-attributes.js.map
|
package/lib/src/utils/sleep.js
DELETED
package/lib/src/utils/utils.js
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
export function keys(object) {
|
|
2
|
-
return Object.keys(object);
|
|
3
|
-
}
|
|
4
|
-
export { sleep } from "./sleep.js";
|
|
5
|
-
export { naturalNumbers } from "./natural-numbers.js";
|
|
6
|
-
export { UrlWithNewParams } from "./url-with-new-params.js";
|
|
7
|
-
export { exec } from "./exec.js";
|
|
8
|
-
export { importPath, curryImportPath } from "./import-path.js";
|
|
9
|
-
export { listCollections } from "./list-collections.js";
|
|
10
|
-
export { walkDir } from "./walk.js";
|
|
11
|
-
export { assertThrowsAsync } from "./assert-throws.js";
|
|
12
|
-
export * from "./make-slug.js";
|
|
13
|
-
export * from "./render-attributes.js";
|
|
14
|
-
export * from "./format-external-url.js";
|
|
15
|
-
export * from "./base64.js";
|
|
16
|
-
//# sourceMappingURL=utils.js.map
|
package/lib/src/utils/walk.js
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { promises as fs } from "fs";
|
|
2
|
-
import { resolve } from "path";
|
|
3
|
-
export async function walkDir(dir) {
|
|
4
|
-
const entries = await fs.readdir(dir);
|
|
5
|
-
let ret = [];
|
|
6
|
-
for (const entry of entries) {
|
|
7
|
-
if (entry.includes(".#")) {
|
|
8
|
-
continue;
|
|
9
|
-
}
|
|
10
|
-
const fullpath = resolve(dir, entry);
|
|
11
|
-
// eslint-disable-next-line no-await-in-loop
|
|
12
|
-
const info = await fs.stat(fullpath);
|
|
13
|
-
if (info.isDirectory()) {
|
|
14
|
-
// eslint-disable-next-line no-await-in-loop
|
|
15
|
-
ret = [...ret, ...(await walkDir(fullpath))];
|
|
16
|
-
}
|
|
17
|
-
else {
|
|
18
|
-
ret = [...ret, fullpath];
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
return ret;
|
|
22
|
-
}
|
|
23
|
-
//# sourceMappingURL=walk.js.map
|
package/lib/src/vitest.config.js
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { defineConfig } from "vitest/config";
|
|
2
|
-
const exclude = ["node_modules", "lib", "dist"];
|
|
3
|
-
export default defineConfig({
|
|
4
|
-
test: {
|
|
5
|
-
testTimeout: 10000,
|
|
6
|
-
exclude,
|
|
7
|
-
globals: true,
|
|
8
|
-
coverage: {
|
|
9
|
-
exclude,
|
|
10
|
-
enabled: true,
|
|
11
|
-
all: true,
|
|
12
|
-
include: ["dist/**", "test?(-*).?(c|m)[jt]s?(x)"],
|
|
13
|
-
},
|
|
14
|
-
sequence: { setupFiles: "list" },
|
|
15
|
-
maxConcurrency: 1,
|
|
16
|
-
pool: "threads",
|
|
17
|
-
poolOptions: { threads: { maxThreads: 1, minThreads: 1 } },
|
|
18
|
-
},
|
|
19
|
-
});
|
|
20
|
-
//# sourceMappingURL=vitest.config.js.map
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
export function collectionTemplate(collection_name) {
|
|
2
|
-
return `import { Collection, FieldTypes, Policies } from "sealious";
|
|
3
|
-
|
|
4
|
-
export default class ${collection_name} extends Collection {
|
|
5
|
-
fields = {
|
|
6
|
-
content: new FieldTypes.Text(),
|
|
7
|
-
};
|
|
8
|
-
defaultPolicy = new Policies.Public();
|
|
9
|
-
}
|
|
10
|
-
`;
|
|
11
|
-
}
|
|
12
|
-
//# sourceMappingURL=collection.js.map
|
package/lib/templates/form.js
DELETED
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
import { curryImportPath } from "../utils/import-path.js";
|
|
2
|
-
export async function formTemplate(action_name, newfilefullpath) {
|
|
3
|
-
const rel = curryImportPath(newfilefullpath);
|
|
4
|
-
return `import { Context } from "koa";
|
|
5
|
-
import { Form, FormData, FormDataValue, Fields, Controls } from "@sealcode/sealgen";
|
|
6
|
-
import html from "${rel("src/back/html.js")}";
|
|
7
|
-
import { Users } from "${rel("src/back/collections/collections.js")}";
|
|
8
|
-
|
|
9
|
-
export const actionName = "${action_name}";
|
|
10
|
-
|
|
11
|
-
const fields = {
|
|
12
|
-
email: new Fields.CollectionField(true, Users.fields.email),
|
|
13
|
-
password: new Fields.SimpleFormField(true),
|
|
14
|
-
};
|
|
15
|
-
|
|
16
|
-
export const ${action_name}Shape = Fields.fieldsToShape(fields);
|
|
17
|
-
|
|
18
|
-
export default new (class ${action_name}Form extends Form<typeof fields, void> {
|
|
19
|
-
defaultSuccessMessage = "Formularz wypełniony poprawnie";
|
|
20
|
-
fields = fields;
|
|
21
|
-
|
|
22
|
-
controls = [
|
|
23
|
-
new Controls.SimpleInput(fields.email, { label: "Email:", type: "email" }),
|
|
24
|
-
new Controls.SimpleInput(fields.password, { label: "Password:", type: "password" }),
|
|
25
|
-
];
|
|
26
|
-
|
|
27
|
-
async validateValues(
|
|
28
|
-
ctx: Context,
|
|
29
|
-
data: Record<string, FormDataValue>
|
|
30
|
-
): Promise<{ valid: boolean; error: string }> {
|
|
31
|
-
// just an example
|
|
32
|
-
const { parsed: email } = await this.fields.email.getValue(ctx, data);
|
|
33
|
-
const { parsed: password } = await this.fields.password.getValue(ctx, data);
|
|
34
|
-
if ((password || "").length > (email || "").length) {
|
|
35
|
-
return { valid: false, error: "Password cannot be longer than email" };
|
|
36
|
-
} else {
|
|
37
|
-
return { valid: true, error: "" };
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
42
|
-
async canAccess(_: Context) {
|
|
43
|
-
return { canAccess: true, message: "" };
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
async onSubmit() {
|
|
47
|
-
//noop
|
|
48
|
-
return;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
async render(ctx: Context, data: FormData, show_field_errors: boolean) {
|
|
52
|
-
return html(ctx, "${action_name}", await super.render(ctx, data, show_field_errors));
|
|
53
|
-
}
|
|
54
|
-
})();
|
|
55
|
-
`;
|
|
56
|
-
}
|
|
57
|
-
//# sourceMappingURL=form.js.map
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import { toKebabCase, toPascalCase } from "js-convert-case";
|
|
2
|
-
export function jddComponentTemplate(component_name) {
|
|
3
|
-
return `import { FlatTemplatable, TempstreamJSX } from "tempstream";
|
|
4
|
-
import {
|
|
5
|
-
Component,
|
|
6
|
-
ComponentArguments,
|
|
7
|
-
ExtractStructuredComponentArgumentsValues,
|
|
8
|
-
JDDContext,
|
|
9
|
-
} from "@sealcode/jdd";
|
|
10
|
-
|
|
11
|
-
const component_arguments = {
|
|
12
|
-
title: new ComponentArguments.ShortText(),
|
|
13
|
-
content: new ComponentArguments.Markdown(),
|
|
14
|
-
} as const;
|
|
15
|
-
|
|
16
|
-
export class ${toPascalCase(component_name)} extends Component<typeof component_arguments> {
|
|
17
|
-
getArguments() {
|
|
18
|
-
return component_arguments;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
toHTML(
|
|
22
|
-
{
|
|
23
|
-
title,
|
|
24
|
-
content,
|
|
25
|
-
}: ExtractStructuredComponentArgumentsValues<typeof component_arguments>,
|
|
26
|
-
{ render_markdown }: JDDContext
|
|
27
|
-
): FlatTemplatable {
|
|
28
|
-
return (
|
|
29
|
-
<div class="${toKebabCase(component_name)}">
|
|
30
|
-
<h2>{title} • ${toPascalCase(component_name)} </h2>
|
|
31
|
-
<div>{render_markdown(content)}</div>
|
|
32
|
-
</div>
|
|
33
|
-
);
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
`;
|
|
38
|
-
}
|
|
39
|
-
//# sourceMappingURL=jdd-component.js.map
|
package/lib/templates/list.js
DELETED
|
@@ -1,139 +0,0 @@
|
|
|
1
|
-
import _locreq from "locreq";
|
|
2
|
-
import { curryImportPath } from "../utils/import-path.js";
|
|
3
|
-
import prompts from "prompts";
|
|
4
|
-
import { listCollections } from "../utils/list-collections.js";
|
|
5
|
-
import { extractCollectionClassname } from "../generate-collections.js";
|
|
6
|
-
import extract_fields_from_collection from "../utils/extract-fields-from-collection.js";
|
|
7
|
-
import { DefaultListFilters } from "../page/default-list-filters.js";
|
|
8
|
-
const target_locreq = _locreq(process.cwd());
|
|
9
|
-
export const listTemplate = async (action_name, newfilefullpath) => {
|
|
10
|
-
const response = await prompts({
|
|
11
|
-
type: "autocomplete",
|
|
12
|
-
name: "collection",
|
|
13
|
-
message: "Which sealious collection do you want to list?",
|
|
14
|
-
choices: (await listCollections()).map((collection) => ({
|
|
15
|
-
title: collection,
|
|
16
|
-
value: collection,
|
|
17
|
-
})),
|
|
18
|
-
});
|
|
19
|
-
const collection_name = response.collection;
|
|
20
|
-
const [uppercase_collection, collection_fields] = await Promise.all([
|
|
21
|
-
extractCollectionClassname(target_locreq.resolve("src/back/collections/" + collection_name + ".ts")),
|
|
22
|
-
extract_fields_from_collection(collection_name),
|
|
23
|
-
]);
|
|
24
|
-
const rel = curryImportPath(newfilefullpath);
|
|
25
|
-
return `import { Context } from "koa";
|
|
26
|
-
import { CollectionItem } from "sealious";
|
|
27
|
-
import { FlatTemplatable, TempstreamJSX } from "tempstream";
|
|
28
|
-
import { ${uppercase_collection} } from "${rel("src/back/collections/collections.js")}";
|
|
29
|
-
import html from "${rel("src/back/html.js")}";
|
|
30
|
-
import {
|
|
31
|
-
SealiousItemListPage,
|
|
32
|
-
BaseListPageFields,
|
|
33
|
-
DefaultListFilters,
|
|
34
|
-
ListFilterRender,
|
|
35
|
-
} from "@sealcode/sealgen";;
|
|
36
|
-
import qs from "qs";
|
|
37
|
-
import { is, predicates } from "@sealcode/ts-predicates";
|
|
38
|
-
|
|
39
|
-
export const actionName = "${action_name}";
|
|
40
|
-
|
|
41
|
-
const filterFields = [
|
|
42
|
-
${collection_fields
|
|
43
|
-
.map((field) => ` { field: "${field.name}", render: ${DefaultListFilters[field.type]
|
|
44
|
-
? `DefaultListFilters["${field.type}"]`
|
|
45
|
-
: `DefaultListFilters.fallback`} }`)
|
|
46
|
-
.join(",\n")}
|
|
47
|
-
] as {
|
|
48
|
-
field: keyof (typeof ${uppercase_collection})["fields"];
|
|
49
|
-
render?: ListFilterRender;
|
|
50
|
-
}[];
|
|
51
|
-
|
|
52
|
-
const displayFields = [
|
|
53
|
-
${collection_fields
|
|
54
|
-
.map((field) => {
|
|
55
|
-
if (field.type == "boolean") {
|
|
56
|
-
return ` {
|
|
57
|
-
field: "${field.name}",
|
|
58
|
-
label: "${field.name}",
|
|
59
|
-
format: (v: boolean) => (v ? "YES" : "NO"),
|
|
60
|
-
}`;
|
|
61
|
-
}
|
|
62
|
-
if (field.type == "datetime") {
|
|
63
|
-
return ` {
|
|
64
|
-
field: "${field.name}",
|
|
65
|
-
label: "${field.name}",
|
|
66
|
-
format: (v: number) => {
|
|
67
|
-
const d = new Date();
|
|
68
|
-
d.setTime(v);
|
|
69
|
-
return d.toString().split(" ").slice(1, 5).join(" ");
|
|
70
|
-
},
|
|
71
|
-
}`;
|
|
72
|
-
}
|
|
73
|
-
return ` { field: "${field.name}", label: "${field.name}" }`;
|
|
74
|
-
})
|
|
75
|
-
.join(",\n")}
|
|
76
|
-
];
|
|
77
|
-
|
|
78
|
-
export default new (class ${action_name}Page extends SealiousItemListPage<
|
|
79
|
-
typeof ${uppercase_collection},
|
|
80
|
-
typeof BaseListPageFields
|
|
81
|
-
> {
|
|
82
|
-
fields = BaseListPageFields;
|
|
83
|
-
|
|
84
|
-
async renderFilters(ctx: Context): Promise<FlatTemplatable> {
|
|
85
|
-
const query_params = qs.parse(ctx.search.slice(1));
|
|
86
|
-
query_params.page = "1";
|
|
87
|
-
const filter_values = await this.getFilterValues(ctx);
|
|
88
|
-
return <form>
|
|
89
|
-
{Object.entries(query_params).map(([key, value]) => {
|
|
90
|
-
if (key == "filter") {
|
|
91
|
-
return "";
|
|
92
|
-
}
|
|
93
|
-
return <input
|
|
94
|
-
type="hidden"
|
|
95
|
-
name="\${key}"
|
|
96
|
-
value="\${value}"
|
|
97
|
-
/>;
|
|
98
|
-
})}
|
|
99
|
-
{filterFields.map(({ field, render }) => {
|
|
100
|
-
if (!render) {
|
|
101
|
-
render = DefaultListFilters.fallback;
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
return (
|
|
105
|
-
render(filter_values[field] || "", this.collection.fields[field]) ||
|
|
106
|
-
""
|
|
107
|
-
);
|
|
108
|
-
})}
|
|
109
|
-
<input type="submit" />
|
|
110
|
-
</form>;
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
async renderItem(_: Context, item: CollectionItem<typeof ${uppercase_collection}>) {
|
|
114
|
-
return <tr>
|
|
115
|
-
{displayFields.map(({ field, format }) => {
|
|
116
|
-
const value = item.get(field as any);
|
|
117
|
-
return <td>{format ? format(value) : value}</td>;
|
|
118
|
-
})}
|
|
119
|
-
</tr>;
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
async render(ctx: Context) {
|
|
123
|
-
return html(
|
|
124
|
-
ctx,
|
|
125
|
-
"${action_name}",
|
|
126
|
-
<div>
|
|
127
|
-
<h2>${action_name} List</h2>
|
|
128
|
-
<table class="sealious-list">
|
|
129
|
-
{this.renderTableHead(ctx, displayFields)}
|
|
130
|
-
<tbody>{super.render(ctx)}</tbody>
|
|
131
|
-
</table>
|
|
132
|
-
</div>
|
|
133
|
-
);
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
})(${uppercase_collection});
|
|
137
|
-
`;
|
|
138
|
-
};
|
|
139
|
-
//# sourceMappingURL=list.js.map
|
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
import { curryImportPath } from "../utils/import-path.js";
|
|
2
|
-
export async function LongRunningProcessTemplate(action_name, newfilefullpath) {
|
|
3
|
-
const rel = curryImportPath(newfilefullpath);
|
|
4
|
-
return `import { Context } from "koa";
|
|
5
|
-
import { TempstreamJSX } from "tempstream";
|
|
6
|
-
import { Page } from "@sealcode/sealgen";
|
|
7
|
-
import html from "${rel("src/back/html.js")}";
|
|
8
|
-
import { LongRunningProcess } from "sealious";
|
|
9
|
-
|
|
10
|
-
export const actionName = "${action_name}";
|
|
11
|
-
|
|
12
|
-
export default new (class PatroniteAutoImportStatusPage extends Page {
|
|
13
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
14
|
-
async canAccess(_: Context) {
|
|
15
|
-
return { canAccess: true, message: "" };
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
public interval = 2000;
|
|
19
|
-
|
|
20
|
-
async render(ctx: Context) {
|
|
21
|
-
const lpr_id = ctx.params.id;
|
|
22
|
-
const lpr_data = LongRunningProcess.getByID(ctx.$context, lpr_id);
|
|
23
|
-
const render_script = lpr_data.state !== "error" && lpr_data.state !== "finished";
|
|
24
|
-
const script = /* HTML */ \`<script>
|
|
25
|
-
setTimeout(() => {
|
|
26
|
-
document.location = document.location;
|
|
27
|
-
}, \${this.interval});
|
|
28
|
-
</script>\`;
|
|
29
|
-
|
|
30
|
-
return html(
|
|
31
|
-
ctx,
|
|
32
|
-
"PatroniteAutoImportStatus",
|
|
33
|
-
<div>
|
|
34
|
-
{lpr_data.then((lpr_data) => {
|
|
35
|
-
return (
|
|
36
|
-
<div>
|
|
37
|
-
<div>status: {lpr_data.state}</div>
|
|
38
|
-
<div style="height: 20px; width: 100%">
|
|
39
|
-
<div
|
|
40
|
-
style="height: 100%; background-color: green; width: {Math.round(
|
|
41
|
-
lpr_data.progress * 100
|
|
42
|
-
)}%"
|
|
43
|
-
></div>
|
|
44
|
-
</div>
|
|
45
|
-
<div>
|
|
46
|
-
{lpr_data.events.map((e) => (
|
|
47
|
-
<div>{e.message}</div>
|
|
48
|
-
))}
|
|
49
|
-
</div>
|
|
50
|
-
{render_script ? { script } : ""}
|
|
51
|
-
</div>
|
|
52
|
-
);
|
|
53
|
-
})}
|
|
54
|
-
</div>
|
|
55
|
-
);
|
|
56
|
-
}
|
|
57
|
-
})();
|
|
58
|
-
`;
|
|
59
|
-
}
|
|
60
|
-
//# sourceMappingURL=long-running-process.js.map
|