1
0
Fork 0
Commit Graph

38 Commits (1cb47d4acfd4087f4e8641fa4c80ce0eaa3fc058)

Author SHA1 Message Date
Austin Schaffer 1cb47d4acf [DEV-6710] [WIP] Save environment on quote save 2019-12-19 14:17:06 -05:00
Austin Schaffer 015a3f5d47 [DEV-5312] Convert MongoServerDao to TS 2019-11-11 15:14:49 -05:00
Austin Schaffer cda048dd8c [DEV-6353] Generate and save reverse deltas for ratingdata and step save 2019-11-07 16:25:33 -05:00
Austin Schaffer 48aa315c2a [DEV-6353] Get and set past rate data 2019-11-07 16:25:33 -05:00
Mike Gerwitz 1ed8ad1cd7 RatingService: Return promise
This only replaces the callbacks at the highest level and starts to move
toward proper error handling.  The private methods do not yet properly
propagate errors.
2019-10-29 13:36:55 -04:00
Mike Gerwitz 767a248e44 RatingService: Convert to TypeScript
This was an adventure, and was also used as a peer programming exercise to
introduce TypeScript to other programmers in the office.

This class has far too many dependencies, which made this difficult.  The
approach was to create .d.ts files for dependencies and wait on moving those
over for now, otherwise the task will never get done.

The RatingServicePublic trait was left as such for the time being; I was
able to work around a bug that was making it difficult to mix it into a
prototype.

There were no logic changes; this was just type refactoring.
2019-10-29 13:36:41 -04:00
Mike Gerwitz 7583cc1a71 RatingServiceSubmitNotify: Remove unused trait 2019-10-21 14:06:47 -04:00
Mike Gerwitz e003abcd4b Integrate TokenedDataApi into system
This changes the easejs interface for DataApi, which requires adding the
param to everything.  The TS interface was created in a previous commit and
already contained this parameter.  The idea is to remove the easejs
interface in the future, but traits are a barrier to that atm.

DocumentServer and controller demonstrate the mess that we have with regards
to instantiating dependencies.  This needs to change---DocumentServer itself
was something that was started but never fully realized.  It makes this
incredibly confusing, difficult to follow, and complicates important error
handling that ought to be taking place.  It also discourages implementing
additional dependencies.

I'm not going to go through and provide a ChangeLog-style commit message for
this commit.  I'm too exhausted by this crap.
2019-10-18 09:55:11 -04:00
Mike Gerwitz fb88ceeae6 TokenDao: class=>interface
TokenDao has been renamed to MongoTokenDao.  While it's good for this to
have its own interface anyway, the immediate motivation was for unit tests:
I started playing with mocking with TypeScript and researching some
libraries, but I don't have time to research enough to commit to any of them
at the moment.  Interfaces remove the need to mock at all.

This also stops using `export default' in favor of just importing by
name.  Using defaults only saves us a few characters, and it makes for
awkward syntax in various cases (e.g. with multiple exports).  But I'm still
new to TS, so who knows if I'll be flip-flopping on this decision in the
future.  If we kept to our normal 1:1 file:definition convention, it
wouldn't cause problems, but based on the types I've had to define so far,
that'd cause way too much bloat and boilerplate.

* src/server/daemon/controller.js: No long import `default'.  Use
  `MongoTokenDao'.
* src/server/token/TokenedService.js: Stop checking type (since TS
  interfaces do not result in compiler output, easejs cannot validate
  against them.)
* src/server/token/MongoTokenDao.ts: Rename from `TokenDao.ts'.
* src/server/token/TokenDao.ts: Rename from `TokenQueryResult.ts'.
  (TokenDao): New interface.
* src/server/token/TokenQueryResult.ts: Rename to `TokenDao.ts'.
* test/server/token/MongoTokenDaoTest.ts: Rename from `TokenDaoTest.ts'.
2019-10-17 11:47:14 -04:00
Mike Gerwitz 9ea66c0440 TokenDao: Lift out nondeterminism (date)
* src/server/daemon/controller.js (getUnixTimestamp): New method.  Not
  ideal, but better than where it was.
  (_initExportService): Pass to TokenDao constructor.
* src/server/token/TokenDao.ts (_getTimestamp): New field.
  (constructor)[get_timestamp]: New param.
  (updateToken): Use it.
* test/server/token/TokenDaoTest.ts: Provide stub timestamp function.
2019-10-17 11:47:14 -04:00
Mike Gerwitz 9dd1ae3428 TokenDao: Export as default alongside TokenData
Our coding standards are to create a separate file for classes and
interfaces, but this is a bit different: this "interface" is more like a
struct, and it's used to define the return type of a method of this
class.  Since it's inherently coupled, I'm keeping it in the same file.

The idea is that the caller will provide its own abstraction rather than
continuing to export this one.  Note that Typescript does support
re-exporting symbols if need be.

* src/server/daemon/controller.js: Adjust import of TokenDao (TS compiles
  default modules as `default').
