@sealcode/sealgen 0.14.8 → 0.14.10

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.
@@ -1,6 +1,5 @@
1
1
  function collectionTemplate(collection_name) {
2
- return `import type { App, Policy } from "sealious";
3
- import { Collection, FieldTypes, Policies } from "sealious";
2
+ return `import { Collection, FieldTypes, Policies } from "sealious";
4
3
 
5
4
  export default class ${collection_name} extends Collection {
6
5
  fields = {
@@ -1,15 +1,9 @@
1
1
  import { curryImportPath } from "../utils/import-path.js";
2
2
  async function formTemplate(action_name, newfilefullpath) {
3
3
  const rel = curryImportPath(newfilefullpath);
4
- return `import { Context } from "koa";
5
- import {
6
- Form,
7
- FormData,
8
- FormDataValue,
9
- Fields,
10
- Controls,
11
- fieldsToShape,
12
- } from "@sealcode/sealgen";
4
+ return `import type { Context } from "koa";
5
+ import type { FormData, FormDataValue } from "@sealcode/sealgen";
6
+ import { Form, Fields, Controls, fieldsToShape } from "@sealcode/sealgen";
13
7
  import html from "${rel("src/back/html.js")}";
14
8
  import { Users } from "${rel("src/back/collections/collections.js")}";
15
9
 
@@ -20,7 +14,7 @@ const fields = {
20
14
  password: new Fields.SimpleFormField(true),
21
15
  };
22
16
 
23
- export const ${action_name}Shape = Fields.fieldsToShape(fields);
17
+ export const ${action_name}Shape = fieldsToShape(fields);
24
18
 
25
19
  export default new (class ${action_name}Form extends Form<typeof fields, void> {
26
20
  defaultSuccessMessage = "Formularz wype\u0142niony poprawnie";
@@ -28,7 +22,10 @@ export default new (class ${action_name}Form extends Form<typeof fields, void> {
28
22
 
29
23
  controls = [
30
24
  new Controls.SimpleInput(fields.email, { label: "Email:", type: "email" }),
31
- new Controls.SimpleInput(fields.password, { label: "Password:", type: "password" }),
25
+ new Controls.SimpleInput(fields.password, {
26
+ label: "Password:",
27
+ type: "password",
28
+ }),
32
29
  ];
33
30
 
34
31
  async validateValues(
@@ -1,13 +1,10 @@
1
1
  import _locreq from "locreq";
2
- import { curryImportPath, exec } from "./utils.js";
2
+ import { exec } from "./utils.js";
3
3
  const target_locreq = _locreq(process.cwd());
4
4
  import { promises as fs } from "fs";
5
5
  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(
8
- `./back/collections/${collection_name}.js`
9
- )}";
10
- const c = new Collection();
6
+ const extractor_code = `import {default as the_app} from "./app.js";
7
+ const c = new the_app().collections["${collection_name}"];
11
8
  const fields = [];
12
9
  for (const field_name in c.fields){
13
10
  const field = c.fields[field_name];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sealcode/sealgen",
3
- "version": "0.14.8",
3
+ "version": "0.14.10",
4
4
  "description": "Module to automate adding routes and collections to a sealious application",
5
5
  "main": "dist/index.js",
6
6
  "type": "module",
@@ -1,6 +1,5 @@
1
1
  export function collectionTemplate(collection_name: string) {
2
- return `import type { App, Policy } from "sealious";
3
- import { Collection, FieldTypes, Policies } from "sealious";
2
+ return `import { Collection, FieldTypes, Policies } from "sealious";
4
3
 
5
4
  export default class ${collection_name} extends Collection {
6
5
  fields = {
@@ -5,15 +5,9 @@ export async function formTemplate(
5
5
  newfilefullpath: string
6
6
  ): Promise<string> {
7
7
  const rel = curryImportPath(newfilefullpath);
8
- return `import { Context } from "koa";
9
- import {
10
- Form,
11
- FormData,
12
- FormDataValue,
13
- Fields,
14
- Controls,
15
- fieldsToShape,
16
- } from "@sealcode/sealgen";
8
+ return `import type { Context } from "koa";
9
+ import type { FormData, FormDataValue } from "@sealcode/sealgen";
10
+ import { Form, Fields, Controls, fieldsToShape } from "@sealcode/sealgen";
17
11
  import html from "${rel("src/back/html.js")}";
18
12
  import { Users } from "${rel("src/back/collections/collections.js")}";
19
13
 
@@ -24,7 +18,7 @@ const fields = {
24
18
  password: new Fields.SimpleFormField(true),
25
19
  };
26
20
 
27
- export const ${action_name}Shape = Fields.fieldsToShape(fields);
21
+ export const ${action_name}Shape = fieldsToShape(fields);
28
22
 
29
23
  export default new (class ${action_name}Form extends Form<typeof fields, void> {
30
24
  defaultSuccessMessage = "Formularz wypełniony poprawnie";
@@ -32,7 +26,10 @@ export default new (class ${action_name}Form extends Form<typeof fields, void> {
32
26
 
33
27
  controls = [
34
28
  new Controls.SimpleInput(fields.email, { label: "Email:", type: "email" }),
35
- new Controls.SimpleInput(fields.password, { label: "Password:", type: "password" }),
29
+ new Controls.SimpleInput(fields.password, {
30
+ label: "Password:",
31
+ type: "password",
32
+ }),
36
33
  ];
37
34
 
38
35
  async validateValues(
@@ -1,16 +1,13 @@
1
1
  import _locreq from "locreq";
2
- import { curryImportPath, exec } from "./utils.js";
2
+ import { exec } from "./utils.js";
3
3
  const target_locreq = _locreq(process.cwd());
4
4
  import { promises as fs } from "fs";
5
5
 
6
6
  export default async function extract_fields_from_collection(
7
7
  collection_name: string
8
8
  ): Promise<{ name: string; type: string }[]> {
9
- const rel = curryImportPath(target_locreq.resolve("dist/back"));
10
- const extractor_code = `import {default as Collection} from "${rel(
11
- `./back/collections/${collection_name}.js`
12
- )}";
13
- const c = new Collection();
9
+ const extractor_code = `import {default as the_app} from "./app.js";
10
+ const c = new the_app().collections["${collection_name}"];
14
11
  const fields = [];
15
12
  for (const field_name in c.fields){
16
13
  const field = c.fields[field_name];