3173 Commits

Author SHA1 Message Date
daffl
2dc8c8b235 feat(cli): Feathers Cloud integration 2022-12-16 12:01:57 -08:00
David Luecke
e3cedc8e00
fix(cli): Add unhandledRejection handler to generated index file (#2932) 2022-12-15 15:21:28 -08:00
daffl
3189c26dba chore: Update changelog 2022-12-14 11:41:50 -08:00
daffl
42cca600d0 chore(release): publish v5.0.0-pre.34 2022-12-14 11:40:34 -08:00
David Luecke
7088af64a5
feat(cli): Use separate patch schema and types (#2916) 2022-12-14 11:18:46 -08:00
David Luecke
df569183d1
fix(core): Allow services with no external methods (#2921) 2022-12-13 08:45:54 -08:00
philipimperato
d9449fa835
fix(schema): Check for undefined value in resolveQueryObjectId resolver (#2914) 2022-12-11 15:44:27 -08:00
fratzinger
d606ac660f
fix(core): context.type for around hooks (#2890) 2022-12-09 09:46:09 -08:00
David Luecke
801a503425
fix(authentication): Fix order of connection and login event handling (#2909) 2022-12-08 13:37:02 -08:00
Marshall Thompson
142914fc00
feat(docs): CLI and application structure guide (#2818) 2022-12-08 11:55:18 -08:00
David Luecke
9f712bf569
chore(dependencies): Update all dependencies (#2901) 2022-12-06 11:54:13 -08:00
David Luecke
9ddc2e6b02
feat(adapter): Add patch data type to adapters and refactor AdapterBase usage (#2906) 2022-12-05 22:06:41 -08:00
David Luecke
b66c734357
fix(schema): Allow query schemas with no properties, error on unsupported types (#2904) 2022-12-05 16:57:45 -08:00
Nils Bergmann
4ff1ed084e
fix(adapter-commons): multiple type definition issues (#2876) 2022-12-04 09:07:24 -08:00
David Luecke
7d03b57ae2
feat(schema): Virtual property resolvers (#2900) 2022-12-03 10:05:11 -08:00
David Luecke
164d75c0f1
fix(core): Improve service option usage and method option typings (#2902) 2022-12-02 09:07:45 -08:00
David Luecke
4ba0039078
fix(socketio): Disconnect socket on app disconnect event (#2896) 2022-11-27 15:05:16 -08:00
David Luecke
9db5e7adb0
fix(authentication-client): Improve socket reauthentication handling (#2895) 2022-11-27 09:28:29 -08:00
David Luecke
cfc6c7a6b9
fix(authentication-client): Remove access token for fatal 400 errors (#2894) 2022-11-25 13:07:37 -08:00
David Luecke
cc4e76726f
fix(authentication-client): Do not cache authentication errors (#2892) 2022-11-24 15:57:03 -08:00
David Luecke
4822c94981
feat(schema): Split resolver options and property resolvers (#2889) 2022-11-23 17:04:37 -08:00
David Luecke
59f3cdca63
fix(typebox): Improve query syntax defaults (#2888) 2022-11-23 17:04:28 -08:00
David Luecke
bddce89079
chore(tests): Fix Express application test (#2891) 2022-11-23 16:43:53 -08:00
David Luecke
5696000561
chore(tests): Add tracing information to debug flaky CLI test 2022-11-22 10:56:41 -08:00
Marshall Thompson
7fa2012897
fix(cli): mongodb connection string for node 17+ (#2875) 2022-11-18 13:48:25 -08:00
daffl
bffb634dec chore: Update changelog 2022-11-07 20:15:54 -08:00
daffl
89f516bcb1 chore(release): publish v5.0.0-pre.33 2022-11-07 20:14:53 -08:00
David Luecke
6853277e1f
chore: Edit Readme and contribution templates (#2866) 2022-11-07 20:12:03 -08:00
Marshall Thompson
742e5b8256
docs(styles): Fix home footer (#2855) 2022-11-04 22:58:45 -07:00
David Luecke
bae5176488
fix(cli): Use proper MSSQL client (#2853) 2022-11-04 21:44:53 -07:00
David Luecke
c5c1fba571
feat(mongodb): Add ObjectId resolvers and MongoDB option in the guide (#2847) 2022-11-04 21:10:58 -07:00
Marshall Thompson
cb70e0778e
feat(mongodb) aggregation pipeline queries (#2840)
* feat(mongodb) aggregation pipeline queries

Makes queries using the MongoDB Aggregation Pipeline, by default, unless either of these conditions is met:

- `params.mongodb` is provided. This object is for the `collection.find` method, and won’t work for `collection.aggregate`.
- `params.query.$limit` is set to `0`. The aggregation pipeline will not accept 0 as a value for the `$limit` stage.

## Updates to `service.find`

The `find` method has been updated so that queries not meeting the two criteria, above, are created using the aggregation pipeline, which is an array of the document objects representing the stages of the request. Here’s an example query:

```ts
app.service(‘todos’).find({
  query: {
    $sort: { name: 1 },
    $skip: 1,
    $limit: 4
  }
})

// the internal aggregation request looks like this
const query = collection.aggregate([
  { $match: {} },
  { $sort: { name: 1 } },
  { $skip: 1 },
  { $limit: 4 },
  …params.pipeline || []
])
```

## New `pipeline` param

Notice that it’s now possible to pass `params.pipeline`.  This means you can set params.pipeline as an array of additional stages in the aggregation pipeline and they will be executed during the same request.  This means that it’s now possible to perform `$lookup` and `$unwind` stages alongside the normal Feathers queries.

## Feathers Query with `params.pipeline`

This example shows how to populate the `user` onto a query for `todos`, assuming that each `todo` contains a `userId` property.

```ts
const result = await app.service('todos').find({
  query: { $sort: { name: 1 } },
  pipeline: [
    {
      $lookup: {
        from: ‘users’,
        localField: 'userId',
        foreignField: '_id',
        as: ‘user’
      }
    },
    { $unwind: { path: '$user’ } }
  ],
  paginate: false
})
```

In the above example, the `query` is added to the pipeline, first (under the hood) then additional stages are added in the `pipeline` option:

- The `$lookup` stage creates an array called `user` which contains any matches in `todo.userId`, so if `userId` were an array of ids, any matches would be in the `users` array.  However, in this example, the `userId` is a single id, so…
- The `$unwind` stage turns the array into a single object.

All stages of the pipeline happen directly on the MongoDB server.

## Custom `.aggregate` requests

It’s still possible to make `.aggregate` requests without the Feathers syntax by directly accessing `service.model`:

```ts
const result = await app.service(‘todos’).model.aggregate([
   // …stages go here
]).toArray()
```

* refactor(mongodb): decouple find logic, getModel

Splits the `find` method into two utilities for converting params into MongoDB requests:

- `asFindQuery`
- `asAggregateQuery`

Each of the above methods returns the raw MongoDB request object, without having called `.toArray`, so it’s likely also possible to directly use MongoDB cursors on the returned object, though I’ve not added a test for such a use case.

This PR also optimizes the `find` method to parallelize the `count` query (for pagination) and the `results` query.  This makes it so we don’t have to wait for the count before we start querying the results.

One more thing: this PR also combines non-DRY code that was found in every method into a single `getModel` method.

* feat(mongodb) control stages with $feathers stage

A custom `$feathers` stage has been added to our wrapper for the MongoDB aggregation pipeline.  It allows you to specify where in the pipeline the Feathers-related stages get injected.  This means you can now specify for some pipeline operations to run BEFORE the ones related to the Feathers query.

The `$feathers` stage is an object optionally containing a `handleStages` function.  The `handleStages` function receives the Feathers stages and allows them to be modified.  It’s a feature that will only be used in complex, modular/layered queries, since it would usually be simpler to just modify the incoming query before passing it to `service.find`.

* refactor(mongodb) rename utils and combine methods

- rename `asFindQuery` to `findRaw`
- rename `asAggregateQuery` to `aggregateRaw`
- combine the `makePipeline` method into the `aggregateRaw` method,

* docs(mongodb) document aggregation queries

* feat(mongodb) remove handleStages from aggregation
2022-11-04 15:58:35 -06:00
Beau Shaw
d6ee5f1c86
fix(memory): Use for loop in _find() for better performance (#2844) 2022-11-03 12:26:58 -07:00
Nicholas Whitney
50e7463971
fix(cli): Fix MongoDB connection database name parsing (#2845) 2022-11-03 11:50:36 -07:00
Marshall Thompson
65d36656f5
feat(schema): Add StringEnum to TypeBox module (#2827) 2022-11-03 11:50:04 -07:00
David Luecke
8b89c8bab5
chore(dependencies): Update all dependencies (#2841) 2022-11-03 11:49:33 -07:00
David Luecke
68cf03f092
fix(docs): Add JavaScript web app frontend guide (#2834) 2022-10-27 09:42:32 -07:00
daffl
8c6f2efa9d chore: Update changelog 2022-10-25 21:11:31 -07:00
daffl
b405e205fc chore(release): publish v5.0.0-pre.32 2022-10-25 21:10:10 -07:00
David Luecke
ed3b05051d
fix(schema): Use the same options for resolveData hook (#2833) 2022-10-25 17:54:12 -07:00
David Luecke
0776e26bfe
fix(cli): Ensure code injection points are not code style dependent (#2832) 2022-10-25 09:26:15 -07:00
David Luecke
7d219d9c52
fix(cli): Only generate authentication setup when selected (#2823) 2022-10-21 08:33:06 -07:00
David Luecke
5fa900f90d
fix(schema): Improve resolver performance (#2822) 2022-10-20 16:56:46 -07:00
David Luecke
91920dfdbc
chore(docs): Review authentication API documentation (#2812) 2022-10-18 18:55:53 -07:00
David Luecke
dd77379d8b
fix(authentication): Improve logout and disconnect connection handling (#2813) 2022-10-18 16:23:22 -07:00
David Luecke
1b97f14d47
fix(docs): Review transport API docs and update Express middleware setup (#2811) 2022-10-18 08:09:28 -07:00
Marshall Thompson
ae85fa216f
feat(docs): New website and documentation pages (#2802)
* feat(docs) new docs site started

* Minor page edits

* feat(footer) fix spacing

* empty guides template

Co-authored-by: daffl <daff@neyeon.com>
2022-10-17 13:05:01 -06:00
David Luecke
0d5781a5c7
fix(transports): Add remaining middleware for generated apps to Koa and Express (#2796) 2022-10-15 13:29:19 -07:00
David Luecke
bd59f91b45
feat(cli): Add authentication client to generated client (#2801) 2022-10-15 13:14:38 -07:00
David Luecke
f394098d4e
chore(authentication-oauth): Add tests for oAuth default handling (#2795) 2022-10-15 10:54:26 -07:00