cozy-harvest-lib 13.2.2 → 13.4.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.
Files changed (42) hide show
  1. package/CHANGELOG.md +29 -0
  2. package/dist/components/AccountForm/CannotConnectModal.js +14 -8
  3. package/dist/components/AccountForm/index.js +3 -5
  4. package/dist/components/Markdown.js +7 -3
  5. package/dist/components/TriggerManager.spec.js +6 -3
  6. package/dist/components/cards/LaunchTriggerAlert.js +3 -5
  7. package/dist/components/cards/LaunchTriggerCard.js +2 -5
  8. package/dist/helpers/konnectors.js +0 -29
  9. package/dist/helpers/konnectors.spec.js +1 -46
  10. package/dist/konnector-policies.js +14 -8
  11. package/dist/locales/en.json +2 -1
  12. package/dist/locales/fr.json +2 -1
  13. package/dist/models/ConnectionFlow.js +102 -145
  14. package/dist/models/ConnectionFlow.spec.js +219 -263
  15. package/dist/{services → policies}/biWebView.js +7 -3
  16. package/dist/{services → policies}/biWebView.spec.js +3 -3
  17. package/dist/{services → policies}/budget-insight.js +8 -3
  18. package/dist/{services → policies}/budget-insight.spec.js +5 -5
  19. package/dist/policies/clisk.js +75 -0
  20. package/dist/policies/clisk.spec.js +27 -0
  21. package/dist/types.js +4 -1
  22. package/package.json +2 -2
  23. package/src/components/AccountForm/CannotConnectModal.jsx +15 -7
  24. package/src/components/AccountForm/index.jsx +3 -2
  25. package/src/components/Markdown.jsx +2 -1
  26. package/src/components/TriggerManager.spec.jsx +6 -3
  27. package/src/components/cards/LaunchTriggerAlert.jsx +3 -2
  28. package/src/components/cards/LaunchTriggerCard.jsx +2 -2
  29. package/src/helpers/konnectors.js +0 -23
  30. package/src/helpers/konnectors.spec.js +0 -30
  31. package/src/konnector-policies.js +13 -9
  32. package/src/locales/en.json +2 -1
  33. package/src/locales/fr.json +2 -1
  34. package/src/models/ConnectionFlow.js +48 -75
  35. package/src/models/ConnectionFlow.spec.js +154 -186
  36. package/src/{services → policies}/biWebView.js +9 -3
  37. package/src/{services → policies}/biWebView.spec.js +6 -3
  38. package/src/{services → policies}/budget-insight.js +6 -3
  39. package/src/{services → policies}/budget-insight.spec.js +5 -5
  40. package/src/policies/clisk.js +66 -0
  41. package/src/policies/clisk.spec.js +29 -0
  42. package/src/types.js +4 -1
