cozy-client 60.24.0 → 60.26.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/dist/CozyClient.js +1 -1
- package/dist/models/assistant.js +38 -40
- package/package.json +2 -2
- package/types/models/assistant.d.ts +1 -1
package/dist/CozyClient.js
CHANGED
|
@@ -3126,7 +3126,7 @@ var CozyClient = /*#__PURE__*/function () {
|
|
|
3126
3126
|
CozyClient.hooks = CozyClient.hooks || {};
|
|
3127
3127
|
CozyClient.fetchPolicies = _policies.default; //COZY_CLIENT_VERSION_PACKAGE in replaced by babel. See babel config
|
|
3128
3128
|
|
|
3129
|
-
CozyClient.version = "60.
|
|
3129
|
+
CozyClient.version = "60.26.0";
|
|
3130
3130
|
|
|
3131
3131
|
_microee.default.mixin(CozyClient);
|
|
3132
3132
|
|
package/dist/models/assistant.js
CHANGED
|
@@ -41,13 +41,14 @@ var ACCOUNT_DOCTYPE = 'io.cozy.accounts';
|
|
|
41
41
|
*
|
|
42
42
|
* @param {CozyClient} client - An instance of CozyClient
|
|
43
43
|
* @param {Assistant} assistantData - Data for the new assistant
|
|
44
|
-
* @returns {Promise<
|
|
44
|
+
* @returns {Promise<Assistant>} - A promise that resolves with the created assistant document
|
|
45
45
|
* @throws {Error} - Throws an error if the creation fails
|
|
46
46
|
*/
|
|
47
47
|
|
|
48
48
|
var createAssistant = /*#__PURE__*/function () {
|
|
49
49
|
var _ref = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(client, assistantData) {
|
|
50
|
-
var createdAccountId, account, response, assistant;
|
|
50
|
+
var createdAccountId, account, response, assistant, _yield$client$save, savedAssistant;
|
|
51
|
+
|
|
51
52
|
return _regenerator.default.wrap(function _callee$(_context) {
|
|
52
53
|
while (1) {
|
|
53
54
|
switch (_context.prev = _context.next) {
|
|
@@ -108,43 +109,44 @@ var createAssistant = /*#__PURE__*/function () {
|
|
|
108
109
|
return client.save(assistant);
|
|
109
110
|
|
|
110
111
|
case 14:
|
|
111
|
-
|
|
112
|
-
|
|
112
|
+
_yield$client$save = _context.sent;
|
|
113
|
+
savedAssistant = _yield$client$save.data;
|
|
114
|
+
return _context.abrupt("return", savedAssistant);
|
|
113
115
|
|
|
114
|
-
case
|
|
115
|
-
_context.prev =
|
|
116
|
+
case 19:
|
|
117
|
+
_context.prev = 19;
|
|
116
118
|
_context.t0 = _context["catch"](1);
|
|
117
119
|
|
|
118
120
|
if (!createdAccountId) {
|
|
119
|
-
_context.next =
|
|
121
|
+
_context.next = 30;
|
|
120
122
|
break;
|
|
121
123
|
}
|
|
122
124
|
|
|
123
|
-
_context.prev =
|
|
124
|
-
_context.next =
|
|
125
|
+
_context.prev = 22;
|
|
126
|
+
_context.next = 25;
|
|
125
127
|
return client.stackClient.collection('io.cozy.accounts').destroy({
|
|
126
128
|
_id: createdAccountId
|
|
127
129
|
});
|
|
128
130
|
|
|
129
|
-
case
|
|
130
|
-
_context.next =
|
|
131
|
+
case 25:
|
|
132
|
+
_context.next = 30;
|
|
131
133
|
break;
|
|
132
134
|
|
|
133
|
-
case
|
|
134
|
-
_context.prev =
|
|
135
|
-
_context.t1 = _context["catch"](
|
|
135
|
+
case 27:
|
|
136
|
+
_context.prev = 27;
|
|
137
|
+
_context.t1 = _context["catch"](22);
|
|
136
138
|
|
|
137
139
|
_logger.default.warn('Failed to cleanup orphaned account:', _context.t1);
|
|
138
140
|
|
|
139
|
-
case
|
|
141
|
+
case 30:
|
|
140
142
|
throw new Error("Failed to create assistant: ".concat(_context.t0.message));
|
|
141
143
|
|
|
142
|
-
case
|
|
144
|
+
case 31:
|
|
143
145
|
case "end":
|
|
144
146
|
return _context.stop();
|
|
145
147
|
}
|
|
146
148
|
}
|
|
147
|
-
}, _callee, null, [[1,
|
|
149
|
+
}, _callee, null, [[1, 19], [22, 27]]);
|
|
148
150
|
}));
|
|
149
151
|
|
|
150
152
|
return function createAssistant(_x, _x2) {
|
|
@@ -165,7 +167,7 @@ exports.createAssistant = createAssistant;
|
|
|
165
167
|
|
|
166
168
|
var deleteAssistant = /*#__PURE__*/function () {
|
|
167
169
|
var _ref2 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2(client, assistantId) {
|
|
168
|
-
var
|
|
170
|
+
var _yield$client$query, assistantDoc, included, provider;
|
|
169
171
|
|
|
170
172
|
return _regenerator.default.wrap(function _callee2$(_context2) {
|
|
171
173
|
while (1) {
|
|
@@ -176,42 +178,38 @@ var deleteAssistant = /*#__PURE__*/function () {
|
|
|
176
178
|
return client.query((0, _dsl.Q)(ASSISTANT_DOCTYPE).getById(assistantId).include(['provider']));
|
|
177
179
|
|
|
178
180
|
case 3:
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
181
|
+
_yield$client$query = _context2.sent;
|
|
182
|
+
assistantDoc = _yield$client$query.data;
|
|
183
|
+
included = _yield$client$query.included;
|
|
182
184
|
_context2.next = 8;
|
|
183
|
-
return client.
|
|
184
|
-
_id: assistantId,
|
|
185
|
-
_rev: assistantInstance._rev
|
|
186
|
-
});
|
|
185
|
+
return client.destroy(assistantDoc);
|
|
187
186
|
|
|
188
187
|
case 8:
|
|
189
|
-
|
|
190
|
-
|
|
188
|
+
provider = included === null || included === void 0 ? void 0 : included[0];
|
|
189
|
+
|
|
190
|
+
if (!provider) {
|
|
191
|
+
_context2.next = 12;
|
|
191
192
|
break;
|
|
192
193
|
}
|
|
193
194
|
|
|
194
|
-
_context2.next =
|
|
195
|
-
return client.
|
|
196
|
-
_id: provider._id,
|
|
197
|
-
_rev: provider._rev
|
|
198
|
-
});
|
|
195
|
+
_context2.next = 12;
|
|
196
|
+
return client.destroy(provider);
|
|
199
197
|
|
|
200
|
-
case
|
|
201
|
-
_context2.next =
|
|
198
|
+
case 12:
|
|
199
|
+
_context2.next = 17;
|
|
202
200
|
break;
|
|
203
201
|
|
|
204
|
-
case
|
|
205
|
-
_context2.prev =
|
|
202
|
+
case 14:
|
|
203
|
+
_context2.prev = 14;
|
|
206
204
|
_context2.t0 = _context2["catch"](0);
|
|
207
205
|
throw new Error("Failed to delete assistant: ".concat(_context2.t0.message));
|
|
208
206
|
|
|
209
|
-
case
|
|
207
|
+
case 17:
|
|
210
208
|
case "end":
|
|
211
209
|
return _context2.stop();
|
|
212
210
|
}
|
|
213
211
|
}
|
|
214
|
-
}, _callee2, null, [[0,
|
|
212
|
+
}, _callee2, null, [[0, 14]]);
|
|
215
213
|
}));
|
|
216
214
|
|
|
217
215
|
return function deleteAssistant(_x3, _x4) {
|
|
@@ -233,7 +231,7 @@ exports.deleteAssistant = deleteAssistant;
|
|
|
233
231
|
|
|
234
232
|
var editAssistant = /*#__PURE__*/function () {
|
|
235
233
|
var _ref3 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee3(client, assistantId, assistantData) {
|
|
236
|
-
var _existedAssistant$
|
|
234
|
+
var _existedAssistant$inc, _existedAssistantData, _existedAssistantData2, _existedAssistantData3, _existedAssistantData4, _existedAssistantData5, existedAssistant, existedAssistantData, provider, account, _account$data, _account$auth, response, assistant;
|
|
237
235
|
|
|
238
236
|
return _regenerator.default.wrap(function _callee3$(_context3) {
|
|
239
237
|
while (1) {
|
|
@@ -255,7 +253,7 @@ var editAssistant = /*#__PURE__*/function () {
|
|
|
255
253
|
|
|
256
254
|
case 6:
|
|
257
255
|
existedAssistantData = existedAssistant.data;
|
|
258
|
-
provider = existedAssistant === null || existedAssistant === void 0 ? void 0 : (_existedAssistant$
|
|
256
|
+
provider = existedAssistant === null || existedAssistant === void 0 ? void 0 : (_existedAssistant$inc = existedAssistant.included) === null || _existedAssistant$inc === void 0 ? void 0 : _existedAssistant$inc[0];
|
|
259
257
|
|
|
260
258
|
if (provider) {
|
|
261
259
|
_context3.next = 10;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cozy-client",
|
|
3
|
-
"version": "60.
|
|
3
|
+
"version": "60.26.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"main": "dist/index.node.js",
|
|
6
6
|
"browser": "dist/index.js",
|
|
@@ -74,5 +74,5 @@
|
|
|
74
74
|
"react-native-ios11-devicecheck": "^0.0.3"
|
|
75
75
|
},
|
|
76
76
|
"sideEffects": false,
|
|
77
|
-
"gitHead": "
|
|
77
|
+
"gitHead": "364d348ff17d2e0683b7bfec9f03ab5a680f9c29"
|
|
78
78
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export function createAssistant(client: CozyClient, assistantData: Assistant): Promise<
|
|
1
|
+
export function createAssistant(client: CozyClient, assistantData: Assistant): Promise<Assistant>;
|
|
2
2
|
export function deleteAssistant(client: CozyClient, assistantId: string): Promise<void>;
|
|
3
3
|
export function editAssistant(client: CozyClient, assistantId: string, assistantData: Assistant): Promise<void>;
|
|
4
4
|
export type Assistant = {
|