@equinor/apollo-utils 0.1.7 → 0.1.9
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/dist/index.d.mts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +3 -6
- package/dist/index.mjs +3 -6
- package/package.json +25 -20
package/dist/index.d.mts
CHANGED
|
@@ -8,8 +8,8 @@ type ValidationErrorMap<T> = Map<keyof T, {
|
|
|
8
8
|
}>;
|
|
9
9
|
|
|
10
10
|
declare function createValidator<S extends z.ZodTypeAny>(schema: S): {
|
|
11
|
-
validate: <E extends z.
|
|
12
|
-
validateAsync: <
|
|
11
|
+
validate: <E extends z.infer<typeof schema>>(entity: E) => ValidationErrorMap<E> | undefined;
|
|
12
|
+
validateAsync: <E extends z.infer<typeof schema>>(entity: z.infer<typeof schema>) => Promise<ValidationErrorMap<E> | undefined>;
|
|
13
13
|
getSchema(): S;
|
|
14
14
|
};
|
|
15
15
|
|
package/dist/index.d.ts
CHANGED
|
@@ -8,8 +8,8 @@ type ValidationErrorMap<T> = Map<keyof T, {
|
|
|
8
8
|
}>;
|
|
9
9
|
|
|
10
10
|
declare function createValidator<S extends z.ZodTypeAny>(schema: S): {
|
|
11
|
-
validate: <E extends z.
|
|
12
|
-
validateAsync: <
|
|
11
|
+
validate: <E extends z.infer<typeof schema>>(entity: E) => ValidationErrorMap<E> | undefined;
|
|
12
|
+
validateAsync: <E extends z.infer<typeof schema>>(entity: z.infer<typeof schema>) => Promise<ValidationErrorMap<E> | undefined>;
|
|
13
13
|
getSchema(): S;
|
|
14
14
|
};
|
|
15
15
|
|
package/dist/index.js
CHANGED
|
@@ -96,8 +96,7 @@ function useFormFamilyMutation(family, param, validator) {
|
|
|
96
96
|
const mutate = (0, import_jotai.useSetAtom)(family(param));
|
|
97
97
|
return (update) => {
|
|
98
98
|
return mutate((previous) => {
|
|
99
|
-
if (!previous)
|
|
100
|
-
return;
|
|
99
|
+
if (!previous) return;
|
|
101
100
|
const updatedValues = __spreadValues(__spreadValues({}, previous.values), update);
|
|
102
101
|
const errors = validator == null ? void 0 : validator.validate(updatedValues);
|
|
103
102
|
return {
|
|
@@ -115,14 +114,12 @@ function createValidator(schema) {
|
|
|
115
114
|
return {
|
|
116
115
|
validate: (entity) => {
|
|
117
116
|
const validation = schema.safeParse(entity);
|
|
118
|
-
if (validation.success)
|
|
119
|
-
return void 0;
|
|
117
|
+
if (validation.success) return void 0;
|
|
120
118
|
return prepareErrors(validation);
|
|
121
119
|
},
|
|
122
120
|
validateAsync: (entity) => __async(this, null, function* () {
|
|
123
121
|
const validation = yield schema.safeParseAsync(entity);
|
|
124
|
-
if (validation.success)
|
|
125
|
-
return void 0;
|
|
122
|
+
if (validation.success) return void 0;
|
|
126
123
|
return prepareErrors(validation);
|
|
127
124
|
}),
|
|
128
125
|
getSchema() {
|
package/dist/index.mjs
CHANGED
|
@@ -70,8 +70,7 @@ function useFormFamilyMutation(family, param, validator) {
|
|
|
70
70
|
const mutate = useSetAtom(family(param));
|
|
71
71
|
return (update) => {
|
|
72
72
|
return mutate((previous) => {
|
|
73
|
-
if (!previous)
|
|
74
|
-
return;
|
|
73
|
+
if (!previous) return;
|
|
75
74
|
const updatedValues = __spreadValues(__spreadValues({}, previous.values), update);
|
|
76
75
|
const errors = validator == null ? void 0 : validator.validate(updatedValues);
|
|
77
76
|
return {
|
|
@@ -89,14 +88,12 @@ function createValidator(schema) {
|
|
|
89
88
|
return {
|
|
90
89
|
validate: (entity) => {
|
|
91
90
|
const validation = schema.safeParse(entity);
|
|
92
|
-
if (validation.success)
|
|
93
|
-
return void 0;
|
|
91
|
+
if (validation.success) return void 0;
|
|
94
92
|
return prepareErrors(validation);
|
|
95
93
|
},
|
|
96
94
|
validateAsync: (entity) => __async(this, null, function* () {
|
|
97
95
|
const validation = yield schema.safeParseAsync(entity);
|
|
98
|
-
if (validation.success)
|
|
99
|
-
return void 0;
|
|
96
|
+
if (validation.success) return void 0;
|
|
100
97
|
return prepareErrors(validation);
|
|
101
98
|
}),
|
|
102
99
|
getSchema() {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@equinor/apollo-utils",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.9",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"module": "./dist/index.mjs",
|
|
@@ -13,34 +13,39 @@
|
|
|
13
13
|
"clean": "rm -rf .turbo && rm -rf node_modules && rm -rf dist",
|
|
14
14
|
"dev": "tsup src/index.ts --format esm,cjs --watch --dts --external react",
|
|
15
15
|
"lint": "TIMING=1 eslint . --fix",
|
|
16
|
-
"type-check": "tsc --noEmit",
|
|
17
16
|
"test": "vitest --run",
|
|
18
|
-
"test:watch": "vitest --watch"
|
|
17
|
+
"test:watch": "vitest --watch",
|
|
18
|
+
"type-check": "tsc --noEmit"
|
|
19
19
|
},
|
|
20
20
|
"dependencies": {
|
|
21
|
-
"jotai": "^2.
|
|
22
|
-
"
|
|
23
|
-
"zod": "^3.22.3"
|
|
24
|
-
},
|
|
25
|
-
"peerDependencies": {
|
|
26
|
-
"@equinor/eds-core-react": "^0.35.1",
|
|
27
|
-
"react": "^18.2.0",
|
|
28
|
-
"react-dom": "^18.2.0",
|
|
29
|
-
"styled-components": "^5.3.11"
|
|
21
|
+
"jotai": "^2.8.4",
|
|
22
|
+
"zod": "^3.23.8"
|
|
30
23
|
},
|
|
31
24
|
"devDependencies": {
|
|
32
|
-
"@
|
|
25
|
+
"@equinor/eds-core-react": "^0.40.0",
|
|
26
|
+
"@testing-library/react": "^16.0.0",
|
|
33
27
|
"@testing-library/react-hooks": "^8.0.1",
|
|
34
|
-
"@types/react": "^18.
|
|
35
|
-
"@types/react-dom": "^18.0
|
|
36
|
-
"@types/styled-components": "^5.1.
|
|
37
|
-
"@vitest/ui": "^
|
|
28
|
+
"@types/react": "^18.3.3",
|
|
29
|
+
"@types/react-dom": "^18.3.0",
|
|
30
|
+
"@types/styled-components": "^5.1.34",
|
|
31
|
+
"@vitest/ui": "^1.6.0",
|
|
38
32
|
"eslint": "^8.56.0",
|
|
39
33
|
"eslint-config-custom": "*",
|
|
40
|
-
"jsdom": "^
|
|
34
|
+
"jsdom": "^24.1.0",
|
|
35
|
+
"react": "^18.2.0",
|
|
36
|
+
"react-dom": "^18.2.0",
|
|
37
|
+
"styled-components": "^6.1.11",
|
|
41
38
|
"tsconfig": "*",
|
|
42
|
-
"
|
|
43
|
-
"
|
|
39
|
+
"tsup": "^8.1.0",
|
|
40
|
+
"typescript": "^5.5.2",
|
|
41
|
+
"vitest": "^1.6.0"
|
|
42
|
+
},
|
|
43
|
+
"peerDependencies": {
|
|
44
|
+
"@equinor/eds-core-react": "^0.35.1",
|
|
45
|
+
"react": "^18.2.0",
|
|
46
|
+
"react-dom": "^18.2.0",
|
|
47
|
+
"styled-components": "^5.3.11",
|
|
48
|
+
"tsup": "^8.0.1"
|
|
44
49
|
},
|
|
45
50
|
"publishConfig": {
|
|
46
51
|
"access": "public"
|