@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.
Files changed (268) hide show
  1. package/dist/notifier.js +1 -1
  2. package/package.json +2 -2
  3. package/src/notifier.ts +1 -1
  4. package/.madgerc +0 -7
  5. package/coverage/.tmp/coverage-15.json +0 -1
  6. package/coverage/.tmp/coverage-16.json +0 -1
  7. package/coverage/.tmp/coverage-17.json +0 -1
  8. package/coverage/.tmp/coverage-18.json +0 -1
  9. package/coverage/.tmp/coverage-19.json +0 -1
  10. package/coverage/.tmp/coverage-20.json +0 -1
  11. package/coverage/.tmp/coverage-21.json +0 -1
  12. package/coverage/.tmp/coverage-22.json +0 -1
  13. package/coverage/.tmp/coverage-23.json +0 -1
  14. package/coverage/.tmp/coverage-24.json +0 -1
  15. package/coverage/.tmp/coverage-25.json +0 -1
  16. package/coverage/.tmp/coverage-26.json +0 -1
  17. package/lib/add-collection.js +0 -24
  18. package/lib/add-jdd-component.js +0 -27
  19. package/lib/add-route.js +0 -65
  20. package/lib/add-route.test.js +0 -60
  21. package/lib/build.js +0 -187
  22. package/lib/cli.js +0 -35
  23. package/lib/components/components.js +0 -3
  24. package/lib/components/tabs.js +0 -88
  25. package/lib/components/toggle-modal.js +0 -46
  26. package/lib/example.test.js +0 -5
  27. package/lib/find-css-includes.js +0 -23
  28. package/lib/forms/controls/array.js +0 -140
  29. package/lib/forms/controls/autocomplete.js +0 -23
  30. package/lib/forms/controls/big-radio-group.js +0 -34
  31. package/lib/forms/controls/checkbox-group.js +0 -29
  32. package/lib/forms/controls/checkbox.js +0 -24
  33. package/lib/forms/controls/checkboxed-list-input.js +0 -35
  34. package/lib/forms/controls/collapsible-checkbox-group.js +0 -13
  35. package/lib/forms/controls/collapsible-field-group.js +0 -78
  36. package/lib/forms/controls/controls.js +0 -31
  37. package/lib/forms/controls/derived-frame.js +0 -52
  38. package/lib/forms/controls/derived.js +0 -77
  39. package/lib/forms/controls/dropdown.js +0 -55
  40. package/lib/forms/controls/editable-collection-subset.js +0 -68
  41. package/lib/forms/controls/field-group.js +0 -53
  42. package/lib/forms/controls/file.js +0 -35
  43. package/lib/forms/controls/form-control.js +0 -14
  44. package/lib/forms/controls/form-field-control.js +0 -9
  45. package/lib/forms/controls/form-header.js +0 -14
  46. package/lib/forms/controls/form-paragraph.js +0 -12
  47. package/lib/forms/controls/frame.js +0 -25
  48. package/lib/forms/controls/hidden-input.js +0 -14
  49. package/lib/forms/controls/html.js +0 -23
  50. package/lib/forms/controls/multiple-files.js +0 -160
  51. package/lib/forms/controls/multiple-photos.js +0 -33
  52. package/lib/forms/controls/number.js +0 -25
  53. package/lib/forms/controls/photo.js +0 -57
  54. package/lib/forms/controls/radio.js +0 -25
  55. package/lib/forms/controls/reverse-single-reference.js +0 -47
  56. package/lib/forms/controls/simple-input.js +0 -78
  57. package/lib/forms/controls/textarea.js +0 -33
  58. package/lib/forms/controls/tickable.js +0 -75
  59. package/lib/forms/fields/boolean.js +0 -51
  60. package/lib/forms/fields/boolean.test.js +0 -32
  61. package/lib/forms/fields/checkboxed-list.js +0 -40
  62. package/lib/forms/fields/collection-field.js +0 -29
  63. package/lib/forms/fields/email.js +0 -11
  64. package/lib/forms/fields/email.test.js +0 -20
  65. package/lib/forms/fields/enum-multiple.js +0 -47
  66. package/lib/forms/fields/enum-multiple.test.js +0 -27
  67. package/lib/forms/fields/enum.js +0 -39
  68. package/lib/forms/fields/enum.test.js +0 -21
  69. package/lib/forms/fields/existing-sealious-value.js +0 -16
  70. package/lib/forms/fields/field.js +0 -81
  71. package/lib/forms/fields/file.js +0 -53
  72. package/lib/forms/fields/multiple-files.js +0 -15
  73. package/lib/forms/fields/number.js +0 -45
  74. package/lib/forms/fields/number.test.js +0 -30
  75. package/lib/forms/fields/pick-from-list.js +0 -31
  76. package/lib/forms/fields/pick-from-list.test.js +0 -17
  77. package/lib/forms/fields/proxy-field.js +0 -20
  78. package/lib/forms/fields/regexp.js +0 -40
  79. package/lib/forms/fields/regexp.test.js +0 -21
  80. package/lib/forms/fields/reverse-single-reference.js +0 -14
  81. package/lib/forms/fields/simple-form-field.js +0 -20
  82. package/lib/forms/fields/structured-array.js +0 -18
  83. package/lib/forms/form.js +0 -176
  84. package/lib/forms/form.test.js +0 -1
  85. package/lib/forms/multiform.js +0 -174
  86. package/lib/forms/multiform.test.js +0 -426
  87. package/lib/generate-collections.js +0 -52
  88. package/lib/generate-components.js +0 -33
  89. package/lib/generate-routes.js +0 -75
  90. package/lib/index.js +0 -17
  91. package/lib/make-env.js +0 -14
  92. package/lib/make-hidden-inputs.js +0 -14
  93. package/lib/mount.js +0 -70
  94. package/lib/notifier.js +0 -19
  95. package/lib/page/access-control.js +0 -16
  96. package/lib/page/default-list-filters.js +0 -40
  97. package/lib/page/list.js +0 -183
  98. package/lib/page/mountable-with-fields.js +0 -85
  99. package/lib/page/mountable.js +0 -5
  100. package/lib/page/page.js +0 -26
  101. package/lib/page/props-parser.js +0 -23
  102. package/lib/page/sealious-list.js +0 -59
  103. package/lib/page/stateful-page.js +0 -97
  104. package/lib/remove-named-imports.js +0 -47
  105. package/lib/run.js +0 -2
  106. package/lib/sanitize.js +0 -10
  107. package/lib/src/add-collection.js +0 -24
  108. package/lib/src/add-jdd-component.js +0 -27
  109. package/lib/src/add-route.js +0 -65
  110. package/lib/src/add-route.test.js +0 -72
  111. package/lib/src/build.js +0 -142
  112. package/lib/src/cli.js +0 -37
  113. package/lib/src/components/components.js +0 -3
  114. package/lib/src/components/tabs.js +0 -88
  115. package/lib/src/components/toggle-modal.js +0 -46
  116. package/lib/src/example.test.js +0 -5
  117. package/lib/src/find-css-includes.js +0 -23
  118. package/lib/src/forms/controls/array.js +0 -141
  119. package/lib/src/forms/controls/autocomplete.js +0 -23
  120. package/lib/src/forms/controls/big-radio-group.js +0 -34
  121. package/lib/src/forms/controls/checkbox-group.js +0 -30
  122. package/lib/src/forms/controls/checkbox.js +0 -24
  123. package/lib/src/forms/controls/checkboxed-list-input.js +0 -35
  124. package/lib/src/forms/controls/collapsible-checkbox-group.js +0 -13
  125. package/lib/src/forms/controls/collapsible-field-group.js +0 -78
  126. package/lib/src/forms/controls/controls.js +0 -31
  127. package/lib/src/forms/controls/derived-frame.js +0 -52
  128. package/lib/src/forms/controls/derived.js +0 -77
  129. package/lib/src/forms/controls/dropdown.js +0 -55
  130. package/lib/src/forms/controls/editable-collection-subset.js +0 -68
  131. package/lib/src/forms/controls/field-group.js +0 -53
  132. package/lib/src/forms/controls/file.js +0 -35
  133. package/lib/src/forms/controls/form-control.js +0 -14
  134. package/lib/src/forms/controls/form-field-control.js +0 -9
  135. package/lib/src/forms/controls/form-header.js +0 -14
  136. package/lib/src/forms/controls/form-paragraph.js +0 -12
  137. package/lib/src/forms/controls/frame.js +0 -25
  138. package/lib/src/forms/controls/hidden-input.js +0 -14
  139. package/lib/src/forms/controls/html.js +0 -23
  140. package/lib/src/forms/controls/multiple-files.js +0 -160
  141. package/lib/src/forms/controls/multiple-photos.js +0 -33
  142. package/lib/src/forms/controls/number.js +0 -25
  143. package/lib/src/forms/controls/photo.js +0 -57
  144. package/lib/src/forms/controls/radio.js +0 -25
  145. package/lib/src/forms/controls/reverse-single-reference.js +0 -47
  146. package/lib/src/forms/controls/simple-input.js +0 -78
  147. package/lib/src/forms/controls/textarea.js +0 -33
  148. package/lib/src/forms/controls/tickable.js +0 -75
  149. package/lib/src/forms/fields/boolean.js +0 -51
  150. package/lib/src/forms/fields/boolean.test.js +0 -33
  151. package/lib/src/forms/fields/checkboxed-list.js +0 -40
  152. package/lib/src/forms/fields/collection-field.js +0 -29
  153. package/lib/src/forms/fields/email.js +0 -11
  154. package/lib/src/forms/fields/email.test.js +0 -20
  155. package/lib/src/forms/fields/enum-multiple.js +0 -47
  156. package/lib/src/forms/fields/enum-multiple.test.js +0 -27
  157. package/lib/src/forms/fields/enum.js +0 -39
  158. package/lib/src/forms/fields/enum.test.js +0 -21
  159. package/lib/src/forms/fields/existing-sealious-value.js +0 -16
  160. package/lib/src/forms/fields/field.js +0 -66
  161. package/lib/src/forms/fields/fields.js +0 -16
  162. package/lib/src/forms/fields/file.js +0 -53
  163. package/lib/src/forms/fields/multiple-files.js +0 -15
  164. package/lib/src/forms/fields/number.js +0 -45
  165. package/lib/src/forms/fields/number.test.js +0 -31
  166. package/lib/src/forms/fields/pick-from-list.js +0 -31
  167. package/lib/src/forms/fields/pick-from-list.test.js +0 -17
  168. package/lib/src/forms/fields/proxy-field.js +0 -20
  169. package/lib/src/forms/fields/regexp.js +0 -40
  170. package/lib/src/forms/fields/regexp.test.js +0 -21
  171. package/lib/src/forms/fields/reverse-single-reference.js +0 -14
  172. package/lib/src/forms/fields/simple-form-field.js +0 -19
  173. package/lib/src/forms/fields/structured-array.js +0 -18
  174. package/lib/src/forms/form-types.js +0 -2
  175. package/lib/src/forms/form.js +0 -176
  176. package/lib/src/forms/form.test.js +0 -271
  177. package/lib/src/forms/multiform.js +0 -174
  178. package/lib/src/forms/multiform.test.js +0 -430
  179. package/lib/src/generate-collections.js +0 -52
  180. package/lib/src/generate-components.js +0 -33
  181. package/lib/src/generate-routes.js +0 -75
  182. package/lib/src/hehe.test.js +0 -7
  183. package/lib/src/index.js +0 -19
  184. package/lib/src/make-env.js +0 -14
  185. package/lib/src/make-hidden-inputs.js +0 -14
  186. package/lib/src/mount.js +0 -70
  187. package/lib/src/notifier.js +0 -19
  188. package/lib/src/page/access-control.js +0 -16
  189. package/lib/src/page/default-list-filters.js +0 -40
  190. package/lib/src/page/list.js +0 -184
  191. package/lib/src/page/mountable-with-fields.js +0 -85
  192. package/lib/src/page/mountable.js +0 -5
  193. package/lib/src/page/page.js +0 -26
  194. package/lib/src/page/props-parser.js +0 -23
  195. package/lib/src/page/sealious-list.js +0 -59
  196. package/lib/src/page/stateful-page.js +0 -97
  197. package/lib/src/run.js +0 -2
  198. package/lib/src/sample-index.js +0 -3
  199. package/lib/src/sample-lib.js +0 -6
  200. package/lib/src/sanitize.js +0 -10
  201. package/lib/src/templates/collection.js +0 -12
  202. package/lib/src/templates/form.js +0 -57
  203. package/lib/src/templates/jdd-component.js +0 -39
  204. package/lib/src/templates/list.js +0 -139
  205. package/lib/src/templates/long-running-process.js +0 -60
  206. package/lib/src/templates/multiform.js +0 -55
  207. package/lib/src/templates/page.js +0 -23
  208. package/lib/src/templates/post.js +0 -22
  209. package/lib/src/templates/redirect.js +0 -23
  210. package/lib/src/templates/route-test.js +0 -54
  211. package/lib/src/templates/stateful-page.js +0 -66
  212. package/lib/src/templates/templates.js +0 -21
  213. package/lib/src/test_utils/locator_is_visible.js +0 -11
  214. package/lib/src/utils/assert-throws.js +0 -17
  215. package/lib/src/utils/base64.js +0 -7
  216. package/lib/src/utils/browser-creator.js +0 -10
  217. package/lib/src/utils/escape-url-params.js +0 -14
  218. package/lib/src/utils/exec.js +0 -22
  219. package/lib/src/utils/extract-fields-from-collection.js +0 -26
  220. package/lib/src/utils/format-external-url.js +0 -11
  221. package/lib/src/utils/import-path.js +0 -16
  222. package/lib/src/utils/input-wrapper.js +0 -15
  223. package/lib/src/utils/list-collections.js +0 -13
  224. package/lib/src/utils/make-slug.js +0 -6
  225. package/lib/src/utils/natural-numbers.js +0 -6
  226. package/lib/src/utils/prettier.js +0 -10
  227. package/lib/src/utils/question.js +0 -19
  228. package/lib/src/utils/render-attributes.js +0 -19
  229. package/lib/src/utils/sleep.js +0 -4
  230. package/lib/src/utils/translate.js +0 -6
  231. package/lib/src/utils/url-with-new-params.js +0 -5
  232. package/lib/src/utils/utils.js +0 -16
  233. package/lib/src/utils/walk.js +0 -23
  234. package/lib/src/vitest.config.js +0 -20
  235. package/lib/templates/collection.js +0 -12
  236. package/lib/templates/form.js +0 -57
  237. package/lib/templates/jdd-component.js +0 -39
  238. package/lib/templates/list.js +0 -139
  239. package/lib/templates/long-running-process.js +0 -60
  240. package/lib/templates/multiform.js +0 -55
  241. package/lib/templates/page.js +0 -23
  242. package/lib/templates/post.js +0 -22
  243. package/lib/templates/redirect.js +0 -23
  244. package/lib/templates/route-test.js +0 -54
  245. package/lib/templates/stateful-page.js +0 -66
  246. package/lib/templates/templates.js +0 -21
  247. package/lib/test_utils/locator_is_visible.js +0 -11
  248. package/lib/utils/assert-throws.js +0 -17
  249. package/lib/utils/base64.js +0 -7
  250. package/lib/utils/browser-creator.js +0 -10
  251. package/lib/utils/escape-url-params.js +0 -14
  252. package/lib/utils/exec.js +0 -22
  253. package/lib/utils/extract-fields-from-collection.js +0 -26
  254. package/lib/utils/format-external-url.js +0 -11
  255. package/lib/utils/import-path.js +0 -16
  256. package/lib/utils/input-wrapper.js +0 -15
  257. package/lib/utils/list-collections.js +0 -13
  258. package/lib/utils/make-slug.js +0 -6
  259. package/lib/utils/natural-numbers.js +0 -6
  260. package/lib/utils/prettier.js +0 -10
  261. package/lib/utils/question.js +0 -19
  262. package/lib/utils/render-attributes.js +0 -19
  263. package/lib/utils/sleep.js +0 -4
  264. package/lib/utils/translate.js +0 -6
  265. package/lib/utils/url-with-new-params.js +0 -5
  266. package/lib/utils/utils.js +0 -16
  267. package/lib/utils/walk.js +0 -23
  268. package/lib/vitest.config.js +0 -22
