@sealcode/sealgen 0.19.25 → 0.19.26

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.
@@ -10,7 +10,7 @@ describe("add crud test", () => {
10
10
  after(async () => {
11
11
  await page.close();
12
12
  });
13
- it.only("Generate simple sealious crud", async function() {
13
+ it("Generate simple sealious crud", async function() {
14
14
  const test_app = await RealAppTest.init();
15
15
  const path = "/sample";
16
16
  await test_app.runSealgenCommand(`add-collection --collection_name=sealcode-test`);
@@ -14,7 +14,7 @@ class BackendTSBuilder extends Builder {
14
14
  return "backend-ts";
15
15
  }
16
16
  ownsFile(file_path) {
17
- return (file_path.endsWith(".ts") || file_path.endsWith(".tsx")) && !file_path.endsWith("src/back/collections/collections.ts") && !file_path.endsWith("src/back/routes/routes.ts") && !file_path.endsWith("src/back/routes/urls.ts") && !file_path.endsWith("stimulus.ts") && !file_path.startsWith("src/front");
17
+ return (file_path.endsWith(".ts") || file_path.endsWith(".tsx")) && !file_path.endsWith("src/back/collections/collections.ts") && !file_path.endsWith("src/back/routes/routes.ts") && !file_path.endsWith("src/back/routes/urls.ts") && !file_path.endsWith("src/back/jdd-components/components.ts") && !file_path.endsWith("stimulus.ts") && !file_path.startsWith("src/front");
18
18
  }
19
19
  async dispose() {
20
20
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sealcode/sealgen",
3
- "version": "0.19.25",
3
+ "version": "0.19.26",
4
4
  "description": "Module to automate adding routes and collections to a sealious application",
5
5
  "main": "lib/index.js",
6
6
  "type": "module",
@@ -55,7 +55,7 @@
55
55
  "playwright": "^1.29.2",
56
56
  "source-map-support": "^0.5.21",
57
57
  "ts-node": "^10.9.1",
58
- "typescript": "5.9",
58
+ "typescript": "6.0.3",
59
59
  "typescript-eslint": "^8.44.0",
60
60
  "wait-port": "^1.0.4"
61
61
  },
package/src/add-route.ts CHANGED
@@ -54,20 +54,18 @@ export async function addRoute(
54
54
  ]);
55
55
 
56
56
  const { action, url, mode } = response as Record<string, string>;
57
- const extension = ["list", "lpr", "page", "sreact", "jdd-editor"].includes(
58
- mode
59
- )
60
- ? "tsx"
61
- : "ts";
57
+ const extension =
58
+ ["list", "lpr", "page", "sreact", "jdd-editor"].includes(mode!) ? "tsx"
59
+ : "ts";
62
60
 
63
- const base_file_name = escape_url_params(url) || "index";
61
+ const base_file_name = escape_url_params(url!) || "index";
64
62
  const file_path = target_locreq.resolve(
65
63
  `src/back/routes/${base_file_name}.${mode}.${extension}`
66
64
  );
67
65
  const test_file_path = target_locreq.resolve(
68
66
  `src/back/routes/${base_file_name}.test.ts`
69
67
  );
70
- const template = Templates[mode];
68
+ const template = Templates[mode!];
71
69
 
72
70
  if (!template) {
73
71
  throw new Error(`Could not get template ${mode}`);
@@ -78,7 +76,7 @@ export async function addRoute(
78
76
  return;
79
77
  }
80
78
  await fs.mkdir(resolve(file_path, "../"), { recursive: true });
81
- await fs.writeFile(file_path, await template(action, file_path));
79
+ await fs.writeFile(file_path, await template(action!, file_path));
82
80
  console.info(`${file_path} created`);
83
81
  console.info(`${test_file_path} created`);
84
82
  await generateRoutes();
@@ -91,9 +91,9 @@ export class ColorsBuilder extends Builder {
91
91
  }) {
92
92
  const c = colord(color);
93
93
  return /* HTML */ `<div
94
- class="color-box ${c.isDark() ? "is-dark" : ""} ${is_main
95
- ? "is-main"
96
- : ""} ${c.toHsl().l > 90 ? "is-almost-white" : ""}"
94
+ class="color-box ${c.isDark() ? "is-dark" : ""} ${is_main ?
95
+ "is-main"
96
+ : ""} ${c.toHsl().l > 90 ? "is-almost-white" : ""}"
97
97
  style="background-color: ${color}; order: ${parseInt(shade_no)}"
98
98
  data-color-name="${name}"
99
99
  data-color-group-name="${group_name}"
@@ -107,7 +107,7 @@ export class ColorsBuilder extends Builder {
107
107
  key == "brand" ? -1 : 11
108
108
  )) {
109
109
  html_colors += `<h2>${group_name}</h2><div class="group">`;
110
- const colors = color_groups[group_name];
110
+ const colors = color_groups[group_name]!;
111
111
  for (const [color_name, color_info] of Object.entries(colors)) {
112
112
  html_colors += `<h3>${color_name}</h3><div class="shades">`;
113
113
  const main_color = color_info.color;
@@ -156,7 +156,7 @@ export class ColorsBuilder extends Builder {
156
156
 
157
157
  function colorCodeFind(color_varibale_name: string) {
158
158
  const parts = color_varibale_name.split("-").slice(2);
159
- const colorGroup = parts[1];
159
+ const colorGroup = parts[1]!;
160
160
  const colorName = parts.slice(2).join("-").replace(/\)$/, "");
161
161
  const colorCode = color_groups[colorGroup]?.[colorName]?.color;
162
162
 
@@ -171,8 +171,8 @@ export class ColorsBuilder extends Builder {
171
171
  ) {
172
172
  let roundedContrast = "";
173
173
  if (fg !== "") {
174
- const fg_code = colorCodeFind(fg);
175
- const bg_code = colorCodeFind(bg);
174
+ const fg_code = colorCodeFind(fg)!;
175
+ const bg_code = colorCodeFind(bg)!;
176
176
  const contrast = hex(fg_code, bg_code);
177
177
  roundedContrast = Math.round(contrast).toString();
178
178
  }
@@ -430,15 +430,14 @@ export class ColorsBuilder extends Builder {
430
430
  document.addEventListener("click", (event) => {
431
431
  const box = event.target.closest(".color-box");
432
432
  if (box) {
433
- const css_var = box.classList.contains(
434
- "is-main"
435
- )
436
- ? \`var(--color-\${box.getAttribute(
433
+ const css_var =
434
+ box.classList.contains("is-main") ?
435
+ \`var(--color-\${box.getAttribute(
437
436
  "data-color-group-name"
438
437
  )}-\${box.getAttribute(
439
438
  "data-color-name"
440
439
  )})\`
441
- : \`var(--color-\${box.getAttribute(
440
+ : \`var(--color-\${box.getAttribute(
442
441
  "data-color-group-name"
443
442
  )}-\${box.getAttribute(
444
443
  "data-color-name"
@@ -47,7 +47,7 @@ export default class TableController extends Controller {
47
47
  swapRows(index_a: number, index_b: number) {
48
48
  const tbody = this.getTbody();
49
49
  const [a, b] = [index_a, index_b].sort().reverse(); // we want them in descending order
50
- tbody.insertBefore(tbody.children[a], tbody.children[b]);
50
+ tbody.insertBefore(tbody.children[a!]!, tbody.children[b!]!);
51
51
  this.reindex();
52
52
  }
53
53
 
@@ -101,13 +101,13 @@ export default class TableController extends Controller {
101
101
  // disable up/down buttons for first/last items
102
102
  // first reset all states to enabled
103
103
  this.element
104
- .querySelectorAll(
104
+ .querySelectorAll<HTMLButtonElement>(
105
105
  `[data-action="sealgen-table#moveUp"], [data-action="sealgen-table#moveDown"]`
106
106
  )
107
107
  .forEach((e: HTMLButtonElement) => (e.disabled = false));
108
108
  // then disable the ones at the top and bottom
109
109
  this.element
110
- .querySelectorAll(
110
+ .querySelectorAll<HTMLButtonElement>(
111
111
  'tr:first-child [data-action="sealgen-table#moveUp"], tr:last-child [data-action="sealgen-table#moveDown"]'
112
112
  )
113
113
  .forEach((e: HTMLButtonElement) => (e.disabled = true));
@@ -71,7 +71,7 @@ export abstract class StatefulPage<
71
71
 
72
72
  constructor(public form_id?: string) {
73
73
  super();
74
- const original_render = this.render.bind(this) as typeof this.render;
74
+ const original_render = this.render.bind(this);
75
75
  this.render = async (
76
76
  ctx: Context,
77
77
  state: State,
@@ -308,7 +308,7 @@ export abstract class StatefulPage<
308
308
  const { action, state, inputs, action_args } =
309
309
  await this.extractState(ctx);
310
310
  if (action) {
311
- const new_state = await this.actions[action]({
311
+ const new_state = await this.actions[action]!({
312
312
  ctx,
313
313
  state,
314
314
  inputs,
package/tsconfig.json CHANGED
@@ -17,6 +17,7 @@
17
17
  "sourceMap": true,
18
18
  "allowSyntheticDefaultImports": true,
19
19
  "skipLibCheck": true,
20
+ "noUncheckedIndexedAccess": true
20
21
  },
21
22
 
22
23
  "include": ["src/**/*"],
@@ -1,39 +0,0 @@
1
- import Router from "@koa/router";
2
- import { Context } from "koa";
3
- import { FlatTemplatable } from "tempstream";
4
- import { FormField } from "../fields/field.js";
5
- import { Table as TableField } from "../fields/table.js";
6
- import { Form } from "../form.js";
7
- import { FormControl, FormControlContext } from "./form-control.js";
8
- export type TableControlOptions<F extends Record<string, FormField>> = {
9
- subfield_controls: {
10
- [field_name in keyof F]: FormControl;
11
- };
12
- allow_removing?: boolean;
13
- label_add?: string;
14
- label: string;
15
- label_remove?: string;
16
- } & ({
17
- allow_adding: false;
18
- } | {
19
- allow_adding: true;
20
- make_new_row: (ctx: Context) => Promise<{
21
- [field_name in keyof F]: unknown;
22
- }>;
23
- });
24
- export declare const TABLE_COLUMN_FIELD_INDEX_PLACEHOLDER = "TABLE_ROW_INDEX________________";
25
- export declare class Table<F extends Record<string, FormField>> extends FormControl {
26
- table_field: TableField<F>;
27
- options: TableControlOptions<F>;
28
- role: "input";
29
- constructor(table_field: TableField<F>, options: TableControlOptions<F>);
30
- render(fctx: FormControlContext): Promise<FlatTemplatable>;
31
- getFrameID(): string;
32
- getActionURL(field_name: string, action: Record<string, unknown>): string;
33
- mount(router: Router, form: Form<any, any>): void;
34
- setAllowRemoving(value: boolean): this;
35
- setAllowAdding(value: boolean): this;
36
- setLabel(value: string): this;
37
- setRemoveLabel(value: string): this;
38
- setAddLabel(value: string): this;
39
- }
@@ -1,47 +0,0 @@
1
- export * as Controls from "./forms/controls/controls.js";
2
- export * from "./forms/fields/field.js";
3
- export * as Fields from "./forms/fields/fields.js";
4
- export * from "./page/mountable.js";
5
- export * from "./page/page.js";
6
- export * from "./page/stateful-page.js";
7
- export * from "./forms/form-types.js";
8
- export * from "./forms/form.js";
9
- export * from "./page/props-parser.js";
10
- export * from "./utils/utils.js";
11
- export * from "./page/list.js";
12
- export * from "./page/sealious-list.js";
13
- export * from "./utils/translate.js";
14
- export * as sanitize from "./sanitize.js";
15
- export * from "./forms/multiform.js";
16
- export * as Components from "./components/components.js";
17
- export * from "./mount.js";
18
- export * from "./page/default-list-filters.js";
19
- export * from "./forms/fields/get-field-for-sealious.js";
20
- export * from "./forms/controls/form-control.js";
21
- import { Context } from "koa";
22
- import { Readable } from "node:stream";
23
- export interface HTMLOptions {
24
- morphing?: boolean;
25
- }
26
- export interface HTMLHeadOptions {
27
- ctx: Context;
28
- title: string | Promise<string | Readable>;
29
- htmlOptions: Partial<HTMLOptions>;
30
- metaImage?: string;
31
- canonicalPath?: string;
32
- css_clumps: string[];
33
- description: string;
34
- }
35
- export interface HTMLArgs {
36
- ctx: Context;
37
- title: string | Promise<string>;
38
- body: string | Promise<string> | Readable;
39
- htmlOptions?: Partial<HTMLOptions>;
40
- makeHead?: (args: HTMLHeadOptions) => string | Promise<string> | Readable | Promise<Readable>;
41
- metaImage?: string;
42
- canonicalPath?: string;
43
- css_clumps?: string[];
44
- description: string;
45
- hideNavigation?: boolean;
46
- }
47
- export type HTMLFunc = (args: HTMLArgs) => Readable | Promise<Readable>;