1
0
Fork 0
Commit Graph

451 Commits (master)

Author SHA1 Message Date
Austin Schaffer 48aa315c2a [DEV-6353] Get and set past rate data 2019-11-07 16:25:33 -05:00
Austin Schaffer 9f8fb90d0d [DEV-6353] Add dapi definitions 2019-11-07 16:25:33 -05:00
Austin Schaffer 4f39c754a2 [DEV-6353] Add bucket definitions 2019-11-07 16:25:33 -05:00
Austin Schaffer 6fcf72f1b6 [DEV-6353] Convert DataProcessor to TS 2019-11-07 16:25:33 -05:00
Mike Gerwitz 64718d5513 RatingService: Fix initialRatedDate and lastRatedDate reply
Recent changes caused the quote to be read before it was mutated by
_saveRatingData.
2019-10-31 14:26:12 -04:00
Mike Gerwitz f0e246deef RatingService#postProcessRaterData: Fix accidental indvRate change
I accidentally changed id=>after when prototyping data for the _new_
deferred rating (not yet written).  There were no tests for this code, which
was originally written in July of 2012 (see private lovullo.git repo), so it
was not caught until QA.
2019-10-31 11:21:01 -04:00
Mike Gerwitz cefd6e95cb RatingService: Remove unnecessary program param
It was kept for postProcessRaterData for now since that would involve
modifying a subtype as well.
2019-10-29 13:36:55 -04:00
Mike Gerwitz 65e7880c81 RatingService: Improved error handling
This does only a slightly better job than before.
2019-10-29 13:36:55 -04:00
Mike Gerwitz a23f2040dd RatingService: Remove unreachable error check 2019-10-29 13:36:55 -04: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 1aa69c2a56 RatingService: Save rating data to separate field (ratedata)
This adds ratedata to the quote collection.  We use the existing saveQuote
method so that this operation is atomic.  We're also continuing to save to
the bucket for now so as not to break existing code, but the intent in the
future will be to remove all but necessary data that should be exposed to
the client.
2019-10-29 13:36:55 -04:00
Mike Gerwitz cffd9ddeb0 RatingServiceTest: Add type information for stubs
This also gets rid of the RatingServiceStub module, which is not used by
anything else.  I suspect that I originally added it to be shared by traits,
but that's no longer going to be the case (and the only remaining trait is
unfortunately untested atm, and will be going away).
2019-10-29 13:36:55 -04:00
Mike Gerwitz 312142b3e8 RatingService: Use ServerDao
I had forgotten an interface exists, and this will be needed for the next
commit.  Unfortunately it requires a bit of duplication with
MongoServerDao.d.ts, for now.
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 2771cf2a71 src/types/misc: Add UnixTimestampMillis, Seconds, and Milliseconds
These should be moved into their own module at some point and provide
functions to convert between and to yield these types.
2019-10-24 10:30:14 -04:00
Mike Gerwitz 5552de93d5 Rater: Remove interface
It's used only by HttpRater and the interface is no longer adhered to by
DslRater (which no longer implements it).
2019-10-24 10:30:14 -04:00
Mike Gerwitz e2edbfc7b2 src/numeric: New module
This beings to introduce compile-time safety for numeric values under the
assumption that they are enforced by the runtime.  See docblock for more
information.
2019-10-24 10:29:33 -04:00
Mike Gerwitz 7583cc1a71 RatingServiceSubmitNotify: Remove unused trait 2019-10-21 14:06:47 -04:00
Mike Gerwitz 44ad6437e2 {src,test}/.npmignore: New files
NPM was not publishing the compiled JS files (from the TS input) because
they were present in generated .gitignore files.  .npmignore takes
precedence.
2019-10-21 13:22:24 -04:00
Mike Gerwitz 16409a014f TokenedDataApi: Accept or kill token
Rather than leaving a token in a DONE state, we should either transition to
ACCEPTED or DEAD depending on whether the token was superceded.

* src/server/dapi/TokenedDataApi.ts (_replyUnlessStale): Accept token when
  not superceded, otherwise kill.
  [store]: New param.
  (request): Use it.
* test/server/dapi/TokenedDataApiTest.ts: Update accordingly.
2019-10-18 09:55:11 -04:00
Mike Gerwitz 544fe1a1fe RestrictedDataApi: Provide error to event if present
Rather than always providing an "Response data is not an array" error.

