@equinor/apollo-utils 0.1.8 → 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 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.TypeOf<S>>(entity: E) => ValidationErrorMap<E> | undefined;
12
- validateAsync: <E_1 extends z.TypeOf<S>>(entity: z.infer<typeof schema>) => Promise<ValidationErrorMap<E_1> | undefined>;
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.TypeOf<S>>(entity: E) => ValidationErrorMap<E> | undefined;
12
- validateAsync: <E_1 extends z.TypeOf<S>>(entity: z.infer<typeof schema>) => Promise<ValidationErrorMap<E_1> | undefined>;
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.8",
3
+ "version": "0.1.9",
4
4
  "license": "MIT",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",
@@ -13,13 +13,32 @@
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.0.1",
22
- "zod": "^3.22.3"
21
+ "jotai": "^2.8.4",
22
+ "zod": "^3.23.8"
23
+ },
24
+ "devDependencies": {
25
+ "@equinor/eds-core-react": "^0.40.0",
26
+ "@testing-library/react": "^16.0.0",
27
+ "@testing-library/react-hooks": "^8.0.1",
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",
32
+ "eslint": "^8.56.0",
33
+ "eslint-config-custom": "*",
34
+ "jsdom": "^24.1.0",
35
+ "react": "^18.2.0",
36
+ "react-dom": "^18.2.0",
37
+ "styled-components": "^6.1.11",
38
+ "tsconfig": "*",
39
+ "tsup": "^8.1.0",
40
+ "typescript": "^5.5.2",
41
+ "vitest": "^1.6.0"
23
42
  },
24
43
  "peerDependencies": {
25
44
  "@equinor/eds-core-react": "^0.35.1",
@@ -28,20 +47,6 @@
28
47
  "styled-components": "^5.3.11",
29
48
  "tsup": "^8.0.1"
30
49
  },
31
- "devDependencies": {
32
- "@testing-library/react": "^13.4.0",
33
- "@testing-library/react-hooks": "^8.0.1",
34
- "@types/react": "^18.0.1",
35
- "@types/react-dom": "^18.0.1",
36
- "@types/styled-components": "^5.1.26",
37
- "@vitest/ui": "^0.28.5",
38
- "eslint": "^8.56.0",
39
- "eslint-config-custom": "*",
40
- "jsdom": "^21.1.0",
41
- "tsconfig": "*",
42
- "typescript": "^5.2.2",
43
- "vitest": "^0.28.5"
44
- },
45
50
  "publishConfig": {
46
51
  "access": "public"
47
52
  }