Skip to content

Commit 163a015

Browse files
RatGabisethk4783
authored andcommitted
Added back picasa as a potential source (#567)
* Added back picasa as a potential source * Invalid values in fromSources only trigger a warning if they are not valid instead of an error
1 parent 29a9a94 commit 163a015

File tree

2 files changed

+44
-30
lines changed

2 files changed

+44
-30
lines changed

src/lib/picker.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -787,7 +787,17 @@ class PickerLoader {
787787
const validateRes = getValidator(PickerParamsSchema)(options);
788788

789789
if (validateRes.errors.length) {
790-
throw new FilestackError(`Invalid picker params`, validateRes.errors, FilestackErrorType.VALIDATION);
790+
validateRes.errors.forEach(error => {
791+
if (error.path.includes('fromSources')) {
792+
console.warn(`Warning: Invalid source \"${error.instance}\" found and removed!`);
793+
options.fromSources = options.fromSources.filter(source => source !== error.instance);
794+
} else {
795+
throw new FilestackError(`Invalid picker params`, validateRes.errors, FilestackErrorType.VALIDATION);
796+
}
797+
});
798+
if (!options.fromSources.length) {
799+
delete options.fromSources;
800+
}
791801
}
792802

793803
this._initialized = this.loadModule(client, options);

src/schema/picker.schema.ts

Lines changed: 33 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -57,35 +57,39 @@ export const PickerParamsSchema = {
5757
},
5858
fromSources: {
5959
type: 'array',
60-
items: [
61-
{
62-
type: ['string', 'object'],
63-
additionalProperties: false,
64-
enum: [
65-
'local_file_system',
66-
'url',
67-
'imagesearch',
68-
'facebook',
69-
'instagram',
70-
'googledrive',
71-
'unsplash',
72-
'dropbox',
73-
'webcam',
74-
'video',
75-
'audio',
76-
'box',
77-
'github',
78-
'gmail',
79-
'googlephotos',
80-
'onedrive',
81-
'onedriveforbusiness',
82-
'clouddrive',
83-
'googlephotos',
84-
'customsource',
85-
'tint',
86-
],
87-
},
88-
],
60+
items: {
61+
anyOf: [
62+
{
63+
type: 'string',
64+
enum: [
65+
'local_file_system',
66+
'url',
67+
'imagesearch',
68+
'facebook',
69+
'instagram',
70+
'googledrive',
71+
'picasa',
72+
'unsplash',
73+
'dropbox',
74+
'webcam',
75+
'video',
76+
'audio',
77+
'box',
78+
'github',
79+
'gmail',
80+
'googlephotos',
81+
'onedrive',
82+
'onedriveforbusiness',
83+
'clouddrive',
84+
'customsource',
85+
'tint',
86+
],
87+
},
88+
{
89+
type: 'object',
90+
},
91+
],
92+
},
8993
},
9094
container: {
9195
format: 'HTMLContainer',

0 commit comments

Comments
 (0)