cozy-client 41.7.1 → 41.8.1
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/models/utils.js +44 -2
- package/dist/models/utils.spec.js +79 -1
- package/package.json +2 -2
- package/types/models/utils.d.ts +3 -2
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 = "41.
|
|
2706
|
+
CozyClient.version = "41.8.1";
|
|
2707
2707
|
|
|
2708
2708
|
_microee.default.mixin(CozyClient);
|
|
2709
2709
|
|
package/dist/models/utils.js
CHANGED
|
@@ -5,21 +5,63 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", {
|
|
6
6
|
value: true
|
|
7
7
|
});
|
|
8
|
-
exports.getCreatedByApp = exports.hasBeenUpdatedByApp = void 0;
|
|
8
|
+
exports.getFlagshipDownloadLink = exports.getCreatedByApp = exports.hasBeenUpdatedByApp = void 0;
|
|
9
9
|
|
|
10
10
|
var _get = _interopRequireDefault(require("lodash/get"));
|
|
11
11
|
|
|
12
|
+
var _cozyDeviceHelper = require("cozy-device-helper");
|
|
13
|
+
|
|
14
|
+
var _cozyFlags = _interopRequireDefault(require("cozy-flags"));
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Checks if a document has been updated by a specific app
|
|
18
|
+
*
|
|
19
|
+
* @param {object} doc - The document to check
|
|
20
|
+
* @param {string} appSlug - The slug of the app to check
|
|
21
|
+
* @returns {boolean} - True if the document has been updated by the app, false otherwise
|
|
22
|
+
*/
|
|
12
23
|
var hasBeenUpdatedByApp = function hasBeenUpdatedByApp(doc, appSlug) {
|
|
13
24
|
var updatedByApps = (0, _get.default)(doc, 'cozyMetadata.updatedByApps');
|
|
14
25
|
return Boolean(updatedByApps && updatedByApps.find(function (x) {
|
|
15
26
|
return x.slug === appSlug;
|
|
16
27
|
}));
|
|
17
28
|
};
|
|
29
|
+
/**
|
|
30
|
+
* Gets the app that created a document
|
|
31
|
+
*
|
|
32
|
+
* @param {object} doc - The document to check
|
|
33
|
+
* @returns {string} - The slug of the app that created the document
|
|
34
|
+
*/
|
|
35
|
+
|
|
18
36
|
|
|
19
37
|
exports.hasBeenUpdatedByApp = hasBeenUpdatedByApp;
|
|
20
38
|
|
|
21
39
|
var getCreatedByApp = function getCreatedByApp(doc) {
|
|
22
40
|
return (0, _get.default)(doc, 'cozyMetadata.createdByApp');
|
|
23
41
|
};
|
|
42
|
+
/**
|
|
43
|
+
* Gets the download link for the Cozy Flagship app and his white-labels versions
|
|
44
|
+
*
|
|
45
|
+
* @param {string} lang - The language code for the download page
|
|
46
|
+
* @returns {string} - The URL of the download page
|
|
47
|
+
*/
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
exports.getCreatedByApp = getCreatedByApp;
|
|
51
|
+
|
|
52
|
+
var getFlagshipDownloadLink = function getFlagshipDownloadLink(lang) {
|
|
53
|
+
if ((0, _cozyDeviceHelper.isAndroid)()) {
|
|
54
|
+
var id = (0, _cozyFlags.default)('flagship.playstore-id') || 'io.cozy.flagship.mobile';
|
|
55
|
+
return "https://play.google.com/store/apps/details?id=".concat(id, "&hl=").concat(lang);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
if ((0, _cozyDeviceHelper.isIOS)()) {
|
|
59
|
+
var _id = (0, _cozyFlags.default)('flagship.appstore-id') || 'id1600636174';
|
|
60
|
+
|
|
61
|
+
return "https://apps.apple.com/".concat(lang, "/app/").concat(_id);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
return (0, _cozyFlags.default)('flagship.download-link') || "https://cozy.io/".concat(lang, "/download");
|
|
65
|
+
};
|
|
24
66
|
|
|
25
|
-
exports.
|
|
67
|
+
exports.getFlagshipDownloadLink = getFlagshipDownloadLink;
|
|
@@ -1,4 +1,17 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
getCreatedByApp,
|
|
3
|
+
hasBeenUpdatedByApp,
|
|
4
|
+
getFlagshipDownloadLink
|
|
5
|
+
} from './utils'
|
|
6
|
+
import { isAndroid, isIOS } from 'cozy-device-helper'
|
|
7
|
+
import flag from 'cozy-flags'
|
|
8
|
+
|
|
9
|
+
jest.mock('cozy-device-helper', () => ({
|
|
10
|
+
isAndroid: jest.fn(),
|
|
11
|
+
isIOS: jest.fn()
|
|
12
|
+
}))
|
|
13
|
+
|
|
14
|
+
jest.mock('cozy-flags')
|
|
2
15
|
|
|
3
16
|
test('getCreatedByApp', () => {
|
|
4
17
|
expect(getCreatedByApp({ cozyMetadata: { createdByApp: 'banks' } })).toBe(
|
|
@@ -22,3 +35,68 @@ test('hasBeenUpdatedByApp', () => {
|
|
|
22
35
|
).toBe(false)
|
|
23
36
|
expect(hasBeenUpdatedByApp({}, 'drive')).toBe(false)
|
|
24
37
|
})
|
|
38
|
+
|
|
39
|
+
describe('getFlagshipDownloadLink', () => {
|
|
40
|
+
afterEach(() => {
|
|
41
|
+
jest.resetAllMocks()
|
|
42
|
+
})
|
|
43
|
+
|
|
44
|
+
it('should return the Android download link with the correct ID and language', () => {
|
|
45
|
+
// @ts-ignore
|
|
46
|
+
isAndroid.mockReturnValueOnce(true)
|
|
47
|
+
flag.mockReturnValueOnce('com.example.app')
|
|
48
|
+
const lang = 'fr'
|
|
49
|
+
expect(getFlagshipDownloadLink(lang)).toBe(
|
|
50
|
+
'https://play.google.com/store/apps/details?id=com.example.app&hl=fr'
|
|
51
|
+
)
|
|
52
|
+
})
|
|
53
|
+
|
|
54
|
+
it('should return the default Android download link if no ID is provided', () => {
|
|
55
|
+
// @ts-ignore
|
|
56
|
+
isAndroid.mockReturnValueOnce(true)
|
|
57
|
+
flag.mockReturnValueOnce(null)
|
|
58
|
+
const lang = 'en'
|
|
59
|
+
expect(getFlagshipDownloadLink(lang)).toBe(
|
|
60
|
+
'https://play.google.com/store/apps/details?id=io.cozy.flagship.mobile&hl=en'
|
|
61
|
+
)
|
|
62
|
+
})
|
|
63
|
+
|
|
64
|
+
it('should return the iOS download link with the correct ID and language', () => {
|
|
65
|
+
// @ts-ignore
|
|
66
|
+
isIOS.mockReturnValueOnce(true)
|
|
67
|
+
flag.mockReturnValueOnce('id123456')
|
|
68
|
+
const lang = 'es'
|
|
69
|
+
expect(getFlagshipDownloadLink(lang)).toBe(
|
|
70
|
+
'https://apps.apple.com/es/app/id123456'
|
|
71
|
+
)
|
|
72
|
+
})
|
|
73
|
+
|
|
74
|
+
it('should return the default iOS download link if no ID is provided', () => {
|
|
75
|
+
// @ts-ignore
|
|
76
|
+
isIOS.mockReturnValueOnce(true)
|
|
77
|
+
flag.mockReturnValueOnce(null)
|
|
78
|
+
const lang = 'en'
|
|
79
|
+
expect(getFlagshipDownloadLink(lang)).toBe(
|
|
80
|
+
'https://apps.apple.com/en/app/id1600636174'
|
|
81
|
+
)
|
|
82
|
+
})
|
|
83
|
+
|
|
84
|
+
it('should return the download link from the flag for other platforms', () => {
|
|
85
|
+
// @ts-ignore
|
|
86
|
+
isAndroid.mockReturnValueOnce(false)
|
|
87
|
+
// @ts-ignore
|
|
88
|
+
isIOS.mockReturnValueOnce(false)
|
|
89
|
+
flag.mockReturnValueOnce('https://other.site/download')
|
|
90
|
+
const lang = 'fr'
|
|
91
|
+
expect(getFlagshipDownloadLink(lang)).toBe('https://other.site/download')
|
|
92
|
+
})
|
|
93
|
+
|
|
94
|
+
it('should return the default download link for other platforms', () => {
|
|
95
|
+
// @ts-ignore
|
|
96
|
+
isAndroid.mockReturnValueOnce(false)
|
|
97
|
+
// @ts-ignore
|
|
98
|
+
isIOS.mockReturnValueOnce(false)
|
|
99
|
+
const lang = 'fr'
|
|
100
|
+
expect(getFlagshipDownloadLink(lang)).toBe('https://cozy.io/fr/download')
|
|
101
|
+
})
|
|
102
|
+
})
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cozy-client",
|
|
3
|
-
"version": "41.
|
|
3
|
+
"version": "41.8.1",
|
|
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": "9641ee5ed541bc481f6b5a83d3c678277c502301"
|
|
79
79
|
}
|
package/types/models/utils.d.ts
CHANGED
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
export function hasBeenUpdatedByApp(doc:
|
|
2
|
-
export function getCreatedByApp(doc:
|
|
1
|
+
export function hasBeenUpdatedByApp(doc: object, appSlug: string): boolean;
|
|
2
|
+
export function getCreatedByApp(doc: object): string;
|
|
3
|
+
export function getFlagshipDownloadLink(lang: string): string;
|