* src/server/service/TokenedService.js: Adjust import of TokenDao.
* src/server/token/TokenDao.ts: Export TokenDao as `default'.  Export
  TokenData.
* test/server/token/TokenDaoTest.ts: Adjust import of TokenDao.  Import
  TokenData.
2019-10-17 11:47:14 -04:00
Mike Gerwitz 742955a671 TokenDao: Make root field configurable
This was previously hard-coded to "exports", which is so named because the
system is currently used only to export data to another system.

This change retains the previous functionality.

* src/server/daemon/controller.js (_initExportService): Pass new TokenDao
    argument.
* src/server/token/TokenDao.ts (TokenDao)[_rootField]: New property.
  (constructor, getToken, _genRoot): Use it.
2019-10-17 11:47:14 -04:00
Mike Gerwitz c909599ab5 TokenDao: Move to src/server/{service=>token}
This is no longer going to be coupled with the concept of a "service",
though it'll continue to be used by it.

* src/server/daemon/controller.js: Change TokenDao import path.
* src/server/service/TokenedService.js: Likewise.
* src/server/service/TokenDao.ts: Rename (delete).
* src/server/token/TokenDao.ts: New name.
2019-10-17 11:47:14 -04:00
Mike Gerwitz 5a1b84c271 TokenDao: Typescript conversion
This is the first test of integrating typescript.  I'm using the `export ='
syntax to keep imports the same using `require', but note that the `new'
keyword is now required for instantiation (whereas it was not with easejs).
2019-10-17 11:47:14 -04:00
Mike Gerwitz 27d570578d quicksave: Remove saving and restoring of state
The quicksave feature was added back in 2011 when the framework was somewhat
unstable---we were taking calls from users and it wasn't a pleasent
experience to tell them that they had to refresh the page to work around
some issue with bad state, and lose all unsaved data.

This feature is now more trouble than it's worth, since it causes a number
of bugs and can even cause data corruption.  If this is reintroduced in the
future, I'd prefer it be done by periodically saving quote state after every
or a few bucket modifications, to permit Meteor-like features.

This keeps the feature available on the client as a heartbeat for quote
locking; this can be removed in the future when we handle distributed
locking.

* src/client/Client.js (_changeQuote): Stop setting quicksave data from
    request.
  (_mergeQuickSaveData): Remove now-unused method.
  (_createUi): Stop merging quicksave data on render.
  (saveStaging): Add note that this method is now only used as a heartbeat.
* src/client/quote/ClientQuote.js (saveStaging): Add comment indicating that
    this is now used for a heartbeat.
  (setQuickSaveData, getQuickSaveData): Remove methods.
* src/quote/BaseQuote.js (_quickSaveData): Remove field.
  (setQuickSaveData, getQuickSaveData): Remove methods.
* src/server/Server.js (initQuote): Do not create or initialize quicksave
    data.
  (handleQuickSave): Remove method.
* src/server/daemon/controller.js (doRoute): Return empty reply without
    processing quicksave data.  Continue touching session to retain quote
    lock.
* src/server/db/MongoServerDao.js (saveQuote): Do not clear quicksave.
  (quickSaveQuote): Remove method.
2019-09-04 11:59:36 -04:00
Mike Gerwitz e058c8b509 Copyright range update
All files now have the same range, beginning from the conception of this
project.
2019-08-30 09:41:35 -04:00
Mike Gerwitz 2c49156ba3 controller: Add missing returns
This was broken when the controller was made async; the returns were
converted into resolves.
2019-08-28 15:17:04 -04:00
Andrew Fanton 5a5c2ca629 [DEV-3514] Lock quotes that exceed expiration date 2019-05-28 16:33:05 -04:00
Herbert Burzlaff 7ac88d6e55
DEVOPS-151: code changes to support mongodb HA (Replication) 2019-05-08 17:05:30 -04:00
Mike Gerwitz 90802edc03 RatingServicePublish: Publish to {queue=>exchange}
This now publishes to a fanout exchange instead of a queue, which allows
consumers to handle their own queue configuration.