* src/dapi/RestrictedDataApi.js (_checkResponse)[err]: New first parameter.
  (request): Use it.
2019-10-18 09:55:11 -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 d8c065817f NodeCallback<T, R>: New type to simplify callback declarations
Just trying to reduce some boilerplate.  I kept this as a separate commit to
illustrate clearly how this type of things is done since we'll have people
learning TypeScript.

* src/types/misc.ts (NodeCallback<T,R>): New type.
* src/server/dapi/TokenedDataApi.ts: Use it.
* test/server/dapi/TokenedDataApiTest.ts: Use it.
2019-10-18 09:55:11 -04:00
Mike Gerwitz 07c8b55475 TokenedDataApi: New class
This integrates the PersistentTokenStore into the DataAPI system via a
decorator.  Unfortunately, it requires an API change and propagating data
through the system is a huge mess, which is the topic of a following
commit.  The API modification was a compromise.

This modifies the interface of DataApi to include a third parameter.  I am
continuing to export the old easejs interface for an incremental migration
away from it.  That old interface will be modified next commit, since
it requires modifying a lot of files and will muddy up this commit.

* src/dapi/DataApi.ts: Rename from js.  Add types.  Add new interface.
  Continue exporting old.
* src/server/dapi/TokenedDataApi.ts: New class.
* test/server/dapi/TokenedDataApiTest.ts: New test cases.
2019-10-18 09:55:11 -04:00
Mike Gerwitz b3ab082e9c {=>Persistent}TokenStore
This creates an interface for TokenStore.  The main motivation of this right
now is testing, since I'm punting on figuring out a mock framework right
now (due to time constraints).

* src/server/token/TokenStore.ts: Rename file.
* src/server/token/store/PersistentTokenStore.ts: Rename from TokenStore.
* test/server/token/TokenStoreTest.ts: Rename file.
* test/server/token/store/PersistentTokenStoreTest.ts: Rename from TokenStoreTest.
2019-10-18 09:55:11 -04:00
Mike Gerwitz d1f72cf5b3 MongoTokenDao, TokenStore: Simplify constructors
This is a feature that I originally wished I could introduce into easejs.  I
enjoyed it in Scala.  Cuts down on a lot of boilerplate.

* src/server/token/MongoTokenDao.ts (constructor): Remove fields and replace
  with inline definitions.
* src/server/token/TokenStore.ts (constructor): Likewise.
2019-10-18 09:55:10 -04:00
Mike Gerwitz c8589a1c57 TokenDao, TokenStore: Track most recently created tokens
This is much more useful information than the last modified.  For example:

- Token A is created.  It becomes the last modified.
- Token B is created.  It becomes the last modified.
- Token A completes.  Mismatch.  It becomes the last modified.
- Token B completes.  Mismatch.  It becomes the last modified.

So in this case, we're unable to use the flag to determine whether we should
ignore the token.  But if we instead us the new flag to see what token was
last _created_, the problem is solved.

This should have been obvious the first time around.

