cozy-client 34.11.1 → 35.1.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/index.js +1 -1
- package/dist/index.node.js +1 -1
- package/dist/models/account.js +91 -15
- package/dist/models/account.spec.js +82 -1
- package/dist/models/manifest.js +239 -0
- package/dist/models/manifest.spec.js +446 -0
- package/dist/models/trigger.js +120 -27
- package/dist/models/trigger.spec.js +67 -0
- package/dist/types.js +63 -3
- package/package.json +3 -3
- package/types/index.d.ts +1 -1
- package/types/index.node.d.ts +1 -1
- package/types/models/account.d.ts +7 -5
- package/types/models/manifest.d.ts +23 -0
- package/types/models/trigger.d.ts +16 -10
- package/types/types.d.ts +150 -4
- package/dist/manifest.js +0 -83
- package/dist/manifest.spec.js +0 -135
- package/types/manifest.d.ts +0 -12
|
@@ -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
|
|
@@ -34,6 +78,22 @@ var _dsl = require("./queries/dsl");
|
|
|
34
78
|
* @typedef {object} Token
|
|
35
79
|
* @typedef {object} ClientResponse
|
|
36
80
|
* @typedef {object} Manifest
|
|
81
|
+
* @typedef {object} SanitizedManifest
|
|
82
|
+
*/
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* @typedef {Object} ManifestField
|
|
86
|
+
* @property {String} [type] - field type : can be "text" or "hidden" or "date" or "dropdown" or "password"
|
|
87
|
+
* @property {String} [role] - field role : with "identifier" value
|
|
88
|
+
* @property {Boolean} [required] - is the field required or not
|
|
89
|
+
* @property {Boolean} [isRequired] - is the field required or not (legacy)
|
|
90
|
+
* @property {Boolean} [encrypted] - encrypted value of the field (legacy)
|
|
91
|
+
*/
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* @typedef {{
|
|
95
|
+
* [key: string]: ManifestField;
|
|
96
|
+
* }} ManifestFields
|
|
37
97
|
*/
|
|
38
98
|
|
|
39
99
|
/**
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cozy-client",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "35.1.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": "^
|
|
21
|
+
"cozy-stack-client": "^35.0.0",
|
|
22
22
|
"date-fns": "2.29.3",
|
|
23
23
|
"json-stable-stringify": "^1.0.1",
|
|
24
24
|
"lodash": "^4.17.13",
|
|
@@ -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": "13f6b8880b6b9bdc31e541682bb4c767b4c0224b"
|
|
77
77
|
}
|
package/types/index.d.ts
CHANGED
|
@@ -13,7 +13,7 @@ export { default as fetchPolicies } from "./policies";
|
|
|
13
13
|
export * from "./mock";
|
|
14
14
|
export * from "./hooks";
|
|
15
15
|
export { BulkEditError } from "./errors";
|
|
16
|
-
import * as manifest from "./manifest";
|
|
16
|
+
import * as manifest from "./models/manifest";
|
|
17
17
|
import * as models from "./models";
|
|
18
18
|
export { manifest, models };
|
|
19
19
|
export { QueryDefinition, Q, Mutations, MutationTypes, getDoctypeFromOperation } from "./queries/dsl";
|
package/types/index.node.d.ts
CHANGED
|
@@ -9,7 +9,7 @@ export * from "./mock";
|
|
|
9
9
|
export * from "./cli";
|
|
10
10
|
export { BulkEditError } from "./errors";
|
|
11
11
|
export { default as fetchPolicies } from "./policies";
|
|
12
|
-
import * as manifest from "./manifest";
|
|
12
|
+
import * as manifest from "./models/manifest";
|
|
13
13
|
import * as models from "./models";
|
|
14
14
|
export { manifest, models };
|
|
15
15
|
export { QueryDefinition, Mutations, MutationTypes, getDoctypeFromOperation, Q } from "./queries/dsl";
|
|
@@ -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;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Filters unauthorized categories. Defaults to ['others'] if no suitable category.
|
|
3
|
+
*
|
|
4
|
+
* @param {Array<Object>} categories - Array of categories
|
|
5
|
+
* @returns {Array<Object>} sanitized categories
|
|
6
|
+
*/
|
|
7
|
+
export function sanitizeCategories(categories: Array<any>): Array<any>;
|
|
8
|
+
export function areTermsValid(terms: any): boolean;
|
|
9
|
+
export function isPartnershipValid(partnership: any): boolean;
|
|
10
|
+
/**
|
|
11
|
+
* Normalize app manifest, retro-compatibility for old manifests
|
|
12
|
+
*
|
|
13
|
+
* @param {import('../types').Manifest} manifest - app manifest to normalize
|
|
14
|
+
* @returns {import('../types').SanitizedManifest}
|
|
15
|
+
*/
|
|
16
|
+
export function sanitize(manifest: import('../types').Manifest): import('../types').SanitizedManifest;
|
|
17
|
+
export const ROLE_IDENTIFIER: "identifier";
|
|
18
|
+
/**
|
|
19
|
+
* Legacy login fields declared by some konnectors
|
|
20
|
+
*/
|
|
21
|
+
export const legacyLoginFields: string[];
|
|
22
|
+
export function sanitizeIdentifier(fields: import('../types').ManifestFields): import('../types').ManifestFields;
|
|
23
|
+
export function getIdentifier(fields?: import('../types').ManifestFields): string | null;
|
|
@@ -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;
|
|
@@ -20,6 +140,32 @@ export type ReduxStore = any;
|
|
|
20
140
|
export type Token = any;
|
|
21
141
|
export type ClientResponse = any;
|
|
22
142
|
export type Manifest = any;
|
|
143
|
+
export type SanitizedManifest = any;
|
|
144
|
+
export type ManifestField = {
|
|
145
|
+
/**
|
|
146
|
+
* - field type : can be "text" or "hidden" or "date" or "dropdown" or "password"
|
|
147
|
+
*/
|
|
148
|
+
type?: string;
|
|
149
|
+
/**
|
|
150
|
+
* - field role : with "identifier" value
|
|
151
|
+
*/
|
|
152
|
+
role?: string;
|
|
153
|
+
/**
|
|
154
|
+
* - is the field required or not
|
|
155
|
+
*/
|
|
156
|
+
required?: boolean;
|
|
157
|
+
/**
|
|
158
|
+
* - is the field required or not (legacy)
|
|
159
|
+
*/
|
|
160
|
+
isRequired?: boolean;
|
|
161
|
+
/**
|
|
162
|
+
* - encrypted value of the field (legacy)
|
|
163
|
+
*/
|
|
164
|
+
encrypted?: boolean;
|
|
165
|
+
};
|
|
166
|
+
export type ManifestFields = {
|
|
167
|
+
[key: string]: ManifestField;
|
|
168
|
+
};
|
|
23
169
|
export type OldCozyClient = any;
|
|
24
170
|
export type NodeEnvironment = any;
|
|
25
171
|
export type QueryFetchStatus = "failed" | "loading" | "pending" | "loaded";
|
package/dist/manifest.js
DELETED
|
@@ -1,83 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
|
-
Object.defineProperty(exports, "__esModule", {
|
|
6
|
-
value: true
|
|
7
|
-
});
|
|
8
|
-
exports.sanitizeCategories = sanitizeCategories;
|
|
9
|
-
exports.areTermsValid = areTermsValid;
|
|
10
|
-
exports.isPartnershipValid = isPartnershipValid;
|
|
11
|
-
exports.sanitize = sanitize;
|
|
12
|
-
|
|
13
|
-
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
14
|
-
|
|
15
|
-
var _types = require("./types");
|
|
16
|
-
|
|
17
|
-
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; }
|
|
18
|
-
|
|
19
|
-
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; }
|
|
20
|
-
|
|
21
|
-
var APP_CATEGORIES = ['banking', 'cozy', 'energy', 'health', 'host_provider', 'insurance', 'isp', 'mes_infos', 'online_services', 'others', 'partners', 'press', 'productivity', 'ptnb', 'public_service', 'shopping', 'social', 'telecom', 'transport'];
|
|
22
|
-
/** Filters unauthorized categories. Defaults to ['others'] if no suitable category. */
|
|
23
|
-
|
|
24
|
-
function sanitizeCategories(categories) {
|
|
25
|
-
if (!categories) return ['others'];
|
|
26
|
-
var filteredList = categories.filter(function (c) {
|
|
27
|
-
return APP_CATEGORIES.includes(c);
|
|
28
|
-
});
|
|
29
|
-
if (!filteredList.length) return ['others'];
|
|
30
|
-
return filteredList;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
function areTermsValid(terms) {
|
|
34
|
-
return Boolean(terms && terms.id && terms.url && terms.version);
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
function isPartnershipValid(partnership) {
|
|
38
|
-
return Boolean(partnership && partnership.description);
|
|
39
|
-
}
|
|
40
|
-
/**
|
|
41
|
-
* Normalize app manifest, retro-compatibility for old manifests
|
|
42
|
-
*
|
|
43
|
-
* @param {Manifest} manifest - app manifest to normalize
|
|
44
|
-
* @returns {Manifest}
|
|
45
|
-
*/
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
function sanitize(manifest) {
|
|
49
|
-
var sanitized = _objectSpread({}, manifest); // Make categories an array and delete category attribute if it exists
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
if (!manifest.categories && manifest.category && typeof manifest.category === 'string') {
|
|
53
|
-
sanitized.categories = [manifest.category];
|
|
54
|
-
delete sanitized.category;
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
sanitized.categories = sanitizeCategories(sanitized.categories); // manifest name is not an object
|
|
58
|
-
|
|
59
|
-
if (typeof manifest.name === 'object') sanitized.name = manifest.name.en; // Fix camelCase from cozy-stack
|
|
60
|
-
|
|
61
|
-
if (manifest.available_version) {
|
|
62
|
-
sanitized.availableVersion = manifest.available_version;
|
|
63
|
-
delete sanitized.available_version;
|
|
64
|
-
} // Fix camelCase from cozy-stack
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
if (manifest.latest_version) {
|
|
68
|
-
sanitized.latestVersion = manifest.latestVersion;
|
|
69
|
-
delete sanitized.latest_version;
|
|
70
|
-
} // Remove invalid terms
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
if (sanitized.terms && !areTermsValid(sanitized.terms)) {
|
|
74
|
-
delete sanitized.terms;
|
|
75
|
-
} // Remove invalid partnership
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
if (sanitized.partnership && !isPartnershipValid(sanitized.partnership)) {
|
|
79
|
-
delete sanitized.partnership;
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
return sanitized;
|
|
83
|
-
}
|
package/dist/manifest.spec.js
DELETED
|
@@ -1,135 +0,0 @@
|
|
|
1
|
-
import { sanitizeCategories, sanitize as sanitizeManifest } from './manifest'
|
|
2
|
-
|
|
3
|
-
describe('sanitizeCategories', () => {
|
|
4
|
-
it('should return the list of the provided expected categories correctly', () => {
|
|
5
|
-
// all of these categories is authorized by config/categories.json
|
|
6
|
-
// so it won't be filtered
|
|
7
|
-
const categories = [
|
|
8
|
-
'cozy',
|
|
9
|
-
'isp',
|
|
10
|
-
'partners',
|
|
11
|
-
'press',
|
|
12
|
-
'shopping',
|
|
13
|
-
'telecom'
|
|
14
|
-
]
|
|
15
|
-
expect(sanitizeCategories(categories)).toEqual(categories)
|
|
16
|
-
})
|
|
17
|
-
it('should filter unwanted categories', () => {
|
|
18
|
-
// pressingggg is not allowed as category
|
|
19
|
-
const categories = [
|
|
20
|
-
'cozy',
|
|
21
|
-
'isp',
|
|
22
|
-
'partners',
|
|
23
|
-
'pressingggg',
|
|
24
|
-
'shopping',
|
|
25
|
-
'telecom'
|
|
26
|
-
]
|
|
27
|
-
expect(sanitizeCategories(categories)).toEqual(
|
|
28
|
-
categories.filter(c => c !== 'pressingggg')
|
|
29
|
-
)
|
|
30
|
-
})
|
|
31
|
-
it('should return "others" as category if no categories provided', () => {
|
|
32
|
-
expect(sanitizeCategories([])).toEqual(['others'])
|
|
33
|
-
expect(sanitizeCategories(null)).toEqual(['others'])
|
|
34
|
-
})
|
|
35
|
-
it('should return "others" as category if categories after filtering is empty', () => {
|
|
36
|
-
// pressingggg is not allowed as category
|
|
37
|
-
expect(sanitizeCategories(['pressingggg'])).toEqual(['others'])
|
|
38
|
-
})
|
|
39
|
-
})
|
|
40
|
-
|
|
41
|
-
describe('sanitizeManifest', () => {
|
|
42
|
-
const baseMan = { slug: 'mock' }
|
|
43
|
-
|
|
44
|
-
it('should handle legacy category property', () => {
|
|
45
|
-
const testCategory = 'cozy'
|
|
46
|
-
expect(
|
|
47
|
-
sanitizeManifest({ slug: 'mock', category: testCategory })
|
|
48
|
-
).toStrictEqual({
|
|
49
|
-
slug: 'mock',
|
|
50
|
-
categories: [testCategory]
|
|
51
|
-
})
|
|
52
|
-
})
|
|
53
|
-
it('should handle legacy name property locales ("en" only)', () => {
|
|
54
|
-
const testName = 'Mock'
|
|
55
|
-
expect(
|
|
56
|
-
sanitizeManifest({
|
|
57
|
-
slug: 'mock',
|
|
58
|
-
name: {
|
|
59
|
-
en: testName
|
|
60
|
-
}
|
|
61
|
-
})
|
|
62
|
-
).toEqual(
|
|
63
|
-
expect.objectContaining({
|
|
64
|
-
slug: 'mock',
|
|
65
|
-
name: testName
|
|
66
|
-
})
|
|
67
|
-
)
|
|
68
|
-
})
|
|
69
|
-
|
|
70
|
-
it('should transform available_version property to availableVersion', () => {
|
|
71
|
-
const testVersion = '3.0.0'
|
|
72
|
-
const man = sanitizeManifest({
|
|
73
|
-
slug: 'mock',
|
|
74
|
-
available_version: testVersion
|
|
75
|
-
})
|
|
76
|
-
expect(man.availableVersion).toBe('3.0.0')
|
|
77
|
-
expect(man).not.toHaveProperty('available_version')
|
|
78
|
-
})
|
|
79
|
-
|
|
80
|
-
describe('terms', () => {
|
|
81
|
-
it('should remove incomplete terms', () => {
|
|
82
|
-
const incompleteTerms = {
|
|
83
|
-
id: 'mock-terms'
|
|
84
|
-
}
|
|
85
|
-
expect(
|
|
86
|
-
sanitizeManifest({ ...baseMan, terms: incompleteTerms })
|
|
87
|
-
).not.toHaveProperty('terms')
|
|
88
|
-
expect(sanitizeManifest({ ...baseMan, terms: {} })).not.toHaveProperty(
|
|
89
|
-
'terms'
|
|
90
|
-
)
|
|
91
|
-
})
|
|
92
|
-
|
|
93
|
-
it('should keep complete terms', () => {
|
|
94
|
-
const completeTerms = {
|
|
95
|
-
id: 'mock-terms',
|
|
96
|
-
url: 'mock://terms',
|
|
97
|
-
version: 'mock001'
|
|
98
|
-
}
|
|
99
|
-
const man = { ...baseMan, terms: completeTerms }
|
|
100
|
-
|
|
101
|
-
expect(sanitizeManifest(man)).toEqual(expect.objectContaining(man))
|
|
102
|
-
})
|
|
103
|
-
})
|
|
104
|
-
|
|
105
|
-
describe('partnership', () => {
|
|
106
|
-
it('should remove incomplete', () => {
|
|
107
|
-
const incompletePartnership = {
|
|
108
|
-
icon: 'icon.svg' // icon is optional
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
expect(
|
|
112
|
-
sanitizeManifest({
|
|
113
|
-
...baseMan,
|
|
114
|
-
partnership: {}
|
|
115
|
-
})
|
|
116
|
-
).not.toHaveProperty('partnership')
|
|
117
|
-
|
|
118
|
-
expect(
|
|
119
|
-
sanitizeManifest({
|
|
120
|
-
...baseMan,
|
|
121
|
-
partnership: incompletePartnership
|
|
122
|
-
})
|
|
123
|
-
).not.toHaveProperty('partnership')
|
|
124
|
-
})
|
|
125
|
-
|
|
126
|
-
it('should keep complete', () => {
|
|
127
|
-
const completePartnership = {
|
|
128
|
-
description: 'A partnership text here' // description is mandatory
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
const man = { ...baseMan, partnership: completePartnership }
|
|
132
|
-
expect(sanitizeManifest(man)).toEqual(expect.objectContaining(man))
|
|
133
|
-
})
|
|
134
|
-
})
|
|
135
|
-
})
|
package/types/manifest.d.ts
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
/** Filters unauthorized categories. Defaults to ['others'] if no suitable category. */
|
|
2
|
-
export function sanitizeCategories(categories: any): any;
|
|
3
|
-
export function areTermsValid(terms: any): boolean;
|
|
4
|
-
export function isPartnershipValid(partnership: any): boolean;
|
|
5
|
-
/**
|
|
6
|
-
* Normalize app manifest, retro-compatibility for old manifests
|
|
7
|
-
*
|
|
8
|
-
* @param {Manifest} manifest - app manifest to normalize
|
|
9
|
-
* @returns {Manifest}
|
|
10
|
-
*/
|
|
11
|
-
export function sanitize(manifest: Manifest): Manifest;
|
|
12
|
-
import { Manifest } from "./types";
|