package/CHANGELOG.md CHANGED
@@ -3,6 +3,35 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ # [13.4.0](https://github.com/cozy/cozy-libs/compare/cozy-harvest-lib@13.3.0...cozy-harvest-lib@13.4.0) (2023-02-21)
7
+
8
+
9
+ ### Features
10
+
11
+ * **harvest:** Add create account wording in CannotConnectModal ([1d78356](https://github.com/cozy/cozy-libs/commit/1d78356b441b70c4da0a0ad06df3250edfe5ae52))
12
+ * **harvest:** Add props propagation on Markdown component ([f76f9a6](https://github.com/cozy/cozy-libs/commit/f76f9a6a22c6bbe23169638973b68ecfb7842257))
13
+
14
+
15
+
16
+
17
+
18
+ # [13.3.0](https://github.com/cozy/cozy-libs/compare/cozy-harvest-lib@13.2.2...cozy-harvest-lib@13.3.0) (2023-02-16)
19
+
20
+
21
+ ### Bug Fixes
22
+
23
+ * Avoid ts error ([25f577d](https://github.com/cozy/cozy-libs/commit/25f577d22c9eca08d34cf15edb4c4529ba8b0766))
24
+ * Remove findKonnectorPolicy log ([e26b0d0](https://github.com/cozy/cozy-libs/commit/e26b0d000c9d10a27e436949eb321949716d8d90))
25
+
26
+
27
+ ### Features
28
+
29
+ * Extract clisk policy and do not create triggers and accounts ([b137453](https://github.com/cozy/cozy-libs/commit/b137453509fd65f2f538c1852154a3f85b01fb71))
30
+
31
+
32
+
33
+
34
+
6
35
  ## [13.2.2](https://github.com/cozy/cozy-libs/compare/cozy-harvest-lib@13.2.1...cozy-harvest-lib@13.2.2) (2023-02-11)
7
36
 
8
37
  **Note:** Version bump only for package cozy-harvest-lib
@@ -1,10 +1,10 @@
1
1
  import React from 'react';
2
2
  import PropTypes from 'prop-types';
3
3
  import Typography from 'cozy-ui/transpiled/react/Typography';
4
- import Link from 'cozy-ui/transpiled/react/Link';
5
4
  import { ConfirmDialog } from 'cozy-ui/transpiled/react/CozyDialogs';
6
5
  import { useI18n } from 'cozy-ui/transpiled/react/I18n';
7
6
  import { useComponentsProps } from '../Providers/ComponentsPropsProvider';
7
+ import Markdown from '../Markdown';
8
8
 
9
9
  var CannotConnectModal = function CannotConnectModal(_ref) {
10
10
  var _ComponentsProps$Cann;
@@ -24,13 +24,19 @@ var CannotConnectModal = function CannotConnectModal(_ref) {
24
24
  content: /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Typography, {
25
25
  variant: "h4",
26
26
  className: "u-mb-1"
27
- }, t('accountForm.cannotConnectModal.title')), /*#__PURE__*/React.createElement(Typography, {
28
- className: "u-mb-1"
29
- }, t('accountForm.cannotConnectModal.content'), /*#__PURE__*/React.createElement(Link, {
30
- href: vendorLink,
31
- target: "_blank",
32
- rel: "noopener noreferrer"
33
- }, vendorName)), ComponentsProps === null || ComponentsProps === void 0 ? void 0 : (_ComponentsProps$Cann = ComponentsProps.CannotConnectModal) === null || _ComponentsProps$Cann === void 0 ? void 0 : _ComponentsProps$Cann.extraContent),
27
+ }, t('accountForm.cannotConnectModal.title')), /*#__PURE__*/React.createElement(Markdown, {
28
+ className: "u-mb-1",
29
+ source: t('accountForm.cannotConnectModal.content', {
30
+ vendorLink: vendorLink,
31
+ vendorName: vendorName
32
+ })
33
+ }), /*#__PURE__*/React.createElement(Markdown, {
34
+ className: "u-mb-1",
35
+ source: t('accountForm.cannotConnectModal.noAccount', {
36
+ vendorLink: vendorLink,
37
+ vendorName: vendorName
38
+ })
39
+ }), ComponentsProps === null || ComponentsProps === void 0 ? void 0 : (_ComponentsProps$Cann = ComponentsProps.CannotConnectModal) === null || _ComponentsProps$Cann === void 0 ? void 0 : _ComponentsProps$Cann.extraContent),
34
40
  onClose: onClose
35
41
  });
36
42
  };
@@ -34,7 +34,8 @@ import AccountFields from './AccountFields';
34
34
  import ReadOnlyIdentifier from './ReadOnlyIdentifier';
35
35
  import TriggerErrorInfo from '../infos/TriggerErrorInfo';
36
36
  import fieldHelpers, { getEncryptedFieldName, SECRET } from '../../helpers/fields';
37
- import { KonnectorJobError, isRunnable } from '../../helpers/konnectors';
37
+ import { KonnectorJobError } from '../../helpers/konnectors';
38
+ import { findKonnectorPolicy } from '../../konnector-policies';
38
39
  import manifest from '../../helpers/manifest';
39
40
  import withKonnectorLocales from '../hoc/withKonnectorLocales';
40
41
  import withConnectionFlow from '../../models/withConnectionFlow';
@@ -344,10 +345,7 @@ export var AccountForm = /*#__PURE__*/function (_PureComponent) {
344
345
  onClick: onBack,
345
346
  konnector: konnector,
346
347
  identifier: get(account, "auth.".concat(manifest.getIdentifier(sanitizedFields)))
347
- }), isRunnable({
348
- win: window,
349
- konnector: konnector
350
- }) ? /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(AccountFields, {
348
+ }), findKonnectorPolicy(konnector).isRunnable() ? /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(AccountFields, {
351
349
  disabled: submitting,
352
350
  fields: sanitizedFields,
353
351
  hasError: error && isLoginError,
@@ -1,4 +1,6 @@
1
+ import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
1
2
  import _extends from "@babel/runtime/helpers/extends";
3
+ var _excluded = ["source", "linkProps"];
2
4
  import React from 'react';
3
5
  import ReactMarkdown from 'react-markdown';
4
6
  import Link from 'cozy-ui/transpiled/react/Link';
@@ -24,13 +26,15 @@ var reactMarkdownRendererOptions = function reactMarkdownRendererOptions(_ref) {
24
26
 
25
27
  export var Markdown = function Markdown(_ref2) {
26
28
  var source = _ref2.source,
27
- linkProps = _ref2.linkProps;
28
- return /*#__PURE__*/React.createElement(ReactMarkdown, {
29
+ linkProps = _ref2.linkProps,
30
+ props = _objectWithoutProperties(_ref2, _excluded);
31
+
32
+ return /*#__PURE__*/React.createElement(ReactMarkdown, _extends({}, props, {
29
33
  source: source,
30
34
  linkTarget: "_blank",
31
35
  renderers: reactMarkdownRendererOptions({
32
36
  linkProps: linkProps
33
37
  })
34
- });
38
+ }));
35
39
  };
36
40
  export default Markdown;
@@ -65,8 +65,8 @@ jest.mock('cozy-doctypes', function () {
65
65
  CozyFolder: CozyFolder
66
66
  });
67
67
  });
68
- jest.mock('../../src/services/budget-insight', function () {
69
- var originalBudgetInsight = jest.requireActual('../../src/services/budget-insight');
68
+ jest.mock('../../src/policies/budget-insight', function () {
69
+ var originalBudgetInsight = jest.requireActual('../../src/policies/budget-insight');
70
70
  return {
71
71
  konnectorPolicy: _objectSpread(_objectSpread({}, originalBudgetInsight.konnectorPolicy), {}, {
72
72
  onAccountCreation: jest.fn()
@@ -252,7 +252,10 @@ describe('TriggerManager', function () {
252
252
  switch (_context5.prev = _context5.next) {
253
253
  case 0:
254
254
  findKonnectorPolicy.mockReturnValue({
255
- saveInVault: false
255
+ saveInVault: false,
256
+ isRunnable: function isRunnable() {
257
+ return true;
258
+ }
256
259
  });
257
260
  _render2 = render( /*#__PURE__*/React.createElement(AppLike, null, /*#__PURE__*/React.createElement(TriggerManager, omit(props, 'vaultClient')))), findByLabelText = _render2.findByLabelText, findByTitle = _render2.findByTitle;
258
261
  _context5.next = 4;
@@ -11,7 +11,8 @@ import Snackbar from 'cozy-ui/transpiled/react/Snackbar';
11
11
  import WrenchCircleIcon from 'cozy-ui/transpiled/react/Icons/WrenchCircle';
12
12
  import { makeStyles } from 'cozy-ui/transpiled/react/styles';
13
13
  import { getAccountId, getKonnectorSlug } from '../../helpers/triggers';
14
- import { isRunnable, isDisconnected } from '../../helpers/konnectors';
14
+ import { isDisconnected } from '../../helpers/konnectors';
15
+ import { findKonnectorPolicy } from '../../konnector-policies';
15
16
  import { useFlowState } from '../../models/withConnectionFlow';
16
17
  import { SUCCESS } from '../../models/flowEvents';
17
18
  import withAdaptiveRouter from '../hoc/withRouter';
@@ -72,10 +73,7 @@ export var LaunchTriggerAlert = function LaunchTriggerAlert(_ref2) {
72
73
  var styles = useStyles({
73
74
  block: block
74
75
  });
75
- var isKonnectorRunnable = isRunnable({
76
- win: window,
77
- konnector: konnector
78
- });
76
+ var isKonnectorRunnable = findKonnectorPolicy(konnector).isRunnable();
79
77
  var isKonnectorDisconnected = isDisconnected(konnector, trigger);
80
78
  useEffect(function () {
81
79
  if (status === SUCCESS) {
@@ -18,7 +18,7 @@ import Typography from 'cozy-ui/transpiled/react/Typography';
18
18
  import SyncIcon from 'cozy-ui/transpiled/react/Icons/Sync';
19
19
  import LaunchTriggerAlert from './LaunchTriggerAlert';
20
20
  import * as triggers from '../../helpers/triggers';
21
- import { isRunnable } from '../../helpers/konnectors';
21
+ import { findKonnectorPolicy } from '../../konnector-policies';
22
22
  import FlowProvider from '../FlowProvider';
23
23
  import { useFlowState } from '../../models/withConnectionFlow';
24
24
  var inlineStyle = {
@@ -37,10 +37,7 @@ export var DumbLaunchTriggerCard = function DumbLaunchTriggerCard(_ref) {
37
37
  running = flowState.running,
38
38
  expectingTriggerLaunch = flowState.expectingTriggerLaunch;
39
39
  var lastSuccessDate = triggers.getLastSuccessDate(trigger);
40
- var isKonnectorRunnable = isRunnable({
41
- win: window,
42
- konnector: konnector
43
- });
40
+ var isKonnectorRunnable = findKonnectorPolicy(konnector).isRunnable();
44
41
  return /*#__PURE__*/React.createElement(Card, {
45
42
  className: className
46
43
  }, /*#__PURE__*/React.createElement("div", {
@@ -385,33 +385,6 @@ export var buildFolderPermission = function buildFolderPermission(folder) {
385
385
  }
386
386
  };
387
387
  };
388
- /**
389
- * Get's the launcher in the current environment if any
390
- *
391
- * @param {Object} win The window object in the current environment
392
- * @returns {Object}
393
- */
394
-
395
- export var getLauncher = function getLauncher(_ref2) {
396
- var win = _ref2.win;
397
- return get(win, 'cozy.ClientConnectorLauncher', null);
398
- };
399
- /**
400
- * Define if it is possible to run a konnector in the current environment
401
- *
402
- * @param {Object} win The window object in the current environment
403
- * @param {Object} konnector The io.cozy.konnectors object for the current konnector
404
- * @returns {Boolean}
405
- */
406
-
407
- export var isRunnable = function isRunnable(_ref3) {
408
- var win = _ref3.win,
409
- _ref3$konnector = _ref3.konnector,
410
- konnector = _ref3$konnector === void 0 ? {} : _ref3$konnector;
411
- return Boolean(!konnector.clientSide || getLauncher({
412
- win: win
413
- }));
414
- };
415
388
  /**
416
389
  * Define if konnector is disconnected or not
417
390
  *
@@ -428,8 +401,6 @@ export default {
428
401
  buildFolderPath: buildFolderPath,
429
402
  buildFolderPermission: buildFolderPermission,
430
403
  getAccountType: getAccountType,
431
- getLauncher: getLauncher,
432
- isRunnable: isRunnable,
433
404
  hasNewVersionAvailable: hasNewVersionAvailable,
434
405
  needsFolder: needsFolder,
435
406
  fetchSupportMail: fetchSupportMail,
@@ -4,7 +4,7 @@ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (O
4
4
 
5
5
  function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
6
6
 
7
- import { buildFolderPath, buildFolderPermission, getAccountType, hasNewVersionAvailable, KonnectorJobError, needsFolder, getErrorLocale, getLauncher, isRunnable, getErrorLocaleBound } from 'helpers/konnectors';
7
+ import { buildFolderPath, buildFolderPermission, getAccountType, hasNewVersionAvailable, KonnectorJobError, needsFolder, getErrorLocale, getErrorLocaleBound } from 'helpers/konnectors';
8
8
  var fixtures = {
9
9
  account: {
10
10
  _id: '5f344a5e53034124846dd0816909e27c'
@@ -201,51 +201,6 @@ describe('Konnectors Helpers', function () {
201
201
  expect(error.type).toBe('UNKNOWN_ERROR');
202
202
  });
203
203
  });
204
- describe('getLauncher', function () {
205
- it('should get the current Launcher from the given window object', function () {
206
- var cozy = {
207
- ClientConnectorLauncher: 'test-react-native'
208
- };
209
- expect(getLauncher({
210
- win: {
211
- cozy: cozy
212
- }
213
- })).toEqual('test-react-native');
214
- });
215
- it('should should return null if no launcher is available', function () {
216
- expect(getLauncher({
217
- win: {}
218
- })).toBe(null);
219
- });
220
- });
221
- describe('isRunnable', function () {
222
- var cozy = {
223
- ClientConnectorLauncher: 'test-react-native'
224
- };
225
- var konnector = {
226
- clientSide: true
227
- };
228
- it('should return true if konnector is clientSide and a launcher is available', function () {
229
- expect(isRunnable({
230
- win: {
231
- cozy: cozy
232
- },
233
- konnector: konnector
234
- })).toBe(true);
235
- });
236
- it('should should return true if not ClientSide', function () {
237
- expect(isRunnable({
238
- win: {},
239
- konnector: {}
240
- })).toBe(true);
241
- });
242
- it('should should return false in other case', function () {
243
- expect(isRunnable({
244
- win: {},
245
- konnector: konnector
246
- })).toBe(false);
247
- });
248
- });
249
204
  });
250
205
  describe('locales', function () {
251
206
  var error = new KonnectorJobError('DISK_QUOTA_EXCEEDED');
@@ -1,18 +1,26 @@
1
1
  import logger from './logger';
2
- import { konnectorPolicy as biKonnectorPolicy } from './services/budget-insight';
3
- import { konnectorPolicy as biWebViewPolicy } from './services/biWebView';
2
+ import { konnectorPolicy as biKonnectorPolicy } from './policies/budget-insight';
3
+ import { konnectorPolicy as biWebViewPolicy } from './policies/biWebView';
4
+ import { konnectorPolicy as cliskPolicy } from './policies/clisk';
4
5
  var defaultKonnectorPolicy = {
5
6
  accountContainsAuth: true,
6
7
  saveInVault: true,
7
8
  onAccountCreation: null,
8
- match: function match() {
9
+ // eslint-disable-next-line no-unused-vars
10
+ match: function match(konnector) {
9
11
  return true;
10
12
  },
11
13
  name: 'default',
12
14
  fetchExtraOAuthUrlParams: null,
13
- refreshContracts: null
15
+ refreshContracts: null,
16
+ needsTriggerLaunch: true,
17
+ needsAccountAndTriggerCreation: true,
18
+ onLaunch: null,
19
+ isRunnable: function isRunnable() {
20
+ return true;
21
+ }
14
22
  };
15
- var policies = [biWebViewPolicy, biKonnectorPolicy, defaultKonnectorPolicy].filter(Boolean);
23
+ var policies = [cliskPolicy, biWebViewPolicy, biKonnectorPolicy, defaultKonnectorPolicy].filter(Boolean);
16
24
  logger.info('Available konnector policies', policies);
17
25
  /**
18
26
  * Find the konnector policy corresponding to the given konnector
@@ -22,9 +30,7 @@ logger.info('Available konnector policies', policies);
22
30
  */
23
31
 
24
32
  export var findKonnectorPolicy = function findKonnectorPolicy(konnector) {
25
- var policy = policies.find(function (policy) {
33
+ return policies.find(function (policy) {
26
34
  return policy.match(konnector);
27
35
  });
28
- logger.info("Using ".concat(policy.name, " konnector policy for ").concat(konnector.slug));
29
- return policy;
30
36
  };
@@ -23,7 +23,8 @@
23
23
  },
24
24
  "cannotConnectModal": {
25
25
  "title": "You can't connect?",
26
- "content": "You can check your login or reset your password on the website "
26
+ "content": "You can check your login or reset your password on the [%{vendorName}](%{vendorLink})'s website.",
27
+ "noAccount": "If you do not have an account you will need to create one on the [%{vendorName}](%{vendorLink})'s website."
27
28
  },
28
29
  "cannotConnectLink": "I can't connect",
29
30
  "notClientSide": "The %{name} application uses a brand-new and efficient system for retrieving your data from your Cozy. This action is only accessible from the Cozy mobile app."
@@ -23,7 +23,8 @@
23
23
  },
24
24
  "cannotConnectModal": {
25
25
  "title": "Vous ne parvenez pas à vous connecter ?",
26
- "content": "Vous pouvez vérifier vos identifiants ou réinitialiser votre mot de passe sur le site "
26
+ "content": "Vous pouvez vérifier vos identifiants ou réinitialiser votre mot de passe sur le site [%{vendorName}](%{vendorLink}).",
27
+ "noAccount": "Si vous n'avez pas de compte il vous faudra en créer sur le site [%{vendorName}](%{vendorLink})."
27
28
  },
28
29
  "cannotConnectLink": "Je ne parviens pas à me connecter",
29
30
  "notClientSide": "L'application %{name} utilise un nouveau système plus efficace pour la récupération de vos données dans votre Cozy. Cette action est uniquement accessible depuis l’application mobile Cozy."