* src/server/token/MongoTokenDao.ts (updateToken): Query
    `lastState'.  Return its value.  Update its value.
  (getToken): Query lastState.  Return its value.
* src/server/token/Token.ts (Token)[last_state]: New field.
* src/server/token/TokenDao.ts (TokenQueryResult, TokenNamespaceResults):
    Use type instead of interface.
  (TokenStateHistory): New type.
  (TokenNamespaceData)[lastState]: New optional field.
  (TokenData)[prev_state]: New field.
* src/server/token/TokenStore.ts: Return previous state data for each
    method.
* test/server/token/MongoTokenDaoTest.ts: Add last_state.
* test/server/token/TokenStoreTest.ts: Likewise.
2019-10-18 09:55:10 -04:00
Mike Gerwitz 0a9a5fe56e TokenStore: Provide document id via constructor
The primary use case for this is currently the DataAPI, and the quote id is
only available at the highest level of the server, before dapis are
processed.

In any case, the TokenStore was already described in terms of a combination
of document id; namespace; and root field; so it makes sense for doc id to
be part of the constructor.

If a more generic TokenStore is needed in the future, we could go back to
the previous API and wrap it in another class, like a partially applied
function (e.g. `DocumentTokenStore`).

* src/server/token/TokenStore.ts: Move doc_id out of arguments and into the
  constructor.
* test/server/token/TokenStoreTest.ts: Update accordingly.
2019-10-18 09:55:10 -04:00
Mike Gerwitz 929acf0e90 TokenStore: Implement for token lookups and creation
Does not yet support token updates.

* src/server/token/Token.ts (TokenStateDeadable, TokenStateDoneable,
  TokenStateAcceptable, Token): New types.
* src/server/token/TokenStore.ts: New class.
* test/server/token/TokenStoreTest.ts: New test case.
2019-10-18 09:55:10 -04:00
Mike Gerwitz 9997da3f65 TokenDao: Return previous state
This causes the DAO to return the state of the document prior to the
database operation (in the case of a retrieval, the previous state is the
same as the current state).  This will allow determining whether other
tokens were modified since a previous request.

* src/server/token/MongoTokenDao.ts: Stop using TokenType in favor of new
    TokenState.
  (updateToken): Query for and return previous state.  Use findAndModify
    instead of update.
  (getToken): Return previous state.  Minor changes to account for new
    TokenQueryResult types (null=>undefined).
* src/server/token/Token.ts: Add comments for existing Token{Id,Namespace}
    nominal types.
  (TokenState): New string enum.
* src/server/token/TokenDao.ts: Import new TokenState.
  (TokenDao)[updateToken]: Use it.
  (TokenType): Remove.
  (TokenQueryResult, TokenNamespaceResults, TokenNamespaceData):
    null=>undefined for unavailable value.  null was wrong.
  (TokenStatus): Token{Type=>State}.
  (TokenData)[prev_state, prev_status]: New fields.
* test/server/token/MongoTokenDaoTest.ts: Update tests accordingly.
2019-10-18 09:55:10 -04:00
Mike Gerwitz ddf5892c83 src/types/mongo.d.ts: Add findAndModify
* src/types/mongo.d.ts (MongoCollection)[#findAndModify]: New method.
2019-10-18 09:55:10 -04:00
Mike Gerwitz 5b279f77cb TokenDao (#updateToken): Return updated data
Since some of these data are generated within TokenDao (e.g. the timestamp),
the caller cannot infer all values.

* src/server/token/MongoTokenDao.ts (updateToken): Return
  Promise<{void=>TokenData}>.
* src/server/token/TokenDao.ts (TokenDao)[#updateToken]: Update interface
  accordingly.
* test/server/token/MongoTokenDaoTest.ts: Update test accordingly.
2019-10-18 09:55:10 -04:00
Mike Gerwitz 4454e40e19 TokenDao: Add error context 2019-10-18 09:55:10 -04:00
Mike Gerwitz fe10578949 {Context,Chained}Error: New modules
This will allow us to provide additional useful information for structure
logging.
2019-10-18 09:55:09 -04:00
Mike Gerwitz 1f66a25658 TokenDao: Better error handling for unknown tokens
Rather than replying with null, which complicates using the returned promise
efficiently, we'll respond with a unique error that allows us to distinguish
between a database failure and a missing token.

These are more traditional errors, but we're moving toward structured
logging, so I want error objects that provide more context.  I'll explore
that a bit more in next commit.  Unfortunately, the untypedness of Promise
rejections make for a less than desirable situation here.  Async/await is
not yet an option since we're still compiling to ES5 (have to support
IE11), and TS compiles async/await into generators for environments that
don't support them, which also are not available in ES5.

* src/server/service/TokenedService.js (_getQuoteToken): Remove null check,
  since this situation can no longer occur.
* src/server/token/MongoTokenDao.ts (getToken): Remove null from return type
  union; reject with `UnknownTokenError' instead.
* src/server/token/TokenDao.ts: Modify interface accordingly.
* src/server/token/UnknownTokenError.ts: New class.
* test/server/token/MongoTokenDaoTest.ts: Modify tests accordingly.  Add
  missing test for latest token namespace missing.
2019-10-17 11:47:14 -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 37f1b86ac1 TokenDao: "quote"=>"document" with nominal type
* src/document/Document.ts: New file.
* src/server/token/TokenDao.ts: quote=>document and use DocumentId.
* test/server/token/TokenDaoTest.ts: Likewise.
2019-10-17 11:47:14 -04:00
Mike Gerwitz 54b3f0db72 TokenDao: Nominal typing
This beings an experiment with nominal typing using what the TS community
calls "branding".  The lack of nominal types was one of my biggest
disappointments with TS, so this should really help to mitigate bugs
resulting from misappropriation of data.