@@ -1,55 +0,0 @@
1
- import { curryImportPath } from "../utils/utils.js";
2
- export async function multiformTemplate(action_name, newfilefullpath) {
3
- const rel = curryImportPath(newfilefullpath);
4
- return `import { Context } from "koa";
5
- import html from "${rel("src/back/html.js")}";
6
- import { Controls, Fields, Form, FormMessage, Multiform } from "@sealcode/sealgen";
7
- import { FlatTemplatable } from "tempstream";
8
-
9
- export const actionName = "${action_name}";
10
-
11
- const fields1 = {
12
- email: new Fields.SimpleFormField(true),
13
- password: new Fields.SimpleFormField(true),
14
- };
15
-
16
- const form1 = new (class extends Form<typeof fields1> {
17
- defaultSuccessMessage = "Form1 done!";
18
- controls = [
19
- new Controls.FormHeader("form1"),
20
- new Controls.SimpleInput(fields1.email),
21
- ];
22
- fields = fields1;
23
- onSubmit() {
24
- console.log("form1 submit");
25
- }
26
- })();
27
-
28
- const fields2 = {
29
- name: new Fields.SimpleFormField(true),
30
- surname: new Fields.SimpleFormField(true),
31
- };
32
-
33
- const form2 = new (class extends Form<Record<never, unknown>> {
34
- defaultSuccessMessage = "Form2 done!";
35
- controls = [new Controls.FormHeader("form2"), new Controls.SimpleInput(fields2.name)];
36
- fields = fields2;
37
- onSubmit() {
38
- console.log("form2 submit");
39
- }
40
- })();
41
-
42
- export default new (class extends Multiform {
43
- name = "multiform_test";
44
- forms = { form1, form2 };
45
- async render(
46
- ctx: Context,
47
- messages: FormMessage[],
48
- prerenderedForms?: Record<string, FlatTemplatable | undefined>
49
- ): Promise<FlatTemplatable> {
50
- return html(ctx, "${action_name}", await super.render(ctx, messages, prerenderedForms));
51
- }
52
- })();
53
- `;
54
- }
55
- //# sourceMappingURL=multiform.js.map
@@ -1,23 +0,0 @@
1
- import { curryImportPath } from "../utils/import-path.js";
2
- export async function pageTemplate(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
-
9
- export const actionName = "${action_name}";
10
-
11
- export default new (class ${action_name}Page extends Page {
12
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
13
- async canAccess(_: Context) {
14
- return { canAccess: true, message: "" };
15
- }
16
-
17
- async render(ctx: Context) {
18
- return html(ctx, "${action_name}", <div></div>);
19
- }
20
- })();
21
- `;
22
- }
23
- //# sourceMappingURL=page.js.map
@@ -1,22 +0,0 @@
1
- export async function postTemplate(action_name) {
2
- return `import { Context } from "koa";
3
- import { Mountable } from "@sealcode/sealgen";
4
- import Router from "@koa/router";
5
-
6
- export const actionName = "${action_name}";
7
-
8
- export default new (class ${action_name}Redirect extends Mountable {
9
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
10
- async canAccess(_: Context) {
11
- return { canAccess: true, message: "" };
12
- }
13
-
14
- mount(router: Router, path: string) {
15
- router.post(path, async (ctx) => {
16
- ctx.body = { message: "OK!" }
17
- });
18
- }
19
- })();
20
- `;
21
- }
22
- //# sourceMappingURL=post.js.map
@@ -1,23 +0,0 @@
1
- export async function redirectTemplate(action_name) {
2
- return `import { Context } from "koa";
3
- import { Mountable } from "@sealcode/sealgen";
4
- import Router from "@koa/router";
5
-
6
- export const actionName = "${action_name}";
7
-
8
- export default new (class ${action_name}Redirect extends Mountable {
9
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
10
- async canAccess(_: Context) {
11
- return { canAccess: true, message: "" };
12
- }
13
-
14
- mount(router: Router, path: string) {
15
- router.get(path, async (ctx) => {
16
- ctx.status = 302;
17
- ctx.redirect("/new_url");
18
- });
19
- }
20
- })();
21
- `;
22
- }
23
- //# sourceMappingURL=redirect.js.map
@@ -1,54 +0,0 @@
1
- import { curryImportPath } from "../utils/import-path.js";
2
- export function testTemplate(action_name, new_file_fullpath) {
3
- const rel = curryImportPath(new_file_fullpath);
4
- return `import { withProdApp } from "${rel("src/back/test_utils/with-prod-app.js")}";
5
- import { VERY_LONG_TEST_TIMEOUT, webhintURL } from "${rel("src/back/test_utils/webhint.js")}";
6
- import { ${action_name}URL } from "${rel("src/back/routes/urls.js")}";
7
- import { getBrowser } from "${rel("src/back/test_utils/browser-creator.js")}";
8
- import { Browser, BrowserContext, Page } from "@playwright/test";
9
-
10
- describe("${action_name} webhint", () => {
11
- it(
12
- "doesn't crash",
13
- async function () {
14
- return withProdApp(async ({ base_url, rest_api }) => {
15
- await rest_api.get(${action_name}URL);
16
- await webhintURL(base_url + ${action_name}URL);
17
- // alternatively you can use webhintHTML for faster but less precise scans
18
- // or for scanning responses of requests that use some form of authorization:
19
- // const response = await rest_api.get(${action_name}URL);
20
- // await webhintHTML(response);
21
- });
22
- },
23
- VERY_LONG_TEST_TIMEOUT
24
- );
25
- });
26
-
27
- describe("${action_name}", () => {
28
- let page: Page;
29
- let browser: Browser;
30
- let context: BrowserContext;
31
-
32
- beforeEach(async () => {
33
- browser = await getBrowser();
34
- context = await browser.newContext();
35
- page = await context.newPage();
36
- });
37
-
38
- afterEach(async () => {
39
- await context.close();
40
- });
41
-
42
- it(
43
- "works as expected",
44
- async function () {
45
- return withProdApp(async ({ base_url }) => {
46
- await page.goto(base_url + ${action_name}URL);
47
- });
48
- },
49
- VERY_LONG_TEST_TIMEOUT
50
- );
51
- });
52
- `;
53
- }
54
- //# sourceMappingURL=route-test.js.map
@@ -1,66 +0,0 @@
1
- import { curryImportPath } from "../utils/import-path.js";
2
- export async function statefulPageTemplate(action_name, newfilefullpath) {
3
- const rel = curryImportPath(newfilefullpath);
4
- return `import { TempstreamJSX, Templatable } from "tempstream";
5
- import { BaseContext } from "koa";
6
- import { StatefulPage } from "@sealcode/sealgen";
7
- import html from "${rel("src/back/html.js")}";
8
-
9
- export const actionName = "${action_name}";
10
-
11
- const actions = {
12
- add: (state: State, inputs: Record<string, string>) => {
13
- console.log({ inputs });
14
- return {
15
- ...state,
16
- elements: [...state.elements, inputs.element_to_add || "new element"],
17
- };
18
- },
19
- remove: (state: State, _: unknown, index_to_remove: number) => {
20
- return {
21
- ...state,
22
- elements: state.elements.filter((_, index) => index != index_to_remove),
23
- };
24
- },
25
- } as const;
26
-
27
- type State = {
28
- elements: string[];
29
- };
30
-
31
- export default new (class ${action_name}Page extends StatefulPage<State, typeof actions> {
32
- actions = actions;
33
-
34
- getInitialState() {
35
- return { elements: ["one", "two", "three"] };
36
- }
37
-
38
- wrapInLayout(ctx: BaseContext, content: Templatable): Templatable {
39
- return html(ctx, "${action_name}", content);
40
- }
41
-
42
- render(ctx: BaseContext, state: State, inputs: Record<string, string>) {
43
- return (
44
- <div>
45
- <ul>
46
- {state.elements.map((e, index) => (
47
- <li>
48
- {e} {this.makeActionButton(state, "remove", index)}
49
- </li>
50
- ))}
51
- </ul>
52
- <div>
53
- <input
54
- name="element_to_add"
55
- type="text"
56
- value={inputs.element_to_add || ""}
57
- />
58
- {this.makeActionButton(state, "add")}
59
- </div>
60
- </div>
61
- );
62
- }
63
- })();
64
- `;
65
- }
66
- //# sourceMappingURL=stateful-page.js.map
@@ -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
@@ -1,7 +0,0 @@
1
- export function to_base64(s) {
2
- return Buffer.from(s).toString("base64");
3
- }
4
- export function from_base64(s) {
5
- return Buffer.from(s, "base64").toString("utf-8");
6
- }
7
- //# sourceMappingURL=base64.js.map
@@ -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/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,6 +0,0 @@
1
- export function makeSlug(t) {
2
- return t
3
- .replaceAll(/\P{General_Category=Letter}/g, "-")
4
- .replaceAll(/-+/g, "-");
5
- }
6
- //# sourceMappingURL=make-slug.js.map
@@ -1,6 +0,0 @@
1
- export function* naturalNumbers(min, max) {
2
- for (let i = min; i <= max; i++) {
3
- yield i;
4
- }
5
- }
6
- //# sourceMappingURL=natural-numbers.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
@@ -1,4 +0,0 @@
1
- export async function sleep(time) {
2
- return new Promise((resolve) => setTimeout(resolve, time));
3
- }
4
- //# sourceMappingURL=sleep.js.map
@@ -1,6 +0,0 @@
1
- export function t(ctx, key, props, default_translation) {
2
- return /* HTML */ `<span translation-key="${key.replace('"', '\\"')}"
3
- >${ctx.$app.getString(key, props, default_translation)}</span
4
- >`;
5
- }
6
- //# sourceMappingURL=translate.js.map
@@ -1,5 +0,0 @@
1
- import qs from "qs";
2
- export function UrlWithNewParams(ctx, query_params) {
3
- return `${ctx.path}?${qs.stringify(query_params)}`;
4
- }
5
- //# sourceMappingURL=url-with-new-params.js.map
@@ -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/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
@@ -1,22 +0,0 @@
1
- import { defineConfig } from "vitest/config";
2
- const exclude = [
3
- "docker_node_modules",
4
- "node_modules",
5
- "dist",
6
- "lib",
7
- "webhint",
8
- ];
9
- export default defineConfig({
10
- test: {
11
- testTimeout: 10000,
12
- exclude,
13
- globals: true,
14
- coverage: {
15
- exclude,
16
- enabled: true,
17
- all: true,
18
- include: ["src/**", "test?(-*).?(c|m)[jt]s?(x)"],
19
- },
20
- },
21
- });
22
- //# sourceMappingURL=vitest.config.js.map