@equinor/apollo-utils 0.1.8 → 0.1.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.
package/LICENCE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2020 Equinor ASA
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,11 @@
1
+ [<-- Go back](../../README.md)
2
+
3
+ # @equinor/apollo-utls DEPRECATED
4
+
5
+ This package is deprecated. Please do not use.
6
+
7
+ ## Installation
8
+
9
+ ```sh
10
+ yarn add @equinor/apollo-utls
11
+ ```
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.10",
4
4
  "license": "MIT",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",
@@ -8,41 +8,45 @@
8
8
  "files": [
9
9
  "dist/**"
10
10
  ],
11
- "scripts": {
12
- "build": "tsup src/index.ts --format esm,cjs --dts --external react",
13
- "clean": "rm -rf .turbo && rm -rf node_modules && rm -rf dist",
14
- "dev": "tsup src/index.ts --format esm,cjs --watch --dts --external react",
15
- "lint": "TIMING=1 eslint . --fix",
16
- "type-check": "tsc --noEmit",
17
- "test": "vitest --run",
18
- "test:watch": "vitest --watch"
19
- },
20
11
  "dependencies": {
21
- "jotai": "^2.0.1",
22
- "zod": "^3.22.3"
12
+ "jotai": "^2.8.4",
13
+ "zod": "^3.23.8"
14
+ },
15
+ "devDependencies": {
16
+ "@equinor/eds-core-react": "^0.42.1",
17
+ "@testing-library/react": "^16.0.0",
18
+ "@testing-library/react-hooks": "^8.0.1",
19
+ "@types/react": "^18.3.3",
20
+ "@types/react-dom": "^18.3.0",
21
+ "@types/styled-components": "^5.1.34",
22
+ "@vitest/ui": "^1.6.0",
23
+ "eslint": "^8.56.0",
24
+ "jsdom": "^24.1.0",
25
+ "react": "^18.2.0",
26
+ "react-dom": "^18.2.0",
27
+ "styled-components": "^6.1.11",
28
+ "tsup": "^8.1.0",
29
+ "vitest": "^1.6.0",
30
+ "eslint-config-custom": "0.0.5",
31
+ "tsconfig": "0.0.1"
23
32
  },
24
33
  "peerDependencies": {
25
- "@equinor/eds-core-react": "^0.35.1",
34
+ "@equinor/eds-core-react": ">=0.42.1",
26
35
  "react": "^18.2.0",
27
36
  "react-dom": "^18.2.0",
28
37
  "styled-components": "^5.3.11",
29
38
  "tsup": "^8.0.1"
30
39
  },
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
40
  "publishConfig": {
46
41
  "access": "public"
42
+ },
43
+ "scripts": {
44
+ "build": "tsup src/index.ts --format esm,cjs --dts --external react",
45
+ "clean": "rm -rf .turbo && rm -rf node_modules && rm -rf dist",
46
+ "dev": "tsup src/index.ts --format esm,cjs --watch --dts --external react",
47
+ "lint": "TIMING=1 eslint . --fix",
48
+ "test": "vitest --run",
49
+ "test:watch": "vitest --watch",
50
+ "type-check": "tsc --noEmit"
47
51
  }
48
- }
52
+ }