cozy-client 42.0.1 → 42.2.0

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,18 @@
1
+ import { checkCountryCode } from './countries'
2
+
3
+ describe('checkCountryCode', () => {
4
+ it('should return true for valid country codes', () => {
5
+ expect(checkCountryCode('FR')).toBe(true)
6
+ expect(checkCountryCode('fr')).toBe(true)
7
+ expect(checkCountryCode('FRA')).toBe(true)
8
+ expect(checkCountryCode('fra')).toBe(true)
9
+ expect(checkCountryCode('US')).toBe(true)
10
+ expect(checkCountryCode('us')).toBe(true)
11
+ })
12
+
13
+ it('should return false for invalid country codes', () => {
14
+ expect(checkCountryCode(undefined)).toBe(false)
15
+ expect(checkCountryCode(null)).toBe(false)
16
+ expect(checkCountryCode('')).toBe(false)
17
+ })
18
+ })
package/dist/utils.js CHANGED
@@ -5,7 +5,7 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
5
5
  Object.defineProperty(exports, "__esModule", {
6
6
  value: true
7
7
  });
8
- exports.hasQueryBeenLoaded = exports.isQueryLoading = exports.cancelable = void 0;
8
+ exports.hasQueriesBeenLoaded = exports.isQueriesLoading = exports.hasQueryBeenLoaded = exports.isQueryLoading = exports.cancelable = void 0;
9
9
 
10
10
  var _logger = _interopRequireDefault(require("./logger"));
11
11
 
@@ -65,5 +65,29 @@ exports.isQueryLoading = isQueryLoading;
65
65
  var hasQueryBeenLoaded = function hasQueryBeenLoaded(col) {
66
66
  return col.lastFetch;
67
67
  };
68
+ /**
69
+ * Returns whether the result of queries are loading
70
+ */
71
+
72
+
73
+ exports.hasQueryBeenLoaded = hasQueryBeenLoaded;
74
+
75
+ var isQueriesLoading = function isQueriesLoading(queriesResults) {
76
+ return Object.values(queriesResults).some(function (queryResult) {
77
+ return isQueryLoading(queryResult);
78
+ });
79
+ };
80
+ /**
81
+ * Returns whether queries have been loaded at least once
82
+ */
83
+
84
+
85
+ exports.isQueriesLoading = isQueriesLoading;
86
+
87
+ var hasQueriesBeenLoaded = function hasQueriesBeenLoaded(queriesResults) {
88
+ return Object.values(queriesResults).some(function (queryResult) {
89
+ return hasQueryBeenLoaded(queryResult);
90
+ });
91
+ };
68
92
 
69
- exports.hasQueryBeenLoaded = hasQueryBeenLoaded;
93
+ exports.hasQueriesBeenLoaded = hasQueriesBeenLoaded;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cozy-client",
3
- "version": "42.0.1",
3
+ "version": "42.2.0",
4
4
  "license": "MIT",
5
5
  "main": "dist/index.node.js",
6
6
  "browser": "dist/index.js",
@@ -75,5 +75,5 @@
75
75
  "react-native-ios11-devicecheck": "https://github.com/cozy/react-native-devicecheck#app-attest-v0.1"
76
76
  },
77
77
  "sideEffects": false,
78
- "gitHead": "93a6b17de1e874a38de698e29a3b922c63842236"
78
+ "gitHead": "9c7fe8079758eb097916eaa2fe847d8730605021"
79
79
  }
@@ -2,7 +2,7 @@ export { default as useAppLinkWithStoreFallback } from "./useAppLinkWithStoreFal
2
2
  export { default as useCapabilities } from "./useCapabilities";
3
3
  export { default as useFetchShortcut } from "./useFetchShortcut";
4
4
  export { default as useClient } from "./useClient";
5
- export { default as useQuery } from "./useQuery";
6
5
  export { default as useAppsInMaintenance } from "./useAppsInMaintenance";
7
6
  export { default as useQueryAll } from "./useQueryAll";
8
7
  export { useMutation } from "./useMutation";
8
+ export { default as useQuery, useQueries } from "./useQuery";
package/types/index.d.ts CHANGED
@@ -20,5 +20,5 @@ export { QueryDefinition, Q, Mutations, MutationTypes, getDoctypeFromOperation }
20
20
  export { Association, HasMany, HasOne, HasOneInPlace, HasManyInPlace, HasManyTriggers } from "./associations";
21
21
  export { isReferencedBy, isReferencedById, getReferencedBy, getReferencedById } from "./associations/helpers";
22
22
  export { deconstructCozyWebLinkWithSlug, deconstructRedirectLink, dehydrate, generateWebLink, ensureFirstSlash, rootCozyUrl, InvalidRedirectLinkError, InvalidCozyUrlError, InvalidProtocolError, BlockedCozyError } from "./helpers";
23
- export { cancelable, isQueryLoading, hasQueryBeenLoaded } from "./utils";
23
+ export { cancelable, isQueryLoading, hasQueryBeenLoaded, isQueriesLoading, hasQueriesBeenLoaded } from "./utils";
24
24
  export { queryConnect, queryConnectFlat, withClient } from "./hoc";
@@ -0,0 +1,33 @@
1
+ /**
2
+ * @typedef {Object} CountryISO
3
+ * @property {string} code2 - ISO 3166-1 alpha-2
4
+ * @property {string} code3 - ISO 3166-1 alpha-3
5
+ * @property {string} name - Country name
6
+ * @property {string} number - ISO 3166-1 numeric
7
+ */
8
+ /**
9
+ * List of countries with their ISO codes
10
+ *
11
+ * @constant
12
+ * @type {CountryISO[]}
13
+ */
14
+ export const COUNTRIES_ISO: CountryISO[];
15
+ export function checkCountryCode(code: string): boolean;
16
+ export type CountryISO = {
17
+ /**
18
+ * - ISO 3166-1 alpha-2
19
+ */
20
+ code2: string;
21
+ /**
22
+ * - ISO 3166-1 alpha-3
23
+ */
24
+ code3: string;
25
+ /**
26
+ * - Country name
27
+ */
28
+ name: string;
29
+ /**
30
+ * - ISO 3166-1 numeric
31
+ */
32
+ number: string;
33
+ };
package/types/utils.d.ts CHANGED
@@ -1,5 +1,7 @@
1
1
  export function isQueryLoading(col: any): boolean;
2
2
  export function hasQueryBeenLoaded(col: any): any;
3
+ export function isQueriesLoading(queriesResults: any): boolean;
4
+ export function hasQueriesBeenLoaded(queriesResults: any): boolean;
3
5
  export type CancelablePromise = Promise<any>;
4
6
  /**
5
7
  * @typedef {Promise} CancelablePromise