cozy-harvest-lib 22.2.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,19 @@
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
+
6
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)
7
20
 
8
21
 
@@ -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;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cozy-harvest-lib",
3
- "version": "22.2.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": "4aabca6edec79405a512a15e004db9b3ad331e67"
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