cozy-client 60.9.0 → 60.12.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 +8 -0
- package/dist/hooks/useFetchHomeShortcuts.js +60 -0
- package/dist/models/file.js +25 -2
- package/dist/models/instance.js +2 -1
- package/dist/models/instance.spec.js +5 -2
- package/dist/types.js +2 -0
- package/package.json +2 -2
- package/types/hooks/index.d.ts +1 -0
- package/types/hooks/useFetchHomeShortcuts.d.ts +2 -0
- package/types/models/file.d.ts +1 -0
- package/types/types.d.ts +8 -0
package/dist/CozyClient.js
CHANGED
|
@@ -3126,7 +3126,7 @@ var CozyClient = /*#__PURE__*/function () {
|
|
|
3126
3126
|
CozyClient.hooks = CozyClient.hooks || {};
|
|
3127
3127
|
CozyClient.fetchPolicies = _policies.default; //COZY_CLIENT_VERSION_PACKAGE in replaced by babel. See babel config
|
|
3128
3128
|
|
|
3129
|
-
CozyClient.version = "60.
|
|
3129
|
+
CozyClient.version = "60.12.0";
|
|
3130
3130
|
|
|
3131
3131
|
_microee.default.mixin(CozyClient);
|
|
3132
3132
|
|
package/dist/hooks/index.js
CHANGED
|
@@ -25,6 +25,12 @@ Object.defineProperty(exports, "useFetchShortcut", {
|
|
|
25
25
|
return _useFetchShortcut.default;
|
|
26
26
|
}
|
|
27
27
|
});
|
|
28
|
+
Object.defineProperty(exports, "useFetchHomeShortcuts", {
|
|
29
|
+
enumerable: true,
|
|
30
|
+
get: function get() {
|
|
31
|
+
return _useFetchHomeShortcuts.default;
|
|
32
|
+
}
|
|
33
|
+
});
|
|
28
34
|
Object.defineProperty(exports, "useClient", {
|
|
29
35
|
enumerable: true,
|
|
30
36
|
get: function get() {
|
|
@@ -80,6 +86,8 @@ var _useCapabilities = _interopRequireDefault(require("./useCapabilities"));
|
|
|
80
86
|
|
|
81
87
|
var _useFetchShortcut = _interopRequireDefault(require("./useFetchShortcut"));
|
|
82
88
|
|
|
89
|
+
var _useFetchHomeShortcuts = _interopRequireDefault(require("./useFetchHomeShortcuts"));
|
|
90
|
+
|
|
83
91
|
var _useClient = _interopRequireDefault(require("./useClient"));
|
|
84
92
|
|
|
85
93
|
var _useQuery = _interopRequireWildcard(require("./useQuery"));
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard");
|
|
4
|
+
|
|
5
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
6
|
+
|
|
7
|
+
Object.defineProperty(exports, "__esModule", {
|
|
8
|
+
value: true
|
|
9
|
+
});
|
|
10
|
+
exports.default = void 0;
|
|
11
|
+
|
|
12
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
13
|
+
|
|
14
|
+
var _cozyClient = _interopRequireWildcard(require("cozy-client"));
|
|
15
|
+
|
|
16
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
|
|
17
|
+
|
|
18
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
19
|
+
|
|
20
|
+
var fetchPolicy = _cozyClient.default.fetchPolicies.olderThan(30 * 1000);
|
|
21
|
+
|
|
22
|
+
var buildHomeMagicFolderQuery = function buildHomeMagicFolderQuery() {
|
|
23
|
+
return {
|
|
24
|
+
query: (0, _cozyClient.Q)('io.cozy.files').where({
|
|
25
|
+
path: '/Settings/Home'
|
|
26
|
+
}).indexFields(['path']),
|
|
27
|
+
as: 'io.cozy.files/path/Settings/Home',
|
|
28
|
+
fetchPolicy: fetchPolicy
|
|
29
|
+
};
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
var buildHomeShortcutsQuery = function buildHomeShortcutsQuery(folderId) {
|
|
33
|
+
return {
|
|
34
|
+
query: (0, _cozyClient.Q)('io.cozy.files').where({
|
|
35
|
+
dir_id: folderId,
|
|
36
|
+
class: 'shortcut'
|
|
37
|
+
}).indexFields(['dir_id', 'class']),
|
|
38
|
+
as: "io.cozy.files/dir_id/".concat(folderId, "/class/shortcut"),
|
|
39
|
+
fetchPolicy: fetchPolicy
|
|
40
|
+
};
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
var useFetchHomeShortcuts = function useFetchHomeShortcuts() {
|
|
44
|
+
var _magicHomeFolder$data, _magicHomeFolder$data2;
|
|
45
|
+
|
|
46
|
+
var homeMagicFolderQuery = buildHomeMagicFolderQuery();
|
|
47
|
+
var magicHomeFolder = (0, _cozyClient.useQuery)(homeMagicFolderQuery.query, homeMagicFolderQuery);
|
|
48
|
+
var magicHomeFolderId = magicHomeFolder === null || magicHomeFolder === void 0 ? void 0 : (_magicHomeFolder$data = magicHomeFolder.data) === null || _magicHomeFolder$data === void 0 ? void 0 : (_magicHomeFolder$data2 = _magicHomeFolder$data[0]) === null || _magicHomeFolder$data2 === void 0 ? void 0 : _magicHomeFolder$data2._id;
|
|
49
|
+
var homeShortcutsQuery = buildHomeShortcutsQuery(magicHomeFolderId);
|
|
50
|
+
|
|
51
|
+
var _useQuery = (0, _cozyClient.useQuery)(homeShortcutsQuery.query, _objectSpread(_objectSpread({}, homeShortcutsQuery), {}, {
|
|
52
|
+
enabled: !!magicHomeFolderId
|
|
53
|
+
})),
|
|
54
|
+
shortcuts = _useQuery.data;
|
|
55
|
+
|
|
56
|
+
return shortcuts;
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
var _default = useFetchHomeShortcuts;
|
|
60
|
+
exports.default = _default;
|
package/dist/models/file.js
CHANGED
|
@@ -8,7 +8,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
8
8
|
exports.normalize = normalize;
|
|
9
9
|
exports.ensureFilePath = ensureFilePath;
|
|
10
10
|
exports.getParentFolderId = getParentFolderId;
|
|
11
|
-
exports.downloadFile = exports.copy = exports.fetchBlobFileById = exports.isFromKonnector = exports.hasCertifications = exports.hasQualifications = exports.isPlainText = exports.uploadFileWithConflictStrategy = exports.generateFileNameForRevision = exports.generateNewFileNameOnConflict = exports.overrideFileForPath = exports.move = exports.getFullpath = exports.hasMetadataAttribute = exports.fetchFilesByQualificationRules = exports.saveFileQualification = exports.isSharingShorcutNew = exports.isSharingShortcutNew = exports.isSharingShorcut = exports.isSharingShortcut = exports.getSharingShortcutTargetDoctype = exports.getSharingShortcutTargetMime = exports.getSharingShortcutStatus = exports.isShortcut = exports.shouldBeOpenedByOnlyOffice = exports.isOnlyOfficeFile = exports.isEncryptedFileOrFolder = exports.isEncryptedFolder = exports.getEncryptiondRef = exports.isEncrypted = exports.isDocs = exports.isNote = exports.isDirectory = exports.isFile = exports.splitFilename = exports.ALBUMS_DOCTYPE = void 0;
|
|
11
|
+
exports.downloadFile = exports.copy = exports.fetchBlobFileById = exports.isFromKonnector = exports.hasCertifications = exports.hasQualifications = exports.isPlainText = exports.uploadFileWithConflictStrategy = exports.generateFileNameForRevision = exports.generateNewFileNameOnConflict = exports.overrideFileForPath = exports.move = exports.getFullpath = exports.hasMetadataAttribute = exports.fetchFilesByQualificationRules = exports.saveFileQualification = exports.isSharingShorcutNew = exports.isSharingShortcutNew = exports.isSharingShorcut = exports.isSharingShortcut = exports.getSharingShortcutTargetDoctype = exports.getSharingShortcutTargetMime = exports.getSharingShortcutStatus = exports.getShortcutImgSrc = exports.isShortcut = exports.shouldBeOpenedByOnlyOffice = exports.isOnlyOfficeFile = exports.isEncryptedFileOrFolder = exports.isEncryptedFolder = exports.getEncryptiondRef = exports.isEncrypted = exports.isDocs = exports.isNote = exports.isDirectory = exports.isFile = exports.splitFilename = exports.ALBUMS_DOCTYPE = void 0;
|
|
12
12
|
|
|
13
13
|
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
|
|
14
14
|
|
|
@@ -217,6 +217,29 @@ exports.shouldBeOpenedByOnlyOffice = shouldBeOpenedByOnlyOffice;
|
|
|
217
217
|
var isShortcut = function isShortcut(file) {
|
|
218
218
|
return file && file.class === 'shortcut';
|
|
219
219
|
};
|
|
220
|
+
/**
|
|
221
|
+
*
|
|
222
|
+
* @param {import("../types").IOCozyFile} file - io.cozy.files document
|
|
223
|
+
* @returns {string | undefined} image src that can be used in an <img> tag
|
|
224
|
+
*/
|
|
225
|
+
|
|
226
|
+
|
|
227
|
+
exports.isShortcut = isShortcut;
|
|
228
|
+
|
|
229
|
+
var getShortcutImgSrc = function getShortcutImgSrc(file) {
|
|
230
|
+
/**
|
|
231
|
+
* If we don't have iconMimeType, we consider that the icon is a binary svg.
|
|
232
|
+
* Otherwise we consider that the icon comes from Iconizer api so it is in base64 directly.
|
|
233
|
+
*/
|
|
234
|
+
var icon = file.metadata.icon;
|
|
235
|
+
var iconMimeType = file.metadata.iconMimeType;
|
|
236
|
+
|
|
237
|
+
if (!icon) {
|
|
238
|
+
return undefined;
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
return iconMimeType ? "data:".concat(iconMimeType, ";base64,").concat(icon) : "data:image/svg+xml;base64,".concat(window.btoa(icon));
|
|
242
|
+
};
|
|
220
243
|
/**
|
|
221
244
|
* Normalizes an object representing a io.cozy.files object
|
|
222
245
|
*
|
|
@@ -228,7 +251,7 @@ var isShortcut = function isShortcut(file) {
|
|
|
228
251
|
*/
|
|
229
252
|
|
|
230
253
|
|
|
231
|
-
exports.
|
|
254
|
+
exports.getShortcutImgSrc = getShortcutImgSrc;
|
|
232
255
|
|
|
233
256
|
function normalize(file) {
|
|
234
257
|
var id = file._id || file.id;
|
package/dist/models/instance.js
CHANGED
|
@@ -91,10 +91,11 @@ exports.hasAnOffer = hasAnOffer;
|
|
|
91
91
|
|
|
92
92
|
var buildPremiumLink = function buildPremiumLink(instanceInfo) {
|
|
93
93
|
var managerUrl = (0, _get.default)(instanceInfo, 'context.data.manager_url', false);
|
|
94
|
+
var locale = (0, _get.default)(instanceInfo, 'instance.data.locale', 'en');
|
|
94
95
|
var uuid = getUuid(instanceInfo);
|
|
95
96
|
|
|
96
97
|
if (managerUrl && uuid) {
|
|
97
|
-
return "".concat(managerUrl, "/cozy/instances/").concat(uuid, "/premium");
|
|
98
|
+
return "".concat(managerUrl, "/cozy/instances/").concat(uuid, "/premium?lang=").concat(locale);
|
|
98
99
|
} else {
|
|
99
100
|
return null;
|
|
100
101
|
}
|
|
@@ -9,7 +9,8 @@ const noSelfHostedInstance = {
|
|
|
9
9
|
},
|
|
10
10
|
instance: {
|
|
11
11
|
data: {
|
|
12
|
-
uuid: '1234'
|
|
12
|
+
uuid: '1234',
|
|
13
|
+
locale: 'fr'
|
|
13
14
|
}
|
|
14
15
|
},
|
|
15
16
|
diskUsage: {
|
|
@@ -78,7 +79,9 @@ describe('instance', () => {
|
|
|
78
79
|
|
|
79
80
|
it('should generate the link to the manager', () => {
|
|
80
81
|
const url = instance.buildPremiumLink(noSelfHostedInstance)
|
|
81
|
-
expect(url).toBe(
|
|
82
|
+
expect(url).toBe(
|
|
83
|
+
'https://manager.cozy.cc/cozy/instances/1234/premium?lang=fr'
|
|
84
|
+
)
|
|
82
85
|
})
|
|
83
86
|
|
|
84
87
|
it('should test if an instance has already subscribed to one of our offers', () => {
|
package/dist/types.js
CHANGED
|
@@ -492,6 +492,8 @@ var _dsl = require("./queries/dsl");
|
|
|
492
492
|
* @property {object} [target] - Information of the target of the shortcut
|
|
493
493
|
* @property {string} [target.title] - The title of the application to which the shortcut redirects
|
|
494
494
|
* @property {string} [target.category] - The category of the application
|
|
495
|
+
* @property {string} [icon] - Shortcut icon (base64 encoded image or svg binary if mimetype is not present)
|
|
496
|
+
* @property {string} [iconMimeType] - Shortcut icon mimetype
|
|
495
497
|
* @property {string} [externalId] - An external Id, typically used for external apps
|
|
496
498
|
* @property {object} [externalDataSource] - Additional information to maintain link with external data source
|
|
497
499
|
* @property {string} [externalDataSource.source] - The space to which the application belongs
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cozy-client",
|
|
3
|
-
"version": "60.
|
|
3
|
+
"version": "60.12.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"main": "dist/index.node.js",
|
|
6
6
|
"browser": "dist/index.js",
|
|
@@ -74,5 +74,5 @@
|
|
|
74
74
|
"react-native-ios11-devicecheck": "^0.0.3"
|
|
75
75
|
},
|
|
76
76
|
"sideEffects": false,
|
|
77
|
-
"gitHead": "
|
|
77
|
+
"gitHead": "447b690728bc0016d69a8a71fc31f72339fbf1ce"
|
|
78
78
|
}
|
package/types/hooks/index.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export { default as useAppLinkWithStoreFallback } from "./useAppLinkWithStoreFallback";
|
|
2
2
|
export { default as useCapabilities } from "./useCapabilities";
|
|
3
3
|
export { default as useFetchShortcut } from "./useFetchShortcut";
|
|
4
|
+
export { default as useFetchHomeShortcuts } from "./useFetchHomeShortcuts";
|
|
4
5
|
export { default as useClient } from "./useClient";
|
|
5
6
|
export { default as useAppsInMaintenance } from "./useAppsInMaintenance";
|
|
6
7
|
export { default as useQueryAll } from "./useQueryAll";
|
package/types/models/file.d.ts
CHANGED
|
@@ -40,6 +40,7 @@ export function isEncryptedFileOrFolder(fileOrdir: import("../types").IOCozyFile
|
|
|
40
40
|
export function isOnlyOfficeFile(file: import("../types").IOCozyFile): boolean;
|
|
41
41
|
export function shouldBeOpenedByOnlyOffice(file: import("../types").IOCozyFile): boolean;
|
|
42
42
|
export function isShortcut(file: import("../types").IOCozyFile): boolean;
|
|
43
|
+
export function getShortcutImgSrc(file: import("../types").IOCozyFile): string | undefined;
|
|
43
44
|
export function getSharingShortcutStatus(file: import("../types").IOCozyFile): string;
|
|
44
45
|
export function getSharingShortcutTargetMime(file: import("../types").IOCozyFile): string;
|
|
45
46
|
export function getSharingShortcutTargetDoctype(file: import("../types").IOCozyFile): string;
|
package/types/types.d.ts
CHANGED
|
@@ -879,6 +879,14 @@ export type FileMetadata = {
|
|
|
879
879
|
title: string;
|
|
880
880
|
category: string;
|
|
881
881
|
};
|
|
882
|
+
/**
|
|
883
|
+
* - Shortcut icon (base64 encoded image or svg binary if mimetype is not present)
|
|
884
|
+
*/
|
|
885
|
+
icon?: string;
|
|
886
|
+
/**
|
|
887
|
+
* - Shortcut icon mimetype
|
|
888
|
+
*/
|
|
889
|
+
iconMimeType?: string;
|
|
882
890
|
/**
|
|
883
891
|
* - An external Id, typically used for external apps
|
|
884
892
|
*/
|