cozy-client 38.9.1 → 38.10.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
CHANGED
|
@@ -2677,7 +2677,7 @@ var CozyClient = /*#__PURE__*/function () {
|
|
|
2677
2677
|
CozyClient.hooks = CozyClient.hooks || {};
|
|
2678
2678
|
CozyClient.fetchPolicies = _policies.default; //COZY_CLIENT_VERSION_PACKAGE in replaced by babel. See babel config
|
|
2679
2679
|
|
|
2680
|
-
CozyClient.version = "38.
|
|
2680
|
+
CozyClient.version = "38.10.0";
|
|
2681
2681
|
|
|
2682
2682
|
_microee.default.mixin(CozyClient);
|
|
2683
2683
|
|
package/dist/models/index.js
CHANGED
|
@@ -5,7 +5,7 @@ var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWild
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", {
|
|
6
6
|
value: true
|
|
7
7
|
});
|
|
8
|
-
exports.paper = exports.dacc = exports.sharing = exports.timeseries = exports.document = exports.contact = exports.utils = exports.permission = exports.note = exports.account = exports.folder = exports.file = exports.applications = exports.instance = exports.trigger = exports.accounts = exports.triggers = void 0;
|
|
8
|
+
exports.user = exports.paper = exports.dacc = exports.sharing = exports.timeseries = exports.document = exports.contact = exports.utils = exports.permission = exports.note = exports.account = exports.folder = exports.file = exports.applications = exports.instance = exports.trigger = exports.accounts = exports.triggers = void 0;
|
|
9
9
|
|
|
10
10
|
var trigger = _interopRequireWildcard(require("./trigger"));
|
|
11
11
|
|
|
@@ -66,6 +66,10 @@ exports.dacc = dacc;
|
|
|
66
66
|
var paper = _interopRequireWildcard(require("./paper"));
|
|
67
67
|
|
|
68
68
|
exports.paper = paper;
|
|
69
|
+
|
|
70
|
+
var user = _interopRequireWildcard(require("./user"));
|
|
71
|
+
|
|
72
|
+
exports.user = user;
|
|
69
73
|
// For backward compatibility before 9.0.0
|
|
70
74
|
var triggers = trigger;
|
|
71
75
|
exports.triggers = triggers;
|
package/dist/models/instance.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.hasPasswordDefinedAttribute = exports.buildPremiumLink = exports.hasAnOffer = exports.shouldDisplayOffers = exports.getUuid = exports.isFreemiumUser = exports.arePremiumLinksEnabled = exports.isSelfHosted = void 0;
|
|
8
|
+
exports.makeDiskInfos = exports.hasPasswordDefinedAttribute = exports.buildPremiumLink = exports.hasAnOffer = exports.shouldDisplayOffers = exports.getUuid = exports.isFreemiumUser = exports.arePremiumLinksEnabled = exports.isSelfHosted = void 0;
|
|
9
9
|
|
|
10
10
|
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
|
|
11
11
|
|
|
@@ -15,6 +15,7 @@ var _get = _interopRequireDefault(require("lodash/get"));
|
|
|
15
15
|
|
|
16
16
|
var _dsl = require("../queries/dsl");
|
|
17
17
|
|
|
18
|
+
var FallbackQuota = 1e11;
|
|
18
19
|
var GB = 1000 * 1000 * 1000;
|
|
19
20
|
var PREMIUM_QUOTA = 50 * GB;
|
|
20
21
|
/**
|
|
@@ -148,5 +149,83 @@ var hasPasswordDefinedAttribute = /*#__PURE__*/function () {
|
|
|
148
149
|
return _ref.apply(this, arguments);
|
|
149
150
|
};
|
|
150
151
|
}();
|
|
152
|
+
/**
|
|
153
|
+
* @typedef DiskInfosRaw
|
|
154
|
+
* @property diskQuota {number} - Space used in GB
|
|
155
|
+
* @property diskUsage {number} - Maximum space available in GB
|
|
156
|
+
* @property percentUsage {number} - Usage percent of the disk
|
|
157
|
+
*/
|
|
158
|
+
|
|
159
|
+
/**
|
|
160
|
+
* @typedef DiskInfos
|
|
161
|
+
* @property humanDiskQuota {string} - Space used in GB rounded
|
|
162
|
+
* @property humanDiskUsage {string} - Maximum space available in GB rounded
|
|
163
|
+
* @property percentUsage {string} - Usage percent of the disk rounded
|
|
164
|
+
*/
|
|
165
|
+
|
|
166
|
+
/**
|
|
167
|
+
* Convert input value into GB
|
|
168
|
+
*
|
|
169
|
+
* @param {number} bytes - Value in bytes
|
|
170
|
+
* @returns {number} - Returns the value in GB
|
|
171
|
+
*/
|
|
172
|
+
|
|
173
|
+
|
|
174
|
+
exports.hasPasswordDefinedAttribute = hasPasswordDefinedAttribute;
|
|
175
|
+
|
|
176
|
+
var convertBytesToGB = function convertBytesToGB(bytes) {
|
|
177
|
+
return bytes * 1e-9;
|
|
178
|
+
};
|
|
179
|
+
/**
|
|
180
|
+
* Computes `value` rounded to `fractionDigits`.
|
|
181
|
+
*
|
|
182
|
+
* @param {number} value - Value to format
|
|
183
|
+
* @param {number} fractionDigits - Number of decimal numbers
|
|
184
|
+
* @returns {string} - Returns the rounded number as a string
|
|
185
|
+
*/
|
|
186
|
+
|
|
187
|
+
|
|
188
|
+
var formatDecimals = function formatDecimals(value) {
|
|
189
|
+
var fractionDigits = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 2;
|
|
190
|
+
return "".concat(value % 1 ? value.toFixed(fractionDigits) : value);
|
|
191
|
+
};
|
|
192
|
+
/**
|
|
193
|
+
* Transform bytes data to GB data and compute percent usage
|
|
194
|
+
*
|
|
195
|
+
* @param {number} usage - Value in bytes representing the space used
|
|
196
|
+
* @param {number} quota - Value in bytes representing the maximum space available
|
|
197
|
+
* @returns {DiskInfosRaw} - Returns an transform data to GB and usage percent of the disk
|
|
198
|
+
*/
|
|
199
|
+
|
|
200
|
+
|
|
201
|
+
var computeDiskInfos = function computeDiskInfos(usage) {
|
|
202
|
+
var quota = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : FallbackQuota;
|
|
203
|
+
return {
|
|
204
|
+
diskQuota: convertBytesToGB(quota),
|
|
205
|
+
diskUsage: convertBytesToGB(usage),
|
|
206
|
+
percentUsage: usage / quota * 100
|
|
207
|
+
};
|
|
208
|
+
};
|
|
209
|
+
/**
|
|
210
|
+
* Make human readable information from disk information (usage, quota)
|
|
211
|
+
*
|
|
212
|
+
* @param {number|string} usage - Value in bytes representing the space used
|
|
213
|
+
* @param {number|string} [quota] - Value in bytes representing the maximum space available
|
|
214
|
+
* @returns {DiskInfos} - Return a set of human readable information about disk
|
|
215
|
+
*/
|
|
216
|
+
|
|
217
|
+
|
|
218
|
+
var makeDiskInfos = function makeDiskInfos(usage, quota) {
|
|
219
|
+
var _computeDiskInfos = computeDiskInfos(+usage, quota ? +quota : undefined),
|
|
220
|
+
diskQuota = _computeDiskInfos.diskQuota,
|
|
221
|
+
diskUsage = _computeDiskInfos.diskUsage,
|
|
222
|
+
percentUsage = _computeDiskInfos.percentUsage;
|
|
223
|
+
|
|
224
|
+
return {
|
|
225
|
+
humanDiskQuota: formatDecimals(diskQuota),
|
|
226
|
+
humanDiskUsage: formatDecimals(diskUsage),
|
|
227
|
+
percentUsage: Math.round(percentUsage).toString()
|
|
228
|
+
};
|
|
229
|
+
};
|
|
151
230
|
|
|
152
|
-
exports.
|
|
231
|
+
exports.makeDiskInfos = makeDiskInfos;
|
|
@@ -102,4 +102,49 @@ describe('instance', () => {
|
|
|
102
102
|
expect(instance.hasAnOffer(hadAnOfferInstance)).toBe(true)
|
|
103
103
|
expect(instance.hasAnOffer(selftHostedInstance)).toBe(false)
|
|
104
104
|
})
|
|
105
|
+
|
|
106
|
+
describe('makeDiskInfos', () => {
|
|
107
|
+
it('computes disk percent with a quota', () => {
|
|
108
|
+
expect(instance.makeDiskInfos('0', '5000000000')).toStrictEqual({
|
|
109
|
+
humanDiskQuota: '5',
|
|
110
|
+
humanDiskUsage: '0',
|
|
111
|
+
percentUsage: '0'
|
|
112
|
+
})
|
|
113
|
+
expect(instance.makeDiskInfos('115600793', '5000000000')).toStrictEqual({
|
|
114
|
+
humanDiskQuota: '5',
|
|
115
|
+
humanDiskUsage: '0.12',
|
|
116
|
+
percentUsage: '2'
|
|
117
|
+
})
|
|
118
|
+
expect(
|
|
119
|
+
instance.makeDiskInfos('22115600793', '90000000000')
|
|
120
|
+
).toStrictEqual({
|
|
121
|
+
humanDiskQuota: '90',
|
|
122
|
+
humanDiskUsage: '22.12',
|
|
123
|
+
percentUsage: '25'
|
|
124
|
+
})
|
|
125
|
+
expect(instance.makeDiskInfos('5000000000', '5000000000')).toStrictEqual({
|
|
126
|
+
humanDiskQuota: '5',
|
|
127
|
+
humanDiskUsage: '5',
|
|
128
|
+
percentUsage: '100'
|
|
129
|
+
})
|
|
130
|
+
})
|
|
131
|
+
|
|
132
|
+
it('computes disk percent without a quota', () => {
|
|
133
|
+
expect(instance.makeDiskInfos('1156007930', '')).toStrictEqual({
|
|
134
|
+
humanDiskQuota: '100',
|
|
135
|
+
humanDiskUsage: '1.16',
|
|
136
|
+
percentUsage: '1'
|
|
137
|
+
})
|
|
138
|
+
expect(instance.makeDiskInfos('0', undefined)).toStrictEqual({
|
|
139
|
+
humanDiskQuota: '100',
|
|
140
|
+
humanDiskUsage: '0',
|
|
141
|
+
percentUsage: '0'
|
|
142
|
+
})
|
|
143
|
+
expect(instance.makeDiskInfos('0', 0)).toStrictEqual({
|
|
144
|
+
humanDiskQuota: '100',
|
|
145
|
+
humanDiskUsage: '0',
|
|
146
|
+
percentUsage: '0'
|
|
147
|
+
})
|
|
148
|
+
})
|
|
149
|
+
})
|
|
105
150
|
})
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cozy-client",
|
|
3
|
-
"version": "38.
|
|
3
|
+
"version": "38.10.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"main": "dist/index.node.js",
|
|
6
6
|
"browser": "dist/index.js",
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
"@types/jest": "^26.0.20",
|
|
19
19
|
"@types/lodash": "^4.14.170",
|
|
20
20
|
"btoa": "^1.2.1",
|
|
21
|
-
"cozy-stack-client": "^38.
|
|
21
|
+
"cozy-stack-client": "^38.9.2",
|
|
22
22
|
"date-fns": "2.29.3",
|
|
23
23
|
"json-stable-stringify": "^1.0.1",
|
|
24
24
|
"lodash": "^4.17.13",
|
|
@@ -73,5 +73,5 @@
|
|
|
73
73
|
"react-native-ios11-devicecheck": "https://github.com/cozy/react-native-devicecheck#app-attest-v0.1"
|
|
74
74
|
},
|
|
75
75
|
"sideEffects": false,
|
|
76
|
-
"gitHead": "
|
|
76
|
+
"gitHead": "a2a811593b4181f559583c994a91d95cf3f7e289"
|
|
77
77
|
}
|
package/types/models/index.d.ts
CHANGED
|
@@ -15,4 +15,5 @@ import * as timeseries from "./timeseries";
|
|
|
15
15
|
import * as sharing from "./sharing";
|
|
16
16
|
import * as dacc from "./dacc";
|
|
17
17
|
import * as paper from "./paper";
|
|
18
|
-
|
|
18
|
+
import * as user from "./user";
|
|
19
|
+
export { trigger, instance, applications, file, folder, note, account, permission, utils, contact, document, timeseries, sharing, dacc, paper, user };
|
|
@@ -6,6 +6,7 @@ export function shouldDisplayOffers(data: SettingsInfo): boolean;
|
|
|
6
6
|
export function hasAnOffer(data: SettingsInfo): boolean;
|
|
7
7
|
export function buildPremiumLink(instanceInfo: InstanceInfo): string;
|
|
8
8
|
export function hasPasswordDefinedAttribute(client: import("../CozyClient").default): Promise<boolean>;
|
|
9
|
+
export function makeDiskInfos(usage: number | string, quota?: number | string): DiskInfos;
|
|
9
10
|
export type InstanceInfo = any;
|
|
10
11
|
export type ContextInfo = any;
|
|
11
12
|
export type DiskUsageInfo = any;
|
|
@@ -23,3 +24,31 @@ export type SettingsInfo = {
|
|
|
23
24
|
*/
|
|
24
25
|
diskUsage: DiskUsageInfo;
|
|
25
26
|
};
|
|
27
|
+
export type DiskInfosRaw = {
|
|
28
|
+
/**
|
|
29
|
+
* - Space used in GB
|
|
30
|
+
*/
|
|
31
|
+
diskQuota: number;
|
|
32
|
+
/**
|
|
33
|
+
* - Maximum space available in GB
|
|
34
|
+
*/
|
|
35
|
+
diskUsage: number;
|
|
36
|
+
/**
|
|
37
|
+
* - Usage percent of the disk
|
|
38
|
+
*/
|
|
39
|
+
percentUsage: number;
|
|
40
|
+
};
|
|
41
|
+
export type DiskInfos = {
|
|
42
|
+
/**
|
|
43
|
+
* - Space used in GB rounded
|
|
44
|
+
*/
|
|
45
|
+
humanDiskQuota: string;
|
|
46
|
+
/**
|
|
47
|
+
* - Maximum space available in GB rounded
|
|
48
|
+
*/
|
|
49
|
+
humanDiskUsage: string;
|
|
50
|
+
/**
|
|
51
|
+
* - Usage percent of the disk rounded
|
|
52
|
+
*/
|
|
53
|
+
percentUsage: string;
|
|
54
|
+
};
|