Skip to content

Commit

Permalink
fix: angular 9 compile issues
Browse files Browse the repository at this point in the history
  • Loading branch information
KutsenkoA committed May 20, 2020
1 parent ba504f0 commit 2c6c2f3
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 7 deletions.
5 changes: 3 additions & 2 deletions package.json
Expand Up @@ -4,13 +4,14 @@
"description": "Jexia Javascript SDK",
"main": "index.js",
"module": "./_esm5/index.js",
"es2015": "./_esm2015/index.js",
"es2015": "./_es2015/index.js",
"typings": "index.d.ts",
"sideEffects": false,
"scripts": {
"cleanup": "run-p cleanup:*",
"cleanup:dist": "shx rm -rf dist",
"cleanup:docs": "shx rm -rf docs",
"cleanup:docs": "shx rm -rf docs .temp",
"cleanup:tests": "shx rm -rf coverage test-results junit.xml",
"cross-env": "cross-env",
"commit": "git-cz",
"lint": "tslint \"src/**/*.ts\" \"spec/**/*.ts\" \"e2e/**/*.ts\"",
Expand Down
22 changes: 18 additions & 4 deletions src/api/core/client.ts
Expand Up @@ -15,6 +15,20 @@ export const ClientInit = new InjectionToken<Promise<Client>>("SystemInit");
*/
export const ClientConfiguration = new InjectionToken("ClientConfiguration");

export function CollectConfigurationFactory(modules: IModule[]) {
// tslint:disable-next-line:only-arrow-functions
return function() {
return Client.collectConfiguration(modules);
}
}

export function RequestAdapterFactory(fetch: Fetch) {
// tslint:disable-next-line:only-arrow-functions
return function() {
return new RequestAdapter(fetch);
}
}

/**
* Jexia main client fo the JavaScript SDK, used to initialize the necessary modules with your project information.
* This object must be build from the helper functions, never to be instantiated directly.
Expand All @@ -29,7 +43,7 @@ export const ClientConfiguration = new InjectionToken("ClientConfiguration");
export class Client {
/* token manager (responsible for getting fresh and valid token), should be injected to plugins/modules (if needed) */
private tokenManager: TokenManager;
/* modules to be initilized */
/* modules to be initialized */
private modules: IModule[];

/**
Expand All @@ -54,15 +68,15 @@ export class Client {
},
{
provide: ClientConfiguration,
useFactory: () => this.collectConfiguration(modules),
useFactory: CollectConfigurationFactory(modules),
},
{
provide: AuthOptions,
useValue: opts,
},
{
provide: RequestAdapter,
useFactory: () => new RequestAdapter(this.fetch),
useFactory: RequestAdapterFactory(this.fetch),
},
Logger,
TokenManager,
Expand Down Expand Up @@ -115,7 +129,7 @@ export class Client {
* Collect all module configurations into one configuration object
* @param modules
*/
private collectConfiguration(modules: IModule[]): { [moduleName: string]: ModuleConfiguration } {
static collectConfiguration(modules: IModule[]): { [moduleName: string]: ModuleConfiguration } {
return Object.assign({}, ...modules.map((module) => module.getConfig()));
}

Expand Down
12 changes: 11 additions & 1 deletion src/api/dataops/dataOperationsModule.ts
Expand Up @@ -5,6 +5,16 @@ import { AuthOptions } from "../core/tokenManager";
import { DataSetName } from "./dataops.tokens";
import { Dataset } from "./dataset";

/**
* @internal
*/
function datasetNameErrorFactory() {
// tslint:disable-next-line:only-arrow-functions
return function() {
throw new Error("Datasets requires valid names, please assure you provide a string value. \\ne.g. dataOperations.dataset('authors')");
}
}

/**
* Data Operation Module used to retrieve the dataset objects.
* This object must be build from the helper functions, never to be instantiated directly.
Expand All @@ -30,7 +40,7 @@ export class DataOperationsModule implements IModule {
this.injector = coreInjector.resolveAndCreateChild([
{
provide: DataSetName,
useFactory: () => { throw new Error("Please set the dataset name at the DI"); },
useFactory: datasetNameErrorFactory(),
},
RequestExecuter,
Dataset,
Expand Down

0 comments on commit 2c6c2f3

Please sign in to comment.