* src/server/token/Token.ts: New file.
* src/server/token/TokenDao.ts: Use Token{Id,Namespace}.
* src/server/token/TokenQueryResult.ts: Likewise.
* src/types/misc.d.ts: Introduce NominalType and UnixTimestamp.
* test/server/token/TokenDaoTest.ts: Use nominal types.
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 c90757a6d3 TokenDao: Callbacks=>promises
This makes minimal changes to TokenedService, even though there is obvious
refactoring that can be done to reduce duplication, because the class is
currently untested.

* src/server/service/TokenedService.js (_getQuoteToken, generateToken,
    killToken, acceptToken, completeToken): Expect promise.
* src/server/token/TokenDao.ts (updateToken, getToken): Remove callback
    param, return Promise.
* test/server/token/TokenDaoTest.ts: Use promises.
2019-10-17 11:47:14 -04:00
Mike Gerwitz 18e86ebfe7 TokenDao: Add test and further refine types
This tests the existing state of TokenDao before additional modifications
are made.  This commit also further refines the types introduced in a
previous commit.

This is also the first test written in Typescript.

* package.json.in (devDependencies): Add node, chai, and mocha types.
* src/server/token/TokenDao.ts (updateToken): `data` accepts null (as it
    should).  Do not conditionall add data to object (it doesn't matter for
    later retrieval).  Note nondeterminism with date.  More concise syntax
    for object fields.
* src/server/token/TokenQueryResult.ts: Make all fields readonly.
  (TokenStatus): Date is no longer optional (see above mention).
* src/types/mongodb.d.ts: Remove generics (erroneously added).
  (Collection)[update]: Remove 3-argument declaration (see comment).
* test/server/token/TokenDaoTest.ts: New test case.
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 b83f13f480 TokenDao: Add type information for Mongo interactions
This adds type information for both MongoCollection and some details about
the structure of the data itself as it is stored in the database.

* src/server/token/TokenDao.ts: Import types from TokenQueryResult.
  (TokenType): Move to TokenQueryResult module.
  (TokenData)[status]: string=>TokenStatus.
  (TokenDao)[_collection]: Remove optional type specifier.
    [_collection]: Make readonly.
    [updateToken]: Use TokenStatus type for token_entry.
    [getToken]: Add return type.  Add type for query result.  Remove useless
      length check (no such field exists).  Add types for variables.
    [_getLatestToken]: Use interface instead of inline type definition.
    [_getRequestedToken]: Use type definition for `data' instead of
      `any'.  Add type of variable.
* src/server/token/TokenQueryResult.ts: Define structure of data in Mongo.
* src/types/mongodb.d.ts: Add type information for methods used by TokenDao.
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
Joseph Frazer 28cac6917f [DEV-5872] Catch when an element is not present
When a question has been removed, but exists in a bucket for an existing
quote, it cannot find the element to hide and it ends up showing all (or
mostly all) question elements. We are ignoring this case since the
possible side effects of ignoring them are less severe than what happens
now. Additionally, the way this works will be changing in the future.
2019-09-26 13:24:39 -04:00
Mike Gerwitz 0553060f42 Add optional rate event delay
I've long been opposed to adding this delay, but a proper fix (for deferred,
async rating) that meets the needs of our current project will require
changes that I don't have time to take on for a little while.  As such, this
will be a temporary solution for hopefully no more than a month's time.

* src/client/Client.js (_initBeforeLoadHook): Pass value to event in
  addition to step id.
* src/client/event/RateEventHandler.js: Implement delay.

