270 Commits

Author SHA1 Message Date
0da43b0411 Fix iterating over non-filtered array 2019-08-13 10:01:23 +07:00
1289913d06 Add ability to generate interfaces 2019-08-13 09:23:28 +07:00
d06781277a Add ability to get definitions from types exported from modules 2019-08-13 09:12:28 +07:00
877024ec8c Add TODO comment 2019-08-13 08:10:41 +07:00
e3232882aa Add support for type aliases, restructure 2019-08-12 21:32:09 +07:00
d1072031d6 Filter out strings and numbers 2019-08-12 14:14:50 +07:00
3ba279a0ab Clean up comments 2019-08-12 12:34:37 +07:00
aa78b12e54 Add ability to filter out duplicate and generic parameter types
This should make it easier to generate interfaces and use the type
references.
2019-08-12 12:31:16 +07:00
3937778e06 Recursively expand type references 2019-08-12 11:29:12 +07:00
515232c458 Add getAllTypeParameters (not fully impl) 2019-08-12 09:50:24 +07:00
0ce76eb648 Add support for question tokens in typecheck.ts 2019-08-12 09:08:13 +07:00
e55738f547 Remove unused comments from typecheck.ts
TODO: figure out how to determine locations of used:

a) interfaces
b) type aliases
c) union types
d) complex types like Array<MyType>

There should be two scenarios:

a) Type is imported from a library
b) Type is imported from an adjacent module
c) Type is privately declared in current module
2019-08-11 23:14:16 +07:00
472c7b3574 Figure out how to determine class type parameters 2019-08-11 22:19:49 +07:00
d7b2ad7a38 Add typecheck.ts
This uses TypeScript's TypeChecker to determine the types and the code
is a little cleaner, but still needs a lot of work:

- Determine how to figure out class type parameters
2019-08-11 22:03:06 +07:00
7a26d5c0f1 Add support for type parameters/arguments 2019-08-11 21:37:03 +07:00
d22f38ec92 Add TODO for typed parameters 2019-08-11 14:41:12 +07:00
fb4bb7b61b Add ability to process literals, type defs and interfaces 2019-08-11 14:36:27 +07:00
4f90e865fa Use experimental Typescript API to process class defs
The goal is to generate reusable interfaces from entity definitions.
While class definitions could be made to implement interfaces, this
seems like too much work at this point.
2019-08-11 13:17:08 +07:00
19565563cc Add Contextual<Service, Context> type
As seen in TeamService2.ts, the Contextual type will add Context as the
last argument to any method of the interface, as long as the method has
0-4 arguments.

Interfaces with more than 4 arguments cannot use this type, but they
could be converted to interfaces which use 1 argument
(object/dictionary) only.

Some long-term thinking: Maybe only methods with a single argument
should be supported, similar to the way gRPC does it.
2019-08-07 22:37:48 +07:00
cc2f5f58e2 Add ability to specify jsonrpc context as extra argument
In this case the interface does not define context, but the implementing
service may use it as an optional argument:

  interface IService {
    add(a: number, b: number): number
  }

  class Service implements IService {
    add(a: number, b: number, ctx?: IContext): number {
      return a + b + ctx!.userId
    }
  }
2019-08-06 20:10:38 +07:00
b617069784 Add packages/services/src/services/TeamService2.ts
A few notes:

1) The context higher-order function will be tedious to define - a lot
   more typing than just an extra function argument.
2) As some methods do not require the context function, forgetting to
   call it might introduce bugs (await fn will not error out), but
   compile checks of the return value type might detect this

Possible solution is to go the GRPC way and allow only a single method
type as a parameter so all server-side method types would look like:

  async fn(param: IParam, context: Context) {}

and all client-side method types would look like:

  async fn(param: IParam) {}

However, This would deviate from the JSON-RPC standard which allows
multiple arguments to be passed in an array.

Alternatively, context could be passed as a first argument and then
filtered out:

  type Arguments<T> = T extends (context: Ctx, ...args: infer A) => infer R
    ? A
    : never

In this case, the type of Ctx would need to be known in advance. Will
have to think about this some more.
2019-08-06 19:26:11 +07:00
a057ca97d5 Automatically print help 2019-08-06 18:29:58 +07:00
10ca503e59 Add script to create new package from template 2019-08-06 15:40:16 +07:00
87d515d89b Add help for positional arguments 2019-08-06 11:37:44 +07:00
a1ac8880d4 Add ability to generate help text 2019-08-06 11:14:00 +07:00
8c399c1903 Add help function 2019-08-06 11:02:02 +07:00
b50dfb1455 Add support for positional args in @rondo/argparse 2019-08-05 22:56:40 +07:00
7ea1c34428 Use @rondo/argparse for build script 2019-08-05 22:25:49 +07:00
cea9bc0dd1 Add more tests for argparse 2019-08-05 22:07:37 +07:00
86e90d28bb Make express jsonrpc use a builder pattern 2019-08-05 21:07:46 +07:00
f3f6166aab Send 405 when GET request is not allowed 2019-08-05 21:07:46 +07:00
e2f6c5f798 Encode JSON-RPC GET request params as JSON 2019-08-05 21:07:46 +07:00
81225b77a8 Implement GET method for idempotent methods 2019-08-05 21:07:46 +07:00
7edbe354a9 Remove TODO from jsonrpc 2019-08-05 21:07:46 +07:00
9a156fea16 Add ability to process short flags (untested) 2019-08-05 20:26:39 +07:00
47859ffa34 Add packages/argparse 2019-08-05 18:11:46 +07:00
15d54639ab Move ILogger to @rondo/common 2019-08-04 13:15:33 +07:00
aeb208162f Refactor express#handleError 2019-08-04 13:02:01 +07:00
e6a98bb450 Add ability to call idempotent methods via GET request 2019-08-04 10:19:42 +07:00
c273c1b914 Extract jsonrpc functionality into a separate file 2019-08-04 10:08:06 +07:00
745834848f Add createMigration task 2019-08-02 22:39:04 +07:00
3690908918 Add exec script command 2019-08-02 20:46:23 +07:00
41c5022f32 Add rondo test command 2019-08-02 20:30:44 +07:00
4c3570a9ce Do not extend/modify existing entities
Typeorm loads all @Entities and decorator-defined relations into a
global variable, and thus makes it impossible to override already
defined variables.

Will have to think about how to disable this behaviour in case the user
of this library does not want to use predefined variables, but for now
we will use the predefined defaults.
2019-08-02 20:17:10 +07:00
a6649def72 Add packages/server/src/database/DB.ts 2019-08-02 17:05:36 +07:00
d2a9d6faf6 Add log message when killing subprocess 2019-08-02 09:21:38 +07:00
9d35984033 Add frontend build scripts 2019-08-02 09:11:52 +07:00
1cb41e4b4a Move types to types.ts, rename some types 2019-08-02 08:27:53 +07:00
9aba9000b7 Rename createReduxClient to createActions 2019-08-01 20:01:30 +07:00
daf32de431 Add test for missing method 2019-08-01 19:55:30 +07:00