lumen-framework 3.0.3 → 3.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.cjs +70 -38
- package/dist/cli.cjs.map +4 -4
- package/dist/index.js +928 -259
- package/dist/index.js.map +4 -4
- package/dist/index.mjs +919 -250
- package/dist/index.mjs.map +4 -4
- package/dist/types/errors/namespaced-serializer-missing-error.d.ts +15 -0
- package/dist/types/packages/application/utils/validate-namespaced-serializers.d.ts +15 -0
- package/dist/types/packages/controller/errors/index.d.ts +1 -0
- package/dist/types/packages/controller/errors/related-record-not-found-error.d.ts +14 -0
- package/dist/types/packages/controller/index.d.ts +65 -0
- package/dist/types/packages/controller/utils/find-many.d.ts +2 -1
- package/dist/types/packages/controller/utils/find-one.d.ts +2 -1
- package/dist/types/packages/controller/utils/params-to-query.d.ts +7 -2
- package/dist/types/packages/controller/utils/validate-relationships.d.ts +8 -0
- package/dist/types/packages/database/constants.d.ts +1 -0
- package/dist/types/packages/database/model/index.d.ts +11 -0
- package/dist/types/packages/database/model/utils/process-write-error.d.ts +9 -1
- package/dist/types/packages/database/validation/errors/validation-error.d.ts +11 -2
- package/dist/types/packages/jsonapi/interfaces.d.ts +1 -1
- package/dist/types/packages/router/route/params/errors/client-generated-id-error.d.ts +13 -0
- package/dist/types/packages/router/route/params/errors/forbidden-parameter-error.d.ts +14 -0
- package/dist/types/packages/router/route/params/errors/index.d.ts +2 -0
- package/dist/types/packages/router/route/params/errors/invalid-parameter-error.d.ts +2 -0
- package/dist/types/packages/router/route/params/errors/parameter-not-nullable-error.d.ts +2 -0
- package/dist/types/packages/router/route/params/errors/parameter-required-error.d.ts +2 -0
- package/dist/types/packages/router/route/params/errors/parameter-type-error.d.ts +2 -0
- package/dist/types/packages/router/route/params/errors/parameter-value-error.d.ts +2 -0
- package/dist/types/packages/router/route/params/errors/resource-mismatch-error.d.ts +2 -0
- package/dist/types/packages/router/route/params/index.d.ts +1 -0
- package/dist/types/packages/router/route/params/parameter/forbidden-parameter.d.ts +12 -0
- package/dist/types/packages/router/route/params/parameter/index.d.ts +8 -0
- package/dist/types/packages/router/route/params/utils/validate-client-id.d.ts +8 -0
- package/dist/types/packages/serializer/index.d.ts +111 -36
- package/dist/types/packages/serializer/utils/include-tree.d.ts +29 -0
- package/dist/types/packages/serializer/utils/load-linkage.d.ts +22 -0
- package/dist/types/packages/server/index.d.ts +2 -1
- package/dist/types/packages/server/interfaces.d.ts +5 -0
- package/dist/types/packages/server/utils/source-for.d.ts +10 -0
- package/package.json +1 -1
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { Model, ModelClass } from '../../database';
|
|
2
|
+
import type Serializer from '../index';
|
|
3
|
+
/**
|
|
4
|
+
* A parsed `include` parameter: each relationship name maps to the tree of
|
|
5
|
+
* relationships to include from the records it points to.
|
|
6
|
+
*
|
|
7
|
+
* @private
|
|
8
|
+
*/
|
|
9
|
+
export type IncludeTree = Map<string, IncludeTree>;
|
|
10
|
+
/**
|
|
11
|
+
* Parse relationship paths (`['comments', 'comments.user', 'user']`) into an
|
|
12
|
+
* include tree. Every prefix of a path is part of the tree, because JSON:API
|
|
13
|
+
* requires the intermediate resources of a multi-part path to be included
|
|
14
|
+
* along with its leaves (`comments.user` includes the comments too).
|
|
15
|
+
*
|
|
16
|
+
* @private
|
|
17
|
+
*/
|
|
18
|
+
export declare function createIncludeTree(paths?: Array<string>): IncludeTree;
|
|
19
|
+
/**
|
|
20
|
+
* Enumerate every include path available from `names` (relationships of
|
|
21
|
+
* `model`), down to `depth` levels. Each level continues with the relationships
|
|
22
|
+
* declared by the related model's serializer as `serializerFor` resolves it —
|
|
23
|
+
* the same one its included resources are serialized with (namespaced, with a
|
|
24
|
+
* fallback to the root). Used to build the allowed values of the `include`
|
|
25
|
+
* parameter.
|
|
26
|
+
*
|
|
27
|
+
* @private
|
|
28
|
+
*/
|
|
29
|
+
export declare function enumerateIncludePaths(model: ModelClass, names: Array<string>, depth: number, serializerFor?: (model: ModelClass) => Serializer<Model> | undefined): Array<string>;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { Model, ModelClass } from '../../database';
|
|
2
|
+
/**
|
|
3
|
+
* The resource linkage of one record: the primary key(s) of the records each
|
|
4
|
+
* named relationship points to — an array for has-many, otherwise a single id
|
|
5
|
+
* or `null`.
|
|
6
|
+
*
|
|
7
|
+
* @private
|
|
8
|
+
*/
|
|
9
|
+
export type Linkage = Record<string, Array<string> | string | null>;
|
|
10
|
+
/**
|
|
11
|
+
* Batch-load the resource linkage of the relationships `names` for every one of
|
|
12
|
+
* `records` (all instances of `model`), keyed by each record's primary key.
|
|
13
|
+
*
|
|
14
|
+
* This is what lets included resources carry `relationships` without an N+1:
|
|
15
|
+
* it issues at most one query per relationship — and a single query for all
|
|
16
|
+
* belongs-to relationships, whose foreign keys live on `model` itself — however
|
|
17
|
+
* many records there are. The queries mirror the lazy relationship getters in
|
|
18
|
+
* `database/relationship/utils/getters.ts`, which remain the source of truth.
|
|
19
|
+
*
|
|
20
|
+
* @private
|
|
21
|
+
*/
|
|
22
|
+
export default function loadLinkage(model: ModelClass, records: Array<Model>, names: Array<string>): Promise<Map<string, Linkage>>;
|
|
@@ -22,6 +22,7 @@ declare class Server {
|
|
|
22
22
|
export default Server;
|
|
23
23
|
export { REQUEST_METHODS, getDomain } from './request';
|
|
24
24
|
export { default as createServerError } from './utils/create-server-error';
|
|
25
|
-
export
|
|
25
|
+
export { default as sourceFor } from './utils/source-for';
|
|
26
|
+
export type { Server$config, Server$ErrorSource } from './interfaces';
|
|
26
27
|
export type { Request, Request$params, Request$method } from './request/interfaces';
|
|
27
28
|
export type { Response } from './response/interfaces';
|
|
@@ -13,6 +13,11 @@ export type Server$opts = Server$config & {
|
|
|
13
13
|
logger: Logger;
|
|
14
14
|
router: Router;
|
|
15
15
|
};
|
|
16
|
+
export type Server$ErrorSource = {
|
|
17
|
+
pointer?: string;
|
|
18
|
+
parameter?: string;
|
|
19
|
+
};
|
|
16
20
|
export interface Server$Error extends Error {
|
|
17
21
|
statusCode: number;
|
|
22
|
+
source?: Server$ErrorSource;
|
|
18
23
|
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { Server$ErrorSource } from '../interfaces';
|
|
2
|
+
/**
|
|
3
|
+
* Map an internal parameter path to a JSON:API error `source`. Paths under
|
|
4
|
+
* `data` are request document members and become a JSON Pointer
|
|
5
|
+
* (`data.attributes.isPublic` -> `/data/attributes/is-public`); anything else
|
|
6
|
+
* is a query parameter (`page.size` -> `page[size]`).
|
|
7
|
+
*
|
|
8
|
+
* @private
|
|
9
|
+
*/
|
|
10
|
+
export default function sourceFor(path: string): Server$ErrorSource;
|