This also adds some basic logging that was missing from the first version.

Note that I still don't consider this to be production-quality code; it's
missing tests, and there's still notes that need to be addressed.
2019-04-03 10:43:58 -04:00
Mike Gerwitz 77ddbbef3b Exclusively use RatingServicePublish over submit URL 2019-03-26 11:01:16 -04:00
Mike Gerwitz b8801c039f RatingServicePublish: New trait (mostly proof-of-concept)
This is unfortunately not production-ready code, but we need to get
something out there in the meantime.  The RatingServicePublish's docblock
mentions some of the shortcomings, which will be addressed in the near
future.

There is also more documentation to come once we settle on an implementation.

DEV-4400
2019-03-21 14:08:00 -04:00
Joseph Frazer 0a01456a46 [DEV-3284] Remove references to "LoVullo" 2018-09-27 10:07:08 -04:00
Mike Gerwitz 3261fbd7ec controller: Fix progdata route error reporting
* src/server/daemon/controller.js (doRoute): response.{error=>internalError}.
2018-06-20 10:48:23 -04:00
Andrew Elbaneh 28fef16971 [DEV-2871] cleaned up some of the code based on the merge request 2018-06-12 09:02:54 -04:00
Mark Goldsmith 9907c698d1 [DEV-2871] Added DocumentProgramFormatter to format program data by step, group and field metadata 2018-06-12 09:02:54 -04:00
Mike Gerwitz ad52dbec9a controller: Only init submit notification if requested
* src/server/daemon/controller.js (exports.init): Do not initialize submit
    notifier if no URL was provided.
2018-05-03 14:39:04 -04:00
Mike Gerwitz fac64b6ae1 Server: Set program internal flag before assertions
Requests that came in between (for example) a post request and the actual
validation of the posted data would potentially reset the flag, causing
internal assertions to fail.

* src/server/Server.js
  (sendStep): Provide session to #_forwardValidate.
  (_forwardValidate): Set `program.isInternal' immediately before invoking
    event.  Provide session to #quoteFill.
    [session]: New argument.
  (quoteFill): Add `session' argument.  Provide session to hooks.
  (loadProgram): Receive session via #quoteFill hook.  Set
    `program.isInternal' before submit hook.
* src/server/daemon/controller.js (doRoute): Remove `program.isInternal'
    set.
2018-05-01 15:03:55 -04:00
Mike Gerwitz ea30e94527 Integrate noResultsUrl configuration
This is not the ideal implementation.  Instantiation of RatingService and
such should be moved out of the controller entirely, but we don't have the
time for that right now.
2018-05-01 09:44:55 -04:00
Mike Gerwitz 25cb1f62c1 controller: Integrate RatingServiceSubmitNotify
This is not an ideal location.
2018-05-01 09:44:55 -04:00
Mike Gerwitz 6733556582 Remove hard-coded skey
This wasn't intended to make its way into a public repo. :)

The existing key was a long-forgotten kluge that was supposed to be
temporary, allowing internal services to create quotes without
authentication.  The chances of this being practically exploited are minimal
in our environment, and it's auditable using webserver logs.

This moves the skey into a configuration file, which allows it to vary by
server and be rotated until a better solution is made available.  skey is
disabled by default (empty string), and when used by us internally, the keys
are now generated using a CSPRNG rather than a brute-forcable 5-byte key
that was hard-coded.

The fact that this appears in webserver logs is a big issue as well.  I
added a task to address that.

* conf/vanilla-server.json (skey): New key.  Default empty.
* src/server/daemon/Daemon.js (start): Provide skey to `#getRouters'.
  (getRouters): Provide skey to `#getProgramController'.
  (getProgramController): Set skey on `controller'.
* src/server/daemon/controller.js (skey): New mutable export (unideal; quick
    change).
  (has_skey): Use it.
2018-04-03 15:29:47 -04:00
Mike Gerwitz 445783c256 [BC BREAK] DataApi config lookup
This was a bit involved because the system had to be made async all
the way up the stack.  No attempt was made to clean up the mess up the
stack---no time.

* src/dapi/DataApiFactory.js
  (fromType): [BC BREAK] Fix docblock.  Add `api_name' param.  Call
    `#descLookup' and return promise.
  (descLookup): Add method.  Return promise resolving to provided
    descriptor.  Intended to be overridden by subtype.
* src/dapi/DataApiManager.js
  (_dataApis): Update docblock to indicate that it now stores
    promises.
  (getApiData): Expect promise for `DataApiFactory#fromType' call.
