cozy-harvest-lib 22.1.0 → 22.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/CHANGELOG.md CHANGED
@@ -3,6 +3,30 @@
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
+ # [22.3.0](https://github.com/cozy/cozy-libs/compare/cozy-harvest-lib@22.2.0...cozy-harvest-lib@22.3.0) (2024-01-31)
7
+
8
+
9
+ ### Features
10
+
11
+ * Add doctype debug cards for bills, files and identities ([1e65d7d](https://github.com/cozy/cozy-libs/commit/1e65d7dde77776a19dc545073968b7b03b09a5b5))
12
+ * Add realtime to doctype debug cards ([36609e5](https://github.com/cozy/cozy-libs/commit/36609e5d9d33ace65e9ae74a56db6b0ed2f86e92))
13
+ * Pass the sourceAccountIdentifier to harvest cards ([309e16c](https://github.com/cozy/cozy-libs/commit/309e16cfb17ca08ded268ac368e8fb27dcd97710))
14
+
15
+
16
+
17
+
18
+
19
+ # [22.2.0](https://github.com/cozy/cozy-libs/compare/cozy-harvest-lib@22.1.0...cozy-harvest-lib@22.2.0) (2024-01-29)
20
+
21
+
22
+ ### Features
23
+
24
+ * Add the UNKNOWN_ERROR.PARTIAL_SYNC konnector error message ([8532ee1](https://github.com/cozy/cozy-libs/commit/8532ee1ae2b22f3c3b166ae9e2d6d4e9ac0f343c))
25
+
26
+
27
+
28
+
29
+
6
30
  # [22.1.0](https://github.com/cozy/cozy-libs/compare/cozy-harvest-lib@22.0.8...cozy-harvest-lib@22.1.0) (2024-01-25)
7
31
 
8
32
 
@@ -1,4 +1,5 @@
1
1
  import React, { useMemo } from 'react';
2
+ import { models } from 'cozy-client';
2
3
  import { useDatacardOptions } from './DatacardOptionsContext';
3
4
 
4
5
  var findSuitableDataCards = function findSuitableDataCards(datacardOptions, datacardContext) {
@@ -28,7 +29,8 @@ var Datacards = function Datacards(_ref2) {
28
29
  key: i,
29
30
  konnector: konnector,
30
31
  trigger: trigger,
31
- accountId: trigger.message.account
32
+ accountId: trigger.message.account,
33
+ sourceAccountIdentifier: models.account.getAccountLogin(account)
32
34
  });
33
35
  }));
34
36
  };
@@ -1,7 +1,7 @@
1
1
  import PropTypes from 'prop-types';
2
2
  import React from 'react';
3
3
  import ReactJsonPrint from 'react-json-print';
4
- import CozyClient, { Q, useQuery, hasQueryBeenLoaded } from 'cozy-client';
4
+ import CozyClient, { Q, useQuery, hasQueryBeenLoaded, RealTimeQueries } from 'cozy-client';
5
5
  import Button from 'cozy-ui/transpiled/react/Buttons';
6
6
  import Card from 'cozy-ui/transpiled/react/Card';
7
7
  import Divider from 'cozy-ui/transpiled/react/Divider';
@@ -46,7 +46,9 @@ var DoctypeDebugCard = function DoctypeDebugCard(_ref) {
46
46
  }
47
47
 
48
48
  var clipBoardAvailable = (_navigator$clipboard = navigator.clipboard) === null || _navigator$clipboard === void 0 ? void 0 : _navigator$clipboard.writeText;
49
- return !failed && loaded ? /*#__PURE__*/React.createElement(Card, null, /*#__PURE__*/React.createElement(Typography, {
49
+ return !failed && loaded ? /*#__PURE__*/React.createElement(Card, null, /*#__PURE__*/React.createElement(RealTimeQueries, {
50
+ doctype: doctype
51
+ }), /*#__PURE__*/React.createElement(Typography, {
50
52
  variant: "button"
51
53
  }, doctype), clipBoardAvailable ? /*#__PURE__*/React.createElement(Button, {
52
54
  label: "copy",
@@ -1,3 +1,9 @@
1
+ import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
+
3
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
4
+
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
+
1
7
  /**
2
8
  * This file list all possible doctypes to datacard possibilities.
3
9
  * Its default export can be used as the value of the doctypeToDataCard
@@ -7,6 +13,8 @@
7
13
  * all dependencies that are necessary for all types of data card.
8
14
  */
9
15
  import get from 'lodash/get';
16
+ import flag from 'cozy-flags';
17
+ import DoctypeDebugCard from './DoctypeDebugCard';
10
18
  import FileDataCard from './FileDataCard';
11
19
  import GeoDataCard from './GeoDataCard';
12
20
  var timeseriesGeoJSONDatacard = {
@@ -25,7 +33,47 @@ var filesDatacard = {
25
33
  return get(trigger, 'message.folder_to_save');
26
34
  }
27
35
  };
36
+ var filesDebugDatacard = {
37
+ component: function component(options) {
38
+ return DoctypeDebugCard(_objectSpread({
39
+ doctype: 'io.cozy.files'
40
+ }, options));
41
+ },
42
+ match: function match(_ref3) {
43
+ var konnector = _ref3.konnector;
44
+ return hasPermission(konnector, 'io.cozy.files') && flag('harvest.show-doctype-debug-cards');
45
+ }
46
+ };
47
+ var identitiesDebugDatacard = {
48
+ component: function component(options) {
49
+ return DoctypeDebugCard(_objectSpread({
50
+ doctype: 'io.cozy.identities'
51
+ }, options));
52
+ },
53
+ match: function match(_ref4) {
54
+ var konnector = _ref4.konnector;
55
+ return hasPermission(konnector, 'io.cozy.identities') && flag('harvest.show-doctype-debug-cards');
56
+ }
57
+ };
58
+ var billsDebugDatacard = {
59
+ component: function component(options) {
60
+ return DoctypeDebugCard(_objectSpread({
61
+ doctype: 'io.cozy.bills'
62
+ }, options));
63
+ },
64
+ match: function match(_ref5) {
65
+ var konnector = _ref5.konnector;
66
+ return hasPermission(konnector, 'io.cozy.bills') && flag('harvest.show-doctype-debug-cards');
67
+ }
68
+ };
28
69
  var options = {
29
- datacards: [timeseriesGeoJSONDatacard, filesDatacard]
70
+ datacards: [timeseriesGeoJSONDatacard, filesDatacard, filesDebugDatacard, identitiesDebugDatacard, billsDebugDatacard]
30
71
  };
72
+
73
+ function hasPermission(konnector, doctype) {
74
+ return Object.values(konnector.permissions).filter(function (x) {
75
+ return x.type === doctype;
76
+ }).length > 0;
77
+ }
78
+
31
79
  export default options;
@@ -191,6 +191,10 @@
191
191
  "title": "Connection error",
192
192
  "description": "An unknown error has occurred. You can try to update your data. If the problem persists, please contact us at [%{supportMail}](mailto:%{supportMail})."
193
193
  },
194
+ "UNKNOWN_ERROR.PARTIAL_SYNC": {
195
+ "title": "Connection error",
196
+ "description": "The synchronization is complete but some elements may be missing"
197
+ },
194
198
  "USER_ACTION_NEEDED": {
195
199
  "title": "Action needed on the provider's website",
196
200
  "description": "It seems that the [%{name}](%{link}) website requires you to log in and to complete a specific action. Please re-run the connector once you have settled the issue on the website."
@@ -191,6 +191,10 @@
191
191
  "title": "Erreur de Connexion",
192
192
  "description": "Une erreur inconnue est survenue. Vous pouvez essayer de synchroniser à nouveau vos données. Si le problème persiste, n'hésitez pas à nous contacter via [%{supportMail}](mailto:%{supportMail})."
193
193
  },
194
+ "UNKNOWN_ERROR.PARTIAL_SYNC": {
195
+ "title": "Erreur de Connexion",
196
+ "description": "La synchronisation est terminé mais certains éléments peuvent manquer"
197
+ },
194
198
  "USER_ACTION_NEEDED": {
195
199
  "title": "Action nécessaire chez le fournisseur",
196
200
  "description": "Il semble que [%{name}](%{link}) ait besoin de revérifier votre connexion. Connectez-vous sur [%{name}](%{link}) avant de synchroniser à nouveau vos données."
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cozy-harvest-lib",
3
- "version": "22.1.0",
3
+ "version": "22.3.0",
4
4
  "description": "Provides logic, modules and components for Cozy's harvest applications.",
5
5
  "main": "dist/index.js",
6
6
  "author": "Cozy",
@@ -107,5 +107,5 @@
107
107
  "react-router-dom": ">=4.3.1"
108
108
  },
109
109
  "sideEffects": false,
110
- "gitHead": "f9c3597079f8b120e43249d752227da9a2e63541"
110
+ "gitHead": "c71fea1c06805d3a37ff6b6a7837d4d7eacfb9f7"
111
111
  }
@@ -1,5 +1,7 @@
1
1
  import React, { useMemo } from 'react'
2
2
 
3
+ import { models } from 'cozy-client'
4
+
3
5
  import { useDatacardOptions } from './DatacardOptionsContext'
4
6
 
5
7
  const findSuitableDataCards = (datacardOptions, datacardContext) => {
@@ -24,6 +26,7 @@ const Datacards = ({ konnector, account, trigger }) => {
24
26
  konnector={konnector}
25
27
  trigger={trigger}
26
28
  accountId={trigger.message.account}
29
+ sourceAccountIdentifier={models.account.getAccountLogin(account)}
27
30
  />
28
31
  ))}
29
32
  </>
@@ -1,8 +1,12 @@
1
1
  import PropTypes from 'prop-types'
2
2
  import React from 'react'
3
3
  import ReactJsonPrint from 'react-json-print'
4
-
5
- import CozyClient, { Q, useQuery, hasQueryBeenLoaded } from 'cozy-client'
4
+ import CozyClient, {
5
+ Q,
6
+ useQuery,
7
+ hasQueryBeenLoaded,
8
+ RealTimeQueries
9
+ } from 'cozy-client'
6
10
  import Button from 'cozy-ui/transpiled/react/Buttons'
7
11
  import Card from 'cozy-ui/transpiled/react/Card'
8
12
  import Divider from 'cozy-ui/transpiled/react/Divider'
@@ -53,6 +57,7 @@ const DoctypeDebugCard = ({ sourceAccountIdentifier, konnector, doctype }) => {
53
57
  const clipBoardAvailable = navigator.clipboard?.writeText
54
58
  return !failed && loaded ? (
55
59
  <Card>
60
+ <RealTimeQueries doctype={doctype} />
56
61
  <Typography variant="button">{doctype}</Typography>
57
62
  {clipBoardAvailable ? (
58
63
  <Button
@@ -9,6 +9,9 @@
9
9
 
10
10
  import get from 'lodash/get'
11
11
 
12
+ import flag from 'cozy-flags'
13
+
14
+ import DoctypeDebugCard from './DoctypeDebugCard'
12
15
  import FileDataCard from './FileDataCard'
13
16
  import GeoDataCard from './GeoDataCard'
14
17
 
@@ -25,8 +28,45 @@ const filesDatacard = {
25
28
  match: ({ trigger }) => get(trigger, 'message.folder_to_save')
26
29
  }
27
30
 
31
+ const filesDebugDatacard = {
32
+ component: options =>
33
+ DoctypeDebugCard({ doctype: 'io.cozy.files', ...options }),
34
+ match: ({ konnector }) =>
35
+ hasPermission(konnector, 'io.cozy.files') &&
36
+ flag('harvest.show-doctype-debug-cards')
37
+ }
38
+
39
+ const identitiesDebugDatacard = {
40
+ component: options =>
41
+ DoctypeDebugCard({ doctype: 'io.cozy.identities', ...options }),
42
+ match: ({ konnector }) =>
43
+ hasPermission(konnector, 'io.cozy.identities') &&
44
+ flag('harvest.show-doctype-debug-cards')
45
+ }
46
+
47
+ const billsDebugDatacard = {
48
+ component: options =>
49
+ DoctypeDebugCard({ doctype: 'io.cozy.bills', ...options }),
50
+ match: ({ konnector }) =>
51
+ hasPermission(konnector, 'io.cozy.bills') &&
52
+ flag('harvest.show-doctype-debug-cards')
53
+ }
54
+
28
55
  const options = {
29
- datacards: [timeseriesGeoJSONDatacard, filesDatacard]
56
+ datacards: [
57
+ timeseriesGeoJSONDatacard,
58
+ filesDatacard,
59
+ filesDebugDatacard,
60
+ identitiesDebugDatacard,
61
+ billsDebugDatacard
62
+ ]
63
+ }
64
+
65
+ function hasPermission(konnector, doctype) {
66
+ return (
67
+ Object.values(konnector.permissions).filter(x => x.type === doctype)
68
+ .length > 0
69
+ )
30
70
  }
31
71
 
32
72
  export default options
@@ -191,6 +191,10 @@
191
191
  "title": "Connection error",
192
192
  "description": "An unknown error has occurred. You can try to update your data. If the problem persists, please contact us at [%{supportMail}](mailto:%{supportMail})."
193
193
  },
194
+ "UNKNOWN_ERROR.PARTIAL_SYNC": {
195
+ "title": "Connection error",
196
+ "description": "The synchronization is complete but some elements may be missing"
197
+ },
194
198
  "USER_ACTION_NEEDED": {
195
199
  "title": "Action needed on the provider's website",
196
200
  "description": "It seems that the [%{name}](%{link}) website requires you to log in and to complete a specific action. Please re-run the connector once you have settled the issue on the website."
@@ -191,6 +191,10 @@
191
191
  "title": "Erreur de Connexion",
192
192
  "description": "Une erreur inconnue est survenue. Vous pouvez essayer de synchroniser à nouveau vos données. Si le problème persiste, n'hésitez pas à nous contacter via [%{supportMail}](mailto:%{supportMail})."
193
193
  },
194
+ "UNKNOWN_ERROR.PARTIAL_SYNC": {
195
+ "title": "Erreur de Connexion",
196
+ "description": "La synchronisation est terminé mais certains éléments peuvent manquer"
197
+ },
194
198
  "USER_ACTION_NEEDED": {
195
199
  "title": "Action nécessaire chez le fournisseur",
196
200
  "description": "Il semble que [%{name}](%{link}) ait besoin de revérifier votre connexion. Connectez-vous sur [%{name}](%{link}) avant de synchroniser à nouveau vos données."