Skip to content

Commit

Permalink
Merge pull request #108 from launchdarkly/eb/move-client-impl
Browse files Browse the repository at this point in the history
(2) move entire client implementation into common package
  • Loading branch information
eli-darkly committed Oct 16, 2018
2 parents 8016918 + 5dab7ce commit 72b04f7
Show file tree
Hide file tree
Showing 33 changed files with 1,421 additions and 1,355 deletions.
16 changes: 16 additions & 0 deletions packages/ldclient-js-common/jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
const version = process.env.npm_package_version;

module.exports = {
automock: false,
resetModules: true,
rootDir: 'src',
setupFiles: ['jest-localstorage-mock', './jest.setup.js'],
testMatch: ['**/__tests__/**/*-test.js'],
transform: {
'^.+\\.js$': 'babel-jest',
},
globals: {
window: true,
VERSION: version,
},
};
8 changes: 6 additions & 2 deletions packages/ldclient-js-common/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion packages/ldclient-js-common/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,10 @@
"sinon": "4.5.0",
"typescript": "3.0.1"
},
"dependencies": {},
"dependencies": {
"Base64": "1.0.1",
"escape-string-regexp": "1.0.5"
},
"repository": {
"type": "git",
"url": "git://github.com/launchdarkly/js-client.git"
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import * as common from 'ldclient-js-common';

import EventSender from './EventSender';
import EventSummarizer from './EventSummarizer';
import UserFilter from './UserFilter';
import * as errors from './errors';
import * as messages from './messages';
import * as utils from './utils';

export default function EventProcessor(eventsUrl, environmentId, options = {}, emitter = null, sender = null) {
Expand Down Expand Up @@ -131,7 +130,7 @@ export default function EventProcessor(eventsUrl, environmentId, options = {}, e
utils.onNextTick(() => {
emitter.maybeReportError(
new errors.LDUnexpectedResponseError(
common.messages.httpErrorMessage(responseInfo.status, 'event posting', 'some events were dropped')
messages.httpErrorMessage(responseInfo.status, 'event posting', 'some events were dropped')
)
);
});
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import * as common from 'ldclient-js-common';

import * as utils from './utils';
import * as errors from './errors';
import * as messages from './messages';

const json = 'application/json';

Expand Down Expand Up @@ -44,7 +43,7 @@ function fetchJSON(endpoint, body, callback, sendLDHeaders) {

function getResponseError(xhr) {
if (xhr.status === 404) {
return new errors.LDInvalidEnvironmentIdError(common.messages.environmentNotFound());
return new errors.LDInvalidEnvironmentIdError(messages.environmentNotFound());
} else {
return xhr.statusText;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import * as common from 'ldclient-js-common';

import * as messages from './messages';
import * as utils from './utils';

export default function Store(environment, hash, ident) {
Expand All @@ -20,7 +19,7 @@ export default function Store(environment, hash, ident) {
try {
dataStr = localStorage.getItem(key);
} catch (ex) {
console.warn(common.messages.localStorageUnavailable());
console.warn(messages.localStorageUnavailable());
return null;
}
try {
Expand All @@ -44,7 +43,7 @@ export default function Store(environment, hash, ident) {
try {
localStorage.setItem(key, JSON.stringify(data));
} catch (ex) {
console.warn(common.messages.localStorageUnavailable());
console.warn(messages.localStorageUnavailable());
}
};

Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import * as common from 'ldclient-js-common';

import * as messages from './messages';
import * as utils from './utils';

/**
Expand Down Expand Up @@ -30,14 +29,10 @@ export default function UserFilter(config) {
};

if (config.all_attributes_private !== undefined) {
console &&
console.warn &&
console.warn(common.messages.deprecated('all_attributes_private', 'allAttributesPrivate'));
console && console.warn && console.warn(messages.deprecated('all_attributes_private', 'allAttributesPrivate'));
}
if (config.private_attribute_names !== undefined) {
console &&
console.warn &&
console.warn(common.messages.deprecated('private_attribute_names', 'privateAttributeNames'));
console && console.warn && console.warn(messages.deprecated('private_attribute_names', 'privateAttributeNames'));
}

filter.filterUser = function(user) {
Expand Down
Loading

0 comments on commit 72b04f7

Please sign in to comment.