@sealcode/sealgen 0.15.13 → 0.15.15
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,8 +1,8 @@
|
|
|
1
1
|
import { FilePointer } from "@sealcode/file-manager";
|
|
2
2
|
import type { FlatTemplatable } from "tempstream";
|
|
3
3
|
import type { FormField } from "./fields/field.js";
|
|
4
|
-
export type FormDataPrimitive = string | string[] | number | undefined;
|
|
5
|
-
export type FormDataValue = FormDataPrimitive | Record<string, FormDataPrimitive
|
|
4
|
+
export type FormDataPrimitive = string | string[] | number | undefined | FilePointer;
|
|
5
|
+
export type FormDataValue = FormDataPrimitive | Record<string, FormDataPrimitive>;
|
|
6
6
|
export type FieldValueType<F extends FormField> = F extends FormField<infer R> ? R : never;
|
|
7
7
|
export type FormFieldsToValues<F extends Record<string, FormField<boolean, keyof F>>> = {
|
|
8
8
|
[Property in keyof F]: FieldValueType<F[Property]>;
|
package/lib/generate-routes.js
CHANGED
|
@@ -65,7 +65,9 @@ ${files.map(
|
|
|
65
65
|
).join("\n")}
|
|
66
66
|
|
|
67
67
|
export default function mountAutoRoutes(router: Router) {
|
|
68
|
-
${files.
|
|
68
|
+
${files.sort(
|
|
69
|
+
({ url: url1 }, { url: url2 }) => url1.includes(":") ? 1 : url2.includes(":") ? -1 : url1 < url2 ? -1 : 1
|
|
70
|
+
).map(
|
|
69
71
|
({ actionName }) => ` mount(router, URLs.${actionName}URL, ${actionName});`
|
|
70
72
|
).join("\n")}
|
|
71
73
|
}`;
|
package/package.json
CHANGED
package/src/forms/form-types.ts
CHANGED
|
@@ -2,11 +2,16 @@ import { FilePointer } from "@sealcode/file-manager";
|
|
|
2
2
|
import type { FlatTemplatable } from "tempstream";
|
|
3
3
|
import type { FormField } from "./fields/field.js";
|
|
4
4
|
|
|
5
|
-
export type FormDataPrimitive =
|
|
5
|
+
export type FormDataPrimitive =
|
|
6
|
+
| string
|
|
7
|
+
| string[]
|
|
8
|
+
| number
|
|
9
|
+
| undefined
|
|
10
|
+
| FilePointer;
|
|
11
|
+
|
|
6
12
|
export type FormDataValue =
|
|
7
13
|
| FormDataPrimitive
|
|
8
|
-
| Record<string, FormDataPrimitive
|
|
9
|
-
| FilePointer;
|
|
14
|
+
| Record<string, FormDataPrimitive>;
|
|
10
15
|
|
|
11
16
|
export type FieldValueType<F extends FormField> = F extends FormField<infer R>
|
|
12
17
|
? R
|
package/src/generate-routes.ts
CHANGED
|
@@ -90,6 +90,16 @@ ${files
|
|
|
90
90
|
|
|
91
91
|
export default function mountAutoRoutes(router: Router) {
|
|
92
92
|
${files
|
|
93
|
+
|
|
94
|
+
.sort(({ url: url1 }, { url: url2 }) =>
|
|
95
|
+
url1.includes(":") // make sure the parametrized ones come later, so the more concrete ones show up first. This is not a full solution, but works for single-parameter urls
|
|
96
|
+
? 1
|
|
97
|
+
: url2.includes(":")
|
|
98
|
+
? -1
|
|
99
|
+
: url1 < url2
|
|
100
|
+
? -1
|
|
101
|
+
: 1
|
|
102
|
+
)
|
|
93
103
|
.map(
|
|
94
104
|
({ actionName }) =>
|
|
95
105
|
` mount(router, URLs.${actionName}URL, ${actionName});`
|