cozy-client 35.0.0 → 35.2.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/account.js +91 -15
- package/dist/models/account.spec.js +82 -1
- package/dist/models/document/locales/en.json +9 -1
- package/dist/models/document/locales/fr.json +9 -1
- package/dist/models/trigger.js +120 -27
- package/dist/models/trigger.spec.js +67 -0
- package/dist/types.js +47 -3
- package/package.json +2 -2
- package/types/models/account.d.ts +7 -5
- package/types/models/trigger.d.ts +16 -10
- package/types/types.d.ts +124 -4
package/dist/CozyClient.js
CHANGED
|
@@ -2669,7 +2669,7 @@ var CozyClient = /*#__PURE__*/function () {
|
|
|
2669
2669
|
CozyClient.hooks = CozyClient.hooks || {};
|
|
2670
2670
|
CozyClient.fetchPolicies = _policies.default; //COZY_CLIENT_VERSION_PACKAGE in replaced by babel. See babel config
|
|
2671
2671
|
|
|
2672
|
-
CozyClient.version = "35.
|
|
2672
|
+
CozyClient.version = "35.2.0";
|
|
2673
2673
|
|
|
2674
2674
|
_microee.default.mixin(CozyClient);
|
|
2675
2675
|
|
package/dist/models/account.js
CHANGED
|
@@ -5,41 +5,43 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", {
|
|
6
6
|
value: true
|
|
7
7
|
});
|
|
8
|
-
exports.setContractSyncStatusInAccount = exports.getContractSyncStatusFromAccount = exports.muteError = exports.getMutedErrors = void 0;
|
|
8
|
+
exports.buildAccount = exports.getAccountName = exports.getAccountLogin = exports.setContractSyncStatusInAccount = exports.getContractSyncStatusFromAccount = exports.muteError = exports.getMutedErrors = void 0;
|
|
9
9
|
|
|
10
10
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
11
11
|
|
|
12
|
-
var _get = _interopRequireDefault(require("lodash/get"));
|
|
13
|
-
|
|
14
12
|
var _merge = _interopRequireDefault(require("lodash/merge"));
|
|
15
13
|
|
|
16
14
|
var _HasMany = require("../associations/HasMany");
|
|
17
15
|
|
|
16
|
+
var _manifest = require("./manifest");
|
|
17
|
+
|
|
18
|
+
function _createForOfIteratorHelper(o, allowArrayLike) { var it; if (typeof Symbol === "undefined" || o[Symbol.iterator] == null) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = o[Symbol.iterator](); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
|
|
19
|
+
|
|
20
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
21
|
+
|
|
22
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
|
23
|
+
|
|
18
24
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
|
|
19
25
|
|
|
20
26
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
21
27
|
|
|
22
|
-
/**
|
|
23
|
-
* @typedef {object} CozyAccount
|
|
24
|
-
*/
|
|
25
|
-
|
|
26
28
|
/**
|
|
27
29
|
* getMutedErrors - Returns the list of errors that have been muted for the given account
|
|
28
30
|
*
|
|
29
|
-
* @param {
|
|
31
|
+
* @param {import('../types').IOCozyAccount} account io.cozy.accounts
|
|
30
32
|
*
|
|
31
33
|
* @returns {Array} An array of errors with a `type` and `mutedAt` field
|
|
32
34
|
*/
|
|
33
35
|
var getMutedErrors = function getMutedErrors(account) {
|
|
34
|
-
return (0
|
|
36
|
+
return (account === null || account === void 0 ? void 0 : account.mutedErrors) || [];
|
|
35
37
|
};
|
|
36
38
|
/**
|
|
37
39
|
* muteError - Adds an error to the list of muted errors for the given account
|
|
38
40
|
*
|
|
39
|
-
* @param {
|
|
41
|
+
* @param {import('../types').IOCozyAccount} account io.cozy.accounts
|
|
40
42
|
* @param {string} errorType The type of the error to mute
|
|
41
43
|
*
|
|
42
|
-
* @returns {
|
|
44
|
+
* @returns {import('../types').IOCozyAccount} An updated io.cozy.accounts
|
|
43
45
|
*/
|
|
44
46
|
|
|
45
47
|
|
|
@@ -61,22 +63,29 @@ var DEFAULT_CONTRACT_SYNC_STATUS = true;
|
|
|
61
63
|
/**
|
|
62
64
|
* Returns whether a contract is synced from account relationship
|
|
63
65
|
*
|
|
64
|
-
* @param {
|
|
66
|
+
* @param {import('../types').IOCozyAccount} account - Cozy account
|
|
67
|
+
* @param {String} contractId - contract identifier
|
|
68
|
+
* @returns {Boolean} synchronisation status
|
|
65
69
|
*/
|
|
66
70
|
|
|
67
71
|
var getContractSyncStatusFromAccount = function getContractSyncStatusFromAccount(account, contractId) {
|
|
72
|
+
var _relItem$metadata$imp, _relItem$metadata;
|
|
73
|
+
|
|
68
74
|
var relItem = (0, _HasMany.getHasManyItem)(account, 'contracts', contractId);
|
|
69
75
|
|
|
70
76
|
if (!relItem) {
|
|
71
77
|
throw new Error("Cannot find contrat ".concat(contractId, " in account"));
|
|
72
78
|
}
|
|
73
79
|
|
|
74
|
-
return (0
|
|
80
|
+
return (_relItem$metadata$imp = relItem === null || relItem === void 0 ? void 0 : (_relItem$metadata = relItem.metadata) === null || _relItem$metadata === void 0 ? void 0 : _relItem$metadata.imported) !== null && _relItem$metadata$imp !== void 0 ? _relItem$metadata$imp : DEFAULT_CONTRACT_SYNC_STATUS;
|
|
75
81
|
};
|
|
76
82
|
/**
|
|
77
83
|
* Sets contract sync status into account relationship
|
|
78
84
|
*
|
|
79
|
-
* @param {
|
|
85
|
+
* @param {import('../types').IOCozyAccount} account - Cozy account
|
|
86
|
+
* @param {String} contractId - contract identifier
|
|
87
|
+
* @param {String} syncStatus - synchronisation status
|
|
88
|
+
* @returns {import('../types').IOCozyAccount}
|
|
80
89
|
*/
|
|
81
90
|
|
|
82
91
|
|
|
@@ -95,5 +104,72 @@ var setContractSyncStatusInAccount = function setContractSyncStatusInAccount(acc
|
|
|
95
104
|
});
|
|
96
105
|
});
|
|
97
106
|
};
|
|
107
|
+
/**
|
|
108
|
+
* Get the account login field value from a given account
|
|
109
|
+
*
|
|
110
|
+
* @param {import('../types').IOCozyAccount} account - the given cozy account
|
|
111
|
+
* @returns {String|null} - Account login
|
|
112
|
+
*/
|
|
113
|
+
|
|
114
|
+
|
|
115
|
+
exports.setContractSyncStatusInAccount = setContractSyncStatusInAccount;
|
|
116
|
+
|
|
117
|
+
var getAccountLogin = function getAccountLogin(account) {
|
|
118
|
+
if (account && account.auth) {
|
|
119
|
+
var _iterator = _createForOfIteratorHelper(_manifest.legacyLoginFields),
|
|
120
|
+
_step;
|
|
121
|
+
|
|
122
|
+
try {
|
|
123
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
124
|
+
var fieldName = _step.value;
|
|
125
|
+
if (account.auth[fieldName]) return account.auth[fieldName];
|
|
126
|
+
}
|
|
127
|
+
} catch (err) {
|
|
128
|
+
_iterator.e(err);
|
|
129
|
+
} finally {
|
|
130
|
+
_iterator.f();
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
return null;
|
|
135
|
+
};
|
|
136
|
+
/**
|
|
137
|
+
* Get the account name from a given account
|
|
138
|
+
*
|
|
139
|
+
* @param {import('../types').IOCozyAccount} account - the given cozy account
|
|
140
|
+
* @returns {String|null} - Account name
|
|
141
|
+
*/
|
|
142
|
+
|
|
143
|
+
|
|
144
|
+
exports.getAccountLogin = getAccountLogin;
|
|
145
|
+
|
|
146
|
+
var getAccountName = function getAccountName(account) {
|
|
147
|
+
if (!account) return null;
|
|
148
|
+
|
|
149
|
+
if (account.auth) {
|
|
150
|
+
return account.auth.accountName || getAccountLogin(account) || account._id;
|
|
151
|
+
} else {
|
|
152
|
+
return account._id;
|
|
153
|
+
}
|
|
154
|
+
};
|
|
155
|
+
/**
|
|
156
|
+
* Transforms account auth data to io.cozy.accounts document
|
|
157
|
+
*
|
|
158
|
+
* @param {import('../types').IOCozyKonnector} konnector Konnector related to account
|
|
159
|
+
* @param {object} authData Authentication data
|
|
160
|
+
* @returns {import('../types').IOCozyAccount} io.cozy.accounts attributes
|
|
161
|
+
*/
|
|
162
|
+
|
|
163
|
+
|
|
164
|
+
exports.getAccountName = getAccountName;
|
|
165
|
+
|
|
166
|
+
var buildAccount = function buildAccount(konnector, authData) {
|
|
167
|
+
return {
|
|
168
|
+
auth: authData,
|
|
169
|
+
account_type: konnector.slug,
|
|
170
|
+
identifier: (0, _manifest.getIdentifier)(konnector.fields),
|
|
171
|
+
state: null
|
|
172
|
+
};
|
|
173
|
+
};
|
|
98
174
|
|
|
99
|
-
exports.
|
|
175
|
+
exports.buildAccount = buildAccount;
|
|
@@ -3,7 +3,10 @@ import {
|
|
|
3
3
|
setContractSyncStatusInAccount,
|
|
4
4
|
getContractSyncStatusFromAccount,
|
|
5
5
|
getMutedErrors,
|
|
6
|
-
muteError
|
|
6
|
+
muteError,
|
|
7
|
+
getAccountLogin,
|
|
8
|
+
getAccountName,
|
|
9
|
+
buildAccount
|
|
7
10
|
} from './account'
|
|
8
11
|
|
|
9
12
|
const fixtures = {
|
|
@@ -176,4 +179,82 @@ describe('account model', () => {
|
|
|
176
179
|
).toThrow('Cannot find contrat non-existing-contract-id in account')
|
|
177
180
|
})
|
|
178
181
|
})
|
|
182
|
+
|
|
183
|
+
describe('getAccountLogin', () => {
|
|
184
|
+
it('should get the login value according to legacyLoginFields order', () => {
|
|
185
|
+
expect(
|
|
186
|
+
getAccountLogin({
|
|
187
|
+
auth: { test: 'testvalue', login: 'loginvalue', email: 'emailvalue' }
|
|
188
|
+
})
|
|
189
|
+
).toStrictEqual('loginvalue')
|
|
190
|
+
|
|
191
|
+
expect(
|
|
192
|
+
getAccountLogin({
|
|
193
|
+
auth: { test: 'testvalue', email: 'emailvalue' }
|
|
194
|
+
})
|
|
195
|
+
).toStrictEqual('emailvalue')
|
|
196
|
+
|
|
197
|
+
expect(
|
|
198
|
+
getAccountLogin({
|
|
199
|
+
auth: { test: 'testvalue', email: 'emailvalue', login: 'loginvalue' }
|
|
200
|
+
})
|
|
201
|
+
).toStrictEqual('loginvalue')
|
|
202
|
+
|
|
203
|
+
expect(
|
|
204
|
+
getAccountLogin({
|
|
205
|
+
auth: { test: 'testvalue' }
|
|
206
|
+
})
|
|
207
|
+
).toStrictEqual(null)
|
|
208
|
+
})
|
|
209
|
+
})
|
|
210
|
+
|
|
211
|
+
describe('getAccountName', () => {
|
|
212
|
+
it('should return auth.accountName in priority', () => {
|
|
213
|
+
expect(
|
|
214
|
+
getAccountName({
|
|
215
|
+
_id: 'idvalue',
|
|
216
|
+
auth: { _id: 'idvalue', login: 'loginvalue' }
|
|
217
|
+
})
|
|
218
|
+
).toStrictEqual('loginvalue')
|
|
219
|
+
|
|
220
|
+
expect(
|
|
221
|
+
getAccountName({
|
|
222
|
+
_id: 'idvalue',
|
|
223
|
+
auth: {
|
|
224
|
+
accountName: 'accountNameValue',
|
|
225
|
+
login: 'loginvalue'
|
|
226
|
+
}
|
|
227
|
+
})
|
|
228
|
+
).toStrictEqual('accountNameValue')
|
|
229
|
+
})
|
|
230
|
+
it('should return account _id by default', () => {
|
|
231
|
+
expect(
|
|
232
|
+
getAccountName({
|
|
233
|
+
_id: 'idvalue',
|
|
234
|
+
auth: {}
|
|
235
|
+
})
|
|
236
|
+
).toStrictEqual('idvalue')
|
|
237
|
+
|
|
238
|
+
expect(
|
|
239
|
+
getAccountName({
|
|
240
|
+
_id: 'idvalue'
|
|
241
|
+
})
|
|
242
|
+
).toStrictEqual('idvalue')
|
|
243
|
+
})
|
|
244
|
+
})
|
|
245
|
+
describe('buildAccount', () => {
|
|
246
|
+
it('should build an account', () => {
|
|
247
|
+
expect(
|
|
248
|
+
buildAccount(
|
|
249
|
+
{ slug: 'slugvalue', fields: { loginfield: { role: 'identifier' } } },
|
|
250
|
+
{ loginfield: 'loginfieldvalue' }
|
|
251
|
+
)
|
|
252
|
+
).toStrictEqual({
|
|
253
|
+
auth: { loginfield: 'loginfieldvalue' },
|
|
254
|
+
account_type: 'slugvalue',
|
|
255
|
+
identifier: 'loginfield',
|
|
256
|
+
state: null
|
|
257
|
+
})
|
|
258
|
+
})
|
|
259
|
+
})
|
|
179
260
|
})
|
|
@@ -18,7 +18,6 @@
|
|
|
18
18
|
"successful": {
|
|
19
19
|
"qualified_ok": "You just have successfully described your file! "
|
|
20
20
|
},
|
|
21
|
-
|
|
22
21
|
"items": {
|
|
23
22
|
"accommodation_proof": "Proof of accommodation",
|
|
24
23
|
"appliance_invoice": "Appliance invoice",
|
|
@@ -114,6 +113,15 @@
|
|
|
114
113
|
"work_quote": "Work quote",
|
|
115
114
|
"work_study": "Work & Study"
|
|
116
115
|
},
|
|
116
|
+
"attributes":{
|
|
117
|
+
"contractType": {
|
|
118
|
+
"cdi": "CDI",
|
|
119
|
+
"cdd": "CDD",
|
|
120
|
+
"alternate": "Alternate",
|
|
121
|
+
"internship": "Internship",
|
|
122
|
+
"other": "Other"
|
|
123
|
+
}
|
|
124
|
+
},
|
|
117
125
|
"themes": {
|
|
118
126
|
"activity": "Activities",
|
|
119
127
|
"family": "Family",
|
|
@@ -18,7 +18,6 @@
|
|
|
18
18
|
"successful": {
|
|
19
19
|
"qualified_ok": "Vous venez de qualifier votre fichier avec succès !"
|
|
20
20
|
},
|
|
21
|
-
|
|
22
21
|
"items": {
|
|
23
22
|
"accommodation_proof": "Attestation d'hébergement",
|
|
24
23
|
"appliance_invoice": "Facture d'électroménager",
|
|
@@ -114,6 +113,15 @@
|
|
|
114
113
|
"work_quote": "Devis de travaux",
|
|
115
114
|
"work_study": "Travail & Études"
|
|
116
115
|
},
|
|
116
|
+
"attributes":{
|
|
117
|
+
"contractType": {
|
|
118
|
+
"cdi": "CDI",
|
|
119
|
+
"cdd": "CDD",
|
|
120
|
+
"alternate": "Alternance",
|
|
121
|
+
"internship": "Stage",
|
|
122
|
+
"other": "Autre"
|
|
123
|
+
}
|
|
124
|
+
},
|
|
117
125
|
"themes": {
|
|
118
126
|
"activity": "Activités & loisirs",
|
|
119
127
|
"family": "Famille",
|
package/dist/models/trigger.js
CHANGED
|
@@ -7,43 +7,92 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
7
7
|
});
|
|
8
8
|
exports.triggers = exports.triggerStates = void 0;
|
|
9
9
|
|
|
10
|
-
var
|
|
10
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
11
11
|
|
|
12
12
|
var _account = require("./account");
|
|
13
13
|
|
|
14
14
|
var _logger = _interopRequireDefault(require("../logger"));
|
|
15
15
|
|
|
16
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
|
|
17
|
+
|
|
18
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
19
|
+
|
|
16
20
|
var actionableErrors = ['CHALLENGE_ASKED', 'DISK_QUOTA_EXCEEDED', 'TERMS_VERSION_MISMATCH', 'USER_ACTION_NEEDED', 'USER_ACTION_NEEDED.CHANGE_PASSWORD', 'USER_ACTION_NEEDED.ACCOUNT_REMOVED', 'USER_ACTION_NEEDED.WEBAUTH_REQUIRED', 'USER_ACTION_NEEDED.SCA_REQUIRED', 'LOGIN_FAILED'];
|
|
17
21
|
/** Trigger states come from /jobs/triggers */
|
|
18
22
|
|
|
19
23
|
var triggerStates = {
|
|
20
|
-
/**
|
|
21
|
-
|
|
22
|
-
|
|
24
|
+
/**
|
|
25
|
+
* Returns when the trigger was last executed
|
|
26
|
+
*
|
|
27
|
+
* @param {import('../types').IOCozyTrigger} trigger - trigger object
|
|
28
|
+
* @returns {String} last execution date of any job related to the given trigger
|
|
29
|
+
*/
|
|
30
|
+
getLastExecution: function getLastExecution(trigger) {
|
|
31
|
+
var _trigger$current_stat;
|
|
32
|
+
|
|
33
|
+
return trigger === null || trigger === void 0 ? void 0 : (_trigger$current_stat = trigger.current_state) === null || _trigger$current_stat === void 0 ? void 0 : _trigger$current_stat.last_execution;
|
|
23
34
|
},
|
|
24
|
-
getLastsuccess: function getLastsuccess(triggerState) {
|
|
25
|
-
_logger.default.warn('Deprecated, please use getLastSuccess instead of getLastsuccess');
|
|
26
35
|
|
|
27
|
-
|
|
36
|
+
/**
|
|
37
|
+
* Returns when the trigger was last executed with success
|
|
38
|
+
*
|
|
39
|
+
* @param {import('../types').IOCozyTrigger} trigger - trigger object
|
|
40
|
+
* @returns {String} last execution date of any job related to the given trigger and with success
|
|
41
|
+
*/
|
|
42
|
+
getLastSuccess: function getLastSuccess(trigger) {
|
|
43
|
+
var _trigger$current_stat2;
|
|
44
|
+
|
|
45
|
+
return trigger === null || trigger === void 0 ? void 0 : (_trigger$current_stat2 = trigger.current_state) === null || _trigger$current_stat2 === void 0 ? void 0 : _trigger$current_stat2.last_success;
|
|
28
46
|
},
|
|
29
47
|
|
|
30
|
-
/**
|
|
31
|
-
|
|
32
|
-
|
|
48
|
+
/**
|
|
49
|
+
* Returns when the trigger was last executed with success
|
|
50
|
+
*
|
|
51
|
+
* @param {import('../types').IOCozyTrigger} trigger - trigger object
|
|
52
|
+
* @returns {String} last execution date of any job related to the given trigger and with success
|
|
53
|
+
*/
|
|
54
|
+
getLastsuccess: function getLastsuccess(trigger) {
|
|
55
|
+
var _trigger$current_stat3;
|
|
56
|
+
|
|
57
|
+
_logger.default.warn('Deprecated, please use getLastSuccess instead of getLastsuccess');
|
|
58
|
+
|
|
59
|
+
return trigger === null || trigger === void 0 ? void 0 : (_trigger$current_stat3 = trigger.current_state) === null || _trigger$current_stat3 === void 0 ? void 0 : _trigger$current_stat3.last_success;
|
|
33
60
|
},
|
|
34
61
|
|
|
35
|
-
/**
|
|
36
|
-
|
|
37
|
-
|
|
62
|
+
/**
|
|
63
|
+
* Returns whether last job failed
|
|
64
|
+
*
|
|
65
|
+
* @param {import('../types').IOCozyTrigger} trigger - trigger object
|
|
66
|
+
* @returns {Boolean}
|
|
67
|
+
*/
|
|
68
|
+
isErrored: function isErrored(trigger) {
|
|
69
|
+
var _trigger$current_stat4;
|
|
70
|
+
|
|
71
|
+
return (trigger === null || trigger === void 0 ? void 0 : (_trigger$current_stat4 = trigger.current_state) === null || _trigger$current_stat4 === void 0 ? void 0 : _trigger$current_stat4.status) === 'errored';
|
|
38
72
|
},
|
|
39
73
|
|
|
40
|
-
/**
|
|
41
|
-
|
|
42
|
-
|
|
74
|
+
/**
|
|
75
|
+
* Returns the type of the last error to occur
|
|
76
|
+
*
|
|
77
|
+
* @param {import('../types').IOCozyTrigger} trigger - trigger object
|
|
78
|
+
* @returns {String}
|
|
79
|
+
*/
|
|
80
|
+
getLastErrorType: function getLastErrorType(trigger) {
|
|
81
|
+
var _trigger$current_stat5;
|
|
82
|
+
|
|
83
|
+
return trigger === null || trigger === void 0 ? void 0 : (_trigger$current_stat5 = trigger.current_state) === null || _trigger$current_stat5 === void 0 ? void 0 : _trigger$current_stat5.last_error;
|
|
43
84
|
}
|
|
44
85
|
};
|
|
45
86
|
exports.triggerStates = triggerStates;
|
|
87
|
+
var DEFAULT_CRON = '0 0 0 * * 0'; // Once a week, sunday at midnight
|
|
88
|
+
|
|
46
89
|
var triggers = {
|
|
90
|
+
/**
|
|
91
|
+
* Returns whether the given trigger is associated to a konnector or not
|
|
92
|
+
*
|
|
93
|
+
* @param {import('../types').IOCozyTrigger} trigger - trigger object
|
|
94
|
+
* @returns {Boolean}
|
|
95
|
+
*/
|
|
47
96
|
isKonnectorWorker: function isKonnectorWorker(trigger) {
|
|
48
97
|
return trigger.worker === 'konnector';
|
|
49
98
|
},
|
|
@@ -51,7 +100,7 @@ var triggers = {
|
|
|
51
100
|
/**
|
|
52
101
|
* Returns the konnector slug that executed a trigger
|
|
53
102
|
*
|
|
54
|
-
* @param {
|
|
103
|
+
* @param {import('../types').IOCozyTrigger} trigger - io.cozy.triggers
|
|
55
104
|
*
|
|
56
105
|
* @returns {string|void} A konnector slug
|
|
57
106
|
*/
|
|
@@ -72,28 +121,32 @@ var triggers = {
|
|
|
72
121
|
/**
|
|
73
122
|
* getAccountId - Returns the account id for a trigger
|
|
74
123
|
*
|
|
75
|
-
* @param {
|
|
124
|
+
* @param {import('../types').IOCozyTrigger} trigger io.cozy.triggers
|
|
76
125
|
*
|
|
77
|
-
* @returns {
|
|
126
|
+
* @returns {String} Id for an io.cozy.accounts
|
|
78
127
|
*/
|
|
79
128
|
getAccountId: function getAccountId(trigger) {
|
|
80
|
-
var
|
|
129
|
+
var _trigger$message;
|
|
130
|
+
|
|
131
|
+
var legacyData = trigger === null || trigger === void 0 ? void 0 : (_trigger$message = trigger.message) === null || _trigger$message === void 0 ? void 0 : _trigger$message.Data;
|
|
81
132
|
|
|
82
133
|
if (legacyData) {
|
|
83
134
|
var message = JSON.parse(atob(legacyData));
|
|
84
135
|
return message.account;
|
|
85
136
|
} else {
|
|
86
|
-
|
|
137
|
+
var _trigger$message2;
|
|
138
|
+
|
|
139
|
+
return trigger === null || trigger === void 0 ? void 0 : (_trigger$message2 = trigger.message) === null || _trigger$message2 === void 0 ? void 0 : _trigger$message2.account;
|
|
87
140
|
}
|
|
88
141
|
},
|
|
89
142
|
|
|
90
143
|
/**
|
|
91
144
|
* Checks if the triggers current error has been muted in the corresponding io.cozy.accounts
|
|
92
145
|
*
|
|
93
|
-
* @param {
|
|
94
|
-
* @param {
|
|
146
|
+
* @param {import('../types').IOCozyTrigger} trigger io.cozy.triggers
|
|
147
|
+
* @param {import('../types').IOCozyAccount} account io.cozy.accounts used by the trigger
|
|
95
148
|
*
|
|
96
|
-
* @returns {
|
|
149
|
+
* @returns {Boolean} Whether the error is muted or not
|
|
97
150
|
*/
|
|
98
151
|
isLatestErrorMuted: function isLatestErrorMuted(trigger, account) {
|
|
99
152
|
var lastErrorType = triggerStates.getLastErrorType(trigger);
|
|
@@ -109,12 +162,52 @@ var triggers = {
|
|
|
109
162
|
/**
|
|
110
163
|
* Returns whether the error in trigger can be solved by the user
|
|
111
164
|
*
|
|
112
|
-
* @param {
|
|
165
|
+
* @param {import('../types').IOCozyTrigger} trigger io.cozy.triggers
|
|
113
166
|
*
|
|
114
|
-
* @returns {
|
|
167
|
+
* @returns {Boolean} Whether the error is muted or not
|
|
115
168
|
*/
|
|
116
169
|
hasActionableError: function hasActionableError(trigger) {
|
|
117
|
-
|
|
170
|
+
var _trigger$current_stat6;
|
|
171
|
+
|
|
172
|
+
return actionableErrors.includes(trigger === null || trigger === void 0 ? void 0 : (_trigger$current_stat6 = trigger.current_state) === null || _trigger$current_stat6 === void 0 ? void 0 : _trigger$current_stat6.last_error);
|
|
173
|
+
},
|
|
174
|
+
|
|
175
|
+
/**
|
|
176
|
+
* Build trigger attributes given konnector and account
|
|
177
|
+
*
|
|
178
|
+
* @param {Object} options - options object
|
|
179
|
+
* @param {import('../types').IOCozyKonnector} options.konnector - konnector object
|
|
180
|
+
* @param {import('../types').IOCozyAccount} options.account - account object
|
|
181
|
+
* @param {String} [options.cron] - cron string. Defaults to '0 0 0 * * 0'
|
|
182
|
+
* @param {object} [options.folder] - folder object
|
|
183
|
+
* @returns {import('../types').IOCozyTrigger} created trigger
|
|
184
|
+
*/
|
|
185
|
+
buildTriggerAttributes: function buildTriggerAttributes(_ref) {
|
|
186
|
+
var account = _ref.account,
|
|
187
|
+
_ref$cron = _ref.cron,
|
|
188
|
+
cron = _ref$cron === void 0 ? DEFAULT_CRON : _ref$cron,
|
|
189
|
+
folder = _ref.folder,
|
|
190
|
+
konnector = _ref.konnector;
|
|
191
|
+
var message = {
|
|
192
|
+
account: account._id,
|
|
193
|
+
konnector: konnector.slug
|
|
194
|
+
};
|
|
195
|
+
|
|
196
|
+
if (folder) {
|
|
197
|
+
message['folder_to_save'] = folder._id;
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
var result = {
|
|
201
|
+
worker: 'konnector',
|
|
202
|
+
message: message
|
|
203
|
+
};
|
|
204
|
+
var options = konnector.clientSide ? {
|
|
205
|
+
type: '@client'
|
|
206
|
+
} : {
|
|
207
|
+
type: '@cron',
|
|
208
|
+
arguments: cron
|
|
209
|
+
};
|
|
210
|
+
return _objectSpread(_objectSpread({}, result), options);
|
|
118
211
|
}
|
|
119
212
|
};
|
|
120
213
|
exports.triggers = triggers;
|
|
@@ -219,4 +219,71 @@ describe('trigger model', () => {
|
|
|
219
219
|
).toBe(false)
|
|
220
220
|
})
|
|
221
221
|
})
|
|
222
|
+
|
|
223
|
+
describe('buildTriggerAttributes', () => {
|
|
224
|
+
const konnector = { slug: 'konnectest' }
|
|
225
|
+
const account = { _id: '963a51f6cdd34401b0904de32cc5578d' }
|
|
226
|
+
|
|
227
|
+
it('builds attributes', () => {
|
|
228
|
+
expect(
|
|
229
|
+
triggerModel.buildTriggerAttributes({ konnector, account })
|
|
230
|
+
).toEqual({
|
|
231
|
+
arguments: '0 0 0 * * 0',
|
|
232
|
+
type: '@cron',
|
|
233
|
+
worker: 'konnector',
|
|
234
|
+
message: {
|
|
235
|
+
account: '963a51f6cdd34401b0904de32cc5578d',
|
|
236
|
+
konnector: 'konnectest'
|
|
237
|
+
}
|
|
238
|
+
})
|
|
239
|
+
})
|
|
240
|
+
|
|
241
|
+
it('builds attributes with cron', () => {
|
|
242
|
+
const cron = '0 0 0 * * 2'
|
|
243
|
+
expect(
|
|
244
|
+
triggerModel.buildTriggerAttributes({ konnector, account, cron })
|
|
245
|
+
).toEqual({
|
|
246
|
+
arguments: '0 0 0 * * 2',
|
|
247
|
+
type: '@cron',
|
|
248
|
+
worker: 'konnector',
|
|
249
|
+
message: {
|
|
250
|
+
account: '963a51f6cdd34401b0904de32cc5578d',
|
|
251
|
+
konnector: 'konnectest'
|
|
252
|
+
}
|
|
253
|
+
})
|
|
254
|
+
})
|
|
255
|
+
|
|
256
|
+
it('builds for client side connectors', () => {
|
|
257
|
+
const clientSideConnector = { ...konnector, clientSide: true }
|
|
258
|
+
expect(
|
|
259
|
+
triggerModel.buildTriggerAttributes({
|
|
260
|
+
konnector: clientSideConnector,
|
|
261
|
+
account
|
|
262
|
+
})
|
|
263
|
+
).toEqual({
|
|
264
|
+
type: '@client',
|
|
265
|
+
worker: 'konnector',
|
|
266
|
+
message: {
|
|
267
|
+
account: '963a51f6cdd34401b0904de32cc5578d',
|
|
268
|
+
konnector: 'konnectest'
|
|
269
|
+
}
|
|
270
|
+
})
|
|
271
|
+
})
|
|
272
|
+
|
|
273
|
+
it('build attributes with folder', () => {
|
|
274
|
+
const folder = { _id: '4c43f8e88e5f4a608667da6b5bae8fa4' }
|
|
275
|
+
expect(
|
|
276
|
+
triggerModel.buildTriggerAttributes({ konnector, account, folder })
|
|
277
|
+
).toEqual({
|
|
278
|
+
arguments: '0 0 0 * * 0',
|
|
279
|
+
type: '@cron',
|
|
280
|
+
worker: 'konnector',
|
|
281
|
+
message: {
|
|
282
|
+
account: '963a51f6cdd34401b0904de32cc5578d',
|
|
283
|
+
folder_to_save: '4c43f8e88e5f4a608667da6b5bae8fa4',
|
|
284
|
+
konnector: 'konnectest'
|
|
285
|
+
}
|
|
286
|
+
})
|
|
287
|
+
})
|
|
288
|
+
})
|
|
222
289
|
})
|
package/dist/types.js
CHANGED
|
@@ -12,18 +12,62 @@ var _dsl = require("./queries/dsl");
|
|
|
12
12
|
*/
|
|
13
13
|
|
|
14
14
|
/**
|
|
15
|
-
* @typedef {"io.cozy.accounts"} AccountsDoctype
|
|
16
|
-
* @typedef {"io.cozy.triggers"} TriggersDoctype
|
|
17
|
-
* @typedef {"io.cozy.konnectors"} KonnectorsDoctype
|
|
18
15
|
* @typedef {"io.cozy.notes"} NotesDoctype
|
|
19
16
|
* @typedef {"io.cozy.apps"} AppsDoctype
|
|
20
17
|
* @typedef {"io.cozy.settings"} SettingsDoctype
|
|
21
18
|
* @typedef {"io.cozy-oauth.clients"} OAuthClientsDoctype
|
|
22
19
|
* @typedef {"io.cozy.files"} FilesDoctype
|
|
20
|
+
* @typedef {"io.cozy.account"} AccountsDoctype
|
|
21
|
+
* @typedef {"io.cozy.konnectors"} KonnectorsDoctype
|
|
22
|
+
* @typedef {"io.cozy.triggers"} TriggersDoctype
|
|
23
23
|
* @typedef {AccountsDoctype|TriggersDoctype|KonnectorsDoctype|NotesDoctype|AppsDoctype|SettingsDoctype|OAuthClientsDoctype|FilesDoctype} KnownDoctype
|
|
24
24
|
* @typedef {KnownDoctype|string} Doctype
|
|
25
25
|
*/
|
|
26
26
|
|
|
27
|
+
/**
|
|
28
|
+
* @typedef {object} AccountsDocument
|
|
29
|
+
* @property {String} [_id] - document identifier
|
|
30
|
+
* @property {String} account_type - slug of the associated konnector
|
|
31
|
+
* @property {object} auth - user credentials
|
|
32
|
+
* @property {String} [identifier] - Name of the attribute in the auth object that can be used to name the account.
|
|
33
|
+
* @property {Array} [mutedErrors] - list of ignored errors
|
|
34
|
+
* @property {String} [state] - used by harvest and the konnectors to communicate
|
|
35
|
+
* @typedef {CozyClientDocument & AccountsDocument} IOCozyAccount - An io.cozy.accounts document
|
|
36
|
+
*/
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* @typedef {object} KonnectorsDocument
|
|
40
|
+
* @property {String} slug - slug of konnector
|
|
41
|
+
* @property {ManifestFields} fields - konnector fields
|
|
42
|
+
* @property {Boolean} clientSide - whether the konnector runs on client or not
|
|
43
|
+
* @typedef {CozyClientDocument & KonnectorsDocument} IOCozyKonnector - An io.cozy.konnectors document
|
|
44
|
+
*/
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* @typedef {object} TriggersDocument
|
|
48
|
+
* @property {String} [_id] - document identifier
|
|
49
|
+
* @property {String} type - type of the trigger. Can be "at", "cron", "event", "every", "in", "webhook", "client"
|
|
50
|
+
* @property {String} worker - type of worker. Can be "konnector" or "sendmail"
|
|
51
|
+
* @property {object} message - Parameters to pass to the the worker. For example, when the worker is set to konnector, message contains the related konnector and the related account.
|
|
52
|
+
* @property {TriggerState} [current_state] - state of the last executed jobs related to this trigger
|
|
53
|
+
* @property {String} [arguments] - Arguments related to the type attribute. For example it's a cron configuration when the type is set to @cron.
|
|
54
|
+
* @typedef {CozyClientDocument & TriggersDocument} IOCozyTrigger - An io.cozy.konnectors document
|
|
55
|
+
*/
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* @typedef {object} TriggerState
|
|
59
|
+
* @property {'queued'|'running'|'done'|'errored'} status - Global status of the trigger
|
|
60
|
+
* @property {String} last_success - Date of the last job in success
|
|
61
|
+
* @property {String} last_successful_job_id - ID of the last job in success
|
|
62
|
+
* @property {String} last_execution - Date of the last executed job
|
|
63
|
+
* @property {String} last_executed_job_id - ID of the last executed job
|
|
64
|
+
* @property {String} last_failure - Date of the last job in failure
|
|
65
|
+
* @property {String} last_failed_job_id - ID of the last job in failure
|
|
66
|
+
* @property {String} last_manual_execution - Date of the last job manually executed
|
|
67
|
+
* @property {String} last_manual_job_id - ID of the last job manually executed
|
|
68
|
+
* @property {String} last_error - Content of the last error
|
|
69
|
+
*/
|
|
70
|
+
|
|
27
71
|
/**
|
|
28
72
|
* @typedef {object} Link
|
|
29
73
|
* @typedef {object} Mutation
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cozy-client",
|
|
3
|
-
"version": "35.
|
|
3
|
+
"version": "35.2.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"main": "dist/index.node.js",
|
|
6
6
|
"browser": "dist/index.js",
|
|
@@ -73,5 +73,5 @@
|
|
|
73
73
|
"react-native-ios11-devicecheck": "https://github.com/cozy/react-native-devicecheck#app-attest-v0.1"
|
|
74
74
|
},
|
|
75
75
|
"sideEffects": false,
|
|
76
|
-
"gitHead": "
|
|
76
|
+
"gitHead": "17eccb5506e6d7a34c7b4fdd4d2a15d3500f8d8e"
|
|
77
77
|
}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
export function getMutedErrors(account:
|
|
2
|
-
export function muteError(account:
|
|
3
|
-
export function getContractSyncStatusFromAccount(account:
|
|
4
|
-
export function setContractSyncStatusInAccount(account:
|
|
5
|
-
export
|
|
1
|
+
export function getMutedErrors(account: import('../types').IOCozyAccount): any[];
|
|
2
|
+
export function muteError(account: import('../types').IOCozyAccount, errorType: string): import('../types').IOCozyAccount;
|
|
3
|
+
export function getContractSyncStatusFromAccount(account: import('../types').IOCozyAccount, contractId: string): boolean;
|
|
4
|
+
export function setContractSyncStatusInAccount(account: import('../types').IOCozyAccount, contractId: string, syncStatus: string): import('../types').IOCozyAccount;
|
|
5
|
+
export function getAccountLogin(account: import('../types').IOCozyAccount): string | null;
|
|
6
|
+
export function getAccountName(account: import('../types').IOCozyAccount): string | null;
|
|
7
|
+
export function buildAccount(konnector: import('../types').IOCozyKonnector, authData: object): import('../types').IOCozyAccount;
|
|
@@ -1,14 +1,20 @@
|
|
|
1
1
|
export namespace triggerStates {
|
|
2
|
-
function getLastExecution(
|
|
3
|
-
function
|
|
4
|
-
function
|
|
5
|
-
function isErrored(
|
|
6
|
-
function getLastErrorType(
|
|
2
|
+
function getLastExecution(trigger: import("../types").IOCozyTrigger): string;
|
|
3
|
+
function getLastSuccess(trigger: import("../types").IOCozyTrigger): string;
|
|
4
|
+
function getLastsuccess(trigger: import("../types").IOCozyTrigger): string;
|
|
5
|
+
function isErrored(trigger: import("../types").IOCozyTrigger): boolean;
|
|
6
|
+
function getLastErrorType(trigger: import("../types").IOCozyTrigger): string;
|
|
7
7
|
}
|
|
8
8
|
export namespace triggers {
|
|
9
|
-
function isKonnectorWorker(trigger:
|
|
10
|
-
function getKonnector(trigger:
|
|
11
|
-
function getAccountId(trigger:
|
|
12
|
-
function isLatestErrorMuted(trigger:
|
|
13
|
-
function hasActionableError(trigger:
|
|
9
|
+
function isKonnectorWorker(trigger: import("../types").IOCozyTrigger): boolean;
|
|
10
|
+
function getKonnector(trigger: import("../types").IOCozyTrigger): string | void;
|
|
11
|
+
function getAccountId(trigger: import("../types").IOCozyTrigger): string;
|
|
12
|
+
function isLatestErrorMuted(trigger: import("../types").IOCozyTrigger, account: import("../types").IOCozyAccount): boolean;
|
|
13
|
+
function hasActionableError(trigger: import("../types").IOCozyTrigger): boolean;
|
|
14
|
+
function buildTriggerAttributes({ account, cron, folder, konnector }: {
|
|
15
|
+
konnector: import("../types").IOCozyKonnector;
|
|
16
|
+
account: import("../types").IOCozyAccount;
|
|
17
|
+
cron?: string;
|
|
18
|
+
folder?: any;
|
|
19
|
+
}): import("../types").IOCozyTrigger;
|
|
14
20
|
}
|
package/types/types.d.ts
CHANGED
|
@@ -1,16 +1,136 @@
|
|
|
1
1
|
declare var _default: {};
|
|
2
2
|
export default _default;
|
|
3
3
|
export type Qualification = import("./models/document/qualification").Qualification;
|
|
4
|
-
export type AccountsDoctype = "io.cozy.accounts";
|
|
5
|
-
export type TriggersDoctype = "io.cozy.triggers";
|
|
6
|
-
export type KonnectorsDoctype = "io.cozy.konnectors";
|
|
7
4
|
export type NotesDoctype = "io.cozy.notes";
|
|
8
5
|
export type AppsDoctype = "io.cozy.apps";
|
|
9
6
|
export type SettingsDoctype = "io.cozy.settings";
|
|
10
7
|
export type OAuthClientsDoctype = "io.cozy-oauth.clients";
|
|
11
8
|
export type FilesDoctype = "io.cozy.files";
|
|
12
|
-
export type
|
|
9
|
+
export type AccountsDoctype = "io.cozy.account";
|
|
10
|
+
export type KonnectorsDoctype = "io.cozy.konnectors";
|
|
11
|
+
export type TriggersDoctype = "io.cozy.triggers";
|
|
12
|
+
export type KnownDoctype = "io.cozy.files" | "io.cozy.account" | "io.cozy.triggers" | "io.cozy.konnectors" | "io.cozy.notes" | "io.cozy.apps" | "io.cozy.settings" | "io.cozy-oauth.clients";
|
|
13
13
|
export type Doctype = string;
|
|
14
|
+
export type AccountsDocument = {
|
|
15
|
+
/**
|
|
16
|
+
* - document identifier
|
|
17
|
+
*/
|
|
18
|
+
_id?: string;
|
|
19
|
+
/**
|
|
20
|
+
* - slug of the associated konnector
|
|
21
|
+
*/
|
|
22
|
+
account_type: string;
|
|
23
|
+
/**
|
|
24
|
+
* - user credentials
|
|
25
|
+
*/
|
|
26
|
+
auth: object;
|
|
27
|
+
/**
|
|
28
|
+
* - Name of the attribute in the auth object that can be used to name the account.
|
|
29
|
+
*/
|
|
30
|
+
identifier?: string;
|
|
31
|
+
/**
|
|
32
|
+
* - list of ignored errors
|
|
33
|
+
*/
|
|
34
|
+
mutedErrors?: any[];
|
|
35
|
+
/**
|
|
36
|
+
* - used by harvest and the konnectors to communicate
|
|
37
|
+
*/
|
|
38
|
+
state?: string;
|
|
39
|
+
};
|
|
40
|
+
/**
|
|
41
|
+
* - An io.cozy.accounts document
|
|
42
|
+
*/
|
|
43
|
+
export type IOCozyAccount = CozyClientDocument & AccountsDocument;
|
|
44
|
+
export type KonnectorsDocument = {
|
|
45
|
+
/**
|
|
46
|
+
* - slug of konnector
|
|
47
|
+
*/
|
|
48
|
+
slug: string;
|
|
49
|
+
/**
|
|
50
|
+
* - konnector fields
|
|
51
|
+
*/
|
|
52
|
+
fields: ManifestFields;
|
|
53
|
+
/**
|
|
54
|
+
* - whether the konnector runs on client or not
|
|
55
|
+
*/
|
|
56
|
+
clientSide: boolean;
|
|
57
|
+
};
|
|
58
|
+
/**
|
|
59
|
+
* - An io.cozy.konnectors document
|
|
60
|
+
*/
|
|
61
|
+
export type IOCozyKonnector = CozyClientDocument & KonnectorsDocument;
|
|
62
|
+
export type TriggersDocument = {
|
|
63
|
+
/**
|
|
64
|
+
* - document identifier
|
|
65
|
+
*/
|
|
66
|
+
_id?: string;
|
|
67
|
+
/**
|
|
68
|
+
* - type of the trigger. Can be "at", "cron", "event", "every", "in", "webhook", "client"
|
|
69
|
+
*/
|
|
70
|
+
type: string;
|
|
71
|
+
/**
|
|
72
|
+
* - type of worker. Can be "konnector" or "sendmail"
|
|
73
|
+
*/
|
|
74
|
+
worker: string;
|
|
75
|
+
/**
|
|
76
|
+
* - Parameters to pass to the the worker. For example, when the worker is set to konnector, message contains the related konnector and the related account.
|
|
77
|
+
*/
|
|
78
|
+
message: object;
|
|
79
|
+
/**
|
|
80
|
+
* - state of the last executed jobs related to this trigger
|
|
81
|
+
*/
|
|
82
|
+
current_state?: TriggerState;
|
|
83
|
+
/**
|
|
84
|
+
* - Arguments related to the type attribute. For example it's a cron configuration when the type is set to
|
|
85
|
+
*/
|
|
86
|
+
arguments?: string;
|
|
87
|
+
};
|
|
88
|
+
/**
|
|
89
|
+
* - An io.cozy.konnectors document
|
|
90
|
+
*/
|
|
91
|
+
export type IOCozyTrigger = CozyClientDocument & TriggersDocument;
|
|
92
|
+
export type TriggerState = {
|
|
93
|
+
/**
|
|
94
|
+
* - Global status of the trigger
|
|
95
|
+
*/
|
|
96
|
+
status: 'queued' | 'running' | 'done' | 'errored';
|
|
97
|
+
/**
|
|
98
|
+
* - Date of the last job in success
|
|
99
|
+
*/
|
|
100
|
+
last_success: string;
|
|
101
|
+
/**
|
|
102
|
+
* - ID of the last job in success
|
|
103
|
+
*/
|
|
104
|
+
last_successful_job_id: string;
|
|
105
|
+
/**
|
|
106
|
+
* - Date of the last executed job
|
|
107
|
+
*/
|
|
108
|
+
last_execution: string;
|
|
109
|
+
/**
|
|
110
|
+
* - ID of the last executed job
|
|
111
|
+
*/
|
|
112
|
+
last_executed_job_id: string;
|
|
113
|
+
/**
|
|
114
|
+
* - Date of the last job in failure
|
|
115
|
+
*/
|
|
116
|
+
last_failure: string;
|
|
117
|
+
/**
|
|
118
|
+
* - ID of the last job in failure
|
|
119
|
+
*/
|
|
120
|
+
last_failed_job_id: string;
|
|
121
|
+
/**
|
|
122
|
+
* - Date of the last job manually executed
|
|
123
|
+
*/
|
|
124
|
+
last_manual_execution: string;
|
|
125
|
+
/**
|
|
126
|
+
* - ID of the last job manually executed
|
|
127
|
+
*/
|
|
128
|
+
last_manual_job_id: string;
|
|
129
|
+
/**
|
|
130
|
+
* - Content of the last error
|
|
131
|
+
*/
|
|
132
|
+
last_error: string;
|
|
133
|
+
};
|
|
14
134
|
export type Link = any;
|
|
15
135
|
export type Mutation = any;
|
|
16
136
|
export type DocumentCollection = any;
|