diff --git a/CHANGELOG.md b/CHANGELOG.md index 84efd4816f..6774df35cb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,17 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +## [5.0.1](https://github.com/feathersjs/feathers/compare/v5.0.0...v5.0.1) (2023-03-15) + +### Bug Fixes + +- **core:** Add PaginationParams to general find method ([#3095](https://github.com/feathersjs/feathers/issues/3095)) ([8ebdcf5](https://github.com/feathersjs/feathers/commit/8ebdcf5107fae5fa23920390052b871033de3a0a)) +- **core:** Use Symbol.for to instantiate shared symbols ([#3087](https://github.com/feathersjs/feathers/issues/3087)) ([7f3fc21](https://github.com/feathersjs/feathers/commit/7f3fc2167576f228f8183568eb52b077160e8d65)) +- **generators:** Conditionally import channels in Express app ([#3106](https://github.com/feathersjs/feathers/issues/3106)) ([c2dbaaa](https://github.com/feathersjs/feathers/commit/c2dbaaa4d1d5a5675b5812a7ed2317076ac414fe)) +- **koa:** Replace koa-bodyparser with koa-body ([#3093](https://github.com/feathersjs/feathers/issues/3093)) ([2456bf8](https://github.com/feathersjs/feathers/commit/2456bf882c99ae2cddd1a39bffba7e61217fc055)) +- **memory/mongodb:** $select as only property & force 'id' in '$select' ([#3081](https://github.com/feathersjs/feathers/issues/3081)) ([fbe3cf5](https://github.com/feathersjs/feathers/commit/fbe3cf5199e102b5aeda2ae33828d5034df3d105)) +- **transport-commons:** Fix dispatching of arrays ([#3075](https://github.com/feathersjs/feathers/issues/3075)) ([98fdda5](https://github.com/feathersjs/feathers/commit/98fdda53187acee88137b39662c766cc62cd7b55)) + # [5.0.0](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.38...v5.0.0) (2023-02-24) ### Bug Fixes diff --git a/README.md b/README.md index 4aaa84b45c..09d1d93d31 100644 --- a/README.md +++ b/README.md @@ -26,10 +26,6 @@ $ npm run dev To learn more about Feathers visit the website at [feathersjs.com](http://feathersjs.com) or jump right into [the Feathers guides](https://feathersjs.com/guides/). -# Documentation - -The [Feathers website](http://feathersjs.com) are loaded with awesome stuff and tell you every thing you need to know about using and configuring Feathers. - # License Copyright (c) 2023 [Feathers contributors](https://github.com/feathersjs/feathers/graphs/contributors) diff --git a/docs/api/channels.md b/docs/api/channels.md index 7cb18c77f7..325e7c07a9 100644 --- a/docs/api/channels.md +++ b/docs/api/channels.md @@ -33,7 +33,7 @@ Here are some example logic conditions where channels are useful: ## Concepts -A **_channel_** is basically an array of **_connection_** objects. Each array is explicitly given a name. When using a real-time server transport and a new client connects, the you can tell the server to explicitly add that client's connection object to any relevant channels. Any connection in a channel will receive all events that are sent to that channel. This allows clients to receive only their intended messages. +A **_channel_** is basically an array of **_connection_** objects. Each array is explicitly given a name. When using a real-time server transport and a new client connects, you can tell the server to explicitly add that client's connection object to any relevant channels. Any connection in a channel will receive all events that are sent to that channel. This allows clients to receive only their intended messages. When using a real-time transport, the server pushes events (such as "created", "removed" etc. for a particular service) down to its clients. Using channels allows customizing which clients should receive each event. The client doesn’t subscribe to individual channels, directly, but rather subscribes to specific events like `created`, `patched`, custom events, etc, in which they are interested. Those events will only fire for a client if the server pushes data to one a channel to which the client has been added. diff --git a/docs/api/client.md b/docs/api/client.md index 3e38bdf4ce..1be860cdea 100644 --- a/docs/api/client.md +++ b/docs/api/client.md @@ -11,7 +11,7 @@ In order to connect to a Feathers server, a client creates [Services](./services Modules most relevant on the client are: - `@feathersjs/feathers` to initialize a new Feathers [application](./application.md) -- [@feathersjs/rest-client](./client/rest.md) to connect to services through REST HTTP provided by [Koa](./koa.md) or [Epress](./express.md). +- [@feathersjs/rest-client](./client/rest.md) to connect to services through REST HTTP provided by [Koa](./koa.md) or [Express](./express.md). - [@feathersjs/socketio-client](./client/socketio.md) to connect to services through [Socket.io](./socketio.md). - [@feathersjs/authentication-client](./authentication/client.md) to authenticate a client @@ -122,7 +122,7 @@ No additional setup should be necessary to use the Feathers client modules in a ### create-react-app -[create-react-app](https://github.com/facebookincubator/create-react-app) uses [Webpack](#webpack) and also no longer requires additional setup to load the individual Feathers clietn modules. +[create-react-app](https://github.com/facebookincubator/create-react-app) uses [Webpack](#webpack) and also no longer requires additional setup to load the individual Feathers client modules. ### Others diff --git a/docs/api/databases/mongodb.md b/docs/api/databases/mongodb.md index 542f1dd3db..0c53207c67 100644 --- a/docs/api/databases/mongodb.md +++ b/docs/api/databases/mongodb.md @@ -435,6 +435,12 @@ The `ObjectIdSchema` helper will only work when the [`objectid` AJV keyword](#aj While the AJV format checks if an object id is valid, it still needs to be converted to the right type. An alternative the the [AJV converter](#ajv-converter) is to use [Feathers resolvers](../schema/resolvers.md). The following [property resolver](../schema/resolvers.md) helpers can be used. +
+ +ObjectId resolvers do not need to be used when using the [AJV keyword](#ajv-keyword). They are useful however when using another JSON schema validation library. + ++ #### resolveObjectId `resolveObjectId` resolves a property as an object id. It can be used as a direct property resolver or called with the original value. diff --git a/docs/api/express.md b/docs/api/express.md index bb7ceb3e89..7901fea755 100644 --- a/docs/api/express.md +++ b/docs/api/express.md @@ -30,7 +30,7 @@ const app = express(feathers())
-As of Feathers v5, [Koa](./koa.md) is the recommended framework integration since it is more modern, faster and easier to use. When chosen explicitly, you should be already familiar [Express](http://expressjs.com/en/guide/routing.html). +As of Feathers v5, [Koa](./koa.md) is the recommended framework integration since it is more modern, faster and easier to use. When chosen explicitly, you should already be familiar with [Express](http://expressjs.com/en/guide/routing.html).diff --git a/docs/api/koa.md b/docs/api/koa.md index d84dea6dbc..8fb5fe3bda 100644 --- a/docs/api/koa.md +++ b/docs/api/koa.md @@ -253,7 +253,7 @@ app.use( ### bodyParser -A reference to the [koa-bodyparser](https://github.com/koajs/bodyparser) module. +A reference to the [koa-body](https://github.com/koajs/koa-body) module. ### cors diff --git a/docs/api/schema/resolvers.md b/docs/api/schema/resolvers.md index 6a74a7ed0b..ffcbfd088e 100644 --- a/docs/api/schema/resolvers.md +++ b/docs/api/schema/resolvers.md @@ -227,11 +227,11 @@ app.service('users').hooks({ ### resolveResult -Result resolvers use the `schemaHooks.resolveResult(...resolvers)` hook and resolve the data that is returned by a service call ([context.result](../hooks.md#context-result) in a hook). This can be used to populate associations or add other computed properties etc. It is possible to pass multiple resolvers which will run in the order they are passed, using the previous data. `schemaHooks.resolveResult` can be used as an `around` and `after` hook. +Result resolvers use the `schemaHooks.resolveResult(...resolvers)` hook and resolve the data that is returned by a service call ([context.result](../hooks.md#context-result) in a hook). This can be used to populate associations or add other computed properties etc. It is possible to pass multiple resolvers which will run in the order they are passed, using the previous data.
-Use as an `around` hook is recommended since this will ensure that database adapters will be able to handle [$select queries](../databases/querying.md#select) properly when using [virtual properties](#virtual-property-resolvers). +`schemaHooks.resolveResult` must be used as an `around` hook. This is to ensure that the database adapters will be able to handle [$select queries](../databases/querying.md#select) properly when using [virtual properties](#virtual-property-resolvers).diff --git a/docs/api/schema/typebox.md b/docs/api/schema/typebox.md index d7969b6e1a..2c6b888930 100644 --- a/docs/api/schema/typebox.md +++ b/docs/api/schema/typebox.md @@ -1452,11 +1452,81 @@ Omitting this keyword has the same behavior as an empty object. ### Extended -In addition to JSON schema types, TypeBox provides several extended types that allow for the composition of `function` and `constructor` types. These additional types are not valid JSON Schema and will not validate using typical JSON Schema validation. However, these types can be used to frame JSON schema and describe callable interfaces that may receive JSON validated data. These types are as follows. +In addition to JSON schema types, TypeBox provides several extended types that allow for the composition of `function` and `constructor` types. These additional types are not valid JSON Schema and will not validate using typical JSON Schema validation. However, these types can be used to frame JSON schema and describe callable interfaces that may receive JSON validated data. Since these are nonstandard types, most applications will not need them. Consider using the [Standard Types](#standard), instead, as using these types may make it difficult to upgrade your application in the future. #### Extended Configuration -Utilities in this section require updating `src/schemas/validators.ts` to the [Extended Ajv Configuration](https://github.com/sinclairzx81/typebox#ajv) shown in the Typebox documentation. +Utilities in this section require updating `src/schemas/validators.ts` to the Extended Ajv Configuration, as shown here: + +```ts +import { TypeGuard } from '@sinclair/typebox/guard' +import { Value } from '@sinclair/typebox/value' +import { Type } from '@sinclair/typebox' +import addFormats from 'ajv-formats' +import Ajv from 'ajv' + +function schemaOf(schemaOf: string, value: unknown, schema: unknown) { + switch (schemaOf) { + case 'Constructor': + return TypeGuard.TConstructor(schema) && Value.Check(schema, value) // not supported + case 'Function': + return TypeGuard.TFunction(schema) && Value.Check(schema, value) // not supported + case 'Date': + return TypeGuard.TDate(schema) && Value.Check(schema, value) + case 'Promise': + return TypeGuard.TPromise(schema) && Value.Check(schema, value) // not supported + case 'Uint8Array': + return TypeGuard.TUint8Array(schema) && Value.Check(schema, value) + case 'Undefined': + return TypeGuard.TUndefined(schema) && Value.Check(schema, value) // not supported + case 'Void': + return TypeGuard.TVoid(schema) && Value.Check(schema, value) + default: + return false + } +} + +export function createAjv() { + return addFormats(new Ajv({}), [ + 'date-time', + 'time', + 'date', + 'email', + 'hostname', + 'ipv4', + 'ipv6', + 'uri', + 'uri-reference', + 'uuid', + 'uri-template', + 'json-pointer', + 'relative-json-pointer', + 'regex' + ]) + .addKeyword({ type: 'object', keyword: 'instanceOf', validate: schemaOf }) + .addKeyword({ type: 'null', keyword: 'typeOf', validate: schemaOf }) + .addKeyword('exclusiveMinimumTimestamp') + .addKeyword('exclusiveMaximumTimestamp') + .addKeyword('minimumTimestamp') + .addKeyword('maximumTimestamp') + .addKeyword('minByteLength') + .addKeyword('maxByteLength') +} + +const ajv = createAjv() + +const R = ajv.validate(Type.Object({ // const R = true + buffer: Type.Uint8Array(), + date: Type.Date(), + void: Type.Void() +}), { + buffer: new Uint8Array(), + date: new Date(), + void: null +}) +``` + +If you see an error stating `Error: strict mode: unknown keyword: "instanceOf"`, it's likely because you need to extend your configuration, as shown above. #### Constructor @@ -1616,3 +1686,5 @@ Use `Type.Ref(...)` to create referenced types. The target type must specify an const T = Type.String({ $id: 'T' }) const R = Type.Ref(T) ``` + +For a more detailed example see the [result and data schema](#result-and-data-schemas) section. diff --git a/docs/guides/basics/starting.md b/docs/guides/basics/starting.md index 8d35b67ac5..7765c4a8cd 100644 --- a/docs/guides/basics/starting.md +++ b/docs/guides/basics/starting.md @@ -380,7 +380,7 @@ In the same folder, add the following `index.html` page: