tsc handles its own incremental builds, and if a file is removed, it isn't
always regenerated. This resulted in a bad distribution being generated and
published to npm.
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.
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.
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.
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).
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.
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.
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.
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.
Rather than always providing an "Response data is not an array" error.
* src/dapi/RestrictedDataApi.js (_checkResponse)[err]: New first parameter.
(request): Use it.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.