DEV-6145
2019-09-19 10:54:21 -04:00
Joseph Frazer 28f938853a [DEV-5657] Check for TLD in email addresses
The DocuSign service rejects email addresses without a TLD, even though
they are valid.
2019-09-12 09:30:23 -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
Schaffer, Austin 858efdce84 [DEV-5752] Allow override for dynamic submit messages 2019-08-01 15:53:13 -04:00
Mark Goldsmith 6e99e65167 [DEV-5618] Expose meta bucket to init route 2019-08-01 12:20:22 -04:00
Sarah Chintomby c55235d7d4 [DEV-5546] Move edge case code for month 2019-06-18 12:14:36 -04:00
Sarah Chintomby 716f2b1a32 [DEV-5546] Update to use setUTCDate 2019-06-18 12:14:36 -04:00
Sarah Chintomby 3372e433d7 [DEV-5546] Update getdate to universal time 2019-06-18 12:14:36 -04:00
Sarah Chintomby 8f0b12bd3a [DEV-5546] Change getdate to getUTCDate 2019-06-18 12:14:36 -04:00
Sarah Chintomby 53f3e2317e [DEV-5546] Fix calc relativedate for day and also month concerning edge cases 2019-06-18 12:14:36 -04:00
Austin Schaffer 9637fc22e1 [DEV-5333] Pass last rated date from the server quote back to the client quote
Correct and add more elaborate tests for RateEventHandler
2019-06-17 08:28:19 -04:00
Austin Schaffer 23889cbfca [DEV-5333] Use the correct function for day calculations 2019-06-14 10:40:49 -04:00
Austin Schaffer 723a7f7ff7 [DEV-5333] Expose initialRatedDate to the client from the bucket
[DEV-5333] WIP

Add RateEventHandlerTest and fix RatingServiceSubmitNotifyTest

WIP: Add RateEventHandlerTest

Add stubs for RateEventHandlerTest

Finish RateEventHandlerTest

Move done to fix test bug
2019-06-14 10:40:46 -04:00
Joseph Frazer 2f0fea8f49 Revert "[DEV-5492] Do not unserialize PHP objects in _sf2_attributes"
This reverts commit 981ba45d7c, reversing
changes made to e5917418fa.
2019-06-11 10:36:07 -04:00
Joseph Frazer 5b08c981c3 [DEV-5492] Do not unserialize PHP objects in _sf2_attributes
The PHP objects in the session from PHP7 cannot be unserialized. Since
they are not needed, we can safely ignore them.

Co-Authored-By: Jim Grundner <james.grundner@rtspecialty.com>
2019-06-10 11:19:04 -04:00
Mark Goldsmith 6e65b1f1e6 [DEV-5255] Fix setStartDate to use startData 2019-06-06 15:29:01 -04:00
Andrew Fanton 0be64040f8 [DEV-3514] Fix bug with expiration date calculation
The nature of this bug was two-fold:
1.) A new Date was being instantiated with seconds,
but the constructor expects milliseconds.
2.) The expiration period was not cast to a number,
causing an expression to concatenate strings instead of
adding numeric values; this greatly increased the actual
expiration date.
2019-05-30 14:29:55 -04:00
Austin Schaffer c1082d2a9d [DEV-5254] Expose lastPremDate for the data warehouse 2019-05-30 10:15:25 -04:00
Andrew Fanton f569a7e94d [DEV-3514] Display message explaining why quote is locked
Prior to this change, a single generic message was always shown simply
stating that the quote had been locked. These changes now allow for
different messages to be displayed in different circumstances.
2019-05-28 16:33:08 -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 c0feed41e9 src/calc/Calc.js (relativeDate): Default format to empty string
We shouldn't throw errors given an empty array for this value.

* src/calc/Calc.js (relativeDate): Default `format' in `_each' call.
2019-04-26 11:02:49 -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
Mark Goldsmith aedf8ceed8 RatingServicePublish:_sendMessage passes program_id 2019-03-27 15:01:24 -04:00
Mike Gerwitz 77ddbbef3b Exclusively use RatingServicePublish over submit URL 2019-03-26 11:01:16 -04:00
Mike Gerwitz 98d81c2f2f RatingServicePublish: Close connections after a timeout
Until we have a better option.

I really hate that all of this is rushed.
2019-03-21 16:34:41 -04:00
Mike Gerwitz c4591f681d Daemon: Return promise for post_rate reduction
This was causing a race condition in some environments.
2019-03-21 14:56:42 -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
Mike Gerwitz 814b0ff3a0 Client: Fix forward-validation failure messages
Forward validation failures were never updated to use the new Failure
object, so they ended up showing the default message.  The problem was that
`ui.invalidateForm' was replacing the Failure object with a new one with an
empty message.

This change just does the same thing as the change and save events.

* src/client/Client.js (_forwardValidate): Invoke `#_genValidationMessages'
    and `_dataValidator.updateFailures'.  Stop calling `ui.invalidateForm'.
