cozy-client 48.11.2 → 48.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.
@@ -2839,7 +2839,7 @@ var CozyClient = /*#__PURE__*/function () {
2839
2839
  CozyClient.hooks = CozyClient.hooks || {};
2840
2840
  CozyClient.fetchPolicies = _policies.default; //COZY_CLIENT_VERSION_PACKAGE in replaced by babel. See babel config
2841
2841
 
2842
- CozyClient.version = "48.11.2";
2842
+ CozyClient.version = "48.12.0";
2843
2843
 
2844
2844
  _microee.default.mixin(CozyClient);
2845
2845
 
@@ -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.fetchBlobFileById = exports.isFromKonnector = exports.hasCertifications = exports.hasQualifications = exports.isPlainText = exports.doMobileUpload = exports.readMobileFile = 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.isEncrypted = exports.isNote = exports.isDirectory = exports.isFile = exports.splitFilename = exports.ALBUMS_DOCTYPE = void 0;
11
+ exports.copy = exports.fetchBlobFileById = exports.isFromKonnector = exports.hasCertifications = exports.hasQualifications = exports.isPlainText = exports.doMobileUpload = exports.readMobileFile = 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.isEncrypted = 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
 
@@ -1083,5 +1083,95 @@ var fetchBlobFileById = /*#__PURE__*/function () {
1083
1083
  return _ref14.apply(this, arguments);
1084
1084
  };
1085
1085
  }();
1086
+ /**
1087
+ * Copies a file to a specified destination.
1088
+ *
1089
+ * @param {object} client - The client object used for making API requests.
1090
+ * @param {object} file - The file object to be copied.
1091
+ * @param {object} destination - The destination object where the file will be copied to.
1092
+ * @returns {Promise} - A promise that resolves with the response from the API.
1093
+ * @throws {Error} - If an error occurs during the API request.
1094
+ */
1095
+
1096
+
1097
+ exports.fetchBlobFileById = fetchBlobFileById;
1098
+
1099
+ var copy = /*#__PURE__*/function () {
1100
+ var _ref15 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee13(client, file, destination) {
1101
+ var _resp2, _resp3, _resp4, resp;
1102
+
1103
+ return _regenerator.default.wrap(function _callee13$(_context13) {
1104
+ while (1) {
1105
+ switch (_context13.prev = _context13.next) {
1106
+ case 0:
1107
+ _context13.prev = 0;
1108
+
1109
+ if (!(file._type === 'io.cozy.remote.nextcloud.files' && destination._type === 'io.cozy.remote.nextcloud.files')) {
1110
+ _context13.next = 6;
1111
+ break;
1112
+ }
1113
+
1114
+ _context13.next = 4;
1115
+ return client.collection('io.cozy.remote.nextcloud.files').copy(file, destination);
1116
+
1117
+ case 4:
1118
+ _resp2 = _context13.sent;
1119
+ return _context13.abrupt("return", _resp2);
1120
+
1121
+ case 6:
1122
+ if (!(file._type === 'io.cozy.remote.nextcloud.files' && destination._type === 'io.cozy.files')) {
1123
+ _context13.next = 11;
1124
+ break;
1125
+ }
1126
+
1127
+ _context13.next = 9;
1128
+ return client.collection('io.cozy.remote.nextcloud.files').moveToCozy(file, destination, {
1129
+ copy: true
1130
+ });
1131
+
1132
+ case 9:
1133
+ _resp3 = _context13.sent;
1134
+ return _context13.abrupt("return", _resp3);
1135
+
1136
+ case 11:
1137
+ if (!(destination._type === 'io.cozy.remote.nextcloud.files')) {
1138
+ _context13.next = 16;
1139
+ break;
1140
+ }
1141
+
1142
+ _context13.next = 14;
1143
+ return client.collection('io.cozy.remote.nextcloud.files').moveFromCozy(destination, file, {
1144
+ copy: true
1145
+ });
1146
+
1147
+ case 14:
1148
+ _resp4 = _context13.sent;
1149
+ return _context13.abrupt("return", _resp4);
1150
+
1151
+ case 16:
1152
+ _context13.next = 18;
1153
+ return client.collection(_const.DOCTYPE_FILES).copy(file._id, undefined, destination._id);
1154
+
1155
+ case 18:
1156
+ resp = _context13.sent;
1157
+ return _context13.abrupt("return", resp);
1158
+
1159
+ case 22:
1160
+ _context13.prev = 22;
1161
+ _context13.t0 = _context13["catch"](0);
1162
+ throw _context13.t0;
1163
+
1164
+ case 25:
1165
+ case "end":
1166
+ return _context13.stop();
1167
+ }
1168
+ }
1169
+ }, _callee13, null, [[0, 22]]);
1170
+ }));
1171
+
1172
+ return function copy(_x27, _x28, _x29) {
1173
+ return _ref15.apply(this, arguments);
1174
+ };
1175
+ }();
1086
1176
 
1087
- exports.fetchBlobFileById = fetchBlobFileById;
1177
+ exports.copy = copy;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cozy-client",
3
- "version": "48.11.2",
3
+ "version": "48.12.0",
4
4
  "license": "MIT",
5
5
  "main": "dist/index.node.js",
6
6
  "browser": "dist/index.js",
@@ -18,7 +18,7 @@
18
18
  "@types/jest": "^26.0.20",
19
19
  "@types/lodash": "^4.14.170",
20
20
  "btoa": "^1.2.1",
21
- "cozy-stack-client": "^48.9.0",
21
+ "cozy-stack-client": "^48.12.0",
22
22
  "date-fns": "2.29.3",
23
23
  "json-stable-stringify": "^1.0.1",
24
24
  "lodash": "^4.17.13",
@@ -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": "e8129adc0b6d19e3165c79fe00294428e213f9c4"
78
+ "gitHead": "4b5b757b6b1cc8029453eab2d981214be6f33256"
79
79
  }
@@ -67,6 +67,7 @@ export function hasQualifications(file: import("../types").IOCozyFile): boolean;
67
67
  export function hasCertifications(file: import("../types").IOCozyFile): boolean;
68
68
  export function isFromKonnector(file: import("../types").IOCozyFile): boolean;
69
69
  export function fetchBlobFileById(client: CozyClient, fileId: string): Promise<Blob>;
70
+ export function copy(client: object, file: object, destination: object): Promise<any>;
70
71
  export type FileUploadOptions = {
71
72
  /**
72
73
  * - The file name to upload