@spinajs/fs
Advanced tools
Comparing version 2.0.219 to 2.0.220
@@ -0,2 +1,5 @@ | ||
import { AsyncService } from '@spinajs/di'; | ||
import { Bootstrapper } from '@spinajs/di'; | ||
import { IFsConfiguration } from './interfaces.js'; | ||
import { Log } from '@spinajs/log-common'; | ||
export * from './interfaces.js'; | ||
@@ -8,2 +11,7 @@ export * from './local-provider.js'; | ||
export * from './file-info.js'; | ||
export declare class fsService extends AsyncService { | ||
protected Logger: Log; | ||
protected Config: IFsConfiguration; | ||
resolve(): Promise<void>; | ||
} | ||
export declare class FsBootsrapper extends Bootstrapper { | ||
@@ -10,0 +18,0 @@ bootstrap(): void; |
@@ -22,4 +22,7 @@ "use strict"; | ||
}; | ||
var __metadata = (this && this.__metadata) || function (k, v) { | ||
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.FsBootsrapper = void 0; | ||
exports.FsBootsrapper = exports.fsService = void 0; | ||
const configuration_1 = require("@spinajs/configuration"); | ||
@@ -29,2 +32,3 @@ const di_1 = require("@spinajs/di"); | ||
const interfaces_js_1 = require("./interfaces.js"); | ||
const log_common_1 = require("@spinajs/log-common"); | ||
__exportStar(require("./interfaces.js"), exports); | ||
@@ -36,31 +40,39 @@ __exportStar(require("./local-provider.js"), exports); | ||
__exportStar(require("./file-info.js"), exports); | ||
class fsService extends di_1.AsyncService { | ||
async resolve() { | ||
if (this.Config.defaultProvider === undefined) { | ||
throw new configuration_1.InvalidConfiguration('fs default provider is not set. Please set default file provider '); | ||
} | ||
const providers = new Map(); | ||
// collapse provider config | ||
// when name is the same, addes last is created | ||
// eg fs-temp can have default config from package | ||
// but is overriden in application | ||
this.Config.providers.forEach((x) => { | ||
providers.set(x.name, x); | ||
}); | ||
const rProviders = di_2.DI.RootContainer.Registry.getTypes(interfaces_js_1.fs); | ||
const list = Array.from(providers, ([name, value]) => ({ name, value })); | ||
for (const cProvider of list) { | ||
const type = rProviders.find((x) => x.name === cProvider.value.service); | ||
if (!type) { | ||
throw new di_1.ResolveException(`Type ${cProvider.value.service} not registered, make sure all fs providers are registered`); | ||
} | ||
const fs = await di_2.DI.resolve(type, [cProvider.value]); | ||
di_2.DI.register(fs).asValue('__file_provider_instance_' + cProvider.value.name); | ||
this.Logger.info(`File provider ${cProvider.value.name} registered, type: ${cProvider.value.service}`); | ||
} | ||
} | ||
} | ||
exports.fsService = fsService; | ||
__decorate([ | ||
(0, log_common_1.Logger)('fs'), | ||
__metadata("design:type", log_common_1.Log) | ||
], fsService.prototype, "Logger", void 0); | ||
__decorate([ | ||
(0, configuration_1.Config)('fs'), | ||
__metadata("design:type", Object) | ||
], fsService.prototype, "Config", void 0); | ||
let FsBootsrapper = class FsBootsrapper extends di_2.Bootstrapper { | ||
bootstrap() { | ||
const listener = (container) => { | ||
const cfg = container.get(configuration_1.Configuration).get('fs'); | ||
const defaultProvider = cfg.defaultProvider; | ||
if (!defaultProvider) { | ||
throw new configuration_1.InvalidConfiguration('fs default provider is not set. Please set default file provider '); | ||
} | ||
const providers = new Map(); | ||
// collapse provider config | ||
// when name is the same, addes last is created | ||
// eg fs-temp can have default config from package | ||
// but is overriden in application | ||
cfg.providers.forEach((x) => { | ||
providers.set(x.name, x); | ||
}); | ||
const rProviders = di_2.DI.RootContainer.Registry.getTypes(interfaces_js_1.fs); | ||
const list = Array.from(providers, ([name, value]) => ({ name, value })); | ||
for (const cProvider of list) { | ||
const type = rProviders.find((x) => x.name === cProvider.value.service); | ||
if (!type) { | ||
throw new di_1.ResolveException(`Type ${cProvider.value.service} not registered, make sure all fs providers are registered`); | ||
} | ||
di_2.DI.resolve(type, [cProvider.value]).then((result) => { | ||
di_2.DI.register(result).asValue('__file_provider_instance_' + cProvider.value.name); | ||
}); | ||
} | ||
}; | ||
di_2.DI.once('di.resolved.Configuration', listener); | ||
di_2.DI.register((_container, name) => { | ||
@@ -67,0 +79,0 @@ const provider = di_2.DI.get('__file_provider_instance_' + name); |
@@ -0,2 +1,5 @@ | ||
import { AsyncService } from '@spinajs/di'; | ||
import { Bootstrapper } from '@spinajs/di'; | ||
import { IFsConfiguration } from './interfaces.js'; | ||
import { Log } from '@spinajs/log-common'; | ||
export * from './interfaces.js'; | ||
@@ -8,2 +11,7 @@ export * from './local-provider.js'; | ||
export * from './file-info.js'; | ||
export declare class fsService extends AsyncService { | ||
protected Logger: Log; | ||
protected Config: IFsConfiguration; | ||
resolve(): Promise<void>; | ||
} | ||
export declare class FsBootsrapper extends Bootstrapper { | ||
@@ -10,0 +18,0 @@ bootstrap(): void; |
@@ -7,6 +7,10 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { | ||
}; | ||
import { Configuration, InvalidConfiguration } from '@spinajs/configuration'; | ||
import { ResolveException } from '@spinajs/di'; | ||
var __metadata = (this && this.__metadata) || function (k, v) { | ||
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); | ||
}; | ||
import { Config, InvalidConfiguration } from '@spinajs/configuration'; | ||
import { AsyncService, ResolveException } from '@spinajs/di'; | ||
import { Injectable, Bootstrapper, DI } from '@spinajs/di'; | ||
import { fs } from './interfaces.js'; | ||
import { Log, Logger } from '@spinajs/log-common'; | ||
export * from './interfaces.js'; | ||
@@ -18,31 +22,38 @@ export * from './local-provider.js'; | ||
export * from './file-info.js'; | ||
export class fsService extends AsyncService { | ||
async resolve() { | ||
if (this.Config.defaultProvider === undefined) { | ||
throw new InvalidConfiguration('fs default provider is not set. Please set default file provider '); | ||
} | ||
const providers = new Map(); | ||
// collapse provider config | ||
// when name is the same, addes last is created | ||
// eg fs-temp can have default config from package | ||
// but is overriden in application | ||
this.Config.providers.forEach((x) => { | ||
providers.set(x.name, x); | ||
}); | ||
const rProviders = DI.RootContainer.Registry.getTypes(fs); | ||
const list = Array.from(providers, ([name, value]) => ({ name, value })); | ||
for (const cProvider of list) { | ||
const type = rProviders.find((x) => x.name === cProvider.value.service); | ||
if (!type) { | ||
throw new ResolveException(`Type ${cProvider.value.service} not registered, make sure all fs providers are registered`); | ||
} | ||
const fs = await DI.resolve(type, [cProvider.value]); | ||
DI.register(fs).asValue('__file_provider_instance_' + cProvider.value.name); | ||
this.Logger.info(`File provider ${cProvider.value.name} registered, type: ${cProvider.value.service}`); | ||
} | ||
} | ||
} | ||
__decorate([ | ||
Logger('fs'), | ||
__metadata("design:type", Log) | ||
], fsService.prototype, "Logger", void 0); | ||
__decorate([ | ||
Config('fs'), | ||
__metadata("design:type", Object) | ||
], fsService.prototype, "Config", void 0); | ||
let FsBootsrapper = class FsBootsrapper extends Bootstrapper { | ||
bootstrap() { | ||
const listener = (container) => { | ||
const cfg = container.get(Configuration).get('fs'); | ||
const defaultProvider = cfg.defaultProvider; | ||
if (!defaultProvider) { | ||
throw new InvalidConfiguration('fs default provider is not set. Please set default file provider '); | ||
} | ||
const providers = new Map(); | ||
// collapse provider config | ||
// when name is the same, addes last is created | ||
// eg fs-temp can have default config from package | ||
// but is overriden in application | ||
cfg.providers.forEach((x) => { | ||
providers.set(x.name, x); | ||
}); | ||
const rProviders = DI.RootContainer.Registry.getTypes(fs); | ||
const list = Array.from(providers, ([name, value]) => ({ name, value })); | ||
for (const cProvider of list) { | ||
const type = rProviders.find((x) => x.name === cProvider.value.service); | ||
if (!type) { | ||
throw new ResolveException(`Type ${cProvider.value.service} not registered, make sure all fs providers are registered`); | ||
} | ||
DI.resolve(type, [cProvider.value]).then((result) => { | ||
DI.register(result).asValue('__file_provider_instance_' + cProvider.value.name); | ||
}); | ||
} | ||
}; | ||
DI.once('di.resolved.Configuration', listener); | ||
DI.register((_container, name) => { | ||
@@ -49,0 +60,0 @@ const provider = DI.get('__file_provider_instance_' + name); |
{ | ||
"name": "@spinajs/fs", | ||
"version": "2.0.219", | ||
"version": "2.0.220", | ||
"description": "wrapper for file operations", | ||
@@ -55,5 +55,5 @@ "main": "lib/cjs/index.js", | ||
"dependencies": { | ||
"@spinajs/exceptions": "2.0.219", | ||
"@spinajs/util": "2.0.219", | ||
"@spinajs/log-common": "2.0.219", | ||
"@spinajs/exceptions": "2.0.220", | ||
"@spinajs/util": "2.0.220", | ||
"@spinajs/log-common": "2.0.220", | ||
"archiver": "^5.3.1", | ||
@@ -60,0 +60,0 @@ "lodash": "^4.17.21", |
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
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
289265
77
2194
+ Added@spinajs/exceptions@2.0.220(transitive)
+ Added@spinajs/log-common@2.0.220(transitive)
+ Added@spinajs/util@2.0.220(transitive)
- Removed@spinajs/exceptions@2.0.219(transitive)
- Removed@spinajs/log-common@2.0.219(transitive)
- Removed@spinajs/util@2.0.219(transitive)
Updated@spinajs/exceptions@2.0.220
Updated@spinajs/log-common@2.0.220
Updated@spinajs/util@2.0.220