Skip to content

Commit

Permalink
Added back picasa as a potential source (#567)
Browse files Browse the repository at this point in the history
* Added back picasa as a potential source

* Invalid values in fromSources only trigger a warning if they are not valid instead of an error
  • Loading branch information
RatGabi authored and sethk4783 committed Sep 13, 2024
1 parent 29a9a94 commit 163a015
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 30 deletions.
12 changes: 11 additions & 1 deletion src/lib/picker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -787,7 +787,17 @@ class PickerLoader {
const validateRes = getValidator(PickerParamsSchema)(options);

if (validateRes.errors.length) {
throw new FilestackError(`Invalid picker params`, validateRes.errors, FilestackErrorType.VALIDATION);
validateRes.errors.forEach(error => {
if (error.path.includes('fromSources')) {
console.warn(`Warning: Invalid source \"${error.instance}\" found and removed!`);
options.fromSources = options.fromSources.filter(source => source !== error.instance);
} else {
throw new FilestackError(`Invalid picker params`, validateRes.errors, FilestackErrorType.VALIDATION);
}
});
if (!options.fromSources.length) {
delete options.fromSources;
}
}

this._initialized = this.loadModule(client, options);
Expand Down
62 changes: 33 additions & 29 deletions src/schema/picker.schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,35 +57,39 @@ export const PickerParamsSchema = {
},
fromSources: {
type: 'array',
items: [
{
type: ['string', 'object'],
additionalProperties: false,
enum: [
'local_file_system',
'url',
'imagesearch',
'facebook',
'instagram',
'googledrive',
'unsplash',
'dropbox',
'webcam',
'video',
'audio',
'box',
'github',
'gmail',
'googlephotos',
'onedrive',
'onedriveforbusiness',
'clouddrive',
'googlephotos',
'customsource',
'tint',
],
},
],
items: {
anyOf: [
{
type: 'string',
enum: [
'local_file_system',
'url',
'imagesearch',
'facebook',
'instagram',
'googledrive',
'picasa',
'unsplash',
'dropbox',
'webcam',
'video',
'audio',
'box',
'github',
'gmail',
'googlephotos',
'onedrive',
'onedriveforbusiness',
'clouddrive',
'customsource',
'tint',
],
},
{
type: 'object',
},
],
},
},
container: {
format: 'HTMLContainer',
Expand Down

0 comments on commit 163a015

Please sign in to comment.