@sealcode/sealgen 0.15.45 → 0.15.46

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/lib/builder.js CHANGED
@@ -104,6 +104,7 @@ class BackendTSBuilder extends Builder {
104
104
  sourcemap: true,
105
105
  bundle: false,
106
106
  jsxFactory: "TempstreamJSX.createElement",
107
+ jsxFragment: "TempstreamJSX.Fragment",
107
108
  outdir: "./dist/back",
108
109
  logLevel: "info",
109
110
  platform: "node",
@@ -6,10 +6,8 @@ const defaults = {
6
6
  import { Fields } from "@sealcode/sealgen";
7
7
  import type {FormDataValue} from "@sealcode/sealgen";`,
8
8
  fields: `
9
- email: new Fields.CollectionField(true, Users.fields.email),
10
9
  password: new Fields.SimpleFormField(true),`,
11
10
  controls: `
12
- new Controls.SimpleInput(fields.email, { label: "Email:", type: "email" }),
13
11
  new Controls.SimpleInput(fields.password, {
14
12
  label: "Password:",
15
13
  type: "password",
@@ -26,12 +26,12 @@ export class ${toPascalCase(
26
26
  content,
27
27
  }: ExtractStructuredComponentArgumentsParsed<typeof component_arguments>,
28
28
  classes: string[],
29
- { render_markdown }: JDDContext
29
+ { language, render_markdown }: JDDContext
30
30
  ): FlatTemplatable {
31
31
  return (
32
32
  <div class={["${toKebabCase(component_name)}", ...classes]}>
33
33
  <h2>{title} \u2022 ${toPascalCase(component_name)} </h2>
34
- <div>{render_markdown(content)}</div>
34
+ <div>{render_markdown(language, content)}</div>
35
35
  </div>
36
36
  );
37
37
  }
@@ -1,7 +1,7 @@
1
1
  async function redirectTemplate(action_name) {
2
- return `import { Context } from "koa";
2
+ return `import type { Context } from "koa";
3
3
  import { Mountable } from "@sealcode/sealgen";
4
- import Router from "@koa/router";
4
+ import type Router from "@koa/router";
5
5
 
6
6
  export const actionName = "${action_name}";
7
7
 
@@ -70,7 +70,7 @@ async function createItemFormTemplate(create_action_name, newfilefullpath, colle
70
70
  return html(
71
71
  ctx,
72
72
  "Create ${toKebabCase(collection_name)}",
73
- tempstream/* HTML */ \` <div class="add-opinion-form">
73
+ tempstream/* HTML */ \` <div class="sealgen-crud-form">
74
74
  <a class="" href="\${${list_action}URL}"
75
75
  >\u2190 Back to ${collection_name} list</a
76
76
  >
@@ -45,15 +45,20 @@ async function editItemFormTemplate(edit_action_name, newfilefullpath, collectio
45
45
  return { canAccess: response?.allowed || false, message: response?.reason || "" };
46
46
  };`,
47
47
  onsubmit: `
48
- async onSubmit(ctx: Context) {
48
+ async onSubmit(ctx: Context) {
49
49
  const data = await this.getParsedValues(ctx);
50
- const id = await this.getID(ctx);
51
- const {items: [item]} = await ctx.$app.collections["${toKebabCase(
50
+ const id = await this.getID(ctx);
51
+ const {items: [item]} = await ctx.$app.collections["${toKebabCase(
52
52
  collection_name
53
53
  )}"]
54
- .list(ctx.$context)
55
- .ids([id])
56
- .fetch();
54
+ .list(ctx.$context)
55
+ .ids([id])
56
+ .fetch();
57
+
58
+ if (!item) {
59
+ throw new Error("Unknown id: " + id);
60
+ }
61
+
57
62
  if (!data) {
58
63
  throw new Error("Error when parsing the form values");
59
64
  }
@@ -141,7 +146,7 @@ async function editItemFormTemplate(edit_action_name, newfilefullpath, collectio
141
146
  return html(
142
147
  ctx,
143
148
  "Edit ${toPascalCase(collection_name)}",
144
- tempstream/* HTML */ \` <div class="add-opinion-form">
149
+ tempstream/* HTML */ \` <div class="sealgen-crud-form">
145
150
  <a class="" href="\${${list_action}URL}"
146
151
  >\u2190 Back to ${collection_name} list</a
147
152
  >
@@ -28,7 +28,7 @@ export default new (class ${delete_action_name}Redirect extends Mountable {
28
28
  router.get(path, async (ctx) => {
29
29
  await ctx.$app.collections["${toKebabCase(
30
30
  collection_name
31
- )}"].removeByID(ctx.$context, ctx.params.id);
31
+ )}"].removeByID(ctx.$context, ctx.params.id!);
32
32
  ctx.status = 302;
33
33
  ctx.redirect(${list_action_name}URL);
34
34
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sealcode/sealgen",
3
- "version": "0.15.45",
3
+ "version": "0.15.46",
4
4
  "description": "Module to automate adding routes and collections to a sealious application",
5
5
  "main": "lib/index.js",
6
6
  "type": "module",
package/src/builder.ts CHANGED
@@ -135,6 +135,7 @@ export class BackendTSBuilder extends Builder {
135
135
  sourcemap: true,
136
136
  bundle: false,
137
137
  jsxFactory: "TempstreamJSX.createElement",
138
+ jsxFragment: "TempstreamJSX.Fragment",
138
139
  outdir: "./dist/back",
139
140
  logLevel: "info",
140
141
  platform: "node",
@@ -7,10 +7,8 @@ const defaults = {
7
7
  import { Fields } from "@sealcode/sealgen";
8
8
  import type {FormDataValue} from "@sealcode/sealgen";`,
9
9
  fields: `
10
- email: new Fields.CollectionField(true, Users.fields.email),
11
10
  password: new Fields.SimpleFormField(true),`,
12
11
  controls: `
13
- new Controls.SimpleInput(fields.email, { label: "Email:", type: "email" }),
14
12
  new Controls.SimpleInput(fields.password, {
15
13
  label: "Password:",
16
14
  type: "password",
@@ -27,12 +27,12 @@ export class ${toPascalCase(
27
27
  content,
28
28
  }: ExtractStructuredComponentArgumentsParsed<typeof component_arguments>,
29
29
  classes: string[],
30
- { render_markdown }: JDDContext
30
+ { language, render_markdown }: JDDContext
31
31
  ): FlatTemplatable {
32
32
  return (
33
33
  <div class={["${toKebabCase(component_name)}", ...classes]}>
34
34
  <h2>{title} • ${toPascalCase(component_name)} </h2>
35
- <div>{render_markdown(content)}</div>
35
+ <div>{render_markdown(language, content)}</div>
36
36
  </div>
37
37
  );
38
38
  }
@@ -1,7 +1,7 @@
1
1
  export async function redirectTemplate(action_name: string): Promise<string> {
2
- return `import { Context } from "koa";
2
+ return `import type { Context } from "koa";
3
3
  import { Mountable } from "@sealcode/sealgen";
4
- import Router from "@koa/router";
4
+ import type Router from "@koa/router";
5
5
 
6
6
  export const actionName = "${action_name}";
7
7
 
@@ -109,7 +109,7 @@ export async function createItemFormTemplate(
109
109
  return html(
110
110
  ctx,
111
111
  "Create ${toKebabCase(collection_name)}",
112
- tempstream/* HTML */ \` <div class="add-opinion-form">
112
+ tempstream/* HTML */ \` <div class="sealgen-crud-form">
113
113
  <a class="" href="\${${list_action}URL}"
114
114
  >← Back to ${collection_name} list</a
115
115
  >
@@ -63,15 +63,20 @@ export async function editItemFormTemplate(
63
63
  };`,
64
64
 
65
65
  onsubmit: `
66
- async onSubmit(ctx: Context) {
66
+ async onSubmit(ctx: Context) {
67
67
  const data = await this.getParsedValues(ctx);
68
- const id = await this.getID(ctx);
69
- const {items: [item]} = await ctx.$app.collections["${toKebabCase(
68
+ const id = await this.getID(ctx);
69
+ const {items: [item]} = await ctx.$app.collections["${toKebabCase(
70
70
  collection_name
71
71
  )}"]
72
- .list(ctx.$context)
73
- .ids([id])
74
- .fetch();
72
+ .list(ctx.$context)
73
+ .ids([id])
74
+ .fetch();
75
+
76
+ if (!item) {
77
+ throw new Error("Unknown id: " + id);
78
+ }
79
+
75
80
  if (!data) {
76
81
  throw new Error("Error when parsing the form values");
77
82
  }
@@ -184,7 +189,7 @@ export async function editItemFormTemplate(
184
189
  return html(
185
190
  ctx,
186
191
  "Edit ${toPascalCase(collection_name)}",
187
- tempstream/* HTML */ \` <div class="add-opinion-form">
192
+ tempstream/* HTML */ \` <div class="sealgen-crud-form">
188
193
  <a class="" href="\${${list_action}URL}"
189
194
  >← Back to ${collection_name} list</a
190
195
  >
@@ -34,7 +34,7 @@ export default new (class ${delete_action_name}Redirect extends Mountable {
34
34
  router.get(path, async (ctx) => {
35
35
  await ctx.$app.collections["${toKebabCase(
36
36
  collection_name
37
- )}"].removeByID(ctx.$context, ctx.params.id);
37
+ )}"].removeByID(ctx.$context, ctx.params.id!);
38
38
  ctx.status = 302;
39
39
  ctx.redirect(${list_action_name}URL);
40
40
  });
@@ -1 +0,0 @@
1
- export {};
@@ -1,2 +0,0 @@
1
- declare const _default: import("vite").UserConfig;
2
- export default _default;