2019-03-07 16:13:36 -05:00
Mark Goldsmith 04565a6559 [DEV-4452] Accordion margin applies to collapsable header only 2019-03-01 10:02:39 -05:00
Mike Gerwitz 20234bd906 db: Restore previous save-all-meta behavior
It looks like the metabucket is never initialized, so saving the quote is
right now the only thing that sets default values.  That should be fixed in
the future.

This also begins adding tests for the terrible MongoServerDao, that could
use some refactoring.

* src/server/db/MongoServerDao.js: Make `meta' mutable.  I had forgotten to
    remove the code that mutates it (since our version of v8 right now does
    not blow up for const assignments), so this is all that's needed.
* test/server/db/MongoServerDaoTest.js: New file to test this situation.
2019-02-12 09:18:48 -05:00
Mike Gerwitz 13716d240b server: Correct liza_timestamp_initial_rated to be a vector
The metabucket expects vectors, not scalars.  This causes the value
to be inaccessible when loaded by the ProcessManager for rating,
because it uses the Bucket implementation expecting vectors.

This wasn't noticed at first because it works through TAME's map.

* doc/bucket.texi (Metabucket): Clarify expected data format.
* src/server/db/MongoServerDao.js (saveQuote): Store
    `meta.liza_timestamp_initial_rated' as a vector.
2019-02-07 09:57:45 -05:00
Mike Gerwitz 833017c359 server: Auto-populate liza_timestamp_initial_rated in metabucket
This value already existed on the document, but was inaccessible to external
systems.  This is now accessible to e.g. raters.

* doc/bucket.texi (Metabucket): New section.
* src/server/db/MongoServerDao.js (saveQuote): Set initial quoted date as
    liza_timestamp_initial_rated.  Update metabucket keys individually so as
    not to inadvertently overwrite the entire metabucket.

DEV-3715
2019-02-05 16:01:59 -05:00
Joseph Frazer a2d1ea706a [DEV-4338] Change behavior of default data
Default data was converted to an empty array if the data evaluated to
false. We only want to convert it if it is undefined so values that are
false remain false.
2019-02-04 08:09:19 -05:00
Mike Gerwitz e4047b52cc src/css/base.css: Style Accordion group
Note that this permits animation if you just add:

  transition: transform 0.25s;

for example to `dt.stack-header::before'.  I didn't add that because nothing
else is animated atm, and so it seems out-of-place.

* src/css/base.css: Add styling for Accordion group.

DEV-3989
2019-01-17 12:10:10 -05:00
Mike Gerwitz 2ecaeb568b Add basic Accordion group extending Stacked group
* src/client/ClientDependencyFactory.js: Remove old AccordionGroupUi
    require, add new one.
* src/ui/group/AccordionGroupUi.js: New class.
* src/ui/group/GroupUi.js (postAddRow): Make virtual.
2019-01-17 12:10:09 -05:00
Mike Gerwitz 6b3ab89e77 dapi: Fix *_label setting
The `*_label' fields were not being properly set because they were being
considered just as every other expanded field, which is subject to other
considerations to ensure that we do not overwrite user data.  Label fields,
on the other hand, _must_ always be set whenever the value changes, and are
_not_ modifiable by the user.

This codifies that `_label' assumption that I would like removed in the
future, but time does not permit that sort of refactoring right
now.  Ideally, labels would be treated generically like any other expanded
field and have an attribute set of them that would change their expansion
behavior.

* src/client/dapi/DataApiMediator.js (_updateFieldData): Pass label field id
    to `_populateWithMap'.
  (_populateWithMap): Use it to always populate the label field when the key
    matches, ignoring the other expansion criteria that would inhibit it.
* test/client/dapi/DataApiMediatorTest.js: Update test accordingly.
* src/dapi/DataApiManager.js (triggerFieldUpdate): Provide id to
    `_genUiFieldData'.
  (_genUiFieldData)[label_id]: New field.  Return it as part of the return
    object's `label_id' field.

DEV-4077
2018-12-17 13:32:00 -05:00
Joseph Frazer b037339bce [DEV-3731] Change visibility of postProcessResults method
The postProcessResults method occasionally failed to be overridden in
local environments due to issues with how npm handled its dependencies.
For some reason, changing this to a public method corrected the issue. I
am changing this to, hopefully, prevent future frustrations.
2018-11-29 11:33:42 -05:00
Mike Gerwitz f9f7cebce7 Accommodate ancient qtype data on init and clean
* src/program/ProgramInit.js (_isKnownType): Account for ancient qtype
    representation (as a string).
