Skip to content

Commit

Permalink
Bump SDK to 0.6.0
Browse files Browse the repository at this point in the history
  • Loading branch information
marcospassos committed May 26, 2021
1 parent 16498a4 commit 6f5c393
Show file tree
Hide file tree
Showing 15 changed files with 7,098 additions and 8,225 deletions.
3 changes: 2 additions & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,8 @@
"default-case": "off",
"import/extensions": ["error", "never"],
"import/no-unresolved": "off",
"import/prefer-default-export": "off",
"import/no-default-export": ["error"],
"import/no-internal-modules": ["off", {"allow": []}],
"indent": ["error", 4, {"SwitchCase": 1}],
"linebreak-style": ["error", "unix"],
"max-classes-per-file": "off",
Expand Down
15,207 changes: 7,044 additions & 8,163 deletions package-lock.json

Large diffs are not rendered by default.

43 changes: 21 additions & 22 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
"javascript",
"typescript"
],
"main": "index.js",
"types": "index.d.ts",
"main": "./index.js",
"types": "./index.d.ts",
"repository": {
"type": "git",
"url": "git+https://github.com/croct-tech/plug-js.git"
Expand All @@ -30,35 +30,34 @@
"test": "jest -c jest.config.js --coverage",
"validate": "tsc --noEmit",
"build": "tsc",
"bundle": "rollup -c rollup.config.js"
"bundle": "rollup -c"
},
"dependencies": {
"@croct/sdk": "^0.5.1",
"tslib": "^2.0.3"
"@croct/sdk": "^0.6.0",
"tslib": "^2.2.0"
},
"devDependencies": {
"@babel/core": "^7.12.10",
"@babel/preset-env": "^7.12.11",
"@babel/preset-typescript": "^7.12.7",
"@rollup/plugin-commonjs": "^17.0.0",
"@rollup/plugin-node-resolve": "^11.0.1",
"@rollup/plugin-replace": "^2.3.4",
"@rollup/plugin-typescript": "^8.1.0",
"@types/jest": "^26.0.19",
"@typescript-eslint/eslint-plugin": "^2.34.0",
"@typescript-eslint/parser": "^2.34.0",
"@babel/core": "^7.14.3",
"@babel/preset-env": "^7.14.2",
"@babel/preset-typescript": "^7.13.0",
"@rollup/plugin-commonjs": "^19.0.0",
"@rollup/plugin-node-resolve": "^13.0.0",
"@rollup/plugin-replace": "^2.4.2",
"@rollup/plugin-typescript": "^8.2.1",
"@types/jest": "^26.0.23",
"@typescript-eslint/eslint-plugin": "^4.24.0",
"@typescript-eslint/parser": "^4.24.0",
"babel-jest": "^26.6.3",
"eslint": "^7.17.0",
"eslint": "^7.27.0",
"eslint-config-airbnb-base": "^14.2.1",
"eslint-plugin-import": "^2.22.1",
"eslint-plugin-jest": "^24.1.3",
"eslint-plugin-import": "^2.23.3",
"eslint-plugin-jest": "^24.3.6",
"jest": "^26.6.3",
"rollup": "^2.35.1",
"rollup": "^2.48.0",
"rollup-plugin-terser": "^7.0.2",
"rollup-plugin-typescript2": "^0.29.0",
"temp-dir": "^2.0.0",
"ts-jest": "^26.4.4",
"typescript": "^3.9.7"
"ts-jest": "^26.5.6",
"typescript": "^4.2.4"
},
"browserslist": [
"last 1 version"
Expand Down
2 changes: 2 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import {Configuration, Plug, GlobalPlug} from './plug';

export {Configuration, Plug};

/* eslint-disable-next-line import/no-default-export */
export default new GlobalPlug();
6 changes: 3 additions & 3 deletions src/playground.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {formatCause} from '@croct/sdk/error';
import CidAssigner from '@croct/sdk/cid';
import {CidAssigner} from '@croct/sdk/cid';
import {ContextFactory, TabContextFactory} from '@croct/sdk/facade/evaluatorFacade';
import {Campaign, EvaluationContext, Page} from '@croct/sdk/evaluator';
import {Plugin, PluginFactory} from './plugin';
Expand Down Expand Up @@ -76,7 +76,7 @@ export class PlaygroundPlugin implements Plugin {

private readonly logger: Logger;

private syncListener: {(): void};
private syncListener?: {(): void};

public constructor(configuration: Configuration) {
this.sdkVersion = configuration.sdkVersion;
Expand Down Expand Up @@ -147,7 +147,7 @@ export class PlaygroundPlugin implements Plugin {
}

public disable(): Promise<void> | void {
if (this.syncListener !== null) {
if (this.syncListener !== undefined) {
this.eventSubscriber.removeListener('tokenChanged', this.syncListener);
this.tab.removeListener('urlChange', this.syncListener);

Expand Down
18 changes: 9 additions & 9 deletions src/plug.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import {Logger} from '@croct/sdk/logging';
import SessionFacade from '@croct/sdk/facade/sessionFacade';
import UserFacade from '@croct/sdk/facade/userFacade';
import TrackerFacade from '@croct/sdk/facade/trackerFacade';
import EvaluatorFacade, {EvaluationOptions} from '@croct/sdk/facade/evaluatorFacade';
import Sdk, {Configuration as SdkFacadeConfiguration} from '@croct/sdk/facade/sdkFacade';
import {SessionFacade} from '@croct/sdk/facade/sessionFacade';
import {UserFacade} from '@croct/sdk/facade/userFacade';
import {TrackerFacade} from '@croct/sdk/facade/trackerFacade';
import {EvaluatorFacade, EvaluationOptions} from '@croct/sdk/facade/evaluatorFacade';
import {SdkFacade, Configuration as SdkFacadeConfiguration} from '@croct/sdk/facade/sdkFacade';
import {formatCause} from '@croct/sdk/error';
import {describe} from '@croct/sdk/validation';
import {Optional} from '@croct/sdk/utilityTypes';
import Token from '@croct/sdk/token';
import {Token} from '@croct/sdk/token';
import {
ExternalTrackingEvent as ExternalEvent,
ExternalTrackingEventPayload as ExternalEventPayload,
Expand Down Expand Up @@ -72,7 +72,7 @@ function detectAppId(): string | null {
export class GlobalPlug implements Plug {
private pluginFactories: {[key: string]: PluginFactory} = {playground: playgroundPluginFactory};

private instance?: Sdk;
private instance?: SdkFacade;

private plugins: {[key: string]: Plugin} = {};

Expand Down Expand Up @@ -125,7 +125,7 @@ export class GlobalPlug implements Plug {

const {plugins, ...sdkConfiguration} = configuration;

const sdk = Sdk.init({
const sdk = SdkFacade.init({
...sdkConfiguration,
appId: appId,
});
Expand Down Expand Up @@ -251,7 +251,7 @@ export class GlobalPlug implements Plug {
return this.tracker.flushed.then(() => this);
}

private get sdk(): Sdk {
private get sdk(): SdkFacade {
if (this.instance === undefined) {
throw new Error('Croct is not plugged in.');
}
Expand Down
8 changes: 4 additions & 4 deletions src/plugin.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import {TokenStore} from './sdk/token';
import {Evaluator} from './sdk/evaluation';
import {Tracker} from './sdk/tracking';
import {EvaluatorFacade} from './sdk/evaluation';
import {TrackerFacade} from './sdk/tracking';
import {Tab, Logger, SdkEventManager, SessionFacade, UserFacade, CidAssigner} from './sdk';

export interface PluginSdk {
readonly version: string;
readonly appId: string;
readonly tracker: Tracker;
readonly evaluator: Evaluator;
readonly tracker: TrackerFacade;
readonly evaluator: EvaluatorFacade;
readonly user: UserFacade;
readonly session: SessionFacade;
readonly tab: Tab;
Expand Down
2 changes: 1 addition & 1 deletion src/sdk/evaluation.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
export {default as Evaluator, EvaluationOptions} from '@croct/sdk/facade/evaluatorFacade';
export {EvaluatorFacade, EvaluationOptions} from '@croct/sdk/facade/evaluatorFacade';
export {EvaluationError, EvaluationErrorType, ExpressionError} from '@croct/sdk/evaluator';
12 changes: 6 additions & 6 deletions src/sdk/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@ import {EventListener, EventDispatcher, EventSubscriber, EventManager} from '@cr
import {SdkEventMap, SdkEventType} from '@croct/sdk/sdkEvents';

export {Logger} from '@croct/sdk/logging';
export {default as SessionFacade} from '@croct/sdk/facade/sessionFacade';
export {default as UserFacade} from '@croct/sdk/facade/userFacade';
export {default as Tab} from '@croct/sdk/tab';
export {default as CidAssigner} from '@croct/sdk/cid';
export {SessionFacade} from '@croct/sdk/facade/sessionFacade';
export {UserFacade} from '@croct/sdk/facade/userFacade';
export {Tab} from '@croct/sdk/tab';
export {CidAssigner} from '@croct/sdk/cid';
export {SdkEventType, SdkEvent} from '@croct/sdk/sdkEvents';

export type SdkEventListener<T extends SdkEventType> = EventListener<SdkEventMap[T]>;
export type SdkEventDispatcher = EventDispatcher<Record<string, object>>;
export type SdkEventDispatcher = EventDispatcher<Record<string, Record<string, any>>>;
export type SdkEventSubscriber = EventSubscriber<SdkEventMap>;
export type SdkEventManager = EventManager<SdkEventMap, Record<string, object>>;
export type SdkEventManager = EventManager<SdkEventMap, Record<string, Record<string, any>>>;
2 changes: 1 addition & 1 deletion src/sdk/token.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export {default as Token, Claims, Headers, TokenProvider, TokenStore} from '@croct/sdk/token';
export {Token, Claims, Headers, TokenProvider, TokenStore} from '@croct/sdk/token';
2 changes: 1 addition & 1 deletion src/sdk/tracking.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export {default as Tracker} from '@croct/sdk/facade/trackerFacade';
export {TrackerFacade} from '@croct/sdk/facade/trackerFacade';
export {EventInfo, EventListener} from '@croct/sdk/tracker';
export {
TrackingEvent,
Expand Down
10 changes: 0 additions & 10 deletions src/sdk/validation.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,2 @@
export * from '@croct/sdk/validation';
export * from '@croct/sdk/error';
export * from '@croct/sdk/validation/jsonType';
export {default as ArrayType} from '@croct/sdk/validation/arrayType';
export {default as BooleanType} from '@croct/sdk/validation/booleanType';
export {default as FunctionType} from '@croct/sdk/validation/functionType';
export {default as MixedSchema} from '@croct/sdk/validation/mixedSchema';
export {default as NullType} from '@croct/sdk/validation/nullType';
export {default as NumberType} from '@croct/sdk/validation/numberType';
export {default as ObjectType} from '@croct/sdk/validation/objectType';
export {default as StringType} from '@croct/sdk/validation/stringType';
export {default as UnionType} from '@croct/sdk/validation/unionType';
2 changes: 1 addition & 1 deletion test/playground.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {EvaluationContext} from '@croct/sdk/evaluator';
import Token from '@croct/sdk/token';
import {Token} from '@croct/sdk/token';
import {PlaygroundPlugin, Configuration, factory} from '../src/playground';
import {Tab} from '../src/sdk';
import {PLAYGROUND_ORIGIN} from '../src/constants';
Expand Down
2 changes: 1 addition & 1 deletion test/plug.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import SdkFacade, {Configuration as SdkFacadeConfiguration} from '@croct/sdk/facade/sdkFacade';
import {SdkFacade, Configuration as SdkFacadeConfiguration} from '@croct/sdk/facade/sdkFacade';
import {Logger} from '../src/sdk';
import {Plugin, PluginFactory} from '../src/plugin';
import {GlobalPlug} from '../src/plug';
Expand Down
4 changes: 2 additions & 2 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"compilerOptions": {
"module": "ES2015",
"target": "es5",
"module": "CommonJS",
"target": "ES5",
"importHelpers": true,
"moduleResolution": "Node",
"allowSyntheticDefaultImports": true,
Expand Down

0 comments on commit 6f5c393

Please sign in to comment.