formeact 0.0.3 → 0.0.4

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.
@@ -0,0 +1,3 @@
1
+ import { FormBuilderField } from "../../core/types";
2
+ export declare function loadJson<T>(name: string): Promise<T>;
3
+ export declare function loadForm<T>(name?: string): Promise<FormBuilderField<T>>;
@@ -0,0 +1,16 @@
1
+ "use server";
2
+ import { promises as fs } from "fs";
3
+ export async function loadJson(name) {
4
+ const file = await fs.readFile(process.cwd() + "/src/assets/" + name + ".json", "utf-8");
5
+ return JSON.parse(file);
6
+ }
7
+ export async function loadForm(name) {
8
+ if (!name)
9
+ throw new Error("Form not found");
10
+ try {
11
+ return loadJson(`forms/${name}`);
12
+ }
13
+ catch {
14
+ throw new Error(`Couldn't load form ${name}`);
15
+ }
16
+ }
@@ -43,3 +43,7 @@ export type FormControls<T, K extends keyof T> = {
43
43
  update: (id: K, x: T[K]) => void;
44
44
  clear: () => void;
45
45
  };
46
+ export type AuthCredentials = {
47
+ email: string;
48
+ password: string;
49
+ };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
 
3
3
  "name": "formeact",
4
- "version": "0.0.3",
4
+ "version": "0.0.4",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",
7
7
  "license": "MIT",