From de523836e6acc54c29aa93c702b15221d671f80a Mon Sep 17 00:00:00 2001 From: GR Date: Wed, 3 Jul 2024 12:13:49 +0200 Subject: [PATCH] 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 --- src/lib/picker.ts | 12 ++++++- src/schema/picker.schema.ts | 62 ++++++++++++++++++++----------------- 2 files changed, 44 insertions(+), 30 deletions(-) diff --git a/src/lib/picker.ts b/src/lib/picker.ts index 1c2bd962..a0afd1bb 100644 --- a/src/lib/picker.ts +++ b/src/lib/picker.ts @@ -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); diff --git a/src/schema/picker.schema.ts b/src/schema/picker.schema.ts index 1eeb7daa..6b8355cc 100644 --- a/src/schema/picker.schema.ts +++ b/src/schema/picker.schema.ts @@ -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',