* src/server/quote/ProgramQuoteCleaner.js (_isKnownType): Likewise.
* test/program/ProgramInitTest.js: New test case for this situation.
* test/server/quote/ProgramQuoteCleanerTest.js: Modify existing test case
    for this situation.
2018-11-19 11:10:16 -05:00
Mike Gerwitz e3b73f3b36 TabbedBlockGroupUi: Ignore default index selection if missing
If only one supplier returns this datum and that supplier is ineligible,
then the value may not exist if this is not defined as an external
value.  (Really, that's the bigger problem, but let's be resilient.)

* src/ui/group/TabbedBlockGroupUi.js (visit): Ignore missing index value.
2018-11-14 11:53:02 -05:00
Mike Gerwitz ecdfea5cdb ProgramInit: Do not initialize bucket values for undefined question types
These denote fields that are generated but do not actually have any data
associated with them.  For example, select options with predicates have a
field generated so that they contribute to the group field count (so that
the group will automatically show/hide appropriately), but those should
never have values associated with them in the bucket.

This was manifesting as a nasty bug:  The bucket contained a key for
generated options.  When the quote is loaded, the client "empties" the
bucket.  In doing so, it set the option value to the empty string, which had
the effect of rendering the dropdown useless---every value was the empty
string!

* src/program/ProgramInit.js (_isKnownType): New method.
  (init): Use it and ignore fields with unknown types.
* src/server/Server.js: Add note that we shouldn't have this logic
  duplicated between ProgramInit and ProgramQuoteCleaner.
* src/server/quote/ProgramQuoteCleaner.js (_fixGroup): Ignore fields with
    unknown types.
  (_isKnownType): New method.
* test/program/ProgramInitTest.js: Update existing tests.  Add new.
* test/server/quote/ProgramQuoteCleanerTest.js: Test this case.
2018-11-14 11:52:52 -05:00
Joseph Frazer 85ac34ebbd [DEV-3866] allow checkboxes to be unchecked 2018-11-06 11:51:22 -05:00
Joseph Frazer a3b5dd286f [DEV-3866] handle checkbox default values properly
The "checkbox" questions belong to the group of questions that change
the "checked" attribute rather than the "value" attribute.
2018-11-05 16:26:11 -05:00
Joseph Frazer a8d0b8c817 [DEV-3866] changes for new checkbox question type
The new checkbox question type is setup with an empty validator. When
checked, it was not unchecking because it was trying to behave like the
"noyes" questions. I updated the logic to not behave like that if there
is only one checkbox in a group.
2018-11-05 11:34:33 -05:00
Mike Gerwitz 2bc1b96a15 ProgramQuoteCleaner: Clean all groups (not just linked)
* src/server/quote/ProgramQuoteCleaner.js (clean): Add docblock.
    Replace previous linked group cleaning with call to `_fixGroup'.
  (_fixGroup): New method.  Similar logic to previous linked group cleaning,
    except that fields are never truncated.
  (_fixLinkedGroups, _getLinkedIndexLength): Remove methods.
  (_getGroupLength): New method determining group size from leader length,
    which also accounts for linked groups.
* test/server/quote/ProgramQuoteCleanerTest.js: New test case.
2018-10-21 23:41:58 -04:00
Mike Gerwitz 27cc3d2c63 Program#cmatchCheck: Add more informative third argument
* src/program/Program.js (cmatchCheck)[cdata]: New argument to try to disambiguate
    empty indexes while maintaining BC with existing quirky behavior.
2018-10-16 10:28:19 -04:00
Joseph Frazer 0a01456a46 [DEV-3284] Remove references to "LoVullo" 2018-09-27 10:07:08 -04:00
Joseph Frazer aed5ddd1b7 Revert "[DEV-3011] Add validation and style for datalists"
This reverts commit 394dde7de7.
2018-09-24 11:03:30 -04:00
Joseph Frazer e17ace40ed Revert "[DEV-3011] Do not use "Number" validator for datalists."
This reverts commit e064378c99.
2018-09-24 11:03:27 -04:00
Joseph Frazer e064378c99 [DEV-3011] Do not use "Number" validator for datalists. 2018-09-12 13:50:52 -04:00
Joseph Frazer 394dde7de7 [DEV-3011] Add validation and style for datalists 2018-09-12 12:29:40 -04:00