Commit 3e7626f8 authored by Robert Knight's avatar Robert Knight

Move services to `services/` directory

Following the plan outlined in #687, move services into a `services/`
directory.

The definition of "services" in that plan (a possibly stateful module
that handles interaction with an external party) is slightly more narrow
than what constitutes an Angular service (a stateful singleton that has
dependencies on injectable services/values).

However as a first approximation most Angular services are services as
defined in #687, so I've simply moved them all to the `services/`
directory.
parent d97b07ac
......@@ -71,7 +71,7 @@ describe('sidebar.components.hypothesis-app', function () {
fakeAnalytics = {
track: sandbox.stub(),
events: require('../../analytics')().events,
events: require('../../services/analytics')().events,
};
fakeAuth = {};
......
......@@ -56,7 +56,7 @@ describe('sidebar.components.sidebar-content', function () {
before(function () {
angular.module('h', [])
.service('annotationUI', require('../../annotation-ui'))
.service('annotationUI', require('../../services/annotation-ui'))
.component('sidebarContent', proxyquire('../sidebar-content',
noCallThru({
angular: angular,
......
......@@ -184,30 +184,30 @@ module.exports = angular.module('h', [
.directive('spinner', require('./directive/spinner'))
.directive('windowScroll', require('./directive/window-scroll'))
.service('analytics', require('./analytics'))
.service('annotationMapper', require('./annotation-mapper'))
.service('annotationUI', require('./annotation-ui'))
.service('analytics', require('./services/analytics'))
.service('annotationMapper', require('./services/annotation-mapper'))
.service('annotationUI', require('./services/annotation-ui'))
.service('api', require('./services/api'))
.service('apiRoutes', require('./api-routes'))
.service('auth', require('./oauth-auth'))
.service('apiRoutes', require('./services/api-routes'))
.service('auth', require('./services/oauth-auth'))
.service('bridge', require('../shared/bridge'))
.service('drafts', require('./drafts'))
.service('features', require('./features'))
.service('flash', require('./flash'))
.service('frameSync', require('./frame-sync').default)
.service('groups', require('./groups'))
.service('localStorage', require('./local-storage'))
.service('permissions', require('./permissions'))
.service('queryParser', require('./query-parser'))
.service('rootThread', require('./root-thread'))
.service('searchFilter', require('./search-filter'))
.service('serviceUrl', require('./service-url'))
.service('session', require('./session'))
.service('streamer', require('./streamer'))
.service('streamFilter', require('./stream-filter'))
.service('tags', require('./tags'))
.service('unicode', require('./unicode'))
.service('viewFilter', require('./view-filter'))
.service('drafts', require('./services/drafts'))
.service('features', require('./services/features'))
.service('flash', require('./services/flash'))
.service('frameSync', require('./services/frame-sync').default)
.service('groups', require('./services/groups'))
.service('localStorage', require('./services/local-storage'))
.service('permissions', require('./services/permissions'))
.service('queryParser', require('./services/query-parser'))
.service('rootThread', require('./services/root-thread'))
.service('searchFilter', require('./services/search-filter'))
.service('serviceUrl', require('./services/service-url'))
.service('session', require('./services/session'))
.service('streamer', require('./services/streamer'))
.service('streamFilter', require('./services/stream-filter'))
.service('tags', require('./services/tags'))
.service('unicode', require('./services/unicode'))
.service('viewFilter', require('./services/view-filter'))
.value('Discovery', require('../shared/discovery'))
.value('ExcerptOverflowMonitor', require('./util/excerpt-overflow-monitor'))
......
......@@ -2,7 +2,7 @@
var angular = require('angular');
var events = require('./events');
var events = require('../events');
function getExistingAnnotation(annotationUI, id) {
return annotationUI.getState().annotations.find(function (annot) {
......
......@@ -36,16 +36,16 @@ var redux = require('redux');
// `.default` is needed because 'redux-thunk' is built as an ES2015 module
var thunk = require('redux-thunk').default;
var reducers = require('./reducers');
var annotationsReducer = require('./reducers/annotations');
var framesReducer = require('./reducers/frames');
var linksReducer = require('./reducers/links');
var selectionReducer = require('./reducers/selection');
var sessionReducer = require('./reducers/session');
var viewerReducer = require('./reducers/viewer');
var util = require('./reducers/util');
var reducers = require('../reducers');
var annotationsReducer = require('../reducers/annotations');
var framesReducer = require('../reducers/frames');
var linksReducer = require('../reducers/links');
var selectionReducer = require('../reducers/selection');
var sessionReducer = require('../reducers/session');
var viewerReducer = require('../reducers/viewer');
var util = require('../reducers/util');
var debugMiddleware = require('./reducers/debug-middleware');
var debugMiddleware = require('../reducers/debug-middleware');
/**
* Redux middleware which triggers an Angular change-detection cycle
......
'use strict';
var { retryPromiseOperation } = require('./retry-util');
var { retryPromiseOperation } = require('../retry-util');
/**
* A service which fetches and caches API route metadata.
......
......@@ -11,8 +11,8 @@
*/
'use strict';
var events = require('./events');
var bridgeEvents = require('../shared/bridge-events');
var events = require('../events');
var bridgeEvents = require('../../shared/bridge-events');
// @ngInject
......
......@@ -2,10 +2,10 @@
var debounce = require('lodash.debounce');
var events = require('./events');
var bridgeEvents = require('../shared/bridge-events');
var metadata = require('./annotation-metadata');
var uiConstants = require('./ui-constants');
var events = require('../events');
var bridgeEvents = require('../../shared/bridge-events');
var metadata = require('../annotation-metadata');
var uiConstants = require('../ui-constants');
/**
* @typedef FrameInfo
......
......@@ -13,9 +13,9 @@
var STORAGE_KEY = 'hypothesis.groups.focus';
var events = require('./events');
var { awaitStateChange } = require('./util/state-util');
var serviceConfig = require('./service-config');
var events = require('../events');
var { awaitStateChange } = require('../util/state-util');
var serviceConfig = require('../service-config');
// @ngInject
function groups($rootScope, annotationUI, api, isSidebar, localStorage, serviceUrl, session,
......
'use strict';
var events = require('./events');
var resolve = require('./util/url-util').resolve;
var serviceConfig = require('./service-config');
var events = require('../events');
var resolve = require('../util/url-util').resolve;
var serviceConfig = require('../service-config');
/**
* @typedef RefreshOptions
......
'use strict';
var buildThread = require('./build-thread');
var events = require('./events');
var memoize = require('./util/memoize');
var metadata = require('./annotation-metadata');
var tabs = require('./tabs');
var uiConstants = require('./ui-constants');
var buildThread = require('../build-thread');
var events = require('../events');
var memoize = require('../util/memoize');
var metadata = require('../annotation-metadata');
var tabs = require('../tabs');
var uiConstants = require('../ui-constants');
function truthyKeys(map) {
return Object.keys(map).filter(function (k) {
......
'use strict';
var urlUtil = require('./util/url-util');
var urlUtil = require('../util/url-util');
/**
* A function that returns an absolute URL given a link name and params, by
......
'use strict';
var events = require('./events');
var retryUtil = require('./retry-util');
var events = require('../events');
var retryUtil = require('../retry-util');
var CACHE_TTL = 5 * 60 * 1000; // 5 minutes
......
......@@ -3,8 +3,8 @@
var queryString = require('query-string');
var uuid = require('node-uuid');
var events = require('./events');
var Socket = require('./websocket');
var events = require('../events');
var Socket = require('../websocket');
/**
* Open a new WebSocket connection to the Hypothesis push notification service.
......
......@@ -3,7 +3,7 @@
var angular = require('angular');
var immutable = require('seamless-immutable');
var events = require('../events');
var events = require('../../events');
describe('annotationMapper', function() {
var sandbox = sinon.sandbox.create();
......
......@@ -3,10 +3,10 @@
var immutable = require('seamless-immutable');
var annotationUIFactory = require('../annotation-ui');
var annotationFixtures = require('./annotation-fixtures');
var metadata = require('../annotation-metadata');
var unroll = require('../../shared/test/util').unroll;
var uiConstants = require('../ui-constants');
var annotationFixtures = require('../../test/annotation-fixtures');
var metadata = require('../../annotation-metadata');
var unroll = require('../../../shared/test/util').unroll;
var uiConstants = require('../../ui-constants');
var defaultAnnotation = annotationFixtures.defaultAnnotation;
var newAnnotation = annotationFixtures.newAnnotation;
......
......@@ -69,7 +69,7 @@ describe('sidebar.services.api', function () {
angular.module('h', [])
.service('api', proxyquire('../api', util.noCallThru({
angular: angular,
'./retry-util': {
'../retry-util': {
retryPromiseOperation: function (fn) {
return fn();
},
......
'use strict';
var features = require('../features');
var events = require('../events');
var bridgeEvents = require('../../shared/bridge-events');
var events = require('../../events');
var bridgeEvents = require('../../../shared/bridge-events');
describe('h:features - sidebar layer', function () {
......
......@@ -3,12 +3,12 @@
var angular = require('angular');
var EventEmitter = require('tiny-emitter');
var annotationFixtures = require('./annotation-fixtures');
var events = require('../events');
var annotationFixtures = require('../../test/annotation-fixtures');
var events = require('../../events');
var FrameSync = require('../frame-sync').default;
var fakeStore = require('./fake-redux-store');
var fakeStore = require('../../test/fake-redux-store');
var formatAnnot = require('../frame-sync').formatAnnot;
var uiConstants = require('../ui-constants');
var uiConstants = require('../../ui-constants');
var fixtures = {
ann: Object.assign({$tag: 't1'}, annotationFixtures.defaultAnnotation()),
......
'use strict';
var events = require('../events');
var fakeReduxStore = require('./fake-redux-store');
var events = require('../../events');
var fakeReduxStore = require('../../test/fake-redux-store');
var groups = require('../groups');
var unroll = require('../../shared/test/util').unroll;
var unroll = require('../../../shared/test/util').unroll;
// Return a mock session service containing three groups.
var sessionWithThreeGroups = function() {
......
......@@ -2,9 +2,9 @@
var angular = require('angular');
var events = require('../events');
var events = require('../../events');
var FakeWindow = require('../util/test/fake-window');
var FakeWindow = require('../../util/test/fake-window');
var DEFAULT_TOKEN_EXPIRES_IN_SECS = 1000;
var TOKEN_KEY = 'hypothesis.oauth.hypothes%2Eis.token';
......
......@@ -4,10 +4,10 @@ var angular = require('angular');
var proxyquire = require('proxyquire');
var immutable = require('seamless-immutable');
var annotationFixtures = require('./annotation-fixtures');
var events = require('../events');
var uiConstants = require('../ui-constants');
var util = require('../../shared/test/util');
var annotationFixtures = require('../../test/annotation-fixtures');
var events = require('../../events');
var uiConstants = require('../../ui-constants');
var util = require('../../../shared/test/util');
var unroll = util.unroll;
......@@ -84,7 +84,7 @@ describe('rootThread', function () {
.value('searchFilter', fakeSearchFilter)
.value('viewFilter', fakeViewFilter)
.service('rootThread', proxyquire('../root-thread', {
'./build-thread': util.noCallThru(fakeBuildThread),
'../build-thread': util.noCallThru(fakeBuildThread),
}));
angular.mock.module('app');
......
......@@ -21,7 +21,7 @@ function createServiceUrl(linksPromise) {
);
var serviceUrlFactory = proxyquire('../service-url', {
'./util/url-util': { replaceURLParams: replaceURLParams },
'../util/url-util': { replaceURLParams: replaceURLParams },
});
var annotationUI = fakeAnnotationUI();
......
......@@ -2,7 +2,7 @@
var angular = require('angular');
var events = require('../events');
var events = require('../../events');
var mock = angular.mock;
......
......@@ -4,8 +4,8 @@ var EventEmitter = require('tiny-emitter');
var inherits = require('inherits');
var proxyquire = require('proxyquire');
var events = require('../events');
var unroll = require('../../shared/test/util').unroll;
var events = require('../../events');
var unroll = require('../../../shared/test/util').unroll;
var fixtures = {
createNotification: {
......@@ -136,7 +136,7 @@ describe('Streamer', function () {
};
Streamer = proxyquire('../streamer', {
'./websocket': FakeSocket,
'../websocket': FakeSocket,
});
});
......
......@@ -44,11 +44,11 @@ describe('annotation threading', function () {
};
angular.module('app', [])
.service('annotationUI', require('../../annotation-ui'))
.service('drafts', require('../../drafts'))
.service('rootThread', require('../../root-thread'))
.service('searchFilter', require('../../search-filter'))
.service('viewFilter', require('../../view-filter'))
.service('annotationUI', require('../../services/annotation-ui'))
.service('drafts', require('../../services/drafts'))
.service('rootThread', require('../../services/root-thread'))
.service('searchFilter', require('../../services/search-filter'))
.service('viewFilter', require('../../services/view-filter'))
.value('features', fakeFeatures)
.value('settings', {})
.value('unicode', fakeUnicode);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment