cozy-client 43.2.0 → 43.3.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.
- package/dist/CozyClient.js +1 -1
- package/dist/hooks/index.js +9 -1
- package/dist/hooks/useInstanceInfo.js +56 -0
- package/dist/types.js +71 -0
- package/package.json +2 -2
- package/types/hooks/index.d.ts +1 -0
- package/types/hooks/useInstanceInfo.d.ts +1 -0
- package/types/types.d.ts +151 -0
package/dist/CozyClient.js
CHANGED
|
@@ -2703,7 +2703,7 @@ var CozyClient = /*#__PURE__*/function () {
|
|
|
2703
2703
|
CozyClient.hooks = CozyClient.hooks || {};
|
|
2704
2704
|
CozyClient.fetchPolicies = _policies.default; //COZY_CLIENT_VERSION_PACKAGE in replaced by babel. See babel config
|
|
2705
2705
|
|
|
2706
|
-
CozyClient.version = "43.
|
|
2706
|
+
CozyClient.version = "43.3.0";
|
|
2707
2707
|
|
|
2708
2708
|
_microee.default.mixin(CozyClient);
|
|
2709
2709
|
|
package/dist/hooks/index.js
CHANGED
|
@@ -61,6 +61,12 @@ Object.defineProperty(exports, "useMutation", {
|
|
|
61
61
|
return _useMutation.useMutation;
|
|
62
62
|
}
|
|
63
63
|
});
|
|
64
|
+
Object.defineProperty(exports, "useInstanceInfo", {
|
|
65
|
+
enumerable: true,
|
|
66
|
+
get: function get() {
|
|
67
|
+
return _useInstanceInfo.useInstanceInfo;
|
|
68
|
+
}
|
|
69
|
+
});
|
|
64
70
|
|
|
65
71
|
var _useAppLinkWithStoreFallback = _interopRequireDefault(require("./useAppLinkWithStoreFallback"));
|
|
66
72
|
|
|
@@ -76,4 +82,6 @@ var _useAppsInMaintenance = _interopRequireDefault(require("./useAppsInMaintenan
|
|
|
76
82
|
|
|
77
83
|
var _useQueryAll = _interopRequireDefault(require("./useQueryAll"));
|
|
78
84
|
|
|
79
|
-
var _useMutation = require("./useMutation");
|
|
85
|
+
var _useMutation = require("./useMutation");
|
|
86
|
+
|
|
87
|
+
var _useInstanceInfo = require("./useInstanceInfo");
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.useInstanceInfo = void 0;
|
|
9
|
+
|
|
10
|
+
var _useQuery = _interopRequireDefault(require("./useQuery"));
|
|
11
|
+
|
|
12
|
+
var _CozyClient = _interopRequireDefault(require("../CozyClient"));
|
|
13
|
+
|
|
14
|
+
var _dsl = require("../queries/dsl");
|
|
15
|
+
|
|
16
|
+
var _utils = require("../utils");
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Retrieve intance info like context, uuid, disk usage etc
|
|
20
|
+
*
|
|
21
|
+
* @returns {import("../types").InstanceInfo}
|
|
22
|
+
*/
|
|
23
|
+
var useInstanceInfo = function useInstanceInfo() {
|
|
24
|
+
var instanceQuery = buildSettingsByIdQuery('io.cozy.settings.instance');
|
|
25
|
+
var instanceResult = (0, _useQuery.default)(instanceQuery.definition, instanceQuery.options);
|
|
26
|
+
var contextQuery = buildSettingsByIdQuery('context');
|
|
27
|
+
var contextResult = (0, _useQuery.default)(contextQuery.definition, contextQuery.options);
|
|
28
|
+
var diskUsageQuery = buildSettingsByIdQuery('disk-usage');
|
|
29
|
+
var diskUsageResult = (0, _useQuery.default)(diskUsageQuery.definition, diskUsageQuery.options);
|
|
30
|
+
return {
|
|
31
|
+
isLoaded: !!(0, _utils.hasQueryBeenLoaded)(instanceResult) !== null && !!(0, _utils.hasQueryBeenLoaded)(contextResult) !== null && !!(0, _utils.hasQueryBeenLoaded)(diskUsageResult) !== null,
|
|
32
|
+
instance: {
|
|
33
|
+
data: instanceResult.data
|
|
34
|
+
},
|
|
35
|
+
context: {
|
|
36
|
+
data: contextResult.data
|
|
37
|
+
},
|
|
38
|
+
diskUsage: {
|
|
39
|
+
data: diskUsageResult.data
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
exports.useInstanceInfo = useInstanceInfo;
|
|
45
|
+
var DEFAULT_CACHE_TIMEOUT_QUERIES = 9 * 60 * 1000;
|
|
46
|
+
|
|
47
|
+
var buildSettingsByIdQuery = function buildSettingsByIdQuery(id) {
|
|
48
|
+
return {
|
|
49
|
+
definition: (0, _dsl.Q)('io.cozy.settings').getById(id),
|
|
50
|
+
options: {
|
|
51
|
+
as: "io.cozy.settings/".concat(id),
|
|
52
|
+
fetchPolicy: _CozyClient.default.fetchPolicies.olderThan(DEFAULT_CACHE_TIMEOUT_QUERIES),
|
|
53
|
+
singleDocData: true
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
};
|
package/dist/types.js
CHANGED
|
@@ -566,5 +566,76 @@ var _dsl = require("./queries/dsl");
|
|
|
566
566
|
* @template T
|
|
567
567
|
* @typedef {[T, import('react').Dispatch<import('react').SetStateAction<T>>]} useState
|
|
568
568
|
*/
|
|
569
|
+
|
|
570
|
+
/**
|
|
571
|
+
* Represents the Cozy's instance parameters
|
|
572
|
+
*
|
|
573
|
+
* @typedef {object} InstanceData
|
|
574
|
+
* @property {string} email - The email of the instance
|
|
575
|
+
* @property {string} locale - The locale used on the server
|
|
576
|
+
* @property {string} [public_name] - The public displayed name of the instance
|
|
577
|
+
* @property {string} [uuid] - UUID associated with the instance
|
|
578
|
+
* @property {string} [context] - The name of the context attached to the instance
|
|
579
|
+
* @property {string} [default_redirection] - Redirect to a specific route after the login (format: 'appslug/#/path/to/route'). This value has priority over the Context's default_redirection
|
|
580
|
+
* @property {boolean} [onboarding_finished] - Whether or not the onboarding is complete
|
|
581
|
+
* @property {boolean} [password_defined] - Whether or not the Cozy has a password defined (i.e. may be false for OIDC instances)
|
|
582
|
+
* @property {'basic' | 'two_factor_mail'} [auth_mode] - Authentication type (basic or 2FA)
|
|
583
|
+
* @property {string} [oidc_id] - An identifier to check authentication from OIDC
|
|
584
|
+
* @property {string} [tos] - Terms of Service signed version
|
|
585
|
+
* @property {string} [tos_latest] - Terms of Service latest version
|
|
586
|
+
*/
|
|
587
|
+
|
|
588
|
+
/**
|
|
589
|
+
* Represents the Cozy's instance parameters
|
|
590
|
+
*
|
|
591
|
+
* @typedef {object} Instance
|
|
592
|
+
* @property {InstanceData} data - data from Instance Query
|
|
593
|
+
*/
|
|
594
|
+
|
|
595
|
+
/**
|
|
596
|
+
* Represents the Cozy's context parameters
|
|
597
|
+
*
|
|
598
|
+
* @typedef {object} ContextData
|
|
599
|
+
* @property {string} [default_redirection] - Redirect to a specific route after the login (format: 'appslug/#/path/to/route')
|
|
600
|
+
* @property {string} [onboarded_redirection] - Redirect to a specific route after the onboarding (format: appslug/#/path/to/route')
|
|
601
|
+
* @property {string} [help_link] - Link that the user can use to get help (i.e. 'https://forum.cozy.io/')
|
|
602
|
+
* @property {string} [manager_url] - Url of the instance's Manager that can be use to enable/disable premium features
|
|
603
|
+
* @property {boolean} [enable_premium_links] - Whether or not the Cozy can show links to the Manager in order to enable/disable premium features
|
|
604
|
+
*/
|
|
605
|
+
|
|
606
|
+
/**
|
|
607
|
+
* Represents the Cozy's context parameters
|
|
608
|
+
*
|
|
609
|
+
* @typedef {object} Context
|
|
610
|
+
* @property {ContextData} data - data from Context Query
|
|
611
|
+
*/
|
|
612
|
+
|
|
613
|
+
/**
|
|
614
|
+
* Represents the Cozy's disk usage
|
|
615
|
+
*
|
|
616
|
+
* @typedef {object} DiskUsageData
|
|
617
|
+
* @property {string} [quota] - Value in bytes representing the maximum space available. Omitted means unlimited
|
|
618
|
+
* @property {string} used - Value in bytes representing the space used
|
|
619
|
+
* @property {string} files - Value in bytes representing the space used by files in their last version
|
|
620
|
+
* @property {string} versions - Value in bytes representing the space used by files in their older version
|
|
621
|
+
* @property {string} [trash] - Value in bytes representing the space used by files in the trash
|
|
622
|
+
*/
|
|
623
|
+
|
|
624
|
+
/**
|
|
625
|
+
* Represents the Cozy's disk usage
|
|
626
|
+
*
|
|
627
|
+
* @typedef {object} DiskUsage
|
|
628
|
+
* @property {DiskUsageData} data - data from DiskUsage Query
|
|
629
|
+
*/
|
|
630
|
+
|
|
631
|
+
/**
|
|
632
|
+
* Represents the Cozy's instance info (instance level parameters, context level parameters and disk usage)
|
|
633
|
+
*
|
|
634
|
+
* @typedef {object} InstanceInfo
|
|
635
|
+
* @property {boolean} isLoaded - Whether or not the queries have been loaded
|
|
636
|
+
* @property {Instance} instance - The Cozy's instance parameters
|
|
637
|
+
* @property {Context} context - The Cozy's context parameters
|
|
638
|
+
* @property {DiskUsage} diskUsage - The Cozy's disk usage
|
|
639
|
+
*/
|
|
569
640
|
var _default = {};
|
|
570
641
|
exports.default = _default;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cozy-client",
|
|
3
|
-
"version": "43.
|
|
3
|
+
"version": "43.3.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": "
|
|
78
|
+
"gitHead": "eeefc22374dbb95969c385ca383b7d6ee8a1a58f"
|
|
79
79
|
}
|
package/types/hooks/index.d.ts
CHANGED
|
@@ -5,4 +5,5 @@ export { default as useClient } from "./useClient";
|
|
|
5
5
|
export { default as useAppsInMaintenance } from "./useAppsInMaintenance";
|
|
6
6
|
export { default as useQueryAll } from "./useQueryAll";
|
|
7
7
|
export { useMutation } from "./useMutation";
|
|
8
|
+
export { useInstanceInfo } from "./useInstanceInfo";
|
|
8
9
|
export { default as useQuery, useQueries } from "./useQuery";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export function useInstanceInfo(): import("../types").InstanceInfo;
|
package/types/types.d.ts
CHANGED
|
@@ -920,4 +920,155 @@ export type RedirectLinkData = {
|
|
|
920
920
|
* Template to type useState
|
|
921
921
|
*/
|
|
922
922
|
export type useState<T> = [T, import("react").Dispatch<import("react").SetStateAction<T>>];
|
|
923
|
+
/**
|
|
924
|
+
* Represents the Cozy's instance parameters
|
|
925
|
+
*/
|
|
926
|
+
export type InstanceData = {
|
|
927
|
+
/**
|
|
928
|
+
* - The email of the instance
|
|
929
|
+
*/
|
|
930
|
+
email: string;
|
|
931
|
+
/**
|
|
932
|
+
* - The locale used on the server
|
|
933
|
+
*/
|
|
934
|
+
locale: string;
|
|
935
|
+
/**
|
|
936
|
+
* - The public displayed name of the instance
|
|
937
|
+
*/
|
|
938
|
+
public_name?: string;
|
|
939
|
+
/**
|
|
940
|
+
* - UUID associated with the instance
|
|
941
|
+
*/
|
|
942
|
+
uuid?: string;
|
|
943
|
+
/**
|
|
944
|
+
* - The name of the context attached to the instance
|
|
945
|
+
*/
|
|
946
|
+
context?: string;
|
|
947
|
+
/**
|
|
948
|
+
* - Redirect to a specific route after the login (format: 'appslug/#/path/to/route'). This value has priority over the Context's default_redirection
|
|
949
|
+
*/
|
|
950
|
+
default_redirection?: string;
|
|
951
|
+
/**
|
|
952
|
+
* - Whether or not the onboarding is complete
|
|
953
|
+
*/
|
|
954
|
+
onboarding_finished?: boolean;
|
|
955
|
+
/**
|
|
956
|
+
* - Whether or not the Cozy has a password defined (i.e. may be false for OIDC instances)
|
|
957
|
+
*/
|
|
958
|
+
password_defined?: boolean;
|
|
959
|
+
/**
|
|
960
|
+
* - Authentication type (basic or 2FA)
|
|
961
|
+
*/
|
|
962
|
+
auth_mode?: 'basic' | 'two_factor_mail';
|
|
963
|
+
/**
|
|
964
|
+
* - An identifier to check authentication from OIDC
|
|
965
|
+
*/
|
|
966
|
+
oidc_id?: string;
|
|
967
|
+
/**
|
|
968
|
+
* - Terms of Service signed version
|
|
969
|
+
*/
|
|
970
|
+
tos?: string;
|
|
971
|
+
/**
|
|
972
|
+
* - Terms of Service latest version
|
|
973
|
+
*/
|
|
974
|
+
tos_latest?: string;
|
|
975
|
+
};
|
|
976
|
+
/**
|
|
977
|
+
* Represents the Cozy's instance parameters
|
|
978
|
+
*/
|
|
979
|
+
export type Instance = {
|
|
980
|
+
/**
|
|
981
|
+
* - data from Instance Query
|
|
982
|
+
*/
|
|
983
|
+
data: InstanceData;
|
|
984
|
+
};
|
|
985
|
+
/**
|
|
986
|
+
* Represents the Cozy's context parameters
|
|
987
|
+
*/
|
|
988
|
+
export type ContextData = {
|
|
989
|
+
/**
|
|
990
|
+
* - Redirect to a specific route after the login (format: 'appslug/#/path/to/route')
|
|
991
|
+
*/
|
|
992
|
+
default_redirection?: string;
|
|
993
|
+
/**
|
|
994
|
+
* - Redirect to a specific route after the onboarding (format: appslug/#/path/to/route')
|
|
995
|
+
*/
|
|
996
|
+
onboarded_redirection?: string;
|
|
997
|
+
/**
|
|
998
|
+
* - Link that the user can use to get help (i.e. 'https://forum.cozy.io/')
|
|
999
|
+
*/
|
|
1000
|
+
help_link?: string;
|
|
1001
|
+
/**
|
|
1002
|
+
* - Url of the instance's Manager that can be use to enable/disable premium features
|
|
1003
|
+
*/
|
|
1004
|
+
manager_url?: string;
|
|
1005
|
+
/**
|
|
1006
|
+
* - Whether or not the Cozy can show links to the Manager in order to enable/disable premium features
|
|
1007
|
+
*/
|
|
1008
|
+
enable_premium_links?: boolean;
|
|
1009
|
+
};
|
|
1010
|
+
/**
|
|
1011
|
+
* Represents the Cozy's context parameters
|
|
1012
|
+
*/
|
|
1013
|
+
export type Context = {
|
|
1014
|
+
/**
|
|
1015
|
+
* - data from Context Query
|
|
1016
|
+
*/
|
|
1017
|
+
data: ContextData;
|
|
1018
|
+
};
|
|
1019
|
+
/**
|
|
1020
|
+
* Represents the Cozy's disk usage
|
|
1021
|
+
*/
|
|
1022
|
+
export type DiskUsageData = {
|
|
1023
|
+
/**
|
|
1024
|
+
* - Value in bytes representing the maximum space available. Omitted means unlimited
|
|
1025
|
+
*/
|
|
1026
|
+
quota?: string;
|
|
1027
|
+
/**
|
|
1028
|
+
* - Value in bytes representing the space used
|
|
1029
|
+
*/
|
|
1030
|
+
used: string;
|
|
1031
|
+
/**
|
|
1032
|
+
* - Value in bytes representing the space used by files in their last version
|
|
1033
|
+
*/
|
|
1034
|
+
files: string;
|
|
1035
|
+
/**
|
|
1036
|
+
* - Value in bytes representing the space used by files in their older version
|
|
1037
|
+
*/
|
|
1038
|
+
versions: string;
|
|
1039
|
+
/**
|
|
1040
|
+
* - Value in bytes representing the space used by files in the trash
|
|
1041
|
+
*/
|
|
1042
|
+
trash?: string;
|
|
1043
|
+
};
|
|
1044
|
+
/**
|
|
1045
|
+
* Represents the Cozy's disk usage
|
|
1046
|
+
*/
|
|
1047
|
+
export type DiskUsage = {
|
|
1048
|
+
/**
|
|
1049
|
+
* - data from DiskUsage Query
|
|
1050
|
+
*/
|
|
1051
|
+
data: DiskUsageData;
|
|
1052
|
+
};
|
|
1053
|
+
/**
|
|
1054
|
+
* Represents the Cozy's instance info (instance level parameters, context level parameters and disk usage)
|
|
1055
|
+
*/
|
|
1056
|
+
export type InstanceInfo = {
|
|
1057
|
+
/**
|
|
1058
|
+
* - Whether or not the queries have been loaded
|
|
1059
|
+
*/
|
|
1060
|
+
isLoaded: boolean;
|
|
1061
|
+
/**
|
|
1062
|
+
* - The Cozy's instance parameters
|
|
1063
|
+
*/
|
|
1064
|
+
instance: Instance;
|
|
1065
|
+
/**
|
|
1066
|
+
* - The Cozy's context parameters
|
|
1067
|
+
*/
|
|
1068
|
+
context: Context;
|
|
1069
|
+
/**
|
|
1070
|
+
* - The Cozy's disk usage
|
|
1071
|
+
*/
|
|
1072
|
+
diskUsage: DiskUsage;
|
|
1073
|
+
};
|
|
923
1074
|
import { QueryDefinition } from "./queries/dsl";
|