* src/server/DocumentServer.js: (create): [BC BREAK] Accept
    configuration.  Look up dapi conf and pass to
    `ServerDataApiFactory' ctor.  Return promise.
* src/server/daemon/Daemon.js (_initRouters): Provide configuration.
* src/server/daemon/controller.js
  (init): Accept configuration.  Handle return of promise from
    `_createDocumentServer'.
  (_createDocumentServer): Accept configuration, providing to
    `DocumentServer#create'.  Because of aforementioned change to
    `#create', returns promise.
* src/server/request/ServerDataApiFactory.js: Add StoreMissError
    import.
  (_conf): Add property.
  (constructor): [BC BREAK] Accept configuration.
  (descLookup): Add override.  Look up configuration for provided
    dapi.
2017-08-29 15:11:28 -04:00
Mike Gerwitz 6a777c3c51 Auto-reconnect to mongo database
I wish I knew this option existed ~7yr ago.  This should have been
done long ago, but we've had so few problems with it, that it had
never been explored.

This [version of this] mongo library is ancient and needs to be
upgraded.  Until then, this'll do.

* src/server/daemon/controller.js (init): Set `auto_reconnect'.
2017-08-22 16:46:47 -04:00
Mike Gerwitz 2eacd310b2 Process metadata and provide to rate process
Prefixes with "meta:".

* src/server/Server.js (initQuote): Initialze metadata to empty.
* src/server/daemon/controller.js (createQuote): Add metabucket.
* src/server/db/MongoServerDao.js (saveQuote): Add additional
  documentation to docblock.  Save all metadata if no bucket data
  provided (which indicates a full quote save).  This happens on
  version change.
* src/server/rater/ProcessManager.js (_genData): Add method to merge
  metadata into bucket data with "meta:" prefix.
  (byId): Use merged data.
2017-07-10 10:09:24 -04:00
Mike Gerwitz 0c24e3d280 Populate document metadata using Data APIs
What a cluster.

This was a lot of work to work around existing, bad APIs; there is no
time to refactor at the moment; this already took much longer than
expected.
2017-06-28 16:33:24 -04:00
Mike Gerwitz 95c28d4db4 Extract Server construction into DocumentServer
* src/server/DocumentServer.js: Add facade.
* src/server/daemon/controller.js: Use it.
2017-06-28 14:56:26 -04:00
Mike Gerwitz 1bb5191e3e LoVullo Associates => R-T Specialty
Copyright notices updated.  More casual references to "LoVullo
Associates" replaced with "RT Specialty / Lovullo", which will be "RT
Specialty Buffalo" in the future.  Or "RT Specialty", depending on how
this is rolled out.  Or "Ryan Specialty Group".  Who knows.

"R-T Specialty, LLC." is the legal name, which includes the dash.  Not
to be confused with a certain television network.
2017-06-08 14:48:43 -04:00
Mike Gerwitz 657573ab63 Near-complete liberation of liza
I have sat on releasing a lot of this code for years because I wanted
the liza repo to be in a pristine state---tests and all---which
required a great deal of refactoring.  Well, that never happened, and
time is up.

LoVullo Associates---my employer---has been purchased by another
company.  This means that any agreement with LoVullo regarding
releasing free software is going to have to be re-negotiated with this
new company, and I have no idea how those negotiations will go.  So,
I have no choice but to simply release everything in its current state,
or risk it being lost forever.

This represents work over the past 6--7 years, 99.9% of it written by
me.  This project has been my baby for quite some time, and has been
through a number of battles with deadlines and other unfortunate
circumstances; the scars show.  I also didn't really "know" JS when
starting this project.  Perhaps you can help improve upon it.

There are some odds-and-ends that could be committed.  And references
to insurance and LoVullo need to be removed to generalize this.

I hope that this will not be the last public commit for this project.
I'll fight the good fight and we'll see where that takes us.  Maybe
it'll be easy.

Happy hacking.
2017-06-08 14:38:28 -04:00