Comparing version 1.0.1 to 1.0.2
/// <reference types="node" /> | ||
import Stream from 'node:stream'; | ||
import Pino, { Level } from 'pino'; | ||
import Pino from 'pino'; | ||
export declare abstract class SavimProviderInterface { | ||
@@ -13,5 +13,6 @@ name: string; | ||
export declare class Savim { | ||
log?: "fatal" | "error" | "warn" | "info" | "debug" | "trace" | undefined; | ||
providers: Record<string, SavimProviderInterface>; | ||
logger: Pino.BaseLogger; | ||
constructor(log?: Level); | ||
constructor(log?: "fatal" | "error" | "warn" | "info" | "debug" | "trace" | undefined); | ||
addProvider<T>(provider: new (...args: any[]) => SavimProviderInterface, config: T): Promise<void>; | ||
@@ -18,0 +19,0 @@ uploadFile(filenameWithPath: string, content: Buffer | string | Stream, params?: object, providerName?: string): Promise<unknown>; |
@@ -52,2 +52,3 @@ 'use strict'; | ||
this.log = log; | ||
this.providers = {}; | ||
@@ -54,0 +55,0 @@ |
@@ -1,2 +0,2 @@ | ||
"use strict";function r(r){return r&&"object"==typeof r&&"default"in r?r.default:r}Object.defineProperty(exports,"__esModule",{value:!0});var e=r(require("regenerator-runtime")),t=r(require("pino"));function n(r,e,t,n,i,o,u){try{var a=r[o](u),s=a.value}catch(r){return void t(r)}a.done?e(s):Promise.resolve(s).then(n,i)}function i(r){return function(){var e=this,t=arguments;return new Promise((function(i,o){var u=r.apply(e,t);function a(r){n(u,i,o,a,s,"next",r)}function s(r){n(u,i,o,a,s,"throw",r)}a(void 0)}))}}exports.Savim=function(){function r(r){var e=this;this.providers={},this.getInvolvedProvider=function(r){var t=Object.keys(e.providers),n=void 0;return r&&e.providers[r]?n=e.providers[r]:(null==t?void 0:t.length)>0&&(n=e.providers[t[0]]),n},this.logger=t({level:r||"info"})}var n=r.prototype;return n.addProvider=function(){var r=i(e.mark((function r(t,n){var i;return e.wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return i=new t(n),r.next=3,i.isHealthy();case 3:if(r.sent){r.next=6;break}return this.logger.error("[SAVIM] Provider "+i.name+" is not healthy !"),r.abrupt("return");case 6:this.providers[i.name]=i;case 7:case"end":return r.stop()}}),r,this)})));return function(e,t){return r.apply(this,arguments)}}(),n.uploadFile=function(){var r=i(e.mark((function r(t,n,i,o){var u;return e.wrap((function(r){for(;;)switch(r.prev=r.next){case 0:if(void 0===i&&(i={}),u=this.getInvolvedProvider(o),this.logger.debug("[SAVIM] Upload file "+(u?"(Provider: "+u.name+")":"(No provider)")+" "+(u?"(Provider: "+u.name+")":"(No provider)")+" "+t),this.logger.debug(i),!u){r.next=6;break}return r.abrupt("return",u.uploadFile(t,n,i));case 6:return r.abrupt("return",void 0);case 7:case"end":return r.stop()}}),r,this)})));return function(e,t,n,i){return r.apply(this,arguments)}}(),n.getFile=function(){var r=i(e.mark((function r(t,n,i){var o;return e.wrap((function(r){for(;;)switch(r.prev=r.next){case 0:if(void 0===n&&(n={}),o=this.getInvolvedProvider(i),this.logger.debug("[SAVIM] Get file "+(o?"(Provider: "+o.name+")":"(No provider)")+" "+(o?"(Provider: "+o.name+")":"(No provider)")+" "+t),this.logger.debug(n),!o){r.next=6;break}return r.abrupt("return",o.getFile(t,n));case 6:return r.abrupt("return",void 0);case 7:case"end":return r.stop()}}),r,this)})));return function(e,t,n){return r.apply(this,arguments)}}(),n.deleteFile=function(){var r=i(e.mark((function r(t,n,i){var o;return e.wrap((function(r){for(;;)switch(r.prev=r.next){case 0:if(void 0===n&&(n={}),o=this.getInvolvedProvider(i),this.logger.debug("[SAVIM] Delete file "+(o?"(Provider: "+o.name+")":"(No provider)")+" "+(o?"(Provider: "+o.name+")":"(No provider)")),this.logger.debug(n),!o){r.next=6;break}return r.abrupt("return",o.deleteFile(t,n));case 6:return r.abrupt("return",void 0);case 7:case"end":return r.stop()}}),r,this)})));return function(e,t,n){return r.apply(this,arguments)}}(),r}(),exports.SavimProviderInterface=function(r){}; | ||
"use strict";function r(r){return r&&"object"==typeof r&&"default"in r?r.default:r}Object.defineProperty(exports,"__esModule",{value:!0});var e=r(require("regenerator-runtime")),t=r(require("pino"));function n(r,e,t,n,i,o,u){try{var a=r[o](u),s=a.value}catch(r){return void t(r)}a.done?e(s):Promise.resolve(s).then(n,i)}function i(r){return function(){var e=this,t=arguments;return new Promise((function(i,o){var u=r.apply(e,t);function a(r){n(u,i,o,a,s,"next",r)}function s(r){n(u,i,o,a,s,"throw",r)}a(void 0)}))}}exports.Savim=function(){function r(r){var e=this;this.log=r,this.providers={},this.getInvolvedProvider=function(r){var t=Object.keys(e.providers),n=void 0;return r&&e.providers[r]?n=e.providers[r]:(null==t?void 0:t.length)>0&&(n=e.providers[t[0]]),n},this.logger=t({level:r||"info"})}var n=r.prototype;return n.addProvider=function(){var r=i(e.mark((function r(t,n){var i;return e.wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return i=new t(n),r.next=3,i.isHealthy();case 3:if(r.sent){r.next=6;break}return this.logger.error("[SAVIM] Provider "+i.name+" is not healthy !"),r.abrupt("return");case 6:this.providers[i.name]=i;case 7:case"end":return r.stop()}}),r,this)})));return function(e,t){return r.apply(this,arguments)}}(),n.uploadFile=function(){var r=i(e.mark((function r(t,n,i,o){var u;return e.wrap((function(r){for(;;)switch(r.prev=r.next){case 0:if(void 0===i&&(i={}),u=this.getInvolvedProvider(o),this.logger.debug("[SAVIM] Upload file "+(u?"(Provider: "+u.name+")":"(No provider)")+" "+(u?"(Provider: "+u.name+")":"(No provider)")+" "+t),this.logger.debug(i),!u){r.next=6;break}return r.abrupt("return",u.uploadFile(t,n,i));case 6:return r.abrupt("return",void 0);case 7:case"end":return r.stop()}}),r,this)})));return function(e,t,n,i){return r.apply(this,arguments)}}(),n.getFile=function(){var r=i(e.mark((function r(t,n,i){var o;return e.wrap((function(r){for(;;)switch(r.prev=r.next){case 0:if(void 0===n&&(n={}),o=this.getInvolvedProvider(i),this.logger.debug("[SAVIM] Get file "+(o?"(Provider: "+o.name+")":"(No provider)")+" "+(o?"(Provider: "+o.name+")":"(No provider)")+" "+t),this.logger.debug(n),!o){r.next=6;break}return r.abrupt("return",o.getFile(t,n));case 6:return r.abrupt("return",void 0);case 7:case"end":return r.stop()}}),r,this)})));return function(e,t,n){return r.apply(this,arguments)}}(),n.deleteFile=function(){var r=i(e.mark((function r(t,n,i){var o;return e.wrap((function(r){for(;;)switch(r.prev=r.next){case 0:if(void 0===n&&(n={}),o=this.getInvolvedProvider(i),this.logger.debug("[SAVIM] Delete file "+(o?"(Provider: "+o.name+")":"(No provider)")+" "+(o?"(Provider: "+o.name+")":"(No provider)")),this.logger.debug(n),!o){r.next=6;break}return r.abrupt("return",o.deleteFile(t,n));case 6:return r.abrupt("return",void 0);case 7:case"end":return r.stop()}}),r,this)})));return function(e,t,n){return r.apply(this,arguments)}}(),r}(),exports.SavimProviderInterface=function(r){}; | ||
//# sourceMappingURL=savim.cjs.production.min.js.map |
@@ -46,2 +46,3 @@ import _regeneratorRuntime from 'regenerator-runtime'; | ||
this.log = log; | ||
this.providers = {}; | ||
@@ -48,0 +49,0 @@ |
{ | ||
"version": "1.0.1", | ||
"version": "1.0.2", | ||
"license": "MIT", | ||
@@ -4,0 +4,0 @@ "main": "dist/index.js", |
@@ -30,3 +30,3 @@ /* eslint-disable @typescript-eslint/no-explicit-any */ | ||
constructor(log?: Level) { | ||
constructor(public log?: Level) { | ||
this.logger = Pino({ level: log || 'info' }); | ||
@@ -33,0 +33,0 @@ } |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
44862
522